@remkoj/optimizely-cms-api 6.0.0-pre2 → 6.0.0-pre4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/dist/api-client.d.ts +1 -1
  2. package/dist/client-config.js +1 -1
  3. package/dist/config.d.ts +4 -0
  4. package/dist/config.js +39 -1
  5. package/dist/getaccesstoken.js +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.js +3 -1
  8. package/package.json +1 -1
  9. package/dist/client/CmsIntegrationApiClient.d.ts +0 -22
  10. package/dist/client/CmsIntegrationApiClient.js +0 -34
  11. package/dist/client/core/ApiError.d.ts +0 -10
  12. package/dist/client/core/ApiError.js +0 -15
  13. package/dist/client/core/ApiRequestOptions.d.ts +0 -13
  14. package/dist/client/core/ApiRequestOptions.js +0 -2
  15. package/dist/client/core/ApiResult.d.ts +0 -7
  16. package/dist/client/core/ApiResult.js +0 -2
  17. package/dist/client/core/BaseHttpRequest.d.ts +0 -8
  18. package/dist/client/core/BaseHttpRequest.js +0 -9
  19. package/dist/client/core/CancelablePromise.d.ts +0 -20
  20. package/dist/client/core/CancelablePromise.js +0 -116
  21. package/dist/client/core/FetchHttpRequest.d.ts +0 -14
  22. package/dist/client/core/FetchHttpRequest.js +0 -20
  23. package/dist/client/core/OpenAPI.d.ts +0 -16
  24. package/dist/client/core/OpenAPI.js +0 -14
  25. package/dist/client/core/request.d.ts +0 -30
  26. package/dist/client/core/request.js +0 -294
  27. package/dist/client/models/BinaryProperty.d.ts +0 -8
  28. package/dist/client/models/BinaryProperty.js +0 -2
  29. package/dist/client/models/BooleanProperty.d.ts +0 -5
  30. package/dist/client/models/BooleanProperty.js +0 -2
  31. package/dist/client/models/Changeset.d.ts +0 -26
  32. package/dist/client/models/Changeset.js +0 -2
  33. package/dist/client/models/ChangesetItem.d.ts +0 -11
  34. package/dist/client/models/ChangesetItem.js +0 -2
  35. package/dist/client/models/ChangesetItemPage.d.ts +0 -19
  36. package/dist/client/models/ChangesetItemPage.js +0 -2
  37. package/dist/client/models/ChangesetPage.d.ts +0 -19
  38. package/dist/client/models/ChangesetPage.js +0 -2
  39. package/dist/client/models/ComponentListItem.d.ts +0 -10
  40. package/dist/client/models/ComponentListItem.js +0 -2
  41. package/dist/client/models/ComponentProperty.d.ts +0 -10
  42. package/dist/client/models/ComponentProperty.js +0 -2
  43. package/dist/client/models/CompositionBehavior.d.ts +0 -7
  44. package/dist/client/models/CompositionBehavior.js +0 -15
  45. package/dist/client/models/ContentBaseType.d.ts +0 -14
  46. package/dist/client/models/ContentBaseType.js +0 -22
  47. package/dist/client/models/ContentComponent.d.ts +0 -30
  48. package/dist/client/models/ContentComponent.js +0 -2
  49. package/dist/client/models/ContentItem.d.ts +0 -60
  50. package/dist/client/models/ContentItem.js +0 -2
  51. package/dist/client/models/ContentItemListWithContentTypes.d.ts +0 -27
  52. package/dist/client/models/ContentItemListWithContentTypes.js +0 -2
  53. package/dist/client/models/ContentItemPage.d.ts +0 -19
  54. package/dist/client/models/ContentItemPage.js +0 -2
  55. package/dist/client/models/ContentItemWithContentTypes.d.ts +0 -12
  56. package/dist/client/models/ContentItemWithContentTypes.js +0 -2
  57. package/dist/client/models/ContentListItem.d.ts +0 -14
  58. package/dist/client/models/ContentListItem.js +0 -2
  59. package/dist/client/models/ContentLocaleInfo.d.ts +0 -19
  60. package/dist/client/models/ContentLocaleInfo.js +0 -2
  61. package/dist/client/models/ContentMetadata.d.ts +0 -38
  62. package/dist/client/models/ContentMetadata.js +0 -2
  63. package/dist/client/models/ContentMetadataPage.d.ts +0 -19
  64. package/dist/client/models/ContentMetadataPage.js +0 -2
  65. package/dist/client/models/ContentProperty.d.ts +0 -14
  66. package/dist/client/models/ContentProperty.js +0 -2
  67. package/dist/client/models/ContentReference.d.ts +0 -17
  68. package/dist/client/models/ContentReference.js +0 -2
  69. package/dist/client/models/ContentReferenceListItem.d.ts +0 -14
  70. package/dist/client/models/ContentReferenceListItem.js +0 -2
  71. package/dist/client/models/ContentReferenceProperty.d.ts +0 -14
  72. package/dist/client/models/ContentReferenceProperty.js +0 -2
  73. package/dist/client/models/ContentType.d.ts +0 -84
  74. package/dist/client/models/ContentType.js +0 -2
  75. package/dist/client/models/ContentTypeFeature.d.ts +0 -10
  76. package/dist/client/models/ContentTypeFeature.js +0 -18
  77. package/dist/client/models/ContentTypePage.d.ts +0 -19
  78. package/dist/client/models/ContentTypePage.js +0 -2
  79. package/dist/client/models/ContentTypeProperty.d.ts +0 -47
  80. package/dist/client/models/ContentTypeProperty.js +0 -2
  81. package/dist/client/models/ContentTypeUsage.d.ts +0 -7
  82. package/dist/client/models/ContentTypeUsage.js +0 -15
  83. package/dist/client/models/CopyContentOptions.d.ts +0 -21
  84. package/dist/client/models/CopyContentOptions.js +0 -2
  85. package/dist/client/models/DateTimeListItem.d.ts +0 -14
  86. package/dist/client/models/DateTimeListItem.js +0 -2
  87. package/dist/client/models/DateTimeProperty.d.ts +0 -14
  88. package/dist/client/models/DateTimeProperty.js +0 -2
  89. package/dist/client/models/DisplaySetting.d.ts +0 -22
  90. package/dist/client/models/DisplaySetting.js +0 -2
  91. package/dist/client/models/DisplaySettingChoice.d.ts +0 -13
  92. package/dist/client/models/DisplaySettingChoice.js +0 -2
  93. package/dist/client/models/DisplayTemplate.d.ts +0 -49
  94. package/dist/client/models/DisplayTemplate.js +0 -2
  95. package/dist/client/models/DisplayTemplatePage.d.ts +0 -19
  96. package/dist/client/models/DisplayTemplatePage.js +0 -2
  97. package/dist/client/models/DoubleEnumerationSettings.d.ts +0 -10
  98. package/dist/client/models/DoubleEnumerationSettings.js +0 -2
  99. package/dist/client/models/DoubleEnumerationValue.d.ts +0 -13
  100. package/dist/client/models/DoubleEnumerationValue.js +0 -2
  101. package/dist/client/models/FloatListItem.d.ts +0 -16
  102. package/dist/client/models/FloatListItem.js +0 -2
  103. package/dist/client/models/FloatProperty.d.ts +0 -16
  104. package/dist/client/models/FloatProperty.js +0 -2
  105. package/dist/client/models/ImageDescriptor.d.ts +0 -17
  106. package/dist/client/models/ImageDescriptor.js +0 -2
  107. package/dist/client/models/IndexingType.d.ts +0 -8
  108. package/dist/client/models/IndexingType.js +0 -16
  109. package/dist/client/models/Int32EnumerationSettings.d.ts +0 -10
  110. package/dist/client/models/Int32EnumerationSettings.js +0 -2
  111. package/dist/client/models/Int32EnumerationValue.d.ts +0 -13
  112. package/dist/client/models/Int32EnumerationValue.js +0 -2
  113. package/dist/client/models/IntegerListItem.d.ts +0 -16
  114. package/dist/client/models/IntegerListItem.js +0 -2
  115. package/dist/client/models/IntegerProperty.d.ts +0 -16
  116. package/dist/client/models/IntegerProperty.js +0 -2
  117. package/dist/client/models/JsonStringProperty.d.ts +0 -5
  118. package/dist/client/models/JsonStringProperty.js +0 -2
  119. package/dist/client/models/ListProperty.d.ts +0 -26
  120. package/dist/client/models/ListProperty.js +0 -2
  121. package/dist/client/models/ListPropertyItem.d.ts +0 -11
  122. package/dist/client/models/ListPropertyItem.js +0 -2
  123. package/dist/client/models/LocaleStatus.d.ts +0 -7
  124. package/dist/client/models/LocaleStatus.js +0 -15
  125. package/dist/client/models/OauthToken.d.ts +0 -18
  126. package/dist/client/models/OauthToken.js +0 -2
  127. package/dist/client/models/OauthTokenError.d.ts +0 -13
  128. package/dist/client/models/OauthTokenError.js +0 -2
  129. package/dist/client/models/OauthTokenRequest.d.ts +0 -21
  130. package/dist/client/models/OauthTokenRequest.js +0 -2
  131. package/dist/client/models/ProblemDetails.d.ts +0 -1
  132. package/dist/client/models/ProblemDetails.js +0 -2
  133. package/dist/client/models/PropertyDataType.d.ts +0 -18
  134. package/dist/client/models/PropertyDataType.js +0 -26
  135. package/dist/client/models/PropertyFormat.d.ts +0 -37
  136. package/dist/client/models/PropertyFormat.js +0 -2
  137. package/dist/client/models/PropertyFormatPage.d.ts +0 -19
  138. package/dist/client/models/PropertyFormatPage.js +0 -2
  139. package/dist/client/models/PropertyGroup.d.ts +0 -21
  140. package/dist/client/models/PropertyGroup.js +0 -2
  141. package/dist/client/models/PropertyGroupPage.d.ts +0 -19
  142. package/dist/client/models/PropertyGroupPage.js +0 -2
  143. package/dist/client/models/StringEnumerationSettings.d.ts +0 -10
  144. package/dist/client/models/StringEnumerationSettings.js +0 -2
  145. package/dist/client/models/StringEnumerationValue.d.ts +0 -13
  146. package/dist/client/models/StringEnumerationValue.js +0 -2
  147. package/dist/client/models/StringListItem.d.ts +0 -20
  148. package/dist/client/models/StringListItem.js +0 -2
  149. package/dist/client/models/StringProperty.d.ts +0 -20
  150. package/dist/client/models/StringProperty.js +0 -2
  151. package/dist/client/models/UrlListItem.d.ts +0 -5
  152. package/dist/client/models/UrlListItem.js +0 -2
  153. package/dist/client/models/UrlProperty.d.ts +0 -5
  154. package/dist/client/models/UrlProperty.js +0 -2
  155. package/dist/client/models/VersionStatus.d.ts +0 -12
  156. package/dist/client/models/VersionStatus.js +0 -20
  157. package/dist/client/services/ChangesetsService.d.ts +0 -105
  158. package/dist/client/services/ChangesetsService.js +0 -239
  159. package/dist/client/services/ContentService.d.ts +0 -172
  160. package/dist/client/services/ContentService.js +0 -409
  161. package/dist/client/services/ContentTypesService.d.ts +0 -66
  162. package/dist/client/services/ContentTypesService.js +0 -149
  163. package/dist/client/services/DisplayTemplatesService.d.ts +0 -60
  164. package/dist/client/services/DisplayTemplatesService.js +0 -135
  165. package/dist/client/services/OauthService.d.ts +0 -17
  166. package/dist/client/services/OauthService.js +0 -28
  167. package/dist/client/services/PropertyFormatsService.d.ts +0 -26
  168. package/dist/client/services/PropertyFormatsService.js +0 -53
  169. package/dist/client/services/PropertyGroupsService.d.ts +0 -61
  170. package/dist/client/services/PropertyGroupsService.js +0 -135
@@ -2,7 +2,7 @@ import * as Operations from './client/sdk.gen';
2
2
  import { type CmsIntegrationApiOptions } from "./config";
3
3
  import { type InstanceApiVersionInfo, OptiCmsVersion } from "./types";
4
4
  import { createClient, type RequestResult, type ResponseStyle } from './client/client';
5
- import { type CreateClientConfig } from './client/client.gen';
5
+ import type { CreateClientConfig } from './client/client.gen';
6
6
  type OperationsType = {
7
7
  -readonly [KT in keyof typeof Operations]: (typeof Operations)[KT];
8
8
  };
@@ -4,7 +4,7 @@ exports.createClientConfig = void 0;
4
4
  const config_1 = require("./config");
5
5
  const getaccesstoken_1 = require("./getaccesstoken");
6
6
  const createClientConfig = (config) => {
7
- const envConfig = (0, config_1.getCmsIntegrationApiConfigFromEnvironment)();
7
+ const envConfig = (0, config_1.readPartialEnvConfig)();
8
8
  const baseUrl = envConfig.base.href;
9
9
  const newClientConfig = {
10
10
  baseUrl,
package/dist/config.d.ts CHANGED
@@ -10,4 +10,8 @@ export type CmsIntegrationApiOptions = {
10
10
  */
11
11
  cmsVersion?: OptiCmsVersion;
12
12
  };
13
+ type ClientCredentials = 'clientId' | 'clientSecret';
14
+ export declare function readPartialEnvConfig(): CmsIntegrationApiOptions;
15
+ export declare function readEnvConfig(): Omit<CmsIntegrationApiOptions, ClientCredentials> & Pick<Required<CmsIntegrationApiOptions>, ClientCredentials>;
13
16
  export declare function getCmsIntegrationApiConfigFromEnvironment(): CmsIntegrationApiOptions;
17
+ export {};
package/dist/config.js CHANGED
@@ -1,9 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readPartialEnvConfig = readPartialEnvConfig;
4
+ exports.readEnvConfig = readEnvConfig;
3
5
  exports.getCmsIntegrationApiConfigFromEnvironment = getCmsIntegrationApiConfigFromEnvironment;
4
6
  const types_1 = require("./types");
7
+ function readPartialEnvConfig() {
8
+ const cmsUrl = getOptional('OPTIMIZELY_CMS_URL', 'https://api.cms.optimizely.com');
9
+ const clientId = getOptional('OPTIMIZELY_CMS_CLIENT_ID');
10
+ const clientSecret = getOptional('OPTIMIZELY_CMS_CLIENT_SECRET');
11
+ const actAs = getOptional('OPTIMIZELY_CMS_USER_ID');
12
+ const debug = getOptional('OPTIMIZELY_DEBUG', "0") == "1";
13
+ const cmsVersion = getSelection('OPTIMIZELY_CMS_SCHEMA', [types_1.OptiCmsVersion.CMS12, types_1.OptiCmsVersion.CMS13], types_1.OptiCmsVersion.CMS13);
14
+ let baseUrl;
15
+ try {
16
+ const cmsUrlAdjusted = cmsUrl.includes("://") ? cmsUrl : 'https://' + cmsUrl;
17
+ baseUrl = new URL('/_cms/preview2', cmsUrlAdjusted);
18
+ if (cmsVersion == types_1.OptiCmsVersion.CMS12)
19
+ baseUrl.pathname = baseUrl.pathname.replace('preview2', 'preview1');
20
+ }
21
+ catch (e) {
22
+ throw new Error("Invalid Optimizely CMS URL provided");
23
+ }
24
+ if (debug)
25
+ console.log(`[Optimizely CMS API] Connecting to ${baseUrl} as ${clientId ?? 'Anonymous'}`);
26
+ return {
27
+ base: baseUrl,
28
+ clientId,
29
+ clientSecret,
30
+ actAs,
31
+ debug,
32
+ cmsVersion
33
+ };
34
+ }
35
+ function readEnvConfig() {
36
+ const partialConfig = readPartialEnvConfig();
37
+ if (!partialConfig.clientId)
38
+ throw new Error("The Client ID (OPTIMIZELY_CMS_CLIENT_ID) is a required environment variable");
39
+ if (!partialConfig.clientSecret)
40
+ throw new Error("The Client Secret (OPTIMIZELY_CMS_CLIENT_SECRET) is a required environment variable");
41
+ return partialConfig;
42
+ }
5
43
  function getCmsIntegrationApiConfigFromEnvironment() {
6
- const cmsUrl = getOptional('OPTIMIZELY_CMS_URL', 'https://example.cms.optimizely.com');
44
+ const cmsUrl = getOptional('OPTIMIZELY_CMS_URL', 'https://api.cms.optimizely.com');
7
45
  const clientId = getMandatory('OPTIMIZELY_CMS_CLIENT_ID');
8
46
  const clientSecret = getMandatory('OPTIMIZELY_CMS_CLIENT_SECRET');
9
47
  const actAs = getOptional('OPTIMIZELY_CMS_USER_ID');
@@ -12,7 +12,7 @@ async function getAccessToken(config) {
12
12
  const headers = new Headers();
13
13
  if (options.cmsVersion == types_1.OptiCmsVersion.CMS12)
14
14
  authUrl = authUrl.replace('preview2', 'preview1');
15
- headers.append('Authorization', `Basic ${base64Encode(`${options.clientId}:${options.clientSecret}`)}`);
15
+ headers.append('Authorization', `Basic ${base64Encode(`${options.clientId ?? ''}:${options.clientSecret ?? ''}`)}`);
16
16
  headers.append('Content-Type', 'application/x-www-form-urlencoded');
17
17
  headers.append('Connection', 'close');
18
18
  if (options.debug) {
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export { ApiClient, ApiError, ApiClient as CoreClient, type ApiClientStatic, typ
4
4
  export { OptiCmsVersion } from "./types";
5
5
  import { type CmsIntegrationApiOptions } from './config';
6
6
  import { type CmsIntegrationApiClient } from './api-client';
7
+ export { getCmsIntegrationApiConfigFromEnvironment as readEnvConfig } from './config';
7
8
  export declare function createClient(config?: CmsIntegrationApiOptions): CmsIntegrationApiClient;
8
9
  export declare enum ContentRoots {
9
10
  /**
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ 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.CoreClient = exports.ApiError = exports.ApiClient = exports.IntegrationApi = void 0;
39
+ exports.ContentTypeKeys = exports.ContentRoots = exports.readEnvConfig = exports.OptiCmsVersion = exports.CoreClient = exports.ApiError = exports.ApiClient = exports.IntegrationApi = void 0;
40
40
  exports.createClient = createClient;
41
41
  __exportStar(require("./config"), exports);
42
42
  exports.IntegrationApi = __importStar(require("./client/types.gen"));
@@ -47,6 +47,8 @@ Object.defineProperty(exports, "CoreClient", { enumerable: true, get: function (
47
47
  var types_1 = require("./types");
48
48
  Object.defineProperty(exports, "OptiCmsVersion", { enumerable: true, get: function () { return types_1.OptiCmsVersion; } });
49
49
  const api_client_2 = require("./api-client");
50
+ var config_1 = require("./config");
51
+ Object.defineProperty(exports, "readEnvConfig", { enumerable: true, get: function () { return config_1.getCmsIntegrationApiConfigFromEnvironment; } });
50
52
  function createClient(config) {
51
53
  return new api_client_2.ApiClient(config);
52
54
  }
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": "6.0.0-pre2",
5
+ "version": "6.0.0-pre4",
6
6
  "type": "commonjs",
7
7
  "license": "Apache-2.0",
8
8
  "main": "./dist/index.js",
@@ -1,22 +0,0 @@
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 { DisplayTemplatesService } from './services/DisplayTemplatesService';
7
- import { OauthService } from './services/OauthService';
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 displayTemplates: DisplayTemplatesService;
16
- readonly oauth: OauthService;
17
- readonly propertyFormats: PropertyFormatsService;
18
- readonly propertyGroups: PropertyGroupsService;
19
- readonly request: BaseHttpRequest;
20
- constructor(config?: Partial<OpenAPIConfig>, HttpRequest?: HttpRequestConstructor);
21
- }
22
- export {};
@@ -1,34 +0,0 @@
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 DisplayTemplatesService_1 = require("./services/DisplayTemplatesService");
9
- const OauthService_1 = require("./services/OauthService");
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.displayTemplates = new DisplayTemplatesService_1.DisplayTemplatesService(this.request);
29
- this.oauth = new OauthService_1.OauthService(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;
@@ -1,10 +0,0 @@
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
- }
@@ -1,15 +0,0 @@
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;
@@ -1,13 +0,0 @@
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
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
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
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +0,0 @@
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
- }
@@ -1,9 +0,0 @@
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;
@@ -1,20 +0,0 @@
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
- }
@@ -1,116 +0,0 @@
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;
@@ -1,14 +0,0 @@
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
- }
@@ -1,20 +0,0 @@
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;
@@ -1,16 +0,0 @@
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 {};
@@ -1,14 +0,0 @@
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
- };
@@ -1,30 +0,0 @@
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 {};