decap-cms-lib-util 3.2.0 → 3.3.1
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/README.md +1 -1
- package/dist/decap-cms-lib-util.js +1 -1
- package/dist/decap-cms-lib-util.js.LICENSE.txt +9 -0
- package/dist/decap-cms-lib-util.js.map +1 -1
- package/dist/esm/API.js +17 -25
- package/dist/esm/APIError.js +0 -7
- package/dist/esm/AccessTokenError.js +0 -4
- package/dist/esm/Cursor.js +4 -9
- package/dist/esm/EditorialWorkflowError.js +0 -5
- package/dist/esm/backendUtil.js +6 -7
- package/dist/esm/getBlobSHA.js +3 -3
- package/dist/esm/git-lfs.js +21 -29
- package/dist/esm/implementation.js +14 -17
- package/dist/esm/unsentRequest.js +9 -12
- package/package.json +5 -2
- package/CHANGELOG.md +0 -382
- package/dist/esm/stega.js +0 -129
- package/src/API.ts +0 -376
- package/src/APIError.ts +0 -17
- package/src/APIUtils.ts +0 -38
- package/src/AccessTokenError.ts +0 -11
- package/src/Cursor.ts +0 -178
- package/src/EditorialWorkflowError.ts +0 -12
- package/src/__tests__/api.spec.js +0 -13
- package/src/__tests__/apiUtils.spec.js +0 -74
- package/src/__tests__/asyncLock.spec.js +0 -85
- package/src/__tests__/backendUtil.spec.js +0 -97
- package/src/__tests__/implementation.spec.js +0 -58
- package/src/__tests__/path.spec.js +0 -53
- package/src/__tests__/unsentRequest.spec.js +0 -19
- package/src/asyncLock.ts +0 -43
- package/src/backendUtil.ts +0 -120
- package/src/getBlobSHA.ts +0 -12
- package/src/git-lfs.ts +0 -133
- package/src/implementation.ts +0 -575
- package/src/index.ts +0 -213
- package/src/loadScript.js +0 -24
- package/src/localForage.ts +0 -21
- package/src/path.ts +0 -86
- package/src/promise.ts +0 -21
- package/src/stega.ts +0 -134
- package/src/types/semaphore.d.ts +0 -5
- package/src/types.ts +0 -9
- package/src/unsentRequest.js +0 -133
- package/webpack.config.js +0 -3
package/dist/esm/API.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
const _excluded = ["token", "backend"];
|
|
2
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
3
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
-
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; }
|
|
7
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
8
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
1
|
function _extendableBuiltin(cls) {
|
|
10
2
|
function ExtendableBuiltin() {
|
|
11
3
|
var instance = Reflect.construct(cls, Array.from(arguments));
|
|
@@ -33,7 +25,6 @@ import APIError from './APIError';
|
|
|
33
25
|
class RateLimitError extends _extendableBuiltin(Error) {
|
|
34
26
|
constructor(message, resetSeconds) {
|
|
35
27
|
super(message);
|
|
36
|
-
_defineProperty(this, "resetSeconds", void 0);
|
|
37
28
|
if (resetSeconds < 0) {
|
|
38
29
|
this.resetSeconds = 1;
|
|
39
30
|
} else if (resetSeconds > 60 * 60) {
|
|
@@ -96,8 +87,7 @@ export async function requestWithBackoff(api, req, attempt = 1) {
|
|
|
96
87
|
api.rateLimiter = asyncLock();
|
|
97
88
|
api.rateLimiter.acquire();
|
|
98
89
|
setTimeout(() => {
|
|
99
|
-
|
|
100
|
-
(_api$rateLimiter = api.rateLimiter) === null || _api$rateLimiter === void 0 ? void 0 : _api$rateLimiter.release();
|
|
90
|
+
api.rateLimiter?.release();
|
|
101
91
|
api.rateLimiter = undefined;
|
|
102
92
|
console.log(`Done pausing requests`);
|
|
103
93
|
}, 1000 * timeout);
|
|
@@ -151,9 +141,10 @@ async function constructRequestHeaders(headerConfig) {
|
|
|
151
141
|
token,
|
|
152
142
|
headers
|
|
153
143
|
} = headerConfig;
|
|
154
|
-
const baseHeaders =
|
|
155
|
-
'Content-Type': 'application/json; charset=utf-8'
|
|
156
|
-
|
|
144
|
+
const baseHeaders = {
|
|
145
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
146
|
+
...headers
|
|
147
|
+
};
|
|
157
148
|
if (token) {
|
|
158
149
|
baseHeaders['Authorization'] = `Bearer ${token}`;
|
|
159
150
|
}
|
|
@@ -163,26 +154,27 @@ function handleRequestError(error, responseStatus, backend) {
|
|
|
163
154
|
throw new APIError(error.message, responseStatus, backend);
|
|
164
155
|
}
|
|
165
156
|
export async function apiRequest(path, config, parser = response => parseResponse(response)) {
|
|
166
|
-
var _config$apiRoot;
|
|
167
157
|
const {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const options =
|
|
173
|
-
cache: 'no-cache'
|
|
174
|
-
|
|
158
|
+
token,
|
|
159
|
+
backend,
|
|
160
|
+
...props
|
|
161
|
+
} = config;
|
|
162
|
+
const options = {
|
|
163
|
+
cache: 'no-cache',
|
|
164
|
+
...props
|
|
165
|
+
};
|
|
175
166
|
const headers = await constructRequestHeaders({
|
|
176
167
|
headers: options.headers || {},
|
|
177
168
|
token
|
|
178
169
|
});
|
|
179
|
-
const baseUrl =
|
|
170
|
+
const baseUrl = config.apiRoot ?? apiRoots[backend];
|
|
180
171
|
const url = constructUrlWithParams(`${baseUrl}${path}`, options.params);
|
|
181
172
|
let responseStatus = 500;
|
|
182
173
|
try {
|
|
183
|
-
const req = unsentRequest.fromFetchArguments(url,
|
|
174
|
+
const req = unsentRequest.fromFetchArguments(url, {
|
|
175
|
+
...options,
|
|
184
176
|
headers
|
|
185
|
-
})
|
|
177
|
+
});
|
|
186
178
|
const response = await requestWithBackoff(api, req);
|
|
187
179
|
responseStatus = response.status;
|
|
188
180
|
const parsedResponse = await parser(response);
|
package/dist/esm/APIError.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
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; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
1
|
function _extendableBuiltin(cls) {
|
|
5
2
|
function ExtendableBuiltin() {
|
|
6
3
|
var instance = Reflect.construct(cls, Array.from(arguments));
|
|
@@ -26,10 +23,6 @@ export const API_ERROR = 'API_ERROR';
|
|
|
26
23
|
export default class APIError extends _extendableBuiltin(Error) {
|
|
27
24
|
constructor(message, status, api, meta = {}) {
|
|
28
25
|
super(message);
|
|
29
|
-
_defineProperty(this, "message", void 0);
|
|
30
|
-
_defineProperty(this, "status", void 0);
|
|
31
|
-
_defineProperty(this, "api", void 0);
|
|
32
|
-
_defineProperty(this, "meta", void 0);
|
|
33
26
|
this.message = message;
|
|
34
27
|
this.status = status;
|
|
35
28
|
this.api = api;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
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; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
1
|
function _extendableBuiltin(cls) {
|
|
5
2
|
function ExtendableBuiltin() {
|
|
6
3
|
var instance = Reflect.construct(cls, Array.from(arguments));
|
|
@@ -26,7 +23,6 @@ export const ACCESS_TOKEN_ERROR = 'ACCESS_TOKEN_ERROR';
|
|
|
26
23
|
export default class AccessTokenError extends _extendableBuiltin(Error) {
|
|
27
24
|
constructor(message) {
|
|
28
25
|
super(message);
|
|
29
|
-
_defineProperty(this, "message", void 0);
|
|
30
26
|
this.message = message;
|
|
31
27
|
this.name = ACCESS_TOKEN_ERROR;
|
|
32
28
|
}
|
package/dist/esm/Cursor.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
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; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
1
|
import { fromJS, Map, Set } from 'immutable';
|
|
5
2
|
function jsToMap(obj) {
|
|
6
3
|
if (obj === undefined) {
|
|
@@ -51,16 +48,14 @@ function getActionHandlers(store, handler) {
|
|
|
51
48
|
// The cursor logic is entirely functional, so this class simply
|
|
52
49
|
// provides a chainable interface
|
|
53
50
|
export default class Cursor {
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
|
|
54
55
|
static create(...args) {
|
|
55
56
|
return new Cursor(...args);
|
|
56
57
|
}
|
|
57
58
|
constructor(...args) {
|
|
58
|
-
_defineProperty(this, "store", void 0);
|
|
59
|
-
_defineProperty(this, "actions", void 0);
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
-
_defineProperty(this, "data", void 0);
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
-
_defineProperty(this, "meta", void 0);
|
|
64
59
|
if (args[0] instanceof Cursor) {
|
|
65
60
|
return args[0];
|
|
66
61
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
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; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
1
|
function _extendableBuiltin(cls) {
|
|
5
2
|
function ExtendableBuiltin() {
|
|
6
3
|
var instance = Reflect.construct(cls, Array.from(arguments));
|
|
@@ -26,8 +23,6 @@ export const EDITORIAL_WORKFLOW_ERROR = 'EDITORIAL_WORKFLOW_ERROR';
|
|
|
26
23
|
export default class EditorialWorkflowError extends _extendableBuiltin(Error) {
|
|
27
24
|
constructor(message, notUnderEditorialWorkflow) {
|
|
28
25
|
super(message);
|
|
29
|
-
_defineProperty(this, "message", void 0);
|
|
30
|
-
_defineProperty(this, "notUnderEditorialWorkflow", void 0);
|
|
31
26
|
this.message = message;
|
|
32
27
|
this.notUnderEditorialWorkflow = notUnderEditorialWorkflow;
|
|
33
28
|
this.name = EDITORIAL_WORKFLOW_ERROR;
|
package/dist/esm/backendUtil.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import flow from 'lodash/flow';
|
|
2
|
+
import fromPairs from 'lodash/fromPairs';
|
|
3
|
+
import { map } from 'lodash/fp';
|
|
4
4
|
import { fromJS } from 'immutable';
|
|
5
5
|
import unsentRequest from './unsentRequest';
|
|
6
6
|
import APIError from './APIError';
|
|
7
7
|
export function filterByExtension(file, extension) {
|
|
8
|
-
const path =
|
|
8
|
+
const path = file?.path || '';
|
|
9
9
|
return path.endsWith(extension.startsWith('.') ? extension : `.${extension}`);
|
|
10
10
|
}
|
|
11
11
|
function catchFormatErrors(format, formatter) {
|
|
@@ -44,9 +44,8 @@ export async function parseResponse(res, {
|
|
|
44
44
|
throw new APIError(err.message, res.status, apiName);
|
|
45
45
|
}
|
|
46
46
|
if (expectingOk && !res.ok) {
|
|
47
|
-
var _body$error;
|
|
48
47
|
const isJSON = format === 'json';
|
|
49
|
-
const message = isJSON ? body.message || body.msg ||
|
|
48
|
+
const message = isJSON ? body.message || body.msg || body.error?.message : body;
|
|
50
49
|
throw new APIError(isJSON && message ? message : body, res.status, apiName);
|
|
51
50
|
}
|
|
52
51
|
return body;
|
|
@@ -58,7 +57,7 @@ export function parseLinkHeader(header) {
|
|
|
58
57
|
if (!header) {
|
|
59
58
|
return {};
|
|
60
59
|
}
|
|
61
|
-
return
|
|
60
|
+
return flow([linksString => linksString.split(','), map(str => str.trim().split(';')), map(([linkStr, keyStr]) => [keyStr.match(/rel="(.*?)"/)[1], linkStr.trim().match(/<(.*?)>/)[1].replace(/\+/g, '%20')]), fromPairs])(header);
|
|
62
61
|
}
|
|
63
62
|
export async function getAllResponses(url, options = {}, linkHeaderRelName, nextUrlProcessor) {
|
|
64
63
|
const maxResponses = 30;
|
package/dist/esm/getBlobSHA.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { sha256 } from 'js-sha256';
|
|
2
|
-
export default
|
|
2
|
+
export default blob => new Promise((resolve, reject) => {
|
|
3
3
|
const fr = new FileReader();
|
|
4
4
|
fr.onload = ({
|
|
5
5
|
target
|
|
6
|
-
}) => resolve(sha256(
|
|
6
|
+
}) => resolve(sha256(target?.result || ''));
|
|
7
7
|
fr.onerror = err => {
|
|
8
8
|
fr.abort();
|
|
9
9
|
reject(err);
|
|
10
10
|
};
|
|
11
11
|
fr.readAsArrayBuffer(blob);
|
|
12
|
-
})
|
|
12
|
+
});
|
package/dist/esm/git-lfs.js
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import _fromPairs from "lodash/fp/fromPairs";
|
|
3
|
-
import _flow from "lodash/fp/flow";
|
|
4
|
-
import _filter from "lodash/fp/filter"; //
|
|
1
|
+
//
|
|
5
2
|
// Pointer file parsing
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
|
-
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; }
|
|
10
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
11
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
12
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
13
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
3
|
+
|
|
4
|
+
import { filter, flow, fromPairs, map } from 'lodash/fp';
|
|
14
5
|
import getBlobSHA from './getBlobSHA';
|
|
15
6
|
function splitIntoLines(str) {
|
|
16
7
|
return str.split('\n');
|
|
@@ -21,18 +12,16 @@ function splitIntoWords(str) {
|
|
|
21
12
|
function isNonEmptyString(str) {
|
|
22
13
|
return str !== '';
|
|
23
14
|
}
|
|
24
|
-
const withoutEmptyLines =
|
|
25
|
-
export const parsePointerFile =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}, rest);
|
|
35
|
-
}]);
|
|
15
|
+
const withoutEmptyLines = flow([map(str => str.trim()), filter(isNonEmptyString)]);
|
|
16
|
+
export const parsePointerFile = flow([splitIntoLines, withoutEmptyLines, map(splitIntoWords), fromPairs, ({
|
|
17
|
+
size,
|
|
18
|
+
oid,
|
|
19
|
+
...rest
|
|
20
|
+
}) => ({
|
|
21
|
+
size: parseInt(size),
|
|
22
|
+
sha: oid?.split(':')[1],
|
|
23
|
+
...rest
|
|
24
|
+
})]);
|
|
36
25
|
|
|
37
26
|
//
|
|
38
27
|
// .gitattributes file parsing
|
|
@@ -54,10 +43,10 @@ function parseGitPatternAttribute(attributeString) {
|
|
|
54
43
|
}
|
|
55
44
|
return [attributeString, true];
|
|
56
45
|
}
|
|
57
|
-
const parseGitPatternAttributes =
|
|
58
|
-
const parseGitAttributesPatternLine =
|
|
59
|
-
const parseGitAttributesFileToPatternAttributePairs =
|
|
60
|
-
export const getLargeMediaPatternsFromGitAttributesFile =
|
|
46
|
+
const parseGitPatternAttributes = flow([map(parseGitPatternAttribute), fromPairs]);
|
|
47
|
+
const parseGitAttributesPatternLine = flow([splitIntoWords, ([pattern, ...attributes]) => [pattern, parseGitPatternAttributes(attributes)]]);
|
|
48
|
+
const parseGitAttributesFileToPatternAttributePairs = flow([splitIntoLines, map(removeGitAttributesCommentsFromLine), withoutEmptyLines, map(parseGitAttributesPatternLine)]);
|
|
49
|
+
export const getLargeMediaPatternsFromGitAttributesFile = flow([parseGitAttributesFileToPatternAttributePairs, filter(([, attributes]) => attributes.filter === 'lfs' && attributes.diff === 'lfs' && attributes.merge === 'lfs'), map(([pattern]) => pattern)]);
|
|
61
50
|
export function createPointerFile({
|
|
62
51
|
size,
|
|
63
52
|
sha
|
|
@@ -106,6 +95,9 @@ export async function getLargeMediaFilteredMediaFiles(client, mediaFiles) {
|
|
|
106
95
|
return mediaFile;
|
|
107
96
|
}
|
|
108
97
|
const pointerFileDetails = await getPointerFileForMediaFileObj(client, fileObj, path);
|
|
109
|
-
return
|
|
98
|
+
return {
|
|
99
|
+
...mediaFile,
|
|
100
|
+
...pointerFileDetails
|
|
101
|
+
};
|
|
110
102
|
}));
|
|
111
103
|
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import _sortBy from "lodash/sortBy";
|
|
2
|
-
import _unionBy from "lodash/unionBy";
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
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; }
|
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
7
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
1
|
import semaphore from 'semaphore';
|
|
2
|
+
import unionBy from 'lodash/unionBy';
|
|
3
|
+
import sortBy from 'lodash/sortBy';
|
|
9
4
|
import { basename } from './path';
|
|
10
5
|
const MAX_CONCURRENT_DOWNLOADS = 10;
|
|
11
6
|
async function fetchFiles(files, readFile, readFileMetadata, apiName) {
|
|
@@ -18,7 +13,10 @@ async function fetchFiles(files, readFile, readFileMetadata, apiName) {
|
|
|
18
13
|
parseText: true
|
|
19
14
|
}), readFileMetadata(file.path, file.id)]);
|
|
20
15
|
resolve({
|
|
21
|
-
file:
|
|
16
|
+
file: {
|
|
17
|
+
...file,
|
|
18
|
+
...fileMetadata
|
|
19
|
+
},
|
|
22
20
|
data: data
|
|
23
21
|
});
|
|
24
22
|
sem.leave();
|
|
@@ -140,10 +138,7 @@ async function getDiffFromLocalTree({
|
|
|
140
138
|
getFileId
|
|
141
139
|
}) {
|
|
142
140
|
const diff = await getDifferences(branch.sha, localTree.head);
|
|
143
|
-
const diffFiles = diff.filter(d => {
|
|
144
|
-
var _d$oldPath, _d$newPath;
|
|
145
|
-
return ((_d$oldPath = d.oldPath) === null || _d$oldPath === void 0 ? void 0 : _d$oldPath.startsWith(folder)) || ((_d$newPath = d.newPath) === null || _d$newPath === void 0 ? void 0 : _d$newPath.startsWith(folder));
|
|
146
|
-
}).reduce((acc, d) => {
|
|
141
|
+
const diffFiles = diff.filter(d => d.oldPath?.startsWith(folder) || d.newPath?.startsWith(folder)).reduce((acc, d) => {
|
|
147
142
|
if (d.status === 'renamed') {
|
|
148
143
|
acc.push({
|
|
149
144
|
path: d.oldPath,
|
|
@@ -173,13 +168,15 @@ async function getDiffFromLocalTree({
|
|
|
173
168
|
const diffFilesWithIds = await Promise.all(diffFiles.map(async file => {
|
|
174
169
|
if (!file.deleted) {
|
|
175
170
|
const id = await getFileId(file.path);
|
|
176
|
-
return
|
|
171
|
+
return {
|
|
172
|
+
...file,
|
|
177
173
|
id
|
|
178
|
-
}
|
|
174
|
+
};
|
|
179
175
|
} else {
|
|
180
|
-
return
|
|
176
|
+
return {
|
|
177
|
+
...file,
|
|
181
178
|
id: ''
|
|
182
|
-
}
|
|
179
|
+
};
|
|
183
180
|
}
|
|
184
181
|
}));
|
|
185
182
|
return diffFilesWithIds;
|
|
@@ -262,7 +259,7 @@ export async function allEntriesByFolder({
|
|
|
262
259
|
acc[d.path] = d.deleted;
|
|
263
260
|
return acc;
|
|
264
261
|
}, {});
|
|
265
|
-
const newCopy =
|
|
262
|
+
const newCopy = sortBy(unionBy(diff.filter(d => !deleted[d.path]), localTree.files.filter(f => !deleted[f.path]), file => file.path), file => file.path);
|
|
266
263
|
await persistLocalTree({
|
|
267
264
|
localForage,
|
|
268
265
|
localTree: {
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
-
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; }
|
|
4
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
5
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
1
|
import { fromJS, List, Map } from 'immutable';
|
|
7
2
|
import curry from 'lodash/curry';
|
|
8
3
|
import flow from 'lodash/flow';
|
|
@@ -20,9 +15,10 @@ function fetchWithTimeout(input, init) {
|
|
|
20
15
|
}
|
|
21
16
|
const controller = new AbortController();
|
|
22
17
|
const timeoutId = setTimeout(() => controller.abort(), timeout * 1000);
|
|
23
|
-
return fetch(input,
|
|
18
|
+
return fetch(input, {
|
|
19
|
+
...init,
|
|
24
20
|
signal: controller.signal
|
|
25
|
-
})
|
|
21
|
+
}).then(res => {
|
|
26
22
|
clearTimeout(timeoutId);
|
|
27
23
|
return res;
|
|
28
24
|
}).catch(e => {
|
|
@@ -37,11 +33,12 @@ function decodeParams(paramsString) {
|
|
|
37
33
|
}
|
|
38
34
|
function fromURL(wholeURL) {
|
|
39
35
|
const [url, allParamsString] = wholeURL.split('?');
|
|
40
|
-
return Map(
|
|
41
|
-
url
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
return Map({
|
|
37
|
+
url,
|
|
38
|
+
...(allParamsString ? {
|
|
39
|
+
params: decodeParams(allParamsString)
|
|
40
|
+
} : {})
|
|
41
|
+
});
|
|
45
42
|
}
|
|
46
43
|
function fromFetchArguments(wholeURL, options) {
|
|
47
44
|
return fromURL(wholeURL).merge((options ? fromJS(options) : Map()).remove('url').remove('params'));
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "decap-cms-lib-util",
|
|
3
3
|
"description": "Shared utilities for Decap CMS.",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.3.1",
|
|
5
5
|
"repository": "https://github.com/decaporg/decap-cms/tree/main/packages/decap-cms-lib-util",
|
|
6
6
|
"bugs": "https://github.com/decaporg/decap-cms/issues",
|
|
7
7
|
"module": "dist/esm/index.js",
|
|
8
8
|
"main": "dist/decap-cms-lib-util.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
9
12
|
"license": "MIT",
|
|
10
13
|
"keywords": [
|
|
11
14
|
"decap-cms"
|
|
@@ -25,5 +28,5 @@
|
|
|
25
28
|
"immutable": "^3.7.6",
|
|
26
29
|
"lodash": "^4.17.11"
|
|
27
30
|
},
|
|
28
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "899dba82d1f396260e0f84c6977c1d2aee809b59"
|
|
29
32
|
}
|