@skmtc/core 0.0.556 → 0.0.557
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/GenerateContext.d.ts +2 -12
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +32 -100
- package/esm/dsl/operation/OperationInsertable.d.ts +0 -16
- package/esm/dsl/operation/OperationInsertable.d.ts.map +1 -1
- package/esm/dsl/operation/toOperationInsertable.js +2 -2
- package/esm/mod.d.ts +0 -2
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +0 -2
- package/esm/run/handleEnrichment.d.ts +1 -1
- package/esm/run/handleEnrichment.d.ts.map +1 -1
- package/esm/run/handleEnrichment.js +3 -3
- package/esm/run/toSettings.d.ts.map +1 -1
- package/esm/run/toSettings.js +7 -27
- package/esm/types/EnrichmentRequest.d.ts +1 -1
- package/esm/types/EnrichmentRequest.d.ts.map +1 -1
- package/esm/types/GeneratorType.d.ts +1 -2
- package/esm/types/GeneratorType.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/context/GenerateContext.d.ts +2 -12
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +32 -100
- package/script/dsl/operation/OperationInsertable.d.ts +0 -16
- package/script/dsl/operation/OperationInsertable.d.ts.map +1 -1
- package/script/dsl/operation/toOperationInsertable.js +2 -2
- package/script/mod.d.ts +0 -2
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +0 -2
- package/script/run/handleEnrichment.d.ts +1 -1
- package/script/run/handleEnrichment.d.ts.map +1 -1
- package/script/run/handleEnrichment.js +3 -3
- package/script/run/toSettings.d.ts.map +1 -1
- package/script/run/toSettings.js +7 -27
- package/script/types/EnrichmentRequest.d.ts +1 -1
- package/script/types/EnrichmentRequest.d.ts.map +1 -1
- package/script/types/GeneratorType.d.ts +1 -2
- package/script/types/GeneratorType.d.ts.map +1 -1
- package/esm/dsl/GatewayBase.d.ts +0 -13
- package/esm/dsl/GatewayBase.d.ts.map +0 -1
- package/esm/dsl/GatewayBase.js +0 -19
- package/esm/dsl/operation/toOperationGateway.d.ts +0 -39
- package/esm/dsl/operation/toOperationGateway.d.ts.map +0 -1
- package/esm/dsl/operation/toOperationGateway.js +0 -84
- package/script/dsl/GatewayBase.d.ts +0 -13
- package/script/dsl/GatewayBase.d.ts.map +0 -1
- package/script/dsl/GatewayBase.js +0 -23
- package/script/dsl/operation/toOperationGateway.d.ts +0 -39
- package/script/dsl/operation/toOperationGateway.d.ts.map +0 -1
- package/script/dsl/operation/toOperationGateway.js +0 -88
|
@@ -50,6 +50,7 @@ const tracer_js_1 = require("../helpers/tracer.js");
|
|
|
50
50
|
const Inserted_js_1 = require("../dsl/Inserted.js");
|
|
51
51
|
const File_js_1 = require("../dsl/File.js");
|
|
52
52
|
const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
|
53
|
+
const ts_pattern_1 = require("ts-pattern");
|
|
53
54
|
class GenerateContext {
|
|
54
55
|
constructor({ oasDocument, settings, logger, callback, captureCurrentResult, stackTrail, toGeneratorsMap }) {
|
|
55
56
|
_GenerateContext_instances.add(this);
|
|
@@ -107,22 +108,16 @@ class GenerateContext {
|
|
|
107
108
|
*/
|
|
108
109
|
generate() {
|
|
109
110
|
const generators = Object.values(this.toGeneratorsMap());
|
|
110
|
-
Sentry.startSpan({ name: 'Generate
|
|
111
|
-
.filter(generator => generator.type === 'operation')
|
|
112
|
-
.forEach(generator => {
|
|
111
|
+
Sentry.startSpan({ name: 'Generate' }, () => generators.forEach(generator => {
|
|
113
112
|
this.trace(generator.id, () => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
.filter(generator => generator.type === 'model')
|
|
120
|
-
.forEach(generator => {
|
|
121
|
-
this.trace(generator.id, () => {
|
|
122
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, { oasDocument: this.oasDocument, generator });
|
|
113
|
+
(0, ts_pattern_1.match)(generator.type)
|
|
114
|
+
.with('operation', () => __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runOperationGenerator).call(this, { oasDocument: this.oasDocument, generator }))
|
|
115
|
+
.with('model', () => __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, { oasDocument: this.oasDocument, generator }))
|
|
116
|
+
.otherwise(matched => {
|
|
117
|
+
throw new Error(`Invalid generator type: '${matched}' on ${generator.id}`);
|
|
123
118
|
});
|
|
124
119
|
});
|
|
125
|
-
});
|
|
120
|
+
}));
|
|
126
121
|
return {
|
|
127
122
|
files: __classPrivateFieldGet(this, _GenerateContext_files, "f"),
|
|
128
123
|
previews: __classPrivateFieldGet(this, _GenerateContext_previews, "f")
|
|
@@ -351,44 +346,25 @@ class GenerateContext {
|
|
|
351
346
|
enrichments: insertable.toEnrichments({ refName, context: this })
|
|
352
347
|
});
|
|
353
348
|
}
|
|
354
|
-
/**
|
|
355
|
-
* Generate and return content settings for a gateway
|
|
356
|
-
*
|
|
357
|
-
* Content settings are produced by passing base settings
|
|
358
|
-
* through toIdentifier, toExportPath methods on the gateway
|
|
359
|
-
* @param gateway
|
|
360
|
-
* @returns Content settings for model
|
|
361
|
-
*/
|
|
362
|
-
toGatewayContentSetting(gateway) {
|
|
363
|
-
return new ContentSettings_js_1.ContentSettings({
|
|
364
|
-
identifier: gateway.toIdentifier(),
|
|
365
|
-
selected: true,
|
|
366
|
-
exportPath: gateway.toExportPath(),
|
|
367
|
-
enrichments: undefined
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
349
|
/**
|
|
371
350
|
* Look up operation settings for a given generatorId, path and method.
|
|
372
351
|
* @param { generatorId, path, method }
|
|
373
352
|
* @returns Base settings for operation
|
|
374
353
|
*/
|
|
375
354
|
toOperationSettings({ generatorId, path, method }) {
|
|
376
|
-
const generatorSettings = this.
|
|
355
|
+
const generatorSettings = this.settings?.generators?.find(({ id }) => id === generatorId);
|
|
377
356
|
const operationSettings = generatorSettings && 'operations' in generatorSettings
|
|
378
357
|
? generatorSettings.operations[path]?.[method]
|
|
379
358
|
: undefined;
|
|
380
359
|
return operationSettings ?? { selected: false, enrichments: undefined };
|
|
381
360
|
}
|
|
382
361
|
toModelSettings({ generatorId, refName }) {
|
|
383
|
-
const generatorSettings = this.
|
|
362
|
+
const generatorSettings = this.settings?.generators?.find(({ id }) => id === generatorId);
|
|
384
363
|
const modelSettings = generatorSettings && 'models' in generatorSettings
|
|
385
364
|
? generatorSettings.models[refName]
|
|
386
365
|
: undefined;
|
|
387
366
|
return modelSettings ?? { selected: false, enrichments: undefined };
|
|
388
367
|
}
|
|
389
|
-
toGeneratorSettings(generatorId) {
|
|
390
|
-
return this.settings?.generators?.find(({ id }) => id === generatorId);
|
|
391
|
-
}
|
|
392
368
|
/**
|
|
393
369
|
* Perform one lookup of schema by `refName`.
|
|
394
370
|
* @param refName
|
|
@@ -415,74 +391,30 @@ class GenerateContext {
|
|
|
415
391
|
}
|
|
416
392
|
exports.GenerateContext = GenerateContext;
|
|
417
393
|
_GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(), _GenerateContext_stackTrail = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_runOperationGenerator = function _GenerateContext_runOperationGenerator({ oasDocument, generator }) {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
if (!generator.isSupported({
|
|
435
|
-
operation,
|
|
436
|
-
context: this
|
|
437
|
-
})) {
|
|
438
|
-
return this.captureCurrentResult('notSupported');
|
|
439
|
-
}
|
|
440
|
-
const settings = this.toOperationSettings({
|
|
441
|
-
generatorId: generator.id,
|
|
442
|
-
path,
|
|
443
|
-
method
|
|
444
|
-
});
|
|
445
|
-
if (!settings) {
|
|
446
|
-
return this.captureCurrentResult('notSelected');
|
|
447
|
-
}
|
|
448
|
-
gatewayInstance.transformOperation(operation);
|
|
449
|
-
this.captureCurrentResult('success');
|
|
450
|
-
});
|
|
451
|
-
});
|
|
452
|
-
return this.defineAndRegister({
|
|
453
|
-
identifier: gatewaySettings.identifier,
|
|
454
|
-
value: gatewayInstance,
|
|
455
|
-
destinationPath: gatewaySettings.exportPath
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
if (generator._class === 'OperationInsertable') {
|
|
459
|
-
return oasDocument.operations.forEach(operation => {
|
|
460
|
-
// TODO If we make OasOperation generic, for example by
|
|
461
|
-
// adding a `method` type, we could make isSupported
|
|
462
|
-
// a type guard which could help us narrow down the
|
|
463
|
-
// exact operation type that a generator receives.
|
|
464
|
-
// This would allow us to remove some type checks
|
|
465
|
-
// in the generator implementations
|
|
466
|
-
// https://linear.app/skmtc/issue/SKM-32/generic-models-operations
|
|
467
|
-
const { path, method } = operation;
|
|
468
|
-
this.trace([path, method], () => {
|
|
469
|
-
if (!generator.isSupported({ operation, context: this })) {
|
|
470
|
-
return this.captureCurrentResult('notSupported');
|
|
471
|
-
}
|
|
472
|
-
const settings = this.toOperationSettings({
|
|
473
|
-
generatorId: generator.id,
|
|
474
|
-
path,
|
|
475
|
-
method
|
|
476
|
-
});
|
|
477
|
-
if (!settings) {
|
|
478
|
-
return this.captureCurrentResult('notSelected');
|
|
479
|
-
}
|
|
480
|
-
this.insertOperation({ insertable: generator, operation });
|
|
481
|
-
this.captureCurrentResult('success');
|
|
394
|
+
return oasDocument.operations.forEach(operation => {
|
|
395
|
+
// TODO If we make OasOperation generic, for example by
|
|
396
|
+
// adding a `method` type, we could make isSupported
|
|
397
|
+
// a type guard which could help us narrow down the
|
|
398
|
+
// exact operation type that a generator receives.
|
|
399
|
+
// This would allow us to remove some type checks
|
|
400
|
+
// in the generator implementations
|
|
401
|
+
// https://linear.app/skmtc/issue/SKM-32/generic-models-operations
|
|
402
|
+
this.trace([operation.path, operation.method], () => {
|
|
403
|
+
if (!generator.isSupported({ operation, context: this })) {
|
|
404
|
+
return this.captureCurrentResult('notSupported');
|
|
405
|
+
}
|
|
406
|
+
const settings = this.toOperationSettings({
|
|
407
|
+
generatorId: generator.id,
|
|
408
|
+
path: operation.path,
|
|
409
|
+
method: operation.method
|
|
482
410
|
});
|
|
411
|
+
if (!settings) {
|
|
412
|
+
return this.captureCurrentResult('notSelected');
|
|
413
|
+
}
|
|
414
|
+
this.insertOperation({ insertable: generator, operation });
|
|
415
|
+
this.captureCurrentResult('success');
|
|
483
416
|
});
|
|
484
|
-
}
|
|
485
|
-
throw new Error(`Unknown generator type`);
|
|
417
|
+
});
|
|
486
418
|
}, _GenerateContext_runModelGenerator = function _GenerateContext_runModelGenerator({ oasDocument, generator }) {
|
|
487
419
|
const refNames = oasDocument.components?.toSchemasRefNames() ?? [];
|
|
488
420
|
return refNames.forEach(refName => {
|
|
@@ -12,10 +12,6 @@ export type OperationInsertableArgs<EnrichmentType> = {
|
|
|
12
12
|
export type WithTransformOperation = {
|
|
13
13
|
transformOperation: (operation: OasOperation) => void;
|
|
14
14
|
};
|
|
15
|
-
export type OperationOperationGatewayArgs<EnrichmentType> = {
|
|
16
|
-
context: GenerateContext;
|
|
17
|
-
settings: ContentSettings<EnrichmentType>;
|
|
18
|
-
};
|
|
19
15
|
export type IsSupportedOperationConfigArgs<EnrichmentType> = {
|
|
20
16
|
context: GenerateContext;
|
|
21
17
|
operation: OasOperation;
|
|
@@ -29,18 +25,6 @@ type ToEnrichmentsArgs = {
|
|
|
29
25
|
operation: OasOperation;
|
|
30
26
|
context: GenerateContext;
|
|
31
27
|
};
|
|
32
|
-
export type OperationGateway<EnrichmentType> = {
|
|
33
|
-
new ({ context, settings }: OperationOperationGatewayArgs<EnrichmentType>): WithTransformOperation;
|
|
34
|
-
id: string;
|
|
35
|
-
type: 'operation';
|
|
36
|
-
_class: 'OperationGateway';
|
|
37
|
-
toIdentifier: () => Identifier;
|
|
38
|
-
toExportPath: () => string;
|
|
39
|
-
toEnrichmentRequest?: <RequestedEnrichment extends EnrichmentType>(operation: OasOperation) => EnrichmentRequest<RequestedEnrichment> | undefined;
|
|
40
|
-
toEnrichmentSchema: () => z.ZodType<EnrichmentType>;
|
|
41
|
-
toEnrichments: ({ operation, context }: ToEnrichmentsArgs) => EnrichmentType;
|
|
42
|
-
isSupported: ({ context, operation }: IsSupportedOperationArgs) => boolean;
|
|
43
|
-
};
|
|
44
28
|
export type OperationInsertable<V, EnrichmentType> = {
|
|
45
29
|
prototype: V;
|
|
46
30
|
} & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationInsertable.d.ts","sourceRoot":"","sources":["../../../src/dsl/operation/OperationInsertable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,MAAM,MAAM,uBAAuB,CAAC,cAAc,IAAI;IACpD,OAAO,EAAE,eAAe,CAAA;IACxB,QAAQ,EAAE,eAAe,CAAC,cAAc,CAAC,CAAA;IACzC,SAAS,EAAE,YAAY,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,kBAAkB,EAAE,CAAC,SAAS,EAAE,YAAY,KAAK,IAAI,CAAA;CACtD,CAAA;AAED,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"OperationInsertable.d.ts","sourceRoot":"","sources":["../../../src/dsl/operation/OperationInsertable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,MAAM,MAAM,uBAAuB,CAAC,cAAc,IAAI;IACpD,OAAO,EAAE,eAAe,CAAA;IACxB,QAAQ,EAAE,eAAe,CAAC,cAAc,CAAC,CAAA;IACzC,SAAS,EAAE,YAAY,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,kBAAkB,EAAE,CAAC,SAAS,EAAE,YAAY,KAAK,IAAI,CAAA;CACtD,CAAA;AAED,MAAM,MAAM,8BAA8B,CAAC,cAAc,IAAI;IAC3D,OAAO,EAAE,eAAe,CAAA;IACxB,SAAS,EAAE,YAAY,CAAA;IACvB,WAAW,EAAE,cAAc,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,eAAe,CAAA;IACxB,SAAS,EAAE,YAAY,CAAA;CACxB,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,SAAS,EAAE,YAAY,CAAA;IACvB,OAAO,EAAE,eAAe,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,mBAAmB,CAAC,CAAC,EAAE,cAAc,IAAI;IAAE,SAAS,EAAE,CAAC,CAAA;CAAE,GAAG;IACtE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,uBAAuB,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;IAClF,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,WAAW,CAAA;IACjB,MAAM,EAAE,qBAAqB,CAAA;IAC7B,YAAY,EAAE,CAAC,SAAS,EAAE,YAAY,KAAK,UAAU,CAAA;IACrD,YAAY,EAAE,CAAC,SAAS,EAAE,YAAY,KAAK,MAAM,CAAA;IACjD,mBAAmB,CAAC,EAAE,CAAC,mBAAmB,SAAS,cAAc,EAC/D,SAAS,EAAE,YAAY,KACpB,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAA;IACvD,kBAAkB,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IACnD,aAAa,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,iBAAiB,KAAK,cAAc,CAAA;IAC5E,WAAW,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,wBAAwB,KAAK,OAAO,CAAA;CAE3E,GAAG,QAAQ,CAAA"}
|
|
@@ -73,8 +73,8 @@ const toOperationInsertable = (config) => {
|
|
|
73
73
|
path: operation.path,
|
|
74
74
|
method: operation.method
|
|
75
75
|
});
|
|
76
|
-
const
|
|
77
|
-
return
|
|
76
|
+
const enrichmentSchema = config.toEnrichmentSchema?.();
|
|
77
|
+
return enrichmentSchema?.parse(generatorSettings.enrichments);
|
|
78
78
|
}
|
|
79
79
|
}),
|
|
80
80
|
Object.defineProperty(_a, "isSupported", {
|
package/script/mod.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export * from './dsl/constants.js';
|
|
|
6
6
|
export * from './dsl/ContentSettings.js';
|
|
7
7
|
export * from './dsl/Definition.js';
|
|
8
8
|
export * from './dsl/EntityType.js';
|
|
9
|
-
export * from './dsl/GatewayBase.js';
|
|
10
9
|
export * from './dsl/GeneratedValueList.js';
|
|
11
10
|
export * from './dsl/Identifier.js';
|
|
12
11
|
export * from './dsl/Import.js';
|
|
@@ -18,7 +17,6 @@ export * from './dsl/model/toModelInsertable.js';
|
|
|
18
17
|
export * from './dsl/operation/OperationBase.js';
|
|
19
18
|
export * from './dsl/operation/OperationDriver.js';
|
|
20
19
|
export * from './dsl/operation/OperationInsertable.js';
|
|
21
|
-
export * from './dsl/operation/toOperationGateway.js';
|
|
22
20
|
export * from './dsl/operation/toOperationInsertable.js';
|
|
23
21
|
export * from './dsl/Stringable.js';
|
|
24
22
|
export * from './dsl/ValueBase.js';
|
package/script/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,kCAAkC,CAAA;AAChD,cAAc,kCAAkC,CAAA;AAChD,cAAc,oCAAoC,CAAA;AAClD,cAAc,wCAAwC,CAAA;AACtD,cAAc,0CAA0C,CAAA;AACxD,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qCAAqC,CAAA;AACnD,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sCAAsC,CAAA;AACpD,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,oCAAoC,CAAA;AAClD,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,kBAAkB,CAAA;AAChC,cAAc,kCAAkC,CAAA;AAChD,cAAc,4BAA4B,CAAA;AAC1C,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,mCAAmC,CAAA;AACjD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uCAAuC,CAAA;AACrD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iCAAiC,CAAA"}
|
package/script/mod.js
CHANGED
|
@@ -22,7 +22,6 @@ __exportStar(require("./dsl/constants.js"), exports);
|
|
|
22
22
|
__exportStar(require("./dsl/ContentSettings.js"), exports);
|
|
23
23
|
__exportStar(require("./dsl/Definition.js"), exports);
|
|
24
24
|
__exportStar(require("./dsl/EntityType.js"), exports);
|
|
25
|
-
__exportStar(require("./dsl/GatewayBase.js"), exports);
|
|
26
25
|
__exportStar(require("./dsl/GeneratedValueList.js"), exports);
|
|
27
26
|
__exportStar(require("./dsl/Identifier.js"), exports);
|
|
28
27
|
__exportStar(require("./dsl/Import.js"), exports);
|
|
@@ -34,7 +33,6 @@ __exportStar(require("./dsl/model/toModelInsertable.js"), exports);
|
|
|
34
33
|
__exportStar(require("./dsl/operation/OperationBase.js"), exports);
|
|
35
34
|
__exportStar(require("./dsl/operation/OperationDriver.js"), exports);
|
|
36
35
|
__exportStar(require("./dsl/operation/OperationInsertable.js"), exports);
|
|
37
|
-
__exportStar(require("./dsl/operation/toOperationGateway.js"), exports);
|
|
38
36
|
__exportStar(require("./dsl/operation/toOperationInsertable.js"), exports);
|
|
39
37
|
__exportStar(require("./dsl/Stringable.js"), exports);
|
|
40
38
|
__exportStar(require("./dsl/ValueBase.js"), exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { EnrichmentRequest } from '../types/EnrichmentRequest.js';
|
|
2
|
-
export declare const handleEnrichment: <EnrichmentType>({ prompt, content,
|
|
2
|
+
export declare const handleEnrichment: <EnrichmentType>({ prompt, content, enrichmentSchema: zodResponseSchema }: EnrichmentRequest<EnrichmentType>) => Promise<string>;
|
|
3
3
|
export declare function removeProperties<T extends Record<string, any>>(obj: T, propertyName: string): Partial<T>;
|
|
4
4
|
//# sourceMappingURL=handleEnrichment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleEnrichment.d.ts","sourceRoot":"","sources":["../../src/run/handleEnrichment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAetE,eAAO,MAAM,gBAAgB,GAAU,cAAc,
|
|
1
|
+
{"version":3,"file":"handleEnrichment.d.ts","sourceRoot":"","sources":["../../src/run/handleEnrichment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAetE,eAAO,MAAM,gBAAgB,GAAU,cAAc,4DAIlD,iBAAiB,CAAC,cAAc,CAAC,oBAmBnC,CAAA;AAGD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5D,GAAG,EAAE,CAAC,EACN,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,CAAC,CAyBZ"}
|
|
@@ -36,8 +36,8 @@ const genAI = new generative_ai_1.GoogleGenerativeAI(apiKey);
|
|
|
36
36
|
const model = genAI.getGenerativeModel({
|
|
37
37
|
model: 'gemini-1.5-flash'
|
|
38
38
|
});
|
|
39
|
-
const handleEnrichment = async ({ prompt, content,
|
|
40
|
-
const
|
|
39
|
+
const handleEnrichment = async ({ prompt, content, enrichmentSchema: zodResponseSchema }) => {
|
|
40
|
+
const enrichmentSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(zodResponseSchema, {
|
|
41
41
|
target: 'openApi3'
|
|
42
42
|
});
|
|
43
43
|
const chatSession = model.startChat({
|
|
@@ -47,7 +47,7 @@ const handleEnrichment = async ({ prompt, content, responseSchema: zodResponseSc
|
|
|
47
47
|
topK: 40,
|
|
48
48
|
maxOutputTokens: 8192,
|
|
49
49
|
responseMimeType: 'application/json',
|
|
50
|
-
responseSchema: removeProperties(
|
|
50
|
+
responseSchema: removeProperties(enrichmentSchema, 'additionalProperties')
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
const result = await chatSession.sendMessage(`${prompt}\n\n${content}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toSettings.d.ts","sourceRoot":"","sources":["../../src/run/toSettings.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAmB,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"toSettings.d.ts","sourceRoot":"","sources":["../../src/run/toSettings.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAmB,MAAM,sBAAsB,CAAA;AACpG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAE9D,KAAK,cAAc,CAAC,cAAc,IAAI;IACpC,UAAU,EAAE,aAAa,CAAC,cAAc,CAAC,EAAE,CAAA;IAC3C,cAAc,EAAE,cAAc,GAAG,SAAS,CAAA;IAC1C,eAAe,EAAE,OAAO,CAAA;IACxB,WAAW,EAAE,WAAW,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,cAAc,gEAKtC,cAAc,CAAC,cAAc,CAAC,8BAuChC,CAAA"}
|
package/script/run/toSettings.js
CHANGED
|
@@ -8,52 +8,32 @@ const toSettings = ({ generators, clientSettings, defaultSelected, oasDocument }
|
|
|
8
8
|
const generatorType = generator.type;
|
|
9
9
|
return (0, ts_pattern_1.match)(generatorType)
|
|
10
10
|
.with('operation', () => {
|
|
11
|
-
if (!generatorSettings) {
|
|
12
|
-
return {
|
|
13
|
-
id: generator.id,
|
|
14
|
-
operations: toOperations({
|
|
15
|
-
generator: generator,
|
|
16
|
-
oasDocument,
|
|
17
|
-
defaultSelected,
|
|
18
|
-
operationsSettings: undefined
|
|
19
|
-
})
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
11
|
return {
|
|
23
12
|
...generatorSettings,
|
|
24
13
|
id: generator.id,
|
|
25
14
|
operations: toOperations({
|
|
26
|
-
generator: generator,
|
|
27
15
|
oasDocument,
|
|
28
16
|
defaultSelected,
|
|
29
|
-
operationsSettings: 'operations' in generatorSettings
|
|
17
|
+
operationsSettings: generatorSettings && 'operations' in generatorSettings
|
|
18
|
+
? generatorSettings.operations
|
|
19
|
+
: undefined
|
|
30
20
|
})
|
|
31
21
|
};
|
|
32
22
|
})
|
|
33
23
|
.with('model', () => {
|
|
34
|
-
if (!generatorSettings) {
|
|
35
|
-
return {
|
|
36
|
-
id: generator.id,
|
|
37
|
-
models: toModels({
|
|
38
|
-
oasDocument,
|
|
39
|
-
defaultSelected,
|
|
40
|
-
modelsSettings: undefined
|
|
41
|
-
})
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
24
|
return {
|
|
45
25
|
...generatorSettings,
|
|
46
26
|
id: generator.id,
|
|
47
27
|
models: toModels({
|
|
48
28
|
oasDocument,
|
|
49
29
|
defaultSelected,
|
|
50
|
-
modelsSettings: 'models' in generatorSettings
|
|
30
|
+
modelsSettings: generatorSettings && 'models' in generatorSettings
|
|
31
|
+
? generatorSettings.models
|
|
32
|
+
: undefined
|
|
51
33
|
})
|
|
52
34
|
};
|
|
53
35
|
})
|
|
54
|
-
.
|
|
55
|
-
throw new Error(`Invalid generator type: '${matched}' for ${generator.id}`);
|
|
56
|
-
});
|
|
36
|
+
.exhaustive();
|
|
57
37
|
});
|
|
58
38
|
return generatorsSettings;
|
|
59
39
|
};
|
|
@@ -2,7 +2,7 @@ import "../_dnt.polyfills.js";
|
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
export type EnrichmentRequest<EnrichmentType> = {
|
|
4
4
|
prompt: string;
|
|
5
|
-
|
|
5
|
+
enrichmentSchema: z.ZodType<EnrichmentType>;
|
|
6
6
|
content: string;
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=EnrichmentRequest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnrichmentRequest.d.ts","sourceRoot":"","sources":["../../src/types/EnrichmentRequest.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,MAAM,MAAM,iBAAiB,CAAC,cAAc,IAAI;IAC9C,MAAM,EAAE,MAAM,CAAA;IACd,
|
|
1
|
+
{"version":3,"file":"EnrichmentRequest.d.ts","sourceRoot":"","sources":["../../src/types/EnrichmentRequest.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,MAAM,MAAM,iBAAiB,CAAC,cAAc,IAAI;IAC9C,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IAC3C,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { OperationGateway } from '../dsl/operation/OperationInsertable.js';
|
|
2
1
|
import type { OperationInsertable } from '../dsl/operation/OperationInsertable.js';
|
|
3
2
|
import type { ModelInsertable } from '../dsl/model/ModelInsertable.js';
|
|
4
3
|
import type { GeneratedValue } from './GeneratedValue.js';
|
|
5
|
-
export type GeneratorType<EnrichmentType> =
|
|
4
|
+
export type GeneratorType<EnrichmentType> = OperationInsertable<GeneratedValue, EnrichmentType> | ModelInsertable<GeneratedValue, EnrichmentType>;
|
|
6
5
|
export type GeneratorsMap<G extends GeneratorType<EnrichmentType>, EnrichmentType> = {
|
|
7
6
|
[K in keyof G]: G[K];
|
|
8
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeneratorType.d.ts","sourceRoot":"","sources":["../../src/types/GeneratorType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"GeneratorType.d.ts","sourceRoot":"","sources":["../../src/types/GeneratorType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEzD,MAAM,MAAM,aAAa,CAAC,cAAc,IACpC,mBAAmB,CAAC,cAAc,EAAE,cAAc,CAAC,GACnD,eAAe,CAAC,cAAc,EAAE,cAAc,CAAC,CAAA;AAEnD,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,aAAa,CAAC,cAAc,CAAC,EAAE,cAAc,IAAI;KAClF,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACrB,CAAA"}
|
package/esm/dsl/GatewayBase.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { GenerateContext, RegisterArgs } from '../context/GenerateContext.js';
|
|
2
|
-
import type { ContentSettings } from './ContentSettings.js';
|
|
3
|
-
import { ValueBase } from './ValueBase.js';
|
|
4
|
-
export type OperationGatewayArgs = {
|
|
5
|
-
context: GenerateContext;
|
|
6
|
-
settings: ContentSettings<undefined>;
|
|
7
|
-
};
|
|
8
|
-
export declare class GatewayBase extends ValueBase {
|
|
9
|
-
settings: ContentSettings<undefined>;
|
|
10
|
-
constructor({ context, settings }: OperationGatewayArgs);
|
|
11
|
-
register(args: Omit<RegisterArgs, 'destinationPath'>): void;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=GatewayBase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayBase.d.ts","sourceRoot":"","sources":["../../src/dsl/GatewayBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,eAAe,CAAA;IACxB,QAAQ,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;CACrC,CAAA;AAED,qBAAa,WAAY,SAAQ,SAAS;IACxC,QAAQ,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;gBAExB,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,oBAAoB;IAM9C,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,iBAAiB,CAAC;CAM9D"}
|
package/esm/dsl/GatewayBase.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ValueBase } from './ValueBase.js';
|
|
2
|
-
export class GatewayBase extends ValueBase {
|
|
3
|
-
constructor({ context, settings }) {
|
|
4
|
-
super({ context });
|
|
5
|
-
Object.defineProperty(this, "settings", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
configurable: true,
|
|
8
|
-
writable: true,
|
|
9
|
-
value: void 0
|
|
10
|
-
});
|
|
11
|
-
this.settings = settings;
|
|
12
|
-
}
|
|
13
|
-
register(args) {
|
|
14
|
-
this.context.register({
|
|
15
|
-
...args,
|
|
16
|
-
destinationPath: this.settings.exportPath
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { OasOperation } from '../../oas/operation/Operation.js';
|
|
2
|
-
import { type OperationGatewayArgs } from '../GatewayBase.js';
|
|
3
|
-
import type { Identifier } from '../Identifier.js';
|
|
4
|
-
import type { EnrichmentRequest } from '../../types/EnrichmentRequest.js';
|
|
5
|
-
import type { IsSupportedOperationConfigArgs, IsSupportedOperationArgs } from './OperationInsertable.js';
|
|
6
|
-
import type { GenerateContext } from '../../context/GenerateContext.js';
|
|
7
|
-
import type { z } from 'zod';
|
|
8
|
-
export type ToOperationGatewayArgs<EnrichmentType> = {
|
|
9
|
-
id: string;
|
|
10
|
-
toIdentifier: () => Identifier;
|
|
11
|
-
toExportPath: () => string;
|
|
12
|
-
isSupported?: ({ context, operation, enrichments }: IsSupportedOperationConfigArgs<EnrichmentType>) => boolean;
|
|
13
|
-
toEnrichmentRequest?: <RequestedEnrichment extends EnrichmentType>(operation: OasOperation) => EnrichmentRequest<RequestedEnrichment> | undefined;
|
|
14
|
-
toEnrichmentSchema: () => z.ZodType<EnrichmentType>;
|
|
15
|
-
};
|
|
16
|
-
type ToEnrichmentsArgs = {
|
|
17
|
-
operation: OasOperation;
|
|
18
|
-
context: GenerateContext;
|
|
19
|
-
};
|
|
20
|
-
export declare const toOperationGateway: <EnrichmentType>(config: ToOperationGatewayArgs<EnrichmentType>) => {
|
|
21
|
-
new ({ context, settings }: OperationGatewayArgs): {
|
|
22
|
-
settings: import("../ContentSettings.js").ContentSettings<undefined>;
|
|
23
|
-
register(args: Omit<import("../../context/GenerateContext.js").RegisterArgs, "destinationPath">): void;
|
|
24
|
-
context: GenerateContext;
|
|
25
|
-
skipped: boolean;
|
|
26
|
-
generatorKey: import("../../mod.js").GeneratorKey | undefined;
|
|
27
|
-
};
|
|
28
|
-
id: string;
|
|
29
|
-
type: "operation";
|
|
30
|
-
_class: "OperationGateway";
|
|
31
|
-
toIdentifier: () => Identifier;
|
|
32
|
-
toExportPath: () => string;
|
|
33
|
-
toEnrichmentRequest: (<RequestedEnrichment extends EnrichmentType>(operation: OasOperation) => EnrichmentRequest<RequestedEnrichment> | undefined) | undefined;
|
|
34
|
-
toEnrichmentSchema: () => z.ZodType<EnrichmentType>;
|
|
35
|
-
toEnrichments: ({ operation, context }: ToEnrichmentsArgs) => EnrichmentType;
|
|
36
|
-
isSupported: ({ context, operation }: IsSupportedOperationArgs) => boolean;
|
|
37
|
-
};
|
|
38
|
-
export {};
|
|
39
|
-
//# sourceMappingURL=toOperationGateway.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toOperationGateway.d.ts","sourceRoot":"","sources":["../../../src/dsl/operation/toOperationGateway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAe,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,EACV,8BAA8B,EAC9B,wBAAwB,EACzB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,MAAM,MAAM,sBAAsB,CAAC,cAAc,IAAI;IACnD,EAAE,EAAE,MAAM,CAAA;IACV,YAAY,EAAE,MAAM,UAAU,CAAA;IAC9B,YAAY,EAAE,MAAM,MAAM,CAAA;IAC1B,WAAW,CAAC,EAAE,CAAC,EACb,OAAO,EACP,SAAS,EACT,WAAW,EACZ,EAAE,8BAA8B,CAAC,cAAc,CAAC,KAAK,OAAO,CAAA;IAC7D,mBAAmB,CAAC,EAAE,CAAC,mBAAmB,SAAS,cAAc,EAC/D,SAAS,EAAE,YAAY,KACpB,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAA;IACvD,kBAAkB,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;CACpD,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,SAAS,EAAE,YAAY,CAAA;IACvB,OAAO,EAAE,eAAe,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,cAAc,UACvC,sBAAsB,CAAC,cAAc,CAAC;gCAkCT,oBAAoB;;;;;;;;;;wBArDrC,UAAU;wBACV,MAAM;2BAMH,mBAAmB,oCAC7B,YAAY,KACpB,iBAAiB,qBAAqB,GAAG,SAAS;8BAC7B,CAAC,CAAC,OAAO,gBAAgB;4CAqBD,iBAAiB,KAAG,cAAc;0CAYpC,wBAAwB;CAgBzE,CAAA"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
2
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
3
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
4
|
-
};
|
|
5
|
-
import { GatewayBase } from '../GatewayBase.js';
|
|
6
|
-
export const toOperationGateway = (config) => {
|
|
7
|
-
var _a;
|
|
8
|
-
const OperationGateway = (_a = class extends GatewayBase {
|
|
9
|
-
constructor({ context, settings }) {
|
|
10
|
-
super({ context, settings });
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
__setFunctionName(_a, "OperationGateway"),
|
|
14
|
-
Object.defineProperty(_a, "id", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: config.id
|
|
19
|
-
}),
|
|
20
|
-
Object.defineProperty(_a, "type", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: 'operation'
|
|
25
|
-
}),
|
|
26
|
-
Object.defineProperty(_a, "_class", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
configurable: true,
|
|
29
|
-
writable: true,
|
|
30
|
-
value: 'OperationGateway'
|
|
31
|
-
}),
|
|
32
|
-
Object.defineProperty(_a, "toIdentifier", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
configurable: true,
|
|
35
|
-
writable: true,
|
|
36
|
-
value: config.toIdentifier.bind(config)
|
|
37
|
-
}),
|
|
38
|
-
Object.defineProperty(_a, "toExportPath", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true,
|
|
41
|
-
writable: true,
|
|
42
|
-
value: config.toExportPath.bind(config)
|
|
43
|
-
}),
|
|
44
|
-
Object.defineProperty(_a, "toEnrichmentRequest", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
configurable: true,
|
|
47
|
-
writable: true,
|
|
48
|
-
value: config.toEnrichmentRequest?.bind(config)
|
|
49
|
-
}),
|
|
50
|
-
Object.defineProperty(_a, "toEnrichmentSchema", {
|
|
51
|
-
enumerable: true,
|
|
52
|
-
configurable: true,
|
|
53
|
-
writable: true,
|
|
54
|
-
value: config.toEnrichmentSchema.bind(config)
|
|
55
|
-
}),
|
|
56
|
-
Object.defineProperty(_a, "toEnrichments", {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
configurable: true,
|
|
59
|
-
writable: true,
|
|
60
|
-
value: ({ operation, context }) => {
|
|
61
|
-
const generatorSettings = context.toOperationSettings({
|
|
62
|
-
generatorId: config.id,
|
|
63
|
-
path: operation.path,
|
|
64
|
-
method: operation.method
|
|
65
|
-
});
|
|
66
|
-
const responseSchema = config.toEnrichmentSchema?.();
|
|
67
|
-
return responseSchema?.parse(generatorSettings.enrichments);
|
|
68
|
-
}
|
|
69
|
-
}),
|
|
70
|
-
Object.defineProperty(_a, "isSupported", {
|
|
71
|
-
enumerable: true,
|
|
72
|
-
configurable: true,
|
|
73
|
-
writable: true,
|
|
74
|
-
value: ({ context, operation }) => {
|
|
75
|
-
if (typeof config.isSupported !== 'function') {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
const enrichments = OperationGateway.toEnrichments({ operation, context });
|
|
79
|
-
return config.isSupported({ context, operation, enrichments });
|
|
80
|
-
}
|
|
81
|
-
}),
|
|
82
|
-
_a);
|
|
83
|
-
return OperationGateway;
|
|
84
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { GenerateContext, RegisterArgs } from '../context/GenerateContext.js';
|
|
2
|
-
import type { ContentSettings } from './ContentSettings.js';
|
|
3
|
-
import { ValueBase } from './ValueBase.js';
|
|
4
|
-
export type OperationGatewayArgs = {
|
|
5
|
-
context: GenerateContext;
|
|
6
|
-
settings: ContentSettings<undefined>;
|
|
7
|
-
};
|
|
8
|
-
export declare class GatewayBase extends ValueBase {
|
|
9
|
-
settings: ContentSettings<undefined>;
|
|
10
|
-
constructor({ context, settings }: OperationGatewayArgs);
|
|
11
|
-
register(args: Omit<RegisterArgs, 'destinationPath'>): void;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=GatewayBase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayBase.d.ts","sourceRoot":"","sources":["../../src/dsl/GatewayBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,eAAe,CAAA;IACxB,QAAQ,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;CACrC,CAAA;AAED,qBAAa,WAAY,SAAQ,SAAS;IACxC,QAAQ,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;gBAExB,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,oBAAoB;IAM9C,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,iBAAiB,CAAC;CAM9D"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GatewayBase = void 0;
|
|
4
|
-
const ValueBase_js_1 = require("./ValueBase.js");
|
|
5
|
-
class GatewayBase extends ValueBase_js_1.ValueBase {
|
|
6
|
-
constructor({ context, settings }) {
|
|
7
|
-
super({ context });
|
|
8
|
-
Object.defineProperty(this, "settings", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: void 0
|
|
13
|
-
});
|
|
14
|
-
this.settings = settings;
|
|
15
|
-
}
|
|
16
|
-
register(args) {
|
|
17
|
-
this.context.register({
|
|
18
|
-
...args,
|
|
19
|
-
destinationPath: this.settings.exportPath
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.GatewayBase = GatewayBase;
|