@takeshape/cli 11.113.1 → 11.113.5

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 (2) hide show
  1. package/dist/index.js +1366 -1
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -206930,7 +206930,7 @@ var engines = {
206930
206930
  };
206931
206931
  var package_default = {
206932
206932
  name: "@takeshape/cli",
206933
- version: "11.113.1",
206933
+ version: "11.113.5",
206934
206934
  description: "TakeShape CLI",
206935
206935
  homepage: "https://www.takeshape.io",
206936
206936
  repository: {
@@ -219695,6 +219695,9 @@ var scalars = ["string", "boolean", "integer", "number"];
219695
219695
  // ../schema/dist/services/util.js
219696
219696
  var import_isEmpty2 = __toESM(require_isEmpty(), 1);
219697
219697
  var import_uniq2 = __toESM(require_uniq(), 1);
219698
+ function getStoredServiceConfig(projectSchema, serviceKey) {
219699
+ return projectSchema.services?.[serviceKey];
219700
+ }
219698
219701
  function getServiceNamespaces(context) {
219699
219702
  const namespaces = /* @__PURE__ */ new Map();
219700
219703
  const { services } = context;
@@ -397423,6 +397426,9 @@ var allProjectSchemas = [
397423
397426
  function isBasicResolver(resolver) {
397424
397427
  return isRecord(resolver) && (0, import_isString3.default)(resolver.name);
397425
397428
  }
397429
+ function isServiceResolver(resolver) {
397430
+ return isRecord(resolver) && (0, import_isString3.default)(resolver.name) && (0, import_isString3.default)(resolver.service);
397431
+ }
397426
397432
  function isComposeResolver(resolver) {
397427
397433
  return Boolean((0, import_isArray.default)(resolver?.compose) && resolver.compose.length && resolver.compose.every(isBasicResolver));
397428
397434
  }
@@ -397456,6 +397462,15 @@ function isArraySchema(propertySchema2) {
397456
397462
  function isObjectSchema(propertySchema2) {
397457
397463
  return isRecord(propertySchema2) && propertySchema2.type === "object" && isRecord(propertySchema2.properties);
397458
397464
  }
397465
+ function isAnyServiceConfig(maybeConfig) {
397466
+ return maybeConfig && (0, import_isString3.default)(maybeConfig.title) && (0, import_isString3.default)(maybeConfig.id) && (0, import_isString3.default)(maybeConfig.provider) && (0, import_isString3.default)(maybeConfig.serviceType) && (0, import_isString3.default)(maybeConfig.authenticationType);
397467
+ }
397468
+ function isServiceAuthentication(maybeAuthentication) {
397469
+ return maybeAuthentication?.type;
397470
+ }
397471
+ function isSearchParamsAuthentication(authentication) {
397472
+ return authentication?.type === "searchParams";
397473
+ }
397459
397474
  var getArgsType = (argsSchema) => {
397460
397475
  if ((0, import_has.default)(argsSchema, "@args")) {
397461
397476
  return ArgsType["@args"];
@@ -397817,6 +397832,9 @@ function propertyRefItemToPath(getNamespace2, item2) {
397817
397832
  }
397818
397833
  return ["shapes", applyNamespace(namespace, shapeName14), "schema", "properties", propertyName];
397819
397834
  }
397835
+ function normalizeRefExpression(context, refExpression) {
397836
+ return serializeRef(parseRef(context, refExpression));
397837
+ }
397820
397838
  function getToolRef(tool) {
397821
397839
  return typeof tool === "string" ? tool : tool.ref;
397822
397840
  }
@@ -398016,9 +398034,59 @@ var nonStructuralSchemaKeys = [
398016
398034
  "minItems",
398017
398035
  "uniqueItems"
398018
398036
  ];
398037
+ function getServiceIdFieldName(serviceFieldName) {
398038
+ return `${serviceFieldName}Id`;
398039
+ }
398019
398040
  var generatorVersions = {
398020
398041
  [SERVICE_OBJECT_PATTERN_NAME]: "1"
398021
398042
  };
398043
+ function getGeneratorVersion(generator) {
398044
+ return generatorVersions[generator];
398045
+ }
398046
+ function pathBetween(fromShape, toShape, projectSchema, depthLimit = 4) {
398047
+ if (fromShape.name === toShape.name) {
398048
+ return [];
398049
+ }
398050
+ const toShapeName = toShape.name;
398051
+ let shortestPath;
398052
+ let shortestPathLength = Number.MAX_SAFE_INTEGER;
398053
+ const pathBetweenHelper = (schema22, pathSoFar, seen, depth) => {
398054
+ if (depth > depthLimit) {
398055
+ return;
398056
+ }
398057
+ if (schema22.items) {
398058
+ pathBetweenHelper(schema22.items, pathSoFar, seen, depth);
398059
+ return;
398060
+ }
398061
+ const refItem = getRef(projectSchema, schema22);
398062
+ if (refItem) {
398063
+ const referenced = refItemToShape(projectSchema, refItem);
398064
+ if (referenced) {
398065
+ if (referenced.name === toShapeName && pathSoFar.length < shortestPathLength) {
398066
+ shortestPath = pathSoFar;
398067
+ shortestPathLength = pathSoFar.length;
398068
+ } else if (!seen.has(referenced.name)) {
398069
+ pathBetweenHelper(referenced.schema, pathSoFar, /* @__PURE__ */ new Set([...seen, referenced.name]), depth);
398070
+ }
398071
+ }
398072
+ } else if (pathSoFar.length + 1 < shortestPathLength && (schema22.oneOf ?? schema22.allOf ?? schema22.properties)) {
398073
+ if (schema22.oneOf) {
398074
+ for (const itemSchema of schema22.oneOf) {
398075
+ pathBetweenHelper(itemSchema, pathSoFar, seen, depth);
398076
+ }
398077
+ } else {
398078
+ for (const [propName, propSchema] of createSchemaPropertyList(projectSchema, schema22).getNodes()) {
398079
+ pathBetweenHelper(propSchema, pathSoFar.concat(String(propName)), seen, depth + 1);
398080
+ }
398081
+ }
398082
+ }
398083
+ };
398084
+ pathBetweenHelper(fromShape.schema, [], /* @__PURE__ */ new Set([fromShape.name]), 0);
398085
+ if (!shortestPath) {
398086
+ throw new Error(`No path between ${fromShape.name} and ${toShape.name}`);
398087
+ }
398088
+ return shortestPath;
398089
+ }
398022
398090
  function getShapeQueriesAndMutations(shapes) {
398023
398091
  const queries = {};
398024
398092
  const mutations = {};
@@ -398796,59 +398864,1001 @@ var import_keyBy3 = __toESM(require_keyBy(), 1);
398796
398864
  var import_forEach4 = __toESM(require_forEach(), 1);
398797
398865
  var import_pick2 = __toESM(require_pick(), 1);
398798
398866
 
398867
+ // ../schema/dist/migration/utils.js
398868
+ function formatDate(timestamp) {
398869
+ return (timestamp ? new Date(timestamp) : /* @__PURE__ */ new Date()).toISOString();
398870
+ }
398871
+
398872
+ // ../schema/dist/migration/to/v3.0.0.js
398873
+ var annotationMap = {
398874
+ l10n: "@l10n",
398875
+ sensitive: "@sensitive",
398876
+ syncLocaleStructure: "@syncLocaleStructure"
398877
+ };
398878
+ function isColor(schema22) {
398879
+ const { type, properties } = schema22;
398880
+ return Boolean(type === "object" && properties?.hsl && properties.hsv && properties.rgb && properties.hex);
398881
+ }
398882
+ function getModelType(contentType) {
398883
+ if (contentType.single) {
398884
+ return "single";
398885
+ }
398886
+ if (contentType.taxonomy) {
398887
+ return "taxonomy";
398888
+ }
398889
+ return "multiple";
398890
+ }
398891
+ function getRelationshipSchema(relationship) {
398892
+ const itemSchema = {
398893
+ $ref: "#/shapes/TSRelationship/schema"
398894
+ };
398895
+ if (relationship.type === "multiple") {
398896
+ return {
398897
+ type: "array",
398898
+ items: itemSchema,
398899
+ "@relationship": relationship
398900
+ };
398901
+ }
398902
+ return {
398903
+ ...itemSchema,
398904
+ "@relationship": relationship
398905
+ };
398906
+ }
398907
+ function migrateToContentSchemaV3(params) {
398908
+ const { schema: schema22, service, name, key, setSource, omitAllSources } = params;
398909
+ const { type } = schema22;
398910
+ const mapping = !omitAllSources && key && setSource !== false && name !== key ? `${service}.${key}` : void 0;
398911
+ (0, import_forEach4.default)(schema22, (value2, key2) => {
398912
+ if (annotationMap[key2]) {
398913
+ const newAnnotation = annotationMap[key2];
398914
+ schema22[newAnnotation] = value2;
398915
+ delete schema22[key2];
398916
+ }
398917
+ });
398918
+ if (type === "string" || type === "boolean" || type === "number" || type === "integer") {
398919
+ return {
398920
+ schema: { ...(0, import_pick2.default)(schema22, scalarSchemaKeys), "@mapping": mapping }
398921
+ };
398922
+ }
398923
+ const { relationship } = schema22;
398924
+ if (relationship) {
398925
+ const { contentTypeIds, type: relationshipType, relatedName } = relationship;
398926
+ return {
398927
+ schema: {
398928
+ ...(0, import_pick2.default)(schema22, relationshipType === "multiple" ? multipleRelationshipSchemaKeys : schemaMetadataKeys),
398929
+ "@mapping": mapping,
398930
+ ...getRelationshipSchema({
398931
+ shapeIds: contentTypeIds,
398932
+ type: relationshipType ?? "single",
398933
+ // Type is optional on assets
398934
+ relatedName
398935
+ })
398936
+ }
398937
+ };
398938
+ }
398939
+ if (type === "object" && schema22.draftjs) {
398940
+ return {
398941
+ schema: {
398942
+ ...(0, import_pick2.default)(schema22, scalarSchemaKeys),
398943
+ "@mapping": mapping,
398944
+ "@tag": "draftjs"
398945
+ }
398946
+ };
398947
+ }
398948
+ if (isColor(schema22)) {
398949
+ return {
398950
+ schema: {
398951
+ ...(0, import_pick2.default)(schema22, scalarSchemaKeys),
398952
+ $ref: "#/shapes/TSColor/schema",
398953
+ "@mapping": mapping
398954
+ }
398955
+ };
398956
+ }
398957
+ if (type === "object" && schema22.properties) {
398958
+ const properties = {};
398959
+ const shapes = {};
398960
+ const shapeTitle = [params.shapeTitle, pascalCase(schema22.title ?? params.name)].filter(Boolean).join(" ");
398961
+ const shapeName14 = `${params.shapeName}${pascalCase(params.name)}`;
398962
+ const contentSourceId = `takeshape:local:${shapeName14}`;
398963
+ (0, import_forEach4.default)(schema22.properties, (propSchema, name2) => {
398964
+ const { schema: migratedPropSchema, hoistedShapes } = migrateToContentSchemaV3({
398965
+ ...params,
398966
+ shapeName: shapeName14,
398967
+ shapeTitle,
398968
+ depth: params.depth + 1,
398969
+ schema: propSchema,
398970
+ parentSchema: schema22,
398971
+ service: contentSourceId,
398972
+ key: propSchema.key ?? name2,
398973
+ name: name2,
398974
+ setSource: true
398975
+ });
398976
+ properties[name2] = migratedPropSchema;
398977
+ Object.assign(shapes, hoistedShapes);
398978
+ });
398979
+ if (params.depth > 0) {
398980
+ const { title, description, ...rest } = schema22;
398981
+ return {
398982
+ schema: {
398983
+ title,
398984
+ description,
398985
+ "@mapping": mapping,
398986
+ $ref: `#/shapes/${shapeName14}/schema`
398987
+ },
398988
+ hoistedShapes: {
398989
+ ...shapes,
398990
+ [shapeName14]: {
398991
+ id: name === key ? shapeName14 : key,
398992
+ name: shapeName14,
398993
+ title: shapeTitle,
398994
+ schema: {
398995
+ ...(0, import_pick2.default)(rest, objectSchemaKeys),
398996
+ type: "object",
398997
+ properties
398998
+ }
398999
+ }
399000
+ }
399001
+ };
399002
+ }
399003
+ return {
399004
+ schema: {
399005
+ ...(0, import_pick2.default)(schema22, objectSchemaKeys),
399006
+ properties,
399007
+ "@mapping": mapping
399008
+ },
399009
+ hoistedShapes: shapes
399010
+ };
399011
+ }
399012
+ if (schema22.type === "array" && schema22.items) {
399013
+ const { schema: itemSchema, hoistedShapes } = migrateToContentSchemaV3({
399014
+ ...params,
399015
+ schema: schema22.items,
399016
+ parentSchema: schema22,
399017
+ service: "parent",
399018
+ setSource: false
399019
+ });
399020
+ return {
399021
+ schema: {
399022
+ ...(0, import_pick2.default)(schema22, arraySchemaKeys),
399023
+ items: itemSchema,
399024
+ "@mapping": mapping
399025
+ },
399026
+ hoistedShapes
399027
+ };
399028
+ }
399029
+ throw new Error(`Unknown schema type "${type}"`);
399030
+ }
399031
+ function contentTypeToShape(contentType, contentTypeId) {
399032
+ const title = contentType.title ?? contentType.name;
399033
+ const name = pascalCase(contentType.name);
399034
+ const contentSourceId = `takeshape:local:${name}`;
399035
+ const { schema: schema22, hoistedShapes } = migrateToContentSchemaV3({
399036
+ shapeName: name,
399037
+ shapeTitle: title,
399038
+ schema: contentType.schema,
399039
+ service: contentSourceId,
399040
+ name: "",
399041
+ key: "",
399042
+ depth: 0
399043
+ });
399044
+ return {
399045
+ [name]: {
399046
+ id: contentTypeId,
399047
+ name,
399048
+ title,
399049
+ model: {
399050
+ type: getModelType(contentType)
399051
+ },
399052
+ workflow: contentType.workflow,
399053
+ schema: schema22
399054
+ },
399055
+ ...hoistedShapes
399056
+ };
399057
+ }
399058
+ var migrate = async (_, projectSchema) => {
399059
+ const { contentTypes, created, updated, ...rest } = projectSchema;
399060
+ const shapes = {};
399061
+ const forms = {};
399062
+ for (const contentTypeId of Object.keys(contentTypes)) {
399063
+ const contentType = contentTypes[contentTypeId];
399064
+ Object.assign(shapes, contentTypeToShape(contentType, contentTypeId));
399065
+ forms[pascalCase(contentType.name)] = contentType.forms;
399066
+ }
399067
+ return deepClone({
399068
+ ...rest,
399069
+ ...getShapeQueriesAndMutations(Object.values(shapes)),
399070
+ schemaVersion: "3",
399071
+ created: formatDate(created),
399072
+ updated: formatDate(updated),
399073
+ shapes,
399074
+ forms
399075
+ });
399076
+ };
399077
+ var v3_0_0_default2 = migrate;
399078
+
398799
399079
  // ../schema/dist/migration/to/v3.1.0.js
398800
399080
  var import_isObject2 = __toESM(require_isObject(), 1);
398801
399081
  var import_isString6 = __toESM(require_isString(), 1);
398802
399082
  var import_isUndefined2 = __toESM(require_isUndefined(), 1);
398803
399083
  var import_p_reduce = __toESM(require_p_reduce(), 1);
399084
+ function parseV3ServiceStr(service) {
399085
+ const parts = service.split(":");
399086
+ return {
399087
+ provider: parts.length > 1 ? parts[0] : void 0,
399088
+ id: parts.length > 1 ? parts[1] : parts[0]
399089
+ };
399090
+ }
399091
+ function updateServiceConfigV3ToV3_1(serviceConfig, serviceKey) {
399092
+ if (isAnyServiceConfig(serviceConfig)) {
399093
+ if ((0, import_isString6.default)(serviceConfig.authentication) || (0, import_isUndefined2.default)(serviceConfig.authentication)) {
399094
+ return serviceConfig;
399095
+ }
399096
+ return serviceConfig;
399097
+ }
399098
+ const { auth } = serviceConfig;
399099
+ const serviceParams = serviceConfig.params || {};
399100
+ let { provider: serviceKeyProvider, id: serviceKeyId } = parseV3ServiceStr(serviceKey);
399101
+ const authType = serviceParams.authType || void 0;
399102
+ const title = serviceParams.name || serviceKeyId;
399103
+ if (serviceKeyId === "vercel") {
399104
+ serviceKeyProvider = "vercel";
399105
+ } else if (serviceKeyId === "netlify") {
399106
+ serviceKeyProvider = "netlify";
399107
+ }
399108
+ if (serviceParams.type === "rest") {
399109
+ serviceKeyProvider = "rest";
399110
+ } else if (serviceParams.type === "graphql" && serviceKeyProvider !== "shopify") {
399111
+ serviceKeyProvider = "graphql";
399112
+ }
399113
+ let provider;
399114
+ let authenticationType;
399115
+ let serviceType;
399116
+ let namespace;
399117
+ if (serviceKeyProvider === "shopify") {
399118
+ provider = "shopify";
399119
+ authenticationType = "oauth2Bearer";
399120
+ serviceType = "graphql";
399121
+ namespace = serviceParams.namespace ?? "Shopify";
399122
+ } else if (serviceKeyProvider === "takeshape") {
399123
+ provider = "takeshape";
399124
+ authenticationType = "none";
399125
+ serviceType = "takeshape";
399126
+ namespace = serviceParams.namespace ?? "TakeShape";
399127
+ } else if (serviceKeyProvider === "bigcommerce") {
399128
+ provider = "bigcommerce";
399129
+ authenticationType = "bearer";
399130
+ serviceType = "graphql";
399131
+ namespace = serviceParams.namespace ?? "BigCommerce";
399132
+ } else if (serviceKeyProvider === "rest") {
399133
+ provider = "generic";
399134
+ authenticationType = mapAuthType(authType, auth);
399135
+ serviceType = "rest";
399136
+ namespace = serviceParams.namespace ?? pascalCase(title);
399137
+ } else if (serviceKeyProvider === "graphql") {
399138
+ provider = "generic";
399139
+ authenticationType = mapAuthType(authType, auth);
399140
+ serviceType = "graphql";
399141
+ namespace = serviceParams.namespace ?? pascalCase(title);
399142
+ } else if (serviceKeyProvider === "vercel") {
399143
+ provider = "vercel";
399144
+ authenticationType = "oauth2Bearer";
399145
+ serviceType = "deployment";
399146
+ } else if (serviceKeyProvider === "netlify") {
399147
+ provider = "netlify";
399148
+ authenticationType = "oauth2Bearer";
399149
+ serviceType = "deployment";
399150
+ } else {
399151
+ provider = "generic";
399152
+ authenticationType = mapAuthType(authType, auth);
399153
+ serviceType = "unknown";
399154
+ namespace = serviceParams.namespace ?? pascalCase(title);
399155
+ }
399156
+ const updatedServiceConfig = {
399157
+ title,
399158
+ id: serviceKey,
399159
+ provider,
399160
+ namespace,
399161
+ serviceType,
399162
+ authenticationType,
399163
+ options: {
399164
+ ...serviceParams
399165
+ }
399166
+ };
399167
+ if (serviceConfig.auth && (0, import_isObject2.default)(serviceConfig.auth)) {
399168
+ const authentication = updateServiceAuthentication(updatedServiceConfig.authenticationType, serviceConfig.auth, serviceParams);
399169
+ return {
399170
+ ...updatedServiceConfig,
399171
+ authentication
399172
+ };
399173
+ }
399174
+ return updatedServiceConfig;
399175
+ }
399176
+ function updateServiceAuthentication(authenticationType, legacyAuth, legacyParams) {
399177
+ if (authenticationType === "oauth2Bearer") {
399178
+ return {
399179
+ token: legacyAuth.accessToken,
399180
+ scope: legacyAuth.scope,
399181
+ header: legacyParams.authHeader
399182
+ };
399183
+ }
399184
+ if (authenticationType === "searchParams" && legacyParams.authProp) {
399185
+ return [
399186
+ {
399187
+ name: legacyParams.authProp,
399188
+ value: legacyAuth.accessToken
399189
+ }
399190
+ ];
399191
+ }
399192
+ if (authenticationType === "basic") {
399193
+ const [username, password] = Buffer.from(legacyAuth.accessToken, "base64").toString("utf-8").split(":");
399194
+ return {
399195
+ username,
399196
+ password
399197
+ };
399198
+ }
399199
+ if (authenticationType === "bearer") {
399200
+ return {
399201
+ token: legacyAuth.accessToken,
399202
+ header: legacyParams.authHeader
399203
+ };
399204
+ }
399205
+ }
399206
+ function mapAuthType(authType, auth) {
399207
+ if (authType === "none") {
399208
+ return "none";
399209
+ }
399210
+ if (authType === "searchParams") {
399211
+ return "searchParams";
399212
+ }
399213
+ if (authType === "bearer") {
399214
+ return "bearer";
399215
+ }
399216
+ if (authType === "bearer") {
399217
+ return "basic";
399218
+ }
399219
+ if (!auth) {
399220
+ return "none";
399221
+ }
399222
+ if (auth) {
399223
+ return "bearer";
399224
+ }
399225
+ return "unknown";
399226
+ }
399227
+ var migrate2 = async (context, projectSchema) => {
399228
+ const { encryptFn, decryptFn } = context;
399229
+ let services;
399230
+ if (projectSchema.services) {
399231
+ services = await (0, import_p_reduce.default)(Object.entries(projectSchema.services), async (serviceMap, [serviceKey, serviceConfig]) => {
399232
+ const auth = serviceConfig.auth && decryptFn(serviceConfig.auth);
399233
+ const updatedServiceConfig = updateServiceConfigV3ToV3_1({ ...serviceConfig, auth }, serviceKey);
399234
+ const authentication = updatedServiceConfig?.authentication;
399235
+ serviceMap[serviceKey] = {
399236
+ ...updatedServiceConfig,
399237
+ authentication: authentication && (0, import_isObject2.default)(authentication) ? encryptFn(authentication) : authentication
399238
+ };
399239
+ return serviceMap;
399240
+ }, {});
399241
+ }
399242
+ return deepClone({
399243
+ ...projectSchema,
399244
+ services,
399245
+ schemaVersion: "3.1.0"
399246
+ });
399247
+ };
399248
+ var v3_1_0_default2 = migrate2;
399249
+
399250
+ // ../schema/dist/migration/to/v3.3.0.js
399251
+ var migrate3 = async (context, projectSchema) => {
399252
+ const { generateDataKeyFn } = context;
399253
+ const dataKey = projectSchema.dataKey ? projectSchema.dataKey : await generateDataKeyFn();
399254
+ return {
399255
+ ...projectSchema,
399256
+ schemaVersion: "3.3.0",
399257
+ dataKey
399258
+ };
399259
+ };
399260
+ var v3_3_0_default2 = migrate3;
398804
399261
 
398805
399262
  // ../schema/dist/migration/to/v3.9.0.js
398806
399263
  var import_isEmpty3 = __toESM(require_isEmpty(), 1);
398807
399264
  var import_omit8 = __toESM(require_omit(), 1);
399265
+ function omitOptions(resolver, names) {
399266
+ if (resolver.options) {
399267
+ const newOptions = (0, import_omit8.default)(resolver.options, names);
399268
+ if ((0, import_isEmpty3.default)(newOptions)) {
399269
+ resolver.options = void 0;
399270
+ } else {
399271
+ resolver.options = newOptions;
399272
+ }
399273
+ }
399274
+ }
399275
+ var migrate4 = async (_, projectSchema) => {
399276
+ const ensureResolverOptions = (resolver) => {
399277
+ if (resolver.name.startsWith("takeshape")) {
399278
+ if (!resolver.shapeName) {
399279
+ resolver.shapeName = resolver.options?.model ?? resolver.options?.indexedShape ?? "";
399280
+ omitOptions(resolver, ["model", "indexedShape"]);
399281
+ }
399282
+ }
399283
+ if (resolver.name.startsWith("graphql")) {
399284
+ if (!resolver.fieldName) {
399285
+ resolver.fieldName = resolver.options?.fieldName ?? "";
399286
+ omitOptions(resolver, ["fieldName"]);
399287
+ }
399288
+ }
399289
+ if (resolver.name.startsWith("awsLambda")) {
399290
+ if (!resolver.functionName) {
399291
+ resolver.functionName = resolver.options?.functionName ?? "";
399292
+ omitOptions(resolver, ["functionName"]);
399293
+ }
399294
+ }
399295
+ if (resolver.name.startsWith("rest")) {
399296
+ if (!resolver.path) {
399297
+ if (resolver.pathParams) {
399298
+ resolver.path = {
399299
+ ...resolver.pathParams,
399300
+ serialize: {
399301
+ ...resolver.pathParams.serialize,
399302
+ template: resolver.options?.path
399303
+ }
399304
+ };
399305
+ } else {
399306
+ resolver.path = resolver.options?.path ?? "";
399307
+ }
399308
+ omitOptions(resolver, ["path"]);
399309
+ }
399310
+ }
399311
+ return resolver;
399312
+ };
399313
+ visit3(projectSchema, ["resolver", "@resolver"], (resolver) => {
399314
+ if (resolver.compose) {
399315
+ resolver.compose.forEach(ensureResolverOptions);
399316
+ } else {
399317
+ ensureResolverOptions(resolver);
399318
+ }
399319
+ });
399320
+ return {
399321
+ ...projectSchema,
399322
+ schemaVersion: "3.9.0"
399323
+ };
399324
+ };
399325
+ var v3_9_0_default2 = migrate4;
398808
399326
 
398809
399327
  // ../schema/dist/migration/to/v3.10.0.js
398810
399328
  var import_set3 = __toESM(require_set3(), 1);
398811
399329
  var import_mapValues2 = __toESM(require_mapValues(), 1);
399330
+ function $refToPath2(ref) {
399331
+ return ref.substr(2).split("/");
399332
+ }
399333
+ function $refToShapeName2(ref) {
399334
+ return $refToPath2(ref)[1];
399335
+ }
399336
+ function findServiceIdForNamespace(projectSchema, namespace) {
399337
+ if (projectSchema.services) {
399338
+ for (const [serviceId, service] of Object.entries(projectSchema.services)) {
399339
+ if (service.namespace === namespace) {
399340
+ return serviceId;
399341
+ }
399342
+ }
399343
+ }
399344
+ return "local";
399345
+ }
399346
+ function updateRefSyntax(projectSchema, $ref) {
399347
+ const shapeName14 = $refToShapeName2($ref);
399348
+ const parts = shapeName14.split("_");
399349
+ const serviceId = parts.length === 1 ? "local" : findServiceIdForNamespace(projectSchema, parts[0]);
399350
+ return `${serviceId}:${parts[parts.length - 1]}`;
399351
+ }
399352
+ function migrateQueryToV3_10(projectSchema) {
399353
+ return (query, queryName) => {
399354
+ const { args, shape } = query;
399355
+ if (typeof args === "object" && ("oneOf" in args || "allOf" in args || "$ref" in args || "@ref" in args)) {
399356
+ throw new Error(`Query "${queryName}" contains an unsupported arg schema ${JSON.stringify(args)}. Please contact support`);
399357
+ }
399358
+ if (typeof shape === "object") {
399359
+ if (shape.items.$ref) {
399360
+ return (0, import_set3.default)("shape.items", { "@ref": updateRefSyntax(projectSchema, shape.items.$ref) }, query);
399361
+ }
399362
+ if (!shape.items["@ref"]) {
399363
+ throw new Error(`Query "${queryName}" contains an unsupported shape schema ${JSON.stringify(shape)}. Please contact support`);
399364
+ }
399365
+ }
399366
+ return query;
399367
+ };
399368
+ }
399369
+ function migrateShapeToV3_10(shape) {
399370
+ const { schema: schema22, ...rest } = shape;
399371
+ if ("type" in schema22 && schema22.type === "array") {
399372
+ throw new Error(`Shape ${shape.name} uses an unsupported array schema. Please contact support`);
399373
+ }
399374
+ const newSchema = "$ref" in schema22 || "@ref" in schema22 ? { allOf: [schema22] } : schema22;
399375
+ return {
399376
+ ...rest,
399377
+ schema: newSchema
399378
+ };
399379
+ }
399380
+ var migrate5 = async (_, projectSchema) => {
399381
+ const { queries, mutations, shapes, schemaVersion, ...rest } = projectSchema;
399382
+ const migrate25 = migrateQueryToV3_10(projectSchema);
399383
+ return {
399384
+ ...rest,
399385
+ queries: (0, import_mapValues2.default)(queries, migrate25),
399386
+ mutations: (0, import_mapValues2.default)(mutations, migrate25),
399387
+ shapes: (0, import_mapValues2.default)(shapes, migrateShapeToV3_10),
399388
+ schemaVersion: "3.10.0"
399389
+ };
399390
+ };
399391
+ var v3_10_0_default2 = migrate5;
398812
399392
 
398813
399393
  // ../schema/dist/migration/to/v3.11.0.js
398814
399394
  var import_fromPairs = __toESM(require_fromPairs(), 1);
399395
+ var migrate6 = async (context, projectSchema) => {
399396
+ const { decryptFn, encryptFn } = context;
399397
+ const migratedServices = [];
399398
+ for (const [serviceKey, serviceConfig] of Object.entries(projectSchema.services ?? {})) {
399399
+ const { authenticationType, authentication } = serviceConfig;
399400
+ if (authentication && authenticationType !== "unknown" && authenticationType !== "none") {
399401
+ const decrypted = decryptFn(authentication);
399402
+ if (!decrypted) {
399403
+ throw new Error(`Service "${serviceKey}" authentication could not be decrypted. Please contact support.`);
399404
+ }
399405
+ let migrated;
399406
+ if (authenticationType === "searchParams") {
399407
+ migrated = {
399408
+ params: decrypted,
399409
+ type: authenticationType
399410
+ };
399411
+ }
399412
+ if (authenticationType === "basic") {
399413
+ migrated = {
399414
+ username: "",
399415
+ password: "",
399416
+ ...decrypted,
399417
+ type: authenticationType
399418
+ };
399419
+ }
399420
+ if (authenticationType === "bearer") {
399421
+ migrated = {
399422
+ token: "",
399423
+ ...decrypted,
399424
+ type: authenticationType
399425
+ };
399426
+ }
399427
+ if (authenticationType === "oauth2Bearer") {
399428
+ migrated = {
399429
+ token: "",
399430
+ ...decrypted,
399431
+ type: authenticationType
399432
+ };
399433
+ }
399434
+ if (authenticationType === "oauth2") {
399435
+ migrated = {
399436
+ grantType: "clientCredentials",
399437
+ clientId: "",
399438
+ ...decrypted,
399439
+ type: authenticationType
399440
+ };
399441
+ }
399442
+ if (authenticationType === "aws") {
399443
+ migrated = {
399444
+ awsAccessKeyId: "",
399445
+ awsSecretAccessKey: "",
399446
+ ...decrypted,
399447
+ type: authenticationType
399448
+ };
399449
+ }
399450
+ if (authenticationType === "custom") {
399451
+ migrated = {
399452
+ ...decrypted,
399453
+ type: authenticationType
399454
+ };
399455
+ }
399456
+ if (migrated) {
399457
+ const migratedServiceConfig = {
399458
+ ...serviceConfig,
399459
+ authentication: encryptFn(migrated)
399460
+ };
399461
+ migratedServices.push([serviceKey, migratedServiceConfig]);
399462
+ } else {
399463
+ migratedServices.push([serviceKey, serviceConfig]);
399464
+ }
399465
+ } else {
399466
+ migratedServices.push([serviceKey, serviceConfig]);
399467
+ }
399468
+ }
399469
+ return {
399470
+ ...projectSchema,
399471
+ services: (0, import_fromPairs.default)(migratedServices),
399472
+ schemaVersion: "3.11.0"
399473
+ };
399474
+ };
399475
+ var v3_11_0_default2 = migrate6;
398815
399476
 
398816
399477
  // ../schema/dist/migration/to/v3.12.3.js
398817
399478
  var import_omit9 = __toESM(require_omit(), 1);
399479
+ function hasWebhook(projectSchema, config) {
399480
+ const queryName = config.queries?.single?.name;
399481
+ if (!queryName) {
399482
+ return false;
399483
+ }
399484
+ const resolver = projectSchema?.queries[queryName]?.resolver;
399485
+ return resolver && "service" in resolver && projectSchema?.services?.[resolver.service].provider === "shopify";
399486
+ }
399487
+ var migrate7 = async (_, { indexedShapes: oldIndexedShapes, ...projectSchema }) => {
399488
+ if (!oldIndexedShapes) {
399489
+ return {
399490
+ ...projectSchema,
399491
+ schemaVersion: "3.12.3"
399492
+ };
399493
+ }
399494
+ const indexedShapes = Object.fromEntries(Object.entries(oldIndexedShapes).map(([shapeName14, config]) => {
399495
+ const queries = {};
399496
+ const triggers = [];
399497
+ if (!config.queries) {
399498
+ return [
399499
+ shapeName14,
399500
+ {
399501
+ ...config,
399502
+ queries,
399503
+ triggers
399504
+ }
399505
+ ];
399506
+ }
399507
+ if (hasWebhook(projectSchema, config)) {
399508
+ queries.get = config.queries.single;
399509
+ triggers.push({
399510
+ type: "webhook",
399511
+ query: "get",
399512
+ service: "shopify",
399513
+ events: ["products/create", "products/update", "products/delete"]
399514
+ });
399515
+ }
399516
+ const oldPagination = config.queries.all?.pagination;
399517
+ const pagination = oldPagination === void 0 ? void 0 : oldPagination.type === "cursor" ? {
399518
+ ...oldPagination,
399519
+ itemsToIndexPath: oldPagination.itemsPath,
399520
+ pageSize: oldPagination.size,
399521
+ pageSizeArg: oldPagination.sizeArg
399522
+ } : oldPagination.type === "offset" ? {
399523
+ ...oldPagination,
399524
+ itemsToIndexPath: oldPagination.itemsPath,
399525
+ itemTotalPath: oldPagination.totalPath,
399526
+ offsetArg: oldPagination.offsetParam
399527
+ } : {
399528
+ ...oldPagination,
399529
+ itemsToIndexPath: oldPagination.itemsPath,
399530
+ pageTotalPath: oldPagination.totalPagesPath
399531
+ };
399532
+ queries.list = pagination ? {
399533
+ ...(0, import_omit9.default)(config.queries.all, "interval"),
399534
+ pagination
399535
+ } : (0, import_omit9.default)(config.queries.all, "interval", "pagination");
399536
+ triggers.push({
399537
+ type: "schedule",
399538
+ query: "list",
399539
+ interval: config.queries.all.interval ?? 60 * 24
399540
+ });
399541
+ return [
399542
+ shapeName14,
399543
+ {
399544
+ ...config,
399545
+ queries,
399546
+ triggers
399547
+ }
399548
+ ];
399549
+ }));
399550
+ return {
399551
+ ...projectSchema,
399552
+ schemaVersion: "3.12.3",
399553
+ indexedShapes
399554
+ };
399555
+ };
399556
+ var v3_12_3_default2 = migrate7;
398818
399557
 
398819
399558
  // ../schema/dist/migration/to/v3.13.0.js
398820
399559
  var import_get8 = __toESM(require_get(), 1);
399560
+ var migrate8 = async (_, projectSchema) => {
399561
+ visit3(projectSchema, ["@relationship"], (relationship, path16) => {
399562
+ const parent = (0, import_get8.default)(projectSchema, path16.slice(0, -1));
399563
+ parent["@backreference"] = { enabled: true };
399564
+ if (relationship.relatedName) {
399565
+ parent["@backreference"].name = relationship.relatedName;
399566
+ relationship.relatedName = void 0;
399567
+ }
399568
+ });
399569
+ return {
399570
+ ...projectSchema,
399571
+ schemaVersion: "3.13.0"
399572
+ };
399573
+ };
399574
+ var v3_13_0_default2 = migrate8;
398821
399575
 
398822
399576
  // ../schema/dist/migration/to/v3.17.0.js
398823
399577
  var import_get9 = __toESM(require_get(), 1);
398824
399578
  var import_omit10 = __toESM(require_omit(), 1);
398825
399579
  var import_set4 = __toESM(require_set2(), 1);
399580
+ var migrate9 = async (_, projectSchema) => {
399581
+ visit3(projectSchema, ["@user"], (_2, path16) => {
399582
+ const parentPath = path16.slice(0, -1);
399583
+ const oldSchema = (0, import_get9.default)(projectSchema, parentPath);
399584
+ const newSchema = {
399585
+ ...(0, import_omit10.default)(oldSchema, ["@user", "type"]),
399586
+ "@ref": "local:TSUser",
399587
+ "@input": { type: "string" },
399588
+ "@resolver": { name: "takeshape:getUser", service: "takeshape:local" }
399589
+ };
399590
+ (0, import_set4.default)(projectSchema, parentPath, newSchema);
399591
+ });
399592
+ return {
399593
+ ...projectSchema,
399594
+ schemaVersion: "3.17.0"
399595
+ };
399596
+ };
399597
+ var v3_17_0_default2 = migrate9;
398826
399598
 
398827
399599
  // ../schema/dist/migration/to/v3.18.0.js
398828
399600
  var import_get10 = __toESM(require_get(), 1);
398829
399601
  var import_omit11 = __toESM(require_omit(), 1);
398830
399602
  var import_set5 = __toESM(require_set2(), 1);
399603
+ var migrate10 = async (_, projectSchema) => {
399604
+ visit3(projectSchema, ["@relationship"], (relationship, path16) => {
399605
+ const propertyPath = path16.slice(0, -1);
399606
+ const originalPropertySchema = (0, import_get10.default)(projectSchema, propertyPath);
399607
+ const propertySchema2 = (0, import_omit11.default)(originalPropertySchema, ["@relationship", "type", "$ref"]);
399608
+ const shapeIdMap = new Map(Object.values(projectSchema.shapes).map((shape) => [shape.id, shape]));
399609
+ const shapeIdsToShapeRefs = (shapeIds) => {
399610
+ return shapeIds.map((shapeId5) => {
399611
+ let shape;
399612
+ if (shapeId5 === "ASSET") {
399613
+ shape = { name: "Asset" };
399614
+ } else {
399615
+ shape = shapeIdMap.get(shapeId5);
399616
+ }
399617
+ if (!shape) {
399618
+ return;
399619
+ }
399620
+ return {
399621
+ "@ref": `local:${shape.name}`
399622
+ };
399623
+ }).filter(isDefined);
399624
+ };
399625
+ const shapeRefs = shapeIdsToShapeRefs(relationship.shapeIds);
399626
+ const shapeRefsSchema = shapeRefs.length === 1 ? shapeRefs[0] : { oneOf: shapeRefs };
399627
+ if (relationship.type === "multiple") {
399628
+ propertySchema2.type = "array";
399629
+ propertySchema2.items = shapeRefsSchema;
399630
+ propertySchema2["@input"] = {
399631
+ type: "array",
399632
+ items: {
399633
+ "@ref": "local:TSRelationship"
399634
+ }
399635
+ };
399636
+ } else {
399637
+ propertySchema2.type = void 0;
399638
+ Object.assign(propertySchema2, shapeRefsSchema);
399639
+ propertySchema2["@input"] = {
399640
+ "@ref": "local:TSRelationship"
399641
+ };
399642
+ }
399643
+ propertySchema2["@args"] = "TSRelationshipArgs";
399644
+ propertySchema2["@resolver"] = {
399645
+ name: "takeshape:getRelated",
399646
+ service: "takeshape:local",
399647
+ options: {
399648
+ nullable: true
399649
+ }
399650
+ };
399651
+ (0, import_set5.default)(projectSchema, propertyPath, propertySchema2);
399652
+ });
399653
+ return {
399654
+ ...projectSchema,
399655
+ schemaVersion: "3.18.0"
399656
+ };
399657
+ };
399658
+ var v3_18_0_default2 = migrate10;
398831
399659
 
398832
399660
  // ../schema/dist/migration/to/v3.18.1.js
398833
399661
  var import_pick3 = __toESM(require_pick2(), 1);
398834
399662
  var import_mapValues3 = __toESM(require_mapValues(), 1);
398835
399663
  var pruneQuery = (0, import_pick3.default)(["args", "resolver", "shape", "description"]);
399664
+ var migrate11 = async (_, projectSchema) => {
399665
+ return {
399666
+ ...projectSchema,
399667
+ queries: (0, import_mapValues3.default)(projectSchema.queries, pruneQuery),
399668
+ mutations: (0, import_mapValues3.default)(projectSchema.mutations, pruneQuery),
399669
+ schemaVersion: "3.18.1"
399670
+ };
399671
+ };
399672
+ var v3_18_1_default2 = migrate11;
398836
399673
 
398837
399674
  // ../schema/dist/migration/to/v3.18.2.js
398838
399675
  var import_mapValues4 = __toESM(require_mapValues(), 1);
399676
+ function updateGenericServices(projectSchema) {
399677
+ if (projectSchema.services) {
399678
+ return {
399679
+ ...projectSchema,
399680
+ services: (0, import_mapValues4.default)(projectSchema.services, (serviceConfig) => (
399681
+ // generic provider has been renamed to match service type
399682
+ serviceConfig.provider === "generic" ? { ...serviceConfig, provider: serviceConfig.serviceType } : serviceConfig
399683
+ ))
399684
+ };
399685
+ }
399686
+ return projectSchema;
399687
+ }
399688
+ var migrate12 = async (_, projectSchema) => {
399689
+ return {
399690
+ ...updateGenericServices(projectSchema),
399691
+ schemaVersion: "3.18.2"
399692
+ };
399693
+ };
399694
+ var v3_18_2_default2 = migrate12;
398839
399695
 
398840
399696
  // ../schema/dist/migration/to/v3.20.0.js
398841
399697
  var import_mapValues5 = __toESM(require_mapValues(), 1);
399698
+ function updateGenericServices2(projectSchema) {
399699
+ if (projectSchema.services) {
399700
+ return {
399701
+ ...projectSchema,
399702
+ services: (0, import_mapValues5.default)(projectSchema.services, (serviceConfig) => (
399703
+ // generic provider has been renamed to match service type
399704
+ serviceConfig.provider === "shopify" ? {
399705
+ ...serviceConfig,
399706
+ options: { ...serviceConfig.options, legacyApp: true }
399707
+ } : serviceConfig
399708
+ ))
399709
+ };
399710
+ }
399711
+ return projectSchema;
399712
+ }
399713
+ var migrate13 = async (_, projectSchema) => {
399714
+ return {
399715
+ ...updateGenericServices2(projectSchema),
399716
+ schemaVersion: "3.20.0"
399717
+ };
399718
+ };
399719
+ var v3_20_0_default2 = migrate13;
398842
399720
 
398843
399721
  // ../schema/dist/migration/to/v3.22.0.js
398844
399722
  var import_mapValues6 = __toESM(require_mapValues(), 1);
398845
399723
  var import_omit12 = __toESM(require_omit(), 1);
399724
+ var migrate14 = async (_, projectSchema) => {
399725
+ const { indexedShapes, ...rest } = projectSchema;
399726
+ const migrated = {
399727
+ ...rest,
399728
+ schemaVersion: "3.22.0"
399729
+ };
399730
+ if (indexedShapes) {
399731
+ migrated.indexedShapes = (0, import_mapValues6.default)(indexedShapes, (indexedShape) => {
399732
+ const { ignoreFields, objectDepthLimit } = indexedShape.queries.list ?? indexedShape.queries.get ?? {};
399733
+ return {
399734
+ ...indexedShape,
399735
+ query: {
399736
+ ignoreFields,
399737
+ maxDepth: objectDepthLimit
399738
+ },
399739
+ queries: (0, import_mapValues6.default)(indexedShape.queries, (config) => config && (0, import_omit12.default)(config, ["ignoreFields", "objectDepthLimit"]))
399740
+ };
399741
+ });
399742
+ }
399743
+ return migrated;
399744
+ };
399745
+ var v3_22_0_default2 = migrate14;
399746
+
399747
+ // ../schema/dist/migration/to/v3.24.0.js
399748
+ var migrate15 = async (_, projectSchema) => {
399749
+ const { updated, created, version, ...migrated } = projectSchema;
399750
+ return {
399751
+ ...migrated,
399752
+ schemaVersion: "3.24.0"
399753
+ };
399754
+ };
399755
+ var v3_24_0_default2 = migrate15;
399756
+
399757
+ // ../schema/dist/migration/to/v3.25.0.js
399758
+ var migrate16 = async (_, projectSchema) => {
399759
+ const { dataKey, ...migrated } = projectSchema;
399760
+ return {
399761
+ ...migrated,
399762
+ schemaVersion: "3.25.0"
399763
+ };
399764
+ };
399765
+ var v3_25_0_default2 = migrate16;
398846
399766
 
398847
399767
  // ../schema/dist/migration/to/v3.31.0.js
398848
399768
  var import_isString7 = __toESM(require_isString(), 1);
398849
399769
  var import_last2 = __toESM(require_last(), 1);
398850
399770
  var import_set6 = __toESM(require_set2(), 1);
398851
399771
  var import_unset3 = __toESM(require_unset(), 1);
399772
+ var TAKESHAPE_RESOLVERS = ["takeshape:getUser", "takeshape:search", "takeshape:queryApiIndex", "util:wrap"];
399773
+ function getServicePath(path16) {
399774
+ const servicePath = [...path16];
399775
+ servicePath.splice(-1, 1, "service");
399776
+ return servicePath;
399777
+ }
399778
+ var migrate17 = async (_, projectSchema) => {
399779
+ visit3(projectSchema, ["@ref", "@mapping", "name"], (value2, path16) => {
399780
+ if ((0, import_isString7.default)(value2)) {
399781
+ const name = (0, import_last2.default)(path16);
399782
+ if (name === "name" && value2 === "debug:noop") {
399783
+ (0, import_set6.default)(projectSchema, path16, "util:noop");
399784
+ (0, import_unset3.default)(projectSchema, getServicePath(path16));
399785
+ } else if (name === "name" && value2 === "util:wrap") {
399786
+ (0, import_unset3.default)(projectSchema, getServicePath(path16));
399787
+ } else if (name === "name" && value2.startsWith("takeshape:")) {
399788
+ const serviceName = TAKESHAPE_RESOLVERS.includes(value2) ? "takeshape" : "shapedb";
399789
+ (0, import_set6.default)(projectSchema, getServicePath(path16), serviceName);
399790
+ (0, import_set6.default)(projectSchema, path16, value2.replace("takeshape:", `${serviceName}:`));
399791
+ } else {
399792
+ (0, import_set6.default)(projectSchema, path16, value2.replace("takeshape:local", "shapedb"));
399793
+ }
399794
+ }
399795
+ });
399796
+ return {
399797
+ ...projectSchema,
399798
+ schemaVersion: "3.31.0"
399799
+ };
399800
+ };
399801
+ var v3_31_0_default2 = migrate17;
399802
+
399803
+ // ../schema/dist/migration/to/v3.32.0.js
399804
+ function migrateListQuery(listConfig) {
399805
+ const { pagination, name, ...restConfig } = listConfig;
399806
+ const result = { ...restConfig, query: name };
399807
+ if (pagination) {
399808
+ const { itemsToIndexPath, ...restPagination } = pagination;
399809
+ result.pagination = { ...restPagination, itemsPath: itemsToIndexPath };
399810
+ }
399811
+ return result;
399812
+ }
399813
+ function queriesToLoaders(queries) {
399814
+ if (queries.list) {
399815
+ const loaders = {
399816
+ list: Array.isArray(queries.list) ? queries.list.map(migrateListQuery) : migrateListQuery(queries.list)
399817
+ };
399818
+ if (queries.get) {
399819
+ const { name, ...restGet } = queries.get;
399820
+ loaders.get = { ...restGet, query: name };
399821
+ }
399822
+ return loaders;
399823
+ }
399824
+ }
399825
+ function migrateTrigger(trigger) {
399826
+ const { query, ...rest } = trigger;
399827
+ return { ...rest, loader: query };
399828
+ }
399829
+ var migrate18 = async (_, projectSchema) => {
399830
+ const updatedShapes = { ...projectSchema.shapes };
399831
+ const { indexedShapes, ...rest } = projectSchema;
399832
+ if (indexedShapes) {
399833
+ for (const [name, config] of Object.entries(indexedShapes)) {
399834
+ let shape = updatedShapes[name];
399835
+ shape ||= {
399836
+ name,
399837
+ id: name,
399838
+ title: name,
399839
+ schema: {
399840
+ extends: [{ "@ref": normalizeRefExpression(projectSchema, name) }]
399841
+ }
399842
+ };
399843
+ const loaders = queriesToLoaders(config.queries);
399844
+ if (loaders) {
399845
+ shape.loaders = loaders;
399846
+ }
399847
+ shape.cache = {
399848
+ enabled: true,
399849
+ fragment: config.query,
399850
+ triggers: config.triggers.map(migrateTrigger)
399851
+ };
399852
+ updatedShapes[name] = shape;
399853
+ }
399854
+ }
399855
+ return {
399856
+ ...rest,
399857
+ shapes: updatedShapes,
399858
+ schemaVersion: "3.32.0"
399859
+ };
399860
+ };
399861
+ var v3_32_0_default2 = migrate18;
398852
399862
 
398853
399863
  // ../schema/dist/migration/to/v3.34.0.js
398854
399864
  var import_set7 = __toESM(require_set3(), 1);
@@ -398892,12 +399902,271 @@ function createServiceConfigValidator() {
398892
399902
  });
398893
399903
  }
398894
399904
  var serviceConfigValidator = createServiceConfigValidator();
399905
+ function getServiceObjectFields(projectSchema, shape, provider) {
399906
+ return (getServiceInfo(projectSchema, shape)[provider] ?? []).filter((serviceInfo) => serviceInfo.generators[SERVICE_OBJECT_PATTERN_NAME]);
399907
+ }
399908
+ function getServiceInfo(projectSchema, shape) {
399909
+ const result = {};
399910
+ const inlineDepShapes = getShapeDependencies(projectSchema, shape, (prop) => !prop["@resolver"]).map((name) => projectSchema.shapes[name]);
399911
+ const shapesToCheck = [shape, ...inlineDepShapes];
399912
+ for (const thisShape of shapesToCheck) {
399913
+ createSchemaPropertyList(projectSchema, thisShape).forEach(([key, value2]) => {
399914
+ const resolver = value2["@resolver"];
399915
+ if (!isServiceResolver(resolver)) {
399916
+ return;
399917
+ }
399918
+ const serviceConfig = getStoredServiceConfig(projectSchema, resolver.service);
399919
+ if (!serviceConfig) {
399920
+ return;
399921
+ }
399922
+ const { provider } = serviceConfig;
399923
+ const generators = {};
399924
+ const tag3 = value2["@tag"];
399925
+ if (tag3?.startsWith(SERVICE_OBJECT_PATTERN_NAME)) {
399926
+ const idFieldName = getServiceIdFieldName(key);
399927
+ const version = tag3.substr(Number(tag3.lastIndexOf(":")) + 1);
399928
+ generators[SERVICE_OBJECT_PATTERN_NAME] = {
399929
+ version,
399930
+ currentVersion: getGeneratorVersion(SERVICE_OBJECT_PATTERN_NAME),
399931
+ idFieldName,
399932
+ serviceObjectType: resolver.fieldName
399933
+ };
399934
+ }
399935
+ const serviceInfo = {
399936
+ service: resolver.service,
399937
+ fieldName: key,
399938
+ path: pathBetween(shape, thisShape, projectSchema),
399939
+ generators
399940
+ };
399941
+ if (Array.isArray(result[provider])) {
399942
+ if (!result[provider].find((existingServiceInfo) => (0, import_isEqual2.default)(existingServiceInfo, serviceInfo))) {
399943
+ result[provider].push(serviceInfo);
399944
+ }
399945
+ } else {
399946
+ result[provider] = [serviceInfo];
399947
+ }
399948
+ });
399949
+ }
399950
+ return result;
399951
+ }
399952
+
399953
+ // ../schema/dist/migration/to/v3.34.0.js
399954
+ var widgetMigrations = {
399955
+ object: "shapeObject",
399956
+ repeater: "shapeArray"
399957
+ };
399958
+ function normalizeForms(projectSchema) {
399959
+ const normalizedForms = {};
399960
+ const { forms = {} } = projectSchema;
399961
+ const storeSourceForm = (shapeName14, formConfig, propName) => {
399962
+ normalizedForms[shapeName14] ||= { default: deepClone(formConfig) };
399963
+ const propConfig = normalizedForms[shapeName14].default.properties[propName];
399964
+ propConfig.properties = void 0;
399965
+ propConfig.order = void 0;
399966
+ propConfig.widget = widgetMigrations[propConfig.widget] ?? propConfig.widget;
399967
+ };
399968
+ const normalizeNested = (shapeName14, formConfig) => {
399969
+ const shape = projectSchema.shapes[shapeName14];
399970
+ if (!shape || !formConfig.properties) {
399971
+ return;
399972
+ }
399973
+ const propertyAccessor = createSchemaPropertyAccessor(projectSchema, shape);
399974
+ for (const propName of Object.keys(formConfig.properties)) {
399975
+ const propConfig = formConfig.properties[propName];
399976
+ const propSchema = propertyAccessor.getValue(propName);
399977
+ if (propSchema) {
399978
+ const ref = getRefOrItemsRef(projectSchema, propSchema);
399979
+ if (ref && propConfig.properties && propConfig.widget !== "shopify") {
399980
+ const nestedShapeName = refItemToNamespacedShapeName(projectSchema, ref);
399981
+ normalizedForms[nestedShapeName] = { default: deepClone(propConfig) };
399982
+ storeSourceForm(shapeName14, formConfig, propName);
399983
+ normalizeNested(nestedShapeName, propConfig);
399984
+ }
399985
+ }
399986
+ }
399987
+ };
399988
+ if (forms) {
399989
+ for (const shapeName14 of Object.keys(forms)) {
399990
+ normalizeNested(shapeName14, forms[shapeName14].default);
399991
+ normalizedForms[shapeName14] ||= forms[shapeName14];
399992
+ }
399993
+ }
399994
+ return normalizedForms;
399995
+ }
399996
+ function migrateInterfaceShapes(projectSchema) {
399997
+ let updatedProjectSchema = projectSchema;
399998
+ for (const shape of Object.values(projectSchema.shapes)) {
399999
+ if (!shape.model) {
400000
+ continue;
400001
+ }
400002
+ const serviceObjectFields = getServiceObjectFields({ ...projectSchema, schemaVersion: CURRENT_SCHEMA_VERSION }, shape, "shopify");
400003
+ for (const field of serviceObjectFields) {
400004
+ const { fieldName, service } = field;
400005
+ const { serviceObjectType } = field.generators[SERVICE_OBJECT_PATTERN_NAME];
400006
+ const serviceShapeName = (0, import_upperFirst3.default)(serviceObjectType);
400007
+ const interfaceShapeName = `${serviceShapeName}Interface`;
400008
+ updatedProjectSchema = (0, import_unset4.default)(["shapes", interfaceShapeName], updatedProjectSchema);
400009
+ if ("type" in shape.schema && shape.schema.type === "object") {
400010
+ const prop = shape.schema.properties[fieldName];
400011
+ if (prop) {
400012
+ updatedProjectSchema = (0, import_set7.default)(["shapes", shape.name, "schema", "properties", fieldName, "@input"], { "@ref": `${service}:${serviceShapeName}Input` }, updatedProjectSchema);
400013
+ }
400014
+ }
400015
+ for (const [mutationName, mutation] of Object.entries(projectSchema.mutations)) {
400016
+ if (!mutation || typeof mutation.args !== "string") {
400017
+ continue;
400018
+ }
400019
+ for (const template of ["CreateArgs", "UpdateArgs"]) {
400020
+ if (mutation.args === `${template}<${interfaceShapeName}>`) {
400021
+ updatedProjectSchema = (0, import_set7.default)(["mutations", mutationName], { ...mutation, args: `${template}<${serviceShapeName}>` }, updatedProjectSchema);
400022
+ }
400023
+ }
400024
+ }
400025
+ }
400026
+ }
400027
+ return updatedProjectSchema;
400028
+ }
400029
+ var migrate19 = async (_, projectSchema) => {
400030
+ let normalized = projectSchema;
400031
+ try {
400032
+ normalized = {
400033
+ ...projectSchema,
400034
+ forms: normalizeForms(projectSchema)
400035
+ };
400036
+ } catch (e2) {
400037
+ console.info("v3.34.0 migration warning: Failed to normalize forms", e2.message);
400038
+ }
400039
+ try {
400040
+ normalized = migrateInterfaceShapes(normalized);
400041
+ } catch (e2) {
400042
+ console.info("v3.34.0 migration warning: Failed to migrate interface shapes", e2.message);
400043
+ }
400044
+ return {
400045
+ ...normalized,
400046
+ schemaVersion: "3.34.0"
400047
+ };
400048
+ };
400049
+ var v3_34_0_default2 = migrate19;
398895
400050
 
398896
400051
  // ../schema/dist/migration/to/v3.36.0.js
398897
400052
  var import_mapValues7 = __toESM(require_mapValues(), 1);
400053
+ var migrate20 = async (_, projectSchema) => {
400054
+ const result = {
400055
+ ...projectSchema,
400056
+ schemaVersion: "3.36.0"
400057
+ };
400058
+ result.services &&= (0, import_mapValues7.default)(result.services, (config) => {
400059
+ if (config.serviceType === "openapi") {
400060
+ return {
400061
+ ...config,
400062
+ options: {
400063
+ ...config.options,
400064
+ transformVersion: "1.0.0"
400065
+ }
400066
+ };
400067
+ }
400068
+ return config;
400069
+ });
400070
+ return result;
400071
+ };
400072
+ var v3_36_0_default2 = migrate20;
400073
+
400074
+ // ../schema/dist/migration/to/v3.39.0.js
400075
+ var migrate21 = async ({ decryptFn, encryptFn }, projectSchema) => {
400076
+ for (const serviceConfig of Object.values(projectSchema.services ?? {})) {
400077
+ if (serviceConfig.authentication) {
400078
+ const authentication = decryptFn(serviceConfig.authentication);
400079
+ if (isServiceAuthentication(authentication) && isSearchParamsAuthentication(authentication)) {
400080
+ if (serviceConfig.provider === "judgeMe") {
400081
+ const shopDomain = authentication.params.find((param) => param.name === "shop_domain");
400082
+ if (shopDomain) {
400083
+ serviceConfig.options = {
400084
+ ...serviceConfig.options,
400085
+ searchParams: {
400086
+ shop_domain: shopDomain.value
400087
+ }
400088
+ };
400089
+ serviceConfig.options.shopDomain = void 0;
400090
+ }
400091
+ authentication.params = authentication.params.filter((param) => param.name !== "shop_domain");
400092
+ }
400093
+ if (serviceConfig.provider === "reviewsIo") {
400094
+ const storeId = authentication.params.find((param) => param.name === "store");
400095
+ if (storeId) {
400096
+ serviceConfig.options = {
400097
+ ...serviceConfig.options,
400098
+ searchParams: {
400099
+ store: storeId.value
400100
+ }
400101
+ };
400102
+ serviceConfig.options.storeId = void 0;
400103
+ }
400104
+ authentication.params = authentication.params.filter((param) => param.name !== "store");
400105
+ }
400106
+ serviceConfig.authentication = encryptFn(authentication);
400107
+ }
400108
+ }
400109
+ }
400110
+ return {
400111
+ ...projectSchema,
400112
+ schemaVersion: "3.39.0"
400113
+ };
400114
+ };
400115
+ var v3_39_0_default2 = migrate21;
398898
400116
 
398899
400117
  // ../schema/dist/migration/to/v3.40.0.js
398900
400118
  var import_mapValues8 = __toESM(require_mapValues(), 1);
400119
+ var migrate22 = async (_, projectSchema) => {
400120
+ const newShapes = (0, import_mapValues8.default)(projectSchema.shapes, (shape) => {
400121
+ if (shape.cache?.fragment?.maxDepth !== void 0) {
400122
+ const newShape = {
400123
+ ...shape,
400124
+ cache: {
400125
+ ...shape.cache,
400126
+ fragment: {
400127
+ ...shape.cache.fragment,
400128
+ includeDeprecated: true
400129
+ }
400130
+ }
400131
+ };
400132
+ return newShape;
400133
+ }
400134
+ return shape;
400135
+ });
400136
+ return {
400137
+ ...projectSchema,
400138
+ shapes: newShapes,
400139
+ schemaVersion: "3.40.0"
400140
+ };
400141
+ };
400142
+ var v3_40_0_default2 = migrate22;
400143
+
400144
+ // ../schema/dist/migration/to/v3.46.0.js
400145
+ function isBasicResolver2(resolver) {
400146
+ return isRecord(resolver) && typeof resolver.name === "string";
400147
+ }
400148
+ function isComposeResolver2(resolver) {
400149
+ return Boolean(isRecord(resolver) && Array.isArray(resolver.compose) && resolver.compose.length && resolver.compose.every(isBasicResolver2));
400150
+ }
400151
+ function renameResolver(resolver) {
400152
+ if (resolver.name === "ai:generateText" && (resolver.options?.history ?? true)) {
400153
+ resolver.name = "ai:chat";
400154
+ }
400155
+ }
400156
+ var migrate23 = async (_, projectSchema) => {
400157
+ visit3(projectSchema, ["resolver", "@resolver"], (maybeResolver) => {
400158
+ if (isComposeResolver2(maybeResolver)) {
400159
+ maybeResolver.compose.forEach(renameResolver);
400160
+ } else if (isBasicResolver2(maybeResolver)) {
400161
+ renameResolver(maybeResolver);
400162
+ }
400163
+ });
400164
+ return {
400165
+ ...projectSchema,
400166
+ schemaVersion: "3.46.0"
400167
+ };
400168
+ };
400169
+ var v3_46_0_default2 = migrate23;
398901
400170
 
398902
400171
  // ../../node_modules/.pnpm/jsonpath-plus@10.0.1/node_modules/jsonpath-plus/dist/index-node-esm.js
398903
400172
  var import_vm = __toESM(require("vm"), 1);
@@ -403477,7 +404746,103 @@ function validateProjectSchemaImport(maybeSchema) {
403477
404746
  });
403478
404747
  }
403479
404748
 
404749
+ // ../schema/dist/migration/to/v3.57.0.js
404750
+ var migrate24 = async (context, projectSchema) => {
404751
+ const { ["ai-experimental"]: ai, ...rest } = projectSchema;
404752
+ const migrated = {
404753
+ ...rest,
404754
+ schemaVersion: "3.57.0"
404755
+ };
404756
+ if (ai) {
404757
+ const migratedWithAi = Object.assign({ ...migrated }, ai);
404758
+ const { valid } = await validateSchema({ ignoreEntitlements: true, structureOnly: true }, migratedWithAi);
404759
+ if (valid) {
404760
+ return migratedWithAi;
404761
+ }
404762
+ context.logger.warn(`Dropping "ai-experimental" properties schema for project "${projectSchema.projectId}".`);
404763
+ }
404764
+ return migrated;
404765
+ };
404766
+ var v3_57_0_default2 = migrate24;
404767
+
403480
404768
  // ../schema/dist/migration/index.js
404769
+ function getNoopMigration(_from, to) {
404770
+ return async (_context, projectSchema) => {
404771
+ return {
404772
+ ...projectSchema,
404773
+ schemaVersion: to
404774
+ };
404775
+ };
404776
+ }
404777
+ var migrateTo = {
404778
+ "v3.0.0": v3_0_0_default2,
404779
+ "v3.1.0": v3_1_0_default2,
404780
+ "v3.2.0": getNoopMigration("3.1.0", "3.2.0"),
404781
+ "v3.3.0": v3_3_0_default2,
404782
+ "v3.4.0": getNoopMigration("3.3.0", "3.4.0"),
404783
+ "v3.5.0": getNoopMigration("3.4.0", "3.5.0"),
404784
+ "v3.5.1": getNoopMigration("3.5.0", "3.5.1"),
404785
+ "v3.6.0": getNoopMigration("3.5.1", "3.6.0"),
404786
+ "v3.7.0": getNoopMigration("3.6.0", "3.7.0"),
404787
+ "v3.8.0": getNoopMigration("3.7.0", "3.8.0"),
404788
+ "v3.9.0": v3_9_0_default2,
404789
+ "v3.10.0": v3_10_0_default2,
404790
+ "v3.11.0": v3_11_0_default2,
404791
+ "v3.12.0": getNoopMigration("3.11.0", "3.12.0"),
404792
+ "v3.12.1": getNoopMigration("3.12.0", "3.12.1"),
404793
+ "v3.12.2": getNoopMigration("3.12.1", "3.12.2"),
404794
+ "v3.12.3": v3_12_3_default2,
404795
+ "v3.13.0": v3_13_0_default2,
404796
+ "v3.14.0": getNoopMigration("3.13.0", "3.14.0"),
404797
+ "v3.15.0": getNoopMigration("3.14.0", "3.15.0"),
404798
+ "v3.16.0": getNoopMigration("3.15.0", "3.16.0"),
404799
+ "v3.17.0": v3_17_0_default2,
404800
+ "v3.17.1": getNoopMigration("3.17.0", "3.17.1"),
404801
+ "v3.18.0": v3_18_0_default2,
404802
+ "v3.18.1": v3_18_1_default2,
404803
+ "v3.18.2": v3_18_2_default2,
404804
+ "v3.19.0": getNoopMigration("3.18.2", "3.19.0"),
404805
+ "v3.20.0": v3_20_0_default2,
404806
+ "v3.21.0": getNoopMigration("3.20.0", "3.21.0"),
404807
+ "v3.22.0": v3_22_0_default2,
404808
+ "v3.23.0": getNoopMigration("3.22.0", "3.23.0"),
404809
+ "v3.24.0": v3_24_0_default2,
404810
+ "v3.25.0": v3_25_0_default2,
404811
+ "v3.26.0": getNoopMigration("3.25.0", "3.26.0"),
404812
+ "v3.27.0": getNoopMigration("3.26.0", "3.27.0"),
404813
+ "v3.28.0": getNoopMigration("3.27.0", "3.28.0"),
404814
+ "v3.29.0": getNoopMigration("3.28.0", "3.29.0"),
404815
+ "v3.30.0": getNoopMigration("3.29.0", "3.30.0"),
404816
+ "v3.31.0": v3_31_0_default2,
404817
+ "v3.32.0": v3_32_0_default2,
404818
+ "v3.33.0": getNoopMigration("3.32.0", "3.33.0"),
404819
+ "v3.34.0": v3_34_0_default2,
404820
+ "v3.35.0": getNoopMigration("3.34.0", "3.35.0"),
404821
+ "v3.36.0": v3_36_0_default2,
404822
+ "v3.37.0": getNoopMigration("3.36.0", "3.37.0"),
404823
+ "v3.38.0": getNoopMigration("3.37.0", "3.38.0"),
404824
+ "v3.39.0": v3_39_0_default2,
404825
+ "v3.40.0": v3_40_0_default2,
404826
+ "v3.41.0": getNoopMigration("3.40.0", "3.41.0"),
404827
+ "v3.42.0": getNoopMigration("3.41.0", "3.42.0"),
404828
+ "v3.43.0": getNoopMigration("3.42.0", "3.43.0"),
404829
+ "v3.44.0": getNoopMigration("3.43.0", "3.44.0"),
404830
+ "v3.45.0": getNoopMigration("3.44.0", "3.45.0"),
404831
+ "v3.46.0": v3_46_0_default2,
404832
+ "v3.47.0": getNoopMigration("3.46.0", "3.47.0"),
404833
+ "v3.48.0": getNoopMigration("3.47.0", "3.48.0"),
404834
+ "v3.49.0": getNoopMigration("3.48.0", "3.49.0"),
404835
+ "v3.50.0": getNoopMigration("3.49.0", "3.50.0"),
404836
+ "v3.51.0": getNoopMigration("3.50.0", "3.51.0"),
404837
+ "v3.52.0": getNoopMigration("3.51.0", "3.52.0"),
404838
+ "v3.53.0": getNoopMigration("3.52.0", "3.53.0"),
404839
+ "v3.54.0": getNoopMigration("3.53.0", "3.54.0"),
404840
+ "v3.55.0": getNoopMigration("3.54.0", "3.55.0"),
404841
+ "v3.56.0": getNoopMigration("3.55.0", "3.56.0"),
404842
+ "v3.57.0": v3_57_0_default2,
404843
+ "v3.58.0": getNoopMigration("3.57.0", "3.58.0"),
404844
+ "v3.59.0": getNoopMigration("3.58.0", "3.59.0")
404845
+ };
403481
404846
  var listTypePrefix = "PaginatedList";
403482
404847
 
403483
404848
  // ../schema/dist/template-shapes/types.js