@nascentdigital/funnel-cms 5.0.1 → 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 (49) hide show
  1. package/dist/contentful/ContentfulAccess.d.ts +19 -0
  2. package/dist/contentful/ContentfulAccess.js +67 -0
  3. package/dist/contentful/ContentfulApiCommand.d.ts +21 -0
  4. package/dist/contentful/ContentfulApiCommand.js +20 -0
  5. package/dist/contentful/ContentfulApiResponse.d.ts +10 -0
  6. package/dist/contentful/ContentfulApiResponse.js +2 -0
  7. package/dist/contentful/ContentfulAssetClient.d.ts +11 -0
  8. package/dist/contentful/ContentfulAssetClient.js +26 -0
  9. package/dist/contentful/ContentfulAuthClient.d.ts +9 -0
  10. package/dist/contentful/ContentfulAuthClient.js +20 -0
  11. package/dist/contentful/ContentfulChangeSetClient.d.ts +14 -0
  12. package/dist/contentful/ContentfulChangeSetClient.js +35 -0
  13. package/dist/contentful/ContentfulCollectionClient.d.ts +38 -0
  14. package/dist/contentful/ContentfulCollectionClient.js +173 -0
  15. package/dist/contentful/ContentfulContentClient.d.ts +59 -0
  16. package/dist/contentful/ContentfulContentClient.js +208 -0
  17. package/dist/contentful/ContentfulContentClientFactory.d.ts +12 -0
  18. package/dist/contentful/ContentfulContentClientFactory.js +19 -0
  19. package/dist/contentful/ContentfulPageClient.d.ts +43 -0
  20. package/dist/contentful/ContentfulPageClient.js +251 -0
  21. package/dist/contentful/ContentfulSiteConfigClient.d.ts +9 -0
  22. package/dist/contentful/ContentfulSiteConfigClient.js +33 -0
  23. package/dist/contentful/ContentfulUpgradeClient.d.ts +9 -0
  24. package/dist/contentful/ContentfulUpgradeClient.js +17 -0
  25. package/dist/contentful/ContentfulUserClient.d.ts +13 -0
  26. package/dist/contentful/ContentfulUserClient.js +32 -0
  27. package/dist/contentful/IContentfulContentClient.d.ts +52 -0
  28. package/dist/contentful/IContentfulContentClient.js +2 -0
  29. package/dist/contentful/api/ContentfulApi.d.ts +10 -0
  30. package/dist/contentful/api/ContentfulApi.js +82 -0
  31. package/dist/contentful/index.d.ts +12 -0
  32. package/dist/contentful/index.js +28 -0
  33. package/dist/contentful/models/ContentfulAssetData.d.ts +8 -0
  34. package/dist/contentful/models/ContentfulAssetData.js +29 -0
  35. package/dist/contentful/models/ContentfulCollectionData.d.ts +11 -0
  36. package/dist/contentful/models/ContentfulCollectionData.js +98 -0
  37. package/dist/contentful/models/ContentfulData.d.ts +40 -0
  38. package/dist/contentful/models/ContentfulData.js +118 -0
  39. package/dist/contentful/models/ContentfulPageData.d.ts +17 -0
  40. package/dist/contentful/models/ContentfulPageData.js +117 -0
  41. package/dist/contentful/models/ContentfulSiteConfigData.d.ts +10 -0
  42. package/dist/contentful/models/ContentfulSiteConfigData.js +9 -0
  43. package/dist/contentful/models/ContentfulUserData.d.ts +6 -0
  44. package/dist/contentful/models/ContentfulUserData.js +26 -0
  45. package/dist/contentful/models/index.d.ts +6 -0
  46. package/dist/contentful/models/index.js +22 -0
  47. package/dist/contentful/server.d.ts +1 -0
  48. package/dist/contentful/server.js +17 -0
  49. package/package.json +9 -3
@@ -0,0 +1,19 @@
1
+ import { User } from '../models';
2
+ export declare class ContentfulAccess {
3
+ readonly userId: User.Id;
4
+ readonly token: string;
5
+ readonly expiry: number;
6
+ constructor(args: ContentfulAccess.ConstructorArgs);
7
+ get isExpired(): boolean;
8
+ get data(): ContentfulAccess.Data;
9
+ static new(userId: string): ContentfulAccess;
10
+ }
11
+ export declare namespace ContentfulAccess {
12
+ type Data = {
13
+ userId: string;
14
+ token: string;
15
+ expiry: number;
16
+ };
17
+ type ConstructorArgs = Data;
18
+ const tokenLifetimeMs: number;
19
+ }
@@ -0,0 +1,67 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ContentfulAccess = void 0;
37
+ const funnel_core_1 = require("@nascentdigital/funnel-core");
38
+ const uuid = __importStar(require("uuid"));
39
+ // class
40
+ class ContentfulAccess {
41
+ constructor(args) {
42
+ // initialize instance variables
43
+ this.userId = args.userId;
44
+ this.token = args.token;
45
+ this.expiry = args.expiry || 0;
46
+ }
47
+ get isExpired() {
48
+ return Date.now() > this.expiry;
49
+ }
50
+ get data() {
51
+ const { userId, token, expiry } = this;
52
+ return { userId, token, expiry };
53
+ }
54
+ static new(userId) {
55
+ return new ContentfulAccess({
56
+ userId,
57
+ token: uuid.v4(),
58
+ expiry: Date.now() + ContentfulAccess.tokenLifetimeMs
59
+ });
60
+ }
61
+ }
62
+ exports.ContentfulAccess = ContentfulAccess;
63
+ // extension
64
+ (function (ContentfulAccess) {
65
+ // constants
66
+ ContentfulAccess.tokenLifetimeMs = funnel_core_1.Duration.toMilliseconds('30s');
67
+ })(ContentfulAccess || (exports.ContentfulAccess = ContentfulAccess = {}));
@@ -0,0 +1,21 @@
1
+ export type ContentfulApiCommand = ContentfulApiCommand.GetAccessTokens;
2
+ export declare namespace ContentfulApiCommand {
3
+ type Type = 'GetAccessTokens';
4
+ namespace Type {
5
+ const values: ReadonlyArray<Type>;
6
+ }
7
+ type Spec<TCommand extends Type = Type> = {
8
+ type: TCommand;
9
+ userId: string;
10
+ token: string;
11
+ };
12
+ type GetAccessTokens = Spec<'GetAccessTokens'>;
13
+ namespace GetAccessTokens {
14
+ type Result = {
15
+ deliveryAccessToken: string;
16
+ previewAccessToken: string;
17
+ };
18
+ }
19
+ type Result = GetAccessTokens.Result;
20
+ function filter(json: any): json is ContentfulApiCommand;
21
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContentfulApiCommand = void 0;
4
+ var ContentfulApiCommand;
5
+ (function (ContentfulApiCommand) {
6
+ let Type;
7
+ (function (Type) {
8
+ Type.values = [
9
+ 'GetAccessTokens'
10
+ ];
11
+ })(Type = ContentfulApiCommand.Type || (ContentfulApiCommand.Type = {}));
12
+ // helpers
13
+ function filter(json) {
14
+ return !!json && typeof json === 'object' && !Array.isArray(json)
15
+ && 'type' in json && typeof json.type === 'string' && Type.values.includes(json.type)
16
+ && 'userId' in json && typeof json.userId === 'string'
17
+ && 'token' in json && typeof json.token === 'string';
18
+ }
19
+ ContentfulApiCommand.filter = filter;
20
+ })(ContentfulApiCommand || (exports.ContentfulApiCommand = ContentfulApiCommand = {}));
@@ -0,0 +1,10 @@
1
+ import { SerializedIsometricError } from '@nascentdigital/funnel-core';
2
+ export type ContentfulApiResponse<T> = ContentfulApiResponse.Data<T> | ContentfulApiResponse.Error;
3
+ export declare namespace ContentfulApiResponse {
4
+ type Data<T> = {
5
+ data: T;
6
+ };
7
+ type Error = {
8
+ error: SerializedIsometricError;
9
+ };
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ import { AssetClient } from '../api';
2
+ import { IContentfulContentClient } from './IContentfulContentClient';
3
+ export declare class ContentfulAssetClient implements AssetClient {
4
+ readonly cms: IContentfulContentClient;
5
+ constructor(cms: IContentfulContentClient);
6
+ getAssets(args: AssetClient.GetAssets.Args): Promise<AssetClient.GetAssets.Result>;
7
+ getAsset(args: AssetClient.GetAsset.Args): Promise<AssetClient.GetAsset.Result>;
8
+ createAsset(args: AssetClient.CreateAsset.Args): Promise<AssetClient.CreateAsset.Result>;
9
+ updateAsset(args: AssetClient.UpdateAsset.Args): Promise<AssetClient.UpdateAsset.Result>;
10
+ deleteAsset(args: AssetClient.DeleteAsset.Args): Promise<AssetClient.DeleteAsset.Result>;
11
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContentfulAssetClient = void 0;
4
+ const funnel_core_1 = require("@nascentdigital/funnel-core");
5
+ // class
6
+ class ContentfulAssetClient {
7
+ constructor(cms) {
8
+ this.cms = cms;
9
+ }
10
+ getAssets(args) {
11
+ throw new funnel_core_1.NotImplementedError();
12
+ }
13
+ getAsset(args) {
14
+ throw new funnel_core_1.NotImplementedError();
15
+ }
16
+ createAsset(args) {
17
+ throw new funnel_core_1.NotImplementedError();
18
+ }
19
+ updateAsset(args) {
20
+ throw new funnel_core_1.NotImplementedError();
21
+ }
22
+ deleteAsset(args) {
23
+ throw new funnel_core_1.NotImplementedError();
24
+ }
25
+ }
26
+ exports.ContentfulAssetClient = ContentfulAssetClient;
@@ -0,0 +1,9 @@
1
+ import { AuthClient } from '../api';
2
+ import { IContentfulContentClient } from './IContentfulContentClient';
3
+ export declare class ContentfulAuthClient implements AuthClient {
4
+ readonly cms: IContentfulContentClient;
5
+ constructor(cms: IContentfulContentClient);
6
+ identify(args: AuthClient.Identify.Args): Promise<AuthClient.Identify.Result>;
7
+ login(args: AuthClient.Login.Args): Promise<AuthClient.Login.Result>;
8
+ authorize(args: AuthClient.Authorize.Args): Promise<AuthClient.Authorize.Result>;
9
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContentfulAuthClient = void 0;
4
+ const funnel_core_1 = require("@nascentdigital/funnel-core");
5
+ // class
6
+ class ContentfulAuthClient {
7
+ constructor(cms) {
8
+ this.cms = cms;
9
+ }
10
+ identify(args) {
11
+ throw new funnel_core_1.NotImplementedError();
12
+ }
13
+ login(args) {
14
+ throw new funnel_core_1.NotImplementedError();
15
+ }
16
+ authorize(args) {
17
+ throw new funnel_core_1.NotImplementedError();
18
+ }
19
+ }
20
+ exports.ContentfulAuthClient = ContentfulAuthClient;
@@ -0,0 +1,14 @@
1
+ import { ChangeSetClient } from '../api';
2
+ import { IContentfulContentClient } from './IContentfulContentClient';
3
+ export declare class ContentfulChangeSetClient implements ChangeSetClient {
4
+ readonly cms: IContentfulContentClient;
5
+ constructor(cms: IContentfulContentClient);
6
+ current(args: ChangeSetClient.Current.Args): Promise<ChangeSetClient.Current.Result>;
7
+ listGroups(args: ChangeSetClient.ListGroups.Args): Promise<ChangeSetClient.ListGroups.Result>;
8
+ list(args: ChangeSetClient.List.Args): Promise<ChangeSetClient.List.Result>;
9
+ get(args: ChangeSetClient.Get.Args): Promise<ChangeSetClient.Get.Result>;
10
+ update(args: ChangeSetClient.Update.Args): Promise<ChangeSetClient.Update.Result>;
11
+ delete(args: ChangeSetClient.Delete.Args): Promise<ChangeSetClient.Delete.Result>;
12
+ commit(args: ChangeSetClient.Commit.Args): Promise<ChangeSetClient.Commit.Result>;
13
+ revert(args: ChangeSetClient.Revert.Args): Promise<ChangeSetClient.Revert.Result>;
14
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContentfulChangeSetClient = void 0;
4
+ const funnel_core_1 = require("@nascentdigital/funnel-core");
5
+ // class
6
+ class ContentfulChangeSetClient {
7
+ constructor(cms) {
8
+ this.cms = cms;
9
+ }
10
+ current(args) {
11
+ throw new funnel_core_1.NotImplementedError();
12
+ }
13
+ listGroups(args) {
14
+ throw new funnel_core_1.NotImplementedError();
15
+ }
16
+ list(args) {
17
+ throw new funnel_core_1.NotImplementedError();
18
+ }
19
+ get(args) {
20
+ throw new funnel_core_1.NotImplementedError();
21
+ }
22
+ update(args) {
23
+ throw new funnel_core_1.NotImplementedError();
24
+ }
25
+ delete(args) {
26
+ throw new funnel_core_1.NotImplementedError();
27
+ }
28
+ commit(args) {
29
+ throw new funnel_core_1.NotImplementedError();
30
+ }
31
+ revert(args) {
32
+ throw new funnel_core_1.NotImplementedError();
33
+ }
34
+ }
35
+ exports.ContentfulChangeSetClient = ContentfulChangeSetClient;
@@ -0,0 +1,38 @@
1
+ import { Schema } from '@nascentdigital/funnel-core';
2
+ import { CollectionClient } from '../api';
3
+ import { IContentfulContentClient } from './IContentfulContentClient';
4
+ import { ContentfulCollectionData } from './models';
5
+ export declare class ContentfulCollectionClient implements CollectionClient {
6
+ readonly cms: IContentfulContentClient;
7
+ constructor(cms: IContentfulContentClient);
8
+ getOverview(args: CollectionClient.GetOverview.Args): Promise<CollectionClient.GetOverview.Result>;
9
+ getItems(args: CollectionClient.GetItems.Args): Promise<CollectionClient.GetItems.Result>;
10
+ find(args: CollectionClient.Find.Args): Promise<CollectionClient.Find.Result>;
11
+ getGroup(args: CollectionClient.GetGroup.Args): Promise<ContentfulCollectionClient.GetGroup.Result>;
12
+ get(args: CollectionClient.Get.Args): Promise<ContentfulCollectionClient.Get.Result>;
13
+ create(args: CollectionClient.Create.Args): Promise<CollectionClient.Create.Result>;
14
+ duplicate(args: CollectionClient.Duplicate.Args): Promise<CollectionClient.Duplicate.Result>;
15
+ update(args: CollectionClient.Update.Args): Promise<ContentfulCollectionClient.Update.Result>;
16
+ replace(args: CollectionClient.Replace.Args): Promise<CollectionClient.Replace.Result>;
17
+ unpublish(args: CollectionClient.Unpublish.Args): Promise<CollectionClient.Unpublish.Result>;
18
+ getDependants(args: CollectionClient.GetDependants.Args): Promise<CollectionClient.GetDependants.Result>;
19
+ getDependencies(args: CollectionClient.GetDependencies.Args): Promise<CollectionClient.GetDependencies.Result>;
20
+ }
21
+ export declare namespace ContentfulCollectionClient {
22
+ type FlattenedCollectionData = Omit<Schema.Collection.FlattenedData, 'data'> & {
23
+ data: ContentfulCollectionData.ForSchema;
24
+ };
25
+ namespace GetGroup {
26
+ type Result = (Omit<Schema.Collection.Data.AsGroup, 'collection'> & {
27
+ collection?: FlattenedCollectionData;
28
+ }) | undefined;
29
+ }
30
+ namespace Get {
31
+ type Result = FlattenedCollectionData | undefined;
32
+ }
33
+ namespace Update {
34
+ type Result = Omit<CollectionClient.Update.Result, 'collection'> & {
35
+ collection?: FlattenedCollectionData;
36
+ };
37
+ }
38
+ }
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContentfulCollectionClient = void 0;
4
+ const funnel_core_1 = require("@nascentdigital/funnel-core");
5
+ const models_1 = require("./models");
6
+ // class
7
+ class ContentfulCollectionClient {
8
+ constructor(cms) {
9
+ this.cms = cms;
10
+ }
11
+ async getOverview(args) {
12
+ throw new funnel_core_1.NotImplementedError();
13
+ }
14
+ async getItems(args) {
15
+ throw new funnel_core_1.NotImplementedError();
16
+ }
17
+ async find(args) {
18
+ throw new funnel_core_1.NotImplementedError();
19
+ }
20
+ async getGroup(args) {
21
+ var _a, _b;
22
+ // fetch items (bail if there are no instances
23
+ const { cms } = this;
24
+ const { entries } = await cms.getEntries(Object.assign({ content_type: models_1.ContentfulCollectionData.contentType, version: args.version, select: getCollectionSelect(funnel_core_1.Schema.Collection.Data.AsGroup.Instance.props) }, getCollectionQueryParams(args)));
25
+ // bail if no items
26
+ if (entries.length === 0) {
27
+ return undefined;
28
+ }
29
+ // create group
30
+ const { type, brand, language, groupId, version } = args;
31
+ const schema = funnel_core_1.Schema.Site.getCollection(type);
32
+ const instances = entries.map(entry => models_1.ContentfulCollectionData.deserialize(entry, funnel_core_1.Schema.Collection.Data.AsGroup.Instance.props));
33
+ const result = {
34
+ group: {
35
+ type,
36
+ brand,
37
+ groupId,
38
+ name: (_b = (_a = funnel_core_1.ArrayUtils.first(entries)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : schema.name,
39
+ instances
40
+ }
41
+ };
42
+ // add language if it exists as an instance
43
+ const target = instances.find(item => item.language === language);
44
+ if (target) {
45
+ // get collection
46
+ result.collection = await this.get({ version, id: target.id });
47
+ // sync name if collection was found
48
+ if (result.collection) {
49
+ result.group.name = result.collection.data.name;
50
+ }
51
+ }
52
+ // return result
53
+ return result;
54
+ }
55
+ async get(args) {
56
+ // fetch entry
57
+ const { cms } = this;
58
+ const { entry, references } = await cms.getEntry({
59
+ entryId: args.id,
60
+ version: args.version
61
+ });
62
+ return Object.assign({ data: models_1.ContentfulCollectionData.deserialize(entry) }, models_1.ContentfulCollectionData.deserializeRefs(references));
63
+ }
64
+ async create(args) {
65
+ throw new funnel_core_1.NotImplementedError();
66
+ }
67
+ async duplicate(args) {
68
+ throw new funnel_core_1.NotImplementedError();
69
+ }
70
+ async update(args) {
71
+ throw new funnel_core_1.NotImplementedError();
72
+ }
73
+ async replace(args) {
74
+ throw new funnel_core_1.NotImplementedError();
75
+ }
76
+ async unpublish(args) {
77
+ throw new funnel_core_1.NotImplementedError();
78
+ }
79
+ async getDependants(args) {
80
+ throw new funnel_core_1.NotImplementedError();
81
+ }
82
+ async getDependencies(args) {
83
+ throw new funnel_core_1.NotImplementedError();
84
+ }
85
+ }
86
+ exports.ContentfulCollectionClient = ContentfulCollectionClient;
87
+ // helpers
88
+ function getCollectionQueryParams(query) {
89
+ // build filters
90
+ const { ids = [], groupId, brand, type, slug, language, name, tags = [], tagsMatch = 'any', version } = query;
91
+ const filters = {};
92
+ // filter id(s)
93
+ if (ids.length === 1) {
94
+ filters['sys.id'] = ids[0];
95
+ }
96
+ else if (ids.length > 1) {
97
+ filters['sys.id[in]'] = ids.join(',');
98
+ }
99
+ // filter group
100
+ if (groupId) {
101
+ filters['fields.groupId'] = groupId;
102
+ }
103
+ // filter brand
104
+ if (brand) {
105
+ filters['fields.brand'] = brand;
106
+ }
107
+ // filter type(s)
108
+ const normalizedType = type
109
+ ? Array.isArray(type)
110
+ ? type
111
+ : [type]
112
+ : [];
113
+ if (normalizedType.length === 1) {
114
+ filters['fields.type'] = normalizedType[0];
115
+ }
116
+ else if (normalizedType.length > 1) {
117
+ filters['fields.type[in]'] = normalizedType.join(',');
118
+ }
119
+ // filter slug
120
+ if (slug) {
121
+ filters['fields.slug'] = slug;
122
+ }
123
+ // filter language
124
+ if (language) {
125
+ filters['fields.language'] = language;
126
+ }
127
+ // filter name
128
+ if (name) {
129
+ filters['fields.name[match]'] = name;
130
+ }
131
+ // filter tags
132
+ if (tags.length > 0) {
133
+ filters[`fields.tags[${tagsMatch === 'any' ? 'in' : 'all'}]`] = tags
134
+ .filter((tag) => !!tag)
135
+ .join(',');
136
+ }
137
+ // return filters
138
+ return filters;
139
+ }
140
+ function getCollectionSelect(props) {
141
+ // build select
142
+ const select = new Set(['sys']);
143
+ for (const prop of props) {
144
+ switch (prop) {
145
+ // parity
146
+ case 'groupId':
147
+ case 'brand':
148
+ case 'type':
149
+ case 'language':
150
+ case 'name':
151
+ case 'tags':
152
+ case 'state':
153
+ case 'errors':
154
+ case 'publishedOn':
155
+ select.add(`fields.${prop}`);
156
+ break;
157
+ // links
158
+ case 'files':
159
+ case 'collections':
160
+ select.add('fields.references');
161
+ break;
162
+ // ignore the rest
163
+ default:
164
+ break;
165
+ }
166
+ }
167
+ // bail if nothing added
168
+ if (select.size === 0) {
169
+ return undefined;
170
+ }
171
+ // return as joint string
172
+ return Array.from(select).join(',');
173
+ }
@@ -0,0 +1,59 @@
1
+ import { CMAClient, KnownAppSDK } from '@contentful/app-sdk';
2
+ import { PlainClientAPI } from 'contentful-management';
3
+ import { AuthClient, ContentClient } from '../api';
4
+ import { User } from '../models';
5
+ import { ContentfulAssetClient } from './ContentfulAssetClient';
6
+ import { ContentfulAuthClient } from './ContentfulAuthClient';
7
+ import { ContentfulChangeSetClient } from './ContentfulChangeSetClient';
8
+ import { ContentfulCollectionClient } from './ContentfulCollectionClient';
9
+ import { ContentfulPageClient } from './ContentfulPageClient';
10
+ import { ContentfulSiteConfigClient } from './ContentfulSiteConfigClient';
11
+ import { ContentfulUpgradeClient } from './ContentfulUpgradeClient';
12
+ import { ContentfulUserClient } from './ContentfulUserClient';
13
+ import { IContentfulContentClient } from './IContentfulContentClient';
14
+ import { ContentfulData } from './models';
15
+ export declare class ContentfulContentClient implements ContentClient, IContentfulContentClient {
16
+ readonly user: User;
17
+ readonly locale: string;
18
+ readonly deliveryAccessToken: string;
19
+ readonly previewAccessToken: string;
20
+ readonly cma: CMAClient;
21
+ readonly cda: PlainClientAPI;
22
+ readonly cpa: PlainClientAPI;
23
+ readonly auth: ContentfulAuthClient;
24
+ readonly changeSets: ContentfulChangeSetClient;
25
+ readonly files: ContentfulAssetClient;
26
+ readonly pages: ContentfulPageClient;
27
+ readonly collections: ContentfulCollectionClient;
28
+ readonly upgrade: ContentfulUpgradeClient;
29
+ readonly users: ContentfulUserClient;
30
+ readonly siteConfig: ContentfulSiteConfigClient;
31
+ constructor(args: ContentfulContentClient.ConstructorArgs);
32
+ get token(): AuthClient.AccessToken;
33
+ set token(token: AuthClient.AccessToken);
34
+ clearToken(): void;
35
+ createEntry<T extends ContentfulData>(contentTypeId: string, entry: ContentfulData.Draft<T>): Promise<T>;
36
+ getEntry<TEntry extends ContentfulData>({ entryId, includeLinks, version }: IContentfulContentClient.GetEntry.Args<TEntry>): Promise<IContentfulContentClient.GetEntry.Result<TEntry>>;
37
+ getEntries<TEntry extends ContentfulData>({ limit, version, includeLinks, ...query }: IContentfulContentClient.GetEntries.Args<TEntry>): Promise<IContentfulContentClient.GetEntries.Result<TEntry>>;
38
+ static forEditor(sdk: KnownAppSDK): Promise<ContentfulContentClient>;
39
+ }
40
+ export declare namespace ContentfulContentClient {
41
+ type ConstructorArgs = ConstructorArgs.ForServer | ConstructorArgs.ForEditor;
42
+ namespace ConstructorArgs {
43
+ type ForServer = {
44
+ locale: string;
45
+ accessToken: string;
46
+ spaceId: string;
47
+ environment: string;
48
+ deliveryAccessToken: string;
49
+ previewAccessToken: string;
50
+ };
51
+ type ForEditor = {
52
+ sdk: KnownAppSDK;
53
+ deliveryAccessToken: string;
54
+ previewAccessToken: string;
55
+ };
56
+ function isForServer(args: ConstructorArgs): args is ForServer;
57
+ function isForEditor(args: ConstructorArgs): args is ForEditor;
58
+ }
59
+ }