@takeshape/schema 11.51.0 → 11.51.3

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 (63) hide show
  1. package/dist/cjs/src/agents.js +2 -2
  2. package/dist/cjs/src/builtin-schema.js +4 -4
  3. package/dist/cjs/src/content-schema-transform.js +7 -7
  4. package/dist/cjs/src/create-input-schema.js +1 -2
  5. package/dist/cjs/src/enum.js +1 -2
  6. package/dist/cjs/src/flatten-templates.js +1 -2
  7. package/dist/cjs/src/get-is-leaf.js +1 -2
  8. package/dist/cjs/src/interfaces.js +8 -9
  9. package/dist/cjs/src/layers/layers.js +7 -8
  10. package/dist/cjs/src/layers/refs.js +17 -17
  11. package/dist/cjs/src/layers/type-utils.js +22 -23
  12. package/dist/cjs/src/layers/visitor.js +2 -3
  13. package/dist/cjs/src/migration/to/v3.34.0.js +2 -3
  14. package/dist/cjs/src/migration/utils.js +2 -3
  15. package/dist/cjs/src/mocks.js +5 -6
  16. package/dist/cjs/src/project-schema/migrate.js +2 -3
  17. package/dist/cjs/src/refs.js +56 -57
  18. package/dist/cjs/src/relationships.js +10 -11
  19. package/dist/cjs/src/runtime-schema.js +3 -3
  20. package/dist/cjs/src/scalars.js +2 -2
  21. package/dist/cjs/src/schema-transform.js +4 -4
  22. package/dist/cjs/src/schema-util.js +50 -51
  23. package/dist/cjs/src/schemas/project-schema/experimental.json +25 -0
  24. package/dist/cjs/src/service-dependencies.js +2 -3
  25. package/dist/cjs/src/services/services.js +6 -7
  26. package/dist/cjs/src/services/util.js +4 -5
  27. package/dist/cjs/src/taxonomies.js +2 -2
  28. package/dist/cjs/src/template-shapes/index.js +2 -3
  29. package/dist/cjs/src/template-shapes/names.js +3 -4
  30. package/dist/cjs/src/template-shapes/templates.js +7 -7
  31. package/dist/cjs/src/template-shapes/where.js +12 -10
  32. package/dist/cjs/src/types/utils.js +58 -59
  33. package/dist/cjs/src/unions.js +4 -4
  34. package/dist/cjs/src/util/ai-tools.js +2 -3
  35. package/dist/cjs/src/util/api-indexing.js +3 -3
  36. package/dist/cjs/src/util/detect-cycles.js +1 -2
  37. package/dist/cjs/src/util/find-shape-at-path.js +2 -3
  38. package/dist/cjs/src/util/form-config.js +2 -3
  39. package/dist/cjs/src/util/get-conflicting-properties.js +1 -2
  40. package/dist/cjs/src/util/get-return-shape.js +2 -3
  41. package/dist/cjs/src/util/has-arg.js +2 -3
  42. package/dist/cjs/src/util/merge.js +8 -9
  43. package/dist/cjs/src/util/patch-schema.js +1 -2
  44. package/dist/cjs/src/util/shapes.js +4 -5
  45. package/dist/cjs/src/validate.js +9 -9
  46. package/dist/cjs/src/workflows.js +8 -8
  47. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
  48. package/dist/esm/src/schemas/project-schema/experimental.json +25 -0
  49. package/dist/esm/src/template-shapes/where.js +6 -4
  50. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
  51. package/dist/types/src/api-version.d.ts +1 -1
  52. package/dist/types/src/layers/refs.d.ts +0 -1
  53. package/dist/types/src/models/shape.d.ts +6 -6
  54. package/dist/types/src/project-schema/latest.d.ts +17 -0
  55. package/dist/types/src/project-schema/v3.48.0.d.ts +17 -0
  56. package/dist/types/src/project-schema/v3.49.0.d.ts +17 -0
  57. package/dist/types/src/project-schema/v3.50.0.d.ts +17 -0
  58. package/dist/types/src/project-schema/v3.51.0.d.ts +17 -0
  59. package/dist/types/src/refs.d.ts +0 -1
  60. package/dist/types/src/schema-util.d.ts +6 -7
  61. package/dist/types/src/util/ai-tools.d.ts +3 -3
  62. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  63. package/package.json +5 -5
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.addAiQueries = exports.createArgs = exports.removeBuiltInArgs = exports.getInspectAgentSessionQueryName = exports.getAgentEndStates = exports.getAgentEndTransitions = exports.BUILT_IN_CHAT_ARG_NAMES = exports.BUILT_IN_CHAT_ARGS = exports.END_AGENT_EXECUTION = void 0;
6
+ exports.createArgs = exports.removeBuiltInArgs = exports.getInspectAgentSessionQueryName = exports.getAgentEndStates = exports.getAgentEndTransitions = exports.BUILT_IN_CHAT_ARG_NAMES = exports.BUILT_IN_CHAT_ARGS = exports.END_AGENT_EXECUTION = void 0;
7
+ exports.addAiQueries = addAiQueries;
7
8
  const uniq_js_1 = __importDefault(require("lodash/uniq.js"));
8
9
  const uniqBy_js_1 = __importDefault(require("lodash/uniqBy.js"));
9
10
  const upperFirst_js_1 = __importDefault(require("lodash/upperFirst.js"));
@@ -144,4 +145,3 @@ function addAiQueries(projectSchema) {
144
145
  }
145
146
  return newSchema;
146
147
  }
147
- exports.addAiQueries = addAiQueries;
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.builtInForms = exports.builtInShapes = exports.jsonShape = exports.setAssetS3Path = exports.getAssetS3Path = exports.isAsset = void 0;
3
+ exports.builtInForms = exports.builtInShapes = exports.jsonShape = void 0;
4
+ exports.isAsset = isAsset;
5
+ exports.getAssetS3Path = getAssetS3Path;
6
+ exports.setAssetS3Path = setAssetS3Path;
4
7
  function isAsset(content) {
5
8
  return content._contentTypeId === 'ASSET' || content._shapeId === 'ASSET';
6
9
  }
7
- exports.isAsset = isAsset;
8
10
  const ASSET_PATH = 'Hk6FQuz5';
9
11
  function getAssetS3Path(content) {
10
12
  return content[ASSET_PATH];
11
13
  }
12
- exports.getAssetS3Path = getAssetS3Path;
13
14
  function setAssetS3Path(content, path) {
14
15
  content[ASSET_PATH] = path;
15
16
  }
16
- exports.setAssetS3Path = setAssetS3Path;
17
17
  exports.jsonShape = {
18
18
  id: 'JSON',
19
19
  name: 'JSON',
@@ -3,7 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPropertyInfo = exports.getContentTransform = exports.findTransforms = exports.preferSourceKey = exports.preferName = exports.preferKey = exports.getType = void 0;
6
+ exports.preferName = void 0;
7
+ exports.getType = getType;
8
+ exports.preferKey = preferKey;
9
+ exports.preferSourceKey = preferSourceKey;
10
+ exports.findTransforms = findTransforms;
11
+ exports.getContentTransform = getContentTransform;
12
+ exports.getPropertyInfo = getPropertyInfo;
7
13
  const difference_js_1 = __importDefault(require("lodash/difference.js"));
8
14
  const forEach_js_1 = __importDefault(require("lodash/forEach.js"));
9
15
  const get_js_1 = __importDefault(require("lodash/get.js"));
@@ -30,14 +36,12 @@ function getType(schema) {
30
36
  typeCache.set(schema, type);
31
37
  return type;
32
38
  }
33
- exports.getType = getType;
34
39
  function ensureArray(value) {
35
40
  return Array.isArray(value) ? value : [value];
36
41
  }
37
42
  function preferKey(name, schema) {
38
43
  return (0, schema_util_1.getStorageKey)(schema) ?? name;
39
44
  }
40
- exports.preferKey = preferKey;
41
45
  /**
42
46
  * A key transform to select the field name
43
47
  */
@@ -56,7 +60,6 @@ function preferSourceKey(name, schema) {
56
60
  const key = (0, schema_util_1.getStorageKey)(schema);
57
61
  return key ? [key, name] : [name];
58
62
  }
59
- exports.preferSourceKey = preferSourceKey;
60
63
  function findTransforms(pluginMap, schema, name, shape) {
61
64
  const type = getType(schema);
62
65
  if (pluginMap && (pluginMap[type] ?? pluginMap['*'])) {
@@ -65,7 +68,6 @@ function findTransforms(pluginMap, schema, name, shape) {
65
68
  }
66
69
  return undefined;
67
70
  }
68
- exports.findTransforms = findTransforms;
69
71
  function getContentTransform({ transforms, accumulators, keyTransform = preferKey, sourceKeyTransform = preferSourceKey, passThrough = true, allowNullObjects = false, projectSchema }) {
70
72
  const nonDefaultLocales = getNonDefaultLocales(projectSchema);
71
73
  const prepare = (schema, obj, name = '') => {
@@ -131,7 +133,6 @@ function getContentTransform({ transforms, accumulators, keyTransform = preferKe
131
133
  };
132
134
  return prepare;
133
135
  }
134
- exports.getContentTransform = getContentTransform;
135
136
  function transformKey(transforms, propSchema, name, transform = preferKey) {
136
137
  const schemaTransform = findTransforms(transforms, propSchema, name);
137
138
  if (schemaTransform?.keyTransform) {
@@ -172,4 +173,3 @@ function getPropertyInfo(context, schema, path) {
172
173
  findProperty((0, refs_1.dereferenceSchema)(projectSchema, schema), first, rest, []);
173
174
  return result;
174
175
  }
175
- exports.getPropertyInfo = getPropertyInfo;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createInputSchema = void 0;
6
+ exports.createInputSchema = createInputSchema;
7
7
  const util_1 = require("@takeshape/util");
8
8
  const defaults_js_1 = __importDefault(require("lodash/fp/defaults.js"));
9
9
  const inputSchemaCache = new Map();
@@ -64,4 +64,3 @@ function createInputSchema(schema, options = {}) {
64
64
  inputSchemaCache.set(schema, rewrittenSchema);
65
65
  return rewrittenSchema;
66
66
  }
67
- exports.createInputSchema = createInputSchema;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEnumLikeSchema = void 0;
3
+ exports.isEnumLikeSchema = isEnumLikeSchema;
4
4
  function isEnumLikeSchema(schema) {
5
5
  if (schema.enum) {
6
6
  return true;
@@ -10,4 +10,3 @@ function isEnumLikeSchema(schema) {
10
10
  }
11
11
  return false;
12
12
  }
13
- exports.isEnumLikeSchema = isEnumLikeSchema;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.flattenTemplates = void 0;
6
+ exports.flattenTemplates = flattenTemplates;
7
7
  const util_1 = require("@takeshape/util");
8
8
  const set_js_1 = __importDefault(require("lodash/set.js"));
9
9
  const refs_1 = require("./refs");
@@ -24,4 +24,3 @@ function flattenTemplates(projectSchema) {
24
24
  }
25
25
  return newSchema;
26
26
  }
27
- exports.flattenTemplates = flattenTemplates;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIsLeaf = void 0;
3
+ exports.getIsLeaf = getIsLeaf;
4
4
  const content_schema_transform_1 = require("./content-schema-transform");
5
5
  const refs_1 = require("./refs");
6
6
  const schema_util_1 = require("./schema-util");
@@ -57,4 +57,3 @@ function getIsLeaf(projectSchema, shapeSchema) {
57
57
  return Boolean(key && leafMap.has(key));
58
58
  };
59
59
  }
60
- exports.getIsLeaf = getIsLeaf;
@@ -3,7 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPossibleShapeNames = exports.interfaceToUnion = exports.getImplementingShapes = exports.pruneUnusedInterfaces = exports.getImplementationShapeNameMap = exports.getImplementationShapeMap = exports.isInterfaceRef = exports.isInterfaceShape = void 0;
6
+ exports.isInterfaceShape = isInterfaceShape;
7
+ exports.isInterfaceRef = isInterfaceRef;
8
+ exports.getImplementationShapeMap = getImplementationShapeMap;
9
+ exports.getImplementationShapeNameMap = getImplementationShapeNameMap;
10
+ exports.pruneUnusedInterfaces = pruneUnusedInterfaces;
11
+ exports.getImplementingShapes = getImplementingShapes;
12
+ exports.interfaceToUnion = interfaceToUnion;
13
+ exports.getPossibleShapeNames = getPossibleShapeNames;
7
14
  const util_1 = require("@takeshape/util");
8
15
  const mapValues_js_1 = __importDefault(require("lodash/mapValues.js"));
9
16
  const refs_1 = require("./refs");
@@ -11,12 +18,10 @@ const unions_1 = require("./unions");
11
18
  function isInterfaceShape(shape) {
12
19
  return shape?.type === 'interface';
13
20
  }
14
- exports.isInterfaceShape = isInterfaceShape;
15
21
  function isInterfaceRef(context, propertySchema) {
16
22
  const ref = (0, refs_1.getRef)(context, propertySchema);
17
23
  return Boolean(ref && isInterfaceShape((0, refs_1.refItemToShape)(context, ref)));
18
24
  }
19
- exports.isInterfaceRef = isInterfaceRef;
20
25
  function add(record, key, value) {
21
26
  if (!record[key]) {
22
27
  record[key] = new Set([value]);
@@ -37,11 +42,9 @@ function getImplementationsHelper(shapeMap, mapFn) {
37
42
  function getImplementationShapeMap(shapeMap) {
38
43
  return getImplementationsHelper(shapeMap, (x) => x);
39
44
  }
40
- exports.getImplementationShapeMap = getImplementationShapeMap;
41
45
  function getImplementationShapeNameMap(shapeMap) {
42
46
  return getImplementationsHelper(shapeMap, (shape) => shape.name);
43
47
  }
44
- exports.getImplementationShapeNameMap = getImplementationShapeNameMap;
45
48
  function pruneUnusedInterfaces(projectSchema, shapeMap) {
46
49
  return (0, mapValues_js_1.default)(shapeMap, (shape) => {
47
50
  const { interfaces } = shape;
@@ -54,7 +57,6 @@ function pruneUnusedInterfaces(projectSchema, shapeMap) {
54
57
  return shape;
55
58
  });
56
59
  }
57
- exports.pruneUnusedInterfaces = pruneUnusedInterfaces;
58
60
  function compareRefItems(refItem1, refItem2) {
59
61
  return refItem1.typeName === refItem2.typeName && refItem1.serviceKey === refItem2.serviceKey;
60
62
  }
@@ -68,7 +70,6 @@ function getImplementingShapes(context, interfaceRef) {
68
70
  }
69
71
  return implementingShapes;
70
72
  }
71
- exports.getImplementingShapes = getImplementingShapes;
72
73
  function interfaceToUnion(context, interfaceRef) {
73
74
  const shapes = getImplementingShapes(context, interfaceRef);
74
75
  return {
@@ -77,7 +78,6 @@ function interfaceToUnion(context, interfaceRef) {
77
78
  }))
78
79
  };
79
80
  }
80
- exports.interfaceToUnion = interfaceToUnion;
81
81
  function getPossibleShapeNames(projectSchema, shape) {
82
82
  let names;
83
83
  if (isInterfaceShape(shape)) {
@@ -96,4 +96,3 @@ function getPossibleShapeNames(projectSchema, shape) {
96
96
  }
97
97
  return names;
98
98
  }
99
- exports.getPossibleShapeNames = getPossibleShapeNames;
@@ -3,7 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.flattenSchema = exports.collectReferencedShapeNames = exports.getAllRefs = exports.getAllRefsInQueries = exports.getAllRefsInQuery = exports.getAllRefsInShapes = exports.isObjectSchemaV4_0_0 = void 0;
6
+ exports.isObjectSchemaV4_0_0 = isObjectSchemaV4_0_0;
7
+ exports.getAllRefsInShapes = getAllRefsInShapes;
8
+ exports.getAllRefsInQuery = getAllRefsInQuery;
9
+ exports.getAllRefsInQueries = getAllRefsInQueries;
10
+ exports.getAllRefs = getAllRefs;
11
+ exports.collectReferencedShapeNames = collectReferencedShapeNames;
12
+ exports.flattenSchema = flattenSchema;
7
13
  const util_1 = require("@takeshape/util");
8
14
  const set_js_1 = __importDefault(require("lodash/set.js"));
9
15
  const uniq_js_1 = __importDefault(require("lodash/uniq.js"));
@@ -40,7 +46,6 @@ function filterLayer(layerSchema, filters) {
40
46
  function isObjectSchemaV4_0_0(maybeObjectSchema) {
41
47
  return maybeObjectSchema.type === 'object' && (0, util_1.isRecord)(maybeObjectSchema.properties);
42
48
  }
43
- exports.isObjectSchemaV4_0_0 = isObjectSchemaV4_0_0;
44
49
  function mergeShape(a, b) {
45
50
  if (b.override === 'extend') {
46
51
  if (isObjectSchemaV4_0_0(a.schema) && isObjectSchemaV4_0_0(b.schema)) {
@@ -96,7 +101,6 @@ function getAllRefsInShapes(shapes, predicate) {
96
101
  }
97
102
  return items;
98
103
  }
99
- exports.getAllRefsInShapes = getAllRefsInShapes;
100
104
  /**
101
105
  * Get all refs
102
106
  */
@@ -122,7 +126,6 @@ function getAllRefsInQuery(shapes, queryPath, query, predicate) {
122
126
  }
123
127
  return refItems;
124
128
  }
125
- exports.getAllRefsInQuery = getAllRefsInQuery;
126
129
  /**
127
130
  * Collect refs from `queries` or `mutations`.
128
131
  */
@@ -138,7 +141,6 @@ function getAllRefsInQueries(context, rootPropertyName, predicate) {
138
141
  }
139
142
  return refItems;
140
143
  }
141
- exports.getAllRefsInQueries = getAllRefsInQueries;
142
144
  /**
143
145
  * Get all refs in a ProjectSchema
144
146
  * @param predicate return true to include the ref in
@@ -150,7 +152,6 @@ function getAllRefs(projectSchema, predicate) {
150
152
  ...getAllRefsInQueries(projectSchema, 'mutations', predicate)
151
153
  ];
152
154
  }
153
- exports.getAllRefs = getAllRefs;
154
155
  function collectReferencedShapeNames(layerId, refSet) {
155
156
  const addLayerId = (ref) => ({ ...ref, layerId });
156
157
  const collect = (schema) => {
@@ -169,7 +170,6 @@ function collectReferencedShapeNames(layerId, refSet) {
169
170
  };
170
171
  return collect;
171
172
  }
172
- exports.collectReferencedShapeNames = collectReferencedShapeNames;
173
173
  function collectServiceRefs(flattenedSchema, getLayer) {
174
174
  const refs = new Set(getAllRefs(flattenedSchema, (refItem) => refItem.layerId !== 'local').map(refs_2.refItemToString));
175
175
  if (refs.size) {
@@ -311,4 +311,3 @@ function flattenSchema(projectSchema, getLayer) {
311
311
  }
312
312
  return flattenedSchema;
313
313
  }
314
- exports.flattenSchema = flattenSchema;
@@ -3,7 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.parseReturnShape = exports.dereferenceSchema = exports.getArgsReferenceWithPath = exports.hasResolvableRef = exports.hasRef = exports.followRef = exports.omitRefAndExtend = exports.refItemToShape = exports.refItemToString = exports.getRefOrItemsRef = exports.hasRefProperty = exports.getRefWithPath = exports.getRef = exports.atRefToRefItem = exports.splitAtRef = exports.refExpressionToShape = exports.refExpressionToRefItem = void 0;
6
+ exports.omitRefAndExtend = void 0;
7
+ exports.refExpressionToRefItem = refExpressionToRefItem;
8
+ exports.refExpressionToShape = refExpressionToShape;
9
+ exports.splitAtRef = splitAtRef;
10
+ exports.atRefToRefItem = atRefToRefItem;
11
+ exports.getRef = getRef;
12
+ exports.getRefWithPath = getRefWithPath;
13
+ exports.hasRefProperty = hasRefProperty;
14
+ exports.getRefOrItemsRef = getRefOrItemsRef;
15
+ exports.refItemToString = refItemToString;
16
+ exports.refItemToShape = refItemToShape;
17
+ exports.followRef = followRef;
18
+ exports.hasRef = hasRef;
19
+ exports.hasResolvableRef = hasResolvableRef;
20
+ exports.getArgsReferenceWithPath = getArgsReferenceWithPath;
21
+ exports.dereferenceSchema = dereferenceSchema;
22
+ exports.parseReturnShape = parseReturnShape;
7
23
  const util_1 = require("@takeshape/util");
8
24
  const assign_js_1 = __importDefault(require("lodash/fp/assign.js"));
9
25
  const omit_js_1 = __importDefault(require("lodash/fp/omit.js"));
@@ -22,7 +38,6 @@ function refExpressionToRefItem(refExpression) {
22
38
  const { shapeName, template } = (0, refs_1.parseTemplateShape)(refExpression);
23
39
  return atRefToRefItem(shapeName, template);
24
40
  }
25
- exports.refExpressionToRefItem = refExpressionToRefItem;
26
41
  /**
27
42
  * Sugar for converting a `refExpression` directly into a shape, without the
28
43
  * intermediate `refItem`.
@@ -35,7 +50,6 @@ exports.refExpressionToRefItem = refExpressionToRefItem;
35
50
  function refExpressionToShape(shapes, refExpression) {
36
51
  return refItemToShape(shapes, refExpressionToRefItem(refExpression));
37
52
  }
38
- exports.refExpressionToShape = refExpressionToShape;
39
53
  /**
40
54
  * Provided a service name and a referenced type. Supports 2 or 3 part
41
55
  * references, e.g., `shopify:my-store:ProductInput` or `my-store:ProductInput`.
@@ -53,7 +67,6 @@ function splitAtRef(atRef) {
53
67
  }
54
68
  throw new Error(`Invalid ref string ${atRef}`);
55
69
  }
56
- exports.splitAtRef = splitAtRef;
57
70
  /**
58
71
  * Parses and returns a typeName, serviceKey, and potentially a namespace for
59
72
  * the type.
@@ -66,7 +79,6 @@ function atRefToRefItem(atRef, template) {
66
79
  template
67
80
  };
68
81
  }
69
- exports.atRefToRefItem = atRefToRefItem;
70
82
  /**
71
83
  * Given a content schema and project schema, finds a `@ref` or `$ref` and
72
84
  * returns a `RefItem` suitable for loading a referenced schema...
@@ -77,7 +89,6 @@ function getRef(refSchema) {
77
89
  return atRefToRefItem(refSchema['@ref']);
78
90
  }
79
91
  }
80
- exports.getRef = getRef;
81
92
  function getRefWithPath(refSchema, schemaPath = []) {
82
93
  const refItem = getRef(refSchema);
83
94
  if (refItem) {
@@ -87,7 +98,6 @@ function getRefWithPath(refSchema, schemaPath = []) {
87
98
  };
88
99
  }
89
100
  }
90
- exports.getRefWithPath = getRefWithPath;
91
101
  /**
92
102
  * Tests for a `@ref` or `$ref` property directly on the passed schema.
93
103
  *
@@ -96,7 +106,6 @@ exports.getRefWithPath = getRefWithPath;
96
106
  function hasRefProperty(schema) {
97
107
  return Boolean(schema['@ref'] ?? schema.$ref);
98
108
  }
99
- exports.hasRefProperty = hasRefProperty;
100
109
  /**
101
110
  * From a schema with a ref, will return the top-level ref, and potentially
102
111
  * a ref item from a nested `items` property.
@@ -110,21 +119,18 @@ function getRefOrItemsRef(refSchema, schemaPath = []) {
110
119
  return getRefOrItemsRef(refSchema.items, schemaPath.concat(['items']));
111
120
  }
112
121
  }
113
- exports.getRefOrItemsRef = getRefOrItemsRef;
114
122
  /**
115
123
  * Turns a `RefItem` into an `@ref`.
116
124
  */
117
125
  function refItemToString(refItem) {
118
126
  return `${refItem.layerId}:${refItem.typeName}`;
119
127
  }
120
- exports.refItemToString = refItemToString;
121
128
  /**
122
129
  * Get a Shape referenced by a `RefItem`.
123
130
  */
124
131
  function refItemToShape(shapes, refItem) {
125
132
  return shapes[refItemToString(refItem)];
126
133
  }
127
- exports.refItemToShape = refItemToShape;
128
134
  /**
129
135
  * Helper fn to omit `ref` props from the target schema, and then extend it with the source schema.
130
136
  */
@@ -144,7 +150,6 @@ function followRef(shapes, contentSchema) {
144
150
  }
145
151
  return contentSchema;
146
152
  }
147
- exports.followRef = followRef;
148
153
  /**
149
154
  * Returns whether a schema has refs.
150
155
  */
@@ -160,7 +165,6 @@ function hasRef(contentSchema) {
160
165
  }
161
166
  return false;
162
167
  }
163
- exports.hasRef = hasRef;
164
168
  /**
165
169
  * Returns whether a schema has refs which can be followed.
166
170
  */
@@ -176,7 +180,6 @@ function hasResolvableRef(shapes, contentSchema) {
176
180
  }
177
181
  return false;
178
182
  }
179
- exports.hasResolvableRef = hasResolvableRef;
180
183
  function getArgsReferenceWithPath(argsSchema, schemaPath = []) {
181
184
  const isQuery = 'args' in argsSchema;
182
185
  const args = isQuery ? argsSchema.args : argsSchema['@args'];
@@ -188,7 +191,6 @@ function getArgsReferenceWithPath(argsSchema, schemaPath = []) {
188
191
  };
189
192
  }
190
193
  }
191
- exports.getArgsReferenceWithPath = getArgsReferenceWithPath;
192
194
  /*
193
195
  * Helper fn to omit `allOf` props from the target schema, and then extend it with the source schema.
194
196
  */
@@ -221,7 +223,6 @@ function dereferenceSchema(shapes, shapeOrFieldSchema, schemaPath = []) {
221
223
  };
222
224
  return resolveAll(shapeOrFieldSchema, schemaPath) ?? shapeOrFieldSchema;
223
225
  }
224
- exports.dereferenceSchema = dereferenceSchema;
225
226
  function parseReturnShape(shape) {
226
227
  if (typeof shape === 'object') {
227
228
  if ((0, type_utils_1.isRefSchema)(shape.items)) {
@@ -240,4 +241,3 @@ function parseReturnShape(shape) {
240
241
  const shapeName = refItemToString(ref);
241
242
  return { isArray: false, shapeName, ref, template: ref.template };
242
243
  }
243
- exports.parseReturnShape = parseReturnShape;
@@ -3,7 +3,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isObjectSchema = exports.isArraySchema = exports.isOneOfSchema = exports.isAllOfSchema = exports.isRefSchema = exports.isParameterSerializeStyleOptions = exports.isParameterOpOp = exports.isParameterOpValue = exports.isParameterOpMapping = exports.isParameterOpNested = exports.isParameterOp = exports.isParameterSerializeContentOptions = exports.isDirectiveConfig = exports.isDirectiveMappingArray = exports.isDirectiveMappingMap = exports.isUtilResolver = exports.isAwsLambdaResolver = exports.isRestResolver = exports.isGraphqlResolver = exports.isTakeshapeResolver = exports.isComposeResolver = exports.isBasicResolver = void 0;
6
+ exports.isBasicResolver = isBasicResolver;
7
+ exports.isComposeResolver = isComposeResolver;
8
+ exports.isTakeshapeResolver = isTakeshapeResolver;
9
+ exports.isGraphqlResolver = isGraphqlResolver;
10
+ exports.isRestResolver = isRestResolver;
11
+ exports.isAwsLambdaResolver = isAwsLambdaResolver;
12
+ exports.isUtilResolver = isUtilResolver;
13
+ exports.isDirectiveMappingMap = isDirectiveMappingMap;
14
+ exports.isDirectiveMappingArray = isDirectiveMappingArray;
15
+ exports.isDirectiveConfig = isDirectiveConfig;
16
+ exports.isParameterSerializeContentOptions = isParameterSerializeContentOptions;
17
+ exports.isParameterOp = isParameterOp;
18
+ exports.isParameterOpNested = isParameterOpNested;
19
+ exports.isParameterOpMapping = isParameterOpMapping;
20
+ exports.isParameterOpValue = isParameterOpValue;
21
+ exports.isParameterOpOp = isParameterOpOp;
22
+ exports.isParameterSerializeStyleOptions = isParameterSerializeStyleOptions;
23
+ exports.isRefSchema = isRefSchema;
24
+ exports.isAllOfSchema = isAllOfSchema;
25
+ exports.isOneOfSchema = isOneOfSchema;
26
+ exports.isArraySchema = isArraySchema;
27
+ exports.isObjectSchema = isObjectSchema;
7
28
  const util_1 = require("@takeshape/util");
8
29
  const isArray_js_1 = __importDefault(require("lodash/isArray.js"));
9
30
  const isPlainObject_js_1 = __importDefault(require("lodash/isPlainObject.js"));
@@ -16,34 +37,27 @@ const schemas_1 = require("../schemas");
16
37
  function isBasicResolver(resolver) {
17
38
  return (0, isString_js_1.default)(resolver?.name) && (0, isString_js_1.default)(resolver.service);
18
39
  }
19
- exports.isBasicResolver = isBasicResolver;
20
40
  function isComposeResolver(resolver) {
21
41
  return Boolean((0, isArray_js_1.default)(resolver?.compose) &&
22
42
  resolver.compose.length &&
23
43
  resolver.compose.every(isBasicResolver));
24
44
  }
25
- exports.isComposeResolver = isComposeResolver;
26
45
  const { definitions: { takeshapeResolver, utilResolver, graphqlResolver, restResolver, awsLambdaResolver } } = schemas_1.latestSchemaJson;
27
46
  function isTakeshapeResolver(resolver) {
28
47
  return takeshapeResolver.properties.name.enum.includes(resolver.name);
29
48
  }
30
- exports.isTakeshapeResolver = isTakeshapeResolver;
31
49
  function isGraphqlResolver(resolver) {
32
50
  return graphqlResolver.properties.name.enum.includes(resolver.name);
33
51
  }
34
- exports.isGraphqlResolver = isGraphqlResolver;
35
52
  function isRestResolver(resolver) {
36
53
  return restResolver.properties.name.enum.includes(resolver.name);
37
54
  }
38
- exports.isRestResolver = isRestResolver;
39
55
  function isAwsLambdaResolver(resolver) {
40
56
  return awsLambdaResolver.properties.name.enum.includes(resolver.name);
41
57
  }
42
- exports.isAwsLambdaResolver = isAwsLambdaResolver;
43
58
  function isUtilResolver(resolver) {
44
59
  return utilResolver.properties.name.enum.includes(resolver.name);
45
60
  }
46
- exports.isUtilResolver = isUtilResolver;
47
61
  /** Directive Mapping Utils **/
48
62
  /**
49
63
  * Determine whether the ambiguous Directive structure is a DirectiveMappingMap
@@ -51,28 +65,24 @@ exports.isUtilResolver = isUtilResolver;
51
65
  function isDirectiveMappingMap(maybeMap) {
52
66
  return (0, isPlainObject_js_1.default)(maybeMap) && Object.keys(maybeMap).length > 0;
53
67
  }
54
- exports.isDirectiveMappingMap = isDirectiveMappingMap;
55
68
  /**
56
69
  * Determine whether the ambiguous Directive structure is a DirectiveMappingArray
57
70
  */
58
71
  function isDirectiveMappingArray(maybeArray) {
59
72
  return (0, isArray_js_1.default)(maybeArray) && (0, isArray_js_1.default)(maybeArray[0]) && (0, isString_js_1.default)(maybeArray[0][0]) && (0, isArray_js_1.default)(maybeArray[0][1]);
60
73
  }
61
- exports.isDirectiveMappingArray = isDirectiveMappingArray;
62
74
  /**
63
75
  * Determine whether the ambiguous Directive structure is a DirectiveConfig array
64
76
  */
65
77
  function isDirectiveConfig(maybeConfig) {
66
78
  return (0, isArray_js_1.default)(maybeConfig) && (0, isArray_js_1.default)(maybeConfig[0]) && (0, isString_js_1.default)(maybeConfig[0][0]) && (0, util_1.isRecord)(maybeConfig[0][1]);
67
79
  }
68
- exports.isDirectiveConfig = isDirectiveConfig;
69
80
  /**
70
81
  * Determine whether a ParameterSerializeOption is a content type serializer
71
82
  */
72
83
  function isParameterSerializeContentOptions(maybeContent) {
73
84
  return Boolean('contentType' in maybeContent && maybeContent.contentType);
74
85
  }
75
- exports.isParameterSerializeContentOptions = isParameterSerializeContentOptions;
76
86
  /**
77
87
  * Determine whether an unknown variable is a `ParameterOp`
78
88
  */
@@ -83,28 +93,24 @@ function isParameterOp(maybeOp) {
83
93
  }
84
94
  return isParameterOpNested(op) || isParameterOpMapping(op) || isParameterOpValue(op) || isParameterOpOp(op);
85
95
  }
86
- exports.isParameterOp = isParameterOp;
87
96
  /**
88
97
  * Determine whether a `ParameterOp` is a `ParameterOpNested`
89
98
  */
90
99
  function isParameterOpNested(maybeOp) {
91
100
  return Boolean('ops' in maybeOp && maybeOp.ops);
92
101
  }
93
- exports.isParameterOpNested = isParameterOpNested;
94
102
  /**
95
103
  * Determine whether a `ParameterOp` is a `ParameterOpMapping`
96
104
  */
97
105
  function isParameterOpMapping(maybeOp) {
98
106
  return Boolean('mapping' in maybeOp && maybeOp.mapping);
99
107
  }
100
- exports.isParameterOpMapping = isParameterOpMapping;
101
108
  /**
102
109
  * Determine whether a `ParameterOp` is a `ParameterOpMapping`
103
110
  */
104
111
  function isParameterOpValue(maybeOp) {
105
112
  return Boolean('value' in maybeOp && maybeOp.value);
106
113
  }
107
- exports.isParameterOpValue = isParameterOpValue;
108
114
  /**
109
115
  * Determine whether a `ParameterOp` is a `ParameterOpOp`
110
116
  */
@@ -115,32 +121,25 @@ function isParameterOpOp(maybeOp) {
115
121
  }
116
122
  return !(isParameterOpNested(op) || isParameterOpMapping(op) || isParameterOpValue(op));
117
123
  }
118
- exports.isParameterOpOp = isParameterOpOp;
119
124
  /**
120
125
  * Determine whether a ParameterSerializeOption is a style serializer
121
126
  */
122
127
  function isParameterSerializeStyleOptions(maybeStyle) {
123
128
  return Boolean('style' in maybeStyle && maybeStyle.style);
124
129
  }
125
- exports.isParameterSerializeStyleOptions = isParameterSerializeStyleOptions;
126
130
  /** Typeguards for different types of shape schemas **/
127
131
  function isRefSchema(maybeRefSchema) {
128
132
  return (0, isString_js_1.default)(maybeRefSchema['@ref']) || (0, isString_js_1.default)(maybeRefSchema.$ref);
129
133
  }
130
- exports.isRefSchema = isRefSchema;
131
134
  function isAllOfSchema(schema) {
132
135
  return (0, isArray_js_1.default)(schema.allOf);
133
136
  }
134
- exports.isAllOfSchema = isAllOfSchema;
135
137
  function isOneOfSchema(schema) {
136
138
  return (0, isArray_js_1.default)(schema.oneOf);
137
139
  }
138
- exports.isOneOfSchema = isOneOfSchema;
139
140
  function isArraySchema(schema) {
140
141
  return schema.type === 'array' && (0, util_1.isRecord)(schema.items);
141
142
  }
142
- exports.isArraySchema = isArraySchema;
143
143
  function isObjectSchema(schema) {
144
144
  return schema.type === 'object' && (0, util_1.isRecord)(schema.properties);
145
145
  }
146
- exports.isObjectSchema = isObjectSchema;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.visitShapeProperties = exports.visitSchemaProperties = void 0;
3
+ exports.visitSchemaProperties = visitSchemaProperties;
4
+ exports.visitShapeProperties = visitShapeProperties;
4
5
  const type_utils_1 = require("./type-utils");
5
6
  function visitSchemaProperties(schema, path, callback) {
6
7
  if ((0, type_utils_1.isObjectSchema)(schema)) {
@@ -34,10 +35,8 @@ function visitSchemaProperties(schema, path, callback) {
34
35
  callback(schema, path);
35
36
  }
36
37
  }
37
- exports.visitSchemaProperties = visitSchemaProperties;
38
38
  function visitShapeProperties(shapes, callback) {
39
39
  for (const [shapeName, shape] of Object.entries(shapes)) {
40
40
  visitSchemaProperties(shape.schema, ['shapes', shapeName, 'schema'], callback);
41
41
  }
42
42
  }
43
- exports.visitShapeProperties = visitShapeProperties;
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.migrateInterfaceShapes = exports.normalizeForms = void 0;
6
+ exports.normalizeForms = normalizeForms;
7
+ exports.migrateInterfaceShapes = migrateInterfaceShapes;
7
8
  const util_1 = require("@takeshape/util");
8
9
  const set_js_1 = __importDefault(require("lodash/fp/set.js"));
9
10
  const unset_js_1 = __importDefault(require("lodash/fp/unset.js"));
@@ -62,7 +63,6 @@ function normalizeForms(projectSchema) {
62
63
  }
63
64
  return normalizedForms;
64
65
  }
65
- exports.normalizeForms = normalizeForms;
66
66
  function migrateInterfaceShapes(projectSchema) {
67
67
  let updatedProjectSchema = projectSchema;
68
68
  for (const shape of Object.values(projectSchema.shapes)) {
@@ -97,7 +97,6 @@ function migrateInterfaceShapes(projectSchema) {
97
97
  }
98
98
  return updatedProjectSchema;
99
99
  }
100
- exports.migrateInterfaceShapes = migrateInterfaceShapes;
101
100
  const migrate = async (_, projectSchema) => {
102
101
  let normalized = projectSchema;
103
102
  try {
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeSchemaVersion = exports.formatDate = void 0;
3
+ exports.formatDate = formatDate;
4
+ exports.normalizeSchemaVersion = normalizeSchemaVersion;
4
5
  function formatDate(timestamp) {
5
6
  return (timestamp ? new Date(timestamp) : new Date()).toISOString();
6
7
  }
7
- exports.formatDate = formatDate;
8
8
  function normalizeSchemaVersion(version) {
9
9
  return version ?? '1';
10
10
  }
11
- exports.normalizeSchemaVersion = normalizeSchemaVersion;