@windmill-labs/shared-utils 1.0.1 → 1.0.3
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/assets/tokens/colorTokensConfig.d.ts +2 -0
- package/base.d.ts +1 -0
- package/cloud.d.ts +1 -0
- package/common.d.ts +108 -0
- package/components/apps/components/display/dbtable/queries/count.d.ts +5 -0
- package/components/apps/components/display/dbtable/queries/delete.d.ts +5 -0
- package/components/apps/components/display/dbtable/queries/insert.d.ts +5 -0
- package/components/apps/components/display/dbtable/queries/select.d.ts +11 -0
- package/components/apps/components/display/dbtable/queries/update.d.ts +11 -0
- package/components/apps/components/display/dbtable/utils.d.ts +84 -0
- package/components/apps/editor/appPolicy.d.ts +3 -0
- package/components/apps/editor/appUtilsCore.d.ts +7 -0
- package/components/apps/editor/appUtilsS3.d.ts +22 -0
- package/components/apps/editor/commonAppUtils.d.ts +10 -0
- package/components/apps/editor/component/components.d.ts +5045 -0
- package/components/apps/editor/component/default-codes.d.ts +3 -0
- package/components/apps/editor/component/index.d.ts +3 -0
- package/components/apps/editor/component/sets.d.ts +7 -0
- package/components/apps/editor/componentsPanel/componentDefaultProps.d.ts +3 -0
- package/components/apps/gridUtils.d.ts +14 -0
- package/components/apps/inputType.d.ts +176 -0
- package/components/apps/rx.d.ts +29 -0
- package/components/apps/sharedTypes.d.ts +19 -0
- package/components/apps/types.d.ts +273 -0
- package/components/common/alert/model.d.ts +2 -0
- package/components/common/badge/model.d.ts +8 -0
- package/components/common/button/model.d.ts +45 -0
- package/components/common/fileInput/model.d.ts +1 -0
- package/components/common/index.d.ts +24 -0
- package/components/common/skeleton/model.d.ts +21 -0
- package/components/dbTypes.d.ts +11 -0
- package/components/diff_drawer.d.ts +26 -0
- package/components/ducklake.d.ts +1 -0
- package/components/flows/scheduleUtils.d.ts +7 -0
- package/components/random_positive_adjetive.d.ts +1 -0
- package/components/raw_apps/utils.d.ts +15 -0
- package/components/triggers/email/utils.d.ts +4 -0
- package/components/triggers/gcp/utils.d.ts +2 -0
- package/components/triggers/http/utils.d.ts +11 -0
- package/components/triggers/kafka/utils.d.ts +2 -0
- package/components/triggers/mqtt/utils.d.ts +2 -0
- package/components/triggers/nats/utils.d.ts +2 -0
- package/components/triggers/postgres/utils.d.ts +8 -0
- package/components/triggers/sqs/utils.d.ts +2 -0
- package/components/triggers/triggers.svelte.d.ts +32 -0
- package/components/triggers/utils.d.ts +81 -0
- package/components/triggers/websocket/utils.d.ts +2 -0
- package/components/triggers.d.ts +20 -0
- package/gen/core/ApiError.d.ts +10 -0
- package/gen/core/ApiRequestOptions.d.ts +13 -0
- package/gen/core/ApiResult.d.ts +7 -0
- package/gen/core/CancelablePromise.d.ts +26 -0
- package/gen/core/OpenAPI.d.ts +27 -0
- package/gen/core/request.d.ts +29 -0
- package/gen/index.d.ts +6 -0
- package/gen/schemas.gen.d.ts +6192 -0
- package/gen/services.gen.d.ts +5735 -0
- package/gen/types.gen.d.ts +20116 -0
- package/history.svelte.d.ts +9 -0
- package/hub.d.ts +48 -0
- package/lib.d.ts +3 -0
- package/lib.es.js +70 -3
- package/package.json +1 -1
- package/schema.d.ts +3 -0
- package/stores.d.ts +96 -0
- package/svelte5Utils.svelte.d.ts +49 -0
- package/toast.d.ts +8 -0
- package/utils.d.ts +250 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Value } from "$lib/utils";
|
|
2
|
+
export type DiffDrawerDiff = {
|
|
3
|
+
mode: 'normal';
|
|
4
|
+
deployed: Value;
|
|
5
|
+
draft: Value | undefined;
|
|
6
|
+
current: Value;
|
|
7
|
+
defaultDiffType?: 'deployed' | 'draft';
|
|
8
|
+
button?: {
|
|
9
|
+
text: string;
|
|
10
|
+
onClick: () => void;
|
|
11
|
+
};
|
|
12
|
+
} | {
|
|
13
|
+
mode: 'simple';
|
|
14
|
+
original: Value;
|
|
15
|
+
current: Value;
|
|
16
|
+
title: string;
|
|
17
|
+
button?: {
|
|
18
|
+
text: string;
|
|
19
|
+
onClick: () => void;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export interface DiffDrawerI {
|
|
23
|
+
openDrawer: () => void;
|
|
24
|
+
closeDrawer: () => void;
|
|
25
|
+
setDiff: (diff: DiffDrawerDiff) => void;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function wrapDucklakeQuery(query: string, ducklake: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Schedule, type TriggersCount } from '$lib/gen';
|
|
2
|
+
import type { ScheduleTrigger } from '../triggers';
|
|
3
|
+
import type { Writable } from 'svelte/store';
|
|
4
|
+
export declare function loadSchedule(path: string, workspace: string): Promise<ScheduleTrigger>;
|
|
5
|
+
export declare function loadSchedules(forceRefresh: boolean, path: string, isFlow: boolean, schedules: Writable<Schedule[] | undefined>, primarySchedule: Writable<ScheduleTrigger | false | undefined>, initialPrimarySchedule: Writable<ScheduleTrigger | false | undefined>, workspace: string, triggersCount: Writable<TriggersCount | undefined>, loadPrimarySchedule?: boolean, isDeployed?: Writable<boolean | undefined>): Promise<void>;
|
|
6
|
+
export declare function saveSchedule(path: string, newItem: boolean, workspace: string, primarySchedule: Writable<ScheduleTrigger | false | undefined>, isFlow: boolean): Promise<void>;
|
|
7
|
+
export declare function saveScheduleFromCfg(scheduleCfg: Record<string, any>, edit: boolean, workspace: string): Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function random_adj(): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ScriptLang } from '../../gen/types.gen';
|
|
2
|
+
import type { InlineScript } from '../apps/sharedTypes';
|
|
3
|
+
export type RunnableWithFields = any;
|
|
4
|
+
type RunnableWithInlineScript = RunnableWithFields & {
|
|
5
|
+
inlineScript?: InlineScript & {
|
|
6
|
+
language: ScriptLang;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export type Runnable = RunnableWithInlineScript | undefined;
|
|
10
|
+
export type RawApp = {
|
|
11
|
+
files: string[];
|
|
12
|
+
};
|
|
13
|
+
export declare function htmlContent(workspace: string, secret: string | undefined, ctx: any): string;
|
|
14
|
+
export declare function genWmillTs(runnables: Record<string, Runnable>): string;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Writable } from 'svelte/store';
|
|
2
|
+
export declare function getEmailAddress(local_part: string | undefined, workspaced_local_part: boolean, workspace_id: string, emailDomain: string): string;
|
|
3
|
+
export declare function saveEmailTriggerFromCfg(initialPath: string, emailCfg: Record<string, any>, edit: boolean, workspace: string, isAdmin: boolean, usedTriggerKinds: Writable<string[]>): Promise<boolean>;
|
|
4
|
+
export declare function getEmailDomain(): Promise<string>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { NewHttpTrigger } from '$lib/gen';
|
|
2
|
+
import type { Writable } from 'svelte/store';
|
|
3
|
+
export declare const SECRET_KEY_PATH = "secret_key_path";
|
|
4
|
+
export declare const HUB_SCRIPT_ID = 19670;
|
|
5
|
+
export declare const SIGNATURE_TEMPLATE_SCRIPT_HUB_PATH: string;
|
|
6
|
+
export declare const SIGNATURE_TEMPLATE_FLOW_HUB_ID = "67";
|
|
7
|
+
export declare function getHttpRoute(route_prefix: string, route_path: string | undefined, workspaced_route: boolean, workspace_id: string): string;
|
|
8
|
+
export declare function replacePlaceholderForSignatureScriptTemplate(content: string): string;
|
|
9
|
+
export declare function saveHttpRouteFromCfg(initialPath: string, routeCfg: Record<string, any>, edit: boolean, workspace: string, isAdmin: boolean, usedTriggerKinds: Writable<string[]>): Promise<boolean>;
|
|
10
|
+
export type Source = 'OpenAPI' | 'OpenAPI_File' | 'OpenAPI_URL';
|
|
11
|
+
export declare function generateHttpTriggerFromOpenApi(api: string, folderName: string): Promise<NewHttpTrigger[]>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Relations } from '$lib/gen';
|
|
2
|
+
import type { Writable } from 'svelte/store';
|
|
3
|
+
export declare function invalidRelations(relations: Relations[], options?: {
|
|
4
|
+
trackSchemaTableError?: boolean;
|
|
5
|
+
showError?: boolean;
|
|
6
|
+
}): string;
|
|
7
|
+
export declare function savePostgresTriggerFromCfg(initialPath: string, config: Record<string, any>, edit: boolean, workspace: string, usedTriggerKinds: Writable<string[]>): Promise<boolean>;
|
|
8
|
+
export declare function getDefaultTableToTrack(pg14: boolean): Relations[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type TriggersCount } from '$lib/gen';
|
|
2
|
+
import { type Trigger } from './utils';
|
|
3
|
+
import { type Writable } from 'svelte/store';
|
|
4
|
+
import type { TriggerType } from './utils';
|
|
5
|
+
import type { UserExt } from '$lib/stores';
|
|
6
|
+
import type { ScheduleTrigger } from '../triggers';
|
|
7
|
+
export declare class Triggers {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(triggers?: Trigger[], selectedIndex?: number, updateDraftCallback?: (() => void) | undefined);
|
|
10
|
+
get selectedTrigger(): Trigger | undefined;
|
|
11
|
+
get selectedTriggerIndex(): number | undefined;
|
|
12
|
+
set selectedTriggerIndex(index: number | undefined);
|
|
13
|
+
get triggers(): Trigger[];
|
|
14
|
+
setTriggers(triggers: Trigger[]): void;
|
|
15
|
+
setDraftConfig(triggerIndex: number, draftConfig: Record<string, any> | undefined): void;
|
|
16
|
+
getDraftTriggersSnapshot(): Trigger[] | undefined;
|
|
17
|
+
getSelectedTriggerSnapshot(): number | undefined;
|
|
18
|
+
addDraftTrigger(triggersCountStore: Writable<TriggersCount | undefined>, type: TriggerType, path?: string, draftCfg?: Record<string, any>): number;
|
|
19
|
+
deleteTrigger(triggersCountStore: Writable<TriggersCount | undefined>, triggerIndex: number): void;
|
|
20
|
+
updateTriggers(remoteTriggers: any[], type: TriggerType, user?: UserExt | undefined): number;
|
|
21
|
+
fetchSchedules(triggersCountStore: Writable<TriggersCount | undefined>, workspaceId: string | undefined, path: string, isFlow: boolean, primarySchedule?: ScheduleTrigger | undefined | false, user?: UserExt | undefined): Promise<void>;
|
|
22
|
+
fetchWebsocketTriggers(triggersCountStore: Writable<TriggersCount | undefined>, workspaceId: string | undefined, path: string, isFlow: boolean, user?: UserExt | undefined): Promise<void>;
|
|
23
|
+
fetchPostgresTriggers(triggersCountStore: Writable<TriggersCount | undefined>, workspaceId: string | undefined, path: string, isFlow: boolean, user?: UserExt | undefined): Promise<void>;
|
|
24
|
+
fetchKafkaTriggers(triggersCountStore: Writable<TriggersCount | undefined>, workspaceId: string | undefined, path: string, isFlow: boolean, user?: UserExt | undefined): Promise<void>;
|
|
25
|
+
fetchNatsTriggers(triggersCountStore: Writable<TriggersCount | undefined>, workspaceId: string | undefined, path: string, isFlow: boolean, user?: UserExt | undefined): Promise<void>;
|
|
26
|
+
fetchMqttTriggers(triggersCountStore: Writable<TriggersCount | undefined>, workspaceId: string | undefined, path: string, isFlow: boolean, user?: UserExt | undefined): Promise<void>;
|
|
27
|
+
fetchSqsTriggers(triggersCountStore: Writable<TriggersCount | undefined>, workspaceId: string | undefined, path: string, isFlow: boolean, user?: UserExt | undefined): Promise<void>;
|
|
28
|
+
fetchGcpTriggers(triggersCountStore: Writable<TriggersCount | undefined>, workspaceId: string | undefined, path: string, isFlow: boolean, user?: UserExt | undefined): Promise<void>;
|
|
29
|
+
fetchHttpTriggers(triggersCountStore: Writable<TriggersCount | undefined>, workspaceId: string | undefined, path: string, isFlow: boolean, user?: UserExt | undefined): Promise<void>;
|
|
30
|
+
fetchEmailTriggers(triggersCountStore: Writable<TriggersCount | undefined>, workspaceId: string | undefined, path: string, isFlow: boolean, user?: UserExt | undefined): Promise<void>;
|
|
31
|
+
fetchTriggers(triggersCountStore: Writable<TriggersCount | undefined>, workspaceId: string | undefined, path: string, isFlow: boolean, primarySchedule?: ScheduleTrigger | undefined | false, user?: UserExt | undefined): Promise<void>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Webhook, Mail, Calendar, Route, Unplug, Database, Terminal } from 'lucide-svelte';
|
|
2
|
+
import type { CaptureTriggerKind, ErrorHandler, Flow, NewScript, TriggersCount } from '$lib/gen/types.gen';
|
|
3
|
+
import type { Writable } from 'svelte/store';
|
|
4
|
+
import { type TriggerKind } from '$lib/components/triggers';
|
|
5
|
+
import type { Triggers } from './triggers.svelte';
|
|
6
|
+
export declare const CLOUD_DISABLED_TRIGGER_TYPES: string[];
|
|
7
|
+
export type TriggerType = 'webhook' | 'default_email' | 'email' | 'schedule' | 'http' | 'websocket' | 'postgres' | 'kafka' | 'nats' | 'mqtt' | 'sqs' | 'gcp' | 'email' | 'poll' | 'cli';
|
|
8
|
+
export declare const jobTriggerTypes: readonly ["webhook", "http", "websocket", "kafka", "email", "nats", "mqtt", "sqs", "postgres", "schedule", "gcp"];
|
|
9
|
+
export type JobTriggerType = (typeof jobTriggerTypes)[number];
|
|
10
|
+
export type Trigger = {
|
|
11
|
+
type: TriggerType;
|
|
12
|
+
path?: string;
|
|
13
|
+
isDraft?: boolean;
|
|
14
|
+
isPrimary?: boolean;
|
|
15
|
+
canWrite?: boolean;
|
|
16
|
+
id?: string;
|
|
17
|
+
draftConfig?: Record<string, any>;
|
|
18
|
+
captureConfig?: Record<string, any>;
|
|
19
|
+
extra?: Record<string, any>;
|
|
20
|
+
lightConfig?: Record<string, any>;
|
|
21
|
+
};
|
|
22
|
+
export declare const triggerIconMap: {
|
|
23
|
+
webhook: typeof Webhook;
|
|
24
|
+
email: typeof Mail;
|
|
25
|
+
default_email: typeof Mail;
|
|
26
|
+
schedule: typeof Calendar;
|
|
27
|
+
http: typeof Route;
|
|
28
|
+
websocket: typeof Unplug;
|
|
29
|
+
postgres: typeof Database;
|
|
30
|
+
kafka: import("svelte/legacy").LegacyComponentType;
|
|
31
|
+
nats: import("svelte/legacy").LegacyComponentType;
|
|
32
|
+
mqtt: import("svelte/legacy").LegacyComponentType;
|
|
33
|
+
sqs: import("svelte/legacy").LegacyComponentType;
|
|
34
|
+
gcp: import("svelte/legacy").LegacyComponentType;
|
|
35
|
+
primary_schedule: typeof Calendar;
|
|
36
|
+
poll: import("svelte/legacy").LegacyComponentType;
|
|
37
|
+
cli: typeof Terminal;
|
|
38
|
+
};
|
|
39
|
+
export declare const triggerDisplayNamesMap: {
|
|
40
|
+
readonly schedule: "Schedule";
|
|
41
|
+
readonly http: "HTTP";
|
|
42
|
+
readonly websocket: "WebSocket";
|
|
43
|
+
readonly postgres: "Postgres";
|
|
44
|
+
readonly kafka: "Kafka";
|
|
45
|
+
readonly nats: "NATS";
|
|
46
|
+
readonly mqtt: "MQTT";
|
|
47
|
+
readonly sqs: "SQS";
|
|
48
|
+
readonly gcp: "GCP Pub/Sub";
|
|
49
|
+
readonly email: "Email";
|
|
50
|
+
readonly poll: "Scheduled Poll";
|
|
51
|
+
readonly webhook: "Webhook";
|
|
52
|
+
readonly default_email: "Default Email";
|
|
53
|
+
readonly cli: "CLI";
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Converts a TriggerType to a CaptureTriggerKind when a mapping exists
|
|
57
|
+
* @param triggerType The trigger type to convert
|
|
58
|
+
* @returns The corresponding CaptureTriggerKind or undefined if no mapping exists
|
|
59
|
+
*/
|
|
60
|
+
export declare function triggerTypeToCaptureKind(triggerType: TriggerType): CaptureTriggerKind | undefined;
|
|
61
|
+
export declare function updateTriggersCount(triggersCountStore: Writable<TriggersCount | undefined>, type: TriggerType, action: 'add' | 'remove', primaryCfg?: Record<string, any>, isPrimary?: boolean): void;
|
|
62
|
+
export declare function triggerKindToTriggerType(kind: TriggerKind): TriggerType | undefined;
|
|
63
|
+
export declare function deployTriggers(triggersToDeploy: Trigger[], workspaceId: string | undefined, isAdmin: boolean, usedTriggerKinds: Writable<string[]>, initialPath?: string, isNew?: boolean): Promise<void>;
|
|
64
|
+
export declare function handleSelectTriggerFromKind(triggersState: Triggers, triggersCountStore: Writable<TriggersCount | undefined>, initialPath: string | undefined, triggerKind: TriggerKind): void;
|
|
65
|
+
export declare function handleConfigChange(nCfg: Record<string, any>, initialConfig: Record<string, any> | undefined, saveDisabled: boolean, edit: boolean, onConfigChange?: (cfg: Record<string, any>, saveDisabled: boolean, updated: boolean) => void): void;
|
|
66
|
+
export declare function getLightConfig(triggerType: TriggerType, trigger: Record<string, any>): Record<string, any> | undefined;
|
|
67
|
+
export declare function getTriggerLabel(trigger: Trigger): string;
|
|
68
|
+
export declare function sortTriggers(triggers: Trigger[]): Trigger[];
|
|
69
|
+
export type FlowWithDraftAndDraftTriggers = Flow & {
|
|
70
|
+
draft?: Flow & {
|
|
71
|
+
draft_triggers?: Trigger[];
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export type NewScriptWithDraftAndDraftTriggers = NewScript & {
|
|
75
|
+
draft?: NewScript & {
|
|
76
|
+
draft_triggers?: Trigger[];
|
|
77
|
+
};
|
|
78
|
+
hash: string;
|
|
79
|
+
};
|
|
80
|
+
export declare function filterDraftTriggers(savedValue: FlowWithDraftAndDraftTriggers | NewScriptWithDraftAndDraftTriggers, triggersState: Triggers): FlowWithDraftAndDraftTriggers | NewScriptWithDraftAndDraftTriggers;
|
|
81
|
+
export declare function getHandlerType(scriptPath: string): ErrorHandler;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CaptureTriggerKind, TriggersCount } from '$lib/gen';
|
|
2
|
+
import { type Writable } from 'svelte/store';
|
|
3
|
+
import { Triggers } from './triggers/triggers.svelte';
|
|
4
|
+
export type ScheduleTrigger = {
|
|
5
|
+
summary: string | undefined;
|
|
6
|
+
description?: string;
|
|
7
|
+
args: Record<string, any>;
|
|
8
|
+
cron: string;
|
|
9
|
+
timezone: string;
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type TriggerContext = {
|
|
13
|
+
triggersCount: Writable<TriggersCount | undefined>;
|
|
14
|
+
simplifiedPoll: Writable<boolean | undefined>;
|
|
15
|
+
showCaptureHint: Writable<boolean | undefined>;
|
|
16
|
+
triggersState: Triggers;
|
|
17
|
+
};
|
|
18
|
+
export declare function setScheduledPollSchedule(triggersState: Triggers, triggersCount: Writable<TriggersCount | undefined>): void;
|
|
19
|
+
export type TriggerKind = 'webhooks' | 'emails' | 'default_emails' | 'schedules' | 'cli' | 'routes' | 'websockets' | 'scheduledPoll' | 'kafka' | 'nats' | 'postgres' | 'mqtt' | 'sqs' | 'gcp';
|
|
20
|
+
export declare function captureTriggerKindToTriggerKind(kind: CaptureTriggerKind): TriggerKind;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,29 @@
|
|
|
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/gen/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ApiError } from './core/ApiError';
|
|
2
|
+
export { CancelablePromise, CancelError } from './core/CancelablePromise';
|
|
3
|
+
export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI';
|
|
4
|
+
export * from './schemas.gen';
|
|
5
|
+
export * from './services.gen';
|
|
6
|
+
export * from './types.gen';
|