@powerhousedao/shared 6.0.0-dev.104 → 6.0.0-dev.106
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/dist/analytics/index.d.ts +42 -4
- package/dist/analytics/index.d.ts.map +1 -1
- package/dist/analytics/index.js +307 -4
- package/dist/analytics/index.js.map +1 -1
- package/dist/clis/index.d.mts +1271 -0
- package/dist/clis/index.d.mts.map +1 -0
- package/dist/clis/index.mjs +6801 -0
- package/dist/clis/index.mjs.map +1 -0
- package/dist/connect/index.d.ts +866 -1
- package/dist/connect/index.d.ts.map +1 -1
- package/dist/connect/index.js +254 -1
- package/dist/connect/index.js.map +1 -1
- package/dist/constants.d.ts +8 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +41 -0
- package/dist/constants.js.map +1 -0
- package/dist/document-drive/index.d.ts +546 -0
- package/dist/document-drive/index.d.ts.map +1 -0
- package/dist/document-drive/index.js +956 -0
- package/dist/document-drive/index.js.map +1 -0
- package/dist/document-model/index.d.ts +3 -5
- package/dist/document-model/index.js +3408 -2
- package/dist/document-model/index.js.map +1 -1
- package/dist/index-dg_xL7sp.d.ts +567 -0
- package/dist/index-dg_xL7sp.d.ts.map +1 -0
- package/dist/processors/index.d.ts +2 -5
- package/dist/processors/index.js +116 -3
- package/dist/processors/index.js.map +1 -1
- package/dist/registry/index.d.ts +46 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +0 -0
- package/dist/types-DWXYsIF1.d.ts +158 -0
- package/dist/types-DWXYsIF1.d.ts.map +1 -0
- package/dist/types-faUXKACL.d.ts +2153 -0
- package/dist/types-faUXKACL.d.ts.map +1 -0
- package/package.json +44 -4
- package/dist/analytics/analytics-path.d.ts +0 -36
- package/dist/analytics/analytics-path.d.ts.map +0 -1
- package/dist/analytics/analytics-path.js +0 -170
- package/dist/analytics/analytics-path.js.map +0 -1
- package/dist/analytics/analytics-period.d.ts +0 -40
- package/dist/analytics/analytics-period.d.ts.map +0 -1
- package/dist/analytics/analytics-period.js +0 -204
- package/dist/analytics/analytics-period.js.map +0 -1
- package/dist/analytics/constants.d.ts +0 -35
- package/dist/analytics/constants.d.ts.map +0 -1
- package/dist/analytics/constants.js +0 -40
- package/dist/analytics/constants.js.map +0 -1
- package/dist/analytics/types.d.ts +0 -85
- package/dist/analytics/types.d.ts.map +0 -1
- package/dist/analytics/types.js +0 -2
- package/dist/analytics/types.js.map +0 -1
- package/dist/connect/env-config.d.ts +0 -862
- package/dist/connect/env-config.d.ts.map +0 -1
- package/dist/connect/env-config.js +0 -525
- package/dist/connect/env-config.js.map +0 -1
- package/dist/document-model/core/actions.d.ts +0 -62
- package/dist/document-model/core/actions.d.ts.map +0 -1
- package/dist/document-model/core/actions.js +0 -2
- package/dist/document-model/core/actions.js.map +0 -1
- package/dist/document-model/core/constants.d.ts +0 -6
- package/dist/document-model/core/constants.d.ts.map +0 -1
- package/dist/document-model/core/constants.js +0 -8
- package/dist/document-model/core/constants.js.map +0 -1
- package/dist/document-model/core/documents.d.ts +0 -102
- package/dist/document-model/core/documents.d.ts.map +0 -1
- package/dist/document-model/core/documents.js +0 -2
- package/dist/document-model/core/documents.js.map +0 -1
- package/dist/document-model/core/operations.d.ts +0 -74
- package/dist/document-model/core/operations.d.ts.map +0 -1
- package/dist/document-model/core/operations.js +0 -2
- package/dist/document-model/core/operations.js.map +0 -1
- package/dist/document-model/core/ph-types.d.ts +0 -7
- package/dist/document-model/core/ph-types.d.ts.map +0 -1
- package/dist/document-model/core/ph-types.js +0 -2
- package/dist/document-model/core/ph-types.js.map +0 -1
- package/dist/document-model/core/signatures.d.ts +0 -52
- package/dist/document-model/core/signatures.d.ts.map +0 -1
- package/dist/document-model/core/signatures.js +0 -2
- package/dist/document-model/core/signatures.js.map +0 -1
- package/dist/document-model/core/state.d.ts +0 -38
- package/dist/document-model/core/state.d.ts.map +0 -1
- package/dist/document-model/core/state.js +0 -2
- package/dist/document-model/core/state.js.map +0 -1
- package/dist/document-model/core/types.d.ts +0 -533
- package/dist/document-model/core/types.d.ts.map +0 -1
- package/dist/document-model/core/types.js +0 -2
- package/dist/document-model/core/types.js.map +0 -1
- package/dist/document-model/core/upgrades.d.ts +0 -24
- package/dist/document-model/core/upgrades.d.ts.map +0 -1
- package/dist/document-model/core/upgrades.js +0 -2
- package/dist/document-model/core/upgrades.js.map +0 -1
- package/dist/document-model/index.d.ts.map +0 -1
- package/dist/document-model/types.d.ts +0 -97
- package/dist/document-model/types.d.ts.map +0 -1
- package/dist/document-model/types.js +0 -2
- package/dist/document-model/types.js.map +0 -1
- package/dist/processors/constants.d.ts +0 -4
- package/dist/processors/constants.d.ts.map +0 -1
- package/dist/processors/constants.js +0 -4
- package/dist/processors/constants.js.map +0 -1
- package/dist/processors/drive-analytics/document-processor.d.ts +0 -10
- package/dist/processors/drive-analytics/document-processor.d.ts.map +0 -1
- package/dist/processors/drive-analytics/document-processor.js +0 -43
- package/dist/processors/drive-analytics/document-processor.js.map +0 -1
- package/dist/processors/drive-analytics/drive-processor.d.ts +0 -10
- package/dist/processors/drive-analytics/drive-processor.d.ts.map +0 -1
- package/dist/processors/drive-analytics/drive-processor.js +0 -85
- package/dist/processors/drive-analytics/drive-processor.js.map +0 -1
- package/dist/processors/drive-analytics/index.d.ts +0 -10
- package/dist/processors/drive-analytics/index.d.ts.map +0 -1
- package/dist/processors/drive-analytics/index.js +0 -28
- package/dist/processors/drive-analytics/index.js.map +0 -1
- package/dist/processors/drive-analytics/types.d.ts +0 -3
- package/dist/processors/drive-analytics/types.d.ts.map +0 -1
- package/dist/processors/drive-analytics/types.js +0 -2
- package/dist/processors/drive-analytics/types.js.map +0 -1
- package/dist/processors/index.d.ts.map +0 -1
- package/dist/processors/relational/types.d.ts +0 -72
- package/dist/processors/relational/types.d.ts.map +0 -1
- package/dist/processors/relational/types.js +0 -45
- package/dist/processors/relational/types.js.map +0 -1
- package/dist/processors/relational/utils.d.ts +0 -29
- package/dist/processors/relational/utils.d.ts.map +0 -1
- package/dist/processors/relational/utils.js +0 -67
- package/dist/processors/relational/utils.js.map +0 -1
- package/dist/processors/types.d.ts +0 -90
- package/dist/processors/types.d.ts.map +0 -1
- package/dist/processors/types.js +0 -2
- package/dist/processors/types.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,956 @@
|
|
|
1
|
+
import { BaseDocumentHeaderSchema, BaseDocumentStateSchema, baseCreateDocument, baseLoadFromInput, baseSaveToFileHandle, createAction, createBaseState, createReducer, createState as createState$1, defaultBaseState, generateId, isDocumentAction } from "../document-model/index.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __exportAll = (all, no_symbols) => {
|
|
6
|
+
let target = {};
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
12
|
+
return target;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region document-drive/constants.ts
|
|
16
|
+
const driveDocumentFileExtension = "phdd";
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region document-drive/gen/schema/zod.ts
|
|
19
|
+
const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
|
|
20
|
+
const definedNonNullAnySchema = z.any().refine((v) => isDefinedNonNullAny(v));
|
|
21
|
+
const TransmitterTypeSchema = z.enum([
|
|
22
|
+
"Internal",
|
|
23
|
+
"MatrixConnect",
|
|
24
|
+
"PullResponder",
|
|
25
|
+
"RESTWebhook",
|
|
26
|
+
"SecureConnect",
|
|
27
|
+
"SwitchboardPush"
|
|
28
|
+
]);
|
|
29
|
+
const TriggerTypeSchema = z.enum(["PullResponder"]);
|
|
30
|
+
function AddFileInputSchema() {
|
|
31
|
+
return z.object({
|
|
32
|
+
documentType: z.string(),
|
|
33
|
+
id: z.string(),
|
|
34
|
+
name: z.string(),
|
|
35
|
+
parentFolder: z.string().nullish()
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function AddFolderInputSchema() {
|
|
39
|
+
return z.object({
|
|
40
|
+
id: z.string(),
|
|
41
|
+
name: z.string(),
|
|
42
|
+
parentFolder: z.string().nullish()
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function AddListenerInputSchema() {
|
|
46
|
+
return z.object({ listener: ListenerInputSchema() });
|
|
47
|
+
}
|
|
48
|
+
function AddTriggerInputSchema() {
|
|
49
|
+
return z.object({ trigger: TriggerInputSchema() });
|
|
50
|
+
}
|
|
51
|
+
function CopyNodeInputSchema() {
|
|
52
|
+
return z.object({
|
|
53
|
+
srcId: z.string(),
|
|
54
|
+
targetId: z.string(),
|
|
55
|
+
targetName: z.string().nullish(),
|
|
56
|
+
targetParentFolder: z.string().nullish()
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function DeleteNodeInputSchema() {
|
|
60
|
+
return z.object({ id: z.string() });
|
|
61
|
+
}
|
|
62
|
+
function DocumentDriveLocalStateSchema() {
|
|
63
|
+
return z.object({
|
|
64
|
+
__typename: z.literal("DocumentDriveLocalState").optional(),
|
|
65
|
+
availableOffline: z.boolean(),
|
|
66
|
+
listeners: z.array(ListenerSchema()),
|
|
67
|
+
sharingType: z.string().nullable(),
|
|
68
|
+
triggers: z.array(TriggerSchema())
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function DocumentDriveStateSchema() {
|
|
72
|
+
return z.object({
|
|
73
|
+
__typename: z.literal("DocumentDriveState").optional(),
|
|
74
|
+
icon: z.string().nullable(),
|
|
75
|
+
name: z.string(),
|
|
76
|
+
nodes: z.array(NodeSchema())
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function FileNodeSchema() {
|
|
80
|
+
return z.object({
|
|
81
|
+
__typename: z.literal("FileNode").optional(),
|
|
82
|
+
documentType: z.string(),
|
|
83
|
+
id: z.string(),
|
|
84
|
+
kind: z.string(),
|
|
85
|
+
name: z.string(),
|
|
86
|
+
parentFolder: z.string().nullable()
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function FolderNodeSchema() {
|
|
90
|
+
return z.object({
|
|
91
|
+
__typename: z.literal("FolderNode").optional(),
|
|
92
|
+
id: z.string(),
|
|
93
|
+
kind: z.string(),
|
|
94
|
+
name: z.string(),
|
|
95
|
+
parentFolder: z.string().nullable()
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function ListenerSchema() {
|
|
99
|
+
return z.object({
|
|
100
|
+
__typename: z.literal("Listener").optional(),
|
|
101
|
+
block: z.boolean(),
|
|
102
|
+
callInfo: ListenerCallInfoSchema().nullable(),
|
|
103
|
+
filter: ListenerFilterSchema(),
|
|
104
|
+
label: z.string().nullable(),
|
|
105
|
+
listenerId: z.string(),
|
|
106
|
+
system: z.boolean()
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function ListenerInputSchema() {
|
|
110
|
+
return z.object({
|
|
111
|
+
block: z.boolean(),
|
|
112
|
+
callInfo: ListenerCallInfoInputSchema().nullish(),
|
|
113
|
+
filter: ListenerFilterInputSchema(),
|
|
114
|
+
label: z.string().nullish(),
|
|
115
|
+
listenerId: z.string(),
|
|
116
|
+
system: z.boolean()
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function ListenerCallInfoSchema() {
|
|
120
|
+
return z.object({
|
|
121
|
+
__typename: z.literal("ListenerCallInfo").optional(),
|
|
122
|
+
data: z.string().nullable(),
|
|
123
|
+
name: z.string().nullable(),
|
|
124
|
+
transmitterType: TransmitterTypeSchema.nullable()
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function ListenerCallInfoInputSchema() {
|
|
128
|
+
return z.object({
|
|
129
|
+
data: z.string().nullish(),
|
|
130
|
+
name: z.string().nullish(),
|
|
131
|
+
transmitterType: TransmitterTypeSchema.nullish()
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function ListenerFilterSchema() {
|
|
135
|
+
return z.object({
|
|
136
|
+
__typename: z.literal("ListenerFilter").optional(),
|
|
137
|
+
branch: z.array(z.string()).nullable(),
|
|
138
|
+
documentId: z.array(z.string()).nullable(),
|
|
139
|
+
documentType: z.array(z.string()),
|
|
140
|
+
scope: z.array(z.string()).nullable()
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
function ListenerFilterInputSchema() {
|
|
144
|
+
return z.object({
|
|
145
|
+
branch: z.array(z.string()).nullish(),
|
|
146
|
+
documentId: z.array(z.string()).nullish(),
|
|
147
|
+
documentType: z.array(z.string()).nullish(),
|
|
148
|
+
scope: z.array(z.string()).nullish()
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function MoveNodeInputSchema() {
|
|
152
|
+
return z.object({
|
|
153
|
+
srcFolder: z.string(),
|
|
154
|
+
targetParentFolder: z.string().nullish()
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function NodeSchema() {
|
|
158
|
+
return z.union([FileNodeSchema(), FolderNodeSchema()]);
|
|
159
|
+
}
|
|
160
|
+
function PullResponderTriggerDataSchema() {
|
|
161
|
+
return z.object({
|
|
162
|
+
__typename: z.literal("PullResponderTriggerData").optional(),
|
|
163
|
+
interval: z.string(),
|
|
164
|
+
listenerId: z.string(),
|
|
165
|
+
url: z.string()
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function PullResponderTriggerDataInputSchema() {
|
|
169
|
+
return z.object({
|
|
170
|
+
interval: z.string(),
|
|
171
|
+
listenerId: z.string(),
|
|
172
|
+
url: z.string()
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function RemoveListenerInputSchema() {
|
|
176
|
+
return z.object({ listenerId: z.string() });
|
|
177
|
+
}
|
|
178
|
+
function RemoveTriggerInputSchema() {
|
|
179
|
+
return z.object({ triggerId: z.string() });
|
|
180
|
+
}
|
|
181
|
+
function SetAvailableOfflineInputSchema() {
|
|
182
|
+
return z.object({ availableOffline: z.boolean() });
|
|
183
|
+
}
|
|
184
|
+
function SetDriveIconInputSchema() {
|
|
185
|
+
return z.object({ icon: z.string() });
|
|
186
|
+
}
|
|
187
|
+
function SetDriveNameInputSchema() {
|
|
188
|
+
return z.object({ name: z.string() });
|
|
189
|
+
}
|
|
190
|
+
function SetSharingTypeInputSchema() {
|
|
191
|
+
return z.object({ type: z.string() });
|
|
192
|
+
}
|
|
193
|
+
function TriggerSchema() {
|
|
194
|
+
return z.object({
|
|
195
|
+
__typename: z.literal("Trigger").optional(),
|
|
196
|
+
data: TriggerDataSchema().nullable(),
|
|
197
|
+
id: z.string(),
|
|
198
|
+
type: TriggerTypeSchema
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function TriggerInputSchema() {
|
|
202
|
+
return z.object({
|
|
203
|
+
data: PullResponderTriggerDataInputSchema().nullish(),
|
|
204
|
+
id: z.string(),
|
|
205
|
+
type: TriggerTypeSchema
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function TriggerDataSchema() {
|
|
209
|
+
return PullResponderTriggerDataSchema();
|
|
210
|
+
}
|
|
211
|
+
function UpdateFileInputSchema() {
|
|
212
|
+
return z.object({
|
|
213
|
+
documentType: z.string().nullish(),
|
|
214
|
+
id: z.string(),
|
|
215
|
+
name: z.string().nullish(),
|
|
216
|
+
parentFolder: z.string().nullish()
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
function UpdateNodeInputSchema() {
|
|
220
|
+
return z.object({
|
|
221
|
+
id: z.string(),
|
|
222
|
+
name: z.string().nullish(),
|
|
223
|
+
parentFolder: z.string().nullish()
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region document-drive/gen/node/creators.ts
|
|
228
|
+
function addFile(input) {
|
|
229
|
+
if (input && typeof input === "object" && "synchronizationUnits" in input) return createAction("ADD_FILE", { ...input }, void 0, void 0, "global");
|
|
230
|
+
return createAction("ADD_FILE", { ...input }, void 0, AddFileInputSchema, "global");
|
|
231
|
+
}
|
|
232
|
+
const addFolder = (input) => createAction("ADD_FOLDER", { ...input }, void 0, AddFolderInputSchema, "global");
|
|
233
|
+
const deleteNode = (input) => createAction("DELETE_NODE", { ...input }, void 0, DeleteNodeInputSchema, "global");
|
|
234
|
+
const updateFile = (input) => createAction("UPDATE_FILE", { ...input }, void 0, UpdateFileInputSchema, "global");
|
|
235
|
+
const updateNode = (input) => createAction("UPDATE_NODE", { ...input }, void 0, UpdateNodeInputSchema, "global");
|
|
236
|
+
const copyNode = (input) => createAction("COPY_NODE", { ...input }, void 0, CopyNodeInputSchema, "global");
|
|
237
|
+
const moveNode = (input) => createAction("MOVE_NODE", { ...input }, void 0, MoveNodeInputSchema, "global");
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region document-drive/gen/drive/creators.ts
|
|
240
|
+
const setDriveName = (input) => createAction("SET_DRIVE_NAME", { ...input }, void 0, SetDriveNameInputSchema, "global");
|
|
241
|
+
const setDriveIcon = (input) => createAction("SET_DRIVE_ICON", { ...input }, void 0, SetDriveIconInputSchema, "global");
|
|
242
|
+
const setSharingType = (input) => createAction("SET_SHARING_TYPE", { ...input }, void 0, SetSharingTypeInputSchema, "local");
|
|
243
|
+
const setAvailableOffline = (input) => createAction("SET_AVAILABLE_OFFLINE", { ...input }, void 0, SetAvailableOfflineInputSchema, "local");
|
|
244
|
+
const addListener = (input) => createAction("ADD_LISTENER", { ...input }, void 0, AddListenerInputSchema, "local");
|
|
245
|
+
const removeListener = (input) => createAction("REMOVE_LISTENER", { ...input }, void 0, RemoveListenerInputSchema, "local");
|
|
246
|
+
const addTrigger = (input) => createAction("ADD_TRIGGER", { ...input }, void 0, AddTriggerInputSchema, "local");
|
|
247
|
+
const removeTrigger = (input) => createAction("REMOVE_TRIGGER", { ...input }, void 0, RemoveTriggerInputSchema, "local");
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region document-drive/gen/creators.ts
|
|
250
|
+
var creators_exports = /* @__PURE__ */ __exportAll({
|
|
251
|
+
addFile: () => addFile,
|
|
252
|
+
addFolder: () => addFolder,
|
|
253
|
+
addListener: () => addListener,
|
|
254
|
+
addTrigger: () => addTrigger,
|
|
255
|
+
copyNode: () => copyNode,
|
|
256
|
+
deleteNode: () => deleteNode,
|
|
257
|
+
moveNode: () => moveNode,
|
|
258
|
+
removeListener: () => removeListener,
|
|
259
|
+
removeTrigger: () => removeTrigger,
|
|
260
|
+
setAvailableOffline: () => setAvailableOffline,
|
|
261
|
+
setDriveIcon: () => setDriveIcon,
|
|
262
|
+
setDriveName: () => setDriveName,
|
|
263
|
+
setSharingType: () => setSharingType,
|
|
264
|
+
updateFile: () => updateFile,
|
|
265
|
+
updateNode: () => updateNode
|
|
266
|
+
});
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region document-drive/gen/document-model.ts
|
|
269
|
+
const driveDocumentModel = {
|
|
270
|
+
id: "powerhouse/document-drive",
|
|
271
|
+
name: "DocumentDrive",
|
|
272
|
+
extension: "phdd",
|
|
273
|
+
description: "",
|
|
274
|
+
author: {
|
|
275
|
+
name: "Powerhouse Inc",
|
|
276
|
+
website: "https://www.powerhouse.inc/"
|
|
277
|
+
},
|
|
278
|
+
specifications: [{
|
|
279
|
+
version: 1,
|
|
280
|
+
changeLog: [],
|
|
281
|
+
state: {
|
|
282
|
+
global: {
|
|
283
|
+
schema: "type FolderNode {\n id: String!\n name: String!\n kind: String!\n parentFolder: String\n}\n\ntype FileNode {\n id: String!\n name: String!\n kind: String!\n documentType: String!\n parentFolder: String\n}\n\nunion Node = FolderNode | FileNode\n\ntype DocumentDriveState {\n name: String!\n nodes: [Node!]!\n icon: String\n}",
|
|
284
|
+
initialValue: "\"{\\\"name\\\":\\\"\\\",\\\"nodes\\\":[],\\\"icon\\\":null}\"",
|
|
285
|
+
examples: []
|
|
286
|
+
},
|
|
287
|
+
local: {
|
|
288
|
+
schema: "type ListenerFilter {\n documentType: [String!]!\n documentId: [ID!]\n scope: [String!]\n branch: [String!]\n}\n\nenum TransmitterType {\n Internal,\n SwitchboardPush,\n PullResponder,\n SecureConnect, \n MatrixConnect,\n RESTWebhook\n}\n\ntype ListenerCallInfo {\n transmitterType: TransmitterType\n name: String\n data: String\n}\n\ntype Listener {\n listenerId: ID!\n label: String\n block: Boolean!\n system: Boolean!\n filter: ListenerFilter!\n callInfo: ListenerCallInfo\n}\n\nenum TriggerType {\n PullResponder\n}\n\ntype PullResponderTriggerData {\n listenerId: ID!\n url: String!\n interval: String!\n}\n\nunion TriggerData = PullResponderTriggerData\n\ntype Trigger {\n id: ID!\n type: TriggerType!\n data: TriggerData\n}\n\ntype DocumentDriveLocalState{\n sharingType: String\n listeners: [Listener!]!\n triggers: [Trigger!]!\n availableOffline: Boolean!\n}",
|
|
289
|
+
initialValue: "\"{ \\\"listeners\\\": [], \\\"triggers\\\": [], \\\"sharingType\\\": \\\"private\\\", \\\"availableOffline\\\": false}\"",
|
|
290
|
+
examples: []
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
modules: [{
|
|
294
|
+
id: "GRzuvv78tBvmB6ciitokLfonNHA=",
|
|
295
|
+
name: "Node",
|
|
296
|
+
description: "",
|
|
297
|
+
operations: [
|
|
298
|
+
{
|
|
299
|
+
id: "7xiTdxonc9yEASR8sfV/KnbSV10=",
|
|
300
|
+
name: "ADD_FILE",
|
|
301
|
+
description: "",
|
|
302
|
+
schema: "input AddFileInput {\n id: ID!\n name: String!\n documentType: String!\n parentFolder: ID\n}",
|
|
303
|
+
template: "",
|
|
304
|
+
reducer: "",
|
|
305
|
+
errors: [],
|
|
306
|
+
examples: [],
|
|
307
|
+
scope: "global"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
id: "4lzNMMKKdIAtEU6i12xLgi9hp+U=",
|
|
311
|
+
name: "ADD_FOLDER",
|
|
312
|
+
description: "",
|
|
313
|
+
schema: "input AddFolderInput {\n id: ID!\n name: String!\n parentFolder: ID\n}",
|
|
314
|
+
template: "",
|
|
315
|
+
reducer: "",
|
|
316
|
+
errors: [],
|
|
317
|
+
examples: [],
|
|
318
|
+
scope: "global"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
id: "53jH2/3TWTTcgCJiv2C+BmuC6i0=",
|
|
322
|
+
name: "DELETE_NODE",
|
|
323
|
+
description: "",
|
|
324
|
+
schema: "input DeleteNodeInput {\n id: ID!\n}",
|
|
325
|
+
template: "",
|
|
326
|
+
reducer: "",
|
|
327
|
+
errors: [],
|
|
328
|
+
examples: [],
|
|
329
|
+
scope: "global"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
id: "pNn+Y1/HVq/GNMk7t0u3g3gtMLE=",
|
|
333
|
+
name: "UPDATE_FILE",
|
|
334
|
+
description: "",
|
|
335
|
+
schema: "input UpdateFileInput {\n id: ID!\n parentFolder: ID\n name: String\n documentType: String\n}",
|
|
336
|
+
template: "",
|
|
337
|
+
reducer: "",
|
|
338
|
+
errors: [],
|
|
339
|
+
examples: [],
|
|
340
|
+
scope: "global"
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
id: "P0x1M8Mnt+Q/+9nggkwgVbfybsc=",
|
|
344
|
+
name: "UPDATE_NODE",
|
|
345
|
+
description: "",
|
|
346
|
+
schema: "input UpdateNodeInput {\n id: ID!\n parentFolder: ID\n name: String\n}",
|
|
347
|
+
template: "",
|
|
348
|
+
reducer: "",
|
|
349
|
+
errors: [],
|
|
350
|
+
examples: [],
|
|
351
|
+
scope: "global"
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
id: "vnQ7OB5b3wGLgjhbgJqAIpA+JLE=",
|
|
355
|
+
name: "COPY_NODE",
|
|
356
|
+
description: "",
|
|
357
|
+
schema: "input CopyNodeInput {\n srcId: ID!\n targetId: ID!\n targetName: String\n targetParentFolder: ID\n}",
|
|
358
|
+
template: "",
|
|
359
|
+
reducer: "",
|
|
360
|
+
errors: [],
|
|
361
|
+
examples: [],
|
|
362
|
+
scope: "global"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
id: "VNyiD/sNGzk6k9A1Qe7s8dmrJxA=",
|
|
366
|
+
name: "MOVE_NODE",
|
|
367
|
+
description: "",
|
|
368
|
+
schema: "input MoveNodeInput {\n srcFolder: ID!\n targetParentFolder: ID\n}",
|
|
369
|
+
template: "",
|
|
370
|
+
reducer: "",
|
|
371
|
+
errors: [],
|
|
372
|
+
examples: [],
|
|
373
|
+
scope: "global"
|
|
374
|
+
}
|
|
375
|
+
]
|
|
376
|
+
}, {
|
|
377
|
+
id: "0dHwHlxOM9x0vMZ+gLnKxf2qTEo=",
|
|
378
|
+
name: "Drive",
|
|
379
|
+
description: "",
|
|
380
|
+
operations: [
|
|
381
|
+
{
|
|
382
|
+
id: "qGCiPGpTt/cyz3HzyrBn92z1dsU=",
|
|
383
|
+
name: "SET_DRIVE_NAME",
|
|
384
|
+
description: "",
|
|
385
|
+
schema: "input SetDriveNameInput {\n name: String!\n}",
|
|
386
|
+
template: "",
|
|
387
|
+
reducer: "",
|
|
388
|
+
errors: [],
|
|
389
|
+
examples: [],
|
|
390
|
+
scope: "global"
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
id: "qGCiPGpTt/cyz3HzyrBn92z30dsU=",
|
|
394
|
+
name: "SET_DRIVE_ICON",
|
|
395
|
+
description: "",
|
|
396
|
+
schema: "input SetDriveIconInput {\n icon: String!\n}",
|
|
397
|
+
template: "",
|
|
398
|
+
reducer: "",
|
|
399
|
+
errors: [],
|
|
400
|
+
examples: [],
|
|
401
|
+
scope: "global"
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
id: "qGCiPGpTt/cyz3HzyrBn92z2dsU=",
|
|
405
|
+
name: "SET_SHARING_TYPE",
|
|
406
|
+
description: "",
|
|
407
|
+
schema: "input SetSharingTypeInput {\n type: String!\n}",
|
|
408
|
+
template: "",
|
|
409
|
+
reducer: "",
|
|
410
|
+
errors: [],
|
|
411
|
+
examples: [],
|
|
412
|
+
scope: "local"
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
id: "qGCiPGpTt/cyz3HzyrBn92z3dsU=",
|
|
416
|
+
name: "SET_AVAILABLE_OFFLINE",
|
|
417
|
+
description: "",
|
|
418
|
+
schema: "input SetAvailableOfflineInput {\n availableOffline: Boolean!\n}",
|
|
419
|
+
template: "",
|
|
420
|
+
reducer: "",
|
|
421
|
+
errors: [],
|
|
422
|
+
examples: [],
|
|
423
|
+
scope: "local"
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
id: "qGCiPGpTt/cyz3HzyrBn92z9dsU=",
|
|
427
|
+
name: "ADD_LISTENER",
|
|
428
|
+
description: "",
|
|
429
|
+
schema: "input ListenerFilterInput {\n documentType: [String!]\n documentId: [ID!]\n scope: [String!]\n branch: [String!]\n}\n\ninput ListenerCallInfoInput {\n transmitterType: TransmitterType\n name: String\n data: String\n}\n\ninput ListenerInput {\n listenerId: ID!\n label: String\n block: Boolean!\n system: Boolean!\n filter: ListenerFilterInput!\n callInfo: ListenerCallInfoInput\n}\n\ninput AddListenerInput {\n listener: ListenerInput!\n}",
|
|
430
|
+
template: "",
|
|
431
|
+
reducer: "",
|
|
432
|
+
errors: [],
|
|
433
|
+
examples: [],
|
|
434
|
+
scope: "local"
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
id: "qGCiPGpTt/cyz3HzyrBn92z10dsU=",
|
|
438
|
+
name: "REMOVE_LISTENER",
|
|
439
|
+
description: "",
|
|
440
|
+
schema: "input RemoveListenerInput {\n listenerId: String!\n}",
|
|
441
|
+
template: "",
|
|
442
|
+
reducer: "",
|
|
443
|
+
errors: [],
|
|
444
|
+
examples: [],
|
|
445
|
+
scope: "local"
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
id: "qGCiPGpTt/cyz3HzyrBn92z20dsU=",
|
|
449
|
+
name: "ADD_TRIGGER",
|
|
450
|
+
description: "",
|
|
451
|
+
schema: "input PullResponderTriggerDataInput {\n listenerId: ID!\n url: String!\n interval: String!\n}\n\ninput TriggerInput {\n id: ID!\n type: TriggerType!\n data: PullResponderTriggerDataInput\n}\n\ninput AddTriggerInput {\n trigger: TriggerInput!\n}",
|
|
452
|
+
template: "",
|
|
453
|
+
reducer: "",
|
|
454
|
+
errors: [],
|
|
455
|
+
examples: [],
|
|
456
|
+
scope: "local"
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
id: "qGCiPGpTt/cyz3HzyrBn92z30dsU=",
|
|
460
|
+
name: "REMOVE_TRIGGER",
|
|
461
|
+
description: "",
|
|
462
|
+
schema: "input RemoveTriggerInput {\n triggerId: String!\n}",
|
|
463
|
+
template: "",
|
|
464
|
+
reducer: "",
|
|
465
|
+
errors: [],
|
|
466
|
+
examples: [],
|
|
467
|
+
scope: "local"
|
|
468
|
+
}
|
|
469
|
+
]
|
|
470
|
+
}]
|
|
471
|
+
}]
|
|
472
|
+
};
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region document-drive/gen/document-type.ts
|
|
475
|
+
const driveDocumentType = "powerhouse/document-drive";
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region document-drive/gen/ph-factories.ts
|
|
478
|
+
/**
|
|
479
|
+
* Factory methods for creating DocumentDriveDocument instances
|
|
480
|
+
*/
|
|
481
|
+
function defaultGlobalState() {
|
|
482
|
+
return {
|
|
483
|
+
icon: null,
|
|
484
|
+
name: "",
|
|
485
|
+
nodes: []
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
function defaultLocalState() {
|
|
489
|
+
return {
|
|
490
|
+
availableOffline: false,
|
|
491
|
+
listeners: [],
|
|
492
|
+
sharingType: null,
|
|
493
|
+
triggers: []
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
function defaultPHState() {
|
|
497
|
+
return {
|
|
498
|
+
...defaultBaseState(),
|
|
499
|
+
global: defaultGlobalState(),
|
|
500
|
+
local: defaultLocalState()
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
function createGlobalState(state) {
|
|
504
|
+
return {
|
|
505
|
+
...defaultGlobalState(),
|
|
506
|
+
...state || {}
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
function createLocalState(state) {
|
|
510
|
+
return {
|
|
511
|
+
...defaultLocalState(),
|
|
512
|
+
...state || {}
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
function createState(baseState, globalState, localState) {
|
|
516
|
+
return {
|
|
517
|
+
...createBaseState(baseState?.auth, baseState?.document),
|
|
518
|
+
global: createGlobalState(globalState),
|
|
519
|
+
local: createLocalState(localState)
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
//#endregion
|
|
523
|
+
//#region document-drive/src/reducers/drive.ts
|
|
524
|
+
const driveReducer = {
|
|
525
|
+
setDriveNameOperation(state, action, dispatch) {
|
|
526
|
+
state.name = action.input.name;
|
|
527
|
+
},
|
|
528
|
+
setDriveIconOperation(state, action, dispatch) {
|
|
529
|
+
state.icon = action.input.icon;
|
|
530
|
+
},
|
|
531
|
+
setSharingTypeOperation(state, action, dispatch) {
|
|
532
|
+
state.sharingType = action.input.type;
|
|
533
|
+
},
|
|
534
|
+
setAvailableOfflineOperation(state, action, dispatch) {
|
|
535
|
+
state.availableOffline = action.input.availableOffline;
|
|
536
|
+
},
|
|
537
|
+
addListenerOperation(state, action, dispatch) {
|
|
538
|
+
const { listener: input } = action.input;
|
|
539
|
+
if (state.listeners.find((l) => l.listenerId === input.listenerId)) throw new Error(`A listener with Id: ${input.listenerId} already exists`);
|
|
540
|
+
const listener = {
|
|
541
|
+
listenerId: input.listenerId,
|
|
542
|
+
label: input.label ?? null,
|
|
543
|
+
block: input.block,
|
|
544
|
+
system: input.system,
|
|
545
|
+
filter: {
|
|
546
|
+
documentType: input.filter.documentType ?? null,
|
|
547
|
+
documentId: input.filter.documentId ?? null,
|
|
548
|
+
scope: input.filter.scope ?? null,
|
|
549
|
+
branch: input.filter.branch ?? null
|
|
550
|
+
},
|
|
551
|
+
callInfo: input.callInfo ? {
|
|
552
|
+
transmitterType: input.callInfo.transmitterType ?? null,
|
|
553
|
+
name: input.callInfo.name ?? null,
|
|
554
|
+
data: input.callInfo.data ?? null
|
|
555
|
+
} : null
|
|
556
|
+
};
|
|
557
|
+
state.listeners.push(listener);
|
|
558
|
+
},
|
|
559
|
+
removeListenerOperation(state, action, dispatch) {
|
|
560
|
+
state.listeners = state.listeners.filter((listener) => listener.listenerId !== action.input.listenerId);
|
|
561
|
+
},
|
|
562
|
+
addTriggerOperation(state, action, dispatch) {
|
|
563
|
+
const { trigger: input } = action.input;
|
|
564
|
+
if (state.triggers.find((t) => t.id === input.id)) throw new Error(`A trigger with Id: ${input.id} already exists`);
|
|
565
|
+
const trigger = {
|
|
566
|
+
id: input.id,
|
|
567
|
+
type: input.type,
|
|
568
|
+
data: input.data ? { ...input.data } : null
|
|
569
|
+
};
|
|
570
|
+
state.triggers.push(trigger);
|
|
571
|
+
},
|
|
572
|
+
removeTriggerOperation(state, action, dispatch) {
|
|
573
|
+
state.triggers = state.triggers.filter((trigger) => trigger.id !== action.input.triggerId);
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
//#endregion
|
|
577
|
+
//#region document-drive/src/utils.ts
|
|
578
|
+
function isFileNode(node) {
|
|
579
|
+
return node.kind === "file";
|
|
580
|
+
}
|
|
581
|
+
function isFolderNode(node) {
|
|
582
|
+
return node.kind === "folder";
|
|
583
|
+
}
|
|
584
|
+
function getAncestors(node, allNodes) {
|
|
585
|
+
if (!node.parentFolder) return [];
|
|
586
|
+
else {
|
|
587
|
+
const parentNode = allNodes.find((_node) => _node.id === node.parentFolder);
|
|
588
|
+
if (!parentNode) throw new Error(`Parent node with id ${node.parentFolder} not found`);
|
|
589
|
+
return [parentNode, ...getAncestors(parentNode, allNodes)];
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
function getDescendants(node, allNodes) {
|
|
593
|
+
const children = allNodes.filter((_node) => _node.parentFolder === node.id);
|
|
594
|
+
const descendants = children.map((child) => getDescendants(child, allNodes));
|
|
595
|
+
return [...children, ...descendants.flat()];
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Generates a copy of nodes based on the provided source and target information.
|
|
599
|
+
* @param src - The source information for generating the copy.
|
|
600
|
+
* @param idGenerator - The function used to generate new IDs for the copied nodes.
|
|
601
|
+
* @param nodes - The array of nodes to copy from.
|
|
602
|
+
* @returns An array of copied nodes with updated IDs and parent folders.
|
|
603
|
+
* @throws Error if the root node with the specified ID is not found.
|
|
604
|
+
*/
|
|
605
|
+
function generateNodesCopy(src, idGenerator, nodes) {
|
|
606
|
+
const rootNode = nodes.find((node) => node.id === src.srcId);
|
|
607
|
+
if (!rootNode) throw new Error(`Node with id ${src.srcId} not found`);
|
|
608
|
+
const nodesToCopy = [{
|
|
609
|
+
...rootNode,
|
|
610
|
+
name: src.targetName || rootNode.name,
|
|
611
|
+
parentFolder: src.targetParentFolder || null
|
|
612
|
+
}, ...getDescendants(rootNode, nodes)];
|
|
613
|
+
const ids = {};
|
|
614
|
+
if (src.targetParentFolder) ids[src.targetParentFolder] = src.targetParentFolder;
|
|
615
|
+
const getNewNodeId = (node) => {
|
|
616
|
+
let newId = ids[node.id];
|
|
617
|
+
if (!newId) {
|
|
618
|
+
const oldId = node.id;
|
|
619
|
+
newId = idGenerator(node);
|
|
620
|
+
ids[oldId] = newId;
|
|
621
|
+
}
|
|
622
|
+
return newId;
|
|
623
|
+
};
|
|
624
|
+
return nodesToCopy.map((node) => ({
|
|
625
|
+
srcId: node.id,
|
|
626
|
+
targetId: getNewNodeId(node),
|
|
627
|
+
targetName: node.name,
|
|
628
|
+
targetParentFolder: node.parentFolder ? ids[node.parentFolder] : null
|
|
629
|
+
}));
|
|
630
|
+
}
|
|
631
|
+
function getNextCopyNumber(files, baseFilename) {
|
|
632
|
+
let maxNumber = 0;
|
|
633
|
+
const regex = new RegExp(`^${escapeRegExp(baseFilename)} \\(copy\\)(?: (\\d+))?$`);
|
|
634
|
+
for (const file of files) {
|
|
635
|
+
const match = file.match(regex);
|
|
636
|
+
if (match) {
|
|
637
|
+
const number = match[1] ? parseInt(match[1], 10) : 1;
|
|
638
|
+
if (number > maxNumber) maxNumber = number;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return maxNumber + 1;
|
|
642
|
+
}
|
|
643
|
+
function escapeRegExp(string) {
|
|
644
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
645
|
+
}
|
|
646
|
+
function handleTargetNameCollisions(params) {
|
|
647
|
+
const { nodes, targetParentFolder, srcName } = params;
|
|
648
|
+
const targetNodeChildrenNames = nodes.filter((node) => targetParentFolder === "" ? node.parentFolder === null : node.parentFolder === targetParentFolder).map((node) => node.name);
|
|
649
|
+
return targetNodeChildrenNames.includes(srcName) ? `${srcName} (copy) ${getNextCopyNumber(targetNodeChildrenNames, srcName)}` : srcName;
|
|
650
|
+
}
|
|
651
|
+
const isValidName = (name) => {
|
|
652
|
+
return /^[a-zA-Z0-9-_.\s()]+$/.test(name);
|
|
653
|
+
};
|
|
654
|
+
//#endregion
|
|
655
|
+
//#region document-drive/src/reducers/node.ts
|
|
656
|
+
const nodeReducer = {
|
|
657
|
+
addFileOperation(state, action, dispatch) {
|
|
658
|
+
if (state.nodes.find((node) => node.id === action.input.id)) throw new Error(`Node with id ${action.input.id} already exists!`);
|
|
659
|
+
if (!isValidName(action.input.name)) throw new Error(`Invalid name: '${action.input.name}'. Names must be valid URL characters.`);
|
|
660
|
+
const name = handleTargetNameCollisions({
|
|
661
|
+
nodes: state.nodes,
|
|
662
|
+
srcName: action.input.name,
|
|
663
|
+
targetParentFolder: action.input.parentFolder || null
|
|
664
|
+
});
|
|
665
|
+
const fileNode = {
|
|
666
|
+
id: action.input.id,
|
|
667
|
+
name,
|
|
668
|
+
kind: "file",
|
|
669
|
+
parentFolder: action.input.parentFolder ?? null,
|
|
670
|
+
documentType: action.input.documentType
|
|
671
|
+
};
|
|
672
|
+
state.nodes.push(fileNode);
|
|
673
|
+
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
674
|
+
dispatch?.({
|
|
675
|
+
type: "CREATE_CHILD_DOCUMENT",
|
|
676
|
+
input: {
|
|
677
|
+
id: action.input.id,
|
|
678
|
+
documentType: action.input.documentType
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
},
|
|
682
|
+
addFolderOperation(state, action) {
|
|
683
|
+
if (state.nodes.find((node) => node.id === action.input.id)) throw new Error(`Node with id ${action.input.id} already exists!`);
|
|
684
|
+
if (!isValidName(action.input.name)) throw new Error(`Invalid name: '${action.input.name}'. Names must be valid URL characters.`);
|
|
685
|
+
const name = handleTargetNameCollisions({
|
|
686
|
+
nodes: state.nodes,
|
|
687
|
+
srcName: action.input.name,
|
|
688
|
+
targetParentFolder: action.input.parentFolder || null
|
|
689
|
+
});
|
|
690
|
+
state.nodes.push({
|
|
691
|
+
...action.input,
|
|
692
|
+
name,
|
|
693
|
+
kind: "folder",
|
|
694
|
+
parentFolder: action.input.parentFolder ?? null
|
|
695
|
+
});
|
|
696
|
+
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
697
|
+
},
|
|
698
|
+
deleteNodeOperation(state, action, dispatch) {
|
|
699
|
+
const node = state.nodes.find((node) => node.id === action.input.id);
|
|
700
|
+
if (!node) throw new Error(`Node with id ${action.input.id} not found`);
|
|
701
|
+
const descendants = getDescendants(node, state.nodes);
|
|
702
|
+
state.nodes = state.nodes.filter((node) => node.id !== action.input.id && !descendants.find((descendant) => descendant.id === node.id));
|
|
703
|
+
[node, ...descendants].filter((node) => isFileNode(node)).forEach((node) => {
|
|
704
|
+
dispatch?.({
|
|
705
|
+
type: "DELETE_CHILD_DOCUMENT",
|
|
706
|
+
input: { id: node.id }
|
|
707
|
+
});
|
|
708
|
+
});
|
|
709
|
+
},
|
|
710
|
+
updateFileOperation(state, action) {
|
|
711
|
+
if (action.input.name && !isValidName(action.input.name)) throw new Error(`Invalid name: '${action.input.name}'. Names must be valid URL characters.`);
|
|
712
|
+
state.nodes = state.nodes.map((node) => node.id === action.input.id ? {
|
|
713
|
+
...node,
|
|
714
|
+
name: handleTargetNameCollisions({
|
|
715
|
+
nodes: state.nodes,
|
|
716
|
+
srcName: action.input.name ?? node.name,
|
|
717
|
+
targetParentFolder: action.input.parentFolder || null
|
|
718
|
+
}),
|
|
719
|
+
documentType: action.input.documentType ?? node.documentType
|
|
720
|
+
} : node);
|
|
721
|
+
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
722
|
+
},
|
|
723
|
+
updateNodeOperation(state, action) {
|
|
724
|
+
if (action.input.name && !isValidName(action.input.name)) throw new Error(`Invalid name: '${action.input.name}'. Names must be valid URL characters.`);
|
|
725
|
+
state.nodes = state.nodes.map((node) => node.id === action.input.id ? {
|
|
726
|
+
...node,
|
|
727
|
+
name: handleTargetNameCollisions({
|
|
728
|
+
nodes: state.nodes,
|
|
729
|
+
srcName: action.input.name ?? node.name,
|
|
730
|
+
targetParentFolder: action.input.parentFolder || null
|
|
731
|
+
}),
|
|
732
|
+
parentFolder: action.input.parentFolder === null ? null : node.parentFolder
|
|
733
|
+
} : node);
|
|
734
|
+
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
735
|
+
},
|
|
736
|
+
copyNodeOperation(state, action, dispatch) {
|
|
737
|
+
const node = state.nodes.find((node) => node.id === action.input.srcId);
|
|
738
|
+
if (!node) throw new Error(`Node with id ${action.input.srcId} not found`);
|
|
739
|
+
if (state.nodes.find((node) => node.id === action.input.targetId)) throw new Error(`Node with id ${action.input.targetId} already exists`);
|
|
740
|
+
const name = handleTargetNameCollisions({
|
|
741
|
+
nodes: state.nodes,
|
|
742
|
+
srcName: action.input.targetName || node.name,
|
|
743
|
+
targetParentFolder: action.input.targetParentFolder || null
|
|
744
|
+
});
|
|
745
|
+
const newNode = {
|
|
746
|
+
...node,
|
|
747
|
+
id: action.input.targetId,
|
|
748
|
+
slug: action.input.targetId,
|
|
749
|
+
name,
|
|
750
|
+
parentFolder: action.input.targetParentFolder || null
|
|
751
|
+
};
|
|
752
|
+
state.nodes.push(newNode);
|
|
753
|
+
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
754
|
+
if (isFileNode(newNode)) dispatch?.({
|
|
755
|
+
type: "COPY_CHILD_DOCUMENT",
|
|
756
|
+
input: {
|
|
757
|
+
id: action.input.srcId,
|
|
758
|
+
newId: action.input.targetId
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
},
|
|
762
|
+
moveNodeOperation(state, action) {
|
|
763
|
+
if (action.input.srcFolder === action.input.targetParentFolder) throw new Error("Circular Reference Error: Attempting to move a node to its current parent folder");
|
|
764
|
+
const node = state.nodes.find((node) => node.id === action.input.srcFolder);
|
|
765
|
+
if (!node) throw new Error(`Node with id ${action.input.srcFolder} not found`);
|
|
766
|
+
const name = handleTargetNameCollisions({
|
|
767
|
+
nodes: state.nodes,
|
|
768
|
+
srcName: node.name,
|
|
769
|
+
targetParentFolder: action.input.targetParentFolder || null
|
|
770
|
+
});
|
|
771
|
+
if (isFolderNode(node)) {
|
|
772
|
+
if (getDescendants(node, state.nodes).find((descendant) => descendant.id === action.input.targetParentFolder)) throw new Error("Circular Reference Error: Cannot move a folder to one of its descendants");
|
|
773
|
+
}
|
|
774
|
+
state.nodes = state.nodes.map((node) => {
|
|
775
|
+
if (node.id === action.input.srcFolder) return {
|
|
776
|
+
...node,
|
|
777
|
+
name,
|
|
778
|
+
parentFolder: action.input.targetParentFolder || null
|
|
779
|
+
};
|
|
780
|
+
return node;
|
|
781
|
+
});
|
|
782
|
+
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
//#endregion
|
|
786
|
+
//#region document-drive/gen/reducer.ts
|
|
787
|
+
const driveStateReducer = (state, action, dispatch) => {
|
|
788
|
+
if (isDocumentAction(action)) return state;
|
|
789
|
+
const typedAction = action;
|
|
790
|
+
switch (typedAction.type) {
|
|
791
|
+
case "ADD_FILE":
|
|
792
|
+
AddFileInputSchema().parse(typedAction.input);
|
|
793
|
+
nodeReducer.addFileOperation(state[typedAction.scope], action, dispatch);
|
|
794
|
+
break;
|
|
795
|
+
case "ADD_FOLDER":
|
|
796
|
+
AddFolderInputSchema().parse(typedAction.input);
|
|
797
|
+
nodeReducer.addFolderOperation(state[typedAction.scope], action, dispatch);
|
|
798
|
+
break;
|
|
799
|
+
case "DELETE_NODE":
|
|
800
|
+
DeleteNodeInputSchema().parse(typedAction.input);
|
|
801
|
+
nodeReducer.deleteNodeOperation(state[typedAction.scope], action, dispatch);
|
|
802
|
+
break;
|
|
803
|
+
case "UPDATE_FILE":
|
|
804
|
+
UpdateFileInputSchema().parse(typedAction.input);
|
|
805
|
+
nodeReducer.updateFileOperation(state[typedAction.scope], action, dispatch);
|
|
806
|
+
break;
|
|
807
|
+
case "UPDATE_NODE":
|
|
808
|
+
UpdateNodeInputSchema().parse(typedAction.input);
|
|
809
|
+
nodeReducer.updateNodeOperation(state[typedAction.scope], action, dispatch);
|
|
810
|
+
break;
|
|
811
|
+
case "COPY_NODE":
|
|
812
|
+
CopyNodeInputSchema().parse(typedAction.input);
|
|
813
|
+
nodeReducer.copyNodeOperation(state[typedAction.scope], action, dispatch);
|
|
814
|
+
break;
|
|
815
|
+
case "MOVE_NODE":
|
|
816
|
+
MoveNodeInputSchema().parse(typedAction.input);
|
|
817
|
+
nodeReducer.moveNodeOperation(state[typedAction.scope], action, dispatch);
|
|
818
|
+
break;
|
|
819
|
+
case "SET_DRIVE_NAME":
|
|
820
|
+
SetDriveNameInputSchema().parse(typedAction.input);
|
|
821
|
+
driveReducer.setDriveNameOperation(state[typedAction.scope], action, dispatch);
|
|
822
|
+
break;
|
|
823
|
+
case "SET_DRIVE_ICON":
|
|
824
|
+
SetDriveIconInputSchema().parse(typedAction.input);
|
|
825
|
+
driveReducer.setDriveIconOperation(state[typedAction.scope], action, dispatch);
|
|
826
|
+
break;
|
|
827
|
+
case "SET_SHARING_TYPE":
|
|
828
|
+
SetSharingTypeInputSchema().parse(typedAction.input);
|
|
829
|
+
driveReducer.setSharingTypeOperation(state[typedAction.scope], action, dispatch);
|
|
830
|
+
break;
|
|
831
|
+
case "SET_AVAILABLE_OFFLINE":
|
|
832
|
+
SetAvailableOfflineInputSchema().parse(typedAction.input);
|
|
833
|
+
driveReducer.setAvailableOfflineOperation(state[typedAction.scope], action, dispatch);
|
|
834
|
+
break;
|
|
835
|
+
case "ADD_LISTENER":
|
|
836
|
+
AddListenerInputSchema().parse(typedAction.input);
|
|
837
|
+
driveReducer.addListenerOperation(state[typedAction.scope], action, dispatch);
|
|
838
|
+
break;
|
|
839
|
+
case "REMOVE_LISTENER":
|
|
840
|
+
RemoveListenerInputSchema().parse(typedAction.input);
|
|
841
|
+
driveReducer.removeListenerOperation(state[typedAction.scope], action, dispatch);
|
|
842
|
+
break;
|
|
843
|
+
case "ADD_TRIGGER":
|
|
844
|
+
AddTriggerInputSchema().parse(typedAction.input);
|
|
845
|
+
driveReducer.addTriggerOperation(state[typedAction.scope], action, dispatch);
|
|
846
|
+
break;
|
|
847
|
+
case "REMOVE_TRIGGER":
|
|
848
|
+
RemoveTriggerInputSchema().parse(typedAction.input);
|
|
849
|
+
driveReducer.removeTriggerOperation(state[typedAction.scope], action, dispatch);
|
|
850
|
+
break;
|
|
851
|
+
default: return state;
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
const driveDocumentReducer = createReducer(driveStateReducer);
|
|
855
|
+
//#endregion
|
|
856
|
+
//#region document-drive/gen/document-schema.ts
|
|
857
|
+
/** Schema for validating the header object of a Drive document */
|
|
858
|
+
const DriveDocumentHeaderSchema = BaseDocumentHeaderSchema.extend({ documentType: z.literal(driveDocumentType) });
|
|
859
|
+
/** Schema for validating the state object of a Drive document */
|
|
860
|
+
const DrivePHStateSchema = BaseDocumentStateSchema.extend({
|
|
861
|
+
global: DocumentDriveStateSchema(),
|
|
862
|
+
local: DocumentDriveLocalStateSchema()
|
|
863
|
+
});
|
|
864
|
+
const DriveDocumentSchema = z.object({
|
|
865
|
+
header: DriveDocumentHeaderSchema,
|
|
866
|
+
state: DrivePHStateSchema,
|
|
867
|
+
initialState: DrivePHStateSchema
|
|
868
|
+
});
|
|
869
|
+
/** Simple helper function to check if a state object is a Drive document state object */
|
|
870
|
+
function isDriveState(state) {
|
|
871
|
+
return DrivePHStateSchema.safeParse(state).success;
|
|
872
|
+
}
|
|
873
|
+
/** Simple helper function to assert that a document state object is a Drive document state object */
|
|
874
|
+
function assertIsDriveState(state) {
|
|
875
|
+
DrivePHStateSchema.parse(state);
|
|
876
|
+
}
|
|
877
|
+
/** Simple helper function to check if a document is a Drive document */
|
|
878
|
+
function isDriveDocument(document) {
|
|
879
|
+
return DriveDocumentSchema.safeParse(document).success;
|
|
880
|
+
}
|
|
881
|
+
/** Simple helper function to assert that a document is a Drive document */
|
|
882
|
+
function assertIsDriveDocument(document) {
|
|
883
|
+
DriveDocumentSchema.parse(document);
|
|
884
|
+
}
|
|
885
|
+
//#endregion
|
|
886
|
+
//#region document-drive/gen/utils.ts
|
|
887
|
+
const initialGlobalState = {
|
|
888
|
+
name: "",
|
|
889
|
+
nodes: [],
|
|
890
|
+
icon: null
|
|
891
|
+
};
|
|
892
|
+
const initialLocalState = {
|
|
893
|
+
listeners: [],
|
|
894
|
+
triggers: [],
|
|
895
|
+
sharingType: "private",
|
|
896
|
+
availableOffline: false
|
|
897
|
+
};
|
|
898
|
+
const driveCreateState = (state) => {
|
|
899
|
+
return {
|
|
900
|
+
...defaultBaseState(),
|
|
901
|
+
global: {
|
|
902
|
+
...initialGlobalState,
|
|
903
|
+
...state?.global
|
|
904
|
+
},
|
|
905
|
+
local: {
|
|
906
|
+
...initialLocalState,
|
|
907
|
+
...state?.local
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
};
|
|
911
|
+
const driveCreateDocument = (state) => {
|
|
912
|
+
const document = baseCreateDocument(driveCreateState, state);
|
|
913
|
+
document.header.documentType = driveDocumentType;
|
|
914
|
+
document.header.id = generateId();
|
|
915
|
+
return document;
|
|
916
|
+
};
|
|
917
|
+
const driveSaveToFileHandle = (document, input) => {
|
|
918
|
+
return baseSaveToFileHandle(document, input);
|
|
919
|
+
};
|
|
920
|
+
const driveLoadFromInput = (input) => {
|
|
921
|
+
return baseLoadFromInput(input, driveDocumentReducer);
|
|
922
|
+
};
|
|
923
|
+
const isStateOfType = (state) => {
|
|
924
|
+
return isDriveState(state);
|
|
925
|
+
};
|
|
926
|
+
const assertIsStateOfType = (state) => {
|
|
927
|
+
assertIsDriveState(state);
|
|
928
|
+
};
|
|
929
|
+
const isDocumentOfType = (document) => {
|
|
930
|
+
return isDriveDocument(document);
|
|
931
|
+
};
|
|
932
|
+
const assertIsDocumentOfType = (document) => {
|
|
933
|
+
assertIsDriveDocument(document);
|
|
934
|
+
};
|
|
935
|
+
//#endregion
|
|
936
|
+
//#region document-drive/module.ts
|
|
937
|
+
const driveDocumentModelModule = {
|
|
938
|
+
actions: creators_exports,
|
|
939
|
+
reducer: driveDocumentReducer,
|
|
940
|
+
documentModel: createState$1(defaultBaseState(), driveDocumentModel),
|
|
941
|
+
utils: {
|
|
942
|
+
fileExtension: driveDocumentFileExtension,
|
|
943
|
+
createState: driveCreateState,
|
|
944
|
+
createDocument: driveCreateDocument,
|
|
945
|
+
loadFromInput: driveLoadFromInput,
|
|
946
|
+
saveToFileHandle: driveSaveToFileHandle,
|
|
947
|
+
isStateOfType,
|
|
948
|
+
assertIsStateOfType,
|
|
949
|
+
isDocumentOfType,
|
|
950
|
+
assertIsDocumentOfType
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
//#endregion
|
|
954
|
+
export { AddFileInputSchema, AddFolderInputSchema, AddListenerInputSchema, AddTriggerInputSchema, CopyNodeInputSchema, DeleteNodeInputSchema, DocumentDriveLocalStateSchema, DocumentDriveStateSchema, FileNodeSchema, FolderNodeSchema, ListenerCallInfoInputSchema, ListenerCallInfoSchema, ListenerFilterInputSchema, ListenerFilterSchema, ListenerInputSchema, ListenerSchema, MoveNodeInputSchema, NodeSchema, PullResponderTriggerDataInputSchema, PullResponderTriggerDataSchema, RemoveListenerInputSchema, RemoveTriggerInputSchema, SetAvailableOfflineInputSchema, SetDriveIconInputSchema, SetDriveNameInputSchema, SetSharingTypeInputSchema, TransmitterTypeSchema, TriggerDataSchema, TriggerInputSchema, TriggerSchema, TriggerTypeSchema, UpdateFileInputSchema, UpdateNodeInputSchema, addFile, addFolder, addListener, addTrigger, assertIsDocumentOfType, assertIsStateOfType, copyNode, createGlobalState, createLocalState, createState, defaultGlobalState, defaultLocalState, defaultPHState, definedNonNullAnySchema, deleteNode, driveCreateDocument, driveCreateState, driveDocumentFileExtension, driveDocumentModel, driveDocumentModelModule, driveDocumentReducer, driveDocumentType, driveLoadFromInput, driveReducer, driveSaveToFileHandle, escapeRegExp, generateNodesCopy, getAncestors, getDescendants, getNextCopyNumber, handleTargetNameCollisions, initialGlobalState, initialLocalState, isDefinedNonNullAny, isDocumentOfType, isFileNode, isFolderNode, isStateOfType, isValidName, moveNode, nodeReducer, removeListener, removeTrigger, setAvailableOffline, setDriveIcon, setDriveName, setSharingType, updateFile, updateNode };
|
|
955
|
+
|
|
956
|
+
//# sourceMappingURL=index.js.map
|