@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
@@ -1,236 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RemoteCollectionRepository = void 0;
4
- const funnel_core_1 = require("@nascentdigital/funnel-core");
5
- const components_1 = require("@nascentdigital/funnel-editor/components");
6
- const contentful_1 = require("../contentful");
7
- // class
8
- class RemoteCollectionRepository {
9
- constructor(sdk) {
10
- this.sdk = sdk;
11
- }
12
- async create(args) {
13
- throw new funnel_core_1.NotImplementedError();
14
- }
15
- async createRaw(args) {
16
- // locale
17
- const locale = this.sdk.locales.default;
18
- const groupId = funnel_core_1.Value.uuid();
19
- const brand = funnel_core_1.AppConfig.brand();
20
- const name = args.name;
21
- // create entry
22
- const entry = await this.sdk.cma.entry.create({ contentTypeId: contentful_1.ContentfulCollection.contentTypeId }, {
23
- fields: {
24
- groupId: { [locale]: groupId },
25
- type: { [locale]: args.template.type },
26
- version: { [locale]: args.template.version },
27
- brand: { [locale]: brand },
28
- name: { [locale]: name },
29
- tags: { [locale]: JSON.stringify(args.tags) },
30
- language: { [locale]: args.language },
31
- }
32
- });
33
- // serialize entry to data
34
- const data = contentful_1.ContentfulCollection.serializeRemote(entry, locale);
35
- // return as group data
36
- return {
37
- collection: {
38
- data,
39
- collections: {},
40
- files: {}
41
- },
42
- group: {
43
- groupId,
44
- type: args.template.type,
45
- brand,
46
- name,
47
- instances: [{
48
- id: data.id,
49
- version: data.version,
50
- language: data.language,
51
- tags: data.tags
52
- }]
53
- }
54
- };
55
- }
56
- async createLanguage(args) {
57
- throw new funnel_core_1.NotImplementedError();
58
- }
59
- async save(collection) {
60
- throw new funnel_core_1.NotImplementedError();
61
- }
62
- async unpublish(collection) {
63
- throw new funnel_core_1.NotImplementedError();
64
- }
65
- async getOverview(args) {
66
- // locale
67
- const locale = this.sdk.locales.default;
68
- // collection templates
69
- const templates = funnel_core_1.Schema.Site.current().collections;
70
- // set counts to zero
71
- const collectionCounts = new Map();
72
- templates.forEach(template => collectionCounts.set(template.type, 0));
73
- // fetch thin collections
74
- const collections = await contentful_1.Contentful.allEntries(this.sdk, {
75
- content_type: contentful_1.ContentfulCollection.contentTypeId,
76
- select: 'fields.type'
77
- });
78
- // count each type
79
- collections.forEach(collection => {
80
- const type = collection.fields.type[locale];
81
- const count = collectionCounts.get(type);
82
- if (count !== undefined) {
83
- collectionCounts.set(type, count + 1);
84
- }
85
- });
86
- // return decorated templates
87
- return templates.map(template => {
88
- var _a;
89
- return ({
90
- template,
91
- type: template.type,
92
- count: (_a = collectionCounts.get(template.type)) !== null && _a !== void 0 ? _a : 0
93
- });
94
- });
95
- }
96
- async getItems({ type, tags, language }) {
97
- // locale
98
- const locale = this.sdk.locales.default;
99
- // query entries
100
- // TODO: implement tags filter
101
- const items = await contentful_1.Contentful.allEntries(this.sdk, {
102
- content_type: contentful_1.ContentfulCollection.contentTypeId,
103
- [`fields.type.${locale}`]: type
104
- });
105
- // group entries by groupId
106
- const groups = new Map();
107
- items.forEach(item => {
108
- const groupId = item.fields.groupId[locale];
109
- const group = groups.get(groupId);
110
- if (group) {
111
- group.push(item);
112
- }
113
- else {
114
- groups.set(groupId, [item]);
115
- }
116
- });
117
- // create items
118
- const result = [];
119
- for (const [groupId, entries] of groups) {
120
- // find entry matching arg language
121
- const mainEntry = entries.find(entry => entry.fields.language[locale] === language);
122
- if (!mainEntry) {
123
- continue;
124
- }
125
- // create item
126
- result.push({
127
- id: mainEntry.sys.id,
128
- type: mainEntry.fields.type[locale],
129
- groupId: groupId,
130
- name: mainEntry.fields.name[locale],
131
- refs: entries.reduce((refs, ref) => {
132
- // serialize ref
133
- const refLang = ref.fields.language[locale];
134
- refs[refLang] = contentful_1.ContentfulCollection.serializeRemoteRef(ref, locale);
135
- // keep reducing
136
- return refs;
137
- }, {})
138
- });
139
- }
140
- return result;
141
- }
142
- async get({ id }) {
143
- // locale
144
- const locale = this.sdk.locales.default;
145
- // search by id (expect 0 or 1 items)
146
- const response = await this.sdk.cma.entry.getMany({
147
- query: { 'sys.id': id, include: 1 }
148
- });
149
- // no results
150
- if (response.items.length === 0) {
151
- return undefined;
152
- }
153
- // bad state
154
- else if (response.items.length > 1) {
155
- throw new funnel_core_1.IllegalStateError(`There is more than one entry with id "${id}"`);
156
- }
157
- // serialize single item
158
- else {
159
- return contentful_1.ContentfulCollection.serializeRemoteWithRefs(response.items[0], locale);
160
- }
161
- }
162
- async update(args) {
163
- // locale
164
- const locale = this.sdk.locales.default;
165
- // fetch latest version of collection
166
- const entry = await this.sdk.cma.entry.get({ entryId: args.id });
167
- const data = contentful_1.ContentfulCollection.serializeRemote(entry, locale);
168
- // apply updates
169
- const model = new funnel_core_1.Schema.CollectionModel(data);
170
- model.update(args.updates);
171
- // update fields
172
- entry.fields.name = { [locale]: data.name };
173
- entry.fields.fields = { [locale]: data.fields };
174
- // update entry
175
- const updatedEntry = await this.sdk.cma.entry.update({ entryId: args.id }, entry);
176
- const updatedOn = new Date(updatedEntry.sys.updatedAt).getTime();
177
- // return
178
- return {
179
- // TODO: get latest references
180
- collection: { data, collections: {}, files: {} },
181
- updatedOn,
182
- changeSetId: ''
183
- };
184
- }
185
- serializeUpdate(collection, savables) {
186
- // add name updates
187
- const { id, nameField, name, initialTags, tags, fields, initialErrors, valid } = collection;
188
- const updates = [];
189
- if (nameField.modified) {
190
- updates.push({
191
- type: 'collection',
192
- property: 'name',
193
- value: name
194
- });
195
- // track change
196
- savables.push(nameField);
197
- }
198
- // add tag updates
199
- if (initialTags.symmetricDifference(tags).size > 0) {
200
- updates.push({
201
- type: 'collection',
202
- property: 'tags',
203
- value: Array.from(tags).map(tag => tag.data)
204
- });
205
- }
206
- // add errors updates
207
- if (initialErrors !== !valid) {
208
- updates.push({
209
- type: 'collection',
210
- property: 'errors',
211
- value: !valid
212
- });
213
- }
214
- // add fields
215
- components_1.SerializeCollectionUpdate.serializeFieldsUpdate(updates, fields, ['fields'], savables);
216
- // return updates
217
- return {
218
- id,
219
- updates,
220
- updatedOn: Date.now()
221
- };
222
- }
223
- async getReferences(collectionId) {
224
- // setup
225
- const { sdk } = this;
226
- const locale = sdk.locales.default;
227
- // fetch references
228
- const references = await sdk.cma.entry.references({
229
- entryId: collectionId,
230
- include: 10
231
- });
232
- // serialize and return
233
- return contentful_1.ContentfulRefs.serialize(references, locale);
234
- }
235
- }
236
- exports.RemoteCollectionRepository = RemoteCollectionRepository;
@@ -1,14 +0,0 @@
1
- import { EditorAppSDK } from '@contentful/app-sdk';
2
- import { Schema } from '@nascentdigital/funnel-core';
3
- import { IPage, IPageRepository } from '@nascentdigital/funnel-editor/components';
4
- export declare class RemotePageRepository implements IPageRepository {
5
- readonly sdk: EditorAppSDK;
6
- constructor(sdk: EditorAppSDK);
7
- search(args: IPageRepository.Search.Args): Promise<IPageRepository.Search.Result>;
8
- create(args: IPageRepository.Create.Args): Promise<IPageRepository.Create.Result>;
9
- createLanguage(args: IPageRepository.CreateLang.Args): Promise<IPageRepository.CreateLang.Result>;
10
- save(page: IPage): Promise<IPage>;
11
- unpublish(page: IPage): Promise<void>;
12
- getOverview(args: IPageRepository.GetOverview.Args): Promise<IPageRepository.GetOverview.Result>;
13
- getReferences(pageId: Schema.Page.Id): Promise<IPage.References>;
14
- }
@@ -1,113 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.RemotePageRepository = void 0;
15
- const funnel_core_1 = require("@nascentdigital/funnel-core");
16
- const components_1 = require("@nascentdigital/funnel-editor/components");
17
- const contentful_1 = require("../contentful");
18
- // class
19
- class RemotePageRepository {
20
- constructor(sdk) {
21
- this.sdk = sdk;
22
- }
23
- async search(args) {
24
- // locale
25
- const locale = this.sdk.locales.default;
26
- // templates
27
- const templates = funnel_core_1.Schema.Site.current().regions[args.region];
28
- // fetch all pages
29
- // TODO: implement paging
30
- // TODO: implement other search args
31
- const pages = await contentful_1.Contentful.allEntries(this.sdk, {
32
- content_type: contentful_1.ContentfulPage.contentTypeId,
33
- [`fields.type`]: args.template.type
34
- });
35
- // return result
36
- return {
37
- items: pages.map(page => {
38
- const _a = contentful_1.ContentfulPage.serializeRemoteLink(page, locale), { type, tags } = _a, data = __rest(_a, ["type", "tags"]);
39
- const template = templates[type];
40
- return Object.assign({ template, tags: components_1.TagSerializer.deserializeTags({
41
- groups: template.tags,
42
- tagsData: tags
43
- }) }, data);
44
- }),
45
- page: 1,
46
- pageCount: 1,
47
- totalItemCount: pages.length
48
- };
49
- }
50
- async create(args) {
51
- throw new funnel_core_1.NotImplementedError();
52
- }
53
- async createLanguage(args) {
54
- throw new funnel_core_1.NotImplementedError();
55
- }
56
- async save(page) {
57
- throw new funnel_core_1.NotImplementedError();
58
- }
59
- async unpublish(page) {
60
- throw new funnel_core_1.NotImplementedError();
61
- }
62
- async getOverview(args) {
63
- // fetch all pages
64
- const pages = await contentful_1.Contentful.allEntriesNormalized(this.sdk, {
65
- content_type: contentful_1.ContentfulPage.contentTypeId
66
- });
67
- // enrich with templates and flip to array
68
- const templates = Object.values(funnel_core_1.Schema.Site.current().regions[args.region]);
69
- return templates.map(template => {
70
- // extract static page overview
71
- const { type } = template;
72
- if (template.variant === 'static') {
73
- const staticPages = pages.filter(page => page.type === type);
74
- return new components_1.StaticPageOverview({
75
- template,
76
- type,
77
- refs: staticPages.reduce((refs, page) => {
78
- // page language (bail if no language)
79
- const language = page.language;
80
- if (!language) {
81
- return refs;
82
- }
83
- // add page link
84
- refs[language] = contentful_1.ContentfulPage.normalizedToLink(page);
85
- // keep reducing
86
- return refs;
87
- }, {})
88
- });
89
- }
90
- // or dynamic one
91
- else {
92
- return new components_1.DynamicPageOverview({
93
- template,
94
- type,
95
- count: pages.filter(page => page.type === type).length,
96
- });
97
- }
98
- });
99
- }
100
- async getReferences(pageId) {
101
- // setup
102
- const { sdk } = this;
103
- const locale = sdk.locales.default;
104
- // fetch references
105
- const references = await sdk.cma.entry.references({
106
- entryId: pageId,
107
- include: 10
108
- });
109
- // serialize and return
110
- return contentful_1.ContentfulRefs.serialize(references, locale);
111
- }
112
- }
113
- exports.RemotePageRepository = RemotePageRepository;
@@ -1,4 +0,0 @@
1
- export * from './LocalCollectionRepository';
2
- export * from './LocalPageRepository';
3
- export * from './RemoteCollectionRepository';
4
- export * from './RemotePageRepository';
@@ -1,26 +0,0 @@
1
- import { Callback } from '@nascentdigital/funnel-core';
2
- import { PropsWithChildren } from 'react';
3
- export declare function Header({ className, title, breadcrumbs: breadcrumbsRaw, highlightBreadcrumb, back, onBack, disableBack, hideControls, children }: Header.Props): import("react/jsx-runtime").JSX.Element;
4
- export declare namespace Header {
5
- type Breadcrumb = Breadcrumb.Label | Breadcrumb.Link;
6
- namespace Breadcrumb {
7
- type Label = string;
8
- type Link = {
9
- label: string;
10
- url: string;
11
- };
12
- }
13
- type Props = PropsWithChildren & {
14
- className?: string;
15
- title?: string;
16
- subtitle?: string;
17
- label?: string;
18
- breadcrumbs?: ReadonlyArray<Breadcrumb>;
19
- highlightBreadcrumb?: boolean;
20
- back: BackVariant;
21
- onBack?: Callback.Void;
22
- disableBack?: boolean;
23
- hideControls?: boolean;
24
- };
25
- type BackVariant = 'back' | 'close' | 'none';
26
- }
@@ -1 +0,0 @@
1
- export declare function SiteExplorer(): import("react/jsx-runtime").JSX.Element;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SiteExplorer = SiteExplorer;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const components_1 = require("@nascentdigital/funnel-editor/components");
6
- const react_1 = require("react");
7
- const react_router_1 = require("react-router");
8
- const components_2 = require("../components");
9
- // screen
10
- function SiteExplorer() {
11
- // bind hooks
12
- const navigate = (0, react_router_1.useNavigate)();
13
- const site = (0, components_1.useSite)();
14
- const splash = (0, components_1.useSplash)();
15
- const { ready } = site;
16
- // dismiss splash
17
- (0, react_1.useEffect)(() => {
18
- if (ready) {
19
- splash.dismiss();
20
- }
21
- }, [splash, ready]);
22
- // render
23
- return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(components_2.Header, { breadcrumbs: ['Dashboard', 'Sites'], back: "back", onBack: () => navigate('/contentful') }), (0, jsx_runtime_1.jsx)(react_router_1.Link, { to: "/contentful", children: "Back to Dashboard" })] }));
24
- }