@keystrokehq/shopify 0.0.1 → 0.0.5

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Buster
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,3 +1,38 @@
1
- import { i as shopifyOfficialIntegration, n as shopify, r as shopifyBundle, t as ShopifyCredentials } from "../integration-BwDBsGX-.mjs";
2
- import { n as shopifyAppCredentialSet, r as shopifyPlatformProviderSeed, t as ShopifyAppCredentials } from "../provider-app-DHxVZI6q.mjs";
1
+ import { i as shopifyOfficialIntegration, n as shopify, r as shopifyBundle, t as ShopifyCredentials } from "../integration-D5cqyAen.mjs";
2
+ import { z } from "zod";
3
+ import { CredentialSet } from "@keystrokehq/core";
4
+ import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
5
+ import { InferCredentialSetAuth } from "@keystrokehq/core/credential-set";
6
+
7
+ //#region src/_official/provider-app.d.ts
8
+ declare const shopifyAppCredentialSet: CredentialSet<"keystroke:shopify-app", z.ZodObject<{
9
+ clientId: z.ZodString;
10
+ clientSecret: z.ZodString;
11
+ webhookSecret: z.ZodString;
12
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
13
+ clientId: z.ZodString;
14
+ clientSecret: z.ZodString;
15
+ webhookSecret: z.ZodString;
16
+ }, z.core.$strip>>[] | undefined>;
17
+ declare const shopifyPlatformProviderSeed: {
18
+ readonly provider: "shopify";
19
+ readonly appRef: "shopify-platform";
20
+ readonly displayName: "Shopify Platform";
21
+ readonly credentialSetName: "Keystroke Shopify Platform App";
22
+ readonly envShape: {
23
+ readonly KEYSTROKE_PLATFORM_SHOPIFY_APP_ID: z.ZodOptional<z.ZodString>;
24
+ readonly KEYSTROKE_PLATFORM_SHOPIFY_CLIENT_ID: z.ZodOptional<z.ZodString>;
25
+ readonly KEYSTROKE_PLATFORM_SHOPIFY_CLIENT_SECRET: z.ZodOptional<z.ZodString>;
26
+ readonly KEYSTROKE_PLATFORM_SHOPIFY_WEBHOOK_SECRET: z.ZodOptional<z.ZodString>;
27
+ };
28
+ readonly requiredEnvKeys: readonly ["KEYSTROKE_PLATFORM_SHOPIFY_APP_ID", "KEYSTROKE_PLATFORM_SHOPIFY_CLIENT_ID", "KEYSTROKE_PLATFORM_SHOPIFY_CLIENT_SECRET", "KEYSTROKE_PLATFORM_SHOPIFY_WEBHOOK_SECRET"];
29
+ readonly externalAppIdEnvKey: "KEYSTROKE_PLATFORM_SHOPIFY_APP_ID";
30
+ readonly buildCredentials: (env: Record<string, string | undefined>) => {
31
+ clientId: string | undefined;
32
+ clientSecret: string | undefined;
33
+ webhookSecret: string | undefined;
34
+ };
35
+ };
36
+ type ShopifyAppCredentials = InferCredentialSetAuth<typeof shopifyAppCredentialSet>;
37
+ //#endregion
3
38
  export { type ShopifyAppCredentials, type ShopifyCredentials, shopify, shopifyAppCredentialSet, shopifyBundle, shopifyOfficialIntegration, shopifyPlatformProviderSeed };
@@ -1,3 +1,3 @@
1
- import { a as shopifyAppCredentialSet, n as shopifyBundle, o as shopifyPlatformProviderSeed, r as shopifyOfficialIntegration, t as shopify } from "../integration-BN3pjCz4.mjs";
1
+ import { a as shopifyAppCredentialSet, n as shopifyBundle, o as shopifyPlatformProviderSeed, r as shopifyOfficialIntegration, t as shopify } from "../integration-Bo2QSs3C.mjs";
2
2
 
3
3
  export { shopify, shopifyAppCredentialSet, shopifyBundle, shopifyOfficialIntegration, shopifyPlatformProviderSeed };
@@ -1,4 +1,4 @@
1
- import { t as ShopifyCredentials } from "../integration-BwDBsGX-.mjs";
1
+ import { t as ShopifyCredentials } from "../integration-D5cqyAen.mjs";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/webhook-management.d.ts
@@ -1,3 +1,150 @@
1
- import { i as listShopifyWebhookSubscriptions, n as buildShopifyWebhookCallbackUri, r as ensureShopifyWebhookSubscriptions, t as SHOPIFY_WEBHOOK_RUNTIME_DEFINITIONS } from "../webhook-management-BmIxO0vr.mjs";
1
+ import { shopifyGlobalIdSchema, shopifyUserErrorSchema } from "../schemas.mjs";
2
+ import { createShopifyClient } from "../client.mjs";
3
+ import { shopifyWebhookSubscriptionTopicSchema, shopifyWebhookTopicSchema } from "../events.mjs";
4
+ import { z } from "zod";
2
5
 
6
+ //#region src/webhook-management.ts
7
+ const shopifyWebhookRuntimeDefinitionSchema = z.object({
8
+ eventTopic: shopifyWebhookTopicSchema,
9
+ subscriptionTopic: shopifyWebhookSubscriptionTopicSchema,
10
+ path: z.string().min(1)
11
+ });
12
+ const SHOPIFY_WEBHOOK_RUNTIME_DEFINITIONS = [
13
+ {
14
+ eventTopic: "products/create",
15
+ subscriptionTopic: "PRODUCTS_CREATE",
16
+ path: "/shopify/products/create"
17
+ },
18
+ {
19
+ eventTopic: "products/update",
20
+ subscriptionTopic: "PRODUCTS_UPDATE",
21
+ path: "/shopify/products/update"
22
+ },
23
+ {
24
+ eventTopic: "products/delete",
25
+ subscriptionTopic: "PRODUCTS_DELETE",
26
+ path: "/shopify/products/delete"
27
+ },
28
+ {
29
+ eventTopic: "orders/create",
30
+ subscriptionTopic: "ORDERS_CREATE",
31
+ path: "/shopify/orders/create"
32
+ },
33
+ {
34
+ eventTopic: "orders/updated",
35
+ subscriptionTopic: "ORDERS_UPDATED",
36
+ path: "/shopify/orders/updated"
37
+ },
38
+ {
39
+ eventTopic: "orders/cancelled",
40
+ subscriptionTopic: "ORDERS_CANCELLED",
41
+ path: "/shopify/orders/cancelled"
42
+ },
43
+ {
44
+ eventTopic: "orders/fulfilled",
45
+ subscriptionTopic: "ORDERS_FULFILLED",
46
+ path: "/shopify/orders/fulfilled"
47
+ }
48
+ ];
49
+ const webhookSubscriptionSchema = z.object({
50
+ id: shopifyGlobalIdSchema,
51
+ topic: shopifyWebhookSubscriptionTopicSchema,
52
+ uri: z.string().url()
53
+ });
54
+ const listWebhookSubscriptionsResponseSchema = z.object({ webhookSubscriptions: z.object({ nodes: z.array(webhookSubscriptionSchema) }) });
55
+ const createWebhookSubscriptionResponseSchema = z.object({ webhookSubscriptionCreate: z.object({
56
+ webhookSubscription: webhookSubscriptionSchema.nullable(),
57
+ userErrors: z.array(shopifyUserErrorSchema)
58
+ }) });
59
+ const deleteWebhookSubscriptionResponseSchema = z.object({ webhookSubscriptionDelete: z.object({
60
+ deletedWebhookSubscriptionId: shopifyGlobalIdSchema.nullable(),
61
+ userErrors: z.array(shopifyUserErrorSchema)
62
+ }) });
63
+ function assertNoUserErrors(userErrors) {
64
+ if (userErrors.length === 0) return;
65
+ const message = userErrors.map((error) => error.field && error.field.length > 0 ? `${error.field.join(".")}: ${error.message}` : error.message).join("; ");
66
+ throw new Error(`Shopify webhook subscription error: ${message}`);
67
+ }
68
+ function buildShopifyWebhookCallbackUri(baseUrl, path) {
69
+ return new URL(path, baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`).toString();
70
+ }
71
+ async function listShopifyWebhookSubscriptions(credentials) {
72
+ return (await createShopifyClient(credentials).graphql(`
73
+ query ListWebhookSubscriptions($topics: [WebhookSubscriptionTopic!]) {
74
+ webhookSubscriptions(first: 50, topics: $topics) {
75
+ nodes {
76
+ id
77
+ topic
78
+ uri
79
+ }
80
+ }
81
+ }
82
+ `, listWebhookSubscriptionsResponseSchema, { variables: { topics: SHOPIFY_WEBHOOK_RUNTIME_DEFINITIONS.map((definition) => definition.subscriptionTopic) } })).webhookSubscriptions.nodes;
83
+ }
84
+ async function createShopifyWebhookSubscription(credentials, topic, uri) {
85
+ const response = await createShopifyClient(credentials).graphql(`
86
+ mutation CreateWebhookSubscription(
87
+ $topic: WebhookSubscriptionTopic!
88
+ $webhookSubscription: WebhookSubscriptionInput!
89
+ ) {
90
+ webhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {
91
+ webhookSubscription {
92
+ id
93
+ topic
94
+ uri
95
+ }
96
+ userErrors {
97
+ field
98
+ message
99
+ }
100
+ }
101
+ }
102
+ `, createWebhookSubscriptionResponseSchema, { variables: {
103
+ topic,
104
+ webhookSubscription: { uri }
105
+ } });
106
+ assertNoUserErrors(response.webhookSubscriptionCreate.userErrors);
107
+ if (!response.webhookSubscriptionCreate.webhookSubscription) throw new Error(`Shopify did not return the created webhook subscription for ${topic}.`);
108
+ return response.webhookSubscriptionCreate.webhookSubscription;
109
+ }
110
+ async function deleteShopifyWebhookSubscription(credentials, id) {
111
+ const response = await createShopifyClient(credentials).graphql(`
112
+ mutation DeleteWebhookSubscription($id: ID!) {
113
+ webhookSubscriptionDelete(id: $id) {
114
+ deletedWebhookSubscriptionId
115
+ userErrors {
116
+ field
117
+ message
118
+ }
119
+ }
120
+ }
121
+ `, deleteWebhookSubscriptionResponseSchema, { variables: { id } });
122
+ assertNoUserErrors(response.webhookSubscriptionDelete.userErrors);
123
+ if (!response.webhookSubscriptionDelete.deletedWebhookSubscriptionId) throw new Error(`Shopify did not confirm deletion for webhook subscription ${id}.`);
124
+ return response.webhookSubscriptionDelete.deletedWebhookSubscriptionId;
125
+ }
126
+ async function ensureShopifyWebhookSubscriptions(credentials, callbackBaseUrl) {
127
+ const existing = await listShopifyWebhookSubscriptions(credentials);
128
+ const kept = [];
129
+ const created = [];
130
+ const deleted = [];
131
+ for (const definition of SHOPIFY_WEBHOOK_RUNTIME_DEFINITIONS) {
132
+ const expectedUri = buildShopifyWebhookCallbackUri(callbackBaseUrl, definition.path);
133
+ const matches = existing.filter((subscription) => subscription.topic === definition.subscriptionTopic);
134
+ const canonical = matches.find((subscription) => subscription.uri === expectedUri);
135
+ if (canonical) kept.push(canonical.id);
136
+ for (const subscription of matches) if (!canonical || subscription.id !== canonical.id) deleted.push(await deleteShopifyWebhookSubscription(credentials, subscription.id));
137
+ if (!canonical) {
138
+ const createdSubscription = await createShopifyWebhookSubscription(credentials, definition.subscriptionTopic, expectedUri);
139
+ created.push(createdSubscription.id);
140
+ }
141
+ }
142
+ return {
143
+ kept,
144
+ created,
145
+ deleted
146
+ };
147
+ }
148
+
149
+ //#endregion
3
150
  export { SHOPIFY_WEBHOOK_RUNTIME_DEFINITIONS, buildShopifyWebhookCallbackUri, ensureShopifyWebhookSubscriptions, listShopifyWebhookSubscriptions };
@@ -38,7 +38,7 @@ declare const listArticles: _keystrokehq_core0.Operation<z.ZodObject<{
38
38
  startCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
39
39
  endCursor: z.ZodNullable<z.ZodString>;
40
40
  }, z.core.$strip>;
41
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
41
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
42
42
  SHOPIFY_STORE_DOMAIN: z.ZodString;
43
43
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
44
44
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -70,7 +70,7 @@ declare const getArticle: _keystrokehq_core0.Operation<z.ZodObject<{
70
70
  }, z.core.$strip>>>;
71
71
  publishedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
72
72
  updatedAt: z.ZodOptional<z.ZodISODateTime>;
73
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
73
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
74
74
  SHOPIFY_STORE_DOMAIN: z.ZodString;
75
75
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
76
76
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -110,7 +110,7 @@ declare const createArticle: _keystrokehq_core0.Operation<z.ZodObject<{
110
110
  }, z.core.$strip>>>;
111
111
  publishedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
112
112
  updatedAt: z.ZodOptional<z.ZodISODateTime>;
113
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
113
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
114
114
  SHOPIFY_STORE_DOMAIN: z.ZodString;
115
115
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
116
116
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -152,7 +152,7 @@ declare const updateArticle: _keystrokehq_core0.Operation<z.ZodObject<{
152
152
  }, z.core.$strip>>>;
153
153
  publishedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
154
154
  updatedAt: z.ZodOptional<z.ZodISODateTime>;
155
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
155
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
156
156
  SHOPIFY_STORE_DOMAIN: z.ZodString;
157
157
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
158
158
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -163,7 +163,7 @@ declare const deleteArticle: _keystrokehq_core0.Operation<z.ZodObject<{
163
163
  id: z.ZodString;
164
164
  }, z.core.$strip>, z.ZodObject<{
165
165
  deletedArticleId: z.ZodString;
166
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
166
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
167
167
  SHOPIFY_STORE_DOMAIN: z.ZodString;
168
168
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
169
169
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
package/dist/articles.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { shopifyArticleSchema, shopifyConnectionNodesSchema, shopifyGlobalIdSchema, shopifyUserErrorSchema } from "./schemas.mjs";
2
2
  import { createShopifyClient } from "./client.mjs";
3
- import { t as shopifyOperation } from "./factory-DC-gY8L0.mjs";
3
+ import { t as shopifyOperation } from "./factory-DgZsA1YB.mjs";
4
4
  import { n as omitUndefined, r as shopifyPageInputSchema, t as assertNoUserErrors } from "./operation-helpers-CKEDIx0o.mjs";
5
5
  import { z } from "zod";
6
6
 
package/dist/blogs.d.mts CHANGED
@@ -23,7 +23,7 @@ declare const listBlogs: _keystrokehq_core0.Operation<z.ZodObject<{
23
23
  startCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
24
  endCursor: z.ZodNullable<z.ZodString>;
25
25
  }, z.core.$strip>;
26
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
26
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
27
27
  SHOPIFY_STORE_DOMAIN: z.ZodString;
28
28
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
29
29
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -40,7 +40,7 @@ declare const getBlog: _keystrokehq_core0.Operation<z.ZodObject<{
40
40
  updatedAt: z.ZodOptional<z.ZodISODateTime>;
41
41
  commentPolicy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
42
42
  templateSuffix: z.ZodOptional<z.ZodNullable<z.ZodString>>;
43
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
43
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
44
44
  SHOPIFY_STORE_DOMAIN: z.ZodString;
45
45
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
46
46
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -65,7 +65,7 @@ declare const createBlog: _keystrokehq_core0.Operation<z.ZodObject<{
65
65
  updatedAt: z.ZodOptional<z.ZodISODateTime>;
66
66
  commentPolicy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
67
67
  templateSuffix: z.ZodOptional<z.ZodNullable<z.ZodString>>;
68
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
68
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
69
69
  SHOPIFY_STORE_DOMAIN: z.ZodString;
70
70
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
71
71
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -91,7 +91,7 @@ declare const updateBlog: _keystrokehq_core0.Operation<z.ZodObject<{
91
91
  updatedAt: z.ZodOptional<z.ZodISODateTime>;
92
92
  commentPolicy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
93
93
  templateSuffix: z.ZodOptional<z.ZodNullable<z.ZodString>>;
94
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
94
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
95
95
  SHOPIFY_STORE_DOMAIN: z.ZodString;
96
96
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
97
97
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -102,7 +102,7 @@ declare const deleteBlog: _keystrokehq_core0.Operation<z.ZodObject<{
102
102
  id: z.ZodString;
103
103
  }, z.core.$strip>, z.ZodObject<{
104
104
  deletedBlogId: z.ZodString;
105
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
105
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
106
106
  SHOPIFY_STORE_DOMAIN: z.ZodString;
107
107
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
108
108
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
package/dist/blogs.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { shopifyBlogSchema, shopifyConnectionNodesSchema, shopifyGlobalIdSchema, shopifyUserErrorSchema } from "./schemas.mjs";
2
2
  import { createShopifyClient } from "./client.mjs";
3
- import { t as shopifyOperation } from "./factory-DC-gY8L0.mjs";
3
+ import { t as shopifyOperation } from "./factory-DgZsA1YB.mjs";
4
4
  import { n as omitUndefined, r as shopifyPageInputSchema, t as assertNoUserErrors } from "./operation-helpers-CKEDIx0o.mjs";
5
5
  import { z } from "zod";
6
6
 
package/dist/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as ShopifyCredentials } from "./integration-BwDBsGX-.mjs";
1
+ import { t as ShopifyCredentials } from "./integration-D5cqyAen.mjs";
2
2
  import { z } from "zod";
3
3
  import { ClientResponse, SearchParams } from "@shopify/admin-api-client";
4
4
 
package/dist/client.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as shopify } from "./integration-BN3pjCz4.mjs";
1
+ import { t as shopify } from "./integration-Bo2QSs3C.mjs";
2
2
  import { shopifyGraphqlErrorSchema } from "./schemas.mjs";
3
3
  import { CredentialRevokedError } from "@keystrokehq/core/errors";
4
4
  import { createAdminApiClient, createAdminRestApiClient } from "@shopify/admin-api-client";
@@ -29,7 +29,7 @@ declare const listCollections: _keystrokehq_core0.Operation<z.ZodObject<{
29
29
  startCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
30
30
  endCursor: z.ZodNullable<z.ZodString>;
31
31
  }, z.core.$strip>;
32
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
32
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
33
33
  SHOPIFY_STORE_DOMAIN: z.ZodString;
34
34
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
35
35
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -52,7 +52,7 @@ declare const getCollection: _keystrokehq_core0.Operation<z.ZodObject<{
52
52
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
53
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
54
54
  }, z.core.$strip>>>;
55
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
55
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
56
56
  SHOPIFY_STORE_DOMAIN: z.ZodString;
57
57
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
58
58
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -81,7 +81,7 @@ declare const createCollection: _keystrokehq_core0.Operation<z.ZodObject<{
81
81
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
82
82
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
83
83
  }, z.core.$strip>>>;
84
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
84
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
85
85
  SHOPIFY_STORE_DOMAIN: z.ZodString;
86
86
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
87
87
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -92,7 +92,7 @@ declare const deleteCollection: _keystrokehq_core0.Operation<z.ZodObject<{
92
92
  id: z.ZodString;
93
93
  }, z.core.$strip>, z.ZodObject<{
94
94
  deletedCollectionId: z.ZodString;
95
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
95
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
96
96
  SHOPIFY_STORE_DOMAIN: z.ZodString;
97
97
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
98
98
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -116,7 +116,7 @@ declare const addProductsToCollection: _keystrokehq_core0.Operation<z.ZodObject<
116
116
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
117
117
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
118
118
  }, z.core.$strip>>>;
119
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
119
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
120
120
  SHOPIFY_STORE_DOMAIN: z.ZodString;
121
121
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
122
122
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -129,7 +129,7 @@ declare const removeProductsFromCollection: _keystrokehq_core0.Operation<z.ZodOb
129
129
  }, z.core.$strip>, z.ZodObject<{
130
130
  id: z.ZodString;
131
131
  done: z.ZodOptional<z.ZodBoolean>;
132
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
132
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
133
133
  SHOPIFY_STORE_DOMAIN: z.ZodString;
134
134
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
135
135
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -1,6 +1,6 @@
1
1
  import { shopifyCollectionSchema, shopifyConnectionNodesSchema, shopifyGlobalIdSchema, shopifyJobSchema, shopifyUserErrorSchema } from "./schemas.mjs";
2
2
  import { createShopifyClient } from "./client.mjs";
3
- import { t as shopifyOperation } from "./factory-DC-gY8L0.mjs";
3
+ import { t as shopifyOperation } from "./factory-DgZsA1YB.mjs";
4
4
  import { i as shopifyProductIdsInputSchema, n as omitUndefined, r as shopifyPageInputSchema, t as assertNoUserErrors } from "./operation-helpers-CKEDIx0o.mjs";
5
5
  import { z } from "zod";
6
6
 
@@ -1,2 +1,2 @@
1
- import { n as shopify, t as ShopifyCredentials } from "./integration-BwDBsGX-.mjs";
1
+ import { n as shopify, t as ShopifyCredentials } from "./integration-D5cqyAen.mjs";
2
2
  export { type ShopifyCredentials, shopify };
@@ -1,3 +1,3 @@
1
- import { t as shopify } from "./integration-BN3pjCz4.mjs";
1
+ import { t as shopify } from "./integration-Bo2QSs3C.mjs";
2
2
 
3
3
  export { shopify };
@@ -24,7 +24,7 @@ declare const listCustomers: _keystrokehq_core0.Operation<z.ZodObject<{
24
24
  startCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
25
  endCursor: z.ZodNullable<z.ZodString>;
26
26
  }, z.core.$strip>;
27
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
27
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
28
28
  SHOPIFY_STORE_DOMAIN: z.ZodString;
29
29
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
30
30
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -42,7 +42,7 @@ declare const getCustomer: _keystrokehq_core0.Operation<z.ZodObject<{
42
42
  phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
43
43
  createdAt: z.ZodOptional<z.ZodISODateTime>;
44
44
  updatedAt: z.ZodOptional<z.ZodISODateTime>;
45
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
45
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
46
46
  SHOPIFY_STORE_DOMAIN: z.ZodString;
47
47
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
48
48
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -65,7 +65,7 @@ declare const createCustomer: _keystrokehq_core0.Operation<z.ZodObject<{
65
65
  phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
66
66
  createdAt: z.ZodOptional<z.ZodISODateTime>;
67
67
  updatedAt: z.ZodOptional<z.ZodISODateTime>;
68
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
68
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
69
69
  SHOPIFY_STORE_DOMAIN: z.ZodString;
70
70
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
71
71
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -89,7 +89,7 @@ declare const updateCustomer: _keystrokehq_core0.Operation<z.ZodObject<{
89
89
  phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
90
90
  createdAt: z.ZodOptional<z.ZodISODateTime>;
91
91
  updatedAt: z.ZodOptional<z.ZodISODateTime>;
92
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
92
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
93
93
  SHOPIFY_STORE_DOMAIN: z.ZodString;
94
94
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
95
95
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -100,7 +100,7 @@ declare const deleteCustomer: _keystrokehq_core0.Operation<z.ZodObject<{
100
100
  id: z.ZodString;
101
101
  }, z.core.$strip>, z.ZodObject<{
102
102
  deletedCustomerId: z.ZodString;
103
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
103
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
104
104
  SHOPIFY_STORE_DOMAIN: z.ZodString;
105
105
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
106
106
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -150,7 +150,7 @@ declare const getCustomerOrders: _keystrokehq_core0.Operation<z.ZodObject<{
150
150
  startCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
151
151
  endCursor: z.ZodNullable<z.ZodString>;
152
152
  }, z.core.$strip>;
153
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
153
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
154
154
  SHOPIFY_STORE_DOMAIN: z.ZodString;
155
155
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
156
156
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -1,6 +1,6 @@
1
1
  import { shopifyConnectionNodesSchema, shopifyCustomerSchema, shopifyGlobalIdSchema, shopifyOrderSchema, shopifyUserErrorSchema } from "./schemas.mjs";
2
2
  import { createShopifyClient } from "./client.mjs";
3
- import { t as shopifyOperation } from "./factory-DC-gY8L0.mjs";
3
+ import { t as shopifyOperation } from "./factory-DgZsA1YB.mjs";
4
4
  import { n as omitUndefined, r as shopifyPageInputSchema, t as assertNoUserErrors } from "./operation-helpers-CKEDIx0o.mjs";
5
5
  import { z } from "zod";
6
6
 
@@ -1,4 +1,4 @@
1
- import { t as shopify } from "./integration-BN3pjCz4.mjs";
1
+ import { t as shopify } from "./integration-Bo2QSs3C.mjs";
2
2
  import { createOfficialOperationFactory } from "@keystrokehq/integration-authoring/official";
3
3
 
4
4
  //#region src/factory.ts
@@ -43,7 +43,7 @@ declare const listFulfillmentOrdersForOrder: _keystrokehq_core0.Operation<z.ZodO
43
43
  startCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
44
44
  endCursor: z.ZodNullable<z.ZodString>;
45
45
  }, z.core.$strip>;
46
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
46
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
47
47
  SHOPIFY_STORE_DOMAIN: z.ZodString;
48
48
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
49
49
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -59,7 +59,7 @@ declare const getFulfillment: _keystrokehq_core0.Operation<z.ZodObject<{
59
59
  number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
60
60
  url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
61
61
  }, z.core.$strip>>>;
62
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
62
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
63
63
  SHOPIFY_STORE_DOMAIN: z.ZodString;
64
64
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
65
65
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -88,7 +88,7 @@ declare const createFulfillment: _keystrokehq_core0.Operation<z.ZodObject<{
88
88
  number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
89
89
  url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
90
90
  }, z.core.$strip>>>;
91
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
91
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
92
92
  SHOPIFY_STORE_DOMAIN: z.ZodString;
93
93
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
94
94
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -1,6 +1,6 @@
1
1
  import { shopifyConnectionNodesSchema, shopifyFulfillmentSchema, shopifyGlobalIdSchema, shopifyLocationSchema, shopifyUserErrorSchema } from "./schemas.mjs";
2
2
  import { createShopifyClient } from "./client.mjs";
3
- import { t as shopifyOperation } from "./factory-DC-gY8L0.mjs";
3
+ import { t as shopifyOperation } from "./factory-DgZsA1YB.mjs";
4
4
  import { t as assertNoUserErrors } from "./operation-helpers-CKEDIx0o.mjs";
5
5
  import { z } from "zod";
6
6
 
@@ -1,4 +1,4 @@
1
- import { defineOfficialIntegration } from "@keystrokehq/integration-authoring/official";
1
+ import { defineOfficialIntegration, officialCredentialSetId } from "@keystrokehq/integration-authoring/official";
2
2
  import { z } from "zod";
3
3
  import { CredentialSet } from "@keystrokehq/core";
4
4
  import { createHmac, timingSafeEqual } from "node:crypto";
@@ -6,7 +6,7 @@ import { TokenExchangeError, normalizeOAuthTokens, parseOAuthTokenResponse } fro
6
6
 
7
7
  //#region src/_official/provider-app.ts
8
8
  const shopifyAppCredentialSet = new CredentialSet({
9
- id: "shopify-app",
9
+ id: officialCredentialSetId("shopify-app"),
10
10
  exposure: "platform-only",
11
11
  name: "Shopify App",
12
12
  auth: z.object({
@@ -59,7 +59,7 @@ declare const shopifyBundle: _keystrokehq_integration_authoring_official0.Offici
59
59
  SHOPIFY_STORE_DOMAIN: z.ZodString;
60
60
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
61
61
  }, z.core.$strip>>;
62
- declare const shopify: _keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
62
+ declare const shopify: _keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
63
63
  SHOPIFY_STORE_DOMAIN: z.ZodString;
64
64
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
65
65
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -19,7 +19,7 @@ declare const listInventoryItems: _keystrokehq_core0.Operation<z.ZodObject<{
19
19
  startCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
20
  endCursor: z.ZodNullable<z.ZodString>;
21
21
  }, z.core.$strip>;
22
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
22
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
23
23
  SHOPIFY_STORE_DOMAIN: z.ZodString;
24
24
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
25
25
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -32,7 +32,7 @@ declare const getInventoryItem: _keystrokehq_core0.Operation<z.ZodObject<{
32
32
  id: z.ZodString;
33
33
  sku: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
34
  tracked: z.ZodOptional<z.ZodBoolean>;
35
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
35
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
36
36
  SHOPIFY_STORE_DOMAIN: z.ZodString;
37
37
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
38
38
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -68,7 +68,7 @@ declare const getInventoryLevelsForItem: _keystrokehq_core0.Operation<z.ZodObjec
68
68
  startCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
69
69
  endCursor: z.ZodNullable<z.ZodString>;
70
70
  }, z.core.$strip>;
71
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
71
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
72
72
  SHOPIFY_STORE_DOMAIN: z.ZodString;
73
73
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
74
74
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -92,7 +92,7 @@ declare const adjustInventoryQuantities: _keystrokehq_core0.Operation<z.ZodObjec
92
92
  name: z.ZodString;
93
93
  delta: z.ZodNumber;
94
94
  }, z.core.$strip>>;
95
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
95
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
96
96
  SHOPIFY_STORE_DOMAIN: z.ZodString;
97
97
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
98
98
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -1,6 +1,6 @@
1
1
  import { shopifyConnectionNodesSchema, shopifyGlobalIdSchema, shopifyInventoryItemSchema, shopifyInventoryLevelSchema, shopifyUserErrorSchema } from "./schemas.mjs";
2
2
  import { createShopifyClient } from "./client.mjs";
3
- import { t as shopifyOperation } from "./factory-DC-gY8L0.mjs";
3
+ import { t as shopifyOperation } from "./factory-DgZsA1YB.mjs";
4
4
  import { r as shopifyPageInputSchema, t as assertNoUserErrors } from "./operation-helpers-CKEDIx0o.mjs";
5
5
  import { z } from "zod";
6
6
 
@@ -22,7 +22,7 @@ declare const listLocations: _keystrokehq_core0.Operation<z.ZodObject<{
22
22
  startCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
23
23
  endCursor: z.ZodNullable<z.ZodString>;
24
24
  }, z.core.$strip>;
25
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
25
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
26
26
  SHOPIFY_STORE_DOMAIN: z.ZodString;
27
27
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
28
28
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -36,7 +36,7 @@ declare const getLocation: _keystrokehq_core0.Operation<z.ZodObject<{
36
36
  name: z.ZodString;
37
37
  isActive: z.ZodOptional<z.ZodBoolean>;
38
38
  fulfillsOnlineOrders: z.ZodOptional<z.ZodBoolean>;
39
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
39
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
40
40
  SHOPIFY_STORE_DOMAIN: z.ZodString;
41
41
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
42
42
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -1,6 +1,6 @@
1
1
  import { shopifyConnectionNodesSchema, shopifyGlobalIdSchema, shopifyLocationSchema } from "./schemas.mjs";
2
2
  import { createShopifyClient } from "./client.mjs";
3
- import { t as shopifyOperation } from "./factory-DC-gY8L0.mjs";
3
+ import { t as shopifyOperation } from "./factory-DgZsA1YB.mjs";
4
4
  import { r as shopifyPageInputSchema } from "./operation-helpers-CKEDIx0o.mjs";
5
5
  import { z } from "zod";
6
6
 
package/dist/orders.d.mts CHANGED
@@ -46,7 +46,7 @@ declare const listOrders: _keystrokehq_core0.Operation<z.ZodObject<{
46
46
  startCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
47
  endCursor: z.ZodNullable<z.ZodString>;
48
48
  }, z.core.$strip>;
49
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
49
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
50
50
  SHOPIFY_STORE_DOMAIN: z.ZodString;
51
51
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
52
52
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -86,7 +86,7 @@ declare const getOrder: _keystrokehq_core0.Operation<z.ZodObject<{
86
86
  createdAt: z.ZodOptional<z.ZodISODateTime>;
87
87
  updatedAt: z.ZodOptional<z.ZodISODateTime>;
88
88
  }, z.core.$strip>>>;
89
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
89
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
90
90
  SHOPIFY_STORE_DOMAIN: z.ZodString;
91
91
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
92
92
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -138,7 +138,7 @@ declare const createOrder: _keystrokehq_core0.Operation<z.ZodObject<{
138
138
  createdAt: z.ZodOptional<z.ZodISODateTime>;
139
139
  updatedAt: z.ZodOptional<z.ZodISODateTime>;
140
140
  }, z.core.$strip>>>;
141
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
141
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
142
142
  SHOPIFY_STORE_DOMAIN: z.ZodString;
143
143
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
144
144
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -192,7 +192,7 @@ declare const updateOrder: _keystrokehq_core0.Operation<z.ZodObject<{
192
192
  createdAt: z.ZodOptional<z.ZodISODateTime>;
193
193
  updatedAt: z.ZodOptional<z.ZodISODateTime>;
194
194
  }, z.core.$strip>>>;
195
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
195
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
196
196
  SHOPIFY_STORE_DOMAIN: z.ZodString;
197
197
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
198
198
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -218,7 +218,7 @@ declare const cancelOrder: _keystrokehq_core0.Operation<z.ZodObject<{
218
218
  }, z.core.$strip>, z.ZodObject<{
219
219
  id: z.ZodString;
220
220
  done: z.ZodOptional<z.ZodBoolean>;
221
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
221
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
222
222
  SHOPIFY_STORE_DOMAIN: z.ZodString;
223
223
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
224
224
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
package/dist/orders.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { shopifyConnectionNodesSchema, shopifyGlobalIdSchema, shopifyJobSchema, shopifyOrderSchema, shopifyUserErrorSchema } from "./schemas.mjs";
2
2
  import { createShopifyClient } from "./client.mjs";
3
- import { t as shopifyOperation } from "./factory-DC-gY8L0.mjs";
3
+ import { t as shopifyOperation } from "./factory-DgZsA1YB.mjs";
4
4
  import { n as omitUndefined, r as shopifyPageInputSchema, t as assertNoUserErrors } from "./operation-helpers-CKEDIx0o.mjs";
5
5
  import { z } from "zod";
6
6
 
@@ -35,7 +35,7 @@ declare const listProducts: _keystrokehq_core0.Operation<z.ZodObject<{
35
35
  startCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
36
  endCursor: z.ZodNullable<z.ZodString>;
37
37
  }, z.core.$strip>;
38
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
38
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
39
39
  SHOPIFY_STORE_DOMAIN: z.ZodString;
40
40
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
41
41
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -64,7 +64,7 @@ declare const getProduct: _keystrokehq_core0.Operation<z.ZodObject<{
64
64
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
65
65
  }, z.core.$strip>>>;
66
66
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
67
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
67
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
68
68
  SHOPIFY_STORE_DOMAIN: z.ZodString;
69
69
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
70
70
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -98,7 +98,7 @@ declare const createProduct: _keystrokehq_core0.Operation<z.ZodObject<{
98
98
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
99
99
  }, z.core.$strip>>>;
100
100
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
101
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
101
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
102
102
  SHOPIFY_STORE_DOMAIN: z.ZodString;
103
103
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
104
104
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -133,7 +133,7 @@ declare const updateProduct: _keystrokehq_core0.Operation<z.ZodObject<{
133
133
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
134
134
  }, z.core.$strip>>>;
135
135
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
136
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
136
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
137
137
  SHOPIFY_STORE_DOMAIN: z.ZodString;
138
138
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
139
139
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
@@ -144,7 +144,7 @@ declare const deleteProduct: _keystrokehq_core0.Operation<z.ZodObject<{
144
144
  id: z.ZodString;
145
145
  }, z.core.$strip>, z.ZodObject<{
146
146
  deletedProductId: z.ZodString;
147
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
147
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
148
148
  SHOPIFY_STORE_DOMAIN: z.ZodString;
149
149
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
150
150
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
package/dist/products.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { shopifyConnectionNodesSchema, shopifyGlobalIdSchema, shopifyProductSchema, shopifyUserErrorSchema } from "./schemas.mjs";
2
2
  import { createShopifyClient } from "./client.mjs";
3
- import { t as shopifyOperation } from "./factory-DC-gY8L0.mjs";
3
+ import { t as shopifyOperation } from "./factory-DgZsA1YB.mjs";
4
4
  import { n as omitUndefined, r as shopifyPageInputSchema, t as assertNoUserErrors } from "./operation-helpers-CKEDIx0o.mjs";
5
5
  import { z } from "zod";
6
6
 
package/dist/schemas.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as shopifyStoreDomainSchema } from "./integration-BN3pjCz4.mjs";
1
+ import { i as shopifyStoreDomainSchema } from "./integration-Bo2QSs3C.mjs";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/schemas.ts
package/dist/shop.d.mts CHANGED
@@ -9,7 +9,7 @@ declare const getShop: _keystrokehq_core0.Operation<z.ZodObject<{}, z.core.$stri
9
9
  myshopifyDomain: z.ZodString;
10
10
  contactEmail: z.ZodOptional<z.ZodNullable<z.ZodEmail>>;
11
11
  currencyCode: z.ZodOptional<z.ZodString>;
12
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
12
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:shopify", z.ZodObject<{
13
13
  SHOPIFY_STORE_DOMAIN: z.ZodString;
14
14
  SHOPIFY_ACCESS_TOKEN: z.ZodString;
15
15
  }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
package/dist/shop.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { shopifyShopSchema } from "./schemas.mjs";
2
2
  import { createShopifyClient } from "./client.mjs";
3
- import { t as shopifyOperation } from "./factory-DC-gY8L0.mjs";
3
+ import { t as shopifyOperation } from "./factory-DgZsA1YB.mjs";
4
4
  import { z } from "zod";
5
5
 
6
6
  //#region src/shop.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keystrokehq/shopify",
3
- "version": "0.0.1",
3
+ "version": "0.0.5",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -69,10 +69,6 @@
69
69
  "types": "./dist/fulfillments.d.mts",
70
70
  "default": "./dist/fulfillments.mjs"
71
71
  },
72
- "./triggers": {
73
- "types": "./dist/triggers.d.mts",
74
- "default": "./dist/triggers.mjs"
75
- },
76
72
  "./_official": {
77
73
  "types": "./dist/_official/index.d.mts",
78
74
  "default": "./dist/_official/index.mjs"
@@ -87,29 +83,23 @@
87
83
  "README.md",
88
84
  "LICENSE"
89
85
  ],
90
- "scripts": {
91
- "typecheck": "tsgo --build",
92
- "build": "tsdown",
93
- "lint": "biome check .",
94
- "test:unit": "vitest run --passWithNoTests --project unit",
95
- "test:int": "vitest run --passWithNoTests --project int",
96
- "prepublishOnly": "pnpm build && pnpm test:unit",
97
- "lint:fix": "biome check --write ."
98
- },
99
86
  "dependencies": {
87
+ "@keystrokehq/credential-connection": "^0.0.4",
88
+ "@keystrokehq/integration-authoring": "^0.0.5",
100
89
  "@shopify/admin-api-client": "^1.1.2",
101
- "@keystrokehq/credential-connection": "^0.0.1",
102
- "@keystrokehq/integration-authoring": "^0.0.1",
103
- "@keystrokehq/core": "^0.0.5",
104
90
  "zod": "^4.3.6"
105
91
  },
92
+ "peerDependencies": {
93
+ "@keystrokehq/core": ">=0.0.7 <0.1.0"
94
+ },
106
95
  "devDependencies": {
107
- "@types/node": "catalog:",
108
- "@keystrokehq/test-utils": "workspace:*",
109
- "@keystrokehq/typescript-config": "workspace:*",
110
- "tsdown": "catalog:",
111
- "typescript": "catalog:",
112
- "vitest": "catalog:"
96
+ "@types/node": "^22.19.11",
97
+ "tsdown": "^0.20.3",
98
+ "typescript": "^5.9.3",
99
+ "vitest": "^4.0.18",
100
+ "@keystrokehq/core": "^0.0.7",
101
+ "@keystrokehq/test-utils": "0.0.0",
102
+ "@keystrokehq/typescript-config": "0.0.0"
113
103
  },
114
104
  "keywords": [
115
105
  "shopify",
@@ -126,5 +116,13 @@
126
116
  "publishConfig": {
127
117
  "access": "public",
128
118
  "registry": "https://registry.npmjs.org/"
119
+ },
120
+ "scripts": {
121
+ "typecheck": "tsgo --build",
122
+ "build": "tsdown",
123
+ "lint": "biome check .",
124
+ "test:unit": "vitest run --passWithNoTests --project unit",
125
+ "test:int": "vitest run --passWithNoTests --project int",
126
+ "lint:fix": "biome check --write ."
129
127
  }
130
- }
128
+ }
@@ -1,37 +0,0 @@
1
- import { z } from "zod";
2
- import { CredentialSet } from "@keystrokehq/core";
3
- import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
4
- import { InferCredentialSetAuth } from "@keystrokehq/core/credential-set";
5
-
6
- //#region src/_official/provider-app.d.ts
7
- declare const shopifyAppCredentialSet: CredentialSet<"shopify-app", z.ZodObject<{
8
- clientId: z.ZodString;
9
- clientSecret: z.ZodString;
10
- webhookSecret: z.ZodString;
11
- }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
12
- clientId: z.ZodString;
13
- clientSecret: z.ZodString;
14
- webhookSecret: z.ZodString;
15
- }, z.core.$strip>>[] | undefined>;
16
- declare const shopifyPlatformProviderSeed: {
17
- readonly provider: "shopify";
18
- readonly appRef: "shopify-platform";
19
- readonly displayName: "Shopify Platform";
20
- readonly credentialSetName: "Keystroke Shopify Platform App";
21
- readonly envShape: {
22
- readonly KEYSTROKE_PLATFORM_SHOPIFY_APP_ID: z.ZodOptional<z.ZodString>;
23
- readonly KEYSTROKE_PLATFORM_SHOPIFY_CLIENT_ID: z.ZodOptional<z.ZodString>;
24
- readonly KEYSTROKE_PLATFORM_SHOPIFY_CLIENT_SECRET: z.ZodOptional<z.ZodString>;
25
- readonly KEYSTROKE_PLATFORM_SHOPIFY_WEBHOOK_SECRET: z.ZodOptional<z.ZodString>;
26
- };
27
- readonly requiredEnvKeys: readonly ["KEYSTROKE_PLATFORM_SHOPIFY_APP_ID", "KEYSTROKE_PLATFORM_SHOPIFY_CLIENT_ID", "KEYSTROKE_PLATFORM_SHOPIFY_CLIENT_SECRET", "KEYSTROKE_PLATFORM_SHOPIFY_WEBHOOK_SECRET"];
28
- readonly externalAppIdEnvKey: "KEYSTROKE_PLATFORM_SHOPIFY_APP_ID";
29
- readonly buildCredentials: (env: Record<string, string | undefined>) => {
30
- clientId: string | undefined;
31
- clientSecret: string | undefined;
32
- webhookSecret: string | undefined;
33
- };
34
- };
35
- type ShopifyAppCredentials = InferCredentialSetAuth<typeof shopifyAppCredentialSet>;
36
- //#endregion
37
- export { shopifyAppCredentialSet as n, shopifyPlatformProviderSeed as r, ShopifyAppCredentials as t };
@@ -1,23 +0,0 @@
1
- import { n as shopify } from "./integration-BwDBsGX-.mjs";
2
- import { n as shopifyAppCredentialSet } from "./provider-app-DHxVZI6q.mjs";
3
- import { ShopifyOrderCancelledEvent, ShopifyOrderCreatedEvent, ShopifyOrderFulfilledEvent, ShopifyOrderUpdatedEvent, ShopifyProductCreatedEvent, ShopifyProductDeletedEvent, ShopifyProductUpdatedEvent, shopifyOrderWebhookPayloadSchema, shopifyProductWebhookPayloadSchema } from "./events.mjs";
4
- import { z } from "zod";
5
- import { BoundTrigger, WebhookRequest } from "@keystrokehq/core";
6
- import { IntegrationTriggerBindingOptions } from "@keystrokehq/integration-authoring";
7
- import { WebhookTriggerManifest } from "@keystrokehq/core/trigger";
8
-
9
- //#region src/triggers.d.ts
10
- type ShopifyWebhookCredentialSets = readonly [typeof shopify, typeof shopifyAppCredentialSet];
11
- type ShopifyWebhookBindingOptions<TEvent, TOutput = TEvent> = IntegrationTriggerBindingOptions<TEvent, TOutput, WebhookRequest>;
12
- type ShopifyWebhookBinding<TPayloadSchema extends z.ZodTypeAny, TEvent> = <TOutput = TEvent>(options?: ShopifyWebhookBindingOptions<TEvent, TOutput>) => BoundTrigger<z.output<TPayloadSchema>, ShopifyWebhookCredentialSets, WebhookTriggerManifest, TOutput, WebhookRequest>;
13
- declare const webhooks: Readonly<{
14
- productCreated: ShopifyWebhookBinding<typeof shopifyProductWebhookPayloadSchema, ShopifyProductCreatedEvent>;
15
- productUpdated: ShopifyWebhookBinding<typeof shopifyProductWebhookPayloadSchema, ShopifyProductUpdatedEvent>;
16
- productDeleted: ShopifyWebhookBinding<typeof shopifyProductWebhookPayloadSchema, ShopifyProductDeletedEvent>;
17
- orderCreated: ShopifyWebhookBinding<typeof shopifyOrderWebhookPayloadSchema, ShopifyOrderCreatedEvent>;
18
- orderUpdated: ShopifyWebhookBinding<typeof shopifyOrderWebhookPayloadSchema, ShopifyOrderUpdatedEvent>;
19
- orderCancelled: ShopifyWebhookBinding<typeof shopifyOrderWebhookPayloadSchema, ShopifyOrderCancelledEvent>;
20
- orderFulfilled: ShopifyWebhookBinding<typeof shopifyOrderWebhookPayloadSchema, ShopifyOrderFulfilledEvent>;
21
- }>;
22
- //#endregion
23
- export { webhooks };
package/dist/triggers.mjs DELETED
@@ -1,138 +0,0 @@
1
- import { a as shopifyAppCredentialSet, t as shopify } from "./integration-BN3pjCz4.mjs";
2
- import { shopifyOrderCancelledEventSchema, shopifyOrderCreatedEventSchema, shopifyOrderFulfilledEventSchema, shopifyOrderUpdatedEventSchema, shopifyOrderWebhookPayloadSchema, shopifyProductCreatedEventSchema, shopifyProductDeletedEventSchema, shopifyProductUpdatedEventSchema, shopifyProductWebhookPayloadSchema } from "./events.mjs";
3
- import { t as SHOPIFY_WEBHOOK_RUNTIME_DEFINITIONS } from "./webhook-management-BmIxO0vr.mjs";
4
- import { createHmac, timingSafeEqual } from "node:crypto";
5
- import { createWebhookTriggerBindingFactory } from "@keystrokehq/integration-authoring";
6
-
7
- //#region src/verification.ts
8
- function getHeader(headers, name) {
9
- const normalizedName = name.toLowerCase();
10
- for (const [key, value] of Object.entries(headers)) if (key.toLowerCase() === normalizedName) return value;
11
- }
12
- function verifyShopifyWebhook(request, webhookSecret) {
13
- const signature = getHeader(request.headers, "x-shopify-hmac-sha256");
14
- if (!signature) return false;
15
- const expectedDigest = createHmac("sha256", webhookSecret).update(request.rawBody, "utf8").digest("base64");
16
- const signatureBuffer = Buffer.from(signature, "utf8");
17
- const expectedBuffer = Buffer.from(expectedDigest, "utf8");
18
- if (signatureBuffer.length !== expectedBuffer.length) return false;
19
- return timingSafeEqual(signatureBuffer, expectedBuffer);
20
- }
21
-
22
- //#endregion
23
- //#region src/triggers.ts
24
- function getWebhookPath(topic) {
25
- const definition = SHOPIFY_WEBHOOK_RUNTIME_DEFINITIONS.find((candidate) => candidate.eventTopic === topic);
26
- if (!definition) throw new Error(`Unsupported Shopify webhook topic: ${topic}`);
27
- return definition.path;
28
- }
29
- function extractStringField(payload, fieldNames) {
30
- for (const fieldName of fieldNames) {
31
- const value = payload[fieldName];
32
- if (typeof value === "string" && value.length > 0) return value;
33
- }
34
- }
35
- function extractNumberField(payload, fieldNames) {
36
- for (const fieldName of fieldNames) {
37
- const value = payload[fieldName];
38
- if (typeof value === "number" && Number.isFinite(value)) return String(value);
39
- }
40
- }
41
- function buildShopifyWebhookEventId(topic, payload) {
42
- return `${topic}:${extractStringField(payload, ["admin_graphql_api_id"]) ?? extractNumberField(payload, ["id"]) ?? "unknown-resource"}:${extractStringField(payload, [
43
- "updated_at",
44
- "created_at",
45
- "cancelled_at",
46
- "processed_at",
47
- "published_at"
48
- ]) ?? "unknown-time"}`;
49
- }
50
- function createShopifyWebhookBindingFactory(config) {
51
- return createWebhookTriggerBindingFactory({
52
- defaultName: config.defaultName,
53
- defaultDescription: config.defaultDescription,
54
- path: getWebhookPath(config.topic),
55
- method: "POST",
56
- payload: config.payloadSchema,
57
- credentialSets: [shopify, shopifyAppCredentialSet],
58
- verify: (request, ctx) => {
59
- const appCredentials = ctx.credentials["shopify-app"];
60
- if (!verifyShopifyWebhook(request, appCredentials.webhookSecret)) throw new Error("Invalid Shopify webhook signature.");
61
- },
62
- mapPayload: (payload) => config.eventSchema.parse({
63
- eventId: buildShopifyWebhookEventId(config.topic, payload),
64
- topic: config.topic,
65
- resourceId: extractStringField(payload, ["admin_graphql_api_id"]) ?? extractNumberField(payload, ["id"]),
66
- occurredAt: extractStringField(payload, [
67
- "updated_at",
68
- "created_at",
69
- "cancelled_at",
70
- "processed_at",
71
- "published_at"
72
- ]),
73
- payload
74
- }),
75
- response: { successStatus: 200 }
76
- });
77
- }
78
- const productCreatedBinding = createShopifyWebhookBindingFactory({
79
- topic: "products/create",
80
- defaultName: "Shopify Product Created",
81
- defaultDescription: "Trigger when a Shopify product is created.",
82
- payloadSchema: shopifyProductWebhookPayloadSchema,
83
- eventSchema: shopifyProductCreatedEventSchema
84
- });
85
- const productUpdatedBinding = createShopifyWebhookBindingFactory({
86
- topic: "products/update",
87
- defaultName: "Shopify Product Updated",
88
- defaultDescription: "Trigger when a Shopify product is updated.",
89
- payloadSchema: shopifyProductWebhookPayloadSchema,
90
- eventSchema: shopifyProductUpdatedEventSchema
91
- });
92
- const productDeletedBinding = createShopifyWebhookBindingFactory({
93
- topic: "products/delete",
94
- defaultName: "Shopify Product Deleted",
95
- defaultDescription: "Trigger when a Shopify product is deleted.",
96
- payloadSchema: shopifyProductWebhookPayloadSchema,
97
- eventSchema: shopifyProductDeletedEventSchema
98
- });
99
- const orderCreatedBinding = createShopifyWebhookBindingFactory({
100
- topic: "orders/create",
101
- defaultName: "Shopify Order Created",
102
- defaultDescription: "Trigger when a Shopify order is created.",
103
- payloadSchema: shopifyOrderWebhookPayloadSchema,
104
- eventSchema: shopifyOrderCreatedEventSchema
105
- });
106
- const orderUpdatedBinding = createShopifyWebhookBindingFactory({
107
- topic: "orders/updated",
108
- defaultName: "Shopify Order Updated",
109
- defaultDescription: "Trigger when a Shopify order is updated.",
110
- payloadSchema: shopifyOrderWebhookPayloadSchema,
111
- eventSchema: shopifyOrderUpdatedEventSchema
112
- });
113
- const orderCancelledBinding = createShopifyWebhookBindingFactory({
114
- topic: "orders/cancelled",
115
- defaultName: "Shopify Order Cancelled",
116
- defaultDescription: "Trigger when a Shopify order is cancelled.",
117
- payloadSchema: shopifyOrderWebhookPayloadSchema,
118
- eventSchema: shopifyOrderCancelledEventSchema
119
- });
120
- const orderFulfilledBinding = createShopifyWebhookBindingFactory({
121
- topic: "orders/fulfilled",
122
- defaultName: "Shopify Order Fulfilled",
123
- defaultDescription: "Trigger when a Shopify order is fulfilled.",
124
- payloadSchema: shopifyOrderWebhookPayloadSchema,
125
- eventSchema: shopifyOrderFulfilledEventSchema
126
- });
127
- const webhooks = Object.freeze({
128
- productCreated: (options) => productCreatedBinding(options),
129
- productUpdated: (options) => productUpdatedBinding(options),
130
- productDeleted: (options) => productDeletedBinding(options),
131
- orderCreated: (options) => orderCreatedBinding(options),
132
- orderUpdated: (options) => orderUpdatedBinding(options),
133
- orderCancelled: (options) => orderCancelledBinding(options),
134
- orderFulfilled: (options) => orderFulfilledBinding(options)
135
- });
136
-
137
- //#endregion
138
- export { webhooks };
@@ -1,150 +0,0 @@
1
- import { shopifyGlobalIdSchema, shopifyUserErrorSchema } from "./schemas.mjs";
2
- import { createShopifyClient } from "./client.mjs";
3
- import { shopifyWebhookSubscriptionTopicSchema, shopifyWebhookTopicSchema } from "./events.mjs";
4
- import { z } from "zod";
5
-
6
- //#region src/webhook-management.ts
7
- const shopifyWebhookRuntimeDefinitionSchema = z.object({
8
- eventTopic: shopifyWebhookTopicSchema,
9
- subscriptionTopic: shopifyWebhookSubscriptionTopicSchema,
10
- path: z.string().min(1)
11
- });
12
- const SHOPIFY_WEBHOOK_RUNTIME_DEFINITIONS = [
13
- {
14
- eventTopic: "products/create",
15
- subscriptionTopic: "PRODUCTS_CREATE",
16
- path: "/shopify/products/create"
17
- },
18
- {
19
- eventTopic: "products/update",
20
- subscriptionTopic: "PRODUCTS_UPDATE",
21
- path: "/shopify/products/update"
22
- },
23
- {
24
- eventTopic: "products/delete",
25
- subscriptionTopic: "PRODUCTS_DELETE",
26
- path: "/shopify/products/delete"
27
- },
28
- {
29
- eventTopic: "orders/create",
30
- subscriptionTopic: "ORDERS_CREATE",
31
- path: "/shopify/orders/create"
32
- },
33
- {
34
- eventTopic: "orders/updated",
35
- subscriptionTopic: "ORDERS_UPDATED",
36
- path: "/shopify/orders/updated"
37
- },
38
- {
39
- eventTopic: "orders/cancelled",
40
- subscriptionTopic: "ORDERS_CANCELLED",
41
- path: "/shopify/orders/cancelled"
42
- },
43
- {
44
- eventTopic: "orders/fulfilled",
45
- subscriptionTopic: "ORDERS_FULFILLED",
46
- path: "/shopify/orders/fulfilled"
47
- }
48
- ];
49
- const webhookSubscriptionSchema = z.object({
50
- id: shopifyGlobalIdSchema,
51
- topic: shopifyWebhookSubscriptionTopicSchema,
52
- uri: z.string().url()
53
- });
54
- const listWebhookSubscriptionsResponseSchema = z.object({ webhookSubscriptions: z.object({ nodes: z.array(webhookSubscriptionSchema) }) });
55
- const createWebhookSubscriptionResponseSchema = z.object({ webhookSubscriptionCreate: z.object({
56
- webhookSubscription: webhookSubscriptionSchema.nullable(),
57
- userErrors: z.array(shopifyUserErrorSchema)
58
- }) });
59
- const deleteWebhookSubscriptionResponseSchema = z.object({ webhookSubscriptionDelete: z.object({
60
- deletedWebhookSubscriptionId: shopifyGlobalIdSchema.nullable(),
61
- userErrors: z.array(shopifyUserErrorSchema)
62
- }) });
63
- function assertNoUserErrors(userErrors) {
64
- if (userErrors.length === 0) return;
65
- const message = userErrors.map((error) => error.field && error.field.length > 0 ? `${error.field.join(".")}: ${error.message}` : error.message).join("; ");
66
- throw new Error(`Shopify webhook subscription error: ${message}`);
67
- }
68
- function buildShopifyWebhookCallbackUri(baseUrl, path) {
69
- return new URL(path, baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`).toString();
70
- }
71
- async function listShopifyWebhookSubscriptions(credentials) {
72
- return (await createShopifyClient(credentials).graphql(`
73
- query ListWebhookSubscriptions($topics: [WebhookSubscriptionTopic!]) {
74
- webhookSubscriptions(first: 50, topics: $topics) {
75
- nodes {
76
- id
77
- topic
78
- uri
79
- }
80
- }
81
- }
82
- `, listWebhookSubscriptionsResponseSchema, { variables: { topics: SHOPIFY_WEBHOOK_RUNTIME_DEFINITIONS.map((definition) => definition.subscriptionTopic) } })).webhookSubscriptions.nodes;
83
- }
84
- async function createShopifyWebhookSubscription(credentials, topic, uri) {
85
- const response = await createShopifyClient(credentials).graphql(`
86
- mutation CreateWebhookSubscription(
87
- $topic: WebhookSubscriptionTopic!
88
- $webhookSubscription: WebhookSubscriptionInput!
89
- ) {
90
- webhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {
91
- webhookSubscription {
92
- id
93
- topic
94
- uri
95
- }
96
- userErrors {
97
- field
98
- message
99
- }
100
- }
101
- }
102
- `, createWebhookSubscriptionResponseSchema, { variables: {
103
- topic,
104
- webhookSubscription: { uri }
105
- } });
106
- assertNoUserErrors(response.webhookSubscriptionCreate.userErrors);
107
- if (!response.webhookSubscriptionCreate.webhookSubscription) throw new Error(`Shopify did not return the created webhook subscription for ${topic}.`);
108
- return response.webhookSubscriptionCreate.webhookSubscription;
109
- }
110
- async function deleteShopifyWebhookSubscription(credentials, id) {
111
- const response = await createShopifyClient(credentials).graphql(`
112
- mutation DeleteWebhookSubscription($id: ID!) {
113
- webhookSubscriptionDelete(id: $id) {
114
- deletedWebhookSubscriptionId
115
- userErrors {
116
- field
117
- message
118
- }
119
- }
120
- }
121
- `, deleteWebhookSubscriptionResponseSchema, { variables: { id } });
122
- assertNoUserErrors(response.webhookSubscriptionDelete.userErrors);
123
- if (!response.webhookSubscriptionDelete.deletedWebhookSubscriptionId) throw new Error(`Shopify did not confirm deletion for webhook subscription ${id}.`);
124
- return response.webhookSubscriptionDelete.deletedWebhookSubscriptionId;
125
- }
126
- async function ensureShopifyWebhookSubscriptions(credentials, callbackBaseUrl) {
127
- const existing = await listShopifyWebhookSubscriptions(credentials);
128
- const kept = [];
129
- const created = [];
130
- const deleted = [];
131
- for (const definition of SHOPIFY_WEBHOOK_RUNTIME_DEFINITIONS) {
132
- const expectedUri = buildShopifyWebhookCallbackUri(callbackBaseUrl, definition.path);
133
- const matches = existing.filter((subscription) => subscription.topic === definition.subscriptionTopic);
134
- const canonical = matches.find((subscription) => subscription.uri === expectedUri);
135
- if (canonical) kept.push(canonical.id);
136
- for (const subscription of matches) if (!canonical || subscription.id !== canonical.id) deleted.push(await deleteShopifyWebhookSubscription(credentials, subscription.id));
137
- if (!canonical) {
138
- const createdSubscription = await createShopifyWebhookSubscription(credentials, definition.subscriptionTopic, expectedUri);
139
- created.push(createdSubscription.id);
140
- }
141
- }
142
- return {
143
- kept,
144
- created,
145
- deleted
146
- };
147
- }
148
-
149
- //#endregion
150
- export { listShopifyWebhookSubscriptions as i, buildShopifyWebhookCallbackUri as n, ensureShopifyWebhookSubscriptions as r, SHOPIFY_WEBHOOK_RUNTIME_DEFINITIONS as t };