@takeshape/schema 11.73.0 → 11.76.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.
Files changed (109) hide show
  1. package/dist/builtin-schema.js +1 -0
  2. package/dist/models/runtime-schema.js +1 -0
  3. package/dist/project-schema/latest.d.ts +6 -1
  4. package/dist/project-schema/v3.48.0.d.ts +6 -1
  5. package/dist/project-schema/v3.49.0.d.ts +6 -1
  6. package/dist/project-schema/v3.50.0.d.ts +6 -1
  7. package/dist/project-schema/v3.51.0.d.ts +6 -1
  8. package/dist/project-schema/v3.52.0.d.ts +6 -1
  9. package/dist/project-schema/v3.53.0.d.ts +6 -1
  10. package/dist/project-schema/v3.54.0.d.ts +6 -1
  11. package/dist/schemas/project-schema/experimental.json +20 -0
  12. package/dist/util/expressions.js +2 -2
  13. package/package.json +6 -6
  14. package/dist/__tests__/_examples.test.d.ts +0 -1
  15. package/dist/__tests__/_examples.test.js +0 -77
  16. package/dist/__tests__/agents.test.d.ts +0 -1
  17. package/dist/__tests__/agents.test.js +0 -163
  18. package/dist/__tests__/api-version.test.d.ts +0 -1
  19. package/dist/__tests__/api-version.test.js +0 -24
  20. package/dist/__tests__/builtin-schema.test.d.ts +0 -1
  21. package/dist/__tests__/builtin-schema.test.js +0 -18
  22. package/dist/__tests__/content-schema-transform.test.d.ts +0 -1
  23. package/dist/__tests__/content-schema-transform.test.js +0 -522
  24. package/dist/__tests__/create-input-schema.test.d.ts +0 -1
  25. package/dist/__tests__/create-input-schema.test.js +0 -184
  26. package/dist/__tests__/enum.test.d.ts +0 -1
  27. package/dist/__tests__/enum.test.js +0 -36
  28. package/dist/__tests__/flatten-templates.test.d.ts +0 -1
  29. package/dist/__tests__/flatten-templates.test.js +0 -40
  30. package/dist/__tests__/get-is-leaf.test.d.ts +0 -1
  31. package/dist/__tests__/get-is-leaf.test.js +0 -50
  32. package/dist/__tests__/interfaces.test.d.ts +0 -1
  33. package/dist/__tests__/interfaces.test.js +0 -219
  34. package/dist/__tests__/migration.test.d.ts +0 -1
  35. package/dist/__tests__/migration.test.js +0 -34
  36. package/dist/__tests__/mocks.test.d.ts +0 -1
  37. package/dist/__tests__/mocks.test.js +0 -24
  38. package/dist/__tests__/refs.test.d.ts +0 -1
  39. package/dist/__tests__/refs.test.js +0 -813
  40. package/dist/__tests__/relationships.test.d.ts +0 -1
  41. package/dist/__tests__/relationships.test.js +0 -638
  42. package/dist/__tests__/schema-transform.test.d.ts +0 -1
  43. package/dist/__tests__/schema-transform.test.js +0 -205
  44. package/dist/__tests__/schema-util.test.d.ts +0 -1
  45. package/dist/__tests__/schema-util.test.js +0 -1731
  46. package/dist/__tests__/service-dependencies.test.d.ts +0 -1
  47. package/dist/__tests__/service-dependencies.test.js +0 -360
  48. package/dist/__tests__/unions.test.d.ts +0 -1
  49. package/dist/__tests__/unions.test.js +0 -44
  50. package/dist/__tests__/validate.test.d.ts +0 -1
  51. package/dist/__tests__/validate.test.js +0 -1980
  52. package/dist/__tests__/workflows.test.d.ts +0 -3
  53. package/dist/__tests__/workflows.test.js +0 -149
  54. package/dist/layers/__tests__/layers.test.d.ts +0 -1
  55. package/dist/layers/__tests__/layers.test.js +0 -38
  56. package/dist/migration/to/__tests__/v3.10.0.test.d.ts +0 -1
  57. package/dist/migration/to/__tests__/v3.10.0.test.js +0 -90
  58. package/dist/migration/to/__tests__/v3.12.3.test.d.ts +0 -1
  59. package/dist/migration/to/__tests__/v3.12.3.test.js +0 -103
  60. package/dist/migration/to/__tests__/v3.17.test.d.ts +0 -1
  61. package/dist/migration/to/__tests__/v3.17.test.js +0 -71
  62. package/dist/migration/to/__tests__/v3.34.0.test.d.ts +0 -1
  63. package/dist/migration/to/__tests__/v3.34.0.test.js +0 -240
  64. package/dist/migration/to/__tests__/v3.39.0.test.d.ts +0 -1
  65. package/dist/migration/to/__tests__/v3.39.0.test.js +0 -116
  66. package/dist/migration/to/__tests__/v3.46.0.test.d.ts +0 -1
  67. package/dist/migration/to/__tests__/v3.46.0.test.js +0 -59
  68. package/dist/models/__tests__/fixtures.d.ts +0 -15
  69. package/dist/models/__tests__/fixtures.js +0 -56
  70. package/dist/models/__tests__/query.test.d.ts +0 -1
  71. package/dist/models/__tests__/query.test.js +0 -19
  72. package/dist/models/__tests__/runtime-schema.test.d.ts +0 -1
  73. package/dist/models/__tests__/runtime-schema.test.js +0 -43
  74. package/dist/models/__tests__/shape.test.d.ts +0 -1
  75. package/dist/models/__tests__/shape.test.js +0 -24
  76. package/dist/resolvers/ai/__tests__/rag-query.test.d.ts +0 -1
  77. package/dist/resolvers/ai/__tests__/rag-query.test.js +0 -49
  78. package/dist/services/__tests__/services.test.d.ts +0 -1
  79. package/dist/services/__tests__/services.test.js +0 -113
  80. package/dist/template-shapes/__tests__/index.test.d.ts +0 -1
  81. package/dist/template-shapes/__tests__/index.test.js +0 -40
  82. package/dist/template-shapes/__tests__/names.test.d.ts +0 -1
  83. package/dist/template-shapes/__tests__/names.test.js +0 -19
  84. package/dist/template-shapes/__tests__/templates.test.d.ts +0 -1
  85. package/dist/template-shapes/__tests__/templates.test.js +0 -80
  86. package/dist/template-shapes/__tests__/where.test.d.ts +0 -1
  87. package/dist/template-shapes/__tests__/where.test.js +0 -218
  88. package/dist/types/__tests__/utils.test.d.ts +0 -1
  89. package/dist/types/__tests__/utils.test.js +0 -159
  90. package/dist/util/__tests__/api-indexing.test.d.ts +0 -1
  91. package/dist/util/__tests__/api-indexing.test.js +0 -129
  92. package/dist/util/__tests__/detect-cycles.test.d.ts +0 -1
  93. package/dist/util/__tests__/detect-cycles.test.js +0 -193
  94. package/dist/util/__tests__/expressions.test.d.ts +0 -1
  95. package/dist/util/__tests__/expressions.test.js +0 -172
  96. package/dist/util/__tests__/find-shape-at-path.test.d.ts +0 -1
  97. package/dist/util/__tests__/find-shape-at-path.test.js +0 -41
  98. package/dist/util/__tests__/form-config.test.d.ts +0 -1
  99. package/dist/util/__tests__/form-config.test.js +0 -196
  100. package/dist/util/__tests__/get-return-shape.test.d.ts +0 -1
  101. package/dist/util/__tests__/get-return-shape.test.js +0 -27
  102. package/dist/util/__tests__/has-args.test.d.ts +0 -1
  103. package/dist/util/__tests__/has-args.test.js +0 -46
  104. package/dist/util/__tests__/merge.test.d.ts +0 -1
  105. package/dist/util/__tests__/merge.test.js +0 -1074
  106. package/dist/util/__tests__/patch-schema.test.d.ts +0 -1
  107. package/dist/util/__tests__/patch-schema.test.js +0 -82
  108. package/dist/util/__tests__/shapes.test.d.ts +0 -1
  109. package/dist/util/__tests__/shapes.test.js +0 -30
@@ -1 +0,0 @@
1
- export {};
@@ -1,638 +0,0 @@
1
- import massiveSchemaJson from '@takeshape/schema/examples/latest/massive-schema.json';
2
- import postSchemaJson from '@takeshape/schema/examples/latest/post-schema.json';
3
- import shapeBooksSchemaJson from '@takeshape/schema/examples/latest/shape-books.json';
4
- import { deepClone } from '@takeshape/util';
5
- import { describe, expect, it, test } from 'vitest';
6
- import { createMockSchema, createMockSchemaWithDefaults } from "../mocks.js";
7
- import { addRelatedFields, findExistingRelationships, getRelationshipSchema } from "../relationships.js";
8
- import { applyDefaultsToSchema, createShape } from "../schema-util.js";
9
- const projectSchema = applyDefaultsToSchema(shapeBooksSchemaJson);
10
- describe('getRelationshipSchema', () => {
11
- const projectSchema = createMockSchema('<project-id>', {
12
- shapes: {
13
- A: createShape('A', {
14
- type: 'object',
15
- properties: { a: { type: 'string' } }
16
- }),
17
- B: createShape('B', {
18
- type: 'object',
19
- properties: { b: { type: 'string' } }
20
- })
21
- }
22
- });
23
- const singleRelationship = {
24
- shapeIds: ['ASSET'],
25
- type: 'single'
26
- };
27
- const multipleRelationship = {
28
- shapeIds: ['ASSET'],
29
- type: 'multiple'
30
- };
31
- it('gets a schema when provided a single relationship', () => {
32
- const schema = getRelationshipSchema(projectSchema, singleRelationship);
33
- expect(schema).toEqual({
34
- '@ref': 'local:Asset',
35
- '@args': 'TSRelationshipArgs',
36
- '@input': {
37
- '@ref': 'local:TSRelationship'
38
- },
39
- '@resolver': {
40
- name: 'shapedb:getRelated',
41
- service: 'shapedb',
42
- options: {
43
- nullable: true
44
- }
45
- }
46
- });
47
- });
48
- it('gets an array schema when provided a multiple relationship', () => {
49
- const schema = getRelationshipSchema(projectSchema, multipleRelationship);
50
- expect(schema).toEqual({
51
- type: 'array',
52
- items: { '@ref': 'local:Asset' },
53
- '@args': 'TSRelationshipArgs',
54
- '@input': {
55
- type: 'array',
56
- items: {
57
- '@ref': 'local:TSRelationship'
58
- }
59
- },
60
- '@resolver': {
61
- name: 'shapedb:getRelated',
62
- service: 'shapedb',
63
- options: {
64
- nullable: true
65
- }
66
- }
67
- });
68
- });
69
- it('gets uses oneOf when relationship has multiple shape ids', () => {
70
- const multipleRelationship = {
71
- shapeIds: ['A', 'B'],
72
- type: 'multiple'
73
- };
74
- const schema = getRelationshipSchema(projectSchema, multipleRelationship);
75
- expect(schema).toEqual({
76
- type: 'array',
77
- items: { oneOf: [{ '@ref': 'local:A' }, { '@ref': 'local:B' }] },
78
- '@args': 'TSRelationshipArgs',
79
- '@input': {
80
- type: 'array',
81
- items: {
82
- '@ref': 'local:TSRelationship'
83
- }
84
- },
85
- '@resolver': {
86
- name: 'shapedb:getRelated',
87
- service: 'shapedb',
88
- options: {
89
- nullable: true
90
- }
91
- }
92
- });
93
- });
94
- it('throws error for empty relationship', () => {
95
- const empty = {
96
- shapeIds: [],
97
- type: 'single'
98
- };
99
- expect(() => getRelationshipSchema(projectSchema, empty)).toThrowErrorMatchingInlineSnapshot(`[Error: Invalid empty relationship {"shapeIds":[],"type":"single"}]`);
100
- });
101
- });
102
- const massiveSchema = createMockSchemaWithDefaults(massiveSchemaJson.projectId, massiveSchemaJson);
103
- const postSchema = createMockSchemaWithDefaults(postSchemaJson.projectId, postSchemaJson);
104
- describe('findExistingRelationships', () => {
105
- test('post', () => {
106
- const schema = postSchema;
107
- const actual = findExistingRelationships(schema, schema.shapes);
108
- const expected = {
109
- tagContentTypeId: [
110
- {
111
- shapeId: 'postContentTypeId',
112
- path: ['tags'],
113
- relatedName: 'firstTags',
114
- hasBackreference: true,
115
- schema: {
116
- '@args': 'TSRelationshipArgs',
117
- '@backreference': {
118
- enabled: true,
119
- name: 'firstTags'
120
- },
121
- '@input': {
122
- items: {
123
- '@ref': 'local:TSRelationship'
124
- },
125
- type: 'array'
126
- },
127
- '@mapping': 'shapedb:Post.tagsId',
128
- '@resolver': {
129
- name: 'shapedb:getRelated',
130
- service: 'shapedb',
131
- options: {
132
- nullable: true
133
- }
134
- },
135
- items: {
136
- '@ref': 'local:Tag'
137
- },
138
- type: 'array'
139
- },
140
- shapeName: 'Post'
141
- }
142
- ]
143
- };
144
- expect(actual).toEqual(expected);
145
- });
146
- test('massive', () => {
147
- const actual = findExistingRelationships(massiveSchema, massiveSchema.shapes);
148
- expect(Object.keys(actual).length).toBe(15);
149
- });
150
- test('recursive ', () => {
151
- const recursiveSchema = createMockSchemaWithDefaults('project-id', {
152
- shapes: {
153
- Node: {
154
- title: 'Node',
155
- name: 'Node',
156
- id: 'node-id',
157
- schema: {
158
- type: 'object',
159
- properties: {
160
- value: { type: 'number' },
161
- left: { '@ref': 'local:Node' },
162
- right: { '@ref': 'local:Node' }
163
- }
164
- }
165
- },
166
- Report: {
167
- title: 'Report',
168
- name: 'Report',
169
- id: 'report-id',
170
- model: {
171
- type: 'multiple'
172
- },
173
- schema: {
174
- type: 'object',
175
- properties: {
176
- name: { type: 'string' },
177
- tree: {
178
- oneOf: [
179
- {
180
- '@ref': 'local:Node'
181
- }
182
- ],
183
- '@input': {
184
- '@ref': 'local:TSRelationship'
185
- },
186
- '@backreference': {
187
- enabled: true,
188
- name: 'firstTags'
189
- },
190
- '@resolver': {
191
- name: 'shapedb:getRelated',
192
- service: 'shapedb'
193
- }
194
- }
195
- }
196
- }
197
- }
198
- }
199
- });
200
- const actual = findExistingRelationships(recursiveSchema, recursiveSchema.shapes);
201
- expect(actual).toEqual({
202
- 'node-id': [
203
- {
204
- path: ['tree'],
205
- shapeId: 'report-id',
206
- relatedName: 'firstTags',
207
- hasBackreference: true,
208
- schema: {
209
- '@backreference': {
210
- enabled: true,
211
- name: 'firstTags'
212
- },
213
- '@input': {
214
- '@ref': 'local:TSRelationship'
215
- },
216
- '@resolver': {
217
- name: 'shapedb:getRelated',
218
- service: 'shapedb'
219
- },
220
- oneOf: [
221
- {
222
- '@ref': 'local:Node'
223
- }
224
- ]
225
- },
226
- shapeName: 'Report'
227
- }
228
- ]
229
- });
230
- });
231
- test('nested in union ', () => {
232
- const projectSchema = createMockSchema('project-id', {
233
- shapes: {
234
- Center: {
235
- title: 'Center',
236
- name: 'Center',
237
- id: 'Center',
238
- model: {
239
- type: 'multiple'
240
- },
241
- schema: {
242
- type: 'object',
243
- properties: {
244
- name: { type: 'string' },
245
- info: {
246
- oneOf: [{ '@ref': 'local:BasicInfo' }, { '@ref': 'local:AdvancedInfo' }]
247
- }
248
- }
249
- }
250
- },
251
- BasicInfo: {
252
- title: 'BasicInfo',
253
- name: 'BasicInfo',
254
- id: 'BasicInfo',
255
- schema: {
256
- type: 'object',
257
- properties: {
258
- treatments: {
259
- type: 'array',
260
- items: {
261
- oneOf: [
262
- {
263
- '@ref': 'local:Treatment'
264
- }
265
- ]
266
- },
267
- '@input': {
268
- type: 'array',
269
- items: {
270
- '@ref': 'local:TSRelationship'
271
- }
272
- },
273
- '@backreference': { enabled: true, name: 'basicInfoSet' },
274
- '@resolver': {
275
- name: 'shapedb:getRelated',
276
- service: 'shapedb'
277
- }
278
- }
279
- }
280
- }
281
- },
282
- AdvancedInfo: {
283
- title: 'AdvancedInfo',
284
- name: 'AdvancedInfo',
285
- id: 'AdvancedInfo',
286
- schema: {
287
- type: 'object',
288
- properties: {
289
- isExpensive: { type: 'boolean' }
290
- }
291
- }
292
- },
293
- Treatment: {
294
- title: 'Treatment',
295
- name: 'Treatment',
296
- id: 'Treatment',
297
- model: {
298
- type: 'multiple'
299
- },
300
- schema: {
301
- type: 'object',
302
- properties: {
303
- name: { type: 'string' }
304
- }
305
- }
306
- }
307
- }
308
- });
309
- const actual = findExistingRelationships(projectSchema, projectSchema.shapes);
310
- expect(actual).toEqual({
311
- Treatment: [
312
- {
313
- relatedName: 'basicInfoSet',
314
- path: ['info', 'treatments'],
315
- shapeId: 'Center',
316
- hasBackreference: true,
317
- schema: {
318
- '@backreference': {
319
- enabled: true,
320
- name: 'basicInfoSet'
321
- },
322
- '@input': {
323
- items: {
324
- '@ref': 'local:TSRelationship'
325
- },
326
- type: 'array'
327
- },
328
- '@resolver': {
329
- name: 'shapedb:getRelated',
330
- service: 'shapedb'
331
- },
332
- items: {
333
- oneOf: [
334
- {
335
- '@ref': 'local:Treatment'
336
- }
337
- ]
338
- },
339
- type: 'array'
340
- },
341
- shapeName: 'BasicInfo'
342
- }
343
- ]
344
- });
345
- });
346
- test('shopify', () => {
347
- const shapes = {
348
- TSRelationship: {
349
- id: 'TSRelationship',
350
- name: 'TSRelationship',
351
- title: 'Relationship',
352
- schema: {
353
- type: 'object',
354
- properties: {
355
- shapeId: {
356
- type: 'string'
357
- },
358
- id: { type: 'string' }
359
- },
360
- required: ['shapeId', 'id']
361
- }
362
- },
363
- Post: {
364
- name: 'Post',
365
- schema: {
366
- type: 'object',
367
- properties: {
368
- shopifyProduct: {
369
- $ref: '#/shapes/TSShopify_Product/schema',
370
- '@resolver': {
371
- name: 'graphql:query',
372
- argsMapping: {
373
- id: [['jsonPath', { path: '$.productId' }]]
374
- },
375
- service: 'seans-store-takeshape',
376
- fieldName: 'product'
377
- }
378
- },
379
- rating: {
380
- type: 'integer',
381
- '@mapping': 'shapedb:self.ratingId'
382
- },
383
- productId: {
384
- type: 'string',
385
- '@tag': 'id'
386
- },
387
- title: {
388
- type: 'string',
389
- '@l10n': true,
390
- '@mapping': 'shapedb:self.titleId'
391
- },
392
- body: {
393
- type: 'string',
394
- '@l10n': true,
395
- '@mapping': 'shapedb:self.bodyId'
396
- },
397
- tags: {
398
- '@mapping': 'shapedb:self.tagsId',
399
- type: 'array',
400
- items: {
401
- oneOf: [
402
- {
403
- '@ref': 'local:Tag'
404
- }
405
- ]
406
- },
407
- '@input': {
408
- items: {
409
- '@ref': 'local:TSRelationship'
410
- }
411
- },
412
- '@backreference': {
413
- enabled: true,
414
- name: 'firstTags'
415
- },
416
- '@resolver': {
417
- name: 'shapedb:getRelated',
418
- service: 'shapedb'
419
- }
420
- }
421
- },
422
- required: ['title']
423
- },
424
- model: {
425
- type: 'multiple'
426
- },
427
- id: 'postContentTypeId',
428
- title: 'Post'
429
- },
430
- Tag: {
431
- name: 'Tag',
432
- schema: {
433
- type: 'object',
434
- properties: {
435
- name: {
436
- type: 'string',
437
- '@mapping': 'shapedb:self.nameId'
438
- }
439
- },
440
- required: ['name']
441
- },
442
- model: {
443
- type: 'taxonomy'
444
- },
445
- id: 'tagContentTypeId',
446
- title: 'Tag'
447
- }
448
- };
449
- const relationships = findExistingRelationships(massiveSchema, shapes);
450
- expect(relationships).toEqual({
451
- tagContentTypeId: [
452
- {
453
- path: ['tags'],
454
- relatedName: 'firstTags',
455
- shapeId: 'postContentTypeId',
456
- hasBackreference: true,
457
- schema: {
458
- '@backreference': {
459
- enabled: true,
460
- name: 'firstTags'
461
- },
462
- '@input': {
463
- items: {
464
- '@ref': 'local:TSRelationship'
465
- }
466
- },
467
- '@mapping': 'shapedb:self.tagsId',
468
- '@resolver': {
469
- name: 'shapedb:getRelated',
470
- service: 'shapedb'
471
- },
472
- items: {
473
- oneOf: [
474
- {
475
- '@ref': 'local:Tag'
476
- }
477
- ]
478
- },
479
- type: 'array'
480
- },
481
- shapeName: 'Post'
482
- }
483
- ]
484
- });
485
- });
486
- });
487
- describe('addRelatedFields', () => {
488
- test('it works', () => {
489
- const relationships = findExistingRelationships(projectSchema, projectSchema.shapes);
490
- const actual = addRelatedFields(deepClone(projectSchema), relationships);
491
- const { properties } = actual.shapes.Author.schema;
492
- expect(properties.postSet).toEqual({
493
- '@args': 'TSListArgs<local:Post>',
494
- '@ref': 'PaginatedList<local:Post>',
495
- '@resolver': {
496
- args: {
497
- ops: [
498
- {
499
- path: '$',
500
- mapping: '$args'
501
- },
502
- {
503
- path: 'baseWhere._references.eq',
504
- mapping: '$source._id'
505
- },
506
- {
507
- path: 'baseWhere._shapeId.eq',
508
- value: projectSchema.shapes.Post.id
509
- }
510
- ]
511
- },
512
- name: 'shapedb:list',
513
- service: 'shapedb'
514
- }
515
- });
516
- expect(properties.authored).toEqual({
517
- '@args': 'TSListArgs<local:Book>',
518
- '@ref': 'PaginatedList<local:Book>',
519
- '@resolver': {
520
- args: {
521
- ops: [
522
- {
523
- path: '$',
524
- mapping: '$args'
525
- },
526
- {
527
- path: 'baseWhere.author._id.eq',
528
- mapping: '$source._id'
529
- },
530
- {
531
- path: 'baseWhere._shapeId.eq',
532
- value: projectSchema.shapes.Book.id
533
- }
534
- ]
535
- },
536
- name: 'shapedb:list',
537
- service: 'shapedb'
538
- }
539
- });
540
- expect(properties._references).toEqual({
541
- '@args': 'TSListArgs<local:AuthorReference>',
542
- '@ref': 'PaginatedList<local:AuthorReference>',
543
- '@resolver': {
544
- args: {
545
- ops: [
546
- {
547
- path: '$',
548
- mapping: '$args'
549
- },
550
- {
551
- path: 'baseWhere._references.eq',
552
- mapping: '$source._id'
553
- },
554
- {
555
- path: 'baseWhere._shapeId.in',
556
- value: [projectSchema.shapes.Asset.id, projectSchema.shapes.Post.id, projectSchema.shapes.Book.id]
557
- }
558
- ]
559
- },
560
- name: 'shapedb:list',
561
- service: 'shapedb'
562
- }
563
- });
564
- expect(actual.shapes.AuthorReference).toEqual({
565
- id: 'AuthorReference',
566
- name: 'AuthorReference',
567
- title: 'AuthorReference',
568
- schema: {
569
- oneOf: [{ '@ref': 'local:Asset' }, { '@ref': 'local:Post' }, { '@ref': 'local:Book' }]
570
- }
571
- });
572
- });
573
- test('backreference not enabled, no reference', () => {
574
- const mockSchema = deepClone(projectSchema);
575
- // @ts-expect-error
576
- mockSchema.shapes.Post.schema.properties.author['@backreference'].enabled = false;
577
- const relationships = findExistingRelationships(mockSchema, mockSchema.shapes);
578
- const actual = addRelatedFields(deepClone(projectSchema), relationships);
579
- const { properties } = actual.shapes.Author.schema;
580
- expect(properties.postSet).toBeUndefined();
581
- expect(properties.authored).toEqual({
582
- '@args': 'TSListArgs<local:Book>',
583
- '@ref': 'PaginatedList<local:Book>',
584
- '@resolver': {
585
- args: {
586
- ops: [
587
- {
588
- path: '$',
589
- mapping: '$args'
590
- },
591
- {
592
- path: 'baseWhere.author._id.eq',
593
- mapping: '$source._id'
594
- },
595
- {
596
- path: 'baseWhere._shapeId.eq',
597
- value: projectSchema.shapes.Book.id
598
- }
599
- ]
600
- },
601
- name: 'shapedb:list',
602
- service: 'shapedb'
603
- }
604
- });
605
- expect(properties._references).toEqual({
606
- '@args': 'TSListArgs<local:AuthorReference>',
607
- '@ref': 'PaginatedList<local:AuthorReference>',
608
- '@resolver': {
609
- args: {
610
- ops: [
611
- {
612
- path: '$',
613
- mapping: '$args'
614
- },
615
- {
616
- path: 'baseWhere._references.eq',
617
- mapping: '$source._id'
618
- },
619
- {
620
- path: 'baseWhere._shapeId.in',
621
- value: [projectSchema.shapes.Asset.id, projectSchema.shapes.Book.id]
622
- }
623
- ]
624
- },
625
- name: 'shapedb:list',
626
- service: 'shapedb'
627
- }
628
- });
629
- expect(actual.shapes.AuthorReference).toEqual({
630
- id: 'AuthorReference',
631
- name: 'AuthorReference',
632
- title: 'AuthorReference',
633
- schema: {
634
- oneOf: [{ '@ref': 'local:Asset' }, { '@ref': 'local:Book' }]
635
- }
636
- });
637
- });
638
- });
@@ -1 +0,0 @@
1
- export {};