@nascentdigital/funnel-cms 4.4.4
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.
- package/dist/api/AssetClient.d.ts +53 -0
- package/dist/api/AssetClient.js +2 -0
- package/dist/api/AssetUploadClient.d.ts +17 -0
- package/dist/api/AssetUploadClient.js +26 -0
- package/dist/api/AuthClient.d.ts +29 -0
- package/dist/api/AuthClient.js +2 -0
- package/dist/api/ChangeSetClient.d.ts +84 -0
- package/dist/api/ChangeSetClient.js +31 -0
- package/dist/api/CollectionClient.d.ts +187 -0
- package/dist/api/CollectionClient.js +2 -0
- package/dist/api/ContentClient.d.ts +43 -0
- package/dist/api/ContentClient.js +34 -0
- package/dist/api/IAssetApiClient.d.ts +9 -0
- package/dist/api/IAssetApiClient.js +2 -0
- package/dist/api/PageClient.d.ts +264 -0
- package/dist/api/PageClient.js +2 -0
- package/dist/api/SiteClient.d.ts +23 -0
- package/dist/api/SiteClient.js +2 -0
- package/dist/api/SiteConfigClient.d.ts +26 -0
- package/dist/api/SiteConfigClient.js +2 -0
- package/dist/api/UpgradeClient.d.ts +16 -0
- package/dist/api/UpgradeClient.js +2 -0
- package/dist/api/UserClient.d.ts +46 -0
- package/dist/api/UserClient.js +2 -0
- package/dist/api/index.d.ts +11 -0
- package/dist/api/index.js +27 -0
- package/dist/errors/CMSError.d.ts +8 -0
- package/dist/errors/CMSError.js +17 -0
- package/dist/errors/CMSErrors.d.ts +5 -0
- package/dist/errors/CMSErrors.js +36 -0
- package/dist/errors/LinkedDependantsError.d.ts +21 -0
- package/dist/errors/LinkedDependantsError.js +31 -0
- package/dist/errors/LockdownError.d.ts +4 -0
- package/dist/errors/LockdownError.js +12 -0
- package/dist/errors/SlugValidationError.d.ts +21 -0
- package/dist/errors/SlugValidationError.js +23 -0
- package/dist/errors/TranslateReferencesError.d.ts +21 -0
- package/dist/errors/TranslateReferencesError.js +22 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.js +25 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -0
- package/dist/models/Entity.d.ts +14 -0
- package/dist/models/Entity.js +2 -0
- package/dist/models/Environment.d.ts +1 -0
- package/dist/models/Environment.js +2 -0
- package/dist/models/Pagination.d.ts +20 -0
- package/dist/models/Pagination.js +21 -0
- package/dist/models/Privilege.d.ts +57 -0
- package/dist/models/Privilege.js +163 -0
- package/dist/models/Role.d.ts +33 -0
- package/dist/models/Role.js +118 -0
- package/dist/models/SiteConfig.d.ts +14 -0
- package/dist/models/SiteConfig.js +2 -0
- package/dist/models/Upgrade.d.ts +40 -0
- package/dist/models/Upgrade.js +19 -0
- package/dist/models/User.d.ts +41 -0
- package/dist/models/User.js +71 -0
- package/dist/models/Versioned.d.ts +22 -0
- package/dist/models/Versioned.js +45 -0
- package/dist/models/index.d.ts +9 -0
- package/dist/models/index.js +25 -0
- package/dist/strapi/IStrapiContentClient.d.ts +39 -0
- package/dist/strapi/IStrapiContentClient.js +2 -0
- package/dist/strapi/Strapi.d.ts +37 -0
- package/dist/strapi/Strapi.js +156 -0
- package/dist/strapi/StrapiAssetClient.d.ts +11 -0
- package/dist/strapi/StrapiAssetClient.js +143 -0
- package/dist/strapi/StrapiAssetUploadClient.d.ts +6 -0
- package/dist/strapi/StrapiAssetUploadClient.js +109 -0
- package/dist/strapi/StrapiAuthClient.d.ts +9 -0
- package/dist/strapi/StrapiAuthClient.js +64 -0
- package/dist/strapi/StrapiChangeSetClient.d.ts +22 -0
- package/dist/strapi/StrapiChangeSetClient.js +218 -0
- package/dist/strapi/StrapiCollectionClient.d.ts +18 -0
- package/dist/strapi/StrapiCollectionClient.js +610 -0
- package/dist/strapi/StrapiContentClient.d.ts +38 -0
- package/dist/strapi/StrapiContentClient.js +105 -0
- package/dist/strapi/StrapiContentClientFactory.d.ts +13 -0
- package/dist/strapi/StrapiContentClientFactory.js +19 -0
- package/dist/strapi/StrapiPageClient.d.ts +23 -0
- package/dist/strapi/StrapiPageClient.js +882 -0
- package/dist/strapi/StrapiSiteConfigClient.d.ts +8 -0
- package/dist/strapi/StrapiSiteConfigClient.js +50 -0
- package/dist/strapi/StrapiUpgradeClient.d.ts +13 -0
- package/dist/strapi/StrapiUpgradeClient.js +118 -0
- package/dist/strapi/StrapiUserClient.d.ts +17 -0
- package/dist/strapi/StrapiUserClient.js +199 -0
- package/dist/strapi/client.d.ts +1 -0
- package/dist/strapi/client.js +17 -0
- package/dist/strapi/index.d.ts +3 -0
- package/dist/strapi/index.js +19 -0
- package/dist/strapi/models/StrapiAsset.d.ts +10 -0
- package/dist/strapi/models/StrapiAsset.js +16 -0
- package/dist/strapi/models/StrapiData.d.ts +13 -0
- package/dist/strapi/models/StrapiData.js +16 -0
- package/dist/strapi/models/StrapiFile.d.ts +18 -0
- package/dist/strapi/models/StrapiFile.js +2 -0
- package/dist/strapi/models/index.d.ts +3 -0
- package/dist/strapi/models/index.js +19 -0
- package/dist/strapi/serialization/ChangeSetData.d.ts +15 -0
- package/dist/strapi/serialization/ChangeSetData.js +76 -0
- package/dist/strapi/serialization/CollectionData.d.ts +57 -0
- package/dist/strapi/serialization/CollectionData.js +258 -0
- package/dist/strapi/serialization/CollectionSnapshotData.d.ts +16 -0
- package/dist/strapi/serialization/CollectionSnapshotData.js +66 -0
- package/dist/strapi/serialization/PageData.d.ts +126 -0
- package/dist/strapi/serialization/PageData.js +335 -0
- package/dist/strapi/serialization/PageSnapshotData.d.ts +20 -0
- package/dist/strapi/serialization/PageSnapshotData.js +69 -0
- package/dist/strapi/serialization/RoleData.d.ts +5 -0
- package/dist/strapi/serialization/RoleData.js +2 -0
- package/dist/strapi/serialization/SiteConfigData.d.ts +11 -0
- package/dist/strapi/serialization/SiteConfigData.js +23 -0
- package/dist/strapi/serialization/StrapiAssetData.d.ts +17 -0
- package/dist/strapi/serialization/StrapiAssetData.js +39 -0
- package/dist/strapi/serialization/UserData.d.ts +18 -0
- package/dist/strapi/serialization/UserData.js +42 -0
- package/dist/strapi/serialization/VersionData.d.ts +26 -0
- package/dist/strapi/serialization/VersionData.js +88 -0
- package/dist/strapi/serialization/index.d.ts +10 -0
- package/dist/strapi/serialization/index.js +26 -0
- package/dist/strapi/test.d.ts +563 -0
- package/dist/strapi/test.js +1131 -0
- package/package.json +42 -0
|
@@ -0,0 +1,105 @@
|
|
|
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.StrapiContentClient = void 0;
|
|
7
|
+
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
8
|
+
const webhook_1 = require("@slack/webhook");
|
|
9
|
+
const client_1 = require("@strapi/client");
|
|
10
|
+
const qs_1 = __importDefault(require("qs"));
|
|
11
|
+
const StrapiAssetClient_1 = require("./StrapiAssetClient");
|
|
12
|
+
const StrapiAuthClient_1 = require("./StrapiAuthClient");
|
|
13
|
+
const StrapiChangeSetClient_1 = require("./StrapiChangeSetClient");
|
|
14
|
+
const StrapiCollectionClient_1 = require("./StrapiCollectionClient");
|
|
15
|
+
const StrapiPageClient_1 = require("./StrapiPageClient");
|
|
16
|
+
const StrapiSiteConfigClient_1 = require("./StrapiSiteConfigClient");
|
|
17
|
+
const StrapiUpgradeClient_1 = require("./StrapiUpgradeClient");
|
|
18
|
+
const StrapiUserClient_1 = require("./StrapiUserClient");
|
|
19
|
+
// class
|
|
20
|
+
class StrapiContentClient {
|
|
21
|
+
constructor({ baseUrl, token, slackUrl }) {
|
|
22
|
+
// initialize instance variables
|
|
23
|
+
const slack = slackUrl
|
|
24
|
+
? new webhook_1.IncomingWebhook(slackUrl)
|
|
25
|
+
: undefined;
|
|
26
|
+
this._baseUrl = baseUrl;
|
|
27
|
+
this._token = token;
|
|
28
|
+
this._client = (0, client_1.strapi)({
|
|
29
|
+
baseURL: baseUrl,
|
|
30
|
+
auth: token
|
|
31
|
+
});
|
|
32
|
+
this.auth = new StrapiAuthClient_1.StrapiAuthClient(this);
|
|
33
|
+
this.changeSets = new StrapiChangeSetClient_1.StrapiChangeSetClient(this);
|
|
34
|
+
this.files = new StrapiAssetClient_1.StrapiAssetClient(this);
|
|
35
|
+
this.pages = new StrapiPageClient_1.StrapiPageClient(this);
|
|
36
|
+
this.collections = new StrapiCollectionClient_1.StrapiCollectionClient(this);
|
|
37
|
+
this.upgrade = new StrapiUpgradeClient_1.StrapiUpgradeClient(this);
|
|
38
|
+
this.users = new StrapiUserClient_1.StrapiUserClient(this, slack);
|
|
39
|
+
this.siteConfig = new StrapiSiteConfigClient_1.StrapiSiteConfigClient(this);
|
|
40
|
+
}
|
|
41
|
+
get client() {
|
|
42
|
+
return this._client;
|
|
43
|
+
}
|
|
44
|
+
get token() {
|
|
45
|
+
// throw if token isn't set
|
|
46
|
+
const { _token } = this;
|
|
47
|
+
if (!_token) {
|
|
48
|
+
throw new funnel_core_1.InvalidOperationError('Cannot access token before authentication');
|
|
49
|
+
}
|
|
50
|
+
// return token
|
|
51
|
+
return _token;
|
|
52
|
+
}
|
|
53
|
+
set token(token) {
|
|
54
|
+
// change client if token changes
|
|
55
|
+
if (this._token !== token) {
|
|
56
|
+
// capture new token
|
|
57
|
+
this._token = token;
|
|
58
|
+
// create new client
|
|
59
|
+
this._client = (0, client_1.strapi)({
|
|
60
|
+
baseURL: this._baseUrl,
|
|
61
|
+
auth: token
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
clearToken() {
|
|
66
|
+
// change client if token changes
|
|
67
|
+
if (this._token) {
|
|
68
|
+
// clear token
|
|
69
|
+
delete this._token;
|
|
70
|
+
// create new client
|
|
71
|
+
this._client = (0, client_1.strapi)({
|
|
72
|
+
baseURL: this._baseUrl
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async customRequest({ command, method = 'GET', params = {}, data, onError }) {
|
|
77
|
+
// create full query
|
|
78
|
+
const { client, token } = this;
|
|
79
|
+
const url = new URL(`/api/funnel/${command}`, client.baseURL);
|
|
80
|
+
url.search = qs_1.default.stringify(params, { addQueryPrefix: true });
|
|
81
|
+
// send request
|
|
82
|
+
const response = await fetch(url.href, {
|
|
83
|
+
method,
|
|
84
|
+
headers: {
|
|
85
|
+
Authorization: `Bearer ${token}`,
|
|
86
|
+
'Content-Type': 'application/json'
|
|
87
|
+
},
|
|
88
|
+
body: data
|
|
89
|
+
});
|
|
90
|
+
// handle errors (never return)
|
|
91
|
+
if (!response.ok) {
|
|
92
|
+
// process error if expected
|
|
93
|
+
if (onError) {
|
|
94
|
+
onError(await response.json());
|
|
95
|
+
}
|
|
96
|
+
// or throw generic error
|
|
97
|
+
else {
|
|
98
|
+
throw new funnel_core_1.ServerError(`Failed to invoke "${command}" command:` + response.statusText);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// return response
|
|
102
|
+
return response.json();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.StrapiContentClient = StrapiContentClient;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RequiredBy } from '@nascentdigital/funnel-core';
|
|
2
|
+
import { ContentClient } from '../api';
|
|
3
|
+
import { StrapiContentClient } from './StrapiContentClient';
|
|
4
|
+
export declare class StrapiContentClientFactory implements ContentClient.Factory {
|
|
5
|
+
private readonly _baseUrl;
|
|
6
|
+
private readonly _serverClient;
|
|
7
|
+
constructor(args: StrapiContentClientFactory.ConstructorArgs);
|
|
8
|
+
forServer(): StrapiContentClient;
|
|
9
|
+
forEditor(): StrapiContentClient;
|
|
10
|
+
}
|
|
11
|
+
export declare namespace StrapiContentClientFactory {
|
|
12
|
+
type ConstructorArgs = RequiredBy<StrapiContentClient.ConstructorArgs, 'token'>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StrapiContentClientFactory = void 0;
|
|
4
|
+
const StrapiContentClient_1 = require("./StrapiContentClient");
|
|
5
|
+
// factory
|
|
6
|
+
class StrapiContentClientFactory {
|
|
7
|
+
constructor(args) {
|
|
8
|
+
// initialize instance variables
|
|
9
|
+
this._baseUrl = args.baseUrl;
|
|
10
|
+
this._serverClient = new StrapiContentClient_1.StrapiContentClient(args);
|
|
11
|
+
}
|
|
12
|
+
forServer() {
|
|
13
|
+
return this._serverClient;
|
|
14
|
+
}
|
|
15
|
+
forEditor() {
|
|
16
|
+
return new StrapiContentClient_1.StrapiContentClient({ baseUrl: this._baseUrl });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.StrapiContentClientFactory = StrapiContentClientFactory;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PageClient } from '../api';
|
|
2
|
+
import type { IStrapiContentClient } from './IStrapiContentClient';
|
|
3
|
+
export declare class StrapiPageClient implements PageClient {
|
|
4
|
+
private readonly provider;
|
|
5
|
+
constructor(provider: IStrapiContentClient);
|
|
6
|
+
getOverview({ brand, region, version }: PageClient.GetOverview.Args): Promise<PageClient.GetOverview.Result>;
|
|
7
|
+
getSummaries(args: PageClient.GetSummaries.Args): Promise<PageClient.GetSummaries.Result>;
|
|
8
|
+
getPreviews({ pagination, ...args }: PageClient.GetPreviews.Args): Promise<PageClient.GetPreviews.Result>;
|
|
9
|
+
search({ pagination, ...args }: PageClient.Search.Args): Promise<PageClient.Search.Result>;
|
|
10
|
+
query({ pagination, ...args }: PageClient.Query.Args): Promise<PageClient.Query.Result>;
|
|
11
|
+
find({ pagination, ...args }: PageClient.Find.Args): Promise<PageClient.Find.Result>;
|
|
12
|
+
getGroup({ brand, groupId, type, slug, region, language, version }: PageClient.GetGroup.Args): Promise<PageClient.GetGroup.Result>;
|
|
13
|
+
get(args: PageClient.Get.Args): Promise<PageClient.Get.Result>;
|
|
14
|
+
create(args: PageClient.Create.Args): Promise<PageClient.Create.Result>;
|
|
15
|
+
duplicate({ source: pageId, targetPage, targetLanguage, targetSlug }: PageClient.Duplicate.Args): Promise<PageClient.Duplicate.Result>;
|
|
16
|
+
touch({ id: pageId, version: status }: PageClient.Touch.Args): Promise<PageClient.Touch.Result>;
|
|
17
|
+
update({ id: pageId, slug: pageSlug, publication: pagePublication, errors, updates }: PageClient.Update.Args): Promise<PageClient.Update.Result>;
|
|
18
|
+
replace({ page, version, skipSync }: PageClient.Replace.Args): Promise<PageClient.Replace.Result>;
|
|
19
|
+
unpublish(pageId: PageClient.Unpublish.Args): Promise<PageClient.Unpublish.Result>;
|
|
20
|
+
getDependants({ id: pageId, version }: PageClient.GetDependants.Args): Promise<PageClient.GetDependants.Result>;
|
|
21
|
+
getDependencies({ id: pageId, version }: PageClient.GetDependencies.Args): Promise<PageClient.GetDependencies.Result>;
|
|
22
|
+
validateSlug({ brand, type, region, slug, groupId }: PageClient.ValidateSlug.Args): Promise<PageClient.ValidateSlug.Result>;
|
|
23
|
+
}
|