@nascentdigital/funnel-editor-contentful 5.0.1 → 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 (164) hide show
  1. package/dist/EditorApp.js +11 -9
  2. package/dist/EditorPageRouter.d.ts +1 -0
  3. package/dist/EditorPageRouter.js +34 -0
  4. package/dist/EditorPageRoutes.d.ts +1 -0
  5. package/dist/EditorPageRoutes.js +16 -0
  6. package/dist/EntryEditor.js +30 -29
  7. package/dist/EntrySidebar.js +26 -5
  8. package/dist/NotFound.d.ts +1 -0
  9. package/dist/NotFound.js +18 -0
  10. package/dist/asset/index.d.ts +1 -0
  11. package/dist/{core/api → asset}/index.js +1 -3
  12. package/dist/{core → asset}/repository/AssetRepository.d.ts +11 -3
  13. package/dist/{core → asset}/repository/AssetRepository.js +6 -5
  14. package/dist/asset/repository/index.d.ts +1 -0
  15. package/dist/{core → asset}/repository/index.js +0 -4
  16. package/dist/collection/controller/{LocalCollectionController.d.ts → ContentfulCollectionController.d.ts} +17 -11
  17. package/dist/collection/controller/ContentfulCollectionController.js +278 -0
  18. package/dist/collection/controller/ContentfulCollectionControllerContainer.d.ts +5 -0
  19. package/dist/collection/controller/ContentfulCollectionControllerContainer.js +28 -0
  20. package/dist/collection/controller/index.d.ts +3 -4
  21. package/dist/collection/controller/index.js +3 -4
  22. package/dist/collection/controller/useContentfulCollectionController.d.ts +2 -0
  23. package/dist/collection/controller/useContentfulCollectionController.js +8 -0
  24. package/dist/{core → collection}/domain/Collection.d.ts +11 -2
  25. package/dist/{core → collection}/domain/Collection.js +76 -0
  26. package/dist/{core → collection}/domain/index.d.ts +0 -1
  27. package/dist/{core → collection}/domain/index.js +0 -1
  28. package/dist/collection/index.d.ts +1 -0
  29. package/dist/collection/index.js +1 -0
  30. package/dist/collection/repository/CollectionRepository.d.ts +49 -0
  31. package/dist/collection/repository/CollectionRepository.js +223 -0
  32. package/dist/collection/repository/index.d.ts +1 -0
  33. package/dist/{core/contentful → collection/repository}/index.js +1 -5
  34. package/dist/collection/screens/CollectionEditor.js +23 -6
  35. package/dist/core/bridge/AppBridge.d.ts +31 -0
  36. package/dist/core/bridge/AppBridge.js +160 -0
  37. package/dist/core/bridge/AppBridgeContainer.d.ts +3 -3
  38. package/dist/core/bridge/AppBridgeContainer.js +8 -44
  39. package/dist/core/bridge/AppBridgeContext.d.ts +7 -8
  40. package/dist/core/bridge/AppBridgeContext.js +1 -6
  41. package/dist/core/bridge/BridgeLifecycleMessage.d.ts +7 -0
  42. package/dist/core/bridge/BridgeLifecycleMessage.js +12 -0
  43. package/dist/core/bridge/IAppBridgeMessage.d.ts +16 -0
  44. package/dist/core/bridge/IAppBridgeMessage.js +12 -0
  45. package/dist/core/bridge/index.d.ts +2 -1
  46. package/dist/core/bridge/index.js +2 -1
  47. package/dist/core/bridge/useAppBridge.d.ts +2 -8
  48. package/dist/core/bridge/useAppBridge.js +24 -15
  49. package/dist/core/client/ContentfulClientContainer.d.ts +8 -0
  50. package/dist/core/client/ContentfulClientContainer.js +43 -0
  51. package/dist/core/client/ContentfulClientContext.d.ts +8 -0
  52. package/dist/core/client/ContentfulClientContext.js +8 -0
  53. package/dist/core/client/index.d.ts +3 -0
  54. package/dist/core/client/index.js +19 -0
  55. package/dist/core/client/useContentfulClient.d.ts +4 -0
  56. package/dist/core/client/useContentfulClient.js +24 -0
  57. package/dist/core/index.d.ts +1 -4
  58. package/dist/core/index.js +1 -4
  59. package/dist/explore/components/header/Header.d.ts +14 -0
  60. package/dist/explore/components/header/Header.js +33 -0
  61. package/dist/explore/components/header/HeaderActions.d.ts +8 -0
  62. package/dist/explore/components/header/HeaderActions.js +37 -0
  63. package/dist/explore/components/header/HeaderContainer.d.ts +2 -0
  64. package/dist/explore/components/header/HeaderContainer.js +15 -0
  65. package/dist/explore/components/header/HeaderContext.d.ts +7 -0
  66. package/dist/{core/api/EditorApiContext.js → explore/components/header/HeaderContext.js} +2 -2
  67. package/dist/explore/components/header/HeaderController.d.ts +39 -0
  68. package/dist/explore/components/header/HeaderController.js +100 -0
  69. package/dist/explore/components/header/HeaderOptions.d.ts +10 -0
  70. package/dist/explore/components/header/HeaderOptions.js +26 -0
  71. package/dist/explore/components/header/index.d.ts +5 -0
  72. package/dist/explore/components/header/index.js +21 -0
  73. package/dist/explore/components/header/useHeader.d.ts +2 -0
  74. package/dist/explore/components/header/useHeader.js +30 -0
  75. package/dist/explore/components/index.d.ts +2 -0
  76. package/dist/explore/components/index.js +18 -0
  77. package/dist/explore/components/pages/PagesExplorerLayout.d.ts +4 -0
  78. package/dist/explore/components/pages/PagesExplorerLayout.js +28 -0
  79. package/dist/explore/components/pages/index.d.ts +1 -0
  80. package/dist/explore/components/pages/index.js +17 -0
  81. package/dist/explore/index.d.ts +2 -0
  82. package/dist/explore/index.js +18 -0
  83. package/dist/explore/screens/Dashboard.d.ts +4 -0
  84. package/dist/explore/screens/Dashboard.js +55 -0
  85. package/dist/explore/screens/PageExplorer.d.ts +11 -0
  86. package/dist/explore/screens/PageExplorer.js +129 -0
  87. package/dist/explore/screens/PagesExplorer.d.ts +7 -0
  88. package/dist/explore/screens/PagesExplorer.js +98 -0
  89. package/dist/explore/screens/index.d.ts +3 -0
  90. package/dist/explore/screens/index.js +19 -0
  91. package/dist/page/bridge/BlockChangedMessage.d.ts +25 -0
  92. package/dist/page/bridge/BlockChangedMessage.js +18 -0
  93. package/dist/page/bridge/PageBridgeHub.d.ts +8 -0
  94. package/dist/page/bridge/PageBridgeHub.js +51 -0
  95. package/dist/page/bridge/index.d.ts +2 -0
  96. package/dist/page/bridge/index.js +18 -0
  97. package/dist/page/controller/{LocalPageController.d.ts → ContentfulPageController.d.ts} +15 -9
  98. package/dist/page/controller/ContentfulPageController.js +277 -0
  99. package/dist/page/controller/ContentfulPageControllerContainer.d.ts +5 -0
  100. package/dist/page/controller/ContentfulPageControllerContainer.js +28 -0
  101. package/dist/page/controller/index.d.ts +3 -3
  102. package/dist/page/controller/index.js +3 -3
  103. package/dist/page/controller/useContentfulPageController.d.ts +2 -0
  104. package/dist/page/controller/useContentfulPageController.js +8 -0
  105. package/dist/{core → page}/domain/Page.d.ts +23 -12
  106. package/dist/{core → page}/domain/Page.js +139 -0
  107. package/dist/page/domain/index.d.ts +1 -0
  108. package/dist/page/domain/index.js +17 -0
  109. package/dist/page/index.d.ts +3 -0
  110. package/dist/page/index.js +3 -0
  111. package/dist/page/repository/PageRepository.d.ts +45 -0
  112. package/dist/page/repository/PageRepository.js +241 -0
  113. package/dist/page/repository/index.d.ts +1 -0
  114. package/dist/page/repository/index.js +17 -0
  115. package/dist/page/screens/PageEditor.js +36 -12
  116. package/package.json +9 -5
  117. package/dist/collection/controller/LocalCollectionController.js +0 -200
  118. package/dist/collection/controller/LocalCollectionControllerContainer.d.ts +0 -8
  119. package/dist/collection/controller/LocalCollectionControllerContainer.js +0 -36
  120. package/dist/collection/controller/LocalCollectionControllerContext.d.ts +0 -7
  121. package/dist/collection/controller/LocalCollectionControllerContext.js +0 -6
  122. package/dist/collection/controller/useLocalCollectionController.d.ts +0 -2
  123. package/dist/collection/controller/useLocalCollectionController.js +0 -10
  124. package/dist/core/api/EditorApiClient.d.ts +0 -7
  125. package/dist/core/api/EditorApiClient.js +0 -29
  126. package/dist/core/api/EditorApiContainer.d.ts +0 -5
  127. package/dist/core/api/EditorApiContainer.js +0 -16
  128. package/dist/core/api/EditorApiContext.d.ts +0 -7
  129. package/dist/core/api/index.d.ts +0 -3
  130. package/dist/core/api/useEditorApi.d.ts +0 -2
  131. package/dist/core/api/useEditorApi.js +0 -12
  132. package/dist/core/bridge/AppMessage.d.ts +0 -19
  133. package/dist/core/bridge/AppMessage.js +0 -19
  134. package/dist/core/contentful/Contentful.d.ts +0 -33
  135. package/dist/core/contentful/Contentful.js +0 -67
  136. package/dist/core/contentful/ContentfulAsset.d.ts +0 -23
  137. package/dist/core/contentful/ContentfulAsset.js +0 -88
  138. package/dist/core/contentful/ContentfulCollection.d.ts +0 -29
  139. package/dist/core/contentful/ContentfulCollection.js +0 -97
  140. package/dist/core/contentful/ContentfulPage.d.ts +0 -31
  141. package/dist/core/contentful/ContentfulPage.js +0 -84
  142. package/dist/core/contentful/ContentfulRefs.d.ts +0 -16
  143. package/dist/core/contentful/ContentfulRefs.js +0 -152
  144. package/dist/core/contentful/index.d.ts +0 -5
  145. package/dist/core/repository/CollectionSerializer.d.ts +0 -9
  146. package/dist/core/repository/CollectionSerializer.js +0 -41
  147. package/dist/core/repository/LocalCollectionRepository.d.ts +0 -27
  148. package/dist/core/repository/LocalCollectionRepository.js +0 -143
  149. package/dist/core/repository/LocalPageRepository.d.ts +0 -16
  150. package/dist/core/repository/LocalPageRepository.js +0 -153
  151. package/dist/core/repository/PageSerializer.d.ts +0 -9
  152. package/dist/core/repository/PageSerializer.js +0 -47
  153. package/dist/core/repository/RemoteCollectionRepository.d.ts +0 -19
  154. package/dist/core/repository/RemoteCollectionRepository.js +0 -236
  155. package/dist/core/repository/RemotePageRepository.d.ts +0 -14
  156. package/dist/core/repository/RemotePageRepository.js +0 -113
  157. package/dist/core/repository/index.d.ts +0 -5
  158. package/dist/page/controller/LocalPageController.js +0 -190
  159. package/dist/page/controller/LocalPageControllerContainer.d.ts +0 -8
  160. package/dist/page/controller/LocalPageControllerContainer.js +0 -36
  161. package/dist/page/controller/LocalPageControllerContext.d.ts +0 -7
  162. package/dist/page/controller/LocalPageControllerContext.js +0 -6
  163. package/dist/page/controller/useLocalPageController.d.ts +0 -2
  164. package/dist/page/controller/useLocalPageController.js +0 -10
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EditorApiClient = void 0;
4
- // class
5
- class EditorApiClient {
6
- constructor(sdk) {
7
- this.sdk = sdk;
8
- }
9
- async currentPageGroup() {
10
- const entry = this.sdk.entry;
11
- const { type, content } = entry.fields;
12
- return {
13
- group: {},
14
- page: {
15
- data: {
16
- id: entry.getSys().id,
17
- type: 'home', // type.getValue(),
18
- region: 'ca',
19
- language: 'en',
20
- content: content.getValue(),
21
- },
22
- files: {},
23
- pages: {},
24
- collections: {},
25
- },
26
- };
27
- }
28
- }
29
- exports.EditorApiClient = EditorApiClient;
@@ -1,5 +0,0 @@
1
- import { PropsWithChildren } from 'react';
2
- export declare function EditorApiContainer({ children }: EditorApiContainer.Props): import("react/jsx-runtime").JSX.Element;
3
- export declare namespace EditorApiContainer {
4
- type Props = PropsWithChildren;
5
- }
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EditorApiContainer = EditorApiContainer;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_apps_toolkit_1 = require("@contentful/react-apps-toolkit");
6
- const react_1 = require("react");
7
- const EditorApiClient_1 = require("./EditorApiClient");
8
- const EditorApiContext_1 = require("./EditorApiContext");
9
- // container
10
- function EditorApiContainer({ children }) {
11
- // bind context
12
- const sdk = (0, react_apps_toolkit_1.useSDK)();
13
- const context = (0, react_1.useMemo)(() => ({ client: new EditorApiClient_1.EditorApiClient(sdk) }), [sdk]);
14
- // render
15
- return ((0, jsx_runtime_1.jsx)(EditorApiContext_1.EditorApiContext.Provider, { value: context, children: children }));
16
- }
@@ -1,7 +0,0 @@
1
- import { EditorApiClient } from './EditorApiClient';
2
- export declare const EditorApiContext: import("react").Context<EditorApiContext.Type>;
3
- export declare namespace EditorApiContext {
4
- type Type = {
5
- client: EditorApiClient;
6
- };
7
- }
@@ -1,3 +0,0 @@
1
- export * from './EditorApiClient';
2
- export * from './EditorApiContainer';
3
- export * from './useEditorApi';
@@ -1,2 +0,0 @@
1
- import { EditorApiClient } from './EditorApiClient';
2
- export declare function useEditorApi(): EditorApiClient;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useEditorApi = useEditorApi;
4
- const react_1 = require("react");
5
- const EditorApiContext_1 = require("./EditorApiContext");
6
- // hook
7
- function useEditorApi() {
8
- // bind context
9
- const { client } = (0, react_1.useContext)(EditorApiContext_1.EditorApiContext);
10
- // return client
11
- return client;
12
- }
@@ -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
- media: Contentful.Link.Asset;
12
- metadata: object;
13
- scope: string;
14
- tags?: string | null;
15
- url: string;
16
- size: number;
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,88 +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
- var _a, _b, _c;
12
- // setup
13
- const locale = sdk.locales.default;
14
- // upload file
15
- const uploadResult = await sdk.cma.upload.create({}, {
16
- file: await args.file.arrayBuffer()
17
- });
18
- // create contentful asset
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]: JSON.stringify(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
- // extract fields
68
- const { name, description, type, brand, metadata, scope, tags, url, size } = entry.fields;
69
- // create asset
70
- return {
71
- __root: 'asset',
72
- type: 'asset',
73
- value: {
74
- id: entry.sys.id,
75
- name: name[locale],
76
- description: description === null || description === void 0 ? void 0 : description[locale],
77
- type: type[locale],
78
- brand: (_a = brand === null || brand === void 0 ? void 0 : brand[locale]) !== null && _a !== void 0 ? _a : undefined,
79
- metadata: metadata[locale],
80
- scope: scope[locale],
81
- tags: JSON.parse((_b = tags === null || tags === void 0 ? void 0 : tags[locale]) !== null && _b !== void 0 ? _b : '[]'),
82
- url: url[locale],
83
- size: size[locale]
84
- }
85
- };
86
- }
87
- ContentfulAsset.serialize = serialize;
88
- })(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
- references?: Contentful.Link[];
15
- pageRefIds?: string;
16
- state: string;
17
- errors: boolean;
18
- publishedOn?: number;
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
- }