@typicalday/firegraph 0.1.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.
Files changed (48) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +527 -0
  3. package/bin/firegraph.mjs +129 -0
  4. package/dist/chunk-KFA7G37W.js +443 -0
  5. package/dist/chunk-KFA7G37W.js.map +1 -0
  6. package/dist/chunk-YLGXLEUE.js +47 -0
  7. package/dist/chunk-YLGXLEUE.js.map +1 -0
  8. package/dist/client-Bk2Cm6xv.d.cts +131 -0
  9. package/dist/client-Bk2Cm6xv.d.ts +131 -0
  10. package/dist/codegen/index.cjs +81 -0
  11. package/dist/codegen/index.cjs.map +1 -0
  12. package/dist/codegen/index.d.cts +2 -0
  13. package/dist/codegen/index.d.ts +2 -0
  14. package/dist/codegen/index.js +7 -0
  15. package/dist/codegen/index.js.map +1 -0
  16. package/dist/editor/client/assets/index-DJJ_b0jI.js +411 -0
  17. package/dist/editor/client/assets/index-Q0QBYrMV.css +1 -0
  18. package/dist/editor/client/index.html +16 -0
  19. package/dist/editor/server/index.mjs +49597 -0
  20. package/dist/index-CG3R68Hu.d.cts +414 -0
  21. package/dist/index-CG3R68Hu.d.ts +414 -0
  22. package/dist/index.cjs +1953 -0
  23. package/dist/index.cjs.map +1 -0
  24. package/dist/index.d.cts +186 -0
  25. package/dist/index.d.ts +186 -0
  26. package/dist/index.js +1569 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/query-client/index.cjs +484 -0
  29. package/dist/query-client/index.cjs.map +1 -0
  30. package/dist/query-client/index.d.cts +15 -0
  31. package/dist/query-client/index.d.ts +15 -0
  32. package/dist/query-client/index.js +17 -0
  33. package/dist/query-client/index.js.map +1 -0
  34. package/dist/react.cjs +85 -0
  35. package/dist/react.cjs.map +1 -0
  36. package/dist/react.d.cts +44 -0
  37. package/dist/react.d.ts +44 -0
  38. package/dist/react.js +60 -0
  39. package/dist/react.js.map +1 -0
  40. package/dist/svelte.cjs +90 -0
  41. package/dist/svelte.cjs.map +1 -0
  42. package/dist/svelte.d.cts +46 -0
  43. package/dist/svelte.d.ts +46 -0
  44. package/dist/svelte.js +65 -0
  45. package/dist/svelte.js.map +1 -0
  46. package/dist/views-DL60k0cf.d.cts +91 -0
  47. package/dist/views-DL60k0cf.d.ts +91 -0
  48. package/package.json +122 -0
@@ -0,0 +1,186 @@
1
+ import { Firestore } from '@google-cloud/firestore';
2
+ import { G as GraphClientOptions, D as DynamicRegistryConfig, a as DynamicGraphClient, b as GraphClient, R as RegistryEntry, c as DiscoveryResult, d as GraphRegistry, e as GraphReader, f as GraphRecord, F as FindEdgesParams, Q as QueryPlan, g as FindNodesParams, T as TraversalBuilder } from './index-CG3R68Hu.js';
3
+ export { B as BulkBatchError, h as BulkOptions, i as BulkProgress, j as BulkResult, C as CascadeResult, k as CodegenOptions, l as DefineTypeOptions, m as DiscoveredEntity, E as EdgeTopology, n as EdgeTypeData, o as FiregraphConfig, p as GraphBatch, q as GraphTransaction, r as GraphWriter, H as HopDefinition, s as HopResult, N as NodeTypeData, t as QueryFilter, u as QueryMode, v as QueryOptions, S as StoredGraphRecord, w as TraversalOptions, x as TraversalResult, V as ViewContext, y as ViewDefaultsConfig, z as ViewResolverConfig, W as WhereClause, A as defineConfig, I as generateTypes, J as resolveView } from './index-CG3R68Hu.js';
4
+ export { E as EntityViewConfig, a as EntityViewMeta, V as ViewComponentClass, b as ViewMeta, c as ViewRegistry, d as ViewRegistryInput, e as defineViews } from './views-DL60k0cf.js';
5
+ export { Q as QueryClient, a as QueryClientError, b as QueryClientErrorCode, c as QueryClientOptions } from './client-Bk2Cm6xv.js';
6
+
7
+ declare function createGraphClient(db: Firestore, collectionPath: string, options: GraphClientOptions & {
8
+ registryMode: DynamicRegistryConfig;
9
+ }): DynamicGraphClient;
10
+ declare function createGraphClient(db: Firestore, collectionPath: string, options?: GraphClientOptions): GraphClient;
11
+
12
+ /**
13
+ * Build a registry from either explicit entries or a DiscoveryResult.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * // From explicit entries (programmatic)
18
+ * const registry = createRegistry([
19
+ * { aType: 'user', axbType: 'is', bType: 'user', jsonSchema: userSchema },
20
+ * { aType: 'user', axbType: 'follows', bType: 'user', jsonSchema: followsSchema },
21
+ * ]);
22
+ *
23
+ * // From discovery result (folder convention)
24
+ * const discovered = await discoverEntities('./entities');
25
+ * const registry = createRegistry(discovered);
26
+ * ```
27
+ */
28
+ declare function createRegistry(input: RegistryEntry[] | DiscoveryResult): GraphRegistry;
29
+
30
+ /** The aType used for node type definition meta-nodes. */
31
+ declare const META_NODE_TYPE = "nodeType";
32
+ /** The aType used for edge type definition meta-nodes. */
33
+ declare const META_EDGE_TYPE = "edgeType";
34
+ /** JSON Schema for the `data` payload of a `nodeType` meta-node. */
35
+ declare const NODE_TYPE_SCHEMA: object;
36
+ /** JSON Schema for the `data` payload of an `edgeType` meta-node. */
37
+ declare const EDGE_TYPE_SCHEMA: object;
38
+ /** Registry entries for the two meta-types (always present). */
39
+ declare const BOOTSTRAP_ENTRIES: readonly RegistryEntry[];
40
+ /**
41
+ * Build the bootstrap registry that validates meta-type writes.
42
+ * This is always available, even before any dynamic types are loaded.
43
+ */
44
+ declare function createBootstrapRegistry(): GraphRegistry;
45
+ /**
46
+ * Generate a deterministic UID for a meta-type definition.
47
+ * This ensures that defining the same type name always targets the same
48
+ * Firestore document, enabling upsert semantics.
49
+ *
50
+ * Format: 21-char base64url substring of SHA-256(`metaType:name`).
51
+ */
52
+ declare function generateDeterministicUid(metaType: string, name: string): string;
53
+ /**
54
+ * Read meta-type nodes from the graph and compile them into a GraphRegistry.
55
+ *
56
+ * The returned registry includes both the dynamic entries AND the bootstrap
57
+ * meta-type entries, so meta-type writes remain validateable after a reload.
58
+ *
59
+ * @param reader - A GraphReader pointed at the collection containing meta-nodes.
60
+ */
61
+ declare function createRegistryFromGraph(reader: GraphReader): Promise<GraphRegistry>;
62
+
63
+ declare function generateId(): string;
64
+
65
+ declare function computeNodeDocId(uid: string): string;
66
+ declare function computeEdgeDocId(aUid: string, axbType: string, bUid: string): string;
67
+
68
+ declare function buildNodeRecord(aType: string, uid: string, data: Record<string, unknown>): GraphRecord;
69
+ declare function buildEdgeRecord(aType: string, aUid: string, axbType: string, bType: string, bUid: string, data: Record<string, unknown>): GraphRecord;
70
+
71
+ declare function buildEdgeQueryPlan(params: FindEdgesParams): QueryPlan;
72
+ declare function buildNodeQueryPlan(params: FindNodesParams): QueryPlan;
73
+
74
+ declare function createTraversal(reader: GraphReader, startUid: string): TraversalBuilder;
75
+
76
+ declare class FiregraphError extends Error {
77
+ readonly code: string;
78
+ constructor(message: string, code: string);
79
+ }
80
+ declare class NodeNotFoundError extends FiregraphError {
81
+ constructor(uid: string);
82
+ }
83
+ declare class EdgeNotFoundError extends FiregraphError {
84
+ constructor(aUid: string, axbType: string, bUid: string);
85
+ }
86
+ declare class ValidationError extends FiregraphError {
87
+ readonly details?: unknown | undefined;
88
+ constructor(message: string, details?: unknown | undefined);
89
+ }
90
+ declare class RegistryViolationError extends FiregraphError {
91
+ constructor(aType: string, axbType: string, bType: string);
92
+ }
93
+ declare class InvalidQueryError extends FiregraphError {
94
+ constructor(message: string);
95
+ }
96
+ declare class TraversalError extends FiregraphError {
97
+ constructor(message: string);
98
+ }
99
+ declare class DynamicRegistryError extends FiregraphError {
100
+ constructor(message: string);
101
+ }
102
+
103
+ /**
104
+ * Entity Discovery — convention-based auto-discovery of entities from
105
+ * a per-entity folder structure.
106
+ *
107
+ * Scans `entitiesDir/nodes/` and `entitiesDir/edges/` subdirectories.
108
+ * Each subfolder is treated as an entity type.
109
+ *
110
+ * Schema files can be either `schema.json` (plain JSON Schema) or
111
+ * `schema.ts` / `schema.js` (a module whose default export is a JSON Schema
112
+ * object). When both exist, the TS/JS file takes precedence so that authors
113
+ * can compose schemas programmatically while keeping a JSON fallback.
114
+ *
115
+ * @example
116
+ * ```
117
+ * entities/
118
+ * nodes/
119
+ * task/
120
+ * schema.json | schema.ts (required — one or both)
121
+ * views.ts (optional)
122
+ * sample.json (optional)
123
+ * meta.json (optional)
124
+ * edges/
125
+ * hasStep/
126
+ * schema.json | schema.ts (required — one or both)
127
+ * edge.json (required — topology)
128
+ * views.ts (optional)
129
+ * sample.json (optional)
130
+ * meta.json (optional)
131
+ * ```
132
+ */
133
+
134
+ declare class DiscoveryError extends FiregraphError {
135
+ constructor(message: string);
136
+ }
137
+ interface DiscoveryWarning {
138
+ code: 'DANGLING_TOPOLOGY_REF';
139
+ message: string;
140
+ }
141
+ interface DiscoverResult {
142
+ result: DiscoveryResult;
143
+ warnings: DiscoveryWarning[];
144
+ }
145
+ /**
146
+ * Scan an entities directory and return all discovered nodes and edges.
147
+ *
148
+ * @param entitiesDir - Path to the entities directory (absolute or relative to cwd)
149
+ * @returns Discovery result with nodes and edges maps, plus any warnings
150
+ */
151
+ declare function discoverEntities(entitiesDir: string): DiscoverResult;
152
+
153
+ /**
154
+ * JSON Schema validation and introspection utilities.
155
+ *
156
+ * Standard JSON Schema validation and introspection
157
+ * processing. Uses ajv for validation and a recursive walker for converting
158
+ * JSON Schema properties into FieldMeta objects for editor form generation.
159
+ */
160
+ interface FieldMeta {
161
+ name: string;
162
+ type: 'string' | 'number' | 'boolean' | 'enum' | 'array' | 'object' | 'unknown';
163
+ required: boolean;
164
+ description?: string;
165
+ enumValues?: string[];
166
+ minLength?: number;
167
+ maxLength?: number;
168
+ pattern?: string;
169
+ min?: number;
170
+ max?: number;
171
+ isInt?: boolean;
172
+ itemMeta?: FieldMeta;
173
+ fields?: FieldMeta[];
174
+ }
175
+ /**
176
+ * Compile a JSON Schema into a validation function.
177
+ * The returned function throws `ValidationError` if data is invalid.
178
+ */
179
+ declare function compileSchema(schema: object, label?: string): (data: unknown) => void;
180
+ /**
181
+ * Convert a JSON Schema (expected to be `type: "object"`) into `FieldMeta[]`
182
+ * suitable for the editor's SchemaForm component.
183
+ */
184
+ declare function jsonSchemaToFieldMeta(schema: any): FieldMeta[];
185
+
186
+ export { BOOTSTRAP_ENTRIES, type DiscoverResult, DiscoveryError, DiscoveryResult, type DiscoveryWarning, DynamicGraphClient, DynamicRegistryConfig, DynamicRegistryError, EDGE_TYPE_SCHEMA, EdgeNotFoundError, type FieldMeta, FindEdgesParams, FindNodesParams, FiregraphError, GraphClient, GraphClientOptions, GraphReader, GraphRecord, GraphRegistry, InvalidQueryError, META_EDGE_TYPE, META_NODE_TYPE, NODE_TYPE_SCHEMA, NodeNotFoundError, QueryPlan, RegistryEntry, RegistryViolationError, TraversalBuilder, TraversalError, ValidationError, buildEdgeQueryPlan, buildEdgeRecord, buildNodeQueryPlan, buildNodeRecord, compileSchema, computeEdgeDocId, computeNodeDocId, createBootstrapRegistry, createGraphClient, createRegistry, createRegistryFromGraph, createTraversal, discoverEntities, generateDeterministicUid, generateId, jsonSchemaToFieldMeta };