Skip to content

Commit

Permalink
feat(core/create): adds extract
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Oct 13, 2019
1 parent f1e229d commit b39c5c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/create/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { default as application } from './application';
export { default as collection } from './collection';
export { default as scope } from './scope';
export { default as schema } from './schema';
export * from './scopes';
export * from './intercepts';
export * from './references';
export * from './services';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { CollectionTreeImplementation, ScopeTreeImplementation } from '~/types';
import { emptyCollection, emptyScope } from '~/utils';

export default function scope<
T extends CollectionTreeImplementation,
N extends string
>(
export function scope<T extends CollectionTreeImplementation, N extends string>(
name: N,
collection: T
): CollectionTreeImplementation<
Expand All @@ -22,3 +19,24 @@ export default function scope<
} as any
};
}

export function extract<
T extends CollectionTreeImplementation,
N extends keyof T['scopes']
>(
collection: T,
name: N & string
): CollectionTreeImplementation<
T['types'],
T['scopes'][N]['services'],
T['scopes'][N]['scopes']
> {
const { types } = collection;
const { services, scopes } = collection.scopes[name];
return {
...emptyCollection(),
types,
services,
scopes
};
}

0 comments on commit b39c5c6

Please sign in to comment.