spectrum-ts 0.9.0 → 1.0.1

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.
@@ -2,7 +2,7 @@ import { M as ManagedStream } from '../../stream-B55k7W8-.js';
2
2
  import { WhatsAppClient } from '@photon-ai/whatsapp-business';
3
3
  import * as z from 'zod';
4
4
  import z__default from 'zod';
5
- import { l as SchemaMessage, d as Platform, c as PlatformDef, P as ProviderMessage } from '../../types-B8g0pvfg.js';
5
+ import { l as SchemaMessage, d as Platform, c as PlatformDef, P as ProviderMessage } from '../../types-D5KhSXLy.js';
6
6
  import * as zod_v4_core from 'zod/v4/core';
7
7
  import 'hotscript';
8
8
 
@@ -1,17 +1,17 @@
1
1
  import {
2
- asAttachment,
3
- asContact,
4
- asCustom,
5
- asReaction,
6
2
  cloud,
7
3
  mergeStreams,
8
4
  stream
9
- } from "../../chunk-CZIWNTXP.js";
5
+ } from "../../chunk-2Y5GBI6W.js";
10
6
  import {
11
7
  UnsupportedError,
8
+ asAttachment,
9
+ asContact,
10
+ asCustom,
11
+ asReaction,
12
12
  asText,
13
13
  definePlatform
14
- } from "../../chunk-PLJI5FTO.js";
14
+ } from "../../chunk-XMAI2AAN.js";
15
15
 
16
16
  // src/providers/whatsapp-business/index.ts
17
17
  import { createClient as createClient2 } from "@photon-ai/whatsapp-business";
@@ -401,11 +401,16 @@ var mapContent = (client, content) => {
401
401
  return asCustom({ whatsapp_type: "sticker", ...content.sticker });
402
402
  case "location":
403
403
  return asCustom({ whatsapp_type: "location", ...content.location });
404
- case "reaction":
404
+ case "reaction": {
405
+ const stubTarget = {
406
+ id: content.reaction.messageId,
407
+ content: asCustom({ whatsapp_type: "reaction-target", stub: true })
408
+ };
405
409
  return asReaction({
406
410
  emoji: content.reaction.emoji,
407
- target: content.reaction.messageId
411
+ target: stubTarget
408
412
  });
413
+ }
409
414
  case "interactive":
410
415
  return asCustom({ whatsapp_type: "interactive", ...content.interactive });
411
416
  case "button":
@@ -723,11 +728,11 @@ var whatsappBusiness = definePlatform("WhatsApp Business", {
723
728
  send: async ({ space, content, client }) => {
724
729
  return await send(client, space.id, content);
725
730
  },
726
- reactToMessage: async ({ space, messageId, reaction, client }) => {
731
+ reactToMessage: async ({ space, target, reaction, client }) => {
727
732
  await reactToMessage(
728
733
  client,
729
734
  space.id,
730
- messageId,
735
+ target.id,
731
736
  reaction
732
737
  );
733
738
  },
@@ -91,7 +91,10 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
91
91
  }, z__default.core.$strip>, z__default.ZodObject<{
92
92
  type: z__default.ZodLiteral<"reaction">;
93
93
  emoji: z__default.ZodString;
94
- target: z__default.ZodString;
94
+ target: z__default.ZodCustom<Message, Message>;
95
+ }, z__default.core.$strip>, z__default.ZodObject<{
96
+ type: z__default.ZodLiteral<"group">;
97
+ items: z__default.ZodArray<z__default.ZodCustom<Message, Message>>;
95
98
  }, z__default.core.$strip>], "type">;
96
99
  type Content = z__default.infer<typeof contentSchema>;
97
100
  interface ContentBuilder {
@@ -107,6 +110,13 @@ interface User {
107
110
  interface Space<_Def = unknown> {
108
111
  readonly __platform: string;
109
112
  edit(message: OutboundMessage, newContent: ContentInput): Promise<void>;
113
+ /**
114
+ * Look up a message in this space by its id. Returns `undefined` if the
115
+ * platform has no way to resolve the id (e.g. cache miss with no by-id
116
+ * SDK fallback). Used to materialize a `Message` for APIs that require one,
117
+ * such as `reaction()`.
118
+ */
119
+ getMessage(id: string): Promise<Message | undefined>;
110
120
  readonly id: string;
111
121
  responding<T>(fn: () => T | Promise<T>): Promise<T>;
112
122
  send(content: ContentInput): Promise<OutboundMessage | undefined>;
@@ -158,6 +168,14 @@ type ProviderMessage<TSender extends ResolvedUser = ResolvedUser, TSpace extends
158
168
  timestamp?: Date;
159
169
  } & TExtra;
160
170
  interface SendResult<TSender extends ResolvedUser = ResolvedUser> {
171
+ /**
172
+ * Per-item send receipts returned when the dispatched content was a
173
+ * `group`. Providers that iterate native sends to emulate a group
174
+ * (e.g. iMessage) populate this so the platform build layer can
175
+ * replace the outbound group's placeholder items with real Messages
176
+ * that carry each item's own id.
177
+ */
178
+ groupMembers?: SendResult<TSender>[];
161
179
  id: string;
162
180
  sender?: TSender;
163
181
  timestamp?: Date;
@@ -190,7 +208,7 @@ interface PlatformDef<_Name extends string = string, _ConfigSchema extends z__de
190
208
  }) => Promise<void>;
191
209
  reactToMessage?: (_: {
192
210
  space: _ResolvedSpace & SpaceRef;
193
- messageId: string;
211
+ target: _MessageType;
194
212
  reaction: string;
195
213
  client: _Client;
196
214
  config: z__default.infer<_ConfigSchema>;
@@ -209,6 +227,12 @@ interface PlatformDef<_Name extends string = string, _ConfigSchema extends z__de
209
227
  client: _Client;
210
228
  config: z__default.infer<_ConfigSchema>;
211
229
  }) => Promise<void>;
230
+ getMessage?: (_: {
231
+ space: _ResolvedSpace & SpaceRef;
232
+ messageId: string;
233
+ client: _Client;
234
+ config: z__default.infer<_ConfigSchema>;
235
+ }) => Promise<_MessageType | undefined>;
212
236
  };
213
237
  config: _ConfigSchema;
214
238
  events: _Events;
@@ -259,6 +283,7 @@ interface AnyPlatformDef {
259
283
  reactToMessage?: (_: any) => Promise<void>;
260
284
  replyToMessage?: (_: any) => Promise<SendResult>;
261
285
  editMessage?: (_: any) => Promise<void>;
286
+ getMessage?: (_: any) => Promise<any>;
262
287
  };
263
288
  config: z__default.ZodType<object>;
264
289
  events: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spectrum-ts",
3
- "version": "0.9.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",