mtmsdk 0.0.50 → 0.0.52
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/gomtmapi/@tanstack/react-query.gen.d.ts +1 -13
- package/dist/gomtmapi/@tanstack/react-query.gen.d.ts.map +1 -1
- package/dist/gomtmapi/@tanstack/react-query.gen.js +1 -37
- package/dist/gomtmapi/@tanstack/react-query.gen.js.map +1 -1
- package/dist/gomtmapi/index.d.ts +2 -2
- package/dist/gomtmapi/index.d.ts.map +1 -1
- package/dist/gomtmapi/index.js +1 -1
- package/dist/gomtmapi/index.js.map +1 -1
- package/dist/gomtmapi/schemas.gen.d.ts +0 -57
- package/dist/gomtmapi/schemas.gen.d.ts.map +1 -1
- package/dist/gomtmapi/schemas.gen.js +0 -60
- package/dist/gomtmapi/schemas.gen.js.map +1 -1
- package/dist/gomtmapi/sdk.gen.d.ts +1 -13
- package/dist/gomtmapi/sdk.gen.d.ts.map +1 -1
- package/dist/gomtmapi/sdk.gen.js +0 -26
- package/dist/gomtmapi/sdk.gen.js.map +1 -1
- package/dist/gomtmapi/types.gen.d.ts +0 -94
- package/dist/gomtmapi/types.gen.d.ts.map +1 -1
- package/dist/gomtmapi/zod.gen.d.ts +0 -62
- package/dist/gomtmapi/zod.gen.d.ts.map +1 -1
- package/dist/gomtmapi/zod.gen.js +0 -51
- package/dist/gomtmapi/zod.gen.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/schema.d.ts +1 -11
- package/dist/lib/schema.d.ts.map +1 -1
- package/dist/lib/schema.js +0 -9
- package/dist/lib/schema.js.map +1 -1
- package/dist/mtgate_api/client.gen.d.ts.map +1 -1
- package/dist/mtgate_api/client.gen.js +1 -1
- package/dist/mtgate_api/client.gen.js.map +1 -1
- package/dist/mtgate_api/index.d.ts +2 -2
- package/dist/mtgate_api/index.d.ts.map +1 -1
- package/dist/mtgate_api/index.js +1 -1
- package/dist/mtgate_api/index.js.map +1 -1
- package/dist/mtgate_api/sdk.gen.d.ts +0 -8
- package/dist/mtgate_api/sdk.gen.d.ts.map +1 -1
- package/dist/mtgate_api/sdk.gen.js +1 -29
- package/dist/mtgate_api/sdk.gen.js.map +1 -1
- package/dist/mtgate_api/types.gen.d.ts +1 -200
- package/dist/mtgate_api/types.gen.d.ts.map +1 -1
- package/dist/openclaw/gateway.d.ts.map +1 -1
- package/dist/openclaw/gateway.js +1 -1
- package/dist/openclaw/gateway.js.map +1 -1
- package/dist/sbmng/@tanstack/react-query.gen.d.ts +39 -65
- package/dist/sbmng/@tanstack/react-query.gen.d.ts.map +1 -1
- package/dist/sbmng/@tanstack/react-query.gen.js +19 -65
- package/dist/sbmng/@tanstack/react-query.gen.js.map +1 -1
- package/dist/sbmng/index.d.ts +2 -2
- package/dist/sbmng/index.d.ts.map +1 -1
- package/dist/sbmng/index.js +1 -1
- package/dist/sbmng/index.js.map +1 -1
- package/dist/sbmng/schemas.gen.d.ts +6 -95
- package/dist/sbmng/schemas.gen.d.ts.map +1 -1
- package/dist/sbmng/schemas.gen.js +7 -139
- package/dist/sbmng/schemas.gen.js.map +1 -1
- package/dist/sbmng/sdk.gen.d.ts +7 -17
- package/dist/sbmng/sdk.gen.d.ts.map +1 -1
- package/dist/sbmng/sdk.gen.js +10 -32
- package/dist/sbmng/sdk.gen.js.map +1 -1
- package/dist/sbmng/types.gen.d.ts +41 -157
- package/dist/sbmng/types.gen.d.ts.map +1 -1
- package/dist/supabase/supabase-client.d.ts +85 -181
- package/dist/supabase/supabase-client.d.ts.map +1 -1
- package/dist/supabase/supabase.d.ts +170 -362
- package/dist/supabase/supabase.d.ts.map +1 -1
- package/dist/supabase/use-sb-query/build-query-opts.d.ts +6 -2
- package/dist/supabase/use-sb-query/build-query-opts.d.ts.map +1 -1
- package/dist/supabase/use-sb-query/build-query-opts.js +8 -4
- package/dist/supabase/use-sb-query/build-query-opts.js.map +1 -1
- package/dist/supabase/use-sb-query/use-query.d.ts +9 -6
- package/dist/supabase/use-sb-query/use-query.d.ts.map +1 -1
- package/dist/supabase/use-sb-query/use-query.js.map +1 -1
- package/dist/supabase/use-sb-query/use-rpc-query.d.ts +25 -17
- package/dist/supabase/use-sb-query/use-rpc-query.d.ts.map +1 -1
- package/dist/supabase/use-sb-query/use-rpc-query.js +48 -26
- package/dist/supabase/use-sb-query/use-rpc-query.js.map +1 -1
- package/dist/types/database.schemas.d.ts +129 -222
- package/dist/types/database.schemas.d.ts.map +1 -1
- package/dist/types/database.schemas.js +112 -124
- package/dist/types/database.schemas.js.map +1 -1
- package/dist/types/database.types.d.ts +85 -181
- package/dist/types/database.types.d.ts.map +1 -1
- package/dist/types/database.types.js.map +1 -1
- package/dist/types/index.d.ts +30 -59
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +16 -3
- package/dist/types/index.js.map +1 -1
- package/package.json +105 -110
- package/src/cloud-account/platform-configs.ts +73 -73
- package/src/gomtmapi/@tanstack/react-query.gen.ts +537 -575
- package/src/gomtmapi/client/client.gen.ts +311 -311
- package/src/gomtmapi/client/index.ts +25 -25
- package/src/gomtmapi/client/types.gen.ts +241 -241
- package/src/gomtmapi/client/utils.gen.ts +332 -332
- package/src/gomtmapi/client.gen.ts +16 -16
- package/src/gomtmapi/core/auth.gen.ts +42 -42
- package/src/gomtmapi/core/bodySerializer.gen.ts +100 -100
- package/src/gomtmapi/core/params.gen.ts +176 -176
- package/src/gomtmapi/core/pathSerializer.gen.ts +181 -181
- package/src/gomtmapi/core/queryKeySerializer.gen.ts +136 -136
- package/src/gomtmapi/core/serverSentEvents.gen.ts +266 -266
- package/src/gomtmapi/core/types.gen.ts +118 -118
- package/src/gomtmapi/core/utils.gen.ts +143 -143
- package/src/gomtmapi/index.ts +4 -4
- package/src/gomtmapi/schemas.gen.ts +532 -596
- package/src/gomtmapi/sdk.gen.ts +371 -399
- package/src/gomtmapi/types.gen.ts +854 -962
- package/src/gomtmapi/zod.gen.ts +448 -507
- package/src/index.ts +4 -5
- package/src/lib/aisdk/types.ts +7 -7
- package/src/lib/logger/index.ts +8 -8
- package/src/lib/schema.ts +37 -50
- package/src/mtgate_api/client/client.gen.ts +311 -311
- package/src/mtgate_api/client/index.ts +25 -25
- package/src/mtgate_api/client/types.gen.ts +241 -241
- package/src/mtgate_api/client/utils.gen.ts +332 -332
- package/src/mtgate_api/client.gen.ts +16 -16
- package/src/mtgate_api/core/auth.gen.ts +42 -42
- package/src/mtgate_api/core/bodySerializer.gen.ts +100 -100
- package/src/mtgate_api/core/params.gen.ts +176 -176
- package/src/mtgate_api/core/pathSerializer.gen.ts +181 -181
- package/src/mtgate_api/core/queryKeySerializer.gen.ts +136 -136
- package/src/mtgate_api/core/serverSentEvents.gen.ts +266 -266
- package/src/mtgate_api/core/types.gen.ts +118 -118
- package/src/mtgate_api/core/utils.gen.ts +143 -143
- package/src/mtgate_api/index.ts +4 -4
- package/src/mtgate_api/sdk.gen.ts +17 -54
- package/src/mtgate_api/types.gen.ts +5 -239
- package/src/openclaw/client-info.ts +54 -54
- package/src/openclaw/device-auth-utils.ts +26 -26
- package/src/openclaw/device-auth.ts +99 -99
- package/src/openclaw/device-identity.ts +108 -108
- package/src/openclaw/gateway.ts +392 -392
- package/src/openclaw/types.ts +518 -518
- package/src/sbmng/@tanstack/react-query.gen.ts +2967 -3017
- package/src/sbmng/client/client.gen.ts +311 -311
- package/src/sbmng/client/index.ts +25 -25
- package/src/sbmng/client/types.gen.ts +241 -241
- package/src/sbmng/client/utils.gen.ts +332 -332
- package/src/sbmng/client.gen.ts +16 -16
- package/src/sbmng/core/auth.gen.ts +42 -42
- package/src/sbmng/core/bodySerializer.gen.ts +100 -100
- package/src/sbmng/core/params.gen.ts +176 -176
- package/src/sbmng/core/pathSerializer.gen.ts +181 -181
- package/src/sbmng/core/queryKeySerializer.gen.ts +136 -136
- package/src/sbmng/core/serverSentEvents.gen.ts +266 -266
- package/src/sbmng/core/types.gen.ts +118 -118
- package/src/sbmng/core/utils.gen.ts +143 -143
- package/src/sbmng/index.ts +4 -4
- package/src/sbmng/schemas.gen.ts +9671 -9805
- package/src/sbmng/sdk.gen.ts +1755 -1780
- package/src/sbmng/types.gen.ts +7886 -8016
- package/src/supabase/auth-provider.tsx +67 -67
- package/src/supabase/context.tsx +51 -51
- package/src/supabase/cursor-pagination.ts +155 -155
- package/src/supabase/schema/browser.ts +44 -44
- package/src/supabase/schema/index.ts +25 -25
- package/src/supabase/supabase-client.ts +30 -30
- package/src/supabase/supabase.ts +67 -67
- package/src/supabase/use-sb-query/build-query-opts.ts +68 -56
- package/src/supabase/use-sb-query/key.ts +57 -57
- package/src/supabase/use-sb-query/use-query.ts +352 -340
- package/src/supabase/use-sb-query/use-rpc-mutation.ts +83 -83
- package/src/supabase/use-sb-query/use-rpc-query.ts +267 -231
- package/src/supabase/utils.ts +75 -75
- package/src/types/database.schemas.ts +4359 -4378
- package/src/types/database.types.ts +4182 -4288
- package/src/types/index.ts +85 -102
- package/dist/adk/api/client.d.ts +0 -9
- package/dist/adk/api/client.d.ts.map +0 -1
- package/dist/adk/api/client.js +0 -39
- package/dist/adk/api/client.js.map +0 -1
- package/dist/adk/core/constants/tool-icons.d.ts +0 -21
- package/dist/adk/core/constants/tool-icons.d.ts.map +0 -1
- package/dist/adk/core/constants/tool-icons.js +0 -47
- package/dist/adk/core/constants/tool-icons.js.map +0 -1
- package/dist/adk/core/models/AgentBuilder.d.ts +0 -77
- package/dist/adk/core/models/AgentBuilder.d.ts.map +0 -1
- package/dist/adk/core/models/AgentBuilder.js +0 -18
- package/dist/adk/core/models/AgentBuilder.js.map +0 -1
- package/dist/adk/core/models/AgentRunRequest.d.ts +0 -37
- package/dist/adk/core/models/AgentRunRequest.d.ts.map +0 -1
- package/dist/adk/core/models/AgentRunRequest.js +0 -18
- package/dist/adk/core/models/AgentRunRequest.js.map +0 -1
- package/dist/adk/core/models/Eval.d.ts +0 -55
- package/dist/adk/core/models/Eval.d.ts.map +0 -1
- package/dist/adk/core/models/Eval.js +0 -27
- package/dist/adk/core/models/Eval.js.map +0 -1
- package/dist/adk/core/models/LiveRequest.d.ts +0 -23
- package/dist/adk/core/models/LiveRequest.d.ts.map +0 -1
- package/dist/adk/core/models/LiveRequest.js +0 -18
- package/dist/adk/core/models/LiveRequest.js.map +0 -1
- package/dist/adk/core/models/RuntimeConfig.d.ts +0 -32
- package/dist/adk/core/models/RuntimeConfig.d.ts.map +0 -1
- package/dist/adk/core/models/RuntimeConfig.js +0 -18
- package/dist/adk/core/models/RuntimeConfig.js.map +0 -1
- package/dist/adk/core/models/Session.d.ts +0 -117
- package/dist/adk/core/models/Session.d.ts.map +0 -1
- package/dist/adk/core/models/Session.js +0 -31
- package/dist/adk/core/models/Session.js.map +0 -1
- package/dist/adk/core/models/Trace.d.ts +0 -40
- package/dist/adk/core/models/Trace.d.ts.map +0 -1
- package/dist/adk/core/models/Trace.js +0 -2
- package/dist/adk/core/models/Trace.js.map +0 -1
- package/dist/adk/core/models/types.d.ts +0 -338
- package/dist/adk/core/models/types.d.ts.map +0 -1
- package/dist/adk/core/models/types.js +0 -189
- package/dist/adk/core/models/types.js.map +0 -1
- package/dist/lib/utils.d.ts +0 -14
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/utils.js +0 -45
- package/dist/lib/utils.js.map +0 -1
- package/dist/mtgate_api/@tanstack/react-query.gen.d.ts +0 -166
- package/dist/mtgate_api/@tanstack/react-query.gen.d.ts.map +0 -1
- package/dist/mtgate_api/@tanstack/react-query.gen.js +0 -118
- package/dist/mtgate_api/@tanstack/react-query.gen.js.map +0 -1
- package/dist/mtgate_api/schemas.gen.d.ts +0 -233
- package/dist/mtgate_api/schemas.gen.d.ts.map +0 -1
- package/dist/mtgate_api/schemas.gen.js +0 -277
- package/dist/mtgate_api/schemas.gen.js.map +0 -1
- package/dist/mtgate_api/zod.gen.d.ts +0 -321
- package/dist/mtgate_api/zod.gen.d.ts.map +0 -1
- package/dist/mtgate_api/zod.gen.js +0 -148
- package/dist/mtgate_api/zod.gen.js.map +0 -1
- package/dist/mtmai_api/@tanstack/react-query.gen.d.ts +0 -949
- package/dist/mtmai_api/@tanstack/react-query.gen.d.ts.map +0 -1
- package/dist/mtmai_api/@tanstack/react-query.gen.js +0 -917
- package/dist/mtmai_api/@tanstack/react-query.gen.js.map +0 -1
- package/dist/mtmai_api/client/client.gen.d.ts +0 -3
- package/dist/mtmai_api/client/client.gen.d.ts.map +0 -1
- package/dist/mtmai_api/client/client.gen.js +0 -236
- package/dist/mtmai_api/client/client.gen.js.map +0 -1
- package/dist/mtmai_api/client/index.d.ts +0 -9
- package/dist/mtmai_api/client/index.d.ts.map +0 -1
- package/dist/mtmai_api/client/index.js +0 -7
- package/dist/mtmai_api/client/index.js.map +0 -1
- package/dist/mtmai_api/client/types.gen.d.ts +0 -118
- package/dist/mtmai_api/client/types.gen.d.ts.map +0 -1
- package/dist/mtmai_api/client/types.gen.js +0 -3
- package/dist/mtmai_api/client/types.gen.js.map +0 -1
- package/dist/mtmai_api/client/utils.gen.d.ts +0 -34
- package/dist/mtmai_api/client/utils.gen.d.ts.map +0 -1
- package/dist/mtmai_api/client/utils.gen.js +0 -232
- package/dist/mtmai_api/client/utils.gen.js.map +0 -1
- package/dist/mtmai_api/client.gen.d.ts +0 -13
- package/dist/mtmai_api/client.gen.d.ts.map +0 -1
- package/dist/mtmai_api/client.gen.js +0 -4
- package/dist/mtmai_api/client.gen.js.map +0 -1
- package/dist/mtmai_api/core/auth.gen.d.ts +0 -19
- package/dist/mtmai_api/core/auth.gen.d.ts.map +0 -1
- package/dist/mtmai_api/core/auth.gen.js +0 -15
- package/dist/mtmai_api/core/auth.gen.js.map +0 -1
- package/dist/mtmai_api/core/bodySerializer.gen.d.ts +0 -26
- package/dist/mtmai_api/core/bodySerializer.gen.d.ts.map +0 -1
- package/dist/mtmai_api/core/bodySerializer.gen.js +0 -58
- package/dist/mtmai_api/core/bodySerializer.gen.js.map +0 -1
- package/dist/mtmai_api/core/params.gen.d.ts +0 -44
- package/dist/mtmai_api/core/params.gen.d.ts.map +0 -1
- package/dist/mtmai_api/core/params.gen.js +0 -101
- package/dist/mtmai_api/core/params.gen.js.map +0 -1
- package/dist/mtmai_api/core/pathSerializer.gen.d.ts +0 -34
- package/dist/mtmai_api/core/pathSerializer.gen.d.ts.map +0 -1
- package/dist/mtmai_api/core/pathSerializer.gen.js +0 -115
- package/dist/mtmai_api/core/pathSerializer.gen.js.map +0 -1
- package/dist/mtmai_api/core/queryKeySerializer.gen.d.ts +0 -19
- package/dist/mtmai_api/core/queryKeySerializer.gen.d.ts.map +0 -1
- package/dist/mtmai_api/core/queryKeySerializer.gen.js +0 -100
- package/dist/mtmai_api/core/queryKeySerializer.gen.js.map +0 -1
- package/dist/mtmai_api/core/serverSentEvents.gen.d.ts +0 -72
- package/dist/mtmai_api/core/serverSentEvents.gen.d.ts.map +0 -1
- package/dist/mtmai_api/core/serverSentEvents.gen.js +0 -138
- package/dist/mtmai_api/core/serverSentEvents.gen.js.map +0 -1
- package/dist/mtmai_api/core/types.gen.d.ts +0 -79
- package/dist/mtmai_api/core/types.gen.d.ts.map +0 -1
- package/dist/mtmai_api/core/types.gen.js +0 -3
- package/dist/mtmai_api/core/types.gen.js.map +0 -1
- package/dist/mtmai_api/core/utils.gen.d.ts +0 -20
- package/dist/mtmai_api/core/utils.gen.d.ts.map +0 -1
- package/dist/mtmai_api/core/utils.gen.js +0 -88
- package/dist/mtmai_api/core/utils.gen.js.map +0 -1
- package/dist/mtmai_api/index.d.ts +0 -3
- package/dist/mtmai_api/index.d.ts.map +0 -1
- package/dist/mtmai_api/index.js +0 -4
- package/dist/mtmai_api/index.js.map +0 -1
- package/dist/mtmai_api/schemas.gen.d.ts +0 -7721
- package/dist/mtmai_api/schemas.gen.d.ts.map +0 -1
- package/dist/mtmai_api/schemas.gen.js +0 -9774
- package/dist/mtmai_api/schemas.gen.js.map +0 -1
- package/dist/mtmai_api/sdk.gen.d.ts +0 -282
- package/dist/mtmai_api/sdk.gen.d.ts.map +0 -1
- package/dist/mtmai_api/sdk.gen.js +0 -404
- package/dist/mtmai_api/sdk.gen.js.map +0 -1
- package/dist/mtmai_api/types.gen.d.ts +0 -7152
- package/dist/mtmai_api/types.gen.d.ts.map +0 -1
- package/dist/mtmai_api/types.gen.js +0 -253
- package/dist/mtmai_api/types.gen.js.map +0 -1
- package/dist/mtmai_api/zod.gen.d.ts +0 -55827
- package/dist/mtmai_api/zod.gen.d.ts.map +0 -1
- package/dist/mtmai_api/zod.gen.js +0 -4805
- package/dist/mtmai_api/zod.gen.js.map +0 -1
- package/dist/supabase/use-sb-query/prefetch.d.ts +0 -10
- package/dist/supabase/use-sb-query/prefetch.d.ts.map +0 -1
- package/dist/supabase/use-sb-query/prefetch.js +0 -14
- package/dist/supabase/use-sb-query/prefetch.js.map +0 -1
- package/src/adk/api/client.ts +0 -46
- package/src/adk/core/constants/tool-icons.ts +0 -51
- package/src/adk/core/models/AgentBuilder.ts +0 -80
- package/src/adk/core/models/AgentRunRequest.ts +0 -33
- package/src/adk/core/models/Eval.ts +0 -70
- package/src/adk/core/models/LiveRequest.ts +0 -23
- package/src/adk/core/models/RuntimeConfig.ts +0 -33
- package/src/adk/core/models/Session.ts +0 -52
- package/src/adk/core/models/Trace.ts +0 -42
- package/src/adk/core/models/types.ts +0 -255
- package/src/lib/utils.ts +0 -54
- package/src/mtgate_api/@tanstack/react-query.gen.ts +0 -142
- package/src/mtgate_api/schemas.gen.ts +0 -290
- package/src/mtgate_api/zod.gen.ts +0 -176
- package/src/mtmai_api/@tanstack/react-query.gen.ts +0 -1010
- package/src/mtmai_api/client/client.gen.ts +0 -311
- package/src/mtmai_api/client/index.ts +0 -25
- package/src/mtmai_api/client/types.gen.ts +0 -241
- package/src/mtmai_api/client/utils.gen.ts +0 -332
- package/src/mtmai_api/client.gen.ts +0 -16
- package/src/mtmai_api/core/auth.gen.ts +0 -42
- package/src/mtmai_api/core/bodySerializer.gen.ts +0 -100
- package/src/mtmai_api/core/params.gen.ts +0 -176
- package/src/mtmai_api/core/pathSerializer.gen.ts +0 -181
- package/src/mtmai_api/core/queryKeySerializer.gen.ts +0 -136
- package/src/mtmai_api/core/serverSentEvents.gen.ts +0 -266
- package/src/mtmai_api/core/types.gen.ts +0 -118
- package/src/mtmai_api/core/utils.gen.ts +0 -143
- package/src/mtmai_api/index.ts +0 -4
- package/src/mtmai_api/schemas.gen.ts +0 -9980
- package/src/mtmai_api/sdk.gen.ts +0 -471
- package/src/mtmai_api/types.gen.ts +0 -7609
- package/src/mtmai_api/zod.gen.ts +0 -5101
- package/src/supabase/use-sb-query/prefetch.ts +0 -59
package/src/sbmng/client.gen.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
|
|
3
|
-
import { type ClientOptions, type Config, createClient, createConfig } from './client';
|
|
4
|
-
import type { ClientOptions as ClientOptions2 } from './types.gen';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The `createClientConfig()` function will be called on client initialization
|
|
8
|
-
* and the returned object will become the client's initial configuration.
|
|
9
|
-
*
|
|
10
|
-
* You may want to initialize your client this way instead of calling
|
|
11
|
-
* `setConfig()`. This is useful for example if you're using Next.js
|
|
12
|
-
* to ensure your client always has the correct values.
|
|
13
|
-
*/
|
|
14
|
-
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
15
|
-
|
|
16
|
-
export const client = createClient(createConfig<ClientOptions2>());
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import { type ClientOptions, type Config, createClient, createConfig } from './client';
|
|
4
|
+
import type { ClientOptions as ClientOptions2 } from './types.gen';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
8
|
+
* and the returned object will become the client's initial configuration.
|
|
9
|
+
*
|
|
10
|
+
* You may want to initialize your client this way instead of calling
|
|
11
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
12
|
+
* to ensure your client always has the correct values.
|
|
13
|
+
*/
|
|
14
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
15
|
+
|
|
16
|
+
export const client = createClient(createConfig<ClientOptions2>());
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
|
|
3
|
-
export type AuthToken = string | undefined;
|
|
4
|
-
|
|
5
|
-
export interface Auth {
|
|
6
|
-
/**
|
|
7
|
-
* Which part of the request do we use to send the auth?
|
|
8
|
-
*
|
|
9
|
-
* @default 'header'
|
|
10
|
-
*/
|
|
11
|
-
in?: 'header' | 'query' | 'cookie';
|
|
12
|
-
/**
|
|
13
|
-
* Header or query parameter name.
|
|
14
|
-
*
|
|
15
|
-
* @default 'Authorization'
|
|
16
|
-
*/
|
|
17
|
-
name?: string;
|
|
18
|
-
scheme?: 'basic' | 'bearer';
|
|
19
|
-
type: 'apiKey' | 'http';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const getAuthToken = async (
|
|
23
|
-
auth: Auth,
|
|
24
|
-
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
|
|
25
|
-
): Promise<string | undefined> => {
|
|
26
|
-
const token =
|
|
27
|
-
typeof callback === 'function' ? await callback(auth) : callback;
|
|
28
|
-
|
|
29
|
-
if (!token) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (auth.scheme === 'bearer') {
|
|
34
|
-
return `Bearer ${token}`;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (auth.scheme === 'basic') {
|
|
38
|
-
return `Basic ${btoa(token)}`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return token;
|
|
42
|
-
};
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
export type AuthToken = string | undefined;
|
|
4
|
+
|
|
5
|
+
export interface Auth {
|
|
6
|
+
/**
|
|
7
|
+
* Which part of the request do we use to send the auth?
|
|
8
|
+
*
|
|
9
|
+
* @default 'header'
|
|
10
|
+
*/
|
|
11
|
+
in?: 'header' | 'query' | 'cookie';
|
|
12
|
+
/**
|
|
13
|
+
* Header or query parameter name.
|
|
14
|
+
*
|
|
15
|
+
* @default 'Authorization'
|
|
16
|
+
*/
|
|
17
|
+
name?: string;
|
|
18
|
+
scheme?: 'basic' | 'bearer';
|
|
19
|
+
type: 'apiKey' | 'http';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const getAuthToken = async (
|
|
23
|
+
auth: Auth,
|
|
24
|
+
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
|
|
25
|
+
): Promise<string | undefined> => {
|
|
26
|
+
const token =
|
|
27
|
+
typeof callback === 'function' ? await callback(auth) : callback;
|
|
28
|
+
|
|
29
|
+
if (!token) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (auth.scheme === 'bearer') {
|
|
34
|
+
return `Bearer ${token}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (auth.scheme === 'basic') {
|
|
38
|
+
return `Basic ${btoa(token)}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return token;
|
|
42
|
+
};
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
ArrayStyle,
|
|
5
|
-
ObjectStyle,
|
|
6
|
-
SerializerOptions,
|
|
7
|
-
} from './pathSerializer.gen';
|
|
8
|
-
|
|
9
|
-
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
|
10
|
-
|
|
11
|
-
export type BodySerializer = (body: any) => any;
|
|
12
|
-
|
|
13
|
-
type QuerySerializerOptionsObject = {
|
|
14
|
-
allowReserved?: boolean;
|
|
15
|
-
array?: Partial<SerializerOptions<ArrayStyle>>;
|
|
16
|
-
object?: Partial<SerializerOptions<ObjectStyle>>;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
|
20
|
-
/**
|
|
21
|
-
* Per-parameter serialization overrides. When provided, these settings
|
|
22
|
-
* override the global array/object settings for specific parameter names.
|
|
23
|
-
*/
|
|
24
|
-
parameters?: Record<string, QuerySerializerOptionsObject>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const serializeFormDataPair = (
|
|
28
|
-
data: FormData,
|
|
29
|
-
key: string,
|
|
30
|
-
value: unknown,
|
|
31
|
-
): void => {
|
|
32
|
-
if (typeof value === 'string' || value instanceof Blob) {
|
|
33
|
-
data.append(key, value);
|
|
34
|
-
} else if (value instanceof Date) {
|
|
35
|
-
data.append(key, value.toISOString());
|
|
36
|
-
} else {
|
|
37
|
-
data.append(key, JSON.stringify(value));
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const serializeUrlSearchParamsPair = (
|
|
42
|
-
data: URLSearchParams,
|
|
43
|
-
key: string,
|
|
44
|
-
value: unknown,
|
|
45
|
-
): void => {
|
|
46
|
-
if (typeof value === 'string') {
|
|
47
|
-
data.append(key, value);
|
|
48
|
-
} else {
|
|
49
|
-
data.append(key, JSON.stringify(value));
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const formDataBodySerializer = {
|
|
54
|
-
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
|
|
55
|
-
body: T,
|
|
56
|
-
): FormData => {
|
|
57
|
-
const data = new FormData();
|
|
58
|
-
|
|
59
|
-
Object.entries(body).forEach(([key, value]) => {
|
|
60
|
-
if (value === undefined || value === null) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
if (Array.isArray(value)) {
|
|
64
|
-
value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
65
|
-
} else {
|
|
66
|
-
serializeFormDataPair(data, key, value);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
return data;
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const jsonBodySerializer = {
|
|
75
|
-
bodySerializer: <T>(body: T): string =>
|
|
76
|
-
JSON.stringify(body, (_key, value) =>
|
|
77
|
-
typeof value === 'bigint' ? value.toString() : value,
|
|
78
|
-
),
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const urlSearchParamsBodySerializer = {
|
|
82
|
-
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
|
|
83
|
-
body: T,
|
|
84
|
-
): string => {
|
|
85
|
-
const data = new URLSearchParams();
|
|
86
|
-
|
|
87
|
-
Object.entries(body).forEach(([key, value]) => {
|
|
88
|
-
if (value === undefined || value === null) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (Array.isArray(value)) {
|
|
92
|
-
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
93
|
-
} else {
|
|
94
|
-
serializeUrlSearchParamsPair(data, key, value);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
return data.toString();
|
|
99
|
-
},
|
|
100
|
-
};
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ArrayStyle,
|
|
5
|
+
ObjectStyle,
|
|
6
|
+
SerializerOptions,
|
|
7
|
+
} from './pathSerializer.gen';
|
|
8
|
+
|
|
9
|
+
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
|
10
|
+
|
|
11
|
+
export type BodySerializer = (body: any) => any;
|
|
12
|
+
|
|
13
|
+
type QuerySerializerOptionsObject = {
|
|
14
|
+
allowReserved?: boolean;
|
|
15
|
+
array?: Partial<SerializerOptions<ArrayStyle>>;
|
|
16
|
+
object?: Partial<SerializerOptions<ObjectStyle>>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
|
20
|
+
/**
|
|
21
|
+
* Per-parameter serialization overrides. When provided, these settings
|
|
22
|
+
* override the global array/object settings for specific parameter names.
|
|
23
|
+
*/
|
|
24
|
+
parameters?: Record<string, QuerySerializerOptionsObject>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const serializeFormDataPair = (
|
|
28
|
+
data: FormData,
|
|
29
|
+
key: string,
|
|
30
|
+
value: unknown,
|
|
31
|
+
): void => {
|
|
32
|
+
if (typeof value === 'string' || value instanceof Blob) {
|
|
33
|
+
data.append(key, value);
|
|
34
|
+
} else if (value instanceof Date) {
|
|
35
|
+
data.append(key, value.toISOString());
|
|
36
|
+
} else {
|
|
37
|
+
data.append(key, JSON.stringify(value));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const serializeUrlSearchParamsPair = (
|
|
42
|
+
data: URLSearchParams,
|
|
43
|
+
key: string,
|
|
44
|
+
value: unknown,
|
|
45
|
+
): void => {
|
|
46
|
+
if (typeof value === 'string') {
|
|
47
|
+
data.append(key, value);
|
|
48
|
+
} else {
|
|
49
|
+
data.append(key, JSON.stringify(value));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const formDataBodySerializer = {
|
|
54
|
+
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
|
|
55
|
+
body: T,
|
|
56
|
+
): FormData => {
|
|
57
|
+
const data = new FormData();
|
|
58
|
+
|
|
59
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
60
|
+
if (value === undefined || value === null) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (Array.isArray(value)) {
|
|
64
|
+
value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
65
|
+
} else {
|
|
66
|
+
serializeFormDataPair(data, key, value);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return data;
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const jsonBodySerializer = {
|
|
75
|
+
bodySerializer: <T>(body: T): string =>
|
|
76
|
+
JSON.stringify(body, (_key, value) =>
|
|
77
|
+
typeof value === 'bigint' ? value.toString() : value,
|
|
78
|
+
),
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const urlSearchParamsBodySerializer = {
|
|
82
|
+
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
|
|
83
|
+
body: T,
|
|
84
|
+
): string => {
|
|
85
|
+
const data = new URLSearchParams();
|
|
86
|
+
|
|
87
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
88
|
+
if (value === undefined || value === null) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (Array.isArray(value)) {
|
|
92
|
+
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
93
|
+
} else {
|
|
94
|
+
serializeUrlSearchParamsPair(data, key, value);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return data.toString();
|
|
99
|
+
},
|
|
100
|
+
};
|
|
@@ -1,176 +1,176 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
|
|
3
|
-
type Slot = 'body' | 'headers' | 'path' | 'query';
|
|
4
|
-
|
|
5
|
-
export type Field =
|
|
6
|
-
| {
|
|
7
|
-
in: Exclude<Slot, 'body'>;
|
|
8
|
-
/**
|
|
9
|
-
* Field name. This is the name we want the user to see and use.
|
|
10
|
-
*/
|
|
11
|
-
key: string;
|
|
12
|
-
/**
|
|
13
|
-
* Field mapped name. This is the name we want to use in the request.
|
|
14
|
-
* If omitted, we use the same value as `key`.
|
|
15
|
-
*/
|
|
16
|
-
map?: string;
|
|
17
|
-
}
|
|
18
|
-
| {
|
|
19
|
-
in: Extract<Slot, 'body'>;
|
|
20
|
-
/**
|
|
21
|
-
* Key isn't required for bodies.
|
|
22
|
-
*/
|
|
23
|
-
key?: string;
|
|
24
|
-
map?: string;
|
|
25
|
-
}
|
|
26
|
-
| {
|
|
27
|
-
/**
|
|
28
|
-
* Field name. This is the name we want the user to see and use.
|
|
29
|
-
*/
|
|
30
|
-
key: string;
|
|
31
|
-
/**
|
|
32
|
-
* Field mapped name. This is the name we want to use in the request.
|
|
33
|
-
* If `in` is omitted, `map` aliases `key` to the transport layer.
|
|
34
|
-
*/
|
|
35
|
-
map: Slot;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export interface Fields {
|
|
39
|
-
allowExtra?: Partial<Record<Slot, boolean>>;
|
|
40
|
-
args?: ReadonlyArray<Field>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
|
44
|
-
|
|
45
|
-
const extraPrefixesMap: Record<string, Slot> = {
|
|
46
|
-
$body_: 'body',
|
|
47
|
-
$headers_: 'headers',
|
|
48
|
-
$path_: 'path',
|
|
49
|
-
$query_: 'query',
|
|
50
|
-
};
|
|
51
|
-
const extraPrefixes = Object.entries(extraPrefixesMap);
|
|
52
|
-
|
|
53
|
-
type KeyMap = Map<
|
|
54
|
-
string,
|
|
55
|
-
| {
|
|
56
|
-
in: Slot;
|
|
57
|
-
map?: string;
|
|
58
|
-
}
|
|
59
|
-
| {
|
|
60
|
-
in?: never;
|
|
61
|
-
map: Slot;
|
|
62
|
-
}
|
|
63
|
-
>;
|
|
64
|
-
|
|
65
|
-
const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
|
|
66
|
-
if (!map) {
|
|
67
|
-
map = new Map();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
for (const config of fields) {
|
|
71
|
-
if ('in' in config) {
|
|
72
|
-
if (config.key) {
|
|
73
|
-
map.set(config.key, {
|
|
74
|
-
in: config.in,
|
|
75
|
-
map: config.map,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
} else if ('key' in config) {
|
|
79
|
-
map.set(config.key, {
|
|
80
|
-
map: config.map,
|
|
81
|
-
});
|
|
82
|
-
} else if (config.args) {
|
|
83
|
-
buildKeyMap(config.args, map);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return map;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
interface Params {
|
|
91
|
-
body: unknown;
|
|
92
|
-
headers: Record<string, unknown>;
|
|
93
|
-
path: Record<string, unknown>;
|
|
94
|
-
query: Record<string, unknown>;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const stripEmptySlots = (params: Params) => {
|
|
98
|
-
for (const [slot, value] of Object.entries(params)) {
|
|
99
|
-
if (value && typeof value === 'object' && !Object.keys(value).length) {
|
|
100
|
-
delete params[slot as Slot];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export const buildClientParams = (
|
|
106
|
-
args: ReadonlyArray<unknown>,
|
|
107
|
-
fields: FieldsConfig,
|
|
108
|
-
) => {
|
|
109
|
-
const params: Params = {
|
|
110
|
-
body: {},
|
|
111
|
-
headers: {},
|
|
112
|
-
path: {},
|
|
113
|
-
query: {},
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const map = buildKeyMap(fields);
|
|
117
|
-
|
|
118
|
-
let config: FieldsConfig[number] | undefined;
|
|
119
|
-
|
|
120
|
-
for (const [index, arg] of args.entries()) {
|
|
121
|
-
if (fields[index]) {
|
|
122
|
-
config = fields[index];
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (!config) {
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if ('in' in config) {
|
|
130
|
-
if (config.key) {
|
|
131
|
-
const field = map.get(config.key)!;
|
|
132
|
-
const name = field.map || config.key;
|
|
133
|
-
if (field.in) {
|
|
134
|
-
(params[field.in] as Record<string, unknown>)[name] = arg;
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
params.body = arg;
|
|
138
|
-
}
|
|
139
|
-
} else {
|
|
140
|
-
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
141
|
-
const field = map.get(key);
|
|
142
|
-
|
|
143
|
-
if (field) {
|
|
144
|
-
if (field.in) {
|
|
145
|
-
const name = field.map || key;
|
|
146
|
-
(params[field.in] as Record<string, unknown>)[name] = value;
|
|
147
|
-
} else {
|
|
148
|
-
params[field.map] = value;
|
|
149
|
-
}
|
|
150
|
-
} else {
|
|
151
|
-
const extra = extraPrefixes.find(([prefix]) =>
|
|
152
|
-
key.startsWith(prefix),
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
if (extra) {
|
|
156
|
-
const [prefix, slot] = extra;
|
|
157
|
-
(params[slot] as Record<string, unknown>)[
|
|
158
|
-
key.slice(prefix.length)
|
|
159
|
-
] = value;
|
|
160
|
-
} else if ('allowExtra' in config && config.allowExtra) {
|
|
161
|
-
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
|
162
|
-
if (allowed) {
|
|
163
|
-
(params[slot as Slot] as Record<string, unknown>)[key] = value;
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
stripEmptySlots(params);
|
|
174
|
-
|
|
175
|
-
return params;
|
|
176
|
-
};
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
type Slot = 'body' | 'headers' | 'path' | 'query';
|
|
4
|
+
|
|
5
|
+
export type Field =
|
|
6
|
+
| {
|
|
7
|
+
in: Exclude<Slot, 'body'>;
|
|
8
|
+
/**
|
|
9
|
+
* Field name. This is the name we want the user to see and use.
|
|
10
|
+
*/
|
|
11
|
+
key: string;
|
|
12
|
+
/**
|
|
13
|
+
* Field mapped name. This is the name we want to use in the request.
|
|
14
|
+
* If omitted, we use the same value as `key`.
|
|
15
|
+
*/
|
|
16
|
+
map?: string;
|
|
17
|
+
}
|
|
18
|
+
| {
|
|
19
|
+
in: Extract<Slot, 'body'>;
|
|
20
|
+
/**
|
|
21
|
+
* Key isn't required for bodies.
|
|
22
|
+
*/
|
|
23
|
+
key?: string;
|
|
24
|
+
map?: string;
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
/**
|
|
28
|
+
* Field name. This is the name we want the user to see and use.
|
|
29
|
+
*/
|
|
30
|
+
key: string;
|
|
31
|
+
/**
|
|
32
|
+
* Field mapped name. This is the name we want to use in the request.
|
|
33
|
+
* If `in` is omitted, `map` aliases `key` to the transport layer.
|
|
34
|
+
*/
|
|
35
|
+
map: Slot;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export interface Fields {
|
|
39
|
+
allowExtra?: Partial<Record<Slot, boolean>>;
|
|
40
|
+
args?: ReadonlyArray<Field>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
|
44
|
+
|
|
45
|
+
const extraPrefixesMap: Record<string, Slot> = {
|
|
46
|
+
$body_: 'body',
|
|
47
|
+
$headers_: 'headers',
|
|
48
|
+
$path_: 'path',
|
|
49
|
+
$query_: 'query',
|
|
50
|
+
};
|
|
51
|
+
const extraPrefixes = Object.entries(extraPrefixesMap);
|
|
52
|
+
|
|
53
|
+
type KeyMap = Map<
|
|
54
|
+
string,
|
|
55
|
+
| {
|
|
56
|
+
in: Slot;
|
|
57
|
+
map?: string;
|
|
58
|
+
}
|
|
59
|
+
| {
|
|
60
|
+
in?: never;
|
|
61
|
+
map: Slot;
|
|
62
|
+
}
|
|
63
|
+
>;
|
|
64
|
+
|
|
65
|
+
const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
|
|
66
|
+
if (!map) {
|
|
67
|
+
map = new Map();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
for (const config of fields) {
|
|
71
|
+
if ('in' in config) {
|
|
72
|
+
if (config.key) {
|
|
73
|
+
map.set(config.key, {
|
|
74
|
+
in: config.in,
|
|
75
|
+
map: config.map,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
} else if ('key' in config) {
|
|
79
|
+
map.set(config.key, {
|
|
80
|
+
map: config.map,
|
|
81
|
+
});
|
|
82
|
+
} else if (config.args) {
|
|
83
|
+
buildKeyMap(config.args, map);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return map;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
interface Params {
|
|
91
|
+
body: unknown;
|
|
92
|
+
headers: Record<string, unknown>;
|
|
93
|
+
path: Record<string, unknown>;
|
|
94
|
+
query: Record<string, unknown>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const stripEmptySlots = (params: Params) => {
|
|
98
|
+
for (const [slot, value] of Object.entries(params)) {
|
|
99
|
+
if (value && typeof value === 'object' && !Object.keys(value).length) {
|
|
100
|
+
delete params[slot as Slot];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const buildClientParams = (
|
|
106
|
+
args: ReadonlyArray<unknown>,
|
|
107
|
+
fields: FieldsConfig,
|
|
108
|
+
) => {
|
|
109
|
+
const params: Params = {
|
|
110
|
+
body: {},
|
|
111
|
+
headers: {},
|
|
112
|
+
path: {},
|
|
113
|
+
query: {},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const map = buildKeyMap(fields);
|
|
117
|
+
|
|
118
|
+
let config: FieldsConfig[number] | undefined;
|
|
119
|
+
|
|
120
|
+
for (const [index, arg] of args.entries()) {
|
|
121
|
+
if (fields[index]) {
|
|
122
|
+
config = fields[index];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (!config) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if ('in' in config) {
|
|
130
|
+
if (config.key) {
|
|
131
|
+
const field = map.get(config.key)!;
|
|
132
|
+
const name = field.map || config.key;
|
|
133
|
+
if (field.in) {
|
|
134
|
+
(params[field.in] as Record<string, unknown>)[name] = arg;
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
params.body = arg;
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
141
|
+
const field = map.get(key);
|
|
142
|
+
|
|
143
|
+
if (field) {
|
|
144
|
+
if (field.in) {
|
|
145
|
+
const name = field.map || key;
|
|
146
|
+
(params[field.in] as Record<string, unknown>)[name] = value;
|
|
147
|
+
} else {
|
|
148
|
+
params[field.map] = value;
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
const extra = extraPrefixes.find(([prefix]) =>
|
|
152
|
+
key.startsWith(prefix),
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
if (extra) {
|
|
156
|
+
const [prefix, slot] = extra;
|
|
157
|
+
(params[slot] as Record<string, unknown>)[
|
|
158
|
+
key.slice(prefix.length)
|
|
159
|
+
] = value;
|
|
160
|
+
} else if ('allowExtra' in config && config.allowExtra) {
|
|
161
|
+
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
|
162
|
+
if (allowed) {
|
|
163
|
+
(params[slot as Slot] as Record<string, unknown>)[key] = value;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
stripEmptySlots(params);
|
|
174
|
+
|
|
175
|
+
return params;
|
|
176
|
+
};
|