@voltro/database 0.6.0 → 0.8.0
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/CHANGELOG.md +41 -0
- package/dist/index.d.ts +49 -1
- package/dist/index.js +490 -489
- package/dist/wire.d.ts +44 -0
- package/dist/wire.js +5 -0
- package/package.json +7 -2
package/dist/wire.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The timestamp mapping as a STANDALONE field schema: `Date` in the
|
|
5
|
+
* handler, epoch-ms `number` on the wire.
|
|
6
|
+
*
|
|
7
|
+
* A `timestamp()` column comes back from the store as a `Date`, and `Date`
|
|
8
|
+
* is not JSON. Declaring that field `Schema.Number` describes the WIRE type
|
|
9
|
+
* rather than the domain type — which leaves the schema nothing to convert
|
|
10
|
+
* and pushes the conversion back into the handler, one `.getTime()` at a
|
|
11
|
+
* time. Declare this instead and the framework performs the conversion,
|
|
12
|
+
* because a descriptor's `output` IS the serializer (it is handed to the
|
|
13
|
+
* rpc as the success schema).
|
|
14
|
+
*
|
|
15
|
+
* output: Schema.Struct({
|
|
16
|
+
* id: Schema.String,
|
|
17
|
+
* name: Schema.String,
|
|
18
|
+
* addedAt: timestampMs, // Date in, epoch ms on the wire
|
|
19
|
+
* archivedAt: timestampMsOrNull, // for a nullable column
|
|
20
|
+
* seenAt: Schema.optional(timestampMs),
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* This is the SAME schema `columnSchema` maps a `timestamp()` / `date()`
|
|
24
|
+
* column to — it reads the value from here — so a hand-written struct and a
|
|
25
|
+
* derived row can never drift into different wire representations.
|
|
26
|
+
*
|
|
27
|
+
* There is deliberately no `timestampMsOptional`: an absent field is
|
|
28
|
+
* `Schema.optional(timestampMs)`, which composes without a third export.
|
|
29
|
+
*/
|
|
30
|
+
export declare const timestampMs: Schema.Schema<Date, number>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* `timestampMs` for a NULLABLE timestamp column — `Date | null` in the
|
|
34
|
+
* handler, `number | null` on the wire.
|
|
35
|
+
*
|
|
36
|
+
* The mistake this exists to prevent is writing `timestampMs` for a
|
|
37
|
+
* nullable column and converting by hand at the tail: `new Date(null)` is
|
|
38
|
+
* 1970-01-01, so a "never archived" row renders as a plausible date
|
|
39
|
+
* instead of as nothing. Mirrors what `columnSchema` does for a
|
|
40
|
+
* `.nullable()` timestamp.
|
|
41
|
+
*/
|
|
42
|
+
export declare const timestampMsOrNull: Schema.Schema<Date | null, number | null>;
|
|
43
|
+
|
|
44
|
+
export { }
|
package/dist/wire.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/database",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Browser-safe schema DSL, query builder, and cross-dialect migration planner for Voltro — one schema, every SQL backend.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|
|
@@ -27,6 +27,11 @@
|
|
|
27
27
|
"types": "./dist/sql.d.ts",
|
|
28
28
|
"import": "./dist/sql.js",
|
|
29
29
|
"default": "./dist/sql.js"
|
|
30
|
+
},
|
|
31
|
+
"./wire": {
|
|
32
|
+
"types": "./dist/wire.d.ts",
|
|
33
|
+
"import": "./dist/wire.js",
|
|
34
|
+
"default": "./dist/wire.js"
|
|
30
35
|
}
|
|
31
36
|
},
|
|
32
37
|
"main": "./dist/index.js",
|
|
@@ -38,7 +43,7 @@
|
|
|
38
43
|
},
|
|
39
44
|
"dependencies": {
|
|
40
45
|
"@effect/sql": "^0.51.1",
|
|
41
|
-
"@voltro/logger": "0.
|
|
46
|
+
"@voltro/logger": "0.8.0",
|
|
42
47
|
"typeid-js": "^1.2.0",
|
|
43
48
|
"ulidx": "^2.4.1"
|
|
44
49
|
},
|