@rxap/schematics-ts-morph 16.0.0-dev.34 → 16.0.0-dev.35
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.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [16.0.0-dev.35](https://gitlab.com/rxap/packages/compare/@rxap/schematics-ts-morph@16.0.0-dev.34...@rxap/schematics-ts-morph@16.0.0-dev.35) (2023-11-18)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- support relativeTo parameter ([0f1e690](https://gitlab.com/rxap/packages/commit/0f1e690f74802761efee09fa73ffb8036b3cefcd))
|
|
11
|
+
|
|
6
12
|
# [16.0.0-dev.34](https://gitlab.com/rxap/packages/compare/@rxap/schematics-ts-morph@16.0.0-dev.33...@rxap/schematics-ts-morph@16.0.0-dev.34) (2023-11-17)
|
|
7
13
|
|
|
8
14
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -17,5 +17,5 @@ yarn add @rxap/schematics-ts-morph
|
|
|
17
17
|
```
|
|
18
18
|
**Install peer dependencies:**
|
|
19
19
|
```bash
|
|
20
|
-
yarn add @angular-devkit/core@^16.1.4 @angular-devkit/schematics@^16.1.4 @rxap/schematics-utilities@^16.0.0-dev.21 @rxap/ts-morph@^0.1.0-dev.
|
|
20
|
+
yarn add @angular-devkit/core@^16.1.4 @angular-devkit/schematics@^16.1.4 @rxap/schematics-utilities@^16.0.0-dev.21 @rxap/ts-morph@^0.1.0-dev.19 @rxap/utilities@^16.0.0-dev.23 @rxap/workspace-ts-morph@^0.1.0-dev.12 ts-morph@^18.0.0 tslib@2.6.2
|
|
21
21
|
```
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "16.0.0-dev.
|
|
2
|
+
"version": "16.0.0-dev.35",
|
|
3
3
|
"name": "@rxap/schematics-ts-morph",
|
|
4
4
|
"license": "GPL-3.0-or-later",
|
|
5
5
|
"dependencies": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@angular-devkit/core": "^16.1.4",
|
|
14
14
|
"@angular-devkit/schematics": "^16.1.4",
|
|
15
15
|
"@rxap/schematics-utilities": "^16.0.0-dev.21",
|
|
16
|
-
"@rxap/ts-morph": "^0.1.0-dev.
|
|
16
|
+
"@rxap/ts-morph": "^0.1.0-dev.19",
|
|
17
17
|
"@rxap/utilities": "^16.0.0-dev.23",
|
|
18
18
|
"@rxap/workspace-ts-morph": "^0.1.0-dev.12",
|
|
19
19
|
"ts-morph": "^18.0.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
"package": "@rxap/ts-morph",
|
|
48
|
-
"version": "0.1.0-dev.
|
|
48
|
+
"version": "0.1.0-dev.19"
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"package": "@rxap/utilities",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"directory": "packages/schematic/ts-morph"
|
|
68
68
|
},
|
|
69
69
|
"type": "commonjs",
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "eae9d8105fc9ecfdf80101d147d1947b99d68fb8",
|
|
71
71
|
"main": "./src/index.js",
|
|
72
72
|
"types": "./src/index.d.ts"
|
|
73
73
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CoerceTableActionOptions } from './coerce-table-action';
|
|
2
2
|
export interface CoerceLinkTableActionRuleOptions extends CoerceTableActionOptions {
|
|
3
3
|
route?: string | null;
|
|
4
|
+
relativeTo?: boolean;
|
|
4
5
|
}
|
|
5
6
|
export declare function CoerceNavigationTableActionRule(options: CoerceLinkTableActionRuleOptions): import("@angular-devkit/schematics").Rule;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CoerceNavigationTableActionRule = void 0;
|
|
4
|
-
const coerce_table_action_1 = require("./coerce-table-action");
|
|
5
|
-
const coerce_class_constructor_1 = require("../coerce-class-constructor");
|
|
6
4
|
const ts_morph_1 = require("ts-morph");
|
|
7
|
-
const
|
|
5
|
+
const coerce_class_constructor_1 = require("../coerce-class-constructor");
|
|
8
6
|
const coerce_imports_1 = require("../ts-morph/coerce-imports");
|
|
7
|
+
const coerce_parameter_declaration_1 = require("../ts-morph/coerce-parameter-declaration");
|
|
8
|
+
const coerce_table_action_1 = require("./coerce-table-action");
|
|
9
9
|
function extractAllProperties(route) {
|
|
10
10
|
const match = route.match(/\{\{([^}]+)}}/g);
|
|
11
11
|
if (!match) {
|
|
@@ -24,12 +24,12 @@ function buildDynamicRoute(route) {
|
|
|
24
24
|
return route;
|
|
25
25
|
}
|
|
26
26
|
function CoerceNavigationTableActionRule(options) {
|
|
27
|
-
let { tsMorphTransform, tableName, type, route, } = options;
|
|
27
|
+
let { tsMorphTransform, tableName, type, route, relativeTo, } = options;
|
|
28
28
|
tsMorphTransform !== null && tsMorphTransform !== void 0 ? tsMorphTransform : (tsMorphTransform = () => ({}));
|
|
29
29
|
route !== null && route !== void 0 ? route : (route = '{{uuid}}');
|
|
30
30
|
return (0, coerce_table_action_1.CoerceTableActionRule)(Object.assign(Object.assign({}, options), { tsMorphTransform: (project, sourceFile, classDeclaration) => {
|
|
31
31
|
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
32
|
-
namedImports: ['Router'
|
|
32
|
+
namedImports: ['Router'],
|
|
33
33
|
moduleSpecifier: '@angular/router',
|
|
34
34
|
});
|
|
35
35
|
const [constructorDeclaration] = (0, coerce_class_constructor_1.CoerceClassConstructor)(classDeclaration);
|
|
@@ -39,23 +39,33 @@ function CoerceNavigationTableActionRule(options) {
|
|
|
39
39
|
isReadonly: true,
|
|
40
40
|
scope: ts_morph_1.Scope.Private,
|
|
41
41
|
});
|
|
42
|
-
(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
if (relativeTo) {
|
|
43
|
+
(0, coerce_parameter_declaration_1.CoerceParameterDeclaration)(constructorDeclaration, 'route').set({
|
|
44
|
+
type: 'ActivatedRoute',
|
|
45
|
+
isReadonly: true,
|
|
46
|
+
scope: ts_morph_1.Scope.Private,
|
|
47
|
+
});
|
|
48
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
49
|
+
namedImports: ['ActivatedRoute'],
|
|
50
|
+
moduleSpecifier: '@angular/router',
|
|
51
|
+
});
|
|
52
|
+
}
|
|
47
53
|
const properties = extractAllProperties(route);
|
|
48
54
|
const statements = [];
|
|
49
55
|
statements.push(`console.log(\`action row type: ${type}\`, parameters);`);
|
|
56
|
+
let routeValue = route;
|
|
50
57
|
if (properties.length) {
|
|
51
58
|
statements.push(`const { ${properties.join(', ')} } = parameters;`);
|
|
52
59
|
for (const property of properties) {
|
|
53
60
|
statements.push(`if (!${property}) { throw new Error('The table action ${type} is called with a row object that does not have the property ${property}.'); }`);
|
|
54
61
|
}
|
|
55
|
-
|
|
62
|
+
routeValue = buildDynamicRoute(route);
|
|
63
|
+
}
|
|
64
|
+
if (relativeTo) {
|
|
65
|
+
statements.push(`return this.router.navigate([ '${routeValue}' ], { relativeTo: this.route } );`);
|
|
56
66
|
}
|
|
57
67
|
else {
|
|
58
|
-
statements.push(`return this.router.navigate([ '${
|
|
68
|
+
statements.push(`return this.router.navigate([ '${routeValue}' ]);`);
|
|
59
69
|
}
|
|
60
70
|
return Object.assign({ statements, scope: ts_morph_1.Scope.Public, returnType: 'Promise<any>' }, tsMorphTransform(project, sourceFile, classDeclaration));
|
|
61
71
|
} }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-navigation-table-action.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/angular/coerce-navigation-table-action.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"coerce-navigation-table-action.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/angular/coerce-navigation-table-action.ts"],"names":[],"mappings":";;;AAAA,uCAIkB;AAClB,0EAAqE;AACrE,+DAA2D;AAC3D,2FAAsF;AACtF,+DAG+B;AAO/B,SAAS,oBAAoB,CAAC,KAAa;IACzC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC5C,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,CAAC;KACX;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAa;IACtC,MAAM,UAAU,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;QACtB,OAAO,KAAK,CAAC;KACd;IACD,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;QACjC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAM,QAAS,IAAI,EAAE,MAAO,QAAS,GAAG,CAAC,CAAC;KACjE;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,+BAA+B,CAAC,OAAyC;IACvF,IAAI,EACF,gBAAgB,EAChB,SAAS,EACT,IAAI,EACJ,KAAK,EACL,UAAU,GACX,GAAG,OAAO,CAAC;IACZ,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,IAAhB,gBAAgB,GAAK,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAC;IAChC,KAAK,aAAL,KAAK,cAAL,KAAK,IAAL,KAAK,GA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