@shopify/hydrogen-codegen 0.3.0 → 0.3.2

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.
@@ -34,7 +34,7 @@ const caapiDefaultValues = {
34
34
  )
35
35
  };
36
36
  function getDefaultOptions(outputFile = "") {
37
- return /^(customer|caapi\.)/i.test(outputFile) ? caapiDefaultValues : sfapiDefaultValues;
37
+ return /(customer|caapi\.)/i.test(outputFile) ? caapiDefaultValues : sfapiDefaultValues;
38
38
  }
39
39
 
40
40
  exports.getDefaultOptions = getDefaultOptions;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/defaults.ts"],"names":[],"mappings":"AAEA,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAE9B,MAAM,qCAAqC;AAAA;AAAA,wCAEH,mBAAmB;AAAA,0CACjB,qBAAqB;AAAA;AAG/D,MAAM,qCAAqC;AAAA;AAAA,6CAEE,mBAAmB;AAAA,+CACjB,qBAAqB;AAAA;AAGpE,SAAS,oBACP,MACA,WACA,cACA;AACA,SAAO,KACJ,QAAQ,qBAAqB,SAAS,EACtC,QAAQ,uBAAuB,YAAY;AAChD;AAQA,MAAM,qBAAoC;AAAA,EACxC,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,wBAAwB,CAAC,EAAC,WAAW,aAAY,MAC/C;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACJ;AAEA,MAAM,qBAAoC;AAAA,EACxC,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,wBAAwB,CAAC,EAAC,WAAW,aAAY,MAC/C;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACJ;AAEO,SAAS,kBAAkB,aAAa,IAAI;AACjD,SAAO,uBAAuB,KAAK,UAAU,IACzC,qBACA;AACN","sourcesContent":["import type {PresetConfig} from './preset';\n\nconst QUERIES_PLACEHOLDER = '%queries%';\nconst MUTATIONS_PLACEHOLDER = '%mutations%';\n\nconst sfapiDefaultInterfaceExtensionCode = `\ndeclare module '@shopify/hydrogen' {\n interface StorefrontQueries extends ${QUERIES_PLACEHOLDER} {}\n interface StorefrontMutations extends ${MUTATIONS_PLACEHOLDER} {}\n}`;\n\nconst caapiDefaultInterfaceExtensionCode = `\ndeclare module '@shopify/hydrogen' {\n interface CustomerAccountQueries extends ${QUERIES_PLACEHOLDER} {}\n interface CustomerAccountMutations extends ${MUTATIONS_PLACEHOLDER} {}\n}`;\n\nfunction replacePlaceholders(\n code: string,\n queryType: string,\n mutationType: string,\n) {\n return code\n .replace(QUERIES_PLACEHOLDER, queryType)\n .replace(MUTATIONS_PLACEHOLDER, mutationType);\n}\n\ntype DefaultValues = {\n importTypesFrom: string;\n namespacedImportName: string;\n interfaceExtensionCode: NonNullable<PresetConfig['interfaceExtension']>;\n};\n\nconst sfapiDefaultValues: DefaultValues = {\n importTypesFrom: '@shopify/hydrogen/storefront-api-types',\n namespacedImportName: 'StorefrontAPI',\n interfaceExtensionCode: ({queryType, mutationType}) =>\n replacePlaceholders(\n sfapiDefaultInterfaceExtensionCode,\n queryType,\n mutationType,\n ),\n};\n\nconst caapiDefaultValues: DefaultValues = {\n importTypesFrom: '@shopify/hydrogen/customer-account-api-types',\n namespacedImportName: 'CustomerAccountAPI',\n interfaceExtensionCode: ({queryType, mutationType}) =>\n replacePlaceholders(\n caapiDefaultInterfaceExtensionCode,\n queryType,\n mutationType,\n ),\n};\n\nexport function getDefaultOptions(outputFile = '') {\n return /^(customer|caapi\\.)/i.test(outputFile)\n ? caapiDefaultValues\n : sfapiDefaultValues;\n}\n"]}
1
+ {"version":3,"sources":["../../src/defaults.ts"],"names":[],"mappings":"AAEA,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAE9B,MAAM,qCAAqC;AAAA;AAAA,wCAEH,mBAAmB;AAAA,0CACjB,qBAAqB;AAAA;AAG/D,MAAM,qCAAqC;AAAA;AAAA,6CAEE,mBAAmB;AAAA,+CACjB,qBAAqB;AAAA;AAGpE,SAAS,oBACP,MACA,WACA,cACA;AACA,SAAO,KACJ,QAAQ,qBAAqB,SAAS,EACtC,QAAQ,uBAAuB,YAAY;AAChD;AAQA,MAAM,qBAAoC;AAAA,EACxC,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,wBAAwB,CAAC,EAAC,WAAW,aAAY,MAC/C;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACJ;AAEA,MAAM,qBAAoC;AAAA,EACxC,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,wBAAwB,CAAC,EAAC,WAAW,aAAY,MAC/C;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACJ;AAEO,SAAS,kBAAkB,aAAa,IAAI;AACjD,SAAO,sBAAsB,KAAK,UAAU,IACxC,qBACA;AACN","sourcesContent":["import type {PresetConfig} from './preset';\n\nconst QUERIES_PLACEHOLDER = '%queries%';\nconst MUTATIONS_PLACEHOLDER = '%mutations%';\n\nconst sfapiDefaultInterfaceExtensionCode = `\ndeclare module '@shopify/hydrogen' {\n interface StorefrontQueries extends ${QUERIES_PLACEHOLDER} {}\n interface StorefrontMutations extends ${MUTATIONS_PLACEHOLDER} {}\n}`;\n\nconst caapiDefaultInterfaceExtensionCode = `\ndeclare module '@shopify/hydrogen' {\n interface CustomerAccountQueries extends ${QUERIES_PLACEHOLDER} {}\n interface CustomerAccountMutations extends ${MUTATIONS_PLACEHOLDER} {}\n}`;\n\nfunction replacePlaceholders(\n code: string,\n queryType: string,\n mutationType: string,\n) {\n return code\n .replace(QUERIES_PLACEHOLDER, queryType)\n .replace(MUTATIONS_PLACEHOLDER, mutationType);\n}\n\ntype DefaultValues = {\n importTypesFrom: string;\n namespacedImportName: string;\n interfaceExtensionCode: NonNullable<PresetConfig['interfaceExtension']>;\n};\n\nconst sfapiDefaultValues: DefaultValues = {\n importTypesFrom: '@shopify/hydrogen/storefront-api-types',\n namespacedImportName: 'StorefrontAPI',\n interfaceExtensionCode: ({queryType, mutationType}) =>\n replacePlaceholders(\n sfapiDefaultInterfaceExtensionCode,\n queryType,\n mutationType,\n ),\n};\n\nconst caapiDefaultValues: DefaultValues = {\n importTypesFrom: '@shopify/hydrogen/customer-account-api-types',\n namespacedImportName: 'CustomerAccountAPI',\n interfaceExtensionCode: ({queryType, mutationType}) =>\n replacePlaceholders(\n caapiDefaultInterfaceExtensionCode,\n queryType,\n mutationType,\n ),\n};\n\nexport function getDefaultOptions(outputFile = '') {\n return /(customer|caapi\\.)/i.test(outputFile)\n ? caapiDefaultValues\n : sfapiDefaultValues;\n}\n"]}
@@ -6,23 +6,23 @@ var graphqlCodegen = require('@shopify/graphql-codegen');
6
6
 
7
7
 
8
8
 
9
- Object.defineProperty(exports, 'preset', {
9
+ Object.defineProperty(exports, "preset", {
10
10
  enumerable: true,
11
11
  get: function () { return preset_js.preset; }
12
12
  });
13
- Object.defineProperty(exports, 'getSchema', {
13
+ Object.defineProperty(exports, "getSchema", {
14
14
  enumerable: true,
15
15
  get: function () { return schema_js.getSchema; }
16
16
  });
17
- Object.defineProperty(exports, 'pluckConfig', {
17
+ Object.defineProperty(exports, "pluckConfig", {
18
18
  enumerable: true,
19
19
  get: function () { return graphqlCodegen.pluckConfig; }
20
20
  });
21
- Object.defineProperty(exports, 'plugin', {
21
+ Object.defineProperty(exports, "plugin", {
22
22
  enumerable: true,
23
23
  get: function () { return graphqlCodegen.plugin; }
24
24
  });
25
- Object.defineProperty(exports, 'processSources', {
25
+ Object.defineProperty(exports, "processSources", {
26
26
  enumerable: true,
27
27
  get: function () { return graphqlCodegen.processSources; }
28
28
  });
@@ -8,7 +8,7 @@ function getSchema(api, options) {
8
8
  );
9
9
  }
10
10
  try {
11
- return require.resolve(`@shopify/hydrogen-react/${api}.schema.json`);
11
+ return require.resolve(`@shopify/hydrogen/${api}.schema.json`);
12
12
  } catch {
13
13
  if (options?.throwIfMissing !== false) {
14
14
  throw new Error(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema.ts"],"names":[],"mappings":"AACA;AAgBO,SAAS,UAAU,KAAU,SAA4B;AAC9D,MAAI,QAAQ,gBAAgB,QAAQ,oBAAoB;AACtD,UAAM,IAAI;AAAA,MACR,0BAA0B,GAAG;AAAA,IAC/B;AAAA,EACF;AAEA,MAAI;AACF,WAAO,QAAQ,QAAQ,2BAA2B,GAAG,cAAc;AAAA,EACrE,QAAQ;AACN,QAAI,SAAS,mBAAmB,OAAO;AACrC,YAAM,IAAI;AAAA,QACR,gCAAgC,GAAG;AAAA;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AACF","sourcesContent":["// This comment is used during ESM build:\n//! import {createRequire} from 'module'; const require = createRequire(import.meta.url);\n\ntype Api = 'storefront' | 'customer-account';\ntype Options<T extends boolean> = {throwIfMissing?: T};\n\n/**\n * Resolves a schema path for the provided API type. Only the API types currently\n * bundled in Hydrogen are allowed: \"storefront\" and \"customer\".\n * @param api\n * @returns\n */\nexport function getSchema(api: Api, options?: Options<true>): string;\nexport function getSchema(\n api: Api,\n options: Options<false>,\n): string | undefined;\nexport function getSchema(api: Api, options?: Options<boolean>) {\n if (api !== 'storefront' && api !== 'customer-account') {\n throw new Error(\n `The provided API type \"${api}\" is unknown. Please use \"storefront\" or \"customer-account\".`,\n );\n }\n\n try {\n return require.resolve(`@shopify/hydrogen-react/${api}.schema.json`);\n } catch {\n if (options?.throwIfMissing !== false) {\n throw new Error(\n `Could not find a schema for \"${api}\".\\nPlease make sure a recent version of \\`@shopify/hydrogen\\` is installed.`,\n );\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/schema.ts"],"names":[],"mappings":"AACA;AAgBO,SAAS,UAAU,KAAU,SAA4B;AAC9D,MAAI,QAAQ,gBAAgB,QAAQ,oBAAoB;AACtD,UAAM,IAAI;AAAA,MACR,0BAA0B,GAAG;AAAA,IAC/B;AAAA,EACF;AAEA,MAAI;AACF,WAAO,QAAQ,QAAQ,qBAAqB,GAAG,cAAc;AAAA,EAC/D,QAAQ;AACN,QAAI,SAAS,mBAAmB,OAAO;AACrC,YAAM,IAAI;AAAA,QACR,gCAAgC,GAAG;AAAA;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AACF","sourcesContent":["// This comment is used during ESM build:\n//! import {createRequire} from 'module'; const require = createRequire(import.meta.url);\n\ntype Api = 'storefront' | 'customer-account';\ntype Options<T extends boolean> = {throwIfMissing?: T};\n\n/**\n * Resolves a schema path for the provided API type. Only the API types currently\n * bundled in Hydrogen are allowed: \"storefront\" and \"customer\".\n * @param api\n * @returns\n */\nexport function getSchema(api: Api, options?: Options<true>): string;\nexport function getSchema(\n api: Api,\n options: Options<false>,\n): string | undefined;\nexport function getSchema(api: Api, options?: Options<boolean>) {\n if (api !== 'storefront' && api !== 'customer-account') {\n throw new Error(\n `The provided API type \"${api}\" is unknown. Please use \"storefront\" or \"customer-account\".`,\n );\n }\n\n try {\n return require.resolve(`@shopify/hydrogen/${api}.schema.json`);\n } catch {\n if (options?.throwIfMissing !== false) {\n throw new Error(\n `Could not find a schema for \"${api}\".\\nPlease make sure a recent version of \\`@shopify/hydrogen\\` is installed.`,\n );\n }\n }\n}\n"]}
@@ -32,7 +32,7 @@ const caapiDefaultValues = {
32
32
  )
33
33
  };
34
34
  function getDefaultOptions(outputFile = "") {
35
- return /^(customer|caapi\.)/i.test(outputFile) ? caapiDefaultValues : sfapiDefaultValues;
35
+ return /(customer|caapi\.)/i.test(outputFile) ? caapiDefaultValues : sfapiDefaultValues;
36
36
  }
37
37
 
38
38
  export { getDefaultOptions };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/defaults.ts"],"names":[],"mappings":"AAEA,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAE9B,MAAM,qCAAqC;AAAA;AAAA,wCAEH,mBAAmB;AAAA,0CACjB,qBAAqB;AAAA;AAG/D,MAAM,qCAAqC;AAAA;AAAA,6CAEE,mBAAmB;AAAA,+CACjB,qBAAqB;AAAA;AAGpE,SAAS,oBACP,MACA,WACA,cACA;AACA,SAAO,KACJ,QAAQ,qBAAqB,SAAS,EACtC,QAAQ,uBAAuB,YAAY;AAChD;AAQA,MAAM,qBAAoC;AAAA,EACxC,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,wBAAwB,CAAC,EAAC,WAAW,aAAY,MAC/C;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACJ;AAEA,MAAM,qBAAoC;AAAA,EACxC,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,wBAAwB,CAAC,EAAC,WAAW,aAAY,MAC/C;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACJ;AAEO,SAAS,kBAAkB,aAAa,IAAI;AACjD,SAAO,uBAAuB,KAAK,UAAU,IACzC,qBACA;AACN","sourcesContent":["import type {PresetConfig} from './preset';\n\nconst QUERIES_PLACEHOLDER = '%queries%';\nconst MUTATIONS_PLACEHOLDER = '%mutations%';\n\nconst sfapiDefaultInterfaceExtensionCode = `\ndeclare module '@shopify/hydrogen' {\n interface StorefrontQueries extends ${QUERIES_PLACEHOLDER} {}\n interface StorefrontMutations extends ${MUTATIONS_PLACEHOLDER} {}\n}`;\n\nconst caapiDefaultInterfaceExtensionCode = `\ndeclare module '@shopify/hydrogen' {\n interface CustomerAccountQueries extends ${QUERIES_PLACEHOLDER} {}\n interface CustomerAccountMutations extends ${MUTATIONS_PLACEHOLDER} {}\n}`;\n\nfunction replacePlaceholders(\n code: string,\n queryType: string,\n mutationType: string,\n) {\n return code\n .replace(QUERIES_PLACEHOLDER, queryType)\n .replace(MUTATIONS_PLACEHOLDER, mutationType);\n}\n\ntype DefaultValues = {\n importTypesFrom: string;\n namespacedImportName: string;\n interfaceExtensionCode: NonNullable<PresetConfig['interfaceExtension']>;\n};\n\nconst sfapiDefaultValues: DefaultValues = {\n importTypesFrom: '@shopify/hydrogen/storefront-api-types',\n namespacedImportName: 'StorefrontAPI',\n interfaceExtensionCode: ({queryType, mutationType}) =>\n replacePlaceholders(\n sfapiDefaultInterfaceExtensionCode,\n queryType,\n mutationType,\n ),\n};\n\nconst caapiDefaultValues: DefaultValues = {\n importTypesFrom: '@shopify/hydrogen/customer-account-api-types',\n namespacedImportName: 'CustomerAccountAPI',\n interfaceExtensionCode: ({queryType, mutationType}) =>\n replacePlaceholders(\n caapiDefaultInterfaceExtensionCode,\n queryType,\n mutationType,\n ),\n};\n\nexport function getDefaultOptions(outputFile = '') {\n return /^(customer|caapi\\.)/i.test(outputFile)\n ? caapiDefaultValues\n : sfapiDefaultValues;\n}\n"]}
1
+ {"version":3,"sources":["../../src/defaults.ts"],"names":[],"mappings":"AAEA,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAE9B,MAAM,qCAAqC;AAAA;AAAA,wCAEH,mBAAmB;AAAA,0CACjB,qBAAqB;AAAA;AAG/D,MAAM,qCAAqC;AAAA;AAAA,6CAEE,mBAAmB;AAAA,+CACjB,qBAAqB;AAAA;AAGpE,SAAS,oBACP,MACA,WACA,cACA;AACA,SAAO,KACJ,QAAQ,qBAAqB,SAAS,EACtC,QAAQ,uBAAuB,YAAY;AAChD;AAQA,MAAM,qBAAoC;AAAA,EACxC,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,wBAAwB,CAAC,EAAC,WAAW,aAAY,MAC/C;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACJ;AAEA,MAAM,qBAAoC;AAAA,EACxC,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,wBAAwB,CAAC,EAAC,WAAW,aAAY,MAC/C;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACJ;AAEO,SAAS,kBAAkB,aAAa,IAAI;AACjD,SAAO,sBAAsB,KAAK,UAAU,IACxC,qBACA;AACN","sourcesContent":["import type {PresetConfig} from './preset';\n\nconst QUERIES_PLACEHOLDER = '%queries%';\nconst MUTATIONS_PLACEHOLDER = '%mutations%';\n\nconst sfapiDefaultInterfaceExtensionCode = `\ndeclare module '@shopify/hydrogen' {\n interface StorefrontQueries extends ${QUERIES_PLACEHOLDER} {}\n interface StorefrontMutations extends ${MUTATIONS_PLACEHOLDER} {}\n}`;\n\nconst caapiDefaultInterfaceExtensionCode = `\ndeclare module '@shopify/hydrogen' {\n interface CustomerAccountQueries extends ${QUERIES_PLACEHOLDER} {}\n interface CustomerAccountMutations extends ${MUTATIONS_PLACEHOLDER} {}\n}`;\n\nfunction replacePlaceholders(\n code: string,\n queryType: string,\n mutationType: string,\n) {\n return code\n .replace(QUERIES_PLACEHOLDER, queryType)\n .replace(MUTATIONS_PLACEHOLDER, mutationType);\n}\n\ntype DefaultValues = {\n importTypesFrom: string;\n namespacedImportName: string;\n interfaceExtensionCode: NonNullable<PresetConfig['interfaceExtension']>;\n};\n\nconst sfapiDefaultValues: DefaultValues = {\n importTypesFrom: '@shopify/hydrogen/storefront-api-types',\n namespacedImportName: 'StorefrontAPI',\n interfaceExtensionCode: ({queryType, mutationType}) =>\n replacePlaceholders(\n sfapiDefaultInterfaceExtensionCode,\n queryType,\n mutationType,\n ),\n};\n\nconst caapiDefaultValues: DefaultValues = {\n importTypesFrom: '@shopify/hydrogen/customer-account-api-types',\n namespacedImportName: 'CustomerAccountAPI',\n interfaceExtensionCode: ({queryType, mutationType}) =>\n replacePlaceholders(\n caapiDefaultInterfaceExtensionCode,\n queryType,\n mutationType,\n ),\n};\n\nexport function getDefaultOptions(outputFile = '') {\n return /(customer|caapi\\.)/i.test(outputFile)\n ? caapiDefaultValues\n : sfapiDefaultValues;\n}\n"]}
@@ -159,7 +159,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
159
159
  ```
160
160
 
161
161
  @link https://github.com/microsoft/TypeScript/issues/15300
162
-
162
+ @see SimplifyDeep
163
163
  @category Object
164
164
  */
165
165
  export type Simplify<T> = {
@@ -176,14 +176,7 @@ Useful in type utilities, such as checking if something does not occur.
176
176
 
177
177
  @example
178
178
  ```
179
- import type {IsNever} from 'type-fest';
180
-
181
- type And<A, B> =
182
- A extends true
183
- ? B extends true
184
- ? true
185
- : false
186
- : false;
179
+ import type {IsNever, And} from 'type-fest';
187
180
 
188
181
  // https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
189
182
  type AreStringsEqual<A extends string, B extends string> =
@@ -6,7 +6,7 @@ function getSchema(api, options) {
6
6
  );
7
7
  }
8
8
  try {
9
- return require.resolve(`@shopify/hydrogen-react/${api}.schema.json`);
9
+ return require.resolve(`@shopify/hydrogen/${api}.schema.json`);
10
10
  } catch {
11
11
  if (options?.throwIfMissing !== false) {
12
12
  throw new Error(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema.ts"],"names":[],"mappings":"AACA;AAgBO,SAAS,UAAU,KAAU,SAA4B;AAC9D,MAAI,QAAQ,gBAAgB,QAAQ,oBAAoB;AACtD,UAAM,IAAI;AAAA,MACR,0BAA0B,GAAG;AAAA,IAC/B;AAAA,EACF;AAEA,MAAI;AACF,WAAO,QAAQ,QAAQ,2BAA2B,GAAG,cAAc;AAAA,EACrE,QAAQ;AACN,QAAI,SAAS,mBAAmB,OAAO;AACrC,YAAM,IAAI;AAAA,QACR,gCAAgC,GAAG;AAAA;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AACF","sourcesContent":["// This comment is used during ESM build:\n//! import {createRequire} from 'module'; const require = createRequire(import.meta.url);\n\ntype Api = 'storefront' | 'customer-account';\ntype Options<T extends boolean> = {throwIfMissing?: T};\n\n/**\n * Resolves a schema path for the provided API type. Only the API types currently\n * bundled in Hydrogen are allowed: \"storefront\" and \"customer\".\n * @param api\n * @returns\n */\nexport function getSchema(api: Api, options?: Options<true>): string;\nexport function getSchema(\n api: Api,\n options: Options<false>,\n): string | undefined;\nexport function getSchema(api: Api, options?: Options<boolean>) {\n if (api !== 'storefront' && api !== 'customer-account') {\n throw new Error(\n `The provided API type \"${api}\" is unknown. Please use \"storefront\" or \"customer-account\".`,\n );\n }\n\n try {\n return require.resolve(`@shopify/hydrogen-react/${api}.schema.json`);\n } catch {\n if (options?.throwIfMissing !== false) {\n throw new Error(\n `Could not find a schema for \"${api}\".\\nPlease make sure a recent version of \\`@shopify/hydrogen\\` is installed.`,\n );\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/schema.ts"],"names":[],"mappings":"AACA;AAgBO,SAAS,UAAU,KAAU,SAA4B;AAC9D,MAAI,QAAQ,gBAAgB,QAAQ,oBAAoB;AACtD,UAAM,IAAI;AAAA,MACR,0BAA0B,GAAG;AAAA,IAC/B;AAAA,EACF;AAEA,MAAI;AACF,WAAO,QAAQ,QAAQ,qBAAqB,GAAG,cAAc;AAAA,EAC/D,QAAQ;AACN,QAAI,SAAS,mBAAmB,OAAO;AACrC,YAAM,IAAI;AAAA,QACR,gCAAgC,GAAG;AAAA;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AACF","sourcesContent":["// This comment is used during ESM build:\n//! import {createRequire} from 'module'; const require = createRequire(import.meta.url);\n\ntype Api = 'storefront' | 'customer-account';\ntype Options<T extends boolean> = {throwIfMissing?: T};\n\n/**\n * Resolves a schema path for the provided API type. Only the API types currently\n * bundled in Hydrogen are allowed: \"storefront\" and \"customer\".\n * @param api\n * @returns\n */\nexport function getSchema(api: Api, options?: Options<true>): string;\nexport function getSchema(\n api: Api,\n options: Options<false>,\n): string | undefined;\nexport function getSchema(api: Api, options?: Options<boolean>) {\n if (api !== 'storefront' && api !== 'customer-account') {\n throw new Error(\n `The provided API type \"${api}\" is unknown. Please use \"storefront\" or \"customer-account\".`,\n );\n }\n\n try {\n return require.resolve(`@shopify/hydrogen/${api}.schema.json`);\n } catch {\n if (options?.throwIfMissing !== false) {\n throw new Error(\n `Could not find a schema for \"${api}\".\\nPlease make sure a recent version of \\`@shopify/hydrogen\\` is installed.`,\n );\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "@shopify:registry": "https://registry.npmjs.org"
6
6
  },
7
- "version": "0.3.0",
7
+ "version": "0.3.2",
8
8
  "license": "MIT",
9
9
  "type": "module",
10
10
  "main": "dist/cjs/index.cjs",
@@ -39,10 +39,10 @@
39
39
  "@graphql-codegen/cli": "^5.0.1",
40
40
  "@graphql-codegen/plugin-helpers": "^5.0.2",
41
41
  "dts-bundle-generator": "^9.3.1",
42
- "type-fest": "^4.5.0",
42
+ "type-fest": "^4.26.1",
43
43
  "vitest": "^1.0.4"
44
44
  },
45
45
  "dependencies": {
46
- "@shopify/graphql-codegen": "^0.0.1"
46
+ "@shopify/graphql-codegen": "^0.0.2"
47
47
  }
48
48
  }