@phpsandbox/sdk 0.3.5 → 0.5.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 +37 -0
- package/dist/app.d.ts +21 -0
- package/dist/app.js +23 -0
- package/dist/browser/phpsandbox-sdk.esm.js +516 -30
- package/dist/browser/phpsandbox-sdk.esm.min.js +10 -10
- package/dist/browser/phpsandbox-sdk.iife.js +516 -30
- package/dist/browser/phpsandbox-sdk.iife.min.js +10 -10
- package/dist/customers.d.ts +241 -0
- package/dist/customers.js +141 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +20 -0
- package/dist/payments.d.ts +363 -0
- package/dist/payments.js +265 -0
- package/package.json +1 -1
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Client } from './index.js';
|
|
3
|
+
export declare const customerModeSchema: z.ZodEnum<{
|
|
4
|
+
test: "test";
|
|
5
|
+
live: "live";
|
|
6
|
+
}>;
|
|
7
|
+
export type CustomerMode = z.infer<typeof customerModeSchema>;
|
|
8
|
+
export declare const customerSchema: z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
externalId: z.ZodString;
|
|
11
|
+
email: z.ZodString;
|
|
12
|
+
name: z.ZodNullable<z.ZodString>;
|
|
13
|
+
source: z.ZodNullable<z.ZodString>;
|
|
14
|
+
marketingSubscribed: z.ZodBoolean;
|
|
15
|
+
suppressionReason: z.ZodNullable<z.ZodString>;
|
|
16
|
+
activatedAt: z.ZodNullable<z.ZodString>;
|
|
17
|
+
createdAt: z.ZodNullable<z.ZodString>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type CustomerData = z.infer<typeof customerSchema>;
|
|
20
|
+
declare const spaceSchema: z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
mode: z.ZodEnum<{
|
|
23
|
+
test: "test";
|
|
24
|
+
live: "live";
|
|
25
|
+
}>;
|
|
26
|
+
enabled: z.ZodBoolean;
|
|
27
|
+
senderName: z.ZodNullable<z.ZodString>;
|
|
28
|
+
senderEmail: z.ZodNullable<z.ZodString>;
|
|
29
|
+
replyTo: z.ZodNullable<z.ZodString>;
|
|
30
|
+
senderVerified: z.ZodBoolean;
|
|
31
|
+
domainRecords: z.ZodNullable<z.ZodString>;
|
|
32
|
+
provisionedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
33
|
+
lastRequestAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
34
|
+
processedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
export type CustomerSpaceData = z.infer<typeof spaceSchema>;
|
|
37
|
+
declare const journeyInputSchema: z.ZodObject<{
|
|
38
|
+
enabled: z.ZodBoolean;
|
|
39
|
+
subject: z.ZodString;
|
|
40
|
+
body: z.ZodString;
|
|
41
|
+
delayMinutes: z.ZodNumber;
|
|
42
|
+
activationEvent: z.ZodString;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type CustomerJourneyInput = z.infer<typeof journeyInputSchema>;
|
|
45
|
+
declare const journeySchema: z.ZodObject<{
|
|
46
|
+
enabled: z.ZodBoolean;
|
|
47
|
+
subject: z.ZodString;
|
|
48
|
+
body: z.ZodString;
|
|
49
|
+
delayMinutes: z.ZodNumber;
|
|
50
|
+
activationEvent: z.ZodString;
|
|
51
|
+
kind: z.ZodEnum<{
|
|
52
|
+
setup: "setup";
|
|
53
|
+
welcome: "welcome";
|
|
54
|
+
purchase: "purchase";
|
|
55
|
+
}>;
|
|
56
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
startsAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
58
|
+
draft: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
59
|
+
enabled: z.ZodBoolean;
|
|
60
|
+
subject: z.ZodString;
|
|
61
|
+
body: z.ZodString;
|
|
62
|
+
delayMinutes: z.ZodNumber;
|
|
63
|
+
activationEvent: z.ZodString;
|
|
64
|
+
}, z.core.$strip>>>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
export type CustomerJourneyData = z.infer<typeof journeySchema>;
|
|
67
|
+
declare const messageSchema: z.ZodObject<{
|
|
68
|
+
id: z.ZodString;
|
|
69
|
+
customerId: z.ZodNullable<z.ZodString>;
|
|
70
|
+
recipient: z.ZodString;
|
|
71
|
+
subject: z.ZodString;
|
|
72
|
+
body: z.ZodString;
|
|
73
|
+
status: z.ZodString;
|
|
74
|
+
error: z.ZodNullable<z.ZodString>;
|
|
75
|
+
dueAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
76
|
+
attemptedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
77
|
+
receivedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
78
|
+
journeyKind: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
79
|
+
setup: "setup";
|
|
80
|
+
welcome: "welcome";
|
|
81
|
+
purchase: "purchase";
|
|
82
|
+
}>>>;
|
|
83
|
+
journeyVersion: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
84
|
+
category: z.ZodOptional<z.ZodEnum<{
|
|
85
|
+
marketing: "marketing";
|
|
86
|
+
service: "service";
|
|
87
|
+
}>>;
|
|
88
|
+
from: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
89
|
+
replyTo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
90
|
+
renderedText: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
91
|
+
unsubscribeUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
92
|
+
createdAt: z.ZodNullable<z.ZodString>;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
export type CustomerMessageData = z.infer<typeof messageSchema>;
|
|
95
|
+
declare const overviewSchema: z.ZodObject<{
|
|
96
|
+
space: z.ZodNullable<z.ZodObject<{
|
|
97
|
+
id: z.ZodString;
|
|
98
|
+
mode: z.ZodEnum<{
|
|
99
|
+
test: "test";
|
|
100
|
+
live: "live";
|
|
101
|
+
}>;
|
|
102
|
+
enabled: z.ZodBoolean;
|
|
103
|
+
senderName: z.ZodNullable<z.ZodString>;
|
|
104
|
+
senderEmail: z.ZodNullable<z.ZodString>;
|
|
105
|
+
replyTo: z.ZodNullable<z.ZodString>;
|
|
106
|
+
senderVerified: z.ZodBoolean;
|
|
107
|
+
domainRecords: z.ZodNullable<z.ZodString>;
|
|
108
|
+
provisionedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
109
|
+
lastRequestAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
110
|
+
processedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
111
|
+
}, z.core.$strip>>;
|
|
112
|
+
customers: z.ZodArray<z.ZodObject<{
|
|
113
|
+
id: z.ZodString;
|
|
114
|
+
externalId: z.ZodString;
|
|
115
|
+
email: z.ZodString;
|
|
116
|
+
name: z.ZodNullable<z.ZodString>;
|
|
117
|
+
source: z.ZodNullable<z.ZodString>;
|
|
118
|
+
marketingSubscribed: z.ZodBoolean;
|
|
119
|
+
suppressionReason: z.ZodNullable<z.ZodString>;
|
|
120
|
+
activatedAt: z.ZodNullable<z.ZodString>;
|
|
121
|
+
createdAt: z.ZodNullable<z.ZodString>;
|
|
122
|
+
}, z.core.$strip>>;
|
|
123
|
+
journeys: z.ZodArray<z.ZodObject<{
|
|
124
|
+
enabled: z.ZodBoolean;
|
|
125
|
+
subject: z.ZodString;
|
|
126
|
+
body: z.ZodString;
|
|
127
|
+
delayMinutes: z.ZodNumber;
|
|
128
|
+
activationEvent: z.ZodString;
|
|
129
|
+
kind: z.ZodEnum<{
|
|
130
|
+
setup: "setup";
|
|
131
|
+
welcome: "welcome";
|
|
132
|
+
purchase: "purchase";
|
|
133
|
+
}>;
|
|
134
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
135
|
+
startsAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
136
|
+
draft: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
137
|
+
enabled: z.ZodBoolean;
|
|
138
|
+
subject: z.ZodString;
|
|
139
|
+
body: z.ZodString;
|
|
140
|
+
delayMinutes: z.ZodNumber;
|
|
141
|
+
activationEvent: z.ZodString;
|
|
142
|
+
}, z.core.$strip>>>;
|
|
143
|
+
}, z.core.$strip>>;
|
|
144
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
145
|
+
id: z.ZodString;
|
|
146
|
+
customerId: z.ZodNullable<z.ZodString>;
|
|
147
|
+
recipient: z.ZodString;
|
|
148
|
+
subject: z.ZodString;
|
|
149
|
+
body: z.ZodString;
|
|
150
|
+
status: z.ZodString;
|
|
151
|
+
error: z.ZodNullable<z.ZodString>;
|
|
152
|
+
dueAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
153
|
+
attemptedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
154
|
+
receivedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
155
|
+
journeyKind: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
156
|
+
setup: "setup";
|
|
157
|
+
welcome: "welcome";
|
|
158
|
+
purchase: "purchase";
|
|
159
|
+
}>>>;
|
|
160
|
+
journeyVersion: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
161
|
+
category: z.ZodOptional<z.ZodEnum<{
|
|
162
|
+
marketing: "marketing";
|
|
163
|
+
service: "service";
|
|
164
|
+
}>>;
|
|
165
|
+
from: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
166
|
+
replyTo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
167
|
+
renderedText: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
168
|
+
unsubscribeUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
169
|
+
createdAt: z.ZodNullable<z.ZodString>;
|
|
170
|
+
}, z.core.$strip>>;
|
|
171
|
+
total: z.ZodNumber;
|
|
172
|
+
messageTotal: z.ZodOptional<z.ZodNumber>;
|
|
173
|
+
events: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
174
|
+
}, z.core.$strip>;
|
|
175
|
+
export type CustomersOverview = z.infer<typeof overviewSchema>;
|
|
176
|
+
export interface IdentifyCustomerInput {
|
|
177
|
+
externalId: string;
|
|
178
|
+
email: string;
|
|
179
|
+
name?: string;
|
|
180
|
+
source?: string;
|
|
181
|
+
billingStatus?: 'unknown' | 'free' | 'paid';
|
|
182
|
+
}
|
|
183
|
+
export interface CustomerEventInput {
|
|
184
|
+
eventId: string;
|
|
185
|
+
name: string;
|
|
186
|
+
occurredAt?: string;
|
|
187
|
+
properties?: Record<string, string | number | boolean | null>;
|
|
188
|
+
}
|
|
189
|
+
export interface SendCustomerMessageInput {
|
|
190
|
+
requestId: string;
|
|
191
|
+
subject: string;
|
|
192
|
+
body: string;
|
|
193
|
+
category: 'service' | 'marketing';
|
|
194
|
+
}
|
|
195
|
+
/** Use only from trusted app servers with a dedicated Customers credential. */
|
|
196
|
+
export declare class CustomerRuntime {
|
|
197
|
+
private readonly client;
|
|
198
|
+
constructor(client: Client);
|
|
199
|
+
identify(input: IdentifyCustomerInput): Promise<CustomerData>;
|
|
200
|
+
linkIdentity(customerId: string, externalId: string): Promise<CustomerData>;
|
|
201
|
+
get(customerId: string): Promise<CustomerData>;
|
|
202
|
+
event(customerId: string, input: CustomerEventInput): Promise<{
|
|
203
|
+
id: string;
|
|
204
|
+
name: string;
|
|
205
|
+
}>;
|
|
206
|
+
preferences(customerId: string, input: {
|
|
207
|
+
subscribed: boolean;
|
|
208
|
+
source: string;
|
|
209
|
+
}): Promise<CustomerData>;
|
|
210
|
+
send(customerId: string, input: SendCustomerMessageInput): Promise<CustomerMessageData>;
|
|
211
|
+
}
|
|
212
|
+
export declare class CustomersApi {
|
|
213
|
+
private readonly client;
|
|
214
|
+
readonly runtime: CustomerRuntime;
|
|
215
|
+
constructor(client: Client);
|
|
216
|
+
forNotebook(notebookId: string): NotebookCustomers;
|
|
217
|
+
}
|
|
218
|
+
export declare class NotebookCustomers {
|
|
219
|
+
private readonly notebookId;
|
|
220
|
+
private readonly client;
|
|
221
|
+
constructor(notebookId: string, client: Client);
|
|
222
|
+
list(mode?: CustomerMode, query?: {
|
|
223
|
+
search?: string;
|
|
224
|
+
page?: number;
|
|
225
|
+
messagePage?: number;
|
|
226
|
+
}): Promise<CustomersOverview>;
|
|
227
|
+
connect(mode?: CustomerMode): Promise<CustomerSpaceData>;
|
|
228
|
+
provision(mode?: CustomerMode): Promise<CustomerSpaceData>;
|
|
229
|
+
disable(mode?: CustomerMode): Promise<CustomerSpaceData>;
|
|
230
|
+
resume(mode?: CustomerMode): Promise<CustomerSpaceData>;
|
|
231
|
+
rotate(mode?: CustomerMode): Promise<CustomerSpaceData>;
|
|
232
|
+
sender(input: {
|
|
233
|
+
senderName: string;
|
|
234
|
+
senderEmail: string;
|
|
235
|
+
replyTo: string;
|
|
236
|
+
}, mode?: CustomerMode): Promise<CustomerSpaceData>;
|
|
237
|
+
verifySender(mode?: CustomerMode): Promise<CustomerSpaceData>;
|
|
238
|
+
journey(kind: CustomerJourneyData['kind'], input: CustomerJourneyInput, mode?: CustomerMode): Promise<CustomerJourneyData>;
|
|
239
|
+
private path;
|
|
240
|
+
}
|
|
241
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const customerModeSchema = z.enum(['test', 'live']);
|
|
3
|
+
export const customerSchema = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
externalId: z.string(),
|
|
6
|
+
email: z.string(),
|
|
7
|
+
name: z.string().nullable(),
|
|
8
|
+
source: z.string().nullable(),
|
|
9
|
+
marketingSubscribed: z.boolean(),
|
|
10
|
+
suppressionReason: z.string().nullable(),
|
|
11
|
+
activatedAt: z.string().nullable(),
|
|
12
|
+
createdAt: z.string().nullable(),
|
|
13
|
+
});
|
|
14
|
+
const spaceSchema = z.object({
|
|
15
|
+
id: z.string(),
|
|
16
|
+
mode: customerModeSchema,
|
|
17
|
+
enabled: z.boolean(),
|
|
18
|
+
senderName: z.string().nullable(),
|
|
19
|
+
senderEmail: z.string().nullable(),
|
|
20
|
+
replyTo: z.string().nullable(),
|
|
21
|
+
senderVerified: z.boolean(),
|
|
22
|
+
domainRecords: z.string().nullable(),
|
|
23
|
+
provisionedAt: z.string().nullable().optional(),
|
|
24
|
+
lastRequestAt: z.string().nullable().optional(),
|
|
25
|
+
processedAt: z.string().nullable().optional(),
|
|
26
|
+
});
|
|
27
|
+
const journeyInputSchema = z.object({
|
|
28
|
+
enabled: z.boolean(),
|
|
29
|
+
subject: z.string(),
|
|
30
|
+
body: z.string(),
|
|
31
|
+
delayMinutes: z.number(),
|
|
32
|
+
activationEvent: z.string(),
|
|
33
|
+
});
|
|
34
|
+
const journeySchema = journeyInputSchema.extend({
|
|
35
|
+
kind: z.enum(['welcome', 'setup', 'purchase']),
|
|
36
|
+
version: z.number().int().optional(),
|
|
37
|
+
startsAt: z.string().nullable().optional(),
|
|
38
|
+
draft: journeyInputSchema.nullable().optional(),
|
|
39
|
+
});
|
|
40
|
+
const messageSchema = z.object({
|
|
41
|
+
id: z.string(),
|
|
42
|
+
customerId: z.string().nullable(),
|
|
43
|
+
recipient: z.string(),
|
|
44
|
+
subject: z.string(),
|
|
45
|
+
body: z.string(),
|
|
46
|
+
status: z.string(),
|
|
47
|
+
error: z.string().nullable(),
|
|
48
|
+
dueAt: z.string().nullable().optional(),
|
|
49
|
+
attemptedAt: z.string().nullable().optional(),
|
|
50
|
+
receivedAt: z.string().nullable().optional(),
|
|
51
|
+
journeyKind: z.enum(['welcome', 'setup', 'purchase']).nullable().optional(),
|
|
52
|
+
journeyVersion: z.number().int().nullable().optional(),
|
|
53
|
+
category: z.enum(['marketing', 'service']).optional(),
|
|
54
|
+
from: z.string().nullable().optional(),
|
|
55
|
+
replyTo: z.string().nullable().optional(),
|
|
56
|
+
renderedText: z.string().nullable().optional(),
|
|
57
|
+
unsubscribeUrl: z.string().nullable().optional(),
|
|
58
|
+
createdAt: z.string().nullable(),
|
|
59
|
+
});
|
|
60
|
+
const overviewSchema = z.object({
|
|
61
|
+
space: spaceSchema.nullable(),
|
|
62
|
+
customers: z.array(customerSchema),
|
|
63
|
+
journeys: z.array(journeySchema),
|
|
64
|
+
messages: z.array(messageSchema),
|
|
65
|
+
total: z.number(),
|
|
66
|
+
messageTotal: z.number().optional(),
|
|
67
|
+
events: z.array(z.string()).optional(),
|
|
68
|
+
});
|
|
69
|
+
/** Use only from trusted app servers with a dedicated Customers credential. */
|
|
70
|
+
export class CustomerRuntime {
|
|
71
|
+
constructor(client) {
|
|
72
|
+
this.client = client;
|
|
73
|
+
}
|
|
74
|
+
async identify(input) {
|
|
75
|
+
return customerSchema.parse((await this.client.post('/platform/customers/runtime/identify', input)).data);
|
|
76
|
+
}
|
|
77
|
+
async linkIdentity(customerId, externalId) {
|
|
78
|
+
return customerSchema.parse((await this.client.post(`/platform/customers/runtime/${encodeURIComponent(customerId)}/identities`, {
|
|
79
|
+
externalId,
|
|
80
|
+
})).data);
|
|
81
|
+
}
|
|
82
|
+
async get(customerId) {
|
|
83
|
+
return customerSchema.parse((await this.client.get(`/platform/customers/runtime/${encodeURIComponent(customerId)}`)).data);
|
|
84
|
+
}
|
|
85
|
+
async event(customerId, input) {
|
|
86
|
+
return z
|
|
87
|
+
.object({ id: z.string(), name: z.string() })
|
|
88
|
+
.parse((await this.client.post(`/platform/customers/runtime/${encodeURIComponent(customerId)}/events`, input)).data);
|
|
89
|
+
}
|
|
90
|
+
async preferences(customerId, input) {
|
|
91
|
+
return customerSchema.parse((await this.client.put(`/platform/customers/runtime/${encodeURIComponent(customerId)}/preferences`, input)).data);
|
|
92
|
+
}
|
|
93
|
+
async send(customerId, input) {
|
|
94
|
+
return messageSchema.parse((await this.client.post(`/platform/customers/runtime/${encodeURIComponent(customerId)}/messages`, input)).data);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export class CustomersApi {
|
|
98
|
+
constructor(client) {
|
|
99
|
+
this.client = client;
|
|
100
|
+
this.runtime = new CustomerRuntime(client);
|
|
101
|
+
}
|
|
102
|
+
forNotebook(notebookId) {
|
|
103
|
+
return new NotebookCustomers(notebookId, this.client);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export class NotebookCustomers {
|
|
107
|
+
constructor(notebookId, client) {
|
|
108
|
+
this.notebookId = notebookId;
|
|
109
|
+
this.client = client;
|
|
110
|
+
}
|
|
111
|
+
async list(mode = 'test', query = {}) {
|
|
112
|
+
return overviewSchema.parse((await this.client.get(`${this.path(mode)}?${new URLSearchParams(Object.entries(query).map(([key, value]) => [key, String(value)])).toString()}`)).data);
|
|
113
|
+
}
|
|
114
|
+
async connect(mode = 'test') {
|
|
115
|
+
return spaceSchema.parse((await this.client.put(this.path(mode), {})).data);
|
|
116
|
+
}
|
|
117
|
+
async provision(mode = 'test') {
|
|
118
|
+
return spaceSchema.parse((await this.client.post(`${this.path(mode)}/provision`, {})).data);
|
|
119
|
+
}
|
|
120
|
+
async disable(mode = 'test') {
|
|
121
|
+
return spaceSchema.parse((await this.client.post(`${this.path(mode)}/disable`, {})).data);
|
|
122
|
+
}
|
|
123
|
+
async resume(mode = 'test') {
|
|
124
|
+
return spaceSchema.parse((await this.client.post(`${this.path(mode)}/resume`, {})).data);
|
|
125
|
+
}
|
|
126
|
+
async rotate(mode = 'test') {
|
|
127
|
+
return spaceSchema.parse((await this.client.post(`${this.path(mode)}/rotate`, {})).data);
|
|
128
|
+
}
|
|
129
|
+
async sender(input, mode = 'test') {
|
|
130
|
+
return spaceSchema.parse((await this.client.put(`${this.path(mode)}/sender`, input)).data);
|
|
131
|
+
}
|
|
132
|
+
async verifySender(mode = 'test') {
|
|
133
|
+
return spaceSchema.parse((await this.client.post(`${this.path(mode)}/sender/verify`, {})).data);
|
|
134
|
+
}
|
|
135
|
+
async journey(kind, input, mode = 'test') {
|
|
136
|
+
return journeySchema.parse((await this.client.put(`${this.path(mode)}/journeys/${kind}`, input)).data);
|
|
137
|
+
}
|
|
138
|
+
path(mode) {
|
|
139
|
+
return `/platform/customers/sandboxes/${encodeURIComponent(this.notebookId)}/${mode}`;
|
|
140
|
+
}
|
|
141
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { AppRuntime, type AppRuntimeOptions } from './app.js';
|
|
2
|
+
export { AppRuntime };
|
|
3
|
+
export type { AppRuntimeOptions };
|
|
1
4
|
import { type Identity } from './identity.js';
|
|
2
5
|
export type { Identity } from './identity.js';
|
|
3
6
|
import { NotebookPublication } from './publication/index.js';
|
|
@@ -18,6 +21,10 @@ import { PublicationApi } from './publication/index.js';
|
|
|
18
21
|
import { ServerApi } from './servers.js';
|
|
19
22
|
import { Feedback } from './feedback.js';
|
|
20
23
|
import { IntegrationApi, SandboxIntegrationApi } from './integrations/index.js';
|
|
24
|
+
import { PaymentsApi, NotebookPayments } from './payments.js';
|
|
25
|
+
import { CustomersApi } from './customers.js';
|
|
26
|
+
export * from './customers.js';
|
|
27
|
+
export * from './payments.js';
|
|
21
28
|
export type { Disposable } from './types.js';
|
|
22
29
|
export { LspConnection } from './lsp.js';
|
|
23
30
|
export { FileChangeFilter, FileChangeType, FileType } from './filesystem.js';
|
|
@@ -172,6 +179,8 @@ export interface NotebookSecretData {
|
|
|
172
179
|
name: string;
|
|
173
180
|
type: SecretType;
|
|
174
181
|
environment: SecretEnvironment;
|
|
182
|
+
managedBy?: string | null;
|
|
183
|
+
inheritOnFork?: boolean;
|
|
175
184
|
createdAt: string | null;
|
|
176
185
|
updatedAt: string | null;
|
|
177
186
|
}
|
|
@@ -179,6 +188,9 @@ export interface NotebookSecretListOptions {
|
|
|
179
188
|
environment?: SecretEnvironment;
|
|
180
189
|
}
|
|
181
190
|
export interface UpsertNotebookSecretInput {
|
|
191
|
+
/** Platform-owned secrets cannot be inherited by forks. Requires a platform credential. */
|
|
192
|
+
managed?: boolean;
|
|
193
|
+
inheritOnFork?: boolean;
|
|
182
194
|
value: string;
|
|
183
195
|
type?: SecretType;
|
|
184
196
|
environment?: SecretEnvironment;
|
|
@@ -329,6 +341,8 @@ declare class ClientImplementation {
|
|
|
329
341
|
readonly publications: PublicationApi;
|
|
330
342
|
readonly servers: ServerApi;
|
|
331
343
|
readonly integrations: IntegrationApi;
|
|
344
|
+
readonly payments: PaymentsApi;
|
|
345
|
+
readonly customers: CustomersApi;
|
|
332
346
|
readonly options: PHPSandboxClientOptions;
|
|
333
347
|
private readonly runtimeTransportValue;
|
|
334
348
|
get runtimeTransport(): RuntimeTransport;
|
|
@@ -364,9 +378,12 @@ export declare class PHPSandbox {
|
|
|
364
378
|
readonly publications: PublicationApi;
|
|
365
379
|
readonly servers: ServerApi;
|
|
366
380
|
readonly integrations: IntegrationApi;
|
|
381
|
+
readonly payments: PaymentsApi;
|
|
382
|
+
readonly customers: CustomersApi;
|
|
367
383
|
private constructor();
|
|
368
384
|
whoami(): Promise<Identity>;
|
|
369
385
|
get runtimeTransport(): RuntimeTransport;
|
|
386
|
+
static app(options?: AppRuntimeOptions): AppRuntime;
|
|
370
387
|
static realtime(token: string, url?: string, options?: PHPSandboxClientOptions): PHPSandbox;
|
|
371
388
|
static rest(token: string, url?: string, options?: PHPSandboxClientOptions): PHPSandbox;
|
|
372
389
|
}
|
|
@@ -399,6 +416,7 @@ export declare class NotebookInstance {
|
|
|
399
416
|
readonly config: Config;
|
|
400
417
|
readonly secrets: NotebookSecrets;
|
|
401
418
|
readonly integrations: SandboxIntegrationApi;
|
|
419
|
+
readonly payments: NotebookPayments;
|
|
402
420
|
readonly preview: NotebookPreview;
|
|
403
421
|
readonly mail: NotebookMail;
|
|
404
422
|
readonly feedback: Feedback;
|
|
@@ -462,6 +480,15 @@ declare class NotebookMail {
|
|
|
462
480
|
private readonly notebookId;
|
|
463
481
|
constructor(client: Client, notebookId: string);
|
|
464
482
|
status(): Promise<NotebookMailStateData>;
|
|
483
|
+
/** Capture a platform-generated development email in the notebook inbox. Never sends externally. */
|
|
484
|
+
capture(input: {
|
|
485
|
+
requestId: string;
|
|
486
|
+
from: string;
|
|
487
|
+
fromName: string;
|
|
488
|
+
to: string;
|
|
489
|
+
subject: string;
|
|
490
|
+
text: string;
|
|
491
|
+
}): Promise<NotebookMailData>;
|
|
465
492
|
enable(): Promise<NotebookMailStateData>;
|
|
466
493
|
disable(): Promise<void>;
|
|
467
494
|
list(options?: NotebookMailListOptions): Promise<PaginatedApiResponse<NotebookMailData>>;
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,8 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
12
|
var _NotebookInstance_instances, _NotebookInstance_initPromise, _NotebookInstance_init;
|
|
13
|
+
import { AppRuntime, resolveAppConfiguration } from './app.js';
|
|
14
|
+
export { AppRuntime };
|
|
13
15
|
import { identitySchema } from './identity.js';
|
|
14
16
|
import { NotebookPublication } from './publication/index.js';
|
|
15
17
|
import { Filesystem } from './filesystem.js';
|
|
@@ -31,6 +33,10 @@ import { RestRuntimeInvoker } from './runtime/rest.js';
|
|
|
31
33
|
import { Feedback } from './feedback.js';
|
|
32
34
|
import { IntegrationApi, SandboxIntegrationApi } from './integrations/index.js';
|
|
33
35
|
import { authenticatedRequest } from './http.js';
|
|
36
|
+
import { PaymentsApi, NotebookPayments } from './payments.js';
|
|
37
|
+
import { CustomersApi } from './customers.js';
|
|
38
|
+
export * from './customers.js';
|
|
39
|
+
export * from './payments.js';
|
|
34
40
|
export { LspConnection } from './lsp.js';
|
|
35
41
|
export { FileChangeFilter, FileChangeType, FileType } from './filesystem.js';
|
|
36
42
|
export { notebookBuiltinServices, notebookKnownServices } from './services.js';
|
|
@@ -86,6 +92,8 @@ class ClientImplementation {
|
|
|
86
92
|
this.notebook = new NotebookApi(this);
|
|
87
93
|
this.servers = new ServerApi(this);
|
|
88
94
|
this.integrations = new IntegrationApi(this);
|
|
95
|
+
this.payments = new PaymentsApi(this);
|
|
96
|
+
this.customers = new CustomersApi(this);
|
|
89
97
|
this.options = { ...options };
|
|
90
98
|
this.runtimeTransportValue = runtimeTransport;
|
|
91
99
|
this.baseUrl = normalizeApiBaseUrl(url);
|
|
@@ -220,6 +228,8 @@ export class PHPSandbox {
|
|
|
220
228
|
this.publications = client.publications;
|
|
221
229
|
this.servers = client.servers;
|
|
222
230
|
this.integrations = client.integrations;
|
|
231
|
+
this.payments = client.payments;
|
|
232
|
+
this.customers = client.customers;
|
|
223
233
|
}
|
|
224
234
|
async whoami() {
|
|
225
235
|
const { data } = await this.client.get('/auth/whoami');
|
|
@@ -232,6 +242,10 @@ export class PHPSandbox {
|
|
|
232
242
|
get runtimeTransport() {
|
|
233
243
|
return this.client.runtimeTransport;
|
|
234
244
|
}
|
|
245
|
+
static app(options = {}) {
|
|
246
|
+
const { token, url, mode } = resolveAppConfiguration(options);
|
|
247
|
+
return new AppRuntime(new ClientImplementation(token, url, {}, 'rest'), token, mode);
|
|
248
|
+
}
|
|
235
249
|
static realtime(token, url = 'https://api.phpsandbox.io/v1', options = {}) {
|
|
236
250
|
return new PHPSandbox(new ClientImplementation(token, url, options));
|
|
237
251
|
}
|
|
@@ -287,6 +301,7 @@ export class NotebookInstance {
|
|
|
287
301
|
this.config = new Config(this);
|
|
288
302
|
this.secrets = new NotebookSecrets(client, this.data.id);
|
|
289
303
|
this.integrations = new SandboxIntegrationApi(this.data.id, client);
|
|
304
|
+
this.payments = new NotebookPayments(this.data.id, client);
|
|
290
305
|
this.preview = new NotebookPreview(client, this.data.id);
|
|
291
306
|
this.mail = new NotebookMail(client, this.data.id);
|
|
292
307
|
this.feedback = new Feedback(client, this.data.id);
|
|
@@ -593,6 +608,11 @@ class NotebookMail {
|
|
|
593
608
|
const response = await this.client.get(`/notebook/${this.notebookId}/mail`);
|
|
594
609
|
return response.data;
|
|
595
610
|
}
|
|
611
|
+
/** Capture a platform-generated development email in the notebook inbox. Never sends externally. */
|
|
612
|
+
async capture(input) {
|
|
613
|
+
const response = await this.client.post(`/notebook/${this.notebookId}/mails`, input);
|
|
614
|
+
return response.data;
|
|
615
|
+
}
|
|
596
616
|
async enable() {
|
|
597
617
|
const response = await this.client.put(`/notebook/${this.notebookId}/mail`);
|
|
598
618
|
return response.data;
|