@rxap/ts-morph 1.1.0-dev.9 → 1.2.0-dev.0

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 (86) hide show
  1. package/CHANGELOG.md +170 -0
  2. package/README.md +1 -1
  3. package/package.json +8 -6
  4. package/src/index.d.ts +13 -0
  5. package/src/index.js +13 -0
  6. package/src/index.js.map +1 -1
  7. package/src/lib/angular/add-route.d.ts +12 -0
  8. package/src/lib/angular/add-route.js +77 -0
  9. package/src/lib/angular/add-route.js.map +1 -0
  10. package/src/lib/angular/build-route-object.d.ts +20 -0
  11. package/src/lib/angular/build-route-object.js +68 -0
  12. package/src/lib/angular/build-route-object.js.map +1 -0
  13. package/src/lib/angular/coerce-app-config-provider.js +1 -1
  14. package/src/lib/angular/coerce-app-config-provider.js.map +1 -1
  15. package/src/lib/angular/coerce-app-navigation.d.ts +13 -0
  16. package/src/lib/angular/coerce-app-navigation.js +99 -0
  17. package/src/lib/angular/coerce-app-navigation.js.map +1 -0
  18. package/src/lib/angular/coerce-app-routes.d.ts +4 -0
  19. package/src/lib/angular/coerce-app-routes.js +27 -0
  20. package/src/lib/angular/coerce-app-routes.js.map +1 -0
  21. package/src/lib/angular/coerce-component-import.d.ts +1 -1
  22. package/src/lib/angular/coerce-component-import.js +9 -7
  23. package/src/lib/angular/coerce-component-import.js.map +1 -1
  24. package/src/lib/angular/coerce-component-input.js +10 -10
  25. package/src/lib/angular/coerce-component-input.js.map +1 -1
  26. package/src/lib/angular/coerce-component.d.ts +1 -1
  27. package/src/lib/angular/coerce-component.js +15 -2
  28. package/src/lib/angular/coerce-component.js.map +1 -1
  29. package/src/lib/angular/coerce-layout-routes.d.ts +4 -0
  30. package/src/lib/angular/coerce-layout-routes.js +63 -0
  31. package/src/lib/angular/coerce-layout-routes.js.map +1 -0
  32. package/src/lib/angular/coerce-route-guard.d.ts +6 -0
  33. package/src/lib/angular/coerce-route-guard.js +34 -0
  34. package/src/lib/angular/coerce-route-guard.js.map +1 -0
  35. package/src/lib/angular/coerce-routes.d.ts +8 -0
  36. package/src/lib/angular/coerce-routes.js +43 -0
  37. package/src/lib/angular/coerce-routes.js.map +1 -0
  38. package/src/lib/angular/find-parent-route.d.ts +6 -0
  39. package/src/lib/angular/find-parent-route.js +76 -0
  40. package/src/lib/angular/find-parent-route.js.map +1 -0
  41. package/src/lib/angular/get-component-decorator-object.js +5 -5
  42. package/src/lib/angular/get-component-decorator-object.js.map +1 -1
  43. package/src/lib/angular/remove-component-import.d.ts +3 -0
  44. package/src/lib/angular/remove-component-import.js +23 -0
  45. package/src/lib/angular/remove-component-import.js.map +1 -0
  46. package/src/lib/angular/remove-route.d.ts +13 -0
  47. package/src/lib/angular/remove-route.js +58 -0
  48. package/src/lib/angular/remove-route.js.map +1 -0
  49. package/src/lib/coerce-array-element.js +6 -1
  50. package/src/lib/coerce-array-element.js.map +1 -1
  51. package/src/lib/coerce-default-class-export.d.ts +1 -1
  52. package/src/lib/coerce-default-class-export.js +3 -16
  53. package/src/lib/coerce-default-class-export.js.map +1 -1
  54. package/src/lib/coerce-default-export.d.ts +2 -0
  55. package/src/lib/coerce-default-export.js +14 -0
  56. package/src/lib/coerce-default-export.js.map +1 -0
  57. package/src/lib/coerce-dependency-injection.d.ts +1 -1
  58. package/src/lib/coerce-dependency-injection.js +42 -31
  59. package/src/lib/coerce-dependency-injection.js.map +1 -1
  60. package/src/lib/coerce-imports.js +10 -0
  61. package/src/lib/coerce-imports.js.map +1 -1
  62. package/src/lib/coerce-statements.d.ts +1 -1
  63. package/src/lib/coerce-statements.js +8 -3
  64. package/src/lib/coerce-statements.js.map +1 -1
  65. package/src/lib/data-property.d.ts +10 -6
  66. package/src/lib/data-property.js +31 -7
  67. package/src/lib/data-property.js.map +1 -1
  68. package/src/lib/get-coerce-array-literal-form-object-literal.d.ts +1 -0
  69. package/src/lib/get-coerce-array-literal-form-object-literal.js +19 -1
  70. package/src/lib/get-coerce-array-literal-form-object-literal.js.map +1 -1
  71. package/src/lib/identifier.d.ts +10 -0
  72. package/src/lib/identifier.js +16 -0
  73. package/src/lib/identifier.js.map +1 -0
  74. package/src/lib/nest/add-health-endpoint.js +1 -0
  75. package/src/lib/nest/add-health-endpoint.js.map +1 -1
  76. package/src/lib/nest/coerce-nest-app-config.js +14 -1
  77. package/src/lib/nest/coerce-nest-app-config.js.map +1 -1
  78. package/src/lib/nest/coerce-nest-cache-module-import.d.ts +4 -0
  79. package/src/lib/nest/coerce-nest-cache-module-import.js +26 -0
  80. package/src/lib/nest/coerce-nest-cache-module-import.js.map +1 -0
  81. package/src/lib/type-import.d.ts +18 -3
  82. package/src/lib/type-import.js +28 -8
  83. package/src/lib/type-import.js.map +1 -1
  84. package/src/lib/upstream-options.d.ts +49 -7
  85. package/src/lib/upstream-options.js +69 -15
  86. package/src/lib/upstream-options.js.map +1 -1
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoerceAppNavigation = void 0;
4
+ const utilities_1 = require("@rxap/utilities");
5
+ const ts_morph_1 = require("ts-morph");
6
+ const coerce_imports_1 = require("../coerce-imports");
7
+ const coerce_variable_declaration_1 = require("../coerce-variable-declaration");
8
+ function CoerceAppNavigation(sourceFile, options = {}) {
9
+ var _a, _b, _c, _d, _e;
10
+ const variableDeclaration = (0, coerce_variable_declaration_1.CoerceVariableDeclaration)(sourceFile, 'APP_NAVIGATION', {
11
+ type: '() => NavigationWithInserts',
12
+ initializer: '() => []',
13
+ });
14
+ (0, coerce_variable_declaration_1.CoerceVariableDeclaration)(sourceFile, 'APP_NAVIGATION_PROVIDER', {
15
+ initializer: ts_morph_1.Writers.object({
16
+ provide: 'RXAP_NAVIGATION_CONFIG',
17
+ useValue: 'APP_NAVIGATION',
18
+ }),
19
+ });
20
+ (0, coerce_imports_1.CoerceImports)(sourceFile, [
21
+ {
22
+ namedImports: ['NavigationWithInserts', 'RXAP_NAVIGATION_CONFIG'],
23
+ moduleSpecifier: '@rxap/layout',
24
+ },
25
+ ]);
26
+ if (!((_a = options.itemList) === null || _a === void 0 ? void 0 : _a.length)) {
27
+ return;
28
+ }
29
+ const arrowFunction = variableDeclaration.getInitializerIfKindOrThrow(ts_morph_1.SyntaxKind.ArrowFunction);
30
+ const array = arrowFunction.getBody().asKindOrThrow(ts_morph_1.SyntaxKind.ArrayLiteralExpression);
31
+ const arrayLiteralExpression = array.asKindOrThrow(ts_morph_1.SyntaxKind.ArrayLiteralExpression);
32
+ const existingItems = arrayLiteralExpression.getElements()
33
+ .filter(e => e.isKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression))
34
+ .map(e => e.asKindOrThrow(ts_morph_1.SyntaxKind.ObjectLiteralExpression));
35
+ const existingItemLabels = existingItems.map(e => {
36
+ var _a;
37
+ return (_a = e.getProperty('label')) === null || _a === void 0 ? void 0 : _a.asKindOrThrow(ts_morph_1.SyntaxKind.PropertyAssignment).getInitializerIfKindOrThrow(ts_morph_1.SyntaxKind.StringLiteral).getText().trim().replace(/['"]/g, '');
38
+ });
39
+ for (const item of (_b = options.itemList) !== null && _b !== void 0 ? _b : []) {
40
+ const existingItemIndex = existingItemLabels.findIndex(e => e === item.label);
41
+ const routerLink = w => {
42
+ w.write('[');
43
+ for (let i = 0; i < item.routerLink.length; i++) {
44
+ const link = item.routerLink[i];
45
+ w.quote(link);
46
+ if (i < item.routerLink.length - 1) {
47
+ w.write(',');
48
+ }
49
+ }
50
+ w.write(']');
51
+ };
52
+ let icon = null;
53
+ if (item.icon) {
54
+ const iconObj = {};
55
+ if (item.icon.color) {
56
+ iconObj['color'] = w => w.quote(item.icon.color);
57
+ }
58
+ if ((0, utilities_1.IsSvgIcon)(item.icon)) {
59
+ const name = item.icon.svgIcon;
60
+ iconObj['svgIcon'] = w => w.quote(name);
61
+ }
62
+ if ((0, utilities_1.IsMaterialIcon)(item.icon)) {
63
+ const name = item.icon.icon;
64
+ iconObj['icon'] = w => w.quote(name);
65
+ }
66
+ icon = ts_morph_1.Writers.object(iconObj);
67
+ }
68
+ if (existingItemIndex === -1) {
69
+ const obj = {
70
+ routerLink,
71
+ label: w => w.quote(item.label),
72
+ };
73
+ if (icon) {
74
+ obj['icon'] = icon;
75
+ }
76
+ arrayLiteralExpression.addElement(ts_morph_1.Writers.object(obj));
77
+ }
78
+ else {
79
+ const existingItem = existingItems[existingItemIndex];
80
+ (_c = existingItem.getProperty('routerLink')) === null || _c === void 0 ? void 0 : _c.asKindOrThrow(ts_morph_1.SyntaxKind.PropertyAssignment).setInitializer(routerLink);
81
+ if (icon) {
82
+ if (!existingItem.getProperty('icon')) {
83
+ existingItem.addPropertyAssignment({
84
+ name: 'icon',
85
+ initializer: icon,
86
+ });
87
+ }
88
+ else if (options.overwrite) {
89
+ (_d = existingItem.getProperty('icon')) === null || _d === void 0 ? void 0 : _d.asKindOrThrow(ts_morph_1.SyntaxKind.PropertyAssignment).setInitializer(icon);
90
+ }
91
+ }
92
+ else if (options.overwrite) {
93
+ (_e = existingItem.getProperty('icon')) === null || _e === void 0 ? void 0 : _e.remove();
94
+ }
95
+ }
96
+ }
97
+ }
98
+ exports.CoerceAppNavigation = CoerceAppNavigation;
99
+ //# sourceMappingURL=coerce-app-navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-app-navigation.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-app-navigation.ts"],"names":[],"mappings":";;;AAAA,+CAIyB;AACzB,uCAKkB;AAClB,sDAAkD;AAClD,gFAA2E;AAc3E,SAAgB,mBAAmB,CAAC,UAAsB,EAAE,UAAsC,EAAE;;IAElG,MAAM,mBAAmB,GAAG,IAAA,uDAAyB,EAAC,UAAU,EAAE,gBAAgB,EAAE;QAClF,IAAI,EAAE,6BAA6B;QACnC,WAAW,EAAE,UAAU;KACxB,CAAC,CAAC;IAEH,IAAA,uDAAyB,EAAC,UAAU,EAAE,yBAAyB,EAAE;QAC/D,WAAW,EAAE,kBAAO,CAAC,MA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AC;aAC5C;SACF;KAEF;AAEH,CAAC;AA3FD,kDA2FC"}
@@ -0,0 +1,4 @@
1
+ import { SourceFile } from 'ts-morph';
2
+ import { CoerceRoutesOptions } from './coerce-routes';
3
+ export type CoerceAppRoutesOptions = CoerceRoutesOptions;
4
+ export declare function CoerceAppRoutes(sourceFile: SourceFile, options?: CoerceAppRoutesOptions): import("ts-morph").VariableDeclaration;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoerceAppRoutes = void 0;
4
+ const ts_morph_1 = require("ts-morph");
5
+ const coerce_imports_1 = require("../coerce-imports");
6
+ const coerce_routes_1 = require("./coerce-routes");
7
+ function CoerceAppRoutes(sourceFile, options = {}) {
8
+ var _a, _b;
9
+ const variableDeclaration = (0, coerce_routes_1.CoerceRoutes)(sourceFile, Object.assign(Object.assign({}, options), { name: (_a = options.name) !== null && _a !== void 0 ? _a : 'appRoutes', initializer: (_b = options.initializer) !== null && _b !== void 0 ? _b : (w => {
10
+ w.writeLine('[');
11
+ w.write('STATUS_CHECK_ROUTE,');
12
+ ts_morph_1.Writers.object({
13
+ path: w => w.quote('**'),
14
+ redirectTo: w => w.quote('')
15
+ })(w);
16
+ w.write(']');
17
+ }) }));
18
+ (0, coerce_imports_1.CoerceImports)(sourceFile, [
19
+ {
20
+ namedImports: ['STATUS_CHECK_ROUTE'],
21
+ moduleSpecifier: '@rxap/ngx-status-check'
22
+ },
23
+ ]);
24
+ return variableDeclaration;
25
+ }
26
+ exports.CoerceAppRoutes = CoerceAppRoutes;
27
+ //# sourceMappingURL=coerce-app-routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-app-routes.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-app-routes.ts"],"names":[],"mappings":";;;AAAA,uCAGkB;AAClB,sDAAkD;AAClD,mDAGyB;AAIzB,SAAgB,eAAe,CAAC,UAAsB,EAAE,UAAkC,EAAE;;IAE1F,MAAM,mBAAmB,GAAG,IAAA,4BAAY,EAAC,UAAU,kCAC9C,OAAO,KACV,IAAI,EAAE,MAAA,OAAO,CAAC,IAAI,mCAAI,WAAW,EACjC,WAAW,EAAE,MAAA,OAAO,CAAC,WAAW,mCAAI,CAAC,CAAC,CAAC,EAAE;YACvC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACjB,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;YAC/B,kBAAO,CAAC,MAAM,CAAC;gBACb,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;gBACxB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;aAC7B,CAAC,CAAC,CAAC,CAAC,CAAC;YACN,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACf,CAAC,CAAC,IACF,CAAC;IAGH,IAAA,8BAAa,EAAC,UAAU,EAAE;QACxB;YACE,YAAY,EAAE,CAAE,oBAAoB,CAAE;YACtC,eAAe,EAAE,wBAAwB;SAC1C;KACF,CAAC,CAAC;IAEH,OAAO,mBAAmB,CAAC;AAE7B,CAAC;AA1BD,0CA0BC"}
@@ -1,5 +1,5 @@
1
- import { TypeImport } from '@rxap/ts-morph';
2
1
  import { ClassDeclaration, SourceFile } from 'ts-morph';
2
+ import { TypeImport } from '../type-import';
3
3
  /**
4
4
  * Coerces the component import by adding it to the imports array of the component decorator object.
5
5
  * If a module specifier is provided, the import is also coerced at the file level.
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CoerceComponentImport = void 0;
4
- const ts_morph_1 = require("@rxap/ts-morph");
4
+ const ts_morph_1 = require("ts-morph");
5
+ const coerce_array_element_1 = require("../coerce-array-element");
5
6
  const coerce_imports_1 = require("../coerce-imports");
6
- const ts_morph_2 = require("ts-morph");
7
7
  const get_coerce_array_literal_form_object_literal_1 = require("../get-coerce-array-literal-form-object-literal");
8
+ const type_import_1 = require("../type-import");
9
+ const get_component_class_1 = require("./get-component-class");
8
10
  const get_component_decorator_object_1 = require("./get-component-decorator-object");
9
11
  /**
10
12
  * Coerces the component import by adding it to the imports array of the component decorator object.
@@ -16,15 +18,15 @@ const get_component_decorator_object_1 = require("./get-component-decorator-obje
16
18
  */
17
19
  function CoerceComponentImport(sourceFileOrClassDeclaration, componentImport) {
18
20
  var _a;
19
- const classDeclaration = sourceFileOrClassDeclaration instanceof ts_morph_2.ClassDeclaration ? sourceFileOrClassDeclaration : (0, ts_morph_1.GetComponentClass)(sourceFileOrClassDeclaration);
20
- const sourceFile = sourceFileOrClassDeclaration instanceof ts_morph_2.SourceFile ? sourceFileOrClassDeclaration : sourceFileOrClassDeclaration.getSourceFile();
21
+ const classDeclaration = sourceFileOrClassDeclaration instanceof ts_morph_1.ClassDeclaration ? sourceFileOrClassDeclaration : (0, get_component_class_1.GetComponentClass)(sourceFileOrClassDeclaration);
22
+ const sourceFile = sourceFileOrClassDeclaration instanceof ts_morph_1.SourceFile ? sourceFileOrClassDeclaration : sourceFileOrClassDeclaration.getSourceFile();
21
23
  const importName = typeof componentImport === 'string' ? componentImport : (_a = componentImport.namedImport) !== null && _a !== void 0 ? _a : componentImport.name;
22
- if ((0, ts_morph_1.IsTypeImport)(componentImport)) {
23
- (0, coerce_imports_1.CoerceImports)(sourceFile, (0, ts_morph_1.TypeImportToImportStructure)(componentImport));
24
+ if ((0, type_import_1.IsTypeImport)(componentImport)) {
25
+ (0, coerce_imports_1.CoerceImports)(sourceFile, (0, type_import_1.TypeImportToImportStructure)(componentImport));
24
26
  }
25
27
  const componentDecoratorObject = (0, get_component_decorator_object_1.GetComponentDecoratorObject)(classDeclaration);
26
28
  const importsArray = (0, get_coerce_array_literal_form_object_literal_1.GetCoerceArrayLiteralFromObjectLiteral)(componentDecoratorObject, 'imports');
27
- (0, ts_morph_1.CoerceArrayElement)(importsArray, importName);
29
+ (0, coerce_array_element_1.CoerceArrayElement)(importsArray, importName);
28
30
  return importsArray;
29
31
  }
30
32
  exports.CoerceComponentImport = CoerceComponentImport;
@@ -1 +1 @@
1
- {"version":3,"file":"coerce-component-import.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component-import.ts"],"names":[],"mappings":";;;AAAA,6CAMwB;AACxB,sDAAkD;AAClD,uCAGkB;AAClB,kHAAyG;AACzG,qFAA+E;AAE/E;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,4BAA2D,EAC3D,eAAoC;;IAGpC,MAAM,gBAAgB,GAAG,4BAA4B,YAAY,2BAAgB,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,IAAA,4BAAiB,EAAC,4BAA4B,CAAC,CAAC;IACnK,MAAM,UAAU,GAAG,4BAA4B,YAAY,qBAAU,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,4BAA4B,CAAC,aAAa,EAAE,CAAC;IAEpJ,MAAM,UAAU,GAAG,OAAO,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,MAAA,eAAe,CAAC,WAAW,mCAAI,eAAe,CAAC,IAAI,CAAC;IAE/H,IAAI,IAAA,uBAAY,EAAC,eAAe,CAAC,EAAE;QACjC,IAAA,8BAAa,EAAC,UAAU,EAAE,IAAA,sCAA2B,EAAC,eAAe,CAAC,CAAC,CAAC;KACzE;IAED,MAAM,wBAAwB,GAAG,IAAA,4DAA2B,EAAC,gBAAgB,CAAC,CAAC;IAE/E,MAAM,YAAY,GAAG,IAAA,qFAAsC,EAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;IAEjG,IAAA,6BAAkB,EAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAE7C,OAAO,YAAY,CAAC;AAEtB,CAAC;AAtBD,sDAsBC"}
1
+ {"version":3,"file":"coerce-component-import.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component-import.ts"],"names":[],"mappings":";;;AAAA,uCAGkB;AAClB,kEAA6D;AAC7D,sDAAkD;AAClD,kHAAyG;AACzG,gDAIwB;AACxB,+DAA0D;AAC1D,qFAA+E;AAE/E;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,4BAA2D,EAC3D,eAAoC;;IAGpC,MAAM,gBAAgB,GAAG,4BAA4B,YAAY,2BAAgB,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,IAAA,uCAAiB,EAAC,4BAA4B,CAAC,CAAC;IACnK,MAAM,UAAU,GAAG,4BAA4B,YAAY,qBAAU,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,4BAA4B,CAAC,aAAa,EAAE,CAAC;IAEpJ,MAAM,UAAU,GAAG,OAAO,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,MAAA,eAAe,CAAC,WAAW,mCAAI,eAAe,CAAC,IAAI,CAAC;IAE/H,IAAI,IAAA,0BAAY,EAAC,eAAe,CAAC,EAAE;QACjC,IAAA,8BAAa,EAAC,UAAU,EAAE,IAAA,yCAA2B,EAAC,eAAe,CAAC,CAAC,CAAC;KACzE;IAED,MAAM,wBAAwB,GAAG,IAAA,4DAA2B,EAAC,gBAAgB,CAAC,CAAC;IAE/E,MAAM,YAAY,GAAG,IAAA,qFAAsC,EAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;IAEjG,IAAA,yCAAkB,EAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAE7C,OAAO,YAAY,CAAC;AAEtB,CAAC;AAtBD,sDAsBC"}
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CoerceComponentInput = void 0;
4
- const ts_morph_1 = require("@rxap/ts-morph");
4
+ const ts_morph_1 = require("ts-morph");
5
5
  const coerce_accessor_declaration_1 = require("../coerce-accessor-declaration");
6
+ const coerce_decorator_1 = require("../coerce-decorator");
6
7
  const coerce_imports_1 = require("../coerce-imports");
7
- const ts_morph_2 = require("ts-morph");
8
8
  const coerce_property_declaration_1 = require("../coerce-property-declaration");
9
9
  const has_constructor_parameter_1 = require("../has-constructor-parameter");
10
- const get_component_class_1 = require("./get-component-class");
11
10
  const write_type_1 = require("../write-type");
11
+ const get_component_class_1 = require("./get-component-class");
12
12
  function CoerceComponentInput(sourceFileOrClassDeclaration, name, type, { initializer, alias, isRequired, asSetAccessor } = {}) {
13
- const classDeclaration = sourceFileOrClassDeclaration instanceof ts_morph_2.ClassDeclaration ? sourceFileOrClassDeclaration : (0, get_component_class_1.GetComponentClass)(sourceFileOrClassDeclaration);
14
- const sourceFile = sourceFileOrClassDeclaration instanceof ts_morph_2.SourceFile ? sourceFileOrClassDeclaration : sourceFileOrClassDeclaration.getSourceFile();
13
+ const classDeclaration = sourceFileOrClassDeclaration instanceof ts_morph_1.ClassDeclaration ? sourceFileOrClassDeclaration : (0, get_component_class_1.GetComponentClass)(sourceFileOrClassDeclaration);
14
+ const sourceFile = sourceFileOrClassDeclaration instanceof ts_morph_1.SourceFile ? sourceFileOrClassDeclaration : sourceFileOrClassDeclaration.getSourceFile();
15
15
  if ((0, has_constructor_parameter_1.HasConstructorParameter)(classDeclaration, name, true)) {
16
16
  throw new Error(`The component '${classDeclaration.getName()}' already has a constructor parameter that is a class member with the name '${name}'. Cannot add an input with the same name!`);
17
17
  }
@@ -31,12 +31,12 @@ function CoerceComponentInput(sourceFileOrClassDeclaration, name, type, { initia
31
31
  if (isRequired) {
32
32
  inputArgument['required'] = 'true';
33
33
  }
34
- inputDecoratorStructure.arguments = [ts_morph_2.Writers.object(inputArgument)];
34
+ inputDecoratorStructure.arguments = [ts_morph_1.Writers.object(inputArgument)];
35
35
  }
36
36
  let propertyNode;
37
37
  if (asSetAccessor) {
38
38
  propertyNode = (0, coerce_accessor_declaration_1.CoerceSetAccessorDeclaration)(classDeclaration, name, { statements: `this._${name} = ${name};` }).set({
39
- scope: ts_morph_2.Scope.Public,
39
+ scope: ts_morph_1.Scope.Public,
40
40
  parameters: [
41
41
  {
42
42
  name: name,
@@ -44,7 +44,7 @@ function CoerceComponentInput(sourceFileOrClassDeclaration, name, type, { initia
44
44
  },
45
45
  ],
46
46
  });
47
- (0, coerce_property_declaration_1.CoercePropertyDeclaration)(classDeclaration, '_' + name, { scope: ts_morph_2.Scope.Private }).set({
47
+ (0, coerce_property_declaration_1.CoercePropertyDeclaration)(classDeclaration, '_' + name, { scope: ts_morph_1.Scope.Private }).set({
48
48
  type: (0, write_type_1.WriteType)(type, sourceFile),
49
49
  initializer: initializer,
50
50
  hasQuestionToken: !initializer && !isRequired,
@@ -53,14 +53,14 @@ function CoerceComponentInput(sourceFileOrClassDeclaration, name, type, { initia
53
53
  }
54
54
  else {
55
55
  propertyNode = (0, coerce_property_declaration_1.CoercePropertyDeclaration)(classDeclaration, name).set({
56
- scope: ts_morph_2.Scope.Public,
56
+ scope: ts_morph_1.Scope.Public,
57
57
  type: (0, write_type_1.WriteType)(type, sourceFile),
58
58
  initializer,
59
59
  hasQuestionToken: !initializer && !isRequired,
60
60
  hasExclamationToken: !initializer && isRequired,
61
61
  });
62
62
  }
63
- (0, ts_morph_1.CoerceDecorator)(propertyNode, 'Input', inputDecoratorStructure);
63
+ (0, coerce_decorator_1.CoerceDecorator)(propertyNode, 'Input', inputDecoratorStructure);
64
64
  return propertyNode;
65
65
  }
66
66
  exports.CoerceComponentInput = CoerceComponentInput;
@@ -1 +1 @@
1
- {"version":3,"file":"coerce-component-input.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component-input.ts"],"names":[],"mappings":";;;AAAA,6CAAiD;AACjD,gFAA8E;AAE9E,sDAE2B;AAC3B,uCAYkB;AAClB,gFAA2E;AAC3E,4EAAuE;AACvE,+DAA0D;AAE1D,8CAA0C;AAoD1C,SAAgB,oBAAoB,CAClC,4BAA2D,EAC3D,IAAY,EACZ,I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IAAK,MAAO,IAAK,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC;YACtH,KAAK,EAAE,gBAAK,CAAC,MAAM;YACnB,UAAU,EAAE;gBACV;oBACE,IAAI,EAAE,IAAI;oBACV,IAAI,EAAE,IAAA,sBAAS,EAAC,IAAI,EAAE,UAAU,CAAC;iBAClC;aACF;SACF,CAAC,CAAC;QAEH,IAAA,uDAAyB,EAAC,gBAAgB,EAAE,GAAG,GAAG,IAAI,EAAE,EAAE,KAAK,EAAE,gBAAK,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC;YACpF,IAAI,EAAE,IAAA,sBAAS,EAAC,IAAI,EAAE,UAAU,CAAC;YACjC,WAAW,EAAE,WAAW;YACxB,gBAAgB,EAAE,CAAC,WAAW,IAAI,CAAC,UAAU;YAC7C,mBAAmB,EAAE,CAAC,WAAW,IAAI,UAAU;SAChD,CAAC,CAAC;KAEJ;SAAM;QAEL,YAAY,GAAG,IAAA,uDAAyB,EAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC;YACnE,KAAK,EAAE,gBAAK,CAAC,MAAM;YACnB,IAAI,EAAE,IAAA,sBAAS,EAAC,IAAI,EAAE,UAAU,CAAC;YACjC,WAAW;YACX,gBAAgB,EAAE,CAAC,WAAW,IAAI,CAAC,UAAU;YAC7C,mBAAmB,EAAE,CAAC,WAAW,IAAI,UAAU;SAChD,CAAC,CAAC;KAEJ;IAED,IAAA,0BAAe,EAAC,YAAY,EAAE,OAAO,EAAE,uBAAuB,CAAC,CAAC;IAEhE,OAAO,YAAY,CAAC;AAEtB,CAAC;AAxED,oDAwEC"}
1
+ {"version":3,"file":"coerce-component-input.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component-input.ts"],"names":[],"mappings":";;;AAAA,uCAYkB;AAClB,gFAA8E;AAC9E,0DAAsD;AACtD,sDAAkD;AAClD,gFAA2E;AAC3E,4EAAuE;AAEvE,8CAA0C;AAC1C,+DAA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AA4B,EAAC,gBAAgB,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,SAAU,IAAK,MAAO,IAAK,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC;YACtH,KAAK,EAAE,gBAAK,CAAC,MAAM;YACnB,UAAU,EAAE;gBACV;oBACE,IAAI,EAAE,IAAI;oBACV,IAAI,EAAE,IAAA,sBAAS,EAAC,IAAI,EAAE,UAAU,CAAC;iBAClC;aACF;SACF,CAAC,CAAC;QAEH,IAAA,uDAAyB,EAAC,gBAAgB,EAAE,GAAG,GAAG,IAAI,EAAE,EAAE,KAAK,EAAE,gBAAK,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC;YACpF,IAAI,EAAE,IAAA,sBAAS,EAAC,IAAI,EAAE,UAAU,CAAC;YACjC,WAAW,EAAE,WAAW;YACxB,gBAAgB,EAAE,CAAC,WAAW,IAAI,CAAC,UAAU;YAC7C,mBAAmB,EAAE,CAAC,WAAW,IAAI,UAAU;SAChD,CAAC,CAAC;KAEJ;SAAM;QAEL,YAAY,GAAG,IAAA,uDAAyB,EAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC;YACnE,KAAK,EAAE,gBAAK,CAAC,MAAM;YACnB,IAAI,EAAE,IAAA,sBAAS,EAAC,IAAI,EAAE,UAAU,CAAC;YACjC,WAAW;YACX,gBAAgB,EAAE,CAAC,WAAW,IAAI,CAAC,UAAU;YAC7C,mBAAmB,EAAE,CAAC,WAAW,IAAI,UAAU;SAChD,CAAC,CAAC;KAEJ;IAED,IAAA,kCAAe,EAAC,YAAY,EAAE,OAAO,EAAE,uBAAuB,CAAC,CAAC;IAEhE,OAAO,YAAY,CAAC;AAEtB,CAAC;AAxED,oDAwEC"}
@@ -1,6 +1,6 @@
1
1
  import { ClassDeclarationStructure, ObjectLiteralExpression, OptionalKind, SourceFile } from 'ts-morph';
2
2
  export interface CoerceComponentOptions {
3
- selector?: string;
3
+ selector?: string | false;
4
4
  prefix?: string;
5
5
  template?: string;
6
6
  styles?: string;
@@ -11,7 +11,18 @@ function CoerceComponent(sourceFile, name, options = {}, classStructure = {}) {
11
11
  const className = (0, utilities_1.classify)((0, utilities_1.CoerceSuffix)((0, utilities_1.dasherize)(name), '-component'));
12
12
  const { prefix, changeDetection, } = options;
13
13
  let { selector, template, templateUrl, styles, styleUrls, } = options;
14
- selector !== null && selector !== void 0 ? selector : (selector = prefix ? `${prefix}-${(0, utilities_1.dasherize)(name)}` : (0, utilities_1.dasherize)(name));
14
+ if (selector !== false) {
15
+ selector !== null && selector !== void 0 ? selector : (selector = prefix ? `${prefix}-${(0, utilities_1.dasherize)(name)}` : (0, utilities_1.dasherize)(name));
16
+ if (selector.includes('{{prefix}}')) {
17
+ if (!prefix) {
18
+ throw new Error(`The selector '${selector}' contains a template expression '{{prefix}}' but no prefix is provided`);
19
+ }
20
+ selector = selector.replace('{{prefix}}', prefix);
21
+ }
22
+ if (selector.match(/\{\{.*}}/)) {
23
+ throw new Error(`The selector '${selector}' contains an invalid templates expression`);
24
+ }
25
+ }
15
26
  if (templateUrl === true || !template) {
16
27
  template = undefined;
17
28
  templateUrl = `./${(0, utilities_1.dasherize)(name)}.component.html`;
@@ -36,8 +47,10 @@ function CoerceComponent(sourceFile, name, options = {}, classStructure = {}) {
36
47
  const classDeclaration = (0, coerce_class_1.CoerceClass)(sourceFile, className, classStructure);
37
48
  const componentOptions = {
38
49
  standalone: 'true',
39
- selector: w => w.quote(selector),
40
50
  };
51
+ if (selector) {
52
+ componentOptions['selector'] = w => w.quote(selector);
53
+ }
41
54
  if (changeDetection) {
42
55
  componentOptions['changeDetection'] = `ChangeDetectionStrategy.${changeDetection}`;
43
56
  (0, coerce_imports_1.CoerceImports)(sourceFile, {
@@ -1 +1 @@
1
- {"version":3,"file":"coerce-component.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component.ts"],"names":[],"mappings":";;;AAAA,+CAIyB;AACzB,uCAOkB;AAClB,kDAA8C;AAC9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kCAAe,EAAC,gBAAgB,EAAE,WAAW,EAAE;QACnF,SAAS,EAAE;YACT,kBAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC;SACjC;KACF,CAAC,CAAC;IAEH,MAAM,wBAAwB,GAAG,6BAA6B,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;IACjF,IAAI,CAAC,wBAAwB,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,4DAA6D,SAAU,GAAG,CAAC,CAAC;KAC7F;IACD,IAAI,CAAC,CAAC,wBAAwB,YAAY,kCAAuB,CAAC,EAAE;QAClE,MAAM,IAAI,KAAK,CAAC,6CAA8C,SAAU,uCAAuC,CAAC,CAAC;KAClH;IAED,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,CAAC;AACxD,CAAC;AAzFD,0CAyFC"}
1
+ {"version":3,"file":"coerce-component.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component.ts"],"names":[],"mappings":";;;AAAA,+CAIyB;AACzB,uCAOkB;AAClB,kDAA8C;AAC9C,0DAAsD;AACtD,sDAAkD;AAkBlD,SAAgB,eAAe,CAC7B,UAAsB,EACtB,IAAY,EACZ,UAAkC,EAAE,EACpC,iBAAwE,EAAE;;IAE1E,MAAM,SAAS,GAAG,IAAA,oBAAQ,EAAC,IAAA,wBAAY,EAAC,IAAA,qBAAS,EAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;IACxE,MAAM,EACJ,MAAM,EACN,eAAe,GAChB,GAAG,OAAO,CAAC;IACZ,IAAI,EACF,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,MAAM,EACN,SAAS,GACV,GAAG,OAAO,CAAC;IAEZ,IAAI,QAAQ,KAAK,KAAK,EAAE;QACtB,QAAQ,aAAR,QAAQ,cAAR,QAAQ,IAAR,QAAQ,GAAK,MAAM,CAAC,CAAC,CAAC,GAAI,MAAO,IAAK,IAAA,qBAAS,EAAC,IAAI,CAAE,EAAE,CA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ACF,CAAC,CAAC;IAEH,MAAM,wBAAwB,GAAG,6BAA6B,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;IACjF,IAAI,CAAC,wBAAwB,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,4DAA6D,SAAU,GAAG,CAAC,CAAC;KAC7F;IACD,IAAI,CAAC,CAAC,wBAAwB,YAAY,kCAAuB,CAAC,EAAE;QAClE,MAAM,IAAI,KAAK,CAAC,6CAA8C,SAAU,uCAAuC,CAAC,CAAC;KAClH;IAED,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,CAAC;AACxD,CAAC;AAxGD,0CAwGC"}
@@ -0,0 +1,4 @@
1
+ import { SourceFile } from 'ts-morph';
2
+ import { CoerceRoutesOptions } from './coerce-routes';
3
+ export type CoerceLayoutRoutesOptions = CoerceRoutesOptions;
4
+ export declare function CoerceLayoutRoutes(sourceFile: SourceFile, options?: CoerceLayoutRoutesOptions): import("ts-morph").VariableDeclaration;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoerceLayoutRoutes = void 0;
4
+ const ts_morph_1 = require("ts-morph");
5
+ const coerce_imports_1 = require("../coerce-imports");
6
+ const coerce_routes_1 = require("./coerce-routes");
7
+ function CoerceLayoutRoutes(sourceFile, options = {}) {
8
+ var _a;
9
+ const variableDeclaration = (0, coerce_routes_1.CoerceRoutes)(sourceFile, Object.assign(Object.assign({}, options), { initializer: (_a = options.initializer) !== null && _a !== void 0 ? _a : (w => {
10
+ w.writeLine('[');
11
+ w.indent(() => {
12
+ ts_morph_1.Writers.object({
13
+ path: w => w.quote(''),
14
+ component: 'LayoutComponent',
15
+ canActivateChild: '[StatusCheckGuard]',
16
+ children: w => {
17
+ w.writeLine('[');
18
+ w.indent(() => {
19
+ ts_morph_1.Writers.object({
20
+ path: w => w.quote('**'),
21
+ redirectTo: w => w.quote('')
22
+ })(w);
23
+ });
24
+ w.write(']');
25
+ },
26
+ providers: w => {
27
+ w.write('[');
28
+ w.indent(() => {
29
+ w.write('APP_NAVIGATION_PROVIDER');
30
+ w.write(',');
31
+ w.newLine();
32
+ w.write('NavigationService');
33
+ });
34
+ w.write(']');
35
+ }
36
+ })(w);
37
+ w.write(',');
38
+ });
39
+ ts_morph_1.Writers.object({
40
+ path: w => w.quote('**'),
41
+ redirectTo: w => w.quote('')
42
+ })(w);
43
+ w.newLine();
44
+ w.write(']');
45
+ }) }));
46
+ (0, coerce_imports_1.CoerceImports)(sourceFile, [
47
+ {
48
+ namedImports: ['LayoutComponent', 'NavigationService'],
49
+ moduleSpecifier: '@rxap/layout'
50
+ },
51
+ {
52
+ namedImports: ['StatusCheckGuard'],
53
+ moduleSpecifier: '@rxap/ngx-status-check'
54
+ },
55
+ {
56
+ namedImports: ['APP_NAVIGATION_PROVIDER'],
57
+ moduleSpecifier: './app.navigation'
58
+ }
59
+ ]);
60
+ return variableDeclaration;
61
+ }
62
+ exports.CoerceLayoutRoutes = CoerceLayoutRoutes;
63
+ //# sourceMappingURL=coerce-layout-routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-layout-routes.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-layout-routes.ts"],"names":[],"mappings":";;;AAAA,uCAGkB;AAClB,sDAAkD;AAClD,mDAGyB;AAIzB,SAAgB,kBAAkB,CAAC,UAAsB,EAAE,UAAqC,EAAE;;IAEhG,MAAM,mBAAmB,GAAG,IAAA,4BAAY,EAAC,UAAU,kCAC9C,OAAO,KACV,WAAW,EAAE,MAAA,OAAO,CAAC,WAAW,mCAAI,CAAC,CAAC,CAAC,EAAE;YACvC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACjB,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE;gBACZ,kBAAO,CAAC,MAAM,CAAC;oBACb,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CA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AC,CAAC;YACN,CAAC,CAAC,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACf,CAAC,CAAC,IACF,CAAC;IAEH,IAAA,8BAAa,EAAC,UAAU,EAAE;QACxB;YACE,YAAY,EAAE,CAAE,iBAAiB,EAAE,mBAAmB,CAAE;YACxD,eAAe,EAAE,cAAc;SAChC;QACD;YACE,YAAY,EAAE,CAAE,kBAAkB,CAAE;YACpC,eAAe,EAAE,wBAAwB;SAC1C;QACD;YACE,YAAY,EAAE,CAAE,yBAAyB,CAAE;YAC3C,eAAe,EAAE,kBAAkB;SACpC;KACF,CAAC,CAAC;IAEH,OAAO,mBAAmB,CAAC;AAE7B,CAAC;AA7DD,gDA6DC"}
@@ -0,0 +1,6 @@
1
+ import { SourceFile } from 'ts-morph';
2
+ export interface CoerceRouteGuardOptions {
3
+ routeArrayName?: string;
4
+ type?: 'canActivate' | 'canActivateChild';
5
+ }
6
+ export declare function CoerceRouteGuard(sourceFile: SourceFile, path: string[], guard: string, options?: CoerceRouteGuardOptions): void;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoerceRouteGuard = void 0;
4
+ const ts_morph_1 = require("@rxap/ts-morph");
5
+ const ts_morph_2 = require("ts-morph");
6
+ function CoerceRouteGuard(sourceFile, path, guard, options = {}) {
7
+ var _a;
8
+ const { routeArrayName = 'ROUTES', type = 'canActivate' } = options;
9
+ const routes = sourceFile.getVariableDeclaration(routeArrayName);
10
+ if (routes) {
11
+ const initializer = (0, ts_morph_1.FindParentRouteByPath)(routes.getInitializerIfKindOrThrow(ts_morph_2.SyntaxKind.ArrayLiteralExpression), path);
12
+ if (initializer) {
13
+ const guardArray = (_a = initializer.getProperty(type)) !== null && _a !== void 0 ? _a : initializer.addPropertyAssignment({
14
+ name: type,
15
+ initializer: '[]',
16
+ });
17
+ if (guardArray instanceof ts_morph_2.PropertyAssignment) {
18
+ const guardArrayInitializer = guardArray.getInitializerIfKindOrThrow(ts_morph_2.SyntaxKind.ArrayLiteralExpression);
19
+ (0, ts_morph_1.CoerceArrayElement)(guardArrayInitializer, guard);
20
+ }
21
+ else {
22
+ throw new Error('Guard array is not a PropertyAssignment');
23
+ }
24
+ }
25
+ else {
26
+ console.warn('Initializer not found');
27
+ }
28
+ }
29
+ else {
30
+ throw new Error(`${routeArrayName} variable not found`);
31
+ }
32
+ }
33
+ exports.CoerceRouteGuard = CoerceRouteGuard;
34
+ //# sourceMappingURL=coerce-route-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-route-guard.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-route-guard.ts"],"names":[],"mappings":";;;AAAA,6CAGwB;AACxB,uCAIkB;AAOlB,SAAgB,gBAAgB,CAAC,UAAsB,EAAE,IAAc,EAAE,KAAa,EAAE,UAAmC,EAAE;;IAC3H,MAAM,EAAE,cAAc,GAAG,QAAQ,EAAE,IAAI,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC;IACpE,MAAM,MAAM,GAAG,UAAU,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAC;IACjE,IAAI,MAAM,EAAE;QACV,MAAM,WAAW,GAAG,IAAA,gCAAqB,EAAC,MAAM,CAAC,2BAA2B,CAAC,qBAAU,CAAC,sBAAsB,CAAC,EAAE,IAAI,CAAC,CAAC;QACvH,IAAI,WAAW,EAAE;YACf,MAAM,UAAU,GAAG,MAAA,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,mCAAI,WAAW,CAAC,qBAAqB,CAAC;gBACpF,IAAI,EAAE,IAAI;gBACV,WAAW,EAAE,IAAI;aAClB,CAAC,CAAC;YACH,IAAI,UAAU,YAAY,6BAAkB,EAAE;gBAC5C,MAAM,qBAAqB,GAAG,UAAU,CAAC,2BAA2B,CAAC,qBAAU,CAAC,sBAAsB,CAAC,CAAC;gBACxG,IAAA,6BAAkB,EAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;aAClD;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;aAC5D;SACF;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;SACvC;KACF;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,GAAG,cAAc,qBAAqB,CAAC,CAAC;KACzD;AACH,CAAC;AAtBD,4CAsBC"}
@@ -0,0 +1,8 @@
1
+ import { SourceFile, WriterFunction } from 'ts-morph';
2
+ import { AddRouteOptions } from './add-route';
3
+ export interface CoerceRoutesOptions {
4
+ name?: string;
5
+ initializer?: string | WriterFunction;
6
+ itemList?: Array<Omit<AddRouteOptions, 'name'>>;
7
+ }
8
+ export declare function CoerceRoutes(sourceFile: SourceFile, options?: CoerceRoutesOptions): import("ts-morph").VariableDeclaration;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoerceRoutes = void 0;
4
+ const ts_morph_1 = require("ts-morph");
5
+ const coerce_default_export_1 = require("../coerce-default-export");
6
+ const coerce_imports_1 = require("../coerce-imports");
7
+ const coerce_variable_declaration_1 = require("../coerce-variable-declaration");
8
+ const add_route_1 = require("./add-route");
9
+ function CoerceRoutes(sourceFile, options = {}) {
10
+ var _a, _b;
11
+ const { name = 'ROUTES', initializer = `[{ path: '**', redirectTo: '' }]` } = options;
12
+ // region remove a route declaration if the initializer is an empty array to ensure the initializer is set
13
+ let variableDeclaration = (0, coerce_variable_declaration_1.CoerceVariableDeclaration)(sourceFile, name, { initializer: '[]', type: 'Route[]' });
14
+ if (variableDeclaration.getInitializerIfKindOrThrow(ts_morph_1.SyntaxKind.ArrayLiteralExpression).getElements().length === 0) {
15
+ variableDeclaration.getVariableStatementOrThrow().remove();
16
+ }
17
+ // endregion
18
+ variableDeclaration = (0, coerce_variable_declaration_1.CoerceVariableDeclaration)(sourceFile, name, {
19
+ initializer,
20
+ type: 'Route[]'
21
+ });
22
+ (0, coerce_default_export_1.CoerceDefaultExport)(variableDeclaration);
23
+ (0, coerce_imports_1.CoerceImports)(sourceFile, [
24
+ {
25
+ namedImports: ['Route'],
26
+ moduleSpecifier: '@angular/router'
27
+ },
28
+ ]);
29
+ if ((_a = options.itemList) === null || _a === void 0 ? void 0 : _a.some(item => item.route.loadRemoteModule)) {
30
+ (0, coerce_imports_1.CoerceImports)(sourceFile, [
31
+ {
32
+ namedImports: ['loadRemoteModule'],
33
+ moduleSpecifier: '@nx/angular/mf'
34
+ },
35
+ ]);
36
+ }
37
+ for (const item of (_b = options.itemList) !== null && _b !== void 0 ? _b : []) {
38
+ (0, add_route_1.AddRoute)(sourceFile, Object.assign(Object.assign({}, item), { name }));
39
+ }
40
+ return variableDeclaration;
41
+ }
42
+ exports.CoerceRoutes = CoerceRoutes;
43
+ //# sourceMappingURL=coerce-routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-routes.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-routes.ts"],"names":[],"mappings":";;;AAAA,uCAIkB;AAClB,oEAA+D;AAC/D,sDAAkD;AAClD,gFAA2E;AAC3E,2CAGqB;AAQrB,SAAgB,YAAY,CAAC,UAAsB,EAAE,UAA+B,EAAE;;IAEpF,MAAM,EACJ,IAAI,GAAG,QAAQ,EACf,WAAW,GAAG,kCAAkC,EACjD,GAAG,OAAO,CAAC;IAEZ,0GAA0G;IAC1G,IAAI,mBAAmB,GAAG,IAAA,uDAAyB,EAAC,UAAU,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC9G,IAAI,mBAAmB,CAAC,2BAA2B,CAAC,qBAAU,CAAC,sBAAsB,CAAC,CAAC,WAAW,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;QACjH,mBAAmB,CAAC,2BAA2B,EAAE,CAAC,MAAM,EAAE,CAAC;KAC5D;IACD,YAAY;IACZ,mBAAmB,GAAG,IAAA,uDAAyB,EAAC,UAAU,EAAE,IAAI,EAAE;QAChE,WAAW;QACX,IAAI,EAAE,SAAS;KAChB,CAAC,CAAC;IACH,IAAA,2CAAmB,EAAC,mBAAmB,CAAC,CAAC;IACzC,IAAA,8BAAa,EAAC,UAAU,EAAE;QACxB;YACE,YAAY,EAAE,CAAE,OAAO,CAAE;YACzB,eAAe,EAAE,iBAAiB;SACnC;KACF,CAAC,CAAC;IACH,IAAI,MAAA,OAAO,CAAC,QAAQ,0CAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE;QAC/D,IAAA,8BAAa,EAAC,UAAU,EAAE;YACxB;gBACE,YAAY,EAAE,CAAE,kBAAkB,CAAE;gBACpC,eAAe,EAAE,gBAAgB;aAClC;SACF,CAAC,CAAC;KACJ;IAED,KAAK,MAAM,IAAI,IAAI,MAAA,OAAO,CAAC,QAAQ,mCAAI,EAAE,EAAE;QACzC,IAAA,oBAAQ,EAAC,UAAU,kCAAO,IAAI,KAAE,IAAI,IAAG,CAAC;KACzC;IAED,OAAO,mBAAmB,CAAC;AAE7B,CAAC;AAvCD,oCAuCC"}
@@ -0,0 +1,6 @@
1
+ import { ArrayLiteralExpression, ObjectLiteralExpression } from 'ts-morph';
2
+ export declare function GetRouteChildrenArray(e: ObjectLiteralExpression): ArrayLiteralExpression;
3
+ export declare function FindParentRouteByPath(ale: ArrayLiteralExpression, path: string[]): ObjectLiteralExpression | null;
4
+ export declare function FindParentRouteByComponent(ale: ArrayLiteralExpression, component: string): ObjectLiteralExpression | null;
5
+ export declare function FindParentRouteChildrenArrayByPath(ale: ArrayLiteralExpression, path: string[]): ArrayLiteralExpression | null;
6
+ export declare function FindParentRouteChildrenArrayByComponent(ale: ArrayLiteralExpression, component: string): ArrayLiteralExpression | null;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindParentRouteChildrenArrayByComponent = exports.FindParentRouteChildrenArrayByPath = exports.FindParentRouteByComponent = exports.FindParentRouteByPath = exports.GetRouteChildrenArray = void 0;
4
+ const ts_morph_1 = require("ts-morph");
5
+ function GetRouteChildrenArray(e) {
6
+ var _a;
7
+ const childrenProperty = (_a = e.getProperty('children')) !== null && _a !== void 0 ? _a : e.addProperty({
8
+ name: 'children',
9
+ initializer: '[]',
10
+ kind: ts_morph_1.StructureKind.PropertyAssignment,
11
+ });
12
+ if (childrenProperty instanceof ts_morph_1.PropertyAssignment) {
13
+ return childrenProperty.getInitializerIfKindOrThrow(ts_morph_1.SyntaxKind.ArrayLiteralExpression);
14
+ }
15
+ throw new Error('Children property is not a PropertyAssignment');
16
+ }
17
+ exports.GetRouteChildrenArray = GetRouteChildrenArray;
18
+ function FindParentRouteByPath(ale, path) {
19
+ const fragment = path.pop();
20
+ for (const e of ale.getElements()) {
21
+ if (e.isKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression)) {
22
+ const pathProperty = e.getProperty('path');
23
+ if (pathProperty === null || pathProperty === void 0 ? void 0 : pathProperty.isKind(ts_morph_1.SyntaxKind.PropertyAssignment)) {
24
+ const initializer = pathProperty.getInitializerIfKind(ts_morph_1.SyntaxKind.StringLiteral);
25
+ if ((initializer === null || initializer === void 0 ? void 0 : initializer.getLiteralText()) === fragment) {
26
+ if (path.length) {
27
+ const children = GetRouteChildrenArray(e);
28
+ // console.log('Continue search for parent route');
29
+ return FindParentRouteByPath(children, path);
30
+ }
31
+ else {
32
+ // console.log('Found parent route');
33
+ return e;
34
+ }
35
+ }
36
+ else {
37
+ // console.log('Path property does not match', initializer.getLiteralText(), fragment);
38
+ }
39
+ }
40
+ else {
41
+ // console.log('Element has no path property');
42
+ }
43
+ }
44
+ else {
45
+ // console.log('Element is not an ObjectLiteralExpression');
46
+ }
47
+ }
48
+ return null;
49
+ }
50
+ exports.FindParentRouteByPath = FindParentRouteByPath;
51
+ function FindParentRouteByComponent(ale, component) {
52
+ for (const e of ale.getElements()) {
53
+ if (e.isKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression)) {
54
+ const componentProperty = e.getProperty('component');
55
+ if (componentProperty === null || componentProperty === void 0 ? void 0 : componentProperty.isKind(ts_morph_1.SyntaxKind.PropertyAssignment)) {
56
+ const initializer = componentProperty.getInitializer();
57
+ if ((initializer === null || initializer === void 0 ? void 0 : initializer.getText()) === component) {
58
+ return e;
59
+ }
60
+ }
61
+ }
62
+ }
63
+ return null;
64
+ }
65
+ exports.FindParentRouteByComponent = FindParentRouteByComponent;
66
+ function FindParentRouteChildrenArrayByPath(ale, path) {
67
+ const parent = FindParentRouteByPath(ale, path);
68
+ return parent ? GetRouteChildrenArray(parent) : null;
69
+ }
70
+ exports.FindParentRouteChildrenArrayByPath = FindParentRouteChildrenArrayByPath;
71
+ function FindParentRouteChildrenArrayByComponent(ale, component) {
72
+ const parent = FindParentRouteByComponent(ale, component);
73
+ return parent ? GetRouteChildrenArray(parent) : null;
74
+ }
75
+ exports.FindParentRouteChildrenArrayByComponent = FindParentRouteChildrenArrayByComponent;
76
+ //# sourceMappingURL=find-parent-route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-parent-route.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/find-parent-route.ts"],"names":[],"mappings":";;;AAAA,uCAMkB;AAElB,SAAgB,qBAAqB,CAAC,CAA0B;;IAC9D,MAAM,gBAAgB,GAAG,MAAA,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,mCAAI,CAAC,CAAC,WAAW,CAAC;QAClE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,IAAI;QACjB,IAAI,EAAE,wBAAa,CAAC,kBAAkB;KACvC,CAAC,CAAC;IACH,IAAI,gBAAgB,YAAY,6BAAkB,EAAE;QAClD,OAAO,gBAAgB,CAAC,2BAA2B,CAAC,qBAAU,CAAC,sBAAsB,CAAC,CAAC;KACxF;IACD,MAAM,IAAI,KA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