@takeshape/schema 9.80.3 → 9.81.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.
Files changed (189) hide show
  1. package/dist/api-version.js +0 -9
  2. package/dist/builtin-schema.js +0 -5
  3. package/dist/content-schema-transform.js +4 -52
  4. package/dist/create-input-schema.js +7 -19
  5. package/dist/enum.js +0 -3
  6. package/dist/flatten-templates.js +0 -11
  7. package/dist/get-is-leaf.js +8 -18
  8. package/dist/index.js +0 -58
  9. package/dist/interfaces.js +2 -26
  10. package/dist/layers/layers.js +23 -103
  11. package/dist/layers/refs.js +26 -69
  12. package/dist/layers/type-utils.js +11 -43
  13. package/dist/layers/visitor.js +0 -6
  14. package/dist/migration/index.js +0 -51
  15. package/dist/migration/to/v3.0.0.js +31 -45
  16. package/dist/migration/to/v3.1.0.js +15 -41
  17. package/dist/migration/to/v3.10.0.js +6 -20
  18. package/dist/migration/to/v3.11.0.js +8 -20
  19. package/dist/migration/to/v3.12.0.js +2 -3
  20. package/dist/migration/to/v3.12.1.js +2 -3
  21. package/dist/migration/to/v3.12.2.js +2 -3
  22. package/dist/migration/to/v3.12.3.js +16 -21
  23. package/dist/migration/to/v3.13.0.js +2 -7
  24. package/dist/migration/to/v3.14.0.js +2 -3
  25. package/dist/migration/to/v3.15.0.js +2 -3
  26. package/dist/migration/to/v3.16.0.js +2 -3
  27. package/dist/migration/to/v3.17.0.js +4 -9
  28. package/dist/migration/to/v3.17.1.js +2 -3
  29. package/dist/migration/to/v3.18.0.js +2 -15
  30. package/dist/migration/to/v3.18.1.js +2 -7
  31. package/dist/migration/to/v3.18.2.js +8 -10
  32. package/dist/migration/to/v3.19.0.js +2 -3
  33. package/dist/migration/to/v3.2.0.js +2 -3
  34. package/dist/migration/to/v3.20.0.js +10 -11
  35. package/dist/migration/to/v3.21.0.js +2 -3
  36. package/dist/migration/to/v3.22.0.js +4 -9
  37. package/dist/migration/to/v3.23.0.js +2 -3
  38. package/dist/migration/to/v3.24.0.js +2 -3
  39. package/dist/migration/to/v3.25.0.js +2 -3
  40. package/dist/migration/to/v3.26.0.js +2 -3
  41. package/dist/migration/to/v3.27.0.js +2 -3
  42. package/dist/migration/to/v3.28.0.js +2 -3
  43. package/dist/migration/to/v3.29.0.js +2 -3
  44. package/dist/migration/to/v3.3.0.js +3 -4
  45. package/dist/migration/to/v3.30.0.js +2 -3
  46. package/dist/migration/to/v3.31.0.js +2 -12
  47. package/dist/migration/to/v3.32.0.js +12 -22
  48. package/dist/migration/to/v3.33.0.js +2 -3
  49. package/dist/migration/to/v3.34.0.js +14 -43
  50. package/dist/migration/to/v3.35.0.js +2 -3
  51. package/dist/migration/to/v3.36.0.js +6 -10
  52. package/dist/migration/to/v3.37.0.js +2 -3
  53. package/dist/migration/to/v3.38.0.js +2 -3
  54. package/dist/migration/to/v3.39.0.js +6 -13
  55. package/dist/migration/to/v3.4.0.js +2 -3
  56. package/dist/migration/to/v3.5.0.js +2 -3
  57. package/dist/migration/to/v3.5.1.js +2 -3
  58. package/dist/migration/to/v3.6.0.js +2 -3
  59. package/dist/migration/to/v3.7.0.js +2 -3
  60. package/dist/migration/to/v3.8.0.js +2 -3
  61. package/dist/migration/to/v3.9.0.js +8 -24
  62. package/dist/migration/utils.js +0 -2
  63. package/dist/mocks.js +9 -12
  64. package/dist/models/project-schema.js +0 -34
  65. package/dist/models/query.js +0 -9
  66. package/dist/models/service.js +0 -8
  67. package/dist/models/shape.js +0 -29
  68. package/dist/project-schema/index.js +1 -105
  69. package/dist/project-schema/migrate.js +1 -54
  70. package/dist/refs.js +39 -159
  71. package/dist/relationships.js +13 -57
  72. package/dist/scalars.js +0 -1
  73. package/dist/schema-transform.js +0 -11
  74. package/dist/schema-util.js +75 -271
  75. package/dist/schemas/index.js +0 -64
  76. package/dist/services.js +24 -44
  77. package/dist/taxonomies.js +0 -13
  78. package/dist/template-shapes/index.js +1 -8
  79. package/dist/template-shapes/templates.js +9 -40
  80. package/dist/template-shapes/types.js +4 -5
  81. package/dist/template-shapes/where.js +14 -110
  82. package/dist/types/index.js +0 -4
  83. package/dist/types/types.js +41 -13
  84. package/dist/types/utils.js +15 -89
  85. package/dist/unions.js +8 -38
  86. package/dist/util/api-indexing.js +2 -19
  87. package/dist/util/detect-cycles.js +2 -16
  88. package/dist/util/find-shape-at-path.js +1 -15
  89. package/dist/util/form-config.js +6 -23
  90. package/dist/util/get-conflicting-properties.js +7 -17
  91. package/dist/util/get-return-shape.js +0 -11
  92. package/dist/util/has-arg.js +0 -6
  93. package/dist/util/index.js +0 -18
  94. package/dist/util/merge.js +28 -74
  95. package/dist/util/patch-schema.js +5 -13
  96. package/dist/validate.js +15 -234
  97. package/dist/versions.js +0 -2
  98. package/dist/workflows.js +0 -15
  99. package/es/api-version.js +0 -4
  100. package/es/content-schema-transform.js +4 -38
  101. package/es/create-input-schema.js +7 -14
  102. package/es/enum.js +0 -2
  103. package/es/flatten-templates.js +0 -4
  104. package/es/get-is-leaf.js +8 -13
  105. package/es/index.js +1 -0
  106. package/es/interfaces.js +2 -14
  107. package/es/layers/layers.js +23 -90
  108. package/es/layers/refs.js +22 -45
  109. package/es/layers/type-utils.js +11 -16
  110. package/es/layers/visitor.js +0 -3
  111. package/es/migration/to/v3.0.0.js +31 -38
  112. package/es/migration/to/v3.1.0.js +16 -34
  113. package/es/migration/to/v3.10.0.js +6 -17
  114. package/es/migration/to/v3.11.0.js +8 -18
  115. package/es/migration/to/v3.12.0.js +2 -2
  116. package/es/migration/to/v3.12.1.js +2 -2
  117. package/es/migration/to/v3.12.2.js +2 -2
  118. package/es/migration/to/v3.12.3.js +16 -19
  119. package/es/migration/to/v3.13.0.js +2 -4
  120. package/es/migration/to/v3.14.0.js +2 -2
  121. package/es/migration/to/v3.15.0.js +2 -2
  122. package/es/migration/to/v3.16.0.js +2 -2
  123. package/es/migration/to/v3.17.0.js +4 -4
  124. package/es/migration/to/v3.17.1.js +2 -2
  125. package/es/migration/to/v3.18.0.js +2 -10
  126. package/es/migration/to/v3.18.1.js +2 -3
  127. package/es/migration/to/v3.18.2.js +8 -8
  128. package/es/migration/to/v3.19.0.js +2 -2
  129. package/es/migration/to/v3.2.0.js +2 -2
  130. package/es/migration/to/v3.20.0.js +10 -9
  131. package/es/migration/to/v3.21.0.js +2 -2
  132. package/es/migration/to/v3.22.0.js +4 -6
  133. package/es/migration/to/v3.23.0.js +2 -2
  134. package/es/migration/to/v3.24.0.js +2 -2
  135. package/es/migration/to/v3.25.0.js +2 -2
  136. package/es/migration/to/v3.26.0.js +2 -2
  137. package/es/migration/to/v3.27.0.js +2 -2
  138. package/es/migration/to/v3.28.0.js +2 -2
  139. package/es/migration/to/v3.29.0.js +2 -2
  140. package/es/migration/to/v3.3.0.js +3 -3
  141. package/es/migration/to/v3.30.0.js +2 -2
  142. package/es/migration/to/v3.31.0.js +2 -5
  143. package/es/migration/to/v3.32.0.js +12 -21
  144. package/es/migration/to/v3.33.0.js +2 -2
  145. package/es/migration/to/v3.34.0.js +16 -32
  146. package/es/migration/to/v3.35.0.js +2 -2
  147. package/es/migration/to/v3.36.0.js +6 -8
  148. package/es/migration/to/v3.37.0.js +2 -2
  149. package/es/migration/to/v3.38.0.js +2 -2
  150. package/es/migration/to/v3.39.0.js +6 -12
  151. package/es/migration/to/v3.4.0.js +2 -2
  152. package/es/migration/to/v3.5.0.js +2 -2
  153. package/es/migration/to/v3.5.1.js +2 -2
  154. package/es/migration/to/v3.6.0.js +2 -2
  155. package/es/migration/to/v3.7.0.js +2 -2
  156. package/es/migration/to/v3.8.0.js +2 -2
  157. package/es/migration/to/v3.9.0.js +8 -20
  158. package/es/mocks.js +10 -6
  159. package/es/models/project-schema.js +0 -26
  160. package/es/models/query.js +0 -7
  161. package/es/models/service.js +0 -6
  162. package/es/models/shape.js +1 -25
  163. package/es/project-schema/index.js +0 -5
  164. package/es/project-schema/migrate.js +3 -51
  165. package/es/refs.js +40 -96
  166. package/es/relationships.js +14 -42
  167. package/es/schema-transform.js +0 -7
  168. package/es/schema-util.js +75 -180
  169. package/es/services.js +18 -27
  170. package/es/taxonomies.js +0 -9
  171. package/es/template-shapes/index.js +1 -4
  172. package/es/template-shapes/templates.js +9 -18
  173. package/es/template-shapes/types.js +3 -4
  174. package/es/template-shapes/where.js +14 -94
  175. package/es/types/types.js +43 -10
  176. package/es/types/utils.js +16 -24
  177. package/es/unions.js +8 -22
  178. package/es/util/api-indexing.js +2 -12
  179. package/es/util/detect-cycles.js +2 -14
  180. package/es/util/find-shape-at-path.js +2 -12
  181. package/es/util/form-config.js +7 -19
  182. package/es/util/get-conflicting-properties.js +8 -14
  183. package/es/util/get-return-shape.js +0 -8
  184. package/es/util/has-arg.js +0 -3
  185. package/es/util/merge.js +28 -55
  186. package/es/util/patch-schema.js +5 -7
  187. package/es/validate.js +15 -194
  188. package/es/workflows.js +0 -6
  189. package/package.json +5 -5
@@ -16,133 +16,69 @@ Object.defineProperty(exports, "latestSchemaJson", {
16
16
  return _v.default;
17
17
  }
18
18
  });
19
-
20
19
  var _projectSchema = _interopRequireDefault(require("./project-schema.json"));
21
-
22
20
  var _v = _interopRequireDefault(require("./project-schema/v3.39.0.json"));
23
-
24
21
  var _metaSchemaV = _interopRequireDefault(require("./project-schema/meta-schema-v1.0.0.json"));
25
-
26
22
  var _v2 = _interopRequireDefault(require("./project-schema/v1.0.0.json"));
27
-
28
23
  var _metaSchemaV2 = _interopRequireDefault(require("./project-schema/meta-schema-v3.0.0.json"));
29
-
30
24
  var _v3 = _interopRequireDefault(require("./project-schema/v3.0.0.json"));
31
-
32
25
  var _metaSchemaV3 = _interopRequireDefault(require("./project-schema/meta-schema-v3.1.0.json"));
33
-
34
26
  var _v4 = _interopRequireDefault(require("./project-schema/v3.1.0.json"));
35
-
36
27
  var _metaSchemaV4 = _interopRequireDefault(require("./project-schema/meta-schema-v3.2.0.json"));
37
-
38
28
  var _v5 = _interopRequireDefault(require("./project-schema/v3.2.0.json"));
39
-
40
29
  var _metaSchemaV5 = _interopRequireDefault(require("./project-schema/meta-schema-v3.3.0.json"));
41
-
42
30
  var _v6 = _interopRequireDefault(require("./project-schema/v3.3.0.json"));
43
-
44
31
  var _metaSchemaV6 = _interopRequireDefault(require("./project-schema/meta-schema-v3.4.0.json"));
45
-
46
32
  var _v7 = _interopRequireDefault(require("./project-schema/v3.4.0.json"));
47
-
48
33
  var _metaSchemaV7 = _interopRequireDefault(require("./project-schema/meta-schema-v3.5.0.json"));
49
-
50
34
  var _v8 = _interopRequireDefault(require("./project-schema/v3.5.0.json"));
51
-
52
35
  var _metaSchemaV8 = _interopRequireDefault(require("./project-schema/meta-schema-v3.5.1.json"));
53
-
54
36
  var _v9 = _interopRequireDefault(require("./project-schema/v3.5.1.json"));
55
-
56
37
  var _metaSchemaV9 = _interopRequireDefault(require("./project-schema/meta-schema-v3.6.0.json"));
57
-
58
38
  var _v10 = _interopRequireDefault(require("./project-schema/v3.6.0.json"));
59
-
60
39
  var _metaSchemaV10 = _interopRequireDefault(require("./project-schema/meta-schema-v3.7.0.json"));
61
-
62
40
  var _v11 = _interopRequireDefault(require("./project-schema/v3.7.0.json"));
63
-
64
41
  var _metaSchemaV11 = _interopRequireDefault(require("./project-schema/meta-schema-v3.8.0.json"));
65
-
66
42
  var _v12 = _interopRequireDefault(require("./project-schema/v3.8.0.json"));
67
-
68
43
  var _metaSchemaV12 = _interopRequireDefault(require("./project-schema/meta-schema-v3.9.0.json"));
69
-
70
44
  var _v13 = _interopRequireDefault(require("./project-schema/v3.9.0.json"));
71
-
72
45
  var _v14 = _interopRequireDefault(require("./project-schema/v3.10.0.json"));
73
-
74
46
  var _v15 = _interopRequireDefault(require("./project-schema/v3.11.0.json"));
75
-
76
47
  var _v16 = _interopRequireDefault(require("./project-schema/v3.12.0.json"));
77
-
78
48
  var _v17 = _interopRequireDefault(require("./project-schema/v3.12.1.json"));
79
-
80
49
  var _v18 = _interopRequireDefault(require("./project-schema/v3.12.2.json"));
81
-
82
50
  var _v19 = _interopRequireDefault(require("./project-schema/v3.12.3.json"));
83
-
84
51
  var _v20 = _interopRequireDefault(require("./project-schema/v3.13.0.json"));
85
-
86
52
  var _v21 = _interopRequireDefault(require("./project-schema/v3.14.0.json"));
87
-
88
53
  var _v22 = _interopRequireDefault(require("./project-schema/v3.15.0.json"));
89
-
90
54
  var _v23 = _interopRequireDefault(require("./project-schema/v3.16.0.json"));
91
-
92
55
  var _v24 = _interopRequireDefault(require("./project-schema/v3.17.0.json"));
93
-
94
56
  var _v25 = _interopRequireDefault(require("./project-schema/v3.17.1.json"));
95
-
96
57
  var _v26 = _interopRequireDefault(require("./project-schema/v3.18.0.json"));
97
-
98
58
  var _v27 = _interopRequireDefault(require("./project-schema/v3.18.1.json"));
99
-
100
59
  var _v28 = _interopRequireDefault(require("./project-schema/v3.18.2.json"));
101
-
102
60
  var _v29 = _interopRequireDefault(require("./project-schema/v3.19.0.json"));
103
-
104
61
  var _v30 = _interopRequireDefault(require("./project-schema/v3.20.0.json"));
105
-
106
62
  var _v31 = _interopRequireDefault(require("./project-schema/v3.21.0.json"));
107
-
108
63
  var _v32 = _interopRequireDefault(require("./project-schema/v3.22.0.json"));
109
-
110
64
  var _v33 = _interopRequireDefault(require("./project-schema/v3.23.0.json"));
111
-
112
65
  var _v34 = _interopRequireDefault(require("./project-schema/v3.24.0.json"));
113
-
114
66
  var _v35 = _interopRequireDefault(require("./project-schema/v3.25.0.json"));
115
-
116
67
  var _v36 = _interopRequireDefault(require("./project-schema/v3.26.0.json"));
117
-
118
68
  var _v37 = _interopRequireDefault(require("./project-schema/v3.27.0.json"));
119
-
120
69
  var _v38 = _interopRequireDefault(require("./project-schema/v3.28.0.json"));
121
-
122
70
  var _v39 = _interopRequireDefault(require("./project-schema/v3.29.0.json"));
123
-
124
71
  var _v40 = _interopRequireDefault(require("./project-schema/v3.30.0.json"));
125
-
126
72
  var _v41 = _interopRequireDefault(require("./project-schema/v3.31.0.json"));
127
-
128
73
  var _v42 = _interopRequireDefault(require("./project-schema/v3.32.0.json"));
129
-
130
74
  var _v43 = _interopRequireDefault(require("./project-schema/v3.33.0.json"));
131
-
132
75
  var _v44 = _interopRequireDefault(require("./project-schema/v3.34.0.json"));
133
-
134
76
  var _v45 = _interopRequireDefault(require("./project-schema/v3.35.0.json"));
135
-
136
77
  var _v46 = _interopRequireDefault(require("./project-schema/v3.36.0.json"));
137
-
138
78
  var _v47 = _interopRequireDefault(require("./project-schema/v3.37.0.json"));
139
-
140
79
  var _v48 = _interopRequireDefault(require("./project-schema/v3.38.0.json"));
141
-
142
80
  var _v49 = _interopRequireDefault(require("./project-schema/v4.0.0.json"));
143
-
144
81
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
145
-
146
82
  // This file is generated by "pnpm json2ts"
147
83
  const CURRENT_SCHEMA_VERSION = '3.39.0';
148
84
  exports.CURRENT_SCHEMA_VERSION = CURRENT_SCHEMA_VERSION;
package/dist/services.js CHANGED
@@ -12,28 +12,30 @@ exports.getStoredServiceConfig = getStoredServiceConfig;
12
12
  exports.isMissingAuth = isMissingAuth;
13
13
  exports.prepareServiceUpdate = prepareServiceUpdate;
14
14
  exports.validateServiceConfig = validateServiceConfig;
15
-
16
15
  var _util = require("@takeshape/util");
17
-
18
16
  var _jsonSchema = require("@takeshape/json-schema");
19
-
20
17
  var _errors = require("@takeshape/errors");
21
-
22
18
  var _isNull = _interopRequireDefault(require("lodash/isNull"));
23
-
24
19
  var _utils = require("./types/utils");
25
-
26
20
  var _schemaUtil = require("./schema-util");
27
-
28
21
  var _schemas = require("./schemas");
29
-
30
22
  var _validate = require("./validate");
31
-
32
23
  var _uniq = _interopRequireDefault(require("lodash/uniq"));
33
-
34
24
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
35
-
36
25
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
+ /**
27
+ * Decrypt an encrypted authentication JSON string
28
+ * Throws an error if decryption fails
29
+ */
30
+ // eslint-disable-next-line @typescript-eslint/ban-types
31
+
32
+ /**
33
+ * Decrypt an encrypted authentication JSON string
34
+ * Returns undefined if decryption fails
35
+ */
36
+ // eslint-disable-next-line @typescript-eslint/ban-types
37
+
38
+ // eslint-disable-next-line @typescript-eslint/ban-types
37
39
 
38
40
  /**
39
41
  * Given a `StoredServiceConfig` returns a usable `ServiceConfig` with the
@@ -41,31 +43,27 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
41
43
  */
42
44
  function decryptServiceConfig(decryptFn, storedServiceConfig) {
43
45
  let authentication;
44
-
45
46
  if ((0, _utils.isEncryptedServiceConfig)(storedServiceConfig)) {
46
47
  const decrypted = decryptFn(storedServiceConfig.authentication);
47
-
48
48
  if ((0, _utils.isServiceAuthentication)(decrypted)) {
49
49
  authentication = decrypted;
50
50
  }
51
51
  }
52
-
53
- return { ...storedServiceConfig,
52
+ return {
53
+ ...storedServiceConfig,
54
54
  authentication
55
55
  };
56
56
  }
57
+
57
58
  /**
58
59
  * Given a `ServiceMapJSON` returns a usable `ServiceMap` with all the
59
60
  * authentication objects decrypted.
60
61
  */
61
-
62
-
63
62
  async function decryptServiceMap(decryptFn, ServiceMapJSON) {
64
63
  return Object.entries(ServiceMapJSON).reduce((result, [serviceKey, serviceConfig]) => {
65
64
  return result.set(serviceKey, decryptServiceConfig(decryptFn, serviceConfig));
66
65
  }, new Map());
67
66
  }
68
-
69
67
  function createServiceConfigValidator() {
70
68
  const validator = (0, _jsonSchema.createAjv)();
71
69
  const {
@@ -78,75 +76,66 @@ function createServiceConfigValidator() {
78
76
  ...serviceConfig
79
77
  });
80
78
  }
81
-
82
79
  const serviceConfigValidator = createServiceConfigValidator();
80
+
83
81
  /**
84
82
  * Validates a `ServiceConfig` validator based on the JSON-schema.
85
83
  */
86
-
87
84
  function validateServiceConfig(maybeServiceConfig) {
88
85
  var _serviceConfigValidat;
89
-
90
86
  if (serviceConfigValidator(maybeServiceConfig)) {
91
87
  return maybeServiceConfig;
92
88
  }
93
-
94
89
  throw new _errors.SchemaValidationError('ServiceConfig was invalid', (_serviceConfigValidat = serviceConfigValidator.errors) === null || _serviceConfigValidat === void 0 ? void 0 : _serviceConfigValidat.map(_validate.formatError));
95
90
  }
91
+
96
92
  /**
97
93
  * Prepare a `ServiceConfig` object update, validating the overall structure
98
94
  * and encrypting the `ServiceAuthentication` object.
99
95
  */
100
96
  // eslint-disable-next-line max-params
101
-
102
-
103
97
  function prepareServiceUpdate(encryptFn, decryptFn, projectSchema, serviceConfigUpdate, serviceKey) {
104
98
  const storedServiceConfig = getStoredServiceConfig(projectSchema, serviceKey);
105
99
  let newServiceConfig = serviceConfigUpdate;
106
-
107
100
  if (storedServiceConfig) {
108
101
  const existingServiceConfig = decryptServiceConfig(decryptFn, storedServiceConfig);
109
102
  newServiceConfig = (0, _util.mergeWithArrayMerge)(existingServiceConfig, serviceConfigUpdate);
110
103
  }
111
-
112
104
  const {
113
105
  authentication,
114
106
  authenticationType
115
107
  } = newServiceConfig;
116
-
117
108
  if (authenticationType === 'none' || (0, _isNull.default)(authentication)) {
118
109
  delete newServiceConfig.authentication;
119
110
  } else if (authentication !== undefined) {
120
111
  // Add the discriminator to the authentication object, set authenticationType
121
112
  // to ensure the update is correct for the auth type.
122
- newServiceConfig.authentication = { ...authentication,
113
+ newServiceConfig.authentication = {
114
+ ...authentication,
123
115
  type: authenticationType
124
116
  };
125
117
  }
126
-
127
118
  validateServiceConfig(newServiceConfig);
128
119
  let serviceConfig;
129
-
130
120
  if (newServiceConfig.authentication) {
131
- serviceConfig = { ...newServiceConfig,
121
+ serviceConfig = {
122
+ ...newServiceConfig,
132
123
  authentication: encryptFn(newServiceConfig.authentication)
133
124
  };
134
125
  } else {
135
126
  serviceConfig = newServiceConfig;
136
127
  }
137
-
138
128
  return serviceConfig;
139
129
  }
130
+
140
131
  /**
141
132
  * Get a service config from a project schema.
142
133
  */
143
-
144
-
145
134
  function getStoredServiceConfig(projectSchema, serviceKey) {
146
135
  var _projectSchema$servic;
147
-
148
136
  return (_projectSchema$servic = projectSchema.services) === null || _projectSchema$servic === void 0 ? void 0 : _projectSchema$servic[serviceKey];
149
137
  }
138
+
150
139
  /**
151
140
  * Get a `Map` keyed with all the service namespaces.
152
141
  *
@@ -154,38 +143,29 @@ function getStoredServiceConfig(projectSchema, serviceKey) {
154
143
  *
155
144
  * @returns A `Map` with namespaces as keys, and service keys as values.
156
145
  */
157
-
158
-
159
146
  function getServiceNamespaces(context) {
160
147
  const namespaces = new Map();
161
148
  const {
162
149
  services
163
150
  } = context;
164
-
165
151
  if (services) {
166
152
  Object.keys(services).forEach(serviceKey => {
167
153
  var _services$serviceKey;
168
-
169
154
  const namespace = (_services$serviceKey = services[serviceKey]) === null || _services$serviceKey === void 0 ? void 0 : _services$serviceKey.namespace;
170
-
171
155
  if (namespace) {
172
156
  namespaces.set(namespace, serviceKey);
173
157
  }
174
158
  });
175
159
  }
176
-
177
160
  return namespaces;
178
161
  }
179
-
180
162
  function getServiceObjectFields(projectSchema, shape, provider) {
181
163
  return ((0, _schemaUtil.getServiceInfo)(projectSchema, shape)[provider] ?? []).filter(serviceInfo => serviceInfo.generators[_schemaUtil.SERVICE_OBJECT_PATTERN_NAME]);
182
164
  }
183
-
184
165
  function getResolverServices(resolver) {
185
166
  const resolverArray = 'compose' in resolver ? resolver.compose : [resolver];
186
167
  return (0, _uniq.default)(resolverArray.map(resolver => 'service' in resolver ? resolver.service : undefined).filter(_util.isDefined));
187
168
  }
188
-
189
169
  function isMissingAuth(service) {
190
170
  return service.authenticationType !== 'none' && (0, _isEmpty.default)(service.authentication);
191
171
  }
@@ -5,35 +5,26 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getFirstStringFieldV3 = getFirstStringFieldV3;
7
7
  exports.getTaxonomyField = exports.getTaxonomies = void 0;
8
-
9
8
  var _memoize = _interopRequireDefault(require("lodash/memoize"));
10
-
11
9
  var _schemaUtil = require("./schema-util");
12
-
13
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
11
  function weakMemoize(fn) {
16
12
  const memoized = (0, _memoize.default)(fn);
17
13
  memoized.cache = new WeakMap();
18
14
  return memoized;
19
15
  }
20
-
21
16
  function getFirstStringFieldV3(shape, projectSchema) {
22
17
  var _projectSchema$forms;
23
-
24
18
  const forms = (_projectSchema$forms = projectSchema.forms) === null || _projectSchema$forms === void 0 ? void 0 : _projectSchema$forms[shape.name];
25
-
26
19
  if (!forms || !forms.default) {
27
20
  return null;
28
21
  }
29
-
30
22
  const schemaProperties = (0, _schemaUtil.createSchemaPropertyAccessor)(projectSchema, shape);
31
23
  const {
32
24
  order
33
25
  } = forms.default;
34
26
  const name = order.find(name => {
35
27
  var _schemaProperties$get;
36
-
37
28
  return ((_schemaProperties$get = schemaProperties.getValue(name)) === null || _schemaProperties$get === void 0 ? void 0 : _schemaProperties$get.type) === 'string';
38
29
  });
39
30
  return name ? {
@@ -41,10 +32,8 @@ function getFirstStringFieldV3(shape, projectSchema) {
41
32
  key: schemaProperties.getKey(name)
42
33
  } : null;
43
34
  }
44
-
45
35
  const getTaxonomyField = weakMemoize((shape, projectSchema) => {
46
36
  var _shape$model;
47
-
48
37
  return ((_shape$model = shape.model) === null || _shape$model === void 0 ? void 0 : _shape$model.type) === 'taxonomy' ? getFirstStringFieldV3(shape, projectSchema) : null;
49
38
  });
50
39
  exports.getTaxonomyField = getTaxonomyField;
@@ -55,14 +44,12 @@ const getTaxonomies = weakMemoize(projectSchema => {
55
44
  return Object.keys(shapes).reduce((result, shapeName) => {
56
45
  const shape = shapes[shapeName];
57
46
  const field = getTaxonomyField(shape, projectSchema);
58
-
59
47
  if (field) {
60
48
  result.push({
61
49
  shapeId: shape.id,
62
50
  field
63
51
  });
64
52
  }
65
-
66
53
  return result;
67
54
  }, []);
68
55
  });
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isValidTemplate = isValidTemplate;
7
7
  exports.resolveTemplate = resolveTemplate;
8
-
9
8
  var _templates = require("./templates");
10
-
11
9
  const templateMappings = {
12
10
  TSGetArgs: _templates.TSGetArgs,
13
11
  TSGetSingletonArgs: _templates.TSGetSingletonArgs,
@@ -24,27 +22,22 @@ const templateMappings = {
24
22
  DuplicateResult: _templates.DuplicateResult,
25
23
  DeleteResult: _templates.DeleteResult
26
24
  };
27
-
28
25
  function resolveTemplate(projectSchema, templateName, shapeName) {
29
26
  const mapping = templateMappings[templateName];
30
-
31
27
  if (!mapping) {
32
28
  throw new Error(`Invalid shape template ${templateName}`);
33
29
  }
34
-
35
30
  if (projectSchema.shapes[shapeName] === undefined) {
36
31
  throw new Error(`Unknown shape "${shapeName}" in template "${templateName}"`);
37
32
  }
38
-
39
33
  return mapping({
40
34
  projectSchema
41
35
  }, projectSchema.shapes[shapeName]);
42
36
  }
37
+
43
38
  /**
44
39
  * Check if a string is a known template such as `PaginatedList`
45
40
  */
46
-
47
-
48
41
  function isValidTemplate(template) {
49
42
  return Boolean(templateMappings[template]);
50
43
  }
@@ -14,29 +14,17 @@ exports.getPaginatedListShape = getPaginatedListShape;
14
14
  exports.getSearchResultsShape = getSearchResultsShape;
15
15
  exports.getShapeListQueryArgs = getShapeListQueryArgs;
16
16
  exports.termsProps = exports.localeProps = void 0;
17
-
18
17
  var _types = require("./types");
19
-
20
18
  var _migration = require("../migration");
21
-
22
19
  var _util = require("@takeshape/util");
23
-
24
20
  var _keyBy = _interopRequireDefault(require("lodash/keyBy"));
25
-
26
21
  var _schemaUtil = require("../schema-util");
27
-
28
22
  var _refs = require("../refs");
29
-
30
23
  var _where = require("./where");
31
-
32
24
  var _util2 = require("../util");
33
-
34
25
  var _createInputSchema = require("../create-input-schema");
35
-
36
26
  var _get = _interopRequireDefault(require("lodash/get"));
37
-
38
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
-
40
28
  const TSGetArgs = getIDQueryArgs('TSGetArgs');
41
29
  exports.TSGetArgs = TSGetArgs;
42
30
  const TSGetSingletonArgs = getIDQueryArgs('TSGetSingletonArgs');
@@ -146,7 +134,6 @@ const TSContentStructureInput = (0, _schemaUtil.createShape)('TSContentStructure
146
134
  description: 'Describes a structural update to an array of data.'
147
135
  });
148
136
  exports.TSContentStructureInput = TSContentStructureInput;
149
-
150
137
  function getPaginatedListShape(context, shape) {
151
138
  const shapeName = `${shape.name}${_migration.listTypePrefix}`;
152
139
  return {
@@ -170,7 +157,6 @@ function getPaginatedListShape(context, shape) {
170
157
  }
171
158
  };
172
159
  }
173
-
174
160
  function getSearchResultsShape(context, shape) {
175
161
  const shapeName = `${shape.name}SearchResults`;
176
162
  return {
@@ -196,7 +182,6 @@ function getSearchResultsShape(context, shape) {
196
182
  }
197
183
  };
198
184
  }
199
-
200
185
  const contentStructureFields = {
201
186
  type: 'object',
202
187
  properties: {
@@ -217,11 +202,9 @@ const idSchema = {
217
202
  },
218
203
  required: ['_id']
219
204
  };
220
-
221
205
  function getIDQueryArgs(templateName) {
222
206
  return (context, shape) => {
223
207
  var _shape$model;
224
-
225
208
  const schema = ((_shape$model = shape.model) === null || _shape$model === void 0 ? void 0 : _shape$model.type) !== 'single' ? (0, _util2.mergeSchemaProperties)(idSchema, localeProps) : localeProps;
226
209
  const shapeName = (0, _refs.getFlattenedTemplateShapeName)(shape.name, templateName);
227
210
  return {
@@ -232,11 +215,10 @@ function getIDQueryArgs(templateName) {
232
215
  };
233
216
  };
234
217
  }
218
+
235
219
  /**
236
220
  * Construct a shape name used for a mutation input shape.
237
221
  */
238
-
239
-
240
222
  function getMutationInputShapeName(verb) {
241
223
  return shapeName => {
242
224
  return (0, _util.formatShapeName)([verb, shapeName, 'input'], {
@@ -244,35 +226,28 @@ function getMutationInputShapeName(verb) {
244
226
  });
245
227
  };
246
228
  }
229
+
247
230
  /**
248
231
  * Create a shape name variant for an input.
249
232
  */
250
-
251
-
252
233
  function getInputShapeName(shapeName) {
253
234
  if (shapeName === 'TSRelationship') {
254
235
  return shapeName;
255
236
  }
256
-
257
237
  return `${shapeName}Input`;
258
238
  }
259
-
260
239
  function getOutputShapeName(name) {
261
240
  return name.replace(/(?:Input|PartialInput)$/, '');
262
241
  }
263
-
264
242
  function rewriteRefs(context, shapeSchema, rewriteShapeName) {
265
243
  const newSchema = (0, _util.deepClone)(shapeSchema);
266
244
  (0, _util.visit)(newSchema, ['$ref', '@ref'], (_, path) => {
267
245
  const parentPath = path.slice(0, -1);
268
246
  const value = (0, _get.default)(newSchema, parentPath);
269
-
270
247
  if ((value['@ref'] || value.$ref) && !parentPath.includes('@input') && !parentPath.includes('@output')) {
271
248
  const refItem = (0, _refs.getRef)(context, value);
272
-
273
249
  if (refItem) {
274
250
  value['@ref'] = refItem.isForeign ? (0, _refs.refItemToAtRef)(refItem) : `local:${rewriteShapeName((0, _refs.refItemToShapeName)(refItem))}`;
275
-
276
251
  if (value.$ref) {
277
252
  delete value.$ref;
278
253
  }
@@ -281,11 +256,10 @@ function rewriteRefs(context, shapeSchema, rewriteShapeName) {
281
256
  });
282
257
  return newSchema;
283
258
  }
259
+
284
260
  /**
285
261
  * Construct shapes for a mutation inputs, given source shape info.
286
262
  */
287
-
288
-
289
263
  function getMutationArgs(templateName, verb) {
290
264
  const getShapeName = getMutationInputShapeName(verb);
291
265
  const addLocale = verb === _types.TemplateVerbs.Update || verb === _types.TemplateVerbs.Duplicate;
@@ -299,14 +273,12 @@ function getMutationArgs(templateName, verb) {
299
273
  const shouldRequireId = !isSingleton && (verb === _types.TemplateVerbs.Update || verb === _types.TemplateVerbs.Delete || verb === _types.TemplateVerbs.Duplicate);
300
274
  let rewrittenSchema;
301
275
  let inputShapeSchema;
302
-
303
276
  if (verb !== _types.TemplateVerbs.Delete) {
304
277
  rewrittenSchema = (0, _createInputSchema.createInputSchema)(shape.schema, {
305
278
  isUpdate
306
279
  });
307
280
  inputShapeSchema = rewriteRefs(projectSchema, rewrittenSchema, getInputShapeName);
308
281
  }
309
-
310
282
  const inputShape = (0, _schemaUtil.createShape)(inputName, (0, _util2.mergeObjectSchemas)(shouldRequireId ? idSchema : undefined, inputShapeSchema), {
311
283
  description: `${verb} ${shape.name} input`
312
284
  });
@@ -328,22 +300,21 @@ function getMutationArgs(templateName, verb) {
328
300
  dependencies: {
329
301
  [inputName]: inputShape,
330
302
  [argsShapeName]: argsShape,
331
- ...(verb !== _types.TemplateVerbs.Delete && (0, _keyBy.default)((0, _schemaUtil.getShapeDependencies)(projectSchema, // get the shape dependencies of the shape with the @input swapped
303
+ ...(verb !== _types.TemplateVerbs.Delete && (0, _keyBy.default)((0, _schemaUtil.getShapeDependencies)(projectSchema,
304
+ // get the shape dependencies of the shape with the @input swapped
332
305
  (0, _schemaUtil.createShape)(inputShape.name, rewrittenSchema), propSchema => {
333
306
  if (propSchema['@resolver']) {
334
307
  return false;
335
308
  }
336
-
337
309
  const shapeName = (0, _refs.getRefShapeName)(projectSchema, propSchema);
338
-
339
310
  if (shapeName) {
340
311
  return shapeName !== 'TSRelationship' && !projectSchema.shapes[getInputShapeName(shapeName)];
341
312
  }
342
-
343
313
  return true;
344
314
  }).map(shapeName => {
345
- const shape = projectSchema.shapes[shapeName]; // We only allow partial input at the top-level
315
+ const shape = projectSchema.shapes[shapeName];
346
316
 
317
+ // We only allow partial input at the top-level
347
318
  return (0, _schemaUtil.createShape)(getInputShapeName(shapeName), rewriteRefs(projectSchema, (0, _createInputSchema.createInputSchema)(shape.schema), getInputShapeName));
348
319
  }), 'name')),
349
320
  ...(addStructure ? {
@@ -353,7 +324,6 @@ function getMutationArgs(templateName, verb) {
353
324
  };
354
325
  };
355
326
  }
356
-
357
327
  function getMutationResultType(verb) {
358
328
  return (context, shape) => {
359
329
  const shapeName = (0, _util.formatShapeName)([verb, shape.name, 'result'], {
@@ -380,7 +350,6 @@ function getMutationResultType(verb) {
380
350
  };
381
351
  };
382
352
  }
383
-
384
353
  const commonSearchArgs = {
385
354
  type: 'object',
386
355
  properties: {
@@ -448,7 +417,6 @@ const shapeFilterProps = {
448
417
  }
449
418
  }
450
419
  };
451
-
452
420
  function getShapeListQueryArgs(templateName, legacyArgs) {
453
421
  return (context, shape) => {
454
422
  const {
@@ -463,7 +431,8 @@ function getShapeListQueryArgs(templateName, legacyArgs) {
463
431
  } = (0, _where.getWhereSearchArg)(projectSchema, shapes);
464
432
  return {
465
433
  shapeName,
466
- dependencies: { ...dependencies,
434
+ dependencies: {
435
+ ...dependencies,
467
436
  TSSearchSortInput,
468
437
  [shapeName]: (0, _schemaUtil.createShape)(shapeName, (0, _util2.mergeObjectSchemas)(commonSearchArgs, localeProps, legacyArgs ? legacyListArgs : undefined, isAllShapes ? shapeFilterProps : undefined, schema))
469
438
  }
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.TemplateVerbs = void 0;
7
- let TemplateVerbs;
8
- exports.TemplateVerbs = TemplateVerbs;
9
-
10
- (function (TemplateVerbs) {
7
+ let TemplateVerbs = /*#__PURE__*/function (TemplateVerbs) {
11
8
  TemplateVerbs["Create"] = "create";
12
9
  TemplateVerbs["Update"] = "update";
13
10
  TemplateVerbs["Duplicate"] = "duplicate";
14
11
  TemplateVerbs["Delete"] = "delete";
15
- })(TemplateVerbs || (exports.TemplateVerbs = TemplateVerbs = {}));
12
+ return TemplateVerbs;
13
+ }({});
14
+ exports.TemplateVerbs = TemplateVerbs;