@picsart/ai-sdk 1.140.0 → 1.146.0
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/_cli.js +72 -68
- package/index.d.ts +6 -1
- package/index.js +67 -1
- package/package.json +1 -1
package/_cli.js
CHANGED
|
@@ -6917,6 +6917,76 @@ var init_deeplink = __esm({
|
|
|
6917
6917
|
}
|
|
6918
6918
|
});
|
|
6919
6919
|
|
|
6920
|
+
// src/core/pricing.ts
|
|
6921
|
+
function resolveToolId(mapping, ctx) {
|
|
6922
|
+
if (!mapping) return void 0;
|
|
6923
|
+
if (typeof mapping === "string") return mapping;
|
|
6924
|
+
let next;
|
|
6925
|
+
switch (mapping.by) {
|
|
6926
|
+
case "audio":
|
|
6927
|
+
next = ctx.generateAudio ?? false ? mapping.on : mapping.off;
|
|
6928
|
+
break;
|
|
6929
|
+
case "resolution": {
|
|
6930
|
+
const key = ctx.resolution ?? Object.keys(mapping.map)[0];
|
|
6931
|
+
next = mapping.map[key] ?? Object.values(mapping.map)[0];
|
|
6932
|
+
break;
|
|
6933
|
+
}
|
|
6934
|
+
case "quality": {
|
|
6935
|
+
const key = String(ctx.quality ?? Object.keys(mapping.map)[0]);
|
|
6936
|
+
next = mapping.map[key] ?? Object.values(mapping.map)[0];
|
|
6937
|
+
break;
|
|
6938
|
+
}
|
|
6939
|
+
case "renderingSpeed": {
|
|
6940
|
+
const key = String(ctx.renderingSpeed ?? Object.keys(mapping.map)[0]);
|
|
6941
|
+
next = mapping.map[key] ?? Object.values(mapping.map)[0];
|
|
6942
|
+
break;
|
|
6943
|
+
}
|
|
6944
|
+
case "duration": {
|
|
6945
|
+
const key = String(ctx.duration ?? Object.keys(mapping.map)[0]);
|
|
6946
|
+
next = mapping.map[key] ?? Object.values(mapping.map)[0];
|
|
6947
|
+
break;
|
|
6948
|
+
}
|
|
6949
|
+
case "megapixel": {
|
|
6950
|
+
const mp = ctx.outputMegapixels ?? 0;
|
|
6951
|
+
const tiers = Object.keys(mapping.map).map(Number).sort((a, b) => a - b);
|
|
6952
|
+
const tier = tiers.find((t) => mp <= t) ?? tiers[tiers.length - 1];
|
|
6953
|
+
next = mapping.map[String(tier)];
|
|
6954
|
+
break;
|
|
6955
|
+
}
|
|
6956
|
+
}
|
|
6957
|
+
return resolveToolId(next, ctx);
|
|
6958
|
+
}
|
|
6959
|
+
function getAllToolIds(model) {
|
|
6960
|
+
const ids = [];
|
|
6961
|
+
const extract = (m) => {
|
|
6962
|
+
if (!m) return;
|
|
6963
|
+
if (typeof m === "string") {
|
|
6964
|
+
ids.push(m);
|
|
6965
|
+
return;
|
|
6966
|
+
}
|
|
6967
|
+
switch (m.by) {
|
|
6968
|
+
case "resolution":
|
|
6969
|
+
case "quality":
|
|
6970
|
+
case "renderingSpeed":
|
|
6971
|
+
case "duration":
|
|
6972
|
+
case "megapixel":
|
|
6973
|
+
for (const v of Object.values(m.map)) extract(v);
|
|
6974
|
+
break;
|
|
6975
|
+
case "audio":
|
|
6976
|
+
extract(m.on);
|
|
6977
|
+
extract(m.off);
|
|
6978
|
+
break;
|
|
6979
|
+
}
|
|
6980
|
+
};
|
|
6981
|
+
extract(model.toolId);
|
|
6982
|
+
extract(model.editToolId);
|
|
6983
|
+
return ids;
|
|
6984
|
+
}
|
|
6985
|
+
var init_pricing = __esm({
|
|
6986
|
+
"src/core/pricing.ts"() {
|
|
6987
|
+
}
|
|
6988
|
+
});
|
|
6989
|
+
|
|
6920
6990
|
// src/index.ts
|
|
6921
6991
|
var init_src = __esm({
|
|
6922
6992
|
"src/index.ts"() {
|
|
@@ -6928,6 +6998,7 @@ var init_src = __esm({
|
|
|
6928
6998
|
init_deeplink();
|
|
6929
6999
|
init_catalog();
|
|
6930
7000
|
init_model_registry();
|
|
7001
|
+
init_pricing();
|
|
6931
7002
|
}
|
|
6932
7003
|
});
|
|
6933
7004
|
|
|
@@ -11580,74 +11651,7 @@ Done: ${uploaded} uploaded, ${failed} failed`);
|
|
|
11580
11651
|
init_base_command();
|
|
11581
11652
|
init_src();
|
|
11582
11653
|
init_model_registry();
|
|
11583
|
-
|
|
11584
|
-
// src/core/pricing.ts
|
|
11585
|
-
function resolveToolId(mapping, ctx) {
|
|
11586
|
-
if (!mapping) return void 0;
|
|
11587
|
-
if (typeof mapping === "string") return mapping;
|
|
11588
|
-
let next;
|
|
11589
|
-
switch (mapping.by) {
|
|
11590
|
-
case "audio":
|
|
11591
|
-
next = ctx.generateAudio ?? false ? mapping.on : mapping.off;
|
|
11592
|
-
break;
|
|
11593
|
-
case "resolution": {
|
|
11594
|
-
const key = ctx.resolution ?? Object.keys(mapping.map)[0];
|
|
11595
|
-
next = mapping.map[key] ?? Object.values(mapping.map)[0];
|
|
11596
|
-
break;
|
|
11597
|
-
}
|
|
11598
|
-
case "quality": {
|
|
11599
|
-
const key = String(ctx.quality ?? Object.keys(mapping.map)[0]);
|
|
11600
|
-
next = mapping.map[key] ?? Object.values(mapping.map)[0];
|
|
11601
|
-
break;
|
|
11602
|
-
}
|
|
11603
|
-
case "renderingSpeed": {
|
|
11604
|
-
const key = String(ctx.renderingSpeed ?? Object.keys(mapping.map)[0]);
|
|
11605
|
-
next = mapping.map[key] ?? Object.values(mapping.map)[0];
|
|
11606
|
-
break;
|
|
11607
|
-
}
|
|
11608
|
-
case "duration": {
|
|
11609
|
-
const key = String(ctx.duration ?? Object.keys(mapping.map)[0]);
|
|
11610
|
-
next = mapping.map[key] ?? Object.values(mapping.map)[0];
|
|
11611
|
-
break;
|
|
11612
|
-
}
|
|
11613
|
-
case "megapixel": {
|
|
11614
|
-
const mp = ctx.outputMegapixels ?? 0;
|
|
11615
|
-
const tiers = Object.keys(mapping.map).map(Number).sort((a, b) => a - b);
|
|
11616
|
-
const tier = tiers.find((t) => mp <= t) ?? tiers[tiers.length - 1];
|
|
11617
|
-
next = mapping.map[String(tier)];
|
|
11618
|
-
break;
|
|
11619
|
-
}
|
|
11620
|
-
}
|
|
11621
|
-
return resolveToolId(next, ctx);
|
|
11622
|
-
}
|
|
11623
|
-
function getAllToolIds(model) {
|
|
11624
|
-
const ids = [];
|
|
11625
|
-
const extract = (m) => {
|
|
11626
|
-
if (!m) return;
|
|
11627
|
-
if (typeof m === "string") {
|
|
11628
|
-
ids.push(m);
|
|
11629
|
-
return;
|
|
11630
|
-
}
|
|
11631
|
-
switch (m.by) {
|
|
11632
|
-
case "resolution":
|
|
11633
|
-
case "quality":
|
|
11634
|
-
case "renderingSpeed":
|
|
11635
|
-
case "duration":
|
|
11636
|
-
case "megapixel":
|
|
11637
|
-
for (const v of Object.values(m.map)) extract(v);
|
|
11638
|
-
break;
|
|
11639
|
-
case "audio":
|
|
11640
|
-
extract(m.on);
|
|
11641
|
-
extract(m.off);
|
|
11642
|
-
break;
|
|
11643
|
-
}
|
|
11644
|
-
};
|
|
11645
|
-
extract(model.toolId);
|
|
11646
|
-
extract(model.editToolId);
|
|
11647
|
-
return ids;
|
|
11648
|
-
}
|
|
11649
|
-
|
|
11650
|
-
// _cli/src/commands/pricing.ts
|
|
11654
|
+
init_pricing();
|
|
11651
11655
|
init_usage();
|
|
11652
11656
|
init_key_value();
|
|
11653
11657
|
var Pricing = class _Pricing extends BaseCommand {
|
package/index.d.ts
CHANGED
|
@@ -1649,4 +1649,9 @@ declare const getModel: (id: string) => ModelDefinition | undefined;
|
|
|
1649
1649
|
/** Find a model by ID, workflow name, or display name (case-insensitive). */
|
|
1650
1650
|
declare const findModel: (ref: string) => ModelDefinition | undefined;
|
|
1651
1651
|
|
|
1652
|
-
|
|
1652
|
+
/** Resolve a ToolIdMapping to a concrete toolId for a generation context. Recursive. */
|
|
1653
|
+
declare function resolveToolId(mapping: ToolIdMapping | undefined, ctx: Partial<GenerationContext>): string | undefined;
|
|
1654
|
+
/** Return all toolIds a model can resolve to (toolId + editToolId variants). Recursive. */
|
|
1655
|
+
declare function getAllToolIds(model: ModelDefinition): string[];
|
|
1656
|
+
|
|
1657
|
+
export { ALL_MODELS, type AiClient, type AuthenticatedFetch, type AvatarOption, type BooleanDescriptor, type BooleanEntry, type ClientConfig, type DeepLinkResult, type DriveConfig, type DriveFileDetails, type DriveFolder, type DriveMediaItem, type DriveSaveResult, type EntryMeta, type EnumDescriptor, type EnumEntry, type FileDescriptor, type FileEntry, type FlatParamEntry, type GenerateOptions, type GenerateResult, type GenerateResultItem, type GenerationContext, type GenerationMode, type ListOptions, type MediaTypeFilter, Model, type ModelDefinition, type ModelDescriptor, type ModelFilter$1 as ModelFilter, type ModelInput, type ModelInputById, type ModelMeta, type ModelParams, type ModelParamsAccessor, Models, type ObjectDescriptor, type ObjectEntry, type ParamDescriptor, type ParamEntry, type ParamOption, type PayloadDriveFolderOptions, type PayloadDriveOptions, type ProviderInfo, type RangeDescriptor, type RangeEntry, type SaveParams, type SdkTransport, type TextDescriptor, type TextEntry, type TypedModelId, type VoiceOption, type WorkflowJobHandle, buildFilename, createClient, decodeDeepLinkPayload, encodeDeepLinkPayload, findModel, getAllToolIds, getModel, getModelsByMode, getVoiceById, inferResourceType, resolveToolId };
|
package/index.js
CHANGED
|
@@ -6290,4 +6290,70 @@ function decodeDeepLinkPayload(encoded) {
|
|
|
6290
6290
|
return deserializePayload(encoded);
|
|
6291
6291
|
}
|
|
6292
6292
|
|
|
6293
|
-
|
|
6293
|
+
// src/core/pricing.ts
|
|
6294
|
+
function resolveToolId(mapping, ctx) {
|
|
6295
|
+
if (!mapping) return void 0;
|
|
6296
|
+
if (typeof mapping === "string") return mapping;
|
|
6297
|
+
let next;
|
|
6298
|
+
switch (mapping.by) {
|
|
6299
|
+
case "audio":
|
|
6300
|
+
next = ctx.generateAudio ?? false ? mapping.on : mapping.off;
|
|
6301
|
+
break;
|
|
6302
|
+
case "resolution": {
|
|
6303
|
+
const key = ctx.resolution ?? Object.keys(mapping.map)[0];
|
|
6304
|
+
next = mapping.map[key] ?? Object.values(mapping.map)[0];
|
|
6305
|
+
break;
|
|
6306
|
+
}
|
|
6307
|
+
case "quality": {
|
|
6308
|
+
const key = String(ctx.quality ?? Object.keys(mapping.map)[0]);
|
|
6309
|
+
next = mapping.map[key] ?? Object.values(mapping.map)[0];
|
|
6310
|
+
break;
|
|
6311
|
+
}
|
|
6312
|
+
case "renderingSpeed": {
|
|
6313
|
+
const key = String(ctx.renderingSpeed ?? Object.keys(mapping.map)[0]);
|
|
6314
|
+
next = mapping.map[key] ?? Object.values(mapping.map)[0];
|
|
6315
|
+
break;
|
|
6316
|
+
}
|
|
6317
|
+
case "duration": {
|
|
6318
|
+
const key = String(ctx.duration ?? Object.keys(mapping.map)[0]);
|
|
6319
|
+
next = mapping.map[key] ?? Object.values(mapping.map)[0];
|
|
6320
|
+
break;
|
|
6321
|
+
}
|
|
6322
|
+
case "megapixel": {
|
|
6323
|
+
const mp = ctx.outputMegapixels ?? 0;
|
|
6324
|
+
const tiers = Object.keys(mapping.map).map(Number).sort((a, b) => a - b);
|
|
6325
|
+
const tier = tiers.find((t) => mp <= t) ?? tiers[tiers.length - 1];
|
|
6326
|
+
next = mapping.map[String(tier)];
|
|
6327
|
+
break;
|
|
6328
|
+
}
|
|
6329
|
+
}
|
|
6330
|
+
return resolveToolId(next, ctx);
|
|
6331
|
+
}
|
|
6332
|
+
function getAllToolIds(model) {
|
|
6333
|
+
const ids = [];
|
|
6334
|
+
const extract = (m) => {
|
|
6335
|
+
if (!m) return;
|
|
6336
|
+
if (typeof m === "string") {
|
|
6337
|
+
ids.push(m);
|
|
6338
|
+
return;
|
|
6339
|
+
}
|
|
6340
|
+
switch (m.by) {
|
|
6341
|
+
case "resolution":
|
|
6342
|
+
case "quality":
|
|
6343
|
+
case "renderingSpeed":
|
|
6344
|
+
case "duration":
|
|
6345
|
+
case "megapixel":
|
|
6346
|
+
for (const v of Object.values(m.map)) extract(v);
|
|
6347
|
+
break;
|
|
6348
|
+
case "audio":
|
|
6349
|
+
extract(m.on);
|
|
6350
|
+
extract(m.off);
|
|
6351
|
+
break;
|
|
6352
|
+
}
|
|
6353
|
+
};
|
|
6354
|
+
extract(model.toolId);
|
|
6355
|
+
extract(model.editToolId);
|
|
6356
|
+
return ids;
|
|
6357
|
+
}
|
|
6358
|
+
|
|
6359
|
+
export { ALL_MODELS, Model, Models, buildFilename, createClient, decodeDeepLinkPayload, encodeDeepLinkPayload, findModel, getAllToolIds, getModel, getModelsByMode, getVoiceById, inferResourceType, resolveToolId };
|