durable-db 0.5.0 → 0.5.1
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/dist/actionArgs-C6B67Xnr.js +39 -0
- package/dist/db/index.js +2 -2
- package/dist/{defineDatabase-D_RpcKj1.js → defineDatabase-mrwCGeOt.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/registry.js +1 -1
- package/dist/testing/index.js +2 -2
- package/package.json +1 -1
- package/dist/actionArgs-1hEaDUia.js +0 -7465
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { scope } from "arktype";
|
|
2
|
+
//#region src/arktypeConfig.ts
|
|
3
|
+
const type = scope({}, { jitless: true }).type;
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/db/actionArgs.ts
|
|
6
|
+
/**
|
|
7
|
+
* ArkType's `type`, for an action's `args` schema: jitless like
|
|
8
|
+
* `../arktypeConfig` (eval-free for Workers), and with an optional key
|
|
9
|
+
* accepting `undefined`.
|
|
10
|
+
*
|
|
11
|
+
* ArkType checks an optional key as TypeScript's `exactOptionalPropertyTypes`
|
|
12
|
+
* would by default: `'photoKey?': 'string'` rejects `{ photoKey: undefined }`,
|
|
13
|
+
* while the inferred `{ photoKey?: string }` accepts it under TypeScript's
|
|
14
|
+
* default settings — so `addReview({ …, photoKey: maybeKey })` type-checks and
|
|
15
|
+
* then fails at runtime. This scope turns ArkType's
|
|
16
|
+
* `exactOptionalPropertyTypes` off: an optional key, at any depth, admits
|
|
17
|
+
* `undefined`, and a required key stays required (`'note': 'string |
|
|
18
|
+
* undefined'` must be present, as TypeScript says). The validator is a plain
|
|
19
|
+
* object Type — `.props`, `.toJsonSchema()` and `.assert()` work as usual; in
|
|
20
|
+
* JSON Schema the `undefined` an optional key admits is `{ not: {} }` (a JSON
|
|
21
|
+
* document never holds it), so `'photoKey?': 'string'` is still a string.
|
|
22
|
+
*
|
|
23
|
+
* An `args` given as a ready `type(…)` keeps the rules of the scope that made
|
|
24
|
+
* it.
|
|
25
|
+
*
|
|
26
|
+
* The action transform compiles `args` with this (it is the `type` that
|
|
27
|
+
* `durable-db/registry` exports), for the RPC stub and the Durable Object
|
|
28
|
+
* alike; the untransformed `action()` and the test harness use it too.
|
|
29
|
+
*/
|
|
30
|
+
const actionArgsType = scope({}, {
|
|
31
|
+
jitless: true,
|
|
32
|
+
exactOptionalPropertyTypes: false,
|
|
33
|
+
toJsonSchema: { fallback: { unit: (ctx) => {
|
|
34
|
+
if (ctx.unit === void 0) return { not: {} };
|
|
35
|
+
throw new Error(`${String(ctx.unit)} is not convertible to JSON Schema`);
|
|
36
|
+
} } }
|
|
37
|
+
}).type;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { type as n, actionArgsType as t };
|
package/dist/db/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as init_debug, n as debugMigrations } from "../debug-Cz8KzMft.js";
|
|
2
|
-
import { n as type } from "../actionArgs-
|
|
3
|
-
import { n as defineDatabase } from "../defineDatabase-
|
|
2
|
+
import { n as type } from "../actionArgs-C6B67Xnr.js";
|
|
3
|
+
import { n as defineDatabase } from "../defineDatabase-mrwCGeOt.js";
|
|
4
4
|
import { a as createDrizzlePlugins, i as SchemaPlugin, n as DateSerializePlugin, o as dateSerializers, r as DrizzleDefaultsPlugin, t as createKyselyFromSql } from "../kysely-CYmmiwDm.js";
|
|
5
5
|
import { DurableObject } from "cloudflare:workers";
|
|
6
6
|
import { CamelCasePlugin } from "kysely";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as type } from "./actionArgs-
|
|
2
|
-
import { n as defineDatabase } from "./defineDatabase-
|
|
1
|
+
import { n as type } from "./actionArgs-C6B67Xnr.js";
|
|
2
|
+
import { n as defineDatabase } from "./defineDatabase-mrwCGeOt.js";
|
|
3
3
|
import { blob, foreignKey, index, integer, numeric, primaryKey, real, table, text, uniqueIndex } from "./schema.js";
|
|
4
4
|
import { getTenantId, hasTenantId, setTenantIdResolver } from "./context/index.js";
|
|
5
5
|
export { blob, defineDatabase, foreignKey, getTenantId, hasTenantId, index, integer, numeric, primaryKey, real, setTenantIdResolver, table, text, type, uniqueIndex };
|
package/dist/registry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as type, t as actionArgsType } from "./actionArgs-
|
|
1
|
+
import { n as type, t as actionArgsType } from "./actionArgs-C6B67Xnr.js";
|
|
2
2
|
import { WebSocketTransport } from "./transport/websocket.js";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
//#region src/registry.ts
|
package/dist/testing/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as type } from "../actionArgs-
|
|
2
|
-
import { r as liveTestDatabases, t as ACTION_TEST_META } from "../defineDatabase-
|
|
1
|
+
import { n as type } from "../actionArgs-C6B67Xnr.js";
|
|
2
|
+
import { r as liveTestDatabases, t as ACTION_TEST_META } from "../defineDatabase-mrwCGeOt.js";
|
|
3
3
|
import { setTenantIdResolver } from "../context/index.js";
|
|
4
4
|
import { t as createKyselyFromSql } from "../kysely-CYmmiwDm.js";
|
|
5
5
|
import { i as generateSnapshotFromSchema, n as createEmptySnapshot, r as generateMigrationStatements } from "../snapshot-D_z95s6E.js";
|