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