@keystrokehq/shopify 0.0.11 → 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.
Files changed (52) hide show
  1. package/README.md +14 -153
  2. package/dist/{schemas.d.mts → common-C2s35du9.d.mts} +3 -2
  3. package/dist/{schemas.mjs → common-JZyHdK6p.mjs} +3 -3
  4. package/dist/credential-sets/index.d.mts +2 -0
  5. package/dist/credential-sets/index.mjs +4 -0
  6. package/dist/index.d.mts +4 -1
  7. package/dist/index.mjs +6 -1
  8. package/dist/operations/index.d.mts +2 -0
  9. package/dist/operations/index.mjs +3 -0
  10. package/dist/schemas/index.d.mts +2 -0
  11. package/dist/schemas/index.mjs +3 -0
  12. package/dist/shopify-app.credential-set-DuAYUhzY.d.mts +65 -0
  13. package/dist/shopify-app.credential-set-M3vKwTji.mjs +17 -0
  14. package/dist/{integration-vSl3XHTG.mjs → shopify.credential-set-CaxST3GP.mjs} +6 -141
  15. package/dist/update-shopify-product.operation-ByYhZggW.mjs +1972 -0
  16. package/dist/update-shopify-product.operation-Db_kLuJa.d.mts +2817 -0
  17. package/package.json +11 -67
  18. package/dist/_official/index.d.mts +0 -38
  19. package/dist/_official/index.mjs +0 -3
  20. package/dist/_runtime/index.d.mts +0 -56
  21. package/dist/_runtime/index.mjs +0 -150
  22. package/dist/articles.d.mts +0 -174
  23. package/dist/articles.mjs +0 -252
  24. package/dist/blogs.d.mts +0 -113
  25. package/dist/blogs.mjs +0 -174
  26. package/dist/client.d.mts +0 -22
  27. package/dist/client.mjs +0 -90
  28. package/dist/collections.d.mts +0 -140
  29. package/dist/collections.mjs +0 -209
  30. package/dist/connection.d.mts +0 -2
  31. package/dist/connection.mjs +0 -3
  32. package/dist/customers.d.mts +0 -161
  33. package/dist/customers.mjs +0 -225
  34. package/dist/events.d.mts +0 -181
  35. package/dist/events.mjs +0 -67
  36. package/dist/factory-BKmxl2-8.mjs +0 -7
  37. package/dist/fulfillments.d.mts +0 -99
  38. package/dist/fulfillments.mjs +0 -167
  39. package/dist/integration-HrSKAMfF.d.mts +0 -70
  40. package/dist/inventory.d.mts +0 -103
  41. package/dist/inventory.mjs +0 -182
  42. package/dist/locations.d.mts +0 -47
  43. package/dist/locations.mjs +0 -81
  44. package/dist/messaging.d.mts +0 -1
  45. package/dist/messaging.mjs +0 -1
  46. package/dist/operation-helpers-CKEDIx0o.mjs +0 -21
  47. package/dist/orders.d.mts +0 -229
  48. package/dist/orders.mjs +0 -271
  49. package/dist/products.d.mts +0 -155
  50. package/dist/products.mjs +0 -171
  51. package/dist/shop.d.mts +0 -20
  52. package/dist/shop.mjs +0 -31
@@ -1,167 +0,0 @@
1
- import { shopifyConnectionNodesSchema, shopifyFulfillmentSchema, shopifyGlobalIdSchema, shopifyLocationSchema, shopifyUserErrorSchema } from "./schemas.mjs";
2
- import { createShopifyClient } from "./client.mjs";
3
- import { t as shopifyOperation } from "./factory-BKmxl2-8.mjs";
4
- import { t as assertNoUserErrors } from "./operation-helpers-CKEDIx0o.mjs";
5
- import { z } from "zod";
6
-
7
- //#region src/fulfillments.ts
8
- const fulfillmentSelection = `
9
- id
10
- status
11
- trackingInfo {
12
- number
13
- url
14
- }
15
- `;
16
- const fulfillmentOrderLineItemSchema = z.object({
17
- id: shopifyGlobalIdSchema,
18
- remainingQuantity: z.number().int(),
19
- lineItem: z.object({
20
- id: shopifyGlobalIdSchema,
21
- name: z.string(),
22
- quantity: z.number().int()
23
- }).nullable().optional()
24
- });
25
- const fulfillmentOrderSchema = z.object({
26
- id: shopifyGlobalIdSchema,
27
- status: z.string(),
28
- assignedLocation: z.object({ location: shopifyLocationSchema.nullable().optional() }).nullable().optional(),
29
- lineItems: shopifyConnectionNodesSchema(fulfillmentOrderLineItemSchema)
30
- });
31
- const fulfillmentOrderConnectionSchema = z.object({ order: z.object({ fulfillmentOrders: shopifyConnectionNodesSchema(fulfillmentOrderSchema) }).nullable() });
32
- const fulfillmentResponseSchema = z.object({ fulfillment: shopifyFulfillmentSchema.nullable() });
33
- const fulfillmentCreatePayloadSchema = z.object({
34
- fulfillment: shopifyFulfillmentSchema.nullable(),
35
- userErrors: z.array(shopifyUserErrorSchema)
36
- });
37
- const listFulfillmentOrdersForOrder = shopifyOperation({
38
- id: "shopify.list-shopify-fulfillment-orders-for-order",
39
- name: "List Shopify Fulfillment Orders For Order",
40
- description: "List fulfillment orders for a Shopify order so they can be fulfilled.",
41
- input: z.object({
42
- orderId: shopifyGlobalIdSchema,
43
- first: z.number().int().min(1).max(100).optional().default(25),
44
- after: z.string().optional()
45
- }),
46
- output: shopifyConnectionNodesSchema(fulfillmentOrderSchema),
47
- run: async (input, credentials) => {
48
- const response = await createShopifyClient(credentials).graphql(`
49
- query ListFulfillmentOrdersForOrder($id: ID!, $first: Int!, $after: String) {
50
- order(id: $id) {
51
- fulfillmentOrders(first: $first, after: $after) {
52
- nodes {
53
- id
54
- status
55
- assignedLocation {
56
- location {
57
- id
58
- name
59
- isActive
60
- fulfillsOnlineOrders
61
- }
62
- }
63
- lineItems(first: 50) {
64
- nodes {
65
- id
66
- remainingQuantity
67
- lineItem {
68
- id
69
- name
70
- quantity
71
- }
72
- }
73
- pageInfo {
74
- hasNextPage
75
- hasPreviousPage
76
- startCursor
77
- endCursor
78
- }
79
- }
80
- }
81
- pageInfo {
82
- hasNextPage
83
- hasPreviousPage
84
- startCursor
85
- endCursor
86
- }
87
- }
88
- }
89
- }
90
- `, fulfillmentOrderConnectionSchema, { variables: {
91
- id: input.orderId,
92
- first: input.first,
93
- ...input.after ? { after: input.after } : {}
94
- } });
95
- if (!response.order) throw new Error(`Shopify order not found for fulfillment orders lookup: ${input.orderId}`);
96
- return response.order.fulfillmentOrders;
97
- }
98
- });
99
- const getFulfillment = shopifyOperation({
100
- id: "shopify.get-shopify-fulfillment",
101
- name: "Get Shopify Fulfillment",
102
- description: "Retrieve a single Shopify fulfillment by its global ID.",
103
- input: z.object({ id: shopifyGlobalIdSchema }),
104
- output: shopifyFulfillmentSchema,
105
- run: async (input, credentials) => {
106
- const response = await createShopifyClient(credentials).graphql(`
107
- query GetFulfillment($id: ID!) {
108
- fulfillment(id: $id) {
109
- ${fulfillmentSelection}
110
- }
111
- }
112
- `, fulfillmentResponseSchema, { variables: { id: input.id } });
113
- if (!response.fulfillment) throw new Error(`Shopify fulfillment not found: ${input.id}`);
114
- return response.fulfillment;
115
- }
116
- });
117
- const createFulfillment = shopifyOperation({
118
- id: "shopify.create-shopify-fulfillment",
119
- name: "Create Shopify Fulfillment",
120
- description: "Create a fulfillment from one or more Shopify fulfillment orders.",
121
- needsApproval: true,
122
- input: z.object({
123
- lineItemsByFulfillmentOrder: z.array(z.object({
124
- fulfillmentOrderId: shopifyGlobalIdSchema,
125
- fulfillmentOrderLineItems: z.array(z.object({
126
- id: shopifyGlobalIdSchema,
127
- quantity: z.number().int().min(1)
128
- })).optional()
129
- })).min(1),
130
- notifyCustomer: z.boolean().optional(),
131
- message: z.string().optional(),
132
- trackingInfo: z.object({
133
- company: z.string().optional(),
134
- number: z.string().optional(),
135
- url: z.url().optional()
136
- }).optional()
137
- }),
138
- output: shopifyFulfillmentSchema,
139
- run: async (input, credentials) => {
140
- const response = await createShopifyClient(credentials).graphql(`
141
- mutation CreateFulfillment($fulfillment: FulfillmentInput!, $message: String) {
142
- fulfillmentCreate(fulfillment: $fulfillment, message: $message) {
143
- fulfillment {
144
- ${fulfillmentSelection}
145
- }
146
- userErrors {
147
- field
148
- message
149
- }
150
- }
151
- }
152
- `, z.object({ fulfillmentCreate: fulfillmentCreatePayloadSchema }), { variables: {
153
- fulfillment: {
154
- lineItemsByFulfillmentOrder: input.lineItemsByFulfillmentOrder,
155
- notifyCustomer: input.notifyCustomer,
156
- trackingInfo: input.trackingInfo
157
- },
158
- ...input.message ? { message: input.message } : {}
159
- } });
160
- assertNoUserErrors(response.fulfillmentCreate.userErrors);
161
- if (!response.fulfillmentCreate.fulfillment) throw new Error("Shopify did not return the created fulfillment.");
162
- return response.fulfillmentCreate.fulfillment;
163
- }
164
- });
165
-
166
- //#endregion
167
- export { createFulfillment, getFulfillment, listFulfillmentOrdersForOrder };
@@ -1,70 +0,0 @@
1
- import * as _keystrokehq_core0 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/integration.d.ts
7
- declare const shopifyOfficialIntegration: {
8
- id: "shopify";
9
- name: string;
10
- description: string;
11
- auth: z.ZodObject<{
12
- SHOPIFY_STORE_DOMAIN: z.ZodString;
13
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
14
- }, z.core.$strip>;
15
- connections: {
16
- kind: "oauth";
17
- tokenType: "refreshable";
18
- authUrl: "https://{shop}.myshopify.com/admin/oauth/authorize";
19
- tokenUrl: "https://{shop}.myshopify.com/admin/oauth/access_token";
20
- revokeUrl: null;
21
- 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"];
22
- vault: {
23
- readonly accessToken: "SHOPIFY_ACCESS_TOKEN";
24
- readonly raw: {
25
- readonly SHOPIFY_STORE_DOMAIN: "_shopifyShopDomain";
26
- };
27
- };
28
- buildAuthUrl: ({
29
- oauthClient,
30
- redirectUri,
31
- state,
32
- connection,
33
- initiateInput,
34
- requestedScopes
35
- }: _keystrokehq_core_credential_set0.BuildAuthUrlContext) => string;
36
- exchangeCode: ({
37
- oauthClient,
38
- code,
39
- queryParams
40
- }: _keystrokehq_core_credential_set0.ExchangeCodeContext) => Promise<_keystrokehq_core_credential_set0.TokenResult>;
41
- refreshToken: ({
42
- oauthClient,
43
- refreshToken
44
- }: _keystrokehq_core_credential_set0.RefreshTokenContext) => Promise<_keystrokehq_core_credential_set0.TokenResult>;
45
- extractInstallationInfo: ({
46
- tokenResult
47
- }: _keystrokehq_core_credential_set0.ExtractInstallationContext) => {
48
- externalInstallationId: string | undefined;
49
- externalWorkspaceId: string | undefined;
50
- metadata: {
51
- shopDomain: string;
52
- } | undefined;
53
- };
54
- id: string;
55
- }[];
56
- };
57
- declare const shopifyBundle: undefined<"shopify", z.ZodObject<{
58
- SHOPIFY_STORE_DOMAIN: z.ZodString;
59
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
60
- }, z.core.$strip>>;
61
- declare const shopify: _keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
62
- SHOPIFY_STORE_DOMAIN: z.ZodString;
63
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
64
- }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
65
- SHOPIFY_STORE_DOMAIN: z.ZodString;
66
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
67
- }, z.core.$strip>>[] | undefined>;
68
- type ShopifyCredentials = InferCredentialSetAuth<typeof shopify>;
69
- //#endregion
70
- export { shopifyOfficialIntegration as i, shopify as n, shopifyBundle as r, ShopifyCredentials as t };
@@ -1,103 +0,0 @@
1
- import * as _keystrokehq_core0 from "@keystrokehq/core";
2
- import { z } from "zod";
3
- import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
4
-
5
- //#region src/inventory.d.ts
6
- declare const listInventoryItems: _keystrokehq_core0.Operation<z.ZodObject<{
7
- first: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
8
- after: z.ZodOptional<z.ZodString>;
9
- query: z.ZodOptional<z.ZodString>;
10
- }, z.core.$strip>, z.ZodObject<{
11
- nodes: z.ZodArray<z.ZodObject<{
12
- id: z.ZodString;
13
- sku: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
- tracked: z.ZodOptional<z.ZodBoolean>;
15
- }, z.core.$strip>>;
16
- pageInfo: z.ZodObject<{
17
- hasNextPage: z.ZodBoolean;
18
- hasPreviousPage: z.ZodOptional<z.ZodBoolean>;
19
- startCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
- endCursor: z.ZodNullable<z.ZodString>;
21
- }, z.core.$strip>;
22
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
23
- SHOPIFY_STORE_DOMAIN: z.ZodString;
24
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
25
- }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
26
- SHOPIFY_STORE_DOMAIN: z.ZodString;
27
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
28
- }, z.core.$strip>>[] | undefined>], undefined>;
29
- declare const getInventoryItem: _keystrokehq_core0.Operation<z.ZodObject<{
30
- id: z.ZodString;
31
- }, z.core.$strip>, z.ZodObject<{
32
- id: z.ZodString;
33
- sku: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
- tracked: z.ZodOptional<z.ZodBoolean>;
35
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
36
- SHOPIFY_STORE_DOMAIN: z.ZodString;
37
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
38
- }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
39
- SHOPIFY_STORE_DOMAIN: z.ZodString;
40
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
41
- }, z.core.$strip>>[] | undefined>], undefined>;
42
- declare const getInventoryLevelsForItem: _keystrokehq_core0.Operation<z.ZodObject<{
43
- inventoryItemId: z.ZodString;
44
- first: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
45
- after: z.ZodOptional<z.ZodString>;
46
- }, z.core.$strip>, z.ZodObject<{
47
- nodes: z.ZodArray<z.ZodObject<{
48
- id: z.ZodString;
49
- quantities: z.ZodArray<z.ZodObject<{
50
- name: z.ZodString;
51
- quantity: z.ZodNumber;
52
- }, z.core.$strip>>;
53
- item: z.ZodOptional<z.ZodObject<{
54
- id: z.ZodString;
55
- sku: z.ZodOptional<z.ZodNullable<z.ZodString>>;
56
- tracked: z.ZodOptional<z.ZodBoolean>;
57
- }, z.core.$strip>>;
58
- location: z.ZodOptional<z.ZodObject<{
59
- id: z.ZodString;
60
- name: z.ZodString;
61
- isActive: z.ZodOptional<z.ZodBoolean>;
62
- fulfillsOnlineOrders: z.ZodOptional<z.ZodBoolean>;
63
- }, z.core.$strip>>;
64
- }, z.core.$strip>>;
65
- pageInfo: z.ZodObject<{
66
- hasNextPage: z.ZodBoolean;
67
- hasPreviousPage: z.ZodOptional<z.ZodBoolean>;
68
- startCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
69
- endCursor: z.ZodNullable<z.ZodString>;
70
- }, z.core.$strip>;
71
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
72
- SHOPIFY_STORE_DOMAIN: z.ZodString;
73
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
74
- }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
75
- SHOPIFY_STORE_DOMAIN: z.ZodString;
76
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
77
- }, z.core.$strip>>[] | undefined>], undefined>;
78
- declare const adjustInventoryQuantities: _keystrokehq_core0.Operation<z.ZodObject<{
79
- name: z.ZodDefault<z.ZodString>;
80
- reason: z.ZodString;
81
- referenceDocumentUri: z.ZodOptional<z.ZodString>;
82
- changes: z.ZodArray<z.ZodObject<{
83
- inventoryItemId: z.ZodString;
84
- locationId: z.ZodString;
85
- delta: z.ZodNumber;
86
- }, z.core.$strip>>;
87
- }, z.core.$strip>, z.ZodObject<{
88
- createdAt: z.ZodOptional<z.ZodISODateTime>;
89
- reason: z.ZodString;
90
- referenceDocumentUri: z.ZodOptional<z.ZodNullable<z.ZodString>>;
91
- changes: z.ZodArray<z.ZodObject<{
92
- name: z.ZodString;
93
- delta: z.ZodNumber;
94
- }, z.core.$strip>>;
95
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
96
- SHOPIFY_STORE_DOMAIN: z.ZodString;
97
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
98
- }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
99
- SHOPIFY_STORE_DOMAIN: z.ZodString;
100
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
101
- }, z.core.$strip>>[] | undefined>], undefined>;
102
- //#endregion
103
- export { adjustInventoryQuantities, getInventoryItem, getInventoryLevelsForItem, listInventoryItems };
@@ -1,182 +0,0 @@
1
- import { shopifyConnectionNodesSchema, shopifyGlobalIdSchema, shopifyInventoryItemSchema, shopifyInventoryLevelSchema, shopifyUserErrorSchema } from "./schemas.mjs";
2
- import { createShopifyClient } from "./client.mjs";
3
- import { t as shopifyOperation } from "./factory-BKmxl2-8.mjs";
4
- import { r as shopifyPageInputSchema, t as assertNoUserErrors } from "./operation-helpers-CKEDIx0o.mjs";
5
- import { z } from "zod";
6
-
7
- //#region src/inventory.ts
8
- const inventoryItemSelection = `
9
- id
10
- sku
11
- tracked
12
- `;
13
- const inventoryLevelSelection = `
14
- id
15
- quantities(names: ["available", "committed", "incoming", "on_hand", "reserved"]) {
16
- name
17
- quantity
18
- }
19
- item {
20
- ${inventoryItemSelection}
21
- }
22
- location {
23
- id
24
- name
25
- isActive
26
- fulfillsOnlineOrders
27
- }
28
- `;
29
- const listInventoryItemsResponseSchema = z.object({ inventoryItems: shopifyConnectionNodesSchema(shopifyInventoryItemSchema) });
30
- const getInventoryItemResponseSchema = z.object({ inventoryItem: shopifyInventoryItemSchema.nullable() });
31
- const inventoryLevelsResponseSchema = z.object({ inventoryItem: z.object({ inventoryLevels: shopifyConnectionNodesSchema(shopifyInventoryLevelSchema) }).nullable() });
32
- const inventoryAdjustmentResponseSchema = z.object({
33
- inventoryAdjustmentGroup: z.object({
34
- createdAt: z.iso.datetime().optional(),
35
- reason: z.string(),
36
- referenceDocumentUri: z.string().nullable().optional(),
37
- changes: z.array(z.object({
38
- name: z.string(),
39
- delta: z.number()
40
- }))
41
- }).nullable(),
42
- userErrors: z.array(shopifyUserErrorSchema)
43
- });
44
- const listInventoryItems = shopifyOperation({
45
- id: "shopify.list-shopify-inventory-items",
46
- name: "List Shopify Inventory Items",
47
- description: "List inventory items from the connected Shopify store.",
48
- input: shopifyPageInputSchema,
49
- output: shopifyConnectionNodesSchema(shopifyInventoryItemSchema),
50
- run: async (input, credentials) => {
51
- return (await createShopifyClient(credentials).graphql(`
52
- query ListInventoryItems($first: Int!, $after: String, $query: String) {
53
- inventoryItems(first: $first, after: $after, query: $query) {
54
- nodes {
55
- ${inventoryItemSelection}
56
- }
57
- pageInfo {
58
- hasNextPage
59
- hasPreviousPage
60
- startCursor
61
- endCursor
62
- }
63
- }
64
- }
65
- `, listInventoryItemsResponseSchema, { variables: {
66
- first: input.first,
67
- ...input.after ? { after: input.after } : {},
68
- ...input.query ? { query: input.query } : {}
69
- } })).inventoryItems;
70
- }
71
- });
72
- const getInventoryItem = shopifyOperation({
73
- id: "shopify.get-shopify-inventory-item",
74
- name: "Get Shopify Inventory Item",
75
- description: "Retrieve a single Shopify inventory item by its global ID.",
76
- input: z.object({ id: shopifyGlobalIdSchema }),
77
- output: shopifyInventoryItemSchema,
78
- run: async (input, credentials) => {
79
- const response = await createShopifyClient(credentials).graphql(`
80
- query GetInventoryItem($id: ID!) {
81
- inventoryItem(id: $id) {
82
- ${inventoryItemSelection}
83
- }
84
- }
85
- `, getInventoryItemResponseSchema, { variables: { id: input.id } });
86
- if (!response.inventoryItem) throw new Error(`Shopify inventory item not found: ${input.id}`);
87
- return response.inventoryItem;
88
- }
89
- });
90
- const getInventoryLevelsForItem = shopifyOperation({
91
- id: "shopify.get-shopify-inventory-levels-for-item",
92
- name: "Get Shopify Inventory Levels For Item",
93
- description: "Retrieve inventory levels for a specific Shopify inventory item.",
94
- input: z.object({
95
- inventoryItemId: shopifyGlobalIdSchema,
96
- first: z.number().int().min(1).max(100).optional().default(25),
97
- after: z.string().optional()
98
- }),
99
- output: shopifyConnectionNodesSchema(shopifyInventoryLevelSchema),
100
- run: async (input, credentials) => {
101
- const response = await createShopifyClient(credentials).graphql(`
102
- query GetInventoryLevelsForItem($id: ID!, $first: Int!, $after: String) {
103
- inventoryItem(id: $id) {
104
- inventoryLevels(first: $first, after: $after) {
105
- nodes {
106
- ${inventoryLevelSelection}
107
- }
108
- pageInfo {
109
- hasNextPage
110
- hasPreviousPage
111
- startCursor
112
- endCursor
113
- }
114
- }
115
- }
116
- }
117
- `, inventoryLevelsResponseSchema, { variables: {
118
- id: input.inventoryItemId,
119
- first: input.first,
120
- ...input.after ? { after: input.after } : {}
121
- } });
122
- if (!response.inventoryItem) throw new Error(`Shopify inventory item not found for inventory levels lookup: ${input.inventoryItemId}`);
123
- return response.inventoryItem.inventoryLevels;
124
- }
125
- });
126
- const adjustInventoryQuantities = shopifyOperation({
127
- id: "shopify.adjust-shopify-inventory-quantities",
128
- name: "Adjust Shopify Inventory Quantities",
129
- description: "Adjust inventory quantities at specific Shopify locations.",
130
- needsApproval: true,
131
- input: z.object({
132
- name: z.string().min(1).default("available"),
133
- reason: z.string().min(1),
134
- referenceDocumentUri: z.string().optional(),
135
- changes: z.array(z.object({
136
- inventoryItemId: shopifyGlobalIdSchema,
137
- locationId: shopifyGlobalIdSchema,
138
- delta: z.number().int()
139
- })).min(1)
140
- }),
141
- output: z.object({
142
- createdAt: z.iso.datetime().optional(),
143
- reason: z.string(),
144
- referenceDocumentUri: z.string().nullable().optional(),
145
- changes: z.array(z.object({
146
- name: z.string(),
147
- delta: z.number()
148
- }))
149
- }),
150
- run: async (input, credentials) => {
151
- const response = await createShopifyClient(credentials).graphql(`
152
- mutation AdjustInventoryQuantities($input: InventoryAdjustQuantitiesInput!) {
153
- inventoryAdjustQuantities(input: $input) {
154
- inventoryAdjustmentGroup {
155
- createdAt
156
- reason
157
- referenceDocumentUri
158
- changes {
159
- name
160
- delta
161
- }
162
- }
163
- userErrors {
164
- field
165
- message
166
- }
167
- }
168
- }
169
- `, z.object({ inventoryAdjustQuantities: inventoryAdjustmentResponseSchema }), { variables: { input: {
170
- name: input.name,
171
- reason: input.reason,
172
- referenceDocumentUri: input.referenceDocumentUri,
173
- changes: input.changes
174
- } } });
175
- assertNoUserErrors(response.inventoryAdjustQuantities.userErrors);
176
- if (!response.inventoryAdjustQuantities.inventoryAdjustmentGroup) throw new Error("Shopify did not return the inventory adjustment group.");
177
- return response.inventoryAdjustQuantities.inventoryAdjustmentGroup;
178
- }
179
- });
180
-
181
- //#endregion
182
- export { adjustInventoryQuantities, getInventoryItem, getInventoryLevelsForItem, listInventoryItems };
@@ -1,47 +0,0 @@
1
- import * as _keystrokehq_core0 from "@keystrokehq/core";
2
- import { z } from "zod";
3
- import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
4
-
5
- //#region src/locations.d.ts
6
- declare const listLocations: _keystrokehq_core0.Operation<z.ZodObject<{
7
- first: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
8
- after: z.ZodOptional<z.ZodString>;
9
- query: z.ZodOptional<z.ZodString>;
10
- includeInactive: z.ZodOptional<z.ZodBoolean>;
11
- includeLegacy: z.ZodOptional<z.ZodBoolean>;
12
- }, z.core.$strip>, z.ZodObject<{
13
- nodes: z.ZodArray<z.ZodObject<{
14
- id: z.ZodString;
15
- name: z.ZodString;
16
- isActive: z.ZodOptional<z.ZodBoolean>;
17
- fulfillsOnlineOrders: z.ZodOptional<z.ZodBoolean>;
18
- }, z.core.$strip>>;
19
- pageInfo: z.ZodObject<{
20
- hasNextPage: z.ZodBoolean;
21
- hasPreviousPage: z.ZodOptional<z.ZodBoolean>;
22
- startCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
23
- endCursor: z.ZodNullable<z.ZodString>;
24
- }, z.core.$strip>;
25
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
26
- SHOPIFY_STORE_DOMAIN: z.ZodString;
27
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
28
- }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
29
- SHOPIFY_STORE_DOMAIN: z.ZodString;
30
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
31
- }, z.core.$strip>>[] | undefined>], undefined>;
32
- declare const getLocation: _keystrokehq_core0.Operation<z.ZodObject<{
33
- id: z.ZodString;
34
- }, z.core.$strip>, z.ZodObject<{
35
- id: z.ZodString;
36
- name: z.ZodString;
37
- isActive: z.ZodOptional<z.ZodBoolean>;
38
- fulfillsOnlineOrders: z.ZodOptional<z.ZodBoolean>;
39
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"shopify", z.ZodObject<{
40
- SHOPIFY_STORE_DOMAIN: z.ZodString;
41
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
42
- }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
43
- SHOPIFY_STORE_DOMAIN: z.ZodString;
44
- SHOPIFY_ACCESS_TOKEN: z.ZodString;
45
- }, z.core.$strip>>[] | undefined>], undefined>;
46
- //#endregion
47
- export { getLocation, listLocations };
@@ -1,81 +0,0 @@
1
- import { shopifyConnectionNodesSchema, shopifyGlobalIdSchema, shopifyLocationSchema } from "./schemas.mjs";
2
- import { createShopifyClient } from "./client.mjs";
3
- import { t as shopifyOperation } from "./factory-BKmxl2-8.mjs";
4
- import { r as shopifyPageInputSchema } from "./operation-helpers-CKEDIx0o.mjs";
5
- import { z } from "zod";
6
-
7
- //#region src/locations.ts
8
- const locationSelection = `
9
- id
10
- name
11
- isActive
12
- fulfillsOnlineOrders
13
- `;
14
- const listLocationsResponseSchema = z.object({ locations: shopifyConnectionNodesSchema(shopifyLocationSchema) });
15
- const getLocationResponseSchema = z.object({ location: shopifyLocationSchema.nullable() });
16
- const listLocations = shopifyOperation({
17
- id: "shopify.list-shopify-locations",
18
- name: "List Shopify Locations",
19
- description: "List locations from the connected Shopify store.",
20
- input: shopifyPageInputSchema.extend({
21
- includeInactive: z.boolean().optional(),
22
- includeLegacy: z.boolean().optional()
23
- }),
24
- output: shopifyConnectionNodesSchema(shopifyLocationSchema),
25
- run: async (input, credentials) => {
26
- return (await createShopifyClient(credentials).graphql(`
27
- query ListLocations(
28
- $first: Int!
29
- $after: String
30
- $query: String
31
- $includeInactive: Boolean
32
- $includeLegacy: Boolean
33
- ) {
34
- locations(
35
- first: $first
36
- after: $after
37
- query: $query
38
- includeInactive: $includeInactive
39
- includeLegacy: $includeLegacy
40
- ) {
41
- nodes {
42
- ${locationSelection}
43
- }
44
- pageInfo {
45
- hasNextPage
46
- hasPreviousPage
47
- startCursor
48
- endCursor
49
- }
50
- }
51
- }
52
- `, listLocationsResponseSchema, { variables: {
53
- first: input.first,
54
- ...input.after ? { after: input.after } : {},
55
- ...input.query ? { query: input.query } : {},
56
- ...input.includeInactive !== void 0 ? { includeInactive: input.includeInactive } : {},
57
- ...input.includeLegacy !== void 0 ? { includeLegacy: input.includeLegacy } : {}
58
- } })).locations;
59
- }
60
- });
61
- const getLocation = shopifyOperation({
62
- id: "shopify.get-shopify-location",
63
- name: "Get Shopify Location",
64
- description: "Retrieve a single Shopify location by its global ID.",
65
- input: z.object({ id: shopifyGlobalIdSchema }),
66
- output: shopifyLocationSchema,
67
- run: async (input, credentials) => {
68
- const response = await createShopifyClient(credentials).graphql(`
69
- query GetLocation($id: ID!) {
70
- location(id: $id) {
71
- ${locationSelection}
72
- }
73
- }
74
- `, getLocationResponseSchema, { variables: { id: input.id } });
75
- if (!response.location) throw new Error(`Shopify location not found: ${input.id}`);
76
- return response.location;
77
- }
78
- });
79
-
80
- //#endregion
81
- export { getLocation, listLocations };
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };
@@ -1,21 +0,0 @@
1
- import { shopifyGlobalIdSchema } from "./schemas.mjs";
2
- import { z } from "zod";
3
-
4
- //#region src/operation-helpers.ts
5
- const shopifyPageInputSchema = z.object({
6
- first: z.number().int().min(1).max(100).optional().default(25),
7
- after: z.string().optional(),
8
- query: z.string().optional()
9
- });
10
- const shopifyProductIdsInputSchema = z.array(shopifyGlobalIdSchema).min(1).max(250);
11
- function assertNoUserErrors(userErrors) {
12
- if (userErrors.length === 0) return;
13
- const message = userErrors.map((error) => error.field && error.field.length > 0 ? `${error.field.join(".")}: ${error.message}` : error.message).join("; ");
14
- throw new Error(`Shopify mutation returned user errors: ${message}`);
15
- }
16
- function omitUndefined(input) {
17
- return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
18
- }
19
-
20
- //#endregion
21
- export { shopifyProductIdsInputSchema as i, omitUndefined as n, shopifyPageInputSchema as r, assertNoUserErrors as t };