decap-cms-lib-util 2.16.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/CHANGELOG.md +601 -0
- package/LICENSE +22 -0
- package/README.md +22 -0
- package/dist/decap-cms-lib-util.js +3 -0
- package/dist/decap-cms-lib-util.js.LICENSE.txt +15 -0
- package/dist/decap-cms-lib-util.js.map +1 -0
- package/dist/esm/API.js +177 -0
- package/dist/esm/APIError.js +47 -0
- package/dist/esm/APIUtils.js +48 -0
- package/dist/esm/AccessTokenError.js +41 -0
- package/dist/esm/Cursor.js +135 -0
- package/dist/esm/EditorialWorkflowError.js +43 -0
- package/dist/esm/asyncLock.js +45 -0
- package/dist/esm/backendUtil.js +98 -0
- package/dist/esm/getBlobSHA.js +19 -0
- package/dist/esm/git-lfs.js +123 -0
- package/dist/esm/implementation.js +304 -0
- package/dist/esm/index.js +403 -0
- package/dist/esm/loadScript.js +27 -0
- package/dist/esm/localForage.js +25 -0
- package/dist/esm/path.js +93 -0
- package/dist/esm/promise.js +23 -0
- package/dist/esm/types/semaphore.d.js +1 -0
- package/dist/esm/unsentRequest.js +123 -0
- package/package.json +29 -0
- package/src/API.ts +220 -0
- package/src/APIError.ts +17 -0
- package/src/APIUtils.ts +38 -0
- package/src/AccessTokenError.ts +11 -0
- package/src/Cursor.ts +178 -0
- package/src/EditorialWorkflowError.ts +12 -0
- package/src/__tests__/api.spec.js +12 -0
- package/src/__tests__/apiUtils.spec.js +74 -0
- package/src/__tests__/asyncLock.spec.js +85 -0
- package/src/__tests__/backendUtil.spec.js +97 -0
- package/src/__tests__/implementation.spec.js +58 -0
- package/src/__tests__/path.spec.js +53 -0
- package/src/__tests__/unsentRequest.spec.js +19 -0
- package/src/asyncLock.ts +43 -0
- package/src/backendUtil.ts +120 -0
- package/src/getBlobSHA.ts +12 -0
- package/src/git-lfs.ts +133 -0
- package/src/implementation.ts +573 -0
- package/src/index.ts +210 -0
- package/src/loadScript.js +24 -0
- package/src/localForage.ts +21 -0
- package/src/path.ts +86 -0
- package/src/promise.ts +21 -0
- package/src/types/semaphore.d.ts +5 -0
- package/src/unsentRequest.js +133 -0
- package/webpack.config.js +3 -0
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "APIError", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _APIError.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "AccessTokenError", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _AccessTokenError.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "CMS_BRANCH_PREFIX", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _APIUtils.CMS_BRANCH_PREFIX;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "CURSOR_COMPATIBILITY_SYMBOL", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _Cursor.CURSOR_COMPATIBILITY_SYMBOL;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "Cursor", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _Cursor.default;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "DEFAULT_PR_BODY", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _APIUtils.DEFAULT_PR_BODY;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
exports.DecapCmsLibUtil = void 0;
|
|
43
|
+
Object.defineProperty(exports, "EDITORIAL_WORKFLOW_ERROR", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _EditorialWorkflowError.EDITORIAL_WORKFLOW_ERROR;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(exports, "EditorialWorkflowError", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () {
|
|
52
|
+
return _EditorialWorkflowError.default;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, "MERGE_COMMIT_MESSAGE", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return _APIUtils.MERGE_COMMIT_MESSAGE;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(exports, "PreviewState", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () {
|
|
64
|
+
return _API.PreviewState;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, "allEntriesByFolder", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () {
|
|
70
|
+
return _implementation.allEntriesByFolder;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, "asyncLock", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () {
|
|
76
|
+
return _asyncLock.asyncLock;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(exports, "basename", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () {
|
|
82
|
+
return _path.basename;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(exports, "blobToFileObj", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function () {
|
|
88
|
+
return _implementation.blobToFileObj;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(exports, "branchFromContentKey", {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function () {
|
|
94
|
+
return _APIUtils.branchFromContentKey;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(exports, "contentKeyFromBranch", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function () {
|
|
100
|
+
return _APIUtils.contentKeyFromBranch;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(exports, "createPointerFile", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function () {
|
|
106
|
+
return _gitLfs.createPointerFile;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(exports, "entriesByFiles", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _implementation.entriesByFiles;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(exports, "entriesByFolder", {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function () {
|
|
118
|
+
return _implementation.entriesByFolder;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
Object.defineProperty(exports, "fileExtension", {
|
|
122
|
+
enumerable: true,
|
|
123
|
+
get: function () {
|
|
124
|
+
return _path.fileExtension;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
Object.defineProperty(exports, "fileExtensionWithSeparator", {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
get: function () {
|
|
130
|
+
return _path.fileExtensionWithSeparator;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(exports, "filterByExtension", {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
get: function () {
|
|
136
|
+
return _backendUtil.filterByExtension;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(exports, "flowAsync", {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
get: function () {
|
|
142
|
+
return _promise.flowAsync;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
Object.defineProperty(exports, "generateContentKey", {
|
|
146
|
+
enumerable: true,
|
|
147
|
+
get: function () {
|
|
148
|
+
return _APIUtils.generateContentKey;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
Object.defineProperty(exports, "getAllResponses", {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
get: function () {
|
|
154
|
+
return _backendUtil.getAllResponses;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
Object.defineProperty(exports, "getBlobSHA", {
|
|
158
|
+
enumerable: true,
|
|
159
|
+
get: function () {
|
|
160
|
+
return _getBlobSHA.default;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
Object.defineProperty(exports, "getLargeMediaFilteredMediaFiles", {
|
|
164
|
+
enumerable: true,
|
|
165
|
+
get: function () {
|
|
166
|
+
return _gitLfs.getLargeMediaFilteredMediaFiles;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
Object.defineProperty(exports, "getLargeMediaPatternsFromGitAttributesFile", {
|
|
170
|
+
enumerable: true,
|
|
171
|
+
get: function () {
|
|
172
|
+
return _gitLfs.getLargeMediaPatternsFromGitAttributesFile;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
Object.defineProperty(exports, "getMediaAsBlob", {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: function () {
|
|
178
|
+
return _implementation.getMediaAsBlob;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
Object.defineProperty(exports, "getMediaDisplayURL", {
|
|
182
|
+
enumerable: true,
|
|
183
|
+
get: function () {
|
|
184
|
+
return _implementation.getMediaDisplayURL;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
Object.defineProperty(exports, "getPathDepth", {
|
|
188
|
+
enumerable: true,
|
|
189
|
+
get: function () {
|
|
190
|
+
return _backendUtil.getPathDepth;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
Object.defineProperty(exports, "getPointerFileForMediaFileObj", {
|
|
194
|
+
enumerable: true,
|
|
195
|
+
get: function () {
|
|
196
|
+
return _gitLfs.getPointerFileForMediaFileObj;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
Object.defineProperty(exports, "getPreviewStatus", {
|
|
200
|
+
enumerable: true,
|
|
201
|
+
get: function () {
|
|
202
|
+
return _API.getPreviewStatus;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
Object.defineProperty(exports, "isAbsolutePath", {
|
|
206
|
+
enumerable: true,
|
|
207
|
+
get: function () {
|
|
208
|
+
return _path.isAbsolutePath;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
Object.defineProperty(exports, "isCMSLabel", {
|
|
212
|
+
enumerable: true,
|
|
213
|
+
get: function () {
|
|
214
|
+
return _APIUtils.isCMSLabel;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
Object.defineProperty(exports, "isPreviewContext", {
|
|
218
|
+
enumerable: true,
|
|
219
|
+
get: function () {
|
|
220
|
+
return _API.isPreviewContext;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
Object.defineProperty(exports, "labelToStatus", {
|
|
224
|
+
enumerable: true,
|
|
225
|
+
get: function () {
|
|
226
|
+
return _APIUtils.labelToStatus;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
Object.defineProperty(exports, "loadScript", {
|
|
230
|
+
enumerable: true,
|
|
231
|
+
get: function () {
|
|
232
|
+
return _loadScript.default;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
Object.defineProperty(exports, "localForage", {
|
|
236
|
+
enumerable: true,
|
|
237
|
+
get: function () {
|
|
238
|
+
return _localForage.default;
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
Object.defineProperty(exports, "onlySuccessfulPromises", {
|
|
242
|
+
enumerable: true,
|
|
243
|
+
get: function () {
|
|
244
|
+
return _promise.onlySuccessfulPromises;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
Object.defineProperty(exports, "parseContentKey", {
|
|
248
|
+
enumerable: true,
|
|
249
|
+
get: function () {
|
|
250
|
+
return _APIUtils.parseContentKey;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
Object.defineProperty(exports, "parseLinkHeader", {
|
|
254
|
+
enumerable: true,
|
|
255
|
+
get: function () {
|
|
256
|
+
return _backendUtil.parseLinkHeader;
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
Object.defineProperty(exports, "parsePointerFile", {
|
|
260
|
+
enumerable: true,
|
|
261
|
+
get: function () {
|
|
262
|
+
return _gitLfs.parsePointerFile;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
Object.defineProperty(exports, "parseResponse", {
|
|
266
|
+
enumerable: true,
|
|
267
|
+
get: function () {
|
|
268
|
+
return _backendUtil.parseResponse;
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
Object.defineProperty(exports, "readFile", {
|
|
272
|
+
enumerable: true,
|
|
273
|
+
get: function () {
|
|
274
|
+
return _API.readFile;
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
Object.defineProperty(exports, "readFileMetadata", {
|
|
278
|
+
enumerable: true,
|
|
279
|
+
get: function () {
|
|
280
|
+
return _API.readFileMetadata;
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
Object.defineProperty(exports, "requestWithBackoff", {
|
|
284
|
+
enumerable: true,
|
|
285
|
+
get: function () {
|
|
286
|
+
return _API.requestWithBackoff;
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
Object.defineProperty(exports, "responseParser", {
|
|
290
|
+
enumerable: true,
|
|
291
|
+
get: function () {
|
|
292
|
+
return _backendUtil.responseParser;
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
Object.defineProperty(exports, "runWithLock", {
|
|
296
|
+
enumerable: true,
|
|
297
|
+
get: function () {
|
|
298
|
+
return _implementation.runWithLock;
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
Object.defineProperty(exports, "statusToLabel", {
|
|
302
|
+
enumerable: true,
|
|
303
|
+
get: function () {
|
|
304
|
+
return _APIUtils.statusToLabel;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
Object.defineProperty(exports, "then", {
|
|
308
|
+
enumerable: true,
|
|
309
|
+
get: function () {
|
|
310
|
+
return _promise.then;
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
Object.defineProperty(exports, "throwOnConflictingBranches", {
|
|
314
|
+
enumerable: true,
|
|
315
|
+
get: function () {
|
|
316
|
+
return _API.throwOnConflictingBranches;
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
Object.defineProperty(exports, "unpublishedEntries", {
|
|
320
|
+
enumerable: true,
|
|
321
|
+
get: function () {
|
|
322
|
+
return _implementation.unpublishedEntries;
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
Object.defineProperty(exports, "unsentRequest", {
|
|
326
|
+
enumerable: true,
|
|
327
|
+
get: function () {
|
|
328
|
+
return _unsentRequest.default;
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
var _APIError = _interopRequireDefault(require("./APIError"));
|
|
332
|
+
var _Cursor = _interopRequireWildcard(require("./Cursor"));
|
|
333
|
+
var _EditorialWorkflowError = _interopRequireWildcard(require("./EditorialWorkflowError"));
|
|
334
|
+
var _AccessTokenError = _interopRequireDefault(require("./AccessTokenError"));
|
|
335
|
+
var _localForage = _interopRequireDefault(require("./localForage"));
|
|
336
|
+
var _path = require("./path");
|
|
337
|
+
var _promise = require("./promise");
|
|
338
|
+
var _unsentRequest = _interopRequireDefault(require("./unsentRequest"));
|
|
339
|
+
var _backendUtil = require("./backendUtil");
|
|
340
|
+
var _loadScript = _interopRequireDefault(require("./loadScript"));
|
|
341
|
+
var _getBlobSHA = _interopRequireDefault(require("./getBlobSHA"));
|
|
342
|
+
var _asyncLock = require("./asyncLock");
|
|
343
|
+
var _implementation = require("./implementation");
|
|
344
|
+
var _API = require("./API");
|
|
345
|
+
var _APIUtils = require("./APIUtils");
|
|
346
|
+
var _gitLfs = require("./git-lfs");
|
|
347
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
348
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
349
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
350
|
+
const DecapCmsLibUtil = {
|
|
351
|
+
APIError: _APIError.default,
|
|
352
|
+
Cursor: _Cursor.default,
|
|
353
|
+
CURSOR_COMPATIBILITY_SYMBOL: _Cursor.CURSOR_COMPATIBILITY_SYMBOL,
|
|
354
|
+
EditorialWorkflowError: _EditorialWorkflowError.default,
|
|
355
|
+
EDITORIAL_WORKFLOW_ERROR: _EditorialWorkflowError.EDITORIAL_WORKFLOW_ERROR,
|
|
356
|
+
localForage: _localForage.default,
|
|
357
|
+
basename: _path.basename,
|
|
358
|
+
fileExtensionWithSeparator: _path.fileExtensionWithSeparator,
|
|
359
|
+
fileExtension: _path.fileExtension,
|
|
360
|
+
onlySuccessfulPromises: _promise.onlySuccessfulPromises,
|
|
361
|
+
flowAsync: _promise.flowAsync,
|
|
362
|
+
then: _promise.then,
|
|
363
|
+
unsentRequest: _unsentRequest.default,
|
|
364
|
+
filterByExtension: _backendUtil.filterByExtension,
|
|
365
|
+
parseLinkHeader: _backendUtil.parseLinkHeader,
|
|
366
|
+
parseResponse: _backendUtil.parseResponse,
|
|
367
|
+
responseParser: _backendUtil.responseParser,
|
|
368
|
+
loadScript: _loadScript.default,
|
|
369
|
+
getBlobSHA: _getBlobSHA.default,
|
|
370
|
+
getPathDepth: _backendUtil.getPathDepth,
|
|
371
|
+
entriesByFiles: _implementation.entriesByFiles,
|
|
372
|
+
entriesByFolder: _implementation.entriesByFolder,
|
|
373
|
+
unpublishedEntries: _implementation.unpublishedEntries,
|
|
374
|
+
getMediaDisplayURL: _implementation.getMediaDisplayURL,
|
|
375
|
+
getMediaAsBlob: _implementation.getMediaAsBlob,
|
|
376
|
+
readFile: _API.readFile,
|
|
377
|
+
readFileMetadata: _API.readFileMetadata,
|
|
378
|
+
CMS_BRANCH_PREFIX: _APIUtils.CMS_BRANCH_PREFIX,
|
|
379
|
+
generateContentKey: _APIUtils.generateContentKey,
|
|
380
|
+
isCMSLabel: _APIUtils.isCMSLabel,
|
|
381
|
+
labelToStatus: _APIUtils.labelToStatus,
|
|
382
|
+
statusToLabel: _APIUtils.statusToLabel,
|
|
383
|
+
DEFAULT_PR_BODY: _APIUtils.DEFAULT_PR_BODY,
|
|
384
|
+
MERGE_COMMIT_MESSAGE: _APIUtils.MERGE_COMMIT_MESSAGE,
|
|
385
|
+
isPreviewContext: _API.isPreviewContext,
|
|
386
|
+
getPreviewStatus: _API.getPreviewStatus,
|
|
387
|
+
runWithLock: _implementation.runWithLock,
|
|
388
|
+
PreviewState: _API.PreviewState,
|
|
389
|
+
parseContentKey: _APIUtils.parseContentKey,
|
|
390
|
+
createPointerFile: _gitLfs.createPointerFile,
|
|
391
|
+
getLargeMediaFilteredMediaFiles: _gitLfs.getLargeMediaFilteredMediaFiles,
|
|
392
|
+
getLargeMediaPatternsFromGitAttributesFile: _gitLfs.getLargeMediaPatternsFromGitAttributesFile,
|
|
393
|
+
parsePointerFile: _gitLfs.parsePointerFile,
|
|
394
|
+
getPointerFileForMediaFileObj: _gitLfs.getPointerFileForMediaFileObj,
|
|
395
|
+
branchFromContentKey: _APIUtils.branchFromContentKey,
|
|
396
|
+
contentKeyFromBranch: _APIUtils.contentKeyFromBranch,
|
|
397
|
+
blobToFileObj: _implementation.blobToFileObj,
|
|
398
|
+
requestWithBackoff: _API.requestWithBackoff,
|
|
399
|
+
allEntriesByFolder: _implementation.allEntriesByFolder,
|
|
400
|
+
AccessTokenError: _AccessTokenError.default,
|
|
401
|
+
throwOnConflictingBranches: _API.throwOnConflictingBranches
|
|
402
|
+
};
|
|
403
|
+
exports.DecapCmsLibUtil = DecapCmsLibUtil;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = loadScript;
|
|
7
|
+
/**
|
|
8
|
+
* Simple script loader that returns a promise.
|
|
9
|
+
*/
|
|
10
|
+
function loadScript(url) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
let done = false;
|
|
13
|
+
const head = document.getElementsByTagName('head')[0];
|
|
14
|
+
const script = document.createElement('script');
|
|
15
|
+
script.src = url;
|
|
16
|
+
script.onload = script.onreadystatechange = function () {
|
|
17
|
+
if (!done && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) {
|
|
18
|
+
done = true;
|
|
19
|
+
resolve();
|
|
20
|
+
} else {
|
|
21
|
+
reject();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
script.onerror = error => reject(error);
|
|
25
|
+
head.appendChild(script);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _localforage = _interopRequireDefault(require("localforage"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
function localForageTest() {
|
|
10
|
+
const testKey = 'localForageTest';
|
|
11
|
+
_localforage.default.setItem(testKey, {
|
|
12
|
+
expires: Date.now() + 300000
|
|
13
|
+
}).then(() => {
|
|
14
|
+
_localforage.default.removeItem(testKey);
|
|
15
|
+
}).catch(err => {
|
|
16
|
+
if (err.code === 22) {
|
|
17
|
+
const message = 'Unable to set localStorage key. Quota exceeded! Full disk?';
|
|
18
|
+
console.warn(message);
|
|
19
|
+
}
|
|
20
|
+
console.log(err);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
localForageTest();
|
|
24
|
+
var _default = _localforage.default;
|
|
25
|
+
exports.default = _default;
|
package/dist/esm/path.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.basename = basename;
|
|
7
|
+
exports.fileExtension = fileExtension;
|
|
8
|
+
exports.fileExtensionWithSeparator = fileExtensionWithSeparator;
|
|
9
|
+
exports.isAbsolutePath = isAbsolutePath;
|
|
10
|
+
const absolutePath = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
11
|
+
function normalizePath(path) {
|
|
12
|
+
return path.replace(/[\\/]+/g, '/');
|
|
13
|
+
}
|
|
14
|
+
function isAbsolutePath(path) {
|
|
15
|
+
return absolutePath.test(path);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Return the last portion of a path. Similar to the Unix basename command.
|
|
20
|
+
* @example Usage example
|
|
21
|
+
* path.basename('/foo/bar/baz/asdf/quux.html')
|
|
22
|
+
* // returns
|
|
23
|
+
* 'quux.html'
|
|
24
|
+
*
|
|
25
|
+
* path.basename('/foo/bar/baz/asdf/quux.html', '.html')
|
|
26
|
+
* // returns
|
|
27
|
+
* 'quux'
|
|
28
|
+
*/
|
|
29
|
+
function basename(p, ext = '') {
|
|
30
|
+
// Special case: Normalize will modify this to '.'
|
|
31
|
+
if (p === '') {
|
|
32
|
+
return p;
|
|
33
|
+
}
|
|
34
|
+
// Normalize the string first to remove any weirdness.
|
|
35
|
+
p = normalizePath(p);
|
|
36
|
+
// Get the last part of the string.
|
|
37
|
+
const sections = p.split('/');
|
|
38
|
+
const lastPart = sections[sections.length - 1];
|
|
39
|
+
// Special case: If it's empty, then we have a string like so: foo/
|
|
40
|
+
// Meaning, 'foo' is guaranteed to be a directory.
|
|
41
|
+
if (lastPart === '' && sections.length > 1) {
|
|
42
|
+
return sections[sections.length - 2];
|
|
43
|
+
}
|
|
44
|
+
// Remove the extension, if need be.
|
|
45
|
+
if (ext.length > 0) {
|
|
46
|
+
const lastPartExt = lastPart.slice(-ext.length);
|
|
47
|
+
if (lastPartExt === ext) {
|
|
48
|
+
return lastPart.slice(0, -ext.length);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return lastPart;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Return the extension of the path, from the last '.' to end of string in the
|
|
56
|
+
* last portion of the path. If there is no '.' in the last portion of the path
|
|
57
|
+
* or the first character of it is '.', then it returns an empty string.
|
|
58
|
+
* @example Usage example
|
|
59
|
+
* path.fileExtensionWithSeparator('index.html')
|
|
60
|
+
* // returns
|
|
61
|
+
* '.html'
|
|
62
|
+
*/
|
|
63
|
+
function fileExtensionWithSeparator(p) {
|
|
64
|
+
p = normalizePath(p);
|
|
65
|
+
const sections = p.split('/');
|
|
66
|
+
p = sections.pop();
|
|
67
|
+
// Special case: foo/file.ext/ should return '.ext'
|
|
68
|
+
if (p === '' && sections.length > 0) {
|
|
69
|
+
p = sections.pop();
|
|
70
|
+
}
|
|
71
|
+
if (p === '..') {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
const i = p.lastIndexOf('.');
|
|
75
|
+
if (i === -1 || i === 0) {
|
|
76
|
+
return '';
|
|
77
|
+
}
|
|
78
|
+
return p.slice(i);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Return the extension of the path, from after the last '.' to end of string in the
|
|
83
|
+
* last portion of the path. If there is no '.' in the last portion of the path
|
|
84
|
+
* or the first character of it is '.', then it returns an empty string.
|
|
85
|
+
* @example Usage example
|
|
86
|
+
* path.fileExtension('index.html')
|
|
87
|
+
* // returns
|
|
88
|
+
* 'html'
|
|
89
|
+
*/
|
|
90
|
+
function fileExtension(p) {
|
|
91
|
+
const ext = fileExtensionWithSeparator(p);
|
|
92
|
+
return ext === '' ? ext : ext.slice(1);
|
|
93
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.flowAsync = flowAsync;
|
|
7
|
+
exports.onlySuccessfulPromises = onlySuccessfulPromises;
|
|
8
|
+
exports.then = then;
|
|
9
|
+
var _flow = _interopRequireDefault(require("lodash/flow"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function then(fn) {
|
|
12
|
+
return p => Promise.resolve(p).then(fn);
|
|
13
|
+
}
|
|
14
|
+
const filterPromiseSymbol = Symbol('filterPromiseSymbol');
|
|
15
|
+
function onlySuccessfulPromises(promises) {
|
|
16
|
+
return Promise.all(promises.map(p => p.catch(() => filterPromiseSymbol))).then(results => results.filter(result => result !== filterPromiseSymbol));
|
|
17
|
+
}
|
|
18
|
+
function wrapFlowAsync(fn) {
|
|
19
|
+
return async arg => fn(await arg);
|
|
20
|
+
}
|
|
21
|
+
function flowAsync(fns) {
|
|
22
|
+
return (0, _flow.default)(fns.map(fn => wrapFlowAsync(fn)));
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _immutable = require("immutable");
|
|
8
|
+
var _curry = _interopRequireDefault(require("lodash/curry"));
|
|
9
|
+
var _flow = _interopRequireDefault(require("lodash/flow"));
|
|
10
|
+
var _isString = _interopRequireDefault(require("lodash/isString"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
16
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
17
|
+
function isAbortControllerSupported() {
|
|
18
|
+
if (typeof window !== 'undefined') {
|
|
19
|
+
return !!window.AbortController;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const timeout = 60;
|
|
24
|
+
function fetchWithTimeout(input, init) {
|
|
25
|
+
if (init && init.signal || !isAbortControllerSupported()) {
|
|
26
|
+
return fetch(input, init);
|
|
27
|
+
}
|
|
28
|
+
const controller = new AbortController();
|
|
29
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout * 1000);
|
|
30
|
+
return fetch(input, _objectSpread(_objectSpread({}, init), {}, {
|
|
31
|
+
signal: controller.signal
|
|
32
|
+
})).then(res => {
|
|
33
|
+
clearTimeout(timeoutId);
|
|
34
|
+
return res;
|
|
35
|
+
}).catch(e => {
|
|
36
|
+
if (e.name === 'AbortError' || e.name === 'DOMException') {
|
|
37
|
+
throw new Error(`Request timed out after ${timeout} seconds`);
|
|
38
|
+
}
|
|
39
|
+
throw e;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function decodeParams(paramsString) {
|
|
43
|
+
return (0, _immutable.List)(paramsString.split('&')).map(s => (0, _immutable.List)(s.split('=')).map(decodeURIComponent)).update(_immutable.Map);
|
|
44
|
+
}
|
|
45
|
+
function fromURL(wholeURL) {
|
|
46
|
+
const [url, allParamsString] = wholeURL.split('?');
|
|
47
|
+
return (0, _immutable.Map)(_objectSpread({
|
|
48
|
+
url
|
|
49
|
+
}, allParamsString ? {
|
|
50
|
+
params: decodeParams(allParamsString)
|
|
51
|
+
} : {}));
|
|
52
|
+
}
|
|
53
|
+
function fromFetchArguments(wholeURL, options) {
|
|
54
|
+
return fromURL(wholeURL).merge((options ? (0, _immutable.fromJS)(options) : (0, _immutable.Map)()).remove('url').remove('params'));
|
|
55
|
+
}
|
|
56
|
+
function encodeParams(params) {
|
|
57
|
+
return params.entrySeq().map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join('&');
|
|
58
|
+
}
|
|
59
|
+
function toURL(req) {
|
|
60
|
+
return `${req.get('url')}${req.get('params') ? `?${encodeParams(req.get('params'))}` : ''}`;
|
|
61
|
+
}
|
|
62
|
+
function toFetchArguments(req) {
|
|
63
|
+
return [toURL(req), req.remove('url').remove('params').toJS()];
|
|
64
|
+
}
|
|
65
|
+
function maybeRequestArg(req) {
|
|
66
|
+
if ((0, _isString.default)(req)) {
|
|
67
|
+
return fromURL(req);
|
|
68
|
+
}
|
|
69
|
+
if (req) {
|
|
70
|
+
return (0, _immutable.fromJS)(req);
|
|
71
|
+
}
|
|
72
|
+
return (0, _immutable.Map)();
|
|
73
|
+
}
|
|
74
|
+
function ensureRequestArg(func) {
|
|
75
|
+
return req => func(maybeRequestArg(req));
|
|
76
|
+
}
|
|
77
|
+
function ensureRequestArg2(func) {
|
|
78
|
+
return (arg, req) => func(arg, maybeRequestArg(req));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// This actually performs the built request object
|
|
82
|
+
const performRequest = ensureRequestArg(req => {
|
|
83
|
+
const args = toFetchArguments(req);
|
|
84
|
+
return fetchWithTimeout(...args);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Each of the following functions takes options and returns another
|
|
88
|
+
// function that performs the requested action on a request.
|
|
89
|
+
const getCurriedRequestProcessor = (0, _flow.default)([ensureRequestArg2, _curry.default]);
|
|
90
|
+
function getPropSetFunction(path) {
|
|
91
|
+
return getCurriedRequestProcessor((val, req) => req.setIn(path, val));
|
|
92
|
+
}
|
|
93
|
+
function getPropMergeFunction(path) {
|
|
94
|
+
return getCurriedRequestProcessor((obj, req) => req.updateIn(path, (p = (0, _immutable.Map)()) => p.merge(obj)));
|
|
95
|
+
}
|
|
96
|
+
const withMethod = getPropSetFunction(['method']);
|
|
97
|
+
const withBody = getPropSetFunction(['body']);
|
|
98
|
+
const withNoCache = getPropSetFunction(['cache'])('no-cache');
|
|
99
|
+
const withParams = getPropMergeFunction(['params']);
|
|
100
|
+
const withHeaders = getPropMergeFunction(['headers']);
|
|
101
|
+
|
|
102
|
+
// withRoot sets a root URL, unless the URL is already absolute
|
|
103
|
+
const absolutePath = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
104
|
+
const withRoot = getCurriedRequestProcessor((root, req) => req.update('url', p => {
|
|
105
|
+
if (absolutePath.test(p)) {
|
|
106
|
+
return p;
|
|
107
|
+
}
|
|
108
|
+
return root && p && p[0] !== '/' && root[root.length - 1] !== '/' ? `${root}/${p}` : `${root}${p}`;
|
|
109
|
+
}));
|
|
110
|
+
var _default = {
|
|
111
|
+
toURL,
|
|
112
|
+
fromURL,
|
|
113
|
+
fromFetchArguments,
|
|
114
|
+
performRequest,
|
|
115
|
+
withMethod,
|
|
116
|
+
withBody,
|
|
117
|
+
withHeaders,
|
|
118
|
+
withParams,
|
|
119
|
+
withRoot,
|
|
120
|
+
withNoCache,
|
|
121
|
+
fetchWithTimeout
|
|
122
|
+
};
|
|
123
|
+
exports.default = _default;
|