@lunora/server 1.0.0-alpha.2 → 1.0.0-alpha.21
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 +6 -0
- package/README.md +51 -1
- package/__assets__/package-og.svg +1 -1
- package/dist/data-model.d.mts +158 -32
- package/dist/data-model.d.ts +158 -32
- package/dist/index.d.mts +459 -117
- package/dist/index.d.ts +459 -117
- package/dist/index.mjs +20 -15
- package/dist/packem_shared/{LunoraEnvError-DjFkpkSP.mjs → LunoraEnvError-BGmd1Qs0.mjs} +4 -4
- package/dist/packem_shared/LunoraError-WbxmrpxR.mjs +9 -0
- package/dist/packem_shared/{PRESENCE_DEFAULT_TTL_MS-BZYd5-uo.mjs → PRESENCE_DEFAULT_TTL_MS-BtPCiNLW.mjs} +4 -4
- package/dist/packem_shared/bindOrm-Bfgl7f-Q.mjs +146 -0
- package/dist/packem_shared/buildRlsReadRegistry-D54vUQe4.mjs +107 -0
- package/dist/packem_shared/{composePluginMiddleware-Ck5_TUO8.mjs → composePluginMiddleware-CcTj1_v2.mjs} +9 -6
- package/dist/packem_shared/{createPolicyDsl-De67zPDS.mjs → createPolicyDsl-By3QB4he.mjs} +4 -1
- package/dist/packem_shared/createSecrets-DwaR2rNG.mjs +58 -0
- package/dist/packem_shared/{defineAggregateIndex-DxSso0rH.mjs → defineAggregateIndex-znq4ygKQ.mjs} +69 -10
- package/dist/packem_shared/defineIdentity-DiX4zM9x.mjs +35 -0
- package/dist/packem_shared/{defineMigration-CAJLr6fx.mjs → defineMigration-Hx01yIht.mjs} +3 -1
- package/dist/packem_shared/defineMutator-EIXAWhs9.mjs +11 -0
- package/dist/packem_shared/defineShape-C5scNOrf.mjs +18 -0
- package/dist/packem_shared/{defineStorageRule-qu0mpilX.mjs → defineStorageRule-B5nL4Z1P.mjs} +4 -1
- package/dist/packem_shared/functions-Di9FUNkf.mjs +5 -0
- package/dist/packem_shared/{httpAction-B7FYUEgr.mjs → httpAction-DCXoYPIk.mjs} +42 -27
- package/dist/packem_shared/{initLunora-CATvPsVt.mjs → initLunora-sQUqaejx.mjs} +18 -4
- package/dist/packem_shared/{mask-Jc84C_hK.mjs → mask-BT1YgRbF.mjs} +89 -9
- package/dist/packem_shared/policy-tag-DvpVH2tv.mjs +13 -0
- package/dist/packem_shared/{protectPublic-BjFkQ_Or.mjs → protectPublic-BlcGpiRc.mjs} +1 -1
- package/dist/packem_shared/{rls-BDKRbMCA.mjs → rls-B_ZWgslr.mjs} +51 -7
- package/dist/packem_shared/{run-middleware-CYQOuoV6.mjs → run-middleware-I6EiQfxL.mjs} +3 -1
- package/dist/packem_shared/{storageRules-4a30FSpI.mjs → storageRules-6QxzDOcx.mjs} +1 -1
- package/dist/packem_shared/{types.d-DmvyEMD6.d.mts → types.d-BB3pjV0m.d.mts} +10 -4
- package/dist/packem_shared/{types.d-BDY0FYHK.d.ts → types.d-Cxl6ndhm.d.ts} +10 -4
- package/dist/rls/testing.d.mts +1 -1
- package/dist/rls/testing.d.ts +1 -1
- package/dist/rls/testing.mjs +1 -1
- package/dist/types.d.mts +206 -5
- package/dist/types.d.ts +206 -5
- package/package.json +6 -5
- package/dist/packem_shared/LunoraError-DhggBJZF.mjs +0 -51
- package/dist/packem_shared/bindOrm-DCuyr46L.mjs +0 -71
package/dist/rls/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PolicyOperation, R as Role, a as Policy } from "../packem_shared/types.d-
|
|
1
|
+
import { P as PolicyOperation, R as Role, a as Policy } from "../packem_shared/types.d-Cxl6ndhm.js";
|
|
2
2
|
import "../data-model.js";
|
|
3
3
|
/**
|
|
4
4
|
* The slice of a request identity a policy reads. Mirrors the
|
package/dist/rls/testing.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { indexRolePermissions, computeReadBaseWhere, matchesWhere, evaluateWrite, permissionName } from '../packem_shared/rls-
|
|
1
|
+
import { indexRolePermissions, computeReadBaseWhere, matchesWhere, evaluateWrite, permissionName } from '../packem_shared/rls-B_ZWgslr.mjs';
|
|
2
2
|
|
|
3
3
|
const expectPolicy = (policies, options = {}) => {
|
|
4
4
|
const rolePermissions = indexRolePermissions(options.roles);
|
package/dist/types.d.mts
CHANGED
|
@@ -5,6 +5,14 @@ type ArgsValidator = ValidatorMap;
|
|
|
5
5
|
type InferArgs<A extends ArgsValidator> = InferValidatorMap<A>;
|
|
6
6
|
/** Storage backend for a `.global()` table: D1 (default) or a Postgres/MySQL database via Cloudflare Hyperdrive (PlanetScale, Neon, …). */
|
|
7
7
|
type GlobalBackend = "d1" | "hyperdrive";
|
|
8
|
+
/**
|
|
9
|
+
* Cloudflare Durable Object data-residency jurisdiction declared via
|
|
10
|
+
* `defineSchema(...).jurisdiction("…")`. Restricts where every DO the app
|
|
11
|
+
* reaches runs and persists data (GDPR, FedRAMP, US data residency). Widening
|
|
12
|
+
* union — Cloudflare adds values over time.
|
|
13
|
+
* @see https://developers.cloudflare.com/durable-objects/reference/data-location/
|
|
14
|
+
*/
|
|
15
|
+
type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
|
|
8
16
|
/** How a table is routed at runtime. */
|
|
9
17
|
type ShardMode = {
|
|
10
18
|
backend?: GlobalBackend;
|
|
@@ -15,6 +23,51 @@ type ShardMode = {
|
|
|
15
23
|
} | {
|
|
16
24
|
kind: "root";
|
|
17
25
|
};
|
|
26
|
+
/** Poll cadence for a sourced table — `"manual"` (pull only on an explicit trigger) or a fixed interval. */
|
|
27
|
+
type ExternalSourceRefresh = "manual" | {
|
|
28
|
+
everyMs: number;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Delete-detection mode for external-source ingest. `"full-pull"` (default) reads
|
|
32
|
+
* the whole tenant membership each tick and diffs it, so it observes upstream
|
|
33
|
+
* deletes; `"incremental"` pulls only changed rows (cheap) and is blind to deletes
|
|
34
|
+
* unless paired with a soft-delete column or a `reconcileEveryMs` full-pull sweep.
|
|
35
|
+
*/
|
|
36
|
+
type ExternalSourceMode = "full-pull" | "incremental";
|
|
37
|
+
/**
|
|
38
|
+
* Config for `.source(...)` (plan 077): declares a table as **materialized from an
|
|
39
|
+
* external Postgres/MySQL behind Cloudflare Hyperdrive**, not written by user
|
|
40
|
+
* mutations. A system-driven poll loop reads the tenant slice and lands it in the
|
|
41
|
+
* DO's SQLite (via the validated CDC writer), after which `defineShape` carries it
|
|
42
|
+
* to clients unchanged. Orthogonal to `shardMode` — a sourced table almost always
|
|
43
|
+
* also `.shardBy()`s, in which case `tenantBy` is the mandatory tenant-isolation
|
|
44
|
+
* boundary (enforced by the `external_source_unscoped` advisor lint).
|
|
45
|
+
*/
|
|
46
|
+
interface ExternalSourceDefinition {
|
|
47
|
+
/** The wrangler Hyperdrive binding name the poll loop reads from. */
|
|
48
|
+
binding: string;
|
|
49
|
+
/** Project the materialized rows to these columns (passed to the membership diff). Omit ⇒ the full mapped document. */
|
|
50
|
+
columns?: ReadonlyArray<string>;
|
|
51
|
+
/** Column whose value becomes the Lunora `_id`. Defaults to `"id"`. */
|
|
52
|
+
idColumn?: string;
|
|
53
|
+
/** Transform an external row into the stored document body. Omit ⇒ every selected column except `idColumn` is copied. */
|
|
54
|
+
map?: (row: Record<string, unknown>) => Record<string, unknown>;
|
|
55
|
+
/** Delete-detection mode. Defaults to `"full-pull"`. */
|
|
56
|
+
mode?: ExternalSourceMode;
|
|
57
|
+
/** The full tenant-membership query, with driver-native placeholders (`$1` / `?`). `tenantBy` binds its params. */
|
|
58
|
+
query: string;
|
|
59
|
+
/** `"incremental"` only: run a full-pull reconcile this often to garbage-collect tombstones the incremental path can't see. */
|
|
60
|
+
reconcileEveryMs?: number;
|
|
61
|
+
/** Poll cadence, or `"manual"`. Omit ⇒ the runtime's size-scaled default. */
|
|
62
|
+
refresh?: ExternalSourceRefresh;
|
|
63
|
+
/**
|
|
64
|
+
* **Mandatory under `.shardBy()`**: map this DO's shard key → the query's bound
|
|
65
|
+
* params, so a tenant DO can only ever pull its own rows. An unscoped sourced +
|
|
66
|
+
* sharded table replicates the whole multitenant table into every shard — the
|
|
67
|
+
* `external_source_unscoped` advisor lint fails the build when this is absent.
|
|
68
|
+
*/
|
|
69
|
+
tenantBy?: (shardKey: string) => ReadonlyArray<unknown>;
|
|
70
|
+
}
|
|
18
71
|
interface IndexDefinition {
|
|
19
72
|
fields: ReadonlyArray<string>;
|
|
20
73
|
name: string;
|
|
@@ -130,6 +183,14 @@ interface TableDefinition<Shape extends Record<string, Validator> = Record<strin
|
|
|
130
183
|
* without scanning the underlying table.
|
|
131
184
|
*/
|
|
132
185
|
aggregateIndexes: ReadonlyArray<AggregateIndexDefinition>;
|
|
186
|
+
/**
|
|
187
|
+
* Set by `.source(...)` (named `externalSource`, not `source`, so the data
|
|
188
|
+
* field doesn't collide with the fluent `.source()` builder method — same
|
|
189
|
+
* convention as `shardBy()`/`shardMode`). When present, the table is
|
|
190
|
+
* materialized from an external Hyperdrive-backed database by a system poll
|
|
191
|
+
* loop rather than user mutations. Implies `isExternallyManaged`.
|
|
192
|
+
*/
|
|
193
|
+
externalSource?: ExternalSourceDefinition;
|
|
133
194
|
indexes: ReadonlyArray<IndexDefinition>;
|
|
134
195
|
/**
|
|
135
196
|
* `true` when `.externallyManaged()` was called — the table's rows are
|
|
@@ -165,6 +226,20 @@ interface TableDefinition<Shape extends Record<string, Validator> = Record<strin
|
|
|
165
226
|
shape: Shape;
|
|
166
227
|
shardMode: ShardMode;
|
|
167
228
|
/**
|
|
229
|
+
* Set by `.softDelete()` (named `softDeleteMode`, not `softDelete`, so the
|
|
230
|
+
* data field doesn't collide with the fluent `.softDelete()` builder method —
|
|
231
|
+
* same convention as `shardBy()`/`shardMode`). When present, the table carries
|
|
232
|
+
* a nullable timestamp column (`field`, default `deletedAt`):
|
|
233
|
+
* `ctx.db.<table>.delete()` flips it instead of physically removing the row,
|
|
234
|
+
* and **list reads** (`findMany`/`findFirst`/`query()`/`count`/`aggregate`/
|
|
235
|
+
* relation loads) hide rows whose `field` is set unless
|
|
236
|
+
* `includeDeleted: true` is passed. By-id `get`/`patch`/`replace` and
|
|
237
|
+
* `restore` are unaffected. Absent ⇒ deletes are physical, as before.
|
|
238
|
+
*/
|
|
239
|
+
softDeleteMode?: {
|
|
240
|
+
field: string;
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
168
243
|
* Declared lifecycle triggers keyed by accessor name; empty unless
|
|
169
244
|
* `.triggers()` was called. Named `triggerMap` (not `triggers`) so the
|
|
170
245
|
* fluent `.triggers((t) => …)` builder method doesn't collide with this
|
|
@@ -443,6 +518,16 @@ interface BatchWriteOptions {
|
|
|
443
518
|
/** Reject the call when the batch size exceeds this value (default 500). */
|
|
444
519
|
limit?: number;
|
|
445
520
|
}
|
|
521
|
+
/** Options accepted by {@link DatabaseWriter.insertMany} and the per-table facade. */
|
|
522
|
+
interface InsertManyOptions extends BatchWriteOptions {
|
|
523
|
+
/**
|
|
524
|
+
* When `true`, a UNIQUE-constraint breach for a row resolves to `null`
|
|
525
|
+
* instead of throwing — the rest of the batch is still inserted. Skipped rows
|
|
526
|
+
* keep their input-order slot with `null` in the returned array. Mirrors
|
|
527
|
+
* better-drizzle's `createMany({ skipDuplicates: true })`.
|
|
528
|
+
*/
|
|
529
|
+
skipDuplicates?: boolean;
|
|
530
|
+
}
|
|
446
531
|
interface DatabaseWriter extends DatabaseReader {
|
|
447
532
|
delete: <T extends string>(id: Id<T>) => Promise<void>;
|
|
448
533
|
/**
|
|
@@ -460,6 +545,18 @@ interface DatabaseWriter extends DatabaseReader {
|
|
|
460
545
|
deleted: number;
|
|
461
546
|
}>;
|
|
462
547
|
/**
|
|
548
|
+
* Delete every row matching `where` in one call. Matching rows are resolved
|
|
549
|
+
* first, then each row is deleted through the single-row delete pipeline
|
|
550
|
+
* (triggers, companion sync, CDC, broadcast) so reactive subscriptions and
|
|
551
|
+
* search/aggregate companions stay correct.
|
|
552
|
+
*
|
|
553
|
+
* **Atomic within a mutation:** the DO wraps a mutation's dispatch in a
|
|
554
|
+
* BEGIN/COMMIT span, so a mid-batch failure rolls back the whole mutation.
|
|
555
|
+
*/
|
|
556
|
+
deleteWhere: (tableName: string, where: Record<string, unknown>, options?: BatchWriteOptions) => Promise<{
|
|
557
|
+
deleted: number;
|
|
558
|
+
}>;
|
|
559
|
+
/**
|
|
463
560
|
* Insert a document, returning its server id.
|
|
464
561
|
*
|
|
465
562
|
* Pass `options.clientId` (a UUID) to key the row yourself — for an
|
|
@@ -476,12 +573,21 @@ interface DatabaseWriter extends DatabaseReader {
|
|
|
476
573
|
* row gets defaults, validators, triggers, and a per-row RLS check — but the
|
|
477
574
|
* caller pays one round-trip instead of N.
|
|
478
575
|
*
|
|
576
|
+
* Pass `{ skipDuplicates: true }` to turn UNIQUE-constraint breaches into
|
|
577
|
+
* `null` results for that row instead of failing the whole batch; the rest of
|
|
578
|
+
* the batch is still inserted and order is preserved.
|
|
579
|
+
*
|
|
479
580
|
* **Atomic within a mutation:** the DO wraps a mutation's dispatch in a
|
|
480
581
|
* BEGIN/COMMIT span, so a mid-batch failure (an invalid or RLS-denied row)
|
|
481
582
|
* rolls back the whole mutation. (In an action there is no transaction span,
|
|
482
583
|
* so the prior inserts persist; the in-memory test harness mirrors the span.)
|
|
483
584
|
*/
|
|
484
|
-
insertMany:
|
|
585
|
+
insertMany: {
|
|
586
|
+
<T extends string>(tableName: T, documents: ReadonlyArray<Record<string, unknown>>, options: BatchWriteOptions & {
|
|
587
|
+
skipDuplicates: true;
|
|
588
|
+
}): Promise<(Id<T> | null)[]>;
|
|
589
|
+
<T extends string>(tableName: T, documents: ReadonlyArray<Record<string, unknown>>, options?: InsertManyOptions): Promise<Id<T>[]>;
|
|
590
|
+
};
|
|
485
591
|
/**
|
|
486
592
|
* **Trusted** bulk insert: one multi-row `INSERT` that **skips per-row
|
|
487
593
|
* `.check()` validators and before/after triggers** for throughput on data you
|
|
@@ -501,7 +607,8 @@ interface DatabaseWriter extends DatabaseReader {
|
|
|
501
607
|
patch: <T extends string>(id: Id<T>, patch: Record<string, unknown>) => Promise<void>;
|
|
502
608
|
/**
|
|
503
609
|
* Patch many rows by id in one call. Each `{ id, patch }` is applied like a
|
|
504
|
-
* single `patch()` (per-row triggers + RLS).
|
|
610
|
+
* single `patch()` (per-row triggers + RLS). Returns the number of rows
|
|
611
|
+
* actually patched.
|
|
505
612
|
*
|
|
506
613
|
* **Atomic within a mutation:** the DO wraps a mutation's dispatch in a
|
|
507
614
|
* BEGIN/COMMIT span, so a mid-batch failure rolls back the whole mutation.
|
|
@@ -511,7 +618,24 @@ interface DatabaseWriter extends DatabaseReader {
|
|
|
511
618
|
patchMany: <T extends string>(patches: ReadonlyArray<{
|
|
512
619
|
id: Id<T>;
|
|
513
620
|
patch: Record<string, unknown>;
|
|
514
|
-
}>, options?: BatchWriteOptions) => Promise<
|
|
621
|
+
}>, options?: BatchWriteOptions) => Promise<{
|
|
622
|
+
patched: number;
|
|
623
|
+
}>;
|
|
624
|
+
/**
|
|
625
|
+
* Patch every row matching `where` with the same `patch` in one call. The
|
|
626
|
+
* matching rows are resolved first, then each row is updated through the
|
|
627
|
+
* single-row patch pipeline (OCC, triggers, companion sync, CDC, broadcast)
|
|
628
|
+
* so reactive subscriptions and search/aggregate companions stay correct.
|
|
629
|
+
*
|
|
630
|
+
* **Atomic within a mutation:** the DO wraps a mutation's dispatch in a
|
|
631
|
+
* BEGIN/COMMIT span, so a mid-batch failure rolls back the whole mutation.
|
|
632
|
+
*/
|
|
633
|
+
patchWhere: (tableName: string, args: {
|
|
634
|
+
patch: Record<string, unknown>;
|
|
635
|
+
where: Record<string, unknown>;
|
|
636
|
+
}, options?: BatchWriteOptions) => Promise<{
|
|
637
|
+
patched: number;
|
|
638
|
+
}>;
|
|
515
639
|
replace: <T extends string>(id: Id<T>, document: Record<string, unknown>) => Promise<void>;
|
|
516
640
|
}
|
|
517
641
|
/** Authenticated identity surfaced into every context. */
|
|
@@ -614,6 +738,46 @@ interface Workflows {
|
|
|
614
738
|
/** Resolve the handle for a declared workflow by export name. */
|
|
615
739
|
get: <Params = Record<string, unknown>>(name: string) => WorkflowHandle<Params>;
|
|
616
740
|
}
|
|
741
|
+
/**
|
|
742
|
+
* Programmatic cache purge surface exposed on {@link ActionCtx}. Actions run
|
|
743
|
+
* in the Worker (not the DO), so they can reach the Worker's `ctx.cache.purge`.
|
|
744
|
+
* Queries and mutations do not expose this — they run inside the Durable Object.
|
|
745
|
+
*/
|
|
746
|
+
interface CachePurge {
|
|
747
|
+
/**
|
|
748
|
+
* Purge cached responses matching the given tags, or everything when
|
|
749
|
+
* `purgeEverything` is true. Only available in action handlers.
|
|
750
|
+
*/
|
|
751
|
+
purge: (options: {
|
|
752
|
+
purgeEverything?: boolean;
|
|
753
|
+
tags?: string[];
|
|
754
|
+
}) => Promise<unknown>;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Structural projection of workers-types' `SecretsStoreSecret` binding — the
|
|
758
|
+
* per-secret `secrets_store_secrets[]` binding whose `.get()` resolves the
|
|
759
|
+
* secret value (or throws if it does not exist). Mirrored structurally so the
|
|
760
|
+
* runtime resolves it without a workerd type dependency.
|
|
761
|
+
*/
|
|
762
|
+
interface SecretsStoreSecretLike {
|
|
763
|
+
get: () => Promise<string>;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* `ctx.secrets` — read account-level secrets bound via Cloudflare Secrets Store.
|
|
767
|
+
* A core built-in (always present on every context, like `ctx.log`): a binding
|
|
768
|
+
* named in wrangler's `secrets_store_secrets[]` is read by its binding name.
|
|
769
|
+
*
|
|
770
|
+
* ```ts
|
|
771
|
+
* const apiKey = await ctx.secrets.get("STRIPE_KEY");
|
|
772
|
+
* ```
|
|
773
|
+
*
|
|
774
|
+
* The lookup is async (the platform fetches and decrypts on first read);
|
|
775
|
+
* reading an undeclared name throws a directed error naming the bound secrets.
|
|
776
|
+
*/
|
|
777
|
+
interface Secrets {
|
|
778
|
+
/** Resolve a Secrets Store secret by its wrangler binding name. */
|
|
779
|
+
get: (name: string) => Promise<string>;
|
|
780
|
+
}
|
|
617
781
|
/** Lifecycle phase relative to the SQL write. */
|
|
618
782
|
type TriggerTiming = "after" | "before";
|
|
619
783
|
/** The CRUD operation a trigger reacts to. `patch` and `replace` both map to `update`. */
|
|
@@ -899,7 +1063,7 @@ interface VectorRecord {
|
|
|
899
1063
|
}
|
|
900
1064
|
/**
|
|
901
1065
|
* Read-only vector surface exposed on {@link QueryCtx}. Mirrors the read half
|
|
902
|
-
* of `@lunora/vectors`' `LunoraVectors` so the live adapter is assignable.
|
|
1066
|
+
* of `@lunora/bindings/vectors`' `LunoraVectors` so the live adapter is assignable.
|
|
903
1067
|
*/
|
|
904
1068
|
interface VectorSearchReader {
|
|
905
1069
|
getByIds: (indexName: string, ids: ReadonlyArray<string>) => Promise<ReadonlyArray<VectorRecord>>;
|
|
@@ -944,6 +1108,14 @@ interface QueryCtx {
|
|
|
944
1108
|
readonly auth: AuthState;
|
|
945
1109
|
readonly db: DatabaseReader;
|
|
946
1110
|
/**
|
|
1111
|
+
* The validated, typed environment. Populated only when the project declares
|
|
1112
|
+
* a `defineEnv(...)` contract in `lunora/env.ts`; codegen then narrows this to
|
|
1113
|
+
* the validated `InferEnv` shape so `ctx.env.STRIPE_KEY` is parsed and
|
|
1114
|
+
* coercion-aware. Absent (optional) without a contract — declare
|
|
1115
|
+
* `lunora/env.ts` to populate and type it.
|
|
1116
|
+
*/
|
|
1117
|
+
readonly env?: Record<string, unknown>;
|
|
1118
|
+
/**
|
|
947
1119
|
* The caller's IP for this request — Cloudflare's trusted `CF-Connecting-IP`,
|
|
948
1120
|
* forwarded server-side (never read from a client header). `undefined` when
|
|
949
1121
|
* unknown: a live-subscription re-run, a server-initiated dispatch, or
|
|
@@ -969,6 +1141,8 @@ interface QueryCtx {
|
|
|
969
1141
|
* Mirrors Convex's `ctx.runQuery`.
|
|
970
1142
|
*/
|
|
971
1143
|
readonly runQuery: <A extends ArgsValidator, R>(reference: RegisteredQuery<A, R>, args: InferArgs<A>) => Promise<R>;
|
|
1144
|
+
/** Read account-level secrets from Cloudflare Secrets Store; see {@link Secrets}. */
|
|
1145
|
+
readonly secrets: Secrets;
|
|
972
1146
|
readonly storage: ReadOnlyStorage;
|
|
973
1147
|
readonly vectors: VectorSearchReader;
|
|
974
1148
|
}
|
|
@@ -976,6 +1150,14 @@ interface MutationCtx {
|
|
|
976
1150
|
readonly auth: AuthState;
|
|
977
1151
|
readonly db: DatabaseWriter;
|
|
978
1152
|
/**
|
|
1153
|
+
* The validated, typed environment. Populated only when the project declares
|
|
1154
|
+
* a `defineEnv(...)` contract in `lunora/env.ts`; codegen then narrows this to
|
|
1155
|
+
* the validated `InferEnv` shape so `ctx.env.STRIPE_KEY` is parsed and
|
|
1156
|
+
* coercion-aware. Absent (optional) without a contract — declare
|
|
1157
|
+
* `lunora/env.ts` to populate and type it.
|
|
1158
|
+
*/
|
|
1159
|
+
readonly env?: Record<string, unknown>;
|
|
1160
|
+
/**
|
|
979
1161
|
* The caller's IP for this request — Cloudflare's trusted `CF-Connecting-IP`,
|
|
980
1162
|
* forwarded server-side (never read from a client header). `undefined` when
|
|
981
1163
|
* unknown: a live-subscription re-run, a server-initiated dispatch, or
|
|
@@ -1009,6 +1191,8 @@ interface MutationCtx {
|
|
|
1009
1191
|
*/
|
|
1010
1192
|
readonly runQuery: <A extends ArgsValidator, R>(reference: RegisteredQuery<A, R>, args: InferArgs<A>) => Promise<R>;
|
|
1011
1193
|
readonly scheduler: Scheduler;
|
|
1194
|
+
/** Read account-level secrets from Cloudflare Secrets Store; see {@link Secrets}. */
|
|
1195
|
+
readonly secrets: Secrets;
|
|
1012
1196
|
readonly storage: ReadOnlyStorage;
|
|
1013
1197
|
readonly vectors: VectorSearch;
|
|
1014
1198
|
/** Start / resume / inspect durable workflows; see {@link Workflows}. */
|
|
@@ -1016,7 +1200,22 @@ interface MutationCtx {
|
|
|
1016
1200
|
}
|
|
1017
1201
|
interface ActionCtx {
|
|
1018
1202
|
readonly auth: AuthState;
|
|
1203
|
+
/**
|
|
1204
|
+
* Programmatic Workers Cache purge; see {@link CachePurge}.
|
|
1205
|
+
* **Action-only** — actions run in the Worker, which has a `cache` binding.
|
|
1206
|
+
* Queries and mutations run inside the Durable Object and do not expose this.
|
|
1207
|
+
* Optional at runtime because Workers Cache is only present when enabled.
|
|
1208
|
+
*/
|
|
1209
|
+
readonly cache?: CachePurge;
|
|
1019
1210
|
readonly db: DatabaseWriter;
|
|
1211
|
+
/**
|
|
1212
|
+
* The validated, typed environment. Populated only when the project declares
|
|
1213
|
+
* a `defineEnv(...)` contract in `lunora/env.ts`; codegen then narrows this to
|
|
1214
|
+
* the validated `InferEnv` shape so `ctx.env.STRIPE_KEY` is parsed and
|
|
1215
|
+
* coercion-aware. Absent (optional) without a contract — declare
|
|
1216
|
+
* `lunora/env.ts` to populate and type it.
|
|
1217
|
+
*/
|
|
1218
|
+
readonly env?: Record<string, unknown>;
|
|
1020
1219
|
readonly fetch: typeof globalThis.fetch;
|
|
1021
1220
|
/**
|
|
1022
1221
|
* The caller's IP for this request — Cloudflare's trusted `CF-Connecting-IP`,
|
|
@@ -1037,6 +1236,8 @@ interface ActionCtx {
|
|
|
1037
1236
|
readonly runMutation: <A extends ArgsValidator, R>(reference: RegisteredMutation<A, R>, args: InferArgs<A>) => Promise<R>;
|
|
1038
1237
|
readonly runQuery: <A extends ArgsValidator, R>(reference: RegisteredQuery<A, R>, args: InferArgs<A>) => Promise<R>;
|
|
1039
1238
|
readonly scheduler: Scheduler;
|
|
1239
|
+
/** Read account-level secrets from Cloudflare Secrets Store; see {@link Secrets}. */
|
|
1240
|
+
readonly secrets: Secrets;
|
|
1040
1241
|
readonly storage: Storage;
|
|
1041
1242
|
readonly vectors: VectorSearch;
|
|
1042
1243
|
/** Start / resume / inspect durable workflows; see {@link Workflows}. */
|
|
@@ -1048,4 +1249,4 @@ interface ActionCtx {
|
|
|
1048
1249
|
*/
|
|
1049
1250
|
type AnyApi = Record<string, Record<string, RegisteredFunction<ArgsValidator, unknown, FunctionKind>>>;
|
|
1050
1251
|
declare const anyApi: AnyApi;
|
|
1051
|
-
export { type ActionCtx, type AggregateIndexDefinition, type AggregateOp, type AnyApi, type ArgsValidator, type AuthState, type DatabaseReader, type DatabaseWriter, type FunctionKind, type FunctionVisibility, type GlobalBackend, type IndexDefinition, type IndexRangeBuilder, type InferArgs, type LifecycleEvent, type LifecycleEventKind, type LunoraLogger, type MutationCtx, type OnDeleteAction, type PaginationOptions, type PaginationResult, type QueryCtx, type RankIndexDefinition, type RankSortKey, type ReadOnlyStorage, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMutation, type RegisteredQuery, type RegisteredStream, type RelationDefinition, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type Schema, type SearchFilterBuilder, type SearchIndexDefinition, type ShardMode, type Storage, type StorageMetadata, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableDefinition, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerBuilder, type TriggerCtx, type TriggerDatabase, type TriggerDefinition, 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 VectorEmbedder, type VectorIndexDefinition, type VectorMatch, type VectorMatches, type VectorMetric, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, anyApi };
|
|
1252
|
+
export { type ActionCtx, type AggregateIndexDefinition, type AggregateOp, type AnyApi, type ArgsValidator, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type DurableObjectJurisdiction, type ExternalSourceDefinition, type ExternalSourceMode, type ExternalSourceRefresh, type FunctionKind, type FunctionVisibility, type GlobalBackend, type IndexDefinition, type IndexRangeBuilder, type InferArgs, type LifecycleEvent, type LifecycleEventKind, type LunoraLogger, type MutationCtx, type OnDeleteAction, type PaginationOptions, type PaginationResult, type QueryCtx, type RankIndexDefinition, type RankSortKey, type ReadOnlyStorage, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMutation, type RegisteredQuery, type RegisteredStream, type RelationDefinition, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type Schema, type SearchFilterBuilder, type SearchIndexDefinition, type Secrets, type SecretsStoreSecretLike, type ShardMode, type Storage, type StorageMetadata, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableDefinition, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerBuilder, type TriggerCtx, type TriggerDatabase, type TriggerDefinition, 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 VectorEmbedder, type VectorIndexDefinition, type VectorMatch, type VectorMatches, type VectorMetric, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, anyApi };
|