palbase 0.0.0-stage → 0.1.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/LICENSE +27 -0
- package/README.md +2 -2
- package/dist/ai/index.js +17 -0
- package/dist/backend/engine.js +2 -0
- package/dist/backend/env.js +1 -0
- package/dist/backend/index.js +12 -0
- package/dist/backend/stack.js +1 -0
- package/dist/backend/test.js +2 -0
- package/dist/chunks/3OGEBGYZ.js +20 -0
- package/dist/chunks/3VASGTIN.js +2 -0
- package/dist/chunks/3XT4L2XV.js +2 -0
- package/dist/chunks/45J7YXRB.js +2 -0
- package/dist/chunks/6FWCNTAM.js +2 -0
- package/dist/chunks/DAOLIUNZ.js +2 -0
- package/dist/chunks/E5Q4VTW4.js +2 -0
- package/dist/chunks/HKJU2FKE.js +2 -0
- package/dist/chunks/IKVOXHEE.js +2 -0
- package/dist/chunks/JAWWIVZH.js +2 -0
- package/dist/chunks/LYEFPLJZ.js +4 -0
- package/dist/chunks/QXUMLO7O.js +13 -0
- package/dist/chunks/UAY56IQR.js +6 -0
- package/dist/cli.js +815 -0
- package/dist/refuse/ai.js +2 -0
- package/dist/refuse/backend.js +2 -0
- package/dist/refuse/server.js +2 -0
- package/dist/server/index.js +2 -0
- package/dist/server/testing.js +2 -0
- package/dist/web/index.js +2 -0
- package/dist/web/palbe.js +2 -0
- package/dist/web/vite.js +3 -0
- package/package.json +107 -4
- package/types/ai/src/ai.d.ts +178 -0
- package/types/ai/src/index.d.ts +5 -0
- package/types/ai/src/partial.d.ts +1 -0
- package/types/ai/src/schema.d.ts +47 -0
- package/types/backend/src/bootstrap.d.ts +72 -0
- package/types/backend/src/cache.d.ts +32 -0
- package/types/backend/src/container.d.ts +49 -0
- package/types/backend/src/database.d.ts +148 -0
- package/types/backend/src/db-env.d.ts +4 -0
- package/types/backend/src/decorators.d.ts +293 -0
- package/types/backend/src/engine-db.d.ts +24 -0
- package/types/backend/src/engine-exports.d.ts +3 -0
- package/types/backend/src/engine.d.ts +124 -0
- package/types/backend/src/env.d.ts +27 -0
- package/types/backend/src/errors.d.ts +70 -0
- package/types/backend/src/i18n.d.ts +21 -0
- package/types/backend/src/index.d.ts +23 -0
- package/types/backend/src/openapi.d.ts +73 -0
- package/types/backend/src/platform-calls.d.ts +41 -0
- package/types/backend/src/requests.d.ts +81 -0
- package/types/backend/src/rooms.d.ts +168 -0
- package/types/backend/src/router.d.ts +22 -0
- package/types/backend/src/runtime.d.ts +56 -0
- package/types/backend/src/services.d.ts +262 -0
- package/types/backend/src/stack.d.ts +20 -0
- package/types/backend/src/strings-files.d.ts +3 -0
- package/types/backend/src/testing/index.d.ts +3 -0
- package/types/backend/src/testing/unit.d.ts +66 -0
- package/types/backend/src/upload.d.ts +125 -0
- package/types/backend/src/webhooks.d.ts +113 -0
- package/types/internal/src/event.d.ts +9 -0
- package/types/internal/src/modules/ai.d.ts +678 -0
- package/types/internal/src/modules/analytics.d.ts +1414 -0
- package/types/internal/src/modules/auth.d.ts +5660 -0
- package/types/internal/src/modules/cache.d.ts +158 -0
- package/types/internal/src/modules/events.d.ts +19 -0
- package/types/internal/src/modules/flags.d.ts +957 -0
- package/types/internal/src/modules/index.d.ts +13 -0
- package/types/internal/src/modules/machines.d.ts +1584 -0
- package/types/internal/src/modules/notify.d.ts +1450 -0
- package/types/internal/src/modules/purchases.d.ts +2944 -0
- package/types/internal/src/modules/realtime.d.ts +326 -0
- package/types/internal/src/modules/secrets.d.ts +275 -0
- package/types/internal/src/modules/storage.d.ts +691 -0
- package/types/internal/src/modules/stores.d.ts +1516 -0
- package/types/internal/src/retry.d.ts +14 -0
- package/types/internal/src/transport.d.ts +106 -0
- package/types/server/src/auth/dpop.d.ts +47 -0
- package/types/server/src/auth/jwt.d.ts +115 -0
- package/types/server/src/index.d.ts +9 -0
- package/types/server/src/pages.d.ts +4 -0
- package/types/server/src/purchases.d.ts +51 -0
- package/types/server/src/secrets-env.d.ts +22 -0
- package/types/server/src/server.d.ts +40 -0
- package/types/server/src/testing.d.ts +91 -0
- package/types/server/src/webhooks.d.ts +72 -0
- package/types/web/src/analytics.d.ts +87 -0
- package/types/web/src/auth.d.ts +155 -0
- package/types/web/src/backend-error.d.ts +38 -0
- package/types/web/src/backend-names.d.ts +25 -0
- package/types/web/src/backends.d.ts +84 -0
- package/types/web/src/client.d.ts +51 -0
- package/types/web/src/index.d.ts +11 -0
- package/types/web/src/palbe.d.ts +2 -0
- package/types/web/src/purchases.d.ts +73 -0
- package/types/web/src/rooms.d.ts +61 -0
- package/types/web/src/session.d.ts +91 -0
- package/types/web/src/socket.d.ts +87 -0
- package/types/web/src/vite.d.ts +49 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { type Reply, type Transport } from '../transport.js';
|
|
2
|
+
export type BroadcastAccepted = {
|
|
3
|
+
/**
|
|
4
|
+
* The events published.
|
|
5
|
+
*/
|
|
6
|
+
accepted: number;
|
|
7
|
+
};
|
|
8
|
+
export type BroadcastBatch = {
|
|
9
|
+
/**
|
|
10
|
+
* 1 to 100 events.
|
|
11
|
+
*/
|
|
12
|
+
messages: BroadcastMessage[];
|
|
13
|
+
};
|
|
14
|
+
export type BroadcastMessage = {
|
|
15
|
+
/**
|
|
16
|
+
* One membership the event is for alone: the conn its join was answered with (what a room's machine is told a member is). Omitted, every member hears it.
|
|
17
|
+
*/
|
|
18
|
+
conn_id?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The event's name.
|
|
21
|
+
*/
|
|
22
|
+
event: string;
|
|
23
|
+
/**
|
|
24
|
+
* The event's payload: any JSON.
|
|
25
|
+
*/
|
|
26
|
+
payload?: unknown;
|
|
27
|
+
/**
|
|
28
|
+
* The channel (without the realtime: prefix the socket carries).
|
|
29
|
+
*/
|
|
30
|
+
topic: string;
|
|
31
|
+
};
|
|
32
|
+
export type ChannelDeclaration = {
|
|
33
|
+
/**
|
|
34
|
+
* The channels, in the order they are matched.
|
|
35
|
+
*/
|
|
36
|
+
channels: ChannelRule[];
|
|
37
|
+
};
|
|
38
|
+
export type ChannelRule = {
|
|
39
|
+
/**
|
|
40
|
+
* owner: the pattern's one {name} is the joining user, who may do everything; public: any signed-in user subscribes, with the rights below.
|
|
41
|
+
*/
|
|
42
|
+
kind: "owner" | "public";
|
|
43
|
+
/**
|
|
44
|
+
* ':'-separated segments, a {name} segment matching exactly one non-empty segment; 255 bytes at most.
|
|
45
|
+
*/
|
|
46
|
+
pattern: string;
|
|
47
|
+
/**
|
|
48
|
+
* A public channel's subscribers may broadcast on it.
|
|
49
|
+
*/
|
|
50
|
+
publish?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* A public channel's subscribers receive its state.
|
|
53
|
+
*/
|
|
54
|
+
state_read?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* A public channel's subscribers may write its state.
|
|
57
|
+
*/
|
|
58
|
+
state_write?: boolean;
|
|
59
|
+
};
|
|
60
|
+
export type ChannelSubscribers = {
|
|
61
|
+
/**
|
|
62
|
+
* The channel.
|
|
63
|
+
*/
|
|
64
|
+
name: string;
|
|
65
|
+
/**
|
|
66
|
+
* Its subscribers now: the memberships on it, over every replica.
|
|
67
|
+
*/
|
|
68
|
+
subscribers: number;
|
|
69
|
+
};
|
|
70
|
+
export type ErrorResponse = {
|
|
71
|
+
/**
|
|
72
|
+
* Machine-readable error code (snake_case)
|
|
73
|
+
*/
|
|
74
|
+
error: string;
|
|
75
|
+
/**
|
|
76
|
+
* Human-readable explanation
|
|
77
|
+
*/
|
|
78
|
+
error_description: string;
|
|
79
|
+
/**
|
|
80
|
+
* Correlation ID for log/audit lookup
|
|
81
|
+
*/
|
|
82
|
+
request_id: string;
|
|
83
|
+
/**
|
|
84
|
+
* Seconds to wait before retrying; present on a refusal that ends with time.
|
|
85
|
+
*/
|
|
86
|
+
retry_after?: number;
|
|
87
|
+
/**
|
|
88
|
+
* HTTP status code (mirrors the response status)
|
|
89
|
+
*/
|
|
90
|
+
status: number;
|
|
91
|
+
};
|
|
92
|
+
export type PlatformLimits = {
|
|
93
|
+
/**
|
|
94
|
+
* Channels one connection may be on; 0: no ceiling.
|
|
95
|
+
*/
|
|
96
|
+
max_channels_per_connection: number;
|
|
97
|
+
/**
|
|
98
|
+
* Connections a project may hold open at once; 0: no ceiling.
|
|
99
|
+
*/
|
|
100
|
+
max_connections: number;
|
|
101
|
+
/**
|
|
102
|
+
* Broadcasts and state writes per second; 0: no ceiling.
|
|
103
|
+
*/
|
|
104
|
+
max_events_per_second: number;
|
|
105
|
+
/**
|
|
106
|
+
* Channel joins per second; 0: no ceiling.
|
|
107
|
+
*/
|
|
108
|
+
max_joins_per_second: number;
|
|
109
|
+
};
|
|
110
|
+
export type RealtimeLimits = {
|
|
111
|
+
/**
|
|
112
|
+
* Channels one connection may be on; null: the platform's.
|
|
113
|
+
*/
|
|
114
|
+
max_channels_per_connection?: number | null;
|
|
115
|
+
/**
|
|
116
|
+
* Connections open at once; null: the platform's.
|
|
117
|
+
*/
|
|
118
|
+
max_connections?: number | null;
|
|
119
|
+
/**
|
|
120
|
+
* Broadcasts and state writes per second; null: the platform's.
|
|
121
|
+
*/
|
|
122
|
+
max_events_per_second?: number | null;
|
|
123
|
+
/**
|
|
124
|
+
* Channel joins per second; null: the platform's.
|
|
125
|
+
*/
|
|
126
|
+
max_joins_per_second?: number | null;
|
|
127
|
+
platform?: PlatformLimits;
|
|
128
|
+
};
|
|
129
|
+
export type RealtimeLimitsWrite = {
|
|
130
|
+
/**
|
|
131
|
+
* Channels one connection may be on; null: the platform's.
|
|
132
|
+
*/
|
|
133
|
+
max_channels_per_connection?: number | null;
|
|
134
|
+
/**
|
|
135
|
+
* Connections open at once; null: the platform's.
|
|
136
|
+
*/
|
|
137
|
+
max_connections?: number | null;
|
|
138
|
+
/**
|
|
139
|
+
* Broadcasts and state writes per second; null: the platform's.
|
|
140
|
+
*/
|
|
141
|
+
max_events_per_second?: number | null;
|
|
142
|
+
/**
|
|
143
|
+
* Channel joins per second; null: the platform's.
|
|
144
|
+
*/
|
|
145
|
+
max_joins_per_second?: number | null;
|
|
146
|
+
};
|
|
147
|
+
export type RealtimeStats = {
|
|
148
|
+
/**
|
|
149
|
+
* The rows' bucket.
|
|
150
|
+
*/
|
|
151
|
+
bucket: "hour" | "day";
|
|
152
|
+
limits: StatsLimits;
|
|
153
|
+
now: StatsNow;
|
|
154
|
+
/**
|
|
155
|
+
* The measured buckets that overlap the window, oldest first. A bucket nobody measured is absent: zero for a counter, no value for a gauge.
|
|
156
|
+
*/
|
|
157
|
+
rows: StatsRow[];
|
|
158
|
+
/**
|
|
159
|
+
* The window read, in seconds.
|
|
160
|
+
*/
|
|
161
|
+
window_seconds: number;
|
|
162
|
+
};
|
|
163
|
+
export type StateApplied = {
|
|
164
|
+
/**
|
|
165
|
+
* The operations applied.
|
|
166
|
+
*/
|
|
167
|
+
applied: number;
|
|
168
|
+
};
|
|
169
|
+
export type StateBatch = {
|
|
170
|
+
/**
|
|
171
|
+
* 1 to 100 operations.
|
|
172
|
+
*/
|
|
173
|
+
ops: StateOp[];
|
|
174
|
+
};
|
|
175
|
+
export type StateOp = {
|
|
176
|
+
/**
|
|
177
|
+
* Remove the entry instead.
|
|
178
|
+
*/
|
|
179
|
+
delete?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* The entry's key.
|
|
182
|
+
*/
|
|
183
|
+
key: string;
|
|
184
|
+
/**
|
|
185
|
+
* The channel.
|
|
186
|
+
*/
|
|
187
|
+
topic: string;
|
|
188
|
+
/**
|
|
189
|
+
* The entry's value: any JSON (16 KiB at most). Absent with delete.
|
|
190
|
+
*/
|
|
191
|
+
value?: unknown;
|
|
192
|
+
};
|
|
193
|
+
export type StatsLimits = {
|
|
194
|
+
/**
|
|
195
|
+
* The connections the project may hold open at once — its own limit under the platform's (PUT /realtime/limits); null when there is none.
|
|
196
|
+
*/
|
|
197
|
+
connections: number | null;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* What the project holds this moment, over every replica — asked of each replica when read, never a stored sample. Gauges.
|
|
201
|
+
*/
|
|
202
|
+
export type StatsNow = {
|
|
203
|
+
/**
|
|
204
|
+
* Channels with at least one subscriber now — a channel with subscribers on two replicas is one. The platform's channels the SDKs join (roles:<ref>:<user_id>, flags:<ref>) are among them.
|
|
205
|
+
*/
|
|
206
|
+
channels: number;
|
|
207
|
+
/**
|
|
208
|
+
* Sockets open now.
|
|
209
|
+
*/
|
|
210
|
+
connections: number;
|
|
211
|
+
/**
|
|
212
|
+
* The 10 channels with the most subscribers now, the most first (ties by name).
|
|
213
|
+
*/
|
|
214
|
+
top_channels: ChannelSubscribers[];
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* One measured bucket. peak_connections is a gauge (a bucket's highest); the rest are counters (a bucket's total).
|
|
218
|
+
*/
|
|
219
|
+
export type StatsRow = {
|
|
220
|
+
/**
|
|
221
|
+
* Counter: broadcasts published on the project's channels — by its clients, its server, the platform's notices — once each, however many received them.
|
|
222
|
+
*/
|
|
223
|
+
broadcasts: number;
|
|
224
|
+
/**
|
|
225
|
+
* The bucket's start, Unix milliseconds: a UTC hour or day.
|
|
226
|
+
*/
|
|
227
|
+
bucket_ms: number;
|
|
228
|
+
/**
|
|
229
|
+
* Counter: sockets opened.
|
|
230
|
+
*/
|
|
231
|
+
connections_opened: number;
|
|
232
|
+
/**
|
|
233
|
+
* Counter: sockets refused (429) at the project's connection limit or its used-up realtime quota.
|
|
234
|
+
*/
|
|
235
|
+
connections_refused: number;
|
|
236
|
+
/**
|
|
237
|
+
* Counter: frames delivered to the project's sockets — a broadcast as each subscriber received it, a state snapshot or diff. What the meter counts as realtime.messages.
|
|
238
|
+
*/
|
|
239
|
+
messages_delivered: number;
|
|
240
|
+
/**
|
|
241
|
+
* Gauge: the most sockets the project held at once in the bucket — each minute's census summed over every replica, or one replica's own most between two censuses; never above the true peak, and 0 when no census saw one open.
|
|
242
|
+
*/
|
|
243
|
+
peak_connections: number;
|
|
244
|
+
/**
|
|
245
|
+
* Counter: presence (ephemeral) entries written new: a membership's first write of a key, or its first since it removed it.
|
|
246
|
+
*/
|
|
247
|
+
presence_joins: number;
|
|
248
|
+
/**
|
|
249
|
+
* Counter: presence entries removed — by their writer, with its membership, or by the reaper after its replica died.
|
|
250
|
+
*/
|
|
251
|
+
presence_leaves: number;
|
|
252
|
+
};
|
|
253
|
+
/** Palbase Realtime */
|
|
254
|
+
export declare function client(t: Transport): {
|
|
255
|
+
/**
|
|
256
|
+
* Broadcast as the server
|
|
257
|
+
*
|
|
258
|
+
* Publishes events on the project's channels, to every subscriber on every replica, as the project's server (1 to 100 events). Delivered at most once, like every broadcast.
|
|
259
|
+
*/
|
|
260
|
+
broadcast(input: {
|
|
261
|
+
body: BroadcastBatch; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
262
|
+
signal?: AbortSignal;
|
|
263
|
+
}): Promise<Reply<202, BroadcastAccepted>>;
|
|
264
|
+
/**
|
|
265
|
+
* Read the channel declaration
|
|
266
|
+
*
|
|
267
|
+
* The project's channels, in the order they are matched: the first pattern that matches a channel decides it.
|
|
268
|
+
*/
|
|
269
|
+
getChannels(input?: {
|
|
270
|
+
signal?: AbortSignal;
|
|
271
|
+
}): Promise<Reply<200, ChannelDeclaration>>;
|
|
272
|
+
/**
|
|
273
|
+
* Declare the channels
|
|
274
|
+
*
|
|
275
|
+
* Replaces the project's channel declaration, in its order (100 at most). A pattern is ':'-separated segments; a {name} segment matches exactly one. `owner`: the pattern's one {name} must be the joining user, who may do everything on it. `public`: any signed-in user of the project subscribes, and may publish and read or write state as declared. A channel no pattern matches belongs to no one. roles:, flags:, messaging: and debug: are the platform's. Open sockets are decided again within a heartbeat.
|
|
276
|
+
*/
|
|
277
|
+
putChannels(input: {
|
|
278
|
+
body: ChannelDeclaration; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
279
|
+
signal?: AbortSignal;
|
|
280
|
+
}): Promise<Reply<200, ChannelDeclaration>>;
|
|
281
|
+
/**
|
|
282
|
+
* Read the limits
|
|
283
|
+
*
|
|
284
|
+
* The limits the project set for its clients (null: the platform's), and the platform's, which they may only go under.
|
|
285
|
+
*/
|
|
286
|
+
getLimits(input?: {
|
|
287
|
+
signal?: AbortSignal;
|
|
288
|
+
}): Promise<Reply<200, RealtimeLimits>>;
|
|
289
|
+
/**
|
|
290
|
+
* Set the limits
|
|
291
|
+
*
|
|
292
|
+
* Sets the limits the project holds its clients to: connections open at once, events (broadcasts and state writes) and joins per second, channels per connection. null is the platform's; a value above the platform's has no effect beyond it.
|
|
293
|
+
*/
|
|
294
|
+
putLimits(input: {
|
|
295
|
+
body: RealtimeLimitsWrite; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
296
|
+
signal?: AbortSignal;
|
|
297
|
+
}): Promise<Reply<200, RealtimeLimits>>;
|
|
298
|
+
/**
|
|
299
|
+
* Write state as the server
|
|
300
|
+
*
|
|
301
|
+
* Writes or removes entries of the project's channels' state, as the project's server (1 to 100 operations): durable entries, read by every subscriber with state access as a diff. A write past a channel's budget is refused (422) and the operations before it stay applied.
|
|
302
|
+
*/
|
|
303
|
+
writeState(input: {
|
|
304
|
+
body: StateBatch; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
305
|
+
signal?: AbortSignal;
|
|
306
|
+
}): Promise<Reply<200, StateApplied>>;
|
|
307
|
+
/**
|
|
308
|
+
* Read the realtime stats
|
|
309
|
+
*
|
|
310
|
+
* The project's realtime, measured — for its charts.
|
|
311
|
+
*
|
|
312
|
+
* `now` is what it holds this moment: every replica is asked when this is read and all must answer; a replica that is alive and silent (one that just died, for up to 15 seconds) makes it a 503 to retry, never a smaller number.
|
|
313
|
+
*
|
|
314
|
+
* `rows` are the window's buckets (UTC hours, or days), from what realtime measured as it ran: each replica counts in memory and adds its counts to the hour once a minute — a replica that dies loses at most its last minute — and the leader counts every replica's sockets once a minute for the peak. `peak_connections` is a gauge; `messages_delivered`, `broadcasts`, `presence_joins`, `presence_leaves`, `connections_opened` and `connections_refused` are counters. Hours are kept 91 days, then forgotten; they go with the project.
|
|
315
|
+
*
|
|
316
|
+
* `limits.connections` is the connection limit in force, for a limit line.
|
|
317
|
+
*/
|
|
318
|
+
getStats(input?: {
|
|
319
|
+
query?: {
|
|
320
|
+
window_seconds?: number; /** The rows' bucket: hour or day. Absent: hour up to a window of two days, day beyond. */
|
|
321
|
+
bucket?: "hour" | "day";
|
|
322
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
323
|
+
signal?: AbortSignal;
|
|
324
|
+
}): Promise<Reply<200, RealtimeStats>>;
|
|
325
|
+
};
|
|
326
|
+
export type Client = ReturnType<typeof client>;
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { type Reply, type Transport } from '../transport.js';
|
|
2
|
+
/**
|
|
3
|
+
* Every secret of an environment with its value.
|
|
4
|
+
*/
|
|
5
|
+
export type EnvironmentValues = {
|
|
6
|
+
environment: "development" | "production";
|
|
7
|
+
/**
|
|
8
|
+
* Each secret's current value, by name.
|
|
9
|
+
*/
|
|
10
|
+
values: {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Each secret's current version, by name.
|
|
15
|
+
*/
|
|
16
|
+
versions: {
|
|
17
|
+
[key: string]: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type ErrorResponse = {
|
|
21
|
+
/**
|
|
22
|
+
* Machine-readable error code (snake_case)
|
|
23
|
+
*/
|
|
24
|
+
error: string;
|
|
25
|
+
/**
|
|
26
|
+
* Human-readable explanation
|
|
27
|
+
*/
|
|
28
|
+
error_description: string;
|
|
29
|
+
/**
|
|
30
|
+
* Correlation ID for log/audit lookup
|
|
31
|
+
*/
|
|
32
|
+
request_id: string;
|
|
33
|
+
/**
|
|
34
|
+
* Seconds to wait before retrying; present on a refusal that ends with time.
|
|
35
|
+
*/
|
|
36
|
+
retry_after?: number;
|
|
37
|
+
/**
|
|
38
|
+
* HTTP status code (mirrors the response status)
|
|
39
|
+
*/
|
|
40
|
+
status: number;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A secret, without its value.
|
|
44
|
+
*/
|
|
45
|
+
export type Secret = {
|
|
46
|
+
created_at: string;
|
|
47
|
+
environment: "development" | "production";
|
|
48
|
+
/**
|
|
49
|
+
* An environment-variable name.
|
|
50
|
+
*/
|
|
51
|
+
name: string;
|
|
52
|
+
updated_at: string;
|
|
53
|
+
/**
|
|
54
|
+
* The current version.
|
|
55
|
+
*/
|
|
56
|
+
version: number;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* One read or write of the project's secrets.
|
|
60
|
+
*/
|
|
61
|
+
export type SecretAuditEntry = {
|
|
62
|
+
action: "list" | "read" | "read_all" | "write" | "rollback" | "delete" | "versions";
|
|
63
|
+
/**
|
|
64
|
+
* When it happened.
|
|
65
|
+
*/
|
|
66
|
+
at: string;
|
|
67
|
+
environment: "development" | "production";
|
|
68
|
+
id: string;
|
|
69
|
+
/**
|
|
70
|
+
* The id of the key that made the request.
|
|
71
|
+
*/
|
|
72
|
+
key_id: string;
|
|
73
|
+
/**
|
|
74
|
+
* The secret, when the action names one.
|
|
75
|
+
*/
|
|
76
|
+
name?: string;
|
|
77
|
+
request_id: string;
|
|
78
|
+
/**
|
|
79
|
+
* The version read or written, when there is one.
|
|
80
|
+
*/
|
|
81
|
+
version?: number;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* A page of the audit trail, newest first.
|
|
85
|
+
*/
|
|
86
|
+
export type SecretAuditPage = {
|
|
87
|
+
entries: SecretAuditEntry[];
|
|
88
|
+
/**
|
|
89
|
+
* The cursor of the next page; absent on the last page.
|
|
90
|
+
*/
|
|
91
|
+
next_cursor?: string;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A page of an environment's secrets, by name.
|
|
95
|
+
*/
|
|
96
|
+
export type SecretPage = {
|
|
97
|
+
/**
|
|
98
|
+
* The cursor of the next page; absent on the last page.
|
|
99
|
+
*/
|
|
100
|
+
next_cursor?: string;
|
|
101
|
+
secrets: Secret[];
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* The version to go back to.
|
|
105
|
+
*/
|
|
106
|
+
export type SecretRollback = {
|
|
107
|
+
version: number;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* A secret's current value.
|
|
111
|
+
*/
|
|
112
|
+
export type SecretValue = {
|
|
113
|
+
created_at: string;
|
|
114
|
+
environment: "development" | "production";
|
|
115
|
+
name: string;
|
|
116
|
+
updated_at: string;
|
|
117
|
+
/**
|
|
118
|
+
* The value, as written.
|
|
119
|
+
*/
|
|
120
|
+
value: string;
|
|
121
|
+
version: number;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* One of a secret's versions, without its value.
|
|
125
|
+
*/
|
|
126
|
+
export type SecretVersion = {
|
|
127
|
+
created_at: string;
|
|
128
|
+
/**
|
|
129
|
+
* The id of the key that wrote it.
|
|
130
|
+
*/
|
|
131
|
+
created_by: string;
|
|
132
|
+
/**
|
|
133
|
+
* Whether it is the secret's value now.
|
|
134
|
+
*/
|
|
135
|
+
current: boolean;
|
|
136
|
+
version: number;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* A page of a secret's versions, newest first.
|
|
140
|
+
*/
|
|
141
|
+
export type SecretVersionPage = {
|
|
142
|
+
/**
|
|
143
|
+
* The cursor of the next page; absent on the last page.
|
|
144
|
+
*/
|
|
145
|
+
next_cursor?: string;
|
|
146
|
+
versions: SecretVersion[];
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* A secret's new value.
|
|
150
|
+
*/
|
|
151
|
+
export type SecretWrite = {
|
|
152
|
+
/**
|
|
153
|
+
* The value, 64 KiB at most.
|
|
154
|
+
*/
|
|
155
|
+
value: string;
|
|
156
|
+
};
|
|
157
|
+
/** Palbase Secrets */
|
|
158
|
+
export declare function client(t: Transport): {
|
|
159
|
+
/**
|
|
160
|
+
* List the audit trail
|
|
161
|
+
*
|
|
162
|
+
* Every read and write of the project's secrets, newest first, with the key that made it and the request id. Narrow it to an environment, and to a secret's name.
|
|
163
|
+
*/
|
|
164
|
+
listSecretAudit(input?: {
|
|
165
|
+
query?: {
|
|
166
|
+
limit?: number; /** The next_cursor of the previous page. Opaque; omit it for the first page. */
|
|
167
|
+
cursor?: string; /** Only this environment's entries. */
|
|
168
|
+
environment?: "development" | "production"; /** Only this secret's entries. */
|
|
169
|
+
name?: string;
|
|
170
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
171
|
+
signal?: AbortSignal;
|
|
172
|
+
}): Promise<Reply<200, SecretAuditPage>>;
|
|
173
|
+
/**
|
|
174
|
+
* List an environment's secrets
|
|
175
|
+
*
|
|
176
|
+
* An environment's secrets by name, with their current version — never their values. The listing is recorded in the audit trail.
|
|
177
|
+
*/
|
|
178
|
+
listSecrets(input: {
|
|
179
|
+
path: {
|
|
180
|
+
environment: "development" | "production";
|
|
181
|
+
};
|
|
182
|
+
query?: {
|
|
183
|
+
limit?: number; /** The next_cursor of the previous page. Opaque; omit it for the first page. */
|
|
184
|
+
cursor?: string;
|
|
185
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
186
|
+
signal?: AbortSignal;
|
|
187
|
+
}): Promise<Reply<200, SecretPage>>;
|
|
188
|
+
/**
|
|
189
|
+
* Read every value of an environment
|
|
190
|
+
*
|
|
191
|
+
* Every secret of the environment with its current value, in one call: what a server reads at startup. The read is recorded in the audit trail.
|
|
192
|
+
*/
|
|
193
|
+
getEnvironmentValues(input: {
|
|
194
|
+
path: {
|
|
195
|
+
environment: "development" | "production";
|
|
196
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
197
|
+
signal?: AbortSignal;
|
|
198
|
+
}): Promise<Reply<200, EnvironmentValues>>;
|
|
199
|
+
/**
|
|
200
|
+
* Read a secret
|
|
201
|
+
*
|
|
202
|
+
* A secret's current value. The read is recorded in the audit trail.
|
|
203
|
+
*/
|
|
204
|
+
getSecret(input: {
|
|
205
|
+
path: {
|
|
206
|
+
environment: "development" | "production"; /** The secret's name: an environment-variable name (A-Z, 0-9 and _, starting with a letter, 128 at most). */
|
|
207
|
+
name: string;
|
|
208
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
209
|
+
signal?: AbortSignal;
|
|
210
|
+
}): Promise<Reply<200, SecretValue>>;
|
|
211
|
+
/**
|
|
212
|
+
* Write a secret
|
|
213
|
+
*
|
|
214
|
+
* Writes the value as the secret's next version, creating the secret if it is new. Every write is a new version; the old ones stay, to go back to. Emits `secret.changed` (without the value). An environment holds 1000 secrets at most, a value 64 KiB.
|
|
215
|
+
*/
|
|
216
|
+
putSecret(input: {
|
|
217
|
+
path: {
|
|
218
|
+
environment: "development" | "production"; /** The secret's name: an environment-variable name (A-Z, 0-9 and _, starting with a letter, 128 at most). */
|
|
219
|
+
name: string;
|
|
220
|
+
};
|
|
221
|
+
headers?: {
|
|
222
|
+
"Idempotency-Key"?: string;
|
|
223
|
+
};
|
|
224
|
+
body: SecretWrite; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
225
|
+
signal?: AbortSignal;
|
|
226
|
+
}): Promise<Reply<200, Secret>>;
|
|
227
|
+
/**
|
|
228
|
+
* Delete a secret
|
|
229
|
+
*
|
|
230
|
+
* Forgets the secret and every version of it. Emits `secret.changed` (without the value).
|
|
231
|
+
*/
|
|
232
|
+
deleteSecret(input: {
|
|
233
|
+
path: {
|
|
234
|
+
environment: "development" | "production"; /** The secret's name: an environment-variable name (A-Z, 0-9 and _, starting with a letter, 128 at most). */
|
|
235
|
+
name: string;
|
|
236
|
+
};
|
|
237
|
+
headers?: {
|
|
238
|
+
"Idempotency-Key"?: string;
|
|
239
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
240
|
+
signal?: AbortSignal;
|
|
241
|
+
}): Promise<Reply<204, undefined>>;
|
|
242
|
+
/**
|
|
243
|
+
* Go back to an earlier version
|
|
244
|
+
*
|
|
245
|
+
* Makes an earlier version's value the secret's next version; the history stays whole. Emits `secret.changed` (without the value).
|
|
246
|
+
*/
|
|
247
|
+
rollbackSecret(input: {
|
|
248
|
+
path: {
|
|
249
|
+
environment: "development" | "production"; /** The secret's name: an environment-variable name (A-Z, 0-9 and _, starting with a letter, 128 at most). */
|
|
250
|
+
name: string;
|
|
251
|
+
};
|
|
252
|
+
headers?: {
|
|
253
|
+
"Idempotency-Key"?: string;
|
|
254
|
+
};
|
|
255
|
+
body: SecretRollback; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
256
|
+
signal?: AbortSignal;
|
|
257
|
+
}): Promise<Reply<200, Secret>>;
|
|
258
|
+
/**
|
|
259
|
+
* List a secret's versions
|
|
260
|
+
*
|
|
261
|
+
* A secret's versions, newest first, with the key that wrote each — never their values.
|
|
262
|
+
*/
|
|
263
|
+
listSecretVersions(input: {
|
|
264
|
+
path: {
|
|
265
|
+
environment: "development" | "production"; /** The secret's name: an environment-variable name (A-Z, 0-9 and _, starting with a letter, 128 at most). */
|
|
266
|
+
name: string;
|
|
267
|
+
};
|
|
268
|
+
query?: {
|
|
269
|
+
limit?: number; /** The next_cursor of the previous page. Opaque; omit it for the first page. */
|
|
270
|
+
cursor?: string;
|
|
271
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
272
|
+
signal?: AbortSignal;
|
|
273
|
+
}): Promise<Reply<200, SecretVersionPage>>;
|
|
274
|
+
};
|
|
275
|
+
export type Client = ReturnType<typeof client>;
|