spectrum-ts 4.2.0 → 5.0.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 +29 -67
- package/dist/authoring.d.ts +1 -6
- package/dist/authoring.js +2 -36
- package/dist/elysia.d.ts +1 -94
- package/dist/elysia.js +2 -15
- package/dist/express.d.ts +1 -62
- package/dist/express.js +2 -19
- package/dist/hono.d.ts +1 -64
- package/dist/hono.js +2 -11
- package/dist/index.d.ts +1 -2851
- package/dist/index.js +2 -3763
- package/dist/manifest.json +5 -5
- package/dist/providers/imessage/index.d.ts +1 -222
- package/dist/providers/imessage/index.js +2 -25
- package/dist/providers/index.d.ts +6 -19
- package/dist/providers/index.js +6 -34
- package/dist/providers/slack/index.d.ts +1 -46
- package/dist/providers/slack/index.js +2 -11
- package/dist/providers/telegram/index.d.ts +1 -45
- package/dist/providers/telegram/index.js +2 -13
- package/dist/providers/terminal/index.d.ts +1 -119
- package/dist/providers/terminal/index.js +2 -13
- package/dist/providers/whatsapp-business/index.d.ts +1 -27
- package/dist/providers/whatsapp-business/index.js +2 -14
- package/package.json +11 -38
- package/dist/attachment-CnivEhr6.d.ts +0 -29
- package/dist/authoring-b9AhXgPI.d.ts +0 -304
- package/dist/chunk-2D27WW5B.js +0 -63
- package/dist/chunk-34FQGGD7.js +0 -34
- package/dist/chunk-3GEJYGZK.js +0 -84
- package/dist/chunk-5XEFJBN2.js +0 -197
- package/dist/chunk-6UZFVXQF.js +0 -374
- package/dist/chunk-A37PM5N2.js +0 -91
- package/dist/chunk-ARL2NOBO.js +0 -887
- package/dist/chunk-B52VPQO3.js +0 -1379
- package/dist/chunk-DMPDLSFU.js +0 -864
- package/dist/chunk-FAIFTUV2.js +0 -139
- package/dist/chunk-LZXPLXZF.js +0 -35
- package/dist/chunk-N6THJDZV.js +0 -929
- package/dist/chunk-NLMQ75LH.js +0 -2980
- package/dist/chunk-UXAKIXVM.js +0 -409
- package/dist/chunk-WXLQNANA.js +0 -539
- package/dist/chunk-ZR3TKZMT.js +0 -129
- package/dist/read-C4uvozGX.d.ts +0 -53
- package/dist/types-CyfLJXgu.d.ts +0 -1530
- package/dist/types-ZgFTj5hJ.d.ts +0 -87
package/dist/types-ZgFTj5hJ.d.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { c as ProjectData, d as Store, e as ProviderMessageRecord, S as Space, M as Message } from './types-CyfLJXgu.js';
|
|
2
|
-
|
|
3
|
-
declare const FUSOR_EVENT_BRAND: unique symbol;
|
|
4
|
-
interface FusorEvent<TName extends string = string, TData = unknown> {
|
|
5
|
-
readonly data: TData;
|
|
6
|
-
readonly name: TName;
|
|
7
|
-
readonly [FUSOR_EVENT_BRAND]: true;
|
|
8
|
-
}
|
|
9
|
-
declare function fusorEvent<TName extends string, TData>(name: TName, data: TData): FusorEvent<TName, TData>;
|
|
10
|
-
declare function isFusorEvent(value: unknown): value is FusorEvent;
|
|
11
|
-
|
|
12
|
-
interface FusorVerifyRequest {
|
|
13
|
-
headers: Record<string, string>;
|
|
14
|
-
method: string;
|
|
15
|
-
path: string;
|
|
16
|
-
rawBody: Uint8Array;
|
|
17
|
-
}
|
|
18
|
-
type FusorVerify<TPayload = unknown> = (req: FusorVerifyRequest) => TPayload | Promise<TPayload>;
|
|
19
|
-
interface FusorReply {
|
|
20
|
-
body?: string | Uint8Array;
|
|
21
|
-
headers?: Record<string, string>;
|
|
22
|
-
status?: number;
|
|
23
|
-
}
|
|
24
|
-
type FusorRespond = (reply: FusorReply) => void;
|
|
25
|
-
interface FusorMessagesCtx<TPayload, TConfig = unknown> {
|
|
26
|
-
/** Parsed provider config (`z.infer` of the platform's config schema). */
|
|
27
|
-
config: TConfig;
|
|
28
|
-
payload: TPayload;
|
|
29
|
-
/**
|
|
30
|
-
* Spectrum Cloud project metadata, fetched once at `Spectrum()` init.
|
|
31
|
-
* `undefined` for local-only setups (no `projectId`/`projectSecret`). Read
|
|
32
|
-
* project-level toggles from `projectConfig.profile.<key>`.
|
|
33
|
-
*/
|
|
34
|
-
projectConfig: ProjectData | undefined;
|
|
35
|
-
respond: FusorRespond;
|
|
36
|
-
/** Per-platform in-memory key/value store, shared with the rest of the platform. */
|
|
37
|
-
store: Store;
|
|
38
|
-
}
|
|
39
|
-
type FusorMessagesReturn = ProviderMessageRecord | FusorEvent | (ProviderMessageRecord | FusorEvent)[] | undefined;
|
|
40
|
-
type FusorMessages<TPayload, TConfig = unknown> = (ctx: FusorMessagesCtx<TPayload, TConfig>) => FusorMessagesReturn | Promise<FusorMessagesReturn>;
|
|
41
|
-
declare const FUSOR_BRAND: unique symbol;
|
|
42
|
-
interface FusorClient<TPayload = unknown> {
|
|
43
|
-
readonly platform: string;
|
|
44
|
-
readonly verify: FusorVerify<TPayload>;
|
|
45
|
-
readonly [FUSOR_BRAND]: true;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Request-scoped handler invoked once per inbound message that
|
|
49
|
-
* `spectrum.webhook()` resolves. Receives the same fully-built `[space,
|
|
50
|
-
* message]` pair that `spectrum.messages` yields.
|
|
51
|
-
*
|
|
52
|
-
* Runs **fire-and-forget**: it is dispatched after the HTTP response (the
|
|
53
|
-
* platform's `respond()` reply) has already been computed, so its outcome never
|
|
54
|
-
* affects the response, and a throw is caught + logged rather than surfaced —
|
|
55
|
-
* mirroring the body of a `for await (… of spectrum.messages)` loop.
|
|
56
|
-
*
|
|
57
|
-
* On a long-running server the event loop keeps the handler alive. On
|
|
58
|
-
* serverless/edge runtimes the function may be frozen once the response is
|
|
59
|
-
* returned, so keeping background work alive is the caller's responsibility —
|
|
60
|
-
* the usual pattern is to enqueue the work and process it in a separate worker.
|
|
61
|
-
*/
|
|
62
|
-
type WebhookHandler = (space: Space, message: Message) => void | Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Raw webhook input for HTTP servers without Web `Request`/`Response` (Express,
|
|
65
|
-
* raw Node). `body` MUST be the exact bytes POSTed — never a re-encoded
|
|
66
|
-
* JSON/text body — so both the protobuf decode (fusor) and the HMAC
|
|
67
|
-
* verification (native Spectrum webhook) work.
|
|
68
|
-
*
|
|
69
|
-
* `headers` ARE read for **native Spectrum webhooks**: `X-Spectrum-Signature` /
|
|
70
|
-
* `X-Spectrum-Timestamp` carry the HMAC verified against
|
|
71
|
-
* `Spectrum({ webhookSecret })`, and the signature header also selects the
|
|
72
|
-
* native path. For **fusor** envelopes they are ignored (authenticity is the
|
|
73
|
-
* per-platform `verify()` reading the inner reconstructed request). The natural
|
|
74
|
-
* `{ headers: req.headers, body: req.body }` shape works for both.
|
|
75
|
-
*/
|
|
76
|
-
interface WebhookRawRequest {
|
|
77
|
-
body: Uint8Array | ArrayBuffer;
|
|
78
|
-
headers?: Record<string, string>;
|
|
79
|
-
}
|
|
80
|
-
/** Raw webhook result, written back by the caller as the HTTP response. */
|
|
81
|
-
interface WebhookRawResult {
|
|
82
|
-
body: Uint8Array;
|
|
83
|
-
headers: Record<string, string>;
|
|
84
|
-
status: number;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export { type FusorClient as F, type WebhookHandler as W, type FusorVerify as a, type FusorMessages as b, type WebhookRawRequest as c, type WebhookRawResult as d, type FusorEvent as e, type FusorMessagesCtx as f, type FusorMessagesReturn as g, type FusorReply as h, type FusorRespond as i, type FusorVerifyRequest as j, fusorEvent as k, isFusorEvent as l };
|