@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.
Files changed (167) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +44 -0
  3. package/dist/client/CmsIntegrationApiClient.d.ts +22 -0
  4. package/dist/client/CmsIntegrationApiClient.js +34 -0
  5. package/dist/client/core/ApiError.d.ts +10 -0
  6. package/dist/client/core/ApiError.js +15 -0
  7. package/dist/client/core/ApiRequestOptions.d.ts +13 -0
  8. package/dist/client/core/ApiRequestOptions.js +2 -0
  9. package/dist/client/core/ApiResult.d.ts +7 -0
  10. package/dist/client/core/ApiResult.js +2 -0
  11. package/dist/client/core/BaseHttpRequest.d.ts +8 -0
  12. package/dist/client/core/BaseHttpRequest.js +9 -0
  13. package/dist/client/core/CancelablePromise.d.ts +20 -0
  14. package/dist/client/core/CancelablePromise.js +116 -0
  15. package/dist/client/core/FetchHttpRequest.d.ts +14 -0
  16. package/dist/client/core/FetchHttpRequest.js +20 -0
  17. package/dist/client/core/OpenAPI.d.ts +16 -0
  18. package/dist/client/core/OpenAPI.js +14 -0
  19. package/dist/client/core/request.d.ts +30 -0
  20. package/dist/client/core/request.js +294 -0
  21. package/dist/client/index.d.ts +76 -0
  22. package/dist/client/index.js +46 -0
  23. package/dist/client/models/BinaryProperty.d.ts +8 -0
  24. package/dist/client/models/BinaryProperty.js +2 -0
  25. package/dist/client/models/BooleanProperty.d.ts +5 -0
  26. package/dist/client/models/BooleanProperty.js +2 -0
  27. package/dist/client/models/Changeset.d.ts +26 -0
  28. package/dist/client/models/Changeset.js +2 -0
  29. package/dist/client/models/ChangesetItem.d.ts +11 -0
  30. package/dist/client/models/ChangesetItem.js +2 -0
  31. package/dist/client/models/ChangesetItemPage.d.ts +19 -0
  32. package/dist/client/models/ChangesetItemPage.js +2 -0
  33. package/dist/client/models/ChangesetPage.d.ts +19 -0
  34. package/dist/client/models/ChangesetPage.js +2 -0
  35. package/dist/client/models/ComponentListItem.d.ts +10 -0
  36. package/dist/client/models/ComponentListItem.js +2 -0
  37. package/dist/client/models/ComponentProperty.d.ts +10 -0
  38. package/dist/client/models/ComponentProperty.js +2 -0
  39. package/dist/client/models/ContentBaseType.d.ts +11 -0
  40. package/dist/client/models/ContentBaseType.js +19 -0
  41. package/dist/client/models/ContentComponent.d.ts +34 -0
  42. package/dist/client/models/ContentComponent.js +2 -0
  43. package/dist/client/models/ContentItem.d.ts +60 -0
  44. package/dist/client/models/ContentItem.js +2 -0
  45. package/dist/client/models/ContentItemListWithContentTypes.d.ts +27 -0
  46. package/dist/client/models/ContentItemListWithContentTypes.js +2 -0
  47. package/dist/client/models/ContentItemPage.d.ts +19 -0
  48. package/dist/client/models/ContentItemPage.js +2 -0
  49. package/dist/client/models/ContentItemWithContentTypes.d.ts +12 -0
  50. package/dist/client/models/ContentItemWithContentTypes.js +2 -0
  51. package/dist/client/models/ContentListItem.d.ts +14 -0
  52. package/dist/client/models/ContentListItem.js +2 -0
  53. package/dist/client/models/ContentLocaleInfo.d.ts +11 -0
  54. package/dist/client/models/ContentLocaleInfo.js +2 -0
  55. package/dist/client/models/ContentMetadata.d.ts +46 -0
  56. package/dist/client/models/ContentMetadata.js +2 -0
  57. package/dist/client/models/ContentMetadataPage.d.ts +19 -0
  58. package/dist/client/models/ContentMetadataPage.js +2 -0
  59. package/dist/client/models/ContentProperty.d.ts +14 -0
  60. package/dist/client/models/ContentProperty.js +2 -0
  61. package/dist/client/models/ContentReference.d.ts +17 -0
  62. package/dist/client/models/ContentReference.js +2 -0
  63. package/dist/client/models/ContentReferenceListItem.d.ts +14 -0
  64. package/dist/client/models/ContentReferenceListItem.js +2 -0
  65. package/dist/client/models/ContentReferenceProperty.d.ts +14 -0
  66. package/dist/client/models/ContentReferenceProperty.js +2 -0
  67. package/dist/client/models/ContentType.d.ts +79 -0
  68. package/dist/client/models/ContentType.js +2 -0
  69. package/dist/client/models/ContentTypeFeature.d.ts +10 -0
  70. package/dist/client/models/ContentTypeFeature.js +18 -0
  71. package/dist/client/models/ContentTypePage.d.ts +19 -0
  72. package/dist/client/models/ContentTypePage.js +2 -0
  73. package/dist/client/models/ContentTypeProperty.d.ts +47 -0
  74. package/dist/client/models/ContentTypeProperty.js +2 -0
  75. package/dist/client/models/ContentTypeUsage.d.ts +7 -0
  76. package/dist/client/models/ContentTypeUsage.js +15 -0
  77. package/dist/client/models/CopyContentOptions.d.ts +21 -0
  78. package/dist/client/models/CopyContentOptions.js +2 -0
  79. package/dist/client/models/DateTimeListItem.d.ts +14 -0
  80. package/dist/client/models/DateTimeListItem.js +2 -0
  81. package/dist/client/models/DateTimeProperty.d.ts +14 -0
  82. package/dist/client/models/DateTimeProperty.js +2 -0
  83. package/dist/client/models/DoubleEnumerationSettings.d.ts +9 -0
  84. package/dist/client/models/DoubleEnumerationSettings.js +2 -0
  85. package/dist/client/models/FloatListItem.d.ts +16 -0
  86. package/dist/client/models/FloatListItem.js +2 -0
  87. package/dist/client/models/FloatProperty.d.ts +16 -0
  88. package/dist/client/models/FloatProperty.js +2 -0
  89. package/dist/client/models/ImageDescriptor.d.ts +17 -0
  90. package/dist/client/models/ImageDescriptor.js +2 -0
  91. package/dist/client/models/ImportPackageMessage.d.ts +17 -0
  92. package/dist/client/models/ImportPackageMessage.js +2 -0
  93. package/dist/client/models/ImportPackageResult.d.ts +22 -0
  94. package/dist/client/models/ImportPackageResult.js +2 -0
  95. package/dist/client/models/IndexingType.d.ts +8 -0
  96. package/dist/client/models/IndexingType.js +16 -0
  97. package/dist/client/models/Int32EnumerationSettings.d.ts +9 -0
  98. package/dist/client/models/Int32EnumerationSettings.js +2 -0
  99. package/dist/client/models/IntegerListItem.d.ts +16 -0
  100. package/dist/client/models/IntegerListItem.js +2 -0
  101. package/dist/client/models/IntegerProperty.d.ts +16 -0
  102. package/dist/client/models/IntegerProperty.js +2 -0
  103. package/dist/client/models/JsonStringProperty.d.ts +5 -0
  104. package/dist/client/models/JsonStringProperty.js +2 -0
  105. package/dist/client/models/ListProperty.d.ts +26 -0
  106. package/dist/client/models/ListProperty.js +2 -0
  107. package/dist/client/models/ListPropertyItem.d.ts +11 -0
  108. package/dist/client/models/ListPropertyItem.js +2 -0
  109. package/dist/client/models/LocaleStatus.d.ts +7 -0
  110. package/dist/client/models/LocaleStatus.js +15 -0
  111. package/dist/client/models/Manifest.d.ts +19 -0
  112. package/dist/client/models/Manifest.js +2 -0
  113. package/dist/client/models/OauthToken.d.ts +18 -0
  114. package/dist/client/models/OauthToken.js +2 -0
  115. package/dist/client/models/OauthTokenError.d.ts +13 -0
  116. package/dist/client/models/OauthTokenError.js +2 -0
  117. package/dist/client/models/OauthTokenRequest.d.ts +21 -0
  118. package/dist/client/models/OauthTokenRequest.js +2 -0
  119. package/dist/client/models/PackageJob.d.ts +28 -0
  120. package/dist/client/models/PackageJob.js +2 -0
  121. package/dist/client/models/PackageJobMessage.d.ts +17 -0
  122. package/dist/client/models/PackageJobMessage.js +2 -0
  123. package/dist/client/models/PackageJobStatus.d.ts +4 -0
  124. package/dist/client/models/PackageJobStatus.js +2 -0
  125. package/dist/client/models/ProblemDetails.d.ts +1 -0
  126. package/dist/client/models/ProblemDetails.js +2 -0
  127. package/dist/client/models/PropertyDataType.d.ts +18 -0
  128. package/dist/client/models/PropertyDataType.js +26 -0
  129. package/dist/client/models/PropertyFormat.d.ts +34 -0
  130. package/dist/client/models/PropertyFormat.js +2 -0
  131. package/dist/client/models/PropertyFormatPage.d.ts +19 -0
  132. package/dist/client/models/PropertyFormatPage.js +2 -0
  133. package/dist/client/models/PropertyGroup.d.ts +21 -0
  134. package/dist/client/models/PropertyGroup.js +2 -0
  135. package/dist/client/models/PropertyGroupPage.d.ts +19 -0
  136. package/dist/client/models/PropertyGroupPage.js +2 -0
  137. package/dist/client/models/StringEnumerationSettings.d.ts +9 -0
  138. package/dist/client/models/StringEnumerationSettings.js +2 -0
  139. package/dist/client/models/StringListItem.d.ts +14 -0
  140. package/dist/client/models/StringListItem.js +2 -0
  141. package/dist/client/models/StringProperty.d.ts +14 -0
  142. package/dist/client/models/StringProperty.js +2 -0
  143. package/dist/client/models/UrlListItem.d.ts +5 -0
  144. package/dist/client/models/UrlListItem.js +2 -0
  145. package/dist/client/models/UrlProperty.d.ts +5 -0
  146. package/dist/client/models/UrlProperty.js +2 -0
  147. package/dist/client/models/VersionStatus.d.ts +12 -0
  148. package/dist/client/models/VersionStatus.js +20 -0
  149. package/dist/client/services/ChangesetsService.d.ts +105 -0
  150. package/dist/client/services/ChangesetsService.js +239 -0
  151. package/dist/client/services/ContentService.d.ts +172 -0
  152. package/dist/client/services/ContentService.js +409 -0
  153. package/dist/client/services/ContentTypesService.d.ts +66 -0
  154. package/dist/client/services/ContentTypesService.js +149 -0
  155. package/dist/client/services/OauthService.d.ts +17 -0
  156. package/dist/client/services/OauthService.js +28 -0
  157. package/dist/client/services/PackagesService.d.ts +41 -0
  158. package/dist/client/services/PackagesService.js +80 -0
  159. package/dist/client/services/PropertyFormatsService.d.ts +26 -0
  160. package/dist/client/services/PropertyFormatsService.js +53 -0
  161. package/dist/client/services/PropertyGroupsService.d.ts +61 -0
  162. package/dist/client/services/PropertyGroupsService.js +135 -0
  163. package/dist/config.d.ts +8 -0
  164. package/dist/config.js +36 -0
  165. package/dist/index.d.ts +15 -0
  166. package/dist/index.js +95 -0
  167. package/package.json +27 -0
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Remko Jantzen
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](./LICENSE)
2
+ ![Static Badge](https://img.shields.io/badge/Optimizely-Content_Management_System-blue?cacheSeconds=7200)
3
+
4
+ # Optimizely CMS - Integration API Client <!-- omit in toc -->
5
+ A Javascript client for the Integration API provided by the Optimizely CMS. It wraps the [Optimizely CMS SaaS Core REST API](https://docs.developers.optimizely.com/content-management-system/v1.0.0-SaaS-Core/reference/introduction-to-the-cms-content-api).
6
+
7
+ ## Installation
8
+ This package is provides as part of one of the mono-repo style demo sites. Install this package by using a mono-repo style structure for your project and copying this package into your mono-repo.
9
+
10
+ ## Requirements
11
+ This package works across browser and modern Node.JS environments, which provide an implementation for the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). The library has been tested with the Fetch API implementation in [Node.JS v18](https://nodejs.org/dist/latest-v20.x/docs/api/globals.html#fetch) and above.
12
+
13
+ ## Usage
14
+ ```typescript
15
+ // Import the Client
16
+ import createClient, { ContentRoots } from '@remkoj/optimizely-cms-integration-api'
17
+
18
+ // Create an instance of the client
19
+ const client = createClient({
20
+ base: "https://example.com",
21
+ clientId: "apiClientID",
22
+ clientSecret: "apiClientSecret"
23
+ });
24
+
25
+ // Start using client
26
+ client.content.contentListItems(ContentRoots.SystemRoot).then(response => {
27
+ const items = response.items
28
+ items?.map(item => {
29
+ // Do something with the item
30
+ })
31
+ })
32
+ ```
33
+
34
+ ## Alternative configuration for Node.JS
35
+ The configuration object for the `createClient()` method is optional, if it is omitted, the configuration will be read from the environment variables.
36
+
37
+ ## Configuration options
38
+ The following configuration options are available for
39
+ | Environment variable | Configuration key | Required | Usage |
40
+ | --- | --- | --- | --- |
41
+ | OPTIMIZELY_CMS_URL | base | yes | The URL where the CMS is available |
42
+ | OPTIMIZELY_CMS_CLIENT_ID | clientId | yes | The API Client ID, as configured within the CMS |
43
+ | OPTIMIZELY_CMS_CLIENT_SECRET | clientSecret | yes | The API Client Secret as generated by the CMS when creating the client |
44
+ | OPTIMIZELY_CMS_USER_ID | actAs | no | The username of the CMS user to impersonate |
@@ -0,0 +1,22 @@
1
+ import type { BaseHttpRequest } from './core/BaseHttpRequest';
2
+ import type { OpenAPIConfig } from './core/OpenAPI';
3
+ import { ChangesetsService } from './services/ChangesetsService';
4
+ import { ContentService } from './services/ContentService';
5
+ import { ContentTypesService } from './services/ContentTypesService';
6
+ import { OauthService } from './services/OauthService';
7
+ import { PackagesService } from './services/PackagesService';
8
+ import { PropertyFormatsService } from './services/PropertyFormatsService';
9
+ import { PropertyGroupsService } from './services/PropertyGroupsService';
10
+ type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;
11
+ export declare class CmsIntegrationApiClient {
12
+ readonly changesets: ChangesetsService;
13
+ readonly content: ContentService;
14
+ readonly contentTypes: ContentTypesService;
15
+ readonly oauth: OauthService;
16
+ readonly packages: PackagesService;
17
+ readonly propertyFormats: PropertyFormatsService;
18
+ readonly propertyGroups: PropertyGroupsService;
19
+ readonly request: BaseHttpRequest;
20
+ constructor(config?: Partial<OpenAPIConfig>, HttpRequest?: HttpRequestConstructor);
21
+ }
22
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CmsIntegrationApiClient = void 0;
4
+ const FetchHttpRequest_1 = require("./core/FetchHttpRequest");
5
+ const ChangesetsService_1 = require("./services/ChangesetsService");
6
+ const ContentService_1 = require("./services/ContentService");
7
+ const ContentTypesService_1 = require("./services/ContentTypesService");
8
+ const OauthService_1 = require("./services/OauthService");
9
+ const PackagesService_1 = require("./services/PackagesService");
10
+ const PropertyFormatsService_1 = require("./services/PropertyFormatsService");
11
+ const PropertyGroupsService_1 = require("./services/PropertyGroupsService");
12
+ class CmsIntegrationApiClient {
13
+ constructor(config, HttpRequest = FetchHttpRequest_1.FetchHttpRequest) {
14
+ this.request = new HttpRequest({
15
+ BASE: config?.BASE ?? '/_cms/preview2',
16
+ VERSION: config?.VERSION ?? 'preview2',
17
+ WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
18
+ CREDENTIALS: config?.CREDENTIALS ?? 'include',
19
+ TOKEN: config?.TOKEN,
20
+ USERNAME: config?.USERNAME,
21
+ PASSWORD: config?.PASSWORD,
22
+ HEADERS: config?.HEADERS,
23
+ ENCODE_PATH: config?.ENCODE_PATH,
24
+ });
25
+ this.changesets = new ChangesetsService_1.ChangesetsService(this.request);
26
+ this.content = new ContentService_1.ContentService(this.request);
27
+ this.contentTypes = new ContentTypesService_1.ContentTypesService(this.request);
28
+ this.oauth = new OauthService_1.OauthService(this.request);
29
+ this.packages = new PackagesService_1.PackagesService(this.request);
30
+ this.propertyFormats = new PropertyFormatsService_1.PropertyFormatsService(this.request);
31
+ this.propertyGroups = new PropertyGroupsService_1.PropertyGroupsService(this.request);
32
+ }
33
+ }
34
+ exports.CmsIntegrationApiClient = CmsIntegrationApiClient;
@@ -0,0 +1,10 @@
1
+ import type { ApiRequestOptions } from './ApiRequestOptions';
2
+ import type { ApiResult } from './ApiResult';
3
+ export declare class ApiError extends Error {
4
+ readonly url: string;
5
+ readonly status: number;
6
+ readonly statusText: string;
7
+ readonly body: any;
8
+ readonly request: ApiRequestOptions;
9
+ constructor(request: ApiRequestOptions, response: ApiResult, message: string);
10
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiError = void 0;
4
+ class ApiError extends Error {
5
+ constructor(request, response, message) {
6
+ super(message);
7
+ this.name = 'ApiError';
8
+ this.url = response.url;
9
+ this.status = response.status;
10
+ this.statusText = response.statusText;
11
+ this.body = response.body;
12
+ this.request = request;
13
+ }
14
+ }
15
+ exports.ApiError = ApiError;
@@ -0,0 +1,13 @@
1
+ export type ApiRequestOptions = {
2
+ readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
3
+ readonly url: string;
4
+ readonly path?: Record<string, any>;
5
+ readonly cookies?: Record<string, any>;
6
+ readonly headers?: Record<string, any>;
7
+ readonly query?: Record<string, any>;
8
+ readonly formData?: Record<string, any>;
9
+ readonly body?: any;
10
+ readonly mediaType?: string;
11
+ readonly responseHeader?: string;
12
+ readonly errors?: Record<number, string>;
13
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export type ApiResult = {
2
+ readonly url: string;
3
+ readonly ok: boolean;
4
+ readonly status: number;
5
+ readonly statusText: string;
6
+ readonly body: any;
7
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import type { ApiRequestOptions } from './ApiRequestOptions';
2
+ import type { CancelablePromise } from './CancelablePromise';
3
+ import type { OpenAPIConfig } from './OpenAPI';
4
+ export declare abstract class BaseHttpRequest {
5
+ readonly config: OpenAPIConfig;
6
+ constructor(config: OpenAPIConfig);
7
+ abstract request<T>(options: ApiRequestOptions): CancelablePromise<T>;
8
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseHttpRequest = void 0;
4
+ class BaseHttpRequest {
5
+ constructor(config) {
6
+ this.config = config;
7
+ }
8
+ }
9
+ exports.BaseHttpRequest = BaseHttpRequest;
@@ -0,0 +1,20 @@
1
+ export declare class CancelError extends Error {
2
+ constructor(message: string);
3
+ get isCancelled(): boolean;
4
+ }
5
+ export interface OnCancel {
6
+ readonly isResolved: boolean;
7
+ readonly isRejected: boolean;
8
+ readonly isCancelled: boolean;
9
+ (cancelHandler: () => void): void;
10
+ }
11
+ export declare class CancelablePromise<T> implements Promise<T> {
12
+ #private;
13
+ constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, onCancel: OnCancel) => void);
14
+ get [Symbol.toStringTag](): string;
15
+ then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
16
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
17
+ finally(onFinally?: (() => void) | null): Promise<T>;
18
+ cancel(): void;
19
+ get isCancelled(): boolean;
20
+ }
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _CancelablePromise_isResolved, _CancelablePromise_isRejected, _CancelablePromise_isCancelled, _CancelablePromise_cancelHandlers, _CancelablePromise_promise, _CancelablePromise_resolve, _CancelablePromise_reject;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CancelablePromise = exports.CancelError = void 0;
16
+ /* generated using openapi-typescript-codegen -- do not edit */
17
+ /* istanbul ignore file */
18
+ /* tslint:disable */
19
+ /* eslint-disable */
20
+ class CancelError extends Error {
21
+ constructor(message) {
22
+ super(message);
23
+ this.name = 'CancelError';
24
+ }
25
+ get isCancelled() {
26
+ return true;
27
+ }
28
+ }
29
+ exports.CancelError = CancelError;
30
+ class CancelablePromise {
31
+ constructor(executor) {
32
+ _CancelablePromise_isResolved.set(this, void 0);
33
+ _CancelablePromise_isRejected.set(this, void 0);
34
+ _CancelablePromise_isCancelled.set(this, void 0);
35
+ _CancelablePromise_cancelHandlers.set(this, void 0);
36
+ _CancelablePromise_promise.set(this, void 0);
37
+ _CancelablePromise_resolve.set(this, void 0);
38
+ _CancelablePromise_reject.set(this, void 0);
39
+ __classPrivateFieldSet(this, _CancelablePromise_isResolved, false, "f");
40
+ __classPrivateFieldSet(this, _CancelablePromise_isRejected, false, "f");
41
+ __classPrivateFieldSet(this, _CancelablePromise_isCancelled, false, "f");
42
+ __classPrivateFieldSet(this, _CancelablePromise_cancelHandlers, [], "f");
43
+ __classPrivateFieldSet(this, _CancelablePromise_promise, new Promise((resolve, reject) => {
44
+ __classPrivateFieldSet(this, _CancelablePromise_resolve, resolve, "f");
45
+ __classPrivateFieldSet(this, _CancelablePromise_reject, reject, "f");
46
+ const onResolve = (value) => {
47
+ if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
48
+ return;
49
+ }
50
+ __classPrivateFieldSet(this, _CancelablePromise_isResolved, true, "f");
51
+ if (__classPrivateFieldGet(this, _CancelablePromise_resolve, "f"))
52
+ __classPrivateFieldGet(this, _CancelablePromise_resolve, "f").call(this, value);
53
+ };
54
+ const onReject = (reason) => {
55
+ if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
56
+ return;
57
+ }
58
+ __classPrivateFieldSet(this, _CancelablePromise_isRejected, true, "f");
59
+ if (__classPrivateFieldGet(this, _CancelablePromise_reject, "f"))
60
+ __classPrivateFieldGet(this, _CancelablePromise_reject, "f").call(this, reason);
61
+ };
62
+ const onCancel = (cancelHandler) => {
63
+ if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
64
+ return;
65
+ }
66
+ __classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f").push(cancelHandler);
67
+ };
68
+ Object.defineProperty(onCancel, 'isResolved', {
69
+ get: () => __classPrivateFieldGet(this, _CancelablePromise_isResolved, "f"),
70
+ });
71
+ Object.defineProperty(onCancel, 'isRejected', {
72
+ get: () => __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f"),
73
+ });
74
+ Object.defineProperty(onCancel, 'isCancelled', {
75
+ get: () => __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f"),
76
+ });
77
+ return executor(onResolve, onReject, onCancel);
78
+ }), "f");
79
+ }
80
+ get [(_CancelablePromise_isResolved = new WeakMap(), _CancelablePromise_isRejected = new WeakMap(), _CancelablePromise_isCancelled = new WeakMap(), _CancelablePromise_cancelHandlers = new WeakMap(), _CancelablePromise_promise = new WeakMap(), _CancelablePromise_resolve = new WeakMap(), _CancelablePromise_reject = new WeakMap(), Symbol.toStringTag)]() {
81
+ return "Cancellable Promise";
82
+ }
83
+ then(onFulfilled, onRejected) {
84
+ return __classPrivateFieldGet(this, _CancelablePromise_promise, "f").then(onFulfilled, onRejected);
85
+ }
86
+ catch(onRejected) {
87
+ return __classPrivateFieldGet(this, _CancelablePromise_promise, "f").catch(onRejected);
88
+ }
89
+ finally(onFinally) {
90
+ return __classPrivateFieldGet(this, _CancelablePromise_promise, "f").finally(onFinally);
91
+ }
92
+ cancel() {
93
+ if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
94
+ return;
95
+ }
96
+ __classPrivateFieldSet(this, _CancelablePromise_isCancelled, true, "f");
97
+ if (__classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f").length) {
98
+ try {
99
+ for (const cancelHandler of __classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f")) {
100
+ cancelHandler();
101
+ }
102
+ }
103
+ catch (error) {
104
+ console.warn('Cancellation threw an error', error);
105
+ return;
106
+ }
107
+ }
108
+ __classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f").length = 0;
109
+ if (__classPrivateFieldGet(this, _CancelablePromise_reject, "f"))
110
+ __classPrivateFieldGet(this, _CancelablePromise_reject, "f").call(this, new CancelError('Request aborted'));
111
+ }
112
+ get isCancelled() {
113
+ return __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f");
114
+ }
115
+ }
116
+ exports.CancelablePromise = CancelablePromise;
@@ -0,0 +1,14 @@
1
+ import type { ApiRequestOptions } from './ApiRequestOptions';
2
+ import { BaseHttpRequest } from './BaseHttpRequest';
3
+ import type { CancelablePromise } from './CancelablePromise';
4
+ import type { OpenAPIConfig } from './OpenAPI';
5
+ export declare class FetchHttpRequest extends BaseHttpRequest {
6
+ constructor(config: OpenAPIConfig);
7
+ /**
8
+ * Request method
9
+ * @param options The request options from the service
10
+ * @returns CancelablePromise<T>
11
+ * @throws ApiError
12
+ */
13
+ request<T>(options: ApiRequestOptions): CancelablePromise<T>;
14
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FetchHttpRequest = void 0;
4
+ const BaseHttpRequest_1 = require("./BaseHttpRequest");
5
+ const request_1 = require("./request");
6
+ class FetchHttpRequest extends BaseHttpRequest_1.BaseHttpRequest {
7
+ constructor(config) {
8
+ super(config);
9
+ }
10
+ /**
11
+ * Request method
12
+ * @param options The request options from the service
13
+ * @returns CancelablePromise<T>
14
+ * @throws ApiError
15
+ */
16
+ request(options) {
17
+ return (0, request_1.request)(this.config, options);
18
+ }
19
+ }
20
+ exports.FetchHttpRequest = FetchHttpRequest;
@@ -0,0 +1,16 @@
1
+ import type { ApiRequestOptions } from './ApiRequestOptions';
2
+ type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
3
+ type Headers = Record<string, string>;
4
+ export type OpenAPIConfig = {
5
+ BASE: string;
6
+ VERSION: string;
7
+ WITH_CREDENTIALS: boolean;
8
+ CREDENTIALS: 'include' | 'omit' | 'same-origin';
9
+ TOKEN?: string | Resolver<string> | undefined;
10
+ USERNAME?: string | Resolver<string> | undefined;
11
+ PASSWORD?: string | Resolver<string> | undefined;
12
+ HEADERS?: Headers | Resolver<Headers> | undefined;
13
+ ENCODE_PATH?: ((path: string) => string) | undefined;
14
+ };
15
+ export declare const OpenAPI: OpenAPIConfig;
16
+ export {};
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenAPI = void 0;
4
+ exports.OpenAPI = {
5
+ BASE: '/_cms/preview2',
6
+ VERSION: 'preview2',
7
+ WITH_CREDENTIALS: false,
8
+ CREDENTIALS: 'include',
9
+ TOKEN: undefined,
10
+ USERNAME: undefined,
11
+ PASSWORD: undefined,
12
+ HEADERS: undefined,
13
+ ENCODE_PATH: undefined,
14
+ };
@@ -0,0 +1,30 @@
1
+ import type { ApiRequestOptions } from './ApiRequestOptions';
2
+ import type { ApiResult } from './ApiResult';
3
+ import { CancelablePromise } from './CancelablePromise';
4
+ import type { OnCancel } from './CancelablePromise';
5
+ import type { OpenAPIConfig } from './OpenAPI';
6
+ export declare const isDefined: <T>(value: T | null | undefined) => value is Exclude<T, null | undefined>;
7
+ export declare const isString: (value: any) => value is string;
8
+ export declare const isStringWithValue: (value: any) => value is string;
9
+ export declare const isBlob: (value: any) => value is Blob;
10
+ export declare const isFormData: (value: any) => value is FormData;
11
+ export declare const base64: (str: string) => string;
12
+ export declare const getQueryString: (params: Record<string, any>) => string;
13
+ export declare const getFormData: (options: ApiRequestOptions) => FormData | undefined;
14
+ type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
15
+ export declare const resolve: <T>(options: ApiRequestOptions, resolver?: T | Resolver<T>) => Promise<T | undefined>;
16
+ export declare const getHeaders: (config: OpenAPIConfig, options: ApiRequestOptions) => Promise<Headers>;
17
+ export declare const getRequestBody: (options: ApiRequestOptions) => any;
18
+ export declare const sendRequest: (config: OpenAPIConfig, options: ApiRequestOptions, url: string, body: any, formData: FormData | undefined, headers: Headers, onCancel: OnCancel) => Promise<Response>;
19
+ export declare const getResponseHeader: (response: Response, responseHeader?: string) => string | undefined;
20
+ export declare const getResponseBody: (response: Response) => Promise<any>;
21
+ export declare const catchErrorCodes: (options: ApiRequestOptions, result: ApiResult) => void;
22
+ /**
23
+ * Request method
24
+ * @param config The OpenAPI configuration object
25
+ * @param options The request options from the service
26
+ * @returns CancelablePromise<T>
27
+ * @throws ApiError
28
+ */
29
+ export declare const request: <T>(config: OpenAPIConfig, options: ApiRequestOptions) => CancelablePromise<T>;
30
+ export {};