@01.software/sdk 0.4.3 → 0.5.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 (40) hide show
  1. package/README.md +13 -13
  2. package/dist/auth.d.cts +1 -1
  3. package/dist/auth.d.ts +1 -1
  4. package/dist/{const-C3GC2SxR.d.cts → const-BO4SPN7f.d.ts} +2 -2
  5. package/dist/{const-ikSyKVND.d.ts → const-hqVXNZoy.d.cts} +2 -2
  6. package/dist/index.cjs +9 -7
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +27 -18
  9. package/dist/index.d.ts +27 -18
  10. package/dist/index.js +9 -7
  11. package/dist/index.js.map +1 -1
  12. package/dist/{payload-types-DPka7hJu.d.cts → payload-types-mZpmjJBz.d.cts} +102 -4
  13. package/dist/{payload-types-DPka7hJu.d.ts → payload-types-mZpmjJBz.d.ts} +102 -4
  14. package/dist/realtime.cjs.map +1 -1
  15. package/dist/realtime.d.cts +2 -2
  16. package/dist/realtime.d.ts +2 -2
  17. package/dist/realtime.js.map +1 -1
  18. package/dist/server-B80o7igg.d.cts +242 -0
  19. package/dist/server-B80o7igg.d.ts +242 -0
  20. package/dist/ui/flow/server.cjs +233 -0
  21. package/dist/ui/flow/server.cjs.map +1 -0
  22. package/dist/ui/flow/server.d.cts +3 -0
  23. package/dist/ui/flow/server.d.ts +3 -0
  24. package/dist/ui/flow/server.js +213 -0
  25. package/dist/ui/flow/server.js.map +1 -0
  26. package/dist/ui/flow.cjs +540 -127
  27. package/dist/ui/flow.cjs.map +1 -1
  28. package/dist/ui/flow.d.cts +39 -189
  29. package/dist/ui/flow.d.ts +39 -189
  30. package/dist/ui/flow.js +544 -135
  31. package/dist/ui/flow.js.map +1 -1
  32. package/dist/ui/form.d.cts +1 -1
  33. package/dist/ui/form.d.ts +1 -1
  34. package/dist/ui/video.d.cts +1 -1
  35. package/dist/ui/video.d.ts +1 -1
  36. package/dist/{webhook-CvNTdBWV.d.ts → webhook-CMi4JRCp.d.ts} +3 -3
  37. package/dist/{webhook-B8BfJ_Ka.d.cts → webhook-D65mzWt2.d.cts} +3 -3
  38. package/dist/webhook.d.cts +3 -3
  39. package/dist/webhook.d.ts +3 -3
  40. package/package.json +19 -14
@@ -0,0 +1,242 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ import React from 'react';
3
+
4
+ interface DynamicNodeData {
5
+ nodeTypeSlug: string;
6
+ label: string;
7
+ fields: Record<string, unknown>;
8
+ }
9
+ type FlowNodeData = (DynamicNodeData | FrameNodeData) & Record<string, unknown>;
10
+ interface FlowNodePosition {
11
+ x: number;
12
+ y: number;
13
+ }
14
+ interface FlowNode {
15
+ id: string;
16
+ type?: string;
17
+ position: FlowNodePosition;
18
+ data: FlowNodeData;
19
+ parentId?: string;
20
+ style?: React.CSSProperties;
21
+ width?: number;
22
+ height?: number;
23
+ measured?: {
24
+ width?: number;
25
+ height?: number;
26
+ };
27
+ draggable?: boolean;
28
+ selectable?: boolean;
29
+ [key: string]: unknown;
30
+ }
31
+ interface FlowEdge {
32
+ id: string;
33
+ source: string;
34
+ target: string;
35
+ sourceHandle?: string | null;
36
+ targetHandle?: string | null;
37
+ type?: string;
38
+ style?: React.CSSProperties;
39
+ animated?: boolean;
40
+ markerStart?: unknown;
41
+ markerEnd?: unknown;
42
+ edgeTypeSlug?: string;
43
+ fields?: Record<string, unknown>;
44
+ [key: string]: unknown;
45
+ }
46
+ interface FlowViewport {
47
+ x: number;
48
+ y: number;
49
+ zoom: number;
50
+ }
51
+ interface CanvasData {
52
+ nodes: FlowNode[];
53
+ edges: FlowEdge[];
54
+ viewport: FlowViewport;
55
+ }
56
+ interface NodeTypeFieldDef {
57
+ name: string;
58
+ label: string;
59
+ fieldType: 'text' | 'textarea' | 'number' | 'url' | 'color' | 'image' | 'select' | 'toggle';
60
+ options?: {
61
+ label: string;
62
+ value: string;
63
+ }[];
64
+ defaultValue?: string;
65
+ required?: boolean;
66
+ }
67
+ interface NodeTypeDef {
68
+ slug: string;
69
+ name: string;
70
+ color: string;
71
+ defaultSize: {
72
+ width: number;
73
+ height: number;
74
+ };
75
+ fields: NodeTypeFieldDef[];
76
+ transparentBackground?: boolean;
77
+ template?: string | null;
78
+ customCSS?: string | null;
79
+ }
80
+ interface EdgeTypeDef {
81
+ slug: string;
82
+ name: string;
83
+ color: string;
84
+ strokeWidth: number;
85
+ animated: boolean;
86
+ lineStyle: string;
87
+ markerStart: string;
88
+ markerEnd: string;
89
+ fields: NodeTypeFieldDef[];
90
+ }
91
+ declare function isDynamicNode(node: FlowNode): node is FlowNode & {
92
+ data: DynamicNodeData;
93
+ };
94
+ declare function isFrameNode(node: FlowNode): node is FlowNode & {
95
+ data: FrameNodeData;
96
+ };
97
+ interface DynamicNodeSlotProps {
98
+ id: string;
99
+ nodeTypeSlug: string;
100
+ label: string;
101
+ fields: Record<string, unknown>;
102
+ nodeTypeDef?: NodeTypeDef;
103
+ /** Whether this node is currently selected */
104
+ selected?: boolean;
105
+ /** Measured node width (undefined before first measurement) */
106
+ width?: number;
107
+ /** Measured node height (undefined before first measurement) */
108
+ height?: number;
109
+ /** The default rendering (template or field-based). Allows custom renderers to wrap/extend instead of replacing entirely. */
110
+ defaultRender?: React.ReactElement;
111
+ }
112
+ interface FrameNodeData {
113
+ label: string;
114
+ color?: string;
115
+ padding?: number;
116
+ borderStyle?: 'dashed' | 'solid' | 'none';
117
+ opacity?: number;
118
+ }
119
+ interface FrameNodeSlotProps {
120
+ id: string;
121
+ label: string;
122
+ color?: string;
123
+ padding?: number;
124
+ borderStyle?: 'dashed' | 'solid' | 'none';
125
+ opacity?: number;
126
+ width?: number;
127
+ height?: number;
128
+ children?: React.ReactNode;
129
+ }
130
+ interface EdgeSlotProps {
131
+ id: string;
132
+ edgeTypeSlug?: string;
133
+ source: string;
134
+ target: string;
135
+ label?: string;
136
+ fields?: Record<string, unknown>;
137
+ edgeTypeDef?: EdgeTypeDef;
138
+ style?: React.CSSProperties;
139
+ }
140
+ interface NodeWrapperSlotProps {
141
+ id: string;
142
+ nodeTypeSlug: string;
143
+ label: string;
144
+ selected?: boolean;
145
+ nodeTypeDef?: NodeTypeDef;
146
+ children: React.ReactNode;
147
+ }
148
+ interface FlowBounds {
149
+ x: number;
150
+ y: number;
151
+ width: number;
152
+ height: number;
153
+ }
154
+
155
+ type FlowCollection = 'flows' | 'flow-node-types' | 'flow-edge-types';
156
+ type AnyFn = (...args: any[]) => any;
157
+ interface SDKClient {
158
+ from(collection: FlowCollection): {
159
+ find: AnyFn;
160
+ findById: AnyFn;
161
+ };
162
+ queryClient: QueryClient;
163
+ }
164
+ interface UseFlowOptions {
165
+ /** SDK client instance (Client or ServerClient) */
166
+ client: SDKClient;
167
+ /** Flow slug (URL-friendly identifier) */
168
+ slug?: string;
169
+ /** Flow document ID (UUID) */
170
+ id?: string;
171
+ /** Enable/disable data fetching (default: true) */
172
+ enabled?: boolean;
173
+ }
174
+ interface UseFlowResult {
175
+ data: CanvasData | undefined;
176
+ nodeTypeDefs: NodeTypeDef[];
177
+ edgeTypeDefs: EdgeTypeDef[];
178
+ flow: Record<string, unknown> | undefined;
179
+ isLoading: boolean;
180
+ error: Error | null;
181
+ }
182
+ declare function useFlow(options: UseFlowOptions): UseFlowResult;
183
+
184
+ interface PrefetchFlowOptions {
185
+ /** SDK client instance (Client or ServerClient) */
186
+ client: SDKClient;
187
+ /** Flow slug (URL-friendly identifier) */
188
+ slug?: string;
189
+ /** Flow document ID (UUID) */
190
+ id?: string;
191
+ }
192
+ /**
193
+ * Prefetch flow data into the query cache.
194
+ * Call in route loaders or server components to eliminate loading states on mount.
195
+ *
196
+ * ```ts
197
+ * // React Router loader / Server Component
198
+ * await prefetchFlow({ client, slug: 'Home' })
199
+ * ```
200
+ */
201
+ declare function prefetchFlow(options: PrefetchFlowOptions): Promise<void>;
202
+
203
+ /**
204
+ * Calculate bounding box for given node IDs.
205
+ * Pure function — usable in SSR, server components, or outside React.
206
+ */
207
+ declare function getNodeBounds(nodes: FlowNode[], nodeIds: string[]): FlowBounds | undefined;
208
+ /**
209
+ * Get all frame nodes with their bounds.
210
+ * Sorted by position (top-left to bottom-right).
211
+ */
212
+ declare function getFrames(nodes: FlowNode[]): Array<{
213
+ id: string;
214
+ label: string;
215
+ bounds: FlowBounds;
216
+ }>;
217
+ /** Result of getFrameData — contains filtered canvas + dual bounds. */
218
+ interface FrameData {
219
+ /** Canvas data containing only the frame's descendants (nodes have draggable: false). */
220
+ data: CanvasData;
221
+ /** Bounding box of child content nodes — use for initial viewport fit (centering). */
222
+ fitBounds: FlowBounds;
223
+ /** Bounding box of the frame itself — use for panning/zoom restriction (clamp). */
224
+ clampBounds: FlowBounds;
225
+ /** @deprecated Use fitBounds instead. Alias for clampBounds for backward compatibility. */
226
+ bounds: FlowBounds;
227
+ }
228
+ /**
229
+ * Extract a frame's descendants and related edges from canvas data.
230
+ * Recursively collects all nested children (supports nested frames).
231
+ * Returns undefined if frameId is not found or is not a frame node.
232
+ *
233
+ * Child nodes are marked `draggable: false` to prevent interfering with canvas panning.
234
+ * The frame node itself is included (use `frameRenderer={() => null}` to hide it).
235
+ *
236
+ * Returns dual bounds:
237
+ * - `fitBounds`: child content bounding box (for centering the viewport)
238
+ * - `clampBounds`: frame area bounding box (for panning restriction)
239
+ */
240
+ declare function getFrameData(data: CanvasData, frameId: string): FrameData | undefined;
241
+
242
+ export { type CanvasData as C, type DynamicNodeSlotProps as D, type EdgeTypeDef as E, type FlowNode as F, type NodeTypeDef as N, type PrefetchFlowOptions as P, type SDKClient as S, type UseFlowOptions as U, type FlowEdge as a, type FrameNodeSlotProps as b, type EdgeSlotProps as c, type NodeWrapperSlotProps as d, type FlowViewport as e, type FlowBounds as f, type FlowNodePosition as g, type FlowNodeData as h, type DynamicNodeData as i, type FrameNodeData as j, type NodeTypeFieldDef as k, isDynamicNode as l, isFrameNode as m, type UseFlowResult as n, getNodeBounds as o, prefetchFlow as p, getFrames as q, getFrameData as r, type FrameData as s, useFlow as u };
@@ -0,0 +1,242 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ import React from 'react';
3
+
4
+ interface DynamicNodeData {
5
+ nodeTypeSlug: string;
6
+ label: string;
7
+ fields: Record<string, unknown>;
8
+ }
9
+ type FlowNodeData = (DynamicNodeData | FrameNodeData) & Record<string, unknown>;
10
+ interface FlowNodePosition {
11
+ x: number;
12
+ y: number;
13
+ }
14
+ interface FlowNode {
15
+ id: string;
16
+ type?: string;
17
+ position: FlowNodePosition;
18
+ data: FlowNodeData;
19
+ parentId?: string;
20
+ style?: React.CSSProperties;
21
+ width?: number;
22
+ height?: number;
23
+ measured?: {
24
+ width?: number;
25
+ height?: number;
26
+ };
27
+ draggable?: boolean;
28
+ selectable?: boolean;
29
+ [key: string]: unknown;
30
+ }
31
+ interface FlowEdge {
32
+ id: string;
33
+ source: string;
34
+ target: string;
35
+ sourceHandle?: string | null;
36
+ targetHandle?: string | null;
37
+ type?: string;
38
+ style?: React.CSSProperties;
39
+ animated?: boolean;
40
+ markerStart?: unknown;
41
+ markerEnd?: unknown;
42
+ edgeTypeSlug?: string;
43
+ fields?: Record<string, unknown>;
44
+ [key: string]: unknown;
45
+ }
46
+ interface FlowViewport {
47
+ x: number;
48
+ y: number;
49
+ zoom: number;
50
+ }
51
+ interface CanvasData {
52
+ nodes: FlowNode[];
53
+ edges: FlowEdge[];
54
+ viewport: FlowViewport;
55
+ }
56
+ interface NodeTypeFieldDef {
57
+ name: string;
58
+ label: string;
59
+ fieldType: 'text' | 'textarea' | 'number' | 'url' | 'color' | 'image' | 'select' | 'toggle';
60
+ options?: {
61
+ label: string;
62
+ value: string;
63
+ }[];
64
+ defaultValue?: string;
65
+ required?: boolean;
66
+ }
67
+ interface NodeTypeDef {
68
+ slug: string;
69
+ name: string;
70
+ color: string;
71
+ defaultSize: {
72
+ width: number;
73
+ height: number;
74
+ };
75
+ fields: NodeTypeFieldDef[];
76
+ transparentBackground?: boolean;
77
+ template?: string | null;
78
+ customCSS?: string | null;
79
+ }
80
+ interface EdgeTypeDef {
81
+ slug: string;
82
+ name: string;
83
+ color: string;
84
+ strokeWidth: number;
85
+ animated: boolean;
86
+ lineStyle: string;
87
+ markerStart: string;
88
+ markerEnd: string;
89
+ fields: NodeTypeFieldDef[];
90
+ }
91
+ declare function isDynamicNode(node: FlowNode): node is FlowNode & {
92
+ data: DynamicNodeData;
93
+ };
94
+ declare function isFrameNode(node: FlowNode): node is FlowNode & {
95
+ data: FrameNodeData;
96
+ };
97
+ interface DynamicNodeSlotProps {
98
+ id: string;
99
+ nodeTypeSlug: string;
100
+ label: string;
101
+ fields: Record<string, unknown>;
102
+ nodeTypeDef?: NodeTypeDef;
103
+ /** Whether this node is currently selected */
104
+ selected?: boolean;
105
+ /** Measured node width (undefined before first measurement) */
106
+ width?: number;
107
+ /** Measured node height (undefined before first measurement) */
108
+ height?: number;
109
+ /** The default rendering (template or field-based). Allows custom renderers to wrap/extend instead of replacing entirely. */
110
+ defaultRender?: React.ReactElement;
111
+ }
112
+ interface FrameNodeData {
113
+ label: string;
114
+ color?: string;
115
+ padding?: number;
116
+ borderStyle?: 'dashed' | 'solid' | 'none';
117
+ opacity?: number;
118
+ }
119
+ interface FrameNodeSlotProps {
120
+ id: string;
121
+ label: string;
122
+ color?: string;
123
+ padding?: number;
124
+ borderStyle?: 'dashed' | 'solid' | 'none';
125
+ opacity?: number;
126
+ width?: number;
127
+ height?: number;
128
+ children?: React.ReactNode;
129
+ }
130
+ interface EdgeSlotProps {
131
+ id: string;
132
+ edgeTypeSlug?: string;
133
+ source: string;
134
+ target: string;
135
+ label?: string;
136
+ fields?: Record<string, unknown>;
137
+ edgeTypeDef?: EdgeTypeDef;
138
+ style?: React.CSSProperties;
139
+ }
140
+ interface NodeWrapperSlotProps {
141
+ id: string;
142
+ nodeTypeSlug: string;
143
+ label: string;
144
+ selected?: boolean;
145
+ nodeTypeDef?: NodeTypeDef;
146
+ children: React.ReactNode;
147
+ }
148
+ interface FlowBounds {
149
+ x: number;
150
+ y: number;
151
+ width: number;
152
+ height: number;
153
+ }
154
+
155
+ type FlowCollection = 'flows' | 'flow-node-types' | 'flow-edge-types';
156
+ type AnyFn = (...args: any[]) => any;
157
+ interface SDKClient {
158
+ from(collection: FlowCollection): {
159
+ find: AnyFn;
160
+ findById: AnyFn;
161
+ };
162
+ queryClient: QueryClient;
163
+ }
164
+ interface UseFlowOptions {
165
+ /** SDK client instance (Client or ServerClient) */
166
+ client: SDKClient;
167
+ /** Flow slug (URL-friendly identifier) */
168
+ slug?: string;
169
+ /** Flow document ID (UUID) */
170
+ id?: string;
171
+ /** Enable/disable data fetching (default: true) */
172
+ enabled?: boolean;
173
+ }
174
+ interface UseFlowResult {
175
+ data: CanvasData | undefined;
176
+ nodeTypeDefs: NodeTypeDef[];
177
+ edgeTypeDefs: EdgeTypeDef[];
178
+ flow: Record<string, unknown> | undefined;
179
+ isLoading: boolean;
180
+ error: Error | null;
181
+ }
182
+ declare function useFlow(options: UseFlowOptions): UseFlowResult;
183
+
184
+ interface PrefetchFlowOptions {
185
+ /** SDK client instance (Client or ServerClient) */
186
+ client: SDKClient;
187
+ /** Flow slug (URL-friendly identifier) */
188
+ slug?: string;
189
+ /** Flow document ID (UUID) */
190
+ id?: string;
191
+ }
192
+ /**
193
+ * Prefetch flow data into the query cache.
194
+ * Call in route loaders or server components to eliminate loading states on mount.
195
+ *
196
+ * ```ts
197
+ * // React Router loader / Server Component
198
+ * await prefetchFlow({ client, slug: 'Home' })
199
+ * ```
200
+ */
201
+ declare function prefetchFlow(options: PrefetchFlowOptions): Promise<void>;
202
+
203
+ /**
204
+ * Calculate bounding box for given node IDs.
205
+ * Pure function — usable in SSR, server components, or outside React.
206
+ */
207
+ declare function getNodeBounds(nodes: FlowNode[], nodeIds: string[]): FlowBounds | undefined;
208
+ /**
209
+ * Get all frame nodes with their bounds.
210
+ * Sorted by position (top-left to bottom-right).
211
+ */
212
+ declare function getFrames(nodes: FlowNode[]): Array<{
213
+ id: string;
214
+ label: string;
215
+ bounds: FlowBounds;
216
+ }>;
217
+ /** Result of getFrameData — contains filtered canvas + dual bounds. */
218
+ interface FrameData {
219
+ /** Canvas data containing only the frame's descendants (nodes have draggable: false). */
220
+ data: CanvasData;
221
+ /** Bounding box of child content nodes — use for initial viewport fit (centering). */
222
+ fitBounds: FlowBounds;
223
+ /** Bounding box of the frame itself — use for panning/zoom restriction (clamp). */
224
+ clampBounds: FlowBounds;
225
+ /** @deprecated Use fitBounds instead. Alias for clampBounds for backward compatibility. */
226
+ bounds: FlowBounds;
227
+ }
228
+ /**
229
+ * Extract a frame's descendants and related edges from canvas data.
230
+ * Recursively collects all nested children (supports nested frames).
231
+ * Returns undefined if frameId is not found or is not a frame node.
232
+ *
233
+ * Child nodes are marked `draggable: false` to prevent interfering with canvas panning.
234
+ * The frame node itself is included (use `frameRenderer={() => null}` to hide it).
235
+ *
236
+ * Returns dual bounds:
237
+ * - `fitBounds`: child content bounding box (for centering the viewport)
238
+ * - `clampBounds`: frame area bounding box (for panning restriction)
239
+ */
240
+ declare function getFrameData(data: CanvasData, frameId: string): FrameData | undefined;
241
+
242
+ export { type CanvasData as C, type DynamicNodeSlotProps as D, type EdgeTypeDef as E, type FlowNode as F, type NodeTypeDef as N, type PrefetchFlowOptions as P, type SDKClient as S, type UseFlowOptions as U, type FlowEdge as a, type FrameNodeSlotProps as b, type EdgeSlotProps as c, type NodeWrapperSlotProps as d, type FlowViewport as e, type FlowBounds as f, type FlowNodePosition as g, type FlowNodeData as h, type DynamicNodeData as i, type FrameNodeData as j, type NodeTypeFieldDef as k, isDynamicNode as l, isFrameNode as m, type UseFlowResult as n, getNodeBounds as o, prefetchFlow as p, getFrames as q, getFrameData as r, type FrameData as s, useFlow as u };