@uniforge/platform-shopify 0.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/auth/index.d.cts +246 -0
  2. package/dist/auth/index.d.ts +246 -0
  3. package/dist/auth/index.js +623 -0
  4. package/dist/auth/index.js.map +1 -0
  5. package/dist/auth/index.mjs +586 -0
  6. package/dist/auth/index.mjs.map +1 -0
  7. package/dist/billing/index.d.cts +58 -0
  8. package/dist/billing/index.d.ts +58 -0
  9. package/dist/billing/index.js +226 -0
  10. package/dist/billing/index.js.map +1 -0
  11. package/dist/billing/index.mjs +196 -0
  12. package/dist/billing/index.mjs.map +1 -0
  13. package/dist/graphql/index.d.cts +17 -0
  14. package/dist/graphql/index.d.ts +17 -0
  15. package/dist/graphql/index.js +67 -0
  16. package/dist/graphql/index.js.map +1 -0
  17. package/dist/graphql/index.mjs +40 -0
  18. package/dist/graphql/index.mjs.map +1 -0
  19. package/dist/index.d.cts +16 -0
  20. package/dist/index.d.ts +16 -0
  21. package/dist/index.js +37 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/index.mjs +11 -0
  24. package/dist/index.mjs.map +1 -0
  25. package/dist/multi-store/index.d.cts +28 -0
  26. package/dist/multi-store/index.d.ts +28 -0
  27. package/dist/multi-store/index.js +181 -0
  28. package/dist/multi-store/index.js.map +1 -0
  29. package/dist/multi-store/index.mjs +152 -0
  30. package/dist/multi-store/index.mjs.map +1 -0
  31. package/dist/performance/index.d.cts +22 -0
  32. package/dist/performance/index.d.ts +22 -0
  33. package/dist/performance/index.js +64 -0
  34. package/dist/performance/index.js.map +1 -0
  35. package/dist/performance/index.mjs +35 -0
  36. package/dist/performance/index.mjs.map +1 -0
  37. package/dist/platform/index.d.cts +16 -0
  38. package/dist/platform/index.d.ts +16 -0
  39. package/dist/platform/index.js +150 -0
  40. package/dist/platform/index.js.map +1 -0
  41. package/dist/platform/index.mjs +121 -0
  42. package/dist/platform/index.mjs.map +1 -0
  43. package/dist/rbac/index.d.cts +38 -0
  44. package/dist/rbac/index.d.ts +38 -0
  45. package/dist/rbac/index.js +56 -0
  46. package/dist/rbac/index.js.map +1 -0
  47. package/dist/rbac/index.mjs +29 -0
  48. package/dist/rbac/index.mjs.map +1 -0
  49. package/dist/security/index.d.cts +26 -0
  50. package/dist/security/index.d.ts +26 -0
  51. package/dist/security/index.js +102 -0
  52. package/dist/security/index.js.map +1 -0
  53. package/dist/security/index.mjs +69 -0
  54. package/dist/security/index.mjs.map +1 -0
  55. package/dist/webhooks/index.d.cts +36 -0
  56. package/dist/webhooks/index.d.ts +36 -0
  57. package/dist/webhooks/index.js +147 -0
  58. package/dist/webhooks/index.js.map +1 -0
  59. package/dist/webhooks/index.mjs +118 -0
  60. package/dist/webhooks/index.mjs.map +1 -0
  61. package/package.json +95 -0
@@ -0,0 +1,118 @@
1
+ // src/webhooks/registration.ts
2
+ var WEBHOOK_SUBSCRIPTION_CREATE = `
3
+ mutation webhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: WebhookSubscriptionInput!) {
4
+ webhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {
5
+ webhookSubscription {
6
+ id
7
+ }
8
+ userErrors {
9
+ field
10
+ message
11
+ }
12
+ }
13
+ }
14
+ `;
15
+ var WEBHOOK_SUBSCRIPTION_DELETE = `
16
+ mutation webhookSubscriptionDelete($id: ID!) {
17
+ webhookSubscriptionDelete(id: $id) {
18
+ deletedWebhookSubscriptionId
19
+ userErrors {
20
+ field
21
+ message
22
+ }
23
+ }
24
+ }
25
+ `;
26
+ var WEBHOOK_SUBSCRIPTIONS_QUERY = `
27
+ query webhookSubscriptions($first: Int!) {
28
+ webhookSubscriptions(first: $first) {
29
+ edges {
30
+ node {
31
+ id
32
+ topic
33
+ endpoint {
34
+ ... on WebhookHttpEndpoint {
35
+ callbackUrl
36
+ }
37
+ }
38
+ format
39
+ }
40
+ }
41
+ }
42
+ }
43
+ `;
44
+ async function registerShopifyWebhook(graphqlFn, registration) {
45
+ const response = await graphqlFn(WEBHOOK_SUBSCRIPTION_CREATE, {
46
+ topic: registration.topic,
47
+ webhookSubscription: {
48
+ callbackUrl: registration.address,
49
+ format: (registration.format ?? "json").toUpperCase()
50
+ }
51
+ });
52
+ if (response.errors && response.errors.length > 0) {
53
+ return {
54
+ success: false,
55
+ errors: response.errors.map((e) => String(e))
56
+ };
57
+ }
58
+ const data = response.data;
59
+ const result = data.webhookSubscriptionCreate;
60
+ if (result.userErrors.length > 0) {
61
+ return {
62
+ success: false,
63
+ errors: result.userErrors.map((e) => e.message)
64
+ };
65
+ }
66
+ const registerResult = { success: true };
67
+ const subscriptionId = result.webhookSubscription?.id;
68
+ if (subscriptionId) {
69
+ registerResult.webhookSubscriptionId = subscriptionId;
70
+ }
71
+ return registerResult;
72
+ }
73
+ async function unregisterShopifyWebhook(graphqlFn, webhookId) {
74
+ const response = await graphqlFn(WEBHOOK_SUBSCRIPTION_DELETE, {
75
+ id: webhookId
76
+ });
77
+ if (response.errors && response.errors.length > 0) {
78
+ return {
79
+ success: false,
80
+ errors: response.errors.map((e) => String(e))
81
+ };
82
+ }
83
+ const data = response.data;
84
+ const result = data.webhookSubscriptionDelete;
85
+ if (result.userErrors.length > 0) {
86
+ return {
87
+ success: false,
88
+ errors: result.userErrors.map((e) => e.message)
89
+ };
90
+ }
91
+ return { success: true };
92
+ }
93
+ async function listShopifyWebhooks(graphqlFn, first = 50) {
94
+ const response = await graphqlFn(WEBHOOK_SUBSCRIPTIONS_QUERY, { first });
95
+ if (response.errors && response.errors.length > 0) {
96
+ return [];
97
+ }
98
+ const data = response.data;
99
+ return data.webhookSubscriptions.edges.map((edge) => {
100
+ const sub = {
101
+ id: edge.node.id,
102
+ topic: edge.node.topic,
103
+ endpoint: {},
104
+ format: edge.node.format
105
+ };
106
+ const callbackUrl = edge.node.endpoint.callbackUrl;
107
+ if (callbackUrl) {
108
+ sub.endpoint.callbackUrl = callbackUrl;
109
+ }
110
+ return sub;
111
+ });
112
+ }
113
+ export {
114
+ listShopifyWebhooks,
115
+ registerShopifyWebhook,
116
+ unregisterShopifyWebhook
117
+ };
118
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/webhooks/registration.ts"],"sourcesContent":["/**\n * Shopify webhook registration via GraphQL.\n *\n * Uses dependency-injected GraphQL function to register, unregister,\n * and list webhook subscriptions without importing the full Shopify client.\n */\n\nimport type { WebhookRegistration } from '@uniforge/platform-core/webhooks';\n\n/** Dependency-injected GraphQL query function. */\nexport type GraphQLFn = (\n query: string,\n variables?: Record<string, unknown>,\n) => Promise<{ data?: unknown; errors?: unknown[] }>;\n\nexport interface ShopifyWebhookSubscription {\n id: string;\n topic: string;\n endpoint: {\n callbackUrl?: string;\n };\n format: string;\n}\n\nexport interface RegisterWebhookResult {\n success: boolean;\n webhookSubscriptionId?: string;\n errors?: string[];\n}\n\nexport interface UnregisterWebhookResult {\n success: boolean;\n errors?: string[];\n}\n\nconst WEBHOOK_SUBSCRIPTION_CREATE = `\n mutation webhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: WebhookSubscriptionInput!) {\n webhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n webhookSubscription {\n id\n }\n userErrors {\n field\n message\n }\n }\n }\n`;\n\nconst WEBHOOK_SUBSCRIPTION_DELETE = `\n mutation webhookSubscriptionDelete($id: ID!) {\n webhookSubscriptionDelete(id: $id) {\n deletedWebhookSubscriptionId\n userErrors {\n field\n message\n }\n }\n }\n`;\n\nconst WEBHOOK_SUBSCRIPTIONS_QUERY = `\n query webhookSubscriptions($first: Int!) {\n webhookSubscriptions(first: $first) {\n edges {\n node {\n id\n topic\n endpoint {\n ... on WebhookHttpEndpoint {\n callbackUrl\n }\n }\n format\n }\n }\n }\n }\n`;\n\nexport async function registerShopifyWebhook(\n graphqlFn: GraphQLFn,\n registration: WebhookRegistration,\n): Promise<RegisterWebhookResult> {\n const response = await graphqlFn(WEBHOOK_SUBSCRIPTION_CREATE, {\n topic: registration.topic,\n webhookSubscription: {\n callbackUrl: registration.address,\n format: (registration.format ?? 'json').toUpperCase(),\n },\n });\n\n if (response.errors && response.errors.length > 0) {\n return {\n success: false,\n errors: response.errors.map((e) => String(e)),\n };\n }\n\n const data = response.data as {\n webhookSubscriptionCreate: {\n webhookSubscription: { id: string } | null;\n userErrors: Array<{ field: string[]; message: string }>;\n };\n };\n\n const result = data.webhookSubscriptionCreate;\n if (result.userErrors.length > 0) {\n return {\n success: false,\n errors: result.userErrors.map((e) => e.message),\n };\n }\n\n const registerResult: RegisterWebhookResult = { success: true };\n const subscriptionId = result.webhookSubscription?.id;\n if (subscriptionId) {\n registerResult.webhookSubscriptionId = subscriptionId;\n }\n return registerResult;\n}\n\nexport async function unregisterShopifyWebhook(\n graphqlFn: GraphQLFn,\n webhookId: string,\n): Promise<UnregisterWebhookResult> {\n const response = await graphqlFn(WEBHOOK_SUBSCRIPTION_DELETE, {\n id: webhookId,\n });\n\n if (response.errors && response.errors.length > 0) {\n return {\n success: false,\n errors: response.errors.map((e) => String(e)),\n };\n }\n\n const data = response.data as {\n webhookSubscriptionDelete: {\n deletedWebhookSubscriptionId: string | null;\n userErrors: Array<{ field: string[]; message: string }>;\n };\n };\n\n const result = data.webhookSubscriptionDelete;\n if (result.userErrors.length > 0) {\n return {\n success: false,\n errors: result.userErrors.map((e) => e.message),\n };\n }\n\n return { success: true };\n}\n\nexport async function listShopifyWebhooks(\n graphqlFn: GraphQLFn,\n first = 50,\n): Promise<ShopifyWebhookSubscription[]> {\n const response = await graphqlFn(WEBHOOK_SUBSCRIPTIONS_QUERY, { first });\n\n if (response.errors && response.errors.length > 0) {\n return [];\n }\n\n const data = response.data as {\n webhookSubscriptions: {\n edges: Array<{\n node: {\n id: string;\n topic: string;\n endpoint: { callbackUrl?: string };\n format: string;\n };\n }>;\n };\n };\n\n return data.webhookSubscriptions.edges.map((edge) => {\n const sub: ShopifyWebhookSubscription = {\n id: edge.node.id,\n topic: edge.node.topic,\n endpoint: {},\n format: edge.node.format,\n };\n const callbackUrl = edge.node.endpoint.callbackUrl;\n if (callbackUrl) {\n sub.endpoint.callbackUrl = callbackUrl;\n }\n return sub;\n });\n}\n"],"mappings":";AAmCA,IAAM,8BAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcpC,IAAM,8BAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYpC,IAAM,8BAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBpC,eAAsB,uBACpB,WACA,cACgC;AAChC,QAAM,WAAW,MAAM,UAAU,6BAA6B;AAAA,IAC5D,OAAO,aAAa;AAAA,IACpB,qBAAqB;AAAA,MACnB,aAAa,aAAa;AAAA,MAC1B,SAAS,aAAa,UAAU,QAAQ,YAAY;AAAA,IACtD;AAAA,EACF,CAAC;AAED,MAAI,SAAS,UAAU,SAAS,OAAO,SAAS,GAAG;AACjD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,QAAQ,SAAS,OAAO,IAAI,CAAC,MAAM,OAAO,CAAC,CAAC;AAAA,IAC9C;AAAA,EACF;AAEA,QAAM,OAAO,SAAS;AAOtB,QAAM,SAAS,KAAK;AACpB,MAAI,OAAO,WAAW,SAAS,GAAG;AAChC,WAAO;AAAA,MACL,SAAS;AAAA,MACT,QAAQ,OAAO,WAAW,IAAI,CAAC,MAAM,EAAE,OAAO;AAAA,IAChD;AAAA,EACF;AAEA,QAAM,iBAAwC,EAAE,SAAS,KAAK;AAC9D,QAAM,iBAAiB,OAAO,qBAAqB;AACnD,MAAI,gBAAgB;AAClB,mBAAe,wBAAwB;AAAA,EACzC;AACA,SAAO;AACT;AAEA,eAAsB,yBACpB,WACA,WACkC;AAClC,QAAM,WAAW,MAAM,UAAU,6BAA6B;AAAA,IAC5D,IAAI;AAAA,EACN,CAAC;AAED,MAAI,SAAS,UAAU,SAAS,OAAO,SAAS,GAAG;AACjD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,QAAQ,SAAS,OAAO,IAAI,CAAC,MAAM,OAAO,CAAC,CAAC;AAAA,IAC9C;AAAA,EACF;AAEA,QAAM,OAAO,SAAS;AAOtB,QAAM,SAAS,KAAK;AACpB,MAAI,OAAO,WAAW,SAAS,GAAG;AAChC,WAAO;AAAA,MACL,SAAS;AAAA,MACT,QAAQ,OAAO,WAAW,IAAI,CAAC,MAAM,EAAE,OAAO;AAAA,IAChD;AAAA,EACF;AAEA,SAAO,EAAE,SAAS,KAAK;AACzB;AAEA,eAAsB,oBACpB,WACA,QAAQ,IAC+B;AACvC,QAAM,WAAW,MAAM,UAAU,6BAA6B,EAAE,MAAM,CAAC;AAEvE,MAAI,SAAS,UAAU,SAAS,OAAO,SAAS,GAAG;AACjD,WAAO,CAAC;AAAA,EACV;AAEA,QAAM,OAAO,SAAS;AAatB,SAAO,KAAK,qBAAqB,MAAM,IAAI,CAAC,SAAS;AACnD,UAAM,MAAkC;AAAA,MACtC,IAAI,KAAK,KAAK;AAAA,MACd,OAAO,KAAK,KAAK;AAAA,MACjB,UAAU,CAAC;AAAA,MACX,QAAQ,KAAK,KAAK;AAAA,IACpB;AACA,UAAM,cAAc,KAAK,KAAK,SAAS;AACvC,QAAI,aAAa;AACf,UAAI,SAAS,cAAc;AAAA,IAC7B;AACA,WAAO;AAAA,EACT,CAAC;AACH;","names":[]}
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "@uniforge/platform-shopify",
3
+ "version": "0.1.0-alpha.2",
4
+ "description": "Shopify platform adapter for UniForge",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ },
14
+ "./auth": {
15
+ "types": "./dist/auth/index.d.ts",
16
+ "import": "./dist/auth/index.mjs",
17
+ "require": "./dist/auth/index.js"
18
+ },
19
+ "./graphql": {
20
+ "types": "./dist/graphql/index.d.ts",
21
+ "import": "./dist/graphql/index.mjs",
22
+ "require": "./dist/graphql/index.js"
23
+ },
24
+ "./webhooks": {
25
+ "types": "./dist/webhooks/index.d.ts",
26
+ "import": "./dist/webhooks/index.mjs",
27
+ "require": "./dist/webhooks/index.js"
28
+ },
29
+ "./multi-store": {
30
+ "types": "./dist/multi-store/index.d.ts",
31
+ "import": "./dist/multi-store/index.mjs",
32
+ "require": "./dist/multi-store/index.js"
33
+ },
34
+ "./rbac": {
35
+ "types": "./dist/rbac/index.d.ts",
36
+ "import": "./dist/rbac/index.mjs",
37
+ "require": "./dist/rbac/index.js"
38
+ },
39
+ "./billing": {
40
+ "types": "./dist/billing/index.d.ts",
41
+ "import": "./dist/billing/index.mjs",
42
+ "require": "./dist/billing/index.js"
43
+ },
44
+ "./platform": {
45
+ "types": "./dist/platform/index.d.ts",
46
+ "import": "./dist/platform/index.mjs",
47
+ "require": "./dist/platform/index.js"
48
+ },
49
+ "./security": {
50
+ "types": "./dist/security/index.d.ts",
51
+ "import": "./dist/security/index.mjs",
52
+ "require": "./dist/security/index.js"
53
+ },
54
+ "./performance": {
55
+ "types": "./dist/performance/index.d.ts",
56
+ "import": "./dist/performance/index.mjs",
57
+ "require": "./dist/performance/index.js"
58
+ }
59
+ },
60
+ "files": [
61
+ "dist"
62
+ ],
63
+ "dependencies": {
64
+ "@shopify/shopify-api": "^12.3.0",
65
+ "@uniforge/core": "^0.1.0-alpha.2",
66
+ "@uniforge/platform-core": "0.1.0-alpha.2"
67
+ },
68
+ "devDependencies": {
69
+ "tsup": "^8.3.0",
70
+ "vitest": "^2.1.0",
71
+ "@uniforge/testing": "^0.1.0-alpha.2"
72
+ },
73
+ "keywords": [
74
+ "uniforge",
75
+ "shopify",
76
+ "e-commerce",
77
+ "platform"
78
+ ],
79
+ "license": "MIT",
80
+ "publishConfig": {
81
+ "access": "public"
82
+ },
83
+ "repository": {
84
+ "type": "git",
85
+ "url": "https://github.com/uniprocessing/uniforge.git",
86
+ "directory": "packages/platform-shopify"
87
+ },
88
+ "scripts": {
89
+ "build": "tsup",
90
+ "dev": "tsup --watch",
91
+ "test": "vitest",
92
+ "lint": "eslint src/",
93
+ "typecheck": "tsc --noEmit"
94
+ }
95
+ }