@smartbooks-ai/api-client 0.0.6 → 0.0.7

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 (161) hide show
  1. package/package.json +14 -15
  2. package/src/.openapi-generator/FILES +0 -56
  3. package/src/.openapi-generator/VERSION +0 -1
  4. package/src/.openapi-generator-ignore +0 -23
  5. package/src/dist/esm/index.d.ts +0 -1
  6. package/src/dist/esm/index.js +0 -1
  7. package/src/dist/esm/src/apis/AiApi.d.ts +0 -289
  8. package/src/dist/esm/src/apis/AiApi.js +0 -452
  9. package/src/dist/esm/src/apis/AnalyticsApi.d.ts +0 -242
  10. package/src/dist/esm/src/apis/AnalyticsApi.js +0 -391
  11. package/src/dist/esm/src/apis/AsyncOperationsApi.d.ts +0 -48
  12. package/src/dist/esm/src/apis/AsyncOperationsApi.js +0 -53
  13. package/src/dist/esm/src/apis/BusinessModelModulesApi.d.ts +0 -182
  14. package/src/dist/esm/src/apis/BusinessModelModulesApi.js +0 -285
  15. package/src/dist/esm/src/apis/ColorPalettesApi.d.ts +0 -62
  16. package/src/dist/esm/src/apis/ColorPalettesApi.js +0 -78
  17. package/src/dist/esm/src/apis/CommentsApi.d.ts +0 -94
  18. package/src/dist/esm/src/apis/CommentsApi.js +0 -134
  19. package/src/dist/esm/src/apis/CompaniesApi.d.ts +0 -88
  20. package/src/dist/esm/src/apis/CompaniesApi.js +0 -118
  21. package/src/dist/esm/src/apis/CompanyManagementApi.d.ts +0 -90
  22. package/src/dist/esm/src/apis/CompanyManagementApi.js +0 -123
  23. package/src/dist/esm/src/apis/ConnectionParametersApi.d.ts +0 -98
  24. package/src/dist/esm/src/apis/ConnectionParametersApi.js +0 -151
  25. package/src/dist/esm/src/apis/ConnectionTypesApi.d.ts +0 -90
  26. package/src/dist/esm/src/apis/ConnectionTypesApi.js +0 -124
  27. package/src/dist/esm/src/apis/ConnectionsApi.d.ts +0 -156
  28. package/src/dist/esm/src/apis/ConnectionsApi.js +0 -236
  29. package/src/dist/esm/src/apis/ConnectionsAuthorizationApi.d.ts +0 -74
  30. package/src/dist/esm/src/apis/ConnectionsAuthorizationApi.js +0 -108
  31. package/src/dist/esm/src/apis/ConnectionsClientCredentialsApi.d.ts +0 -72
  32. package/src/dist/esm/src/apis/ConnectionsClientCredentialsApi.js +0 -100
  33. package/src/dist/esm/src/apis/ConsolidationApi.d.ts +0 -192
  34. package/src/dist/esm/src/apis/ConsolidationApi.js +0 -297
  35. package/src/dist/esm/src/apis/CostCenterApi.d.ts +0 -130
  36. package/src/dist/esm/src/apis/CostCenterApi.js +0 -188
  37. package/src/dist/esm/src/apis/DashboardsApi.d.ts +0 -306
  38. package/src/dist/esm/src/apis/DashboardsApi.js +0 -515
  39. package/src/dist/esm/src/apis/DataSynchronizationApi.d.ts +0 -92
  40. package/src/dist/esm/src/apis/DataSynchronizationApi.js +0 -127
  41. package/src/dist/esm/src/apis/ExplanationApi.d.ts +0 -110
  42. package/src/dist/esm/src/apis/ExplanationApi.js +0 -227
  43. package/src/dist/esm/src/apis/FormatsApi.d.ts +0 -46
  44. package/src/dist/esm/src/apis/FormatsApi.js +0 -48
  45. package/src/dist/esm/src/apis/FormulasApi.d.ts +0 -62
  46. package/src/dist/esm/src/apis/FormulasApi.js +0 -81
  47. package/src/dist/esm/src/apis/FuturesApi.d.ts +0 -136
  48. package/src/dist/esm/src/apis/FuturesApi.js +0 -204
  49. package/src/dist/esm/src/apis/IdentityLinkingApi.d.ts +0 -46
  50. package/src/dist/esm/src/apis/IdentityLinkingApi.js +0 -49
  51. package/src/dist/esm/src/apis/InputApi.d.ts +0 -55
  52. package/src/dist/esm/src/apis/InputApi.js +0 -57
  53. package/src/dist/esm/src/apis/IntercompanyMatchingApi.d.ts +0 -174
  54. package/src/dist/esm/src/apis/IntercompanyMatchingApi.js +0 -260
  55. package/src/dist/esm/src/apis/InvitationsApi.d.ts +0 -156
  56. package/src/dist/esm/src/apis/InvitationsApi.js +0 -235
  57. package/src/dist/esm/src/apis/MaintenanceApi.d.ts +0 -182
  58. package/src/dist/esm/src/apis/MaintenanceApi.js +0 -278
  59. package/src/dist/esm/src/apis/ManualInputApi.d.ts +0 -204
  60. package/src/dist/esm/src/apis/ManualInputApi.js +0 -328
  61. package/src/dist/esm/src/apis/ModulesApi.d.ts +0 -88
  62. package/src/dist/esm/src/apis/ModulesApi.js +0 -112
  63. package/src/dist/esm/src/apis/NodePurposesApi.d.ts +0 -68
  64. package/src/dist/esm/src/apis/NodePurposesApi.js +0 -86
  65. package/src/dist/esm/src/apis/ProfileApi.d.ts +0 -85
  66. package/src/dist/esm/src/apis/ProfileApi.js +0 -114
  67. package/src/dist/esm/src/apis/RelationsApi.d.ts +0 -46
  68. package/src/dist/esm/src/apis/RelationsApi.js +0 -48
  69. package/src/dist/esm/src/apis/ReportGroupsApi.d.ts +0 -72
  70. package/src/dist/esm/src/apis/ReportGroupsApi.js +0 -92
  71. package/src/dist/esm/src/apis/ReportingApi.d.ts +0 -267
  72. package/src/dist/esm/src/apis/ReportingApi.js +0 -379
  73. package/src/dist/esm/src/apis/ReportingPeriodsApi.d.ts +0 -46
  74. package/src/dist/esm/src/apis/ReportingPeriodsApi.js +0 -48
  75. package/src/dist/esm/src/apis/SourceAccountsApi.d.ts +0 -46
  76. package/src/dist/esm/src/apis/SourceAccountsApi.js +0 -48
  77. package/src/dist/esm/src/apis/StructureApi.d.ts +0 -134
  78. package/src/dist/esm/src/apis/StructureApi.js +0 -163
  79. package/src/dist/esm/src/apis/StructureDefinitionApi.d.ts +0 -164
  80. package/src/dist/esm/src/apis/StructureDefinitionApi.js +0 -259
  81. package/src/dist/esm/src/apis/StructureImprovementApi.d.ts +0 -70
  82. package/src/dist/esm/src/apis/StructureImprovementApi.js +0 -91
  83. package/src/dist/esm/src/apis/TemplatesApi.d.ts +0 -120
  84. package/src/dist/esm/src/apis/TemplatesApi.js +0 -178
  85. package/src/dist/esm/src/apis/TemplatesGenerationApi.d.ts +0 -66
  86. package/src/dist/esm/src/apis/TemplatesGenerationApi.js +0 -85
  87. package/src/dist/esm/src/apis/TenantIntercompanySettingsApi.d.ts +0 -90
  88. package/src/dist/esm/src/apis/TenantIntercompanySettingsApi.js +0 -123
  89. package/src/dist/esm/src/apis/TenantsApi.d.ts +0 -124
  90. package/src/dist/esm/src/apis/TenantsApi.js +0 -180
  91. package/src/dist/esm/src/apis/TransactionDetailsApi.d.ts +0 -50
  92. package/src/dist/esm/src/apis/TransactionDetailsApi.js +0 -57
  93. package/src/dist/esm/src/apis/UsersApi.d.ts +0 -114
  94. package/src/dist/esm/src/apis/UsersApi.js +0 -165
  95. package/src/dist/esm/src/apis/WebhooksApi.d.ts +0 -68
  96. package/src/dist/esm/src/apis/WebhooksApi.js +0 -86
  97. package/src/dist/esm/src/apis/WizardApi.d.ts +0 -74
  98. package/src/dist/esm/src/apis/WizardApi.js +0 -101
  99. package/src/dist/esm/src/apis/index.d.ts +0 -46
  100. package/src/dist/esm/src/apis/index.js +0 -48
  101. package/src/dist/esm/src/index.d.ts +0 -3
  102. package/src/dist/esm/src/index.js +0 -5
  103. package/src/dist/esm/src/models/index.d.ts +0 -15406
  104. package/src/dist/esm/src/models/index.js +0 -1279
  105. package/src/dist/esm/src/runtime.d.ts +0 -181
  106. package/src/dist/esm/src/runtime.js +0 -326
  107. package/src/index.ts +0 -1
  108. package/src/package.json +0 -24
  109. package/src/src/apis/AiApi.ts +0 -1043
  110. package/src/src/apis/AnalyticsApi.ts +0 -925
  111. package/src/src/apis/AsyncOperationsApi.ts +0 -112
  112. package/src/src/apis/BusinessModelModulesApi.ts +0 -649
  113. package/src/src/apis/ColorPalettesApi.ts +0 -148
  114. package/src/src/apis/CommentsApi.ts +0 -308
  115. package/src/src/apis/CompaniesApi.ts +0 -260
  116. package/src/src/apis/CompanyManagementApi.ts +0 -270
  117. package/src/src/apis/ConnectionParametersApi.ts +0 -339
  118. package/src/src/apis/ConnectionTypesApi.ts +0 -280
  119. package/src/src/apis/ConnectionsApi.ts +0 -533
  120. package/src/src/apis/ConnectionsAuthorizationApi.ts +0 -241
  121. package/src/src/apis/ConnectionsClientCredentialsApi.ts +0 -224
  122. package/src/src/apis/ConsolidationApi.ts +0 -682
  123. package/src/src/apis/CostCenterApi.ts +0 -428
  124. package/src/src/apis/DashboardsApi.ts +0 -1179
  125. package/src/src/apis/DataSynchronizationApi.ts +0 -288
  126. package/src/src/apis/ExplanationApi.ts +0 -504
  127. package/src/src/apis/FormatsApi.ts +0 -96
  128. package/src/src/apis/FormulasApi.ts +0 -154
  129. package/src/src/apis/FuturesApi.ts +0 -463
  130. package/src/src/apis/IdentityLinkingApi.ts +0 -101
  131. package/src/src/apis/InputApi.ts +0 -126
  132. package/src/src/apis/IntercompanyMatchingApi.ts +0 -588
  133. package/src/src/apis/InvitationsApi.ts +0 -523
  134. package/src/src/apis/MaintenanceApi.ts +0 -597
  135. package/src/src/apis/ManualInputApi.ts +0 -771
  136. package/src/src/apis/ModulesApi.ts +0 -246
  137. package/src/src/apis/NodePurposesApi.ts +0 -184
  138. package/src/src/apis/ProfileApi.ts +0 -203
  139. package/src/src/apis/RelationsApi.ts +0 -99
  140. package/src/src/apis/ReportGroupsApi.ts +0 -205
  141. package/src/src/apis/ReportingApi.ts +0 -851
  142. package/src/src/apis/ReportingPeriodsApi.ts +0 -99
  143. package/src/src/apis/SourceAccountsApi.ts +0 -102
  144. package/src/src/apis/StructureApi.ts +0 -334
  145. package/src/src/apis/StructureDefinitionApi.ts +0 -601
  146. package/src/src/apis/StructureImprovementApi.ts +0 -214
  147. package/src/src/apis/TemplatesApi.ts +0 -334
  148. package/src/src/apis/TemplatesGenerationApi.ts +0 -187
  149. package/src/src/apis/TenantIntercompanySettingsApi.ts +0 -286
  150. package/src/src/apis/TenantsApi.ts +0 -374
  151. package/src/src/apis/TransactionDetailsApi.ts +0 -127
  152. package/src/src/apis/UsersApi.ts +0 -356
  153. package/src/src/apis/WebhooksApi.ts +0 -193
  154. package/src/src/apis/WizardApi.ts +0 -230
  155. package/src/src/apis/index.ts +0 -48
  156. package/src/src/index.ts +0 -5
  157. package/src/src/models/index.ts +0 -15625
  158. package/src/src/runtime.ts +0 -469
  159. package/src/tsconfig.esm.json +0 -7
  160. package/src/tsconfig.json +0 -11
  161. package/tsconfig.json +0 -11
@@ -1,469 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * Smartbooks Restful API
5
- * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
- *
7
- * The version of the OpenAPI document: 0.0.1
8
- *
9
- *
10
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
- * https://openapi-generator.tech
12
- * Do not edit the class manually.
13
- */
14
-
15
- export const BASE_PATH = 'https://app.smartbooks.ai'.replace(/\/+$/, '');
16
-
17
- export interface ConfigurationParameters {
18
- basePath?: string; // override base path
19
- fetchApi?: FetchAPI; // override for fetch implementation
20
- middleware?: Middleware[]; // middleware to apply before/after fetch requests
21
- queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
22
- username?: string; // parameter for basic security
23
- password?: string; // parameter for basic security
24
- apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
25
- accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
26
- headers?: HTTPHeaders; //header params we want to use on every request
27
- credentials?: RequestCredentials; //value for the credentials param we want to use on each request
28
- }
29
-
30
- export class Configuration {
31
- constructor(private configuration: ConfigurationParameters = {}) {}
32
-
33
- set config(configuration: Configuration) {
34
- this.configuration = configuration;
35
- }
36
-
37
- get basePath(): string {
38
- return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
39
- }
40
-
41
- get fetchApi(): FetchAPI | undefined {
42
- return this.configuration.fetchApi;
43
- }
44
-
45
- get middleware(): Middleware[] {
46
- return this.configuration.middleware || [];
47
- }
48
-
49
- get queryParamsStringify(): (params: HTTPQuery) => string {
50
- return this.configuration.queryParamsStringify || querystring;
51
- }
52
-
53
- get username(): string | undefined {
54
- return this.configuration.username;
55
- }
56
-
57
- get password(): string | undefined {
58
- return this.configuration.password;
59
- }
60
-
61
- get apiKey(): ((name: string) => string | Promise<string>) | undefined {
62
- const apiKey = this.configuration.apiKey;
63
- if (apiKey) {
64
- return typeof apiKey === 'function' ? apiKey : () => apiKey;
65
- }
66
- return undefined;
67
- }
68
-
69
- get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined {
70
- const accessToken = this.configuration.accessToken;
71
- if (accessToken) {
72
- return typeof accessToken === 'function' ? accessToken : async () => accessToken;
73
- }
74
- return undefined;
75
- }
76
-
77
- get headers(): HTTPHeaders | undefined {
78
- return this.configuration.headers;
79
- }
80
-
81
- get credentials(): RequestCredentials | undefined {
82
- return this.configuration.credentials;
83
- }
84
- }
85
-
86
- export const DefaultConfig = new Configuration();
87
-
88
- /**
89
- * This is the base class for all generated API classes.
90
- */
91
- export class BaseAPI {
92
- private static readonly jsonRegex = new RegExp(
93
- '^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$',
94
- 'i',
95
- );
96
- private middleware: Middleware[];
97
-
98
- constructor(protected configuration = DefaultConfig) {
99
- this.middleware = configuration.middleware;
100
- }
101
-
102
- withMiddleware<T extends BaseAPI>(this: T, ...middlewares: Middleware[]) {
103
- const next = this.clone<T>();
104
- next.middleware = next.middleware.concat(...middlewares);
105
- return next;
106
- }
107
-
108
- withPreMiddleware<T extends BaseAPI>(this: T, ...preMiddlewares: Array<Middleware['pre']>) {
109
- const middlewares = preMiddlewares.map((pre) => ({ pre }));
110
- return this.withMiddleware<T>(...middlewares);
111
- }
112
-
113
- withPostMiddleware<T extends BaseAPI>(this: T, ...postMiddlewares: Array<Middleware['post']>) {
114
- const middlewares = postMiddlewares.map((post) => ({ post }));
115
- return this.withMiddleware<T>(...middlewares);
116
- }
117
-
118
- /**
119
- * Check if the given MIME is a JSON MIME.
120
- * JSON MIME examples:
121
- * application/json
122
- * application/json; charset=UTF8
123
- * APPLICATION/JSON
124
- * application/vnd.company+json
125
- * @param mime - MIME (Multipurpose Internet Mail Extensions)
126
- * @return True if the given MIME is JSON, false otherwise.
127
- */
128
- protected isJsonMime(mime: string | null | undefined): boolean {
129
- if (!mime) {
130
- return false;
131
- }
132
- return BaseAPI.jsonRegex.test(mime);
133
- }
134
-
135
- protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise<Response> {
136
- const { url, init } = await this.createFetchParams(context, initOverrides);
137
- const response = await this.fetchApi(url, init);
138
- if (response && response.status >= 200 && response.status < 300) {
139
- return response;
140
- }
141
- throw new ResponseError(response, 'Response returned an error code');
142
- }
143
-
144
- private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) {
145
- let url = this.configuration.basePath + context.path;
146
- if (context.query !== undefined && Object.keys(context.query).length !== 0) {
147
- // only add the querystring to the URL if there are query parameters.
148
- // this is done to avoid urls ending with a "?" character which buggy webservers
149
- // do not handle correctly sometimes.
150
- url += '?' + this.configuration.queryParamsStringify(context.query);
151
- }
152
-
153
- const headers = Object.assign({}, this.configuration.headers, context.headers);
154
- Object.keys(headers).forEach((key) => (headers[key] === undefined ? delete headers[key] : {}));
155
-
156
- const initOverrideFn = typeof initOverrides === 'function' ? initOverrides : async () => initOverrides;
157
-
158
- const initParams = {
159
- method: context.method,
160
- headers,
161
- body: context.body,
162
- credentials: this.configuration.credentials,
163
- };
164
-
165
- const overriddenInit: RequestInit = {
166
- ...initParams,
167
- ...(await initOverrideFn({
168
- init: initParams,
169
- context,
170
- })),
171
- };
172
-
173
- let body: any;
174
- if (
175
- isFormData(overriddenInit.body) ||
176
- overriddenInit.body instanceof URLSearchParams ||
177
- isBlob(overriddenInit.body)
178
- ) {
179
- body = overriddenInit.body;
180
- } else if (this.isJsonMime(headers['Content-Type'])) {
181
- body = JSON.stringify(overriddenInit.body);
182
- } else {
183
- body = overriddenInit.body;
184
- }
185
-
186
- const init: RequestInit = {
187
- ...overriddenInit,
188
- body,
189
- };
190
-
191
- return { url, init };
192
- }
193
-
194
- private fetchApi = async (url: string, init: RequestInit) => {
195
- let fetchParams = { url, init };
196
- for (const middleware of this.middleware) {
197
- if (middleware.pre) {
198
- fetchParams =
199
- (await middleware.pre({
200
- fetch: this.fetchApi,
201
- ...fetchParams,
202
- })) || fetchParams;
203
- }
204
- }
205
- let response: Response | undefined = undefined;
206
- try {
207
- response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
208
- } catch (e) {
209
- for (const middleware of this.middleware) {
210
- if (middleware.onError) {
211
- response =
212
- (await middleware.onError({
213
- fetch: this.fetchApi,
214
- url: fetchParams.url,
215
- init: fetchParams.init,
216
- error: e,
217
- response: response ? response.clone() : undefined,
218
- })) || response;
219
- }
220
- }
221
- if (response === undefined) {
222
- if (e instanceof Error) {
223
- throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
224
- } else {
225
- throw e;
226
- }
227
- }
228
- }
229
- for (const middleware of this.middleware) {
230
- if (middleware.post) {
231
- response =
232
- (await middleware.post({
233
- fetch: this.fetchApi,
234
- url: fetchParams.url,
235
- init: fetchParams.init,
236
- response: response.clone(),
237
- })) || response;
238
- }
239
- }
240
- return response;
241
- };
242
-
243
- /**
244
- * Create a shallow clone of `this` by constructing a new instance
245
- * and then shallow cloning data members.
246
- */
247
- private clone<T extends BaseAPI>(this: T): T {
248
- const constructor = this.constructor as any;
249
- const next = new constructor(this.configuration);
250
- next.middleware = this.middleware.slice();
251
- return next;
252
- }
253
- }
254
-
255
- function isBlob(value: any): value is Blob {
256
- return typeof Blob !== 'undefined' && value instanceof Blob;
257
- }
258
-
259
- function isFormData(value: any): value is FormData {
260
- return typeof FormData !== 'undefined' && value instanceof FormData;
261
- }
262
-
263
- export class ResponseError extends Error {
264
- override name: 'ResponseError' = 'ResponseError';
265
- constructor(
266
- public response: Response,
267
- msg?: string,
268
- ) {
269
- super(msg);
270
- }
271
- }
272
-
273
- export class FetchError extends Error {
274
- override name: 'FetchError' = 'FetchError';
275
- constructor(
276
- public cause: Error,
277
- msg?: string,
278
- ) {
279
- super(msg);
280
- }
281
- }
282
-
283
- export class RequiredError extends Error {
284
- override name: 'RequiredError' = 'RequiredError';
285
- constructor(
286
- public field: string,
287
- msg?: string,
288
- ) {
289
- super(msg);
290
- }
291
- }
292
-
293
- export const COLLECTION_FORMATS = {
294
- csv: ',',
295
- ssv: ' ',
296
- tsv: '\t',
297
- pipes: '|',
298
- };
299
-
300
- export type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
301
-
302
- export type Json = any;
303
- export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
304
- export type HTTPHeaders = { [key: string]: string };
305
- export type HTTPQuery = {
306
- [key: string]:
307
- | string
308
- | number
309
- | null
310
- | boolean
311
- | Array<string | number | null | boolean>
312
- | Set<string | number | null | boolean>
313
- | HTTPQuery;
314
- };
315
- export type HTTPBody = Json | FormData | URLSearchParams;
316
- export type HTTPRequestInit = {
317
- headers?: HTTPHeaders;
318
- method: HTTPMethod;
319
- credentials?: RequestCredentials;
320
- body?: HTTPBody;
321
- };
322
- export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
323
-
324
- export type InitOverrideFunction = (requestContext: {
325
- init: HTTPRequestInit;
326
- context: RequestOpts;
327
- }) => Promise<RequestInit>;
328
-
329
- export interface FetchParams {
330
- url: string;
331
- init: RequestInit;
332
- }
333
-
334
- export interface RequestOpts {
335
- path: string;
336
- method: HTTPMethod;
337
- headers: HTTPHeaders;
338
- query?: HTTPQuery;
339
- body?: HTTPBody;
340
- }
341
-
342
- export function querystring(params: HTTPQuery, prefix: string = ''): string {
343
- return Object.keys(params)
344
- .map((key) => querystringSingleKey(key, params[key], prefix))
345
- .filter((part) => part.length > 0)
346
- .join('&');
347
- }
348
-
349
- function querystringSingleKey(
350
- key: string,
351
- value:
352
- | string
353
- | number
354
- | null
355
- | undefined
356
- | boolean
357
- | Array<string | number | null | boolean>
358
- | Set<string | number | null | boolean>
359
- | HTTPQuery,
360
- keyPrefix: string = '',
361
- ): string {
362
- const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
363
- if (value instanceof Array) {
364
- const multiValue = value
365
- .map((singleValue) => encodeURIComponent(String(singleValue)))
366
- .join(`&${encodeURIComponent(fullKey)}=`);
367
- return `${encodeURIComponent(fullKey)}=${multiValue}`;
368
- }
369
- if (value instanceof Set) {
370
- const valueAsArray = Array.from(value);
371
- return querystringSingleKey(key, valueAsArray, keyPrefix);
372
- }
373
- if (value instanceof Date) {
374
- return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
375
- }
376
- if (value instanceof Object) {
377
- return querystring(value as HTTPQuery, fullKey);
378
- }
379
- return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
380
- }
381
-
382
- export function exists(json: any, key: string) {
383
- const value = json[key];
384
- return value !== null && value !== undefined;
385
- }
386
-
387
- export function canConsumeForm(consumes: Consume[]): boolean {
388
- for (const consume of consumes) {
389
- if ('multipart/form-data' === consume.contentType) {
390
- return true;
391
- }
392
- }
393
- return false;
394
- }
395
-
396
- export interface Consume {
397
- contentType: string;
398
- }
399
-
400
- export interface RequestContext {
401
- fetch: FetchAPI;
402
- url: string;
403
- init: RequestInit;
404
- }
405
-
406
- export interface ResponseContext {
407
- fetch: FetchAPI;
408
- url: string;
409
- init: RequestInit;
410
- response: Response;
411
- }
412
-
413
- export interface ErrorContext {
414
- fetch: FetchAPI;
415
- url: string;
416
- init: RequestInit;
417
- error: unknown;
418
- response?: Response;
419
- }
420
-
421
- export interface Middleware {
422
- pre?(context: RequestContext): Promise<FetchParams | void>;
423
- post?(context: ResponseContext): Promise<Response | void>;
424
- onError?(context: ErrorContext): Promise<Response | void>;
425
- }
426
-
427
- export interface ApiResponse<T> {
428
- raw: Response;
429
- value(): Promise<T>;
430
- }
431
-
432
- export interface ResponseTransformer<T> {
433
- (json: any): T;
434
- }
435
-
436
- export class JSONApiResponse<T> {
437
- constructor(
438
- public raw: Response,
439
- private transformer: ResponseTransformer<T> = (jsonValue: any) => jsonValue,
440
- ) {}
441
-
442
- async value(): Promise<T> {
443
- return this.transformer(await this.raw.json());
444
- }
445
- }
446
-
447
- export class VoidApiResponse {
448
- constructor(public raw: Response) {}
449
-
450
- async value(): Promise<void> {
451
- return undefined;
452
- }
453
- }
454
-
455
- export class BlobApiResponse {
456
- constructor(public raw: Response) {}
457
-
458
- async value(): Promise<Blob> {
459
- return await this.raw.blob();
460
- }
461
- }
462
-
463
- export class TextApiResponse {
464
- constructor(public raw: Response) {}
465
-
466
- async value(): Promise<string> {
467
- return await this.raw.text();
468
- }
469
- }
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "module": "esnext",
5
- "outDir": "dist/esm"
6
- }
7
- }
package/src/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "declaration": true,
4
- "target": "es6",
5
- "module": "commonjs",
6
- "moduleResolution": "node",
7
- "outDir": "dist",
8
- "typeRoots": ["node_modules/@types"]
9
- },
10
- "exclude": ["dist", "node_modules"]
11
- }
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "declaration": true,
4
- "target": "es6",
5
- "module": "commonjs",
6
- "moduleResolution": "node",
7
- "outDir": "dist",
8
- "typeRoots": ["node_modules/@types"]
9
- },
10
- "exclude": ["dist", "node_modules"]
11
- }