spectrum-ts 4.2.0 → 5.1.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 -94
  5. package/dist/elysia.js +2 -15
  6. package/dist/express.d.ts +1 -62
  7. package/dist/express.js +2 -19
  8. package/dist/hono.d.ts +1 -64
  9. package/dist/hono.js +2 -11
  10. package/dist/index.d.ts +1 -2851
  11. package/dist/index.js +2 -3763
  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 +11 -38
  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-5XEFJBN2.js +0 -197
  32. package/dist/chunk-6UZFVXQF.js +0 -374
  33. package/dist/chunk-A37PM5N2.js +0 -91
  34. package/dist/chunk-ARL2NOBO.js +0 -887
  35. package/dist/chunk-B52VPQO3.js +0 -1379
  36. package/dist/chunk-DMPDLSFU.js +0 -864
  37. package/dist/chunk-FAIFTUV2.js +0 -139
  38. package/dist/chunk-LZXPLXZF.js +0 -35
  39. package/dist/chunk-N6THJDZV.js +0 -929
  40. package/dist/chunk-NLMQ75LH.js +0 -2980
  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-CyfLJXgu.d.ts +0 -1530
  46. package/dist/types-ZgFTj5hJ.d.ts +0 -87
@@ -1,139 +0,0 @@
1
- import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
- import {
3
- bufferToStream,
4
- fetchUrlBytes,
5
- readSchema,
6
- streamSchema
7
- } from "./chunk-UXAKIXVM.js";
8
-
9
- // src/content/voice.ts
10
- import { createReadStream } from "fs";
11
- import { readFile, stat } from "fs/promises";
12
- import { basename } from "path";
13
- import { Readable } from "stream";
14
- import { lookup as lookupMimeType } from "mime-types";
15
- import z from "zod";
16
- var AUDIO_MIME_PATTERN = /^audio\//i;
17
- var audioMimeSchema = z.string().nonempty().regex(AUDIO_MIME_PATTERN, "voice content requires an audio/* MIME type");
18
- var voiceSchema = z.object({
19
- type: z.literal("voice"),
20
- name: z.string().nonempty().optional(),
21
- mimeType: audioMimeSchema,
22
- duration: z.number().nonnegative().optional(),
23
- size: z.number().int().nonnegative().optional(),
24
- read: readSchema,
25
- stream: streamSchema
26
- });
27
- var resolveVoiceName = (input, name) => {
28
- if (name) {
29
- return name;
30
- }
31
- if (input instanceof URL) {
32
- return basename(input.pathname) || void 0;
33
- }
34
- if (typeof input === "string") {
35
- return basename(input);
36
- }
37
- return;
38
- };
39
- var resolveVoiceMimeHint = (input, name) => {
40
- if (input instanceof URL) {
41
- return basename(input.pathname) || void 0;
42
- }
43
- if (typeof input === "string") {
44
- return basename(input);
45
- }
46
- return name;
47
- };
48
- var resolveVoiceMimeType = (name, mimeType) => {
49
- if (mimeType) {
50
- if (!AUDIO_MIME_PATTERN.test(mimeType)) {
51
- throw new Error(
52
- `voice content requires an audio/* MIME type, got "${mimeType}".`
53
- );
54
- }
55
- return mimeType;
56
- }
57
- if (name) {
58
- const resolved = lookupMimeType(name);
59
- if (resolved && AUDIO_MIME_PATTERN.test(resolved)) {
60
- return resolved;
61
- }
62
- if (resolved) {
63
- throw new Error(
64
- `Resolved non-audio MIME type "${resolved}" from name "${name}". Pass options.mimeType explicitly with an audio/* type.`
65
- );
66
- }
67
- }
68
- throw new Error(
69
- "Unable to resolve MIME type for voice content. Pass options.mimeType explicitly."
70
- );
71
- };
72
- var asVoice = (input) => {
73
- let cached;
74
- const read = () => {
75
- cached ??= input.read().catch((err) => {
76
- cached = void 0;
77
- throw err;
78
- });
79
- return cached;
80
- };
81
- const stream = input.stream ?? (async () => bufferToStream(await read()));
82
- return voiceSchema.parse({
83
- type: "voice",
84
- name: input.name,
85
- mimeType: input.mimeType,
86
- duration: input.duration,
87
- size: input.size,
88
- read,
89
- stream
90
- });
91
- };
92
- function voice(input, options) {
93
- return {
94
- build: async () => {
95
- const name = resolveVoiceName(input, options?.name);
96
- const mimeHint = resolveVoiceMimeHint(input, name);
97
- const mimeType = resolveVoiceMimeType(mimeHint, options?.mimeType);
98
- if (input instanceof URL) {
99
- return asVoice({
100
- name,
101
- mimeType,
102
- duration: options?.duration,
103
- read: async () => (await fetchUrlBytes(input)).data
104
- });
105
- }
106
- if (typeof input === "string") {
107
- const stats = await stat(input);
108
- if (!stats.isFile()) {
109
- throw new Error(
110
- `voice content path "${input}" is not a regular file.`
111
- );
112
- }
113
- return asVoice({
114
- name,
115
- mimeType,
116
- duration: options?.duration,
117
- size: stats.size,
118
- read: () => readFile(input),
119
- stream: async () => Readable.toWeb(
120
- createReadStream(input)
121
- )
122
- });
123
- }
124
- return asVoice({
125
- name,
126
- mimeType,
127
- duration: options?.duration,
128
- size: input.byteLength,
129
- read: async () => input,
130
- stream: async () => bufferToStream(input)
131
- });
132
- }
133
- };
134
- }
135
-
136
- export {
137
- asVoice,
138
- voice
139
- };
@@ -1,35 +0,0 @@
1
- import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
- import {
3
- resolveContents
4
- } from "./chunk-UXAKIXVM.js";
5
-
6
- // src/content/group.ts
7
- import z from "zod";
8
- var isMessage = (v) => typeof v === "object" && v !== null && "id" in v && "content" in v;
9
- var groupSchema = z.object({
10
- type: z.literal("group"),
11
- items: z.array(z.custom(isMessage)).min(2)
12
- });
13
- var asGroup = (input) => groupSchema.parse({ type: "group", items: input.items });
14
- var stubOutboundMessage = (content) => ({ id: "", content });
15
- function group(...items) {
16
- return {
17
- build: async () => {
18
- const resolved = await resolveContents(items);
19
- const members = [];
20
- for (const item of resolved) {
21
- if (item.type === "group" || item.type === "reaction") {
22
- throw new Error(`group() cannot contain "${item.type}" items`);
23
- }
24
- members.push(stubOutboundMessage(item));
25
- }
26
- return asGroup({ items: members });
27
- }
28
- };
29
- }
30
-
31
- export {
32
- groupSchema,
33
- asGroup,
34
- group
35
- };