@lunora/server 1.0.0-alpha.31 → 1.0.0-alpha.33
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.md +213 -0
- package/dist/data-model.mjs +0 -1
- package/dist/drizzle.mjs +1 -1
- package/dist/index.d.mts +106 -9
- package/dist/index.d.ts +106 -9
- package/dist/index.mjs +1 -29
- package/dist/otel.d.mts +543 -0
- package/dist/otel.d.ts +543 -0
- package/dist/otel.mjs +1 -0
- package/dist/packem_shared/LunoraEnvError-CgpI2Mm_.mjs +3 -0
- package/dist/packem_shared/LunoraError-LVhdU0Lo.mjs +1 -0
- package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-CF_9uiu1.mjs +1 -0
- package/dist/packem_shared/allowAll-BnyNbJZT.mjs +1 -0
- package/dist/packem_shared/asBucketStorage-1pFfH-Tn.mjs +1 -0
- package/dist/packem_shared/bindOrm-Bp9hsM2q.mjs +1 -0
- package/dist/packem_shared/buildRlsReadRegistry-WdiqSj87.mjs +1 -0
- package/dist/packem_shared/composePluginMiddleware-COr09CXA.mjs +1 -0
- package/dist/packem_shared/createPolicyDsl-sV1swpkD.mjs +1 -0
- package/dist/packem_shared/createSecrets-CgVPiW2C.mjs +1 -0
- package/dist/packem_shared/defineAggregateIndex-CYuH6IbJ.mjs +1 -0
- package/dist/packem_shared/defineIdentity-B7gfAgxx.mjs +1 -0
- package/dist/packem_shared/defineMigration-Bfpwxv2f.mjs +1 -0
- package/dist/packem_shared/defineMutator-8Kz0j1Kt.mjs +1 -0
- package/dist/packem_shared/defineShape-CyuRfwHz.mjs +1 -0
- package/dist/packem_shared/defineStorageRule-BDu01PUn.mjs +1 -0
- package/dist/packem_shared/functions-CDC08CWY.mjs +1 -0
- package/dist/packem_shared/httpAction-C14NuF3V.mjs +4 -0
- package/dist/packem_shared/initLunora-CHh1EmR4.mjs +1 -0
- package/dist/packem_shared/mask-C6Bi78qj.mjs +1 -0
- package/dist/packem_shared/onConnect-CEtRmUpJ.mjs +1 -0
- package/dist/packem_shared/policy-tag-Dprt9JWo.mjs +1 -0
- package/dist/packem_shared/protectPublic-BhKewPqm.mjs +1 -0
- package/dist/packem_shared/rls-_iVsPvhX.mjs +1 -0
- package/dist/packem_shared/run-middleware-BeEEqmdE.mjs +1 -0
- package/dist/packem_shared/storageRules-BptPZbi8.mjs +1 -0
- package/dist/rls/testing.mjs +1 -49
- package/dist/types.d.mts +211 -4
- package/dist/types.d.ts +211 -4
- package/dist/types.mjs +1 -31
- package/package.json +13 -1
- package/dist/packem_shared/LunoraEnvError-BGmd1Qs0.mjs +0 -187
- package/dist/packem_shared/LunoraError-WbxmrpxR.mjs +0 -9
- package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-Cr0i4mTv.mjs +0 -114
- package/dist/packem_shared/asBucketStorage-Cnxd9y2q.mjs +0 -11
- package/dist/packem_shared/bindOrm-CaY7Wq9Z.mjs +0 -147
- package/dist/packem_shared/buildRlsReadRegistry-2uk_GfiH.mjs +0 -107
- package/dist/packem_shared/composePluginMiddleware-z62dttBo.mjs +0 -103
- package/dist/packem_shared/createPolicyDsl-By3QB4he.mjs +0 -32
- package/dist/packem_shared/createSecrets-DwaR2rNG.mjs +0 -58
- package/dist/packem_shared/defineAggregateIndex-cdo0g-un.mjs +0 -349
- package/dist/packem_shared/defineIdentity-DiX4zM9x.mjs +0 -35
- package/dist/packem_shared/defineMigration-Hx01yIht.mjs +0 -10
- package/dist/packem_shared/defineMutator-EIXAWhs9.mjs +0 -11
- package/dist/packem_shared/defineShape-C5scNOrf.mjs +0 -18
- package/dist/packem_shared/defineStorageRule-B5nL4Z1P.mjs +0 -23
- package/dist/packem_shared/functions-Di9FUNkf.mjs +0 -5
- package/dist/packem_shared/httpAction-DCXoYPIk.mjs +0 -355
- package/dist/packem_shared/initLunora-D0Wuki7S.mjs +0 -115
- package/dist/packem_shared/mask-BepaW7YN.mjs +0 -334
- package/dist/packem_shared/onConnect-CIPXKPyw.mjs +0 -13
- package/dist/packem_shared/policy-tag-DvpVH2tv.mjs +0 -13
- package/dist/packem_shared/protectPublic-BlcGpiRc.mjs +0 -15
- package/dist/packem_shared/rls-BaDQf7MG.mjs +0 -595
- package/dist/packem_shared/run-middleware-I6EiQfxL.mjs +0 -20
- package/dist/packem_shared/storageRules-6QxzDOcx.mjs +0 -88
package/LICENSE.md
CHANGED
|
@@ -108,4 +108,217 @@ specific language governing permissions and limitations under the License.
|
|
|
108
108
|
<!-- /DEPENDENCIES -->
|
|
109
109
|
|
|
110
110
|
<!-- TYPE_DEPENDENCIES -->
|
|
111
|
+
|
|
112
|
+
# Licenses of bundled types
|
|
113
|
+
The published @lunora/server artifact additionally contains code with the following licenses:
|
|
114
|
+
Apache-2.0
|
|
115
|
+
|
|
116
|
+
# Bundled types:
|
|
117
|
+
## @opentelemetry/api
|
|
118
|
+
License: Apache-2.0
|
|
119
|
+
By: OpenTelemetry Authors
|
|
120
|
+
Repository: open-telemetry/opentelemetry-js
|
|
121
|
+
|
|
122
|
+
> Apache License
|
|
123
|
+
> Version 2.0, January 2004
|
|
124
|
+
> http://www.apache.org/licenses/
|
|
125
|
+
>
|
|
126
|
+
> TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
127
|
+
>
|
|
128
|
+
> 1. Definitions.
|
|
129
|
+
>
|
|
130
|
+
> "License" shall mean the terms and conditions for use, reproduction,
|
|
131
|
+
> and distribution as defined by Sections 1 through 9 of this document.
|
|
132
|
+
>
|
|
133
|
+
> "Licensor" shall mean the copyright owner or entity authorized by
|
|
134
|
+
> the copyright owner that is granting the License.
|
|
135
|
+
>
|
|
136
|
+
> "Legal Entity" shall mean the union of the acting entity and all
|
|
137
|
+
> other entities that control, are controlled by, or are under common
|
|
138
|
+
> control with that entity. For the purposes of this definition,
|
|
139
|
+
> "control" means (i) the power, direct or indirect, to cause the
|
|
140
|
+
> direction or management of such entity, whether by contract or
|
|
141
|
+
> otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
142
|
+
> outstanding shares, or (iii) beneficial ownership of such entity.
|
|
143
|
+
>
|
|
144
|
+
> "You" (or "Your") shall mean an individual or Legal Entity
|
|
145
|
+
> exercising permissions granted by this License.
|
|
146
|
+
>
|
|
147
|
+
> "Source" form shall mean the preferred form for making modifications,
|
|
148
|
+
> including but not limited to software source code, documentation
|
|
149
|
+
> source, and configuration files.
|
|
150
|
+
>
|
|
151
|
+
> "Object" form shall mean any form resulting from mechanical
|
|
152
|
+
> transformation or translation of a Source form, including but
|
|
153
|
+
> not limited to compiled object code, generated documentation,
|
|
154
|
+
> and conversions to other media types.
|
|
155
|
+
>
|
|
156
|
+
> "Work" shall mean the work of authorship, whether in Source or
|
|
157
|
+
> Object form, made available under the License, as indicated by a
|
|
158
|
+
> copyright notice that is included in or attached to the work
|
|
159
|
+
> (an example is provided in the Appendix below).
|
|
160
|
+
>
|
|
161
|
+
> "Derivative Works" shall mean any work, whether in Source or Object
|
|
162
|
+
> form, that is based on (or derived from) the Work and for which the
|
|
163
|
+
> editorial revisions, annotations, elaborations, or other modifications
|
|
164
|
+
> represent, as a whole, an original work of authorship. For the purposes
|
|
165
|
+
> of this License, Derivative Works shall not include works that remain
|
|
166
|
+
> separable from, or merely link (or bind by name) to the interfaces of,
|
|
167
|
+
> the Work and Derivative Works thereof.
|
|
168
|
+
>
|
|
169
|
+
> "Contribution" shall mean any work of authorship, including
|
|
170
|
+
> the original version of the Work and any modifications or additions
|
|
171
|
+
> to that Work or Derivative Works thereof, that is intentionally
|
|
172
|
+
> submitted to Licensor for inclusion in the Work by the copyright owner
|
|
173
|
+
> or by an individual or Legal Entity authorized to submit on behalf of
|
|
174
|
+
> the copyright owner. For the purposes of this definition, "submitted"
|
|
175
|
+
> means any form of electronic, verbal, or written communication sent
|
|
176
|
+
> to the Licensor or its representatives, including but not limited to
|
|
177
|
+
> communication on electronic mailing lists, source code control systems,
|
|
178
|
+
> and issue tracking systems that are managed by, or on behalf of, the
|
|
179
|
+
> Licensor for the purpose of discussing and improving the Work, but
|
|
180
|
+
> excluding communication that is conspicuously marked or otherwise
|
|
181
|
+
> designated in writing by the copyright owner as "Not a Contribution."
|
|
182
|
+
>
|
|
183
|
+
> "Contributor" shall mean Licensor and any individual or Legal Entity
|
|
184
|
+
> on behalf of whom a Contribution has been received by Licensor and
|
|
185
|
+
> subsequently incorporated within the Work.
|
|
186
|
+
>
|
|
187
|
+
> 2. Grant of Copyright License. Subject to the terms and conditions of
|
|
188
|
+
> this License, each Contributor hereby grants to You a perpetual,
|
|
189
|
+
> worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
190
|
+
> copyright license to reproduce, prepare Derivative Works of,
|
|
191
|
+
> publicly display, publicly perform, sublicense, and distribute the
|
|
192
|
+
> Work and such Derivative Works in Source or Object form.
|
|
193
|
+
>
|
|
194
|
+
> 3. Grant of Patent License. Subject to the terms and conditions of
|
|
195
|
+
> this License, each Contributor hereby grants to You a perpetual,
|
|
196
|
+
> worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
197
|
+
> (except as stated in this section) patent license to make, have made,
|
|
198
|
+
> use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
199
|
+
> where such license applies only to those patent claims licensable
|
|
200
|
+
> by such Contributor that are necessarily infringed by their
|
|
201
|
+
> Contribution(s) alone or by combination of their Contribution(s)
|
|
202
|
+
> with the Work to which such Contribution(s) was submitted. If You
|
|
203
|
+
> institute patent litigation against any entity (including a
|
|
204
|
+
> cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
205
|
+
> or a Contribution incorporated within the Work constitutes direct
|
|
206
|
+
> or contributory patent infringement, then any patent licenses
|
|
207
|
+
> granted to You under this License for that Work shall terminate
|
|
208
|
+
> as of the date such litigation is filed.
|
|
209
|
+
>
|
|
210
|
+
> 4. Redistribution. You may reproduce and distribute copies of the
|
|
211
|
+
> Work or Derivative Works thereof in any medium, with or without
|
|
212
|
+
> modifications, and in Source or Object form, provided that You
|
|
213
|
+
> meet the following conditions:
|
|
214
|
+
>
|
|
215
|
+
> (a) You must give any other recipients of the Work or
|
|
216
|
+
> Derivative Works a copy of this License; and
|
|
217
|
+
>
|
|
218
|
+
> (b) You must cause any modified files to carry prominent notices
|
|
219
|
+
> stating that You changed the files; and
|
|
220
|
+
>
|
|
221
|
+
> (c) You must retain, in the Source form of any Derivative Works
|
|
222
|
+
> that You distribute, all copyright, patent, trademark, and
|
|
223
|
+
> attribution notices from the Source form of the Work,
|
|
224
|
+
> excluding those notices that do not pertain to any part of
|
|
225
|
+
> the Derivative Works; and
|
|
226
|
+
>
|
|
227
|
+
> (d) If the Work includes a "NOTICE" text file as part of its
|
|
228
|
+
> distribution, then any Derivative Works that You distribute must
|
|
229
|
+
> include a readable copy of the attribution notices contained
|
|
230
|
+
> within such NOTICE file, excluding those notices that do not
|
|
231
|
+
> pertain to any part of the Derivative Works, in at least one
|
|
232
|
+
> of the following places: within a NOTICE text file distributed
|
|
233
|
+
> as part of the Derivative Works; within the Source form or
|
|
234
|
+
> documentation, if provided along with the Derivative Works; or,
|
|
235
|
+
> within a display generated by the Derivative Works, if and
|
|
236
|
+
> wherever such third-party notices normally appear. The contents
|
|
237
|
+
> of the NOTICE file are for informational purposes only and
|
|
238
|
+
> do not modify the License. You may add Your own attribution
|
|
239
|
+
> notices within Derivative Works that You distribute, alongside
|
|
240
|
+
> or as an addendum to the NOTICE text from the Work, provided
|
|
241
|
+
> that such additional attribution notices cannot be construed
|
|
242
|
+
> as modifying the License.
|
|
243
|
+
>
|
|
244
|
+
> You may add Your own copyright statement to Your modifications and
|
|
245
|
+
> may provide additional or different license terms and conditions
|
|
246
|
+
> for use, reproduction, or distribution of Your modifications, or
|
|
247
|
+
> for any such Derivative Works as a whole, provided Your use,
|
|
248
|
+
> reproduction, and distribution of the Work otherwise complies with
|
|
249
|
+
> the conditions stated in this License.
|
|
250
|
+
>
|
|
251
|
+
> 5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
252
|
+
> any Contribution intentionally submitted for inclusion in the Work
|
|
253
|
+
> by You to the Licensor shall be under the terms and conditions of
|
|
254
|
+
> this License, without any additional terms or conditions.
|
|
255
|
+
> Notwithstanding the above, nothing herein shall supersede or modify
|
|
256
|
+
> the terms of any separate license agreement you may have executed
|
|
257
|
+
> with Licensor regarding such Contributions.
|
|
258
|
+
>
|
|
259
|
+
> 6. Trademarks. This License does not grant permission to use the trade
|
|
260
|
+
> names, trademarks, service marks, or product names of the Licensor,
|
|
261
|
+
> except as required for reasonable and customary use in describing the
|
|
262
|
+
> origin of the Work and reproducing the content of the NOTICE file.
|
|
263
|
+
>
|
|
264
|
+
> 7. Disclaimer of Warranty. Unless required by applicable law or
|
|
265
|
+
> agreed to in writing, Licensor provides the Work (and each
|
|
266
|
+
> Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
267
|
+
> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
268
|
+
> implied, including, without limitation, any warranties or conditions
|
|
269
|
+
> of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
270
|
+
> PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
271
|
+
> appropriateness of using or redistributing the Work and assume any
|
|
272
|
+
> risks associated with Your exercise of permissions under this License.
|
|
273
|
+
>
|
|
274
|
+
> 8. Limitation of Liability. In no event and under no legal theory,
|
|
275
|
+
> whether in tort (including negligence), contract, or otherwise,
|
|
276
|
+
> unless required by applicable law (such as deliberate and grossly
|
|
277
|
+
> negligent acts) or agreed to in writing, shall any Contributor be
|
|
278
|
+
> liable to You for damages, including any direct, indirect, special,
|
|
279
|
+
> incidental, or consequential damages of any character arising as a
|
|
280
|
+
> result of this License or out of the use or inability to use the
|
|
281
|
+
> Work (including but not limited to damages for loss of goodwill,
|
|
282
|
+
> work stoppage, computer failure or malfunction, or any and all
|
|
283
|
+
> other commercial damages or losses), even if such Contributor
|
|
284
|
+
> has been advised of the possibility of such damages.
|
|
285
|
+
>
|
|
286
|
+
> 9. Accepting Warranty or Additional Liability. While redistributing
|
|
287
|
+
> the Work or Derivative Works thereof, You may choose to offer,
|
|
288
|
+
> and charge a fee for, acceptance of support, warranty, indemnity,
|
|
289
|
+
> or other liability obligations and/or rights consistent with this
|
|
290
|
+
> License. However, in accepting such obligations, You may act only
|
|
291
|
+
> on Your own behalf and on Your sole responsibility, not on behalf
|
|
292
|
+
> of any other Contributor, and only if You agree to indemnify,
|
|
293
|
+
> defend, and hold each Contributor harmless for any liability
|
|
294
|
+
> incurred by, or claims asserted against, such Contributor by reason
|
|
295
|
+
> of your accepting any such warranty or additional liability.
|
|
296
|
+
>
|
|
297
|
+
> END OF TERMS AND CONDITIONS
|
|
298
|
+
>
|
|
299
|
+
> APPENDIX: How to apply the Apache License to your work.
|
|
300
|
+
>
|
|
301
|
+
> To apply the Apache License to your work, attach the following
|
|
302
|
+
> boilerplate notice, with the fields enclosed by brackets "[]"
|
|
303
|
+
> replaced with your own identifying information. (Don't include
|
|
304
|
+
> the brackets!) The text should be enclosed in the appropriate
|
|
305
|
+
> comment syntax for the file format. We also recommend that a
|
|
306
|
+
> file or class name and description of purpose be included on the
|
|
307
|
+
> same "printed page" as the copyright notice for easier
|
|
308
|
+
> identification within third-party archives.
|
|
309
|
+
>
|
|
310
|
+
> Copyright [yyyy] [name of copyright owner]
|
|
311
|
+
>
|
|
312
|
+
> Licensed under the Apache License, Version 2.0 (the "License");
|
|
313
|
+
> you may not use this file except in compliance with the License.
|
|
314
|
+
> You may obtain a copy of the License at
|
|
315
|
+
>
|
|
316
|
+
> http://www.apache.org/licenses/LICENSE-2.0
|
|
317
|
+
>
|
|
318
|
+
> Unless required by applicable law or agreed to in writing, software
|
|
319
|
+
> distributed under the License is distributed on an "AS IS" BASIS,
|
|
320
|
+
> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
321
|
+
> See the License for the specific language governing permissions and
|
|
322
|
+
> limitations under the License.
|
|
323
|
+
|
|
111
324
|
<!-- /TYPE_DEPENDENCIES -->
|
package/dist/data-model.mjs
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/dist/drizzle.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export*from"drizzle-orm/sqlite-core";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Validator, Infer, ValidatorMap, InferValidatorMap, v } from '@lunora/values';
|
|
2
2
|
export { type ColumnValidator, type GeoPoint, type Id, type Infer, ValidationError, type Validator, type ValidatorKind, v } from '@lunora/values';
|
|
3
3
|
import { ArgsValidator, InferArgs, RegisteredAction, ExposeConfig, X402ProcedureConfig, ActionCtx, MutationCtx, RegisteredMutation, QueryCtx, RegisteredQuery, RegisteredStream, FunctionKind, Secrets, LifecycleEvent, RegisteredLifecycleHook, TableDefinition, RegisteredFunction, VectorIndexDefinition, Schema, AggregateOp, DurableObjectJurisdiction, RelationDefinition, GlobalBackend, OnDeleteAction, ExternalSourceDefinition, TriggerBuilder, TriggerDefinition, VectorEmbedder, VectorMetric, AggregateIndexDefinition, RankIndexDefinition } from "./types.mjs";
|
|
4
|
-
export { type AnyApi, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type IndexDefinition, type IndexRangeBuilder, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type PaginationOptions, type PaginationResult, type RankSortKey, type ReadOnlyStorage, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type SearchFilterBuilder, type SearchIndexDefinition, type ShardMode, type SpanHandle, type Storage, type StorageMetadata, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerCtx, type TriggerDatabase, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorMatch, type VectorMatches, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, anyApi } from "./types.mjs";
|
|
4
|
+
export { type AnyApi, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type IndexDefinition, type IndexRangeBuilder, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type PaginationOptions, type PaginationResult, type RankSortKey, type ReadOnlyStorage, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type SearchFilterBuilder, type SearchIndexDefinition, type ShardMode, type SpanHandle, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerCtx, type TriggerDatabase, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorMatch, type VectorMatches, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, anyApi } from "./types.mjs";
|
|
5
5
|
import { LunoraError as LunoraError$1, LunoraErrorCode } from '@lunora/errors';
|
|
6
6
|
export type { LunoraErrorCode } from '@lunora/errors';
|
|
7
7
|
import { Context, Hono } from 'hono';
|
|
@@ -1396,6 +1396,20 @@ interface TableBuilder<Shape extends Record<string, Validator> = Record<string,
|
|
|
1396
1396
|
index: (name: string, fields: ReadonlyArray<string>, options?: {
|
|
1397
1397
|
unique?: boolean;
|
|
1398
1398
|
}) => TableBuilder<Shape>;
|
|
1399
|
+
/**
|
|
1400
|
+
* Name the column holding the owning user's id, so "only the owner sees these
|
|
1401
|
+
* rows" is declared once here rather than restated in every shape.
|
|
1402
|
+
*
|
|
1403
|
+
* A `defineShape({ table, owner: true })` over this table derives its predicate
|
|
1404
|
+
* from the field: the subscriber's verified `ctx.auth.userId` must match, and an
|
|
1405
|
+
* anonymous subscriber is denied. Pairs naturally with `.shardBy(field)` on the
|
|
1406
|
+
* same column — the shard key routes the storage, `ownedBy` states who the rows
|
|
1407
|
+
* belong to — but the two are independent and either can be used alone.
|
|
1408
|
+
*
|
|
1409
|
+
* This is a *shape* declaration, not an RLS policy: it narrows what a shape
|
|
1410
|
+
* replicates. Guarding procedure reads/writes is still `rls(...)`'s job.
|
|
1411
|
+
*/
|
|
1412
|
+
ownedBy: (field: keyof Shape & string) => TableBuilder<Shape>;
|
|
1399
1413
|
/**
|
|
1400
1414
|
* Opt this table OUT of secure-by-default RLS. Under a schema marked
|
|
1401
1415
|
* `.rls("required")`, every table is protected (the write path denies raw,
|
|
@@ -1878,6 +1892,13 @@ interface DatabaseWriterLike {
|
|
|
1878
1892
|
delete: (id: string, expectedTable?: string, options?: {
|
|
1879
1893
|
hard?: boolean;
|
|
1880
1894
|
}) => Promise<void>;
|
|
1895
|
+
/** Uncapped, chunked erase of a whole table. The RLS wrapper gates each row like a single delete. */
|
|
1896
|
+
deleteAll?: (tableName: string, options?: {
|
|
1897
|
+
chunkSize?: number;
|
|
1898
|
+
hard?: boolean;
|
|
1899
|
+
}) => Promise<{
|
|
1900
|
+
deleted: number;
|
|
1901
|
+
}>;
|
|
1881
1902
|
deleteMany: (ids: ReadonlyArray<string>, options?: {
|
|
1882
1903
|
limit?: number;
|
|
1883
1904
|
}, expectedTable?: string) => Promise<{
|
|
@@ -1965,6 +1986,18 @@ interface DatabaseWriterLike {
|
|
|
1965
1986
|
rankPage: (tableName: string, indexName: string, options?: RankPageArgs) => Promise<QueryPage>;
|
|
1966
1987
|
replace: (id: string, document: Record<string, unknown>, expectedTable?: string) => Promise<void>;
|
|
1967
1988
|
restore?: (id: string, expectedTable?: string) => Promise<void>;
|
|
1989
|
+
/**
|
|
1990
|
+
* Whole-shard erase. The RLS wrapper deliberately **fails this closed** rather
|
|
1991
|
+
* than wrapping it — see the wrapper's `wipeShard`.
|
|
1992
|
+
*/
|
|
1993
|
+
wipeShard?: (options?: {
|
|
1994
|
+
chunkSize?: number;
|
|
1995
|
+
exclude?: ReadonlyArray<string>;
|
|
1996
|
+
tables?: ReadonlyArray<string>;
|
|
1997
|
+
}) => Promise<{
|
|
1998
|
+
deleted: number;
|
|
1999
|
+
tables: Record<string, number>;
|
|
2000
|
+
}>;
|
|
1968
2001
|
}
|
|
1969
2002
|
/**
|
|
1970
2003
|
* What a procedure's `ctx.db` must structurally satisfy for the middleware
|
|
@@ -1987,6 +2020,41 @@ interface RlsContextIn {
|
|
|
1987
2020
|
db: RlsDatabase;
|
|
1988
2021
|
}
|
|
1989
2022
|
declare const rls: <Context extends RlsContextIn = RlsContextIn>(policies: ReadonlyArray<Policy<Context>>, options?: RlsOptions) => Middleware<Context, Context>;
|
|
2023
|
+
/**
|
|
2024
|
+
* A predicate matching **no** rows — the deny decision.
|
|
2025
|
+
*
|
|
2026
|
+
* `{ OR: [] }` is a disjunction over zero branches, which the where-compiler
|
|
2027
|
+
* folds to a constant false. Use it (never a bare `{}`) for the unauthorized
|
|
2028
|
+
* branch of a shape or policy predicate:
|
|
2029
|
+
*
|
|
2030
|
+
* ```ts
|
|
2031
|
+
* where: (ctx, { userId }) => (ctx.auth.userId === userId ? { userId } : deny())
|
|
2032
|
+
* ```
|
|
2033
|
+
*
|
|
2034
|
+
* A fresh object per call, so a caller can safely spread or extend the result.
|
|
2035
|
+
*/
|
|
2036
|
+
declare const deny: () => WhereInput;
|
|
2037
|
+
/**
|
|
2038
|
+
* A predicate matching **every** row — no restriction beyond whatever it is
|
|
2039
|
+
* AND-composed with. The honest spelling of "this branch adds no filter", where a
|
|
2040
|
+
* bare `{}` reads like an oversight.
|
|
2041
|
+
*/
|
|
2042
|
+
declare const allowAll: () => WhereInput;
|
|
2043
|
+
/**
|
|
2044
|
+
* `true` when `where` is the vacuously-false deny predicate — i.e. an `OR` over
|
|
2045
|
+
* zero branches, carrying no other constraint. Used by the runtime to short-circuit
|
|
2046
|
+
* a denied read instead of compiling and running SQL that provably matches nothing.
|
|
2047
|
+
*/
|
|
2048
|
+
declare const isDeny: (where: WhereInput) => boolean;
|
|
2049
|
+
/**
|
|
2050
|
+
* Normalize a boolean-or-predicate decision to a {@link WhereInput}.
|
|
2051
|
+
*
|
|
2052
|
+
* The authoring surfaces accept `true`/`false` as sugar — they read far better
|
|
2053
|
+
* than the sentinel objects in an ownership check — and every consumer downstream
|
|
2054
|
+
* wants a plain predicate. `undefined` means "no opinion" and maps to
|
|
2055
|
+
* {@link allowAll}, matching the RLS `PolicyDecision` contract.
|
|
2056
|
+
*/
|
|
2057
|
+
declare const toWhereInput: (decision: WhereInput | boolean | undefined) => WhereInput;
|
|
1990
2058
|
/**
|
|
1991
2059
|
* One `rls()` tag's read policies for a table, paired with the role→permission
|
|
1992
2060
|
* grants of that SAME middleware. Keeping the role map per-group is what lets a
|
|
@@ -2059,6 +2127,24 @@ interface ShapeDefinition<Args extends ValidatorMap = ValidatorMap, Context = Qu
|
|
|
2059
2127
|
* intent.
|
|
2060
2128
|
*/
|
|
2061
2129
|
readonly columns?: ReadonlyArray<string>;
|
|
2130
|
+
/**
|
|
2131
|
+
* Restrict this shape to rows the **subscriber owns**, without writing the
|
|
2132
|
+
* predicate by hand.
|
|
2133
|
+
*
|
|
2134
|
+
* `true` uses the owning column declared by `.ownedBy(field)` on the table;
|
|
2135
|
+
* `"field"` names the owning column here instead (for a table that has no
|
|
2136
|
+
* `.ownedBy()`, or a shape that scopes by a different column).
|
|
2137
|
+
*
|
|
2138
|
+
* The derived predicate is `{ [field]: ctx.auth.userId }`, AND-composed with
|
|
2139
|
+
* the shape's own `where` when both are present, and an anonymous subscriber is denied
|
|
2140
|
+
* outright. Because the value comes from the socket's verified identity rather
|
|
2141
|
+
* than from `args`, a client cannot ask for another user's partition at all —
|
|
2142
|
+
* strictly safer than accepting a `userId` arg and comparing it.
|
|
2143
|
+
*
|
|
2144
|
+
* This is the primitive for the "every shape repeats the same ownership check"
|
|
2145
|
+
* pattern: with it, an owner-scoped shape needs no `where` at all.
|
|
2146
|
+
*/
|
|
2147
|
+
readonly owner?: string | true;
|
|
2062
2148
|
/** Logical table this shape replicates a partition of. */
|
|
2063
2149
|
readonly table: string;
|
|
2064
2150
|
/**
|
|
@@ -2067,21 +2153,32 @@ interface ShapeDefinition<Args extends ValidatorMap = ValidatorMap, Context = Qu
|
|
|
2067
2153
|
* `ctx` (identity/auth the client can't forge) and the validated client
|
|
2068
2154
|
* `args`; returns a {@link WhereInput} using the same operator set as the
|
|
2069
2155
|
* SQL compiler (`eq`/`in`/`lt`/… + `AND`/`OR`/`NOT`).
|
|
2156
|
+
*
|
|
2157
|
+
* `true`/`false` are accepted as sugar for "no further restriction" / "deny" —
|
|
2158
|
+
* `false` compiles to the vacuously-false predicate, so a denial branch can
|
|
2159
|
+
* never be mistyped as the everything-matches `{}`. Optional when `owner` is
|
|
2160
|
+
* set; otherwise required.
|
|
2070
2161
|
*/
|
|
2071
|
-
readonly where
|
|
2162
|
+
readonly where?: (context: Context, args: InferValidatorMap<Args>) => WhereInput | boolean;
|
|
2072
2163
|
}
|
|
2073
2164
|
/** A {@link ShapeDefinition} plus the codegen discovery marker and a dispatch-shaped `compileWhere`. */
|
|
2074
2165
|
interface RegisteredShape<Args extends ValidatorMap = ValidatorMap, Context = QueryCtx> extends ShapeDefinition<Args, Context> {
|
|
2075
2166
|
readonly __lunoraShape: true;
|
|
2076
2167
|
/**
|
|
2077
|
-
* Validate `rawArgs`, then evaluate
|
|
2078
|
-
* return its {@link WhereInput}. Used by the generated DO's
|
|
2079
|
-
* override: `ctx` is erased to `unknown` at this dispatch
|
|
2080
|
-
* builds it from the socket's verified identity and hands it
|
|
2081
|
-
* concrete {@link QueryContext} the predicate expects), exactly like
|
|
2168
|
+
* Validate `rawArgs`, then evaluate the shape's predicate under the trusted
|
|
2169
|
+
* `ctx` and return its {@link WhereInput}. Used by the generated DO's
|
|
2170
|
+
* `resolveShape` override: `ctx` is erased to `unknown` at this dispatch
|
|
2171
|
+
* boundary (the DO builds it from the socket's verified identity and hands it
|
|
2172
|
+
* back as the concrete {@link QueryContext} the predicate expects), exactly like
|
|
2082
2173
|
* `RegisteredLunoraFunction.handler` erases its context.
|
|
2174
|
+
*
|
|
2175
|
+
* `options.ownerField` carries the table's `.ownedBy(field)` column, which only
|
|
2176
|
+
* the caller (the DO, holding the schema) can look up — it is what resolves an
|
|
2177
|
+
* `owner: true` shape. Omitted for an `owner: "field"` or plain `where` shape.
|
|
2083
2178
|
*/
|
|
2084
|
-
readonly compileWhere: (context: unknown, rawArgs: Record<string, unknown
|
|
2179
|
+
readonly compileWhere: (context: unknown, rawArgs: Record<string, unknown>, options?: {
|
|
2180
|
+
ownerField?: string;
|
|
2181
|
+
}) => WhereInput;
|
|
2085
2182
|
}
|
|
2086
2183
|
/** Declare a replication shape. See the module docs for runtime semantics. */
|
|
2087
2184
|
declare const defineShape: <Args extends ValidatorMap = ValidatorMap, Context = QueryCtx>(definition: ShapeDefinition<Args, Context>) => RegisteredShape<Args, Context>;
|
|
@@ -2168,4 +2265,4 @@ interface StorageContextIn {
|
|
|
2168
2265
|
}
|
|
2169
2266
|
declare const storageRules: <Context extends StorageContextIn = StorageContextIn>(rules: ReadonlyArray<StorageRule<Context>>, options?: StorageRulesOptions) => Middleware<Context, Context>;
|
|
2170
2267
|
declare const VERSION = "0.0.0";
|
|
2171
|
-
export { type ActionBuilder, type ActionCtx, type AggregateIndexDefinition, type AggregateIndexOptions, type AggregateOp, type ArgsValidator, type Component, type ComponentFunctions, type CreateOptions, type DataModelInit, type DefineComponentOptions, type DefineIdentityOptions, type DefinePluginOptions, type DefinePolicyInput, type DefinePresenceOptions, type DefineStorageRuleInput, type DurableObjectJurisdiction, type EmptyArgs, type EnvAccessor, type EnvKeyFailure, type EnvShape, type ExposeConfig, type ExtendableSchema, type FacadeEntry, type FacadeWriterLike, type FunctionKind, type HttpActionCtx, type HttpActionHandler, type HttpMethod, type HttpRoute, type HttpRouteBuilder, type HttpRouteFactory, type HttpRouteHandlerOptions, type HttpStreamHandlerOptions, type IdentityContract, type IdentityRejectMode, type IdentityValidation, type InferArgs, type InferEnv, type InferIdentity, type InlineAggregateIndexOptions, type InlineRankIndexOptions, type InternalActionBuilder, type InternalMutationBuilder, type InternalQueryBuilder, type LifecycleEvent, type LifecycleHandler, type LunoraBuilders, LunoraEnvError, LunoraError, type LunoraHttpApp, type LunoraHttpEnv, type LunoraRouteHandler, type ManyRelation, type MaskColumns, type MaskContext, type MaskFn, type MaskOptions, type MaskPolicies, type MaskStrategy, type Middleware, type MiddlewareNext, type MigrationDefinition, type MigrationDocument, type MigrationTransform, type MutationBuilder, type MutationCtx, type MutatorDefinition, type OnDeleteAction, type OneRelation, type OrmLike, DEFAULT_TTL_MS as PRESENCE_DEFAULT_TTL_MS, PRESENCE_TABLE, type Permission, type Plugin, type Policy, type PrefixedTables, type PresenceComponent, type PresenceFunctions, type PresenceMember, type ProtectPublicOptions, type QueryBuilder, type QueryCtx, type RankIndexDefinition, type RankIndexOptions, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMigration, type RegisteredMutation, type RegisteredMutator, type RegisteredQuery, type RegisteredShape, type RegisteredStream, type RelationBuilder, type RelationDefinition, type RlsOptions, type RlsReadRegistry, type Role, type Schema, type SchemaExtension, type ShapeDefinition, type ShapeReadWhereRequest, type StorageOperation, type StorageRule, type StorageRuleContext, type StorageRuleDecision, type StorageRulesOptions, type TableBuilder, type TableDefinition, type TerminalKind, type TriggerBuilder, type TriggerDefinition, type TypedDefinePolicyInput, VERSION, type VectorEmbedder, type VectorIndexDefinition, type VectorIndexOptions, type VectorMetric, type VectorizeOptions, type WhereInput, asBucketStorage, bindOrm, bindTableFacade, buildRlsReadRegistry, composePluginMiddleware, composeShapeReadWhere, createPolicyDsl, createSecrets, defineAggregateIndex, defineComponent, defineEnv, defineIdentity, defineMigration, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, httpAction, httpRoute, httpRouter, initLunora, installPlugins, isSafeHeaderValue, mask, mergeSchemaExtension, onConnect, onDisconnect, presenceExtension, protectPublic, redactSecrets, rls, serveStorageObject, storageRules };
|
|
2268
|
+
export { type ActionBuilder, type ActionCtx, type AggregateIndexDefinition, type AggregateIndexOptions, type AggregateOp, type ArgsValidator, type Component, type ComponentFunctions, type CreateOptions, type DataModelInit, type DefineComponentOptions, type DefineIdentityOptions, type DefinePluginOptions, type DefinePolicyInput, type DefinePresenceOptions, type DefineStorageRuleInput, type DurableObjectJurisdiction, type EmptyArgs, type EnvAccessor, type EnvKeyFailure, type EnvShape, type ExposeConfig, type ExtendableSchema, type FacadeEntry, type FacadeWriterLike, type FunctionKind, type HttpActionCtx, type HttpActionHandler, type HttpMethod, type HttpRoute, type HttpRouteBuilder, type HttpRouteFactory, type HttpRouteHandlerOptions, type HttpStreamHandlerOptions, type IdentityContract, type IdentityRejectMode, type IdentityValidation, type InferArgs, type InferEnv, type InferIdentity, type InlineAggregateIndexOptions, type InlineRankIndexOptions, type InternalActionBuilder, type InternalMutationBuilder, type InternalQueryBuilder, type LifecycleEvent, type LifecycleHandler, type LunoraBuilders, LunoraEnvError, LunoraError, type LunoraHttpApp, type LunoraHttpEnv, type LunoraRouteHandler, type ManyRelation, type MaskColumns, type MaskContext, type MaskFn, type MaskOptions, type MaskPolicies, type MaskStrategy, type Middleware, type MiddlewareNext, type MigrationDefinition, type MigrationDocument, type MigrationTransform, type MutationBuilder, type MutationCtx, type MutatorDefinition, type OnDeleteAction, type OneRelation, type OrmLike, DEFAULT_TTL_MS as PRESENCE_DEFAULT_TTL_MS, PRESENCE_TABLE, type Permission, type Plugin, type Policy, type PrefixedTables, type PresenceComponent, type PresenceFunctions, type PresenceMember, type ProtectPublicOptions, type QueryBuilder, type QueryCtx, type RankIndexDefinition, type RankIndexOptions, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMigration, type RegisteredMutation, type RegisteredMutator, type RegisteredQuery, type RegisteredShape, type RegisteredStream, type RelationBuilder, type RelationDefinition, type RlsOptions, type RlsReadRegistry, type Role, type Schema, type SchemaExtension, type ShapeDefinition, type ShapeReadWhereRequest, type StorageOperation, type StorageRule, type StorageRuleContext, type StorageRuleDecision, type StorageRulesOptions, type TableBuilder, type TableDefinition, type TerminalKind, type TriggerBuilder, type TriggerDefinition, type TypedDefinePolicyInput, VERSION, type VectorEmbedder, type VectorIndexDefinition, type VectorIndexOptions, type VectorMetric, type VectorizeOptions, type WhereInput, allowAll, asBucketStorage, bindOrm, bindTableFacade, buildRlsReadRegistry, composePluginMiddleware, composeShapeReadWhere, createPolicyDsl, createSecrets, defineAggregateIndex, defineComponent, defineEnv, defineIdentity, defineMigration, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, deny, httpAction, httpRoute, httpRouter, initLunora, installPlugins, isDeny, isSafeHeaderValue, mask, mergeSchemaExtension, onConnect, onDisconnect, presenceExtension, protectPublic, redactSecrets, rls, serveStorageObject, storageRules, toWhereInput };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Validator, Infer, ValidatorMap, InferValidatorMap, v } from '@lunora/values';
|
|
2
2
|
export { type ColumnValidator, type GeoPoint, type Id, type Infer, ValidationError, type Validator, type ValidatorKind, v } from '@lunora/values';
|
|
3
3
|
import { ArgsValidator, InferArgs, RegisteredAction, ExposeConfig, X402ProcedureConfig, ActionCtx, MutationCtx, RegisteredMutation, QueryCtx, RegisteredQuery, RegisteredStream, FunctionKind, Secrets, LifecycleEvent, RegisteredLifecycleHook, TableDefinition, RegisteredFunction, VectorIndexDefinition, Schema, AggregateOp, DurableObjectJurisdiction, RelationDefinition, GlobalBackend, OnDeleteAction, ExternalSourceDefinition, TriggerBuilder, TriggerDefinition, VectorEmbedder, VectorMetric, AggregateIndexDefinition, RankIndexDefinition } from "./types.js";
|
|
4
|
-
export { type AnyApi, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type IndexDefinition, type IndexRangeBuilder, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type PaginationOptions, type PaginationResult, type RankSortKey, type ReadOnlyStorage, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type SearchFilterBuilder, type SearchIndexDefinition, type ShardMode, type SpanHandle, type Storage, type StorageMetadata, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerCtx, type TriggerDatabase, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorMatch, type VectorMatches, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, anyApi } from "./types.js";
|
|
4
|
+
export { type AnyApi, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type IndexDefinition, type IndexRangeBuilder, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type PaginationOptions, type PaginationResult, type RankSortKey, type ReadOnlyStorage, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type SearchFilterBuilder, type SearchIndexDefinition, type ShardMode, type SpanHandle, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerCtx, type TriggerDatabase, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorMatch, type VectorMatches, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, anyApi } from "./types.js";
|
|
5
5
|
import { LunoraError as LunoraError$1, LunoraErrorCode } from '@lunora/errors';
|
|
6
6
|
export type { LunoraErrorCode } from '@lunora/errors';
|
|
7
7
|
import { Context, Hono } from 'hono';
|
|
@@ -1396,6 +1396,20 @@ interface TableBuilder<Shape extends Record<string, Validator> = Record<string,
|
|
|
1396
1396
|
index: (name: string, fields: ReadonlyArray<string>, options?: {
|
|
1397
1397
|
unique?: boolean;
|
|
1398
1398
|
}) => TableBuilder<Shape>;
|
|
1399
|
+
/**
|
|
1400
|
+
* Name the column holding the owning user's id, so "only the owner sees these
|
|
1401
|
+
* rows" is declared once here rather than restated in every shape.
|
|
1402
|
+
*
|
|
1403
|
+
* A `defineShape({ table, owner: true })` over this table derives its predicate
|
|
1404
|
+
* from the field: the subscriber's verified `ctx.auth.userId` must match, and an
|
|
1405
|
+
* anonymous subscriber is denied. Pairs naturally with `.shardBy(field)` on the
|
|
1406
|
+
* same column — the shard key routes the storage, `ownedBy` states who the rows
|
|
1407
|
+
* belong to — but the two are independent and either can be used alone.
|
|
1408
|
+
*
|
|
1409
|
+
* This is a *shape* declaration, not an RLS policy: it narrows what a shape
|
|
1410
|
+
* replicates. Guarding procedure reads/writes is still `rls(...)`'s job.
|
|
1411
|
+
*/
|
|
1412
|
+
ownedBy: (field: keyof Shape & string) => TableBuilder<Shape>;
|
|
1399
1413
|
/**
|
|
1400
1414
|
* Opt this table OUT of secure-by-default RLS. Under a schema marked
|
|
1401
1415
|
* `.rls("required")`, every table is protected (the write path denies raw,
|
|
@@ -1878,6 +1892,13 @@ interface DatabaseWriterLike {
|
|
|
1878
1892
|
delete: (id: string, expectedTable?: string, options?: {
|
|
1879
1893
|
hard?: boolean;
|
|
1880
1894
|
}) => Promise<void>;
|
|
1895
|
+
/** Uncapped, chunked erase of a whole table. The RLS wrapper gates each row like a single delete. */
|
|
1896
|
+
deleteAll?: (tableName: string, options?: {
|
|
1897
|
+
chunkSize?: number;
|
|
1898
|
+
hard?: boolean;
|
|
1899
|
+
}) => Promise<{
|
|
1900
|
+
deleted: number;
|
|
1901
|
+
}>;
|
|
1881
1902
|
deleteMany: (ids: ReadonlyArray<string>, options?: {
|
|
1882
1903
|
limit?: number;
|
|
1883
1904
|
}, expectedTable?: string) => Promise<{
|
|
@@ -1965,6 +1986,18 @@ interface DatabaseWriterLike {
|
|
|
1965
1986
|
rankPage: (tableName: string, indexName: string, options?: RankPageArgs) => Promise<QueryPage>;
|
|
1966
1987
|
replace: (id: string, document: Record<string, unknown>, expectedTable?: string) => Promise<void>;
|
|
1967
1988
|
restore?: (id: string, expectedTable?: string) => Promise<void>;
|
|
1989
|
+
/**
|
|
1990
|
+
* Whole-shard erase. The RLS wrapper deliberately **fails this closed** rather
|
|
1991
|
+
* than wrapping it — see the wrapper's `wipeShard`.
|
|
1992
|
+
*/
|
|
1993
|
+
wipeShard?: (options?: {
|
|
1994
|
+
chunkSize?: number;
|
|
1995
|
+
exclude?: ReadonlyArray<string>;
|
|
1996
|
+
tables?: ReadonlyArray<string>;
|
|
1997
|
+
}) => Promise<{
|
|
1998
|
+
deleted: number;
|
|
1999
|
+
tables: Record<string, number>;
|
|
2000
|
+
}>;
|
|
1968
2001
|
}
|
|
1969
2002
|
/**
|
|
1970
2003
|
* What a procedure's `ctx.db` must structurally satisfy for the middleware
|
|
@@ -1987,6 +2020,41 @@ interface RlsContextIn {
|
|
|
1987
2020
|
db: RlsDatabase;
|
|
1988
2021
|
}
|
|
1989
2022
|
declare const rls: <Context extends RlsContextIn = RlsContextIn>(policies: ReadonlyArray<Policy<Context>>, options?: RlsOptions) => Middleware<Context, Context>;
|
|
2023
|
+
/**
|
|
2024
|
+
* A predicate matching **no** rows — the deny decision.
|
|
2025
|
+
*
|
|
2026
|
+
* `{ OR: [] }` is a disjunction over zero branches, which the where-compiler
|
|
2027
|
+
* folds to a constant false. Use it (never a bare `{}`) for the unauthorized
|
|
2028
|
+
* branch of a shape or policy predicate:
|
|
2029
|
+
*
|
|
2030
|
+
* ```ts
|
|
2031
|
+
* where: (ctx, { userId }) => (ctx.auth.userId === userId ? { userId } : deny())
|
|
2032
|
+
* ```
|
|
2033
|
+
*
|
|
2034
|
+
* A fresh object per call, so a caller can safely spread or extend the result.
|
|
2035
|
+
*/
|
|
2036
|
+
declare const deny: () => WhereInput;
|
|
2037
|
+
/**
|
|
2038
|
+
* A predicate matching **every** row — no restriction beyond whatever it is
|
|
2039
|
+
* AND-composed with. The honest spelling of "this branch adds no filter", where a
|
|
2040
|
+
* bare `{}` reads like an oversight.
|
|
2041
|
+
*/
|
|
2042
|
+
declare const allowAll: () => WhereInput;
|
|
2043
|
+
/**
|
|
2044
|
+
* `true` when `where` is the vacuously-false deny predicate — i.e. an `OR` over
|
|
2045
|
+
* zero branches, carrying no other constraint. Used by the runtime to short-circuit
|
|
2046
|
+
* a denied read instead of compiling and running SQL that provably matches nothing.
|
|
2047
|
+
*/
|
|
2048
|
+
declare const isDeny: (where: WhereInput) => boolean;
|
|
2049
|
+
/**
|
|
2050
|
+
* Normalize a boolean-or-predicate decision to a {@link WhereInput}.
|
|
2051
|
+
*
|
|
2052
|
+
* The authoring surfaces accept `true`/`false` as sugar — they read far better
|
|
2053
|
+
* than the sentinel objects in an ownership check — and every consumer downstream
|
|
2054
|
+
* wants a plain predicate. `undefined` means "no opinion" and maps to
|
|
2055
|
+
* {@link allowAll}, matching the RLS `PolicyDecision` contract.
|
|
2056
|
+
*/
|
|
2057
|
+
declare const toWhereInput: (decision: WhereInput | boolean | undefined) => WhereInput;
|
|
1990
2058
|
/**
|
|
1991
2059
|
* One `rls()` tag's read policies for a table, paired with the role→permission
|
|
1992
2060
|
* grants of that SAME middleware. Keeping the role map per-group is what lets a
|
|
@@ -2059,6 +2127,24 @@ interface ShapeDefinition<Args extends ValidatorMap = ValidatorMap, Context = Qu
|
|
|
2059
2127
|
* intent.
|
|
2060
2128
|
*/
|
|
2061
2129
|
readonly columns?: ReadonlyArray<string>;
|
|
2130
|
+
/**
|
|
2131
|
+
* Restrict this shape to rows the **subscriber owns**, without writing the
|
|
2132
|
+
* predicate by hand.
|
|
2133
|
+
*
|
|
2134
|
+
* `true` uses the owning column declared by `.ownedBy(field)` on the table;
|
|
2135
|
+
* `"field"` names the owning column here instead (for a table that has no
|
|
2136
|
+
* `.ownedBy()`, or a shape that scopes by a different column).
|
|
2137
|
+
*
|
|
2138
|
+
* The derived predicate is `{ [field]: ctx.auth.userId }`, AND-composed with
|
|
2139
|
+
* the shape's own `where` when both are present, and an anonymous subscriber is denied
|
|
2140
|
+
* outright. Because the value comes from the socket's verified identity rather
|
|
2141
|
+
* than from `args`, a client cannot ask for another user's partition at all —
|
|
2142
|
+
* strictly safer than accepting a `userId` arg and comparing it.
|
|
2143
|
+
*
|
|
2144
|
+
* This is the primitive for the "every shape repeats the same ownership check"
|
|
2145
|
+
* pattern: with it, an owner-scoped shape needs no `where` at all.
|
|
2146
|
+
*/
|
|
2147
|
+
readonly owner?: string | true;
|
|
2062
2148
|
/** Logical table this shape replicates a partition of. */
|
|
2063
2149
|
readonly table: string;
|
|
2064
2150
|
/**
|
|
@@ -2067,21 +2153,32 @@ interface ShapeDefinition<Args extends ValidatorMap = ValidatorMap, Context = Qu
|
|
|
2067
2153
|
* `ctx` (identity/auth the client can't forge) and the validated client
|
|
2068
2154
|
* `args`; returns a {@link WhereInput} using the same operator set as the
|
|
2069
2155
|
* SQL compiler (`eq`/`in`/`lt`/… + `AND`/`OR`/`NOT`).
|
|
2156
|
+
*
|
|
2157
|
+
* `true`/`false` are accepted as sugar for "no further restriction" / "deny" —
|
|
2158
|
+
* `false` compiles to the vacuously-false predicate, so a denial branch can
|
|
2159
|
+
* never be mistyped as the everything-matches `{}`. Optional when `owner` is
|
|
2160
|
+
* set; otherwise required.
|
|
2070
2161
|
*/
|
|
2071
|
-
readonly where
|
|
2162
|
+
readonly where?: (context: Context, args: InferValidatorMap<Args>) => WhereInput | boolean;
|
|
2072
2163
|
}
|
|
2073
2164
|
/** A {@link ShapeDefinition} plus the codegen discovery marker and a dispatch-shaped `compileWhere`. */
|
|
2074
2165
|
interface RegisteredShape<Args extends ValidatorMap = ValidatorMap, Context = QueryCtx> extends ShapeDefinition<Args, Context> {
|
|
2075
2166
|
readonly __lunoraShape: true;
|
|
2076
2167
|
/**
|
|
2077
|
-
* Validate `rawArgs`, then evaluate
|
|
2078
|
-
* return its {@link WhereInput}. Used by the generated DO's
|
|
2079
|
-
* override: `ctx` is erased to `unknown` at this dispatch
|
|
2080
|
-
* builds it from the socket's verified identity and hands it
|
|
2081
|
-
* concrete {@link QueryContext} the predicate expects), exactly like
|
|
2168
|
+
* Validate `rawArgs`, then evaluate the shape's predicate under the trusted
|
|
2169
|
+
* `ctx` and return its {@link WhereInput}. Used by the generated DO's
|
|
2170
|
+
* `resolveShape` override: `ctx` is erased to `unknown` at this dispatch
|
|
2171
|
+
* boundary (the DO builds it from the socket's verified identity and hands it
|
|
2172
|
+
* back as the concrete {@link QueryContext} the predicate expects), exactly like
|
|
2082
2173
|
* `RegisteredLunoraFunction.handler` erases its context.
|
|
2174
|
+
*
|
|
2175
|
+
* `options.ownerField` carries the table's `.ownedBy(field)` column, which only
|
|
2176
|
+
* the caller (the DO, holding the schema) can look up — it is what resolves an
|
|
2177
|
+
* `owner: true` shape. Omitted for an `owner: "field"` or plain `where` shape.
|
|
2083
2178
|
*/
|
|
2084
|
-
readonly compileWhere: (context: unknown, rawArgs: Record<string, unknown
|
|
2179
|
+
readonly compileWhere: (context: unknown, rawArgs: Record<string, unknown>, options?: {
|
|
2180
|
+
ownerField?: string;
|
|
2181
|
+
}) => WhereInput;
|
|
2085
2182
|
}
|
|
2086
2183
|
/** Declare a replication shape. See the module docs for runtime semantics. */
|
|
2087
2184
|
declare const defineShape: <Args extends ValidatorMap = ValidatorMap, Context = QueryCtx>(definition: ShapeDefinition<Args, Context>) => RegisteredShape<Args, Context>;
|
|
@@ -2168,4 +2265,4 @@ interface StorageContextIn {
|
|
|
2168
2265
|
}
|
|
2169
2266
|
declare const storageRules: <Context extends StorageContextIn = StorageContextIn>(rules: ReadonlyArray<StorageRule<Context>>, options?: StorageRulesOptions) => Middleware<Context, Context>;
|
|
2170
2267
|
declare const VERSION = "0.0.0";
|
|
2171
|
-
export { type ActionBuilder, type ActionCtx, type AggregateIndexDefinition, type AggregateIndexOptions, type AggregateOp, type ArgsValidator, type Component, type ComponentFunctions, type CreateOptions, type DataModelInit, type DefineComponentOptions, type DefineIdentityOptions, type DefinePluginOptions, type DefinePolicyInput, type DefinePresenceOptions, type DefineStorageRuleInput, type DurableObjectJurisdiction, type EmptyArgs, type EnvAccessor, type EnvKeyFailure, type EnvShape, type ExposeConfig, type ExtendableSchema, type FacadeEntry, type FacadeWriterLike, type FunctionKind, type HttpActionCtx, type HttpActionHandler, type HttpMethod, type HttpRoute, type HttpRouteBuilder, type HttpRouteFactory, type HttpRouteHandlerOptions, type HttpStreamHandlerOptions, type IdentityContract, type IdentityRejectMode, type IdentityValidation, type InferArgs, type InferEnv, type InferIdentity, type InlineAggregateIndexOptions, type InlineRankIndexOptions, type InternalActionBuilder, type InternalMutationBuilder, type InternalQueryBuilder, type LifecycleEvent, type LifecycleHandler, type LunoraBuilders, LunoraEnvError, LunoraError, type LunoraHttpApp, type LunoraHttpEnv, type LunoraRouteHandler, type ManyRelation, type MaskColumns, type MaskContext, type MaskFn, type MaskOptions, type MaskPolicies, type MaskStrategy, type Middleware, type MiddlewareNext, type MigrationDefinition, type MigrationDocument, type MigrationTransform, type MutationBuilder, type MutationCtx, type MutatorDefinition, type OnDeleteAction, type OneRelation, type OrmLike, DEFAULT_TTL_MS as PRESENCE_DEFAULT_TTL_MS, PRESENCE_TABLE, type Permission, type Plugin, type Policy, type PrefixedTables, type PresenceComponent, type PresenceFunctions, type PresenceMember, type ProtectPublicOptions, type QueryBuilder, type QueryCtx, type RankIndexDefinition, type RankIndexOptions, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMigration, type RegisteredMutation, type RegisteredMutator, type RegisteredQuery, type RegisteredShape, type RegisteredStream, type RelationBuilder, type RelationDefinition, type RlsOptions, type RlsReadRegistry, type Role, type Schema, type SchemaExtension, type ShapeDefinition, type ShapeReadWhereRequest, type StorageOperation, type StorageRule, type StorageRuleContext, type StorageRuleDecision, type StorageRulesOptions, type TableBuilder, type TableDefinition, type TerminalKind, type TriggerBuilder, type TriggerDefinition, type TypedDefinePolicyInput, VERSION, type VectorEmbedder, type VectorIndexDefinition, type VectorIndexOptions, type VectorMetric, type VectorizeOptions, type WhereInput, asBucketStorage, bindOrm, bindTableFacade, buildRlsReadRegistry, composePluginMiddleware, composeShapeReadWhere, createPolicyDsl, createSecrets, defineAggregateIndex, defineComponent, defineEnv, defineIdentity, defineMigration, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, httpAction, httpRoute, httpRouter, initLunora, installPlugins, isSafeHeaderValue, mask, mergeSchemaExtension, onConnect, onDisconnect, presenceExtension, protectPublic, redactSecrets, rls, serveStorageObject, storageRules };
|
|
2268
|
+
export { type ActionBuilder, type ActionCtx, type AggregateIndexDefinition, type AggregateIndexOptions, type AggregateOp, type ArgsValidator, type Component, type ComponentFunctions, type CreateOptions, type DataModelInit, type DefineComponentOptions, type DefineIdentityOptions, type DefinePluginOptions, type DefinePolicyInput, type DefinePresenceOptions, type DefineStorageRuleInput, type DurableObjectJurisdiction, type EmptyArgs, type EnvAccessor, type EnvKeyFailure, type EnvShape, type ExposeConfig, type ExtendableSchema, type FacadeEntry, type FacadeWriterLike, type FunctionKind, type HttpActionCtx, type HttpActionHandler, type HttpMethod, type HttpRoute, type HttpRouteBuilder, type HttpRouteFactory, type HttpRouteHandlerOptions, type HttpStreamHandlerOptions, type IdentityContract, type IdentityRejectMode, type IdentityValidation, type InferArgs, type InferEnv, type InferIdentity, type InlineAggregateIndexOptions, type InlineRankIndexOptions, type InternalActionBuilder, type InternalMutationBuilder, type InternalQueryBuilder, type LifecycleEvent, type LifecycleHandler, type LunoraBuilders, LunoraEnvError, LunoraError, type LunoraHttpApp, type LunoraHttpEnv, type LunoraRouteHandler, type ManyRelation, type MaskColumns, type MaskContext, type MaskFn, type MaskOptions, type MaskPolicies, type MaskStrategy, type Middleware, type MiddlewareNext, type MigrationDefinition, type MigrationDocument, type MigrationTransform, type MutationBuilder, type MutationCtx, type MutatorDefinition, type OnDeleteAction, type OneRelation, type OrmLike, DEFAULT_TTL_MS as PRESENCE_DEFAULT_TTL_MS, PRESENCE_TABLE, type Permission, type Plugin, type Policy, type PrefixedTables, type PresenceComponent, type PresenceFunctions, type PresenceMember, type ProtectPublicOptions, type QueryBuilder, type QueryCtx, type RankIndexDefinition, type RankIndexOptions, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMigration, type RegisteredMutation, type RegisteredMutator, type RegisteredQuery, type RegisteredShape, type RegisteredStream, type RelationBuilder, type RelationDefinition, type RlsOptions, type RlsReadRegistry, type Role, type Schema, type SchemaExtension, type ShapeDefinition, type ShapeReadWhereRequest, type StorageOperation, type StorageRule, type StorageRuleContext, type StorageRuleDecision, type StorageRulesOptions, type TableBuilder, type TableDefinition, type TerminalKind, type TriggerBuilder, type TriggerDefinition, type TypedDefinePolicyInput, VERSION, type VectorEmbedder, type VectorIndexDefinition, type VectorIndexOptions, type VectorMetric, type VectorizeOptions, type WhereInput, allowAll, asBucketStorage, bindOrm, bindTableFacade, buildRlsReadRegistry, composePluginMiddleware, composeShapeReadWhere, createPolicyDsl, createSecrets, defineAggregateIndex, defineComponent, defineEnv, defineIdentity, defineMigration, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, deny, httpAction, httpRoute, httpRouter, initLunora, installPlugins, isDeny, isSafeHeaderValue, mask, mergeSchemaExtension, onConnect, onDisconnect, presenceExtension, protectPublic, redactSecrets, rls, serveStorageObject, storageRules, toWhereInput };
|