windmill-client 1.617.3 → 1.618.2
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/chunk-B9dir_RE.mjs +11 -0
- package/dist/index.d.mts +29830 -0
- package/dist/index.d.ts +29831 -7
- package/dist/index.js +13789 -67
- package/dist/index.mjs +13681 -0
- package/package.json +24 -5
- package/dist/client.d.ts +0 -414
- package/dist/client.js +0 -1291
- package/dist/core/ApiError.d.ts +0 -10
- package/dist/core/ApiError.js +0 -15
- package/dist/core/ApiRequestOptions.d.ts +0 -13
- package/dist/core/ApiRequestOptions.js +0 -2
- package/dist/core/ApiResult.d.ts +0 -7
- package/dist/core/ApiResult.js +0 -2
- package/dist/core/CancelablePromise.d.ts +0 -26
- package/dist/core/CancelablePromise.js +0 -93
- package/dist/core/OpenAPI.d.ts +0 -27
- package/dist/core/OpenAPI.js +0 -48
- package/dist/core/request.d.ts +0 -29
- package/dist/core/request.js +0 -278
- package/dist/s3Types.d.ts +0 -38
- package/dist/s3Types.js +0 -2
- package/dist/services.gen.d.ts +0 -6310
- package/dist/services.gen.js +0 -12818
- package/dist/sqlUtils.d.ts +0 -75
- package/dist/sqlUtils.js +0 -197
- package/dist/types.gen.d.ts +0 -22881
- package/dist/types.gen.js +0 -3
package/dist/core/ApiError.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
2
|
-
import type { ApiResult } from './ApiResult';
|
|
3
|
-
export declare class ApiError extends Error {
|
|
4
|
-
readonly url: string;
|
|
5
|
-
readonly status: number;
|
|
6
|
-
readonly statusText: string;
|
|
7
|
-
readonly body: unknown;
|
|
8
|
-
readonly request: ApiRequestOptions;
|
|
9
|
-
constructor(request: ApiRequestOptions, response: ApiResult, message: string);
|
|
10
|
-
}
|
package/dist/core/ApiError.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiError = void 0;
|
|
4
|
-
class ApiError extends Error {
|
|
5
|
-
constructor(request, response, message) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = 'ApiError';
|
|
8
|
-
this.url = response.url;
|
|
9
|
-
this.status = response.status;
|
|
10
|
-
this.statusText = response.statusText;
|
|
11
|
-
this.body = response.body;
|
|
12
|
-
this.request = request;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.ApiError = ApiError;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type ApiRequestOptions = {
|
|
2
|
-
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
|
|
3
|
-
readonly url: string;
|
|
4
|
-
readonly path?: Record<string, unknown>;
|
|
5
|
-
readonly cookies?: Record<string, unknown>;
|
|
6
|
-
readonly headers?: Record<string, unknown>;
|
|
7
|
-
readonly query?: Record<string, unknown>;
|
|
8
|
-
readonly formData?: Record<string, unknown>;
|
|
9
|
-
readonly body?: any;
|
|
10
|
-
readonly mediaType?: string;
|
|
11
|
-
readonly responseHeader?: string;
|
|
12
|
-
readonly errors?: Record<number, string>;
|
|
13
|
-
};
|
package/dist/core/ApiResult.d.ts
DELETED
package/dist/core/ApiResult.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export declare class CancelError extends Error {
|
|
2
|
-
constructor(message: string);
|
|
3
|
-
get isCancelled(): boolean;
|
|
4
|
-
}
|
|
5
|
-
export interface OnCancel {
|
|
6
|
-
readonly isResolved: boolean;
|
|
7
|
-
readonly isRejected: boolean;
|
|
8
|
-
readonly isCancelled: boolean;
|
|
9
|
-
(cancelHandler: () => void): void;
|
|
10
|
-
}
|
|
11
|
-
export declare class CancelablePromise<T> implements Promise<T> {
|
|
12
|
-
private _isResolved;
|
|
13
|
-
private _isRejected;
|
|
14
|
-
private _isCancelled;
|
|
15
|
-
readonly cancelHandlers: (() => void)[];
|
|
16
|
-
readonly promise: Promise<T>;
|
|
17
|
-
private _resolve?;
|
|
18
|
-
private _reject?;
|
|
19
|
-
constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void, onCancel: OnCancel) => void);
|
|
20
|
-
get [Symbol.toStringTag](): string;
|
|
21
|
-
then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
22
|
-
catch<TResult = never>(onRejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
|
|
23
|
-
finally(onFinally?: (() => void) | null): Promise<T>;
|
|
24
|
-
cancel(): void;
|
|
25
|
-
get isCancelled(): boolean;
|
|
26
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CancelablePromise = exports.CancelError = void 0;
|
|
4
|
-
class CancelError extends Error {
|
|
5
|
-
constructor(message) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = 'CancelError';
|
|
8
|
-
}
|
|
9
|
-
get isCancelled() {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.CancelError = CancelError;
|
|
14
|
-
class CancelablePromise {
|
|
15
|
-
constructor(executor) {
|
|
16
|
-
this._isResolved = false;
|
|
17
|
-
this._isRejected = false;
|
|
18
|
-
this._isCancelled = false;
|
|
19
|
-
this.cancelHandlers = [];
|
|
20
|
-
this.promise = new Promise((resolve, reject) => {
|
|
21
|
-
this._resolve = resolve;
|
|
22
|
-
this._reject = reject;
|
|
23
|
-
const onResolve = (value) => {
|
|
24
|
-
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
this._isResolved = true;
|
|
28
|
-
if (this._resolve)
|
|
29
|
-
this._resolve(value);
|
|
30
|
-
};
|
|
31
|
-
const onReject = (reason) => {
|
|
32
|
-
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this._isRejected = true;
|
|
36
|
-
if (this._reject)
|
|
37
|
-
this._reject(reason);
|
|
38
|
-
};
|
|
39
|
-
const onCancel = (cancelHandler) => {
|
|
40
|
-
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
this.cancelHandlers.push(cancelHandler);
|
|
44
|
-
};
|
|
45
|
-
Object.defineProperty(onCancel, 'isResolved', {
|
|
46
|
-
get: () => this._isResolved,
|
|
47
|
-
});
|
|
48
|
-
Object.defineProperty(onCancel, 'isRejected', {
|
|
49
|
-
get: () => this._isRejected,
|
|
50
|
-
});
|
|
51
|
-
Object.defineProperty(onCancel, 'isCancelled', {
|
|
52
|
-
get: () => this._isCancelled,
|
|
53
|
-
});
|
|
54
|
-
return executor(onResolve, onReject, onCancel);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
get [Symbol.toStringTag]() {
|
|
58
|
-
return "Cancellable Promise";
|
|
59
|
-
}
|
|
60
|
-
then(onFulfilled, onRejected) {
|
|
61
|
-
return this.promise.then(onFulfilled, onRejected);
|
|
62
|
-
}
|
|
63
|
-
catch(onRejected) {
|
|
64
|
-
return this.promise.catch(onRejected);
|
|
65
|
-
}
|
|
66
|
-
finally(onFinally) {
|
|
67
|
-
return this.promise.finally(onFinally);
|
|
68
|
-
}
|
|
69
|
-
cancel() {
|
|
70
|
-
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
this._isCancelled = true;
|
|
74
|
-
if (this.cancelHandlers.length) {
|
|
75
|
-
try {
|
|
76
|
-
for (const cancelHandler of this.cancelHandlers) {
|
|
77
|
-
cancelHandler();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
console.warn('Cancellation threw an error', error);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
this.cancelHandlers.length = 0;
|
|
86
|
-
if (this._reject)
|
|
87
|
-
this._reject(new CancelError('Request aborted'));
|
|
88
|
-
}
|
|
89
|
-
get isCancelled() {
|
|
90
|
-
return this._isCancelled;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
exports.CancelablePromise = CancelablePromise;
|
package/dist/core/OpenAPI.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
2
|
-
type Headers = Record<string, string>;
|
|
3
|
-
type Middleware<T> = (value: T) => T | Promise<T>;
|
|
4
|
-
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
|
5
|
-
export declare class Interceptors<T> {
|
|
6
|
-
_fns: Middleware<T>[];
|
|
7
|
-
constructor();
|
|
8
|
-
eject(fn: Middleware<T>): void;
|
|
9
|
-
use(fn: Middleware<T>): void;
|
|
10
|
-
}
|
|
11
|
-
export type OpenAPIConfig = {
|
|
12
|
-
BASE: string;
|
|
13
|
-
CREDENTIALS: 'include' | 'omit' | 'same-origin';
|
|
14
|
-
ENCODE_PATH?: ((path: string) => string) | undefined;
|
|
15
|
-
HEADERS?: Headers | Resolver<Headers> | undefined;
|
|
16
|
-
PASSWORD?: string | Resolver<string> | undefined;
|
|
17
|
-
TOKEN?: string | Resolver<string> | undefined;
|
|
18
|
-
USERNAME?: string | Resolver<string> | undefined;
|
|
19
|
-
VERSION: string;
|
|
20
|
-
WITH_CREDENTIALS: boolean;
|
|
21
|
-
interceptors: {
|
|
22
|
-
request: Interceptors<RequestInit>;
|
|
23
|
-
response: Interceptors<Response>;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export declare const OpenAPI: OpenAPIConfig;
|
|
27
|
-
export {};
|
package/dist/core/OpenAPI.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a, _b;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.OpenAPI = exports.Interceptors = void 0;
|
|
5
|
-
const getEnv = (key) => {
|
|
6
|
-
var _a, _b, _c, _d, _e;
|
|
7
|
-
if (typeof window === "undefined") {
|
|
8
|
-
if (typeof process !== "undefined") {
|
|
9
|
-
return (_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a[key];
|
|
10
|
-
}
|
|
11
|
-
// node
|
|
12
|
-
return (_c = (_b = globalThis === null || globalThis === void 0 ? void 0 : globalThis.process) === null || _b === void 0 ? void 0 : _b.env) === null || _c === void 0 ? void 0 : _c[key];
|
|
13
|
-
}
|
|
14
|
-
// browser
|
|
15
|
-
return (_e = (_d = window === null || window === void 0 ? void 0 : window.process) === null || _d === void 0 ? void 0 : _d.env) === null || _e === void 0 ? void 0 : _e[key];
|
|
16
|
-
};
|
|
17
|
-
const baseUrl = (_b = (_a = getEnv("BASE_INTERNAL_URL")) !== null && _a !== void 0 ? _a : getEnv("BASE_URL")) !== null && _b !== void 0 ? _b : "http://localhost:8000";
|
|
18
|
-
const baseUrlApi = (baseUrl !== null && baseUrl !== void 0 ? baseUrl : '') + "/api";
|
|
19
|
-
class Interceptors {
|
|
20
|
-
constructor() {
|
|
21
|
-
this._fns = [];
|
|
22
|
-
}
|
|
23
|
-
eject(fn) {
|
|
24
|
-
const index = this._fns.indexOf(fn);
|
|
25
|
-
if (index !== -1) {
|
|
26
|
-
this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
use(fn) {
|
|
30
|
-
this._fns = [...this._fns, fn];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.Interceptors = Interceptors;
|
|
34
|
-
exports.OpenAPI = {
|
|
35
|
-
BASE: baseUrlApi,
|
|
36
|
-
CREDENTIALS: 'include',
|
|
37
|
-
ENCODE_PATH: undefined,
|
|
38
|
-
HEADERS: undefined,
|
|
39
|
-
PASSWORD: undefined,
|
|
40
|
-
TOKEN: getEnv("WM_TOKEN"),
|
|
41
|
-
USERNAME: undefined,
|
|
42
|
-
VERSION: '1.617.3',
|
|
43
|
-
WITH_CREDENTIALS: true,
|
|
44
|
-
interceptors: {
|
|
45
|
-
request: new Interceptors(),
|
|
46
|
-
response: new Interceptors(),
|
|
47
|
-
},
|
|
48
|
-
};
|
package/dist/core/request.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
2
|
-
import type { ApiResult } from './ApiResult';
|
|
3
|
-
import { CancelablePromise } from './CancelablePromise';
|
|
4
|
-
import type { OnCancel } from './CancelablePromise';
|
|
5
|
-
import type { OpenAPIConfig } from './OpenAPI';
|
|
6
|
-
export declare const isString: (value: unknown) => value is string;
|
|
7
|
-
export declare const isStringWithValue: (value: unknown) => value is string;
|
|
8
|
-
export declare const isBlob: (value: any) => value is Blob;
|
|
9
|
-
export declare const isFormData: (value: unknown) => value is FormData;
|
|
10
|
-
export declare const base64: (str: string) => string;
|
|
11
|
-
export declare const getQueryString: (params: Record<string, unknown>) => string;
|
|
12
|
-
export declare const getFormData: (options: ApiRequestOptions) => FormData | undefined;
|
|
13
|
-
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
|
14
|
-
export declare const resolve: <T>(options: ApiRequestOptions, resolver?: T | Resolver<T>) => Promise<T | undefined>;
|
|
15
|
-
export declare const getHeaders: (config: OpenAPIConfig, options: ApiRequestOptions) => Promise<Headers>;
|
|
16
|
-
export declare const getRequestBody: (options: ApiRequestOptions) => unknown;
|
|
17
|
-
export declare const sendRequest: (config: OpenAPIConfig, options: ApiRequestOptions, url: string, body: any, formData: FormData | undefined, headers: Headers, onCancel: OnCancel) => Promise<Response>;
|
|
18
|
-
export declare const getResponseHeader: (response: Response, responseHeader?: string) => string | undefined;
|
|
19
|
-
export declare const getResponseBody: (response: Response) => Promise<unknown>;
|
|
20
|
-
export declare const catchErrorCodes: (options: ApiRequestOptions, result: ApiResult) => void;
|
|
21
|
-
/**
|
|
22
|
-
* Request method
|
|
23
|
-
* @param config The OpenAPI configuration object
|
|
24
|
-
* @param options The request options from the service
|
|
25
|
-
* @returns CancelablePromise<T>
|
|
26
|
-
* @throws ApiError
|
|
27
|
-
*/
|
|
28
|
-
export declare const request: <T>(config: OpenAPIConfig, options: ApiRequestOptions) => CancelablePromise<T>;
|
|
29
|
-
export {};
|
package/dist/core/request.js
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.request = exports.catchErrorCodes = exports.getResponseBody = exports.getResponseHeader = exports.sendRequest = exports.getRequestBody = exports.getHeaders = exports.resolve = exports.getFormData = exports.getQueryString = exports.base64 = exports.isFormData = exports.isBlob = exports.isStringWithValue = exports.isString = void 0;
|
|
13
|
-
const ApiError_1 = require("./ApiError");
|
|
14
|
-
const CancelablePromise_1 = require("./CancelablePromise");
|
|
15
|
-
const isString = (value) => {
|
|
16
|
-
return typeof value === 'string';
|
|
17
|
-
};
|
|
18
|
-
exports.isString = isString;
|
|
19
|
-
const isStringWithValue = (value) => {
|
|
20
|
-
return (0, exports.isString)(value) && value !== '';
|
|
21
|
-
};
|
|
22
|
-
exports.isStringWithValue = isStringWithValue;
|
|
23
|
-
const isBlob = (value) => {
|
|
24
|
-
return value instanceof Blob;
|
|
25
|
-
};
|
|
26
|
-
exports.isBlob = isBlob;
|
|
27
|
-
const isFormData = (value) => {
|
|
28
|
-
return value instanceof FormData;
|
|
29
|
-
};
|
|
30
|
-
exports.isFormData = isFormData;
|
|
31
|
-
const base64 = (str) => {
|
|
32
|
-
try {
|
|
33
|
-
return btoa(str);
|
|
34
|
-
}
|
|
35
|
-
catch (err) {
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
return Buffer.from(str).toString('base64');
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
exports.base64 = base64;
|
|
41
|
-
const getQueryString = (params) => {
|
|
42
|
-
const qs = [];
|
|
43
|
-
const append = (key, value) => {
|
|
44
|
-
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
45
|
-
};
|
|
46
|
-
const encodePair = (key, value) => {
|
|
47
|
-
if (value === undefined || value === null) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (value instanceof Date) {
|
|
51
|
-
append(key, value.toISOString());
|
|
52
|
-
}
|
|
53
|
-
else if (Array.isArray(value)) {
|
|
54
|
-
value.forEach(v => encodePair(key, v));
|
|
55
|
-
}
|
|
56
|
-
else if (typeof value === 'object') {
|
|
57
|
-
Object.entries(value).forEach(([k, v]) => encodePair(`${key}[${k}]`, v));
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
append(key, value);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
Object.entries(params).forEach(([key, value]) => encodePair(key, value));
|
|
64
|
-
return qs.length ? `?${qs.join('&')}` : '';
|
|
65
|
-
};
|
|
66
|
-
exports.getQueryString = getQueryString;
|
|
67
|
-
const getUrl = (config, options) => {
|
|
68
|
-
const encoder = config.ENCODE_PATH || encodeURI;
|
|
69
|
-
const path = options.url
|
|
70
|
-
.replace('{api-version}', config.VERSION)
|
|
71
|
-
.replace(/{(.*?)}/g, (substring, group) => {
|
|
72
|
-
var _a;
|
|
73
|
-
if ((_a = options.path) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(group)) {
|
|
74
|
-
return encoder(String(options.path[group]));
|
|
75
|
-
}
|
|
76
|
-
return substring;
|
|
77
|
-
});
|
|
78
|
-
const url = config.BASE + path;
|
|
79
|
-
return options.query ? url + (0, exports.getQueryString)(options.query) : url;
|
|
80
|
-
};
|
|
81
|
-
const getFormData = (options) => {
|
|
82
|
-
if (options.formData) {
|
|
83
|
-
const formData = new FormData();
|
|
84
|
-
const process = (key, value) => {
|
|
85
|
-
if ((0, exports.isString)(value) || (0, exports.isBlob)(value)) {
|
|
86
|
-
formData.append(key, value);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
formData.append(key, JSON.stringify(value));
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
Object.entries(options.formData)
|
|
93
|
-
.filter(([, value]) => value !== undefined && value !== null)
|
|
94
|
-
.forEach(([key, value]) => {
|
|
95
|
-
if (Array.isArray(value)) {
|
|
96
|
-
value.forEach(v => process(key, v));
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
process(key, value);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
return formData;
|
|
103
|
-
}
|
|
104
|
-
return undefined;
|
|
105
|
-
};
|
|
106
|
-
exports.getFormData = getFormData;
|
|
107
|
-
const resolve = (options, resolver) => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
-
if (typeof resolver === 'function') {
|
|
109
|
-
return resolver(options);
|
|
110
|
-
}
|
|
111
|
-
return resolver;
|
|
112
|
-
});
|
|
113
|
-
exports.resolve = resolve;
|
|
114
|
-
const getHeaders = (config, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
115
|
-
const [token, username, password, additionalHeaders] = yield Promise.all([
|
|
116
|
-
(0, exports.resolve)(options, config.TOKEN),
|
|
117
|
-
(0, exports.resolve)(options, config.USERNAME),
|
|
118
|
-
(0, exports.resolve)(options, config.PASSWORD),
|
|
119
|
-
(0, exports.resolve)(options, config.HEADERS),
|
|
120
|
-
]);
|
|
121
|
-
const headers = Object.entries(Object.assign(Object.assign({ Accept: 'application/json' }, additionalHeaders), options.headers))
|
|
122
|
-
.filter(([, value]) => value !== undefined && value !== null)
|
|
123
|
-
.reduce((headers, [key, value]) => (Object.assign(Object.assign({}, headers), { [key]: String(value) })), {});
|
|
124
|
-
if ((0, exports.isStringWithValue)(token)) {
|
|
125
|
-
headers['Authorization'] = `Bearer ${token}`;
|
|
126
|
-
}
|
|
127
|
-
if ((0, exports.isStringWithValue)(username) && (0, exports.isStringWithValue)(password)) {
|
|
128
|
-
const credentials = (0, exports.base64)(`${username}:${password}`);
|
|
129
|
-
headers['Authorization'] = `Basic ${credentials}`;
|
|
130
|
-
}
|
|
131
|
-
if (options.body !== undefined) {
|
|
132
|
-
if (options.mediaType) {
|
|
133
|
-
headers['Content-Type'] = options.mediaType;
|
|
134
|
-
}
|
|
135
|
-
else if ((0, exports.isBlob)(options.body)) {
|
|
136
|
-
headers['Content-Type'] = options.body.type || 'application/octet-stream';
|
|
137
|
-
}
|
|
138
|
-
else if ((0, exports.isString)(options.body)) {
|
|
139
|
-
headers['Content-Type'] = 'text/plain';
|
|
140
|
-
}
|
|
141
|
-
else if (!(0, exports.isFormData)(options.body)) {
|
|
142
|
-
headers['Content-Type'] = 'application/json';
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return new Headers(headers);
|
|
146
|
-
});
|
|
147
|
-
exports.getHeaders = getHeaders;
|
|
148
|
-
const getRequestBody = (options) => {
|
|
149
|
-
var _a, _b;
|
|
150
|
-
if (options.body !== undefined) {
|
|
151
|
-
if (((_a = options.mediaType) === null || _a === void 0 ? void 0 : _a.includes('application/json')) || ((_b = options.mediaType) === null || _b === void 0 ? void 0 : _b.includes('+json'))) {
|
|
152
|
-
return JSON.stringify(options.body);
|
|
153
|
-
}
|
|
154
|
-
else if ((0, exports.isString)(options.body) || (0, exports.isBlob)(options.body) || (0, exports.isFormData)(options.body)) {
|
|
155
|
-
return options.body;
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
return JSON.stringify(options.body);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return undefined;
|
|
162
|
-
};
|
|
163
|
-
exports.getRequestBody = getRequestBody;
|
|
164
|
-
const sendRequest = (config, options, url, body, formData, headers, onCancel) => __awaiter(void 0, void 0, void 0, function* () {
|
|
165
|
-
const controller = new AbortController();
|
|
166
|
-
let request = {
|
|
167
|
-
headers,
|
|
168
|
-
body: body !== null && body !== void 0 ? body : formData,
|
|
169
|
-
method: options.method,
|
|
170
|
-
signal: controller.signal,
|
|
171
|
-
};
|
|
172
|
-
if (config.WITH_CREDENTIALS) {
|
|
173
|
-
request.credentials = config.CREDENTIALS;
|
|
174
|
-
}
|
|
175
|
-
for (const fn of config.interceptors.request._fns) {
|
|
176
|
-
request = yield fn(request);
|
|
177
|
-
}
|
|
178
|
-
onCancel(() => controller.abort());
|
|
179
|
-
return yield fetch(url, request);
|
|
180
|
-
});
|
|
181
|
-
exports.sendRequest = sendRequest;
|
|
182
|
-
const getResponseHeader = (response, responseHeader) => {
|
|
183
|
-
if (responseHeader) {
|
|
184
|
-
const content = response.headers.get(responseHeader);
|
|
185
|
-
if ((0, exports.isString)(content)) {
|
|
186
|
-
return content;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return undefined;
|
|
190
|
-
};
|
|
191
|
-
exports.getResponseHeader = getResponseHeader;
|
|
192
|
-
const getResponseBody = (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
193
|
-
if (response.status !== 204) {
|
|
194
|
-
try {
|
|
195
|
-
const contentType = response.headers.get('Content-Type');
|
|
196
|
-
if (contentType) {
|
|
197
|
-
const binaryTypes = ['application/octet-stream', 'application/pdf', 'application/zip', 'audio/', 'image/', 'video/'];
|
|
198
|
-
if (contentType.includes('application/json') || contentType.includes('+json')) {
|
|
199
|
-
return yield response.json();
|
|
200
|
-
}
|
|
201
|
-
else if (binaryTypes.some(type => contentType.includes(type))) {
|
|
202
|
-
return yield response.blob();
|
|
203
|
-
}
|
|
204
|
-
else if (contentType.includes('multipart/form-data')) {
|
|
205
|
-
return yield response.formData();
|
|
206
|
-
}
|
|
207
|
-
else if (contentType.includes('text/')) {
|
|
208
|
-
return yield response.text();
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
catch (error) {
|
|
213
|
-
console.error(error);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return undefined;
|
|
217
|
-
});
|
|
218
|
-
exports.getResponseBody = getResponseBody;
|
|
219
|
-
const catchErrorCodes = (options, result) => {
|
|
220
|
-
var _a, _b;
|
|
221
|
-
const errors = Object.assign({ 400: 'Bad Request', 401: 'Unauthorized', 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', 405: 'Method Not Allowed', 406: 'Not Acceptable', 407: 'Proxy Authentication Required', 408: 'Request Timeout', 409: 'Conflict', 410: 'Gone', 411: 'Length Required', 412: 'Precondition Failed', 413: 'Payload Too Large', 414: 'URI Too Long', 415: 'Unsupported Media Type', 416: 'Range Not Satisfiable', 417: 'Expectation Failed', 418: 'Im a teapot', 421: 'Misdirected Request', 422: 'Unprocessable Content', 423: 'Locked', 424: 'Failed Dependency', 425: 'Too Early', 426: 'Upgrade Required', 428: 'Precondition Required', 429: 'Too Many Requests', 431: 'Request Header Fields Too Large', 451: 'Unavailable For Legal Reasons', 500: 'Internal Server Error', 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', 504: 'Gateway Timeout', 505: 'HTTP Version Not Supported', 506: 'Variant Also Negotiates', 507: 'Insufficient Storage', 508: 'Loop Detected', 510: 'Not Extended', 511: 'Network Authentication Required' }, options.errors);
|
|
222
|
-
const error = errors[result.status];
|
|
223
|
-
if (error) {
|
|
224
|
-
throw new ApiError_1.ApiError(options, result, error);
|
|
225
|
-
}
|
|
226
|
-
if (!result.ok) {
|
|
227
|
-
const errorStatus = (_a = result.status) !== null && _a !== void 0 ? _a : 'unknown';
|
|
228
|
-
const errorStatusText = (_b = result.statusText) !== null && _b !== void 0 ? _b : 'unknown';
|
|
229
|
-
const errorBody = (() => {
|
|
230
|
-
try {
|
|
231
|
-
return JSON.stringify(result.body, null, 2);
|
|
232
|
-
}
|
|
233
|
-
catch (e) {
|
|
234
|
-
return undefined;
|
|
235
|
-
}
|
|
236
|
-
})();
|
|
237
|
-
throw new ApiError_1.ApiError(options, result, `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`);
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
exports.catchErrorCodes = catchErrorCodes;
|
|
241
|
-
/**
|
|
242
|
-
* Request method
|
|
243
|
-
* @param config The OpenAPI configuration object
|
|
244
|
-
* @param options The request options from the service
|
|
245
|
-
* @returns CancelablePromise<T>
|
|
246
|
-
* @throws ApiError
|
|
247
|
-
*/
|
|
248
|
-
const request = (config, options) => {
|
|
249
|
-
return new CancelablePromise_1.CancelablePromise((resolve, reject, onCancel) => __awaiter(void 0, void 0, void 0, function* () {
|
|
250
|
-
try {
|
|
251
|
-
const url = getUrl(config, options);
|
|
252
|
-
const formData = (0, exports.getFormData)(options);
|
|
253
|
-
const body = (0, exports.getRequestBody)(options);
|
|
254
|
-
const headers = yield (0, exports.getHeaders)(config, options);
|
|
255
|
-
if (!onCancel.isCancelled) {
|
|
256
|
-
let response = yield (0, exports.sendRequest)(config, options, url, body, formData, headers, onCancel);
|
|
257
|
-
for (const fn of config.interceptors.response._fns) {
|
|
258
|
-
response = yield fn(response);
|
|
259
|
-
}
|
|
260
|
-
const responseBody = yield (0, exports.getResponseBody)(response);
|
|
261
|
-
const responseHeader = (0, exports.getResponseHeader)(response, options.responseHeader);
|
|
262
|
-
const result = {
|
|
263
|
-
url,
|
|
264
|
-
ok: response.ok,
|
|
265
|
-
status: response.status,
|
|
266
|
-
statusText: response.statusText,
|
|
267
|
-
body: responseHeader !== null && responseHeader !== void 0 ? responseHeader : responseBody,
|
|
268
|
-
};
|
|
269
|
-
(0, exports.catchErrorCodes)(options, result);
|
|
270
|
-
resolve(result.body);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
catch (error) {
|
|
274
|
-
reject(error);
|
|
275
|
-
}
|
|
276
|
-
}));
|
|
277
|
-
};
|
|
278
|
-
exports.request = request;
|
package/dist/s3Types.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* S3 object representation, either as a URI string or a record object
|
|
3
|
-
*/
|
|
4
|
-
export type S3Object = S3ObjectURI | S3ObjectRecord;
|
|
5
|
-
/**
|
|
6
|
-
* S3 object URI in the format `s3://storage/key`
|
|
7
|
-
*/
|
|
8
|
-
export type S3ObjectURI = `s3://${string}/${string}`;
|
|
9
|
-
/**
|
|
10
|
-
* S3 object record with file key, optional storage identifier, and optional presigned token
|
|
11
|
-
*/
|
|
12
|
-
export type S3ObjectRecord = {
|
|
13
|
-
/** File key/path in S3 bucket */
|
|
14
|
-
s3: string;
|
|
15
|
-
/** Storage backend identifier */
|
|
16
|
-
storage?: string;
|
|
17
|
-
/** Presigned URL query string for public access */
|
|
18
|
-
presigned?: string;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* S3 client configuration settings for Deno S3 light client
|
|
22
|
-
*/
|
|
23
|
-
export type DenoS3LightClientSettings = {
|
|
24
|
-
/** S3 endpoint URL */
|
|
25
|
-
endPoint: string;
|
|
26
|
-
/** AWS region */
|
|
27
|
-
region: string;
|
|
28
|
-
/** Bucket name */
|
|
29
|
-
bucket?: string;
|
|
30
|
-
/** Use HTTPS connection */
|
|
31
|
-
useSSL?: boolean;
|
|
32
|
-
/** AWS access key */
|
|
33
|
-
accessKey?: string;
|
|
34
|
-
/** AWS secret key */
|
|
35
|
-
secretKey?: string;
|
|
36
|
-
/** Use path-style URLs instead of virtual-hosted style */
|
|
37
|
-
pathStyle?: boolean;
|
|
38
|
-
};
|
package/dist/s3Types.js
DELETED