@nrwl/angular 13.10.0-beta.7 → 13.10.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/esm2020/mfe/index.mjs +2 -2
  2. package/fesm2015/nrwl-angular-mfe.mjs +1 -1
  3. package/fesm2015/nrwl-angular-testing.mjs.map +1 -1
  4. package/fesm2015/nrwl-angular.mjs.map +1 -1
  5. package/fesm2020/nrwl-angular-mfe.mjs +1 -1
  6. package/fesm2020/nrwl-angular-testing.mjs.map +1 -1
  7. package/fesm2020/nrwl-angular.mjs.map +1 -1
  8. package/mfe/index.d.ts +1 -1
  9. package/mfe/index.js +2 -1
  10. package/mfe/index.js.map +1 -1
  11. package/package.json +6 -6
  12. package/src/builders/webpack-browser/schema.json +0 -15
  13. package/src/generators/application/lib/add-mfe.js +1 -0
  14. package/src/generators/application/lib/add-mfe.js.map +1 -1
  15. package/src/generators/application/schema.d.ts +1 -0
  16. package/src/generators/application/schema.json +6 -0
  17. package/src/generators/mfe-host/mfe-host.js +1 -0
  18. package/src/generators/mfe-host/mfe-host.js.map +1 -1
  19. package/src/generators/mfe-host/schema.d.ts +1 -0
  20. package/src/generators/mfe-host/schema.json +5 -0
  21. package/src/generators/ng-add/compat.d.ts +1 -1
  22. package/src/generators/ng-add/files/{root → root-karma}/karma.conf.js__tmpl__ +0 -0
  23. package/src/generators/ng-add/migrate-from-angular-cli.d.ts +2 -2
  24. package/src/generators/ng-add/migrate-from-angular-cli.js +38 -607
  25. package/src/generators/ng-add/migrate-from-angular-cli.js.map +1 -1
  26. package/src/generators/ng-add/ng-add.d.ts +3 -3
  27. package/src/generators/ng-add/ng-add.js +2 -2
  28. package/src/generators/ng-add/ng-add.js.map +1 -1
  29. package/src/generators/ng-add/schema.d.ts +1 -1
  30. package/src/generators/ng-add/utilities/app.migrator.d.ts +18 -0
  31. package/src/generators/ng-add/utilities/app.migrator.js +182 -0
  32. package/src/generators/ng-add/utilities/app.migrator.js.map +1 -0
  33. package/src/generators/ng-add/utilities/e2e-project.migrator.d.ts +19 -0
  34. package/src/generators/ng-add/utilities/e2e-project.migrator.js +186 -0
  35. package/src/generators/ng-add/utilities/e2e-project.migrator.js.map +1 -0
  36. package/src/generators/ng-add/utilities/e2e-utils.d.ts +7 -0
  37. package/src/generators/ng-add/utilities/e2e-utils.js +46 -0
  38. package/src/generators/ng-add/utilities/e2e-utils.js.map +1 -0
  39. package/src/generators/ng-add/utilities/get-all-projects.d.ts +3 -0
  40. package/src/generators/ng-add/utilities/get-all-projects.js +26 -0
  41. package/src/generators/ng-add/utilities/get-all-projects.js.map +1 -0
  42. package/src/generators/ng-add/utilities/normalize-options.d.ts +3 -0
  43. package/src/generators/ng-add/utilities/normalize-options.js +24 -0
  44. package/src/generators/ng-add/utilities/normalize-options.js.map +1 -0
  45. package/src/generators/ng-add/utilities/project.migrator.d.ts +21 -0
  46. package/src/generators/ng-add/utilities/project.migrator.js +53 -0
  47. package/src/generators/ng-add/utilities/project.migrator.js.map +1 -0
  48. package/src/generators/ng-add/utilities/types.d.ts +10 -0
  49. package/src/generators/ng-add/utilities/types.js +3 -0
  50. package/src/generators/ng-add/utilities/types.js.map +1 -0
  51. package/src/generators/ng-add/utilities/workspace.d.ts +12 -0
  52. package/src/generators/ng-add/utilities/workspace.js +258 -0
  53. package/src/generators/ng-add/utilities/workspace.js.map +1 -0
  54. package/src/generators/setup-mfe/lib/add-remote-to-host.d.ts +2 -2
  55. package/src/generators/setup-mfe/lib/add-remote-to-host.js +49 -23
  56. package/src/generators/setup-mfe/lib/add-remote-to-host.js.map +1 -1
  57. package/src/generators/setup-mfe/lib/fix-bootstrap.d.ts +2 -1
  58. package/src/generators/setup-mfe/lib/fix-bootstrap.js +13 -4
  59. package/src/generators/setup-mfe/lib/fix-bootstrap.js.map +1 -1
  60. package/src/generators/setup-mfe/lib/index.d.ts +1 -0
  61. package/src/generators/setup-mfe/lib/index.js +1 -0
  62. package/src/generators/setup-mfe/lib/index.js.map +1 -1
  63. package/src/generators/setup-mfe/lib/setup-host-if-dynamic.d.ts +3 -0
  64. package/src/generators/setup-mfe/lib/setup-host-if-dynamic.js +15 -0
  65. package/src/generators/setup-mfe/lib/setup-host-if-dynamic.js.map +1 -0
  66. package/src/generators/setup-mfe/schema.d.ts +1 -0
  67. package/src/generators/setup-mfe/schema.json +6 -0
  68. package/src/generators/setup-mfe/setup-mfe.d.ts +1 -1
  69. package/src/generators/setup-mfe/setup-mfe.js +16 -13
  70. package/src/generators/setup-mfe/setup-mfe.js.map +1 -1
  71. package/src/utils/versions.js +1 -1
  72. package/src/generators/ng-add/files/decorate-angular-cli/decorate-angular-cli.js__tmpl__ +0 -69
  73. package/src/generators/ng-add/files/root/nx.json__tmpl__ +0 -29
@@ -1,2 +1,2 @@
1
- export { setRemoteUrlResolver, loadRemoteModule } from './mfe';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9tZmUvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLG9CQUFvQixFQUFFLGdCQUFnQixFQUFFLE1BQU0sT0FBTyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgc2V0UmVtb3RlVXJsUmVzb2x2ZXIsIGxvYWRSZW1vdGVNb2R1bGUgfSBmcm9tICcuL21mZSc7XG4iXX0=
1
+ export { setRemoteUrlResolver, setRemoteDefinitions, loadRemoteModule, } from './mfe';
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9tZmUvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUNMLG9CQUFvQixFQUNwQixvQkFBb0IsRUFDcEIsZ0JBQWdCLEdBQ2pCLE1BQU0sT0FBTyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHtcbiAgc2V0UmVtb3RlVXJsUmVzb2x2ZXIsXG4gIHNldFJlbW90ZURlZmluaXRpb25zLFxuICBsb2FkUmVtb3RlTW9kdWxlLFxufSBmcm9tICcuL21mZSc7XG4iXX0=
@@ -53,5 +53,5 @@ function loadRemoteContainer(remoteName) {
53
53
  * Generated bundle index. Do not edit.
54
54
  */
55
55
 
56
- export { loadRemoteModule, setRemoteUrlResolver };
56
+ export { loadRemoteModule, setRemoteDefinitions, setRemoteUrlResolver };
57
57
  //# sourceMappingURL=nrwl-angular-mfe.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"nrwl-angular-testing.mjs","sources":["../../testing/src/testing-utils.ts","../../testing/index.ts","../../testing/nrwl-angular-testing.ts"],"sourcesContent":["import type { Observable } from 'rxjs';\nimport { first, toArray } from 'rxjs/operators';\n\n/**\n * @whatItDoes reads all the values from an observable and returns a promise\n * with an array of all values. This should be used in combination with async/await.\n *\n * ## Example\n *\n * ```typescript\n * const obs = of(1, 2, 3, 4);\n * const res = await readAll(obs)\n * expect(res).toEqual([1, 2, 3, 4]);\n * ```\n */\nexport function readAll<T>(o: Observable<T>): Promise<T[]> {\n return o.pipe(toArray()).toPromise();\n}\n\n/**\n * @whatItDoes reads the first value from an observable and returns a promise\n * with it. This should be used in combination with async/await.\n *\n * ## Example\n *\n * ```typescript\n * const obs = of(1, 2, 3, 4);\n * const res = await readFirst(obs)\n * expect(res).toEqual(1);\n * ```\n */\nexport function readFirst<T>(o: Observable<T>): Promise<T> {\n return o.pipe(first()).toPromise();\n}\n","import {\n cold as rxjsMarblesCold,\n hot as rxjsMarblesHot,\n getTestScheduler as rxjsMarblesTestScheduler,\n time as rxjsMarblesTime,\n} from 'jasmine-marbles';\n\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const cold = rxjsMarblesCold;\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const hot = rxjsMarblesHot;\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const getTestScheduler = rxjsMarblesTestScheduler;\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const time = rxjsMarblesTime;\n\nexport { readAll, readFirst } from './src/testing-utils';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["rxjsMarblesCold","rxjsMarblesHot","rxjsMarblesTestScheduler","rxjsMarblesTime"],"mappings":";;;AAGA;;;;;;;;;;;;SAYgB,OAAO,CAAI,CAAgB;IACzC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;;SAYgB,SAAS,CAAI,CAAgB;IAC3C,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;AACrC;;AC1BA;;;MAGa,IAAI,GAAGA,OAAgB;AACpC;;;MAGa,GAAG,GAAGC,MAAe;AAClC;;;MAGa,gBAAgB,GAAGC,mBAAyB;AACzD;;;MAGa,IAAI,GAAGC;;ACtBpB;;;;;;"}
1
+ {"version":3,"file":"nrwl-angular-testing.mjs","sources":["../../testing/src/testing-utils.ts","../../testing/index.ts","../../testing/nrwl-angular-testing.ts"],"sourcesContent":["import type { Observable } from 'rxjs';\nimport { first, toArray } from 'rxjs/operators';\n\n/**\n * @whatItDoes reads all the values from an observable and returns a promise\n * with an array of all values. This should be used in combination with async/await.\n *\n * ## Example\n *\n * ```typescript\n * const obs = of(1, 2, 3, 4);\n * const res = await readAll(obs)\n * expect(res).toEqual([1, 2, 3, 4]);\n * ```\n */\nexport function readAll<T>(o: Observable<T>): Promise<T[]> {\n return o.pipe(toArray()).toPromise();\n}\n\n/**\n * @whatItDoes reads the first value from an observable and returns a promise\n * with it. This should be used in combination with async/await.\n *\n * ## Example\n *\n * ```typescript\n * const obs = of(1, 2, 3, 4);\n * const res = await readFirst(obs)\n * expect(res).toEqual(1);\n * ```\n */\nexport function readFirst<T>(o: Observable<T>): Promise<T> {\n return o.pipe(first()).toPromise();\n}\n","import {\n cold as rxjsMarblesCold,\n hot as rxjsMarblesHot,\n getTestScheduler as rxjsMarblesTestScheduler,\n time as rxjsMarblesTime,\n} from 'jasmine-marbles';\n\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const cold = rxjsMarblesCold;\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const hot = rxjsMarblesHot;\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const getTestScheduler = rxjsMarblesTestScheduler;\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const time = rxjsMarblesTime;\n\nexport { readAll, readFirst } from './src/testing-utils';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["rxjsMarblesCold","rxjsMarblesHot","rxjsMarblesTestScheduler","rxjsMarblesTime"],"mappings":";;;AAGA;;;;;;;;;;;AAWG;AACG,SAAU,OAAO,CAAI,CAAgB,EAAA;IACzC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;AAWG;AACG,SAAU,SAAS,CAAI,CAAgB,EAAA;IAC3C,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;AACrC;;AC1BA;;AAEG;AACI,MAAM,IAAI,GAAGA,OAAgB;AACpC;;AAEG;AACI,MAAM,GAAG,GAAGC,MAAe;AAClC;;AAEG;AACI,MAAM,gBAAgB,GAAGC,mBAAyB;AACzD;;AAEG;AACI,MAAM,IAAI,GAAGC;;ACtBpB;;AAEG;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"nrwl-angular.mjs","sources":["../../src/runtime/nx/data-persistence.ts","../../src/runtime/nx/nx.module.ts","../../nrwl-angular.ts"],"sourcesContent":["import { Injectable, Type } from '@angular/core';\nimport { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\nimport { Actions, ofType } from '@ngrx/effects';\nimport { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store';\nimport { Action, Store, ActionCreator } from '@ngrx/store';\nimport { isObservable, Observable, of } from 'rxjs';\nimport {\n catchError,\n concatMap,\n filter,\n groupBy,\n map,\n mergeMap,\n switchMap,\n withLatestFrom,\n} from 'rxjs/operators';\n\n/**\n * See {@link DataPersistence.pessimisticUpdate} for more information.\n */\nexport interface PessimisticUpdateOpts<T extends Array<unknown>, A> {\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n onError(a: A, e: any): Observable<any> | any;\n}\n/**\n * See {@link DataPersistence.pessimisticUpdate} for more information.\n */\nexport interface OptimisticUpdateOpts<T extends Array<unknown>, A> {\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n undoAction(a: A, e: any): Observable<Action> | Action;\n}\n\n/**\n * See {@link DataPersistence.fetch} for more information.\n */\nexport interface FetchOpts<T extends Array<unknown>, A> {\n id?(a: A, ...slices: [...T]): any;\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n onError?(a: A, e: any): Observable<any> | any;\n}\n\n/**\n * See {@link DataPersistence.navigation} for more information.\n */\nexport interface HandleNavigationOpts<T extends Array<unknown>> {\n run(\n a: ActivatedRouteSnapshot,\n ...slices: [...T]\n ): Observable<Action> | Action | void;\n onError?(a: ActivatedRouteSnapshot, e: any): Observable<any> | any;\n}\n\nexport type ActionOrActionWithStates<T extends Array<unknown>, A> =\n | A\n | [A, ...T];\nexport type ActionOrActionWithState<T, A> = ActionOrActionWithStates<[T], A>;\nexport type ActionStatesStream<T extends Array<unknown>, A> = Observable<\n ActionOrActionWithStates<T, A>\n>;\nexport type ActionStateStream<T, A> = Observable<\n ActionOrActionWithStates<[T], A>\n>;\n\nexport function pessimisticUpdate<T extends Array<unknown>, A extends Action>(\n opts: PessimisticUpdateOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.onError))\n );\n };\n}\n\nexport function optimisticUpdate<T extends Array<unknown>, A extends Action>(\n opts: OptimisticUpdateOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.undoAction))\n );\n };\n}\n\nexport function fetch<T extends Array<unknown>, A extends Action>(\n opts: FetchOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n if (opts.id) {\n const groupedFetches = source.pipe(\n mapActionAndState(),\n groupBy(([action, ...store]) => {\n return opts.id(action, ...store);\n })\n );\n\n return groupedFetches.pipe(\n mergeMap((pairs) =>\n pairs.pipe(switchMap(runWithErrorHandling(opts.run, opts.onError)))\n )\n );\n }\n\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.onError))\n );\n };\n}\n\nexport function navigation<T extends Array<unknown>, A extends Action>(\n component: Type<any>,\n opts: HandleNavigationOpts<T>\n) {\n return (source: ActionStatesStream<T, A>) => {\n const nav = source.pipe(\n mapActionAndState(),\n filter(([action]) => isStateSnapshot(action)),\n map(([action, ...slices]) => {\n if (!isStateSnapshot(action)) {\n // Because of the above filter we'll never get here,\n // but this properly type narrows `action`\n return;\n }\n\n return [\n findSnapshot(component, action.payload.routerState.root),\n ...slices,\n ] as [ActivatedRouteSnapshot, ...T];\n }),\n filter(([snapshot]) => !!snapshot)\n );\n\n return nav.pipe(switchMap(runWithErrorHandling(opts.run, opts.onError)));\n };\n}\n\nfunction isStateSnapshot(\n action: any\n): action is RouterNavigationAction<RouterStateSnapshot> {\n return action.type === ROUTER_NAVIGATION;\n}\n\nfunction runWithErrorHandling<T extends Array<unknown>, A, R>(\n run: (a: A, ...slices: [...T]) => Observable<R> | R | void,\n onError: any\n) {\n return ([action, ...slices]: [A, ...T]): Observable<R> => {\n try {\n const r = wrapIntoObservable(run(action, ...slices));\n return r.pipe(catchError((e) => wrapIntoObservable(onError(action, e))));\n } catch (e) {\n return wrapIntoObservable(onError(action, e));\n }\n };\n}\n\n/**\n * @whatItDoes maps Observable<Action | [Action, State]> to\n * Observable<[Action, State]>\n */\nfunction mapActionAndState<T extends Array<unknown>, A>() {\n return (source: Observable<ActionOrActionWithStates<T, A>>) => {\n return source.pipe(\n map((value) => normalizeActionAndState(value) as [A, ...T])\n );\n };\n}\n\n/**\n * @whatItDoes Normalizes either a bare action or an array of action and slices\n * into an array of action and slices (or undefined)\n */\nfunction normalizeActionAndState<T extends Array<unknown>, A>(\n args: ActionOrActionWithStates<T, A>\n): [A, ...T] {\n let action: A, slices: T;\n\n if (args instanceof Array) {\n [action, ...slices] = args;\n } else {\n slices = [] as T;\n action = args;\n }\n\n return [action, ...slices];\n}\n\n/**\n * @whatItDoes Provides convenience methods for implementing common operations of persisting data.\n */\n@Injectable()\nexport class DataPersistence<T> {\n constructor(public store: Store<T>, public actions: Actions) {}\n\n /**\n *\n * @whatItDoes Handles pessimistic updates (updating the server first).\n *\n * Update the server implemented naively suffers from race conditions and poor error handling.\n *\n * `pessimisticUpdate` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() updateTodo = this.s.pessimisticUpdate<UpdateTodo>('UPDATE_TODO', {\n * // provides an action and the current state of the store\n * run(a, state) {\n * // update the backend first, and then dispatch an action that will\n * // update the client side\n * return this.backend(state.user, a.payload).map(updated => ({\n * type: 'TODO_UPDATED',\n * payload: updated\n * }));\n * },\n *\n * onError(a, e: any) {\n * // we don't need to undo the changes on the client side.\n * // we can dispatch an error, or simply log the error here and return `null`\n * return null;\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * Note that if you don't return a new action from the run callback, you must set the dispatch property\n * of the effect to false, like this:\n *\n * ```\n * class TodoEffects {\n * @Effect({dispatch: false})\n * updateTodo; //...\n * }\n * ```\n */\n pessimisticUpdate<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: PessimisticUpdateOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n pessimisticUpdate(opts)\n );\n }\n\n /**\n *\n * @whatItDoes Handles optimistic updates (updating the client first).\n *\n * `optimisticUpdate` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * `optimisticUpdate` is different from `pessimisticUpdate`. In case of a failure, when using `optimisticUpdate`,\n * the developer already updated the state locally, so the developer must provide an undo action.\n *\n * The error handling must be done in the callback, or by means of the undo action.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() updateTodo = this.s.optimisticUpdate<UpdateTodo>('UPDATE_TODO', {\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload);\n * },\n *\n * undoAction: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * return ({\n * type: 'UNDO_UPDATE_TODO',\n * payload: a\n * });\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * Note that if you don't return a new action from the run callback, you must set the dispatch property\n * of the effect to false, like this:\n *\n * ```\n * class TodoEffects {\n * @Effect({dispatch: false})\n * updateTodo; //...\n * }\n * ```\n */\n optimisticUpdate<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: OptimisticUpdateOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n optimisticUpdate(opts)\n );\n }\n\n /**\n *\n * @whatItDoes Handles data fetching.\n *\n * Data fetching implemented naively suffers from race conditions and poor error handling.\n *\n * `fetch` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodos = this.s.fetch<GetTodos>('GET_TODOS', {\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload).map(r => ({\n * type: 'TODOS',\n * payload: r\n * });\n * },\n *\n * onError: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * This is correct, but because it set the concurrency to 1, it may not be performant.\n *\n * To fix that, you can provide the `id` function, like this:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodo = this.s.fetch<GetTodo>('GET_TODO', {\n * id: (a, state) => {\n * return a.payload.id;\n * }\n *\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload).map(r => ({\n * type: 'TODO',\n * payload: r\n * });\n * },\n *\n * onError: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * return null;\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * With this setup, the requests for Todo 1 will run concurrently with the requests for Todo 2.\n *\n * In addition, if DataPersistence notices that there are multiple requests for Todo 1 scheduled,\n * it will only run the last one.\n */\n fetch<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: FetchOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n fetch(opts)\n );\n }\n\n /**\n * @whatItDoes Handles data fetching as part of router navigation.\n *\n * Data fetching implemented naively suffers from race conditions and poor error handling.\n *\n * `navigation` addresses these problems.\n *\n * It checks if an activated router state contains the passed in component type, and, if it does, runs the `run`\n * callback. It provides the activated snapshot associated with the component and the current state. And it only runs\n * the last request.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodo = this.s.navigation(TodoComponent, {\n * run: (a, state) => {\n * return this.backend.fetchTodo(a.params['id']).map(todo => ({\n * type: 'TODO_LOADED',\n * payload: todo\n * }));\n * },\n * onError: (a, e: any) => {\n * // we can log and error here and return null\n * // we can also navigate back\n * return null;\n * }\n * });\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n */\n navigation(\n component: Type<any>,\n opts: HandleNavigationOpts<[T]>\n ): Observable<any> {\n return this.actions.pipe(\n withLatestFrom(this.store),\n navigation(component, opts)\n );\n }\n}\n\nfunction findSnapshot(\n component: Type<any>,\n s: ActivatedRouteSnapshot\n): ActivatedRouteSnapshot {\n if (s.routeConfig && s.routeConfig.component === component) {\n return s;\n }\n for (const c of s.children) {\n const ss = findSnapshot(component, c);\n if (ss) {\n return ss;\n }\n }\n return null;\n}\n\nfunction wrapIntoObservable<O>(obj: Observable<O> | O | void): Observable<O> {\n if (isObservable(obj)) {\n return obj;\n } else if (!obj) {\n return of();\n } else {\n return of(obj as O);\n }\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { DataPersistence } from './data-persistence';\n\n/**\n * @whatItDoes Provides services for enterprise Angular applications.\n *\n * See {@link DataPersistence} for more information.\n */\n@NgModule({})\nexport class NxModule {\n static forRoot(): ModuleWithProviders<NxModule> {\n return { ngModule: NxModule, providers: [DataPersistence] };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;SA+DgB,iBAAiB,CAC/B,IAAiC;IAEjC,OAAO,CAAC,MAAgC;QACtC,OAAO,MAAM,CAAC,IAAI,CAChB,iBAAiB,EAAE,EACnB,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CACxD,CAAC;KACH,CAAC;AACJ,CAAC;SAEe,gBAAgB,CAC9B,IAAgC;IAEhC,OAAO,CAAC,MAAgC;QACtC,OAAO,MAAM,CAAC,IAAI,CAChB,iBAAiB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AU,CAAC,SAAS,EAAE,IAAI,CAAC,CAC5B,CAAC;KACH;;4GA5OU,eAAe;gHAAf,eAAe;2FAAf,eAAe;kBAD3B,UAAU;;AAgPX,SAAS,YAAY,CACnB,SAAoB,EACpB,CAAyB;IAEzB,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,WAAW,CAAC,SAAS,KAAK,SAAS,EAAE;QAC1D,OAAO,CAAC,CAAC;KACV;IACD,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;QAC1B,MAAM,EAAE,GAAG,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACtC,IAAI,EAAE,EAAE;YACN,OAAO,EAAE,CAAC;SACX;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,kBAAkB,CAAI,GAA6B;IAC1D,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE;QACrB,OAAO,GAAG,CAAC;KACZ;SAAM,IAAI,CAAC,GAAG,EAAE;QACf,OAAO,EAAE,EAAE,CAAC;KACb;SAAM;QACL,OAAO,EAAE,CAAC,GAAQ,CAAC,CAAC;KACrB;AACH;;ACrcA;;;;;MAMa,QAAQ;IACnB,OAAO,OAAO;QACZ,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC;KAC7D;;qGAHU,QAAQ;sGAAR,QAAQ;sGAAR,QAAQ;2FAAR,QAAQ;kBADpB,QAAQ;mBAAC,EAAE;;;ACRZ;;;;;;"}
1
+ {"version":3,"file":"nrwl-angular.mjs","sources":["../../src/runtime/nx/data-persistence.ts","../../src/runtime/nx/nx.module.ts","../../nrwl-angular.ts"],"sourcesContent":["import { Injectable, Type } from '@angular/core';\nimport { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\nimport { Actions, ofType } from '@ngrx/effects';\nimport { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store';\nimport { Action, Store, ActionCreator } from '@ngrx/store';\nimport { isObservable, Observable, of } from 'rxjs';\nimport {\n catchError,\n concatMap,\n filter,\n groupBy,\n map,\n mergeMap,\n switchMap,\n withLatestFrom,\n} from 'rxjs/operators';\n\n/**\n * See {@link DataPersistence.pessimisticUpdate} for more information.\n */\nexport interface PessimisticUpdateOpts<T extends Array<unknown>, A> {\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n onError(a: A, e: any): Observable<any> | any;\n}\n/**\n * See {@link DataPersistence.pessimisticUpdate} for more information.\n */\nexport interface OptimisticUpdateOpts<T extends Array<unknown>, A> {\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n undoAction(a: A, e: any): Observable<Action> | Action;\n}\n\n/**\n * See {@link DataPersistence.fetch} for more information.\n */\nexport interface FetchOpts<T extends Array<unknown>, A> {\n id?(a: A, ...slices: [...T]): any;\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n onError?(a: A, e: any): Observable<any> | any;\n}\n\n/**\n * See {@link DataPersistence.navigation} for more information.\n */\nexport interface HandleNavigationOpts<T extends Array<unknown>> {\n run(\n a: ActivatedRouteSnapshot,\n ...slices: [...T]\n ): Observable<Action> | Action | void;\n onError?(a: ActivatedRouteSnapshot, e: any): Observable<any> | any;\n}\n\nexport type ActionOrActionWithStates<T extends Array<unknown>, A> =\n | A\n | [A, ...T];\nexport type ActionOrActionWithState<T, A> = ActionOrActionWithStates<[T], A>;\nexport type ActionStatesStream<T extends Array<unknown>, A> = Observable<\n ActionOrActionWithStates<T, A>\n>;\nexport type ActionStateStream<T, A> = Observable<\n ActionOrActionWithStates<[T], A>\n>;\n\nexport function pessimisticUpdate<T extends Array<unknown>, A extends Action>(\n opts: PessimisticUpdateOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.onError))\n );\n };\n}\n\nexport function optimisticUpdate<T extends Array<unknown>, A extends Action>(\n opts: OptimisticUpdateOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.undoAction))\n );\n };\n}\n\nexport function fetch<T extends Array<unknown>, A extends Action>(\n opts: FetchOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n if (opts.id) {\n const groupedFetches = source.pipe(\n mapActionAndState(),\n groupBy(([action, ...store]) => {\n return opts.id(action, ...store);\n })\n );\n\n return groupedFetches.pipe(\n mergeMap((pairs) =>\n pairs.pipe(switchMap(runWithErrorHandling(opts.run, opts.onError)))\n )\n );\n }\n\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.onError))\n );\n };\n}\n\nexport function navigation<T extends Array<unknown>, A extends Action>(\n component: Type<any>,\n opts: HandleNavigationOpts<T>\n) {\n return (source: ActionStatesStream<T, A>) => {\n const nav = source.pipe(\n mapActionAndState(),\n filter(([action]) => isStateSnapshot(action)),\n map(([action, ...slices]) => {\n if (!isStateSnapshot(action)) {\n // Because of the above filter we'll never get here,\n // but this properly type narrows `action`\n return;\n }\n\n return [\n findSnapshot(component, action.payload.routerState.root),\n ...slices,\n ] as [ActivatedRouteSnapshot, ...T];\n }),\n filter(([snapshot]) => !!snapshot)\n );\n\n return nav.pipe(switchMap(runWithErrorHandling(opts.run, opts.onError)));\n };\n}\n\nfunction isStateSnapshot(\n action: any\n): action is RouterNavigationAction<RouterStateSnapshot> {\n return action.type === ROUTER_NAVIGATION;\n}\n\nfunction runWithErrorHandling<T extends Array<unknown>, A, R>(\n run: (a: A, ...slices: [...T]) => Observable<R> | R | void,\n onError: any\n) {\n return ([action, ...slices]: [A, ...T]): Observable<R> => {\n try {\n const r = wrapIntoObservable(run(action, ...slices));\n return r.pipe(catchError((e) => wrapIntoObservable(onError(action, e))));\n } catch (e) {\n return wrapIntoObservable(onError(action, e));\n }\n };\n}\n\n/**\n * @whatItDoes maps Observable<Action | [Action, State]> to\n * Observable<[Action, State]>\n */\nfunction mapActionAndState<T extends Array<unknown>, A>() {\n return (source: Observable<ActionOrActionWithStates<T, A>>) => {\n return source.pipe(\n map((value) => normalizeActionAndState(value) as [A, ...T])\n );\n };\n}\n\n/**\n * @whatItDoes Normalizes either a bare action or an array of action and slices\n * into an array of action and slices (or undefined)\n */\nfunction normalizeActionAndState<T extends Array<unknown>, A>(\n args: ActionOrActionWithStates<T, A>\n): [A, ...T] {\n let action: A, slices: T;\n\n if (args instanceof Array) {\n [action, ...slices] = args;\n } else {\n slices = [] as T;\n action = args;\n }\n\n return [action, ...slices];\n}\n\n/**\n * @whatItDoes Provides convenience methods for implementing common operations of persisting data.\n */\n@Injectable()\nexport class DataPersistence<T> {\n constructor(public store: Store<T>, public actions: Actions) {}\n\n /**\n *\n * @whatItDoes Handles pessimistic updates (updating the server first).\n *\n * Update the server implemented naively suffers from race conditions and poor error handling.\n *\n * `pessimisticUpdate` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() updateTodo = this.s.pessimisticUpdate<UpdateTodo>('UPDATE_TODO', {\n * // provides an action and the current state of the store\n * run(a, state) {\n * // update the backend first, and then dispatch an action that will\n * // update the client side\n * return this.backend(state.user, a.payload).map(updated => ({\n * type: 'TODO_UPDATED',\n * payload: updated\n * }));\n * },\n *\n * onError(a, e: any) {\n * // we don't need to undo the changes on the client side.\n * // we can dispatch an error, or simply log the error here and return `null`\n * return null;\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * Note that if you don't return a new action from the run callback, you must set the dispatch property\n * of the effect to false, like this:\n *\n * ```\n * class TodoEffects {\n * @Effect({dispatch: false})\n * updateTodo; //...\n * }\n * ```\n */\n pessimisticUpdate<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: PessimisticUpdateOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n pessimisticUpdate(opts)\n );\n }\n\n /**\n *\n * @whatItDoes Handles optimistic updates (updating the client first).\n *\n * `optimisticUpdate` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * `optimisticUpdate` is different from `pessimisticUpdate`. In case of a failure, when using `optimisticUpdate`,\n * the developer already updated the state locally, so the developer must provide an undo action.\n *\n * The error handling must be done in the callback, or by means of the undo action.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() updateTodo = this.s.optimisticUpdate<UpdateTodo>('UPDATE_TODO', {\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload);\n * },\n *\n * undoAction: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * return ({\n * type: 'UNDO_UPDATE_TODO',\n * payload: a\n * });\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * Note that if you don't return a new action from the run callback, you must set the dispatch property\n * of the effect to false, like this:\n *\n * ```\n * class TodoEffects {\n * @Effect({dispatch: false})\n * updateTodo; //...\n * }\n * ```\n */\n optimisticUpdate<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: OptimisticUpdateOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n optimisticUpdate(opts)\n );\n }\n\n /**\n *\n * @whatItDoes Handles data fetching.\n *\n * Data fetching implemented naively suffers from race conditions and poor error handling.\n *\n * `fetch` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodos = this.s.fetch<GetTodos>('GET_TODOS', {\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload).map(r => ({\n * type: 'TODOS',\n * payload: r\n * });\n * },\n *\n * onError: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * This is correct, but because it set the concurrency to 1, it may not be performant.\n *\n * To fix that, you can provide the `id` function, like this:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodo = this.s.fetch<GetTodo>('GET_TODO', {\n * id: (a, state) => {\n * return a.payload.id;\n * }\n *\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload).map(r => ({\n * type: 'TODO',\n * payload: r\n * });\n * },\n *\n * onError: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * return null;\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * With this setup, the requests for Todo 1 will run concurrently with the requests for Todo 2.\n *\n * In addition, if DataPersistence notices that there are multiple requests for Todo 1 scheduled,\n * it will only run the last one.\n */\n fetch<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: FetchOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n fetch(opts)\n );\n }\n\n /**\n * @whatItDoes Handles data fetching as part of router navigation.\n *\n * Data fetching implemented naively suffers from race conditions and poor error handling.\n *\n * `navigation` addresses these problems.\n *\n * It checks if an activated router state contains the passed in component type, and, if it does, runs the `run`\n * callback. It provides the activated snapshot associated with the component and the current state. And it only runs\n * the last request.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodo = this.s.navigation(TodoComponent, {\n * run: (a, state) => {\n * return this.backend.fetchTodo(a.params['id']).map(todo => ({\n * type: 'TODO_LOADED',\n * payload: todo\n * }));\n * },\n * onError: (a, e: any) => {\n * // we can log and error here and return null\n * // we can also navigate back\n * return null;\n * }\n * });\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n */\n navigation(\n component: Type<any>,\n opts: HandleNavigationOpts<[T]>\n ): Observable<any> {\n return this.actions.pipe(\n withLatestFrom(this.store),\n navigation(component, opts)\n );\n }\n}\n\nfunction findSnapshot(\n component: Type<any>,\n s: ActivatedRouteSnapshot\n): ActivatedRouteSnapshot {\n if (s.routeConfig && s.routeConfig.component === component) {\n return s;\n }\n for (const c of s.children) {\n const ss = findSnapshot(component, c);\n if (ss) {\n return ss;\n }\n }\n return null;\n}\n\nfunction wrapIntoObservable<O>(obj: Observable<O> | O | void): Observable<O> {\n if (isObservable(obj)) {\n return obj;\n } else if (!obj) {\n return of();\n } else {\n return of(obj as O);\n }\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { DataPersistence } from './data-persistence';\n\n/**\n * @whatItDoes Provides services for enterprise Angular applications.\n *\n * See {@link DataPersistence} for more information.\n */\n@NgModule({})\nexport class NxModule {\n static forRoot(): ModuleWithProviders<NxModule> {\n return { ngModule: NxModule, providers: [DataPersistence] };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AA+DM,SAAU,iBAAiB,CAC/B,IAAiC,EAAA;IAEjC,OAAO,CAAC,MAAgC,KAAwB;QAC9D,OAAO,MAAM,CAAC,IAAI,CAChB,iBAAiB,EAAE,EACnB,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CACxD,CAAC;AACJ,KAAC,CAAC;AACJ,CAAC;AAEK,SAAU,gBAAgB,CAC9B,IAAgC,EAAA;IAEhC,OAAO,CAAC,MAAgC,KAAwB;QAC9D,OAAO,MAAM,CAAC,IAAI,CAChB,iBAAiB,EAAE,EACnB,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAC3D,CAAC;AACJ,KAAC,CAAC;AACJ,CAAC;AAEK,SAAU,KAAK,CACnB,IAAq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,KAAA;AACH;;ACrcA;;;;AAIG;MAEU,QAAQ,CAAA;AACnB,IAAA,OAAO,OAAO,GAAA;QACZ,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC;KAC7D;;qGAHU,QAAQ,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;sGAAR,QAAQ,EAAA,CAAA,CAAA;sGAAR,QAAQ,EAAA,CAAA,CAAA;2FAAR,QAAQ,EAAA,UAAA,EAAA,CAAA;kBADpB,QAAQ;mBAAC,EAAE,CAAA;;;ACRZ;;AAEG;;;;"}
@@ -47,5 +47,5 @@ async function loadRemoteContainer(remoteName) {
47
47
  * Generated bundle index. Do not edit.
48
48
  */
49
49
 
50
- export { loadRemoteModule, setRemoteUrlResolver };
50
+ export { loadRemoteModule, setRemoteDefinitions, setRemoteUrlResolver };
51
51
  //# sourceMappingURL=nrwl-angular-mfe.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"nrwl-angular-testing.mjs","sources":["../../testing/src/testing-utils.ts","../../testing/index.ts","../../testing/nrwl-angular-testing.ts"],"sourcesContent":["import type { Observable } from 'rxjs';\nimport { first, toArray } from 'rxjs/operators';\n\n/**\n * @whatItDoes reads all the values from an observable and returns a promise\n * with an array of all values. This should be used in combination with async/await.\n *\n * ## Example\n *\n * ```typescript\n * const obs = of(1, 2, 3, 4);\n * const res = await readAll(obs)\n * expect(res).toEqual([1, 2, 3, 4]);\n * ```\n */\nexport function readAll<T>(o: Observable<T>): Promise<T[]> {\n return o.pipe(toArray()).toPromise();\n}\n\n/**\n * @whatItDoes reads the first value from an observable and returns a promise\n * with it. This should be used in combination with async/await.\n *\n * ## Example\n *\n * ```typescript\n * const obs = of(1, 2, 3, 4);\n * const res = await readFirst(obs)\n * expect(res).toEqual(1);\n * ```\n */\nexport function readFirst<T>(o: Observable<T>): Promise<T> {\n return o.pipe(first()).toPromise();\n}\n","import {\n cold as rxjsMarblesCold,\n hot as rxjsMarblesHot,\n getTestScheduler as rxjsMarblesTestScheduler,\n time as rxjsMarblesTime,\n} from 'jasmine-marbles';\n\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const cold = rxjsMarblesCold;\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const hot = rxjsMarblesHot;\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const getTestScheduler = rxjsMarblesTestScheduler;\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const time = rxjsMarblesTime;\n\nexport { readAll, readFirst } from './src/testing-utils';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["rxjsMarblesCold","rxjsMarblesHot","rxjsMarblesTestScheduler","rxjsMarblesTime"],"mappings":";;;AAGA;;;;;;;;;;;;SAYgB,OAAO,CAAI,CAAgB;IACzC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;;SAYgB,SAAS,CAAI,CAAgB;IAC3C,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;AACrC;;AC1BA;;;MAGa,IAAI,GAAGA,OAAgB;AACpC;;;MAGa,GAAG,GAAGC,MAAe;AAClC;;;MAGa,gBAAgB,GAAGC,mBAAyB;AACzD;;;MAGa,IAAI,GAAGC;;ACtBpB;;;;;;"}
1
+ {"version":3,"file":"nrwl-angular-testing.mjs","sources":["../../testing/src/testing-utils.ts","../../testing/index.ts","../../testing/nrwl-angular-testing.ts"],"sourcesContent":["import type { Observable } from 'rxjs';\nimport { first, toArray } from 'rxjs/operators';\n\n/**\n * @whatItDoes reads all the values from an observable and returns a promise\n * with an array of all values. This should be used in combination with async/await.\n *\n * ## Example\n *\n * ```typescript\n * const obs = of(1, 2, 3, 4);\n * const res = await readAll(obs)\n * expect(res).toEqual([1, 2, 3, 4]);\n * ```\n */\nexport function readAll<T>(o: Observable<T>): Promise<T[]> {\n return o.pipe(toArray()).toPromise();\n}\n\n/**\n * @whatItDoes reads the first value from an observable and returns a promise\n * with it. This should be used in combination with async/await.\n *\n * ## Example\n *\n * ```typescript\n * const obs = of(1, 2, 3, 4);\n * const res = await readFirst(obs)\n * expect(res).toEqual(1);\n * ```\n */\nexport function readFirst<T>(o: Observable<T>): Promise<T> {\n return o.pipe(first()).toPromise();\n}\n","import {\n cold as rxjsMarblesCold,\n hot as rxjsMarblesHot,\n getTestScheduler as rxjsMarblesTestScheduler,\n time as rxjsMarblesTime,\n} from 'jasmine-marbles';\n\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const cold = rxjsMarblesCold;\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const hot = rxjsMarblesHot;\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const getTestScheduler = rxjsMarblesTestScheduler;\n/**\n * @deprecated Import from 'jasmine-marbles' instead\n */\nexport const time = rxjsMarblesTime;\n\nexport { readAll, readFirst } from './src/testing-utils';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["rxjsMarblesCold","rxjsMarblesHot","rxjsMarblesTestScheduler","rxjsMarblesTime"],"mappings":";;;AAGA;;;;;;;;;;;AAWG;AACG,SAAU,OAAO,CAAI,CAAgB,EAAA;IACzC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;AAWG;AACG,SAAU,SAAS,CAAI,CAAgB,EAAA;IAC3C,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;AACrC;;AC1BA;;AAEG;AACI,MAAM,IAAI,GAAGA,OAAgB;AACpC;;AAEG;AACI,MAAM,GAAG,GAAGC,MAAe;AAClC;;AAEG;AACI,MAAM,gBAAgB,GAAGC,mBAAyB;AACzD;;AAEG;AACI,MAAM,IAAI,GAAGC;;ACtBpB;;AAEG;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"nrwl-angular.mjs","sources":["../../src/runtime/nx/data-persistence.ts","../../src/runtime/nx/nx.module.ts","../../nrwl-angular.ts"],"sourcesContent":["import { Injectable, Type } from '@angular/core';\nimport { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\nimport { Actions, ofType } from '@ngrx/effects';\nimport { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store';\nimport { Action, Store, ActionCreator } from '@ngrx/store';\nimport { isObservable, Observable, of } from 'rxjs';\nimport {\n catchError,\n concatMap,\n filter,\n groupBy,\n map,\n mergeMap,\n switchMap,\n withLatestFrom,\n} from 'rxjs/operators';\n\n/**\n * See {@link DataPersistence.pessimisticUpdate} for more information.\n */\nexport interface PessimisticUpdateOpts<T extends Array<unknown>, A> {\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n onError(a: A, e: any): Observable<any> | any;\n}\n/**\n * See {@link DataPersistence.pessimisticUpdate} for more information.\n */\nexport interface OptimisticUpdateOpts<T extends Array<unknown>, A> {\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n undoAction(a: A, e: any): Observable<Action> | Action;\n}\n\n/**\n * See {@link DataPersistence.fetch} for more information.\n */\nexport interface FetchOpts<T extends Array<unknown>, A> {\n id?(a: A, ...slices: [...T]): any;\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n onError?(a: A, e: any): Observable<any> | any;\n}\n\n/**\n * See {@link DataPersistence.navigation} for more information.\n */\nexport interface HandleNavigationOpts<T extends Array<unknown>> {\n run(\n a: ActivatedRouteSnapshot,\n ...slices: [...T]\n ): Observable<Action> | Action | void;\n onError?(a: ActivatedRouteSnapshot, e: any): Observable<any> | any;\n}\n\nexport type ActionOrActionWithStates<T extends Array<unknown>, A> =\n | A\n | [A, ...T];\nexport type ActionOrActionWithState<T, A> = ActionOrActionWithStates<[T], A>;\nexport type ActionStatesStream<T extends Array<unknown>, A> = Observable<\n ActionOrActionWithStates<T, A>\n>;\nexport type ActionStateStream<T, A> = Observable<\n ActionOrActionWithStates<[T], A>\n>;\n\nexport function pessimisticUpdate<T extends Array<unknown>, A extends Action>(\n opts: PessimisticUpdateOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.onError))\n );\n };\n}\n\nexport function optimisticUpdate<T extends Array<unknown>, A extends Action>(\n opts: OptimisticUpdateOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.undoAction))\n );\n };\n}\n\nexport function fetch<T extends Array<unknown>, A extends Action>(\n opts: FetchOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n if (opts.id) {\n const groupedFetches = source.pipe(\n mapActionAndState(),\n groupBy(([action, ...store]) => {\n return opts.id(action, ...store);\n })\n );\n\n return groupedFetches.pipe(\n mergeMap((pairs) =>\n pairs.pipe(switchMap(runWithErrorHandling(opts.run, opts.onError)))\n )\n );\n }\n\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.onError))\n );\n };\n}\n\nexport function navigation<T extends Array<unknown>, A extends Action>(\n component: Type<any>,\n opts: HandleNavigationOpts<T>\n) {\n return (source: ActionStatesStream<T, A>) => {\n const nav = source.pipe(\n mapActionAndState(),\n filter(([action]) => isStateSnapshot(action)),\n map(([action, ...slices]) => {\n if (!isStateSnapshot(action)) {\n // Because of the above filter we'll never get here,\n // but this properly type narrows `action`\n return;\n }\n\n return [\n findSnapshot(component, action.payload.routerState.root),\n ...slices,\n ] as [ActivatedRouteSnapshot, ...T];\n }),\n filter(([snapshot]) => !!snapshot)\n );\n\n return nav.pipe(switchMap(runWithErrorHandling(opts.run, opts.onError)));\n };\n}\n\nfunction isStateSnapshot(\n action: any\n): action is RouterNavigationAction<RouterStateSnapshot> {\n return action.type === ROUTER_NAVIGATION;\n}\n\nfunction runWithErrorHandling<T extends Array<unknown>, A, R>(\n run: (a: A, ...slices: [...T]) => Observable<R> | R | void,\n onError: any\n) {\n return ([action, ...slices]: [A, ...T]): Observable<R> => {\n try {\n const r = wrapIntoObservable(run(action, ...slices));\n return r.pipe(catchError((e) => wrapIntoObservable(onError(action, e))));\n } catch (e) {\n return wrapIntoObservable(onError(action, e));\n }\n };\n}\n\n/**\n * @whatItDoes maps Observable<Action | [Action, State]> to\n * Observable<[Action, State]>\n */\nfunction mapActionAndState<T extends Array<unknown>, A>() {\n return (source: Observable<ActionOrActionWithStates<T, A>>) => {\n return source.pipe(\n map((value) => normalizeActionAndState(value) as [A, ...T])\n );\n };\n}\n\n/**\n * @whatItDoes Normalizes either a bare action or an array of action and slices\n * into an array of action and slices (or undefined)\n */\nfunction normalizeActionAndState<T extends Array<unknown>, A>(\n args: ActionOrActionWithStates<T, A>\n): [A, ...T] {\n let action: A, slices: T;\n\n if (args instanceof Array) {\n [action, ...slices] = args;\n } else {\n slices = [] as T;\n action = args;\n }\n\n return [action, ...slices];\n}\n\n/**\n * @whatItDoes Provides convenience methods for implementing common operations of persisting data.\n */\n@Injectable()\nexport class DataPersistence<T> {\n constructor(public store: Store<T>, public actions: Actions) {}\n\n /**\n *\n * @whatItDoes Handles pessimistic updates (updating the server first).\n *\n * Update the server implemented naively suffers from race conditions and poor error handling.\n *\n * `pessimisticUpdate` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() updateTodo = this.s.pessimisticUpdate<UpdateTodo>('UPDATE_TODO', {\n * // provides an action and the current state of the store\n * run(a, state) {\n * // update the backend first, and then dispatch an action that will\n * // update the client side\n * return this.backend(state.user, a.payload).map(updated => ({\n * type: 'TODO_UPDATED',\n * payload: updated\n * }));\n * },\n *\n * onError(a, e: any) {\n * // we don't need to undo the changes on the client side.\n * // we can dispatch an error, or simply log the error here and return `null`\n * return null;\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * Note that if you don't return a new action from the run callback, you must set the dispatch property\n * of the effect to false, like this:\n *\n * ```\n * class TodoEffects {\n * @Effect({dispatch: false})\n * updateTodo; //...\n * }\n * ```\n */\n pessimisticUpdate<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: PessimisticUpdateOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n pessimisticUpdate(opts)\n );\n }\n\n /**\n *\n * @whatItDoes Handles optimistic updates (updating the client first).\n *\n * `optimisticUpdate` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * `optimisticUpdate` is different from `pessimisticUpdate`. In case of a failure, when using `optimisticUpdate`,\n * the developer already updated the state locally, so the developer must provide an undo action.\n *\n * The error handling must be done in the callback, or by means of the undo action.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() updateTodo = this.s.optimisticUpdate<UpdateTodo>('UPDATE_TODO', {\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload);\n * },\n *\n * undoAction: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * return ({\n * type: 'UNDO_UPDATE_TODO',\n * payload: a\n * });\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * Note that if you don't return a new action from the run callback, you must set the dispatch property\n * of the effect to false, like this:\n *\n * ```\n * class TodoEffects {\n * @Effect({dispatch: false})\n * updateTodo; //...\n * }\n * ```\n */\n optimisticUpdate<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: OptimisticUpdateOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n optimisticUpdate(opts)\n );\n }\n\n /**\n *\n * @whatItDoes Handles data fetching.\n *\n * Data fetching implemented naively suffers from race conditions and poor error handling.\n *\n * `fetch` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodos = this.s.fetch<GetTodos>('GET_TODOS', {\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload).map(r => ({\n * type: 'TODOS',\n * payload: r\n * });\n * },\n *\n * onError: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * This is correct, but because it set the concurrency to 1, it may not be performant.\n *\n * To fix that, you can provide the `id` function, like this:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodo = this.s.fetch<GetTodo>('GET_TODO', {\n * id: (a, state) => {\n * return a.payload.id;\n * }\n *\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload).map(r => ({\n * type: 'TODO',\n * payload: r\n * });\n * },\n *\n * onError: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * return null;\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * With this setup, the requests for Todo 1 will run concurrently with the requests for Todo 2.\n *\n * In addition, if DataPersistence notices that there are multiple requests for Todo 1 scheduled,\n * it will only run the last one.\n */\n fetch<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: FetchOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n fetch(opts)\n );\n }\n\n /**\n * @whatItDoes Handles data fetching as part of router navigation.\n *\n * Data fetching implemented naively suffers from race conditions and poor error handling.\n *\n * `navigation` addresses these problems.\n *\n * It checks if an activated router state contains the passed in component type, and, if it does, runs the `run`\n * callback. It provides the activated snapshot associated with the component and the current state. And it only runs\n * the last request.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodo = this.s.navigation(TodoComponent, {\n * run: (a, state) => {\n * return this.backend.fetchTodo(a.params['id']).map(todo => ({\n * type: 'TODO_LOADED',\n * payload: todo\n * }));\n * },\n * onError: (a, e: any) => {\n * // we can log and error here and return null\n * // we can also navigate back\n * return null;\n * }\n * });\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n */\n navigation(\n component: Type<any>,\n opts: HandleNavigationOpts<[T]>\n ): Observable<any> {\n return this.actions.pipe(\n withLatestFrom(this.store),\n navigation(component, opts)\n );\n }\n}\n\nfunction findSnapshot(\n component: Type<any>,\n s: ActivatedRouteSnapshot\n): ActivatedRouteSnapshot {\n if (s.routeConfig && s.routeConfig.component === component) {\n return s;\n }\n for (const c of s.children) {\n const ss = findSnapshot(component, c);\n if (ss) {\n return ss;\n }\n }\n return null;\n}\n\nfunction wrapIntoObservable<O>(obj: Observable<O> | O | void): Observable<O> {\n if (isObservable(obj)) {\n return obj;\n } else if (!obj) {\n return of();\n } else {\n return of(obj as O);\n }\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { DataPersistence } from './data-persistence';\n\n/**\n * @whatItDoes Provides services for enterprise Angular applications.\n *\n * See {@link DataPersistence} for more information.\n */\n@NgModule({})\nexport class NxModule {\n static forRoot(): ModuleWithProviders<NxModule> {\n return { ngModule: NxModule, providers: [DataPersistence] };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;SA+DgB,iBAAiB,CAC/B,IAAiC;IAEjC,OAAO,CAAC,MAAgC;QACtC,OAAO,MAAM,CAAC,IAAI,CAChB,iBAAiB,EAAE,EACnB,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAA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],"sourcesContent":["import { Injectable, Type } from '@angular/core';\nimport { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\nimport { Actions, ofType } from '@ngrx/effects';\nimport { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store';\nimport { Action, Store, ActionCreator } from '@ngrx/store';\nimport { isObservable, Observable, of } from 'rxjs';\nimport {\n catchError,\n concatMap,\n filter,\n groupBy,\n map,\n mergeMap,\n switchMap,\n withLatestFrom,\n} from 'rxjs/operators';\n\n/**\n * See {@link DataPersistence.pessimisticUpdate} for more information.\n */\nexport interface PessimisticUpdateOpts<T extends Array<unknown>, A> {\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n onError(a: A, e: any): Observable<any> | any;\n}\n/**\n * See {@link DataPersistence.pessimisticUpdate} for more information.\n */\nexport interface OptimisticUpdateOpts<T extends Array<unknown>, A> {\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n undoAction(a: A, e: any): Observable<Action> | Action;\n}\n\n/**\n * See {@link DataPersistence.fetch} for more information.\n */\nexport interface FetchOpts<T extends Array<unknown>, A> {\n id?(a: A, ...slices: [...T]): any;\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n onError?(a: A, e: any): Observable<any> | any;\n}\n\n/**\n * See {@link DataPersistence.navigation} for more information.\n */\nexport interface HandleNavigationOpts<T extends Array<unknown>> {\n run(\n a: ActivatedRouteSnapshot,\n ...slices: [...T]\n ): Observable<Action> | Action | void;\n onError?(a: ActivatedRouteSnapshot, e: any): Observable<any> | any;\n}\n\nexport type ActionOrActionWithStates<T extends Array<unknown>, A> =\n | A\n | [A, ...T];\nexport type ActionOrActionWithState<T, A> = ActionOrActionWithStates<[T], A>;\nexport type ActionStatesStream<T extends Array<unknown>, A> = Observable<\n ActionOrActionWithStates<T, A>\n>;\nexport type ActionStateStream<T, A> = Observable<\n ActionOrActionWithStates<[T], A>\n>;\n\nexport function pessimisticUpdate<T extends Array<unknown>, A extends Action>(\n opts: PessimisticUpdateOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.onError))\n );\n };\n}\n\nexport function optimisticUpdate<T extends Array<unknown>, A extends Action>(\n opts: OptimisticUpdateOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.undoAction))\n );\n };\n}\n\nexport function fetch<T extends Array<unknown>, A extends Action>(\n opts: FetchOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n if (opts.id) {\n const groupedFetches = source.pipe(\n mapActionAndState(),\n groupBy(([action, ...store]) => {\n return opts.id(action, ...store);\n })\n );\n\n return groupedFetches.pipe(\n mergeMap((pairs) =>\n pairs.pipe(switchMap(runWithErrorHandling(opts.run, opts.onError)))\n )\n );\n }\n\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.onError))\n );\n };\n}\n\nexport function navigation<T extends Array<unknown>, A extends Action>(\n component: Type<any>,\n opts: HandleNavigationOpts<T>\n) {\n return (source: ActionStatesStream<T, A>) => {\n const nav = source.pipe(\n mapActionAndState(),\n filter(([action]) => isStateSnapshot(action)),\n map(([action, ...slices]) => {\n if (!isStateSnapshot(action)) {\n // Because of the above filter we'll never get here,\n // but this properly type narrows `action`\n return;\n }\n\n return [\n findSnapshot(component, action.payload.routerState.root),\n ...slices,\n ] as [ActivatedRouteSnapshot, ...T];\n }),\n filter(([snapshot]) => !!snapshot)\n );\n\n return nav.pipe(switchMap(runWithErrorHandling(opts.run, opts.onError)));\n };\n}\n\nfunction isStateSnapshot(\n action: any\n): action is RouterNavigationAction<RouterStateSnapshot> {\n return action.type === ROUTER_NAVIGATION;\n}\n\nfunction runWithErrorHandling<T extends Array<unknown>, A, R>(\n run: (a: A, ...slices: [...T]) => Observable<R> | R | void,\n onError: any\n) {\n return ([action, ...slices]: [A, ...T]): Observable<R> => {\n try {\n const r = wrapIntoObservable(run(action, ...slices));\n return r.pipe(catchError((e) => wrapIntoObservable(onError(action, e))));\n } catch (e) {\n return wrapIntoObservable(onError(action, e));\n }\n };\n}\n\n/**\n * @whatItDoes maps Observable<Action | [Action, State]> to\n * Observable<[Action, State]>\n */\nfunction mapActionAndState<T extends Array<unknown>, A>() {\n return (source: Observable<ActionOrActionWithStates<T, A>>) => {\n return source.pipe(\n map((value) => normalizeActionAndState(value) as [A, ...T])\n );\n };\n}\n\n/**\n * @whatItDoes Normalizes either a bare action or an array of action and slices\n * into an array of action and slices (or undefined)\n */\nfunction normalizeActionAndState<T extends Array<unknown>, A>(\n args: ActionOrActionWithStates<T, A>\n): [A, ...T] {\n let action: A, slices: T;\n\n if (args instanceof Array) {\n [action, ...slices] = args;\n } else {\n slices = [] as T;\n action = args;\n }\n\n return [action, ...slices];\n}\n\n/**\n * @whatItDoes Provides convenience methods for implementing common operations of persisting data.\n */\n@Injectable()\nexport class DataPersistence<T> {\n constructor(public store: Store<T>, public actions: Actions) {}\n\n /**\n *\n * @whatItDoes Handles pessimistic updates (updating the server first).\n *\n * Update the server implemented naively suffers from race conditions and poor error handling.\n *\n * `pessimisticUpdate` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() updateTodo = this.s.pessimisticUpdate<UpdateTodo>('UPDATE_TODO', {\n * // provides an action and the current state of the store\n * run(a, state) {\n * // update the backend first, and then dispatch an action that will\n * // update the client side\n * return this.backend(state.user, a.payload).map(updated => ({\n * type: 'TODO_UPDATED',\n * payload: updated\n * }));\n * },\n *\n * onError(a, e: any) {\n * // we don't need to undo the changes on the client side.\n * // we can dispatch an error, or simply log the error here and return `null`\n * return null;\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * Note that if you don't return a new action from the run callback, you must set the dispatch property\n * of the effect to false, like this:\n *\n * ```\n * class TodoEffects {\n * @Effect({dispatch: false})\n * updateTodo; //...\n * }\n * ```\n */\n pessimisticUpdate<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: PessimisticUpdateOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n pessimisticUpdate(opts)\n );\n }\n\n /**\n *\n * @whatItDoes Handles optimistic updates (updating the client first).\n *\n * `optimisticUpdate` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * `optimisticUpdate` is different from `pessimisticUpdate`. In case of a failure, when using `optimisticUpdate`,\n * the developer already updated the state locally, so the developer must provide an undo action.\n *\n * The error handling must be done in the callback, or by means of the undo action.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() updateTodo = this.s.optimisticUpdate<UpdateTodo>('UPDATE_TODO', {\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload);\n * },\n *\n * undoAction: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * return ({\n * type: 'UNDO_UPDATE_TODO',\n * payload: a\n * });\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * Note that if you don't return a new action from the run callback, you must set the dispatch property\n * of the effect to false, like this:\n *\n * ```\n * class TodoEffects {\n * @Effect({dispatch: false})\n * updateTodo; //...\n * }\n * ```\n */\n optimisticUpdate<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: OptimisticUpdateOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n optimisticUpdate(opts)\n );\n }\n\n /**\n *\n * @whatItDoes Handles data fetching.\n *\n * Data fetching implemented naively suffers from race conditions and poor error handling.\n *\n * `fetch` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodos = this.s.fetch<GetTodos>('GET_TODOS', {\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload).map(r => ({\n * type: 'TODOS',\n * payload: r\n * });\n * },\n *\n * onError: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * This is correct, but because it set the concurrency to 1, it may not be performant.\n *\n * To fix that, you can provide the `id` function, like this:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodo = this.s.fetch<GetTodo>('GET_TODO', {\n * id: (a, state) => {\n * return a.payload.id;\n * }\n *\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload).map(r => ({\n * type: 'TODO',\n * payload: r\n * });\n * },\n *\n * onError: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * return null;\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * With this setup, the requests for Todo 1 will run concurrently with the requests for Todo 2.\n *\n * In addition, if DataPersistence notices that there are multiple requests for Todo 1 scheduled,\n * it will only run the last one.\n */\n fetch<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: FetchOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n fetch(opts)\n );\n }\n\n /**\n * @whatItDoes Handles data fetching as part of router navigation.\n *\n * Data fetching implemented naively suffers from race conditions and poor error handling.\n *\n * `navigation` addresses these problems.\n *\n * It checks if an activated router state contains the passed in component type, and, if it does, runs the `run`\n * callback. It provides the activated snapshot associated with the component and the current state. And it only runs\n * the last request.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodo = this.s.navigation(TodoComponent, {\n * run: (a, state) => {\n * return this.backend.fetchTodo(a.params['id']).map(todo => ({\n * type: 'TODO_LOADED',\n * payload: todo\n * }));\n * },\n * onError: (a, e: any) => {\n * // we can log and error here and return null\n * // we can also navigate back\n * return null;\n * }\n * });\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n */\n navigation(\n component: Type<any>,\n opts: HandleNavigationOpts<[T]>\n ): Observable<any> {\n return this.actions.pipe(\n withLatestFrom(this.store),\n navigation(component, opts)\n );\n }\n}\n\nfunction findSnapshot(\n component: Type<any>,\n s: ActivatedRouteSnapshot\n): ActivatedRouteSnapshot {\n if (s.routeConfig && s.routeConfig.component === component) {\n return s;\n }\n for (const c of s.children) {\n const ss = findSnapshot(component, c);\n if (ss) {\n return ss;\n }\n }\n return null;\n}\n\nfunction wrapIntoObservable<O>(obj: Observable<O> | O | void): Observable<O> {\n if (isObservable(obj)) {\n return obj;\n } else if (!obj) {\n return of();\n } else {\n return of(obj as O);\n }\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { DataPersistence } from './data-persistence';\n\n/**\n * @whatItDoes Provides services for enterprise Angular applications.\n *\n * See {@link DataPersistence} for more information.\n */\n@NgModule({})\nexport class NxModule {\n static forRoot(): ModuleWithProviders<NxModule> {\n return { ngModule: NxModule, providers: [DataPersistence] };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AA+DM,SAAU,iBAAiB,CAC/B,IAAiC,EAAA;IAEjC,OAAO,CAAC,MAAgC,KAAwB;QAC9D,OAAO,MAAM,CAAC,IAAI,CAChB,iBAAiB,EAAE,EACnB,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CACxD,CAAC;AACJ,KAAC,CAAC;AACJ,CAAC;AAEK,SAAU,gBAAgB,CAC9B,IAAgC,EAAA;IAEhC,OAAO,CAAC,MAAgC,KAAwB;QAC9D,OAAO,MAAM,CAAC,IAAI,C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,OAAO,GAAG,CAAC;AACZ,KAAA;SAAM,IAAI,CAAC,GAAG,EAAE;QACf,OAAO,EAAE,EAAE,CAAC;AACb,KAAA;AAAM,SAAA;AACL,QAAA,OAAO,EAAE,CAAC,GAAQ,CAAC,CAAC;AACrB,KAAA;AACH;;ACrcA;;;;AAIG;MAEU,QAAQ,CAAA;AACnB,IAAA,OAAO,OAAO,GAAA;QACZ,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC;KAC7D;;qGAHU,QAAQ,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;sGAAR,QAAQ,EAAA,CAAA,CAAA;sGAAR,QAAQ,EAAA,CAAA,CAAA;2FAAR,QAAQ,EAAA,UAAA,EAAA,CAAA;kBADpB,QAAQ;mBAAC,EAAE,CAAA;;;ACRZ;;AAEG;;;;"}
package/mfe/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { setRemoteUrlResolver, loadRemoteModule } from './mfe';
1
+ export { setRemoteUrlResolver, setRemoteDefinitions, loadRemoteModule, } from './mfe';
package/mfe/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadRemoteModule = exports.setRemoteUrlResolver = void 0;
3
+ exports.loadRemoteModule = exports.setRemoteDefinitions = exports.setRemoteUrlResolver = void 0;
4
4
  var mfe_1 = require("./mfe");
5
5
  Object.defineProperty(exports, "setRemoteUrlResolver", { enumerable: true, get: function () { return mfe_1.setRemoteUrlResolver; } });
6
+ Object.defineProperty(exports, "setRemoteDefinitions", { enumerable: true, get: function () { return mfe_1.setRemoteDefinitions; } });
6
7
  Object.defineProperty(exports, "loadRemoteModule", { enumerable: true, get: function () { return mfe_1.loadRemoteModule; } });
7
8
  //# sourceMappingURL=index.js.map
package/mfe/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/angular/mfe/index.ts"],"names":[],"mappings":";;;AAAA,6BAA+D;AAAtD,2GAAA,oBAAoB,OAAA;AAAE,uGAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/angular/mfe/index.ts"],"names":[],"mappings":";;;AAAA,6BAIe;AAHb,2GAAA,oBAAoB,OAAA;AACpB,2GAAA,oBAAoB,OAAA;AACpB,uGAAA,gBAAgB,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nrwl/angular",
3
- "version": "13.10.0-beta.7",
3
+ "version": "13.10.0-beta.8",
4
4
  "description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, Cypress, Karma, and Protractor. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Upgrading AngularJS applications \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -65,11 +65,11 @@
65
65
  },
66
66
  "dependencies": {
67
67
  "@angular-devkit/schematics": "~13.3.0",
68
- "@nrwl/cypress": "13.10.0-beta.7",
69
- "@nrwl/devkit": "13.10.0-beta.7",
70
- "@nrwl/jest": "13.10.0-beta.7",
71
- "@nrwl/linter": "13.10.0-beta.7",
72
- "@nrwl/storybook": "13.10.0-beta.7",
68
+ "@nrwl/cypress": "13.10.0-beta.8",
69
+ "@nrwl/devkit": "13.10.0-beta.8",
70
+ "@nrwl/jest": "13.10.0-beta.8",
71
+ "@nrwl/linter": "13.10.0-beta.8",
72
+ "@nrwl/storybook": "13.10.0-beta.8",
73
73
  "@schematics/angular": "~13.3.0",
74
74
  "@phenomnomnominal/tsquery": "4.1.1",
75
75
  "ignore": "^5.0.4",
@@ -19,21 +19,6 @@
19
19
  "scripts",
20
20
  "customWebpackConfig"
21
21
  ]
22
- },
23
- {
24
- "name": "Incremental Builds",
25
- "keys": [
26
- "outputs",
27
- "buildLibsFromSource",
28
- "outputPath",
29
- "index",
30
- "main",
31
- "polyfills",
32
- "tsConfig",
33
- "assets",
34
- "styles",
35
- "scripts"
36
- ]
37
22
  }
38
23
  ],
39
24
  "properties": {
@@ -15,6 +15,7 @@ function addMfe(host, options) {
15
15
  skipFormat: true,
16
16
  skipPackageJson: options.skipPackageJson,
17
17
  e2eProjectName: options.e2eProjectName,
18
+ federationType: options.federationType,
18
19
  });
19
20
  });
20
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"add-mfe.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/application/lib/add-mfe.ts"],"names":[],"mappings":";;;;AAGA,yDAAqD;AAErD,SAAsB,MAAM,CAAC,IAAU,EAAE,OAAyB;;QAChE,MAAM,IAAA,oBAAQ,EAAC,IAAI,EAAE;YACnB,OAAO,EAAE,OAAO,CAAC,IAAI;YACrB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,UAAU,EAAE,IAAI;YAChB,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,cAAc,EAAE,OAAO,CAAC,cAAc;SACvC,CAAC,CAAC;IACL,CAAC;CAAA;AAZD,wBAYC"}
1
+ {"version":3,"file":"add-mfe.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/application/lib/add-mfe.ts"],"names":[],"mappings":";;;;AAGA,yDAAqD;AAErD,SAAsB,MAAM,CAAC,IAAU,EAAE,OAAyB;;QAChE,MAAM,IAAA,oBAAQ,EAAC,IAAI,EAAE;YACnB,OAAO,EAAE,OAAO,CAAC,IAAI;YACrB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,UAAU,EAAE,IAAI;YAChB,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,cAAc,EAAE,OAAO,CAAC,cAAc;SACvC,CAAC,CAAC;IACL,CAAC;CAAA;AAbD,wBAaC"}
@@ -30,4 +30,5 @@ export interface Schema {
30
30
  host?: string;
31
31
  setParserOptionsProject?: boolean;
32
32
  skipPackageJson?: boolean;
33
+ federationType?: 'static' | 'dynamic';
33
34
  }
@@ -138,6 +138,12 @@
138
138
  "description": "Type of application to generate the Module Federation configuration for.",
139
139
  "default": "remote"
140
140
  },
141
+ "federationType": {
142
+ "type": "string",
143
+ "enum": ["static", "dynamic"],
144
+ "description": "Use either Static or Dynamic Module Federation pattern for the application.",
145
+ "default": "static"
146
+ },
141
147
  "port": {
142
148
  "type": "number",
143
149
  "description": "The port at which the remote application should be served."
@@ -21,6 +21,7 @@ function mfeHost(tree, options) {
21
21
  routing: true,
22
22
  remotes: (_a = options.remotes) !== null && _a !== void 0 ? _a : [],
23
23
  port: 4200,
24
+ federationType: options.dynamic ? 'dynamic' : 'static',
24
25
  });
25
26
  return installTask;
26
27
  });
@@ -1 +1 @@
1
- {"version":3,"file":"mfe-host.js","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/mfe-host/mfe-host.ts"],"names":[],"mappings":";;;AAGA,yCAA2C;AAC3C,4DAA8D;AAE9D,SAA8B,OAAO,CAAC,IAAU,EAAE,OAAe;;;QAC/D,MAAM,QAAQ,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAEnC,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACjD,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;gBACjC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;oBACzB,MAAM,IAAI,KAAK,CACb,gDAAgD,MAAM,GAAG,CAC1D,CAAC;iBACH;YACH,CAAC,CAAC,CAAC;SACJ;QAED,MAAM,WAAW,GAAG,MAAM,IAAA,qBAAoB,EAAC,IAAI,EAAE;YACnD,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,GAAG,EAAE,IAAI;YACT,OAAO,EAAE,MAAM;YACf,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,MAAA,OAAO,CAAC,OAAO,mCAAI,EAAE;YAC9B,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QAEH,OAAO,WAAW,CAAC;;CACpB;AAvBD,0BAuBC"}
1
+ {"version":3,"file":"mfe-host.js","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/mfe-host/mfe-host.ts"],"names":[],"mappings":";;;AAGA,yCAA2C;AAC3C,4DAA8D;AAE9D,SAA8B,OAAO,CAAC,IAAU,EAAE,OAAe;;;QAC/D,MAAM,QAAQ,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAEnC,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACjD,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;gBACjC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;oBACzB,MAAM,IAAI,KAAK,CACb,gDAAgD,MAAM,GAAG,CAC1D,CAAC;iBACH;YACH,CAAC,CAAC,CAAC;SACJ;QAED,MAAM,WAAW,GAAG,MAAM,IAAA,qBAAoB,EAAC,IAAI,EAAE;YACnD,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,GAAG,EAAE,IAAI;YACT,OAAO,EAAE,MAAM;YACf,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,MAAA,OAAO,CAAC,OAAO,mCAAI,EAAE;YAC9B,IAAI,EAAE,IAAI;YACV,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ;SACvD,CAAC,CAAC;QAEH,OAAO,WAAW,CAAC;;CACpB;AAxBD,0BAwBC"}
@@ -1,4 +1,5 @@
1
1
  export interface Schema {
2
2
  name: string;
3
3
  remotes?: string[];
4
+ dynamic?: boolean;
4
5
  }
@@ -27,6 +27,11 @@
27
27
  "port": {
28
28
  "type": "number",
29
29
  "description": "The port on which this app should be served."
30
+ },
31
+ "dynamic": {
32
+ "type": "boolean",
33
+ "description": "Should the host app use dynamic federation?",
34
+ "default": false
30
35
  }
31
36
  },
32
37
  "required": ["name"]
@@ -1,2 +1,2 @@
1
- declare const _default: (options: import("./schema").Schema) => (tree: any, context: any) => Promise<any>;
1
+ declare const _default: (options: import("./schema").GeneratorOptions) => (tree: any, context: any) => Promise<any>;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import { Tree } from '@nrwl/devkit';
2
- import { Schema } from './schema';
3
- export declare function migrateFromAngularCli(tree: Tree, schema: Schema): Promise<() => void>;
2
+ import type { GeneratorOptions } from './schema';
3
+ export declare function migrateFromAngularCli(tree: Tree, rawOptions: GeneratorOptions): Promise<() => void>;