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