@xnetjs/react 0.0.2 → 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.
- package/README.md +206 -2
- package/dist/chunk-6VOICQZ3.js +760 -0
- package/dist/chunk-7OQXRHEQ.js +4649 -0
- package/dist/chunk-EJ5RW5GI.js +93 -0
- package/dist/chunk-IHTMVTTE.js +1108 -0
- package/dist/chunk-JCOFKBOB.js +11 -0
- package/dist/chunk-KSHTDZ2V.js +893 -0
- package/dist/chunk-QHNYQVUM.js +989 -0
- package/dist/context-CFu9i136.d.ts +392 -0
- package/dist/core.d.ts +372 -0
- package/dist/core.js +29 -0
- package/dist/database.d.ts +383 -0
- package/dist/database.js +19 -0
- package/dist/experimental-B2FrBnkV.d.ts +1584 -0
- package/dist/experimental.d.ts +15 -0
- package/dist/experimental.js +248 -0
- package/dist/index.d.ts +601 -2700
- package/dist/index.js +4782 -4427
- package/dist/{instrumentation-Cn94kn8-.d.ts → instrumentation-CpIuG2y5.d.ts} +32 -1
- package/dist/internal.d.ts +32 -22
- package/dist/internal.js +16 -4
- package/dist/telemetry-context-B7r6H1KW.d.ts +35 -0
- package/dist/useNodeStore-DTCSBF51.d.ts +28 -0
- package/dist/useQuery-D7ajycrc.d.ts +302 -0
- package/package.json +28 -10
- package/dist/chunk-CWHCGYDW.js +0 -2238
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
+
import { QueryCompletenessMetadata, QueryStalenessMetadata, QueryVerificationMetadata, QueryStreamMetadata } from '@xnetjs/data-bridge';
|
|
2
3
|
import * as Y from 'yjs';
|
|
3
4
|
|
|
5
|
+
interface QueryTrackerPlanInfo {
|
|
6
|
+
strategy?: string;
|
|
7
|
+
candidateNodeCount?: number;
|
|
8
|
+
hydratedNodeCount?: number;
|
|
9
|
+
returnedNodeCount?: number;
|
|
10
|
+
durationMs?: number;
|
|
11
|
+
descriptorHash?: string;
|
|
12
|
+
candidateAccelerators?: string[];
|
|
13
|
+
materializedViewId?: string;
|
|
14
|
+
materializedCacheHit?: boolean;
|
|
15
|
+
materializedRefreshReason?: string;
|
|
16
|
+
}
|
|
17
|
+
interface QueryTrackerMaterializedInfo {
|
|
18
|
+
viewId: string;
|
|
19
|
+
cacheHit: boolean;
|
|
20
|
+
generatedAt: number;
|
|
21
|
+
invalidatedAt?: number;
|
|
22
|
+
rowCount: number;
|
|
23
|
+
}
|
|
24
|
+
interface QueryTrackerUpdateMetadata {
|
|
25
|
+
source?: string;
|
|
26
|
+
plan?: QueryTrackerPlanInfo | null;
|
|
27
|
+
materialized?: QueryTrackerMaterializedInfo | null;
|
|
28
|
+
completeness?: QueryCompletenessMetadata | null;
|
|
29
|
+
staleness?: QueryStalenessMetadata | null;
|
|
30
|
+
verification?: QueryVerificationMetadata | null;
|
|
31
|
+
stream?: QueryStreamMetadata | null;
|
|
32
|
+
}
|
|
4
33
|
/**
|
|
5
34
|
* Query tracker interface (implemented by @xnetjs/devtools QueryTracker)
|
|
6
35
|
*/
|
|
@@ -10,10 +39,12 @@ interface QueryTrackerLike {
|
|
|
10
39
|
schemaId: string;
|
|
11
40
|
mode: 'list' | 'single' | 'filtered' | 'document';
|
|
12
41
|
filter?: Record<string, unknown>;
|
|
42
|
+
descriptorKey?: string;
|
|
13
43
|
nodeId?: string;
|
|
14
44
|
callerInfo?: string;
|
|
15
45
|
}): void;
|
|
16
|
-
recordUpdate(id: string, resultCount: number, renderTime: number): void;
|
|
46
|
+
recordUpdate(id: string, resultCount: number, renderTime: number, metadata?: QueryTrackerUpdateMetadata): void;
|
|
47
|
+
recordStreamEvent?(id: string, stream: QueryStreamMetadata, resultCount: number, metadata?: Pick<QueryTrackerUpdateMetadata, 'source'>): void;
|
|
17
48
|
recordError(id: string, error: string): void;
|
|
18
49
|
unregister(id: string): void;
|
|
19
50
|
}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,31 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { N as NodeStoreContextValue, u as useNodeStore } from './useNodeStore-DTCSBF51.js';
|
|
2
|
+
import { DID } from '@xnetjs/core';
|
|
3
|
+
import { NodeId } from '@xnetjs/data';
|
|
4
|
+
import { UndoManagerOptions } from '@xnetjs/history';
|
|
5
|
+
export { I as InstrumentationContext, a as InstrumentationContextValue, Q as QueryTrackerLike, Y as YDocRegistryLike, u as useInstrumentation } from './instrumentation-CpIuG2y5.js';
|
|
6
|
+
export { X as XNetContextValue, c as XNetInternalContextValue, d as XNetRuntimeStatus, u as useDataBridge, a as useXNet, b as useXNetInternal } from './context-CFu9i136.js';
|
|
3
7
|
import 'react';
|
|
8
|
+
import '@xnetjs/data-bridge';
|
|
4
9
|
import 'yjs';
|
|
10
|
+
import '@xnetjs/runtime';
|
|
11
|
+
import '@xnetjs/crypto';
|
|
12
|
+
import '@xnetjs/identity';
|
|
13
|
+
import '@xnetjs/sync';
|
|
14
|
+
import '@xnetjs/plugins';
|
|
15
|
+
import './telemetry-context-B7r6H1KW.js';
|
|
5
16
|
|
|
6
17
|
/**
|
|
7
|
-
*
|
|
18
|
+
* useUndoScope - Internal hook for scoped undo/redo across multiple nodes.
|
|
8
19
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
20
|
+
* Wraps UndoManager's scoped helpers so app surfaces can treat a composite
|
|
21
|
+
* model like "database node plus visible rows" as one undo domain.
|
|
11
22
|
*/
|
|
12
23
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
store: NodeStore | null;
|
|
19
|
-
/** Whether the store is initialized and ready */
|
|
20
|
-
isReady: boolean;
|
|
21
|
-
/** Any initialization error */
|
|
22
|
-
error: Error | null;
|
|
24
|
+
interface UseUndoScopeOptions {
|
|
25
|
+
/** The local user's DID. When absent, undo is disabled until identity is ready. */
|
|
26
|
+
localDID: DID | null;
|
|
27
|
+
/** UndoManager configuration overrides */
|
|
28
|
+
options?: Partial<UndoManagerOptions>;
|
|
23
29
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
interface UseUndoScopeResult {
|
|
31
|
+
undo: () => Promise<boolean>;
|
|
32
|
+
redo: () => Promise<boolean>;
|
|
33
|
+
canUndo: boolean;
|
|
34
|
+
canRedo: boolean;
|
|
35
|
+
undoCount: number;
|
|
36
|
+
redoCount: number;
|
|
37
|
+
clear: () => void;
|
|
38
|
+
}
|
|
39
|
+
declare function useUndoScope(nodeIds: NodeId[], opts: UseUndoScopeOptions): UseUndoScopeResult;
|
|
30
40
|
|
|
31
|
-
export { type
|
|
41
|
+
export { type UseUndoScopeOptions, type UseUndoScopeResult, useUndoScope };
|
package/dist/internal.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useUndoScope
|
|
3
|
+
} from "./chunk-EJ5RW5GI.js";
|
|
1
4
|
import {
|
|
2
5
|
InstrumentationContext,
|
|
3
|
-
useInstrumentation
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
useInstrumentation
|
|
7
|
+
} from "./chunk-JCOFKBOB.js";
|
|
8
|
+
import {
|
|
9
|
+
useDataBridge,
|
|
10
|
+
useNodeStore,
|
|
11
|
+
useXNet,
|
|
12
|
+
useXNetInternal
|
|
13
|
+
} from "./chunk-IHTMVTTE.js";
|
|
6
14
|
export {
|
|
7
15
|
InstrumentationContext,
|
|
16
|
+
useDataBridge,
|
|
8
17
|
useInstrumentation,
|
|
9
|
-
useNodeStore
|
|
18
|
+
useNodeStore,
|
|
19
|
+
useUndoScope,
|
|
20
|
+
useXNet,
|
|
21
|
+
useXNetInternal
|
|
10
22
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Telemetry context for @xnetjs/react
|
|
5
|
+
*
|
|
6
|
+
* Provides an optional duck-typed TelemetryReporter to the React tree.
|
|
7
|
+
* When present, hooks report performance timing, usage counts, and errors.
|
|
8
|
+
*
|
|
9
|
+
* Uses the same duck-typed interface pattern as other xNet packages to
|
|
10
|
+
* avoid circular dependencies with @xnetjs/telemetry.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Duck-typed interface for telemetry reporting.
|
|
14
|
+
* Satisfied by @xnetjs/telemetry's TelemetryCollector or any compatible object.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { TelemetryCollector } from '@xnetjs/telemetry'
|
|
19
|
+
* const telemetry = new TelemetryCollector({ consent })
|
|
20
|
+
* // Pass to XNetProvider via config.telemetry
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
interface TelemetryReporter {
|
|
24
|
+
reportPerformance(metricName: string, durationMs: number): void;
|
|
25
|
+
reportUsage(metricName: string, count: number): void;
|
|
26
|
+
reportCrash(error: Error, context?: Record<string, unknown>): void;
|
|
27
|
+
}
|
|
28
|
+
declare const TelemetryContext: react.Context<TelemetryReporter | null>;
|
|
29
|
+
/**
|
|
30
|
+
* Hook to access the telemetry reporter (null if no telemetry configured).
|
|
31
|
+
* @internal Used by useQuery/useMutate - not part of public API.
|
|
32
|
+
*/
|
|
33
|
+
declare function useTelemetryReporter(): TelemetryReporter | null;
|
|
34
|
+
|
|
35
|
+
export { type TelemetryReporter as T, TelemetryContext as a, useTelemetryReporter as u };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { NodeStore } from '@xnetjs/data';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* useNodeStore hook - internal access to the NodeStore from XNetProvider context.
|
|
5
|
+
*
|
|
6
|
+
* This is NOT part of the public API. Use useQuery/useMutate/useNode instead.
|
|
7
|
+
* Only @xnetjs/devtools uses this via the @xnetjs/react/internal subpath.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* NodeStore context value
|
|
12
|
+
*/
|
|
13
|
+
interface NodeStoreContextValue {
|
|
14
|
+
/** The NodeStore instance */
|
|
15
|
+
store: NodeStore | null;
|
|
16
|
+
/** Whether the store is initialized and ready */
|
|
17
|
+
isReady: boolean;
|
|
18
|
+
/** Any initialization error */
|
|
19
|
+
error: Error | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Hook to access the NodeStore from XNetProvider context.
|
|
23
|
+
*
|
|
24
|
+
* @internal Not part of the public API.
|
|
25
|
+
*/
|
|
26
|
+
declare function useNodeStore(): NodeStoreContextValue;
|
|
27
|
+
|
|
28
|
+
export { type NodeStoreContextValue as N, useNodeStore as u };
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { PropertyBuilder, SchemaIRI, MigrationInfo, InferCreateProps, NodeState, MigratedNodeState, DefinedSchema } from '@xnetjs/data';
|
|
2
|
+
import { QuerySource, QueryMaterializedMetadata, QueryCompletenessMetadata, QueryStalenessMetadata, QueryVerificationMetadata, QueryStreamMetadata, QueryPageInfo, QueryPageOptions, QuerySpatialFilter, QuerySearchFilter, QueryMaterializedViewOptions, QueryExecutionMode, QuerySourcePreference } from '@xnetjs/data-bridge';
|
|
3
|
+
import { DID } from '@xnetjs/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* FlatNode utilities - Flatten NodeState properties to top level
|
|
7
|
+
*
|
|
8
|
+
* This module provides type-safe flattening of Node properties so developers
|
|
9
|
+
* can access `node.title` instead of `node.properties.title`.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Base node fields (always present on any node)
|
|
14
|
+
*/
|
|
15
|
+
interface NodeBase {
|
|
16
|
+
/** Unique node identifier */
|
|
17
|
+
id: string;
|
|
18
|
+
/** Schema IRI this node conforms to */
|
|
19
|
+
schemaId: SchemaIRI;
|
|
20
|
+
/** Creation timestamp */
|
|
21
|
+
createdAt: number;
|
|
22
|
+
/** Creator's DID */
|
|
23
|
+
createdBy: DID;
|
|
24
|
+
/** Last update timestamp */
|
|
25
|
+
updatedAt: number;
|
|
26
|
+
/** Last updater's DID */
|
|
27
|
+
updatedBy: DID;
|
|
28
|
+
/** Whether node is soft-deleted */
|
|
29
|
+
deleted: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* True if this node's schema is not registered/known to the current app version.
|
|
32
|
+
* The node data is still accessible but may not have proper type information.
|
|
33
|
+
* UI should render a generic "Unknown data type" component for these nodes.
|
|
34
|
+
*/
|
|
35
|
+
_unknownSchema?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Properties from future schema versions that aren't known to the current schema.
|
|
38
|
+
* Preserved for forward compatibility - can be displayed in a "raw data" view.
|
|
39
|
+
*/
|
|
40
|
+
_unknown?: Record<string, unknown>;
|
|
41
|
+
/**
|
|
42
|
+
* The schema version that last wrote to this node.
|
|
43
|
+
* Useful for detecting when migrations might be needed.
|
|
44
|
+
*/
|
|
45
|
+
_schemaVersion?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The original schema IRI this node was migrated from.
|
|
48
|
+
* Only present if the node was automatically migrated on read.
|
|
49
|
+
*/
|
|
50
|
+
_migratedFrom?: SchemaIRI;
|
|
51
|
+
/**
|
|
52
|
+
* Full migration info if the node was migrated.
|
|
53
|
+
* Includes lossless flag and any warnings about data loss.
|
|
54
|
+
*/
|
|
55
|
+
_migrationInfo?: MigrationInfo;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A flattened node with properties at the top level.
|
|
59
|
+
*
|
|
60
|
+
* Instead of `node.properties.title`, access `node.title` directly.
|
|
61
|
+
* All property types are correctly inferred from the schema.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```tsx
|
|
65
|
+
* const { data } = useQuery(TaskSchema, id)
|
|
66
|
+
* // data is FlatNode<typeof TaskSchema._properties>
|
|
67
|
+
*
|
|
68
|
+
* console.log(data.title) // string - correctly typed!
|
|
69
|
+
* console.log(data.status) // 'todo' | 'done' - union type!
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
type FlatNode<P extends Record<string, PropertyBuilder>> = NodeBase & InferCreateProps<P>;
|
|
73
|
+
/**
|
|
74
|
+
* Options for flattenNode function
|
|
75
|
+
*/
|
|
76
|
+
interface FlattenNodeOptions {
|
|
77
|
+
/**
|
|
78
|
+
* Mark this node as having an unknown schema.
|
|
79
|
+
* This happens when the node's schemaId is not registered in the current app version.
|
|
80
|
+
*/
|
|
81
|
+
unknownSchema?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Migration info if the node was migrated from a different schema version.
|
|
84
|
+
*/
|
|
85
|
+
migrationInfo?: MigrationInfo;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Flatten a NodeState by spreading properties to top level.
|
|
89
|
+
*
|
|
90
|
+
* @param node - The NodeState with nested properties
|
|
91
|
+
* @param options - Optional settings for handling unknown schemas
|
|
92
|
+
* @returns A new object with properties flattened to top level
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* const nodeState = {
|
|
97
|
+
* id: '123',
|
|
98
|
+
* schemaId: 'xnet://xnet.fyi/Task',
|
|
99
|
+
* properties: { title: 'My Task', status: 'todo' },
|
|
100
|
+
* // ...
|
|
101
|
+
* }
|
|
102
|
+
*
|
|
103
|
+
* const flat = flattenNode(nodeState)
|
|
104
|
+
* // { id: '123', schemaId: '...', title: 'My Task', status: 'todo', ... }
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
declare function flattenNode<P extends Record<string, PropertyBuilder>>(node: NodeState | MigratedNodeState, options?: FlattenNodeOptions): FlatNode<P>;
|
|
108
|
+
/**
|
|
109
|
+
* Flatten an array of NodeState objects.
|
|
110
|
+
*/
|
|
111
|
+
declare function flattenNodes<P extends Record<string, PropertyBuilder>>(nodes: (NodeState | MigratedNodeState)[], options?: FlattenNodeOptions): FlatNode<P>[];
|
|
112
|
+
/**
|
|
113
|
+
* Create a FlatNode with unknown schema flag.
|
|
114
|
+
* Use this when displaying nodes whose schema is not registered.
|
|
115
|
+
*/
|
|
116
|
+
declare function flattenUnknownSchemaNode(node: NodeState): FlatNode<Record<string, PropertyBuilder>>;
|
|
117
|
+
/**
|
|
118
|
+
* Create FlatNodes from an array, marking those with unknown schemas.
|
|
119
|
+
*
|
|
120
|
+
* @param nodes - Array of NodeState objects
|
|
121
|
+
* @param isSchemaKnown - Function to check if a schema is registered
|
|
122
|
+
* @returns Array of FlatNodes with _unknownSchema set appropriately
|
|
123
|
+
*/
|
|
124
|
+
declare function flattenNodesWithSchemaCheck<P extends Record<string, PropertyBuilder>>(nodes: NodeState[], isSchemaKnown: (schemaId: string) => boolean): FlatNode<P>[];
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Shared derivations from bridge query metadata used by the read hooks
|
|
128
|
+
* (useQuery, useSavedView, useInfiniteQuery).
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
interface QueryPlanSummary {
|
|
132
|
+
strategy?: string;
|
|
133
|
+
candidateNodeCount?: number;
|
|
134
|
+
hydratedNodeCount?: number;
|
|
135
|
+
returnedNodeCount?: number;
|
|
136
|
+
durationMs?: number;
|
|
137
|
+
descriptorHash?: string;
|
|
138
|
+
candidateAccelerators?: string[];
|
|
139
|
+
materializedViewId?: string;
|
|
140
|
+
materializedCacheHit?: boolean;
|
|
141
|
+
materializedRefreshReason?: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* useQuery - Unified read hook for Nodes via DataBridge
|
|
146
|
+
*
|
|
147
|
+
* A single hook for all read operations:
|
|
148
|
+
* - List all nodes of a schema
|
|
149
|
+
* - Get a single node by ID
|
|
150
|
+
* - Query with filters
|
|
151
|
+
*
|
|
152
|
+
* Returns FlatNode with properties at top level for ergonomic access.
|
|
153
|
+
*
|
|
154
|
+
* Uses DataBridge for off-main-thread data access. The bridge handles
|
|
155
|
+
* caching and provides useSyncExternalStore-compatible subscriptions.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```tsx
|
|
159
|
+
* // List all tasks
|
|
160
|
+
* const { data: tasks } = useQuery(TaskSchema)
|
|
161
|
+
* tasks.forEach(task => console.log(task.title)) // Direct access!
|
|
162
|
+
*
|
|
163
|
+
* // Get single task by ID
|
|
164
|
+
* const { data: task } = useQuery(TaskSchema, taskId)
|
|
165
|
+
* console.log(task?.status) // Typed correctly!
|
|
166
|
+
*
|
|
167
|
+
* // Query with filters
|
|
168
|
+
* const { data: urgent } = useQuery(TaskSchema, {
|
|
169
|
+
* where: { status: 'urgent' },
|
|
170
|
+
* orderBy: { createdAt: 'desc' }
|
|
171
|
+
* })
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Sort direction
|
|
177
|
+
*/
|
|
178
|
+
type SortDirection = 'asc' | 'desc';
|
|
179
|
+
/**
|
|
180
|
+
* System fields that can be used for ordering
|
|
181
|
+
*/
|
|
182
|
+
type SystemOrderField = 'createdAt' | 'updatedAt';
|
|
183
|
+
/**
|
|
184
|
+
* Query filter options
|
|
185
|
+
*/
|
|
186
|
+
interface QueryFilter<P extends Record<string, PropertyBuilder> = Record<string, PropertyBuilder>> {
|
|
187
|
+
/** Filter conditions (property: value) */
|
|
188
|
+
where?: Partial<InferCreateProps<P>>;
|
|
189
|
+
/** Include soft-deleted nodes */
|
|
190
|
+
includeDeleted?: boolean;
|
|
191
|
+
/** Sort by property or system field (createdAt, updatedAt) */
|
|
192
|
+
orderBy?: {
|
|
193
|
+
[K in keyof InferCreateProps<P> | SystemOrderField]?: SortDirection;
|
|
194
|
+
};
|
|
195
|
+
/** Limit results */
|
|
196
|
+
limit?: number;
|
|
197
|
+
/** Offset for pagination */
|
|
198
|
+
offset?: number;
|
|
199
|
+
/** Recommended pagination option. `page.first` maps to the current bounded read limit. */
|
|
200
|
+
page?: QueryPageOptions;
|
|
201
|
+
/** Spatial filtering for viewport windows or radius-based 2D queries */
|
|
202
|
+
spatial?: QuerySpatialFilter;
|
|
203
|
+
/** Tokenized full-text search over searchable node fields */
|
|
204
|
+
search?: string | QuerySearchFilter;
|
|
205
|
+
/** Stable view cache key for storage-backed materialized result sets */
|
|
206
|
+
materializedView?: string | QueryMaterializedViewOptions;
|
|
207
|
+
/** Future execution mode hint. Current runtimes execute locally. */
|
|
208
|
+
mode?: QueryExecutionMode;
|
|
209
|
+
/** Future source preference hint for hub or federated reads. */
|
|
210
|
+
source?: QuerySourcePreference;
|
|
211
|
+
/** Disable bridge subscription while preserving a typed empty result. */
|
|
212
|
+
enabled?: boolean;
|
|
213
|
+
}
|
|
214
|
+
type QueryStatus = 'loading' | 'success' | 'error';
|
|
215
|
+
|
|
216
|
+
interface QueryBaseResult {
|
|
217
|
+
/** Query lifecycle status */
|
|
218
|
+
status: QueryStatus;
|
|
219
|
+
/** Whether currently loading */
|
|
220
|
+
loading: boolean;
|
|
221
|
+
/** Alias for loading */
|
|
222
|
+
isLoading: boolean;
|
|
223
|
+
/** Whether a fetch/reload is currently active */
|
|
224
|
+
isFetching: boolean;
|
|
225
|
+
/** Whether the query is backed by a live subscription */
|
|
226
|
+
isLive: boolean;
|
|
227
|
+
/** Source that produced the current snapshot */
|
|
228
|
+
source: QuerySource;
|
|
229
|
+
/** Any error that occurred */
|
|
230
|
+
error: Error | null;
|
|
231
|
+
/** Reload the query */
|
|
232
|
+
reload: () => void;
|
|
233
|
+
/** Optional bridge/runtime plan summary */
|
|
234
|
+
plan: QueryPlanSummary | null;
|
|
235
|
+
/** Optional materialized view metadata */
|
|
236
|
+
materialized: QueryMaterializedMetadata | null;
|
|
237
|
+
/** Remote/federated completeness metadata when available */
|
|
238
|
+
completeness: QueryCompletenessMetadata | null;
|
|
239
|
+
/** Remote/federated staleness metadata when available */
|
|
240
|
+
staleness: QueryStalenessMetadata | null;
|
|
241
|
+
/** Remote/federated verification metadata when available */
|
|
242
|
+
verification: QueryVerificationMetadata | null;
|
|
243
|
+
/** Streaming lifecycle metadata when a live or stream query is active */
|
|
244
|
+
stream: QueryStreamMetadata | null;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Migration warning info
|
|
248
|
+
*/
|
|
249
|
+
interface MigrationWarning {
|
|
250
|
+
/** The node ID that was migrated */
|
|
251
|
+
nodeId: string;
|
|
252
|
+
/** The original schema IRI */
|
|
253
|
+
from: string;
|
|
254
|
+
/** The target schema IRI */
|
|
255
|
+
to: string;
|
|
256
|
+
/** Warning messages about potential data loss */
|
|
257
|
+
warnings: string[];
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Result when querying a list of nodes
|
|
261
|
+
*/
|
|
262
|
+
interface QueryListResult<P extends Record<string, PropertyBuilder>> extends QueryBaseResult {
|
|
263
|
+
/** The queried nodes (flattened - access properties directly) */
|
|
264
|
+
data: FlatNode<P>[];
|
|
265
|
+
/** Pagination and count metadata */
|
|
266
|
+
pageInfo: QueryPageInfo;
|
|
267
|
+
/** Total matching count when known. Null means unavailable or intentionally not counted. */
|
|
268
|
+
totalCount: number | null;
|
|
269
|
+
/** Whether more results may be available. Exact when totalCount is known. */
|
|
270
|
+
hasMore: boolean;
|
|
271
|
+
/**
|
|
272
|
+
* Migration warnings for nodes that were migrated from different schema versions.
|
|
273
|
+
* Only populated if nodes required migration and the migration was lossy.
|
|
274
|
+
*/
|
|
275
|
+
migrationWarnings: MigrationWarning[];
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Result when querying a single node
|
|
279
|
+
*/
|
|
280
|
+
interface QuerySingleResult<P extends Record<string, PropertyBuilder>> extends QueryBaseResult {
|
|
281
|
+
/** The queried node (flattened - access properties directly), null if not found */
|
|
282
|
+
data: FlatNode<P> | null;
|
|
283
|
+
/**
|
|
284
|
+
* Migration warnings if the node was migrated from a different schema version.
|
|
285
|
+
* Only populated if the node required migration and the migration was lossy.
|
|
286
|
+
*/
|
|
287
|
+
migrationWarnings: MigrationWarning[];
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Query all nodes of a schema
|
|
291
|
+
*/
|
|
292
|
+
declare function useQuery<P extends Record<string, PropertyBuilder>>(schema: DefinedSchema<P>): QueryListResult<P>;
|
|
293
|
+
/**
|
|
294
|
+
* Query a single node by ID
|
|
295
|
+
*/
|
|
296
|
+
declare function useQuery<P extends Record<string, PropertyBuilder>>(schema: DefinedSchema<P>, id: string): QuerySingleResult<P>;
|
|
297
|
+
/**
|
|
298
|
+
* Query nodes with filters
|
|
299
|
+
*/
|
|
300
|
+
declare function useQuery<P extends Record<string, PropertyBuilder>>(schema: DefinedSchema<P>, filter: QueryFilter<P>): QueryListResult<P>;
|
|
301
|
+
|
|
302
|
+
export { type FlatNode as F, type MigrationWarning as M, type QueryFilter as Q, type SortDirection as S, type QueryStatus as a, type QueryPlanSummary as b, type QueryListResult as c, type QuerySingleResult as d, flattenNodes as e, flattenNode as f, flattenUnknownSchemaNode as g, flattenNodesWithSchemaCheck as h, type FlattenNodeOptions as i, type QueryBaseResult as j, useQuery as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xnetjs/react",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,6 +14,18 @@
|
|
|
14
14
|
"import": "./dist/index.js",
|
|
15
15
|
"types": "./dist/index.d.ts"
|
|
16
16
|
},
|
|
17
|
+
"./core": {
|
|
18
|
+
"import": "./dist/core.js",
|
|
19
|
+
"types": "./dist/core.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./database": {
|
|
22
|
+
"import": "./dist/database.js",
|
|
23
|
+
"types": "./dist/database.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./experimental": {
|
|
26
|
+
"import": "./dist/experimental.js",
|
|
27
|
+
"types": "./dist/experimental.d.ts"
|
|
28
|
+
},
|
|
17
29
|
"./internal": {
|
|
18
30
|
"import": "./dist/internal.js",
|
|
19
31
|
"types": "./dist/internal.d.ts"
|
|
@@ -29,15 +41,20 @@
|
|
|
29
41
|
"provenance": true
|
|
30
42
|
},
|
|
31
43
|
"dependencies": {
|
|
44
|
+
"@tanstack/react-virtual": "^3.13.18",
|
|
45
|
+
"lucide-react": "^0.453.0",
|
|
32
46
|
"y-protocols": "^1.0.6",
|
|
33
47
|
"yjs": "^13.6.24",
|
|
34
|
-
"@xnetjs/
|
|
35
|
-
"@xnetjs/
|
|
36
|
-
"@xnetjs/
|
|
37
|
-
"@xnetjs/data
|
|
38
|
-
"@xnetjs/
|
|
39
|
-
"@xnetjs/
|
|
40
|
-
"@xnetjs/
|
|
48
|
+
"@xnetjs/billing": "0.0.2",
|
|
49
|
+
"@xnetjs/core": "0.1.0",
|
|
50
|
+
"@xnetjs/crypto": "0.1.0",
|
|
51
|
+
"@xnetjs/data": "0.1.0",
|
|
52
|
+
"@xnetjs/data-bridge": "0.1.0",
|
|
53
|
+
"@xnetjs/history": "0.1.0",
|
|
54
|
+
"@xnetjs/identity": "0.1.0",
|
|
55
|
+
"@xnetjs/plugins": "0.1.0",
|
|
56
|
+
"@xnetjs/runtime": "0.1.0",
|
|
57
|
+
"@xnetjs/sync": "0.1.0"
|
|
41
58
|
},
|
|
42
59
|
"peerDependencies": {
|
|
43
60
|
"react": "^18.0.0 || ^19.0.0"
|
|
@@ -50,10 +67,11 @@
|
|
|
50
67
|
"react-dom": "^18.3.1",
|
|
51
68
|
"tsup": "^8.0.0",
|
|
52
69
|
"typescript": "^5.4.0",
|
|
53
|
-
"vitest": "^4.0.0"
|
|
70
|
+
"vitest": "^4.0.0",
|
|
71
|
+
"y-webrtc": "^10.3.0"
|
|
54
72
|
},
|
|
55
73
|
"scripts": {
|
|
56
|
-
"build": "tsup src/index.ts src/internal.ts --format esm --dts --external react",
|
|
74
|
+
"build": "tsup src/index.ts src/core.ts src/database.ts src/experimental.ts src/internal.ts --format esm --dts --external react",
|
|
57
75
|
"test": "vitest run",
|
|
58
76
|
"typecheck": "tsc --noEmit",
|
|
59
77
|
"clean": "rm -rf dist"
|