decap-cms-lib-util 3.8.1 → 3.9.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/dist/decap-cms-lib-util.js +1 -1
- package/dist/decap-cms-lib-util.js.map +1 -1
- package/dist/esm/backendUtil.js +25 -0
- package/dist/esm/index.js +3 -2
- package/package.json +18 -16
- package/LICENSE +0 -22
package/dist/esm/backendUtil.js
CHANGED
|
@@ -91,4 +91,29 @@ export async function getAllResponses(url, options = {}, linkHeaderRelName, next
|
|
|
91
91
|
export function getPathDepth(path) {
|
|
92
92
|
const depth = path.split('/').length;
|
|
93
93
|
return depth;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Stable cache key for a files collection.
|
|
98
|
+
*
|
|
99
|
+
* decap-cms-core's `entriesByFiles` receives only the file list, never the
|
|
100
|
+
* collection name, so a backend that caches such a collection has to derive an
|
|
101
|
+
* identity from the paths themselves.
|
|
102
|
+
*
|
|
103
|
+
* Sorted before hashing so key identity does not depend on the order files
|
|
104
|
+
* happen to be listed in config.yml — reordering them must not orphan the
|
|
105
|
+
* cached rows. Hashed so a collection of many paths does not become a
|
|
106
|
+
* multi-kilobyte value repeated on every cached row.
|
|
107
|
+
*
|
|
108
|
+
* FNV-1a rather than a crypto digest: this needs to be deterministic, short and
|
|
109
|
+
* synchronous, not unforgeable. It lives here rather than in one backend
|
|
110
|
+
* because both Turbo backends need exactly the same key.
|
|
111
|
+
*/
|
|
112
|
+
export function collectionKeyForFiles(paths) {
|
|
113
|
+
let hash = 0x811c9dc5;
|
|
114
|
+
for (const char of [...paths].sort().join('\n')) {
|
|
115
|
+
hash ^= char.charCodeAt(0);
|
|
116
|
+
hash = Math.imul(hash, 0x01000193) >>> 0;
|
|
117
|
+
}
|
|
118
|
+
return `files:${paths.length}:${hash.toString(36)}`;
|
|
94
119
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import localForage from './localForage';
|
|
|
6
6
|
import { isAbsolutePath, basename, fileExtensionWithSeparator, fileExtension } from './path';
|
|
7
7
|
import { onlySuccessfulPromises, flowAsync, then } from './promise';
|
|
8
8
|
import unsentRequest from './unsentRequest';
|
|
9
|
-
import { filterByExtension, getAllResponses, parseLinkHeader, parseResponse, responseParser, getPathDepth } from './backendUtil';
|
|
9
|
+
import { filterByExtension, collectionKeyForFiles, getAllResponses, parseLinkHeader, parseResponse, responseParser, getPathDepth } from './backendUtil';
|
|
10
10
|
import loadScript from './loadScript';
|
|
11
11
|
import getBlobSHA from './getBlobSHA';
|
|
12
12
|
import { asyncLock } from './asyncLock';
|
|
@@ -29,6 +29,7 @@ export const DecapCmsLibUtil = {
|
|
|
29
29
|
then,
|
|
30
30
|
unsentRequest,
|
|
31
31
|
filterByExtension,
|
|
32
|
+
collectionKeyForFiles,
|
|
32
33
|
parseLinkHeader,
|
|
33
34
|
parseResponse,
|
|
34
35
|
responseParser,
|
|
@@ -68,4 +69,4 @@ export const DecapCmsLibUtil = {
|
|
|
68
69
|
AccessTokenError,
|
|
69
70
|
throwOnConflictingBranches
|
|
70
71
|
};
|
|
71
|
-
export { APIError, Cursor, CURSOR_COMPATIBILITY_SYMBOL, EditorialWorkflowError, EDITORIAL_WORKFLOW_ERROR, localForage, basename, fileExtensionWithSeparator, fileExtension, onlySuccessfulPromises, flowAsync, then, unsentRequest, filterByExtension, parseLinkHeader, getAllResponses, parseResponse, responseParser, loadScript, getBlobSHA, asyncLock, isAbsolutePath, getPathDepth, entriesByFiles, entriesByFolder, unpublishedEntries, getMediaDisplayURL, getMediaAsBlob, readFile, readFileMetadata, CMS_BRANCH_PREFIX, generateContentKey, isCMSLabel, labelToStatus, statusToLabel, DEFAULT_PR_BODY, MERGE_COMMIT_MESSAGE, isPreviewContext, getPreviewStatus, runWithLock, PreviewState, parseContentKey, createPointerFile, getLargeMediaFilteredMediaFiles, getLargeMediaPatternsFromGitAttributesFile, parsePointerFile, getPointerFileForMediaFileObj, branchFromContentKey, contentKeyFromBranch, blobToFileObj, requestWithBackoff, getDefaultBranchName, allEntriesByFolder, AccessTokenError, throwOnConflictingBranches };
|
|
72
|
+
export { APIError, Cursor, CURSOR_COMPATIBILITY_SYMBOL, EditorialWorkflowError, EDITORIAL_WORKFLOW_ERROR, localForage, basename, fileExtensionWithSeparator, fileExtension, onlySuccessfulPromises, flowAsync, then, unsentRequest, filterByExtension, collectionKeyForFiles, parseLinkHeader, getAllResponses, parseResponse, responseParser, loadScript, getBlobSHA, asyncLock, isAbsolutePath, getPathDepth, entriesByFiles, entriesByFolder, unpublishedEntries, getMediaDisplayURL, getMediaAsBlob, readFile, readFileMetadata, CMS_BRANCH_PREFIX, generateContentKey, isCMSLabel, labelToStatus, statusToLabel, DEFAULT_PR_BODY, MERGE_COMMIT_MESSAGE, isPreviewContext, getPreviewStatus, runWithLock, PreviewState, parseContentKey, createPointerFile, getLargeMediaFilteredMediaFiles, getLargeMediaPatternsFromGitAttributesFile, parsePointerFile, getPointerFileForMediaFileObj, branchFromContentKey, contentKeyFromBranch, blobToFileObj, requestWithBackoff, getDefaultBranchName, allEntriesByFolder, AccessTokenError, throwOnConflictingBranches };
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "decap-cms-lib-util",
|
|
3
3
|
"description": "Shared utilities for Decap CMS.",
|
|
4
|
-
"version": "3.
|
|
5
|
-
"repository":
|
|
4
|
+
"version": "3.9.0-beta.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/decaporg/decap-cms/tree/main/packages/decap-cms-lib-util"
|
|
8
|
+
},
|
|
6
9
|
"bugs": "https://github.com/decaporg/decap-cms/issues",
|
|
7
10
|
"module": "dist/esm/index.js",
|
|
8
11
|
"main": "dist/decap-cms-lib-util.js",
|
|
@@ -14,23 +17,22 @@
|
|
|
14
17
|
"decap-cms"
|
|
15
18
|
],
|
|
16
19
|
"sideEffects": false,
|
|
17
|
-
"scripts": {
|
|
18
|
-
"develop": "pnpm run build:esm --watch",
|
|
19
|
-
"build": "cross-env NODE_ENV=production webpack",
|
|
20
|
-
"build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore \"**/__tests__\" --root-mode upward --extensions \".js,.jsx,.ts,.tsx\""
|
|
21
|
-
},
|
|
22
20
|
"dependencies": {
|
|
23
|
-
"js-sha256": "
|
|
24
|
-
"localforage": "
|
|
25
|
-
"semaphore": "
|
|
21
|
+
"js-sha256": "^0.9.0",
|
|
22
|
+
"localforage": "^1.7.3",
|
|
23
|
+
"semaphore": "^1.1.0"
|
|
26
24
|
},
|
|
27
25
|
"peerDependencies": {
|
|
28
|
-
"common-tags": "
|
|
29
|
-
"immutable": "
|
|
30
|
-
"lodash": "
|
|
26
|
+
"common-tags": "1.8.2",
|
|
27
|
+
"immutable": "^4.3.9",
|
|
28
|
+
"lodash": "^4.17.11"
|
|
31
29
|
},
|
|
32
30
|
"devDependencies": {
|
|
33
|
-
"common-tags": "
|
|
31
|
+
"common-tags": "1.8.2"
|
|
34
32
|
},
|
|
35
|
-
"
|
|
36
|
-
|
|
33
|
+
"scripts": {
|
|
34
|
+
"develop": "pnpm run build:esm --watch",
|
|
35
|
+
"build": "cross-env NODE_ENV=production webpack",
|
|
36
|
+
"build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore \"**/__tests__\" --root-mode upward --extensions \".js,.jsx,.ts,.tsx\""
|
|
37
|
+
}
|
|
38
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2016 Netlify <decap@p-m.si>
|
|
2
|
-
|
|
3
|
-
MIT License
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|