@lantharos/pult 0.0.0-stage → 0.9.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/index.d.mts ADDED
@@ -0,0 +1,989 @@
1
+ import { StandardSchemaV1 } from "@standard-schema/spec";
2
+ //#region ../protocol/src/wire.d.ts
3
+ interface Actor {
4
+ type: "user" | "agent" | "triage" | "app" | "schedule" | "guard";
5
+ id: string;
6
+ name: string;
7
+ role: string | null;
8
+ }
9
+ interface SendResult {
10
+ id: string;
11
+ created: boolean;
12
+ reopened: boolean;
13
+ occurrences: number;
14
+ }
15
+ interface IncomingMessage {
16
+ thread: string;
17
+ from: string;
18
+ subject?: string;
19
+ text: string;
20
+ }
21
+ type TriageDecision = {
22
+ type: "state";
23
+ state: string;
24
+ } | {
25
+ type: "run";
26
+ action: string;
27
+ input?: Record<string, unknown>;
28
+ } | {
29
+ type: "tag";
30
+ tag: string;
31
+ };
32
+ //#endregion
33
+ //#region ../protocol/src/flags.d.ts
34
+ interface Ramp {
35
+ of: "rollout" | "value";
36
+ from: number;
37
+ to: number;
38
+ start: number;
39
+ end: number;
40
+ every: number | null;
41
+ whole: boolean;
42
+ }
43
+ type Attribute = string | number | boolean;
44
+ interface Condition {
45
+ attribute: string;
46
+ op: "is" | "is not" | "above" | "below";
47
+ values: Attribute[];
48
+ }
49
+ interface FlagRule {
50
+ conditions: Condition[];
51
+ value: unknown;
52
+ rollout: number | null;
53
+ }
54
+ interface FlagValue {
55
+ value: unknown;
56
+ rollout: number | null;
57
+ targets: Record<string, unknown>;
58
+ rules: FlagRule[];
59
+ ramp: Ramp | null;
60
+ }
61
+ interface FlagUsage {
62
+ reads: number;
63
+ lastReadAt: number | null;
64
+ }
65
+ interface FlagState extends FlagValue {
66
+ titles: Record<string, string>;
67
+ updatedAt: number | null;
68
+ updatedBy: Actor | null;
69
+ usage: FlagUsage;
70
+ }
71
+ //#endregion
72
+ //#region ../protocol/src/status.d.ts
73
+ type ComponentState = "operational" | "degraded" | "partial" | "down" | "maintenance";
74
+ //#endregion
75
+ //#region ../protocol/src/console/console.d.ts
76
+ interface ItemSummary {
77
+ id: string;
78
+ inbox: string;
79
+ title: string;
80
+ state: string;
81
+ record: string | null;
82
+ tags: string[];
83
+ assignee: string | null;
84
+ snoozedUntil: number | null;
85
+ occurrences: number;
86
+ users: number;
87
+ firstSeen: number;
88
+ lastSeen: number;
89
+ updatedAt: number;
90
+ unread: boolean;
91
+ triage: "pending" | "done" | null;
92
+ autoHandled: boolean;
93
+ dueAt: number | null;
94
+ fields: Record<string, FieldValue>;
95
+ }
96
+ //#endregion
97
+ //#region ../protocol/src/blocks.d.ts
98
+ type FieldValue = string | number | boolean | null | {
99
+ date: string;
100
+ } | {
101
+ record: RecordRef;
102
+ } | {
103
+ code: string;
104
+ } | {
105
+ live: LiveStat;
106
+ } | {
107
+ sensitive: Sensitive;
108
+ } | {
109
+ edit: Editable;
110
+ };
111
+ interface Editable {
112
+ value: FieldValue;
113
+ action: string;
114
+ record: string | null;
115
+ field: string | null;
116
+ }
117
+ interface Sensitive {
118
+ value?: string;
119
+ hint?: string;
120
+ index?: number;
121
+ }
122
+ type LiveStat = "occurrences" | "users" | "firstSeen" | "lastSeen" | "due";
123
+ interface RecordRef {
124
+ resource: string;
125
+ id: string;
126
+ title?: string;
127
+ }
128
+ type ChartRange = "1h" | "24h" | "7d" | "30d";
129
+ interface ChartPoint {
130
+ at: number;
131
+ value: number;
132
+ }
133
+ interface ActionButton {
134
+ action: string;
135
+ record: string | null;
136
+ input?: Record<string, unknown>;
137
+ label?: string;
138
+ }
139
+ type Block = {
140
+ type: "markdown";
141
+ text: string;
142
+ } | {
143
+ type: "fields";
144
+ fields: {
145
+ label: string;
146
+ value: FieldValue;
147
+ }[];
148
+ } | {
149
+ type: "code";
150
+ code: string;
151
+ lang?: string;
152
+ title?: string;
153
+ } | {
154
+ type: "chart";
155
+ metric: "occurrences";
156
+ range: ChartRange;
157
+ title?: string;
158
+ } | {
159
+ type: "chart";
160
+ points: ChartPoint[];
161
+ title?: string;
162
+ } | {
163
+ type: "chart";
164
+ inbox: string;
165
+ range: ChartRange;
166
+ title?: string;
167
+ points?: ChartPoint[];
168
+ } | {
169
+ type: "attachment";
170
+ name: string;
171
+ url?: string;
172
+ key?: string;
173
+ contentType?: string;
174
+ size?: number;
175
+ } | {
176
+ type: "record";
177
+ ref: RecordRef;
178
+ } | {
179
+ type: "timeline";
180
+ entries: {
181
+ at: number;
182
+ text: string;
183
+ }[];
184
+ } | {
185
+ type: "table";
186
+ columns: string[];
187
+ rows: FieldValue[][];
188
+ } | {
189
+ type: "stats";
190
+ stats: {
191
+ label: string;
192
+ value: FieldValue;
193
+ note?: string;
194
+ }[];
195
+ } | {
196
+ type: "actions";
197
+ actions: ActionButton[];
198
+ } | {
199
+ type: "form";
200
+ form: ActionButton;
201
+ } | {
202
+ type: "columns";
203
+ columns: Block[][];
204
+ } | {
205
+ type: "count";
206
+ label: string;
207
+ inbox: string;
208
+ filter: ViewFilter;
209
+ view: string | null;
210
+ value?: number;
211
+ } | {
212
+ type: "items";
213
+ label: string;
214
+ inbox: string;
215
+ filter: ViewFilter;
216
+ sort: Sort;
217
+ view: string | null;
218
+ limit: number;
219
+ items?: ItemSummary[];
220
+ } | {
221
+ type: "flag";
222
+ flag: string;
223
+ state?: FlagState;
224
+ };
225
+ //#endregion
226
+ //#region ../protocol/src/manifest.d.ts
227
+ type JsonSchema = {
228
+ type?: string | string[];
229
+ title?: string;
230
+ description?: string;
231
+ properties?: Record<string, JsonSchema>;
232
+ required?: string[];
233
+ items?: JsonSchema;
234
+ enum?: unknown[];
235
+ const?: unknown;
236
+ format?: string;
237
+ default?: unknown;
238
+ minimum?: number;
239
+ maximum?: number;
240
+ exclusiveMinimum?: number;
241
+ exclusiveMaximum?: number;
242
+ minLength?: number;
243
+ maxLength?: number;
244
+ anyOf?: JsonSchema[];
245
+ oneOf?: JsonSchema[];
246
+ [key: string]: unknown;
247
+ };
248
+ type Danger = "none" | "confirm" | "reauth";
249
+ type Layout = "list" | "table" | "board";
250
+ interface ActionDef {
251
+ source: string;
252
+ label: string;
253
+ description?: string;
254
+ danger: Danger;
255
+ input: JsonSchema | null;
256
+ preview: boolean;
257
+ automatable: boolean;
258
+ approval: boolean;
259
+ contextual: boolean;
260
+ background: boolean;
261
+ pick: Record<string, string>;
262
+ choices: string[];
263
+ schedule: Schedule | null;
264
+ }
265
+ interface Schedule {
266
+ cron: string;
267
+ timezone: string | null;
268
+ }
269
+ interface RelationDef {
270
+ resource: string;
271
+ label: string;
272
+ }
273
+ interface ResourceDef {
274
+ source: string;
275
+ label: string;
276
+ plural: string;
277
+ icon: string;
278
+ searchable: boolean;
279
+ list: {
280
+ filters: JsonSchema | null;
281
+ } | null;
282
+ related: Record<string, RelationDef>;
283
+ actions: Record<string, ActionDef>;
284
+ }
285
+ type TriageQuestion = {
286
+ type: "noul";
287
+ prompt: string;
288
+ criteria?: string;
289
+ } | {
290
+ type: "choice";
291
+ prompt: string;
292
+ options: Record<string, string>;
293
+ } | {
294
+ type: "score";
295
+ prompt: string;
296
+ levels: string[];
297
+ };
298
+ interface TriageRuleDef {
299
+ name: string;
300
+ live: boolean;
301
+ then: TriageDecision[];
302
+ }
303
+ interface TriageDef {
304
+ instructions: string;
305
+ questions: Record<string, TriageQuestion>;
306
+ rules: TriageRuleDef[];
307
+ }
308
+ interface InboxDef {
309
+ source: string;
310
+ label: string;
311
+ icon: string;
312
+ resource: string | null;
313
+ layout: Layout;
314
+ states: string[];
315
+ closed: string[];
316
+ reopen: string[];
317
+ data: JsonSchema | null;
318
+ columns: string[];
319
+ intake: {
320
+ title: string;
321
+ description?: string;
322
+ } | null;
323
+ triage: TriageDef | null;
324
+ reply: boolean;
325
+ hooks: {
326
+ state: boolean;
327
+ };
328
+ sla: Record<string, number>;
329
+ }
330
+ interface ViewFilter {
331
+ state?: string[];
332
+ tags?: string[];
333
+ assignee?: "me" | "none";
334
+ triaged?: boolean;
335
+ search?: string;
336
+ }
337
+ type SortKey = "lastSeen" | "firstSeen" | "occurrences" | "users" | "title" | "due";
338
+ type Sort = SortKey | `-${SortKey}`;
339
+ interface ViewDef {
340
+ source: string;
341
+ label: string;
342
+ inbox: string;
343
+ filter: ViewFilter;
344
+ layout: Layout;
345
+ columns: string[];
346
+ sort: Sort;
347
+ }
348
+ interface RoleDef {
349
+ source: string;
350
+ label: string;
351
+ inboxes: string[];
352
+ resources: string[];
353
+ actions: string[];
354
+ pages: string[];
355
+ flags: string[];
356
+ reveal: boolean;
357
+ status: boolean;
358
+ }
359
+ interface PageDef {
360
+ source: string;
361
+ label: string;
362
+ icon: string;
363
+ params: JsonSchema | null;
364
+ blocks: Block[] | null;
365
+ }
366
+ interface SpaceDef {
367
+ name: string;
368
+ source: string;
369
+ label: string;
370
+ icon: string;
371
+ home: string | null;
372
+ inboxes: string[];
373
+ resources: string[];
374
+ pages: string[];
375
+ flags: string[];
376
+ }
377
+ interface FlagDef {
378
+ source: string;
379
+ label: string;
380
+ description?: string;
381
+ value: JsonSchema;
382
+ default: unknown;
383
+ target: string | null;
384
+ attributes: JsonSchema | null;
385
+ guards: FlagGuard[];
386
+ danger: Danger;
387
+ approval: boolean;
388
+ }
389
+ interface FlagGuard {
390
+ inbox: string;
391
+ perHour: number;
392
+ then: "pause" | "revert";
393
+ }
394
+ type NotifyTrigger = "created" | "reopened" | "overdue" | {
395
+ spike: number;
396
+ };
397
+ type Recipient = {
398
+ role: string;
399
+ } | {
400
+ channel: string;
401
+ };
402
+ interface NotifyDef {
403
+ source: string;
404
+ inboxes: string[];
405
+ on: NotifyTrigger[];
406
+ to: Recipient[];
407
+ }
408
+ interface StatusComponentDef {
409
+ label: string;
410
+ description: string | null;
411
+ monitored: boolean;
412
+ check: string | null;
413
+ }
414
+ interface StatusLogo {
415
+ light: string;
416
+ dark: string;
417
+ }
418
+ interface StatusDef<Component extends string = string> {
419
+ source: string;
420
+ title: string;
421
+ logo: StatusLogo | null;
422
+ website: string | null;
423
+ css: string | null;
424
+ components: Record<Component, StatusComponentDef>;
425
+ alert: Recipient[];
426
+ after: number;
427
+ }
428
+ type Delivery = {
429
+ mode: "socket";
430
+ } | {
431
+ mode: "webhook";
432
+ path: string;
433
+ };
434
+ interface Manifest<Component extends string = string> {
435
+ project: string;
436
+ version: string;
437
+ environments: string[];
438
+ sync: string;
439
+ delivery: Delivery;
440
+ resources: Record<string, ResourceDef>;
441
+ actions: Record<string, ActionDef>;
442
+ inboxes: Record<string, InboxDef>;
443
+ views: Record<string, ViewDef>;
444
+ pages: Record<string, PageDef>;
445
+ flags: Record<string, FlagDef>;
446
+ roles: Record<string, RoleDef>;
447
+ spaces: SpaceDef[];
448
+ notify: Record<string, NotifyDef>;
449
+ status: StatusDef<Component> | null;
450
+ }
451
+ //#endregion
452
+ //#region src/schema.d.ts
453
+ type Schema<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output>;
454
+ type AnySchema = StandardSchemaV1<any, any>;
455
+ type InferInput<S> = S extends Schema<infer I, unknown> ? I : never;
456
+ type InferOutput<S> = S extends Schema<unknown, infer O> ? O : never;
457
+ export declare class ValidationError extends Error {
458
+ readonly issues: readonly StandardSchemaV1.Issue[];
459
+ constructor(issues: readonly StandardSchemaV1.Issue[]);
460
+ }
461
+ //#endregion
462
+ //#region src/define/core.d.ts
463
+ declare const KIND: unique symbol;
464
+ type Awaitable<T> = T | Promise<T>;
465
+ type Kind = "resource" | "action" | "inbox" | "role" | "view" | "page" | "flag" | "notify" | "space" | "status" | "config";
466
+ interface Located {
467
+ readonly [KIND]: Kind;
468
+ readonly origin: Origin;
469
+ }
470
+ interface Origin {
471
+ file: string;
472
+ line: number;
473
+ }
474
+ //#endregion
475
+ //#region src/define/resource.d.ts
476
+ interface ActionContext<R, I> {
477
+ record: R;
478
+ input: I;
479
+ actor: Actor;
480
+ item: string | null;
481
+ progress: (fraction: number | null, note?: string) => Promise<void>;
482
+ }
483
+ type ActionReturn = undefined | string | {
484
+ message?: string;
485
+ blocks?: BlockInput[];
486
+ };
487
+ type ActionInput<S> = S extends AnySchema ? InferOutput<S> : Record<string, never>;
488
+ type Prefill<S> = S extends AnySchema ? Partial<InferInput<S>> : Record<string, never>;
489
+ type ChoiceInput = string | {
490
+ value: string;
491
+ label: string;
492
+ };
493
+ interface ActionOptions<R, S> {
494
+ label?: string;
495
+ description?: string;
496
+ input?: S;
497
+ danger?: Danger;
498
+ automatable?: boolean;
499
+ approval?: boolean;
500
+ background?: boolean;
501
+ when?: (record: R) => boolean;
502
+ defaults?: (record: R) => Partial<ActionInput<S>>;
503
+ pick?: { [K in keyof ActionInput<S>]?: string; };
504
+ choices?: { [K in keyof ActionInput<S>]?: (record: R) => Awaitable<ChoiceInput[]>; };
505
+ preview?: (context: ActionContext<R, ActionInput<S>>) => Awaitable<BlockInput[]>;
506
+ run: (context: ActionContext<R, ActionInput<S>>) => Awaitable<ActionReturn>;
507
+ }
508
+ interface ActionRef {
509
+ readonly id: string;
510
+ }
511
+ type ScheduleInput = string | {
512
+ cron: string;
513
+ timezone?: string;
514
+ };
515
+ interface StandaloneOptions<S> extends Omit<ActionOptions<null, S>, "when"> {
516
+ schedule?: ScheduleInput;
517
+ }
518
+ interface Action<R = any, S = any> extends Located, ActionRef {
519
+ readonly options: ActionOptions<R, S> & {
520
+ schedule?: ScheduleInput;
521
+ };
522
+ readonly resource: string | null;
523
+ readonly name: string;
524
+ }
525
+ export declare function action<S extends AnySchema | undefined = undefined>(name: string, options: StandaloneOptions<S>): Action<null, S>;
526
+ type ActionFactory<R> = <S extends AnySchema | undefined = undefined>(options: ActionOptions<R, S>) => ActionOptions<R, S>;
527
+ interface Relation<R = any> {
528
+ resource: string;
529
+ label?: string;
530
+ list: (record: R, limit: number) => Awaitable<unknown[]>;
531
+ }
532
+ interface ListQuery<F> {
533
+ query: string;
534
+ filters: F;
535
+ cursor: string | null;
536
+ limit: number;
537
+ }
538
+ interface ListOptions<R, F extends AnySchema | undefined> {
539
+ filters?: F;
540
+ run: (query: ListQuery<F extends AnySchema ? InferOutput<F> : Record<string, never>>) => Awaitable<{
541
+ records: R[];
542
+ cursor?: string | null;
543
+ }>;
544
+ }
545
+ interface ResourceOptions<R, A, F extends AnySchema | undefined> {
546
+ get: (id: string) => Awaitable<R | null | undefined>;
547
+ find?: (query: string, limit: number) => Awaitable<R[]>;
548
+ list?: ListOptions<R, F>;
549
+ id?: (record: R) => string;
550
+ title: (record: R) => string;
551
+ subtitle?: (record: R) => string | undefined;
552
+ fields?: (record: R) => Record<string, FieldInput>;
553
+ url?: (record: R) => string | undefined;
554
+ render?: (record: R) => Awaitable<BlockInput[]>;
555
+ label?: string;
556
+ plural?: string;
557
+ icon?: string;
558
+ related?: Record<string, Relation<R>>;
559
+ actions?: (action: ActionFactory<R>) => A;
560
+ }
561
+ type Actions<R, A> = { readonly [K in keyof A]: A[K] extends ActionOptions<R, infer S> ? Action<R, S> : never; } & {
562
+ readonly "*": ActionRef;
563
+ };
564
+ interface Resource<R = any, A = any> extends Located {
565
+ readonly name: string;
566
+ readonly options: ResourceOptions<R, A, any>;
567
+ readonly actions: Actions<R, A>;
568
+ }
569
+ export declare function resource<R, A extends Record<string, unknown> = Record<never, never>, F extends AnySchema | undefined = undefined>(name: string, options: ResourceOptions<R, A, F>): Resource<R, A>;
570
+ //#endregion
571
+ //#region src/define/inbox/triage.d.ts
572
+ declare const answer: unique symbol;
573
+ type Question<T> = TriageQuestion & {
574
+ readonly [answer]?: T;
575
+ };
576
+ export declare function noul(prompt: string, criteria?: string): Question<number>;
577
+ export declare function choice<const O extends string>(options: readonly O[] | Record<O, string>, prompt: string): Question<O>;
578
+ export declare function score(levels: readonly string[], prompt: string): Question<number>;
579
+ type Answers<Q extends Record<string, Question<unknown>>> = { [K in keyof Q]: Q[K] extends Question<infer T> ? T : never; } & {
580
+ confidence: number;
581
+ };
582
+ interface Rule<A> {
583
+ name?: string;
584
+ live?: boolean;
585
+ when(answers: A): boolean;
586
+ then: TriageDecision | TriageDecision[];
587
+ }
588
+ interface Triage<Q extends Record<string, Question<unknown>> = Record<string, Question<unknown>>> {
589
+ instructions: string;
590
+ questions: Q;
591
+ rules: Rule<Answers<Q>>[];
592
+ }
593
+ export declare function triage<Q extends Record<string, Question<unknown>>>(options: {
594
+ instructions?: string;
595
+ questions: Q;
596
+ rules?: Rule<Answers<Q>>[];
597
+ }): Triage<Q>;
598
+ export declare const setState: (state: string) => TriageDecision;
599
+ export declare const tag: (name: string) => TriageDecision;
600
+ export declare const run: <S>(action: Action<any, S>, input?: Prefill<S>) => TriageDecision;
601
+ //#endregion
602
+ //#region src/define/inbox/inbox.d.ts
603
+ type Duration = `${number}${"m" | "h" | "d"}`;
604
+ interface ItemView<D> {
605
+ title: string;
606
+ data: D;
607
+ record: string | null;
608
+ occurrences: FieldValue;
609
+ users: FieldValue;
610
+ firstSeen: FieldValue;
611
+ lastSeen: FieldValue;
612
+ due: FieldValue;
613
+ }
614
+ interface InboxOptions<S extends Schema | undefined> {
615
+ label?: string;
616
+ icon?: string;
617
+ resource?: Resource;
618
+ layout?: Layout;
619
+ states?: string[];
620
+ closed?: string[];
621
+ reopenOn?: "new-occurrence";
622
+ reopenFrom?: string[];
623
+ data?: S;
624
+ title?: (data: InboxData<S>) => string;
625
+ render?: (item: ItemView<InboxData<S>>) => Awaitable<BlockInput[]>;
626
+ columns?: string[];
627
+ intake?: boolean | {
628
+ title?: string;
629
+ description?: string;
630
+ };
631
+ triage?: Triage;
632
+ reply?: {
633
+ to: (item: ItemView<InboxData<S>>) => string | undefined;
634
+ send: (email: OutgoingEmail<InboxData<S>>) => Awaitable<void>;
635
+ };
636
+ onState?: (change: StateChange<InboxData<S>>) => Awaitable<void>;
637
+ sla?: Record<string, Duration>;
638
+ }
639
+ interface OutgoingEmail<D> {
640
+ item: {
641
+ id: string;
642
+ title: string;
643
+ record: string | null;
644
+ data: D;
645
+ };
646
+ to: string;
647
+ subject: string;
648
+ text: string;
649
+ thread: string;
650
+ actor: Actor;
651
+ }
652
+ interface StateChange<D> {
653
+ item: {
654
+ id: string;
655
+ title: string;
656
+ record: string | null;
657
+ data: D;
658
+ };
659
+ from: string;
660
+ to: string;
661
+ actor: Actor;
662
+ }
663
+ type InboxData<S> = S extends Schema ? InferOutput<S> : Record<string, unknown>;
664
+ type InboxInput<S> = S extends Schema ? InferInput<S> : Record<string, unknown>;
665
+ interface Inbox<S extends Schema | undefined = any> extends Located {
666
+ readonly name: string;
667
+ readonly options: InboxOptions<S>;
668
+ readonly states: string[];
669
+ readonly closed: string[];
670
+ }
671
+ export declare function inbox<S extends Schema | undefined = undefined>(name: string, options: InboxOptions<S>): Inbox<S>;
672
+ //#endregion
673
+ //#region src/define/controls/flag.d.ts
674
+ interface Guard {
675
+ inbox: Inbox;
676
+ perHour: number;
677
+ then?: "pause" | "revert";
678
+ }
679
+ interface FlagOptions<A = undefined> {
680
+ label?: string;
681
+ description?: string;
682
+ target?: Resource;
683
+ attributes?: A;
684
+ guard?: Guard | Guard[];
685
+ danger?: Danger;
686
+ approval?: boolean;
687
+ }
688
+ type Attributes<A> = A extends AnySchema ? Partial<InferOutput<A>> : Record<string, Attribute | null | undefined>;
689
+ type FlagContext<A = undefined> = {
690
+ key?: string;
691
+ } & Attributes<A>;
692
+ interface Flag<T = unknown, A = unknown> extends Located {
693
+ readonly name: string;
694
+ readonly options: FlagOptions<AnySchema> & {
695
+ value?: AnySchema;
696
+ default: T;
697
+ };
698
+ readonly context?: FlagContext<A>;
699
+ }
700
+ export declare function flag<A extends AnySchema | undefined = undefined>(name: string, options?: FlagOptions<A> & {
701
+ default?: boolean;
702
+ }): Flag<boolean, A>;
703
+ export declare function flag<S extends AnySchema, A extends AnySchema | undefined = undefined>(name: string, options: FlagOptions<A> & {
704
+ value: S;
705
+ default: InferOutput<S>;
706
+ }): Flag<InferOutput<S>, A>;
707
+ //#endregion
708
+ //#region src/define/inbox/view.d.ts
709
+ type Filter = Omit<ViewFilter, "state"> & {
710
+ state?: string | string[];
711
+ };
712
+ interface ViewOptions {
713
+ label?: string;
714
+ inbox: Inbox;
715
+ filter?: Filter;
716
+ layout?: Layout;
717
+ columns?: string[];
718
+ sort?: Sort;
719
+ }
720
+ interface View extends Located {
721
+ readonly name: string;
722
+ readonly options: ViewOptions;
723
+ }
724
+ export declare function view(name: string, options: ViewOptions): View;
725
+ //#endregion
726
+ //#region src/blocks.d.ts
727
+ type FieldInput = FieldValue | Date | undefined;
728
+ interface PendingAttachment {
729
+ type: "attachment";
730
+ name: string;
731
+ contentType: string;
732
+ data: Blob | ArrayBuffer | Uint8Array;
733
+ }
734
+ interface ColumnsInput {
735
+ type: "columns";
736
+ columns: BlockInput[][];
737
+ }
738
+ type BlockInput = Block | PendingAttachment | ColumnsInput;
739
+ type ResourceLike = string | {
740
+ readonly name: string;
741
+ };
742
+ type Points = {
743
+ at: Date | number;
744
+ value: number;
745
+ }[];
746
+ declare function chart(metric: "occurrences", options?: {
747
+ range?: ChartRange;
748
+ title?: string;
749
+ }): Block;
750
+ declare function chart(points: Points, options?: {
751
+ title?: string;
752
+ }): Block;
753
+ declare function chart(inbox: Inbox, options?: {
754
+ range?: ChartRange;
755
+ title?: string;
756
+ }): Block;
757
+ type Listing = Inbox | View;
758
+ type ActionTarget = Action | string;
759
+ interface ButtonOptions {
760
+ record?: string;
761
+ label?: string;
762
+ }
763
+ type ButtonInput<S = any> = ActionTarget | (ButtonOptions & {
764
+ action: string;
765
+ input?: Record<string, unknown>;
766
+ }) | (ButtonOptions & {
767
+ action: Action<any, S>;
768
+ input?: Prefill<S>;
769
+ });
770
+ export declare const b: {
771
+ markdown: (text: string) => Block;
772
+ fields: (fields: Record<string, FieldInput>) => Block;
773
+ code: (code: string, options?: {
774
+ lang?: string;
775
+ title?: string;
776
+ }) => Block;
777
+ chart: typeof chart;
778
+ attachment: (attachment: {
779
+ name: string;
780
+ url: string;
781
+ contentType?: string;
782
+ size?: number;
783
+ } | Omit<PendingAttachment, "type">) => BlockInput;
784
+ record: (resource: ResourceLike, id: string, title?: string) => Block;
785
+ ref: (resource: ResourceLike, id: string, title?: string) => FieldValue;
786
+ sensitive: (value: string | number, options?: {
787
+ hint?: string;
788
+ }) => FieldValue;
789
+ timeline: (entries: {
790
+ at: Date | number;
791
+ text: string;
792
+ }[]) => Block;
793
+ table: (rows: Record<string, FieldInput>[], columns?: string[]) => Block;
794
+ stats: (stats: Record<string, FieldInput | {
795
+ value: FieldInput;
796
+ note?: string;
797
+ }>) => Block;
798
+ actions: <S extends unknown[]>(...buttons: { [K in keyof S]: ButtonInput<S[K]>; }) => Block;
799
+ form: <S>(action: ButtonInput<S>) => Block;
800
+ columns: (...columns: BlockInput[][]) => BlockInput;
801
+ count: (target: Listing, options?: {
802
+ filter?: Filter;
803
+ label?: string;
804
+ }) => Block;
805
+ items: (target: Listing, options?: {
806
+ filter?: Filter;
807
+ label?: string;
808
+ limit?: number;
809
+ }) => Block;
810
+ flag: (flag: Flag) => Block;
811
+ edit: (value: FieldInput, action: ActionTarget, options?: {
812
+ record?: string;
813
+ field?: string;
814
+ }) => FieldValue;
815
+ };
816
+ //#endregion
817
+ //#region src/define/config.d.ts
818
+ interface ConfigOptions {
819
+ project: string;
820
+ include: string[];
821
+ delivery?: Delivery;
822
+ environments?: string[];
823
+ sync?: string;
824
+ }
825
+ interface Config extends Located {
826
+ readonly options: Required<ConfigOptions>;
827
+ }
828
+ export declare function defineConfig(options: ConfigOptions): Config;
829
+ //#endregion
830
+ //#region src/define/console/page.d.ts
831
+ type Params<P> = P extends AnySchema ? InferOutput<P> : Record<string, never>;
832
+ interface PageContext<P> {
833
+ params: P;
834
+ actor: Actor;
835
+ }
836
+ type PageContent<P> = BlockInput[] | ((context: PageContext<Params<P>>) => Awaitable<BlockInput[]>);
837
+ interface PageOptions<P extends AnySchema | undefined> {
838
+ label?: string;
839
+ icon?: string;
840
+ params?: P;
841
+ render: PageContent<P>;
842
+ }
843
+ interface Page extends Located {
844
+ readonly name: string;
845
+ readonly options: PageOptions<any>;
846
+ }
847
+ export declare function page<P extends AnySchema | undefined = undefined>(name: string, options: PageOptions<P>): Page;
848
+ export declare function home<P extends AnySchema | undefined = undefined>(options: PageContent<P> | PageOptions<P>): Page;
849
+ //#endregion
850
+ //#region src/define/console/role.d.ts
851
+ interface RoleOptions {
852
+ label?: string;
853
+ inboxes?: Inbox[];
854
+ resources?: Resource[];
855
+ actions?: ActionRef[];
856
+ pages?: Page[];
857
+ flags?: Flag[];
858
+ reveal?: boolean;
859
+ status?: boolean;
860
+ }
861
+ interface Role extends Located {
862
+ readonly name: string;
863
+ readonly options: RoleOptions;
864
+ }
865
+ export declare function role(name: string, options: RoleOptions): Role;
866
+ //#endregion
867
+ //#region src/define/console/space.d.ts
868
+ interface SpaceOptions {
869
+ label?: string;
870
+ icon?: string;
871
+ home?: Page | PageContent<undefined>;
872
+ inboxes?: Inbox[];
873
+ resources?: Resource[];
874
+ pages?: Page[];
875
+ flags?: Flag[];
876
+ }
877
+ interface Space extends Located {
878
+ readonly name: string;
879
+ readonly options: SpaceOptions;
880
+ readonly home: Page | null;
881
+ }
882
+ export declare function space(name: string, options: SpaceOptions): Space;
883
+ //#endregion
884
+ //#region src/define/inbox/notify.d.ts
885
+ interface Channel {
886
+ readonly channel: string;
887
+ }
888
+ export declare function slack(channel: string): Channel;
889
+ interface NotifyOptions {
890
+ inboxes: Inbox[];
891
+ on: NotifyTrigger[];
892
+ to: (Role | Channel)[];
893
+ }
894
+ interface Notify extends Located {
895
+ readonly name: string;
896
+ readonly options: NotifyOptions;
897
+ }
898
+ export declare function notify(name: string, options: NotifyOptions): Notify;
899
+ //#endregion
900
+ //#region src/define/controls/status.d.ts
901
+ interface StatusComponent {
902
+ label: string;
903
+ description?: string;
904
+ monitored?: boolean;
905
+ check?: string;
906
+ }
907
+ interface StatusOptions {
908
+ title?: string;
909
+ logo?: string | {
910
+ light: string;
911
+ dark: string;
912
+ };
913
+ website?: string;
914
+ css?: string;
915
+ components: Record<string, string | StatusComponent>;
916
+ alert?: (Role | Channel)[];
917
+ after?: Duration;
918
+ }
919
+ interface Status extends Located {
920
+ readonly options: StatusOptions;
921
+ }
922
+ export declare function status(options: StatusOptions): Status;
923
+ //#endregion
924
+ //#region src/client/transport.d.ts
925
+ type Fetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
926
+ export declare class PultError extends Error {
927
+ readonly status: number;
928
+ readonly code?: string | undefined;
929
+ constructor(message: string, status: number, code?: string | undefined);
930
+ }
931
+ //#endregion
932
+ //#region src/client/dispatch.d.ts
933
+ interface Project<Component extends string = string> {
934
+ manifest: Manifest<Component>;
935
+ modules: Record<string, () => Promise<Record<string, unknown>>>;
936
+ }
937
+ //#endregion
938
+ //#region src/client/socket.d.ts
939
+ interface Connection {
940
+ close(): void;
941
+ }
942
+ //#endregion
943
+ //#region src/client/pult.d.ts
944
+ interface PultOptions<Component extends string = string> {
945
+ key?: string;
946
+ project: Project<Component>;
947
+ url?: string;
948
+ fetch?: Fetch;
949
+ }
950
+ interface Suggestion<S = any> {
951
+ action: Action<any, S>;
952
+ input?: Prefill<S>;
953
+ reason?: string;
954
+ }
955
+ interface SendOptions<S extends Schema | undefined, Suggested extends unknown[] = unknown[]> {
956
+ title?: string;
957
+ fingerprint?: string;
958
+ record?: string;
959
+ data: InboxInput<S>;
960
+ tags?: string[];
961
+ suggest?: { [K in keyof Suggested]: Suggestion<Suggested[K]>; };
962
+ }
963
+ interface ListenOptions {
964
+ onStatus?: (status: "connected" | "disconnected") => void;
965
+ }
966
+ export declare function createPult<Component extends string = string>({ key, project, url, fetch }: PultOptions<Component>): {
967
+ send: <S extends Schema | undefined, Suggested extends unknown[]>(inbox: Inbox<S>, item: SendOptions<S, Suggested>) => Promise<SendResult>;
968
+ log: (resource: Resource, id: string, text: string, options?: {
969
+ blocks?: BlockInput[];
970
+ by?: string;
971
+ }) => Promise<void>;
972
+ receive: (message: IncomingMessage) => Promise<{
973
+ item: string;
974
+ } | null>;
975
+ flag: <T, A>(definition: Flag<T, A>, context?: string | FlagContext<A>) => Promise<T>;
976
+ status: {
977
+ set(component: Component, state: ComponentState): Promise<void>;
978
+ };
979
+ listen: (options?: ListenOptions) => Connection;
980
+ handler: () => (request: Request, context?: {
981
+ waitUntil(work: Promise<unknown>): void;
982
+ }) => Promise<Response>;
983
+ deploy: () => Promise<{
984
+ version: string;
985
+ }>;
986
+ };
987
+ type Pult = ReturnType<typeof createPult>;
988
+ //#endregion
989
+ 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 };