@dinghy-chat/sdk 0.37.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 CHANGED
@@ -148,7 +148,7 @@ It reconnects when the server ends the stream or the connection drops, and resum
148
148
  | `conversations` | `list`, `search`, `messages`, `reply`, `note`, `upload`, `receipt`, `close`, `reopen`, `snooze`, `assign`, `addLabel`, `removeLabel`, `handoff`, `typing` |
149
149
  | `contacts` | `upsert` |
150
150
  | `outboundMessages` | `send`, `get`, `list`, `cancel` |
151
- | `campaigns` | `list`, `get`, `create`, `upsert`, `update`, `pause`, `resume`, `end`, `results`, `send` |
151
+ | `campaigns` | `list`, `get`, `create`, `upsert`, `update`, `pause`, `resume`, `end`, `delete`, `results`, `send` |
152
152
  | `labels` | `list` |
153
153
  | `savedReplies` | `list` |
154
154
  | `analytics` | `get` |
package/dist/index.js CHANGED
@@ -280,6 +280,11 @@ function campaigns(request) {
280
280
  /** Starts a draft, or resumes a paused campaign. */
281
281
  resume: status("/resume"),
282
282
  end: status("/end"),
283
+ /** Deletes a campaign that never sent a message. One that sent can only end. */
284
+ delete: (ref) => {
285
+ const { at, path } = campaignAt(ref, "");
286
+ return request("delete", at, { path });
287
+ },
283
288
  results: (ref, query = {}) => {
284
289
  const { at, path } = campaignAt(ref, "/results");
285
290
  return request("get", at, { path, query });
package/dist/openapi.d.ts CHANGED
@@ -3518,6 +3518,83 @@ export interface paths {
3518
3518
  patch?: never;
3519
3519
  trace?: never;
3520
3520
  };
3521
+ "/v1/operator/workspaces/{workspaceId}/contact-fields": {
3522
+ parameters: {
3523
+ query?: never;
3524
+ header?: never;
3525
+ path?: never;
3526
+ cookie?: never;
3527
+ };
3528
+ /**
3529
+ * The attribute keys and event names of the contacts seen last
3530
+ * @description It reads the 1,000 contacts seen last, and leaves out test visitors. Each list is A to Z, with at most 200 names.
3531
+ */
3532
+ get: {
3533
+ parameters: {
3534
+ query?: never;
3535
+ header?: never;
3536
+ path: {
3537
+ workspaceId: string;
3538
+ };
3539
+ cookie?: never;
3540
+ };
3541
+ requestBody?: never;
3542
+ responses: {
3543
+ /** @description The attributes and events */
3544
+ 200: {
3545
+ headers: {
3546
+ [name: string]: unknown;
3547
+ };
3548
+ content: {
3549
+ "application/json": components["schemas"]["ContactFields"];
3550
+ };
3551
+ };
3552
+ /** @description unauthorized: no valid session, or the API key is not valid or was revoked. two_factor_required: the session has not passed two-step sign-in yet */
3553
+ 401: {
3554
+ headers: {
3555
+ [name: string]: unknown;
3556
+ };
3557
+ content: {
3558
+ "application/json": components["schemas"]["Error"];
3559
+ };
3560
+ };
3561
+ /** @description payment_required: the workspace waits for payment */
3562
+ 402: {
3563
+ headers: {
3564
+ [name: string]: unknown;
3565
+ };
3566
+ content: {
3567
+ "application/json": components["schemas"]["Error"];
3568
+ };
3569
+ };
3570
+ /** @description not_found: it does not exist, or this operator is not a member */
3571
+ 404: {
3572
+ headers: {
3573
+ [name: string]: unknown;
3574
+ };
3575
+ content: {
3576
+ "application/json": components["schemas"]["Error"];
3577
+ };
3578
+ };
3579
+ /** @description too_many_requests: over an API key's 300 requests a minute. Retry after `retry-after` */
3580
+ 429: {
3581
+ headers: {
3582
+ [name: string]: unknown;
3583
+ };
3584
+ content: {
3585
+ "application/json": components["schemas"]["Error"];
3586
+ };
3587
+ };
3588
+ };
3589
+ };
3590
+ put?: never;
3591
+ post?: never;
3592
+ delete?: never;
3593
+ options?: never;
3594
+ head?: never;
3595
+ patch?: never;
3596
+ trace?: never;
3597
+ };
3521
3598
  "/v1/operator/workspaces/{workspaceId}/outbound-messages": {
3522
3599
  parameters: {
3523
3600
  query?: never;
@@ -4815,7 +4892,118 @@ export interface paths {
4815
4892
  };
4816
4893
  put?: never;
4817
4894
  post?: never;
4818
- delete?: never;
4895
+ /**
4896
+ * Delete a campaign that never sent a message, such as a draft. Owners, admins and Full access keys only
4897
+ * @description Test messages do not count. A campaign that sent keeps its results, so it can only end.
4898
+ */
4899
+ delete: {
4900
+ parameters: {
4901
+ query?: never;
4902
+ header?: never;
4903
+ path: {
4904
+ workspaceId: string;
4905
+ /** @description The campaign's ID */
4906
+ ref: string;
4907
+ };
4908
+ cookie?: never;
4909
+ };
4910
+ requestBody?: never;
4911
+ responses: {
4912
+ /** @description Deleted */
4913
+ 200: {
4914
+ headers: {
4915
+ [name: string]: unknown;
4916
+ };
4917
+ content: {
4918
+ "application/json": {
4919
+ /** @enum {boolean} */
4920
+ ok: true;
4921
+ };
4922
+ };
4923
+ };
4924
+ /** @description invalid_request: the request is not valid */
4925
+ 400: {
4926
+ headers: {
4927
+ [name: string]: unknown;
4928
+ };
4929
+ content: {
4930
+ "application/json": components["schemas"]["Error"];
4931
+ };
4932
+ };
4933
+ /** @description unauthorized: no valid session, or the API key is not valid or was revoked. two_factor_required: the session has not passed two-step sign-in yet */
4934
+ 401: {
4935
+ headers: {
4936
+ [name: string]: unknown;
4937
+ };
4938
+ content: {
4939
+ "application/json": components["schemas"]["Error"];
4940
+ };
4941
+ };
4942
+ /** @description payment_required: the workspace waits for payment. read_only: the subscription ended, so operators can only read and export */
4943
+ 402: {
4944
+ headers: {
4945
+ [name: string]: unknown;
4946
+ };
4947
+ content: {
4948
+ "application/json": components["schemas"]["Error"];
4949
+ };
4950
+ };
4951
+ /** @description forbidden: this role may not do this. suspended: the server's admin suspended the workspace. origin_not_allowed: the request did not come from this server's own pages */
4952
+ 403: {
4953
+ headers: {
4954
+ [name: string]: unknown;
4955
+ };
4956
+ content: {
4957
+ "application/json": components["schemas"]["Error"];
4958
+ };
4959
+ };
4960
+ /** @description not_found: it does not exist, or this operator is not a member */
4961
+ 404: {
4962
+ headers: {
4963
+ [name: string]: unknown;
4964
+ };
4965
+ content: {
4966
+ "application/json": components["schemas"]["Error"];
4967
+ };
4968
+ };
4969
+ /** @description campaign_live: pause or end the campaign first. campaign_sent: the campaign sent messages */
4970
+ 409: {
4971
+ headers: {
4972
+ [name: string]: unknown;
4973
+ };
4974
+ content: {
4975
+ "application/json": components["schemas"]["Error"];
4976
+ };
4977
+ };
4978
+ /** @description too_large: the body is over 64 KB */
4979
+ 413: {
4980
+ headers: {
4981
+ [name: string]: unknown;
4982
+ };
4983
+ content: {
4984
+ "application/json": components["schemas"]["Error"];
4985
+ };
4986
+ };
4987
+ /** @description too_many_requests: over an API key's 300 requests a minute. Retry after `retry-after` */
4988
+ 429: {
4989
+ headers: {
4990
+ [name: string]: unknown;
4991
+ };
4992
+ content: {
4993
+ "application/json": components["schemas"]["Error"];
4994
+ };
4995
+ };
4996
+ /** @description busy: the workspace is busy. Retry after `retry-after` */
4997
+ 503: {
4998
+ headers: {
4999
+ [name: string]: unknown;
5000
+ };
5001
+ content: {
5002
+ "application/json": components["schemas"]["Error"];
5003
+ };
5004
+ };
5005
+ };
5006
+ };
4819
5007
  options?: never;
4820
5008
  head?: never;
4821
5009
  /**
@@ -5007,7 +5195,118 @@ export interface paths {
5007
5195
  };
5008
5196
  put?: never;
5009
5197
  post?: never;
5010
- delete?: never;
5198
+ /**
5199
+ * Delete a campaign that never sent a message, such as a draft. Owners, admins and Full access keys only
5200
+ * @description Test messages do not count. A campaign that sent keeps its results, so it can only end.
5201
+ */
5202
+ delete: {
5203
+ parameters: {
5204
+ query?: never;
5205
+ header?: never;
5206
+ path: {
5207
+ workspaceId: string;
5208
+ /** @description The campaign's key */
5209
+ ref: string;
5210
+ };
5211
+ cookie?: never;
5212
+ };
5213
+ requestBody?: never;
5214
+ responses: {
5215
+ /** @description Deleted */
5216
+ 200: {
5217
+ headers: {
5218
+ [name: string]: unknown;
5219
+ };
5220
+ content: {
5221
+ "application/json": {
5222
+ /** @enum {boolean} */
5223
+ ok: true;
5224
+ };
5225
+ };
5226
+ };
5227
+ /** @description invalid_request: the request is not valid */
5228
+ 400: {
5229
+ headers: {
5230
+ [name: string]: unknown;
5231
+ };
5232
+ content: {
5233
+ "application/json": components["schemas"]["Error"];
5234
+ };
5235
+ };
5236
+ /** @description unauthorized: no valid session, or the API key is not valid or was revoked. two_factor_required: the session has not passed two-step sign-in yet */
5237
+ 401: {
5238
+ headers: {
5239
+ [name: string]: unknown;
5240
+ };
5241
+ content: {
5242
+ "application/json": components["schemas"]["Error"];
5243
+ };
5244
+ };
5245
+ /** @description payment_required: the workspace waits for payment. read_only: the subscription ended, so operators can only read and export */
5246
+ 402: {
5247
+ headers: {
5248
+ [name: string]: unknown;
5249
+ };
5250
+ content: {
5251
+ "application/json": components["schemas"]["Error"];
5252
+ };
5253
+ };
5254
+ /** @description forbidden: this role may not do this. suspended: the server's admin suspended the workspace. origin_not_allowed: the request did not come from this server's own pages */
5255
+ 403: {
5256
+ headers: {
5257
+ [name: string]: unknown;
5258
+ };
5259
+ content: {
5260
+ "application/json": components["schemas"]["Error"];
5261
+ };
5262
+ };
5263
+ /** @description not_found: it does not exist, or this operator is not a member */
5264
+ 404: {
5265
+ headers: {
5266
+ [name: string]: unknown;
5267
+ };
5268
+ content: {
5269
+ "application/json": components["schemas"]["Error"];
5270
+ };
5271
+ };
5272
+ /** @description campaign_live: pause or end the campaign first. campaign_sent: the campaign sent messages */
5273
+ 409: {
5274
+ headers: {
5275
+ [name: string]: unknown;
5276
+ };
5277
+ content: {
5278
+ "application/json": components["schemas"]["Error"];
5279
+ };
5280
+ };
5281
+ /** @description too_large: the body is over 64 KB */
5282
+ 413: {
5283
+ headers: {
5284
+ [name: string]: unknown;
5285
+ };
5286
+ content: {
5287
+ "application/json": components["schemas"]["Error"];
5288
+ };
5289
+ };
5290
+ /** @description too_many_requests: over an API key's 300 requests a minute. Retry after `retry-after` */
5291
+ 429: {
5292
+ headers: {
5293
+ [name: string]: unknown;
5294
+ };
5295
+ content: {
5296
+ "application/json": components["schemas"]["Error"];
5297
+ };
5298
+ };
5299
+ /** @description busy: the workspace is busy. Retry after `retry-after` */
5300
+ 503: {
5301
+ headers: {
5302
+ [name: string]: unknown;
5303
+ };
5304
+ content: {
5305
+ "application/json": components["schemas"]["Error"];
5306
+ };
5307
+ };
5308
+ };
5309
+ };
5011
5310
  options?: never;
5012
5311
  head?: never;
5013
5312
  /**
@@ -7333,7 +7632,7 @@ export interface components {
7333
7632
  Error: {
7334
7633
  error: {
7335
7634
  /** @enum {string} */
7336
- code: "already_active" | "already_member" | "bad_endpoint" | "bad_origin" | "bad_signature" | "billing_unavailable" | "blocked" | "bots_paused" | "busy" | "campaign_ended" | "campaign_key_taken" | "campaign_not_live" | "check_unavailable" | "checkout_retry_later" | "conversation_closed" | "drafts_text_only" | "email_mismatch" | "email_rejected" | "email_taken" | "email_unavailable" | "forbidden" | "human_handling" | "grant_limit" | "internal_error" | "invalid_client" | "invalid_name" | "invalid_redirect_uri" | "invalid_reply_to" | "invalid_request" | "invite_invalid" | "invite_other_email" | "label_limit" | "label_name_taken" | "last_owner" | "last_workspace" | "manual_review" | "length_required" | "link_invalid" | "mail_failed" | "message_seen" | "name_mismatch" | "no_setup" | "no_customer" | "no_email" | "no_removal" | "not_a_member" | "not_an_image" | "not_found" | "operator_limit" | "opted_out" | "origin_not_allowed" | "payment_pending" | "payment_required" | "push_unavailable" | "read_only" | "removal_blocked" | "removal_not_needed" | "saved_reply_limit" | "saved_reply_shortcut_taken" | "send_as_member_required" | "send_email_required" | "send_mode_required" | "signed_in" | "sign_in_again" | "site_limit" | "storage_full" | "suspended" | "team_changed" | "too_large" | "too_many_attempts" | "too_many_pixels" | "too_many_requests" | "too_many_streams" | "too_many_waiting" | "too_slow" | "two_factor_off" | "two_factor_on" | "two_factor_required" | "two_factor_unreadable" | "type_not_allowed" | "unauthorized" | "unsupported_media_type" | "webhook_limit" | "workspace_deleted" | "wrong_code";
7635
+ code: "already_active" | "already_member" | "bad_endpoint" | "bad_origin" | "bad_signature" | "billing_unavailable" | "blocked" | "bots_paused" | "busy" | "campaign_ended" | "campaign_key_taken" | "campaign_live" | "campaign_not_live" | "campaign_sent" | "check_unavailable" | "checkout_retry_later" | "conversation_closed" | "drafts_text_only" | "email_mismatch" | "email_rejected" | "email_taken" | "email_unavailable" | "forbidden" | "human_handling" | "grant_limit" | "internal_error" | "invalid_client" | "invalid_name" | "invalid_redirect_uri" | "invalid_reply_to" | "invalid_request" | "invite_invalid" | "invite_other_email" | "label_limit" | "label_name_taken" | "last_owner" | "last_workspace" | "manual_review" | "length_required" | "link_invalid" | "mail_failed" | "message_seen" | "name_mismatch" | "no_setup" | "no_customer" | "no_email" | "no_removal" | "not_a_member" | "not_an_image" | "not_found" | "operator_limit" | "opted_out" | "origin_not_allowed" | "payment_pending" | "payment_required" | "push_unavailable" | "read_only" | "removal_blocked" | "removal_not_needed" | "saved_reply_limit" | "saved_reply_shortcut_taken" | "send_as_member_required" | "send_email_required" | "send_mode_required" | "signed_in" | "sign_in_again" | "site_limit" | "storage_full" | "suspended" | "team_changed" | "too_large" | "too_many_attempts" | "too_many_pixels" | "too_many_requests" | "too_many_streams" | "too_many_waiting" | "too_slow" | "two_factor_off" | "two_factor_on" | "two_factor_required" | "two_factor_unreadable" | "type_not_allowed" | "unauthorized" | "unsupported_media_type" | "webhook_limit" | "workspace_deleted" | "wrong_code";
7337
7636
  message: string;
7338
7637
  requestId?: string;
7339
7638
  };
@@ -7970,6 +8269,22 @@ export interface components {
7970
8269
  viewedAt: string;
7971
8270
  }[];
7972
8271
  };
8272
+ ContactFields: {
8273
+ attributes: {
8274
+ name: string;
8275
+ /** @description How many of those contacts have it */
8276
+ contacts: number;
8277
+ /** @description When one of them was last seen */
8278
+ lastSeenAt: string;
8279
+ }[];
8280
+ events: {
8281
+ name: string;
8282
+ /** @description How many of those contacts have it */
8283
+ contacts: number;
8284
+ /** @description When one of them last did it */
8285
+ lastAt: string;
8286
+ }[];
8287
+ };
7973
8288
  OutboundMessage: {
7974
8289
  id: string;
7975
8290
  /** @enum {string} */
@@ -304,6 +304,10 @@ export declare function campaigns(request: Request): {
304
304
  } | {
305
305
  campaign: components["schemas"]["Campaign"];
306
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
+ }>;
307
311
  results: (ref: CampaignRef, query?: QueryOf<ByKey<"/results">, "get">) => Promise<{
308
312
  days: {
309
313
  entered: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dinghy-chat/sdk",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "description": "Call the Dinghy API from your server, with typed methods, webhook checks and host tokens.",
5
5
  "type": "module",
6
6
  "license": "MIT",