@unlimited-messaging/sdk 0.1.19 → 0.1.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unlimited-messaging/sdk",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "TypeScript / Node.js SDK for the Unlimited Messaging API — send and receive WhatsApp messages programmatically",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -85,6 +85,13 @@ export declare namespace Webhooks {
85
85
  *
86
86
  * `GET /message` returns the same `sentAt`.
87
87
  *
88
+ * **A change can arrive before the message it changes.** A reaction, an edit or a deletion names its
89
+ * target by `externalId` (`reactedToExternalId`, `edit.externalId`, `deletion.externalId`), and
90
+ * by UnlimitedMessaging id (`reactedToMessageId`, `messageId`) only when that message was already
91
+ * stored. A reaction to a photo typically beats the photo, which is announced once its media is stored:
92
+ * the id is then `null`. Keep such an event and link it later by `externalId`, which the message
93
+ * carries when it arrives (`message.externalId`).
94
+ *
88
95
  * ### Events
89
96
  *
90
97
  * | Type | When |
@@ -93,7 +100,7 @@ export declare namespace Webhooks {
93
100
  * | `message.self_sent` | The account's own phone sent a message by hand, outside the API. Same shape as `message.received`, with `direction: "OUT"` and `fromMe: true`. |
94
101
  * | `message.status` | A message you sent changed status: `SENT`, `DELIVERED`, `READ`, `FAILED` or `UNDELIVERABLE`. Only effective changes fire: a late `DELIVERED` after `READ` does not. |
95
102
  * | `message.reaction` | Someone reacted to a message, or took their reaction back (`removed: true`, empty `emoji`). |
96
- * | `message.edited` | A message was edited. Carries its `externalId`, `newContent`, and `kind`: `text`, or `caption` for the caption of an image, video or document. |
103
+ * | `message.edited` | A message was edited. Carries its `externalId`, `newContent`, and `kind`: `text`, or `caption` for the caption of an image, video or document. Phones encrypt an edit with the original message's key: when it cannot be opened (`error`: `original_secret_missing` for a message the account received before it was linked, `decryption_failed` otherwise), the edit is still announced, with `newContent` and `kind` null, and the stored content is left as it was. |
97
104
  * | `message.deleted` | A message was deleted for everyone, by its author or a group admin (`deletedBy`). The stored message is kept, with `deletedAt` set. |
98
105
  * | `message.history` | Past messages, in batches, for an account linked with `syncHistory` (see below). |
99
106
  * | `group.updated` | A group the account is in changed: members `added`, `removed`, `promoted` or `demoted`, a new `name` or `topic`. |
@@ -118,6 +118,13 @@ const errors = __importStar(require("../../../../errors/index"));
118
118
  *
119
119
  * `GET /message` returns the same `sentAt`.
120
120
  *
121
+ * **A change can arrive before the message it changes.** A reaction, an edit or a deletion names its
122
+ * target by `externalId` (`reactedToExternalId`, `edit.externalId`, `deletion.externalId`), and
123
+ * by UnlimitedMessaging id (`reactedToMessageId`, `messageId`) only when that message was already
124
+ * stored. A reaction to a photo typically beats the photo, which is announced once its media is stored:
125
+ * the id is then `null`. Keep such an event and link it later by `externalId`, which the message
126
+ * carries when it arrives (`message.externalId`).
127
+ *
121
128
  * ### Events
122
129
  *
123
130
  * | Type | When |
@@ -126,7 +133,7 @@ const errors = __importStar(require("../../../../errors/index"));
126
133
  * | `message.self_sent` | The account's own phone sent a message by hand, outside the API. Same shape as `message.received`, with `direction: "OUT"` and `fromMe: true`. |
127
134
  * | `message.status` | A message you sent changed status: `SENT`, `DELIVERED`, `READ`, `FAILED` or `UNDELIVERABLE`. Only effective changes fire: a late `DELIVERED` after `READ` does not. |
128
135
  * | `message.reaction` | Someone reacted to a message, or took their reaction back (`removed: true`, empty `emoji`). |
129
- * | `message.edited` | A message was edited. Carries its `externalId`, `newContent`, and `kind`: `text`, or `caption` for the caption of an image, video or document. |
136
+ * | `message.edited` | A message was edited. Carries its `externalId`, `newContent`, and `kind`: `text`, or `caption` for the caption of an image, video or document. Phones encrypt an edit with the original message's key: when it cannot be opened (`error`: `original_secret_missing` for a message the account received before it was linked, `decryption_failed` otherwise), the edit is still announced, with `newContent` and `kind` null, and the stored content is left as it was. |
130
137
  * | `message.deleted` | A message was deleted for everyone, by its author or a group admin (`deletedBy`). The stored message is kept, with `deletedAt` set. |
131
138
  * | `message.history` | Past messages, in batches, for an account linked with `syncHistory` (see below). |
132
139
  * | `group.updated` | A group the account is in changed: members `added`, `removed`, `promoted` or `demoted`, a new `name` or `topic`. |
@@ -6,7 +6,8 @@ export interface WebhookEventMessageEditedDataEdit {
6
6
  externalId: string;
7
7
  messageId: string | null;
8
8
  newContent: string | null;
9
- kind: UnlimitedMessagingApi.WebhookEventMessageEditedDataEditKind;
9
+ kind: UnlimitedMessagingApi.WebhookEventMessageEditedDataEditKind | null;
10
+ error: UnlimitedMessagingApi.WebhookEventMessageEditedDataEditError | null;
10
11
  editedAt: Date;
11
12
  sender: string | null;
12
13
  senderId: string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export type WebhookEventMessageEditedDataEditError = "original_secret_missing" | "decryption_failed";
5
+ export declare const WebhookEventMessageEditedDataEditError: {
6
+ readonly OriginalSecretMissing: "original_secret_missing";
7
+ readonly DecryptionFailed: "decryption_failed";
8
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WebhookEventMessageEditedDataEditError = void 0;
7
+ exports.WebhookEventMessageEditedDataEditError = {
8
+ OriginalSecretMissing: "original_secret_missing",
9
+ DecryptionFailed: "decryption_failed",
10
+ };
@@ -38,6 +38,7 @@ export * from "./WebhookEventMessageReactionData";
38
38
  export * from "./WebhookEventMessageReaction";
39
39
  export * from "./WebhookEventMessageEditedType";
40
40
  export * from "./WebhookEventMessageEditedDataEditKind";
41
+ export * from "./WebhookEventMessageEditedDataEditError";
41
42
  export * from "./WebhookEventMessageEditedDataEdit";
42
43
  export * from "./WebhookEventMessageEditedDataChannelType";
43
44
  export * from "./WebhookEventMessageEditedDataChannelAccount";
@@ -54,6 +54,7 @@ __exportStar(require("./WebhookEventMessageReactionData"), exports);
54
54
  __exportStar(require("./WebhookEventMessageReaction"), exports);
55
55
  __exportStar(require("./WebhookEventMessageEditedType"), exports);
56
56
  __exportStar(require("./WebhookEventMessageEditedDataEditKind"), exports);
57
+ __exportStar(require("./WebhookEventMessageEditedDataEditError"), exports);
57
58
  __exportStar(require("./WebhookEventMessageEditedDataEdit"), exports);
58
59
  __exportStar(require("./WebhookEventMessageEditedDataChannelType"), exports);
59
60
  __exportStar(require("./WebhookEventMessageEditedDataChannelAccount"), exports);
@@ -5,13 +5,15 @@ import * as serializers from "../index";
5
5
  import * as UnlimitedMessagingApi from "../../api/index";
6
6
  import * as core from "../../core";
7
7
  import { WebhookEventMessageEditedDataEditKind } from "./WebhookEventMessageEditedDataEditKind";
8
+ import { WebhookEventMessageEditedDataEditError } from "./WebhookEventMessageEditedDataEditError";
8
9
  export declare const WebhookEventMessageEditedDataEdit: core.serialization.ObjectSchema<serializers.WebhookEventMessageEditedDataEdit.Raw, UnlimitedMessagingApi.WebhookEventMessageEditedDataEdit>;
9
10
  export declare namespace WebhookEventMessageEditedDataEdit {
10
11
  interface Raw {
11
12
  externalId: string;
12
13
  messageId: string | null;
13
14
  newContent: string | null;
14
- kind: WebhookEventMessageEditedDataEditKind.Raw;
15
+ kind: WebhookEventMessageEditedDataEditKind.Raw | null;
16
+ error: WebhookEventMessageEditedDataEditError.Raw | null;
15
17
  editedAt: string;
16
18
  sender: string | null;
17
19
  senderId: string;
@@ -39,11 +39,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.WebhookEventMessageEditedDataEdit = void 0;
40
40
  const core = __importStar(require("../../core"));
41
41
  const WebhookEventMessageEditedDataEditKind_1 = require("./WebhookEventMessageEditedDataEditKind");
42
+ const WebhookEventMessageEditedDataEditError_1 = require("./WebhookEventMessageEditedDataEditError");
42
43
  exports.WebhookEventMessageEditedDataEdit = core.serialization.object({
43
44
  externalId: core.serialization.string(),
44
45
  messageId: core.serialization.string().nullable(),
45
46
  newContent: core.serialization.string().nullable(),
46
- kind: WebhookEventMessageEditedDataEditKind_1.WebhookEventMessageEditedDataEditKind,
47
+ kind: WebhookEventMessageEditedDataEditKind_1.WebhookEventMessageEditedDataEditKind.nullable(),
48
+ error: WebhookEventMessageEditedDataEditError_1.WebhookEventMessageEditedDataEditError.nullable(),
47
49
  editedAt: core.serialization.date(),
48
50
  sender: core.serialization.string().nullable(),
49
51
  senderId: core.serialization.string(),
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as serializers from "../index";
5
+ import * as UnlimitedMessagingApi from "../../api/index";
6
+ import * as core from "../../core";
7
+ export declare const WebhookEventMessageEditedDataEditError: core.serialization.Schema<serializers.WebhookEventMessageEditedDataEditError.Raw, UnlimitedMessagingApi.WebhookEventMessageEditedDataEditError>;
8
+ export declare namespace WebhookEventMessageEditedDataEditError {
9
+ type Raw = "original_secret_missing" | "decryption_failed";
10
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.WebhookEventMessageEditedDataEditError = void 0;
40
+ const core = __importStar(require("../../core"));
41
+ exports.WebhookEventMessageEditedDataEditError = core.serialization.enum_(["original_secret_missing", "decryption_failed"]);
@@ -38,6 +38,7 @@ export * from "./WebhookEventMessageReactionData";
38
38
  export * from "./WebhookEventMessageReaction";
39
39
  export * from "./WebhookEventMessageEditedType";
40
40
  export * from "./WebhookEventMessageEditedDataEditKind";
41
+ export * from "./WebhookEventMessageEditedDataEditError";
41
42
  export * from "./WebhookEventMessageEditedDataEdit";
42
43
  export * from "./WebhookEventMessageEditedDataChannelType";
43
44
  export * from "./WebhookEventMessageEditedDataChannelAccount";
@@ -54,6 +54,7 @@ __exportStar(require("./WebhookEventMessageReactionData"), exports);
54
54
  __exportStar(require("./WebhookEventMessageReaction"), exports);
55
55
  __exportStar(require("./WebhookEventMessageEditedType"), exports);
56
56
  __exportStar(require("./WebhookEventMessageEditedDataEditKind"), exports);
57
+ __exportStar(require("./WebhookEventMessageEditedDataEditError"), exports);
57
58
  __exportStar(require("./WebhookEventMessageEditedDataEdit"), exports);
58
59
  __exportStar(require("./WebhookEventMessageEditedDataChannelType"), exports);
59
60
  __exportStar(require("./WebhookEventMessageEditedDataChannelAccount"), exports);