@skmtc/core 0.0.306 → 0.0.308
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/context/CoreContext.d.ts +3 -27
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +26 -201
- package/esm/context/GenerateContext.d.ts +12 -16
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +58 -70
- package/esm/context/ParseContext.d.ts +1 -2
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/ParseContext.js +18 -12
- package/esm/context/RenderContext.d.ts +7 -13
- package/esm/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +26 -46
- package/esm/context/ResultsHandler.d.ts.map +1 -1
- package/esm/context/ResultsHandler.js +0 -1
- package/esm/context/StackTrail.d.ts +1 -1
- package/esm/context/StackTrail.d.ts.map +1 -1
- package/esm/context/types.d.ts +0 -5
- package/esm/context/types.d.ts.map +1 -1
- package/esm/dsl/Definition.d.ts +2 -2
- package/esm/dsl/Definition.d.ts.map +1 -1
- package/esm/dsl/ModelDriver.d.ts +3 -3
- package/esm/dsl/ModelDriver.d.ts.map +1 -1
- package/esm/dsl/ModelInsertable.d.ts +3 -3
- package/esm/dsl/ModelInsertable.d.ts.map +1 -1
- package/esm/dsl/OperationDriver.d.ts +3 -3
- package/esm/dsl/OperationDriver.d.ts.map +1 -1
- package/esm/dsl/OperationInsertable.d.ts +3 -3
- package/esm/dsl/OperationInsertable.d.ts.map +1 -1
- package/esm/dsl/ValueBase.d.ts +3 -3
- package/esm/dsl/ValueBase.d.ts.map +1 -1
- package/esm/dsl/ValueBase.js +1 -3
- package/esm/dsl/base.d.ts +3 -4
- package/esm/dsl/base.d.ts.map +1 -1
- package/esm/dsl/withConfig.d.ts +7 -7
- package/esm/dsl/withConfig.d.ts.map +1 -1
- package/esm/generate/generate.d.ts +0 -1
- package/esm/generate/generate.d.ts.map +1 -1
- package/esm/generate/generate.js +6 -6
- package/esm/oas/parameter/toParameterV3.d.ts.map +1 -1
- package/esm/oas/parameter/toParameterV3.js +1 -0
- package/esm/server/createServer.d.ts.map +1 -1
- package/esm/server/createServer.js +3 -7
- package/esm/types/CustomValue.d.ts +2 -2
- package/esm/types/CustomValue.d.ts.map +1 -1
- package/esm/typescript/PathParams.d.ts +3 -3
- package/esm/typescript/PathParams.d.ts.map +1 -1
- package/esm/typescript/ReactRouterPathParams.d.ts +2 -2
- package/esm/typescript/ReactRouterPathParams.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts +3 -27
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +26 -201
- package/script/context/GenerateContext.d.ts +12 -16
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +58 -70
- package/script/context/ParseContext.d.ts +1 -2
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/ParseContext.js +18 -12
- package/script/context/RenderContext.d.ts +7 -13
- package/script/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +26 -46
- package/script/context/ResultsHandler.d.ts.map +1 -1
- package/script/context/ResultsHandler.js +0 -1
- package/script/context/StackTrail.d.ts +1 -1
- package/script/context/StackTrail.d.ts.map +1 -1
- package/script/context/types.d.ts +0 -5
- package/script/context/types.d.ts.map +1 -1
- package/script/dsl/Definition.d.ts +2 -2
- package/script/dsl/Definition.d.ts.map +1 -1
- package/script/dsl/ModelDriver.d.ts +3 -3
- package/script/dsl/ModelDriver.d.ts.map +1 -1
- package/script/dsl/ModelInsertable.d.ts +3 -3
- package/script/dsl/ModelInsertable.d.ts.map +1 -1
- package/script/dsl/OperationDriver.d.ts +3 -3
- package/script/dsl/OperationDriver.d.ts.map +1 -1
- package/script/dsl/OperationInsertable.d.ts +3 -3
- package/script/dsl/OperationInsertable.d.ts.map +1 -1
- package/script/dsl/ValueBase.d.ts +3 -3
- package/script/dsl/ValueBase.d.ts.map +1 -1
- package/script/dsl/ValueBase.js +1 -3
- package/script/dsl/base.d.ts +3 -4
- package/script/dsl/base.d.ts.map +1 -1
- package/script/dsl/withConfig.d.ts +7 -7
- package/script/dsl/withConfig.d.ts.map +1 -1
- package/script/generate/generate.d.ts +0 -1
- package/script/generate/generate.d.ts.map +1 -1
- package/script/generate/generate.js +6 -6
- package/script/oas/parameter/toParameterV3.d.ts.map +1 -1
- package/script/oas/parameter/toParameterV3.js +1 -0
- package/script/server/createServer.d.ts.map +1 -1
- package/script/server/createServer.js +3 -7
- package/script/types/CustomValue.d.ts +2 -2
- package/script/types/CustomValue.d.ts.map +1 -1
- package/script/typescript/PathParams.d.ts +3 -3
- package/script/typescript/PathParams.d.ts.map +1 -1
- package/script/typescript/ReactRouterPathParams.d.ts +2 -2
- package/script/typescript/ReactRouterPathParams.d.ts.map +1 -1
|
@@ -72,24 +72,30 @@ class CoreContext {
|
|
|
72
72
|
if (__classPrivateFieldGet(this, _CoreContext_phase, "f").type !== 'parse') {
|
|
73
73
|
throw new Error(`Expected 'parse' phase, got '${__classPrivateFieldGet(this, _CoreContext_phase, "f").type}'`);
|
|
74
74
|
}
|
|
75
|
+
const callback = (generatorKey) => {
|
|
76
|
+
if (__classPrivateFieldGet(this, _CoreContext_phase, "f").type === 'render') {
|
|
77
|
+
__classPrivateFieldGet(this, _CoreContext_phase, "f").context.addGeneratorKey({ generatorKey });
|
|
78
|
+
}
|
|
79
|
+
};
|
|
75
80
|
const schemaModel = __classPrivateFieldGet(this, _CoreContext_phase, "f").context.parse();
|
|
76
81
|
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupGeneratePhase).call(this, {
|
|
77
82
|
schemaModel,
|
|
78
83
|
settings,
|
|
79
|
-
generatorsMap
|
|
84
|
+
generatorsMap,
|
|
85
|
+
callback
|
|
80
86
|
}), "f");
|
|
81
|
-
__classPrivateFieldGet(this, _CoreContext_phase, "f").context.generate(
|
|
82
|
-
this.logger.debug(`${
|
|
87
|
+
const files = __classPrivateFieldGet(this, _CoreContext_phase, "f").context.generate(generatorsMap);
|
|
88
|
+
this.logger.debug(`${files.size} files generated`);
|
|
83
89
|
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupRenderPhase).call(this, {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
pinnableGenerators: Object.values(this.generatorsMap)
|
|
90
|
+
files,
|
|
91
|
+
pinnableGenerators: Object.values(generatorsMap)
|
|
87
92
|
.map(({ id, pinnable }) => (pinnable ? id : null))
|
|
88
93
|
.filter(generatorId => generatorId !== null),
|
|
89
94
|
prettier,
|
|
90
|
-
settings
|
|
95
|
+
basePath: settings?.basePath
|
|
91
96
|
}), "f");
|
|
92
|
-
const renderOutput = __classPrivateFieldGet(this, _CoreContext_phase, "f").context.render(
|
|
97
|
+
const renderOutput = __classPrivateFieldGet(this, _CoreContext_phase, "f").context.render();
|
|
98
|
+
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove('render');
|
|
93
99
|
return {
|
|
94
100
|
...renderOutput,
|
|
95
101
|
results: __classPrivateFieldGet(this, _CoreContext_results, "f")
|
|
@@ -115,192 +121,6 @@ class CoreContext {
|
|
|
115
121
|
removeStackTrailChunk(chunk) {
|
|
116
122
|
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove(chunk);
|
|
117
123
|
}
|
|
118
|
-
register({ destinationPath, ...args }) {
|
|
119
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
120
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
121
|
-
return context.register({ destinationPath, ...args });
|
|
122
|
-
})
|
|
123
|
-
.with({ type: 'parse' }, () => {
|
|
124
|
-
throw new Error(`Cannot register during parse phase`);
|
|
125
|
-
})
|
|
126
|
-
.with({ type: 'render' }, () => {
|
|
127
|
-
throw new Error(`Cannot register during render phase`);
|
|
128
|
-
})
|
|
129
|
-
.exhaustive();
|
|
130
|
-
}
|
|
131
|
-
addGeneratorKey({ generatorKey }) {
|
|
132
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
133
|
-
.with({ type: 'generate' }, () => {
|
|
134
|
-
this.logger.info('trying to add generator key during generate phase');
|
|
135
|
-
})
|
|
136
|
-
.with({ type: 'parse' }, () => {
|
|
137
|
-
throw new Error(`Cannot add generator key during parse phase`);
|
|
138
|
-
})
|
|
139
|
-
.with({ type: 'render' }, ({ context }) => {
|
|
140
|
-
return context.addGeneratorKey({ generatorKey });
|
|
141
|
-
})
|
|
142
|
-
.exhaustive();
|
|
143
|
-
}
|
|
144
|
-
resolveSchemaRefOnce(refName) {
|
|
145
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
146
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
147
|
-
return context.resolveSchemaRefOnce(refName);
|
|
148
|
-
})
|
|
149
|
-
.with({ type: 'parse' }, () => {
|
|
150
|
-
throw new Error(`Cannot resolve schema during parse phase`);
|
|
151
|
-
})
|
|
152
|
-
.with({ type: 'render' }, () => {
|
|
153
|
-
throw new Error(`Cannot resolve schema during render phase`);
|
|
154
|
-
})
|
|
155
|
-
.exhaustive();
|
|
156
|
-
}
|
|
157
|
-
addRenderDependency(args) {
|
|
158
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
159
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
160
|
-
return context.addRenderDependency(args);
|
|
161
|
-
})
|
|
162
|
-
.with({ type: 'parse' }, () => {
|
|
163
|
-
throw new Error(`Cannot add render dependency during parse phase`);
|
|
164
|
-
})
|
|
165
|
-
.with({ type: 'render' }, () => {
|
|
166
|
-
throw new Error(`Cannot add render dependency during render phase`);
|
|
167
|
-
})
|
|
168
|
-
.exhaustive();
|
|
169
|
-
}
|
|
170
|
-
getFile(filePath) {
|
|
171
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
172
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
173
|
-
return context.getFile(filePath);
|
|
174
|
-
})
|
|
175
|
-
.with({ type: 'parse' }, () => {
|
|
176
|
-
throw new Error(`Cannot get file during parse phase`);
|
|
177
|
-
})
|
|
178
|
-
.with({ type: 'render' }, () => {
|
|
179
|
-
throw new Error(`Cannot get file during render phase`);
|
|
180
|
-
})
|
|
181
|
-
.exhaustive();
|
|
182
|
-
}
|
|
183
|
-
findDefinition(args) {
|
|
184
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
185
|
-
.with({ type: 'generate' }, ({ context }) => context.findDefinition(args))
|
|
186
|
-
.with({ type: 'parse' }, () => {
|
|
187
|
-
throw new Error(`Cannot pick during parse phase`);
|
|
188
|
-
})
|
|
189
|
-
.with({ type: 'render' }, ({ context }) => context.pick(args))
|
|
190
|
-
.exhaustive();
|
|
191
|
-
}
|
|
192
|
-
addFile(normalisedPath) {
|
|
193
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
194
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
195
|
-
return context.addFile(normalisedPath);
|
|
196
|
-
})
|
|
197
|
-
.with({ type: 'parse' }, () => {
|
|
198
|
-
throw new Error(`Cannot add file during parse phase`);
|
|
199
|
-
})
|
|
200
|
-
.with({ type: 'render' }, () => {
|
|
201
|
-
throw new Error(`Cannot add file during render phase`);
|
|
202
|
-
})
|
|
203
|
-
.exhaustive();
|
|
204
|
-
}
|
|
205
|
-
getOperationBaseSettings(args) {
|
|
206
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
207
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
208
|
-
return context.getOperationBaseSettings(args);
|
|
209
|
-
})
|
|
210
|
-
.with({ type: 'parse' }, () => {
|
|
211
|
-
throw new Error(`Cannot access operation settings during parse phase`);
|
|
212
|
-
})
|
|
213
|
-
.with({ type: 'render' }, () => {
|
|
214
|
-
throw new Error(`Cannot access operation settings during render phase`);
|
|
215
|
-
})
|
|
216
|
-
.exhaustive();
|
|
217
|
-
}
|
|
218
|
-
insert(args) {
|
|
219
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
220
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
221
|
-
return context.insert({ ...args, coreContext: this });
|
|
222
|
-
})
|
|
223
|
-
.with({ type: 'parse' }, () => {
|
|
224
|
-
throw new Error(`Cannot run 'transform' during parse phase`);
|
|
225
|
-
})
|
|
226
|
-
.with({ type: 'render' }, () => {
|
|
227
|
-
throw new Error(`Cannot run 'transform' during render phase`);
|
|
228
|
-
})
|
|
229
|
-
.exhaustive();
|
|
230
|
-
}
|
|
231
|
-
getModelBaseSettings(args) {
|
|
232
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
233
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
234
|
-
return context.getModelBaseSettings(args);
|
|
235
|
-
})
|
|
236
|
-
.with({ type: 'parse' }, () => {
|
|
237
|
-
throw new Error(`Cannot access model settings during parse phase`);
|
|
238
|
-
})
|
|
239
|
-
.with({ type: 'render' }, () => {
|
|
240
|
-
throw new Error(`Cannot access model settings during render phase`);
|
|
241
|
-
})
|
|
242
|
-
.exhaustive();
|
|
243
|
-
}
|
|
244
|
-
get files() {
|
|
245
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
246
|
-
.with({ type: 'generate' }, ({ context }) => context.files)
|
|
247
|
-
.with({ type: 'parse' }, () => {
|
|
248
|
-
throw new Error(`Cannot access files during parse phase`);
|
|
249
|
-
})
|
|
250
|
-
.with({ type: 'render' }, ({ context }) => context.files)
|
|
251
|
-
.exhaustive();
|
|
252
|
-
}
|
|
253
|
-
get renderDependencies() {
|
|
254
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
255
|
-
.with({ type: 'generate' }, ({ context }) => context.renderDependencies)
|
|
256
|
-
.with({ type: 'parse' }, () => {
|
|
257
|
-
throw new Error(`Cannot access files during parse phase`);
|
|
258
|
-
})
|
|
259
|
-
.with({ type: 'render' }, ({ context }) => context.renderDependencies)
|
|
260
|
-
.exhaustive();
|
|
261
|
-
}
|
|
262
|
-
get packageDependencies() {
|
|
263
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
264
|
-
.with({ type: 'generate' }, ({ context }) => context.packageDependencies)
|
|
265
|
-
.with({ type: 'parse' }, () => {
|
|
266
|
-
throw new Error(`Cannot access package dependencies during parse phase`);
|
|
267
|
-
})
|
|
268
|
-
.with({ type: 'render' }, ({ context }) => context.packageDependencies)
|
|
269
|
-
.exhaustive();
|
|
270
|
-
}
|
|
271
|
-
get schemaModel() {
|
|
272
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
273
|
-
.with({ type: 'generate' }, ({ context }) => context.schemaModel)
|
|
274
|
-
.with({ type: 'parse' }, () => {
|
|
275
|
-
throw new Error(`Cannot access schema model during parse phase`);
|
|
276
|
-
})
|
|
277
|
-
.with({ type: 'render' }, () => {
|
|
278
|
-
throw new Error(`Cannot access schema model during render phase`);
|
|
279
|
-
})
|
|
280
|
-
.exhaustive();
|
|
281
|
-
}
|
|
282
|
-
get generatorsMap() {
|
|
283
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
284
|
-
.with({ type: 'generate' }, ({ context }) => context.generatorsMap)
|
|
285
|
-
.with({ type: 'parse' }, () => {
|
|
286
|
-
throw new Error(`Cannot access schema model during parse phase`);
|
|
287
|
-
})
|
|
288
|
-
.with({ type: 'render' }, () => {
|
|
289
|
-
throw new Error(`Cannot access schema model during render phase`);
|
|
290
|
-
})
|
|
291
|
-
.exhaustive();
|
|
292
|
-
}
|
|
293
|
-
get settings() {
|
|
294
|
-
return (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
295
|
-
.with({ type: 'generate' }, ({ context }) => context.settings)
|
|
296
|
-
.with({ type: 'parse' }, () => {
|
|
297
|
-
throw new Error(`Cannot access settings during parse phase`);
|
|
298
|
-
})
|
|
299
|
-
.with({ type: 'render' }, () => {
|
|
300
|
-
throw new Error(`Cannot access settings during render phase`);
|
|
301
|
-
})
|
|
302
|
-
.exhaustive();
|
|
303
|
-
}
|
|
304
124
|
}
|
|
305
125
|
exports.CoreContext = CoreContext;
|
|
306
126
|
_CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreContext_stackTrail = new WeakMap(), _CoreContext_instances = new WeakSet(), _CoreContext_setupLogger = function _CoreContext_setupLogger(spanId) {
|
|
@@ -337,22 +157,27 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
337
157
|
.exhaustive();
|
|
338
158
|
return StackTrail_js_1.StackTrail.join(__classPrivateFieldGet(this, _CoreContext_stackTrail, "f"), substack);
|
|
339
159
|
}, _CoreContext_setupParsePhase = function _CoreContext_setupParsePhase(schema) {
|
|
160
|
+
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").append('parse');
|
|
340
161
|
const parseContext = new ParseContext_js_1.ParseContext({ schema, logger: this.logger });
|
|
341
162
|
return { type: 'parse', context: parseContext };
|
|
342
|
-
}, _CoreContext_setupGeneratePhase = function _CoreContext_setupGeneratePhase({ schemaModel, settings, generatorsMap }) {
|
|
163
|
+
}, _CoreContext_setupGeneratePhase = function _CoreContext_setupGeneratePhase({ schemaModel, settings, generatorsMap, callback }) {
|
|
164
|
+
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove('parse');
|
|
165
|
+
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").append('generate');
|
|
343
166
|
const generateContext = new GenerateContext_js_1.GenerateContext({
|
|
344
167
|
schemaModel,
|
|
345
168
|
settings,
|
|
346
|
-
generatorsMap
|
|
169
|
+
generatorsMap,
|
|
170
|
+
logger: this.logger,
|
|
171
|
+
callback
|
|
347
172
|
});
|
|
348
173
|
return { type: 'generate', context: generateContext };
|
|
349
|
-
}, _CoreContext_setupRenderPhase = function _CoreContext_setupRenderPhase({
|
|
174
|
+
}, _CoreContext_setupRenderPhase = function _CoreContext_setupRenderPhase({ files, prettier, basePath, pinnableGenerators }) {
|
|
175
|
+
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove('generate');
|
|
176
|
+
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").append('render');
|
|
350
177
|
const renderContext = new RenderContext_js_1.RenderContext({
|
|
351
|
-
files
|
|
352
|
-
renderDependencies,
|
|
353
|
-
packageDependencies,
|
|
178
|
+
files,
|
|
354
179
|
prettier,
|
|
355
|
-
|
|
180
|
+
basePath,
|
|
356
181
|
pinnableGenerators
|
|
357
182
|
});
|
|
358
183
|
return { type: 'render', context: renderContext };
|
|
@@ -3,21 +3,23 @@ import type { Definition } from '../dsl/Definition.js';
|
|
|
3
3
|
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
|
-
import type { FileContents, GetFileOptions
|
|
6
|
+
import type { FileContents, GetFileOptions } from './types.js';
|
|
7
7
|
import type { BaseSettings, ClientSettings } from '../types/Settings.js';
|
|
8
8
|
import type { Method } from '../types/Method.js';
|
|
9
9
|
import type { OperationInsertable, OperationGenerator } from '../dsl/OperationInsertable.js';
|
|
10
10
|
import type { OasOperation } from '../oas/operation/Operation.js';
|
|
11
|
-
import type { CoreContext } from './CoreContext.js';
|
|
12
11
|
import type { ModelInsertable, ModelGenerator } from '../dsl/ModelInsertable.js';
|
|
13
12
|
import type { GenerationType, GeneratedDefintion, GeneratedValue } from '../types/GeneratedValue.js';
|
|
14
13
|
import type { ContentSettings } from '../dsl/ContentSettings.js';
|
|
15
14
|
import type { RefName } from '../types/RefName.js';
|
|
16
|
-
import
|
|
15
|
+
import type * as log from '../deps/jsr.io/@std/log/0.224.6/mod.js';
|
|
16
|
+
import type { GeneratorKey } from '../types/GeneratorKeys.js';
|
|
17
17
|
type ConstructorArgs = {
|
|
18
18
|
schemaModel: OasDocument;
|
|
19
19
|
settings: ClientSettings | undefined;
|
|
20
20
|
generatorsMap: Record<string, OperationGenerator | ModelGenerator>;
|
|
21
|
+
logger: log.Logger;
|
|
22
|
+
callback: (generatorKey: GeneratorKey) => void;
|
|
21
23
|
};
|
|
22
24
|
export type PickArgs = {
|
|
23
25
|
name: string;
|
|
@@ -25,7 +27,6 @@ export type PickArgs = {
|
|
|
25
27
|
};
|
|
26
28
|
export type RegisterArgs = {
|
|
27
29
|
imports?: Record<string, ImportNameArg[]>;
|
|
28
|
-
packageDependencies?: Record<string, string>;
|
|
29
30
|
definitions?: (Definition | undefined)[];
|
|
30
31
|
destinationPath: string;
|
|
31
32
|
};
|
|
@@ -60,27 +61,22 @@ export type InsertReturn<V extends GeneratedValue, T extends GenerationType> = {
|
|
|
60
61
|
};
|
|
61
62
|
export declare class GenerateContext {
|
|
62
63
|
#private;
|
|
63
|
-
files: Map<string, FileContents>;
|
|
64
|
-
renderDependencies: RenderDependencies;
|
|
65
|
-
packageDependencies: Map<string, string>;
|
|
66
64
|
schemaModel: OasDocument;
|
|
67
65
|
settings: ClientSettings | undefined;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
constructor({ schemaModel,
|
|
71
|
-
generate(
|
|
66
|
+
logger: log.Logger;
|
|
67
|
+
callback: (generatorKey: GeneratorKey) => void;
|
|
68
|
+
constructor({ schemaModel, settings, logger, callback }: ConstructorArgs);
|
|
69
|
+
generate(generatorsMap: Record<string, OperationGenerator | ModelGenerator>): Map<string, FileContents>;
|
|
72
70
|
appendStackTrailChunk(chunk: string | string[]): void;
|
|
73
71
|
removeStackTrailChunk(chunk: string | string[]): void;
|
|
72
|
+
get stackTrail(): string;
|
|
74
73
|
getFile(filePath: string, { throwIfNotFound }?: GetFileOptions): FileContents;
|
|
75
|
-
register({ imports,
|
|
76
|
-
insert<V extends GeneratedValue, T extends GenerationType>({
|
|
77
|
-
coreContext: CoreContext;
|
|
78
|
-
}): InsertReturn<V, T>;
|
|
74
|
+
register({ imports, definitions, destinationPath }: RegisterArgs): void;
|
|
75
|
+
insert<V extends GeneratedValue, T extends GenerationType>({ generation, destinationPath, ...rest }: InsertArgs<V, T>): InsertReturn<V, T>;
|
|
79
76
|
getOperationBaseSettings({ generatorId, path, method }: GetOperationSettingsArgs): BaseSettings;
|
|
80
77
|
getModelBaseSettings({ generatorId, refName }: GetModelSettingsArgs): BaseSettings;
|
|
81
78
|
addFile(normalisedPath: string): FileContents;
|
|
82
79
|
resolveSchemaRefOnce(refName: RefName): OasSchema | OasRef<'schema'>;
|
|
83
|
-
addRenderDependency({ generatorId, dependencies, operation }: AddRenderDependencyArgs): void;
|
|
84
80
|
/** Produce external instance and return its name */
|
|
85
81
|
findDefinition({ name, exportPath }: PickArgs): Definition | undefined;
|
|
86
82
|
}
|
|
@@ -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,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,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,
|
|
1
|
+
{"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AAE,MAAM,GAAG,YAAY;IAgB7C,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;IAWpE,oDAAoD;IACpD,cAAc,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;CAGvE"}
|
|
@@ -22,42 +22,30 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
26
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
27
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
28
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
29
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
30
|
+
};
|
|
25
31
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
26
32
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
27
33
|
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");
|
|
28
34
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
29
35
|
};
|
|
30
|
-
var _GenerateContext_instances, _GenerateContext_runOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_generateModel, _GenerateContext_generateOperation;
|
|
36
|
+
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_stackTrail, _GenerateContext_runOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_generateModel, _GenerateContext_generateOperation;
|
|
31
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
38
|
exports.GenerateContext = void 0;
|
|
33
39
|
const mod_js_1 = require("../deps/jsr.io/@std/path/1.0.0/mod.js");
|
|
34
40
|
const Import_js_1 = require("../dsl/Import.js");
|
|
35
|
-
const GeneratorKeys_js_1 = require("../types/GeneratorKeys.js");
|
|
36
41
|
const OperationDriver_js_1 = require("../dsl/OperationDriver.js");
|
|
37
42
|
const ModelDriver_js_1 = require("../dsl/ModelDriver.js");
|
|
38
43
|
const StackTrail_js_1 = require("./StackTrail.js");
|
|
39
44
|
const Sentry = __importStar(require("@sentry/deno"));
|
|
40
45
|
class GenerateContext {
|
|
41
|
-
constructor({ schemaModel,
|
|
46
|
+
constructor({ schemaModel, settings, logger, callback }) {
|
|
42
47
|
_GenerateContext_instances.add(this);
|
|
43
|
-
|
|
44
|
-
enumerable: true,
|
|
45
|
-
configurable: true,
|
|
46
|
-
writable: true,
|
|
47
|
-
value: void 0
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(this, "renderDependencies", {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
configurable: true,
|
|
52
|
-
writable: true,
|
|
53
|
-
value: void 0
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(this, "packageDependencies", {
|
|
56
|
-
enumerable: true,
|
|
57
|
-
configurable: true,
|
|
58
|
-
writable: true,
|
|
59
|
-
value: void 0
|
|
60
|
-
});
|
|
48
|
+
_GenerateContext_files.set(this, void 0);
|
|
61
49
|
Object.defineProperty(this, "schemaModel", {
|
|
62
50
|
enumerable: true,
|
|
63
51
|
configurable: true,
|
|
@@ -70,53 +58,66 @@ class GenerateContext {
|
|
|
70
58
|
writable: true,
|
|
71
59
|
value: void 0
|
|
72
60
|
});
|
|
73
|
-
|
|
61
|
+
_GenerateContext_stackTrail.set(this, void 0);
|
|
62
|
+
Object.defineProperty(this, "logger", {
|
|
74
63
|
enumerable: true,
|
|
75
64
|
configurable: true,
|
|
76
65
|
writable: true,
|
|
77
66
|
value: void 0
|
|
78
67
|
});
|
|
79
|
-
Object.defineProperty(this, "
|
|
68
|
+
Object.defineProperty(this, "callback", {
|
|
80
69
|
enumerable: true,
|
|
81
70
|
configurable: true,
|
|
82
71
|
writable: true,
|
|
83
72
|
value: void 0
|
|
84
73
|
});
|
|
85
|
-
this.
|
|
86
|
-
this.
|
|
87
|
-
this
|
|
88
|
-
this.renderDependencies = new Map();
|
|
89
|
-
this.packageDependencies = new Map();
|
|
74
|
+
this.logger = logger;
|
|
75
|
+
__classPrivateFieldSet(this, _GenerateContext_stackTrail, new StackTrail_js_1.StackTrail(), "f");
|
|
76
|
+
__classPrivateFieldSet(this, _GenerateContext_files, new Map(), "f");
|
|
90
77
|
this.schemaModel = schemaModel;
|
|
91
78
|
this.settings = settings;
|
|
79
|
+
this.callback = callback;
|
|
92
80
|
}
|
|
93
|
-
generate(
|
|
94
|
-
Sentry.startSpan({ name: 'Generate operations' }, () => Object.values(
|
|
81
|
+
generate(generatorsMap) {
|
|
82
|
+
Sentry.startSpan({ name: 'Generate operations' }, () => Object.values(generatorsMap)
|
|
95
83
|
.filter(generator => generator.type === 'operation')
|
|
96
84
|
.forEach(generator => {
|
|
97
85
|
this.appendStackTrailChunk(generator.id);
|
|
98
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runOperationGenerator).call(this, {
|
|
86
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runOperationGenerator).call(this, {
|
|
87
|
+
schemaModel: this.schemaModel,
|
|
88
|
+
generator
|
|
89
|
+
});
|
|
99
90
|
this.removeStackTrailChunk(generator.id);
|
|
100
91
|
}));
|
|
101
92
|
Sentry.startSpan({ name: 'Generate models' }, () => {
|
|
102
|
-
Object.values(
|
|
93
|
+
Object.values(generatorsMap)
|
|
103
94
|
.filter(generator => generator.type === 'model')
|
|
104
95
|
.forEach(generator => {
|
|
105
96
|
this.appendStackTrailChunk(generator.id);
|
|
106
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, {
|
|
97
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, { schemaModel: this.schemaModel, generator });
|
|
107
98
|
this.removeStackTrailChunk(generator.id);
|
|
108
99
|
});
|
|
109
100
|
});
|
|
101
|
+
return __classPrivateFieldGet(this, _GenerateContext_files, "f");
|
|
110
102
|
}
|
|
111
103
|
appendStackTrailChunk(chunk) {
|
|
112
|
-
this.
|
|
104
|
+
__classPrivateFieldGet(this, _GenerateContext_stackTrail, "f").append(chunk);
|
|
113
105
|
}
|
|
114
106
|
removeStackTrailChunk(chunk) {
|
|
115
|
-
this.
|
|
107
|
+
__classPrivateFieldGet(this, _GenerateContext_stackTrail, "f").remove(chunk);
|
|
108
|
+
}
|
|
109
|
+
// captureCurrentResult(result: SuccessWarningError): void {
|
|
110
|
+
// const stackTrail = this.#stackTrail.toString()
|
|
111
|
+
// if (applyResult({ current: this.#results[stackTrail], incoming: result })) {
|
|
112
|
+
// this.#results[stackTrail] = result
|
|
113
|
+
// }
|
|
114
|
+
// }
|
|
115
|
+
get stackTrail() {
|
|
116
|
+
return __classPrivateFieldGet(this, _GenerateContext_stackTrail, "f").toString();
|
|
116
117
|
}
|
|
117
118
|
getFile(filePath, { throwIfNotFound = false } = {}) {
|
|
118
119
|
const normalisedPath = (0, mod_js_1.normalize)(filePath);
|
|
119
|
-
const currentFile = this.
|
|
120
|
+
const currentFile = __classPrivateFieldGet(this, _GenerateContext_files, "f").get(normalisedPath);
|
|
120
121
|
if (!currentFile) {
|
|
121
122
|
if (throwIfNotFound) {
|
|
122
123
|
throw new Error(`File not found: '${normalisedPath}'`);
|
|
@@ -127,7 +128,7 @@ class GenerateContext {
|
|
|
127
128
|
}
|
|
128
129
|
return currentFile;
|
|
129
130
|
}
|
|
130
|
-
register({ imports = {},
|
|
131
|
+
register({ imports = {}, definitions, destinationPath }) {
|
|
131
132
|
const currentFile = this.getFile(destinationPath);
|
|
132
133
|
Object.entries(imports).forEach(([importModule, importNames]) => {
|
|
133
134
|
const module = currentFile.imports.get(importModule);
|
|
@@ -139,20 +140,17 @@ class GenerateContext {
|
|
|
139
140
|
currentFile.imports.set(importModule, new Set(importItem.importNames.map(n => `${n}`)));
|
|
140
141
|
}
|
|
141
142
|
});
|
|
142
|
-
Object.entries(packageDependencies).forEach(([module, version]) => {
|
|
143
|
-
this.packageDependencies.set(module, version);
|
|
144
|
-
});
|
|
145
143
|
definitions
|
|
146
144
|
?.filter((definition) => Boolean(definition))
|
|
147
145
|
.forEach(definition => {
|
|
148
146
|
currentFile.definitions.set(`${definition.identifier}`, definition);
|
|
149
147
|
});
|
|
150
148
|
}
|
|
151
|
-
insert({
|
|
149
|
+
insert({ generation, destinationPath, ...rest }) {
|
|
152
150
|
if ('operation' in rest) {
|
|
153
151
|
const { insertable, operation } = rest;
|
|
154
152
|
const { settings, definition } = new OperationDriver_js_1.OperationDriver({
|
|
155
|
-
context:
|
|
153
|
+
context: this,
|
|
156
154
|
insertable,
|
|
157
155
|
operation,
|
|
158
156
|
generation,
|
|
@@ -163,7 +161,7 @@ class GenerateContext {
|
|
|
163
161
|
else {
|
|
164
162
|
const { insertable, refName } = rest;
|
|
165
163
|
const { settings, definition } = new ModelDriver_js_1.ModelDriver({
|
|
166
|
-
context:
|
|
164
|
+
context: this,
|
|
167
165
|
insertable,
|
|
168
166
|
refName,
|
|
169
167
|
generation,
|
|
@@ -205,7 +203,7 @@ class GenerateContext {
|
|
|
205
203
|
return baseSettings;
|
|
206
204
|
}
|
|
207
205
|
addFile(normalisedPath) {
|
|
208
|
-
if (this.
|
|
206
|
+
if (__classPrivateFieldGet(this, _GenerateContext_files, "f").has(normalisedPath)) {
|
|
209
207
|
throw new Error(`File already exists: ${normalisedPath}`);
|
|
210
208
|
}
|
|
211
209
|
const newFile = {
|
|
@@ -213,7 +211,7 @@ class GenerateContext {
|
|
|
213
211
|
definitions: new Map(),
|
|
214
212
|
generatorKeys: new Set()
|
|
215
213
|
};
|
|
216
|
-
this.
|
|
214
|
+
__classPrivateFieldGet(this, _GenerateContext_files, "f").set(normalisedPath, newFile);
|
|
217
215
|
return newFile;
|
|
218
216
|
}
|
|
219
217
|
resolveSchemaRefOnce(refName) {
|
|
@@ -223,24 +221,15 @@ class GenerateContext {
|
|
|
223
221
|
}
|
|
224
222
|
return schema;
|
|
225
223
|
}
|
|
226
|
-
addRenderDependency({ generatorId, dependencies, operation }) {
|
|
227
|
-
if (!this.renderDependencies.has(generatorId)) {
|
|
228
|
-
this.renderDependencies.set(generatorId, new Set());
|
|
229
|
-
}
|
|
230
|
-
const generatorDependencies = this.renderDependencies.get(generatorId);
|
|
231
|
-
dependencies.forEach(dependencyId => {
|
|
232
|
-
generatorDependencies?.add((0, GeneratorKeys_js_1.toOperationGeneratorKey)({ generatorId: dependencyId, operation }));
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
224
|
/** Produce external instance and return its name */
|
|
236
225
|
findDefinition({ name, exportPath }) {
|
|
237
226
|
return this.getFile(exportPath).definitions.get(name);
|
|
238
227
|
}
|
|
239
228
|
}
|
|
240
229
|
exports.GenerateContext = GenerateContext;
|
|
241
|
-
_GenerateContext_instances = new WeakSet(), _GenerateContext_runOperationGenerator = function _GenerateContext_runOperationGenerator({
|
|
242
|
-
const generatorInstance = new generator(
|
|
243
|
-
|
|
230
|
+
_GenerateContext_files = new WeakMap(), _GenerateContext_stackTrail = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_runOperationGenerator = function _GenerateContext_runOperationGenerator({ schemaModel, generator }) {
|
|
231
|
+
const generatorInstance = new generator(this);
|
|
232
|
+
schemaModel.operations.forEach(operation => {
|
|
244
233
|
// TODO If we make OasOperation generic, for example by
|
|
245
234
|
// adding a `method` type, we could make isSupported
|
|
246
235
|
// a type guard which could help us narrow down the
|
|
@@ -251,40 +240,39 @@ _GenerateContext_instances = new WeakSet(), _GenerateContext_runOperationGenerat
|
|
|
251
240
|
const { path, method } = operation;
|
|
252
241
|
if (generator.isSupported(operation)) {
|
|
253
242
|
this.appendStackTrailChunk([path, method]);
|
|
254
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_generateOperation).call(this, {
|
|
243
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_generateOperation).call(this, { operation, generatorInstance });
|
|
255
244
|
this.removeStackTrailChunk([path, method]);
|
|
256
245
|
}
|
|
257
246
|
});
|
|
258
|
-
}, _GenerateContext_runModelGenerator = function _GenerateContext_runModelGenerator({
|
|
259
|
-
const generatorInstance = new generator(
|
|
260
|
-
const refNames = Object.keys(
|
|
247
|
+
}, _GenerateContext_runModelGenerator = function _GenerateContext_runModelGenerator({ schemaModel, generator }) {
|
|
248
|
+
const generatorInstance = new generator(this);
|
|
249
|
+
const refNames = Object.keys(schemaModel.components?.schemas ?? {});
|
|
261
250
|
refNames.forEach(rn => {
|
|
262
251
|
this.appendStackTrailChunk(rn);
|
|
263
252
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_generateModel).call(this, {
|
|
264
|
-
context,
|
|
265
253
|
refName: rn,
|
|
266
254
|
generatorInstance
|
|
267
255
|
});
|
|
268
256
|
this.removeStackTrailChunk(rn);
|
|
269
257
|
});
|
|
270
|
-
}, _GenerateContext_generateModel = function _GenerateContext_generateModel({
|
|
258
|
+
}, _GenerateContext_generateModel = function _GenerateContext_generateModel({ refName, generatorInstance }) {
|
|
271
259
|
try {
|
|
272
260
|
generatorInstance.transformModel(refName);
|
|
273
|
-
|
|
261
|
+
// this.captureCurrentResult('success')
|
|
274
262
|
}
|
|
275
263
|
catch (error) {
|
|
276
|
-
|
|
277
|
-
|
|
264
|
+
this.logger.error(error);
|
|
265
|
+
// this.captureCurrentResult('error')
|
|
278
266
|
Sentry.captureException(error);
|
|
279
267
|
}
|
|
280
|
-
}, _GenerateContext_generateOperation = function _GenerateContext_generateOperation({
|
|
268
|
+
}, _GenerateContext_generateOperation = function _GenerateContext_generateOperation({ operation, generatorInstance }) {
|
|
281
269
|
try {
|
|
282
270
|
generatorInstance.transformOperation(operation);
|
|
283
|
-
|
|
271
|
+
// this.captureCurrentResult('success')
|
|
284
272
|
}
|
|
285
273
|
catch (error) {
|
|
286
|
-
|
|
287
|
-
|
|
274
|
+
this.logger.error(error);
|
|
275
|
+
// this.captureCurrentResult('error')
|
|
288
276
|
Sentry.captureException(error);
|
|
289
277
|
}
|
|
290
278
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import { StackTrail } from './StackTrail.js';
|
|
3
2
|
import { OasDocument } from '../oas/document/Document.js';
|
|
4
3
|
import type * as log from '../deps/jsr.io/@std/log/0.224.6/mod.js';
|
|
5
4
|
type ConstructorArgs = {
|
|
@@ -9,12 +8,12 @@ type ConstructorArgs = {
|
|
|
9
8
|
export declare class ParseContext {
|
|
10
9
|
#private;
|
|
11
10
|
schema: string;
|
|
12
|
-
stackTrail: StackTrail;
|
|
13
11
|
logger: log.Logger;
|
|
14
12
|
documentRoot: OasDocument;
|
|
15
13
|
constructor({ schema, logger }: ConstructorArgs);
|
|
16
14
|
parse(): OasDocument;
|
|
17
15
|
logSkippedFields(skipped: Record<string, unknown>): void;
|
|
16
|
+
get stackTrail(): string;
|
|
18
17
|
appendStackTrailChunk(chunk: string | string[]): void;
|
|
19
18
|
removeStackTrailChunk(chunk: string | string[]): void;
|
|
20
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParseContext.d.ts","sourceRoot":"","sources":["../../src/context/ParseContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"ParseContext.d.ts","sourceRoot":"","sources":["../../src/context/ParseContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAK9C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,KAAK,GAAG,MAAM,wCAAwC,CAAA;AAElE,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;CACnB,CAAA;AAED,qBAAa,YAAY;;IACvB,MAAM,EAAE,MAAM,CAAA;IAEd,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAClB,YAAY,EAAE,WAAW,CAAA;gBAEb,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,eAAe;IAQ/C,KAAK;IA4BL,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAYjD,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAI9C,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CAG/C;AAED,eAAO,MAAM,WAAW,WAAY,MAAM,2BAMzC,CAAA"}
|