@mdxui/do 2.1.1 → 4.0.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 +115 -323
- package/dist/{agents-xcIn2dUB.d.ts → agents-2_r9e9i7.d.ts} +213 -2
- package/dist/app/index.d.ts +347 -0
- package/dist/app/index.js +14 -0
- package/dist/app/index.js.map +1 -0
- package/dist/breadcrumbs-C9Qn3S7d.d.ts +81 -0
- package/dist/capnweb-client-Bq78FtEA.d.ts +229 -0
- package/dist/chunk-3XKYQRXY.js +192 -0
- package/dist/chunk-3XKYQRXY.js.map +1 -0
- package/dist/chunk-4KXVN3EQ.js +56 -0
- package/dist/chunk-4KXVN3EQ.js.map +1 -0
- package/dist/chunk-5SHZZC7L.js +234 -0
- package/dist/chunk-5SHZZC7L.js.map +1 -0
- package/dist/chunk-7UFINK3Q.js +1994 -0
- package/dist/chunk-7UFINK3Q.js.map +1 -0
- package/dist/chunk-JJLAES6W.js +76 -0
- package/dist/chunk-JJLAES6W.js.map +1 -0
- package/dist/chunk-KT52UU3U.js +985 -0
- package/dist/chunk-KT52UU3U.js.map +1 -0
- package/dist/chunk-LJIWB7KE.js +95 -0
- package/dist/chunk-LJIWB7KE.js.map +1 -0
- package/dist/chunk-NA652ART.js +596 -0
- package/dist/chunk-NA652ART.js.map +1 -0
- package/dist/chunk-OVLO7UOH.js +1071 -0
- package/dist/chunk-OVLO7UOH.js.map +1 -0
- package/dist/chunk-VRLUXCLD.js +31 -0
- package/dist/chunk-VRLUXCLD.js.map +1 -0
- package/dist/chunk-WMNT4OIE.js +249 -0
- package/dist/chunk-WMNT4OIE.js.map +1 -0
- package/dist/chunk-Y52IEYVM.js +131 -0
- package/dist/chunk-Y52IEYVM.js.map +1 -0
- package/dist/components/index.d.ts +14 -732
- package/dist/components/index.js +3 -6
- package/dist/config-CxvpD8Y6.d.ts +111 -0
- package/dist/{do-CaQVueZw.d.ts → do-D27i5bU0.d.ts} +32 -33
- package/dist/errors-DratdVIz.d.ts +346 -0
- package/dist/hooks/index.d.ts +450 -691
- package/dist/hooks/index.js +6 -4
- package/dist/hooks/things/index.d.ts +298 -0
- package/dist/hooks/things/index.js +8 -0
- package/dist/hooks/things/index.js.map +1 -0
- package/dist/index.d.ts +62 -989
- package/dist/index.js +12 -839
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +798 -0
- package/dist/lib/index.js +6 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/providers/index.d.ts +130 -34
- package/dist/providers/index.js +3 -2
- package/dist/query-keys-CZNFikIi.d.ts +153 -0
- package/dist/schemas/index.d.ts +5 -5
- package/dist/schemas/index.js +2 -2
- package/dist/schemas/index.js.map +1 -1
- package/dist/{thing-DtI25yZh.d.ts → thing-BF25aUtJ.d.ts} +72 -72
- package/dist/types/index.d.ts +693 -658
- package/dist/types/index.js +1 -2
- package/dist/views/index.d.ts +131 -0
- package/dist/views/index.js +11 -0
- package/dist/views/index.js.map +1 -0
- package/package.json +39 -17
- package/dist/__test-utils__/index.d.ts +0 -399
- package/dist/__test-utils__/index.js +0 -34641
- package/dist/__test-utils__/index.js.map +0 -1
- package/dist/chunk-EEDMN7UF.js +0 -1351
- package/dist/chunk-EEDMN7UF.js.map +0 -1
- package/dist/chunk-G3PMV62Z.js +0 -33
- package/dist/chunk-G3PMV62Z.js.map +0 -1
- package/dist/chunk-NXPXL5NA.js +0 -3789
- package/dist/chunk-NXPXL5NA.js.map +0 -1
- package/dist/chunk-PC5FJY6M.js +0 -20
- package/dist/chunk-PC5FJY6M.js.map +0 -1
- package/dist/chunk-XF6LKY2M.js +0 -445
- package/dist/chunk-XF6LKY2M.js.map +0 -1
- package/dist/magic-string.es-J7BYFTTJ.js +0 -1307
- package/dist/magic-string.es-J7BYFTTJ.js.map +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { APIError, NetworkError, SyncError, ValidationError, isAPIError, isNetworkError, isSyncError, isValidationError } from '../chunk-JJLAES6W.js';
|
|
2
|
+
export { agentsKeys, createQueryKeys, relationshipsKeys, thingsKeys, workflowsKeys } from '../chunk-4KXVN3EQ.js';
|
|
3
|
+
export { $CapnwebContext, $JsonRpcContext, $MockContext, DEFAULT_REQUEST_TIMEOUT, MOCK_TYPES, createCapnwebClient, createFetchWithTimeout, createJsonRpcClient, createMockClient, deriveRpcUrl, fetchWithTimeout, generateInitialMockData, generateMockSchema, generateMockThing, generateMockThings, useHealthCheck } from '../chunk-OVLO7UOH.js';
|
|
4
|
+
export { camelToTitle, capitalize, cn, debounce, formatBytes, formatDate, formatDateTime, formatDuration, formatNumber, formatRelativeTime, formatSemanticId, generateId, groupBy, parseSemanticId, retryWithBackoff, truncate } from '../chunk-Y52IEYVM.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { QueryClient } from '@tanstack/react-query';
|
|
4
|
-
import { DotdoContextValue } from '@dotdo/react';
|
|
5
2
|
import { DataProvider } from '@mdxui/app';
|
|
6
|
-
import {
|
|
3
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
4
|
+
export { useQueryClient } from '@tanstack/react-query';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { $ as $CapnwebContext } from '../capnweb-client-Bq78FtEA.js';
|
|
7
|
+
import { i as DOAdminConfig } from '../do-D27i5bU0.js';
|
|
7
8
|
import 'zod';
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Type for the DO client instance
|
|
12
|
+
*
|
|
13
|
+
* The client provides a structured interface for RPC operations.
|
|
14
|
+
* Common patterns:
|
|
15
|
+
* - client.Thing.list({ type: 'User' })
|
|
16
|
+
* - client.Thing.get({ id: 'xxx' })
|
|
17
|
+
* - client.Thing.create({ type: 'User', name: 'Alice', data: {} })
|
|
18
|
+
* - client.Schema.discover()
|
|
19
|
+
*/
|
|
20
|
+
type DOClient = ReturnType<typeof $CapnwebContext>;
|
|
9
21
|
/**
|
|
10
22
|
* DO Context value
|
|
23
|
+
*
|
|
24
|
+
* Provides access to config, connection state, RPC URL, and the @dotdo/client instance.
|
|
11
25
|
*/
|
|
12
26
|
interface DOContextValue {
|
|
13
27
|
/** Admin configuration */
|
|
@@ -22,36 +36,85 @@ interface DOContextValue {
|
|
|
22
36
|
isConnected: boolean;
|
|
23
37
|
/** Connection error */
|
|
24
38
|
connectionError?: Error;
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
/** Sync URL derived from doUrl */
|
|
30
|
-
syncUrl: string | null;
|
|
31
|
-
/** Whether using TanStack DB mode */
|
|
32
|
-
isTanStackDBMode: boolean;
|
|
33
|
-
/** TanStack DB context from @dotdo/react (null in REST mode) */
|
|
34
|
-
db: DotdoContextValue | null;
|
|
35
|
-
/** Collections being synced */
|
|
36
|
-
collections: readonly string[];
|
|
39
|
+
/** RPC URL for capnweb session */
|
|
40
|
+
rpcUrl: string;
|
|
41
|
+
/** @dotdo/client instance for direct RPC calls */
|
|
42
|
+
client: DOClient;
|
|
37
43
|
}
|
|
38
44
|
/**
|
|
39
|
-
*
|
|
45
|
+
* Primary hook for accessing the DO provider context.
|
|
46
|
+
*
|
|
47
|
+
* This is the **main hook for application development** with @mdxui/do.
|
|
48
|
+
* It provides access to configuration, connection state, RPC URL, and the client.
|
|
49
|
+
*
|
|
50
|
+
* @returns The DO context value containing config, state, rpcUrl, and client
|
|
51
|
+
* @throws Error if called outside of a `DOProvider`
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* import { useDO } from '@mdxui/do'
|
|
56
|
+
*
|
|
57
|
+
* function ConnectionStatus() {
|
|
58
|
+
* const { isConnected, namespace, rpcUrl, client } = useDO()
|
|
59
|
+
*
|
|
60
|
+
* const handleFetch = async () => {
|
|
61
|
+
* const users = await client.Thing.list({ type: 'User' })
|
|
62
|
+
* console.log(users)
|
|
63
|
+
* }
|
|
64
|
+
*
|
|
65
|
+
* return (
|
|
66
|
+
* <div>
|
|
67
|
+
* <span>Namespace: {namespace}</span>
|
|
68
|
+
* <span>Connected: {isConnected ? 'Yes' : 'No'}</span>
|
|
69
|
+
* <button onClick={handleFetch}>Fetch Users</button>
|
|
70
|
+
* </div>
|
|
71
|
+
* )
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
40
74
|
*/
|
|
41
75
|
declare function useDO(): DOContextValue;
|
|
42
76
|
/**
|
|
43
|
-
* Hook to access
|
|
77
|
+
* Hook to access the @dotdo/client instance directly.
|
|
78
|
+
*
|
|
79
|
+
* Convenience hook for components that only need the RPC client.
|
|
80
|
+
*
|
|
81
|
+
* @returns The @dotdo/client instance
|
|
82
|
+
* @throws Error if called outside of a `DOProvider`
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```tsx
|
|
86
|
+
* import { useDOClient } from '@mdxui/do'
|
|
87
|
+
*
|
|
88
|
+
* function UserList() {
|
|
89
|
+
* const client = useDOClient()
|
|
90
|
+
* const [users, setUsers] = useState([])
|
|
91
|
+
*
|
|
92
|
+
* useEffect(() => {
|
|
93
|
+
* client.Thing.list({ type: 'User' }).then(setUsers)
|
|
94
|
+
* }, [client])
|
|
95
|
+
*
|
|
96
|
+
* return <ul>{users.map(u => <li key={u.id}>{u.name}</li>)}</ul>
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
declare function useDOClient(): DOClient;
|
|
101
|
+
/**
|
|
102
|
+
* Convenience hook to access derived URLs for API operations.
|
|
103
|
+
*
|
|
104
|
+
* Returns URL endpoints from the DOProvider configuration,
|
|
105
|
+
* useful for making direct API calls or debugging connection issues.
|
|
106
|
+
*
|
|
107
|
+
* @returns Object containing rpcUrl and apiEndpoint
|
|
44
108
|
*/
|
|
45
109
|
declare function useDOUrls(): {
|
|
46
|
-
rpcUrl: string
|
|
47
|
-
syncUrl: string | null;
|
|
110
|
+
rpcUrl: string;
|
|
48
111
|
apiEndpoint: string;
|
|
49
|
-
doUrl: string | null;
|
|
50
112
|
};
|
|
51
113
|
/**
|
|
52
|
-
*
|
|
114
|
+
* @deprecated Sync status is no longer available in the simplified RPC-only architecture.
|
|
115
|
+
* This function is kept for backward compatibility but always returns 'disconnected'.
|
|
53
116
|
*/
|
|
54
|
-
declare function useSyncStatus():
|
|
117
|
+
declare function useSyncStatus(): 'disconnected';
|
|
55
118
|
/**
|
|
56
119
|
* Props for DOProvider
|
|
57
120
|
*/
|
|
@@ -67,24 +130,57 @@ interface DOProviderProps {
|
|
|
67
130
|
/** Custom QueryClient (for testing) */
|
|
68
131
|
queryClient?: QueryClient;
|
|
69
132
|
}
|
|
70
|
-
declare function DOProvider({ config, initialNamespace, userId, children, queryClient: providedQueryClient, }: DOProviderProps): react_jsx_runtime.JSX.Element;
|
|
71
|
-
|
|
72
133
|
/**
|
|
73
|
-
*
|
|
134
|
+
* DOProvider - Main provider for @mdxui/do
|
|
74
135
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
136
|
+
* Provides a single-mode RPC-first architecture using @dotdo/client for typed RPC calls.
|
|
137
|
+
* All data operations go through the RPC endpoint using promise pipelining.
|
|
138
|
+
*
|
|
139
|
+
* Namespace state is managed via TanStack Query with localStorage persistence,
|
|
140
|
+
* allowing it to be shared across components and persist across sessions.
|
|
77
141
|
*
|
|
78
142
|
* @example
|
|
79
143
|
* ```tsx
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
144
|
+
* <DOProvider
|
|
145
|
+
* config={{
|
|
146
|
+
* apiEndpoint: 'https://admin.do.ai',
|
|
147
|
+
* authMethod: 'jwt',
|
|
148
|
+
* authToken: 'xxx',
|
|
149
|
+
* bindings: [...],
|
|
150
|
+
* realTimeUpdates: false,
|
|
151
|
+
* }}
|
|
152
|
+
* initialNamespace="my-app"
|
|
153
|
+
* userId="user_123"
|
|
154
|
+
* >
|
|
155
|
+
* <App />
|
|
156
|
+
* </DOProvider>
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```tsx
|
|
161
|
+
* // Accessing the client in a child component
|
|
162
|
+
* function MyComponent() {
|
|
163
|
+
* const { client } = useDO()
|
|
164
|
+
*
|
|
165
|
+
* const fetchData = async () => {
|
|
166
|
+
* // Promise pipelining - efficient batched RPC calls
|
|
167
|
+
* const [users, projects] = await Promise.all([
|
|
168
|
+
* client.Thing.list({ type: 'User' }),
|
|
169
|
+
* client.Thing.list({ type: 'Project' }),
|
|
170
|
+
* ])
|
|
171
|
+
* return { users, projects }
|
|
172
|
+
* }
|
|
85
173
|
* }
|
|
86
174
|
* ```
|
|
87
175
|
*/
|
|
176
|
+
declare function DOProvider({ config, initialNamespace, userId, children, queryClient: providedQueryClient, }: DOProviderProps): react_jsx_runtime.JSX.Element;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Hook to safely access the DataProvider, returning null if not available.
|
|
180
|
+
*
|
|
181
|
+
* This is useful for hooks that can optionally use a DataProvider when one
|
|
182
|
+
* is configured, but should fall back to RPC when no DataProvider is present.
|
|
183
|
+
*/
|
|
88
184
|
declare function useDataProviderSafe(): DataProvider | null;
|
|
89
185
|
|
|
90
|
-
export { type DOContextValue, DOProvider, type DOProviderProps, useDO, useDOUrls, useDataProviderSafe, useSyncStatus };
|
|
186
|
+
export { type DOClient, type DOContextValue, DOProvider, type DOProviderProps, useDO, useDOClient, useDOUrls, useDataProviderSafe, useSyncStatus };
|
package/dist/providers/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import '../chunk-GKSP5RIA.js';
|
|
2
|
-
export { DOProvider, useDO, useDOUrls, useDataProviderSafe, useSyncStatus } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
2
|
+
export { DOProvider, useDO, useDOClient, useDOUrls, useDataProviderSafe, useQueryClient, useSyncStatus } from '../chunk-WMNT4OIE.js';
|
|
3
|
+
import '../chunk-OVLO7UOH.js';
|
|
4
|
+
import '../chunk-Y52IEYVM.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import * as zod from 'zod';
|
|
2
|
+
import { EntityReference } from './schemas/index.js';
|
|
3
|
+
import { c as ThingFilter, d as ThingSort, e as ThingPagination } from './thing-BF25aUtJ.js';
|
|
4
|
+
import { a5 as AgentFilter, a6 as AgentExecutionFilter, B as WorkflowFilter, F as ExecutionFilter, e as RelationshipFilter, G as GraphPattern } from './agents-2_r9e9i7.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generic pagination parameters for list queries
|
|
8
|
+
*/
|
|
9
|
+
interface Pagination {
|
|
10
|
+
page?: number;
|
|
11
|
+
perPage?: number;
|
|
12
|
+
cursor?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Query keys for Things resource
|
|
16
|
+
*
|
|
17
|
+
* Things have a special key structure because:
|
|
18
|
+
* - List queries include filter, sort, and pagination
|
|
19
|
+
* - Detail queries use composite keys (ns, type, id) instead of a single id
|
|
20
|
+
* - Additional sub-queries for versions and type stats
|
|
21
|
+
*/
|
|
22
|
+
declare const thingsKeys: {
|
|
23
|
+
all: readonly ["things"];
|
|
24
|
+
lists: () => readonly ["things", "list"];
|
|
25
|
+
list: (filter: ThingFilter, sort?: ThingSort, pagination?: ThingPagination) => readonly ["things", "list", {
|
|
26
|
+
readonly filter: zod.objectOutputType<{
|
|
27
|
+
ns: zod.ZodOptional<zod.ZodUnion<[zod.ZodString, zod.ZodArray<zod.ZodString, "many">]>>;
|
|
28
|
+
type: zod.ZodOptional<zod.ZodUnion<[zod.ZodString, zod.ZodArray<zod.ZodString, "many">]>>;
|
|
29
|
+
idPattern: zod.ZodOptional<zod.ZodString>;
|
|
30
|
+
nameSearch: zod.ZodOptional<zod.ZodString>;
|
|
31
|
+
createdAfter: zod.ZodOptional<zod.ZodDate>;
|
|
32
|
+
createdBefore: zod.ZodOptional<zod.ZodDate>;
|
|
33
|
+
updatedAfter: zod.ZodOptional<zod.ZodDate>;
|
|
34
|
+
updatedBefore: zod.ZodOptional<zod.ZodDate>;
|
|
35
|
+
includeDeleted: zod.ZodOptional<zod.ZodBoolean>;
|
|
36
|
+
properties: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
37
|
+
variant: zod.ZodOptional<zod.ZodString>;
|
|
38
|
+
}, zod.ZodTypeAny, "passthrough">;
|
|
39
|
+
readonly sort: {
|
|
40
|
+
order: "desc" | "asc";
|
|
41
|
+
field: "type" | "name" | "ts" | "createdAt" | "updatedAt";
|
|
42
|
+
} | undefined;
|
|
43
|
+
readonly pagination: {
|
|
44
|
+
page: number;
|
|
45
|
+
perPage: number;
|
|
46
|
+
} | undefined;
|
|
47
|
+
}];
|
|
48
|
+
details: () => readonly ["things", "detail"];
|
|
49
|
+
detail: (ns: string, type: string, id: string) => readonly ["things", "detail", string, string, string];
|
|
50
|
+
versions: (ns: string, type: string, id: string) => readonly ["things", "detail", string, string, string, "versions"];
|
|
51
|
+
types: () => readonly ["things", "types"];
|
|
52
|
+
typeStats: (ns: string, type: string) => readonly ["things", "types", string, string];
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Query keys for Agents resource
|
|
56
|
+
*
|
|
57
|
+
* Includes keys for:
|
|
58
|
+
* - Agent lists and details
|
|
59
|
+
* - Agent metrics (per-agent)
|
|
60
|
+
* - Agent executions (list and detail)
|
|
61
|
+
*/
|
|
62
|
+
declare const agentsKeys: {
|
|
63
|
+
all: readonly ["agents"];
|
|
64
|
+
lists: () => readonly ["agents", "list"];
|
|
65
|
+
list: (filter: AgentFilter) => readonly ["agents", "list", AgentFilter];
|
|
66
|
+
details: () => readonly ["agents", "detail"];
|
|
67
|
+
detail: (id: string) => readonly ["agents", "detail", string];
|
|
68
|
+
metrics: (id: string) => readonly ["agents", "detail", string, "metrics"];
|
|
69
|
+
executions: () => readonly ["agents", "executions"];
|
|
70
|
+
executionsList: (filter: AgentExecutionFilter) => readonly ["agents", "executions", "list", AgentExecutionFilter];
|
|
71
|
+
execution: (id: string) => readonly ["agents", "executions", "detail", string];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Query keys for Workflows resource
|
|
75
|
+
*
|
|
76
|
+
* Includes keys for:
|
|
77
|
+
* - Workflow lists and details
|
|
78
|
+
* - Workflow executions (list and detail)
|
|
79
|
+
*/
|
|
80
|
+
declare const workflowsKeys: {
|
|
81
|
+
all: readonly ["workflows"];
|
|
82
|
+
lists: () => readonly ["workflows", "list"];
|
|
83
|
+
list: (filter: WorkflowFilter) => readonly ["workflows", "list", WorkflowFilter];
|
|
84
|
+
details: () => readonly ["workflows", "detail"];
|
|
85
|
+
detail: (id: string) => readonly ["workflows", "detail", string];
|
|
86
|
+
executions: () => readonly ["workflows", "executions"];
|
|
87
|
+
executionsList: (filter: ExecutionFilter) => readonly ["workflows", "executions", "list", ExecutionFilter];
|
|
88
|
+
execution: (id: string) => readonly ["workflows", "executions", "detail", string];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Query keys for Relationships resource
|
|
92
|
+
*
|
|
93
|
+
* Includes keys for:
|
|
94
|
+
* - Relationship lists and details
|
|
95
|
+
* - Graph traversal queries
|
|
96
|
+
* - Graph statistics
|
|
97
|
+
*/
|
|
98
|
+
declare const relationshipsKeys: {
|
|
99
|
+
all: readonly ["relationships"];
|
|
100
|
+
lists: () => readonly ["relationships", "list"];
|
|
101
|
+
list: (filter: RelationshipFilter) => readonly ["relationships", "list", RelationshipFilter];
|
|
102
|
+
details: () => readonly ["relationships", "detail"];
|
|
103
|
+
detail: (id: string) => readonly ["relationships", "detail", string];
|
|
104
|
+
graph: () => readonly ["relationships", "graph"];
|
|
105
|
+
traverse: (entity: EntityReference, pattern: GraphPattern) => readonly ["relationships", "graph", {
|
|
106
|
+
id: string;
|
|
107
|
+
type: string;
|
|
108
|
+
ns: string;
|
|
109
|
+
semanticId: string;
|
|
110
|
+
name?: string | undefined;
|
|
111
|
+
}, GraphPattern];
|
|
112
|
+
stats: () => readonly ["relationships", "stats"];
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Base query keys structure that all resources share
|
|
116
|
+
*/
|
|
117
|
+
interface QueryKeys<TFilter = unknown> {
|
|
118
|
+
/** Root key for all queries of this resource */
|
|
119
|
+
all: readonly [string];
|
|
120
|
+
/** Key for all list queries */
|
|
121
|
+
lists: () => readonly [string, 'list'];
|
|
122
|
+
/** Key for a specific list query with filter */
|
|
123
|
+
list: (filter: TFilter) => readonly unknown[];
|
|
124
|
+
/** Key for all detail queries */
|
|
125
|
+
details: () => readonly [string, 'detail'];
|
|
126
|
+
/** Key for a specific detail query */
|
|
127
|
+
detail: (id: string) => readonly [string, 'detail', string];
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Create a basic query key factory for a resource
|
|
131
|
+
*
|
|
132
|
+
* @param resource - The resource name (e.g., 'agents', 'workflows')
|
|
133
|
+
* @returns Query key factory with type-safe keys
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* const customKeys = createQueryKeys<CustomFilter>('custom')
|
|
138
|
+
*
|
|
139
|
+
* // All queries
|
|
140
|
+
* customKeys.all // ['custom']
|
|
141
|
+
*
|
|
142
|
+
* // List queries
|
|
143
|
+
* customKeys.lists() // ['custom', 'list']
|
|
144
|
+
* customKeys.list({ status: 'active' }) // ['custom', 'list', { status: 'active' }]
|
|
145
|
+
*
|
|
146
|
+
* // Detail queries
|
|
147
|
+
* customKeys.details() // ['custom', 'detail']
|
|
148
|
+
* customKeys.detail('item-1') // ['custom', 'detail', 'item-1']
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
declare function createQueryKeys<TFilter = unknown>(resource: string): QueryKeys<TFilter>;
|
|
152
|
+
|
|
153
|
+
export { type Pagination as P, type QueryKeys as Q, agentsKeys as a, createQueryKeys as c, relationshipsKeys as r, thingsKeys as t, workflowsKeys as w };
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export { N as Namespace, x as NamespaceSchema,
|
|
2
|
+
export { N as Namespace, x as NamespaceSchema, b as SemanticProperty, v as SemanticPropertySchema, S as SemanticType, w as SemanticTypeSchema, T as Thing, g as ThingCreateInput, r as ThingCreateInputSchema, a as ThingData, l as ThingDataSchema, i as ThingDeleteOptions, t as ThingDeleteOptionsSchema, c as ThingFilter, n as ThingFilterSchema, e as ThingPagination, p as ThingPaginationSchema, f as ThingQueryResult, q as ThingQueryResultSchema, m as ThingSchema, d as ThingSort, o as ThingSortSchema, h as ThingUpdateInput, s as ThingUpdateInputSchema, j as ThingVersion, u as ThingVersionSchema, k as TypeStats, y as TypeStatsSchema } from '../thing-BF25aUtJ.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Common Zod Schemas - Shared Schema Definitions
|
|
@@ -41,15 +41,15 @@ declare const EntityReferenceSchema: z.ZodObject<{
|
|
|
41
41
|
/** Display name (if loaded) */
|
|
42
42
|
name: z.ZodOptional<z.ZodString>;
|
|
43
43
|
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
id: string;
|
|
44
45
|
type: string;
|
|
45
46
|
ns: string;
|
|
46
|
-
id: string;
|
|
47
47
|
semanticId: string;
|
|
48
48
|
name?: string | undefined;
|
|
49
49
|
}, {
|
|
50
|
+
id: string;
|
|
50
51
|
type: string;
|
|
51
52
|
ns: string;
|
|
52
|
-
id: string;
|
|
53
53
|
semanticId: string;
|
|
54
54
|
name?: string | undefined;
|
|
55
55
|
}>;
|
|
@@ -175,15 +175,15 @@ declare const PaginatedResponseSchema: <T extends z.ZodTypeAny>(dataSchema: T) =
|
|
|
175
175
|
/** Total number of pages */
|
|
176
176
|
totalPages: z.ZodNumber;
|
|
177
177
|
}, "strip", z.ZodTypeAny, {
|
|
178
|
+
data: T["_output"][];
|
|
178
179
|
page: number;
|
|
179
180
|
perPage: number;
|
|
180
|
-
data: T["_output"][];
|
|
181
181
|
total: number;
|
|
182
182
|
totalPages: number;
|
|
183
183
|
}, {
|
|
184
|
+
data: T["_input"][];
|
|
184
185
|
page: number;
|
|
185
186
|
perPage: number;
|
|
186
|
-
data: T["_input"][];
|
|
187
187
|
total: number;
|
|
188
188
|
totalPages: number;
|
|
189
189
|
}>;
|
package/dist/schemas/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import '../chunk-G3PMV62Z.js';
|
|
2
1
|
import { z } from 'zod';
|
|
3
2
|
|
|
3
|
+
// src/types/schemas/common.ts
|
|
4
4
|
var DateSchema = z.coerce.date();
|
|
5
5
|
var OptionalDateSchema = z.union([DateSchema, z.null()]).optional();
|
|
6
6
|
var EntityReferenceSchema = z.object({
|
|
@@ -212,7 +212,7 @@ var SemanticTypeSchema = z.object({
|
|
|
212
212
|
/** Human-readable label */
|
|
213
213
|
label: z.string(),
|
|
214
214
|
/** Type description */
|
|
215
|
-
description: z.string(),
|
|
215
|
+
description: z.string().optional(),
|
|
216
216
|
/** Parent types (inheritance) */
|
|
217
217
|
parentTypes: z.array(z.string()),
|
|
218
218
|
/** Properties defined by this type */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schemas/common.ts","../../src/schemas/thing.ts"],"names":["z"],"mappings":";;;AAqBO,IAAM,UAAA,GAAa,CAAA,CAAE,MAAA,CAAO,IAAA;AAK5B,IAAM,kBAAA,GAAqB,CAAA,CAAE,KAAA,CAAM,CAAC,UAAA,EAAY,EAAE,IAAA,EAAM,CAAC,CAAA,CAAE,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;AAAA,EAEf,WAAA,EAAaA,CAAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA;AAAA,EAEjC,OAAA,EAASA,CAAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA;AAAA,EAE7B,KAAA,EAAOA,CAAAA,CAAE,KAAA,CAAMA,CAAAA,CAAE,QAAQ,CAAA;AAAA;AAAA,EAEzB,UAAA,EAAYA,EAAE,MAAA,EAAO;AAAA;AAAA,EAErB,SAAA,EAAW;AACb,CAAC;AAcM,IAAM,eAAA,GAAkBA,EAAE,MAAA,CAAO;AAAA;AAAA,EAEtC,IAAA,EAAMA,EAAE,MAAA,EAAO;AAAA;AAAA,EAEf,EAAA,EAAIA,EAAE,MAAA,EAAO;AAAA;AAAA,EAEb,KAAA,EAAOA,EAAE,MAAA,EAAO;AAAA;AAAA,EAEhB,WAAA,EAAaA,EAAE,MAAA,EAAO;AAAA;AAAA,EAEtB,YAAA,EAAcA,EAAE,MAAA,EAAO;AAAA;AAAA,EAEvB,YAAA,EAAcA,EAAE,MAAA,EAAO;AAAA;AAAA,EAEvB,aAAA,EAAe,WAAW,QAAA,EAAS;AAAA;AAAA,EAEnC,aAAA,EAAe,WAAW,QAAA;AAC5B,CAAC","file":"index.js","sourcesContent":["/**\n * Common Zod Schemas - Shared Schema Definitions\n *\n * This file contains Zod schemas that are used across multiple domains.\n * Types are derived from these schemas to ensure a single source of truth.\n *\n * @remarks\n * Import schemas from here for validation.\n * Import types from here or from domain files for TypeScript types.\n */\n\nimport { z } from 'zod'\n\n// =============================================================================\n// Date Handling\n// =============================================================================\n\n/**\n * Schema for Date fields that can be either Date objects or ISO strings.\n * API responses typically return ISO strings, not Date objects.\n */\nexport const DateSchema = z.coerce.date()\n\n/**\n * Optional nullable date for responses\n */\nexport const OptionalDateSchema = z.union([DateSchema, z.null()]).optional()\n\n// =============================================================================\n// EntityReference\n// =============================================================================\n\n/**\n * Schema for EntityReference - reference to a Thing in the semantic graph.\n *\n * Used by:\n * - Relationships (subject/object in semantic triples)\n * - Events (subject/object in semantic events)\n * - Graph traversal results\n */\nexport const EntityReferenceSchema = z.object({\n /** Namespace */\n ns: z.string(),\n /** Entity type */\n type: z.string(),\n /** Entity ID */\n id: z.string(),\n /** Semantic ID (ns/type/id) */\n semanticId: z.string(),\n /** Display name (if loaded) */\n name: z.string().optional(),\n})\n\n/**\n * Reference to an entity (Thing) in the semantic graph.\n */\nexport type EntityReference = z.infer<typeof EntityReferenceSchema>\n\n// =============================================================================\n// TokenUsage\n// =============================================================================\n\n/**\n * Schema for TokenUsage - token usage metrics for AI operations.\n *\n * Used by:\n * - Agent executions\n * - Function executions (generative/agentic)\n * - Agent trace entries\n */\nexport const TokenUsageSchema = z.object({\n /** Input/prompt tokens */\n inputTokens: z.number(),\n /** Output/completion tokens */\n outputTokens: z.number(),\n /** Total tokens (input + output) */\n totalTokens: z.number(),\n /** Thinking tokens (for reasoning models like o1, Claude with thinking) */\n thinkingTokens: z.number().optional(),\n /** Estimated cost in USD */\n costUsd: z.number().optional(),\n})\n\n/**\n * Token usage metrics for AI operations.\n */\nexport type TokenUsage = z.infer<typeof TokenUsageSchema>\n\n// =============================================================================\n// ExecutionError\n// =============================================================================\n\n/**\n * Schema for ExecutionError - error information for execution failures.\n *\n * Used by:\n * - Workflow executions\n * - Function executions\n * - Step executions\n */\nexport const ExecutionErrorSchema = z.object({\n /** Error code (e.g., 'TIMEOUT', 'VALIDATION_ERROR', 'RATE_LIMITED') */\n code: z.string(),\n /** Human-readable error message */\n message: z.string(),\n /** Stack trace (for debugging) */\n stack: z.string().optional(),\n /** ID of the step that failed (for workflow executions) */\n failedStep: z.string().optional(),\n /** Number of retry attempts made (for function executions) */\n retryCount: z.number().optional(),\n /** Whether this error is retryable (for function executions) */\n retryable: z.boolean().optional(),\n})\n\n/**\n * Error information for execution failures.\n */\nexport type ExecutionError = z.infer<typeof ExecutionErrorSchema>\n\n// =============================================================================\n// SortDirection\n// =============================================================================\n\n/**\n * Schema for SortDirection - sort direction for list queries.\n */\nexport const SortDirectionSchema = z.enum(['asc', 'desc'])\n\n/**\n * Sort direction for list queries.\n */\nexport type SortDirection = z.infer<typeof SortDirectionSchema>\n\n// =============================================================================\n// Pagination Types\n// =============================================================================\n\n/**\n * Schema for Pagination - pagination input parameters for list queries.\n */\nexport const PaginationSchema = z.object({\n /** Page number (1-indexed) */\n page: z.number().int().positive(),\n /** Items per page */\n perPage: z.number().int().positive(),\n})\n\n/**\n * Pagination input parameters for list queries.\n */\nexport type Pagination = z.infer<typeof PaginationSchema>\n\n/**\n * Schema factory for paginated responses.\n */\nexport const PaginatedResponseSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>\n z.object({\n /** Array of items for the current page */\n data: z.array(dataSchema),\n /** Total number of items across all pages */\n total: z.number(),\n /** Current page number (1-indexed) */\n page: z.number(),\n /** Items per page */\n perPage: z.number(),\n /** Total number of pages */\n totalPages: z.number(),\n })\n\n/**\n * Paginated response wrapper for list queries.\n */\nexport interface PaginatedResponse<T> {\n /** Array of items for the current page */\n data: T[]\n /** Total number of items across all pages */\n total: number\n /** Current page number (1-indexed) */\n page: number\n /** Items per page */\n perPage: number\n /** Total number of pages */\n totalPages: number\n}\n","/**\n * Thing Zod Schemas - Semantic Entity Management\n *\n * Things are the core entities in the .do platform, stored in the Things table\n * with ClickHouse's ReplacingMergeTree engine for immutable, versioned storage.\n *\n * All types are derived from Zod schemas to ensure a single source of truth.\n *\n * @remarks\n * Key patterns:\n * - Semantic IDs: `[namespace]/[Name]` (e.g., `schema.org/Person`)\n * - JSON-LD compatible data structure\n * - Full version history via Events table\n * - Soft deletes with deletedAt timestamp\n */\n\nimport { z } from 'zod'\nimport { DateSchema, OptionalDateSchema, SortDirectionSchema } from './common'\n\n// =============================================================================\n// ThingData Schema\n// =============================================================================\n\n/**\n * Schema for ThingData - JSON-LD compatible data structure for Things.\n */\nexport const ThingDataSchema = z\n .object({\n /** JSON-LD context */\n '@context': z.union([z.string(), z.record(z.unknown())]).optional(),\n /** JSON-LD type (should match Thing.type) */\n '@type': z.string().optional(),\n /** JSON-LD identifier */\n '@id': z.string().optional(),\n })\n .passthrough()\n\n/**\n * JSON-LD compatible data structure for Things.\n */\nexport type ThingData = z.infer<typeof ThingDataSchema>\n\n// =============================================================================\n// Thing Schema\n// =============================================================================\n\n/**\n * Schema for Thing - base Thing record from database.\n */\nexport const ThingSchema = z.object({\n /** Namespace (tenant/domain) */\n ns: z.string(),\n /** Entity type (e.g., 'Person', 'Organization', 'Agent') */\n type: z.string(),\n /** Unique identifier within namespace/type */\n id: z.string(),\n /** Version timestamp for deduplication */\n ts: DateSchema,\n /** Display name */\n name: z.string(),\n /** Creation timestamp */\n createdAt: DateSchema,\n /** Last update timestamp */\n updatedAt: DateSchema,\n /** Creator user ID */\n createdBy: z.string().optional(),\n /** Last updater user ID */\n updatedBy: z.string().optional(),\n /** Soft delete timestamp */\n deletedAt: OptionalDateSchema,\n /** A/B test variant */\n variant: z.string().optional(),\n /** JSON-LD data blob */\n data: ThingDataSchema,\n})\n\n/**\n * Base Thing record from database.\n */\nexport type Thing = z.infer<typeof ThingSchema>\n\n// =============================================================================\n// ThingFilter Schema\n// =============================================================================\n\n/**\n * Schema for ThingFilter - query filters for Things.\n */\nexport const ThingFilterSchema = z\n .object({\n /** Filter by namespace - single string or array of strings */\n ns: z.union([z.string(), z.array(z.string())]).optional(),\n /** Filter by type - single string or array of strings */\n type: z.union([z.string(), z.array(z.string())]).optional(),\n /** Filter by ID pattern (supports wildcards) */\n idPattern: z.string().optional(),\n /** Filter by name (case-insensitive search) */\n nameSearch: z.string().optional(),\n /** Filter by creation date range - start */\n createdAfter: z.coerce.date().optional(),\n /** Filter by creation date range - end */\n createdBefore: z.coerce.date().optional(),\n /** Filter by update date range - start */\n updatedAfter: z.coerce.date().optional(),\n /** Filter by update date range - end */\n updatedBefore: z.coerce.date().optional(),\n /** Include soft-deleted things */\n includeDeleted: z.boolean().optional(),\n /** Filter by specific property values in data */\n properties: z.record(z.unknown()).optional(),\n /** Filter by variant */\n variant: z.string().optional(),\n })\n .passthrough()\n\n/**\n * Query filters for Things.\n */\nexport type ThingFilter = z.infer<typeof ThingFilterSchema>\n\n// =============================================================================\n// ThingSort Schema\n// =============================================================================\n\n/**\n * Schema for ThingSort - sort options for Things.\n */\nexport const ThingSortSchema = z.object({\n /** Field to sort by */\n field: z.enum(['name', 'createdAt', 'updatedAt', 'ts', 'type']),\n /** Sort direction */\n order: SortDirectionSchema,\n})\n\n/**\n * Sort options for Things.\n */\nexport type ThingSort = z.infer<typeof ThingSortSchema>\n\n// =============================================================================\n// ThingPagination Schema\n// =============================================================================\n\n/**\n * Schema for ThingPagination - pagination for Things queries.\n */\nexport const ThingPaginationSchema = z.object({\n /** Page number (1-indexed, must be positive) */\n page: z.number().int().positive(),\n /** Items per page (must be positive, max 1000) */\n perPage: z.number().int().positive().max(1000),\n})\n\n/**\n * Pagination for Things queries.\n */\nexport type ThingPagination = z.infer<typeof ThingPaginationSchema>\n\n// =============================================================================\n// ThingQueryResult Schema\n// =============================================================================\n\n/**\n * Schema for ThingQueryResult - result of a Things query.\n */\nexport const ThingQueryResultSchema = z.object({\n /** Matching things */\n data: z.array(ThingSchema),\n /** Total count (without pagination) */\n total: z.number(),\n /** Current page */\n page: z.number(),\n /** Items per page */\n perPage: z.number(),\n /** Total pages */\n totalPages: z.number(),\n})\n\n/**\n * Result of a Things query.\n */\nexport type ThingQueryResult = z.infer<typeof ThingQueryResultSchema>\n\n// =============================================================================\n// ThingCreateInput Schema\n// =============================================================================\n\n/**\n * Schema for ThingCreateInput - thing creation payload.\n */\nexport const ThingCreateInputSchema = z.object({\n /** Namespace (required, non-empty string) */\n ns: z.string().min(1, 'Namespace is required'),\n /** Type (required, non-empty string) */\n type: z.string().min(1, 'Type is required'),\n /** ID (optional, auto-generated if not provided) */\n id: z.string().optional(),\n /** Display name (required, non-empty string) */\n name: z.string().min(1, 'Name is required'),\n /** JSON-LD data */\n data: ThingDataSchema,\n /** Variant for A/B testing */\n variant: z.string().optional(),\n})\n\n/**\n * Thing creation payload.\n */\nexport type ThingCreateInput = z.infer<typeof ThingCreateInputSchema>\n\n// =============================================================================\n// ThingUpdateInput Schema\n// =============================================================================\n\n/**\n * Schema for ThingUpdateInput - thing update payload.\n */\nexport const ThingUpdateInputSchema = z.object({\n /** Updated name */\n name: z.string().min(1, 'Name cannot be empty').optional(),\n /** Updated data (merged with existing) */\n data: ThingDataSchema.partial().optional(),\n /** Updated variant */\n variant: z.string().optional(),\n})\n\n/**\n * Thing update payload.\n */\nexport type ThingUpdateInput = z.infer<typeof ThingUpdateInputSchema>\n\n// =============================================================================\n// ThingDeleteOptions Schema\n// =============================================================================\n\n/**\n * Schema for ThingDeleteOptions - delete options.\n */\nexport const ThingDeleteOptionsSchema = z.object({\n /** Hard delete (permanent) vs soft delete */\n hard: z.boolean().optional(),\n})\n\n/**\n * Thing delete options.\n */\nexport type ThingDeleteOptions = z.infer<typeof ThingDeleteOptionsSchema>\n\n// =============================================================================\n// ThingVersion Schema\n// =============================================================================\n\n/**\n * Schema for ThingVersion - thing version from Events table.\n */\nexport const ThingVersionSchema = z.object({\n /** Event ID */\n eventId: z.string(),\n /** Event type (create, update, delete) */\n eventType: z.enum(['create', 'update', 'delete', 'create_version', 'update_version']),\n /** Version timestamp */\n ts: DateSchema,\n /** User who made the change */\n userId: z.string(),\n /** Full data snapshot at this version */\n data: ThingDataSchema,\n /** Delta from previous version */\n delta: ThingDataSchema.optional(),\n /** Event metadata */\n metadata: z.record(z.unknown()),\n})\n\n/**\n * Thing version from Events table.\n */\nexport type ThingVersion = z.infer<typeof ThingVersionSchema>\n\n// =============================================================================\n// SemanticProperty Schema\n// =============================================================================\n\n/**\n * Schema for SemanticProperty - property definition for semantic types.\n */\nexport const SemanticPropertySchema = z.object({\n /** Property name */\n name: z.string(),\n /** Property label */\n label: z.string(),\n /** Property description */\n description: z.string(),\n /** Expected value types */\n rangeIncludes: z.array(z.string()),\n /** Types that use this property */\n domainIncludes: z.array(z.string()),\n /** Is this property required? */\n required: z.boolean(),\n /** Is this property an array? */\n isArray: z.boolean(),\n /** Default value */\n defaultValue: z.unknown().optional(),\n})\n\n/**\n * Property definition for semantic types.\n */\nexport type SemanticProperty = z.infer<typeof SemanticPropertySchema>\n\n// =============================================================================\n// SemanticType Schema\n// =============================================================================\n\n/**\n * Schema for SemanticType - semantic type definition (like schema.org types).\n */\nexport const SemanticTypeSchema = z.object({\n /** Type namespace (e.g., 'schema.org') */\n namespace: z.string(),\n /** Type name (e.g., 'Person') */\n name: z.string(),\n /** Full semantic ID */\n id: z.string(),\n /** Human-readable label */\n label: z.string(),\n /** Type description */\n description: z.string(),\n /** Parent types (inheritance) */\n parentTypes: z.array(z.string()),\n /** Properties defined by this type */\n properties: z.array(SemanticPropertySchema),\n /** Child types */\n subtypes: z.array(z.string()),\n /** Example instances */\n examples: z.array(ThingDataSchema).optional(),\n})\n\n/**\n * Semantic type definition (like schema.org types).\n */\nexport type SemanticType = z.infer<typeof SemanticTypeSchema>\n\n// =============================================================================\n// Namespace Schema\n// =============================================================================\n\n/**\n * Schema for Namespace - namespace definition (tenant/domain).\n */\nexport const NamespaceSchema = z.object({\n /** Namespace identifier */\n id: z.string(),\n /** Namespace name */\n name: z.string(),\n /** Namespace description */\n description: z.string().optional(),\n /** Base URL for the namespace */\n baseUrl: z.string().optional(),\n /** Available types in this namespace */\n types: z.array(z.string()),\n /** Thing count in this namespace */\n thingCount: z.number(),\n /** Creation timestamp */\n createdAt: DateSchema,\n})\n\n/**\n * Namespace definition (tenant/domain).\n */\nexport type Namespace = z.infer<typeof NamespaceSchema>\n\n// =============================================================================\n// TypeStats Schema\n// =============================================================================\n\n/**\n * Schema for TypeStats - statistics for a type.\n */\nexport const TypeStatsSchema = z.object({\n /** Type name */\n type: z.string(),\n /** Namespace */\n ns: z.string(),\n /** Total count */\n count: z.number(),\n /** Active count (not deleted) */\n activeCount: z.number(),\n /** Created today */\n createdToday: z.number(),\n /** Updated today */\n updatedToday: z.number(),\n /** Most recent creation */\n lastCreatedAt: DateSchema.optional(),\n /** Most recent update */\n lastUpdatedAt: DateSchema.optional(),\n})\n\n/**\n * Statistics for a type.\n */\nexport type TypeStats = z.infer<typeof TypeStatsSchema>\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/schemas/common.ts","../../src/types/schemas/thing.ts"],"names":["z"],"mappings":";;;AAqBO,IAAM,UAAA,GAAa,CAAA,CAAE,MAAA,CAAO,IAAA;AAK5B,IAAM,kBAAA,GAAqB,CAAA,CAAE,KAAA,CAAM,CAAC,UAAA,EAAY,EAAE,IAAA,EAAM,CAAC,CAAA,CAAE,QAAA;AAc3D,IAAM,qBAAA,GAAwB,EAAE,MAAA,CAAO;AAAA;AAAA,EAE5C,EAAA,EAAI,EAAE,MAAA,EAAO;AAAA;AAAA,EAEb,IAAA,EAAM,EAAE,MAAA,EAAO;AAAA;AAAA,EAEf,EAAA,EAAI,EAAE,MAAA,EAAO;AAAA;AAAA,EAEb,UAAA,EAAY,EAAE,MAAA,EAAO;AAAA;AAAA,EAErB,IAAA,EAAM,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA;AACnB,CAAC;AAmBM,IAAM,gBAAA,GAAmB,EAAE,MAAA,CAAO;AAAA;AAAA,EAEvC,WAAA,EAAa,EAAE,MAAA,EAAO;AAAA;AAAA,EAEtB,YAAA,EAAc,EAAE,MAAA,EAAO;AAAA;AAAA,EAEvB,WAAA,EAAa,EAAE,MAAA,EAAO;AAAA;AAAA,EAEtB,cAAA,EAAgB,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA;AAAA,EAEpC,OAAA,EAAS,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA;AACtB,CAAC;AAmBM,IAAM,oBAAA,GAAuB,EAAE,MAAA,CAAO;AAAA;AAAA,EAE3C,IAAA,EAAM,EAAE,MAAA,EAAO;AAAA;AAAA,EAEf,OAAA,EAAS,EAAE,MAAA,EAAO;AAAA;AA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common Zod Schemas - Shared Schema Definitions\n *\n * This file contains Zod schemas that are used across multiple domains.\n * Types are derived from these schemas to ensure a single source of truth.\n *\n * @remarks\n * Import schemas from here for validation.\n * Import types from here or from domain files for TypeScript types.\n */\n\nimport { z } from 'zod'\n\n// =============================================================================\n// Date Handling\n// =============================================================================\n\n/**\n * Schema for Date fields that can be either Date objects or ISO strings.\n * API responses typically return ISO strings, not Date objects.\n */\nexport const DateSchema = z.coerce.date()\n\n/**\n * Optional nullable date for responses\n */\nexport const OptionalDateSchema = z.union([DateSchema, z.null()]).optional()\n\n// =============================================================================\n// EntityReference\n// =============================================================================\n\n/**\n * Schema for EntityReference - reference to a Thing in the semantic graph.\n *\n * Used by:\n * - Relationships (subject/object in semantic triples)\n * - Events (subject/object in semantic events)\n * - Graph traversal results\n */\nexport const EntityReferenceSchema = z.object({\n /** Namespace */\n ns: z.string(),\n /** Entity type */\n type: z.string(),\n /** Entity ID */\n id: z.string(),\n /** Semantic ID (ns/type/id) */\n semanticId: z.string(),\n /** Display name (if loaded) */\n name: z.string().optional(),\n})\n\n/**\n * Reference to an entity (Thing) in the semantic graph.\n */\nexport type EntityReference = z.infer<typeof EntityReferenceSchema>\n\n// =============================================================================\n// TokenUsage\n// =============================================================================\n\n/**\n * Schema for TokenUsage - token usage metrics for AI operations.\n *\n * Used by:\n * - Agent executions\n * - Function executions (generative/agentic)\n * - Agent trace entries\n */\nexport const TokenUsageSchema = z.object({\n /** Input/prompt tokens */\n inputTokens: z.number(),\n /** Output/completion tokens */\n outputTokens: z.number(),\n /** Total tokens (input + output) */\n totalTokens: z.number(),\n /** Thinking tokens (for reasoning models like o1, Claude with thinking) */\n thinkingTokens: z.number().optional(),\n /** Estimated cost in USD */\n costUsd: z.number().optional(),\n})\n\n/**\n * Token usage metrics for AI operations.\n */\nexport type TokenUsage = z.infer<typeof TokenUsageSchema>\n\n// =============================================================================\n// ExecutionError\n// =============================================================================\n\n/**\n * Schema for ExecutionError - error information for execution failures.\n *\n * Used by:\n * - Workflow executions\n * - Function executions\n * - Step executions\n */\nexport const ExecutionErrorSchema = z.object({\n /** Error code (e.g., 'TIMEOUT', 'VALIDATION_ERROR', 'RATE_LIMITED') */\n code: z.string(),\n /** Human-readable error message */\n message: z.string(),\n /** Stack trace (for debugging) */\n stack: z.string().optional(),\n /** ID of the step that failed (for workflow executions) */\n failedStep: z.string().optional(),\n /** Number of retry attempts made (for function executions) */\n retryCount: z.number().optional(),\n /** Whether this error is retryable (for function executions) */\n retryable: z.boolean().optional(),\n})\n\n/**\n * Error information for execution failures.\n */\nexport type ExecutionError = z.infer<typeof ExecutionErrorSchema>\n\n// =============================================================================\n// SortDirection\n// =============================================================================\n\n/**\n * Schema for SortDirection - sort direction for list queries.\n */\nexport const SortDirectionSchema = z.enum(['asc', 'desc'])\n\n/**\n * Sort direction for list queries.\n */\nexport type SortDirection = z.infer<typeof SortDirectionSchema>\n\n// =============================================================================\n// Pagination Types\n// =============================================================================\n\n/**\n * Schema for Pagination - pagination input parameters for list queries.\n */\nexport const PaginationSchema = z.object({\n /** Page number (1-indexed) */\n page: z.number().int().positive(),\n /** Items per page */\n perPage: z.number().int().positive(),\n})\n\n/**\n * Pagination input parameters for list queries.\n */\nexport type Pagination = z.infer<typeof PaginationSchema>\n\n/**\n * Schema factory for paginated responses.\n */\nexport const PaginatedResponseSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>\n z.object({\n /** Array of items for the current page */\n data: z.array(dataSchema),\n /** Total number of items across all pages */\n total: z.number(),\n /** Current page number (1-indexed) */\n page: z.number(),\n /** Items per page */\n perPage: z.number(),\n /** Total number of pages */\n totalPages: z.number(),\n })\n\n/**\n * Paginated response wrapper for list queries.\n */\nexport interface PaginatedResponse<T> {\n /** Array of items for the current page */\n data: T[]\n /** Total number of items across all pages */\n total: number\n /** Current page number (1-indexed) */\n page: number\n /** Items per page */\n perPage: number\n /** Total number of pages */\n totalPages: number\n}\n","/**\n * Thing Zod Schemas - Semantic Entity Management\n *\n * Things are the core entities in the .do platform, stored in the Things table\n * with ClickHouse's ReplacingMergeTree engine for immutable, versioned storage.\n *\n * All types are derived from Zod schemas to ensure a single source of truth.\n *\n * @remarks\n * Key patterns:\n * - Semantic IDs: `[namespace]/[Name]` (e.g., `schema.org/Person`)\n * - JSON-LD compatible data structure\n * - Full version history via Events table\n * - Soft deletes with deletedAt timestamp\n */\n\nimport { z } from 'zod'\nimport { DateSchema, OptionalDateSchema, SortDirectionSchema } from './common'\n\n// =============================================================================\n// ThingData Schema\n// =============================================================================\n\n/**\n * Schema for ThingData - JSON-LD compatible data structure for Things.\n */\nexport const ThingDataSchema = z\n .object({\n /** JSON-LD context */\n '@context': z.union([z.string(), z.record(z.unknown())]).optional(),\n /** JSON-LD type (should match Thing.type) */\n '@type': z.string().optional(),\n /** JSON-LD identifier */\n '@id': z.string().optional(),\n })\n .passthrough()\n\n/**\n * JSON-LD compatible data structure for Things.\n */\nexport type ThingData = z.infer<typeof ThingDataSchema>\n\n// =============================================================================\n// Thing Schema\n// =============================================================================\n\n/**\n * Schema for Thing - base Thing record from database.\n */\nexport const ThingSchema = z.object({\n /** Namespace (tenant/domain) */\n ns: z.string(),\n /** Entity type (e.g., 'Person', 'Organization', 'Agent') */\n type: z.string(),\n /** Unique identifier within namespace/type */\n id: z.string(),\n /** Version timestamp for deduplication */\n ts: DateSchema,\n /** Display name */\n name: z.string(),\n /** Creation timestamp */\n createdAt: DateSchema,\n /** Last update timestamp */\n updatedAt: DateSchema,\n /** Creator user ID */\n createdBy: z.string().optional(),\n /** Last updater user ID */\n updatedBy: z.string().optional(),\n /** Soft delete timestamp */\n deletedAt: OptionalDateSchema,\n /** A/B test variant */\n variant: z.string().optional(),\n /** JSON-LD data blob */\n data: ThingDataSchema,\n})\n\n/**\n * Base Thing record from database.\n */\nexport type Thing = z.infer<typeof ThingSchema>\n\n// =============================================================================\n// ThingFilter Schema\n// =============================================================================\n\n/**\n * Schema for ThingFilter - query filters for Things.\n */\nexport const ThingFilterSchema = z\n .object({\n /** Filter by namespace - single string or array of strings */\n ns: z.union([z.string(), z.array(z.string())]).optional(),\n /** Filter by type - single string or array of strings */\n type: z.union([z.string(), z.array(z.string())]).optional(),\n /** Filter by ID pattern (supports wildcards) */\n idPattern: z.string().optional(),\n /** Filter by name (case-insensitive search) */\n nameSearch: z.string().optional(),\n /** Filter by creation date range - start */\n createdAfter: z.coerce.date().optional(),\n /** Filter by creation date range - end */\n createdBefore: z.coerce.date().optional(),\n /** Filter by update date range - start */\n updatedAfter: z.coerce.date().optional(),\n /** Filter by update date range - end */\n updatedBefore: z.coerce.date().optional(),\n /** Include soft-deleted things */\n includeDeleted: z.boolean().optional(),\n /** Filter by specific property values in data */\n properties: z.record(z.unknown()).optional(),\n /** Filter by variant */\n variant: z.string().optional(),\n })\n .passthrough()\n\n/**\n * Query filters for Things.\n */\nexport type ThingFilter = z.infer<typeof ThingFilterSchema>\n\n// =============================================================================\n// ThingSort Schema\n// =============================================================================\n\n/**\n * Schema for ThingSort - sort options for Things.\n */\nexport const ThingSortSchema = z.object({\n /** Field to sort by */\n field: z.enum(['name', 'createdAt', 'updatedAt', 'ts', 'type']),\n /** Sort direction */\n order: SortDirectionSchema,\n})\n\n/**\n * Sort options for Things.\n */\nexport type ThingSort = z.infer<typeof ThingSortSchema>\n\n// =============================================================================\n// ThingPagination Schema\n// =============================================================================\n\n/**\n * Schema for ThingPagination - pagination for Things queries.\n */\nexport const ThingPaginationSchema = z.object({\n /** Page number (1-indexed, must be positive) */\n page: z.number().int().positive(),\n /** Items per page (must be positive, max 1000) */\n perPage: z.number().int().positive().max(1000),\n})\n\n/**\n * Pagination for Things queries.\n */\nexport type ThingPagination = z.infer<typeof ThingPaginationSchema>\n\n// =============================================================================\n// ThingQueryResult Schema\n// =============================================================================\n\n/**\n * Schema for ThingQueryResult - result of a Things query.\n */\nexport const ThingQueryResultSchema = z.object({\n /** Matching things */\n data: z.array(ThingSchema),\n /** Total count (without pagination) */\n total: z.number(),\n /** Current page */\n page: z.number(),\n /** Items per page */\n perPage: z.number(),\n /** Total pages */\n totalPages: z.number(),\n})\n\n/**\n * Result of a Things query.\n */\nexport type ThingQueryResult = z.infer<typeof ThingQueryResultSchema>\n\n// =============================================================================\n// ThingCreateInput Schema\n// =============================================================================\n\n/**\n * Schema for ThingCreateInput - thing creation payload.\n */\nexport const ThingCreateInputSchema = z.object({\n /** Namespace (required, non-empty string) */\n ns: z.string().min(1, 'Namespace is required'),\n /** Type (required, non-empty string) */\n type: z.string().min(1, 'Type is required'),\n /** ID (optional, auto-generated if not provided) */\n id: z.string().optional(),\n /** Display name (required, non-empty string) */\n name: z.string().min(1, 'Name is required'),\n /** JSON-LD data */\n data: ThingDataSchema,\n /** Variant for A/B testing */\n variant: z.string().optional(),\n})\n\n/**\n * Thing creation payload.\n */\nexport type ThingCreateInput = z.infer<typeof ThingCreateInputSchema>\n\n// =============================================================================\n// ThingUpdateInput Schema\n// =============================================================================\n\n/**\n * Schema for ThingUpdateInput - thing update payload.\n */\nexport const ThingUpdateInputSchema = z.object({\n /** Updated name */\n name: z.string().min(1, 'Name cannot be empty').optional(),\n /** Updated data (merged with existing) */\n data: ThingDataSchema.partial().optional(),\n /** Updated variant */\n variant: z.string().optional(),\n})\n\n/**\n * Thing update payload.\n */\nexport type ThingUpdateInput = z.infer<typeof ThingUpdateInputSchema>\n\n// =============================================================================\n// ThingDeleteOptions Schema\n// =============================================================================\n\n/**\n * Schema for ThingDeleteOptions - delete options.\n */\nexport const ThingDeleteOptionsSchema = z.object({\n /** Hard delete (permanent) vs soft delete */\n hard: z.boolean().optional(),\n})\n\n/**\n * Thing delete options.\n */\nexport type ThingDeleteOptions = z.infer<typeof ThingDeleteOptionsSchema>\n\n// =============================================================================\n// ThingVersion Schema\n// =============================================================================\n\n/**\n * Schema for ThingVersion - thing version from Events table.\n */\nexport const ThingVersionSchema = z.object({\n /** Event ID */\n eventId: z.string(),\n /** Event type (create, update, delete) */\n eventType: z.enum(['create', 'update', 'delete', 'create_version', 'update_version']),\n /** Version timestamp */\n ts: DateSchema,\n /** User who made the change */\n userId: z.string(),\n /** Full data snapshot at this version */\n data: ThingDataSchema,\n /** Delta from previous version */\n delta: ThingDataSchema.optional(),\n /** Event metadata */\n metadata: z.record(z.unknown()),\n})\n\n/**\n * Thing version from Events table.\n */\nexport type ThingVersion = z.infer<typeof ThingVersionSchema>\n\n// =============================================================================\n// SemanticProperty Schema\n// =============================================================================\n\n/**\n * Schema for SemanticProperty - property definition for semantic types.\n */\nexport const SemanticPropertySchema = z.object({\n /** Property name */\n name: z.string(),\n /** Property label */\n label: z.string(),\n /** Property description */\n description: z.string(),\n /** Expected value types */\n rangeIncludes: z.array(z.string()),\n /** Types that use this property */\n domainIncludes: z.array(z.string()),\n /** Is this property required? */\n required: z.boolean(),\n /** Is this property an array? */\n isArray: z.boolean(),\n /** Default value */\n defaultValue: z.unknown().optional(),\n})\n\n/**\n * Property definition for semantic types.\n */\nexport type SemanticProperty = z.infer<typeof SemanticPropertySchema>\n\n// =============================================================================\n// SemanticType Schema\n// =============================================================================\n\n/**\n * Schema for SemanticType - semantic type definition (like schema.org types).\n */\nexport const SemanticTypeSchema = z.object({\n /** Type namespace (e.g., 'schema.org') */\n namespace: z.string(),\n /** Type name (e.g., 'Person') */\n name: z.string(),\n /** Full semantic ID */\n id: z.string(),\n /** Human-readable label */\n label: z.string(),\n /** Type description */\n description: z.string().optional(),\n /** Parent types (inheritance) */\n parentTypes: z.array(z.string()),\n /** Properties defined by this type */\n properties: z.array(SemanticPropertySchema),\n /** Child types */\n subtypes: z.array(z.string()),\n /** Example instances */\n examples: z.array(ThingDataSchema).optional(),\n})\n\n/**\n * Semantic type definition (like schema.org types).\n */\nexport type SemanticType = z.infer<typeof SemanticTypeSchema>\n\n// =============================================================================\n// Namespace Schema\n// =============================================================================\n\n/**\n * Schema for Namespace - namespace definition (tenant/domain).\n */\nexport const NamespaceSchema = z.object({\n /** Namespace identifier */\n id: z.string(),\n /** Namespace name */\n name: z.string(),\n /** Namespace description */\n description: z.string().optional(),\n /** Base URL for the namespace */\n baseUrl: z.string().optional(),\n /** Available types in this namespace */\n types: z.array(z.string()),\n /** Thing count in this namespace */\n thingCount: z.number(),\n /** Creation timestamp */\n createdAt: DateSchema,\n})\n\n/**\n * Namespace definition (tenant/domain).\n */\nexport type Namespace = z.infer<typeof NamespaceSchema>\n\n// =============================================================================\n// TypeStats Schema\n// =============================================================================\n\n/**\n * Schema for TypeStats - statistics for a type.\n */\nexport const TypeStatsSchema = z.object({\n /** Type name */\n type: z.string(),\n /** Namespace */\n ns: z.string(),\n /** Total count */\n count: z.number(),\n /** Active count (not deleted) */\n activeCount: z.number(),\n /** Created today */\n createdToday: z.number(),\n /** Updated today */\n updatedToday: z.number(),\n /** Most recent creation */\n lastCreatedAt: DateSchema.optional(),\n /** Most recent update */\n lastUpdatedAt: DateSchema.optional(),\n})\n\n/**\n * Statistics for a type.\n */\nexport type TypeStats = z.infer<typeof TypeStatsSchema>\n"]}
|