decap-cms-core 3.5.0 → 3.6.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.
Files changed (141) hide show
  1. package/dist/decap-cms-core.js +10 -10
  2. package/dist/decap-cms-core.js.map +1 -1
  3. package/dist/esm/actions/auth.js +22 -37
  4. package/dist/esm/actions/collections.js +9 -17
  5. package/dist/esm/actions/config.js +58 -74
  6. package/dist/esm/actions/deploys.js +10 -17
  7. package/dist/esm/actions/editorialWorkflow.js +87 -101
  8. package/dist/esm/actions/entries.js +161 -211
  9. package/dist/esm/actions/media.js +31 -46
  10. package/dist/esm/actions/mediaLibrary.js +94 -126
  11. package/dist/esm/actions/notifications.js +5 -13
  12. package/dist/esm/actions/search.js +30 -47
  13. package/dist/esm/actions/status.js +13 -23
  14. package/dist/esm/actions/waitUntil.js +4 -11
  15. package/dist/esm/backend.js +132 -148
  16. package/dist/esm/bootstrap.js +37 -44
  17. package/dist/esm/components/App/App.js +82 -89
  18. package/dist/esm/components/App/Header.js +46 -52
  19. package/dist/esm/components/App/NotFoundPage.js +11 -18
  20. package/dist/esm/components/Collection/Collection.js +55 -63
  21. package/dist/esm/components/Collection/CollectionControls.js +15 -22
  22. package/dist/esm/components/Collection/CollectionSearch.js +35 -42
  23. package/dist/esm/components/Collection/CollectionTop.js +23 -30
  24. package/dist/esm/components/Collection/ControlButton.js +10 -16
  25. package/dist/esm/components/Collection/Entries/Entries.js +24 -31
  26. package/dist/esm/components/Collection/Entries/EntriesCollection.js +60 -63
  27. package/dist/esm/components/Collection/Entries/EntriesSearch.js +26 -33
  28. package/dist/esm/components/Collection/Entries/EntryCard.js +38 -45
  29. package/dist/esm/components/Collection/Entries/EntryListing.js +24 -32
  30. package/dist/esm/components/Collection/FilterControl.js +9 -16
  31. package/dist/esm/components/Collection/GroupControl.js +9 -16
  32. package/dist/esm/components/Collection/NestedCollection.js +56 -64
  33. package/dist/esm/components/Collection/Sidebar.js +36 -43
  34. package/dist/esm/components/Collection/SortControl.js +19 -26
  35. package/dist/esm/components/Collection/ViewStyleControl.js +17 -24
  36. package/dist/esm/components/Editor/Editor.js +100 -108
  37. package/dist/esm/components/Editor/EditorControlPane/EditorControl.js +105 -112
  38. package/dist/esm/components/Editor/EditorControlPane/EditorControlPane.js +68 -62
  39. package/dist/esm/components/Editor/EditorControlPane/Widget.js +87 -73
  40. package/dist/esm/components/Editor/EditorInterface.js +95 -98
  41. package/dist/esm/components/Editor/EditorPreviewPane/EditorPreview.js +13 -21
  42. package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewContent.js +64 -23
  43. package/dist/esm/components/Editor/EditorPreviewPane/EditorPreviewPane.js +94 -78
  44. package/dist/esm/components/Editor/EditorPreviewPane/PreviewHOC.js +9 -16
  45. package/dist/esm/components/Editor/EditorToolbar.js +133 -140
  46. package/dist/esm/components/Editor/withWorkflow.js +15 -22
  47. package/dist/esm/components/EditorWidgets/Unknown/UnknownControl.js +9 -16
  48. package/dist/esm/components/EditorWidgets/Unknown/UnknownPreview.js +9 -16
  49. package/dist/esm/components/EditorWidgets/index.js +4 -7
  50. package/dist/esm/components/MediaLibrary/EmptyMessage.js +12 -19
  51. package/dist/esm/components/MediaLibrary/MediaLibrary.js +55 -62
  52. package/dist/esm/components/MediaLibrary/MediaLibraryButtons.js +28 -35
  53. package/dist/esm/components/MediaLibrary/MediaLibraryCard.js +36 -43
  54. package/dist/esm/components/MediaLibrary/MediaLibraryCardGrid.js +50 -57
  55. package/dist/esm/components/MediaLibrary/MediaLibraryHeader.js +16 -23
  56. package/dist/esm/components/MediaLibrary/MediaLibraryModal.js +59 -64
  57. package/dist/esm/components/MediaLibrary/MediaLibrarySearch.js +18 -25
  58. package/dist/esm/components/MediaLibrary/MediaLibraryTop.js +39 -46
  59. package/dist/esm/components/UI/DragDrop.js +21 -30
  60. package/dist/esm/components/UI/ErrorBoundary.js +35 -43
  61. package/dist/esm/components/UI/FileUploadButton.js +11 -18
  62. package/dist/esm/components/UI/Modal.js +19 -26
  63. package/dist/esm/components/UI/Notifications.js +21 -28
  64. package/dist/esm/components/UI/SettingsDropdown.js +28 -34
  65. package/dist/esm/components/UI/index.js +6 -60
  66. package/dist/esm/components/Workflow/Workflow.js +52 -61
  67. package/dist/esm/components/Workflow/WorkflowCard.js +45 -51
  68. package/dist/esm/components/Workflow/WorkflowList.js +43 -49
  69. package/dist/esm/constants/collectionTypes.js +2 -8
  70. package/dist/esm/constants/collectionViews.js +2 -8
  71. package/dist/esm/constants/commitProps.js +2 -8
  72. package/dist/esm/constants/configSchema.js +23 -27
  73. package/dist/esm/constants/fieldInference.js +8 -15
  74. package/dist/esm/constants/publishModes.js +6 -11
  75. package/dist/esm/constants/validationErrorTypes.js +1 -7
  76. package/dist/esm/formats/formats.js +32 -41
  77. package/dist/esm/formats/frontmatter.js +18 -30
  78. package/dist/esm/formats/helpers.js +1 -7
  79. package/dist/esm/formats/json.js +1 -7
  80. package/dist/esm/formats/toml.js +11 -18
  81. package/dist/esm/formats/yaml.js +7 -14
  82. package/dist/esm/index.js +5 -12
  83. package/dist/esm/integrations/index.js +8 -16
  84. package/dist/esm/integrations/providers/algolia/implementation.js +14 -22
  85. package/dist/esm/integrations/providers/assetStore/implementation.js +10 -18
  86. package/dist/esm/lib/consoleError.js +1 -7
  87. package/dist/esm/lib/formatters.js +34 -47
  88. package/dist/esm/lib/i18n.js +37 -66
  89. package/dist/esm/lib/phrases.js +4 -11
  90. package/dist/esm/lib/registry.js +40 -75
  91. package/dist/esm/lib/serializeEntryValues.js +11 -18
  92. package/dist/esm/lib/textHelper.js +1 -7
  93. package/dist/esm/lib/urlHelper.js +28 -43
  94. package/dist/esm/mediaLibrary.js +12 -16
  95. package/dist/esm/reducers/auth.js +10 -16
  96. package/dist/esm/reducers/collections.js +70 -102
  97. package/dist/esm/reducers/combinedReducer.js +4 -11
  98. package/dist/esm/reducers/config.js +11 -19
  99. package/dist/esm/reducers/cursors.js +12 -18
  100. package/dist/esm/reducers/deploys.js +8 -15
  101. package/dist/esm/reducers/editorialWorkflow.js +37 -47
  102. package/dist/esm/reducers/entries.js +107 -132
  103. package/dist/esm/reducers/entryDraft.js +64 -72
  104. package/dist/esm/reducers/globalUI.js +5 -11
  105. package/dist/esm/reducers/index.js +43 -64
  106. package/dist/esm/reducers/integrations.js +8 -16
  107. package/dist/esm/reducers/mediaLibrary.js +43 -52
  108. package/dist/esm/reducers/medias.js +11 -18
  109. package/dist/esm/reducers/notifications.js +9 -15
  110. package/dist/esm/reducers/search.js +12 -18
  111. package/dist/esm/reducers/status.js +7 -13
  112. package/dist/esm/redux/index.js +7 -13
  113. package/dist/esm/redux/middleware/waitUntilAction.js +3 -10
  114. package/dist/esm/routing/history.js +7 -15
  115. package/dist/esm/types/diacritics.d.js +0 -1
  116. package/dist/esm/types/global.d.js +1 -5
  117. package/dist/esm/types/immutable.js +1 -5
  118. package/dist/esm/types/redux.js +7 -8
  119. package/dist/esm/types/tomlify-j0.4.d.js +0 -1
  120. package/dist/esm/valueObjects/AssetProxy.js +2 -10
  121. package/dist/esm/valueObjects/EditorComponent.js +5 -12
  122. package/dist/esm/valueObjects/Entry.js +3 -10
  123. package/index.d.ts +1 -0
  124. package/package.json +3 -2
  125. package/src/components/Collection/Entries/EntriesCollection.js +21 -10
  126. package/src/components/Collection/Entries/__tests__/EntriesCollection.spec.js +7 -7
  127. package/src/components/Collection/Entries/__tests__/__snapshots__/EntriesCollection.spec.js.snap +9 -9
  128. package/src/components/Collection/NestedCollection.js +11 -2
  129. package/src/components/Collection/__tests__/NestedCollection.spec.js +3 -0
  130. package/src/components/Collection/__tests__/__snapshots__/NestedCollection.spec.js.snap +68 -0
  131. package/src/components/Editor/EditorControlPane/EditorControl.js +0 -3
  132. package/src/components/Editor/EditorControlPane/EditorControlPane.js +21 -8
  133. package/src/components/Editor/EditorControlPane/Widget.js +22 -1
  134. package/src/components/Editor/EditorInterface.js +6 -1
  135. package/src/components/Editor/EditorPreviewPane/EditorPreviewContent.js +51 -11
  136. package/src/components/Editor/EditorPreviewPane/EditorPreviewPane.js +33 -1
  137. package/src/constants/configSchema.js +1 -0
  138. package/src/types/redux.ts +1 -1
  139. package/dist/esm/actions/editorControl.js +0 -14
  140. package/dist/esm/reducers/editorComponent.js +0 -1
  141. package/dist/esm/reducers/editorControl.js +0 -17
@@ -1,44 +1,12 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.currentBackend = exports.LocalStorageAuthStore = exports.Backend = void 0;
7
- exports.expandSearchEntries = expandSearchEntries;
8
- exports.extractSearchFields = extractSearchFields;
9
- exports.mergeExpandedEntries = mergeExpandedEntries;
10
- exports.resolveBackend = resolveBackend;
11
- exports.slugFromCustomPath = slugFromCustomPath;
12
- var _set2 = _interopRequireDefault(require("lodash/set"));
13
- var _get2 = _interopRequireDefault(require("lodash/get"));
14
- var _sortBy2 = _interopRequireDefault(require("lodash/sortBy"));
15
- var _trim2 = _interopRequireDefault(require("lodash/trim"));
16
- var _uniq2 = _interopRequireDefault(require("lodash/uniq"));
17
- var _isError2 = _interopRequireDefault(require("lodash/isError"));
18
- var _flatten2 = _interopRequireDefault(require("lodash/flatten"));
19
- var _attempt2 = _interopRequireDefault(require("lodash/attempt"));
20
- var _immutable = require("immutable");
21
- var fuzzy = _interopRequireWildcard(require("fuzzy"));
22
- var _decapCmsLibUtil = require("decap-cms-lib-util");
23
- var _path = require("path");
24
- var _decapCmsLibWidgets = require("decap-cms-lib-widgets");
25
- var _formats = require("./formats/formats");
26
- var _config = require("./reducers/config");
27
- var _entries = require("./reducers/entries");
28
- var _integrations = require("./reducers/integrations");
29
- var _collections = require("./reducers/collections");
30
- var _Entry = require("./valueObjects/Entry");
31
- var _urlHelper = require("./lib/urlHelper");
32
- var _registry = require("./lib/registry");
33
- var _formatters = require("./lib/formatters");
34
- var _publishModes = require("./constants/publishModes");
35
- var _collectionTypes = require("./constants/collectionTypes");
36
- var _entryDraft = require("./reducers/entryDraft");
37
- var _i18n = require("./lib/i18n");
1
+ import _set from "lodash/set";
2
+ import _get from "lodash/get";
3
+ import _sortBy from "lodash/sortBy";
4
+ import _trim from "lodash/trim";
5
+ import _uniq from "lodash/uniq";
6
+ import _isError from "lodash/isError";
7
+ import _flatten from "lodash/flatten";
8
+ import _attempt from "lodash/attempt";
38
9
  const _excluded = ["field"];
39
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
40
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
41
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
42
10
  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; }
43
11
  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; }
44
12
  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; }
@@ -46,20 +14,38 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
46
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; }
47
15
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
48
16
  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); }
17
+ import { List, fromJS, Set } from 'immutable';
18
+ import * as fuzzy from 'fuzzy';
19
+ import { localForage, Cursor, CURSOR_COMPATIBILITY_SYMBOL, getPathDepth, blobToFileObj, asyncLock, EDITORIAL_WORKFLOW_ERROR } from 'decap-cms-lib-util';
20
+ import { basename, join, extname, dirname } from 'path';
21
+ import { stringTemplate } from 'decap-cms-lib-widgets';
22
+ import { resolveFormat } from './formats/formats';
23
+ import { selectUseWorkflow } from './reducers/config';
24
+ import { selectMediaFilePath, selectEntry } from './reducers/entries';
25
+ import { selectIntegration } from './reducers/integrations';
26
+ import { selectEntrySlug, selectEntryPath, selectFileEntryLabel, selectAllowNewEntries, selectAllowDeletion, selectFolderEntryExtension, selectInferredField, selectMediaFolders, selectFieldsComments, selectHasMetaPath } from './reducers/collections';
27
+ import { createEntry } from './valueObjects/Entry';
28
+ import { sanitizeChar } from './lib/urlHelper';
29
+ import { getBackend, invokeEvent } from './lib/registry';
30
+ import { commitMessageFormatter, slugFormatter, previewUrlFormatter } from './lib/formatters';
31
+ import { status } from './constants/publishModes';
32
+ import { FOLDER, FILES } from './constants/collectionTypes';
33
+ import { selectCustomPath } from './reducers/entryDraft';
34
+ import { getI18nFilesDepth, getI18nFiles, hasI18n, getFilePaths, getI18nEntry, groupEntries, getI18nDataFiles, getI18nBackup, formatI18nBackup, getI18nInfo, I18N_STRUCTURE } from './lib/i18n';
49
35
  const {
50
36
  extractTemplateVars,
51
37
  dateParsers,
52
38
  expandPath
53
- } = _decapCmsLibWidgets.stringTemplate;
39
+ } = stringTemplate;
54
40
  function updateAssetProxies(assetProxies, config, collection, entryDraft, path) {
55
41
  assetProxies.map(asset => {
56
42
  // update media files path based on entry path
57
43
  const oldPath = asset.path;
58
- const newPath = (0, _entries.selectMediaFilePath)(config, collection, entryDraft.get('entry').set('path', path), oldPath, asset.field);
44
+ const newPath = selectMediaFilePath(config, collection, entryDraft.get('entry').set('path', path), oldPath, asset.field);
59
45
  asset.path = newPath;
60
46
  });
61
47
  }
62
- class LocalStorageAuthStore {
48
+ export class LocalStorageAuthStore {
63
49
  constructor() {
64
50
  _defineProperty(this, "storageKey", 'decap-cms-user');
65
51
  }
@@ -74,7 +60,6 @@ class LocalStorageAuthStore {
74
60
  window.localStorage.removeItem(this.storageKey);
75
61
  }
76
62
  }
77
- exports.LocalStorageAuthStore = LocalStorageAuthStore;
78
63
  function getEntryBackupKey(collectionName, slug) {
79
64
  const baseKey = 'backup';
80
65
  if (!collectionName) {
@@ -84,7 +69,7 @@ function getEntryBackupKey(collectionName, slug) {
84
69
  return `${baseKey}.${collectionName}${suffix}`;
85
70
  }
86
71
  function getEntryField(field, entry) {
87
- const value = (0, _get2.default)(entry.data, field);
72
+ const value = _get(entry.data, field);
88
73
  if (value) {
89
74
  return String(value);
90
75
  } else {
@@ -97,7 +82,7 @@ function getEntryField(field, entry) {
97
82
  }
98
83
  }
99
84
  }
100
- function extractSearchFields(searchFields) {
85
+ export function extractSearchFields(searchFields) {
101
86
  return entry => searchFields.reduce((acc, field) => {
102
87
  const value = getEntryField(field, entry);
103
88
  if (value) {
@@ -107,7 +92,7 @@ function extractSearchFields(searchFields) {
107
92
  }
108
93
  }, '');
109
94
  }
110
- function expandSearchEntries(entries, searchFields) {
95
+ export function expandSearchEntries(entries, searchFields) {
111
96
  // expand the entries for the purpose of the search
112
97
  const expandedEntries = entries.reduce((acc, e) => {
113
98
  const expandedFields = searchFields.reduce((acc, f) => {
@@ -127,7 +112,7 @@ function expandSearchEntries(entries, searchFields) {
127
112
  }, []);
128
113
  return expandedEntries;
129
114
  }
130
- function mergeExpandedEntries(entries) {
115
+ export function mergeExpandedEntries(entries) {
131
116
  // merge the search results by slug and only keep data that matched the search
132
117
  const fields = entries.map(f => f.field);
133
118
  const arrayPaths = {};
@@ -139,7 +124,7 @@ function mergeExpandedEntries(entries) {
139
124
  } = e,
140
125
  rest = _objectWithoutProperties(e, _excluded);
141
126
  acc[e.slug] = rest;
142
- arrayPaths[e.slug] = (0, _immutable.Set)();
127
+ arrayPaths[e.slug] = Set();
143
128
  }
144
129
  const nestedFields = e.field.split('.');
145
130
  let value = acc[e.slug].data;
@@ -158,7 +143,7 @@ function mergeExpandedEntries(entries) {
158
143
  Object.keys(merged).forEach(slug => {
159
144
  const data = merged[slug].data;
160
145
  for (const path of arrayPaths[slug].toArray()) {
161
- const array = (0, _get2.default)(data, path);
146
+ const array = _get(data, path);
162
147
  const filtered = array.filter((_, index) => {
163
148
  return fields.some(f => `${f}.`.startsWith(`${path}.${index}.`));
164
149
  });
@@ -171,7 +156,7 @@ function mergeExpandedEntries(entries) {
171
156
  const matchingFieldIndexB = fields.findIndex(f => `${f}.`.startsWith(pathOfB));
172
157
  return matchingFieldIndexA - matchingFieldIndexB;
173
158
  });
174
- (0, _set2.default)(data, path, filtered);
159
+ _set(data, path, filtered);
175
160
  }
176
161
  });
177
162
  return Object.values(merged);
@@ -181,25 +166,25 @@ function sortByScore(a, b) {
181
166
  if (a.score < b.score) return 1;
182
167
  return 0;
183
168
  }
184
- function slugFromCustomPath(collection, customPath) {
169
+ export function slugFromCustomPath(collection, customPath) {
185
170
  const folderPath = collection.get('folder', '');
186
171
  const entryPath = customPath.toLowerCase().replace(folderPath.toLowerCase(), '');
187
- const slug = (0, _path.join)((0, _path.dirname)((0, _trim2.default)(entryPath, '/')), (0, _path.basename)(entryPath, (0, _path.extname)(customPath)));
172
+ const slug = join(dirname(_trim(entryPath, '/')), basename(entryPath, extname(customPath)));
188
173
  return slug;
189
174
  }
190
175
  function prepareMetaPath(path, collection) {
191
- if (!(0, _collections.selectHasMetaPath)(collection)) {
176
+ if (!selectHasMetaPath(collection)) {
192
177
  return path;
193
178
  }
194
- const dir = (0, _path.dirname)(path);
179
+ const dir = dirname(path);
195
180
  return dir.slice(collection.get('folder').length + 1) || '/';
196
181
  }
197
182
  function collectionDepth(collection) {
198
183
  var _collection$get;
199
184
  let depth;
200
- depth = ((_collection$get = collection.get('nested')) === null || _collection$get === void 0 ? void 0 : _collection$get.get('depth')) || (0, _decapCmsLibUtil.getPathDepth)(collection.get('path', ''));
201
- if ((0, _i18n.hasI18n)(collection)) {
202
- depth = (0, _i18n.getI18nFilesDepth)(collection, depth);
185
+ depth = ((_collection$get = collection.get('nested')) === null || _collection$get === void 0 ? void 0 : _collection$get.get('depth')) || getPathDepth(collection.get('path', ''));
186
+ if (hasI18n(collection)) {
187
+ depth = getI18nFilesDepth(collection, depth);
203
188
  }
204
189
  return depth;
205
190
  }
@@ -207,10 +192,10 @@ function i18nRulestring(ruleString, {
207
192
  defaultLocale,
208
193
  structure
209
194
  }) {
210
- if (structure === _i18n.I18N_STRUCTURE.MULTIPLE_FOLDERS) {
195
+ if (structure === I18N_STRUCTURE.MULTIPLE_FOLDERS) {
211
196
  return `${defaultLocale}\\/${ruleString}`;
212
197
  }
213
- if (structure === _i18n.I18N_STRUCTURE.MULTIPLE_FILES) {
198
+ if (structure === I18N_STRUCTURE.MULTIPLE_FILES) {
214
199
  return `${ruleString}\\.${defaultLocale}\\..*`;
215
200
  }
216
201
  return ruleString;
@@ -220,12 +205,12 @@ function collectionRegex(collection) {
220
205
  if (collection.get('path')) {
221
206
  ruleString = `${collection.get('folder')}/${collection.get('path')}`.replace(/{{.*}}/gm, '(.*)');
222
207
  }
223
- if ((0, _i18n.hasI18n)(collection)) {
224
- ruleString = i18nRulestring(ruleString, (0, _i18n.getI18nInfo)(collection));
208
+ if (hasI18n(collection)) {
209
+ ruleString = i18nRulestring(ruleString, getI18nInfo(collection));
225
210
  }
226
211
  return ruleString ? new RegExp(ruleString) : undefined;
227
212
  }
228
- class Backend {
213
+ export class Backend {
229
214
  constructor(implementation, {
230
215
  backendName,
231
216
  authStore,
@@ -250,16 +235,16 @@ class Backend {
250
235
  this.deleteAnonymousBackup();
251
236
  this.config = config;
252
237
  this.implementation = implementation.init(this.config, {
253
- useWorkflow: (0, _config.selectUseWorkflow)(this.config),
238
+ useWorkflow: selectUseWorkflow(this.config),
254
239
  updateUserCredentials: this.updateUserCredentials,
255
- initialWorkflowStatus: _publishModes.status.first()
240
+ initialWorkflowStatus: status.first()
256
241
  });
257
242
  this.backendName = backendName;
258
243
  this.authStore = authStore;
259
244
  if (this.implementation === null) {
260
245
  throw new Error('Cannot instantiate a Backend with no implementation');
261
246
  }
262
- this.backupSync = (0, _decapCmsLibUtil.asyncLock)();
247
+ this.backupSync = asyncLock();
263
248
  }
264
249
  async status() {
265
250
  const attempts = 3;
@@ -335,7 +320,7 @@ class Backend {
335
320
  collection: collection.get('name'),
336
321
  slug
337
322
  }).catch(error => {
338
- if (error.name === _decapCmsLibUtil.EDITORIAL_WORKFLOW_ERROR && error.notUnderEditorialWorkflow) {
323
+ if (error.name === EDITORIAL_WORKFLOW_ERROR && error.notUnderEditorialWorkflow) {
339
324
  return Promise.resolve(false);
340
325
  }
341
326
  return Promise.reject(error);
@@ -354,19 +339,19 @@ class Backend {
354
339
  if (customPath) {
355
340
  slug = slugFromCustomPath(collection, customPath);
356
341
  } else {
357
- slug = (0, _formatters.slugFormatter)(collection, entryData, slugConfig);
342
+ slug = slugFormatter(collection, entryData, slugConfig);
358
343
  }
359
344
  let i = 1;
360
345
  let uniqueSlug = slug;
361
346
 
362
347
  // Check for duplicate slug in loaded entities store first before repo
363
- while (usedSlugs.includes(uniqueSlug) || (await this.entryExist(collection, (0, _collections.selectEntryPath)(collection, uniqueSlug), uniqueSlug, (0, _config.selectUseWorkflow)(config)))) {
364
- uniqueSlug = `${slug}${(0, _urlHelper.sanitizeChar)(' ', slugConfig)}${i++}`;
348
+ while (usedSlugs.includes(uniqueSlug) || (await this.entryExist(collection, selectEntryPath(collection, uniqueSlug), uniqueSlug, selectUseWorkflow(config)))) {
349
+ uniqueSlug = `${slug}${sanitizeChar(' ', slugConfig)}${i++}`;
365
350
  }
366
351
  return uniqueSlug;
367
352
  }
368
353
  processEntries(loadedEntries, collection) {
369
- const entries = loadedEntries.map(loadedEntry => (0, _Entry.createEntry)(collection.get('name'), (0, _collections.selectEntrySlug)(collection, loadedEntry.file.path), loadedEntry.file.path, {
354
+ const entries = loadedEntries.map(loadedEntry => createEntry(collection.get('name'), selectEntrySlug(collection, loadedEntry.file.path), loadedEntry.file.path, {
370
355
  raw: loadedEntry.data || '',
371
356
  label: loadedEntry.file.label,
372
357
  author: loadedEntry.file.author,
@@ -381,24 +366,24 @@ class Backend {
381
366
  const filteredEntries = collectionFilter ? this.filterEntries({
382
367
  entries: formattedEntries
383
368
  }, collectionFilter) : formattedEntries;
384
- if ((0, _i18n.hasI18n)(collection)) {
385
- const extension = (0, _collections.selectFolderEntryExtension)(collection);
386
- const groupedEntries = (0, _i18n.groupEntries)(collection, extension, filteredEntries);
369
+ if (hasI18n(collection)) {
370
+ const extension = selectFolderEntryExtension(collection);
371
+ const groupedEntries = groupEntries(collection, extension, filteredEntries);
387
372
  return groupedEntries;
388
373
  }
389
374
  return filteredEntries;
390
375
  }
391
376
  async listEntries(collection) {
392
377
  var _cursor$meta;
393
- const extension = (0, _collections.selectFolderEntryExtension)(collection);
378
+ const extension = selectFolderEntryExtension(collection);
394
379
  let listMethod;
395
380
  const collectionType = collection.get('type');
396
- if (collectionType === _collectionTypes.FOLDER) {
381
+ if (collectionType === FOLDER) {
397
382
  listMethod = () => {
398
383
  const depth = collectionDepth(collection);
399
384
  return this.implementation.entriesByFolder(collection.get('folder'), extension, depth);
400
385
  };
401
- } else if (collectionType === _collectionTypes.FILES) {
386
+ } else if (collectionType === FILES) {
402
387
  const files = collection.get('files').map(collectionFile => ({
403
388
  path: collectionFile.get('file'),
404
389
  label: collectionFile.get('label')
@@ -415,7 +400,7 @@ class Backend {
415
400
  */
416
401
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
417
402
  // @ts-ignore
418
- const cursor = _decapCmsLibUtil.Cursor.create(loadedEntries[_decapCmsLibUtil.CURSOR_COMPATIBILITY_SYMBOL]).wrapData({
403
+ const cursor = Cursor.create(loadedEntries[CURSOR_COMPATIBILITY_SYMBOL]).wrapData({
419
404
  cursorType: 'collectionEntries',
420
405
  collection
421
406
  });
@@ -434,7 +419,7 @@ class Backend {
434
419
  async listAllEntries(collection) {
435
420
  if (collection.get('folder') && this.implementation.allEntriesByFolder) {
436
421
  const depth = collectionDepth(collection);
437
- const extension = (0, _collections.selectFolderEntryExtension)(collection);
422
+ const extension = selectFolderEntryExtension(collection);
438
423
  return this.implementation.allEntriesByFolder(collection.get('folder'), extension, depth, collectionRegex(collection)).then(entries => this.processEntries(entries, collection));
439
424
  }
440
425
  const response = await this.listEntries(collection);
@@ -465,16 +450,16 @@ class Backend {
465
450
 
466
451
  // TODO: pass search fields in as an argument
467
452
  let searchFields = [];
468
- if (collection.get('type') === _collectionTypes.FILES) {
453
+ if (collection.get('type') === FILES) {
469
454
  var _collection$get2;
470
455
  (_collection$get2 = collection.get('files')) === null || _collection$get2 === void 0 ? void 0 : _collection$get2.forEach(f => {
471
456
  const topLevelFields = f.get('fields').map(f => f.get('name')).toArray();
472
457
  searchFields = [...searchFields, ...topLevelFields];
473
458
  });
474
459
  } else {
475
- searchFields = [(0, _collections.selectInferredField)(collection, 'title'), (0, _collections.selectInferredField)(collection, 'shortTitle'), (0, _collections.selectInferredField)(collection, 'author'), ...summaryFields.map(elem => {
460
+ searchFields = [selectInferredField(collection, 'title'), selectInferredField(collection, 'shortTitle'), selectInferredField(collection, 'author'), ...summaryFields.map(elem => {
476
461
  if (dateParsers[elem]) {
477
- return (0, _collections.selectInferredField)(collection, 'date');
462
+ return selectInferredField(collection, 'date');
478
463
  }
479
464
  return elem;
480
465
  })];
@@ -482,13 +467,13 @@ class Backend {
482
467
  const filteredSearchFields = searchFields.filter(Boolean);
483
468
  const collectionEntries = await this.listAllEntries(collection);
484
469
  return fuzzy.filter(searchTerm, collectionEntries, {
485
- extract: extractSearchFields((0, _uniq2.default)(filteredSearchFields))
470
+ extract: extractSearchFields(_uniq(filteredSearchFields))
486
471
  });
487
472
  }).map(p => p.catch(err => {
488
473
  errors.push(err);
489
474
  return [];
490
475
  }));
491
- const entries = await Promise.all(collectionEntriesRequests).then(arrays => (0, _flatten2.default)(arrays));
476
+ const entries = await Promise.all(collectionEntriesRequests).then(arrays => _flatten(arrays));
492
477
  if (errors.length > 0) {
493
478
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
494
479
  // @ts-ignore
@@ -533,7 +518,7 @@ class Backend {
533
518
  cursor: newCursor
534
519
  }) => ({
535
520
  entries: this.processEntries(entries, collection),
536
- cursor: _decapCmsLibUtil.Cursor.create(newCursor).wrapData({
521
+ cursor: Cursor.create(newCursor).wrapData({
537
522
  cursorType: 'collectionEntries',
538
523
  collection
539
524
  })
@@ -541,7 +526,7 @@ class Backend {
541
526
  }
542
527
  async getLocalDraftBackup(collection, slug) {
543
528
  const key = getEntryBackupKey(collection.get('name'), slug);
544
- const backup = await _decapCmsLibUtil.localForage.getItem(key);
529
+ const backup = await localForage.getItem(key);
545
530
  if (!backup || !backup.raw.trim()) {
546
531
  return {};
547
532
  }
@@ -561,9 +546,9 @@ class Backend {
561
546
  }
562
547
  return file;
563
548
  });
564
- const label = (0, _collections.selectFileEntryLabel)(collection, slug);
549
+ const label = selectFileEntryLabel(collection, slug);
565
550
  const formatRawData = raw => {
566
- return this.entryWithFormat(collection)((0, _Entry.createEntry)(collection.get('name'), slug, path, {
551
+ return this.entryWithFormat(collection)(createEntry(collection.get('name'), slug, path, {
567
552
  raw,
568
553
  label,
569
554
  mediaFiles,
@@ -573,8 +558,8 @@ class Backend {
573
558
  }));
574
559
  };
575
560
  const entry = formatRawData(raw);
576
- if ((0, _i18n.hasI18n)(collection) && backup.i18n) {
577
- const i18n = (0, _i18n.formatI18nBackup)(backup.i18n, formatRawData);
561
+ if (hasI18n(collection) && backup.i18n) {
562
+ const i18n = formatI18nBackup(backup.i18n, formatRawData);
578
563
  entry.i18n = i18n;
579
564
  }
580
565
  return {
@@ -595,23 +580,23 @@ class Backend {
595
580
  if ((_file$url = file.url) !== null && _file$url !== void 0 && _file$url.startsWith('blob:')) {
596
581
  const blob = await fetch(file.url).then(res => res.blob());
597
582
  return _objectSpread(_objectSpread({}, file), {}, {
598
- file: (0, _decapCmsLibUtil.blobToFileObj)(file.name, blob)
583
+ file: blobToFileObj(file.name, blob)
599
584
  });
600
585
  }
601
586
  return file;
602
587
  }));
603
588
  let i18n;
604
- if ((0, _i18n.hasI18n)(collection)) {
605
- i18n = (0, _i18n.getI18nBackup)(collection, entry, entry => this.entryToRaw(collection, entry));
589
+ if (hasI18n(collection)) {
590
+ i18n = getI18nBackup(collection, entry, entry => this.entryToRaw(collection, entry));
606
591
  }
607
- await _decapCmsLibUtil.localForage.setItem(key, _objectSpread({
592
+ await localForage.setItem(key, _objectSpread({
608
593
  raw,
609
594
  path: entry.get('path'),
610
595
  mediaFiles
611
596
  }, i18n && {
612
597
  i18n
613
598
  }));
614
- const result = await _decapCmsLibUtil.localForage.setItem(getEntryBackupKey(), raw);
599
+ const result = await localForage.setItem(getEntryBackupKey(), raw);
615
600
  return result;
616
601
  } catch (e) {
617
602
  console.warn('persistLocalDraftBackup', e);
@@ -622,9 +607,9 @@ class Backend {
622
607
  async deleteLocalDraftBackup(collection, slug) {
623
608
  try {
624
609
  await this.backupSync.acquire();
625
- await _decapCmsLibUtil.localForage.removeItem(getEntryBackupKey(collection.get('name'), slug));
610
+ await localForage.removeItem(getEntryBackupKey(collection.get('name'), slug));
626
611
  // delete new entry backup if not deleted
627
- slug && (await _decapCmsLibUtil.localForage.removeItem(getEntryBackupKey(collection.get('name'))));
612
+ slug && (await localForage.removeItem(getEntryBackupKey(collection.get('name'))));
628
613
  const result = await this.deleteAnonymousBackup();
629
614
  return result;
630
615
  } catch (e) {
@@ -637,15 +622,15 @@ class Backend {
637
622
  // Unnamed backup for use in the global error boundary, should always be
638
623
  // deleted on cms load.
639
624
  deleteAnonymousBackup() {
640
- return _decapCmsLibUtil.localForage.removeItem(getEntryBackupKey());
625
+ return localForage.removeItem(getEntryBackupKey());
641
626
  }
642
627
  async getEntry(state, collection, slug) {
643
- const path = (0, _collections.selectEntryPath)(collection, slug);
644
- const label = (0, _collections.selectFileEntryLabel)(collection, slug);
645
- const extension = (0, _collections.selectFolderEntryExtension)(collection);
628
+ const path = selectEntryPath(collection, slug);
629
+ const label = selectFileEntryLabel(collection, slug);
630
+ const extension = selectFolderEntryExtension(collection);
646
631
  const getEntryValue = async path => {
647
632
  const loadedEntry = await this.implementation.getEntry(path);
648
- let entry = (0, _Entry.createEntry)(collection.get('name'), slug, loadedEntry.file.path, {
633
+ let entry = createEntry(collection.get('name'), slug, loadedEntry.file.path, {
649
634
  raw: loadedEntry.data,
650
635
  label,
651
636
  mediaFiles: [],
@@ -658,8 +643,8 @@ class Backend {
658
643
  return entry;
659
644
  };
660
645
  let entryValue;
661
- if ((0, _i18n.hasI18n)(collection)) {
662
- entryValue = await (0, _i18n.getI18nEntry)(collection, extension, path, slug, getEntryValue);
646
+ if (hasI18n(collection)) {
647
+ entryValue = await getI18nEntry(collection, extension, path, slug, getEntryValue);
663
648
  } else {
664
649
  entryValue = await getEntryValue(path);
665
650
  }
@@ -681,12 +666,12 @@ class Backend {
681
666
  }
682
667
  entryWithFormat(collection) {
683
668
  return entry => {
684
- const format = (0, _formats.resolveFormat)(collection, entry);
669
+ const format = resolveFormat(collection, entry);
685
670
  if (entry && entry.raw !== undefined) {
686
- const data = format && (0, _attempt2.default)(format.fromFile.bind(format, entry.raw)) || {};
687
- if ((0, _isError2.default)(data)) console.error(data);
671
+ const data = format && _attempt(format.fromFile.bind(format, entry.raw)) || {};
672
+ if (_isError(data)) console.error(data);
688
673
  return Object.assign(entry, {
689
- data: (0, _isError2.default)(data) ? {} : data
674
+ data: _isError(data) ? {} : data
690
675
  });
691
676
  }
692
677
  return format.fromFile(entry);
@@ -697,11 +682,11 @@ class Backend {
697
682
  slug
698
683
  } = entryData;
699
684
  let extension;
700
- if (collection.get('type') === _collectionTypes.FILES) {
685
+ if (collection.get('type') === FILES) {
701
686
  const file = collection.get('files').find(f => (f === null || f === void 0 ? void 0 : f.get('name')) === slug);
702
- extension = (0, _path.extname)(file.get('file'));
687
+ extension = extname(file.get('file'));
703
688
  } else {
704
- extension = (0, _collections.selectFolderEntryExtension)(collection);
689
+ extension = selectFolderEntryExtension(collection);
705
690
  }
706
691
  const mediaFiles = [];
707
692
  if (withMediaFiles) {
@@ -711,12 +696,12 @@ class Backend {
711
696
  draft: true
712
697
  })));
713
698
  }
714
- const dataFiles = (0, _sortBy2.default)(entryData.diffs.filter(d => d.path.endsWith(extension)), f => f.path.length);
699
+ const dataFiles = _sortBy(entryData.diffs.filter(d => d.path.endsWith(extension)), f => f.path.length);
715
700
  const formatData = (data, path, newFile) => {
716
- const entry = (0, _Entry.createEntry)(collection.get('name'), slug, path, {
701
+ const entry = createEntry(collection.get('name'), slug, path, {
717
702
  raw: data,
718
703
  isModification: !newFile,
719
- label: collection && (0, _collections.selectFileEntryLabel)(collection, slug),
704
+ label: collection && selectFileEntryLabel(collection, slug),
720
705
  mediaFiles,
721
706
  updatedOn: entryData.updatedAt,
722
707
  author: entryData.pullRequestAuthor,
@@ -736,15 +721,15 @@ class Backend {
736
721
 
737
722
  // if the unpublished entry has no diffs, return the original
738
723
  if (dataFiles.length <= 0) {
739
- const loadedEntry = await this.implementation.getEntry((0, _collections.selectEntryPath)(collection, slug));
724
+ const loadedEntry = await this.implementation.getEntry(selectEntryPath(collection, slug));
740
725
  return formatData(loadedEntry.data, loadedEntry.file.path, false);
741
- } else if ((0, _i18n.hasI18n)(collection)) {
726
+ } else if (hasI18n(collection)) {
742
727
  // we need to read all locales files and not just the changes
743
- const path = (0, _collections.selectEntryPath)(collection, slug);
744
- const i18nFiles = (0, _i18n.getI18nDataFiles)(collection, extension, path, slug, dataFiles);
728
+ const path = selectEntryPath(collection, slug);
729
+ const i18nFiles = getI18nDataFiles(collection, extension, path, slug, dataFiles);
745
730
  let entries = await Promise.all(i18nFiles.map(dataFile => readAndFormatDataFile(dataFile).catch(() => null)));
746
731
  entries = entries.filter(Boolean);
747
- const grouped = await (0, _i18n.groupEntries)(collection, extension, entries);
732
+ const grouped = await groupEntries(collection, extension, entries);
748
733
  return grouped[0];
749
734
  } else {
750
735
  const entryWithFormat = await readAndFormatDataFile(dataFiles[0]);
@@ -772,8 +757,8 @@ class Backend {
772
757
  };
773
758
  }
774
759
  async processEntry(state, collection, entry) {
775
- const integration = (0, _integrations.selectIntegration)(state.integrations, null, 'assetStore');
776
- const mediaFolders = (0, _collections.selectMediaFolders)(state.config, collection, (0, _immutable.fromJS)(entry));
760
+ const integration = selectIntegration(state.integrations, null, 'assetStore');
761
+ const mediaFolders = selectMediaFolders(state.config, collection, fromJS(entry));
777
762
  if (mediaFolders.length > 0 && !integration) {
778
763
  const files = await Promise.all(mediaFolders.map(folder => this.implementation.getMedia(folder)));
779
764
  entry.mediaFiles = entry.mediaFiles.concat(...files);
@@ -807,7 +792,7 @@ class Backend {
807
792
  return;
808
793
  }
809
794
  return {
810
- url: (0, _formatters.previewUrlFormatter)(baseUrl, collection, slug, entry, this.config.slug),
795
+ url: previewUrlFormatter(baseUrl, collection, slug, entry, this.config.slug),
811
796
  status: 'SUCCESS'
812
797
  };
813
798
  }
@@ -853,7 +838,7 @@ class Backend {
853
838
  /**
854
839
  * Create a URL using the collection `preview_path`, if provided.
855
840
  */
856
- url: (0, _formatters.previewUrlFormatter)(deployPreview.url, collection, slug, entry, this.config.slug),
841
+ url: previewUrlFormatter(deployPreview.url, collection, slug, entry, this.config.slug),
857
842
  /**
858
843
  * Always capitalize the status for consistency.
859
844
  */
@@ -877,15 +862,15 @@ class Backend {
877
862
  entryDraft = updatedEntity && draft.setIn(['entry'], updatedEntity) || draft;
878
863
  }
879
864
  const newEntry = entryDraft.getIn(['entry', 'newRecord']) || false;
880
- const useWorkflow = (0, _config.selectUseWorkflow)(config);
881
- const customPath = (0, _entryDraft.selectCustomPath)(collection, entryDraft);
865
+ const useWorkflow = selectUseWorkflow(config);
866
+ const customPath = selectCustomPath(collection, entryDraft);
882
867
  let dataFile;
883
868
  if (newEntry) {
884
- if (!(0, _collections.selectAllowNewEntries)(collection)) {
869
+ if (!selectAllowNewEntries(collection)) {
885
870
  throw new Error('Not allowed to create new entries in this collection');
886
871
  }
887
872
  const slug = await this.generateUniqueSlug(collection, entryDraft.getIn(['entry', 'data']), config, usedSlugs, customPath);
888
- const path = customPath || (0, _collections.selectEntryPath)(collection, slug);
873
+ const path = customPath || selectEntryPath(collection, slug);
889
874
  dataFile = {
890
875
  path,
891
876
  slug,
@@ -908,12 +893,12 @@ class Backend {
908
893
  newPath
909
894
  } = dataFile;
910
895
  let dataFiles = [dataFile];
911
- if ((0, _i18n.hasI18n)(collection)) {
912
- const extension = (0, _collections.selectFolderEntryExtension)(collection);
913
- dataFiles = (0, _i18n.getI18nFiles)(collection, extension, entryDraft.get('entry'), draftData => this.entryToRaw(collection, draftData), path, slug, newPath);
896
+ if (hasI18n(collection)) {
897
+ const extension = selectFolderEntryExtension(collection);
898
+ dataFiles = getI18nFiles(collection, extension, entryDraft.get('entry'), draftData => this.entryToRaw(collection, draftData), path, slug, newPath);
914
899
  }
915
900
  const user = await this.currentUser();
916
- const commitMessage = (0, _formatters.commitMessageFormatter)(newEntry ? 'create' : 'update', config, {
901
+ const commitMessage = commitMessageFormatter(newEntry ? 'create' : 'update', config, {
917
902
  collection,
918
903
  slug,
919
904
  path,
@@ -949,7 +934,7 @@ class Backend {
949
934
  login,
950
935
  name
951
936
  } = await this.currentUser();
952
- return await (0, _registry.invokeEvent)({
937
+ return await invokeEvent({
953
938
  name: event,
954
939
  data: {
955
940
  entry,
@@ -981,7 +966,7 @@ class Backend {
981
966
  async persistMedia(config, file) {
982
967
  const user = await this.currentUser();
983
968
  const options = {
984
- commitMessage: (0, _formatters.commitMessageFormatter)('uploadMedia', config, {
969
+ commitMessage: commitMessageFormatter('uploadMedia', config, {
985
970
  path: file.path,
986
971
  authorLogin: user.login,
987
972
  authorName: user.name
@@ -991,31 +976,31 @@ class Backend {
991
976
  }
992
977
  async deleteEntry(state, collection, slug) {
993
978
  const config = state.config;
994
- const path = (0, _collections.selectEntryPath)(collection, slug);
995
- const extension = (0, _collections.selectFolderEntryExtension)(collection);
996
- if (!(0, _collections.selectAllowDeletion)(collection)) {
979
+ const path = selectEntryPath(collection, slug);
980
+ const extension = selectFolderEntryExtension(collection);
981
+ if (!selectAllowDeletion(collection)) {
997
982
  throw new Error('Not allowed to delete entries in this collection');
998
983
  }
999
984
  const user = await this.currentUser();
1000
- const commitMessage = (0, _formatters.commitMessageFormatter)('delete', config, {
985
+ const commitMessage = commitMessageFormatter('delete', config, {
1001
986
  collection,
1002
987
  slug,
1003
988
  path,
1004
989
  authorLogin: user.login,
1005
990
  authorName: user.name
1006
991
  }, user.useOpenAuthoring);
1007
- const entry = (0, _entries.selectEntry)(state.entries, collection.get('name'), slug);
992
+ const entry = selectEntry(state.entries, collection.get('name'), slug);
1008
993
  await this.invokePreUnpublishEvent(entry);
1009
994
  let paths = [path];
1010
- if ((0, _i18n.hasI18n)(collection)) {
1011
- paths = (0, _i18n.getFilePaths)(collection, extension, path, slug);
995
+ if (hasI18n(collection)) {
996
+ paths = getFilePaths(collection, extension, path, slug);
1012
997
  }
1013
998
  await this.implementation.deleteFiles(paths, commitMessage);
1014
999
  await this.invokePostUnpublishEvent(entry);
1015
1000
  }
1016
1001
  async deleteMedia(config, path) {
1017
1002
  const user = await this.currentUser();
1018
- const commitMessage = (0, _formatters.commitMessageFormatter)('deleteMedia', config, {
1003
+ const commitMessage = commitMessageFormatter('deleteMedia', config, {
1019
1004
  path,
1020
1005
  authorLogin: user.login,
1021
1006
  authorName: user.name
@@ -1041,9 +1026,9 @@ class Backend {
1041
1026
  return this.implementation.deleteUnpublishedEntry(collection, slug);
1042
1027
  }
1043
1028
  entryToRaw(collection, entry) {
1044
- const format = (0, _formats.resolveFormat)(collection, entry.toJS());
1029
+ const format = resolveFormat(collection, entry.toJS());
1045
1030
  const fieldsOrder = this.fieldsOrder(collection, entry);
1046
- const fieldsComments = (0, _collections.selectFieldsComments)(collection, entry);
1031
+ const fieldsComments = selectFieldsComments(collection, entry);
1047
1032
  let content = format.toFile(entry.get('data').toJS(), fieldsOrder, fieldsComments);
1048
1033
  if (content.slice(-1) != '\n') {
1049
1034
  // add the EOL if it does not exist.
@@ -1057,7 +1042,7 @@ class Backend {
1057
1042
  return collection.get('fields').map(f => f.get('name')).toArray();
1058
1043
  }
1059
1044
  const files = collection.get('files');
1060
- const file = (files || (0, _immutable.List)()).filter(f => f.get('name') === entry.get('slug')).get(0);
1045
+ const file = (files || List()).filter(f => f.get('name') === entry.get('slug')).get(0);
1061
1046
  if (file == null) {
1062
1047
  throw new Error(`No file found for ${entry.get('slug')} in ${collection.get('name')}`);
1063
1048
  }
@@ -1073,8 +1058,7 @@ class Backend {
1073
1058
  });
1074
1059
  }
1075
1060
  }
1076
- exports.Backend = Backend;
1077
- function resolveBackend(config) {
1061
+ export function resolveBackend(config) {
1078
1062
  if (!config.backend.name) {
1079
1063
  throw new Error('No backend defined in configuration');
1080
1064
  }
@@ -1082,7 +1066,7 @@ function resolveBackend(config) {
1082
1066
  name
1083
1067
  } = config.backend;
1084
1068
  const authStore = new LocalStorageAuthStore();
1085
- const backend = (0, _registry.getBackend)(name);
1069
+ const backend = getBackend(name);
1086
1070
  if (!backend) {
1087
1071
  throw new Error(`Backend not found: ${name}`);
1088
1072
  } else {
@@ -1093,7 +1077,7 @@ function resolveBackend(config) {
1093
1077
  });
1094
1078
  }
1095
1079
  }
1096
- const currentBackend = exports.currentBackend = function () {
1080
+ export const currentBackend = function () {
1097
1081
  let backend;
1098
1082
  return config => {
1099
1083
  if (backend) {