@nx/angular 21.0.0-canary.20250206-8bd0bcd → 21.0.0-canary.20250418-8619c1d

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 (115) hide show
  1. package/fesm2022/nx-angular.mjs +0 -352
  2. package/fesm2022/nx-angular.mjs.map +1 -1
  3. package/generators.json +7 -2
  4. package/index.d.ts +1 -1
  5. package/migrations.json +199 -69
  6. package/ng-package.json +1 -1
  7. package/package.json +11 -14
  8. package/src/builders/dev-server/dev-server.impl.js +2 -3
  9. package/src/builders/dev-server/lib/normalize-options.js +1 -0
  10. package/src/builders/dev-server/schema.d.ts +4 -0
  11. package/src/builders/dev-server/schema.json +9 -4
  12. package/src/builders/webpack-browser/schema.d.ts +1 -4
  13. package/src/builders/webpack-browser/schema.json +5 -0
  14. package/src/builders/webpack-browser/webpack-browser.impl.js +5 -5
  15. package/src/executors/delegate-build/delegate-build.impl.d.ts +1 -3
  16. package/src/executors/delegate-build/delegate-build.impl.js +0 -3
  17. package/src/executors/module-federation-dev-server/schema.d.ts +3 -0
  18. package/src/executors/module-federation-dev-server/schema.json +1 -1
  19. package/src/executors/package/package.impl.js +1 -4
  20. package/src/generators/add-linting/add-linting.js +1 -16
  21. package/src/generators/add-linting/lib/create-eslint-configuration.d.ts +2 -2
  22. package/src/generators/add-linting/lib/create-eslint-configuration.js +2 -2
  23. package/src/generators/add-linting/schema.d.ts +1 -0
  24. package/src/generators/application/application.js +20 -1
  25. package/src/generators/application/files/rspack-ssr/server.ts__tmpl__ +72 -0
  26. package/src/generators/application/lib/add-e2e.js +2 -9
  27. package/src/generators/application/lib/add-linting.js +1 -0
  28. package/src/generators/application/lib/add-serve-static-target.js +1 -0
  29. package/src/generators/application/lib/add-unit-test-runner.js +2 -0
  30. package/src/generators/application/lib/create-project.js +1 -0
  31. package/src/generators/application/lib/normalize-options.d.ts +1 -1
  32. package/src/generators/application/lib/normalize-options.js +9 -2
  33. package/src/generators/application/schema.d.ts +2 -2
  34. package/src/generators/application/schema.json +1 -7
  35. package/src/generators/component-test/component-test.js +1 -1
  36. package/src/generators/convert-to-rspack/convert-to-rspack.d.ts +4 -0
  37. package/src/generators/convert-to-rspack/convert-to-rspack.js +314 -0
  38. package/src/generators/convert-to-rspack/lib/create-config.d.ts +2 -0
  39. package/src/generators/convert-to-rspack/lib/create-config.js +48 -0
  40. package/src/generators/convert-to-rspack/lib/get-custom-webpack-config.d.ts +6 -0
  41. package/src/generators/convert-to-rspack/lib/get-custom-webpack-config.js +75 -0
  42. package/src/generators/convert-to-rspack/lib/update-tsconfig.d.ts +2 -0
  43. package/src/generators/convert-to-rspack/lib/update-tsconfig.js +26 -0
  44. package/src/generators/convert-to-rspack/lib/validate-supported-executor.d.ts +2 -0
  45. package/src/generators/convert-to-rspack/lib/validate-supported-executor.js +14 -0
  46. package/src/generators/convert-to-rspack/schema.d.ts +5 -0
  47. package/src/generators/convert-to-rspack/schema.json +30 -0
  48. package/src/generators/host/host.js +1 -1
  49. package/src/generators/host/schema.d.ts +0 -1
  50. package/src/generators/host/schema.json +0 -6
  51. package/src/generators/library/lib/add-project.d.ts +1 -1
  52. package/src/generators/library/lib/add-project.js +7 -1
  53. package/src/generators/library/lib/normalize-options.js +1 -1
  54. package/src/generators/library/lib/normalized-schema.d.ts +0 -1
  55. package/src/generators/library/library.js +5 -1
  56. package/src/generators/library/schema.d.ts +0 -1
  57. package/src/generators/library/schema.json +0 -6
  58. package/src/generators/move/move.d.ts +3 -0
  59. package/src/generators/move/move.js +3 -0
  60. package/src/generators/ng-add/migrators/projects/e2e.migrator.js +2 -2
  61. package/src/generators/ngrx/ngrx.d.ts +3 -0
  62. package/src/generators/ngrx/ngrx.js +3 -0
  63. package/src/generators/ngrx/schema.json +1 -1
  64. package/src/generators/ngrx-feature-store/schema.d.ts +1 -1
  65. package/src/generators/remote/remote.js +1 -1
  66. package/src/generators/remote/schema.d.ts +0 -1
  67. package/src/generators/remote/schema.json +0 -6
  68. package/src/generators/setup-mf/lib/setup-serve-target.js +1 -0
  69. package/src/generators/setup-ssr/files/v19+/application-builder/ngmodule-src/app/__rootModuleFileName__ +2 -2
  70. package/src/generators/setup-ssr/files/v19+/application-builder/server/__serverFileName__ +1 -1
  71. package/src/generators/setup-ssr/files/v19+/application-builder/standalone-src/app/app.config.server.ts__tpl__ +2 -2
  72. package/src/generators/setup-ssr/files/v19+/application-builder-common-engine/server/__serverFileName__ +2 -0
  73. package/src/generators/setup-ssr/lib/generate-files.js +12 -1
  74. package/src/generators/setup-ssr/lib/update-project-config.js +1 -0
  75. package/src/generators/stories/stories.js +2 -2
  76. package/src/generators/utils/add-jest.d.ts +1 -0
  77. package/src/generators/utils/add-jest.js +2 -2
  78. package/src/generators/utils/add-vitest.d.ts +1 -0
  79. package/src/generators/utils/add-vitest.js +1 -1
  80. package/src/generators/utils/ensure-angular-dependencies.js +0 -1
  81. package/src/migrations/update-16-2-0/switch-data-persistence-operators-imports-to-ngrx-router-store.js +4 -4
  82. package/src/migrations/update-19-6-0/turn-off-dts-by-default.js +2 -2
  83. package/src/migrations/{update-16-1-0 → update-20-5-0}/update-angular-cli.d.ts +1 -1
  84. package/src/migrations/{update-16-1-0 → update-20-5-0}/update-angular-cli.js +1 -1
  85. package/src/migrations/{update-16-1-0/remove-ngcc-invocation.d.ts → update-21-0-0/change-data-persistence-operators-imports-to-ngrx-router-store-data-persistence.d.ts} +1 -1
  86. package/src/migrations/update-21-0-0/change-data-persistence-operators-imports-to-ngrx-router-store-data-persistence.js +122 -0
  87. package/src/migrations/update-21-0-0/set-continuous-option.d.ts +3 -0
  88. package/src/migrations/update-21-0-0/set-continuous-option.js +29 -0
  89. package/src/plugins/plugin.js +2 -0
  90. package/src/utils/backward-compatible-versions.js +2 -0
  91. package/src/utils/nx-devkit/ast-utils.d.ts +0 -8
  92. package/src/utils/nx-devkit/ast-utils.js +7 -12
  93. package/src/utils/versions.d.ts +7 -6
  94. package/src/utils/versions.js +8 -7
  95. package/fesm2022/nx-angular-testing.mjs +0 -45
  96. package/fesm2022/nx-angular-testing.mjs.map +0 -1
  97. package/src/migrations/update-16-0-0/remove-karma-defaults.d.ts +0 -2
  98. package/src/migrations/update-16-0-0/remove-karma-defaults.js +0 -52
  99. package/src/migrations/update-16-0-0/remove-library-generator-simple-module-name-option.d.ts +0 -2
  100. package/src/migrations/update-16-0-0/remove-library-generator-simple-module-name-option.js +0 -40
  101. package/src/migrations/update-16-0-0/remove-protractor-defaults.d.ts +0 -2
  102. package/src/migrations/update-16-0-0/remove-protractor-defaults.js +0 -52
  103. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
  104. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
  105. package/src/migrations/update-16-1-0/extract-standalone-config-from-bootstrap.d.ts +0 -2
  106. package/src/migrations/update-16-1-0/extract-standalone-config-from-bootstrap.js +0 -127
  107. package/src/migrations/update-16-1-0/remove-ngcc-invocation.js +0 -22
  108. package/src/migrations/update-16-1-0/remove-render-module-platform-server-exports.d.ts +0 -2
  109. package/src/migrations/update-16-1-0/remove-render-module-platform-server-exports.js +0 -62
  110. package/src/migrations/update-16-1-0/update-server-executor-config.d.ts +0 -2
  111. package/src/migrations/update-16-1-0/update-server-executor-config.js +0 -26
  112. package/src/runtime/nx/data-persistence.d.ts +0 -276
  113. package/testing/index.d.ts +0 -1
  114. package/testing/ng-package.json +0 -6
  115. package/testing/src/testing-utils.d.ts +0 -33
@@ -1,127 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = extractStandaloneConfig;
4
- const devkit_1 = require("@nx/devkit");
5
- const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
6
- const path_1 = require("path");
7
- const projects_1 = require("../utils/projects");
8
- let tsModule;
9
- let tsquery;
10
- function getBootstrapCallFileInfo(tree, project, mainFilePath) {
11
- const IMPORT_BOOTSTRAP_FILE = 'CallExpression:has(ImportKeyword) > StringLiteral';
12
- let bootstrapCallFilePath = mainFilePath;
13
- let bootstrapCallFileContents = tree.read(bootstrapCallFilePath, 'utf-8');
14
- const ast = tsquery.ast(bootstrapCallFileContents);
15
- const importBootstrapNodes = tsquery(ast, IMPORT_BOOTSTRAP_FILE, {
16
- visitAllChildren: true,
17
- });
18
- if (importBootstrapNodes.length > 0 &&
19
- importBootstrapNodes[0].getText().includes('./bootstrap')) {
20
- bootstrapCallFilePath = (0, devkit_1.joinPathFragments)(project.sourceRoot, 'bootstrap.ts');
21
- bootstrapCallFileContents = tree.read(bootstrapCallFilePath, 'utf-8');
22
- }
23
- return { bootstrapCallFilePath, bootstrapCallFileContents };
24
- }
25
- function getImportTokenMap(bootstrapCallFileContentsAst) {
26
- const importTokenMap = new Map();
27
- const importedTokensNodes = tsquery(bootstrapCallFileContentsAst, 'ImportDeclaration > ImportClause', { visitAllChildren: true });
28
- for (const node of importedTokensNodes) {
29
- importTokenMap.set(node.getText(), node.parent.getText());
30
- }
31
- return importTokenMap;
32
- }
33
- function getImportsRequiredForAppConfig(importTokenMap, appConfigNode, oldSourceFilePath, newSourceFilePath) {
34
- const identifiers = tsquery.query(appConfigNode, 'Identifier:not(PropertyAssignment > Identifier)', { visitAllChildren: true });
35
- const appConfigImports = new Set();
36
- const originalImportsToRemove = new Set();
37
- for (const identifier of identifiers) {
38
- for (const key of importTokenMap.keys()) {
39
- if (!key.includes(identifier.getText())) {
40
- continue;
41
- }
42
- let importText = importTokenMap.get(key);
43
- originalImportsToRemove.add(importText);
44
- if (oldSourceFilePath === newSourceFilePath ||
45
- oldSourceFilePath.split('/').length ===
46
- newSourceFilePath.split('/').length) {
47
- appConfigImports.add(importText);
48
- continue;
49
- }
50
- const importPath = tsquery
51
- .query(importText, 'StringLiteral', {
52
- visitAllChildren: true,
53
- })[0]
54
- .getText()
55
- .replace(/'/g, '')
56
- .replace(/"/g, '');
57
- if (importPath.startsWith('.')) {
58
- const resolvedImportPath = (0, path_1.resolve)((0, path_1.dirname)(oldSourceFilePath), importPath);
59
- const newRelativeImportPath = (0, path_1.relative)((0, path_1.dirname)(newSourceFilePath), resolvedImportPath);
60
- importText = importText.replace(importPath, newRelativeImportPath.startsWith('.')
61
- ? newRelativeImportPath
62
- : `./${newRelativeImportPath}`);
63
- }
64
- appConfigImports.add(importText);
65
- }
66
- }
67
- return {
68
- appConfigImports: Array.from(appConfigImports),
69
- importsToRemoveFromSource: Array.from(originalImportsToRemove),
70
- };
71
- }
72
- function getAppConfigFileContents(importsRequiredForAppConfig, appConfigText) {
73
- const buildAppConfigFileContents = (importStatements, appConfig) => `import { ApplicationConfig } from '@angular/core';${importStatements.join('\n')}
74
- export const appConfig: ApplicationConfig = ${appConfig}`;
75
- const appConfigFileContents = buildAppConfigFileContents(importsRequiredForAppConfig, appConfigText);
76
- return appConfigFileContents;
77
- }
78
- function getBootstrapCallFileContents(bootstrapCallFileContents, appConfigNode, importsRequiredForAppConfig) {
79
- let newBootstrapCallFileContents = `import { appConfig } from './app/app.config';
80
- ${bootstrapCallFileContents.slice(0, appConfigNode.getStart())}appConfig${bootstrapCallFileContents.slice(appConfigNode.getEnd())}`;
81
- for (const importStatement of importsRequiredForAppConfig) {
82
- newBootstrapCallFileContents = newBootstrapCallFileContents.replace(importStatement, '');
83
- }
84
- return newBootstrapCallFileContents;
85
- }
86
- async function extractStandaloneConfig(tree) {
87
- if (!tsModule) {
88
- tsModule = (0, ensure_typescript_1.ensureTypescript)();
89
- }
90
- if (!tsquery) {
91
- tsquery = require('@phenomnomnominal/tsquery').tsquery;
92
- }
93
- const projects = await (0, projects_1.getProjectsFilteredByDependencies)(tree, [
94
- 'npm:@angular/core',
95
- ]);
96
- const BOOTSTRAP_APPLICATION_CALL_SELECTOR = 'CallExpression:has(Identifier[name=bootstrapApplication])';
97
- const BOOTSTRAP_APPLICATION_CALL_CONFIG_SELECTOR = 'CallExpression:has(Identifier[name=bootstrapApplication]) > ObjectLiteralExpression';
98
- for (const { project } of projects) {
99
- if (project.projectType !== 'application') {
100
- continue;
101
- }
102
- if (project.targets?.build?.options?.main === undefined) {
103
- continue;
104
- }
105
- const { bootstrapCallFilePath, bootstrapCallFileContents } = getBootstrapCallFileInfo(tree, project, project.targets.build.options.main);
106
- const bootstrapCallFileContentsAst = tsquery.ast(bootstrapCallFileContents);
107
- const nodes = tsquery(bootstrapCallFileContentsAst, BOOTSTRAP_APPLICATION_CALL_SELECTOR, { visitAllChildren: true });
108
- if (nodes.length === 0) {
109
- continue;
110
- }
111
- const importTokenMap = getImportTokenMap(bootstrapCallFileContentsAst);
112
- const bootstrapCallNode = nodes[0];
113
- const appConfigNodes = tsquery(bootstrapCallNode, BOOTSTRAP_APPLICATION_CALL_CONFIG_SELECTOR, { visitAllChildren: true });
114
- if (appConfigNodes.length === 0) {
115
- continue;
116
- }
117
- const appConfigNode = appConfigNodes[0];
118
- const appConfigText = appConfigNode.getText();
119
- const appConfigFilePath = (0, devkit_1.joinPathFragments)(project.sourceRoot, 'app/app.config.ts');
120
- const { appConfigImports, importsToRemoveFromSource } = getImportsRequiredForAppConfig(importTokenMap, appConfigNode, bootstrapCallFilePath, appConfigFilePath);
121
- const appConfigFileContents = getAppConfigFileContents(appConfigImports, appConfigText);
122
- tree.write(appConfigFilePath, appConfigFileContents);
123
- let newBootstrapCallFileContents = getBootstrapCallFileContents(bootstrapCallFileContents, appConfigNode, importsToRemoveFromSource);
124
- tree.write(bootstrapCallFilePath, newBootstrapCallFileContents);
125
- }
126
- await (0, devkit_1.formatFiles)(tree);
127
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const devkit_1 = require("@nx/devkit");
5
- async function default_1(tree) {
6
- (0, devkit_1.updateJson)(tree, 'package.json', (json) => {
7
- if (!json.scripts?.postinstall?.includes('ngcc ')) {
8
- return json;
9
- }
10
- json.scripts.postinstall = json.scripts.postinstall
11
- // special case when ngcc is at the start so we remove the && as well
12
- .replace(/^(ngcc.*?&& *)(.*)/, '$2')
13
- // everything else
14
- .replace(/(.*?)((&& *)?ngcc.*?)((?=&)|$)(.*)/, '$1$5')
15
- .trim();
16
- if (json.scripts.postinstall === '') {
17
- json.scripts.postinstall = undefined;
18
- }
19
- return json;
20
- });
21
- await (0, devkit_1.formatFiles)(tree);
22
- }
@@ -1,2 +0,0 @@
1
- import type { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const tslib_1 = require("tslib");
5
- const devkit_1 = require("@nx/devkit");
6
- const ts = tslib_1.__importStar(require("typescript"));
7
- const file_change_recorder_1 = require("../../utils/file-change-recorder");
8
- async function default_1(tree) {
9
- (0, devkit_1.visitNotIgnoredFiles)(tree, '/', (path) => {
10
- if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
11
- const content = tree.read(path, 'utf8');
12
- if (content.includes('@angular/platform-server') &&
13
- content.includes('renderModule')) {
14
- const source = ts.createSourceFile(path, content.toString().replace(/^\uFEFF/, ''), ts.ScriptTarget.Latest, true);
15
- let recorder;
16
- let printer;
17
- ts.forEachChild(source, function analyze(node) {
18
- if (!(ts.isExportDeclaration(node) &&
19
- node.moduleSpecifier &&
20
- ts.isStringLiteral(node.moduleSpecifier) &&
21
- node.moduleSpecifier.text === '@angular/platform-server' &&
22
- node.exportClause &&
23
- ts.isNamedExports(node.exportClause))) {
24
- // Not a @angular/platform-server named export.
25
- return;
26
- }
27
- const exportClause = node.exportClause;
28
- const newElements = [];
29
- for (const element of exportClause.elements) {
30
- if (element.name.text !== 'renderModule') {
31
- newElements.push(element);
32
- }
33
- }
34
- if (newElements.length === exportClause.elements.length) {
35
- // No changes
36
- return;
37
- }
38
- recorder ??= new file_change_recorder_1.FileChangeRecorder(tree, path);
39
- if (newElements.length) {
40
- // Update named exports as there are leftovers.
41
- const newExportClause = ts.factory.updateNamedExports(exportClause, newElements);
42
- printer ??= ts.createPrinter();
43
- const fix = printer.printNode(ts.EmitHint.Unspecified, newExportClause, source);
44
- const index = exportClause.getStart();
45
- const length = exportClause.getWidth();
46
- recorder.remove(index, index + length);
47
- recorder.insertLeft(index, fix);
48
- }
49
- else {
50
- // Delete export as no exports remain.
51
- recorder.remove(node.getStart(), node.getStart() + node.getWidth());
52
- }
53
- ts.forEachChild(node, analyze);
54
- });
55
- if (recorder) {
56
- recorder.applyChanges();
57
- }
58
- }
59
- }
60
- });
61
- await (0, devkit_1.formatFiles)(tree);
62
- }
@@ -1,2 +0,0 @@
1
- import type { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const devkit_1 = require("@nx/devkit");
5
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
- const executors = [
7
- '@angular-devkit/build-angular:server',
8
- '@nx/angular:server',
9
- '@nrwl/angular:server',
10
- ];
11
- async function default_1(tree) {
12
- executors.forEach((executor) => {
13
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, executor, (_options, projectName, targetName, configurationName) => {
14
- const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, projectName);
15
- const configToUpdate = configurationName
16
- ? projectConfiguration.targets[targetName].configurations[configurationName]
17
- : projectConfiguration.targets[targetName].options;
18
- if (configToUpdate?.buildOptimizer === undefined &&
19
- configToUpdate?.optimization !== undefined) {
20
- configToUpdate.buildOptimizer = !!configToUpdate.optimization;
21
- }
22
- (0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
23
- });
24
- });
25
- await (0, devkit_1.formatFiles)(tree);
26
- }
@@ -1,276 +0,0 @@
1
- import type { Type } from '@angular/core';
2
- import type { ActivatedRouteSnapshot } from '@angular/router';
3
- import type { Action } from '@ngrx/store';
4
- import type { Observable } from 'rxjs';
5
- export interface PessimisticUpdateOpts<T extends Array<unknown>, A> {
6
- run(a: A, ...slices: [...T]): Observable<Action> | Action | void;
7
- onError(a: A, e: any): Observable<any> | any;
8
- }
9
- export interface OptimisticUpdateOpts<T extends Array<unknown>, A> {
10
- run(a: A, ...slices: [...T]): Observable<Action> | Action | void;
11
- undoAction(a: A, e: any): Observable<Action> | Action;
12
- }
13
- export interface FetchOpts<T extends Array<unknown>, A> {
14
- id?(a: A, ...slices: [...T]): any;
15
- run(a: A, ...slices: [...T]): Observable<Action> | Action | void;
16
- onError?(a: A, e: any): Observable<any> | any;
17
- }
18
- export interface HandleNavigationOpts<T extends Array<unknown>> {
19
- run(a: ActivatedRouteSnapshot, ...slices: [...T]): Observable<Action> | Action | void;
20
- onError?(a: ActivatedRouteSnapshot, e: any): Observable<any> | any;
21
- }
22
- export type ActionOrActionWithStates<T extends Array<unknown>, A> = A | [A, ...T];
23
- export type ActionOrActionWithState<T, A> = ActionOrActionWithStates<[T], A>;
24
- export type ActionStatesStream<T extends Array<unknown>, A> = Observable<ActionOrActionWithStates<T, A>>;
25
- export type ActionStateStream<T, A> = Observable<ActionOrActionWithStates<[T], A>>;
26
- /**
27
- * @whatItDoes Handles pessimistic updates (updating the server first).
28
- *
29
- * Updating the server, when implemented naively, suffers from race conditions and poor error handling.
30
- *
31
- * `pessimisticUpdate` addresses these problems. It runs all fetches in order, which removes race conditions
32
- * and forces the developer to handle errors.
33
- *
34
- * ## Example:
35
- *
36
- * ```typescript
37
- * @Injectable()
38
- * class TodoEffects {
39
- * updateTodo$ = createEffect(() =>
40
- * this.actions$.pipe(
41
- * ofType('UPDATE_TODO'),
42
- * pessimisticUpdate({
43
- * // provides an action
44
- * run: (action: UpdateTodo) => {
45
- * // update the backend first, and then dispatch an action that will
46
- * // update the client side
47
- * return this.backend.updateTodo(action.todo.id, action.todo).pipe(
48
- * map((updated) => ({
49
- * type: 'UPDATE_TODO_SUCCESS',
50
- * todo: updated,
51
- * }))
52
- * );
53
- * },
54
- * onError: (action: UpdateTodo, error: any) => {
55
- * // we don't need to undo the changes on the client side.
56
- * // we can dispatch an error, or simply log the error here and return `null`
57
- * return null;
58
- * },
59
- * })
60
- * )
61
- * );
62
- *
63
- * constructor(private actions$: Actions, private backend: Backend) {}
64
- * }
65
- * ```
66
- *
67
- * Note that if you don't return a new action from the run callback, you must set the dispatch property
68
- * of the effect to false, like this:
69
- *
70
- * ```typescript
71
- * class TodoEffects {
72
- * updateTodo$ = createEffect(() =>
73
- * this.actions$.pipe(
74
- * //...
75
- * ), { dispatch: false }
76
- * );
77
- * }
78
- * ```
79
- *
80
- * @param opts
81
- *
82
- * @deprecated This will be removed in Nx v21. Import `pessimisticUpdate` from `@ngrx/router-store/data-persistence` instead.
83
- */
84
- export declare function pessimisticUpdate<T extends Array<unknown>, A extends Action>(opts: PessimisticUpdateOpts<T, A>): (source: ActionStatesStream<T, A>) => Observable<Action>;
85
- /**
86
- * @whatItDoes Handles optimistic updates (updating the client first).
87
- *
88
- * It runs all fetches in order, which removes race conditions and forces the developer to handle errors.
89
- *
90
- * When using `optimisticUpdate`, in case of a failure, the developer has already updated the state locally,
91
- * so the developer must provide an undo action.
92
- *
93
- * The error handling must be done in the callback, or by means of the undo action.
94
- *
95
- * ## Example:
96
- *
97
- * ```typescript
98
- * @Injectable()
99
- * class TodoEffects {
100
- * updateTodo$ = createEffect(() =>
101
- * this.actions$.pipe(
102
- * ofType('UPDATE_TODO'),
103
- * optimisticUpdate({
104
- * // provides an action
105
- * run: (action: UpdateTodo) => {
106
- * return this.backend.updateTodo(action.todo.id, action.todo).pipe(
107
- * mapTo({
108
- * type: 'UPDATE_TODO_SUCCESS',
109
- * })
110
- * );
111
- * },
112
- * undoAction: (action: UpdateTodo, error: any) => {
113
- * // dispatch an undo action to undo the changes in the client state
114
- * return {
115
- * type: 'UNDO_TODO_UPDATE',
116
- * todo: action.todo,
117
- * };
118
- * },
119
- * })
120
- * )
121
- * );
122
- *
123
- * constructor(private actions$: Actions, private backend: Backend) {}
124
- * }
125
- * ```
126
- *
127
- * Note that if you don't return a new action from the run callback, you must set the dispatch property
128
- * of the effect to false, like this:
129
- *
130
- * ```typescript
131
- * class TodoEffects {
132
- * updateTodo$ = createEffect(() =>
133
- * this.actions$.pipe(
134
- * //...
135
- * ), { dispatch: false }
136
- * );
137
- * }
138
- * ```
139
- *
140
- * @param opts
141
- *
142
- * @deprecated This will be removed in Nx v21. Import `optimisticUpdate` from `@ngrx/router-store/data-persistence` instead.
143
- */
144
- export declare function optimisticUpdate<T extends Array<unknown>, A extends Action>(opts: OptimisticUpdateOpts<T, A>): (source: ActionStatesStream<T, A>) => Observable<Action>;
145
- /**
146
- * @whatItDoes Handles data fetching.
147
- *
148
- * Data fetching implemented naively suffers from race conditions and poor error handling.
149
- *
150
- * `fetch` addresses these problems. It runs all fetches in order, which removes race conditions
151
- * and forces the developer to handle errors.
152
- *
153
- * ## Example:
154
- *
155
- * ```typescript
156
- * @Injectable()
157
- * class TodoEffects {
158
- * loadTodos$ = createEffect(() =>
159
- * this.actions$.pipe(
160
- * ofType('GET_TODOS'),
161
- * fetch({
162
- * // provides an action
163
- * run: (a: GetTodos) => {
164
- * return this.backend.getAll().pipe(
165
- * map((response) => ({
166
- * type: 'TODOS',
167
- * todos: response.todos,
168
- * }))
169
- * );
170
- * },
171
- * onError: (action: GetTodos, error: any) => {
172
- * // dispatch an undo action to undo the changes in the client state
173
- * return null;
174
- * },
175
- * })
176
- * )
177
- * );
178
- *
179
- * constructor(private actions$: Actions, private backend: Backend) {}
180
- * }
181
- * ```
182
- *
183
- * This is correct, but because it set the concurrency to 1, it may not be performant.
184
- *
185
- * To fix that, you can provide the `id` function, like this:
186
- *
187
- * ```typescript
188
- * @Injectable()
189
- * class TodoEffects {
190
- * loadTodo$ = createEffect(() =>
191
- * this.actions$.pipe(
192
- * ofType('GET_TODO'),
193
- * fetch({
194
- * id: (todo: GetTodo) => {
195
- * return todo.id;
196
- * },
197
- * // provides an action
198
- * run: (todo: GetTodo) => {
199
- * return this.backend.getTodo(todo.id).map((response) => ({
200
- * type: 'LOAD_TODO_SUCCESS',
201
- * todo: response.todo,
202
- * }));
203
- * },
204
- * onError: (action: GetTodo, error: any) => {
205
- * // dispatch an undo action to undo the changes in the client state
206
- * return null;
207
- * },
208
- * })
209
- * )
210
- * );
211
- *
212
- * constructor(private actions$: Actions, private backend: Backend) {}
213
- * }
214
- * ```
215
- *
216
- * With this setup, the requests for Todo 1 will run concurrently with the requests for Todo 2.
217
- *
218
- * In addition, if there are multiple requests for Todo 1 scheduled, it will only run the last one.
219
- *
220
- * @param opts
221
- *
222
- * @deprecated This will be removed in Nx v21. Import `fetch` from `@ngrx/router-store/data-persistence` instead.
223
- */
224
- export declare function fetch<T extends Array<unknown>, A extends Action>(opts: FetchOpts<T, A>): (source: ActionStatesStream<T, A>) => Observable<Action>;
225
- /**
226
- * @whatItDoes Handles data fetching as part of router navigation.
227
- *
228
- * Data fetching implemented naively suffers from race conditions and poor error handling.
229
- *
230
- * `navigation` addresses these problems.
231
- *
232
- * It checks if an activated router state contains the passed in component type, and, if it does, runs the `run`
233
- * callback. It provides the activated snapshot associated with the component and the current state. And it only runs
234
- * the last request.
235
- *
236
- * ## Example:
237
- *
238
- * ```typescript
239
- * @Injectable()
240
- * class TodoEffects {
241
- * loadTodo$ = createEffect(() =>
242
- * this.actions$.pipe(
243
- * // listens for the routerNavigation action from @ngrx/router-store
244
- * navigation(TodoComponent, {
245
- * run: (activatedRouteSnapshot: ActivatedRouteSnapshot) => {
246
- * return this.backend
247
- * .fetchTodo(activatedRouteSnapshot.params['id'])
248
- * .pipe(
249
- * map((todo) => ({
250
- * type: 'LOAD_TODO_SUCCESS',
251
- * todo: todo,
252
- * }))
253
- * );
254
- * },
255
- * onError: (
256
- * activatedRouteSnapshot: ActivatedRouteSnapshot,
257
- * error: any
258
- * ) => {
259
- * // we can log and error here and return null
260
- * // we can also navigate back
261
- * return null;
262
- * },
263
- * })
264
- * )
265
- * );
266
- *
267
- * constructor(private actions$: Actions, private backend: Backend) {}
268
- * }
269
- * ```
270
- *
271
- * @param component
272
- * @param opts
273
- *
274
- * @deprecated This will be removed in Nx v21. Import `navigation` from `@ngrx/router-store/data-persistence` instead.
275
- */
276
- export declare function navigation<T extends Array<unknown>, A extends Action>(component: Type<any>, opts: HandleNavigationOpts<T>): (source: ActionStatesStream<T, A>) => Observable<Action<string>>;
@@ -1 +0,0 @@
1
- export { readAll, readFirst } from './src/testing-utils';
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
3
- "lib": {
4
- "entryFile": "index.ts"
5
- }
6
- }
@@ -1,33 +0,0 @@
1
- import type { Observable } from 'rxjs';
2
- /**
3
- * @deprecated This will be removed in Nx v21. If using RxJS 7, use `firstValueFrom(obs$.pipe(toArray()))`
4
- * or `lastValueFrom(obs$.pipe(toArray()))`. If using RxJS 6, use `obs$.pipe(toArray()).toPromise()`.
5
- *
6
- * @whatItDoes reads all the values from an observable and returns a promise
7
- * with an array of all values. This should be used in combination with async/await.
8
- *
9
- * ## Example
10
- *
11
- * ```typescript
12
- * const obs = of(1, 2, 3, 4);
13
- * const res = await readAll(obs)
14
- * expect(res).toEqual([1, 2, 3, 4]);
15
- * ```
16
- */
17
- export declare function readAll<T>(o: Observable<T>): Promise<T[]>;
18
- /**
19
- * @deprecated This will be removed in Nx v21. Since RxJS 7, use `firstValueFrom(obs$)`. If using RxJS 6,
20
- * use `obs$.pipe(first()).toPromise()`.
21
- *
22
- * @whatItDoes reads the first value from an observable and returns a promise
23
- * with it. This should be used in combination with async/await.
24
- *
25
- * ## Example
26
- *
27
- * ```typescript
28
- * const obs = of(1, 2, 3, 4);
29
- * const res = await readFirst(obs)
30
- * expect(res).toEqual(1);
31
- * ```
32
- */
33
- export declare function readFirst<T>(o: Observable<T>): Promise<T>;