@takeshape/schema 8.36.2 → 8.38.2
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/es/flatten-templates.js +26 -0
- package/es/index.js +2 -1
- package/es/layers/layers.js +1 -1
- package/es/layers/refs.js +1 -1
- package/es/refs.js +74 -2
- package/es/schema-util.js +28 -17
- package/es/template-shapes/index.js +35 -0
- package/es/template-shapes/templates.js +379 -0
- package/es/template-shapes/types.js +1 -0
- package/es/template-shapes/where.js +501 -0
- package/es/validate.js +2 -2
- package/lib/flatten-templates.d.ts +3 -0
- package/lib/flatten-templates.d.ts.map +1 -0
- package/lib/flatten-templates.js +39 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +14 -0
- package/lib/layers/layers.js +3 -3
- package/lib/layers/refs.js +2 -2
- package/lib/refs.d.ts +26 -1
- package/lib/refs.d.ts.map +1 -1
- package/lib/refs.js +94 -11
- package/lib/schema-util.d.ts +7 -6
- package/lib/schema-util.d.ts.map +1 -1
- package/lib/schema-util.js +41 -29
- package/lib/template-shapes/index.d.ts +8 -0
- package/lib/template-shapes/index.d.ts.map +1 -0
- package/lib/template-shapes/index.js +46 -0
- package/lib/template-shapes/templates.d.ts +29 -0
- package/lib/template-shapes/templates.d.ts.map +1 -0
- package/lib/template-shapes/templates.js +427 -0
- package/lib/template-shapes/types.d.ts +10 -0
- package/lib/template-shapes/types.d.ts.map +1 -0
- package/lib/template-shapes/types.js +5 -0
- package/lib/template-shapes/where.d.ts +39 -0
- package/lib/template-shapes/where.d.ts.map +1 -0
- package/lib/template-shapes/where.js +534 -0
- package/lib/validate.js +1 -1
- package/package.json +4 -4
- package/es/template-shapes.js +0 -79
- package/lib/template-shapes.d.ts +0 -32
- package/lib/template-shapes.d.ts.map +0 -1
- package/lib/template-shapes.js +0 -101
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.commonSearchProps = exports.commonSearchArgs = exports.UpdateResult = exports.UpdateArgs = exports.TSSearchSortInput = exports.TSSearchArgs = exports.TSListArgs = exports.TSGetSingletonArgs = exports.TSGetArgs = exports.SearchResults = exports.PaginatedList = exports.DuplicateResult = exports.DuplicateArgs = exports.DeleteResult = exports.DeleteArgs = exports.CreateResult = exports.CreateArgs = exports.ContentStructureInput = void 0;
|
|
7
|
+
exports.getIDQueryArgs = getIDQueryArgs;
|
|
8
|
+
exports.getMutationArgs = getMutationArgs;
|
|
9
|
+
exports.getMutationResultType = getMutationResultType;
|
|
10
|
+
exports.getPaginatedListShape = getPaginatedListShape;
|
|
11
|
+
exports.getSearchResultsShape = getSearchResultsShape;
|
|
12
|
+
exports.getShapeListQueryArgs = getShapeListQueryArgs;
|
|
13
|
+
exports.termsProps = exports.localeProps = void 0;
|
|
14
|
+
|
|
15
|
+
var _migration = require("../migration");
|
|
16
|
+
|
|
17
|
+
var _util = require("@takeshape/util");
|
|
18
|
+
|
|
19
|
+
var _keyBy = _interopRequireDefault(require("lodash/keyBy"));
|
|
20
|
+
|
|
21
|
+
var _schemaUtil = require("../schema-util");
|
|
22
|
+
|
|
23
|
+
var _refs = require("../refs");
|
|
24
|
+
|
|
25
|
+
var _where = require("./where");
|
|
26
|
+
|
|
27
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
+
|
|
29
|
+
const CREATE = 'create';
|
|
30
|
+
const UPDATE = 'update';
|
|
31
|
+
const DELETE = 'delete';
|
|
32
|
+
const DUPLICATE = 'duplicate';
|
|
33
|
+
const TSGetArgs = getIDQueryArgs('TSGetArgs');
|
|
34
|
+
exports.TSGetArgs = TSGetArgs;
|
|
35
|
+
const TSGetSingletonArgs = getIDQueryArgs('TSGetSingletonArgs');
|
|
36
|
+
exports.TSGetSingletonArgs = TSGetSingletonArgs;
|
|
37
|
+
const TSListArgs = getShapeListQueryArgs('TSListArgs', true);
|
|
38
|
+
exports.TSListArgs = TSListArgs;
|
|
39
|
+
const TSSearchArgs = getShapeListQueryArgs('TSSearchArgs', false);
|
|
40
|
+
exports.TSSearchArgs = TSSearchArgs;
|
|
41
|
+
const CreateArgs = getMutationArgs('CreateArgs', CREATE);
|
|
42
|
+
exports.CreateArgs = CreateArgs;
|
|
43
|
+
const UpdateArgs = getMutationArgs('UpdateArgs', UPDATE);
|
|
44
|
+
exports.UpdateArgs = UpdateArgs;
|
|
45
|
+
const DuplicateArgs = getMutationArgs('DuplicateArgs', DUPLICATE);
|
|
46
|
+
exports.DuplicateArgs = DuplicateArgs;
|
|
47
|
+
const DeleteArgs = getMutationArgs('DeleteArgs', DELETE);
|
|
48
|
+
exports.DeleteArgs = DeleteArgs;
|
|
49
|
+
const PaginatedList = getPaginatedListShape;
|
|
50
|
+
exports.PaginatedList = PaginatedList;
|
|
51
|
+
const SearchResults = getSearchResultsShape;
|
|
52
|
+
exports.SearchResults = SearchResults;
|
|
53
|
+
const CreateResult = getMutationResultType(CREATE);
|
|
54
|
+
exports.CreateResult = CreateResult;
|
|
55
|
+
const UpdateResult = getMutationResultType(UPDATE);
|
|
56
|
+
exports.UpdateResult = UpdateResult;
|
|
57
|
+
const DuplicateResult = getMutationResultType(DUPLICATE);
|
|
58
|
+
exports.DuplicateResult = DuplicateResult;
|
|
59
|
+
const DeleteResult = getMutationResultType(DELETE);
|
|
60
|
+
exports.DeleteResult = DeleteResult;
|
|
61
|
+
const TSSearchSortInput = (0, _schemaUtil.createShape)('TSSearchSortInput', {
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {
|
|
64
|
+
field: {
|
|
65
|
+
type: 'string'
|
|
66
|
+
},
|
|
67
|
+
order: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
description: '"asc" for ascending or "desc" for descending'
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
required: ['field', 'order']
|
|
73
|
+
});
|
|
74
|
+
exports.TSSearchSortInput = TSSearchSortInput;
|
|
75
|
+
const commonSearchProps = {
|
|
76
|
+
terms: {
|
|
77
|
+
type: 'string'
|
|
78
|
+
},
|
|
79
|
+
from: {
|
|
80
|
+
type: 'integer',
|
|
81
|
+
description: 'The offset from the first result you want to fetch.'
|
|
82
|
+
},
|
|
83
|
+
size: {
|
|
84
|
+
type: 'integer',
|
|
85
|
+
description: 'The maximum number of items to return.'
|
|
86
|
+
},
|
|
87
|
+
filter: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
description: 'An elasticsearch style filter. Overrides onlyEnabled.'
|
|
90
|
+
},
|
|
91
|
+
sort: {
|
|
92
|
+
type: 'array',
|
|
93
|
+
description: 'An list of fields to sort by.',
|
|
94
|
+
items: {
|
|
95
|
+
'@ref': `local:${TSSearchSortInput.name}`
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
exports.commonSearchProps = commonSearchProps;
|
|
100
|
+
const localeProps = {
|
|
101
|
+
type: 'object',
|
|
102
|
+
properties: {
|
|
103
|
+
locale: {
|
|
104
|
+
type: 'string'
|
|
105
|
+
},
|
|
106
|
+
enableLocaleFallback: {
|
|
107
|
+
type: 'boolean',
|
|
108
|
+
default: true
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
exports.localeProps = localeProps;
|
|
113
|
+
const termsProps = {
|
|
114
|
+
type: 'object',
|
|
115
|
+
properties: {
|
|
116
|
+
terms: {
|
|
117
|
+
type: 'string'
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
exports.termsProps = termsProps;
|
|
122
|
+
const ContentStructureInput = (0, _schemaUtil.createShape)('ContentStructureInput', {
|
|
123
|
+
type: 'object',
|
|
124
|
+
properties: {
|
|
125
|
+
path: {
|
|
126
|
+
type: 'string',
|
|
127
|
+
description: 'A deep path to the array being updated (e.g. a.b[1].c).'
|
|
128
|
+
},
|
|
129
|
+
structure: {
|
|
130
|
+
type: 'array',
|
|
131
|
+
description: 'An array where the indices represent the to index, and the values represent the from index.' + 'For example to transform ["a","b","c","d"] into ["c","a"], this value would be [2,0].',
|
|
132
|
+
items: {
|
|
133
|
+
type: 'integer'
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
required: ['path']
|
|
138
|
+
}, {
|
|
139
|
+
description: 'Describes a structural update to an array of data.'
|
|
140
|
+
});
|
|
141
|
+
exports.ContentStructureInput = ContentStructureInput;
|
|
142
|
+
|
|
143
|
+
function getPaginatedListShape(context, shape) {
|
|
144
|
+
const shapeName = `${shape.name}${_migration.listTypePrefix}`;
|
|
145
|
+
return {
|
|
146
|
+
shapeName,
|
|
147
|
+
dependencies: {
|
|
148
|
+
[shapeName]: (0, _schemaUtil.createShape)(shapeName, {
|
|
149
|
+
type: 'object',
|
|
150
|
+
properties: {
|
|
151
|
+
items: {
|
|
152
|
+
type: 'array',
|
|
153
|
+
items: {
|
|
154
|
+
'@ref': `local:${shape.name}`
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
total: {
|
|
158
|
+
type: 'integer'
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
required: ['items', 'total']
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function getSearchResultsShape(context, shape) {
|
|
168
|
+
const shapeName = `${shape.name}SearchResults`;
|
|
169
|
+
return {
|
|
170
|
+
shapeName,
|
|
171
|
+
dependencies: {
|
|
172
|
+
[shapeName]: (0, _schemaUtil.createShape)(shapeName, {
|
|
173
|
+
type: 'object',
|
|
174
|
+
properties: {
|
|
175
|
+
results: {
|
|
176
|
+
type: 'array',
|
|
177
|
+
items: {
|
|
178
|
+
'@ref': `local:${shape.name}`
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
total: {
|
|
182
|
+
type: 'integer'
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
required: ['results', 'total']
|
|
186
|
+
}, {
|
|
187
|
+
description: `${shape.name} search results`
|
|
188
|
+
})
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const contentStructureFields = {
|
|
194
|
+
type: 'object',
|
|
195
|
+
properties: {
|
|
196
|
+
structure: {
|
|
197
|
+
type: 'array',
|
|
198
|
+
items: {
|
|
199
|
+
'@ref': 'local:ContentStructureInput'
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
const idSchema = {
|
|
205
|
+
type: 'object',
|
|
206
|
+
properties: {
|
|
207
|
+
_id: {
|
|
208
|
+
type: 'string'
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
required: ['_id']
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
function rewriteSchema(shapeSchema) {
|
|
215
|
+
return JSON.parse(JSON.stringify(shapeSchema), (key, value) => {
|
|
216
|
+
var _value$required;
|
|
217
|
+
|
|
218
|
+
// Remove required
|
|
219
|
+
if (typeof value === 'object' && value.type === 'object' && (_value$required = value.required) !== null && _value$required !== void 0 && _value$required.length) {
|
|
220
|
+
delete value.required;
|
|
221
|
+
} // Remove default
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
if (typeof value === 'object' && value.type && value.default) {
|
|
225
|
+
delete value.default;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return value;
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function getIDQueryArgs(templateName) {
|
|
233
|
+
return (context, shape) => {
|
|
234
|
+
var _shape$model;
|
|
235
|
+
|
|
236
|
+
const schema = ((_shape$model = shape.model) === null || _shape$model === void 0 ? void 0 : _shape$model.type) !== 'single' ? (0, _schemaUtil.mergeSchemaProperties)(idSchema, localeProps) : localeProps;
|
|
237
|
+
const shapeName = (0, _refs.getFlattenedTemplateShapeName)(shape.name, templateName);
|
|
238
|
+
return {
|
|
239
|
+
shapeName,
|
|
240
|
+
dependencies: {
|
|
241
|
+
[shapeName]: (0, _schemaUtil.createShape)(shapeName, schema)
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function mergeObjectSchemas(...args) {
|
|
248
|
+
return args.filter(_util.isDefined).reduce(_schemaUtil.mergeSchemaProperties, {
|
|
249
|
+
type: 'object',
|
|
250
|
+
properties: {}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function getMutationArgs(templateName, verb) {
|
|
255
|
+
return ({
|
|
256
|
+
projectSchema
|
|
257
|
+
}, shape) => {
|
|
258
|
+
const addLocale = verb === UPDATE || verb === DUPLICATE;
|
|
259
|
+
const addStructure = verb === UPDATE;
|
|
260
|
+
const inputName = (0, _util.pascalCase)([verb, shape.name, 'input']);
|
|
261
|
+
const isSingleton = shape.model && shape.model.type === 'single';
|
|
262
|
+
const requireId = !isSingleton && (verb === UPDATE || verb === DELETE || verb === DUPLICATE);
|
|
263
|
+
const isUpdate = verb === UPDATE || verb === DUPLICATE;
|
|
264
|
+
const inputShape = (0, _schemaUtil.createShape)(inputName, mergeObjectSchemas(requireId ? idSchema : undefined, verb !== DELETE ? isUpdate ? rewriteSchema(shape.schema) : shape.schema : undefined), {
|
|
265
|
+
description: `${verb} ${shape.name} input`
|
|
266
|
+
});
|
|
267
|
+
const argsShapeName = (0, _refs.getFlattenedTemplateShapeName)(shape.name, templateName);
|
|
268
|
+
const argsShape = (0, _schemaUtil.createShape)(argsShapeName, mergeObjectSchemas({
|
|
269
|
+
type: 'object',
|
|
270
|
+
properties: {
|
|
271
|
+
input: {
|
|
272
|
+
'@ref': `local:${inputShape.name}`
|
|
273
|
+
},
|
|
274
|
+
clientMutationId: {
|
|
275
|
+
type: 'string'
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
required: ['input']
|
|
279
|
+
}, addStructure ? contentStructureFields : undefined, addLocale ? localeProps : undefined));
|
|
280
|
+
|
|
281
|
+
const getInputShapeName = shapeName => isUpdate ? `${shapeName}PartialInput` : `${shapeName}Input`;
|
|
282
|
+
|
|
283
|
+
return {
|
|
284
|
+
shapeName: argsShapeName,
|
|
285
|
+
dependencies: {
|
|
286
|
+
[inputName]: inputShape,
|
|
287
|
+
[argsShapeName]: argsShape,
|
|
288
|
+
...(verb !== DELETE && (0, _keyBy.default)((0, _schemaUtil.getShapeDependencies)(projectSchema, shape, propSchema => {
|
|
289
|
+
if (!propSchema['@resolver']) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const shapeName = (0, _refs.getRefShapeName)(projectSchema, propSchema);
|
|
294
|
+
|
|
295
|
+
if (shapeName) {
|
|
296
|
+
return !projectSchema.shapes[getInputShapeName(shapeName)];
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return true;
|
|
300
|
+
}).map(shapeName => {
|
|
301
|
+
const shape = projectSchema.shapes[shapeName];
|
|
302
|
+
const name = getInputShapeName(shapeName);
|
|
303
|
+
return { ...shape,
|
|
304
|
+
name,
|
|
305
|
+
id: name,
|
|
306
|
+
schema: isUpdate ? rewriteSchema(shape.schema) : shape.schema
|
|
307
|
+
};
|
|
308
|
+
}), 'name')),
|
|
309
|
+
...(addStructure ? {
|
|
310
|
+
ContentStructureInput
|
|
311
|
+
} : {})
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function getMutationResultType(verb) {
|
|
318
|
+
return (context, shape) => {
|
|
319
|
+
const shapeName = (0, _util.pascalCase)([verb, shape.name, 'result']);
|
|
320
|
+
const result = verb === DELETE ? {
|
|
321
|
+
type: 'boolean'
|
|
322
|
+
} : {
|
|
323
|
+
'@ref': `local:${shape.name}`
|
|
324
|
+
};
|
|
325
|
+
return {
|
|
326
|
+
shapeName,
|
|
327
|
+
dependencies: {
|
|
328
|
+
[shapeName]: (0, _schemaUtil.createShape)(shapeName, {
|
|
329
|
+
type: 'object',
|
|
330
|
+
properties: {
|
|
331
|
+
clientMutationId: {
|
|
332
|
+
type: 'string'
|
|
333
|
+
},
|
|
334
|
+
result
|
|
335
|
+
}
|
|
336
|
+
})
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const commonSearchArgs = {
|
|
343
|
+
type: 'object',
|
|
344
|
+
properties: {
|
|
345
|
+
terms: {
|
|
346
|
+
type: 'string'
|
|
347
|
+
},
|
|
348
|
+
from: {
|
|
349
|
+
type: 'integer',
|
|
350
|
+
description: 'The offset from the first result you want to fetch.'
|
|
351
|
+
},
|
|
352
|
+
size: {
|
|
353
|
+
type: 'integer',
|
|
354
|
+
description: 'The maximum number of items to return.'
|
|
355
|
+
},
|
|
356
|
+
filter: {
|
|
357
|
+
type: 'object',
|
|
358
|
+
description: 'An elasticsearch style filter. Overrides onlyEnabled.'
|
|
359
|
+
},
|
|
360
|
+
sort: {
|
|
361
|
+
type: 'array',
|
|
362
|
+
description: 'An list of fields to sort by.',
|
|
363
|
+
items: {
|
|
364
|
+
'@ref': `local:${TSSearchSortInput.name}`
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
exports.commonSearchArgs = commonSearchArgs;
|
|
370
|
+
const legacyListArgs = {
|
|
371
|
+
type: 'object',
|
|
372
|
+
properties: {
|
|
373
|
+
onlyEnabled: {
|
|
374
|
+
type: 'boolean',
|
|
375
|
+
default: true,
|
|
376
|
+
description: 'Filter out content that is not enabled. Defaults to true.'
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
const shapeFilterProps = {
|
|
381
|
+
type: 'object',
|
|
382
|
+
properties: {
|
|
383
|
+
shapeNames: {
|
|
384
|
+
type: 'array',
|
|
385
|
+
items: {
|
|
386
|
+
type: 'string'
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
shapeIds: {
|
|
390
|
+
type: 'array',
|
|
391
|
+
items: {
|
|
392
|
+
type: 'string'
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
contentTypeNames: {
|
|
396
|
+
type: 'array',
|
|
397
|
+
items: {
|
|
398
|
+
type: 'string'
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
contentTypeIds: {
|
|
402
|
+
type: 'array',
|
|
403
|
+
items: {
|
|
404
|
+
type: 'string'
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
function getShapeListQueryArgs(templateName, legacyArgs) {
|
|
411
|
+
return (context, shape) => {
|
|
412
|
+
const isAllShapes = shape.name === 'TSSearchable';
|
|
413
|
+
const shapeName = isAllShapes ? templateName : (0, _refs.getFlattenedTemplateShapeName)(shape.name, templateName);
|
|
414
|
+
const shapes = isAllShapes ? Object.values(context.projectSchema.shapes) : [shape];
|
|
415
|
+
const {
|
|
416
|
+
schema,
|
|
417
|
+
dependencies
|
|
418
|
+
} = (0, _where.getWhereSearchArg)(context.projectSchema, shapes);
|
|
419
|
+
return {
|
|
420
|
+
shapeName,
|
|
421
|
+
dependencies: { ...dependencies,
|
|
422
|
+
TSSearchSortInput,
|
|
423
|
+
[shapeName]: (0, _schemaUtil.createShape)(shapeName, mergeObjectSchemas(commonSearchArgs, localeProps, legacyArgs ? legacyListArgs : undefined, isAllShapes ? shapeFilterProps : undefined, schema))
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
};
|
|
427
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ProjectSchema, Shape, ShapeMap } from '../project-schema';
|
|
2
|
+
export interface ResolvedTemplate {
|
|
3
|
+
shapeName: string;
|
|
4
|
+
dependencies: ShapeMap;
|
|
5
|
+
}
|
|
6
|
+
export interface TemplateContext {
|
|
7
|
+
projectSchema: ProjectSchema;
|
|
8
|
+
}
|
|
9
|
+
export declare type TemplateShapeFactory = (context: TemplateContext, shape: Shape) => ResolvedTemplate;
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/template-shapes/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAEjE,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,QAAQ,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,oBAAY,oBAAoB,GAAG,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,KAAK,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Maybe } from '@takeshape/util';
|
|
2
|
+
import type { PropertySchema, ProjectSchema, Shape } from '../project-schema';
|
|
3
|
+
import { ObjectSchema, ShapeMap } from '../project-schema';
|
|
4
|
+
import { ResolvedTemplate } from './types';
|
|
5
|
+
export declare const MAX_RELATIONSHIP_DEPTH = 1;
|
|
6
|
+
export declare const exceededRelationshipDepth: (depth?: number) => boolean;
|
|
7
|
+
declare type ComparisonOperatorKey = 'eq' | 'lt' | 'lte' | 'gt' | 'gte' | 'in' | 'match' | 'regexp';
|
|
8
|
+
declare type ShapeThunk = Shape | (() => Shape);
|
|
9
|
+
declare class ShapeCache {
|
|
10
|
+
thunks: Map<string, ShapeThunk>;
|
|
11
|
+
unresolved: Set<string>;
|
|
12
|
+
has(shapeName: string): boolean;
|
|
13
|
+
set(shapeName: string, thunk: ShapeThunk): void;
|
|
14
|
+
resolveAll(): ShapeMap;
|
|
15
|
+
}
|
|
16
|
+
export declare const fieldTypeComparison: Record<string, {
|
|
17
|
+
comparators: ComparisonOperatorKey[];
|
|
18
|
+
type: 'string' | 'number' | 'integer' | 'boolean';
|
|
19
|
+
}>;
|
|
20
|
+
export declare const comparatorDescriptions: Record<string, string>;
|
|
21
|
+
export declare const booleanOperators: string[];
|
|
22
|
+
export declare const boolOpDescriptionMap: Record<string, string>;
|
|
23
|
+
export declare function getFieldTypeComparison(fieldType: string): Maybe<Record<string, PropertySchema>>;
|
|
24
|
+
export interface PropertyContext {
|
|
25
|
+
shapeCache: ShapeCache;
|
|
26
|
+
conflictingProperties: string[];
|
|
27
|
+
projectSchema: ProjectSchema;
|
|
28
|
+
relationshipDepth: number;
|
|
29
|
+
booleanOperators?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function getFields(typeName: string, shapes: Shape[], context: PropertyContext): Record<string, PropertySchema>;
|
|
32
|
+
export declare function getPropertyComparisonType(name: string, prop: PropertySchema, shapeName: string, context: PropertyContext): Maybe<Record<string, PropertySchema>>;
|
|
33
|
+
export declare function getWhereShape(projectSchema: ProjectSchema, shapes: Shape[]): ResolvedTemplate;
|
|
34
|
+
export declare function getWhereSearchArg(projectSchema: ProjectSchema, shapes: Shape[]): {
|
|
35
|
+
schema: ObjectSchema;
|
|
36
|
+
dependencies: ShapeMap;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=where.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"where.d.ts","sourceRoot":"","sources":["../../../src/template-shapes/where.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,EAAY,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAC,cAAc,EAAE,aAAa,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAY5E,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAKzD,OAAO,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAC;AAEzC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,yBAAyB,sBAAgB,OAA0C,CAAC;AAEjG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