@webiny/app-record-locking 0.0.0-unstable.06b2ede40f
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/LICENSE +21 -0
- package/README.md +12 -0
- package/components/HeadlessCmsActionsAcoCell.d.ts +2 -0
- package/components/HeadlessCmsActionsAcoCell.js +60 -0
- package/components/HeadlessCmsActionsAcoCell.js.map +1 -0
- package/components/HeadlessCmsContentEntry/ContentEntryGuard.d.ts +9 -0
- package/components/HeadlessCmsContentEntry/ContentEntryGuard.js +40 -0
- package/components/HeadlessCmsContentEntry/ContentEntryGuard.js.map +1 -0
- package/components/HeadlessCmsContentEntry/ContentEntryLocker.d.ts +18 -0
- package/components/HeadlessCmsContentEntry/ContentEntryLocker.js +106 -0
- package/components/HeadlessCmsContentEntry/ContentEntryLocker.js.map +1 -0
- package/components/HeadlessCmsContentEntry/HeadlessCmsContentEntry.d.ts +2 -0
- package/components/HeadlessCmsContentEntry/HeadlessCmsContentEntry.js +90 -0
- package/components/HeadlessCmsContentEntry/HeadlessCmsContentEntry.js.map +1 -0
- package/components/HeadlessCmsContentEntry/index.d.ts +1 -0
- package/components/HeadlessCmsContentEntry/index.js +3 -0
- package/components/HeadlessCmsContentEntry/index.js.map +1 -0
- package/components/LockedRecord/LockedRecord.d.ts +6 -0
- package/components/LockedRecord/LockedRecord.js +66 -0
- package/components/LockedRecord/LockedRecord.js.map +1 -0
- package/components/LockedRecord/LockedRecordForceUnlock.d.ts +9 -0
- package/components/LockedRecord/LockedRecordForceUnlock.js +75 -0
- package/components/LockedRecord/LockedRecordForceUnlock.js.map +1 -0
- package/components/LockedRecord/index.d.ts +1 -0
- package/components/LockedRecord/index.js +3 -0
- package/components/LockedRecord/index.js.map +1 -0
- package/components/RecordLockingProvider.d.ts +7 -0
- package/components/RecordLockingProvider.js +125 -0
- package/components/RecordLockingProvider.js.map +1 -0
- package/components/decorators/UseContentEntriesListHookDecorator.d.ts +2 -0
- package/components/decorators/UseContentEntriesListHookDecorator.js +21 -0
- package/components/decorators/UseContentEntriesListHookDecorator.js.map +1 -0
- package/components/decorators/UseRecordsDecorator.d.ts +9 -0
- package/components/decorators/UseRecordsDecorator.js +25 -0
- package/components/decorators/UseRecordsDecorator.js.map +1 -0
- package/components/decorators/UseSaveEntryDecorator.d.ts +2 -0
- package/components/decorators/UseSaveEntryDecorator.js +55 -0
- package/components/decorators/UseSaveEntryDecorator.js.map +1 -0
- package/components/permissionRenderer/RecordLockingPermissions.d.ts +7 -0
- package/components/permissionRenderer/RecordLockingPermissions.js +71 -0
- package/components/permissionRenderer/RecordLockingPermissions.js.map +1 -0
- package/components/permissionRenderer/index.d.ts +2 -0
- package/components/permissionRenderer/index.js +21 -0
- package/components/permissionRenderer/index.js.map +1 -0
- package/domain/RecordLocking.d.ts +28 -0
- package/domain/RecordLocking.js +320 -0
- package/domain/RecordLocking.js.map +1 -0
- package/domain/RecordLockingClient.d.ts +12 -0
- package/domain/RecordLockingClient.js +19 -0
- package/domain/RecordLockingClient.js.map +1 -0
- package/domain/RecordLockingGetLockRecord.d.ts +11 -0
- package/domain/RecordLockingGetLockRecord.js +21 -0
- package/domain/RecordLockingGetLockRecord.js.map +1 -0
- package/domain/RecordLockingGetLockedEntryLockRecord.d.ts +11 -0
- package/domain/RecordLockingGetLockedEntryLockRecord.js +19 -0
- package/domain/RecordLockingGetLockedEntryLockRecord.js.map +1 -0
- package/domain/RecordLockingIsEntryLocked.d.ts +11 -0
- package/domain/RecordLockingIsEntryLocked.js +19 -0
- package/domain/RecordLockingIsEntryLocked.js.map +1 -0
- package/domain/RecordLockingListLockRecords.d.ts +12 -0
- package/domain/RecordLockingListLockRecords.js +31 -0
- package/domain/RecordLockingListLockRecords.js.map +1 -0
- package/domain/RecordLockingLockEntry.d.ts +11 -0
- package/domain/RecordLockingLockEntry.js +15 -0
- package/domain/RecordLockingLockEntry.js.map +1 -0
- package/domain/RecordLockingUnlockEntry.d.ts +11 -0
- package/domain/RecordLockingUnlockEntry.js +19 -0
- package/domain/RecordLockingUnlockEntry.js.map +1 -0
- package/domain/RecordLockingUpdateEntryLock.d.ts +11 -0
- package/domain/RecordLockingUpdateEntryLock.js +19 -0
- package/domain/RecordLockingUpdateEntryLock.js.map +1 -0
- package/domain/abstractions/IRecordLocking.d.ts +25 -0
- package/domain/abstractions/IRecordLocking.js +3 -0
- package/domain/abstractions/IRecordLocking.js.map +1 -0
- package/domain/abstractions/IRecordLockingClient.d.ts +6 -0
- package/domain/abstractions/IRecordLockingClient.js +3 -0
- package/domain/abstractions/IRecordLockingClient.js.map +1 -0
- package/domain/abstractions/IRecordLockingGetLockRecord.d.ts +12 -0
- package/domain/abstractions/IRecordLockingGetLockRecord.js +3 -0
- package/domain/abstractions/IRecordLockingGetLockRecord.js.map +1 -0
- package/domain/abstractions/IRecordLockingGetLockedEntryLockRecord.d.ts +12 -0
- package/domain/abstractions/IRecordLockingGetLockedEntryLockRecord.js +3 -0
- package/domain/abstractions/IRecordLockingGetLockedEntryLockRecord.js.map +1 -0
- package/domain/abstractions/IRecordLockingIsEntryLocked.d.ts +8 -0
- package/domain/abstractions/IRecordLockingIsEntryLocked.js +3 -0
- package/domain/abstractions/IRecordLockingIsEntryLocked.js.map +1 -0
- package/domain/abstractions/IRecordLockingListLockRecords.d.ts +19 -0
- package/domain/abstractions/IRecordLockingListLockRecords.js +3 -0
- package/domain/abstractions/IRecordLockingListLockRecords.js.map +1 -0
- package/domain/abstractions/IRecordLockingLockEntry.d.ts +12 -0
- package/domain/abstractions/IRecordLockingLockEntry.js +3 -0
- package/domain/abstractions/IRecordLockingLockEntry.js.map +1 -0
- package/domain/abstractions/IRecordLockingUnlockEntry.d.ts +13 -0
- package/domain/abstractions/IRecordLockingUnlockEntry.js +3 -0
- package/domain/abstractions/IRecordLockingUnlockEntry.js.map +1 -0
- package/domain/abstractions/IRecordLockingUpdateEntryLock.d.ts +12 -0
- package/domain/abstractions/IRecordLockingUpdateEntryLock.js +3 -0
- package/domain/abstractions/IRecordLockingUpdateEntryLock.js.map +1 -0
- package/domain/graphql/fields.d.ts +2 -0
- package/domain/graphql/fields.js +30 -0
- package/domain/graphql/fields.js.map +1 -0
- package/domain/graphql/getLockRecord.d.ts +12 -0
- package/domain/graphql/getLockRecord.js +18 -0
- package/domain/graphql/getLockRecord.js.map +1 -0
- package/domain/graphql/getLockedEntryLockRecord.d.ts +12 -0
- package/domain/graphql/getLockedEntryLockRecord.js +18 -0
- package/domain/graphql/getLockedEntryLockRecord.js.map +1 -0
- package/domain/graphql/isEntryLocked.d.ts +12 -0
- package/domain/graphql/isEntryLocked.js +16 -0
- package/domain/graphql/isEntryLocked.js.map +1 -0
- package/domain/graphql/listLockRecords.d.ts +17 -0
- package/domain/graphql/listLockRecords.js +26 -0
- package/domain/graphql/listLockRecords.js.map +1 -0
- package/domain/graphql/lockEntry.d.ts +12 -0
- package/domain/graphql/lockEntry.js +20 -0
- package/domain/graphql/lockEntry.js.map +1 -0
- package/domain/graphql/unlockEntry.d.ts +12 -0
- package/domain/graphql/unlockEntry.js +18 -0
- package/domain/graphql/unlockEntry.js.map +1 -0
- package/domain/graphql/updateEntryLock.d.ts +12 -0
- package/domain/graphql/updateEntryLock.js +18 -0
- package/domain/graphql/updateEntryLock.js.map +1 -0
- package/domain/utils/createRecordLockingClient.d.ts +3 -0
- package/domain/utils/createRecordLockingClient.js +12 -0
- package/domain/utils/createRecordLockingClient.js.map +1 -0
- package/domain/utils/createRecordLockingError.d.ts +6 -0
- package/domain/utils/createRecordLockingError.js +16 -0
- package/domain/utils/createRecordLockingError.js.map +1 -0
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +4 -0
- package/hooks/index.js.map +1 -0
- package/hooks/usePermission.d.ts +3 -0
- package/hooks/usePermission.js +21 -0
- package/hooks/usePermission.js.map +1 -0
- package/hooks/useRecordLocking.d.ts +2 -0
- package/hooks/useRecordLocking.js +12 -0
- package/hooks/useRecordLocking.js.map +1 -0
- package/index.d.ts +7 -0
- package/index.js +29 -0
- package/index.js.map +1 -0
- package/package.json +52 -0
- package/types.d.ts +75 -0
- package/types.js +3 -0
- package/types.js.map +1 -0
- package/utils/createCacheKey.d.ts +3 -0
- package/utils/createCacheKey.js +15 -0
- package/utils/createCacheKey.js.map +1 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { RecordLockingGetLockRecord } from "./RecordLockingGetLockRecord";
|
|
2
|
+
import { RecordLockingIsEntryLocked } from "./RecordLockingIsEntryLocked";
|
|
3
|
+
import { RecordLockingListLockRecords } from "./RecordLockingListLockRecords";
|
|
4
|
+
import { RecordLockingLockEntry } from "./RecordLockingLockEntry";
|
|
5
|
+
import { RecordLockingUnlockEntry } from "./RecordLockingUnlockEntry";
|
|
6
|
+
import { RecordLockingClient } from "./RecordLockingClient";
|
|
7
|
+
import { createRecordLockingError } from "./utils/createRecordLockingError";
|
|
8
|
+
import { parseIdentifier } from "@webiny/utils/parseIdentifier";
|
|
9
|
+
import { createCacheKey } from "../utils/createCacheKey";
|
|
10
|
+
import { RecordLockingUpdateEntryLock } from "./RecordLockingUpdateEntryLock";
|
|
11
|
+
import { RecordLockingGetLockedEntryLockRecord } from "./RecordLockingGetLockedEntryLockRecord";
|
|
12
|
+
class RecordLocking {
|
|
13
|
+
loading = false;
|
|
14
|
+
records = [];
|
|
15
|
+
onErrorCb = null;
|
|
16
|
+
constructor(params) {
|
|
17
|
+
this._setLoading = params.setLoading;
|
|
18
|
+
this._getLockRecord = params.getLockRecord;
|
|
19
|
+
this._getLockedEntryLockRecord = params.getLockedEntryLockRecord;
|
|
20
|
+
this._listLockRecords = params.listLockRecords;
|
|
21
|
+
this._unlockEntry = params.unlockEntry;
|
|
22
|
+
this._updateEntryLock = params.updateEntryLock;
|
|
23
|
+
}
|
|
24
|
+
async setRecords(folderId, type, records) {
|
|
25
|
+
const result = await this.fetchAndAssignRecords(folderId, type, records);
|
|
26
|
+
if (!result) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return result.map(record => {
|
|
30
|
+
const {
|
|
31
|
+
id: entryId
|
|
32
|
+
} = parseIdentifier(record.id);
|
|
33
|
+
return {
|
|
34
|
+
...record,
|
|
35
|
+
$lockingType: type,
|
|
36
|
+
$locked: record.$locked,
|
|
37
|
+
$selectable: record.$locked ? false : record.$selectable,
|
|
38
|
+
entryId
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async fetchLockRecord(params) {
|
|
43
|
+
const {
|
|
44
|
+
id,
|
|
45
|
+
$lockingType
|
|
46
|
+
} = params;
|
|
47
|
+
const {
|
|
48
|
+
id: entryId
|
|
49
|
+
} = parseIdentifier(id);
|
|
50
|
+
try {
|
|
51
|
+
const result = await this._getLockRecord.execute({
|
|
52
|
+
id: entryId,
|
|
53
|
+
type: $lockingType
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
data: result.data,
|
|
57
|
+
error: result.error
|
|
58
|
+
};
|
|
59
|
+
} catch (ex) {
|
|
60
|
+
return {
|
|
61
|
+
data: null,
|
|
62
|
+
error: ex
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async fetchLockedEntryLockRecord(params) {
|
|
67
|
+
const {
|
|
68
|
+
id,
|
|
69
|
+
$lockingType
|
|
70
|
+
} = params;
|
|
71
|
+
const {
|
|
72
|
+
id: entryId
|
|
73
|
+
} = parseIdentifier(id);
|
|
74
|
+
const result = await this._getLockedEntryLockRecord.execute({
|
|
75
|
+
id: entryId,
|
|
76
|
+
type: $lockingType
|
|
77
|
+
});
|
|
78
|
+
return result.data;
|
|
79
|
+
}
|
|
80
|
+
getLockRecordEntry(id) {
|
|
81
|
+
return this.records.find(record => {
|
|
82
|
+
const {
|
|
83
|
+
id: entryId
|
|
84
|
+
} = parseIdentifier(id);
|
|
85
|
+
return record.entryId === entryId;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
isRecordLocked(record) {
|
|
89
|
+
const result = this.records.find(r => {
|
|
90
|
+
const {
|
|
91
|
+
id: entryId
|
|
92
|
+
} = parseIdentifier(record.id);
|
|
93
|
+
return r.entryId === entryId && !!r.$locked && r.$lockingType === record.$lockingType;
|
|
94
|
+
});
|
|
95
|
+
if (!result?.$locked?.expiresOn) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
const isExpired = this.isLockExpired(result.$locked.expiresOn);
|
|
99
|
+
return !isExpired;
|
|
100
|
+
}
|
|
101
|
+
async updateEntryLock(params) {
|
|
102
|
+
try {
|
|
103
|
+
return await this._updateEntryLock.execute({
|
|
104
|
+
id: params.id,
|
|
105
|
+
type: params.$lockingType
|
|
106
|
+
});
|
|
107
|
+
} catch (ex) {
|
|
108
|
+
this.triggerOnError(ex);
|
|
109
|
+
return {
|
|
110
|
+
data: null,
|
|
111
|
+
error: ex
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
removeEntryLock(params) {
|
|
116
|
+
const index = this.records.findIndex(record => {
|
|
117
|
+
return record.entryId === params.id && record.$lockingType === params.$lockingType;
|
|
118
|
+
});
|
|
119
|
+
if (index === -1) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
this.records[index] = {
|
|
123
|
+
...this.records[index],
|
|
124
|
+
$locked: null,
|
|
125
|
+
$selectable: true
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
async unlockEntry(params, force) {
|
|
129
|
+
try {
|
|
130
|
+
const result = await this._unlockEntry.execute({
|
|
131
|
+
id: params.id,
|
|
132
|
+
type: params.$lockingType,
|
|
133
|
+
force
|
|
134
|
+
});
|
|
135
|
+
const id = result.data?.id;
|
|
136
|
+
if (!id) {
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
this.removeEntryLock({
|
|
140
|
+
...params
|
|
141
|
+
});
|
|
142
|
+
return result;
|
|
143
|
+
} catch (ex) {
|
|
144
|
+
this.triggerOnError(ex);
|
|
145
|
+
return {
|
|
146
|
+
data: null,
|
|
147
|
+
error: ex
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
onError(cb) {
|
|
152
|
+
this.onErrorCb = cb;
|
|
153
|
+
}
|
|
154
|
+
triggerOnError(error) {
|
|
155
|
+
this.setIsLoading(false);
|
|
156
|
+
if (!this.onErrorCb) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
this.onErrorCb(error);
|
|
160
|
+
}
|
|
161
|
+
isLockExpired(input) {
|
|
162
|
+
const expiresOn = new Date(input);
|
|
163
|
+
return expiresOn <= new Date();
|
|
164
|
+
}
|
|
165
|
+
setIsLoading(loading) {
|
|
166
|
+
this._setLoading(loading);
|
|
167
|
+
this.loading = loading;
|
|
168
|
+
}
|
|
169
|
+
async fetchAndAssignRecords(folderId, type, records) {
|
|
170
|
+
if (records.length === 0) {
|
|
171
|
+
return;
|
|
172
|
+
} else if (this.loading) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const assignedIdList = await this.assignRecords(folderId, type, records);
|
|
176
|
+
if (assignedIdList.length === 0) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
this.setIsLoading(true);
|
|
180
|
+
let result;
|
|
181
|
+
try {
|
|
182
|
+
result = await this._listLockRecords.execute({
|
|
183
|
+
where: {
|
|
184
|
+
id_in: assignedIdList,
|
|
185
|
+
type
|
|
186
|
+
},
|
|
187
|
+
limit: 10000
|
|
188
|
+
});
|
|
189
|
+
} catch (ex) {
|
|
190
|
+
console.error(ex);
|
|
191
|
+
this.triggerOnError(ex);
|
|
192
|
+
return;
|
|
193
|
+
} finally {
|
|
194
|
+
this.setIsLoading(false);
|
|
195
|
+
}
|
|
196
|
+
if (result.error) {
|
|
197
|
+
this.triggerOnError(result.error);
|
|
198
|
+
return;
|
|
199
|
+
} else if (!result.data) {
|
|
200
|
+
this.triggerOnError(createRecordLockingError({
|
|
201
|
+
message: `There is no data in the result and there is no error. Please check the network tab for more info.`,
|
|
202
|
+
code: "NO_DATA_IN_RESULT"
|
|
203
|
+
}));
|
|
204
|
+
return;
|
|
205
|
+
} else if (result.data.length === 0) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
for (const record of result.data) {
|
|
209
|
+
const index = this.records.findIndex(r => {
|
|
210
|
+
const {
|
|
211
|
+
id: entryId
|
|
212
|
+
} = parseIdentifier(record.id);
|
|
213
|
+
return r.entryId === entryId;
|
|
214
|
+
});
|
|
215
|
+
if (index < 0) {
|
|
216
|
+
console.error(`There is no record with id ${record.id} in the records array.`);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
this.records[index] = {
|
|
220
|
+
...this.records[index],
|
|
221
|
+
$locked: {
|
|
222
|
+
lockedBy: record.lockedBy,
|
|
223
|
+
expiresOn: record.expiresOn,
|
|
224
|
+
lockedOn: record.lockedOn,
|
|
225
|
+
actions: record.actions
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return this.records;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Assign records and return the assigned ID list.
|
|
233
|
+
*/
|
|
234
|
+
async assignRecords(folderId, type, records) {
|
|
235
|
+
/**
|
|
236
|
+
* First we check the record keys against ones in the local cache.
|
|
237
|
+
*/
|
|
238
|
+
const keys = records.map(record => {
|
|
239
|
+
if (record.entryId) {
|
|
240
|
+
return record.entryId;
|
|
241
|
+
}
|
|
242
|
+
const {
|
|
243
|
+
id: entryId
|
|
244
|
+
} = parseIdentifier(record.id);
|
|
245
|
+
return entryId;
|
|
246
|
+
});
|
|
247
|
+
const cacheKey = await createCacheKey(keys);
|
|
248
|
+
if (this.currentRecordsCacheKey === cacheKey) {
|
|
249
|
+
return [];
|
|
250
|
+
}
|
|
251
|
+
this.currentRecordsCacheKey = cacheKey;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Reset records if new type is not as same as the old type / folderId.
|
|
255
|
+
*/
|
|
256
|
+
if (this.currentRecordType !== type || this.currentFolderId !== folderId) {
|
|
257
|
+
this.records = [];
|
|
258
|
+
this.currentRecordType = type;
|
|
259
|
+
this.currentFolderId = folderId;
|
|
260
|
+
}
|
|
261
|
+
return records.reduce((collection, record) => {
|
|
262
|
+
const {
|
|
263
|
+
id: entryId
|
|
264
|
+
} = parseIdentifier(record.id);
|
|
265
|
+
const index = this.records.findIndex(r => r.entryId === entryId);
|
|
266
|
+
if (index >= 0) {
|
|
267
|
+
return collection;
|
|
268
|
+
}
|
|
269
|
+
this.records.push({
|
|
270
|
+
...record,
|
|
271
|
+
entryId,
|
|
272
|
+
$lockingType: type,
|
|
273
|
+
$locked: undefined
|
|
274
|
+
});
|
|
275
|
+
if (record.$type !== "RECORD") {
|
|
276
|
+
return collection;
|
|
277
|
+
}
|
|
278
|
+
collection.push(entryId);
|
|
279
|
+
return collection;
|
|
280
|
+
}, []);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
export const createRecordLocking = config => {
|
|
284
|
+
const client = new RecordLockingClient({
|
|
285
|
+
client: config.client
|
|
286
|
+
});
|
|
287
|
+
const getLockRecord = new RecordLockingGetLockRecord({
|
|
288
|
+
client
|
|
289
|
+
});
|
|
290
|
+
const getLockedEntryLockRecord = new RecordLockingGetLockedEntryLockRecord({
|
|
291
|
+
client
|
|
292
|
+
});
|
|
293
|
+
const isEntryLocked = new RecordLockingIsEntryLocked({
|
|
294
|
+
client
|
|
295
|
+
});
|
|
296
|
+
const listLockRecords = new RecordLockingListLockRecords({
|
|
297
|
+
client
|
|
298
|
+
});
|
|
299
|
+
const lockEntry = new RecordLockingLockEntry({
|
|
300
|
+
client
|
|
301
|
+
});
|
|
302
|
+
const unlockEntry = new RecordLockingUnlockEntry({
|
|
303
|
+
client
|
|
304
|
+
});
|
|
305
|
+
const updateEntryLock = new RecordLockingUpdateEntryLock({
|
|
306
|
+
client
|
|
307
|
+
});
|
|
308
|
+
return new RecordLocking({
|
|
309
|
+
setLoading: config.setLoading,
|
|
310
|
+
getLockRecord,
|
|
311
|
+
getLockedEntryLockRecord,
|
|
312
|
+
isEntryLocked,
|
|
313
|
+
listLockRecords,
|
|
314
|
+
updateEntryLock,
|
|
315
|
+
lockEntry,
|
|
316
|
+
unlockEntry
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
//# sourceMappingURL=RecordLocking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["RecordLockingGetLockRecord","RecordLockingIsEntryLocked","RecordLockingListLockRecords","RecordLockingLockEntry","RecordLockingUnlockEntry","RecordLockingClient","createRecordLockingError","parseIdentifier","createCacheKey","RecordLockingUpdateEntryLock","RecordLockingGetLockedEntryLockRecord","RecordLocking","loading","records","onErrorCb","constructor","params","_setLoading","setLoading","_getLockRecord","getLockRecord","_getLockedEntryLockRecord","getLockedEntryLockRecord","_listLockRecords","listLockRecords","_unlockEntry","unlockEntry","_updateEntryLock","updateEntryLock","setRecords","folderId","type","result","fetchAndAssignRecords","undefined","map","record","id","entryId","$lockingType","$locked","$selectable","fetchLockRecord","execute","data","error","ex","fetchLockedEntryLockRecord","getLockRecordEntry","find","isRecordLocked","r","expiresOn","isExpired","isLockExpired","triggerOnError","removeEntryLock","index","findIndex","force","onError","cb","setIsLoading","input","Date","length","assignedIdList","assignRecords","where","id_in","limit","console","message","code","lockedBy","lockedOn","actions","keys","cacheKey","currentRecordsCacheKey","currentRecordType","currentFolderId","reduce","collection","push","$type","createRecordLocking","config","client","isEntryLocked","lockEntry"],"sources":["RecordLocking.ts"],"sourcesContent":["import type {\n IRecordLocking,\n IRecordLockingUpdateEntryLockResult\n} from \"./abstractions/IRecordLocking\";\nimport type { ApolloClient } from \"apollo-client\";\nimport { RecordLockingGetLockRecord } from \"./RecordLockingGetLockRecord\";\nimport { RecordLockingIsEntryLocked } from \"./RecordLockingIsEntryLocked\";\nimport { RecordLockingListLockRecords } from \"./RecordLockingListLockRecords\";\nimport { RecordLockingLockEntry } from \"./RecordLockingLockEntry\";\nimport { RecordLockingUnlockEntry } from \"./RecordLockingUnlockEntry\";\nimport { RecordLockingClient } from \"./RecordLockingClient\";\nimport type { IRecordLockingGetLockRecord } from \"./abstractions/IRecordLockingGetLockRecord\";\nimport type { IRecordLockingIsEntryLocked } from \"./abstractions/IRecordLockingIsEntryLocked\";\nimport type {\n IRecordLockingListLockRecords,\n IRecordLockingListLockRecordsResult\n} from \"./abstractions/IRecordLockingListLockRecords\";\nimport type { IRecordLockingLockEntry } from \"./abstractions/IRecordLockingLockEntry\";\nimport type {\n IRecordLockingUnlockEntry,\n IRecordLockingUnlockEntryResult\n} from \"./abstractions/IRecordLockingUnlockEntry\";\nimport type {\n IFetchLockedEntryLockRecordParams,\n IFetchLockRecordParams,\n IFetchLockRecordResult,\n IIsRecordLockedParams,\n IPossiblyRecordLockingRecord,\n IRecordLockingError,\n IRecordLockingLockRecord,\n IRecordLockingRecord,\n IUnlockEntryParams,\n IUpdateEntryLockParams\n} from \"~/types\";\nimport { createRecordLockingError } from \"./utils/createRecordLockingError\";\nimport { parseIdentifier } from \"@webiny/utils/parseIdentifier\";\nimport { createCacheKey } from \"~/utils/createCacheKey\";\nimport { RecordLockingUpdateEntryLock } from \"~/domain/RecordLockingUpdateEntryLock\";\nimport type { IRecordLockingUpdateEntryLock } from \"~/domain/abstractions/IRecordLockingUpdateEntryLock\";\nimport { RecordLockingGetLockedEntryLockRecord } from \"~/domain/RecordLockingGetLockedEntryLockRecord\";\nimport type { IRecordLockingGetLockedEntryLockRecord } from \"./abstractions/IRecordLockingGetLockedEntryLockRecord\";\n\nexport interface ICreateRecordLockingParams {\n client: ApolloClient<any>;\n setLoading: (loading: boolean) => void;\n}\n\nexport interface IRecordLockingParams {\n setLoading: (loading: boolean) => void;\n getLockRecord: IRecordLockingGetLockRecord;\n getLockedEntryLockRecord: IRecordLockingGetLockedEntryLockRecord;\n isEntryLocked: IRecordLockingIsEntryLocked;\n listLockRecords: IRecordLockingListLockRecords;\n lockEntry: IRecordLockingLockEntry;\n unlockEntry: IRecordLockingUnlockEntry;\n updateEntryLock: IRecordLockingUpdateEntryLock;\n}\n\nexport interface IOnErrorCb {\n (error: IRecordLockingError): void;\n}\n\nclass RecordLocking<T extends IPossiblyRecordLockingRecord = IPossiblyRecordLockingRecord>\n implements IRecordLocking<T>\n{\n private currentRecordType?: string;\n private currentFolderId?: string;\n private currentRecordsCacheKey?: string;\n private readonly _setLoading: (loading: boolean) => void;\n public loading = false;\n public records: IRecordLockingRecord[] = [];\n private readonly _getLockRecord: IRecordLockingGetLockRecord;\n private readonly _getLockedEntryLockRecord: IRecordLockingGetLockedEntryLockRecord;\n private readonly _listLockRecords: IRecordLockingListLockRecords;\n private readonly _unlockEntry: IRecordLockingUnlockEntry;\n private readonly _updateEntryLock: IRecordLockingUpdateEntryLock;\n\n private onErrorCb: IOnErrorCb | null = null;\n\n public constructor(params: IRecordLockingParams) {\n this._setLoading = params.setLoading;\n this._getLockRecord = params.getLockRecord;\n this._getLockedEntryLockRecord = params.getLockedEntryLockRecord;\n this._listLockRecords = params.listLockRecords;\n this._unlockEntry = params.unlockEntry;\n this._updateEntryLock = params.updateEntryLock;\n }\n\n public async setRecords(\n folderId: string,\n type: string,\n records: T[]\n ): Promise<IRecordLockingRecord[] | undefined> {\n const result = await this.fetchAndAssignRecords(folderId, type, records);\n if (!result) {\n return undefined;\n }\n\n return result.map(record => {\n const { id: entryId } = parseIdentifier(record.id);\n return {\n ...record,\n $lockingType: type,\n $locked: record.$locked,\n $selectable: record.$locked ? false : record.$selectable,\n entryId\n };\n });\n }\n\n public async fetchLockRecord(params: IFetchLockRecordParams): Promise<IFetchLockRecordResult> {\n const { id, $lockingType } = params;\n\n const { id: entryId } = parseIdentifier(id);\n\n try {\n const result = await this._getLockRecord.execute({\n id: entryId,\n type: $lockingType\n });\n\n return {\n data: result.data,\n error: result.error\n };\n } catch (ex) {\n return {\n data: null,\n error: ex\n };\n }\n }\n\n public async fetchLockedEntryLockRecord(\n params: IFetchLockedEntryLockRecordParams\n ): Promise<IRecordLockingLockRecord | null> {\n const { id, $lockingType } = params;\n\n const { id: entryId } = parseIdentifier(id);\n const result = await this._getLockedEntryLockRecord.execute({\n id: entryId,\n type: $lockingType\n });\n return result.data;\n }\n\n public getLockRecordEntry(id: string): IRecordLockingRecord | undefined {\n return this.records.find(record => {\n const { id: entryId } = parseIdentifier(id);\n return record.entryId === entryId;\n });\n }\n\n public isRecordLocked(record: IIsRecordLockedParams): boolean {\n const result = this.records.find(r => {\n const { id: entryId } = parseIdentifier(record.id);\n\n return r.entryId === entryId && !!r.$locked && r.$lockingType === record.$lockingType;\n });\n if (!result?.$locked?.expiresOn) {\n return false;\n }\n const isExpired = this.isLockExpired(result.$locked.expiresOn);\n return !isExpired;\n }\n\n public async updateEntryLock(\n params: IUpdateEntryLockParams\n ): Promise<IRecordLockingUpdateEntryLockResult> {\n try {\n return await this._updateEntryLock.execute({\n id: params.id,\n type: params.$lockingType\n });\n } catch (ex) {\n this.triggerOnError(ex);\n return {\n data: null,\n error: ex\n };\n }\n }\n\n public removeEntryLock(params: IUnlockEntryParams): void {\n const index = this.records.findIndex(record => {\n return record.entryId === params.id && record.$lockingType === params.$lockingType;\n });\n if (index === -1) {\n return;\n }\n this.records[index] = {\n ...this.records[index],\n $locked: null,\n $selectable: true\n };\n }\n\n public async unlockEntry(\n params: IUnlockEntryParams,\n force?: boolean\n ): Promise<IRecordLockingUnlockEntryResult> {\n try {\n const result = await this._unlockEntry.execute({\n id: params.id,\n type: params.$lockingType,\n force\n });\n\n const id = result.data?.id;\n if (!id) {\n return result;\n }\n this.removeEntryLock({\n ...params\n });\n return result;\n } catch (ex) {\n this.triggerOnError(ex);\n return {\n data: null,\n error: ex\n };\n }\n }\n\n public onError(cb: IOnErrorCb): void {\n this.onErrorCb = cb;\n }\n\n public triggerOnError(error: IRecordLockingError): void {\n this.setIsLoading(false);\n if (!this.onErrorCb) {\n return;\n }\n this.onErrorCb(error);\n }\n\n public isLockExpired(input: Date | string): boolean {\n const expiresOn = new Date(input);\n return expiresOn <= new Date();\n }\n\n private setIsLoading(loading: boolean): void {\n this._setLoading(loading);\n this.loading = loading;\n }\n\n private async fetchAndAssignRecords(\n folderId: string,\n type: string,\n records: T[]\n ): Promise<IPossiblyRecordLockingRecord[] | undefined> {\n if (records.length === 0) {\n return;\n } else if (this.loading) {\n return;\n }\n const assignedIdList = await this.assignRecords(folderId, type, records);\n if (assignedIdList.length === 0) {\n return;\n }\n this.setIsLoading(true);\n let result: IRecordLockingListLockRecordsResult;\n try {\n result = await this._listLockRecords.execute({\n where: {\n id_in: assignedIdList,\n type\n },\n limit: 10000\n });\n } catch (ex) {\n console.error(ex);\n this.triggerOnError(ex);\n return;\n } finally {\n this.setIsLoading(false);\n }\n if (result.error) {\n this.triggerOnError(result.error);\n return;\n } else if (!result.data) {\n this.triggerOnError(\n createRecordLockingError({\n message: `There is no data in the result and there is no error. Please check the network tab for more info.`,\n code: \"NO_DATA_IN_RESULT\"\n })\n );\n return;\n } else if (result.data.length === 0) {\n return;\n }\n\n for (const record of result.data) {\n const index = this.records.findIndex(r => {\n const { id: entryId } = parseIdentifier(record.id);\n return r.entryId === entryId;\n });\n if (index < 0) {\n console.error(`There is no record with id ${record.id} in the records array.`);\n continue;\n }\n this.records[index] = {\n ...this.records[index],\n $locked: {\n lockedBy: record.lockedBy,\n expiresOn: record.expiresOn,\n lockedOn: record.lockedOn,\n actions: record.actions\n }\n };\n }\n\n return this.records;\n }\n /**\n * Assign records and return the assigned ID list.\n */\n private async assignRecords(folderId: string, type: string, records: T[]): Promise<string[]> {\n /**\n * First we check the record keys against ones in the local cache.\n */\n const keys = records.map(record => {\n if (record.entryId) {\n return record.entryId;\n }\n const { id: entryId } = parseIdentifier(record.id);\n return entryId;\n });\n const cacheKey = await createCacheKey(keys);\n if (this.currentRecordsCacheKey === cacheKey) {\n return [];\n }\n this.currentRecordsCacheKey = cacheKey;\n\n /**\n * Reset records if new type is not as same as the old type / folderId.\n */\n if (this.currentRecordType !== type || this.currentFolderId !== folderId) {\n this.records = [];\n this.currentRecordType = type;\n this.currentFolderId = folderId;\n }\n\n return records.reduce<string[]>((collection, record) => {\n const { id: entryId } = parseIdentifier(record.id);\n const index = this.records.findIndex(r => r.entryId === entryId);\n if (index >= 0) {\n return collection;\n }\n this.records.push({\n ...record,\n entryId,\n $lockingType: type,\n $locked: undefined\n });\n if (record.$type !== \"RECORD\") {\n return collection;\n }\n collection.push(entryId);\n return collection;\n }, []);\n }\n}\n\nexport const createRecordLocking = <T extends IRecordLockingRecord>(\n config: ICreateRecordLockingParams\n): IRecordLocking => {\n const client = new RecordLockingClient({\n client: config.client\n });\n\n const getLockRecord = new RecordLockingGetLockRecord({\n client\n });\n\n const getLockedEntryLockRecord = new RecordLockingGetLockedEntryLockRecord({\n client\n });\n\n const isEntryLocked = new RecordLockingIsEntryLocked({\n client\n });\n\n const listLockRecords = new RecordLockingListLockRecords({\n client\n });\n\n const lockEntry = new RecordLockingLockEntry({\n client\n });\n\n const unlockEntry = new RecordLockingUnlockEntry({\n client\n });\n\n const updateEntryLock = new RecordLockingUpdateEntryLock({\n client\n });\n\n return new RecordLocking<T>({\n setLoading: config.setLoading,\n getLockRecord,\n getLockedEntryLockRecord,\n isEntryLocked,\n listLockRecords,\n updateEntryLock,\n lockEntry,\n unlockEntry\n });\n};\n"],"mappings":"AAKA,SAASA,0BAA0B;AACnC,SAASC,0BAA0B;AACnC,SAASC,4BAA4B;AACrC,SAASC,sBAAsB;AAC/B,SAASC,wBAAwB;AACjC,SAASC,mBAAmB;AAwB5B,SAASC,wBAAwB;AACjC,SAASC,eAAe,QAAQ,+BAA+B;AAC/D,SAASC,cAAc;AACvB,SAASC,4BAA4B;AAErC,SAASC,qCAAqC;AAuB9C,MAAMC,aAAa,CAEnB;EAKWC,OAAO,GAAG,KAAK;EACfC,OAAO,GAA2B,EAAE;EAOnCC,SAAS,GAAsB,IAAI;EAEpCC,WAAWA,CAACC,MAA4B,EAAE;IAC7C,IAAI,CAACC,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M,CAACrE,UAAU;IAC7BE,aAAa;IACbE,wBAAwB;IACxBmE,aAAa;IACbjE,eAAe;IACfI,eAAe;IACf8D,SAAS;IACThE;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ApolloClient, ApolloQueryResult, MutationOptions, QueryOptions } from "apollo-client";
|
|
2
|
+
import type { FetchResult } from "apollo-link";
|
|
3
|
+
import type { IRecordLockingClient } from "./abstractions/IRecordLockingClient";
|
|
4
|
+
export interface IRecordLockingClientParams {
|
|
5
|
+
client: ApolloClient<any>;
|
|
6
|
+
}
|
|
7
|
+
export declare class RecordLockingClient implements IRecordLockingClient {
|
|
8
|
+
private readonly client;
|
|
9
|
+
constructor(params: IRecordLockingClientParams);
|
|
10
|
+
query<T, R>(params: QueryOptions<R>): Promise<ApolloQueryResult<T>>;
|
|
11
|
+
mutation<T, R>(options: MutationOptions<T, R>): Promise<FetchResult<T>>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class RecordLockingClient {
|
|
2
|
+
constructor(params) {
|
|
3
|
+
this.client = params.client;
|
|
4
|
+
}
|
|
5
|
+
async query(params) {
|
|
6
|
+
return this.client.query({
|
|
7
|
+
...params,
|
|
8
|
+
fetchPolicy: "network-only"
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
async mutation(options) {
|
|
12
|
+
return this.client.mutate({
|
|
13
|
+
...options,
|
|
14
|
+
fetchPolicy: "no-cache"
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=RecordLockingClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["RecordLockingClient","constructor","params","client","query","fetchPolicy","mutation","options","mutate"],"sources":["RecordLockingClient.ts"],"sourcesContent":["import type { ApolloClient, ApolloQueryResult, MutationOptions, QueryOptions } from \"apollo-client\";\nimport type { FetchResult } from \"apollo-link\";\nimport type { IRecordLockingClient } from \"~/domain/abstractions/IRecordLockingClient\";\n\nexport interface IRecordLockingClientParams {\n client: ApolloClient<any>;\n}\n\nexport class RecordLockingClient implements IRecordLockingClient {\n private readonly client: ApolloClient<any>;\n\n public constructor(params: IRecordLockingClientParams) {\n this.client = params.client;\n }\n\n public async query<T, R>(params: QueryOptions<R>): Promise<ApolloQueryResult<T>> {\n return this.client.query<T, R>({\n ...params,\n fetchPolicy: \"network-only\"\n });\n }\n\n public async mutation<T, R>(options: MutationOptions<T, R>): Promise<FetchResult<T>> {\n return this.client.mutate<T, R>({\n ...options,\n fetchPolicy: \"no-cache\"\n });\n }\n}\n"],"mappings":"AAQA,OAAO,MAAMA,mBAAmB,CAAiC;EAGtDC,WAAWA,CAACC,MAAkC,EAAE;IACnD,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;EAEA,MAAaC,KAAKA,CAAOF,MAAuB,EAAiC;IAC7E,OAAO,IAAI,CAACC,MAAM,CAACC,KAAK,CAAO;MAC3B,GAAGF,MAAM;MACTG,WAAW,EAAE;IACjB,CAAC,CAAC;EACN;EAEA,MAAaC,QAAQA,CAAOC,OAA8B,EAA2B;IACjF,OAAO,IAAI,CAACJ,MAAM,CAACK,MAAM,CAAO;MAC5B,GAAGD,OAAO;MACVF,WAAW,EAAE;IACjB,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IRecordLockingGetLockRecord, IRecordLockingGetLockRecordExecuteParams, IRecordLockingGetLockRecordExecuteResult } from "./abstractions/IRecordLockingGetLockRecord";
|
|
2
|
+
import type { IRecordLockingClient } from "./abstractions/IRecordLockingClient";
|
|
3
|
+
interface Params {
|
|
4
|
+
client: IRecordLockingClient;
|
|
5
|
+
}
|
|
6
|
+
export declare class RecordLockingGetLockRecord implements IRecordLockingGetLockRecord {
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor(params: Params);
|
|
9
|
+
execute(params: IRecordLockingGetLockRecordExecuteParams): Promise<IRecordLockingGetLockRecordExecuteResult>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GET_LOCK_RECORD_QUERY } from "./graphql/getLockRecord";
|
|
2
|
+
import { WebinyError } from "@webiny/error";
|
|
3
|
+
export class RecordLockingGetLockRecord {
|
|
4
|
+
constructor(params) {
|
|
5
|
+
this.client = params.client;
|
|
6
|
+
}
|
|
7
|
+
async execute(params) {
|
|
8
|
+
const result = await this.client.query({
|
|
9
|
+
query: GET_LOCK_RECORD_QUERY,
|
|
10
|
+
variables: params
|
|
11
|
+
});
|
|
12
|
+
if (result.data.recordLocking.getLockRecord.error) {
|
|
13
|
+
throw new WebinyError(result.data.recordLocking.getLockRecord.error);
|
|
14
|
+
} else if (!result.data.recordLocking.getLockRecord.data) {
|
|
15
|
+
throw new WebinyError("No data returned from server.");
|
|
16
|
+
}
|
|
17
|
+
return result.data.recordLocking.getLockRecord;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=RecordLockingGetLockRecord.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GET_LOCK_RECORD_QUERY","WebinyError","RecordLockingGetLockRecord","constructor","params","client","execute","result","query","variables","data","recordLocking","getLockRecord","error"],"sources":["RecordLockingGetLockRecord.ts"],"sourcesContent":["import type {\n IRecordLockingGetLockRecord,\n IRecordLockingGetLockRecordExecuteParams,\n IRecordLockingGetLockRecordExecuteResult\n} from \"~/domain/abstractions/IRecordLockingGetLockRecord\";\nimport type { IRecordLockingClient } from \"~/domain/abstractions/IRecordLockingClient\";\nimport type {\n IRecordLockingGetLockRecordResponse,\n IRecordLockingGetLockRecordVariables\n} from \"~/domain/graphql/getLockRecord\";\nimport { GET_LOCK_RECORD_QUERY } from \"~/domain/graphql/getLockRecord\";\nimport { WebinyError } from \"@webiny/error\";\n\ninterface Params {\n client: IRecordLockingClient;\n}\n\nexport class RecordLockingGetLockRecord implements IRecordLockingGetLockRecord {\n private readonly client: IRecordLockingClient;\n\n public constructor(params: Params) {\n this.client = params.client;\n }\n public async execute(\n params: IRecordLockingGetLockRecordExecuteParams\n ): Promise<IRecordLockingGetLockRecordExecuteResult> {\n const result = await this.client.query<\n IRecordLockingGetLockRecordResponse,\n IRecordLockingGetLockRecordVariables\n >({\n query: GET_LOCK_RECORD_QUERY,\n variables: params\n });\n if (result.data.recordLocking.getLockRecord.error) {\n throw new WebinyError(result.data.recordLocking.getLockRecord.error);\n } else if (!result.data.recordLocking.getLockRecord.data) {\n throw new WebinyError(\"No data returned from server.\");\n }\n return result.data.recordLocking.getLockRecord;\n }\n}\n"],"mappings":"AAUA,SAASA,qBAAqB;AAC9B,SAASC,WAAW,QAAQ,eAAe;AAM3C,OAAO,MAAMC,0BAA0B,CAAwC;EAGpEC,WAAWA,CAACC,MAAc,EAAE;IAC/B,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;EACA,MAAaC,OAAOA,CAChBF,MAAgD,EACC;IACjD,MAAMG,MAAM,GAAG,MAAM,IAAI,CAACF,MAAM,CAACG,KAAK,CAGpC;MACEA,KAAK,EAAER,qBAAqB;MAC5BS,SAAS,EAAEL;IACf,CAAC,CAAC;IACF,IAAIG,MAAM,CAACG,IAAI,CAACC,aAAa,CAACC,aAAa,CAACC,KAAK,EAAE;MAC/C,MAAM,IAAIZ,WAAW,CAACM,MAAM,CAACG,IAAI,CAACC,aAAa,CAACC,aAAa,CAACC,KAAK,CAAC;IACxE,CAAC,MAAM,IAAI,CAACN,MAAM,CAACG,IAAI,CAACC,aAAa,CAACC,aAAa,CAACF,IAAI,EAAE;MACtD,MAAM,IAAIT,WAAW,CAAC,+BAA+B,CAAC;IAC1D;IACA,OAAOM,MAAM,CAACG,IAAI,CAACC,aAAa,CAACC,aAAa;EAClD;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IRecordLockingClient } from "./abstractions/IRecordLockingClient";
|
|
2
|
+
import type { IRecordLockingGetLockedEntryLockRecord, IRecordLockingGetLockedEntryLockRecordExecuteParams, IRecordLockingGetLockedEntryLockRecordExecuteResult } from "./abstractions/IRecordLockingGetLockedEntryLockRecord";
|
|
3
|
+
interface Params {
|
|
4
|
+
client: IRecordLockingClient;
|
|
5
|
+
}
|
|
6
|
+
export declare class RecordLockingGetLockedEntryLockRecord implements IRecordLockingGetLockedEntryLockRecord {
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor(params: Params);
|
|
9
|
+
execute(params: IRecordLockingGetLockedEntryLockRecordExecuteParams): Promise<IRecordLockingGetLockedEntryLockRecordExecuteResult>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GET_LOCKED_ENTRY_LOCK_RECORD_QUERY } from "./graphql/getLockedEntryLockRecord";
|
|
2
|
+
import { WebinyError } from "@webiny/error";
|
|
3
|
+
export class RecordLockingGetLockedEntryLockRecord {
|
|
4
|
+
constructor(params) {
|
|
5
|
+
this.client = params.client;
|
|
6
|
+
}
|
|
7
|
+
async execute(params) {
|
|
8
|
+
const result = await this.client.query({
|
|
9
|
+
query: GET_LOCKED_ENTRY_LOCK_RECORD_QUERY,
|
|
10
|
+
variables: params
|
|
11
|
+
});
|
|
12
|
+
if (result.data.recordLocking.getLockedEntryLockRecord.error) {
|
|
13
|
+
throw new WebinyError(result.data.recordLocking.getLockedEntryLockRecord.error);
|
|
14
|
+
}
|
|
15
|
+
return result.data.recordLocking.getLockedEntryLockRecord;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=RecordLockingGetLockedEntryLockRecord.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GET_LOCKED_ENTRY_LOCK_RECORD_QUERY","WebinyError","RecordLockingGetLockedEntryLockRecord","constructor","params","client","execute","result","query","variables","data","recordLocking","getLockedEntryLockRecord","error"],"sources":["RecordLockingGetLockedEntryLockRecord.ts"],"sourcesContent":["import type { IRecordLockingClient } from \"~/domain/abstractions/IRecordLockingClient\";\nimport type {\n IRecordLockingGetLockedEntryLockRecordResponse,\n IRecordLockingGetLockedEntryLockRecordVariables\n} from \"~/domain/graphql/getLockedEntryLockRecord\";\nimport { GET_LOCKED_ENTRY_LOCK_RECORD_QUERY } from \"~/domain/graphql/getLockedEntryLockRecord\";\nimport { WebinyError } from \"@webiny/error\";\nimport type {\n IRecordLockingGetLockedEntryLockRecord,\n IRecordLockingGetLockedEntryLockRecordExecuteParams,\n IRecordLockingGetLockedEntryLockRecordExecuteResult\n} from \"~/domain/abstractions/IRecordLockingGetLockedEntryLockRecord\";\n\ninterface Params {\n client: IRecordLockingClient;\n}\n\nexport class RecordLockingGetLockedEntryLockRecord\n implements IRecordLockingGetLockedEntryLockRecord\n{\n private readonly client: IRecordLockingClient;\n\n public constructor(params: Params) {\n this.client = params.client;\n }\n public async execute(\n params: IRecordLockingGetLockedEntryLockRecordExecuteParams\n ): Promise<IRecordLockingGetLockedEntryLockRecordExecuteResult> {\n const result = await this.client.query<\n IRecordLockingGetLockedEntryLockRecordResponse,\n IRecordLockingGetLockedEntryLockRecordVariables\n >({\n query: GET_LOCKED_ENTRY_LOCK_RECORD_QUERY,\n variables: params\n });\n if (result.data.recordLocking.getLockedEntryLockRecord.error) {\n throw new WebinyError(result.data.recordLocking.getLockedEntryLockRecord.error);\n }\n return result.data.recordLocking.getLockedEntryLockRecord;\n }\n}\n"],"mappings":"AAKA,SAASA,kCAAkC;AAC3C,SAASC,WAAW,QAAQ,eAAe;AAW3C,OAAO,MAAMC,qCAAqC,CAElD;EAGWC,WAAWA,CAACC,MAAc,EAAE;IAC/B,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;EACA,MAAaC,OAAOA,CAChBF,MAA2D,EACC;IAC5D,MAAMG,MAAM,GAAG,MAAM,IAAI,CAACF,MAAM,CAACG,KAAK,CAGpC;MACEA,KAAK,EAAER,kCAAkC;MACzCS,SAAS,EAAEL;IACf,CAAC,CAAC;IACF,IAAIG,MAAM,CAACG,IAAI,CAACC,aAAa,CAACC,wBAAwB,CAACC,KAAK,EAAE;MAC1D,MAAM,IAAIZ,WAAW,CAACM,MAAM,CAACG,IAAI,CAACC,aAAa,CAACC,wBAAwB,CAACC,KAAK,CAAC;IACnF;IACA,OAAON,MAAM,CAACG,IAAI,CAACC,aAAa,CAACC,wBAAwB;EAC7D;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IRecordLockingIsEntryLocked, IRecordLockingIsEntryLockedParams, IRecordLockingIsEntryLockedResult } from "./abstractions/IRecordLockingIsEntryLocked";
|
|
2
|
+
import type { IRecordLockingClient } from "./abstractions/IRecordLockingClient";
|
|
3
|
+
interface Params {
|
|
4
|
+
client: IRecordLockingClient;
|
|
5
|
+
}
|
|
6
|
+
export declare class RecordLockingIsEntryLocked implements IRecordLockingIsEntryLocked {
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor(params: Params);
|
|
9
|
+
execute(params: IRecordLockingIsEntryLockedParams): Promise<IRecordLockingIsEntryLockedResult>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IS_ENTRY_LOCKED_QUERY } from "./graphql/isEntryLocked";
|
|
2
|
+
export class RecordLockingIsEntryLocked {
|
|
3
|
+
constructor(params) {
|
|
4
|
+
this.client = params.client;
|
|
5
|
+
}
|
|
6
|
+
async execute(params) {
|
|
7
|
+
try {
|
|
8
|
+
const result = await this.client.query({
|
|
9
|
+
query: IS_ENTRY_LOCKED_QUERY,
|
|
10
|
+
variables: params
|
|
11
|
+
});
|
|
12
|
+
return !!result.data.recordLocking.isEntryLocked.data;
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=RecordLockingIsEntryLocked.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["IS_ENTRY_LOCKED_QUERY","RecordLockingIsEntryLocked","constructor","params","client","execute","result","query","variables","data","recordLocking","isEntryLocked"],"sources":["RecordLockingIsEntryLocked.ts"],"sourcesContent":["import type {\n IRecordLockingIsEntryLocked,\n IRecordLockingIsEntryLockedParams,\n IRecordLockingIsEntryLockedResult\n} from \"~/domain/abstractions/IRecordLockingIsEntryLocked\";\nimport type { IRecordLockingClient } from \"./abstractions/IRecordLockingClient\";\nimport type {\n IRecordLockingIsEntryLockedResponse,\n IRecordLockingIsEntryLockedVariables\n} from \"~/domain/graphql/isEntryLocked\";\nimport { IS_ENTRY_LOCKED_QUERY } from \"~/domain/graphql/isEntryLocked\";\n\ninterface Params {\n client: IRecordLockingClient;\n}\n\nexport class RecordLockingIsEntryLocked implements IRecordLockingIsEntryLocked {\n private readonly client: IRecordLockingClient;\n\n public constructor(params: Params) {\n this.client = params.client;\n }\n public async execute(\n params: IRecordLockingIsEntryLockedParams\n ): Promise<IRecordLockingIsEntryLockedResult> {\n try {\n const result = await this.client.query<\n IRecordLockingIsEntryLockedResponse,\n IRecordLockingIsEntryLockedVariables\n >({\n query: IS_ENTRY_LOCKED_QUERY,\n variables: params\n });\n return !!result.data.recordLocking.isEntryLocked.data;\n } catch {\n return false;\n }\n }\n}\n"],"mappings":"AAUA,SAASA,qBAAqB;AAM9B,OAAO,MAAMC,0BAA0B,CAAwC;EAGpEC,WAAWA,CAACC,MAAc,EAAE;IAC/B,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;EACA,MAAaC,OAAOA,CAChBF,MAAyC,EACC;IAC1C,IAAI;MACA,MAAMG,MAAM,GAAG,MAAM,IAAI,CAACF,MAAM,CAACG,KAAK,CAGpC;QACEA,KAAK,EAAEP,qBAAqB;QAC5BQ,SAAS,EAAEL;MACf,CAAC,CAAC;MACF,OAAO,CAAC,CAACG,MAAM,CAACG,IAAI,CAACC,aAAa,CAACC,aAAa,CAACF,IAAI;IACzD,CAAC,CAAC,MAAM;MACJ,OAAO,KAAK;IAChB;EACJ;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ApolloClient } from "apollo-client";
|
|
2
|
+
import type { IRecordLockingListLockRecords, IRecordLockingListLockRecordsParams, IRecordLockingListLockRecordsResult } from "./abstractions/IRecordLockingListLockRecords";
|
|
3
|
+
import type { IRecordLockingClient } from "./abstractions/IRecordLockingClient";
|
|
4
|
+
interface Params {
|
|
5
|
+
client: IRecordLockingClient | ApolloClient<any>;
|
|
6
|
+
}
|
|
7
|
+
export declare class RecordLockingListLockRecords implements IRecordLockingListLockRecords {
|
|
8
|
+
private readonly client;
|
|
9
|
+
constructor(params: Params);
|
|
10
|
+
execute(params: IRecordLockingListLockRecordsParams): Promise<IRecordLockingListLockRecordsResult>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
|
+
import { createRecordLockingClient } from "./utils/createRecordLockingClient";
|
|
3
|
+
import { LIST_LOCK_RECORDS } from "./graphql/listLockRecords";
|
|
4
|
+
export class RecordLockingListLockRecords {
|
|
5
|
+
constructor(params) {
|
|
6
|
+
this.client = createRecordLockingClient(params.client);
|
|
7
|
+
}
|
|
8
|
+
async execute(params) {
|
|
9
|
+
const {
|
|
10
|
+
where,
|
|
11
|
+
sort,
|
|
12
|
+
limit,
|
|
13
|
+
after
|
|
14
|
+
} = params;
|
|
15
|
+
const result = await this.client.query({
|
|
16
|
+
query: LIST_LOCK_RECORDS,
|
|
17
|
+
variables: {
|
|
18
|
+
where,
|
|
19
|
+
sort,
|
|
20
|
+
limit,
|
|
21
|
+
after
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
if (!result.data?.recordLocking?.listLockRecords) {
|
|
25
|
+
throw new WebinyError("No data returned from server.");
|
|
26
|
+
}
|
|
27
|
+
return result.data.recordLocking.listLockRecords;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=RecordLockingListLockRecords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WebinyError","createRecordLockingClient","LIST_LOCK_RECORDS","RecordLockingListLockRecords","constructor","params","client","execute","where","sort","limit","after","result","query","variables","data","recordLocking","listLockRecords"],"sources":["RecordLockingListLockRecords.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport type { ApolloClient } from \"apollo-client\";\nimport type {\n IRecordLockingListLockRecords,\n IRecordLockingListLockRecordsParams,\n IRecordLockingListLockRecordsResult\n} from \"./abstractions/IRecordLockingListLockRecords\";\nimport type { IRecordLockingClient } from \"./abstractions/IRecordLockingClient\";\nimport { createRecordLockingClient } from \"./utils/createRecordLockingClient\";\nimport type {\n IRecordLockingListLockedRecordsResponse,\n IRecordLockingListLockedRecordsVariables\n} from \"~/domain/graphql/listLockRecords\";\nimport { LIST_LOCK_RECORDS } from \"~/domain/graphql/listLockRecords\";\n\ninterface Params {\n client: IRecordLockingClient | ApolloClient<any>;\n}\n\nexport class RecordLockingListLockRecords implements IRecordLockingListLockRecords {\n private readonly client: IRecordLockingClient;\n\n public constructor(params: Params) {\n this.client = createRecordLockingClient(params.client);\n }\n public async execute(\n params: IRecordLockingListLockRecordsParams\n ): Promise<IRecordLockingListLockRecordsResult> {\n const { where, sort, limit, after } = params;\n\n const result = await this.client.query<\n IRecordLockingListLockedRecordsResponse,\n IRecordLockingListLockedRecordsVariables\n >({\n query: LIST_LOCK_RECORDS,\n variables: {\n where,\n sort,\n limit,\n after\n }\n });\n if (!result.data?.recordLocking?.listLockRecords) {\n throw new WebinyError(\"No data returned from server.\");\n }\n return result.data.recordLocking.listLockRecords;\n }\n}\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAe;AAQ3C,SAASC,yBAAyB;AAKlC,SAASC,iBAAiB;AAM1B,OAAO,MAAMC,4BAA4B,CAA0C;EAGxEC,WAAWA,CAACC,MAAc,EAAE;IAC/B,IAAI,CAACC,MAAM,GAAGL,yBAAyB,CAACI,MAAM,CAACC,MAAM,CAAC;EAC1D;EACA,MAAaC,OAAOA,CAChBF,MAA2C,EACC;IAC5C,MAAM;MAAEG,KAAK;MAAEC,IAAI;MAAEC,KAAK;MAAEC;IAAM,CAAC,GAAGN,MAAM;IAE5C,MAAMO,MAAM,GAAG,MAAM,IAAI,CAACN,MAAM,CAACO,KAAK,CAGpC;MACEA,KAAK,EAAEX,iBAAiB;MACxBY,SAAS,EAAE;QACPN,KAAK;QACLC,IAAI;QACJC,KAAK;QACLC;MACJ;IACJ,CAAC,CAAC;IACF,IAAI,CAACC,MAAM,CAACG,IAAI,EAAEC,aAAa,EAAEC,eAAe,EAAE;MAC9C,MAAM,IAAIjB,WAAW,CAAC,+BAA+B,CAAC;IAC1D;IACA,OAAOY,MAAM,CAACG,IAAI,CAACC,aAAa,CAACC,eAAe;EACpD;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IRecordLockingLockEntry, IRecordLockingLockEntryParams, IRecordLockingLockEntryResult } from "./abstractions/IRecordLockingLockEntry";
|
|
2
|
+
import type { IRecordLockingClient } from "./abstractions/IRecordLockingClient";
|
|
3
|
+
interface Params {
|
|
4
|
+
client: IRecordLockingClient;
|
|
5
|
+
}
|
|
6
|
+
export declare class RecordLockingLockEntry implements IRecordLockingLockEntry {
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor(params: Params);
|
|
9
|
+
execute(params: IRecordLockingLockEntryParams): Promise<IRecordLockingLockEntryResult>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
|
+
export class RecordLockingLockEntry {
|
|
3
|
+
// eslint-disable-next-line
|
|
4
|
+
|
|
5
|
+
constructor(params) {
|
|
6
|
+
this.client = params.client;
|
|
7
|
+
}
|
|
8
|
+
async execute(
|
|
9
|
+
// eslint-disable-next-line
|
|
10
|
+
params) {
|
|
11
|
+
throw new WebinyError("Method not implemented.");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=RecordLockingLockEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WebinyError","RecordLockingLockEntry","constructor","params","client","execute"],"sources":["RecordLockingLockEntry.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport type {\n IRecordLockingLockEntry,\n IRecordLockingLockEntryParams,\n IRecordLockingLockEntryResult\n} from \"~/domain/abstractions/IRecordLockingLockEntry\";\nimport type { IRecordLockingClient } from \"./abstractions/IRecordLockingClient\";\n\ninterface Params {\n client: IRecordLockingClient;\n}\n\nexport class RecordLockingLockEntry implements IRecordLockingLockEntry {\n // eslint-disable-next-line\n private readonly client: IRecordLockingClient;\n\n public constructor(params: Params) {\n this.client = params.client;\n }\n public async execute(\n // eslint-disable-next-line\n params: IRecordLockingLockEntryParams\n ): Promise<IRecordLockingLockEntryResult> {\n throw new WebinyError(\"Method not implemented.\");\n }\n}\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAe;AAY3C,OAAO,MAAMC,sBAAsB,CAAoC;EACnE;;EAGOC,WAAWA,CAACC,MAAc,EAAE;IAC/B,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;EACA,MAAaC,OAAOA;EAChB;EACAF,MAAqC,EACC;IACtC,MAAM,IAAIH,WAAW,CAAC,yBAAyB,CAAC;EACpD;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IRecordLockingUnlockEntry, IRecordLockingUnlockEntryParams, IRecordLockingUnlockEntryResult } from "./abstractions/IRecordLockingUnlockEntry";
|
|
2
|
+
import type { IRecordLockingClient } from "./abstractions/IRecordLockingClient";
|
|
3
|
+
interface Params {
|
|
4
|
+
client: IRecordLockingClient;
|
|
5
|
+
}
|
|
6
|
+
export declare class RecordLockingUnlockEntry implements IRecordLockingUnlockEntry {
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor(params: Params);
|
|
9
|
+
execute(params: IRecordLockingUnlockEntryParams): Promise<IRecordLockingUnlockEntryResult>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|