@lantharos/pult 0.10.0 → 0.12.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 +2 -2
- package/index.d.mts +21 -3
- package/index.mjs +10 -3
- package/package.json +1 -1
- package/{schema-DuTVNptF.mjs → schema-D7N0bd_N.mjs} +6 -1
package/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { C as traceOrigins, L as findActionDef, M as valuesIn, S as kindOf, _ as normalizeFilter, a as collect, c as guards, d as Transport, h as hasPendingAttachments, i as validate, j as shownValue, k as eachBlock, r as toJsonSchema, x as humanize } from "./schema-
|
|
2
|
+
import { C as traceOrigins, L as findActionDef, M as valuesIn, S as kindOf, _ as normalizeFilter, a as collect, c as guards, d as Transport, h as hasPendingAttachments, i as validate, j as shownValue, k as eachBlock, r as toJsonSchema, x as humanize } from "./schema-D7N0bd_N.mjs";
|
|
3
3
|
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
4
4
|
import { parseArgs, styleText } from "node:util";
|
|
5
5
|
import { Cron } from "croner";
|
|
@@ -184,7 +184,7 @@ function actionChanges(prefix) {
|
|
|
184
184
|
}
|
|
185
185
|
//#endregion
|
|
186
186
|
//#region package.json
|
|
187
|
-
var version = "0.
|
|
187
|
+
var version = "0.12.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";
|
|
@@ -101,6 +102,8 @@ type FieldValue = string | number | boolean | null | {
|
|
|
101
102
|
record: RecordRef;
|
|
102
103
|
} | {
|
|
103
104
|
code: string;
|
|
105
|
+
} | {
|
|
106
|
+
link: Link;
|
|
104
107
|
} | {
|
|
105
108
|
live: LiveStat;
|
|
106
109
|
} | {
|
|
@@ -114,6 +117,10 @@ interface Editable {
|
|
|
114
117
|
record: string | null;
|
|
115
118
|
field: string | null;
|
|
116
119
|
}
|
|
120
|
+
interface Link {
|
|
121
|
+
url: string;
|
|
122
|
+
title?: string;
|
|
123
|
+
}
|
|
117
124
|
interface Sensitive {
|
|
118
125
|
value?: string;
|
|
119
126
|
hint?: string;
|
|
@@ -183,6 +190,7 @@ type Block = {
|
|
|
183
190
|
}[];
|
|
184
191
|
} | {
|
|
185
192
|
type: "table";
|
|
193
|
+
title?: string;
|
|
186
194
|
columns: string[];
|
|
187
195
|
rows: FieldValue[][];
|
|
188
196
|
} | {
|
|
@@ -222,6 +230,9 @@ type Block = {
|
|
|
222
230
|
flag: string;
|
|
223
231
|
state?: FlagState;
|
|
224
232
|
};
|
|
233
|
+
type AttachmentBlock = Extract<Block, {
|
|
234
|
+
type: "attachment";
|
|
235
|
+
}>;
|
|
225
236
|
//#endregion
|
|
226
237
|
//#region ../protocol/src/manifest.d.ts
|
|
227
238
|
type JsonSchema = {
|
|
@@ -792,7 +803,11 @@ export declare const b: {
|
|
|
792
803
|
at: Date | number;
|
|
793
804
|
text: string;
|
|
794
805
|
}[]) => Block;
|
|
795
|
-
|
|
806
|
+
link: (url: string, title?: string) => FieldValue;
|
|
807
|
+
table: (rows: Record<string, FieldInput>[], { title, columns }?: {
|
|
808
|
+
title?: string;
|
|
809
|
+
columns?: string[];
|
|
810
|
+
}) => Block;
|
|
796
811
|
stats: (stats: Record<string, FieldInput | {
|
|
797
812
|
value: FieldInput;
|
|
798
813
|
note?: string;
|
|
@@ -962,6 +977,9 @@ interface SendOptions<S extends Schema | undefined, Suggested extends unknown[]
|
|
|
962
977
|
tags?: string[];
|
|
963
978
|
suggest?: { [K in keyof Suggested]: Suggestion<Suggested[K]>; };
|
|
964
979
|
}
|
|
980
|
+
interface ReceivedMessage extends Omit<IncomingMessage, "attachments"> {
|
|
981
|
+
attachments?: BlockInput[];
|
|
982
|
+
}
|
|
965
983
|
interface ListenOptions {
|
|
966
984
|
onStatus?: (status: "connected" | "disconnected") => void;
|
|
967
985
|
}
|
|
@@ -971,7 +989,7 @@ export declare function createPult<Component extends string = string>({ key, pro
|
|
|
971
989
|
blocks?: BlockInput[];
|
|
972
990
|
by?: string;
|
|
973
991
|
}) => Promise<void>;
|
|
974
|
-
receive: (message:
|
|
992
|
+
receive: ({ attachments, ...message }: ReceivedMessage) => Promise<{
|
|
975
993
|
item: string;
|
|
976
994
|
} | null>;
|
|
977
995
|
flag: <T, A>(definition: Flag<T, A>, context?: string | FlagContext<A>) => Promise<T>;
|
|
@@ -988,4 +1006,4 @@ export declare function createPult<Component extends string = string>({ key, pro
|
|
|
988
1006
|
};
|
|
989
1007
|
type Pult = ReturnType<typeof createPult>;
|
|
990
1008
|
//#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 };
|
|
1009
|
+
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as mapBlocks, D as sign, E as NonceWindow, F as HOME, I as actionId, L as findActionDef, M as valuesIn, N as DEFAULT_STATES, O as verify, S as kindOf, T as refKey, a as collect, b as captureOrigin, d as Transport, f as b, g as isPendingAttachment, h as hasPendingAttachments, i as validate, k as eachBlock, m as fieldValues, n as reviveDates, o as findAction, p as bindActions, s as flag, t as ValidationError, u as PultError, v as view, w as HEADER, y as KIND } from "./schema-
|
|
1
|
+
import { A as mapBlocks, D as sign, E as NonceWindow, F as HOME, I as actionId, L as findActionDef, M as valuesIn, N as DEFAULT_STATES, O as verify, S as kindOf, T as refKey, a as collect, b as captureOrigin, d as Transport, f as b, g as isPendingAttachment, h as hasPendingAttachments, i as validate, k as eachBlock, m as fieldValues, n as reviveDates, o as findAction, p as bindActions, s as flag, t as ValidationError, u as PultError, v as view, w as HEADER, y as KIND } from "./schema-D7N0bd_N.mjs";
|
|
2
2
|
//#region ../protocol/src/flags.ts
|
|
3
3
|
function rampAt(ramp, now = Date.now()) {
|
|
4
4
|
if (now >= ramp.end) return ramp.to;
|
|
@@ -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",
|
|
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
|
@@ -361,8 +361,13 @@ const b = {
|
|
|
361
361
|
text
|
|
362
362
|
}))
|
|
363
363
|
}),
|
|
364
|
-
|
|
364
|
+
link: (url, title) => ({ link: {
|
|
365
|
+
url,
|
|
366
|
+
...title ? { title } : {}
|
|
367
|
+
} }),
|
|
368
|
+
table: (rows, { title, columns = Object.keys(rows[0] ?? {}) } = {}) => ({
|
|
365
369
|
type: "table",
|
|
370
|
+
...title ? { title } : {},
|
|
366
371
|
columns,
|
|
367
372
|
rows: rows.map((row) => columns.map((column) => field(row[column])))
|
|
368
373
|
}),
|