@mongodb-js/mql-typescript 0.2.0
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/LICENSE +201 -0
- package/bin/runner.js +3 -0
- package/dist/.esm-wrapper.mjs +5 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +50 -0
- package/dist/cli.js.map +1 -0
- package/dist/driverSchema/docs-crawler.d.ts +13 -0
- package/dist/driverSchema/docs-crawler.d.ts.map +1 -0
- package/dist/driverSchema/docs-crawler.js +151 -0
- package/dist/driverSchema/docs-crawler.js.map +1 -0
- package/dist/driverSchema/driver-schema-generator.d.ts +8 -0
- package/dist/driverSchema/driver-schema-generator.d.ts.map +1 -0
- package/dist/driverSchema/driver-schema-generator.js +98 -0
- package/dist/driverSchema/driver-schema-generator.js.map +1 -0
- package/dist/driverSchema/static-schemas.d.ts +9 -0
- package/dist/driverSchema/static-schemas.d.ts.map +1 -0
- package/dist/driverSchema/static-schemas.js +1633 -0
- package/dist/driverSchema/static-schemas.js.map +1 -0
- package/dist/generator.d.ts +20 -0
- package/dist/generator.d.ts.map +1 -0
- package/dist/generator.js +288 -0
- package/dist/generator.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/metaschema.d.ts +222 -0
- package/dist/metaschema.d.ts.map +1 -0
- package/dist/metaschema.js +203 -0
- package/dist/metaschema.js.map +1 -0
- package/dist/schema-generator.d.ts +15 -0
- package/dist/schema-generator.d.ts.map +1 -0
- package/dist/schema-generator.js +486 -0
- package/dist/schema-generator.js.map +1 -0
- package/dist/testGenerator/test-generator.d.ts +11 -0
- package/dist/testGenerator/test-generator.d.ts.map +1 -0
- package/dist/testGenerator/test-generator.js +211 -0
- package/dist/testGenerator/test-generator.js.map +1 -0
- package/dist/testGenerator/unsupported-aggregations.d.ts +11 -0
- package/dist/testGenerator/unsupported-aggregations.d.ts.map +1 -0
- package/dist/testGenerator/unsupported-aggregations.js +254 -0
- package/dist/testGenerator/unsupported-aggregations.js.map +1 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +28 -0
- package/dist/utils.js.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SchemaGenerator = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const generator_1 = require("./generator");
|
|
9
|
+
const metaschema_1 = require("./metaschema");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
class SchemaGenerator extends generator_1.GeneratorBase {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.schemaOutputFile = path_1.default.resolve(__dirname, '..', 'out', 'schema.d.ts');
|
|
15
|
+
this.trivialTypeMappings = {
|
|
16
|
+
any: 'any',
|
|
17
|
+
bool: 'boolean',
|
|
18
|
+
date: 'Date',
|
|
19
|
+
null: 'null',
|
|
20
|
+
timestamp: 'bson.Timestamp',
|
|
21
|
+
array: 'unknown[]',
|
|
22
|
+
binData: 'bson.Binary',
|
|
23
|
+
objectId: 'bson.ObjectId',
|
|
24
|
+
object: 'Record<string, unknown>',
|
|
25
|
+
string: 'string',
|
|
26
|
+
};
|
|
27
|
+
this.typeMappings = {
|
|
28
|
+
int: ['number', 'bson.Int32', '{ $numberInt: string }'],
|
|
29
|
+
double: ['number', 'bson.Double', '{ $numberDouble: string }'],
|
|
30
|
+
decimal: ['bson.Decimal128', '{ $numberDecimal: string }'],
|
|
31
|
+
regex: [
|
|
32
|
+
'RegExp',
|
|
33
|
+
'bson.BSONRegExp',
|
|
34
|
+
'{ pattern: string, options?: string }',
|
|
35
|
+
],
|
|
36
|
+
long: ['bigint', 'bson.Long', '{ $numberLong: string }'],
|
|
37
|
+
javascript: ['bson.Code', 'Function', 'string'],
|
|
38
|
+
geometry_S: [
|
|
39
|
+
'{type: "Point", coordinates: number[] }',
|
|
40
|
+
'{type:"MultiPoint", coordinates: number[][] }',
|
|
41
|
+
'{type:"LineString", coordinates: number[][] }',
|
|
42
|
+
'{type:"MultiLineString", coordinates: number[][][] }',
|
|
43
|
+
'{type:"Polygon", coordinates: number[][][] }',
|
|
44
|
+
'{type:"MultiPolygon", coordinates: number[][][][] }',
|
|
45
|
+
],
|
|
46
|
+
number: [
|
|
47
|
+
this.toTypeName('int'),
|
|
48
|
+
this.toTypeName('long'),
|
|
49
|
+
this.toTypeName('double'),
|
|
50
|
+
this.toTypeName('decimal'),
|
|
51
|
+
],
|
|
52
|
+
bsonPrimitive: [
|
|
53
|
+
this.toTypeName('number'),
|
|
54
|
+
this.toTypeName('binData'),
|
|
55
|
+
this.toTypeName('objectId'),
|
|
56
|
+
'string',
|
|
57
|
+
this.toTypeName('bool'),
|
|
58
|
+
this.toTypeName('date'),
|
|
59
|
+
this.toTypeName('null'),
|
|
60
|
+
this.toTypeName('regex'),
|
|
61
|
+
this.toTypeName('javascript'),
|
|
62
|
+
this.toTypeName('timestamp'),
|
|
63
|
+
],
|
|
64
|
+
searchPath_S: [
|
|
65
|
+
'UnprefixedFieldPath<S>',
|
|
66
|
+
'UnprefixedFieldPath<S>[]',
|
|
67
|
+
'{ wildcard: string }',
|
|
68
|
+
],
|
|
69
|
+
searchScore: ['unknown'],
|
|
70
|
+
granularity: ['string'],
|
|
71
|
+
fullDocument: ['string'],
|
|
72
|
+
fullDocumentBeforeChange: ['string'],
|
|
73
|
+
accumulatorPercentile: ['string'],
|
|
74
|
+
range: ['unknown'],
|
|
75
|
+
sortBy: ['unknown'],
|
|
76
|
+
geoPoint: ['unknown'],
|
|
77
|
+
sortSpec: ['-1', '1'],
|
|
78
|
+
timeUnit: [
|
|
79
|
+
'"year"',
|
|
80
|
+
'"quarter"',
|
|
81
|
+
'"month"',
|
|
82
|
+
'"week"',
|
|
83
|
+
'"day"',
|
|
84
|
+
'"hour"',
|
|
85
|
+
'"minute"',
|
|
86
|
+
'"second"',
|
|
87
|
+
'"millisecond"',
|
|
88
|
+
],
|
|
89
|
+
outCollection: ['unknown'],
|
|
90
|
+
whenMatched: ['string'],
|
|
91
|
+
whenNotMatched: ['string'],
|
|
92
|
+
expression_S: [
|
|
93
|
+
this.toTypeName('ExpressionOperator<S>'),
|
|
94
|
+
this.toTypeName('fieldPath<S>'),
|
|
95
|
+
this.toTypeName('bsonPrimitive'),
|
|
96
|
+
'FieldExpression<S>',
|
|
97
|
+
'FieldPath<S>[]',
|
|
98
|
+
],
|
|
99
|
+
expressionMap_S: [
|
|
100
|
+
`{ [k: string]: ${this.toTypeName('Expression<S>')} | ${this.toTypeName('ExpressionMap<S>')} }`,
|
|
101
|
+
],
|
|
102
|
+
stage_S: [this.toTypeName('StageOperator<S>')],
|
|
103
|
+
pipeline_S: [this.toTypeName('stage<S>[]')],
|
|
104
|
+
untypedPipeline: [this.toTypeName('Pipeline<any>')],
|
|
105
|
+
query_S: [
|
|
106
|
+
this.toTypeName('QueryOperator<S>'),
|
|
107
|
+
'Partial<{ [k in keyof S]: Condition<S[k]> }>',
|
|
108
|
+
],
|
|
109
|
+
accumulator_S: [],
|
|
110
|
+
searchHighlight_S: [
|
|
111
|
+
`{
|
|
112
|
+
path:
|
|
113
|
+
| UnprefixedFieldPath<S>
|
|
114
|
+
| UnprefixedFieldPath<S>[]
|
|
115
|
+
| { wildcard: string }
|
|
116
|
+
| '*'
|
|
117
|
+
| MultiAnalyzerSpec<S>
|
|
118
|
+
| (UnprefixedFieldPath<S> | MultiAnalyzerSpec<S>)[];
|
|
119
|
+
|
|
120
|
+
maxCharsToExamine?: number;
|
|
121
|
+
maxNumPassages?: number;
|
|
122
|
+
}`,
|
|
123
|
+
],
|
|
124
|
+
fieldPath_S: ['`$${AFieldPath<S, any>}`'],
|
|
125
|
+
unprefixedFieldPath_S: ['AFieldPath<S, any>'],
|
|
126
|
+
numberFieldPath_S: [this.toTypeFieldTypeName('number')],
|
|
127
|
+
doubleFieldPath_S: [this.toTypeFieldTypeName('double')],
|
|
128
|
+
stringFieldPath_S: [this.toTypeFieldTypeName('string')],
|
|
129
|
+
objectFieldPath_S: [this.toTypeFieldTypeName('object')],
|
|
130
|
+
arrayFieldPath_S: [this.toTypeFieldTypeName('array')],
|
|
131
|
+
binDataFieldPath_S: [this.toTypeFieldTypeName('binData')],
|
|
132
|
+
objectIdFieldPath_S: [this.toTypeFieldTypeName('objectId')],
|
|
133
|
+
boolFieldPath_S: [this.toTypeFieldTypeName('bool')],
|
|
134
|
+
dateFieldPath_S: [this.toTypeFieldTypeName('date')],
|
|
135
|
+
nullFieldPath_S: [this.toTypeFieldTypeName('null')],
|
|
136
|
+
regexFieldPath_S: [this.toTypeFieldTypeName('regex')],
|
|
137
|
+
javascriptFieldPath_S: [this.toTypeFieldTypeName('javascript')],
|
|
138
|
+
intFieldPath_S: [this.toTypeFieldTypeName('int')],
|
|
139
|
+
timestampFieldPath_S: [this.toTypeFieldTypeName('timestamp')],
|
|
140
|
+
longFieldPath_S: [this.toTypeFieldTypeName('long')],
|
|
141
|
+
decimalFieldPath_S: [this.toTypeFieldTypeName('decimal')],
|
|
142
|
+
resolvesToNumber_S: [
|
|
143
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
144
|
+
this.toTypeName('numberFieldPath<S>'),
|
|
145
|
+
this.toTypeName('number'),
|
|
146
|
+
this.toTypeName('resolvesToInt<S>'),
|
|
147
|
+
this.toTypeName('resolvesToDouble<S>'),
|
|
148
|
+
this.toTypeName('resolvesToLong<S>'),
|
|
149
|
+
this.toTypeName('resolvesToDecimal<S>'),
|
|
150
|
+
],
|
|
151
|
+
resolvesToDouble_S: [
|
|
152
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
153
|
+
this.toTypeName('doubleFieldPath<S>'),
|
|
154
|
+
this.toTypeName('double'),
|
|
155
|
+
],
|
|
156
|
+
resolvesToString_S: [
|
|
157
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
158
|
+
this.toTypeName('stringFieldPath<S>'),
|
|
159
|
+
this.toTypeName('string'),
|
|
160
|
+
],
|
|
161
|
+
resolvesToObject_S: [
|
|
162
|
+
"'$$ROOT'",
|
|
163
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
164
|
+
this.toTypeName('objectFieldPath<S>'),
|
|
165
|
+
this.toTypeName('object'),
|
|
166
|
+
],
|
|
167
|
+
resolvesToArray_S: [
|
|
168
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
169
|
+
this.toTypeName('arrayFieldPath<S>'),
|
|
170
|
+
this.toTypeName('array'),
|
|
171
|
+
],
|
|
172
|
+
resolvesToBinData_S: [
|
|
173
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
174
|
+
this.toTypeName('binDataFieldPath<S>'),
|
|
175
|
+
this.toTypeName('binData'),
|
|
176
|
+
],
|
|
177
|
+
resolvesToObjectId_S: [
|
|
178
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
179
|
+
this.toTypeName('objectIdFieldPath<S>'),
|
|
180
|
+
this.toTypeName('objectId'),
|
|
181
|
+
],
|
|
182
|
+
resolvesToBool_S: [
|
|
183
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
184
|
+
this.toTypeName('boolFieldPath<S>'),
|
|
185
|
+
this.toTypeName('bool'),
|
|
186
|
+
],
|
|
187
|
+
resolvesToDate_S: [
|
|
188
|
+
"'$$NOW'",
|
|
189
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
190
|
+
this.toTypeName('dateFieldPath<S>'),
|
|
191
|
+
this.toTypeName('date'),
|
|
192
|
+
],
|
|
193
|
+
resolvesToNull_S: [
|
|
194
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
195
|
+
this.toTypeName('nullFieldPath<S>'),
|
|
196
|
+
this.toTypeName('null'),
|
|
197
|
+
],
|
|
198
|
+
resolvesToRegex_S: [
|
|
199
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
200
|
+
this.toTypeName('regexFieldPath<S>'),
|
|
201
|
+
this.toTypeName('regex'),
|
|
202
|
+
],
|
|
203
|
+
resolvesToJavascript_S: [
|
|
204
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
205
|
+
this.toTypeName('javascriptFieldPath<S>'),
|
|
206
|
+
this.toTypeName('javascript'),
|
|
207
|
+
],
|
|
208
|
+
resolvesToInt_S: [
|
|
209
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
210
|
+
this.toTypeName('intFieldPath<S>'),
|
|
211
|
+
this.toTypeName('int'),
|
|
212
|
+
],
|
|
213
|
+
resolvesToTimestamp_S: [
|
|
214
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
215
|
+
this.toTypeName('timestampFieldPath<S>'),
|
|
216
|
+
this.toTypeName('timestamp'),
|
|
217
|
+
"'$clusterTime'",
|
|
218
|
+
],
|
|
219
|
+
resolvesToLong_S: [
|
|
220
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
221
|
+
this.toTypeName('longFieldPath<S>'),
|
|
222
|
+
this.toTypeName('long'),
|
|
223
|
+
],
|
|
224
|
+
resolvesToDecimal_S: [
|
|
225
|
+
this.toTypeName('resolvesToAny<S>'),
|
|
226
|
+
this.toTypeName('decimalFieldPath<S>'),
|
|
227
|
+
this.toTypeName('decimal'),
|
|
228
|
+
],
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
toTypeName(type) {
|
|
232
|
+
return this.trivialTypeMappings[type] ?? (0, utils_1.capitalize)(type);
|
|
233
|
+
}
|
|
234
|
+
toTypeFieldTypeName(type) {
|
|
235
|
+
return '`$${AFieldPath<S, ' + this.toTypeName(type) + '>}`';
|
|
236
|
+
}
|
|
237
|
+
emitHeader() {
|
|
238
|
+
this.emit(`
|
|
239
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
240
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
241
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
242
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
243
|
+
|
|
244
|
+
import type * as bson from 'bson';
|
|
245
|
+
import type { FilterOperators } from 'mongodb';
|
|
246
|
+
|
|
247
|
+
type Condition<T> = AlternativeType<T> | FilterOperators<T> | QueryOperator<T>;
|
|
248
|
+
type AlternativeType<T> =
|
|
249
|
+
T extends ReadonlyArray<infer U> ? T | RegExpOrString<U> : RegExpOrString<T>;
|
|
250
|
+
type RegExpOrString<T> = T extends string ? Regex | T : T;
|
|
251
|
+
type KeysOfAType<T, Type> = {
|
|
252
|
+
[k in keyof T]: Extract<T[k], Type> extends never ? never : k;
|
|
253
|
+
}[keyof T]
|
|
254
|
+
type RecordWithStaticFields<T extends Record<string, any>, TValue> = T & {
|
|
255
|
+
[key: string]: TValue | T[keyof T];
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
// TBD: Nested fields
|
|
259
|
+
type AFieldPath<S, Type> = KeysOfAType<S, Type> & string;
|
|
260
|
+
type FieldExpression<T> = { [k: string]: FieldPath<T> };
|
|
261
|
+
|
|
262
|
+
type MultiAnalyzerSpec<T> = {
|
|
263
|
+
value: KeysOfAType<T, string>;
|
|
264
|
+
multi: string;
|
|
265
|
+
};
|
|
266
|
+
`);
|
|
267
|
+
}
|
|
268
|
+
getArgumentTypeName(type, syntheticVariables) {
|
|
269
|
+
if (this.typeMappings[type]) {
|
|
270
|
+
return this.toTypeName(type);
|
|
271
|
+
}
|
|
272
|
+
if (this.typeMappings[`${type}_S`]) {
|
|
273
|
+
let genericArg = 'S';
|
|
274
|
+
if (syntheticVariables) {
|
|
275
|
+
const syntheticFields = syntheticVariables
|
|
276
|
+
.map((v) => `${this.toComment(v.description)}$${v.name}: any`)
|
|
277
|
+
.join(';\n');
|
|
278
|
+
genericArg = `S & { ${syntheticFields}; }`;
|
|
279
|
+
}
|
|
280
|
+
return this.toTypeName(`${type}<${genericArg}>`);
|
|
281
|
+
}
|
|
282
|
+
if (this.trivialTypeMappings[type]) {
|
|
283
|
+
return this.trivialTypeMappings[type];
|
|
284
|
+
}
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
emitArg(arg, named) {
|
|
288
|
+
if (named) {
|
|
289
|
+
this.emit(`${arg.name}${arg.optional ? '?' : ''}: `);
|
|
290
|
+
}
|
|
291
|
+
const allowsArrays = arg.type.includes('array');
|
|
292
|
+
const argTypes = arg.type
|
|
293
|
+
.filter((t) => t !== 'array')
|
|
294
|
+
.map((type) => {
|
|
295
|
+
const name = this.getArgumentTypeName(type, arg.syntheticVariables);
|
|
296
|
+
if (!name) {
|
|
297
|
+
throw new Error(`Unknown type ${type}`);
|
|
298
|
+
}
|
|
299
|
+
return name;
|
|
300
|
+
})
|
|
301
|
+
.join(' | ');
|
|
302
|
+
if (allowsArrays) {
|
|
303
|
+
if (arg.type.length > 1) {
|
|
304
|
+
this.emit(`(${argTypes}) | (${argTypes})[]`);
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
this.emit('unknown[]');
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
this.emit(argTypes);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
emitArrayWithOptionals(parsed) {
|
|
315
|
+
if (!parsed.arguments) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
let lastRequired, firstOptional = undefined;
|
|
319
|
+
for (let i = 0; i < parsed.arguments.length; i++) {
|
|
320
|
+
const arg = parsed.arguments[i];
|
|
321
|
+
if (!arg.optional) {
|
|
322
|
+
lastRequired = i;
|
|
323
|
+
}
|
|
324
|
+
else if (firstOptional === undefined) {
|
|
325
|
+
firstOptional = i;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (firstOptional !== undefined &&
|
|
329
|
+
lastRequired !== undefined &&
|
|
330
|
+
firstOptional < lastRequired) {
|
|
331
|
+
const optionalArgs = parsed.arguments.filter((arg) => arg.optional);
|
|
332
|
+
const totalCombinations = 1 << optionalArgs.length;
|
|
333
|
+
const optionalCombinations = [];
|
|
334
|
+
for (let i = 0; i < totalCombinations; i++) {
|
|
335
|
+
const combination = {};
|
|
336
|
+
for (let j = 0; j < optionalArgs.length; j++) {
|
|
337
|
+
combination[optionalArgs[j].name] = !!(i & (1 << j));
|
|
338
|
+
}
|
|
339
|
+
optionalCombinations.push(combination);
|
|
340
|
+
}
|
|
341
|
+
for (const combination of optionalCombinations) {
|
|
342
|
+
this.emit('| [');
|
|
343
|
+
for (const arg of parsed.arguments) {
|
|
344
|
+
if (!arg.optional || combination[arg.name]) {
|
|
345
|
+
if (arg.description) {
|
|
346
|
+
this.emitComment(arg.description);
|
|
347
|
+
}
|
|
348
|
+
this.emitArg({ ...arg, optional: false }, true);
|
|
349
|
+
this.emit(',');
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
this.emit(']\n');
|
|
353
|
+
}
|
|
354
|
+
return true;
|
|
355
|
+
}
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
async generateImpl(yamlFiles) {
|
|
359
|
+
await this.emitToFile(this.schemaOutputFile);
|
|
360
|
+
this.emitHeader();
|
|
361
|
+
for await (const file of yamlFiles) {
|
|
362
|
+
const namespace = `Aggregation.${(0, utils_1.capitalize)(file.category)}`;
|
|
363
|
+
this.emit(`export namespace ${namespace} {\n`);
|
|
364
|
+
for await (const operator of file.operators()) {
|
|
365
|
+
const parsed = metaschema_1.Operator.parse(operator.yaml);
|
|
366
|
+
const ifaceName = (0, utils_1.capitalize)(parsed.name);
|
|
367
|
+
this.emitComment(`A type describing the \`${parsed.name}\` operator.`, parsed.link);
|
|
368
|
+
this.emit(`export interface ${ifaceName}<S> {`);
|
|
369
|
+
if (parsed.description) {
|
|
370
|
+
this.emitComment(parsed.description, parsed.link);
|
|
371
|
+
}
|
|
372
|
+
this.emit(`${parsed.name}:`);
|
|
373
|
+
for (const type of parsed.type) {
|
|
374
|
+
(this.typeMappings[`${type}_S`] ??= []).push(`${namespace}.${ifaceName}<S>`);
|
|
375
|
+
}
|
|
376
|
+
(this.typeMappings[`${file.category}Operator_S`] ??= []).push(`${namespace}.${ifaceName}<S>`);
|
|
377
|
+
if (!parsed.arguments) {
|
|
378
|
+
this.emit(`Record<string, never>`);
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
let encode = parsed.encode;
|
|
382
|
+
if (encode === 'single') {
|
|
383
|
+
if (parsed.arguments.length !== 1) {
|
|
384
|
+
throw new Error('encode: single should imply arguments.length === 1');
|
|
385
|
+
}
|
|
386
|
+
if (parsed.arguments[0].variadic) {
|
|
387
|
+
encode = parsed.arguments[0].variadic;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
switch (encode) {
|
|
391
|
+
case 'array':
|
|
392
|
+
if (this.emitArrayWithOptionals(parsed)) {
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
case 'object': {
|
|
396
|
+
const mergedArgs = [];
|
|
397
|
+
const objectType = this.getOutputOf(() => {
|
|
398
|
+
this.emit(encode === 'array' ? '[' : '{');
|
|
399
|
+
for (const arg of parsed.arguments ?? []) {
|
|
400
|
+
if (arg.mergeObject) {
|
|
401
|
+
mergedArgs.push(arg);
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
if (arg.description) {
|
|
405
|
+
this.emitComment(arg.description);
|
|
406
|
+
}
|
|
407
|
+
if (arg.variadic === 'array') {
|
|
408
|
+
for (let i = 0; i < (arg.variadicMin ?? 0); i++) {
|
|
409
|
+
this.emitArg(arg, false);
|
|
410
|
+
this.emit(',');
|
|
411
|
+
}
|
|
412
|
+
this.emit('...(');
|
|
413
|
+
this.emitArg(arg, false);
|
|
414
|
+
this.emit(')[]');
|
|
415
|
+
}
|
|
416
|
+
else if (arg.variadic === 'object') {
|
|
417
|
+
this.emit(`} & { [${arg.name}: string]: `);
|
|
418
|
+
this.emitArg(arg, false);
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
this.emitArg(arg, true);
|
|
422
|
+
}
|
|
423
|
+
this.emit(',');
|
|
424
|
+
}
|
|
425
|
+
this.emit(encode === 'array' ? ']' : '}');
|
|
426
|
+
});
|
|
427
|
+
switch (mergedArgs.length) {
|
|
428
|
+
case 0:
|
|
429
|
+
this.emit(objectType);
|
|
430
|
+
break;
|
|
431
|
+
case 1:
|
|
432
|
+
{
|
|
433
|
+
const arg = mergedArgs[0];
|
|
434
|
+
switch (arg.variadic) {
|
|
435
|
+
case 'object':
|
|
436
|
+
if (objectType === '{}') {
|
|
437
|
+
this.emit(`{ [${arg.name}: string]: `);
|
|
438
|
+
this.emitArg(arg, false);
|
|
439
|
+
this.emit(`}`);
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
this.emit(`RecordWithStaticFields<${objectType}, ${this.toComment(arg.description)} ${arg.type
|
|
443
|
+
.map((t) => this.getArgumentTypeName(t))
|
|
444
|
+
.join(' | ')}>`);
|
|
445
|
+
}
|
|
446
|
+
break;
|
|
447
|
+
case 'array':
|
|
448
|
+
throw new Error(`invalid mergeObject combination: variadic=${arg.variadic}, encode=${parsed.encode}`);
|
|
449
|
+
case undefined:
|
|
450
|
+
this.emitArg(arg, false);
|
|
451
|
+
this.emit(' & ');
|
|
452
|
+
this.emit(objectType);
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
break;
|
|
457
|
+
default:
|
|
458
|
+
throw new Error(`Unsupported number of mergeObject arguments: ${mergedArgs.length}, ${namespace}.${ifaceName}.{${mergedArgs
|
|
459
|
+
.map((a) => a.name)
|
|
460
|
+
.join(', ')}}`);
|
|
461
|
+
}
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
case 'single':
|
|
465
|
+
if (parsed.arguments.length !== 1) {
|
|
466
|
+
throw new Error('encode: single should imply arguments.length === 1');
|
|
467
|
+
}
|
|
468
|
+
this.emitArg(parsed.arguments[0], false);
|
|
469
|
+
break;
|
|
470
|
+
default:
|
|
471
|
+
throw new Error(`unknown encode mode ${parsed.encode}`);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
this.emit('};\n');
|
|
475
|
+
}
|
|
476
|
+
this.emit('};\n');
|
|
477
|
+
}
|
|
478
|
+
for (const [type, interfaces] of Object.entries(this.typeMappings)) {
|
|
479
|
+
const isTemplated = type.endsWith('_S');
|
|
480
|
+
const name = isTemplated ? type.replace(/_S$/, '') : type;
|
|
481
|
+
this.emit(`\nexport type ${this.toTypeName(name)}${isTemplated ? '<S>' : ''} = ${[...new Set(interfaces)].join('|')};`);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
exports.SchemaGenerator = SchemaGenerator;
|
|
486
|
+
//# sourceMappingURL=schema-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-generator.js","sourceRoot":"","sources":["../src/schema-generator.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,2CAA4C;AAC5C,6CAAwC;AACxC,mCAAqC;AAUrC,MAAa,eAAgB,SAAQ,yBAAa;IAAlD;;QACU,qBAAgB,GAAG,cAAI,CAAC,OAAO,CACrC,SAAS,EACT,IAAI,EACJ,KAAK,EACL,aAAa,CACd,CAAC;QAUM,wBAAmB,GAAqC;YAC9D,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;YACZ,SAAS,EAAE,gBAAgB;YAC3B,KAAK,EAAE,WAAW;YAClB,OAAO,EAAE,aAAa;YACtB,QAAQ,EAAE,eAAe;YACzB,MAAM,EAAE,yBAAyB;YACjC,MAAM,EAAE,QAAQ;SACjB,CAAC;QAEM,iBAAY,GAA6B;YAC/C,GAAG,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,wBAA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;gBACH,CAAC;gBACD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACpB,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC;QAED,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YACnE,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACxC,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAC1D,IAAI,CAAC,IAAI,CACP,iBAAiB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GACpC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EACxB,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAC5C,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAtjBD,0CAsjBC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { YamlFiles } from '../generator';
|
|
2
|
+
import { GeneratorBase } from '../generator';
|
|
3
|
+
export declare class TestGenerator extends GeneratorBase {
|
|
4
|
+
private schemaBsonTypeToTS;
|
|
5
|
+
private simplifiedTypesToTS;
|
|
6
|
+
private simplifiedSchemaToTS;
|
|
7
|
+
private stageToTS;
|
|
8
|
+
private emitTestBody;
|
|
9
|
+
protected generateImpl(yamlFiles: YamlFiles): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=test-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-generator.d.ts","sourceRoot":"","sources":["../../src/testGenerator/test-generator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAgB7C,qBAAa,aAAc,SAAQ,aAAa;IAC9C,OAAO,CAAC,kBAAkB;IA8C1B,OAAO,CAAC,mBAAmB;IAe3B,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,SAAS;IAiDjB,OAAO,CAAC,YAAY;cAqDK,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CA6C3E"}
|