@umbraco-engage/backoffice 17.2.2 → 17.2.3
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/dist/ab-testing/project/repository/detail/ab-testing-project-detail-server.data-source.js +13 -10
- package/dist/ab-testing/test/components/variant-picker/ab-testing-test-variant-picker.element.js +1 -1
- package/dist/generated/client/client.gen.js +104 -123
- package/dist/generated/client/index.d.ts +1 -0
- package/dist/generated/client/types.gen.d.ts +6 -3
- package/dist/generated/client/utils.gen.d.ts +8 -4
- package/dist/generated/client/utils.gen.js +3 -3
- package/dist/generated/client.gen.d.ts +2 -2
- package/dist/generated/core/auth.gen.d.ts +7 -0
- package/dist/generated/core/params.gen.d.ts +1 -1
- package/dist/generated/core/params.gen.js +10 -10
- package/dist/generated/core/queryKeySerializer.gen.d.ts +1 -1
- package/dist/generated/sdk.gen.d.ts +146 -146
- package/dist/personalization/segments/rules/base/segment-rule-base-grouped-extended-checkbox.element.d.ts +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/umbraco-package.json +1 -1
- package/package.json +1 -1
package/dist/ab-testing/project/repository/detail/ab-testing-project-detail-server.data-source.js
CHANGED
|
@@ -2,8 +2,8 @@ import { ENGAGE_AB_TESTING_PROJECT_ENTITY_TYPE } from "../../constants.js";
|
|
|
2
2
|
import { tryExecute } from "@umbraco-cms/backoffice/resources";
|
|
3
3
|
import { UmbId } from "@umbraco-cms/backoffice/id";
|
|
4
4
|
import { ABTestProjectService, } from "../../../../generated/index.js";
|
|
5
|
-
// read/update here is a bit messy as the server types differ for each endpoint, but only
|
|
6
|
-
//
|
|
5
|
+
// read/create/update here is a bit messy as the server types differ for each endpoint, but only
|
|
6
|
+
// slightly, and only in the type of the abtest property.
|
|
7
7
|
export class UeAbTestingProjectDetailServerDataSource {
|
|
8
8
|
#host;
|
|
9
9
|
constructor(host) {
|
|
@@ -26,8 +26,10 @@ export class UeAbTestingProjectDetailServerDataSource {
|
|
|
26
26
|
};
|
|
27
27
|
return { data };
|
|
28
28
|
}
|
|
29
|
-
async
|
|
30
|
-
|
|
29
|
+
async create(model) {
|
|
30
|
+
if (!model)
|
|
31
|
+
throw new Error("Project data is missing...");
|
|
32
|
+
const { data, error } = await tryExecute(this.#host, ABTestProjectService.postAbTestProject({
|
|
31
33
|
body: { ...this.#mapToDto(model) },
|
|
32
34
|
}));
|
|
33
35
|
if (data) {
|
|
@@ -35,15 +37,16 @@ export class UeAbTestingProjectDetailServerDataSource {
|
|
|
35
37
|
}
|
|
36
38
|
return { error };
|
|
37
39
|
}
|
|
38
|
-
async create(model) {
|
|
39
|
-
if (!model)
|
|
40
|
-
throw new Error("Project data is missing...");
|
|
41
|
-
return await this.#update(model, ABTestProjectService.postAbTestProject);
|
|
42
|
-
}
|
|
43
40
|
async update(model) {
|
|
44
41
|
if (!model)
|
|
45
42
|
throw new Error("Project data is missing");
|
|
46
|
-
|
|
43
|
+
const { data, error } = await tryExecute(this.#host, ABTestProjectService.putAbTestProject({
|
|
44
|
+
body: { ...this.#mapToDto(model) },
|
|
45
|
+
}));
|
|
46
|
+
if (data) {
|
|
47
|
+
return { data: this.#mapFromDto(data) };
|
|
48
|
+
}
|
|
49
|
+
return { error };
|
|
47
50
|
}
|
|
48
51
|
async delete(id) {
|
|
49
52
|
if (!id)
|
package/dist/ab-testing/test/components/variant-picker/ab-testing-test-variant-picker.element.js
CHANGED
|
@@ -156,7 +156,7 @@ let UeAbTestVariantPickerElement = class UeAbTestVariantPickerElement extends Um
|
|
|
156
156
|
if (!pageVariant)
|
|
157
157
|
return;
|
|
158
158
|
const preview = () => {
|
|
159
|
-
this.#previewController.preview(pageVariant.
|
|
159
|
+
this.#previewController.preview(pageVariant.nodeKey, variant.segment ?? "", pageVariant.culture ?? undefined);
|
|
160
160
|
};
|
|
161
161
|
return html ` <uui-button
|
|
162
162
|
.disabled=${this.#disablePreviewButton(variant)}
|
|
@@ -19,10 +19,7 @@ export const createClient = (config = {}) => {
|
|
|
19
19
|
serializedBody: undefined,
|
|
20
20
|
};
|
|
21
21
|
if (opts.security) {
|
|
22
|
-
await setAuthParams(
|
|
23
|
-
...opts,
|
|
24
|
-
security: opts.security,
|
|
25
|
-
});
|
|
22
|
+
await setAuthParams(opts);
|
|
26
23
|
}
|
|
27
24
|
if (opts.requestValidator) {
|
|
28
25
|
await opts.requestValidator(opts);
|
|
@@ -39,149 +36,134 @@ export const createClient = (config = {}) => {
|
|
|
39
36
|
return { opts: resolvedOpts, url };
|
|
40
37
|
};
|
|
41
38
|
const request = async (options) => {
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
...opts,
|
|
46
|
-
body: getValidRequestBody(opts),
|
|
47
|
-
};
|
|
48
|
-
let request = new Request(url, requestInit);
|
|
49
|
-
for (const fn of interceptors.request.fns) {
|
|
50
|
-
if (fn) {
|
|
51
|
-
request = await fn(request, opts);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
// fetch must be assigned here, otherwise it would throw the error:
|
|
55
|
-
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
56
|
-
const _fetch = opts.fetch;
|
|
39
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
40
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
41
|
+
let request;
|
|
57
42
|
let response;
|
|
58
43
|
try {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
44
|
+
const { opts, url } = await beforeRequest(options);
|
|
45
|
+
const requestInit = {
|
|
46
|
+
redirect: 'follow',
|
|
47
|
+
...opts,
|
|
48
|
+
body: getValidRequestBody(opts),
|
|
49
|
+
};
|
|
50
|
+
request = new Request(url, requestInit);
|
|
51
|
+
for (const fn of interceptors.request.fns) {
|
|
65
52
|
if (fn) {
|
|
66
|
-
|
|
53
|
+
request = await fn(request, opts);
|
|
67
54
|
}
|
|
68
55
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
error: finalError,
|
|
78
|
-
request,
|
|
79
|
-
response: undefined,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
for (const fn of interceptors.response.fns) {
|
|
83
|
-
if (fn) {
|
|
84
|
-
response = await fn(response, request, opts);
|
|
56
|
+
// fetch must be assigned here, otherwise it would throw the error:
|
|
57
|
+
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
58
|
+
const _fetch = opts.fetch;
|
|
59
|
+
response = await _fetch(request);
|
|
60
|
+
for (const fn of interceptors.response.fns) {
|
|
61
|
+
if (fn) {
|
|
62
|
+
response = await fn(response, request, opts);
|
|
63
|
+
}
|
|
85
64
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
65
|
+
const result = {
|
|
66
|
+
request,
|
|
67
|
+
response,
|
|
68
|
+
};
|
|
69
|
+
if (response.ok) {
|
|
70
|
+
const parseAs = (opts.parseAs === 'auto'
|
|
71
|
+
? getParseAs(response.headers.get('Content-Type'))
|
|
72
|
+
: opts.parseAs) ?? 'json';
|
|
73
|
+
if (response.status === 204 || response.headers.get('Content-Length') === '0') {
|
|
74
|
+
let emptyData;
|
|
75
|
+
switch (parseAs) {
|
|
76
|
+
case 'arrayBuffer':
|
|
77
|
+
case 'blob':
|
|
78
|
+
case 'text':
|
|
79
|
+
emptyData = await response[parseAs]();
|
|
80
|
+
break;
|
|
81
|
+
case 'formData':
|
|
82
|
+
emptyData = new FormData();
|
|
83
|
+
break;
|
|
84
|
+
case 'stream':
|
|
85
|
+
emptyData = response.body;
|
|
86
|
+
break;
|
|
87
|
+
case 'json':
|
|
88
|
+
default:
|
|
89
|
+
emptyData = {};
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
return opts.responseStyle === 'data'
|
|
93
|
+
? emptyData
|
|
94
|
+
: {
|
|
95
|
+
data: emptyData,
|
|
96
|
+
...result,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
let data;
|
|
97
100
|
switch (parseAs) {
|
|
98
101
|
case 'arrayBuffer':
|
|
99
102
|
case 'blob':
|
|
103
|
+
case 'formData':
|
|
100
104
|
case 'text':
|
|
101
|
-
|
|
105
|
+
data = await response[parseAs]();
|
|
102
106
|
break;
|
|
103
|
-
case '
|
|
104
|
-
|
|
107
|
+
case 'json': {
|
|
108
|
+
// Some servers return 200 with no Content-Length and empty body.
|
|
109
|
+
// response.json() would throw; read as text and parse if non-empty.
|
|
110
|
+
const text = await response.text();
|
|
111
|
+
data = text ? JSON.parse(text) : {};
|
|
105
112
|
break;
|
|
113
|
+
}
|
|
106
114
|
case 'stream':
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
return opts.responseStyle === 'data'
|
|
116
|
+
? response.body
|
|
117
|
+
: {
|
|
118
|
+
data: response.body,
|
|
119
|
+
...result,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (parseAs === 'json') {
|
|
123
|
+
if (opts.responseValidator) {
|
|
124
|
+
await opts.responseValidator(data);
|
|
125
|
+
}
|
|
126
|
+
if (opts.responseTransformer) {
|
|
127
|
+
data = await opts.responseTransformer(data);
|
|
128
|
+
}
|
|
113
129
|
}
|
|
114
130
|
return opts.responseStyle === 'data'
|
|
115
|
-
?
|
|
131
|
+
? data
|
|
116
132
|
: {
|
|
117
|
-
data
|
|
133
|
+
data,
|
|
118
134
|
...result,
|
|
119
135
|
};
|
|
120
136
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
case 'formData':
|
|
126
|
-
case 'text':
|
|
127
|
-
data = await response[parseAs]();
|
|
128
|
-
break;
|
|
129
|
-
case 'json': {
|
|
130
|
-
// Some servers return 200 with no Content-Length and empty body.
|
|
131
|
-
// response.json() would throw; read as text and parse if non-empty.
|
|
132
|
-
const text = await response.text();
|
|
133
|
-
data = text ? JSON.parse(text) : {};
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
case 'stream':
|
|
137
|
-
return opts.responseStyle === 'data'
|
|
138
|
-
? response.body
|
|
139
|
-
: {
|
|
140
|
-
data: response.body,
|
|
141
|
-
...result,
|
|
142
|
-
};
|
|
137
|
+
const textError = await response.text();
|
|
138
|
+
let jsonError;
|
|
139
|
+
try {
|
|
140
|
+
jsonError = JSON.parse(textError);
|
|
143
141
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
142
|
+
catch {
|
|
143
|
+
// noop
|
|
144
|
+
}
|
|
145
|
+
throw jsonError ?? textError;
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
let finalError = error;
|
|
149
|
+
for (const fn of interceptors.error.fns) {
|
|
150
|
+
if (fn) {
|
|
151
|
+
finalError = await fn(finalError, response, request, options);
|
|
150
152
|
}
|
|
151
153
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
finalError = finalError || {};
|
|
155
|
+
if (throwOnError) {
|
|
156
|
+
throw finalError;
|
|
157
|
+
}
|
|
158
|
+
// TODO: we probably want to return error and improve types
|
|
159
|
+
return responseStyle === 'data'
|
|
160
|
+
? undefined
|
|
154
161
|
: {
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
error: finalError,
|
|
163
|
+
request,
|
|
164
|
+
response,
|
|
157
165
|
};
|
|
158
166
|
}
|
|
159
|
-
const textError = await response.text();
|
|
160
|
-
let jsonError;
|
|
161
|
-
try {
|
|
162
|
-
jsonError = JSON.parse(textError);
|
|
163
|
-
}
|
|
164
|
-
catch {
|
|
165
|
-
// noop
|
|
166
|
-
}
|
|
167
|
-
const error = jsonError ?? textError;
|
|
168
|
-
let finalError = error;
|
|
169
|
-
for (const fn of interceptors.error.fns) {
|
|
170
|
-
if (fn) {
|
|
171
|
-
finalError = (await fn(error, response, request, opts));
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
finalError = finalError || {};
|
|
175
|
-
if (opts.throwOnError) {
|
|
176
|
-
throw finalError;
|
|
177
|
-
}
|
|
178
|
-
// TODO: we probably want to return error and improve types
|
|
179
|
-
return opts.responseStyle === 'data'
|
|
180
|
-
? undefined
|
|
181
|
-
: {
|
|
182
|
-
error: finalError,
|
|
183
|
-
...result,
|
|
184
|
-
};
|
|
185
167
|
};
|
|
186
168
|
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
187
169
|
const makeSseFn = (method) => async (options) => {
|
|
@@ -189,7 +171,6 @@ export const createClient = (config = {}) => {
|
|
|
189
171
|
return createSseClient({
|
|
190
172
|
...opts,
|
|
191
173
|
body: opts.body,
|
|
192
|
-
headers: opts.headers,
|
|
193
174
|
method,
|
|
194
175
|
onRequest: async (url, init) => {
|
|
195
176
|
let request = new Request(url, init);
|
|
@@ -3,6 +3,7 @@ export type { QuerySerializerOptions } from '../core/bodySerializer.gen.js';
|
|
|
3
3
|
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from '../core/bodySerializer.gen.js';
|
|
4
4
|
export { buildClientParams } from '../core/params.gen.js';
|
|
5
5
|
export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen.js';
|
|
6
|
+
export type { ServerSentEventsResult } from '../core/serverSentEvents.gen.js';
|
|
6
7
|
export { createClient } from './client.gen.js';
|
|
7
8
|
export type { Client, ClientOptions, Config, CreateClientConfig, Options, RequestOptions, RequestResult, ResolvedRequestOptions, ResponseStyle, TDataShape, } from './types.gen.js';
|
|
8
9
|
export { createConfig, mergeHeaders } from './utils.gen.js';
|
|
@@ -63,6 +63,7 @@ export interface RequestOptions<TData = unknown, TResponseStyle extends Response
|
|
|
63
63
|
url: Url;
|
|
64
64
|
}
|
|
65
65
|
export interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
66
|
+
headers: Headers;
|
|
66
67
|
serializedBody?: string;
|
|
67
68
|
}
|
|
68
69
|
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 : {
|
|
@@ -76,8 +77,10 @@ export type RequestResult<TData = unknown, TError = unknown, ThrowOnError extend
|
|
|
76
77
|
data: undefined;
|
|
77
78
|
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
|
78
79
|
}) & {
|
|
79
|
-
request
|
|
80
|
-
|
|
80
|
+
/** request may be undefined, because error may be from building the request object itself */
|
|
81
|
+
request?: Request;
|
|
82
|
+
/** response may be undefined, because error may be from building the request object itself or from a network error */
|
|
83
|
+
response?: Response;
|
|
81
84
|
}>;
|
|
82
85
|
export interface ClientOptions {
|
|
83
86
|
baseUrl?: string;
|
|
@@ -85,7 +88,7 @@ export interface ClientOptions {
|
|
|
85
88
|
throwOnError?: boolean;
|
|
86
89
|
}
|
|
87
90
|
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,
|
|
91
|
+
type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData>>;
|
|
89
92
|
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>;
|
|
90
93
|
type BuildUrlFn = <TData extends {
|
|
91
94
|
body?: unknown;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import type { QuerySerializerOptions } from '../core/bodySerializer.gen.js';
|
|
2
2
|
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen.js';
|
|
3
|
-
export declare const createQuerySerializer: <T = unknown>({ parameters, ...args }?: QuerySerializerOptions) => (queryParams: T) => string;
|
|
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
|
*/
|
|
7
7
|
export declare const getParseAs: (contentType: string | null) => Exclude<Config["parseAs"], "auto">;
|
|
8
|
-
export declare
|
|
8
|
+
export declare function setAuthParams(options: Pick<RequestOptions, 'auth' | 'query' | 'security'> & {
|
|
9
9
|
headers: Headers;
|
|
10
|
-
})
|
|
10
|
+
}): Promise<void>;
|
|
11
11
|
export declare const buildUrl: Client['buildUrl'];
|
|
12
12
|
export declare const mergeConfigs: (a: Config, b: Config) => Config;
|
|
13
13
|
export declare const mergeHeaders: (...headers: Array<Required<Config>["headers"] | undefined>) => Headers;
|
|
14
|
-
type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
|
|
14
|
+
type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
|
|
15
|
+
/** response may be undefined due to a network error where no response object is produced */
|
|
16
|
+
response: Res | undefined,
|
|
17
|
+
/** request may be undefined, because error may be from building the request object itself */
|
|
18
|
+
request: Req | undefined, options: Options) => Err | Promise<Err>;
|
|
15
19
|
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
|
16
20
|
type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
|
|
17
21
|
declare class Interceptors<Interceptor> {
|
|
@@ -90,8 +90,8 @@ const checkForExistence = (options, name) => {
|
|
|
90
90
|
}
|
|
91
91
|
return false;
|
|
92
92
|
};
|
|
93
|
-
export
|
|
94
|
-
for (const auth of security) {
|
|
93
|
+
export async function setAuthParams(options) {
|
|
94
|
+
for (const auth of options.security ?? []) {
|
|
95
95
|
if (checkForExistence(options, auth.name)) {
|
|
96
96
|
continue;
|
|
97
97
|
}
|
|
@@ -116,7 +116,7 @@ export const setAuthParams = async ({ security, ...options }) => {
|
|
|
116
116
|
break;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
}
|
|
119
|
+
}
|
|
120
120
|
export const buildUrl = (options) => getUrl({
|
|
121
121
|
baseUrl: options.baseUrl,
|
|
122
122
|
path: options.path,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ClientOptions, type Config } from './client/index.js';
|
|
1
|
+
import { type Client, type ClientOptions, type Config } from './client/index.js';
|
|
2
2
|
import type { ClientOptions as ClientOptions2 } from './types.gen.js';
|
|
3
3
|
/**
|
|
4
4
|
* The `createClientConfig()` function will be called on client initialization
|
|
@@ -9,4 +9,4 @@ import type { ClientOptions as ClientOptions2 } from './types.gen.js';
|
|
|
9
9
|
* to ensure your client always has the correct values.
|
|
10
10
|
*/
|
|
11
11
|
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
12
|
-
export declare const client:
|
|
12
|
+
export declare const client: Client;
|
|
@@ -6,6 +6,13 @@ export interface Auth {
|
|
|
6
6
|
* @default 'header'
|
|
7
7
|
*/
|
|
8
8
|
in?: 'header' | 'query' | 'cookie';
|
|
9
|
+
/**
|
|
10
|
+
* A unique identifier for the security scheme.
|
|
11
|
+
*
|
|
12
|
+
* Defined only when there are multiple security schemes whose `Auth`
|
|
13
|
+
* shape would otherwise be identical.
|
|
14
|
+
*/
|
|
15
|
+
key?: string;
|
|
9
16
|
/**
|
|
10
17
|
* Header or query parameter name.
|
|
11
18
|
*
|
|
@@ -39,5 +39,5 @@ interface Params {
|
|
|
39
39
|
path: Record<string, unknown>;
|
|
40
40
|
query: Record<string, unknown>;
|
|
41
41
|
}
|
|
42
|
-
export declare
|
|
42
|
+
export declare function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsConfig): Params;
|
|
43
43
|
export {};
|
|
@@ -6,7 +6,7 @@ const extraPrefixesMap = {
|
|
|
6
6
|
$query_: 'query',
|
|
7
7
|
};
|
|
8
8
|
const extraPrefixes = Object.entries(extraPrefixesMap);
|
|
9
|
-
|
|
9
|
+
function buildKeyMap(fields, map) {
|
|
10
10
|
if (!map) {
|
|
11
11
|
map = new Map();
|
|
12
12
|
}
|
|
@@ -29,20 +29,20 @@ const buildKeyMap = (fields, map) => {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
return map;
|
|
32
|
-
}
|
|
33
|
-
|
|
32
|
+
}
|
|
33
|
+
function stripEmptySlots(params) {
|
|
34
34
|
for (const [slot, value] of Object.entries(params)) {
|
|
35
35
|
if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
|
|
36
36
|
delete params[slot];
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
}
|
|
40
|
-
export
|
|
39
|
+
}
|
|
40
|
+
export function buildClientParams(args, fields) {
|
|
41
41
|
const params = {
|
|
42
|
-
body:
|
|
43
|
-
headers:
|
|
44
|
-
path:
|
|
45
|
-
query:
|
|
42
|
+
body: Object.create(null),
|
|
43
|
+
headers: Object.create(null),
|
|
44
|
+
path: Object.create(null),
|
|
45
|
+
query: Object.create(null),
|
|
46
46
|
};
|
|
47
47
|
const map = buildKeyMap(fields);
|
|
48
48
|
let config;
|
|
@@ -97,4 +97,4 @@ export const buildClientParams = (args, fields) => {
|
|
|
97
97
|
}
|
|
98
98
|
stripEmptySlots(params);
|
|
99
99
|
return params;
|
|
100
|
-
}
|
|
100
|
+
}
|
|
@@ -7,7 +7,7 @@ export type JsonValue = null | string | number | boolean | JsonValue[] | {
|
|
|
7
7
|
/**
|
|
8
8
|
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
|
9
9
|
*/
|
|
10
|
-
export declare const queryKeyJsonReplacer: (_key: string, value: unknown) =>
|
|
10
|
+
export declare const queryKeyJsonReplacer: (_key: string, value: unknown) => unknown | undefined;
|
|
11
11
|
/**
|
|
12
12
|
* Safely stringifies a value and parses it back into a JsonValue.
|
|
13
13
|
*/
|