@remkoj/optimizely-cms-api 5.1.1 → 6.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/dist/api-client.d.ts +53 -10
- package/dist/api-client.js +142 -42
- package/dist/client/client/client.d.ts +2 -0
- package/dist/client/client/client.js +147 -0
- package/dist/client/client/index.d.ts +7 -0
- package/dist/client/client/index.js +14 -0
- package/dist/client/client/types.d.ts +119 -0
- package/dist/client/client/types.js +2 -0
- package/dist/client/client/utils.d.ts +45 -0
- package/dist/client/client/utils.js +296 -0
- package/dist/client/client.gen.d.ts +12 -0
- package/dist/client/client.gen.js +9 -0
- package/dist/client/core/auth.d.ts +18 -0
- package/dist/client/core/auth.js +17 -0
- package/dist/client/core/bodySerializer.d.ts +17 -0
- package/dist/client/core/bodySerializer.js +56 -0
- package/dist/client/core/params.d.ts +23 -0
- package/dist/client/core/params.js +91 -0
- package/dist/client/core/pathSerializer.d.ts +33 -0
- package/dist/client/core/pathSerializer.js +122 -0
- package/dist/client/core/types.d.ts +73 -0
- package/dist/client/core/types.js +2 -0
- package/dist/client/index.d.ts +4 -78
- package/dist/client/index.js +19 -46
- package/dist/client/sdk.gen.d.ts +256 -0
- package/dist/client/sdk.gen.js +638 -0
- package/dist/client/transformers.gen.d.ts +34 -0
- package/dist/client/transformers.gen.js +273 -0
- package/dist/client/types.gen.d.ts +2684 -0
- package/dist/client/types.gen.js +87 -0
- package/dist/client-config.d.ts +2 -0
- package/dist/client-config.js +27 -0
- package/dist/config.js +1 -2
- package/dist/getaccesstoken.js +1 -2
- package/dist/index.d.ts +3 -5
- package/dist/index.js +6 -8
- package/dist/version.json +2 -2
- package/package.json +18 -9
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.VersionStatus = exports.PropertyDataType = exports.LocaleStatus = exports.IndexingType = exports.ContentTypeUsage = exports.ContentTypeFeature = exports.ContentBaseType = exports.CompositionBehavior = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* Represent a Composition behavior for a ContentType.
|
|
7
|
+
*/
|
|
8
|
+
exports.CompositionBehavior = {
|
|
9
|
+
SECTION_ENABLED: 'sectionEnabled',
|
|
10
|
+
ELEMENT_ENABLED: 'elementEnabled'
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Represent the base type of a ContentType.
|
|
14
|
+
*/
|
|
15
|
+
exports.ContentBaseType = {
|
|
16
|
+
PAGE: 'page',
|
|
17
|
+
COMPONENT: 'component',
|
|
18
|
+
MEDIA: 'media',
|
|
19
|
+
IMAGE: 'image',
|
|
20
|
+
VIDEO: 'video',
|
|
21
|
+
FOLDER: 'folder',
|
|
22
|
+
EXPERIENCE: 'experience',
|
|
23
|
+
SECTION: 'section',
|
|
24
|
+
ELEMENT: 'element'
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Represent different features that a content type can have.
|
|
28
|
+
*/
|
|
29
|
+
exports.ContentTypeFeature = {
|
|
30
|
+
LOCALIZATION: 'localization',
|
|
31
|
+
VERSIONING: 'versioning',
|
|
32
|
+
PUBLISH_PERIOD: 'publishPeriod',
|
|
33
|
+
ROUTING: 'routing',
|
|
34
|
+
BINARY: 'binary'
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Represent the usage types for a ContentType.
|
|
38
|
+
*/
|
|
39
|
+
exports.ContentTypeUsage = {
|
|
40
|
+
PROPERTY: 'property',
|
|
41
|
+
INSTANCE: 'instance'
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Represents the indexing type of a content type property.
|
|
45
|
+
*/
|
|
46
|
+
exports.IndexingType = {
|
|
47
|
+
DISABLED: 'disabled',
|
|
48
|
+
QUERYABLE: 'queryable',
|
|
49
|
+
SEARCHABLE: 'searchable'
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Represent the different status values of a content locale.
|
|
53
|
+
*/
|
|
54
|
+
exports.LocaleStatus = {
|
|
55
|
+
DRAFT: 'draft',
|
|
56
|
+
PUBLISHED: 'published'
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Represent the basic type that a PropertyFormat
|
|
60
|
+
* is using for data storage and data transport.
|
|
61
|
+
*/
|
|
62
|
+
exports.PropertyDataType = {
|
|
63
|
+
STRING: 'string',
|
|
64
|
+
URL: 'url',
|
|
65
|
+
BOOLEAN: 'boolean',
|
|
66
|
+
INTEGER: 'integer',
|
|
67
|
+
FLOAT: 'float',
|
|
68
|
+
DATE_TIME: 'dateTime',
|
|
69
|
+
CONTENT_REFERENCE: 'contentReference',
|
|
70
|
+
CONTENT: 'content',
|
|
71
|
+
BINARY: 'binary',
|
|
72
|
+
JSON: 'json',
|
|
73
|
+
ARRAY: 'array',
|
|
74
|
+
COMPONENT: 'component'
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Represent the different status values of a content version.
|
|
78
|
+
*/
|
|
79
|
+
exports.VersionStatus = {
|
|
80
|
+
DRAFT: 'draft',
|
|
81
|
+
READY: 'ready',
|
|
82
|
+
PUBLISHED: 'published',
|
|
83
|
+
PREVIOUS: 'previous',
|
|
84
|
+
SCHEDULED: 'scheduled',
|
|
85
|
+
REJECTED: 'rejected',
|
|
86
|
+
IN_REVIEW: 'inReview'
|
|
87
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createClientConfig = void 0;
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const getaccesstoken_1 = require("./getaccesstoken");
|
|
6
|
+
const createClientConfig = (config) => {
|
|
7
|
+
const envConfig = (0, config_1.getCmsIntegrationApiConfigFromEnvironment)();
|
|
8
|
+
const baseUrl = envConfig.base.href;
|
|
9
|
+
const newClientConfig = {
|
|
10
|
+
baseUrl,
|
|
11
|
+
auth: (auth) => {
|
|
12
|
+
auth.scheme = "bearer";
|
|
13
|
+
auth.type = "apiKey";
|
|
14
|
+
return (0, getaccesstoken_1.getAccessToken)(envConfig).catch((error) => {
|
|
15
|
+
if (envConfig?.debug)
|
|
16
|
+
console.error(`❌ Error while resolving the Access Token`, error);
|
|
17
|
+
return undefined;
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
...config,
|
|
21
|
+
};
|
|
22
|
+
// Ensure the baseUrl is set
|
|
23
|
+
if (!newClientConfig.baseUrl)
|
|
24
|
+
newClientConfig.baseUrl = baseUrl;
|
|
25
|
+
return newClientConfig;
|
|
26
|
+
};
|
|
27
|
+
exports.createClientConfig = createClientConfig;
|
package/dist/config.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCmsIntegrationApiConfigFromEnvironment = getCmsIntegrationApiConfigFromEnvironment;
|
|
4
|
-
const OpenAPI_1 = require("./client/core/OpenAPI");
|
|
5
4
|
const types_1 = require("./types");
|
|
6
5
|
function getCmsIntegrationApiConfigFromEnvironment() {
|
|
7
6
|
const cmsUrl = getOptional('OPTIMIZELY_CMS_URL', 'https://example.cms.optimizely.com');
|
|
@@ -13,7 +12,7 @@ function getCmsIntegrationApiConfigFromEnvironment() {
|
|
|
13
12
|
let baseUrl;
|
|
14
13
|
try {
|
|
15
14
|
const cmsUrlAdjusted = cmsUrl.includes("://") ? cmsUrl : 'https://' + cmsUrl;
|
|
16
|
-
baseUrl = new URL(
|
|
15
|
+
baseUrl = new URL('/_cms/preview2', cmsUrlAdjusted);
|
|
17
16
|
if (cmsVersion == types_1.OptiCmsVersion.CMS12)
|
|
18
17
|
baseUrl.pathname = baseUrl.pathname.replace('preview2', 'preview1');
|
|
19
18
|
}
|
package/dist/getaccesstoken.js
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAccessToken = getAccessToken;
|
|
4
4
|
const config_1 = require("./config");
|
|
5
|
-
const OpenAPI_1 = require("./client/core/OpenAPI");
|
|
6
5
|
const types_1 = require("./types");
|
|
7
6
|
function isErrorResponse(response) {
|
|
8
7
|
return typeof (response.error) == 'string';
|
|
9
8
|
}
|
|
10
9
|
async function getAccessToken(config) {
|
|
11
10
|
const options = config ?? (0, config_1.getCmsIntegrationApiConfigFromEnvironment)();
|
|
12
|
-
let authUrl = new URL(
|
|
11
|
+
let authUrl = new URL(`/_cms/preview2/oauth/token`, options.base).href;
|
|
13
12
|
const headers = new Headers();
|
|
14
13
|
if (options.cmsVersion == types_1.OptiCmsVersion.CMS12)
|
|
15
14
|
authUrl = authUrl.replace('preview2', 'preview1');
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
export * from './config';
|
|
2
|
-
export * as IntegrationApi from './client';
|
|
3
|
-
export {
|
|
4
|
-
export { ApiClient } from './api-client';
|
|
5
|
-
export { ApiClient as CmsIntegrationApiClient } from './api-client';
|
|
2
|
+
export * as IntegrationApi from './client/types.gen';
|
|
3
|
+
export { ApiClient, ApiError, ApiClient as CoreClient, type ApiClientStatic, type CmsIntegrationApiClient } from './api-client';
|
|
6
4
|
export { OptiCmsVersion } from "./types";
|
|
7
5
|
import { type CmsIntegrationApiOptions } from './config';
|
|
8
|
-
import {
|
|
6
|
+
import { type CmsIntegrationApiClient } from './api-client';
|
|
9
7
|
export declare function createClient(config?: CmsIntegrationApiOptions): CmsIntegrationApiClient;
|
|
10
8
|
export declare enum ContentRoots {
|
|
11
9
|
/**
|
package/dist/index.js
CHANGED
|
@@ -36,21 +36,19 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.ContentTypeKeys = exports.ContentRoots = exports.OptiCmsVersion = exports.
|
|
39
|
+
exports.ContentTypeKeys = exports.ContentRoots = exports.OptiCmsVersion = exports.CoreClient = exports.ApiError = exports.ApiClient = exports.IntegrationApi = void 0;
|
|
40
40
|
exports.createClient = createClient;
|
|
41
41
|
__exportStar(require("./config"), exports);
|
|
42
|
-
exports.IntegrationApi = __importStar(require("./client"));
|
|
43
|
-
var client_1 = require("./client");
|
|
44
|
-
Object.defineProperty(exports, "CoreClient", { enumerable: true, get: function () { return client_1.CmsIntegrationApiClient; } });
|
|
42
|
+
exports.IntegrationApi = __importStar(require("./client/types.gen"));
|
|
45
43
|
var api_client_1 = require("./api-client");
|
|
46
44
|
Object.defineProperty(exports, "ApiClient", { enumerable: true, get: function () { return api_client_1.ApiClient; } });
|
|
47
|
-
|
|
48
|
-
Object.defineProperty(exports, "
|
|
45
|
+
Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return api_client_1.ApiError; } });
|
|
46
|
+
Object.defineProperty(exports, "CoreClient", { enumerable: true, get: function () { return api_client_1.ApiClient; } });
|
|
49
47
|
var types_1 = require("./types");
|
|
50
48
|
Object.defineProperty(exports, "OptiCmsVersion", { enumerable: true, get: function () { return types_1.OptiCmsVersion; } });
|
|
51
|
-
const
|
|
49
|
+
const api_client_2 = require("./api-client");
|
|
52
50
|
function createClient(config) {
|
|
53
|
-
return new
|
|
51
|
+
return new api_client_2.ApiClient(config);
|
|
54
52
|
}
|
|
55
53
|
var ContentRoots;
|
|
56
54
|
(function (ContentRoots) {
|
package/dist/version.json
CHANGED
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": "
|
|
5
|
+
"version": "6.0.0-pre2",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "./dist/index.js",
|
|
@@ -11,20 +11,29 @@
|
|
|
11
11
|
"./dist"
|
|
12
12
|
],
|
|
13
13
|
"devDependencies": {
|
|
14
|
+
"@hey-api/client-fetch": "^0.13.1",
|
|
15
|
+
"@hey-api/openapi-ts": "^0.78.2",
|
|
14
16
|
"@types/node": "^22.16.2",
|
|
15
|
-
"dotenv": "^
|
|
17
|
+
"dotenv": "^17.1.0",
|
|
18
|
+
"dotenv-expand": "^12.0.2",
|
|
19
|
+
"glob": "^11.0.3",
|
|
20
|
+
"rimraf": "^6.0.1",
|
|
21
|
+
"typescript": "^5.8.3"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@types/node": "^22.16.2",
|
|
25
|
+
"dotenv": "^17.1.0",
|
|
16
26
|
"glob": "^11.0.3",
|
|
17
27
|
"openapi-typescript-codegen": "^0.29.0",
|
|
18
28
|
"tslib": "^2.8.1",
|
|
19
29
|
"typescript": "^5.8.3"
|
|
20
30
|
},
|
|
21
31
|
"scripts": {
|
|
22
|
-
"clean": "
|
|
23
|
-
"prepare": "tsc --build",
|
|
32
|
+
"clean": "rimraf -g ./dist ./*.tsbuildinfo && rimraf -g ./openapi-ts*log",
|
|
33
|
+
"prepare": "tsc --build && yarn node scripts/copy-client.mjs",
|
|
24
34
|
"watch": "tsc --watch",
|
|
25
|
-
"rebuild": "yarn clean && yarn
|
|
26
|
-
"generate": "yarn
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
35
|
+
"rebuild": "yarn clean && yarn generate && tsc --build --force",
|
|
36
|
+
"generate": "yarn node scripts/create-client.mjs"
|
|
37
|
+
},
|
|
38
|
+
"stableVersion": "5.1.0"
|
|
30
39
|
}
|