@dinghy-chat/sdk 0.36.0 → 0.38.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 +28 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +52 -0
- package/dist/openapi.d.ts +3231 -105
- package/dist/resources.d.ts +101 -3
- package/package.json +1 -1
package/dist/resources.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ declare const CONVERSATION: "/v1/operator/workspaces/{workspaceId}/conversations
|
|
|
19
19
|
declare const MESSAGES: "/v1/operator/workspaces/{workspaceId}/conversations/{conversationId}/messages";
|
|
20
20
|
declare const CONTACT_BY_USER: "/v1/operator/workspaces/{workspaceId}/contacts/by-user/{userId}";
|
|
21
21
|
declare const OUTBOUND: "/v1/operator/workspaces/{workspaceId}/outbound-messages";
|
|
22
|
+
declare const CAMPAIGNS: "/v1/operator/workspaces/{workspaceId}/campaigns";
|
|
22
23
|
declare const WEBHOOKS: "/v1/operator/workspaces/{workspaceId}/webhooks";
|
|
23
24
|
declare const WEBHOOK: "/v1/operator/workspaces/{workspaceId}/webhooks/{webhookId}";
|
|
24
25
|
type Reply = Send<Omit<Body<typeof MESSAGES, "post">, "note" | "mentions">>;
|
|
@@ -253,6 +254,103 @@ export declare function outboundMessages(request: Request): {
|
|
|
253
254
|
outboundMessage: components["schemas"]["OutboundMessage"];
|
|
254
255
|
}>;
|
|
255
256
|
};
|
|
257
|
+
/** A campaign by its key, as a repository keeps it, or by its ID. */
|
|
258
|
+
type CampaignRef = string | {
|
|
259
|
+
id: string;
|
|
260
|
+
};
|
|
261
|
+
type ByKey<T extends string> = `${typeof CAMPAIGNS}/by-key/{ref}${T}`;
|
|
262
|
+
type Definition = Body<typeof CAMPAIGNS, "post">;
|
|
263
|
+
export declare function campaigns(request: Request): {
|
|
264
|
+
list: (query?: QueryOf<typeof CAMPAIGNS, "get">) => Promise<{
|
|
265
|
+
campaigns: components["schemas"]["Campaign"][];
|
|
266
|
+
sentLastWeek: number;
|
|
267
|
+
}>;
|
|
268
|
+
get: (ref: CampaignRef) => Promise<{
|
|
269
|
+
campaign: components["schemas"]["Campaign"];
|
|
270
|
+
}>;
|
|
271
|
+
/** A new campaign, as a draft. Its key must be free. */
|
|
272
|
+
create: (body: Definition) => Promise<{
|
|
273
|
+
campaign: components["schemas"]["Campaign"];
|
|
274
|
+
}>;
|
|
275
|
+
/** Creates the campaign with this key as a draft, or replaces it. Its status stays. */
|
|
276
|
+
upsert: ({ key, ...rest }: Definition) => Promise<{
|
|
277
|
+
campaign: components["schemas"]["Campaign"];
|
|
278
|
+
} | {
|
|
279
|
+
campaign: components["schemas"]["Campaign"];
|
|
280
|
+
}>;
|
|
281
|
+
/** Replaces the parts the patch gives. */
|
|
282
|
+
update: (ref: CampaignRef, body: Body<ByKey<"">, "patch">) => Promise<{
|
|
283
|
+
campaign: components["schemas"]["Campaign"];
|
|
284
|
+
}>;
|
|
285
|
+
pause: (ref: CampaignRef) => Promise<{
|
|
286
|
+
campaign: components["schemas"]["Campaign"];
|
|
287
|
+
} | {
|
|
288
|
+
campaign: components["schemas"]["Campaign"];
|
|
289
|
+
} | {
|
|
290
|
+
campaign: components["schemas"]["Campaign"];
|
|
291
|
+
}>;
|
|
292
|
+
/** Starts a draft, or resumes a paused campaign. */
|
|
293
|
+
resume: (ref: CampaignRef) => Promise<{
|
|
294
|
+
campaign: components["schemas"]["Campaign"];
|
|
295
|
+
} | {
|
|
296
|
+
campaign: components["schemas"]["Campaign"];
|
|
297
|
+
} | {
|
|
298
|
+
campaign: components["schemas"]["Campaign"];
|
|
299
|
+
}>;
|
|
300
|
+
end: (ref: CampaignRef) => Promise<{
|
|
301
|
+
campaign: components["schemas"]["Campaign"];
|
|
302
|
+
} | {
|
|
303
|
+
campaign: components["schemas"]["Campaign"];
|
|
304
|
+
} | {
|
|
305
|
+
campaign: components["schemas"]["Campaign"];
|
|
306
|
+
}>;
|
|
307
|
+
/** Deletes a campaign that never sent a message. One that sent can only end. */
|
|
308
|
+
delete: (ref: CampaignRef) => Promise<{
|
|
309
|
+
ok: true;
|
|
310
|
+
}>;
|
|
311
|
+
results: (ref: CampaignRef, query?: QueryOf<ByKey<"/results">, "get">) => Promise<{
|
|
312
|
+
days: {
|
|
313
|
+
entered: number;
|
|
314
|
+
sent: number;
|
|
315
|
+
delivered: number;
|
|
316
|
+
read: number;
|
|
317
|
+
replied: number;
|
|
318
|
+
dismissed: number;
|
|
319
|
+
goalReached: number;
|
|
320
|
+
conversationsStarted: number;
|
|
321
|
+
clicks: {
|
|
322
|
+
[key: string]: number;
|
|
323
|
+
};
|
|
324
|
+
day: string;
|
|
325
|
+
variant: string | null;
|
|
326
|
+
}[];
|
|
327
|
+
variants: {
|
|
328
|
+
entered: number;
|
|
329
|
+
sent: number;
|
|
330
|
+
delivered: number;
|
|
331
|
+
read: number;
|
|
332
|
+
replied: number;
|
|
333
|
+
dismissed: number;
|
|
334
|
+
goalReached: number;
|
|
335
|
+
conversationsStarted: number;
|
|
336
|
+
clicks: {
|
|
337
|
+
[key: string]: number;
|
|
338
|
+
};
|
|
339
|
+
variant: string | null;
|
|
340
|
+
}[];
|
|
341
|
+
}>;
|
|
342
|
+
/** Runs a live campaign for one person: it skips the audience and the trigger. */
|
|
343
|
+
send: (ref: CampaignRef, input: Send<Body<ByKey<"/send">, "post">>) => Promise<{
|
|
344
|
+
outboundMessage: components["schemas"]["OutboundMessage"];
|
|
345
|
+
} | {
|
|
346
|
+
outboundMessage: components["schemas"]["OutboundMessage"];
|
|
347
|
+
}>;
|
|
348
|
+
};
|
|
349
|
+
/** Counts an event on a contact, from your server. */
|
|
350
|
+
export declare const track: (request: Request) => (body: Body<`${typeof IN_WORKSPACE}/track`, "post">) => Promise<{
|
|
351
|
+
visitorId: string;
|
|
352
|
+
counted: boolean;
|
|
353
|
+
}>;
|
|
256
354
|
type NewWebhook = Body<typeof WEBHOOKS, "post">;
|
|
257
355
|
/** The webhook routes, which need a Full access (setup) key. */
|
|
258
356
|
export declare function webhookRoutes(request: Request): {
|
|
@@ -262,7 +360,7 @@ export declare function webhookRoutes(request: Request): {
|
|
|
262
360
|
create: (body: NewWebhook) => Promise<{
|
|
263
361
|
id: string;
|
|
264
362
|
url: string;
|
|
265
|
-
events: ("conversation.created" | "message.created" | "message.updated" | "message.deleted" | "conversation.closed" | "conversation.reopened" | "conversation.assigned" | "conversation.handoff" | "conversation.given_back" | "conversation.labeled" | "outbound_message.sent" | "outbound_message.delivered" | "outbound_message.read" | "outbound_message.clicked" | "outbound_message.replied" | "outbound_message.dismissed" | "outbound_message.cancelled" | "outbound_message.expired")[];
|
|
363
|
+
events: ("conversation.created" | "message.created" | "message.updated" | "message.deleted" | "conversation.closed" | "conversation.reopened" | "conversation.assigned" | "conversation.handoff" | "conversation.given_back" | "conversation.labeled" | "outbound_message.sent" | "outbound_message.delivered" | "outbound_message.read" | "outbound_message.clicked" | "outbound_message.replied" | "outbound_message.dismissed" | "outbound_message.cancelled" | "outbound_message.expired" | "campaign.updated")[];
|
|
266
364
|
enabled: boolean;
|
|
267
365
|
createdBy: {
|
|
268
366
|
kind: "operator" | "key";
|
|
@@ -275,7 +373,7 @@ export declare function webhookRoutes(request: Request): {
|
|
|
275
373
|
update: (webhookId: string, body: Body<typeof WEBHOOK, "patch">) => Promise<{
|
|
276
374
|
id: string;
|
|
277
375
|
url: string;
|
|
278
|
-
events: ("conversation.created" | "message.created" | "message.updated" | "message.deleted" | "conversation.closed" | "conversation.reopened" | "conversation.assigned" | "conversation.handoff" | "conversation.given_back" | "conversation.labeled" | "outbound_message.sent" | "outbound_message.delivered" | "outbound_message.read" | "outbound_message.clicked" | "outbound_message.replied" | "outbound_message.dismissed" | "outbound_message.cancelled" | "outbound_message.expired")[];
|
|
376
|
+
events: ("conversation.created" | "message.created" | "message.updated" | "message.deleted" | "conversation.closed" | "conversation.reopened" | "conversation.assigned" | "conversation.handoff" | "conversation.given_back" | "conversation.labeled" | "outbound_message.sent" | "outbound_message.delivered" | "outbound_message.read" | "outbound_message.clicked" | "outbound_message.replied" | "outbound_message.dismissed" | "outbound_message.cancelled" | "outbound_message.expired" | "campaign.updated")[];
|
|
279
377
|
enabled: boolean;
|
|
280
378
|
createdBy: {
|
|
281
379
|
kind: "operator" | "key";
|
|
@@ -289,7 +387,7 @@ export declare function webhookRoutes(request: Request): {
|
|
|
289
387
|
rotateSecret: (webhookId: string) => Promise<{
|
|
290
388
|
id: string;
|
|
291
389
|
url: string;
|
|
292
|
-
events: ("conversation.created" | "message.created" | "message.updated" | "message.deleted" | "conversation.closed" | "conversation.reopened" | "conversation.assigned" | "conversation.handoff" | "conversation.given_back" | "conversation.labeled" | "outbound_message.sent" | "outbound_message.delivered" | "outbound_message.read" | "outbound_message.clicked" | "outbound_message.replied" | "outbound_message.dismissed" | "outbound_message.cancelled" | "outbound_message.expired")[];
|
|
390
|
+
events: ("conversation.created" | "message.created" | "message.updated" | "message.deleted" | "conversation.closed" | "conversation.reopened" | "conversation.assigned" | "conversation.handoff" | "conversation.given_back" | "conversation.labeled" | "outbound_message.sent" | "outbound_message.delivered" | "outbound_message.read" | "outbound_message.clicked" | "outbound_message.replied" | "outbound_message.dismissed" | "outbound_message.cancelled" | "outbound_message.expired" | "campaign.updated")[];
|
|
293
391
|
enabled: boolean;
|
|
294
392
|
createdBy: {
|
|
295
393
|
kind: "operator" | "key";
|