@remkoj/optimizely-cms-api 2.0.0-pre3 → 2.0.0-pre4
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/client/CmsIntegrationApiClient.d.ts +2 -0
- package/dist/client/CmsIntegrationApiClient.js +36 -34
- package/dist/client/core/ApiError.js +15 -15
- package/dist/client/core/ApiRequestOptions.js +2 -2
- package/dist/client/core/ApiResult.js +2 -2
- package/dist/client/core/BaseHttpRequest.js +9 -9
- package/dist/client/core/CancelablePromise.js +116 -116
- package/dist/client/core/FetchHttpRequest.js +20 -20
- package/dist/client/core/OpenAPI.js +14 -14
- package/dist/client/core/request.js +294 -294
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.js +48 -46
- package/dist/client/models/BinaryProperty.js +2 -2
- package/dist/client/models/BooleanProperty.js +2 -2
- package/dist/client/models/Changeset.js +2 -2
- package/dist/client/models/ChangesetItem.js +2 -2
- package/dist/client/models/ChangesetItemPage.js +2 -2
- package/dist/client/models/ChangesetPage.js +2 -2
- package/dist/client/models/ComponentListItem.js +2 -2
- package/dist/client/models/ComponentProperty.js +2 -2
- package/dist/client/models/ContentBaseType.js +19 -19
- package/dist/client/models/ContentComponent.js +2 -2
- package/dist/client/models/ContentItem.js +2 -2
- package/dist/client/models/ContentItemListWithContentTypes.js +2 -2
- package/dist/client/models/ContentItemPage.js +2 -2
- package/dist/client/models/ContentItemWithContentTypes.js +2 -2
- package/dist/client/models/ContentListItem.js +2 -2
- package/dist/client/models/ContentLocaleInfo.js +2 -2
- package/dist/client/models/ContentMetadata.js +2 -2
- package/dist/client/models/ContentMetadataPage.js +2 -2
- package/dist/client/models/ContentProperty.js +2 -2
- package/dist/client/models/ContentReference.js +2 -2
- package/dist/client/models/ContentReferenceListItem.js +2 -2
- package/dist/client/models/ContentReferenceProperty.js +2 -2
- package/dist/client/models/ContentType.js +2 -2
- package/dist/client/models/ContentTypeFeature.js +18 -18
- package/dist/client/models/ContentTypePage.js +2 -2
- package/dist/client/models/ContentTypeProperty.js +2 -2
- package/dist/client/models/ContentTypeUsage.js +15 -15
- package/dist/client/models/CopyContentOptions.js +2 -2
- package/dist/client/models/DateTimeListItem.js +2 -2
- package/dist/client/models/DateTimeProperty.js +2 -2
- package/dist/client/models/DisplaySetting.d.ts +22 -0
- package/dist/client/models/DisplaySetting.js +2 -0
- package/dist/client/models/DisplaySettingChoice.d.ts +13 -0
- package/dist/client/models/DisplaySettingChoice.js +2 -0
- package/dist/client/models/DisplayTemplate.d.ts +49 -0
- package/dist/client/models/DisplayTemplate.js +2 -0
- package/dist/client/models/DisplayTemplatePage.d.ts +19 -0
- package/dist/client/models/DisplayTemplatePage.js +2 -0
- package/dist/client/models/DoubleEnumerationSettings.js +2 -2
- package/dist/client/models/FloatListItem.js +2 -2
- package/dist/client/models/FloatProperty.js +2 -2
- package/dist/client/models/ImageDescriptor.js +2 -2
- package/dist/client/models/ImportPackageMessage.js +2 -2
- package/dist/client/models/ImportPackageResult.js +2 -2
- package/dist/client/models/IndexingType.js +16 -16
- package/dist/client/models/Int32EnumerationSettings.js +2 -2
- package/dist/client/models/IntegerListItem.js +2 -2
- package/dist/client/models/IntegerProperty.js +2 -2
- package/dist/client/models/JsonStringProperty.js +2 -2
- package/dist/client/models/ListProperty.js +2 -2
- package/dist/client/models/ListPropertyItem.js +2 -2
- package/dist/client/models/LocaleStatus.js +15 -15
- package/dist/client/models/Manifest.d.ts +5 -0
- package/dist/client/models/Manifest.js +2 -2
- package/dist/client/models/OauthToken.js +2 -2
- package/dist/client/models/OauthTokenError.js +2 -2
- package/dist/client/models/OauthTokenRequest.js +2 -2
- package/dist/client/models/PackageJob.js +2 -2
- package/dist/client/models/PackageJobMessage.js +2 -2
- package/dist/client/models/PackageJobStatus.js +2 -2
- package/dist/client/models/ProblemDetails.js +2 -2
- package/dist/client/models/PropertyDataType.js +26 -26
- package/dist/client/models/PropertyFormat.js +2 -2
- package/dist/client/models/PropertyFormatPage.js +2 -2
- package/dist/client/models/PropertyGroup.js +2 -2
- package/dist/client/models/PropertyGroupPage.js +2 -2
- package/dist/client/models/StringEnumerationSettings.js +2 -2
- package/dist/client/models/StringListItem.js +2 -2
- package/dist/client/models/StringProperty.js +2 -2
- package/dist/client/models/UrlListItem.js +2 -2
- package/dist/client/models/UrlProperty.js +2 -2
- package/dist/client/models/VersionStatus.js +20 -20
- package/dist/client/services/ChangesetsService.js +239 -239
- package/dist/client/services/ContentService.js +409 -409
- package/dist/client/services/ContentTypesService.js +149 -149
- package/dist/client/services/DisplayTemplatesService.d.ts +60 -0
- package/dist/client/services/DisplayTemplatesService.js +135 -0
- package/dist/client/services/OauthService.js +28 -28
- package/dist/client/services/PackagesService.js +80 -80
- package/dist/client/services/PropertyFormatsService.js +53 -53
- package/dist/client/services/PropertyGroupsService.js +135 -135
- package/dist/config.d.ts +1 -0
- package/dist/config.js +40 -39
- package/dist/index.js +95 -95
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
-
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
-
__setModuleDefault(result, mod);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.ContentTypeKeys = exports.ContentRoots = exports.createClient = exports.getAccessToken = exports.CmsIntegrationApiClient = exports.IntegrationApi = void 0;
|
|
30
|
-
__exportStar(require("./config"), exports);
|
|
31
|
-
exports.IntegrationApi = __importStar(require("./client"));
|
|
32
|
-
var client_1 = require("./client");
|
|
33
|
-
Object.defineProperty(exports, "CmsIntegrationApiClient", { enumerable: true, get: function () { return client_1.CmsIntegrationApiClient; } });
|
|
34
|
-
const config_1 = require("./config");
|
|
35
|
-
const client_2 = require("./client");
|
|
36
|
-
function isErrorResponse(response) {
|
|
37
|
-
return typeof (response.error) == 'string';
|
|
38
|
-
}
|
|
39
|
-
let _access_token = undefined;
|
|
40
|
-
async function getAccessToken(config) {
|
|
41
|
-
if (!_access_token) {
|
|
42
|
-
_access_token = (async (config) => {
|
|
43
|
-
const options = config ?? (0, config_1.getCmsIntegrationApiConfigFromEnvironment)();
|
|
44
|
-
const authUrl = `${options.base.href}/oauth/token`;
|
|
45
|
-
const headers = new Headers();
|
|
46
|
-
headers.append('Authorization', `Basic ${base64Encode(`${options.clientId}:${options.clientSecret}`)}`);
|
|
47
|
-
headers.append('Content-Type', 'application/x-www-form-urlencoded');
|
|
48
|
-
headers.append('Connection', 'close');
|
|
49
|
-
const body = new URLSearchParams();
|
|
50
|
-
body.append("grant_type", "client_credentials");
|
|
51
|
-
if (options.actAs)
|
|
52
|
-
body.append("act_as", options.actAs);
|
|
53
|
-
const response = await (await fetch(authUrl, {
|
|
54
|
-
method: "POST",
|
|
55
|
-
headers: headers,
|
|
56
|
-
body: body.toString()
|
|
57
|
-
})).json();
|
|
58
|
-
if (isErrorResponse(response))
|
|
59
|
-
throw new Error("Authentication error: " + response.error_description);
|
|
60
|
-
return response.access_token;
|
|
61
|
-
})(config);
|
|
62
|
-
}
|
|
63
|
-
return _access_token;
|
|
64
|
-
}
|
|
65
|
-
exports.getAccessToken = getAccessToken;
|
|
66
|
-
function createClient(config) {
|
|
67
|
-
const options = config ?? (0, config_1.getCmsIntegrationApiConfigFromEnvironment)();
|
|
68
|
-
const client = new client_2.CmsIntegrationApiClient({
|
|
69
|
-
BASE: options.base.href,
|
|
70
|
-
TOKEN: () => getAccessToken(options),
|
|
71
|
-
HEADERS: {
|
|
72
|
-
Connection: "Close"
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
return client;
|
|
76
|
-
}
|
|
77
|
-
exports.createClient = createClient;
|
|
78
|
-
var ContentRoots;
|
|
79
|
-
(function (ContentRoots) {
|
|
80
|
-
ContentRoots["SystemRoot"] = "43f936c99b234ea397b261c538ad07c9";
|
|
81
|
-
ContentRoots["MultiChannelContent"] = "41118A415C8C4BE08E73520FF3DE8244";
|
|
82
|
-
})(ContentRoots || (exports.ContentRoots = ContentRoots = {}));
|
|
83
|
-
var ContentTypeKeys;
|
|
84
|
-
(function (ContentTypeKeys) {
|
|
85
|
-
ContentTypeKeys["Folder"] = "SysContentFolder";
|
|
86
|
-
})(ContentTypeKeys || (exports.ContentTypeKeys = ContentTypeKeys = {}));
|
|
87
|
-
function base64Encode(input) {
|
|
88
|
-
if (btoa && typeof (btoa) == 'function')
|
|
89
|
-
return btoa(input);
|
|
90
|
-
if (Buffer && typeof (Buffer) == 'object')
|
|
91
|
-
//@ts-expect-error
|
|
92
|
-
return Buffer.from(input).toString('base64');
|
|
93
|
-
throw new Error("Unable to base64Encode");
|
|
94
|
-
}
|
|
95
|
-
exports.default = createClient;
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ContentTypeKeys = exports.ContentRoots = exports.createClient = exports.getAccessToken = exports.CmsIntegrationApiClient = exports.IntegrationApi = void 0;
|
|
30
|
+
__exportStar(require("./config"), exports);
|
|
31
|
+
exports.IntegrationApi = __importStar(require("./client"));
|
|
32
|
+
var client_1 = require("./client");
|
|
33
|
+
Object.defineProperty(exports, "CmsIntegrationApiClient", { enumerable: true, get: function () { return client_1.CmsIntegrationApiClient; } });
|
|
34
|
+
const config_1 = require("./config");
|
|
35
|
+
const client_2 = require("./client");
|
|
36
|
+
function isErrorResponse(response) {
|
|
37
|
+
return typeof (response.error) == 'string';
|
|
38
|
+
}
|
|
39
|
+
let _access_token = undefined;
|
|
40
|
+
async function getAccessToken(config) {
|
|
41
|
+
if (!_access_token) {
|
|
42
|
+
_access_token = (async (config) => {
|
|
43
|
+
const options = config ?? (0, config_1.getCmsIntegrationApiConfigFromEnvironment)();
|
|
44
|
+
const authUrl = `${options.base.href}/oauth/token`;
|
|
45
|
+
const headers = new Headers();
|
|
46
|
+
headers.append('Authorization', `Basic ${base64Encode(`${options.clientId}:${options.clientSecret}`)}`);
|
|
47
|
+
headers.append('Content-Type', 'application/x-www-form-urlencoded');
|
|
48
|
+
headers.append('Connection', 'close');
|
|
49
|
+
const body = new URLSearchParams();
|
|
50
|
+
body.append("grant_type", "client_credentials");
|
|
51
|
+
if (options.actAs)
|
|
52
|
+
body.append("act_as", options.actAs);
|
|
53
|
+
const response = await (await fetch(authUrl, {
|
|
54
|
+
method: "POST",
|
|
55
|
+
headers: headers,
|
|
56
|
+
body: body.toString()
|
|
57
|
+
})).json();
|
|
58
|
+
if (isErrorResponse(response))
|
|
59
|
+
throw new Error("Authentication error: " + response.error_description);
|
|
60
|
+
return response.access_token;
|
|
61
|
+
})(config);
|
|
62
|
+
}
|
|
63
|
+
return _access_token;
|
|
64
|
+
}
|
|
65
|
+
exports.getAccessToken = getAccessToken;
|
|
66
|
+
function createClient(config) {
|
|
67
|
+
const options = config ?? (0, config_1.getCmsIntegrationApiConfigFromEnvironment)();
|
|
68
|
+
const client = new client_2.CmsIntegrationApiClient({
|
|
69
|
+
BASE: options.base.href,
|
|
70
|
+
TOKEN: () => getAccessToken(options),
|
|
71
|
+
HEADERS: {
|
|
72
|
+
Connection: "Close"
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return client;
|
|
76
|
+
}
|
|
77
|
+
exports.createClient = createClient;
|
|
78
|
+
var ContentRoots;
|
|
79
|
+
(function (ContentRoots) {
|
|
80
|
+
ContentRoots["SystemRoot"] = "43f936c99b234ea397b261c538ad07c9";
|
|
81
|
+
ContentRoots["MultiChannelContent"] = "41118A415C8C4BE08E73520FF3DE8244";
|
|
82
|
+
})(ContentRoots || (exports.ContentRoots = ContentRoots = {}));
|
|
83
|
+
var ContentTypeKeys;
|
|
84
|
+
(function (ContentTypeKeys) {
|
|
85
|
+
ContentTypeKeys["Folder"] = "SysContentFolder";
|
|
86
|
+
})(ContentTypeKeys || (exports.ContentTypeKeys = ContentTypeKeys = {}));
|
|
87
|
+
function base64Encode(input) {
|
|
88
|
+
if (btoa && typeof (btoa) == 'function')
|
|
89
|
+
return btoa(input);
|
|
90
|
+
if (Buffer && typeof (Buffer) == 'object')
|
|
91
|
+
//@ts-expect-error
|
|
92
|
+
return Buffer.from(input).toString('base64');
|
|
93
|
+
throw new Error("Unable to base64Encode");
|
|
94
|
+
}
|
|
95
|
+
exports.default = createClient;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@remkoj/optimizely-cms-api",
|
|
3
3
|
"displayName": "Optimizely CMS - Integration API Client",
|
|
4
4
|
"description": "A Javascript client for the Integration API provided by the Optimizely CMS.",
|
|
5
|
-
"version": "2.0.0-
|
|
5
|
+
"version": "2.0.0-pre4",
|
|
6
6
|
"packageManager": "yarn@4.1.1",
|
|
7
7
|
"type": "commonjs",
|
|
8
8
|
"license": "Apache-2.0",
|