@explo-tech/fido-api 2.12.10 → 3.0.0-jordan-testing
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/index.ts +2802 -178
- package/package.json +9 -3
- package/core/ApiError.ts +0 -24
- package/core/ApiRequestOptions.ts +0 -16
- package/core/ApiResult.ts +0 -10
- package/core/CancelablePromise.ts +0 -130
- package/core/OpenAPI.ts +0 -31
- package/core/request.ts +0 -307
- package/models/AggregateProperty.ts +0 -15
- package/models/Aggregation.ts +0 -13
- package/models/AggregationOption.ts +0 -8
- package/models/And.ts +0 -11
- package/models/And1.ts +0 -11
- package/models/BigQuery.ts +0 -13
- package/models/BigQueryAuthentication.ts +0 -9
- package/models/BooleanPropertyValue.ts +0 -9
- package/models/Branch.ts +0 -9
- package/models/BranchResponse.ts +0 -12
- package/models/BranchResponseMetadata.ts +0 -8
- package/models/CacheTelemetry.ts +0 -10
- package/models/CalendarInterval.ts +0 -12
- package/models/CalendarIntervalGrouping.ts +0 -14
- package/models/Clickhouse.ts +0 -18
- package/models/ClickhouseConnectionType.ts +0 -8
- package/models/ClientError.ts +0 -9
- package/models/ColumnFormat.ts +0 -10
- package/models/Commit.ts +0 -11
- package/models/CommitResponse.ts +0 -10
- package/models/Computation.ts +0 -19
- package/models/ComputedView.ts +0 -20
- package/models/CreateCommitRequest.ts +0 -13
- package/models/CreateCommitResponse.ts +0 -11
- package/models/CreateViewChange.ts +0 -12
- package/models/CreateViewDiff.ts +0 -11
- package/models/DataPage.ts +0 -10
- package/models/DataRecord.ts +0 -10
- package/models/DataRequestParameters.ts +0 -11
- package/models/DataResponseMetadata.ts +0 -12
- package/models/DataSchema.ts +0 -10
- package/models/DataSource.ts +0 -14
- package/models/DataSourceConfiguration.ts +0 -17
- package/models/DataSourceError.ts +0 -14
- package/models/DataSourceRequest.ts +0 -10
- package/models/DataSourceResponse.ts +0 -13
- package/models/DatePart.ts +0 -10
- package/models/DatePartGrouping.ts +0 -14
- package/models/DatePropertyValue.ts +0 -9
- package/models/DateTimeColumnFormat.ts +0 -14
- package/models/DateTimeFormat.ts +0 -9
- package/models/DateTimePropertyValue.ts +0 -9
- package/models/DecimalColumnFormat.ts +0 -15
- package/models/DecimalIntervalGrouping.ts +0 -11
- package/models/DecimalPropertyValue.ts +0 -9
- package/models/DeleteViewChange.ts +0 -9
- package/models/DeleteViewDiff.ts +0 -11
- package/models/DiffBranchResponse.ts +0 -10
- package/models/DoublePropertyValue.ts +0 -9
- package/models/DurationColumnFormat.ts +0 -9
- package/models/EmailConfiguration.ts +0 -10
- package/models/Equal.ts +0 -12
- package/models/Equal1.ts +0 -13
- package/models/EvictionPolicy.ts +0 -9
- package/models/ExportColumnOptions.ts +0 -12
- package/models/ExportFormat.ts +0 -9
- package/models/ExportTargetConfiguration.ts +0 -13
- package/models/Filter.ts +0 -25
- package/models/FormulaProperty.ts +0 -10
- package/models/GreaterThan.ts +0 -12
- package/models/GreaterThan1.ts +0 -13
- package/models/GreaterThanOrEqual.ts +0 -12
- package/models/GreaterThanOrEqual1.ts +0 -13
- package/models/Grouping.ts +0 -15
- package/models/Having.ts +0 -25
- package/models/In.ts +0 -12
- package/models/In1.ts +0 -13
- package/models/IntegerIntervalGrouping.ts +0 -11
- package/models/IntegerPropertyValue.ts +0 -9
- package/models/JdbcAuthentication.ts +0 -8
- package/models/LateBoundEqual.ts +0 -10
- package/models/LateBoundEqual1.ts +0 -12
- package/models/LateBoundGreaterThan.ts +0 -10
- package/models/LateBoundGreaterThan1.ts +0 -12
- package/models/LateBoundGreaterThanOrEqual.ts +0 -10
- package/models/LateBoundGreaterThanOrEqual1.ts +0 -12
- package/models/LateBoundIn.ts +0 -10
- package/models/LateBoundIn1.ts +0 -12
- package/models/LateBoundLessThan.ts +0 -10
- package/models/LateBoundLessThan1.ts +0 -12
- package/models/LateBoundLessThanOrEqual.ts +0 -10
- package/models/LateBoundLessThanOrEqual1.ts +0 -12
- package/models/LateBoundStringContains.ts +0 -11
- package/models/LateBoundStringContains1.ts +0 -13
- package/models/LessThan.ts +0 -12
- package/models/LessThan1.ts +0 -13
- package/models/LessThanOrEqual.ts +0 -12
- package/models/LessThanOrEqual1.ts +0 -13
- package/models/ListBranchResponse.ts +0 -10
- package/models/ListNamespacesResponse.ts +0 -10
- package/models/ListVersionedViewsRequest.ts +0 -8
- package/models/ListViewsRequest.ts +0 -8
- package/models/ListViewsResponse.ts +0 -10
- package/models/MSS.ts +0 -16
- package/models/MergeBranchRequest.ts +0 -9
- package/models/MySql.ts +0 -16
- package/models/Namespace.ts +0 -10
- package/models/NamespaceRequest.ts +0 -10
- package/models/NamespaceResponse.ts +0 -14
- package/models/NamespaceResponseMetadata.ts +0 -12
- package/models/Not.ts +0 -11
- package/models/Not1.ts +0 -11
- package/models/Null.ts +0 -9
- package/models/Null1.ts +0 -11
- package/models/Or.ts +0 -11
- package/models/Or1.ts +0 -11
- package/models/PagingConfiguration.ts +0 -9
- package/models/PasswordAuthentication.ts +0 -10
- package/models/Postgres.ts +0 -16
- package/models/Property.ts +0 -12
- package/models/PropertySchema.ts +0 -13
- package/models/PropertyType.ts +0 -15
- package/models/PropertyValue.ts +0 -14
- package/models/PublicTunnel.ts +0 -8
- package/models/QueryExecutionError.ts +0 -13
- package/models/QueryExecutionResponse.ts +0 -14
- package/models/QueryExportEmailResponse.ts +0 -8
- package/models/QueryExportLinkResponse.ts +0 -9
- package/models/QueryExportResponse.ts +0 -9
- package/models/QueryPreviewRequest.ts +0 -14
- package/models/QueryTimeoutError.ts +0 -13
- package/models/Redshift.ts +0 -16
- package/models/RequestExecutionParameters.ts +0 -8
- package/models/RequestTelemetry.ts +0 -13
- package/models/SSHAuthentication.ts +0 -11
- package/models/SSHTunnel.ts +0 -15
- package/models/ScheduledEviction.ts +0 -9
- package/models/Snowflake.ts +0 -17
- package/models/SnowflakeAuthentication.ts +0 -8
- package/models/SnowflakePasswordAuthentication.ts +0 -9
- package/models/Sort.ts +0 -11
- package/models/SortDirection.ts +0 -8
- package/models/SourceProperty.ts +0 -10
- package/models/StringContains.ts +0 -13
- package/models/StringContains1.ts +0 -14
- package/models/StringPropertyValue.ts +0 -9
- package/models/TablePreviewRequest.ts +0 -11
- package/models/TableView.ts +0 -18
- package/models/Tenant.ts +0 -14
- package/models/TenantKey.ts +0 -10
- package/models/TenantPrivateKeyAuthentication.ts +0 -10
- package/models/TenantRequest.ts +0 -11
- package/models/TenantResponse.ts +0 -10
- package/models/TenantS3Configuration.ts +0 -11
- package/models/TestConnectionRequest.ts +0 -10
- package/models/TestConnectionResponse.ts +0 -8
- package/models/TtlEviction.ts +0 -9
- package/models/Tunnel.ts +0 -9
- package/models/UUID.ts +0 -5
- package/models/UnitOfMeasurement.ts +0 -7
- package/models/UpdateViewChange.ts +0 -11
- package/models/UpdateViewDiff.ts +0 -12
- package/models/ValueGrouping.ts +0 -10
- package/models/VendorPrivateKeyAuthentication.ts +0 -9
- package/models/View.ts +0 -17
- package/models/ViewChange.ts +0 -10
- package/models/ViewDiff.ts +0 -10
- package/models/ViewExportRequest.ts +0 -18
- package/models/ViewRequest.ts +0 -19
- package/models/ViewResponse.ts +0 -10
- package/models/ViewRunRequest.ts +0 -15
- package/services/BranchResourceService.ts +0 -112
- package/services/CommitResourceService.ts +0 -48
- package/services/DataSourceResourceService.ts +0 -146
- package/services/HealthResourceService.ts +0 -45
- package/services/ListViewsResourceService.ts +0 -73
- package/services/NamespaceResourceService.ts +0 -120
- package/services/QueryResourceService.ts +0 -207
- package/services/TenantResourceService.ts +0 -89
- package/services/TestConnectionResourceService.ts +0 -56
- package/services/ViewResourceService.ts +0 -130
package/package.json
CHANGED
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
"name": "@explo-tech/fido-api",
|
|
3
3
|
"description": "Fido api",
|
|
4
4
|
"homepage": "https://github.com/trust-kaz/fido",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "3.0.0-jordan-testing",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/trust-kaz/fido"
|
|
9
9
|
},
|
|
10
|
-
"devDependencies":{
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"openapi-typescript-codegen": "^0.24.0"
|
|
12
|
+
},
|
|
11
13
|
"publishConfig": {
|
|
12
14
|
"registry": "https://registry.npmjs.org"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@zodios/core": "^10.9.6",
|
|
18
|
+
"zod": "^3.23.8"
|
|
13
19
|
}
|
|
14
|
-
}
|
|
20
|
+
}
|
package/core/ApiError.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
5
|
-
import type { ApiResult } from './ApiResult';
|
|
6
|
-
|
|
7
|
-
export class ApiError extends Error {
|
|
8
|
-
public readonly url: string;
|
|
9
|
-
public readonly status: number;
|
|
10
|
-
public readonly statusText: string;
|
|
11
|
-
public readonly body: any;
|
|
12
|
-
public readonly request: ApiRequestOptions;
|
|
13
|
-
|
|
14
|
-
constructor(request: ApiRequestOptions, response: ApiResult, message: string) {
|
|
15
|
-
super(message);
|
|
16
|
-
|
|
17
|
-
this.name = 'ApiError';
|
|
18
|
-
this.url = response.url;
|
|
19
|
-
this.status = response.status;
|
|
20
|
-
this.statusText = response.statusText;
|
|
21
|
-
this.body = response.body;
|
|
22
|
-
this.request = request;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
export type ApiRequestOptions = {
|
|
5
|
-
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
|
|
6
|
-
readonly url: string;
|
|
7
|
-
readonly path?: Record<string, any>;
|
|
8
|
-
readonly cookies?: Record<string, any>;
|
|
9
|
-
readonly headers?: Record<string, any>;
|
|
10
|
-
readonly query?: Record<string, any>;
|
|
11
|
-
readonly formData?: Record<string, any>;
|
|
12
|
-
readonly body?: any;
|
|
13
|
-
readonly mediaType?: string;
|
|
14
|
-
readonly responseHeader?: string;
|
|
15
|
-
readonly errors?: Record<number, string>;
|
|
16
|
-
};
|
package/core/ApiResult.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
export class CancelError extends Error {
|
|
5
|
-
|
|
6
|
-
constructor(message: string) {
|
|
7
|
-
super(message);
|
|
8
|
-
this.name = 'CancelError';
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
public get isCancelled(): boolean {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface OnCancel {
|
|
17
|
-
readonly isResolved: boolean;
|
|
18
|
-
readonly isRejected: boolean;
|
|
19
|
-
readonly isCancelled: boolean;
|
|
20
|
-
|
|
21
|
-
(cancelHandler: () => void): void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class CancelablePromise<T> implements Promise<T> {
|
|
25
|
-
#isResolved: boolean;
|
|
26
|
-
#isRejected: boolean;
|
|
27
|
-
#isCancelled: boolean;
|
|
28
|
-
readonly #cancelHandlers: (() => void)[];
|
|
29
|
-
readonly #promise: Promise<T>;
|
|
30
|
-
#resolve?: (value: T | PromiseLike<T>) => void;
|
|
31
|
-
#reject?: (reason?: any) => void;
|
|
32
|
-
|
|
33
|
-
constructor(
|
|
34
|
-
executor: (
|
|
35
|
-
resolve: (value: T | PromiseLike<T>) => void,
|
|
36
|
-
reject: (reason?: any) => void,
|
|
37
|
-
onCancel: OnCancel
|
|
38
|
-
) => void
|
|
39
|
-
) {
|
|
40
|
-
this.#isResolved = false;
|
|
41
|
-
this.#isRejected = false;
|
|
42
|
-
this.#isCancelled = false;
|
|
43
|
-
this.#cancelHandlers = [];
|
|
44
|
-
this.#promise = new Promise<T>((resolve, reject) => {
|
|
45
|
-
this.#resolve = resolve;
|
|
46
|
-
this.#reject = reject;
|
|
47
|
-
|
|
48
|
-
const onResolve = (value: T | PromiseLike<T>): void => {
|
|
49
|
-
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
this.#isResolved = true;
|
|
53
|
-
this.#resolve?.(value);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const onReject = (reason?: any): void => {
|
|
57
|
-
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
this.#isRejected = true;
|
|
61
|
-
this.#reject?.(reason);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const onCancel = (cancelHandler: () => void): void => {
|
|
65
|
-
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
this.#cancelHandlers.push(cancelHandler);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
Object.defineProperty(onCancel, 'isResolved', {
|
|
72
|
-
get: (): boolean => this.#isResolved,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
Object.defineProperty(onCancel, 'isRejected', {
|
|
76
|
-
get: (): boolean => this.#isRejected,
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
Object.defineProperty(onCancel, 'isCancelled', {
|
|
80
|
-
get: (): boolean => this.#isCancelled,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
return executor(onResolve, onReject, onCancel as OnCancel);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
get [Symbol.toStringTag]() {
|
|
88
|
-
return "Cancellable Promise";
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public then<TResult1 = T, TResult2 = never>(
|
|
92
|
-
onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
|
|
93
|
-
onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null
|
|
94
|
-
): Promise<TResult1 | TResult2> {
|
|
95
|
-
return this.#promise.then(onFulfilled, onRejected);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
public catch<TResult = never>(
|
|
99
|
-
onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null
|
|
100
|
-
): Promise<T | TResult> {
|
|
101
|
-
return this.#promise.catch(onRejected);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public finally(onFinally?: (() => void) | null): Promise<T> {
|
|
105
|
-
return this.#promise.finally(onFinally);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public cancel(): void {
|
|
109
|
-
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
this.#isCancelled = true;
|
|
113
|
-
if (this.#cancelHandlers.length) {
|
|
114
|
-
try {
|
|
115
|
-
for (const cancelHandler of this.#cancelHandlers) {
|
|
116
|
-
cancelHandler();
|
|
117
|
-
}
|
|
118
|
-
} catch (error) {
|
|
119
|
-
console.warn('Cancellation threw an error', error);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
this.#cancelHandlers.length = 0;
|
|
124
|
-
this.#reject?.(new CancelError('Request aborted'));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public get isCancelled(): boolean {
|
|
128
|
-
return this.#isCancelled;
|
|
129
|
-
}
|
|
130
|
-
}
|
package/core/OpenAPI.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
5
|
-
|
|
6
|
-
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
|
7
|
-
type Headers = Record<string, string>;
|
|
8
|
-
|
|
9
|
-
export type OpenAPIConfig = {
|
|
10
|
-
BASE: string;
|
|
11
|
-
VERSION: string;
|
|
12
|
-
WITH_CREDENTIALS: boolean;
|
|
13
|
-
CREDENTIALS: 'include' | 'omit' | 'same-origin';
|
|
14
|
-
TOKEN?: string | Resolver<string>;
|
|
15
|
-
USERNAME?: string | Resolver<string>;
|
|
16
|
-
PASSWORD?: string | Resolver<string>;
|
|
17
|
-
HEADERS?: Headers | Resolver<Headers>;
|
|
18
|
-
ENCODE_PATH?: (path: string) => string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const OpenAPI: OpenAPIConfig = {
|
|
22
|
-
BASE: '',
|
|
23
|
-
VERSION: '0.1',
|
|
24
|
-
WITH_CREDENTIALS: false,
|
|
25
|
-
CREDENTIALS: 'include',
|
|
26
|
-
TOKEN: undefined,
|
|
27
|
-
USERNAME: undefined,
|
|
28
|
-
PASSWORD: undefined,
|
|
29
|
-
HEADERS: undefined,
|
|
30
|
-
ENCODE_PATH: undefined,
|
|
31
|
-
};
|
package/core/request.ts
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
import { ApiError } from './ApiError';
|
|
5
|
-
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
6
|
-
import type { ApiResult } from './ApiResult';
|
|
7
|
-
import { CancelablePromise } from './CancelablePromise';
|
|
8
|
-
import type { OnCancel } from './CancelablePromise';
|
|
9
|
-
import type { OpenAPIConfig } from './OpenAPI';
|
|
10
|
-
|
|
11
|
-
const isDefined = <T>(value: T | null | undefined): value is Exclude<T, null | undefined> => {
|
|
12
|
-
return value !== undefined && value !== null;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const isString = (value: any): value is string => {
|
|
16
|
-
return typeof value === 'string';
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const isStringWithValue = (value: any): value is string => {
|
|
20
|
-
return isString(value) && value !== '';
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const isBlob = (value: any): value is Blob => {
|
|
24
|
-
return (
|
|
25
|
-
typeof value === 'object' &&
|
|
26
|
-
typeof value.type === 'string' &&
|
|
27
|
-
typeof value.stream === 'function' &&
|
|
28
|
-
typeof value.arrayBuffer === 'function' &&
|
|
29
|
-
typeof value.constructor === 'function' &&
|
|
30
|
-
typeof value.constructor.name === 'string' &&
|
|
31
|
-
/^(Blob|File)$/.test(value.constructor.name) &&
|
|
32
|
-
/^(Blob|File)$/.test(value[Symbol.toStringTag])
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const isFormData = (value: any): value is FormData => {
|
|
37
|
-
return value instanceof FormData;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const base64 = (str: string): string => {
|
|
41
|
-
try {
|
|
42
|
-
return btoa(str);
|
|
43
|
-
} catch (err) {
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
return Buffer.from(str).toString('base64');
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const getQueryString = (params: Record<string, any>): string => {
|
|
50
|
-
const qs: string[] = [];
|
|
51
|
-
|
|
52
|
-
const append = (key: string, value: any) => {
|
|
53
|
-
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const process = (key: string, value: any) => {
|
|
57
|
-
if (isDefined(value)) {
|
|
58
|
-
if (Array.isArray(value)) {
|
|
59
|
-
value.forEach(v => {
|
|
60
|
-
process(key, v);
|
|
61
|
-
});
|
|
62
|
-
} else if (typeof value === 'object') {
|
|
63
|
-
Object.entries(value).forEach(([k, v]) => {
|
|
64
|
-
process(`${key}[${k}]`, v);
|
|
65
|
-
});
|
|
66
|
-
} else {
|
|
67
|
-
append(key, value);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
73
|
-
process(key, value);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
if (qs.length > 0) {
|
|
77
|
-
return `?${qs.join('&')}`;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return '';
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => {
|
|
84
|
-
const encoder = config.ENCODE_PATH || encodeURI;
|
|
85
|
-
|
|
86
|
-
const path = options.url
|
|
87
|
-
.replace('{api-version}', config.VERSION)
|
|
88
|
-
.replace(/{(.*?)}/g, (substring: string, group: string) => {
|
|
89
|
-
if (options.path?.hasOwnProperty(group)) {
|
|
90
|
-
return encoder(String(options.path[group]));
|
|
91
|
-
}
|
|
92
|
-
return substring;
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const url = `${config.BASE}${path}`;
|
|
96
|
-
if (options.query) {
|
|
97
|
-
return `${url}${getQueryString(options.query)}`;
|
|
98
|
-
}
|
|
99
|
-
return url;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const getFormData = (options: ApiRequestOptions): FormData | undefined => {
|
|
103
|
-
if (options.formData) {
|
|
104
|
-
const formData = new FormData();
|
|
105
|
-
|
|
106
|
-
const process = (key: string, value: any) => {
|
|
107
|
-
if (isString(value) || isBlob(value)) {
|
|
108
|
-
formData.append(key, value);
|
|
109
|
-
} else {
|
|
110
|
-
formData.append(key, JSON.stringify(value));
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
Object.entries(options.formData)
|
|
115
|
-
.filter(([_, value]) => isDefined(value))
|
|
116
|
-
.forEach(([key, value]) => {
|
|
117
|
-
if (Array.isArray(value)) {
|
|
118
|
-
value.forEach(v => process(key, v));
|
|
119
|
-
} else {
|
|
120
|
-
process(key, value);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
return formData;
|
|
125
|
-
}
|
|
126
|
-
return undefined;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
|
130
|
-
|
|
131
|
-
const resolve = async <T>(options: ApiRequestOptions, resolver?: T | Resolver<T>): Promise<T | undefined> => {
|
|
132
|
-
if (typeof resolver === 'function') {
|
|
133
|
-
return (resolver as Resolver<T>)(options);
|
|
134
|
-
}
|
|
135
|
-
return resolver;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise<Headers> => {
|
|
139
|
-
const token = await resolve(options, config.TOKEN);
|
|
140
|
-
const username = await resolve(options, config.USERNAME);
|
|
141
|
-
const password = await resolve(options, config.PASSWORD);
|
|
142
|
-
const additionalHeaders = await resolve(options, config.HEADERS);
|
|
143
|
-
|
|
144
|
-
const headers = Object.entries({
|
|
145
|
-
Accept: 'application/json',
|
|
146
|
-
...additionalHeaders,
|
|
147
|
-
...options.headers,
|
|
148
|
-
})
|
|
149
|
-
.filter(([_, value]) => isDefined(value))
|
|
150
|
-
.reduce((headers, [key, value]) => ({
|
|
151
|
-
...headers,
|
|
152
|
-
[key]: String(value),
|
|
153
|
-
}), {} as Record<string, string>);
|
|
154
|
-
|
|
155
|
-
if (isStringWithValue(token)) {
|
|
156
|
-
headers['Authorization'] = `Bearer ${token}`;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
160
|
-
const credentials = base64(`${username}:${password}`);
|
|
161
|
-
headers['Authorization'] = `Basic ${credentials}`;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (options.body) {
|
|
165
|
-
if (options.mediaType) {
|
|
166
|
-
headers['Content-Type'] = options.mediaType;
|
|
167
|
-
} else if (isBlob(options.body)) {
|
|
168
|
-
headers['Content-Type'] = options.body.type || 'application/octet-stream';
|
|
169
|
-
} else if (isString(options.body)) {
|
|
170
|
-
headers['Content-Type'] = 'text/plain';
|
|
171
|
-
} else if (!isFormData(options.body)) {
|
|
172
|
-
headers['Content-Type'] = 'application/json';
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return new Headers(headers);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const getRequestBody = (options: ApiRequestOptions): any => {
|
|
180
|
-
if (options.body !== undefined) {
|
|
181
|
-
if (options.mediaType?.includes('/json')) {
|
|
182
|
-
return JSON.stringify(options.body)
|
|
183
|
-
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
|
184
|
-
return options.body;
|
|
185
|
-
} else {
|
|
186
|
-
return JSON.stringify(options.body);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return undefined;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
export const sendRequest = async (
|
|
193
|
-
config: OpenAPIConfig,
|
|
194
|
-
options: ApiRequestOptions,
|
|
195
|
-
url: string,
|
|
196
|
-
body: any,
|
|
197
|
-
formData: FormData | undefined,
|
|
198
|
-
headers: Headers,
|
|
199
|
-
onCancel: OnCancel
|
|
200
|
-
): Promise<Response> => {
|
|
201
|
-
const controller = new AbortController();
|
|
202
|
-
|
|
203
|
-
const request: RequestInit = {
|
|
204
|
-
headers,
|
|
205
|
-
body: body ?? formData,
|
|
206
|
-
method: options.method,
|
|
207
|
-
signal: controller.signal,
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
if (config.WITH_CREDENTIALS) {
|
|
211
|
-
request.credentials = config.CREDENTIALS;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
onCancel(() => controller.abort());
|
|
215
|
-
|
|
216
|
-
return await fetch(url, request);
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => {
|
|
220
|
-
if (responseHeader) {
|
|
221
|
-
const content = response.headers.get(responseHeader);
|
|
222
|
-
if (isString(content)) {
|
|
223
|
-
return content;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return undefined;
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
const getResponseBody = async (response: Response): Promise<any> => {
|
|
230
|
-
if (response.status !== 204) {
|
|
231
|
-
try {
|
|
232
|
-
const contentType = response.headers.get('Content-Type');
|
|
233
|
-
if (contentType) {
|
|
234
|
-
const jsonTypes = ['application/json', 'application/problem+json']
|
|
235
|
-
const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
|
|
236
|
-
if (isJSON) {
|
|
237
|
-
return await response.json();
|
|
238
|
-
} else {
|
|
239
|
-
return await response.text();
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
} catch (error) {
|
|
243
|
-
console.error(error);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return undefined;
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => {
|
|
250
|
-
const errors: Record<number, string> = {
|
|
251
|
-
400: 'Bad Request',
|
|
252
|
-
401: 'Unauthorized',
|
|
253
|
-
403: 'Forbidden',
|
|
254
|
-
404: 'Not Found',
|
|
255
|
-
500: 'Internal Server Error',
|
|
256
|
-
502: 'Bad Gateway',
|
|
257
|
-
503: 'Service Unavailable',
|
|
258
|
-
...options.errors,
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const error = errors[result.status];
|
|
262
|
-
if (error) {
|
|
263
|
-
throw new ApiError(options, result, error);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (!result.ok) {
|
|
267
|
-
throw new ApiError(options, result, 'Generic Error');
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Request method
|
|
273
|
-
* @param config The OpenAPI configuration object
|
|
274
|
-
* @param options The request options from the service
|
|
275
|
-
* @returns CancelablePromise<T>
|
|
276
|
-
* @throws ApiError
|
|
277
|
-
*/
|
|
278
|
-
export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise<T> => {
|
|
279
|
-
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
|
280
|
-
try {
|
|
281
|
-
const url = getUrl(config, options);
|
|
282
|
-
const formData = getFormData(options);
|
|
283
|
-
const body = getRequestBody(options);
|
|
284
|
-
const headers = await getHeaders(config, options);
|
|
285
|
-
|
|
286
|
-
if (!onCancel.isCancelled) {
|
|
287
|
-
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
|
|
288
|
-
const responseBody = await getResponseBody(response);
|
|
289
|
-
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
290
|
-
|
|
291
|
-
const result: ApiResult = {
|
|
292
|
-
url,
|
|
293
|
-
ok: response.ok,
|
|
294
|
-
status: response.status,
|
|
295
|
-
statusText: response.statusText,
|
|
296
|
-
body: responseHeader ?? responseBody,
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
catchErrorCodes(options, result);
|
|
300
|
-
|
|
301
|
-
resolve(result.body);
|
|
302
|
-
}
|
|
303
|
-
} catch (error) {
|
|
304
|
-
reject(error);
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
|
|
5
|
-
import type { Aggregation } from './Aggregation';
|
|
6
|
-
import type { AggregationOption } from './AggregationOption';
|
|
7
|
-
|
|
8
|
-
export type AggregateProperty = {
|
|
9
|
-
targetPropertyId: string | null;
|
|
10
|
-
'@type': 'aggregate';
|
|
11
|
-
propertyId: string | null;
|
|
12
|
-
aggregation: Aggregation;
|
|
13
|
-
aggregationOption?: AggregationOption | null;
|
|
14
|
-
};
|
|
15
|
-
|
package/models/Aggregation.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
|
|
5
|
-
export enum Aggregation {
|
|
6
|
-
AVG = 'avg',
|
|
7
|
-
COUNT = 'count',
|
|
8
|
-
COUNT_DISTINCT = 'count-distinct',
|
|
9
|
-
MAX = 'max',
|
|
10
|
-
MIN = 'min',
|
|
11
|
-
PERCENTILE = 'percentile',
|
|
12
|
-
SUM = 'sum',
|
|
13
|
-
}
|
package/models/And.ts
DELETED
package/models/And1.ts
DELETED
package/models/BigQuery.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
|
|
5
|
-
import type { BigQueryAuthentication } from './BigQueryAuthentication';
|
|
6
|
-
import type { Tunnel } from './Tunnel';
|
|
7
|
-
|
|
8
|
-
export type BigQuery = {
|
|
9
|
-
tunnel: Tunnel;
|
|
10
|
-
'@type': 'bigquery';
|
|
11
|
-
authentication: BigQueryAuthentication;
|
|
12
|
-
};
|
|
13
|
-
|
package/models/Branch.ts
DELETED
package/models/BranchResponse.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
|
|
5
|
-
import type { Branch } from './Branch';
|
|
6
|
-
import type { BranchResponseMetadata } from './BranchResponseMetadata';
|
|
7
|
-
|
|
8
|
-
export type BranchResponse = {
|
|
9
|
-
branch: Branch;
|
|
10
|
-
meta: BranchResponseMetadata | null;
|
|
11
|
-
};
|
|
12
|
-
|