@isnap/sdk 1.2.0-next.86 → 1.2.0-next.87
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/CHANGELOG.md +3 -1
- package/README.md +2 -0
- package/dist/generated/openapi.d.ts +3 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +4 -2
- package/dist/version.js.map +1 -1
- package/dist/webhooks/types.d.ts +43 -3
- package/dist/webhooks/types.d.ts.map +1 -1
- package/dist/webhooks/types.js +6 -0
- package/dist/webhooks/types.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,7 +10,8 @@ All notable changes to `@isnap/sdk` will be documented in this file. The format
|
|
|
10
10
|
- Resource classes: `messages`, `chats`, `lines`, `lookup`, `attachments`, `webhooks`, `byod`, `trial`.
|
|
11
11
|
- `attachments.upload()` — transparent 3-step (POST register → presigned R2 PUT → poll until `ready`) with 5 GB cap and four typed failure modes.
|
|
12
12
|
- Cursor pagination as `AsyncIterable` with optional `AbortSignal` on `messages.list`, `webhooks.deliveries`, `webhooks.events`.
|
|
13
|
-
- Webhook helpers: `verifyWebhook` (HMAC-SHA256 + 5min replay window + multi-secret rotation), `parseWebhookEvent`, prefix-based type guards (`isMessageEvent`, `isReactionEvent`, `isLineEvent`, `isTypingIndicatorEvent`, `isTrialEvent`, `isPreOrderEvent`).
|
|
13
|
+
- Webhook helpers: `verifyWebhook` (HMAC-SHA256 + 5min replay window + multi-secret rotation), `parseWebhookEvent`, prefix-based type guards (`isMessageEvent`, `isReactionEvent`, `isLineEvent`, `isTypingIndicatorEvent`, `isTrialEvent`, `isPreOrderEvent`, `isBindingEvent`, `isAdminEvent`).
|
|
14
|
+
- Webhook event-type aliases re-synced with the backend catalog (additive, MINOR): `MessageEventType` gains `message.fallback_triggered` (iMessage→SMS/RCS degradation) and `LineEventType` gains `line.capability_changed`; two new families ship complete — `BindingEventType`/`BindingEvent`/`isBindingEvent` (`binding.released`, shared-plan contact-binding release) and `AdminEventType`/`AdminEvent`/`isAdminEvent` (`webhook.test`, the suspended-state probe). All eight aliases are now locked to the generated `WebhookEventName` enum by a compile-time parity assertion (`src/webhooks/catalog-parity.test.ts`), so a future catalog change — including a brand-new family — fails `bun run typecheck` instead of silently stranding consumers who cast `event.event_type as MessageEventType` for exhaustiveness. Runtime narrowing is unchanged: the guards already prefix-matched every one of these.
|
|
14
15
|
- Error hierarchy mirroring contract §6: `APIError` + 13 subclasses, all carrying `status`, `code`, `traceId`, `requestId`. Connection failures surface as `APIConnectionError` with native `Error.cause`.
|
|
15
16
|
- Generated TypeScript types (`src/generated/openapi.d.ts`) compiled from the backend's frozen `openapi.json`.
|
|
16
17
|
- `maxRetryDelayMs` client option (default `60_000`) — ceiling on how long a single retry may sleep. A 429 whose `retry_after` exceeds it is rethrown as `RateLimitError` (with `retryAfter` intact) instead of slept through, so a day-scale `Retry-After` such as the trial rebind cap can no longer park a call for hours. The exponential-backoff branch is clamped to the same ceiling.
|
|
@@ -19,6 +20,7 @@ All notable changes to `@isnap/sdk` will be documented in this file. The format
|
|
|
19
20
|
- `src/generated/openapi.d.ts` is now generated from the **published** contract. `packages/backend/openapi.json` carries only the partner-facing `/v1/*` surface, so the internal operator routes (`/admin`, `/va`, `/farm-ops`, `/kam`, `/auth`, …) and the bridge-only `/v1/device/*` contract — plus every schema reachable only from them — are no longer emitted into the SDK types. Those routes are the dashboard, the ops back-office and the device bridge; none of them is part of the partner contract this SDK wraps, and no `ISnapClient` method referenced their types, so no documented method changes shape.
|
|
20
21
|
|
|
21
22
|
### Fixed
|
|
23
|
+
- `User-Agent` misreported the SDK version. `SDK_VERSION` was left at `1.0.0` through `package.json`'s bumps to `1.1.0` and `1.2.0`, and it is the sole input to the header, so every request from the published package mis-identified its own version to server, proxy and CDN logs. `SDK_VERSION` now tracks `package.json` (`1.2.0`), and `src/version.test.ts` reads the published version off disk and fails the build the next time they disagree.
|
|
22
24
|
- **`ReactionEvent.data` is now the flat contract §4.3.2 payload** (`parent_message_id`, `reaction_id`, `reaction_type`, `reaction_emoji`, `direction`, a direction-appropriate handle, and one of `received_at` / `added_at` / `removed_at`). The previous `{ reaction: Reaction }` nesting never matched any delivery, so the documented happy path (`event.data.reaction.id`) always threw `TypeError` — with TypeScript's blessing. `reaction_type` now also admits `custom` and `reaction_emoji` is nullable, neither of which the borrowed REST `Reaction` schema could express. The new `ReactionEventData` is a union discriminated on `direction`, so reading `from_handle` on an outbound payload (or `actor_handle` on an inbound one) is a compile error — **source-breaking for consumers that read those keys without narrowing**, though no such consumer could have been working at runtime. No wire, schema, or `api_version` change: the producers were already correct.
|
|
23
25
|
- `packages/sdk/examples/` is now linted and typechecked. `lint` covers `examples/`, and they are in `tsconfig.json` itself — so the single `tsc --noEmit` pass sees them and, more importantly, so does the editor: a mistake in an example is red as you type rather than minutes later in CI, which is how these defects reached a published tarball in the first place. `tsconfig.build.json` carries its own `include` + `rootDir` so emit stays bounded to `src/` no matter how the editor program grows, and `dist/` is byte-identical to before. That gap had let four defects ship in reference code: `handle-webhook.ts` imported the non-existent `isTypingEvent` (it is `isTypingIndicatorEvent`) so the example died at import, dereferenced `event.data.reaction.id`, and dropped every `pre_order.*` delivery into its unhandled `else` (no `isPreOrderEvent` branch); `upload-attachment.ts` sent `attachment_ids` instead of the contract's `attachments`.
|
|
24
26
|
- Regenerated `src/generated/openapi.d.ts` against API `1.3.0`. `lookup.check()` now types the `202` pending trio (`pending`, `probe_id`, `retry_after`), so the re-poll branch is reachable without a cast.
|
package/README.md
CHANGED
|
@@ -160,6 +160,8 @@ Throws `WebhookSignatureError` on missing headers, expired timestamp (5min toler
|
|
|
160
160
|
|
|
161
161
|
If verification happens behind a trusted gateway, use `parseWebhookEvent(rawBody)` to skip HMAC and just type the envelope.
|
|
162
162
|
|
|
163
|
+
One guard per event family, each narrowing `event.data` and matching on the wire prefix: `isMessageEvent`, `isReactionEvent`, `isLineEvent`, `isTypingIndicatorEvent`, `isTrialEvent`, `isPreOrderEvent`, `isBindingEvent` (`binding.*`) and `isAdminEvent` (`webhook.*`, the `webhook.test` probe). They prefix-match, so a future event in a known family still narrows without an SDK upgrade. The matching `*EventType` aliases (`MessageEventType`, …) enumerate today's catalog for exhaustive `switch` statements and are kept in lockstep with the backend by a compile-time parity check. A full worked handler lives in [`examples/handle-webhook.ts`](./examples/handle-webhook.ts).
|
|
164
|
+
|
|
163
165
|
## Errors
|
|
164
166
|
|
|
165
167
|
All API errors extend `APIError` and carry `status`, `code`, `message`, `traceId`, `requestId`. Subclasses match the §6 contract codes:
|
|
@@ -6095,6 +6095,9 @@ export interface components {
|
|
|
6095
6095
|
runtime_capabilities: {
|
|
6096
6096
|
[key: string]: "active" | "degraded" | "disabled";
|
|
6097
6097
|
} | null;
|
|
6098
|
+
/** @enum {string|null} */
|
|
6099
|
+
device_state: "online" | "degraded" | "offline" | "initializing" | "blocked" | null;
|
|
6100
|
+
storage_free_bytes: number | null;
|
|
6098
6101
|
};
|
|
6099
6102
|
LineConfigEnvelope: {
|
|
6100
6103
|
/** @enum {boolean} */
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,6 @@ export type { CreateWebhookBody, ListDeliveriesQuery, ListEventsQuery, UpdateWeb
|
|
|
28
28
|
export { parseWebhookEvent } from './webhooks/parse.js';
|
|
29
29
|
export { verifyWebhook } from './webhooks/verify.js';
|
|
30
30
|
export type { VerifyWebhookOptions } from './webhooks/verify.js';
|
|
31
|
-
export { isLineEvent, isMessageEvent, isPreOrderEvent, isReactionEvent, isTrialEvent, isTypingIndicatorEvent } from './webhooks/types.js';
|
|
32
|
-
export type { LineEvent, LineEventType, MessageEvent, MessageEventType, PreOrderEvent, PreOrderEventType, ReactionEvent, ReactionEventData, ReactionEventType, TrialEvent, TrialEventType, TypingIndicatorEvent, TypingIndicatorEventType, WebhookEvent, WebhookEventBase } from './webhooks/types.js';
|
|
31
|
+
export { isAdminEvent, isBindingEvent, isLineEvent, isMessageEvent, isPreOrderEvent, isReactionEvent, isTrialEvent, isTypingIndicatorEvent } from './webhooks/types.js';
|
|
32
|
+
export type { AdminEvent, AdminEventType, BindingEvent, BindingEventType, LineEvent, LineEventType, MessageEvent, MessageEventType, PreOrderEvent, PreOrderEventType, ReactionEvent, ReactionEventData, ReactionEventType, TrialEvent, TrialEventType, TypingIndicatorEvent, TypingIndicatorEventType, WebhookEvent, WebhookEventBase } from './webhooks/types.js';
|
|
33
33
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AACvF,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAA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,gBAAgB,EAChB,cAAc,EACf,MAAM,0BAA0B,CAAA;AACjC,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,eAAe,EAChB,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EACV,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACpB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EACL,WAAW,EACX,cAAc,EACd,eAAe,EACf,eAAe,EACf,YAAY,EACZ,sBAAsB,EACvB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,SAAS,EACT,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,EACZ,gBAAgB,EACjB,MAAM,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,qBAAq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/index.js
CHANGED
|
@@ -13,5 +13,5 @@ export { TrialResource } from './resources/trial.js';
|
|
|
13
13
|
export { WebhooksResource } from './resources/webhooks.js';
|
|
14
14
|
export { parseWebhookEvent } from './webhooks/parse.js';
|
|
15
15
|
export { verifyWebhook } from './webhooks/verify.js';
|
|
16
|
-
export { isLineEvent, isMessageEvent, isPreOrderEvent, isReactionEvent, isTrialEvent, isTypingIndicatorEvent } from './webhooks/types.js';
|
|
16
|
+
export { isAdminEvent, isBindingEvent, isLineEvent, isMessageEvent, isPreOrderEvent, isReactionEvent, isTrialEvent, isTypingIndicatorEvent } from './webhooks/types.js';
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAKpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,C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,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAiF1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,WAAW,EACX,cAAc,EACd,eAAe,EACf,eAAe,EACf,YAAY,EACZ,sBAAsB,EACvB,MAAM,qBAAqB,CAAA"}
|
package/dist/version.d.ts
CHANGED
package/dist/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,UAAU,CAAA;AAelC,eAAO,MAAM,eAAe,UAAU,CAAA"}
|
package/dist/version.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// SDK version. Bumped INDEPENDENTLY of the API contract version per
|
|
2
2
|
// industry standard (Stripe, Twilio, OpenAI, AWS): SDK semver tracks SDK
|
|
3
3
|
// changes (new methods, retry logic, type fixes), API semver tracks the
|
|
4
|
-
// contract surface.
|
|
5
|
-
|
|
4
|
+
// contract surface. Hand-maintained: no build or publish step derives this
|
|
5
|
+
// from `package.json`, so it MUST be bumped in the same commit as the
|
|
6
|
+
// `version` field there. `src/version.test.ts` fails CI when they disagree.
|
|
7
|
+
export const SDK_VERSION = '1.2.0';
|
|
6
8
|
// Minimum API version the SDK considers compatible. Reference-only
|
|
7
9
|
// today: the client does NOT yet fetch `/v1/version` at first request,
|
|
8
10
|
// and there is no `IncompatibleApiVersionError` thrown on a lower
|
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,yEAAyE;AACzE,wEAAwE;AACxE,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,yEAAyE;AACzE,wEAAwE;AACxE,2EAA2E;AAC3E,sEAAsE;AACtE,4EAA4E;AAC5E,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA;AAElC,mEAAmE;AACnE,uEAAuE;AACvE,kEAAkE;AAClE,wEAAwE;AACxE,kEAAkE;AAClE,sEAAsE;AACtE,EAAE;AACF,yEAAyE;AACzE,sEAAsE;AACtE,mEAAmE;AACnE,iDAAiD;AACjD,uEAAuE;AACvE,6DAA6D;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAA"}
|
package/dist/webhooks/types.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface WebhookEventBase {
|
|
|
13
13
|
trace_id?: string;
|
|
14
14
|
data: Record<string, unknown>;
|
|
15
15
|
}
|
|
16
|
-
export type MessageEventType = 'message.queued' | 'message.scheduled' | 'message.sent' | 'message.delivered' | 'message.failed' | 'message.received' | 'message.read' | 'message.cancelled';
|
|
16
|
+
export type MessageEventType = 'message.queued' | 'message.scheduled' | 'message.sent' | 'message.delivered' | 'message.failed' | 'message.received' | 'message.read' | 'message.cancelled' | 'message.fallback_triggered';
|
|
17
17
|
export interface MessageEvent extends WebhookEventBase {
|
|
18
18
|
event_type: `message.${string}`;
|
|
19
19
|
data: {
|
|
@@ -65,7 +65,7 @@ export interface ReactionEvent extends WebhookEventBase {
|
|
|
65
65
|
event_type: `reaction.${string}`;
|
|
66
66
|
data: ReactionEventData;
|
|
67
67
|
}
|
|
68
|
-
export type LineEventType = 'line.connected' | 'line.disconnected' | 'line.offline' | 'line.degraded' | 'line.apple_id_flagged' | 'line.quota_warning' | 'line.quota_exceeded';
|
|
68
|
+
export type LineEventType = 'line.connected' | 'line.disconnected' | 'line.offline' | 'line.degraded' | 'line.apple_id_flagged' | 'line.quota_warning' | 'line.quota_exceeded' | 'line.capability_changed';
|
|
69
69
|
/**
|
|
70
70
|
* `data` is intentionally typed as `Record<string, unknown>` until the
|
|
71
71
|
* contract pins per-event-type field shapes. Today's payloads vary by
|
|
@@ -107,6 +107,44 @@ export interface PreOrderEvent extends WebhookEventBase {
|
|
|
107
107
|
event_type: `pre_order.${string}`;
|
|
108
108
|
data: Record<string, unknown>;
|
|
109
109
|
}
|
|
110
|
+
export type BindingEventType = 'binding.released';
|
|
111
|
+
/**
|
|
112
|
+
* Shared-plan contact-binding lifecycle (contract §4.3.7). Fires on the
|
|
113
|
+
* VIRTUAL line when a `(virtual line, contact handle)` leg is torn down.
|
|
114
|
+
* `data` carries `{ line_id, contact_handle, outbound_number (nullable),
|
|
115
|
+
* released_at, reason: 'inactivity' | 'carrier_terminated' }` — the
|
|
116
|
+
* `outbound_number` being the physical line's number the contact knew,
|
|
117
|
+
* since that association is exactly what the release severs.
|
|
118
|
+
*
|
|
119
|
+
* Left as `Record<string, unknown>` for the same reason as `LineEvent`:
|
|
120
|
+
* `event_type` is the template literal `binding.${string}` so the guard
|
|
121
|
+
* keeps prefix-matching, and a concrete `data` shape here would mistype
|
|
122
|
+
* any future `binding.*` event. There is deliberately no
|
|
123
|
+
* `binding.created` — the first outbound to a new contact already
|
|
124
|
+
* signals it via `message.queued`.
|
|
125
|
+
*/
|
|
126
|
+
export interface BindingEvent extends WebhookEventBase {
|
|
127
|
+
event_type: `binding.${string}`;
|
|
128
|
+
data: Record<string, unknown>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Administrative synthetic probe — the suspended-state health check that
|
|
132
|
+
* decides whether a disabled subscription can be resumed. Not a partner
|
|
133
|
+
* business event, but consumers do receive it, so it gets an alias and a
|
|
134
|
+
* guard like every other family.
|
|
135
|
+
*
|
|
136
|
+
* Named `Admin*` after the backend's `ADMIN_EVENTS` catalog constant
|
|
137
|
+
* while the wire prefix is `webhook.` (and `isAdminEvent` matches that
|
|
138
|
+
* prefix). The names deliberately differ: `WebhookEvent*` is already
|
|
139
|
+
* taken by the union and the envelope base, so an accurate
|
|
140
|
+
* `WebhookEventType` here would collide with both.
|
|
141
|
+
*/
|
|
142
|
+
export type AdminEventType = 'webhook.test';
|
|
143
|
+
/** See `LineEvent` for why `data` is loose. */
|
|
144
|
+
export interface AdminEvent extends WebhookEventBase {
|
|
145
|
+
event_type: `webhook.${string}`;
|
|
146
|
+
data: Record<string, unknown>;
|
|
147
|
+
}
|
|
110
148
|
/**
|
|
111
149
|
* Discriminated union over the typed event families plus `WebhookEventBase`
|
|
112
150
|
* as the catch-all for event types not yet known to this SDK version.
|
|
@@ -121,12 +159,14 @@ export interface PreOrderEvent extends WebhookEventBase {
|
|
|
121
159
|
* }
|
|
122
160
|
* ```
|
|
123
161
|
*/
|
|
124
|
-
export type WebhookEvent = MessageEvent | ReactionEvent | LineEvent | TypingIndicatorEvent | TrialEvent | PreOrderEvent | WebhookEventBase;
|
|
162
|
+
export type WebhookEvent = MessageEvent | ReactionEvent | LineEvent | TypingIndicatorEvent | TrialEvent | PreOrderEvent | BindingEvent | AdminEvent | WebhookEventBase;
|
|
125
163
|
export declare function isMessageEvent(event: WebhookEventBase): event is MessageEvent;
|
|
126
164
|
export declare function isReactionEvent(event: WebhookEventBase): event is ReactionEvent;
|
|
127
165
|
export declare function isLineEvent(event: WebhookEventBase): event is LineEvent;
|
|
128
166
|
export declare function isTypingIndicatorEvent(event: WebhookEventBase): event is TypingIndicatorEvent;
|
|
129
167
|
export declare function isTrialEvent(event: WebhookEventBase): event is TrialEvent;
|
|
130
168
|
export declare function isPreOrderEvent(event: WebhookEventBase): event is PreOrderEvent;
|
|
169
|
+
export declare function isBindingEvent(event: WebhookEventBase): event is BindingEvent;
|
|
170
|
+
export declare function isAdminEvent(event: WebhookEventBase): event is AdminEvent;
|
|
131
171
|
export {};
|
|
132
172
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAErE;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAErE;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AA0BD,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,mBAAmB,GACnB,cAAc,GACd,mBAAmB,GACnB,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,mBAAmB,GAMnB,4BAA4B,CAAA;AAEhC,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACpD,UAAU,EAAE,WAAW,MAAM,EAAE,CAAA;IAC/B,IAAI,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAA;CAC3B;AAID,MAAM,MAAM,iBAAiB,GACzB,gBAAgB,GAChB,mBAAmB,GACnB,kBAAkB,CAAA;AAEtB,wEAAw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KAAK,IAAI,aAAa,CAE/E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,SAAS,CAEvE;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,gBAAgB,GACtB,KAAK,IAAI,oBAAoB,CAE/B;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,UAAU,CAEzE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,aAAa,CAE/E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,YAAY,CAE7E;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,UAAU,CAEzE"}
|
package/dist/webhooks/types.js
CHANGED
|
@@ -17,4 +17,10 @@ export function isTrialEvent(event) {
|
|
|
17
17
|
export function isPreOrderEvent(event) {
|
|
18
18
|
return event.event_type.startsWith('pre_order.');
|
|
19
19
|
}
|
|
20
|
+
export function isBindingEvent(event) {
|
|
21
|
+
return event.event_type.startsWith('binding.');
|
|
22
|
+
}
|
|
23
|
+
export function isAdminEvent(event) {
|
|
24
|
+
return event.event_type.startsWith('webhook.');
|
|
25
|
+
}
|
|
20
26
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"AAsRA,6EAA6E;AAE7E,MAAM,UAAU,cAAc,CAAC,KAAuB;IACpD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;AAChD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAuB;IACrD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;AACjD,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;AAC7C,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,KAAuB;IAEvB,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAA;AACzD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAuB;IAClD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;AAC9C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAuB;IACrD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;AAClD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAuB;IACpD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;AAChD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAuB;IAClD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;AAChD,CAAC"}
|