@skmtc/core 0.0.555 → 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/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +3 -4
- 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/esm/types/Manifest.d.ts +18 -27
- package/esm/types/Manifest.d.ts.map +1 -1
- package/esm/types/Manifest.js +2 -3
- 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/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +3 -4
- 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/script/types/Manifest.d.ts +18 -27
- package/script/types/Manifest.d.ts.map +1 -1
- package/script/types/Manifest.js +2 -3
- 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
|
@@ -3,9 +3,9 @@ import { 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 {
|
|
6
|
+
import type { ClientSettings, EnrichedSetting } from '../types/Settings.js';
|
|
7
7
|
import type { Method } from '../types/Method.js';
|
|
8
|
-
import type { OperationInsertable
|
|
8
|
+
import type { OperationInsertable } from '../dsl/operation/OperationInsertable.js';
|
|
9
9
|
import type { OasOperation } from '../oas/operation/Operation.js';
|
|
10
10
|
import type { ModelInsertable } from '../dsl/model/ModelInsertable.js';
|
|
11
11
|
import type { GenerationType, GeneratedValue } from '../types/GeneratedValue.js';
|
|
@@ -204,15 +204,6 @@ export declare class GenerateContext {
|
|
|
204
204
|
* @returns Content settings for model
|
|
205
205
|
*/
|
|
206
206
|
toModelContentSettings<V, EnrichmentType>({ refName, insertable }: BuildModelSettingsArgs<V, EnrichmentType>): ContentSettings<EnrichmentType>;
|
|
207
|
-
/**
|
|
208
|
-
* Generate and return content settings for a gateway
|
|
209
|
-
*
|
|
210
|
-
* Content settings are produced by passing base settings
|
|
211
|
-
* through toIdentifier, toExportPath methods on the gateway
|
|
212
|
-
* @param gateway
|
|
213
|
-
* @returns Content settings for model
|
|
214
|
-
*/
|
|
215
|
-
toGatewayContentSetting<EnrichmentType>(gateway: OperationGateway<EnrichmentType>): ContentSettings<undefined>;
|
|
216
207
|
/**
|
|
217
208
|
* Look up operation settings for a given generatorId, path and method.
|
|
218
209
|
* @param { generatorId, path, method }
|
|
@@ -220,7 +211,6 @@ export declare class GenerateContext {
|
|
|
220
211
|
*/
|
|
221
212
|
toOperationSettings({ generatorId, path, method }: GetOperationSettingsArgs): EnrichedSetting;
|
|
222
213
|
toModelSettings({ generatorId, refName }: ToModelSettingsArgs): EnrichedSetting;
|
|
223
|
-
toGeneratorSettings(generatorId: string): ClientGeneratorSettings | undefined;
|
|
224
214
|
/**
|
|
225
215
|
* Perform one lookup of schema by `refName`.
|
|
226
216
|
* @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;AAE/C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"GenerateContext.d.ts","sourceRoot":"","sources":["../../src/context/GenerateContext.ts"],"names":[],"mappings":"AACA,OA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,EACP,UAAU,EACV,eAAe,EAChB,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC;IAYzE;;;;;;;;;OASG;IACH,0BAA0B,CAAC,CAAC,EAAE,cAAc,EAAE,EAC5C,SAAS,EACT,UAAU,EACX,EAAE,uBAAuB,CAAC,CAAC,EAAE,cAAc,CAAC,GAAG,eAAe,CAAC,cAAc,CAAC;IAe/E;;;;;;;;OAQG;IACH,sBAAsB,CAAC,CAAC,EAAE,cAAc,EAAE,EACxC,OAAO,EACP,UAAU,EACX,EAAE,sBAAsB,CAAC,CAAC,EAAE,cAAc,CAAC,GAAG,eAAe,CAAC,cAAc,CAAC;IAc9E;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,wBAAwB,GAAG,eAAe;IAW7F,eAAe,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,mBAAmB,GAAG,eAAe;IAsB/E;;;;;OAKG;IACH,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;IAUpE;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;CAGvE"}
|
|
@@ -21,6 +21,7 @@ import { tracer } from '../helpers/tracer.js';
|
|
|
21
21
|
import { Inserted } from '../dsl/Inserted.js';
|
|
22
22
|
import { File } from '../dsl/File.js';
|
|
23
23
|
import invariant from 'tiny-invariant';
|
|
24
|
+
import { match } from 'ts-pattern';
|
|
24
25
|
export class GenerateContext {
|
|
25
26
|
constructor({ oasDocument, settings, logger, callback, captureCurrentResult, stackTrail, toGeneratorsMap }) {
|
|
26
27
|
_GenerateContext_instances.add(this);
|
|
@@ -78,22 +79,16 @@ export class GenerateContext {
|
|
|
78
79
|
*/
|
|
79
80
|
generate() {
|
|
80
81
|
const generators = Object.values(this.toGeneratorsMap());
|
|
81
|
-
Sentry.startSpan({ name: 'Generate
|
|
82
|
-
.filter(generator => generator.type === 'operation')
|
|
83
|
-
.forEach(generator => {
|
|
82
|
+
Sentry.startSpan({ name: 'Generate' }, () => generators.forEach(generator => {
|
|
84
83
|
this.trace(generator.id, () => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
.filter(generator => generator.type === 'model')
|
|
91
|
-
.forEach(generator => {
|
|
92
|
-
this.trace(generator.id, () => {
|
|
93
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, { oasDocument: this.oasDocument, generator });
|
|
84
|
+
match(generator.type)
|
|
85
|
+
.with('operation', () => __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runOperationGenerator).call(this, { oasDocument: this.oasDocument, generator }))
|
|
86
|
+
.with('model', () => __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, { oasDocument: this.oasDocument, generator }))
|
|
87
|
+
.otherwise(matched => {
|
|
88
|
+
throw new Error(`Invalid generator type: '${matched}' on ${generator.id}`);
|
|
94
89
|
});
|
|
95
90
|
});
|
|
96
|
-
});
|
|
91
|
+
}));
|
|
97
92
|
return {
|
|
98
93
|
files: __classPrivateFieldGet(this, _GenerateContext_files, "f"),
|
|
99
94
|
previews: __classPrivateFieldGet(this, _GenerateContext_previews, "f")
|
|
@@ -322,44 +317,25 @@ export class GenerateContext {
|
|
|
322
317
|
enrichments: insertable.toEnrichments({ refName, context: this })
|
|
323
318
|
});
|
|
324
319
|
}
|
|
325
|
-
/**
|
|
326
|
-
* Generate and return content settings for a gateway
|
|
327
|
-
*
|
|
328
|
-
* Content settings are produced by passing base settings
|
|
329
|
-
* through toIdentifier, toExportPath methods on the gateway
|
|
330
|
-
* @param gateway
|
|
331
|
-
* @returns Content settings for model
|
|
332
|
-
*/
|
|
333
|
-
toGatewayContentSetting(gateway) {
|
|
334
|
-
return new ContentSettings({
|
|
335
|
-
identifier: gateway.toIdentifier(),
|
|
336
|
-
selected: true,
|
|
337
|
-
exportPath: gateway.toExportPath(),
|
|
338
|
-
enrichments: undefined
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
320
|
/**
|
|
342
321
|
* Look up operation settings for a given generatorId, path and method.
|
|
343
322
|
* @param { generatorId, path, method }
|
|
344
323
|
* @returns Base settings for operation
|
|
345
324
|
*/
|
|
346
325
|
toOperationSettings({ generatorId, path, method }) {
|
|
347
|
-
const generatorSettings = this.
|
|
326
|
+
const generatorSettings = this.settings?.generators?.find(({ id }) => id === generatorId);
|
|
348
327
|
const operationSettings = generatorSettings && 'operations' in generatorSettings
|
|
349
328
|
? generatorSettings.operations[path]?.[method]
|
|
350
329
|
: undefined;
|
|
351
330
|
return operationSettings ?? { selected: false, enrichments: undefined };
|
|
352
331
|
}
|
|
353
332
|
toModelSettings({ generatorId, refName }) {
|
|
354
|
-
const generatorSettings = this.
|
|
333
|
+
const generatorSettings = this.settings?.generators?.find(({ id }) => id === generatorId);
|
|
355
334
|
const modelSettings = generatorSettings && 'models' in generatorSettings
|
|
356
335
|
? generatorSettings.models[refName]
|
|
357
336
|
: undefined;
|
|
358
337
|
return modelSettings ?? { selected: false, enrichments: undefined };
|
|
359
338
|
}
|
|
360
|
-
toGeneratorSettings(generatorId) {
|
|
361
|
-
return this.settings?.generators?.find(({ id }) => id === generatorId);
|
|
362
|
-
}
|
|
363
339
|
/**
|
|
364
340
|
* Perform one lookup of schema by `refName`.
|
|
365
341
|
* @param refName
|
|
@@ -385,74 +361,30 @@ export class GenerateContext {
|
|
|
385
361
|
}
|
|
386
362
|
}
|
|
387
363
|
_GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(), _GenerateContext_stackTrail = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_runOperationGenerator = function _GenerateContext_runOperationGenerator({ oasDocument, generator }) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
if (!generator.isSupported({
|
|
405
|
-
operation,
|
|
406
|
-
context: this
|
|
407
|
-
})) {
|
|
408
|
-
return this.captureCurrentResult('notSupported');
|
|
409
|
-
}
|
|
410
|
-
const settings = this.toOperationSettings({
|
|
411
|
-
generatorId: generator.id,
|
|
412
|
-
path,
|
|
413
|
-
method
|
|
414
|
-
});
|
|
415
|
-
if (!settings) {
|
|
416
|
-
return this.captureCurrentResult('notSelected');
|
|
417
|
-
}
|
|
418
|
-
gatewayInstance.transformOperation(operation);
|
|
419
|
-
this.captureCurrentResult('success');
|
|
420
|
-
});
|
|
421
|
-
});
|
|
422
|
-
return this.defineAndRegister({
|
|
423
|
-
identifier: gatewaySettings.identifier,
|
|
424
|
-
value: gatewayInstance,
|
|
425
|
-
destinationPath: gatewaySettings.exportPath
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
if (generator._class === 'OperationInsertable') {
|
|
429
|
-
return oasDocument.operations.forEach(operation => {
|
|
430
|
-
// TODO If we make OasOperation generic, for example by
|
|
431
|
-
// adding a `method` type, we could make isSupported
|
|
432
|
-
// a type guard which could help us narrow down the
|
|
433
|
-
// exact operation type that a generator receives.
|
|
434
|
-
// This would allow us to remove some type checks
|
|
435
|
-
// in the generator implementations
|
|
436
|
-
// https://linear.app/skmtc/issue/SKM-32/generic-models-operations
|
|
437
|
-
const { path, method } = operation;
|
|
438
|
-
this.trace([path, method], () => {
|
|
439
|
-
if (!generator.isSupported({ operation, context: this })) {
|
|
440
|
-
return this.captureCurrentResult('notSupported');
|
|
441
|
-
}
|
|
442
|
-
const settings = this.toOperationSettings({
|
|
443
|
-
generatorId: generator.id,
|
|
444
|
-
path,
|
|
445
|
-
method
|
|
446
|
-
});
|
|
447
|
-
if (!settings) {
|
|
448
|
-
return this.captureCurrentResult('notSelected');
|
|
449
|
-
}
|
|
450
|
-
this.insertOperation({ insertable: generator, operation });
|
|
451
|
-
this.captureCurrentResult('success');
|
|
364
|
+
return oasDocument.operations.forEach(operation => {
|
|
365
|
+
// TODO If we make OasOperation generic, for example by
|
|
366
|
+
// adding a `method` type, we could make isSupported
|
|
367
|
+
// a type guard which could help us narrow down the
|
|
368
|
+
// exact operation type that a generator receives.
|
|
369
|
+
// This would allow us to remove some type checks
|
|
370
|
+
// in the generator implementations
|
|
371
|
+
// https://linear.app/skmtc/issue/SKM-32/generic-models-operations
|
|
372
|
+
this.trace([operation.path, operation.method], () => {
|
|
373
|
+
if (!generator.isSupported({ operation, context: this })) {
|
|
374
|
+
return this.captureCurrentResult('notSupported');
|
|
375
|
+
}
|
|
376
|
+
const settings = this.toOperationSettings({
|
|
377
|
+
generatorId: generator.id,
|
|
378
|
+
path: operation.path,
|
|
379
|
+
method: operation.method
|
|
452
380
|
});
|
|
381
|
+
if (!settings) {
|
|
382
|
+
return this.captureCurrentResult('notSelected');
|
|
383
|
+
}
|
|
384
|
+
this.insertOperation({ insertable: generator, operation });
|
|
385
|
+
this.captureCurrentResult('success');
|
|
453
386
|
});
|
|
454
|
-
}
|
|
455
|
-
throw new Error(`Unknown generator type`);
|
|
387
|
+
});
|
|
456
388
|
}, _GenerateContext_runModelGenerator = function _GenerateContext_runModelGenerator({ oasDocument, generator }) {
|
|
457
389
|
const refNames = oasDocument.components?.toSchemasRefNames() ?? [];
|
|
458
390
|
return refNames.forEach(refName => {
|
|
@@ -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;AAEpE,OAAO,KAAK,EAAE,mBAA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OAAO;IAmDf,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAIlD,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAU/B,eAAe,CAAC,EAAE,YAAY,EAAE,EAAE,mBAAmB;IAarD,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;CAG7D"}
|
|
@@ -147,9 +147,8 @@ const renderFile = ({ content, generatorKeys, destinationPath, basePath }) => {
|
|
|
147
147
|
content,
|
|
148
148
|
path: toResolvedArtifactPath({ basePath, destinationPath }),
|
|
149
149
|
destinationPath,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
generatorKeys
|
|
153
|
-
hash: 'PLACEHOLDER'
|
|
150
|
+
lines: content.split('\n').length,
|
|
151
|
+
characters: content.length,
|
|
152
|
+
generatorKeys
|
|
154
153
|
};
|
|
155
154
|
};
|
|
@@ -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":["../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AAA;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"}
|
|
@@ -70,8 +70,8 @@ export const toOperationInsertable = (config) => {
|
|
|
70
70
|
path: operation.path,
|
|
71
71
|
method: operation.method
|
|
72
72
|
});
|
|
73
|
-
const
|
|
74
|
-
return
|
|
73
|
+
const enrichmentSchema = config.toEnrichmentSchema?.();
|
|
74
|
+
return enrichmentSchema?.parse(generatorSettings.enrichments);
|
|
75
75
|
}
|
|
76
76
|
}),
|
|
77
77
|
Object.defineProperty(_a, "isSupported", {
|
package/esm/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/esm/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;AACn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,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uCAAuC,CAAA;AACrD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iCAAiC,CAAA"}
|
package/esm/mod.js
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';
|
|
@@ -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"}
|
|
@@ -9,8 +9,8 @@ const genAI = new GoogleGenerativeAI(apiKey);
|
|
|
9
9
|
const model = genAI.getGenerativeModel({
|
|
10
10
|
model: 'gemini-1.5-flash'
|
|
11
11
|
});
|
|
12
|
-
export const handleEnrichment = async ({ prompt, content,
|
|
13
|
-
const
|
|
12
|
+
export const handleEnrichment = async ({ prompt, content, enrichmentSchema: zodResponseSchema }) => {
|
|
13
|
+
const enrichmentSchema = zodToJsonSchema(zodResponseSchema, {
|
|
14
14
|
target: 'openApi3'
|
|
15
15
|
});
|
|
16
16
|
const chatSession = model.startChat({
|
|
@@ -20,7 +20,7 @@ export const handleEnrichment = async ({ prompt, content, responseSchema: zodRes
|
|
|
20
20
|
topK: 40,
|
|
21
21
|
maxOutputTokens: 8192,
|
|
22
22
|
responseMimeType: 'application/json',
|
|
23
|
-
responseSchema: removeProperties(
|
|
23
|
+
responseSchema: removeProperties(enrichmentSchema, 'additionalProperties')
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
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/esm/run/toSettings.js
CHANGED
|
@@ -5,52 +5,32 @@ export const toSettings = ({ generators, clientSettings, defaultSelected, oasDoc
|
|
|
5
5
|
const generatorType = generator.type;
|
|
6
6
|
return match(generatorType)
|
|
7
7
|
.with('operation', () => {
|
|
8
|
-
if (!generatorSettings) {
|
|
9
|
-
return {
|
|
10
|
-
id: generator.id,
|
|
11
|
-
operations: toOperations({
|
|
12
|
-
generator: generator,
|
|
13
|
-
oasDocument,
|
|
14
|
-
defaultSelected,
|
|
15
|
-
operationsSettings: undefined
|
|
16
|
-
})
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
8
|
return {
|
|
20
9
|
...generatorSettings,
|
|
21
10
|
id: generator.id,
|
|
22
11
|
operations: toOperations({
|
|
23
|
-
generator: generator,
|
|
24
12
|
oasDocument,
|
|
25
13
|
defaultSelected,
|
|
26
|
-
operationsSettings: 'operations' in generatorSettings
|
|
14
|
+
operationsSettings: generatorSettings && 'operations' in generatorSettings
|
|
15
|
+
? generatorSettings.operations
|
|
16
|
+
: undefined
|
|
27
17
|
})
|
|
28
18
|
};
|
|
29
19
|
})
|
|
30
20
|
.with('model', () => {
|
|
31
|
-
if (!generatorSettings) {
|
|
32
|
-
return {
|
|
33
|
-
id: generator.id,
|
|
34
|
-
models: toModels({
|
|
35
|
-
oasDocument,
|
|
36
|
-
defaultSelected,
|
|
37
|
-
modelsSettings: undefined
|
|
38
|
-
})
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
21
|
return {
|
|
42
22
|
...generatorSettings,
|
|
43
23
|
id: generator.id,
|
|
44
24
|
models: toModels({
|
|
45
25
|
oasDocument,
|
|
46
26
|
defaultSelected,
|
|
47
|
-
modelsSettings: 'models' in generatorSettings
|
|
27
|
+
modelsSettings: generatorSettings && 'models' in generatorSettings
|
|
28
|
+
? generatorSettings.models
|
|
29
|
+
: undefined
|
|
48
30
|
})
|
|
49
31
|
};
|
|
50
32
|
})
|
|
51
|
-
.
|
|
52
|
-
throw new Error(`Invalid generator type: '${matched}' for ${generator.id}`);
|
|
53
|
-
});
|
|
33
|
+
.exhaustive();
|
|
54
34
|
});
|
|
55
35
|
return generatorsSettings;
|
|
56
36
|
};
|
|
@@ -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/types/Manifest.d.ts
CHANGED
|
@@ -4,28 +4,24 @@ import { z } from '@hono/zod-openapi';
|
|
|
4
4
|
import { type ResultsItem } from './Results.js';
|
|
5
5
|
import { type Preview } from './Preview.js';
|
|
6
6
|
export type ManifestEntry = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
hash: string;
|
|
7
|
+
lines: number;
|
|
8
|
+
characters: number;
|
|
10
9
|
generatorKeys: GeneratorKey[];
|
|
11
10
|
destinationPath: string;
|
|
12
11
|
};
|
|
13
12
|
export declare const manifestEntry: z.ZodObject<{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
hash: z.ZodString;
|
|
13
|
+
lines: z.ZodNumber;
|
|
14
|
+
characters: z.ZodNumber;
|
|
17
15
|
generatorKeys: z.ZodArray<z.ZodEffects<z.ZodString, GeneratorKey, string>, "many">;
|
|
18
16
|
destinationPath: z.ZodString;
|
|
19
17
|
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
hash: string;
|
|
18
|
+
lines: number;
|
|
19
|
+
characters: number;
|
|
23
20
|
generatorKeys: GeneratorKey[];
|
|
24
21
|
destinationPath: string;
|
|
25
22
|
}, {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
hash: string;
|
|
23
|
+
lines: number;
|
|
24
|
+
characters: number;
|
|
29
25
|
generatorKeys: string[];
|
|
30
26
|
destinationPath: string;
|
|
31
27
|
}>;
|
|
@@ -60,21 +56,18 @@ export declare const manifestContent: z.ZodObject<{
|
|
|
60
56
|
spanId: z.ZodString;
|
|
61
57
|
region: z.ZodOptional<z.ZodString>;
|
|
62
58
|
files: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
hash: z.ZodString;
|
|
59
|
+
lines: z.ZodNumber;
|
|
60
|
+
characters: z.ZodNumber;
|
|
66
61
|
generatorKeys: z.ZodArray<z.ZodEffects<z.ZodString, GeneratorKey, string>, "many">;
|
|
67
62
|
destinationPath: z.ZodString;
|
|
68
63
|
}, "strip", z.ZodTypeAny, {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
hash: string;
|
|
64
|
+
lines: number;
|
|
65
|
+
characters: number;
|
|
72
66
|
generatorKeys: GeneratorKey[];
|
|
73
67
|
destinationPath: string;
|
|
74
68
|
}, {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
hash: string;
|
|
69
|
+
lines: number;
|
|
70
|
+
characters: number;
|
|
78
71
|
generatorKeys: string[];
|
|
79
72
|
destinationPath: string;
|
|
80
73
|
}>>;
|
|
@@ -191,9 +184,8 @@ export declare const manifestContent: z.ZodObject<{
|
|
|
191
184
|
traceId: string;
|
|
192
185
|
spanId: string;
|
|
193
186
|
files: Record<string, {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
hash: string;
|
|
187
|
+
lines: number;
|
|
188
|
+
characters: number;
|
|
197
189
|
generatorKeys: GeneratorKey[];
|
|
198
190
|
destinationPath: string;
|
|
199
191
|
}>;
|
|
@@ -231,9 +223,8 @@ export declare const manifestContent: z.ZodObject<{
|
|
|
231
223
|
traceId: string;
|
|
232
224
|
spanId: string;
|
|
233
225
|
files: Record<string, {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
hash: string;
|
|
226
|
+
lines: number;
|
|
227
|
+
characters: number;
|
|
237
228
|
generatorKeys: string[];
|
|
238
229
|
destinationPath: string;
|
|
239
230
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Manifest.d.ts","sourceRoot":"","sources":["../../src/types/Manifest.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AACrC,OAAO,EAAsC,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AACnF,OAAO,EAAW,KAAK,OAAO,EAAE,MAAM,cAAc,CAAA;AAEpD,MAAM,MAAM,aAAa,GAAG;IAC1B,
|
|
1
|
+
{"version":3,"file":"Manifest.d.ts","sourceRoot":"","sources":["../../src/types/Manifest.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AACrC,OAAO,EAAsC,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AACnF,OAAO,EAAW,KAAK,OAAO,EAAE,MAAM,cAAc,CAAA;AAEpD,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,YAAY,EAAE,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;EAOC,CAAA;AAE3B,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;EAKC,CAAA;AACzB,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACpC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,OAAO,EAAE,WAAW,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYC,CAAA"}
|
package/esm/types/Manifest.js
CHANGED
|
@@ -5,9 +5,8 @@ import { resultsItem, resultsItemJsonSchema } from './Results.js';
|
|
|
5
5
|
import { preview } from './Preview.js';
|
|
6
6
|
export const manifestEntry = z
|
|
7
7
|
.object({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
hash: z.string(),
|
|
8
|
+
lines: z.number(),
|
|
9
|
+
characters: z.number(),
|
|
11
10
|
generatorKeys: z.array(z.string().refine(isGeneratorKey)),
|
|
12
11
|
destinationPath: z.string()
|
|
13
12
|
})
|