@lunora/client 1.0.0-alpha.29 → 1.0.0-alpha.290

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.
Files changed (109) hide show
  1. package/LICENSE.md +201 -104
  2. package/README.md +22 -7
  3. package/dist/admin/index.d.mts +687 -0
  4. package/dist/admin/index.d.ts +687 -0
  5. package/dist/admin/index.mjs +1 -0
  6. package/dist/auth/index.d.mts +138 -5
  7. package/dist/auth/index.d.ts +138 -5
  8. package/dist/auth/index.mjs +1 -1
  9. package/dist/index.d.mts +757 -187
  10. package/dist/index.d.ts +757 -187
  11. package/dist/index.mjs +1 -1
  12. package/dist/packem_shared/ADMIN_AUTH_DEFAULT_PAGE_SIZE-V9c3bHU1.mjs +1 -0
  13. package/dist/packem_shared/CONFLICT_ERROR_CODE-B7qNZMMk.mjs +1 -0
  14. package/dist/packem_shared/DEFAULT_MAX_BUFFER-Bd-_iyiV.mjs +1 -0
  15. package/dist/packem_shared/LunoraAdminClient-aBcOpYpI.mjs +1 -0
  16. package/dist/packem_shared/LunoraClient--R-NfrXm.mjs +1 -0
  17. package/dist/packem_shared/OfflineQueue-Ba2qgZK1.mjs +1 -0
  18. package/dist/packem_shared/RETIRE_AFTER_DURABLE_SEQ_ADVANCE-DoEHtuR8.mjs +1 -0
  19. package/dist/packem_shared/SKIP-d7LeP-sY.mjs +1 -0
  20. package/dist/packem_shared/SubscriptionRegistry-_FfLskdB.mjs +1 -0
  21. package/dist/packem_shared/TabCoordinator-IUCwjnqX.mjs +1 -0
  22. package/dist/packem_shared/applyDelta-CaudNj2C.mjs +1 -0
  23. package/dist/packem_shared/base64-849R7V-V.mjs +1 -0
  24. package/dist/packem_shared/client-tuning-C10B2KCO.mjs +1 -0
  25. package/dist/packem_shared/client-urls-BHLUjjcG.mjs +1 -0
  26. package/dist/packem_shared/connectLiveStream-BdjsWP1-.mjs +1 -0
  27. package/dist/packem_shared/createAsyncStoragePersistence-BgfdvLwe.mjs +1 -0
  28. package/dist/packem_shared/createAsyncStorageQueryCache-6Y94ocbQ.mjs +1 -0
  29. package/dist/packem_shared/createCallRunner-Bwcrfh76.mjs +1 -0
  30. package/dist/packem_shared/createClientQuery-B8Nfj-7o.mjs +1 -0
  31. package/dist/packem_shared/createInMemoryBookmarkStorage-BooZhW0n.mjs +1 -0
  32. package/dist/packem_shared/createInMemoryPersistence-C-IzNVbg.mjs +1 -0
  33. package/dist/packem_shared/createInMemoryQueryCache-DR6AorA2.mjs +1 -0
  34. package/dist/packem_shared/createLocalStore-CDCtdy5O.mjs +1 -0
  35. package/dist/packem_shared/createMutatorRunner-CuMRJpUx.mjs +1 -0
  36. package/dist/packem_shared/createReconnect-CjTmjJDH.mjs +1 -0
  37. package/dist/packem_shared/createServerClient-DEvfqFbl.mjs +1 -0
  38. package/dist/packem_shared/createSnapshotPrecondition-BXP1NPBW.mjs +1 -0
  39. package/dist/packem_shared/delta-merge-C6OqMEPH.mjs +1 -0
  40. package/dist/packem_shared/deserializePreloaded-DxozvweR.mjs +1 -0
  41. package/dist/packem_shared/frame-hint-D-NK691z.mjs +1 -0
  42. package/dist/packem_shared/function-reference.d-Br_hsKje.d.mts +45 -0
  43. package/dist/packem_shared/function-reference.d-Br_hsKje.d.ts +45 -0
  44. package/dist/packem_shared/getServerSession-BaOoo1p6.mjs +1 -0
  45. package/dist/packem_shared/httpStream-DN3D9WqW.mjs +7 -0
  46. package/dist/packem_shared/idb-utility-BS7xvou1.mjs +1 -0
  47. package/dist/packem_shared/live-stream-DBKgZlnb.mjs +10 -0
  48. package/dist/packem_shared/liveTopicSubscription-DQtKMFKw.mjs +1 -0
  49. package/dist/packem_shared/lunora-client-joBzs47U.mjs +1 -0
  50. package/dist/packem_shared/lunora-client.d-DKfDdnjJ.d.ts +4999 -0
  51. package/dist/packem_shared/lunora-client.d-Ezp1eG81.d.mts +4999 -0
  52. package/dist/packem_shared/lunoraQueryKey-CucWmxnx.mjs +1 -0
  53. package/dist/packem_shared/offline-queue-BEqCPDmw.mjs +1 -0
  54. package/dist/packem_shared/optimistic-layers-D-7D3yeJ.mjs +1 -0
  55. package/dist/packem_shared/{preload.d-DGGRMWB5.d.ts → preload.d-qnL9TXVr.d.mts} +2 -1
  56. package/dist/packem_shared/{preload.d-BmztUzzG.d.mts → preload.d-wJ_ggZsg.d.ts} +2 -1
  57. package/dist/packem_shared/preloadQuery-uFy24PCR.mjs +1 -0
  58. package/dist/packem_shared/setAuthTokenProvider-DhBppDiZ.mjs +1 -0
  59. package/dist/packem_shared/single-blob-store-DeaYPBSS.mjs +1 -0
  60. package/dist/packem_shared/snapshot-precondition-BEtcSbWr.mjs +1 -0
  61. package/dist/packem_shared/stream-idle-C7CsIT_m.mjs +1 -0
  62. package/dist/packem_shared/wire-errors-BDckSTKZ.mjs +1 -0
  63. package/dist/pagination/index.d.mts +30 -1
  64. package/dist/pagination/index.d.ts +30 -1
  65. package/dist/pagination/index.mjs +1 -1
  66. package/dist/query/index.d.mts +143 -4
  67. package/dist/query/index.d.ts +143 -4
  68. package/dist/query/index.mjs +1 -1
  69. package/dist/service.d.mts +49 -0
  70. package/dist/service.d.ts +49 -0
  71. package/dist/service.mjs +1 -0
  72. package/dist/ssr/index.d.mts +45 -16
  73. package/dist/ssr/index.d.ts +45 -16
  74. package/dist/ssr/index.mjs +1 -1
  75. package/dist/upload.d.mts +14 -0
  76. package/dist/upload.d.ts +14 -0
  77. package/dist/upload.mjs +1 -1
  78. package/package.json +16 -4
  79. package/dist/packem_shared/CONFLICT_ERROR_CODE-B2SU0CaJ.mjs +0 -1
  80. package/dist/packem_shared/ClientServiceWorker-CRQ5yl7-.mjs +0 -1
  81. package/dist/packem_shared/DEFAULT_MAX_BUFFER-TBn2s7Rz.mjs +0 -1
  82. package/dist/packem_shared/LunoraClient-DDEoZdgP.mjs +0 -1
  83. package/dist/packem_shared/OfflineQueue-B603_q8m.mjs +0 -1
  84. package/dist/packem_shared/SKIP-CArzT3Vl.mjs +0 -1
  85. package/dist/packem_shared/SubscriptionRegistry-CdrOD7sZ.mjs +0 -1
  86. package/dist/packem_shared/TabCoordinator-ijLic02x.mjs +0 -1
  87. package/dist/packem_shared/applyDelta-DXqQORbM.mjs +0 -1
  88. package/dist/packem_shared/createAsyncStoragePersistence-BRLqeXsC.mjs +0 -1
  89. package/dist/packem_shared/createClientQuery-CrdRoicO.mjs +0 -1
  90. package/dist/packem_shared/createInMemoryBookmarkStorage-DCd5Ej-t.mjs +0 -1
  91. package/dist/packem_shared/createInMemoryPersistence-CQYXy8UP.mjs +0 -1
  92. package/dist/packem_shared/createInMemoryQueryCache-DjCKrLjk.mjs +0 -1
  93. package/dist/packem_shared/createLocalStore-B3Tw_Tw1.mjs +0 -1
  94. package/dist/packem_shared/createMutationRunner-lQXH8Amk.mjs +0 -1
  95. package/dist/packem_shared/createMutatorRunner-BVzo0FBZ.mjs +0 -1
  96. package/dist/packem_shared/createReconnect-CFT7YRSR.mjs +0 -1
  97. package/dist/packem_shared/createReply-DF0jRsv-.mjs +0 -1
  98. package/dist/packem_shared/createServerClient-B7KqO8tv.mjs +0 -1
  99. package/dist/packem_shared/createSnapshotPrecondition-DOKRAJ4b.mjs +0 -1
  100. package/dist/packem_shared/deserializePreloaded-CHfOFpka.mjs +0 -1
  101. package/dist/packem_shared/getServerSession-CGjgRBAE.mjs +0 -1
  102. package/dist/packem_shared/httpStream-Cz4_QyjV.mjs +0 -11
  103. package/dist/packem_shared/idb-utility-C-DR8nG1.mjs +0 -1
  104. package/dist/packem_shared/local-store-C53xDvEr.mjs +0 -1
  105. package/dist/packem_shared/lunora-client.d-Bt65hm_E.d.mts +0 -2979
  106. package/dist/packem_shared/lunora-client.d-Bt65hm_E.d.ts +0 -2979
  107. package/dist/packem_shared/offline-queue-D73Dq95V.mjs +0 -1
  108. package/dist/packem_shared/preloadQuery-DjwSjFwt.mjs +0 -1
  109. package/dist/packem_shared/wire-key-D_zOxXK4.mjs +0 -1
@@ -0,0 +1,687 @@
1
+ import { ae as ShardTrafficResult, t as DeploymentPauseStatus, a2 as ScheduleRecord, a8 as SchedulerStatus, a6 as ScheduledJobView, a4 as ScheduledHistoryPage, s as CronRunsResult, as as WorkflowInstanceStatus, ar as WorkflowInstancePage, aq as WorkflowInstanceDetail, ap as WorkflowInstanceCreated, ao as WorkflowInstanceAction, u as FunctionDescriptor, af as StorageListPage, x as GlobalTableInfo, w as GlobalFilterClause, y as GlobalTablePage, G as GlobalFacetResult, L as LunoraClient } from "../packem_shared/lunora-client.d-Ezp1eG81.mjs";
2
+ import { CronJobInfo, VectorIndexSummary, VectorQueryMatch, PipelineLogQuery, PipelineLogPage, AdminTokenSummary, CreatedAdminToken, KvNamespaceSummary, KvKeyListResult, KvValueResult, AuthUser, AuthPage, AuthImpersonation, AuthCapabilities, AuthConfigInfo, AuthSession } from '@lunora/runtime';
3
+ import '@lunora/errors';
4
+ import "../packem_shared/function-reference.d-Br_hsKje.mjs";
5
+ /**
6
+ * A {@link LunoraClient} with the deployment-admin surface: the Studio's
7
+ * functions, scheduler, workflow, storage, KV, vector, global-table and log
8
+ * readers, and the better-auth admin (users, sessions, organizations, teams,
9
+ * roles, invitations).
10
+ *
11
+ * These live on a subclass rather than on `LunoraClient` because class methods
12
+ * never tree-shake: every web app shipped all of them. An app that only reads,
13
+ * writes and subscribes constructs `LunoraClient` and pays nothing for them;
14
+ * an admin tool constructs this instead.
15
+ */
16
+ declare class LunoraAdminClient extends LunoraClient {
17
+ /**
18
+ * Read the cross-shard request distribution for a `.shardBy(...)` table —
19
+ * the feed the studio's `hot_shard` advisor lint consumes. Hits the
20
+ * admin-gated `POST /_lunora/admin/shard-traffic` endpoint, which fans the
21
+ * cheap per-shard `getMetrics` read out across every live shard and returns
22
+ * each shard's `{ shardKey, requests }` total (a failed shard surfaces with
23
+ * `requests: 0`). Requires the worker to be built with a `queryCoordinator`
24
+ * and `adminToken`, and this client's auth token to match; defaults any
25
+ * absent field so an older worker yields an empty-but-valid shape.
26
+ */
27
+ shardTraffic(table: string): Promise<ShardTrafficResult>;
28
+ /**
29
+ * Whether the deployment is paused — function calls refused with
30
+ * `503 DEPLOYMENT_PAUSED`, scheduled jobs held, cron ticks skipped, queue
31
+ * batches handed back. Hits the admin-gated `GET /_lunora/admin/pause`.
32
+ * `supported` is `false` on a worker without a `schedulerDO`.
33
+ */
34
+ getDeploymentPause(): Promise<DeploymentPauseStatus>;
35
+ /**
36
+ * Pause (`true`) or resume (`false`) the deployment, with an optional note
37
+ * shown wherever the pause is. Resuming runs every scheduled job held while
38
+ * paused. Hits the admin-gated `POST /_lunora/admin/pause`.
39
+ */
40
+ setDeploymentPause(paused: boolean, reason?: string): Promise<DeploymentPauseStatus>;
41
+ /**
42
+ * List the functions queued via `runAfter` / `runAt`, soonest-due last
43
+ * (the worker returns them in storage order). Hits the admin-gated
44
+ * `/_lunora/admin/scheduled` endpoint, so the worker must be built with a
45
+ * `schedulerDO` namespace and `adminToken`, and this client's auth token
46
+ * must match. Powers `@lunora/studio`'s scheduled-jobs panel.
47
+ */
48
+ listScheduledJobs(): Promise<ScheduleRecord[]>;
49
+ /**
50
+ * Read the app-level workpool backlog that powers `@lunora/studio`'s SLO
51
+ * view: per-pool `{ name, queued, inFlight, maxConcurrency }` plus the
52
+ * app-wide `backlog` (total queued) and `inFlight` (total held slots) sums.
53
+ * Hits the admin-gated `GET /_lunora/admin/scheduled/status` endpoint, so the
54
+ * same preconditions as {@link listScheduledJobs} apply (a `schedulerDO`
55
+ * namespace + `adminToken` on the worker and a matching auth token here).
56
+ * Defaults any absent field so an older worker still yields a valid shape.
57
+ */
58
+ schedulerStatus(): Promise<SchedulerStatus>;
59
+ /**
60
+ * One scheduled job with its lifecycle state — pending, running, or how it
61
+ * ended (succeeded, failed, canceled) for the scheduler's retention window.
62
+ * `null` for an id never scheduled or past retention. Hits the admin-gated
63
+ * `GET /_lunora/admin/scheduled/job?id=`.
64
+ */
65
+ getScheduledJob(id: string): Promise<ScheduledJobView | null>;
66
+ /**
67
+ * Finished scheduled jobs, newest first — one page of the scheduler's
68
+ * terminal records within the retention window. Pass the returned `cursor`
69
+ * back for the next, older page; it is absent on the last one. Hits the
70
+ * admin-gated `GET /_lunora/admin/scheduled/history`. Powers
71
+ * `@lunora/studio`'s recent-jobs panel.
72
+ */
73
+ listScheduledHistory(options?: {
74
+ cursor?: string;
75
+ }): Promise<ScheduledHistoryPage>;
76
+ /**
77
+ * The code-defined cron jobs' run history: which runs are in flight, and the
78
+ * recorded fires (start, duration, outcome, error, ticks skipped because the
79
+ * previous run was still going), newest first per job. Hits the admin-gated
80
+ * `GET /_lunora/admin/scheduled/cron-runs`, so the worker needs a
81
+ * `schedulerDO` — which every app declaring a cron has.
82
+ */
83
+ listCronRuns(): Promise<CronRunsResult>;
84
+ /** Cancel a pending scheduled job by id. Returns whether a job was removed. */
85
+ cancelScheduledJob(id: string): Promise<{
86
+ cancelled: boolean;
87
+ }>;
88
+ /**
89
+ * List the dead-letter jobs: schedules that exhausted their retry budget
90
+ * and were parked instead of dropped. These never appear in
91
+ * {@link listScheduledJobs} (their live header is gone), so this is the only
92
+ * way the studio surfaces a permanently-failed job. Hits the admin-gated
93
+ * `GET /_lunora/admin/scheduled/dead`; same preconditions as
94
+ * {@link listScheduledJobs}. Powers `@lunora/studio`'s dead-letter panel.
95
+ */
96
+ listDeadJobs(): Promise<ScheduleRecord[]>;
97
+ /**
98
+ * Resurrect a dead-letter job by id: it re-enters the schedule with a fresh
99
+ * retry budget and fires on the next drain. Returns whether a parked record
100
+ * matched. Hits the admin-gated `POST /_lunora/admin/scheduled/dead/retry`.
101
+ */
102
+ retryDeadJob(id: string): Promise<{
103
+ retried: boolean;
104
+ }>;
105
+ /**
106
+ * Permanently drop a dead-letter job by id (the operator has decided not to
107
+ * recover it). Returns whether a parked record was removed. Hits the
108
+ * admin-gated `POST /_lunora/admin/scheduled/dead/cancel`.
109
+ */
110
+ removeDeadJob(id: string): Promise<{
111
+ removed: boolean;
112
+ }>;
113
+ /**
114
+ * List a workflow's instances via the admin Workflows proxy
115
+ * (`/_lunora/admin/workflows/instances`) — the Cloudflare control-plane data
116
+ * the `Workflow` binding can't expose. Requires the worker to be built with a
117
+ * `workflowsClient` (Cloudflare account id + API token). When one isn't
118
+ * configured this does NOT reject: the proxy returns a `200 { configured:
119
+ * false }` sentinel, so the result resolves with `configured === false` and an
120
+ * empty `instances` list — callers should branch on that flag rather than
121
+ * try/catch. (The instance-detail / status endpoints still reject with 501.)
122
+ * `name` is the deployed workflow name.
123
+ */
124
+ listWorkflowInstances(options: {
125
+ name: string;
126
+ page?: number;
127
+ perPage?: number;
128
+ status?: WorkflowInstanceStatus;
129
+ }): Promise<WorkflowInstancePage>;
130
+ /** Read one workflow instance with its step timeline (`/_lunora/admin/workflows/instance`). */
131
+ getWorkflowInstance(options: {
132
+ id: string;
133
+ name: string;
134
+ }): Promise<WorkflowInstanceDetail>;
135
+ /** Start a workflow instance (`/_lunora/admin/workflows/create`). `params` is the instance's JSON-encoded event payload. Needs an Edit-scoped Cloudflare token. */
136
+ createWorkflowInstance(options: {
137
+ id?: string;
138
+ name: string;
139
+ params?: unknown;
140
+ }): Promise<WorkflowInstanceCreated>;
141
+ /** Deliver an event to a running instance's matching `waitForEvent` (`/_lunora/admin/workflows/event`). Needs an Edit-scoped Cloudflare token. */
142
+ sendWorkflowEvent(options: {
143
+ id: string;
144
+ name: string;
145
+ payload?: unknown;
146
+ type: string;
147
+ }): Promise<{
148
+ instanceId: string;
149
+ timestamp?: string;
150
+ }>;
151
+ /** Pause / resume / restart / terminate a workflow instance (`/_lunora/admin/workflows/status`). Needs an Edit-scoped Cloudflare token. */
152
+ setWorkflowInstanceStatus(options: {
153
+ action: WorkflowInstanceAction;
154
+ id: string;
155
+ name: string;
156
+ }): Promise<{
157
+ status: WorkflowInstanceStatus;
158
+ }>;
159
+ /**
160
+ * List the registered public functions (queries / mutations / actions) with
161
+ * their kinds. Hits the admin-gated `GET /_lunora/admin/functions` endpoint —
162
+ * the worker must be built with a `functions` registry and `adminToken`, and
163
+ * this client's auth token must match. Powers `@lunora/studio`'s function
164
+ * runner auto-discovery.
165
+ */
166
+ listFunctions(): Promise<FunctionDescriptor[]>;
167
+ /**
168
+ * List the code-defined cron triggers (the `cronJobs()` map injected on the
169
+ * worker), each flattened to its firing `cron` expression. Hits the
170
+ * admin-gated `GET /_lunora/admin/cron-jobs` endpoint — the worker must be
171
+ * built with a `cronJobs` map and `adminToken`, and this client's auth token
172
+ * must match. These are static (Cloudflare exposes no runtime cron
173
+ * introspection), so the studio renders them read-only alongside the dynamic
174
+ * scheduler jobs.
175
+ */
176
+ getCronJobs(): Promise<CronJobInfo[]>;
177
+ /**
178
+ * Manually fire one code-defined cron job by name — the same dispatch the
179
+ * scheduled trigger runs (dispatch the function, or start the durable
180
+ * workflow), on demand. Hits the admin-gated `POST /_lunora/admin/cron-jobs/run`
181
+ * endpoint; the worker must be built with a `cronJobs` map and `adminToken`,
182
+ * and this client's auth token must match. Resolves when the job has run (a
183
+ * function job's shard response is 2xx, or the workflow instance was created)
184
+ * and rejects with the dispatch error otherwise.
185
+ */
186
+ runCronJob(name: string): Promise<{
187
+ name: string;
188
+ ran: boolean;
189
+ }>;
190
+ /**
191
+ * Fetch the generated OpenAPI 3.1 document. Hits the admin-gated
192
+ * `GET /_lunora/admin/openapi` endpoint — the worker must be built with an
193
+ * `openApiSpec` and `adminToken`, and this client's auth token must match.
194
+ * Powers `@lunora/studio`'s API-reference (Scalar) view. When the worker has
195
+ * no spec wired, the endpoint still resolves with an empty-but-valid OpenAPI
196
+ * document (no `paths`), so callers can render a "not configured" state.
197
+ */
198
+ fetchOpenApi(): Promise<Record<string, unknown>>;
199
+ /**
200
+ * Fetch the generated architecture manifest (module catalog + static call
201
+ * graph). Hits the admin-gated `GET /_lunora/admin/architecture` endpoint.
202
+ * Codegen emits the manifest once the app declares a module
203
+ * (`lunora/<dir>/module.ts`); until then the endpoint answers an empty one
204
+ * (no modules, nodes or edges). Powers `@lunora/studio`'s Architecture view.
205
+ */
206
+ fetchArchitecture(): Promise<Record<string, unknown>>;
207
+ /**
208
+ * Fetch the generated OpenRPC 1.x document. Hits the admin-gated
209
+ * `GET /_lunora/admin/openrpc` endpoint — the worker must be built with an
210
+ * `openRpcSpec` and `adminToken`, and this client's auth token must match.
211
+ * OpenRPC is the RPC-native spec (a `methods` array over the JSON-RPC-shaped
212
+ * `POST /_lunora/rpc` transport); it documents the RPC functions only.
213
+ * Powers `@lunora/studio`'s OpenRPC API-reference view. When the worker has
214
+ * no spec wired, the endpoint still resolves with an empty-but-valid OpenRPC
215
+ * document (no `methods`), so callers can render a "not configured" state.
216
+ */
217
+ fetchOpenRpc(): Promise<Record<string, unknown>>;
218
+ /**
219
+ * List objects in the storage bucket, optionally under a `prefix` and from a
220
+ * pagination `cursor`. Hits the admin-gated `GET /_lunora/admin/storage`
221
+ * endpoint — the worker must be built with a `storageList` function and
222
+ * `adminToken`, and this client's auth token must match. Powers
223
+ * `@lunora/studio`'s file browser.
224
+ */
225
+ listStorageObjects(options?: {
226
+ bucket?: string;
227
+ cursor?: string;
228
+ limit?: number;
229
+ prefix?: string;
230
+ }): Promise<StorageListPage>;
231
+ /**
232
+ * Delete one object from the storage bucket by key. Hits the admin-gated
233
+ * `DELETE /_lunora/admin/storage?key=…` endpoint — the worker must be built
234
+ * with a `storageDelete` function and `adminToken`. Powers the studio file
235
+ * browser's per-row delete; resolves `{ deleted, key }`.
236
+ *
237
+ * An absent `deleted` field reads as `false`, matching every sibling admin
238
+ * verb (`runCronJob`'s `ran`, …): the studio renders this value as the row's
239
+ * outcome, so defaulting a missing field to success would report a delete
240
+ * that a mismatched/older worker never performed.
241
+ */
242
+ deleteStorageObject(key: string, options?: {
243
+ bucket?: string;
244
+ }): Promise<{
245
+ deleted: boolean;
246
+ key: string;
247
+ }>;
248
+ /**
249
+ * List the storage bucket names the worker exposes, for the studio file
250
+ * browser's bucket picker. Hits the admin-gated
251
+ * `GET /_lunora/admin/storage/buckets` endpoint — always resolves (an empty
252
+ * array when the worker configures no `storageBuckets`, i.e. single-bucket).
253
+ */
254
+ listStorageBuckets(): Promise<string[]>;
255
+ /**
256
+ * Upload one object to the storage bucket. Hits the admin-gated
257
+ * `PUT /_lunora/admin/storage?key=…` endpoint with the raw body and an
258
+ * optional `contentType` header — the worker must be built with a
259
+ * `storageUpload` function and `adminToken`. Powers the studio file
260
+ * browser's upload control; resolves `{ etag?, key }`.
261
+ */
262
+ uploadStorageObject(options: {
263
+ body: ArrayBuffer | Blob;
264
+ bucket?: string;
265
+ contentType?: string;
266
+ key: string;
267
+ }): Promise<{
268
+ etag?: string;
269
+ key: string;
270
+ }>;
271
+ /**
272
+ * Build a (signed or public) URL for one object. Hits the admin-gated
273
+ * `GET /_lunora/admin/storage/url?key=…` endpoint — the worker must be built
274
+ * with a `storageSignedUrl` function and `adminToken`. Powers the studio
275
+ * file browser's copy-URL action; resolves the URL string.
276
+ *
277
+ * `options.expiresInSeconds` requests a share-link lifetime, which is
278
+ * validated/clamped server-side. The options object mirrors the worker's
279
+ * `StorageSignedUrlFunction` options (a `password` / download-limit are noted
280
+ * as future fields there).
281
+ */
282
+ signedStorageUrl(key: string, options?: {
283
+ bucket?: string;
284
+ expiresInSeconds?: number;
285
+ }): Promise<string>;
286
+ /**
287
+ * List the `.global()` (D1-backed) tables with their row counts. Hits the
288
+ * admin-gated `GET /_lunora/admin/global/tables` endpoint — the worker must
289
+ * be built with a `globalIntrospector` and `adminToken`. Powers the data
290
+ * browser's global mode.
291
+ */
292
+ listGlobalTables(): Promise<GlobalTableInfo[]>;
293
+ /**
294
+ * Read a page of rows from one `.global()` table. `filters` AND-narrows the
295
+ * page to rows matching each `column = value` eq constraint — the drill-down a
296
+ * facet-value click applies; the array is wire-encoded, JSON-encoded into the
297
+ * `filters` query param, and the values are bound server-side.
298
+ *
299
+ * The response is `decodeWire`d. The worker encodes it (`readGlobalTablePage`
300
+ * in `@lunora/d1`) because JSON cannot carry a `v.bigint()` column at all and
301
+ * silently flattens a `v.bytes()` one to `{}` — so without the decode here the
302
+ * grid renders the raw 3-element tagged array instead of the value. The shard
303
+ * browser's twin already pairs the same way through `rpc`; this is the global
304
+ * half of that symmetry.
305
+ */
306
+ readGlobalTablePage(options: {
307
+ filters?: GlobalFilterClause[];
308
+ limit?: number;
309
+ offset?: number;
310
+ table: string;
311
+ }): Promise<GlobalTablePage>;
312
+ /**
313
+ * Summarise the distinct values of one column in a `.global()` table over the
314
+ * active view (the same eq `filters` the browser is previewing) — the global
315
+ * twin of the shard browser's facet. Hits the admin-gated
316
+ * `GET /_lunora/admin/global/facet` endpoint; `column` is validated + bound
317
+ * server-side. Powers the global data browser's facet sidebar.
318
+ *
319
+ * Wire-encoded/decoded on both legs for the same reason
320
+ * {@link LunoraAdminClient.readGlobalTablePage} is: a facet over a BLOB column
321
+ * returns bytes, which `Response.json` flattens to `{}` — and since a facet
322
+ * value is exactly what a click sends back as a `filters` clause, that is a
323
+ * broken drill-down rather than a display glitch.
324
+ */
325
+ facetGlobalColumn(options: {
326
+ column: string;
327
+ filters?: GlobalFilterClause[];
328
+ limit?: number;
329
+ table: string;
330
+ }): Promise<GlobalFacetResult>;
331
+ /**
332
+ * List the schema's Vectorize indexes with their declared shape (table,
333
+ * field, dimensions, metric, metadata) and live stats (vector count,
334
+ * processing watermark) when the binding is reachable. Hits the admin-gated
335
+ * `GET /_lunora/admin/vector/indexes` endpoint — the worker must be built
336
+ * with a `vectorIntrospector` and `adminToken`. Powers the studio's vector
337
+ * browser. Vectorize can't enumerate indexes at runtime, so this list comes
338
+ * from the generated `LUNORA_VECTOR_INDEXES` registry.
339
+ */
340
+ listVectorIndexes(): Promise<VectorIndexSummary[]>;
341
+ /**
342
+ * Run a nearest-neighbour similarity query against one vector index: the
343
+ * worker embeds `text` via the index's embedder and returns the top matches.
344
+ * Hits the admin-gated `POST /_lunora/admin/vector/query` endpoint. Throws
345
+ * `VECTOR_QUERY_UNSUPPORTED` when the worker's introspector has no embedder
346
+ * wired (the index lists read-only).
347
+ */
348
+ queryVectorIndex(options: {
349
+ name: string;
350
+ text: string;
351
+ topK?: number;
352
+ }): Promise<VectorQueryMatch[]>;
353
+ /**
354
+ * Read one keyset-paginated page of the durable `ctx.log` archive that
355
+ * `pipelineLogSink` writes to R2. Server-side only — the worker holds the R2
356
+ * SQL credentials and runs the reader; the browser only sees the decoded
357
+ * `{ rows, nextCursor }`. Pass the previous page's `nextCursor` as
358
+ * `query.cursor` to page. Admin-gated. When the operator hasn't wired the
359
+ * archive, `adminFetch` throws a `LunoraClientError` with `.code ===
360
+ * "LOG_ARCHIVE_NOT_CONFIGURED"`, so a caller can render a "not configured"
361
+ * state rather than an error.
362
+ */
363
+ queryLogArchive(query?: PipelineLogQuery): Promise<PipelineLogPage>;
364
+ /**
365
+ * List the deployment's named admin tokens (name, created, last used,
366
+ * expiry — never the secret). Hits the root-only `GET /_lunora/admin/tokens`.
367
+ */
368
+ listAdminTokens(): Promise<AdminTokenSummary[]>;
369
+ /**
370
+ * Create a named admin token. The returned `token` is the only time the
371
+ * secret is shown. Root-only: a named token cannot create another.
372
+ */
373
+ createAdminToken(options: {
374
+ expiresAt?: number;
375
+ name: string;
376
+ scopes?: ReadonlyArray<string>;
377
+ }): Promise<CreatedAdminToken>;
378
+ /** Revoke a named admin token. Root-only; other isolates refuse it within 30 seconds. */
379
+ revokeAdminToken(name: string): Promise<void>;
380
+ /**
381
+ * List the worker's registered Workers KV namespaces (binding names). Hits
382
+ * the admin-gated `GET /_lunora/admin/kv/namespaces` endpoint — the worker
383
+ * must be built with a `kvIntrospector` and `adminToken`. Powers the
384
+ * studio's KV browser.
385
+ */
386
+ listKvNamespaces(): Promise<KvNamespaceSummary[]>;
387
+ /**
388
+ * List keys in a KV namespace, optionally filtered by `prefix` and
389
+ * paginated via `cursor`. Hits the admin-gated
390
+ * `GET /_lunora/admin/kv/keys` endpoint.
391
+ */
392
+ listKvKeys(options: {
393
+ cursor?: string;
394
+ limit?: number;
395
+ namespace: string;
396
+ prefix?: string;
397
+ }): Promise<KvKeyListResult>;
398
+ /**
399
+ * Read a KV value (as text) and its metadata. Hits the admin-gated
400
+ * `GET /_lunora/admin/kv/value` endpoint. Returns `{ value: null, metadata: null }`
401
+ * when the key is absent.
402
+ */
403
+ getKvValue(options: {
404
+ key: string;
405
+ namespace: string;
406
+ }): Promise<KvValueResult>;
407
+ /**
408
+ * Write a string value to a KV namespace. Accepts an absolute `expiration`
409
+ * (Unix seconds) or a relative `expirationTtl`, plus optional `metadata` —
410
+ * re-send the loaded values on edit so a save preserves rather than clears
411
+ * them. Hits the admin-gated `PUT /_lunora/admin/kv/value` endpoint.
412
+ */
413
+ putKvValue(options: {
414
+ expiration?: number;
415
+ expirationTtl?: number;
416
+ key: string;
417
+ metadata?: unknown;
418
+ namespace: string;
419
+ value: string;
420
+ }): Promise<void>;
421
+ /**
422
+ * Delete a key from a KV namespace. No-op when the key is absent. Hits the
423
+ * admin-gated `DELETE /_lunora/admin/kv/value` endpoint.
424
+ */
425
+ deleteKvKey(options: {
426
+ key: string;
427
+ namespace: string;
428
+ }): Promise<void>;
429
+ /**
430
+ * List authenticated users, paged and optionally searched / filtered / sorted.
431
+ * Hits the admin-gated `GET /_lunora/admin/auth/users` endpoint — the worker
432
+ * must be built with an `authAdmin` and `adminToken`. Powers the studio's
433
+ * users dashboard.
434
+ */
435
+ listAuthUsers(options?: {
436
+ filterField?: string;
437
+ filterValue?: string;
438
+ limit?: number;
439
+ offset?: number;
440
+ search?: string;
441
+ searchField?: string;
442
+ sortBy?: string;
443
+ sortDirection?: "asc" | "desc";
444
+ }): Promise<AuthPage<AuthUser>>;
445
+ /**
446
+ * Create a user. Hits the admin-gated `POST /_lunora/admin/auth/users/create`
447
+ * endpoint (requires the worker's `authAdmin` to implement `createUser`).
448
+ * `data` carries any app-defined `user.additionalFields`.
449
+ */
450
+ createAuthUser(input: {
451
+ data?: Record<string, unknown>;
452
+ email: string;
453
+ name: string;
454
+ password?: string;
455
+ role?: string | string[];
456
+ }): Promise<AuthUser>;
457
+ /** Set a user's role (string, or array joined comma-wise server-side). */
458
+ setAuthUserRole(input: {
459
+ role: string | string[];
460
+ userId: string;
461
+ }): Promise<AuthUser>;
462
+ /** Ban a user. `expiresInSeconds` sets a temporary ban; omit it for a permanent one. Revokes the user's live sessions. */
463
+ banAuthUser(input: {
464
+ expiresInSeconds?: number;
465
+ reason?: string;
466
+ userId: string;
467
+ }): Promise<AuthUser>;
468
+ /** Lift a user's ban. */
469
+ unbanAuthUser(input: {
470
+ userId: string;
471
+ }): Promise<AuthUser>;
472
+ /** Set a user's password (admin override — no current-password challenge). */
473
+ setAuthUserPassword(input: {
474
+ newPassword: string;
475
+ userId: string;
476
+ }): Promise<void>;
477
+ /** Permanently delete a user and revoke their sessions. */
478
+ removeAuthUser(input: {
479
+ userId: string;
480
+ }): Promise<void>;
481
+ /**
482
+ * Mint an impersonation session for a user, returning its bearer `token`.
483
+ * The caller is responsible for using the token (e.g. setting the session
484
+ * cookie); the server performs no cookie round-trip.
485
+ */
486
+ impersonateAuthUser(input: {
487
+ userId: string;
488
+ }): Promise<AuthImpersonation>;
489
+ /** Revoke a single session by its id (force sign-out of one device). */
490
+ revokeAuthSession(input: {
491
+ sessionId: string;
492
+ }): Promise<void>;
493
+ /** Revoke every session for a user (force sign-out everywhere). */
494
+ revokeAuthUserSessions(input: {
495
+ userId: string;
496
+ }): Promise<void>;
497
+ /**
498
+ * Report which auth dashboard surfaces are available — derived server-side
499
+ * from the enabled better-auth plugins. The studio renders only the panels
500
+ * whose capability is `true`.
501
+ */
502
+ getAuthCapabilities(): Promise<AuthCapabilities>;
503
+ /** Update a user's fields (name/email/app-defined `additionalFields`). */
504
+ updateAuthUser(input: {
505
+ data: Record<string, unknown>;
506
+ userId: string;
507
+ }): Promise<AuthUser>;
508
+ /** List a user's linked accounts (credential / OAuth providers). Token material is stripped server-side. */
509
+ listAuthAccounts(input: {
510
+ userId: string;
511
+ }): Promise<Record<string, unknown>[]>;
512
+ /** Unlink a linked account from a user. */
513
+ unlinkAuthAccount(input: {
514
+ accountId: string;
515
+ userId: string;
516
+ }): Promise<void>;
517
+ /** List a user's API keys (requires the `apiKey` plugin). The hash is never returned. */
518
+ listAuthApiKeys(input: {
519
+ userId: string;
520
+ }): Promise<Record<string, unknown>[]>;
521
+ /** Revoke (delete) an API key by id (requires the `apiKey` plugin). */
522
+ deleteAuthApiKey(input: {
523
+ apiKeyId: string;
524
+ }): Promise<void>;
525
+ /** List a user's registered passkeys (requires the passkey plugin). */
526
+ listAuthPasskeys(input: {
527
+ userId: string;
528
+ }): Promise<Record<string, unknown>[]>;
529
+ /** Delete a passkey by id (requires the passkey plugin). */
530
+ deleteAuthPasskey(input: {
531
+ passkeyId: string;
532
+ }): Promise<void>;
533
+ /** Disable two-factor auth for a user (requires the two-factor plugin). */
534
+ disableAuthTwoFactor(input: {
535
+ userId: string;
536
+ }): Promise<void>;
537
+ /** List organizations, paged (requires the organization plugin). */
538
+ listAuthOrganizations(options?: {
539
+ limit?: number;
540
+ offset?: number;
541
+ }): Promise<AuthPage<Record<string, unknown>>>;
542
+ /** List the members of an organization (requires the organization plugin). */
543
+ listAuthOrgMembers(input: {
544
+ limit?: number;
545
+ offset?: number;
546
+ organizationId: string;
547
+ }): Promise<AuthPage<Record<string, unknown>>>;
548
+ /** List an organization's pending invitations (requires the organization plugin). */
549
+ listAuthOrgInvitations(input: {
550
+ limit?: number;
551
+ offset?: number;
552
+ organizationId: string;
553
+ }): Promise<AuthPage<Record<string, unknown>>>;
554
+ /**
555
+ * List sign-up invitations, newest first (requires the `inviteOnly` plugin).
556
+ * Unfiltered: a row is pending when `acceptedAt` is null and `expiresAt` is in
557
+ * the future, and the caller labels it — filtering server-side after the page
558
+ * would let page 1 come back empty while pending rows sat on page 2.
559
+ */
560
+ listAuthSignUpInvitations(options?: {
561
+ limit?: number;
562
+ offset?: number;
563
+ }): Promise<AuthPage<Record<string, unknown>>>;
564
+ /** Invite an address to sign up, or refresh an existing invitation for it. */
565
+ createAuthSignUpInvitation(input: {
566
+ email: string;
567
+ expiresInSeconds?: number;
568
+ invitedBy?: string;
569
+ }): Promise<Record<string, unknown>>;
570
+ /** Withdraw a sign-up invitation. Not retroactive — an account already created keeps existing. */
571
+ revokeAuthSignUpInvitation(input: {
572
+ email: string;
573
+ }): Promise<void>;
574
+ removeAuthOrgMember(input: {
575
+ memberId: string;
576
+ }): Promise<void>;
577
+ cancelAuthOrgInvitation(input: {
578
+ invitationId: string;
579
+ }): Promise<void>;
580
+ /**
581
+ * Report the deployment's auth configuration — enabled plugins, sign-in
582
+ * methods, user-settable create-user fields, organization sub-features
583
+ * (teams / roles), and session / rate-limit policy. Drives the config panel
584
+ * and the dynamic create-user form. Never carries a secret.
585
+ */
586
+ getAuthConfig(): Promise<AuthConfigInfo>;
587
+ /** Create an organization; optionally seed an `owner` member for `ownerId`. */
588
+ createAuthOrganization(input: {
589
+ logo?: string;
590
+ metadata?: Record<string, unknown>;
591
+ name: string;
592
+ ownerId?: string;
593
+ slug?: string;
594
+ }): Promise<Record<string, unknown>>;
595
+ /** Update an organization's name/slug/logo/metadata. */
596
+ updateAuthOrganization(input: {
597
+ logo?: string;
598
+ metadata?: Record<string, unknown>;
599
+ name?: string;
600
+ organizationId: string;
601
+ slug?: string;
602
+ }): Promise<Record<string, unknown>>;
603
+ /** Delete an organization and cascade its members, invitations, teams, and custom roles. */
604
+ deleteAuthOrganization(input: {
605
+ organizationId: string;
606
+ }): Promise<void>;
607
+ /** Directly add an existing user to an organization (no invitation/acceptance). */
608
+ addAuthOrgMember(input: {
609
+ organizationId: string;
610
+ role?: string;
611
+ userId: string;
612
+ }): Promise<Record<string, unknown>>;
613
+ /** Create a pending email invitation to an organization. */
614
+ inviteAuthOrgMember(input: {
615
+ email: string;
616
+ inviterId?: string;
617
+ organizationId: string;
618
+ role?: string;
619
+ }): Promise<Record<string, unknown>>;
620
+ setAuthOrgMemberRole(input: {
621
+ memberId: string;
622
+ role: string | string[];
623
+ }): Promise<Record<string, unknown>>;
624
+ /** List an organization's teams (requires the organization plugin with teams enabled). */
625
+ listAuthOrgTeams(input: {
626
+ limit?: number;
627
+ offset?: number;
628
+ organizationId: string;
629
+ }): Promise<AuthPage<Record<string, unknown>>>;
630
+ /** Create a team under an organization. */
631
+ createAuthOrgTeam(input: {
632
+ name: string;
633
+ organizationId: string;
634
+ }): Promise<Record<string, unknown>>;
635
+ updateAuthOrgTeam(input: {
636
+ name: string;
637
+ teamId: string;
638
+ }): Promise<Record<string, unknown>>;
639
+ /** Delete a team and its memberships. */
640
+ removeAuthOrgTeam(input: {
641
+ teamId: string;
642
+ }): Promise<void>;
643
+ listAuthOrgTeamMembers(input: {
644
+ limit?: number;
645
+ offset?: number;
646
+ teamId: string;
647
+ }): Promise<AuthPage<Record<string, unknown>>>;
648
+ addAuthOrgTeamMember(input: {
649
+ teamId: string;
650
+ userId: string;
651
+ }): Promise<Record<string, unknown>>;
652
+ removeAuthOrgTeamMember(input: {
653
+ teamMemberId: string;
654
+ }): Promise<void>;
655
+ /** List an organization's custom roles (requires the organization plugin with dynamic access control). */
656
+ listAuthOrgRoles(input: {
657
+ limit?: number;
658
+ offset?: number;
659
+ organizationId: string;
660
+ }): Promise<AuthPage<Record<string, unknown>>>;
661
+ /** Create a custom org role with a permission grant (a `resource -> actions[]` map). */
662
+ createAuthOrgRole(input: {
663
+ organizationId: string;
664
+ permission: Record<string, string[]>;
665
+ role: string;
666
+ }): Promise<Record<string, unknown>>;
667
+ /** Replace a custom org role's permission grant. */
668
+ updateAuthOrgRole(input: {
669
+ permission: Record<string, string[]>;
670
+ roleId: string;
671
+ }): Promise<Record<string, unknown>>;
672
+ deleteAuthOrgRole(input: {
673
+ roleId: string;
674
+ }): Promise<void>;
675
+ /** List auth sessions, paged and optionally filtered to one user. */
676
+ listAuthSessions(options?: {
677
+ limit?: number;
678
+ offset?: number;
679
+ userId?: string;
680
+ }): Promise<AuthPage<AuthSession>>;
681
+ }
682
+ /**
683
+ * Whether `client` carries the admin surface. Structural rather than
684
+ * `instanceof`, so a client from a second copy of this package still passes.
685
+ */
686
+ declare const isLunoraAdminClient: (client: LunoraClient) => client is LunoraAdminClient;
687
+ export { LunoraAdminClient, isLunoraAdminClient };