primitive-functions 0.1.0-alpha.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/README.md +20 -0
- package/index.d.ts +706 -0
- package/index.js +34 -0
- package/package.json +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# primitive-functions
|
|
2
|
+
|
|
3
|
+
The module a [Primitive](https://primitive.dev) **server function** imports.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { defineFunction } from "primitive-functions";
|
|
7
|
+
|
|
8
|
+
export default defineFunction(async (input) => {
|
|
9
|
+
return { ok: true, echo: input };
|
|
10
|
+
});
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The platform supplies this module at invoke time: `primitive config push`
|
|
14
|
+
builds your function's bundle with esbuild, inlines every npm dependency, and
|
|
15
|
+
leaves `primitive-functions` external — so your function always runs against the SDK
|
|
16
|
+
the platform is running.
|
|
17
|
+
|
|
18
|
+
This release is a **name reservation** (issue #3179). Its runtime surface
|
|
19
|
+
lands with the server-functions loader; calling anything here outside a
|
|
20
|
+
Primitive sandbox throws.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,706 @@
|
|
|
1
|
+
// GENERATED by scripts/generate-function-profile.mjs from openapi.json.
|
|
2
|
+
// DO NOT EDIT. Run `pnpm functions:profile` and commit the result; the
|
|
3
|
+
// freshness guard in tests/api/spec/function-profile.test.ts fails when this
|
|
4
|
+
// file and a fresh generation diverge.
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type surface of `primitive-functions` — what a server function's author writes
|
|
8
|
+
* against (#3180). The published package's RUNTIME is a stub that throws from
|
|
9
|
+
* every export on purpose: the platform substitutes its own copy at invoke
|
|
10
|
+
* time, and reaching the stub means it did not.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** The signed-in user on whose behalf the invocation runs. */
|
|
14
|
+
export interface FunctionUser {
|
|
15
|
+
userId: string;
|
|
16
|
+
email: string | null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** What started this invocation. Only `http` exists today. */
|
|
20
|
+
export interface FunctionTrigger {
|
|
21
|
+
kind: "http";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The result shape of an operation that answers in response headers. */
|
|
25
|
+
export interface HeaderResult {
|
|
26
|
+
status: number;
|
|
27
|
+
headers: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A platform call that was refused. `errorCode` carries the gateway's own
|
|
32
|
+
* codes (`FUNCTION_ROUTE_NOT_ALLOWED`, `FUNCTION_EGRESS_DENIED`, …) as well
|
|
33
|
+
* as the route's.
|
|
34
|
+
*/
|
|
35
|
+
export interface PrimitivePlatformError extends Error {
|
|
36
|
+
status: number;
|
|
37
|
+
errorCode: string | null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The typed HTTP profile, generated from the platform's OpenAPI document. Its
|
|
42
|
+
* namespaces mirror the operation ids: databaseTypeConfigs, databases, documents, functions.
|
|
43
|
+
* Methods take one options object carrying the operation's path parameters,
|
|
44
|
+
* query parameters, request headers (under their wire names) and `body`.
|
|
45
|
+
*
|
|
46
|
+
* Generated from the same operations as the runtime profile, so a method that
|
|
47
|
+
* type-checks is a method the platform publishes — and a missing path
|
|
48
|
+
* parameter or a missing required header is a compile error rather than a
|
|
49
|
+
* `TypeError` at invoke time. Namespaces the GATEWAY does not yet allow are
|
|
50
|
+
* still declared: they exist, they answer the gateway's structured denial, and
|
|
51
|
+
* hiding them would make a route's availability look like a typo.
|
|
52
|
+
*/
|
|
53
|
+
export interface FunctionApi {
|
|
54
|
+
"databaseTypeConfigs": {
|
|
55
|
+
/** `databaseTypeConfigs.create` — POST /databases/types. Create a database type */
|
|
56
|
+
"create"(args: {
|
|
57
|
+
"dryRun"?: string | number | boolean;
|
|
58
|
+
body: unknown;
|
|
59
|
+
}): Promise<any>;
|
|
60
|
+
/** `databaseTypeConfigs.createOperation` — POST /databases/types/{databaseType}/operations. Create an operation for a database type */
|
|
61
|
+
"createOperation"(args: {
|
|
62
|
+
"databaseType": string | number;
|
|
63
|
+
"dryRun"?: string | number | boolean;
|
|
64
|
+
body: unknown;
|
|
65
|
+
}): Promise<any>;
|
|
66
|
+
/** `databaseTypeConfigs.delete` — DELETE /databases/types/{databaseType}. Delete a database type */
|
|
67
|
+
"delete"(args: {
|
|
68
|
+
"databaseType": string | number;
|
|
69
|
+
}): Promise<any>;
|
|
70
|
+
/** `databaseTypeConfigs.deleteOperation` — DELETE /databases/types/{databaseType}/operations/{name}. Delete an operation for a database type */
|
|
71
|
+
"deleteOperation"(args: {
|
|
72
|
+
"databaseType": string | number;
|
|
73
|
+
"name": string | number;
|
|
74
|
+
}): Promise<any>;
|
|
75
|
+
/** `databaseTypeConfigs.get` — GET /databases/types/{databaseType}. Get a database type */
|
|
76
|
+
"get"(args: {
|
|
77
|
+
"databaseType": string | number;
|
|
78
|
+
}): Promise<any>;
|
|
79
|
+
/** `databaseTypeConfigs.getOperation` — GET /databases/types/{databaseType}/operations/{name}. Get an operation for a database type */
|
|
80
|
+
"getOperation"(args: {
|
|
81
|
+
"databaseType": string | number;
|
|
82
|
+
"name": string | number;
|
|
83
|
+
}): Promise<any>;
|
|
84
|
+
/** `databaseTypeConfigs.getReindexStatus` — GET /databases/types/{databaseType}/reindex-status. Status of the index back-provision fan-out for a type */
|
|
85
|
+
"getReindexStatus"(args: {
|
|
86
|
+
"databaseType": string | number;
|
|
87
|
+
"runId"?: string | number | boolean;
|
|
88
|
+
}): Promise<any>;
|
|
89
|
+
/** `databaseTypeConfigs.list` — GET /databases/types. List database types */
|
|
90
|
+
"list"(args?: Record<string, never>): Promise<any>;
|
|
91
|
+
/** `databaseTypeConfigs.listOperations` — GET /databases/types/{databaseType}/operations. List operations for a database type */
|
|
92
|
+
"listOperations"(args: {
|
|
93
|
+
"databaseType": string | number;
|
|
94
|
+
}): Promise<any>;
|
|
95
|
+
/** `databaseTypeConfigs.scaffoldSchema` — POST /databases/types/{databaseType}/schema:scaffold. Scaffold a starter schema for a database type */
|
|
96
|
+
"scaffoldSchema"(args: {
|
|
97
|
+
"databaseType": string | number;
|
|
98
|
+
}): Promise<any>;
|
|
99
|
+
"subscriptions": {
|
|
100
|
+
/** `databaseTypeConfigs.subscriptions.create` — POST /databases/types/{databaseType}/subscriptions. Create a subscription for a database type */
|
|
101
|
+
"create"(args: {
|
|
102
|
+
"databaseType": string | number;
|
|
103
|
+
body: unknown;
|
|
104
|
+
}): Promise<any>;
|
|
105
|
+
/** `databaseTypeConfigs.subscriptions.delete` — DELETE /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Delete a database type subscription */
|
|
106
|
+
"delete"(args: {
|
|
107
|
+
"databaseType": string | number;
|
|
108
|
+
"subscriptionKey": string | number;
|
|
109
|
+
}): Promise<any>;
|
|
110
|
+
/** `databaseTypeConfigs.subscriptions.get` — GET /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Get a database type subscription */
|
|
111
|
+
"get"(args: {
|
|
112
|
+
"databaseType": string | number;
|
|
113
|
+
"subscriptionKey": string | number;
|
|
114
|
+
}): Promise<any>;
|
|
115
|
+
/** `databaseTypeConfigs.subscriptions.list` — GET /databases/types/{databaseType}/subscriptions. List subscriptions for a database type */
|
|
116
|
+
"list"(args: {
|
|
117
|
+
"databaseType": string | number;
|
|
118
|
+
}): Promise<any>;
|
|
119
|
+
/** `databaseTypeConfigs.subscriptions.update` — PUT /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Update a database type subscription */
|
|
120
|
+
"update"(args: {
|
|
121
|
+
"databaseType": string | number;
|
|
122
|
+
"subscriptionKey": string | number;
|
|
123
|
+
body: unknown;
|
|
124
|
+
}): Promise<any>;
|
|
125
|
+
};
|
|
126
|
+
/** `databaseTypeConfigs.update` — PATCH /databases/types/{databaseType}. Update a database type */
|
|
127
|
+
"update"(args: {
|
|
128
|
+
"databaseType": string | number;
|
|
129
|
+
"dryRun"?: string | number | boolean;
|
|
130
|
+
body: unknown;
|
|
131
|
+
}): Promise<any>;
|
|
132
|
+
/** `databaseTypeConfigs.updateOperation` — PATCH /databases/types/{databaseType}/operations/{name}. Update an operation for a database type */
|
|
133
|
+
"updateOperation"(args: {
|
|
134
|
+
"databaseType": string | number;
|
|
135
|
+
"name": string | number;
|
|
136
|
+
"dryRun"?: string | number | boolean;
|
|
137
|
+
body: unknown;
|
|
138
|
+
}): Promise<any>;
|
|
139
|
+
};
|
|
140
|
+
"databases": {
|
|
141
|
+
/** `databases.addManager` — PUT /databases/{databaseId}/permissions. Set a user's database permission */
|
|
142
|
+
"addManager"(args: {
|
|
143
|
+
"databaseId": string | number;
|
|
144
|
+
body: unknown;
|
|
145
|
+
}): Promise<any>;
|
|
146
|
+
"adminData": {
|
|
147
|
+
/** `databases.adminData.batch` — POST /databases/{databaseId}/admin-data/batch. DEPRECATED — direct database batch; use databases/{databaseId}/records/batch */
|
|
148
|
+
"batch"(args: {
|
|
149
|
+
"databaseId": string | number;
|
|
150
|
+
body: unknown;
|
|
151
|
+
}): Promise<any>;
|
|
152
|
+
/** `databases.adminData.count` — POST /databases/{databaseId}/admin-data/count. DEPRECATED — direct database count; use databases/{databaseId}/records/count */
|
|
153
|
+
"count"(args: {
|
|
154
|
+
"databaseId": string | number;
|
|
155
|
+
body: unknown;
|
|
156
|
+
}): Promise<any>;
|
|
157
|
+
/** `databases.adminData.delete` — POST /databases/{databaseId}/admin-data/delete. DEPRECATED — direct database delete; use databases/{databaseId}/records/delete */
|
|
158
|
+
"delete"(args: {
|
|
159
|
+
"databaseId": string | number;
|
|
160
|
+
body: unknown;
|
|
161
|
+
}): Promise<any>;
|
|
162
|
+
/** `databases.adminData.patch` — POST /databases/{databaseId}/admin-data/patch. DEPRECATED — direct database patch; use databases/{databaseId}/records/patch */
|
|
163
|
+
"patch"(args: {
|
|
164
|
+
"databaseId": string | number;
|
|
165
|
+
body: unknown;
|
|
166
|
+
}): Promise<any>;
|
|
167
|
+
/** `databases.adminData.query` — POST /databases/{databaseId}/admin-data/query. DEPRECATED — direct database query; use databases/{databaseId}/records/query */
|
|
168
|
+
"query"(args: {
|
|
169
|
+
"databaseId": string | number;
|
|
170
|
+
body: unknown;
|
|
171
|
+
}): Promise<any>;
|
|
172
|
+
/** `databases.adminData.save` — POST /databases/{databaseId}/admin-data/save. DEPRECATED — direct database save; use databases/{databaseId}/records/save */
|
|
173
|
+
"save"(args: {
|
|
174
|
+
"databaseId": string | number;
|
|
175
|
+
body: unknown;
|
|
176
|
+
}): Promise<any>;
|
|
177
|
+
};
|
|
178
|
+
/** `databases.create` — POST /databases. Create a database */
|
|
179
|
+
"create"(args: {
|
|
180
|
+
body: unknown;
|
|
181
|
+
}): Promise<any>;
|
|
182
|
+
/** `databases.delete` — DELETE /databases/{databaseId}. Delete a database */
|
|
183
|
+
"delete"(args: {
|
|
184
|
+
"databaseId": string | number;
|
|
185
|
+
}): Promise<any>;
|
|
186
|
+
/** `databases.executeBatch` — POST /databases/{databaseId}/operations/{name}/batch. Execute a database operation in batch */
|
|
187
|
+
"executeBatch"(args: {
|
|
188
|
+
"databaseId": string | number;
|
|
189
|
+
"name": string | number;
|
|
190
|
+
body: unknown;
|
|
191
|
+
}): Promise<any>;
|
|
192
|
+
/** `databases.executeOperation` — POST /databases/{databaseId}/operations/{name}/execute. Execute a database operation */
|
|
193
|
+
"executeOperation"(args: {
|
|
194
|
+
"databaseId": string | number;
|
|
195
|
+
"name": string | number;
|
|
196
|
+
"dryRun"?: string | number | boolean;
|
|
197
|
+
body?: unknown;
|
|
198
|
+
}): Promise<any>;
|
|
199
|
+
/** `databases.get` — GET /databases/{databaseId}. Get a database by id */
|
|
200
|
+
"get"(args: {
|
|
201
|
+
"databaseId": string | number;
|
|
202
|
+
}): Promise<any>;
|
|
203
|
+
/** `databases.getMetadata` — GET /databases/{databaseId}/metadata. Get database metadata */
|
|
204
|
+
"getMetadata"(args: {
|
|
205
|
+
"databaseId": string | number;
|
|
206
|
+
}): Promise<any>;
|
|
207
|
+
/** `databases.grantGroupPermission` — POST /databases/{databaseId}/group-permissions. Grant a group permission on a database */
|
|
208
|
+
"grantGroupPermission"(args: {
|
|
209
|
+
"databaseId": string | number;
|
|
210
|
+
body: unknown;
|
|
211
|
+
}): Promise<any>;
|
|
212
|
+
/** `databases.importBulk` — POST /databases/{databaseId}/operations/{name}/import-bulk. Bulk-import records via a database operation */
|
|
213
|
+
"importBulk"(args: {
|
|
214
|
+
"databaseId": string | number;
|
|
215
|
+
"name": string | number;
|
|
216
|
+
body: unknown;
|
|
217
|
+
}): Promise<any>;
|
|
218
|
+
/** `databases.list` — GET /databases. List databases */
|
|
219
|
+
"list"(args?: Record<string, never>): Promise<any>;
|
|
220
|
+
/** `databases.listGroupPermissions` — GET /databases/{databaseId}/group-permissions. List a database's group permissions */
|
|
221
|
+
"listGroupPermissions"(args: {
|
|
222
|
+
"databaseId": string | number;
|
|
223
|
+
}): Promise<any>;
|
|
224
|
+
/** `databases.listOperations` — GET /databases/{databaseId}/operations. List operations runnable on a database */
|
|
225
|
+
"listOperations"(args: {
|
|
226
|
+
"databaseId": string | number;
|
|
227
|
+
}): Promise<any>;
|
|
228
|
+
/** `databases.listPermissions` — GET /databases/{databaseId}/permissions. List a database's user permissions */
|
|
229
|
+
"listPermissions"(args: {
|
|
230
|
+
"databaseId": string | number;
|
|
231
|
+
}): Promise<any>;
|
|
232
|
+
"records": {
|
|
233
|
+
/** `databases.records.addToSet` — POST /databases/{databaseId}/records/stringset/add. Database records: stringset/add (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
234
|
+
"addToSet"(args: {
|
|
235
|
+
"databaseId": string | number;
|
|
236
|
+
body: unknown;
|
|
237
|
+
}): Promise<any>;
|
|
238
|
+
/** `databases.records.aggregate` — POST /databases/{databaseId}/records/aggregate. Database records: aggregate (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
239
|
+
"aggregate"(args: {
|
|
240
|
+
"databaseId": string | number;
|
|
241
|
+
body: unknown;
|
|
242
|
+
}): Promise<any>;
|
|
243
|
+
/** `databases.records.batch` — POST /databases/{databaseId}/records/batch. Database records: batch (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
244
|
+
"batch"(args: {
|
|
245
|
+
"databaseId": string | number;
|
|
246
|
+
body: unknown;
|
|
247
|
+
}): Promise<any>;
|
|
248
|
+
/** `databases.records.count` — POST /databases/{databaseId}/records/count. Database records: count (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
249
|
+
"count"(args: {
|
|
250
|
+
"databaseId": string | number;
|
|
251
|
+
body: unknown;
|
|
252
|
+
}): Promise<any>;
|
|
253
|
+
/** `databases.records.delete` — POST /databases/{databaseId}/records/delete. Database records: delete (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
254
|
+
"delete"(args: {
|
|
255
|
+
"databaseId": string | number;
|
|
256
|
+
body: unknown;
|
|
257
|
+
}): Promise<any>;
|
|
258
|
+
/** `databases.records.describe` — GET /databases/{databaseId}/records/describe. Database records: describe (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
259
|
+
"describe"(args: {
|
|
260
|
+
"databaseId": string | number;
|
|
261
|
+
"modelName"?: string | number | boolean;
|
|
262
|
+
}): Promise<any>;
|
|
263
|
+
/** `databases.records.dropIndex` — POST /databases/{databaseId}/records/index/drop. Database records: index/drop (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
264
|
+
"dropIndex"(args: {
|
|
265
|
+
"databaseId": string | number;
|
|
266
|
+
body: unknown;
|
|
267
|
+
}): Promise<any>;
|
|
268
|
+
/** `databases.records.dropUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/drop. Database records: unique-constraint/drop (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
269
|
+
"dropUniqueConstraint"(args: {
|
|
270
|
+
"databaseId": string | number;
|
|
271
|
+
body: unknown;
|
|
272
|
+
}): Promise<any>;
|
|
273
|
+
/** `databases.records.increment` — POST /databases/{databaseId}/records/increment. Database records: increment (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
274
|
+
"increment"(args: {
|
|
275
|
+
"databaseId": string | number;
|
|
276
|
+
body: unknown;
|
|
277
|
+
}): Promise<any>;
|
|
278
|
+
/** `databases.records.listIndexes` — GET /databases/{databaseId}/records/indexes. Database records: indexes (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
279
|
+
"listIndexes"(args: {
|
|
280
|
+
"databaseId": string | number;
|
|
281
|
+
"modelName"?: string | number | boolean;
|
|
282
|
+
}): Promise<any>;
|
|
283
|
+
/** `databases.records.listUniqueConstraints` — GET /databases/{databaseId}/records/unique-constraints. Database records: unique-constraints (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
284
|
+
"listUniqueConstraints"(args: {
|
|
285
|
+
"databaseId": string | number;
|
|
286
|
+
"modelName"?: string | number | boolean;
|
|
287
|
+
}): Promise<any>;
|
|
288
|
+
/** `databases.records.models` — GET /databases/{databaseId}/records/models. Database records: models (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
289
|
+
"models"(args: {
|
|
290
|
+
"databaseId": string | number;
|
|
291
|
+
"modelName"?: string | number | boolean;
|
|
292
|
+
}): Promise<any>;
|
|
293
|
+
/** `databases.records.patch` — POST /databases/{databaseId}/records/patch. Database records: patch (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
294
|
+
"patch"(args: {
|
|
295
|
+
"databaseId": string | number;
|
|
296
|
+
body: unknown;
|
|
297
|
+
}): Promise<any>;
|
|
298
|
+
/** `databases.records.query` — POST /databases/{databaseId}/records/query. Database records: query (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
299
|
+
"query"(args: {
|
|
300
|
+
"databaseId": string | number;
|
|
301
|
+
body: unknown;
|
|
302
|
+
}): Promise<any>;
|
|
303
|
+
/** `databases.records.registerIndex` — POST /databases/{databaseId}/records/index/register. Database records: index/register (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
304
|
+
"registerIndex"(args: {
|
|
305
|
+
"databaseId": string | number;
|
|
306
|
+
body: unknown;
|
|
307
|
+
}): Promise<any>;
|
|
308
|
+
/** `databases.records.registerUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/register. Database records: unique-constraint/register (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
309
|
+
"registerUniqueConstraint"(args: {
|
|
310
|
+
"databaseId": string | number;
|
|
311
|
+
body: unknown;
|
|
312
|
+
}): Promise<any>;
|
|
313
|
+
/** `databases.records.removeFromSet` — POST /databases/{databaseId}/records/stringset/remove. Database records: stringset/remove (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
314
|
+
"removeFromSet"(args: {
|
|
315
|
+
"databaseId": string | number;
|
|
316
|
+
body: unknown;
|
|
317
|
+
}): Promise<any>;
|
|
318
|
+
/** `databases.records.save` — POST /databases/{databaseId}/records/save. Database records: save (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
319
|
+
"save"(args: {
|
|
320
|
+
"databaseId": string | number;
|
|
321
|
+
body: unknown;
|
|
322
|
+
}): Promise<any>;
|
|
323
|
+
/** `databases.records.syncIndexes` — POST /databases/{databaseId}/records/indexes/sync. Database records: indexes/sync (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
324
|
+
"syncIndexes"(args: {
|
|
325
|
+
"databaseId": string | number;
|
|
326
|
+
body: unknown;
|
|
327
|
+
}): Promise<any>;
|
|
328
|
+
};
|
|
329
|
+
/** `databases.reindex` — POST /databases/{databaseId}/reindex. Reindex a database */
|
|
330
|
+
"reindex"(args: {
|
|
331
|
+
"databaseId": string | number;
|
|
332
|
+
}): Promise<any>;
|
|
333
|
+
/** `databases.revokeGroupPermission` — DELETE /databases/{databaseId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a database */
|
|
334
|
+
"revokeGroupPermission"(args: {
|
|
335
|
+
"databaseId": string | number;
|
|
336
|
+
"groupType": string | number;
|
|
337
|
+
"groupId": string | number;
|
|
338
|
+
}): Promise<any>;
|
|
339
|
+
/** `databases.revokePermission` — DELETE /databases/{databaseId}/permissions/{userId}. Remove a user's database permission */
|
|
340
|
+
"revokePermission"(args: {
|
|
341
|
+
"databaseId": string | number;
|
|
342
|
+
"userId": string | number;
|
|
343
|
+
}): Promise<any>;
|
|
344
|
+
/** `databases.transferOwnership` — POST /databases/{databaseId}/permissions/transfer. Transfer database ownership */
|
|
345
|
+
"transferOwnership"(args: {
|
|
346
|
+
"databaseId": string | number;
|
|
347
|
+
body: unknown;
|
|
348
|
+
}): Promise<any>;
|
|
349
|
+
/** `databases.update` — PATCH /databases/{databaseId}. Update a database */
|
|
350
|
+
"update"(args: {
|
|
351
|
+
"databaseId": string | number;
|
|
352
|
+
body: unknown;
|
|
353
|
+
}): Promise<any>;
|
|
354
|
+
/** `databases.updateMetadata` — PATCH /databases/{databaseId}/metadata. Update database metadata */
|
|
355
|
+
"updateMetadata"(args: {
|
|
356
|
+
"databaseId": string | number;
|
|
357
|
+
body: unknown;
|
|
358
|
+
}): Promise<any>;
|
|
359
|
+
};
|
|
360
|
+
"documents": {
|
|
361
|
+
/** `documents.addTag` — POST /documents/{documentId}/tags. Add a tag to a document */
|
|
362
|
+
"addTag"(args: {
|
|
363
|
+
"documentId": string | number;
|
|
364
|
+
body: unknown;
|
|
365
|
+
}): Promise<any>;
|
|
366
|
+
"aliases": {
|
|
367
|
+
/** `documents.aliases.delete` — DELETE /document-aliases/{scope}/{aliasKey}. Delete a (scope, aliasKey) document alias binding */
|
|
368
|
+
"delete"(args: {
|
|
369
|
+
"scope": string | number;
|
|
370
|
+
"aliasKey": string | number;
|
|
371
|
+
}): Promise<any>;
|
|
372
|
+
/** `documents.aliases.listForDocument` — GET /documents/{documentId}/aliases. List aliases bound to a document */
|
|
373
|
+
"listForDocument"(args: {
|
|
374
|
+
"documentId": string | number;
|
|
375
|
+
}): Promise<any>;
|
|
376
|
+
/** `documents.aliases.resolve` — GET /document-aliases/{scope}/{aliasKey}. Resolve the document bound to a (scope, aliasKey) alias */
|
|
377
|
+
"resolve"(args: {
|
|
378
|
+
"scope": string | number;
|
|
379
|
+
"aliasKey": string | number;
|
|
380
|
+
}): Promise<any>;
|
|
381
|
+
/** `documents.aliases.set` — PUT /document-aliases/{scope}/{aliasKey}. Bind a (scope, aliasKey) alias to a document */
|
|
382
|
+
"set"(args: {
|
|
383
|
+
"scope": string | number;
|
|
384
|
+
"aliasKey": string | number;
|
|
385
|
+
body: unknown;
|
|
386
|
+
}): Promise<any>;
|
|
387
|
+
};
|
|
388
|
+
/** `documents.approveAccessRequest` — POST /documents/{documentId}/access-requests/{requestId}/approve. Approve a document access request */
|
|
389
|
+
"approveAccessRequest"(args: {
|
|
390
|
+
"documentId": string | number;
|
|
391
|
+
"requestId": string | number;
|
|
392
|
+
body?: unknown;
|
|
393
|
+
}): Promise<any>;
|
|
394
|
+
"blobs": {
|
|
395
|
+
/** `documents.blobs.delete` — DELETE /documents/{documentId}/blobs/{blobId}. Delete a document blob */
|
|
396
|
+
"delete"(args: {
|
|
397
|
+
"documentId": string | number;
|
|
398
|
+
"blobId": string | number;
|
|
399
|
+
}): Promise<any>;
|
|
400
|
+
/** `documents.blobs.downloadHeaders` — HEAD /documents/{documentId}/blobs/{blobId}/download. Get document blob download headers (ETag/304 support) */
|
|
401
|
+
"downloadHeaders"(args: {
|
|
402
|
+
"documentId": string | number;
|
|
403
|
+
"blobId": string | number;
|
|
404
|
+
}): Promise<HeaderResult>;
|
|
405
|
+
/** `documents.blobs.downloadUrl` — GET /documents/{documentId}/blobs/{blobId}/download. Download a document blob's bytes */
|
|
406
|
+
"downloadUrl"(args: {
|
|
407
|
+
"documentId": string | number;
|
|
408
|
+
"blobId": string | number;
|
|
409
|
+
"disposition"?: string | number | boolean;
|
|
410
|
+
}): Promise<Uint8Array>;
|
|
411
|
+
/** `documents.blobs.get` — GET /documents/{documentId}/blobs/{blobId}. Get a document blob's metadata */
|
|
412
|
+
"get"(args: {
|
|
413
|
+
"documentId": string | number;
|
|
414
|
+
"blobId": string | number;
|
|
415
|
+
}): Promise<any>;
|
|
416
|
+
/** `documents.blobs.list` — GET /documents/{documentId}/blobs. List blobs attached to a document */
|
|
417
|
+
"list"(args: {
|
|
418
|
+
"documentId": string | number;
|
|
419
|
+
}): Promise<any>;
|
|
420
|
+
/** `documents.blobs.upload` — PUT /documents/{documentId}/blobs/{blobId}. Upload a document blob with a client-specified id (immutable + idempotent) */
|
|
421
|
+
"upload"(args: {
|
|
422
|
+
"documentId": string | number;
|
|
423
|
+
"blobId": string | number;
|
|
424
|
+
"X-Blob-Filename": string | number;
|
|
425
|
+
"X-Blob-Size": string | number;
|
|
426
|
+
"X-Blob-Sha256": string | number;
|
|
427
|
+
body: ArrayBuffer | Uint8Array | string;
|
|
428
|
+
}): Promise<any>;
|
|
429
|
+
/** `documents.blobs.uploadWithoutId` — PUT /documents/{documentId}/blobs. Deprecated: upload a document blob without a client-specified id */
|
|
430
|
+
"uploadWithoutId"(args: {
|
|
431
|
+
"documentId": string | number;
|
|
432
|
+
}): Promise<any>;
|
|
433
|
+
};
|
|
434
|
+
/** `documents.clearLinkAccess` — DELETE /documents/{documentId}/link-access. Turn off the document's link access */
|
|
435
|
+
"clearLinkAccess"(args: {
|
|
436
|
+
"documentId": string | number;
|
|
437
|
+
}): Promise<any>;
|
|
438
|
+
/** `documents.create` — POST /documents. Create a new document */
|
|
439
|
+
"create"(args: {
|
|
440
|
+
body: unknown;
|
|
441
|
+
}): Promise<any>;
|
|
442
|
+
/** `documents.createInvitation` — POST /documents/{documentId}/invitations. Send an invitation to collaborate on a document */
|
|
443
|
+
"createInvitation"(args: {
|
|
444
|
+
"documentId": string | number;
|
|
445
|
+
body: unknown;
|
|
446
|
+
}): Promise<any>;
|
|
447
|
+
/** `documents.createWithAlias` — POST /documents/create-with-alias. Create a document and bind it to an alias */
|
|
448
|
+
"createWithAlias"(args: {
|
|
449
|
+
body: unknown;
|
|
450
|
+
}): Promise<any>;
|
|
451
|
+
/** `documents.debugDumpUpdates` — POST /documents/{documentId}/debug/dump-updates. Dump a document's raw CRDT update log (debug) */
|
|
452
|
+
"debugDumpUpdates"(args: {
|
|
453
|
+
"documentId": string | number;
|
|
454
|
+
"limit"?: string | number | boolean;
|
|
455
|
+
"offset"?: string | number | boolean;
|
|
456
|
+
"includeData"?: string | number | boolean;
|
|
457
|
+
"includeR2Data"?: string | number | boolean;
|
|
458
|
+
body?: unknown;
|
|
459
|
+
}): Promise<any>;
|
|
460
|
+
/** `documents.debugMerge` — POST /documents/{documentId}/debug/merge. Force-merge a document's pending updates (debug) */
|
|
461
|
+
"debugMerge"(args: {
|
|
462
|
+
"documentId": string | number;
|
|
463
|
+
body?: unknown;
|
|
464
|
+
}): Promise<any>;
|
|
465
|
+
/** `documents.debugMergeBlock` — POST /documents/{documentId}/debug/merge-block. Merge a specific update block of a document (debug) */
|
|
466
|
+
"debugMergeBlock"(args: {
|
|
467
|
+
"documentId": string | number;
|
|
468
|
+
body?: unknown;
|
|
469
|
+
}): Promise<any>;
|
|
470
|
+
/** `documents.debugRestore` — POST /documents/debug/restore. Restore a document from a prior state snapshot (debug) */
|
|
471
|
+
"debugRestore"(args: {
|
|
472
|
+
body: unknown;
|
|
473
|
+
}): Promise<any>;
|
|
474
|
+
/** `documents.debugStats` — GET /documents/{documentId}/debug/stats. Get document storage/update stats (debug) */
|
|
475
|
+
"debugStats"(args: {
|
|
476
|
+
"documentId": string | number;
|
|
477
|
+
}): Promise<any>;
|
|
478
|
+
/** `documents.declineInvitation` — POST /documents/{documentId}/invitations/{invitationId}/decline. Decline a document invitation (invitee only) */
|
|
479
|
+
"declineInvitation"(args: {
|
|
480
|
+
"documentId": string | number;
|
|
481
|
+
"invitationId": string | number;
|
|
482
|
+
}): Promise<any>;
|
|
483
|
+
/** `documents.delete` — DELETE /documents/{documentId}. Delete a document */
|
|
484
|
+
"delete"(args: {
|
|
485
|
+
"documentId": string | number;
|
|
486
|
+
}): Promise<any>;
|
|
487
|
+
/** `documents.deleteInvitation` — DELETE /documents/{documentId}/invitations/{invitationId}. Cancel a pending document invitation */
|
|
488
|
+
"deleteInvitation"(args: {
|
|
489
|
+
"documentId": string | number;
|
|
490
|
+
"invitationId": string | number;
|
|
491
|
+
}): Promise<any>;
|
|
492
|
+
/** `documents.denyAccessRequest` — POST /documents/{documentId}/access-requests/{requestId}/deny. Deny a document access request */
|
|
493
|
+
"denyAccessRequest"(args: {
|
|
494
|
+
"documentId": string | number;
|
|
495
|
+
"requestId": string | number;
|
|
496
|
+
body?: unknown;
|
|
497
|
+
}): Promise<any>;
|
|
498
|
+
/** `documents.exportChain` — GET /documents/{documentId}/export/chain. Export chain of a large document (snapshot + sealed overlays + open epoch) */
|
|
499
|
+
"exportChain"(args: {
|
|
500
|
+
"documentId": string | number;
|
|
501
|
+
}): Promise<any>;
|
|
502
|
+
/** `documents.exportState` — GET /documents/{documentId}/export/state. Export a document's encoded CRDT state */
|
|
503
|
+
"exportState"(args: {
|
|
504
|
+
"documentId": string | number;
|
|
505
|
+
}): Promise<any>;
|
|
506
|
+
/** `documents.get` — GET /documents/{documentId}. Get a single document by id */
|
|
507
|
+
"get"(args: {
|
|
508
|
+
"documentId": string | number;
|
|
509
|
+
}): Promise<any>;
|
|
510
|
+
/** `documents.getImportChainStatus` — GET /documents/{documentId}/import/chain. How far a large document's chain import has got */
|
|
511
|
+
"getImportChainStatus"(args: {
|
|
512
|
+
"documentId": string | number;
|
|
513
|
+
}): Promise<any>;
|
|
514
|
+
/** `documents.getLinkAccess` — GET /documents/{documentId}/link-access. Get the document's "anyone with the link" access level */
|
|
515
|
+
"getLinkAccess"(args: {
|
|
516
|
+
"documentId": string | number;
|
|
517
|
+
}): Promise<any>;
|
|
518
|
+
/** `documents.getOrCreateWithAlias` — POST /documents/get-or-create-with-alias. Get the document bound to an alias, creating it if absent (idempotent) */
|
|
519
|
+
"getOrCreateWithAlias"(args: {
|
|
520
|
+
body: unknown;
|
|
521
|
+
}): Promise<any>;
|
|
522
|
+
/** `documents.getPermissions` — GET /documents/{documentId}/permissions. List a document's user permissions */
|
|
523
|
+
"getPermissions"(args: {
|
|
524
|
+
"documentId": string | number;
|
|
525
|
+
}): Promise<any>;
|
|
526
|
+
/** `documents.getSchema` — GET /documents/{documentId}/schema. Introspect a document's model schema */
|
|
527
|
+
"getSchema"(args: {
|
|
528
|
+
"documentId": string | number;
|
|
529
|
+
}): Promise<any>;
|
|
530
|
+
/** `documents.getStats` — GET /documents/{documentId}/stats. Document statistics (record/model/blob counts, approximate size) */
|
|
531
|
+
"getStats"(args: {
|
|
532
|
+
"documentId": string | number;
|
|
533
|
+
}): Promise<any>;
|
|
534
|
+
/** `documents.grantGroupPermission` — POST /documents/{documentId}/group-permissions. Grant a group permission on a document */
|
|
535
|
+
"grantGroupPermission"(args: {
|
|
536
|
+
"documentId": string | number;
|
|
537
|
+
body: unknown;
|
|
538
|
+
}): Promise<any>;
|
|
539
|
+
/** `documents.importChain` — POST /documents/{documentId}/import/chain. Install an uploaded chain into a large document */
|
|
540
|
+
"importChain"(args: {
|
|
541
|
+
"documentId": string | number;
|
|
542
|
+
body: unknown;
|
|
543
|
+
}): Promise<any>;
|
|
544
|
+
/** `documents.importChainArtifact` — POST /documents/{documentId}/import/chain/artifact. Upload one artifact of a large document's import chain */
|
|
545
|
+
"importChainArtifact"(args: {
|
|
546
|
+
"documentId": string | number;
|
|
547
|
+
"kind"?: string | number | boolean;
|
|
548
|
+
"epoch"?: string | number | boolean;
|
|
549
|
+
"buildId"?: string | number | boolean;
|
|
550
|
+
"model"?: string | number | boolean;
|
|
551
|
+
"index"?: string | number | boolean;
|
|
552
|
+
body: ArrayBuffer | Uint8Array | string;
|
|
553
|
+
}): Promise<any>;
|
|
554
|
+
/** `documents.importState` — POST /documents/{documentId}/import/state. Import encoded CRDT state into a document */
|
|
555
|
+
"importState"(args: {
|
|
556
|
+
"documentId": string | number;
|
|
557
|
+
body: unknown;
|
|
558
|
+
}): Promise<any>;
|
|
559
|
+
/** `documents.list` — GET /documents. List documents the caller can access */
|
|
560
|
+
"list"(args?: Record<string, never>): Promise<any>;
|
|
561
|
+
/** `documents.listAccessRequests` — GET /documents/{documentId}/access-requests. List access requests for a document */
|
|
562
|
+
"listAccessRequests"(args: {
|
|
563
|
+
"documentId": string | number;
|
|
564
|
+
}): Promise<any>;
|
|
565
|
+
/** `documents.listGroupPermissions` — GET /documents/{documentId}/group-permissions. List a document's group permissions */
|
|
566
|
+
"listGroupPermissions"(args: {
|
|
567
|
+
"documentId": string | number;
|
|
568
|
+
}): Promise<any>;
|
|
569
|
+
/** `documents.listInvitations` — GET /documents/{documentId}/invitations. List invitations issued for a document */
|
|
570
|
+
"listInvitations"(args: {
|
|
571
|
+
"documentId": string | number;
|
|
572
|
+
}): Promise<any>;
|
|
573
|
+
/** `documents.listPendingInvitations` — GET /documents/{documentId}/pending-invitations. List a document's pending (deferred) invitations */
|
|
574
|
+
"listPendingInvitations"(args: {
|
|
575
|
+
"documentId": string | number;
|
|
576
|
+
}): Promise<any>;
|
|
577
|
+
/** `documents.open` — POST /documents/open. Open a document for collaboration (resolves access + alias) */
|
|
578
|
+
"open"(args: {
|
|
579
|
+
body: unknown;
|
|
580
|
+
}): Promise<any>;
|
|
581
|
+
"records": {
|
|
582
|
+
/** `documents.records.aggregate` — POST /documents/{documentId}/records/{model}/aggregate. Aggregate records in a document model (count/sum/avg/min/max, optional grouping) */
|
|
583
|
+
"aggregate"(args: {
|
|
584
|
+
"documentId": string | number;
|
|
585
|
+
"model": string | number;
|
|
586
|
+
body: unknown;
|
|
587
|
+
}): Promise<any>;
|
|
588
|
+
/** `documents.records.bulk` — POST /documents/{documentId}/records/bulk. Apply an atomic multi-model record blob to a document (create/patch/delete) */
|
|
589
|
+
"bulk"(args: {
|
|
590
|
+
"documentId": string | number;
|
|
591
|
+
body: unknown;
|
|
592
|
+
}): Promise<any>;
|
|
593
|
+
/** `documents.records.count` — GET /documents/{documentId}/records/{model}/count. Count records in a document model */
|
|
594
|
+
"count"(args: {
|
|
595
|
+
"documentId": string | number;
|
|
596
|
+
"model": string | number;
|
|
597
|
+
}): Promise<any>;
|
|
598
|
+
/** `documents.records.delete` — DELETE /documents/{documentId}/records/{model}/{recordId}. Delete a record from a document model */
|
|
599
|
+
"delete"(args: {
|
|
600
|
+
"documentId": string | number;
|
|
601
|
+
"model": string | number;
|
|
602
|
+
"recordId": string | number;
|
|
603
|
+
}): Promise<any>;
|
|
604
|
+
/** `documents.records.patch` — PATCH /documents/{documentId}/records/{model}/{recordId}. Merge fields into an existing record in a document model */
|
|
605
|
+
"patch"(args: {
|
|
606
|
+
"documentId": string | number;
|
|
607
|
+
"model": string | number;
|
|
608
|
+
"recordId": string | number;
|
|
609
|
+
body: unknown;
|
|
610
|
+
}): Promise<any>;
|
|
611
|
+
/** `documents.records.query` — GET /documents/{documentId}/records/{model}. Query records in a document model */
|
|
612
|
+
"query"(args: {
|
|
613
|
+
"documentId": string | number;
|
|
614
|
+
"model": string | number;
|
|
615
|
+
}): Promise<any>;
|
|
616
|
+
/** `documents.records.save` — POST /documents/{documentId}/records/{model}. Create or replace a record in a document model */
|
|
617
|
+
"save"(args: {
|
|
618
|
+
"documentId": string | number;
|
|
619
|
+
"model": string | number;
|
|
620
|
+
body: unknown;
|
|
621
|
+
}): Promise<any>;
|
|
622
|
+
};
|
|
623
|
+
/** `documents.removePermissionByEmail` — DELETE /documents/{documentId}/permissions. Revoke a user's permission on a document by email (?email=) */
|
|
624
|
+
"removePermissionByEmail"(args: {
|
|
625
|
+
"documentId": string | number;
|
|
626
|
+
"email"?: string | number | boolean;
|
|
627
|
+
}): Promise<any>;
|
|
628
|
+
/** `documents.removePermissionByUserId` — DELETE /documents/{documentId}/permissions/{userId}. Revoke a user's permission on a document by user id */
|
|
629
|
+
"removePermissionByUserId"(args: {
|
|
630
|
+
"documentId": string | number;
|
|
631
|
+
"userId": string | number;
|
|
632
|
+
}): Promise<any>;
|
|
633
|
+
/** `documents.removeTag` — DELETE /documents/{documentId}/tags/{tag}. Remove a tag from a document */
|
|
634
|
+
"removeTag"(args: {
|
|
635
|
+
"documentId": string | number;
|
|
636
|
+
"tag": string | number;
|
|
637
|
+
}): Promise<any>;
|
|
638
|
+
/** `documents.requestAccess` — POST /documents/{documentId}/access-requests. Request access to a document */
|
|
639
|
+
"requestAccess"(args: {
|
|
640
|
+
"documentId": string | number;
|
|
641
|
+
body: unknown;
|
|
642
|
+
}): Promise<any>;
|
|
643
|
+
/** `documents.revokeGroupPermission` — DELETE /documents/{documentId}/group-permissions/{groupType}/{groupId}. Revoke a group permission on a document */
|
|
644
|
+
"revokeGroupPermission"(args: {
|
|
645
|
+
"documentId": string | number;
|
|
646
|
+
"groupType": string | number;
|
|
647
|
+
"groupId": string | number;
|
|
648
|
+
}): Promise<any>;
|
|
649
|
+
/** `documents.setLinkAccess` — PUT /documents/{documentId}/link-access. Set the document's "anyone with the link" access level */
|
|
650
|
+
"setLinkAccess"(args: {
|
|
651
|
+
"documentId": string | number;
|
|
652
|
+
body: unknown;
|
|
653
|
+
}): Promise<any>;
|
|
654
|
+
/** `documents.transferOwnership` — POST /documents/{documentId}/permissions/transfer. Transfer ownership of a document to another user */
|
|
655
|
+
"transferOwnership"(args: {
|
|
656
|
+
"documentId": string | number;
|
|
657
|
+
body: unknown;
|
|
658
|
+
}): Promise<any>;
|
|
659
|
+
/** `documents.update` — PUT /documents/{documentId}. Update a document's metadata */
|
|
660
|
+
"update"(args: {
|
|
661
|
+
"documentId": string | number;
|
|
662
|
+
body: unknown;
|
|
663
|
+
}): Promise<any>;
|
|
664
|
+
/** `documents.updatePermissions` — PUT /documents/{documentId}/permissions. Grant or update a user's permission on a document */
|
|
665
|
+
"updatePermissions"(args: {
|
|
666
|
+
"documentId": string | number;
|
|
667
|
+
body: unknown;
|
|
668
|
+
}): Promise<any>;
|
|
669
|
+
/** `documents.validateAccess` — POST /documents/{documentId}/validate-access. Validate access to a document (accepts/upgrades pending invitations) */
|
|
670
|
+
"validateAccess"(args: {
|
|
671
|
+
"documentId": string | number;
|
|
672
|
+
}): Promise<any>;
|
|
673
|
+
};
|
|
674
|
+
"functions": {
|
|
675
|
+
/** `functions.invoke` — POST /functions/{functionKey}. Invoke a server function synchronously and return its result */
|
|
676
|
+
"invoke"(args: {
|
|
677
|
+
"functionKey": string | number;
|
|
678
|
+
body?: unknown;
|
|
679
|
+
}): Promise<any>;
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
export interface FunctionContext {
|
|
684
|
+
user: FunctionUser;
|
|
685
|
+
trigger: FunctionTrigger;
|
|
686
|
+
api: FunctionApi;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
export declare const SDK_STUB_VERSION: string;
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Declare a server function's handler.
|
|
693
|
+
*
|
|
694
|
+
* Both authoring styles reach the platform bootstrap identically — a plain
|
|
695
|
+
* default export taking `(input, ctx)` runs exactly as a wrapped one does —
|
|
696
|
+
* so this is a typing and intent marker, not a different calling convention.
|
|
697
|
+
*/
|
|
698
|
+
export declare function defineFunction<TInput = unknown, TOutput = unknown>(
|
|
699
|
+
handler: (input: TInput, ctx: FunctionContext) => TOutput | Promise<TOutput>
|
|
700
|
+
): (input: TInput, ctx: FunctionContext) => Promise<TOutput>;
|
|
701
|
+
|
|
702
|
+
declare const _default: {
|
|
703
|
+
SDK_STUB_VERSION: string;
|
|
704
|
+
defineFunction: typeof defineFunction;
|
|
705
|
+
};
|
|
706
|
+
export default _default;
|
package/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `primitive-functions` — the module a Primitive server function imports (#3179).
|
|
3
|
+
*
|
|
4
|
+
* A function's bundle is built by `primitive config push` with esbuild, which
|
|
5
|
+
* inlines every npm dependency EXCEPT this one: the platform loader supplies it
|
|
6
|
+
* at invoke time, so a function always runs against the SDK the platform is
|
|
7
|
+
* running, not the copy that happened to be installed when the code was last
|
|
8
|
+
* pushed.
|
|
9
|
+
*
|
|
10
|
+
* That makes this package a name reservation with a working shape rather than
|
|
11
|
+
* an implementation. The runtime surface — the typed API client, the durable
|
|
12
|
+
* primitives, the trigger helpers — belongs to #3180 and the children after it.
|
|
13
|
+
* Everything here throws if it is ever reached, because reaching it means the
|
|
14
|
+
* loader did not substitute the platform copy, and a silent no-op there would
|
|
15
|
+
* be a function that appears to run and does nothing.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const NOT_PROVIDED =
|
|
19
|
+
"primitive-functions is supplied by the Primitive platform at invoke time. " +
|
|
20
|
+
"Reaching this stub means the function is running outside a Primitive " +
|
|
21
|
+
"sandbox, or the loader did not substitute the platform copy.";
|
|
22
|
+
|
|
23
|
+
/** The version of the reservation stub, so a mis-substitution is diagnosable. */
|
|
24
|
+
export const SDK_STUB_VERSION = "0.0.1";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Declare a function's handler. The platform copy returns the handler wrapped
|
|
28
|
+
* with its invocation context; this one refuses, loudly.
|
|
29
|
+
*/
|
|
30
|
+
export function defineFunction() {
|
|
31
|
+
throw new Error(NOT_PROVIDED);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default { SDK_STUB_VERSION, defineFunction };
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "primitive-functions",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
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
|
+
"license": "UNLICENSED",
|
|
6
|
+
"author": "Primitive LLC",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"types": "./index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./index.d.ts",
|
|
13
|
+
"import": "./index.js",
|
|
14
|
+
"default": "./index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"index.js",
|
|
19
|
+
"index.d.ts",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
27
|
+
}
|
|
28
|
+
}
|