shop-cli 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/approvalRequired.d.ts +30 -0
- package/dist/cli/approvalRequired.js +87 -0
- package/dist/cli/errors.d.ts +4 -1
- package/dist/cli/errors.js +3 -1
- package/dist/cli/gid.d.ts +1 -1
- package/dist/cli/help/registry.js +1013 -221
- package/dist/cli/help/render.d.ts +1 -0
- package/dist/cli/help/render.js +47 -0
- package/dist/cli/parse-command.d.ts +18 -0
- package/dist/cli/parse-command.js +109 -0
- package/dist/cli/router.js +3 -0
- package/dist/cli/suggest.d.ts +5 -0
- package/dist/cli/suggest.js +88 -0
- package/dist/cli/verbs/_shared.d.ts +1 -1
- package/dist/cli/verbs/_shared.js +4 -3
- package/dist/cli/verbs/catalogs.js +1 -1
- package/dist/cli/verbs/checkout-branding.js +2 -2
- package/dist/cli/verbs/collections.js +147 -12
- package/dist/cli/verbs/companies.js +2 -2
- package/dist/cli/verbs/company-contacts.js +8 -4
- package/dist/cli/verbs/company-locations.js +1 -1
- package/dist/cli/verbs/customers.js +156 -19
- package/dist/cli/verbs/discounts-automatic.js +36 -10
- package/dist/cli/verbs/discounts-code.js +27 -10
- package/dist/cli/verbs/draft-orders.js +49 -3
- package/dist/cli/verbs/files.js +171 -55
- package/dist/cli/verbs/fulfillment-orders.js +19 -4
- package/dist/cli/verbs/fulfillments.js +8 -2
- package/dist/cli/verbs/graphql.js +2 -0
- package/dist/cli/verbs/inventory.js +7 -1
- package/dist/cli/verbs/marketing-activities.js +1 -1
- package/dist/cli/verbs/markets.js +37 -4
- package/dist/cli/verbs/metaobjects.js +10 -1
- package/dist/cli/verbs/orders.js +80 -8
- package/dist/cli/verbs/product-variants.js +67 -16
- package/dist/cli/verbs/products.js +1263 -211
- package/dist/cli/verbs/selling-plan-groups.js +32 -10
- package/dist/cli/verbs/subscription-contracts.js +1 -0
- package/dist/cli/verbs/themes.js +18 -0
- package/dist/cli/verbs/url-redirects.js +64 -6
- package/dist/cli/workflows/files/stagedUploads.d.ts +3 -3
- package/dist/cli/workflows/files/stagedUploads.js +71 -19
- package/dist/cli/workflows/files/stdinFile.d.ts +7 -0
- package/dist/cli/workflows/files/stdinFile.js +65 -0
- package/dist/cli/workflows/files/urlDownloads.d.ts +14 -0
- package/dist/cli/workflows/files/urlDownloads.js +114 -0
- package/dist/cli/workflows/files/waitForReady.d.ts +20 -0
- package/dist/cli/workflows/files/waitForReady.js +114 -0
- package/dist/cli.js +115 -29
- package/package.json +3 -2
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { OutputFormat } from './output';
|
|
2
|
+
type ApprovalRequiredAction = Record<string, unknown> & {
|
|
3
|
+
type?: unknown;
|
|
4
|
+
status?: unknown;
|
|
5
|
+
id?: unknown;
|
|
6
|
+
executed?: unknown;
|
|
7
|
+
contentType?: unknown;
|
|
8
|
+
body?: unknown;
|
|
9
|
+
};
|
|
10
|
+
export type ApprovalRequiredInfo = {
|
|
11
|
+
code: 'APPROVAL_REQUIRED' | 'ACTION_REQUIRED';
|
|
12
|
+
action: ApprovalRequiredAction;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Generic GraphQL proxy contract for deferred execution.
|
|
16
|
+
*
|
|
17
|
+
* When a proxy requires human approval before executing an operation, it may return a
|
|
18
|
+
* standard GraphQL response with an `errors[]` entry that includes:
|
|
19
|
+
* - `error.extensions.code === "APPROVAL_REQUIRED"` (also accepts "ACTION_REQUIRED")
|
|
20
|
+
* - `error.extensions.action` describing the approval workflow
|
|
21
|
+
*
|
|
22
|
+
* In this case, the operation has NOT executed yet. shop-cli surfaces a purpose-built
|
|
23
|
+
* error payload and exits with code 3.
|
|
24
|
+
*/
|
|
25
|
+
export declare const findApprovalRequired: (errors: unknown[] | undefined | null) => ApprovalRequiredInfo | undefined;
|
|
26
|
+
export declare const maybeThrowApprovalRequired: ({ format, errors, }: {
|
|
27
|
+
format: OutputFormat;
|
|
28
|
+
errors: unknown[] | undefined | null;
|
|
29
|
+
}) => void;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var approvalRequired_exports = {};
|
|
20
|
+
__export(approvalRequired_exports, {
|
|
21
|
+
findApprovalRequired: () => findApprovalRequired,
|
|
22
|
+
maybeThrowApprovalRequired: () => maybeThrowApprovalRequired
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(approvalRequired_exports);
|
|
25
|
+
var import_output = require("./output");
|
|
26
|
+
var import_errors = require("./errors");
|
|
27
|
+
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28
|
+
const findApprovalRequired = (errors) => {
|
|
29
|
+
if (!Array.isArray(errors)) return void 0;
|
|
30
|
+
for (const err of errors) {
|
|
31
|
+
if (!isPlainObject(err)) continue;
|
|
32
|
+
const extensions = err.extensions;
|
|
33
|
+
if (!isPlainObject(extensions)) continue;
|
|
34
|
+
const code = extensions.code;
|
|
35
|
+
if (code !== "APPROVAL_REQUIRED" && code !== "ACTION_REQUIRED") continue;
|
|
36
|
+
const action = extensions.action;
|
|
37
|
+
if (!isPlainObject(action)) continue;
|
|
38
|
+
if (action.type !== "approval") continue;
|
|
39
|
+
if (action.status !== "pending") continue;
|
|
40
|
+
if (action.executed !== false) continue;
|
|
41
|
+
if (typeof action.id !== "string" || !action.id.trim()) continue;
|
|
42
|
+
if (typeof action.body !== "string" || !action.body.trim()) continue;
|
|
43
|
+
return { code, action };
|
|
44
|
+
}
|
|
45
|
+
return void 0;
|
|
46
|
+
};
|
|
47
|
+
const writeHumanApprovalMessage = ({ action }) => {
|
|
48
|
+
const id = String(action.id);
|
|
49
|
+
const body = typeof action.body === "string" ? action.body.trim() : "";
|
|
50
|
+
const lines = [
|
|
51
|
+
"Approval required: this operation was NOT executed yet.",
|
|
52
|
+
`Approval id: ${id}`,
|
|
53
|
+
"Execution will happen after approval is granted (out-of-band)."
|
|
54
|
+
];
|
|
55
|
+
if (body) {
|
|
56
|
+
lines.push("", body);
|
|
57
|
+
}
|
|
58
|
+
process.stderr.write(lines.join("\n").trimEnd() + "\n");
|
|
59
|
+
};
|
|
60
|
+
const maybeThrowApprovalRequired = ({
|
|
61
|
+
format,
|
|
62
|
+
errors
|
|
63
|
+
}) => {
|
|
64
|
+
const approval = findApprovalRequired(errors);
|
|
65
|
+
if (!approval) return;
|
|
66
|
+
if (format === "json" || format === "jsonl") {
|
|
67
|
+
(0, import_output.printJsonError)(
|
|
68
|
+
{
|
|
69
|
+
ok: false,
|
|
70
|
+
error: {
|
|
71
|
+
code: approval.code,
|
|
72
|
+
action: approval.action
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
format === "json"
|
|
76
|
+
);
|
|
77
|
+
} else {
|
|
78
|
+
writeHumanApprovalMessage(approval);
|
|
79
|
+
}
|
|
80
|
+
throw new import_errors.CliError("", 3, { silent: true });
|
|
81
|
+
};
|
|
82
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
+
0 && (module.exports = {
|
|
84
|
+
findApprovalRequired,
|
|
85
|
+
maybeThrowApprovalRequired
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=approvalRequired.js.map
|
package/dist/cli/errors.d.ts
CHANGED
package/dist/cli/errors.js
CHANGED
|
@@ -23,9 +23,11 @@ __export(errors_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(errors_exports);
|
|
24
24
|
class CliError extends Error {
|
|
25
25
|
exitCode;
|
|
26
|
-
|
|
26
|
+
silent;
|
|
27
|
+
constructor(message, exitCode = 1, { silent = false } = {}) {
|
|
27
28
|
super(message);
|
|
28
29
|
this.exitCode = exitCode;
|
|
30
|
+
this.silent = silent;
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/cli/gid.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type ShopifyGidType = 'AbandonedCheckout' | 'Abandonment' | 'AndroidApplication' | 'App' | 'Metafield' | 'Job' | 'Product' | 'ProductFeed' | 'ProductVariant' | 'Collection' | 'Customer' | 'CustomerPaymentMethod' | 'CustomerSegmentMembersQuery' | 'StaffMember' | 'Order' | 'OrderTransaction' | 'CalculatedOrder' | 'CalculatedLineItem' | 'CalculatedDiscountApplication' | 'CalculatedShippingLine' | 'AppInstallation' | 'AppSubscription' | 'DiscountAutomaticNode' | 'DiscountCodeNode' | 'DiscountNode' | 'DiscountRedeemCode' | 'DiscountRedeemCodeBulkCreation' | 'InventoryItem' | 'InventoryLevel' | 'InventoryShipment' | 'InventoryTransfer' | 'InventoryTransferLineItem' | 'Location' | 'FulfillmentOrder' | 'Fulfillment' | 'FulfillmentHold' | 'FulfillmentService' | 'FulfillmentConstraintRule' | 'GiftCard' | 'Return' | 'ReturnLineItem' | 'ReturnReasonDefinition' | 'ReturnableFulfillment' | 'DeliveryProfile' | 'DeliveryCustomization' | 'DeliveryCarrierService' | 'File' | 'PaymentTerms' | 'PaymentTermsTemplate' | 'PaymentSchedule' | 'PaymentMandate' | 'PaymentCustomization' | 'PriceList' | 'Publication' | 'Refund' | 'Article' | 'Blog' | 'Page' | 'Comment' | 'Event' | 'Menu' | 'Channel' | 'Catalog' | 'Market' | 'MarketRegionCountry' | 'MarketWebPresence' | 'BusinessEntity' | 'Company' | 'CompanyAddress' | 'CompanyContact' | 'CompanyContactRole' | 'CompanyContactRoleAssignment' | 'CompanyLocation' | 'CompanyLocationStaffMemberAssignment' | 'StoreCreditAccount' | 'StorefrontAccessToken' | 'DraftOrder' | 'DraftOrderTag' | 'BulkOperation' | 'UrlRedirect' | 'UrlRedirectImport' | 'Segment' | 'SavedSearch' | 'ScriptTag' | 'CartTransform' | 'Validation' | 'OnlineStoreTheme' | 'CheckoutProfile' | 'WebPixel' | 'ServerPixel' | 'MarketingActivity' | 'MarketingEvent' | 'WebhookSubscription' | 'Domain' | 'MetafieldDefinition' | 'Metaobject' | 'MetaobjectDefinition' | 'Shop' | 'MarketWebPresence' | 'SellingPlanGroup' | 'ShippingPackage' | 'ShopifyPaymentsDispute' | 'ShopifyPaymentsDisputeEvidence' | 'SubscriptionContract' | 'SubscriptionDraft' | 'SubscriptionLine' | 'SubscriptionManualDiscount' | 'SubscriptionBillingAttempt' | 'AppleApplication' | 'CashTrackingSession' | 'PointOfSaleDevice' | 'CustomerAccountPage' | 'FlowActionDefinition' | 'MailingAddress';
|
|
1
|
+
export type ShopifyGidType = 'AbandonedCheckout' | 'Abandonment' | 'AndroidApplication' | 'App' | 'Metafield' | 'Job' | 'Product' | 'ProductOption' | 'ProductOptionValue' | 'ProductFeed' | 'ProductVariant' | 'Collection' | 'Customer' | 'CustomerPaymentMethod' | 'CustomerSegmentMembersQuery' | 'StaffMember' | 'Order' | 'OrderTransaction' | 'CalculatedOrder' | 'CalculatedLineItem' | 'CalculatedDiscountApplication' | 'CalculatedShippingLine' | 'AppInstallation' | 'AppSubscription' | 'DiscountAutomaticNode' | 'DiscountCodeNode' | 'DiscountNode' | 'DiscountRedeemCode' | 'DiscountRedeemCodeBulkCreation' | 'InventoryItem' | 'InventoryLevel' | 'InventoryShipment' | 'InventoryTransfer' | 'InventoryTransferLineItem' | 'Location' | 'FulfillmentOrder' | 'Fulfillment' | 'FulfillmentHold' | 'FulfillmentService' | 'FulfillmentConstraintRule' | 'GiftCard' | 'Return' | 'ReturnLineItem' | 'ReturnReasonDefinition' | 'ReturnableFulfillment' | 'DeliveryProfile' | 'DeliveryCustomization' | 'DeliveryCarrierService' | 'File' | 'PaymentTerms' | 'PaymentTermsTemplate' | 'PaymentSchedule' | 'PaymentMandate' | 'PaymentCustomization' | 'PriceList' | 'Publication' | 'Refund' | 'Article' | 'Blog' | 'Page' | 'Comment' | 'Event' | 'Menu' | 'Channel' | 'Catalog' | 'Market' | 'MarketRegionCountry' | 'MarketWebPresence' | 'BusinessEntity' | 'Company' | 'CompanyAddress' | 'CompanyContact' | 'CompanyContactRole' | 'CompanyContactRoleAssignment' | 'CompanyLocation' | 'CompanyLocationStaffMemberAssignment' | 'StoreCreditAccount' | 'StorefrontAccessToken' | 'DraftOrder' | 'DraftOrderTag' | 'BulkOperation' | 'UrlRedirect' | 'UrlRedirectImport' | 'Segment' | 'SavedSearch' | 'ScriptTag' | 'CartTransform' | 'Validation' | 'OnlineStoreTheme' | 'CheckoutProfile' | 'WebPixel' | 'ServerPixel' | 'MarketingActivity' | 'MarketingEvent' | 'WebhookSubscription' | 'Domain' | 'MetafieldDefinition' | 'Metaobject' | 'MetaobjectDefinition' | 'Shop' | 'MarketWebPresence' | 'SellingPlanGroup' | 'ShippingPackage' | 'ShopifyPaymentsDispute' | 'ShopifyPaymentsDisputeEvidence' | 'SubscriptionContract' | 'SubscriptionDraft' | 'SubscriptionLine' | 'SubscriptionManualDiscount' | 'SubscriptionBillingAttempt' | 'AppleApplication' | 'CashTrackingSession' | 'PointOfSaleDevice' | 'CustomerAccountPage' | 'FlowActionDefinition' | 'MailingAddress';
|
|
2
2
|
export declare const isGid: (value: string) => boolean;
|
|
3
3
|
export declare const coerceGid: (value: string, type: ShopifyGidType) => string;
|