kindstore 0.1.3 → 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 CHANGED
@@ -32,7 +32,7 @@ const Post = z.object({
32
32
  const db = kindstore({
33
33
  connection: { filename: ":memory:" },
34
34
  posts: kind("pst", Post)
35
- .updatedAt("updatedAt")
35
+ .updatedAt()
36
36
  .index("authorId")
37
37
  .index("slug")
38
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>(field: TKey): KindDefinition<Omit<T, "createdAt"> & {
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>(field: TKey): KindDefinition<Omit<T, "updatedAt"> & {
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(field) {
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(field) {
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",
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",