@pintahub/shopify-next 0.9.0 → 0.10.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.
@@ -0,0 +1,12 @@
1
+ import type { AdminApiClient } from '@shopify/admin-api-client';
2
+ import { Command } from '../../client/Command';
3
+ export interface DeleteFileInput {
4
+ /** The file gid to delete. */
5
+ id: string;
6
+ }
7
+ export interface DeleteFileOutput {
8
+ ids: string[];
9
+ }
10
+ export declare class DeleteFileCommand extends Command<DeleteFileInput, DeleteFileOutput> {
11
+ execute(client: AdminApiClient): Promise<DeleteFileOutput>;
12
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeleteFileCommand = void 0;
4
+ const Command_1 = require("../../client/Command");
5
+ const handleErrors_1 = require("../../utils/handleErrors");
6
+ const MUTATION = /* GraphQL */ `
7
+ mutation DeleteFile($fileIds: [ID!]!) {
8
+ fileDelete(fileIds: $fileIds) {
9
+ deletedFileIds
10
+ userErrors {
11
+ code
12
+ field
13
+ message
14
+ }
15
+ }
16
+ }
17
+ `;
18
+ class DeleteFileCommand extends Command_1.Command {
19
+ async execute(client) {
20
+ const variables = { fileIds: [this.input.id] };
21
+ const { data, errors } = await client.request(MUTATION, { variables });
22
+ (0, handleErrors_1.handleErrors)(errors);
23
+ if (!data)
24
+ throw new Error('DeleteFileCommand: no data returned');
25
+ const { deletedFileIds, userErrors } = data.fileDelete;
26
+ (0, handleErrors_1.assertNoUserErrors)(userErrors, 'DeleteFileCommand');
27
+ return { ids: deletedFileIds ?? [] };
28
+ }
29
+ }
30
+ exports.DeleteFileCommand = DeleteFileCommand;
31
+ //# sourceMappingURL=DeleteFileCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeleteFileCommand.js","sourceRoot":"","sources":["../../../src/commands/files/DeleteFileCommand.ts"],"names":[],"mappings":";;;AACA,kDAA4C;AAC5C,2DAAyF;AAEzF,MAAM,QAAQ,GAAG,aAAa,CAAC;;;;;;;;;;;CAW9B,CAAA;AAkBD,MAAa,iBAAkB,SAAQ,iBAA0C;IAC/E,KAAK,CAAC,OAAO,CAAC,MAAsB;QAClC,MAAM,SAAS,GAAG,EAAC,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAC,CAAA;QAE5C,MAAM,EAAC,IAAI,EAAE,MAAM,EAAC,GAAG,MAAM,MAAM,CAAC,OAAO,CAAmB,QAAQ,EAAE,EAAC,SAAS,EAAC,CAAC,CAAA;QACpF,IAAA,2BAAY,EAAC,MAAM,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QAEjE,MAAM,EAAC,cAAc,EAAE,UAAU,EAAC,GAAG,IAAI,CAAC,UAAU,CAAA;QACpD,IAAA,iCAAkB,EAAC,UAAU,EAAE,mBAAmB,CAAC,CAAA;QAEnD,OAAO,EAAC,GAAG,EAAE,cAAc,IAAI,EAAE,EAAC,CAAA;IACpC,CAAC;CACF;AAbD,8CAaC","sourcesContent":["import type {AdminApiClient} from '@shopify/admin-api-client'\nimport {Command} from '../../client/Command'\nimport {handleErrors, assertNoUserErrors, type UserError} from '../../utils/handleErrors'\n\nconst MUTATION = /* GraphQL */ `\n mutation DeleteFile($fileIds: [ID!]!) {\n fileDelete(fileIds: $fileIds) {\n deletedFileIds\n userErrors {\n code\n field\n message\n }\n }\n }\n`\n\nexport interface DeleteFileInput {\n /** The file gid to delete. */\n id: string\n}\n\nexport interface DeleteFileOutput {\n ids: string[]\n}\n\ninterface MutationResponse {\n fileDelete: {\n deletedFileIds: string[] | null\n userErrors: UserError[]\n }\n}\n\nexport class DeleteFileCommand extends Command<DeleteFileInput, DeleteFileOutput> {\n async execute(client: AdminApiClient): Promise<DeleteFileOutput> {\n const variables = {fileIds: [this.input.id]}\n\n const {data, errors} = await client.request<MutationResponse>(MUTATION, {variables})\n handleErrors(errors)\n if (!data) throw new Error('DeleteFileCommand: no data returned')\n\n const {deletedFileIds, userErrors} = data.fileDelete\n assertNoUserErrors(userErrors, 'DeleteFileCommand')\n\n return {ids: deletedFileIds ?? []}\n }\n}\n"]}
@@ -0,0 +1,30 @@
1
+ import type { AdminApiClient } from '@shopify/admin-api-client';
2
+ import { Command } from '../../client/Command';
3
+ export interface GetImageInput {
4
+ id: string;
5
+ }
6
+ export interface ImageDetail {
7
+ altText: string | null;
8
+ height: number | null;
9
+ url: string;
10
+ width: number | null;
11
+ }
12
+ export interface GetImageOutput {
13
+ id: string;
14
+ mimeType: string | null;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ image: ImageDetail | null;
18
+ originalSource: {
19
+ fileSize: number | null;
20
+ url: string | null;
21
+ } | null;
22
+ }
23
+ /** Sentinel returned when the node is missing or is not a MediaImage. */
24
+ export interface ImageNotFound {
25
+ status: 'not_found';
26
+ }
27
+ export type GetImageResult = GetImageOutput | ImageNotFound;
28
+ export declare class GetImageCommand extends Command<GetImageInput, GetImageResult> {
29
+ execute(client: AdminApiClient): Promise<GetImageResult>;
30
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetImageCommand = void 0;
4
+ const Command_1 = require("../../client/Command");
5
+ const handleErrors_1 = require("../../utils/handleErrors");
6
+ const globalId_1 = require("../../utils/globalId");
7
+ const QUERY = /* GraphQL */ `
8
+ query GetImage($id: ID!) {
9
+ node(id: $id) {
10
+ id
11
+ __typename
12
+ ... on MediaImage {
13
+ id
14
+ mimeType
15
+ createdAt
16
+ updatedAt
17
+ image {
18
+ altText
19
+ height
20
+ url
21
+ width
22
+ }
23
+ originalSource {
24
+ fileSize
25
+ url
26
+ }
27
+ }
28
+ }
29
+ }
30
+ `;
31
+ class GetImageCommand extends Command_1.Command {
32
+ async execute(client) {
33
+ const variables = { id: (0, globalId_1.getGlobalID)(this.input.id, 'MediaImage') };
34
+ const { data, errors } = await client.request(QUERY, { variables });
35
+ (0, handleErrors_1.handleErrors)(errors);
36
+ if (!data)
37
+ throw new Error('GetImageCommand: no data returned');
38
+ // node is null when the id doesn't resolve, or a different type when the id isn't an image.
39
+ if (!data.node || data.node.__typename !== 'MediaImage') {
40
+ return { status: 'not_found' };
41
+ }
42
+ return data.node;
43
+ }
44
+ }
45
+ exports.GetImageCommand = GetImageCommand;
46
+ //# sourceMappingURL=GetImageCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetImageCommand.js","sourceRoot":"","sources":["../../../src/commands/files/GetImageCommand.ts"],"names":[],"mappings":";;;AACA,kDAA4C;AAC5C,2DAAqD;AACrD,mDAAgD;AAEhD,MAAM,KAAK,GAAG,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;CAuB3B,CAAA;AAiCD,MAAa,eAAgB,SAAQ,iBAAsC;IACzE,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;QAEhE,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,mCAAmC,CAAC,CAAA;QAE/D,4FAA4F;QAC5F,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,KAAK,YAAY,EAAE,CAAC;YACxD,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;CACF;AAfD,0CAeC","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 GetImage($id: ID!) {\n node(id: $id) {\n id\n __typename\n ... on MediaImage {\n id\n mimeType\n createdAt\n updatedAt\n image {\n altText\n height\n url\n width\n }\n originalSource {\n fileSize\n url\n }\n }\n }\n }\n`\n\nexport interface GetImageInput {\n id: string\n}\n\nexport interface ImageDetail {\n altText: string | null\n height: number | null\n url: string\n width: number | null\n}\n\nexport interface GetImageOutput {\n id: string\n mimeType: string | null\n createdAt: string\n updatedAt: string\n image: ImageDetail | null\n originalSource: {fileSize: number | null; url: string | null} | null\n}\n\n/** Sentinel returned when the node is missing or is not a MediaImage. */\nexport interface ImageNotFound {\n status: 'not_found'\n}\n\nexport type GetImageResult = GetImageOutput | ImageNotFound\n\ninterface QueryResponse {\n node: (GetImageOutput & {__typename: string}) | null\n}\n\nexport class GetImageCommand extends Command<GetImageInput, GetImageResult> {\n async execute(client: AdminApiClient): Promise<GetImageResult> {\n const variables = {id: getGlobalID(this.input.id, 'MediaImage')}\n\n const {data, errors} = await client.request<QueryResponse>(QUERY, {variables})\n handleErrors(errors)\n if (!data) throw new Error('GetImageCommand: no data returned')\n\n // node is null when the id doesn't resolve, or a different type when the id isn't an image.\n if (!data.node || data.node.__typename !== 'MediaImage') {\n return {status: 'not_found'}\n }\n\n return data.node\n }\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import type { AdminApiClient } from '@shopify/admin-api-client';
2
+ import { Command } from '../../client/Command';
3
+ export interface GetVideoInput {
4
+ id: string;
5
+ }
6
+ export interface VideoSource {
7
+ url: string;
8
+ fileSize: number | null;
9
+ format: string;
10
+ height: number;
11
+ width: number;
12
+ mimeType: string;
13
+ }
14
+ export interface GetVideoOutput {
15
+ id: string;
16
+ filename: string;
17
+ /** Enum: UPLOADED | PROCESSING | READY | FAILED */
18
+ fileStatus: string;
19
+ alt: string | null;
20
+ createdAt: string;
21
+ /** Milliseconds; null until status is READY. */
22
+ duration: number | null;
23
+ mediaContentType: string;
24
+ /** Enum: UPLOADED | PROCESSING | READY | FAILED */
25
+ status: string;
26
+ updatedAt: string;
27
+ /** Null until status is READY. */
28
+ originalSource: VideoSource | null;
29
+ }
30
+ /** Sentinel returned when the node is missing or is not a Video. */
31
+ export interface VideoNotFound {
32
+ status: 'not_found';
33
+ }
34
+ export type GetVideoResult = GetVideoOutput | VideoNotFound;
35
+ export declare class GetVideoCommand extends Command<GetVideoInput, GetVideoResult> {
36
+ execute(client: AdminApiClient): Promise<GetVideoResult>;
37
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetVideoCommand = void 0;
4
+ const Command_1 = require("../../client/Command");
5
+ const handleErrors_1 = require("../../utils/handleErrors");
6
+ const globalId_1 = require("../../utils/globalId");
7
+ const QUERY = /* GraphQL */ `
8
+ query GetVideo($id: ID!) {
9
+ node(id: $id) {
10
+ id
11
+ __typename
12
+ ... on Video {
13
+ id
14
+ filename
15
+ fileStatus
16
+ alt
17
+ createdAt
18
+ duration
19
+ mediaContentType
20
+ status
21
+ updatedAt
22
+ originalSource {
23
+ url
24
+ fileSize
25
+ format
26
+ height
27
+ width
28
+ mimeType
29
+ }
30
+ }
31
+ }
32
+ }
33
+ `;
34
+ class GetVideoCommand extends Command_1.Command {
35
+ async execute(client) {
36
+ const variables = { id: (0, globalId_1.getGlobalID)(this.input.id, 'Video') };
37
+ const { data, errors } = await client.request(QUERY, { variables });
38
+ (0, handleErrors_1.handleErrors)(errors);
39
+ if (!data)
40
+ throw new Error('GetVideoCommand: no data returned');
41
+ if (!data.node || data.node.__typename !== 'Video') {
42
+ return { status: 'not_found' };
43
+ }
44
+ return data.node;
45
+ }
46
+ }
47
+ exports.GetVideoCommand = GetVideoCommand;
48
+ //# sourceMappingURL=GetVideoCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetVideoCommand.js","sourceRoot":"","sources":["../../../src/commands/files/GetVideoCommand.ts"],"names":[],"mappings":";;;AACA,kDAA4C;AAC5C,2DAAqD;AACrD,mDAAgD;AAEhD,MAAM,KAAK,GAAG,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B3B,CAAA;AA2CD,MAAa,eAAgB,SAAQ,iBAAsC;IACzE,KAAK,CAAC,OAAO,CAAC,MAAsB;QAClC,MAAM,SAAS,GAAG,EAAC,EAAE,EAAE,IAAA,sBAAW,EAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,EAAC,CAAA;QAE3D,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,mCAAmC,CAAC,CAAA;QAE/D,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,KAAK,OAAO,EAAE,CAAC;YACnD,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;CACF;AAdD,0CAcC","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 GetVideo($id: ID!) {\n node(id: $id) {\n id\n __typename\n ... on Video {\n id\n filename\n fileStatus\n alt\n createdAt\n duration\n mediaContentType\n status\n updatedAt\n originalSource {\n url\n fileSize\n format\n height\n width\n mimeType\n }\n }\n }\n }\n`\n\nexport interface GetVideoInput {\n id: string\n}\n\nexport interface VideoSource {\n url: string\n fileSize: number | null\n format: string\n height: number\n width: number\n mimeType: string\n}\n\nexport interface GetVideoOutput {\n id: string\n filename: string\n /** Enum: UPLOADED | PROCESSING | READY | FAILED */\n fileStatus: string\n alt: string | null\n createdAt: string\n /** Milliseconds; null until status is READY. */\n duration: number | null\n mediaContentType: string\n /** Enum: UPLOADED | PROCESSING | READY | FAILED */\n status: string\n updatedAt: string\n /** Null until status is READY. */\n originalSource: VideoSource | null\n}\n\n/** Sentinel returned when the node is missing or is not a Video. */\nexport interface VideoNotFound {\n status: 'not_found'\n}\n\nexport type GetVideoResult = GetVideoOutput | VideoNotFound\n\ninterface QueryResponse {\n node: (GetVideoOutput & {__typename: string}) | null\n}\n\nexport class GetVideoCommand extends Command<GetVideoInput, GetVideoResult> {\n async execute(client: AdminApiClient): Promise<GetVideoResult> {\n const variables = {id: getGlobalID(this.input.id, 'Video')}\n\n const {data, errors} = await client.request<QueryResponse>(QUERY, {variables})\n handleErrors(errors)\n if (!data) throw new Error('GetVideoCommand: no data returned')\n\n if (!data.node || data.node.__typename !== 'Video') {\n return {status: 'not_found'}\n }\n\n return data.node\n }\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import type { AdminApiClient } from '@shopify/admin-api-client';
2
+ import { Command } from '../../client/Command';
3
+ export interface SearchImagesInput {
4
+ /** Max images per page. Defaults to 10. */
5
+ first?: number;
6
+ after?: string;
7
+ }
8
+ export interface ImageNode {
9
+ id: string;
10
+ }
11
+ export interface SearchImagesOutput {
12
+ items: ImageNode[];
13
+ pageInfo: {
14
+ hasNextPage: boolean;
15
+ endCursor: string | null;
16
+ };
17
+ }
18
+ export declare class SearchImagesCommand extends Command<SearchImagesInput, SearchImagesOutput> {
19
+ execute(client: AdminApiClient): Promise<SearchImagesOutput>;
20
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SearchImagesCommand = void 0;
4
+ const Command_1 = require("../../client/Command");
5
+ const handleErrors_1 = require("../../utils/handleErrors");
6
+ // Pre-filtered to images, newest-updated first — mirrors the legacy SearchImages.
7
+ const QUERY = /* GraphQL */ `
8
+ query SearchImages($first: Int!, $after: String) {
9
+ files(
10
+ query: "media_type:IMAGE"
11
+ first: $first
12
+ after: $after
13
+ sortKey: UPDATED_AT
14
+ reverse: true
15
+ ) {
16
+ nodes {
17
+ id
18
+ }
19
+ pageInfo {
20
+ hasNextPage
21
+ endCursor
22
+ }
23
+ }
24
+ }
25
+ `;
26
+ class SearchImagesCommand extends Command_1.Command {
27
+ async execute(client) {
28
+ const variables = {
29
+ first: this.input?.first ?? 10,
30
+ after: this.input?.after,
31
+ };
32
+ const { data, errors } = await client.request(QUERY, { variables });
33
+ (0, handleErrors_1.handleErrors)(errors);
34
+ if (!data)
35
+ throw new Error('SearchImagesCommand: no data returned');
36
+ return { items: data.files.nodes, pageInfo: data.files.pageInfo };
37
+ }
38
+ }
39
+ exports.SearchImagesCommand = SearchImagesCommand;
40
+ //# sourceMappingURL=SearchImagesCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SearchImagesCommand.js","sourceRoot":"","sources":["../../../src/commands/files/SearchImagesCommand.ts"],"names":[],"mappings":";;;AACA,kDAA4C;AAC5C,2DAAqD;AAErD,kFAAkF;AAClF,MAAM,KAAK,GAAG,aAAa,CAAC;;;;;;;;;;;;;;;;;;CAkB3B,CAAA;AA2BD,MAAa,mBAAoB,SAAQ,iBAA8C;IACrF,KAAK,CAAC,OAAO,CAAC,MAAsB;QAClC,MAAM,SAAS,GAAG;YAChB,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;YAC9B,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK;SACzB,CAAA;QAED,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,uCAAuC,CAAC,CAAA;QAEnE,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAC,CAAA;IACjE,CAAC;CACF;AAbD,kDAaC","sourcesContent":["import type {AdminApiClient} from '@shopify/admin-api-client'\nimport {Command} from '../../client/Command'\nimport {handleErrors} from '../../utils/handleErrors'\n\n// Pre-filtered to images, newest-updated first — mirrors the legacy SearchImages.\nconst QUERY = /* GraphQL */ `\n query SearchImages($first: Int!, $after: String) {\n files(\n query: \"media_type:IMAGE\"\n first: $first\n after: $after\n sortKey: UPDATED_AT\n reverse: true\n ) {\n nodes {\n id\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n`\n\nexport interface SearchImagesInput {\n /** Max images per page. Defaults to 10. */\n first?: number\n after?: string\n}\n\nexport interface ImageNode {\n id: string\n}\n\nexport interface SearchImagesOutput {\n items: ImageNode[]\n pageInfo: {\n hasNextPage: boolean\n endCursor: string | null\n }\n}\n\ninterface QueryResponse {\n files: {\n nodes: ImageNode[]\n pageInfo: SearchImagesOutput['pageInfo']\n }\n}\n\nexport class SearchImagesCommand extends Command<SearchImagesInput, SearchImagesOutput> {\n async execute(client: AdminApiClient): Promise<SearchImagesOutput> {\n const variables = {\n first: this.input?.first ?? 10,\n after: this.input?.after,\n }\n\n const {data, errors} = await client.request<QueryResponse>(QUERY, {variables})\n handleErrors(errors)\n if (!data) throw new Error('SearchImagesCommand: no data returned')\n\n return {items: data.files.nodes, pageInfo: data.files.pageInfo}\n }\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import type { AdminApiClient } from '@shopify/admin-api-client';
2
+ import { Command } from '../../client/Command';
3
+ export interface UpdateFileInput {
4
+ id: string;
5
+ alt?: string;
6
+ originalSource?: string;
7
+ previewImageSource?: string;
8
+ filename?: string;
9
+ /** Product gids to attach. */
10
+ referencesToAdd?: string[];
11
+ /** Product gids to detach. */
12
+ referencesToRemove?: string[];
13
+ }
14
+ export interface UpdateFileOutput {
15
+ id: string;
16
+ alt: string | null;
17
+ createdAt: string;
18
+ }
19
+ export declare class UpdateFileCommand extends Command<UpdateFileInput, UpdateFileOutput> {
20
+ execute(client: AdminApiClient): Promise<UpdateFileOutput>;
21
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateFileCommand = void 0;
4
+ const Command_1 = require("../../client/Command");
5
+ const handleErrors_1 = require("../../utils/handleErrors");
6
+ const MUTATION = /* GraphQL */ `
7
+ mutation UpdateFile($files: [FileUpdateInput!]!) {
8
+ fileUpdate(files: $files) {
9
+ files {
10
+ id
11
+ alt
12
+ createdAt
13
+ }
14
+ userErrors {
15
+ code
16
+ field
17
+ message
18
+ }
19
+ }
20
+ }
21
+ `;
22
+ class UpdateFileCommand extends Command_1.Command {
23
+ async execute(client) {
24
+ const variables = { files: [this.input] };
25
+ const { data, errors } = await client.request(MUTATION, { variables });
26
+ (0, handleErrors_1.handleErrors)(errors);
27
+ if (!data)
28
+ throw new Error('UpdateFileCommand: no data returned');
29
+ const { files, userErrors } = data.fileUpdate;
30
+ (0, handleErrors_1.assertNoUserErrors)(userErrors, 'UpdateFileCommand');
31
+ const file = files?.[0];
32
+ if (!file)
33
+ throw new Error('UpdateFileCommand: no file returned');
34
+ return file;
35
+ }
36
+ }
37
+ exports.UpdateFileCommand = UpdateFileCommand;
38
+ //# sourceMappingURL=UpdateFileCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UpdateFileCommand.js","sourceRoot":"","sources":["../../../src/commands/files/UpdateFileCommand.ts"],"names":[],"mappings":";;;AACA,kDAA4C;AAC5C,2DAAyF;AAEzF,MAAM,QAAQ,GAAG,aAAa,CAAC;;;;;;;;;;;;;;;CAe9B,CAAA;AA4BD,MAAa,iBAAkB,SAAQ,iBAA0C;IAC/E,KAAK,CAAC,OAAO,CAAC,MAAsB;QAClC,MAAM,SAAS,GAAG,EAAC,KAAK,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAC,CAAA;QAEvC,MAAM,EAAC,IAAI,EAAE,MAAM,EAAC,GAAG,MAAM,MAAM,CAAC,OAAO,CAAmB,QAAQ,EAAE,EAAC,SAAS,EAAC,CAAC,CAAA;QACpF,IAAA,2BAAY,EAAC,MAAM,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QAEjE,MAAM,EAAC,KAAK,EAAE,UAAU,EAAC,GAAG,IAAI,CAAC,UAAU,CAAA;QAC3C,IAAA,iCAAkB,EAAC,UAAU,EAAE,mBAAmB,CAAC,CAAA;QAEnD,MAAM,IAAI,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QAEjE,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAhBD,8CAgBC","sourcesContent":["import type {AdminApiClient} from '@shopify/admin-api-client'\nimport {Command} from '../../client/Command'\nimport {handleErrors, assertNoUserErrors, type UserError} from '../../utils/handleErrors'\n\nconst MUTATION = /* GraphQL */ `\n mutation UpdateFile($files: [FileUpdateInput!]!) {\n fileUpdate(files: $files) {\n files {\n id\n alt\n createdAt\n }\n userErrors {\n code\n field\n message\n }\n }\n }\n`\n\n// Mirrors Shopify's FileUpdateInput. `id` is the file gid (MediaImage / Video / GenericFile).\nexport interface UpdateFileInput {\n id: string\n alt?: string\n originalSource?: string\n previewImageSource?: string\n filename?: string\n /** Product gids to attach. */\n referencesToAdd?: string[]\n /** Product gids to detach. */\n referencesToRemove?: string[]\n}\n\nexport interface UpdateFileOutput {\n id: string\n alt: string | null\n createdAt: string\n}\n\ninterface MutationResponse {\n fileUpdate: {\n files: UpdateFileOutput[] | null\n userErrors: UserError[]\n }\n}\n\nexport class UpdateFileCommand extends Command<UpdateFileInput, UpdateFileOutput> {\n async execute(client: AdminApiClient): Promise<UpdateFileOutput> {\n const variables = {files: [this.input]}\n\n const {data, errors} = await client.request<MutationResponse>(MUTATION, {variables})\n handleErrors(errors)\n if (!data) throw new Error('UpdateFileCommand: no data returned')\n\n const {files, userErrors} = data.fileUpdate\n assertNoUserErrors(userErrors, 'UpdateFileCommand')\n\n const file = files?.[0]\n if (!file) throw new Error('UpdateFileCommand: no file returned')\n\n return file\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export * from './SearchImagesCommand';
2
+ export * from './GetImageCommand';
3
+ export * from './GetVideoCommand';
4
+ export * from './UpdateFileCommand';
5
+ export * from './DeleteFileCommand';
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./SearchImagesCommand"), exports);
18
+ __exportStar(require("./GetImageCommand"), exports);
19
+ __exportStar(require("./GetVideoCommand"), exports);
20
+ __exportStar(require("./UpdateFileCommand"), exports);
21
+ __exportStar(require("./DeleteFileCommand"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/files/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAqC;AACrC,oDAAiC;AACjC,oDAAiC;AACjC,sDAAmC;AACnC,sDAAmC","sourcesContent":["export * from './SearchImagesCommand'\nexport * from './GetImageCommand'\nexport * from './GetVideoCommand'\nexport * from './UpdateFileCommand'\nexport * from './DeleteFileCommand'\n"]}
package/dist/index.d.ts CHANGED
@@ -10,3 +10,4 @@ export * from './commands/metaobjects';
10
10
  export * from './commands/orders';
11
11
  export * from './commands/collections';
12
12
  export * from './commands/fulfillments';
13
+ export * from './commands/files';
package/dist/index.js CHANGED
@@ -33,4 +33,5 @@ __exportStar(require("./commands/metaobjects"), exports);
33
33
  __exportStar(require("./commands/orders"), exports);
34
34
  __exportStar(require("./commands/collections"), exports);
35
35
  __exportStar(require("./commands/fulfillments"), exports);
36
+ __exportStar(require("./commands/files"), exports);
36
37
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wDAK+B;AAJ7B,8GAAA,aAAa,OAAA;AAKf,4CAAwC;AAAhC,kGAAA,OAAO,OAAA;AACf,qDAM6B;AAL3B,4GAAA,YAAY,OAAA;AACZ,kHAAA,kBAAkB,OAAA;AAKpB,6CAAmE;AAA3D,uGAAA,WAAW,OAAA;AAAE,iHAAA,qBAAqB,OAAA;AAG1C,gCAAgC;AAChC,uDAAoC;AACpC,sDAAmC;AACnC,mDAAgC;AAChC,yDAAsC;AACtC,oDAAiC;AACjC,yDAAsC;AACtC,0DAAuC","sourcesContent":["export {\n ShopifyClient,\n type ShopifyClientOptions,\n type StoreId,\n type Middleware,\n} from './client/ShopifyClient'\nexport {Command} from './client/Command'\nexport {\n handleErrors,\n assertNoUserErrors,\n type GraphQLError,\n type ResponseErrors,\n type UserError,\n} from './utils/handleErrors'\nexport {getGlobalID, extractIdFromGlobalID} from './utils/globalId'\nexport type {MoneyV2} from './utils/money'\n\n// Commands grouped by namespace\nexport * from './commands/customers'\nexport * from './commands/payments'\nexport * from './commands/menus'\nexport * from './commands/metaobjects'\nexport * from './commands/orders'\nexport * from './commands/collections'\nexport * from './commands/fulfillments'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wDAK+B;AAJ7B,8GAAA,aAAa,OAAA;AAKf,4CAAwC;AAAhC,kGAAA,OAAO,OAAA;AACf,qDAM6B;AAL3B,4GAAA,YAAY,OAAA;AACZ,kHAAA,kBAAkB,OAAA;AAKpB,6CAAmE;AAA3D,uGAAA,WAAW,OAAA;AAAE,iHAAA,qBAAqB,OAAA;AAG1C,gCAAgC;AAChC,uDAAoC;AACpC,sDAAmC;AACnC,mDAAgC;AAChC,yDAAsC;AACtC,oDAAiC;AACjC,yDAAsC;AACtC,0DAAuC;AACvC,mDAAgC","sourcesContent":["export {\n ShopifyClient,\n type ShopifyClientOptions,\n type StoreId,\n type Middleware,\n} from './client/ShopifyClient'\nexport {Command} from './client/Command'\nexport {\n handleErrors,\n assertNoUserErrors,\n type GraphQLError,\n type ResponseErrors,\n type UserError,\n} from './utils/handleErrors'\nexport {getGlobalID, extractIdFromGlobalID} from './utils/globalId'\nexport type {MoneyV2} from './utils/money'\n\n// Commands grouped by namespace\nexport * from './commands/customers'\nexport * from './commands/payments'\nexport * from './commands/menus'\nexport * from './commands/metaobjects'\nexport * from './commands/orders'\nexport * from './commands/collections'\nexport * from './commands/fulfillments'\nexport * from './commands/files'\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-next",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
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",