@uniforge/core 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 (87) hide show
  1. package/dist/auth/index.d.cts +165 -0
  2. package/dist/auth/index.d.ts +165 -0
  3. package/dist/auth/index.js +443 -0
  4. package/dist/auth/index.js.map +1 -0
  5. package/dist/auth/index.mjs +406 -0
  6. package/dist/auth/index.mjs.map +1 -0
  7. package/dist/billing/index.d.cts +34 -0
  8. package/dist/billing/index.d.ts +34 -0
  9. package/dist/billing/index.js +254 -0
  10. package/dist/billing/index.js.map +1 -0
  11. package/dist/billing/index.mjs +225 -0
  12. package/dist/billing/index.mjs.map +1 -0
  13. package/dist/config/index.d.cts +12 -0
  14. package/dist/config/index.d.ts +12 -0
  15. package/dist/config/index.js +186 -0
  16. package/dist/config/index.js.map +1 -0
  17. package/dist/config/index.mjs +156 -0
  18. package/dist/config/index.mjs.map +1 -0
  19. package/dist/database/index.d.cts +33 -0
  20. package/dist/database/index.d.ts +33 -0
  21. package/dist/database/index.js +127 -0
  22. package/dist/database/index.js.map +1 -0
  23. package/dist/database/index.mjs +95 -0
  24. package/dist/database/index.mjs.map +1 -0
  25. package/dist/graphql/index.d.cts +36 -0
  26. package/dist/graphql/index.d.ts +36 -0
  27. package/dist/graphql/index.js +209 -0
  28. package/dist/graphql/index.js.map +1 -0
  29. package/dist/graphql/index.mjs +179 -0
  30. package/dist/graphql/index.mjs.map +1 -0
  31. package/dist/index.d.cts +16 -0
  32. package/dist/index.d.ts +16 -0
  33. package/dist/index.js +36 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/index.mjs +10 -0
  36. package/dist/index.mjs.map +1 -0
  37. package/dist/multi-store/index.d.cts +11 -0
  38. package/dist/multi-store/index.d.ts +11 -0
  39. package/dist/multi-store/index.js +473 -0
  40. package/dist/multi-store/index.js.map +1 -0
  41. package/dist/multi-store/index.mjs +447 -0
  42. package/dist/multi-store/index.mjs.map +1 -0
  43. package/dist/multi-tenant/index.d.cts +23 -0
  44. package/dist/multi-tenant/index.d.ts +23 -0
  45. package/dist/multi-tenant/index.js +69 -0
  46. package/dist/multi-tenant/index.js.map +1 -0
  47. package/dist/multi-tenant/index.mjs +41 -0
  48. package/dist/multi-tenant/index.mjs.map +1 -0
  49. package/dist/performance/index.d.cts +34 -0
  50. package/dist/performance/index.d.ts +34 -0
  51. package/dist/performance/index.js +319 -0
  52. package/dist/performance/index.js.map +1 -0
  53. package/dist/performance/index.mjs +290 -0
  54. package/dist/performance/index.mjs.map +1 -0
  55. package/dist/platform/index.d.cts +25 -0
  56. package/dist/platform/index.d.ts +25 -0
  57. package/dist/platform/index.js +91 -0
  58. package/dist/platform/index.js.map +1 -0
  59. package/dist/platform/index.mjs +62 -0
  60. package/dist/platform/index.mjs.map +1 -0
  61. package/dist/rbac/index.d.cts +24 -0
  62. package/dist/rbac/index.d.ts +24 -0
  63. package/dist/rbac/index.js +267 -0
  64. package/dist/rbac/index.js.map +1 -0
  65. package/dist/rbac/index.mjs +236 -0
  66. package/dist/rbac/index.mjs.map +1 -0
  67. package/dist/schema-CM7mHj_H.d.cts +53 -0
  68. package/dist/schema-CM7mHj_H.d.ts +53 -0
  69. package/dist/security/index.d.cts +47 -0
  70. package/dist/security/index.d.ts +47 -0
  71. package/dist/security/index.js +505 -0
  72. package/dist/security/index.js.map +1 -0
  73. package/dist/security/index.mjs +474 -0
  74. package/dist/security/index.mjs.map +1 -0
  75. package/dist/session-storage/index.d.cts +70 -0
  76. package/dist/session-storage/index.d.ts +70 -0
  77. package/dist/session-storage/index.js +271 -0
  78. package/dist/session-storage/index.js.map +1 -0
  79. package/dist/session-storage/index.mjs +242 -0
  80. package/dist/session-storage/index.mjs.map +1 -0
  81. package/dist/webhooks/index.d.cts +89 -0
  82. package/dist/webhooks/index.d.ts +89 -0
  83. package/dist/webhooks/index.js +380 -0
  84. package/dist/webhooks/index.js.map +1 -0
  85. package/dist/webhooks/index.mjs +348 -0
  86. package/dist/webhooks/index.mjs.map +1 -0
  87. package/package.json +119 -0
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
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/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ VERSION: () => VERSION,
24
+ uniforge: () => uniforge
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var VERSION = "0.0.0";
28
+ var uniforge = {
29
+ version: VERSION
30
+ };
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ VERSION,
34
+ uniforge
35
+ });
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @uniforge/core\n *\n * Core framework functionality including authentication, GraphQL client,\n * webhooks, and billing integration.\n */\n\nexport const VERSION = '0.0.0';\n\n/**\n * UniForge core module placeholder.\n * Full implementation will include auth, GraphQL, webhooks, and billing.\n */\nexport const uniforge = {\n version: VERSION,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,IAAM,UAAU;AAMhB,IAAM,WAAW;AAAA,EACtB,SAAS;AACX;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,10 @@
1
+ // src/index.ts
2
+ var VERSION = "0.0.0";
3
+ var uniforge = {
4
+ version: VERSION
5
+ };
6
+ export {
7
+ VERSION,
8
+ uniforge
9
+ };
10
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @uniforge/core\n *\n * Core framework functionality including authentication, GraphQL client,\n * webhooks, and billing integration.\n */\n\nexport const VERSION = '0.0.0';\n\n/**\n * UniForge core module placeholder.\n * Full implementation will include auth, GraphQL, webhooks, and billing.\n */\nexport const uniforge = {\n version: VERSION,\n};\n"],"mappings":";AAOO,IAAM,UAAU;AAMhB,IAAM,WAAW;AAAA,EACtB,SAAS;AACX;","names":[]}
@@ -0,0 +1,11 @@
1
+ import { AccountService, SharedSettingsService, AccountMiddleware, AccountPricingTier, AccountPricingResult } from '@uniforge/platform-core/multi-store';
2
+
3
+ declare function createAccountService(prisma: any): AccountService;
4
+
5
+ declare function createSharedSettingsService(prisma: any): SharedSettingsService;
6
+
7
+ declare function createAccountMiddleware(prisma: any): AccountMiddleware;
8
+
9
+ declare function calculateAccountPricing(storeCount: number, tiers?: AccountPricingTier[], basePrice?: number): AccountPricingResult;
10
+
11
+ export { calculateAccountPricing, createAccountMiddleware, createAccountService, createSharedSettingsService };
@@ -0,0 +1,11 @@
1
+ import { AccountService, SharedSettingsService, AccountMiddleware, AccountPricingTier, AccountPricingResult } from '@uniforge/platform-core/multi-store';
2
+
3
+ declare function createAccountService(prisma: any): AccountService;
4
+
5
+ declare function createSharedSettingsService(prisma: any): SharedSettingsService;
6
+
7
+ declare function createAccountMiddleware(prisma: any): AccountMiddleware;
8
+
9
+ declare function calculateAccountPricing(storeCount: number, tiers?: AccountPricingTier[], basePrice?: number): AccountPricingResult;
10
+
11
+ export { calculateAccountPricing, createAccountMiddleware, createAccountService, createSharedSettingsService };
@@ -0,0 +1,473 @@
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/multi-store/index.ts
21
+ var multi_store_exports = {};
22
+ __export(multi_store_exports, {
23
+ calculateAccountPricing: () => calculateAccountPricing,
24
+ createAccountMiddleware: () => createAccountMiddleware,
25
+ createAccountService: () => createAccountService,
26
+ createSharedSettingsService: () => createSharedSettingsService
27
+ });
28
+ module.exports = __toCommonJS(multi_store_exports);
29
+
30
+ // src/multi-store/account-service.ts
31
+ var import_multi_store = require("@uniforge/platform-core/multi-store");
32
+ function mapAccount(row) {
33
+ return {
34
+ id: row.id,
35
+ name: row.name,
36
+ type: row.type,
37
+ isActive: row.isActive,
38
+ createdAt: row.createdAt,
39
+ updatedAt: row.updatedAt
40
+ };
41
+ }
42
+ function mapAccountStore(row) {
43
+ return {
44
+ id: row.id,
45
+ accountId: row.accountId,
46
+ shopDomain: row.shopDomain,
47
+ storeName: row.storeName,
48
+ region: row.region ?? null,
49
+ currency: row.currency ?? null,
50
+ locale: row.locale ?? null,
51
+ timezone: row.timezone ?? null,
52
+ storeSettings: row.storeSettings && typeof row.storeSettings === "object" ? row.storeSettings : {},
53
+ isActive: row.isActive,
54
+ isPrimary: row.isPrimary,
55
+ createdAt: row.createdAt,
56
+ updatedAt: row.updatedAt
57
+ };
58
+ }
59
+ function mapAccountMember(row) {
60
+ return {
61
+ id: row.id,
62
+ accountId: row.accountId,
63
+ userEmail: row.userEmail,
64
+ role: row.role,
65
+ allStoresAccess: row.allStoresAccess,
66
+ allowedStoreIds: Array.isArray(row.allowedStoreIds) ? row.allowedStoreIds : [],
67
+ permissions: Array.isArray(row.permissions) ? row.permissions : [],
68
+ createdAt: row.createdAt,
69
+ updatedAt: row.updatedAt
70
+ };
71
+ }
72
+ function createAccountService(prisma) {
73
+ return {
74
+ async createAccount(input) {
75
+ const row = await prisma.account.create({
76
+ data: {
77
+ name: input.name,
78
+ type: input.type
79
+ }
80
+ });
81
+ return mapAccount(row);
82
+ },
83
+ async getAccount(accountId) {
84
+ const row = await prisma.account.findUnique({
85
+ where: { id: accountId }
86
+ });
87
+ if (!row) return null;
88
+ return mapAccount(row);
89
+ },
90
+ async updateAccount(accountId, input) {
91
+ const data = {};
92
+ if (input.name !== void 0) {
93
+ data.name = input.name;
94
+ }
95
+ if (input.type !== void 0) {
96
+ data.type = input.type;
97
+ }
98
+ if (input.isActive !== void 0) {
99
+ data.isActive = input.isActive;
100
+ }
101
+ const row = await prisma.account.update({
102
+ where: { id: accountId },
103
+ data
104
+ });
105
+ return mapAccount(row);
106
+ },
107
+ async deleteAccount(accountId) {
108
+ await prisma.account.delete({ where: { id: accountId } });
109
+ },
110
+ async addStore(input) {
111
+ const data = {
112
+ accountId: input.accountId,
113
+ shopDomain: input.shopDomain,
114
+ storeName: input.storeName
115
+ };
116
+ if (input.region !== void 0) {
117
+ data.region = input.region;
118
+ }
119
+ if (input.currency !== void 0) {
120
+ data.currency = input.currency;
121
+ }
122
+ if (input.locale !== void 0) {
123
+ data.locale = input.locale;
124
+ }
125
+ if (input.timezone !== void 0) {
126
+ data.timezone = input.timezone;
127
+ }
128
+ if (input.storeSettings !== void 0) {
129
+ data.storeSettings = input.storeSettings;
130
+ }
131
+ if (input.isPrimary !== void 0) {
132
+ data.isPrimary = input.isPrimary;
133
+ }
134
+ const row = await prisma.accountStore.create({ data });
135
+ return mapAccountStore(row);
136
+ },
137
+ async getStore(storeId) {
138
+ const row = await prisma.accountStore.findUnique({
139
+ where: { id: storeId }
140
+ });
141
+ if (!row) return null;
142
+ return mapAccountStore(row);
143
+ },
144
+ async getStoreByDomain(shopDomain) {
145
+ const row = await prisma.accountStore.findUnique({
146
+ where: { shopDomain }
147
+ });
148
+ if (!row) return null;
149
+ return mapAccountStore(row);
150
+ },
151
+ async listStores(accountId) {
152
+ const rows = await prisma.accountStore.findMany({
153
+ where: { accountId }
154
+ });
155
+ return rows.map(mapAccountStore);
156
+ },
157
+ async updateStore(storeId, input) {
158
+ const data = {};
159
+ if (input.storeName !== void 0) {
160
+ data.storeName = input.storeName;
161
+ }
162
+ if (input.region !== void 0) {
163
+ data.region = input.region;
164
+ }
165
+ if (input.currency !== void 0) {
166
+ data.currency = input.currency;
167
+ }
168
+ if (input.locale !== void 0) {
169
+ data.locale = input.locale;
170
+ }
171
+ if (input.timezone !== void 0) {
172
+ data.timezone = input.timezone;
173
+ }
174
+ if (input.storeSettings !== void 0) {
175
+ data.storeSettings = input.storeSettings;
176
+ }
177
+ if (input.isActive !== void 0) {
178
+ data.isActive = input.isActive;
179
+ }
180
+ if (input.isPrimary !== void 0) {
181
+ data.isPrimary = input.isPrimary;
182
+ }
183
+ const row = await prisma.accountStore.update({
184
+ where: { id: storeId },
185
+ data
186
+ });
187
+ return mapAccountStore(row);
188
+ },
189
+ async removeStore(storeId) {
190
+ await prisma.accountStore.delete({ where: { id: storeId } });
191
+ },
192
+ async addMember(input) {
193
+ const data = {
194
+ accountId: input.accountId,
195
+ userEmail: input.userEmail,
196
+ role: input.role
197
+ };
198
+ if (input.allStoresAccess !== void 0) {
199
+ data.allStoresAccess = input.allStoresAccess;
200
+ }
201
+ if (input.allowedStoreIds !== void 0) {
202
+ data.allowedStoreIds = JSON.stringify(input.allowedStoreIds);
203
+ }
204
+ if (input.permissions !== void 0) {
205
+ data.permissions = JSON.stringify(input.permissions);
206
+ }
207
+ const row = await prisma.accountMember.create({ data });
208
+ return mapAccountMember(row);
209
+ },
210
+ async getMember(memberId) {
211
+ const row = await prisma.accountMember.findUnique({
212
+ where: { id: memberId }
213
+ });
214
+ if (!row) return null;
215
+ return mapAccountMember(row);
216
+ },
217
+ async getMemberByEmail(accountId, userEmail) {
218
+ const row = await prisma.accountMember.findUnique({
219
+ where: { accountId_userEmail: { accountId, userEmail } }
220
+ });
221
+ if (!row) return null;
222
+ return mapAccountMember(row);
223
+ },
224
+ async listMembers(accountId) {
225
+ const rows = await prisma.accountMember.findMany({
226
+ where: { accountId }
227
+ });
228
+ return rows.map(mapAccountMember);
229
+ },
230
+ async updateMember(memberId, input) {
231
+ const data = {};
232
+ if (input.role !== void 0) {
233
+ data.role = input.role;
234
+ }
235
+ if (input.allStoresAccess !== void 0) {
236
+ data.allStoresAccess = input.allStoresAccess;
237
+ }
238
+ if (input.allowedStoreIds !== void 0) {
239
+ data.allowedStoreIds = JSON.stringify(input.allowedStoreIds);
240
+ }
241
+ if (input.permissions !== void 0) {
242
+ data.permissions = JSON.stringify(input.permissions);
243
+ }
244
+ const row = await prisma.accountMember.update({
245
+ where: { id: memberId },
246
+ data
247
+ });
248
+ return mapAccountMember(row);
249
+ },
250
+ async removeMember(memberId) {
251
+ await prisma.accountMember.delete({ where: { id: memberId } });
252
+ },
253
+ async canAccessStore(accountId, userEmail, storeId) {
254
+ const row = await prisma.accountMember.findUnique({
255
+ where: { accountId_userEmail: { accountId, userEmail } }
256
+ });
257
+ if (!row) return false;
258
+ const member = mapAccountMember(row);
259
+ if (member.role === "owner" || member.role === "admin") return true;
260
+ if (member.allStoresAccess) return true;
261
+ return member.allowedStoreIds.includes(storeId);
262
+ },
263
+ async isRoleAtLeast(accountId, userEmail, minimumRole) {
264
+ const row = await prisma.accountMember.findUnique({
265
+ where: { accountId_userEmail: { accountId, userEmail } }
266
+ });
267
+ if (!row) return false;
268
+ const member = mapAccountMember(row);
269
+ return import_multi_store.ACCOUNT_ROLE_HIERARCHY[member.role] >= import_multi_store.ACCOUNT_ROLE_HIERARCHY[minimumRole];
270
+ }
271
+ };
272
+ }
273
+
274
+ // src/multi-store/shared-settings-service.ts
275
+ function mapSharedSetting(row) {
276
+ return {
277
+ id: row.id,
278
+ accountId: row.accountId,
279
+ settingKey: row.settingKey,
280
+ settingValue: row.settingValue,
281
+ appliesToStores: Array.isArray(row.appliesToStores) ? row.appliesToStores : null,
282
+ createdAt: row.createdAt,
283
+ updatedAt: row.updatedAt
284
+ };
285
+ }
286
+ function createSharedSettingsService(prisma) {
287
+ return {
288
+ async set(input) {
289
+ const data = {
290
+ settingValue: input.settingValue
291
+ };
292
+ if (input.appliesToStores !== void 0) {
293
+ data.appliesToStores = input.appliesToStores === null ? null : JSON.stringify(input.appliesToStores);
294
+ }
295
+ const row = await prisma.accountSharedSetting.upsert({
296
+ where: {
297
+ accountId_settingKey: {
298
+ accountId: input.accountId,
299
+ settingKey: input.settingKey
300
+ }
301
+ },
302
+ create: {
303
+ accountId: input.accountId,
304
+ settingKey: input.settingKey,
305
+ settingValue: input.settingValue,
306
+ ...input.appliesToStores !== void 0 ? {
307
+ appliesToStores: input.appliesToStores === null ? null : JSON.stringify(input.appliesToStores)
308
+ } : {}
309
+ },
310
+ update: data
311
+ });
312
+ return mapSharedSetting(row);
313
+ },
314
+ async get(accountId, settingKey) {
315
+ const row = await prisma.accountSharedSetting.findUnique({
316
+ where: { accountId_settingKey: { accountId, settingKey } }
317
+ });
318
+ if (!row) return null;
319
+ return mapSharedSetting(row);
320
+ },
321
+ async list(accountId) {
322
+ const rows = await prisma.accountSharedSetting.findMany({
323
+ where: { accountId }
324
+ });
325
+ return rows.map(mapSharedSetting);
326
+ },
327
+ async delete(accountId, settingKey) {
328
+ await prisma.accountSharedSetting.delete({
329
+ where: { accountId_settingKey: { accountId, settingKey } }
330
+ });
331
+ },
332
+ async resolve(accountId, storeId, settingKey, defaultValue) {
333
+ const store = await prisma.accountStore.findUnique({
334
+ where: { id: storeId }
335
+ });
336
+ if (store) {
337
+ const storeSettings = store.storeSettings && typeof store.storeSettings === "object" ? store.storeSettings : {};
338
+ if (settingKey in storeSettings) {
339
+ return storeSettings[settingKey];
340
+ }
341
+ }
342
+ const shared = await prisma.accountSharedSetting.findUnique({
343
+ where: { accountId_settingKey: { accountId, settingKey } }
344
+ });
345
+ if (shared) {
346
+ const appliesToStores = Array.isArray(shared.appliesToStores) ? shared.appliesToStores : null;
347
+ if (appliesToStores === null || appliesToStores.includes(storeId)) {
348
+ return shared.settingValue;
349
+ }
350
+ }
351
+ return defaultValue;
352
+ }
353
+ };
354
+ }
355
+
356
+ // src/multi-store/account-middleware.ts
357
+ function mapAccountStore2(row) {
358
+ return {
359
+ id: row.id,
360
+ accountId: row.accountId,
361
+ shopDomain: row.shopDomain,
362
+ storeName: row.storeName,
363
+ region: row.region ?? null,
364
+ currency: row.currency ?? null,
365
+ locale: row.locale ?? null,
366
+ timezone: row.timezone ?? null,
367
+ storeSettings: row.storeSettings && typeof row.storeSettings === "object" ? row.storeSettings : {},
368
+ isActive: row.isActive,
369
+ isPrimary: row.isPrimary,
370
+ createdAt: row.createdAt,
371
+ updatedAt: row.updatedAt
372
+ };
373
+ }
374
+ function mapAccount2(row) {
375
+ return {
376
+ id: row.id,
377
+ name: row.name,
378
+ type: row.type,
379
+ isActive: row.isActive,
380
+ createdAt: row.createdAt,
381
+ updatedAt: row.updatedAt
382
+ };
383
+ }
384
+ function mapAccountMember2(row) {
385
+ return {
386
+ id: row.id,
387
+ accountId: row.accountId,
388
+ userEmail: row.userEmail,
389
+ role: row.role,
390
+ allStoresAccess: row.allStoresAccess,
391
+ allowedStoreIds: Array.isArray(row.allowedStoreIds) ? row.allowedStoreIds : [],
392
+ permissions: Array.isArray(row.permissions) ? row.permissions : [],
393
+ createdAt: row.createdAt,
394
+ updatedAt: row.updatedAt
395
+ };
396
+ }
397
+ function createAccountMiddleware(prisma) {
398
+ return {
399
+ async getAccountContext(shopDomain, userEmail) {
400
+ const storeRow = await prisma.accountStore.findUnique({
401
+ where: { shopDomain },
402
+ include: { account: true }
403
+ });
404
+ if (!storeRow) return null;
405
+ const account = mapAccount2(storeRow.account);
406
+ const currentStore = mapAccountStore2(storeRow);
407
+ const storeRows = await prisma.accountStore.findMany({
408
+ where: { accountId: account.id }
409
+ });
410
+ const stores = storeRows.map(mapAccountStore2);
411
+ let member = null;
412
+ if (userEmail) {
413
+ const memberRow = await prisma.accountMember.findUnique({
414
+ where: {
415
+ accountId_userEmail: { accountId: account.id, userEmail }
416
+ }
417
+ });
418
+ if (memberRow) {
419
+ member = mapAccountMember2(memberRow);
420
+ }
421
+ }
422
+ return { account, currentStore, member, stores };
423
+ },
424
+ async validateStoreAccess(accountId, userEmail, storeId) {
425
+ const memberRow = await prisma.accountMember.findUnique({
426
+ where: { accountId_userEmail: { accountId, userEmail } }
427
+ });
428
+ if (!memberRow) return false;
429
+ const member = mapAccountMember2(memberRow);
430
+ if (member.role === "owner" || member.role === "admin") return true;
431
+ if (member.allStoresAccess) return true;
432
+ return member.allowedStoreIds.includes(storeId);
433
+ }
434
+ };
435
+ }
436
+
437
+ // src/multi-store/pricing.ts
438
+ var import_multi_store2 = require("@uniforge/platform-core/multi-store");
439
+ function calculateAccountPricing(storeCount, tiers, basePrice) {
440
+ const effectiveTiers = tiers ?? import_multi_store2.DEFAULT_PRICING_TIERS;
441
+ const effectiveBasePrice = basePrice ?? import_multi_store2.DEFAULT_BASE_PRICE;
442
+ const includedStores = import_multi_store2.DEFAULT_INCLUDED_STORES;
443
+ const tierBreakdown = [];
444
+ let additionalStoreCost = 0;
445
+ for (const tier of effectiveTiers) {
446
+ const tierMax = tier.maxStores ?? storeCount;
447
+ const tierStart = tier.minStores;
448
+ const tierEnd = Math.min(tierMax, storeCount);
449
+ if (tierStart > storeCount) {
450
+ tierBreakdown.push({ tier, storeCount: 0, cost: 0 });
451
+ continue;
452
+ }
453
+ const storesInTier = tierEnd - tierStart + 1;
454
+ const cost = storesInTier * tier.pricePerStore;
455
+ tierBreakdown.push({ tier, storeCount: storesInTier, cost });
456
+ additionalStoreCost += cost;
457
+ }
458
+ return {
459
+ basePrice: effectiveBasePrice,
460
+ includedStores,
461
+ additionalStoreCost,
462
+ totalMonthlyPrice: effectiveBasePrice + additionalStoreCost,
463
+ tierBreakdown
464
+ };
465
+ }
466
+ // Annotate the CommonJS export names for ESM import in node:
467
+ 0 && (module.exports = {
468
+ calculateAccountPricing,
469
+ createAccountMiddleware,
470
+ createAccountService,
471
+ createSharedSettingsService
472
+ });
473
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/multi-store/index.ts","../../src/multi-store/account-service.ts","../../src/multi-store/shared-settings-service.ts","../../src/multi-store/account-middleware.ts","../../src/multi-store/pricing.ts"],"sourcesContent":["export { createAccountService } from './account-service';\nexport { createSharedSettingsService } from './shared-settings-service';\nexport { createAccountMiddleware } from './account-middleware';\nexport { calculateAccountPricing } from './pricing';\n","import type {\n Account,\n AccountStore,\n AccountMember,\n AccountRole,\n AccountType,\n AccountService,\n CreateAccountInput,\n UpdateAccountInput,\n AddStoreInput,\n UpdateStoreInput,\n AddMemberInput,\n UpdateMemberInput,\n} from '@uniforge/platform-core/multi-store';\nimport { ACCOUNT_ROLE_HIERARCHY } from '@uniforge/platform-core/multi-store';\n\nfunction mapAccount(row: any): Account {\n return {\n id: row.id,\n name: row.name,\n type: row.type as AccountType,\n isActive: row.isActive,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n\nfunction mapAccountStore(row: any): AccountStore {\n return {\n id: row.id,\n accountId: row.accountId,\n shopDomain: row.shopDomain,\n storeName: row.storeName,\n region: row.region ?? null,\n currency: row.currency ?? null,\n locale: row.locale ?? null,\n timezone: row.timezone ?? null,\n storeSettings:\n row.storeSettings && typeof row.storeSettings === 'object'\n ? (row.storeSettings as Record<string, unknown>)\n : {},\n isActive: row.isActive,\n isPrimary: row.isPrimary,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n\nfunction mapAccountMember(row: any): AccountMember {\n return {\n id: row.id,\n accountId: row.accountId,\n userEmail: row.userEmail,\n role: row.role as AccountRole,\n allStoresAccess: row.allStoresAccess,\n allowedStoreIds: Array.isArray(row.allowedStoreIds)\n ? (row.allowedStoreIds as string[])\n : [],\n permissions: Array.isArray(row.permissions)\n ? (row.permissions as string[])\n : [],\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n\nexport function createAccountService(prisma: any): AccountService {\n return {\n async createAccount(input: CreateAccountInput): Promise<Account> {\n const row = await prisma.account.create({\n data: {\n name: input.name,\n type: input.type,\n },\n });\n return mapAccount(row);\n },\n\n async getAccount(accountId: string): Promise<Account | null> {\n const row = await prisma.account.findUnique({\n where: { id: accountId },\n });\n if (!row) return null;\n return mapAccount(row);\n },\n\n async updateAccount(\n accountId: string,\n input: UpdateAccountInput,\n ): Promise<Account> {\n const data: Record<string, unknown> = {};\n if (input.name !== undefined) {\n data.name = input.name;\n }\n if (input.type !== undefined) {\n data.type = input.type;\n }\n if (input.isActive !== undefined) {\n data.isActive = input.isActive;\n }\n const row = await prisma.account.update({\n where: { id: accountId },\n data,\n });\n return mapAccount(row);\n },\n\n async deleteAccount(accountId: string): Promise<void> {\n await prisma.account.delete({ where: { id: accountId } });\n },\n\n async addStore(input: AddStoreInput): Promise<AccountStore> {\n const data: Record<string, unknown> = {\n accountId: input.accountId,\n shopDomain: input.shopDomain,\n storeName: input.storeName,\n };\n if (input.region !== undefined) {\n data.region = input.region;\n }\n if (input.currency !== undefined) {\n data.currency = input.currency;\n }\n if (input.locale !== undefined) {\n data.locale = input.locale;\n }\n if (input.timezone !== undefined) {\n data.timezone = input.timezone;\n }\n if (input.storeSettings !== undefined) {\n data.storeSettings = input.storeSettings;\n }\n if (input.isPrimary !== undefined) {\n data.isPrimary = input.isPrimary;\n }\n const row = await prisma.accountStore.create({ data });\n return mapAccountStore(row);\n },\n\n async getStore(storeId: string): Promise<AccountStore | null> {\n const row = await prisma.accountStore.findUnique({\n where: { id: storeId },\n });\n if (!row) return null;\n return mapAccountStore(row);\n },\n\n async getStoreByDomain(shopDomain: string): Promise<AccountStore | null> {\n const row = await prisma.accountStore.findUnique({\n where: { shopDomain },\n });\n if (!row) return null;\n return mapAccountStore(row);\n },\n\n async listStores(accountId: string): Promise<AccountStore[]> {\n const rows = await prisma.accountStore.findMany({\n where: { accountId },\n });\n return rows.map(mapAccountStore);\n },\n\n async updateStore(\n storeId: string,\n input: UpdateStoreInput,\n ): Promise<AccountStore> {\n const data: Record<string, unknown> = {};\n if (input.storeName !== undefined) {\n data.storeName = input.storeName;\n }\n if (input.region !== undefined) {\n data.region = input.region;\n }\n if (input.currency !== undefined) {\n data.currency = input.currency;\n }\n if (input.locale !== undefined) {\n data.locale = input.locale;\n }\n if (input.timezone !== undefined) {\n data.timezone = input.timezone;\n }\n if (input.storeSettings !== undefined) {\n data.storeSettings = input.storeSettings;\n }\n if (input.isActive !== undefined) {\n data.isActive = input.isActive;\n }\n if (input.isPrimary !== undefined) {\n data.isPrimary = input.isPrimary;\n }\n const row = await prisma.accountStore.update({\n where: { id: storeId },\n data,\n });\n return mapAccountStore(row);\n },\n\n async removeStore(storeId: string): Promise<void> {\n await prisma.accountStore.delete({ where: { id: storeId } });\n },\n\n async addMember(input: AddMemberInput): Promise<AccountMember> {\n const data: Record<string, unknown> = {\n accountId: input.accountId,\n userEmail: input.userEmail,\n role: input.role,\n };\n if (input.allStoresAccess !== undefined) {\n data.allStoresAccess = input.allStoresAccess;\n }\n if (input.allowedStoreIds !== undefined) {\n data.allowedStoreIds = JSON.stringify(input.allowedStoreIds);\n }\n if (input.permissions !== undefined) {\n data.permissions = JSON.stringify(input.permissions);\n }\n const row = await prisma.accountMember.create({ data });\n return mapAccountMember(row);\n },\n\n async getMember(memberId: string): Promise<AccountMember | null> {\n const row = await prisma.accountMember.findUnique({\n where: { id: memberId },\n });\n if (!row) return null;\n return mapAccountMember(row);\n },\n\n async getMemberByEmail(\n accountId: string,\n userEmail: string,\n ): Promise<AccountMember | null> {\n const row = await prisma.accountMember.findUnique({\n where: { accountId_userEmail: { accountId, userEmail } },\n });\n if (!row) return null;\n return mapAccountMember(row);\n },\n\n async listMembers(accountId: string): Promise<AccountMember[]> {\n const rows = await prisma.accountMember.findMany({\n where: { accountId },\n });\n return rows.map(mapAccountMember);\n },\n\n async updateMember(\n memberId: string,\n input: UpdateMemberInput,\n ): Promise<AccountMember> {\n const data: Record<string, unknown> = {};\n if (input.role !== undefined) {\n data.role = input.role;\n }\n if (input.allStoresAccess !== undefined) {\n data.allStoresAccess = input.allStoresAccess;\n }\n if (input.allowedStoreIds !== undefined) {\n data.allowedStoreIds = JSON.stringify(input.allowedStoreIds);\n }\n if (input.permissions !== undefined) {\n data.permissions = JSON.stringify(input.permissions);\n }\n const row = await prisma.accountMember.update({\n where: { id: memberId },\n data,\n });\n return mapAccountMember(row);\n },\n\n async removeMember(memberId: string): Promise<void> {\n await prisma.accountMember.delete({ where: { id: memberId } });\n },\n\n async canAccessStore(\n accountId: string,\n userEmail: string,\n storeId: string,\n ): Promise<boolean> {\n const row = await prisma.accountMember.findUnique({\n where: { accountId_userEmail: { accountId, userEmail } },\n });\n if (!row) return false;\n const member = mapAccountMember(row);\n if (member.role === 'owner' || member.role === 'admin') return true;\n if (member.allStoresAccess) return true;\n return member.allowedStoreIds.includes(storeId);\n },\n\n async isRoleAtLeast(\n accountId: string,\n userEmail: string,\n minimumRole: AccountRole,\n ): Promise<boolean> {\n const row = await prisma.accountMember.findUnique({\n where: { accountId_userEmail: { accountId, userEmail } },\n });\n if (!row) return false;\n const member = mapAccountMember(row);\n return (\n ACCOUNT_ROLE_HIERARCHY[member.role] >=\n ACCOUNT_ROLE_HIERARCHY[minimumRole]\n );\n },\n };\n}\n","import type {\n AccountSharedSetting,\n SetSharedSettingInput,\n SharedSettingsService,\n} from '@uniforge/platform-core/multi-store';\n\nfunction mapSharedSetting(row: any): AccountSharedSetting {\n return {\n id: row.id,\n accountId: row.accountId,\n settingKey: row.settingKey,\n settingValue: row.settingValue,\n appliesToStores: Array.isArray(row.appliesToStores)\n ? (row.appliesToStores as string[])\n : null,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n\nexport function createSharedSettingsService(\n prisma: any,\n): SharedSettingsService {\n return {\n async set(input: SetSharedSettingInput): Promise<AccountSharedSetting> {\n const data: Record<string, unknown> = {\n settingValue: input.settingValue,\n };\n if (input.appliesToStores !== undefined) {\n data.appliesToStores =\n input.appliesToStores === null\n ? null\n : JSON.stringify(input.appliesToStores);\n }\n const row = await prisma.accountSharedSetting.upsert({\n where: {\n accountId_settingKey: {\n accountId: input.accountId,\n settingKey: input.settingKey,\n },\n },\n create: {\n accountId: input.accountId,\n settingKey: input.settingKey,\n settingValue: input.settingValue,\n ...(input.appliesToStores !== undefined\n ? {\n appliesToStores:\n input.appliesToStores === null\n ? null\n : JSON.stringify(input.appliesToStores),\n }\n : {}),\n },\n update: data,\n });\n return mapSharedSetting(row);\n },\n\n async get(\n accountId: string,\n settingKey: string,\n ): Promise<AccountSharedSetting | null> {\n const row = await prisma.accountSharedSetting.findUnique({\n where: { accountId_settingKey: { accountId, settingKey } },\n });\n if (!row) return null;\n return mapSharedSetting(row);\n },\n\n async list(accountId: string): Promise<AccountSharedSetting[]> {\n const rows = await prisma.accountSharedSetting.findMany({\n where: { accountId },\n });\n return rows.map(mapSharedSetting);\n },\n\n async delete(accountId: string, settingKey: string): Promise<void> {\n await prisma.accountSharedSetting.delete({\n where: { accountId_settingKey: { accountId, settingKey } },\n });\n },\n\n async resolve<T = unknown>(\n accountId: string,\n storeId: string,\n settingKey: string,\n defaultValue: T,\n ): Promise<T> {\n // 1. Check store-specific override\n const store = await prisma.accountStore.findUnique({\n where: { id: storeId },\n });\n if (store) {\n const storeSettings =\n store.storeSettings && typeof store.storeSettings === 'object'\n ? (store.storeSettings as Record<string, unknown>)\n : {};\n if (settingKey in storeSettings) {\n return storeSettings[settingKey] as T;\n }\n }\n\n // 2. Check account shared setting\n const shared = await prisma.accountSharedSetting.findUnique({\n where: { accountId_settingKey: { accountId, settingKey } },\n });\n if (shared) {\n const appliesToStores = Array.isArray(shared.appliesToStores)\n ? (shared.appliesToStores as string[])\n : null;\n if (\n appliesToStores === null ||\n appliesToStores.includes(storeId)\n ) {\n return shared.settingValue as T;\n }\n }\n\n // 3. Return default\n return defaultValue;\n },\n };\n}\n","import type {\n AccountContext,\n AccountMiddleware,\n AccountRole,\n} from '@uniforge/platform-core/multi-store';\n\nfunction mapAccountStore(row: any) {\n return {\n id: row.id,\n accountId: row.accountId,\n shopDomain: row.shopDomain,\n storeName: row.storeName,\n region: row.region ?? null,\n currency: row.currency ?? null,\n locale: row.locale ?? null,\n timezone: row.timezone ?? null,\n storeSettings:\n row.storeSettings && typeof row.storeSettings === 'object'\n ? (row.storeSettings as Record<string, unknown>)\n : {},\n isActive: row.isActive,\n isPrimary: row.isPrimary,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n\nfunction mapAccount(row: any) {\n return {\n id: row.id,\n name: row.name,\n type: row.type as 'individual' | 'enterprise',\n isActive: row.isActive,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n\nfunction mapAccountMember(row: any) {\n return {\n id: row.id,\n accountId: row.accountId,\n userEmail: row.userEmail,\n role: row.role as AccountRole,\n allStoresAccess: row.allStoresAccess,\n allowedStoreIds: Array.isArray(row.allowedStoreIds)\n ? (row.allowedStoreIds as string[])\n : [],\n permissions: Array.isArray(row.permissions)\n ? (row.permissions as string[])\n : [],\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n\nexport function createAccountMiddleware(prisma: any): AccountMiddleware {\n return {\n async getAccountContext(\n shopDomain: string,\n userEmail?: string,\n ): Promise<AccountContext | null> {\n // 1. Find the store by shopDomain, include account\n const storeRow = await prisma.accountStore.findUnique({\n where: { shopDomain },\n include: { account: true },\n });\n if (!storeRow) return null;\n\n const account = mapAccount(storeRow.account);\n const currentStore = mapAccountStore(storeRow);\n\n // 2. Get all stores for the account\n const storeRows = await prisma.accountStore.findMany({\n where: { accountId: account.id },\n });\n const stores = storeRows.map(mapAccountStore);\n\n // 3. Get member if userEmail provided\n let member = null;\n if (userEmail) {\n const memberRow = await prisma.accountMember.findUnique({\n where: {\n accountId_userEmail: { accountId: account.id, userEmail },\n },\n });\n if (memberRow) {\n member = mapAccountMember(memberRow);\n }\n }\n\n return { account, currentStore, member, stores };\n },\n\n async validateStoreAccess(\n accountId: string,\n userEmail: string,\n storeId: string,\n ): Promise<boolean> {\n const memberRow = await prisma.accountMember.findUnique({\n where: { accountId_userEmail: { accountId, userEmail } },\n });\n if (!memberRow) return false;\n\n const member = mapAccountMember(memberRow);\n if (member.role === 'owner' || member.role === 'admin') return true;\n if (member.allStoresAccess) return true;\n return member.allowedStoreIds.includes(storeId);\n },\n };\n}\n","import type {\n AccountPricingTier,\n AccountPricingResult,\n} from '@uniforge/platform-core/multi-store';\nimport {\n DEFAULT_PRICING_TIERS,\n DEFAULT_BASE_PRICE,\n DEFAULT_INCLUDED_STORES,\n} from '@uniforge/platform-core/multi-store';\n\nexport function calculateAccountPricing(\n storeCount: number,\n tiers?: AccountPricingTier[],\n basePrice?: number,\n): AccountPricingResult {\n const effectiveTiers = tiers ?? DEFAULT_PRICING_TIERS;\n const effectiveBasePrice = basePrice ?? DEFAULT_BASE_PRICE;\n const includedStores = DEFAULT_INCLUDED_STORES;\n\n const tierBreakdown: Array<{\n tier: AccountPricingTier;\n storeCount: number;\n cost: number;\n }> = [];\n let additionalStoreCost = 0;\n\n for (const tier of effectiveTiers) {\n const tierMax = tier.maxStores ?? storeCount;\n const tierStart = tier.minStores;\n const tierEnd = Math.min(tierMax, storeCount);\n\n if (tierStart > storeCount) {\n tierBreakdown.push({ tier, storeCount: 0, cost: 0 });\n continue;\n }\n\n const storesInTier = tierEnd - tierStart + 1;\n const cost = storesInTier * tier.pricePerStore;\n\n tierBreakdown.push({ tier, storeCount: storesInTier, cost });\n additionalStoreCost += cost;\n }\n\n return {\n basePrice: effectiveBasePrice,\n includedStores,\n additionalStoreCost,\n totalMonthlyPrice: effectiveBasePrice + additionalStoreCost,\n tierBreakdown,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcA,yBAAuC;AAEvC,SAAS,WAAW,KAAmB;AACrC,SAAO;AAAA,IACL,IAAI,IAAI;AAAA,IACR,MAAM,IAAI;AAAA,IACV,MAAM,IAAI;AAAA,IACV,UAAU,IAAI;AAAA,IACd,WAAW,IAAI;AAAA,IACf,WAAW,IAAI;AAAA,EACjB;AACF;AAEA,SAAS,gBAAgB,KAAwB;AAC/C,SAAO;AAAA,IACL,IAAI,IAAI;AAAA,IACR,WAAW,IAAI;AAAA,IACf,YAAY,IAAI;AAAA,IAChB,WAAW,IAAI;AAAA,IACf,QAAQ,IAAI,UAAU;AAAA,IACtB,UAAU,IAAI,YAAY;AAAA,IAC1B,QAAQ,IAAI,UAAU;AAAA,IACtB,UAAU,IAAI,YAAY;AAAA,IAC1B,eACE,IAAI,iBAAiB,OAAO,IAAI,kBAAkB,WAC7C,IAAI,gBACL,CAAC;AAAA,IACP,UAAU,IAAI;AAAA,IACd,WAAW,IAAI;AAAA,IACf,WAAW,IAAI;AAAA,IACf,WAAW,IAAI;AAAA,EACjB;AACF;AAEA,SAAS,iBAAiB,KAAyB;AACjD,SAAO;AAAA,IACL,IAAI,IAAI;AAAA,IACR,WAAW,IAAI;AAAA,IACf,WAAW,IAAI;AAAA,IACf,MAAM,IAAI;AAAA,IACV,iBAAiB,IAAI;AAAA,IACrB,iBAAiB,MAAM,QAAQ,IAAI,eAAe,IAC7C,IAAI,kBACL,CAAC;AAAA,IACL,aAAa,MAAM,QAAQ,IAAI,WAAW,IACrC,IAAI,cACL,CAAC;AAAA,IACL,WAAW,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