kindstore 0.1.2 → 0.1.4
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/README.md +8 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +4 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,6 +10,13 @@ Requires Bun at runtime because kindstore uses `bun:sqlite`.
|
|
|
10
10
|
bun add kindstore zod
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
The [skills.sh](https://skills.sh/) command line tool makes it easy to teach your
|
|
14
|
+
favorite coding agent how to use Kindstore:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npx skills add alloc/kindstore
|
|
18
|
+
```
|
|
19
|
+
|
|
13
20
|
```ts
|
|
14
21
|
import { z } from "zod";
|
|
15
22
|
import { kind, kindstore } from "kindstore";
|
|
@@ -25,7 +32,7 @@ const Post = z.object({
|
|
|
25
32
|
const db = kindstore({
|
|
26
33
|
connection: { filename: ":memory:" },
|
|
27
34
|
posts: kind("pst", Post)
|
|
28
|
-
.updatedAt(
|
|
35
|
+
.updatedAt()
|
|
29
36
|
.index("authorId")
|
|
30
37
|
.index("slug")
|
|
31
38
|
.index("status")
|
package/dist/index.d.mts
CHANGED
|
@@ -71,6 +71,7 @@ type ConnectionConfig = {
|
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region src/kind.d.ts
|
|
73
73
|
type MultiIndexFields<T extends KindDefinitionBag> = { [K in keyof KindValue<T> & string]?: IndexDirection };
|
|
74
|
+
type DefaultManagedTimestampField<T extends KindDefinitionBag, TName extends "createdAt" | "updatedAt"> = Extract<TName, keyof KindValue<T> & string>;
|
|
74
75
|
type IndexDefinition = {
|
|
75
76
|
field: string;
|
|
76
77
|
type?: SqliteTypeHint;
|
|
@@ -95,10 +96,10 @@ declare class KindDefinition<T extends KindDefinitionBag> {
|
|
|
95
96
|
}): KindDefinition<Omit<T, "indexed"> & {
|
|
96
97
|
indexed: T["indexed"] | TKey;
|
|
97
98
|
}>;
|
|
98
|
-
createdAt<TKey extends keyof KindValue<T> & string>
|
|
99
|
+
createdAt<TKey extends keyof KindValue<T> & string = DefaultManagedTimestampField<T, "createdAt">>(...args: DefaultManagedTimestampField<T, "createdAt"> extends never ? [field: keyof KindValue<T> & string] : [field?: TKey]): KindDefinition<Omit<T, "createdAt"> & {
|
|
99
100
|
createdAt: TKey;
|
|
100
101
|
}>;
|
|
101
|
-
updatedAt<TKey extends keyof KindValue<T> & string>
|
|
102
|
+
updatedAt<TKey extends keyof KindValue<T> & string = DefaultManagedTimestampField<T, "updatedAt">>(...args: DefaultManagedTimestampField<T, "updatedAt"> extends never ? [field: keyof KindValue<T> & string] : [field?: TKey]): KindDefinition<Omit<T, "updatedAt"> & {
|
|
102
103
|
updatedAt: TKey;
|
|
103
104
|
}>;
|
|
104
105
|
multi<const TName extends string, const TFields extends MultiIndexFields<T> & Record<string, IndexDirection>>(name: TName, fields: TFields): KindDefinition<Omit<T, "indexed"> & {
|
package/dist/index.mjs
CHANGED
|
@@ -24,12 +24,14 @@ var KindDefinition = class {
|
|
|
24
24
|
});
|
|
25
25
|
return this;
|
|
26
26
|
}
|
|
27
|
-
createdAt(
|
|
27
|
+
createdAt(...args) {
|
|
28
|
+
const field = args[0] ?? "createdAt";
|
|
28
29
|
if (field === this.updatedAtField) throw new Error(`Kind "${this.tag}" cannot use "${field}" for both createdAt and updatedAt.`);
|
|
29
30
|
this.createdAtField = field;
|
|
30
31
|
return this;
|
|
31
32
|
}
|
|
32
|
-
updatedAt(
|
|
33
|
+
updatedAt(...args) {
|
|
34
|
+
const field = args[0] ?? "updatedAt";
|
|
33
35
|
if (field === this.createdAtField) throw new Error(`Kind "${this.tag}" cannot use "${field}" for both createdAt and updatedAt.`);
|
|
34
36
|
this.updatedAtField = field;
|
|
35
37
|
return this;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kindstore",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "A lightweight, typed document store on SQLite with Zod schemas, indexed queries, and explicit migrations.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Alec Larson",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"sideEffects": false,
|
|
32
32
|
"engines": {
|
|
33
|
-
"bun": ">=1.
|
|
33
|
+
"bun": ">=1.0.7"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"zod": "^4.0.0"
|