@silvana-one/api 1.0.23 → 1.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/node/client/client/client.d.ts +2 -0
  2. package/dist/node/client/client/client.js +146 -0
  3. package/dist/node/client/client/client.js.map +1 -0
  4. package/dist/node/client/client/index.d.ts +7 -0
  5. package/dist/node/client/client/index.js +5 -0
  6. package/dist/node/client/client/index.js.map +1 -0
  7. package/dist/node/client/client/types.d.ts +119 -0
  8. package/dist/node/client/client/types.js +2 -0
  9. package/dist/node/client/client/types.js.map +1 -0
  10. package/dist/node/client/client/utils.d.ts +45 -0
  11. package/dist/node/client/client/utils.js +284 -0
  12. package/dist/node/client/client/utils.js.map +1 -0
  13. package/dist/node/client/client.gen.d.ts +2 -2
  14. package/dist/node/client/client.gen.js +1 -1
  15. package/dist/node/client/client.gen.js.map +1 -1
  16. package/dist/node/client/core/auth.d.ts +18 -0
  17. package/dist/node/client/core/auth.js +14 -0
  18. package/dist/node/client/core/auth.js.map +1 -0
  19. package/dist/node/client/core/bodySerializer.d.ts +17 -0
  20. package/dist/node/client/core/bodySerializer.js +54 -0
  21. package/dist/node/client/core/bodySerializer.js.map +1 -0
  22. package/dist/node/client/core/params.d.ts +23 -0
  23. package/dist/node/client/core/params.js +88 -0
  24. package/dist/node/client/core/params.js.map +1 -0
  25. package/dist/node/client/core/pathSerializer.d.ts +33 -0
  26. package/dist/node/client/core/pathSerializer.js +114 -0
  27. package/dist/node/client/core/pathSerializer.js.map +1 -0
  28. package/dist/node/client/core/types.d.ts +73 -0
  29. package/dist/node/client/core/types.js +2 -0
  30. package/dist/node/client/core/types.js.map +1 -0
  31. package/dist/node/client/sdk.gen.d.ts +38 -38
  32. package/dist/node/index.cjs +530 -2
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/dist/tsconfig.web.tsbuildinfo +1 -1
  35. package/dist/web/client/client/client.d.ts +2 -0
  36. package/dist/web/client/client/client.js +146 -0
  37. package/dist/web/client/client/client.js.map +1 -0
  38. package/dist/web/client/client/index.d.ts +7 -0
  39. package/dist/web/client/client/index.js +5 -0
  40. package/dist/web/client/client/index.js.map +1 -0
  41. package/dist/web/client/client/types.d.ts +119 -0
  42. package/dist/web/client/client/types.js +2 -0
  43. package/dist/web/client/client/types.js.map +1 -0
  44. package/dist/web/client/client/utils.d.ts +45 -0
  45. package/dist/web/client/client/utils.js +284 -0
  46. package/dist/web/client/client/utils.js.map +1 -0
  47. package/dist/web/client/client.gen.d.ts +2 -2
  48. package/dist/web/client/client.gen.js +1 -1
  49. package/dist/web/client/client.gen.js.map +1 -1
  50. package/dist/web/client/core/auth.d.ts +18 -0
  51. package/dist/web/client/core/auth.js +14 -0
  52. package/dist/web/client/core/auth.js.map +1 -0
  53. package/dist/web/client/core/bodySerializer.d.ts +17 -0
  54. package/dist/web/client/core/bodySerializer.js +54 -0
  55. package/dist/web/client/core/bodySerializer.js.map +1 -0
  56. package/dist/web/client/core/params.d.ts +23 -0
  57. package/dist/web/client/core/params.js +88 -0
  58. package/dist/web/client/core/params.js.map +1 -0
  59. package/dist/web/client/core/pathSerializer.d.ts +33 -0
  60. package/dist/web/client/core/pathSerializer.js +114 -0
  61. package/dist/web/client/core/pathSerializer.js.map +1 -0
  62. package/dist/web/client/core/types.d.ts +73 -0
  63. package/dist/web/client/core/types.js +2 -0
  64. package/dist/web/client/core/types.js.map +1 -0
  65. package/dist/web/client/sdk.gen.d.ts +38 -38
  66. package/package.json +4 -7
  67. package/src/client/client/client.ts +195 -0
  68. package/src/client/client/index.ts +22 -0
  69. package/src/client/client/types.ts +222 -0
  70. package/src/client/client/utils.ts +417 -0
  71. package/src/client/client.gen.ts +1 -1
  72. package/src/client/core/auth.ts +40 -0
  73. package/src/client/core/bodySerializer.ts +88 -0
  74. package/src/client/core/params.ts +141 -0
  75. package/src/client/core/pathSerializer.ts +179 -0
  76. package/src/client/core/types.ts +104 -0
  77. package/src/client/sdk.gen.ts +1 -1
@@ -0,0 +1,88 @@
1
+ import type {
2
+ ArrayStyle,
3
+ ObjectStyle,
4
+ SerializerOptions,
5
+ } from './pathSerializer.js';
6
+
7
+ export type QuerySerializer = (query: Record<string, unknown>) => string;
8
+
9
+ export type BodySerializer = (body: any) => any;
10
+
11
+ export interface QuerySerializerOptions {
12
+ allowReserved?: boolean;
13
+ array?: SerializerOptions<ArrayStyle>;
14
+ object?: SerializerOptions<ObjectStyle>;
15
+ }
16
+
17
+ const serializeFormDataPair = (
18
+ data: FormData,
19
+ key: string,
20
+ value: unknown,
21
+ ): void => {
22
+ if (typeof value === 'string' || value instanceof Blob) {
23
+ data.append(key, value);
24
+ } else {
25
+ data.append(key, JSON.stringify(value));
26
+ }
27
+ };
28
+
29
+ const serializeUrlSearchParamsPair = (
30
+ data: URLSearchParams,
31
+ key: string,
32
+ value: unknown,
33
+ ): void => {
34
+ if (typeof value === 'string') {
35
+ data.append(key, value);
36
+ } else {
37
+ data.append(key, JSON.stringify(value));
38
+ }
39
+ };
40
+
41
+ export const formDataBodySerializer = {
42
+ bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
43
+ body: T,
44
+ ): FormData => {
45
+ const data = new FormData();
46
+
47
+ Object.entries(body).forEach(([key, value]) => {
48
+ if (value === undefined || value === null) {
49
+ return;
50
+ }
51
+ if (Array.isArray(value)) {
52
+ value.forEach((v) => serializeFormDataPair(data, key, v));
53
+ } else {
54
+ serializeFormDataPair(data, key, value);
55
+ }
56
+ });
57
+
58
+ return data;
59
+ },
60
+ };
61
+
62
+ export const jsonBodySerializer = {
63
+ bodySerializer: <T>(body: T): string =>
64
+ JSON.stringify(body, (_key, value) =>
65
+ typeof value === 'bigint' ? value.toString() : value,
66
+ ),
67
+ };
68
+
69
+ export const urlSearchParamsBodySerializer = {
70
+ bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
71
+ body: T,
72
+ ): string => {
73
+ const data = new URLSearchParams();
74
+
75
+ Object.entries(body).forEach(([key, value]) => {
76
+ if (value === undefined || value === null) {
77
+ return;
78
+ }
79
+ if (Array.isArray(value)) {
80
+ value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
81
+ } else {
82
+ serializeUrlSearchParamsPair(data, key, value);
83
+ }
84
+ });
85
+
86
+ return data.toString();
87
+ },
88
+ };
@@ -0,0 +1,141 @@
1
+ type Slot = 'body' | 'headers' | 'path' | 'query';
2
+
3
+ export type Field =
4
+ | {
5
+ in: Exclude<Slot, 'body'>;
6
+ key: string;
7
+ map?: string;
8
+ }
9
+ | {
10
+ in: Extract<Slot, 'body'>;
11
+ key?: string;
12
+ map?: string;
13
+ };
14
+
15
+ export interface Fields {
16
+ allowExtra?: Partial<Record<Slot, boolean>>;
17
+ args?: ReadonlyArray<Field>;
18
+ }
19
+
20
+ export type FieldsConfig = ReadonlyArray<Field | Fields>;
21
+
22
+ const extraPrefixesMap: Record<string, Slot> = {
23
+ $body_: 'body',
24
+ $headers_: 'headers',
25
+ $path_: 'path',
26
+ $query_: 'query',
27
+ };
28
+ const extraPrefixes = Object.entries(extraPrefixesMap);
29
+
30
+ type KeyMap = Map<
31
+ string,
32
+ {
33
+ in: Slot;
34
+ map?: string;
35
+ }
36
+ >;
37
+
38
+ const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
39
+ if (!map) {
40
+ map = new Map();
41
+ }
42
+
43
+ for (const config of fields) {
44
+ if ('in' in config) {
45
+ if (config.key) {
46
+ map.set(config.key, {
47
+ in: config.in,
48
+ map: config.map,
49
+ });
50
+ }
51
+ } else if (config.args) {
52
+ buildKeyMap(config.args, map);
53
+ }
54
+ }
55
+
56
+ return map;
57
+ };
58
+
59
+ interface Params {
60
+ body: unknown;
61
+ headers: Record<string, unknown>;
62
+ path: Record<string, unknown>;
63
+ query: Record<string, unknown>;
64
+ }
65
+
66
+ const stripEmptySlots = (params: Params) => {
67
+ for (const [slot, value] of Object.entries(params)) {
68
+ if (value && typeof value === 'object' && !Object.keys(value).length) {
69
+ delete params[slot as Slot];
70
+ }
71
+ }
72
+ };
73
+
74
+ export const buildClientParams = (
75
+ args: ReadonlyArray<unknown>,
76
+ fields: FieldsConfig,
77
+ ) => {
78
+ const params: Params = {
79
+ body: {},
80
+ headers: {},
81
+ path: {},
82
+ query: {},
83
+ };
84
+
85
+ const map = buildKeyMap(fields);
86
+
87
+ let config: FieldsConfig[number] | undefined;
88
+
89
+ for (const [index, arg] of args.entries()) {
90
+ if (fields[index]) {
91
+ config = fields[index];
92
+ }
93
+
94
+ if (!config) {
95
+ continue;
96
+ }
97
+
98
+ if ('in' in config) {
99
+ if (config.key) {
100
+ const field = map.get(config.key)!;
101
+ const name = field.map || config.key;
102
+ (params[field.in] as Record<string, unknown>)[name] = arg;
103
+ } else {
104
+ params.body = arg;
105
+ }
106
+ } else {
107
+ for (const [key, value] of Object.entries(arg ?? {})) {
108
+ const field = map.get(key);
109
+
110
+ if (field) {
111
+ const name = field.map || key;
112
+ (params[field.in] as Record<string, unknown>)[name] = value;
113
+ } else {
114
+ const extra = extraPrefixes.find(([prefix]) =>
115
+ key.startsWith(prefix),
116
+ );
117
+
118
+ if (extra) {
119
+ const [prefix, slot] = extra;
120
+ (params[slot] as Record<string, unknown>)[
121
+ key.slice(prefix.length)
122
+ ] = value;
123
+ } else {
124
+ for (const [slot, allowed] of Object.entries(
125
+ config.allowExtra ?? {},
126
+ )) {
127
+ if (allowed) {
128
+ (params[slot as Slot] as Record<string, unknown>)[key] = value;
129
+ break;
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
136
+ }
137
+
138
+ stripEmptySlots(params);
139
+
140
+ return params;
141
+ };
@@ -0,0 +1,179 @@
1
+ interface SerializeOptions<T>
2
+ extends SerializePrimitiveOptions,
3
+ SerializerOptions<T> {}
4
+
5
+ interface SerializePrimitiveOptions {
6
+ allowReserved?: boolean;
7
+ name: string;
8
+ }
9
+
10
+ export interface SerializerOptions<T> {
11
+ /**
12
+ * @default true
13
+ */
14
+ explode: boolean;
15
+ style: T;
16
+ }
17
+
18
+ export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
19
+ export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
20
+ type MatrixStyle = 'label' | 'matrix' | 'simple';
21
+ export type ObjectStyle = 'form' | 'deepObject';
22
+ type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
23
+
24
+ interface SerializePrimitiveParam extends SerializePrimitiveOptions {
25
+ value: string;
26
+ }
27
+
28
+ export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
29
+ switch (style) {
30
+ case 'label':
31
+ return '.';
32
+ case 'matrix':
33
+ return ';';
34
+ case 'simple':
35
+ return ',';
36
+ default:
37
+ return '&';
38
+ }
39
+ };
40
+
41
+ export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
42
+ switch (style) {
43
+ case 'form':
44
+ return ',';
45
+ case 'pipeDelimited':
46
+ return '|';
47
+ case 'spaceDelimited':
48
+ return '%20';
49
+ default:
50
+ return ',';
51
+ }
52
+ };
53
+
54
+ export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
55
+ switch (style) {
56
+ case 'label':
57
+ return '.';
58
+ case 'matrix':
59
+ return ';';
60
+ case 'simple':
61
+ return ',';
62
+ default:
63
+ return '&';
64
+ }
65
+ };
66
+
67
+ export const serializeArrayParam = ({
68
+ allowReserved,
69
+ explode,
70
+ name,
71
+ style,
72
+ value,
73
+ }: SerializeOptions<ArraySeparatorStyle> & {
74
+ value: unknown[];
75
+ }) => {
76
+ if (!explode) {
77
+ const joinedValues = (
78
+ allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
79
+ ).join(separatorArrayNoExplode(style));
80
+ switch (style) {
81
+ case 'label':
82
+ return `.${joinedValues}`;
83
+ case 'matrix':
84
+ return `;${name}=${joinedValues}`;
85
+ case 'simple':
86
+ return joinedValues;
87
+ default:
88
+ return `${name}=${joinedValues}`;
89
+ }
90
+ }
91
+
92
+ const separator = separatorArrayExplode(style);
93
+ const joinedValues = value
94
+ .map((v) => {
95
+ if (style === 'label' || style === 'simple') {
96
+ return allowReserved ? v : encodeURIComponent(v as string);
97
+ }
98
+
99
+ return serializePrimitiveParam({
100
+ allowReserved,
101
+ name,
102
+ value: v as string,
103
+ });
104
+ })
105
+ .join(separator);
106
+ return style === 'label' || style === 'matrix'
107
+ ? separator + joinedValues
108
+ : joinedValues;
109
+ };
110
+
111
+ export const serializePrimitiveParam = ({
112
+ allowReserved,
113
+ name,
114
+ value,
115
+ }: SerializePrimitiveParam) => {
116
+ if (value === undefined || value === null) {
117
+ return '';
118
+ }
119
+
120
+ if (typeof value === 'object') {
121
+ throw new Error(
122
+ 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.',
123
+ );
124
+ }
125
+
126
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
127
+ };
128
+
129
+ export const serializeObjectParam = ({
130
+ allowReserved,
131
+ explode,
132
+ name,
133
+ style,
134
+ value,
135
+ valueOnly,
136
+ }: SerializeOptions<ObjectSeparatorStyle> & {
137
+ value: Record<string, unknown> | Date;
138
+ valueOnly?: boolean;
139
+ }) => {
140
+ if (value instanceof Date) {
141
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
142
+ }
143
+
144
+ if (style !== 'deepObject' && !explode) {
145
+ let values: string[] = [];
146
+ Object.entries(value).forEach(([key, v]) => {
147
+ values = [
148
+ ...values,
149
+ key,
150
+ allowReserved ? (v as string) : encodeURIComponent(v as string),
151
+ ];
152
+ });
153
+ const joinedValues = values.join(',');
154
+ switch (style) {
155
+ case 'form':
156
+ return `${name}=${joinedValues}`;
157
+ case 'label':
158
+ return `.${joinedValues}`;
159
+ case 'matrix':
160
+ return `;${name}=${joinedValues}`;
161
+ default:
162
+ return joinedValues;
163
+ }
164
+ }
165
+
166
+ const separator = separatorObjectExplode(style);
167
+ const joinedValues = Object.entries(value)
168
+ .map(([key, v]) =>
169
+ serializePrimitiveParam({
170
+ allowReserved,
171
+ name: style === 'deepObject' ? `${name}[${key}]` : key,
172
+ value: v as string,
173
+ }),
174
+ )
175
+ .join(separator);
176
+ return style === 'label' || style === 'matrix'
177
+ ? separator + joinedValues
178
+ : joinedValues;
179
+ };
@@ -0,0 +1,104 @@
1
+ import type { Auth, AuthToken } from './auth.js';
2
+ import type {
3
+ BodySerializer,
4
+ QuerySerializer,
5
+ QuerySerializerOptions,
6
+ } from './bodySerializer.js';
7
+
8
+ export interface Client<
9
+ RequestFn = never,
10
+ Config = unknown,
11
+ MethodFn = never,
12
+ BuildUrlFn = never,
13
+ > {
14
+ /**
15
+ * Returns the final request URL.
16
+ */
17
+ buildUrl: BuildUrlFn;
18
+ connect: MethodFn;
19
+ delete: MethodFn;
20
+ get: MethodFn;
21
+ getConfig: () => Config;
22
+ head: MethodFn;
23
+ options: MethodFn;
24
+ patch: MethodFn;
25
+ post: MethodFn;
26
+ put: MethodFn;
27
+ request: RequestFn;
28
+ setConfig: (config: Config) => Config;
29
+ trace: MethodFn;
30
+ }
31
+
32
+ export interface Config {
33
+ /**
34
+ * Auth token or a function returning auth token. The resolved value will be
35
+ * added to the request payload as defined by its `security` array.
36
+ */
37
+ auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
38
+ /**
39
+ * A function for serializing request body parameter. By default,
40
+ * {@link JSON.stringify()} will be used.
41
+ */
42
+ bodySerializer?: BodySerializer | null;
43
+ /**
44
+ * An object containing any HTTP headers that you want to pre-populate your
45
+ * `Headers` object with.
46
+ *
47
+ * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
48
+ */
49
+ headers?:
50
+ | RequestInit['headers']
51
+ | Record<
52
+ string,
53
+ | string
54
+ | number
55
+ | boolean
56
+ | (string | number | boolean)[]
57
+ | null
58
+ | undefined
59
+ | unknown
60
+ >;
61
+ /**
62
+ * The request method.
63
+ *
64
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
65
+ */
66
+ method?:
67
+ | 'CONNECT'
68
+ | 'DELETE'
69
+ | 'GET'
70
+ | 'HEAD'
71
+ | 'OPTIONS'
72
+ | 'PATCH'
73
+ | 'POST'
74
+ | 'PUT'
75
+ | 'TRACE';
76
+ /**
77
+ * A function for serializing request query parameters. By default, arrays
78
+ * will be exploded in form style, objects will be exploded in deepObject
79
+ * style, and reserved characters are percent-encoded.
80
+ *
81
+ * This method will have no effect if the native `paramsSerializer()` Axios
82
+ * API function is used.
83
+ *
84
+ * {@link https://swagger.io/docs/specification/serialization/#query View examples}
85
+ */
86
+ querySerializer?: QuerySerializer | QuerySerializerOptions;
87
+ /**
88
+ * A function validating request data. This is useful if you want to ensure
89
+ * the request conforms to the desired shape, so it can be safely sent to
90
+ * the server.
91
+ */
92
+ requestValidator?: (data: unknown) => Promise<unknown>;
93
+ /**
94
+ * A function transforming response data before it's returned. This is useful
95
+ * for post-processing data, e.g. converting ISO strings into Date objects.
96
+ */
97
+ responseTransformer?: (data: unknown) => Promise<unknown>;
98
+ /**
99
+ * A function validating response data. This is useful if you want to ensure
100
+ * the response conforms to the desired shape, so it can be safely passed to
101
+ * the transformers and returned to the user.
102
+ */
103
+ responseValidator?: (data: unknown) => Promise<unknown>;
104
+ }
@@ -1,6 +1,6 @@
1
1
  // This file is auto-generated by @hey-api/openapi-ts
2
2
 
3
- import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
3
+ import type { Options as ClientOptions, TDataShape, Client } from './client/index.js';
4
4
  import type { LaunchNftCollectionData, LaunchNftCollectionResponses, LaunchNftCollectionErrors, LaunchTokenData, LaunchTokenResponses, LaunchTokenErrors, GetContractInfoData, GetContractInfoResponses, GetContractInfoErrors, GetNftInfoData, GetNftInfoResponses, GetNftInfoErrors, GetNftV2InfoData, GetNftV2InfoResponses, GetNftV2InfoErrors, FaucetData, FaucetResponses, FaucetErrors, GetTokenInfoData, GetTokenInfoResponses, GetTokenInfoErrors, GetTokenBalanceData, GetTokenBalanceResponses, GetTokenBalanceErrors, GetNonceData, GetNonceResponses, GetNonceErrors, GetTokenHoldersData, GetTokenHoldersResponses, GetTokenHoldersErrors, GetTransactionsData, GetTransactionsResponses, GetTransactionsErrors, ProveData, ProveResponses, ProveErrors, GetProofData, GetProofResponses, GetProofErrors, SendTransactionData, SendTransactionResponses, SendTransactionErrors, TxStatusData, TxStatusResponses, TxStatusErrors, MintTokensData, MintTokensResponses, MintTokensErrors, MintNftData, MintNftResponses, MintNftErrors, TransferNftData, TransferNftResponses, TransferNftErrors, CmsStoreNftData, CmsStoreNftResponses, CmsStoreNftErrors, CmsReadNftData, CmsReadNftResponses, CmsReadNftErrors, CmsReserveNftData, CmsReserveNftResponses, CmsReserveNftErrors, ApproveNftData, ApproveNftResponses, ApproveNftErrors, SellNftData, SellNftResponses, SellNftErrors, BuyNftData, BuyNftResponses, BuyNftErrors, TransferTokensData, TransferTokensResponses, TransferTokensErrors, AirdropTokensData, AirdropTokensResponses, AirdropTokensErrors, RedeemTokensData, RedeemTokensResponses, RedeemTokensErrors, BurnTokensData, BurnTokensResponses, BurnTokensErrors, TokenBidData, TokenBidResponses, TokenBidErrors, TokenOfferData, TokenOfferResponses, TokenOfferErrors, BuyTokensData, BuyTokensResponses, BuyTokensErrors, SellTokensData, SellTokensResponses, SellTokensErrors, WithdrawTokenBidData, WithdrawTokenBidResponses, WithdrawTokenBidErrors, WithdrawTokenOfferData, WithdrawTokenOfferResponses, WithdrawTokenOfferErrors, UpdateTokenBidWhitelistData, UpdateTokenBidWhitelistResponses, UpdateTokenBidWhitelistErrors, UpdateTokenOfferWhitelistData, UpdateTokenOfferWhitelistResponses, UpdateTokenOfferWhitelistErrors, UpdateTokenAdminWhitelistData, UpdateTokenAdminWhitelistResponses, UpdateTokenAdminWhitelistErrors } from './types.gen.js';
5
5
  import { client as _heyApiClient } from './client.gen.js';
6
6