Skip to content

Commit

Permalink
feat(core): adds explicit interfaces for create functions options
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Oct 13, 2019
1 parent b1a7606 commit f1e229d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
14 changes: 6 additions & 8 deletions packages/core/src/create/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
CollectionTreeImplementation,
CollectionTreeApplication,
CollectionTree,
TreeTypes
TreeTypes,
CreateApplicationOptions
} from '~/types';
import clone from 'lodash.clonedeep';
import { traverse, isElementType } from '~/utils';
Expand All @@ -12,14 +13,8 @@ import { mergeServiceTypes } from './merge';

export default function application(
collection: CollectionTree | CollectionTreeImplementation,
options?: {
prefixScope?: boolean;
prefixInlineError?: boolean;
transform?: (str: string, explicit: boolean) => string;
}
options?: CreateApplicationOptions
): CollectionTreeApplication {
collection = clone(collection);

const opts = Object.assign(
{
prefixScope: true,
Expand All @@ -29,6 +24,9 @@ export default function application(
options
);

// clone collection
collection = clone(collection);

const types = {
source: collection.types,
application: Object.entries(collection.types).reduce(
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/create/intercepts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
InputInterceptHook,
InterceptImplementation,
InputIntercept,
CollectionTreeImplementation
CollectionTreeImplementation,
CreateInterceptsOptions
} from '~/types';
import { from, Observable } from 'rxjs';
import { switchMap, mergeMap } from 'rxjs/operators';
Expand All @@ -17,7 +18,7 @@ import {
export function intercepts<T extends CollectionTreeImplementation>(
collection: T,
intercepts: InterceptImplementation[],
options?: { prepend?: boolean }
options?: CreateInterceptsOptions
): T {
collection = clone(collection);
const opts = Object.assign({ prepend: true }, options);
Expand Down
11 changes: 11 additions & 0 deletions packages/core/src/types/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ import {
import { Observable } from './observable';
import { Schema } from './schema';

// Options
export interface CreateApplicationOptions {
prefixScope?: boolean;
prefixInlineError?: boolean;
transform?: (str: string, explicit: boolean) => string;
}

export interface CreateInterceptsOptions {
prepend?: boolean;
}

// Collection
export type InputCollection =
| Partial<CollectionTree>
Expand Down

0 comments on commit f1e229d

Please sign in to comment.