@takeshape/schema 10.4.9 → 10.6.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.
Files changed (207) hide show
  1. package/dist/api-version.d.ts +1 -1
  2. package/dist/api-version.d.ts.map +1 -1
  3. package/dist/builtin-schema.d.ts +2 -2
  4. package/dist/builtin-schema.d.ts.map +1 -1
  5. package/dist/content-schema-transform.d.ts +10 -10
  6. package/dist/content-schema-transform.d.ts.map +1 -1
  7. package/dist/content-schema-transform.js +1 -1
  8. package/dist/create-input-schema.d.ts +3 -3
  9. package/dist/create-input-schema.d.ts.map +1 -1
  10. package/dist/enum.d.ts +1 -1
  11. package/dist/enum.d.ts.map +1 -1
  12. package/dist/enum.js +1 -1
  13. package/dist/flatten-templates.d.ts +1 -1
  14. package/dist/flatten-templates.d.ts.map +1 -1
  15. package/dist/flatten-templates.js +2 -2
  16. package/dist/get-is-leaf.js +1 -1
  17. package/dist/index.d.ts +2 -3
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +11 -49
  20. package/dist/interfaces.d.ts.map +1 -1
  21. package/dist/interfaces.js +2 -2
  22. package/dist/layers/layers.d.ts +2 -2
  23. package/dist/layers/layers.d.ts.map +1 -1
  24. package/dist/layers/layers.js +23 -27
  25. package/dist/layers/refs.d.ts +7 -7
  26. package/dist/layers/refs.d.ts.map +1 -1
  27. package/dist/layers/refs.js +2 -2
  28. package/dist/layers/type-utils.d.ts +1 -1
  29. package/dist/layers/type-utils.d.ts.map +1 -1
  30. package/dist/layers/visitor.d.ts +2 -2
  31. package/dist/layers/visitor.d.ts.map +1 -1
  32. package/dist/migration/to/v3.0.0.d.ts +1 -1
  33. package/dist/migration/to/v3.0.0.d.ts.map +1 -1
  34. package/dist/migration/to/v3.0.0.js +1 -1
  35. package/dist/migration/to/v3.1.0.d.ts +1 -1
  36. package/dist/migration/to/v3.1.0.d.ts.map +1 -1
  37. package/dist/migration/to/v3.10.0.d.ts.map +1 -1
  38. package/dist/migration/to/v3.11.0.d.ts.map +1 -1
  39. package/dist/migration/to/v3.13.0.d.ts.map +1 -1
  40. package/dist/migration/to/v3.17.0.d.ts +1 -1
  41. package/dist/migration/to/v3.17.0.d.ts.map +1 -1
  42. package/dist/migration/to/v3.17.1.d.ts +1 -1
  43. package/dist/migration/to/v3.17.1.d.ts.map +1 -1
  44. package/dist/migration/to/v3.18.0.d.ts +1 -1
  45. package/dist/migration/to/v3.18.0.d.ts.map +1 -1
  46. package/dist/migration/to/v3.18.1.d.ts.map +1 -1
  47. package/dist/migration/to/v3.18.2.d.ts.map +1 -1
  48. package/dist/migration/to/v3.19.0.d.ts +1 -1
  49. package/dist/migration/to/v3.19.0.d.ts.map +1 -1
  50. package/dist/migration/to/v3.20.0.d.ts.map +1 -1
  51. package/dist/migration/to/v3.21.0.d.ts +1 -1
  52. package/dist/migration/to/v3.21.0.d.ts.map +1 -1
  53. package/dist/migration/to/v3.22.0.d.ts +1 -1
  54. package/dist/migration/to/v3.22.0.d.ts.map +1 -1
  55. package/dist/migration/to/v3.23.0.d.ts +1 -1
  56. package/dist/migration/to/v3.23.0.d.ts.map +1 -1
  57. package/dist/migration/to/v3.24.0.d.ts +1 -1
  58. package/dist/migration/to/v3.24.0.d.ts.map +1 -1
  59. package/dist/migration/to/v3.25.0.d.ts +1 -1
  60. package/dist/migration/to/v3.25.0.d.ts.map +1 -1
  61. package/dist/migration/to/v3.26.0.d.ts +1 -1
  62. package/dist/migration/to/v3.26.0.d.ts.map +1 -1
  63. package/dist/migration/to/v3.27.0.d.ts +1 -1
  64. package/dist/migration/to/v3.27.0.d.ts.map +1 -1
  65. package/dist/migration/to/v3.28.0.d.ts +1 -1
  66. package/dist/migration/to/v3.28.0.d.ts.map +1 -1
  67. package/dist/migration/to/v3.29.0.d.ts +1 -1
  68. package/dist/migration/to/v3.29.0.d.ts.map +1 -1
  69. package/dist/migration/to/v3.30.0.d.ts +1 -1
  70. package/dist/migration/to/v3.30.0.d.ts.map +1 -1
  71. package/dist/migration/to/v3.31.0.d.ts +1 -1
  72. package/dist/migration/to/v3.31.0.d.ts.map +1 -1
  73. package/dist/migration/to/v3.32.0.d.ts +1 -1
  74. package/dist/migration/to/v3.32.0.d.ts.map +1 -1
  75. package/dist/migration/to/v3.32.0.js +10 -12
  76. package/dist/migration/to/v3.33.0.d.ts +1 -1
  77. package/dist/migration/to/v3.33.0.d.ts.map +1 -1
  78. package/dist/migration/to/v3.34.0.d.ts +1 -1
  79. package/dist/migration/to/v3.34.0.d.ts.map +1 -1
  80. package/dist/migration/to/v3.34.0.js +7 -10
  81. package/dist/migration/to/v3.35.0.d.ts +1 -1
  82. package/dist/migration/to/v3.35.0.d.ts.map +1 -1
  83. package/dist/migration/to/v3.36.0.d.ts +1 -1
  84. package/dist/migration/to/v3.36.0.d.ts.map +1 -1
  85. package/dist/migration/to/v3.36.0.js +13 -15
  86. package/dist/migration/to/v3.37.0.d.ts +1 -1
  87. package/dist/migration/to/v3.37.0.d.ts.map +1 -1
  88. package/dist/migration/to/v3.38.0.d.ts +1 -1
  89. package/dist/migration/to/v3.38.0.d.ts.map +1 -1
  90. package/dist/migration/to/v3.39.0.d.ts +1 -1
  91. package/dist/migration/to/v3.39.0.d.ts.map +1 -1
  92. package/dist/migration/to/v3.9.0.d.ts +1 -1
  93. package/dist/migration/to/v3.9.0.d.ts.map +1 -1
  94. package/dist/migration/types.d.ts +4 -4
  95. package/dist/migration/types.d.ts.map +1 -1
  96. package/dist/migration/utils.js +1 -1
  97. package/dist/mocks.d.ts.map +1 -1
  98. package/dist/mocks.js +1 -1
  99. package/dist/models/project-schema.d.ts +4 -4
  100. package/dist/models/project-schema.d.ts.map +1 -1
  101. package/dist/models/project-schema.js +4 -4
  102. package/dist/models/query.d.ts +2 -2
  103. package/dist/models/query.d.ts.map +1 -1
  104. package/dist/models/service.d.ts +2 -2
  105. package/dist/models/service.d.ts.map +1 -1
  106. package/dist/models/shape.d.ts +3 -3
  107. package/dist/models/shape.d.ts.map +1 -1
  108. package/dist/patterns.d.ts +4 -4
  109. package/dist/patterns.d.ts.map +1 -1
  110. package/dist/refs.d.ts +14 -14
  111. package/dist/refs.d.ts.map +1 -1
  112. package/dist/refs.js +4 -4
  113. package/dist/relationships.d.ts.map +1 -1
  114. package/dist/relationships.js +2 -4
  115. package/dist/schema-transform.d.ts +1 -1
  116. package/dist/schema-transform.d.ts.map +1 -1
  117. package/dist/schema-transform.js +1 -1
  118. package/dist/schema-util.d.ts +7 -7
  119. package/dist/schema-util.d.ts.map +1 -1
  120. package/dist/schema-util.js +9 -9
  121. package/dist/services.d.ts +2 -3
  122. package/dist/services.d.ts.map +1 -1
  123. package/dist/services.js +2 -2
  124. package/dist/taxonomies.d.ts +4 -4
  125. package/dist/taxonomies.d.ts.map +1 -1
  126. package/dist/taxonomies.js +1 -1
  127. package/dist/template-shapes/index.d.ts +2 -2
  128. package/dist/template-shapes/index.d.ts.map +1 -1
  129. package/dist/template-shapes/templates.d.ts +1 -1
  130. package/dist/template-shapes/templates.d.ts.map +1 -1
  131. package/dist/template-shapes/templates.js +4 -4
  132. package/dist/template-shapes/types.d.ts +5 -5
  133. package/dist/template-shapes/types.d.ts.map +1 -1
  134. package/dist/template-shapes/where.d.ts +2 -2
  135. package/dist/template-shapes/where.d.ts.map +1 -1
  136. package/dist/template-shapes/where.js +3 -3
  137. package/dist/types/types.d.ts +22 -22
  138. package/dist/types/types.d.ts.map +1 -1
  139. package/dist/types/utils.d.ts +2 -2
  140. package/dist/types/utils.d.ts.map +1 -1
  141. package/dist/types/utils.js +2 -2
  142. package/dist/unions.d.ts +3 -3
  143. package/dist/unions.d.ts.map +1 -1
  144. package/dist/unions.js +2 -2
  145. package/dist/util/api-indexing.d.ts +1 -1
  146. package/dist/util/api-indexing.d.ts.map +1 -1
  147. package/dist/util/api-indexing.js +1 -1
  148. package/dist/util/detect-cycles.d.ts +1 -1
  149. package/dist/util/detect-cycles.d.ts.map +1 -1
  150. package/dist/util/detect-cycles.js +1 -1
  151. package/dist/util/find-shape-at-path.d.ts +1 -1
  152. package/dist/util/find-shape-at-path.d.ts.map +1 -1
  153. package/dist/util/form-config.d.ts +2 -3
  154. package/dist/util/form-config.d.ts.map +1 -1
  155. package/dist/util/form-config.js +4 -8
  156. package/dist/util/get-conflicting-properties.d.ts +2 -2
  157. package/dist/util/get-conflicting-properties.d.ts.map +1 -1
  158. package/dist/util/get-conflicting-properties.js +1 -1
  159. package/dist/util/get-return-shape.d.ts +2 -2
  160. package/dist/util/get-return-shape.d.ts.map +1 -1
  161. package/dist/util/has-arg.d.ts +2 -2
  162. package/dist/util/has-arg.d.ts.map +1 -1
  163. package/dist/util/merge.d.ts +1 -1
  164. package/dist/util/merge.d.ts.map +1 -1
  165. package/dist/util/merge.js +3 -5
  166. package/dist/util/patch-schema.d.ts +2 -2
  167. package/dist/util/patch-schema.d.ts.map +1 -1
  168. package/dist/validate.d.ts +11 -11
  169. package/dist/validate.d.ts.map +1 -1
  170. package/dist/validate.js +12 -13
  171. package/dist/workflows.d.ts +3 -3
  172. package/dist/workflows.d.ts.map +1 -1
  173. package/dist/workflows.js +4 -1
  174. package/es/content-schema-transform.js +1 -1
  175. package/es/enum.js +1 -1
  176. package/es/flatten-templates.js +2 -2
  177. package/es/get-is-leaf.js +1 -1
  178. package/es/index.js +3 -3
  179. package/es/interfaces.js +2 -2
  180. package/es/layers/layers.js +4 -8
  181. package/es/layers/refs.js +2 -2
  182. package/es/migration/to/v3.0.0.js +1 -1
  183. package/es/migration/to/v3.32.0.js +10 -12
  184. package/es/migration/to/v3.34.0.js +7 -10
  185. package/es/migration/to/v3.36.0.js +13 -15
  186. package/es/migration/utils.js +1 -1
  187. package/es/mocks.js +1 -1
  188. package/es/models/project-schema.js +4 -4
  189. package/es/models/shape.js +0 -1
  190. package/es/refs.js +4 -4
  191. package/es/relationships.js +2 -4
  192. package/es/schema-transform.js +1 -1
  193. package/es/schema-util.js +9 -9
  194. package/es/services.js +2 -2
  195. package/es/taxonomies.js +1 -1
  196. package/es/template-shapes/templates.js +4 -4
  197. package/es/template-shapes/where.js +3 -3
  198. package/es/types/utils.js +2 -3
  199. package/es/unions.js +2 -2
  200. package/es/util/api-indexing.js +1 -1
  201. package/es/util/detect-cycles.js +1 -1
  202. package/es/util/form-config.js +4 -8
  203. package/es/util/get-conflicting-properties.js +1 -1
  204. package/es/util/merge.js +3 -5
  205. package/es/validate.js +12 -13
  206. package/es/workflows.js +4 -1
  207. package/package.json +6 -6
@@ -4,21 +4,19 @@ const migrate = async (_, projectSchema) => {
4
4
  ...projectSchema,
5
5
  schemaVersion: '3.36.0'
6
6
  };
7
- if (result.services) {
8
- result.services = mapValues(result.services, config => {
9
- // Add transformVersion to OpenAPI services so we can preserve the legacy behavior
10
- if (config.serviceType === 'openapi') {
11
- return {
12
- ...config,
13
- options: {
14
- ...config.options,
15
- transformVersion: '1.0.0'
16
- }
17
- };
18
- }
19
- return config;
20
- });
21
- }
7
+ result.services &&= mapValues(result.services, config => {
8
+ // Add transformVersion to OpenAPI services so we can preserve the legacy behavior
9
+ if (config.serviceType === 'openapi') {
10
+ return {
11
+ ...config,
12
+ options: {
13
+ ...config.options,
14
+ transformVersion: '1.0.0'
15
+ }
16
+ };
17
+ }
18
+ return config;
19
+ });
22
20
  return result;
23
21
  };
24
22
  export default migrate;
@@ -2,5 +2,5 @@ export function formatDate(timestamp) {
2
2
  return (timestamp ? new Date(timestamp) : new Date()).toISOString();
3
3
  }
4
4
  export function normalizeSchemaVersion(version) {
5
- return version === undefined ? '1' : version;
5
+ return version ?? '1';
6
6
  }
package/es/mocks.js CHANGED
@@ -1,5 +1,5 @@
1
- import { emptySchema, applyDefaultsToSchema } from './schema-util';
2
1
  import { pascalCase } from '@takeshape/util';
2
+ import { emptySchema, applyDefaultsToSchema } from './schema-util';
3
3
 
4
4
  /**
5
5
  * Like emptySchema, but for tests.
@@ -1,6 +1,6 @@
1
+ import omit from 'lodash/omit';
1
2
  import { atRefToRefItem, getRef, normalizeRefExpression, refExpressionToRefItem, shapeToRefItem } from '../refs';
2
3
  import { getAllRefs, getShape, getShapeById } from '../schema-util';
3
- import omit from 'lodash/omit';
4
4
  import { ShapeModel } from './shape';
5
5
  import { QueryModel } from './query';
6
6
  import { ServiceConfig } from './service';
@@ -48,18 +48,18 @@ export class ProjectSchema {
48
48
  return new ShapeModel(this, shapeRef);
49
49
  }
50
50
  get shapes() {
51
- this._cache.shapes = this._cache.shapes ?? Object.keys(this.json.shapes).map(name => new ShapeModel(this, normalizeRefExpression(this.json, name)));
51
+ this._cache.shapes ??= Object.keys(this.json.shapes).map(name => new ShapeModel(this, normalizeRefExpression(this.json, name)));
52
52
  return this._cache.shapes;
53
53
  }
54
54
  get refs() {
55
- this._cache.refs = this._cache.refs ?? getAllRefs(this.json);
55
+ this._cache.refs ??= getAllRefs(this.json);
56
56
  return this._cache.refs;
57
57
  }
58
58
  getQueryByName(queryName) {
59
59
  return new QueryModel(this, 'query', queryName);
60
60
  }
61
61
  get queries() {
62
- this._cache.queries = this._cache.queries ?? Object.keys(this.json.queries).map(name => new QueryModel(this, 'query', name));
62
+ this._cache.queries ??= Object.keys(this.json.queries).map(name => new QueryModel(this, 'query', name));
63
63
  return this._cache.queries;
64
64
  }
65
65
  getMutationByName(mutationName) {
@@ -1,7 +1,6 @@
1
1
  import { refItemToShape } from '../refs';
2
2
  import { createSchemaPropertyAccessor, createSchemaPropertyList, getShapeByRef, isCachedShape, isModelShape } from '../schema-util';
3
3
  import { isInterfaceShape } from '../interfaces';
4
-
5
4
  /**
6
5
  * Create a shape model from either a ref item or a ref string such as `rick:Character`
7
6
  */
package/es/refs.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { isIntegerLike, isDefined, visit, isRecord } from '@takeshape/util';
2
- import { getRefType, isAllOfSchema, isExtendsSchema, isObjectSchema, isOneOfSchema, isRefSchema, isRefSchemaLegacy } from './types';
3
2
  import get from 'lodash/get';
4
3
  import assign from 'lodash/fp/assign';
5
4
  import omit from 'lodash/fp/omit';
6
- import { getServiceNamespaces } from './services';
7
- import { mergeObjectSchemas } from './util/merge';
8
5
  import { resolveSchema } from 'ajv/dist/compile';
9
6
  import isString from 'lodash/isString';
10
- import { isScalar } from './scalars';
11
7
  import { NotFoundError } from '@takeshape/errors';
8
+ import { getServiceNamespaces } from './services';
9
+ import { mergeObjectSchemas } from './util/merge';
10
+ import { isScalar } from './scalars';
11
+ import { getRefType, isAllOfSchema, isExtendsSchema, isObjectSchema, isOneOfSchema, isRefSchema, isRefSchemaLegacy } from './types';
12
12
 
13
13
  /**
14
14
  * This interface describes a parsed `@ref` or `$ref`.
@@ -1,10 +1,10 @@
1
1
  import { isDefined } from '@takeshape/util';
2
+ import find from 'lodash/find';
2
3
  import { isPropertySchemaWithRelationship } from './types';
3
4
  import { getShapeById, isModelShape } from './schema-util';
4
5
  import { getRefShapeName, followRef } from './refs';
5
6
  import { isUnionSchema } from './unions';
6
7
  import { builtInShapes } from './builtin-schema';
7
- import find from 'lodash/find';
8
8
 
9
9
  /**
10
10
  * Turn a LegacyRelationship into a partial PropertySchemaWithRelationship.
@@ -130,9 +130,7 @@ export function getRelationship(propertySchema) {
130
130
  };
131
131
  }
132
132
  function addRelationship(relationships, id, env) {
133
- if (!relationships[id]) {
134
- relationships[id] = [];
135
- }
133
+ relationships[id] ||= [];
136
134
  relationships[id].push(env);
137
135
  }
138
136
  export function findExistingRelationships(projectSchema, shapes) {
@@ -1,6 +1,6 @@
1
1
  import { visit } from '@takeshape/util';
2
- import { isObjectSchema } from './types';
3
2
  import pickBy from 'lodash/pickBy';
3
+ import { isObjectSchema } from './types';
4
4
  function createPropertiesPredicate(propertyNames) {
5
5
  const byShape = new Map();
6
6
  for (const name of propertyNames) {
package/es/schema-util.js CHANGED
@@ -6,6 +6,12 @@ import curry from 'lodash/fp/curry';
6
6
  import orderBy from 'lodash/fp/orderBy';
7
7
  import uniq from 'lodash/uniq';
8
8
  import { deepClone, visit, pascalCase, ensureArray } from '@takeshape/util';
9
+ import isEqual from 'lodash/isEqual';
10
+ import isString from 'lodash/isString';
11
+ import { NotFoundError } from '@takeshape/errors';
12
+ import isArray from 'lodash/isArray';
13
+ import some from 'lodash/some';
14
+ import invariant from 'tiny-invariant';
9
15
  import { defaultWorkflow, getStatusField } from './workflows';
10
16
  import { CURRENT_API_VERSION, CURRENT_SCHEMA_VERSION } from './versions';
11
17
  import { workflowsEnabled } from './api-version';
@@ -13,14 +19,8 @@ import { builtInShapes, builtInForms } from './builtin-schema';
13
19
  import { getArgsType, isObjectSchema, isAllOfSchema, isOneOfSchema, isExtendsSchema, isArraySchema, isServiceResolver, isGraphqlResolver, isRefSchema } from './types/utils';
14
20
  import { getStoredServiceConfig } from './services';
15
21
  import { createTemplateShapeName, dereferenceObjectSchema, dereferenceSchema, getRef, getRefOrItemsRef, getRefShapeName, parseReturnShape, refExpressionToRefItem, refItemToShape, refItemToNamespacedShapeName, refItemToShapeSchema, atRefToRefItem, refToRefItem, parseTemplateShape, returnShapeToSchema, serializePropertyRef } from './refs';
16
- import isEqual from 'lodash/isEqual';
17
- import isString from 'lodash/isString';
18
22
  import { isUnionSchema } from './unions';
19
23
  import { mergeFormProperties, mergeSchemaProperties, getArgs } from './util';
20
- import { NotFoundError } from '@takeshape/errors';
21
- import isArray from 'lodash/isArray';
22
- import some from 'lodash/some';
23
- import invariant from 'tiny-invariant';
24
24
  export const SERVICE_OBJECT_PATTERN_NAME = 'pattern:service-object';
25
25
  export function isBuiltinShape(shapeName) {
26
26
  return Boolean(builtInShapes[shapeName]);
@@ -133,7 +133,7 @@ export function pathBetween(fromShape, toShape, projectSchema, depthLimit = 4) {
133
133
  pathBetweenHelper(referenced.schema, pathSoFar, new Set([...seen, referenced.name]), depth);
134
134
  }
135
135
  }
136
- } else if (pathSoFar.length + 1 < shortestPathLength && (schema.oneOf || schema.allOf || schema.properties)) {
136
+ } else if (pathSoFar.length + 1 < shortestPathLength && (schema.oneOf ?? schema.allOf ?? schema.properties)) {
137
137
  if (schema.oneOf) {
138
138
  for (const itemSchema of schema.oneOf) {
139
139
  pathBetweenHelper(itemSchema, pathSoFar, seen, depth);
@@ -651,7 +651,7 @@ export function getRelevantShapes(projectSchema, params) {
651
651
  byId = false,
652
652
  includeDependencies = true
653
653
  } = params;
654
- if (shapeNames?.length || shapeIds?.length) {
654
+ if (Boolean(shapeNames?.length) || Boolean(shapeIds?.length)) {
655
655
  const ids = new Set(shapeIds);
656
656
  const names = new Set(shapeNames);
657
657
  const shapes = {};
@@ -1143,7 +1143,7 @@ export const schemaMatchesShapeName = (workingCopy, schemaWithRef, shapeName) =>
1143
1143
  export const shapeHasArrayPropOfShape = (projectSchema, shape, shapeName) => {
1144
1144
  if (shape && isObjectSchema(shape.schema)) {
1145
1145
  for (const propName in shape.schema.properties) {
1146
- if (Object.prototype.hasOwnProperty.call(shape.schema.properties, propName)) {
1146
+ if (Object.hasOwn(shape.schema.properties, propName)) {
1147
1147
  const propSchema = shape.schema.properties[propName];
1148
1148
  if (propSchema.items && isRefSchema(propSchema.items) && schemaMatchesShapeName(projectSchema, propSchema.items, shapeName)) {
1149
1149
  return true;
package/es/services.js CHANGED
@@ -2,12 +2,12 @@ import { isDefined, mergeWithArrayMerge } from '@takeshape/util';
2
2
  import { createAjv } from '@takeshape/json-schema';
3
3
  import { SchemaValidationError } from '@takeshape/errors';
4
4
  import isNull from 'lodash/isNull';
5
+ import uniq from 'lodash/uniq';
6
+ import isEmpty from 'lodash/isEmpty';
5
7
  import { isEncryptedServiceConfig, isServiceAuthentication } from './types/utils';
6
8
  import { getServiceInfo, SERVICE_OBJECT_PATTERN_NAME } from './schema-util';
7
9
  import { latestSchemaJson } from './schemas';
8
10
  import { formatError } from './validate';
9
- import uniq from 'lodash/uniq';
10
- import isEmpty from 'lodash/isEmpty';
11
11
 
12
12
  /**
13
13
  * Decrypt an encrypted authentication JSON string
package/es/taxonomies.js CHANGED
@@ -7,7 +7,7 @@ function weakMemoize(fn) {
7
7
  }
8
8
  export function getFirstStringFieldV3(shape, projectSchema) {
9
9
  const forms = projectSchema.forms?.[shape.name];
10
- if (!forms || !forms.default) {
10
+ if (!forms?.default) {
11
11
  return null;
12
12
  }
13
13
  const schemaProperties = createSchemaPropertyAccessor(projectSchema, shape);
@@ -1,13 +1,13 @@
1
- import { TemplateVerbs } from './types';
2
- import { listTypePrefix } from '../migration';
3
1
  import { deepClone, formatShapeName, isDefined, visit } from '@takeshape/util';
4
2
  import keyBy from 'lodash/keyBy';
3
+ import get from 'lodash/get';
4
+ import { listTypePrefix } from '../migration';
5
5
  import { createShape, getShapeDependencies, isCachedShape } from '../schema-util';
6
6
  import { getFlattenedTemplateShapeName, getRef, getRefShapeName, refItemToAtRef, refItemToNamespacedShapeName } from '../refs';
7
- import { getWhereSearchArg } from './where';
8
7
  import { mergeObjectSchemas, mergeSchemaProperties } from '../util';
9
8
  import { createInputSchema } from '../create-input-schema';
10
- import get from 'lodash/get';
9
+ import { getWhereSearchArg } from './where';
10
+ import { TemplateVerbs } from './types';
11
11
  export const TSGetArgs = getIDQueryArgs('TSGetArgs');
12
12
  export const TSGetSingletonArgs = getIDQueryArgs('TSGetSingletonArgs');
13
13
  export const TSListArgs = getShapeListQueryArgs('TSListArgs', true);
@@ -1,9 +1,9 @@
1
1
  import unset from 'lodash/unset';
2
2
  import isFunction from 'lodash/isFunction';
3
- import { createSchemaPropertyList, createShape, getAllRefsInShapes, isCachedShape } from '../schema-util';
4
3
  import uniqBy from 'lodash/uniqBy';
5
4
  import md5 from 'blueimp-md5';
6
5
  import { pascalCase, isDefined, formatShapeName } from '@takeshape/util';
6
+ import { createSchemaPropertyList, createShape, getAllRefsInShapes, isCachedShape } from '../schema-util';
7
7
  import { workflowsEnabled } from '../api-version';
8
8
  import { followRef, getRef, getRefOrItemsRef, hasRefProperty, hasResolvableRef, refItemToShape, refItemToNamespacedShapeName } from '../refs';
9
9
  import { enumerateOneOfKeys, isUnionSchema } from '../unions';
@@ -226,7 +226,7 @@ function skipField({
226
226
  isIndexedShape
227
227
  }) {
228
228
  const isRelationship = isPropertySchemaWithRelationship(prop);
229
- return Boolean(prop['@sensitive'] || prop['@resolver'] && !isIndexedShape && !isRelationship || isRelationship && exceededRelationshipDepth || (name === '_enabled' || name === '_enabledAt') && workflowsEnabled);
229
+ return Boolean(prop['@sensitive'] ?? (Boolean(prop['@resolver'] && !isIndexedShape && !isRelationship) || Boolean(isRelationship && exceededRelationshipDepth) || Boolean((name === '_enabled' || name === '_enabledAt') && workflowsEnabled)));
230
230
  }
231
231
  export function getFields(typeName, shapes, context) {
232
232
  const {
@@ -321,7 +321,7 @@ export function getPropertyComparisonType(name, prop, shapeName, context) {
321
321
  } else if (fieldType === 'object' || fieldType === 'array' && prop.items?.type === 'object') {
322
322
  const properties = prop.items?.properties ?? prop.properties;
323
323
  if (properties) {
324
- props = props ?? {};
324
+ props ??= {};
325
325
  const fieldContext = {
326
326
  ...context,
327
327
  conflictingProperties: undefined // non-union objects have no conflicts
package/es/types/utils.js CHANGED
@@ -1,13 +1,12 @@
1
1
  import { isRecord } from '@takeshape/util';
2
- import { ArgsType, RefType } from './types';
3
2
  import isPlainObject from 'lodash/isPlainObject';
4
3
  import isString from 'lodash/isString';
5
4
  import isArray from 'lodash/isArray';
6
5
  import has from 'lodash/has';
7
- import { latestSchemaJson } from '../schemas';
8
6
  import isUndefined from 'lodash/isUndefined';
7
+ import { latestSchemaJson } from '../schemas';
9
8
  import { isCachedShape } from '../schema-util';
10
-
9
+ import { ArgsType, RefType } from './types';
11
10
  /** Resolver Type Utils **/
12
11
 
13
12
  /**
package/es/unions.js CHANGED
@@ -1,9 +1,9 @@
1
- import { getRef, refItemToNamespacedShapeName } from './refs';
2
1
  import { camelCase, isRecord } from '@takeshape/util';
3
2
  import omit from 'lodash/omit';
3
+ import { BadDataError } from '@takeshape/errors';
4
+ import { getRef, refItemToNamespacedShapeName } from './refs';
4
5
  import { getContentTransform, toName } from './content-schema-transform';
5
6
  import { isRefSchema } from './types/utils';
6
- import { BadDataError } from '@takeshape/errors';
7
7
  import { getShapeById } from './schema-util';
8
8
  import { getOutputShapeName } from './template-shapes/templates';
9
9
  export function enumerateOneOfKeys(projectSchema, oneOf) {
@@ -1,5 +1,5 @@
1
- import { isServiceResolver } from '../types';
2
1
  import { ensureArray } from '@takeshape/util';
2
+ import { isServiceResolver } from '../types';
3
3
  import { getResolverServices } from '../services';
4
4
  import { getIdField, isCachedShape } from '../schema-util';
5
5
  import { getQuery } from '../refs';
@@ -1,5 +1,5 @@
1
- import { getRef, refItemToShape } from '../refs';
2
1
  import { value } from '@takeshape/util';
2
+ import { getRef, refItemToShape } from '../refs';
3
3
  function immutableSetAdd(set, str) {
4
4
  const result = new Set(set);
5
5
  result.add(str);
@@ -14,11 +14,9 @@ export function normalizeForms(projectSchema) {
14
14
  const storeSourceForm = (shapeName, formConfig, propName) => {
15
15
  // Leave original forms intact for backwards compatibility
16
16
  if (!forms[shapeName]) {
17
- if (!normalizedForms[shapeName]) {
18
- normalizedForms[shapeName] = {
19
- default: deepClone(formConfig)
20
- };
21
- }
17
+ normalizedForms[shapeName] ||= {
18
+ default: deepClone(formConfig)
19
+ };
22
20
 
23
21
  // Remove prop now that it has been normalized
24
22
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
@@ -52,9 +50,7 @@ export function normalizeForms(projectSchema) {
52
50
  normalizeNested(shapeName, forms[shapeName].default);
53
51
 
54
52
  // copy forms with no changes
55
- if (!normalizedForms[shapeName]) {
56
- normalizedForms[shapeName] = forms[shapeName];
57
- }
53
+ normalizedForms[shapeName] ||= forms[shapeName];
58
54
  }
59
55
  }
60
56
  return normalizedForms;
@@ -1,5 +1,5 @@
1
- import { dereferenceSchema, getRef, refItemToAtRef } from '../refs';
2
1
  import { isDefined, setIsEqual } from '@takeshape/util';
2
+ import { dereferenceSchema, getRef, refItemToAtRef } from '../refs';
3
3
  import { isObjectSchema } from '../types';
4
4
 
5
5
  /**
package/es/util/merge.js CHANGED
@@ -6,9 +6,9 @@ import unset from 'lodash/unset';
6
6
  import set from 'lodash/set';
7
7
  import last from 'lodash/last';
8
8
  import omit from 'lodash/omit';
9
- import { isExtendsSchema, isObjectSchema } from '../types';
10
9
  import invariant from 'tiny-invariant';
11
10
  import pickBy from 'lodash/pickBy';
11
+ import { isExtendsSchema, isObjectSchema } from '../types';
12
12
  export function mergeObjectSchemas(...args) {
13
13
  return args.filter(isDefined).reduce(mergeSchemaProperties, {
14
14
  type: 'object',
@@ -140,7 +140,7 @@ function compareSection(section, original, updated) {
140
140
  return changes;
141
141
  }
142
142
  function compareSections(parent, branch) {
143
- return mergeableSections.flatMap(section => parent[section] || branch[section] ? compareSection(section, parent[section] ?? {}, branch[section] ?? {}) : []);
143
+ return mergeableSections.flatMap(section => parent[section] ?? branch[section] ? compareSection(section, parent[section] ?? {}, branch[section] ?? {}) : []);
144
144
  }
145
145
  function findChangedShape(schema, change) {
146
146
  return schema.shapes[change.path[1]];
@@ -192,9 +192,7 @@ function attemptToMerge(base, parent, head, change) {
192
192
  mergedObjSchema = rebaseSchemaProperties(toObj, baseObj, fromObj);
193
193
  }
194
194
  }
195
- if (!mergedObjSchema) {
196
- mergedObjSchema = mergeSchemaProperties(toObj, fromObj);
197
- }
195
+ mergedObjSchema ||= mergeSchemaProperties(toObj, fromObj);
198
196
  return {
199
197
  ...rebaseShapeProperties(toShape, fromShape, baseShape),
200
198
  schema: {
package/es/validate.js CHANGED
@@ -1,4 +1,3 @@
1
- import { legacyProjectSchemaImportOptionalProps, projectSchemaImportOptionalProps } from './types/types';
2
1
  import { JSONPath } from 'jsonpath-plus';
3
2
  import { createAjv } from '@takeshape/json-schema';
4
3
  import { SchemaValidationError } from '@takeshape/errors';
@@ -6,6 +5,16 @@ import coerce from 'semver/functions/coerce';
6
5
  import neq from 'semver/functions/neq';
7
6
  import lt from 'semver/functions/lt';
8
7
  import isUndefined from 'lodash/isUndefined';
8
+ import { DEFAULT_MIN_SCHEDULE_TRIGGER_INTERVAL, ensureArray, isIntegerLike, isRecord, value } from '@takeshape/util';
9
+ import uniqBy from 'lodash/uniqBy';
10
+ import initial from 'lodash/initial';
11
+ import last from 'lodash/last';
12
+ import get from 'lodash/get';
13
+ import size from 'lodash/size';
14
+ import isEqual from 'lodash/isEqual';
15
+ import pick from 'lodash/pick';
16
+ import pMap from 'p-map';
17
+ import { flatten } from 'lodash';
9
18
  import { CURRENT_SCHEMA_VERSION, LEGACY_SCHEMA_VERSION, LEGACY_API_VERSION } from './versions';
10
19
  import { defaultWorkflow } from './workflows';
11
20
  import { allProjectSchemas } from './schemas';
@@ -18,17 +27,8 @@ import { refItemToNamespacedShapeName, getRefShapeName, parsePropertyRef, proper
18
27
  import { scalars } from './scalars';
19
28
  import { isUnionSchema } from './unions';
20
29
  import { isEnumLikeSchema } from './enum';
21
- import { DEFAULT_MIN_SCHEDULE_TRIGGER_INTERVAL, ensureArray, isIntegerLike, isRecord, value } from '@takeshape/util';
22
- import uniqBy from 'lodash/uniqBy';
23
- import initial from 'lodash/initial';
24
- import last from 'lodash/last';
25
30
  import { getRelationship } from './relationships';
26
- import get from 'lodash/get';
27
- import size from 'lodash/size';
28
- import isEqual from 'lodash/isEqual';
29
- import pick from 'lodash/pick';
30
- import pMap from 'p-map';
31
- import { flatten } from 'lodash';
31
+ import { legacyProjectSchemaImportOptionalProps, projectSchemaImportOptionalProps } from './types/types';
32
32
  import { isLatestProjectSchemaJSON } from './project-schema';
33
33
  const builtInShapeNames = new Set([...Object.keys(builtInShapes), ...scalars, 'object']);
34
34
  function findDuplicates(items) {
@@ -133,8 +133,6 @@ function enumerateBasicResolvers(resolver, path) {
133
133
  visit(resolver, path);
134
134
  return results;
135
135
  }
136
-
137
- // eslint-disable-next-line complexity
138
136
  function validateResolver(projectSchema, basePath, baseResolver) {
139
137
  const errors = [];
140
138
  const isValidShapeName = shapeName => {
@@ -185,6 +183,7 @@ function validateResolver(projectSchema, basePath, baseResolver) {
185
183
  const parsed = parsePropertyRef(resolver.to);
186
184
  if (parsed) {
187
185
  const error = delegateResolverMissingConfig(parsed, resolver);
186
+ // eslint-disable-next-line max-depth
188
187
  if (error) {
189
188
  errors.push(error);
190
189
  }
package/es/workflows.js CHANGED
@@ -34,7 +34,10 @@ export function findWorkflowStep(workflow, keyOrName) {
34
34
  };
35
35
  }
36
36
  export function getStatusField(workflows, shape) {
37
- const workflow = shape.workflow && workflows[shape.workflow] || defaultWorkflow;
37
+ let workflow = defaultWorkflow;
38
+ if (shape.workflow && workflows[shape.workflow]) {
39
+ workflow = workflows[shape.workflow];
40
+ }
38
41
  return {
39
42
  type: 'string',
40
43
  title: 'Status',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/schema",
3
- "version": "10.4.9",
3
+ "version": "10.6.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": "10.4.9",
32
- "@takeshape/json-schema": "10.4.9",
33
- "@takeshape/util": "10.4.9"
31
+ "@takeshape/errors": "10.6.1",
32
+ "@takeshape/json-schema": "10.6.1",
33
+ "@takeshape/util": "10.6.1"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@takeshape/json-schema-to-typescript": "^11.0.0",
@@ -46,8 +46,8 @@
46
46
  "meow": "^9.0.0",
47
47
  "p-map": "^5.0.0",
48
48
  "shortid": "^2.2.15",
49
- "@takeshape/infra": "10.4.9",
50
- "@takeshape/typescript-jest-junit-reporter": "10.4.9"
49
+ "@takeshape/infra": "10.6.1",
50
+ "@takeshape/typescript-jest-junit-reporter": "10.6.1"
51
51
  },
52
52
  "engines": {
53
53
  "node": ">=18"