@skmtc/core 0.0.381 → 0.0.383

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 (102) hide show
  1. package/esm/context/CoreContext.d.ts +2 -2
  2. package/esm/context/CoreContext.d.ts.map +1 -1
  3. package/esm/context/GenerateContext.d.ts +46 -14
  4. package/esm/context/GenerateContext.d.ts.map +1 -1
  5. package/esm/context/GenerateContext.js +187 -76
  6. package/esm/context/RenderContext.d.ts +3 -3
  7. package/esm/context/RenderContext.d.ts.map +1 -1
  8. package/esm/context/types.d.ts +2 -2
  9. package/esm/context/types.d.ts.map +1 -1
  10. package/esm/dsl/GatewayBase.d.ts +12 -0
  11. package/esm/dsl/GatewayBase.d.ts.map +1 -0
  12. package/esm/dsl/GatewayBase.js +13 -0
  13. package/esm/dsl/model/ModelBase.d.ts.map +1 -1
  14. package/esm/dsl/model/ModelBase.js +1 -1
  15. package/esm/dsl/model/ModelInsertable.d.ts +10 -5
  16. package/esm/dsl/model/ModelInsertable.d.ts.map +1 -1
  17. package/esm/dsl/model/toModelGateway.d.ts +30 -0
  18. package/esm/dsl/model/toModelGateway.d.ts.map +1 -0
  19. package/esm/dsl/model/toModelGateway.js +70 -0
  20. package/esm/dsl/model/toModelInsertable.d.ts +36 -0
  21. package/esm/dsl/model/toModelInsertable.d.ts.map +1 -0
  22. package/esm/dsl/model/{toModelBase.js → toModelInsertable.js} +3 -41
  23. package/esm/dsl/operation/OperationBase.d.ts.map +1 -1
  24. package/esm/dsl/operation/OperationBase.js +1 -1
  25. package/esm/dsl/operation/OperationInsertable.d.ts +17 -5
  26. package/esm/dsl/operation/OperationInsertable.d.ts.map +1 -1
  27. package/esm/dsl/operation/toOperationGateway.d.ts +32 -0
  28. package/esm/dsl/operation/toOperationGateway.d.ts.map +1 -0
  29. package/esm/dsl/operation/toOperationGateway.js +70 -0
  30. package/esm/dsl/operation/toOperationInsertable.d.ts +43 -0
  31. package/esm/dsl/operation/toOperationInsertable.d.ts.map +1 -0
  32. package/esm/dsl/operation/{toOperationBase.js → toOperationInsertable.js} +3 -41
  33. package/esm/helpers/ResultsLog.d.ts +2 -2
  34. package/esm/helpers/ResultsLog.d.ts.map +1 -1
  35. package/esm/helpers/ResultsLog.js +11 -3
  36. package/esm/mod.d.ts +4 -2
  37. package/esm/mod.d.ts.map +1 -1
  38. package/esm/mod.js +4 -2
  39. package/esm/types/Results.d.ts +3 -3
  40. package/esm/types/Results.d.ts.map +1 -1
  41. package/esm/types/Results.js +2 -2
  42. package/esm/types/Settings.d.ts +24 -12
  43. package/esm/types/Settings.d.ts.map +1 -1
  44. package/esm/types/Settings.js +4 -3
  45. package/package.json +1 -1
  46. package/script/context/CoreContext.d.ts +2 -2
  47. package/script/context/CoreContext.d.ts.map +1 -1
  48. package/script/context/GenerateContext.d.ts +46 -14
  49. package/script/context/GenerateContext.d.ts.map +1 -1
  50. package/script/context/GenerateContext.js +187 -76
  51. package/script/context/RenderContext.d.ts +3 -3
  52. package/script/context/RenderContext.d.ts.map +1 -1
  53. package/script/context/types.d.ts +2 -2
  54. package/script/context/types.d.ts.map +1 -1
  55. package/script/dsl/GatewayBase.d.ts +12 -0
  56. package/script/dsl/GatewayBase.d.ts.map +1 -0
  57. package/script/dsl/{GeneratorBase.js → GatewayBase.js} +6 -4
  58. package/script/dsl/model/ModelBase.d.ts.map +1 -1
  59. package/script/dsl/model/ModelBase.js +1 -1
  60. package/script/dsl/model/ModelInsertable.d.ts +10 -5
  61. package/script/dsl/model/ModelInsertable.d.ts.map +1 -1
  62. package/script/dsl/model/toModelGateway.d.ts +30 -0
  63. package/script/dsl/model/toModelGateway.d.ts.map +1 -0
  64. package/script/dsl/model/toModelGateway.js +74 -0
  65. package/script/dsl/model/toModelInsertable.d.ts +36 -0
  66. package/script/dsl/model/toModelInsertable.d.ts.map +1 -0
  67. package/script/dsl/model/{toModelBase.js → toModelInsertable.js} +5 -43
  68. package/script/dsl/operation/OperationBase.d.ts.map +1 -1
  69. package/script/dsl/operation/OperationBase.js +1 -1
  70. package/script/dsl/operation/OperationInsertable.d.ts +17 -5
  71. package/script/dsl/operation/OperationInsertable.d.ts.map +1 -1
  72. package/script/dsl/operation/toOperationGateway.d.ts +32 -0
  73. package/script/dsl/operation/toOperationGateway.d.ts.map +1 -0
  74. package/script/dsl/operation/toOperationGateway.js +74 -0
  75. package/script/dsl/operation/toOperationInsertable.d.ts +43 -0
  76. package/script/dsl/operation/toOperationInsertable.d.ts.map +1 -0
  77. package/script/dsl/operation/{toOperationBase.js → toOperationInsertable.js} +5 -43
  78. package/script/helpers/ResultsLog.d.ts +2 -2
  79. package/script/helpers/ResultsLog.d.ts.map +1 -1
  80. package/script/helpers/ResultsLog.js +11 -3
  81. package/script/mod.d.ts +4 -2
  82. package/script/mod.d.ts.map +1 -1
  83. package/script/mod.js +4 -2
  84. package/script/types/Results.d.ts +3 -3
  85. package/script/types/Results.d.ts.map +1 -1
  86. package/script/types/Results.js +3 -3
  87. package/script/types/Settings.d.ts +24 -12
  88. package/script/types/Settings.d.ts.map +1 -1
  89. package/script/types/Settings.js +4 -3
  90. package/esm/dsl/GeneratorBase.d.ts +0 -6
  91. package/esm/dsl/GeneratorBase.d.ts.map +0 -1
  92. package/esm/dsl/GeneratorBase.js +0 -11
  93. package/esm/dsl/model/toModelBase.d.ts +0 -48
  94. package/esm/dsl/model/toModelBase.d.ts.map +0 -1
  95. package/esm/dsl/operation/toOperationBase.d.ts +0 -55
  96. package/esm/dsl/operation/toOperationBase.d.ts.map +0 -1
  97. package/script/dsl/GeneratorBase.d.ts +0 -6
  98. package/script/dsl/GeneratorBase.d.ts.map +0 -1
  99. package/script/dsl/model/toModelBase.d.ts +0 -48
  100. package/script/dsl/model/toModelBase.d.ts.map +0 -1
  101. package/script/dsl/operation/toOperationBase.d.ts +0 -55
  102. package/script/dsl/operation/toOperationBase.d.ts.map +0 -1
@@ -3,7 +3,7 @@ import type { OasDocument } from '../oas/document/Document.js';
3
3
  import type { ClientSettings } from '../types/Settings.js';
4
4
  import type { OperationGateway, OperationInsertable } from '../dsl/operation/OperationInsertable.js';
5
5
  import type { ModelGateway, ModelInsertable } from '../dsl/model/ModelInsertable.js';
6
- import type { SuccessWarningError } from '../types/Results.js';
6
+ import type { ResultType } from '../types/Results.js';
7
7
  import * as log from '../deps/jsr.io/@std/log/0.224.7/mod.js';
8
8
  import type { GeneratorKey } from '../types/GeneratorKeys.js';
9
9
  import type { GeneratedValue } from '../types/GeneratedValue.js';
@@ -29,7 +29,7 @@ export declare class CoreContext {
29
29
  artifacts: Record<string, string>;
30
30
  };
31
31
  trace<T>(token: string | string[], fn: () => T): T;
32
- captureCurrentResult(result: SuccessWarningError): void;
32
+ captureCurrentResult(result: ResultType): void;
33
33
  }
34
34
  export type JsonFormatterArgs = {
35
35
  logRecord: log.LogRecord;
@@ -1 +1 @@
1
- {"version":3,"file":"CoreContext.d.ts","sourceRoot":"","sources":["../../src/context/CoreContext.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AACpG,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACpF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,GAAG,MAAM,wCAAwC,CAAA;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAI7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AA0BhE,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,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MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,cAAc,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,MAAM,CAQnF"}
@@ -4,7 +4,7 @@ import type { OasDocument } from '../oas/document/Document.js';
4
4
  import type { OasSchema } from '../oas/schema/Schema.js';
5
5
  import type { OasRef } from '../oas/ref/Ref.js';
6
6
  import type { FileContents } from './types.js';
7
- import type { BaseSettings, ClientSettings } from '../types/Settings.js';
7
+ import type { ClientSettings } from '../types/Settings.js';
8
8
  import type { Method } from '../types/Method.js';
9
9
  import type { OperationInsertable, OperationGateway } from '../dsl/operation/OperationInsertable.js';
10
10
  import type { OasOperation } from '../oas/operation/Operation.js';
@@ -14,7 +14,7 @@ import { ContentSettings } from '../dsl/ContentSettings.js';
14
14
  import type { RefName } from '../types/RefName.js';
15
15
  import type * as log from '../deps/jsr.io/@std/log/0.224.7/mod.js';
16
16
  import type { GeneratorKey } from '../types/GeneratorKeys.js';
17
- import type { SuccessWarningError } from '../types/Results.js';
17
+ import type { ResultType } from '../types/Results.js';
18
18
  import type { StackTrail } from './StackTrail.js';
19
19
  import type { Identifier } from '../dsl/Identifier.js';
20
20
  import type { SchemaToValueFn, SchemaType, TypeSystemOutput } from '../types/TypeSystem.js';
@@ -25,7 +25,7 @@ type ConstructorArgs = {
25
25
  logger: log.Logger;
26
26
  callback: (generatorKey: GeneratorKey) => void;
27
27
  stackTrail: StackTrail;
28
- captureCurrentResult: (result: SuccessWarningError) => void;
28
+ captureCurrentResult: (result: ResultType) => void;
29
29
  };
30
30
  export type PickArgs = {
31
31
  name: string;
@@ -42,6 +42,11 @@ export type CreateAndRegisterDefinition<Schema extends SchemaType> = {
42
42
  destinationPath: string;
43
43
  schemaToValueFn: SchemaToValueFn;
44
44
  };
45
+ export type DefineAndRegisterArgs<V extends GeneratedValue> = {
46
+ identifier: Identifier;
47
+ value: V;
48
+ destinationPath: string;
49
+ };
45
50
  export type GetOperationSettingsArgs = {
46
51
  generatorId: string;
47
52
  path: string;
@@ -56,12 +61,13 @@ export type GetModelSettingsArgs = {
56
61
  generatorId: string;
57
62
  refName: RefName;
58
63
  };
59
- export type InsertArgs<V extends GeneratedValue, T extends GenerationType> = {
64
+ export type InsertOperationArgs<V extends GeneratedValue, T extends GenerationType> = {
60
65
  insertable: OperationInsertable<V>;
61
66
  operation: OasOperation;
62
67
  generation?: T;
63
68
  destinationPath?: string;
64
- } | {
69
+ };
70
+ export type InsertModelArgs<V extends GeneratedValue, T extends GenerationType> = {
65
71
  insertable: ModelInsertable<V>;
66
72
  refName: RefName;
67
73
  generation?: T;
@@ -82,7 +88,7 @@ export declare class GenerateContext {
82
88
  settings: ClientSettings | undefined;
83
89
  logger: log.Logger;
84
90
  callback: (generatorKey: GeneratorKey) => void;
85
- captureCurrentResult: (result: SuccessWarningError) => void;
91
+ captureCurrentResult: (result: ResultType) => void;
86
92
  constructor({ oasDocument, settings, logger, callback, captureCurrentResult, stackTrail }: ConstructorArgs);
87
93
  /**
88
94
  * @internal
@@ -96,6 +102,8 @@ export declare class GenerateContext {
96
102
  * If a definition with the same name already exists, it will be returned
97
103
  * instead of creating a new one.
98
104
  *
105
+ * @experimental
106
+ *
99
107
  * @param schema - The schema to create the definition for.
100
108
  * @param identifier - The identifier for the definition.
101
109
  * @param destinationPath - The path to the file where the definition will be registered.
@@ -103,6 +111,12 @@ export declare class GenerateContext {
103
111
  * @returns The created definition or cached definition if it already exists.
104
112
  */
105
113
  createAndRegisterDefinition<Schema extends SchemaType>({ schema, identifier, destinationPath, schemaToValueFn }: CreateAndRegisterDefinition<Schema>): Definition<TypeSystemOutput<Schema['type']>>;
114
+ /**
115
+ * Create and register a definition with the given `identifier` at `destinationPath`.
116
+ *
117
+ * @experimental
118
+ */
119
+ defineAndRegister<V extends GeneratedValue>({ identifier, value, destinationPath }: DefineAndRegisterArgs<V>): Definition<V>;
106
120
  /**
107
121
  * Insert supplied `imports` and `definitions` into file at `destinationPath`.
108
122
  *
@@ -116,20 +130,35 @@ export declare class GenerateContext {
116
130
  */
117
131
  register({ imports, definitions, destinationPath }: RegisterArgs): void;
118
132
  /**
119
- * Insert operation or model into the output file with path `destinationPath`.
133
+ * Insert operation into the output file with path `destinationPath`.
120
134
  *
121
135
  * Insert will perform the following steps:
122
- * 1. Generate content settings for the supplied operation or model
136
+ * 1. Generate content settings for the supplied operation
123
137
  * 2. Look up definition in file with path `destinationPath`
124
138
  * 3. If definition is not found, it will create a new one and register it
125
139
  * 4. If the definition is defined at a location that is different from
126
140
  * the current file, it will add an import to the current file from
127
141
  * that location
128
- * 5. Use the content settings to generate the operation/model using the
142
+ * 5. Use the content settings to generate the operation using the
129
143
  * insertable's driver
130
144
  * @mutates this.files
131
145
  */
132
- insert<V extends GeneratedValue, T extends GenerationType>({ generation, destinationPath, ...rest }: InsertArgs<V, T>): Inserted<V, T>;
146
+ insertOperation<V extends GeneratedValue, T extends GenerationType>({ insertable, operation, generation, destinationPath }: InsertOperationArgs<V, T>): Inserted<V, T>;
147
+ /**
148
+ * Insert model into the output file with path `destinationPath`.
149
+ *
150
+ * Insert will perform the following steps:
151
+ * 1. Generate content settings for the supplied model
152
+ * 2. Look up definition in file with path `destinationPath`
153
+ * 3. If definition is not found, it will create a new one and register it
154
+ * 4. If the definition is defined at a location that is different from
155
+ * the current file, it will add an import to the current file from
156
+ * that location
157
+ * 5. Use the content settings to generate the model using the
158
+ * insertable's driver
159
+ * @mutates this.files
160
+ */
161
+ insertModel<V extends GeneratedValue, T extends GenerationType>({ insertable, refName, generation, destinationPath }: InsertModelArgs<V, T>): Inserted<V, T>;
133
162
  /**
134
163
  * Generate and return content settings for operation insertable and
135
164
  * operation.
@@ -152,11 +181,14 @@ export declare class GenerateContext {
152
181
  */
153
182
  toModelContentSettings<V>({ refName, insertable }: BuildModelSettingsArgs<V>): ContentSettings;
154
183
  /**
155
- * Look up operation settings for a given generatorId, path and method.
156
- * @param { generatorId, path, method }
157
- * @returns Base settings for operation
184
+ * Generate and return content settings for a gateway
185
+ *
186
+ * Content settings are produced by passing base settings
187
+ * through toIdentifier, toExportPath methods on the gateway
188
+ * @param gateway
189
+ * @returns Content settings for model
158
190
  */
159
- toOperationBaseSettings({ generatorId, path, method }: GetOperationSettingsArgs): BaseSettings;
191
+ toGatewayContentSetting(gateway: OperationGateway | ModelGateway): ContentSettings;
160
192
  /**
161
193
  * Perform one lookup of schema by `refName`.
162
194
  * @param refName
@@ -1 +1 @@
1
- {"version":3,"file":"GenerateContext.d.ts","sourceRoot":"","sources":["../../src/context/GenerateContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,YAAY,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AACpG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAGpF,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,KAAK,KAAK,GAAG,MAAM,wC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this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_stackTrail, _GenerateContext_runOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_getFile, _GenerateContext_toModelBaseSettings, _GenerateContext_addFile;
12
+ var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_stackTrail, _GenerateContext_runOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_getFile, _GenerateContext_toOperationBaseSettings, _GenerateContext_toGatewayBaseSettings, _GenerateContext_toModelBaseSettings, _GenerateContext_cleanBaseSettings, _GenerateContext_addFile;
13
13
  import { join, normalize } from '../deps/jsr.io/@std/path/1.0.0/mod.js';
14
14
  import { Import } from '../dsl/Import.js';
15
15
  import { Definition } from '../dsl/Definition.js';
@@ -19,7 +19,6 @@ import { ContentSettings } from '../dsl/ContentSettings.js';
19
19
  import * as Sentry from '@sentry/deno';
20
20
  import { tracer } from '../helpers/tracer.js';
21
21
  import { Inserted } from '../dsl/Inserted.js';
22
- import { match, P } from 'ts-pattern';
23
22
  export class GenerateContext {
24
23
  constructor({ oasDocument, settings, logger, callback, captureCurrentResult, stackTrail }) {
25
24
  _GenerateContext_instances.add(this);
@@ -99,6 +98,8 @@ export class GenerateContext {
99
98
  * If a definition with the same name already exists, it will be returned
100
99
  * instead of creating a new one.
101
100
  *
101
+ * @experimental
102
+ *
102
103
  * @param schema - The schema to create the definition for.
103
104
  * @param identifier - The identifier for the definition.
104
105
  * @param destinationPath - The path to the file where the definition will be registered.
@@ -121,16 +122,40 @@ export class GenerateContext {
121
122
  destinationPath,
122
123
  required: true
123
124
  });
124
- const responseDefinition = new Definition({
125
+ return this.defineAndRegister({
126
+ identifier,
127
+ value,
128
+ destinationPath
129
+ });
130
+ }
131
+ /**
132
+ * Create and register a definition with the given `identifier` at `destinationPath`.
133
+ *
134
+ * @experimental
135
+ */
136
+ defineAndRegister({ identifier, value, destinationPath }) {
137
+ // @TODO cache check is duplicatd if call comes from
138
+ // createAndRegisterDefinition. Look for a way to share code between
139
+ // these two functions
140
+ const cachedDefinition = this.findDefinition({
141
+ name: identifier.name,
142
+ exportPath: destinationPath
143
+ });
144
+ // @TODO add check to make sure retrieved definition
145
+ // used same generator and same schema #SKM-47
146
+ if (cachedDefinition) {
147
+ return cachedDefinition;
148
+ }
149
+ const definition = new Definition({
125
150
  context: this,
126
151
  identifier,
127
152
  value
128
153
  });
129
154
  this.register({
130
- definitions: [responseDefinition],
155
+ definitions: [definition],
131
156
  destinationPath
132
157
  });
133
- return responseDefinition;
158
+ return definition;
134
159
  }
135
160
  /**
136
161
  * Insert supplied `imports` and `definitions` into file at `destinationPath`.
@@ -167,40 +192,51 @@ export class GenerateContext {
167
192
  });
168
193
  }
169
194
  /**
170
- * Insert operation or model into the output file with path `destinationPath`.
195
+ * Insert operation into the output file with path `destinationPath`.
171
196
  *
172
197
  * Insert will perform the following steps:
173
- * 1. Generate content settings for the supplied operation or model
198
+ * 1. Generate content settings for the supplied operation
174
199
  * 2. Look up definition in file with path `destinationPath`
175
200
  * 3. If definition is not found, it will create a new one and register it
176
201
  * 4. If the definition is defined at a location that is different from
177
202
  * the current file, it will add an import to the current file from
178
203
  * that location
179
- * 5. Use the content settings to generate the operation/model using the
204
+ * 5. Use the content settings to generate the operation using the
180
205
  * insertable's driver
181
206
  * @mutates this.files
182
207
  */
183
- insert({ generation, destinationPath, ...rest }) {
184
- const { settings, definition } = match(rest)
185
- .with({ operation: P.nonNullable }, ({ insertable, operation }) => {
186
- return new OperationDriver({
187
- context: this,
188
- insertable,
189
- operation,
190
- generation,
191
- destinationPath
192
- });
193
- })
194
- .with({ refName: P.nonNullable }, ({ insertable, refName }) => {
195
- return new ModelDriver({
196
- context: this,
197
- insertable,
198
- refName,
199
- generation,
200
- destinationPath
201
- });
202
- })
203
- .exhaustive();
208
+ insertOperation({ insertable, operation, generation, destinationPath }) {
209
+ const { settings, definition } = new OperationDriver({
210
+ context: this,
211
+ insertable,
212
+ operation,
213
+ generation,
214
+ destinationPath
215
+ });
216
+ return new Inserted({ settings, definition });
217
+ }
218
+ /**
219
+ * Insert model into the output file with path `destinationPath`.
220
+ *
221
+ * Insert will perform the following steps:
222
+ * 1. Generate content settings for the supplied model
223
+ * 2. Look up definition in file with path `destinationPath`
224
+ * 3. If definition is not found, it will create a new one and register it
225
+ * 4. If the definition is defined at a location that is different from
226
+ * the current file, it will add an import to the current file from
227
+ * that location
228
+ * 5. Use the content settings to generate the model using the
229
+ * insertable's driver
230
+ * @mutates this.files
231
+ */
232
+ insertModel({ insertable, refName, generation, destinationPath }) {
233
+ const { settings, definition } = new ModelDriver({
234
+ context: this,
235
+ insertable,
236
+ refName,
237
+ generation,
238
+ destinationPath
239
+ });
204
240
  return new Inserted({ settings, definition });
205
241
  }
206
242
  /**
@@ -214,17 +250,17 @@ export class GenerateContext {
214
250
  * @returns
215
251
  */
216
252
  toOperationContentSettings({ operation, insertable }) {
217
- const baseSettings = this.toOperationBaseSettings({
253
+ const baseSettings = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toOperationBaseSettings).call(this, {
218
254
  generatorId: insertable.id,
219
255
  path: operation.path,
220
256
  method: operation.method
221
257
  });
222
- const e = insertable.toExportPath({ operation, baseSettings });
258
+ const exportPath = insertable.toExportPath({ operation, baseSettings });
223
259
  return new ContentSettings({
224
260
  identifier: insertable.toIdentifier({ operation, baseSettings }),
225
261
  selected: insertable.isSelected({ operation, baseSettings }),
226
- exportPath: e,
227
- importFrom: baseSettings.importFrom ?? e
262
+ exportPath,
263
+ importFrom: baseSettings.importFrom ?? exportPath
228
264
  });
229
265
  }
230
266
  /**
@@ -241,34 +277,31 @@ export class GenerateContext {
241
277
  generatorId: insertable.id,
242
278
  refName
243
279
  });
244
- const e = insertable.toExportPath({ refName, baseSettings });
280
+ const exportPath = insertable.toExportPath({ refName, baseSettings });
245
281
  return new ContentSettings({
246
282
  identifier: insertable.toIdentifier({ refName, baseSettings }),
247
283
  selected: insertable.isSelected({ refName, baseSettings }),
248
- exportPath: e,
249
- importFrom: baseSettings.importFrom ?? e
284
+ exportPath,
285
+ importFrom: baseSettings.importFrom ?? exportPath
250
286
  });
251
287
  }
252
288
  /**
253
- * Look up operation settings for a given generatorId, path and method.
254
- * @param { generatorId, path, method }
255
- * @returns Base settings for operation
289
+ * Generate and return content settings for a gateway
290
+ *
291
+ * Content settings are produced by passing base settings
292
+ * through toIdentifier, toExportPath methods on the gateway
293
+ * @param gateway
294
+ * @returns Content settings for model
256
295
  */
257
- toOperationBaseSettings({ generatorId, path, method }) {
258
- const generatorSettings = this.settings?.generators?.find(({ id }) => id === generatorId);
259
- const operationSettings = generatorSettings && 'operations' in generatorSettings
260
- ? generatorSettings.operations?.[path]?.[method]
261
- : undefined;
262
- const exportPath = operationSettings?.exportPath
263
- ? join(generatorSettings?.exportPath ?? '', operationSettings?.exportPath)
264
- : undefined;
265
- const baseSettings = {
296
+ toGatewayContentSetting(gateway) {
297
+ const baseSettings = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toGatewayBaseSettings).call(this, gateway.id);
298
+ const exportPath = gateway.toExportPath(baseSettings);
299
+ return new ContentSettings({
300
+ identifier: gateway.toIdentifier(baseSettings),
301
+ selected: gateway.isGeneratorSelected(baseSettings),
266
302
  exportPath,
267
- selected: Boolean(operationSettings?.selected),
268
- name: operationSettings?.name,
269
- importFrom: operationSettings?.importFrom
270
- };
271
- return baseSettings;
303
+ importFrom: baseSettings.importFrom ?? exportPath
304
+ });
272
305
  }
273
306
  /**
274
307
  * Perform one lookup of schema by `refName`.
@@ -296,8 +329,12 @@ export class GenerateContext {
296
329
  }
297
330
  _GenerateContext_files = new WeakMap(), _GenerateContext_stackTrail = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_runOperationGenerator = function _GenerateContext_runOperationGenerator({ oasDocument, generator }) {
298
331
  if (generator._class === 'OperationGateway') {
299
- const generatorInstance = new generator(this);
300
- return oasDocument.operations.forEach(operation => {
332
+ const gatewaySettings = this.toGatewayContentSetting(generator);
333
+ const gatewayInstance = new generator({
334
+ context: this,
335
+ settings: gatewaySettings
336
+ });
337
+ oasDocument.operations.forEach(operation => {
301
338
  // TODO If we make OasOperation generic, for example by
302
339
  // adding a `method` type, we could make isSupported
303
340
  // a type guard which could help us narrow down the
@@ -306,12 +343,26 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_stackTrail = new WeakMa
306
343
  // in the generator implementations
307
344
  // https://linear.app/skmtc/issue/SKM-32/generic-models-operations
308
345
  const { path, method } = operation;
309
- if (generator.isSupported(operation)) {
310
- this.trace([path, method], () => {
311
- generatorInstance.transformOperation(operation);
312
- this.captureCurrentResult('success');
346
+ this.trace([path, method], () => {
347
+ if (!generator.isSupported(operation)) {
348
+ return this.captureCurrentResult('notSupported');
349
+ }
350
+ const baseSettings = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toOperationBaseSettings).call(this, {
351
+ generatorId: generator.id,
352
+ path,
353
+ method
313
354
  });
314
- }
355
+ if (!generator.isOperationSelected({ operation, baseSettings })) {
356
+ return this.captureCurrentResult('notSelected');
357
+ }
358
+ gatewayInstance.transformOperation(operation);
359
+ this.captureCurrentResult('success');
360
+ });
361
+ });
362
+ return this.defineAndRegister({
363
+ identifier: gatewaySettings.identifier,
364
+ value: gatewayInstance,
365
+ destinationPath: gatewaySettings.exportPath
315
366
  });
316
367
  }
317
368
  if (generator._class === 'OperationInsertable') {
@@ -324,31 +375,72 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_stackTrail = new WeakMa
324
375
  // in the generator implementations
325
376
  // https://linear.app/skmtc/issue/SKM-32/generic-models-operations
326
377
  const { path, method } = operation;
327
- if (generator.isSupported(operation)) {
328
- this.trace([path, method], () => {
329
- this.insert({ insertable: generator, operation });
330
- this.captureCurrentResult('success');
378
+ this.trace([path, method], () => {
379
+ if (!generator.isSupported(operation)) {
380
+ return this.captureCurrentResult('notSupported');
381
+ }
382
+ const baseSettings = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toOperationBaseSettings).call(this, {
383
+ generatorId: generator.id,
384
+ path,
385
+ method
331
386
  });
332
- }
387
+ if (!generator.isSelected({ operation, baseSettings })) {
388
+ return this.captureCurrentResult('notSelected');
389
+ }
390
+ this.insertOperation({ insertable: generator, operation });
391
+ this.captureCurrentResult('success');
392
+ });
333
393
  });
334
394
  }
335
395
  throw new Error(`Unknown generator type`);
336
396
  }, _GenerateContext_runModelGenerator = function _GenerateContext_runModelGenerator({ oasDocument, generator }) {
337
397
  if (generator._class === 'ModelGateway') {
338
- const generatorInstance = new generator(this);
398
+ const gatewaySettings = this.toGatewayContentSetting(generator);
399
+ if (!gatewaySettings.selected) {
400
+ return this.captureCurrentResult('notSelected');
401
+ }
402
+ const gatewayInstance = new generator({
403
+ context: this,
404
+ settings: gatewaySettings
405
+ });
339
406
  const refNames = oasDocument.components?.toSchemasRefNames() ?? [];
340
- return refNames.forEach(refName => {
407
+ refNames.forEach(refName => {
341
408
  this.trace(refName, () => {
342
- generatorInstance.transformModel(refName);
409
+ if (!generator.isSupported()) {
410
+ return this.captureCurrentResult('notSupported');
411
+ }
412
+ const baseSettings = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toModelBaseSettings).call(this, {
413
+ generatorId: generator.id,
414
+ refName
415
+ });
416
+ if (!generator.isModelSelected({ refName, baseSettings })) {
417
+ return this.captureCurrentResult('notSelected');
418
+ }
419
+ gatewayInstance.transformModel(refName);
343
420
  this.captureCurrentResult('success');
344
421
  });
345
422
  });
423
+ return this.defineAndRegister({
424
+ identifier: gatewaySettings.identifier,
425
+ value: gatewayInstance,
426
+ destinationPath: gatewaySettings.exportPath
427
+ });
346
428
  }
347
429
  if (generator._class === 'ModelInsertable') {
348
430
  const refNames = oasDocument.components?.toSchemasRefNames() ?? [];
349
431
  return refNames.forEach(refName => {
350
432
  this.trace(refName, () => {
351
- this.insert({ insertable: generator, refName });
433
+ if (!generator.isSupported()) {
434
+ return this.captureCurrentResult('notSupported');
435
+ }
436
+ const baseSettings = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toModelBaseSettings).call(this, {
437
+ generatorId: generator.id,
438
+ refName
439
+ });
440
+ if (!generator.isSelected({ refName, baseSettings })) {
441
+ return this.captureCurrentResult('notSelected');
442
+ }
443
+ this.insertModel({ insertable: generator, refName });
352
444
  this.captureCurrentResult('success');
353
445
  });
354
446
  });
@@ -365,21 +457,40 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_stackTrail = new WeakMa
365
457
  }
366
458
  }
367
459
  return currentFile;
460
+ }, _GenerateContext_toOperationBaseSettings = function _GenerateContext_toOperationBaseSettings({ generatorId, path, method }) {
461
+ const generatorSettings = this.settings?.generators?.find(({ id }) => id === generatorId);
462
+ const operationSettings = generatorSettings && 'operations' in generatorSettings
463
+ ? generatorSettings.operations?.[path]?.[method]
464
+ : undefined;
465
+ const exportPath = operationSettings?.exportPath
466
+ ? join(generatorSettings?.baseSettings.exportPath ?? '', operationSettings?.exportPath)
467
+ : undefined;
468
+ return __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_cleanBaseSettings).call(this, {
469
+ ...operationSettings,
470
+ exportPath
471
+ });
472
+ }, _GenerateContext_toGatewayBaseSettings = function _GenerateContext_toGatewayBaseSettings(generatorId) {
473
+ const generatorSettings = this.settings?.generators?.find(({ id }) => id === generatorId);
474
+ return __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_cleanBaseSettings).call(this, generatorSettings?.baseSettings);
368
475
  }, _GenerateContext_toModelBaseSettings = function _GenerateContext_toModelBaseSettings({ generatorId, refName }) {
369
476
  const generatorSettings = this.settings?.generators?.find(({ id }) => id === generatorId);
370
477
  const modelSettings = generatorSettings && 'models' in generatorSettings
371
478
  ? generatorSettings?.models?.[refName]
372
479
  : undefined;
373
480
  const exportPath = modelSettings?.exportPath
374
- ? join(generatorSettings?.exportPath ?? '', modelSettings?.exportPath)
481
+ ? join(generatorSettings?.baseSettings.exportPath ?? '', modelSettings?.exportPath)
375
482
  : undefined;
376
- const baseSettings = {
377
- exportPath,
378
- selected: Boolean(modelSettings?.selected),
379
- name: modelSettings?.name,
380
- importFrom: modelSettings?.importFrom
483
+ return __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_cleanBaseSettings).call(this, {
484
+ ...modelSettings,
485
+ exportPath
486
+ });
487
+ }, _GenerateContext_cleanBaseSettings = function _GenerateContext_cleanBaseSettings(baseSettings) {
488
+ return {
489
+ exportPath: baseSettings?.exportPath,
490
+ selected: Boolean(baseSettings?.selected),
491
+ name: baseSettings?.name,
492
+ importFrom: baseSettings?.importFrom
381
493
  };
382
- return baseSettings;
383
494
  }, _GenerateContext_addFile = function _GenerateContext_addFile(normalisedPath) {
384
495
  if (__classPrivateFieldGet(this, _GenerateContext_files, "f").has(normalisedPath)) {
385
496
  throw new Error(`File already exists: ${normalisedPath}`);
@@ -2,7 +2,7 @@ import type { PrettierConfigType } from '../types/prettierConfig.js';
2
2
  import type { AddGeneratorKeyArgs, FileContents, RenderResult } from './types.js';
3
3
  import type { Definition } from '../dsl/Definition.js';
4
4
  import type { PickArgs } from './GenerateContext.js';
5
- import type { SuccessWarningError } from '../types/Results.js';
5
+ import type { ResultType } from '../types/Results.js';
6
6
  import type { StackTrail } from './StackTrail.js';
7
7
  import type * as log from '../deps/jsr.io/@std/log/0.224.7/mod.js';
8
8
  type ConstructorArgs = {
@@ -12,7 +12,7 @@ type ConstructorArgs = {
12
12
  pinnableGenerators: string[];
13
13
  stackTrail: StackTrail;
14
14
  logger: log.Logger;
15
- captureCurrentResult: (result: SuccessWarningError) => void;
15
+ captureCurrentResult: (result: ResultType) => void;
16
16
  };
17
17
  export declare class RenderContext {
18
18
  #private;
@@ -22,7 +22,7 @@ export declare class RenderContext {
22
22
  currentDestinationPath: string | 'PRE_RENDER' | 'POST_RENDER';
23
23
  pinnableGenerators: string[];
24
24
  logger: log.Logger;
25
- captureCurrentResult: (result: SuccessWarningError) => void;
25
+ captureCurrentResult: (result: ResultType) => void;
26
26
  constructor({ files, prettier, basePath, pinnableGenerators, logger, stackTrail, captureCurrentResult }: ConstructorArgs);
27
27
  render(): Omit<RenderResult, 'results'>;
28
28
  private collate;
@@ -1 +1 @@
1
- {"version":3,"file":"RenderContext.d.ts","sourceRoot":"","sources":["../../src/context/RenderContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAGpE,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EAEZ,YAAY,EACb,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAGpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAG9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,KAAK,GAAG,MAAM,wCAAwC,CAAA;AAElE,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IAChC,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,kBAAkB,EAAE,MAAM,EAAE,CAAA;IAC5B,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAClB,oBAAoB,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAA;CAC5D,CAAA;AAYD,qBAAa,aAAa;;IACxB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY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U,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;CAG7D"}
@@ -1,7 +1,7 @@
1
1
  import type { Definition } from '../dsl/Definition.js';
2
2
  import type { GeneratorKey } from '../types/GeneratorKeys.js';
3
3
  import type { ManifestEntry } from '../types/Manifest.js';
4
- import type { SuccessWarningError } from '../types/Results.js';
4
+ import type { ResultType } from '../types/Results.js';
5
5
  export type PhaseType = 'parse' | 'generate' | 'render';
6
6
  export type FileContents = {
7
7
  imports: Map<string, Set<string>>;
@@ -23,6 +23,6 @@ export type RenderResult = {
23
23
  artifacts: Record<string, string>;
24
24
  files: Record<string, ManifestEntry>;
25
25
  pinnable: Partial<Record<GeneratorKey, string>>;
26
- results: Record<string, SuccessWarningError>;
26
+ results: Record<string, ResultType>;
27
27
  };
28
28
  //# sourceMappingURL=types.d.ts.map