@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.
- package/dist/auth/index.d.cts +246 -0
- package/dist/auth/index.d.ts +246 -0
- package/dist/auth/index.js +623 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/index.mjs +586 -0
- package/dist/auth/index.mjs.map +1 -0
- package/dist/billing/index.d.cts +58 -0
- package/dist/billing/index.d.ts +58 -0
- package/dist/billing/index.js +226 -0
- package/dist/billing/index.js.map +1 -0
- package/dist/billing/index.mjs +196 -0
- package/dist/billing/index.mjs.map +1 -0
- package/dist/graphql/index.d.cts +17 -0
- package/dist/graphql/index.d.ts +17 -0
- package/dist/graphql/index.js +67 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/graphql/index.mjs +40 -0
- package/dist/graphql/index.mjs.map +1 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +11 -0
- package/dist/index.mjs.map +1 -0
- package/dist/multi-store/index.d.cts +28 -0
- package/dist/multi-store/index.d.ts +28 -0
- package/dist/multi-store/index.js +181 -0
- package/dist/multi-store/index.js.map +1 -0
- package/dist/multi-store/index.mjs +152 -0
- package/dist/multi-store/index.mjs.map +1 -0
- package/dist/performance/index.d.cts +22 -0
- package/dist/performance/index.d.ts +22 -0
- package/dist/performance/index.js +64 -0
- package/dist/performance/index.js.map +1 -0
- package/dist/performance/index.mjs +35 -0
- package/dist/performance/index.mjs.map +1 -0
- package/dist/platform/index.d.cts +16 -0
- package/dist/platform/index.d.ts +16 -0
- package/dist/platform/index.js +150 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/index.mjs +121 -0
- package/dist/platform/index.mjs.map +1 -0
- package/dist/rbac/index.d.cts +38 -0
- package/dist/rbac/index.d.ts +38 -0
- package/dist/rbac/index.js +56 -0
- package/dist/rbac/index.js.map +1 -0
- package/dist/rbac/index.mjs +29 -0
- package/dist/rbac/index.mjs.map +1 -0
- package/dist/security/index.d.cts +26 -0
- package/dist/security/index.d.ts +26 -0
- package/dist/security/index.js +102 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/index.mjs +69 -0
- package/dist/security/index.mjs.map +1 -0
- package/dist/webhooks/index.d.cts +36 -0
- package/dist/webhooks/index.d.ts +36 -0
- package/dist/webhooks/index.js +147 -0
- package/dist/webhooks/index.js.map +1 -0
- package/dist/webhooks/index.mjs +118 -0
- package/dist/webhooks/index.mjs.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// src/multi-store/account-extraction.ts
|
|
2
|
+
async function extractAccountFromSession(session, prisma) {
|
|
3
|
+
const accountStore = await prisma.accountStore.findUnique({
|
|
4
|
+
where: { shopDomain: session.shop },
|
|
5
|
+
include: { account: true }
|
|
6
|
+
});
|
|
7
|
+
if (!accountStore) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const stores = await prisma.accountStore.findMany({
|
|
11
|
+
where: { accountId: accountStore.accountId }
|
|
12
|
+
});
|
|
13
|
+
let member = null;
|
|
14
|
+
if (session.onlineAccessInfo?.associatedUser?.email) {
|
|
15
|
+
const memberRow = await prisma.accountMember.findUnique({
|
|
16
|
+
where: {
|
|
17
|
+
accountId_userEmail: {
|
|
18
|
+
accountId: accountStore.accountId,
|
|
19
|
+
userEmail: session.onlineAccessInfo.associatedUser.email
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
if (memberRow) {
|
|
24
|
+
member = {
|
|
25
|
+
id: memberRow.id,
|
|
26
|
+
accountId: memberRow.accountId,
|
|
27
|
+
userEmail: memberRow.userEmail,
|
|
28
|
+
role: memberRow.role,
|
|
29
|
+
allStoresAccess: memberRow.allStoresAccess,
|
|
30
|
+
allowedStoreIds: Array.isArray(memberRow.allowedStoreIds) ? memberRow.allowedStoreIds : JSON.parse(String(memberRow.allowedStoreIds)),
|
|
31
|
+
permissions: Array.isArray(memberRow.permissions) ? memberRow.permissions : JSON.parse(String(memberRow.permissions)),
|
|
32
|
+
createdAt: memberRow.createdAt,
|
|
33
|
+
updatedAt: memberRow.updatedAt
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
account: {
|
|
39
|
+
id: accountStore.account.id,
|
|
40
|
+
name: accountStore.account.name,
|
|
41
|
+
type: accountStore.account.type,
|
|
42
|
+
isActive: accountStore.account.isActive,
|
|
43
|
+
createdAt: accountStore.account.createdAt,
|
|
44
|
+
updatedAt: accountStore.account.updatedAt
|
|
45
|
+
},
|
|
46
|
+
currentStore: {
|
|
47
|
+
id: accountStore.id,
|
|
48
|
+
accountId: accountStore.accountId,
|
|
49
|
+
shopDomain: accountStore.shopDomain,
|
|
50
|
+
storeName: accountStore.storeName,
|
|
51
|
+
region: accountStore.region,
|
|
52
|
+
currency: accountStore.currency,
|
|
53
|
+
locale: accountStore.locale,
|
|
54
|
+
timezone: accountStore.timezone,
|
|
55
|
+
storeSettings: typeof accountStore.storeSettings === "string" ? JSON.parse(accountStore.storeSettings) : accountStore.storeSettings ?? {},
|
|
56
|
+
isActive: accountStore.isActive,
|
|
57
|
+
isPrimary: accountStore.isPrimary,
|
|
58
|
+
createdAt: accountStore.createdAt,
|
|
59
|
+
updatedAt: accountStore.updatedAt
|
|
60
|
+
},
|
|
61
|
+
member,
|
|
62
|
+
stores: stores.map((s) => ({
|
|
63
|
+
id: s.id,
|
|
64
|
+
accountId: s.accountId,
|
|
65
|
+
shopDomain: s.shopDomain,
|
|
66
|
+
storeName: s.storeName,
|
|
67
|
+
region: s.region,
|
|
68
|
+
currency: s.currency,
|
|
69
|
+
locale: s.locale,
|
|
70
|
+
timezone: s.timezone,
|
|
71
|
+
storeSettings: typeof s.storeSettings === "string" ? JSON.parse(s.storeSettings) : s.storeSettings ?? {},
|
|
72
|
+
isActive: s.isActive,
|
|
73
|
+
isPrimary: s.isPrimary,
|
|
74
|
+
createdAt: s.createdAt,
|
|
75
|
+
updatedAt: s.updatedAt
|
|
76
|
+
}))
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/multi-store/store-switching.ts
|
|
81
|
+
var StoreSwitchError = class extends Error {
|
|
82
|
+
constructor(message, code) {
|
|
83
|
+
super(message);
|
|
84
|
+
this.code = code;
|
|
85
|
+
this.name = "StoreSwitchError";
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
async function validateStoreSwitch(currentShopDomain, targetShopDomain, userEmail, prisma) {
|
|
89
|
+
const currentStore = await prisma.accountStore.findUnique({
|
|
90
|
+
where: { shopDomain: currentShopDomain }
|
|
91
|
+
});
|
|
92
|
+
if (!currentStore) {
|
|
93
|
+
throw new StoreSwitchError(
|
|
94
|
+
"Current store is not linked to any account",
|
|
95
|
+
"NOT_IN_ACCOUNT"
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
const targetStore = await prisma.accountStore.findUnique({
|
|
99
|
+
where: { shopDomain: targetShopDomain }
|
|
100
|
+
});
|
|
101
|
+
if (!targetStore) {
|
|
102
|
+
throw new StoreSwitchError(
|
|
103
|
+
`Target store "${targetShopDomain}" not found`,
|
|
104
|
+
"STORE_NOT_FOUND"
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
if (currentStore.accountId !== targetStore.accountId) {
|
|
108
|
+
throw new StoreSwitchError(
|
|
109
|
+
"Cannot switch to a store in a different account",
|
|
110
|
+
"NOT_IN_ACCOUNT"
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
if (!targetStore.isActive) {
|
|
114
|
+
throw new StoreSwitchError(
|
|
115
|
+
`Target store "${targetShopDomain}" is inactive`,
|
|
116
|
+
"STORE_INACTIVE"
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
const member = await prisma.accountMember.findUnique({
|
|
120
|
+
where: {
|
|
121
|
+
accountId_userEmail: {
|
|
122
|
+
accountId: currentStore.accountId,
|
|
123
|
+
userEmail
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
if (!member) {
|
|
128
|
+
throw new StoreSwitchError(
|
|
129
|
+
"User is not a member of this account",
|
|
130
|
+
"ACCESS_DENIED"
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
if (member.role === "owner" || member.role === "admin") {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (member.allStoresAccess) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const allowedIds = Array.isArray(member.allowedStoreIds) ? member.allowedStoreIds : JSON.parse(String(member.allowedStoreIds));
|
|
140
|
+
if (!allowedIds.includes(targetStore.id)) {
|
|
141
|
+
throw new StoreSwitchError(
|
|
142
|
+
"User does not have access to the target store",
|
|
143
|
+
"ACCESS_DENIED"
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
StoreSwitchError,
|
|
149
|
+
extractAccountFromSession,
|
|
150
|
+
validateStoreSwitch
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/multi-store/account-extraction.ts","../../src/multi-store/store-switching.ts"],"sourcesContent":["/**\n * Extract account context from an authenticated Shopify session.\n */\n\nimport type { Session } from '@uniforge/platform-core/auth';\nimport type { AccountContext, AccountRole } from '@uniforge/platform-core/multi-store';\n\n/**\n * Extract AccountContext from a Shopify session and Prisma database.\n * Returns null if the session's shop is not linked to any account.\n */\nexport async function extractAccountFromSession(\n session: Session,\n prisma: any,\n): Promise<AccountContext | null> {\n const accountStore = await prisma.accountStore.findUnique({\n where: { shopDomain: session.shop },\n include: { account: true },\n });\n\n if (!accountStore) {\n return null;\n }\n\n const stores = await prisma.accountStore.findMany({\n where: { accountId: accountStore.accountId },\n });\n\n // Try to find the member based on online access info\n let member = null;\n if (session.onlineAccessInfo?.associatedUser?.email) {\n const memberRow = await prisma.accountMember.findUnique({\n where: {\n accountId_userEmail: {\n accountId: accountStore.accountId,\n userEmail: session.onlineAccessInfo.associatedUser.email,\n },\n },\n });\n if (memberRow) {\n member = {\n id: memberRow.id,\n accountId: memberRow.accountId,\n userEmail: memberRow.userEmail,\n role: memberRow.role as AccountRole,\n allStoresAccess: memberRow.allStoresAccess,\n allowedStoreIds: Array.isArray(memberRow.allowedStoreIds) ? memberRow.allowedStoreIds as string[] : JSON.parse(String(memberRow.allowedStoreIds)) as string[],\n permissions: Array.isArray(memberRow.permissions) ? memberRow.permissions as string[] : JSON.parse(String(memberRow.permissions)) as string[],\n createdAt: memberRow.createdAt,\n updatedAt: memberRow.updatedAt,\n };\n }\n }\n\n return {\n account: {\n id: accountStore.account.id,\n name: accountStore.account.name,\n type: accountStore.account.type as 'individual' | 'enterprise',\n isActive: accountStore.account.isActive,\n createdAt: accountStore.account.createdAt,\n updatedAt: accountStore.account.updatedAt,\n },\n currentStore: {\n id: accountStore.id,\n accountId: accountStore.accountId,\n shopDomain: accountStore.shopDomain,\n storeName: accountStore.storeName,\n region: accountStore.region,\n currency: accountStore.currency,\n locale: accountStore.locale,\n timezone: accountStore.timezone,\n storeSettings: typeof accountStore.storeSettings === 'string'\n ? JSON.parse(accountStore.storeSettings) as Record<string, unknown>\n : (accountStore.storeSettings as Record<string, unknown>) ?? {},\n isActive: accountStore.isActive,\n isPrimary: accountStore.isPrimary,\n createdAt: accountStore.createdAt,\n updatedAt: accountStore.updatedAt,\n },\n member,\n stores: stores.map((s: any) => ({\n id: s.id,\n accountId: s.accountId,\n shopDomain: s.shopDomain,\n storeName: s.storeName,\n region: s.region,\n currency: s.currency,\n locale: s.locale,\n timezone: s.timezone,\n storeSettings: typeof s.storeSettings === 'string'\n ? JSON.parse(s.storeSettings) as Record<string, unknown>\n : (s.storeSettings as Record<string, unknown>) ?? {},\n isActive: s.isActive,\n isPrimary: s.isPrimary,\n createdAt: s.createdAt,\n updatedAt: s.updatedAt,\n })),\n };\n}\n","/**\n * Store switching validation for multi-store enterprise accounts.\n */\n\n/** Error thrown when a store switch is invalid. */\nexport class StoreSwitchError extends Error {\n constructor(\n message: string,\n public readonly code: 'NOT_IN_ACCOUNT' | 'ACCESS_DENIED' | 'STORE_INACTIVE' | 'STORE_NOT_FOUND',\n ) {\n super(message);\n this.name = 'StoreSwitchError';\n }\n}\n\n/**\n * Validate that a user can switch to a target store within their account.\n * Throws StoreSwitchError if the switch is not allowed.\n */\nexport async function validateStoreSwitch(\n currentShopDomain: string,\n targetShopDomain: string,\n userEmail: string,\n prisma: any,\n): Promise<void> {\n // Find the current store's account\n const currentStore = await prisma.accountStore.findUnique({\n where: { shopDomain: currentShopDomain },\n });\n\n if (!currentStore) {\n throw new StoreSwitchError(\n 'Current store is not linked to any account',\n 'NOT_IN_ACCOUNT',\n );\n }\n\n // Find the target store\n const targetStore = await prisma.accountStore.findUnique({\n where: { shopDomain: targetShopDomain },\n });\n\n if (!targetStore) {\n throw new StoreSwitchError(\n `Target store \"${targetShopDomain}\" not found`,\n 'STORE_NOT_FOUND',\n );\n }\n\n // Verify same account\n if (currentStore.accountId !== targetStore.accountId) {\n throw new StoreSwitchError(\n 'Cannot switch to a store in a different account',\n 'NOT_IN_ACCOUNT',\n );\n }\n\n // Check if target store is active\n if (!targetStore.isActive) {\n throw new StoreSwitchError(\n `Target store \"${targetShopDomain}\" is inactive`,\n 'STORE_INACTIVE',\n );\n }\n\n // Check member access\n const member = await prisma.accountMember.findUnique({\n where: {\n accountId_userEmail: {\n accountId: currentStore.accountId,\n userEmail,\n },\n },\n });\n\n if (!member) {\n throw new StoreSwitchError(\n 'User is not a member of this account',\n 'ACCESS_DENIED',\n );\n }\n\n // Owner and admin can access all stores\n if (member.role === 'owner' || member.role === 'admin') {\n return;\n }\n\n // allStoresAccess bypasses store-level checks\n if (member.allStoresAccess) {\n return;\n }\n\n // Check allowed store IDs\n const allowedIds: string[] = Array.isArray(member.allowedStoreIds)\n ? member.allowedStoreIds as string[]\n : JSON.parse(String(member.allowedStoreIds)) as string[];\n\n if (!allowedIds.includes(targetStore.id)) {\n throw new StoreSwitchError(\n 'User does not have access to the target store',\n 'ACCESS_DENIED',\n );\n }\n}\n"],"mappings":";AAWA,eAAsB,0BACpB,SACA,QACgC;AAChC,QAAM,eAAe,MAAM,OAAO,aAAa,WAAW;AAAA,IACxD,OAAO,EAAE,YAAY,QAAQ,KAAK;AAAA,IAClC,SAAS,EAAE,SAAS,KAAK;AAAA,EAC3B,CAAC;AAED,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,MAAM,OAAO,aAAa,SAAS;AAAA,IAChD,OAAO,EAAE,WAAW,aAAa,UAAU;AAAA,EAC7C,CAAC;AAGD,MAAI,SAAS;AACb,MAAI,QAAQ,kBAAkB,gBAAgB,OAAO;AACnD,UAAM,YAAY,MAAM,OAAO,cAAc,WAAW;AAAA,MACtD,OAAO;AAAA,QACL,qBAAqB;AAAA,UACnB,WAAW,aAAa;AAAA,UACxB,WAAW,QAAQ,iBAAiB,eAAe;AAAA,QACrD;AAAA,MACF;AAAA,IACF,CAAC;AACD,QAAI,WAAW;AACb,eAAS;AAAA,QACP,IAAI,UAAU;AAAA,QACd,WAAW,UAAU;AAAA,QACrB,WAAW,UAAU;AAAA,QACrB,MAAM,UAAU;AAAA,QAChB,iBAAiB,UAAU;AAAA,QAC3B,iBAAiB,MAAM,QAAQ,UAAU,eAAe,IAAI,UAAU,kBAA8B,KAAK,MAAM,OAAO,UAAU,eAAe,CAAC;AAAA,QAChJ,aAAa,MAAM,QAAQ,UAAU,WAAW,IAAI,UAAU,cAA0B,KAAK,MAAM,OAAO,UAAU,WAAW,CAAC;AAAA,QAChI,WAAW,UAAU;AAAA,QACrB,WAAW,UAAU;AAAA,MACvB;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,SAAS;AAAA,MACP,IAAI,aAAa,QAA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@uniforge/platform-core/performance';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shopify-specific cache configurations.
|
|
5
|
+
*
|
|
6
|
+
* Provides TTL strategies tuned for Shopify resource types and a
|
|
7
|
+
* pre-configured CacheManagerConfig for Shopify apps.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare const SHOPIFY_CACHE_STRATEGIES: CacheTTLStrategy[];
|
|
11
|
+
declare const SHOPIFY_CACHE_CONFIG: CacheManagerConfig;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Shopify-specific query cost configuration.
|
|
15
|
+
*
|
|
16
|
+
* Shopify's GraphQL Admin API uses a cost-based rate limiting system
|
|
17
|
+
* with a maximum of 1000 points per second.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
declare const SHOPIFY_QUERY_COST_CONFIG: QueryCostConfig;
|
|
21
|
+
|
|
22
|
+
export { SHOPIFY_CACHE_CONFIG, SHOPIFY_CACHE_STRATEGIES, SHOPIFY_QUERY_COST_CONFIG };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CacheTTLStrategy, CacheManagerConfig, QueryCostConfig } from '@uniforge/platform-core/performance';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shopify-specific cache configurations.
|
|
5
|
+
*
|
|
6
|
+
* Provides TTL strategies tuned for Shopify resource types and a
|
|
7
|
+
* pre-configured CacheManagerConfig for Shopify apps.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare const SHOPIFY_CACHE_STRATEGIES: CacheTTLStrategy[];
|
|
11
|
+
declare const SHOPIFY_CACHE_CONFIG: CacheManagerConfig;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Shopify-specific query cost configuration.
|
|
15
|
+
*
|
|
16
|
+
* Shopify's GraphQL Admin API uses a cost-based rate limiting system
|
|
17
|
+
* with a maximum of 1000 points per second.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
declare const SHOPIFY_QUERY_COST_CONFIG: QueryCostConfig;
|
|
21
|
+
|
|
22
|
+
export { SHOPIFY_CACHE_CONFIG, SHOPIFY_CACHE_STRATEGIES, SHOPIFY_QUERY_COST_CONFIG };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/performance/index.ts
|
|
21
|
+
var performance_exports = {};
|
|
22
|
+
__export(performance_exports, {
|
|
23
|
+
SHOPIFY_CACHE_CONFIG: () => SHOPIFY_CACHE_CONFIG,
|
|
24
|
+
SHOPIFY_CACHE_STRATEGIES: () => SHOPIFY_CACHE_STRATEGIES,
|
|
25
|
+
SHOPIFY_QUERY_COST_CONFIG: () => SHOPIFY_QUERY_COST_CONFIG
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(performance_exports);
|
|
28
|
+
|
|
29
|
+
// src/performance/shopify-cache-config.ts
|
|
30
|
+
var SHOPIFY_CACHE_STRATEGIES = [
|
|
31
|
+
{ pattern: "shopify:products:", ttl: 3e5 },
|
|
32
|
+
// 5 min for products
|
|
33
|
+
{ pattern: "shopify:orders:", ttl: 6e4 },
|
|
34
|
+
// 1 min for orders
|
|
35
|
+
{ pattern: "shopify:customers:", ttl: 12e4 },
|
|
36
|
+
// 2 min for customers
|
|
37
|
+
{ pattern: "shopify:shop:", ttl: 6e5 },
|
|
38
|
+
// 10 min for shop info
|
|
39
|
+
{ pattern: "shopify:graphql:", ttl: 3e4 }
|
|
40
|
+
// 30 sec for GraphQL
|
|
41
|
+
];
|
|
42
|
+
var SHOPIFY_CACHE_CONFIG = {
|
|
43
|
+
defaultTTL: 6e4,
|
|
44
|
+
// 1 minute default
|
|
45
|
+
maxEntries: 1e4,
|
|
46
|
+
keyPrefix: "shopify:",
|
|
47
|
+
strategies: SHOPIFY_CACHE_STRATEGIES
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/performance/shopify-query-cost.ts
|
|
51
|
+
var SHOPIFY_QUERY_COST_CONFIG = {
|
|
52
|
+
maxCostPerSecond: 1e3,
|
|
53
|
+
trackingWindowMs: 6e4,
|
|
54
|
+
// 1 minute window
|
|
55
|
+
alertThreshold: 800
|
|
56
|
+
// alert at 80% usage
|
|
57
|
+
};
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
SHOPIFY_CACHE_CONFIG,
|
|
61
|
+
SHOPIFY_CACHE_STRATEGIES,
|
|
62
|
+
SHOPIFY_QUERY_COST_CONFIG
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/performance/index.ts","../../src/performance/shopify-cache-config.ts","../../src/performance/shopify-query-cost.ts"],"sourcesContent":["/**\n * @uniforge/platform-shopify/performance\n *\n * Shopify-specific performance configurations — cache strategies,\n * cache manager config, and query cost settings.\n */\n\nexport {\n SHOPIFY_CACHE_STRATEGIES,\n SHOPIFY_CACHE_CONFIG,\n} from './shopify-cache-config.js';\n\nexport { SHOPIFY_QUERY_COST_CONFIG } from './shopify-query-cost.js';\n","/**\n * Shopify-specific cache configurations.\n *\n * Provides TTL strategies tuned for Shopify resource types and a\n * pre-configured CacheManagerConfig for Shopify apps.\n */\n\nimport type {\n CacheManagerConfig,\n CacheTTLStrategy,\n} from '@uniforge/platform-core/performance';\n\nexport const SHOPIFY_CACHE_STRATEGIES: CacheTTLStrategy[] = [\n { pattern: 'shopify:products:', ttl: 300000 }, // 5 min for products\n { pattern: 'shopify:orders:', ttl: 60000 }, // 1 min for orders\n { pattern: 'shopify:customers:', ttl: 120000 }, // 2 min for customers\n { pattern: 'shopify:shop:', ttl: 600000 }, // 10 min for shop info\n { pattern: 'shopify:graphql:', ttl: 30000 }, // 30 sec for GraphQL\n];\n\nexport const SHOPIFY_CACHE_CONFIG: CacheManagerConfig = {\n defaultTTL: 60000, // 1 minute default\n maxEntries: 10000,\n keyPrefix: 'shopify:',\n strategies: SHOPIFY_CACHE_STRATEGIES,\n};\n","/**\n * Shopify-specific query cost configuration.\n *\n * Shopify's GraphQL Admin API uses a cost-based rate limiting system\n * with a maximum of 1000 points per second.\n */\n\nimport type { QueryCostConfig } from '@uniforge/platform-core/performance';\n\nexport const SHOPIFY_QUERY_COST_CONFIG: QueryCostConfig = {\n maxCostPerSecond: 1000,\n trackingWindowMs: 60000, // 1 minute window\n alertThreshold: 800, // alert at 80% usage\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYO,IAAM,2BAA+C;AAAA,EAC1D,EAAE,SAAS,qBAAqB,KAAK,IAAO;AAAA;AAAA,EAC5C,EAAE,SAAS,mBAAmB,KAAK,IAAM;AAAA;AAAA,EACzC,EAAE,SAAS,sBAAsB,KAAK,KAAO;AAAA;AAAA,EAC7C,EAAE,SAAS,iBAAiB,KAAK,IAAO;AAAA;AAAA,EACxC,EAAE,SAAS,oBAAoB,KAAK,IAAM;AAAA;AAC5C;AAEO,IAAM,uBAA2C;AAAA,EACtD,YAAY;AAAA;AAAA,EACZ,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AACd;;;AChBO,IAAM,4BAA6C;AAAA,EACxD,kBAAkB;AAAA,EAClB,kBAAkB;AAAA;AAAA,EAClB,gBAAgB;AAAA;AAClB;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/performance/shopify-cache-config.ts
|
|
2
|
+
var SHOPIFY_CACHE_STRATEGIES = [
|
|
3
|
+
{ pattern: "shopify:products:", ttl: 3e5 },
|
|
4
|
+
// 5 min for products
|
|
5
|
+
{ pattern: "shopify:orders:", ttl: 6e4 },
|
|
6
|
+
// 1 min for orders
|
|
7
|
+
{ pattern: "shopify:customers:", ttl: 12e4 },
|
|
8
|
+
// 2 min for customers
|
|
9
|
+
{ pattern: "shopify:shop:", ttl: 6e5 },
|
|
10
|
+
// 10 min for shop info
|
|
11
|
+
{ pattern: "shopify:graphql:", ttl: 3e4 }
|
|
12
|
+
// 30 sec for GraphQL
|
|
13
|
+
];
|
|
14
|
+
var SHOPIFY_CACHE_CONFIG = {
|
|
15
|
+
defaultTTL: 6e4,
|
|
16
|
+
// 1 minute default
|
|
17
|
+
maxEntries: 1e4,
|
|
18
|
+
keyPrefix: "shopify:",
|
|
19
|
+
strategies: SHOPIFY_CACHE_STRATEGIES
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// src/performance/shopify-query-cost.ts
|
|
23
|
+
var SHOPIFY_QUERY_COST_CONFIG = {
|
|
24
|
+
maxCostPerSecond: 1e3,
|
|
25
|
+
trackingWindowMs: 6e4,
|
|
26
|
+
// 1 minute window
|
|
27
|
+
alertThreshold: 800
|
|
28
|
+
// alert at 80% usage
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
SHOPIFY_CACHE_CONFIG,
|
|
32
|
+
SHOPIFY_CACHE_STRATEGIES,
|
|
33
|
+
SHOPIFY_QUERY_COST_CONFIG
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/performance/shopify-cache-config.ts","../../src/performance/shopify-query-cost.ts"],"sourcesContent":["/**\n * Shopify-specific cache configurations.\n *\n * Provides TTL strategies tuned for Shopify resource types and a\n * pre-configured CacheManagerConfig for Shopify apps.\n */\n\nimport type {\n CacheManagerConfig,\n CacheTTLStrategy,\n} from '@uniforge/platform-core/performance';\n\nexport const SHOPIFY_CACHE_STRATEGIES: CacheTTLStrategy[] = [\n { pattern: 'shopify:products:', ttl: 300000 }, // 5 min for products\n { pattern: 'shopify:orders:', ttl: 60000 }, // 1 min for orders\n { pattern: 'shopify:customers:', ttl: 120000 }, // 2 min for customers\n { pattern: 'shopify:shop:', ttl: 600000 }, // 10 min for shop info\n { pattern: 'shopify:graphql:', ttl: 30000 }, // 30 sec for GraphQL\n];\n\nexport const SHOPIFY_CACHE_CONFIG: CacheManagerConfig = {\n defaultTTL: 60000, // 1 minute default\n maxEntries: 10000,\n keyPrefix: 'shopify:',\n strategies: SHOPIFY_CACHE_STRATEGIES,\n};\n","/**\n * Shopify-specific query cost configuration.\n *\n * Shopify's GraphQL Admin API uses a cost-based rate limiting system\n * with a maximum of 1000 points per second.\n */\n\nimport type { QueryCostConfig } from '@uniforge/platform-core/performance';\n\nexport const SHOPIFY_QUERY_COST_CONFIG: QueryCostConfig = {\n maxCostPerSecond: 1000,\n trackingWindowMs: 60000, // 1 minute window\n alertThreshold: 800, // alert at 80% usage\n};\n"],"mappings":";AAYO,IAAM,2BAA+C;AAAA,EAC1D,EAAE,SAAS,qBAAqB,KAAK,IAAO;AAAA;AAAA,EAC5C,EAAE,SAAS,mBAAmB,KAAK,IAAM;AAAA;AAAA,EACzC,EAAE,SAAS,sBAAsB,KAAK,KAAO;AAAA;AAAA,EAC7C,EAAE,SAAS,iBAAiB,KAAK,IAAO;AAAA;AAAA,EACxC,EAAE,SAAS,oBAAoB,KAAK,IAAM;AAAA;AAC5C;AAEO,IAAM,uBAA2C;AAAA,EACtD,YAAY;AAAA;AAAA,EACZ,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AACd;;;AChBO,IAAM,4BAA6C;AAAA,EACxD,kBAAkB;AAAA,EAClB,kBAAkB;AAAA;AAAA,EAClB,gBAAgB;AAAA;AAClB;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PlatformCapabilities, PlatformProvider, PlatformConfig } from '@uniforge/platform-core/platform';
|
|
2
|
+
|
|
3
|
+
declare const SHOPIFY_CAPABILITIES: PlatformCapabilities;
|
|
4
|
+
|
|
5
|
+
declare const SHOPIFY_PLATFORM_ID = "shopify";
|
|
6
|
+
interface ShopifyPlatformConfig extends PlatformConfig {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
apiSecretKey: string;
|
|
9
|
+
scopes: string[];
|
|
10
|
+
hostName: string;
|
|
11
|
+
apiVersion: string;
|
|
12
|
+
isEmbeddedApp: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare function createShopifyPlatformProvider(): PlatformProvider;
|
|
15
|
+
|
|
16
|
+
export { SHOPIFY_CAPABILITIES, SHOPIFY_PLATFORM_ID, type ShopifyPlatformConfig, createShopifyPlatformProvider };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PlatformCapabilities, PlatformProvider, PlatformConfig } from '@uniforge/platform-core/platform';
|
|
2
|
+
|
|
3
|
+
declare const SHOPIFY_CAPABILITIES: PlatformCapabilities;
|
|
4
|
+
|
|
5
|
+
declare const SHOPIFY_PLATFORM_ID = "shopify";
|
|
6
|
+
interface ShopifyPlatformConfig extends PlatformConfig {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
apiSecretKey: string;
|
|
9
|
+
scopes: string[];
|
|
10
|
+
hostName: string;
|
|
11
|
+
apiVersion: string;
|
|
12
|
+
isEmbeddedApp: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare function createShopifyPlatformProvider(): PlatformProvider;
|
|
15
|
+
|
|
16
|
+
export { SHOPIFY_CAPABILITIES, SHOPIFY_PLATFORM_ID, type ShopifyPlatformConfig, createShopifyPlatformProvider };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/platform/index.ts
|
|
21
|
+
var platform_exports = {};
|
|
22
|
+
__export(platform_exports, {
|
|
23
|
+
SHOPIFY_CAPABILITIES: () => SHOPIFY_CAPABILITIES,
|
|
24
|
+
SHOPIFY_PLATFORM_ID: () => SHOPIFY_PLATFORM_ID,
|
|
25
|
+
createShopifyPlatformProvider: () => createShopifyPlatformProvider
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(platform_exports);
|
|
28
|
+
|
|
29
|
+
// src/platform/capabilities.ts
|
|
30
|
+
var SHOPIFY_CAPABILITIES = {
|
|
31
|
+
auth: {
|
|
32
|
+
tokenExchange: true,
|
|
33
|
+
oauth: true,
|
|
34
|
+
apiKeys: true,
|
|
35
|
+
sessionManagement: true
|
|
36
|
+
},
|
|
37
|
+
billing: {
|
|
38
|
+
subscriptions: true,
|
|
39
|
+
oneTimeCharges: true,
|
|
40
|
+
usageBased: true,
|
|
41
|
+
trialSupport: true
|
|
42
|
+
},
|
|
43
|
+
webhooks: {
|
|
44
|
+
supported: true,
|
|
45
|
+
verificationMethod: "hmac",
|
|
46
|
+
supportsRegistration: true
|
|
47
|
+
},
|
|
48
|
+
graphql: {
|
|
49
|
+
supported: true,
|
|
50
|
+
rateLimiting: true,
|
|
51
|
+
caching: true
|
|
52
|
+
},
|
|
53
|
+
rbac: true,
|
|
54
|
+
multiStore: true,
|
|
55
|
+
commerce: {
|
|
56
|
+
products: true,
|
|
57
|
+
orders: true,
|
|
58
|
+
customers: true,
|
|
59
|
+
inventory: true
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/platform/provider.ts
|
|
64
|
+
var SHOPIFY_PLATFORM_ID = "shopify";
|
|
65
|
+
function createShopifyPlatformProvider() {
|
|
66
|
+
return {
|
|
67
|
+
id: SHOPIFY_PLATFORM_ID,
|
|
68
|
+
name: "Shopify",
|
|
69
|
+
version: "1.0.0",
|
|
70
|
+
description: "Shopify e-commerce platform adapter with full API integration",
|
|
71
|
+
getCapabilities() {
|
|
72
|
+
return SHOPIFY_CAPABILITIES;
|
|
73
|
+
},
|
|
74
|
+
validateConfig(config) {
|
|
75
|
+
const errors = [];
|
|
76
|
+
const shopifyConfig = config;
|
|
77
|
+
if (shopifyConfig.apiKey === void 0 || shopifyConfig.apiKey === "") {
|
|
78
|
+
errors.push({
|
|
79
|
+
field: "apiKey",
|
|
80
|
+
message: "Shopify API key is required",
|
|
81
|
+
code: "REQUIRED"
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (shopifyConfig.apiSecretKey === void 0 || shopifyConfig.apiSecretKey === "") {
|
|
85
|
+
errors.push({
|
|
86
|
+
field: "apiSecretKey",
|
|
87
|
+
message: "Shopify API secret key is required",
|
|
88
|
+
code: "REQUIRED"
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (shopifyConfig.hostName === void 0 || shopifyConfig.hostName === "") {
|
|
92
|
+
errors.push({
|
|
93
|
+
field: "hostName",
|
|
94
|
+
message: "Host name is required",
|
|
95
|
+
code: "REQUIRED"
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (shopifyConfig.scopes === void 0 || shopifyConfig.scopes.length === 0) {
|
|
99
|
+
errors.push({
|
|
100
|
+
field: "scopes",
|
|
101
|
+
message: "At least one scope is required",
|
|
102
|
+
code: "REQUIRED"
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (shopifyConfig.apiVersion === void 0 || shopifyConfig.apiVersion === "") {
|
|
106
|
+
errors.push({
|
|
107
|
+
field: "apiVersion",
|
|
108
|
+
message: "Shopify API version is required",
|
|
109
|
+
code: "REQUIRED"
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (shopifyConfig.isEmbeddedApp === void 0) {
|
|
113
|
+
errors.push({
|
|
114
|
+
field: "isEmbeddedApp",
|
|
115
|
+
message: "isEmbeddedApp flag is required",
|
|
116
|
+
code: "REQUIRED"
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return { valid: errors.length === 0, errors };
|
|
120
|
+
},
|
|
121
|
+
supportsAuth() {
|
|
122
|
+
return true;
|
|
123
|
+
},
|
|
124
|
+
supportsBilling() {
|
|
125
|
+
return true;
|
|
126
|
+
},
|
|
127
|
+
supportsWebhooks() {
|
|
128
|
+
return true;
|
|
129
|
+
},
|
|
130
|
+
supportsGraphQL() {
|
|
131
|
+
return true;
|
|
132
|
+
},
|
|
133
|
+
supportsRBAC() {
|
|
134
|
+
return true;
|
|
135
|
+
},
|
|
136
|
+
supportsMultiStore() {
|
|
137
|
+
return true;
|
|
138
|
+
},
|
|
139
|
+
supportsCommerce() {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
145
|
+
0 && (module.exports = {
|
|
146
|
+
SHOPIFY_CAPABILITIES,
|
|
147
|
+
SHOPIFY_PLATFORM_ID,
|
|
148
|
+
createShopifyPlatformProvider
|
|
149
|
+
});
|
|
150
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/platform/index.ts","../../src/platform/capabilities.ts","../../src/platform/provider.ts"],"sourcesContent":["export { SHOPIFY_CAPABILITIES } from './capabilities.js';\nexport { createShopifyPlatformProvider, SHOPIFY_PLATFORM_ID } from './provider.js';\nexport type { ShopifyPlatformConfig } from './provider.js';\n","import type { PlatformCapabilities } from '@uniforge/platform-core/platform';\n\nexport const SHOPIFY_CAPABILITIES: PlatformCapabilities = {\n auth: {\n tokenExchange: true,\n oauth: true,\n apiKeys: true,\n sessionManagement: true,\n },\n billing: {\n subscriptions: true,\n oneTimeCharges: true,\n usageBased: true,\n trialSupport: true,\n },\n webhooks: {\n supported: true,\n verificationMethod: 'hmac',\n supportsRegistration: true,\n },\n graphql: {\n supported: true,\n rateLimiting: true,\n caching: true,\n },\n rbac: true,\n multiStore: true,\n commerce: {\n products: true,\n orders: true,\n customers: true,\n inventory: true,\n },\n};\n","import type {\n PlatformProvider,\n PlatformConfig,\n PlatformValidationResult,\n PlatformValidationError,\n} from '@uniforge/platform-core/platform';\nimport { SHOPIFY_CAPABILITIES } from './capabilities.js';\n\nexport const SHOPIFY_PLATFORM_ID = 'shopify';\n\nexport interface ShopifyPlatformConfig extends PlatformConfig {\n apiKey: string;\n apiSecretKey: string;\n scopes: string[];\n hostName: string;\n apiVersion: string;\n isEmbeddedApp: boolean;\n}\n\nexport function createShopifyPlatformProvider(): PlatformProvider {\n return {\n id: SHOPIFY_PLATFORM_ID,\n name: 'Shopify',\n version: '1.0.0',\n description: 'Shopify e-commerce platform adapter with full API integration',\n\n getCapabilities() {\n return SHOPIFY_CAPABILITIES;\n },\n\n validateConfig(config: PlatformConfig): PlatformValidationResult {\n const errors: PlatformValidationError[] = [];\n const shopifyConfig = config as ShopifyPlatformConfig;\n\n if (shopifyConfig.apiKey === undefined || shopifyConfig.apiKey === '') {\n errors.push({\n field: 'apiKey',\n message: 'Shopify API key is required',\n code: 'REQUIRED',\n });\n }\n if (shopifyConfig.apiSecretKey === undefined || shopifyConfig.apiSecretKey === '') {\n errors.push({\n field: 'apiSecretKey',\n message: 'Shopify API secret key is required',\n code: 'REQUIRED',\n });\n }\n if (shopifyConfig.hostName === undefined || shopifyConfig.hostName === '') {\n errors.push({\n field: 'hostName',\n message: 'Host name is required',\n code: 'REQUIRED',\n });\n }\n if (shopifyConfig.scopes === undefined || shopifyConfig.scopes.length === 0) {\n errors.push({\n field: 'scopes',\n message: 'At least one scope is required',\n code: 'REQUIRED',\n });\n }\n if (shopifyConfig.apiVersion === undefined || shopifyConfig.apiVersion === '') {\n errors.push({\n field: 'apiVersion',\n message: 'Shopify API version is required',\n code: 'REQUIRED',\n });\n }\n if (shopifyConfig.isEmbeddedApp === undefined) {\n errors.push({\n field: 'isEmbeddedApp',\n message: 'isEmbeddedApp flag is required',\n code: 'REQUIRED',\n });\n }\n\n return { valid: errors.length === 0, errors };\n },\n\n supportsAuth() {\n return true;\n },\n supportsBilling() {\n return true;\n },\n supportsWebhooks() {\n return true;\n },\n supportsGraphQL() {\n return true;\n },\n supportsRBAC() {\n return true;\n },\n supportsMultiStore() {\n return true;\n },\n supportsCommerce() {\n return true;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,uBAA6C;AAAA,EACxD,MAAM;AAAA,IACJ,eAAe;AAAA,IACf,OAAO;AAAA,IACP,SAAS;AAAA,IACT,mBAAmB;AAAA,EACrB;AAAA,EACA,SAAS;AAAA,IACP,eAAe;AAAA,I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AAI;AAC7E,eAAO,KAAK;AAAA,UACV,OAAO;AAAA,UACP,SAAS;AAAA,UACT,MAAM;AAAA,QACR,CAAC;AAAA,MACH;AACA,UAAI,cAAc,kBAAkB,QAAW;AAC7C,eAAO,KAAK;AAAA,UACV,OAAO;AAAA,UACP,SAAS;AAAA,UACT,MAAM;AAAA,QACR,CAAC;AAAA,MACH;AAEA,aAAO,EAAE,OAAO,OAAO,WAAW,GAAG,OAAO;AAAA,IAC9C;AAAA,IAEA,eAAe;AACb,aAAO;AAAA,IACT;AAAA,IACA,kBAAkB;AAChB,aAAO;AAAA,IACT;AAAA,IACA,mBAAmB;AACjB,aAAO;AAAA,IACT;AAAA,IACA,kBAAkB;AAChB,aAAO;AAAA,IACT;AAAA,IACA,eAAe;AACb,aAAO;AAAA,IACT;AAAA,IACA,qBAAqB;AACnB,aAAO;AAAA,IACT;AAAA,IACA,mBAAmB;AACjB,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// src/platform/capabilities.ts
|
|
2
|
+
var SHOPIFY_CAPABILITIES = {
|
|
3
|
+
auth: {
|
|
4
|
+
tokenExchange: true,
|
|
5
|
+
oauth: true,
|
|
6
|
+
apiKeys: true,
|
|
7
|
+
sessionManagement: true
|
|
8
|
+
},
|
|
9
|
+
billing: {
|
|
10
|
+
subscriptions: true,
|
|
11
|
+
oneTimeCharges: true,
|
|
12
|
+
usageBased: true,
|
|
13
|
+
trialSupport: true
|
|
14
|
+
},
|
|
15
|
+
webhooks: {
|
|
16
|
+
supported: true,
|
|
17
|
+
verificationMethod: "hmac",
|
|
18
|
+
supportsRegistration: true
|
|
19
|
+
},
|
|
20
|
+
graphql: {
|
|
21
|
+
supported: true,
|
|
22
|
+
rateLimiting: true,
|
|
23
|
+
caching: true
|
|
24
|
+
},
|
|
25
|
+
rbac: true,
|
|
26
|
+
multiStore: true,
|
|
27
|
+
commerce: {
|
|
28
|
+
products: true,
|
|
29
|
+
orders: true,
|
|
30
|
+
customers: true,
|
|
31
|
+
inventory: true
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/platform/provider.ts
|
|
36
|
+
var SHOPIFY_PLATFORM_ID = "shopify";
|
|
37
|
+
function createShopifyPlatformProvider() {
|
|
38
|
+
return {
|
|
39
|
+
id: SHOPIFY_PLATFORM_ID,
|
|
40
|
+
name: "Shopify",
|
|
41
|
+
version: "1.0.0",
|
|
42
|
+
description: "Shopify e-commerce platform adapter with full API integration",
|
|
43
|
+
getCapabilities() {
|
|
44
|
+
return SHOPIFY_CAPABILITIES;
|
|
45
|
+
},
|
|
46
|
+
validateConfig(config) {
|
|
47
|
+
const errors = [];
|
|
48
|
+
const shopifyConfig = config;
|
|
49
|
+
if (shopifyConfig.apiKey === void 0 || shopifyConfig.apiKey === "") {
|
|
50
|
+
errors.push({
|
|
51
|
+
field: "apiKey",
|
|
52
|
+
message: "Shopify API key is required",
|
|
53
|
+
code: "REQUIRED"
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (shopifyConfig.apiSecretKey === void 0 || shopifyConfig.apiSecretKey === "") {
|
|
57
|
+
errors.push({
|
|
58
|
+
field: "apiSecretKey",
|
|
59
|
+
message: "Shopify API secret key is required",
|
|
60
|
+
code: "REQUIRED"
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (shopifyConfig.hostName === void 0 || shopifyConfig.hostName === "") {
|
|
64
|
+
errors.push({
|
|
65
|
+
field: "hostName",
|
|
66
|
+
message: "Host name is required",
|
|
67
|
+
code: "REQUIRED"
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (shopifyConfig.scopes === void 0 || shopifyConfig.scopes.length === 0) {
|
|
71
|
+
errors.push({
|
|
72
|
+
field: "scopes",
|
|
73
|
+
message: "At least one scope is required",
|
|
74
|
+
code: "REQUIRED"
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (shopifyConfig.apiVersion === void 0 || shopifyConfig.apiVersion === "") {
|
|
78
|
+
errors.push({
|
|
79
|
+
field: "apiVersion",
|
|
80
|
+
message: "Shopify API version is required",
|
|
81
|
+
code: "REQUIRED"
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (shopifyConfig.isEmbeddedApp === void 0) {
|
|
85
|
+
errors.push({
|
|
86
|
+
field: "isEmbeddedApp",
|
|
87
|
+
message: "isEmbeddedApp flag is required",
|
|
88
|
+
code: "REQUIRED"
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return { valid: errors.length === 0, errors };
|
|
92
|
+
},
|
|
93
|
+
supportsAuth() {
|
|
94
|
+
return true;
|
|
95
|
+
},
|
|
96
|
+
supportsBilling() {
|
|
97
|
+
return true;
|
|
98
|
+
},
|
|
99
|
+
supportsWebhooks() {
|
|
100
|
+
return true;
|
|
101
|
+
},
|
|
102
|
+
supportsGraphQL() {
|
|
103
|
+
return true;
|
|
104
|
+
},
|
|
105
|
+
supportsRBAC() {
|
|
106
|
+
return true;
|
|
107
|
+
},
|
|
108
|
+
supportsMultiStore() {
|
|
109
|
+
return true;
|
|
110
|
+
},
|
|
111
|
+
supportsCommerce() {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
SHOPIFY_CAPABILITIES,
|
|
118
|
+
SHOPIFY_PLATFORM_ID,
|
|
119
|
+
createShopifyPlatformProvider
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/platform/capabilities.ts","../../src/platform/provider.ts"],"sourcesContent":["import type { PlatformCapabilities } from '@uniforge/platform-core/platform';\n\nexport const SHOPIFY_CAPABILITIES: PlatformCapabilities = {\n auth: {\n tokenExchange: true,\n oauth: true,\n apiKeys: true,\n sessionManagement: true,\n },\n billing: {\n subscriptions: true,\n oneTimeCharges: true,\n usageBased: true,\n trialSupport: true,\n },\n webhooks: {\n supported: true,\n verificationMethod: 'hmac',\n supportsRegistration: true,\n },\n graphql: {\n supported: true,\n rateLimiting: true,\n caching: true,\n },\n rbac: true,\n multiStore: true,\n commerce: {\n products: true,\n orders: true,\n customers: true,\n inventory: true,\n },\n};\n","import type {\n PlatformProvider,\n PlatformConfig,\n PlatformValidationResult,\n PlatformValidationError,\n} from '@uniforge/platform-core/platform';\nimport { SHOPIFY_CAPABILITIES } from './capabilities.js';\n\nexport const SHOPIFY_PLATFORM_ID = 'shopify';\n\nexport interface ShopifyPlatformConfig extends PlatformConfig {\n apiKey: string;\n apiSecretKey: string;\n scopes: string[];\n hostName: string;\n apiVersion: string;\n isEmbeddedApp: boolean;\n}\n\nexport function createShopifyPlatformProvider(): PlatformProvider {\n return {\n id: SHOPIFY_PLATFORM_ID,\n name: 'Shopify',\n version: '1.0.0',\n description: 'Shopify e-commerce platform adapter with full API integration',\n\n getCapabilities() {\n return SHOPIFY_CAPABILITIES;\n },\n\n validateConfig(config: PlatformConfig): PlatformValidationResult {\n const errors: PlatformValidationError[] = [];\n const shopifyConfig = config as ShopifyPlatformConfig;\n\n if (shopifyConfig.apiKey === undefined || shopifyConfig.apiKey === '') {\n errors.push({\n field: 'apiKey',\n message: 'Shopify API key is required',\n code: 'REQUIRED',\n });\n }\n if (shopifyConfig.apiSecretKey === undefined || shopifyConfig.apiSecretKey === '') {\n errors.push({\n field: 'apiSecretKey',\n message: 'Shopify API secret key is required',\n code: 'REQUIRED',\n });\n }\n if (shopifyConfig.hostName === undefined || shopifyConfig.hostName === '') {\n errors.push({\n field: 'hostName',\n message: 'Host name is required',\n code: 'REQUIRED',\n });\n }\n if (shopifyConfig.scopes === undefined || shopifyConfig.scopes.length === 0) {\n errors.push({\n field: 'scopes',\n message: 'At least one scope is required',\n code: 'REQUIRED',\n });\n }\n if (shopifyConfig.apiVersion === undefined || shopifyConfig.apiVersion === '') {\n errors.push({\n field: 'apiVersion',\n message: 'Shopify API version is required',\n code: 'REQUIRED',\n });\n }\n if (shopifyConfig.isEmbeddedApp === undefined) {\n errors.push({\n field: 'isEmbeddedApp',\n message: 'isEmbeddedApp flag is required',\n code: 'REQUIRED',\n });\n }\n\n return { valid: errors.length === 0, errors };\n },\n\n supportsAuth() {\n return true;\n },\n supportsBilling() {\n return true;\n },\n supportsWebhooks() {\n return true;\n },\n supportsGraphQL() {\n return true;\n },\n supportsRBAC() {\n return true;\n },\n supportsMultiStore() {\n return true;\n },\n supportsCommerce() {\n return true;\n },\n };\n}\n"],"mappings":";AAEO,IAAM,uBAA6C;AAAA,EACxD,MAAM;AAAA,IACJ,eAAe;AAAA,IACf,OAAO;AAAA,IACP,SAAS;AAAA,IACT,mBAAmB;AAAA,EACrB;AAAA,EACA,SAAS;AAAA,IACP,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB;AAAA,EACA,UAAU;AAAA,IACR,WAAW;AAAA,IACX,oBAAoB;AAAA,IACpB,sBAAsB;AAAA,EACxB;AAAA,EACA,SAAS;AAAA,IACP,WAAW;AAAA,IACX,cAAc;AAAA,IACd,SAAS;AAAA,EACX;AAAA,EACA,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,UAAU;AAAA,IACR,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,WAAW;AAAA,EACb;AACF;;;ACzBO,IAAM,sBAAsB;AAW5B,SAAS,gCAAkD;AAChE,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IAEb,kBAAkB;AAChB,aAAO;AAAA,IACT;AAAA,IAEA,eAAe,QAAkD;AAC/D,YAAM,SAAoC,CAAC;AAC3C,YAAM,gBAAgB;AAEtB,UAAI,cAAc,WAAW,UAAa,cAAc,WAAW,IAAI;AACrE,eAAO,KAAK;AAAA,UACV,OAAO;AAAA,UACP,SAAS;AAAA,UACT,MAAM;AA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