@phpsandbox/sdk 0.5.0 → 0.6.0-canary.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.
- package/README.md +22 -0
- package/dist/browser/phpsandbox-sdk.esm.js +97 -6
- package/dist/browser/phpsandbox-sdk.esm.min.js +9 -9
- package/dist/browser/phpsandbox-sdk.iife.js +97 -6
- package/dist/browser/phpsandbox-sdk.iife.min.js +9 -9
- package/dist/customers.d.ts +190 -1
- package/dist/customers.js +103 -2
- package/dist/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/customers.d.ts
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { Client } from './index.js';
|
|
3
|
+
declare const customerConfigurationSchema: z.ZodObject<{
|
|
4
|
+
funnel: z.ZodNullable<z.ZodObject<{
|
|
5
|
+
title: z.ZodString;
|
|
6
|
+
stages: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
label: z.ZodString;
|
|
9
|
+
measure: z.ZodLiteral<"event">;
|
|
10
|
+
event: z.ZodString;
|
|
11
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
12
|
+
id: z.ZodString;
|
|
13
|
+
label: z.ZodString;
|
|
14
|
+
measure: z.ZodLiteral<"first_payment">;
|
|
15
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
label: z.ZodString;
|
|
18
|
+
measure: z.ZodLiteral<"event_after_payment">;
|
|
19
|
+
event: z.ZodString;
|
|
20
|
+
}, z.core.$strip>], "measure">>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
followUp: z.ZodNullable<z.ZodObject<{
|
|
23
|
+
label: z.ZodString;
|
|
24
|
+
triggerEvent: z.ZodString;
|
|
25
|
+
prerequisiteEvent: z.ZodNullable<z.ZodString>;
|
|
26
|
+
stopOnPayment: z.ZodBoolean;
|
|
27
|
+
}, z.core.$strip>>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type CustomerConfiguration = z.infer<typeof customerConfigurationSchema>;
|
|
3
30
|
export declare const customerModeSchema: z.ZodEnum<{
|
|
4
31
|
test: "test";
|
|
5
32
|
live: "live";
|
|
@@ -12,6 +39,21 @@ export declare const customerSchema: z.ZodObject<{
|
|
|
12
39
|
name: z.ZodNullable<z.ZodString>;
|
|
13
40
|
source: z.ZodNullable<z.ZodString>;
|
|
14
41
|
marketingSubscribed: z.ZodBoolean;
|
|
42
|
+
communicationBasis: z.ZodOptional<z.ZodEnum<{
|
|
43
|
+
unknown: "unknown";
|
|
44
|
+
legacy_account: "legacy_account";
|
|
45
|
+
explicit_opt_in: "explicit_opt_in";
|
|
46
|
+
unsubscribed: "unsubscribed";
|
|
47
|
+
}>>;
|
|
48
|
+
legacyPolicy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
joinedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
50
|
+
importedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
51
|
+
lastActiveAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
52
|
+
billingStatus: z.ZodOptional<z.ZodEnum<{
|
|
53
|
+
unknown: "unknown";
|
|
54
|
+
paid: "paid";
|
|
55
|
+
free: "free";
|
|
56
|
+
}>>;
|
|
15
57
|
suppressionReason: z.ZodNullable<z.ZodString>;
|
|
16
58
|
activatedAt: z.ZodNullable<z.ZodString>;
|
|
17
59
|
createdAt: z.ZodNullable<z.ZodString>;
|
|
@@ -29,6 +71,33 @@ declare const spaceSchema: z.ZodObject<{
|
|
|
29
71
|
replyTo: z.ZodNullable<z.ZodString>;
|
|
30
72
|
senderVerified: z.ZodBoolean;
|
|
31
73
|
domainRecords: z.ZodNullable<z.ZodString>;
|
|
74
|
+
configuration: z.ZodOptional<z.ZodObject<{
|
|
75
|
+
funnel: z.ZodNullable<z.ZodObject<{
|
|
76
|
+
title: z.ZodString;
|
|
77
|
+
stages: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
78
|
+
id: z.ZodString;
|
|
79
|
+
label: z.ZodString;
|
|
80
|
+
measure: z.ZodLiteral<"event">;
|
|
81
|
+
event: z.ZodString;
|
|
82
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
83
|
+
id: z.ZodString;
|
|
84
|
+
label: z.ZodString;
|
|
85
|
+
measure: z.ZodLiteral<"first_payment">;
|
|
86
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
87
|
+
id: z.ZodString;
|
|
88
|
+
label: z.ZodString;
|
|
89
|
+
measure: z.ZodLiteral<"event_after_payment">;
|
|
90
|
+
event: z.ZodString;
|
|
91
|
+
}, z.core.$strip>], "measure">>;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
followUp: z.ZodNullable<z.ZodObject<{
|
|
94
|
+
label: z.ZodString;
|
|
95
|
+
triggerEvent: z.ZodString;
|
|
96
|
+
prerequisiteEvent: z.ZodNullable<z.ZodString>;
|
|
97
|
+
stopOnPayment: z.ZodBoolean;
|
|
98
|
+
}, z.core.$strip>>;
|
|
99
|
+
}, z.core.$strip>>;
|
|
100
|
+
emailTemplate: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
101
|
provisionedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
33
102
|
lastRequestAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
34
103
|
processedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -52,6 +121,7 @@ declare const journeySchema: z.ZodObject<{
|
|
|
52
121
|
setup: "setup";
|
|
53
122
|
welcome: "welcome";
|
|
54
123
|
purchase: "purchase";
|
|
124
|
+
credit_limit: "credit_limit";
|
|
55
125
|
}>;
|
|
56
126
|
version: z.ZodOptional<z.ZodNumber>;
|
|
57
127
|
startsAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -79,6 +149,7 @@ declare const messageSchema: z.ZodObject<{
|
|
|
79
149
|
setup: "setup";
|
|
80
150
|
welcome: "welcome";
|
|
81
151
|
purchase: "purchase";
|
|
152
|
+
credit_limit: "credit_limit";
|
|
82
153
|
}>>>;
|
|
83
154
|
journeyVersion: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
84
155
|
category: z.ZodOptional<z.ZodEnum<{
|
|
@@ -88,11 +159,20 @@ declare const messageSchema: z.ZodObject<{
|
|
|
88
159
|
from: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
89
160
|
replyTo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
90
161
|
renderedText: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
162
|
+
renderedHtml: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
91
163
|
unsubscribeUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
92
164
|
createdAt: z.ZodNullable<z.ZodString>;
|
|
93
165
|
}, z.core.$strip>;
|
|
94
166
|
export type CustomerMessageData = z.infer<typeof messageSchema>;
|
|
95
167
|
declare const overviewSchema: z.ZodObject<{
|
|
168
|
+
funnel: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
169
|
+
title: z.ZodString;
|
|
170
|
+
stages: z.ZodArray<z.ZodObject<{
|
|
171
|
+
id: z.ZodString;
|
|
172
|
+
label: z.ZodString;
|
|
173
|
+
count: z.ZodNumber;
|
|
174
|
+
}, z.core.$strip>>;
|
|
175
|
+
}, z.core.$strip>>>;
|
|
96
176
|
space: z.ZodNullable<z.ZodObject<{
|
|
97
177
|
id: z.ZodString;
|
|
98
178
|
mode: z.ZodEnum<{
|
|
@@ -105,6 +185,33 @@ declare const overviewSchema: z.ZodObject<{
|
|
|
105
185
|
replyTo: z.ZodNullable<z.ZodString>;
|
|
106
186
|
senderVerified: z.ZodBoolean;
|
|
107
187
|
domainRecords: z.ZodNullable<z.ZodString>;
|
|
188
|
+
configuration: z.ZodOptional<z.ZodObject<{
|
|
189
|
+
funnel: z.ZodNullable<z.ZodObject<{
|
|
190
|
+
title: z.ZodString;
|
|
191
|
+
stages: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
192
|
+
id: z.ZodString;
|
|
193
|
+
label: z.ZodString;
|
|
194
|
+
measure: z.ZodLiteral<"event">;
|
|
195
|
+
event: z.ZodString;
|
|
196
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
197
|
+
id: z.ZodString;
|
|
198
|
+
label: z.ZodString;
|
|
199
|
+
measure: z.ZodLiteral<"first_payment">;
|
|
200
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
201
|
+
id: z.ZodString;
|
|
202
|
+
label: z.ZodString;
|
|
203
|
+
measure: z.ZodLiteral<"event_after_payment">;
|
|
204
|
+
event: z.ZodString;
|
|
205
|
+
}, z.core.$strip>], "measure">>;
|
|
206
|
+
}, z.core.$strip>>;
|
|
207
|
+
followUp: z.ZodNullable<z.ZodObject<{
|
|
208
|
+
label: z.ZodString;
|
|
209
|
+
triggerEvent: z.ZodString;
|
|
210
|
+
prerequisiteEvent: z.ZodNullable<z.ZodString>;
|
|
211
|
+
stopOnPayment: z.ZodBoolean;
|
|
212
|
+
}, z.core.$strip>>;
|
|
213
|
+
}, z.core.$strip>>;
|
|
214
|
+
emailTemplate: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
108
215
|
provisionedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
109
216
|
lastRequestAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
110
217
|
processedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -116,6 +223,21 @@ declare const overviewSchema: z.ZodObject<{
|
|
|
116
223
|
name: z.ZodNullable<z.ZodString>;
|
|
117
224
|
source: z.ZodNullable<z.ZodString>;
|
|
118
225
|
marketingSubscribed: z.ZodBoolean;
|
|
226
|
+
communicationBasis: z.ZodOptional<z.ZodEnum<{
|
|
227
|
+
unknown: "unknown";
|
|
228
|
+
legacy_account: "legacy_account";
|
|
229
|
+
explicit_opt_in: "explicit_opt_in";
|
|
230
|
+
unsubscribed: "unsubscribed";
|
|
231
|
+
}>>;
|
|
232
|
+
legacyPolicy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
233
|
+
joinedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
234
|
+
importedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
235
|
+
lastActiveAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
236
|
+
billingStatus: z.ZodOptional<z.ZodEnum<{
|
|
237
|
+
unknown: "unknown";
|
|
238
|
+
paid: "paid";
|
|
239
|
+
free: "free";
|
|
240
|
+
}>>;
|
|
119
241
|
suppressionReason: z.ZodNullable<z.ZodString>;
|
|
120
242
|
activatedAt: z.ZodNullable<z.ZodString>;
|
|
121
243
|
createdAt: z.ZodNullable<z.ZodString>;
|
|
@@ -130,6 +252,7 @@ declare const overviewSchema: z.ZodObject<{
|
|
|
130
252
|
setup: "setup";
|
|
131
253
|
welcome: "welcome";
|
|
132
254
|
purchase: "purchase";
|
|
255
|
+
credit_limit: "credit_limit";
|
|
133
256
|
}>;
|
|
134
257
|
version: z.ZodOptional<z.ZodNumber>;
|
|
135
258
|
startsAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -156,6 +279,7 @@ declare const overviewSchema: z.ZodObject<{
|
|
|
156
279
|
setup: "setup";
|
|
157
280
|
welcome: "welcome";
|
|
158
281
|
purchase: "purchase";
|
|
282
|
+
credit_limit: "credit_limit";
|
|
159
283
|
}>>>;
|
|
160
284
|
journeyVersion: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
161
285
|
category: z.ZodOptional<z.ZodEnum<{
|
|
@@ -165,6 +289,7 @@ declare const overviewSchema: z.ZodObject<{
|
|
|
165
289
|
from: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
166
290
|
replyTo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
167
291
|
renderedText: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
292
|
+
renderedHtml: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
168
293
|
unsubscribeUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
169
294
|
createdAt: z.ZodNullable<z.ZodString>;
|
|
170
295
|
}, z.core.$strip>>;
|
|
@@ -176,16 +301,58 @@ export type CustomersOverview = z.infer<typeof overviewSchema>;
|
|
|
176
301
|
export interface IdentifyCustomerInput {
|
|
177
302
|
externalId: string;
|
|
178
303
|
email: string;
|
|
179
|
-
name?: string;
|
|
304
|
+
name?: string | null;
|
|
180
305
|
source?: string;
|
|
181
306
|
billingStatus?: 'unknown' | 'free' | 'paid';
|
|
307
|
+
/** Original registration time, independent of the Customers record creation time. */
|
|
308
|
+
joinedAt?: string;
|
|
309
|
+
lastActiveAt?: string;
|
|
310
|
+
/** Historical synchronization never enrolls signup journeys. */
|
|
311
|
+
historical?: boolean;
|
|
312
|
+
/** Explicit eligibility policy for accounts with unknown preferences; this does not record consent. */
|
|
313
|
+
legacyPolicy?: string;
|
|
314
|
+
/** Import known suppressions. Identification can never clear an existing suppression. */
|
|
315
|
+
suppressionReason?: string;
|
|
316
|
+
/** Preserve a known unsubscribe atomically during account identification. Never clears an unsubscribe. */
|
|
317
|
+
unsubscribed?: true;
|
|
318
|
+
/** Original known unsubscribe time. A later explicit opt-in remains authoritative. */
|
|
319
|
+
unsubscribedAt?: string;
|
|
182
320
|
}
|
|
183
321
|
export interface CustomerEventInput {
|
|
184
322
|
eventId: string;
|
|
185
323
|
name: string;
|
|
324
|
+
organizationExternalId?: string;
|
|
186
325
|
occurredAt?: string;
|
|
326
|
+
/** Preserve activity history without activating or enrolling a customer. */
|
|
327
|
+
historical?: boolean;
|
|
187
328
|
properties?: Record<string, string | number | boolean | null>;
|
|
188
329
|
}
|
|
330
|
+
export interface CustomerOrganizationInput {
|
|
331
|
+
externalId: string;
|
|
332
|
+
name: string;
|
|
333
|
+
ownerExternalId: string;
|
|
334
|
+
/** Complete current membership snapshot. The owner is always included. */
|
|
335
|
+
members: {
|
|
336
|
+
externalId: string;
|
|
337
|
+
role: string;
|
|
338
|
+
}[];
|
|
339
|
+
}
|
|
340
|
+
export interface CustomerPaymentInput {
|
|
341
|
+
paymentId: string;
|
|
342
|
+
amountMinor: number;
|
|
343
|
+
currency: string;
|
|
344
|
+
paidAt: string;
|
|
345
|
+
historical?: boolean;
|
|
346
|
+
}
|
|
347
|
+
declare const customerOrganizationSchema: z.ZodObject<{
|
|
348
|
+
id: z.ZodString;
|
|
349
|
+
externalId: z.ZodString;
|
|
350
|
+
name: z.ZodString;
|
|
351
|
+
ownerCustomerId: z.ZodString;
|
|
352
|
+
firstPaidAt: z.ZodNullable<z.ZodString>;
|
|
353
|
+
activatedAt: z.ZodNullable<z.ZodString>;
|
|
354
|
+
}, z.core.$strip>;
|
|
355
|
+
export type CustomerOrganizationData = z.infer<typeof customerOrganizationSchema>;
|
|
189
356
|
export interface SendCustomerMessageInput {
|
|
190
357
|
requestId: string;
|
|
191
358
|
subject: string;
|
|
@@ -196,6 +363,27 @@ export interface SendCustomerMessageInput {
|
|
|
196
363
|
export declare class CustomerRuntime {
|
|
197
364
|
private readonly client;
|
|
198
365
|
constructor(client: Client);
|
|
366
|
+
/** Configure this application's event funnel and follow-up rules. Does not activate messaging. */
|
|
367
|
+
configure(input: CustomerConfiguration & {
|
|
368
|
+
emailTemplate?: string | null;
|
|
369
|
+
}): Promise<CustomerConfiguration>;
|
|
370
|
+
/** Inspect the workspace and environment selected by this app credential. */
|
|
371
|
+
context(): Promise<{
|
|
372
|
+
id: string;
|
|
373
|
+
notebookId: string;
|
|
374
|
+
mode: CustomerMode;
|
|
375
|
+
}>;
|
|
376
|
+
/** Pull due conversion follow-ups, then recheck authoritative billing, credit and access. */
|
|
377
|
+
pendingFollowUps(): Promise<{
|
|
378
|
+
messageId: string;
|
|
379
|
+
organizationExternalId: string;
|
|
380
|
+
actorExternalId: string;
|
|
381
|
+
}[]>;
|
|
382
|
+
/** Eligible deliveries run immediately; expired checks are never reused by a later worker. */
|
|
383
|
+
resolveFollowUp(messageId: string, resolution: 'eligible' | 'ineligible' | 'paid' | 'credits_available' | 'access_changed'): Promise<CustomerMessageData>;
|
|
384
|
+
organization(input: CustomerOrganizationInput): Promise<CustomerOrganizationData>;
|
|
385
|
+
/** Report only server-confirmed positive payments from your existing billing integration. */
|
|
386
|
+
confirmPayment(organizationExternalId: string, input: CustomerPaymentInput): Promise<CustomerOrganizationData>;
|
|
199
387
|
identify(input: IdentifyCustomerInput): Promise<CustomerData>;
|
|
200
388
|
linkIdentity(customerId: string, externalId: string): Promise<CustomerData>;
|
|
201
389
|
get(customerId: string): Promise<CustomerData>;
|
|
@@ -206,6 +394,7 @@ export declare class CustomerRuntime {
|
|
|
206
394
|
preferences(customerId: string, input: {
|
|
207
395
|
subscribed: boolean;
|
|
208
396
|
source: string;
|
|
397
|
+
occurredAt?: string;
|
|
209
398
|
}): Promise<CustomerData>;
|
|
210
399
|
send(customerId: string, input: SendCustomerMessageInput): Promise<CustomerMessageData>;
|
|
211
400
|
}
|
package/dist/customers.js
CHANGED
|
@@ -1,4 +1,51 @@
|
|
|
1
|
+
// credit_limit is retained as the compatibility identifier for the application-configured event follow-up.
|
|
1
2
|
import { z } from 'zod';
|
|
3
|
+
const eventName = z.string().trim().min(1).max(100);
|
|
4
|
+
const customerConfigurationSchema = z.object({
|
|
5
|
+
funnel: z
|
|
6
|
+
.object({
|
|
7
|
+
title: z.string().trim().min(1).max(100),
|
|
8
|
+
stages: z
|
|
9
|
+
.array(z.discriminatedUnion('measure', [
|
|
10
|
+
z.object({
|
|
11
|
+
id: z
|
|
12
|
+
.string()
|
|
13
|
+
.regex(/^[a-zA-Z0-9_-]+$/)
|
|
14
|
+
.max(50),
|
|
15
|
+
label: z.string().trim().min(1).max(100),
|
|
16
|
+
measure: z.literal('event'),
|
|
17
|
+
event: eventName,
|
|
18
|
+
}),
|
|
19
|
+
z.object({
|
|
20
|
+
id: z
|
|
21
|
+
.string()
|
|
22
|
+
.regex(/^[a-zA-Z0-9_-]+$/)
|
|
23
|
+
.max(50),
|
|
24
|
+
label: z.string().trim().min(1).max(100),
|
|
25
|
+
measure: z.literal('first_payment'),
|
|
26
|
+
}),
|
|
27
|
+
z.object({
|
|
28
|
+
id: z
|
|
29
|
+
.string()
|
|
30
|
+
.regex(/^[a-zA-Z0-9_-]+$/)
|
|
31
|
+
.max(50),
|
|
32
|
+
label: z.string().trim().min(1).max(100),
|
|
33
|
+
measure: z.literal('event_after_payment'),
|
|
34
|
+
event: eventName,
|
|
35
|
+
}),
|
|
36
|
+
]))
|
|
37
|
+
.max(12),
|
|
38
|
+
})
|
|
39
|
+
.nullable(),
|
|
40
|
+
followUp: z
|
|
41
|
+
.object({
|
|
42
|
+
label: z.string().trim().min(1).max(100),
|
|
43
|
+
triggerEvent: eventName,
|
|
44
|
+
prerequisiteEvent: eventName.nullable(),
|
|
45
|
+
stopOnPayment: z.boolean(),
|
|
46
|
+
})
|
|
47
|
+
.nullable(),
|
|
48
|
+
});
|
|
2
49
|
export const customerModeSchema = z.enum(['test', 'live']);
|
|
3
50
|
export const customerSchema = z.object({
|
|
4
51
|
id: z.string(),
|
|
@@ -7,6 +54,12 @@ export const customerSchema = z.object({
|
|
|
7
54
|
name: z.string().nullable(),
|
|
8
55
|
source: z.string().nullable(),
|
|
9
56
|
marketingSubscribed: z.boolean(),
|
|
57
|
+
communicationBasis: z.enum(['unknown', 'legacy_account', 'explicit_opt_in', 'unsubscribed']).optional(),
|
|
58
|
+
legacyPolicy: z.string().nullable().optional(),
|
|
59
|
+
joinedAt: z.string().nullable().optional(),
|
|
60
|
+
importedAt: z.string().nullable().optional(),
|
|
61
|
+
lastActiveAt: z.string().nullable().optional(),
|
|
62
|
+
billingStatus: z.enum(['unknown', 'free', 'paid']).optional(),
|
|
10
63
|
suppressionReason: z.string().nullable(),
|
|
11
64
|
activatedAt: z.string().nullable(),
|
|
12
65
|
createdAt: z.string().nullable(),
|
|
@@ -20,6 +73,8 @@ const spaceSchema = z.object({
|
|
|
20
73
|
replyTo: z.string().nullable(),
|
|
21
74
|
senderVerified: z.boolean(),
|
|
22
75
|
domainRecords: z.string().nullable(),
|
|
76
|
+
configuration: customerConfigurationSchema.optional(),
|
|
77
|
+
emailTemplate: z.string().nullable().optional(),
|
|
23
78
|
provisionedAt: z.string().nullable().optional(),
|
|
24
79
|
lastRequestAt: z.string().nullable().optional(),
|
|
25
80
|
processedAt: z.string().nullable().optional(),
|
|
@@ -32,7 +87,7 @@ const journeyInputSchema = z.object({
|
|
|
32
87
|
activationEvent: z.string(),
|
|
33
88
|
});
|
|
34
89
|
const journeySchema = journeyInputSchema.extend({
|
|
35
|
-
kind: z.enum(['welcome', 'setup', 'purchase']),
|
|
90
|
+
kind: z.enum(['welcome', 'setup', 'purchase', 'credit_limit']),
|
|
36
91
|
version: z.number().int().optional(),
|
|
37
92
|
startsAt: z.string().nullable().optional(),
|
|
38
93
|
draft: journeyInputSchema.nullable().optional(),
|
|
@@ -48,16 +103,21 @@ const messageSchema = z.object({
|
|
|
48
103
|
dueAt: z.string().nullable().optional(),
|
|
49
104
|
attemptedAt: z.string().nullable().optional(),
|
|
50
105
|
receivedAt: z.string().nullable().optional(),
|
|
51
|
-
journeyKind: z.enum(['welcome', 'setup', 'purchase']).nullable().optional(),
|
|
106
|
+
journeyKind: z.enum(['welcome', 'setup', 'purchase', 'credit_limit']).nullable().optional(),
|
|
52
107
|
journeyVersion: z.number().int().nullable().optional(),
|
|
53
108
|
category: z.enum(['marketing', 'service']).optional(),
|
|
54
109
|
from: z.string().nullable().optional(),
|
|
55
110
|
replyTo: z.string().nullable().optional(),
|
|
56
111
|
renderedText: z.string().nullable().optional(),
|
|
112
|
+
renderedHtml: z.string().nullable().optional(),
|
|
57
113
|
unsubscribeUrl: z.string().nullable().optional(),
|
|
58
114
|
createdAt: z.string().nullable(),
|
|
59
115
|
});
|
|
60
116
|
const overviewSchema = z.object({
|
|
117
|
+
funnel: z
|
|
118
|
+
.object({ title: z.string(), stages: z.array(z.object({ id: z.string(), label: z.string(), count: z.number() })) })
|
|
119
|
+
.nullable()
|
|
120
|
+
.optional(),
|
|
61
121
|
space: spaceSchema.nullable(),
|
|
62
122
|
customers: z.array(customerSchema),
|
|
63
123
|
journeys: z.array(journeySchema),
|
|
@@ -66,11 +126,52 @@ const overviewSchema = z.object({
|
|
|
66
126
|
messageTotal: z.number().optional(),
|
|
67
127
|
events: z.array(z.string()).optional(),
|
|
68
128
|
});
|
|
129
|
+
const customerOrganizationSchema = z.object({
|
|
130
|
+
id: z.string(),
|
|
131
|
+
externalId: z.string(),
|
|
132
|
+
name: z.string(),
|
|
133
|
+
ownerCustomerId: z.string(),
|
|
134
|
+
firstPaidAt: z.string().nullable(),
|
|
135
|
+
activatedAt: z.string().nullable(),
|
|
136
|
+
});
|
|
69
137
|
/** Use only from trusted app servers with a dedicated Customers credential. */
|
|
70
138
|
export class CustomerRuntime {
|
|
71
139
|
constructor(client) {
|
|
72
140
|
this.client = client;
|
|
73
141
|
}
|
|
142
|
+
/** Configure this application's event funnel and follow-up rules. Does not activate messaging. */
|
|
143
|
+
async configure(input) {
|
|
144
|
+
const configuration = customerConfigurationSchema.parse(input);
|
|
145
|
+
return customerConfigurationSchema.parse((await this.client.put('/platform/customers/runtime/configuration', {
|
|
146
|
+
...configuration,
|
|
147
|
+
...(input.emailTemplate !== undefined ? { emailTemplate: input.emailTemplate } : {}),
|
|
148
|
+
})).data);
|
|
149
|
+
}
|
|
150
|
+
/** Inspect the workspace and environment selected by this app credential. */
|
|
151
|
+
async context() {
|
|
152
|
+
return z
|
|
153
|
+
.object({ id: z.string(), notebookId: z.string(), mode: customerModeSchema })
|
|
154
|
+
.parse((await this.client.get('/platform/customers/runtime/context')).data);
|
|
155
|
+
}
|
|
156
|
+
/** Pull due conversion follow-ups, then recheck authoritative billing, credit and access. */
|
|
157
|
+
async pendingFollowUps() {
|
|
158
|
+
return z
|
|
159
|
+
.array(z.object({ messageId: z.string(), organizationExternalId: z.string(), actorExternalId: z.string() }))
|
|
160
|
+
.parse((await this.client.get('/platform/customers/runtime/follow-ups')).data);
|
|
161
|
+
}
|
|
162
|
+
/** Eligible deliveries run immediately; expired checks are never reused by a later worker. */
|
|
163
|
+
async resolveFollowUp(messageId, resolution) {
|
|
164
|
+
return messageSchema.parse((await this.client.post(`/platform/customers/runtime/follow-ups/${encodeURIComponent(messageId)}/resolve`, {
|
|
165
|
+
resolution,
|
|
166
|
+
})).data);
|
|
167
|
+
}
|
|
168
|
+
async organization(input) {
|
|
169
|
+
return customerOrganizationSchema.parse((await this.client.put('/platform/customers/runtime/organizations', input)).data);
|
|
170
|
+
}
|
|
171
|
+
/** Report only server-confirmed positive payments from your existing billing integration. */
|
|
172
|
+
async confirmPayment(organizationExternalId, input) {
|
|
173
|
+
return customerOrganizationSchema.parse((await this.client.post(`/platform/customers/runtime/organizations/${encodeURIComponent(organizationExternalId)}/payments`, input)).data);
|
|
174
|
+
}
|
|
74
175
|
async identify(input) {
|
|
75
176
|
return customerSchema.parse((await this.client.post('/platform/customers/runtime/identify', input)).data);
|
|
76
177
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -288,6 +288,7 @@ export interface NotebookMailData {
|
|
|
288
288
|
createdAt: string;
|
|
289
289
|
diffForHumans: string;
|
|
290
290
|
html: string | null;
|
|
291
|
+
text?: string | null;
|
|
291
292
|
}
|
|
292
293
|
export interface NotebookMailStateData {
|
|
293
294
|
enabled: boolean;
|
|
@@ -488,6 +489,7 @@ declare class NotebookMail {
|
|
|
488
489
|
to: string;
|
|
489
490
|
subject: string;
|
|
490
491
|
text: string;
|
|
492
|
+
html?: string;
|
|
491
493
|
}): Promise<NotebookMailData>;
|
|
492
494
|
enable(): Promise<NotebookMailStateData>;
|
|
493
495
|
disable(): Promise<void>;
|