@rxap/schematics-ts-morph 16.0.1-dev.1 → 16.1.0-dev.1

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 (51) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +1 -1
  3. package/package.json +8 -8
  4. package/src/lib/angular/add-component-import.d.ts +9 -0
  5. package/src/lib/angular/add-component-import.js +9 -0
  6. package/src/lib/angular/add-component-import.js.map +1 -1
  7. package/src/lib/angular/add-component-input.d.ts +2 -1
  8. package/src/lib/angular/add-component-input.js +4 -3
  9. package/src/lib/angular/add-component-input.js.map +1 -1
  10. package/src/lib/angular/coerce-component-class.d.ts +2 -2
  11. package/src/lib/angular/coerce-component-class.js +2 -2
  12. package/src/lib/angular/coerce-component-class.js.map +1 -1
  13. package/src/lib/angular/coerce-component.js +4 -24
  14. package/src/lib/angular/coerce-component.js.map +1 -1
  15. package/src/lib/angular/coerce-form-definition-control.js +7 -3
  16. package/src/lib/angular/coerce-form-definition-control.js.map +1 -1
  17. package/src/lib/angular/coerce-form-definition.js +0 -8
  18. package/src/lib/angular/coerce-form-definition.js.map +1 -1
  19. package/src/lib/angular/coerce-tree-table-root-proxy-remote-method-class.js +1 -5
  20. package/src/lib/angular/coerce-tree-table-root-proxy-remote-method-class.js.map +1 -1
  21. package/src/lib/nest/add-operation-to-controller.d.ts +2 -1
  22. package/src/lib/nest/add-operation-to-controller.js +20 -19
  23. package/src/lib/nest/add-operation-to-controller.js.map +1 -1
  24. package/src/lib/nest/coerce-dto-class.d.ts +4 -1
  25. package/src/lib/nest/coerce-dto-class.js +34 -25
  26. package/src/lib/nest/coerce-dto-class.js.map +1 -1
  27. package/src/lib/nest/coerce-form-submit-operation.d.ts +1 -1
  28. package/src/lib/nest/coerce-form-submit-operation.js +1 -4
  29. package/src/lib/nest/coerce-form-submit-operation.js.map +1 -1
  30. package/src/lib/nest/coerce-get-by-id-operation.d.ts +2 -0
  31. package/src/lib/nest/coerce-get-by-id-operation.js +14 -15
  32. package/src/lib/nest/coerce-get-by-id-operation.js.map +1 -1
  33. package/src/lib/nest/coerce-get-children-operation.d.ts +2 -2
  34. package/src/lib/nest/coerce-get-children-operation.js +17 -20
  35. package/src/lib/nest/coerce-get-children-operation.js.map +1 -1
  36. package/src/lib/nest/coerce-get-page-operation.d.ts +1 -1
  37. package/src/lib/nest/coerce-get-root-operation.d.ts +4 -1
  38. package/src/lib/nest/coerce-get-root-operation.js +17 -19
  39. package/src/lib/nest/coerce-get-root-operation.js.map +1 -1
  40. package/src/lib/nest/coerce-options-operation.js +2 -2
  41. package/src/lib/nest/coerce-options-operation.js.map +1 -1
  42. package/src/lib/nest/create-dto-class.d.ts +10 -5
  43. package/src/lib/nest/create-dto-class.js +11 -40
  44. package/src/lib/nest/create-dto-class.js.map +1 -1
  45. package/src/lib/ts-morph/coerce-interface.d.ts +2 -0
  46. package/src/lib/ts-morph/coerce-interface.js +6 -4
  47. package/src/lib/ts-morph/coerce-interface.js.map +1 -1
  48. package/src/lib/ts-morph/write-type.d.ts +16 -4
  49. package/src/lib/ts-morph/write-type.js +56 -19
  50. package/src/lib/ts-morph/write-type.js.map +1 -1
  51. package/src/lib/types/form-definition-control.d.ts +2 -1
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CoerceInterfaceRule = exports.CoerceInterface = void 0;
4
+ const ts_morph_1 = require("@rxap/ts-morph");
4
5
  const utilities_1 = require("@rxap/utilities");
5
6
  function CoerceInterface(sourceFile, interfaceName, structure = {}) {
6
7
  let interfaceDeclaration = sourceFile.getInterface(interfaceName);
@@ -11,17 +12,18 @@ function CoerceInterface(sourceFile, interfaceName, structure = {}) {
11
12
  }
12
13
  exports.CoerceInterface = CoerceInterface;
13
14
  function CoerceInterfaceRule(options, tsMorphTransForm) {
14
- let { tsMorphTransform, project, feature, shared, directory, name, structure, } = options;
15
+ const { tsMorphTransform = utilities_1.noop, project, feature, shared, directory, structure = { isExported: true }, propertyList, } = options;
16
+ let { name } = options;
15
17
  name = (0, utilities_1.classify)(name);
16
- structure !== null && structure !== void 0 ? structure : (structure = {});
17
- // eslint-disable-next-line @typescript-eslint/no-empty-function
18
- tsMorphTransform !== null && tsMorphTransform !== void 0 ? tsMorphTransform : (tsMorphTransform = () => { });
19
18
  return tsMorphTransForm({
20
19
  project,
21
20
  feature,
22
21
  shared,
23
22
  directory,
24
23
  }, (project, [sourceFile]) => {
24
+ if (propertyList) {
25
+ structure.properties = propertyList.map(p => (0, ts_morph_1.NormalizeDataPropertyToPropertySignatureStructure)(p, sourceFile));
26
+ }
25
27
  const interfaceDeclaration = CoerceInterface(sourceFile, name, structure);
26
28
  tsMorphTransform(project, sourceFile, interfaceDeclaration);
27
29
  }, [(0, utilities_1.dasherize)(name) + '.ts?']);
@@ -1 +1 @@
1
- {"version":3,"file":"coerce-interface.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/ts-morph/coerce-interface.ts"],"names":[],"mappings":";;;AAAA,+CAGyB;AAczB,SAAgB,eAAe,CAC7B,UAAsB,EACtB,aAAqB,EACrB,YAAuE,EAAE;IAEzE,IAAI,oBAAoB,GAAG,UAAU,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IAClE,IAAI,CAAC,oBAAoB,EAAE;QACzB,oBAAoB,GAAG,UAAU,CAAC,YAAY,iCACzC,SAAS,KACZ,IAAI,EAAE,aAAa,IACnB,CAAC;KACJ;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAbD,0CAaC;AASD,SAAgB,mBAAmB,CACjC,OAAmC,EACnC,gBAA0H;IAE1H,IAAI,EACF,gBAAgB,EAChB,OAAO,EACP,OAAO,EACP,MAAM,EACN,SAAS,EACT,IAAI,EACJ,SAAS,GACV,GAAG,OAAO,CAAC;IACZ,IAAI,GAAG,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAC;IACtB,SAAS,aAAT,SAAS,cAAT,SAAS,IAAT,SAAS,GAAK,EAAE,EAAC;IACjB,gEAAgE;IAChE,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,IAAhB,gBAAgB,GAAK,GAAG,EAAE,GAAE,CAAC,EAAC;IAE9B,OAAO,gBAAgB,CAAC;QACtB,OAAO;QACP,OAAO;QACP,MAAM;QACN,SAAS;KACV,EAAE,CAAC,OAAO,EAAE,CAAE,UAAU,CAAE,EAAE,EAAE;QAC7B,MAAM,oBAAoB,GAAG,eAAe,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;QAC1E,gBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,oBAAoB,CAAC,CAAC;IAC/D,CAAC,EAAE,CAAE,IAAA,qBAAS,EAAC,IAAI,CAAC,GAAG,MAAM,CAAE,CAAC,CAAC;AACnC,CAAC;AA3BD,kDA2BC"}
1
+ {"version":3,"file":"coerce-interface.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/ts-morph/coerce-interface.ts"],"names":[],"mappings":";;;AAAA,6CAGwB;AACxB,+CAIyB;AAczB,SAAgB,eAAe,CAC7B,UAAsB,EACtB,aAAqB,EACrB,YAAuE,EAAE;IAEzE,IAAI,oBAAoB,GAAG,UAAU,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IAClE,IAAI,CAAC,oBAAoB,EAAE;QACzB,oBAAoB,GAAG,UAAU,CAAC,YAAY,iCACzC,SAAS,KACZ,IAAI,EAAE,aAAa,IACnB,CAAC;KACJ;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAbD,0CAaC;AAUD,SAAgB,mBAAmB,CACjC,OAAmC,EACnC,gBAA0H;IAE1H,MAAM,EACJ,gBAAgB,GAAG,gBAAI,EACvB,OAAO,EACP,OAAO,EACP,MAAM,EACN,SAAS,EACT,SAAS,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,EAChC,YAAY,GACb,GAAG,OAAO,CAAC;IACZ,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACvB,IAAI,GAAG,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAC;IAEtB,OAAO,gBAAgB,CAAC;QACtB,OAAO;QACP,OAAO;QACP,MAAM;QACN,SAAS;KACV,EAAE,CAAC,OAAO,EAAE,CAAE,UAAU,CAAE,EAAE,EAAE;QAC7B,IAAI,YAAY,EAAE;YAChB,SAAS,CAAC,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,4DAAiD,EAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;SAChH;QACD,MAAM,oBAAoB,GAAG,eAAe,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;QAC1E,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,oBAAoB,CAAC,CAAC;IAC9D,CAAC,EAAE,CAAE,IAAA,qBAAS,EAAC,IAAI,CAAC,GAAG,MAAM,CAAE,CAAC,CAAC;AACnC,CAAC;AA5BD,kDA4BC"}
@@ -1,6 +1,18 @@
1
- import { CodeBlockWriter, WriterFunction } from 'ts-morph';
1
+ import { TypeImport } from '@rxap/ts-morph';
2
+ import { CodeBlockWriter, SourceFile, WriterFunction } from 'ts-morph';
3
+ export type WriteType = string | TypeImport | WriterFunction;
2
4
  export interface WriteTypeOptions {
3
- isArray?: boolean;
4
- type: string | WriterFunction;
5
+ isArray?: boolean | null;
6
+ type: WriteType;
5
7
  }
6
- export declare function WriteType(property: WriteTypeOptions): (w: CodeBlockWriter) => void;
8
+ export declare function IsWriteTypeOptions(value: any): value is WriteTypeOptions;
9
+ /**
10
+ * Uses the CodeBlockWriter to write the type to the AST thereby the value of the property type is evaluated
11
+ * to determine the value that should be written to the AST
12
+ * @param type
13
+ * @param w
14
+ * @constructor
15
+ */
16
+ export declare function WriteStringType(type: string, w: CodeBlockWriter): void;
17
+ export declare function WriteType(type: WriteType, sourceFile: SourceFile): WriterFunction;
18
+ export declare function WriteType(property: WriteTypeOptions, sourceFile: SourceFile): WriterFunction;
@@ -1,31 +1,68 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WriteType = void 0;
4
- function WriteType(property) {
3
+ exports.WriteType = exports.WriteStringType = exports.IsWriteTypeOptions = void 0;
4
+ const ts_morph_1 = require("@rxap/ts-morph");
5
+ function IsWriteTypeOptions(value) {
6
+ return value && typeof value === 'object' && value.type;
7
+ }
8
+ exports.IsWriteTypeOptions = IsWriteTypeOptions;
9
+ /**
10
+ * Uses the CodeBlockWriter to write the type to the AST thereby the value of the property type is evaluated
11
+ * to determine the value that should be written to the AST
12
+ * @param type
13
+ * @param w
14
+ * @constructor
15
+ */
16
+ function WriteStringType(type, w) {
17
+ switch (type) {
18
+ case 'date':
19
+ w.write('Date');
20
+ break;
21
+ case 'uuid':
22
+ w.write('string');
23
+ break;
24
+ default:
25
+ w.write(type);
26
+ break;
27
+ }
28
+ }
29
+ exports.WriteStringType = WriteStringType;
30
+ function WriteType(propertyOrType, sourceFile) {
31
+ var _a;
32
+ let isArray = false;
33
+ let type;
34
+ if (IsWriteTypeOptions(propertyOrType)) {
35
+ isArray = (_a = propertyOrType.isArray) !== null && _a !== void 0 ? _a : isArray;
36
+ type = propertyOrType.type;
37
+ }
38
+ else {
39
+ type = propertyOrType;
40
+ }
41
+ if ((0, ts_morph_1.IsTypeImport)(type)) {
42
+ if (sourceFile) {
43
+ (0, ts_morph_1.CoerceImports)(sourceFile, (0, ts_morph_1.TypeImportToImportStructure)(type));
44
+ }
45
+ else {
46
+ console.warn('WriteType :: No source file provided to coerce imports');
47
+ }
48
+ }
5
49
  return (w) => {
6
- if (property.isArray) {
50
+ if (isArray) {
7
51
  w.write('Array<');
8
52
  }
9
- if (typeof property.type === 'string') {
10
- switch (property.type) {
11
- case 'date':
12
- w.write('Date');
13
- break;
14
- case 'uuid':
15
- w.write('string');
16
- break;
17
- default:
18
- w.write(property.type);
19
- break;
20
- }
21
- }
22
- else if (typeof property.type === 'function') {
23
- property.type(w);
53
+ if (typeof type === 'string') {
54
+ WriteStringType(type, w);
55
+ }
56
+ else if (typeof type === 'function') {
57
+ type(w);
58
+ }
59
+ else if ((0, ts_morph_1.IsTypeImport)(type)) {
60
+ WriteStringType(type.name, w);
24
61
  }
25
62
  else {
26
63
  throw new Error('Invalid type');
27
64
  }
28
- if (property.isArray) {
65
+ if (isArray) {
29
66
  w.write('>');
30
67
  }
31
68
  };
@@ -1 +1 @@
1
- {"version":3,"file":"write-type.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/ts-morph/src/lib/ts-morph/write-type.ts"],"names":[],"mappings":";;;AAUA,SAAgB,SAAS,CAAC,QAA0B;IAClD,OAAO,CAAC,CAAkB,EAAE,EAAE;QAC5B,IAAI,QAAQ,CAAC,OAAO,EAAE;YACpB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SACnB;QACD,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE;YACrC,QAAQ,QAAQ,CAAC,IAAI,EAAE;gBACrB,KAAK,MAAM;oBACT,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBAChB,MAAM;gBACR,KAAK,MAAM;oBACT,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;oBAClB,MAAM;gBACR;oBACE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;oBACvB,MAAM;aACT;SACF;aAAM,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE;YAC9C,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAClB;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;SACjC;QACD,IAAI,QAAQ,CAAC,OAAO,EAAE;YACpB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACd;IACH,CAAC,CAAC;AACJ,CAAC;AA1BD,8BA0BC"}
1
+ {"version":3,"file":"write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AO,IAAI,KAAK,QAAQ,EAAE;YAC5B,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;SAC1B;aAAM,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;YACrC,IAAI,CAAC,CAAC,CAAC,CAAC;SACT;aAAM,IAAI,IAAA,uBAAY,EAAC,IAAI,CAAC,EAAE;YAC7B,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;SAC/B;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;SACjC;QACD,IAAI,OAAO,EAAE;YACX,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACd;IACH,CAAC,CAAC;AACJ,CAAC;AAjCD,8BAiCC"}
@@ -1,7 +1,8 @@
1
+ import { TypeImport } from '@rxap/ts-morph';
1
2
  import { WriterFunction } from 'ts-morph';
2
3
  export interface FormDefinitionControl {
3
4
  name: string;
4
- type?: string | WriterFunction;
5
+ type?: string | TypeImport | WriterFunction;
5
6
  isArray?: boolean;
6
7
  state?: string | WriterFunction | null;
7
8
  isRequired?: boolean;