@remkoj/optimizely-cms-api 6.0.0-pre7 → 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.
- package/LICENSE +12 -12
- package/README.md +3 -5
- package/dist/api-client.d.ts +22 -7
- package/dist/api-client.js +92 -40
- package/dist/client/client/{client.d.ts → client.gen.d.ts} +1 -1
- package/dist/client/client/{client.js → client.gen.js} +88 -29
- package/dist/client/client/index.d.ts +8 -7
- package/dist/client/client/index.js +15 -12
- package/dist/client/client/{types.d.ts → types.gen.d.ts} +18 -13
- package/dist/client/{core/types.js → client/types.gen.js} +1 -0
- package/dist/client/client/{utils.d.ts → utils.gen.d.ts} +8 -20
- package/dist/client/client/{utils.js → utils.gen.js} +61 -116
- package/dist/client/client.gen.d.ts +3 -3
- package/dist/client/client.gen.js +1 -1
- package/dist/client/core/{auth.js → auth.gen.js} +1 -0
- package/dist/client/core/{bodySerializer.d.ts → bodySerializer.gen.d.ts} +1 -1
- package/dist/client/core/{bodySerializer.js → bodySerializer.gen.js} +4 -0
- package/dist/client/core/{params.d.ts → params.gen.d.ts} +10 -0
- package/dist/client/core/{params.js → params.gen.js} +1 -0
- package/dist/client/core/{pathSerializer.js → pathSerializer.gen.js} +1 -0
- package/dist/client/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/client/core/queryKeySerializer.gen.js +105 -0
- package/dist/client/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/client/core/serverSentEvents.gen.js +139 -0
- package/dist/client/core/{types.d.ts → types.gen.d.ts} +19 -14
- package/dist/client/{client/types.js → core/types.gen.js} +1 -0
- package/dist/client/core/utils.gen.d.ts +19 -0
- package/dist/client/core/utils.gen.js +93 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -2
- package/dist/client/sdk.gen.d.ts +11 -167
- package/dist/client/sdk.gen.js +17 -421
- package/dist/client/transformers.gen.d.ts +8 -24
- package/dist/client/transformers.gen.js +77 -193
- package/dist/client/types.gen.d.ts +520 -1919
- package/dist/client/types.gen.js +0 -84
- package/dist/client-config.d.ts +5 -2
- package/dist/client-config.js +42 -14
- package/dist/config.d.ts +2 -3
- package/dist/config.js +13 -42
- package/dist/getaccesstoken.d.ts +1 -1
- package/dist/getaccesstoken.js +9 -7
- package/dist/index.d.ts +4 -1
- package/dist/index.js +9 -2
- package/dist/instance.client/client/client.gen.d.ts +2 -0
- package/dist/instance.client/client/client.gen.js +208 -0
- package/dist/instance.client/client/index.d.ts +8 -0
- package/dist/instance.client/client/index.js +17 -0
- package/dist/instance.client/client/types.gen.d.ts +124 -0
- package/dist/instance.client/client/types.gen.js +3 -0
- package/dist/instance.client/client/utils.gen.d.ts +33 -0
- package/dist/instance.client/client/utils.gen.js +241 -0
- package/dist/instance.client/client.gen.d.ts +12 -0
- package/dist/instance.client/client.gen.js +9 -0
- package/dist/instance.client/core/auth.gen.d.ts +18 -0
- package/dist/instance.client/core/auth.gen.js +18 -0
- package/dist/instance.client/core/bodySerializer.gen.d.ts +17 -0
- package/dist/instance.client/core/bodySerializer.gen.js +60 -0
- package/dist/instance.client/core/params.gen.d.ts +33 -0
- package/dist/instance.client/core/params.gen.js +92 -0
- package/dist/instance.client/core/pathSerializer.gen.d.ts +33 -0
- package/dist/instance.client/core/pathSerializer.gen.js +123 -0
- package/dist/instance.client/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/instance.client/core/queryKeySerializer.gen.js +105 -0
- package/dist/instance.client/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/instance.client/core/serverSentEvents.gen.js +139 -0
- package/dist/instance.client/core/types.gen.d.ts +78 -0
- package/dist/instance.client/core/types.gen.js +3 -0
- package/dist/instance.client/core/utils.gen.d.ts +19 -0
- package/dist/instance.client/core/utils.gen.js +93 -0
- package/dist/instance.client/index.d.ts +4 -0
- package/dist/instance.client/index.js +21 -0
- package/dist/instance.client/sdk.gen.d.ts +256 -0
- package/dist/instance.client/sdk.gen.js +638 -0
- package/dist/instance.client/transformers.gen.d.ts +34 -0
- package/dist/instance.client/transformers.gen.js +273 -0
- package/dist/instance.client/types.gen.d.ts +2838 -0
- package/dist/instance.client/types.gen.js +3 -0
- package/dist/types.d.ts +3 -1
- package/dist/types.js +1 -0
- package/dist/version.json +3 -3
- package/package.json +8 -12
- /package/dist/client/core/{auth.d.ts → auth.gen.d.ts} +0 -0
- /package/dist/client/core/{pathSerializer.d.ts → pathSerializer.gen.d.ts} +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Config } from './types.gen';
|
|
2
|
+
export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & {
|
|
3
|
+
/**
|
|
4
|
+
* Fetch API implementation. You can use this option to provide a custom
|
|
5
|
+
* fetch instance.
|
|
6
|
+
*
|
|
7
|
+
* @default globalThis.fetch
|
|
8
|
+
*/
|
|
9
|
+
fetch?: typeof fetch;
|
|
10
|
+
/**
|
|
11
|
+
* Implementing clients can call request interceptors inside this hook.
|
|
12
|
+
*/
|
|
13
|
+
onRequest?: (url: string, init: RequestInit) => Promise<Request>;
|
|
14
|
+
/**
|
|
15
|
+
* Callback invoked when a network or parsing error occurs during streaming.
|
|
16
|
+
*
|
|
17
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
18
|
+
*
|
|
19
|
+
* @param error The error that occurred.
|
|
20
|
+
*/
|
|
21
|
+
onSseError?: (error: unknown) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Callback invoked when an event is streamed from the server.
|
|
24
|
+
*
|
|
25
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
26
|
+
*
|
|
27
|
+
* @param event Event streamed from the server.
|
|
28
|
+
* @returns Nothing (void).
|
|
29
|
+
*/
|
|
30
|
+
onSseEvent?: (event: StreamEvent<TData>) => void;
|
|
31
|
+
serializedBody?: RequestInit['body'];
|
|
32
|
+
/**
|
|
33
|
+
* Default retry delay in milliseconds.
|
|
34
|
+
*
|
|
35
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
36
|
+
*
|
|
37
|
+
* @default 3000
|
|
38
|
+
*/
|
|
39
|
+
sseDefaultRetryDelay?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Maximum number of retry attempts before giving up.
|
|
42
|
+
*/
|
|
43
|
+
sseMaxRetryAttempts?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Maximum retry delay in milliseconds.
|
|
46
|
+
*
|
|
47
|
+
* Applies only when exponential backoff is used.
|
|
48
|
+
*
|
|
49
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
50
|
+
*
|
|
51
|
+
* @default 30000
|
|
52
|
+
*/
|
|
53
|
+
sseMaxRetryDelay?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Optional sleep function for retry backoff.
|
|
56
|
+
*
|
|
57
|
+
* Defaults to using `setTimeout`.
|
|
58
|
+
*/
|
|
59
|
+
sseSleepFn?: (ms: number) => Promise<void>;
|
|
60
|
+
url: string;
|
|
61
|
+
};
|
|
62
|
+
export interface StreamEvent<TData = unknown> {
|
|
63
|
+
data: TData;
|
|
64
|
+
event?: string;
|
|
65
|
+
id?: string;
|
|
66
|
+
retry?: number;
|
|
67
|
+
}
|
|
68
|
+
export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
|
|
69
|
+
stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
|
|
70
|
+
};
|
|
71
|
+
export declare const createSseClient: <TData = unknown>({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }: ServerSentEventsOptions) => ServerSentEventsResult<TData>;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.createSseClient = void 0;
|
|
5
|
+
const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
|
|
6
|
+
let lastEventId;
|
|
7
|
+
const sleep = sseSleepFn ??
|
|
8
|
+
((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
9
|
+
const createStream = async function* () {
|
|
10
|
+
let retryDelay = sseDefaultRetryDelay ?? 3000;
|
|
11
|
+
let attempt = 0;
|
|
12
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
13
|
+
while (true) {
|
|
14
|
+
if (signal.aborted)
|
|
15
|
+
break;
|
|
16
|
+
attempt++;
|
|
17
|
+
const headers = options.headers instanceof Headers
|
|
18
|
+
? options.headers
|
|
19
|
+
: new Headers(options.headers);
|
|
20
|
+
if (lastEventId !== undefined) {
|
|
21
|
+
headers.set('Last-Event-ID', lastEventId);
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const requestInit = {
|
|
25
|
+
redirect: 'follow',
|
|
26
|
+
...options,
|
|
27
|
+
body: options.serializedBody,
|
|
28
|
+
headers,
|
|
29
|
+
signal,
|
|
30
|
+
};
|
|
31
|
+
let request = new Request(url, requestInit);
|
|
32
|
+
if (onRequest) {
|
|
33
|
+
request = await onRequest(url, requestInit);
|
|
34
|
+
}
|
|
35
|
+
// fetch must be assigned here, otherwise it would throw the error:
|
|
36
|
+
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
37
|
+
const _fetch = options.fetch ?? globalThis.fetch;
|
|
38
|
+
const response = await _fetch(request);
|
|
39
|
+
if (!response.ok)
|
|
40
|
+
throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
41
|
+
if (!response.body)
|
|
42
|
+
throw new Error('No body in SSE response');
|
|
43
|
+
const reader = response.body
|
|
44
|
+
.pipeThrough(new TextDecoderStream())
|
|
45
|
+
.getReader();
|
|
46
|
+
let buffer = '';
|
|
47
|
+
const abortHandler = () => {
|
|
48
|
+
try {
|
|
49
|
+
reader.cancel();
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// noop
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
signal.addEventListener('abort', abortHandler);
|
|
56
|
+
try {
|
|
57
|
+
while (true) {
|
|
58
|
+
const { done, value } = await reader.read();
|
|
59
|
+
if (done)
|
|
60
|
+
break;
|
|
61
|
+
buffer += value;
|
|
62
|
+
const chunks = buffer.split('\n\n');
|
|
63
|
+
buffer = chunks.pop() ?? '';
|
|
64
|
+
for (const chunk of chunks) {
|
|
65
|
+
const lines = chunk.split('\n');
|
|
66
|
+
const dataLines = [];
|
|
67
|
+
let eventName;
|
|
68
|
+
for (const line of lines) {
|
|
69
|
+
if (line.startsWith('data:')) {
|
|
70
|
+
dataLines.push(line.replace(/^data:\s*/, ''));
|
|
71
|
+
}
|
|
72
|
+
else if (line.startsWith('event:')) {
|
|
73
|
+
eventName = line.replace(/^event:\s*/, '');
|
|
74
|
+
}
|
|
75
|
+
else if (line.startsWith('id:')) {
|
|
76
|
+
lastEventId = line.replace(/^id:\s*/, '');
|
|
77
|
+
}
|
|
78
|
+
else if (line.startsWith('retry:')) {
|
|
79
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ''), 10);
|
|
80
|
+
if (!Number.isNaN(parsed)) {
|
|
81
|
+
retryDelay = parsed;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
let data;
|
|
86
|
+
let parsedJson = false;
|
|
87
|
+
if (dataLines.length) {
|
|
88
|
+
const rawData = dataLines.join('\n');
|
|
89
|
+
try {
|
|
90
|
+
data = JSON.parse(rawData);
|
|
91
|
+
parsedJson = true;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
data = rawData;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (parsedJson) {
|
|
98
|
+
if (responseValidator) {
|
|
99
|
+
await responseValidator(data);
|
|
100
|
+
}
|
|
101
|
+
if (responseTransformer) {
|
|
102
|
+
data = await responseTransformer(data);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
onSseEvent?.({
|
|
106
|
+
data,
|
|
107
|
+
event: eventName,
|
|
108
|
+
id: lastEventId,
|
|
109
|
+
retry: retryDelay,
|
|
110
|
+
});
|
|
111
|
+
if (dataLines.length) {
|
|
112
|
+
yield data;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
signal.removeEventListener('abort', abortHandler);
|
|
119
|
+
reader.releaseLock();
|
|
120
|
+
}
|
|
121
|
+
break; // exit loop on normal completion
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
// connection failed or aborted; retry after delay
|
|
125
|
+
onSseError?.(error);
|
|
126
|
+
if (sseMaxRetryAttempts !== undefined &&
|
|
127
|
+
attempt >= sseMaxRetryAttempts) {
|
|
128
|
+
break; // stop after firing error
|
|
129
|
+
}
|
|
130
|
+
// exponential backoff: double retry each attempt, cap at 30s
|
|
131
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
|
|
132
|
+
await sleep(backoff);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const stream = createStream();
|
|
137
|
+
return { stream };
|
|
138
|
+
};
|
|
139
|
+
exports.createSseClient = createSseClient;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import type { Auth, AuthToken } from './auth';
|
|
2
|
-
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer';
|
|
3
|
-
export
|
|
1
|
+
import type { Auth, AuthToken } from './auth.gen';
|
|
2
|
+
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer.gen';
|
|
3
|
+
export type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
|
|
4
|
+
export type Client<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
|
|
4
5
|
/**
|
|
5
6
|
* Returns the final request URL.
|
|
6
7
|
*/
|
|
7
8
|
buildUrl: BuildUrlFn;
|
|
8
|
-
connect: MethodFn;
|
|
9
|
-
delete: MethodFn;
|
|
10
|
-
get: MethodFn;
|
|
11
9
|
getConfig: () => Config;
|
|
12
|
-
head: MethodFn;
|
|
13
|
-
options: MethodFn;
|
|
14
|
-
patch: MethodFn;
|
|
15
|
-
post: MethodFn;
|
|
16
|
-
put: MethodFn;
|
|
17
10
|
request: RequestFn;
|
|
18
11
|
setConfig: (config: Config) => Config;
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
} & {
|
|
13
|
+
[K in HttpMethod]: MethodFn;
|
|
14
|
+
} & ([SseFn] extends [never] ? {
|
|
15
|
+
sse?: never;
|
|
16
|
+
} : {
|
|
17
|
+
sse: {
|
|
18
|
+
[K in HttpMethod]: SseFn;
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
21
|
export interface Config {
|
|
22
22
|
/**
|
|
23
23
|
* Auth token or a function returning auth token. The resolved value will be
|
|
@@ -41,7 +41,7 @@ export interface Config {
|
|
|
41
41
|
*
|
|
42
42
|
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
|
43
43
|
*/
|
|
44
|
-
method?:
|
|
44
|
+
method?: Uppercase<HttpMethod>;
|
|
45
45
|
/**
|
|
46
46
|
* A function for serializing request query parameters. By default, arrays
|
|
47
47
|
* will be exploded in form style, objects will be exploded in deepObject
|
|
@@ -71,3 +71,8 @@ export interface Config {
|
|
|
71
71
|
*/
|
|
72
72
|
responseValidator?: (data: unknown) => Promise<unknown>;
|
|
73
73
|
}
|
|
74
|
+
type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] ? true : [T] extends [never | undefined] ? [undefined] extends [T] ? false : true : false;
|
|
75
|
+
export type OmitNever<T extends Record<string, unknown>> = {
|
|
76
|
+
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K];
|
|
77
|
+
};
|
|
78
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BodySerializer, QuerySerializer } from './bodySerializer.gen';
|
|
2
|
+
export interface PathSerializer {
|
|
3
|
+
path: Record<string, unknown>;
|
|
4
|
+
url: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const PATH_PARAM_RE: RegExp;
|
|
7
|
+
export declare const defaultPathSerializer: ({ path, url: _url }: PathSerializer) => string;
|
|
8
|
+
export declare const getUrl: ({ baseUrl, path, query, querySerializer, url: _url, }: {
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
path?: Record<string, unknown>;
|
|
11
|
+
query?: Record<string, unknown>;
|
|
12
|
+
querySerializer: QuerySerializer;
|
|
13
|
+
url: string;
|
|
14
|
+
}) => string;
|
|
15
|
+
export declare function getValidRequestBody(options: {
|
|
16
|
+
body?: unknown;
|
|
17
|
+
bodySerializer?: BodySerializer | null;
|
|
18
|
+
serializedBody?: unknown;
|
|
19
|
+
}): unknown;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getUrl = exports.defaultPathSerializer = exports.PATH_PARAM_RE = void 0;
|
|
5
|
+
exports.getValidRequestBody = getValidRequestBody;
|
|
6
|
+
const pathSerializer_gen_1 = require("./pathSerializer.gen");
|
|
7
|
+
exports.PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
8
|
+
const defaultPathSerializer = ({ path, url: _url }) => {
|
|
9
|
+
let url = _url;
|
|
10
|
+
const matches = _url.match(exports.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_gen_1.serializeArrayParam)({ explode, name, style, value }));
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === 'object') {
|
|
37
|
+
url = url.replace(match, (0, pathSerializer_gen_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_gen_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
|
+
exports.defaultPathSerializer = defaultPathSerializer;
|
|
60
|
+
const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
|
|
61
|
+
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
|
62
|
+
let url = (baseUrl ?? '') + pathUrl;
|
|
63
|
+
if (path) {
|
|
64
|
+
url = (0, exports.defaultPathSerializer)({ path, url });
|
|
65
|
+
}
|
|
66
|
+
let search = query ? querySerializer(query) : '';
|
|
67
|
+
if (search.startsWith('?')) {
|
|
68
|
+
search = search.substring(1);
|
|
69
|
+
}
|
|
70
|
+
if (search) {
|
|
71
|
+
url += `?${search}`;
|
|
72
|
+
}
|
|
73
|
+
return url;
|
|
74
|
+
};
|
|
75
|
+
exports.getUrl = getUrl;
|
|
76
|
+
function getValidRequestBody(options) {
|
|
77
|
+
const hasBody = options.body !== undefined;
|
|
78
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
79
|
+
if (isSerializedBody) {
|
|
80
|
+
if ('serializedBody' in options) {
|
|
81
|
+
const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== '';
|
|
82
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
83
|
+
}
|
|
84
|
+
// not all clients implement a serializedBody property (i.e. client-axios)
|
|
85
|
+
return options.body !== '' ? options.body : null;
|
|
86
|
+
}
|
|
87
|
+
// plain/text body
|
|
88
|
+
if (hasBody) {
|
|
89
|
+
return options.body;
|
|
90
|
+
}
|
|
91
|
+
// no body was provided
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
package/dist/client/index.d.ts
CHANGED
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
4
|
if (k2 === undefined) k2 = k;
|
|
4
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -14,8 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
15
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
16
|
};
|
|
16
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
18
|
-
__exportStar(require("./types.gen"), exports);
|
|
19
18
|
__exportStar(require("./client.gen"), exports);
|
|
20
19
|
__exportStar(require("./transformers.gen"), exports);
|
|
21
20
|
__exportStar(require("./sdk.gen"), exports);
|
package/dist/client/sdk.gen.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Options as
|
|
2
|
-
import type {
|
|
3
|
-
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> =
|
|
1
|
+
import type { Client, Options as Options2, TDataShape } from './client';
|
|
2
|
+
import type { ContentTypesCreateData, ContentTypesCreateErrors, ContentTypesCreateResponses, ContentTypesDeleteData, ContentTypesDeleteErrors, ContentTypesDeleteResponses, ContentTypesGetData, ContentTypesGetErrors, ContentTypesGetResponses, ContentTypesListData, ContentTypesListErrors, ContentTypesListResponses, ContentTypesPatchData, ContentTypesPatchErrors, ContentTypesPatchResponses, DisplayTemplatesCreateData, DisplayTemplatesCreateErrors, DisplayTemplatesCreateResponses, DisplayTemplatesDeleteData, DisplayTemplatesDeleteErrors, DisplayTemplatesDeleteResponses, DisplayTemplatesGetData, DisplayTemplatesGetErrors, DisplayTemplatesGetResponses, DisplayTemplatesListData, DisplayTemplatesListErrors, DisplayTemplatesListResponses, DisplayTemplatesPatchData, DisplayTemplatesPatchErrors, DisplayTemplatesPatchResponses, PropertyFormatsGetData, PropertyFormatsGetErrors, PropertyFormatsGetResponses, PropertyFormatsListData, PropertyFormatsListErrors, PropertyFormatsListResponses, PropertyGroupsCreateData, PropertyGroupsCreateErrors, PropertyGroupsCreateResponses, PropertyGroupsDeleteData, PropertyGroupsDeleteErrors, PropertyGroupsDeleteResponses, PropertyGroupsGetData, PropertyGroupsGetErrors, PropertyGroupsGetResponses, PropertyGroupsListData, PropertyGroupsListErrors, PropertyGroupsListResponses, PropertyGroupsPatchData, PropertyGroupsPatchErrors, PropertyGroupsPatchResponses } from './types.gen';
|
|
3
|
+
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
|
|
4
4
|
/**
|
|
5
5
|
* You can provide a client instance returned by `createClient()` instead of
|
|
6
6
|
* individual options. This might be also useful if you want to implement a
|
|
@@ -13,141 +13,9 @@ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends
|
|
|
13
13
|
*/
|
|
14
14
|
meta?: Record<string, unknown>;
|
|
15
15
|
};
|
|
16
|
-
/**
|
|
17
|
-
* List changeset
|
|
18
|
-
* Lists all changeset using the provided options.
|
|
19
|
-
*/
|
|
20
|
-
export declare const changesetsList: <ThrowOnError extends boolean = false>(options?: Options<ChangesetsListData, ThrowOnError>) => import("./client").RequestResult<ChangesetsListResponses, ChangesetsListErrors, ThrowOnError, "fields">;
|
|
21
|
-
/**
|
|
22
|
-
* Create changeset
|
|
23
|
-
* Creates a new changeset.
|
|
24
|
-
*/
|
|
25
|
-
export declare const changesetsCreate: <ThrowOnError extends boolean = false>(options: Options<ChangesetsCreateData, ThrowOnError>) => import("./client").RequestResult<ChangesetsCreateResponses, ChangesetsCreateErrors, ThrowOnError, "fields">;
|
|
26
|
-
/**
|
|
27
|
-
* Delete changeset
|
|
28
|
-
* Deletes the changeset with the provided key. If a changeset with the provided key does not exist an error is returned.
|
|
29
|
-
*/
|
|
30
|
-
export declare const changesetsDelete: <ThrowOnError extends boolean = false>(options: Options<ChangesetsDeleteData, ThrowOnError>) => import("./client").RequestResult<ChangesetsDeleteResponses, ChangesetsDeleteErrors, ThrowOnError, "fields">;
|
|
31
|
-
/**
|
|
32
|
-
* Get changeset
|
|
33
|
-
* Gets the changeset with the provided key.
|
|
34
|
-
*/
|
|
35
|
-
export declare const changesetsGet: <ThrowOnError extends boolean = false>(options: Options<ChangesetsGetData, ThrowOnError>) => import("./client").RequestResult<ChangesetsGetResponses, ChangesetsGetErrors, ThrowOnError, "fields">;
|
|
36
|
-
/**
|
|
37
|
-
* Create or replace changeset
|
|
38
|
-
* Creates or replaces a changeset. If a changeset with the provided key exist it is replaced.
|
|
39
|
-
* Otherwise a new changeset is created.
|
|
40
|
-
*/
|
|
41
|
-
export declare const changesetsPut: <ThrowOnError extends boolean = false>(options: Options<ChangesetsPutData, ThrowOnError>) => import("./client").RequestResult<ChangesetsPutResponses, ChangesetsPutErrors, ThrowOnError, "fields">;
|
|
42
|
-
/**
|
|
43
|
-
* Delete changeset item
|
|
44
|
-
* Deletes the specified changeset item from the changeset.
|
|
45
|
-
*/
|
|
46
|
-
export declare const changesetsDeleteItem: <ThrowOnError extends boolean = false>(options: Options<ChangesetsDeleteItemData, ThrowOnError>) => import("./client").RequestResult<ChangesetsDeleteItemResponses, ChangesetsDeleteItemErrors, ThrowOnError, "fields">;
|
|
47
|
-
/**
|
|
48
|
-
* Get changeset item
|
|
49
|
-
* Gets the changeset item for the specified content reference.
|
|
50
|
-
*/
|
|
51
|
-
export declare const changesetsGetItem: <ThrowOnError extends boolean = false>(options: Options<ChangesetsGetItemData, ThrowOnError>) => import("./client").RequestResult<ChangesetsGetItemResponses, ChangesetsGetItemErrors, ThrowOnError, "fields">;
|
|
52
|
-
/**
|
|
53
|
-
* List changeset items
|
|
54
|
-
* Lists the available changeset items for the specified changeset using
|
|
55
|
-
* the provided options.
|
|
56
|
-
*/
|
|
57
|
-
export declare const changesetsListItems: <ThrowOnError extends boolean = false>(options: Options<ChangesetsListItemsData, ThrowOnError>) => import("./client").RequestResult<ChangesetsListItemsResponses, ChangesetsListItemsErrors, ThrowOnError, "fields">;
|
|
58
|
-
/**
|
|
59
|
-
* Create changeset item
|
|
60
|
-
* Creates the given changeset item.
|
|
61
|
-
*/
|
|
62
|
-
export declare const changesetsCreateItem: <ThrowOnError extends boolean = false>(options: Options<ChangesetsCreateItemData, ThrowOnError>) => import("./client").RequestResult<ChangesetsCreateItemResponses, ChangesetsCreateItemErrors, ThrowOnError, "fields">;
|
|
63
|
-
/**
|
|
64
|
-
* Update changeset item
|
|
65
|
-
* Updates the given changeset item.
|
|
66
|
-
*/
|
|
67
|
-
export declare const changesetsUpdateItem: <ThrowOnError extends boolean = false>(options: Options<ChangesetsUpdateItemData, ThrowOnError>) => import("./client").RequestResult<ChangesetsUpdateItemResponses, ChangesetsUpdateItemErrors, ThrowOnError, "fields">;
|
|
68
|
-
/**
|
|
69
|
-
* Create content
|
|
70
|
-
* Create a new content item.
|
|
71
|
-
*/
|
|
72
|
-
export declare const contentCreate: <ThrowOnError extends boolean = false>(options: Options<ContentCreateData, ThrowOnError>) => import("./client").RequestResult<ContentCreateResponses, ContentCreateErrors, ThrowOnError, "fields">;
|
|
73
|
-
/**
|
|
74
|
-
* Delete content
|
|
75
|
-
* Deletes the content item with the provided key. If a content item with the provided key does not exist an error is returned.
|
|
76
|
-
*/
|
|
77
|
-
export declare const contentDelete: <ThrowOnError extends boolean = false>(options: Options<ContentDeleteData, ThrowOnError>) => import("./client").RequestResult<ContentDeleteResponses, ContentDeleteErrors, ThrowOnError, "fields">;
|
|
78
|
-
/**
|
|
79
|
-
* Get content
|
|
80
|
-
* Get shared metadata about the content instance with the provided key.
|
|
81
|
-
*/
|
|
82
|
-
export declare const contentGetMetadata: <ThrowOnError extends boolean = false>(options: Options<ContentGetMetadataData, ThrowOnError>) => import("./client").RequestResult<ContentGetMetadataResponses, ContentGetMetadataErrors, ThrowOnError, "fields">;
|
|
83
|
-
/**
|
|
84
|
-
* Update content
|
|
85
|
-
* Update an existing content item. If a content item with the provided key does not exist an error is returned.
|
|
86
|
-
*/
|
|
87
|
-
export declare const contentPatchMetadata: <ThrowOnError extends boolean = false>(options: Options<ContentPatchMetadataData, ThrowOnError>) => import("./client").RequestResult<ContentPatchMetadataResponses, ContentPatchMetadataErrors, ThrowOnError, "fields">;
|
|
88
|
-
/**
|
|
89
|
-
* Get content path
|
|
90
|
-
* Get the content path with the provided key.
|
|
91
|
-
*/
|
|
92
|
-
export declare const contentGetPath: <ThrowOnError extends boolean = false>(options: Options<ContentGetPathData, ThrowOnError>) => import("./client").RequestResult<ContentGetPathResponses, ContentGetPathErrors, ThrowOnError, "fields">;
|
|
93
|
-
/**
|
|
94
|
-
* List content in container
|
|
95
|
-
* List the content items located in a specific container.
|
|
96
|
-
*/
|
|
97
|
-
export declare const contentListItems: <ThrowOnError extends boolean = false>(options: Options<ContentListItemsData, ThrowOnError>) => import("./client").RequestResult<ContentListItemsResponses, ContentListItemsErrors, ThrowOnError, "fields">;
|
|
98
|
-
/**
|
|
99
|
-
* List assets
|
|
100
|
-
* List the assets that belongs to a content instance.
|
|
101
|
-
*/
|
|
102
|
-
export declare const contentListAssets: <ThrowOnError extends boolean = false>(options: Options<ContentListAssetsData, ThrowOnError>) => import("./client").RequestResult<ContentListAssetsResponses, ContentListAssetsErrors, ThrowOnError, "fields">;
|
|
103
|
-
/**
|
|
104
|
-
* Copy content
|
|
105
|
-
* Create a copy of the content item with the provided key.
|
|
106
|
-
*/
|
|
107
|
-
export declare const contentCopy: <ThrowOnError extends boolean = false>(options: Options<ContentCopyData, ThrowOnError>) => import("./client").RequestResult<ContentCopyResponses, ContentCopyErrors, ThrowOnError, "fields">;
|
|
108
|
-
/**
|
|
109
|
-
* Restore content
|
|
110
|
-
* Restore the deleted content item with the provided key. If a content item with the provided key is not deleted an error is returned.
|
|
111
|
-
*/
|
|
112
|
-
export declare const contentUndelete: <ThrowOnError extends boolean = false>(options: Options<ContentUndeleteData, ThrowOnError>) => import("./client").RequestResult<ContentUndeleteResponses, ContentUndeleteErrors, ThrowOnError, "fields">;
|
|
113
|
-
/**
|
|
114
|
-
* Query versions
|
|
115
|
-
* List content versions based on the provided query options.
|
|
116
|
-
*/
|
|
117
|
-
export declare const contentListAllVersions: <ThrowOnError extends boolean = false>(options?: Options<ContentListAllVersionsData, ThrowOnError>) => import("./client").RequestResult<ContentListAllVersionsResponses, ContentListAllVersionsErrors, ThrowOnError, "fields">;
|
|
118
|
-
/**
|
|
119
|
-
* Delete locale
|
|
120
|
-
* Deletes the content item with the provided key. If a content item with the provided key does not exist an error is returned.
|
|
121
|
-
*/
|
|
122
|
-
export declare const contentDeleteLocale: <ThrowOnError extends boolean = false>(options: Options<ContentDeleteLocaleData, ThrowOnError>) => import("./client").RequestResult<ContentDeleteLocaleResponses, ContentDeleteLocaleErrors, ThrowOnError, "fields">;
|
|
123
|
-
/**
|
|
124
|
-
* List versions
|
|
125
|
-
* List versions of the content item with the provided key and the provided options.
|
|
126
|
-
*/
|
|
127
|
-
export declare const contentListVersions: <ThrowOnError extends boolean = false>(options: Options<ContentListVersionsData, ThrowOnError>) => import("./client").RequestResult<ContentListVersionsResponses, ContentListVersionsErrors, ThrowOnError, "fields">;
|
|
128
|
-
/**
|
|
129
|
-
* Create version
|
|
130
|
-
* Create a new version of a content item.
|
|
131
|
-
*/
|
|
132
|
-
export declare const contentCreateVersion: <ThrowOnError extends boolean = false>(options: Options<ContentCreateVersionData, ThrowOnError>) => import("./client").RequestResult<ContentCreateVersionResponses, ContentCreateVersionErrors, ThrowOnError, "fields">;
|
|
133
|
-
/**
|
|
134
|
-
* Delete version
|
|
135
|
-
* Deletes the content item with the provided key. If a content item with the provided key does not exist an error is returned.
|
|
136
|
-
*/
|
|
137
|
-
export declare const contentDeleteVersion: <ThrowOnError extends boolean = false>(options: Options<ContentDeleteVersionData, ThrowOnError>) => import("./client").RequestResult<ContentDeleteVersionResponses, ContentDeleteVersionErrors, ThrowOnError, "fields">;
|
|
138
|
-
/**
|
|
139
|
-
* Get version
|
|
140
|
-
* Get the content item with the provided key and version.
|
|
141
|
-
*/
|
|
142
|
-
export declare const contentGetVersion: <ThrowOnError extends boolean = false>(options: Options<ContentGetVersionData, ThrowOnError>) => import("./client").RequestResult<ContentGetVersionResponses, ContentGetVersionErrors, ThrowOnError, "fields">;
|
|
143
|
-
/**
|
|
144
|
-
* Update version
|
|
145
|
-
* Update an existing content item. If a content item with the provided key does not exist an error is returned.
|
|
146
|
-
*/
|
|
147
|
-
export declare const contentPatchVersion: <ThrowOnError extends boolean = false>(options: Options<ContentPatchVersionData, ThrowOnError>) => import("./client").RequestResult<ContentPatchVersionResponses, ContentPatchVersionErrors, ThrowOnError, "fields">;
|
|
148
16
|
/**
|
|
149
17
|
* List content types
|
|
150
|
-
* List content types using the provided
|
|
18
|
+
* List content types using the provided parameters.
|
|
151
19
|
*/
|
|
152
20
|
export declare const contentTypesList: <ThrowOnError extends boolean = false>(options?: Options<ContentTypesListData, ThrowOnError>) => import("./client").RequestResult<ContentTypesListResponses, ContentTypesListErrors, ThrowOnError, "fields">;
|
|
153
21
|
/**
|
|
@@ -166,19 +34,13 @@ export declare const contentTypesDelete: <ThrowOnError extends boolean = false>(
|
|
|
166
34
|
*/
|
|
167
35
|
export declare const contentTypesGet: <ThrowOnError extends boolean = false>(options: Options<ContentTypesGetData, ThrowOnError>) => import("./client").RequestResult<ContentTypesGetResponses, ContentTypesGetErrors, ThrowOnError, "fields">;
|
|
168
36
|
/**
|
|
169
|
-
*
|
|
170
|
-
*
|
|
37
|
+
* Patch content type
|
|
38
|
+
* Patch an existing content type. If a content type with the provided key does not exist an error is returned.
|
|
171
39
|
*/
|
|
172
40
|
export declare const contentTypesPatch: <ThrowOnError extends boolean = false>(options: Options<ContentTypesPatchData, ThrowOnError>) => import("./client").RequestResult<ContentTypesPatchResponses, ContentTypesPatchErrors, ThrowOnError, "fields">;
|
|
173
|
-
/**
|
|
174
|
-
* Create or replace content type
|
|
175
|
-
* Create or replace a content type. If a content type with the provided key exist it is replaced.
|
|
176
|
-
* Otherwise a new content type is created.
|
|
177
|
-
*/
|
|
178
|
-
export declare const contentTypesPut: <ThrowOnError extends boolean = false>(options: Options<ContentTypesPutData, ThrowOnError>) => import("./client").RequestResult<ContentTypesPutResponses, ContentTypesPutErrors, ThrowOnError, "fields">;
|
|
179
41
|
/**
|
|
180
42
|
* List display templates
|
|
181
|
-
* List display templates using the provided
|
|
43
|
+
* List display templates using the provided parameters.
|
|
182
44
|
*/
|
|
183
45
|
export declare const displayTemplatesList: <ThrowOnError extends boolean = false>(options?: Options<DisplayTemplatesListData, ThrowOnError>) => import("./client").RequestResult<DisplayTemplatesListResponses, DisplayTemplatesListErrors, ThrowOnError, "fields">;
|
|
184
46
|
/**
|
|
@@ -197,22 +59,10 @@ export declare const displayTemplatesDelete: <ThrowOnError extends boolean = fal
|
|
|
197
59
|
*/
|
|
198
60
|
export declare const displayTemplatesGet: <ThrowOnError extends boolean = false>(options: Options<DisplayTemplatesGetData, ThrowOnError>) => import("./client").RequestResult<DisplayTemplatesGetResponses, DisplayTemplatesGetErrors, ThrowOnError, "fields">;
|
|
199
61
|
/**
|
|
200
|
-
*
|
|
201
|
-
*
|
|
62
|
+
* Patch display template
|
|
63
|
+
* Patch an existing display template.
|
|
202
64
|
*/
|
|
203
65
|
export declare const displayTemplatesPatch: <ThrowOnError extends boolean = false>(options: Options<DisplayTemplatesPatchData, ThrowOnError>) => import("./client").RequestResult<DisplayTemplatesPatchResponses, DisplayTemplatesPatchErrors, ThrowOnError, "fields">;
|
|
204
|
-
/**
|
|
205
|
-
* Create or replace a display template
|
|
206
|
-
* Create or replace a display template. If a display template with the provided key exist it is replaced.
|
|
207
|
-
* Otherwise a new display template is created.
|
|
208
|
-
*/
|
|
209
|
-
export declare const displayTemplatesPut: <ThrowOnError extends boolean = false>(options: Options<DisplayTemplatesPutData, ThrowOnError>) => import("./client").RequestResult<DisplayTemplatesPutResponses, DisplayTemplatesPutErrors, ThrowOnError, "fields">;
|
|
210
|
-
/**
|
|
211
|
-
* Request access token
|
|
212
|
-
* Request an access token. This endpoint only supports the 'client_credentials' grant type
|
|
213
|
-
* and will only issue short-lived tokens.
|
|
214
|
-
*/
|
|
215
|
-
export declare const oauthToken: <ThrowOnError extends boolean = false>(options: Options<OauthTokenData, ThrowOnError>) => import("./client").RequestResult<OauthTokenResponses, OauthTokenErrors, ThrowOnError, "fields">;
|
|
216
66
|
/**
|
|
217
67
|
* List property formats
|
|
218
68
|
* List all property formats using the provided options.
|
|
@@ -244,13 +94,7 @@ export declare const propertyGroupsDelete: <ThrowOnError extends boolean = false
|
|
|
244
94
|
*/
|
|
245
95
|
export declare const propertyGroupsGet: <ThrowOnError extends boolean = false>(options: Options<PropertyGroupsGetData, ThrowOnError>) => import("./client").RequestResult<PropertyGroupsGetResponses, PropertyGroupsGetErrors, ThrowOnError, "fields">;
|
|
246
96
|
/**
|
|
247
|
-
*
|
|
248
|
-
*
|
|
97
|
+
* Patch property group
|
|
98
|
+
* Patch an existing property group.
|
|
249
99
|
*/
|
|
250
100
|
export declare const propertyGroupsPatch: <ThrowOnError extends boolean = false>(options: Options<PropertyGroupsPatchData, ThrowOnError>) => import("./client").RequestResult<PropertyGroupsPatchResponses, PropertyGroupsPatchErrors, ThrowOnError, "fields">;
|
|
251
|
-
/**
|
|
252
|
-
* Create or replace property group
|
|
253
|
-
* Create or replace a property group. If a property group with the provided key exist it is replaced.
|
|
254
|
-
* Otherwise a new property group is created.
|
|
255
|
-
*/
|
|
256
|
-
export declare const propertyGroupsPut: <ThrowOnError extends boolean = false>(options: Options<PropertyGroupsPutData, ThrowOnError>) => import("./client").RequestResult<PropertyGroupsPutResponses, PropertyGroupsPutErrors, ThrowOnError, "fields">;
|