@strapi/typescript-utils 5.50.0 → 5.50.2

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 (171) hide show
  1. package/dist/compile.d.ts +5 -0
  2. package/dist/compile.d.ts.map +1 -0
  3. package/dist/compile.js +12 -0
  4. package/dist/compile.js.map +1 -0
  5. package/dist/compile.mjs +10 -0
  6. package/dist/compile.mjs.map +1 -0
  7. package/dist/compilers/basic.d.ts +11 -0
  8. package/dist/compilers/basic.d.ts.map +1 -0
  9. package/dist/compilers/basic.js +58 -0
  10. package/dist/compilers/basic.js.map +1 -0
  11. package/dist/compilers/basic.mjs +36 -0
  12. package/dist/compilers/basic.mjs.map +1 -0
  13. package/dist/compilers/index.d.ts +3 -0
  14. package/dist/compilers/index.d.ts.map +1 -0
  15. package/dist/compilers/index.js +8 -0
  16. package/dist/compilers/index.js.map +1 -0
  17. package/dist/compilers/index.mjs +3 -0
  18. package/dist/compilers/index.mjs.map +1 -0
  19. package/dist/generators/common/imports.d.ts +5 -0
  20. package/dist/generators/common/imports.d.ts.map +1 -0
  21. package/dist/generators/common/imports.js +42 -0
  22. package/dist/generators/common/imports.js.map +1 -0
  23. package/dist/generators/common/imports.mjs +19 -0
  24. package/dist/generators/common/imports.mjs.map +1 -0
  25. package/dist/generators/common/index.d.ts +4 -0
  26. package/dist/generators/common/index.d.ts.map +1 -0
  27. package/dist/generators/common/models/attributes.d.ts +17 -0
  28. package/dist/generators/common/models/attributes.d.ts.map +1 -0
  29. package/dist/generators/common/models/attributes.js +152 -0
  30. package/dist/generators/common/models/attributes.js.map +1 -0
  31. package/dist/generators/common/models/attributes.mjs +124 -0
  32. package/dist/generators/common/models/attributes.mjs.map +1 -0
  33. package/dist/generators/common/models/index.d.ts +7 -0
  34. package/dist/generators/common/models/index.d.ts.map +1 -0
  35. package/dist/generators/common/models/mappers.d.ts +9 -0
  36. package/dist/generators/common/models/mappers.d.ts.map +1 -0
  37. package/dist/generators/common/models/mappers.js +227 -0
  38. package/dist/generators/common/models/mappers.js.map +1 -0
  39. package/dist/generators/common/models/mappers.mjs +202 -0
  40. package/dist/generators/common/models/mappers.mjs.map +1 -0
  41. package/dist/generators/common/models/schema.d.ts +7 -0
  42. package/dist/generators/common/models/schema.d.ts.map +1 -0
  43. package/dist/generators/common/models/schema.js +79 -0
  44. package/dist/generators/common/models/schema.js.map +1 -0
  45. package/dist/generators/common/models/schema.mjs +57 -0
  46. package/dist/generators/common/models/schema.mjs.map +1 -0
  47. package/dist/generators/common/models/utils.d.ts +54 -0
  48. package/dist/generators/common/models/utils.d.ts.map +1 -0
  49. package/dist/generators/common/models/utils.js +109 -0
  50. package/dist/generators/common/models/utils.js.map +1 -0
  51. package/dist/generators/common/models/utils.mjs +81 -0
  52. package/dist/generators/common/models/utils.mjs.map +1 -0
  53. package/dist/generators/components/index.d.ts +9 -0
  54. package/dist/generators/components/index.d.ts.map +1 -0
  55. package/dist/generators/components/index.js +76 -0
  56. package/dist/generators/components/index.js.map +1 -0
  57. package/dist/generators/components/index.mjs +54 -0
  58. package/dist/generators/components/index.mjs.map +1 -0
  59. package/dist/generators/constants.d.ts +3 -0
  60. package/dist/generators/constants.d.ts.map +1 -0
  61. package/dist/generators/constants.js +8 -0
  62. package/dist/generators/constants.js.map +1 -0
  63. package/dist/generators/constants.mjs +5 -0
  64. package/dist/generators/constants.mjs.map +1 -0
  65. package/dist/generators/content-types/index.d.ts +9 -0
  66. package/dist/generators/content-types/index.d.ts.map +1 -0
  67. package/dist/generators/content-types/index.js +76 -0
  68. package/dist/generators/content-types/index.js.map +1 -0
  69. package/dist/generators/content-types/index.mjs +54 -0
  70. package/dist/generators/content-types/index.mjs.map +1 -0
  71. package/dist/generators/index.d.ts +23 -0
  72. package/dist/generators/index.d.ts.map +1 -0
  73. package/dist/generators/index.js +81 -0
  74. package/dist/generators/index.js.map +1 -0
  75. package/dist/generators/index.mjs +74 -0
  76. package/dist/generators/index.mjs.map +1 -0
  77. package/dist/generators/utils.d.ts +52 -0
  78. package/dist/generators/utils.d.ts.map +1 -0
  79. package/dist/generators/utils.js +164 -0
  80. package/dist/generators/utils.js.map +1 -0
  81. package/dist/generators/utils.mjs +131 -0
  82. package/dist/generators/utils.mjs.map +1 -0
  83. package/dist/index.d.ts +5 -0
  84. package/dist/index.d.ts.map +1 -0
  85. package/dist/index.js +28 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/index.mjs +14 -0
  88. package/dist/index.mjs.map +1 -0
  89. package/dist/utils/format-host.d.ts +3 -0
  90. package/dist/utils/format-host.d.ts.map +1 -0
  91. package/dist/utils/format-host.js +33 -0
  92. package/dist/utils/format-host.js.map +1 -0
  93. package/dist/utils/format-host.mjs +11 -0
  94. package/dist/utils/format-host.mjs.map +1 -0
  95. package/dist/utils/get-config-path.d.ts +10 -0
  96. package/dist/utils/get-config-path.d.ts.map +1 -0
  97. package/dist/utils/get-config-path.js +43 -0
  98. package/dist/utils/get-config-path.js.map +1 -0
  99. package/dist/utils/get-config-path.mjs +18 -0
  100. package/dist/utils/get-config-path.mjs.map +1 -0
  101. package/dist/utils/index.d.ts +9 -0
  102. package/dist/utils/index.d.ts.map +1 -0
  103. package/dist/utils/is-using-typescript-sync.d.ts +5 -0
  104. package/dist/utils/is-using-typescript-sync.d.ts.map +1 -0
  105. package/dist/utils/is-using-typescript-sync.js +20 -0
  106. package/dist/utils/is-using-typescript-sync.js.map +1 -0
  107. package/dist/utils/is-using-typescript-sync.mjs +14 -0
  108. package/dist/utils/is-using-typescript-sync.mjs.map +1 -0
  109. package/dist/utils/is-using-typescript.d.ts +5 -0
  110. package/dist/utils/is-using-typescript.d.ts.map +1 -0
  111. package/dist/utils/is-using-typescript.js +20 -0
  112. package/dist/utils/is-using-typescript.js.map +1 -0
  113. package/dist/utils/is-using-typescript.mjs +14 -0
  114. package/dist/utils/is-using-typescript.mjs.map +1 -0
  115. package/dist/utils/report-diagnostics.d.ts +6 -0
  116. package/dist/utils/report-diagnostics.d.ts.map +1 -0
  117. package/dist/utils/report-diagnostics.js +37 -0
  118. package/dist/utils/report-diagnostics.js.map +1 -0
  119. package/dist/utils/report-diagnostics.mjs +15 -0
  120. package/dist/utils/report-diagnostics.mjs.map +1 -0
  121. package/dist/utils/resolve-config-options.d.ts +12 -0
  122. package/dist/utils/resolve-config-options.d.ts.map +1 -0
  123. package/dist/utils/resolve-config-options.js +39 -0
  124. package/dist/utils/resolve-config-options.js.map +1 -0
  125. package/dist/utils/resolve-config-options.mjs +17 -0
  126. package/dist/utils/resolve-config-options.mjs.map +1 -0
  127. package/dist/utils/resolve-outdir-sync.d.ts +5 -0
  128. package/dist/utils/resolve-outdir-sync.d.ts.map +1 -0
  129. package/dist/utils/resolve-outdir-sync.js +19 -0
  130. package/dist/utils/resolve-outdir-sync.js.map +1 -0
  131. package/dist/utils/resolve-outdir-sync.mjs +13 -0
  132. package/dist/utils/resolve-outdir-sync.mjs.map +1 -0
  133. package/dist/utils/resolve-outdir.d.ts +5 -0
  134. package/dist/utils/resolve-outdir.d.ts.map +1 -0
  135. package/dist/utils/resolve-outdir.js +19 -0
  136. package/dist/utils/resolve-outdir.js.map +1 -0
  137. package/dist/utils/resolve-outdir.mjs +13 -0
  138. package/dist/utils/resolve-outdir.mjs.map +1 -0
  139. package/package.json +25 -10
  140. package/.eslintrc.cjs +0 -16
  141. package/index.d.ts +0 -5
  142. package/jest.config.js +0 -6
  143. package/lib/__tests__/generators/schemas/attributes.test.js +0 -903
  144. package/lib/__tests__/generators/schemas/imports.test.js +0 -56
  145. package/lib/__tests__/generators/schemas/utils.test.js +0 -314
  146. package/lib/compile.js +0 -10
  147. package/lib/compilers/basic.js +0 -50
  148. package/lib/compilers/index.js +0 -7
  149. package/lib/generators/common/imports.js +0 -34
  150. package/lib/generators/common/index.js +0 -9
  151. package/lib/generators/common/models/attributes.js +0 -198
  152. package/lib/generators/common/models/index.js +0 -15
  153. package/lib/generators/common/models/mappers.js +0 -144
  154. package/lib/generators/common/models/schema.js +0 -93
  155. package/lib/generators/common/models/utils.js +0 -178
  156. package/lib/generators/components/index.js +0 -74
  157. package/lib/generators/constants.js +0 -6
  158. package/lib/generators/content-types/index.js +0 -74
  159. package/lib/generators/index.js +0 -122
  160. package/lib/generators/utils.js +0 -216
  161. package/lib/index.js +0 -13
  162. package/lib/utils/format-host.js +0 -15
  163. package/lib/utils/get-config-path.js +0 -29
  164. package/lib/utils/index.js +0 -21
  165. package/lib/utils/is-using-typescript-sync.js +0 -19
  166. package/lib/utils/is-using-typescript.js +0 -17
  167. package/lib/utils/report-diagnostics.js +0 -19
  168. package/lib/utils/resolve-config-options.js +0 -23
  169. package/lib/utils/resolve-outdir-sync.js +0 -18
  170. package/lib/utils/resolve-outdir.js +0 -18
  171. package/lint-staged.config.mjs +0 -1
@@ -0,0 +1,57 @@
1
+ import * as ts from 'typescript';
2
+ import { isEmpty } from 'lodash/fp';
3
+ import { getSchemaInterfaceName, getSchemaExtendsTypeName, toTypeLiteral, NAMESPACES } from './utils.mjs';
4
+ import { attributeToPropertySignature } from './attributes.mjs';
5
+ import { addImport } from '../imports.mjs';
6
+
7
+ const { factory } = ts;
8
+ /**
9
+ * Generate a property signature for the schema's `attributes` field
10
+ */ const generateAttributePropertySignature = (schema)=>{
11
+ const { attributes } = schema;
12
+ const properties = Object.entries(attributes).sort((a, b)=>a[0].localeCompare(b[0])).map(([attributeName, attribute])=>{
13
+ return attributeToPropertySignature(schema, attributeName, attribute);
14
+ });
15
+ return factory.createPropertySignature(undefined, factory.createIdentifier('attributes'), undefined, factory.createTypeLiteralNode(properties));
16
+ };
17
+ const generatePropertyLiteralDefinitionFactory = (schema)=>(key)=>{
18
+ return factory.createPropertySignature(undefined, factory.createIdentifier(key), undefined, toTypeLiteral(schema[key]));
19
+ };
20
+ /**
21
+ * Generate an interface declaration for a given schema
22
+ */ const generateSchemaDefinition = (schema)=>{
23
+ const { uid } = schema;
24
+ // Resolve the different interface names needed to declare the schema's interface
25
+ const interfaceName = getSchemaInterfaceName(uid);
26
+ const parentType = getSchemaExtendsTypeName(schema);
27
+ // Make sure the Struct namespace is imported
28
+ addImport(NAMESPACES.Struct);
29
+ // Properties whose values can be mapped to a literal type expression
30
+ const literalPropertiesDefinitions = [
31
+ 'collectionName',
32
+ 'info',
33
+ 'options',
34
+ 'pluginOptions'
35
+ ]// Ignore non-existent or empty declarations
36
+ .filter((key)=>!isEmpty(schema[key]))// Generate literal definition for each property
37
+ .map(generatePropertyLiteralDefinitionFactory(schema));
38
+ // Generate the `attributes` literal type definition
39
+ const attributesProp = generateAttributePropertySignature(schema);
40
+ // Merge every schema's definition in a single list
41
+ const schemaProperties = [
42
+ ...literalPropertiesDefinitions,
43
+ attributesProp
44
+ ];
45
+ // Generate the schema's interface declaration
46
+ const schemaType = factory.createInterfaceDeclaration([
47
+ factory.createModifier(ts.SyntaxKind.ExportKeyword)
48
+ ], factory.createIdentifier(interfaceName), undefined, [
49
+ factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [
50
+ factory.createIdentifier(parentType)
51
+ ])
52
+ ], schemaProperties);
53
+ return schemaType;
54
+ };
55
+
56
+ export { generateSchemaDefinition };
57
+ //# sourceMappingURL=schema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.mjs","sources":["../../../../src/generators/common/models/schema.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { isEmpty } from 'lodash/fp';\n\nimport {\n getSchemaExtendsTypeName,\n getSchemaInterfaceName,\n toTypeLiteral,\n NAMESPACES,\n} from './utils';\nimport type { Schema } from './utils';\nimport { attributeToPropertySignature } from './attributes';\nimport { addImport } from '../imports';\n\nconst { factory } = ts;\n\n/**\n * Generate a property signature for the schema's `attributes` field\n */\nconst generateAttributePropertySignature = (schema: Schema): ts.PropertySignature => {\n const { attributes } = schema;\n\n const properties = Object.entries(attributes)\n .sort((a, b) => a[0].localeCompare(b[0]))\n .map(([attributeName, attribute]) => {\n return attributeToPropertySignature(schema, attributeName, attribute);\n });\n\n return factory.createPropertySignature(\n undefined,\n factory.createIdentifier('attributes'),\n undefined,\n factory.createTypeLiteralNode(properties as any)\n );\n};\n\nconst generatePropertyLiteralDefinitionFactory = (schema: Schema) => (key: string) => {\n return factory.createPropertySignature(\n undefined,\n factory.createIdentifier(key),\n undefined,\n toTypeLiteral(schema[key])\n );\n};\n\n/**\n * Generate an interface declaration for a given schema\n */\nexport const generateSchemaDefinition = (schema: Schema): ts.InterfaceDeclaration => {\n const { uid } = schema;\n\n // Resolve the different interface names needed to declare the schema's interface\n const interfaceName = getSchemaInterfaceName(uid);\n const parentType = getSchemaExtendsTypeName(schema);\n\n // Make sure the Struct namespace is imported\n addImport(NAMESPACES.Struct);\n\n // Properties whose values can be mapped to a literal type expression\n const literalPropertiesDefinitions = ['collectionName', 'info', 'options', 'pluginOptions']\n // Ignore non-existent or empty declarations\n .filter((key) => !isEmpty(schema[key]))\n // Generate literal definition for each property\n .map(generatePropertyLiteralDefinitionFactory(schema));\n\n // Generate the `attributes` literal type definition\n const attributesProp = generateAttributePropertySignature(schema);\n\n // Merge every schema's definition in a single list\n const schemaProperties = [...literalPropertiesDefinitions, attributesProp];\n\n // Generate the schema's interface declaration\n const schemaType = factory.createInterfaceDeclaration(\n [factory.createModifier(ts.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(interfaceName),\n undefined,\n [\n factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [\n factory.createIdentifier(parentType as string) as any,\n ]),\n ],\n schemaProperties\n );\n\n return schemaType;\n};\n"],"names":["factory","ts","generateAttributePropertySignature","schema","attributes","properties","Object","entries","sort","a","b","localeCompare","map","attributeName","attribute","attributeToPropertySignature","createPropertySignature","undefined","createIdentifier","createTypeLiteralNode","generatePropertyLiteralDefinitionFactory","key","toTypeLiteral","generateSchemaDefinition","uid","interfaceName","getSchemaInterfaceName","parentType","getSchemaExtendsTypeName","addImport","NAMESPACES","Struct","literalPropertiesDefinitions","filter","isEmpty","attributesProp","schemaProperties","schemaType","createInterfaceDe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,CAAyBzB,MAAAA,CAAAA;;AAG5C0B,IAAAA,SAAAA,CAAUC,WAAWC,MAAM,CAAA;;AAG3B,IAAA,MAAMC,4BAAAA,GAA+B;AAAC,QAAA,gBAAA;AAAkB,QAAA,MAAA;AAAQ,QAAA,SAAA;AAAW,QAAA;AAAgB,KACzF;KACCC,MAAM,CAAC,CAACZ,GAAAA,GAAQ,CAACa,QAAQ/B,MAAM,CAACkB,GAAAA,CAAI,CAAA,CACrC;AACCT,KAAAA,GAAG,CAACQ,wCAAAA,CAAyCjB,MAAAA,CAAAA,CAAAA;;AAGhD,IAAA,MAAMgC,iBAAiBjC,kCAAAA,CAAmCC,MAAAA,CAAAA;;AAG1D,IAAA,MAAMiC,gBAAAA,GAAmB;AAAIJ,QAAAA,GAAAA,4BAAAA;AAA8BG,QAAAA;AAAe,KAAA;;IAG1E,MAAME,UAAAA,GAAarC,OAAAA,CAAQsC,0BAA0B,CACnD;AAACtC,QAAAA,OAAAA,CAAQuC,cAAc,CAACtC,EAAAA,CAAGuC,UAAU,CAACC,aAAa;AAAE,KAAA,EACrDzC,OAAAA,CAAQkB,gBAAgB,CAACO,aAAAA,CAAAA,EACzBR,SAAAA,EACA;AACEjB,QAAAA,OAAAA,CAAQ0C,oBAAoB,CAACzC,EAAAA,CAAGuC,UAAU,CAACG,cAAc,EAAE;AACzD3C,YAAAA,OAAAA,CAAQkB,gBAAgB,CAACS,UAAAA;AAC1B,SAAA;KACF,EACDS,gBAAAA,CAAAA;IAGF,OAAOC,UAAAA;AACT;;;;"}
@@ -0,0 +1,54 @@
1
+ import * as ts from 'typescript';
2
+ export declare const NAMESPACES: {
3
+ Struct: string;
4
+ Schema: string;
5
+ };
6
+ /**
7
+ * Shallow representation of a content-type/component attribute definition.
8
+ * Only the fields read by the generators are typed; the rest is left open.
9
+ */
10
+ export interface Attribute {
11
+ type: string;
12
+ [key: string]: any;
13
+ }
14
+ /**
15
+ * Shallow representation of a content-type/component schema definition.
16
+ * Only the fields read by the generators are typed; the rest is left open.
17
+ */
18
+ export interface Schema {
19
+ uid: string;
20
+ modelType?: string;
21
+ kind?: string;
22
+ attributes: Record<string, Attribute>;
23
+ [key: string]: any;
24
+ }
25
+ /**
26
+ * Extract a valid interface name from a schema uid
27
+ */
28
+ export declare const getSchemaInterfaceName: (uid: string) => string;
29
+ export declare const getSchemaModelType: (schema: Schema) => string | null | undefined;
30
+ /**
31
+ * Get the parent type name to extend based on the schema's nature
32
+ */
33
+ export declare const getSchemaExtendsTypeName: (schema: Schema) => string | null;
34
+ /**
35
+ * Get a type node based on a type and its params
36
+ */
37
+ export declare const getTypeNode: (typeName: string, params?: ts.TypeNode[]) => ts.TypeReferenceNode;
38
+ /**
39
+ * Transform a regular JavaScript object or scalar value into a literal expression
40
+ */
41
+ export declare const toTypeLiteral: (data: any) => any;
42
+ /**
43
+ * Get the number of attributes generated for a given schema definition
44
+ */
45
+ export declare const getDefinitionAttributesCount: (definition: ts.InterfaceDeclaration) => number | null;
46
+ /**
47
+ * Add the Schema.Attribute namespace before the typename
48
+ */
49
+ export declare const withAttributeNamespace: (typeName: string) => string;
50
+ /**
51
+ * Add the schema namespace before the typename
52
+ */
53
+ export declare const withSchemaNamespace: (typeName: string) => string;
54
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/generators/common/models/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAkBjC,eAAO,MAAM,UAAU;;;CAGtB,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAwD,CACzF,GAAG,EAAE,MAAM,KACR,MAAM,CAAC;AAEZ,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,KAAG,MAAM,GAAG,IAAI,GAAG,SAcnE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,QAAQ,MAAM,KAAG,MAAM,GAAG,IAQlE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,MAAM,EAAE,SAAQ,EAAE,CAAC,QAAQ,EAAO,KAAG,EAAE,CAAC,iBAE7E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,GAAG,KAAG,GA2DzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,GACvC,YAAY,EAAE,CAAC,oBAAoB,KAClC,MAAM,GAAG,IAUX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,UAAU,MAAM,KAAG,MACZ,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,UAAU,MAAM,KAAG,MACV,CAAC"}
@@ -0,0 +1,109 @@
1
+ 'use strict';
2
+
3
+ var ts = require('typescript');
4
+ var _ = require('lodash/fp');
5
+
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var ts__namespace = /*#__PURE__*/_interopNamespace(ts);
25
+
26
+ const { factory } = ts__namespace;
27
+ const NAMESPACES = {
28
+ Struct: 'Struct',
29
+ Schema: 'Schema'
30
+ };
31
+ /**
32
+ * Extract a valid interface name from a schema uid
33
+ */ const getSchemaInterfaceName = _.pipe(_.replace(/(:.)/, ' '), _.camelCase, _.upperFirst);
34
+ const getSchemaModelType = (schema)=>{
35
+ const { modelType, kind } = schema;
36
+ // Components
37
+ if (modelType === 'component') {
38
+ return 'component';
39
+ }
40
+ // Content-Types
41
+ if (modelType === 'contentType') {
42
+ return kind;
43
+ }
44
+ return null;
45
+ };
46
+ /**
47
+ * Get the parent type name to extend based on the schema's nature
48
+ */ const getSchemaExtendsTypeName = (schema)=>{
49
+ const base = getSchemaModelType(schema);
50
+ if (base === null) {
51
+ return null;
52
+ }
53
+ return `${NAMESPACES.Struct}.${_.upperFirst(base)}Schema`;
54
+ };
55
+ /**
56
+ * Get a type node based on a type and its params
57
+ */ const getTypeNode = (typeName, params = [])=>{
58
+ return factory.createTypeReferenceNode(factory.createIdentifier(typeName), params);
59
+ };
60
+ /**
61
+ * Transform a regular JavaScript object or scalar value into a literal expression
62
+ */ const toTypeLiteral = (data)=>{
63
+ if (_.isUndefined(data)) {
64
+ return factory.createLiteralTypeNode(ts__namespace.SyntaxKind.UndefinedKeyword);
65
+ }
66
+ if (_.isNull(data)) {
67
+ return factory.createLiteralTypeNode(ts__namespace.SyntaxKind.NullKeyword);
68
+ }
69
+ if (_.isString(data)) {
70
+ return factory.createStringLiteral(data, true);
71
+ }
72
+ if (_.isNumber(data)) {
73
+ return data < 0 ? factory.createPrefixUnaryExpression(ts__namespace.SyntaxKind.MinusToken, factory.createNumericLiteral(-data)) : factory.createNumericLiteral(data);
74
+ }
75
+ if (_.isBoolean(data)) {
76
+ return data ? factory.createTrue() : factory.createFalse();
77
+ }
78
+ if (_.isArray(data)) {
79
+ return factory.createTupleTypeNode(data.map((item)=>toTypeLiteral(item)));
80
+ }
81
+ if (_.isDate(data)) {
82
+ return factory.createStringLiteral(data.toISOString());
83
+ }
84
+ if (typeof data !== 'object') {
85
+ throw new Error(`Cannot convert to object literal. Unknown type "${typeof data}"`);
86
+ }
87
+ const entries = Object.entries(data).sort((a, b)=>a[0].localeCompare(b[0]));
88
+ const props = entries.reduce((acc, [key, value])=>{
89
+ // Handle keys such as content-type-builder & co.
90
+ const identifier = key.includes('-') ? factory.createStringLiteral(key, true) : factory.createIdentifier(key);
91
+ return [
92
+ ...acc,
93
+ factory.createPropertyDeclaration(undefined, identifier, undefined, toTypeLiteral(value), undefined)
94
+ ];
95
+ }, []);
96
+ return factory.createTypeLiteralNode(props);
97
+ };
98
+ /**
99
+ * Add the Schema.Attribute namespace before the typename
100
+ */ const withAttributeNamespace = (typeName)=>`${NAMESPACES.Schema}.Attribute.${typeName}`;
101
+
102
+ exports.NAMESPACES = NAMESPACES;
103
+ exports.getSchemaExtendsTypeName = getSchemaExtendsTypeName;
104
+ exports.getSchemaInterfaceName = getSchemaInterfaceName;
105
+ exports.getSchemaModelType = getSchemaModelType;
106
+ exports.getTypeNode = getTypeNode;
107
+ exports.toTypeLiteral = toTypeLiteral;
108
+ exports.withAttributeNamespace = withAttributeNamespace;
109
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/generators/common/models/utils.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport {\n pipe,\n replace,\n camelCase,\n upperFirst,\n isUndefined,\n isNull,\n isString,\n isNumber,\n isDate,\n isArray,\n isBoolean,\n propEq,\n} from 'lodash/fp';\n\nconst { factory } = ts;\n\nexport const NAMESPACES = {\n Struct: 'Struct',\n Schema: 'Schema',\n};\n\n/**\n * Shallow representation of a content-type/component attribute definition.\n * Only the fields read by the generators are typed; the rest is left open.\n */\nexport interface Attribute {\n type: string;\n [key: string]: any;\n}\n\n/**\n * Shallow representation of a content-type/component schema definition.\n * Only the fields read by the generators are typed; the rest is left open.\n */\nexport interface Schema {\n uid: string;\n modelType?: string;\n kind?: string;\n attributes: Record<string, Attribute>;\n [key: string]: any;\n}\n\n/**\n * Extract a valid interface name from a schema uid\n */\nexport const getSchemaInterfaceName = pipe(replace(/(:.)/, ' '), camelCase, upperFirst) as (\n uid: string\n) => string;\n\nexport const getSchemaModelType = (schema: Schema): string | null | undefined => {\n const { modelType, kind } = schema;\n\n // Components\n if (modelType === 'component') {\n return 'component';\n }\n\n // Content-Types\n if (modelType === 'contentType') {\n return kind;\n }\n\n return null;\n};\n\n/**\n * Get the parent type name to extend based on the schema's nature\n */\nexport const getSchemaExtendsTypeName = (schema: Schema): string | null => {\n const base = getSchemaModelType(schema);\n\n if (base === null) {\n return null;\n }\n\n return `${NAMESPACES.Struct}.${upperFirst(base as string)}Schema`;\n};\n\n/**\n * Get a type node based on a type and its params\n */\nexport const getTypeNode = (typeName: string, params: ts.TypeNode[] = []): ts.TypeReferenceNode => {\n return factory.createTypeReferenceNode(factory.createIdentifier(typeName), params);\n};\n\n/**\n * Transform a regular JavaScript object or scalar value into a literal expression\n */\nexport const toTypeLiteral = (data: any): any => {\n if (isUndefined(data)) {\n return factory.createLiteralTypeNode(ts.SyntaxKind.UndefinedKeyword as any);\n }\n\n if (isNull(data)) {\n return factory.createLiteralTypeNode(ts.SyntaxKind.NullKeyword as any);\n }\n\n if (isString(data)) {\n return factory.createStringLiteral(data, true);\n }\n\n if (isNumber(data)) {\n return data < 0\n ? factory.createPrefixUnaryExpression(\n ts.SyntaxKind.MinusToken,\n factory.createNumericLiteral(-data)\n )\n : factory.createNumericLiteral(data);\n }\n\n if (isBoolean(data)) {\n return data ? factory.createTrue() : factory.createFalse();\n }\n\n if (isArray(data)) {\n return factory.createTupleTypeNode(data.map((item) => toTypeLiteral(item)));\n }\n\n if (isDate(data)) {\n return factory.createStringLiteral(data.toISOString());\n }\n\n if (typeof data !== 'object') {\n throw new Error(`Cannot convert to object literal. Unknown type \"${typeof data}\"`);\n }\n\n const entries = Object.entries(data).sort((a, b) => a[0].localeCompare(b[0]));\n\n const props = entries.reduce<any[]>((acc, [key, value]) => {\n // Handle keys such as content-type-builder & co.\n const identifier = key.includes('-')\n ? factory.createStringLiteral(key, true)\n : factory.createIdentifier(key);\n\n return [\n ...acc,\n factory.createPropertyDeclaration(\n undefined,\n identifier,\n undefined,\n toTypeLiteral(value),\n undefined\n ),\n ];\n }, []);\n\n return factory.createTypeLiteralNode(props);\n};\n\n/**\n * Get the number of attributes generated for a given schema definition\n */\nexport const getDefinitionAttributesCount = (\n definition: ts.InterfaceDeclaration\n): number | null => {\n const attributesNode = definition.members.find(\n (propEq as any)('name.escapedText', 'attributes')\n ) as any;\n\n if (!attributesNode) {\n return null;\n }\n\n return attributesNode.type.members.length;\n};\n\n/**\n * Add the Schema.Attribute namespace before the typename\n */\nexport const withAttributeNamespace = (typeName: string): string =>\n `${NAMESPACES.Schema}.Attribute.${typeName}`;\n\n/**\n * Add the schema namespace before the typename\n */\nexport const withSchemaNamespace = (typeName: string): string =>\n `${(NAMESPACES as any).schema}.${typeName}`;\n"],"names":["factory","ts","NAMESPACES","Struct","Schema","getSchemaInterfaceName","pipe","replace","camelCase","upperFirst","getSchemaModelType","schema","modelType","kind","getSchemaExtendsTypeName","base","getTypeNode","typeName","params","createTypeReferenceNode","createIdentifier","toTypeLiteral","data","isUndefined","createLiteralTypeNode","SyntaxKind","UndefinedKeyword","isNull","NullKeyword","isString","createStringLiteral","isNumber","createPrefixUnaryExpression","MinusToken","createNumericLiteral","isBoolean","createTrue","createFalse","isArray","createTupleTypeNode","map","item","isDate","toISOString","Error","entries","Object","sort","a","b","localeCompare","props","reduce","acc","key","value","identifier","includes","createPropertyDeclaration","undefined","createTypeLiteralNode","withAttributeNamespace"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAM,EAAEA,OAAO,EAAE,GAAGC,aAAAA;MAEPC,UAAAA,GAAa;IACxBC,MAAAA,EAAQ,QAAA;IACRC,MAAAA,EAAQ;AACV;AAuBA;;UAGaC,sBAAAA,G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AACC,GAAAA,EAAK,CAACC,KAAKC,KAAAA,CAAM,GAAA;;AAEpD,QAAA,MAAMC,UAAAA,GAAaF,GAAAA,CAAIG,QAAQ,CAAC,GAAA,CAAA,GAC5BzD,OAAAA,CAAQ8B,mBAAmB,CAACwB,GAAAA,EAAK,IAAA,CAAA,GACjCtD,OAAAA,CAAQoB,gBAAgB,CAACkC,GAAAA,CAAAA;QAE7B,OAAO;AACFD,YAAAA,GAAAA,GAAAA;AACHrD,YAAAA,OAAAA,CAAQ0D,yBAAyB,CAC/BC,SAAAA,EACAH,UAAAA,EACAG,SAAAA,EACAtC,cAAckC,KAAAA,CAAAA,EACdI,SAAAA;AAEH,SAAA;AACH,IAAA,CAAA,EAAG,EAAE,CAAA;IAEL,OAAO3D,OAAAA,CAAQ4D,qBAAqB,CAACT,KAAAA,CAAAA;AACvC;AAmBA;;AAEC,IACM,MAAMU,sBAAAA,GAAyB,CAAC5C,QAAAA,GACrC,CAAA,EAAGf,UAAAA,CAAWE,MAAM,CAAC,WAAW,EAAEa,QAAAA,CAAAA;;;;;;;;;;"}
@@ -0,0 +1,81 @@
1
+ import * as ts from 'typescript';
2
+ import { pipe, replace, camelCase, upperFirst, isUndefined, isNull, isString, isNumber, isBoolean, isArray, isDate } from 'lodash/fp';
3
+
4
+ const { factory } = ts;
5
+ const NAMESPACES = {
6
+ Struct: 'Struct',
7
+ Schema: 'Schema'
8
+ };
9
+ /**
10
+ * Extract a valid interface name from a schema uid
11
+ */ const getSchemaInterfaceName = pipe(replace(/(:.)/, ' '), camelCase, upperFirst);
12
+ const getSchemaModelType = (schema)=>{
13
+ const { modelType, kind } = schema;
14
+ // Components
15
+ if (modelType === 'component') {
16
+ return 'component';
17
+ }
18
+ // Content-Types
19
+ if (modelType === 'contentType') {
20
+ return kind;
21
+ }
22
+ return null;
23
+ };
24
+ /**
25
+ * Get the parent type name to extend based on the schema's nature
26
+ */ const getSchemaExtendsTypeName = (schema)=>{
27
+ const base = getSchemaModelType(schema);
28
+ if (base === null) {
29
+ return null;
30
+ }
31
+ return `${NAMESPACES.Struct}.${upperFirst(base)}Schema`;
32
+ };
33
+ /**
34
+ * Get a type node based on a type and its params
35
+ */ const getTypeNode = (typeName, params = [])=>{
36
+ return factory.createTypeReferenceNode(factory.createIdentifier(typeName), params);
37
+ };
38
+ /**
39
+ * Transform a regular JavaScript object or scalar value into a literal expression
40
+ */ const toTypeLiteral = (data)=>{
41
+ if (isUndefined(data)) {
42
+ return factory.createLiteralTypeNode(ts.SyntaxKind.UndefinedKeyword);
43
+ }
44
+ if (isNull(data)) {
45
+ return factory.createLiteralTypeNode(ts.SyntaxKind.NullKeyword);
46
+ }
47
+ if (isString(data)) {
48
+ return factory.createStringLiteral(data, true);
49
+ }
50
+ if (isNumber(data)) {
51
+ return data < 0 ? factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, factory.createNumericLiteral(-data)) : factory.createNumericLiteral(data);
52
+ }
53
+ if (isBoolean(data)) {
54
+ return data ? factory.createTrue() : factory.createFalse();
55
+ }
56
+ if (isArray(data)) {
57
+ return factory.createTupleTypeNode(data.map((item)=>toTypeLiteral(item)));
58
+ }
59
+ if (isDate(data)) {
60
+ return factory.createStringLiteral(data.toISOString());
61
+ }
62
+ if (typeof data !== 'object') {
63
+ throw new Error(`Cannot convert to object literal. Unknown type "${typeof data}"`);
64
+ }
65
+ const entries = Object.entries(data).sort((a, b)=>a[0].localeCompare(b[0]));
66
+ const props = entries.reduce((acc, [key, value])=>{
67
+ // Handle keys such as content-type-builder & co.
68
+ const identifier = key.includes('-') ? factory.createStringLiteral(key, true) : factory.createIdentifier(key);
69
+ return [
70
+ ...acc,
71
+ factory.createPropertyDeclaration(undefined, identifier, undefined, toTypeLiteral(value), undefined)
72
+ ];
73
+ }, []);
74
+ return factory.createTypeLiteralNode(props);
75
+ };
76
+ /**
77
+ * Add the Schema.Attribute namespace before the typename
78
+ */ const withAttributeNamespace = (typeName)=>`${NAMESPACES.Schema}.Attribute.${typeName}`;
79
+
80
+ export { NAMESPACES, getSchemaExtendsTypeName, getSchemaInterfaceName, getSchemaModelType, getTypeNode, toTypeLiteral, withAttributeNamespace };
81
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","sources":["../../../../src/generators/common/models/utils.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport {\n pipe,\n replace,\n camelCase,\n upperFirst,\n isUndefined,\n isNull,\n isString,\n isNumber,\n isDate,\n isArray,\n isBoolean,\n propEq,\n} from 'lodash/fp';\n\nconst { factory } = ts;\n\nexport const NAMESPACES = {\n Struct: 'Struct',\n Schema: 'Schema',\n};\n\n/**\n * Shallow representation of a content-type/component attribute definition.\n * Only the fields read by the generators are typed; the rest is left open.\n */\nexport interface Attribute {\n type: string;\n [key: string]: any;\n}\n\n/**\n * Shallow representation of a content-type/component schema definition.\n * Only the fields read by the generators are typed; the rest is left open.\n */\nexport interface Schema {\n uid: string;\n modelType?: string;\n kind?: string;\n attributes: Record<string, Attribute>;\n [key: string]: any;\n}\n\n/**\n * Extract a valid interface name from a schema uid\n */\nexport const getSchemaInterfaceName = pipe(replace(/(:.)/, ' '), camelCase, upperFirst) as (\n uid: string\n) => string;\n\nexport const getSchemaModelType = (schema: Schema): string | null | undefined => {\n const { modelType, kind } = schema;\n\n // Components\n if (modelType === 'component') {\n return 'component';\n }\n\n // Content-Types\n if (modelType === 'contentType') {\n return kind;\n }\n\n return null;\n};\n\n/**\n * Get the parent type name to extend based on the schema's nature\n */\nexport const getSchemaExtendsTypeName = (schema: Schema): string | null => {\n const base = getSchemaModelType(schema);\n\n if (base === null) {\n return null;\n }\n\n return `${NAMESPACES.Struct}.${upperFirst(base as string)}Schema`;\n};\n\n/**\n * Get a type node based on a type and its params\n */\nexport const getTypeNode = (typeName: string, params: ts.TypeNode[] = []): ts.TypeReferenceNode => {\n return factory.createTypeReferenceNode(factory.createIdentifier(typeName), params);\n};\n\n/**\n * Transform a regular JavaScript object or scalar value into a literal expression\n */\nexport const toTypeLiteral = (data: any): any => {\n if (isUndefined(data)) {\n return factory.createLiteralTypeNode(ts.SyntaxKind.UndefinedKeyword as any);\n }\n\n if (isNull(data)) {\n return factory.createLiteralTypeNode(ts.SyntaxKind.NullKeyword as any);\n }\n\n if (isString(data)) {\n return factory.createStringLiteral(data, true);\n }\n\n if (isNumber(data)) {\n return data < 0\n ? factory.createPrefixUnaryExpression(\n ts.SyntaxKind.MinusToken,\n factory.createNumericLiteral(-data)\n )\n : factory.createNumericLiteral(data);\n }\n\n if (isBoolean(data)) {\n return data ? factory.createTrue() : factory.createFalse();\n }\n\n if (isArray(data)) {\n return factory.createTupleTypeNode(data.map((item) => toTypeLiteral(item)));\n }\n\n if (isDate(data)) {\n return factory.createStringLiteral(data.toISOString());\n }\n\n if (typeof data !== 'object') {\n throw new Error(`Cannot convert to object literal. Unknown type \"${typeof data}\"`);\n }\n\n const entries = Object.entries(data).sort((a, b) => a[0].localeCompare(b[0]));\n\n const props = entries.reduce<any[]>((acc, [key, value]) => {\n // Handle keys such as content-type-builder & co.\n const identifier = key.includes('-')\n ? factory.createStringLiteral(key, true)\n : factory.createIdentifier(key);\n\n return [\n ...acc,\n factory.createPropertyDeclaration(\n undefined,\n identifier,\n undefined,\n toTypeLiteral(value),\n undefined\n ),\n ];\n }, []);\n\n return factory.createTypeLiteralNode(props);\n};\n\n/**\n * Get the number of attributes generated for a given schema definition\n */\nexport const getDefinitionAttributesCount = (\n definition: ts.InterfaceDeclaration\n): number | null => {\n const attributesNode = definition.members.find(\n (propEq as any)('name.escapedText', 'attributes')\n ) as any;\n\n if (!attributesNode) {\n return null;\n }\n\n return attributesNode.type.members.length;\n};\n\n/**\n * Add the Schema.Attribute namespace before the typename\n */\nexport const withAttributeNamespace = (typeName: string): string =>\n `${NAMESPACES.Schema}.Attribute.${typeName}`;\n\n/**\n * Add the schema namespace before the typename\n */\nexport const withSchemaNamespace = (typeName: string): string =>\n `${(NAMESPACES as any).schema}.${typeName}`;\n"],"names":["factory","ts","NAMESPACES","Struct","Schema","getSchemaInterfaceName","pipe","replace","camelCase","upperFirst","getSchemaModelType","schema","modelType","kind","getSchemaExtendsTypeName","base","getTypeNode","typeName","params","createTypeReferenceNode","createIdentifier","toTypeLiteral","data","isUndefined","createLiteralTypeNode","SyntaxKind","UndefinedKeyword","isNull","NullKeyword","isString","createStringLiteral","isNumber","createPrefixUnaryExpression","MinusToken","createNumericLiteral","isBoolean","createTrue","createFalse","isArray","createTupleTypeNode","map","item","isDate","toISOString","Error","entries","Object","sort","a","b","localeCompare","props","reduce","acc","key","value","identifier","includes","createPropertyDeclaration","undefined","createTypeLiteralNode","withAttributeNamespace"],"mappings":";;;AAgBA,MAAM,EAAEA,OAAO,EAAE,GAAGC,EAAAA;MAEPC,UAAAA,GAAa;IACxBC,MAAAA,EAAQ,QAAA;IACRC,MAAAA,EAAQ;AACV;AAuBA;;UAGaC,sBAAAA,GAAyBC,IAAAA,CAAKC,QAAQ,MAAA,EAAQ,GAAA,CAAA,EAAMC,WAAWC,UAAAA;AAIrE,MAAMC,qBAAqB,CAACC,MAAAA,GAAAA;AACjC,IAAA,MAAM,EAAEC,SAAS,EAAEC,IAAI,EAAE,GAAGF,MAAAA;;AAG5B,IAAA,IAAIC,cAAc,WAAA,EAAa;QAC7B,OAAO,WAAA;AACT,IAAA;;AAGA,IAAA,IAAIA,cAAc,aAAA,EAAe;QAC/B,OAAOC,IAAAA;AACT,IAAA;IAEA,OAAO,IAAA;AACT;AAEA;;IAGO,MAAMC,wBAAAA,GAA2B,CAACH,MAAAA,GAAAA;AACvC,IAAA,MAAMI,OAAOL,kBAAAA,CAAmBC,MAAAA,CAAAA;AAEhC,IAAA,IAAII,SAAS,IAAA,EAAM;QACjB,OAAO,IAAA;AACT,IAAA;IAEA,OAAO,CAAA,EAAGb,WAAWC,MAAM,CAAC,CAAC,EAAEM,UAAAA,CAAWM,IAAAA,CAAAA,CAAgB,MAAM,CAAC;AACnE;AAEA;;AAEC,IACM,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;;"}
@@ -0,0 +1,9 @@
1
+ import type { GeneratorOptions } from '../utils';
2
+ /**
3
+ * Generate type definitions for Strapi Components
4
+ */
5
+ export declare const generateComponentsDefinitions: (options?: GeneratorOptions) => Promise<{
6
+ output: string;
7
+ stats: {};
8
+ }>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generators/components/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AASjD;;GAEG;AACH,eAAO,MAAM,6BAA6B,GACxC,UAAS,gBAAyC;;;EAmDnD,CAAC"}
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ var ts = require('typescript');
4
+ var _ = require('lodash/fp');
5
+ var schema = require('../common/models/schema.js');
6
+ var imports = require('../common/imports.js');
7
+ require('../common/models/utils.js');
8
+ var utils = require('../utils.js');
9
+
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default') {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () { return e[k]; }
20
+ });
21
+ }
22
+ });
23
+ }
24
+ n.default = e;
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ var ts__namespace = /*#__PURE__*/_interopNamespace(ts);
29
+
30
+ const { factory } = ts__namespace;
31
+ const NO_COMPONENT_PLACEHOLDER_COMMENT = `/*
32
+ * The app doesn't have any components yet.
33
+ */
34
+ `;
35
+ /**
36
+ * Generate type definitions for Strapi Components
37
+ */ const generateComponentsDefinitions = async (options = {})=>{
38
+ const { strapi } = options;
39
+ const { components } = strapi;
40
+ const componentsDefinitions = _.pipe(_.values, _.sortBy('uid'), _.map((component)=>({
41
+ uid: component.uid,
42
+ definition: schema.generateSchemaDefinition(component)
43
+ })))(components);
44
+ options.logger.debug(`Found ${componentsDefinitions.length} components.`);
45
+ if (componentsDefinitions.length === 0) {
46
+ return {
47
+ output: NO_COMPONENT_PLACEHOLDER_COMMENT,
48
+ stats: {}
49
+ };
50
+ }
51
+ const formattedSchemasDefinitions = componentsDefinitions.reduce((acc, def)=>{
52
+ acc.push(// Definition
53
+ def.definition, // Add a newline between each interface declaration
54
+ factory.createIdentifier('\n'));
55
+ return acc;
56
+ }, []);
57
+ const allDefinitions = [
58
+ // Imports
59
+ ...imports.generateImportDefinition(),
60
+ // Add a newline after the import statement
61
+ factory.createIdentifier('\n'),
62
+ // Schemas
63
+ ...formattedSchemasDefinitions,
64
+ // Global
65
+ utils.generateSharedExtensionDefinition('ComponentSchemas', componentsDefinitions)
66
+ ];
67
+ const output = utils.emitDefinitions(allDefinitions);
68
+ const formattedOutput = await utils.format(output);
69
+ return {
70
+ output: formattedOutput,
71
+ stats: {}
72
+ };
73
+ };
74
+
75
+ exports.generateComponentsDefinitions = generateComponentsDefinitions;
76
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/generators/components/index.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { pipe, values, sortBy, map } from 'lodash/fp';\n\nimport { models } from '../common';\nimport { emitDefinitions, format, generateSharedExtensionDefinition } from '../utils';\nimport type { GeneratorOptions } from '../utils';\n\nconst { factory } = ts;\n\nconst NO_COMPONENT_PLACEHOLDER_COMMENT = `/*\n * The app doesn't have any components yet.\n */\n`;\n\n/**\n * Generate type definitions for Strapi Components\n */\nexport const generateComponentsDefinitions = async (\n options: GeneratorOptions = {} as GeneratorOptions\n) => {\n const { strapi } = options;\n\n const { components } = strapi;\n\n const componentsDefinitions = pipe(\n values,\n sortBy('uid'),\n map((component: any) => ({\n uid: component.uid,\n definition: models.schema.generateSchemaDefinition(component),\n }))\n )(components);\n\n options.logger.debug(`Found ${componentsDefinitions.length} components.`);\n\n if (componentsDefinitions.length === 0) {\n return { output: NO_COMPONENT_PLACEHOLDER_COMMENT, stats: {} };\n }\n\n const formattedSchemasDefinitions = componentsDefinitions.reduce<any[]>((acc, def) => {\n acc.push(\n // Definition\n def.definition,\n\n // Add a newline between each interface declaration\n factory.createIdentifier('\\n')\n );\n\n return acc;\n }, []);\n\n const allDefinitions = [\n // Imports\n ...models.imports.generateImportDefinition(),\n\n // Add a newline after the import statement\n factory.createIdentifier('\\n'),\n\n // Schemas\n ...formattedSchemasDefinitions,\n\n // Global\n generateSharedExtensionDefinition('ComponentSchemas', componentsDefinitions),\n ];\n\n const output = emitDefinitions(allDefinitions);\n const formattedOutput = await format(output);\n\n return { output: formattedOutput, stats: {} };\n};\n"],"names":["factory","ts","NO_COMPONENT_PLACEHOLDER_COMMENT","generateComponentsDefinitions","options","strapi","components","componentsDefinitions","pipe","values","sortBy","map","component","uid","definition","models","logger","debug","length","output","stats","formattedSchemasDefinitions","reduce","acc","def","push","createIdentifier","allDefinitions","generateSharedExtensionDefinition","emitDefinitions","formattedOutput","format"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,EAAEA,OAAO,EAAE,GAAGC,aAAAA;AAEpB,MAAMC,mCAAmC,CAAC;;;AAG1C,CAAC;AAED;;AAEC,IACM,MAAMC,6BAAAA,GAAgC,OAC3CC,OAAAA,GAA4B,EAAsB,GAAA;IAElD,MAAM,EAAEC,MAAM,EAAE,GAAGD,OAAAA;IAEnB,MAAM,EAAEE,UAAU,EAAE,GAAGD,MAAAA;IAEvB,MAAME,qBAAAA,GAAwBC,OAC5BC,QAAAA,EACAC,QAAAA,CAAO,QACPC,KAAAA,CAAI,CAACC,aAAoB;AACvBC,YAAAA,GAAAA,EAAKD,UAAUC,GAAG;AAClBC,YAAAA,UAAAA,EAAYC,+BAAsC,CAACH,SAAAA;AACrD,SAAA,CAAA,CAAA,CAAA,CACAN,UAAAA,CAAAA;IAEFF,OAAAA,CAAQY,MAAM,CAACC,KAAK,CAAC,CAAC,MAAM,EAAEV,qBAAAA,CAAsBW,MAAM,CAAC,YAAY,CAAC,CAAA;IAExE,IAAIX,qBAAAA,CAAsBW,MAAM,KAAK,CAAA,EAAG;QACtC,OAAO;YAAEC,MAAAA,EAAQjB,gCAAAA;AAAkCkB,YAAAA,KAAAA,EAAO;AAAG,SAAA;AAC/D,IAAA;AAEA,IAAA,MAAMC,2BAAAA,GAA8Bd,qBAAAA,CAAsBe,MAAM,CAAQ,CAACC,GAAAA,EAAKC,GAAAA,GAAAA;QAC5ED,GAAAA,CAAIE,IAAI;QAEND,GAAAA,CAAIV,UAAU;AAGdd,QAAAA,OAAAA,CAAQ0B,gBAAgB,CAAC,IAAA,CAAA,CAAA;QAG3B,OAAOH,GAAAA;AACT,IAAA,CAAA,EAAG,EAAE,CAAA;AAEL,IAAA,MAAMI,cAAAA,GAAiB;;WAElBZ,gCAAuC,EAAA;;AAG1Cf,QAAAA,OAAAA,CAAQ0B,gBAAgB,CAAC,IAAA,CAAA;;AAGtBL,QAAAA,GAAAA,2BAAAA;;AAGHO,QAAAA,uCAAAA,CAAkC,kBAAA,EAAoBrB,qBAAAA;AACvD,KAAA;AAED,IAAA,MAAMY,SAASU,qBAAAA,CAAgBF,cAAAA,CAAAA;IAC/B,MAAMG,eAAAA,GAAkB,MAAMC,YAAAA,CAAOZ,MAAAA,CAAAA;IAErC,OAAO;QAAEA,MAAAA,EAAQW,eAAAA;AAAiBV,QAAAA,KAAAA,EAAO;AAAG,KAAA;AAC9C;;;;"}
@@ -0,0 +1,54 @@
1
+ import * as ts from 'typescript';
2
+ import { pipe, values, sortBy, map } from 'lodash/fp';
3
+ import { generateSchemaDefinition } from '../common/models/schema.mjs';
4
+ import { generateImportDefinition } from '../common/imports.mjs';
5
+ import '../common/models/utils.mjs';
6
+ import { generateSharedExtensionDefinition, emitDefinitions, format } from '../utils.mjs';
7
+
8
+ const { factory } = ts;
9
+ const NO_COMPONENT_PLACEHOLDER_COMMENT = `/*
10
+ * The app doesn't have any components yet.
11
+ */
12
+ `;
13
+ /**
14
+ * Generate type definitions for Strapi Components
15
+ */ const generateComponentsDefinitions = async (options = {})=>{
16
+ const { strapi } = options;
17
+ const { components } = strapi;
18
+ const componentsDefinitions = pipe(values, sortBy('uid'), map((component)=>({
19
+ uid: component.uid,
20
+ definition: generateSchemaDefinition(component)
21
+ })))(components);
22
+ options.logger.debug(`Found ${componentsDefinitions.length} components.`);
23
+ if (componentsDefinitions.length === 0) {
24
+ return {
25
+ output: NO_COMPONENT_PLACEHOLDER_COMMENT,
26
+ stats: {}
27
+ };
28
+ }
29
+ const formattedSchemasDefinitions = componentsDefinitions.reduce((acc, def)=>{
30
+ acc.push(// Definition
31
+ def.definition, // Add a newline between each interface declaration
32
+ factory.createIdentifier('\n'));
33
+ return acc;
34
+ }, []);
35
+ const allDefinitions = [
36
+ // Imports
37
+ ...generateImportDefinition(),
38
+ // Add a newline after the import statement
39
+ factory.createIdentifier('\n'),
40
+ // Schemas
41
+ ...formattedSchemasDefinitions,
42
+ // Global
43
+ generateSharedExtensionDefinition('ComponentSchemas', componentsDefinitions)
44
+ ];
45
+ const output = emitDefinitions(allDefinitions);
46
+ const formattedOutput = await format(output);
47
+ return {
48
+ output: formattedOutput,
49
+ stats: {}
50
+ };
51
+ };
52
+
53
+ export { generateComponentsDefinitions };
54
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/generators/components/index.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { pipe, values, sortBy, map } from 'lodash/fp';\n\nimport { models } from '../common';\nimport { emitDefinitions, format, generateSharedExtensionDefinition } from '../utils';\nimport type { GeneratorOptions } from '../utils';\n\nconst { factory } = ts;\n\nconst NO_COMPONENT_PLACEHOLDER_COMMENT = `/*\n * The app doesn't have any components yet.\n */\n`;\n\n/**\n * Generate type definitions for Strapi Components\n */\nexport const generateComponentsDefinitions = async (\n options: GeneratorOptions = {} as GeneratorOptions\n) => {\n const { strapi } = options;\n\n const { components } = strapi;\n\n const componentsDefinitions = pipe(\n values,\n sortBy('uid'),\n map((component: any) => ({\n uid: component.uid,\n definition: models.schema.generateSchemaDefinition(component),\n }))\n )(components);\n\n options.logger.debug(`Found ${componentsDefinitions.length} components.`);\n\n if (componentsDefinitions.length === 0) {\n return { output: NO_COMPONENT_PLACEHOLDER_COMMENT, stats: {} };\n }\n\n const formattedSchemasDefinitions = componentsDefinitions.reduce<any[]>((acc, def) => {\n acc.push(\n // Definition\n def.definition,\n\n // Add a newline between each interface declaration\n factory.createIdentifier('\\n')\n );\n\n return acc;\n }, []);\n\n const allDefinitions = [\n // Imports\n ...models.imports.generateImportDefinition(),\n\n // Add a newline after the import statement\n factory.createIdentifier('\\n'),\n\n // Schemas\n ...formattedSchemasDefinitions,\n\n // Global\n generateSharedExtensionDefinition('ComponentSchemas', componentsDefinitions),\n ];\n\n const output = emitDefinitions(allDefinitions);\n const formattedOutput = await format(output);\n\n return { output: formattedOutput, stats: {} };\n};\n"],"names":["factory","ts","NO_COMPONENT_PLACEHOLDER_COMMENT","generateComponentsDefinitions","options","strapi","components","componentsDefinitions","pipe","values","sortBy","map","component","uid","definition","models","logger","debug","length","output","stats","formattedSchemasDefinitions","reduce","acc","def","push","createIdentifier","allDefinitions","generateSharedExtensionDefinition","emitDefinitions","formattedOutput","format"],"mappings":";;;;;;;AAOA,MAAM,EAAEA,OAAO,EAAE,GAAGC,EAAAA;AAEpB,MAAMC,mCAAmC,CAAC;;;AAG1C,CAAC;AAED;;AAEC,IACM,MAAMC,6BAAAA,GAAgC,OAC3CC,OAAAA,GAA4B,EAAsB,GAAA;IAElD,MAAM,EAAEC,MAAM,EAAE,GAAGD,OAAAA;IAEnB,MAAM,EAAEE,UAAU,EAAE,GAAGD,MAAAA;IAEvB,MAAME,qBAAAA,GAAwBC,KAC5BC,MAAAA,EACAC,MAAAA,CAAO,QACPC,GAAAA,CAAI,CAACC,aAAoB;AACvBC,YAAAA,GAAAA,EA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 {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/generators/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,UAAU,CAAC;AACtC,eAAO,MAAM,iBAAiB,cAAc,CAAC"}
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ const TYPES_ROOT_DIR = 'types';
4
+ const GENERATED_OUT_DIR = 'generated';
5
+
6
+ exports.GENERATED_OUT_DIR = GENERATED_OUT_DIR;
7
+ exports.TYPES_ROOT_DIR = TYPES_ROOT_DIR;
8
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../../src/generators/constants.ts"],"sourcesContent":["export const TYPES_ROOT_DIR = 'types';\nexport const GENERATED_OUT_DIR = 'generated';\n"],"names":["TYPES_ROOT_DIR","GENERATED_OUT_DIR"],"mappings":";;AAAO,MAAMA,iBAAiB;AACvB,MAAMC,oBAAoB;;;;;"}
@@ -0,0 +1,5 @@
1
+ const TYPES_ROOT_DIR = 'types';
2
+ const GENERATED_OUT_DIR = 'generated';
3
+
4
+ export { GENERATED_OUT_DIR, TYPES_ROOT_DIR };
5
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sources":["../../src/generators/constants.ts"],"sourcesContent":["export const TYPES_ROOT_DIR = 'types';\nexport const GENERATED_OUT_DIR = 'generated';\n"],"names":["TYPES_ROOT_DIR","GENERATED_OUT_DIR"],"mappings":"AAAO,MAAMA,iBAAiB;AACvB,MAAMC,oBAAoB;;;;"}
@@ -0,0 +1,9 @@
1
+ import type { GeneratorOptions } from '../utils';
2
+ /**
3
+ * Generate type definitions for Strapi Content-Types
4
+ */
5
+ export declare const generateContentTypesDefinitions: (options?: GeneratorOptions) => Promise<{
6
+ output: string;
7
+ stats: {};
8
+ }>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generators/content-types/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AASjD;;GAEG;AACH,eAAO,MAAM,+BAA+B,GAC1C,UAAS,gBAAyC;;;EAmDnD,CAAC"}