@remkoj/optimizely-cms-api 6.0.0-pre1 → 6.0.0-pre10

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 (85) hide show
  1. package/LICENSE +12 -12
  2. package/README.md +3 -5
  3. package/dist/api-client.d.ts +23 -7
  4. package/dist/api-client.js +97 -37
  5. package/dist/client/client/{client.d.ts → client.gen.d.ts} +1 -1
  6. package/dist/client/client/client.gen.js +208 -0
  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} +9 -21
  12. package/dist/client/client/{utils.js → utils.gen.js} +68 -122
  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} +13 -5
  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 +28 -167
  32. package/dist/client/sdk.gen.js +34 -421
  33. package/dist/client/transformers.gen.d.ts +8 -24
  34. package/dist/client/transformers.gen.js +76 -192
  35. package/dist/client/types.gen.d.ts +511 -2167
  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 +5 -2
  40. package/dist/config.js +26 -17
  41. package/dist/getaccesstoken.d.ts +1 -1
  42. package/dist/getaccesstoken.js +10 -8
  43. package/dist/index.d.ts +4 -0
  44. package/dist/index.js +10 -1
  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 +242 -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 +25 -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 +303 -0
  74. package/dist/instance.client/sdk.gen.js +699 -0
  75. package/dist/instance.client/transformers.gen.d.ts +48 -0
  76. package/dist/instance.client/transformers.gen.js +431 -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/client/client.js +0 -147
  84. /package/dist/client/core/{auth.d.ts → auth.gen.d.ts} +0 -0
  85. /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,6 +1,6 @@
1
- import type { QuerySerializer, QuerySerializerOptions } from '../core/bodySerializer';
2
- import type { Client, ClientOptions, Config, RequestOptions } from './types';
3
- export declare const createQuerySerializer: <T = unknown>({ allowReserved, array, object, }?: QuerySerializerOptions) => (queryParams: T) => string;
1
+ import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
2
+ import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
3
+ export declare const createQuerySerializer: <T = unknown>({ parameters, ...args }?: QuerySerializerOptions) => (queryParams: T) => string;
4
4
  /**
5
5
  * Infers parseAs value from provided Content-Type header.
6
6
  */
@@ -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,62 +1,12 @@
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
- };
59
- const createQuerySerializer = ({ allowReserved, array, object, } = {}) => {
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");
9
+ const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
60
10
  const querySerializer = (queryParams) => {
61
11
  const search = [];
62
12
  if (queryParams && typeof queryParams === 'object') {
@@ -65,33 +15,34 @@ const createQuerySerializer = ({ allowReserved, array, object, } = {}) => {
65
15
  if (value === undefined || value === null) {
66
16
  continue;
67
17
  }
18
+ const options = parameters[name] || args;
68
19
  if (Array.isArray(value)) {
69
- const serializedArray = (0, pathSerializer_1.serializeArrayParam)({
70
- allowReserved,
20
+ const serializedArray = (0, pathSerializer_gen_1.serializeArrayParam)({
21
+ allowReserved: options.allowReserved,
71
22
  explode: true,
72
23
  name,
73
24
  style: 'form',
74
25
  value,
75
- ...array,
26
+ ...options.array,
76
27
  });
77
28
  if (serializedArray)
78
29
  search.push(serializedArray);
79
30
  }
80
31
  else if (typeof value === 'object') {
81
- const serializedObject = (0, pathSerializer_1.serializeObjectParam)({
82
- allowReserved,
32
+ const serializedObject = (0, pathSerializer_gen_1.serializeObjectParam)({
33
+ allowReserved: options.allowReserved,
83
34
  explode: true,
84
35
  name,
85
36
  style: 'deepObject',
86
37
  value: value,
87
- ...object,
38
+ ...options.object,
88
39
  });
89
40
  if (serializedObject)
90
41
  search.push(serializedObject);
91
42
  }
92
43
  else {
93
- const serializedPrimitive = (0, pathSerializer_1.serializePrimitiveParam)({
94
- allowReserved,
44
+ const serializedPrimitive = (0, pathSerializer_gen_1.serializePrimitiveParam)({
45
+ allowReserved: options.allowReserved,
95
46
  name,
96
47
  value: value,
97
48
  });
@@ -134,9 +85,23 @@ const getParseAs = (contentType) => {
134
85
  return;
135
86
  };
136
87
  exports.getParseAs = getParseAs;
88
+ const checkForExistence = (options, name) => {
89
+ if (!name) {
90
+ return false;
91
+ }
92
+ if (options.headers.has(name) ||
93
+ options.query?.[name] ||
94
+ options.headers.get('Cookie')?.includes(`${name}=`)) {
95
+ return true;
96
+ }
97
+ return false;
98
+ };
137
99
  const setAuthParams = async ({ security, ...options }) => {
138
100
  for (const auth of security) {
139
- const token = await (0, auth_1.getAuthToken)(auth, options.auth);
101
+ if (checkForExistence(options, auth.name)) {
102
+ continue;
103
+ }
104
+ const token = await (0, auth_gen_1.getAuthToken)(auth, options.auth);
140
105
  if (!token) {
141
106
  continue;
142
107
  }
@@ -156,39 +121,19 @@ const setAuthParams = async ({ security, ...options }) => {
156
121
  options.headers.set(name, token);
157
122
  break;
158
123
  }
159
- return;
160
124
  }
161
125
  };
162
126
  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
- };
127
+ const buildUrl = (options) => (0, utils_gen_1.getUrl)({
128
+ baseUrl: options.baseUrl,
129
+ path: options.path,
130
+ query: options.query,
131
+ querySerializer: typeof options.querySerializer === 'function'
132
+ ? options.querySerializer
133
+ : (0, exports.createQuerySerializer)(options.querySerializer),
134
+ url: options.url,
135
+ });
175
136
  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
137
  const mergeConfigs = (a, b) => {
193
138
  const config = { ...a, ...b };
194
139
  if (config.baseUrl?.endsWith('/')) {
@@ -198,13 +143,22 @@ const mergeConfigs = (a, b) => {
198
143
  return config;
199
144
  };
200
145
  exports.mergeConfigs = mergeConfigs;
146
+ const headersEntries = (headers) => {
147
+ const entries = [];
148
+ headers.forEach((value, key) => {
149
+ entries.push([key, value]);
150
+ });
151
+ return entries;
152
+ };
201
153
  const mergeHeaders = (...headers) => {
202
154
  const mergedHeaders = new Headers();
203
155
  for (const header of headers) {
204
- if (!header || typeof header !== 'object') {
156
+ if (!header) {
205
157
  continue;
206
158
  }
207
- const iterator = header instanceof Headers ? header.entries() : Object.entries(header);
159
+ const iterator = header instanceof Headers
160
+ ? headersEntries(header)
161
+ : Object.entries(header);
208
162
  for (const [key, value] of iterator) {
209
163
  if (value === null) {
210
164
  mergedHeaders.delete(key);
@@ -225,47 +179,39 @@ const mergeHeaders = (...headers) => {
225
179
  };
226
180
  exports.mergeHeaders = mergeHeaders;
227
181
  class Interceptors {
228
- _fns;
229
- constructor() {
230
- this._fns = [];
231
- }
182
+ fns = [];
232
183
  clear() {
233
- this._fns = [];
184
+ this.fns = [];
234
185
  }
235
- getInterceptorIndex(id) {
236
- if (typeof id === 'number') {
237
- return this._fns[id] ? id : -1;
238
- }
239
- else {
240
- return this._fns.indexOf(id);
186
+ eject(id) {
187
+ const index = this.getInterceptorIndex(id);
188
+ if (this.fns[index]) {
189
+ this.fns[index] = null;
241
190
  }
242
191
  }
243
192
  exists(id) {
244
193
  const index = this.getInterceptorIndex(id);
245
- return !!this._fns[index];
194
+ return Boolean(this.fns[index]);
246
195
  }
247
- eject(id) {
248
- const index = this.getInterceptorIndex(id);
249
- if (this._fns[index]) {
250
- this._fns[index] = null;
196
+ getInterceptorIndex(id) {
197
+ if (typeof id === 'number') {
198
+ return this.fns[id] ? id : -1;
251
199
  }
200
+ return this.fns.indexOf(id);
252
201
  }
253
202
  update(id, fn) {
254
203
  const index = this.getInterceptorIndex(id);
255
- if (this._fns[index]) {
256
- this._fns[index] = fn;
204
+ if (this.fns[index]) {
205
+ this.fns[index] = fn;
257
206
  return id;
258
207
  }
259
- else {
260
- return false;
261
- }
208
+ return false;
262
209
  }
263
210
  use(fn) {
264
- this._fns = [...this._fns, fn];
265
- return this._fns.length - 1;
211
+ this.fns.push(fn);
212
+ return this.fns.length - 1;
266
213
  }
267
214
  }
268
- // do not add `Middleware` as return type so we can use _fns internally
269
215
  const createInterceptors = () => ({
270
216
  error: new Interceptors(),
271
217
  request: new Interceptors(),
@@ -287,7 +233,7 @@ const defaultHeaders = {
287
233
  'Content-Type': 'application/json',
288
234
  };
289
235
  const createConfig = (override = {}) => ({
290
- ...bodySerializer_1.jsonBodySerializer,
236
+ ...bodySerializer_gen_1.jsonBodySerializer,
291
237
  headers: defaultHeaders,
292
238
  parseAs: 'auto',
293
239
  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,11 +1,18 @@
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
- export interface QuerySerializerOptions {
4
+ type QuerySerializerOptionsObject = {
5
5
  allowReserved?: boolean;
6
- array?: SerializerOptions<ArrayStyle>;
7
- object?: SerializerOptions<ObjectStyle>;
8
- }
6
+ array?: Partial<SerializerOptions<ArrayStyle>>;
7
+ object?: Partial<SerializerOptions<ObjectStyle>>;
8
+ };
9
+ export type QuerySerializerOptions = QuerySerializerOptionsObject & {
10
+ /**
11
+ * Per-parameter serialization overrides. When provided, these settings
12
+ * override the global array/object settings for specific parameter names.
13
+ */
14
+ parameters?: Record<string, QuerySerializerOptionsObject>;
15
+ };
9
16
  export declare const formDataBodySerializer: {
10
17
  bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => FormData;
11
18
  };
@@ -15,3 +22,4 @@ export declare const jsonBodySerializer: {
15
22
  export declare const urlSearchParamsBodySerializer: {
16
23
  bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => string;
17
24
  };
25
+ export {};
@@ -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;