@pintahub/shopify-next 0.8.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.
- package/dist/commands/files/DeleteFileCommand.d.ts +12 -0
- package/dist/commands/files/DeleteFileCommand.js +31 -0
- package/dist/commands/files/DeleteFileCommand.js.map +1 -0
- package/dist/commands/files/GetImageCommand.d.ts +30 -0
- package/dist/commands/files/GetImageCommand.js +46 -0
- package/dist/commands/files/GetImageCommand.js.map +1 -0
- package/dist/commands/files/GetVideoCommand.d.ts +37 -0
- package/dist/commands/files/GetVideoCommand.js +48 -0
- package/dist/commands/files/GetVideoCommand.js.map +1 -0
- package/dist/commands/files/SearchImagesCommand.d.ts +20 -0
- package/dist/commands/files/SearchImagesCommand.js +40 -0
- package/dist/commands/files/SearchImagesCommand.js.map +1 -0
- package/dist/commands/files/UpdateFileCommand.d.ts +21 -0
- package/dist/commands/files/UpdateFileCommand.js +38 -0
- package/dist/commands/files/UpdateFileCommand.js.map +1 -0
- package/dist/commands/files/index.d.ts +5 -0
- package/dist/commands/files/index.js +22 -0
- package/dist/commands/files/index.js.map +1 -0
- package/dist/commands/metaobjects/GetMetaobjectCommand.d.ts +30 -0
- package/dist/commands/metaobjects/GetMetaobjectCommand.js +41 -0
- package/dist/commands/metaobjects/GetMetaobjectCommand.js.map +1 -0
- package/dist/commands/metaobjects/ListBannersCommand.d.ts +36 -0
- package/dist/commands/metaobjects/ListBannersCommand.js +47 -0
- package/dist/commands/metaobjects/ListBannersCommand.js.map +1 -0
- package/dist/commands/metaobjects/ListFAQsCommand.d.ts +21 -0
- package/dist/commands/metaobjects/ListFAQsCommand.js +63 -0
- package/dist/commands/metaobjects/ListFAQsCommand.js.map +1 -0
- package/dist/commands/metaobjects/SearchMetaobjectsCommand.d.ts +27 -0
- package/dist/commands/metaobjects/SearchMetaobjectsCommand.js +54 -0
- package/dist/commands/metaobjects/SearchMetaobjectsCommand.js.map +1 -0
- package/dist/commands/metaobjects/index.d.ts +4 -0
- package/dist/commands/metaobjects/index.js +21 -0
- package/dist/commands/metaobjects/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/richText.d.ts +7 -0
- package/dist/utils/richText.js +95 -0
- package/dist/utils/richText.js.map +1 -0
- package/package.json +1 -1
|
@@ -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,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"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AdminApiClient } from '@shopify/admin-api-client';
|
|
2
|
+
import { Command } from '../../client/Command';
|
|
3
|
+
export interface GetMetaobjectInput {
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface MetaobjectField {
|
|
7
|
+
key: string;
|
|
8
|
+
type: string;
|
|
9
|
+
value: string | null;
|
|
10
|
+
}
|
|
11
|
+
export interface GetMetaobjectOutput {
|
|
12
|
+
id: string;
|
|
13
|
+
handle: string;
|
|
14
|
+
displayName: string;
|
|
15
|
+
type: string;
|
|
16
|
+
fields: MetaobjectField[];
|
|
17
|
+
capabilities: {
|
|
18
|
+
publishable: {
|
|
19
|
+
status: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** Sentinel returned when the metaobject no longer exists (deleted on Shopify). */
|
|
24
|
+
export interface MetaobjectNotFound {
|
|
25
|
+
status: 'not_found';
|
|
26
|
+
}
|
|
27
|
+
export type GetMetaobjectResult = GetMetaobjectOutput | MetaobjectNotFound;
|
|
28
|
+
export declare class GetMetaobjectCommand extends Command<GetMetaobjectInput, GetMetaobjectResult> {
|
|
29
|
+
execute(client: AdminApiClient): Promise<GetMetaobjectResult>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetMetaobjectCommand = 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 GetMetaobject($id: ID!) {
|
|
9
|
+
metaobject(id: $id) {
|
|
10
|
+
id
|
|
11
|
+
handle
|
|
12
|
+
displayName
|
|
13
|
+
type
|
|
14
|
+
fields {
|
|
15
|
+
key
|
|
16
|
+
type
|
|
17
|
+
value
|
|
18
|
+
}
|
|
19
|
+
capabilities {
|
|
20
|
+
publishable {
|
|
21
|
+
status
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
class GetMetaobjectCommand extends Command_1.Command {
|
|
28
|
+
async execute(client) {
|
|
29
|
+
const variables = { id: (0, globalId_1.getGlobalID)(this.input.id, 'Metaobject') };
|
|
30
|
+
const { data, errors } = await client.request(QUERY, { variables });
|
|
31
|
+
(0, handleErrors_1.handleErrors)(errors);
|
|
32
|
+
if (!data)
|
|
33
|
+
throw new Error('GetMetaobjectCommand: no data returned');
|
|
34
|
+
if (data.metaobject === null) {
|
|
35
|
+
return { status: 'not_found' };
|
|
36
|
+
}
|
|
37
|
+
return data.metaobject;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.GetMetaobjectCommand = GetMetaobjectCommand;
|
|
41
|
+
//# sourceMappingURL=GetMetaobjectCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetMetaobjectCommand.js","sourceRoot":"","sources":["../../../src/commands/metaobjects/GetMetaobjectCommand.ts"],"names":[],"mappings":";;;AACA,kDAA4C;AAC5C,2DAAqD;AACrD,mDAAgD;AAEhD,MAAM,KAAK,GAAG,aAAa,CAAC;;;;;;;;;;;;;;;;;;;CAmB3B,CAAA;AAkCD,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;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,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;AAjBD,oDAiBC","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 GetMetaobject($id: ID!) {\n metaobject(id: $id) {\n id\n handle\n displayName\n type\n fields {\n key\n type\n value\n }\n capabilities {\n publishable {\n status\n }\n }\n }\n }\n`\n\nexport interface GetMetaobjectInput {\n id: string\n}\n\nexport interface MetaobjectField {\n key: string\n type: string\n value: string | null\n}\n\nexport interface GetMetaobjectOutput {\n id: string\n handle: string\n displayName: string\n type: string\n fields: MetaobjectField[]\n capabilities: {\n publishable: {status: string}\n }\n}\n\n/** Sentinel returned when the metaobject no longer exists (deleted on Shopify). */\nexport interface MetaobjectNotFound {\n status: 'not_found'\n}\n\nexport type GetMetaobjectResult = GetMetaobjectOutput | MetaobjectNotFound\n\ninterface QueryResponse {\n metaobject: GetMetaobjectOutput | null\n}\n\nexport class GetMetaobjectCommand extends Command<\n GetMetaobjectInput,\n GetMetaobjectResult\n> {\n async execute(client: AdminApiClient): Promise<GetMetaobjectResult> {\n const variables = {id: getGlobalID(this.input.id, 'Metaobject')}\n\n const {data, errors} = await client.request<QueryResponse>(QUERY, {variables})\n handleErrors(errors)\n if (!data) throw new Error('GetMetaobjectCommand: no data returned')\n\n if (data.metaobject === null) {\n return {status: 'not_found'}\n }\n\n return data.metaobject\n }\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AdminApiClient } from '@shopify/admin-api-client';
|
|
2
|
+
import { Command } from '../../client/Command';
|
|
3
|
+
export interface BannerImage {
|
|
4
|
+
altText: string | null;
|
|
5
|
+
url: string;
|
|
6
|
+
width: number | null;
|
|
7
|
+
height: number | null;
|
|
8
|
+
}
|
|
9
|
+
export interface BannerField {
|
|
10
|
+
key: string;
|
|
11
|
+
value: string | null;
|
|
12
|
+
reference: {
|
|
13
|
+
image: BannerImage;
|
|
14
|
+
} | null;
|
|
15
|
+
}
|
|
16
|
+
export interface BannerNode {
|
|
17
|
+
id: string;
|
|
18
|
+
type: string;
|
|
19
|
+
handle: string;
|
|
20
|
+
fields: BannerField[];
|
|
21
|
+
capabilities: {
|
|
22
|
+
publishable: {
|
|
23
|
+
status: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface ListBannersInput {
|
|
28
|
+
/** Max banners to return. Defaults to 10. */
|
|
29
|
+
first?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface ListBannersOutput {
|
|
32
|
+
items: BannerNode[];
|
|
33
|
+
}
|
|
34
|
+
export declare class ListBannersCommand extends Command<ListBannersInput, ListBannersOutput> {
|
|
35
|
+
execute(client: AdminApiClient): Promise<ListBannersOutput>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListBannersCommand = void 0;
|
|
4
|
+
const Command_1 = require("../../client/Command");
|
|
5
|
+
const handleErrors_1 = require("../../utils/handleErrors");
|
|
6
|
+
const QUERY = /* GraphQL */ `
|
|
7
|
+
query ListBanners($first: Int!) {
|
|
8
|
+
metaobjects(type: "banner", first: $first) {
|
|
9
|
+
nodes {
|
|
10
|
+
id
|
|
11
|
+
type
|
|
12
|
+
handle
|
|
13
|
+
fields {
|
|
14
|
+
key
|
|
15
|
+
value
|
|
16
|
+
reference {
|
|
17
|
+
... on MediaImage {
|
|
18
|
+
image {
|
|
19
|
+
altText
|
|
20
|
+
url
|
|
21
|
+
width
|
|
22
|
+
height
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
capabilities {
|
|
28
|
+
publishable {
|
|
29
|
+
status
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
class ListBannersCommand extends Command_1.Command {
|
|
37
|
+
async execute(client) {
|
|
38
|
+
const variables = { first: this.input?.first ?? 10 };
|
|
39
|
+
const { data, errors } = await client.request(QUERY, { variables });
|
|
40
|
+
(0, handleErrors_1.handleErrors)(errors);
|
|
41
|
+
if (!data)
|
|
42
|
+
throw new Error('ListBannersCommand: no data returned');
|
|
43
|
+
return { items: data.metaobjects.nodes };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.ListBannersCommand = ListBannersCommand;
|
|
47
|
+
//# sourceMappingURL=ListBannersCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListBannersCommand.js","sourceRoot":"","sources":["../../../src/commands/metaobjects/ListBannersCommand.ts"],"names":[],"mappings":";;;AACA,kDAA4C;AAC5C,2DAAqD;AAErD,MAAM,KAAK,GAAG,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6B3B,CAAA;AAwCD,MAAa,kBAAmB,SAAQ,iBAA4C;IAClF,KAAK,CAAC,OAAO,CAAC,MAAsB;QAClC,MAAM,SAAS,GAAG,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE,EAAC,CAAA;QAElD,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,sCAAsC,CAAC,CAAA;QAElE,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,EAAC,CAAA;IACxC,CAAC;CACF;AAVD,gDAUC","sourcesContent":["import type {AdminApiClient} from '@shopify/admin-api-client'\nimport {Command} from '../../client/Command'\nimport {handleErrors} from '../../utils/handleErrors'\n\nconst QUERY = /* GraphQL */ `\n query ListBanners($first: Int!) {\n metaobjects(type: \"banner\", first: $first) {\n nodes {\n id\n type\n handle\n fields {\n key\n value\n reference {\n ... on MediaImage {\n image {\n altText\n url\n width\n height\n }\n }\n }\n }\n capabilities {\n publishable {\n status\n }\n }\n }\n }\n }\n`\n\nexport interface BannerImage {\n altText: string | null\n url: string\n width: number | null\n height: number | null\n}\n\nexport interface BannerField {\n key: string\n value: string | null\n reference: {image: BannerImage} | null\n}\n\nexport interface BannerNode {\n id: string\n type: string\n handle: string\n fields: BannerField[]\n capabilities: {\n publishable: {status: string}\n }\n}\n\nexport interface ListBannersInput {\n /** Max banners to return. Defaults to 10. */\n first?: number\n}\n\nexport interface ListBannersOutput {\n items: BannerNode[]\n}\n\ninterface QueryResponse {\n metaobjects: {\n nodes: BannerNode[]\n }\n}\n\nexport class ListBannersCommand extends Command<ListBannersInput, ListBannersOutput> {\n async execute(client: AdminApiClient): Promise<ListBannersOutput> {\n const variables = {first: this.input?.first ?? 10}\n\n const {data, errors} = await client.request<QueryResponse>(QUERY, {variables})\n handleErrors(errors)\n if (!data) throw new Error('ListBannersCommand: no data returned')\n\n return {items: data.metaobjects.nodes}\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 FAQItem {
|
|
4
|
+
id: string;
|
|
5
|
+
type: string;
|
|
6
|
+
handle: string;
|
|
7
|
+
updatedAt: string;
|
|
8
|
+
title: string;
|
|
9
|
+
/** HTML built from the `content` field (rich_text_field → HTML, single_line_text_field → <p>). */
|
|
10
|
+
body: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ListFAQsInput {
|
|
13
|
+
/** Max FAQs to return. Defaults to 100. */
|
|
14
|
+
first?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ListFAQsOutput {
|
|
17
|
+
items: FAQItem[];
|
|
18
|
+
}
|
|
19
|
+
export declare class ListFAQsCommand extends Command<ListFAQsInput, ListFAQsOutput> {
|
|
20
|
+
execute(client: AdminApiClient): Promise<ListFAQsOutput>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListFAQsCommand = void 0;
|
|
4
|
+
const Command_1 = require("../../client/Command");
|
|
5
|
+
const handleErrors_1 = require("../../utils/handleErrors");
|
|
6
|
+
const richText_1 = require("../../utils/richText");
|
|
7
|
+
const QUERY = /* GraphQL */ `
|
|
8
|
+
query ListFAQs($first: Int!) {
|
|
9
|
+
metaobjects(type: "faq", first: $first) {
|
|
10
|
+
nodes {
|
|
11
|
+
id
|
|
12
|
+
type
|
|
13
|
+
handle
|
|
14
|
+
updatedAt
|
|
15
|
+
fields {
|
|
16
|
+
key
|
|
17
|
+
value
|
|
18
|
+
type
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
// rich_text_field stores a JSON schema; single_line_text_field stores plain text.
|
|
25
|
+
function parseContentToHtml(content, type) {
|
|
26
|
+
if (type === 'single_line_text_field') {
|
|
27
|
+
return `<p>${content}</p>`;
|
|
28
|
+
}
|
|
29
|
+
if (type !== 'rich_text_field')
|
|
30
|
+
return content;
|
|
31
|
+
return `<div>${(0, richText_1.convertSchemaToHtml)(content)}</div>`;
|
|
32
|
+
}
|
|
33
|
+
function parseFAQ(node) {
|
|
34
|
+
const { fields, ...rest } = node;
|
|
35
|
+
if (!fields || !fields.length)
|
|
36
|
+
return null;
|
|
37
|
+
const byKey = fields.reduce((acc, field) => {
|
|
38
|
+
if (field.key)
|
|
39
|
+
acc[field.key] = field;
|
|
40
|
+
return acc;
|
|
41
|
+
}, {});
|
|
42
|
+
const title = byKey.title?.value;
|
|
43
|
+
if (!title)
|
|
44
|
+
return null;
|
|
45
|
+
const content = byKey.content;
|
|
46
|
+
const body = content?.value ? parseContentToHtml(content.value, content.type) : '';
|
|
47
|
+
return { ...rest, title, body };
|
|
48
|
+
}
|
|
49
|
+
class ListFAQsCommand extends Command_1.Command {
|
|
50
|
+
async execute(client) {
|
|
51
|
+
const variables = { first: this.input?.first ?? 100 };
|
|
52
|
+
const { data, errors } = await client.request(QUERY, { variables });
|
|
53
|
+
(0, handleErrors_1.handleErrors)(errors);
|
|
54
|
+
if (!data)
|
|
55
|
+
throw new Error('ListFAQsCommand: no data returned');
|
|
56
|
+
const items = data.metaobjects.nodes
|
|
57
|
+
.map(parseFAQ)
|
|
58
|
+
.filter((item) => item !== null);
|
|
59
|
+
return { items };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.ListFAQsCommand = ListFAQsCommand;
|
|
63
|
+
//# sourceMappingURL=ListFAQsCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListFAQsCommand.js","sourceRoot":"","sources":["../../../src/commands/metaobjects/ListFAQsCommand.ts"],"names":[],"mappings":";;;AACA,kDAA4C;AAC5C,2DAAqD;AACrD,mDAAwD;AAExD,MAAM,KAAK,GAAG,aAAa,CAAC;;;;;;;;;;;;;;;;CAgB3B,CAAA;AAyCD,kFAAkF;AAClF,SAAS,kBAAkB,CAAC,OAAe,EAAE,IAAY;IACvD,IAAI,IAAI,KAAK,wBAAwB,EAAE,CAAC;QACtC,OAAO,MAAM,OAAO,MAAM,CAAA;IAC5B,CAAC;IAED,IAAI,IAAI,KAAK,iBAAiB;QAAE,OAAO,OAAO,CAAA;IAE9C,OAAO,QAAQ,IAAA,8BAAmB,EAAC,OAAO,CAAC,QAAQ,CAAA;AACrD,CAAC;AAED,SAAS,QAAQ,CAAC,IAAgB;IAChC,MAAM,EAAC,MAAM,EAAE,GAAG,IAAI,EAAC,GAAG,IAAI,CAAA;IAC9B,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IAE1C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAA8B,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACtE,IAAI,KAAK,CAAC,GAAG;YAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QAErC,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,KAAK,CAAA;IAChC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IAEvB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAA;IAC7B,MAAM,IAAI,GAAG,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAElF,OAAO,EAAC,GAAG,IAAI,EAAE,KAAK,EAAE,IAAI,EAAC,CAAA;AAC/B,CAAC;AAED,MAAa,eAAgB,SAAQ,iBAAsC;IACzE,KAAK,CAAC,OAAO,CAAC,MAAsB;QAClC,MAAM,SAAS,GAAG,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,IAAI,GAAG,EAAC,CAAA;QAEnD,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,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK;aACjC,GAAG,CAAC,QAAQ,CAAC;aACb,MAAM,CAAC,CAAC,IAAI,EAAmB,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;QAEnD,OAAO,EAAC,KAAK,EAAC,CAAA;IAChB,CAAC;CACF;AAdD,0CAcC","sourcesContent":["import type {AdminApiClient} from '@shopify/admin-api-client'\nimport {Command} from '../../client/Command'\nimport {handleErrors} from '../../utils/handleErrors'\nimport {convertSchemaToHtml} from '../../utils/richText'\n\nconst QUERY = /* GraphQL */ `\n query ListFAQs($first: Int!) {\n metaobjects(type: \"faq\", first: $first) {\n nodes {\n id\n type\n handle\n updatedAt\n fields {\n key\n value\n type\n }\n }\n }\n }\n`\n\ninterface RawFAQField {\n key: string\n value: string | null\n type: string\n}\n\ninterface RawFAQNode {\n id: string\n type: string\n handle: string\n updatedAt: string\n fields: RawFAQField[]\n}\n\nexport interface FAQItem {\n id: string\n type: string\n handle: string\n updatedAt: string\n title: string\n /** HTML built from the `content` field (rich_text_field → HTML, single_line_text_field → <p>). */\n body: string\n}\n\nexport interface ListFAQsInput {\n /** Max FAQs to return. Defaults to 100. */\n first?: number\n}\n\nexport interface ListFAQsOutput {\n items: FAQItem[]\n}\n\ninterface QueryResponse {\n metaobjects: {\n nodes: RawFAQNode[]\n }\n}\n\n// rich_text_field stores a JSON schema; single_line_text_field stores plain text.\nfunction parseContentToHtml(content: string, type: string): string {\n if (type === 'single_line_text_field') {\n return `<p>${content}</p>`\n }\n\n if (type !== 'rich_text_field') return content\n\n return `<div>${convertSchemaToHtml(content)}</div>`\n}\n\nfunction parseFAQ(node: RawFAQNode): FAQItem | null {\n const {fields, ...rest} = node\n if (!fields || !fields.length) return null\n\n const byKey = fields.reduce<Record<string, RawFAQField>>((acc, field) => {\n if (field.key) acc[field.key] = field\n\n return acc\n }, {})\n\n const title = byKey.title?.value\n if (!title) return null\n\n const content = byKey.content\n const body = content?.value ? parseContentToHtml(content.value, content.type) : ''\n\n return {...rest, title, body}\n}\n\nexport class ListFAQsCommand extends Command<ListFAQsInput, ListFAQsOutput> {\n async execute(client: AdminApiClient): Promise<ListFAQsOutput> {\n const variables = {first: this.input?.first ?? 100}\n\n const {data, errors} = await client.request<QueryResponse>(QUERY, {variables})\n handleErrors(errors)\n if (!data) throw new Error('ListFAQsCommand: no data returned')\n\n const items = data.metaobjects.nodes\n .map(parseFAQ)\n .filter((item): item is FAQItem => item !== null)\n\n return {items}\n }\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AdminApiClient } from '@shopify/admin-api-client';
|
|
2
|
+
import { Command } from '../../client/Command';
|
|
3
|
+
export interface SearchMetaobjectsInput {
|
|
4
|
+
type: string;
|
|
5
|
+
first?: number;
|
|
6
|
+
after?: string;
|
|
7
|
+
query?: string;
|
|
8
|
+
/** Supports "id", "type", "updated_at", "display_name". */
|
|
9
|
+
sortKey?: string;
|
|
10
|
+
reverse?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface MetaobjectNode {
|
|
13
|
+
id: string;
|
|
14
|
+
displayName: string;
|
|
15
|
+
type: string;
|
|
16
|
+
handle: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SearchMetaobjectsOutput {
|
|
19
|
+
items: MetaobjectNode[];
|
|
20
|
+
pageInfo: {
|
|
21
|
+
endCursor: string | null;
|
|
22
|
+
hasNextPage: boolean;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export declare class SearchMetaobjectsCommand extends Command<SearchMetaobjectsInput, SearchMetaobjectsOutput> {
|
|
26
|
+
execute(client: AdminApiClient): Promise<SearchMetaobjectsOutput>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchMetaobjectsCommand = void 0;
|
|
4
|
+
const Command_1 = require("../../client/Command");
|
|
5
|
+
const handleErrors_1 = require("../../utils/handleErrors");
|
|
6
|
+
const QUERY = /* GraphQL */ `
|
|
7
|
+
query SearchMetaobjects(
|
|
8
|
+
$type: String!
|
|
9
|
+
$first: Int
|
|
10
|
+
$after: String
|
|
11
|
+
$query: String
|
|
12
|
+
$sortKey: String
|
|
13
|
+
$reverse: Boolean
|
|
14
|
+
) {
|
|
15
|
+
metaobjects(
|
|
16
|
+
type: $type
|
|
17
|
+
first: $first
|
|
18
|
+
after: $after
|
|
19
|
+
query: $query
|
|
20
|
+
sortKey: $sortKey
|
|
21
|
+
reverse: $reverse
|
|
22
|
+
) {
|
|
23
|
+
nodes {
|
|
24
|
+
id
|
|
25
|
+
displayName
|
|
26
|
+
type
|
|
27
|
+
handle
|
|
28
|
+
}
|
|
29
|
+
pageInfo {
|
|
30
|
+
endCursor
|
|
31
|
+
hasNextPage
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
class SearchMetaobjectsCommand extends Command_1.Command {
|
|
37
|
+
async execute(client) {
|
|
38
|
+
const variables = {
|
|
39
|
+
type: this.input.type,
|
|
40
|
+
first: this.input.first ?? 200,
|
|
41
|
+
after: this.input.after,
|
|
42
|
+
query: this.input.query,
|
|
43
|
+
sortKey: this.input.sortKey,
|
|
44
|
+
reverse: this.input.reverse,
|
|
45
|
+
};
|
|
46
|
+
const { data, errors } = await client.request(QUERY, { variables });
|
|
47
|
+
(0, handleErrors_1.handleErrors)(errors);
|
|
48
|
+
if (!data)
|
|
49
|
+
throw new Error('SearchMetaobjectsCommand: no data returned');
|
|
50
|
+
return { items: data.metaobjects.nodes, pageInfo: data.metaobjects.pageInfo };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.SearchMetaobjectsCommand = SearchMetaobjectsCommand;
|
|
54
|
+
//# sourceMappingURL=SearchMetaobjectsCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchMetaobjectsCommand.js","sourceRoot":"","sources":["../../../src/commands/metaobjects/SearchMetaobjectsCommand.ts"],"names":[],"mappings":";;;AACA,kDAA4C;AAC5C,2DAAqD;AAErD,MAAM,KAAK,GAAG,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6B3B,CAAA;AAkCD,MAAa,wBAAyB,SAAQ,iBAG7C;IACC,KAAK,CAAC,OAAO,CAAC,MAAsB;QAClC,MAAM,SAAS,GAAG;YAChB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,GAAG;YAC9B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;YACvB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;YAC3B,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;SAC5B,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,4CAA4C,CAAC,CAAA;QAExE,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAC,CAAA;IAC7E,CAAC;CACF;AApBD,4DAoBC","sourcesContent":["import type {AdminApiClient} from '@shopify/admin-api-client'\nimport {Command} from '../../client/Command'\nimport {handleErrors} from '../../utils/handleErrors'\n\nconst QUERY = /* GraphQL */ `\n query SearchMetaobjects(\n $type: String!\n $first: Int\n $after: String\n $query: String\n $sortKey: String\n $reverse: Boolean\n ) {\n metaobjects(\n type: $type\n first: $first\n after: $after\n query: $query\n sortKey: $sortKey\n reverse: $reverse\n ) {\n nodes {\n id\n displayName\n type\n handle\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n`\n\nexport interface SearchMetaobjectsInput {\n type: string\n first?: number\n after?: string\n query?: string\n /** Supports \"id\", \"type\", \"updated_at\", \"display_name\". */\n sortKey?: string\n reverse?: boolean\n}\n\nexport interface MetaobjectNode {\n id: string\n displayName: string\n type: string\n handle: string\n}\n\nexport interface SearchMetaobjectsOutput {\n items: MetaobjectNode[]\n pageInfo: {\n endCursor: string | null\n hasNextPage: boolean\n }\n}\n\ninterface QueryResponse {\n metaobjects: {\n nodes: MetaobjectNode[]\n pageInfo: SearchMetaobjectsOutput['pageInfo']\n }\n}\n\nexport class SearchMetaobjectsCommand extends Command<\n SearchMetaobjectsInput,\n SearchMetaobjectsOutput\n> {\n async execute(client: AdminApiClient): Promise<SearchMetaobjectsOutput> {\n const variables = {\n type: this.input.type,\n first: this.input.first ?? 200,\n after: this.input.after,\n query: this.input.query,\n sortKey: this.input.sortKey,\n reverse: this.input.reverse,\n }\n\n const {data, errors} = await client.request<QueryResponse>(QUERY, {variables})\n handleErrors(errors)\n if (!data) throw new Error('SearchMetaobjectsCommand: no data returned')\n\n return {items: data.metaobjects.nodes, pageInfo: data.metaobjects.pageInfo}\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
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("./SearchMetaobjectsCommand"), exports);
|
|
18
|
+
__exportStar(require("./GetMetaobjectCommand"), exports);
|
|
19
|
+
__exportStar(require("./ListBannersCommand"), exports);
|
|
20
|
+
__exportStar(require("./ListFAQsCommand"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/metaobjects/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA0C;AAC1C,yDAAsC;AACtC,uDAAoC;AACpC,oDAAiC","sourcesContent":["export * from './SearchMetaobjectsCommand'\nexport * from './GetMetaobjectCommand'\nexport * from './ListBannersCommand'\nexport * from './ListFAQsCommand'\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export type { MoneyV2 } from './utils/money';
|
|
|
6
6
|
export * from './commands/customers';
|
|
7
7
|
export * from './commands/payments';
|
|
8
8
|
export * from './commands/menus';
|
|
9
|
+
export * from './commands/metaobjects';
|
|
9
10
|
export * from './commands/orders';
|
|
10
11
|
export * from './commands/collections';
|
|
11
12
|
export * from './commands/fulfillments';
|
|
13
|
+
export * from './commands/files';
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,9 @@ Object.defineProperty(exports, "extractIdFromGlobalID", { enumerable: true, get:
|
|
|
29
29
|
__exportStar(require("./commands/customers"), exports);
|
|
30
30
|
__exportStar(require("./commands/payments"), exports);
|
|
31
31
|
__exportStar(require("./commands/menus"), exports);
|
|
32
|
+
__exportStar(require("./commands/metaobjects"), exports);
|
|
32
33
|
__exportStar(require("./commands/orders"), exports);
|
|
33
34
|
__exportStar(require("./commands/collections"), exports);
|
|
34
35
|
__exportStar(require("./commands/fulfillments"), exports);
|
|
36
|
+
__exportStar(require("./commands/files"), exports);
|
|
35
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,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/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"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a Shopify rich_text_field JSON schema into an HTML string.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the legacy `@pintahub/shopify-api` richText helper so metaobject
|
|
5
|
+
* consumers (e.g. FAQs) keep producing identical HTML after migration.
|
|
6
|
+
*/
|
|
7
|
+
export declare const convertSchemaToHtml: (schema: any, scoped?: boolean | string) => string;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Converts a Shopify rich_text_field JSON schema into an HTML string.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the legacy `@pintahub/shopify-api` richText helper so metaobject
|
|
6
|
+
* consumers (e.g. FAQs) keep producing identical HTML after migration.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.convertSchemaToHtml = void 0;
|
|
10
|
+
const convertSchemaToHtml = (schema, scoped = false) => {
|
|
11
|
+
if (typeof schema === 'string') {
|
|
12
|
+
schema = JSON.parse(schema);
|
|
13
|
+
}
|
|
14
|
+
let html = ``;
|
|
15
|
+
if (schema.type === 'root' && schema.children.length > 0) {
|
|
16
|
+
if (scoped) {
|
|
17
|
+
html += `
|
|
18
|
+
<div class="${scoped === true ? `rte` : scoped}">
|
|
19
|
+
${(0, exports.convertSchemaToHtml)(schema.children)}
|
|
20
|
+
</div>
|
|
21
|
+
`;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
html += (0, exports.convertSchemaToHtml)(schema.children);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
for (const el of schema) {
|
|
29
|
+
switch (el.type) {
|
|
30
|
+
case 'paragraph':
|
|
31
|
+
html += buildParagraph(el);
|
|
32
|
+
break;
|
|
33
|
+
case 'heading':
|
|
34
|
+
html += buildHeading(el);
|
|
35
|
+
break;
|
|
36
|
+
case 'list':
|
|
37
|
+
html += buildList(el);
|
|
38
|
+
break;
|
|
39
|
+
case 'list-item':
|
|
40
|
+
html += buildListItem(el);
|
|
41
|
+
break;
|
|
42
|
+
case 'link':
|
|
43
|
+
html += buildLink(el);
|
|
44
|
+
break;
|
|
45
|
+
case 'text':
|
|
46
|
+
html += buildText(el);
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return html;
|
|
54
|
+
};
|
|
55
|
+
exports.convertSchemaToHtml = convertSchemaToHtml;
|
|
56
|
+
function buildParagraph(el) {
|
|
57
|
+
if (el?.children) {
|
|
58
|
+
return `<p>${(0, exports.convertSchemaToHtml)(el?.children)}</p>`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function buildHeading(el) {
|
|
62
|
+
if (el?.children) {
|
|
63
|
+
return `<h${el?.level}>${(0, exports.convertSchemaToHtml)(el?.children)}</h${el?.level}>`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function buildList(el) {
|
|
67
|
+
if (el?.children) {
|
|
68
|
+
if (el?.listType === 'ordered') {
|
|
69
|
+
return `<ol>${(0, exports.convertSchemaToHtml)(el?.children)}</ol>`;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return `<ul>${(0, exports.convertSchemaToHtml)(el?.children)}</ul>`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function buildListItem(el) {
|
|
77
|
+
if (el?.children) {
|
|
78
|
+
return `<li>${(0, exports.convertSchemaToHtml)(el?.children)}</li>`;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function buildLink(el) {
|
|
82
|
+
return `<a href="${el?.url}" title="${el?.title}" target="${el?.target}">${(0, exports.convertSchemaToHtml)(el?.children)}</a>`;
|
|
83
|
+
}
|
|
84
|
+
function buildText(el) {
|
|
85
|
+
const { value } = el;
|
|
86
|
+
const withBreaks = (value || '').replace(/\n/g, '<br/>');
|
|
87
|
+
if (el?.bold) {
|
|
88
|
+
return `<strong>${withBreaks}</strong>`;
|
|
89
|
+
}
|
|
90
|
+
if (el?.italic) {
|
|
91
|
+
return `<em>${withBreaks}</em>`;
|
|
92
|
+
}
|
|
93
|
+
return withBreaks;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=richText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"richText.js","sourceRoot":"","sources":["../../src/utils/richText.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAII,MAAM,mBAAmB,GAAG,CAAC,MAAW,EAAE,SAA2B,KAAK,EAAU,EAAE;IAC3F,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC;IAED,IAAI,IAAI,GAAG,EAAE,CAAA;IAEb,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzD,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,IAAI;oBACM,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;UAC1C,IAAA,2BAAmB,EAAC,MAAM,CAAC,QAAQ,CAAC;;OAEvC,CAAA;QACH,CAAC;aAAM,CAAC;YACN,IAAI,IAAI,IAAA,2BAAmB,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC;SAAM,CAAC;QACN,KAAK,MAAM,EAAE,IAAI,MAAwB,EAAE,CAAC;YAC1C,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;gBAChB,KAAK,WAAW;oBACd,IAAI,IAAI,cAAc,CAAC,EAAE,CAAC,CAAA;oBAC1B,MAAK;gBACP,KAAK,SAAS;oBACZ,IAAI,IAAI,YAAY,CAAC,EAAE,CAAC,CAAA;oBACxB,MAAK;gBACP,KAAK,MAAM;oBACT,IAAI,IAAI,SAAS,CAAC,EAAE,CAAC,CAAA;oBACrB,MAAK;gBACP,KAAK,WAAW;oBACd,IAAI,IAAI,aAAa,CAAC,EAAE,CAAC,CAAA;oBACzB,MAAK;gBACP,KAAK,MAAM;oBACT,IAAI,IAAI,SAAS,CAAC,EAAE,CAAC,CAAA;oBACrB,MAAK;gBACP,KAAK,MAAM;oBACT,IAAI,IAAI,SAAS,CAAC,EAAE,CAAC,CAAA;oBACrB,MAAK;gBACP;oBACE,MAAK;YACT,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AA7CY,QAAA,mBAAmB,uBA6C/B;AAED,SAAS,cAAc,CAAC,EAAgB;IACtC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC;QACjB,OAAO,MAAM,IAAA,2BAAmB,EAAC,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAA;IACtD,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,EAAgB;IACpC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC;QACjB,OAAO,KAAK,EAAE,EAAE,KAAK,IAAI,IAAA,2BAAmB,EAAC,EAAE,EAAE,QAAQ,CAAC,MAAM,EAAE,EAAE,KAAK,GAAG,CAAA;IAC9E,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,EAAgB;IACjC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC;QACjB,IAAI,EAAE,EAAE,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC/B,OAAO,OAAO,IAAA,2BAAmB,EAAC,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,OAAO,OAAO,IAAA,2BAAmB,EAAC,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAA;QACxD,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,EAAgB;IACrC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC;QACjB,OAAO,OAAO,IAAA,2BAAmB,EAAC,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAA;IACxD,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,EAAgB;IACjC,OAAO,YAAY,EAAE,EAAE,GAAG,YAAY,EAAE,EAAE,KAAK,aAC7C,EAAE,EAAE,MACN,KAAK,IAAA,2BAAmB,EAAC,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAA;AAC9C,CAAC;AAED,SAAS,SAAS,CAAC,EAAgB;IACjC,MAAM,EAAC,KAAK,EAAC,GAAG,EAAE,CAAA;IAClB,MAAM,UAAU,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAExD,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC;QACb,OAAO,WAAW,UAAU,WAAW,CAAA;IACzC,CAAC;IACD,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC;QACf,OAAO,OAAO,UAAU,OAAO,CAAA;IACjC,CAAC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["/**\n * Converts a Shopify rich_text_field JSON schema into an HTML string.\n *\n * Mirrors the legacy `@pintahub/shopify-api` richText helper so metaobject\n * consumers (e.g. FAQs) keep producing identical HTML after migration.\n */\n\ntype RichTextNode = Record<string, any>\n\nexport const convertSchemaToHtml = (schema: any, scoped: boolean | string = false): string => {\n if (typeof schema === 'string') {\n schema = JSON.parse(schema)\n }\n\n let html = ``\n\n if (schema.type === 'root' && schema.children.length > 0) {\n if (scoped) {\n html += `\n <div class=\"${scoped === true ? `rte` : scoped}\">\n ${convertSchemaToHtml(schema.children)}\n </div>\n `\n } else {\n html += convertSchemaToHtml(schema.children)\n }\n } else {\n for (const el of schema as RichTextNode[]) {\n switch (el.type) {\n case 'paragraph':\n html += buildParagraph(el)\n break\n case 'heading':\n html += buildHeading(el)\n break\n case 'list':\n html += buildList(el)\n break\n case 'list-item':\n html += buildListItem(el)\n break\n case 'link':\n html += buildLink(el)\n break\n case 'text':\n html += buildText(el)\n break\n default:\n break\n }\n }\n }\n\n return html\n}\n\nfunction buildParagraph(el: RichTextNode) {\n if (el?.children) {\n return `<p>${convertSchemaToHtml(el?.children)}</p>`\n }\n}\n\nfunction buildHeading(el: RichTextNode) {\n if (el?.children) {\n return `<h${el?.level}>${convertSchemaToHtml(el?.children)}</h${el?.level}>`\n }\n}\n\nfunction buildList(el: RichTextNode) {\n if (el?.children) {\n if (el?.listType === 'ordered') {\n return `<ol>${convertSchemaToHtml(el?.children)}</ol>`\n } else {\n return `<ul>${convertSchemaToHtml(el?.children)}</ul>`\n }\n }\n}\n\nfunction buildListItem(el: RichTextNode) {\n if (el?.children) {\n return `<li>${convertSchemaToHtml(el?.children)}</li>`\n }\n}\n\nfunction buildLink(el: RichTextNode) {\n return `<a href=\"${el?.url}\" title=\"${el?.title}\" target=\"${\n el?.target\n }\">${convertSchemaToHtml(el?.children)}</a>`\n}\n\nfunction buildText(el: RichTextNode) {\n const {value} = el\n const withBreaks = (value || '').replace(/\\n/g, '<br/>')\n\n if (el?.bold) {\n return `<strong>${withBreaks}</strong>`\n }\n if (el?.italic) {\n return `<em>${withBreaks}</em>`\n }\n\n return withBreaks\n}\n"]}
|