@keystrokehq/shopify 0.0.15 → 0.0.16-integration-id-canonicalization.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/README.md +14 -153
- package/dist/{schemas.d.mts → common-C2s35du9.d.mts} +3 -2
- package/dist/{schemas.mjs → common-JZyHdK6p.mjs} +3 -3
- package/dist/credential-sets/index.d.mts +2 -0
- package/dist/credential-sets/index.mjs +4 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +6 -1
- package/dist/operations/index.d.mts +2 -0
- package/dist/operations/index.mjs +3 -0
- package/dist/schemas/index.d.mts +2 -0
- package/dist/schemas/index.mjs +3 -0
- package/dist/shopify-app.credential-set-DuAYUhzY.d.mts +65 -0
- package/dist/shopify-app.credential-set-M3vKwTji.mjs +17 -0
- package/dist/shopify.credential-set-CaxST3GP.mjs +205 -0
- package/dist/update-shopify-product.operation-ByYhZggW.mjs +1972 -0
- package/dist/update-shopify-product.operation-Db_kLuJa.d.mts +2817 -0
- package/package.json +14 -69
- package/dist/_official/index.d.mts +0 -33
- package/dist/_official/index.mjs +0 -3
- package/dist/_runtime/index.d.mts +0 -56
- package/dist/_runtime/index.mjs +0 -150
- package/dist/articles.d.mts +0 -158
- package/dist/articles.mjs +0 -252
- package/dist/blogs.d.mts +0 -97
- package/dist/blogs.mjs +0 -174
- package/dist/client.d.mts +0 -22
- package/dist/client.mjs +0 -90
- package/dist/collections.d.mts +0 -121
- package/dist/collections.mjs +0 -209
- package/dist/connection.d.mts +0 -2
- package/dist/connection.mjs +0 -3
- package/dist/customers.d.mts +0 -142
- package/dist/customers.mjs +0 -225
- package/dist/events.d.mts +0 -181
- package/dist/events.mjs +0 -67
- package/dist/factory-DwZJl9JC.mjs +0 -8
- package/dist/fulfillments.d.mts +0 -89
- package/dist/fulfillments.mjs +0 -167
- package/dist/integration-B5LK_0eR.mjs +0 -63
- package/dist/integration-DrHCkXco.d.mts +0 -27
- package/dist/inventory.d.mts +0 -90
- package/dist/inventory.mjs +0 -182
- package/dist/locations.d.mts +0 -40
- package/dist/locations.mjs +0 -81
- package/dist/messaging.d.mts +0 -1
- package/dist/messaging.mjs +0 -1
- package/dist/operation-helpers-CKEDIx0o.mjs +0 -21
- package/dist/orders.d.mts +0 -213
- package/dist/orders.mjs +0 -271
- package/dist/products.d.mts +0 -139
- package/dist/products.mjs +0 -171
- package/dist/shop.d.mts +0 -16
- package/dist/shop.mjs +0 -31
package/README.md
CHANGED
|
@@ -1,35 +1,25 @@
|
|
|
1
1
|
# @keystrokehq/shopify
|
|
2
2
|
|
|
3
|
-
Shopify Admin API integration for Keystroke workflows.
|
|
3
|
+
Shopify Admin API integration for Keystroke workflows. The package follows the canonical Playbook 18 **strict** shape: credential sets and operations are discovered from source primitives, while `src/provider-apps/` retains the platform provider-app seed descriptor.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Per-store `SHOPIFY_STORE_DOMAIN` and `SHOPIFY_ACCESS_TOKEN` fields are required on the user credential set. OAuth uses shop-domain templating via `src/utils/oauth-connection.ts`. Webhook subscription helpers live in `src/utils/webhook-management.ts` (not catalog operations).
|
|
6
6
|
|
|
7
7
|
## Public Subpaths
|
|
8
8
|
|
|
9
|
-
- `@keystrokehq/shopify
|
|
10
|
-
- `@keystrokehq/shopify/
|
|
9
|
+
- `@keystrokehq/shopify` — root barrel (`credential-sets`, `operations`, `schemas`)
|
|
10
|
+
- `@keystrokehq/shopify/credential-sets`
|
|
11
|
+
- `@keystrokehq/shopify/operations`
|
|
11
12
|
- `@keystrokehq/shopify/schemas`
|
|
12
|
-
-
|
|
13
|
-
- `@keystrokehq/shopify/shop`
|
|
14
|
-
- `@keystrokehq/shopify/products`
|
|
15
|
-
- `@keystrokehq/shopify/collections`
|
|
16
|
-
- `@keystrokehq/shopify/orders`
|
|
17
|
-
- `@keystrokehq/shopify/customers`
|
|
18
|
-
- `@keystrokehq/shopify/blogs`
|
|
19
|
-
- `@keystrokehq/shopify/articles`
|
|
20
|
-
- `@keystrokehq/shopify/locations`
|
|
21
|
-
- `@keystrokehq/shopify/inventory`
|
|
22
|
-
- `@keystrokehq/shopify/fulfillments`
|
|
23
|
-
- `@keystrokehq/shopify/triggers`
|
|
13
|
+
- `catalog discovery via `src/provider-apps/`` — provider seed descriptor only
|
|
24
14
|
|
|
25
15
|
## Read Store Data
|
|
26
16
|
|
|
27
17
|
```ts
|
|
28
18
|
import { Workflow } from '@keystrokehq/core';
|
|
29
19
|
import { z } from 'zod';
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
20
|
+
import { shopifyCredentialSet } from '@keystrokehq/shopify/credential-sets';
|
|
21
|
+
import { getShopOperation } from '@keystrokehq/shopify/operations';
|
|
22
|
+
import { listProductsOperation } from '@keystrokehq/shopify/operations';
|
|
33
23
|
|
|
34
24
|
export const syncCatalog = new Workflow({
|
|
35
25
|
id: 'sync-shopify-catalog',
|
|
@@ -40,139 +30,10 @@ export const syncCatalog = new Workflow({
|
|
|
40
30
|
storeName: z.string(),
|
|
41
31
|
productCount: z.number(),
|
|
42
32
|
}),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
credentialSetId: shopify.resolvedCredentialSetId,
|
|
52
|
-
storeName: store.name,
|
|
53
|
-
productCount: products.nodes.length,
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Create Orders And Adjust Inventory
|
|
60
|
-
|
|
61
|
-
```ts
|
|
62
|
-
import { Workflow } from '@keystrokehq/core';
|
|
63
|
-
import { z } from 'zod';
|
|
64
|
-
import { createOrder } from '@keystrokehq/shopify/orders';
|
|
65
|
-
import { adjustInventoryQuantities } from '@keystrokehq/shopify/inventory';
|
|
66
|
-
|
|
67
|
-
export const backofficeWriteFlow = new Workflow({
|
|
68
|
-
id: 'shopify-backoffice-write-flow',
|
|
69
|
-
name: 'Shopify Backoffice Write Flow',
|
|
70
|
-
input: z.object({ variantId: z.string(), inventoryItemId: z.string(), locationId: z.string() }),
|
|
71
|
-
output: z.object({ queued: z.boolean() }),
|
|
72
|
-
run: async (input) => {
|
|
73
|
-
await createOrder.run({
|
|
74
|
-
currency: 'USD',
|
|
75
|
-
email: 'buyer@example.com',
|
|
76
|
-
lineItems: [
|
|
77
|
-
{
|
|
78
|
-
variantId: input.variantId,
|
|
79
|
-
quantity: 1,
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
await adjustInventoryQuantities.run({
|
|
85
|
-
reason: 'correction',
|
|
86
|
-
referenceDocumentUri: 'gid://keystroke/inventory-adjustment/docs-example',
|
|
87
|
-
changes: [
|
|
88
|
-
{
|
|
89
|
-
inventoryItemId: input.inventoryItemId,
|
|
90
|
-
locationId: input.locationId,
|
|
91
|
-
delta: -1,
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
return { queued: true };
|
|
97
|
-
},
|
|
33
|
+
steps: [
|
|
34
|
+
getShopOperation.asStep('shop'),
|
|
35
|
+
listProductsOperation.asStep('products'),
|
|
36
|
+
],
|
|
37
|
+
credentialSets: [shopifyCredentialSet],
|
|
98
38
|
});
|
|
99
39
|
```
|
|
100
|
-
|
|
101
|
-
## Bind Webhook Triggers
|
|
102
|
-
|
|
103
|
-
```ts
|
|
104
|
-
import { Workflow } from '@keystrokehq/core';
|
|
105
|
-
import { z } from 'zod';
|
|
106
|
-
import { webhooks } from '@keystrokehq/shopify/triggers';
|
|
107
|
-
|
|
108
|
-
const orderCreated = webhooks.orderCreated({
|
|
109
|
-
name: 'Shopify Order Created',
|
|
110
|
-
transform: (event) => ({
|
|
111
|
-
orderId: event.resourceId ?? event.payload.admin_graphql_api_id ?? '',
|
|
112
|
-
topic: event.topic,
|
|
113
|
-
}),
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
export const onNewShopifyOrder = new Workflow({
|
|
117
|
-
id: 'on-new-shopify-order',
|
|
118
|
-
name: 'On New Shopify Order',
|
|
119
|
-
input: z.object({
|
|
120
|
-
orderId: z.string(),
|
|
121
|
-
topic: z.literal('orders/create'),
|
|
122
|
-
}),
|
|
123
|
-
output: z.object({ ok: z.boolean() }),
|
|
124
|
-
triggers: [orderCreated],
|
|
125
|
-
run: async () => ({ ok: true }),
|
|
126
|
-
});
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Notes
|
|
130
|
-
|
|
131
|
-
- Mutating operations are marked with `needsApproval: true`.
|
|
132
|
-
- Shopify webhook helpers are direct-binding surfaces under `@keystrokehq/shopify/triggers`.
|
|
133
|
-
- Hidden `_official` and `_runtime` exports are for repo internals, not workflow authoring.
|
|
134
|
-
|
|
135
|
-
## Live Test Runbook
|
|
136
|
-
|
|
137
|
-
The Shopify package now has dedicated `test:int` coverage for every exported operation plus live webhook subscription management:
|
|
138
|
-
|
|
139
|
-
- `shop.int.test.ts`
|
|
140
|
-
- `products.int.test.ts`
|
|
141
|
-
- `collections.int.test.ts`
|
|
142
|
-
- `customers.int.test.ts`
|
|
143
|
-
- `blogs.int.test.ts`
|
|
144
|
-
- `articles.int.test.ts`
|
|
145
|
-
- `orders.int.test.ts`
|
|
146
|
-
- `inventory.int.test.ts`
|
|
147
|
-
- `locations.int.test.ts`
|
|
148
|
-
- `fulfillments.int.test.ts`
|
|
149
|
-
- `webhook-management.int.test.ts`
|
|
150
|
-
|
|
151
|
-
Set up `.env.test` with at least:
|
|
152
|
-
|
|
153
|
-
- `RUN_LIVE_INT=true`
|
|
154
|
-
- `SHOPIFY_LIVE_STORE_DOMAIN`
|
|
155
|
-
- `SHOPIFY_LIVE_ACCESS_TOKEN`
|
|
156
|
-
- `SHOPIFY_LIVE_REFRESH_TOKEN` for control-plane refresh coverage
|
|
157
|
-
- `PUBLIC_SERVER_URL` for webhook subscription coverage
|
|
158
|
-
- `KEYSTROKE_OFFICIAL_SHOPIFY_APP_ID`
|
|
159
|
-
- `KEYSTROKE_OFFICIAL_SHOPIFY_CLIENT_ID`
|
|
160
|
-
- `KEYSTROKE_OFFICIAL_SHOPIFY_CLIENT_SECRET`
|
|
161
|
-
- `KEYSTROKE_OFFICIAL_SHOPIFY_WEBHOOK_SECRET`
|
|
162
|
-
|
|
163
|
-
Recommended execution flow:
|
|
164
|
-
|
|
165
|
-
```bash
|
|
166
|
-
pnpm test:int:wiring
|
|
167
|
-
pnpm --filter @keystrokehq/shopify test:int
|
|
168
|
-
pnpm --filter @keystroke/server test:int
|
|
169
|
-
pnpm --filter @keystroke/control-plane test:int
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
Operational guidance:
|
|
173
|
-
|
|
174
|
-
- Use a dedicated disposable dev store. `orders`, `inventory`, `fulfillments`, and webhook tests are destructive by design.
|
|
175
|
-
- Keep `PUBLIC_SERVER_URL` pointed at a real public tunnel or staging URL when exercising webhook subscription or OAuth callback flows.
|
|
176
|
-
- The package test helpers try to clean up created products, collections, blogs, articles, and order-free customers automatically.
|
|
177
|
-
- Orders with fulfillment history and customers with placed orders should be treated as disposable-store artifacts rather than shared-environment fixtures.
|
|
178
|
-
- Shopify webhook subscription management requires `read_webhooks` and `write_webhooks` scopes in addition to the Admin API scopes used by the operation surface.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
//#region src/schemas.d.ts
|
|
3
|
+
//#region src/schemas/common.d.ts
|
|
4
|
+
declare const shopifyStoreDomainSchema: z.ZodString;
|
|
4
5
|
declare const shopifyCredentialsSchema: z.ZodObject<{
|
|
5
6
|
SHOPIFY_STORE_DOMAIN: z.ZodString;
|
|
6
7
|
SHOPIFY_ACCESS_TOKEN: z.ZodString;
|
|
@@ -230,4 +231,4 @@ type ShopifyFulfillment = z.infer<typeof shopifyFulfillmentSchema>;
|
|
|
230
231
|
type ShopifyBlog = z.infer<typeof shopifyBlogSchema>;
|
|
231
232
|
type ShopifyArticle = z.infer<typeof shopifyArticleSchema>;
|
|
232
233
|
//#endregion
|
|
233
|
-
export {
|
|
234
|
+
export { shopifyOrderSchema as A, shopifyInventoryItemSchema as C, shopifyMetafieldSchema as D, shopifyLocationSchema as E, shopifyStoreDomainSchema as F, shopifyUserErrorSchema as I, shopifyProductSchema as M, shopifySeoSchema as N, shopifyMoneyBagSchema as O, shopifyShopSchema as P, shopifyImageSchema as S, shopifyJobSchema as T, shopifyCredentialsSchema as _, ShopifyCustomer as a, shopifyGlobalIdSchema as b, ShopifyJob as c, ShopifyProduct as d, ShopifyShop as f, shopifyConnectionNodesSchema as g, shopifyCollectionSchema as h, ShopifyCredentialsShape as i, shopifyPageInfoSchema as j, shopifyMoneySchema as k, ShopifyLocation as l, shopifyBlogSchema as m, ShopifyBlog as n, ShopifyFulfillment as o, shopifyArticleSchema as p, ShopifyCollection as r, ShopifyInventoryLevel as s, ShopifyArticle as t, ShopifyOrder as u, shopifyCustomerSchema as v, shopifyInventoryLevelSchema as w, shopifyGraphqlErrorSchema as x, shopifyFulfillmentSchema as y };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as shopifyStoreDomainSchema } from "./integration-B5LK_0eR.mjs";
|
|
2
1
|
import { z } from "zod";
|
|
3
2
|
|
|
4
|
-
//#region src/schemas.ts
|
|
3
|
+
//#region src/schemas/common.ts
|
|
4
|
+
const shopifyStoreDomainSchema = z.string().min(1).regex(/^[a-z0-9][a-z0-9-]*\.myshopify\.com$/i, "Shopify store domain must look like \"example.myshopify.com\".");
|
|
5
5
|
const shopifyCredentialsSchema = z.object({
|
|
6
6
|
SHOPIFY_STORE_DOMAIN: shopifyStoreDomainSchema,
|
|
7
7
|
SHOPIFY_ACCESS_TOKEN: z.string().min(1)
|
|
@@ -161,4 +161,4 @@ const shopifyArticleSchema = z.object({
|
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
//#endregion
|
|
164
|
-
export {
|
|
164
|
+
export { shopifyStoreDomainSchema as C, shopifyShopSchema as S, shopifyMoneySchema as _, shopifyCredentialsSchema as a, shopifyProductSchema as b, shopifyGlobalIdSchema as c, shopifyInventoryItemSchema as d, shopifyInventoryLevelSchema as f, shopifyMoneyBagSchema as g, shopifyMetafieldSchema as h, shopifyConnectionNodesSchema as i, shopifyGraphqlErrorSchema as l, shopifyLocationSchema as m, shopifyBlogSchema as n, shopifyCustomerSchema as o, shopifyJobSchema as p, shopifyCollectionSchema as r, shopifyFulfillmentSchema as s, shopifyArticleSchema as t, shopifyImageSchema as u, shopifyOrderSchema as v, shopifyUserErrorSchema as w, shopifySeoSchema as x, shopifyPageInfoSchema as y };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { i as shopifyCredentialSet, n as shopifyAppCredentialSet, r as ShopifyCredentials, t as ShopifyAppCredentials } from "../shopify-app.credential-set-DuAYUhzY.mjs";
|
|
2
|
+
export { type ShopifyAppCredentials, type ShopifyCredentials, shopifyAppCredentialSet, shopifyCredentialSet };
|
package/dist/index.d.mts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { i as shopifyCredentialSet, n as shopifyAppCredentialSet, r as ShopifyCredentials, t as ShopifyAppCredentials } from "./shopify-app.credential-set-DuAYUhzY.mjs";
|
|
2
|
+
import { A as deleteCollectionOperation, B as cancelOrderOperation, C as getCustomerOrdersOperation, D as getArticleOperation, E as getBlogOperation, F as createFulfillmentOperation, H as addProductsToCollectionOperation, I as createCustomerOperation, L as createCollectionOperation, M as deleteArticleOperation, N as createProductOperation, O as deleteProductOperation, P as createOrderOperation, R as createBlogOperation, S as getFulfillmentOperation, T as getCollectionOperation, V as adjustInventoryQuantitiesOperation, _ as getProductOperation, a as updateArticleOperation, b as getInventoryLevelsForItemOperation, c as listOrdersOperation, d as listFulfillmentOrdersForOrderOperation, f as listCustomersOperation, g as getShopOperation, h as listArticlesOperation, i as updateBlogOperation, j as deleteBlogOperation, k as deleteCustomerOperation, l as listLocationsOperation, m as listBlogsOperation, n as updateOrderOperation, o as removeProductsFromCollectionOperation, p as listCollectionsOperation, r as updateCustomerOperation, s as listProductsOperation, t as updateProductOperation, u as listInventoryItemsOperation, v as getOrderOperation, w as getCustomerOperation, x as getInventoryItemOperation, y as getLocationOperation, z as createArticleOperation } from "./update-shopify-product.operation-Db_kLuJa.mjs";
|
|
3
|
+
import { A as shopifyOrderSchema, C as shopifyInventoryItemSchema, D as shopifyMetafieldSchema, E as shopifyLocationSchema, F as shopifyStoreDomainSchema, I as shopifyUserErrorSchema, M as shopifyProductSchema, N as shopifySeoSchema, O as shopifyMoneyBagSchema, P as shopifyShopSchema, S as shopifyImageSchema, T as shopifyJobSchema, _ as shopifyCredentialsSchema, a as ShopifyCustomer, b as shopifyGlobalIdSchema, c as ShopifyJob, d as ShopifyProduct, f as ShopifyShop, g as shopifyConnectionNodesSchema, h as shopifyCollectionSchema, i as ShopifyCredentialsShape, j as shopifyPageInfoSchema, k as shopifyMoneySchema, l as ShopifyLocation, m as shopifyBlogSchema, n as ShopifyBlog, o as ShopifyFulfillment, p as shopifyArticleSchema, r as ShopifyCollection, s as ShopifyInventoryLevel, t as ShopifyArticle, u as ShopifyOrder, v as shopifyCustomerSchema, w as shopifyInventoryLevelSchema, x as shopifyGraphqlErrorSchema, y as shopifyFulfillmentSchema } from "./common-C2s35du9.mjs";
|
|
4
|
+
export { ShopifyAppCredentials, ShopifyArticle, ShopifyBlog, ShopifyCollection, ShopifyCredentials, ShopifyCredentialsShape, ShopifyCustomer, ShopifyFulfillment, ShopifyInventoryLevel, ShopifyJob, ShopifyLocation, ShopifyOrder, ShopifyProduct, ShopifyShop, addProductsToCollectionOperation, addProductsToCollectionOperation as addProductsToCollectionTool, adjustInventoryQuantitiesOperation, adjustInventoryQuantitiesOperation as adjustInventoryQuantitiesTool, cancelOrderOperation, cancelOrderOperation as cancelOrderTool, createArticleOperation, createArticleOperation as createArticleTool, createBlogOperation, createBlogOperation as createBlogTool, createCollectionOperation, createCollectionOperation as createCollectionTool, createCustomerOperation, createCustomerOperation as createCustomerTool, createFulfillmentOperation, createFulfillmentOperation as createFulfillmentTool, createOrderOperation, createOrderOperation as createOrderTool, createProductOperation, createProductOperation as createProductTool, deleteArticleOperation, deleteArticleOperation as deleteArticleTool, deleteBlogOperation, deleteBlogOperation as deleteBlogTool, deleteCollectionOperation, deleteCollectionOperation as deleteCollectionTool, deleteCustomerOperation, deleteCustomerOperation as deleteCustomerTool, deleteProductOperation, deleteProductOperation as deleteProductTool, getArticleOperation, getArticleOperation as getArticleTool, getBlogOperation, getBlogOperation as getBlogTool, getCollectionOperation, getCollectionOperation as getCollectionTool, getCustomerOperation, getCustomerOperation as getCustomerTool, getCustomerOrdersOperation, getCustomerOrdersOperation as getCustomerOrdersTool, getFulfillmentOperation, getFulfillmentOperation as getFulfillmentTool, getInventoryItemOperation, getInventoryItemOperation as getInventoryItemTool, getInventoryLevelsForItemOperation, getInventoryLevelsForItemOperation as getInventoryLevelsForItemTool, getLocationOperation, getLocationOperation as getLocationTool, getOrderOperation, getOrderOperation as getOrderTool, getProductOperation, getProductOperation as getProductTool, getShopOperation, getShopOperation as getShopTool, listArticlesOperation, listArticlesOperation as listArticlesTool, listBlogsOperation, listBlogsOperation as listBlogsTool, listCollectionsOperation, listCollectionsOperation as listCollectionsTool, listCustomersOperation, listCustomersOperation as listCustomersTool, listFulfillmentOrdersForOrderOperation, listFulfillmentOrdersForOrderOperation as listFulfillmentOrdersForOrderTool, listInventoryItemsOperation, listInventoryItemsOperation as listInventoryItemsTool, listLocationsOperation, listLocationsOperation as listLocationsTool, listOrdersOperation, listOrdersOperation as listOrdersTool, listProductsOperation, listProductsOperation as listProductsTool, removeProductsFromCollectionOperation, removeProductsFromCollectionOperation as removeProductsFromCollectionTool, shopifyAppCredentialSet, shopifyArticleSchema, shopifyBlogSchema, shopifyCollectionSchema, shopifyConnectionNodesSchema, shopifyCredentialSet, shopifyCredentialsSchema, shopifyCustomerSchema, shopifyFulfillmentSchema, shopifyGlobalIdSchema, shopifyGraphqlErrorSchema, shopifyImageSchema, shopifyInventoryItemSchema, shopifyInventoryLevelSchema, shopifyJobSchema, shopifyLocationSchema, shopifyMetafieldSchema, shopifyMoneyBagSchema, shopifyMoneySchema, shopifyOrderSchema, shopifyPageInfoSchema, shopifyProductSchema, shopifySeoSchema, shopifyShopSchema, shopifyStoreDomainSchema, shopifyUserErrorSchema, updateArticleOperation, updateArticleOperation as updateArticleTool, updateBlogOperation, updateBlogOperation as updateBlogTool, updateCustomerOperation, updateCustomerOperation as updateCustomerTool, updateOrderOperation, updateOrderOperation as updateOrderTool, updateProductOperation, updateProductOperation as updateProductTool };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { C as shopifyStoreDomainSchema, S as shopifyShopSchema, _ as shopifyMoneySchema, a as shopifyCredentialsSchema, b as shopifyProductSchema, c as shopifyGlobalIdSchema, d as shopifyInventoryItemSchema, f as shopifyInventoryLevelSchema, g as shopifyMoneyBagSchema, h as shopifyMetafieldSchema, i as shopifyConnectionNodesSchema, l as shopifyGraphqlErrorSchema, m as shopifyLocationSchema, n as shopifyBlogSchema, o as shopifyCustomerSchema, p as shopifyJobSchema, r as shopifyCollectionSchema, s as shopifyFulfillmentSchema, t as shopifyArticleSchema, u as shopifyImageSchema, v as shopifyOrderSchema, w as shopifyUserErrorSchema, x as shopifySeoSchema, y as shopifyPageInfoSchema } from "./common-JZyHdK6p.mjs";
|
|
2
|
+
import { t as shopifyCredentialSet } from "./shopify.credential-set-CaxST3GP.mjs";
|
|
3
|
+
import { t as shopifyAppCredentialSet } from "./shopify-app.credential-set-M3vKwTji.mjs";
|
|
4
|
+
import { A as deleteCollectionOperation, B as cancelOrderOperation, C as getCustomerOrdersOperation, D as getArticleOperation, E as getBlogOperation, F as createFulfillmentOperation, H as addProductsToCollectionOperation, I as createCustomerOperation, L as createCollectionOperation, M as deleteArticleOperation, N as createProductOperation, O as deleteProductOperation, P as createOrderOperation, R as createBlogOperation, S as getFulfillmentOperation, T as getCollectionOperation, V as adjustInventoryQuantitiesOperation, _ as getProductOperation, a as updateArticleOperation, b as getInventoryLevelsForItemOperation, c as listOrdersOperation, d as listFulfillmentOrdersForOrderOperation, f as listCustomersOperation, g as getShopOperation, h as listArticlesOperation, i as updateBlogOperation, j as deleteBlogOperation, k as deleteCustomerOperation, l as listLocationsOperation, m as listBlogsOperation, n as updateOrderOperation, o as removeProductsFromCollectionOperation, p as listCollectionsOperation, r as updateCustomerOperation, s as listProductsOperation, t as updateProductOperation, u as listInventoryItemsOperation, v as getOrderOperation, w as getCustomerOperation, x as getInventoryItemOperation, y as getLocationOperation, z as createArticleOperation } from "./update-shopify-product.operation-ByYhZggW.mjs";
|
|
5
|
+
|
|
6
|
+
export { addProductsToCollectionOperation, addProductsToCollectionOperation as addProductsToCollectionTool, adjustInventoryQuantitiesOperation, adjustInventoryQuantitiesOperation as adjustInventoryQuantitiesTool, cancelOrderOperation, cancelOrderOperation as cancelOrderTool, createArticleOperation, createArticleOperation as createArticleTool, createBlogOperation, createBlogOperation as createBlogTool, createCollectionOperation, createCollectionOperation as createCollectionTool, createCustomerOperation, createCustomerOperation as createCustomerTool, createFulfillmentOperation, createFulfillmentOperation as createFulfillmentTool, createOrderOperation, createOrderOperation as createOrderTool, createProductOperation, createProductOperation as createProductTool, deleteArticleOperation, deleteArticleOperation as deleteArticleTool, deleteBlogOperation, deleteBlogOperation as deleteBlogTool, deleteCollectionOperation, deleteCollectionOperation as deleteCollectionTool, deleteCustomerOperation, deleteCustomerOperation as deleteCustomerTool, deleteProductOperation, deleteProductOperation as deleteProductTool, getArticleOperation, getArticleOperation as getArticleTool, getBlogOperation, getBlogOperation as getBlogTool, getCollectionOperation, getCollectionOperation as getCollectionTool, getCustomerOperation, getCustomerOperation as getCustomerTool, getCustomerOrdersOperation, getCustomerOrdersOperation as getCustomerOrdersTool, getFulfillmentOperation, getFulfillmentOperation as getFulfillmentTool, getInventoryItemOperation, getInventoryItemOperation as getInventoryItemTool, getInventoryLevelsForItemOperation, getInventoryLevelsForItemOperation as getInventoryLevelsForItemTool, getLocationOperation, getLocationOperation as getLocationTool, getOrderOperation, getOrderOperation as getOrderTool, getProductOperation, getProductOperation as getProductTool, getShopOperation, getShopOperation as getShopTool, listArticlesOperation, listArticlesOperation as listArticlesTool, listBlogsOperation, listBlogsOperation as listBlogsTool, listCollectionsOperation, listCollectionsOperation as listCollectionsTool, listCustomersOperation, listCustomersOperation as listCustomersTool, listFulfillmentOrdersForOrderOperation, listFulfillmentOrdersForOrderOperation as listFulfillmentOrdersForOrderTool, listInventoryItemsOperation, listInventoryItemsOperation as listInventoryItemsTool, listLocationsOperation, listLocationsOperation as listLocationsTool, listOrdersOperation, listOrdersOperation as listOrdersTool, listProductsOperation, listProductsOperation as listProductsTool, removeProductsFromCollectionOperation, removeProductsFromCollectionOperation as removeProductsFromCollectionTool, shopifyAppCredentialSet, shopifyArticleSchema, shopifyBlogSchema, shopifyCollectionSchema, shopifyConnectionNodesSchema, shopifyCredentialSet, shopifyCredentialsSchema, shopifyCustomerSchema, shopifyFulfillmentSchema, shopifyGlobalIdSchema, shopifyGraphqlErrorSchema, shopifyImageSchema, shopifyInventoryItemSchema, shopifyInventoryLevelSchema, shopifyJobSchema, shopifyLocationSchema, shopifyMetafieldSchema, shopifyMoneyBagSchema, shopifyMoneySchema, shopifyOrderSchema, shopifyPageInfoSchema, shopifyProductSchema, shopifySeoSchema, shopifyShopSchema, shopifyStoreDomainSchema, shopifyUserErrorSchema, updateArticleOperation, updateArticleOperation as updateArticleTool, updateBlogOperation, updateBlogOperation as updateBlogTool, updateCustomerOperation, updateCustomerOperation as updateCustomerTool, updateOrderOperation, updateOrderOperation as updateOrderTool, updateProductOperation, updateProductOperation as updateProductTool };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as deleteCollectionOperation, B as cancelOrderOperation, C as getCustomerOrdersOperation, D as getArticleOperation, E as getBlogOperation, F as createFulfillmentOperation, H as addProductsToCollectionOperation, I as createCustomerOperation, L as createCollectionOperation, M as deleteArticleOperation, N as createProductOperation, O as deleteProductOperation, P as createOrderOperation, R as createBlogOperation, S as getFulfillmentOperation, T as getCollectionOperation, V as adjustInventoryQuantitiesOperation, _ as getProductOperation, a as updateArticleOperation, b as getInventoryLevelsForItemOperation, c as listOrdersOperation, d as listFulfillmentOrdersForOrderOperation, f as listCustomersOperation, g as getShopOperation, h as listArticlesOperation, i as updateBlogOperation, j as deleteBlogOperation, k as deleteCustomerOperation, l as listLocationsOperation, m as listBlogsOperation, n as updateOrderOperation, o as removeProductsFromCollectionOperation, p as listCollectionsOperation, r as updateCustomerOperation, s as listProductsOperation, t as updateProductOperation, u as listInventoryItemsOperation, v as getOrderOperation, w as getCustomerOperation, x as getInventoryItemOperation, y as getLocationOperation, z as createArticleOperation } from "../update-shopify-product.operation-Db_kLuJa.mjs";
|
|
2
|
+
export { addProductsToCollectionOperation, addProductsToCollectionOperation as addProductsToCollectionTool, adjustInventoryQuantitiesOperation, adjustInventoryQuantitiesOperation as adjustInventoryQuantitiesTool, cancelOrderOperation, cancelOrderOperation as cancelOrderTool, createArticleOperation, createArticleOperation as createArticleTool, createBlogOperation, createBlogOperation as createBlogTool, createCollectionOperation, createCollectionOperation as createCollectionTool, createCustomerOperation, createCustomerOperation as createCustomerTool, createFulfillmentOperation, createFulfillmentOperation as createFulfillmentTool, createOrderOperation, createOrderOperation as createOrderTool, createProductOperation, createProductOperation as createProductTool, deleteArticleOperation, deleteArticleOperation as deleteArticleTool, deleteBlogOperation, deleteBlogOperation as deleteBlogTool, deleteCollectionOperation, deleteCollectionOperation as deleteCollectionTool, deleteCustomerOperation, deleteCustomerOperation as deleteCustomerTool, deleteProductOperation, deleteProductOperation as deleteProductTool, getArticleOperation, getArticleOperation as getArticleTool, getBlogOperation, getBlogOperation as getBlogTool, getCollectionOperation, getCollectionOperation as getCollectionTool, getCustomerOperation, getCustomerOperation as getCustomerTool, getCustomerOrdersOperation, getCustomerOrdersOperation as getCustomerOrdersTool, getFulfillmentOperation, getFulfillmentOperation as getFulfillmentTool, getInventoryItemOperation, getInventoryItemOperation as getInventoryItemTool, getInventoryLevelsForItemOperation, getInventoryLevelsForItemOperation as getInventoryLevelsForItemTool, getLocationOperation, getLocationOperation as getLocationTool, getOrderOperation, getOrderOperation as getOrderTool, getProductOperation, getProductOperation as getProductTool, getShopOperation, getShopOperation as getShopTool, listArticlesOperation, listArticlesOperation as listArticlesTool, listBlogsOperation, listBlogsOperation as listBlogsTool, listCollectionsOperation, listCollectionsOperation as listCollectionsTool, listCustomersOperation, listCustomersOperation as listCustomersTool, listFulfillmentOrdersForOrderOperation, listFulfillmentOrdersForOrderOperation as listFulfillmentOrdersForOrderTool, listInventoryItemsOperation, listInventoryItemsOperation as listInventoryItemsTool, listLocationsOperation, listLocationsOperation as listLocationsTool, listOrdersOperation, listOrdersOperation as listOrdersTool, listProductsOperation, listProductsOperation as listProductsTool, removeProductsFromCollectionOperation, removeProductsFromCollectionOperation as removeProductsFromCollectionTool, updateArticleOperation, updateArticleOperation as updateArticleTool, updateBlogOperation, updateBlogOperation as updateBlogTool, updateCustomerOperation, updateCustomerOperation as updateCustomerTool, updateOrderOperation, updateOrderOperation as updateOrderTool, updateProductOperation, updateProductOperation as updateProductTool };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { A as deleteCollectionOperation, B as cancelOrderOperation, C as getCustomerOrdersOperation, D as getArticleOperation, E as getBlogOperation, F as createFulfillmentOperation, H as addProductsToCollectionOperation, I as createCustomerOperation, L as createCollectionOperation, M as deleteArticleOperation, N as createProductOperation, O as deleteProductOperation, P as createOrderOperation, R as createBlogOperation, S as getFulfillmentOperation, T as getCollectionOperation, V as adjustInventoryQuantitiesOperation, _ as getProductOperation, a as updateArticleOperation, b as getInventoryLevelsForItemOperation, c as listOrdersOperation, d as listFulfillmentOrdersForOrderOperation, f as listCustomersOperation, g as getShopOperation, h as listArticlesOperation, i as updateBlogOperation, j as deleteBlogOperation, k as deleteCustomerOperation, l as listLocationsOperation, m as listBlogsOperation, n as updateOrderOperation, o as removeProductsFromCollectionOperation, p as listCollectionsOperation, r as updateCustomerOperation, s as listProductsOperation, t as updateProductOperation, u as listInventoryItemsOperation, v as getOrderOperation, w as getCustomerOperation, x as getInventoryItemOperation, y as getLocationOperation, z as createArticleOperation } from "../update-shopify-product.operation-ByYhZggW.mjs";
|
|
2
|
+
|
|
3
|
+
export { addProductsToCollectionOperation, addProductsToCollectionOperation as addProductsToCollectionTool, adjustInventoryQuantitiesOperation, adjustInventoryQuantitiesOperation as adjustInventoryQuantitiesTool, cancelOrderOperation, cancelOrderOperation as cancelOrderTool, createArticleOperation, createArticleOperation as createArticleTool, createBlogOperation, createBlogOperation as createBlogTool, createCollectionOperation, createCollectionOperation as createCollectionTool, createCustomerOperation, createCustomerOperation as createCustomerTool, createFulfillmentOperation, createFulfillmentOperation as createFulfillmentTool, createOrderOperation, createOrderOperation as createOrderTool, createProductOperation, createProductOperation as createProductTool, deleteArticleOperation, deleteArticleOperation as deleteArticleTool, deleteBlogOperation, deleteBlogOperation as deleteBlogTool, deleteCollectionOperation, deleteCollectionOperation as deleteCollectionTool, deleteCustomerOperation, deleteCustomerOperation as deleteCustomerTool, deleteProductOperation, deleteProductOperation as deleteProductTool, getArticleOperation, getArticleOperation as getArticleTool, getBlogOperation, getBlogOperation as getBlogTool, getCollectionOperation, getCollectionOperation as getCollectionTool, getCustomerOperation, getCustomerOperation as getCustomerTool, getCustomerOrdersOperation, getCustomerOrdersOperation as getCustomerOrdersTool, getFulfillmentOperation, getFulfillmentOperation as getFulfillmentTool, getInventoryItemOperation, getInventoryItemOperation as getInventoryItemTool, getInventoryLevelsForItemOperation, getInventoryLevelsForItemOperation as getInventoryLevelsForItemTool, getLocationOperation, getLocationOperation as getLocationTool, getOrderOperation, getOrderOperation as getOrderTool, getProductOperation, getProductOperation as getProductTool, getShopOperation, getShopOperation as getShopTool, listArticlesOperation, listArticlesOperation as listArticlesTool, listBlogsOperation, listBlogsOperation as listBlogsTool, listCollectionsOperation, listCollectionsOperation as listCollectionsTool, listCustomersOperation, listCustomersOperation as listCustomersTool, listFulfillmentOrdersForOrderOperation, listFulfillmentOrdersForOrderOperation as listFulfillmentOrdersForOrderTool, listInventoryItemsOperation, listInventoryItemsOperation as listInventoryItemsTool, listLocationsOperation, listLocationsOperation as listLocationsTool, listOrdersOperation, listOrdersOperation as listOrdersTool, listProductsOperation, listProductsOperation as listProductsTool, removeProductsFromCollectionOperation, removeProductsFromCollectionOperation as removeProductsFromCollectionTool, updateArticleOperation, updateArticleOperation as updateArticleTool, updateBlogOperation, updateBlogOperation as updateBlogTool, updateCustomerOperation, updateCustomerOperation as updateCustomerTool, updateOrderOperation, updateOrderOperation as updateOrderTool, updateProductOperation, updateProductOperation as updateProductTool };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as shopifyOrderSchema, C as shopifyInventoryItemSchema, D as shopifyMetafieldSchema, E as shopifyLocationSchema, F as shopifyStoreDomainSchema, I as shopifyUserErrorSchema, M as shopifyProductSchema, N as shopifySeoSchema, O as shopifyMoneyBagSchema, P as shopifyShopSchema, S as shopifyImageSchema, T as shopifyJobSchema, _ as shopifyCredentialsSchema, a as ShopifyCustomer, b as shopifyGlobalIdSchema, c as ShopifyJob, d as ShopifyProduct, f as ShopifyShop, g as shopifyConnectionNodesSchema, h as shopifyCollectionSchema, i as ShopifyCredentialsShape, j as shopifyPageInfoSchema, k as shopifyMoneySchema, l as ShopifyLocation, m as shopifyBlogSchema, n as ShopifyBlog, o as ShopifyFulfillment, p as shopifyArticleSchema, r as ShopifyCollection, s as ShopifyInventoryLevel, t as ShopifyArticle, u as ShopifyOrder, v as shopifyCustomerSchema, w as shopifyInventoryLevelSchema, x as shopifyGraphqlErrorSchema, y as shopifyFulfillmentSchema } from "../common-C2s35du9.mjs";
|
|
2
|
+
export { ShopifyArticle, ShopifyBlog, ShopifyCollection, ShopifyCredentialsShape, ShopifyCustomer, ShopifyFulfillment, ShopifyInventoryLevel, ShopifyJob, ShopifyLocation, ShopifyOrder, ShopifyProduct, ShopifyShop, shopifyArticleSchema, shopifyBlogSchema, shopifyCollectionSchema, shopifyConnectionNodesSchema, shopifyCredentialsSchema, shopifyCustomerSchema, shopifyFulfillmentSchema, shopifyGlobalIdSchema, shopifyGraphqlErrorSchema, shopifyImageSchema, shopifyInventoryItemSchema, shopifyInventoryLevelSchema, shopifyJobSchema, shopifyLocationSchema, shopifyMetafieldSchema, shopifyMoneyBagSchema, shopifyMoneySchema, shopifyOrderSchema, shopifyPageInfoSchema, shopifyProductSchema, shopifySeoSchema, shopifyShopSchema, shopifyStoreDomainSchema, shopifyUserErrorSchema };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { C as shopifyStoreDomainSchema, S as shopifyShopSchema, _ as shopifyMoneySchema, a as shopifyCredentialsSchema, b as shopifyProductSchema, c as shopifyGlobalIdSchema, d as shopifyInventoryItemSchema, f as shopifyInventoryLevelSchema, g as shopifyMoneyBagSchema, h as shopifyMetafieldSchema, i as shopifyConnectionNodesSchema, l as shopifyGraphqlErrorSchema, m as shopifyLocationSchema, n as shopifyBlogSchema, o as shopifyCustomerSchema, p as shopifyJobSchema, r as shopifyCollectionSchema, s as shopifyFulfillmentSchema, t as shopifyArticleSchema, u as shopifyImageSchema, v as shopifyOrderSchema, w as shopifyUserErrorSchema, x as shopifySeoSchema, y as shopifyPageInfoSchema } from "../common-JZyHdK6p.mjs";
|
|
2
|
+
|
|
3
|
+
export { shopifyArticleSchema, shopifyBlogSchema, shopifyCollectionSchema, shopifyConnectionNodesSchema, shopifyCredentialsSchema, shopifyCustomerSchema, shopifyFulfillmentSchema, shopifyGlobalIdSchema, shopifyGraphqlErrorSchema, shopifyImageSchema, shopifyInventoryItemSchema, shopifyInventoryLevelSchema, shopifyJobSchema, shopifyLocationSchema, shopifyMetafieldSchema, shopifyMoneyBagSchema, shopifyMoneySchema, shopifyOrderSchema, shopifyPageInfoSchema, shopifyProductSchema, shopifySeoSchema, shopifyShopSchema, shopifyStoreDomainSchema, shopifyUserErrorSchema };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CredentialSet } from "@keystrokehq/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
|
|
4
|
+
import { InferCredentialSetAuth } from "@keystrokehq/core/credential-set";
|
|
5
|
+
|
|
6
|
+
//#region src/credential-sets/shopify.credential-set.d.ts
|
|
7
|
+
declare const shopifyCredentialSet: CredentialSet<"shopify", z.ZodObject<{
|
|
8
|
+
SHOPIFY_STORE_DOMAIN: z.ZodString;
|
|
9
|
+
SHOPIFY_ACCESS_TOKEN: z.ZodString;
|
|
10
|
+
}, z.core.$strip>, {
|
|
11
|
+
kind: "oauth";
|
|
12
|
+
tokenType: "refreshable";
|
|
13
|
+
authUrl: "https://{shop}.myshopify.com/admin/oauth/authorize";
|
|
14
|
+
tokenUrl: "https://{shop}.myshopify.com/admin/oauth/access_token";
|
|
15
|
+
revokeUrl: null;
|
|
16
|
+
scopes: readonly ["read_products", "write_products", "read_orders", "write_orders", "read_customers", "write_customers", "read_inventory", "write_inventory", "read_locations", "read_fulfillments", "write_fulfillments", "read_content", "write_content", "read_webhooks", "write_webhooks"];
|
|
17
|
+
vault: {
|
|
18
|
+
readonly accessToken: "SHOPIFY_ACCESS_TOKEN";
|
|
19
|
+
readonly raw: {
|
|
20
|
+
readonly SHOPIFY_STORE_DOMAIN: "_shopifyShopDomain";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
buildAuthUrl: ({
|
|
24
|
+
oauthClient,
|
|
25
|
+
redirectUri,
|
|
26
|
+
state,
|
|
27
|
+
connection,
|
|
28
|
+
initiateInput,
|
|
29
|
+
requestedScopes
|
|
30
|
+
}: _keystrokehq_core_credential_set0.BuildAuthUrlContext) => string;
|
|
31
|
+
exchangeCode: ({
|
|
32
|
+
oauthClient,
|
|
33
|
+
code,
|
|
34
|
+
queryParams
|
|
35
|
+
}: _keystrokehq_core_credential_set0.ExchangeCodeContext) => Promise<_keystrokehq_core_credential_set0.TokenResult>;
|
|
36
|
+
refreshToken: ({
|
|
37
|
+
oauthClient,
|
|
38
|
+
refreshToken
|
|
39
|
+
}: _keystrokehq_core_credential_set0.RefreshTokenContext) => Promise<_keystrokehq_core_credential_set0.TokenResult>;
|
|
40
|
+
extractInstallationInfo: ({
|
|
41
|
+
tokenResult
|
|
42
|
+
}: _keystrokehq_core_credential_set0.ExtractInstallationContext) => {
|
|
43
|
+
externalInstallationId: string | undefined;
|
|
44
|
+
externalWorkspaceId: string | undefined;
|
|
45
|
+
metadata: {
|
|
46
|
+
shopDomain: string;
|
|
47
|
+
} | undefined;
|
|
48
|
+
};
|
|
49
|
+
id: string;
|
|
50
|
+
}[]>;
|
|
51
|
+
type ShopifyCredentials = InferCredentialSetAuth<typeof shopifyCredentialSet>;
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/credential-sets/shopify-app.credential-set.d.ts
|
|
54
|
+
declare const shopifyAppCredentialSet: CredentialSet<"shopify-app", z.ZodObject<{
|
|
55
|
+
clientId: z.ZodString;
|
|
56
|
+
clientSecret: z.ZodString;
|
|
57
|
+
webhookSecret: z.ZodString;
|
|
58
|
+
}, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
|
|
59
|
+
clientId: z.ZodString;
|
|
60
|
+
clientSecret: z.ZodString;
|
|
61
|
+
webhookSecret: z.ZodString;
|
|
62
|
+
}, z.core.$strip>>[] | undefined>;
|
|
63
|
+
type ShopifyAppCredentials = InferCredentialSetAuth<typeof shopifyAppCredentialSet>;
|
|
64
|
+
//#endregion
|
|
65
|
+
export { shopifyCredentialSet as i, shopifyAppCredentialSet as n, ShopifyCredentials as r, ShopifyAppCredentials as t };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CredentialSet } from "@keystrokehq/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/credential-sets/shopify-app.credential-set.ts
|
|
5
|
+
const shopifyAppCredentialSet = new CredentialSet({
|
|
6
|
+
id: "shopify-app",
|
|
7
|
+
exposure: "platform-only",
|
|
8
|
+
name: "Shopify App",
|
|
9
|
+
auth: z.object({
|
|
10
|
+
clientId: z.string(),
|
|
11
|
+
clientSecret: z.string(),
|
|
12
|
+
webhookSecret: z.string()
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { shopifyAppCredentialSet as t };
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { C as shopifyStoreDomainSchema } from "./common-JZyHdK6p.mjs";
|
|
2
|
+
import { CredentialSet } from "@keystrokehq/core";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
5
|
+
|
|
6
|
+
//#region ../../packages/credential-connection/dist/defaults-YE9AvLIc.mjs
|
|
7
|
+
/**
|
|
8
|
+
* Shared OAuth 2.0 token-response plumbing.
|
|
9
|
+
*
|
|
10
|
+
* `parseOAuthTokenResponse` handles the two common wire formats (JSON and
|
|
11
|
+
* form-urlencoded, the latter used by GitHub unless you explicitly ask for
|
|
12
|
+
* JSON). `normalizeOAuthTokens` pulls the standard fields out of the parsed
|
|
13
|
+
* body in both the flat form and Slack's nested `authed_user.access_token`
|
|
14
|
+
* form. These helpers are exposed so integration authors overriding
|
|
15
|
+
* `exchangeCode` / `refreshToken` do not have to re-implement them.
|
|
16
|
+
*/
|
|
17
|
+
var TokenExchangeError = class extends Error {
|
|
18
|
+
httpStatus;
|
|
19
|
+
constructor(httpStatus) {
|
|
20
|
+
super(`Token exchange failed: HTTP ${httpStatus}`);
|
|
21
|
+
this.name = "TokenExchangeError";
|
|
22
|
+
this.httpStatus = httpStatus;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
async function parseOAuthTokenResponse(response) {
|
|
26
|
+
const contentType = response.headers.get("content-type")?.toLowerCase() ?? "";
|
|
27
|
+
if (contentType.includes("application/json")) return await response.json();
|
|
28
|
+
const text = await response.text();
|
|
29
|
+
if (!text.trim()) return {};
|
|
30
|
+
if (contentType.includes("application/x-www-form-urlencoded") || text.includes("=")) {
|
|
31
|
+
const params = new URLSearchParams(text);
|
|
32
|
+
return Object.fromEntries(params.entries());
|
|
33
|
+
}
|
|
34
|
+
throw new Error(`Unsupported OAuth token response content type: ${contentType || "unknown"}`);
|
|
35
|
+
}
|
|
36
|
+
function normalizeOAuthTokens(tokenData) {
|
|
37
|
+
const authedUser = tokenData.authed_user;
|
|
38
|
+
const rawAccessToken = tokenData.access_token ?? authedUser?.access_token;
|
|
39
|
+
const rawRefreshToken = tokenData.refresh_token;
|
|
40
|
+
const rawExpiresIn = tokenData.expires_in;
|
|
41
|
+
const rawInstanceUrl = tokenData.instance_url;
|
|
42
|
+
return {
|
|
43
|
+
accessToken: typeof rawAccessToken === "string" ? rawAccessToken : void 0,
|
|
44
|
+
refreshToken: typeof rawRefreshToken === "string" ? rawRefreshToken : void 0,
|
|
45
|
+
expiresIn: typeof rawExpiresIn === "number" ? rawExpiresIn : typeof rawExpiresIn === "string" ? Number(rawExpiresIn) || void 0 : void 0,
|
|
46
|
+
instanceUrl: typeof rawInstanceUrl === "string" ? rawInstanceUrl : void 0
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/utils/oauth-connection.ts
|
|
52
|
+
/**
|
|
53
|
+
* Shopify OAuth connection configuration.
|
|
54
|
+
*
|
|
55
|
+
* Shopify's OAuth flow is per-shop: every handshake is scoped to a specific
|
|
56
|
+
* `{shop}.myshopify.com` domain that the user supplies up front. That shop
|
|
57
|
+
* domain shows up in three places that make Shopify different from a plain
|
|
58
|
+
* OAuth 2.0 integration:
|
|
59
|
+
*
|
|
60
|
+
* - `buildAuthUrl` must point at the shop-specific authorize endpoint at
|
|
61
|
+
* `https://{shop}.myshopify.com/admin/oauth/authorize`. The shop domain is
|
|
62
|
+
* threaded in from the initiate-connection request via `initiateInput`.
|
|
63
|
+
* - `exchangeCode` verifies the Shopify HMAC signature on the callback query
|
|
64
|
+
* string before trusting any of it, and POSTs to the same shop-specific
|
|
65
|
+
* token endpoint. HMAC verification uses `timingSafeEqual` to avoid leaking
|
|
66
|
+
* bytes through timing side channels.
|
|
67
|
+
* - `refreshToken` reads the shop domain out of `oauthClient.metadata` (set
|
|
68
|
+
* during the initial exchange) so proactive refreshes still target the
|
|
69
|
+
* right store, and the `vault` mapping promotes the shop domain into
|
|
70
|
+
* `SHOPIFY_STORE_DOMAIN` so the vault has both the access token and the
|
|
71
|
+
* store it belongs to.
|
|
72
|
+
*
|
|
73
|
+
* Shopify responds with JSON, so we reuse `parseOAuthTokenResponse` +
|
|
74
|
+
* `normalizeOAuthTokens` from `@keystrokehq/credential-connection` to avoid reimplementing
|
|
75
|
+
* the token-response plumbing.
|
|
76
|
+
*/
|
|
77
|
+
function normalizeShopifyShopDomain(raw) {
|
|
78
|
+
const trimmed = raw?.trim().toLowerCase();
|
|
79
|
+
if (!trimmed) throw new Error("Shopify requires a store domain.");
|
|
80
|
+
const normalized = trimmed.endsWith(".myshopify.com") ? trimmed : `${trimmed}.myshopify.com`;
|
|
81
|
+
if (!/^[a-z0-9][a-z0-9-]*\.myshopify\.com$/i.test(normalized)) throw new Error("Invalid Shopify store domain.");
|
|
82
|
+
return normalized;
|
|
83
|
+
}
|
|
84
|
+
function verifyShopifyCallbackHmac(queryParams, clientSecret) {
|
|
85
|
+
const receivedHmac = queryParams.hmac;
|
|
86
|
+
if (!receivedHmac) return false;
|
|
87
|
+
const canonical = Object.entries(queryParams).filter(([key]) => key !== "hmac" && key !== "signature").sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${key}=${value}`).join("&");
|
|
88
|
+
const expected = createHmac("sha256", clientSecret).update(canonical).digest("hex");
|
|
89
|
+
const received = Buffer.from(receivedHmac, "utf8");
|
|
90
|
+
const expectedBuffer = Buffer.from(expected, "utf8");
|
|
91
|
+
if (received.length !== expectedBuffer.length) return false;
|
|
92
|
+
return timingSafeEqual(received, expectedBuffer);
|
|
93
|
+
}
|
|
94
|
+
function resolveShopifyTokenUrl(shopDomain) {
|
|
95
|
+
return `https://${shopDomain}/admin/oauth/access_token`;
|
|
96
|
+
}
|
|
97
|
+
async function shopifyTokenPost(shopDomain, body, missingTokenError) {
|
|
98
|
+
const response = await fetch(resolveShopifyTokenUrl(shopDomain), {
|
|
99
|
+
method: "POST",
|
|
100
|
+
headers: {
|
|
101
|
+
Accept: "application/json",
|
|
102
|
+
"Content-Type": "application/json"
|
|
103
|
+
},
|
|
104
|
+
body: JSON.stringify(body)
|
|
105
|
+
});
|
|
106
|
+
if (!response.ok) throw new TokenExchangeError(response.status);
|
|
107
|
+
const raw = await parseOAuthTokenResponse(response);
|
|
108
|
+
raw._shopifyShopDomain = shopDomain;
|
|
109
|
+
const { accessToken, refreshToken, expiresIn } = normalizeOAuthTokens(raw);
|
|
110
|
+
if (!accessToken) throw new Error(missingTokenError);
|
|
111
|
+
return {
|
|
112
|
+
accessToken,
|
|
113
|
+
refreshToken,
|
|
114
|
+
expiresIn,
|
|
115
|
+
raw
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const shopifyOAuthConnection = {
|
|
119
|
+
kind: "oauth",
|
|
120
|
+
tokenType: "refreshable",
|
|
121
|
+
authUrl: "https://{shop}.myshopify.com/admin/oauth/authorize",
|
|
122
|
+
tokenUrl: "https://{shop}.myshopify.com/admin/oauth/access_token",
|
|
123
|
+
revokeUrl: null,
|
|
124
|
+
scopes: [
|
|
125
|
+
"read_products",
|
|
126
|
+
"write_products",
|
|
127
|
+
"read_orders",
|
|
128
|
+
"write_orders",
|
|
129
|
+
"read_customers",
|
|
130
|
+
"write_customers",
|
|
131
|
+
"read_inventory",
|
|
132
|
+
"write_inventory",
|
|
133
|
+
"read_locations",
|
|
134
|
+
"read_fulfillments",
|
|
135
|
+
"write_fulfillments",
|
|
136
|
+
"read_content",
|
|
137
|
+
"write_content",
|
|
138
|
+
"read_webhooks",
|
|
139
|
+
"write_webhooks"
|
|
140
|
+
],
|
|
141
|
+
vault: {
|
|
142
|
+
accessToken: "SHOPIFY_ACCESS_TOKEN",
|
|
143
|
+
raw: { SHOPIFY_STORE_DOMAIN: "_shopifyShopDomain" }
|
|
144
|
+
},
|
|
145
|
+
buildAuthUrl({ oauthClient, redirectUri, state, connection, initiateInput, requestedScopes }) {
|
|
146
|
+
const rawShopDomain = initiateInput?.shopDomain;
|
|
147
|
+
if (typeof rawShopDomain !== "string") throw new Error("Shopify requires a store domain.");
|
|
148
|
+
const scopes = requestedScopes ?? connection.scopes;
|
|
149
|
+
const shopDomain = normalizeShopifyShopDomain(rawShopDomain);
|
|
150
|
+
const url = new URL(`https://${shopDomain}/admin/oauth/authorize`);
|
|
151
|
+
url.searchParams.set("client_id", oauthClient.clientId);
|
|
152
|
+
url.searchParams.set("scope", scopes.join(","));
|
|
153
|
+
url.searchParams.set("redirect_uri", redirectUri);
|
|
154
|
+
url.searchParams.set("state", state);
|
|
155
|
+
return url.toString();
|
|
156
|
+
},
|
|
157
|
+
async exchangeCode({ oauthClient, code, queryParams }) {
|
|
158
|
+
if (!code) throw new Error("Missing authorization code");
|
|
159
|
+
const shopDomain = normalizeShopifyShopDomain(queryParams.shop);
|
|
160
|
+
if (!verifyShopifyCallbackHmac(queryParams, oauthClient.clientSecret)) throw new Error("Invalid Shopify OAuth callback signature");
|
|
161
|
+
return shopifyTokenPost(shopDomain, {
|
|
162
|
+
client_id: oauthClient.clientId,
|
|
163
|
+
client_secret: oauthClient.clientSecret,
|
|
164
|
+
code
|
|
165
|
+
}, "No access token in Shopify response");
|
|
166
|
+
},
|
|
167
|
+
async refreshToken({ oauthClient, refreshToken }) {
|
|
168
|
+
const rawShopDomain = oauthClient.metadata?.shopDomain;
|
|
169
|
+
if (typeof rawShopDomain !== "string") throw new Error("Missing Shopify store domain for token refresh.");
|
|
170
|
+
return shopifyTokenPost(normalizeShopifyShopDomain(rawShopDomain), {
|
|
171
|
+
grant_type: "refresh_token",
|
|
172
|
+
refresh_token: refreshToken,
|
|
173
|
+
client_id: oauthClient.clientId,
|
|
174
|
+
client_secret: oauthClient.clientSecret
|
|
175
|
+
}, "No access token in Shopify refresh response");
|
|
176
|
+
},
|
|
177
|
+
extractInstallationInfo({ tokenResult }) {
|
|
178
|
+
const shopDomain = typeof tokenResult.raw._shopifyShopDomain === "string" ? tokenResult.raw._shopifyShopDomain : void 0;
|
|
179
|
+
return {
|
|
180
|
+
externalInstallationId: shopDomain,
|
|
181
|
+
externalWorkspaceId: shopDomain,
|
|
182
|
+
metadata: shopDomain ? { shopDomain } : void 0
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/credential-sets/shopify.credential-set.ts
|
|
189
|
+
const shopifyAuthSchema = z.object({
|
|
190
|
+
SHOPIFY_STORE_DOMAIN: shopifyStoreDomainSchema,
|
|
191
|
+
SHOPIFY_ACCESS_TOKEN: z.string().min(1)
|
|
192
|
+
});
|
|
193
|
+
const shopifyCredentialSet = new CredentialSet({
|
|
194
|
+
id: "shopify",
|
|
195
|
+
name: "Shopify",
|
|
196
|
+
description: "Shopify Admin API — stores, products, orders, customers, and webhooks",
|
|
197
|
+
auth: shopifyAuthSchema,
|
|
198
|
+
connections: [{
|
|
199
|
+
id: "oauth",
|
|
200
|
+
...shopifyOAuthConnection
|
|
201
|
+
}]
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
//#endregion
|
|
205
|
+
export { shopifyCredentialSet as t };
|