@uniforge/platform-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.
- package/dist/auth/index.d.cts +184 -0
- package/dist/auth/index.d.ts +184 -0
- package/dist/auth/index.js +62 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/index.mjs +33 -0
- package/dist/auth/index.mjs.map +1 -0
- package/dist/billing/index.d.cts +213 -0
- package/dist/billing/index.d.ts +213 -0
- package/dist/billing/index.js +43 -0
- package/dist/billing/index.js.map +1 -0
- package/dist/billing/index.mjs +16 -0
- package/dist/billing/index.mjs.map +1 -0
- package/dist/graphql/index.d.cts +100 -0
- package/dist/graphql/index.d.ts +100 -0
- package/dist/graphql/index.js +19 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/graphql/index.mjs +1 -0
- package/dist/graphql/index.mjs.map +1 -0
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -0
- package/dist/multi-store/index.d.cts +242 -0
- package/dist/multi-store/index.d.ts +242 -0
- package/dist/multi-store/index.js +53 -0
- package/dist/multi-store/index.js.map +1 -0
- package/dist/multi-store/index.mjs +23 -0
- package/dist/multi-store/index.mjs.map +1 -0
- package/dist/multi-tenant/index.d.cts +64 -0
- package/dist/multi-tenant/index.d.ts +64 -0
- package/dist/multi-tenant/index.js +19 -0
- package/dist/multi-tenant/index.js.map +1 -0
- package/dist/multi-tenant/index.mjs +1 -0
- package/dist/multi-tenant/index.mjs.map +1 -0
- package/dist/performance/index.d.cts +118 -0
- package/dist/performance/index.d.ts +118 -0
- package/dist/performance/index.js +19 -0
- package/dist/performance/index.js.map +1 -0
- package/dist/performance/index.mjs +1 -0
- package/dist/performance/index.mjs.map +1 -0
- package/dist/platform/index.d.cts +156 -0
- package/dist/platform/index.d.ts +156 -0
- package/dist/platform/index.js +64 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/index.mjs +37 -0
- package/dist/platform/index.mjs.map +1 -0
- package/dist/rbac/index.d.cts +140 -0
- package/dist/rbac/index.d.ts +140 -0
- package/dist/rbac/index.js +55 -0
- package/dist/rbac/index.js.map +1 -0
- package/dist/rbac/index.mjs +27 -0
- package/dist/rbac/index.mjs.map +1 -0
- package/dist/registry-efvajmOd.d.cts +118 -0
- package/dist/registry-efvajmOd.d.ts +118 -0
- package/dist/security/index.d.cts +148 -0
- package/dist/security/index.d.ts +148 -0
- package/dist/security/index.js +40 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/index.mjs +13 -0
- package/dist/security/index.mjs.map +1 -0
- package/dist/types-CgnJiK8Z.d.cts +74 -0
- package/dist/types-CgnJiK8Z.d.ts +74 -0
- package/dist/webhooks/index.d.cts +114 -0
- package/dist/webhooks/index.d.ts +114 -0
- package/dist/webhooks/index.js +19 -0
- package/dist/webhooks/index.js.map +1 -0
- package/dist/webhooks/index.mjs +1 -0
- package/dist/webhooks/index.mjs.map +1 -0
- package/package.json +94 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-store enterprise types.
|
|
3
|
+
*
|
|
4
|
+
* Defines the Account hierarchy above Shop for enterprise merchants
|
|
5
|
+
* managing multiple Shopify stores under a single account.
|
|
6
|
+
*/
|
|
7
|
+
/** Account type — individual has one store, enterprise has many. */
|
|
8
|
+
type AccountType = 'individual' | 'enterprise';
|
|
9
|
+
/** Account-level roles with hierarchy: owner > admin > member > viewer. */
|
|
10
|
+
type AccountRole = 'owner' | 'admin' | 'member' | 'viewer';
|
|
11
|
+
/** Role hierarchy for permission comparison (higher = more access). */
|
|
12
|
+
declare const ACCOUNT_ROLE_HIERARCHY: Record<AccountRole, number>;
|
|
13
|
+
/** Top-level account that owns one or more stores. */
|
|
14
|
+
interface Account {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
type: AccountType;
|
|
18
|
+
isActive: boolean;
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
updatedAt: Date;
|
|
21
|
+
}
|
|
22
|
+
/** A store linked to an account (shopDomain is globally unique). */
|
|
23
|
+
interface AccountStore {
|
|
24
|
+
id: string;
|
|
25
|
+
accountId: string;
|
|
26
|
+
shopDomain: string;
|
|
27
|
+
storeName: string;
|
|
28
|
+
region: string | null;
|
|
29
|
+
currency: string | null;
|
|
30
|
+
locale: string | null;
|
|
31
|
+
timezone: string | null;
|
|
32
|
+
storeSettings: Record<string, unknown>;
|
|
33
|
+
isActive: boolean;
|
|
34
|
+
isPrimary: boolean;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
}
|
|
38
|
+
/** A member belonging to an account with role-based store access. */
|
|
39
|
+
interface AccountMember {
|
|
40
|
+
id: string;
|
|
41
|
+
accountId: string;
|
|
42
|
+
userEmail: string;
|
|
43
|
+
role: AccountRole;
|
|
44
|
+
allStoresAccess: boolean;
|
|
45
|
+
allowedStoreIds: string[];
|
|
46
|
+
permissions: string[];
|
|
47
|
+
createdAt: Date;
|
|
48
|
+
updatedAt: Date;
|
|
49
|
+
}
|
|
50
|
+
/** Request-scoped context for multi-store operations. */
|
|
51
|
+
interface AccountContext {
|
|
52
|
+
account: Account;
|
|
53
|
+
currentStore: AccountStore;
|
|
54
|
+
member: AccountMember | null;
|
|
55
|
+
stores: AccountStore[];
|
|
56
|
+
}
|
|
57
|
+
/** Input for creating a new account. */
|
|
58
|
+
interface CreateAccountInput {
|
|
59
|
+
name: string;
|
|
60
|
+
type: AccountType;
|
|
61
|
+
}
|
|
62
|
+
/** Input for updating an existing account. */
|
|
63
|
+
interface UpdateAccountInput {
|
|
64
|
+
name?: string;
|
|
65
|
+
type?: AccountType;
|
|
66
|
+
isActive?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/** Input for adding a store to an account. */
|
|
69
|
+
interface AddStoreInput {
|
|
70
|
+
accountId: string;
|
|
71
|
+
shopDomain: string;
|
|
72
|
+
storeName: string;
|
|
73
|
+
region?: string;
|
|
74
|
+
currency?: string;
|
|
75
|
+
locale?: string;
|
|
76
|
+
timezone?: string;
|
|
77
|
+
storeSettings?: Record<string, unknown>;
|
|
78
|
+
isPrimary?: boolean;
|
|
79
|
+
}
|
|
80
|
+
/** Input for updating an existing account store. */
|
|
81
|
+
interface UpdateStoreInput {
|
|
82
|
+
storeName?: string;
|
|
83
|
+
region?: string;
|
|
84
|
+
currency?: string;
|
|
85
|
+
locale?: string;
|
|
86
|
+
timezone?: string;
|
|
87
|
+
storeSettings?: Record<string, unknown>;
|
|
88
|
+
isActive?: boolean;
|
|
89
|
+
isPrimary?: boolean;
|
|
90
|
+
}
|
|
91
|
+
/** Input for adding a member to an account. */
|
|
92
|
+
interface AddMemberInput {
|
|
93
|
+
accountId: string;
|
|
94
|
+
userEmail: string;
|
|
95
|
+
role: AccountRole;
|
|
96
|
+
allStoresAccess?: boolean;
|
|
97
|
+
allowedStoreIds?: string[];
|
|
98
|
+
permissions?: string[];
|
|
99
|
+
}
|
|
100
|
+
/** Input for updating an existing account member. */
|
|
101
|
+
interface UpdateMemberInput {
|
|
102
|
+
role?: AccountRole;
|
|
103
|
+
allStoresAccess?: boolean;
|
|
104
|
+
allowedStoreIds?: string[];
|
|
105
|
+
permissions?: string[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* AccountService interface for multi-store account management.
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/** Service for managing accounts, stores, and members. */
|
|
113
|
+
interface AccountService {
|
|
114
|
+
createAccount(input: CreateAccountInput): Promise<Account>;
|
|
115
|
+
getAccount(accountId: string): Promise<Account | null>;
|
|
116
|
+
updateAccount(accountId: string, input: UpdateAccountInput): Promise<Account>;
|
|
117
|
+
deleteAccount(accountId: string): Promise<void>;
|
|
118
|
+
addStore(input: AddStoreInput): Promise<AccountStore>;
|
|
119
|
+
getStore(storeId: string): Promise<AccountStore | null>;
|
|
120
|
+
getStoreByDomain(shopDomain: string): Promise<AccountStore | null>;
|
|
121
|
+
listStores(accountId: string): Promise<AccountStore[]>;
|
|
122
|
+
updateStore(storeId: string, input: UpdateStoreInput): Promise<AccountStore>;
|
|
123
|
+
removeStore(storeId: string): Promise<void>;
|
|
124
|
+
addMember(input: AddMemberInput): Promise<AccountMember>;
|
|
125
|
+
getMember(memberId: string): Promise<AccountMember | null>;
|
|
126
|
+
getMemberByEmail(accountId: string, userEmail: string): Promise<AccountMember | null>;
|
|
127
|
+
listMembers(accountId: string): Promise<AccountMember[]>;
|
|
128
|
+
updateMember(memberId: string, input: UpdateMemberInput): Promise<AccountMember>;
|
|
129
|
+
removeMember(memberId: string): Promise<void>;
|
|
130
|
+
canAccessStore(accountId: string, userEmail: string, storeId: string): Promise<boolean>;
|
|
131
|
+
isRoleAtLeast(accountId: string, userEmail: string, minimumRole: AccountRole): Promise<boolean>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Shared settings types and service interface for multi-store accounts.
|
|
136
|
+
*
|
|
137
|
+
* Settings cascade: store override > account shared > default value.
|
|
138
|
+
*/
|
|
139
|
+
/** A shared setting scoped to an account, optionally limited to specific stores. */
|
|
140
|
+
interface AccountSharedSetting {
|
|
141
|
+
id: string;
|
|
142
|
+
accountId: string;
|
|
143
|
+
settingKey: string;
|
|
144
|
+
settingValue: unknown;
|
|
145
|
+
/** Store IDs this setting applies to. Null means all stores. */
|
|
146
|
+
appliesToStores: string[] | null;
|
|
147
|
+
createdAt: Date;
|
|
148
|
+
updatedAt: Date;
|
|
149
|
+
}
|
|
150
|
+
/** Input for creating or updating a shared setting. */
|
|
151
|
+
interface SetSharedSettingInput {
|
|
152
|
+
accountId: string;
|
|
153
|
+
settingKey: string;
|
|
154
|
+
settingValue: unknown;
|
|
155
|
+
appliesToStores?: string[] | null;
|
|
156
|
+
}
|
|
157
|
+
/** Service for managing account-level shared settings with cascade resolution. */
|
|
158
|
+
interface SharedSettingsService {
|
|
159
|
+
/** Set a shared setting (creates or updates). */
|
|
160
|
+
set(input: SetSharedSettingInput): Promise<AccountSharedSetting>;
|
|
161
|
+
/** Get a single shared setting by key. */
|
|
162
|
+
get(accountId: string, settingKey: string): Promise<AccountSharedSetting | null>;
|
|
163
|
+
/** List all shared settings for an account. */
|
|
164
|
+
list(accountId: string): Promise<AccountSharedSetting[]>;
|
|
165
|
+
/** Delete a shared setting. */
|
|
166
|
+
delete(accountId: string, settingKey: string): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Resolve the effective value for a setting key using cascade logic:
|
|
169
|
+
* 1. Store-specific override (AccountStore.storeSettings[key])
|
|
170
|
+
* 2. Account shared setting (where appliesToStores includes storeId or is null)
|
|
171
|
+
* 3. Default value parameter
|
|
172
|
+
*/
|
|
173
|
+
resolve<T = unknown>(accountId: string, storeId: string, settingKey: string, defaultValue: T): Promise<T>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* AccountMiddleware interface for extracting multi-store context from requests.
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
/** Middleware for extracting and validating account context. */
|
|
181
|
+
interface AccountMiddleware {
|
|
182
|
+
/**
|
|
183
|
+
* Extract AccountContext from a shop domain.
|
|
184
|
+
* Returns null if the shop is not linked to any account.
|
|
185
|
+
*/
|
|
186
|
+
getAccountContext(shopDomain: string, userEmail?: string): Promise<AccountContext | null>;
|
|
187
|
+
/**
|
|
188
|
+
* Validate that a user can access a specific store within their account.
|
|
189
|
+
* Returns true if access is allowed.
|
|
190
|
+
*/
|
|
191
|
+
validateStoreAccess(accountId: string, userEmail: string, storeId: string): Promise<boolean>;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Account pricing types and constants for multi-store enterprise billing.
|
|
196
|
+
*
|
|
197
|
+
* Pure interface definitions — no billing dependency required.
|
|
198
|
+
*/
|
|
199
|
+
/** A pricing tier that defines cost per store for a range of store counts. */
|
|
200
|
+
interface AccountPricingTier {
|
|
201
|
+
/** Minimum number of stores for this tier (inclusive). */
|
|
202
|
+
minStores: number;
|
|
203
|
+
/** Maximum number of stores for this tier (inclusive, null = unlimited). */
|
|
204
|
+
maxStores: number | null;
|
|
205
|
+
/** Cost per store per month in this tier. */
|
|
206
|
+
pricePerStore: number;
|
|
207
|
+
}
|
|
208
|
+
/** Result of an account pricing calculation. */
|
|
209
|
+
interface AccountPricingResult {
|
|
210
|
+
/** Base monthly price (includes some stores). */
|
|
211
|
+
basePrice: number;
|
|
212
|
+
/** Number of stores included in the base price. */
|
|
213
|
+
includedStores: number;
|
|
214
|
+
/** Additional cost for stores beyond included count. */
|
|
215
|
+
additionalStoreCost: number;
|
|
216
|
+
/** Total monthly price. */
|
|
217
|
+
totalMonthlyPrice: number;
|
|
218
|
+
/** Breakdown by tier for transparency. */
|
|
219
|
+
tierBreakdown: Array<{
|
|
220
|
+
tier: AccountPricingTier;
|
|
221
|
+
storeCount: number;
|
|
222
|
+
cost: number;
|
|
223
|
+
}>;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Interface-only billing service for enterprise accounts.
|
|
227
|
+
* Implementation deferred until billing is merged to develop.
|
|
228
|
+
*/
|
|
229
|
+
interface AccountBillingService {
|
|
230
|
+
/** Calculate pricing for an account given the number of stores. */
|
|
231
|
+
calculatePricing(storeCount: number): AccountPricingResult;
|
|
232
|
+
/** Get the current pricing tiers. */
|
|
233
|
+
getPricingTiers(): AccountPricingTier[];
|
|
234
|
+
}
|
|
235
|
+
/** Default pricing tiers for enterprise accounts. */
|
|
236
|
+
declare const DEFAULT_PRICING_TIERS: AccountPricingTier[];
|
|
237
|
+
/** Default base price that includes up to 3 stores. */
|
|
238
|
+
declare const DEFAULT_BASE_PRICE = 99;
|
|
239
|
+
/** Number of stores included in the base price. */
|
|
240
|
+
declare const DEFAULT_INCLUDED_STORES = 3;
|
|
241
|
+
|
|
242
|
+
export { ACCOUNT_ROLE_HIERARCHY, type Account, type AccountBillingService, type AccountContext, type AccountMember, type AccountMiddleware, type AccountPricingResult, type AccountPricingTier, type AccountRole, type AccountService, type AccountSharedSetting, type AccountStore, type AccountType, type AddMemberInput, type AddStoreInput, type CreateAccountInput, DEFAULT_BASE_PRICE, DEFAULT_INCLUDED_STORES, DEFAULT_PRICING_TIERS, type SetSharedSettingInput, type SharedSettingsService, type UpdateAccountInput, type UpdateMemberInput, type UpdateStoreInput };
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
ACCOUNT_ROLE_HIERARCHY: () => ACCOUNT_ROLE_HIERARCHY,
|
|
24
|
+
DEFAULT_BASE_PRICE: () => DEFAULT_BASE_PRICE,
|
|
25
|
+
DEFAULT_INCLUDED_STORES: () => DEFAULT_INCLUDED_STORES,
|
|
26
|
+
DEFAULT_PRICING_TIERS: () => DEFAULT_PRICING_TIERS
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(multi_store_exports);
|
|
29
|
+
|
|
30
|
+
// src/multi-store/types.ts
|
|
31
|
+
var ACCOUNT_ROLE_HIERARCHY = {
|
|
32
|
+
owner: 4,
|
|
33
|
+
admin: 3,
|
|
34
|
+
member: 2,
|
|
35
|
+
viewer: 1
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/multi-store/pricing.ts
|
|
39
|
+
var DEFAULT_PRICING_TIERS = [
|
|
40
|
+
{ minStores: 1, maxStores: 3, pricePerStore: 0 },
|
|
41
|
+
{ minStores: 4, maxStores: 10, pricePerStore: 29 },
|
|
42
|
+
{ minStores: 11, maxStores: null, pricePerStore: 19 }
|
|
43
|
+
];
|
|
44
|
+
var DEFAULT_BASE_PRICE = 99;
|
|
45
|
+
var DEFAULT_INCLUDED_STORES = 3;
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
ACCOUNT_ROLE_HIERARCHY,
|
|
49
|
+
DEFAULT_BASE_PRICE,
|
|
50
|
+
DEFAULT_INCLUDED_STORES,
|
|
51
|
+
DEFAULT_PRICING_TIERS
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/multi-store/index.ts","../../src/multi-store/types.ts","../../src/multi-store/pricing.ts"],"sourcesContent":["/**\n * @uniforge/platform-core - Multi-Store\n *\n * Enterprise multi-store management interfaces.\n */\n\nexport type {\n AccountType,\n AccountRole,\n Account,\n AccountStore,\n AccountMember,\n AccountContext,\n CreateAccountInput,\n UpdateAccountInput,\n AddStoreInput,\n UpdateStoreInput,\n AddMemberInput,\n UpdateMemberInput,\n} from './types';\nexport { ACCOUNT_ROLE_HIERARCHY } from './types';\n\nexport type { AccountService } from './service';\n\nexport type {\n AccountSharedSetting,\n SetSharedSettingInput,\n SharedSettingsService,\n} from './shared-settings';\n\nexport type { AccountMiddleware } from './middleware';\n\nexport type {\n AccountPricingTier,\n AccountPricingResult,\n AccountBillingService,\n} from './pricing';\nexport {\n DEFAULT_PRICING_TIERS,\n DEFAULT_BASE_PRICE,\n DEFAULT_INCLUDED_STORES,\n} from './pricing';\n","/**\n * Multi-store enterprise types.\n *\n * Defines the Account hierarchy above Shop for enterprise merchants\n * managing multiple Shopify stores under a single account.\n */\n\n/** Account type — individual has one store, enterprise has many. */\nexport type AccountType = 'individual' | 'enterprise';\n\n/** Account-level roles with hierarchy: owner > admin > member > viewer. */\nexport type AccountRole = 'owner' | 'admin' | 'member' | 'viewer';\n\n/** Role hierarchy for permission comparison (higher = more access). */\nexport const ACCOUNT_ROLE_HIERARCHY: Record<AccountRole, number> = {\n owner: 4,\n admin: 3,\n member: 2,\n viewer: 1,\n};\n\n/** Top-level account that owns one or more stores. */\nexport interface Account {\n id: string;\n name: string;\n type: AccountType;\n isActive: boolean;\n createdAt: Date;\n updatedAt: Date;\n}\n\n/** A store linked to an account (shopDomain is globally unique). */\nexport interface AccountStore {\n id: string;\n accountId: string;\n shopDomain: string;\n storeName: string;\n region: string | null;\n currency: string | null;\n locale: string | null;\n timezone: string | null;\n storeSettings: Record<string, unknown>;\n isActive: boolean;\n isPrimary: boolean;\n createdAt: Date;\n updatedAt: Date;\n}\n\n/** A member belonging to an account with role-based store access. */\nexport interface AccountMember {\n id: string;\n accountId: string;\n userEmail: string;\n role: AccountRole;\n allStoresAccess: boolean;\n allowedStoreIds: string[];\n permissions: string[];\n createdAt: Date;\n updatedAt: Date;\n}\n\n/** Request-scoped context for multi-store operations. */\nexport interface AccountContext {\n account: Account;\n currentStore: AccountStore;\n member: AccountMember | null;\n stores: AccountStore[];\n}\n\n/** Input for creating a new account. */\nexport interface CreateAccountInput {\n name: string;\n type: AccountType;\n}\n\n/** Input for updating an existing account. */\nexport interface UpdateAccountInput {\n name?: string;\n type?: AccountType;\n isActive?: boolean;\n}\n\n/** Input for adding a store to an account. */\nexport interface AddStoreInput {\n accountId: string;\n shopDomain: string;\n storeName: string;\n region?: string;\n currency?: string;\n locale?: string;\n timezone?: string;\n storeSettings?: Record<string, unknown>;\n isPrimary?: boolean;\n}\n\n/** Input for updating an existing account store. */\nexport interface UpdateStoreInput {\n storeName?: string;\n region?: string;\n currency?: string;\n locale?: string;\n timezone?: string;\n storeSettings?: Record<string, unknown>;\n isActive?: boolean;\n isPrimary?: boolean;\n}\n\n/** Input for adding a member to an account. */\nexport interface AddMemberInput {\n accountId: string;\n userEmail: string;\n role: AccountRole;\n allStoresAccess?: boolean;\n allowedStoreIds?: string[];\n permissions?: string[];\n}\n\n/** Input for updating an existing account member. */\nexport interface UpdateMemberInput {\n role?: AccountRole;\n allStoresAccess?: boolean;\n allowedStoreIds?: string[];\n permissions?: string[];\n}\n","/**\n * Account pricing types and constants for multi-store enterprise billing.\n *\n * Pure interface definitions — no billing dependency required.\n */\n\n/** A pricing tier that defines cost per store for a range of store counts. */\nexport interface AccountPricingTier {\n /** Minimum number of stores for this tier (inclusive). */\n minStores: number;\n /** Maximum number of stores for this tier (inclusive, null = unlimited). */\n maxStores: number | null;\n /** Cost per store per month in this tier. */\n pricePerStore: number;\n}\n\n/** Result of an account pricing calculation. */\nexport interface AccountPricingResult {\n /** Base monthly price (includes some stores). */\n basePrice: number;\n /** Number of stores included in the base price. */\n includedStores: number;\n /** Additional cost for stores beyond included count. */\n additionalStoreCost: number;\n /** Total monthly price. */\n totalMonthlyPrice: number;\n /** Breakdown by tier for transparency. */\n tierBreakdown: Array<{\n tier: AccountPricingTier;\n storeCount: number;\n cost: number;\n }>;\n}\n\n/**\n * Interface-only billing service for enterprise accounts.\n * Implementation deferred until billing is merged to develop.\n */\nexport interface AccountBillingService {\n /** Calculate pricing for an account given the number of stores. */\n calculatePricing(storeCount: number): AccountPricingResult;\n\n /** Get the current pricing tiers. */\n getPricingTiers(): AccountPricingTier[];\n}\n\n/** Default pricing tiers for enterprise accounts. */\nexport const DEFAULT_PRICING_TIERS: AccountPricingTier[] = [\n { minStores: 1, maxStores: 3, pricePerStore: 0 },\n { minStores: 4, maxStores: 10, pricePerStore: 29 },\n { minStores: 11, maxStores: null, pricePerStore: 19 },\n];\n\n/** Default base price that includes up to 3 stores. */\nexport const DEFAULT_BASE_PRICE = 99;\n\n/** Number of stores included in the base price. */\nexport const DEFAULT_INCLUDED_STORES = 3;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,IAAM,yBAAsD;AAAA,EACjE,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AACV;;;AC4BO,IAAM,wBAA8C;AAAA,EACzD,EAAE,WAAW,GAAG,WAAW,GAAG,eAAe,EAAE;AAAA,EAC/C,EAAE,WAAW,GAAG,WAAW,IAAI,eAAe,GAAG;AAAA,EACjD,EAAE,WAAW,IAAI,WAAW,MAAM,eAAe,GAAG;AACtD;AAGO,IAAM,qBAAqB;AAG3B,IAAM,0BAA0B;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/multi-store/types.ts
|
|
2
|
+
var ACCOUNT_ROLE_HIERARCHY = {
|
|
3
|
+
owner: 4,
|
|
4
|
+
admin: 3,
|
|
5
|
+
member: 2,
|
|
6
|
+
viewer: 1
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
// src/multi-store/pricing.ts
|
|
10
|
+
var DEFAULT_PRICING_TIERS = [
|
|
11
|
+
{ minStores: 1, maxStores: 3, pricePerStore: 0 },
|
|
12
|
+
{ minStores: 4, maxStores: 10, pricePerStore: 29 },
|
|
13
|
+
{ minStores: 11, maxStores: null, pricePerStore: 19 }
|
|
14
|
+
];
|
|
15
|
+
var DEFAULT_BASE_PRICE = 99;
|
|
16
|
+
var DEFAULT_INCLUDED_STORES = 3;
|
|
17
|
+
export {
|
|
18
|
+
ACCOUNT_ROLE_HIERARCHY,
|
|
19
|
+
DEFAULT_BASE_PRICE,
|
|
20
|
+
DEFAULT_INCLUDED_STORES,
|
|
21
|
+
DEFAULT_PRICING_TIERS
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/multi-store/types.ts","../../src/multi-store/pricing.ts"],"sourcesContent":["/**\n * Multi-store enterprise types.\n *\n * Defines the Account hierarchy above Shop for enterprise merchants\n * managing multiple Shopify stores under a single account.\n */\n\n/** Account type — individual has one store, enterprise has many. */\nexport type AccountType = 'individual' | 'enterprise';\n\n/** Account-level roles with hierarchy: owner > admin > member > viewer. */\nexport type AccountRole = 'owner' | 'admin' | 'member' | 'viewer';\n\n/** Role hierarchy for permission comparison (higher = more access). */\nexport const ACCOUNT_ROLE_HIERARCHY: Record<AccountRole, number> = {\n owner: 4,\n admin: 3,\n member: 2,\n viewer: 1,\n};\n\n/** Top-level account that owns one or more stores. */\nexport interface Account {\n id: string;\n name: string;\n type: AccountType;\n isActive: boolean;\n createdAt: Date;\n updatedAt: Date;\n}\n\n/** A store linked to an account (shopDomain is globally unique). */\nexport interface AccountStore {\n id: string;\n accountId: string;\n shopDomain: string;\n storeName: string;\n region: string | null;\n currency: string | null;\n locale: string | null;\n timezone: string | null;\n storeSettings: Record<string, unknown>;\n isActive: boolean;\n isPrimary: boolean;\n createdAt: Date;\n updatedAt: Date;\n}\n\n/** A member belonging to an account with role-based store access. */\nexport interface AccountMember {\n id: string;\n accountId: string;\n userEmail: string;\n role: AccountRole;\n allStoresAccess: boolean;\n allowedStoreIds: string[];\n permissions: string[];\n createdAt: Date;\n updatedAt: Date;\n}\n\n/** Request-scoped context for multi-store operations. */\nexport interface AccountContext {\n account: Account;\n currentStore: AccountStore;\n member: AccountMember | null;\n stores: AccountStore[];\n}\n\n/** Input for creating a new account. */\nexport interface CreateAccountInput {\n name: string;\n type: AccountType;\n}\n\n/** Input for updating an existing account. */\nexport interface UpdateAccountInput {\n name?: string;\n type?: AccountType;\n isActive?: boolean;\n}\n\n/** Input for adding a store to an account. */\nexport interface AddStoreInput {\n accountId: string;\n shopDomain: string;\n storeName: string;\n region?: string;\n currency?: string;\n locale?: string;\n timezone?: string;\n storeSettings?: Record<string, unknown>;\n isPrimary?: boolean;\n}\n\n/** Input for updating an existing account store. */\nexport interface UpdateStoreInput {\n storeName?: string;\n region?: string;\n currency?: string;\n locale?: string;\n timezone?: string;\n storeSettings?: Record<string, unknown>;\n isActive?: boolean;\n isPrimary?: boolean;\n}\n\n/** Input for adding a member to an account. */\nexport interface AddMemberInput {\n accountId: string;\n userEmail: string;\n role: AccountRole;\n allStoresAccess?: boolean;\n allowedStoreIds?: string[];\n permissions?: string[];\n}\n\n/** Input for updating an existing account member. */\nexport interface UpdateMemberInput {\n role?: AccountRole;\n allStoresAccess?: boolean;\n allowedStoreIds?: string[];\n permissions?: string[];\n}\n","/**\n * Account pricing types and constants for multi-store enterprise billing.\n *\n * Pure interface definitions — no billing dependency required.\n */\n\n/** A pricing tier that defines cost per store for a range of store counts. */\nexport interface AccountPricingTier {\n /** Minimum number of stores for this tier (inclusive). */\n minStores: number;\n /** Maximum number of stores for this tier (inclusive, null = unlimited). */\n maxStores: number | null;\n /** Cost per store per month in this tier. */\n pricePerStore: number;\n}\n\n/** Result of an account pricing calculation. */\nexport interface AccountPricingResult {\n /** Base monthly price (includes some stores). */\n basePrice: number;\n /** Number of stores included in the base price. */\n includedStores: number;\n /** Additional cost for stores beyond included count. */\n additionalStoreCost: number;\n /** Total monthly price. */\n totalMonthlyPrice: number;\n /** Breakdown by tier for transparency. */\n tierBreakdown: Array<{\n tier: AccountPricingTier;\n storeCount: number;\n cost: number;\n }>;\n}\n\n/**\n * Interface-only billing service for enterprise accounts.\n * Implementation deferred until billing is merged to develop.\n */\nexport interface AccountBillingService {\n /** Calculate pricing for an account given the number of stores. */\n calculatePricing(storeCount: number): AccountPricingResult;\n\n /** Get the current pricing tiers. */\n getPricingTiers(): AccountPricingTier[];\n}\n\n/** Default pricing tiers for enterprise accounts. */\nexport const DEFAULT_PRICING_TIERS: AccountPricingTier[] = [\n { minStores: 1, maxStores: 3, pricePerStore: 0 },\n { minStores: 4, maxStores: 10, pricePerStore: 29 },\n { minStores: 11, maxStores: null, pricePerStore: 19 },\n];\n\n/** Default base price that includes up to 3 stores. */\nexport const DEFAULT_BASE_PRICE = 99;\n\n/** Number of stores included in the base price. */\nexport const DEFAULT_INCLUDED_STORES = 3;\n"],"mappings":";AAcO,IAAM,yBAAsD;AAAA,EACjE,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AACV;;;AC4BO,IAAM,wBAA8C;AAAA,EACzD,EAAE,WAAW,GAAG,WAAW,GAAG,eAAe,EAAE;AAAA,EAC/C,EAAE,WAAW,GAAG,WAAW,IAAI,eAAe,GAAG;AAAA,EACjD,EAAE,WAAW,IAAI,WAAW,MAAM,eAAe,GAAG;AACtD;AAGO,IAAM,qBAAqB;AAG3B,IAAM,0BAA0B;","names":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { S as Session, a as ShopContext } from '../types-CgnJiK8Z.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Multi-tenant context and middleware interfaces.
|
|
5
|
+
*
|
|
6
|
+
* These types define the tenant isolation model used across all platform adapters.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Request-scoped tenant context extracted from an authenticated session. */
|
|
10
|
+
interface TenantContext {
|
|
11
|
+
readonly shopDomain: string;
|
|
12
|
+
readonly session: Session;
|
|
13
|
+
readonly shopContext: ShopContext;
|
|
14
|
+
}
|
|
15
|
+
/** Extracts tenant context from an authenticated request. */
|
|
16
|
+
interface TenantExtractor {
|
|
17
|
+
extract(session: Session, shopContext: ShopContext): TenantContext;
|
|
18
|
+
}
|
|
19
|
+
/** Configuration for tenant isolation middleware. */
|
|
20
|
+
interface TenantMiddlewareConfig {
|
|
21
|
+
/** Whether to enforce tenant isolation on all queries. */
|
|
22
|
+
enforceIsolation?: boolean;
|
|
23
|
+
/** Custom tenant extractor. Defaults to extracting from auth session. */
|
|
24
|
+
extractor?: TenantExtractor;
|
|
25
|
+
}
|
|
26
|
+
/** Multi-tenant middleware that ensures tenant isolation per request. */
|
|
27
|
+
interface TenantMiddleware {
|
|
28
|
+
/** Extract tenant context from an authenticated session. */
|
|
29
|
+
getTenantContext(session: Session, shopContext: ShopContext): TenantContext;
|
|
30
|
+
/** Validate that a shop domain matches the current tenant. */
|
|
31
|
+
validateTenant(tenantContext: TenantContext, shopDomain: string): boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Query scoping interfaces for multi-tenant data access.
|
|
36
|
+
*
|
|
37
|
+
* These types define how database queries are automatically
|
|
38
|
+
* scoped to the current tenant to prevent cross-tenant data access.
|
|
39
|
+
*/
|
|
40
|
+
/** Options for applying tenant scope to a query. */
|
|
41
|
+
interface QueryScopeOptions {
|
|
42
|
+
/** The shop domain to scope queries to. */
|
|
43
|
+
shopDomain: string;
|
|
44
|
+
/** Whether to throw on cross-tenant access attempts. */
|
|
45
|
+
throwOnViolation?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** A query that has been scoped to a specific tenant. */
|
|
48
|
+
interface ScopedQuery<T = Record<string, unknown>> {
|
|
49
|
+
/** The original query with tenant filter applied. */
|
|
50
|
+
where: T & {
|
|
51
|
+
shopDomain: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Filter applied to scope queries to a tenant. */
|
|
55
|
+
interface QueryScopeFilter {
|
|
56
|
+
/** Apply tenant scoping to a where clause. */
|
|
57
|
+
applyScope<T extends Record<string, unknown>>(where: T, options: QueryScopeOptions): ScopedQuery<T>;
|
|
58
|
+
/** Validate that a record belongs to the expected tenant. */
|
|
59
|
+
validateOwnership(record: {
|
|
60
|
+
shopDomain: string;
|
|
61
|
+
}, expectedShopDomain: string): boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type { QueryScopeFilter, QueryScopeOptions, ScopedQuery, TenantContext, TenantExtractor, TenantMiddleware, TenantMiddlewareConfig };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { S as Session, a as ShopContext } from '../types-CgnJiK8Z.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Multi-tenant context and middleware interfaces.
|
|
5
|
+
*
|
|
6
|
+
* These types define the tenant isolation model used across all platform adapters.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Request-scoped tenant context extracted from an authenticated session. */
|
|
10
|
+
interface TenantContext {
|
|
11
|
+
readonly shopDomain: string;
|
|
12
|
+
readonly session: Session;
|
|
13
|
+
readonly shopContext: ShopContext;
|
|
14
|
+
}
|
|
15
|
+
/** Extracts tenant context from an authenticated request. */
|
|
16
|
+
interface TenantExtractor {
|
|
17
|
+
extract(session: Session, shopContext: ShopContext): TenantContext;
|
|
18
|
+
}
|
|
19
|
+
/** Configuration for tenant isolation middleware. */
|
|
20
|
+
interface TenantMiddlewareConfig {
|
|
21
|
+
/** Whether to enforce tenant isolation on all queries. */
|
|
22
|
+
enforceIsolation?: boolean;
|
|
23
|
+
/** Custom tenant extractor. Defaults to extracting from auth session. */
|
|
24
|
+
extractor?: TenantExtractor;
|
|
25
|
+
}
|
|
26
|
+
/** Multi-tenant middleware that ensures tenant isolation per request. */
|
|
27
|
+
interface TenantMiddleware {
|
|
28
|
+
/** Extract tenant context from an authenticated session. */
|
|
29
|
+
getTenantContext(session: Session, shopContext: ShopContext): TenantContext;
|
|
30
|
+
/** Validate that a shop domain matches the current tenant. */
|
|
31
|
+
validateTenant(tenantContext: TenantContext, shopDomain: string): boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Query scoping interfaces for multi-tenant data access.
|
|
36
|
+
*
|
|
37
|
+
* These types define how database queries are automatically
|
|
38
|
+
* scoped to the current tenant to prevent cross-tenant data access.
|
|
39
|
+
*/
|
|
40
|
+
/** Options for applying tenant scope to a query. */
|
|
41
|
+
interface QueryScopeOptions {
|
|
42
|
+
/** The shop domain to scope queries to. */
|
|
43
|
+
shopDomain: string;
|
|
44
|
+
/** Whether to throw on cross-tenant access attempts. */
|
|
45
|
+
throwOnViolation?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** A query that has been scoped to a specific tenant. */
|
|
48
|
+
interface ScopedQuery<T = Record<string, unknown>> {
|
|
49
|
+
/** The original query with tenant filter applied. */
|
|
50
|
+
where: T & {
|
|
51
|
+
shopDomain: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Filter applied to scope queries to a tenant. */
|
|
55
|
+
interface QueryScopeFilter {
|
|
56
|
+
/** Apply tenant scoping to a where clause. */
|
|
57
|
+
applyScope<T extends Record<string, unknown>>(where: T, options: QueryScopeOptions): ScopedQuery<T>;
|
|
58
|
+
/** Validate that a record belongs to the expected tenant. */
|
|
59
|
+
validateOwnership(record: {
|
|
60
|
+
shopDomain: string;
|
|
61
|
+
}, expectedShopDomain: string): boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type { QueryScopeFilter, QueryScopeOptions, ScopedQuery, TenantContext, TenantExtractor, TenantMiddleware, TenantMiddlewareConfig };
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/multi-tenant/index.ts
|
|
17
|
+
var multi_tenant_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(multi_tenant_exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/multi-tenant/index.ts"],"sourcesContent":["/**\n * @uniforge/platform-core - Multi-Tenant\n *\n * Platform-agnostic multi-tenant interfaces and types.\n */\n\nexport type {\n TenantContext,\n TenantExtractor,\n TenantMiddleware,\n TenantMiddlewareConfig,\n} from './types';\n\nexport type {\n QueryScopeOptions,\n ScopedQuery,\n QueryScopeFilter,\n} from './query-scoping';\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance types and configuration interfaces.
|
|
3
|
+
*/
|
|
4
|
+
interface CacheManagerConfig {
|
|
5
|
+
defaultTTL: number;
|
|
6
|
+
maxEntries: number;
|
|
7
|
+
keyPrefix?: string;
|
|
8
|
+
strategies?: CacheTTLStrategy[];
|
|
9
|
+
}
|
|
10
|
+
interface CacheTTLStrategy {
|
|
11
|
+
pattern: string;
|
|
12
|
+
ttl: number;
|
|
13
|
+
}
|
|
14
|
+
interface CacheEntry<T = unknown> {
|
|
15
|
+
key: string;
|
|
16
|
+
value: T;
|
|
17
|
+
createdAt: number;
|
|
18
|
+
expiresAt: number;
|
|
19
|
+
hits: number;
|
|
20
|
+
}
|
|
21
|
+
interface CacheMetrics {
|
|
22
|
+
hits: number;
|
|
23
|
+
misses: number;
|
|
24
|
+
hitRate: number;
|
|
25
|
+
totalEntries: number;
|
|
26
|
+
evictions: number;
|
|
27
|
+
}
|
|
28
|
+
interface QueryCostConfig {
|
|
29
|
+
maxCostPerSecond: number;
|
|
30
|
+
trackingWindowMs: number;
|
|
31
|
+
alertThreshold?: number;
|
|
32
|
+
}
|
|
33
|
+
interface QueryCostEntry {
|
|
34
|
+
query: string;
|
|
35
|
+
actualCost: number;
|
|
36
|
+
requestedCost: number;
|
|
37
|
+
timestamp: number;
|
|
38
|
+
}
|
|
39
|
+
interface QueryCostReport {
|
|
40
|
+
totalCost: number;
|
|
41
|
+
averageCost: number;
|
|
42
|
+
maxCost: number;
|
|
43
|
+
queryCount: number;
|
|
44
|
+
costPerSecond: number;
|
|
45
|
+
topQueries: QueryCostEntry[];
|
|
46
|
+
isOverBudget: boolean;
|
|
47
|
+
}
|
|
48
|
+
interface BatchConfig {
|
|
49
|
+
maxBatchSize: number;
|
|
50
|
+
delayMs: number;
|
|
51
|
+
maxDelayMs?: number;
|
|
52
|
+
}
|
|
53
|
+
interface BatchResult<T = unknown> {
|
|
54
|
+
results: T[];
|
|
55
|
+
batchSize: number;
|
|
56
|
+
executionTimeMs: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Cache manager interface.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
interface CacheManager {
|
|
64
|
+
readonly config: CacheManagerConfig;
|
|
65
|
+
/** Get a cached value by key */
|
|
66
|
+
get<T = unknown>(key: string): Promise<CacheEntry<T> | undefined>;
|
|
67
|
+
/** Set a cached value with optional TTL override */
|
|
68
|
+
set<T = unknown>(key: string, value: T, ttl?: number): Promise<void>;
|
|
69
|
+
/** Delete a cached entry */
|
|
70
|
+
delete(key: string): Promise<boolean>;
|
|
71
|
+
/** Invalidate entries matching a pattern */
|
|
72
|
+
invalidate(pattern: string): Promise<number>;
|
|
73
|
+
/** Check if a key exists in cache */
|
|
74
|
+
has(key: string): Promise<boolean>;
|
|
75
|
+
/** Warm cache with pre-computed entries */
|
|
76
|
+
warm(entries: Array<{
|
|
77
|
+
key: string;
|
|
78
|
+
value: unknown;
|
|
79
|
+
ttl?: number;
|
|
80
|
+
}>): Promise<void>;
|
|
81
|
+
/** Get cache performance metrics */
|
|
82
|
+
getMetrics(): CacheMetrics;
|
|
83
|
+
/** Reset all metrics counters */
|
|
84
|
+
resetMetrics(): void;
|
|
85
|
+
/** Clear all cached entries */
|
|
86
|
+
clear(): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Query cost tracking and batching interfaces.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/** Tracks GraphQL query costs to prevent throttling */
|
|
94
|
+
interface QueryCostTracker {
|
|
95
|
+
readonly config: QueryCostConfig;
|
|
96
|
+
/** Record a query's cost */
|
|
97
|
+
track(query: string, actualCost: number, requestedCost: number): void;
|
|
98
|
+
/** Get a report of recent query costs */
|
|
99
|
+
getReport(): QueryCostReport;
|
|
100
|
+
/** Check if current usage is within budget */
|
|
101
|
+
isWithinBudget(): boolean;
|
|
102
|
+
/** Get current cost per second */
|
|
103
|
+
getCostPerSecond(): number;
|
|
104
|
+
/** Reset tracking data */
|
|
105
|
+
reset(): void;
|
|
106
|
+
}
|
|
107
|
+
/** Batches multiple queries into single requests */
|
|
108
|
+
interface QueryBatcher<TQuery = string, TResult = unknown> {
|
|
109
|
+
readonly config: BatchConfig;
|
|
110
|
+
/** Add a query to the current batch */
|
|
111
|
+
add(query: TQuery): Promise<TResult>;
|
|
112
|
+
/** Flush the current batch immediately */
|
|
113
|
+
flush(): Promise<BatchResult<TResult>>;
|
|
114
|
+
/** Get the number of pending queries */
|
|
115
|
+
pending(): number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type { BatchConfig, BatchResult, CacheEntry, CacheManager, CacheManagerConfig, CacheMetrics, CacheTTLStrategy, QueryBatcher, QueryCostConfig, QueryCostEntry, QueryCostReport, QueryCostTracker };
|