@sogni-ai/sogni-client 4.2.0-alpha.2 → 4.2.0-alpha.21
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/CHANGELOG.md +148 -0
- package/CLAUDE.md +25 -3
- package/README.md +411 -136
- package/dist/Account/index.d.ts +4 -2
- package/dist/Account/index.js +27 -23
- package/dist/Account/index.js.map +1 -1
- package/dist/Account/types.d.ts +7 -0
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.d.ts +3 -1
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js +26 -2
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js.map +1 -1
- package/dist/ApiClient/WebSocketClient/eventSubscriptions.d.ts +33 -0
- package/dist/ApiClient/WebSocketClient/eventSubscriptions.js +39 -0
- package/dist/ApiClient/WebSocketClient/eventSubscriptions.js.map +1 -0
- package/dist/ApiClient/WebSocketClient/events.d.ts +24 -7
- package/dist/ApiClient/WebSocketClient/index.d.ts +5 -1
- package/dist/ApiClient/WebSocketClient/index.js +24 -1
- package/dist/ApiClient/WebSocketClient/index.js.map +1 -1
- package/dist/ApiClient/WebSocketClient/messages.d.ts +2 -0
- package/dist/ApiClient/WebSocketClient/types.d.ts +2 -0
- package/dist/ApiClient/index.d.ts +6 -1
- package/dist/ApiClient/index.js +7 -3
- package/dist/ApiClient/index.js.map +1 -1
- package/dist/Chat/ChatTools.d.ts +5 -49
- package/dist/Chat/ChatTools.js +311 -88
- package/dist/Chat/ChatTools.js.map +1 -1
- package/dist/Chat/index.d.ts +11 -2
- package/dist/Chat/index.js +78 -4
- package/dist/Chat/index.js.map +1 -1
- package/dist/Chat/modelRouting.d.ts +100 -0
- package/dist/Chat/modelRouting.js +441 -0
- package/dist/Chat/modelRouting.js.map +1 -0
- package/dist/Chat/sogniHostedTools.generated.json +529 -0
- package/dist/Chat/tools.d.ts +9 -55
- package/dist/Chat/tools.js +72 -228
- package/dist/Chat/tools.js.map +1 -1
- package/dist/Chat/types.d.ts +91 -2
- package/dist/CreativeWorkflows/index.d.ts +23 -0
- package/dist/CreativeWorkflows/index.js +274 -0
- package/dist/CreativeWorkflows/index.js.map +1 -0
- package/dist/CreativeWorkflows/types.d.ts +106 -0
- package/dist/CreativeWorkflows/types.js +3 -0
- package/dist/CreativeWorkflows/types.js.map +1 -0
- package/dist/Projects/Job.d.ts +6 -0
- package/dist/Projects/Job.js +60 -5
- package/dist/Projects/Job.js.map +1 -1
- package/dist/Projects/Project.js +15 -3
- package/dist/Projects/Project.js.map +1 -1
- package/dist/Projects/createJobRequestMessage.js +140 -6
- package/dist/Projects/createJobRequestMessage.js.map +1 -1
- package/dist/Projects/index.d.ts +10 -1
- package/dist/Projects/index.js +197 -58
- package/dist/Projects/index.js.map +1 -1
- package/dist/Projects/types/ModelOptions.d.ts +3 -3
- package/dist/Projects/types/ModelOptions.js +12 -5
- package/dist/Projects/types/ModelOptions.js.map +1 -1
- package/dist/Projects/types/ModelTiersRaw.d.ts +7 -7
- package/dist/Projects/types/RawProject.d.ts +2 -0
- package/dist/Projects/types/events.d.ts +5 -4
- package/dist/Projects/types/index.d.ts +77 -7
- package/dist/Projects/types/index.js.map +1 -1
- package/dist/Projects/utils/index.d.ts +8 -1
- package/dist/Projects/utils/index.js +22 -8
- package/dist/Projects/utils/index.js.map +1 -1
- package/dist/index.d.ts +28 -3
- package/dist/index.js +19 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/RestClient.d.ts +4 -1
- package/dist/lib/RestClient.js +17 -9
- package/dist/lib/RestClient.js.map +1 -1
- package/dist/lib/mediaValidation.d.ts +16 -0
- package/dist/lib/mediaValidation.js +280 -0
- package/dist/lib/mediaValidation.js.map +1 -0
- package/dist/lib/validation.d.ts +6 -1
- package/dist/lib/validation.js +28 -2
- package/dist/lib/validation.js.map +1 -1
- package/llms-full.txt +372 -133
- package/llms.txt +197 -86
- package/package.json +13 -4
- package/src/Account/index.ts +22 -2
- package/src/Account/types.ts +7 -0
- package/src/ApiClient/WebSocketClient/BrowserWebSocketClient/index.ts +47 -3
- package/src/ApiClient/WebSocketClient/eventSubscriptions.ts +92 -0
- package/src/ApiClient/WebSocketClient/events.ts +25 -7
- package/src/ApiClient/WebSocketClient/index.ts +33 -1
- package/src/ApiClient/WebSocketClient/messages.ts +2 -0
- package/src/ApiClient/WebSocketClient/types.ts +2 -0
- package/src/ApiClient/index.ts +32 -2
- package/src/Chat/ChatTools.ts +395 -95
- package/src/Chat/index.ts +149 -5
- package/src/Chat/modelRouting.ts +602 -0
- package/src/Chat/sogniHostedTools.generated.json +529 -0
- package/src/Chat/tools.ts +98 -245
- package/src/Chat/types.ts +100 -2
- package/src/CreativeWorkflows/index.ts +290 -0
- package/src/CreativeWorkflows/types.ts +134 -0
- package/src/Projects/Job.ts +76 -5
- package/src/Projects/Project.ts +13 -3
- package/src/Projects/createJobRequestMessage.ts +152 -13
- package/src/Projects/index.ts +230 -52
- package/src/Projects/types/ModelOptions.ts +15 -8
- package/src/Projects/types/ModelTiersRaw.ts +7 -7
- package/src/Projects/types/RawProject.ts +2 -0
- package/src/Projects/types/events.ts +5 -4
- package/src/Projects/types/index.ts +86 -6
- package/src/Projects/utils/index.ts +24 -8
- package/src/index.ts +93 -0
- package/src/lib/RestClient.ts +15 -5
- package/src/lib/mediaValidation.ts +367 -0
- package/src/lib/validation.ts +38 -2
|
@@ -45,14 +45,21 @@ function mapComfyImageTier(tier) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
function mapVideoTier(tier) {
|
|
48
|
-
|
|
48
|
+
const options = {
|
|
49
49
|
type: 'video',
|
|
50
|
-
steps: mapRange(tier.steps),
|
|
51
|
-
guidance: mapRange(tier.guidance),
|
|
52
50
|
scheduler: mapOptions(tier.comfyScheduler, scheduler_1.schedulerValueToAlias),
|
|
53
|
-
sampler: mapOptions(tier.comfySampler, samplers_1.samplerValueToAlias)
|
|
54
|
-
fps: tier.fps
|
|
51
|
+
sampler: mapOptions(tier.comfySampler, samplers_1.samplerValueToAlias)
|
|
55
52
|
};
|
|
53
|
+
if (tier.steps) {
|
|
54
|
+
options.steps = mapRange(tier.steps);
|
|
55
|
+
}
|
|
56
|
+
if (tier.guidance) {
|
|
57
|
+
options.guidance = mapRange(tier.guidance);
|
|
58
|
+
}
|
|
59
|
+
if (tier.fps) {
|
|
60
|
+
options.fps = tier.fps;
|
|
61
|
+
}
|
|
62
|
+
return options;
|
|
56
63
|
}
|
|
57
64
|
function mapAudioTier(tier) {
|
|
58
65
|
const options = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelOptions.js","sourceRoot":"","sources":["../../../src/Projects/types/ModelOptions.ts"],"names":[],"mappings":";;AA+EA,oCAQC;AAED,8CAQC;AAED,
|
|
1
|
+
{"version":3,"file":"ModelOptions.js","sourceRoot":"","sources":["../../../src/Projects/types/ModelOptions.ts"],"names":[],"mappings":";;AA+EA,oCAQC;AAED,8CAQC;AAED,oCAgBC;AAED,oCA8BC;AAlJD,gDAAwD;AACxD,kDAA2D;AAuD3D,SAAS,QAAQ,CAAC,IAAqB;IACrC,OAAO;QACL,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;QACtE,OAAO,EAAE,IAAI,CAAC,OAAO;KACtB,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAI,IAA4B,EAAE,SAAS,CAAC,KAAQ,EAAE,EAAE,CAAC,KAAK;IAC/E,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO;YACL,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IACD,OAAO;QACL,OAAO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EAAE,CAAC;QACxB,OAAO,CAAC,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -43,14 +43,14 @@ export interface VideoTier {
|
|
|
43
43
|
audioDuration?: DurationDefaults;
|
|
44
44
|
audioStart?: DurationDefaults;
|
|
45
45
|
benchmark: Benchmark;
|
|
46
|
-
comfySampler
|
|
47
|
-
comfyScheduler
|
|
48
|
-
fps
|
|
49
|
-
frames
|
|
50
|
-
guidance
|
|
46
|
+
comfySampler?: StringDefaults;
|
|
47
|
+
comfyScheduler?: StringDefaults;
|
|
48
|
+
fps?: NumericOptions;
|
|
49
|
+
frames?: NumericDefaults;
|
|
50
|
+
guidance?: NumericDefaults;
|
|
51
51
|
height: NumericDefaults;
|
|
52
|
-
shift
|
|
53
|
-
steps
|
|
52
|
+
shift?: NumericDefaults;
|
|
53
|
+
steps?: NumericDefaults;
|
|
54
54
|
type: 'video';
|
|
55
55
|
videoStart?: DurationDefaults;
|
|
56
56
|
width: NumericDefaults;
|
|
@@ -35,8 +35,9 @@ export interface JobStarted extends JobEventBase {
|
|
|
35
35
|
}
|
|
36
36
|
export interface JobProgress extends JobEventBase {
|
|
37
37
|
type: 'progress';
|
|
38
|
-
step
|
|
39
|
-
stepCount
|
|
38
|
+
step?: number;
|
|
39
|
+
stepCount?: number;
|
|
40
|
+
progress?: number;
|
|
40
41
|
}
|
|
41
42
|
export interface JobETA extends JobEventBase {
|
|
42
43
|
type: 'jobETA';
|
|
@@ -48,8 +49,8 @@ export interface JobPreview extends JobEventBase {
|
|
|
48
49
|
}
|
|
49
50
|
export interface JobCompleted extends JobEventBase {
|
|
50
51
|
type: 'completed';
|
|
51
|
-
steps
|
|
52
|
-
seed
|
|
52
|
+
steps?: number;
|
|
53
|
+
seed?: number;
|
|
53
54
|
/**
|
|
54
55
|
* URL to the result image, could be null if the job was canceled or triggered NSFW filter while
|
|
55
56
|
* it was not disabled by the user
|
|
@@ -28,7 +28,9 @@ export interface SizePreset {
|
|
|
28
28
|
ratio: string;
|
|
29
29
|
aspect: string;
|
|
30
30
|
}
|
|
31
|
-
export type ImageOutputFormat = 'png' | 'jpg';
|
|
31
|
+
export type ImageOutputFormat = 'png' | 'jpg' | 'webp';
|
|
32
|
+
export type GptImageQuality = 'low' | 'medium' | 'high' | 'auto' | 'standard' | 'hd';
|
|
33
|
+
export type GptImageBackground = 'opaque' | 'auto';
|
|
32
34
|
export type VideoOutputFormat = 'mp4';
|
|
33
35
|
export type AudioOutputFormat = 'mp3' | 'flac' | 'wav';
|
|
34
36
|
export interface BaseProjectParams {
|
|
@@ -80,6 +82,10 @@ export interface BaseProjectParams {
|
|
|
80
82
|
* If not specified, the Sogni token will be used.
|
|
81
83
|
*/
|
|
82
84
|
tokenType?: TokenType;
|
|
85
|
+
/**
|
|
86
|
+
* Optional client app/source label to attach to the project request for server-side attribution.
|
|
87
|
+
*/
|
|
88
|
+
appSource?: string;
|
|
83
89
|
/**
|
|
84
90
|
* Array of LoRA IDs to apply.
|
|
85
91
|
* Available LoRAs are model-specific. The worker will download the LoRA
|
|
@@ -116,6 +122,14 @@ export type InputMedia = File | Buffer | Blob | boolean;
|
|
|
116
122
|
* - Frame count is calculated as: `duration * fps + 1`
|
|
117
123
|
* - Frame count must follow the pattern: `1 + n*8` (i.e., 1, 9, 17, 25, 33, ...)
|
|
118
124
|
* - Example: 5 seconds at 24fps = 121 frames (since 121 = 1 + 15*8)
|
|
125
|
+
*
|
|
126
|
+
* ### Seedance 2.0 Models (seedance-2-0*)
|
|
127
|
+
* - External API-backed video models for text-to-video, image-to-video,
|
|
128
|
+
* multimodal reference generation, image+audio-to-video, and video-to-video
|
|
129
|
+
* - Generate at fixed 24fps
|
|
130
|
+
* - Direct SDK project duration range is 4 to 15 seconds
|
|
131
|
+
* - Frame count is calculated as: `duration * 24 + 1`
|
|
132
|
+
* - Vendor reference limits are 9 images, 3 videos, 3 audios, and 12 asset files total
|
|
119
133
|
*/
|
|
120
134
|
export interface VideoProjectParams extends BaseProjectParams {
|
|
121
135
|
type: 'video';
|
|
@@ -126,11 +140,13 @@ export interface VideoProjectParams extends BaseProjectParams {
|
|
|
126
140
|
*/
|
|
127
141
|
frames?: number;
|
|
128
142
|
/**
|
|
129
|
-
* Duration of the video in seconds. Supported range 1 to 10 (WAN)
|
|
143
|
+
* Duration of the video in seconds. Supported range 1 to 10 (WAN), 4 to 20 (LTX-2.3),
|
|
144
|
+
* or 4 to 15 (Seedance direct SDK projects).
|
|
130
145
|
*
|
|
131
146
|
* The SDK automatically calculates the correct frame count based on the model:
|
|
132
147
|
* - WAN 2.2: `duration * 16 + 1` (always 16fps generation)
|
|
133
148
|
* - LTX-2.3: `duration * fps + 1`, snapped to frame step constraint
|
|
149
|
+
* - Seedance: `duration * 24 + 1`
|
|
134
150
|
*/
|
|
135
151
|
duration?: number;
|
|
136
152
|
/**
|
|
@@ -141,6 +157,8 @@ export interface VideoProjectParams extends BaseProjectParams {
|
|
|
141
157
|
*
|
|
142
158
|
* **LTX-2.3 Models:** Any value from 1-60 fps. This directly controls the generation
|
|
143
159
|
* frame rate - there is no post-render interpolation.
|
|
160
|
+
*
|
|
161
|
+
* **Seedance Models:** Fixed 24fps external API generation.
|
|
144
162
|
*/
|
|
145
163
|
fps?: number;
|
|
146
164
|
/**
|
|
@@ -160,6 +178,12 @@ export interface VideoProjectParams extends BaseProjectParams {
|
|
|
160
178
|
* Maps to: startImage (i2v), characterImage (animate), referenceImage (s2v, ia2v)
|
|
161
179
|
*/
|
|
162
180
|
referenceImage?: InputMedia;
|
|
181
|
+
/**
|
|
182
|
+
* Seedance-only loose image context references. These must be publicly
|
|
183
|
+
* accessible HTTPS URLs that the vendor can fetch. Use referenceImage /
|
|
184
|
+
* referenceImageEnd when the image should lock the first or last frame.
|
|
185
|
+
*/
|
|
186
|
+
referenceImageUrls?: string[];
|
|
163
187
|
/**
|
|
164
188
|
* Optional end image for i2v interpolation workflows.
|
|
165
189
|
* When provided with referenceImage, the video will interpolate between the two images.
|
|
@@ -169,6 +193,17 @@ export interface VideoProjectParams extends BaseProjectParams {
|
|
|
169
193
|
* Reference audio for audio-driven video workflows (s2v, ia2v, a2v).
|
|
170
194
|
*/
|
|
171
195
|
referenceAudio?: InputMedia;
|
|
196
|
+
/**
|
|
197
|
+
* Seedance-only audio context references. These must be publicly accessible
|
|
198
|
+
* HTTPS URLs. Seedance does not support text+audio-only requests; include at
|
|
199
|
+
* least one image or video reference when using audio URL references.
|
|
200
|
+
*/
|
|
201
|
+
referenceAudioUrls?: string[];
|
|
202
|
+
/**
|
|
203
|
+
* Enable native audio generation for external API-backed video models that support it.
|
|
204
|
+
* Seedance defaults to audio enabled server-side; set to false to request a silent video.
|
|
205
|
+
*/
|
|
206
|
+
generateAudio?: boolean;
|
|
172
207
|
/**
|
|
173
208
|
* Reference audio for ID-LoRA speaker identity transfer (LTX-2.3 only).
|
|
174
209
|
* Provide a ~5 second audio clip of the target speaker's voice.
|
|
@@ -201,6 +236,11 @@ export interface VideoProjectParams extends BaseProjectParams {
|
|
|
201
236
|
* Maps to: drivingVideo (animate-move), sourceVideo (animate-replace), referenceVideo (v2v)
|
|
202
237
|
*/
|
|
203
238
|
referenceVideo?: InputMedia;
|
|
239
|
+
/**
|
|
240
|
+
* Seedance-only video context references. These must be publicly accessible
|
|
241
|
+
* HTTPS URLs and map to Seedance reference_video assets.
|
|
242
|
+
*/
|
|
243
|
+
referenceVideoUrls?: string[];
|
|
204
244
|
/**
|
|
205
245
|
* ControlNet parameters for LTX-2.3 v2v workflows.
|
|
206
246
|
* Specifies which control signal to extract from the reference video.
|
|
@@ -296,6 +336,7 @@ export interface ImageProjectParams extends BaseProjectParams {
|
|
|
296
336
|
startingImageStrength?: number;
|
|
297
337
|
/**
|
|
298
338
|
* Context images for multi-reference image generation.
|
|
339
|
+
* GPT Image 2 supports up to 16 context images.
|
|
299
340
|
* Flux.2 Dev supports up to 6 context images.
|
|
300
341
|
* Qwen Image Edit Plus supports up to 3 context images.
|
|
301
342
|
* Flux Kontext supports up to 2 context images.
|
|
@@ -332,6 +373,15 @@ export interface ImageProjectParams extends BaseProjectParams {
|
|
|
332
373
|
* Output format. Can be 'png' or 'jpg'. Defaults to 'png'.
|
|
333
374
|
*/
|
|
334
375
|
outputFormat?: ImageOutputFormat;
|
|
376
|
+
/**
|
|
377
|
+
* GPT Image 2 quality preset. Only used by external OpenAI image models.
|
|
378
|
+
* Defaults to 'medium'.
|
|
379
|
+
*/
|
|
380
|
+
gptImageQuality?: GptImageQuality;
|
|
381
|
+
/**
|
|
382
|
+
* GPT Image 2 background mode. Only used by external OpenAI image models.
|
|
383
|
+
*/
|
|
384
|
+
gptImageBackground?: GptImageBackground;
|
|
335
385
|
}
|
|
336
386
|
export interface AudioProjectParams extends BaseProjectParams {
|
|
337
387
|
type: 'audio';
|
|
@@ -416,7 +466,7 @@ export type VideoFormat = 'mp4' | 'mov';
|
|
|
416
466
|
export type ImageUrlParams = {
|
|
417
467
|
imageId: string;
|
|
418
468
|
jobId: string;
|
|
419
|
-
type: 'preview' | 'complete' | 'startingImage' | 'cnImage' | 'contextImage1' | 'contextImage2' | 'contextImage3' | 'contextImage4' | 'contextImage5' | 'contextImage6' | 'referenceImage' | 'referenceImageEnd';
|
|
469
|
+
type: 'preview' | 'complete' | 'startingImage' | 'cnImage' | 'contextImage1' | 'contextImage2' | 'contextImage3' | 'contextImage4' | 'contextImage5' | 'contextImage6' | 'contextImage7' | 'contextImage8' | 'contextImage9' | 'contextImage10' | 'contextImage11' | 'contextImage12' | 'contextImage13' | 'contextImage14' | 'contextImage15' | 'contextImage16' | 'referenceImage' | 'referenceImageEnd';
|
|
420
470
|
startContentType?: string;
|
|
421
471
|
contentType?: string;
|
|
422
472
|
};
|
|
@@ -487,10 +537,18 @@ export interface EstimateRequest {
|
|
|
487
537
|
*/
|
|
488
538
|
sampler?: string;
|
|
489
539
|
/**
|
|
490
|
-
* Number of context images to use
|
|
491
|
-
*
|
|
540
|
+
* Number of context images to use. Affects GPT Image 2 input-image pricing
|
|
541
|
+
* and context-aware worker timing estimates.
|
|
492
542
|
*/
|
|
493
543
|
contextImages?: number;
|
|
544
|
+
/**
|
|
545
|
+
* GPT Image 2 quality preset, when estimating external OpenAI image jobs.
|
|
546
|
+
*/
|
|
547
|
+
gptImageQuality?: GptImageQuality;
|
|
548
|
+
/**
|
|
549
|
+
* Output format, when estimating models with format-specific request metadata.
|
|
550
|
+
*/
|
|
551
|
+
outputFormat?: ImageOutputFormat;
|
|
494
552
|
}
|
|
495
553
|
export interface VideoEstimateRequest {
|
|
496
554
|
tokenType: TokenType;
|
|
@@ -504,8 +562,20 @@ export interface VideoEstimateRequest {
|
|
|
504
562
|
*/
|
|
505
563
|
frames?: number;
|
|
506
564
|
fps: number;
|
|
507
|
-
steps
|
|
565
|
+
steps?: number;
|
|
508
566
|
numberOfMedia: number;
|
|
567
|
+
/**
|
|
568
|
+
* Price Seedance estimates using the video-input rate band.
|
|
569
|
+
*/
|
|
570
|
+
hasVideoInput?: boolean;
|
|
571
|
+
/**
|
|
572
|
+
* Optional estimate-only signal: presence implies Seedance video-input pricing.
|
|
573
|
+
*/
|
|
574
|
+
referenceVideo?: unknown;
|
|
575
|
+
/**
|
|
576
|
+
* Optional estimate-only signal: non-empty list implies Seedance video-input pricing.
|
|
577
|
+
*/
|
|
578
|
+
referenceVideoUrls?: string[];
|
|
509
579
|
}
|
|
510
580
|
export interface AudioEstimateRequest {
|
|
511
581
|
tokenType: TokenType;
|
|
@@ -529,7 +599,7 @@ export interface CostEstimation {
|
|
|
529
599
|
}
|
|
530
600
|
export type EnhancementStrength = 'light' | 'medium' | 'heavy';
|
|
531
601
|
/**
|
|
532
|
-
* Video workflow types for WAN
|
|
602
|
+
* Video workflow types for WAN, LTX-2.3, and Seedance models
|
|
533
603
|
*/
|
|
534
604
|
export type VideoWorkflowType = 't2v' | 'i2v' | 's2v' | 'ia2v' | 'a2v' | 'v2v' | 'animate-move' | 'animate-replace' | null;
|
|
535
605
|
export type AssetRequirement = 'required' | 'optional' | 'forbidden';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Projects/types/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Projects/types/index.ts"],"names":[],"mappings":";;AA2cA,sCAEC;AAED,sCAEC;AAED,sCAEC;AAVD,SAAgB,aAAa,CAAC,MAAqB;IACjD,OAAO,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC;AACjC,CAAC;AAED,SAAgB,aAAa,CAAC,MAAqB;IACjD,OAAO,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC;AACjC,CAAC;AAED,SAAgB,aAAa,CAAC,MAAqB;IACjD,OAAO,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC;AACjC,CAAC"}
|
|
@@ -41,6 +41,13 @@ export declare function isWanAnimateModel(modelId: string): boolean;
|
|
|
41
41
|
* ltx2- model IDs to ltx23- equivalents).
|
|
42
42
|
*/
|
|
43
43
|
export declare function isLtx2Model(modelId: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Check if a model ID is a Seedance 2.0 video model.
|
|
46
|
+
*
|
|
47
|
+
* Seedance models are external API-backed video models. They generate at
|
|
48
|
+
* 24fps and support 4-15 second direct SDK project durations.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isSeedanceModel(modelId: string): boolean;
|
|
44
51
|
/**
|
|
45
52
|
* LTX-2.3 frame step constraint.
|
|
46
53
|
* Valid frame counts follow the pattern: 1 + n*8 (i.e., 1, 9, 17, 25, 33, ...)
|
|
@@ -49,7 +56,7 @@ export declare const LTX2_FRAME_STEP = 8;
|
|
|
49
56
|
/**
|
|
50
57
|
* Calculate the frame count for a given duration and fps based on the video model.
|
|
51
58
|
*
|
|
52
|
-
* ## Standard Behavior (LTX-2.3 and future models)
|
|
59
|
+
* ## Standard Behavior (LTX-2.3, Seedance, and future models)
|
|
53
60
|
* - Generate at the actual specified FPS (no interpolation)
|
|
54
61
|
* - Formula: duration * fps + 1
|
|
55
62
|
* - LTX-2.3 specific: Frame count must follow the pattern: 1 + n*8
|
|
@@ -7,6 +7,7 @@ exports.isAudioModel = isAudioModel;
|
|
|
7
7
|
exports.isWanModel = isWanModel;
|
|
8
8
|
exports.isWanAnimateModel = isWanAnimateModel;
|
|
9
9
|
exports.isLtx2Model = isLtx2Model;
|
|
10
|
+
exports.isSeedanceModel = isSeedanceModel;
|
|
10
11
|
exports.calculateVideoFrames = calculateVideoFrames;
|
|
11
12
|
exports.getVideoWorkflowType = getVideoWorkflowType;
|
|
12
13
|
function getEnhacementStrength(strength) {
|
|
@@ -25,7 +26,10 @@ function getEnhacementStrength(strength) {
|
|
|
25
26
|
* Video models produce MP4 output; image models produce PNG/JPG output.
|
|
26
27
|
*/
|
|
27
28
|
function isVideoModel(modelId) {
|
|
28
|
-
return modelId.startsWith('wan_') ||
|
|
29
|
+
return (modelId.startsWith('wan_') ||
|
|
30
|
+
modelId.startsWith('ltx2-') ||
|
|
31
|
+
modelId.startsWith('ltx23-') ||
|
|
32
|
+
modelId.startsWith('seedance-2-0'));
|
|
29
33
|
}
|
|
30
34
|
/**
|
|
31
35
|
* Check if a model ID is for an audio workflow (e.g., ACE-Step).
|
|
@@ -70,6 +74,15 @@ function isWanAnimateModel(modelId) {
|
|
|
70
74
|
function isLtx2Model(modelId) {
|
|
71
75
|
return modelId.startsWith('ltx2-') || modelId.startsWith('ltx23-');
|
|
72
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Check if a model ID is a Seedance 2.0 video model.
|
|
79
|
+
*
|
|
80
|
+
* Seedance models are external API-backed video models. They generate at
|
|
81
|
+
* 24fps and support 4-15 second direct SDK project durations.
|
|
82
|
+
*/
|
|
83
|
+
function isSeedanceModel(modelId) {
|
|
84
|
+
return modelId.startsWith('seedance-2-0');
|
|
85
|
+
}
|
|
73
86
|
/**
|
|
74
87
|
* LTX-2.3 frame step constraint.
|
|
75
88
|
* Valid frame counts follow the pattern: 1 + n*8 (i.e., 1, 9, 17, 25, 33, ...)
|
|
@@ -78,7 +91,7 @@ exports.LTX2_FRAME_STEP = 8;
|
|
|
78
91
|
/**
|
|
79
92
|
* Calculate the frame count for a given duration and fps based on the video model.
|
|
80
93
|
*
|
|
81
|
-
* ## Standard Behavior (LTX-2.3 and future models)
|
|
94
|
+
* ## Standard Behavior (LTX-2.3, Seedance, and future models)
|
|
82
95
|
* - Generate at the actual specified FPS (no interpolation)
|
|
83
96
|
* - Formula: duration * fps + 1
|
|
84
97
|
* - LTX-2.3 specific: Frame count must follow the pattern: 1 + n*8
|
|
@@ -131,21 +144,22 @@ function getVideoWorkflowType(modelId) {
|
|
|
131
144
|
// Check for supported video model prefixes
|
|
132
145
|
const isWan = modelId.startsWith('wan_');
|
|
133
146
|
const isLtx2 = modelId.startsWith('ltx2-') || modelId.startsWith('ltx23-');
|
|
134
|
-
|
|
147
|
+
const isSeedance = modelId.startsWith('seedance-2-0');
|
|
148
|
+
if (!isWan && !isLtx2 && !isSeedance)
|
|
135
149
|
return null;
|
|
136
|
-
// WAN
|
|
150
|
+
// WAN, LTX-2.3, and Seedance models share similar workflow type suffixes
|
|
137
151
|
if (modelId.includes('_i2v'))
|
|
138
152
|
return 'i2v';
|
|
139
153
|
if (modelId.includes('_t2v'))
|
|
140
154
|
return 't2v';
|
|
141
|
-
// LTX-2.3 v2v ControlNet
|
|
142
|
-
if (isLtx2 && modelId.includes('_v2v'))
|
|
155
|
+
// LTX-2.3 v2v ControlNet and Seedance v2v workflows
|
|
156
|
+
if ((isLtx2 || isSeedance) && modelId.includes('_v2v'))
|
|
143
157
|
return 'v2v';
|
|
144
|
-
// LTX-2.3 audio
|
|
158
|
+
// LTX-2.3 and Seedance image+audio workflows
|
|
145
159
|
// ia2v = image+audio to video (requires referenceImage + referenceAudio)
|
|
146
160
|
// a2v = audio to video (requires referenceAudio only)
|
|
147
161
|
// Note: Check _ia2v before _a2v since _ia2v contains _a2v as a substring
|
|
148
|
-
if (isLtx2 && modelId.includes('_ia2v'))
|
|
162
|
+
if ((isLtx2 || isSeedance) && modelId.includes('_ia2v'))
|
|
149
163
|
return 'ia2v';
|
|
150
164
|
if (isLtx2 && modelId.includes('_a2v'))
|
|
151
165
|
return 'a2v';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Projects/utils/index.ts"],"names":[],"mappings":";;;AAEA,sDASC;AAOD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Projects/utils/index.ts"],"names":[],"mappings":";;;AAEA,sDASC;AAOD,oCAOC;AAMD,oCAEC;AAYD,gCAEC;AAMD,8CAEC;AAeD,kCAEC;AAQD,0CAEC;AA4BD,oDAkCC;AAMD,oDAgCC;AApLD,SAAgB,qBAAqB,CAAC,QAA6B;IACjE,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,OAAO;YACV,OAAO,IAAI,CAAC;QACd,KAAK,OAAO;YACV,OAAO,IAAI,CAAC;QACd;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,OAAe;IAC1C,OAAO,CACL,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;QAC1B,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;QAC3B,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;QAC5B,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CACnC,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,EAAE,WAAW;QAC3B,iBAAiB,EAAE,WAAW;QAC9B,cAAc,EAAE,UAAU;QAC1B,sBAAsB,EAAE,WAAW;QACnC,cAAc,EAAE,WAAW;KAC5B;IACD,cAAc,EAAE;QACd,cAAc,EAAE,UAAU;QAC1B,iBAAiB,EAAE,WAAW;QAC9B,cAAc,EAAE,WAAW;QAC3B,sBAAsB,EAAE,WAAW;QACnC,cAAc,EAAE,UAAU;KAC3B;IACD,iBAAiB,EAAE;QACjB,cAAc,EAAE,UAAU;QAC1B,iBAAiB,EAAE,WAAW;QAC9B,cAAc,EAAE,WAAW;QAC3B,sBAAsB,EAAE,WAAW;QACnC,cAAc,EAAE,UAAU;KAC3B;IACD,GAAG,EAAE;QACH,cAAc,EAAE,UAAU,EAAE,8DAA8D;QAC1F,iBAAiB,EAAE,WAAW;QAC9B,cAAc,EAAE,WAAW;QAC3B,sBAAsB,EAAE,UAAU;QAClC,cAAc,EAAE,UAAU;KAC3B;CACF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import AccountApi from './Account';
|
|
|
2
2
|
import CurrentAccount from './Account/CurrentAccount';
|
|
3
3
|
import ApiClient, { ApiError } from './ApiClient';
|
|
4
4
|
import { SupernetType } from './ApiClient/WebSocketClient/types';
|
|
5
|
+
import type { SocketEventName, SocketEventSubscriptionsUpdatedData } from './ApiClient/WebSocketClient/events';
|
|
6
|
+
import type { SocketEventSubscriptionInput, SocketEventSubscriptionName, SocketEventSubscriptions, SocketEventSubscriptionUpdate } from './ApiClient/WebSocketClient/eventSubscriptions';
|
|
5
7
|
import { Logger, LogLevel } from './lib/DefaultLogger';
|
|
6
8
|
import ProjectsApi from './Projects';
|
|
7
9
|
import Job, { JobStatus } from './Projects/Job';
|
|
@@ -11,19 +13,34 @@ import { ControlNetName, ControlNetParams, ControlNetMode, VideoControlNetName,
|
|
|
11
13
|
import ChatApi from './Chat';
|
|
12
14
|
import ChatStream from './Chat/ChatStream';
|
|
13
15
|
import ChatToolsApi from './Chat/ChatTools';
|
|
14
|
-
import { ChatMessage, ChatCompletionParams, ChatCompletionChunk, ChatCompletionResult, ChatJobStateEvent, ContentPart, TextContentPart, ImageUrlContentPart, TokenUsage as ChatTokenUsage, LLMCostEstimation, LLMJobCost, LLMModelInfo, LLMParamConstraint, LLMSamplingDefaults, ToolDefinition, ToolCall, ToolCallDelta, ToolCallFunction, ToolChoice, ToolFunction, ToolExecutionProgress, ToolExecutionResult, ToolHistoryEntry, ToolExecutionOptions } from './Chat/types';
|
|
16
|
+
import { ChatMessage, ChatCompletionParams, ChatCompletionChunk, ChatCompletionResult, ChatJobStateEvent, ChatResponseFormat, ContentPart, HostedChatCompletionParams, HostedChatCompletionResult, HostedChatCompletionChoice, HostedChatCompletionMessage, HostedCreativeWorkflowReference, TextContentPart, ImageUrlContentPart, TokenUsage as ChatTokenUsage, LLMCostEstimation, LLMJobCost, LLMModelInfo, LLMParamConstraint, LLMSamplingDefaults, ToolDefinition, ToolCall, ToolCallDelta, ToolCallFunction, ToolChoice, ToolFunction, SogniToolsMode, ToolExecutionProgress, ToolExecutionResult, ToolHistoryEntry, ToolExecutionOptions } from './Chat/types';
|
|
15
17
|
import { SogniTools, buildSogniTools, isSogniToolCall, parseToolCallArguments } from './Chat/tools';
|
|
18
|
+
import CreativeWorkflowsApi, { parseCreativeWorkflowSseChunk } from './CreativeWorkflows';
|
|
19
|
+
import { CreativeWorkflowArtifact, CreativeWorkflowEvent, CreativeWorkflowKind, CreativeWorkflowRecord, CreativeWorkflowSseEvent, CreativeWorkflowStatus, CreativeWorkflowHostedToolName, ListCreativeWorkflowOptions, StartCreativeWorkflowOptions, StartCreativeWorkflowParams, StartHostedToolSequenceWorkflowDependency, StartHostedToolSequenceWorkflowInput, StartHostedToolSequenceWorkflowStep, StartImageToVideoWorkflowInput, StreamCreativeWorkflowEventsOptions } from './CreativeWorkflows/types';
|
|
16
20
|
import StatsApi from './Stats';
|
|
17
21
|
import ErrorData from './types/ErrorData';
|
|
18
22
|
import { TokenType } from './types/token';
|
|
19
23
|
import { ApiKeyAuthManager, TokenAuthData } from './lib/AuthManager';
|
|
20
|
-
export type { AudioFormat, AudioOutputFormat, AudioProjectParams, AvailableModel, ChatCompletionChunk, ChatCompletionParams, ChatCompletionResult, ChatJobStateEvent, ChatMessage, ChatTokenUsage, ContentPart, ImageUrlContentPart, LLMCostEstimation, LLMJobCost, LLMModelInfo, LLMParamConstraint, LLMSamplingDefaults, ControlNetMode, ControlNetName, ControlNetParams, TextContentPart, ErrorData, ImageProjectParams, ImageOutputFormat, JobStatus, Logger, LogLevel, ProjectParams, ProjectStatus, SupernetType, TokenType, ToolCall, ToolCallDelta, ToolCallFunction, ToolChoice, ToolDefinition, ToolExecutionOptions, ToolExecutionProgress, ToolExecutionResult, ToolFunction, ToolHistoryEntry, VideoControlNetName, VideoControlNetParams, VideoFormat, VideoOutputFormat, VideoProjectParams, VideoWorkflowType };
|
|
21
|
-
export { ApiError, ApiKeyAuthManager, ChatStream, ChatToolsApi, CurrentAccount, Job, Project, SogniTools, buildSogniTools, isSogniToolCall, parseToolCallArguments };
|
|
24
|
+
export type { AudioFormat, AudioOutputFormat, AudioProjectParams, AvailableModel, ChatCompletionChunk, ChatCompletionParams, ChatCompletionResult, ChatJobStateEvent, ChatMessage, ChatResponseFormat, ChatTokenUsage, ContentPart, HostedChatCompletionChoice, HostedChatCompletionMessage, HostedChatCompletionParams, HostedChatCompletionResult, HostedCreativeWorkflowReference, CreativeWorkflowArtifact, CreativeWorkflowEvent, CreativeWorkflowKind, CreativeWorkflowRecord, CreativeWorkflowSseEvent, CreativeWorkflowStatus, ImageUrlContentPart, ListCreativeWorkflowOptions, LLMCostEstimation, LLMJobCost, LLMModelInfo, LLMParamConstraint, LLMSamplingDefaults, ControlNetMode, ControlNetName, ControlNetParams, TextContentPart, ErrorData, ImageProjectParams, ImageOutputFormat, JobStatus, Logger, LogLevel, ProjectParams, ProjectStatus, CreativeWorkflowHostedToolName, StartCreativeWorkflowOptions, StartCreativeWorkflowParams, StartHostedToolSequenceWorkflowDependency, StartHostedToolSequenceWorkflowInput, StartHostedToolSequenceWorkflowStep, StartImageToVideoWorkflowInput, StreamCreativeWorkflowEventsOptions, SupernetType, TokenType, ToolCall, ToolCallDelta, ToolCallFunction, ToolChoice, ToolDefinition, ToolExecutionOptions, ToolExecutionProgress, ToolExecutionResult, ToolFunction, ToolHistoryEntry, SogniToolsMode, SocketEventName, SocketEventSubscriptionInput, SocketEventSubscriptionName, SocketEventSubscriptions, SocketEventSubscriptionsUpdatedData, SocketEventSubscriptionUpdate, VideoControlNetName, VideoControlNetParams, VideoFormat, VideoOutputFormat, VideoProjectParams, VideoWorkflowType };
|
|
25
|
+
export { ApiError, ApiKeyAuthManager, ChatStream, ChatToolsApi, CreativeWorkflowsApi, CurrentAccount, Job, Project, SogniTools, buildSogniTools, isSogniToolCall, parseCreativeWorkflowSseChunk, parseToolCallArguments };
|
|
22
26
|
export interface SogniClientConfig {
|
|
23
27
|
/**
|
|
24
28
|
* The application ID string. Must be unique, multiple connections with the same ID will be rejected.
|
|
25
29
|
*/
|
|
26
30
|
appId: string;
|
|
31
|
+
/**
|
|
32
|
+
* Optional client app/source label to attach to this connection for server-side attribution.
|
|
33
|
+
* The socket server uses this as the default source for project and chat requests from this client.
|
|
34
|
+
*/
|
|
35
|
+
appSource?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Initial WebSocket event subscriptions for this connection.
|
|
38
|
+
*
|
|
39
|
+
* Omit this option to receive the default socket event stream. To reduce socket traffic for
|
|
40
|
+
* proxy or headless clients that do not need live worker counts, set
|
|
41
|
+
* `{ modelAvailability: false }` to opt out of `swarmModels` and `swarmLLMModels` updates.
|
|
42
|
+
*/
|
|
43
|
+
socketEventSubscriptions?: SocketEventSubscriptions;
|
|
27
44
|
/**
|
|
28
45
|
* Override the default REST API endpoint
|
|
29
46
|
* @internal
|
|
@@ -92,6 +109,7 @@ export declare class SogniClient {
|
|
|
92
109
|
projects: ProjectsApi;
|
|
93
110
|
stats: StatsApi;
|
|
94
111
|
chat: ChatApi;
|
|
112
|
+
creativeWorkflows: CreativeWorkflowsApi;
|
|
95
113
|
apiClient: ApiClient;
|
|
96
114
|
private constructor();
|
|
97
115
|
get currentAccount(): CurrentAccount;
|
|
@@ -112,6 +130,13 @@ export declare class SogniClient {
|
|
|
112
130
|
* After calling this method, the instance should not be used.
|
|
113
131
|
*/
|
|
114
132
|
dispose(): void;
|
|
133
|
+
/**
|
|
134
|
+
* Update WebSocket event subscriptions for this live client.
|
|
135
|
+
*
|
|
136
|
+
* This is useful when a process needs the initial model availability snapshot for startup, but
|
|
137
|
+
* does not need ongoing worker count updates afterward.
|
|
138
|
+
*/
|
|
139
|
+
setSocketEventSubscriptions(update: SocketEventSubscriptionInput): Promise<void>;
|
|
115
140
|
/**
|
|
116
141
|
* Create client instance, with default configuration
|
|
117
142
|
* @param config
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.SogniClient = exports.parseToolCallArguments = exports.isSogniToolCall = exports.buildSogniTools = exports.SogniTools = exports.Project = exports.Job = exports.CurrentAccount = exports.ChatToolsApi = exports.ChatStream = exports.ApiKeyAuthManager = exports.ApiError = void 0;
|
|
38
|
+
exports.SogniClient = exports.parseToolCallArguments = exports.parseCreativeWorkflowSseChunk = exports.isSogniToolCall = exports.buildSogniTools = exports.SogniTools = exports.Project = exports.Job = exports.CurrentAccount = exports.CreativeWorkflowsApi = exports.ChatToolsApi = exports.ChatStream = exports.ApiKeyAuthManager = exports.ApiError = void 0;
|
|
39
39
|
// Account API
|
|
40
40
|
const Account_1 = __importDefault(require("./Account"));
|
|
41
41
|
const CurrentAccount_1 = __importDefault(require("./Account/CurrentAccount"));
|
|
@@ -63,6 +63,10 @@ Object.defineProperty(exports, "SogniTools", { enumerable: true, get: function (
|
|
|
63
63
|
Object.defineProperty(exports, "buildSogniTools", { enumerable: true, get: function () { return tools_1.buildSogniTools; } });
|
|
64
64
|
Object.defineProperty(exports, "isSogniToolCall", { enumerable: true, get: function () { return tools_1.isSogniToolCall; } });
|
|
65
65
|
Object.defineProperty(exports, "parseToolCallArguments", { enumerable: true, get: function () { return tools_1.parseToolCallArguments; } });
|
|
66
|
+
// Creative Workflows API
|
|
67
|
+
const CreativeWorkflows_1 = __importStar(require("./CreativeWorkflows"));
|
|
68
|
+
exports.CreativeWorkflowsApi = CreativeWorkflows_1.default;
|
|
69
|
+
Object.defineProperty(exports, "parseCreativeWorkflowSseChunk", { enumerable: true, get: function () { return CreativeWorkflows_1.parseCreativeWorkflowSseChunk; } });
|
|
66
70
|
// Stats API
|
|
67
71
|
const Stats_1 = __importDefault(require("./Stats"));
|
|
68
72
|
const AuthManager_1 = require("./lib/AuthManager");
|
|
@@ -73,6 +77,7 @@ class SogniClient {
|
|
|
73
77
|
this.projects = new Projects_1.default(config);
|
|
74
78
|
this.stats = new Stats_1.default(config);
|
|
75
79
|
this.chat = new Chat_1.default(config, this.projects);
|
|
80
|
+
this.creativeWorkflows = new CreativeWorkflows_1.default(config);
|
|
76
81
|
this.apiClient = config.client;
|
|
77
82
|
}
|
|
78
83
|
get currentAccount() {
|
|
@@ -127,6 +132,17 @@ class SogniClient {
|
|
|
127
132
|
dispose() {
|
|
128
133
|
this.apiClient.dispose();
|
|
129
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Update WebSocket event subscriptions for this live client.
|
|
137
|
+
*
|
|
138
|
+
* This is useful when a process needs the initial model availability snapshot for startup, but
|
|
139
|
+
* does not need ongoing worker count updates afterward.
|
|
140
|
+
*/
|
|
141
|
+
setSocketEventSubscriptions(update) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
yield this.apiClient.setSocketEventSubscriptions(update);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
130
146
|
/**
|
|
131
147
|
* Create client instance, with default configuration
|
|
132
148
|
* @param config
|
|
@@ -143,6 +159,8 @@ class SogniClient {
|
|
|
143
159
|
baseUrl: restEndpoint,
|
|
144
160
|
socketUrl: socketEndpoint,
|
|
145
161
|
appId: config.appId,
|
|
162
|
+
appSource: config.appSource,
|
|
163
|
+
socketEventSubscriptions: config.socketEventSubscriptions,
|
|
146
164
|
networkType: network,
|
|
147
165
|
logger,
|
|
148
166
|
authType,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,wDAAmC;AACnC,8EAAsD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,wDAAmC;AACnC,8EAAsD;AAoMpD,yBApMK,wBAAc,CAoML;AAnMhB,YAAY;AACZ,yDAA+D;AA6L7D,yFA7LkB,oBAAQ,OA6LlB;AAhLV,QAAQ;AACR,uDAAsE;AACtE,sEAA8C;AAC9C,eAAe;AACf,0DAAqC;AACrC,yDAAgD;AAiL9C,cAjLK,aAAG,CAiLL;AAhLL,iEAA4D;AAiL1D,kBAjLK,iBAAO,CAiLL;AA5JT,WAAW;AACX,kDAA6B;AAC7B,mEAA2C;AAqJzC,qBArJK,oBAAU,CAqJL;AApJZ,iEAA4C;AAqJ1C,uBArJK,mBAAY,CAqJL;AAnHd,wCAAoG;AAwHlG,2FAxHO,kBAAU,OAwHP;AACV,gGAzHmB,uBAAe,OAyHnB;AACf,gGA1HoC,uBAAe,OA0HpC;AAEf,uGA5HqD,8BAAsB,OA4HrD;AA3HxB,yBAAyB;AACzB,yEAA0F;AAkHxF,+BAlHK,2BAAoB,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AC,CAAC,KAAK,CAAC;YACxE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,IAAI,OAAO,CAAC;YAEvE,MAAM,MAAM,GAAG,IAAI,mBAAS,CAAC;gBAC3B,OAAO,EAAE,YAAY;gBACrB,SAAS,EAAE,cAAc;gBACzB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,wBAAwB,EAAE,MAAM,CAAC,wBAAwB;gBACzD,WAAW,EAAE,OAAO;gBACpB,MAAM;gBACN,QAAQ;gBACR,aAAa,EAAE,MAAM,CAAC,aAAa;gBACnC,aAAa,EAAE,MAAM,CAAC,aAAa;aACpC,CAAC,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,sBAAY,CAAC;gBAC9B,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU;gBAC9C,OAAO,EAAE,GAAG;gBACZ,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;aACtC,CAAC,CAAC;YACH,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAExD,6CAA6C;YAC7C,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBAClB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAyB,CAAC;gBAC9C,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACzC,CAAC;YAED,OAAO,WAAW,CAAC;QACrB,CAAC;KAAA;CACF;AAvHD,kCAuHC"}
|
package/dist/lib/RestClient.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import TypedEventEmitter, { EventMap } from './TypedEventEmitter';
|
|
|
2
2
|
import { JSONValue } from '../types/json';
|
|
3
3
|
import { Logger } from './DefaultLogger';
|
|
4
4
|
import { AuthManager } from './AuthManager';
|
|
5
|
+
interface RestRequestInit extends RequestInit {
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
}
|
|
5
8
|
declare class RestClient<E extends EventMap = never> extends TypedEventEmitter<E> {
|
|
6
9
|
readonly baseUrl: string;
|
|
7
10
|
protected _auth: AuthManager;
|
|
@@ -12,6 +15,6 @@ declare class RestClient<E extends EventMap = never> extends TypedEventEmitter<E
|
|
|
12
15
|
private request;
|
|
13
16
|
private processResponse;
|
|
14
17
|
get<T = JSONValue>(path: string, query?: Record<string, any>): Promise<T>;
|
|
15
|
-
post<T = JSONValue>(path: string, body?: Record<string, unknown>): Promise<T>;
|
|
18
|
+
post<T = JSONValue>(path: string, body?: Record<string, unknown>, options?: Pick<RestRequestInit, 'timeoutMs'>): Promise<T>;
|
|
16
19
|
}
|
|
17
20
|
export default RestClient;
|
package/dist/lib/RestClient.js
CHANGED
|
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
24
|
};
|
|
@@ -33,12 +44,13 @@ class RestClient extends TypedEventEmitter_1.default {
|
|
|
33
44
|
}
|
|
34
45
|
request(url_1) {
|
|
35
46
|
return __awaiter(this, arguments, void 0, function* (url, options = {}) {
|
|
36
|
-
const
|
|
47
|
+
const { timeoutMs = 30000 } = options, requestOptions = __rest(options, ["timeoutMs"]);
|
|
48
|
+
const init = yield this.auth.authenticateRequest(requestOptions);
|
|
37
49
|
// Add a timeout to detect hanging requests
|
|
38
50
|
const controller = new AbortController();
|
|
39
51
|
const timeoutId = setTimeout(() => {
|
|
40
52
|
controller.abort();
|
|
41
|
-
},
|
|
53
|
+
}, timeoutMs);
|
|
42
54
|
try {
|
|
43
55
|
const response = yield fetch(url, Object.assign(Object.assign({}, init), { signal: controller.signal }));
|
|
44
56
|
clearTimeout(timeoutId);
|
|
@@ -73,14 +85,10 @@ class RestClient extends TypedEventEmitter_1.default {
|
|
|
73
85
|
get(path, query = {}) {
|
|
74
86
|
return this.request(this.formatUrl(path, query));
|
|
75
87
|
}
|
|
76
|
-
post(path, body = {}) {
|
|
77
|
-
return this.request(this.formatUrl(path), {
|
|
78
|
-
method: 'POST',
|
|
79
|
-
headers: {
|
|
88
|
+
post(path, body = {}, options = {}) {
|
|
89
|
+
return this.request(this.formatUrl(path), Object.assign({ method: 'POST', headers: {
|
|
80
90
|
'Content-Type': 'application/json'
|
|
81
|
-
},
|
|
82
|
-
body: JSON.stringify(body)
|
|
83
|
-
});
|
|
91
|
+
}, body: JSON.stringify(body) }, options));
|
|
84
92
|
}
|
|
85
93
|
}
|
|
86
94
|
exports.default = RestClient;
|