@remkoj/optimizely-cms-api 2.0.0-pre2
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/LICENSE +13 -0
- package/README.md +44 -0
- package/dist/client/CmsIntegrationApiClient.d.ts +22 -0
- package/dist/client/CmsIntegrationApiClient.js +34 -0
- package/dist/client/core/ApiError.d.ts +10 -0
- package/dist/client/core/ApiError.js +15 -0
- package/dist/client/core/ApiRequestOptions.d.ts +13 -0
- package/dist/client/core/ApiRequestOptions.js +2 -0
- package/dist/client/core/ApiResult.d.ts +7 -0
- package/dist/client/core/ApiResult.js +2 -0
- package/dist/client/core/BaseHttpRequest.d.ts +8 -0
- package/dist/client/core/BaseHttpRequest.js +9 -0
- package/dist/client/core/CancelablePromise.d.ts +20 -0
- package/dist/client/core/CancelablePromise.js +116 -0
- package/dist/client/core/FetchHttpRequest.d.ts +14 -0
- package/dist/client/core/FetchHttpRequest.js +20 -0
- package/dist/client/core/OpenAPI.d.ts +16 -0
- package/dist/client/core/OpenAPI.js +14 -0
- package/dist/client/core/request.d.ts +30 -0
- package/dist/client/core/request.js +294 -0
- package/dist/client/index.d.ts +76 -0
- package/dist/client/index.js +46 -0
- package/dist/client/models/BinaryProperty.d.ts +8 -0
- package/dist/client/models/BinaryProperty.js +2 -0
- package/dist/client/models/BooleanProperty.d.ts +5 -0
- package/dist/client/models/BooleanProperty.js +2 -0
- package/dist/client/models/Changeset.d.ts +26 -0
- package/dist/client/models/Changeset.js +2 -0
- package/dist/client/models/ChangesetItem.d.ts +11 -0
- package/dist/client/models/ChangesetItem.js +2 -0
- package/dist/client/models/ChangesetItemPage.d.ts +19 -0
- package/dist/client/models/ChangesetItemPage.js +2 -0
- package/dist/client/models/ChangesetPage.d.ts +19 -0
- package/dist/client/models/ChangesetPage.js +2 -0
- package/dist/client/models/ComponentListItem.d.ts +10 -0
- package/dist/client/models/ComponentListItem.js +2 -0
- package/dist/client/models/ComponentProperty.d.ts +10 -0
- package/dist/client/models/ComponentProperty.js +2 -0
- package/dist/client/models/ContentBaseType.d.ts +11 -0
- package/dist/client/models/ContentBaseType.js +19 -0
- package/dist/client/models/ContentComponent.d.ts +34 -0
- package/dist/client/models/ContentComponent.js +2 -0
- package/dist/client/models/ContentItem.d.ts +60 -0
- package/dist/client/models/ContentItem.js +2 -0
- package/dist/client/models/ContentItemListWithContentTypes.d.ts +27 -0
- package/dist/client/models/ContentItemListWithContentTypes.js +2 -0
- package/dist/client/models/ContentItemPage.d.ts +19 -0
- package/dist/client/models/ContentItemPage.js +2 -0
- package/dist/client/models/ContentItemWithContentTypes.d.ts +12 -0
- package/dist/client/models/ContentItemWithContentTypes.js +2 -0
- package/dist/client/models/ContentListItem.d.ts +14 -0
- package/dist/client/models/ContentListItem.js +2 -0
- package/dist/client/models/ContentLocaleInfo.d.ts +11 -0
- package/dist/client/models/ContentLocaleInfo.js +2 -0
- package/dist/client/models/ContentMetadata.d.ts +46 -0
- package/dist/client/models/ContentMetadata.js +2 -0
- package/dist/client/models/ContentMetadataPage.d.ts +19 -0
- package/dist/client/models/ContentMetadataPage.js +2 -0
- package/dist/client/models/ContentProperty.d.ts +14 -0
- package/dist/client/models/ContentProperty.js +2 -0
- package/dist/client/models/ContentReference.d.ts +17 -0
- package/dist/client/models/ContentReference.js +2 -0
- package/dist/client/models/ContentReferenceListItem.d.ts +14 -0
- package/dist/client/models/ContentReferenceListItem.js +2 -0
- package/dist/client/models/ContentReferenceProperty.d.ts +14 -0
- package/dist/client/models/ContentReferenceProperty.js +2 -0
- package/dist/client/models/ContentType.d.ts +79 -0
- package/dist/client/models/ContentType.js +2 -0
- package/dist/client/models/ContentTypeFeature.d.ts +10 -0
- package/dist/client/models/ContentTypeFeature.js +18 -0
- package/dist/client/models/ContentTypePage.d.ts +19 -0
- package/dist/client/models/ContentTypePage.js +2 -0
- package/dist/client/models/ContentTypeProperty.d.ts +47 -0
- package/dist/client/models/ContentTypeProperty.js +2 -0
- package/dist/client/models/ContentTypeUsage.d.ts +7 -0
- package/dist/client/models/ContentTypeUsage.js +15 -0
- package/dist/client/models/CopyContentOptions.d.ts +21 -0
- package/dist/client/models/CopyContentOptions.js +2 -0
- package/dist/client/models/DateTimeListItem.d.ts +14 -0
- package/dist/client/models/DateTimeListItem.js +2 -0
- package/dist/client/models/DateTimeProperty.d.ts +14 -0
- package/dist/client/models/DateTimeProperty.js +2 -0
- package/dist/client/models/DoubleEnumerationSettings.d.ts +9 -0
- package/dist/client/models/DoubleEnumerationSettings.js +2 -0
- package/dist/client/models/FloatListItem.d.ts +16 -0
- package/dist/client/models/FloatListItem.js +2 -0
- package/dist/client/models/FloatProperty.d.ts +16 -0
- package/dist/client/models/FloatProperty.js +2 -0
- package/dist/client/models/ImageDescriptor.d.ts +17 -0
- package/dist/client/models/ImageDescriptor.js +2 -0
- package/dist/client/models/ImportPackageMessage.d.ts +17 -0
- package/dist/client/models/ImportPackageMessage.js +2 -0
- package/dist/client/models/ImportPackageResult.d.ts +22 -0
- package/dist/client/models/ImportPackageResult.js +2 -0
- package/dist/client/models/IndexingType.d.ts +8 -0
- package/dist/client/models/IndexingType.js +16 -0
- package/dist/client/models/Int32EnumerationSettings.d.ts +9 -0
- package/dist/client/models/Int32EnumerationSettings.js +2 -0
- package/dist/client/models/IntegerListItem.d.ts +16 -0
- package/dist/client/models/IntegerListItem.js +2 -0
- package/dist/client/models/IntegerProperty.d.ts +16 -0
- package/dist/client/models/IntegerProperty.js +2 -0
- package/dist/client/models/JsonStringProperty.d.ts +5 -0
- package/dist/client/models/JsonStringProperty.js +2 -0
- package/dist/client/models/ListProperty.d.ts +26 -0
- package/dist/client/models/ListProperty.js +2 -0
- package/dist/client/models/ListPropertyItem.d.ts +11 -0
- package/dist/client/models/ListPropertyItem.js +2 -0
- package/dist/client/models/LocaleStatus.d.ts +7 -0
- package/dist/client/models/LocaleStatus.js +15 -0
- package/dist/client/models/Manifest.d.ts +19 -0
- package/dist/client/models/Manifest.js +2 -0
- package/dist/client/models/OauthToken.d.ts +18 -0
- package/dist/client/models/OauthToken.js +2 -0
- package/dist/client/models/OauthTokenError.d.ts +13 -0
- package/dist/client/models/OauthTokenError.js +2 -0
- package/dist/client/models/OauthTokenRequest.d.ts +21 -0
- package/dist/client/models/OauthTokenRequest.js +2 -0
- package/dist/client/models/PackageJob.d.ts +28 -0
- package/dist/client/models/PackageJob.js +2 -0
- package/dist/client/models/PackageJobMessage.d.ts +17 -0
- package/dist/client/models/PackageJobMessage.js +2 -0
- package/dist/client/models/PackageJobStatus.d.ts +4 -0
- package/dist/client/models/PackageJobStatus.js +2 -0
- package/dist/client/models/ProblemDetails.d.ts +1 -0
- package/dist/client/models/ProblemDetails.js +2 -0
- package/dist/client/models/PropertyDataType.d.ts +18 -0
- package/dist/client/models/PropertyDataType.js +26 -0
- package/dist/client/models/PropertyFormat.d.ts +34 -0
- package/dist/client/models/PropertyFormat.js +2 -0
- package/dist/client/models/PropertyFormatPage.d.ts +19 -0
- package/dist/client/models/PropertyFormatPage.js +2 -0
- package/dist/client/models/PropertyGroup.d.ts +21 -0
- package/dist/client/models/PropertyGroup.js +2 -0
- package/dist/client/models/PropertyGroupPage.d.ts +19 -0
- package/dist/client/models/PropertyGroupPage.js +2 -0
- package/dist/client/models/StringEnumerationSettings.d.ts +9 -0
- package/dist/client/models/StringEnumerationSettings.js +2 -0
- package/dist/client/models/StringListItem.d.ts +14 -0
- package/dist/client/models/StringListItem.js +2 -0
- package/dist/client/models/StringProperty.d.ts +14 -0
- package/dist/client/models/StringProperty.js +2 -0
- package/dist/client/models/UrlListItem.d.ts +5 -0
- package/dist/client/models/UrlListItem.js +2 -0
- package/dist/client/models/UrlProperty.d.ts +5 -0
- package/dist/client/models/UrlProperty.js +2 -0
- package/dist/client/models/VersionStatus.d.ts +12 -0
- package/dist/client/models/VersionStatus.js +20 -0
- package/dist/client/services/ChangesetsService.d.ts +105 -0
- package/dist/client/services/ChangesetsService.js +239 -0
- package/dist/client/services/ContentService.d.ts +172 -0
- package/dist/client/services/ContentService.js +409 -0
- package/dist/client/services/ContentTypesService.d.ts +66 -0
- package/dist/client/services/ContentTypesService.js +149 -0
- package/dist/client/services/OauthService.d.ts +17 -0
- package/dist/client/services/OauthService.js +28 -0
- package/dist/client/services/PackagesService.d.ts +41 -0
- package/dist/client/services/PackagesService.js +80 -0
- package/dist/client/services/PropertyFormatsService.d.ts +26 -0
- package/dist/client/services/PropertyFormatsService.js +53 -0
- package/dist/client/services/PropertyGroupsService.d.ts +61 -0
- package/dist/client/services/PropertyGroupsService.js +135 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.js +36 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +95 -0
- package/package.json +27 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ImportPackageResult } from '../models/ImportPackageResult';
|
|
2
|
+
import type { Manifest } from '../models/Manifest';
|
|
3
|
+
import type { PackageJob } from '../models/PackageJob';
|
|
4
|
+
import type { CancelablePromise } from '../core/CancelablePromise';
|
|
5
|
+
import type { BaseHttpRequest } from '../core/BaseHttpRequest';
|
|
6
|
+
export declare class PackagesService {
|
|
7
|
+
readonly httpRequest: BaseHttpRequest;
|
|
8
|
+
constructor(httpRequest: BaseHttpRequest);
|
|
9
|
+
/**
|
|
10
|
+
* Get job status
|
|
11
|
+
* Get a package job status.
|
|
12
|
+
* @param key The key of the package job.
|
|
13
|
+
* @returns PackageJob Success
|
|
14
|
+
* @throws ApiError
|
|
15
|
+
*/
|
|
16
|
+
packagesGet(key: string): CancelablePromise<PackageJob>;
|
|
17
|
+
/**
|
|
18
|
+
* Export package
|
|
19
|
+
* Export a data package.
|
|
20
|
+
* @param includeReadOnly Indicates if read-only resources should be included in the export data.
|
|
21
|
+
* @returns Manifest Success
|
|
22
|
+
* @throws ApiError
|
|
23
|
+
*/
|
|
24
|
+
packagesExport(includeReadOnly?: boolean): CancelablePromise<Manifest>;
|
|
25
|
+
/**
|
|
26
|
+
* Import package
|
|
27
|
+
* Import a data package.
|
|
28
|
+
* @param container The key of the container content where new content items should be created under.
|
|
29
|
+
* @param overwriteExistingContentItems Indicates if the existing content item in CMS could be overwritten when the importing package contains
|
|
30
|
+
* content item with the same key.
|
|
31
|
+
* If set to `false`, always create new content item under the specified container regardless of the content key.
|
|
32
|
+
* @param ignoreDataLossWarnings Updates the content type even though the changes might result in data loss.
|
|
33
|
+
* @param locale Specifies the locale in which content item in that locale will be imported. If no locale is defined
|
|
34
|
+
* then content in all locales are imported.
|
|
35
|
+
* @param requestBody
|
|
36
|
+
* @returns ImportPackageResult Success
|
|
37
|
+
* @returns PackageJob Accepted
|
|
38
|
+
* @throws ApiError
|
|
39
|
+
*/
|
|
40
|
+
packagesImport(container?: string, overwriteExistingContentItems?: boolean, ignoreDataLossWarnings?: boolean, locale?: string, requestBody?: Blob): CancelablePromise<ImportPackageResult | PackageJob>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PackagesService = void 0;
|
|
4
|
+
class PackagesService {
|
|
5
|
+
constructor(httpRequest) {
|
|
6
|
+
this.httpRequest = httpRequest;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get job status
|
|
10
|
+
* Get a package job status.
|
|
11
|
+
* @param key The key of the package job.
|
|
12
|
+
* @returns PackageJob Success
|
|
13
|
+
* @throws ApiError
|
|
14
|
+
*/
|
|
15
|
+
packagesGet(key) {
|
|
16
|
+
return this.httpRequest.request({
|
|
17
|
+
method: 'GET',
|
|
18
|
+
url: '/packages/{key}',
|
|
19
|
+
path: {
|
|
20
|
+
'key': key,
|
|
21
|
+
},
|
|
22
|
+
errors: {
|
|
23
|
+
403: `Forbidden`,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Export package
|
|
29
|
+
* Export a data package.
|
|
30
|
+
* @param includeReadOnly Indicates if read-only resources should be included in the export data.
|
|
31
|
+
* @returns Manifest Success
|
|
32
|
+
* @throws ApiError
|
|
33
|
+
*/
|
|
34
|
+
packagesExport(includeReadOnly) {
|
|
35
|
+
return this.httpRequest.request({
|
|
36
|
+
method: 'GET',
|
|
37
|
+
url: '/packages',
|
|
38
|
+
query: {
|
|
39
|
+
'includeReadOnly': includeReadOnly,
|
|
40
|
+
},
|
|
41
|
+
errors: {
|
|
42
|
+
403: `Forbidden`,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Import package
|
|
48
|
+
* Import a data package.
|
|
49
|
+
* @param container The key of the container content where new content items should be created under.
|
|
50
|
+
* @param overwriteExistingContentItems Indicates if the existing content item in CMS could be overwritten when the importing package contains
|
|
51
|
+
* content item with the same key.
|
|
52
|
+
* If set to `false`, always create new content item under the specified container regardless of the content key.
|
|
53
|
+
* @param ignoreDataLossWarnings Updates the content type even though the changes might result in data loss.
|
|
54
|
+
* @param locale Specifies the locale in which content item in that locale will be imported. If no locale is defined
|
|
55
|
+
* then content in all locales are imported.
|
|
56
|
+
* @param requestBody
|
|
57
|
+
* @returns ImportPackageResult Success
|
|
58
|
+
* @returns PackageJob Accepted
|
|
59
|
+
* @throws ApiError
|
|
60
|
+
*/
|
|
61
|
+
packagesImport(container, overwriteExistingContentItems = false, ignoreDataLossWarnings = false, locale, requestBody) {
|
|
62
|
+
return this.httpRequest.request({
|
|
63
|
+
method: 'POST',
|
|
64
|
+
url: '/packages',
|
|
65
|
+
query: {
|
|
66
|
+
'container': container,
|
|
67
|
+
'overwriteExistingContentItems': overwriteExistingContentItems,
|
|
68
|
+
'ignoreDataLossWarnings': ignoreDataLossWarnings,
|
|
69
|
+
'locale': locale,
|
|
70
|
+
},
|
|
71
|
+
body: requestBody,
|
|
72
|
+
mediaType: 'application/vnd.episerver.cms.data',
|
|
73
|
+
errors: {
|
|
74
|
+
400: `Bad Request`,
|
|
75
|
+
403: `Forbidden`,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.PackagesService = PackagesService;
|
|
@@ -0,0 +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 Success
|
|
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 Success
|
|
23
|
+
* @throws ApiError
|
|
24
|
+
*/
|
|
25
|
+
propertyFormatsGet(key: string, allowDeleted?: boolean): CancelablePromise<PropertyFormat>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PropertyFormatsService = void 0;
|
|
4
|
+
class PropertyFormatsService {
|
|
5
|
+
constructor(httpRequest) {
|
|
6
|
+
this.httpRequest = httpRequest;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* List property formats
|
|
10
|
+
* List all property formats using the provided options.
|
|
11
|
+
* @param pageIndex
|
|
12
|
+
* @param pageSize
|
|
13
|
+
* @returns PropertyFormatPage Success
|
|
14
|
+
* @throws ApiError
|
|
15
|
+
*/
|
|
16
|
+
propertyFormatsList(pageIndex, pageSize) {
|
|
17
|
+
return this.httpRequest.request({
|
|
18
|
+
method: 'GET',
|
|
19
|
+
url: '/propertyformats',
|
|
20
|
+
query: {
|
|
21
|
+
'pageIndex': pageIndex,
|
|
22
|
+
'pageSize': pageSize,
|
|
23
|
+
},
|
|
24
|
+
errors: {
|
|
25
|
+
403: `Forbidden`,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get property format
|
|
31
|
+
* Get the property format with the provided key.
|
|
32
|
+
* @param key The key of the property format to retrieve.
|
|
33
|
+
* @param allowDeleted Indicates that a deleted property format may be returned.
|
|
34
|
+
* @returns PropertyFormat Success
|
|
35
|
+
* @throws ApiError
|
|
36
|
+
*/
|
|
37
|
+
propertyFormatsGet(key, allowDeleted) {
|
|
38
|
+
return this.httpRequest.request({
|
|
39
|
+
method: 'GET',
|
|
40
|
+
url: '/propertyformats/{key}',
|
|
41
|
+
path: {
|
|
42
|
+
'key': key,
|
|
43
|
+
},
|
|
44
|
+
query: {
|
|
45
|
+
'allowDeleted': allowDeleted,
|
|
46
|
+
},
|
|
47
|
+
errors: {
|
|
48
|
+
403: `Forbidden`,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.PropertyFormatsService = PropertyFormatsService;
|
|
@@ -0,0 +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 Success
|
|
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 Success
|
|
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 Success
|
|
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 Success
|
|
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 Success
|
|
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 Success
|
|
58
|
+
* @throws ApiError
|
|
59
|
+
*/
|
|
60
|
+
propertyGroupsDelete(key: string): CancelablePromise<PropertyGroup>;
|
|
61
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PropertyGroupsService = void 0;
|
|
4
|
+
class PropertyGroupsService {
|
|
5
|
+
constructor(httpRequest) {
|
|
6
|
+
this.httpRequest = httpRequest;
|
|
7
|
+
}
|
|
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 Success
|
|
15
|
+
* @throws ApiError
|
|
16
|
+
*/
|
|
17
|
+
propertyGroupsList(sources) {
|
|
18
|
+
return this.httpRequest.request({
|
|
19
|
+
method: 'GET',
|
|
20
|
+
url: '/propertygroups',
|
|
21
|
+
query: {
|
|
22
|
+
'sources': sources,
|
|
23
|
+
},
|
|
24
|
+
errors: {
|
|
25
|
+
403: `Forbidden`,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create property group
|
|
31
|
+
* Create a new property group.
|
|
32
|
+
* @param requestBody The property group that should be created.
|
|
33
|
+
* @returns PropertyGroup Success
|
|
34
|
+
* @throws ApiError
|
|
35
|
+
*/
|
|
36
|
+
propertyGroupsCreate(requestBody) {
|
|
37
|
+
return this.httpRequest.request({
|
|
38
|
+
method: 'POST',
|
|
39
|
+
url: '/propertygroups',
|
|
40
|
+
body: requestBody,
|
|
41
|
+
mediaType: 'application/json',
|
|
42
|
+
errors: {
|
|
43
|
+
400: `Bad Request`,
|
|
44
|
+
403: `Forbidden`,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get property group
|
|
50
|
+
* Get the property group with the provided key.
|
|
51
|
+
* @param key The key of the property group to retrieve.
|
|
52
|
+
* @returns PropertyGroup Success
|
|
53
|
+
* @throws ApiError
|
|
54
|
+
*/
|
|
55
|
+
propertyGroupsGet(key) {
|
|
56
|
+
return this.httpRequest.request({
|
|
57
|
+
method: 'GET',
|
|
58
|
+
url: '/propertygroups/{key}',
|
|
59
|
+
path: {
|
|
60
|
+
'key': key,
|
|
61
|
+
},
|
|
62
|
+
errors: {
|
|
63
|
+
403: `Forbidden`,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Create or replace property group
|
|
69
|
+
* Create or replace a property group. If a property group with the provided key exist it is replaced.
|
|
70
|
+
* Otherwise a new property group is created.
|
|
71
|
+
* @param key The key of the property group to update or create.
|
|
72
|
+
* @param requestBody The values of the created or replaced property group.
|
|
73
|
+
* @returns PropertyGroup Success
|
|
74
|
+
* @throws ApiError
|
|
75
|
+
*/
|
|
76
|
+
propertyGroupsPut(key, requestBody) {
|
|
77
|
+
return this.httpRequest.request({
|
|
78
|
+
method: 'PUT',
|
|
79
|
+
url: '/propertygroups/{key}',
|
|
80
|
+
path: {
|
|
81
|
+
'key': key,
|
|
82
|
+
},
|
|
83
|
+
body: requestBody,
|
|
84
|
+
mediaType: 'application/json',
|
|
85
|
+
errors: {
|
|
86
|
+
400: `Bad Request`,
|
|
87
|
+
403: `Forbidden`,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Update property group
|
|
93
|
+
* Update an existing property group.
|
|
94
|
+
* @param key The key of the property group to patch.
|
|
95
|
+
* @param requestBody The values of the property group that should be updated.
|
|
96
|
+
* @returns PropertyGroup Success
|
|
97
|
+
* @throws ApiError
|
|
98
|
+
*/
|
|
99
|
+
propertyGroupsPatch(key, requestBody) {
|
|
100
|
+
return this.httpRequest.request({
|
|
101
|
+
method: 'PATCH',
|
|
102
|
+
url: '/propertygroups/{key}',
|
|
103
|
+
path: {
|
|
104
|
+
'key': key,
|
|
105
|
+
},
|
|
106
|
+
body: requestBody,
|
|
107
|
+
mediaType: 'application/merge-patch+json',
|
|
108
|
+
errors: {
|
|
109
|
+
400: `Bad Request`,
|
|
110
|
+
403: `Forbidden`,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Delete property group
|
|
116
|
+
* Deletes the property group with the provided key.
|
|
117
|
+
* @param key The key of the property group to delete.
|
|
118
|
+
* @returns PropertyGroup Success
|
|
119
|
+
* @throws ApiError
|
|
120
|
+
*/
|
|
121
|
+
propertyGroupsDelete(key) {
|
|
122
|
+
return this.httpRequest.request({
|
|
123
|
+
method: 'DELETE',
|
|
124
|
+
url: '/propertygroups/{key}',
|
|
125
|
+
path: {
|
|
126
|
+
'key': key,
|
|
127
|
+
},
|
|
128
|
+
errors: {
|
|
129
|
+
400: `Bad Request`,
|
|
130
|
+
403: `Forbidden`,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.PropertyGroupsService = PropertyGroupsService;
|
package/dist/config.d.ts
ADDED
package/dist/config.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCmsIntegrationApiConfigFromEnvironment = exports.API_VERSION = void 0;
|
|
4
|
+
exports.API_VERSION = 'v0.5';
|
|
5
|
+
function getCmsIntegrationApiConfigFromEnvironment() {
|
|
6
|
+
const cmsUrl = getMandatory('OPTIMIZELY_CMS_URL');
|
|
7
|
+
const clientId = getMandatory('OPTIMIZELY_CMS_CLIENT_ID');
|
|
8
|
+
const clientSecret = getMandatory('OPTIMIZELY_CMS_CLIENT_SECRET');
|
|
9
|
+
const actAs = getOptional('OPTIMIZELY_CMS_USER_ID');
|
|
10
|
+
let baseUrl;
|
|
11
|
+
try {
|
|
12
|
+
baseUrl = new URL('/_cms/' + exports.API_VERSION, cmsUrl);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new Error("Invalid URL provided");
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
base: baseUrl,
|
|
19
|
+
clientId,
|
|
20
|
+
clientSecret,
|
|
21
|
+
actAs
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.getCmsIntegrationApiConfigFromEnvironment = getCmsIntegrationApiConfigFromEnvironment;
|
|
25
|
+
function getOptional(variable, defaultValue) {
|
|
26
|
+
const envValue = process.env[variable];
|
|
27
|
+
if (!envValue || envValue == "")
|
|
28
|
+
return defaultValue;
|
|
29
|
+
return envValue;
|
|
30
|
+
}
|
|
31
|
+
function getMandatory(variable) {
|
|
32
|
+
const envValue = process.env[variable];
|
|
33
|
+
if (!envValue)
|
|
34
|
+
throw new Error(`The environment variable ${variable} is missing or empty`);
|
|
35
|
+
return envValue;
|
|
36
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './config';
|
|
2
|
+
export * as IntegrationApi from './client';
|
|
3
|
+
export { CmsIntegrationApiClient } from './client';
|
|
4
|
+
import { type CmsIntegrationApiOptions } from './config';
|
|
5
|
+
import { CmsIntegrationApiClient } from './client';
|
|
6
|
+
export declare function getAccessToken(config?: CmsIntegrationApiOptions): Promise<string>;
|
|
7
|
+
export declare function createClient(config?: CmsIntegrationApiOptions): CmsIntegrationApiClient;
|
|
8
|
+
export declare enum ContentRoots {
|
|
9
|
+
SystemRoot = "43f936c99b234ea397b261c538ad07c9",
|
|
10
|
+
MultiChannelContent = "41118A415C8C4BE08E73520FF3DE8244"
|
|
11
|
+
}
|
|
12
|
+
export declare enum ContentTypeKeys {
|
|
13
|
+
Folder = "SysContentFolder"
|
|
14
|
+
}
|
|
15
|
+
export default createClient;
|
package/dist/index.js
ADDED
|
@@ -0,0 +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;
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@remkoj/optimizely-cms-api",
|
|
3
|
+
"displayName": "Optimizely CMS - Integration API Client",
|
|
4
|
+
"description": "A Javascript client for the Integration API provided by the Optimizely CMS.",
|
|
5
|
+
"version": "2.0.0-pre2",
|
|
6
|
+
"packageManager": "yarn@4.1.1",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"./dist"
|
|
13
|
+
],
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/node": "^20.12.7",
|
|
16
|
+
"openapi-typescript-codegen": "^0.29.0",
|
|
17
|
+
"tslib": "^2.6.2",
|
|
18
|
+
"typescript": "^5.4.5"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"clean": "tsc --build --clean",
|
|
22
|
+
"prepare": "yarn generate-client && tsc --build",
|
|
23
|
+
"watch": "tsc --watch",
|
|
24
|
+
"rebuild": "tsc --build --clean && yarn generate-client && tsc --build --force",
|
|
25
|
+
"generate-client": "yarn openapi --input ./integrationapi.spec.json --output ./src/client --name CmsIntegrationApiClient"
|
|
26
|
+
}
|
|
27
|
+
}
|