primitive-functions 0.2.0-alpha.10 → 0.2.0-alpha.12
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 +196 -30
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -510,32 +510,50 @@ export interface FunctionApi {
|
|
|
510
510
|
body: unknown;
|
|
511
511
|
}): Promise<any>;
|
|
512
512
|
"adminData": {
|
|
513
|
-
/**
|
|
513
|
+
/**
|
|
514
|
+
* `databases.adminData.batch` — POST /databases/{databaseId}/admin-data/batch. DEPRECATED — direct database batch; use databases/{databaseId}/records/batch
|
|
515
|
+
* @deprecated Use databases/{databaseId}/records/batch
|
|
516
|
+
*/
|
|
514
517
|
"batch"(args: {
|
|
515
518
|
"databaseId": string | number;
|
|
516
519
|
body: unknown;
|
|
517
520
|
}): Promise<any>;
|
|
518
|
-
/**
|
|
521
|
+
/**
|
|
522
|
+
* `databases.adminData.count` — POST /databases/{databaseId}/admin-data/count. DEPRECATED — direct database count; use databases/{databaseId}/records/count
|
|
523
|
+
* @deprecated Use databases/{databaseId}/records/count
|
|
524
|
+
*/
|
|
519
525
|
"count"(args: {
|
|
520
526
|
"databaseId": string | number;
|
|
521
527
|
body: unknown;
|
|
522
528
|
}): Promise<any>;
|
|
523
|
-
/**
|
|
529
|
+
/**
|
|
530
|
+
* `databases.adminData.delete` — POST /databases/{databaseId}/admin-data/delete. DEPRECATED — direct database delete; use databases/{databaseId}/records/delete
|
|
531
|
+
* @deprecated Use databases/{databaseId}/records/delete
|
|
532
|
+
*/
|
|
524
533
|
"delete"(args: {
|
|
525
534
|
"databaseId": string | number;
|
|
526
535
|
body: unknown;
|
|
527
536
|
}): Promise<any>;
|
|
528
|
-
/**
|
|
537
|
+
/**
|
|
538
|
+
* `databases.adminData.patch` — POST /databases/{databaseId}/admin-data/patch. DEPRECATED — direct database patch; use databases/{databaseId}/records/patch
|
|
539
|
+
* @deprecated Use databases/{databaseId}/records/patch
|
|
540
|
+
*/
|
|
529
541
|
"patch"(args: {
|
|
530
542
|
"databaseId": string | number;
|
|
531
543
|
body: unknown;
|
|
532
544
|
}): Promise<any>;
|
|
533
|
-
/**
|
|
545
|
+
/**
|
|
546
|
+
* `databases.adminData.query` — POST /databases/{databaseId}/admin-data/query. DEPRECATED — direct database query; use databases/{databaseId}/records/query
|
|
547
|
+
* @deprecated Use databases/{databaseId}/records/query
|
|
548
|
+
*/
|
|
534
549
|
"query"(args: {
|
|
535
550
|
"databaseId": string | number;
|
|
536
551
|
body: unknown;
|
|
537
552
|
}): Promise<any>;
|
|
538
|
-
/**
|
|
553
|
+
/**
|
|
554
|
+
* `databases.adminData.save` — POST /databases/{databaseId}/admin-data/save. DEPRECATED — direct database save; use databases/{databaseId}/records/save
|
|
555
|
+
* @deprecated Use databases/{databaseId}/records/save
|
|
556
|
+
*/
|
|
539
557
|
"save"(args: {
|
|
540
558
|
"databaseId": string | number;
|
|
541
559
|
body: unknown;
|
|
@@ -566,7 +584,10 @@ export interface FunctionApi {
|
|
|
566
584
|
"get"(args: {
|
|
567
585
|
"databaseId": string | number;
|
|
568
586
|
}): Promise<any>;
|
|
569
|
-
/**
|
|
587
|
+
/**
|
|
588
|
+
* `databases.getMetadata` — GET /databases/{databaseId}/metadata. DEPRECATED — get database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)
|
|
589
|
+
* @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)
|
|
590
|
+
*/
|
|
570
591
|
"getMetadata"(args: {
|
|
571
592
|
"databaseId": string | number;
|
|
572
593
|
}): Promise<any>;
|
|
@@ -723,7 +744,10 @@ export interface FunctionApi {
|
|
|
723
744
|
"databaseId": string | number;
|
|
724
745
|
body: unknown;
|
|
725
746
|
}): Promise<any>;
|
|
726
|
-
/**
|
|
747
|
+
/**
|
|
748
|
+
* `databases.updateMetadata` — PATCH /databases/{databaseId}/metadata. DEPRECATED — update database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)
|
|
749
|
+
* @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)
|
|
750
|
+
*/
|
|
727
751
|
"updateMetadata"(args: {
|
|
728
752
|
"databaseId": string | number;
|
|
729
753
|
body: unknown;
|
|
@@ -804,7 +828,10 @@ export interface FunctionApi {
|
|
|
804
828
|
"X-Blob-Sha256": string | number;
|
|
805
829
|
body: ArrayBuffer | Uint8Array | string;
|
|
806
830
|
}): Promise<any>;
|
|
807
|
-
/**
|
|
831
|
+
/**
|
|
832
|
+
* `documents.blobs.uploadWithoutId` — PUT /documents/{documentId}/blobs. Deprecated: upload a document blob without a client-specified id
|
|
833
|
+
* @deprecated Deprecated in the app API spec; see its description.
|
|
834
|
+
*/
|
|
808
835
|
"uploadWithoutId"(args: {
|
|
809
836
|
"documentId": string | number;
|
|
810
837
|
}): Promise<any>;
|
|
@@ -973,17 +1000,20 @@ export interface FunctionApi {
|
|
|
973
1000
|
"aggregate"(args: {
|
|
974
1001
|
"documentId": string | number;
|
|
975
1002
|
"model": string | number;
|
|
1003
|
+
"documentFormat"?: string | number | boolean;
|
|
976
1004
|
body: unknown;
|
|
977
1005
|
}): Promise<any>;
|
|
978
1006
|
/** `documents.records.bulk` — POST /documents/{documentId}/records/bulk. Apply an atomic multi-model record blob to a document (create/patch/delete) */
|
|
979
1007
|
"bulk"(args: {
|
|
980
1008
|
"documentId": string | number;
|
|
1009
|
+
"documentFormat"?: string | number | boolean;
|
|
981
1010
|
body: unknown;
|
|
982
1011
|
}): Promise<any>;
|
|
983
1012
|
/** `documents.records.count` — GET /documents/{documentId}/records/{model}/count. Count records in a document model */
|
|
984
1013
|
"count"(args: {
|
|
985
1014
|
"documentId": string | number;
|
|
986
1015
|
"model": string | number;
|
|
1016
|
+
"documentFormat"?: string | number | boolean;
|
|
987
1017
|
"filter"?: Record<string, unknown> | string;
|
|
988
1018
|
}): Promise<any>;
|
|
989
1019
|
/** `documents.records.delete` — DELETE /documents/{documentId}/records/{model}/{recordId}. Delete a record from a document model */
|
|
@@ -991,18 +1021,21 @@ export interface FunctionApi {
|
|
|
991
1021
|
"documentId": string | number;
|
|
992
1022
|
"model": string | number;
|
|
993
1023
|
"recordId": string | number;
|
|
1024
|
+
"documentFormat"?: string | number | boolean;
|
|
994
1025
|
}): Promise<any>;
|
|
995
1026
|
/** `documents.records.patch` — PATCH /documents/{documentId}/records/{model}/{recordId}. Merge fields into an existing record in a document model */
|
|
996
1027
|
"patch"(args: {
|
|
997
1028
|
"documentId": string | number;
|
|
998
1029
|
"model": string | number;
|
|
999
1030
|
"recordId": string | number;
|
|
1031
|
+
"documentFormat"?: string | number | boolean;
|
|
1000
1032
|
body: unknown;
|
|
1001
1033
|
}): Promise<any>;
|
|
1002
1034
|
/** `documents.records.query` — GET /documents/{documentId}/records/{model}. Query records in a document model */
|
|
1003
1035
|
"query"(args: {
|
|
1004
1036
|
"documentId": string | number;
|
|
1005
1037
|
"model": string | number;
|
|
1038
|
+
"documentFormat"?: string | number | boolean;
|
|
1006
1039
|
"limit"?: string | number | boolean;
|
|
1007
1040
|
"cursor"?: string | number | boolean;
|
|
1008
1041
|
"filter"?: Record<string, unknown> | string;
|
|
@@ -1011,6 +1044,7 @@ export interface FunctionApi {
|
|
|
1011
1044
|
"save"(args: {
|
|
1012
1045
|
"documentId": string | number;
|
|
1013
1046
|
"model": string | number;
|
|
1047
|
+
"documentFormat"?: string | number | boolean;
|
|
1014
1048
|
body: unknown;
|
|
1015
1049
|
}): Promise<any>;
|
|
1016
1050
|
};
|
|
@@ -1071,9 +1105,10 @@ export interface FunctionApi {
|
|
|
1071
1105
|
"sessionId": string | number;
|
|
1072
1106
|
body: FormData | ArrayBuffer | Uint8Array | string;
|
|
1073
1107
|
}): Promise<any>;
|
|
1074
|
-
/** `documents.validateAccess` — POST /documents/{documentId}/validate-access. Resolve
|
|
1108
|
+
/** `documents.validateAccess` — POST /documents/{documentId}/validate-access. Resolve effective access to a document, for the caller or a named user */
|
|
1075
1109
|
"validateAccess"(args: {
|
|
1076
1110
|
"documentId": string | number;
|
|
1111
|
+
body?: unknown;
|
|
1077
1112
|
}): Promise<any>;
|
|
1078
1113
|
};
|
|
1079
1114
|
"email": {
|
|
@@ -1107,20 +1142,32 @@ export interface FunctionApi {
|
|
|
1107
1142
|
}): Promise<any>;
|
|
1108
1143
|
};
|
|
1109
1144
|
"gemini": {
|
|
1110
|
-
/**
|
|
1145
|
+
/**
|
|
1146
|
+
* `gemini.countTokens` — POST /gemini/count-tokens. Count tokens for a Gemini request
|
|
1147
|
+
* @deprecated These direct proxy routes will be removed in the next major release of the platform server. Run a managed prompt from a server function instead: `ctx.prompts.run` (see the Server Functions guide).
|
|
1148
|
+
*/
|
|
1111
1149
|
"countTokens"(args: {
|
|
1112
1150
|
body: unknown;
|
|
1113
1151
|
}): Promise<any>;
|
|
1114
|
-
/**
|
|
1152
|
+
/**
|
|
1153
|
+
* `gemini.generate` — POST /gemini/generate. Generate content with Gemini
|
|
1154
|
+
* @deprecated These direct proxy routes will be removed in the next major release of the platform server. Run a managed prompt from a server function instead: `ctx.prompts.run` (see the Server Functions guide).
|
|
1155
|
+
*/
|
|
1115
1156
|
"generate"(args: {
|
|
1116
1157
|
body: unknown;
|
|
1117
1158
|
}): Promise<any>;
|
|
1118
|
-
/**
|
|
1159
|
+
/**
|
|
1160
|
+
* `gemini.generateRaw` — POST /gemini/generate-raw. Generate content with Gemini (raw passthrough)
|
|
1161
|
+
* @deprecated These direct proxy routes will be removed in the next major release of the platform server. Run a managed prompt from a server function instead: `ctx.prompts.run` (see the Server Functions guide).
|
|
1162
|
+
*/
|
|
1119
1163
|
"generateRaw"(args: {
|
|
1120
1164
|
"model"?: string | number | boolean;
|
|
1121
1165
|
body: unknown;
|
|
1122
1166
|
}): Promise<any>;
|
|
1123
|
-
/**
|
|
1167
|
+
/**
|
|
1168
|
+
* `gemini.models` — GET /gemini/models. List available Gemini models
|
|
1169
|
+
* @deprecated These direct proxy routes will be removed in the next major release of the platform server. Run a managed prompt from a server function instead: `ctx.prompts.run` (see the Server Functions guide).
|
|
1170
|
+
*/
|
|
1124
1171
|
"models"(args?: Record<string, never>): Promise<any>;
|
|
1125
1172
|
};
|
|
1126
1173
|
"groups": {
|
|
@@ -1213,11 +1260,17 @@ export interface FunctionApi {
|
|
|
1213
1260
|
}): Promise<any>;
|
|
1214
1261
|
};
|
|
1215
1262
|
"llm": {
|
|
1216
|
-
/**
|
|
1263
|
+
/**
|
|
1264
|
+
* `llm.chat` — POST /llm/chat. Run an LLM chat completion
|
|
1265
|
+
* @deprecated These direct proxy routes will be removed in the next major release of the platform server. Run a managed prompt from a server function instead: `ctx.prompts.run` (see the Server Functions guide).
|
|
1266
|
+
*/
|
|
1217
1267
|
"chat"(args: {
|
|
1218
1268
|
body: unknown;
|
|
1219
1269
|
}): Promise<any>;
|
|
1220
|
-
/**
|
|
1270
|
+
/**
|
|
1271
|
+
* `llm.models` — GET /llm/models. List available LLM models
|
|
1272
|
+
* @deprecated These direct proxy routes will be removed in the next major release of the platform server. Run a managed prompt from a server function instead: `ctx.prompts.run` (see the Server Functions guide).
|
|
1273
|
+
*/
|
|
1221
1274
|
"models"(args?: Record<string, never>): Promise<any>;
|
|
1222
1275
|
};
|
|
1223
1276
|
"locks": {
|
|
@@ -1342,7 +1395,10 @@ export interface FunctionApi {
|
|
|
1342
1395
|
"lookup"(args?: {
|
|
1343
1396
|
"email"?: string | number | boolean;
|
|
1344
1397
|
}): Promise<any>;
|
|
1345
|
-
/**
|
|
1398
|
+
/**
|
|
1399
|
+
* `users.remove` — DELETE /users/{userId}. DEPRECATED — remove a user from the app; use the admin API's PUT apps/:appId/users/:userId/disable (`primitive users disable`)
|
|
1400
|
+
* @deprecated Use the admin API's PUT apps/:appId/users/:userId/disable (`primitive users disable`)
|
|
1401
|
+
*/
|
|
1346
1402
|
"remove"(args: {
|
|
1347
1403
|
"userId": string | number;
|
|
1348
1404
|
}): Promise<any>;
|
|
@@ -1583,6 +1639,14 @@ export interface DocumentQueryOptions {
|
|
|
1583
1639
|
filter?: Record<string, unknown> | string;
|
|
1584
1640
|
limit?: number;
|
|
1585
1641
|
cursor?: string;
|
|
1642
|
+
/**
|
|
1643
|
+
* The document format you expect (#3764). When it disagrees with the format
|
|
1644
|
+
* the platform resolved, the call is refused with a 409
|
|
1645
|
+
* DOCUMENT_FORMAT_MISMATCH rather than answered out of the wrong tables.
|
|
1646
|
+
* Usually stated once on the handle, as ctx.doc(id, { documentFormat: 2 }),
|
|
1647
|
+
* rather than per read.
|
|
1648
|
+
*/
|
|
1649
|
+
documentFormat?: 1 | 2;
|
|
1586
1650
|
}
|
|
1587
1651
|
|
|
1588
1652
|
/**
|
|
@@ -1667,6 +1731,13 @@ export interface IntegrationCallResult {
|
|
|
1667
1731
|
|
|
1668
1732
|
/** What a prompt run is given — the member execute route's own body. */
|
|
1669
1733
|
export interface PromptRunArgs {
|
|
1734
|
+
/**
|
|
1735
|
+
* The prompt's variables. A `kind = "decisions"` prompt takes
|
|
1736
|
+
* `{ state, criteria? }`: `state` is the value its questions are asked
|
|
1737
|
+
* about, and `criteria.<question>` supplies this run's options for each
|
|
1738
|
+
* choice question declared `criteriaSource = "dynamic"` — a table of option
|
|
1739
|
+
* key = description (a string or a JSON object), at least two entries (#3813).
|
|
1740
|
+
*/
|
|
1670
1741
|
variables?: Record<string, unknown>;
|
|
1671
1742
|
/** Run against a different model for this call only. */
|
|
1672
1743
|
modelOverride?: string;
|
|
@@ -1684,10 +1755,45 @@ export interface PromptRunArgs {
|
|
|
1684
1755
|
*/
|
|
1685
1756
|
export interface PromptSchemas {}
|
|
1686
1757
|
|
|
1687
|
-
/**
|
|
1758
|
+
/**
|
|
1759
|
+
* The keys whose declaration is an AGENT (`kind = "agent"`, #3798): entries
|
|
1760
|
+
* carrying `{ agent: … }` instead of an output. An agent runs turn by turn in
|
|
1761
|
+
* a session and never single-shot, so these are the keys `PromptKeys` leaves
|
|
1762
|
+
* out.
|
|
1763
|
+
*/
|
|
1764
|
+
export type AgentKeys = {
|
|
1765
|
+
[K in keyof PromptSchemas]: PromptSchemas[K] extends { agent: unknown } ? K : never;
|
|
1766
|
+
}[keyof PromptSchemas] &
|
|
1767
|
+
string;
|
|
1768
|
+
|
|
1769
|
+
/**
|
|
1770
|
+
* The keys `ctx.prompts.run` accepts — every declared one that is not an
|
|
1771
|
+
* agent, or `string` before a push.
|
|
1772
|
+
*/
|
|
1688
1773
|
export type PromptKeys = [keyof PromptSchemas] extends [never]
|
|
1689
1774
|
? string
|
|
1690
|
-
: keyof PromptSchemas & string
|
|
1775
|
+
: Exclude<keyof PromptSchemas & string, AgentKeys>;
|
|
1776
|
+
|
|
1777
|
+
/** One agent's session variables, typed from its `inputSchema` (#3798). */
|
|
1778
|
+
export type AgentVariables<K extends AgentKeys> = PromptSchemas[K] extends {
|
|
1779
|
+
agent: { variables: infer V };
|
|
1780
|
+
}
|
|
1781
|
+
? V
|
|
1782
|
+
: never;
|
|
1783
|
+
|
|
1784
|
+
/** One agent's client tools, by name: each one's `input` and `output` (#3798). */
|
|
1785
|
+
export type AgentClientTools<K extends AgentKeys> = PromptSchemas[K] extends {
|
|
1786
|
+
agent: { clientTools: infer T };
|
|
1787
|
+
}
|
|
1788
|
+
? T
|
|
1789
|
+
: never;
|
|
1790
|
+
|
|
1791
|
+
/** One agent's event kinds, by name: each one's payload (#3798). */
|
|
1792
|
+
export type AgentEvents<K extends AgentKeys> = PromptSchemas[K] extends {
|
|
1793
|
+
agent: { events: infer E };
|
|
1794
|
+
}
|
|
1795
|
+
? E
|
|
1796
|
+
: never;
|
|
1691
1797
|
|
|
1692
1798
|
/** One prompt's declared output type, or `unknown` where none is declared. */
|
|
1693
1799
|
export type PromptOutput<K extends string> = K extends keyof PromptSchemas
|
|
@@ -1705,6 +1811,29 @@ export type PromptOutputErrorCode =
|
|
|
1705
1811
|
| "PROMPT_OUTPUT_NOT_JSON"
|
|
1706
1812
|
| "PROMPT_OUTPUT_SCHEMA_VIOLATION";
|
|
1707
1813
|
|
|
1814
|
+
/**
|
|
1815
|
+
* Every code the envelope's `errorCode` can carry — #3663, #3813.
|
|
1816
|
+
*
|
|
1817
|
+
* `PROMPT_UPSTREAM_TIMEOUT` is the one that is NOT about the prompt's own
|
|
1818
|
+
* answer: the provider ran out of time, so there was no answer to refuse. It
|
|
1819
|
+
* is the only provider failure that sets `errorCode` at all, which is what
|
|
1820
|
+
* leaves "the model returned the wrong shape" distinguishable from "the model
|
|
1821
|
+
* failed" while still letting a caller retry the one failure worth retrying.
|
|
1822
|
+
*
|
|
1823
|
+
* `PROMPT_CRITERIA_INVALID` is the run that never reached a provider: a
|
|
1824
|
+
* decisions run's `variables.criteria` was refused before the call, so
|
|
1825
|
+
* nothing was billed (#3813).
|
|
1826
|
+
*
|
|
1827
|
+
* `PROMPT_STRICT_OUTPUT_SCHEMA_MISSING` never reached one either: the config
|
|
1828
|
+
* sets `strictOutput = true` and the prompt has no usable `outputSchema` to
|
|
1829
|
+
* send as the strict `json_schema` (#3801).
|
|
1830
|
+
*/
|
|
1831
|
+
export type PromptRunErrorCode =
|
|
1832
|
+
| PromptOutputErrorCode
|
|
1833
|
+
| "PROMPT_UPSTREAM_TIMEOUT"
|
|
1834
|
+
| "PROMPT_CRITERIA_INVALID"
|
|
1835
|
+
| "PROMPT_STRICT_OUTPUT_SCHEMA_MISSING";
|
|
1836
|
+
|
|
1708
1837
|
/** A prompt that declares an output shape, when the answer matched it. */
|
|
1709
1838
|
export interface PromptRunSuccess<TParsed> {
|
|
1710
1839
|
success: true;
|
|
@@ -1718,19 +1847,31 @@ export interface PromptRunSuccess<TParsed> {
|
|
|
1718
1847
|
}
|
|
1719
1848
|
|
|
1720
1849
|
/**
|
|
1721
|
-
* The failure arm, whichever failed. `errorCode` is set for a SHAPE failure
|
|
1722
|
-
*
|
|
1723
|
-
*
|
|
1724
|
-
*
|
|
1850
|
+
* The failure arm, whichever failed. `errorCode` is set for a SHAPE failure,
|
|
1851
|
+
* for a refused run (`PROMPT_CRITERIA_INVALID`, #3813), and for a provider
|
|
1852
|
+
* one only when the upstream TIMED OUT (#3663); `output` carries the text
|
|
1853
|
+
* either way, which is where the model's own value lives — a validation
|
|
1854
|
+
* `error` names paths and schema constraints only.
|
|
1725
1855
|
*/
|
|
1726
1856
|
export interface PromptRunFailure {
|
|
1727
1857
|
success: false;
|
|
1728
1858
|
output: string;
|
|
1729
1859
|
error: string | null;
|
|
1730
|
-
errorCode?:
|
|
1860
|
+
errorCode?: PromptRunErrorCode | null;
|
|
1731
1861
|
parsed?: undefined;
|
|
1732
1862
|
metrics?: Record<string, unknown>;
|
|
1733
1863
|
configId: string;
|
|
1864
|
+
/**
|
|
1865
|
+
* The upstream provider's HTTP status, when the call reached a provider and
|
|
1866
|
+
* it answered — #3663. This is what a retry decision is made on: a 504 or a
|
|
1867
|
+
* 503 is worth another attempt, a 400 on a refused payload is not.
|
|
1868
|
+
*
|
|
1869
|
+
* It does not depend on which provider the config named: Gemini and
|
|
1870
|
+
* OpenRouter report it identically. It is absent when no provider answer was
|
|
1871
|
+
* observed — an unset key, an oversized payload, a completion that came back
|
|
1872
|
+
* empty — so a number here is always the provider's own.
|
|
1873
|
+
*/
|
|
1874
|
+
upstreamStatus?: number;
|
|
1734
1875
|
}
|
|
1735
1876
|
|
|
1736
1877
|
/** The envelope for a key whose declaration says nothing about its output. */
|
|
@@ -1743,9 +1884,11 @@ export interface PromptRunOpenResult {
|
|
|
1743
1884
|
*/
|
|
1744
1885
|
parsed?: unknown;
|
|
1745
1886
|
error?: string | null;
|
|
1746
|
-
errorCode?:
|
|
1887
|
+
errorCode?: PromptRunErrorCode | null;
|
|
1747
1888
|
metrics?: Record<string, unknown>;
|
|
1748
1889
|
configId: string;
|
|
1890
|
+
/** The upstream provider's HTTP status on a provider failure — #3663. */
|
|
1891
|
+
upstreamStatus?: number;
|
|
1749
1892
|
}
|
|
1750
1893
|
|
|
1751
1894
|
/**
|
|
@@ -1907,7 +2050,7 @@ export interface FunctionContext {
|
|
|
1907
2050
|
* confers nothing: every call is a `documents.records.*` operation on the
|
|
1908
2051
|
* same authority.
|
|
1909
2052
|
*/
|
|
1910
|
-
doc(documentId: string): DocumentHandle;
|
|
2053
|
+
doc(documentId: string, options?: { documentFormat?: 1 | 2 }): DocumentHandle;
|
|
1911
2054
|
/**
|
|
1912
2055
|
* Outbound HTTP, through a granted integration and nowhere else (#3183).
|
|
1913
2056
|
*
|
|
@@ -2040,6 +2183,29 @@ export interface FunctionContext {
|
|
|
2040
2183
|
};
|
|
2041
2184
|
}
|
|
2042
2185
|
|
|
2186
|
+
/** How the wait between one step's retries grows. */
|
|
2187
|
+
export type StepBackoff = "constant" | "linear" | "exponential";
|
|
2188
|
+
|
|
2189
|
+
/**
|
|
2190
|
+
* The retry and timeout policy for ONE `step.do` — Cloudflare Workflows' own
|
|
2191
|
+
* step config.
|
|
2192
|
+
*
|
|
2193
|
+
* Under the TASK runner the platform forwards this object to Workflows
|
|
2194
|
+
* untouched, so these are its fields and its spellings: a duration is either a
|
|
2195
|
+
* number of milliseconds or a string Workflows parses (`"10 seconds"`,
|
|
2196
|
+
* `"5 minutes"`). Under the REQUEST runner `step.do` accepts a config and
|
|
2197
|
+
* ignores it — the body runs inline, and there is nothing to retry into.
|
|
2198
|
+
*
|
|
2199
|
+
* `stepPolicy.<family>` IS a `StepConfig`, so the platform's own defaults
|
|
2200
|
+
* hand straight to `step.do` (#3657). The shape is closed on purpose: a key
|
|
2201
|
+
* outside it — `retry` for `retries`, `timeoutMs` for `timeout` — is a
|
|
2202
|
+
* refusal at `config push` rather than an option the engine silently drops.
|
|
2203
|
+
*/
|
|
2204
|
+
export interface StepConfig {
|
|
2205
|
+
retries?: { limit: number; delay: string | number; backoff?: StepBackoff };
|
|
2206
|
+
timeout?: string | number;
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2043
2209
|
/**
|
|
2044
2210
|
* The step handle. `step` is the third argument under BOTH runners, so the
|
|
2045
2211
|
* same body runs either way — which is what `mode = "any"` is for (#3454).
|
|
@@ -2062,7 +2228,7 @@ export interface FunctionStep {
|
|
|
2062
2228
|
do<T>(name: string, body: () => T | Promise<T>): Promise<T>;
|
|
2063
2229
|
do<T>(
|
|
2064
2230
|
name: string,
|
|
2065
|
-
config:
|
|
2231
|
+
config: StepConfig,
|
|
2066
2232
|
body: () => T | Promise<T>
|
|
2067
2233
|
): Promise<T>;
|
|
2068
2234
|
sleep(name: string, duration: number | string): Promise<void>;
|
|
@@ -2326,9 +2492,9 @@ export declare const PMAP_DEFAULT_CONCURRENCY: number;
|
|
|
2326
2492
|
*/
|
|
2327
2493
|
export declare function ulid(): string;
|
|
2328
2494
|
|
|
2329
|
-
/** One family's durable `step.do` configuration. */
|
|
2330
|
-
export interface StepPolicy {
|
|
2331
|
-
retries: { limit: number; delay: string; backoff:
|
|
2495
|
+
/** One family's durable `step.do` configuration — a `StepConfig` with every field decided. */
|
|
2496
|
+
export interface StepPolicy extends StepConfig {
|
|
2497
|
+
retries: { limit: number; delay: string; backoff: StepBackoff };
|
|
2332
2498
|
timeout: string;
|
|
2333
2499
|
}
|
|
2334
2500
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "primitive-functions",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.12",
|
|
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",
|