@primitivedotdev/sdk 1.25.0 → 1.26.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.
@@ -56,7 +56,7 @@ type SignalInput = {
56
56
  } | {
57
57
  kind: "read";
58
58
  } | {
59
- kind: "working";
59
+ kind: "working" | "typing";
60
60
  expiresAtMs: number;
61
61
  });
62
62
  interface SignalDependencies {
@@ -73,9 +73,9 @@ function prepareSignalEmail(input, dependencies) {
73
73
  payload.note = input.note;
74
74
  }
75
75
  } else if (input.kind !== "read") {
76
- check(input.kind === "working", "invalid signal kind");
76
+ check(input.kind === "working" || input.kind === "typing", "invalid signal kind");
77
77
  milliseconds(input.expiresAtMs);
78
- check(input.expiresAtMs > now && input.expiresAtMs - now <= 6e4, "working expiry must be within 60 seconds");
78
+ check(input.expiresAtMs > now && input.expiresAtMs - now <= 6e4, `${input.kind} expiry must be within 60 seconds`);
79
79
  expires = input.expiresAtMs;
80
80
  }
81
81
  const interaction = dependencies.uuid().toLowerCase(), step = dependencies.uuid().toLowerCase();
@@ -135,6 +135,7 @@ async function sendPreparedSignal(sendMail, prepared, options) {
135
135
  function signalText(kind, status, note) {
136
136
  if (kind === "read") return "I read your message.";
137
137
  if (kind === "working") return "I am working on your message.";
138
+ if (kind === "typing") return "I am composing a reply to your message.";
138
139
  const bodies = {
139
140
  received: "Received your message.",
140
141
  will_process: "I intend to process your message.",
@@ -198,9 +199,10 @@ function fallback(result) {
198
199
  if (!exactKeys(e, ENVELOPE_KEYS) || e.protocol_version !== 1 || ![
199
200
  "ack",
200
201
  "read",
201
- "working"
202
+ "working",
203
+ "typing"
202
204
  ].includes(e.protocol) || e.step !== e.protocol || e.prev_step_id !== null || e.interaction_id.split("@")[0]?.toLowerCase() === e.step_id.toLowerCase()) return null;
203
- if (e.protocol === "working" ? !utcExpiry(e.expires_at) : e.expires_at !== null) return null;
205
+ if (["working", "typing"].includes(e.protocol) ? !utcExpiry(e.expires_at) : e.expires_at !== null) return null;
204
206
  if (!e.payload || typeof e.payload !== "object" || Array.isArray(e.payload)) return null;
205
207
  const p = e.payload;
206
208
  if (!exactKeys(p, e.protocol === "ack" ? ["subject_message_id", "status"] : ["subject_message_id"], e.protocol === "ack" ? ["note"] : [])) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primitivedotdev/sdk",
3
- "version": "1.25.0",
3
+ "version": "1.26.0",
4
4
  "description": "Official Primitive Node.js SDK: webhook, api, openapi, contract, and parser runtime modules.",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",