@takeshape/schema 10.52.5 → 11.0.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/migration/index.d.ts +1 -0
- package/dist/migration/index.d.ts.map +1 -1
- package/dist/migration/index.js +3 -1
- package/dist/migration/to/v3.46.0.d.ts +5 -0
- package/dist/migration/to/v3.46.0.d.ts.map +1 -0
- package/dist/migration/to/v3.46.0.js +37 -0
- package/dist/project-schema/index.d.ts +4 -1
- package/dist/project-schema/index.d.ts.map +1 -1
- package/dist/project-schema/index.js +17 -3
- package/dist/project-schema/latest.d.ts +56 -3
- package/dist/project-schema/latest.d.ts.map +1 -1
- package/dist/project-schema/migrate.d.ts.map +1 -1
- package/dist/project-schema/migrate.js +3 -0
- package/dist/project-schema/v3.46.0.d.ts +1704 -0
- package/dist/project-schema/v3.46.0.d.ts.map +1 -0
- package/dist/project-schema/v3.46.0.js +5 -0
- package/dist/refs.d.ts.map +1 -1
- package/dist/refs.js +2 -2
- package/dist/schemas/index.d.ts +2 -2
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +5 -4
- package/dist/schemas/index.ts +4 -2
- package/dist/schemas/project-schema/latest.json +81 -4
- package/dist/schemas/project-schema/v3.46.0.json +3565 -0
- package/dist/schemas/project-schema.json +3 -0
- package/dist/types/utils.d.ts +5 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/utils.js +17 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +32 -2
- package/es/migration/index.js +3 -1
- package/es/migration/to/v3.46.0.js +31 -0
- package/es/project-schema/index.js +3 -1
- package/es/project-schema/migrate.js +4 -1
- package/es/project-schema/v3.46.0.js +1 -0
- package/es/refs.js +2 -2
- package/es/schemas/index.js +4 -3
- package/es/schemas/index.ts +4 -2
- package/es/schemas/project-schema/latest.json +81 -4
- package/es/schemas/project-schema/v3.46.0.json +3565 -0
- package/es/schemas/project-schema.json +3 -0
- package/es/types/utils.js +13 -0
- package/es/validate.js +33 -3
- package/examples/latest/all-fields-shapes-inline.json +1 -1
- package/examples/latest/all-fields-shapes.json +1 -1
- package/examples/latest/betzino.json +1 -1
- package/examples/latest/blog-schema.json +1 -1
- package/examples/latest/brewery-schema.json +1 -1
- package/examples/latest/clear-cache-schema.json +1 -1
- package/examples/latest/complex-project-schema.json +1 -1
- package/examples/latest/complex-schema.json +1 -1
- package/examples/latest/edit-schema.json +1 -1
- package/examples/latest/fabric-ecommerce.json +1 -1
- package/examples/latest/frank-and-fred-schema.json +1 -1
- package/examples/latest/klirr-schema.json +1 -1
- package/examples/latest/massive-schema.json +1 -1
- package/examples/latest/mill-components-schema.json +1 -1
- package/examples/latest/nested-shape-arrays.json +1 -1
- package/examples/latest/one-earth.json +1 -1
- package/examples/latest/pet-oneof-array.json +1 -1
- package/examples/latest/post-schema.json +1 -1
- package/examples/latest/pruned-shopify-product-schema.json +1 -1
- package/examples/latest/rag-example.json +2 -2
- package/examples/latest/real-world-schema.json +1 -1
- package/examples/latest/recursive-repeater-schema.json +1 -1
- package/examples/latest/recursive-schema.json +1 -1
- package/examples/latest/rick-and-morty-ast.json +1 -1
- package/examples/latest/rick-and-morty-graphql.json +1 -1
- package/examples/latest/rick-and-morty-rest.json +1 -1
- package/examples/latest/rick-and-morty-with-indexing.json +1 -1
- package/examples/latest/schema-where-filter.json +1 -1
- package/examples/latest/schema-with-repeater-draftjs.json +1 -1
- package/examples/latest/schema-with-rick-and-morty.json +1 -1
- package/examples/latest/shape-books-v3_2_0.json +1 -1
- package/examples/latest/shape-books.json +1 -1
- package/examples/latest/shape-editor-schema-edited.json +1 -1
- package/examples/latest/shape-editor-schema-initial.json +1 -1
- package/examples/latest/shapedb-crud-every-prop-type.json +1 -1
- package/examples/latest/shopify-lookbook.json +1 -1
- package/examples/latest/shopify-product-2022-07.json +1 -1
- package/examples/latest/shopify-product-2023-04.json +1 -1
- package/examples/latest/shopify-store-with-widget.json +1 -1
- package/examples/latest/stripe-product-runtime-schema.json +1 -1
- package/examples/latest/stripe-starter-resolved.json +1 -1
- package/examples/latest/user-schema-no-required.json +1 -1
- package/examples/latest/user-schema-with-defaults.json +1 -1
- package/examples/latest/valvoline-ai-demo.json +2 -2
- package/examples/latest/vector-search-schema.json +1 -1
- package/package.json +6 -6
package/es/types/utils.js
CHANGED
|
@@ -49,9 +49,22 @@ export function isAwsLambdaResolver(resolver) {
|
|
|
49
49
|
export function isUtilResolver(resolver) {
|
|
50
50
|
return isBasicResolver(resolver) && utilResolver.properties.name.enum.includes(resolver.name);
|
|
51
51
|
}
|
|
52
|
+
export const aiResolverNames = ['ai:generateText', 'ai:chat'];
|
|
53
|
+
export function isAIResolverName(name) {
|
|
54
|
+
return name ? aiResolverNames.includes(name) : false;
|
|
55
|
+
}
|
|
56
|
+
export function isAIGenerateTextResolver(resolver) {
|
|
57
|
+
return isBasicResolver(resolver) && isAIResolverName(resolver.name);
|
|
58
|
+
}
|
|
52
59
|
export function isProjectSchemaWithServices(schema) {
|
|
53
60
|
return !isUndefined(schema.services);
|
|
54
61
|
}
|
|
62
|
+
export function containsResolver(resolver, predicate) {
|
|
63
|
+
if (isBasicResolver(resolver)) {
|
|
64
|
+
return predicate(resolver);
|
|
65
|
+
}
|
|
66
|
+
return Boolean(resolver.compose.find(resolver => containsResolver(resolver, predicate)));
|
|
67
|
+
}
|
|
55
68
|
|
|
56
69
|
/** Directive Mapping Utils **/
|
|
57
70
|
|
package/es/validate.js
CHANGED
|
@@ -22,7 +22,7 @@ import authSchemas from './schemas/auth-schemas.json';
|
|
|
22
22
|
import { getAllRefs, getShape } from './schema-util';
|
|
23
23
|
import { builtInShapes } from './builtin-schema';
|
|
24
24
|
import { isValidTemplate } from './template-shapes';
|
|
25
|
-
import { isBasicResolver, isComposeResolver, isExtendsSchema, isObjectSchema } from './types/utils';
|
|
25
|
+
import { isAIGenerateTextResolver, isBasicResolver, isComposeResolver, isExtendsSchema, isObjectSchema } from './types/utils';
|
|
26
26
|
import { refItemToNamespacedShapeName, getRefShapeName, parsePropertyRef, propertyRefItemToResolverPath, createGetNamespace, propertyRefItemToPath, atRefToRefItem, refItemToShape, refItemToAtRef } from './refs';
|
|
27
27
|
import { scalars } from './scalars';
|
|
28
28
|
import { isUnionSchema } from './unions';
|
|
@@ -225,6 +225,36 @@ function validateResolver(projectSchema, basePath, baseResolver) {
|
|
|
225
225
|
pushErrors(errors, validateAITGuardrail(resolver.guardrails[i], path.concat(['guardrails', i])));
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
+
const {
|
|
229
|
+
toolChoice
|
|
230
|
+
} = resolver.options ?? {};
|
|
231
|
+
if (toolChoice === 'required') {
|
|
232
|
+
if (!resolver.tools?.length) {
|
|
233
|
+
errors.push({
|
|
234
|
+
type: 'notFound',
|
|
235
|
+
path: path.concat(['options', 'toolChoice']),
|
|
236
|
+
message: `Must have at least one tool configured to specify "required"`
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
} else if (toolChoice && toolChoice !== 'auto' && toolChoice !== 'none') {
|
|
240
|
+
const parsed = parsePropertyRef(toolChoice);
|
|
241
|
+
if (parsed) {
|
|
242
|
+
const matchingTool = resolver.tools?.find(tool => isEqual(parsed, parsePropertyRef(getToolRef(tool))));
|
|
243
|
+
if (!matchingTool) {
|
|
244
|
+
errors.push({
|
|
245
|
+
type: 'notFound',
|
|
246
|
+
path: path.concat(['options', 'toolChoice']),
|
|
247
|
+
message: `Missing tool "${toolChoice}" must be specified in "tools" array`
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
} else {
|
|
251
|
+
errors.push({
|
|
252
|
+
type: 'conflict',
|
|
253
|
+
path: path.concat(['options', 'toolChoice']),
|
|
254
|
+
message: `Unable to parse property ref "${toolChoice}"`
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
228
258
|
};
|
|
229
259
|
const getNamespace = createGetNamespace(projectSchema);
|
|
230
260
|
for (const [resolver, path] of enumerateBasicResolvers(baseResolver, basePath)) {
|
|
@@ -250,7 +280,7 @@ function validateResolver(projectSchema, basePath, baseResolver) {
|
|
|
250
280
|
}
|
|
251
281
|
if (resolver.name === 'delegate') {
|
|
252
282
|
pushErrors(errors, validateDeletgateResolver(resolver, path));
|
|
253
|
-
} else if (resolver
|
|
283
|
+
} else if (isAIGenerateTextResolver(resolver)) {
|
|
254
284
|
validateAIGenerateTextResolver(resolver, path);
|
|
255
285
|
}
|
|
256
286
|
} else {
|
|
@@ -322,7 +352,7 @@ async function validateResolverReferences(context, projectSchema, basePath, base
|
|
|
322
352
|
message: `Missing resolver config at property ref "${resolver.to}"`
|
|
323
353
|
});
|
|
324
354
|
}
|
|
325
|
-
} else if (resolver
|
|
355
|
+
} else if (isAIGenerateTextResolver(resolver)) {
|
|
326
356
|
if (resolver.tools) {
|
|
327
357
|
await pMap(resolver.tools, async (tool, i) => {
|
|
328
358
|
const toolRef = getToolRef(tool);
|
|
@@ -52781,6 +52781,6 @@
|
|
|
52781
52781
|
}
|
|
52782
52782
|
}
|
|
52783
52783
|
},
|
|
52784
|
-
"schemaVersion": "3.
|
|
52784
|
+
"schemaVersion": "3.46.0",
|
|
52785
52785
|
"services": {}
|
|
52786
52786
|
}
|
|
@@ -10474,5 +10474,5 @@
|
|
|
10474
10474
|
}
|
|
10475
10475
|
}
|
|
10476
10476
|
},
|
|
10477
|
-
"schemaVersion": "3.
|
|
10477
|
+
"schemaVersion": "3.46.0"
|
|
10478
10478
|
}
|
|
@@ -23446,6 +23446,6 @@
|
|
|
23446
23446
|
}
|
|
23447
23447
|
}
|
|
23448
23448
|
},
|
|
23449
|
-
"schemaVersion": "3.
|
|
23449
|
+
"schemaVersion": "3.46.0",
|
|
23450
23450
|
"services": {}
|
|
23451
23451
|
}
|
|
@@ -35163,6 +35163,6 @@
|
|
|
35163
35163
|
}
|
|
35164
35164
|
}
|
|
35165
35165
|
},
|
|
35166
|
-
"schemaVersion": "3.
|
|
35166
|
+
"schemaVersion": "3.46.0",
|
|
35167
35167
|
"services": {}
|
|
35168
35168
|
}
|
|
@@ -14766,6 +14766,6 @@
|
|
|
14766
14766
|
}
|
|
14767
14767
|
}
|
|
14768
14768
|
},
|
|
14769
|
-
"schemaVersion": "3.
|
|
14769
|
+
"schemaVersion": "3.46.0",
|
|
14770
14770
|
"services": {}
|
|
14771
14771
|
}
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
}
|
|
180
180
|
},
|
|
181
181
|
{
|
|
182
|
-
"name": "ai:
|
|
182
|
+
"name": "ai:chat",
|
|
183
183
|
"service": "openai",
|
|
184
184
|
"model": "gpt-3.5-turbo",
|
|
185
185
|
"systemPrompt": "You are a helpful assistant.",
|
|
@@ -314,6 +314,6 @@
|
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
},
|
|
317
|
-
"schemaVersion": "3.
|
|
317
|
+
"schemaVersion": "3.46.0",
|
|
318
318
|
"apiVersion": "2"
|
|
319
319
|
}
|
|
@@ -49144,7 +49144,7 @@
|
|
|
49144
49144
|
}
|
|
49145
49145
|
}
|
|
49146
49146
|
},
|
|
49147
|
-
"schemaVersion": "3.
|
|
49147
|
+
"schemaVersion": "3.46.0",
|
|
49148
49148
|
"apiVersion": "2",
|
|
49149
49149
|
"services": {
|
|
49150
49150
|
"shopify": {
|
|
@@ -12297,5 +12297,5 @@
|
|
|
12297
12297
|
}
|
|
12298
12298
|
}
|
|
12299
12299
|
},
|
|
12300
|
-
"schemaVersion": "3.
|
|
12300
|
+
"schemaVersion": "3.46.0"
|
|
12301
12301
|
}
|
|
@@ -28916,5 +28916,5 @@
|
|
|
28916
28916
|
}
|
|
28917
28917
|
}
|
|
28918
28918
|
},
|
|
28919
|
-
"schemaVersion": "3.
|
|
28919
|
+
"schemaVersion": "3.46.0"
|
|
28920
28920
|
}
|
|
@@ -930,7 +930,7 @@
|
|
|
930
930
|
"shape": "ChatResponse",
|
|
931
931
|
"args": "ChatArgs",
|
|
932
932
|
"resolver": {
|
|
933
|
-
"name": "ai:
|
|
933
|
+
"name": "ai:chat",
|
|
934
934
|
"service": "openai",
|
|
935
935
|
"model": "gpt-4o",
|
|
936
936
|
"systemPrompt": "You are a very helpful assistant. \n\nFirst you must verify the user's car's \"fitment data\" which is defined as the year, make, model and engine. The year must be between 1918 and 2025. The make must be validated by the getMakes tool. The model must be validated with the getModels tool. The engine must be validated with the getEngines tool. Do not assume any fitment data always present the options available from the appropriate tool call. \n\nAfter verifying the \"fitment data\" you should suggest up to five compatible products using the listProducts tool. Please include product IDs from Shopify only, where appropriate, on their own line, with 2 line breaks before and after, with no markdown or styling, in the format: `gid://shopify/Product/8133116887317`",
|
|
@@ -1630,6 +1630,6 @@
|
|
|
1630
1630
|
}
|
|
1631
1631
|
}
|
|
1632
1632
|
},
|
|
1633
|
-
"schemaVersion": "3.
|
|
1633
|
+
"schemaVersion": "3.46.0",
|
|
1634
1634
|
"apiVersion": "2"
|
|
1635
1635
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/schema",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.1",
|
|
4
4
|
"description": "TakeShape Schema",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"p-reduce": "^2.1.0",
|
|
29
29
|
"semver": "^7.3.2",
|
|
30
30
|
"tiny-invariant": "^1.2.0",
|
|
31
|
-
"@takeshape/errors": "
|
|
32
|
-
"@takeshape/json-schema": "
|
|
33
|
-
"@takeshape/util": "
|
|
31
|
+
"@takeshape/errors": "11.0.1",
|
|
32
|
+
"@takeshape/json-schema": "11.0.1",
|
|
33
|
+
"@takeshape/util": "11.0.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@takeshape/json-schema-to-typescript": "^11.0.0",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"meow": "^9.0.0",
|
|
47
47
|
"p-map": "^5.0.0",
|
|
48
48
|
"shortid": "^2.2.15",
|
|
49
|
-
"@takeshape/infra": "
|
|
49
|
+
"@takeshape/infra": "11.0.1"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
|
-
"node": ">=
|
|
52
|
+
"node": ">=20"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "pnpm build:js && pnpm build:es && pnpm build:types && pnpm build:json && pnpm build:copy",
|