primitive-functions 0.3.0-alpha.3 → 0.3.0-alpha.5
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.ts +129 -147
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -8,6 +8,20 @@
|
|
|
8
8
|
* against (#3180). The published package's RUNTIME is a stub that throws from
|
|
9
9
|
* every export on purpose: the platform substitutes its own copy at invoke
|
|
10
10
|
* time, and reaching the stub means it did not.
|
|
11
|
+
*
|
|
12
|
+
* WHICH USER A CALL IS ABOUT. Every `ctx.api` and `ctx.agents` call that is
|
|
13
|
+
* about one user says which user in `userId`. Omitted, it means the invoking
|
|
14
|
+
* user (`ctx.user`); in a run with no caller (cron, a webhook, the system
|
|
15
|
+
* door, a nested start under one of them) it must be named, or the call
|
|
16
|
+
* rejects with `FUNCTION_SUBJECT_REQUIRED`. Naming a user other than the
|
|
17
|
+
* invoking user — whether `userId` is optional or required on the call — is
|
|
18
|
+
* allowed only in a run with no caller or one an app owner or admin invoked,
|
|
19
|
+
* with the role read at the call; an ordinary member's run, and every run an
|
|
20
|
+
* agent drives (a tool, context or history run and anything it starts),
|
|
21
|
+
* rejects with `SUBJECT_USER_FORBIDDEN`. A named user who is not a member of
|
|
22
|
+
* the app rejects with `SUBJECT_USER_NOT_FOUND`. Calls that hand something
|
|
23
|
+
* to a user (`notifications.send`, `users.setProfile`, a channel grant)
|
|
24
|
+
* and app-wide reads are outside this rule.
|
|
11
25
|
*/
|
|
12
26
|
|
|
13
27
|
/**
|
|
@@ -170,7 +184,7 @@ export interface PrimitivePlatformError extends Error {
|
|
|
170
184
|
/**
|
|
171
185
|
* The route's structured `details`, or null when its refusal carries none
|
|
172
186
|
* (#3803). `AGENT_SESSION_VARIABLES_INVALID` lists `errors` as
|
|
173
|
-
* `{ path, message }
|
|
187
|
+
* `{ path, message }`.
|
|
174
188
|
*/
|
|
175
189
|
details: unknown;
|
|
176
190
|
}
|
|
@@ -228,18 +242,24 @@ export interface FunctionApi {
|
|
|
228
242
|
/** `agentSessions.get` — GET /agent-sessions/{sessionId}. Get an agent session */
|
|
229
243
|
"get"(args: {
|
|
230
244
|
"sessionId": string | number;
|
|
245
|
+
"userId"?: string | number;
|
|
231
246
|
}): Promise<any>;
|
|
232
247
|
/** `agentSessions.list` — GET /agent-sessions. List one user's agent sessions */
|
|
233
248
|
"list"(args?: {
|
|
234
|
-
"userId"?: string | number
|
|
249
|
+
"userId"?: string | number;
|
|
235
250
|
"agent"?: string | number | boolean;
|
|
236
251
|
"scope"?: string | number | boolean;
|
|
237
252
|
"limit"?: string | number | boolean;
|
|
238
253
|
"cursor"?: string | number | boolean;
|
|
239
254
|
}): Promise<any>;
|
|
255
|
+
/** `agentSessions.markRead` — POST /agent-sessions/{sessionId}/read. Mark an agent session read */
|
|
256
|
+
"markRead"(args: {
|
|
257
|
+
"sessionId": string | number;
|
|
258
|
+
}): Promise<any>;
|
|
240
259
|
/** `agentSessions.recordEvent` — POST /agent-sessions/{sessionId}/events. Record an event in an agent session (ctx.agents.recordEvent) */
|
|
241
260
|
"recordEvent"(args: {
|
|
242
261
|
"sessionId": string | number;
|
|
262
|
+
"userId"?: string | number;
|
|
243
263
|
body: unknown;
|
|
244
264
|
}): Promise<any>;
|
|
245
265
|
/** `agentSessions.removeMember` — DELETE /agent-sessions/{sessionId}/members/{userId}. Remove a member from an agent session */
|
|
@@ -490,6 +510,7 @@ export interface FunctionApi {
|
|
|
490
510
|
}): Promise<any>;
|
|
491
511
|
/** `collections.list` — GET /collections. List collections */
|
|
492
512
|
"list"(args?: {
|
|
513
|
+
"userId"?: string | number;
|
|
493
514
|
"limit"?: string | number | boolean;
|
|
494
515
|
"cursor"?: string | number | boolean;
|
|
495
516
|
}): Promise<any>;
|
|
@@ -556,30 +577,14 @@ export interface FunctionApi {
|
|
|
556
577
|
"dryRun"?: string | number | boolean;
|
|
557
578
|
body: unknown;
|
|
558
579
|
}): Promise<any>;
|
|
559
|
-
/** `databaseTypeConfigs.createOperation` — POST /databases/types/{databaseType}/operations. Create an operation for a database type */
|
|
560
|
-
"createOperation"(args: {
|
|
561
|
-
"databaseType": string | number;
|
|
562
|
-
"dryRun"?: string | number | boolean;
|
|
563
|
-
body: unknown;
|
|
564
|
-
}): Promise<any>;
|
|
565
580
|
/** `databaseTypeConfigs.delete` — DELETE /databases/types/{databaseType}. Delete a database type */
|
|
566
581
|
"delete"(args: {
|
|
567
582
|
"databaseType": string | number;
|
|
568
583
|
}): Promise<any>;
|
|
569
|
-
/** `databaseTypeConfigs.deleteOperation` — DELETE /databases/types/{databaseType}/operations/{name}. Delete an operation for a database type */
|
|
570
|
-
"deleteOperation"(args: {
|
|
571
|
-
"databaseType": string | number;
|
|
572
|
-
"name": string | number;
|
|
573
|
-
}): Promise<any>;
|
|
574
584
|
/** `databaseTypeConfigs.get` — GET /databases/types/{databaseType}. Get a database type */
|
|
575
585
|
"get"(args: {
|
|
576
586
|
"databaseType": string | number;
|
|
577
587
|
}): Promise<any>;
|
|
578
|
-
/** `databaseTypeConfigs.getOperation` — GET /databases/types/{databaseType}/operations/{name}. Get an operation for a database type */
|
|
579
|
-
"getOperation"(args: {
|
|
580
|
-
"databaseType": string | number;
|
|
581
|
-
"name": string | number;
|
|
582
|
-
}): Promise<any>;
|
|
583
588
|
/** `databaseTypeConfigs.getReindexStatus` — GET /databases/types/{databaseType}/reindex-status. Status of the index back-provision fan-out for a type */
|
|
584
589
|
"getReindexStatus"(args: {
|
|
585
590
|
"databaseType": string | number;
|
|
@@ -587,54 +592,16 @@ export interface FunctionApi {
|
|
|
587
592
|
}): Promise<any>;
|
|
588
593
|
/** `databaseTypeConfigs.list` — GET /databases/types. List database types */
|
|
589
594
|
"list"(args?: Record<string, never>): Promise<any>;
|
|
590
|
-
/** `databaseTypeConfigs.listOperations` — GET /databases/types/{databaseType}/operations. List operations for a database type */
|
|
591
|
-
"listOperations"(args: {
|
|
592
|
-
"databaseType": string | number;
|
|
593
|
-
}): Promise<any>;
|
|
594
595
|
/** `databaseTypeConfigs.scaffoldSchema` — POST /databases/types/{databaseType}/schema:scaffold. Scaffold a starter schema for a database type */
|
|
595
596
|
"scaffoldSchema"(args: {
|
|
596
597
|
"databaseType": string | number;
|
|
597
598
|
}): Promise<any>;
|
|
598
|
-
"subscriptions": {
|
|
599
|
-
/** `databaseTypeConfigs.subscriptions.create` — POST /databases/types/{databaseType}/subscriptions. Create a subscription for a database type */
|
|
600
|
-
"create"(args: {
|
|
601
|
-
"databaseType": string | number;
|
|
602
|
-
body: unknown;
|
|
603
|
-
}): Promise<any>;
|
|
604
|
-
/** `databaseTypeConfigs.subscriptions.delete` — DELETE /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Delete a database type subscription */
|
|
605
|
-
"delete"(args: {
|
|
606
|
-
"databaseType": string | number;
|
|
607
|
-
"subscriptionKey": string | number;
|
|
608
|
-
}): Promise<any>;
|
|
609
|
-
/** `databaseTypeConfigs.subscriptions.get` — GET /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Get a database type subscription */
|
|
610
|
-
"get"(args: {
|
|
611
|
-
"databaseType": string | number;
|
|
612
|
-
"subscriptionKey": string | number;
|
|
613
|
-
}): Promise<any>;
|
|
614
|
-
/** `databaseTypeConfigs.subscriptions.list` — GET /databases/types/{databaseType}/subscriptions. List subscriptions for a database type */
|
|
615
|
-
"list"(args: {
|
|
616
|
-
"databaseType": string | number;
|
|
617
|
-
}): Promise<any>;
|
|
618
|
-
/** `databaseTypeConfigs.subscriptions.update` — PUT /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Update a database type subscription */
|
|
619
|
-
"update"(args: {
|
|
620
|
-
"databaseType": string | number;
|
|
621
|
-
"subscriptionKey": string | number;
|
|
622
|
-
body: unknown;
|
|
623
|
-
}): Promise<any>;
|
|
624
|
-
};
|
|
625
599
|
/** `databaseTypeConfigs.update` — PATCH /databases/types/{databaseType}. Update a database type */
|
|
626
600
|
"update"(args: {
|
|
627
601
|
"databaseType": string | number;
|
|
628
602
|
"dryRun"?: string | number | boolean;
|
|
629
603
|
body: unknown;
|
|
630
604
|
}): Promise<any>;
|
|
631
|
-
/** `databaseTypeConfigs.updateOperation` — PATCH /databases/types/{databaseType}/operations/{name}. Update an operation for a database type */
|
|
632
|
-
"updateOperation"(args: {
|
|
633
|
-
"databaseType": string | number;
|
|
634
|
-
"name": string | number;
|
|
635
|
-
"dryRun"?: string | number | boolean;
|
|
636
|
-
body: unknown;
|
|
637
|
-
}): Promise<any>;
|
|
638
605
|
};
|
|
639
606
|
"databases": {
|
|
640
607
|
/** `databases.addManager` — PUT /databases/{databaseId}/permissions. Set a user's database permission */
|
|
@@ -650,19 +617,6 @@ export interface FunctionApi {
|
|
|
650
617
|
"delete"(args: {
|
|
651
618
|
"databaseId": string | number;
|
|
652
619
|
}): Promise<any>;
|
|
653
|
-
/** `databases.executeBatch` — POST /databases/{databaseId}/operations/{name}/batch. Execute a database operation in batch */
|
|
654
|
-
"executeBatch"(args: {
|
|
655
|
-
"databaseId": string | number;
|
|
656
|
-
"name": string | number;
|
|
657
|
-
body: unknown;
|
|
658
|
-
}): Promise<any>;
|
|
659
|
-
/** `databases.executeOperation` — POST /databases/{databaseId}/operations/{name}/execute. Execute a database operation */
|
|
660
|
-
"executeOperation"(args: {
|
|
661
|
-
"databaseId": string | number;
|
|
662
|
-
"name": string | number;
|
|
663
|
-
"dryRun"?: string | number | boolean;
|
|
664
|
-
body?: unknown;
|
|
665
|
-
}): Promise<any>;
|
|
666
620
|
/** `databases.get` — GET /databases/{databaseId}. Get a database by id */
|
|
667
621
|
"get"(args: {
|
|
668
622
|
"databaseId": string | number;
|
|
@@ -672,118 +626,108 @@ export interface FunctionApi {
|
|
|
672
626
|
"databaseId": string | number;
|
|
673
627
|
body: unknown;
|
|
674
628
|
}): Promise<any>;
|
|
675
|
-
/** `databases.importBulk` — POST /databases/{databaseId}/operations/{name}/import-bulk. Bulk-import records via a database operation */
|
|
676
|
-
"importBulk"(args: {
|
|
677
|
-
"databaseId": string | number;
|
|
678
|
-
"name": string | number;
|
|
679
|
-
body: unknown;
|
|
680
|
-
}): Promise<any>;
|
|
681
629
|
/** `databases.list` — GET /databases. List databases */
|
|
682
630
|
"list"(args?: Record<string, never>): Promise<any>;
|
|
683
631
|
/** `databases.listGroupPermissions` — GET /databases/{databaseId}/group-permissions. List a database's group permissions */
|
|
684
632
|
"listGroupPermissions"(args: {
|
|
685
633
|
"databaseId": string | number;
|
|
686
634
|
}): Promise<any>;
|
|
687
|
-
/** `databases.listOperations` — GET /databases/{databaseId}/operations. List operations runnable on a database */
|
|
688
|
-
"listOperations"(args: {
|
|
689
|
-
"databaseId": string | number;
|
|
690
|
-
}): Promise<any>;
|
|
691
635
|
/** `databases.listPermissions` — GET /databases/{databaseId}/permissions. List a database's user permissions */
|
|
692
636
|
"listPermissions"(args: {
|
|
693
637
|
"databaseId": string | number;
|
|
694
638
|
}): Promise<any>;
|
|
695
639
|
"records": {
|
|
696
|
-
/** `databases.records.addToSet` — POST /databases/{databaseId}/records/stringset/add. Database records: stringset/add (
|
|
640
|
+
/** `databases.records.addToSet` — POST /databases/{databaseId}/records/stringset/add. Database records: stringset/add (app admin or owner) */
|
|
697
641
|
"addToSet"(args: {
|
|
698
642
|
"databaseId": string | number;
|
|
699
643
|
body: unknown;
|
|
700
644
|
}): Promise<any>;
|
|
701
|
-
/** `databases.records.aggregate` — POST /databases/{databaseId}/records/aggregate. Database records: aggregate (
|
|
645
|
+
/** `databases.records.aggregate` — POST /databases/{databaseId}/records/aggregate. Database records: aggregate (app admin or owner) */
|
|
702
646
|
"aggregate"(args: {
|
|
703
647
|
"databaseId": string | number;
|
|
704
648
|
body: unknown;
|
|
705
649
|
}): Promise<any>;
|
|
706
|
-
/** `databases.records.batch` — POST /databases/{databaseId}/records/batch. Database records: batch (
|
|
650
|
+
/** `databases.records.batch` — POST /databases/{databaseId}/records/batch. Database records: batch (app admin or owner) */
|
|
707
651
|
"batch"(args: {
|
|
708
652
|
"databaseId": string | number;
|
|
709
653
|
body: unknown;
|
|
710
654
|
}): Promise<any>;
|
|
711
|
-
/** `databases.records.count` — POST /databases/{databaseId}/records/count. Database records: count (
|
|
655
|
+
/** `databases.records.count` — POST /databases/{databaseId}/records/count. Database records: count (app admin or owner) */
|
|
712
656
|
"count"(args: {
|
|
713
657
|
"databaseId": string | number;
|
|
714
658
|
body: unknown;
|
|
715
659
|
}): Promise<any>;
|
|
716
|
-
/** `databases.records.delete` — POST /databases/{databaseId}/records/delete. Database records: delete (
|
|
660
|
+
/** `databases.records.delete` — POST /databases/{databaseId}/records/delete. Database records: delete (app admin or owner) */
|
|
717
661
|
"delete"(args: {
|
|
718
662
|
"databaseId": string | number;
|
|
719
663
|
body: unknown;
|
|
720
664
|
}): Promise<any>;
|
|
721
|
-
/** `databases.records.describe` — GET /databases/{databaseId}/records/describe. Database records: describe (
|
|
665
|
+
/** `databases.records.describe` — GET /databases/{databaseId}/records/describe. Database records: describe (app admin or owner) */
|
|
722
666
|
"describe"(args: {
|
|
723
667
|
"databaseId": string | number;
|
|
724
668
|
"modelName"?: string | number | boolean;
|
|
725
669
|
}): Promise<any>;
|
|
726
|
-
/** `databases.records.dropIndex` — POST /databases/{databaseId}/records/index/drop. Database records: index/drop (
|
|
670
|
+
/** `databases.records.dropIndex` — POST /databases/{databaseId}/records/index/drop. Database records: index/drop (app admin or owner) */
|
|
727
671
|
"dropIndex"(args: {
|
|
728
672
|
"databaseId": string | number;
|
|
729
673
|
body: unknown;
|
|
730
674
|
}): Promise<any>;
|
|
731
|
-
/** `databases.records.dropUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/drop. Database records: unique-constraint/drop (
|
|
675
|
+
/** `databases.records.dropUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/drop. Database records: unique-constraint/drop (app admin or owner) */
|
|
732
676
|
"dropUniqueConstraint"(args: {
|
|
733
677
|
"databaseId": string | number;
|
|
734
678
|
body: unknown;
|
|
735
679
|
}): Promise<any>;
|
|
736
|
-
/** `databases.records.increment` — POST /databases/{databaseId}/records/increment. Database records: increment (
|
|
680
|
+
/** `databases.records.increment` — POST /databases/{databaseId}/records/increment. Database records: increment (app admin or owner) */
|
|
737
681
|
"increment"(args: {
|
|
738
682
|
"databaseId": string | number;
|
|
739
683
|
body: unknown;
|
|
740
684
|
}): Promise<any>;
|
|
741
|
-
/** `databases.records.listIndexes` — GET /databases/{databaseId}/records/indexes. Database records: indexes (
|
|
685
|
+
/** `databases.records.listIndexes` — GET /databases/{databaseId}/records/indexes. Database records: indexes (app admin or owner) */
|
|
742
686
|
"listIndexes"(args: {
|
|
743
687
|
"databaseId": string | number;
|
|
744
688
|
"modelName"?: string | number | boolean;
|
|
745
689
|
}): Promise<any>;
|
|
746
|
-
/** `databases.records.listUniqueConstraints` — GET /databases/{databaseId}/records/unique-constraints. Database records: unique-constraints (
|
|
690
|
+
/** `databases.records.listUniqueConstraints` — GET /databases/{databaseId}/records/unique-constraints. Database records: unique-constraints (app admin or owner) */
|
|
747
691
|
"listUniqueConstraints"(args: {
|
|
748
692
|
"databaseId": string | number;
|
|
749
693
|
"modelName"?: string | number | boolean;
|
|
750
694
|
}): Promise<any>;
|
|
751
|
-
/** `databases.records.models` — GET /databases/{databaseId}/records/models. Database records: models (
|
|
695
|
+
/** `databases.records.models` — GET /databases/{databaseId}/records/models. Database records: models (app admin or owner) */
|
|
752
696
|
"models"(args: {
|
|
753
697
|
"databaseId": string | number;
|
|
754
698
|
"modelName"?: string | number | boolean;
|
|
755
699
|
}): Promise<any>;
|
|
756
|
-
/** `databases.records.patch` — POST /databases/{databaseId}/records/patch. Database records: patch (
|
|
700
|
+
/** `databases.records.patch` — POST /databases/{databaseId}/records/patch. Database records: patch (app admin or owner) */
|
|
757
701
|
"patch"(args: {
|
|
758
702
|
"databaseId": string | number;
|
|
759
703
|
body: unknown;
|
|
760
704
|
}): Promise<any>;
|
|
761
|
-
/** `databases.records.query` — POST /databases/{databaseId}/records/query. Database records: query (
|
|
705
|
+
/** `databases.records.query` — POST /databases/{databaseId}/records/query. Database records: query (app admin or owner) */
|
|
762
706
|
"query"(args: {
|
|
763
707
|
"databaseId": string | number;
|
|
764
708
|
body: unknown;
|
|
765
709
|
}): Promise<{ items: any[]; hasMore: boolean; nextCursor?: string; prevCursor?: string }>;
|
|
766
|
-
/** `databases.records.registerIndex` — POST /databases/{databaseId}/records/index/register. Database records: index/register (
|
|
710
|
+
/** `databases.records.registerIndex` — POST /databases/{databaseId}/records/index/register. Database records: index/register (app admin or owner) */
|
|
767
711
|
"registerIndex"(args: {
|
|
768
712
|
"databaseId": string | number;
|
|
769
713
|
body: unknown;
|
|
770
714
|
}): Promise<any>;
|
|
771
|
-
/** `databases.records.registerUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/register. Database records: unique-constraint/register (
|
|
715
|
+
/** `databases.records.registerUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/register. Database records: unique-constraint/register (app admin or owner) */
|
|
772
716
|
"registerUniqueConstraint"(args: {
|
|
773
717
|
"databaseId": string | number;
|
|
774
718
|
body: unknown;
|
|
775
719
|
}): Promise<any>;
|
|
776
|
-
/** `databases.records.removeFromSet` — POST /databases/{databaseId}/records/stringset/remove. Database records: stringset/remove (
|
|
720
|
+
/** `databases.records.removeFromSet` — POST /databases/{databaseId}/records/stringset/remove. Database records: stringset/remove (app admin or owner) */
|
|
777
721
|
"removeFromSet"(args: {
|
|
778
722
|
"databaseId": string | number;
|
|
779
723
|
body: unknown;
|
|
780
724
|
}): Promise<any>;
|
|
781
|
-
/** `databases.records.save` — POST /databases/{databaseId}/records/save. Database records: save (
|
|
725
|
+
/** `databases.records.save` — POST /databases/{databaseId}/records/save. Database records: save (app admin or owner) */
|
|
782
726
|
"save"(args: {
|
|
783
727
|
"databaseId": string | number;
|
|
784
728
|
body: unknown;
|
|
785
729
|
}): Promise<any>;
|
|
786
|
-
/** `databases.records.syncIndexes` — POST /databases/{databaseId}/records/indexes/sync. Database records: indexes/sync (
|
|
730
|
+
/** `databases.records.syncIndexes` — POST /databases/{databaseId}/records/indexes/sync. Database records: indexes/sync (app admin or owner) */
|
|
787
731
|
"syncIndexes"(args: {
|
|
788
732
|
"databaseId": string | number;
|
|
789
733
|
body: unknown;
|
|
@@ -804,12 +748,6 @@ export interface FunctionApi {
|
|
|
804
748
|
"databaseId": string | number;
|
|
805
749
|
"userId": string | number;
|
|
806
750
|
}): Promise<any>;
|
|
807
|
-
/** `databases.runOperation` — POST /databases/{databaseId}/operations/{name}/run. Run a database operation under a server function's grants */
|
|
808
|
-
"runOperation"(args: {
|
|
809
|
-
"databaseId": string | number;
|
|
810
|
-
"name": string | number;
|
|
811
|
-
body?: unknown;
|
|
812
|
-
}): Promise<any>;
|
|
813
751
|
/** `databases.transferOwnership` — POST /databases/{databaseId}/permissions/transfer. Transfer database ownership */
|
|
814
752
|
"transferOwnership"(args: {
|
|
815
753
|
"databaseId": string | number;
|
|
@@ -838,7 +776,7 @@ export interface FunctionApi {
|
|
|
838
776
|
"delete"(args: {
|
|
839
777
|
"scope": string | number;
|
|
840
778
|
"aliasKey": string | number;
|
|
841
|
-
"userId"?: string | number
|
|
779
|
+
"userId"?: string | number;
|
|
842
780
|
}): Promise<any>;
|
|
843
781
|
/** `documents.aliases.listForDocument` — GET /documents/{documentId}/aliases. List aliases bound to a document */
|
|
844
782
|
"listForDocument"(args: {
|
|
@@ -848,7 +786,7 @@ export interface FunctionApi {
|
|
|
848
786
|
"resolve"(args: {
|
|
849
787
|
"scope": string | number;
|
|
850
788
|
"aliasKey": string | number;
|
|
851
|
-
"userId"?: string | number
|
|
789
|
+
"userId"?: string | number;
|
|
852
790
|
}): Promise<any>;
|
|
853
791
|
/** `documents.aliases.set` — PUT /document-aliases/{scope}/{aliasKey}. Bind a (scope, aliasKey) alias to a document */
|
|
854
792
|
"set"(args: {
|
|
@@ -1101,6 +1039,7 @@ export interface FunctionApi {
|
|
|
1101
1039
|
"model": string | number;
|
|
1102
1040
|
"recordId": string | number;
|
|
1103
1041
|
"documentFormat"?: string | number | boolean;
|
|
1042
|
+
"requestId"?: string | number | boolean;
|
|
1104
1043
|
}): Promise<any>;
|
|
1105
1044
|
/** `documents.records.patch` — PATCH /documents/{documentId}/records/{model}/{recordId}. Merge fields into an existing record in a document model */
|
|
1106
1045
|
"patch"(args: {
|
|
@@ -1158,6 +1097,13 @@ export interface FunctionApi {
|
|
|
1158
1097
|
"groupType": string | number;
|
|
1159
1098
|
"groupId": string | number;
|
|
1160
1099
|
}): Promise<any>;
|
|
1100
|
+
/** `documents.room` — GET /documents/{documentId}/room. Inspect a record-log document's room */
|
|
1101
|
+
"room"(args: {
|
|
1102
|
+
"documentId": string | number;
|
|
1103
|
+
"refused"?: string | number | boolean;
|
|
1104
|
+
"limit"?: string | number | boolean;
|
|
1105
|
+
"cursor"?: string | number | boolean;
|
|
1106
|
+
}): Promise<any>;
|
|
1161
1107
|
/** `documents.setLinkAccess` — PUT /documents/{documentId}/link-access. Set the document's "anyone with the link" access level */
|
|
1162
1108
|
"setLinkAccess"(args: {
|
|
1163
1109
|
"documentId": string | number;
|
|
@@ -1317,10 +1263,6 @@ export interface FunctionApi {
|
|
|
1317
1263
|
}): Promise<any>;
|
|
1318
1264
|
/** `integrations.list` — GET /integrations. List integrations configured for the app */
|
|
1319
1265
|
"list"(args?: Record<string, never>): Promise<any>;
|
|
1320
|
-
/** `integrations.proxy` — POST /integrations/{integrationKey}/proxy. Proxy a request through a configured integration */
|
|
1321
|
-
"proxy"(args: {
|
|
1322
|
-
"integrationKey": string | number;
|
|
1323
|
-
}): Promise<any>;
|
|
1324
1266
|
};
|
|
1325
1267
|
"locks": {
|
|
1326
1268
|
/** `locks.list` — GET /locks. List all currently-held named locks in the app */
|
|
@@ -1345,19 +1287,26 @@ export interface FunctionApi {
|
|
|
1345
1287
|
"notifications": {
|
|
1346
1288
|
/** `notifications.list` — GET /notifications. List the caller's in-app notification inbox (newest first) */
|
|
1347
1289
|
"list"(args?: {
|
|
1290
|
+
"userId"?: string | number;
|
|
1348
1291
|
"limit"?: string | number | boolean;
|
|
1349
1292
|
"cursor"?: string | number | boolean;
|
|
1350
1293
|
}): Promise<any>;
|
|
1351
1294
|
/** `notifications.listDevices` — GET /me/push-tokens. List the caller's registered push devices */
|
|
1352
|
-
"listDevices"(args?:
|
|
1295
|
+
"listDevices"(args?: {
|
|
1296
|
+
"userId"?: string | number;
|
|
1297
|
+
}): Promise<any>;
|
|
1353
1298
|
/** `notifications.markAllRead` — POST /notifications/read-all. Mark all of the caller's notifications as read */
|
|
1354
|
-
"markAllRead"(args?:
|
|
1299
|
+
"markAllRead"(args?: {
|
|
1300
|
+
"userId"?: string | number;
|
|
1301
|
+
}): Promise<any>;
|
|
1355
1302
|
/** `notifications.markRead` — PATCH /notifications/{notificationId}/read. Mark one of the caller's notifications as read */
|
|
1356
1303
|
"markRead"(args: {
|
|
1357
1304
|
"notificationId": string | number;
|
|
1305
|
+
"userId"?: string | number;
|
|
1358
1306
|
}): Promise<any>;
|
|
1359
1307
|
/** `notifications.registerDevice` — POST /me/push-tokens. Register (upsert) the caller's device push token */
|
|
1360
1308
|
"registerDevice"(args: {
|
|
1309
|
+
"userId"?: string | number;
|
|
1361
1310
|
body: unknown;
|
|
1362
1311
|
}): Promise<any>;
|
|
1363
1312
|
/** `notifications.send` — POST /notifications/send. Send a notification to an app user (durable in-app inbox row + live WS frame) */
|
|
@@ -1365,17 +1314,16 @@ export interface FunctionApi {
|
|
|
1365
1314
|
body: unknown;
|
|
1366
1315
|
}): Promise<any>;
|
|
1367
1316
|
/** `notifications.unreadCount` — GET /notifications/unread-count. Count the caller's unread notifications */
|
|
1368
|
-
"unreadCount"(args?:
|
|
1317
|
+
"unreadCount"(args?: {
|
|
1318
|
+
"userId"?: string | number;
|
|
1319
|
+
}): Promise<any>;
|
|
1369
1320
|
/** `notifications.unregisterDevice` — DELETE /me/push-tokens/{token}. Unregister one of the caller's device push tokens */
|
|
1370
1321
|
"unregisterDevice"(args: {
|
|
1371
1322
|
"token": string | number;
|
|
1323
|
+
"userId"?: string | number;
|
|
1372
1324
|
}): Promise<any>;
|
|
1373
1325
|
};
|
|
1374
1326
|
"prompts": {
|
|
1375
|
-
/** `prompts.execute` — POST /prompts/{promptKey}/execute. Execute a saved prompt */
|
|
1376
|
-
"execute"(args: {
|
|
1377
|
-
"promptKey": string | number;
|
|
1378
|
-
}): Promise<any>;
|
|
1379
1327
|
/** `prompts.run` — POST /prompts/{promptKey}/run. Run a prompt under a server function's grants */
|
|
1380
1328
|
"run"(args: {
|
|
1381
1329
|
"promptKey": string | number;
|
|
@@ -1439,7 +1387,7 @@ export interface FunctionApi {
|
|
|
1439
1387
|
/** `users.list` — GET /users. List app users */
|
|
1440
1388
|
"list"(args?: {
|
|
1441
1389
|
"email"?: string | number | boolean;
|
|
1442
|
-
"userId"?: string | number
|
|
1390
|
+
"userId"?: string | number;
|
|
1443
1391
|
"name"?: string | number | boolean;
|
|
1444
1392
|
"limit"?: string | number | boolean;
|
|
1445
1393
|
"cursor"?: string | number | boolean;
|
|
@@ -1665,8 +1613,6 @@ export interface DatabaseHandle<TModels> {
|
|
|
1665
1613
|
operations: Array<Record<string, unknown>>;
|
|
1666
1614
|
atomic?: boolean;
|
|
1667
1615
|
}): Promise<any>;
|
|
1668
|
-
/** Run one of the database type's prepared operations under this function's grants. */
|
|
1669
|
-
runOperation(name: string, params?: Record<string, unknown>): Promise<any>;
|
|
1670
1616
|
}
|
|
1671
1617
|
|
|
1672
1618
|
/**
|
|
@@ -1704,7 +1650,7 @@ export interface DocumentQueryOptions {
|
|
|
1704
1650
|
* Usually stated once on the handle, as ctx.doc(id, { documentFormat: 2 }),
|
|
1705
1651
|
* rather than per read.
|
|
1706
1652
|
*/
|
|
1707
|
-
documentFormat?: 1 | 2;
|
|
1653
|
+
documentFormat?: 1 | 2 | 3;
|
|
1708
1654
|
}
|
|
1709
1655
|
|
|
1710
1656
|
/**
|
|
@@ -1884,6 +1830,12 @@ export interface AgentSessionCreateOptions<K extends SessionAgentKeys> {
|
|
|
1884
1830
|
* Existing users of this app, not the caller, in neither list twice.
|
|
1885
1831
|
*/
|
|
1886
1832
|
viewers?: string[];
|
|
1833
|
+
/**
|
|
1834
|
+
* The member who owns the session; omitted, the invoking user. A run with
|
|
1835
|
+
* no caller must name one; naming another member follows the header's
|
|
1836
|
+
* subject rule. Initial members may not name the owner.
|
|
1837
|
+
*/
|
|
1838
|
+
userId?: string;
|
|
1887
1839
|
}
|
|
1888
1840
|
|
|
1889
1841
|
/** What `ctx.agents.createSession` answers — #3803. */
|
|
@@ -1907,9 +1859,16 @@ export interface AgentSessionInfo {
|
|
|
1907
1859
|
scope: string | null;
|
|
1908
1860
|
/** ISO-8601; null when the session's listing row is missing. */
|
|
1909
1861
|
lastActivityAt: string | null;
|
|
1862
|
+
/**
|
|
1863
|
+
* Whether the invoking user has activity in the session they have not
|
|
1864
|
+
* marked read (their client marks it); false for an admin with no role.
|
|
1865
|
+
*/
|
|
1866
|
+
hasUnread: boolean;
|
|
1867
|
+
/** When the invoking user last marked the session read (ISO-8601), or null. */
|
|
1868
|
+
lastReadAt: string | null;
|
|
1910
1869
|
/** The members, in the order they were added. */
|
|
1911
1870
|
members: { viewers: string[]; participants: string[] };
|
|
1912
|
-
/** The
|
|
1871
|
+
/** The standing on the session of the member the call acted as. */
|
|
1913
1872
|
role: "owner" | "participant" | "viewer" | "admin";
|
|
1914
1873
|
/**
|
|
1915
1874
|
* The session's status, decided from the session object (never the
|
|
@@ -1963,10 +1922,20 @@ export interface AgentSessionListItem {
|
|
|
1963
1922
|
/** ISO-8601. */
|
|
1964
1923
|
lastActivityAt: string;
|
|
1965
1924
|
createdAt: string | null;
|
|
1925
|
+
/** Whether the user has activity in the session they have not marked read. */
|
|
1926
|
+
hasUnread: boolean;
|
|
1927
|
+
/** When the user last marked the session read (ISO-8601), or null. */
|
|
1928
|
+
lastReadAt: string | null;
|
|
1966
1929
|
}
|
|
1967
1930
|
|
|
1968
|
-
/** What `ctx.agents.listSessions` takes — #3805.
|
|
1931
|
+
/** What `ctx.agents.listSessions` takes — #3805. */
|
|
1969
1932
|
export interface AgentSessionListOptions {
|
|
1933
|
+
/**
|
|
1934
|
+
* Whose sessions; omitted, the invoking user's. A run with no caller must
|
|
1935
|
+
* name one, and naming another follows the header's subject rule. A user
|
|
1936
|
+
* with no sessions here, member or not, answers an empty page.
|
|
1937
|
+
*/
|
|
1938
|
+
userId?: string;
|
|
1970
1939
|
/** Only this agent's sessions. */
|
|
1971
1940
|
agent?: string;
|
|
1972
1941
|
/** Only sessions created with exactly this scope. */
|
|
@@ -1977,6 +1946,15 @@ export interface AgentSessionListOptions {
|
|
|
1977
1946
|
cursor?: string;
|
|
1978
1947
|
}
|
|
1979
1948
|
|
|
1949
|
+
/**
|
|
1950
|
+
* Which member `ctx.agents.getSession` and `recordEvent` act as. Omitted,
|
|
1951
|
+
* the invoking user; a run with no caller must name one, and naming another
|
|
1952
|
+
* follows the header's subject rule.
|
|
1953
|
+
*/
|
|
1954
|
+
export interface AgentSessionSubjectOptions {
|
|
1955
|
+
userId?: string;
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1980
1958
|
/** A page of `ctx.agents.listSessions` — #3805. */
|
|
1981
1959
|
export interface AgentSessionListPage {
|
|
1982
1960
|
items: AgentSessionListItem[];
|
|
@@ -2354,7 +2332,7 @@ export interface FunctionContext {
|
|
|
2354
2332
|
* confers nothing: every call is a `documents.records.*` operation on the
|
|
2355
2333
|
* same authority.
|
|
2356
2334
|
*/
|
|
2357
|
-
doc(documentId: string, options?: { documentFormat?: 1 | 2 }): DocumentHandle;
|
|
2335
|
+
doc(documentId: string, options?: { documentFormat?: 1 | 2 | 3 }): DocumentHandle;
|
|
2358
2336
|
/**
|
|
2359
2337
|
* Outbound HTTP, through a granted integration and nowhere else (#3183).
|
|
2360
2338
|
*
|
|
@@ -2421,30 +2399,27 @@ export interface FunctionContext {
|
|
|
2421
2399
|
): Promise<PromptRunResult<K>>;
|
|
2422
2400
|
};
|
|
2423
2401
|
/**
|
|
2424
|
-
* Agent sessions (#3803, project `agents`)
|
|
2425
|
-
*
|
|
2426
|
-
*
|
|
2427
|
-
* answers `{ sessionId, documentId }`. It is allowed only in a run fired
|
|
2428
|
-
* over HTTP (`invoke`, or a `start` task) by a signed-in user; from a
|
|
2429
|
-
* manual run, a nested start, a workflow step, cron or a webhook it
|
|
2430
|
-
* rejects with `AGENT_SESSION_ORIGIN_REFUSED`, `details.origin` naming
|
|
2431
|
-
* it. Variables failing the agent's `inputSchema` reject with
|
|
2432
|
-
* `AGENT_SESSION_VARIABLES_INVALID` and `details.errors`.
|
|
2402
|
+
* Agent sessions (#3803, project `agents`), on the header's subject rule:
|
|
2403
|
+
* each call acts for `userId`, else the invoking user, and from any kind of
|
|
2404
|
+
* run — a run with no caller must name the member.
|
|
2433
2405
|
*
|
|
2434
|
-
*
|
|
2435
|
-
*
|
|
2436
|
-
* `
|
|
2406
|
+
* `createSession` creates a session that member owns and answers
|
|
2407
|
+
* `{ sessionId, documentId }`. Variables failing the agent's
|
|
2408
|
+
* `inputSchema` reject with `AGENT_SESSION_VARIABLES_INVALID` and
|
|
2409
|
+
* `details.errors`. Once a tree has pushed, a key that is not an agent,
|
|
2410
|
+
* and variables the agent's schema refuses, are compile errors.
|
|
2411
|
+
* `participants` and `viewers` name initial members (#3805).
|
|
2437
2412
|
*
|
|
2438
|
-
* `getSession` and `listSessions` (#3805) read the
|
|
2439
|
-
*
|
|
2440
|
-
* whoever invoked the function
|
|
2441
|
-
* `AGENT_SESSION_NOT_FOUND
|
|
2442
|
-
* `
|
|
2443
|
-
* owner's, from a client.
|
|
2413
|
+
* `getSession` and `listSessions` (#3805) read the member's sessions —
|
|
2414
|
+
* the ones they own or are a member of — as that member, with no admin arm
|
|
2415
|
+
* whoever invoked the function: a session they are not in answers
|
|
2416
|
+
* `AGENT_SESSION_NOT_FOUND`, and function code never sees a session's
|
|
2417
|
+
* `object`, `turnContexts` or `lastTurn`. Renaming, deleting and
|
|
2418
|
+
* changing members are the owner's, from a client.
|
|
2444
2419
|
*
|
|
2445
|
-
* `recordEvent` (#3807) records an event
|
|
2446
|
-
*
|
|
2447
|
-
* the
|
|
2420
|
+
* `recordEvent` (#3807) records an event as the member, who must be the
|
|
2421
|
+
* session's owner or a participant (`AGENT_SESSION_PARTICIPANT_ONLY` for a
|
|
2422
|
+
* viewer); the row is authored `app`. The kind must be one the agent
|
|
2448
2423
|
* declares (`AGENT_EVENT_KIND_UNKNOWN`) and the data must match its schema
|
|
2449
2424
|
* (`AGENT_EVENT_INVALID`). An event never starts a turn; the model reads
|
|
2450
2425
|
* it in a later turn.
|
|
@@ -2453,9 +2428,16 @@ export interface FunctionContext {
|
|
|
2453
2428
|
createSession<K extends SessionAgentKeys>(
|
|
2454
2429
|
options: AgentSessionCreateOptions<K>
|
|
2455
2430
|
): Promise<AgentSessionCreateResult>;
|
|
2456
|
-
getSession(
|
|
2431
|
+
getSession(
|
|
2432
|
+
sessionId: string,
|
|
2433
|
+
options?: AgentSessionSubjectOptions
|
|
2434
|
+
): Promise<AgentSessionInfo>;
|
|
2457
2435
|
listSessions(options?: AgentSessionListOptions): Promise<AgentSessionListPage>;
|
|
2458
|
-
recordEvent(
|
|
2436
|
+
recordEvent(
|
|
2437
|
+
sessionId: string,
|
|
2438
|
+
event: AgentSessionEvent,
|
|
2439
|
+
options?: AgentSessionSubjectOptions
|
|
2440
|
+
): Promise<AgentSessionEventResult>;
|
|
2459
2441
|
};
|
|
2460
2442
|
/**
|
|
2461
2443
|
* The value of one app secret, under a `secret:<NAME>` grant (#3183).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "primitive-functions",
|
|
3
|
-
"version": "0.3.0-alpha.
|
|
3
|
+
"version": "0.3.0-alpha.5",
|
|
4
4
|
"description": "The module a Primitive server function imports. Supplied by the platform at invoke time; reserved here so the name is ours before the runtime lands.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Primitive LLC",
|