@takeshape/schema 11.70.2 → 11.71.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/dist/__tests__/refs.test.js +62 -1
- package/dist/migration/index.d.ts +1 -0
- package/dist/migration/index.js +3 -1
- package/dist/migration/to/v3.54.0.d.ts +4 -0
- package/dist/migration/to/v3.54.0.js +10 -0
- package/dist/project-schema/index.d.ts +4 -1
- package/dist/project-schema/index.js +2 -1
- package/dist/project-schema/latest.d.ts +27 -8
- package/dist/project-schema/migrate.js +4 -1
- package/dist/project-schema/v3.54.0.d.ts +2322 -0
- package/dist/project-schema/v3.54.0.js +7 -0
- package/dist/refs.d.ts +10 -0
- package/dist/refs.js +26 -1
- package/dist/resolvers/ai/__tests__/rag-query.test.d.ts +1 -0
- package/dist/resolvers/ai/__tests__/rag-query.test.js +49 -0
- package/dist/resolvers/ai/rag-query.d.ts +49 -0
- package/dist/resolvers/ai/rag-query.js +40 -0
- package/dist/schemas/index.d.ts +2 -2
- package/dist/schemas/index.js +4 -2
- package/dist/schemas/project-schema/latest.json +38 -2
- package/dist/schemas/project-schema/v3.54.0.json +3512 -0
- package/dist/schemas/project-schema.json +3 -0
- package/dist/util/has-arg.d.ts +3 -2
- package/dist/util/has-arg.js +14 -2
- package/examples/latest/agent-schema.json +1 -1
- 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/layers/rick-and-morty-layer.json +1 -1
- package/examples/latest/layers/shopify-layer-2023-01.json +1 -1
- package/examples/latest/layers/shopify-storefront-2023-04.json +1 -1
- package/examples/latest/layers/wordpress-2024-01.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 +4 -39
- 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-user-schema.json +53 -16
- 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 +1 -1
- package/examples/latest/vector-search-schema.json +1 -1
- package/examples/source/rag-example.json +3 -38
- package/package.json +8 -5
package/dist/refs.d.ts
CHANGED
|
@@ -224,3 +224,13 @@ export type QueryEntry = {
|
|
|
224
224
|
export declare function getQuery(projectSchema: Pick<ProjectSchemaJSON, 'services' | 'shapes' | 'queries' | 'mutations'>, queryRef: string): Maybe<QueryEntry>;
|
|
225
225
|
export declare function ensureQuery(projectSchema: ProjectSchemaJSON, queryRef: string): QueryEntry;
|
|
226
226
|
export declare function normalizeRefs(projectSchema: ProjectSchemaJSON, property: PropertySchema): PropertySchema;
|
|
227
|
+
/**
|
|
228
|
+
* Get a ShapeJSON from a RefItem, with the schema dereferenced.
|
|
229
|
+
*/
|
|
230
|
+
export declare function getReferencedShape(projectSchema: ProjectSchemaJSON, refItem: PropertyRefItem, namespace?: string): (ShapeJSON & {
|
|
231
|
+
schema: PropertySchema;
|
|
232
|
+
}) | undefined;
|
|
233
|
+
/**
|
|
234
|
+
* Get a PropertySchema from a RefItem.
|
|
235
|
+
*/
|
|
236
|
+
export declare function getReferencedShapeProperty(projectSchema: ProjectSchemaJSON, refItem: PropertyRefItem, namespace?: string): PropertySchema | undefined;
|
package/dist/refs.js
CHANGED
|
@@ -10,6 +10,7 @@ import { getServiceNamespaces } from "./services/util.js";
|
|
|
10
10
|
import { getRefType, isAllOfSchema, isExtendsSchema, isObjectSchema, isOneOfSchema, isRefSchema, isRefSchemaLegacy } from "./types/index.js";
|
|
11
11
|
import { getToolRef } from "./util/ai-tools.js";
|
|
12
12
|
import { mergeDeepObjectSchemas, mergeObjectSchemas } from "./util/merge.js";
|
|
13
|
+
import { getShape } from "./util/shapes.js";
|
|
13
14
|
/**
|
|
14
15
|
* Guard for RefItemWithPath. Tests for presence of all required props.
|
|
15
16
|
*/
|
|
@@ -440,8 +441,11 @@ export function dereferenceObjectSchema(context, shapeOrFieldSchema, schemaPath
|
|
|
440
441
|
}
|
|
441
442
|
return schema;
|
|
442
443
|
}
|
|
444
|
+
function getNamespace(context, serviceId) {
|
|
445
|
+
return context.services?.[serviceId]?.namespace;
|
|
446
|
+
}
|
|
443
447
|
export function createGetNamespace(context) {
|
|
444
|
-
return (serviceId) => context
|
|
448
|
+
return (serviceId) => getNamespace(context, serviceId);
|
|
445
449
|
}
|
|
446
450
|
export function parsePropertyRef(refStr) {
|
|
447
451
|
const [serviceId, coordinate] = splitAtRef(refStr);
|
|
@@ -606,3 +610,24 @@ export function normalizeRefs(projectSchema, property) {
|
|
|
606
610
|
}
|
|
607
611
|
return updatedProperty;
|
|
608
612
|
}
|
|
613
|
+
/**
|
|
614
|
+
* Get a ShapeJSON from a RefItem, with the schema dereferenced.
|
|
615
|
+
*/
|
|
616
|
+
export function getReferencedShape(projectSchema, refItem, namespace) {
|
|
617
|
+
const shape = getShape(projectSchema, applyNamespace(namespace ?? getNamespace(projectSchema, refItem.serviceId), refItem.shapeName));
|
|
618
|
+
if (shape) {
|
|
619
|
+
return {
|
|
620
|
+
...shape,
|
|
621
|
+
schema: dereferenceSchema(projectSchema, shape.schema, ['shapes', shape.name])
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Get a PropertySchema from a RefItem.
|
|
627
|
+
*/
|
|
628
|
+
export function getReferencedShapeProperty(projectSchema, refItem, namespace) {
|
|
629
|
+
const shape = getReferencedShape(projectSchema, refItem, namespace ?? getNamespace(projectSchema, refItem.serviceId));
|
|
630
|
+
if (shape && isObjectSchema(shape.schema)) {
|
|
631
|
+
return shape.schema.properties[refItem.propertyName];
|
|
632
|
+
}
|
|
633
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { validateRagQueryArgs } from "../rag-query.js";
|
|
3
|
+
describe('validateRagQueryArgs', () => {
|
|
4
|
+
it('should validate correct arguments', () => {
|
|
5
|
+
const validArgs = {
|
|
6
|
+
text: 'search text',
|
|
7
|
+
size: 10,
|
|
8
|
+
from: 0,
|
|
9
|
+
sort: [
|
|
10
|
+
{ field: 'fieldName', order: 'asc' },
|
|
11
|
+
{ field: 'anotherField', order: 'desc' }
|
|
12
|
+
]
|
|
13
|
+
};
|
|
14
|
+
expect(validateRagQueryArgs(validArgs)).toEqual(true);
|
|
15
|
+
});
|
|
16
|
+
it('should be false for missing required "text" field', () => {
|
|
17
|
+
const invalidArgs = {
|
|
18
|
+
size: 10
|
|
19
|
+
};
|
|
20
|
+
expect(validateRagQueryArgs(invalidArgs)).toEqual(false);
|
|
21
|
+
expect(validateRagQueryArgs?.errors?.[0].message).toEqual(`must have required property 'text'`);
|
|
22
|
+
});
|
|
23
|
+
it('should be false for invalid "size" value', () => {
|
|
24
|
+
const invalidArgs = {
|
|
25
|
+
text: 'search text',
|
|
26
|
+
size: 100 // exceeds the maximum of 50
|
|
27
|
+
};
|
|
28
|
+
expect(validateRagQueryArgs(invalidArgs)).toEqual(false);
|
|
29
|
+
expect(validateRagQueryArgs?.errors?.[0].message).toEqual(`must be <= 50`);
|
|
30
|
+
});
|
|
31
|
+
it('should be false for invalid "sort" structure', () => {
|
|
32
|
+
const invalidArgs = {
|
|
33
|
+
text: 'search text',
|
|
34
|
+
sort: [
|
|
35
|
+
{ field: 'fieldName' } // missing "order"
|
|
36
|
+
]
|
|
37
|
+
};
|
|
38
|
+
expect(validateRagQueryArgs(invalidArgs)).toEqual(false);
|
|
39
|
+
expect(validateRagQueryArgs?.errors?.[0].message).toEqual(`must have required property 'order'`);
|
|
40
|
+
});
|
|
41
|
+
it('should be false for additional properties', () => {
|
|
42
|
+
const invalidArgs = {
|
|
43
|
+
text: 'search text',
|
|
44
|
+
extraField: 'not allowed'
|
|
45
|
+
};
|
|
46
|
+
expect(validateRagQueryArgs(invalidArgs)).toEqual(false);
|
|
47
|
+
expect(validateRagQueryArgs?.errors?.[0].message).toEqual(`must NOT have additional properties`);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { FromSchema } from 'json-schema-to-ts';
|
|
2
|
+
export declare const ragQueryArgsSchema: {
|
|
3
|
+
readonly type: "object";
|
|
4
|
+
readonly properties: {
|
|
5
|
+
readonly text: {
|
|
6
|
+
readonly type: "string";
|
|
7
|
+
readonly description: "The text to search for in the documents.";
|
|
8
|
+
};
|
|
9
|
+
readonly size: {
|
|
10
|
+
readonly type: "integer";
|
|
11
|
+
readonly maximum: 50;
|
|
12
|
+
readonly description: "The maximum number of results to return.";
|
|
13
|
+
};
|
|
14
|
+
readonly from: {
|
|
15
|
+
readonly type: "integer";
|
|
16
|
+
readonly description: "A number of results to skip before starting to collect the result set. This is useful for pagination.";
|
|
17
|
+
};
|
|
18
|
+
readonly sort: {
|
|
19
|
+
readonly type: "array";
|
|
20
|
+
readonly description: "The fields to sort the results by.";
|
|
21
|
+
readonly items: {
|
|
22
|
+
readonly type: "object";
|
|
23
|
+
readonly properties: {
|
|
24
|
+
readonly field: {
|
|
25
|
+
readonly type: "string";
|
|
26
|
+
};
|
|
27
|
+
readonly order: {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly enum: ["asc", "desc"];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
readonly required: ["field", "order"];
|
|
33
|
+
readonly additionalProperties: false;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
readonly required: ["text"];
|
|
38
|
+
readonly additionalProperties: false;
|
|
39
|
+
};
|
|
40
|
+
export type RagQueryArgs = FromSchema<typeof ragQueryArgsSchema>;
|
|
41
|
+
export declare const validateRagQueryArgs: import("ajv").ValidateFunction<{
|
|
42
|
+
sort?: {
|
|
43
|
+
field: string;
|
|
44
|
+
order: "asc" | "desc";
|
|
45
|
+
}[] | undefined;
|
|
46
|
+
size?: number | undefined;
|
|
47
|
+
from?: number | undefined;
|
|
48
|
+
text: string;
|
|
49
|
+
}>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createTypedValidator } from '@takeshape/json-schema';
|
|
2
|
+
export const ragQueryArgsSchema = {
|
|
3
|
+
type: 'object',
|
|
4
|
+
properties: {
|
|
5
|
+
text: {
|
|
6
|
+
type: 'string',
|
|
7
|
+
description: 'The text to search for in the documents.'
|
|
8
|
+
},
|
|
9
|
+
size: {
|
|
10
|
+
type: 'integer',
|
|
11
|
+
maximum: 50,
|
|
12
|
+
description: 'The maximum number of results to return.'
|
|
13
|
+
},
|
|
14
|
+
from: {
|
|
15
|
+
type: 'integer',
|
|
16
|
+
description: 'A number of results to skip before starting to collect the result set. This is useful for pagination.'
|
|
17
|
+
},
|
|
18
|
+
sort: {
|
|
19
|
+
type: 'array',
|
|
20
|
+
description: 'The fields to sort the results by.',
|
|
21
|
+
items: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
field: {
|
|
25
|
+
type: 'string'
|
|
26
|
+
},
|
|
27
|
+
order: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
enum: ['asc', 'desc']
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
required: ['field', 'order'],
|
|
33
|
+
additionalProperties: false
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
required: ['text'],
|
|
38
|
+
additionalProperties: false
|
|
39
|
+
};
|
|
40
|
+
export const validateRagQueryArgs = createTypedValidator(ragQueryArgsSchema, { useDefaults: true });
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const CURRENT_SCHEMA_VERSION = "3.
|
|
1
|
+
export declare const CURRENT_SCHEMA_VERSION = "3.54.0";
|
|
2
2
|
export { default as anyProjectSchema } from './project-schema.json';
|
|
3
|
-
export { default as latestSchemaJson } from './project-schema/v3.
|
|
3
|
+
export { default as latestSchemaJson } from './project-schema/v3.54.0.json';
|
|
4
4
|
export declare const allProjectSchemas: any[];
|
package/dist/schemas/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// This file is generated by "pnpm json2ts"
|
|
2
|
-
export const CURRENT_SCHEMA_VERSION = '3.
|
|
2
|
+
export const CURRENT_SCHEMA_VERSION = '3.54.0';
|
|
3
3
|
export { default as anyProjectSchema } from './project-schema.json' with { type: 'json' };
|
|
4
|
-
export { default as latestSchemaJson } from './project-schema/v3.
|
|
4
|
+
export { default as latestSchemaJson } from './project-schema/v3.54.0.json' with { type: 'json' };
|
|
5
5
|
import experimentalSchemaJson from './project-schema/experimental.json' with { type: 'json' };
|
|
6
6
|
import metaSchemaV1_0_0 from './project-schema/meta-schema-v1.0.0.json' with { type: 'json' };
|
|
7
7
|
import projectSchemaV1_0_0 from './project-schema/v1.0.0.json' with { type: 'json' };
|
|
@@ -77,6 +77,7 @@ import projectSchemaV3_50_0 from './project-schema/v3.50.0.json' with { type: 'j
|
|
|
77
77
|
import projectSchemaV3_51_0 from './project-schema/v3.51.0.json' with { type: 'json' };
|
|
78
78
|
import projectSchemaV3_52_0 from './project-schema/v3.52.0.json' with { type: 'json' };
|
|
79
79
|
import projectSchemaV3_53_0 from './project-schema/v3.53.0.json' with { type: 'json' };
|
|
80
|
+
import projectSchemaV3_54_0 from './project-schema/v3.54.0.json' with { type: 'json' };
|
|
80
81
|
import projectSchemaV4_0_0 from './project-schema/v4.0.0.json' with { type: 'json' };
|
|
81
82
|
export const allProjectSchemas = [
|
|
82
83
|
experimentalSchemaJson,
|
|
@@ -154,5 +155,6 @@ export const allProjectSchemas = [
|
|
|
154
155
|
projectSchemaV3_51_0,
|
|
155
156
|
projectSchemaV3_52_0,
|
|
156
157
|
projectSchemaV3_53_0,
|
|
158
|
+
projectSchemaV3_54_0,
|
|
157
159
|
projectSchemaV4_0_0
|
|
158
160
|
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://schema.takeshape.io/project-schema/v3.
|
|
3
|
+
"$id": "https://schema.takeshape.io/project-schema/v3.54.0#",
|
|
4
4
|
"title": "Project Schema JSON",
|
|
5
5
|
"definitions": {
|
|
6
6
|
"schemaArray": {
|
|
@@ -926,6 +926,9 @@
|
|
|
926
926
|
{
|
|
927
927
|
"$ref": "#/definitions/aiEmbeddingResolver"
|
|
928
928
|
},
|
|
929
|
+
{
|
|
930
|
+
"$ref": "#/definitions/aiEmbeddingSearchResolver"
|
|
931
|
+
},
|
|
929
932
|
{
|
|
930
933
|
"$ref": "#/definitions/aiParseFileResolver"
|
|
931
934
|
},
|
|
@@ -1737,6 +1740,39 @@
|
|
|
1737
1740
|
"required": ["name", "service", "model"],
|
|
1738
1741
|
"additionalProperties": false
|
|
1739
1742
|
},
|
|
1743
|
+
"aiEmbeddingSearchResolver": {
|
|
1744
|
+
"title": "AIEmbeddingSearchResolver",
|
|
1745
|
+
"type": "object",
|
|
1746
|
+
"properties": {
|
|
1747
|
+
"if": {
|
|
1748
|
+
"type": "string"
|
|
1749
|
+
},
|
|
1750
|
+
"id": {
|
|
1751
|
+
"type": "string",
|
|
1752
|
+
"pattern": "^(?=[a-zA-Z])[-_a-zA-Z0-9]+$"
|
|
1753
|
+
},
|
|
1754
|
+
"name": {
|
|
1755
|
+
"title": "AI Resolver Name",
|
|
1756
|
+
"type": "string",
|
|
1757
|
+
"description": "Name of the resolver function.",
|
|
1758
|
+
"enum": ["ai:embeddingSearch"]
|
|
1759
|
+
},
|
|
1760
|
+
"vectorProperty": {
|
|
1761
|
+
"type": "string",
|
|
1762
|
+
"description": "A vector property ref to use for the query."
|
|
1763
|
+
},
|
|
1764
|
+
"args": {
|
|
1765
|
+
"description": "Mapping and serialization configuration for prompt context.",
|
|
1766
|
+
"$ref": "#/definitions/parameterConfigForJson"
|
|
1767
|
+
},
|
|
1768
|
+
"results": {
|
|
1769
|
+
"description": "Mapping configuration for the results of this resolver step.",
|
|
1770
|
+
"$ref": "#/definitions/parameterConfigForJson"
|
|
1771
|
+
}
|
|
1772
|
+
},
|
|
1773
|
+
"required": ["name", "vectorProperty"],
|
|
1774
|
+
"additionalProperties": false
|
|
1775
|
+
},
|
|
1740
1776
|
"aiParseFileResolverOptions": {
|
|
1741
1777
|
"title": "AIParseFileResolverOptions",
|
|
1742
1778
|
"type": "object"
|
|
@@ -3403,7 +3439,7 @@
|
|
|
3403
3439
|
},
|
|
3404
3440
|
"schemaVersion": {
|
|
3405
3441
|
"type": "string",
|
|
3406
|
-
"enum": ["3.
|
|
3442
|
+
"enum": ["3.54.0"],
|
|
3407
3443
|
"description": "The version of the schema format your project is using. We increase the version as we make breaking changes to the schema format."
|
|
3408
3444
|
},
|
|
3409
3445
|
"projectId": {
|