@remkoj/optimizely-cms-api 2.0.0-pre3 → 2.0.0-pre5
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-client.d.ts +35 -0
- package/dist/api-client.js +67 -0
- package/dist/client/CmsIntegrationApiClient.d.ts +24 -22
- package/dist/client/CmsIntegrationApiClient.js +2 -0
- package/dist/client/core/ApiError.d.ts +10 -10
- package/dist/client/core/ApiRequestOptions.d.ts +13 -13
- package/dist/client/core/ApiResult.d.ts +7 -7
- package/dist/client/core/BaseHttpRequest.d.ts +8 -8
- package/dist/client/core/CancelablePromise.d.ts +20 -20
- package/dist/client/core/FetchHttpRequest.d.ts +14 -14
- package/dist/client/core/OpenAPI.d.ts +16 -16
- package/dist/client/core/request.d.ts +30 -30
- package/dist/client/index.d.ts +81 -76
- package/dist/client/index.js +3 -1
- package/dist/client/models/BinaryProperty.d.ts +8 -8
- package/dist/client/models/BooleanProperty.d.ts +5 -5
- package/dist/client/models/Changeset.d.ts +26 -26
- package/dist/client/models/ChangesetItem.d.ts +11 -11
- package/dist/client/models/ChangesetItemPage.d.ts +19 -19
- package/dist/client/models/ChangesetPage.d.ts +19 -19
- package/dist/client/models/ComponentListItem.d.ts +7 -10
- package/dist/client/models/ComponentProperty.d.ts +7 -10
- package/dist/client/models/ContentBaseType.d.ts +11 -11
- package/dist/client/models/ContentComponent.d.ts +34 -34
- package/dist/client/models/ContentItem.d.ts +60 -60
- package/dist/client/models/ContentItemListWithContentTypes.d.ts +27 -27
- package/dist/client/models/ContentItemPage.d.ts +19 -19
- package/dist/client/models/ContentItemWithContentTypes.d.ts +12 -12
- package/dist/client/models/ContentListItem.d.ts +8 -14
- package/dist/client/models/ContentLocaleInfo.d.ts +19 -11
- package/dist/client/models/ContentMetadata.d.ts +38 -46
- package/dist/client/models/ContentMetadataPage.d.ts +19 -19
- package/dist/client/models/ContentProperty.d.ts +8 -14
- package/dist/client/models/ContentReference.d.ts +17 -17
- package/dist/client/models/ContentReferenceListItem.d.ts +8 -14
- package/dist/client/models/ContentReferenceProperty.d.ts +8 -14
- package/dist/client/models/ContentType.d.ts +79 -79
- package/dist/client/models/ContentTypeFeature.d.ts +10 -10
- package/dist/client/models/ContentTypePage.d.ts +19 -19
- package/dist/client/models/ContentTypeProperty.d.ts +47 -47
- package/dist/client/models/ContentTypeUsage.d.ts +7 -7
- package/dist/client/models/CopyContentOptions.d.ts +21 -21
- package/dist/client/models/DateTimeListItem.d.ts +8 -14
- package/dist/client/models/DateTimeProperty.d.ts +8 -14
- 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.d.ts +9 -9
- package/dist/client/models/FloatListItem.d.ts +10 -16
- package/dist/client/models/FloatProperty.d.ts +10 -16
- package/dist/client/models/ImageDescriptor.d.ts +17 -17
- package/dist/client/models/ImportPackageMessage.d.ts +17 -17
- package/dist/client/models/ImportPackageResult.d.ts +22 -22
- package/dist/client/models/IndexingType.d.ts +8 -8
- package/dist/client/models/Int32EnumerationSettings.d.ts +9 -9
- package/dist/client/models/IntegerListItem.d.ts +10 -16
- package/dist/client/models/IntegerProperty.d.ts +10 -16
- package/dist/client/models/JsonStringProperty.d.ts +5 -5
- package/dist/client/models/ListProperty.d.ts +26 -26
- package/dist/client/models/ListPropertyItem.d.ts +11 -11
- package/dist/client/models/LocaleStatus.d.ts +7 -7
- package/dist/client/models/Manifest.d.ts +24 -19
- package/dist/client/models/OauthToken.d.ts +18 -18
- package/dist/client/models/OauthTokenError.d.ts +13 -13
- package/dist/client/models/OauthTokenRequest.d.ts +21 -21
- package/dist/client/models/PackageJob.d.ts +28 -28
- package/dist/client/models/PackageJobMessage.d.ts +17 -17
- package/dist/client/models/PackageJobStatus.d.ts +4 -4
- package/dist/client/models/ProblemDetails.d.ts +1 -1
- package/dist/client/models/PropertyDataType.d.ts +18 -18
- package/dist/client/models/PropertyFormat.d.ts +34 -34
- package/dist/client/models/PropertyFormatPage.d.ts +19 -19
- package/dist/client/models/PropertyGroup.d.ts +21 -21
- package/dist/client/models/PropertyGroupPage.d.ts +19 -19
- package/dist/client/models/StringEnumerationSettings.d.ts +9 -9
- package/dist/client/models/StringListItem.d.ts +11 -14
- package/dist/client/models/StringProperty.d.ts +11 -14
- package/dist/client/models/UrlListItem.d.ts +5 -5
- package/dist/client/models/UrlProperty.d.ts +5 -5
- package/dist/client/models/VersionStatus.d.ts +12 -12
- package/dist/client/services/ChangesetsService.d.ts +105 -105
- package/dist/client/services/ChangesetsService.js +10 -10
- package/dist/client/services/ContentService.d.ts +172 -172
- package/dist/client/services/ContentService.js +14 -14
- package/dist/client/services/ContentTypesService.d.ts +66 -66
- package/dist/client/services/ContentTypesService.js +6 -6
- package/dist/client/services/DisplayTemplatesService.d.ts +60 -0
- package/dist/client/services/DisplayTemplatesService.js +135 -0
- package/dist/client/services/OauthService.d.ts +17 -17
- package/dist/client/services/OauthService.js +1 -1
- package/dist/client/services/PackagesService.d.ts +41 -41
- package/dist/client/services/PackagesService.js +3 -3
- package/dist/client/services/PropertyFormatsService.d.ts +26 -26
- package/dist/client/services/PropertyFormatsService.js +2 -2
- package/dist/client/services/PropertyGroupsService.d.ts +61 -61
- package/dist/client/services/PropertyGroupsService.js +6 -6
- package/dist/config.d.ts +8 -7
- package/dist/config.js +2 -1
- package/dist/getaccesstoken.d.ts +3 -0
- package/dist/getaccesstoken.js +43 -0
- package/dist/index.d.ts +16 -15
- package/dist/index.js +8 -51
- package/dist/types.d.ts +8 -0
- package/dist/types.js +2 -0
- package/dist/version.json +5 -0
- package/package.json +11 -7
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import type { PropertyFormat } from '../models/PropertyFormat';
|
|
2
|
-
import type { PropertyFormatPage } from '../models/PropertyFormatPage';
|
|
3
|
-
import type { CancelablePromise } from '../core/CancelablePromise';
|
|
4
|
-
import type { BaseHttpRequest } from '../core/BaseHttpRequest';
|
|
5
|
-
export declare class PropertyFormatsService {
|
|
6
|
-
readonly httpRequest: BaseHttpRequest;
|
|
7
|
-
constructor(httpRequest: BaseHttpRequest);
|
|
8
|
-
/**
|
|
9
|
-
* List property formats
|
|
10
|
-
* List all property formats using the provided options.
|
|
11
|
-
* @param pageIndex
|
|
12
|
-
* @param pageSize
|
|
13
|
-
* @returns PropertyFormatPage
|
|
14
|
-
* @throws ApiError
|
|
15
|
-
*/
|
|
16
|
-
propertyFormatsList(pageIndex?: number, pageSize?: number): CancelablePromise<PropertyFormatPage>;
|
|
17
|
-
/**
|
|
18
|
-
* Get property format
|
|
19
|
-
* Get the property format with the provided key.
|
|
20
|
-
* @param key The key of the property format to retrieve.
|
|
21
|
-
* @param allowDeleted Indicates that a deleted property format may be returned.
|
|
22
|
-
* @returns PropertyFormat
|
|
23
|
-
* @throws ApiError
|
|
24
|
-
*/
|
|
25
|
-
propertyFormatsGet(key: string, allowDeleted?: boolean): CancelablePromise<PropertyFormat>;
|
|
26
|
-
}
|
|
1
|
+
import type { PropertyFormat } from '../models/PropertyFormat';
|
|
2
|
+
import type { PropertyFormatPage } from '../models/PropertyFormatPage';
|
|
3
|
+
import type { CancelablePromise } from '../core/CancelablePromise';
|
|
4
|
+
import type { BaseHttpRequest } from '../core/BaseHttpRequest';
|
|
5
|
+
export declare class PropertyFormatsService {
|
|
6
|
+
readonly httpRequest: BaseHttpRequest;
|
|
7
|
+
constructor(httpRequest: BaseHttpRequest);
|
|
8
|
+
/**
|
|
9
|
+
* List property formats
|
|
10
|
+
* List all property formats using the provided options.
|
|
11
|
+
* @param pageIndex
|
|
12
|
+
* @param pageSize
|
|
13
|
+
* @returns PropertyFormatPage OK
|
|
14
|
+
* @throws ApiError
|
|
15
|
+
*/
|
|
16
|
+
propertyFormatsList(pageIndex?: number, pageSize?: number): CancelablePromise<PropertyFormatPage>;
|
|
17
|
+
/**
|
|
18
|
+
* Get property format
|
|
19
|
+
* Get the property format with the provided key.
|
|
20
|
+
* @param key The key of the property format to retrieve.
|
|
21
|
+
* @param allowDeleted Indicates that a deleted property format may be returned.
|
|
22
|
+
* @returns PropertyFormat OK
|
|
23
|
+
* @throws ApiError
|
|
24
|
+
*/
|
|
25
|
+
propertyFormatsGet(key: string, allowDeleted?: boolean): CancelablePromise<PropertyFormat>;
|
|
26
|
+
}
|
|
@@ -10,7 +10,7 @@ class PropertyFormatsService {
|
|
|
10
10
|
* List all property formats using the provided options.
|
|
11
11
|
* @param pageIndex
|
|
12
12
|
* @param pageSize
|
|
13
|
-
* @returns PropertyFormatPage
|
|
13
|
+
* @returns PropertyFormatPage OK
|
|
14
14
|
* @throws ApiError
|
|
15
15
|
*/
|
|
16
16
|
propertyFormatsList(pageIndex, pageSize) {
|
|
@@ -31,7 +31,7 @@ class PropertyFormatsService {
|
|
|
31
31
|
* Get the property format with the provided key.
|
|
32
32
|
* @param key The key of the property format to retrieve.
|
|
33
33
|
* @param allowDeleted Indicates that a deleted property format may be returned.
|
|
34
|
-
* @returns PropertyFormat
|
|
34
|
+
* @returns PropertyFormat OK
|
|
35
35
|
* @throws ApiError
|
|
36
36
|
*/
|
|
37
37
|
propertyFormatsGet(key, allowDeleted) {
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import type { PropertyGroup } from '../models/PropertyGroup';
|
|
2
|
-
import type { PropertyGroupPage } from '../models/PropertyGroupPage';
|
|
3
|
-
import type { CancelablePromise } from '../core/CancelablePromise';
|
|
4
|
-
import type { BaseHttpRequest } from '../core/BaseHttpRequest';
|
|
5
|
-
export declare class PropertyGroupsService {
|
|
6
|
-
readonly httpRequest: BaseHttpRequest;
|
|
7
|
-
constructor(httpRequest: BaseHttpRequest);
|
|
8
|
-
/**
|
|
9
|
-
* List property groups
|
|
10
|
-
* List property groups using the provided options.
|
|
11
|
-
* @param sources Indicates which property groups sources that should be listed.
|
|
12
|
-
* Use All to include groups from all sources or
|
|
13
|
-
* Default to include groups without a specific sources.
|
|
14
|
-
* @returns PropertyGroupPage
|
|
15
|
-
* @throws ApiError
|
|
16
|
-
*/
|
|
17
|
-
propertyGroupsList(sources?: Array<string>): CancelablePromise<PropertyGroupPage>;
|
|
18
|
-
/**
|
|
19
|
-
* Create property group
|
|
20
|
-
* Create a new property group.
|
|
21
|
-
* @param requestBody The property group that should be created.
|
|
22
|
-
* @returns PropertyGroup
|
|
23
|
-
* @throws ApiError
|
|
24
|
-
*/
|
|
25
|
-
propertyGroupsCreate(requestBody: PropertyGroup): CancelablePromise<PropertyGroup>;
|
|
26
|
-
/**
|
|
27
|
-
* Get property group
|
|
28
|
-
* Get the property group with the provided key.
|
|
29
|
-
* @param key The key of the property group to retrieve.
|
|
30
|
-
* @returns PropertyGroup
|
|
31
|
-
* @throws ApiError
|
|
32
|
-
*/
|
|
33
|
-
propertyGroupsGet(key: string): CancelablePromise<PropertyGroup>;
|
|
34
|
-
/**
|
|
35
|
-
* Create or replace property group
|
|
36
|
-
* Create or replace a property group. If a property group with the provided key exist it is replaced.
|
|
37
|
-
* Otherwise a new property group is created.
|
|
38
|
-
* @param key The key of the property group to update or create.
|
|
39
|
-
* @param requestBody The values of the created or replaced property group.
|
|
40
|
-
* @returns PropertyGroup
|
|
41
|
-
* @throws ApiError
|
|
42
|
-
*/
|
|
43
|
-
propertyGroupsPut(key: string, requestBody: PropertyGroup): CancelablePromise<PropertyGroup>;
|
|
44
|
-
/**
|
|
45
|
-
* Update property group
|
|
46
|
-
* Update an existing property group.
|
|
47
|
-
* @param key The key of the property group to patch.
|
|
48
|
-
* @param requestBody The values of the property group that should be updated.
|
|
49
|
-
* @returns PropertyGroup
|
|
50
|
-
* @throws ApiError
|
|
51
|
-
*/
|
|
52
|
-
propertyGroupsPatch(key: string, requestBody: PropertyGroup): CancelablePromise<PropertyGroup>;
|
|
53
|
-
/**
|
|
54
|
-
* Delete property group
|
|
55
|
-
* Deletes the property group with the provided key.
|
|
56
|
-
* @param key The key of the property group to delete.
|
|
57
|
-
* @returns PropertyGroup
|
|
58
|
-
* @throws ApiError
|
|
59
|
-
*/
|
|
60
|
-
propertyGroupsDelete(key: string): CancelablePromise<PropertyGroup>;
|
|
61
|
-
}
|
|
1
|
+
import type { PropertyGroup } from '../models/PropertyGroup';
|
|
2
|
+
import type { PropertyGroupPage } from '../models/PropertyGroupPage';
|
|
3
|
+
import type { CancelablePromise } from '../core/CancelablePromise';
|
|
4
|
+
import type { BaseHttpRequest } from '../core/BaseHttpRequest';
|
|
5
|
+
export declare class PropertyGroupsService {
|
|
6
|
+
readonly httpRequest: BaseHttpRequest;
|
|
7
|
+
constructor(httpRequest: BaseHttpRequest);
|
|
8
|
+
/**
|
|
9
|
+
* List property groups
|
|
10
|
+
* List property groups using the provided options.
|
|
11
|
+
* @param sources Indicates which property groups sources that should be listed.
|
|
12
|
+
* Use All to include groups from all sources or
|
|
13
|
+
* Default to include groups without a specific sources.
|
|
14
|
+
* @returns PropertyGroupPage OK
|
|
15
|
+
* @throws ApiError
|
|
16
|
+
*/
|
|
17
|
+
propertyGroupsList(sources?: Array<string>): CancelablePromise<PropertyGroupPage>;
|
|
18
|
+
/**
|
|
19
|
+
* Create property group
|
|
20
|
+
* Create a new property group.
|
|
21
|
+
* @param requestBody The property group that should be created.
|
|
22
|
+
* @returns PropertyGroup OK
|
|
23
|
+
* @throws ApiError
|
|
24
|
+
*/
|
|
25
|
+
propertyGroupsCreate(requestBody: PropertyGroup): CancelablePromise<PropertyGroup>;
|
|
26
|
+
/**
|
|
27
|
+
* Get property group
|
|
28
|
+
* Get the property group with the provided key.
|
|
29
|
+
* @param key The key of the property group to retrieve.
|
|
30
|
+
* @returns PropertyGroup OK
|
|
31
|
+
* @throws ApiError
|
|
32
|
+
*/
|
|
33
|
+
propertyGroupsGet(key: string): CancelablePromise<PropertyGroup>;
|
|
34
|
+
/**
|
|
35
|
+
* Create or replace property group
|
|
36
|
+
* Create or replace a property group. If a property group with the provided key exist it is replaced.
|
|
37
|
+
* Otherwise a new property group is created.
|
|
38
|
+
* @param key The key of the property group to update or create.
|
|
39
|
+
* @param requestBody The values of the created or replaced property group.
|
|
40
|
+
* @returns PropertyGroup OK
|
|
41
|
+
* @throws ApiError
|
|
42
|
+
*/
|
|
43
|
+
propertyGroupsPut(key: string, requestBody: PropertyGroup): CancelablePromise<PropertyGroup>;
|
|
44
|
+
/**
|
|
45
|
+
* Update property group
|
|
46
|
+
* Update an existing property group.
|
|
47
|
+
* @param key The key of the property group to patch.
|
|
48
|
+
* @param requestBody The values of the property group that should be updated.
|
|
49
|
+
* @returns PropertyGroup OK
|
|
50
|
+
* @throws ApiError
|
|
51
|
+
*/
|
|
52
|
+
propertyGroupsPatch(key: string, requestBody: PropertyGroup): CancelablePromise<PropertyGroup>;
|
|
53
|
+
/**
|
|
54
|
+
* Delete property group
|
|
55
|
+
* Deletes the property group with the provided key.
|
|
56
|
+
* @param key The key of the property group to delete.
|
|
57
|
+
* @returns PropertyGroup OK
|
|
58
|
+
* @throws ApiError
|
|
59
|
+
*/
|
|
60
|
+
propertyGroupsDelete(key: string): CancelablePromise<PropertyGroup>;
|
|
61
|
+
}
|
|
@@ -11,7 +11,7 @@ class PropertyGroupsService {
|
|
|
11
11
|
* @param sources Indicates which property groups sources that should be listed.
|
|
12
12
|
* Use All to include groups from all sources or
|
|
13
13
|
* Default to include groups without a specific sources.
|
|
14
|
-
* @returns PropertyGroupPage
|
|
14
|
+
* @returns PropertyGroupPage OK
|
|
15
15
|
* @throws ApiError
|
|
16
16
|
*/
|
|
17
17
|
propertyGroupsList(sources) {
|
|
@@ -30,7 +30,7 @@ class PropertyGroupsService {
|
|
|
30
30
|
* Create property group
|
|
31
31
|
* Create a new property group.
|
|
32
32
|
* @param requestBody The property group that should be created.
|
|
33
|
-
* @returns PropertyGroup
|
|
33
|
+
* @returns PropertyGroup OK
|
|
34
34
|
* @throws ApiError
|
|
35
35
|
*/
|
|
36
36
|
propertyGroupsCreate(requestBody) {
|
|
@@ -49,7 +49,7 @@ class PropertyGroupsService {
|
|
|
49
49
|
* Get property group
|
|
50
50
|
* Get the property group with the provided key.
|
|
51
51
|
* @param key The key of the property group to retrieve.
|
|
52
|
-
* @returns PropertyGroup
|
|
52
|
+
* @returns PropertyGroup OK
|
|
53
53
|
* @throws ApiError
|
|
54
54
|
*/
|
|
55
55
|
propertyGroupsGet(key) {
|
|
@@ -70,7 +70,7 @@ class PropertyGroupsService {
|
|
|
70
70
|
* Otherwise a new property group is created.
|
|
71
71
|
* @param key The key of the property group to update or create.
|
|
72
72
|
* @param requestBody The values of the created or replaced property group.
|
|
73
|
-
* @returns PropertyGroup
|
|
73
|
+
* @returns PropertyGroup OK
|
|
74
74
|
* @throws ApiError
|
|
75
75
|
*/
|
|
76
76
|
propertyGroupsPut(key, requestBody) {
|
|
@@ -93,7 +93,7 @@ class PropertyGroupsService {
|
|
|
93
93
|
* Update an existing property group.
|
|
94
94
|
* @param key The key of the property group to patch.
|
|
95
95
|
* @param requestBody The values of the property group that should be updated.
|
|
96
|
-
* @returns PropertyGroup
|
|
96
|
+
* @returns PropertyGroup OK
|
|
97
97
|
* @throws ApiError
|
|
98
98
|
*/
|
|
99
99
|
propertyGroupsPatch(key, requestBody) {
|
|
@@ -115,7 +115,7 @@ class PropertyGroupsService {
|
|
|
115
115
|
* Delete property group
|
|
116
116
|
* Deletes the property group with the provided key.
|
|
117
117
|
* @param key The key of the property group to delete.
|
|
118
|
-
* @returns PropertyGroup
|
|
118
|
+
* @returns PropertyGroup OK
|
|
119
119
|
* @throws ApiError
|
|
120
120
|
*/
|
|
121
121
|
propertyGroupsDelete(key) {
|
package/dist/config.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export type CmsIntegrationApiOptions = {
|
|
2
|
-
base: URL;
|
|
3
|
-
clientId?: string;
|
|
4
|
-
clientSecret?: string;
|
|
5
|
-
actAs?: string;
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export type CmsIntegrationApiOptions = {
|
|
2
|
+
base: URL;
|
|
3
|
+
clientId?: string;
|
|
4
|
+
clientSecret?: string;
|
|
5
|
+
actAs?: string;
|
|
6
|
+
debug?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function getCmsIntegrationApiConfigFromEnvironment(): CmsIntegrationApiOptions;
|
package/dist/config.js
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAccessToken = void 0;
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
function isErrorResponse(response) {
|
|
6
|
+
return typeof (response.error) == 'string';
|
|
7
|
+
}
|
|
8
|
+
let _access_token = undefined;
|
|
9
|
+
async function getAccessToken(config) {
|
|
10
|
+
if (!_access_token) {
|
|
11
|
+
_access_token = (async (config) => {
|
|
12
|
+
const options = config ?? (0, config_1.getCmsIntegrationApiConfigFromEnvironment)();
|
|
13
|
+
const authUrl = `${options.base.href}/oauth/token`;
|
|
14
|
+
const headers = new Headers();
|
|
15
|
+
headers.append('Authorization', `Basic ${base64Encode(`${options.clientId}:${options.clientSecret}`)}`);
|
|
16
|
+
headers.append('Content-Type', 'application/x-www-form-urlencoded');
|
|
17
|
+
headers.append('Connection', 'close');
|
|
18
|
+
const body = new URLSearchParams();
|
|
19
|
+
body.append("grant_type", "client_credentials");
|
|
20
|
+
if (options.actAs)
|
|
21
|
+
body.append("act_as", options.actAs);
|
|
22
|
+
const response = await (await fetch(authUrl, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
headers: headers,
|
|
25
|
+
body: body.toString()
|
|
26
|
+
})).json();
|
|
27
|
+
if (isErrorResponse(response))
|
|
28
|
+
throw new Error("Authentication error: " + response.error_description);
|
|
29
|
+
return response.access_token;
|
|
30
|
+
})(config);
|
|
31
|
+
}
|
|
32
|
+
return _access_token;
|
|
33
|
+
}
|
|
34
|
+
exports.getAccessToken = getAccessToken;
|
|
35
|
+
function base64Encode(input) {
|
|
36
|
+
if (btoa && typeof (btoa) == 'function')
|
|
37
|
+
return btoa(input);
|
|
38
|
+
if (Buffer && typeof (Buffer) == 'object')
|
|
39
|
+
//@ts-expect-error
|
|
40
|
+
return Buffer.from(input).toString('base64');
|
|
41
|
+
throw new Error("Unable to base64Encode");
|
|
42
|
+
}
|
|
43
|
+
exports.default = getAccessToken;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
export * from './config';
|
|
2
|
-
export * as IntegrationApi from './client';
|
|
3
|
-
export { CmsIntegrationApiClient } from './client';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
export * from './config';
|
|
2
|
+
export * as IntegrationApi from './client';
|
|
3
|
+
export { CmsIntegrationApiClient as CoreClient } from './client';
|
|
4
|
+
export { ApiClient } from './api-client';
|
|
5
|
+
export { ApiClient as CmsIntegrationApiClient } from './api-client';
|
|
6
|
+
import { type CmsIntegrationApiOptions } from './config';
|
|
7
|
+
import { ApiClient as CmsIntegrationApiClient } from './api-client';
|
|
8
|
+
export declare function createClient(config?: CmsIntegrationApiOptions): CmsIntegrationApiClient;
|
|
9
|
+
export declare enum ContentRoots {
|
|
10
|
+
SystemRoot = "43f936c99b234ea397b261c538ad07c9",
|
|
11
|
+
MultiChannelContent = "41118A415C8C4BE08E73520FF3DE8244"
|
|
12
|
+
}
|
|
13
|
+
export declare enum ContentTypeKeys {
|
|
14
|
+
Folder = "SysContentFolder"
|
|
15
|
+
}
|
|
16
|
+
export default createClient;
|
package/dist/index.js
CHANGED
|
@@ -26,53 +26,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.ContentTypeKeys = exports.ContentRoots = exports.createClient = exports.
|
|
29
|
+
exports.ContentTypeKeys = exports.ContentRoots = exports.createClient = exports.CmsIntegrationApiClient = exports.ApiClient = exports.CoreClient = exports.IntegrationApi = void 0;
|
|
30
30
|
__exportStar(require("./config"), exports);
|
|
31
31
|
exports.IntegrationApi = __importStar(require("./client"));
|
|
32
32
|
var client_1 = require("./client");
|
|
33
|
-
Object.defineProperty(exports, "
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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;
|
|
33
|
+
Object.defineProperty(exports, "CoreClient", { enumerable: true, get: function () { return client_1.CmsIntegrationApiClient; } });
|
|
34
|
+
var api_client_1 = require("./api-client");
|
|
35
|
+
Object.defineProperty(exports, "ApiClient", { enumerable: true, get: function () { return api_client_1.ApiClient; } });
|
|
36
|
+
var api_client_2 = require("./api-client");
|
|
37
|
+
Object.defineProperty(exports, "CmsIntegrationApiClient", { enumerable: true, get: function () { return api_client_2.ApiClient; } });
|
|
38
|
+
const api_client_3 = require("./api-client");
|
|
66
39
|
function createClient(config) {
|
|
67
|
-
|
|
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;
|
|
40
|
+
return new api_client_3.ApiClient(config);
|
|
76
41
|
}
|
|
77
42
|
exports.createClient = createClient;
|
|
78
43
|
var ContentRoots;
|
|
@@ -84,12 +49,4 @@ var ContentTypeKeys;
|
|
|
84
49
|
(function (ContentTypeKeys) {
|
|
85
50
|
ContentTypeKeys["Folder"] = "SysContentFolder";
|
|
86
51
|
})(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
52
|
exports.default = createClient;
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
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-
|
|
6
|
-
"packageManager": "yarn@4.
|
|
5
|
+
"version": "2.0.0-pre5",
|
|
6
|
+
"packageManager": "yarn@4.3.0",
|
|
7
7
|
"type": "commonjs",
|
|
8
8
|
"license": "Apache-2.0",
|
|
9
9
|
"main": "./dist/index.js",
|
|
@@ -12,17 +12,21 @@
|
|
|
12
12
|
"./dist"
|
|
13
13
|
],
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@types/node": "^20.
|
|
15
|
+
"@types/node": "^20.14.2",
|
|
16
|
+
"dotenv": "^16.4.5",
|
|
17
|
+
"glob": "^10.4.1",
|
|
16
18
|
"openapi-typescript-codegen": "^0.29.0",
|
|
17
|
-
"tslib": "^2.6.
|
|
19
|
+
"tslib": "^2.6.3",
|
|
18
20
|
"typescript": "^5.4.5"
|
|
19
21
|
},
|
|
20
22
|
"scripts": {
|
|
21
23
|
"clean": "tsc --build --clean",
|
|
22
|
-
"prepare": "
|
|
24
|
+
"prepare": "tsc --build",
|
|
23
25
|
"watch": "tsc --watch",
|
|
24
|
-
"rebuild": "
|
|
25
|
-
"
|
|
26
|
+
"rebuild": "yarn clean && yarn update-client && tsc --build --force",
|
|
27
|
+
"update-client": "yarn generate-spec && yarn generate-client",
|
|
28
|
+
"generate-client": "yarn openapi --input ./integrationapi.spec.json --output ./src/client --name CmsIntegrationApiClient",
|
|
29
|
+
"generate-spec": "yarn node scripts/update-spec.js"
|
|
26
30
|
},
|
|
27
31
|
"stableVersion": "2.0.0-pre2"
|
|
28
32
|
}
|