@lantharos/pult 0.10.0 → 0.11.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/cli.mjs CHANGED
@@ -184,7 +184,7 @@ function actionChanges(prefix) {
184
184
  }
185
185
  //#endregion
186
186
  //#region package.json
187
- var version = "0.10.0";
187
+ var version = "0.11.0";
188
188
  //#endregion
189
189
  //#region ../protocol/src/checks.ts
190
190
  const COLUMNS = [
package/index.d.mts CHANGED
@@ -17,6 +17,7 @@ interface IncomingMessage {
17
17
  from: string;
18
18
  subject?: string;
19
19
  text: string;
20
+ attachments?: AttachmentBlock[];
20
21
  }
21
22
  type TriageDecision = {
22
23
  type: "state";
@@ -222,6 +223,9 @@ type Block = {
222
223
  flag: string;
223
224
  state?: FlagState;
224
225
  };
226
+ type AttachmentBlock = Extract<Block, {
227
+ type: "attachment";
228
+ }>;
225
229
  //#endregion
226
230
  //#region ../protocol/src/manifest.d.ts
227
231
  type JsonSchema = {
@@ -962,6 +966,9 @@ interface SendOptions<S extends Schema | undefined, Suggested extends unknown[]
962
966
  tags?: string[];
963
967
  suggest?: { [K in keyof Suggested]: Suggestion<Suggested[K]>; };
964
968
  }
969
+ interface ReceivedMessage extends Omit<IncomingMessage, "attachments"> {
970
+ attachments?: BlockInput[];
971
+ }
965
972
  interface ListenOptions {
966
973
  onStatus?: (status: "connected" | "disconnected") => void;
967
974
  }
@@ -971,7 +978,7 @@ export declare function createPult<Component extends string = string>({ key, pro
971
978
  blocks?: BlockInput[];
972
979
  by?: string;
973
980
  }) => Promise<void>;
974
- receive: (message: IncomingMessage) => Promise<{
981
+ receive: ({ attachments, ...message }: ReceivedMessage) => Promise<{
975
982
  item: string;
976
983
  } | null>;
977
984
  flag: <T, A>(definition: Flag<T, A>, context?: string | FlagContext<A>) => Promise<T>;
@@ -988,4 +995,4 @@ export declare function createPult<Component extends string = string>({ key, pro
988
995
  };
989
996
  type Pult = ReturnType<typeof createPult>;
990
997
  //#endregion
991
- export type { Action, ActionContext, ActionOptions, ActionRef, Actor, Block, BlockInput, ButtonInput, Channel, ComponentState, Config, ConfigOptions, Duration, FieldInput, Flag, FlagContext, FlagOptions, Guard, Inbox, InboxOptions, ItemView, ListOptions, ListQuery, ListenOptions, Manifest, Notify, NotifyOptions, OutgoingEmail, Page, PageContext, PageOptions, Project, Pult, PultOptions, Question, Relation, Resource, ResourceOptions, Role, RoleOptions, Rule, SendOptions, SendResult, Space, SpaceOptions, StandaloneOptions, StateChange, Status, StatusOptions, Suggestion, Triage, View, ViewOptions };
998
+ export type { Action, ActionContext, ActionOptions, ActionRef, Actor, Block, BlockInput, ButtonInput, Channel, ComponentState, Config, ConfigOptions, Duration, FieldInput, Flag, FlagContext, FlagOptions, Guard, Inbox, InboxOptions, ItemView, ListOptions, ListQuery, ListenOptions, Manifest, Notify, NotifyOptions, OutgoingEmail, Page, PageContext, PageOptions, Project, Pult, PultOptions, Question, ReceivedMessage, Relation, Resource, ResourceOptions, Role, RoleOptions, Rule, SendOptions, SendResult, Space, SpaceOptions, StandaloneOptions, StateChange, Status, StatusOptions, Suggestion, Triage, View, ViewOptions };
package/index.mjs CHANGED
@@ -860,9 +860,13 @@ function createPult({ key = env("PULT_KEY"), project, url = env("PULT_URL") ?? "
860
860
  blocks: options.blocks && await upload(options.blocks)
861
861
  });
862
862
  }
863
- async function receive(message) {
863
+ async function receive({ attachments, ...message }) {
864
+ const incoming = attachments?.length ? {
865
+ ...message,
866
+ attachments: (await upload(attachments)).filter(isAttachment)
867
+ } : message;
864
868
  try {
865
- return await transport.request("POST", "/v1/messages", message);
869
+ return await transport.request("POST", "/v1/messages", incoming);
866
870
  } catch (error) {
867
871
  if (error instanceof PultError && error.code === "no_thread") return null;
868
872
  throw error;
@@ -936,6 +940,9 @@ function createPult({ key = env("PULT_KEY"), project, url = env("PULT_URL") ?? "
936
940
  deploy
937
941
  };
938
942
  }
943
+ function isAttachment(block) {
944
+ return block.type === "attachment";
945
+ }
939
946
  function signedHeaders(headers) {
940
947
  const timestamp = headers.get(HEADER.timestamp);
941
948
  const nonce = headers.get(HEADER.nonce);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lantharos/pult",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "The other side of your app",
5
5
  "license": "MIT",
6
6
  "keywords": [