@mengine/medeo-tool 2.0.1-alpha.10 → 2.0.1-alpha.12
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/{entity-contract-Cf3AiSe7.d.mts → entity-contract-DNIIwpn1.d.mts} +13 -1
- package/dist/{entity-sandbox-BTR2cRl1.mjs → entity-sandbox-DpIkxcei.mjs} +19 -2
- package/dist/{entity-sandbox-BTR2cRl1.mjs.map → entity-sandbox-DpIkxcei.mjs.map} +1 -1
- package/dist/index.d.mts +11 -3
- package/dist/index.mjs +44 -26
- package/dist/index.mjs.map +1 -1
- package/dist/sandbox-api.d.mts +12 -0
- package/dist/worker-entry.d.mts +1 -1
- package/dist/worker-entry.mjs +5 -4
- package/dist/worker-entry.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -147,6 +147,18 @@ type CreateEntityInput = { [K in KnownEntityKind]: {
|
|
|
147
147
|
entity_id?: string;
|
|
148
148
|
entity_kind: K;
|
|
149
149
|
payload: StoredEntityPayload<K>;
|
|
150
|
+
/**
|
|
151
|
+
* The stored resource this entity is made from.
|
|
152
|
+
*
|
|
153
|
+
* Naming it here is the only way to say where an entity's bytes come from:
|
|
154
|
+
* the Asset row and the `from-asset` Relation that reaches it are assembled
|
|
155
|
+
* by the host, never authored. Only a kind that declares `FromAsset` —
|
|
156
|
+
* video, audio, image, caption, audio-script — accepts one.
|
|
157
|
+
*/
|
|
158
|
+
asset?: {
|
|
159
|
+
system: 'memota' | 'memota-speech';
|
|
160
|
+
key: string;
|
|
161
|
+
};
|
|
150
162
|
} }[KnownEntityKind];
|
|
151
163
|
/** Patch supplied fields on the assembled entity; omitted fields remain unchanged. */
|
|
152
164
|
interface UpdateEntityInput {
|
|
@@ -240,4 +252,4 @@ interface BusinessRelationFacade {
|
|
|
240
252
|
}
|
|
241
253
|
//#endregion
|
|
242
254
|
export { UpdateEntityInput as C, UnlinkRelationInput as S, LinkRelationInput as _, DeleteEntityInput as a, SandboxEntity as b, EntitySandboxCheckpoint as c, JsonObject as d, JsonPrimitive as f, LinkGeneratedRelationInput as g, KnownRelationKind as h, CreateEntityInput as i, EntityStoreSnapshot as l, KnownEntityKind as m, BusinessEntityFacade as n, EntityCommand as o, JsonValue as p, BusinessRelationFacade as r, EntityPlanState as s, AuthorableRelationKind as t, EntityUpdateInput as u, RelationUpdateInput as v, SandboxRelation as x, ResourceEntityKind as y };
|
|
243
|
-
//# sourceMappingURL=entity-contract-
|
|
255
|
+
//# sourceMappingURL=entity-contract-DNIIwpn1.d.mts.map
|
|
@@ -1482,6 +1482,16 @@ function businessState(state) {
|
|
|
1482
1482
|
relations: state.relations.filter((row) => row.relation_kind !== "from-asset" && !assets.has(row.endpoint_0_entity_id) && !assets.has(row.endpoint_1_entity_id))
|
|
1483
1483
|
};
|
|
1484
1484
|
}
|
|
1485
|
+
/** Only a kind that declares FromAsset can be made from stored bytes. */
|
|
1486
|
+
function assetLocator(value, entityKind) {
|
|
1487
|
+
if (!declaresKind(entityKind, "FromAsset")) throw new Error(`Entity kind "${entityKind}" cannot be made from an Asset`);
|
|
1488
|
+
if (!isJsonObject(value) || value.system !== "memota" && value.system !== "memota-speech") throw new Error("asset.system must be \"memota\" or \"memota-speech\"");
|
|
1489
|
+
if (typeof value.key !== "string" || value.key.trim() !== value.key || value.key === "") throw new Error("asset.key must be a trimmed, non-empty resource id");
|
|
1490
|
+
return {
|
|
1491
|
+
system: value.system,
|
|
1492
|
+
key: value.key
|
|
1493
|
+
};
|
|
1494
|
+
}
|
|
1485
1495
|
/** Keep infrastructure rows available to assembly without exposing their management to scripts. */
|
|
1486
1496
|
function businessFacades(entities, relations, onDirectScriptWrite) {
|
|
1487
1497
|
const isAsset = (id) => entities.get(id)?.entity_kind === "asset";
|
|
@@ -1506,7 +1516,14 @@ function businessFacades(entities, relations, onDirectScriptWrite) {
|
|
|
1506
1516
|
if (input.entity_kind === "asset") throw new Error("Asset entities are managed by host assembly");
|
|
1507
1517
|
assertBusinessPayload(input.payload);
|
|
1508
1518
|
if (input.entity_id && entities.get(input.entity_id)) throw new Error(`Entity id ${input.entity_id} already exists`);
|
|
1509
|
-
const
|
|
1519
|
+
const asset = input.asset === void 0 ? void 0 : assetLocator(input.asset, input.entity_kind);
|
|
1520
|
+
const { asset: _named, ...row } = input;
|
|
1521
|
+
const id = entities.create(row);
|
|
1522
|
+
if (asset !== void 0) relations.link({
|
|
1523
|
+
relation_kind: "from-asset",
|
|
1524
|
+
endpoint_0_entity_id: id,
|
|
1525
|
+
endpoint_1_entity_id: entities.ensureAsset(asset)
|
|
1526
|
+
});
|
|
1510
1527
|
if (input.entity_kind === "audio-script") onDirectScriptWrite?.(id);
|
|
1511
1528
|
return id;
|
|
1512
1529
|
},
|
|
@@ -2202,4 +2219,4 @@ const numericMarkerComparators = { compareMarkerPoints: (_marker, _range, left,
|
|
|
2202
2219
|
//#endregion
|
|
2203
2220
|
export { createEntityId as a, businessState as i, toDslRows as n, createRelationId as o, businessFacades as r, isMediaAssetVariantKind as s, EntitySandbox as t };
|
|
2204
2221
|
|
|
2205
|
-
//# sourceMappingURL=entity-sandbox-
|
|
2222
|
+
//# sourceMappingURL=entity-sandbox-DpIkxcei.mjs.map
|