@webiny/app-record-locking 6.3.0-beta.4 → 6.4.0-beta.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/components/HeadlessCmsActionsAcoCell.js +29 -51
- package/components/HeadlessCmsActionsAcoCell.js.map +1 -1
- package/components/HeadlessCmsContentEntry/ContentEntryGuard.js +26 -34
- package/components/HeadlessCmsContentEntry/ContentEntryGuard.js.map +1 -1
- package/components/HeadlessCmsContentEntry/ContentEntryLocker.js +70 -89
- package/components/HeadlessCmsContentEntry/ContentEntryLocker.js.map +1 -1
- package/components/HeadlessCmsContentEntry/HeadlessCmsContentEntry.js +38 -62
- package/components/HeadlessCmsContentEntry/HeadlessCmsContentEntry.js.map +1 -1
- package/components/HeadlessCmsContentEntry/index.js +0 -2
- package/components/LockedRecord/LockedRecord.js +45 -57
- package/components/LockedRecord/LockedRecord.js.map +1 -1
- package/components/LockedRecord/LockedRecordForceUnlock.js +49 -63
- package/components/LockedRecord/LockedRecordForceUnlock.js.map +1 -1
- package/components/LockedRecord/index.js +0 -2
- package/components/RecordLockingProvider.js +103 -117
- package/components/RecordLockingProvider.js.map +1 -1
- package/components/SecurityPermissions.js +11 -14
- package/components/SecurityPermissions.js.map +1 -1
- package/components/decorators/UseContentEntriesListHookDecorator.js +18 -18
- package/components/decorators/UseContentEntriesListHookDecorator.js.map +1 -1
- package/components/decorators/UseRecordsDecorator.js +13 -22
- package/components/decorators/UseRecordsDecorator.js.map +1 -1
- package/components/decorators/UseSaveEntryDecorator.js +35 -49
- package/components/decorators/UseSaveEntryDecorator.js.map +1 -1
- package/domain/RecordLocking.js +229 -291
- package/domain/RecordLocking.js.map +1 -1
- package/domain/RecordLockingClient.js +17 -16
- package/domain/RecordLockingClient.js.map +1 -1
- package/domain/RecordLockingGetLockRecord.js +13 -15
- package/domain/RecordLockingGetLockRecord.js.map +1 -1
- package/domain/RecordLockingGetLockedEntryLockRecord.js +12 -13
- package/domain/RecordLockingGetLockedEntryLockRecord.js.map +1 -1
- package/domain/RecordLockingIsEntryLocked.js +15 -14
- package/domain/RecordLockingIsEntryLocked.js.map +1 -1
- package/domain/RecordLockingListLockRecords.js +18 -24
- package/domain/RecordLockingListLockRecords.js.map +1 -1
- package/domain/RecordLockingLockEntry.js +8 -9
- package/domain/RecordLockingLockEntry.js.map +1 -1
- package/domain/RecordLockingUnlockEntry.js +12 -13
- package/domain/RecordLockingUnlockEntry.js.map +1 -1
- package/domain/RecordLockingUpdateEntryLock.js +12 -13
- package/domain/RecordLockingUpdateEntryLock.js.map +1 -1
- package/domain/abstractions/IRecordLocking.js +0 -3
- package/domain/abstractions/IRecordLockingClient.js +0 -3
- package/domain/abstractions/IRecordLockingGetLockRecord.js +0 -3
- package/domain/abstractions/IRecordLockingGetLockedEntryLockRecord.js +0 -3
- package/domain/abstractions/IRecordLockingIsEntryLocked.js +0 -3
- package/domain/abstractions/IRecordLockingListLockRecords.js +0 -3
- package/domain/abstractions/IRecordLockingLockEntry.js +0 -3
- package/domain/abstractions/IRecordLockingUnlockEntry.js +0 -3
- package/domain/abstractions/IRecordLockingUpdateEntryLock.js +0 -3
- package/domain/graphql/fields.js +3 -2
- package/domain/graphql/fields.js.map +1 -1
- package/domain/graphql/getLockRecord.js +3 -2
- package/domain/graphql/getLockRecord.js.map +1 -1
- package/domain/graphql/getLockedEntryLockRecord.js +3 -2
- package/domain/graphql/getLockedEntryLockRecord.js.map +1 -1
- package/domain/graphql/isEntryLocked.js +3 -2
- package/domain/graphql/isEntryLocked.js.map +1 -1
- package/domain/graphql/listLockRecords.js +4 -5
- package/domain/graphql/listLockRecords.js.map +1 -1
- package/domain/graphql/lockEntry.js +3 -4
- package/domain/graphql/lockEntry.js.map +1 -1
- package/domain/graphql/unlockEntry.js +3 -2
- package/domain/graphql/unlockEntry.js.map +1 -1
- package/domain/graphql/updateEntryLock.js +3 -2
- package/domain/graphql/updateEntryLock.js.map +1 -1
- package/domain/permissionsSchema.js +6 -5
- package/domain/permissionsSchema.js.map +1 -1
- package/domain/utils/createRecordLockingClient.js +5 -6
- package/domain/utils/createRecordLockingClient.js.map +1 -1
- package/domain/utils/createRecordLockingError.js +10 -11
- package/domain/utils/createRecordLockingError.js.map +1 -1
- package/features/permissions/abstractions.js +2 -1
- package/features/permissions/abstractions.js.map +1 -1
- package/features/permissions/feature.js +2 -1
- package/features/permissions/feature.js.map +1 -1
- package/hooks/index.js +0 -2
- package/hooks/usePermission.js +14 -15
- package/hooks/usePermission.js.map +1 -1
- package/hooks/useRecordLocking.js +5 -6
- package/hooks/useRecordLocking.js.map +1 -1
- package/index.js +15 -21
- package/index.js.map +1 -1
- package/package.json +12 -12
- package/types.js +0 -3
- package/utils/createCacheKey.js +9 -10
- package/utils/createCacheKey.js.map +1 -1
- package/components/HeadlessCmsContentEntry/index.js.map +0 -1
- package/components/LockedRecord/index.js.map +0 -1
- package/domain/abstractions/IRecordLocking.js.map +0 -1
- package/domain/abstractions/IRecordLockingClient.js.map +0 -1
- package/domain/abstractions/IRecordLockingGetLockRecord.js.map +0 -1
- package/domain/abstractions/IRecordLockingGetLockedEntryLockRecord.js.map +0 -1
- package/domain/abstractions/IRecordLockingIsEntryLocked.js.map +0 -1
- package/domain/abstractions/IRecordLockingListLockRecords.js.map +0 -1
- package/domain/abstractions/IRecordLockingLockEntry.js.map +0 -1
- package/domain/abstractions/IRecordLockingUnlockEntry.js.map +0 -1
- package/domain/abstractions/IRecordLockingUpdateEntryLock.js.map +0 -1
- package/hooks/index.js.map +0 -1
- package/types.js.map +0 -1
package/domain/RecordLocking.js
CHANGED
|
@@ -10,312 +10,250 @@ import { createCacheKey } from "../utils/createCacheKey.js";
|
|
|
10
10
|
import { RecordLockingUpdateEntryLock } from "./RecordLockingUpdateEntryLock.js";
|
|
11
11
|
import { RecordLockingGetLockedEntryLockRecord } from "./RecordLockingGetLockedEntryLockRecord.js";
|
|
12
12
|
class RecordLocking {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
async setRecords(folderId, type, records) {
|
|
25
|
-
const result = await this.fetchAndAssignRecords(folderId, type, records);
|
|
26
|
-
if (!result) {
|
|
27
|
-
return undefined;
|
|
13
|
+
constructor(params){
|
|
14
|
+
this.loading = false;
|
|
15
|
+
this.records = [];
|
|
16
|
+
this.onErrorCb = null;
|
|
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;
|
|
28
23
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
async fetchLockRecord(params) {
|
|
44
|
-
const {
|
|
45
|
-
id,
|
|
46
|
-
$lockingType
|
|
47
|
-
} = params;
|
|
48
|
-
const {
|
|
49
|
-
id: entryId
|
|
50
|
-
} = parseIdentifier(id);
|
|
51
|
-
try {
|
|
52
|
-
const result = await this._getLockRecord.execute({
|
|
53
|
-
id: entryId,
|
|
54
|
-
type: $lockingType
|
|
55
|
-
});
|
|
56
|
-
return {
|
|
57
|
-
data: result.data,
|
|
58
|
-
error: result.error
|
|
59
|
-
};
|
|
60
|
-
} catch (ex) {
|
|
61
|
-
return {
|
|
62
|
-
data: null,
|
|
63
|
-
error: ex
|
|
64
|
-
};
|
|
24
|
+
async setRecords(folderId, type, records) {
|
|
25
|
+
const result = await this.fetchAndAssignRecords(folderId, type, records);
|
|
26
|
+
if (!result) return;
|
|
27
|
+
return result.map((record)=>{
|
|
28
|
+
const { id: entryId } = parseIdentifier(record.id);
|
|
29
|
+
return {
|
|
30
|
+
...record,
|
|
31
|
+
$type: "RECORD",
|
|
32
|
+
$lockingType: type,
|
|
33
|
+
$locked: record.$locked,
|
|
34
|
+
$selectable: record.$locked ? false : record.$selectable,
|
|
35
|
+
entryId
|
|
36
|
+
};
|
|
37
|
+
});
|
|
65
38
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
id: entryId
|
|
85
|
-
} = parseIdentifier(id);
|
|
86
|
-
return record.entryId === entryId;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
isRecordLocked(record) {
|
|
90
|
-
const result = this.records.find(r => {
|
|
91
|
-
const {
|
|
92
|
-
id: entryId
|
|
93
|
-
} = parseIdentifier(record.id);
|
|
94
|
-
return r.entryId === entryId && !!r.$locked && r.$lockingType === record.$lockingType;
|
|
95
|
-
});
|
|
96
|
-
if (!result?.$locked?.expiresOn) {
|
|
97
|
-
return false;
|
|
39
|
+
async fetchLockRecord(params) {
|
|
40
|
+
const { id, $lockingType } = params;
|
|
41
|
+
const { id: entryId } = parseIdentifier(id);
|
|
42
|
+
try {
|
|
43
|
+
const result = await this._getLockRecord.execute({
|
|
44
|
+
id: entryId,
|
|
45
|
+
type: $lockingType
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
data: result.data,
|
|
49
|
+
error: result.error
|
|
50
|
+
};
|
|
51
|
+
} catch (ex) {
|
|
52
|
+
return {
|
|
53
|
+
data: null,
|
|
54
|
+
error: ex
|
|
55
|
+
};
|
|
56
|
+
}
|
|
98
57
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
});
|
|
108
|
-
} catch (ex) {
|
|
109
|
-
this.triggerOnError(ex);
|
|
110
|
-
return {
|
|
111
|
-
data: null,
|
|
112
|
-
error: ex
|
|
113
|
-
};
|
|
58
|
+
async fetchLockedEntryLockRecord(params) {
|
|
59
|
+
const { id, $lockingType } = params;
|
|
60
|
+
const { id: entryId } = parseIdentifier(id);
|
|
61
|
+
const result = await this._getLockedEntryLockRecord.execute({
|
|
62
|
+
id: entryId,
|
|
63
|
+
type: $lockingType
|
|
64
|
+
});
|
|
65
|
+
return result.data;
|
|
114
66
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (index === -1) {
|
|
121
|
-
return;
|
|
67
|
+
getLockRecordEntry(id) {
|
|
68
|
+
return this.records.find((record)=>{
|
|
69
|
+
const { id: entryId } = parseIdentifier(id);
|
|
70
|
+
return record.entryId === entryId;
|
|
71
|
+
});
|
|
122
72
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const result = await this._unlockEntry.execute({
|
|
132
|
-
id: params.id,
|
|
133
|
-
type: params.$lockingType,
|
|
134
|
-
force
|
|
135
|
-
});
|
|
136
|
-
const id = result.data?.id;
|
|
137
|
-
if (!id) {
|
|
138
|
-
return result;
|
|
139
|
-
}
|
|
140
|
-
this.removeEntryLock({
|
|
141
|
-
...params
|
|
142
|
-
});
|
|
143
|
-
return result;
|
|
144
|
-
} catch (ex) {
|
|
145
|
-
this.triggerOnError(ex);
|
|
146
|
-
return {
|
|
147
|
-
data: null,
|
|
148
|
-
error: ex
|
|
149
|
-
};
|
|
73
|
+
isRecordLocked(record) {
|
|
74
|
+
const result = this.records.find((r)=>{
|
|
75
|
+
const { id: entryId } = parseIdentifier(record.id);
|
|
76
|
+
return r.entryId === entryId && !!r.$locked && r.$lockingType === record.$lockingType;
|
|
77
|
+
});
|
|
78
|
+
if (!result?.$locked?.expiresOn) return false;
|
|
79
|
+
const isExpired = this.isLockExpired(result.$locked.expiresOn);
|
|
80
|
+
return !isExpired;
|
|
150
81
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
82
|
+
async updateEntryLock(params) {
|
|
83
|
+
try {
|
|
84
|
+
return await this._updateEntryLock.execute({
|
|
85
|
+
id: params.id,
|
|
86
|
+
type: params.$lockingType
|
|
87
|
+
});
|
|
88
|
+
} catch (ex) {
|
|
89
|
+
this.triggerOnError(ex);
|
|
90
|
+
return {
|
|
91
|
+
data: null,
|
|
92
|
+
error: ex
|
|
93
|
+
};
|
|
94
|
+
}
|
|
159
95
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
this.loading = loading;
|
|
169
|
-
}
|
|
170
|
-
async fetchAndAssignRecords(folderId, type, records) {
|
|
171
|
-
if (records.length === 0) {
|
|
172
|
-
return;
|
|
173
|
-
} else if (this.loading) {
|
|
174
|
-
return;
|
|
96
|
+
removeEntryLock(params) {
|
|
97
|
+
const index = this.records.findIndex((record)=>record.entryId === params.id && record.$lockingType === params.$lockingType);
|
|
98
|
+
if (-1 === index) return;
|
|
99
|
+
this.records[index] = {
|
|
100
|
+
...this.records[index],
|
|
101
|
+
$locked: null,
|
|
102
|
+
$selectable: true
|
|
103
|
+
};
|
|
175
104
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
105
|
+
async unlockEntry(params, force) {
|
|
106
|
+
try {
|
|
107
|
+
const result = await this._unlockEntry.execute({
|
|
108
|
+
id: params.id,
|
|
109
|
+
type: params.$lockingType,
|
|
110
|
+
force
|
|
111
|
+
});
|
|
112
|
+
const id = result.data?.id;
|
|
113
|
+
if (!id) return result;
|
|
114
|
+
this.removeEntryLock({
|
|
115
|
+
...params
|
|
116
|
+
});
|
|
117
|
+
return result;
|
|
118
|
+
} catch (ex) {
|
|
119
|
+
this.triggerOnError(ex);
|
|
120
|
+
return {
|
|
121
|
+
data: null,
|
|
122
|
+
error: ex
|
|
123
|
+
};
|
|
124
|
+
}
|
|
179
125
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
try {
|
|
183
|
-
result = await this._listLockRecords.execute({
|
|
184
|
-
where: {
|
|
185
|
-
id_in: assignedIdList,
|
|
186
|
-
type
|
|
187
|
-
},
|
|
188
|
-
limit: 10000
|
|
189
|
-
});
|
|
190
|
-
} catch (ex) {
|
|
191
|
-
console.error(ex);
|
|
192
|
-
this.triggerOnError(ex);
|
|
193
|
-
return;
|
|
194
|
-
} finally {
|
|
195
|
-
this.setIsLoading(false);
|
|
126
|
+
onError(cb) {
|
|
127
|
+
this.onErrorCb = cb;
|
|
196
128
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
this.triggerOnError(createRecordLockingError({
|
|
202
|
-
message: `There is no data in the result and there is no error. Please check the network tab for more info.`,
|
|
203
|
-
code: "NO_DATA_IN_RESULT"
|
|
204
|
-
}));
|
|
205
|
-
return;
|
|
206
|
-
} else if (result.data.length === 0) {
|
|
207
|
-
return;
|
|
129
|
+
triggerOnError(error) {
|
|
130
|
+
this.setIsLoading(false);
|
|
131
|
+
if (!this.onErrorCb) return;
|
|
132
|
+
this.onErrorCb(error);
|
|
208
133
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
id: entryId
|
|
213
|
-
} = parseIdentifier(record.id);
|
|
214
|
-
return r.entryId === entryId;
|
|
215
|
-
});
|
|
216
|
-
if (index < 0) {
|
|
217
|
-
console.error(`There is no record with id ${record.id} in the records array.`);
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
this.records[index] = {
|
|
221
|
-
...this.records[index],
|
|
222
|
-
$locked: {
|
|
223
|
-
lockedBy: record.lockedBy,
|
|
224
|
-
expiresOn: record.expiresOn,
|
|
225
|
-
lockedOn: record.lockedOn,
|
|
226
|
-
actions: record.actions
|
|
227
|
-
}
|
|
228
|
-
};
|
|
134
|
+
isLockExpired(input) {
|
|
135
|
+
const expiresOn = new Date(input);
|
|
136
|
+
return expiresOn <= new Date();
|
|
229
137
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
* Assign records and return the assigned ID list.
|
|
234
|
-
*/
|
|
235
|
-
async assignRecords(folderId, type, records) {
|
|
236
|
-
/**
|
|
237
|
-
* First we check the record keys against ones in the local cache.
|
|
238
|
-
*/
|
|
239
|
-
const keys = records.map(record => {
|
|
240
|
-
if (record.entryId) {
|
|
241
|
-
return record.entryId;
|
|
242
|
-
}
|
|
243
|
-
const {
|
|
244
|
-
id: entryId
|
|
245
|
-
} = parseIdentifier(record.id);
|
|
246
|
-
return entryId;
|
|
247
|
-
});
|
|
248
|
-
const cacheKey = await createCacheKey(keys);
|
|
249
|
-
if (this.currentRecordsCacheKey === cacheKey) {
|
|
250
|
-
return [];
|
|
138
|
+
setIsLoading(loading) {
|
|
139
|
+
this._setLoading(loading);
|
|
140
|
+
this.loading = loading;
|
|
251
141
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
142
|
+
async fetchAndAssignRecords(folderId, type, records) {
|
|
143
|
+
if (0 === records.length) return;
|
|
144
|
+
if (this.loading) return;
|
|
145
|
+
const assignedIdList = await this.assignRecords(folderId, type, records);
|
|
146
|
+
if (0 === assignedIdList.length) return;
|
|
147
|
+
this.setIsLoading(true);
|
|
148
|
+
let result;
|
|
149
|
+
try {
|
|
150
|
+
result = await this._listLockRecords.execute({
|
|
151
|
+
where: {
|
|
152
|
+
id_in: assignedIdList,
|
|
153
|
+
type
|
|
154
|
+
},
|
|
155
|
+
limit: 10000
|
|
156
|
+
});
|
|
157
|
+
} catch (ex) {
|
|
158
|
+
console.error(ex);
|
|
159
|
+
this.triggerOnError(ex);
|
|
160
|
+
return;
|
|
161
|
+
} finally{
|
|
162
|
+
this.setIsLoading(false);
|
|
163
|
+
}
|
|
164
|
+
if (result.error) return void this.triggerOnError(result.error);
|
|
165
|
+
if (!result.data) return void this.triggerOnError(createRecordLockingError({
|
|
166
|
+
message: "There is no data in the result and there is no error. Please check the network tab for more info.",
|
|
167
|
+
code: "NO_DATA_IN_RESULT"
|
|
168
|
+
}));
|
|
169
|
+
if (0 === result.data.length) return;
|
|
170
|
+
for (const record of result.data){
|
|
171
|
+
const index = this.records.findIndex((r)=>{
|
|
172
|
+
const { id: entryId } = parseIdentifier(record.id);
|
|
173
|
+
return r.entryId === entryId;
|
|
174
|
+
});
|
|
175
|
+
if (index < 0) {
|
|
176
|
+
console.error(`There is no record with id ${record.id} in the records array.`);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
this.records[index] = {
|
|
180
|
+
...this.records[index],
|
|
181
|
+
$locked: {
|
|
182
|
+
lockedBy: record.lockedBy,
|
|
183
|
+
expiresOn: record.expiresOn,
|
|
184
|
+
lockedOn: record.lockedOn,
|
|
185
|
+
actions: record.actions
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
return this.records;
|
|
190
|
+
}
|
|
191
|
+
async assignRecords(folderId, type, records) {
|
|
192
|
+
const keys = records.map((record)=>{
|
|
193
|
+
if (record.entryId) return record.entryId;
|
|
194
|
+
const { id: entryId } = parseIdentifier(record.id);
|
|
195
|
+
return entryId;
|
|
196
|
+
});
|
|
197
|
+
const cacheKey = await createCacheKey(keys);
|
|
198
|
+
if (this.currentRecordsCacheKey === cacheKey) return [];
|
|
199
|
+
this.currentRecordsCacheKey = cacheKey;
|
|
200
|
+
if (this.currentRecordType !== type || this.currentFolderId !== folderId) {
|
|
201
|
+
this.records = [];
|
|
202
|
+
this.currentRecordType = type;
|
|
203
|
+
this.currentFolderId = folderId;
|
|
204
|
+
}
|
|
205
|
+
return records.reduce((collection, record)=>{
|
|
206
|
+
const { id: entryId } = parseIdentifier(record.id);
|
|
207
|
+
const index = this.records.findIndex((r)=>r.entryId === entryId);
|
|
208
|
+
if (index >= 0) return collection;
|
|
209
|
+
this.records.push({
|
|
210
|
+
...record,
|
|
211
|
+
entryId,
|
|
212
|
+
$lockingType: type,
|
|
213
|
+
$locked: void 0
|
|
214
|
+
});
|
|
215
|
+
if ("RECORD" !== record.$type) return collection;
|
|
216
|
+
collection.push(entryId);
|
|
217
|
+
return collection;
|
|
218
|
+
}, []);
|
|
261
219
|
}
|
|
262
|
-
return records.reduce((collection, record) => {
|
|
263
|
-
const {
|
|
264
|
-
id: entryId
|
|
265
|
-
} = parseIdentifier(record.id);
|
|
266
|
-
const index = this.records.findIndex(r => r.entryId === entryId);
|
|
267
|
-
if (index >= 0) {
|
|
268
|
-
return collection;
|
|
269
|
-
}
|
|
270
|
-
this.records.push({
|
|
271
|
-
...record,
|
|
272
|
-
entryId,
|
|
273
|
-
$lockingType: type,
|
|
274
|
-
$locked: undefined
|
|
275
|
-
});
|
|
276
|
-
if (record.$type !== "RECORD") {
|
|
277
|
-
return collection;
|
|
278
|
-
}
|
|
279
|
-
collection.push(entryId);
|
|
280
|
-
return collection;
|
|
281
|
-
}, []);
|
|
282
|
-
}
|
|
283
220
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
221
|
+
const createRecordLocking = (config)=>{
|
|
222
|
+
const client = new RecordLockingClient({
|
|
223
|
+
client: config.client
|
|
224
|
+
});
|
|
225
|
+
const getLockRecord = new RecordLockingGetLockRecord({
|
|
226
|
+
client
|
|
227
|
+
});
|
|
228
|
+
const getLockedEntryLockRecord = new RecordLockingGetLockedEntryLockRecord({
|
|
229
|
+
client
|
|
230
|
+
});
|
|
231
|
+
const isEntryLocked = new RecordLockingIsEntryLocked({
|
|
232
|
+
client
|
|
233
|
+
});
|
|
234
|
+
const listLockRecords = new RecordLockingListLockRecords({
|
|
235
|
+
client
|
|
236
|
+
});
|
|
237
|
+
const lockEntry = new RecordLockingLockEntry({
|
|
238
|
+
client
|
|
239
|
+
});
|
|
240
|
+
const unlockEntry = new RecordLockingUnlockEntry({
|
|
241
|
+
client
|
|
242
|
+
});
|
|
243
|
+
const updateEntryLock = new RecordLockingUpdateEntryLock({
|
|
244
|
+
client
|
|
245
|
+
});
|
|
246
|
+
return new RecordLocking({
|
|
247
|
+
setLoading: config.setLoading,
|
|
248
|
+
getLockRecord,
|
|
249
|
+
getLockedEntryLockRecord,
|
|
250
|
+
isEntryLocked,
|
|
251
|
+
listLockRecords,
|
|
252
|
+
updateEntryLock,
|
|
253
|
+
lockEntry,
|
|
254
|
+
unlockEntry
|
|
255
|
+
});
|
|
319
256
|
};
|
|
257
|
+
export { createRecordLocking };
|
|
320
258
|
|
|
321
259
|
//# sourceMappingURL=RecordLocking.js.map
|
|
@@ -1 +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","$type","$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","createRecordLocking","config","client","isEntryLocked","lockEntry"],"sources":["RecordLocking.ts"],"sourcesContent":["import type {\n IRecordLocking,\n IRecordLockingUpdateEntryLockResult\n} from \"./abstractions/IRecordLocking.js\";\nimport type { ApolloClient } from \"apollo-client\";\nimport { RecordLockingGetLockRecord } from \"./RecordLockingGetLockRecord.js\";\nimport { RecordLockingIsEntryLocked } from \"./RecordLockingIsEntryLocked.js\";\nimport { RecordLockingListLockRecords } from \"./RecordLockingListLockRecords.js\";\nimport { RecordLockingLockEntry } from \"./RecordLockingLockEntry.js\";\nimport { RecordLockingUnlockEntry } from \"./RecordLockingUnlockEntry.js\";\nimport { RecordLockingClient } from \"./RecordLockingClient.js\";\nimport type { IRecordLockingGetLockRecord } from \"./abstractions/IRecordLockingGetLockRecord.js\";\nimport type { IRecordLockingIsEntryLocked } from \"./abstractions/IRecordLockingIsEntryLocked.js\";\nimport type {\n IRecordLockingListLockRecords,\n IRecordLockingListLockRecordsResult\n} from \"./abstractions/IRecordLockingListLockRecords.js\";\nimport type { IRecordLockingLockEntry } from \"./abstractions/IRecordLockingLockEntry.js\";\nimport type {\n IRecordLockingUnlockEntry,\n IRecordLockingUnlockEntryResult\n} from \"./abstractions/IRecordLockingUnlockEntry.js\";\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.js\";\nimport { createRecordLockingError } from \"./utils/createRecordLockingError.js\";\nimport { parseIdentifier } from \"@webiny/utils/parseIdentifier.js\";\nimport { createCacheKey } from \"~/utils/createCacheKey.js\";\nimport { RecordLockingUpdateEntryLock } from \"~/domain/RecordLockingUpdateEntryLock.js\";\nimport type { IRecordLockingUpdateEntryLock } from \"~/domain/abstractions/IRecordLockingUpdateEntryLock.js\";\nimport { RecordLockingGetLockedEntryLockRecord } from \"~/domain/RecordLockingGetLockedEntryLockRecord.js\";\nimport type { IRecordLockingGetLockedEntryLockRecord } from \"./abstractions/IRecordLockingGetLockedEntryLockRecord.js\";\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<\n T extends IPossiblyRecordLockingRecord = IPossiblyRecordLockingRecord\n> implements IRecordLocking<T> {\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 $type: \"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,kCAAkC;AAClE,SAASC,cAAc;AACvB,SAASC,4BAA4B;AAErC,SAASC,qCAAqC;AAuB9C,MAAMC,aAAa,CAEY;EAKpBC,OAAO,GAAG,KAAK;EACfC,OAAO,GAA2B,EAAE;EAOnCC,SAAS,GAAsB,IAAI;EAEpCC,WAAWA,CAACC,MAA4B,EAAE;IAC7C,IAAI,CAACC,WAAW,GAAGD,MAAM,CAACE,UAAU;IACpC,IAAI,CAACC,cAAc,GAAGH,MAAM,CAACI,aAAa;IAC1C,IAAI,CAACC,yBAAyB,GAAGL,MAAM,CAACM,wBAAwB;IAChE,IAAI,CAACC,gBAAgB,GAAGP,MAAM,CAACQ,eAAe;IAC9C,IAAI,CAACC,YAAY,GAAGT,MAAM,CAACU,WAAW;IACtC,IAAI,CAACC,gBAAgB,GAAGX,MAAM,CAACY,eAAe;EAClD;EAEA,MAAaC,UAAUA,CACnBC,QAAg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;MACF,IAAIE,MAAM,CAACG,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO6C,UAAU;MACrB;MACAA,UAAU,CAACC,IAAI,CAAC/C,OAAO,CAAC;MACxB,OAAO8C,UAAU;IACrB,CAAC,EAAE,EAAE,CAAC;EACV;AACJ;AAEA,OAAO,MAAME,mBAAmB,GAC5BC,MAAkC,IACjB;EACjB,MAAMC,MAAM,GAAG,IAAInF,mBAAmB,CAAC;IACnCmF,MAAM,EAAED,MAAM,CAACC;EACnB,CAAC,CAAC;EAEF,MAAMpE,aAAa,GAAG,IAAIpB,0BAA0B,CAAC;IACjDwF;EACJ,CAAC,CAAC;EAEF,MAAMlE,wBAAwB,GAAG,IAAIZ,qCAAqC,CAAC;IACvE8E;EACJ,CAAC,CAAC;EAEF,MAAMC,aAAa,GAAG,IAAIxF,0BAA0B,CAAC;IACjDuF;EACJ,CAAC,CAAC;EAEF,MAAMhE,eAAe,GAAG,IAAItB,4BAA4B,CAAC;IACrDsF;EACJ,CAAC,CAAC;EAEF,MAAME,SAAS,GAAG,IAAIvF,sBAAsB,CAAC;IACzCqF;EACJ,CAAC,CAAC;EAEF,MAAM9D,WAAW,GAAG,IAAItB,wBAAwB,CAAC;IAC7CoF;EACJ,CAAC,CAAC;EAEF,MAAM5D,eAAe,GAAG,IAAInB,4BAA4B,CAAC;IACrD+E;EACJ,CAAC,CAAC;EAEF,OAAO,IAAI7E,aAAa,CAAI;IACxBO,UAAU,EAAEqE,MAAM,CAACrE,UAAU;IAC7BE,aAAa;IACbE,wBAAwB;IACxBmE,aAAa;IACbjE,eAAe;IACfI,eAAe;IACf8D,SAAS;IACThE;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"domain/RecordLocking.js","sources":["../../src/domain/RecordLocking.ts"],"sourcesContent":["import type {\n IRecordLocking,\n IRecordLockingUpdateEntryLockResult\n} from \"./abstractions/IRecordLocking.js\";\nimport type { ApolloClient } from \"apollo-client\";\nimport { RecordLockingGetLockRecord } from \"./RecordLockingGetLockRecord.js\";\nimport { RecordLockingIsEntryLocked } from \"./RecordLockingIsEntryLocked.js\";\nimport { RecordLockingListLockRecords } from \"./RecordLockingListLockRecords.js\";\nimport { RecordLockingLockEntry } from \"./RecordLockingLockEntry.js\";\nimport { RecordLockingUnlockEntry } from \"./RecordLockingUnlockEntry.js\";\nimport { RecordLockingClient } from \"./RecordLockingClient.js\";\nimport type { IRecordLockingGetLockRecord } from \"./abstractions/IRecordLockingGetLockRecord.js\";\nimport type { IRecordLockingIsEntryLocked } from \"./abstractions/IRecordLockingIsEntryLocked.js\";\nimport type {\n IRecordLockingListLockRecords,\n IRecordLockingListLockRecordsResult\n} from \"./abstractions/IRecordLockingListLockRecords.js\";\nimport type { IRecordLockingLockEntry } from \"./abstractions/IRecordLockingLockEntry.js\";\nimport type {\n IRecordLockingUnlockEntry,\n IRecordLockingUnlockEntryResult\n} from \"./abstractions/IRecordLockingUnlockEntry.js\";\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.js\";\nimport { createRecordLockingError } from \"./utils/createRecordLockingError.js\";\nimport { parseIdentifier } from \"@webiny/utils/parseIdentifier.js\";\nimport { createCacheKey } from \"~/utils/createCacheKey.js\";\nimport { RecordLockingUpdateEntryLock } from \"~/domain/RecordLockingUpdateEntryLock.js\";\nimport type { IRecordLockingUpdateEntryLock } from \"~/domain/abstractions/IRecordLockingUpdateEntryLock.js\";\nimport { RecordLockingGetLockedEntryLockRecord } from \"~/domain/RecordLockingGetLockedEntryLockRecord.js\";\nimport type { IRecordLockingGetLockedEntryLockRecord } from \"./abstractions/IRecordLockingGetLockedEntryLockRecord.js\";\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<\n T extends IPossiblyRecordLockingRecord = IPossiblyRecordLockingRecord\n> implements IRecordLocking<T> {\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 $type: \"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"],"names":["RecordLocking","params","folderId","type","records","result","record","entryId","parseIdentifier","id","$lockingType","ex","r","isExpired","index","force","cb","error","input","expiresOn","Date","loading","assignedIdList","console","createRecordLockingError","keys","cacheKey","createCacheKey","collection","undefined","createRecordLocking","config","client","RecordLockingClient","getLockRecord","RecordLockingGetLockRecord","getLockedEntryLockRecord","RecordLockingGetLockedEntryLockRecord","isEntryLocked","RecordLockingIsEntryLocked","listLockRecords","RecordLockingListLockRecords","lockEntry","RecordLockingLockEntry","unlockEntry","RecordLockingUnlockEntry","updateEntryLock","RecordLockingUpdateEntryLock"],"mappings":";;;;;;;;;;;AA8DA,MAAMA;IAiBF,YAAmBC,MAA4B,CAAE;aAV1C,OAAO,GAAG;aACV,OAAO,GAA2B,EAAE;aAOnC,SAAS,GAAsB;QAGnC,IAAI,CAAC,WAAW,GAAGA,OAAO,UAAU;QACpC,IAAI,CAAC,cAAc,GAAGA,OAAO,aAAa;QAC1C,IAAI,CAAC,yBAAyB,GAAGA,OAAO,wBAAwB;QAChE,IAAI,CAAC,gBAAgB,GAAGA,OAAO,eAAe;QAC9C,IAAI,CAAC,YAAY,GAAGA,OAAO,WAAW;QACtC,IAAI,CAAC,gBAAgB,GAAGA,OAAO,eAAe;IAClD;IAEA,MAAa,WACTC,QAAgB,EAChBC,IAAY,EACZC,OAAY,EAC+B;QAC3C,MAAMC,SAAS,MAAM,IAAI,CAAC,qBAAqB,CAACH,UAAUC,MAAMC;QAChE,IAAI,CAACC,QACD;QAGJ,OAAOA,OAAO,GAAG,CAACC,CAAAA;YACd,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF,OAAO,EAAE;YACjD,OAAO;gBACH,GAAGA,MAAM;gBACT,OAAO;gBACP,cAAcH;gBACd,SAASG,OAAO,OAAO;gBACvB,aAAaA,OAAO,OAAO,GAAG,QAAQA,OAAO,WAAW;gBACxDC;YACJ;QACJ;IACJ;IAEA,MAAa,gBAAgBN,MAA8B,EAAmC;QAC1F,MAAM,EAAEQ,EAAE,EAAEC,YAAY,EAAE,GAAGT;QAE7B,MAAM,EAAE,IAAIM,OAAO,EAAE,GAAGC,gBAAgBC;QAExC,IAAI;YACA,MAAMJ,SAAS,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBA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