@nodaro/shared 2.2.1 → 2.5.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/dist/index.cjs +166 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +171 -4
- package/dist/index.d.ts +171 -4
- package/dist/index.js +158 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/effective-tier.test.ts +116 -0
- package/src/__tests__/normalize-model-input.test.ts +153 -0
- package/src/__tests__/normalize-node-params.test.ts +95 -0
- package/src/effective-tier.ts +72 -0
- package/src/index.ts +18 -0
- package/src/model-catalog.ts +161 -0
- package/src/model-constants.ts +6 -1
- package/src/normalize-node-params.ts +126 -0
- package/src/pipeline-defaults.ts +2 -0
package/dist/index.cjs
CHANGED
|
@@ -39,6 +39,12 @@ var FREECUT_EXPORT_COMPLETE = "FREECUT_EXPORT_COMPLETE";
|
|
|
39
39
|
var FREECUT_EXPORT_PROGRESS = "FREECUT_EXPORT_PROGRESS";
|
|
40
40
|
var FREECUT_REQUEST_IMPORT = "FREECUT_REQUEST_IMPORT";
|
|
41
41
|
|
|
42
|
+
// src/flux2-pricing.ts
|
|
43
|
+
var FLUX2_RES_MP = ["0.5", "1", "2", "4"];
|
|
44
|
+
function isFlux2Model(m) {
|
|
45
|
+
return m === "flux-2-klein" || m === "flux-2-pro" || m === "flux-2-max";
|
|
46
|
+
}
|
|
47
|
+
|
|
42
48
|
// src/model-catalog.ts
|
|
43
49
|
var MODEL_RECOMMENDATIONS = [
|
|
44
50
|
// image
|
|
@@ -2150,6 +2156,78 @@ function validateModelInput(modelId, input) {
|
|
|
2150
2156
|
}
|
|
2151
2157
|
return null;
|
|
2152
2158
|
}
|
|
2159
|
+
function defaultResolutionFor(modelId) {
|
|
2160
|
+
if (!isFlux2Model(modelId)) return void 0;
|
|
2161
|
+
return modelId === "flux-2-klein" ? "1 MP" : "2 MP";
|
|
2162
|
+
}
|
|
2163
|
+
function sameOptionValue(a, b) {
|
|
2164
|
+
if (a === b) return true;
|
|
2165
|
+
const norm = (v) => String(v).trim().toLowerCase().replace(/\s*mp$/, "").replace(/\s+/g, "");
|
|
2166
|
+
const na = norm(a);
|
|
2167
|
+
const nb = norm(b);
|
|
2168
|
+
if (na === nb) return true;
|
|
2169
|
+
const fa = Number(na);
|
|
2170
|
+
const fb = Number(nb);
|
|
2171
|
+
return Number.isFinite(fa) && Number.isFinite(fb) && fa === fb;
|
|
2172
|
+
}
|
|
2173
|
+
function normalizeModelInput(modelId, input) {
|
|
2174
|
+
const m = MODEL_CATALOG[modelId];
|
|
2175
|
+
const adjustments = [];
|
|
2176
|
+
if (!m) return { ...input, adjustments };
|
|
2177
|
+
const out = { ...input, adjustments };
|
|
2178
|
+
const snap = (field, value, allowed, preferred) => {
|
|
2179
|
+
if (value === void 0) return void 0;
|
|
2180
|
+
if (!allowed || allowed.length === 0) {
|
|
2181
|
+
adjustments.push({
|
|
2182
|
+
field,
|
|
2183
|
+
from: value,
|
|
2184
|
+
to: void 0,
|
|
2185
|
+
reason: `${m.label} has no ${field} setting \u2014 the value was dropped.`
|
|
2186
|
+
});
|
|
2187
|
+
return void 0;
|
|
2188
|
+
}
|
|
2189
|
+
if (allowed.includes(value)) return value;
|
|
2190
|
+
const canonical = allowed.find((a) => sameOptionValue(a, value));
|
|
2191
|
+
if (canonical !== void 0) return canonical;
|
|
2192
|
+
const next = preferred !== void 0 && allowed.includes(preferred) ? preferred : allowed[0];
|
|
2193
|
+
adjustments.push({
|
|
2194
|
+
field,
|
|
2195
|
+
from: value,
|
|
2196
|
+
to: next,
|
|
2197
|
+
reason: `${m.label} does not support ${field} "${value}" \u2014 using "${next}" instead. Supported: ${allowed.join(", ")}.`
|
|
2198
|
+
});
|
|
2199
|
+
return next;
|
|
2200
|
+
};
|
|
2201
|
+
out.aspectRatio = snap("aspectRatio", input.aspectRatio, m.aspectRatios);
|
|
2202
|
+
out.resolution = snap(
|
|
2203
|
+
"resolution",
|
|
2204
|
+
input.resolution,
|
|
2205
|
+
m.resolutions,
|
|
2206
|
+
defaultResolutionFor(modelId)
|
|
2207
|
+
);
|
|
2208
|
+
out.quality = snap("quality", input.quality, m.qualities);
|
|
2209
|
+
out.duration = snap("duration", input.duration, m.durations);
|
|
2210
|
+
if (modelId === "gpt-image-2" || modelId === "gpt-image-2-i2i") {
|
|
2211
|
+
if (out.aspectRatio === "auto" && out.resolution !== void 0 && out.resolution !== "1K") {
|
|
2212
|
+
adjustments.push({
|
|
2213
|
+
field: "resolution",
|
|
2214
|
+
from: out.resolution,
|
|
2215
|
+
to: "1K",
|
|
2216
|
+
reason: `${m.label} only renders 1K at the "auto" aspect ratio.`
|
|
2217
|
+
});
|
|
2218
|
+
out.resolution = "1K";
|
|
2219
|
+
} else if (out.aspectRatio === "1:1" && out.resolution === "4K") {
|
|
2220
|
+
adjustments.push({
|
|
2221
|
+
field: "resolution",
|
|
2222
|
+
from: "4K",
|
|
2223
|
+
to: "2K",
|
|
2224
|
+
reason: `${m.label} cannot render 4K at a 1:1 aspect ratio.`
|
|
2225
|
+
});
|
|
2226
|
+
out.resolution = "2K";
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
return out;
|
|
2230
|
+
}
|
|
2153
2231
|
var MODEL_VALUE_LABELS = {
|
|
2154
2232
|
// aspect ratios
|
|
2155
2233
|
"1:1": "1:1 (Square)",
|
|
@@ -2655,8 +2733,13 @@ var IMAGE_I2I_PROVIDERS = [
|
|
|
2655
2733
|
"kontext-multi",
|
|
2656
2734
|
// BFL Flux 2 Pro — runs through Replicate with safety_tolerance=5 (max for Pro)
|
|
2657
2735
|
"flux-2-pro",
|
|
2736
|
+
// BFL FLUX Fill Pro — dedicated masked inpainting via Replicate (white = edit area)
|
|
2737
|
+
"flux-fill",
|
|
2658
2738
|
// BFL Flux 2 Max — runs through Replicate with safety_tolerance=5, up to 8 refs
|
|
2659
|
-
"flux-2-max"
|
|
2739
|
+
"flux-2-max",
|
|
2740
|
+
// BFL FLUX Fill Pro — dedicated inpainting via Replicate (image + mask + prompt,
|
|
2741
|
+
// white = edit area). Second mask-capable i2i provider alongside ideogram-edit.
|
|
2742
|
+
"flux-fill"
|
|
2660
2743
|
];
|
|
2661
2744
|
var IMAGE_EDIT_PROVIDERS = [
|
|
2662
2745
|
"recraft-upscale",
|
|
@@ -2948,7 +3031,7 @@ var VOICE_DESIGN_MODELS = [
|
|
|
2948
3031
|
"eleven_multilingual_ttv_v2"
|
|
2949
3032
|
];
|
|
2950
3033
|
var DEFAULT_VOICE_DESIGN_MODEL = "eleven_ttv_v3";
|
|
2951
|
-
var I2I_MASK_SUPPORT = /* @__PURE__ */ new Set(["ideogram-edit"]);
|
|
3034
|
+
var I2I_MASK_SUPPORT = /* @__PURE__ */ new Set(["ideogram-edit", "flux-fill"]);
|
|
2952
3035
|
var IMAGE_MASK_MODE = {
|
|
2953
3036
|
"nano-banana": "prompt",
|
|
2954
3037
|
"nano-banana-pro": "prompt",
|
|
@@ -4014,12 +4097,6 @@ function expandExtraRefsToConnectedReferences(extras, lookupCharacterContext) {
|
|
|
4014
4097
|
return out;
|
|
4015
4098
|
}
|
|
4016
4099
|
|
|
4017
|
-
// src/flux2-pricing.ts
|
|
4018
|
-
var FLUX2_RES_MP = ["0.5", "1", "2", "4"];
|
|
4019
|
-
function isFlux2Model(m) {
|
|
4020
|
-
return m === "flux-2-klein" || m === "flux-2-pro" || m === "flux-2-max";
|
|
4021
|
-
}
|
|
4022
|
-
|
|
4023
4100
|
// src/credit-identifiers.ts
|
|
4024
4101
|
function buildCreditModelIdentifier(provider, quality, resolution, renderingSpeed, targetResolution, referenceImageCount) {
|
|
4025
4102
|
if (isFlux2Model(provider)) {
|
|
@@ -7562,6 +7639,29 @@ var SOCIAL_POST_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
|
7562
7639
|
var INSTAGRAM_CAROUSEL_MIN_ITEMS = 2;
|
|
7563
7640
|
var INSTAGRAM_CAROUSEL_MAX_ITEMS = 10;
|
|
7564
7641
|
|
|
7642
|
+
// src/effective-tier.ts
|
|
7643
|
+
function resolveStoredTier(p) {
|
|
7644
|
+
return p.tier ?? p.subscription_tier ?? "free";
|
|
7645
|
+
}
|
|
7646
|
+
function resolveEffectiveTier(p) {
|
|
7647
|
+
const stored = resolveStoredTier(p);
|
|
7648
|
+
if (stored === "free" && p.lifetime_topup_credits > 0) return "payg";
|
|
7649
|
+
return stored;
|
|
7650
|
+
}
|
|
7651
|
+
var PAYG_RETENTION_DAYS = 90;
|
|
7652
|
+
function isPaygRetentionActive(p, now) {
|
|
7653
|
+
if (p.lifetimeTopupCredits <= 0) return false;
|
|
7654
|
+
const cutoff = now.getTime() - PAYG_RETENTION_DAYS * 24 * 60 * 60 * 1e3;
|
|
7655
|
+
const at = (v) => {
|
|
7656
|
+
if (v === null) return null;
|
|
7657
|
+
const t2 = v instanceof Date ? v.getTime() : new Date(v).getTime();
|
|
7658
|
+
return Number.isFinite(t2) ? t2 : null;
|
|
7659
|
+
};
|
|
7660
|
+
const topup = at(p.lastTopupAt);
|
|
7661
|
+
const spend = at(p.lastSpendAt);
|
|
7662
|
+
return topup !== null && topup >= cutoff || spend !== null && spend >= cutoff;
|
|
7663
|
+
}
|
|
7664
|
+
|
|
7565
7665
|
// src/node-default-mappings.ts
|
|
7566
7666
|
var NODE_DEFAULT_TYPES = [
|
|
7567
7667
|
// Image
|
|
@@ -9795,6 +9895,8 @@ function validateModeActivation(mode, activation) {
|
|
|
9795
9895
|
}
|
|
9796
9896
|
var TIER_PIPELINE_PARALLELISM = {
|
|
9797
9897
|
free: 0,
|
|
9898
|
+
payg: 1,
|
|
9899
|
+
// derived tier — pipeline entitlements copy basic's
|
|
9798
9900
|
basic: 1,
|
|
9799
9901
|
standard: 2,
|
|
9800
9902
|
pro: 3,
|
|
@@ -9802,6 +9904,8 @@ var TIER_PIPELINE_PARALLELISM = {
|
|
|
9802
9904
|
};
|
|
9803
9905
|
var TIER_MAX_PIPELINE_COST_CREDITS = {
|
|
9804
9906
|
free: 0,
|
|
9907
|
+
payg: 3e3,
|
|
9908
|
+
// derived tier — copies basic
|
|
9805
9909
|
basic: 3e3,
|
|
9806
9910
|
standard: 8e3,
|
|
9807
9911
|
pro: 2e4,
|
|
@@ -11817,6 +11921,51 @@ var VOICE_CHANGER_MODEL_IDS = VOICE_CHANGER_MODELS.map(
|
|
|
11817
11921
|
);
|
|
11818
11922
|
var DEFAULT_VOICE_CHANGER_MODEL = "eleven_multilingual_sts_v2";
|
|
11819
11923
|
|
|
11924
|
+
// src/normalize-node-params.ts
|
|
11925
|
+
var MODEL_PARAM_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
11926
|
+
"generate-image",
|
|
11927
|
+
"image-to-image"
|
|
11928
|
+
]);
|
|
11929
|
+
function normalizeNodeModelParams(nodes) {
|
|
11930
|
+
const adjustments = [];
|
|
11931
|
+
const out = nodes.map((node) => {
|
|
11932
|
+
const type = typeof node.type === "string" ? node.type : "";
|
|
11933
|
+
if (!MODEL_PARAM_NODE_TYPES.has(type)) return node;
|
|
11934
|
+
const data = node.data;
|
|
11935
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) return node;
|
|
11936
|
+
const d = data;
|
|
11937
|
+
const multi = Array.isArray(d.providers) ? d.providers : [];
|
|
11938
|
+
if (multi.length > 1) return node;
|
|
11939
|
+
const provider = typeof d.provider === "string" ? d.provider : typeof multi[0] === "string" ? multi[0] : void 0;
|
|
11940
|
+
if (!provider) return node;
|
|
11941
|
+
const normalized = normalizeModelInput(provider, {
|
|
11942
|
+
aspectRatio: typeof d.aspectRatio === "string" ? d.aspectRatio : void 0,
|
|
11943
|
+
resolution: typeof d.resolution === "string" ? d.resolution : void 0,
|
|
11944
|
+
quality: typeof d.quality === "string" ? d.quality : void 0
|
|
11945
|
+
});
|
|
11946
|
+
if (normalized.adjustments.length === 0) return node;
|
|
11947
|
+
const nodeId = typeof node.id === "string" ? node.id : "(unknown node)";
|
|
11948
|
+
for (const adj of normalized.adjustments) {
|
|
11949
|
+
adjustments.push({ ...adj, nodeId, provider });
|
|
11950
|
+
}
|
|
11951
|
+
return {
|
|
11952
|
+
...node,
|
|
11953
|
+
data: {
|
|
11954
|
+
...d,
|
|
11955
|
+
aspectRatio: normalized.aspectRatio,
|
|
11956
|
+
resolution: normalized.resolution,
|
|
11957
|
+
quality: normalized.quality
|
|
11958
|
+
}
|
|
11959
|
+
};
|
|
11960
|
+
});
|
|
11961
|
+
return { nodes: out, adjustments };
|
|
11962
|
+
}
|
|
11963
|
+
function describeNodeAdjustments(adjustments) {
|
|
11964
|
+
return adjustments.map(
|
|
11965
|
+
(a) => `${a.nodeId} (${a.provider}): ${a.field} "${a.from}" \u2192 ${a.to === void 0 ? "removed" : `"${a.to}"`} \u2014 ${a.reason}`
|
|
11966
|
+
);
|
|
11967
|
+
}
|
|
11968
|
+
|
|
11820
11969
|
// src/node-preset-extract.ts
|
|
11821
11970
|
var PRESET_APPLY_CLEAR_KEYS = [...COMPOSER_PLAN_FIELDS, "lottieUrl"];
|
|
11822
11971
|
var PRESET_EXCLUDED_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -13244,6 +13393,7 @@ exports.MINIMAX_H3_DEFAULT_RESOLUTION = MINIMAX_H3_DEFAULT_RESOLUTION;
|
|
|
13244
13393
|
exports.MINIMAX_H3_PROVIDERS = MINIMAX_H3_PROVIDERS;
|
|
13245
13394
|
exports.MODELS_WITH_REFERENCE_IMAGE_SUPPORT = MODELS_WITH_REFERENCE_IMAGE_SUPPORT;
|
|
13246
13395
|
exports.MODEL_CATALOG = MODEL_CATALOG;
|
|
13396
|
+
exports.MODEL_PARAM_NODE_TYPES = MODEL_PARAM_NODE_TYPES;
|
|
13247
13397
|
exports.MODEL_RECOMMENDATIONS = MODEL_RECOMMENDATIONS;
|
|
13248
13398
|
exports.MODIFY_IMAGE_PROVIDERS = MODIFY_IMAGE_PROVIDERS;
|
|
13249
13399
|
exports.MOTION_COLUMN = MOTION_COLUMN;
|
|
@@ -13278,6 +13428,7 @@ exports.OptimizeForModelInputSchema = OptimizeForModelInputSchema;
|
|
|
13278
13428
|
exports.OptimizeForModelResultSchema = OptimizeForModelResultSchema;
|
|
13279
13429
|
exports.PARAMETER_NODE_TYPES = PARAMETER_NODE_TYPES;
|
|
13280
13430
|
exports.PASSTHROUGH_TYPES = PASSTHROUGH_TYPES;
|
|
13431
|
+
exports.PAYG_RETENTION_DAYS = PAYG_RETENTION_DAYS;
|
|
13281
13432
|
exports.PER_FORMAT_DURATION_BOUNDS = PER_FORMAT_DURATION_BOUNDS;
|
|
13282
13433
|
exports.PIPELINE_ACTIVATION_MODES = PIPELINE_ACTIVATION_MODES;
|
|
13283
13434
|
exports.PIPELINE_FORMATS = PIPELINE_FORMATS;
|
|
@@ -13520,6 +13671,7 @@ exports.creditRangesAll = creditRangesAll;
|
|
|
13520
13671
|
exports.creditsToUsd = creditsToUsd;
|
|
13521
13672
|
exports.decodeProviderItem = decodeProviderItem;
|
|
13522
13673
|
exports.defaultCarriedFraction = defaultCarriedFraction;
|
|
13674
|
+
exports.defaultResolutionFor = defaultResolutionFor;
|
|
13523
13675
|
exports.defaultRoleForSource = defaultRoleForSource;
|
|
13524
13676
|
exports.defaultVideoAspectRatio = defaultVideoAspectRatio;
|
|
13525
13677
|
exports.deriveLinkedFields = deriveLinkedFields;
|
|
@@ -13527,6 +13679,7 @@ exports.deriveLottieSlotFields = deriveLottieSlotFields;
|
|
|
13527
13679
|
exports.deriveSlotRefs = deriveSlotRefs;
|
|
13528
13680
|
exports.describeEdgeBehavior = describeEdgeBehavior;
|
|
13529
13681
|
exports.describeMaskRegion = describeMaskRegion;
|
|
13682
|
+
exports.describeNodeAdjustments = describeNodeAdjustments;
|
|
13530
13683
|
exports.describeSlotControl = describeSlotControl;
|
|
13531
13684
|
exports.dropUnknownBindings = dropUnknownBindings;
|
|
13532
13685
|
exports.dropUnknownSpeakers = dropUnknownSpeakers;
|
|
@@ -13625,6 +13778,7 @@ exports.isLocationUsageMode = isLocationUsageMode;
|
|
|
13625
13778
|
exports.isMinimaxH3Provider = isMinimaxH3Provider;
|
|
13626
13779
|
exports.isObjectAspectRatio = isObjectAspectRatio;
|
|
13627
13780
|
exports.isOversizedScene = isOversizedScene;
|
|
13781
|
+
exports.isPaygRetentionActive = isPaygRetentionActive;
|
|
13628
13782
|
exports.isPerSecondLipSyncProvider = isPerSecondLipSyncProvider;
|
|
13629
13783
|
exports.isScraperActor = isScraperActor;
|
|
13630
13784
|
exports.isSeedance2Provider = isSeedance2Provider;
|
|
@@ -13659,6 +13813,8 @@ exports.modelsWithFeature = modelsWithFeature;
|
|
|
13659
13813
|
exports.motionGraphicsFeature = motionGraphicsFeature;
|
|
13660
13814
|
exports.normalizeLottieLayers = normalizeLottieLayers;
|
|
13661
13815
|
exports.normalizeMinimaxH3Resolution = normalizeMinimaxH3Resolution;
|
|
13816
|
+
exports.normalizeModelInput = normalizeModelInput;
|
|
13817
|
+
exports.normalizeNodeModelParams = normalizeNodeModelParams;
|
|
13662
13818
|
exports.normalizePinterestUrl = normalizePinterestUrl;
|
|
13663
13819
|
exports.normalizeRoleSlug = normalizeRoleSlug;
|
|
13664
13820
|
exports.parseAttributedDialogue = parseAttributedDialogue;
|
|
@@ -13696,6 +13852,7 @@ exports.resolveDefaultRole = resolveDefaultRole;
|
|
|
13696
13852
|
exports.resolveDescription = resolveDescription;
|
|
13697
13853
|
exports.resolveDialogueVoices = resolveDialogueVoices;
|
|
13698
13854
|
exports.resolveEffectiveSourceType = resolveEffectiveSourceType;
|
|
13855
|
+
exports.resolveEffectiveTier = resolveEffectiveTier;
|
|
13699
13856
|
exports.resolveEntityAspect = resolveEntityAspect;
|
|
13700
13857
|
exports.resolveFieldMappings = resolveFieldMappings;
|
|
13701
13858
|
exports.resolveGvpAnchorWire = resolveGvpAnchorWire;
|
|
@@ -13716,6 +13873,7 @@ exports.resolveSelectorRefs = resolveSelectorRefs;
|
|
|
13716
13873
|
exports.resolveSeparator = resolveSeparator;
|
|
13717
13874
|
exports.resolveSheetSections = resolveSheetSections;
|
|
13718
13875
|
exports.resolveSourceThroughConnectedList = resolveSourceThroughConnectedList;
|
|
13876
|
+
exports.resolveStoredTier = resolveStoredTier;
|
|
13719
13877
|
exports.resolveSwitchXCreditId = resolveSwitchXCreditId;
|
|
13720
13878
|
exports.resolveVideoAnalysisModel = resolveVideoAnalysisModel;
|
|
13721
13879
|
exports.resolveVideoProviderForMode = resolveVideoProviderForMode;
|