@takeshape/schema 11.72.0 → 11.74.1
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/dist/models/runtime-schema.js +1 -0
- package/dist/project-schema/latest.d.ts +6 -1
- package/dist/project-schema/v3.48.0.d.ts +6 -1
- package/dist/project-schema/v3.49.0.d.ts +6 -1
- package/dist/project-schema/v3.50.0.d.ts +6 -1
- package/dist/project-schema/v3.51.0.d.ts +6 -1
- package/dist/project-schema/v3.52.0.d.ts +6 -1
- package/dist/project-schema/v3.53.0.d.ts +6 -1
- package/dist/project-schema/v3.54.0.d.ts +6 -1
- package/dist/schemas/project-schema/experimental.json +20 -0
- package/dist/util/expressions.js +2 -2
- package/package.json +6 -6
- package/dist/__tests__/_examples.test.d.ts +0 -1
- package/dist/__tests__/_examples.test.js +0 -77
- package/dist/__tests__/agents.test.d.ts +0 -1
- package/dist/__tests__/agents.test.js +0 -163
- package/dist/__tests__/api-version.test.d.ts +0 -1
- package/dist/__tests__/api-version.test.js +0 -24
- package/dist/__tests__/builtin-schema.test.d.ts +0 -1
- package/dist/__tests__/builtin-schema.test.js +0 -18
- package/dist/__tests__/content-schema-transform.test.d.ts +0 -1
- package/dist/__tests__/content-schema-transform.test.js +0 -522
- package/dist/__tests__/create-input-schema.test.d.ts +0 -1
- package/dist/__tests__/create-input-schema.test.js +0 -184
- package/dist/__tests__/enum.test.d.ts +0 -1
- package/dist/__tests__/enum.test.js +0 -36
- package/dist/__tests__/flatten-templates.test.d.ts +0 -1
- package/dist/__tests__/flatten-templates.test.js +0 -40
- package/dist/__tests__/get-is-leaf.test.d.ts +0 -1
- package/dist/__tests__/get-is-leaf.test.js +0 -50
- package/dist/__tests__/interfaces.test.d.ts +0 -1
- package/dist/__tests__/interfaces.test.js +0 -219
- package/dist/__tests__/migration.test.d.ts +0 -1
- package/dist/__tests__/migration.test.js +0 -34
- package/dist/__tests__/mocks.test.d.ts +0 -1
- package/dist/__tests__/mocks.test.js +0 -24
- package/dist/__tests__/refs.test.d.ts +0 -1
- package/dist/__tests__/refs.test.js +0 -813
- package/dist/__tests__/relationships.test.d.ts +0 -1
- package/dist/__tests__/relationships.test.js +0 -638
- package/dist/__tests__/schema-transform.test.d.ts +0 -1
- package/dist/__tests__/schema-transform.test.js +0 -205
- package/dist/__tests__/schema-util.test.d.ts +0 -1
- package/dist/__tests__/schema-util.test.js +0 -1731
- package/dist/__tests__/service-dependencies.test.d.ts +0 -1
- package/dist/__tests__/service-dependencies.test.js +0 -360
- package/dist/__tests__/unions.test.d.ts +0 -1
- package/dist/__tests__/unions.test.js +0 -44
- package/dist/__tests__/validate.test.d.ts +0 -1
- package/dist/__tests__/validate.test.js +0 -1980
- package/dist/__tests__/workflows.test.d.ts +0 -3
- package/dist/__tests__/workflows.test.js +0 -149
- package/dist/layers/__tests__/layers.test.d.ts +0 -1
- package/dist/layers/__tests__/layers.test.js +0 -38
- package/dist/migration/to/__tests__/v3.10.0.test.d.ts +0 -1
- package/dist/migration/to/__tests__/v3.10.0.test.js +0 -90
- package/dist/migration/to/__tests__/v3.12.3.test.d.ts +0 -1
- package/dist/migration/to/__tests__/v3.12.3.test.js +0 -103
- package/dist/migration/to/__tests__/v3.17.test.d.ts +0 -1
- package/dist/migration/to/__tests__/v3.17.test.js +0 -71
- package/dist/migration/to/__tests__/v3.34.0.test.d.ts +0 -1
- package/dist/migration/to/__tests__/v3.34.0.test.js +0 -240
- package/dist/migration/to/__tests__/v3.39.0.test.d.ts +0 -1
- package/dist/migration/to/__tests__/v3.39.0.test.js +0 -116
- package/dist/migration/to/__tests__/v3.46.0.test.d.ts +0 -1
- package/dist/migration/to/__tests__/v3.46.0.test.js +0 -59
- package/dist/models/__tests__/fixtures.d.ts +0 -15
- package/dist/models/__tests__/fixtures.js +0 -56
- package/dist/models/__tests__/query.test.d.ts +0 -1
- package/dist/models/__tests__/query.test.js +0 -19
- package/dist/models/__tests__/runtime-schema.test.d.ts +0 -1
- package/dist/models/__tests__/runtime-schema.test.js +0 -43
- package/dist/models/__tests__/shape.test.d.ts +0 -1
- package/dist/models/__tests__/shape.test.js +0 -24
- package/dist/resolvers/ai/__tests__/rag-query.test.d.ts +0 -1
- package/dist/resolvers/ai/__tests__/rag-query.test.js +0 -49
- package/dist/services/__tests__/services.test.d.ts +0 -1
- package/dist/services/__tests__/services.test.js +0 -113
- package/dist/template-shapes/__tests__/index.test.d.ts +0 -1
- package/dist/template-shapes/__tests__/index.test.js +0 -40
- package/dist/template-shapes/__tests__/names.test.d.ts +0 -1
- package/dist/template-shapes/__tests__/names.test.js +0 -19
- package/dist/template-shapes/__tests__/templates.test.d.ts +0 -1
- package/dist/template-shapes/__tests__/templates.test.js +0 -80
- package/dist/template-shapes/__tests__/where.test.d.ts +0 -1
- package/dist/template-shapes/__tests__/where.test.js +0 -218
- package/dist/types/__tests__/utils.test.d.ts +0 -1
- package/dist/types/__tests__/utils.test.js +0 -159
- package/dist/util/__tests__/api-indexing.test.d.ts +0 -1
- package/dist/util/__tests__/api-indexing.test.js +0 -129
- package/dist/util/__tests__/detect-cycles.test.d.ts +0 -1
- package/dist/util/__tests__/detect-cycles.test.js +0 -193
- package/dist/util/__tests__/expressions.test.d.ts +0 -1
- package/dist/util/__tests__/expressions.test.js +0 -172
- package/dist/util/__tests__/find-shape-at-path.test.d.ts +0 -1
- package/dist/util/__tests__/find-shape-at-path.test.js +0 -41
- package/dist/util/__tests__/form-config.test.d.ts +0 -1
- package/dist/util/__tests__/form-config.test.js +0 -196
- package/dist/util/__tests__/get-return-shape.test.d.ts +0 -1
- package/dist/util/__tests__/get-return-shape.test.js +0 -27
- package/dist/util/__tests__/has-args.test.d.ts +0 -1
- package/dist/util/__tests__/has-args.test.js +0 -46
- package/dist/util/__tests__/merge.test.d.ts +0 -1
- package/dist/util/__tests__/merge.test.js +0 -1074
- package/dist/util/__tests__/patch-schema.test.d.ts +0 -1
- package/dist/util/__tests__/patch-schema.test.js +0 -82
- package/dist/util/__tests__/shapes.test.d.ts +0 -1
- package/dist/util/__tests__/shapes.test.js +0 -30
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_ENTITLEMENTS, deepClone } from '@takeshape/util';
|
|
2
|
-
import { describe, expect, test } from 'vitest';
|
|
3
|
-
import petSchemaJson from '@/examples/latest/pet-oneof-array.json';
|
|
4
|
-
import shopifySchema from '@/examples/latest/shopify-store-with-widget.json';
|
|
5
|
-
import { removePropertiesTransform, unwrapOneOfObjects, wrapOneOfObjects } from "../schema-transform.js";
|
|
6
|
-
import { applyDefaultsToSchema } from "../schema-util.js";
|
|
7
|
-
import { validateSchema } from "../validate/validate.js";
|
|
8
|
-
const petSchema = applyDefaultsToSchema(petSchemaJson);
|
|
9
|
-
describe('removePropertiesTransform', () => {
|
|
10
|
-
test('removePropertiesTransform', async () => {
|
|
11
|
-
const blacklist = ['Shopify_ProductVariant.updatedAt', '*.publishedOnCurrentPublication'];
|
|
12
|
-
const prunedSchema = removePropertiesTransform(blacklist)(deepClone(shopifySchema));
|
|
13
|
-
const { errors } = await validateSchema({
|
|
14
|
-
entitlements: DEFAULT_ENTITLEMENTS
|
|
15
|
-
}, prunedSchema);
|
|
16
|
-
expect(errors).toEqual(undefined);
|
|
17
|
-
const productBefore = shopifySchema.shapes.Shopify_Product.schema;
|
|
18
|
-
const productAfter = prunedSchema.shapes.Shopify_Product.schema;
|
|
19
|
-
// Ensure we remove items in the blacklist
|
|
20
|
-
expect(productBefore.properties.publishedOnCurrentPublication).toBeTruthy();
|
|
21
|
-
expect(productAfter.properties.publishedOnCurrentPublication).toBeUndefined();
|
|
22
|
-
expect(productBefore.required?.includes('publishedOnCurrentPublication')).toBe(true);
|
|
23
|
-
expect(productAfter.required?.includes('publishedOnCurrentPublication')).toBe(false);
|
|
24
|
-
// Ensure we ONLY remove items in the blacklist
|
|
25
|
-
expect(productBefore.properties.id).toBeTruthy();
|
|
26
|
-
expect(productAfter.properties.id).toBeTruthy();
|
|
27
|
-
expect(productBefore.required?.includes('id')).toBe(true);
|
|
28
|
-
expect(productAfter.required?.includes('id')).toBe(true);
|
|
29
|
-
const variantBefore = shopifySchema.shapes.Shopify_ProductVariant.schema;
|
|
30
|
-
const variantAfter = prunedSchema.shapes.Shopify_ProductVariant.schema;
|
|
31
|
-
// Ensure we remove items shape-specific the blacklist
|
|
32
|
-
expect(variantBefore.properties.updatedAt).toBeTruthy();
|
|
33
|
-
expect(variantAfter.properties.updatedAt).toBeUndefined();
|
|
34
|
-
expect(variantBefore.required?.includes('updatedAt')).toBe(true);
|
|
35
|
-
expect(variantAfter.required?.includes('updatedAt')).toBe(false);
|
|
36
|
-
// Ensure removals are shape specific
|
|
37
|
-
expect(productBefore.properties.updatedAt).toBeTruthy();
|
|
38
|
-
expect(productAfter.properties.updatedAt).toBeTruthy();
|
|
39
|
-
expect(productBefore.required?.includes('updatedAt')).toBe(true);
|
|
40
|
-
expect(productAfter.required?.includes('updatedAt')).toBe(true);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
describe('wrapOneOfObjects', () => {
|
|
44
|
-
test('with _shapeId', () => {
|
|
45
|
-
const input = {
|
|
46
|
-
animals: [
|
|
47
|
-
{
|
|
48
|
-
name: 'Mary Doggins',
|
|
49
|
-
rank: 'Nanny',
|
|
50
|
-
_shapeId: '7PSFIZU-N'
|
|
51
|
-
}
|
|
52
|
-
],
|
|
53
|
-
_version: 1
|
|
54
|
-
};
|
|
55
|
-
expect(wrapOneOfObjects(petSchema, petSchema.shapes.PetStore.schema, input)).toEqual({
|
|
56
|
-
animals: [
|
|
57
|
-
{
|
|
58
|
-
dog: {
|
|
59
|
-
name: 'Mary Doggins',
|
|
60
|
-
rank: 'Nanny'
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
],
|
|
64
|
-
_version: 1
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
test('without _shapeId', () => {
|
|
68
|
-
const input = {
|
|
69
|
-
animal: [
|
|
70
|
-
{
|
|
71
|
-
name: 'Mary Doggins',
|
|
72
|
-
rank: 'Nanny'
|
|
73
|
-
}
|
|
74
|
-
],
|
|
75
|
-
_version: 1
|
|
76
|
-
};
|
|
77
|
-
expect(wrapOneOfObjects(petSchema, petSchema.shapes.PetStore.schema, input)).toEqual({
|
|
78
|
-
animal: [
|
|
79
|
-
{
|
|
80
|
-
name: 'Mary Doggins',
|
|
81
|
-
rank: 'Nanny'
|
|
82
|
-
}
|
|
83
|
-
],
|
|
84
|
-
_version: 1
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
test('nested', () => {
|
|
88
|
-
const input = {
|
|
89
|
-
name: 'Crystal Mall',
|
|
90
|
-
shops: [
|
|
91
|
-
{
|
|
92
|
-
_shapeId: 'i8tv9QutR',
|
|
93
|
-
name: 'Petsgo',
|
|
94
|
-
animals: [
|
|
95
|
-
{
|
|
96
|
-
_shapeId: '7PSFIZU-N',
|
|
97
|
-
name: 'Biff',
|
|
98
|
-
bestFriend: false
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
_shapeId: 'k49WhBWPs',
|
|
102
|
-
name: 'Stuart',
|
|
103
|
-
lives: 6
|
|
104
|
-
}
|
|
105
|
-
]
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
_shapeId: 'PretzelShop',
|
|
109
|
-
name: 'Auntie Pretzel Dipper',
|
|
110
|
-
nachoCheese: true
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
};
|
|
114
|
-
expect(wrapOneOfObjects(petSchema, petSchema.shapes.Mall.schema, input)).toEqual({
|
|
115
|
-
name: 'Crystal Mall',
|
|
116
|
-
shops: [
|
|
117
|
-
{
|
|
118
|
-
petStore: {
|
|
119
|
-
name: 'Petsgo',
|
|
120
|
-
animals: [
|
|
121
|
-
{
|
|
122
|
-
dog: {
|
|
123
|
-
name: 'Biff',
|
|
124
|
-
bestFriend: false
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
cat: {
|
|
129
|
-
name: 'Stuart',
|
|
130
|
-
lives: 6
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
]
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
pretzelShop: {
|
|
138
|
-
name: 'Auntie Pretzel Dipper',
|
|
139
|
-
nachoCheese: true
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
]
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
describe('unwrapOneOfObjects', () => {
|
|
147
|
-
test('it works', () => {
|
|
148
|
-
const wrapped = {
|
|
149
|
-
name: 'Crystal Mall',
|
|
150
|
-
shops: [
|
|
151
|
-
{
|
|
152
|
-
petStore: {
|
|
153
|
-
name: 'Petsgo',
|
|
154
|
-
animals: [
|
|
155
|
-
{
|
|
156
|
-
dog: {
|
|
157
|
-
name: 'Biff',
|
|
158
|
-
bestFriend: false
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
cat: {
|
|
163
|
-
name: 'Stuart',
|
|
164
|
-
lives: 6
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
]
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
pretzelShop: {
|
|
172
|
-
name: 'Auntie Pretzel Dipper',
|
|
173
|
-
nachoCheese: true
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
]
|
|
177
|
-
};
|
|
178
|
-
expect(unwrapOneOfObjects(petSchema, petSchema.shapes.Mall.schema, wrapped)).toEqual({
|
|
179
|
-
name: 'Crystal Mall',
|
|
180
|
-
shops: [
|
|
181
|
-
{
|
|
182
|
-
_shapeId: 'i8tv9QutR',
|
|
183
|
-
name: 'Petsgo',
|
|
184
|
-
animals: [
|
|
185
|
-
{
|
|
186
|
-
_shapeId: '7PSFIZU-N',
|
|
187
|
-
name: 'Biff',
|
|
188
|
-
bestFriend: false
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
_shapeId: 'k49WhBWPs',
|
|
192
|
-
name: 'Stuart',
|
|
193
|
-
lives: 6
|
|
194
|
-
}
|
|
195
|
-
]
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
_shapeId: 'PretzelShop',
|
|
199
|
-
name: 'Auntie Pretzel Dipper',
|
|
200
|
-
nachoCheese: true
|
|
201
|
-
}
|
|
202
|
-
]
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|