@typicalday/firegraph 0.7.1 → 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.
@@ -0,0 +1,13 @@
1
+ import {
2
+ SERIALIZATION_TAG,
3
+ deserializeFirestoreTypes,
4
+ isTaggedValue,
5
+ serializeFirestoreTypes
6
+ } from "./chunk-6OQW5OKO.js";
7
+ export {
8
+ SERIALIZATION_TAG,
9
+ deserializeFirestoreTypes,
10
+ isTaggedValue,
11
+ serializeFirestoreTypes
12
+ };
13
+ //# sourceMappingURL=serialization-C6JNNOCS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -104,6 +104,24 @@ declare function defineConfig(config: FiregraphConfig): FiregraphConfig;
104
104
  */
105
105
  declare function resolveView(resolverConfig: ViewResolverConfig | undefined, availableViewNames: string[], context?: ViewContext): string;
106
106
 
107
+ /**
108
+ * Backend-agnostic timestamp.
109
+ *
110
+ * Structurally compatible with `@google-cloud/firestore`'s `Timestamp` so
111
+ * that records returned by either the Firestore or SQLite backend can be
112
+ * consumed through the same `StoredGraphRecord` shape.
113
+ *
114
+ * Firestore's native `Timestamp` already satisfies this interface, so
115
+ * existing Firestore consumers see no behavior change. The SQLite backend
116
+ * returns instances of `GraphTimestampImpl` which also satisfies it.
117
+ */
118
+ interface GraphTimestamp {
119
+ readonly seconds: number;
120
+ readonly nanoseconds: number;
121
+ toDate(): Date;
122
+ toMillis(): number;
123
+ }
124
+
107
125
  interface GraphRecord {
108
126
  aType: string;
109
127
  aUid: string;
@@ -123,8 +141,13 @@ interface StoredGraphRecord {
123
141
  bType: string;
124
142
  bUid: string;
125
143
  data: Record<string, unknown>;
126
- createdAt: Timestamp;
127
- updatedAt: Timestamp;
144
+ /**
145
+ * Backend-agnostic timestamp. Firestore returns its native `Timestamp`
146
+ * (which structurally satisfies `GraphTimestamp`); the SQLite backends
147
+ * return a `GraphTimestampImpl` instance.
148
+ */
149
+ createdAt: GraphTimestamp;
150
+ updatedAt: GraphTimestamp;
128
151
  /** Schema version — set automatically when the registry entry has migrations. */
129
152
  v?: number;
130
153
  }
@@ -618,26 +641,4 @@ interface CascadeResult extends BulkResult {
618
641
  nodeDeleted: boolean;
619
642
  }
620
643
 
621
- /**
622
- * Code generation — produces TypeScript type definitions from JSON Schema
623
- * files discovered via the entity folder convention.
624
- *
625
- * Uses `json-schema-to-typescript` to compile each entity's `schema.json`
626
- * into a TypeScript interface.
627
- *
628
- * Naming convention:
629
- * - Nodes: `{PascalName}Data` (e.g. `TaskData`)
630
- * - Edges: `{PascalName}EdgeData` (e.g. `HasStepEdgeData`)
631
- */
632
-
633
- interface CodegenOptions {
634
- /** Add banner comment at top of output. Defaults to true. */
635
- banner?: boolean;
636
- }
637
- /**
638
- * Generate TypeScript type definitions from a DiscoveryResult.
639
- * Returns the full file content as a string.
640
- */
641
- declare function generateTypes(discovery: DiscoveryResult, options?: CodegenOptions): Promise<string>;
642
-
643
- export { type ScanProtection as A, type BulkBatchError as B, type CascadeResult as C, type DynamicRegistryConfig as D, type EdgeTopology as E, type FindEdgesParams as F, type GraphClientOptions as G, type HopDefinition as H, type TraversalOptions as I, type TraversalResult as J, type ViewDefaultsConfig as K, type ViewResolverConfig as L, type MigrationExecutor as M, type NodeTypeData as N, defineConfig as O, generateTypes as P, type QueryPlan as Q, type RegistryEntry as R, type StoredMigrationStep as S, type TraversalBuilder as T, resolveView as U, type ViewContext as V, type WhereClause as W, type DynamicGraphClient as a, type GraphClient as b, type GraphRegistry as c, type DiscoveryResult as d, type GraphReader as e, type GraphRecord as f, type FindNodesParams as g, type MigrationFn as h, type MigrationStep as i, type StoredGraphRecord as j, type MigrationWriteBack as k, type QueryFilter as l, type BulkOptions as m, type BulkProgress as n, type BulkResult as o, type CodegenOptions as p, type DefineTypeOptions as q, type DiscoveredEntity as r, type EdgeTypeData as s, type FiregraphConfig as t, type GraphBatch as u, type GraphTransaction as v, type GraphWriter as w, type HopResult as x, type QueryMode as y, type QueryOptions as z };
644
+ export { type TraversalOptions as A, type BulkOptions as B, type CascadeResult as C, type DynamicRegistryConfig as D, type EdgeTopology as E, type FindEdgesParams as F, type GraphClientOptions as G, type HopDefinition as H, type TraversalResult as I, type ViewDefaultsConfig as J, type ViewResolverConfig as K, defineConfig as L, type MigrationExecutor as M, type NodeTypeData as N, resolveView as O, type QueryFilter as Q, type RegistryEntry as R, type StoredGraphRecord as S, type TraversalBuilder as T, type ViewContext as V, type WhereClause as W, type DynamicGraphClient as a, type GraphClient as b, type QueryOptions as c, type GraphReader as d, type BulkResult as e, type DiscoveryResult as f, type GraphRegistry as g, type MigrationWriteBack as h, type MigrationStep as i, type QueryPlan as j, type FindNodesParams as k, type GraphRecord as l, type MigrationFn as m, type StoredMigrationStep as n, type BulkBatchError as o, type BulkProgress as p, type DefineTypeOptions as q, type DiscoveredEntity as r, type EdgeTypeData as s, type FiregraphConfig as t, type GraphBatch as u, type GraphTransaction as v, type GraphWriter as w, type HopResult as x, type QueryMode as y, type ScanProtection as z };
@@ -104,6 +104,24 @@ declare function defineConfig(config: FiregraphConfig): FiregraphConfig;
104
104
  */
105
105
  declare function resolveView(resolverConfig: ViewResolverConfig | undefined, availableViewNames: string[], context?: ViewContext): string;
106
106
 
107
+ /**
108
+ * Backend-agnostic timestamp.
109
+ *
110
+ * Structurally compatible with `@google-cloud/firestore`'s `Timestamp` so
111
+ * that records returned by either the Firestore or SQLite backend can be
112
+ * consumed through the same `StoredGraphRecord` shape.
113
+ *
114
+ * Firestore's native `Timestamp` already satisfies this interface, so
115
+ * existing Firestore consumers see no behavior change. The SQLite backend
116
+ * returns instances of `GraphTimestampImpl` which also satisfies it.
117
+ */
118
+ interface GraphTimestamp {
119
+ readonly seconds: number;
120
+ readonly nanoseconds: number;
121
+ toDate(): Date;
122
+ toMillis(): number;
123
+ }
124
+
107
125
  interface GraphRecord {
108
126
  aType: string;
109
127
  aUid: string;
@@ -123,8 +141,13 @@ interface StoredGraphRecord {
123
141
  bType: string;
124
142
  bUid: string;
125
143
  data: Record<string, unknown>;
126
- createdAt: Timestamp;
127
- updatedAt: Timestamp;
144
+ /**
145
+ * Backend-agnostic timestamp. Firestore returns its native `Timestamp`
146
+ * (which structurally satisfies `GraphTimestamp`); the SQLite backends
147
+ * return a `GraphTimestampImpl` instance.
148
+ */
149
+ createdAt: GraphTimestamp;
150
+ updatedAt: GraphTimestamp;
128
151
  /** Schema version — set automatically when the registry entry has migrations. */
129
152
  v?: number;
130
153
  }
@@ -618,26 +641,4 @@ interface CascadeResult extends BulkResult {
618
641
  nodeDeleted: boolean;
619
642
  }
620
643
 
621
- /**
622
- * Code generation — produces TypeScript type definitions from JSON Schema
623
- * files discovered via the entity folder convention.
624
- *
625
- * Uses `json-schema-to-typescript` to compile each entity's `schema.json`
626
- * into a TypeScript interface.
627
- *
628
- * Naming convention:
629
- * - Nodes: `{PascalName}Data` (e.g. `TaskData`)
630
- * - Edges: `{PascalName}EdgeData` (e.g. `HasStepEdgeData`)
631
- */
632
-
633
- interface CodegenOptions {
634
- /** Add banner comment at top of output. Defaults to true. */
635
- banner?: boolean;
636
- }
637
- /**
638
- * Generate TypeScript type definitions from a DiscoveryResult.
639
- * Returns the full file content as a string.
640
- */
641
- declare function generateTypes(discovery: DiscoveryResult, options?: CodegenOptions): Promise<string>;
642
-
643
- export { type ScanProtection as A, type BulkBatchError as B, type CascadeResult as C, type DynamicRegistryConfig as D, type EdgeTopology as E, type FindEdgesParams as F, type GraphClientOptions as G, type HopDefinition as H, type TraversalOptions as I, type TraversalResult as J, type ViewDefaultsConfig as K, type ViewResolverConfig as L, type MigrationExecutor as M, type NodeTypeData as N, defineConfig as O, generateTypes as P, type QueryPlan as Q, type RegistryEntry as R, type StoredMigrationStep as S, type TraversalBuilder as T, resolveView as U, type ViewContext as V, type WhereClause as W, type DynamicGraphClient as a, type GraphClient as b, type GraphRegistry as c, type DiscoveryResult as d, type GraphReader as e, type GraphRecord as f, type FindNodesParams as g, type MigrationFn as h, type MigrationStep as i, type StoredGraphRecord as j, type MigrationWriteBack as k, type QueryFilter as l, type BulkOptions as m, type BulkProgress as n, type BulkResult as o, type CodegenOptions as p, type DefineTypeOptions as q, type DiscoveredEntity as r, type EdgeTypeData as s, type FiregraphConfig as t, type GraphBatch as u, type GraphTransaction as v, type GraphWriter as w, type HopResult as x, type QueryMode as y, type QueryOptions as z };
644
+ export { type TraversalOptions as A, type BulkOptions as B, type CascadeResult as C, type DynamicRegistryConfig as D, type EdgeTopology as E, type FindEdgesParams as F, type GraphClientOptions as G, type HopDefinition as H, type TraversalResult as I, type ViewDefaultsConfig as J, type ViewResolverConfig as K, defineConfig as L, type MigrationExecutor as M, type NodeTypeData as N, resolveView as O, type QueryFilter as Q, type RegistryEntry as R, type StoredGraphRecord as S, type TraversalBuilder as T, type ViewContext as V, type WhereClause as W, type DynamicGraphClient as a, type GraphClient as b, type QueryOptions as c, type GraphReader as d, type BulkResult as e, type DiscoveryResult as f, type GraphRegistry as g, type MigrationWriteBack as h, type MigrationStep as i, type QueryPlan as j, type FindNodesParams as k, type GraphRecord as l, type MigrationFn as m, type StoredMigrationStep as n, type BulkBatchError as o, type BulkProgress as p, type DefineTypeOptions as q, type DiscoveredEntity as r, type EdgeTypeData as s, type FiregraphConfig as t, type GraphBatch as u, type GraphTransaction as v, type GraphWriter as w, type HopResult as x, type QueryMode as y, type ScanProtection as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typicalday/firegraph",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "Generic Firestore adjacency graph client with smart query planning",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -46,6 +46,26 @@
46
46
  "types": "./dist/query-client/index.d.cts",
47
47
  "default": "./dist/query-client/index.cjs"
48
48
  }
49
+ },
50
+ "./d1": {
51
+ "import": {
52
+ "types": "./dist/d1.d.ts",
53
+ "default": "./dist/d1.js"
54
+ },
55
+ "require": {
56
+ "types": "./dist/d1.d.cts",
57
+ "default": "./dist/d1.cjs"
58
+ }
59
+ },
60
+ "./do-sqlite": {
61
+ "import": {
62
+ "types": "./dist/do-sqlite.d.ts",
63
+ "default": "./dist/do-sqlite.js"
64
+ },
65
+ "require": {
66
+ "types": "./dist/do-sqlite.d.cts",
67
+ "default": "./dist/do-sqlite.cjs"
68
+ }
49
69
  }
50
70
  },
51
71
  "bin": {
@@ -72,6 +92,7 @@
72
92
  "test": "vitest run",
73
93
  "test:unit": "vitest run tests/unit/",
74
94
  "test:integration": "vitest run tests/integration/",
95
+ "test:sqlite:integration": "BACKEND=sqlite vitest run tests/integration/",
75
96
  "test:emulator": "bash tests/scripts/test-with-emulator.sh",
76
97
  "test:emulator:unit": "bash tests/scripts/test-with-emulator.sh tests/unit/",
77
98
  "test:emulator:integration": "bash tests/scripts/test-with-emulator.sh tests/integration/",
@@ -111,9 +132,11 @@
111
132
  "@commitlint/cli": "^20.5.0",
112
133
  "@commitlint/config-conventional": "^20.5.0",
113
134
  "@google-cloud/firestore": "^8.3.0",
135
+ "@types/better-sqlite3": "^7.6.13",
114
136
  "@typescript-eslint/eslint-plugin": "^8.57.2",
115
137
  "@typescript-eslint/parser": "^8.57.2",
116
138
  "@vitest/coverage-v8": "^3.0.0",
139
+ "better-sqlite3": "^12.9.0",
117
140
  "eslint": "^10.1.0",
118
141
  "eslint-config-prettier": "^10.1.8",
119
142
  "eslint-plugin-simple-import-sort": "^12.1.1",