@nascentdigital/funnel-editor-contentful 4.6.7 → 5.0.2

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 (129) hide show
  1. package/dist/Editor.d.ts +6 -1
  2. package/dist/Editor.js +17 -1
  3. package/dist/EditorApp.js +11 -9
  4. package/dist/EditorPageRouter.d.ts +1 -0
  5. package/dist/EditorPageRouter.js +40 -0
  6. package/dist/EntryEditor.js +43 -1
  7. package/dist/EntrySidebar.js +18 -1
  8. package/dist/asset/index.d.ts +1 -0
  9. package/dist/{page/hooks → asset}/index.js +1 -1
  10. package/dist/asset/repository/AssetRepository.d.ts +10 -0
  11. package/dist/asset/repository/AssetRepository.js +33 -0
  12. package/dist/asset/repository/index.d.ts +1 -0
  13. package/dist/{core/api → asset/repository}/index.js +1 -3
  14. package/dist/collection/controller/ContentfulCollectionController.d.ts +41 -0
  15. package/dist/collection/controller/ContentfulCollectionController.js +278 -0
  16. package/dist/collection/controller/ContentfulCollectionControllerContainer.d.ts +5 -0
  17. package/dist/collection/controller/ContentfulCollectionControllerContainer.js +28 -0
  18. package/dist/collection/controller/index.d.ts +3 -0
  19. package/dist/collection/controller/index.js +19 -0
  20. package/dist/collection/controller/useContentfulCollectionController.d.ts +2 -0
  21. package/dist/collection/controller/useContentfulCollectionController.js +8 -0
  22. package/dist/collection/domain/Collection.d.ts +108 -0
  23. package/dist/collection/domain/Collection.js +386 -0
  24. package/dist/collection/domain/index.d.ts +1 -0
  25. package/dist/collection/domain/index.js +17 -0
  26. package/dist/collection/index.d.ts +3 -0
  27. package/dist/collection/index.js +19 -0
  28. package/dist/collection/repository/CollectionRepository.d.ts +49 -0
  29. package/dist/collection/repository/CollectionRepository.js +210 -0
  30. package/dist/collection/repository/index.d.ts +1 -0
  31. package/dist/collection/repository/index.js +17 -0
  32. package/dist/collection/screens/CollectionEditor.d.ts +1 -0
  33. package/dist/collection/screens/CollectionEditor.js +59 -0
  34. package/dist/collection/screens/index.d.ts +1 -0
  35. package/dist/collection/screens/index.js +17 -0
  36. package/dist/core/bridge/AppBridgeContainer.d.ts +9 -0
  37. package/dist/core/bridge/AppBridgeContainer.js +55 -0
  38. package/dist/core/bridge/AppBridgeContext.d.ts +8 -0
  39. package/dist/core/bridge/AppBridgeContext.js +11 -0
  40. package/dist/core/bridge/AppMessage.d.ts +19 -0
  41. package/dist/core/bridge/AppMessage.js +19 -0
  42. package/dist/core/bridge/index.d.ts +4 -0
  43. package/dist/core/bridge/index.js +20 -0
  44. package/dist/core/bridge/useAppBridge.d.ts +8 -0
  45. package/dist/core/bridge/useAppBridge.js +24 -0
  46. package/dist/core/client/ContentfulClientContainer.d.ts +8 -0
  47. package/dist/core/client/ContentfulClientContainer.js +43 -0
  48. package/dist/core/client/ContentfulClientContext.d.ts +8 -0
  49. package/dist/core/client/ContentfulClientContext.js +8 -0
  50. package/dist/core/client/index.d.ts +3 -0
  51. package/dist/core/client/index.js +19 -0
  52. package/dist/core/client/useContentfulClient.d.ts +4 -0
  53. package/dist/core/client/useContentfulClient.js +24 -0
  54. package/dist/core/contentful/Contentful.d.ts +33 -0
  55. package/dist/core/contentful/Contentful.js +67 -0
  56. package/dist/core/contentful/ContentfulAsset.d.ts +23 -0
  57. package/dist/core/contentful/ContentfulAsset.js +89 -0
  58. package/dist/core/contentful/ContentfulCollection.d.ts +29 -0
  59. package/dist/core/contentful/ContentfulCollection.js +97 -0
  60. package/dist/core/contentful/ContentfulPage.d.ts +31 -0
  61. package/dist/core/contentful/ContentfulPage.js +84 -0
  62. package/dist/core/contentful/ContentfulRefs.d.ts +16 -0
  63. package/dist/core/contentful/ContentfulRefs.js +152 -0
  64. package/dist/core/contentful/index.d.ts +5 -0
  65. package/dist/core/contentful/index.js +21 -0
  66. package/dist/core/index.d.ts +3 -2
  67. package/dist/core/index.js +3 -2
  68. package/dist/core/repository/CollectionSerializer.d.ts +9 -0
  69. package/dist/core/repository/CollectionSerializer.js +41 -0
  70. package/dist/core/repository/LocalCollectionRepository.d.ts +27 -0
  71. package/dist/core/repository/LocalCollectionRepository.js +143 -0
  72. package/dist/core/repository/LocalPageRepository.d.ts +16 -0
  73. package/dist/core/repository/LocalPageRepository.js +153 -0
  74. package/dist/core/repository/PageSerializer.d.ts +3 -3
  75. package/dist/core/repository/PageSerializer.js +18 -14
  76. package/dist/core/repository/RemoteCollectionRepository.d.ts +19 -0
  77. package/dist/core/repository/RemoteCollectionRepository.js +236 -0
  78. package/dist/core/repository/RemotePageRepository.d.ts +14 -0
  79. package/dist/core/repository/RemotePageRepository.js +113 -0
  80. package/dist/core/repository/index.d.ts +4 -1
  81. package/dist/core/repository/index.js +4 -1
  82. package/dist/explore/components/Header.d.ts +26 -0
  83. package/dist/explore/components/Header.js +31 -0
  84. package/dist/explore/components/index.d.ts +1 -0
  85. package/dist/explore/components/index.js +17 -0
  86. package/dist/explore/index.d.ts +1 -0
  87. package/dist/explore/index.js +17 -0
  88. package/dist/explore/screens/Dashboard.d.ts +1 -0
  89. package/dist/explore/screens/Dashboard.js +22 -0
  90. package/dist/explore/screens/PageExplorer.d.ts +1 -0
  91. package/dist/explore/screens/PageExplorer.js +9 -0
  92. package/dist/explore/screens/SiteExplorer.d.ts +1 -0
  93. package/dist/explore/screens/SiteExplorer.js +24 -0
  94. package/dist/explore/screens/index.d.ts +3 -0
  95. package/dist/explore/screens/index.js +19 -0
  96. package/dist/page/{hooks/PageController.d.ts → controller/ContentfulPageController.d.ts} +17 -6
  97. package/dist/page/controller/ContentfulPageController.js +277 -0
  98. package/dist/page/controller/ContentfulPageControllerContainer.d.ts +5 -0
  99. package/dist/page/controller/ContentfulPageControllerContainer.js +28 -0
  100. package/dist/page/controller/index.d.ts +3 -0
  101. package/dist/page/controller/index.js +19 -0
  102. package/dist/page/controller/useContentfulPageController.d.ts +2 -0
  103. package/dist/page/controller/useContentfulPageController.js +8 -0
  104. package/dist/{core → page}/domain/Page.d.ts +71 -10
  105. package/dist/page/domain/Page.js +631 -0
  106. package/dist/page/index.d.ts +3 -0
  107. package/dist/page/index.js +3 -0
  108. package/dist/page/repository/PageRepository.d.ts +45 -0
  109. package/dist/page/repository/PageRepository.js +224 -0
  110. package/dist/page/repository/index.d.ts +1 -0
  111. package/dist/page/repository/index.js +17 -0
  112. package/dist/page/screens/PageEditor.js +29 -15
  113. package/package.json +10 -4
  114. package/dist/core/api/EditorApiClient.d.ts +0 -7
  115. package/dist/core/api/EditorApiClient.js +0 -29
  116. package/dist/core/api/EditorApiContainer.d.ts +0 -5
  117. package/dist/core/api/EditorApiContainer.js +0 -16
  118. package/dist/core/api/EditorApiContext.d.ts +0 -7
  119. package/dist/core/api/EditorApiContext.js +0 -6
  120. package/dist/core/api/index.d.ts +0 -3
  121. package/dist/core/api/useEditorApi.d.ts +0 -2
  122. package/dist/core/api/useEditorApi.js +0 -12
  123. package/dist/core/domain/Page.js +0 -180
  124. package/dist/core/repository/PageRepository.d.ts +0 -12
  125. package/dist/core/repository/PageRepository.js +0 -23
  126. package/dist/page/hooks/PageController.js +0 -107
  127. package/dist/page/hooks/index.d.ts +0 -1
  128. /package/dist/{core → page}/domain/index.d.ts +0 -0
  129. /package/dist/{core → page}/domain/index.js +0 -0
@@ -0,0 +1,236 @@
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;
@@ -0,0 +1,14 @@
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
+ }
@@ -0,0 +1,113 @@
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 +1,4 @@
1
- export * from './PageRepository';
1
+ export * from './LocalCollectionRepository';
2
+ export * from './LocalPageRepository';
3
+ export * from './RemoteCollectionRepository';
4
+ export * from './RemotePageRepository';
@@ -14,4 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./PageRepository"), exports);
17
+ __exportStar(require("./LocalCollectionRepository"), exports);
18
+ __exportStar(require("./LocalPageRepository"), exports);
19
+ __exportStar(require("./RemoteCollectionRepository"), exports);
20
+ __exportStar(require("./RemotePageRepository"), exports);
@@ -0,0 +1,26 @@
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
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Header = Header;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const funnel_core_1 = require("@nascentdigital/funnel-core");
9
+ const components_1 = require("@nascentdigital/funnel-editor/components");
10
+ const classnames_1 = __importDefault(require("classnames"));
11
+ const react_router_1 = require("react-router");
12
+ const react_1 = require("motion/react");
13
+ // component
14
+ function Header({ className, title, breadcrumbs: breadcrumbsRaw, highlightBreadcrumb = false, back, onBack = funnel_core_1.Fn.NoOp, disableBack = false, hideControls, children }) {
15
+ // bind props + hooks
16
+ const breadcrumbs = breadcrumbsRaw !== null && breadcrumbsRaw !== void 0 ? breadcrumbsRaw : [];
17
+ const breadcrumbsEndIndex = breadcrumbs.length - 1;
18
+ // render
19
+ return ((0, jsx_runtime_1.jsxs)("nav", { className: (0, classnames_1.default)(className, 'h-48 flex items-center gap-l4 px-l8', 'label-sm text-content-primary bg-background border-b border-solid border-border-l1'), children: [back === 'none'
20
+ // logo
21
+ ?
22
+ (0, jsx_runtime_1.jsx)("span", { className: "w-36 h-36 flex justify-center items-center", children: (0, jsx_runtime_1.jsx)(components_1.Logo, { size: 28 }) })
23
+ // back/close
24
+ :
25
+ (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: back === 'back' ? 'ArrowLeft' : 'X', onClick: onBack, disabled: disableBack }), (0, jsx_runtime_1.jsx)("ul", { className: "flex-1 flex items-center gap-l5", children: (0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { children: breadcrumbs.map((breadcrumb, index) => (0, jsx_runtime_1.jsxs)(react_1.motion.li, { className: "flex items-center gap-l5", variants: components_1.Animate.Variants.fade, initial: "initial", animate: "animate", exit: "exit", layout: true, children: [index > 0 &&
26
+ (0, jsx_runtime_1.jsx)("span", { children: "/" }), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)({ 'label-sm label-strong': highlightBreadcrumb && index === breadcrumbsEndIndex }), children: typeof breadcrumb === 'string'
27
+ ?
28
+ (0, jsx_runtime_1.jsx)("span", { children: breadcrumb })
29
+ :
30
+ (0, jsx_runtime_1.jsx)(react_router_1.Link, { to: breadcrumb.url, children: breadcrumb.label }) })] }, index)) }) }), (0, jsx_runtime_1.jsx)("div", { className: "h-full flex items-center gap-l6", children: !hideControls && children })] }));
31
+ }
@@ -0,0 +1 @@
1
+ export * from './Header';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Header"), exports);
@@ -0,0 +1 @@
1
+ export * from './screens';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./screens"), exports);
@@ -0,0 +1 @@
1
+ export declare function Dashboard(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Dashboard = Dashboard;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const funnel_core_1 = require("@nascentdigital/funnel-core");
6
+ const components_1 = require("@nascentdigital/funnel-editor/components");
7
+ const react_1 = require("react");
8
+ const react_router_1 = require("react-router");
9
+ const components_2 = require("../components");
10
+ // screen
11
+ function Dashboard() {
12
+ // bind hooks
13
+ const brand = funnel_core_1.AppConfig.brandConfig();
14
+ const splash = (0, components_1.useSplash)();
15
+ const { collections } = funnel_core_1.Schema.Site.current();
16
+ // dismiss splash
17
+ (0, react_1.useEffect)(() => {
18
+ splash.dismiss();
19
+ }, [splash]);
20
+ // render
21
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(components_2.Header, { breadcrumbs: ['Dashboard'], back: "none" }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_router_1.Link, { to: "/contentful/pages", children: "Site Explorer" }) })] }));
22
+ }
@@ -0,0 +1 @@
1
+ export declare function PageExplorer(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PageExplorer = PageExplorer;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ // screen
6
+ function PageExplorer() {
7
+ // render
8
+ return ((0, jsx_runtime_1.jsx)("div", { children: "Page" }));
9
+ }
@@ -0,0 +1 @@
1
+ export declare function SiteExplorer(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
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
+ }
@@ -0,0 +1,3 @@
1
+ export * from './Dashboard';
2
+ export * from './PageExplorer';
3
+ export * from './SiteExplorer';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Dashboard"), exports);
18
+ __exportStar(require("./PageExplorer"), exports);
19
+ __exportStar(require("./SiteExplorer"), exports);
@@ -1,13 +1,19 @@
1
+ import { EntrySys } from '@contentful/app-sdk';
1
2
  import { Language } from '@nascentdigital/funnel-core';
2
3
  import { IPage, IPageController, PageSummary } from '@nascentdigital/funnel-editor/components';
3
- import { EditorApiClient, Page, PageRepository } from '../../core';
4
- export declare class PageController implements IPageController {
4
+ import { Page } from '../domain';
5
+ import { PageRepository } from '../repository';
6
+ export declare class ContentfulPageController implements IPageController {
7
+ readonly pageRepository: PageRepository;
5
8
  private readonly _eventBus;
6
9
  private _state;
7
10
  private _pageSummary?;
8
11
  private _page?;
9
- readonly repository: PageRepository;
10
- constructor({ editorApi }: PageController.ConstructorArgs);
12
+ private _pageSys?;
13
+ private _queuedSave?;
14
+ private _queuedSync?;
15
+ private _pageSubscription?;
16
+ constructor(args: ContentfulPageController.ConstructorArgs);
11
17
  get events$(): import("rxjs").Observable<IPage.Event | IPageController.Event>;
12
18
  get saved$(): import("rxjs").Observable<[IPageController.StateChangedEvent, IPageController.StateChangedEvent]>;
13
19
  get state(): IPageController.State;
@@ -18,14 +24,19 @@ export declare class PageController implements IPageController {
18
24
  private set pageSummary(value);
19
25
  get page(): Page | undefined;
20
26
  private set page(value);
27
+ get pageSys(): EntrySys | undefined;
28
+ private set pageSys(value);
29
+ sync(updatedSys: EntrySys): Promise<void>;
21
30
  load(): Promise<void>;
22
31
  create(target: IPageController.Target): Promise<void>;
32
+ save(page: Page): Promise<void>;
23
33
  reload(): Promise<void>;
24
34
  unpublish(): Promise<void>;
35
+ private processQueues;
25
36
  private raiseEvent;
26
37
  }
27
- export declare namespace PageController {
38
+ export declare namespace ContentfulPageController {
28
39
  type ConstructorArgs = {
29
- editorApi: EditorApiClient;
40
+ pageRepository: PageRepository;
30
41
  };
31
42
  }