@manuscripts/article-editor 1.13.26 → 1.13.27-LEAN-3304.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/projects/CommentList.js +4 -4
- package/dist/cjs/components/projects/CommentList.js.map +1 -1
- package/dist/cjs/components/projects/CommentsTab.js +1 -1
- package/dist/cjs/components/projects/CommentsTab.js.map +1 -1
- package/dist/cjs/hooks/use-create-editor.js +1 -4
- package/dist/cjs/hooks/use-create-editor.js.map +1 -1
- package/dist/cjs/hooks/use-handle-snapshot.js +25 -45
- package/dist/cjs/hooks/use-handle-snapshot.js.map +1 -1
- package/dist/cjs/postgres-data/Api.js +4 -24
- package/dist/cjs/postgres-data/Api.js.map +1 -1
- package/dist/cjs/postgres-data/PsSource.js +5 -43
- package/dist/cjs/postgres-data/PsSource.js.map +1 -1
- package/dist/cjs/postgres-data/buildData.js +34 -159
- package/dist/cjs/postgres-data/buildData.js.map +1 -1
- package/dist/cjs/postgres-data/buildUtilities.js +84 -229
- package/dist/cjs/postgres-data/buildUtilities.js.map +1 -1
- package/dist/cjs/postgres-data/savingUtilities.js +2 -21
- package/dist/cjs/postgres-data/savingUtilities.js.map +1 -1
- package/dist/cjs/quarterback/api/methods.js.map +1 -1
- package/dist/cjs/store/Store.js.map +1 -1
- package/dist/es/components/projects/CommentList.js +4 -4
- package/dist/es/components/projects/CommentList.js.map +1 -1
- package/dist/es/components/projects/CommentsTab.js +1 -1
- package/dist/es/components/projects/CommentsTab.js.map +1 -1
- package/dist/es/hooks/use-create-editor.js +1 -4
- package/dist/es/hooks/use-create-editor.js.map +1 -1
- package/dist/es/hooks/use-handle-snapshot.js +25 -45
- package/dist/es/hooks/use-handle-snapshot.js.map +1 -1
- package/dist/es/postgres-data/Api.js +4 -24
- package/dist/es/postgres-data/Api.js.map +1 -1
- package/dist/es/postgres-data/PsSource.js +4 -19
- package/dist/es/postgres-data/PsSource.js.map +1 -1
- package/dist/es/postgres-data/buildData.js +34 -157
- package/dist/es/postgres-data/buildData.js.map +1 -1
- package/dist/es/postgres-data/buildUtilities.js +84 -231
- package/dist/es/postgres-data/buildUtilities.js.map +1 -1
- package/dist/es/postgres-data/savingUtilities.js +1 -19
- package/dist/es/postgres-data/savingUtilities.js.map +1 -1
- package/dist/es/quarterback/api/methods.js.map +1 -1
- package/dist/es/store/Store.js.map +1 -1
- package/dist/types/postgres-data/Api.d.ts +3 -6
- package/dist/types/postgres-data/PsSource.d.ts +2 -3
- package/dist/types/postgres-data/buildData.d.ts +1 -16
- package/dist/types/postgres-data/buildUtilities.d.ts +2 -30
- package/dist/types/postgres-data/savingUtilities.d.ts +0 -11
- package/dist/types/quarterback/api/document.d.ts +36 -6
- package/dist/types/quarterback/api/methods.d.ts +8 -1
- package/dist/types/store/Store.d.ts +5 -38
- package/dist/types/store/buildStateFromSources.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/lib/collaborators.js +0 -24
- package/dist/cjs/lib/collaborators.js.map +0 -1
- package/dist/es/lib/collaborators.js +0 -20
- package/dist/es/lib/collaborators.js.map +0 -1
- package/dist/types/lib/collaborators.d.ts +0 -13
|
@@ -9,88 +9,64 @@
|
|
|
9
9
|
*
|
|
10
10
|
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
|
|
11
11
|
*/
|
|
12
|
-
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
13
|
-
import {
|
|
12
|
+
import { manuscriptIDTypes, ObjectTypes, } from '@manuscripts/json-schema';
|
|
13
|
+
import { encode } from '@manuscripts/transform';
|
|
14
14
|
import { saveWithThrottle } from './savingUtilities';
|
|
15
|
-
const buildUtilities = (
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
export const buildUtilities = (getState, updateState, api) => {
|
|
16
|
+
const excludeTypes = new Set([ObjectTypes.Manuscript, ObjectTypes.Project]);
|
|
17
|
+
const updateContainerIDs = (model, projectID, manuscriptID) => {
|
|
18
|
+
const containerIDs = {
|
|
19
|
+
containerID: projectID,
|
|
20
|
+
};
|
|
21
|
+
if (!model._id) {
|
|
22
|
+
throw new Error('Model ID required');
|
|
20
23
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// const bulkUpdate = async (items: Array<ContainedModel>): Promise<void> => {
|
|
24
|
-
// for (const value of items) {
|
|
25
|
-
// const containerIDs: ContainerIDs = {
|
|
26
|
-
// containerID: this.containerID,
|
|
27
|
-
// }
|
|
28
|
-
// if (isManuscriptModel(value)) {
|
|
29
|
-
// containerIDs.manuscriptID = this.manuscriptID
|
|
30
|
-
// }
|
|
31
|
-
// await this.collection.save(value, containerIDs, true)
|
|
32
|
-
// }
|
|
33
|
-
// }
|
|
34
|
-
const bulkPersistentProjectSave = (models) => {
|
|
35
|
-
// combine entire project and overwrite?
|
|
36
|
-
const onlyProjectModels = models.filter((model) => !model.manuscriptID);
|
|
37
|
-
const data = getData();
|
|
38
|
-
if (data.projectID && data.manuscriptID) {
|
|
39
|
-
api.saveProject(data.projectID, onlyProjectModels);
|
|
24
|
+
if (manuscriptIDTypes.has(model.objectType)) {
|
|
25
|
+
containerIDs.manuscriptID = manuscriptID;
|
|
40
26
|
}
|
|
27
|
+
return {
|
|
28
|
+
...model,
|
|
29
|
+
...containerIDs,
|
|
30
|
+
};
|
|
41
31
|
};
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (data.projectID && data.manuscriptID) {
|
|
48
|
-
return api
|
|
49
|
-
.saveProject(data.projectID, clearedModels)
|
|
50
|
-
.then(() => {
|
|
51
|
-
return true; // not sure what will be returned at this point
|
|
52
|
-
})
|
|
53
|
-
.catch((e) => {
|
|
54
|
-
return false;
|
|
55
|
-
});
|
|
32
|
+
const saveProject = async (models, projectID) => {
|
|
33
|
+
try {
|
|
34
|
+
const filtered = models.filter((m) => m.objectType !== ObjectTypes.Project);
|
|
35
|
+
await api.saveProject(projectID, filtered);
|
|
36
|
+
return true;
|
|
56
37
|
}
|
|
57
|
-
|
|
58
|
-
return
|
|
38
|
+
catch (e) {
|
|
39
|
+
return false;
|
|
59
40
|
}
|
|
60
41
|
};
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
42
|
+
const getModel = (id) => {
|
|
43
|
+
const state = getState();
|
|
44
|
+
if (!state.modelMap) {
|
|
45
|
+
return;
|
|
64
46
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
47
|
+
return state.modelMap.get(id);
|
|
48
|
+
};
|
|
49
|
+
const saveModels = async (models, excludeIDs) => {
|
|
50
|
+
const state = getState();
|
|
51
|
+
const projectID = state.projectID;
|
|
52
|
+
const manuscriptID = state.manuscriptID;
|
|
53
|
+
if (!state.modelMap || !manuscriptID || !projectID) {
|
|
54
|
+
throw new Error('Unable to save due to incomplete data');
|
|
68
55
|
}
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
56
|
+
const modelMap = new Map();
|
|
57
|
+
for (const [id, model] of state.modelMap) {
|
|
58
|
+
const type = model.objectType;
|
|
59
|
+
if (!excludeTypes.has(type) && !excludeIDs?.has(id)) {
|
|
60
|
+
modelMap.set(id, model);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
for (const model of models) {
|
|
64
|
+
if (!model._id) {
|
|
65
|
+
throw new Error('Model ID required');
|
|
66
|
+
}
|
|
67
|
+
const updated = updateContainerIDs(model, projectID, manuscriptID);
|
|
68
|
+
modelMap.set(model._id, updated);
|
|
76
69
|
}
|
|
77
|
-
const newModel = {
|
|
78
|
-
...containedModel,
|
|
79
|
-
...containerIDs,
|
|
80
|
-
};
|
|
81
|
-
const modelMap = new Map(data.modelMap);
|
|
82
|
-
modelMap.set(containedModel._id, newModel);
|
|
83
|
-
// data.modelMap.set(containedModel._id, newModel)
|
|
84
|
-
// const { attachment, ...containedModeldata } = containedModel as T &
|
|
85
|
-
// ContainedProps &
|
|
86
|
-
// ModelAttachment
|
|
87
|
-
// TODO: containedModeldata.contents = serialized DOM wrapper for bibliography
|
|
88
|
-
// const result = await this.collection.save(containedModeldata, containerIDs)
|
|
89
|
-
// under this new API we won' save the model separately but rather trigger a bulk save once in a while
|
|
90
|
-
// if (attachment) {
|
|
91
|
-
// await this.collection.putAttachment(result._id, attachment)
|
|
92
|
-
// }
|
|
93
|
-
// return result as T & ContainedProps
|
|
94
70
|
updateState({
|
|
95
71
|
modelMap,
|
|
96
72
|
preventUnload: true,
|
|
@@ -99,184 +75,61 @@ const buildUtilities = (getData, api, updateState) => {
|
|
|
99
75
|
updateState({
|
|
100
76
|
savingProcess: 'saving',
|
|
101
77
|
});
|
|
102
|
-
const result = await
|
|
103
|
-
...modelMap.values(),
|
|
104
|
-
]);
|
|
78
|
+
const result = await saveProject([...modelMap.values()], projectID);
|
|
105
79
|
updateState({
|
|
106
80
|
savingProcess: result ? 'saved' : 'failed',
|
|
107
81
|
preventUnload: false,
|
|
108
82
|
});
|
|
109
83
|
});
|
|
110
|
-
return newModel;
|
|
111
84
|
};
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const data = getData();
|
|
117
|
-
if (!data.modelMap || !data.projectID) {
|
|
118
|
-
throw new Error('State misses important element. Unable to savel a model.');
|
|
119
|
-
}
|
|
120
|
-
const containedModel = {
|
|
121
|
-
...model,
|
|
122
|
-
containerID: data.projectID,
|
|
123
|
-
};
|
|
124
|
-
const map = data.modelMap; // potential time discrepancy bug
|
|
125
|
-
updateState({
|
|
126
|
-
modelMap: map.set(model._id, containedModel),
|
|
127
|
-
});
|
|
128
|
-
saveWithThrottle(() => {
|
|
129
|
-
if (data.modelMap) {
|
|
130
|
-
bulkPersistentProjectSave([
|
|
131
|
-
...data.modelMap.values(),
|
|
132
|
-
]);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
return containedModel;
|
|
85
|
+
const saveModel = async (model) => {
|
|
86
|
+
await saveModels([model]);
|
|
87
|
+
//is this actually needed?
|
|
88
|
+
return model;
|
|
136
89
|
};
|
|
137
90
|
const deleteModel = async (id) => {
|
|
138
|
-
|
|
139
|
-
if (data.modelMap) {
|
|
140
|
-
const modelMap = new Map(data.modelMap);
|
|
141
|
-
modelMap.delete(id);
|
|
142
|
-
// data.modelMap.delete(id)
|
|
143
|
-
updateState({
|
|
144
|
-
modelMap: modelMap,
|
|
145
|
-
savingProcess: 'saving',
|
|
146
|
-
});
|
|
147
|
-
const result = await bulkPersistentManuscriptSave([
|
|
148
|
-
...modelMap.values(),
|
|
149
|
-
]);
|
|
150
|
-
updateState({
|
|
151
|
-
savingProcess: result ? 'saved' : 'failed',
|
|
152
|
-
});
|
|
153
|
-
}
|
|
91
|
+
await saveModels([], new Set([id]));
|
|
154
92
|
return id;
|
|
155
93
|
};
|
|
156
|
-
const saveManuscript = async (
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
throw new Error('Unable to save manuscript due to incomplete data');
|
|
161
|
-
}
|
|
162
|
-
const prevManuscript = data.modelMap.get(data.manuscriptID);
|
|
163
|
-
return saveModel({
|
|
164
|
-
...prevManuscript,
|
|
165
|
-
...manuscriptData,
|
|
166
|
-
}).then(() => undefined);
|
|
167
|
-
}
|
|
168
|
-
catch (e) {
|
|
169
|
-
console.log(e);
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
const saveNewManuscript = async (
|
|
173
|
-
// this is only for development purposes, in LW there should be no direct insertion of manuscripts by user
|
|
174
|
-
dependencies, containerID, // ignoring for now because API doesn't support an compulsory containerID
|
|
175
|
-
manuscript, newProject) => {
|
|
176
|
-
if (newProject) {
|
|
177
|
-
const project = await api.createProject(containerID, newProject.title || 'Untitled');
|
|
178
|
-
if (project) {
|
|
179
|
-
await api.createNewManuscript(project._id, manuscript._id);
|
|
180
|
-
dependencies.forEach((dep) => {
|
|
181
|
-
dep.containerID = project._id;
|
|
182
|
-
});
|
|
183
|
-
await api.saveProjectData(project._id, dependencies);
|
|
184
|
-
return manuscript;
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
throw new Error('Unable to create new project');
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
// else {
|
|
191
|
-
// currently not supporting multiple manuscripts in a project
|
|
192
|
-
// }
|
|
193
|
-
return Promise.resolve(manuscript);
|
|
194
|
-
};
|
|
195
|
-
const saveBiblioItem = async (item, projectID) => {
|
|
196
|
-
return saveProjectModel(item);
|
|
197
|
-
};
|
|
198
|
-
const updateBiblioItem = (item) => {
|
|
199
|
-
return saveModel(item); // difference between modelMap and projectModelMap are those different? should we store project level data in a different map?
|
|
200
|
-
// return this.collection.update(item._id, item)
|
|
201
|
-
};
|
|
202
|
-
const deleteBiblioItem = (item) => {
|
|
203
|
-
return Promise.resolve(getData().modelMap?.delete(item._id) || false);
|
|
204
|
-
};
|
|
205
|
-
const saveCorrection = (correction) => {
|
|
206
|
-
return saveModel(correction);
|
|
207
|
-
};
|
|
208
|
-
const createProjectLibraryCollection = async (libraryCollection, projectID) => {
|
|
209
|
-
saveProjectModel(libraryCollection);
|
|
210
|
-
};
|
|
211
|
-
// async ( model: T | Build<T> | Partial<T>
|
|
212
|
-
const bulkUpdate = async (items) => {
|
|
213
|
-
const data = getData();
|
|
214
|
-
if (!data.modelMap || !data.manuscriptID || !data.projectID) {
|
|
215
|
-
throw new Error('State misses important element. Unable to savel a model.');
|
|
216
|
-
}
|
|
217
|
-
const nonPMModelsTypes = [ObjectTypes.Project, ObjectTypes.Manuscript];
|
|
218
|
-
const modelMap = new Map();
|
|
219
|
-
for (const [id, oldModel] of data.modelMap) {
|
|
220
|
-
if (nonPMModelsTypes.some((t) => t == oldModel.objectType)) {
|
|
221
|
-
modelMap.set(id, oldModel);
|
|
222
|
-
}
|
|
94
|
+
const saveManuscript = async (manuscript) => {
|
|
95
|
+
const state = getState();
|
|
96
|
+
if (!state.modelMap || !state.manuscriptID) {
|
|
97
|
+
throw new Error('Unable to save manuscript due to incomplete data');
|
|
223
98
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
};
|
|
229
|
-
if (!model._id) {
|
|
230
|
-
throw new Error('Model ID required');
|
|
231
|
-
}
|
|
232
|
-
const containedModel = model;
|
|
233
|
-
if (isManuscriptModel(containedModel)) {
|
|
234
|
-
containerIDs.manuscriptID = data.manuscriptID;
|
|
235
|
-
}
|
|
236
|
-
const newModel = {
|
|
237
|
-
...containedModel,
|
|
238
|
-
...containerIDs,
|
|
239
|
-
};
|
|
240
|
-
modelMap.set(containedModel._id, newModel);
|
|
241
|
-
}
|
|
242
|
-
return new Promise((resolve, reject) => {
|
|
243
|
-
saveWithThrottle(async () => {
|
|
244
|
-
updateState({
|
|
245
|
-
savingProcess: 'saving',
|
|
246
|
-
});
|
|
247
|
-
const result = await bulkPersistentManuscriptSave([
|
|
248
|
-
...modelMap.values(),
|
|
249
|
-
]);
|
|
250
|
-
if (result) {
|
|
251
|
-
resolve();
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
reject();
|
|
255
|
-
}
|
|
256
|
-
updateState({
|
|
257
|
-
savingProcess: result ? 'saved' : 'failed',
|
|
258
|
-
});
|
|
259
|
-
});
|
|
99
|
+
const previous = state.modelMap.get(state.manuscriptID);
|
|
100
|
+
await saveModel({
|
|
101
|
+
...previous,
|
|
102
|
+
...manuscript,
|
|
260
103
|
});
|
|
261
104
|
};
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
105
|
+
const saveDoc = async (doc) => {
|
|
106
|
+
const models = encode(doc);
|
|
107
|
+
await saveModels([...models.values()]);
|
|
108
|
+
};
|
|
109
|
+
const createSnapshot = async () => {
|
|
110
|
+
const state = getState();
|
|
111
|
+
const projectID = state.projectID;
|
|
112
|
+
const manuscriptID = state.manuscriptID;
|
|
113
|
+
const snapshots = state.snapshots;
|
|
114
|
+
const snapshotsMap = state.snapshotsMap;
|
|
115
|
+
if (!projectID || !manuscriptID || !snapshots || !snapshotsMap) {
|
|
116
|
+
throw new Error('Unable to create snapshot due to incomplete data');
|
|
117
|
+
}
|
|
118
|
+
const data = await api.createSnapshot(projectID, manuscriptID);
|
|
119
|
+
const { snapshot, ...label } = data.snapshot;
|
|
120
|
+
updateState({
|
|
121
|
+
snapshots: [...snapshots, label],
|
|
122
|
+
snapshotsMap: snapshotsMap.set(label.id, data.snapshot),
|
|
123
|
+
});
|
|
265
124
|
};
|
|
266
125
|
return {
|
|
267
126
|
saveModel,
|
|
268
127
|
deleteModel,
|
|
269
128
|
saveManuscript,
|
|
270
|
-
saveNewManuscript,
|
|
271
129
|
getModel,
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
deleteBiblioItem,
|
|
276
|
-
updateBiblioItem,
|
|
277
|
-
bulkUpdate,
|
|
278
|
-
createUser,
|
|
130
|
+
saveModels,
|
|
131
|
+
saveDoc,
|
|
132
|
+
createSnapshot,
|
|
279
133
|
};
|
|
280
134
|
};
|
|
281
|
-
export default buildUtilities;
|
|
282
135
|
//# sourceMappingURL=buildUtilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUtilities.js","sourceRoot":"","sources":["../../../src/postgres-data/buildUtilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"buildUtilities.js","sourceRoot":"","sources":["../../../src/postgres-data/buildUtilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAEL,iBAAiB,EAEjB,WAAW,GACZ,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAS,MAAM,EAAkB,MAAM,wBAAwB,CAAA;AAItE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEpD,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,QAA8B,EAC9B,WAA4C,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xB,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAA;QACjC,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,CAAA;QACvC,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAA;QACjC,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,CAAA;QACvC,IAAI,CAAC,SAAS,IAAI,CAAC,YAAY,IAAI,CAAC,SAAS,IAAI,CAAC,YAAY,EAAE;YAC9D,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;SACpE;QACD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,SAAS,EAAE,YAAY,CAAC,CAAA;QAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC5C,WAAW,CAAC;YACV,SAAS,EAAE,CAAC,GAAG,SAAS,EAAE,KAAK,CAAC;YAChC,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC;SACxD,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,OAAO;QACL,SAAS;QACT,WAAW;QACX,cAAc;QACd,QAAQ;QACR,UAAU;QACV,OAAO;QACP,cAAc;KACf,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
*
|
|
10
10
|
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
|
|
11
11
|
*/
|
|
12
|
-
import { encode } from '@manuscripts/transform';
|
|
13
12
|
import { useRef } from 'react';
|
|
14
13
|
let throttled = () => null;
|
|
15
14
|
let timeout;
|
|
@@ -58,7 +57,7 @@ export const saveWithDebounce = () => {
|
|
|
58
57
|
export const useDoWithThrottle = () => {
|
|
59
58
|
const throttled = useRef(() => null);
|
|
60
59
|
const timeout = useRef();
|
|
61
|
-
|
|
60
|
+
return (fn, interval = 4000) => {
|
|
62
61
|
throttled.current = fn;
|
|
63
62
|
if (!timeout.current) {
|
|
64
63
|
throttled.current();
|
|
@@ -72,22 +71,5 @@ export const useDoWithThrottle = () => {
|
|
|
72
71
|
}, interval);
|
|
73
72
|
}
|
|
74
73
|
};
|
|
75
|
-
return doWithThrottle;
|
|
76
|
-
};
|
|
77
|
-
export const saveDoc = async (doc, modelMap, bulkUpdate) => {
|
|
78
|
-
if (!modelMap) {
|
|
79
|
-
return {
|
|
80
|
-
err: 'modelMap undefined inside usePouchStore',
|
|
81
|
-
code: 500,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
const models = encode(doc);
|
|
85
|
-
try {
|
|
86
|
-
await bulkUpdate([...models.values()]);
|
|
87
|
-
return { data: true };
|
|
88
|
-
}
|
|
89
|
-
catch (e) {
|
|
90
|
-
return { err: `Failed to save model: ${e}`, code: 500 };
|
|
91
|
-
}
|
|
92
74
|
};
|
|
93
75
|
//# sourceMappingURL=savingUtilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"savingUtilities.js","sourceRoot":"","sources":["../../../src/postgres-data/savingUtilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"savingUtilities.js","sourceRoot":"","sources":["../../../src/postgres-data/savingUtilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAE9B,IAAI,SAAS,GAAG,GAAG,EAAE,CAAC,IAAI,CAAA;AAC1B,IAAI,OAAe,CAAA;AAEnB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,EAAa,EACb,QAAQ,GAAG,IAAI,EACf,KAAK,GAAG,KAAK,EACb,MAAmB,EACnB,EAAE;IACF,SAAS,GAAG,EAAE,CAAA;IACd,MAAM,MAAM,GAAG,GAAG,EAAE;QAClB,SAAS,EAAE,CAAA;QACX,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CA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,EAAE;QACxC,SAAS,CAAC,OAAO,GAAG,EAAE,CAAA;QACtB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACpB,SAAS,CAAC,OAAO,EAAE,CAAA;YACnB,SAAS,CAAC,OAAO,GAAG,GAAG,EAAE;gBACvB,OAAO,IAAI,CAAA;YACb,CAAC,CAAA;YACD,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;gBACvC,SAAS,CAAC,OAAO,EAAE,CAAA;gBACnB,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;gBACpC,OAAO,CAAC,OAAO,GAAG,CAAC,CAAA;YACrB,CAAC,EAAE,QAAQ,CAAC,CAAA;SACb;IACH,CAAC,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../../../src/quarterback/api/methods.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,gBAAgB,GACjB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,MAAM,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../../../src/quarterback/api/methods.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,gBAAgB,GACjB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,MAAM,MAAM,cAAc,CAAA;AAiBjC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,MAAM,EAAE,kBAAkB;IAC1B,cAAc,EAAE,kBAAkB;CACnC,CAAA;AAED,6BAA6B;AAE7B,MAAM,UAAU,aAAa,CAAC,SAAiB;IAC7C,OAAO,SAAS,IAAI,EAAE,aAAa,EAAE,UAAU,SAAS,EAAE,EAAE,CAAA;AAC9D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAY,EACZ,OAAqB,EACrB,YAAY,GAAG,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AAG,CAAC,cAAc,CAAC,KAAK,mBAAmB,EAC5D;gBACA,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAA;gBAC/C,OAAM;aACP;iBAAM,IACL,QAAQ,CAAC,MAAM,IAAI,GAAG;gBACtB,QAAQ,CAAC,MAAM,GAAG,GAAG;gBACrB,QAAQ,CAAC,MAAM,KAAK,GAAG,EACvB;gBACA,gDAAgD;gBAChD,OAAO,CAAC,KAAK,CACX,4CAA4C,GAAG,QAAQ,CAAC,MAAM,CAC/D,CAAA;aACF;iBAAM;gBACL,OAAO,CAAC,KAAK,CACX,4CAA4C,GAAG,QAAQ,CAAC,MAAM,CAC/D,CAAA;aACF;QACH,CAAC;QACD,OAAO;YACL,2DAA2D;YAC3D,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;QAC9C,CAAC;QACD,OAAO,CAAC,GAAG;YACT,OAAO,CAAC,GAAG,CAAC,gCAAgC,GAAG,GAAG,CAAC,CAAA;QACrD,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Store.js","sourceRoot":"","sources":["../../../src/store/Store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"Store.js","sourceRoot":"","sources":["../../../src/store/Store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAqBH,OAAO,EAAE,qBAAqB,EAA2B,MAAM,GAAG,CAAA;AA2ElE,MAAM,cAAc,GAAG,GAAG,CAAA,CAAC,0BAA0B;AAErD,MAAM,cAAc,GAAG,CAAC,OAAY,EAAE,KAAY,EAAE,MAAe,EAAE,EAAE;IACrE,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO,EAAE,CAAA;AACjC,CAAC,CAAA;AAqBD,MAAM,OAAO,YAAY;IAWvB,YACE,OAAO,GAAG,cAAc,EACxB,cAAuC,EACvC,KAAK,GAAG,EAAE;QAmBZ,UA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AC,CAAA;IACxD,CAAC;IACD,SAAS,CAAC,EAAuC;QAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;QACxB,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACb,OAAO,SAAS,WAAW;YACzB,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QAClB,CAAC,CAAA;IACH,CAAC;IACD,cAAc,CAAC,EAAE,MAAM,GAAG,cAAc,EAAE,GAAG,OAAO,EAAE;QACpD,MAAM,kBAAkB,GAAG,IAAI,CAAC,YAAY,CAC1C,MAAM,EACN,OAAO,EACP,IAAI,CAAC,KAAM,EACX,IAAI,CAAC,QAAQ,CACd,CAAA;QACD,IAAI,kBAAkB,EAAE;YACtB,IAAI,CAAC,QAAQ,CACX,IAAI,CAAC,OAAO,CACV,kBAAkB,CAAC,OAAO,EAC1B,IAAI,CAAC,KAAM,EACX,kBAAkB,CAAC,MAAM,IAAI,EAAE,CAChC,CACF,CAAA;SACF;IACH,CAAC;IACD,OAAO;QACL,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAM,CAAC,CAAA;SACjC;QACD,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;SACrE;QACD,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;QACjB,IAAI,CAAC,KAAK,GAAG,EAAW,CAAA;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAA;IACxB,CAAC;CACF"}
|
|
@@ -9,10 +9,9 @@
|
|
|
9
9
|
*
|
|
10
10
|
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
|
|
11
11
|
*/
|
|
12
|
-
import { Bundle,
|
|
13
|
-
import { Build, ContainedModel } from '@manuscripts/transform';
|
|
12
|
+
import { Bundle, ManuscriptTemplate, Model, Project, SectionCategory, UserProfile } from '@manuscripts/json-schema';
|
|
14
13
|
import { AxiosInstance } from 'axios';
|
|
15
|
-
import {
|
|
14
|
+
import { ISaveSnapshotResponse } from '../quarterback/types';
|
|
16
15
|
export default class Api {
|
|
17
16
|
instance: AxiosInstance;
|
|
18
17
|
constructor();
|
|
@@ -30,9 +29,7 @@ export default class Api {
|
|
|
30
29
|
getBundle: (template: ManuscriptTemplate | undefined) => Promise<Bundle | undefined> | undefined;
|
|
31
30
|
getCSLStyle: (bundle: Bundle | undefined) => Promise<string | undefined> | undefined;
|
|
32
31
|
getUserProfiles: (containerID: string) => Promise<UserProfile[] | undefined>;
|
|
33
|
-
signUpAndGetToken: (username: string, password: string, name: string) => Promise<string | undefined>;
|
|
34
32
|
saveProject: (projectId: string, models: Model[]) => Promise<import("axios").AxiosResponse<unknown, any>>;
|
|
35
33
|
createProject: (projectId: string, title: string) => Promise<Project>;
|
|
36
|
-
|
|
37
|
-
saveProjectData: (projectID: string, data: Array<Build<ContainedModel> & ContainedIDs>) => Promise<Array<Build<ContainedModel> & ContainedIDs>>;
|
|
34
|
+
createSnapshot: (projectID: string, manuscriptID: string) => Promise<ISaveSnapshotResponse>;
|
|
38
35
|
}
|
|
@@ -13,15 +13,14 @@ import { FileAttachment } from '@manuscripts/style-guide';
|
|
|
13
13
|
import { builderFn, state, stateSetter } from '../store';
|
|
14
14
|
import { StoreDataSourceStrategy } from '../store/DataSourceStrategy';
|
|
15
15
|
import Api from './Api';
|
|
16
|
-
import buildUtilities from './buildUtilities';
|
|
17
16
|
export default class PsSource implements StoreDataSourceStrategy {
|
|
18
17
|
api: Api;
|
|
19
18
|
data: Partial<state>;
|
|
20
|
-
utilities:
|
|
19
|
+
utilities: Partial<state>;
|
|
21
20
|
files: FileAttachment[];
|
|
22
21
|
constructor(files: FileAttachment[]);
|
|
23
22
|
updateState: (state: Partial<state>) => void;
|
|
24
23
|
build: builderFn;
|
|
25
|
-
afterAction:
|
|
24
|
+
afterAction: (state: state) => void;
|
|
26
25
|
updateStore: (setState: stateSetter) => void;
|
|
27
26
|
}
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
|
|
3
|
-
*
|
|
4
|
-
* Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
|
|
5
|
-
*
|
|
6
|
-
* The Original Code is manuscripts-frontend.
|
|
7
|
-
*
|
|
8
|
-
* The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
|
|
9
|
-
*
|
|
10
|
-
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
|
|
11
|
-
*/
|
|
12
|
-
import { Model } from '@manuscripts/json-schema';
|
|
13
|
-
import { state } from '../store';
|
|
14
1
|
import Api from './Api';
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const getDrivedData: (projectID: string, data: Partial<state>) => Partial<state> | null;
|
|
17
|
-
export default function buildData(projectID: string, manuscriptID: string, api: Api): Promise<{}>;
|
|
2
|
+
export declare const buildData: (projectID: string, manuscriptID: string, api: Api) => Promise<{}>;
|
|
@@ -9,34 +9,6 @@
|
|
|
9
9
|
*
|
|
10
10
|
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
|
|
11
11
|
*/
|
|
12
|
-
import { BibliographyItem, Correction, LibraryCollection, Manuscript, Model, Project, UserProfile } from '@manuscripts/json-schema';
|
|
13
|
-
import { Build, ContainedModel, ContainedProps } from '@manuscripts/transform';
|
|
14
12
|
import Api from '../postgres-data/Api';
|
|
15
|
-
import {
|
|
16
|
-
declare const buildUtilities: (
|
|
17
|
-
saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T & {
|
|
18
|
-
containerID: string;
|
|
19
|
-
manuscriptID?: string | undefined;
|
|
20
|
-
templateID?: string | undefined;
|
|
21
|
-
}>;
|
|
22
|
-
deleteModel: (id: string) => Promise<string>;
|
|
23
|
-
saveManuscript: (manuscriptData: Partial<Manuscript>) => Promise<undefined>;
|
|
24
|
-
saveNewManuscript: (dependencies: Array<Build<ContainedModel> & ContainedIDs>, containerID: string, manuscript: Build<Manuscript>, newProject?: Build<Project>) => Promise<Build<Manuscript>>;
|
|
25
|
-
getModel: <T_1 extends Model>(id: string) => T_1 | undefined;
|
|
26
|
-
saveCorrection: (correction: Correction) => Promise<Correction & {
|
|
27
|
-
containerID: string;
|
|
28
|
-
manuscriptID?: string | undefined;
|
|
29
|
-
templateID?: string | undefined;
|
|
30
|
-
}>;
|
|
31
|
-
createProjectLibraryCollection: (libraryCollection: Build<LibraryCollection>, projectID?: string) => Promise<void>;
|
|
32
|
-
saveBiblioItem: (item: Build<BibliographyItem>, projectID: string) => Promise<BibliographyItem & ContainedProps>;
|
|
33
|
-
deleteBiblioItem: (item: BibliographyItem) => Promise<boolean>;
|
|
34
|
-
updateBiblioItem: (item: BibliographyItem) => Promise<BibliographyItem & {
|
|
35
|
-
containerID: string;
|
|
36
|
-
manuscriptID?: string | undefined;
|
|
37
|
-
templateID?: string | undefined;
|
|
38
|
-
}>;
|
|
39
|
-
bulkUpdate: (items: Array<ContainedModel> | Build<Model>[] | Partial<Model>[]) => Promise<void>;
|
|
40
|
-
createUser: (profile: Build<UserProfile>) => Promise<void>;
|
|
41
|
-
};
|
|
42
|
-
export default buildUtilities;
|
|
13
|
+
import { state } from '../store';
|
|
14
|
+
export declare const buildUtilities: (getState: () => Partial<state>, updateState: (state: Partial<state>) => void, api: Api) => Partial<state>;
|
|
@@ -9,17 +9,6 @@
|
|
|
9
9
|
*
|
|
10
10
|
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
|
|
11
11
|
*/
|
|
12
|
-
import { Model } from '@manuscripts/json-schema';
|
|
13
|
-
import { ContainedModel, ManuscriptNode } from '@manuscripts/transform';
|
|
14
12
|
export declare const saveWithThrottle: (fn: () => any, interval?: number, flush?: boolean, onDone?: () => void) => (() => void) | undefined;
|
|
15
13
|
export declare const saveWithDebounce: () => (fn: () => any, interval?: number, flush?: boolean, onDone?: () => void) => (() => void) | undefined;
|
|
16
14
|
export declare const useDoWithThrottle: () => (fn: () => any, interval?: number) => void;
|
|
17
|
-
export type Ok<T> = {
|
|
18
|
-
data: T;
|
|
19
|
-
};
|
|
20
|
-
export type Error = {
|
|
21
|
-
err: string;
|
|
22
|
-
code: number;
|
|
23
|
-
};
|
|
24
|
-
export type Maybe<T> = Ok<T> | Error;
|
|
25
|
-
export declare const saveDoc: (doc: ManuscriptNode, modelMap: Map<string, Model>, bulkUpdate: (models: Array<ContainedModel> | Partial<Model>[]) => Promise<void>) => Promise<Maybe<boolean>>;
|