spectrum-ts 1.18.0 → 3.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 (38) hide show
  1. package/README.md +11 -1
  2. package/dist/{attachment-DfWSZS5L.d.ts → attachment-WePAHfcH.d.ts} +1 -1
  3. package/dist/{authoring-C9uDdZ2F.d.ts → authoring-DDh3muGT.d.ts} +61 -26
  4. package/dist/authoring.d.ts +3 -3
  5. package/dist/authoring.js +8 -5
  6. package/dist/chunk-34FQGGD7.js +34 -0
  7. package/dist/chunk-3GEJYGZK.js +84 -0
  8. package/dist/{chunk-MC6ZKFSG.js → chunk-5XEFJBN2.js} +25 -103
  9. package/dist/{chunk-QGJFZMD5.js → chunk-6UZFVXQF.js} +17 -101
  10. package/dist/{chunk-NNY6LMSC.js → chunk-77U6SH5A.js} +1 -1
  11. package/dist/{chunk-YN6WOTBF.js → chunk-AYCMTRVC.js} +622 -79
  12. package/dist/{chunk-JQN6CRSC.js → chunk-CHY5YLLV.js} +11 -40
  13. package/dist/{chunk-5BKZJMZV.js → chunk-EZ5SNNFS.js} +79 -38
  14. package/dist/{chunk-3OTECDNH.js → chunk-FULEQIRQ.js} +31 -23
  15. package/dist/{chunk-2ILTJC35.js → chunk-LQMDV75O.js} +205 -11
  16. package/dist/{chunk-IPOFBAIM.js → chunk-LX437ZTY.js} +439 -154
  17. package/dist/chunk-MHGCPC2V.js +35 -0
  18. package/dist/chunk-NZ5WCMTY.js +91 -0
  19. package/dist/chunk-TXRWKSNH.js +927 -0
  20. package/dist/{chunk-5TIF3FIE.js → chunk-UXJ5OO6P.js} +16 -14
  21. package/dist/index.d.ts +125 -129
  22. package/dist/index.js +180 -73
  23. package/dist/manifest.json +6 -0
  24. package/dist/providers/imessage/index.d.ts +6 -14
  25. package/dist/providers/imessage/index.js +9 -6
  26. package/dist/providers/index.d.ts +5 -2
  27. package/dist/providers/index.js +18 -10
  28. package/dist/providers/slack/index.d.ts +1 -2
  29. package/dist/providers/slack/index.js +5 -4
  30. package/dist/providers/telegram/index.d.ts +45 -0
  31. package/dist/providers/telegram/index.js +13 -0
  32. package/dist/providers/terminal/index.d.ts +18 -422
  33. package/dist/providers/terminal/index.js +7 -5
  34. package/dist/providers/whatsapp-business/index.d.ts +1 -1
  35. package/dist/providers/whatsapp-business/index.js +7 -5
  36. package/dist/types-BujGKBin.d.ts +82 -0
  37. package/dist/{types-DcQ5a7PK.d.ts → types-YqCNUDIt.d.ts} +204 -26
  38. package/package.json +3 -1
@@ -0,0 +1,35 @@
1
+ import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
+ import {
3
+ resolveContents
4
+ } from "./chunk-LQMDV75O.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
+ };
@@ -0,0 +1,91 @@
1
+ import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
+ import {
3
+ fromVCard
4
+ } from "./chunk-6UZFVXQF.js";
5
+ import {
6
+ readSchema
7
+ } from "./chunk-LQMDV75O.js";
8
+
9
+ // src/content/contact.ts
10
+ import vCard from "vcf";
11
+ import z from "zod";
12
+ var userRefSchema = z.object({
13
+ __platform: z.string(),
14
+ id: z.string()
15
+ });
16
+ var nameSchema = z.object({
17
+ formatted: z.string().optional(),
18
+ first: z.string().optional(),
19
+ last: z.string().optional(),
20
+ middle: z.string().optional(),
21
+ prefix: z.string().optional(),
22
+ suffix: z.string().optional()
23
+ });
24
+ var phoneTypeSchema = z.enum(["mobile", "home", "work", "other"]);
25
+ var emailTypeSchema = z.enum(["home", "work", "other"]);
26
+ var addressTypeSchema = z.enum(["home", "work", "other"]);
27
+ var phoneSchema = z.object({
28
+ value: z.string(),
29
+ type: phoneTypeSchema.optional()
30
+ });
31
+ var emailSchema = z.object({
32
+ value: z.string(),
33
+ type: emailTypeSchema.optional()
34
+ });
35
+ var addressSchema = z.object({
36
+ street: z.string().optional(),
37
+ city: z.string().optional(),
38
+ region: z.string().optional(),
39
+ postalCode: z.string().optional(),
40
+ country: z.string().optional(),
41
+ type: addressTypeSchema.optional()
42
+ });
43
+ var orgSchema = z.object({
44
+ name: z.string().optional(),
45
+ title: z.string().optional(),
46
+ department: z.string().optional()
47
+ });
48
+ var photoSchema = z.object({
49
+ mimeType: z.string(),
50
+ read: readSchema
51
+ });
52
+ var contactSchema = z.object({
53
+ type: z.literal("contact"),
54
+ user: userRefSchema.optional(),
55
+ name: nameSchema.optional(),
56
+ phones: z.array(phoneSchema).optional(),
57
+ emails: z.array(emailSchema).optional(),
58
+ addresses: z.array(addressSchema).optional(),
59
+ org: orgSchema.optional(),
60
+ urls: z.array(z.string()).optional(),
61
+ birthday: z.string().optional(),
62
+ note: z.string().optional(),
63
+ photo: photoSchema.optional(),
64
+ raw: z.unknown().optional()
65
+ });
66
+ var asContact = (input) => contactSchema.parse({ type: "contact", ...input });
67
+ var isUser = (value) => typeof value === "object" && value !== null && "__platform" in value && "id" in value && typeof value.__platform === "string" && typeof value.id === "string";
68
+ function contact(input, details) {
69
+ return {
70
+ build: async () => {
71
+ if (typeof input === "string") {
72
+ return asContact(fromVCard(input));
73
+ }
74
+ if (input instanceof vCard) {
75
+ return asContact(fromVCard(input.toString()));
76
+ }
77
+ if (isUser(input)) {
78
+ return asContact({
79
+ user: { __platform: input.__platform, id: input.id },
80
+ ...details
81
+ });
82
+ }
83
+ return asContact(input);
84
+ }
85
+ };
86
+ }
87
+
88
+ export {
89
+ asContact,
90
+ contact
91
+ };