@nodaro/shared 3.19.0 → 3.20.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 +177 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +159 -1
- package/dist/index.d.ts +159 -1
- package/dist/index.js +171 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/edit-plan-review.test.ts +379 -0
- package/src/competitors.ts +40 -0
- package/src/edit-plan-review.ts +323 -0
- package/src/index.ts +8 -0
- package/src/node-runtime-keys.ts +5 -0
- package/src/producer-types.ts +15 -0
package/dist/index.cjs
CHANGED
|
@@ -5816,6 +5816,10 @@ var FAN_OUT_EACH_HANDLES = {
|
|
|
5816
5816
|
// (decided 2026-10-04).
|
|
5817
5817
|
"camera-switch": { each: ["edl"], primary: "edl" }
|
|
5818
5818
|
};
|
|
5819
|
+
var OWN_LIST_NODE_TYPES = /* @__PURE__ */ new Set(["extract-field", "json-process"]);
|
|
5820
|
+
function ownsItsList(nodeType) {
|
|
5821
|
+
return typeof nodeType === "string" && OWN_LIST_NODE_TYPES.has(nodeType);
|
|
5822
|
+
}
|
|
5819
5823
|
function defaultEdgeOutputMode(sourceType, sourceHandle) {
|
|
5820
5824
|
if (typeof sourceType !== "string") return "last";
|
|
5821
5825
|
if (FAN_OUT_EACH_TYPES.has(sourceType)) return "each";
|
|
@@ -12793,6 +12797,11 @@ var EXECUTION_DATA_KEYS = /* @__PURE__ */ new Set([
|
|
|
12793
12797
|
"__pickedTotal",
|
|
12794
12798
|
"__restTotal",
|
|
12795
12799
|
"generatedJson",
|
|
12800
|
+
// Edit Plan: a person's review of the plan (`EditedEdl`, edit-plan-review.ts),
|
|
12801
|
+
// kept beside `generatedJson` and fingerprinted against it. Run-result data
|
|
12802
|
+
// (TA14, decided 2026-10-04): out of undo, presets, templates and exports,
|
|
12803
|
+
// and Clear results wipes it. Persisted — never transient.
|
|
12804
|
+
"editedEdl",
|
|
12796
12805
|
"subWorkflowProgress",
|
|
12797
12806
|
"outputResults",
|
|
12798
12807
|
"shots",
|
|
@@ -21273,6 +21282,167 @@ function unwrapEditPlanOutput(outputData) {
|
|
|
21273
21282
|
return rest;
|
|
21274
21283
|
}
|
|
21275
21284
|
|
|
21285
|
+
// src/edit-plan-review.ts
|
|
21286
|
+
var EDITED_EDL_VERSION = 1;
|
|
21287
|
+
function canonicalJson(value) {
|
|
21288
|
+
if (value === null) return "null";
|
|
21289
|
+
switch (typeof value) {
|
|
21290
|
+
case "string":
|
|
21291
|
+
case "boolean":
|
|
21292
|
+
return JSON.stringify(value);
|
|
21293
|
+
case "number":
|
|
21294
|
+
return Number.isFinite(value) ? JSON.stringify(value) : "null";
|
|
21295
|
+
case "object": {
|
|
21296
|
+
const toJSON = value.toJSON;
|
|
21297
|
+
if (typeof toJSON === "function") return canonicalJson(value.toJSON());
|
|
21298
|
+
if (Array.isArray(value)) return `[${value.map((item) => canonicalJson(item) ?? "null").join(",")}]`;
|
|
21299
|
+
const parts = [];
|
|
21300
|
+
for (const key of Object.keys(value).sort()) {
|
|
21301
|
+
const text = canonicalJson(value[key]);
|
|
21302
|
+
if (text !== void 0) parts.push(`${JSON.stringify(key)}:${text}`);
|
|
21303
|
+
}
|
|
21304
|
+
return `{${parts.join(",")}}`;
|
|
21305
|
+
}
|
|
21306
|
+
default:
|
|
21307
|
+
return void 0;
|
|
21308
|
+
}
|
|
21309
|
+
}
|
|
21310
|
+
function fnv1a64(text) {
|
|
21311
|
+
let hi = 3421674724;
|
|
21312
|
+
let lo = 2216829733;
|
|
21313
|
+
const mix = (byte) => {
|
|
21314
|
+
lo = (lo ^ byte) >>> 0;
|
|
21315
|
+
const loProduct = lo * 435;
|
|
21316
|
+
const carry = Math.floor(loProduct / 4294967296);
|
|
21317
|
+
hi = hi * 435 + carry + (lo << 8 >>> 0) >>> 0;
|
|
21318
|
+
lo = loProduct >>> 0;
|
|
21319
|
+
};
|
|
21320
|
+
for (let i = 0; i < text.length; i++) {
|
|
21321
|
+
let code = text.charCodeAt(i);
|
|
21322
|
+
if (code >= 55296 && code <= 56319) {
|
|
21323
|
+
const next = i + 1 < text.length ? text.charCodeAt(i + 1) : 0;
|
|
21324
|
+
if (next >= 56320 && next <= 57343) {
|
|
21325
|
+
code = 65536 + (code - 55296 << 10) + (next - 56320);
|
|
21326
|
+
i++;
|
|
21327
|
+
} else code = 65533;
|
|
21328
|
+
} else if (code >= 56320 && code <= 57343) code = 65533;
|
|
21329
|
+
if (code < 128) mix(code);
|
|
21330
|
+
else if (code < 2048) {
|
|
21331
|
+
mix(192 | code >> 6);
|
|
21332
|
+
mix(128 | code & 63);
|
|
21333
|
+
} else if (code < 65536) {
|
|
21334
|
+
mix(224 | code >> 12);
|
|
21335
|
+
mix(128 | code >> 6 & 63);
|
|
21336
|
+
mix(128 | code & 63);
|
|
21337
|
+
} else {
|
|
21338
|
+
mix(240 | code >> 18);
|
|
21339
|
+
mix(128 | code >> 12 & 63);
|
|
21340
|
+
mix(128 | code >> 6 & 63);
|
|
21341
|
+
mix(128 | code & 63);
|
|
21342
|
+
}
|
|
21343
|
+
}
|
|
21344
|
+
return hi.toString(16).padStart(8, "0") + lo.toString(16).padStart(8, "0");
|
|
21345
|
+
}
|
|
21346
|
+
function editPlanBasis(plan) {
|
|
21347
|
+
return fnv1a64(canonicalJson(plan) ?? "");
|
|
21348
|
+
}
|
|
21349
|
+
var isRecord3 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
21350
|
+
function planShape(plan) {
|
|
21351
|
+
if (Array.isArray(plan)) return "clips";
|
|
21352
|
+
if (isRecord3(plan) && Array.isArray(plan.segments)) return "edl";
|
|
21353
|
+
return "other";
|
|
21354
|
+
}
|
|
21355
|
+
function checkEnvelope(edited, plan) {
|
|
21356
|
+
if (edited === void 0 || edited === null) return { status: "none" };
|
|
21357
|
+
if (!isRecord3(edited)) return { status: "invalid", issue: "editedEdl must be an object" };
|
|
21358
|
+
if (edited.v !== EDITED_EDL_VERSION) return { status: "invalid", issue: `editedEdl.v must be ${EDITED_EDL_VERSION}` };
|
|
21359
|
+
if (typeof edited.basis !== "string" || edited.basis.length === 0) {
|
|
21360
|
+
return { status: "invalid", issue: "editedEdl.basis must be a non-empty string" };
|
|
21361
|
+
}
|
|
21362
|
+
if (edited.kind !== "edl" && edited.kind !== "clips") {
|
|
21363
|
+
return { status: "invalid", issue: `editedEdl.kind must be "edl" or "clips"` };
|
|
21364
|
+
}
|
|
21365
|
+
if (edited.basis !== editPlanBasis(plan)) {
|
|
21366
|
+
return { status: "stale", issue: "editedEdl.basis does not match the plan: the plan changed since this edit was made" };
|
|
21367
|
+
}
|
|
21368
|
+
const shape = planShape(plan);
|
|
21369
|
+
if (edited.kind === "edl") {
|
|
21370
|
+
if (shape !== "edl") return { status: "invalid", issue: `an "edl" edit needs a Tighten plan (one EDL); this plan is ${describeShape(shape)}` };
|
|
21371
|
+
const edl = edited.edl;
|
|
21372
|
+
if (!isRecord3(edl) || !Array.isArray(edl.segments) || !Array.isArray(edl.dropped)) {
|
|
21373
|
+
return { status: "invalid", issue: "editedEdl.edl must hold a segments array and a dropped array" };
|
|
21374
|
+
}
|
|
21375
|
+
} else if (edited.kind === "clips") {
|
|
21376
|
+
if (shape !== "clips") return { status: "invalid", issue: `a "clips" edit needs a clip set; this plan is ${describeShape(shape)}` };
|
|
21377
|
+
const clips = edited.clips;
|
|
21378
|
+
if (!Array.isArray(clips)) return { status: "invalid", issue: "editedEdl.clips must be an array" };
|
|
21379
|
+
const planned = plan.length;
|
|
21380
|
+
if (clips.length !== planned) {
|
|
21381
|
+
return { status: "invalid", issue: `editedEdl.clips holds ${clips.length} decisions; the plan has ${planned} clips` };
|
|
21382
|
+
}
|
|
21383
|
+
const bad = clips.findIndex(
|
|
21384
|
+
(c) => !isRecord3(c) || typeof c.keep !== "boolean" || c.hook !== void 0 && typeof c.hook !== "string"
|
|
21385
|
+
);
|
|
21386
|
+
if (bad >= 0) return { status: "invalid", issue: `editedEdl.clips[${bad}] must be {keep: boolean, hook?: string}` };
|
|
21387
|
+
}
|
|
21388
|
+
return { status: "applied", edited };
|
|
21389
|
+
}
|
|
21390
|
+
function describeShape(shape) {
|
|
21391
|
+
return shape === "edl" ? "a Tighten plan" : shape === "clips" ? "a clip set" : "neither (a chapter list, or no plan)";
|
|
21392
|
+
}
|
|
21393
|
+
function plannedList(plan) {
|
|
21394
|
+
return plan.map((clip) => typeof clip === "string" ? clip : JSON.stringify(clip));
|
|
21395
|
+
}
|
|
21396
|
+
function asOutput(plan) {
|
|
21397
|
+
return Array.isArray(plan) ? { json: plan, listResults: plannedList(plan) } : { json: plan };
|
|
21398
|
+
}
|
|
21399
|
+
function withHook(clip, hook) {
|
|
21400
|
+
if (hook === void 0) return clip;
|
|
21401
|
+
let value = clip;
|
|
21402
|
+
if (typeof clip === "string") {
|
|
21403
|
+
try {
|
|
21404
|
+
value = JSON.parse(clip);
|
|
21405
|
+
} catch {
|
|
21406
|
+
return clip;
|
|
21407
|
+
}
|
|
21408
|
+
}
|
|
21409
|
+
if (!isRecord3(value)) return clip;
|
|
21410
|
+
const meta = isRecord3(value.meta) ? value.meta : {};
|
|
21411
|
+
return { ...value, meta: { ...meta, hook } };
|
|
21412
|
+
}
|
|
21413
|
+
function resolveEditPlanOutput(plan, editedEdl) {
|
|
21414
|
+
const check = checkEnvelope(editedEdl, plan);
|
|
21415
|
+
if (check.status !== "applied") return { status: check.status, ...asOutput(plan) };
|
|
21416
|
+
const edited = check.edited;
|
|
21417
|
+
if (edited.kind === "edl") {
|
|
21418
|
+
const json = { ...plan, segments: edited.edl.segments, dropped: edited.edl.dropped };
|
|
21419
|
+
return { status: "applied", json };
|
|
21420
|
+
}
|
|
21421
|
+
const rows = plan.map((clip, i) => {
|
|
21422
|
+
const decision = edited.clips[i];
|
|
21423
|
+
return decision.keep ? withHook(clip, decision.hook) : void 0;
|
|
21424
|
+
});
|
|
21425
|
+
return {
|
|
21426
|
+
status: "applied",
|
|
21427
|
+
json: rows.filter((clip) => clip !== void 0),
|
|
21428
|
+
listResults: rows.map((clip) => clip === void 0 ? "" : typeof clip === "string" ? clip : JSON.stringify(clip))
|
|
21429
|
+
};
|
|
21430
|
+
}
|
|
21431
|
+
function editPlanSavedOutput(data) {
|
|
21432
|
+
const plan = data.generatedJson;
|
|
21433
|
+
if (plan === void 0) return void 0;
|
|
21434
|
+
const { status: _status, ...output } = resolveEditPlanOutput(plan, data.editedEdl);
|
|
21435
|
+
return output;
|
|
21436
|
+
}
|
|
21437
|
+
function validateEditedEdl(editedEdl, plan) {
|
|
21438
|
+
const check = checkEnvelope(editedEdl, plan);
|
|
21439
|
+
if (check.status === "none") return { ok: false, issues: ["there is no edit"], warnings: [] };
|
|
21440
|
+
if (check.status !== "applied") return { ok: false, issues: [check.issue], warnings: [] };
|
|
21441
|
+
if (check.edited.kind === "clips") return { ok: true, issues: [], warnings: [] };
|
|
21442
|
+
const resolved = resolveEditPlanOutput(plan, editedEdl).json;
|
|
21443
|
+
return validateEdl(resolved);
|
|
21444
|
+
}
|
|
21445
|
+
|
|
21276
21446
|
exports.ACCESS_LEVELS = ACCESS_LEVELS;
|
|
21277
21447
|
exports.ACTION_CARD_KINDS = ACTION_CARD_KINDS;
|
|
21278
21448
|
exports.ACTIVE_SCENE_HELPERS = ACTIVE_SCENE_HELPERS;
|
|
@@ -21423,6 +21593,7 @@ exports.DETAIL_VARIANTS = DETAIL_VARIANTS;
|
|
|
21423
21593
|
exports.DURATION_PRICED_PROVIDERS = DURATION_PRICED_PROVIDERS;
|
|
21424
21594
|
exports.DYNAMIC_PRODUCER_TYPES = DYNAMIC_PRODUCER_TYPES;
|
|
21425
21595
|
exports.DetectionResultSchema = DetectionResultSchema;
|
|
21596
|
+
exports.EDITED_EDL_VERSION = EDITED_EDL_VERSION;
|
|
21426
21597
|
exports.EDIT_PLAN_BASE_CREDIT_ID = EDIT_PLAN_BASE_CREDIT_ID;
|
|
21427
21598
|
exports.EDIT_PLAN_BUCKET_MINUTES = EDIT_PLAN_BUCKET_MINUTES;
|
|
21428
21599
|
exports.EDIT_PLAN_DEFAULT_CLIP_COUNT = EDIT_PLAN_DEFAULT_CLIP_COUNT;
|
|
@@ -21662,6 +21833,7 @@ exports.OVERLAY_PLATFORM_IDS = OVERLAY_PLATFORM_IDS;
|
|
|
21662
21833
|
exports.OVERLAY_SHAPES = OVERLAY_SHAPES;
|
|
21663
21834
|
exports.OVERLAY_TEXT_ALIGNS = OVERLAY_TEXT_ALIGNS;
|
|
21664
21835
|
exports.OVERLAY_VARIANT_HANDLE_PREFIX = OVERLAY_VARIANT_HANDLE_PREFIX;
|
|
21836
|
+
exports.OWN_LIST_NODE_TYPES = OWN_LIST_NODE_TYPES;
|
|
21665
21837
|
exports.ObjectMetadataSchema = ObjectMetadataSchema;
|
|
21666
21838
|
exports.OptimizeForModelInputSchema = OptimizeForModelInputSchema;
|
|
21667
21839
|
exports.OptimizeForModelResultSchema = OptimizeForModelResultSchema;
|
|
@@ -22179,7 +22351,9 @@ exports.detectVideoLinkPlatform = detectVideoLinkPlatform;
|
|
|
22179
22351
|
exports.dropUnknownBindings = dropUnknownBindings;
|
|
22180
22352
|
exports.dropUnknownSpeakers = dropUnknownSpeakers;
|
|
22181
22353
|
exports.durationsByMode = durationsByMode;
|
|
22354
|
+
exports.editPlanBasis = editPlanBasis;
|
|
22182
22355
|
exports.editPlanBucketMinutes = editPlanBucketMinutes;
|
|
22356
|
+
exports.editPlanSavedOutput = editPlanSavedOutput;
|
|
22183
22357
|
exports.editPlanSourceDurationSec = editPlanSourceDurationSec;
|
|
22184
22358
|
exports.editPlanTranscriptOrigin = editPlanTranscriptOrigin;
|
|
22185
22359
|
exports.edlDurationMs = edlDurationMs;
|
|
@@ -22451,6 +22625,7 @@ exports.overlayStrokeSchema = overlayStrokeSchema;
|
|
|
22451
22625
|
exports.overlayTextStyleSchema = overlayTextStyleSchema;
|
|
22452
22626
|
exports.overlayVariantHandle = overlayVariantHandle;
|
|
22453
22627
|
exports.overlayVariantIdFromHandle = overlayVariantIdFromHandle;
|
|
22628
|
+
exports.ownsItsList = ownsItsList;
|
|
22454
22629
|
exports.parseAspectToken = parseAspectToken;
|
|
22455
22630
|
exports.parseAttributedDialogue = parseAttributedDialogue;
|
|
22456
22631
|
exports.parseCharacterMentionToken = parseCharacterMentionToken;
|
|
@@ -22518,6 +22693,7 @@ exports.resolveConditionValue = resolveConditionValue;
|
|
|
22518
22693
|
exports.resolveDefaultRole = resolveDefaultRole;
|
|
22519
22694
|
exports.resolveDescription = resolveDescription;
|
|
22520
22695
|
exports.resolveDialogueVoices = resolveDialogueVoices;
|
|
22696
|
+
exports.resolveEditPlanOutput = resolveEditPlanOutput;
|
|
22521
22697
|
exports.resolveEditPlanSources = resolveEditPlanSources;
|
|
22522
22698
|
exports.resolveEdlSegmentSlots = resolveEdlSegmentSlots;
|
|
22523
22699
|
exports.resolveEffectiveSourceType = resolveEffectiveSourceType;
|
|
@@ -22756,6 +22932,7 @@ exports.usdToCredits = usdToCredits;
|
|
|
22756
22932
|
exports.validateAiAvatarPayload = validateAiAvatarPayload;
|
|
22757
22933
|
exports.validateCinematicAvatarPayload = validateCinematicAvatarPayload;
|
|
22758
22934
|
exports.validateDurationForFormat = validateDurationForFormat;
|
|
22935
|
+
exports.validateEditedEdl = validateEditedEdl;
|
|
22759
22936
|
exports.validateEdl = validateEdl;
|
|
22760
22937
|
exports.validateEdlClipSet = validateEdlClipSet;
|
|
22761
22938
|
exports.validateModeActivation = validateModeActivation;
|