@modainteract/moda-interact-shared 5.1.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,306 @@
1
1
  import { b as ShopifyWhatsAppConsentSyncJobV1 } from '../whatsapp-consent-sync.schema-DEU84xTL.js';
2
+ import { C as CredentialKeyring } from '../keyring-BLXjNChq.js';
2
3
  import 'zod';
3
4
 
5
+ type ShopifyOfflineTokenErrorCode = "SESSION_MISSING" | "SESSION_IDENTITY_CONFLICT" | "INVALID_SESSION" | "REFRESH_TOKEN_EXPIRED" | "OAUTH_CONFIG_UNAVAILABLE" | "LOCK_TIMEOUT" | "CANCELLED" | "DEADLINE" | "REFRESH_REJECTED" | "REFRESH_RESPONSE_INVALID" | "REFRESH_OUTCOME_UNKNOWN" | "PERSISTENCE_UNAVAILABLE";
6
+ /** Bounded refresh lifecycle metadata. Never includes provider credentials or errors. */
7
+ type ShopifyOfflineRefreshEvent = Readonly<{
8
+ event: "shopify.offline_refresh.started" | "shopify.offline_refresh.committed" | "shopify.offline_refresh.failed";
9
+ operationId: string;
10
+ shopId: string | null;
11
+ source: "SHARED" | "SDK";
12
+ durationMs: number;
13
+ outcome: "STARTED" | "COMMITTED" | "REJECTED" | "UNKNOWN" | "CANCELLED" | "UNAVAILABLE";
14
+ reasonCode: ShopifyOfflineTokenErrorCode | null;
15
+ }>;
16
+ declare class ShopifyOfflineTokenError extends Error {
17
+ readonly code: ShopifyOfflineTokenErrorCode;
18
+ readonly retryable: boolean;
19
+ constructor(code: ShopifyOfflineTokenErrorCode);
20
+ }
21
+ type ShopifyOfflineSessionRecord = Readonly<{
22
+ id: string;
23
+ shop: string;
24
+ isOnline: boolean;
25
+ accessToken: string | null;
26
+ refreshToken: string | null;
27
+ scope: string | null;
28
+ expires: Date | null;
29
+ refreshTokenExpires: Date | null;
30
+ }>;
31
+ type ShopifyOfflineShopRecord = Readonly<{
32
+ id: string;
33
+ domain: string;
34
+ platform: string;
35
+ status: string;
36
+ }>;
37
+ type ShopifyOfflineStringFilter = string | Readonly<{
38
+ equals?: string;
39
+ in?: string[];
40
+ notIn?: string[];
41
+ lt?: string;
42
+ lte?: string;
43
+ gt?: string;
44
+ gte?: string;
45
+ contains?: string;
46
+ startsWith?: string;
47
+ endsWith?: string;
48
+ mode?: "default" | "insensitive";
49
+ not?: string | ShopifyOfflineStringFilter;
50
+ }>;
51
+ type ShopifyOfflineBooleanFilter = boolean | Readonly<{
52
+ equals?: boolean;
53
+ not?: boolean | ShopifyOfflineBooleanFilter;
54
+ }>;
55
+ type ShopifyOfflineNullableStringFilter = string | null | Readonly<{
56
+ equals?: string | null;
57
+ in?: string[] | null;
58
+ notIn?: string[] | null;
59
+ lt?: string;
60
+ lte?: string;
61
+ gt?: string;
62
+ gte?: string;
63
+ contains?: string;
64
+ startsWith?: string;
65
+ endsWith?: string;
66
+ mode?: "default" | "insensitive";
67
+ not?: string | null | ShopifyOfflineNullableStringFilter;
68
+ }>;
69
+ type ShopifyOfflineNullableBooleanFilter = boolean | null | Readonly<{
70
+ equals?: boolean | null;
71
+ not?: boolean | null | ShopifyOfflineNullableBooleanFilter;
72
+ }>;
73
+ type ShopifyOfflineDateFilter = Date | string | null | Readonly<{
74
+ equals?: Date | string | null;
75
+ in?: Date[] | string[] | null;
76
+ notIn?: Date[] | string[] | null;
77
+ lt?: Date | string;
78
+ lte?: Date | string;
79
+ gt?: Date | string;
80
+ gte?: Date | string;
81
+ not?: Date | string | null | ShopifyOfflineDateFilter;
82
+ }>;
83
+ type ShopifyOfflineBigIntFilter = bigint | number | null | Readonly<{
84
+ equals?: bigint | number | null;
85
+ in?: bigint[] | number[] | null;
86
+ notIn?: bigint[] | number[] | null;
87
+ lt?: bigint | number;
88
+ lte?: bigint | number;
89
+ gt?: bigint | number;
90
+ gte?: bigint | number;
91
+ not?: bigint | number | null | ShopifyOfflineBigIntFilter;
92
+ }>;
93
+ type ShopifyOfflineSessionScalarWhere = {
94
+ id?: ShopifyOfflineStringFilter;
95
+ shop?: ShopifyOfflineStringFilter;
96
+ state?: ShopifyOfflineStringFilter;
97
+ isOnline?: ShopifyOfflineBooleanFilter;
98
+ scope?: ShopifyOfflineNullableStringFilter;
99
+ expires?: ShopifyOfflineDateFilter;
100
+ accessToken?: ShopifyOfflineStringFilter;
101
+ userId?: ShopifyOfflineBigIntFilter;
102
+ firstName?: ShopifyOfflineNullableStringFilter;
103
+ lastName?: ShopifyOfflineNullableStringFilter;
104
+ email?: ShopifyOfflineNullableStringFilter;
105
+ accountOwner?: ShopifyOfflineBooleanFilter;
106
+ locale?: ShopifyOfflineNullableStringFilter;
107
+ collaborator?: ShopifyOfflineNullableBooleanFilter;
108
+ emailVerified?: ShopifyOfflineNullableBooleanFilter;
109
+ refreshToken?: ShopifyOfflineNullableStringFilter;
110
+ refreshTokenExpires?: ShopifyOfflineDateFilter;
111
+ };
112
+ type ShopifyOfflineSessionWhere = ShopifyOfflineSessionScalarWhere & {
113
+ AND?: ShopifyOfflineSessionScalarWhere | ShopifyOfflineSessionScalarWhere[];
114
+ OR?: ShopifyOfflineSessionScalarWhere[];
115
+ NOT?: ShopifyOfflineSessionScalarWhere | ShopifyOfflineSessionScalarWhere[];
116
+ };
117
+ type ShopifyOfflineSessionUniqueWhere = Readonly<{
118
+ id: string;
119
+ }>;
120
+ type ShopifyOfflineSessionSelect = Readonly<Partial<Record<"id" | "shop" | "state" | "isOnline" | "scope" | "expires" | "accessToken" | "userId" | "firstName" | "lastName" | "email" | "accountOwner" | "locale" | "collaborator" | "emailVerified" | "refreshToken" | "refreshTokenExpires", true>>>;
121
+ type ShopifyOfflineSessionData = Readonly<{
122
+ id?: string;
123
+ shop?: string;
124
+ state?: string;
125
+ isOnline?: boolean;
126
+ scope?: string | null;
127
+ expires?: Date | null;
128
+ accessToken?: string;
129
+ userId?: bigint | null;
130
+ firstName?: string | null;
131
+ lastName?: string | null;
132
+ email?: string | null;
133
+ accountOwner?: boolean;
134
+ locale?: string | null;
135
+ collaborator?: boolean | null;
136
+ emailVerified?: boolean | null;
137
+ refreshToken?: string | null;
138
+ refreshTokenExpires?: Date | null;
139
+ }>;
140
+ type ShopifyOfflineSessionCreateData = ShopifyOfflineSessionData & Readonly<{
141
+ id: string;
142
+ shop: string;
143
+ state: string;
144
+ accessToken: string;
145
+ }>;
146
+ type ShopifyOfflineSessionDelegate = Readonly<{
147
+ findUnique(args: Readonly<{
148
+ where: ShopifyOfflineSessionUniqueWhere;
149
+ select?: ShopifyOfflineSessionSelect;
150
+ }>): Promise<ShopifyOfflineSessionRecord | null>;
151
+ findMany(args: Readonly<{
152
+ where: ShopifyOfflineSessionWhere;
153
+ select?: ShopifyOfflineSessionSelect;
154
+ take?: number;
155
+ }>): Promise<ShopifyOfflineSessionRecord[]>;
156
+ create(args: Readonly<{
157
+ data: ShopifyOfflineSessionCreateData;
158
+ select?: ShopifyOfflineSessionSelect;
159
+ }>): Promise<ShopifyOfflineSessionRecord>;
160
+ update(args: Readonly<{
161
+ where: ShopifyOfflineSessionUniqueWhere;
162
+ data: ShopifyOfflineSessionData;
163
+ select?: ShopifyOfflineSessionSelect;
164
+ }>): Promise<ShopifyOfflineSessionRecord>;
165
+ upsert(args: Readonly<{
166
+ where: ShopifyOfflineSessionUniqueWhere;
167
+ create: ShopifyOfflineSessionCreateData;
168
+ update: ShopifyOfflineSessionData;
169
+ select?: ShopifyOfflineSessionSelect;
170
+ }>): Promise<ShopifyOfflineSessionRecord>;
171
+ delete(args: Readonly<{
172
+ where: ShopifyOfflineSessionUniqueWhere;
173
+ select?: ShopifyOfflineSessionSelect;
174
+ }>): Promise<ShopifyOfflineSessionRecord>;
175
+ deleteMany(args: Readonly<{
176
+ where?: ShopifyOfflineSessionWhere;
177
+ }>): Promise<{
178
+ count: number;
179
+ }>;
180
+ updateMany(args: Readonly<{
181
+ where?: ShopifyOfflineSessionWhere;
182
+ data: ShopifyOfflineSessionData;
183
+ }>): Promise<{
184
+ count: number;
185
+ }>;
186
+ }>;
187
+ type ShopifyOfflineTransaction = Readonly<{
188
+ $queryRawUnsafe<T = unknown>(sql: string, ...values: unknown[]): Promise<T>;
189
+ $executeRawUnsafe(sql: string, ...values: unknown[]): Promise<number>;
190
+ session: ShopifyOfflineSessionDelegate;
191
+ shop: Readonly<{
192
+ findUnique(args: Readonly<{
193
+ where: Readonly<{
194
+ id: string;
195
+ }>;
196
+ select: Readonly<{
197
+ id: true;
198
+ domain: true;
199
+ platform: true;
200
+ status: true;
201
+ }>;
202
+ }>): Promise<ShopifyOfflineShopRecord | null>;
203
+ }>;
204
+ }>;
205
+ type ShopifyOfflineDatabase = Readonly<{
206
+ $transaction<T>(work: (transaction: ShopifyOfflineTransaction) => Promise<T>, options: Readonly<{
207
+ maxWait: 5000;
208
+ timeout: 20000;
209
+ isolationLevel: "ReadCommitted";
210
+ }>): Promise<T>;
211
+ shop: ShopifyOfflineTransaction["shop"];
212
+ }>;
213
+ type OfflineCredentialSnapshot = Readonly<{
214
+ id: string;
215
+ shopId: string;
216
+ shop: string;
217
+ accessToken: string;
218
+ scope: string | null;
219
+ expires: Date | null;
220
+ refreshTokenExpires: Date | null;
221
+ }>;
222
+ type LockedSessionContext = Readonly<{
223
+ transaction: ShopifyOfflineTransaction;
224
+ shopId: string;
225
+ shop: string;
226
+ sessionId: string;
227
+ signal: AbortSignal;
228
+ }>;
229
+ type SdkInstallationSessionContext = Readonly<{
230
+ transaction: ShopifyOfflineTransaction;
231
+ shopId: null;
232
+ shop: string;
233
+ sessionId: string | null;
234
+ signal: AbortSignal;
235
+ }>;
236
+ type ShopifyOfflineTokenProvider = Readonly<{
237
+ withSdkInstallationSessionLock<T>(integrationDomain: string, work: (context: SdkInstallationSessionContext) => Promise<T>): Promise<T>;
238
+ getAccessToken(shopId: string, options?: Readonly<{
239
+ signal?: AbortSignal;
240
+ }>): Promise<string>;
241
+ getSession(shopId: string, options?: Readonly<{
242
+ signal?: AbortSignal;
243
+ }>): Promise<OfflineCredentialSnapshot>;
244
+ withSessionLock<T>(shopId: string, work: (context: LockedSessionContext) => Promise<T>, options?: Readonly<{
245
+ signal?: AbortSignal;
246
+ }>): Promise<T>;
247
+ }>;
248
+ declare function createShopifyOfflineTokenProvider(input: Readonly<{
249
+ prisma: ShopifyOfflineDatabase;
250
+ readOAuth: () => Promise<Readonly<{
251
+ apiKey: string;
252
+ apiSecret: string;
253
+ }>>;
254
+ fetch: typeof fetch;
255
+ now?: () => number;
256
+ onEvent?: (event: ShopifyOfflineRefreshEvent) => void;
257
+ }>): ShopifyOfflineTokenProvider;
258
+
259
+ declare const CONFIGURATION_KEY: "shopify.oauth";
260
+ type ShopifyOAuthConfigurationErrorCode = "INVALID_ENVIRONMENT" | "CONFIGURATION_UNAVAILABLE" | "CONFIGURATION_INVALID";
261
+ /** Safe configuration boundary error; never contains a row, key, or decrypt cause. */
262
+ declare class ShopifyOAuthConfigurationError extends Error {
263
+ readonly code: ShopifyOAuthConfigurationErrorCode;
264
+ constructor(code: ShopifyOAuthConfigurationErrorCode);
265
+ }
266
+ type ShopifyOAuthConfigurationRow = Readonly<{
267
+ environment: string;
268
+ key: string;
269
+ version: number;
270
+ value: unknown;
271
+ }>;
272
+ type ShopifyOAuthConfigurationPrisma = Readonly<{
273
+ platformConfiguration: Readonly<{
274
+ findUnique(args: Readonly<{
275
+ where: Readonly<{
276
+ environment_key: Readonly<{
277
+ environment: string;
278
+ key: typeof CONFIGURATION_KEY;
279
+ }>;
280
+ }>;
281
+ select: Readonly<{
282
+ environment: true;
283
+ key: true;
284
+ version: true;
285
+ value: true;
286
+ }>;
287
+ }>): Promise<ShopifyOAuthConfigurationRow | null>;
288
+ }>;
289
+ }>;
290
+ type ShopifyOAuthCredentials = Readonly<{
291
+ apiKey: string;
292
+ apiSecret: string;
293
+ }>;
294
+ /**
295
+ * Read and unseal the existing platform `shopify.oauth` row. Environment identity
296
+ * is deployment configuration supplied by the caller, never request data.
297
+ */
298
+ declare function readShopifyOAuthConfiguration(input: Readonly<{
299
+ prisma: ShopifyOAuthConfigurationPrisma;
300
+ environment: string;
301
+ unsealKeyring: CredentialKeyring;
302
+ }>): Promise<ShopifyOAuthCredentials>;
303
+
4
304
  /**
5
305
  * Legacy webhook delivery job id used by earlier receipt/outbox flows.
6
306
  * Prefer the resource-scoped helpers below for current queue publication.
@@ -22,4 +322,4 @@ declare function createShopifyDiscountSyncJobId(event: {
22
322
  */
23
323
  declare function createShopifyWhatsAppConsentSyncJobId(input: ShopifyWhatsAppConsentSyncJobV1): string;
24
324
 
25
- export { createPendingRecoveryCandidateJobId, createShopifyCheckoutJobId, createShopifyDiscountSyncJobId, createShopifyOrderJobId, createShopifyWebhookJobId, createShopifyWhatsAppConsentSyncJobId };
325
+ export { type LockedSessionContext, type OfflineCredentialSnapshot, type SdkInstallationSessionContext, ShopifyOAuthConfigurationError, type ShopifyOAuthConfigurationErrorCode, type ShopifyOAuthConfigurationPrisma, type ShopifyOAuthConfigurationRow, type ShopifyOAuthCredentials, type ShopifyOfflineBigIntFilter, type ShopifyOfflineBooleanFilter, type ShopifyOfflineDatabase, type ShopifyOfflineDateFilter, type ShopifyOfflineNullableBooleanFilter, type ShopifyOfflineNullableStringFilter, type ShopifyOfflineRefreshEvent, type ShopifyOfflineSessionCreateData, type ShopifyOfflineSessionData, type ShopifyOfflineSessionDelegate, type ShopifyOfflineSessionRecord, type ShopifyOfflineSessionScalarWhere, type ShopifyOfflineSessionSelect, type ShopifyOfflineSessionUniqueWhere, type ShopifyOfflineSessionWhere, type ShopifyOfflineShopRecord, type ShopifyOfflineStringFilter, ShopifyOfflineTokenError, type ShopifyOfflineTokenErrorCode, type ShopifyOfflineTokenProvider, type ShopifyOfflineTransaction, createPendingRecoveryCandidateJobId, createShopifyCheckoutJobId, createShopifyDiscountSyncJobId, createShopifyOfflineTokenProvider, createShopifyOrderJobId, createShopifyWebhookJobId, createShopifyWhatsAppConsentSyncJobId, readShopifyOAuthConfiguration };