@nascentdigital/funnel-editor-contentful 5.0.2 → 5.0.3

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 (104) hide show
  1. package/dist/EditorApp.js +2 -2
  2. package/dist/EditorPageRouter.js +3 -9
  3. package/dist/EditorPageRoutes.d.ts +1 -0
  4. package/dist/EditorPageRoutes.js +16 -0
  5. package/dist/EntryEditor.js +1 -1
  6. package/dist/EntrySidebar.js +26 -5
  7. package/dist/NotFound.d.ts +1 -0
  8. package/dist/NotFound.js +18 -0
  9. package/dist/asset/repository/AssetRepository.d.ts +11 -3
  10. package/dist/asset/repository/AssetRepository.js +6 -5
  11. package/dist/collection/domain/Collection.js +2 -1
  12. package/dist/collection/repository/CollectionRepository.d.ts +3 -3
  13. package/dist/collection/repository/CollectionRepository.js +19 -6
  14. package/dist/core/bridge/AppBridge.d.ts +31 -0
  15. package/dist/core/bridge/AppBridge.js +160 -0
  16. package/dist/core/bridge/AppBridgeContainer.d.ts +3 -3
  17. package/dist/core/bridge/AppBridgeContainer.js +8 -44
  18. package/dist/core/bridge/AppBridgeContext.d.ts +7 -8
  19. package/dist/core/bridge/AppBridgeContext.js +1 -6
  20. package/dist/core/bridge/BridgeLifecycleMessage.d.ts +7 -0
  21. package/dist/core/bridge/BridgeLifecycleMessage.js +12 -0
  22. package/dist/core/bridge/IAppBridgeMessage.d.ts +16 -0
  23. package/dist/core/bridge/IAppBridgeMessage.js +12 -0
  24. package/dist/core/bridge/index.d.ts +2 -1
  25. package/dist/core/bridge/index.js +2 -1
  26. package/dist/core/bridge/useAppBridge.d.ts +2 -8
  27. package/dist/core/bridge/useAppBridge.js +24 -15
  28. package/dist/core/index.d.ts +0 -2
  29. package/dist/core/index.js +0 -2
  30. package/dist/explore/components/header/Header.d.ts +14 -0
  31. package/dist/explore/components/{Header.js → header/Header.js} +10 -8
  32. package/dist/explore/components/header/HeaderActions.d.ts +8 -0
  33. package/dist/explore/components/header/HeaderActions.js +37 -0
  34. package/dist/explore/components/header/HeaderContainer.d.ts +2 -0
  35. package/dist/explore/components/header/HeaderContainer.js +15 -0
  36. package/dist/explore/components/header/HeaderContext.d.ts +7 -0
  37. package/dist/explore/components/header/HeaderContext.js +6 -0
  38. package/dist/explore/components/header/HeaderController.d.ts +39 -0
  39. package/dist/explore/components/header/HeaderController.js +100 -0
  40. package/dist/explore/components/header/HeaderOptions.d.ts +10 -0
  41. package/dist/explore/components/header/HeaderOptions.js +26 -0
  42. package/dist/explore/components/header/index.d.ts +5 -0
  43. package/dist/{core/contentful → explore/components/header}/index.js +5 -5
  44. package/dist/explore/components/header/useHeader.d.ts +2 -0
  45. package/dist/explore/components/header/useHeader.js +30 -0
  46. package/dist/explore/components/index.d.ts +2 -1
  47. package/dist/explore/components/index.js +2 -1
  48. package/dist/explore/components/pages/PagesExplorerLayout.d.ts +4 -0
  49. package/dist/explore/components/pages/PagesExplorerLayout.js +28 -0
  50. package/dist/explore/components/pages/index.d.ts +1 -0
  51. package/dist/{core/repository → explore/components/pages}/index.js +1 -4
  52. package/dist/explore/index.d.ts +1 -0
  53. package/dist/explore/index.js +1 -0
  54. package/dist/explore/screens/Dashboard.d.ts +3 -0
  55. package/dist/explore/screens/Dashboard.js +34 -1
  56. package/dist/explore/screens/PageExplorer.d.ts +10 -0
  57. package/dist/explore/screens/PageExplorer.js +121 -1
  58. package/dist/explore/screens/PagesExplorer.d.ts +7 -0
  59. package/dist/explore/screens/PagesExplorer.js +98 -0
  60. package/dist/explore/screens/index.d.ts +1 -1
  61. package/dist/explore/screens/index.js +1 -1
  62. package/dist/page/bridge/BlockChangedMessage.d.ts +25 -0
  63. package/dist/page/bridge/BlockChangedMessage.js +18 -0
  64. package/dist/page/bridge/PageBridgeHub.d.ts +8 -0
  65. package/dist/page/bridge/PageBridgeHub.js +51 -0
  66. package/dist/page/bridge/index.d.ts +2 -0
  67. package/dist/page/bridge/index.js +18 -0
  68. package/dist/page/domain/Page.d.ts +2 -2
  69. package/dist/page/domain/Page.js +2 -1
  70. package/dist/page/index.d.ts +1 -0
  71. package/dist/page/index.js +1 -0
  72. package/dist/page/repository/PageRepository.d.ts +3 -3
  73. package/dist/page/repository/PageRepository.js +25 -8
  74. package/dist/page/screens/PageEditor.js +14 -6
  75. package/package.json +5 -5
  76. package/dist/core/bridge/AppMessage.d.ts +0 -19
  77. package/dist/core/bridge/AppMessage.js +0 -19
  78. package/dist/core/contentful/Contentful.d.ts +0 -33
  79. package/dist/core/contentful/Contentful.js +0 -67
  80. package/dist/core/contentful/ContentfulAsset.d.ts +0 -23
  81. package/dist/core/contentful/ContentfulAsset.js +0 -89
  82. package/dist/core/contentful/ContentfulCollection.d.ts +0 -29
  83. package/dist/core/contentful/ContentfulCollection.js +0 -97
  84. package/dist/core/contentful/ContentfulPage.d.ts +0 -31
  85. package/dist/core/contentful/ContentfulPage.js +0 -84
  86. package/dist/core/contentful/ContentfulRefs.d.ts +0 -16
  87. package/dist/core/contentful/ContentfulRefs.js +0 -152
  88. package/dist/core/contentful/index.d.ts +0 -5
  89. package/dist/core/repository/CollectionSerializer.d.ts +0 -9
  90. package/dist/core/repository/CollectionSerializer.js +0 -41
  91. package/dist/core/repository/LocalCollectionRepository.d.ts +0 -27
  92. package/dist/core/repository/LocalCollectionRepository.js +0 -143
  93. package/dist/core/repository/LocalPageRepository.d.ts +0 -16
  94. package/dist/core/repository/LocalPageRepository.js +0 -153
  95. package/dist/core/repository/PageSerializer.d.ts +0 -9
  96. package/dist/core/repository/PageSerializer.js +0 -48
  97. package/dist/core/repository/RemoteCollectionRepository.d.ts +0 -19
  98. package/dist/core/repository/RemoteCollectionRepository.js +0 -236
  99. package/dist/core/repository/RemotePageRepository.d.ts +0 -14
  100. package/dist/core/repository/RemotePageRepository.js +0 -113
  101. package/dist/core/repository/index.d.ts +0 -4
  102. package/dist/explore/components/Header.d.ts +0 -26
  103. package/dist/explore/screens/SiteExplorer.d.ts +0 -1
  104. package/dist/explore/screens/SiteExplorer.js +0 -24
@@ -4,20 +4,22 @@ exports.PageEditor = PageEditor;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const funnel_core_1 = require("@nascentdigital/funnel-core");
6
6
  const components_1 = require("@nascentdigital/funnel-editor/components");
7
+ const hooks_1 = require("@nascentdigital/funnel-ui/hooks");
7
8
  const react_1 = require("react");
8
- const core_1 = require("../../core");
9
+ const bridge_1 = require("../bridge");
9
10
  const controller_1 = require("../controller");
10
11
  // component
11
12
  function PageEditor() {
12
13
  // hooks
13
14
  const splash = (0, components_1.useSplash)();
14
- const bridge = (0, core_1.useAppBridge)();
15
15
  const controller = (0, controller_1.useContentfulPageController)();
16
16
  const { page } = controller;
17
17
  const pageContext = (0, react_1.useMemo)(() => ({ page }), [page]);
18
18
  const [itemId, setItemId] = (0, react_1.useState)();
19
19
  const selectedItem = (0, react_1.useMemo)(() => page === null || page === void 0 ? void 0 : page.coerceItem(itemId), [page, itemId]);
20
20
  const { ready } = controller;
21
+ const [setBlockConfigurationRef, blockConfigurationRef] = (0, hooks_1.useRefValue)();
22
+ const blockConfiguration = (0, components_1.useBlockConfiguration$)(blockConfigurationRef === null || blockConfigurationRef === void 0 ? void 0 : blockConfigurationRef.configuration$);
21
23
  // load
22
24
  (0, react_1.useEffect)(() => {
23
25
  controller.load().catch(e => {
@@ -40,12 +42,17 @@ function PageEditor() {
40
42
  }, [splash, ready]);
41
43
  const onSelectItem = (item) => {
42
44
  setItemId(item.identifier);
43
- bridge.sendMessage(core_1.AppBlockNavMessage.create(item.identifier));
44
45
  };
45
46
  // render
46
- return ((0, jsx_runtime_1.jsx)(components_1.PageContext.Provider, { value: pageContext, children: (0, jsx_runtime_1.jsx)(components_1.AssetStoreContext.Provider, { value: page, children: (0, jsx_runtime_1.jsx)(components_1.CollectionStoreContext.Provider, { value: page, children: (0, jsx_runtime_1.jsx)(components_1.PageRefStoreContext.Provider, { value: page, children: (0, jsx_runtime_1.jsx)("div", { className: "bg-background flex h-dvh w-dvw flex-col", children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex-1", children: (0, jsx_runtime_1.jsxs)("div", { className: "absolute inset-0 flex", children: [(0, jsx_runtime_1.jsx)("section", { className: "scrollbar-thin w-[220px] shrink-0 overflow-y-scroll lg:w-[240px] xl:w-[280px]", tabIndex: -1, children: (0, jsx_runtime_1.jsx)(components_1.PageNav, { selectedItem: selectedItem, onSelectItem: onSelectItem }) }), (0, jsx_runtime_1.jsx)("section", { className: "mx-auto h-full max-h-full max-w-[1000px] flex-1", children: renderContent({ controller, page, selectedItem, onSelectItem }) })] }) }) }) }) }) }) }));
47
+ return ((0, jsx_runtime_1.jsx)(components_1.PageContext.Provider, { value: pageContext, children: (0, jsx_runtime_1.jsx)(components_1.AssetStoreContext.Provider, { value: page, children: (0, jsx_runtime_1.jsx)(components_1.CollectionStoreContext.Provider, { value: page, children: (0, jsx_runtime_1.jsx)(components_1.PageRefStoreContext.Provider, { value: page, children: (0, jsx_runtime_1.jsx)(components_1.BlockConfigurationProvider, { ref: setBlockConfigurationRef, item: selectedItem, children: (0, jsx_runtime_1.jsx)(bridge_1.PageBridgeHub, { selectedItem: selectedItem, children: (0, jsx_runtime_1.jsx)("div", { className: "h-dvh w-dvw flex flex-col bg-background", children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex-1", children: (0, jsx_runtime_1.jsxs)("div", { className: "absolute inset-0 flex", children: [(0, jsx_runtime_1.jsx)("section", { className: "scrollbar-thin w-[220px] shrink-0 overflow-y-scroll lg:w-[240px] xl:w-[280px]", tabIndex: -1, children: (0, jsx_runtime_1.jsx)(components_1.PageNav, { selectedItem: selectedItem, onSelectItem: onSelectItem }) }), (0, jsx_runtime_1.jsx)("section", { className: "mx-auto h-full max-h-full max-w-[1000px] flex-1", children: renderContent({
48
+ controller,
49
+ page,
50
+ blockConfiguration,
51
+ selectedItem,
52
+ onSelectItem
53
+ }) })] }) }) }) }) }) }) }) }) }));
47
54
  }
48
- function renderContent({ controller, page, selectedItem, onSelectItem }) {
55
+ function renderContent({ controller, page, blockConfiguration, selectedItem, onSelectItem }) {
49
56
  // show loader if not ready
50
57
  const { pageSummary } = controller;
51
58
  if (!controller.ready) {
@@ -69,6 +76,7 @@ function renderContent({ controller, page, selectedItem, onSelectItem }) {
69
76
  }
70
77
  // or render block editor
71
78
  else {
72
- return ((0, jsx_runtime_1.jsx)(components_1.BlockEditor, { className: "h-full max-h-full", block: selectedItem, onSelectItem: onSelectItem }));
79
+ return ((0, jsx_runtime_1.jsx)(components_1.BlockEditor, { className: "h-full max-h-full", block: selectedItem, headerActions: (blockConfiguration === null || blockConfiguration === void 0 ? void 0 : blockConfiguration.hasPanels) &&
80
+ (0, jsx_runtime_1.jsx)(components_1.BlockConfigButton, { target: "block" }), onSelectItem: onSelectItem }));
73
81
  }
74
82
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@nascentdigital/funnel-editor-contentful",
3
- "version": "5.0.2",
3
+ "version": "5.0.3",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
- "access": "restricted"
6
+ "access": "public"
7
7
  },
8
8
  "repository": {
9
9
  "url": "git+https://github.com/nascentdigital/funnel.git",
@@ -39,8 +39,8 @@
39
39
  "dependencies": {
40
40
  "@contentful/app-sdk": "^4",
41
41
  "@contentful/react-apps-toolkit": "^2.0.1",
42
- "@nascentdigital/funnel-cms": "^5.0.2",
43
- "@nascentdigital/funnel-editor": "^5.0.2",
42
+ "@nascentdigital/funnel-cms": "^5.0.3",
43
+ "@nascentdigital/funnel-editor": "^5.0.3",
44
44
  "react-dom": "^19",
45
45
  "react-router": "^8",
46
46
  "react-router-dom": "^7",
@@ -59,5 +59,5 @@
59
59
  "ts-jest": "^29",
60
60
  "type-fest": "^4"
61
61
  },
62
- "gitHead": "24d9690cf813052f6561c3ccef11c7cf69ad7f7c"
62
+ "gitHead": "0d1cc7d78504e8819998d928ffb342d622f75690"
63
63
  }
@@ -1,19 +0,0 @@
1
- import { Tagged } from 'type-fest';
2
- export type AppDomain = 'app';
3
- export interface AppMessage {
4
- domain: AppDomain;
5
- type: string;
6
- timestamp: number;
7
- }
8
- export type AppContextId = Tagged<string, 'funnel.AppContextId'>;
9
- export interface TrackedAppMessage extends AppMessage {
10
- source: AppContextId;
11
- }
12
- export interface AppBlockNavMessage extends AppMessage {
13
- type: 'blockNav';
14
- itemId: string;
15
- }
16
- export declare namespace AppBlockNavMessage {
17
- function create(itemId: string): AppBlockNavMessage;
18
- function guard(message: AppMessage): message is AppBlockNavMessage;
19
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppBlockNavMessage = void 0;
4
- var AppBlockNavMessage;
5
- (function (AppBlockNavMessage) {
6
- function create(itemId) {
7
- return {
8
- domain: 'app',
9
- type: 'blockNav',
10
- timestamp: Date.now(),
11
- itemId
12
- };
13
- }
14
- AppBlockNavMessage.create = create;
15
- function guard(message) {
16
- return message.domain === 'app' && message.type === 'blockNav';
17
- }
18
- AppBlockNavMessage.guard = guard;
19
- })(AppBlockNavMessage || (exports.AppBlockNavMessage = AppBlockNavMessage = {}));
@@ -1,33 +0,0 @@
1
- import type { BaseAppSDK } from '@contentful/app-sdk';
2
- import { EntryAPI } from '@contentful/app-sdk/dist/types/entry.types';
3
- import { QueryOptions } from 'contentful-management/dist/typings/common-types';
4
- import { EntryProps } from 'contentful-management/dist/typings/entities/entry';
5
- export declare namespace Contentful {
6
- type Base = {
7
- id: string;
8
- createdOn: number;
9
- updatedOn: number;
10
- };
11
- type LinkType = 'Asset' | 'Entry' | 'Upload';
12
- type Link<TType extends LinkType = LinkType> = {
13
- sys: {
14
- type: 'Link';
15
- linkType: TType;
16
- id: string;
17
- };
18
- };
19
- namespace Link {
20
- type Asset = Link<'Asset'>;
21
- type Entry = Link<'Entry'>;
22
- }
23
- function toLink(id: string, linkType: LinkType): Link;
24
- type Fields<TData extends Record<string, any>> = {
25
- [TKey in Exclude<keyof TData, keyof Base>]: {
26
- [locale: string]: TData[TKey];
27
- };
28
- };
29
- function allEntries<T = EntryProps>(sdk: BaseAppSDK, baseQuery?: QueryOptions): Promise<T[]>;
30
- function allEntriesNormalized<T extends Base>(sdk: BaseAppSDK, baseQuery?: QueryOptions): Promise<T[]>;
31
- function normalize<T extends Base>(entry: EntryAPI): T;
32
- function normalizeRemote<T extends Base>({ sys, fields }: EntryProps, locale: string): T;
33
- }
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Contentful = void 0;
4
- var Contentful;
5
- (function (Contentful) {
6
- function toLink(id, linkType) {
7
- return {
8
- sys: {
9
- type: 'Link',
10
- linkType,
11
- id
12
- }
13
- };
14
- }
15
- Contentful.toLink = toLink;
16
- async function allEntries(sdk, baseQuery = {}) {
17
- // setup
18
- let skip = 0;
19
- const limit = baseQuery.limit || 1000;
20
- let total = 1;
21
- const allItems = [];
22
- // loop until no more pages
23
- while (skip < total) {
24
- const response = await sdk.cma.entry.getMany({
25
- query: Object.assign(Object.assign({}, baseQuery), { limit,
26
- skip })
27
- });
28
- total = response.total;
29
- allItems.push(...response.items);
30
- skip += limit;
31
- }
32
- // return
33
- return allItems;
34
- }
35
- Contentful.allEntries = allEntries;
36
- async function allEntriesNormalized(sdk, baseQuery = {}) {
37
- // locale
38
- const locale = sdk.locales.default;
39
- // fetch items
40
- const items = await allEntries(sdk, baseQuery);
41
- // normalize
42
- return items.map(item => normalizeRemote(item, locale));
43
- }
44
- Contentful.allEntriesNormalized = allEntriesNormalized;
45
- function normalize(entry) {
46
- // get sys
47
- const sys = entry.getSys();
48
- // simplify fields (remove locale)
49
- const normalizedFields = {};
50
- for (const key in entry.fields) {
51
- normalizedFields[key] = entry.fields[key].getValue();
52
- }
53
- // return normalized form
54
- return Object.assign({ id: sys.id, createdOn: new Date(sys.createdAt).getTime(), updatedOn: new Date(sys.updatedAt).getTime() }, normalizedFields);
55
- }
56
- Contentful.normalize = normalize;
57
- function normalizeRemote({ sys, fields }, locale) {
58
- // simplify fields (remove locale)
59
- const normalizedFields = {};
60
- for (const key in fields) {
61
- normalizedFields[key] = fields[key][locale];
62
- }
63
- // return normalized form
64
- return Object.assign({ id: sys.id, createdOn: new Date(sys.createdAt).getTime(), updatedOn: new Date(sys.updatedAt).getTime() }, normalizedFields);
65
- }
66
- Contentful.normalizeRemote = normalizeRemote;
67
- })(Contentful || (exports.Contentful = Contentful = {}));
@@ -1,23 +0,0 @@
1
- import { EditorAppSDK } from '@contentful/app-sdk';
2
- import { Schema } from '@nascentdigital/funnel-core';
3
- import { IAssetRepository } from '@nascentdigital/funnel-editor/components';
4
- import type { EntryProps } from 'contentful-management/dist/typings/entities/entry';
5
- import { Contentful } from './Contentful';
6
- export type ContentfulAsset = Contentful.Base & {
7
- name: string;
8
- description?: string | null;
9
- brand?: string | null;
10
- type: string;
11
- scope: string;
12
- tags?: string[];
13
- url: string;
14
- size: number;
15
- metadata: object;
16
- media: Contentful.Link.Asset;
17
- };
18
- export declare namespace ContentfulAsset {
19
- const contentTypeId: "asset";
20
- type Remote = EntryProps<Contentful.Fields<ContentfulAsset>>;
21
- function upload(args: IAssetRepository.UploadFile.Args, sdk: EditorAppSDK): Promise<Remote>;
22
- function serialize(entry: Remote, locale: string): Schema.Asset.Linked;
23
- }
@@ -1,89 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ContentfulAsset = void 0;
4
- // extension
5
- var ContentfulAsset;
6
- (function (ContentfulAsset) {
7
- // consts
8
- ContentfulAsset.contentTypeId = 'asset';
9
- // helpers
10
- async function upload(args, sdk) {
11
- // setup
12
- var _a, _b, _c;
13
- // upload file
14
- const uploadResult = await sdk.cma.upload.create({}, {
15
- file: await args.file.arrayBuffer()
16
- });
17
- // create contentful asset
18
- const locale = sdk.locales.default;
19
- const contentfulAsset = await sdk.cma.asset.create({}, {
20
- fields: {
21
- title: { [locale]: args.name },
22
- description: { [locale]: (_a = args.description) !== null && _a !== void 0 ? _a : '' },
23
- file: {
24
- [locale]: {
25
- contentType: args.file.type,
26
- fileName: args.name,
27
- uploadFrom: {
28
- sys: {
29
- type: 'Link',
30
- linkType: 'Upload',
31
- id: uploadResult.sys.id
32
- }
33
- }
34
- }
35
- }
36
- }
37
- });
38
- // process contentful asset (creates url etc.) and return
39
- const processedAsset = await sdk.cma.asset.processForAllLocales({}, contentfulAsset);
40
- // create funnel asset then return
41
- return await sdk.cma.entry.create({ contentTypeId: ContentfulAsset.contentTypeId }, {
42
- fields: {
43
- name: { [locale]: args.name },
44
- description: { [locale]: (_b = args.description) !== null && _b !== void 0 ? _b : null },
45
- brand: { [locale]: (_c = args.brand) !== null && _c !== void 0 ? _c : null },
46
- type: { [locale]: args.type },
47
- scope: { [locale]: args.scope },
48
- tags: { [locale]: args.tags },
49
- url: { [locale]: 'https:' + processedAsset.fields.file[locale].url },
50
- size: { [locale]: args.size },
51
- metadata: { [locale]: args.metadata },
52
- media: {
53
- [locale]: {
54
- sys: {
55
- type: 'Link',
56
- linkType: 'Asset',
57
- id: processedAsset.sys.id
58
- }
59
- }
60
- }
61
- }
62
- });
63
- }
64
- ContentfulAsset.upload = upload;
65
- function serialize(entry, locale) {
66
- var _a, _b;
67
- console.debug('[ContentfulAsset] serializing asset', entry);
68
- // extract fields
69
- const { name, description, type, brand, metadata, scope, tags, url, size } = entry.fields;
70
- // create asset
71
- return {
72
- __root: 'asset',
73
- type: 'asset',
74
- value: {
75
- id: entry.sys.id,
76
- name: name[locale],
77
- description: description === null || description === void 0 ? void 0 : description[locale],
78
- type: type[locale],
79
- brand: (_a = brand === null || brand === void 0 ? void 0 : brand[locale]) !== null && _a !== void 0 ? _a : undefined,
80
- metadata: metadata[locale],
81
- scope: scope[locale],
82
- tags: (_b = tags === null || tags === void 0 ? void 0 : tags[locale]) !== null && _b !== void 0 ? _b : [],
83
- url: url[locale],
84
- size: size[locale]
85
- }
86
- };
87
- }
88
- ContentfulAsset.serialize = serialize;
89
- })(ContentfulAsset || (exports.ContentfulAsset = ContentfulAsset = {}));
@@ -1,29 +0,0 @@
1
- import { EntryAPI } from '@contentful/app-sdk/dist/types/entry.types';
2
- import { Schema } from '@nascentdigital/funnel-core';
3
- import { EntryProps } from 'contentful-management/dist/typings/entities/entry';
4
- import { Contentful } from './Contentful';
5
- export type ContentfulCollection = Contentful.Base & {
6
- groupId: string;
7
- name: string;
8
- type: string;
9
- brand?: string;
10
- language: string;
11
- version: number;
12
- tags?: string;
13
- fields: object;
14
- pageRefIds?: string;
15
- state: string;
16
- errors: boolean;
17
- publishedOn?: number;
18
- references?: Contentful.Link[];
19
- };
20
- export declare namespace ContentfulCollection {
21
- const contentTypeId: "collection";
22
- type Remote = EntryProps<Contentful.Fields<ContentfulCollection>>;
23
- function serialize(entry: EntryAPI): Schema.Collection.Data;
24
- function serializeRemoteRef(entry: Remote, locale: string): Schema.Collection.Data.AsRef;
25
- function serializeRemote(entry: Remote, locale: string): Schema.Collection.Data;
26
- function serializeRemoteWithRefs(entry: Remote, locale: string): Schema.Collection.FlattenedData;
27
- function deserialize(data: Schema.Collection.Data): ContentfulCollection;
28
- function deserializeLinks(collection: ContentfulCollection): Contentful.Link[];
29
- }
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ContentfulCollection = void 0;
4
- const Contentful_1 = require("./Contentful");
5
- const ContentfulRefs_1 = require("./ContentfulRefs");
6
- // extension
7
- var ContentfulCollection;
8
- (function (ContentfulCollection) {
9
- // consts
10
- ContentfulCollection.contentTypeId = 'collection';
11
- // helpers
12
- function serialize(entry) {
13
- // normalize
14
- const normalized = Contentful_1.Contentful.normalize(entry);
15
- // create collection data
16
- return normalizedToData(normalized);
17
- }
18
- ContentfulCollection.serialize = serialize;
19
- function serializeRemoteRef(entry, locale) {
20
- // normalize
21
- const normalized = Contentful_1.Contentful.normalizeRemote(entry, locale);
22
- // return collection ref data
23
- return normalizedToRef(normalized);
24
- }
25
- ContentfulCollection.serializeRemoteRef = serializeRemoteRef;
26
- function serializeRemote(entry, locale) {
27
- // normalize
28
- const normalized = Contentful_1.Contentful.normalizeRemote(entry, locale);
29
- // create collection data
30
- return normalizedToData(normalized);
31
- }
32
- ContentfulCollection.serializeRemote = serializeRemote;
33
- function serializeRemoteWithRefs(entry, locale) {
34
- // normalize
35
- const normalized = Contentful_1.Contentful.normalizeRemote(entry, locale);
36
- // create collection flattened data
37
- return normalizeToFlattened(normalized);
38
- }
39
- ContentfulCollection.serializeRemoteWithRefs = serializeRemoteWithRefs;
40
- function deserialize(data) {
41
- var _a;
42
- return {
43
- id: data.id,
44
- groupId: data.groupId,
45
- type: data.type,
46
- version: data.version,
47
- language: data.language,
48
- state: data.state,
49
- name: data.name,
50
- fields: data.fields,
51
- tags: JSON.stringify((_a = data.tags) !== null && _a !== void 0 ? _a : []),
52
- errors: data.errors,
53
- createdOn: data.createdOn,
54
- updatedOn: data.updatedOn
55
- };
56
- }
57
- ContentfulCollection.deserialize = deserialize;
58
- function deserializeLinks(collection) {
59
- const refs = ContentfulRefs_1.ContentfulRefs.find({ fields: collection.fields });
60
- const entryIds = [
61
- ...refs.assets.values(),
62
- ...refs.pages.values(),
63
- ...refs.collections.values()
64
- ];
65
- return entryIds.map(id => Contentful_1.Contentful.toLink(id, 'Entry'));
66
- }
67
- ContentfulCollection.deserializeLinks = deserializeLinks;
68
- // private helpers
69
- function normalizedToRef(data) {
70
- var _a;
71
- return {
72
- id: data.id,
73
- groupId: data.groupId,
74
- version: data.version,
75
- type: data.type,
76
- brand: data.brand,
77
- language: data.language,
78
- state: data.state,
79
- name: data.name,
80
- tags: JSON.parse((_a = data.tags) !== null && _a !== void 0 ? _a : '[]'),
81
- errors: data.errors,
82
- createdOn: data.createdOn,
83
- updatedOn: data.updatedOn,
84
- publishedOn: data.publishedOn
85
- };
86
- }
87
- function normalizedToData(data) {
88
- return Object.assign(Object.assign({ __root: 'collection' }, normalizedToRef(data)), { fields: data.fields });
89
- }
90
- function normalizeToFlattened(data) {
91
- return {
92
- data: normalizedToData(data),
93
- files: {},
94
- collections: {}
95
- };
96
- }
97
- })(ContentfulCollection || (exports.ContentfulCollection = ContentfulCollection = {}));
@@ -1,31 +0,0 @@
1
- import { EntryAPI } from '@contentful/app-sdk/dist/types/entry.types';
2
- import { Schema } from '@nascentdigital/funnel-core';
3
- import { EntryProps } from 'contentful-management/dist/typings/entities/entry';
4
- import { Contentful } from './Contentful';
5
- export type ContentfulPage = Contentful.Base & {
6
- groupId: string;
7
- type: string;
8
- name: string;
9
- brand: string;
10
- region: string;
11
- language: string;
12
- slug?: string;
13
- tags: string;
14
- url: string;
15
- discover: object;
16
- preview?: object;
17
- content: object;
18
- state: string;
19
- errors: boolean;
20
- publishedOn?: number;
21
- publication?: number;
22
- };
23
- export declare namespace ContentfulPage {
24
- const contentTypeId: "page";
25
- type Remote = EntryProps<Contentful.Fields<ContentfulPage>>;
26
- function serialize(entry: EntryAPI): Schema.Page.Data;
27
- function serializeRemoteLink(entry: Remote, locale: string): Schema.Page.Data.AsLink;
28
- function deserialize(data: Schema.Page.Data): ContentfulPage;
29
- function deserializeLinks(page: ContentfulPage): Contentful.Link[];
30
- function normalizedToLink(data: ContentfulPage): Schema.Page.Data.AsLink;
31
- }
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ContentfulPage = void 0;
4
- const Contentful_1 = require("./Contentful");
5
- const ContentfulRefs_1 = require("./ContentfulRefs");
6
- // extension
7
- var ContentfulPage;
8
- (function (ContentfulPage) {
9
- // consts
10
- ContentfulPage.contentTypeId = 'page';
11
- // helpers
12
- function serialize(entry) {
13
- // normalize entry
14
- const normalized = Contentful_1.Contentful.normalize(entry);
15
- // return data
16
- return Object.assign(Object.assign({ __root: 'page' }, normalizedToLink(normalized)), { discover: normalized.discover, preview: normalized.preview, content: normalized.content });
17
- }
18
- ContentfulPage.serialize = serialize;
19
- function serializeRemoteLink(entry, locale) {
20
- // normalize entry
21
- const normalized = Contentful_1.Contentful.normalizeRemote(entry, locale);
22
- // return link data
23
- return normalizedToLink(normalized);
24
- }
25
- ContentfulPage.serializeRemoteLink = serializeRemoteLink;
26
- function deserialize(data) {
27
- var _a;
28
- return {
29
- id: data.id,
30
- createdOn: data.createdOn,
31
- updatedOn: data.updatedOn,
32
- name: data.name,
33
- groupId: data.groupId,
34
- type: data.type,
35
- brand: data.brand,
36
- region: data.region,
37
- language: data.language,
38
- slug: data.slug,
39
- url: data.url,
40
- tags: JSON.stringify((_a = data.tags) !== null && _a !== void 0 ? _a : []),
41
- discover: data.discover,
42
- preview: data.preview,
43
- content: data.content,
44
- errors: data.errors,
45
- state: data.state,
46
- publishedOn: data.publishedOn,
47
- publication: data.publication
48
- };
49
- }
50
- ContentfulPage.deserialize = deserialize;
51
- function deserializeLinks(page) {
52
- const refs = ContentfulRefs_1.ContentfulRefs.find({ content: page.content });
53
- const entryIds = [
54
- ...refs.assets.values(),
55
- ...refs.pages.values(),
56
- ...refs.collections.values()
57
- ];
58
- return entryIds.map(id => Contentful_1.Contentful.toLink(id, 'Entry'));
59
- }
60
- ContentfulPage.deserializeLinks = deserializeLinks;
61
- // private helpers
62
- function normalizedToLink(data) {
63
- var _a;
64
- return {
65
- id: data.id,
66
- groupId: data.groupId,
67
- type: data.type,
68
- brand: data.brand,
69
- region: data.region,
70
- language: data.language,
71
- state: data.state,
72
- name: data.name,
73
- url: data.url,
74
- slug: data.slug,
75
- errors: data.errors,
76
- publishedOn: data.publishedOn,
77
- publication: data.publication,
78
- tags: JSON.parse((_a = data.tags) !== null && _a !== void 0 ? _a : '[]'),
79
- createdOn: data.createdOn,
80
- updatedOn: data.updatedOn
81
- };
82
- }
83
- ContentfulPage.normalizedToLink = normalizedToLink;
84
- })(ContentfulPage || (exports.ContentfulPage = ContentfulPage = {}));
@@ -1,16 +0,0 @@
1
- import { Schema } from '@nascentdigital/funnel-core';
2
- import { Asset, IPage } from '@nascentdigital/funnel-editor/components';
3
- import type { EntryReferenceProps } from 'contentful-management/dist/typings/entities/entry';
4
- export declare namespace ContentfulRefs {
5
- type Computed = {
6
- assets: Set<Schema.Asset.Id>;
7
- pages: Set<Schema.Page.Id>;
8
- collections: Set<Schema.Collection.Id>;
9
- };
10
- function find(data: any): Computed;
11
- function serialize(refs: EntryReferenceProps, locale: string): {
12
- assets: Asset[];
13
- pages: IPage.Ref[];
14
- collections: Schema.Collection.Data.AsLink[];
15
- };
16
- }