@remkoj/optimizely-cms-api 6.0.0-pre8 → 6.0.0-pre9

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 (84) hide show
  1. package/LICENSE +12 -12
  2. package/README.md +3 -5
  3. package/dist/api-client.d.ts +22 -7
  4. package/dist/api-client.js +92 -40
  5. package/dist/client/client/{client.d.ts → client.gen.d.ts} +1 -1
  6. package/dist/client/client/{client.js → client.gen.js} +88 -29
  7. package/dist/client/client/index.d.ts +8 -7
  8. package/dist/client/client/index.js +15 -12
  9. package/dist/client/client/{types.d.ts → types.gen.d.ts} +18 -13
  10. package/dist/client/{core/types.js → client/types.gen.js} +1 -0
  11. package/dist/client/client/{utils.d.ts → utils.gen.d.ts} +8 -20
  12. package/dist/client/client/{utils.js → utils.gen.js} +61 -116
  13. package/dist/client/client.gen.d.ts +3 -3
  14. package/dist/client/client.gen.js +1 -1
  15. package/dist/client/core/{auth.js → auth.gen.js} +1 -0
  16. package/dist/client/core/{bodySerializer.d.ts → bodySerializer.gen.d.ts} +1 -1
  17. package/dist/client/core/{bodySerializer.js → bodySerializer.gen.js} +4 -0
  18. package/dist/client/core/{params.d.ts → params.gen.d.ts} +10 -0
  19. package/dist/client/core/{params.js → params.gen.js} +1 -0
  20. package/dist/client/core/{pathSerializer.js → pathSerializer.gen.js} +1 -0
  21. package/dist/client/core/queryKeySerializer.gen.d.ts +18 -0
  22. package/dist/client/core/queryKeySerializer.gen.js +105 -0
  23. package/dist/client/core/serverSentEvents.gen.d.ts +71 -0
  24. package/dist/client/core/serverSentEvents.gen.js +139 -0
  25. package/dist/client/core/{types.d.ts → types.gen.d.ts} +19 -14
  26. package/dist/client/{client/types.js → core/types.gen.js} +1 -0
  27. package/dist/client/core/utils.gen.d.ts +19 -0
  28. package/dist/client/core/utils.gen.js +93 -0
  29. package/dist/client/index.d.ts +1 -1
  30. package/dist/client/index.js +1 -2
  31. package/dist/client/sdk.gen.d.ts +11 -167
  32. package/dist/client/sdk.gen.js +17 -421
  33. package/dist/client/transformers.gen.d.ts +8 -24
  34. package/dist/client/transformers.gen.js +77 -193
  35. package/dist/client/types.gen.d.ts +520 -1919
  36. package/dist/client/types.gen.js +0 -84
  37. package/dist/client-config.d.ts +5 -2
  38. package/dist/client-config.js +42 -14
  39. package/dist/config.d.ts +2 -3
  40. package/dist/config.js +13 -42
  41. package/dist/getaccesstoken.d.ts +1 -1
  42. package/dist/getaccesstoken.js +9 -7
  43. package/dist/index.d.ts +4 -1
  44. package/dist/index.js +9 -2
  45. package/dist/instance.client/client/client.gen.d.ts +2 -0
  46. package/dist/instance.client/client/client.gen.js +208 -0
  47. package/dist/instance.client/client/index.d.ts +8 -0
  48. package/dist/instance.client/client/index.js +17 -0
  49. package/dist/instance.client/client/types.gen.d.ts +124 -0
  50. package/dist/instance.client/client/types.gen.js +3 -0
  51. package/dist/instance.client/client/utils.gen.d.ts +33 -0
  52. package/dist/instance.client/client/utils.gen.js +241 -0
  53. package/dist/instance.client/client.gen.d.ts +12 -0
  54. package/dist/instance.client/client.gen.js +9 -0
  55. package/dist/instance.client/core/auth.gen.d.ts +18 -0
  56. package/dist/instance.client/core/auth.gen.js +18 -0
  57. package/dist/instance.client/core/bodySerializer.gen.d.ts +17 -0
  58. package/dist/instance.client/core/bodySerializer.gen.js +60 -0
  59. package/dist/instance.client/core/params.gen.d.ts +33 -0
  60. package/dist/instance.client/core/params.gen.js +92 -0
  61. package/dist/instance.client/core/pathSerializer.gen.d.ts +33 -0
  62. package/dist/instance.client/core/pathSerializer.gen.js +123 -0
  63. package/dist/instance.client/core/queryKeySerializer.gen.d.ts +18 -0
  64. package/dist/instance.client/core/queryKeySerializer.gen.js +105 -0
  65. package/dist/instance.client/core/serverSentEvents.gen.d.ts +71 -0
  66. package/dist/instance.client/core/serverSentEvents.gen.js +139 -0
  67. package/dist/instance.client/core/types.gen.d.ts +78 -0
  68. package/dist/instance.client/core/types.gen.js +3 -0
  69. package/dist/instance.client/core/utils.gen.d.ts +19 -0
  70. package/dist/instance.client/core/utils.gen.js +93 -0
  71. package/dist/instance.client/index.d.ts +4 -0
  72. package/dist/instance.client/index.js +21 -0
  73. package/dist/instance.client/sdk.gen.d.ts +256 -0
  74. package/dist/instance.client/sdk.gen.js +638 -0
  75. package/dist/instance.client/transformers.gen.d.ts +34 -0
  76. package/dist/instance.client/transformers.gen.js +273 -0
  77. package/dist/instance.client/types.gen.d.ts +2838 -0
  78. package/dist/instance.client/types.gen.js +3 -0
  79. package/dist/types.d.ts +3 -1
  80. package/dist/types.js +1 -0
  81. package/dist/version.json +3 -3
  82. package/package.json +8 -12
  83. /package/dist/client/core/{auth.d.ts → auth.gen.d.ts} +0 -0
  84. /package/dist/client/core/{pathSerializer.d.ts → pathSerializer.gen.d.ts} +0 -0
@@ -1,6 +1,7 @@
1
- import type { Auth } from '../core/auth';
2
- import type { Client as CoreClient, Config as CoreConfig } from '../core/types';
3
- import type { Middleware } from './utils';
1
+ import type { Auth } from '../core/auth.gen';
2
+ import type { ServerSentEventsOptions, ServerSentEventsResult } from '../core/serverSentEvents.gen';
3
+ import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen';
4
+ import type { Middleware } from './utils.gen';
4
5
  export type ResponseStyle = 'data' | 'fields';
5
6
  export interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig {
6
7
  /**
@@ -13,7 +14,7 @@ export interface Config<T extends ClientOptions = ClientOptions> extends Omit<Re
13
14
  *
14
15
  * @default globalThis.fetch
15
16
  */
16
- fetch?: (request: Request) => ReturnType<typeof fetch>;
17
+ fetch?: typeof fetch;
17
18
  /**
18
19
  * Please don't use the Fetch client for Next.js applications. The `next`
19
20
  * options won't have any effect.
@@ -43,10 +44,10 @@ export interface Config<T extends ClientOptions = ClientOptions> extends Omit<Re
43
44
  */
44
45
  throwOnError?: T['throwOnError'];
45
46
  }
46
- export interface RequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
47
+ export interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
47
48
  responseStyle: TResponseStyle;
48
49
  throwOnError: ThrowOnError;
49
- }> {
50
+ }>, Pick<ServerSentEventsOptions<TData>, 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
50
51
  /**
51
52
  * Any body that you want to add to your request.
52
53
  *
@@ -61,6 +62,9 @@ export interface RequestOptions<TResponseStyle extends ResponseStyle = 'fields',
61
62
  security?: ReadonlyArray<Auth>;
62
63
  url: Url;
63
64
  }
65
+ export interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
66
+ serializedBody?: string;
67
+ }
64
68
  export type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
65
69
  data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
66
70
  request: Request;
@@ -80,16 +84,17 @@ export interface ClientOptions {
80
84
  responseStyle?: ResponseStyle;
81
85
  throwOnError?: boolean;
82
86
  }
83
- type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
84
- type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
87
+ type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
88
+ type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
89
+ type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
85
90
  type BuildUrlFn = <TData extends {
86
91
  body?: unknown;
87
92
  path?: Record<string, unknown>;
88
93
  query?: Record<string, unknown>;
89
94
  url: string;
90
95
  }>(options: Pick<TData, 'url'> & Options<TData>) => string;
91
- export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn> & {
92
- interceptors: Middleware<Request, Response, unknown, RequestOptions>;
96
+ export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
97
+ interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
93
98
  };
94
99
  /**
95
100
  * The `createClientConfig()` function will be called on client initialization
@@ -108,12 +113,12 @@ export interface TDataShape {
108
113
  url: string;
109
114
  }
110
115
  type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
111
- export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & Omit<TData, 'url'>;
116
+ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & Omit<TData, 'url'>;
112
117
  export type OptionsLegacyParser<TData = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = TData extends {
113
118
  body?: any;
114
119
  } ? TData extends {
115
120
  headers?: any;
116
- } ? OmitKeys<RequestOptions<TResponseStyle, ThrowOnError>, 'body' | 'headers' | 'url'> & TData : OmitKeys<RequestOptions<TResponseStyle, ThrowOnError>, 'body' | 'url'> & TData & Pick<RequestOptions<TResponseStyle, ThrowOnError>, 'headers'> : TData extends {
121
+ } ? OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>, 'body' | 'headers' | 'url'> & TData : OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>, 'body' | 'url'> & TData & Pick<RequestOptions<unknown, TResponseStyle, ThrowOnError>, 'headers'> : TData extends {
117
122
  headers?: any;
118
- } ? OmitKeys<RequestOptions<TResponseStyle, ThrowOnError>, 'headers' | 'url'> & TData & Pick<RequestOptions<TResponseStyle, ThrowOnError>, 'body'> : OmitKeys<RequestOptions<TResponseStyle, ThrowOnError>, 'url'> & TData;
123
+ } ? OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>, 'headers' | 'url'> & TData & Pick<RequestOptions<unknown, TResponseStyle, ThrowOnError>, 'body'> : OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>, 'url'> & TData;
119
124
  export {};
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,5 @@
1
- import type { QuerySerializer, QuerySerializerOptions } from '../core/bodySerializer';
2
- import type { Client, ClientOptions, Config, RequestOptions } from './types';
1
+ import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
2
+ import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
3
3
  export declare const createQuerySerializer: <T = unknown>({ allowReserved, array, object, }?: QuerySerializerOptions) => (queryParams: T) => string;
4
4
  /**
5
5
  * Infers parseAs value from provided Content-Type header.
@@ -9,37 +9,25 @@ export declare const setAuthParams: ({ security, ...options }: Pick<Required<Req
9
9
  headers: Headers;
10
10
  }) => Promise<void>;
11
11
  export declare const buildUrl: Client['buildUrl'];
12
- export declare const getUrl: ({ baseUrl, path, query, querySerializer, url: _url, }: {
13
- baseUrl?: string;
14
- path?: Record<string, unknown>;
15
- query?: Record<string, unknown>;
16
- querySerializer: QuerySerializer;
17
- url: string;
18
- }) => string;
19
12
  export declare const mergeConfigs: (a: Config, b: Config) => Config;
20
13
  export declare const mergeHeaders: (...headers: Array<Required<Config>["headers"] | undefined>) => Headers;
21
14
  type ErrInterceptor<Err, Res, Req, Options> = (error: Err, response: Res, request: Req, options: Options) => Err | Promise<Err>;
22
15
  type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
23
16
  type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
24
17
  declare class Interceptors<Interceptor> {
25
- _fns: (Interceptor | null)[];
26
- constructor();
18
+ fns: Array<Interceptor | null>;
27
19
  clear(): void;
28
- getInterceptorIndex(id: number | Interceptor): number;
29
- exists(id: number | Interceptor): boolean;
30
20
  eject(id: number | Interceptor): void;
31
- update(id: number | Interceptor, fn: Interceptor): number | false | Interceptor;
21
+ exists(id: number | Interceptor): boolean;
22
+ getInterceptorIndex(id: number | Interceptor): number;
23
+ update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
32
24
  use(fn: Interceptor): number;
33
25
  }
34
26
  export interface Middleware<Req, Res, Err, Options> {
35
- error: Pick<Interceptors<ErrInterceptor<Err, Res, Req, Options>>, 'eject' | 'use'>;
36
- request: Pick<Interceptors<ReqInterceptor<Req, Options>>, 'eject' | 'use'>;
37
- response: Pick<Interceptors<ResInterceptor<Res, Req, Options>>, 'eject' | 'use'>;
38
- }
39
- export declare const createInterceptors: <Req, Res, Err, Options>() => {
40
27
  error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
41
28
  request: Interceptors<ReqInterceptor<Req, Options>>;
42
29
  response: Interceptors<ResInterceptor<Res, Req, Options>>;
43
- };
30
+ }
31
+ export declare const createInterceptors: <Req, Res, Err, Options>() => Middleware<Req, Res, Err, Options>;
44
32
  export declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>;
45
33
  export {};
@@ -1,61 +1,11 @@
1
1
  "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createConfig = exports.createInterceptors = exports.mergeHeaders = exports.mergeConfigs = exports.getUrl = exports.buildUrl = exports.setAuthParams = exports.getParseAs = exports.createQuerySerializer = void 0;
4
- const auth_1 = require("../core/auth");
5
- const bodySerializer_1 = require("../core/bodySerializer");
6
- const pathSerializer_1 = require("../core/pathSerializer");
7
- const PATH_PARAM_RE = /\{[^{}]+\}/g;
8
- const defaultPathSerializer = ({ path, url: _url }) => {
9
- let url = _url;
10
- const matches = _url.match(PATH_PARAM_RE);
11
- if (matches) {
12
- for (const match of matches) {
13
- let explode = false;
14
- let name = match.substring(1, match.length - 1);
15
- let style = 'simple';
16
- if (name.endsWith('*')) {
17
- explode = true;
18
- name = name.substring(0, name.length - 1);
19
- }
20
- if (name.startsWith('.')) {
21
- name = name.substring(1);
22
- style = 'label';
23
- }
24
- else if (name.startsWith(';')) {
25
- name = name.substring(1);
26
- style = 'matrix';
27
- }
28
- const value = path[name];
29
- if (value === undefined || value === null) {
30
- continue;
31
- }
32
- if (Array.isArray(value)) {
33
- url = url.replace(match, (0, pathSerializer_1.serializeArrayParam)({ explode, name, style, value }));
34
- continue;
35
- }
36
- if (typeof value === 'object') {
37
- url = url.replace(match, (0, pathSerializer_1.serializeObjectParam)({
38
- explode,
39
- name,
40
- style,
41
- value: value,
42
- valueOnly: true,
43
- }));
44
- continue;
45
- }
46
- if (style === 'matrix') {
47
- url = url.replace(match, `;${(0, pathSerializer_1.serializePrimitiveParam)({
48
- name,
49
- value: value,
50
- })}`);
51
- continue;
52
- }
53
- const replaceValue = encodeURIComponent(style === 'label' ? `.${value}` : value);
54
- url = url.replace(match, replaceValue);
55
- }
56
- }
57
- return url;
58
- };
4
+ exports.createConfig = exports.createInterceptors = exports.mergeHeaders = exports.mergeConfigs = exports.buildUrl = exports.setAuthParams = exports.getParseAs = exports.createQuerySerializer = void 0;
5
+ const auth_gen_1 = require("../core/auth.gen");
6
+ const bodySerializer_gen_1 = require("../core/bodySerializer.gen");
7
+ const pathSerializer_gen_1 = require("../core/pathSerializer.gen");
8
+ const utils_gen_1 = require("../core/utils.gen");
59
9
  const createQuerySerializer = ({ allowReserved, array, object, } = {}) => {
60
10
  const querySerializer = (queryParams) => {
61
11
  const search = [];
@@ -66,7 +16,7 @@ const createQuerySerializer = ({ allowReserved, array, object, } = {}) => {
66
16
  continue;
67
17
  }
68
18
  if (Array.isArray(value)) {
69
- const serializedArray = (0, pathSerializer_1.serializeArrayParam)({
19
+ const serializedArray = (0, pathSerializer_gen_1.serializeArrayParam)({
70
20
  allowReserved,
71
21
  explode: true,
72
22
  name,
@@ -78,7 +28,7 @@ const createQuerySerializer = ({ allowReserved, array, object, } = {}) => {
78
28
  search.push(serializedArray);
79
29
  }
80
30
  else if (typeof value === 'object') {
81
- const serializedObject = (0, pathSerializer_1.serializeObjectParam)({
31
+ const serializedObject = (0, pathSerializer_gen_1.serializeObjectParam)({
82
32
  allowReserved,
83
33
  explode: true,
84
34
  name,
@@ -90,7 +40,7 @@ const createQuerySerializer = ({ allowReserved, array, object, } = {}) => {
90
40
  search.push(serializedObject);
91
41
  }
92
42
  else {
93
- const serializedPrimitive = (0, pathSerializer_1.serializePrimitiveParam)({
43
+ const serializedPrimitive = (0, pathSerializer_gen_1.serializePrimitiveParam)({
94
44
  allowReserved,
95
45
  name,
96
46
  value: value,
@@ -134,9 +84,23 @@ const getParseAs = (contentType) => {
134
84
  return;
135
85
  };
136
86
  exports.getParseAs = getParseAs;
87
+ const checkForExistence = (options, name) => {
88
+ if (!name) {
89
+ return false;
90
+ }
91
+ if (options.headers.has(name) ||
92
+ options.query?.[name] ||
93
+ options.headers.get('Cookie')?.includes(`${name}=`)) {
94
+ return true;
95
+ }
96
+ return false;
97
+ };
137
98
  const setAuthParams = async ({ security, ...options }) => {
138
99
  for (const auth of security) {
139
- const token = await (0, auth_1.getAuthToken)(auth, options.auth);
100
+ if (checkForExistence(options, auth.name)) {
101
+ continue;
102
+ }
103
+ const token = await (0, auth_gen_1.getAuthToken)(auth, options.auth);
140
104
  if (!token) {
141
105
  continue;
142
106
  }
@@ -156,39 +120,19 @@ const setAuthParams = async ({ security, ...options }) => {
156
120
  options.headers.set(name, token);
157
121
  break;
158
122
  }
159
- return;
160
123
  }
161
124
  };
162
125
  exports.setAuthParams = setAuthParams;
163
- const buildUrl = (options) => {
164
- const url = (0, exports.getUrl)({
165
- baseUrl: options.baseUrl,
166
- path: options.path,
167
- query: options.query,
168
- querySerializer: typeof options.querySerializer === 'function'
169
- ? options.querySerializer
170
- : (0, exports.createQuerySerializer)(options.querySerializer),
171
- url: options.url,
172
- });
173
- return url;
174
- };
126
+ const buildUrl = (options) => (0, utils_gen_1.getUrl)({
127
+ baseUrl: options.baseUrl,
128
+ path: options.path,
129
+ query: options.query,
130
+ querySerializer: typeof options.querySerializer === 'function'
131
+ ? options.querySerializer
132
+ : (0, exports.createQuerySerializer)(options.querySerializer),
133
+ url: options.url,
134
+ });
175
135
  exports.buildUrl = buildUrl;
176
- const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
177
- const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
178
- let url = (baseUrl ?? '') + pathUrl;
179
- if (path) {
180
- url = defaultPathSerializer({ path, url });
181
- }
182
- let search = query ? querySerializer(query) : '';
183
- if (search.startsWith('?')) {
184
- search = search.substring(1);
185
- }
186
- if (search) {
187
- url += `?${search}`;
188
- }
189
- return url;
190
- };
191
- exports.getUrl = getUrl;
192
136
  const mergeConfigs = (a, b) => {
193
137
  const config = { ...a, ...b };
194
138
  if (config.baseUrl?.endsWith('/')) {
@@ -198,13 +142,22 @@ const mergeConfigs = (a, b) => {
198
142
  return config;
199
143
  };
200
144
  exports.mergeConfigs = mergeConfigs;
145
+ const headersEntries = (headers) => {
146
+ const entries = [];
147
+ headers.forEach((value, key) => {
148
+ entries.push([key, value]);
149
+ });
150
+ return entries;
151
+ };
201
152
  const mergeHeaders = (...headers) => {
202
153
  const mergedHeaders = new Headers();
203
154
  for (const header of headers) {
204
- if (!header || typeof header !== 'object') {
155
+ if (!header) {
205
156
  continue;
206
157
  }
207
- const iterator = header instanceof Headers ? header.entries() : Object.entries(header);
158
+ const iterator = header instanceof Headers
159
+ ? headersEntries(header)
160
+ : Object.entries(header);
208
161
  for (const [key, value] of iterator) {
209
162
  if (value === null) {
210
163
  mergedHeaders.delete(key);
@@ -225,47 +178,39 @@ const mergeHeaders = (...headers) => {
225
178
  };
226
179
  exports.mergeHeaders = mergeHeaders;
227
180
  class Interceptors {
228
- _fns;
229
- constructor() {
230
- this._fns = [];
231
- }
181
+ fns = [];
232
182
  clear() {
233
- this._fns = [];
183
+ this.fns = [];
234
184
  }
235
- getInterceptorIndex(id) {
236
- if (typeof id === 'number') {
237
- return this._fns[id] ? id : -1;
238
- }
239
- else {
240
- return this._fns.indexOf(id);
185
+ eject(id) {
186
+ const index = this.getInterceptorIndex(id);
187
+ if (this.fns[index]) {
188
+ this.fns[index] = null;
241
189
  }
242
190
  }
243
191
  exists(id) {
244
192
  const index = this.getInterceptorIndex(id);
245
- return !!this._fns[index];
193
+ return Boolean(this.fns[index]);
246
194
  }
247
- eject(id) {
248
- const index = this.getInterceptorIndex(id);
249
- if (this._fns[index]) {
250
- this._fns[index] = null;
195
+ getInterceptorIndex(id) {
196
+ if (typeof id === 'number') {
197
+ return this.fns[id] ? id : -1;
251
198
  }
199
+ return this.fns.indexOf(id);
252
200
  }
253
201
  update(id, fn) {
254
202
  const index = this.getInterceptorIndex(id);
255
- if (this._fns[index]) {
256
- this._fns[index] = fn;
203
+ if (this.fns[index]) {
204
+ this.fns[index] = fn;
257
205
  return id;
258
206
  }
259
- else {
260
- return false;
261
- }
207
+ return false;
262
208
  }
263
209
  use(fn) {
264
- this._fns = [...this._fns, fn];
265
- return this._fns.length - 1;
210
+ this.fns.push(fn);
211
+ return this.fns.length - 1;
266
212
  }
267
213
  }
268
- // do not add `Middleware` as return type so we can use _fns internally
269
214
  const createInterceptors = () => ({
270
215
  error: new Interceptors(),
271
216
  request: new Interceptors(),
@@ -287,7 +232,7 @@ const defaultHeaders = {
287
232
  'Content-Type': 'application/json',
288
233
  };
289
234
  const createConfig = (override = {}) => ({
290
- ...bodySerializer_1.jsonBodySerializer,
235
+ ...bodySerializer_gen_1.jsonBodySerializer,
291
236
  headers: defaultHeaders,
292
237
  parseAs: 'auto',
293
238
  querySerializer: defaultQuerySerializer,
@@ -1,5 +1,5 @@
1
- import type { ClientOptions } from './types.gen';
2
- import { type Config, type ClientOptions as DefaultClientOptions } from './client';
1
+ import { type ClientOptions, type Config } from './client';
2
+ import type { ClientOptions as ClientOptions2 } from './types.gen';
3
3
  /**
4
4
  * The `createClientConfig()` function will be called on client initialization
5
5
  * and the returned object will become the client's initial configuration.
@@ -8,5 +8,5 @@ import { type Config, type ClientOptions as DefaultClientOptions } from './clien
8
8
  * `setConfig()`. This is useful for example if you're using Next.js
9
9
  * to ensure your client always has the correct values.
10
10
  */
11
- export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
11
+ export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
12
12
  export declare const client: import("./client").Client;
@@ -5,5 +5,5 @@ exports.client = void 0;
5
5
  const client_1 = require("./client");
6
6
  const client_config_1 = require("../client-config");
7
7
  exports.client = (0, client_1.createClient)((0, client_config_1.createClientConfig)((0, client_1.createConfig)({
8
- baseUrl: '/_cms/preview2'
8
+ baseUrl: 'https://api.cms.optimizely.com/preview3'
9
9
  })));
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.getAuthToken = void 0;
4
5
  const getAuthToken = async (auth, callback) => {
@@ -1,4 +1,4 @@
1
- import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer';
1
+ import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer.gen';
2
2
  export type QuerySerializer = (query: Record<string, unknown>) => string;
3
3
  export type BodySerializer = (body: any) => any;
4
4
  export interface QuerySerializerOptions {
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.urlSearchParamsBodySerializer = exports.jsonBodySerializer = exports.formDataBodySerializer = void 0;
4
5
  const serializeFormDataPair = (data, key, value) => {
5
6
  if (typeof value === 'string' || value instanceof Blob) {
6
7
  data.append(key, value);
7
8
  }
9
+ else if (value instanceof Date) {
10
+ data.append(key, value.toISOString());
11
+ }
8
12
  else {
9
13
  data.append(key, JSON.stringify(value));
10
14
  }
@@ -1,10 +1,20 @@
1
1
  type Slot = 'body' | 'headers' | 'path' | 'query';
2
2
  export type Field = {
3
3
  in: Exclude<Slot, 'body'>;
4
+ /**
5
+ * Field name. This is the name we want the user to see and use.
6
+ */
4
7
  key: string;
8
+ /**
9
+ * Field mapped name. This is the name we want to use in the request.
10
+ * If omitted, we use the same value as `key`.
11
+ */
5
12
  map?: string;
6
13
  } | {
7
14
  in: Extract<Slot, 'body'>;
15
+ /**
16
+ * Key isn't required for bodies.
17
+ */
8
18
  key?: string;
9
19
  map?: string;
10
20
  };
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.buildClientParams = void 0;
4
5
  const extraPrefixesMap = {
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.serializeObjectParam = exports.serializePrimitiveParam = exports.serializeArrayParam = exports.separatorObjectExplode = exports.separatorArrayNoExplode = exports.separatorArrayExplode = void 0;
4
5
  const separatorArrayExplode = (style) => {
@@ -0,0 +1,18 @@
1
+ /**
2
+ * JSON-friendly union that mirrors what Pinia Colada can hash.
3
+ */
4
+ export type JsonValue = null | string | number | boolean | JsonValue[] | {
5
+ [key: string]: JsonValue;
6
+ };
7
+ /**
8
+ * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
9
+ */
10
+ export declare const queryKeyJsonReplacer: (_key: string, value: unknown) => {} | null | undefined;
11
+ /**
12
+ * Safely stringifies a value and parses it back into a JsonValue.
13
+ */
14
+ export declare const stringifyToJsonValue: (input: unknown) => JsonValue | undefined;
15
+ /**
16
+ * Normalizes any accepted value into a JSON-friendly shape for query keys.
17
+ */
18
+ export declare const serializeQueryKeyValue: (value: unknown) => JsonValue | undefined;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.serializeQueryKeyValue = exports.stringifyToJsonValue = exports.queryKeyJsonReplacer = void 0;
5
+ /**
6
+ * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
7
+ */
8
+ const queryKeyJsonReplacer = (_key, value) => {
9
+ if (value === undefined ||
10
+ typeof value === 'function' ||
11
+ typeof value === 'symbol') {
12
+ return undefined;
13
+ }
14
+ if (typeof value === 'bigint') {
15
+ return value.toString();
16
+ }
17
+ if (value instanceof Date) {
18
+ return value.toISOString();
19
+ }
20
+ return value;
21
+ };
22
+ exports.queryKeyJsonReplacer = queryKeyJsonReplacer;
23
+ /**
24
+ * Safely stringifies a value and parses it back into a JsonValue.
25
+ */
26
+ const stringifyToJsonValue = (input) => {
27
+ try {
28
+ const json = JSON.stringify(input, exports.queryKeyJsonReplacer);
29
+ if (json === undefined) {
30
+ return undefined;
31
+ }
32
+ return JSON.parse(json);
33
+ }
34
+ catch {
35
+ return undefined;
36
+ }
37
+ };
38
+ exports.stringifyToJsonValue = stringifyToJsonValue;
39
+ /**
40
+ * Detects plain objects (including objects with a null prototype).
41
+ */
42
+ const isPlainObject = (value) => {
43
+ if (value === null || typeof value !== 'object') {
44
+ return false;
45
+ }
46
+ const prototype = Object.getPrototypeOf(value);
47
+ return prototype === Object.prototype || prototype === null;
48
+ };
49
+ /**
50
+ * Turns URLSearchParams into a sorted JSON object for deterministic keys.
51
+ */
52
+ const serializeSearchParams = (params) => {
53
+ const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
54
+ const result = {};
55
+ for (const [key, value] of entries) {
56
+ const existing = result[key];
57
+ if (existing === undefined) {
58
+ result[key] = value;
59
+ continue;
60
+ }
61
+ if (Array.isArray(existing)) {
62
+ existing.push(value);
63
+ }
64
+ else {
65
+ result[key] = [existing, value];
66
+ }
67
+ }
68
+ return result;
69
+ };
70
+ /**
71
+ * Normalizes any accepted value into a JSON-friendly shape for query keys.
72
+ */
73
+ const serializeQueryKeyValue = (value) => {
74
+ if (value === null) {
75
+ return null;
76
+ }
77
+ if (typeof value === 'string' ||
78
+ typeof value === 'number' ||
79
+ typeof value === 'boolean') {
80
+ return value;
81
+ }
82
+ if (value === undefined ||
83
+ typeof value === 'function' ||
84
+ typeof value === 'symbol') {
85
+ return undefined;
86
+ }
87
+ if (typeof value === 'bigint') {
88
+ return value.toString();
89
+ }
90
+ if (value instanceof Date) {
91
+ return value.toISOString();
92
+ }
93
+ if (Array.isArray(value)) {
94
+ return (0, exports.stringifyToJsonValue)(value);
95
+ }
96
+ if (typeof URLSearchParams !== 'undefined' &&
97
+ value instanceof URLSearchParams) {
98
+ return serializeSearchParams(value);
99
+ }
100
+ if (isPlainObject(value)) {
101
+ return (0, exports.stringifyToJsonValue)(value);
102
+ }
103
+ return undefined;
104
+ };
105
+ exports.serializeQueryKeyValue = serializeQueryKeyValue;