@01.software/sdk 0.2.7 → 0.2.9-dev.260305.35fd2d4
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 +37 -8
- package/dist/{auth-ZBsN9vPn.d.cts → auth-CDyJoENT.d.cts} +1 -1
- package/dist/{auth-D-_Ju7m5.d.ts → auth-Gb34eOkR.d.ts} +1 -1
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +2 -2
- package/dist/auth.d.ts +2 -2
- package/dist/auth.js.map +1 -1
- package/dist/components.cjs +225 -42
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +98 -16
- package/dist/components.d.ts +98 -16
- package/dist/components.js +218 -34
- package/dist/components.js.map +1 -1
- package/dist/flow.cjs +148 -0
- package/dist/flow.cjs.map +1 -0
- package/dist/flow.d.cts +116 -0
- package/dist/flow.d.ts +116 -0
- package/dist/flow.js +123 -0
- package/dist/flow.js.map +1 -0
- package/dist/index.cjs +70 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -21
- package/dist/index.d.ts +48 -21
- package/dist/index.js +70 -15
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-CRSz8jfP.d.cts → payload-types-BFAXKjly.d.cts} +242 -79
- package/dist/{payload-types-CRSz8jfP.d.ts → payload-types-BFAXKjly.d.ts} +242 -79
- package/dist/{webhook-Dn5o0LXq.d.cts → webhook-CmbS5Uu3.d.cts} +2 -2
- package/dist/{webhook-C_DHB0Sw.d.ts → webhook-Ct6PD0Ys.d.ts} +2 -2
- package/dist/webhook.d.cts +2 -2
- package/dist/webhook.d.ts +2 -2
- package/package.json +29 -3
package/dist/flow.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
declare const FLOW_NODE_TYPES: readonly ["text", "image", "iframe", "note"];
|
|
4
|
+
type FlowNodeType = (typeof FLOW_NODE_TYPES)[number];
|
|
5
|
+
interface BaseNodeData {
|
|
6
|
+
label: string;
|
|
7
|
+
}
|
|
8
|
+
interface TextNodeData extends BaseNodeData {
|
|
9
|
+
nodeType: 'text';
|
|
10
|
+
body?: string;
|
|
11
|
+
}
|
|
12
|
+
interface ImageNodeData extends BaseNodeData {
|
|
13
|
+
nodeType: 'image';
|
|
14
|
+
imageId?: string;
|
|
15
|
+
imageUrl?: string;
|
|
16
|
+
alt?: string;
|
|
17
|
+
caption?: string;
|
|
18
|
+
}
|
|
19
|
+
interface IframeNodeData extends BaseNodeData {
|
|
20
|
+
nodeType: 'iframe';
|
|
21
|
+
url?: string;
|
|
22
|
+
}
|
|
23
|
+
interface NoteNodeData extends BaseNodeData {
|
|
24
|
+
nodeType: 'note';
|
|
25
|
+
body?: string;
|
|
26
|
+
color?: string;
|
|
27
|
+
}
|
|
28
|
+
type FlowNodeData = (TextNodeData | ImageNodeData | IframeNodeData | NoteNodeData) & Record<string, unknown>;
|
|
29
|
+
interface FlowNodePosition {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
}
|
|
33
|
+
interface FlowNode {
|
|
34
|
+
id: string;
|
|
35
|
+
type?: string;
|
|
36
|
+
position: FlowNodePosition;
|
|
37
|
+
data: FlowNodeData;
|
|
38
|
+
style?: React.CSSProperties;
|
|
39
|
+
width?: number;
|
|
40
|
+
height?: number;
|
|
41
|
+
measured?: {
|
|
42
|
+
width?: number;
|
|
43
|
+
height?: number;
|
|
44
|
+
};
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
}
|
|
47
|
+
interface FlowEdge {
|
|
48
|
+
id: string;
|
|
49
|
+
source: string;
|
|
50
|
+
target: string;
|
|
51
|
+
sourceHandle?: string | null;
|
|
52
|
+
targetHandle?: string | null;
|
|
53
|
+
type?: string;
|
|
54
|
+
style?: React.CSSProperties;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
interface FlowViewport {
|
|
58
|
+
x: number;
|
|
59
|
+
y: number;
|
|
60
|
+
zoom: number;
|
|
61
|
+
}
|
|
62
|
+
interface CanvasData {
|
|
63
|
+
nodes: FlowNode[];
|
|
64
|
+
edges: FlowEdge[];
|
|
65
|
+
viewport: FlowViewport;
|
|
66
|
+
}
|
|
67
|
+
interface TextNodeSlotProps {
|
|
68
|
+
id: string;
|
|
69
|
+
data: TextNodeData;
|
|
70
|
+
}
|
|
71
|
+
interface ImageNodeSlotProps {
|
|
72
|
+
id: string;
|
|
73
|
+
data: ImageNodeData;
|
|
74
|
+
}
|
|
75
|
+
interface IframeNodeSlotProps {
|
|
76
|
+
id: string;
|
|
77
|
+
data: IframeNodeData;
|
|
78
|
+
}
|
|
79
|
+
interface NoteNodeSlotProps {
|
|
80
|
+
id: string;
|
|
81
|
+
data: NoteNodeData;
|
|
82
|
+
}
|
|
83
|
+
interface FlowNodeComponents {
|
|
84
|
+
Text?: React.ComponentType<TextNodeSlotProps>;
|
|
85
|
+
Image?: React.ComponentType<ImageNodeSlotProps>;
|
|
86
|
+
Iframe?: React.ComponentType<IframeNodeSlotProps>;
|
|
87
|
+
Note?: React.ComponentType<NoteNodeSlotProps>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Renders a Flow canvas in read-only mode.
|
|
92
|
+
*
|
|
93
|
+
* Requires `@xyflow/react` peer dependency and its CSS:
|
|
94
|
+
* ```ts
|
|
95
|
+
* import '@xyflow/react/dist/style.css'
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
interface FlowRendererProps {
|
|
99
|
+
/** Canvas data from Flow document's `canvas` field */
|
|
100
|
+
data: CanvasData;
|
|
101
|
+
/** Container className */
|
|
102
|
+
className?: string;
|
|
103
|
+
/** Container style */
|
|
104
|
+
style?: React.CSSProperties;
|
|
105
|
+
/** Custom node type components (memoize or define outside component to avoid re-renders) */
|
|
106
|
+
nodeComponents?: FlowNodeComponents;
|
|
107
|
+
/** Show background pattern (default: true) */
|
|
108
|
+
background?: boolean;
|
|
109
|
+
/** Allow user interaction - pan, zoom (default: false for read-only display) */
|
|
110
|
+
interactive?: boolean;
|
|
111
|
+
/** Fit view on mount (default: true) */
|
|
112
|
+
fitView?: boolean;
|
|
113
|
+
}
|
|
114
|
+
declare function FlowRenderer({ data, className, style, nodeComponents, background, interactive, fitView, }: FlowRendererProps): React.JSX.Element;
|
|
115
|
+
|
|
116
|
+
export { type CanvasData, FLOW_NODE_TYPES, type FlowEdge, type FlowNode, type FlowNodeComponents, type FlowNodeData, type FlowNodePosition, type FlowNodeType, FlowRenderer, type FlowRendererProps, type FlowViewport, type IframeNodeData, type IframeNodeSlotProps, type ImageNodeData, type ImageNodeSlotProps, type NoteNodeData, type NoteNodeSlotProps, type TextNodeData, type TextNodeSlotProps };
|
package/dist/flow.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __spreadValues = (a, b) => {
|
|
8
|
+
for (var prop in b || (b = {}))
|
|
9
|
+
if (__hasOwnProp.call(b, prop))
|
|
10
|
+
__defNormalProp(a, prop, b[prop]);
|
|
11
|
+
if (__getOwnPropSymbols)
|
|
12
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
13
|
+
if (__propIsEnum.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
}
|
|
16
|
+
return a;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// src/components/FlowRenderer/index.tsx
|
|
20
|
+
import React from "react";
|
|
21
|
+
import {
|
|
22
|
+
ReactFlow,
|
|
23
|
+
Background
|
|
24
|
+
} from "@xyflow/react";
|
|
25
|
+
|
|
26
|
+
// src/components/FlowRenderer/types.ts
|
|
27
|
+
var FLOW_NODE_TYPES = ["text", "image", "iframe", "note"];
|
|
28
|
+
|
|
29
|
+
// src/components/FlowRenderer/index.tsx
|
|
30
|
+
function DefaultTextNode({ data }) {
|
|
31
|
+
const d = data;
|
|
32
|
+
return /* @__PURE__ */ React.createElement("div", { style: { padding: 12 } }, /* @__PURE__ */ React.createElement("strong", null, d.label), d.body && /* @__PURE__ */ React.createElement("p", { style: { margin: "8px 0 0", whiteSpace: "pre-wrap" } }, d.body));
|
|
33
|
+
}
|
|
34
|
+
function DefaultImageNode({ data }) {
|
|
35
|
+
const d = data;
|
|
36
|
+
return /* @__PURE__ */ React.createElement("div", { style: { padding: 12 } }, /* @__PURE__ */ React.createElement("strong", null, d.label), d.imageUrl && /* @__PURE__ */ React.createElement(
|
|
37
|
+
"img",
|
|
38
|
+
{
|
|
39
|
+
src: d.imageUrl,
|
|
40
|
+
alt: d.alt || d.label,
|
|
41
|
+
style: { width: "100%", marginTop: 8, borderRadius: 4 }
|
|
42
|
+
}
|
|
43
|
+
), d.caption && /* @__PURE__ */ React.createElement("p", { style: { margin: "4px 0 0", fontSize: "0.85em", opacity: 0.7 } }, d.caption));
|
|
44
|
+
}
|
|
45
|
+
function DefaultIframeNode({ data }) {
|
|
46
|
+
const d = data;
|
|
47
|
+
return /* @__PURE__ */ React.createElement("div", { style: { padding: 12 } }, /* @__PURE__ */ React.createElement("strong", null, d.label), d.url && /* @__PURE__ */ React.createElement(
|
|
48
|
+
"iframe",
|
|
49
|
+
{
|
|
50
|
+
src: d.url,
|
|
51
|
+
title: d.label,
|
|
52
|
+
style: { width: "100%", height: 150, border: "none", marginTop: 8, borderRadius: 4 }
|
|
53
|
+
}
|
|
54
|
+
));
|
|
55
|
+
}
|
|
56
|
+
function DefaultNoteNode({ data }) {
|
|
57
|
+
const d = data;
|
|
58
|
+
return /* @__PURE__ */ React.createElement("div", { style: { padding: 12, backgroundColor: d.color || "#fef3c7", borderRadius: 4 } }, /* @__PURE__ */ React.createElement("strong", null, d.label), d.body && /* @__PURE__ */ React.createElement("p", { style: { margin: "8px 0 0", whiteSpace: "pre-wrap" } }, d.body));
|
|
59
|
+
}
|
|
60
|
+
function createNodeTypes(components) {
|
|
61
|
+
const types = {};
|
|
62
|
+
if (components == null ? void 0 : components.Text) {
|
|
63
|
+
const Text = components.Text;
|
|
64
|
+
types.text = (({ id, data }) => /* @__PURE__ */ React.createElement(Text, { id, data }));
|
|
65
|
+
} else {
|
|
66
|
+
types.text = DefaultTextNode;
|
|
67
|
+
}
|
|
68
|
+
if (components == null ? void 0 : components.Image) {
|
|
69
|
+
const Image = components.Image;
|
|
70
|
+
types.image = (({ id, data }) => /* @__PURE__ */ React.createElement(Image, { id, data }));
|
|
71
|
+
} else {
|
|
72
|
+
types.image = DefaultImageNode;
|
|
73
|
+
}
|
|
74
|
+
if (components == null ? void 0 : components.Iframe) {
|
|
75
|
+
const Iframe = components.Iframe;
|
|
76
|
+
types.iframe = (({ id, data }) => /* @__PURE__ */ React.createElement(Iframe, { id, data }));
|
|
77
|
+
} else {
|
|
78
|
+
types.iframe = DefaultIframeNode;
|
|
79
|
+
}
|
|
80
|
+
if (components == null ? void 0 : components.Note) {
|
|
81
|
+
const Note = components.Note;
|
|
82
|
+
types.note = (({ id, data }) => /* @__PURE__ */ React.createElement(Note, { id, data }));
|
|
83
|
+
} else {
|
|
84
|
+
types.note = DefaultNoteNode;
|
|
85
|
+
}
|
|
86
|
+
return types;
|
|
87
|
+
}
|
|
88
|
+
function FlowRenderer({
|
|
89
|
+
data,
|
|
90
|
+
className,
|
|
91
|
+
style,
|
|
92
|
+
nodeComponents,
|
|
93
|
+
background = true,
|
|
94
|
+
interactive = false,
|
|
95
|
+
fitView = true
|
|
96
|
+
}) {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
const nodeTypes = React.useMemo(() => createNodeTypes(nodeComponents), [nodeComponents]);
|
|
99
|
+
const defaultViewport = !fitView && data.viewport ? data.viewport : void 0;
|
|
100
|
+
return /* @__PURE__ */ React.createElement("div", { className, style: __spreadValues({ width: "100%", height: "100%" }, style) }, /* @__PURE__ */ React.createElement(
|
|
101
|
+
ReactFlow,
|
|
102
|
+
{
|
|
103
|
+
nodes: (_a = data.nodes) != null ? _a : [],
|
|
104
|
+
edges: (_b = data.edges) != null ? _b : [],
|
|
105
|
+
nodeTypes,
|
|
106
|
+
defaultViewport,
|
|
107
|
+
fitView,
|
|
108
|
+
nodesDraggable: interactive,
|
|
109
|
+
nodesConnectable: false,
|
|
110
|
+
elementsSelectable: interactive,
|
|
111
|
+
panOnDrag: interactive,
|
|
112
|
+
zoomOnScroll: interactive,
|
|
113
|
+
zoomOnPinch: interactive,
|
|
114
|
+
zoomOnDoubleClick: false
|
|
115
|
+
},
|
|
116
|
+
background && /* @__PURE__ */ React.createElement(Background, null)
|
|
117
|
+
));
|
|
118
|
+
}
|
|
119
|
+
export {
|
|
120
|
+
FLOW_NODE_TYPES,
|
|
121
|
+
FlowRenderer
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=flow.js.map
|
package/dist/flow.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/FlowRenderer/index.tsx","../src/components/FlowRenderer/types.ts"],"sourcesContent":["'use client'\n\nimport React from 'react'\nimport {\n ReactFlow,\n Background,\n type NodeTypes,\n type NodeProps,\n} from '@xyflow/react'\nimport type {\n CanvasData,\n FlowNodeComponents,\n TextNodeData,\n ImageNodeData,\n IframeNodeData,\n NoteNodeData,\n} from './types'\n\nexport { FLOW_NODE_TYPES } from './types'\nexport type { CanvasData, FlowNodeComponents } from './types'\nexport type {\n FlowNodeType,\n FlowNode,\n FlowEdge,\n FlowViewport,\n FlowNodeData,\n TextNodeData,\n ImageNodeData,\n IframeNodeData,\n NoteNodeData,\n TextNodeSlotProps,\n ImageNodeSlotProps,\n IframeNodeSlotProps,\n NoteNodeSlotProps,\n FlowNodePosition,\n} from './types'\n\n// ── Default node renderers ──\n\nfunction DefaultTextNode({ data }: NodeProps) {\n const d = data as unknown as TextNodeData\n return (\n <div style={{ padding: 12 }}>\n <strong>{d.label}</strong>\n {d.body && <p style={{ margin: '8px 0 0', whiteSpace: 'pre-wrap' }}>{d.body}</p>}\n </div>\n )\n}\n\nfunction DefaultImageNode({ data }: NodeProps) {\n const d = data as unknown as ImageNodeData\n return (\n <div style={{ padding: 12 }}>\n <strong>{d.label}</strong>\n {d.imageUrl && (\n <img\n src={d.imageUrl}\n alt={d.alt || d.label}\n style={{ width: '100%', marginTop: 8, borderRadius: 4 }}\n />\n )}\n {d.caption && (\n <p style={{ margin: '4px 0 0', fontSize: '0.85em', opacity: 0.7 }}>{d.caption}</p>\n )}\n </div>\n )\n}\n\nfunction DefaultIframeNode({ data }: NodeProps) {\n const d = data as unknown as IframeNodeData\n return (\n <div style={{ padding: 12 }}>\n <strong>{d.label}</strong>\n {d.url && (\n <iframe\n src={d.url}\n title={d.label}\n style={{ width: '100%', height: 150, border: 'none', marginTop: 8, borderRadius: 4 }}\n />\n )}\n </div>\n )\n}\n\nfunction DefaultNoteNode({ data }: NodeProps) {\n const d = data as unknown as NoteNodeData\n return (\n <div style={{ padding: 12, backgroundColor: d.color || '#fef3c7', borderRadius: 4 }}>\n <strong>{d.label}</strong>\n {d.body && <p style={{ margin: '8px 0 0', whiteSpace: 'pre-wrap' }}>{d.body}</p>}\n </div>\n )\n}\n\nfunction createNodeTypes(components?: FlowNodeComponents): NodeTypes {\n const types: NodeTypes = {} as NodeTypes\n\n if (components?.Text) {\n const Text = components.Text\n types.text = (({ id, data }: NodeProps) => (\n <Text id={id} data={data as unknown as TextNodeData} />\n )) as NodeTypes[string]\n } else {\n types.text = DefaultTextNode as NodeTypes[string]\n }\n\n if (components?.Image) {\n const Image = components.Image\n types.image = (({ id, data }: NodeProps) => (\n <Image id={id} data={data as unknown as ImageNodeData} />\n )) as NodeTypes[string]\n } else {\n types.image = DefaultImageNode as NodeTypes[string]\n }\n\n if (components?.Iframe) {\n const Iframe = components.Iframe\n types.iframe = (({ id, data }: NodeProps) => (\n <Iframe id={id} data={data as unknown as IframeNodeData} />\n )) as NodeTypes[string]\n } else {\n types.iframe = DefaultIframeNode as NodeTypes[string]\n }\n\n if (components?.Note) {\n const Note = components.Note\n types.note = (({ id, data }: NodeProps) => (\n <Note id={id} data={data as unknown as NoteNodeData} />\n )) as NodeTypes[string]\n } else {\n types.note = DefaultNoteNode as NodeTypes[string]\n }\n\n return types\n}\n\n// ── FlowRenderer ──\n\n/**\n * Renders a Flow canvas in read-only mode.\n *\n * Requires `@xyflow/react` peer dependency and its CSS:\n * ```ts\n * import '@xyflow/react/dist/style.css'\n * ```\n */\nexport interface FlowRendererProps {\n /** Canvas data from Flow document's `canvas` field */\n data: CanvasData\n /** Container className */\n className?: string\n /** Container style */\n style?: React.CSSProperties\n /** Custom node type components (memoize or define outside component to avoid re-renders) */\n nodeComponents?: FlowNodeComponents\n /** Show background pattern (default: true) */\n background?: boolean\n /** Allow user interaction - pan, zoom (default: false for read-only display) */\n interactive?: boolean\n /** Fit view on mount (default: true) */\n fitView?: boolean\n}\n\nexport function FlowRenderer({\n data,\n className,\n style,\n nodeComponents,\n background = true,\n interactive = false,\n fitView = true,\n}: FlowRendererProps) {\n const nodeTypes = React.useMemo(() => createNodeTypes(nodeComponents), [nodeComponents])\n\n const defaultViewport = !fitView && data.viewport ? data.viewport : undefined\n\n return (\n <div className={className} style={{ width: '100%', height: '100%', ...style }}>\n <ReactFlow\n nodes={(data.nodes ?? []) as unknown as Parameters<typeof ReactFlow>[0]['nodes']}\n edges={(data.edges ?? []) as unknown as Parameters<typeof ReactFlow>[0]['edges']}\n nodeTypes={nodeTypes}\n defaultViewport={defaultViewport}\n fitView={fitView}\n nodesDraggable={interactive}\n nodesConnectable={false}\n elementsSelectable={interactive}\n panOnDrag={interactive}\n zoomOnScroll={interactive}\n zoomOnPinch={interactive}\n zoomOnDoubleClick={false}\n >\n {background && <Background />}\n </ReactFlow>\n </div>\n )\n}\n","import type React from 'react'\n\n// ── Node type constants ──\n\nexport const FLOW_NODE_TYPES = ['text', 'image', 'iframe', 'note'] as const\n\nexport type FlowNodeType = (typeof FLOW_NODE_TYPES)[number]\n\n// ── Per-type data ──\n\ninterface BaseNodeData {\n label: string\n}\n\nexport interface TextNodeData extends BaseNodeData {\n nodeType: 'text'\n body?: string\n}\n\nexport interface ImageNodeData extends BaseNodeData {\n nodeType: 'image'\n imageId?: string\n imageUrl?: string\n alt?: string\n caption?: string\n}\n\nexport interface IframeNodeData extends BaseNodeData {\n nodeType: 'iframe'\n url?: string\n}\n\nexport interface NoteNodeData extends BaseNodeData {\n nodeType: 'note'\n body?: string\n color?: string\n}\n\nexport type FlowNodeData = (TextNodeData | ImageNodeData | IframeNodeData | NoteNodeData) &\n Record<string, unknown>\n\n// ── Canvas types (mirrors @xyflow/react but standalone) ──\n\nexport interface FlowNodePosition {\n x: number\n y: number\n}\n\nexport interface FlowNode {\n id: string\n type?: string\n position: FlowNodePosition\n data: FlowNodeData\n style?: React.CSSProperties\n width?: number\n height?: number\n measured?: { width?: number; height?: number }\n [key: string]: unknown\n}\n\nexport interface FlowEdge {\n id: string\n source: string\n target: string\n sourceHandle?: string | null\n targetHandle?: string | null\n type?: string\n style?: React.CSSProperties\n [key: string]: unknown\n}\n\nexport interface FlowViewport {\n x: number\n y: number\n zoom: number\n}\n\nexport interface CanvasData {\n nodes: FlowNode[]\n edges: FlowEdge[]\n viewport: FlowViewport\n}\n\n// ── Component slot props ──\n\nexport interface TextNodeSlotProps {\n id: string\n data: TextNodeData\n}\n\nexport interface ImageNodeSlotProps {\n id: string\n data: ImageNodeData\n}\n\nexport interface IframeNodeSlotProps {\n id: string\n data: IframeNodeData\n}\n\nexport interface NoteNodeSlotProps {\n id: string\n data: NoteNodeData\n}\n\nexport interface FlowNodeComponents {\n Text?: React.ComponentType<TextNodeSlotProps>\n Image?: React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AM,gBAAgB,cAAc,GAAG,CAAC,cAAc,CAAC;AAEvF,QAAM,kBAAkB,CAAC,WAAW,KAAK,WAAW,KAAK,WAAW;AAEpE,SACE,oCAAC,SAAI,WAAsB,OAAO,iBAAE,OAAO,QAAQ,QAAQ,UAAW,UACpE;AAAA,IAAC;AAAA;AAAA,MACC,QAAQ,UAAK,UAAL,YAAc,CAAC;AAAA,MACvB,QAAQ,UAAK,UAAL,YAAc,CAAC;AAAA,MACvB;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB,kBAAkB;AAAA,MAClB,oBAAoB;AAAA,MACpB,WAAW;AAAA,MACX,cAAc;AAAA,MACd,aAAa;AAAA,MACb,mBAAmB;AAAA;AAAA,IAElB,cAAc,oCAAC,gBAAW;AAAA,EAC7B,CACF;AAEJ;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -385,7 +385,7 @@ function _fetch(url, options) {
|
|
|
385
385
|
if (authToken) {
|
|
386
386
|
headers.set("Authorization", `Bearer ${authToken}`);
|
|
387
387
|
}
|
|
388
|
-
if (!headers.has("Content-Type") && requestInit.body) {
|
|
388
|
+
if (!headers.has("Content-Type") && requestInit.body && !(requestInit.body instanceof FormData)) {
|
|
389
389
|
headers.set("Content-Type", "application/json");
|
|
390
390
|
}
|
|
391
391
|
const redactedHeaders = Object.fromEntries(headers.entries());
|
|
@@ -701,7 +701,7 @@ var ProductApi = class {
|
|
|
701
701
|
|
|
702
702
|
// src/utils/types.ts
|
|
703
703
|
var resolveRelation = (ref) => {
|
|
704
|
-
if (typeof ref === "string" ||
|
|
704
|
+
if (typeof ref === "string" || ref === null || ref === void 0)
|
|
705
705
|
return null;
|
|
706
706
|
return ref;
|
|
707
707
|
};
|
|
@@ -789,12 +789,18 @@ var CollectionQueryBuilder = class {
|
|
|
789
789
|
* POST /api/{collection}
|
|
790
790
|
* @returns Payload CMS mutation response with doc and message
|
|
791
791
|
*/
|
|
792
|
-
create(data) {
|
|
792
|
+
create(data, options) {
|
|
793
793
|
return __async(this, null, function* () {
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
794
|
+
const endpoint = `/api/${String(this.collection)}`;
|
|
795
|
+
if (options == null ? void 0 : options.file) {
|
|
796
|
+
return this.api.requestCreateWithFile(
|
|
797
|
+
endpoint,
|
|
798
|
+
data,
|
|
799
|
+
options.file,
|
|
800
|
+
options.filename
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
return this.api.requestCreate(endpoint, data);
|
|
798
804
|
});
|
|
799
805
|
}
|
|
800
806
|
/**
|
|
@@ -802,12 +808,18 @@ var CollectionQueryBuilder = class {
|
|
|
802
808
|
* PATCH /api/{collection}/{id}
|
|
803
809
|
* @returns Payload CMS mutation response with doc and message
|
|
804
810
|
*/
|
|
805
|
-
update(id, data) {
|
|
811
|
+
update(id, data, options) {
|
|
806
812
|
return __async(this, null, function* () {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
813
|
+
const endpoint = `/api/${String(this.collection)}/${String(id)}`;
|
|
814
|
+
if (options == null ? void 0 : options.file) {
|
|
815
|
+
return this.api.requestUpdateWithFile(
|
|
816
|
+
endpoint,
|
|
817
|
+
data,
|
|
818
|
+
options.file,
|
|
819
|
+
options.filename
|
|
820
|
+
);
|
|
821
|
+
}
|
|
822
|
+
return this.api.requestUpdate(endpoint, data);
|
|
811
823
|
});
|
|
812
824
|
}
|
|
813
825
|
/**
|
|
@@ -1007,6 +1019,14 @@ var HttpClient = class {
|
|
|
1007
1019
|
};
|
|
1008
1020
|
|
|
1009
1021
|
// src/core/collection/collection-client.ts
|
|
1022
|
+
function buildPayloadFormData(data, file, filename) {
|
|
1023
|
+
const formData = new FormData();
|
|
1024
|
+
formData.append("file", file, filename);
|
|
1025
|
+
if (data != null) {
|
|
1026
|
+
formData.append("_payload", JSON.stringify(data));
|
|
1027
|
+
}
|
|
1028
|
+
return formData;
|
|
1029
|
+
}
|
|
1010
1030
|
var CollectionClient = class extends HttpClient {
|
|
1011
1031
|
constructor(clientKey, secretKey, baseUrl, getCustomerToken) {
|
|
1012
1032
|
super(clientKey, secretKey, baseUrl, getCustomerToken);
|
|
@@ -1114,6 +1134,32 @@ var CollectionClient = class extends HttpClient {
|
|
|
1114
1134
|
return this.parseFindResponse(response);
|
|
1115
1135
|
});
|
|
1116
1136
|
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Create document with file upload
|
|
1139
|
+
* POST /api/{collection} (multipart/form-data)
|
|
1140
|
+
*/
|
|
1141
|
+
requestCreateWithFile(endpoint, data, file, filename) {
|
|
1142
|
+
return __async(this, null, function* () {
|
|
1143
|
+
const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
|
|
1144
|
+
method: "POST",
|
|
1145
|
+
body: buildPayloadFormData(data, file, filename)
|
|
1146
|
+
}));
|
|
1147
|
+
return this.parseMutationResponse(response);
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Update document with file upload
|
|
1152
|
+
* PATCH /api/{collection}/{id} (multipart/form-data)
|
|
1153
|
+
*/
|
|
1154
|
+
requestUpdateWithFile(endpoint, data, file, filename) {
|
|
1155
|
+
return __async(this, null, function* () {
|
|
1156
|
+
const response = yield _fetch(endpoint, __spreadProps(__spreadValues({}, this.defaultOptions), {
|
|
1157
|
+
method: "PATCH",
|
|
1158
|
+
body: buildPayloadFormData(data, file, filename)
|
|
1159
|
+
}));
|
|
1160
|
+
return this.parseMutationResponse(response);
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1117
1163
|
};
|
|
1118
1164
|
|
|
1119
1165
|
// src/core/collection/const.ts
|
|
@@ -1159,6 +1205,8 @@ var COLLECTIONS = [
|
|
|
1159
1205
|
"playlists",
|
|
1160
1206
|
"playlist-images",
|
|
1161
1207
|
"musics",
|
|
1208
|
+
"flows",
|
|
1209
|
+
"flow-images",
|
|
1162
1210
|
"forms",
|
|
1163
1211
|
"form-submissions",
|
|
1164
1212
|
"media"
|
|
@@ -1556,8 +1604,11 @@ var QueryHooks = class {
|
|
|
1556
1604
|
useCreate(params, options) {
|
|
1557
1605
|
const { collection } = params;
|
|
1558
1606
|
return (0, import_react_query2.useMutation)({
|
|
1559
|
-
mutationFn: (
|
|
1560
|
-
return yield this.collectionClient.from(collection).create(
|
|
1607
|
+
mutationFn: (variables) => __async(this, null, function* () {
|
|
1608
|
+
return yield this.collectionClient.from(collection).create(
|
|
1609
|
+
variables.data,
|
|
1610
|
+
variables.file ? { file: variables.file, filename: variables.filename } : void 0
|
|
1611
|
+
);
|
|
1561
1612
|
}),
|
|
1562
1613
|
onSuccess: (data) => {
|
|
1563
1614
|
var _a;
|
|
@@ -1572,7 +1623,11 @@ var QueryHooks = class {
|
|
|
1572
1623
|
const { collection } = params;
|
|
1573
1624
|
return (0, import_react_query2.useMutation)({
|
|
1574
1625
|
mutationFn: (variables) => __async(this, null, function* () {
|
|
1575
|
-
return yield this.collectionClient.from(collection).update(
|
|
1626
|
+
return yield this.collectionClient.from(collection).update(
|
|
1627
|
+
variables.id,
|
|
1628
|
+
variables.data,
|
|
1629
|
+
variables.file ? { file: variables.file, filename: variables.filename } : void 0
|
|
1630
|
+
);
|
|
1576
1631
|
}),
|
|
1577
1632
|
onSuccess: (data) => {
|
|
1578
1633
|
var _a;
|