@lunora/server 1.0.0-alpha.9 → 1.0.0-alpha.90

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 (86) hide show
  1. package/LICENSE.md +219 -0
  2. package/README.md +46 -0
  3. package/dist/data-model.d.mts +260 -164
  4. package/dist/data-model.d.ts +260 -164
  5. package/dist/data-model.mjs +0 -1
  6. package/dist/drizzle.mjs +1 -1
  7. package/dist/index.d.mts +2675 -1562
  8. package/dist/index.d.ts +2675 -1562
  9. package/dist/index.mjs +1 -28
  10. package/dist/otel.d.mts +543 -0
  11. package/dist/otel.d.ts +543 -0
  12. package/dist/otel.mjs +1 -0
  13. package/dist/packem_shared/ACTION_CACHE_DEFAULT_TTL_MS-DRJUQGut.mjs +1 -0
  14. package/dist/packem_shared/DEFAULT_LIMIT-DC-M6faS.mjs +1 -0
  15. package/dist/packem_shared/DOCUMENT_HISTORY_REDACTED_FIELDS-KTkC4xOc.mjs +1 -0
  16. package/dist/packem_shared/LunoraEnvError-_BakoYQ3.mjs +3 -0
  17. package/dist/packem_shared/LunoraError-DcKdk9Ti.mjs +1 -0
  18. package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-BpSPSCwL.mjs +1 -0
  19. package/dist/packem_shared/allowAll-DkRAgItV.mjs +1 -0
  20. package/dist/packem_shared/apply-output-BG8Bd0Ug.mjs +1 -0
  21. package/dist/packem_shared/asBucketStorage-BthCnWop.mjs +1 -0
  22. package/dist/packem_shared/bindOrm-lWdeDi9P.mjs +1 -0
  23. package/dist/packem_shared/buildMaskRegistry-72SL8fJn.mjs +1 -0
  24. package/dist/packem_shared/buildRlsReadRegistry-Deq8inqS.mjs +1 -0
  25. package/dist/packem_shared/composePluginMiddleware-DQHF6mYr.mjs +1 -0
  26. package/dist/packem_shared/context-identity-B2XYGA0B.mjs +1 -0
  27. package/dist/packem_shared/createPolicyDsl-DNfByAUX.mjs +1 -0
  28. package/dist/packem_shared/createSecrets-CyrEddTF.mjs +1 -0
  29. package/dist/packem_shared/defineAggregateIndex-BtVAy69G.mjs +1 -0
  30. package/dist/packem_shared/defineIdentity-DwkNKwYa.mjs +1 -0
  31. package/dist/packem_shared/defineMigration-7GI9Qbtd.mjs +1 -0
  32. package/dist/packem_shared/defineMutator-DKy8UtbB.mjs +1 -0
  33. package/dist/packem_shared/defineShape-DYxbNl5W.mjs +1 -0
  34. package/dist/packem_shared/defineStorageRule-BvxHVq3b.mjs +1 -0
  35. package/dist/packem_shared/flushDeferredDeletes-DEJXlhop.mjs +1 -0
  36. package/dist/packem_shared/fnv1a-D6VtE8WR.mjs +1 -0
  37. package/dist/packem_shared/functions-B2-H4PQT.mjs +1 -0
  38. package/dist/packem_shared/httpAction-D3b9-YiY.mjs +5 -0
  39. package/dist/packem_shared/initLunora-B2sfmFJ6.mjs +1 -0
  40. package/dist/packem_shared/mask-Da7q82ZC.mjs +1 -0
  41. package/dist/packem_shared/middleware-DEW0yLvU.mjs +1 -0
  42. package/dist/packem_shared/onConnect-BLRoOpv2.mjs +1 -0
  43. package/dist/packem_shared/onQueryChange-pRK6Dh3g.mjs +1 -0
  44. package/dist/packem_shared/plugin-DQcLxTx1.mjs +1 -0
  45. package/dist/packem_shared/policy-tag-D4RzgQnw.mjs +1 -0
  46. package/dist/packem_shared/protectPublic-Bo4G9xaV.mjs +1 -0
  47. package/dist/packem_shared/rls-B3mNGBuc.mjs +1 -0
  48. package/dist/packem_shared/run-middleware-B-JeGGp9.mjs +1 -0
  49. package/dist/packem_shared/stable-key-B_BlboiY.mjs +1 -0
  50. package/dist/packem_shared/storageRules-CyaiZ0av.mjs +1 -0
  51. package/dist/packem_shared/types.d-B-pIn8rE.d.mts +141 -0
  52. package/dist/packem_shared/types.d-CdPDEjhz.d.ts +141 -0
  53. package/dist/packem_shared/wire-codec-hZHn-Ooo.mjs +1 -0
  54. package/dist/rls/testing.d.mts +31 -31
  55. package/dist/rls/testing.d.ts +31 -31
  56. package/dist/rls/testing.mjs +1 -49
  57. package/dist/types.d.mts +1621 -508
  58. package/dist/types.d.ts +1621 -508
  59. package/dist/types.mjs +1 -31
  60. package/package.json +17 -4
  61. package/dist/packem_shared/LunoraEnvError-DjFkpkSP.mjs +0 -187
  62. package/dist/packem_shared/LunoraError-DN7Zhhvu.mjs +0 -54
  63. package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-D8viLY1S.mjs +0 -114
  64. package/dist/packem_shared/asBucketStorage-Cnxd9y2q.mjs +0 -11
  65. package/dist/packem_shared/bindOrm-Ce57S3N9.mjs +0 -128
  66. package/dist/packem_shared/buildRlsReadRegistry-1jexWrb3.mjs +0 -107
  67. package/dist/packem_shared/composePluginMiddleware-Ck5_TUO8.mjs +0 -100
  68. package/dist/packem_shared/createPolicyDsl-De67zPDS.mjs +0 -29
  69. package/dist/packem_shared/createSecrets-TsIP9lOa.mjs +0 -55
  70. package/dist/packem_shared/defineAggregateIndex-ZdyU78gh.mjs +0 -291
  71. package/dist/packem_shared/defineMigration-CAJLr6fx.mjs +0 -8
  72. package/dist/packem_shared/defineMutator-EIXAWhs9.mjs +0 -11
  73. package/dist/packem_shared/defineShape-CJ27Wx7o.mjs +0 -17
  74. package/dist/packem_shared/defineStorageRule-qu0mpilX.mjs +0 -20
  75. package/dist/packem_shared/functions-Di9FUNkf.mjs +0 -5
  76. package/dist/packem_shared/httpAction-FLwfsePg.mjs +0 -340
  77. package/dist/packem_shared/initLunora-lxwHTEV3.mjs +0 -100
  78. package/dist/packem_shared/mask-BV_jNzsN.mjs +0 -211
  79. package/dist/packem_shared/onConnect-CIPXKPyw.mjs +0 -13
  80. package/dist/packem_shared/policy-tag-DvpVH2tv.mjs +0 -13
  81. package/dist/packem_shared/protectPublic-BjFkQ_Or.mjs +0 -15
  82. package/dist/packem_shared/rls-2Jhd0uev.mjs +0 -569
  83. package/dist/packem_shared/run-middleware-CYQOuoV6.mjs +0 -18
  84. package/dist/packem_shared/storageRules-Cje6Woea.mjs +0 -88
  85. package/dist/packem_shared/types.d-BDY0FYHK.d.ts +0 -135
  86. package/dist/packem_shared/types.d-DmvyEMD6.d.mts +0 -135
package/LICENSE.md CHANGED
@@ -103,3 +103,222 @@ Unless required by applicable law or agreed to in writing, software distributed
103
103
  under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
104
  CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
105
  specific language governing permissions and limitations under the License.
106
+
107
+ <!-- DEPENDENCIES -->
108
+ <!-- /DEPENDENCIES -->
109
+
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
+
324
+ <!-- /TYPE_DEPENDENCIES -->
package/README.md CHANGED
@@ -99,6 +99,52 @@ The builder chain is `<builder>.input(validators).<kind>(handler)`, plus `.use(m
99
99
 
100
100
  > This README covers the basics. For the full API, options, and guides, see the **[documentation](https://lunora.sh/docs/packages/server)**.
101
101
 
102
+ ### Caching with Workers Cache
103
+
104
+ Lunora supports Cloudflare Workers Cache for HTTP actions (`httpRoute`). RPC queries and mutations are `POST /_lunora/rpc` and are not cacheable at the edge by design.
105
+
106
+ **Enable Workers Cache** in `wrangler.jsonc`:
107
+
108
+ ```jsonc
109
+ {
110
+ "cache": { "enabled": true },
111
+ }
112
+ ```
113
+
114
+ The dev server and CLI automatically bump `compatibility_date` to the minimum required when cache is enabled — you do not need to set it manually.
115
+
116
+ **Set cache headers declaratively** on an `httpRoute`:
117
+
118
+ ```ts
119
+ import { httpRoute } from "./_generated/server";
120
+
121
+ export const getProduct = httpRoute
122
+ .get("/api/products/:id")
123
+ .params({ id: v.string() })
124
+ .cacheControl("public, max-age=300, stale-while-revalidate=3600")
125
+ .cacheTag("products")
126
+ .handler(async ({ ctx, params }) => {
127
+ return { id: params.id, name: "Widget" };
128
+ });
129
+ ```
130
+
131
+ **Purge cache by tag** from an action handler:
132
+
133
+ ```ts
134
+ import { action } from "./_generated/server";
135
+
136
+ export const refreshProducts = action.action(async ({ ctx }) => {
137
+ if (!ctx.cache) {
138
+ throw new Error("Workers Cache is not enabled in wrangler.jsonc");
139
+ }
140
+
141
+ await ctx.cache.purge({ tags: ["products"] });
142
+ return { ok: true };
143
+ });
144
+ ```
145
+
146
+ The `ctx.cache.purge` API accepts `{ tags?: string[]; purgeEverything?: boolean }`. Only action handlers expose `ctx.cache`; queries and mutations run inside the Durable Object and do not have access to the Worker-level cache binding.
147
+
102
148
  ## Related
103
149
 
104
150
  - [`@lunora/values`](https://www.npmjs.com/package/@lunora/values) — the `v.*` validators re-exported here.