@shopify/cli-kit 4.3.0 → 4.5.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/cli/api/graphql/bulk-operations/generated/bulk-operation-cancel.d.ts +28 -0
- package/dist/cli/api/graphql/bulk-operations/generated/bulk-operation-cancel.js +74 -0
- package/dist/cli/api/graphql/bulk-operations/generated/bulk-operation-cancel.js.map +1 -0
- package/dist/cli/api/graphql/bulk-operations/generated/bulk-operation-run-mutation.d.ts +28 -0
- package/dist/cli/api/graphql/bulk-operations/generated/bulk-operation-run-mutation.js +92 -0
- package/dist/cli/api/graphql/bulk-operations/generated/bulk-operation-run-mutation.js.map +1 -0
- package/dist/cli/api/graphql/bulk-operations/generated/bulk-operation-run-query.d.ts +26 -0
- package/dist/cli/api/graphql/bulk-operations/generated/bulk-operation-run-query.js +72 -0
- package/dist/cli/api/graphql/bulk-operations/generated/bulk-operation-run-query.js.map +1 -0
- package/dist/cli/api/graphql/bulk-operations/generated/get-bulk-operation-by-id.d.ts +19 -0
- package/dist/cli/api/graphql/bulk-operations/generated/get-bulk-operation-by-id.js +49 -0
- package/dist/cli/api/graphql/bulk-operations/generated/get-bulk-operation-by-id.js.map +1 -0
- package/dist/cli/api/graphql/bulk-operations/generated/list-bulk-operations.d.ts +22 -0
- package/dist/cli/api/graphql/bulk-operations/generated/list-bulk-operations.js +78 -0
- package/dist/cli/api/graphql/bulk-operations/generated/list-bulk-operations.js.map +1 -0
- package/dist/cli/api/graphql/bulk-operations/generated/staged-uploads-create.d.ts +22 -0
- package/dist/cli/api/graphql/bulk-operations/generated/staged-uploads-create.js +82 -0
- package/dist/cli/api/graphql/bulk-operations/generated/staged-uploads-create.js.map +1 -0
- package/dist/private/node/api/headers.js +1 -1
- package/dist/private/node/api/headers.js.map +1 -1
- package/dist/private/node/ui/components/Alert.test.js +5 -5
- package/dist/private/node/ui/components/Alert.test.js.map +1 -1
- package/dist/private/node/ui/components/Banner.js +9 -1
- package/dist/private/node/ui/components/Banner.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/api/admin.d.ts +2 -1
- package/dist/public/node/api/admin.js +4 -3
- package/dist/public/node/api/admin.js.map +1 -1
- package/dist/public/node/api/bulk-operations/cancel.d.ts +15 -0
- package/dist/public/node/api/bulk-operations/cancel.js +20 -0
- package/dist/public/node/api/bulk-operations/cancel.js.map +1 -0
- package/dist/public/node/api/bulk-operations/constants.d.ts +5 -0
- package/dist/public/node/api/bulk-operations/constants.js +6 -0
- package/dist/public/node/api/bulk-operations/constants.js.map +1 -0
- package/dist/public/node/api/bulk-operations/download-bulk-operation-results.d.ts +17 -0
- package/dist/public/node/api/bulk-operations/download-bulk-operation-results.js +48 -0
- package/dist/public/node/api/bulk-operations/download-bulk-operation-results.js.map +1 -0
- package/dist/public/node/api/bulk-operations/fetch.d.ts +31 -0
- package/dist/public/node/api/bulk-operations/fetch.js +42 -0
- package/dist/public/node/api/bulk-operations/fetch.js.map +1 -0
- package/dist/public/node/api/bulk-operations/format-bulk-operation-status.d.ts +45 -0
- package/dist/public/node/api/bulk-operations/format-bulk-operation-status.js +91 -0
- package/dist/public/node/api/bulk-operations/format-bulk-operation-status.js.map +1 -0
- package/dist/public/node/api/bulk-operations/helpers.d.ts +51 -0
- package/dist/public/node/api/bulk-operations/helpers.js +110 -0
- package/dist/public/node/api/bulk-operations/helpers.js.map +1 -0
- package/dist/public/node/api/bulk-operations/query.d.ts +22 -0
- package/dist/public/node/api/bulk-operations/query.js +40 -0
- package/dist/public/node/api/bulk-operations/query.js.map +1 -0
- package/dist/public/node/api/bulk-operations/run-mutation.d.ts +16 -0
- package/dist/public/node/api/bulk-operations/run-mutation.js +27 -0
- package/dist/public/node/api/bulk-operations/run-mutation.js.map +1 -0
- package/dist/public/node/api/bulk-operations/run-query.d.ts +15 -0
- package/dist/public/node/api/bulk-operations/run-query.js +19 -0
- package/dist/public/node/api/bulk-operations/run-query.js.map +1 -0
- package/dist/public/node/api/bulk-operations/stage-file.d.ts +13 -0
- package/dist/public/node/api/bulk-operations/stage-file.js +89 -0
- package/dist/public/node/api/bulk-operations/stage-file.js.map +1 -0
- package/dist/public/node/api/bulk-operations/watch-bulk-operation.d.ts +26 -0
- package/dist/public/node/api/bulk-operations/watch-bulk-operation.js +131 -0
- package/dist/public/node/api/bulk-operations/watch-bulk-operation.js.map +1 -0
- package/dist/public/node/api/bulk-operations.d.ts +18 -0
- package/dist/public/node/api/bulk-operations.js +19 -0
- package/dist/public/node/api/bulk-operations.js.map +1 -0
- package/dist/public/node/constants.d.ts +1 -0
- package/dist/public/node/constants.js +2 -0
- package/dist/public/node/constants.js.map +1 -0
- package/dist/public/node/context/fqdn.js +45 -4
- package/dist/public/node/context/fqdn.js.map +1 -1
- package/dist/public/node/graphiql/session.d.ts +50 -0
- package/dist/public/node/graphiql/session.js +92 -0
- package/dist/public/node/graphiql/session.js.map +1 -0
- package/dist/public/node/graphiql/templates/graphiql.js +1 -4
- package/dist/public/node/graphiql/templates/graphiql.js.map +1 -1
- package/dist/public/node/store-auth-session.d.ts +113 -0
- package/dist/public/node/store-auth-session.js +257 -0
- package/dist/public/node/store-auth-session.js.map +1 -0
- package/dist/public/node/ui.d.ts +2 -6
- package/dist/public/node/ui.js +2 -6
- package/dist/public/node/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export const StagedUploadsCreate = {
|
|
2
|
+
kind: 'Document',
|
|
3
|
+
definitions: [
|
|
4
|
+
{
|
|
5
|
+
kind: 'OperationDefinition',
|
|
6
|
+
operation: 'mutation',
|
|
7
|
+
name: { kind: 'Name', value: 'StagedUploadsCreate' },
|
|
8
|
+
variableDefinitions: [
|
|
9
|
+
{
|
|
10
|
+
kind: 'VariableDefinition',
|
|
11
|
+
variable: { kind: 'Variable', name: { kind: 'Name', value: 'input' } },
|
|
12
|
+
type: {
|
|
13
|
+
kind: 'NonNullType',
|
|
14
|
+
type: {
|
|
15
|
+
kind: 'ListType',
|
|
16
|
+
type: { kind: 'NonNullType', type: { kind: 'NamedType', name: { kind: 'Name', value: 'StagedUploadInput' } } },
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
selectionSet: {
|
|
22
|
+
kind: 'SelectionSet',
|
|
23
|
+
selections: [
|
|
24
|
+
{
|
|
25
|
+
kind: 'Field',
|
|
26
|
+
name: { kind: 'Name', value: 'stagedUploadsCreate' },
|
|
27
|
+
arguments: [
|
|
28
|
+
{
|
|
29
|
+
kind: 'Argument',
|
|
30
|
+
name: { kind: 'Name', value: 'input' },
|
|
31
|
+
value: { kind: 'Variable', name: { kind: 'Name', value: 'input' } },
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
selectionSet: {
|
|
35
|
+
kind: 'SelectionSet',
|
|
36
|
+
selections: [
|
|
37
|
+
{
|
|
38
|
+
kind: 'Field',
|
|
39
|
+
name: { kind: 'Name', value: 'stagedTargets' },
|
|
40
|
+
selectionSet: {
|
|
41
|
+
kind: 'SelectionSet',
|
|
42
|
+
selections: [
|
|
43
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'url' } },
|
|
44
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'resourceUrl' } },
|
|
45
|
+
{
|
|
46
|
+
kind: 'Field',
|
|
47
|
+
name: { kind: 'Name', value: 'parameters' },
|
|
48
|
+
selectionSet: {
|
|
49
|
+
kind: 'SelectionSet',
|
|
50
|
+
selections: [
|
|
51
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'name' } },
|
|
52
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'value' } },
|
|
53
|
+
{ kind: 'Field', name: { kind: 'Name', value: '__typename' } },
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{ kind: 'Field', name: { kind: 'Name', value: '__typename' } },
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
kind: 'Field',
|
|
63
|
+
name: { kind: 'Name', value: 'userErrors' },
|
|
64
|
+
selectionSet: {
|
|
65
|
+
kind: 'SelectionSet',
|
|
66
|
+
selections: [
|
|
67
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'field' } },
|
|
68
|
+
{ kind: 'Field', name: { kind: 'Name', value: 'message' } },
|
|
69
|
+
{ kind: 'Field', name: { kind: 'Name', value: '__typename' } },
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{ kind: 'Field', name: { kind: 'Name', value: '__typename' } },
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=staged-uploads-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staged-uploads-create.js","sourceRoot":"","sources":["../../../../../../src/cli/api/graphql/bulk-operations/generated/staged-uploads-create.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE;QACX;YACE,IAAI,EAAE,qBAAqB;YAC3B,SAAS,EAAE,UAAU;YACrB,IAAI,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAC;YAClD,mBAAmB,EAAE;gBACnB;oBACE,IAAI,EAAE,oBAAoB;oBAC1B,QAAQ,EAAE,EAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAC,EAAC;oBAClE,IAAI,EAAE;wBACJ,IAAI,EAAE,aAAa;wBACnB,IAAI,EAAE;4BACJ,IAAI,EAAE,UAAU;4BAChB,IAAI,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C,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAC,EAAC;wDACpD,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAC,EAAC;wDACrD,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAC,EAAC;qDAC3D;iDACF;6CACF;4CACD,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAC,EAAC;yCAC3D;qCACF;iCACF;gCACD;oCACE,IAAI,EAAE,OAAO;oCACb,IAAI,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAC;oCACzC,YAAY,EAAE;wCACZ,IAAI,EAAE,cAAc;wCACpB,UAAU,EAAE;4CACV,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAC,EAAC;4CACrD,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAC,EAAC;4CACvD,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAC,EAAC;yCAC3D;qCACF;iCACF;gCACD,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAC,EAAC;6BAC3D;yBACF;qBACF;iBACF;aACF;SACF;KACF;CAC4F,CAAA","sourcesContent":["/* eslint-disable @typescript-eslint/consistent-type-definitions */\nimport * as Types from './types.js'\n\nimport {TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/core'\n\nexport type StagedUploadsCreateMutationVariables = Types.Exact<{\n input: Types.StagedUploadInput[] | Types.StagedUploadInput\n}>\n\nexport type StagedUploadsCreateMutation = {\n stagedUploadsCreate?: {\n stagedTargets?:\n | {\n url?: string | null\n resourceUrl?: string | null\n parameters: {name: string; value: string}[]\n }[]\n | null\n userErrors: {field?: string[] | null; message: string}[]\n } | null\n}\n\nexport const StagedUploadsCreate = {\n kind: 'Document',\n definitions: [\n {\n kind: 'OperationDefinition',\n operation: 'mutation',\n name: {kind: 'Name', value: 'StagedUploadsCreate'},\n variableDefinitions: [\n {\n kind: 'VariableDefinition',\n variable: {kind: 'Variable', name: {kind: 'Name', value: 'input'}},\n type: {\n kind: 'NonNullType',\n type: {\n kind: 'ListType',\n type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'StagedUploadInput'}}},\n },\n },\n },\n ],\n selectionSet: {\n kind: 'SelectionSet',\n selections: [\n {\n kind: 'Field',\n name: {kind: 'Name', value: 'stagedUploadsCreate'},\n arguments: [\n {\n kind: 'Argument',\n name: {kind: 'Name', value: 'input'},\n value: {kind: 'Variable', name: {kind: 'Name', value: 'input'}},\n },\n ],\n selectionSet: {\n kind: 'SelectionSet',\n selections: [\n {\n kind: 'Field',\n name: {kind: 'Name', value: 'stagedTargets'},\n selectionSet: {\n kind: 'SelectionSet',\n selections: [\n {kind: 'Field', name: {kind: 'Name', value: 'url'}},\n {kind: 'Field', name: {kind: 'Name', value: 'resourceUrl'}},\n {\n kind: 'Field',\n name: {kind: 'Name', value: 'parameters'},\n selectionSet: {\n kind: 'SelectionSet',\n selections: [\n {kind: 'Field', name: {kind: 'Name', value: 'name'}},\n {kind: 'Field', name: {kind: 'Name', value: 'value'}},\n {kind: 'Field', name: {kind: 'Name', value: '__typename'}},\n ],\n },\n },\n {kind: 'Field', name: {kind: 'Name', value: '__typename'}},\n ],\n },\n },\n {\n kind: 'Field',\n name: {kind: 'Name', value: 'userErrors'},\n selectionSet: {\n kind: 'SelectionSet',\n selections: [\n {kind: 'Field', name: {kind: 'Name', value: 'field'}},\n {kind: 'Field', name: {kind: 'Name', value: 'message'}},\n {kind: 'Field', name: {kind: 'Name', value: '__typename'}},\n ],\n },\n },\n {kind: 'Field', name: {kind: 'Name', value: '__typename'}},\n ],\n },\n },\n ],\n },\n },\n ],\n} as unknown as DocumentNode<StagedUploadsCreateMutation, StagedUploadsCreateMutationVariables>\n"]}
|
|
@@ -19,7 +19,7 @@ export class GraphQLClientError extends RequestClientError {
|
|
|
19
19
|
this.stack = undefined;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
const SENSITIVE_HEADERS = ['token', 'authorization', 'subject_token', 'cookie'];
|
|
22
|
+
const SENSITIVE_HEADERS = ['token', 'authorization', 'subject_token', 'cookie', 'signature'];
|
|
23
23
|
/**
|
|
24
24
|
* Removes the sensitive data from the headers and outputs them as a string.
|
|
25
25
|
* @param headers - HTTP headers.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headers.js","sourceRoot":"","sources":["../../../../src/private/node/api/headers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,mCAAmC,CAAA;AACjE,OAAO,EAAC,aAAa,EAAE,UAAU,EAAE,SAAS,EAAC,MAAM,uCAAuC,CAAA;AAC1F,OAAO,EAAC,UAAU,EAAC,MAAM,+BAA+B,CAAA;AACxD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,kBAAmB,SAAQ,UAAU;IAEzC,YAAmB,OAAe,EAAE,UAAkB;QACpD,MAAM,UAAU,GACd,UAAU,KAAK,GAAG;YAChB,CAAC,CAAC,oFAAoF;YACtF,CAAC,CAAC,SAAS,CAAA;QACf,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;QAC1B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AACD,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;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F,OAAO,CAAC,aAAa,GAAG,UAAU,CAAA;QAClC,OAAO,CAAC,wBAAwB,CAAC,GAAG,UAAU,CAAA;IAChD,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC;QACrB,kBAAkB,EAAE,IAAI;QACxB,SAAS,EAAE,IAAI;KAChB,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {CLI_KIT_VERSION} from '../../../public/common/version.js'\nimport {firstPartyDev, isUnitTest, isVerbose} from '../../../public/node/context/local.js'\nimport {AbortError} from '../../../public/node/error.js'\nimport https from 'https'\n\nclass RequestClientError extends AbortError {\n statusCode: number\n public constructor(message: string, statusCode: number) {\n const tryMessage =\n statusCode === 403\n ? 'Ensure you are using the correct account. You can switch with `shopify auth login`'\n : undefined\n super(message, tryMessage)\n this.statusCode = statusCode\n }\n}\nexport class GraphQLClientError extends RequestClientError {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n errors?: any[]\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public constructor(message: string, statusCode: number, errors?: any[]) {\n super(message, statusCode)\n this.errors = errors\n this.stack = undefined\n }\n}\n\nconst SENSITIVE_HEADERS = ['token', 'authorization', 'subject_token', 'cookie', 'signature']\n\n/**\n * Removes the sensitive data from the headers and outputs them as a string.\n * @param headers - HTTP headers.\n * @returns A sanitized version of the headers as a string.\n */\nexport function sanitizedHeadersOutput(headers: Record<string, string>): string {\n if (!isVerbose() && !isUnitTest()) {\n return ''\n }\n\n const sanitized: Record<string, string> = {}\n Object.keys(headers).forEach((header) => {\n if (SENSITIVE_HEADERS.find((keyword) => header.toLowerCase().includes(keyword)) === undefined) {\n sanitized[header] = headers[header]!\n }\n })\n return Object.keys(sanitized)\n .map((header) => {\n return ` - ${header}: ${sanitized[header]}`\n })\n .join('\\n')\n}\n\nexport function buildHeaders(token?: string): Record<string, string> {\n const userAgent = `Shopify CLI; v=${CLI_KIT_VERSION}`\n\n const headers: Record<string, string> = {\n 'User-Agent': userAgent,\n 'Keep-Alive': 'timeout=30',\n // 'Sec-CH-UA': secCHUA, This header requires the Git sha.\n 'Sec-CH-UA-PLATFORM': process.platform,\n 'Content-Type': 'application/json',\n ...(firstPartyDev() && {'X-Shopify-Cli-Employee': '1'}),\n }\n if (token) {\n const authString = token.match(/^shp(at|ua|ca|tka)/) ? token : `Bearer ${token}`\n\n headers.authorization = authString\n headers['X-Shopify-Access-Token'] = authString\n }\n\n return headers\n}\n\n/**\n * This utility function returns the https.Agent to use for a given service.\n */\nexport async function httpsAgent(): Promise<https.Agent> {\n return new https.Agent({\n rejectUnauthorized: true,\n keepAlive: true,\n })\n}\n"]}
|
|
@@ -150,14 +150,14 @@ describe('Alert', async () => {
|
|
|
150
150
|
expect(line).not.toContain(longUrl);
|
|
151
151
|
});
|
|
152
152
|
// The footnote block (rendered after the closing `╰`) must list the
|
|
153
|
-
// URL
|
|
154
|
-
//
|
|
155
|
-
//
|
|
153
|
+
// URL as a single contiguous `[1] URL` line. The footnote Box is sized to
|
|
154
|
+
// the line length so Ink never hard-wraps the URL (which would insert
|
|
155
|
+
// newline characters and break copy-paste/clickability); the terminal
|
|
156
|
+
// soft-wraps the overflow at display time instead.
|
|
156
157
|
const closingBorderIndex = frame.indexOf('╰');
|
|
157
158
|
expect(closingBorderIndex).toBeGreaterThanOrEqual(0);
|
|
158
159
|
const afterBox = frame.slice(closingBorderIndex);
|
|
159
|
-
expect(afterBox).toContain(
|
|
160
|
-
expect(afterBox).toContain(longUrl);
|
|
160
|
+
expect(afterBox).toContain(`[1] ${longUrl}`);
|
|
161
161
|
// And the body must reference the footnote.
|
|
162
162
|
expect(frame).toContain('docs [1]');
|
|
163
163
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Alert.test.tsx"],"names":[],"mapp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'../../../../public/node/output.js'\nimport {render} from '../../testing/ui.js'\nimport {describe, expect, test} from 'vitest'\n\nimport React from 'react'\n\ndescribe('Alert', async () => {\n test('renders correctly with all the options', async () => {\n const options = {\n headline: [{userInput: 'my-app'}, 'initialized and ready to build.'],\n body: ['You can find the build files in the', {filePath: 'dist'}, 'folder.'],\n nextSteps: [\n [\n 'Run',\n {\n command: 'cd santorini-goods',\n },\n ],\n [\n 'To preview your project, run',\n {\n command: 'npm app dev',\n },\n ],\n [\n 'To add extensions, run',\n {\n command: 'npm generate extension',\n },\n ],\n ],\n reference: [\n [\n 'Run',\n {\n command: 'npm shopify help',\n },\n ],\n [\n // testing link wrapping behavior\n \"Press 'return' to open the really amazing and clean\",\n {\n link: {\n label: 'dev docs',\n url: 'https://shopify.dev',\n },\n },\n ],\n ],\n link: {\n label: 'Link',\n url: 'https://www.google.com',\n },\n customSections: [\n {\n title: 'Custom section',\n body: {\n list: {\n items: ['Item 1', 'Item 2', 'Item 3'],\n },\n },\n },\n {\n title: 'Custom section 2',\n body: {\n list: {\n items: ['Item 1', 'Item 2', 'Item 3'],\n },\n },\n },\n ],\n }\n\n const {lastFrame} = render(<Alert type=\"info\" {...options} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"╭─ info ───────────────────────────────────────────────────────────────────────╮\n │ │\n │ my-app initialized and ready to build. │\n │ │\n │ You can find the build files in the dist folder. │\n │ │\n │ Next steps │\n │ • Run \\`cd santorini-goods\\` │\n │ • To preview your project, run \\`npm app dev\\` │\n │ • To add extensions, run \\`npm generate extension\\` │\n │ │\n │ Reference │\n │ • Run \\`npm shopify help\\` │\n │ • Press 'return' to open the really amazing and clean dev docs [1] │\n │ │\n │ Link [2] │\n │ │\n │ Custom section │\n │ • Item 1 │\n │ • Item 2 │\n │ • Item 3 │\n │ │\n │ Custom section 2 │\n │ • Item 1 │\n │ • Item 2 │\n │ • Item 3 │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n [1] https://shopify.dev\n [2] https://www.google.com\n \"\n `)\n })\n\n test('allows passing just a body', async () => {\n const options = {\n body: 'Title',\n }\n\n const {lastFrame} = render(<Alert type=\"info\" {...options} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"╭─ info ───────────────────────────────────────────────────────────────────────╮\n │ │\n │ Title │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n \"\n `)\n })\n\n test('has the headline in bold', async () => {\n const options = {\n headline: 'Title.',\n }\n\n const {lastFrame} = render(<Alert type=\"info\" {...options} />)\n\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[2m╭─\u001b[22m info \u001b[2m───────────────────────────────────────────────────────────────────────╮\u001b[22m\n \u001b[2m│\u001b[22m \u001b[2m│\u001b[22m\n \u001b[2m│\u001b[22m \u001b[1mTitle.\u001b[22m \u001b[2m│\u001b[22m\n \u001b[2m│\u001b[22m \u001b[2m│\u001b[22m\n \u001b[2m╰──────────────────────────────────────────────────────────────────────────────╯\u001b[22m\n \"\n `)\n })\n\n test(\"footnotes a long URL written as `[label](url)` in the body so it doesn't wrap inside the banner border\", async () => {\n // Regression: a 100-char URL embedded as plain text wraps across the\n // banner border at ~78 cols, splitting the URL with │ characters and\n // making it neither clickable nor copy-pasteable. Marking the URL up\n // with `[label](url)` should place the label inline (with a `[N]`\n // anchor) and emit the URL in the post-banner footnote block.\n const longUrl =\n 'https://shopify.dev/docs/apps/build/sales-channels/channel-config-extension#specification-properties'\n const options = {\n body: `See specification requirements: [docs](${longUrl})`,\n }\n\n const {lastFrame} = render(<Alert type=\"error\" {...options} />)\n const frame = unstyled(lastFrame()!)\n\n // The URL must not appear inside the bordered box.\n const bodyLines = frame.split('\\n').filter((line) => line.startsWith('│'))\n bodyLines.forEach((line) => {\n expect(line).not.toContain(longUrl)\n })\n\n // The footnote block (rendered after the closing `╰`) must list the\n // URL. Ink wraps the long URL onto its own line when it exceeds terminal\n // width, so we assert the `[1]` anchor and the URL show up *outside* the\n // bordered box rather than as a single contiguous `[1] URL` substring.\n const closingBorderIndex = frame.indexOf('╰')\n expect(closingBorderIndex).toBeGreaterThanOrEqual(0)\n const afterBox = frame.slice(closingBorderIndex)\n expect(afterBox).toContain('[1]')\n expect(afterBox).toContain(longUrl)\n // And the body must reference the footnote.\n expect(frame).toContain('docs [1]')\n })\n})\n"]}
|
|
1
|
+
{"version":3,"file":"Alert.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Alert.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAChC,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAA;AAC1D,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAE7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,QAAQ,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;IAC3B,IAAI,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACxD,MAAM,OAAO,GAAG;YACd,QAAQ,EAAE,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAC,EAAE,iCAAiC,CAAC;YACpE,IAAI,EAAE,CAAC,qCAAqC,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,EAAE,SAAS,CAAC;YAC5E,SAAS,EAAE;gBACT;oBACE,KAAK;oBACL;wBACE,OAAO,EAAE,oBAAoB;qBAC9B;iBACF;gBACD;oBACE,8BAA8B;oBAC9B;wBACE,OAAO,EAAE,aAAa;qBACvB;iBACF;gBACD;oBACE,wBAAwB;oBACxB;wBACE,OAAO,EAAE,wBAAwB;qBAClC;iBACF;aACF;YACD,SAAS,EAAE;gBACT;oBACE,KAAK;oBACL;wBACE,OAAO,EAAE,kBAAkB;qBAC5B;iBACF;gBACD;oBACE,iCAAiC;oBACjC,qDAAqD;oBACrD;wBACE,IAAI,EA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C,kBAAkB,CAAC,CAAA;QAChD,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,OAAO,OAAO,EAAE,CAAC,CAAA;QAC5C,4CAA4C;QAC5C,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {Alert} from './Alert.js'\nimport {unstyled} from '../../../../public/node/output.js'\nimport {render} from '../../testing/ui.js'\nimport {describe, expect, test} from 'vitest'\n\nimport React from 'react'\n\ndescribe('Alert', async () => {\n test('renders correctly with all the options', async () => {\n const options = {\n headline: [{userInput: 'my-app'}, 'initialized and ready to build.'],\n body: ['You can find the build files in the', {filePath: 'dist'}, 'folder.'],\n nextSteps: [\n [\n 'Run',\n {\n command: 'cd santorini-goods',\n },\n ],\n [\n 'To preview your project, run',\n {\n command: 'npm app dev',\n },\n ],\n [\n 'To add extensions, run',\n {\n command: 'npm generate extension',\n },\n ],\n ],\n reference: [\n [\n 'Run',\n {\n command: 'npm shopify help',\n },\n ],\n [\n // testing link wrapping behavior\n \"Press 'return' to open the really amazing and clean\",\n {\n link: {\n label: 'dev docs',\n url: 'https://shopify.dev',\n },\n },\n ],\n ],\n link: {\n label: 'Link',\n url: 'https://www.google.com',\n },\n customSections: [\n {\n title: 'Custom section',\n body: {\n list: {\n items: ['Item 1', 'Item 2', 'Item 3'],\n },\n },\n },\n {\n title: 'Custom section 2',\n body: {\n list: {\n items: ['Item 1', 'Item 2', 'Item 3'],\n },\n },\n },\n ],\n }\n\n const {lastFrame} = render(<Alert type=\"info\" {...options} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"╭─ info ───────────────────────────────────────────────────────────────────────╮\n │ │\n │ my-app initialized and ready to build. │\n │ │\n │ You can find the build files in the dist folder. │\n │ │\n │ Next steps │\n │ • Run \\`cd santorini-goods\\` │\n │ • To preview your project, run \\`npm app dev\\` │\n │ • To add extensions, run \\`npm generate extension\\` │\n │ │\n │ Reference │\n │ • Run \\`npm shopify help\\` │\n │ • Press 'return' to open the really amazing and clean dev docs [1] │\n │ │\n │ Link [2] │\n │ │\n │ Custom section │\n │ • Item 1 │\n │ • Item 2 │\n │ • Item 3 │\n │ │\n │ Custom section 2 │\n │ • Item 1 │\n │ • Item 2 │\n │ • Item 3 │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n [1] https://shopify.dev\n [2] https://www.google.com\n \"\n `)\n })\n\n test('allows passing just a body', async () => {\n const options = {\n body: 'Title',\n }\n\n const {lastFrame} = render(<Alert type=\"info\" {...options} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"╭─ info ───────────────────────────────────────────────────────────────────────╮\n │ │\n │ Title │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n \"\n `)\n })\n\n test('has the headline in bold', async () => {\n const options = {\n headline: 'Title.',\n }\n\n const {lastFrame} = render(<Alert type=\"info\" {...options} />)\n\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[2m╭─\u001b[22m info \u001b[2m───────────────────────────────────────────────────────────────────────╮\u001b[22m\n \u001b[2m│\u001b[22m \u001b[2m│\u001b[22m\n \u001b[2m│\u001b[22m \u001b[1mTitle.\u001b[22m \u001b[2m│\u001b[22m\n \u001b[2m│\u001b[22m \u001b[2m│\u001b[22m\n \u001b[2m╰──────────────────────────────────────────────────────────────────────────────╯\u001b[22m\n \"\n `)\n })\n\n test(\"footnotes a long URL written as `[label](url)` in the body so it doesn't wrap inside the banner border\", async () => {\n // Regression: a 100-char URL embedded as plain text wraps across the\n // banner border at ~78 cols, splitting the URL with │ characters and\n // making it neither clickable nor copy-pasteable. Marking the URL up\n // with `[label](url)` should place the label inline (with a `[N]`\n // anchor) and emit the URL in the post-banner footnote block.\n const longUrl =\n 'https://shopify.dev/docs/apps/build/sales-channels/channel-config-extension#specification-properties'\n const options = {\n body: `See specification requirements: [docs](${longUrl})`,\n }\n\n const {lastFrame} = render(<Alert type=\"error\" {...options} />)\n const frame = unstyled(lastFrame()!)\n\n // The URL must not appear inside the bordered box.\n const bodyLines = frame.split('\\n').filter((line) => line.startsWith('│'))\n bodyLines.forEach((line) => {\n expect(line).not.toContain(longUrl)\n })\n\n // The footnote block (rendered after the closing `╰`) must list the\n // URL as a single contiguous `[1] URL` line. The footnote Box is sized to\n // the line length so Ink never hard-wraps the URL (which would insert\n // newline characters and break copy-paste/clickability); the terminal\n // soft-wraps the overflow at display time instead.\n const closingBorderIndex = frame.indexOf('╰')\n expect(closingBorderIndex).toBeGreaterThanOrEqual(0)\n const afterBox = frame.slice(closingBorderIndex)\n expect(afterBox).toContain(`[1] ${longUrl}`)\n // And the body must reference the footnote.\n expect(frame).toContain('docs [1]')\n })\n})\n"]}
|
|
@@ -18,7 +18,15 @@ const Footnotes = () => {
|
|
|
18
18
|
}
|
|
19
19
|
const links = linksContext.links.current;
|
|
20
20
|
const linkIds = Object.keys(links);
|
|
21
|
-
return linkIds.length > 0 ? (React.createElement(Box, { marginBottom: 1, marginTop: -1, flexDirection: "column" }, linkIds.map((id) =>
|
|
21
|
+
return linkIds.length > 0 ? (React.createElement(Box, { marginBottom: 1, marginTop: -1, flexDirection: "column" }, linkIds.map((id) => {
|
|
22
|
+
const line = `[${id}] ${links[id]?.url}`;
|
|
23
|
+
// Render each footnote on a Box wide enough to fit the whole line so
|
|
24
|
+
// Ink doesn't hard-wrap long URLs (which inserts newline characters and
|
|
25
|
+
// breaks copy-paste/clickability). The terminal soft-wraps the overflow
|
|
26
|
+
// at display time without mutating the underlying text.
|
|
27
|
+
return (React.createElement(Box, { key: id, width: line.length },
|
|
28
|
+
React.createElement(Text, null, line)));
|
|
29
|
+
}))) : null;
|
|
22
30
|
};
|
|
23
31
|
const BoxWithBorder = ({ type, children }) => {
|
|
24
32
|
const { twoThirds } = useLayout();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Banner.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAO,YAAY,EAAC,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAAK,EAAE,EAAoB,UAAU,EAAE,MAAM,EAAC,MAAM,OAAO,CAAA;AASlE,SAAS,WAAW,CAAC,IAAyB;IAC5C,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,KAAK;QACX,cAAc,EAAE,KAAK;KACtB,CAAC,IAAI,CAAC,CAAA;AACT,CAAC;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC,CAAA;IAE7C,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QACjE,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,CAAA;IACxC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAElC,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAC1B,oBAAC,GAAG,IAAC,YAAY,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,aAAa,EAAC,QAAQ,IACxD,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"Banner.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Banner.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAO,YAAY,EAAC,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAC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pC,OAAO,KAAK,CAAC,aAAa,CAAC,qBAAqB,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;IACpE,CAAC;SAAM,CAAC;QACN,OAAO,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;IAC5D,CAAC;AACH,CAAC,CAAA;AAED,OAAO,EAAC,MAAM,EAAC,CAAA","sourcesContent":["import useLayout from '../hooks/use-layout.js'\nimport {Link, LinksContext} from '../contexts/LinksContext.js'\nimport {Box, Text} from 'ink'\nimport React, {FunctionComponent, useContext, useRef} from 'react'\n\nexport type BannerType = 'success' | 'error' | 'warning' | 'info' | 'external_error'\n\ninterface BannerProps {\n type: BannerType\n children?: React.ReactNode\n}\n\nfunction typeToColor(type: BannerProps['type']) {\n return {\n success: 'green',\n error: 'red',\n warning: 'yellow',\n info: 'dim',\n external_error: 'red',\n }[type]\n}\n\nconst Footnotes = () => {\n const linksContext = useContext(LinksContext)\n\n if (linksContext === null || linksContext.links.current === null) {\n return null\n }\n\n const links = linksContext.links.current\n const linkIds = Object.keys(links)\n\n return linkIds.length > 0 ? (\n <Box marginBottom={1} marginTop={-1} flexDirection=\"column\">\n {linkIds.map((id) => {\n const line = `[${id}] ${links[id]?.url}`\n // Render each footnote on a Box wide enough to fit the whole line so\n // Ink doesn't hard-wrap long URLs (which inserts newline characters and\n // breaks copy-paste/clickability). The terminal soft-wraps the overflow\n // at display time without mutating the underlying text.\n return (\n <Box key={id} width={line.length}>\n <Text>{line}</Text>\n </Box>\n )\n })}\n </Box>\n ) : null\n}\n\nconst BoxWithBorder: FunctionComponent<BannerProps> = ({type, children}) => {\n const {twoThirds} = useLayout()\n const links = useRef<Record<string, Link>>({})\n\n return (\n <LinksContext.Provider\n value={{\n links,\n addLink: (label, url) => {\n const id: string | undefined = Object.keys(links.current).find((id) => links.current[id]!.url === url)\n if (id) {\n return id\n }\n const newId = (Object.keys(links.current).length + 1).toString()\n links.current = {\n ...links.current,\n [newId]: {label, url},\n }\n return newId\n },\n }}\n >\n <Box\n width={twoThirds}\n marginBottom={1}\n borderStyle=\"round\"\n flexDirection=\"column\"\n borderColor={typeToColor(type)}\n >\n <Box marginTop={-1} marginLeft={1}>\n <Text>{` ${type.replace(/_/g, ' ')} `}</Text>\n </Box>\n <Box flexDirection=\"column\" paddingY={1} paddingX={2} gap={1}>\n {children}\n </Box>\n </Box>\n <Footnotes />\n </LinksContext.Provider>\n )\n}\n\nconst BoxWithTopBottomLines: FunctionComponent<BannerProps> = ({type, children}) => {\n const {twoThirds} = useLayout()\n // 2 initial dashes + 2 spaces surrounding the type\n let topLineAfterTypeLength = twoThirds - 2 - type.length - 2\n if (topLineAfterTypeLength < 0) topLineAfterTypeLength = 0\n\n return (\n <Box flexDirection=\"column\" marginBottom={1} gap={1}>\n <Text>\n <Text color={typeToColor(type)}>{'─'.repeat(2)}</Text>\n <Text>{` ${type.replace(/_/g, ' ')} `}</Text>\n <Text color={typeToColor(type)}>{'─'.repeat(topLineAfterTypeLength)}</Text>\n </Text>\n\n {children}\n\n <Text color={typeToColor(type)}>{'─'.repeat(twoThirds)}</Text>\n </Box>\n )\n}\n\nconst Banner: FunctionComponent<BannerProps> = ({children, ...props}) => {\n if (props.type === 'external_error') {\n return React.createElement(BoxWithTopBottomLines, props, children)\n } else {\n return React.createElement(BoxWithBorder, props, children)\n }\n}\n\nexport {Banner}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CLI_KIT_VERSION = "4.
|
|
1
|
+
export declare const CLI_KIT_VERSION = "4.5.0";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const CLI_KIT_VERSION = '4.
|
|
1
|
+
export const CLI_KIT_VERSION = '4.5.0';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '4.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '4.5.0'\n"]}
|
|
@@ -9,9 +9,10 @@ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
|
9
9
|
* @param query - GraphQL query to execute.
|
|
10
10
|
* @param session - Shopify admin session including token and Store FQDN.
|
|
11
11
|
* @param variables - GraphQL variables to pass to the query.
|
|
12
|
+
* @param version - API version.
|
|
12
13
|
* @returns The response of the query of generic type <T>.
|
|
13
14
|
*/
|
|
14
|
-
export declare function adminRequest<T>(query: string, session: AdminSession, variables?: GraphQLVariables): Promise<T>;
|
|
15
|
+
export declare function adminRequest<T>(query: string, session: AdminSession, variables?: GraphQLVariables, version?: string): Promise<T>;
|
|
15
16
|
export interface AdminRequestOptions<TResult, TVariables extends Variables> {
|
|
16
17
|
/** GraphQL query to execute. */
|
|
17
18
|
query: TypedDocumentNode<TResult, TVariables>;
|
|
@@ -16,18 +16,19 @@ const LatestApiVersionByFQDN = new Map();
|
|
|
16
16
|
* @param query - GraphQL query to execute.
|
|
17
17
|
* @param session - Shopify admin session including token and Store FQDN.
|
|
18
18
|
* @param variables - GraphQL variables to pass to the query.
|
|
19
|
+
* @param version - API version.
|
|
19
20
|
* @returns The response of the query of generic type <T>.
|
|
20
21
|
*/
|
|
21
|
-
export async function adminRequest(query, session, variables) {
|
|
22
|
+
export async function adminRequest(query, session, variables, version) {
|
|
22
23
|
const api = 'Admin';
|
|
23
|
-
const
|
|
24
|
+
const apiVersion = version ?? (await fetchLatestSupportedApiVersion(session));
|
|
24
25
|
let storeDomain = session.storeFqdn;
|
|
25
26
|
const addedHeaders = themeAccessHeaders(session);
|
|
26
27
|
if (serviceEnvironment() === 'local') {
|
|
27
28
|
addedHeaders['x-forwarded-host'] = storeDomain;
|
|
28
29
|
storeDomain = new DevServerCore().host('app');
|
|
29
30
|
}
|
|
30
|
-
const url = adminUrl(storeDomain,
|
|
31
|
+
const url = adminUrl(storeDomain, apiVersion, session);
|
|
31
32
|
return graphqlRequest({ query, api, addedHeaders, url, token: session.token, variables });
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../../../src/public/node/api/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,iBAAiB,GAIlB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,cAAc,CAAA;AACvD,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAA;AAChD,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,oBAAoB,GACrB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAmB,YAAY,EAAC,MAAM,YAAY,CAAA;AACzD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iEAAiE,CAAA;AACjG,OAAO,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAA;AACvE,OAAO,EAAC,kBAAkB,EAAC,MAAM,0CAA0C,CAAA;AAC3E,OAAO,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAC,WAAW,EAAY,MAAM,iBAAiB,CAAA;AAItD,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAkB,CAAA;AAExD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAI,KAAa,EAAE,OAAqB,EAAE,SAA4B;IACtG,MAAM,GAAG,GAAG,OAAO,CAAA;IACnB,MAAM,OAAO,GAAG,MAAM,8BAA8B,CAAC,OAAO,CAAC,CAAA;IAC7D,IAAI,WAAW,GAAG,OAAO,C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;KACL,CAAC,CAAA;IAEF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAEpD,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE;KAChC,CAAA;AACH,CAAC","sourcesContent":["import {\n graphqlRequest,\n graphqlRequestDoc,\n GraphQLResponseOptions,\n GraphQLVariables,\n UnauthorizedHandler,\n} from './graphql.js'\nimport {AdminSession} from '../session.js'\nimport {outputContent, outputToken} from '../output.js'\nimport {AbortError, BugError} from '../error.js'\nimport {\n restRequestBody,\n restRequestHeaders,\n restRequestUrl,\n isThemeAccessSession,\n} from '../../../private/node/api/rest.js'\nimport {isNetworkError} from '../../../private/node/api.js'\nimport {RequestModeInput, shopifyFetch} from '../http.js'\nimport {PublicApiVersions} from '../../../cli/api/graphql/admin/generated/public_api_versions.js'\nimport {themeKitAccessDomain} from '../../../private/node/constants.js'\nimport {serviceEnvironment} from '../../../private/node/context/service.js'\nimport {DevServerCore} from '../vendor/dev_server/index.js'\nimport {ClientError, Variables} from 'graphql-request'\n\nimport {TypedDocumentNode} from '@graphql-typed-document-node/core'\n\nconst LatestApiVersionByFQDN = new Map<string, string>()\n\n/**\n * Executes a GraphQL query against the Admin API.\n *\n * @param query - GraphQL query to execute.\n * @param session - Shopify admin session including token and Store FQDN.\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query of generic type <T>.\n */\nexport async function adminRequest<T>(query: string, session: AdminSession, variables?: GraphQLVariables): Promise<T> {\n const api = 'Admin'\n const version = await fetchLatestSupportedApiVersion(session)\n let storeDomain = session.storeFqdn\n const addedHeaders = themeAccessHeaders(session)\n\n if (serviceEnvironment() === 'local') {\n addedHeaders['x-forwarded-host'] = storeDomain\n storeDomain = new DevServerCore().host('app')\n }\n\n const url = adminUrl(storeDomain, version, session)\n return graphqlRequest({query, api, addedHeaders, url, token: session.token, variables})\n}\n\nexport interface AdminRequestOptions<TResult, TVariables extends Variables> {\n /** GraphQL query to execute. */\n query: TypedDocumentNode<TResult, TVariables>\n /** Shopify admin session including token and Store FQDN. */\n session: AdminSession\n /** GraphQL variables to pass to the query. */\n variables?: TVariables\n /** API version. */\n version?: string\n /** Control how API responses will be handled. */\n responseOptions?: GraphQLResponseOptions<TResult>\n /** Custom request behaviour for retries and timeouts. */\n preferredBehaviour?: RequestModeInput\n}\n\n/**\n * Executes a GraphQL query against the Admin API. Uses typed documents.\n *\n * @param options - Admin request options.\n * @returns The response of the query of generic type <TResult>.\n */\nexport async function adminRequestDoc<TResult, TVariables extends Variables>(\n options: AdminRequestOptions<TResult, TVariables>,\n): Promise<TResult> {\n const {query, session, variables, version, responseOptions, preferredBehaviour} = options\n\n let apiVersion = version ?? LatestApiVersionByFQDN.get(session.storeFqdn)\n apiVersion ??= await fetchLatestSupportedApiVersion(session, preferredBehaviour)\n let storeDomain = session.storeFqdn\n const addedHeaders = themeAccessHeaders(session)\n\n if (serviceEnvironment() === 'local') {\n addedHeaders['x-forwarded-host'] = storeDomain\n storeDomain = new DevServerCore().host('app')\n }\n\n const opts = {\n url: adminUrl(storeDomain, apiVersion, session),\n api: 'Admin',\n token: session.token,\n addedHeaders,\n }\n let unauthorizedHandler: UnauthorizedHandler | undefined\n if ('refresh' in session) {\n unauthorizedHandler = {type: 'token_refresh', handler: session.refresh as () => Promise<{token: string}>}\n }\n const result = graphqlRequestDoc<TResult, TVariables>({\n ...opts,\n query,\n variables,\n responseOptions,\n unauthorizedHandler,\n preferredBehaviour,\n })\n return result\n}\n\nfunction themeAccessHeaders(session: AdminSession): Record<string, string> {\n return isThemeAccessSession(session)\n ? {'X-Shopify-Shop': session.storeFqdn, 'X-Shopify-Access-Token': session.token}\n : {}\n}\n\n/**\n * GraphQL query to retrieve the latest supported API version.\n *\n * @param session - Shopify admin session including token and Store FQDN.\n * @param preferredBehaviour - Custom request behaviour for retries and timeouts.\n * @returns - The latest supported API version.\n */\nasync function fetchLatestSupportedApiVersion(\n session: AdminSession,\n preferredBehaviour?: RequestModeInput,\n): Promise<string> {\n const apiVersions = await supportedApiVersions(session, preferredBehaviour)\n\n const latest = apiVersions.reverse()[0]!\n LatestApiVersionByFQDN.set(session.storeFqdn, latest)\n return latest\n}\n\n/**\n * GraphQL query to retrieve all supported API versions.\n *\n * @param session - Shopify admin session including token and Store FQDN.\n * @param preferredBehaviour - Custom request behaviour for retries and timeouts.\n * @returns - An array of supported API versions.\n */\nexport async function supportedApiVersions(\n session: AdminSession,\n preferredBehaviour?: RequestModeInput,\n): Promise<string[]> {\n const apiVersions = await fetchApiVersions(session, preferredBehaviour)\n return apiVersions\n .filter((item) => item.supported)\n .map((item) => item.handle)\n .sort()\n}\n\n/**\n * GraphQL query to retrieve all API versions.\n *\n * @param session - Shopify admin session including token and Store FQDN.\n * @param preferredBehaviour - Custom request behaviour for retries and timeouts.\n * @returns - An array of supported and unsupported API versions.\n */\nexport async function fetchApiVersions(\n session: AdminSession,\n preferredBehaviour?: RequestModeInput,\n): Promise<ApiVersion[]> {\n try {\n const response = await adminRequestDoc({\n query: PublicApiVersions,\n session,\n variables: {},\n version: 'unstable',\n responseOptions: {handleErrors: false},\n preferredBehaviour,\n })\n return response.publicApiVersions\n } catch (error) {\n if (error instanceof ClientError && error.response.status === 403) {\n const storeName = session.storeFqdn.replace('.myshopify.com', '')\n throw new AbortError(\n outputContent`Looks like you don't have access to this dev store: (${outputToken.link(\n storeName,\n `https://${session.storeFqdn}`,\n )})`,\n outputContent`If you're not the owner, create a dev store staff account for yourself`,\n )\n }\n if (error instanceof ClientError && (error.response.status === 401 || error.response.status === 404)) {\n throw new AbortError(\n `Error connecting to your store ${session.storeFqdn}: ${error.message} ${error.response.status} ${error.response.data}`,\n )\n }\n\n // Check for network-level errors (connection issues, timeouts, DNS failures, TLS/certificate errors, etc.)\n // All network errors should be treated as user-facing errors, not CLI bugs\n // Note: Some of these may have been retried already by lower-level retry logic\n if (isNetworkError(error)) {\n throw new AbortError(\n `Network error connecting to your store ${session.storeFqdn}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n 'Check your internet connection and try again.',\n )\n }\n\n // Unknown errors are likely bugs in the CLI\n throw new BugError(\n `Unknown error connecting to your store ${session.storeFqdn}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n )\n }\n}\n\n/**\n * Returns the Admin API URL for the given store and version.\n *\n * @param store - Store FQDN.\n * @param version - API version.\n * @param session - User session.\n * @returns - Admin API URL.\n */\nexport function adminUrl(store: string, version: string | undefined, session?: AdminSession): string {\n const realVersion = version ?? 'unstable'\n\n const url =\n session && isThemeAccessSession(session)\n ? `https://${themeKitAccessDomain}/cli/admin/api/${realVersion}/graphql.json`\n : `https://${store}/admin/api/${realVersion}/graphql.json`\n return url\n}\n\ninterface ApiVersion {\n handle: string\n supported: boolean\n}\n\n/**\n * Executes a REST request against the Admin API.\n *\n * @param method - Request's HTTP method.\n * @param path - Path of the REST resource.\n * @param session - Shopify Admin session including token and Store FQDN.\n * @param requestBody - Request body of including REST resource specific parameters.\n * @param searchParams - Search params, appended to the URL.\n * @param apiVersion - Admin API version.\n * @returns - The {@link RestResponse}.\n */\nexport async function restRequest<T>(\n method: string,\n path: string,\n session: AdminSession,\n requestBody?: T,\n searchParams: Record<string, string> = {},\n apiVersion = 'unstable',\n): Promise<RestResponse> {\n const url = restRequestUrl(session, apiVersion, path, searchParams)\n const body = restRequestBody<T>(requestBody)\n\n const headers = restRequestHeaders(session)\n const response = await shopifyFetch(url, {\n headers,\n method,\n body,\n })\n\n const json = await response.json().catch(() => ({}))\n\n return {\n json,\n status: response.status,\n headers: response.headers.raw(),\n }\n}\n\n/**\n * Respose of a REST request.\n */\nexport interface RestResponse {\n /**\n * REST JSON respose.\n */\n // Using `any` to avoid introducing extra DTO layers.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n json: any\n\n /**\n * HTTP response status.\n */\n status: number\n\n /**\n * HTTP response headers.\n */\n headers: Record<string, string[]>\n}\n"]}
|
|
1
|
+
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../../../src/public/node/api/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,iBAAiB,GAIlB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,cAAc,CAAA;AACvD,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAA;AAChD,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,oBAAoB,GACrB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAmB,YAAY,EAAC,MAAM,YAAY,CAAA;AACzD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iEAAiE,CAAA;AACjG,OAAO,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAA;AACvE,OAAO,EAAC,kBAAkB,EAAC,MAAM,0CAA0C,CAAA;AAC3E,OAAO,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAC,WAAW,EAAY,MAAM,iBAAiB,CAAA;AAItD,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAkB,CAAA;AAExD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,KAAa,EACb,OAAqB,EACrB,SAA4B,EAC5B,OAAgB;IAEhB,MAAM,GAAG,GAAG,OAAO,CAAA;IACnB,MAAM,UAAU,GAAG,OAAO,IAAI,CAAC,MAAM,8BAA8B,CAAC,OAAO,CAAC,CAAC,CAAA;IAC7E,IAAI,WAAW,GAAG,OAAO,CAAC,SAAS,CAAA;IACnC,MAAM,YAAY,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAA;IAEhD,IAAI,kBAAkB,EAAE,KAAK,OAAO,EAAE,CAAC;QACrC,Y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,CAAA;IAEpD,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE;KAChC,CAAA;AACH,CAAC","sourcesContent":["import {\n graphqlRequest,\n graphqlRequestDoc,\n GraphQLResponseOptions,\n GraphQLVariables,\n UnauthorizedHandler,\n} from './graphql.js'\nimport {AdminSession} from '../session.js'\nimport {outputContent, outputToken} from '../output.js'\nimport {AbortError, BugError} from '../error.js'\nimport {\n restRequestBody,\n restRequestHeaders,\n restRequestUrl,\n isThemeAccessSession,\n} from '../../../private/node/api/rest.js'\nimport {isNetworkError} from '../../../private/node/api.js'\nimport {RequestModeInput, shopifyFetch} from '../http.js'\nimport {PublicApiVersions} from '../../../cli/api/graphql/admin/generated/public_api_versions.js'\nimport {themeKitAccessDomain} from '../../../private/node/constants.js'\nimport {serviceEnvironment} from '../../../private/node/context/service.js'\nimport {DevServerCore} from '../vendor/dev_server/index.js'\nimport {ClientError, Variables} from 'graphql-request'\n\nimport {TypedDocumentNode} from '@graphql-typed-document-node/core'\n\nconst LatestApiVersionByFQDN = new Map<string, string>()\n\n/**\n * Executes a GraphQL query against the Admin API.\n *\n * @param query - GraphQL query to execute.\n * @param session - Shopify admin session including token and Store FQDN.\n * @param variables - GraphQL variables to pass to the query.\n * @param version - API version.\n * @returns The response of the query of generic type <T>.\n */\nexport async function adminRequest<T>(\n query: string,\n session: AdminSession,\n variables?: GraphQLVariables,\n version?: string,\n): Promise<T> {\n const api = 'Admin'\n const apiVersion = version ?? (await fetchLatestSupportedApiVersion(session))\n let storeDomain = session.storeFqdn\n const addedHeaders = themeAccessHeaders(session)\n\n if (serviceEnvironment() === 'local') {\n addedHeaders['x-forwarded-host'] = storeDomain\n storeDomain = new DevServerCore().host('app')\n }\n\n const url = adminUrl(storeDomain, apiVersion, session)\n return graphqlRequest({query, api, addedHeaders, url, token: session.token, variables})\n}\n\nexport interface AdminRequestOptions<TResult, TVariables extends Variables> {\n /** GraphQL query to execute. */\n query: TypedDocumentNode<TResult, TVariables>\n /** Shopify admin session including token and Store FQDN. */\n session: AdminSession\n /** GraphQL variables to pass to the query. */\n variables?: TVariables\n /** API version. */\n version?: string\n /** Control how API responses will be handled. */\n responseOptions?: GraphQLResponseOptions<TResult>\n /** Custom request behaviour for retries and timeouts. */\n preferredBehaviour?: RequestModeInput\n}\n\n/**\n * Executes a GraphQL query against the Admin API. Uses typed documents.\n *\n * @param options - Admin request options.\n * @returns The response of the query of generic type <TResult>.\n */\nexport async function adminRequestDoc<TResult, TVariables extends Variables>(\n options: AdminRequestOptions<TResult, TVariables>,\n): Promise<TResult> {\n const {query, session, variables, version, responseOptions, preferredBehaviour} = options\n\n let apiVersion = version ?? LatestApiVersionByFQDN.get(session.storeFqdn)\n apiVersion ??= await fetchLatestSupportedApiVersion(session, preferredBehaviour)\n let storeDomain = session.storeFqdn\n const addedHeaders = themeAccessHeaders(session)\n\n if (serviceEnvironment() === 'local') {\n addedHeaders['x-forwarded-host'] = storeDomain\n storeDomain = new DevServerCore().host('app')\n }\n\n const opts = {\n url: adminUrl(storeDomain, apiVersion, session),\n api: 'Admin',\n token: session.token,\n addedHeaders,\n }\n let unauthorizedHandler: UnauthorizedHandler | undefined\n if ('refresh' in session) {\n unauthorizedHandler = {type: 'token_refresh', handler: session.refresh as () => Promise<{token: string}>}\n }\n const result = graphqlRequestDoc<TResult, TVariables>({\n ...opts,\n query,\n variables,\n responseOptions,\n unauthorizedHandler,\n preferredBehaviour,\n })\n return result\n}\n\nfunction themeAccessHeaders(session: AdminSession): Record<string, string> {\n return isThemeAccessSession(session)\n ? {'X-Shopify-Shop': session.storeFqdn, 'X-Shopify-Access-Token': session.token}\n : {}\n}\n\n/**\n * GraphQL query to retrieve the latest supported API version.\n *\n * @param session - Shopify admin session including token and Store FQDN.\n * @param preferredBehaviour - Custom request behaviour for retries and timeouts.\n * @returns - The latest supported API version.\n */\nasync function fetchLatestSupportedApiVersion(\n session: AdminSession,\n preferredBehaviour?: RequestModeInput,\n): Promise<string> {\n const apiVersions = await supportedApiVersions(session, preferredBehaviour)\n\n const latest = apiVersions.reverse()[0]!\n LatestApiVersionByFQDN.set(session.storeFqdn, latest)\n return latest\n}\n\n/**\n * GraphQL query to retrieve all supported API versions.\n *\n * @param session - Shopify admin session including token and Store FQDN.\n * @param preferredBehaviour - Custom request behaviour for retries and timeouts.\n * @returns - An array of supported API versions.\n */\nexport async function supportedApiVersions(\n session: AdminSession,\n preferredBehaviour?: RequestModeInput,\n): Promise<string[]> {\n const apiVersions = await fetchApiVersions(session, preferredBehaviour)\n return apiVersions\n .filter((item) => item.supported)\n .map((item) => item.handle)\n .sort()\n}\n\n/**\n * GraphQL query to retrieve all API versions.\n *\n * @param session - Shopify admin session including token and Store FQDN.\n * @param preferredBehaviour - Custom request behaviour for retries and timeouts.\n * @returns - An array of supported and unsupported API versions.\n */\nexport async function fetchApiVersions(\n session: AdminSession,\n preferredBehaviour?: RequestModeInput,\n): Promise<ApiVersion[]> {\n try {\n const response = await adminRequestDoc({\n query: PublicApiVersions,\n session,\n variables: {},\n version: 'unstable',\n responseOptions: {handleErrors: false},\n preferredBehaviour,\n })\n return response.publicApiVersions\n } catch (error) {\n if (error instanceof ClientError && error.response.status === 403) {\n const storeName = session.storeFqdn.replace('.myshopify.com', '')\n throw new AbortError(\n outputContent`Looks like you don't have access to this dev store: (${outputToken.link(\n storeName,\n `https://${session.storeFqdn}`,\n )})`,\n outputContent`If you're not the owner, create a dev store staff account for yourself`,\n )\n }\n if (error instanceof ClientError && (error.response.status === 401 || error.response.status === 404)) {\n throw new AbortError(\n `Error connecting to your store ${session.storeFqdn}: ${error.message} ${error.response.status} ${error.response.data}`,\n )\n }\n\n // Check for network-level errors (connection issues, timeouts, DNS failures, TLS/certificate errors, etc.)\n // All network errors should be treated as user-facing errors, not CLI bugs\n // Note: Some of these may have been retried already by lower-level retry logic\n if (isNetworkError(error)) {\n throw new AbortError(\n `Network error connecting to your store ${session.storeFqdn}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n 'Check your internet connection and try again.',\n )\n }\n\n // Unknown errors are likely bugs in the CLI\n throw new BugError(\n `Unknown error connecting to your store ${session.storeFqdn}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n )\n }\n}\n\n/**\n * Returns the Admin API URL for the given store and version.\n *\n * @param store - Store FQDN.\n * @param version - API version.\n * @param session - User session.\n * @returns - Admin API URL.\n */\nexport function adminUrl(store: string, version: string | undefined, session?: AdminSession): string {\n const realVersion = version ?? 'unstable'\n\n const url =\n session && isThemeAccessSession(session)\n ? `https://${themeKitAccessDomain}/cli/admin/api/${realVersion}/graphql.json`\n : `https://${store}/admin/api/${realVersion}/graphql.json`\n return url\n}\n\ninterface ApiVersion {\n handle: string\n supported: boolean\n}\n\n/**\n * Executes a REST request against the Admin API.\n *\n * @param method - Request's HTTP method.\n * @param path - Path of the REST resource.\n * @param session - Shopify Admin session including token and Store FQDN.\n * @param requestBody - Request body of including REST resource specific parameters.\n * @param searchParams - Search params, appended to the URL.\n * @param apiVersion - Admin API version.\n * @returns - The {@link RestResponse}.\n */\nexport async function restRequest<T>(\n method: string,\n path: string,\n session: AdminSession,\n requestBody?: T,\n searchParams: Record<string, string> = {},\n apiVersion = 'unstable',\n): Promise<RestResponse> {\n const url = restRequestUrl(session, apiVersion, path, searchParams)\n const body = restRequestBody<T>(requestBody)\n\n const headers = restRequestHeaders(session)\n const response = await shopifyFetch(url, {\n headers,\n method,\n body,\n })\n\n const json = await response.json().catch(() => ({}))\n\n return {\n json,\n status: response.status,\n headers: response.headers.raw(),\n }\n}\n\n/**\n * Respose of a REST request.\n */\nexport interface RestResponse {\n /**\n * REST JSON respose.\n */\n // Using `any` to avoid introducing extra DTO layers.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n json: any\n\n /**\n * HTTP response status.\n */\n status: number\n\n /**\n * HTTP response headers.\n */\n headers: Record<string, string[]>\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AdminSession } from '../../session.js';
|
|
2
|
+
import { BulkOperationCancelMutation } from '../../../../cli/api/graphql/bulk-operations/generated/bulk-operation-cancel.js';
|
|
3
|
+
interface CancelBulkOperationOptions {
|
|
4
|
+
adminSession: AdminSession;
|
|
5
|
+
operationId: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Requests cancellation of a bulk operation.
|
|
10
|
+
*
|
|
11
|
+
* @param options - The admin session, operation ID, and optional API version.
|
|
12
|
+
* @returns The bulkOperationCancel result, including any user errors.
|
|
13
|
+
*/
|
|
14
|
+
export declare function cancelBulkOperationRequest(options: CancelBulkOperationOptions): Promise<BulkOperationCancelMutation['bulkOperationCancel']>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BULK_OPERATIONS_MIN_API_VERSION } from './constants.js';
|
|
2
|
+
import { adminRequestDoc } from '../admin.js';
|
|
3
|
+
import { BulkOperationCancel, } from '../../../../cli/api/graphql/bulk-operations/generated/bulk-operation-cancel.js';
|
|
4
|
+
/**
|
|
5
|
+
* Requests cancellation of a bulk operation.
|
|
6
|
+
*
|
|
7
|
+
* @param options - The admin session, operation ID, and optional API version.
|
|
8
|
+
* @returns The bulkOperationCancel result, including any user errors.
|
|
9
|
+
*/
|
|
10
|
+
export async function cancelBulkOperationRequest(options) {
|
|
11
|
+
const { adminSession, operationId, version } = options;
|
|
12
|
+
const response = await adminRequestDoc({
|
|
13
|
+
query: BulkOperationCancel,
|
|
14
|
+
session: adminSession,
|
|
15
|
+
variables: { id: operationId },
|
|
16
|
+
version: version ?? BULK_OPERATIONS_MIN_API_VERSION,
|
|
17
|
+
});
|
|
18
|
+
return response.bulkOperationCancel;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=cancel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../../../src/public/node/api/bulk-operations/cancel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,+BAA+B,EAAC,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAA;AAE3C,OAAO,EACL,mBAAmB,GAGpB,MAAM,gFAAgF,CAAA;AAQvF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,OAAmC;IAEnC,MAAM,EAAC,YAAY,EAAE,WAAW,EAAE,OAAO,EAAC,GAAG,OAAO,CAAA;IAEpD,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAoE;QACxG,KAAK,EAAE,mBAAmB;QAC1B,OAAO,EAAE,YAAY;QACrB,SAAS,EAAE,EAAC,EAAE,EAAE,WAAW,EAAC;QAC5B,OAAO,EAAE,OAAO,IAAI,+BAA+B;KACpD,CAAC,CAAA;IAEF,OAAO,QAAQ,CAAC,mBAAmB,CAAA;AACrC,CAAC","sourcesContent":["import {BULK_OPERATIONS_MIN_API_VERSION} from './constants.js'\nimport {adminRequestDoc} from '../admin.js'\nimport {AdminSession} from '../../session.js'\nimport {\n BulkOperationCancel,\n BulkOperationCancelMutation,\n BulkOperationCancelMutationVariables,\n} from '../../../../cli/api/graphql/bulk-operations/generated/bulk-operation-cancel.js'\n\ninterface CancelBulkOperationOptions {\n adminSession: AdminSession\n operationId: string\n version?: string\n}\n\n/**\n * Requests cancellation of a bulk operation.\n *\n * @param options - The admin session, operation ID, and optional API version.\n * @returns The bulkOperationCancel result, including any user errors.\n */\nexport async function cancelBulkOperationRequest(\n options: CancelBulkOperationOptions,\n): Promise<BulkOperationCancelMutation['bulkOperationCancel']> {\n const {adminSession, operationId, version} = options\n\n const response = await adminRequestDoc<BulkOperationCancelMutation, BulkOperationCancelMutationVariables>({\n query: BulkOperationCancel,\n session: adminSession,\n variables: {id: operationId},\n version: version ?? BULK_OPERATIONS_MIN_API_VERSION,\n })\n\n return response.bulkOperationCancel\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/public/node/api/bulk-operations/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,SAAS,CAAA","sourcesContent":["/**\n * Minimum API version for bulk operations.\n * This ensures bulk operation features work correctly across all operations.\n */\nexport const BULK_OPERATIONS_MIN_API_VERSION = '2026-01'\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Downloads the results of a completed bulk operation.
|
|
3
|
+
*
|
|
4
|
+
* @param url - The results URL returned by the Admin API.
|
|
5
|
+
* @returns The raw JSONL results as a string.
|
|
6
|
+
*/
|
|
7
|
+
export declare function downloadBulkOperationResults(url: string): Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Checks whether any line of a JSONL bulk operation result reports GraphQL user errors.
|
|
10
|
+
*
|
|
11
|
+
* Blank result files, such as a completed operation that matched nothing, are treated as having
|
|
12
|
+
* no user errors instead of crashing the JSON parser.
|
|
13
|
+
*
|
|
14
|
+
* @param results - The raw JSONL results string.
|
|
15
|
+
* @returns True if any result line reports user errors.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resultsContainUserErrors(results: string): boolean;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { fetch } from '../../http.js';
|
|
2
|
+
import { AbortError } from '../../error.js';
|
|
3
|
+
/**
|
|
4
|
+
* Downloads the results of a completed bulk operation.
|
|
5
|
+
*
|
|
6
|
+
* @param url - The results URL returned by the Admin API.
|
|
7
|
+
* @returns The raw JSONL results as a string.
|
|
8
|
+
*/
|
|
9
|
+
export async function downloadBulkOperationResults(url) {
|
|
10
|
+
const response = await fetch(url);
|
|
11
|
+
if (!response.ok) {
|
|
12
|
+
throw new AbortError(`Failed to download bulk operation results: ${response.statusText}`);
|
|
13
|
+
}
|
|
14
|
+
return response.text();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Checks whether any line of a JSONL bulk operation result reports GraphQL user errors.
|
|
18
|
+
*
|
|
19
|
+
* Blank result files, such as a completed operation that matched nothing, are treated as having
|
|
20
|
+
* no user errors instead of crashing the JSON parser.
|
|
21
|
+
*
|
|
22
|
+
* @param results - The raw JSONL results string.
|
|
23
|
+
* @returns True if any result line reports user errors.
|
|
24
|
+
*/
|
|
25
|
+
export function resultsContainUserErrors(results) {
|
|
26
|
+
const lines = results
|
|
27
|
+
.trim()
|
|
28
|
+
.split('\n')
|
|
29
|
+
.filter((line) => line.trim().length > 0);
|
|
30
|
+
return lines.some((line) => {
|
|
31
|
+
let parsed;
|
|
32
|
+
try {
|
|
33
|
+
parsed = JSON.parse(line);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
// A single malformed line (truncated download, partial flush, etc.) shouldn't dictate the
|
|
37
|
+
// overall result; skip it rather than throwing an uncontextualized SyntaxError.
|
|
38
|
+
if (error instanceof SyntaxError)
|
|
39
|
+
return false;
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
if (!parsed.data)
|
|
43
|
+
return false;
|
|
44
|
+
const result = Object.values(parsed.data)[0];
|
|
45
|
+
return result?.userErrors !== undefined && result.userErrors.length > 0;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=download-bulk-operation-results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download-bulk-operation-results.js","sourceRoot":"","sources":["../../../../../src/public/node/api/bulk-operations/download-bulk-operation-results.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAA;AACnC,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAA;AAEzC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,GAAW;IAC5D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;IAEjC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,UAAU,CAAC,8CAA8C,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;IAC3F,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;AACxB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAe;IACtD,MAAM,KAAK,GAAG,OAAO;SAClB,IAAI,EAAE;SACN,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAE3C,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QACzB,IAAI,MAAM,CAAA;QACV,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,0FAA0F;YAC1F,gFAAgF;YAChF,IAAI,KAAK,YAAY,WAAW;gBAAE,OAAO,KAAK,CAAA;YAC9C,MAAM,KAAK,CAAA;QACb,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,IAAI;YAAE,OAAO,KAAK,CAAA;QAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAyC,CAAA;QACpF,OAAO,MAAM,EAAE,UAAU,KAAK,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAA;IACzE,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {fetch} from '../../http.js'\nimport {AbortError} from '../../error.js'\n\n/**\n * Downloads the results of a completed bulk operation.\n *\n * @param url - The results URL returned by the Admin API.\n * @returns The raw JSONL results as a string.\n */\nexport async function downloadBulkOperationResults(url: string): Promise<string> {\n const response = await fetch(url)\n\n if (!response.ok) {\n throw new AbortError(`Failed to download bulk operation results: ${response.statusText}`)\n }\n\n return response.text()\n}\n\n/**\n * Checks whether any line of a JSONL bulk operation result reports GraphQL user errors.\n *\n * Blank result files, such as a completed operation that matched nothing, are treated as having\n * no user errors instead of crashing the JSON parser.\n *\n * @param results - The raw JSONL results string.\n * @returns True if any result line reports user errors.\n */\nexport function resultsContainUserErrors(results: string): boolean {\n const lines = results\n .trim()\n .split('\\n')\n .filter((line) => line.trim().length > 0)\n\n return lines.some((line) => {\n let parsed\n try {\n parsed = JSON.parse(line)\n } catch (error) {\n // A single malformed line (truncated download, partial flush, etc.) shouldn't dictate the\n // overall result; skip it rather than throwing an uncontextualized SyntaxError.\n if (error instanceof SyntaxError) return false\n throw error\n }\n if (!parsed.data) return false\n const result = Object.values(parsed.data)[0] as {userErrors?: unknown[]} | undefined\n return result?.userErrors !== undefined && result.userErrors.length > 0\n })\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AdminSession } from '../../session.js';
|
|
2
|
+
import { GetBulkOperationByIdQuery } from '../../../../cli/api/graphql/bulk-operations/generated/get-bulk-operation-by-id.js';
|
|
3
|
+
import { ListBulkOperationsQuery } from '../../../../cli/api/graphql/bulk-operations/generated/list-bulk-operations.js';
|
|
4
|
+
interface FetchBulkOperationByIdOptions {
|
|
5
|
+
adminSession: AdminSession;
|
|
6
|
+
operationId: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Fetches a single bulk operation by ID.
|
|
11
|
+
*
|
|
12
|
+
* @param options - The admin session, operation ID, and optional API version.
|
|
13
|
+
* @returns The bulk operation, or null if it doesn't exist.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fetchBulkOperationById(options: FetchBulkOperationByIdOptions): Promise<GetBulkOperationByIdQuery['bulkOperation']>;
|
|
16
|
+
interface FetchRecentBulkOperationsOptions {
|
|
17
|
+
adminSession: AdminSession;
|
|
18
|
+
version?: string;
|
|
19
|
+
/** Number of days back to include. Defaults to 7. */
|
|
20
|
+
sinceDays?: number;
|
|
21
|
+
/** Maximum number of operations to return. Defaults to 100. */
|
|
22
|
+
first?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Fetches recent bulk operations for the store.
|
|
26
|
+
*
|
|
27
|
+
* @param options - The admin session, optional API version, look-back window, and page size.
|
|
28
|
+
* @returns The list of bulk operation nodes, most recent first.
|
|
29
|
+
*/
|
|
30
|
+
export declare function fetchRecentBulkOperations(options: FetchRecentBulkOperationsOptions): Promise<ListBulkOperationsQuery['bulkOperations']['nodes']>;
|
|
31
|
+
export {};
|