spectrum-ts 4.1.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.
Files changed (46) hide show
  1. package/README.md +29 -67
  2. package/dist/authoring.d.ts +1 -6
  3. package/dist/authoring.js +2 -36
  4. package/dist/elysia.d.ts +1 -0
  5. package/dist/elysia.js +2 -0
  6. package/dist/express.d.ts +1 -0
  7. package/dist/express.js +2 -0
  8. package/dist/hono.d.ts +1 -0
  9. package/dist/hono.js +2 -0
  10. package/dist/index.d.ts +1 -2837
  11. package/dist/index.js +2 -3373
  12. package/dist/manifest.json +5 -5
  13. package/dist/providers/imessage/index.d.ts +1 -222
  14. package/dist/providers/imessage/index.js +2 -25
  15. package/dist/providers/index.d.ts +6 -19
  16. package/dist/providers/index.js +6 -34
  17. package/dist/providers/slack/index.d.ts +1 -46
  18. package/dist/providers/slack/index.js +2 -11
  19. package/dist/providers/telegram/index.d.ts +1 -45
  20. package/dist/providers/telegram/index.js +2 -13
  21. package/dist/providers/terminal/index.d.ts +1 -119
  22. package/dist/providers/terminal/index.js +2 -13
  23. package/dist/providers/whatsapp-business/index.d.ts +1 -27
  24. package/dist/providers/whatsapp-business/index.js +2 -14
  25. package/package.json +23 -26
  26. package/dist/attachment-CnivEhr6.d.ts +0 -29
  27. package/dist/authoring-b9AhXgPI.d.ts +0 -304
  28. package/dist/chunk-2D27WW5B.js +0 -63
  29. package/dist/chunk-34FQGGD7.js +0 -34
  30. package/dist/chunk-3GEJYGZK.js +0 -84
  31. package/dist/chunk-3KWFP4L2.js +0 -864
  32. package/dist/chunk-5XEFJBN2.js +0 -197
  33. package/dist/chunk-6UZFVXQF.js +0 -374
  34. package/dist/chunk-A37PM5N2.js +0 -91
  35. package/dist/chunk-B52VPQO3.js +0 -1379
  36. package/dist/chunk-DMT6BFJV.js +0 -2980
  37. package/dist/chunk-FAIFTUV2.js +0 -139
  38. package/dist/chunk-IM5ADDZS.js +0 -887
  39. package/dist/chunk-LZXPLXZF.js +0 -35
  40. package/dist/chunk-U3QQ56YZ.js +0 -929
  41. package/dist/chunk-UXAKIXVM.js +0 -409
  42. package/dist/chunk-WXLQNANA.js +0 -539
  43. package/dist/chunk-ZR3TKZMT.js +0 -129
  44. package/dist/read-C4uvozGX.d.ts +0 -53
  45. package/dist/types-BIta6Kxi.d.ts +0 -82
  46. package/dist/types-CyfLJXgu.d.ts +0 -1530
@@ -1,82 +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 fusor POSTed — never a re-encoded
66
- * JSON/text body — so the protobuf decode works. `headers` are accepted (so the
67
- * natural `{ headers: req.headers, body: req.body }` shape keeps working) but are
68
- * not read: inbound authenticity is established by the per-platform `verify()`,
69
- * which reads the inner request reconstructed from the envelope.
70
- */
71
- interface WebhookRawRequest {
72
- body: Uint8Array | ArrayBuffer;
73
- headers?: Record<string, string>;
74
- }
75
- /** Raw webhook result, written back by the caller as the HTTP response. */
76
- interface WebhookRawResult {
77
- body: Uint8Array;
78
- headers: Record<string, string>;
79
- status: number;
80
- }
81
-
82
- 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 };