@takeshape/schema 11.89.0 → 11.92.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.
- package/dist/agents.d.ts +7 -0
- package/dist/agents.js +7 -0
- package/dist/builtin-schema.js +3 -1
- package/dist/flatten-templates.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces.d.ts +4 -2
- package/dist/interfaces.js +6 -5
- package/dist/migration/to/v3.34.0.js +2 -7
- package/dist/models/runtime-schema.js +7 -7
- package/dist/models/shape.d.ts +1 -0
- package/dist/models/shape.js +5 -2
- package/dist/project-schema/latest.d.ts +32 -12
- package/dist/project-schema/v3.48.0.d.ts +32 -12
- package/dist/project-schema/v3.49.0.d.ts +32 -12
- package/dist/project-schema/v3.50.0.d.ts +32 -12
- package/dist/project-schema/v3.51.0.d.ts +32 -12
- package/dist/project-schema/v3.52.0.d.ts +32 -12
- package/dist/project-schema/v3.53.0.d.ts +32 -12
- package/dist/project-schema/v3.54.0.d.ts +32 -12
- package/dist/project-schema/v3.55.0.d.ts +32 -12
- package/dist/refs.d.ts +30 -51
- package/dist/refs.js +101 -137
- package/dist/relationships.d.ts +1 -1
- package/dist/relationships.js +22 -31
- package/dist/schema-util.d.ts +4 -16
- package/dist/schema-util.js +12 -45
- package/dist/schemas/project-schema/experimental.json +107 -56
- package/dist/service-dependencies.js +9 -9
- package/dist/template-shapes/templates.d.ts +10 -10
- package/dist/template-shapes/templates.js +6 -9
- package/dist/template-shapes/where.js +9 -11
- package/dist/types/types.d.ts +0 -14
- package/dist/types/types.js +0 -8
- package/dist/types/utils.d.ts +2 -8
- package/dist/types/utils.js +1 -14
- package/dist/unions.js +2 -2
- package/dist/util/expressions.d.ts +13 -2
- package/dist/util/expressions.js +32 -0
- package/dist/util/form-config.js +1 -1
- package/dist/util/get-conflicting-properties.js +2 -2
- package/dist/util/has-arg.js +2 -2
- package/dist/util/is-asset-property.d.ts +3 -0
- package/dist/util/is-asset-property.js +11 -0
- package/dist/util/merge.js +1 -1
- package/dist/validate/validate.js +39 -20
- package/examples/latest/agent-schema.json +4 -2
- package/examples/source/agent-schema.json +4 -2
- package/package.json +6 -5
package/dist/schema-util.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type Maybe } from '@takeshape/util';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ProjectSchemaJSON, PropertySchema, QueryJSON, ServiceConfig, ShapeJSON, ShapeMap, ShapeSchema } from './project-schema/index.ts';
|
|
3
3
|
import { type RefItem, type RefItemWithPath, type ServicesContext, type ServicesShapesContext } from './refs.ts';
|
|
4
|
-
import { type LatestProjectSchemaWithServices, type LayerSchema, type SchemaPath, type SchemaPropertyName, type SchemaPropertyNode, type SchemaWithArgs, type
|
|
4
|
+
import { type LatestProjectSchemaWithServices, type LayerSchema, type SchemaPath, type SchemaPropertyName, type SchemaPropertyNode, type SchemaWithArgs, type ServiceMap } from './types/index.ts';
|
|
5
5
|
export declare function isBuiltinShape(shapeName: string): boolean;
|
|
6
6
|
export declare function isBuiltinQuery(name: string): boolean;
|
|
7
7
|
export declare function isBuiltinMutation(name: string): boolean;
|
|
8
|
-
export declare function isBuiltinType(projectSchema: ProjectSchemaJSON, refSchema:
|
|
8
|
+
export declare function isBuiltinType(projectSchema: ProjectSchemaJSON, refSchema: PropertySchema): boolean;
|
|
9
9
|
export declare const schemaMetadataKeys: readonly ["$comment", "title", "description", "@l10n", "@deprecationReason", "@tag", "@tags", "@syncLocaleStructure", "@sensitive"];
|
|
10
10
|
export declare const commonSchemaKeys: readonly ["type", "default", "readOnly", "$comment", "title", "description", "@l10n", "@deprecationReason", "@tag", "@tags", "@syncLocaleStructure", "@sensitive"];
|
|
11
11
|
export declare const scalarSchemaKeys: readonly ["type", "default", "readOnly", "$comment", "title", "description", "@l10n", "@deprecationReason", "@tag", "@tags", "@syncLocaleStructure", "@sensitive", "format", "oneOf", "multipleOf", "maximum", "exclusiveMaximum", "minimum", "exclusiveMinimum", "maxLength", "minLength", "pattern"];
|
|
@@ -41,7 +41,6 @@ export declare function applyBuiltinPropertiesToShape(projectSchema: ProjectSche
|
|
|
41
41
|
*/
|
|
42
42
|
export declare function getBuiltinsUsed(projectSchema: ProjectSchemaJSON): ShapeMap;
|
|
43
43
|
export declare function applyDefaultsToSchema<T extends ProjectSchemaJSON>(projectSchema: T): T;
|
|
44
|
-
export declare function getShapeByRef(projectSchema: ServicesShapesContext, shapeRef: string): ShapeJSON | undefined;
|
|
45
44
|
export declare function getArgsReference(projectSchema: ServicesContext, argsSchema: SchemaWithArgs): Maybe<RefItem>;
|
|
46
45
|
export declare function getArgsReferenceWithPath(context: ServicesContext, argsSchema: SchemaWithArgs, schemaPath?: SchemaPath): Maybe<RefItemWithPath>;
|
|
47
46
|
export declare function getArgsShapeSchema(context: ServicesShapesContext, argsSchema: SchemaWithArgs): Maybe<ShapeSchema>;
|
|
@@ -99,7 +98,7 @@ export declare function shapeToJsonSchema(projectSchema: ProjectSchemaJSON, shap
|
|
|
99
98
|
'@l10n'?: boolean;
|
|
100
99
|
'@key'?: string;
|
|
101
100
|
'@workflow'?: string;
|
|
102
|
-
'@mapping'?: FieldMapping;
|
|
101
|
+
'@mapping'?: import("./project-schema/latest.ts").FieldMapping;
|
|
103
102
|
'@tag'?: string;
|
|
104
103
|
'@tags'?: string[];
|
|
105
104
|
'@deprecationReason'?: string;
|
|
@@ -147,30 +146,20 @@ export declare function getAllRefsInQueries(projectSchema: Pick<ProjectSchemaJSO
|
|
|
147
146
|
* @param predicate return true to include the ref in
|
|
148
147
|
*/
|
|
149
148
|
export declare function getAllRefs(projectSchema: Pick<ProjectSchemaJSON, 'queries' | 'mutations' | 'shapes' | 'services'>, predicate?: RefPredicate): RefItemWithPath[];
|
|
150
|
-
export declare function isValidRefItem(refItem: RefItem): boolean;
|
|
151
149
|
/**
|
|
152
150
|
* Get all valid refs in a ProjectSchemaJSON
|
|
153
151
|
* @param predicate return true to include the ref in
|
|
154
152
|
*/
|
|
155
153
|
export declare function getAllValidRefs(projectSchema: Pick<ProjectSchemaJSON, 'queries' | 'mutations' | 'shapes' | 'services'>, predicate?: RefPredicate): RefItemWithPath[];
|
|
156
|
-
export type Mapping = {
|
|
157
|
-
providerId: string;
|
|
158
|
-
serviceId: string;
|
|
159
|
-
shapeName: string;
|
|
160
|
-
key: string;
|
|
161
|
-
};
|
|
162
|
-
export declare function parseMapping(mapping: string): Mapping;
|
|
163
154
|
export declare function splitMapping(mapping: string): string[];
|
|
164
155
|
export declare function findMapping(schema: PropertySchema, predicate: (mappingStr: string) => boolean): string | undefined;
|
|
165
156
|
export declare function getFirstMapping(schema: PropertySchema): string | undefined;
|
|
166
|
-
export declare function getFullyQualifiedShapeName(schema: PropertySchema): string | undefined;
|
|
167
157
|
/**
|
|
168
158
|
* Find key for use storing data in ShapeDB or API Indexing this allows renaming of properties without db migration
|
|
169
159
|
* Mapping must be using the shapedb service id
|
|
170
160
|
* @param schema
|
|
171
161
|
*/
|
|
172
162
|
export declare function getStorageKey(schema: PropertySchema): string | undefined;
|
|
173
|
-
export declare function getPropertyService(schema: PropertySchema): string | undefined;
|
|
174
163
|
export declare function emptySchema(projectId: string): ProjectSchemaJSON;
|
|
175
164
|
export declare function createLayerSchema(partialSchema?: Partial<LayerSchema>): LayerSchema;
|
|
176
165
|
export declare function getShapesById(projectSchema: ProjectSchemaJSON): ShapeMap;
|
|
@@ -264,7 +253,6 @@ export declare const getDefaultMutationName: (shapeName: string, resolver: Resol
|
|
|
264
253
|
export declare function createShape(name: string, schema: ShapeSchema, rest?: Partial<ShapeJSON>): ShapeJSON;
|
|
265
254
|
export declare function queryToPropertySchema(projectSchema: ProjectSchemaJSON, query: QueryJSON): PropertySchema;
|
|
266
255
|
export declare function getQueriesShape(projectSchema: ProjectSchemaJSON, operation: 'query' | 'mutation'): ShapeJSON;
|
|
267
|
-
export declare function fieldMappingContainsKey(fieldMapping: FieldMapping, key: string): boolean;
|
|
268
256
|
/**
|
|
269
257
|
* Return true if `schemaWithRef` is a ref to a shape named `shapeName`
|
|
270
258
|
*/
|
package/dist/schema-util.js
CHANGED
|
@@ -5,12 +5,11 @@ import isArray from 'lodash/isArray.js';
|
|
|
5
5
|
import isString from 'lodash/isString.js';
|
|
6
6
|
import keyBy from 'lodash/keyBy.js';
|
|
7
7
|
import mapValues from 'lodash/mapValues.js';
|
|
8
|
-
import some from 'lodash/some.js';
|
|
9
8
|
import uniq from 'lodash/uniq.js';
|
|
10
9
|
import { workflowsEnabled } from "./api-version.js";
|
|
11
10
|
import { builtInForms, builtInShapes } from "./builtin-schema.js";
|
|
12
11
|
import { SERVICE_OBJECT_PATTERN_NAME } from "./constants.js";
|
|
13
|
-
import {
|
|
12
|
+
import { createTemplateShapeName, dereferenceObjectSchema, dereferenceSchema, getRef, getRefOrItemsRef, getRefShapeName, isValidRefItem, parseRef, parseReturnShape, refItemToNamespacedShapeName, refItemToShape, refItemToShapeSchema, refToRefItem, returnShapeToSchema, serializePropertyRef } from "./refs.js";
|
|
14
13
|
import { getArgsType, isAllOfSchema, isArraySchema, isCachedShape, isExtendsSchema, isGraphqlResolver, isModelShape, isObjectSchema, isOneOfSchema, isReferenceableShape, isRefSchema } from "./types/index.js";
|
|
15
14
|
import { isUnionSchema } from "./unions.js";
|
|
16
15
|
import { getArgs } from "./util/has-arg.js";
|
|
@@ -384,7 +383,7 @@ const requiredBuiltinShapes = ['Asset', 'TSRelationship', 'TSStaticSite', 'TSUse
|
|
|
384
383
|
*/
|
|
385
384
|
export function getBuiltinsUsed(projectSchema) {
|
|
386
385
|
const builtinsUsed = {};
|
|
387
|
-
const shapeNames = uniq(requiredBuiltinShapes.concat(getAllRefs(projectSchema, (refItem) => refItem.
|
|
386
|
+
const shapeNames = uniq(requiredBuiltinShapes.concat(getAllRefs(projectSchema, (refItem) => refItem.layerId === 'local' && isBuiltinShape(refItem.shapeName)).map((ref) => refItemToNamespacedShapeName(projectSchema, ref))));
|
|
388
387
|
const schemaWithAllBuiltins = {
|
|
389
388
|
...emptySchema('project-id'),
|
|
390
389
|
shapes: builtInShapes
|
|
@@ -437,14 +436,11 @@ export function applyDefaultsToSchema(projectSchema) {
|
|
|
437
436
|
})
|
|
438
437
|
};
|
|
439
438
|
}
|
|
440
|
-
export function getShapeByRef(projectSchema, shapeRef) {
|
|
441
|
-
return refItemToShape(projectSchema, atRefToRefItem(projectSchema, shapeRef));
|
|
442
|
-
}
|
|
443
439
|
export function getArgsReference(projectSchema, argsSchema) {
|
|
444
440
|
const args = getArgs(argsSchema);
|
|
445
441
|
if (args && typeof args === 'string') {
|
|
446
442
|
// @args: ShapeName OR Namespace_TypeName
|
|
447
|
-
return
|
|
443
|
+
return parseRef(projectSchema, args);
|
|
448
444
|
}
|
|
449
445
|
}
|
|
450
446
|
export function getArgsReferenceWithPath(context, argsSchema, schemaPath = []) {
|
|
@@ -500,7 +496,7 @@ const createShapeToPropertySchema = (projectSchema, definitions, definitionNames
|
|
|
500
496
|
}
|
|
501
497
|
const refItem = getRef(projectSchema, propSchema);
|
|
502
498
|
if (refItem) {
|
|
503
|
-
const shapeName = refItemToNamespacedShapeName(refItem);
|
|
499
|
+
const shapeName = refItemToNamespacedShapeName(projectSchema, refItem);
|
|
504
500
|
const shape = refItemToShape(projectSchema, refItem);
|
|
505
501
|
if (shape) {
|
|
506
502
|
delete propSchema['@ref'];
|
|
@@ -689,7 +685,7 @@ export function getAllRefsInShapes(projectSchema, predicate) {
|
|
|
689
685
|
if (propName === 'interfaces' && isArray(interfaces)) {
|
|
690
686
|
interfaces.forEach((interfaceRefExpression, index) => {
|
|
691
687
|
addRef(items, {
|
|
692
|
-
...
|
|
688
|
+
...parseRef(projectSchema, interfaceRefExpression),
|
|
693
689
|
path: [...path, index]
|
|
694
690
|
}, predicate);
|
|
695
691
|
});
|
|
@@ -701,14 +697,13 @@ export function getAllRefsInShapes(projectSchema, predicate) {
|
|
|
701
697
|
return;
|
|
702
698
|
}
|
|
703
699
|
if (propName === '@ref') {
|
|
704
|
-
|
|
705
|
-
addRef(items, { ...atRefToRefItem(projectSchema, shapeName, template), path }, predicate);
|
|
700
|
+
addRef(items, { ...parseRef(projectSchema, interfaces), path }, predicate);
|
|
706
701
|
}
|
|
707
702
|
else if (propName === '$ref') {
|
|
708
703
|
addRef(items, { ...refToRefItem(projectSchema, interfaces), path }, predicate);
|
|
709
704
|
}
|
|
710
705
|
else if (propName === '@args' || propName === 'args') {
|
|
711
|
-
addRef(items, { ...
|
|
706
|
+
addRef(items, { ...parseRef(projectSchema, interfaces), path }, predicate);
|
|
712
707
|
}
|
|
713
708
|
});
|
|
714
709
|
return items;
|
|
@@ -764,25 +759,12 @@ export function getAllRefs(projectSchema, predicate) {
|
|
|
764
759
|
...getAllRefsInQueries(projectSchema, 'mutations', predicate)
|
|
765
760
|
];
|
|
766
761
|
}
|
|
767
|
-
export function isValidRefItem(refItem) {
|
|
768
|
-
return refItem.isValidService;
|
|
769
|
-
}
|
|
770
762
|
/**
|
|
771
763
|
* Get all valid refs in a ProjectSchemaJSON
|
|
772
764
|
* @param predicate return true to include the ref in
|
|
773
765
|
*/
|
|
774
766
|
export function getAllValidRefs(projectSchema, predicate) {
|
|
775
|
-
return getAllRefs(projectSchema, predicate).filter(isValidRefItem);
|
|
776
|
-
}
|
|
777
|
-
export function parseMapping(mapping) {
|
|
778
|
-
const [providerId, serviceId, coordinate] = mapping.split(':');
|
|
779
|
-
const [shapeName, key] = coordinate.split('.');
|
|
780
|
-
return {
|
|
781
|
-
providerId,
|
|
782
|
-
serviceId,
|
|
783
|
-
shapeName,
|
|
784
|
-
key
|
|
785
|
-
};
|
|
767
|
+
return getAllRefs(projectSchema, predicate).filter(isValidRefItem(projectSchema));
|
|
786
768
|
}
|
|
787
769
|
export function splitMapping(mapping) {
|
|
788
770
|
const parts = mapping.split('.');
|
|
@@ -798,10 +780,6 @@ export function findMapping(schema, predicate) {
|
|
|
798
780
|
export function getFirstMapping(schema) {
|
|
799
781
|
return Array.isArray(schema['@mapping']) ? schema['@mapping'][0] : schema['@mapping'];
|
|
800
782
|
}
|
|
801
|
-
export function getFullyQualifiedShapeName(schema) {
|
|
802
|
-
const first = getFirstMapping(schema);
|
|
803
|
-
return first ? splitMapping(first)[0] : undefined;
|
|
804
|
-
}
|
|
805
783
|
/**
|
|
806
784
|
* Find key for use storing data in ShapeDB or API Indexing this allows renaming of properties without db migration
|
|
807
785
|
* Mapping must be using the shapedb service id
|
|
@@ -811,11 +789,6 @@ export function getStorageKey(schema) {
|
|
|
811
789
|
const first = findMapping(schema, (mapping) => mapping.startsWith('shapedb:'));
|
|
812
790
|
return first ? splitMapping(first)[1] : undefined;
|
|
813
791
|
}
|
|
814
|
-
export function getPropertyService(schema) {
|
|
815
|
-
const first = getFirstMapping(schema);
|
|
816
|
-
const split = first?.split(':');
|
|
817
|
-
return split ? `${split[0]}:${split[1]}` : undefined;
|
|
818
|
-
}
|
|
819
792
|
export function emptySchema(projectId) {
|
|
820
793
|
return {
|
|
821
794
|
projectId,
|
|
@@ -851,8 +824,8 @@ export function getShapesById(projectSchema) {
|
|
|
851
824
|
* @returns A `string` array with all the shapes that are in namespaces.
|
|
852
825
|
*/
|
|
853
826
|
export function getAllNamespaceShapes(projectSchema) {
|
|
854
|
-
const isServiceRef = (refItem) =>
|
|
855
|
-
return uniq(getAllValidRefs(projectSchema, isServiceRef).map(refItemToNamespacedShapeName));
|
|
827
|
+
const isServiceRef = (refItem) => refItem.layerId !== 'local';
|
|
828
|
+
return uniq(getAllValidRefs(projectSchema, isServiceRef).map((ref) => refItemToNamespacedShapeName(projectSchema, ref)));
|
|
856
829
|
}
|
|
857
830
|
/**
|
|
858
831
|
* Returns a list of all shape names in a service namespace, excluding any
|
|
@@ -1052,7 +1025,7 @@ export function queryToPropertySchema(projectSchema, query) {
|
|
|
1052
1025
|
let mapping;
|
|
1053
1026
|
if (isGraphqlResolver(query.resolver)) {
|
|
1054
1027
|
mapping = serializePropertyRef({
|
|
1055
|
-
|
|
1028
|
+
layerId: query.resolver.service,
|
|
1056
1029
|
shapeName: 'Query',
|
|
1057
1030
|
propertyName: query.resolver.fieldName
|
|
1058
1031
|
});
|
|
@@ -1070,18 +1043,12 @@ export function getQueriesShape(projectSchema, operation) {
|
|
|
1070
1043
|
properties: mapValues(projectSchema[operation === 'query' ? 'queries' : 'mutations'], (query) => queryToPropertySchema(projectSchema, query))
|
|
1071
1044
|
});
|
|
1072
1045
|
}
|
|
1073
|
-
export function fieldMappingContainsKey(fieldMapping, key) {
|
|
1074
|
-
if (isArray(fieldMapping)) {
|
|
1075
|
-
return some(fieldMapping, (mapping) => parseMapping(mapping).key === key);
|
|
1076
|
-
}
|
|
1077
|
-
return parseMapping(fieldMapping).key === key;
|
|
1078
|
-
}
|
|
1079
1046
|
/**
|
|
1080
1047
|
* Return true if `schemaWithRef` is a ref to a shape named `shapeName`
|
|
1081
1048
|
*/
|
|
1082
1049
|
export function schemaMatchesShapeName(workingCopy, propertySchema, shapeName) {
|
|
1083
1050
|
const arrayOfShapeRef = getRef(workingCopy, propertySchema);
|
|
1084
|
-
return Boolean(arrayOfShapeRef && refItemToNamespacedShapeName(arrayOfShapeRef) === shapeName);
|
|
1051
|
+
return Boolean(arrayOfShapeRef && refItemToNamespacedShapeName(workingCopy, arrayOfShapeRef) === shapeName);
|
|
1085
1052
|
}
|
|
1086
1053
|
/**
|
|
1087
1054
|
* Return true if `shape` has a property that is an array of refs to `shapeName`
|
|
@@ -30,11 +30,115 @@
|
|
|
30
30
|
"items": {
|
|
31
31
|
"$ref": "#/definitions/agentGuard"
|
|
32
32
|
}
|
|
33
|
+
},
|
|
34
|
+
"historyStrategies": {
|
|
35
|
+
"$ref": "#/definitions/historyStrategyMap"
|
|
33
36
|
}
|
|
34
37
|
},
|
|
35
38
|
"required": ["start", "states", "api"],
|
|
36
39
|
"additionalProperties": false
|
|
37
40
|
},
|
|
41
|
+
"historyStrategyMap": {
|
|
42
|
+
"title": "History Strategy Map",
|
|
43
|
+
"type": "object",
|
|
44
|
+
"patternProperties": {
|
|
45
|
+
"^[0-9A-Za-z_]+$": {
|
|
46
|
+
"$ref": "#/definitions/historyStrategy"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"additionalProperties": false
|
|
50
|
+
},
|
|
51
|
+
"historyStrategy": {
|
|
52
|
+
"title": "History Strategy",
|
|
53
|
+
"type": "object",
|
|
54
|
+
"properties": {
|
|
55
|
+
"name": {
|
|
56
|
+
"type": "string"
|
|
57
|
+
},
|
|
58
|
+
"variables": {
|
|
59
|
+
"title": "Variables",
|
|
60
|
+
"type": "array",
|
|
61
|
+
"items": {
|
|
62
|
+
"$ref": "#/definitions/agentVariable"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"filter": {
|
|
66
|
+
"$ref": "#/definitions/historyStrategyFilter"
|
|
67
|
+
},
|
|
68
|
+
"execution": {
|
|
69
|
+
"$ref": "#/definitions/historyStrategyExecution"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"required": ["name", "execution"],
|
|
73
|
+
"additionalProperties": false
|
|
74
|
+
},
|
|
75
|
+
"historyStrategyFilter": {
|
|
76
|
+
"title": "History Strategy Filter",
|
|
77
|
+
"type": "object",
|
|
78
|
+
"properties": {
|
|
79
|
+
"toolCalls": {
|
|
80
|
+
"enum": ["retain", "clear"]
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"additionalProperties": false
|
|
84
|
+
},
|
|
85
|
+
"historyStrategyExecution": {
|
|
86
|
+
"title": "History Strategy Execution",
|
|
87
|
+
"discriminator": {
|
|
88
|
+
"propertyName": "type"
|
|
89
|
+
},
|
|
90
|
+
"oneOf": [
|
|
91
|
+
{
|
|
92
|
+
"$ref": "#/definitions/historyStrategyExecutionReplace"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"$ref": "#/definitions/historyStrategyExecutionSummarize"
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
"historyStrategyExecutionReplace": {
|
|
100
|
+
"title": "History Strategy Execution Replace",
|
|
101
|
+
"type": "object",
|
|
102
|
+
"properties": {
|
|
103
|
+
"type": {
|
|
104
|
+
"enum": ["replace"]
|
|
105
|
+
},
|
|
106
|
+
"template": {
|
|
107
|
+
"type": "string"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"required": ["type", "template"],
|
|
111
|
+
"additionalProperties": false
|
|
112
|
+
},
|
|
113
|
+
"historyStrategyExecutionSummarize": {
|
|
114
|
+
"title": "History Strategy Execution Summarize",
|
|
115
|
+
"type": "object",
|
|
116
|
+
"properties": {
|
|
117
|
+
"type": {
|
|
118
|
+
"enum": ["generate"]
|
|
119
|
+
},
|
|
120
|
+
"service": {
|
|
121
|
+
"type": "string"
|
|
122
|
+
},
|
|
123
|
+
"model": {
|
|
124
|
+
"type": "string"
|
|
125
|
+
},
|
|
126
|
+
"systemPrompt": {
|
|
127
|
+
"type": "string"
|
|
128
|
+
},
|
|
129
|
+
"tools": {
|
|
130
|
+
"type": "array",
|
|
131
|
+
"items": {
|
|
132
|
+
"$ref": "#/definitions/agentToolConfig"
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"options": {
|
|
136
|
+
"$ref": "#/definitions/agentGenerateOptions"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"required": ["type", "service", "model", "systemPrompt"],
|
|
140
|
+
"additionalProperties": false
|
|
141
|
+
},
|
|
38
142
|
"tool": {
|
|
39
143
|
"title": "Tool JSON",
|
|
40
144
|
"type": "object",
|
|
@@ -604,59 +708,6 @@
|
|
|
604
708
|
"required": ["type", "argName", "variableName"],
|
|
605
709
|
"additionalProperties": false
|
|
606
710
|
},
|
|
607
|
-
"agentChatHistoryConfig": {
|
|
608
|
-
"title": "Agent Chat History Config",
|
|
609
|
-
"discriminator": {
|
|
610
|
-
"propertyName": "type"
|
|
611
|
-
},
|
|
612
|
-
"oneOf": [
|
|
613
|
-
{
|
|
614
|
-
"$ref": "#/definitions/agentChatHistoryRetain"
|
|
615
|
-
},
|
|
616
|
-
{
|
|
617
|
-
"$ref": "#/definitions/agentChatHistorySummarize"
|
|
618
|
-
},
|
|
619
|
-
{
|
|
620
|
-
"$ref": "#/definitions/agentChatHistoryClear"
|
|
621
|
-
}
|
|
622
|
-
]
|
|
623
|
-
},
|
|
624
|
-
"agentChatHistoryRetain": {
|
|
625
|
-
"title": "Agent Chat History Retain",
|
|
626
|
-
"type": "object",
|
|
627
|
-
"properties": {
|
|
628
|
-
"type": {
|
|
629
|
-
"enum": ["retain"]
|
|
630
|
-
}
|
|
631
|
-
},
|
|
632
|
-
"required": ["type"],
|
|
633
|
-
"additionalProperties": false
|
|
634
|
-
},
|
|
635
|
-
"agentChatHistorySummarize": {
|
|
636
|
-
"title": "Agent Chat History Summarize",
|
|
637
|
-
"type": "object",
|
|
638
|
-
"properties": {
|
|
639
|
-
"type": {
|
|
640
|
-
"enum": ["summarize"]
|
|
641
|
-
},
|
|
642
|
-
"toolCalls": {
|
|
643
|
-
"enum": ["retain", "clear"]
|
|
644
|
-
}
|
|
645
|
-
},
|
|
646
|
-
"required": ["type", "toolCalls"],
|
|
647
|
-
"additionalProperties": false
|
|
648
|
-
},
|
|
649
|
-
"agentChatHistoryClear": {
|
|
650
|
-
"title": "Agent Chat History Clear",
|
|
651
|
-
"type": "object",
|
|
652
|
-
"properties": {
|
|
653
|
-
"type": {
|
|
654
|
-
"enum": ["clear"]
|
|
655
|
-
}
|
|
656
|
-
},
|
|
657
|
-
"required": ["type"],
|
|
658
|
-
"additionalProperties": false
|
|
659
|
-
},
|
|
660
711
|
"agentExecutionGenerate": {
|
|
661
712
|
"title": "Agent Execution Generate",
|
|
662
713
|
"type": "object",
|
|
@@ -720,9 +771,6 @@
|
|
|
720
771
|
"$ref": "#/definitions/agentToolConfig"
|
|
721
772
|
}
|
|
722
773
|
},
|
|
723
|
-
"history": {
|
|
724
|
-
"$ref": "#/definitions/agentChatHistoryConfig"
|
|
725
|
-
},
|
|
726
774
|
"options": {
|
|
727
775
|
"$ref": "#/definitions/agentGenerateOptions"
|
|
728
776
|
}
|
|
@@ -747,6 +795,9 @@
|
|
|
747
795
|
},
|
|
748
796
|
"limit": {
|
|
749
797
|
"type": "integer"
|
|
798
|
+
},
|
|
799
|
+
"historyStrategy": {
|
|
800
|
+
"type": "string"
|
|
750
801
|
}
|
|
751
802
|
},
|
|
752
803
|
"additionalProperties": false,
|
|
@@ -4,8 +4,8 @@ import isObject from 'lodash/isObject.js';
|
|
|
4
4
|
import pick from 'lodash/pick.js';
|
|
5
5
|
import set from 'lodash/set.js';
|
|
6
6
|
import { getImplementationShapeNameMap, isInterfaceShape, pruneUnusedInterfaces } from "./interfaces.js";
|
|
7
|
-
import { createGetNamespace, dereferenceObjectSchema, getAllPropertyRefs, getRef, getRefShapeName, propertyRefItemToPath,
|
|
8
|
-
import { getAllNamespaceShapes, getAllRefsInQuery, getArgsReference,
|
|
7
|
+
import { createGetNamespace, dereferenceObjectSchema, getAllPropertyRefs, getRef, getRefShapeName, isValidRefItem, propertyRefItemToPath, refExpressionToNamespacedName, refItemToNamespacedShapeName } from "./refs.js";
|
|
8
|
+
import { getAllNamespaceShapes, getAllRefsInQuery, getArgsReference, visitSchemaProperties } from "./schema-util.js";
|
|
9
9
|
import { isExtendsSchema, isObjectSchema, isProjectSchemaWithServices } from "./types/index.js";
|
|
10
10
|
function getGraphQLServiceShapeMap(layers) {
|
|
11
11
|
return Object.assign({}, ...Object.values(layers).map((layer) => layer.schema?.shapes ?? {}));
|
|
@@ -22,7 +22,7 @@ function getMissingPropertyRefs(projectSchema, getNamespace) {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
function refToQuery(serviceSchemas, ref) {
|
|
25
|
-
const serviceSchema = serviceSchemas[ref.
|
|
25
|
+
const serviceSchema = serviceSchemas[ref.layerId]?.schema;
|
|
26
26
|
if (serviceSchema) {
|
|
27
27
|
if (ref.shapeName === 'Query' || ref.shapeName === 'Mutation') {
|
|
28
28
|
const operation = ref.shapeName === 'Query' ? 'queries' : 'mutations';
|
|
@@ -34,11 +34,11 @@ function getShapeRefs(services, serviceSchemas, propertyRefs) {
|
|
|
34
34
|
const results = [];
|
|
35
35
|
for (const ref of propertyRefs) {
|
|
36
36
|
const query = refToQuery(serviceSchemas, ref);
|
|
37
|
-
const layerSchema = serviceSchemas[ref.
|
|
37
|
+
const layerSchema = serviceSchemas[ref.layerId]?.schema;
|
|
38
38
|
if (query && layerSchema) {
|
|
39
39
|
const layerWithService = {
|
|
40
40
|
...layerSchema,
|
|
41
|
-
services: pick(services, [ref.
|
|
41
|
+
services: pick(services, [ref.layerId]) // include own service so refs have isValidService: true
|
|
42
42
|
};
|
|
43
43
|
results.push(...getAllRefsInQuery(layerWithService, [], query));
|
|
44
44
|
}
|
|
@@ -46,14 +46,14 @@ function getShapeRefs(services, serviceSchemas, propertyRefs) {
|
|
|
46
46
|
return results;
|
|
47
47
|
}
|
|
48
48
|
function interfacesToShapeNames(projectSchema, shapeRefArray) {
|
|
49
|
-
return shapeRefArray.map((shapeRef) =>
|
|
49
|
+
return shapeRefArray.map((shapeRef) => refExpressionToNamespacedName(projectSchema, shapeRef));
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Add all referenced shape names to the refSet meant to be used as a callback to visitSchemaProperties
|
|
53
53
|
*/
|
|
54
54
|
export function collectReferencedShapeNames(context, shapeNames) {
|
|
55
55
|
const addRef = (refItem) => {
|
|
56
|
-
shapeNames.add(refItemToNamespacedShapeName(refItem));
|
|
56
|
+
shapeNames.add(refItemToNamespacedShapeName(context, refItem));
|
|
57
57
|
};
|
|
58
58
|
const collect = (schema) => {
|
|
59
59
|
const args = schema['@args'];
|
|
@@ -87,8 +87,8 @@ export function resolveSchemaShapeDependencies(projectSchema, serviceLayers) {
|
|
|
87
87
|
const remoteShapeMap = getGraphQLServiceShapeMap(serviceLayers);
|
|
88
88
|
// Add shape references from queries
|
|
89
89
|
addAll(requiredShapeNames, getShapeRefs(projectSchema.services, serviceLayers, missingPropertyRefs)
|
|
90
|
-
.filter(isValidRefItem)
|
|
91
|
-
.map(refItemToNamespacedShapeName));
|
|
90
|
+
.filter(isValidRefItem(projectSchema))
|
|
91
|
+
.map((item) => refItemToNamespacedShapeName(projectSchema, item)));
|
|
92
92
|
// Add referenced queries and mutations
|
|
93
93
|
for (const ref of missingPropertyRefs) {
|
|
94
94
|
const query = refToQuery(serviceLayers, ref);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ObjectSchema, PropertySchema, ShapeJSON } from '../project-schema/index.ts';
|
|
2
2
|
import type { ResolvedTemplate, TemplateContext } from './types.ts';
|
|
3
3
|
import { TemplateVerbs } from './types.ts';
|
|
4
|
-
export declare const TSGetArgs: (
|
|
5
|
-
export declare const TSGetSingletonArgs: (
|
|
4
|
+
export declare const TSGetArgs: (_context: unknown, shape: ShapeJSON) => ResolvedTemplate;
|
|
5
|
+
export declare const TSGetSingletonArgs: (_context: unknown, shape: ShapeJSON) => ResolvedTemplate;
|
|
6
6
|
export declare const TSListArgs: (context: TemplateContext, shape: ShapeJSON) => ResolvedTemplate;
|
|
7
7
|
export declare const TSSearchArgs: (context: TemplateContext, shape: ShapeJSON) => ResolvedTemplate;
|
|
8
8
|
export declare const CreateArgs: ({ projectSchema }: TemplateContext, shape: ShapeJSON) => ResolvedTemplate;
|
|
@@ -11,22 +11,22 @@ export declare const DuplicateArgs: ({ projectSchema }: TemplateContext, shape:
|
|
|
11
11
|
export declare const DeleteArgs: ({ projectSchema }: TemplateContext, shape: ShapeJSON) => ResolvedTemplate;
|
|
12
12
|
export declare const PaginatedList: typeof getPaginatedListShape;
|
|
13
13
|
export declare const SearchResults: typeof getSearchResultsShape;
|
|
14
|
-
export declare const CreateResult: (
|
|
15
|
-
export declare const UpdateResult: (
|
|
16
|
-
export declare const DuplicateResult: (
|
|
17
|
-
export declare const DeleteResult: (
|
|
14
|
+
export declare const CreateResult: (_context: unknown, shape: ShapeJSON) => ResolvedTemplate;
|
|
15
|
+
export declare const UpdateResult: (_context: unknown, shape: ShapeJSON) => ResolvedTemplate;
|
|
16
|
+
export declare const DuplicateResult: (_context: unknown, shape: ShapeJSON) => ResolvedTemplate;
|
|
17
|
+
export declare const DeleteResult: (_context: unknown, shape: ShapeJSON) => ResolvedTemplate;
|
|
18
18
|
export declare const TSSearchSortInput: ShapeJSON;
|
|
19
19
|
export declare const commonSearchProps: Record<string, PropertySchema>;
|
|
20
20
|
export declare const localeProps: ObjectSchema;
|
|
21
21
|
export declare const termsProps: ObjectSchema;
|
|
22
22
|
export declare const TSContentStructureInput: ShapeJSON;
|
|
23
|
-
export declare function getPaginatedListShape(
|
|
24
|
-
export declare function getSearchResultsShape(
|
|
25
|
-
export declare function getIDQueryArgs(templateName: string): (
|
|
23
|
+
export declare function getPaginatedListShape(_context: unknown, shape: ShapeJSON): ResolvedTemplate;
|
|
24
|
+
export declare function getSearchResultsShape(_context: unknown, shape: ShapeJSON): ResolvedTemplate;
|
|
25
|
+
export declare function getIDQueryArgs(templateName: string): (_context: unknown, shape: ShapeJSON) => ResolvedTemplate;
|
|
26
26
|
/**
|
|
27
27
|
* Construct shapes for a mutation inputs, given source shape info.
|
|
28
28
|
*/
|
|
29
29
|
export declare function getMutationArgs(templateName: string, verb: TemplateVerbs): ({ projectSchema }: TemplateContext, shape: ShapeJSON) => ResolvedTemplate;
|
|
30
|
-
export declare function getMutationResultType(verb: TemplateVerbs): (
|
|
30
|
+
export declare function getMutationResultType(verb: TemplateVerbs): (_context: unknown, shape: ShapeJSON) => ResolvedTemplate;
|
|
31
31
|
export declare const commonSearchArgs: ObjectSchema;
|
|
32
32
|
export declare function getShapeListQueryArgs(templateName: string, legacyArgs: boolean): (context: TemplateContext, shape: ShapeJSON) => ResolvedTemplate;
|
|
@@ -3,7 +3,7 @@ import get from 'lodash/get.js';
|
|
|
3
3
|
import keyBy from 'lodash/keyBy.js';
|
|
4
4
|
import { createInputSchema } from "../create-input-schema.js";
|
|
5
5
|
import { listTypePrefix } from "../migration/index.js";
|
|
6
|
-
import { getFlattenedTemplateShapeName, getRef, getRefShapeName,
|
|
6
|
+
import { getFlattenedTemplateShapeName, getRef, getRefShapeName, serializeRef } from "../refs.js";
|
|
7
7
|
import { createShape, getShapeDependencies } from "../schema-util.js";
|
|
8
8
|
import { isCachedShape } from "../types/index.js";
|
|
9
9
|
import { mergeObjectSchemas, mergeSchemaProperties } from "../util/merge.js";
|
|
@@ -88,7 +88,7 @@ export const TSContentStructureInput = createShape('TSContentStructureInput', {
|
|
|
88
88
|
},
|
|
89
89
|
required: ['path']
|
|
90
90
|
}, { description: 'Describes a structural update to an array of data.' });
|
|
91
|
-
export function getPaginatedListShape(
|
|
91
|
+
export function getPaginatedListShape(_context, shape) {
|
|
92
92
|
const shapeName = `${shape.name}${listTypePrefix}`;
|
|
93
93
|
return {
|
|
94
94
|
shapeName,
|
|
@@ -104,7 +104,7 @@ export function getPaginatedListShape(context, shape) {
|
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
-
export function getSearchResultsShape(
|
|
107
|
+
export function getSearchResultsShape(_context, shape) {
|
|
108
108
|
const shapeName = `${shape.name}SearchResults`;
|
|
109
109
|
return {
|
|
110
110
|
shapeName,
|
|
@@ -142,7 +142,7 @@ const idSchema = {
|
|
|
142
142
|
required: ['_id']
|
|
143
143
|
};
|
|
144
144
|
export function getIDQueryArgs(templateName) {
|
|
145
|
-
return (
|
|
145
|
+
return (_context, shape) => {
|
|
146
146
|
const schema = shape.model?.type !== 'single' ? mergeSchemaProperties(idSchema, localeProps) : localeProps;
|
|
147
147
|
const shapeName = getFlattenedTemplateShapeName(shape.name, templateName);
|
|
148
148
|
return {
|
|
@@ -161,11 +161,8 @@ function rewriteRefs(context, shapeSchema, rewriteShapeName) {
|
|
|
161
161
|
if ((value['@ref'] || value.$ref) && !parentPath.includes('@input') && !parentPath.includes('@output')) {
|
|
162
162
|
const refItem = getRef(context, value);
|
|
163
163
|
if (refItem) {
|
|
164
|
-
value['@ref'] = refItem.
|
|
165
|
-
? refItemToAtRef(refItem)
|
|
166
|
-
: `local:${rewriteShapeName(refItemToNamespacedShapeName(refItem))}`;
|
|
164
|
+
value['@ref'] = serializeRef(refItem.layerId === 'local' ? { ...refItem, shapeName: rewriteShapeName(refItem.shapeName) } : refItem);
|
|
167
165
|
if (value.$ref) {
|
|
168
|
-
// biome-ignore lint/performance/noDelete: Property presence may matter here
|
|
169
166
|
delete value.$ref;
|
|
170
167
|
}
|
|
171
168
|
}
|
|
@@ -235,7 +232,7 @@ export function getMutationArgs(templateName, verb) {
|
|
|
235
232
|
};
|
|
236
233
|
}
|
|
237
234
|
export function getMutationResultType(verb) {
|
|
238
|
-
return (
|
|
235
|
+
return (_context, shape) => {
|
|
239
236
|
const shapeName = formatShapeName([verb, shape.name, 'result'], {
|
|
240
237
|
shapeNameIndex: 1
|
|
241
238
|
});
|
|
@@ -4,7 +4,7 @@ import isFunction from 'lodash/isFunction.js';
|
|
|
4
4
|
import uniqBy from 'lodash/uniqBy.js';
|
|
5
5
|
import unset from 'lodash/unset.js';
|
|
6
6
|
import { workflowsEnabled } from "../api-version.js";
|
|
7
|
-
import { followRef, getRef, getRefOrItemsRef, hasRefProperty, hasResolvableRef, refItemToNamespacedShapeName, refItemToShape } from "../refs.js";
|
|
7
|
+
import { followRef, getRef, getRefOrItemsRef, hasRefProperty, hasResolvableRef, parseRef, refItemToNamespacedShapeName, refItemToShape } from "../refs.js";
|
|
8
8
|
import { getRelationship, getRelationshipShapes, isEqualRelationship } from "../relationships.js";
|
|
9
9
|
import { createSchemaPropertyList, createShape, getAllRefsInShapes } from "../schema-util.js";
|
|
10
10
|
import { isCachedShape, isObjectSchema, isPropertySchemaWithRelationship } from "../types/utils.js";
|
|
@@ -144,12 +144,10 @@ function truncateNames(names) {
|
|
|
144
144
|
* Get a formatted string of related shape names from a property schema with a
|
|
145
145
|
* relationship resolver
|
|
146
146
|
*/
|
|
147
|
-
function getRelationshipShapeName(refs) {
|
|
147
|
+
function getRelationshipShapeName(context, refs) {
|
|
148
148
|
return refs
|
|
149
|
-
.map((ref) =>
|
|
150
|
-
|
|
151
|
-
return formatShapeName(shapeName);
|
|
152
|
-
})
|
|
149
|
+
.map((ref) => formatShapeName(parseRef(context, ref).shapeName))
|
|
150
|
+
.filter(isDefined)
|
|
153
151
|
.sort()
|
|
154
152
|
.join('');
|
|
155
153
|
}
|
|
@@ -164,7 +162,7 @@ function getTypeName(name, prop, shapeName, context) {
|
|
|
164
162
|
}
|
|
165
163
|
const relationship = getRelationship(prop);
|
|
166
164
|
if (relationship) {
|
|
167
|
-
const relationshipName = getRelationshipShapeName(relationship.refs);
|
|
165
|
+
const relationshipName = getRelationshipShapeName(context.projectSchema, relationship.refs);
|
|
168
166
|
if (!relationshipName) {
|
|
169
167
|
throw new Error(`Relationship property "${prop.title ?? ''}" is missing related shapes`);
|
|
170
168
|
}
|
|
@@ -183,7 +181,7 @@ function getTypeName(name, prop, shapeName, context) {
|
|
|
183
181
|
const prefix = `TS${relationshipDepth >= MAX_RELATIONSHIP_DEPTH ? 'Shallow' : ''}Where`;
|
|
184
182
|
const fieldName = `${conflictingProperties?.has(name) ? '_' : ''}${formatShapeName(name)}`;
|
|
185
183
|
const refItem = getRefOrItemsRef(projectSchema, prop);
|
|
186
|
-
const suffix = refItem ? refItemToNamespacedShapeName(refItem) : `${shapeName}${fieldName}`;
|
|
184
|
+
const suffix = refItem ? refItemToNamespacedShapeName(projectSchema, refItem) : `${shapeName}${fieldName}`;
|
|
187
185
|
return `${prefix}${suffix}`;
|
|
188
186
|
}
|
|
189
187
|
return `TSWhere${pascalCase(type)}`;
|
|
@@ -323,11 +321,11 @@ function getRefSummary(shapes) {
|
|
|
323
321
|
const result = {};
|
|
324
322
|
for (const ref of getAllRefsInShapes({ shapes, services: {} })) {
|
|
325
323
|
const path = ref.path.slice(1, ref.path.length - 1);
|
|
326
|
-
if (result[ref.
|
|
327
|
-
result[ref.
|
|
324
|
+
if (result[ref.shapeName]) {
|
|
325
|
+
result[ref.shapeName].push(path);
|
|
328
326
|
}
|
|
329
327
|
else {
|
|
330
|
-
result[ref.
|
|
328
|
+
result[ref.shapeName] = [path];
|
|
331
329
|
}
|
|
332
330
|
}
|
|
333
331
|
return result;
|