@ama-sdk/schematics 0.0.0-placeholder

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 (144) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +72 -0
  3. package/collection.json +42 -0
  4. package/package.json +148 -0
  5. package/schematics/api-extension/index.d.ts +9 -0
  6. package/schematics/api-extension/index.d.ts.map +1 -0
  7. package/schematics/api-extension/index.js +21 -0
  8. package/schematics/api-extension/index.js.map +1 -0
  9. package/schematics/api-extension/schema.d.ts +10 -0
  10. package/schematics/api-extension/schema.d.ts.map +1 -0
  11. package/schematics/api-extension/schema.js +3 -0
  12. package/schematics/api-extension/schema.js.map +1 -0
  13. package/schematics/api-extension/schema.json +37 -0
  14. package/schematics/api-extension/templates/.gitignore.template +38 -0
  15. package/schematics/api-extension/templates/.npmrc.template +4 -0
  16. package/schematics/api-extension/templates/package.json.template +16 -0
  17. package/schematics/api-extension/templates/src/API_swagger_template.yaml +269 -0
  18. package/schematics/api-extension/templates/src/definitions/__name__ExampleReply.yaml +20 -0
  19. package/schematics/api-extension/templates/src/generate.config.json +10 -0
  20. package/schematics/api-extension/templates/src/override/.gitkeep +0 -0
  21. package/schematics/api-extension/templates/src/products/Additional Products.yaml +25 -0
  22. package/schematics/helpers/execute-jars.d.ts +14 -0
  23. package/schematics/helpers/execute-jars.d.ts.map +1 -0
  24. package/schematics/helpers/execute-jars.js +62 -0
  25. package/schematics/helpers/execute-jars.js.map +1 -0
  26. package/schematics/helpers/generator-java.task.d.ts +59 -0
  27. package/schematics/helpers/generator-java.task.d.ts.map +1 -0
  28. package/schematics/helpers/generator-java.task.js +83 -0
  29. package/schematics/helpers/generator-java.task.js.map +1 -0
  30. package/schematics/helpers/read-package.d.ts +4 -0
  31. package/schematics/helpers/read-package.d.ts.map +1 -0
  32. package/schematics/helpers/read-package.js +12 -0
  33. package/schematics/helpers/read-package.js.map +1 -0
  34. package/schematics/helpers/tree-glob.d.ts +9 -0
  35. package/schematics/helpers/tree-glob.d.ts.map +1 -0
  36. package/schematics/helpers/tree-glob.js +27 -0
  37. package/schematics/helpers/tree-glob.js.map +1 -0
  38. package/schematics/java/client-core/index.d.ts +9 -0
  39. package/schematics/java/client-core/index.d.ts.map +1 -0
  40. package/schematics/java/client-core/index.js +74 -0
  41. package/schematics/java/client-core/index.js.map +1 -0
  42. package/schematics/java/client-core/schema.d.ts +8 -0
  43. package/schematics/java/client-core/schema.d.ts.map +1 -0
  44. package/schematics/java/client-core/schema.js +3 -0
  45. package/schematics/java/client-core/schema.js.map +1 -0
  46. package/schematics/java/client-core/schema.json +26 -0
  47. package/schematics/ng-add/index.d.ts +15 -0
  48. package/schematics/ng-add/index.d.ts.map +1 -0
  49. package/schematics/ng-add/index.js +106 -0
  50. package/schematics/ng-add/index.js.map +1 -0
  51. package/schematics/ng-add/schema.d.ts +6 -0
  52. package/schematics/ng-add/schema.d.ts.map +1 -0
  53. package/schematics/ng-add/schema.js +3 -0
  54. package/schematics/ng-add/schema.js.map +1 -0
  55. package/schematics/ng-add/schema.json +18 -0
  56. package/schematics/resources/swagger-codegen-cli.jar +0 -0
  57. package/schematics/typescript/core/index.d.ts +9 -0
  58. package/schematics/typescript/core/index.d.ts.map +1 -0
  59. package/schematics/typescript/core/index.js +109 -0
  60. package/schematics/typescript/core/index.js.map +1 -0
  61. package/schematics/typescript/core/schema.d.ts +6 -0
  62. package/schematics/typescript/core/schema.d.ts.map +1 -0
  63. package/schematics/typescript/core/schema.js +3 -0
  64. package/schematics/typescript/core/schema.js.map +1 -0
  65. package/schematics/typescript/core/schema.json +21 -0
  66. package/schematics/typescript/core/templates/src/spec/operation-adapter.ts.template +5 -0
  67. package/schematics/typescript/create/index.d.ts +9 -0
  68. package/schematics/typescript/create/index.d.ts.map +1 -0
  69. package/schematics/typescript/create/index.js +17 -0
  70. package/schematics/typescript/create/index.js.map +1 -0
  71. package/schematics/typescript/create/schema.d.ts +5 -0
  72. package/schematics/typescript/create/schema.d.ts.map +1 -0
  73. package/schematics/typescript/create/schema.js +3 -0
  74. package/schematics/typescript/create/schema.js.map +1 -0
  75. package/schematics/typescript/create/schema.json +40 -0
  76. package/schematics/typescript/mock/index.d.ts +15 -0
  77. package/schematics/typescript/mock/index.d.ts.map +1 -0
  78. package/schematics/typescript/mock/index.js +84 -0
  79. package/schematics/typescript/mock/index.js.map +1 -0
  80. package/schematics/typescript/mock/schema.d.ts +12 -0
  81. package/schematics/typescript/mock/schema.d.ts.map +1 -0
  82. package/schematics/typescript/mock/schema.js +3 -0
  83. package/schematics/typescript/mock/schema.js.map +1 -0
  84. package/schematics/typescript/mock/schema.json +42 -0
  85. package/schematics/typescript/mock/templates/__dasherizeModelName__.mock.ts +85 -0
  86. package/schematics/typescript/mock/templates/__dasherizeModelName__.spec.ts +51 -0
  87. package/schematics/typescript/mock/templates/index.ts +1 -0
  88. package/schematics/typescript/shell/index.d.ts +7 -0
  89. package/schematics/typescript/shell/index.d.ts.map +1 -0
  90. package/schematics/typescript/shell/index.js +54 -0
  91. package/schematics/typescript/shell/index.js.map +1 -0
  92. package/schematics/typescript/shell/schema.d.ts +10 -0
  93. package/schematics/typescript/shell/schema.d.ts.map +1 -0
  94. package/schematics/typescript/shell/schema.js +3 -0
  95. package/schematics/typescript/shell/schema.js.map +1 -0
  96. package/schematics/typescript/shell/schema.json +30 -0
  97. package/schematics/typescript/shell/templates/base/.commitlintrc.json +37 -0
  98. package/schematics/typescript/shell/templates/base/.editorconfig +13 -0
  99. package/schematics/typescript/shell/templates/base/.eslintignore +9 -0
  100. package/schematics/typescript/shell/templates/base/.eslintrc.js +46 -0
  101. package/schematics/typescript/shell/templates/base/.husky/commit-msg +4 -0
  102. package/schematics/typescript/shell/templates/base/.husky/pre-commit +4 -0
  103. package/schematics/typescript/shell/templates/base/.renovaterc.json +93 -0
  104. package/schematics/typescript/shell/templates/base/.swagger-codegen-ignore +1 -0
  105. package/schematics/typescript/shell/templates/base/.swcrc +16 -0
  106. package/schematics/typescript/shell/templates/base/.versionrc.json +9 -0
  107. package/schematics/typescript/shell/templates/base/.yarnrc.yml +6 -0
  108. package/schematics/typescript/shell/templates/base/CONTRIBUTING.md +4 -0
  109. package/schematics/typescript/shell/templates/base/configs/tsconfig.test.json +21 -0
  110. package/schematics/typescript/shell/templates/base/jest.config.js +23 -0
  111. package/schematics/typescript/shell/templates/base/package.json +119 -0
  112. package/schematics/typescript/shell/templates/base/readme.md +134 -0
  113. package/schematics/typescript/shell/templates/base/scripts/clear-index.js +30 -0
  114. package/schematics/typescript/shell/templates/base/scripts/files-pack.js +74 -0
  115. package/schematics/typescript/shell/templates/base/scripts/override-readme.js +15 -0
  116. package/schematics/typescript/shell/templates/base/scripts/restore-readme.js +14 -0
  117. package/schematics/typescript/shell/templates/base/src/fixtures/jest/index.ts +1 -0
  118. package/schematics/typescript/shell/templates/base/src/fixtures/jest/package.json +10 -0
  119. package/schematics/typescript/shell/templates/base/src/helpers/index.ts +1 -0
  120. package/schematics/typescript/shell/templates/base/src/helpers/package.json +10 -0
  121. package/schematics/typescript/shell/templates/base/src/index.ts +4 -0
  122. package/schematics/typescript/shell/templates/base/src/models/base/index.ts +0 -0
  123. package/schematics/typescript/shell/templates/base/src/models/core/enums.ts +2 -0
  124. package/schematics/typescript/shell/templates/base/src/models/core/index.ts +2 -0
  125. package/schematics/typescript/shell/templates/base/src/models/core/patterns.ts +2 -0
  126. package/schematics/typescript/shell/templates/base/src/models/custom/enums.ts +2 -0
  127. package/schematics/typescript/shell/templates/base/src/models/custom/index.ts +1 -0
  128. package/schematics/typescript/shell/templates/base/src/models/custom/patterns.ts +2 -0
  129. package/schematics/typescript/shell/templates/base/src/models/enums.ts +4 -0
  130. package/schematics/typescript/shell/templates/base/src/models/index.ts +6 -0
  131. package/schematics/typescript/shell/templates/base/src/models/patterns.ts +4 -0
  132. package/schematics/typescript/shell/templates/base/src/spec/index.ts +3 -0
  133. package/schematics/typescript/shell/templates/base/src/spec/mock-factory/index.ts +2 -0
  134. package/schematics/typescript/shell/templates/base/src/spec/package.json +10 -0
  135. package/schematics/typescript/shell/templates/base/testing/tsconfig.spec.json +24 -0
  136. package/schematics/typescript/shell/templates/base/tsconfig.build.json +44 -0
  137. package/schematics/typescript/shell/templates/base/tsconfig.doc.json +20 -0
  138. package/schematics/typescript/shell/templates/base/tsconfig.json +14 -0
  139. package/schematics/typescript/shell/templates/base/tsconfigs/esm2020/tsconfig.jest.json +16 -0
  140. package/schematics/typescript/shell/templates/base/tsconfigs/esm2020/tsconfig.json +10 -0
  141. package/schematics/typescript/shell/templates/base/tsconfigs/esm2020/tsconfig.source.json +11 -0
  142. package/schematics/typescript/shell/templates/base/tsconfigs/tsconfig.jest.json +20 -0
  143. package/schematics/typescript/shell/templates/base/tsconfigs/tsconfig.source.json +13 -0
  144. package/schematics/typescript/shell/templates/base/typedoc.json +12 -0
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ngGenerateMock = exports.getDasherizeModelName = void 0;
4
+ const core_1 = require("@angular-devkit/core");
5
+ const schematics_1 = require("@angular-devkit/schematics");
6
+ const path = require("node:path");
7
+ /**
8
+ * @param singular
9
+ * @param matches
10
+ * @param excludes
11
+ */
12
+ function endsWith(singular, matches, excludes = []) {
13
+ return matches.some((match) => singular.endsWith(match)
14
+ && excludes.every((exclude) => !singular.endsWith(exclude)));
15
+ }
16
+ /**
17
+ * @param singular
18
+ */
19
+ function plurialize(singular) {
20
+ // If the singular form is already pluralized do nothing
21
+ if (endsWith(singular, ['data', 'ies', 'es', 's'], ['us', 'ss'])) {
22
+ return singular;
23
+ }
24
+ else if (endsWith(singular, ['y'], ['ay', 'ey'])) {
25
+ return `${singular.substring(0, singular.length - 1)}ies`;
26
+ }
27
+ else if (endsWith(singular, ['us', 'ss', 'ch', 'sh'])) {
28
+ return `${singular}es`;
29
+ }
30
+ else {
31
+ return `${singular}s`;
32
+ }
33
+ }
34
+ /**
35
+ * returns the folder name
36
+ *
37
+ * @param modelName
38
+ */
39
+ function getDasherizeModelName(modelName) {
40
+ return core_1.strings.dasherize(modelName).replace(/\s/g, '');
41
+ }
42
+ exports.getDasherizeModelName = getDasherizeModelName;
43
+ /**
44
+ * Add mock
45
+ *
46
+ * @param options
47
+ */
48
+ function ngGenerateMock(options) {
49
+ const dasherizeModelName = getDasherizeModelName(options.apiModel);
50
+ const generateRootBarrel = (tree) => {
51
+ let currentComponentIndex = '';
52
+ const barrelPath = path.posix.join(options.path, 'index.ts');
53
+ if (tree.exists(barrelPath)) {
54
+ const currentServiceIndexBuffer = tree.read(barrelPath);
55
+ currentComponentIndex = currentServiceIndexBuffer ? currentServiceIndexBuffer.toString() : '';
56
+ if (!(new RegExp(`./${dasherizeModelName}/index`).test(currentComponentIndex))) {
57
+ currentComponentIndex = `export * from './${dasherizeModelName}/index';\n` + currentComponentIndex;
58
+ }
59
+ currentComponentIndex = `${currentComponentIndex.split('\n').filter((e) => !!e).sort().join('\n')}\n`;
60
+ tree.overwrite(barrelPath, currentComponentIndex);
61
+ }
62
+ return tree;
63
+ };
64
+ const generateFiles = (tree, context) => {
65
+ const mockDestination = path.posix.join(options.path, dasherizeModelName);
66
+ return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./templates'), [
67
+ (0, schematics_1.template)({
68
+ ...options,
69
+ identified: !!options.identified,
70
+ apiModels: plurialize(options.apiModel),
71
+ dasherizeModelName,
72
+ dasherizeAndCapitalizeModelName: dasherizeModelName.toUpperCase()
73
+ }),
74
+ (0, schematics_1.move)(mockDestination)
75
+ ]), schematics_1.MergeStrategy.Overwrite)(tree, context);
76
+ };
77
+ const rules = [
78
+ generateRootBarrel,
79
+ generateFiles
80
+ ];
81
+ return (0, schematics_1.chain)(rules);
82
+ }
83
+ exports.ngGenerateMock = ngGenerateMock;
84
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/typescript/mock/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C,IAAA,gBAAG,EAAC,aAAa,CAAC,EAAE;YACzC,IAAA,qBAAQ,EAAC;gBACP,GAAG,OAAO;gBACV,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU;gBAChC,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC;gBACvC,kBAAkB;gBAClB,+BAA+B,EAAE,kBAAkB,CAAC,WAAW,EAAE;aAClE,CAAC;YACF,IAAA,iBAAI,EAAC,eAAe,CAAC;SACtB,CAAC,EAAE,0BAAa,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE9C,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG;QACZ,kBAAkB;QAClB,aAAa;KACd,CAAC;IAEF,OAAO,IAAA,kBAAK,EAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAxCD,wCAwCC"}
@@ -0,0 +1,12 @@
1
+ import type { JsonObject } from '@angular-devkit/core';
2
+ export interface NgGenerateMockSchematicsSchema extends JsonObject {
3
+ /** Name of the api model to generate */
4
+ apiModel: string;
5
+ /** True if the api model has a property id */
6
+ identified: boolean;
7
+ /** Directory in which the mock-factory will be created */
8
+ path: string;
9
+ /** Package name of the sdk */
10
+ packageName: string;
11
+ }
12
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/mock/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAErD,MAAM,WAAW,8BAA+B,SAAQ,UAAU;IAChE,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IAEjB,8CAA8C;IAC9C,UAAU,EAAE,OAAO,CAAC;IAEpB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IAEb,8BAA8B;IAC9B,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../schematics/typescript/mock/schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "NgGenerateMockSchematicsSchema",
4
+ "title": "Generate Mock",
5
+ "description": "ng generate mock",
6
+ "properties": {
7
+ "apiModel": {
8
+ "type": "string",
9
+ "description": "Name of the api model to generate",
10
+ "x-prompt": "Your api model name",
11
+ "$default": {
12
+ "$source": "argv",
13
+ "index": 0
14
+ }
15
+ },
16
+ "identified": {
17
+ "type": "boolean",
18
+ "description": "True if the api model has a property id",
19
+ "x-prompt": "Does the model have an id ? ",
20
+ "$default": {
21
+ "$source": "argv",
22
+ "index": 1
23
+ }
24
+ },
25
+ "packageName": {
26
+ "type": "string",
27
+ "description": "Package name of the sdk",
28
+ "x-prompt": "Your sdk package name"
29
+ },
30
+ "path": {
31
+ "type": "string",
32
+ "description": "Directory in which the mock-factory will be created",
33
+ "x-prompt": "Destination path of the mock-factory ?"
34
+ }
35
+ },
36
+ "additionalProperties": true,
37
+ "required": [
38
+ "apiModel",
39
+ "path",
40
+ "packageName"
41
+ ]
42
+ }
@@ -0,0 +1,85 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ import {<%= apiModel %>} from '<%= packageName %>';
3
+
4
+ import {<% if (identified) { %>CombineConfig, <% } %>CombineResult, CreateInput, defaultCombine, <% if (identified) { %>generateId, IdentifiedResource, <% } %>Mock, RecursivePartial, Repository} from '../common';
5
+
6
+ //
7
+ // TEMPLATES
8
+ //
9
+
10
+ /** The known names of <%= apiModel %> templates */
11
+ export type <%= apiModel %>TemplateNames = 'DEFAULT'; // in case of more templates, please use the format 'NAME1' | 'NAME2';
12
+
13
+ /**
14
+ * An inventory of predefined <%= apiModel %> templates
15
+ */
16
+ export const <%= apiModel %>Templates: Record<<%= apiModel %>TemplateNames, RecursivePartial<<%= apiModel %>>> = {
17
+ DEFAULT: {}
18
+ };
19
+
20
+ /**
21
+ * The type of a mocked <%= apiModel %>
22
+ */
23
+ export type Mock<%= apiModel %> = Mock<<%= apiModel %>>;
24
+ // Add all optional properties of <%= apiModel %> that are defined in the create<%= apiModel %> method,
25
+ // so none of them are undefined in the result of the method
26
+ // Format: Mock<apiModel, 'propOne' | 'propTwo'>
27
+
28
+ //
29
+ // CREATE FACTORY
30
+ //
31
+
32
+ /**
33
+ * The create input for <%= apiModel %>
34
+ */
35
+ export interface Create<%= apiModel %>Input extends CreateInput<<%= apiModel %>><% if (identified) { %>, IdentifiedResource<% } %> {}
36
+
37
+ /**
38
+ * The create factory for <%= apiModel %>
39
+ * @param input configuration related to the creation
40
+ */
41
+ export function create<%= apiModel %>(input: Create<%= apiModel %>Input = {}): Mock<%= apiModel %> {
42
+ const template = input.template || <%= apiModel %>Templates.DEFAULT;
43
+ const mock = {
44
+ ...template<% if (identified) { %>,
45
+ id: generateId('<%= apiModel %>', template.id, input.id)<% } %>
46
+ } as Mock<%= apiModel %>;
47
+ return mock;
48
+ }
49
+
50
+
51
+ //
52
+ // REPOSITORY
53
+ //
54
+
55
+ /** The known names of <%= apiModel %>Repository items */
56
+ interface <%= apiModel %>RepositoryType extends Repository<Mock<%= apiModel %>> { // in case of more items, please include new properties in the interface
57
+ }
58
+
59
+ /**
60
+ * Repository containing predefined <%= apiModel %> mock items
61
+ */
62
+ export const <%= apiModel %>Repository: <%= apiModel %>RepositoryType = {
63
+ DEFAULT: create<%= apiModel %>()
64
+ };
65
+
66
+ //
67
+ // COMBINE FACTORY
68
+ //
69
+
70
+ /**
71
+ * The combine configuration for list of <%= apiModel %>
72
+ */
73
+ export interface Combine<%= apiModel %>Config <% if (identified) { %>extends CombineConfig <% } %>{}
74
+
75
+ /**
76
+ * The combine factory for list of <%= apiModel %>
77
+ * @param items the items to be combined
78
+ * @param config the combine configuration
79
+ */
80
+ export function combine<%= dapiModels %>(
81
+ items: RecursivePartial<<%= apiModel %>>[] = [<%= apiModel %>Repository.DEFAULT],
82
+ <% if (!identified) { %>_<% } %>config: Partial<Combine<%= apiModel %>Config> = {}
83
+ ): CombineResult<Mock<%= apiModel %>> {
84
+ return defaultCombine(items, create<%= apiModel %><% if (identified) { %>, config<% } %>);
85
+ }
@@ -0,0 +1,51 @@
1
+ import {combine<%= apiModels %>, create<%= apiModel %>, <%= apiModel %>Repository} from './<%= dasherizeModelName %>.mock';
2
+
3
+ describe('[MockFactory] <%= apiModel %>', () => {
4
+ describe('CreateFactory', () => {
5
+ it('should create a default object', () => {
6
+ const result = create<%= apiModel %>();
7
+
8
+ expect(result).toEqual(<%= apiModel %>Repository.DEFAULT);<% if (identified) { %>
9
+ expect(result.id).toBe('<%= dasherizeAndCapitalizeModelName %>-0-MOCK');<% } %>
10
+ });
11
+ });
12
+
13
+ describe('CombineFactory', () => {
14
+ it('should combine only the default object', () => {
15
+ const result = combine<%= apiModels %>();
16
+
17
+ expect(result.items.length).toBe(1);
18
+ expect(result.items).toEqual([<%= apiModel %>Repository.DEFAULT]);
19
+ });<% if (identified) { %>
20
+
21
+ let results: <%= apiModel %>[];
22
+ let lastId: number | undefined;
23
+
24
+ beforeAll(() => {
25
+ const combination = combine<%= apiModels %>([
26
+ <%= apiModel %>Repository.DEFAULT,
27
+ <%= apiModel %>Repository.DEFAULT,
28
+ <%= apiModel %>Repository.DEFAULT
29
+ ]);
30
+ results = combination.items;
31
+ lastId = combination.lastId;
32
+ });
33
+
34
+ it('should return the correct lastId', () => {
35
+ expect(lastId).toEqual(2);
36
+ });
37
+
38
+ it('should set the ids incrementally', () => {
39
+ expect(results[0].id).toEqual('<%= dasherizeAndCapitalizeModelName %>-0-MOCK');
40
+ expect(results[1].id).toEqual('<%= dasherizeAndCapitalizeModelName %>-1-MOCK');
41
+ expect(results[2].id).toEqual('<%= dasherizeAndCapitalizeModelName %>-2-MOCK');
42
+ });
43
+
44
+ it('should use lastId config', () => {
45
+ const {items, lastId: thisLastId} = combine<%= apiModels %>([<%= apiModel %>Repository.DEFAULT], {lastId: 100});
46
+
47
+ expect(items[0].id).toEqual('<%= dasherizeAndCapitalizeModelName %>-101-MOCK');
48
+ expect(thisLastId).toEqual(101);
49
+ });<% } %>
50
+ });
51
+ });
@@ -0,0 +1 @@
1
+ export * from './<%= dasherizeModelName %>.mock';
@@ -0,0 +1,7 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import type { NgGenerateTypescriptSDKShellSchematicsSchema } from './schema';
3
+ /**
4
+ * @param options
5
+ */
6
+ export declare function ngGenerateTypescriptSDK(options: NgGenerateTypescriptSDKShellSchematicsSchema): Rule;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/shell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,IAAI,EAIL,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,UAAU,CAAC;AAE7E;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,4CAA4C,GAAG,IAAI,CAgDnG"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ngGenerateTypescriptSDK = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const read_package_1 = require("../../helpers/read-package");
6
+ /**
7
+ * @param options
8
+ */
9
+ function ngGenerateTypescriptSDK(options) {
10
+ return async (tree) => {
11
+ const amaSdkSchematicsPackageJson = await (0, read_package_1.readPackageJson)();
12
+ /* eslint-disable @typescript-eslint/naming-convention */
13
+ const versions = {
14
+ 'tslib': amaSdkSchematicsPackageJson.dependencies.tslib,
15
+ '@types/jest': amaSdkSchematicsPackageJson.devDependencies['@types/jest'],
16
+ '@types/node': amaSdkSchematicsPackageJson.devDependencies['@types/node'],
17
+ '@typescript-eslint/eslint-plugin': amaSdkSchematicsPackageJson.devDependencies['@typescript-eslint/eslint-plugin'],
18
+ '@typescript-eslint/parser': amaSdkSchematicsPackageJson.devDependencies['@typescript-eslint/parser'],
19
+ 'eslint': amaSdkSchematicsPackageJson.devDependencies.eslint,
20
+ 'eslint-plugin-jest': amaSdkSchematicsPackageJson.devDependencies['eslint-plugin-jest'],
21
+ 'eslint-plugin-jsdoc': amaSdkSchematicsPackageJson.devDependencies['eslint-plugin-jsdoc'],
22
+ 'eslint-plugin-prefer-arrow': amaSdkSchematicsPackageJson.devDependencies['eslint-plugin-prefer-arrow'],
23
+ 'eslint-plugin-unicorn': amaSdkSchematicsPackageJson.devDependencies['eslint-plugin-unicorn'],
24
+ 'isomorphic-fetch': amaSdkSchematicsPackageJson.devDependencies['isomorphic-fetch'],
25
+ 'jest': amaSdkSchematicsPackageJson.devDependencies.jest,
26
+ 'ts-jest': amaSdkSchematicsPackageJson.devDependencies['ts-jest'],
27
+ 'typescript': amaSdkSchematicsPackageJson.devDependencies.typescript
28
+ };
29
+ const engineVersions = {
30
+ 'node': amaSdkSchematicsPackageJson.engines.node,
31
+ 'npm': amaSdkSchematicsPackageJson.engines.npm,
32
+ 'yarn': amaSdkSchematicsPackageJson.engines.yarn
33
+ };
34
+ const properties = {
35
+ projectName: options.name,
36
+ projectPackageName: options.package,
37
+ projectDescription: options.description,
38
+ projectHosting: options.hosting,
39
+ sdkCoreVersion: amaSdkSchematicsPackageJson.version,
40
+ angularVersion: amaSdkSchematicsPackageJson.dependencies['@angular-devkit/core'],
41
+ versions,
42
+ engineVersions,
43
+ empty: ''
44
+ };
45
+ const baseRule = (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./templates/base'), [
46
+ (0, schematics_1.template)(properties),
47
+ (0, schematics_1.move)(tree.root.path),
48
+ (0, schematics_1.renameTemplateFiles)()
49
+ ]), schematics_1.MergeStrategy.Overwrite);
50
+ return baseRule;
51
+ };
52
+ }
53
+ exports.ngGenerateTypescriptSDK = ngGenerateTypescriptSDK;
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/typescript/shell/index.ts"],"names":[],"mappings":";;;AAAA,2DAUoC;AACpC,6DAA6D;AAG7D;;GAEG;AACH,SAAgB,uBAAuB,CAAC,OAAqD;IAE3F,OAAO,KAAK,EAAE,IAAU,EAAE,EAAE;QAC1B,MAAM,2BAA2B,GAAG,MAAM,IAAA,8BAAe,GAAE,CAAC;QAE5D,yDAAyD;QACzD,MAAM,QAAQ,GAAG;YACf,OAAO,EAAE,2BAA2B,CAAC,YAAa,CAAC,KAAK;YACxD,aAAa,EAAE,2BAA2B,CAAC,eAAgB,CAAC,aAAa,CAAC;YAC1E,aAAa,EAAE,2BAA2B,CAAC,eAAgB,CAAC,aAAa,CAAC;YAC1E,kCAAkC,EAAE,2BAA2B,CAAC,eAAgB,CAAC,kCAAkC,CAAC;YACpH,2BAA2B,EAAE,2BAA2B,CAAC,eAAgB,CAAC,2BAA2B,CAAC;YACtG,QAAQ,EAAE,2BAA2B,CAAC,eAAgB,CAAC,MAAM;YAC7D,oBAAoB,EAAE,2BAA2B,CAAC,eAAgB,CAAC,oBAAoB,CAAC;YACxF,qBAAqB,EAAE,2BAA2B,CAAC,eAAgB,CAAC,qBAAqB,CAAC;YAC1F,4BAA4B,EAAE,2BAA2B,CAAC,eAAgB,CAAC,4BAA4B,CAAC;YACxG,uBAAuB,EAAE,2BAA2B,CAAC,eAAgB,CAAC,uBAAuB,CAAC;YAC9F,kBAAkB,EAAE,2BAA2B,CAAC,eAAgB,CAAC,kBAAkB,CAAC;YACpF,MAAM,EAAE,2BAA2B,CAAC,eAAgB,CAAC,IAAI;YACzD,SAAS,EAAE,2BAA2B,CAAC,eAAgB,CAAC,SAAS,CAAC;YAClE,YAAY,EAAE,2BAA2B,CAAC,eAAgB,CAAC,UAAU;SACtE,CAAC;QACF,MAAM,cAAc,GAAG;YACrB,MAAM,EAAE,2BAA2B,CAAC,OAAQ,CAAC,IAAI;YACjD,KAAK,EAAE,2BAA2B,CAAC,OAAQ,CAAC,GAAG;YAC/C,MAAM,EAAE,2BAA2B,CAAC,OAAQ,CAAC,IAAI;SAClD,CAAC;QAEF,MAAM,UAAU,GAAG;YACjB,WAAW,EAAE,OAAO,CAAC,IAAI;YACzB,kBAAkB,EAAE,OAAO,CAAC,OAAO;YACnC,kBAAkB,EAAE,OAAO,CAAC,WAAW;YACvC,cAAc,EAAE,OAAO,CAAC,OAAO;YAC/B,cAAc,EAAE,2BAA2B,CAAC,OAAO;YACnD,cAAc,EAAE,2BAA2B,CAAC,YAAa,CAAC,sBAAsB,CAAC;YACjF,QAAQ;YACR,cAAc;YACd,KAAK,EAAE,EAAE;SACV,CAAC;QAEF,MAAM,QAAQ,GAAG,IAAA,sBAAS,EAAC,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,kBAAkB,CAAC,EAAE;YACxD,IAAA,qBAAQ,EAAC,UAAU,CAAC;YACpB,IAAA,iBAAI,EAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YACpB,IAAA,gCAAmB,GAAE;SACtB,CAAC,EAAE,0BAAa,CAAC,SAAS,CAAC,CAAC;QAE7B,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC;AAhDD,0DAgDC"}
@@ -0,0 +1,10 @@
1
+ import type { JsonObject } from '@angular-devkit/core';
2
+ export interface NgGenerateTypescriptSDKShellSchematicsSchema extends JsonObject {
3
+ /** Project name (NPM package scope) */
4
+ name: string;
5
+ /** Package name */
6
+ package: string;
7
+ /** Project description */
8
+ description: string;
9
+ }
10
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/shell/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,4CAA6C,SAAQ,UAAU;IAC9E,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IAEb,mBAAmB;IACnB,OAAO,EAAE,MAAM,CAAC;IAEhB,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../schematics/typescript/shell/schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "NgGenerateTypescriptSDKSchematicsSchema",
4
+ "title": "Generate Typescript SDK",
5
+ "description": "ng generate typescript-shell",
6
+ "properties": {
7
+ "name": {
8
+ "type": "string",
9
+ "description": "Project name (NPM package scope)",
10
+ "x-prompt": "Project name (NPM package scope)?"
11
+ },
12
+ "package": {
13
+ "type": "string",
14
+ "description": "Package name",
15
+ "x-prompt": "Package name?",
16
+ "default": "sdk"
17
+ },
18
+ "description": {
19
+ "type": "string",
20
+ "alias": "package",
21
+ "description": "Project description",
22
+ "default": ""
23
+ }
24
+ },
25
+ "additionalProperties": true,
26
+ "required": [
27
+ "name",
28
+ "package"
29
+ ]
30
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "parserPreset": "@commitlint/config-conventional",
3
+ "rules": {
4
+ "body-leading-blank": [1,"always"],
5
+ "footer-leading-blank": [1, "always"],
6
+ "header-max-length": [2, "always", 72],
7
+ "scope-case": [2, "always", "lower-case"],
8
+ "subject-case": [2, "never",
9
+ [
10
+ "sentence-case",
11
+ "start-case",
12
+ "pascal-case",
13
+ "upper-case"
14
+ ]
15
+ ],
16
+ "subject-empty": [2, "never"],
17
+ "subject-full-stop": [2, "never", "."],
18
+ "type-case": [2, "always", "lower-case"],
19
+ "type-empty": [2, "never" ],
20
+ "type-enum": [2, "always",
21
+ [
22
+ "build",
23
+ "chore",
24
+ "ci",
25
+ "docs",
26
+ "feat",
27
+ "fix",
28
+ "improvement",
29
+ "perf",
30
+ "refactor",
31
+ "revert",
32
+ "style",
33
+ "test"
34
+ ]
35
+ ]
36
+ }
37
+ }
@@ -0,0 +1,13 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.md]
12
+ max_line_length = 0
13
+ trim_trailing_whitespace = false
@@ -0,0 +1,9 @@
1
+ /src/api
2
+ /src/models/base
3
+ /src/spec/api-mocks.ts
4
+ /src/spec/operation-adapter.ts
5
+ /dist
6
+ /build
7
+ /scripts
8
+ /jest.config.js
9
+ /.eslintrc.js
@@ -0,0 +1,46 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ /* eslint-disable quote-props */
3
+
4
+ module.exports = {
5
+ 'parser': require.resolve('@typescript-eslint/parser'),
6
+ 'parserOptions': {
7
+ 'tsconfigRootDir': __dirname,
8
+ 'project': [
9
+ 'testing/tsconfig.spec.json',
10
+ 'tsconfigs/tsconfig.jest.json',
11
+ 'tsconfigs/tsconfig.source.json'
12
+ ],
13
+ 'ecmaVersion': 12
14
+ },
15
+ 'env': {
16
+ 'browser': true,
17
+ 'node': true,
18
+ 'es6': true,
19
+ 'jest': true,
20
+ 'jest/globals': true
21
+ },
22
+ 'settings': {
23
+ 'import/resolver': 'node'
24
+ },
25
+ 'overrides': [
26
+ {
27
+ 'files': ['*.helper.ts'],
28
+ 'rules': {
29
+ '@typescript-eslint/explicit-function-return-type': 'error'
30
+ }
31
+ },
32
+ {
33
+ 'files': ['*.js'],
34
+ 'rules': {
35
+ '@typescript-eslint/restrict-template-expressions': 'off'
36
+ }
37
+ }
38
+ ],
39
+ 'plugins': [
40
+ 'jest'
41
+ ],
42
+ 'extends': [
43
+ '@o3r/eslint-config-otter'
44
+ ].map(require.resolve)
45
+ };
46
+
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ yarn commitlint --edit $1
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ yarn lint-staged
@@ -0,0 +1,93 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:base",
5
+ "group:allNonMajor",
6
+ "group:recommended",
7
+ "group:monorepos",
8
+ "group:test",
9
+ "group:linters"
10
+ ],
11
+ "prConcurrentLimit": 0,
12
+ "prHourlyLimit": 0,
13
+ "baseBranches": [
14
+ "master"
15
+ ],
16
+ "endpoint": "https://dev.azure.com/AmadeusDigitalAirline",
17
+ "platform": "azure",
18
+ "enabledManagers": [
19
+ "npm"
20
+ ],
21
+ "npm": {
22
+ "stabilityDays": 0
23
+ },
24
+ "labels": [
25
+ "upgrade"
26
+ ],
27
+ "updateInternalDeps": true,
28
+ "postUpdateOptions": [
29
+ "yarnDedupeHighest"
30
+ ],
31
+ "rangeStrategy": "replace",
32
+ "automerge": true,
33
+ "platformAutomerge": true,
34
+ "packageRules": [
35
+ {
36
+ "matchPackagePrefixes": [
37
+ "@my-api-scope",
38
+ "@ama-sdk/generator"
39
+ ],
40
+ "postUpgradeTasks": {
41
+ "commands": [
42
+ "yarn install",
43
+ "yarn run swagger:generate"
44
+ ],
45
+ "executionMode": "branch"
46
+ }
47
+ },
48
+ {
49
+ "matchPackagePrefixes": [
50
+ "@my-api-scope"
51
+ ],
52
+ "rangeStrategy": "bump",
53
+ "groupName": "Swagger Specification upgrade",
54
+ "groupSlug": "spec-upgrade"
55
+ },
56
+ {
57
+ "matchPackagePrefixes": [
58
+ "@my-api-scope"
59
+ ],
60
+ "matchBaseBranches": [
61
+ "/^release\/.*/"
62
+ ],
63
+ "rangeStrategy": "in-range-only"
64
+ },
65
+ {
66
+ "matchPackageNames": [
67
+ "@ama-sdk/core",
68
+ "@ama-sdk/generator-sdk"
69
+ ],
70
+ "rangeStrategy": "bump",
71
+ "groupName": "SDK Core and Generator dependencies",
72
+ "groupSlug": "sdk-core-dependencies"
73
+ },
74
+ {
75
+ "excludePackagePrefixes": [
76
+ "@my-api-scope"
77
+ ],
78
+ "matchBaseBranches": [
79
+ "/^release\/.*/"
80
+ ],
81
+ "enabled": false
82
+ },
83
+ {
84
+ "matchDepTypes": [
85
+ "peerDependencies"
86
+ ],
87
+ "matchUpdateTypes": [
88
+ "major"
89
+ ],
90
+ "enabled": false
91
+ }
92
+ ]
93
+ }
@@ -0,0 +1 @@
1
+ # Indicate the index.ts file you have override to redirect to custom interface definition