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,8 +1,2 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.FOLDER = exports.FILES = void 0;
7
- const FILES = exports.FILES = 'file_based_collection';
8
- const FOLDER = exports.FOLDER = 'folder_based_collection';
1
+ export const FILES = 'file_based_collection';
2
+ export const FOLDER = 'folder_based_collection';
@@ -1,8 +1,2 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.VIEW_STYLE_LIST = exports.VIEW_STYLE_GRID = void 0;
7
- const VIEW_STYLE_LIST = exports.VIEW_STYLE_LIST = 'VIEW_STYLE_LIST';
8
- const VIEW_STYLE_GRID = exports.VIEW_STYLE_GRID = 'VIEW_STYLE_GRID';
1
+ export const VIEW_STYLE_LIST = 'VIEW_STYLE_LIST';
2
+ export const VIEW_STYLE_GRID = 'VIEW_STYLE_GRID';
@@ -1,8 +1,2 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.COMMIT_DATE = exports.COMMIT_AUTHOR = void 0;
7
- const COMMIT_AUTHOR = exports.COMMIT_AUTHOR = 'commit_author';
8
- const COMMIT_DATE = exports.COMMIT_DATE = 'commit_date';
1
+ export const COMMIT_AUTHOR = 'commit_author';
2
+ export const COMMIT_DATE = 'commit_date';
@@ -1,17 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.validateConfig = validateConfig;
7
- var _ajv = _interopRequireDefault(require("ajv"));
8
- var _keywords = require("ajv-keywords/dist/keywords");
9
- var _ajvErrors = _interopRequireDefault(require("ajv-errors"));
10
- var _uuid = require("uuid");
11
- var _formats = require("../formats/formats");
12
- var _registry = require("../lib/registry");
13
- var _i18n = require("../lib/i18n");
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
1
  function _extendableBuiltin(cls) {
16
2
  function ExtendableBuiltin() {
17
3
  var instance = Reflect.construct(cls, Array.from(arguments));
@@ -38,6 +24,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
38
24
  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; }
39
25
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
40
26
  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); }
27
+ import AJV from 'ajv';
28
+ import { select, uniqueItemProperties, instanceof as instanceOf, prohibited } from 'ajv-keywords/dist/keywords';
29
+ import ajvErrors from 'ajv-errors';
30
+ import { v4 as uuid } from 'uuid';
31
+ import { frontmatterFormats, extensionFormatters } from '../formats/formats';
32
+ import { getWidgets } from '../lib/registry';
33
+ import { I18N_STRUCTURE, I18N_FIELD } from '../lib/i18n';
41
34
  const localeType = {
42
35
  type: 'string',
43
36
  minLength: 2,
@@ -49,7 +42,7 @@ const i18n = {
49
42
  properties: {
50
43
  structure: {
51
44
  type: 'string',
52
- enum: Object.values(_i18n.I18N_STRUCTURE)
45
+ enum: Object.values(I18N_STRUCTURE)
53
46
  },
54
47
  locales: {
55
48
  type: 'array',
@@ -73,7 +66,7 @@ const i18nField = {
73
66
  type: 'boolean'
74
67
  }, {
75
68
  type: 'string',
76
- enum: Object.values(_i18n.I18N_FIELD)
69
+ enum: Object.values(I18N_FIELD)
77
70
  }]
78
71
  };
79
72
 
@@ -81,7 +74,7 @@ const i18nField = {
81
74
  * Config for fields in both file and folder collections.
82
75
  */
83
76
  function fieldsConfig() {
84
- const id = (0, _uuid.v4)();
77
+ const id = uuid();
85
78
  return {
86
79
  $id: `fields_${id}`,
87
80
  type: 'array',
@@ -424,6 +417,9 @@ function getConfigSchema() {
424
417
  minimum: 1,
425
418
  maximum: 1000
426
419
  },
420
+ subfolders: {
421
+ type: 'boolean'
422
+ },
427
423
  summary: {
428
424
  type: 'string'
429
425
  }
@@ -471,7 +467,7 @@ function getConfigSchema() {
471
467
  if: {
472
468
  properties: {
473
469
  extension: {
474
- enum: Object.keys(_formats.extensionFormatters)
470
+ enum: Object.keys(extensionFormatters)
475
471
  }
476
472
  }
477
473
  },
@@ -483,7 +479,7 @@ function getConfigSchema() {
483
479
  frontmatter_delimiter: {
484
480
  properties: {
485
481
  format: {
486
- enum: _formats.frontmatterFormats
482
+ enum: frontmatterFormats
487
483
  }
488
484
  },
489
485
  required: ['format']
@@ -510,7 +506,7 @@ function getConfigSchema() {
510
506
  };
511
507
  }
512
508
  function getWidgetSchemas() {
513
- const schemas = (0, _registry.getWidgets)().map(widget => ({
509
+ const schemas = getWidgets().map(widget => ({
514
510
  [widget.name]: widget.schema
515
511
  }));
516
512
  return Object.assign(...schemas);
@@ -537,17 +533,17 @@ class ConfigError extends _extendableBuiltin(Error) {
537
533
  * `validateConfig` is a pure function. It does not mutate
538
534
  * the config that is passed in.
539
535
  */
540
- function validateConfig(config) {
541
- const ajv = new _ajv.default({
536
+ export function validateConfig(config) {
537
+ const ajv = new AJV({
542
538
  allErrors: true,
543
539
  $data: true,
544
540
  strict: false
545
541
  });
546
- (0, _keywords.uniqueItemProperties)(ajv);
547
- (0, _keywords.select)(ajv);
548
- (0, _keywords.instanceof)(ajv);
549
- (0, _keywords.prohibited)(ajv);
550
- (0, _ajvErrors.default)(ajv);
542
+ uniqueItemProperties(ajv);
543
+ select(ajv);
544
+ instanceOf(ajv);
545
+ prohibited(ajv);
546
+ ajvErrors(ajv);
551
547
  const valid = ajv.validate(getConfigSchema(), config);
552
548
  if (!valid) {
553
549
  const errors = ajv.errors.map(e => {
@@ -1,20 +1,13 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SORTABLE_FIELDS = exports.INFERABLE_FIELDS = exports.IDENTIFIER_FIELDS = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _react2 = require("@emotion/react");
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- const IDENTIFIER_FIELDS = exports.IDENTIFIER_FIELDS = ['title', 'path'];
11
- const SORTABLE_FIELDS = exports.SORTABLE_FIELDS = ['title', 'date', 'author', 'description'];
12
- const INFERABLE_FIELDS = exports.INFERABLE_FIELDS = {
1
+ import React from 'react';
2
+ import { jsx as ___EmotionJSX } from "@emotion/react";
3
+ export const IDENTIFIER_FIELDS = ['title', 'path'];
4
+ export const SORTABLE_FIELDS = ['title', 'date', 'author', 'description'];
5
+ export const INFERABLE_FIELDS = {
13
6
  title: {
14
7
  type: 'string',
15
8
  secondaryTypes: [],
16
9
  synonyms: ['title', 'name', 'label', 'headline', 'header'],
17
- defaultPreview: value => (0, _react2.jsx)("h1", null, value),
10
+ defaultPreview: value => ___EmotionJSX("h1", null, value),
18
11
  // eslint-disable-line react/display-name
19
12
  fallbackToFirstField: true,
20
13
  showError: true
@@ -23,7 +16,7 @@ const INFERABLE_FIELDS = exports.INFERABLE_FIELDS = {
23
16
  type: 'string',
24
17
  secondaryTypes: [],
25
18
  synonyms: ['short_title', 'shortTitle', 'short'],
26
- defaultPreview: value => (0, _react2.jsx)("h2", null, value),
19
+ defaultPreview: value => ___EmotionJSX("h2", null, value),
27
20
  // eslint-disable-line react/display-name
28
21
  fallbackToFirstField: false,
29
22
  showError: false
@@ -32,7 +25,7 @@ const INFERABLE_FIELDS = exports.INFERABLE_FIELDS = {
32
25
  type: 'string',
33
26
  secondaryTypes: [],
34
27
  synonyms: ['author', 'name', 'by', 'byline', 'owner'],
35
- defaultPreview: value => (0, _react2.jsx)("strong", null, value),
28
+ defaultPreview: value => ___EmotionJSX("strong", null, value),
36
29
  // eslint-disable-line react/display-name
37
30
  fallbackToFirstField: false,
38
31
  showError: false
@@ -1,22 +1,17 @@
1
- "use strict";
1
+ import { Map, OrderedMap } from 'immutable';
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.statusDescriptions = exports.status = exports.Statues = exports.SIMPLE = exports.EDITORIAL_WORKFLOW = void 0;
7
- var _immutable = require("immutable");
8
3
  // Create/edit workflow modes
9
- const SIMPLE = exports.SIMPLE = 'simple';
10
- const EDITORIAL_WORKFLOW = exports.EDITORIAL_WORKFLOW = 'editorial_workflow';
11
- const Statues = exports.Statues = {
4
+ export const SIMPLE = 'simple';
5
+ export const EDITORIAL_WORKFLOW = 'editorial_workflow';
6
+ export const Statues = {
12
7
  DRAFT: 'draft',
13
8
  PENDING_REVIEW: 'pending_review',
14
9
  PENDING_PUBLISH: 'pending_publish'
15
10
  };
16
11
 
17
12
  // Available status
18
- const status = exports.status = (0, _immutable.OrderedMap)(Statues);
19
- const statusDescriptions = exports.statusDescriptions = (0, _immutable.Map)({
13
+ export const status = OrderedMap(Statues);
14
+ export const statusDescriptions = Map({
20
15
  [status.get('DRAFT')]: 'Draft',
21
16
  [status.get('PENDING_REVIEW')]: 'Waiting for Review',
22
17
  [status.get('PENDING_PUBLISH')]: 'Waiting to go live'
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = exports.default = {
1
+ export default {
8
2
  PRESENCE: 'PRESENCE',
9
3
  PATTERN: 'PATTERN',
10
4
  RANGE: 'RANGE',
@@ -1,26 +1,17 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.frontmatterFormats = exports.formatExtensions = exports.extensionFormatters = void 0;
7
- exports.getFormatExtensions = getFormatExtensions;
8
- exports.resolveFormat = resolveFormat;
9
- var _get2 = _interopRequireDefault(require("lodash/get"));
10
- var _immutable = require("immutable");
11
- var _yaml = _interopRequireDefault(require("./yaml"));
12
- var _toml = _interopRequireDefault(require("./toml"));
13
- var _json = _interopRequireDefault(require("./json"));
14
- var _frontmatter = require("./frontmatter");
15
- var _registry = require("../lib/registry");
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1
+ import _get from "lodash/get";
17
2
  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; }
18
3
  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; }
19
4
  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; }
20
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
21
6
  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); }
22
- const frontmatterFormats = exports.frontmatterFormats = ['yaml-frontmatter', 'toml-frontmatter', 'json-frontmatter'];
23
- const formatExtensions = exports.formatExtensions = {
7
+ import { List } from 'immutable';
8
+ import yamlFormatter from './yaml';
9
+ import tomlFormatter from './toml';
10
+ import jsonFormatter from './json';
11
+ import { FrontmatterInfer, frontmatterJSON, frontmatterTOML, frontmatterYAML } from './frontmatter';
12
+ import { getCustomFormatsExtensions, getCustomFormatsFormatters } from '../lib/registry';
13
+ export const frontmatterFormats = ['yaml-frontmatter', 'toml-frontmatter', 'json-frontmatter'];
14
+ export const formatExtensions = {
24
15
  yml: 'yml',
25
16
  yaml: 'yml',
26
17
  toml: 'toml',
@@ -30,38 +21,38 @@ const formatExtensions = exports.formatExtensions = {
30
21
  'toml-frontmatter': 'md',
31
22
  'yaml-frontmatter': 'md'
32
23
  };
33
- function getFormatExtensions() {
34
- return _objectSpread(_objectSpread({}, formatExtensions), (0, _registry.getCustomFormatsExtensions)());
24
+ export function getFormatExtensions() {
25
+ return _objectSpread(_objectSpread({}, formatExtensions), getCustomFormatsExtensions());
35
26
  }
36
- const extensionFormatters = exports.extensionFormatters = {
37
- yml: _yaml.default,
38
- yaml: _yaml.default,
39
- toml: _toml.default,
40
- json: _json.default,
41
- md: _frontmatter.FrontmatterInfer,
42
- markdown: _frontmatter.FrontmatterInfer,
43
- html: _frontmatter.FrontmatterInfer
27
+ export const extensionFormatters = {
28
+ yml: yamlFormatter,
29
+ yaml: yamlFormatter,
30
+ toml: tomlFormatter,
31
+ json: jsonFormatter,
32
+ md: FrontmatterInfer,
33
+ markdown: FrontmatterInfer,
34
+ html: FrontmatterInfer
44
35
  };
45
36
  function formatByName(name, customDelimiter) {
46
37
  const formatters = _objectSpread({
47
- yml: _yaml.default,
48
- yaml: _yaml.default,
49
- toml: _toml.default,
50
- json: _json.default,
51
- frontmatter: _frontmatter.FrontmatterInfer,
52
- 'json-frontmatter': (0, _frontmatter.frontmatterJSON)(customDelimiter),
53
- 'toml-frontmatter': (0, _frontmatter.frontmatterTOML)(customDelimiter),
54
- 'yaml-frontmatter': (0, _frontmatter.frontmatterYAML)(customDelimiter)
55
- }, (0, _registry.getCustomFormatsFormatters)());
38
+ yml: yamlFormatter,
39
+ yaml: yamlFormatter,
40
+ toml: tomlFormatter,
41
+ json: jsonFormatter,
42
+ frontmatter: FrontmatterInfer,
43
+ 'json-frontmatter': frontmatterJSON(customDelimiter),
44
+ 'toml-frontmatter': frontmatterTOML(customDelimiter),
45
+ 'yaml-frontmatter': frontmatterYAML(customDelimiter)
46
+ }, getCustomFormatsFormatters());
56
47
  if (name in formatters) {
57
48
  return formatters[name];
58
49
  }
59
50
  throw new Error(`No formatter available with name: ${name}`);
60
51
  }
61
52
  function frontmatterDelimiterIsList(frontmatterDelimiter) {
62
- return _immutable.List.isList(frontmatterDelimiter);
53
+ return List.isList(frontmatterDelimiter);
63
54
  }
64
- function resolveFormat(collection, entry) {
55
+ export function resolveFormat(collection, entry) {
65
56
  // Check for custom delimiter
66
57
  const frontmatter_delimiter = collection.get('frontmatter_delimiter');
67
58
  const customDelimiter = frontmatterDelimiterIsList(frontmatter_delimiter) ? frontmatter_delimiter.toArray() : frontmatter_delimiter;
@@ -77,7 +68,7 @@ function resolveFormat(collection, entry) {
77
68
  if (filePath) {
78
69
  const fileExtension = filePath.split('.').pop();
79
70
  if (fileExtension) {
80
- return (0, _get2.default)(extensionFormatters, fileExtension);
71
+ return _get(extensionFormatters, fileExtension);
81
72
  }
82
73
  }
83
74
 
@@ -85,7 +76,7 @@ function resolveFormat(collection, entry) {
85
76
  // collection config, infer the format from that extension.
86
77
  const extension = collection.get('extension');
87
78
  if (extension) {
88
- return (0, _get2.default)(extensionFormatters, extension);
79
+ return _get(extensionFormatters, extension);
89
80
  }
90
81
 
91
82
  // If no format is specified and it cannot be inferred, return the default.
@@ -1,19 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.FrontmatterInfer = exports.FrontmatterFormatter = void 0;
7
- exports.frontmatterJSON = frontmatterJSON;
8
- exports.frontmatterTOML = frontmatterTOML;
9
- exports.frontmatterYAML = frontmatterYAML;
10
- exports.getFormatOpts = getFormatOpts;
11
- var _grayMatter = _interopRequireDefault(require("gray-matter"));
12
- var _toml = _interopRequireDefault(require("./toml"));
13
- var _yaml = _interopRequireDefault(require("./yaml"));
14
- var _json = _interopRequireDefault(require("./json"));
15
1
  const _excluded = ["body"];
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
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; }
18
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; }
19
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; }
@@ -21,6 +6,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
21
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; }
22
7
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
23
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
+ import matter from 'gray-matter';
10
+ import tomlFormatter from './toml';
11
+ import yamlFormatter from './yaml';
12
+ import jsonFormatter from './json';
24
13
  const Languages = {
25
14
  YAML: 'yaml',
26
15
  TOML: 'toml',
@@ -28,12 +17,12 @@ const Languages = {
28
17
  };
29
18
  const parsers = {
30
19
  toml: {
31
- parse: input => _toml.default.fromFile(input),
20
+ parse: input => tomlFormatter.fromFile(input),
32
21
  stringify: (metadata, opts) => {
33
22
  const {
34
23
  sortedKeys
35
24
  } = opts || {};
36
- return _toml.default.toFile(metadata, sortedKeys);
25
+ return tomlFormatter.toFile(metadata, sortedKeys);
37
26
  }
38
27
  },
39
28
  json: {
@@ -43,10 +32,10 @@ const parsers = {
43
32
  if (JSONinput.slice(0, 1) !== '{') {
44
33
  JSONinput = '{' + JSONinput + '}';
45
34
  }
46
- return _json.default.fromFile(JSONinput);
35
+ return jsonFormatter.fromFile(JSONinput);
47
36
  },
48
37
  stringify: metadata => {
49
- let JSONoutput = _json.default.toFile(metadata).trim();
38
+ let JSONoutput = jsonFormatter.toFile(metadata).trim();
50
39
  // Trim leading and trailing brackets.
51
40
  if (JSONoutput.slice(0, 1) === '{' && JSONoutput.slice(-1) === '}') {
52
41
  JSONoutput = JSONoutput.slice(1, -1);
@@ -55,13 +44,13 @@ const parsers = {
55
44
  }
56
45
  },
57
46
  yaml: {
58
- parse: input => _yaml.default.fromFile(input),
47
+ parse: input => yamlFormatter.fromFile(input),
59
48
  stringify: (metadata, opts) => {
60
49
  const {
61
50
  sortedKeys,
62
51
  comments
63
52
  } = opts || {};
64
- return _yaml.default.toFile(metadata, sortedKeys, comments);
53
+ return yamlFormatter.toFile(metadata, sortedKeys, comments);
65
54
  }
66
55
  }
67
56
  };
@@ -83,7 +72,7 @@ function inferFrontmatterFormat(str) {
83
72
  console.warn('Unrecognized front-matter format.');
84
73
  }
85
74
  }
86
- function getFormatOpts(format, customDelimiter) {
75
+ export function getFormatOpts(format, customDelimiter) {
87
76
  if (!format) {
88
77
  return undefined;
89
78
  }
@@ -110,14 +99,14 @@ function getFormatOpts(format, customDelimiter) {
110
99
  delimiters: customDelimiter || delimiters
111
100
  };
112
101
  }
113
- class FrontmatterFormatter {
102
+ export class FrontmatterFormatter {
114
103
  constructor(format, customDelimiter) {
115
104
  _defineProperty(this, "format", void 0);
116
105
  this.format = getFormatOpts(format, customDelimiter);
117
106
  }
118
107
  fromFile(content) {
119
108
  const format = this.format || inferFrontmatterFormat(content);
120
- const result = (0, _grayMatter.default)(content, _objectSpread({
109
+ const result = matter(content, _objectSpread({
121
110
  engines: parsers
122
111
  }, format));
123
112
  // in the absent of a body when serializing an entry we use an empty one
@@ -139,7 +128,7 @@ class FrontmatterFormatter {
139
128
  // change detection logic
140
129
  // https://github.com/jonschlinkert/gray-matter/issues/96
141
130
  const trimLastLineBreak = body.slice(-1) !== '\n';
142
- const file = _grayMatter.default.stringify(body, meta, _objectSpread({
131
+ const file = matter.stringify(body, meta, _objectSpread({
143
132
  engines: parsers,
144
133
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
145
134
  // @ts-ignore `sortedKeys` is not recognized by gray-matter, so it gets passed through to the parser
@@ -149,14 +138,13 @@ class FrontmatterFormatter {
149
138
  return trimLastLineBreak && file.slice(-1) === '\n' ? file.slice(0, -1) : file;
150
139
  }
151
140
  }
152
- exports.FrontmatterFormatter = FrontmatterFormatter;
153
- const FrontmatterInfer = exports.FrontmatterInfer = new FrontmatterFormatter();
154
- function frontmatterYAML(customDelimiter) {
141
+ export const FrontmatterInfer = new FrontmatterFormatter();
142
+ export function frontmatterYAML(customDelimiter) {
155
143
  return new FrontmatterFormatter(Languages.YAML, customDelimiter);
156
144
  }
157
- function frontmatterTOML(customDelimiter) {
145
+ export function frontmatterTOML(customDelimiter) {
158
146
  return new FrontmatterFormatter(Languages.TOML, customDelimiter);
159
147
  }
160
- function frontmatterJSON(customDelimiter) {
148
+ export function frontmatterJSON(customDelimiter) {
161
149
  return new FrontmatterFormatter(Languages.JSON, customDelimiter);
162
150
  }
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.sortKeys = sortKeys;
7
- function sortKeys(sortedKeys,
1
+ export function sortKeys(sortedKeys,
8
2
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
3
  selector = a => a) {
10
4
  return (a, b) => {
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = exports.default = {
1
+ export default {
8
2
  fromFile(content) {
9
3
  return JSON.parse(content);
10
4
  },
@@ -1,22 +1,15 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _toml = _interopRequireDefault(require("@iarna/toml"));
8
- var _tomlifyJ = _interopRequireDefault(require("tomlify-j0.4"));
9
- var _dayjs = _interopRequireDefault(require("dayjs"));
10
- var _AssetProxy = _interopRequireDefault(require("../valueObjects/AssetProxy"));
11
- var _helpers = require("./helpers");
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1
+ import toml from '@iarna/toml';
2
+ import tomlify from 'tomlify-j0.4';
3
+ import dayjs from 'dayjs';
4
+ import AssetProxy from '../valueObjects/AssetProxy';
5
+ import { sortKeys } from './helpers';
13
6
  function outputReplacer(_key, value) {
14
- if (_dayjs.default.isDayjs(value)) {
7
+ if (dayjs.isDayjs(value)) {
15
8
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16
9
  // @ts-ignore
17
10
  return value.format(value._f);
18
11
  }
19
- if (value instanceof _AssetProxy.default) {
12
+ if (value instanceof AssetProxy) {
20
13
  return `${value.path}`;
21
14
  }
22
15
  if (typeof value === 'number' && Number.isInteger(value)) {
@@ -26,14 +19,14 @@ function outputReplacer(_key, value) {
26
19
  // Return `false` to use default (`undefined` would delete key).
27
20
  return false;
28
21
  }
29
- var _default = exports.default = {
22
+ export default {
30
23
  fromFile(content) {
31
- return _toml.default.parse(content);
24
+ return toml.parse(content);
32
25
  },
33
26
  toFile(data, sortedKeys = []) {
34
- return _tomlifyJ.default.toToml(data, {
27
+ return tomlify.toToml(data, {
35
28
  replace: outputReplacer,
36
- sort: (0, _helpers.sortKeys)(sortedKeys)
29
+ sort: sortKeys(sortedKeys)
37
30
  });
38
31
  }
39
32
  };
@@ -1,12 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _yaml = _interopRequireDefault(require("yaml"));
8
- var _helpers = require("./helpers");
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1
+ import yaml from 'yaml';
2
+ import { sortKeys } from './helpers';
10
3
  function addComments(items, comments, prefix = '') {
11
4
  items.forEach(item => {
12
5
  if (item.key !== undefined) {
@@ -39,23 +32,23 @@ const timestampTag = {
39
32
  resolve: str => new Date(str),
40
33
  stringify: value => value.toISOString()
41
34
  };
42
- var _default = exports.default = {
35
+ export default {
43
36
  fromFile(content) {
44
37
  if (content && content.trim().endsWith('---')) {
45
38
  content = content.trim().slice(0, -3);
46
39
  }
47
- return _yaml.default.parse(content, {
40
+ return yaml.parse(content, {
48
41
  customTags: [timestampTag]
49
42
  });
50
43
  },
51
44
  toFile(data, sortedKeys = [], comments = {}) {
52
- const contents = _yaml.default.createNode(data);
45
+ const contents = yaml.createNode(data);
53
46
  addComments(contents.items, comments);
54
- contents.items.sort((0, _helpers.sortKeys)(sortedKeys, item => {
47
+ contents.items.sort(sortKeys(sortedKeys, item => {
55
48
  var _item$key;
56
49
  return (_item$key = item.key) === null || _item$key === void 0 ? void 0 : _item$key.toString();
57
50
  }));
58
- const doc = new _yaml.default.Document();
51
+ const doc = new yaml.Document();
59
52
  doc.contents = contents;
60
53
  return doc.toString();
61
54
  }
package/dist/esm/index.js CHANGED
@@ -1,18 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.DecapCmsCore = void 0;
7
- var _bootstrap = _interopRequireDefault(require("./bootstrap"));
8
- var _registry = _interopRequireDefault(require("./lib/registry"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
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; }
11
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; }
12
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; }
13
4
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
14
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); }
15
- const DecapCmsCore = exports.DecapCmsCore = _objectSpread(_objectSpread({}, _registry.default), {}, {
16
- init: _bootstrap.default
6
+ import bootstrap from './bootstrap';
7
+ import Registry from './lib/registry';
8
+ export const DecapCmsCore = _objectSpread(_objectSpread({}, Registry), {}, {
9
+ init: bootstrap
17
10
  });
18
- var _default = exports.default = DecapCmsCore;
11
+ export default DecapCmsCore;