@pintahub/shopify-next 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,6 +28,11 @@ export interface GetCollectionOutput {
28
28
  } | null;
29
29
  image: CollectionImage | null;
30
30
  }
31
- export declare class GetCollectionCommand extends Command<GetCollectionInput, GetCollectionOutput | null> {
32
- execute(client: AdminApiClient): Promise<GetCollectionOutput | null>;
31
+ /** Sentinel returned when the collection no longer exists (deleted on Shopify). */
32
+ export interface CollectionNotFound {
33
+ status: 'not_found';
34
+ }
35
+ export type GetCollectionResult = GetCollectionOutput | CollectionNotFound;
36
+ export declare class GetCollectionCommand extends Command<GetCollectionInput, GetCollectionResult> {
37
+ execute(client: AdminApiClient): Promise<GetCollectionResult>;
33
38
  }
@@ -38,6 +38,9 @@ class GetCollectionCommand extends Command_1.Command {
38
38
  (0, handleErrors_1.handleErrors)(errors);
39
39
  if (!data)
40
40
  throw new Error('GetCollectionCommand: no data returned');
41
+ if (data.collection === null) {
42
+ return { status: 'not_found' };
43
+ }
41
44
  return data.collection;
42
45
  }
43
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"GetCollectionCommand.js","sourceRoot":"","sources":["../../../src/commands/collections/GetCollectionCommand.ts"],"names":[],"mappings":";;;AACA,kDAA4C;AAC5C,2DAAqD;AACrD,mDAAgD;AAEhD,MAAM,KAAK,GAAG,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B3B,CAAA;AAmCD,MAAa,oBAAqB,SAAQ,iBAGzC;IACC,KAAK,CAAC,OAAO,CAAC,MAAsB;QAClC,MAAM,SAAS,GAAG,EAAC,EAAE,EAAE,IAAA,sBAAW,EAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,YAAY,CAAC,EAAC,CAAA;QAChE,MAAM,EAAC,IAAI,EAAE,MAAM,EAAC,GAAG,MAAM,MAAM,CAAC,OAAO,CAAgB,KAAK,EAAE,EAAC,SAAS,EAAC,CAAC,CAAA;QAC9E,IAAA,2BAAY,EAAC,MAAM,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAA;QAEpE,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;CACF;AAZD,oDAYC","sourcesContent":["import type {AdminApiClient} from '@shopify/admin-api-client'\nimport {Command} from '../../client/Command'\nimport {handleErrors} from '../../utils/handleErrors'\nimport {getGlobalID} from '../../utils/globalId'\n\nconst QUERY = /* GraphQL */ `\n query GetCollection($id: ID!) {\n collection(id: $id) {\n id\n handle\n title\n updatedAt\n description\n descriptionHtml\n seo {\n title\n description\n }\n productsCount {\n count\n precision\n }\n image {\n id\n url\n altText\n height\n width\n }\n }\n }\n`\n\nexport interface GetCollectionInput {\n id: string\n}\n\nexport interface CollectionImage {\n id: string | null\n url: string\n altText: string | null\n height: number | null\n width: number | null\n}\n\nexport interface CollectionSEO {\n title: string | null\n description: string | null\n}\n\nexport interface GetCollectionOutput {\n id: string\n handle: string\n title: string\n updatedAt: string\n description: string\n descriptionHtml: string\n seo: CollectionSEO\n productsCount: {count: number; precision: string} | null\n image: CollectionImage | null\n}\n\ninterface QueryResponse {\n collection: GetCollectionOutput | null\n}\n\nexport class GetCollectionCommand extends Command<\n GetCollectionInput,\n GetCollectionOutput | null\n> {\n async execute(client: AdminApiClient): Promise<GetCollectionOutput | null> {\n const variables = {id: getGlobalID(this.input.id, 'Collection')}\n const {data, errors} = await client.request<QueryResponse>(QUERY, {variables})\n handleErrors(errors)\n if (!data) throw new Error('GetCollectionCommand: no data returned')\n\n return data.collection\n }\n}\n"]}
1
+ {"version":3,"file":"GetCollectionCommand.js","sourceRoot":"","sources":["../../../src/commands/collections/GetCollectionCommand.ts"],"names":[],"mappings":";;;AACA,kDAA4C;AAC5C,2DAAqD;AACrD,mDAAgD;AAEhD,MAAM,KAAK,GAAG,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B3B,CAAA;AA0CD,MAAa,oBAAqB,SAAQ,iBAGzC;IACC,KAAK,CAAC,OAAO,CAAC,MAAsB;QAClC,MAAM,SAAS,GAAG,EAAC,EAAE,EAAE,IAAA,sBAAW,EAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,YAAY,CAAC,EAAC,CAAA;QAChE,MAAM,EAAC,IAAI,EAAE,MAAM,EAAC,GAAG,MAAM,MAAM,CAAC,OAAO,CAAgB,KAAK,EAAE,EAAC,SAAS,EAAC,CAAC,CAAA;QAC9E,IAAA,2BAAY,EAAC,MAAM,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAA;QAEpE,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;YAC7B,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;CACF;AAhBD,oDAgBC","sourcesContent":["import type {AdminApiClient} from '@shopify/admin-api-client'\nimport {Command} from '../../client/Command'\nimport {handleErrors} from '../../utils/handleErrors'\nimport {getGlobalID} from '../../utils/globalId'\n\nconst QUERY = /* GraphQL */ `\n query GetCollection($id: ID!) {\n collection(id: $id) {\n id\n handle\n title\n updatedAt\n description\n descriptionHtml\n seo {\n title\n description\n }\n productsCount {\n count\n precision\n }\n image {\n id\n url\n altText\n height\n width\n }\n }\n }\n`\n\nexport interface GetCollectionInput {\n id: string\n}\n\nexport interface CollectionImage {\n id: string | null\n url: string\n altText: string | null\n height: number | null\n width: number | null\n}\n\nexport interface CollectionSEO {\n title: string | null\n description: string | null\n}\n\nexport interface GetCollectionOutput {\n id: string\n handle: string\n title: string\n updatedAt: string\n description: string\n descriptionHtml: string\n seo: CollectionSEO\n productsCount: {count: number; precision: string} | null\n image: CollectionImage | null\n}\n\n/** Sentinel returned when the collection no longer exists (deleted on Shopify). */\nexport interface CollectionNotFound {\n status: 'not_found'\n}\n\nexport type GetCollectionResult = GetCollectionOutput | CollectionNotFound\n\ninterface QueryResponse {\n collection: GetCollectionOutput | null\n}\n\nexport class GetCollectionCommand extends Command<\n GetCollectionInput,\n GetCollectionResult\n> {\n async execute(client: AdminApiClient): Promise<GetCollectionResult> {\n const variables = {id: getGlobalID(this.input.id, 'Collection')}\n const {data, errors} = await client.request<QueryResponse>(QUERY, {variables})\n handleErrors(errors)\n if (!data) throw new Error('GetCollectionCommand: no data returned')\n\n if (data.collection === null) {\n return {status: 'not_found'}\n }\n\n return data.collection\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-next",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Shopify Admin GraphQL client for pintahub services via shopify-gateway",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",