@picsart/ai-sdk 1.149.1 → 3.17.4
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/_vendor/pa-model-pricing-sdk/index.d.ts +6 -0
- package/_vendor/pa-model-pricing-sdk/lib/ModelPricingClient.d.ts +30 -0
- package/_vendor/pa-model-pricing-sdk/lib/errors/ModelPricingClientError.d.ts +5 -0
- package/_vendor/pa-model-pricing-sdk/lib/errors/ModelPricingServerError.d.ts +3 -0
- package/_vendor/pa-model-pricing-sdk/lib/errors/ModelPricingUnknownError.d.ts +3 -0
- package/_vendor/pa-model-pricing-sdk/lib/types.d.ts +94 -0
- package/_vendor/workflows-client/index.d.ts +131 -0
- package/_vendor/workflows-types/index.d.ts +9327 -0
- package/index.d.ts +1190 -467
- package/index.js +5693 -1736
- package/package.json +18 -45
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ModelPricingClient } from './lib/ModelPricingClient';
|
|
2
|
+
import { ModelPricingClientError } from './lib/errors/ModelPricingClientError';
|
|
3
|
+
import { ModelPricingServerError } from './lib/errors/ModelPricingServerError';
|
|
4
|
+
import { ModelPricingUnknownError } from './lib/errors/ModelPricingUnknownError';
|
|
5
|
+
import { UseCase, PricingUnit, ModelPricingFilters, ModelPricingMetadata, SkuEntry, VendorCostEntry, ModelPricing, ModelPricingListResponse, ModelPricingClientOptions } from './lib/types';
|
|
6
|
+
export { ModelPricingClient, ModelPricingClientError, ModelPricingServerError, ModelPricingUnknownError, UseCase, PricingUnit, ModelPricingFilters, ModelPricingMetadata, SkuEntry, VendorCostEntry, ModelPricing, ModelPricingListResponse, ModelPricingClientOptions, };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ModelPricingClientOptions, ModelPricingFilters, ModelPricing } from './types';
|
|
2
|
+
export declare class ModelPricingClient {
|
|
3
|
+
private readonly options;
|
|
4
|
+
private readonly modelPricingApiBaseUrl;
|
|
5
|
+
private pricing;
|
|
6
|
+
private refreshTimer;
|
|
7
|
+
private readonly defaultHeaders;
|
|
8
|
+
constructor(options: ModelPricingClientOptions);
|
|
9
|
+
/**
|
|
10
|
+
* Loads pricing data and starts the periodic refresh scheduler.
|
|
11
|
+
* Must be called and awaited before getModelPricing.
|
|
12
|
+
*/
|
|
13
|
+
init(): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Stops the periodic refresh scheduler.
|
|
16
|
+
*/
|
|
17
|
+
stop(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Returns model pricings matching the given filters from the in-memory cache.
|
|
20
|
+
* Throws if pricing has not been loaded yet — call and await init() first.
|
|
21
|
+
*/
|
|
22
|
+
getModelPricing(filters?: ModelPricingFilters): ModelPricing[];
|
|
23
|
+
private loadAll;
|
|
24
|
+
private applyFilters;
|
|
25
|
+
private toSuccessResponse;
|
|
26
|
+
private throwIfError;
|
|
27
|
+
private wrapError;
|
|
28
|
+
private buildRequestHeaders;
|
|
29
|
+
private _fetch;
|
|
30
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export declare enum UseCase {
|
|
2
|
+
TextToImage = "text-to-image",
|
|
3
|
+
ImageToImage = "image-to-image",
|
|
4
|
+
TextToVideo = "text-to-video",
|
|
5
|
+
ImageToVideo = "image-to-video",
|
|
6
|
+
VideoToVideo = "video-to-video",
|
|
7
|
+
TextToSpeech = "text-to-speech",
|
|
8
|
+
TextToAudio = "text-to-audio",
|
|
9
|
+
SpeechToText = "speech-to-text",
|
|
10
|
+
ImageToAudio = "image-to-audio",
|
|
11
|
+
AudioToAudio = "audio-to-audio",
|
|
12
|
+
SpeechToSpeech = "speech-to-speech",
|
|
13
|
+
ChatCompletions = "chat-completions",
|
|
14
|
+
AudioToVideo = "audio-to-video",
|
|
15
|
+
VideoToAudio = "video-to-audio"
|
|
16
|
+
}
|
|
17
|
+
export declare enum PricingUnit {
|
|
18
|
+
Generation = "generation",
|
|
19
|
+
Megapixel = "megapixel",
|
|
20
|
+
Second = "second",
|
|
21
|
+
ThirtySecond = "30_second",
|
|
22
|
+
Minute = "minute",
|
|
23
|
+
ThousandCharacters = "1k_characters",
|
|
24
|
+
InputTokens = "input_tokens",
|
|
25
|
+
InputTextTokens = "input_text_tokens",
|
|
26
|
+
InputCachedTokens = "input_cached_tokens",
|
|
27
|
+
OutputImageTokens = "output_image_tokens",
|
|
28
|
+
OutputAudioTokens = "output_audio_tokens",
|
|
29
|
+
OutputTextTokens = "output_text_tokens"
|
|
30
|
+
}
|
|
31
|
+
export interface ModelPricingFilters {
|
|
32
|
+
vendor?: string;
|
|
33
|
+
modelId?: string;
|
|
34
|
+
useCase?: UseCase;
|
|
35
|
+
quality?: string;
|
|
36
|
+
audio?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface ModelPricingMetadata {
|
|
39
|
+
vendor: string;
|
|
40
|
+
model: string;
|
|
41
|
+
modelId: string;
|
|
42
|
+
useCase: UseCase;
|
|
43
|
+
quality: string;
|
|
44
|
+
audio: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface SkuEntry {
|
|
47
|
+
id: string;
|
|
48
|
+
}
|
|
49
|
+
export interface VendorCostEntry {
|
|
50
|
+
cost: number;
|
|
51
|
+
unit: PricingUnit;
|
|
52
|
+
skus: SkuEntry[];
|
|
53
|
+
}
|
|
54
|
+
export interface ModelPricing {
|
|
55
|
+
id: string;
|
|
56
|
+
operationId: string;
|
|
57
|
+
metadata: ModelPricingMetadata;
|
|
58
|
+
vendorCosts: VendorCostEntry[];
|
|
59
|
+
unit: PricingUnit;
|
|
60
|
+
credits: number;
|
|
61
|
+
costPerUnit: number;
|
|
62
|
+
legacy: boolean;
|
|
63
|
+
created: string;
|
|
64
|
+
updated: string;
|
|
65
|
+
}
|
|
66
|
+
export interface ModelPricingListResponse {
|
|
67
|
+
status: string;
|
|
68
|
+
response: ModelPricing[];
|
|
69
|
+
}
|
|
70
|
+
export interface ModelPricingClientOptions {
|
|
71
|
+
/** Base URL of the model pricing service. */
|
|
72
|
+
baseUrl: string;
|
|
73
|
+
/**
|
|
74
|
+
* Custom fetch implementation.
|
|
75
|
+
* When provided, the client delegates all HTTP calls to this function.
|
|
76
|
+
*/
|
|
77
|
+
fetch?: typeof fetch;
|
|
78
|
+
/**
|
|
79
|
+
* Extra headers to include in every request.
|
|
80
|
+
*/
|
|
81
|
+
headers?: Record<string, string>;
|
|
82
|
+
/**
|
|
83
|
+
* Interval in milliseconds at which the in-memory cache is refreshed by the
|
|
84
|
+
* background scheduler. The cache itself never expires; it is only replaced
|
|
85
|
+
* by a successful refresh. Set 0 to disable the scheduler.
|
|
86
|
+
* @default 600_000 (10 minutes)
|
|
87
|
+
*/
|
|
88
|
+
refreshIntervalMs?: number;
|
|
89
|
+
/**
|
|
90
|
+
* HTTP request timeout in milliseconds.
|
|
91
|
+
* @default 5_000
|
|
92
|
+
*/
|
|
93
|
+
timeoutMs?: number;
|
|
94
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { WorkflowTypes } from '../workflows-types/index';
|
|
2
|
+
export { WorkflowTypes } from '../workflows-types/index';
|
|
3
|
+
|
|
4
|
+
declare enum PicsartStatus {
|
|
5
|
+
SUCCESS = "success",
|
|
6
|
+
ERROR = "error"
|
|
7
|
+
}
|
|
8
|
+
type PicsartResponse = {
|
|
9
|
+
status: PicsartStatus.SUCCESS;
|
|
10
|
+
};
|
|
11
|
+
declare enum WorkflowStatus {
|
|
12
|
+
ACCEPTED = "ACCEPTED",
|
|
13
|
+
FAILED = "FAILED",
|
|
14
|
+
COMPLETED = "COMPLETED",
|
|
15
|
+
IN_PROGRESS = "IN_PROGRESS"
|
|
16
|
+
}
|
|
17
|
+
interface TaskCreditUsage {
|
|
18
|
+
toolId: string;
|
|
19
|
+
price: number;
|
|
20
|
+
amount: number;
|
|
21
|
+
credits: number;
|
|
22
|
+
details?: ToolUsage[];
|
|
23
|
+
}
|
|
24
|
+
interface ToolUsage {
|
|
25
|
+
toolId: string;
|
|
26
|
+
price: number;
|
|
27
|
+
amount: number;
|
|
28
|
+
credits: number;
|
|
29
|
+
}
|
|
30
|
+
type WorkflowApiResponse<R> = {
|
|
31
|
+
id: string;
|
|
32
|
+
status: WorkflowStatus;
|
|
33
|
+
updated: string;
|
|
34
|
+
result: R;
|
|
35
|
+
progress?: WorkflowProgress;
|
|
36
|
+
usage?: TaskCreditUsage;
|
|
37
|
+
events?: WorkflowEvent[];
|
|
38
|
+
};
|
|
39
|
+
type PartialWorkflowResult<R> = {
|
|
40
|
+
status: WorkflowStatus;
|
|
41
|
+
result: R;
|
|
42
|
+
};
|
|
43
|
+
type HistoryResponse<R> = PicsartResponse & {
|
|
44
|
+
response: {
|
|
45
|
+
id: string;
|
|
46
|
+
created: string;
|
|
47
|
+
status: WorkflowStatus;
|
|
48
|
+
params: {
|
|
49
|
+
prompt: string;
|
|
50
|
+
};
|
|
51
|
+
result: (R | null)[];
|
|
52
|
+
}[];
|
|
53
|
+
};
|
|
54
|
+
type WorkflowProgress = {
|
|
55
|
+
percent: number;
|
|
56
|
+
estimatedSecondsLeft?: number;
|
|
57
|
+
};
|
|
58
|
+
type OnPartialResultFn = <R>(result: WorkflowApiResponse<R> | PartialWorkflowResult<R>) => Promise<void> | void;
|
|
59
|
+
type OnProgressFn = (progress: WorkflowProgress) => Promise<void> | void;
|
|
60
|
+
declare enum ExecutionMode {
|
|
61
|
+
ASYNC = "ASYNC",
|
|
62
|
+
SYNC = "SYNC",
|
|
63
|
+
STREAM = "STREAM"
|
|
64
|
+
}
|
|
65
|
+
declare class ExecutionOptions {
|
|
66
|
+
mode?: ExecutionMode;
|
|
67
|
+
remoteSettingName?: string;
|
|
68
|
+
abortSignal?: AbortSignal;
|
|
69
|
+
retriesCount?: number;
|
|
70
|
+
pollingInterval?: number;
|
|
71
|
+
onPartialResult?: OnPartialResultFn;
|
|
72
|
+
onProgress?: OnProgressFn;
|
|
73
|
+
onAccepted?: (id: string) => Promise<void> | void;
|
|
74
|
+
onEvent?: (event: WorkflowEvent) => Promise<void> | void;
|
|
75
|
+
notificationConfig?: INotificationContext;
|
|
76
|
+
headers?: HeadersInit;
|
|
77
|
+
}
|
|
78
|
+
declare class ApiSettings {
|
|
79
|
+
executionMode?: ExecutionMode;
|
|
80
|
+
configId?: string;
|
|
81
|
+
}
|
|
82
|
+
interface WorkflowEvent {
|
|
83
|
+
type: string;
|
|
84
|
+
id?: string;
|
|
85
|
+
}
|
|
86
|
+
interface WorkflowResponse<R> {
|
|
87
|
+
result: R;
|
|
88
|
+
usage?: TaskCreditUsage;
|
|
89
|
+
}
|
|
90
|
+
interface INotificationContext {
|
|
91
|
+
projectId?: string;
|
|
92
|
+
miniappPackageId?: string;
|
|
93
|
+
actions?: INotificationContextAction[];
|
|
94
|
+
}
|
|
95
|
+
interface INotificationContextAction {
|
|
96
|
+
deeplink: string;
|
|
97
|
+
mobileDeeplink: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
type getRemoteSettingsFn = (name: string, tag?: string) => Promise<ApiSettings>;
|
|
101
|
+
interface ClientOptions {
|
|
102
|
+
baseUrl?: string;
|
|
103
|
+
fetch?: typeof fetch;
|
|
104
|
+
apiKey?: string;
|
|
105
|
+
identityToken?: string;
|
|
106
|
+
getRemoteSettings?: getRemoteSettingsFn;
|
|
107
|
+
headers?: HeadersInit;
|
|
108
|
+
}
|
|
109
|
+
declare class WorkflowsClient {
|
|
110
|
+
private readonly workflowsApiBaseUrl;
|
|
111
|
+
private readonly defaultHeaders;
|
|
112
|
+
private readonly options;
|
|
113
|
+
private readonly terminalStatuses;
|
|
114
|
+
constructor(options: ClientOptions);
|
|
115
|
+
run<R>(name: string, params: unknown, executionOptions?: ExecutionOptions): Promise<WorkflowResponse<R>>;
|
|
116
|
+
runTypeSafe<N extends keyof WorkflowTypes>(name: N, params: WorkflowTypes[N]['params'], executionOptions?: ExecutionOptions): Promise<WorkflowResponse<WorkflowTypes[N]['result']>>;
|
|
117
|
+
private postTask;
|
|
118
|
+
runPolling<R>(taskName: string, taskId: string, executionOptions?: ExecutionOptions): Promise<WorkflowResponse<R>>;
|
|
119
|
+
private executeTaskSync;
|
|
120
|
+
private getResult;
|
|
121
|
+
private executeTaskStream;
|
|
122
|
+
executionsHistory<R>(taskName: string, offset?: number, limit?: number, isGrouped?: boolean): Promise<HistoryResponse<R>>;
|
|
123
|
+
private toSuccessResponse;
|
|
124
|
+
private throwIfError;
|
|
125
|
+
private getApiSettings;
|
|
126
|
+
private wrapError;
|
|
127
|
+
private buildRequestHeaders;
|
|
128
|
+
private _fetch;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { ExecutionMode, ExecutionOptions, type WorkflowEvent, type WorkflowProgress, type WorkflowResponse, WorkflowStatus, WorkflowsClient };
|