@milaboratories/pl-middle-layer 1.53.2 → 1.53.3
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.
|
@@ -3,8 +3,8 @@ import "../pool/index.js";
|
|
|
3
3
|
import { DriverKitOpsConstructor } from "./ops.js";
|
|
4
4
|
import { Signer } from "@milaboratories/ts-helpers";
|
|
5
5
|
import { PlClient } from "@milaboratories/pl-client";
|
|
6
|
-
import { DownloadBlobToURLDriver, DownloadDriver, DownloadUrlDriver, InternalLsDriver, LogsDriver, UploadDriver } from "@milaboratories/pl-drivers";
|
|
7
6
|
import * as Sdk from "@milaboratories/pl-model-common";
|
|
7
|
+
import { DownloadBlobToURLDriver, DownloadDriver, DownloadUrlDriver, InternalLsDriver, LogsDriver, UploadDriver } from "@milaboratories/pl-drivers";
|
|
8
8
|
|
|
9
9
|
//#region src/middle_layer/driver_kit.d.ts
|
|
10
10
|
/**
|
|
@@ -4,6 +4,7 @@ const require_project_model_util = require('../model/project_model_util.cjs');
|
|
|
4
4
|
const require_project_model_v1 = require('../model/project_model_v1.cjs');
|
|
5
5
|
let _milaboratories_ts_helpers = require("@milaboratories/ts-helpers");
|
|
6
6
|
let _milaboratories_pl_client = require("@milaboratories/pl-client");
|
|
7
|
+
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
7
8
|
|
|
8
9
|
//#region src/mutator/migration.ts
|
|
9
10
|
/**
|
|
@@ -25,7 +26,7 @@ async function applyProjectMigrations(pl, rid) {
|
|
|
25
26
|
schemaVersion = require_project_model.SchemaVersionV3;
|
|
26
27
|
}
|
|
27
28
|
if (schemaVersion === require_project_model.SchemaVersionV3) schemaVersion = require_project_model.SchemaVersionCurrent;
|
|
28
|
-
if (schemaVersion !== require_project_model.SchemaVersionCurrent) throw new
|
|
29
|
+
if (schemaVersion !== require_project_model.SchemaVersionCurrent) throw new _milaboratories_pl_model_common.UiError(`This project was created with a newer version of Platforma. Please update to the latest version to open it.`);
|
|
29
30
|
tx.setKValue(rid, require_project_model.SchemaVersionKey, JSON.stringify(require_project_model.SchemaVersionCurrent));
|
|
30
31
|
await tx.commit();
|
|
31
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.cjs","names":["SchemaVersionKey","SchemaVersionCurrent","SchemaVersionV1","SchemaVersionV2","SchemaVersionV3","ProjectStructureKey","allBlocks","BlockFrontendStateKeyPrefixV1","projectFieldName"],"sources":["../../src/mutator/migration.ts"],"sourcesContent":["import type { PlClient, PlTransaction, ResourceId } from \"@milaboratories/pl-client\";\nimport type { ProjectField, ProjectStructure } from \"../model/project_model\";\nimport {\n projectFieldName,\n ProjectStructureKey,\n SchemaVersionCurrent,\n SchemaVersionKey,\n SchemaVersionV2,\n SchemaVersionV3,\n} from \"../model/project_model\";\nimport { BlockFrontendStateKeyPrefixV1, SchemaVersionV1 } from \"../model/project_model_v1\";\nimport { field, isNullResourceId } from \"@milaboratories/pl-client\";\nimport { cachedDeserialize } from \"@milaboratories/ts-helpers\";\nimport { allBlocks } from \"../model/project_model_util\";\n\n/**\n * Migrates the project to the latest schema version.\n *\n * @param pl - The client to use.\n * @param rid - The resource id of the project.\n */\nexport async function applyProjectMigrations(pl: PlClient, rid: ResourceId) {\n await pl.withWriteTx(\"ProjectMigration\", async (tx) => {\n let schemaVersion = await tx.getKValueJson<string>(rid, SchemaVersionKey);\n if (schemaVersion === SchemaVersionCurrent) return;\n\n // Apply migrations in sequence\n if (schemaVersion === SchemaVersionV1) {\n await migrateV1ToV2(tx, rid);\n schemaVersion = SchemaVersionV2;\n }\n\n if (schemaVersion === SchemaVersionV2) {\n await migrateV2ToV3(tx, rid);\n schemaVersion = SchemaVersionV3;\n }\n\n if (schemaVersion === SchemaVersionV3) {\n // V3 → V4: production context chain + staging re-render.\n // The actual chain building and staging reset happens in fixProblemsAndMigrate()\n // (called from ProjectMutator.load). This migration step just bumps the schema\n // to prevent older clients from operating on the new project structure.\n schemaVersion = SchemaVersionCurrent;\n }\n\n if (schemaVersion !== SchemaVersionCurrent) {\n throw new
|
|
1
|
+
{"version":3,"file":"migration.cjs","names":["SchemaVersionKey","SchemaVersionCurrent","SchemaVersionV1","SchemaVersionV2","SchemaVersionV3","UiError","ProjectStructureKey","allBlocks","BlockFrontendStateKeyPrefixV1","projectFieldName"],"sources":["../../src/mutator/migration.ts"],"sourcesContent":["import { UiError } from \"@milaboratories/pl-model-common\";\nimport type { PlClient, PlTransaction, ResourceId } from \"@milaboratories/pl-client\";\nimport type { ProjectField, ProjectStructure } from \"../model/project_model\";\nimport {\n projectFieldName,\n ProjectStructureKey,\n SchemaVersionCurrent,\n SchemaVersionKey,\n SchemaVersionV2,\n SchemaVersionV3,\n} from \"../model/project_model\";\nimport { BlockFrontendStateKeyPrefixV1, SchemaVersionV1 } from \"../model/project_model_v1\";\nimport { field, isNullResourceId } from \"@milaboratories/pl-client\";\nimport { cachedDeserialize } from \"@milaboratories/ts-helpers\";\nimport { allBlocks } from \"../model/project_model_util\";\n\n/**\n * Migrates the project to the latest schema version.\n *\n * @param pl - The client to use.\n * @param rid - The resource id of the project.\n */\nexport async function applyProjectMigrations(pl: PlClient, rid: ResourceId) {\n await pl.withWriteTx(\"ProjectMigration\", async (tx) => {\n let schemaVersion = await tx.getKValueJson<string>(rid, SchemaVersionKey);\n if (schemaVersion === SchemaVersionCurrent) return;\n\n // Apply migrations in sequence\n if (schemaVersion === SchemaVersionV1) {\n await migrateV1ToV2(tx, rid);\n schemaVersion = SchemaVersionV2;\n }\n\n if (schemaVersion === SchemaVersionV2) {\n await migrateV2ToV3(tx, rid);\n schemaVersion = SchemaVersionV3;\n }\n\n if (schemaVersion === SchemaVersionV3) {\n // V3 → V4: production context chain + staging re-render.\n // The actual chain building and staging reset happens in fixProblemsAndMigrate()\n // (called from ProjectMutator.load). This migration step just bumps the schema\n // to prevent older clients from operating on the new project structure.\n schemaVersion = SchemaVersionCurrent;\n }\n\n if (schemaVersion !== SchemaVersionCurrent) {\n throw new UiError(\n `This project was created with a newer version of Platforma. Please update to the latest version to open it.`,\n );\n }\n\n tx.setKValue(rid, SchemaVersionKey, JSON.stringify(SchemaVersionCurrent));\n await tx.commit();\n });\n}\n\n/**\n * Migrates the project from schema version 1 to 2.\n *\n * Summary of changes:\n * - uiState is now stored in a field instead of a KV\n *\n * @param tx - The transaction to use.\n * @param rid - The resource id of the project.\n */\nasync function migrateV1ToV2(tx: PlTransaction, rid: ResourceId) {\n const [structure, allKV] = await Promise.all([\n tx.getKValueJson<ProjectStructure>(rid, ProjectStructureKey),\n tx.listKeyValues(rid),\n ]);\n const kvMap = new Map<string, Uint8Array>(allKV.map((kv) => [kv.key, kv.value]));\n for (const block of allBlocks(structure)) {\n const kvKey = BlockFrontendStateKeyPrefixV1 + block.id;\n const uiState = kvMap.get(kvKey);\n const valueJson = uiState ? cachedDeserialize(uiState) : {};\n const uiStateR = tx.createJsonGzValue(valueJson);\n const uiStateF = field(rid, projectFieldName(block.id, \"blockStorage\"));\n tx.createField(uiStateF, \"Dynamic\", uiStateR);\n tx.deleteKValue(rid, kvKey);\n }\n}\n\n/**\n * Migrates the project from schema version 2 to 3.\n *\n * Summary of changes:\n * - Introduces unified 'blockStorage' field containing { args, uiState }\n * - Adds 'currentPrerunArgs' field for staging/prerun rendering\n * - For each block:\n * 1. Read existing 'blockStorage' field (contains uiState in v2)\n * 2. Read existing 'currentArgs' field (contains args)\n * 3. Create unified state = { args: currentArgs, uiState: oldState }\n * 4. Write to new {blockId}-blockStorage field (overwrites)\n * 5. Initialize {blockId}-currentPrerunArgs (same as prodArgs for v1/v2 blocks)\n * - Note: currentArgs and prodArgs fields remain for compatibility layer\n *\n * @param tx - The transaction to use.\n * @param rid - The resource id of the project.\n */\nasync function migrateV2ToV3(tx: PlTransaction, rid: ResourceId) {\n const [structure, fullResourceState] = await Promise.all([\n tx.getKValueJson<ProjectStructure>(rid, ProjectStructureKey),\n tx.getResourceData(rid, true),\n ]);\n\n // Build a map of field name -> resource id for quick lookup\n const fieldMap = new Map<string, ResourceId>();\n for (const f of fullResourceState.fields) {\n if (!isNullResourceId(f.value)) {\n fieldMap.set(f.name, f.value);\n }\n }\n\n for (const block of allBlocks(structure)) {\n // Read existing field values\n const uiStateFieldName = projectFieldName(block.id, \"uiState\" as ProjectField[\"fieldName\"]);\n const currentArgsFieldName = projectFieldName(block.id, \"currentArgs\");\n\n const uiStateRid = fieldMap.get(uiStateFieldName);\n const currentArgsRid = fieldMap.get(currentArgsFieldName);\n\n // Read field data in parallel where available\n const [uiStateData, currentArgsData] = await Promise.all([\n uiStateRid ? tx.getResourceData(uiStateRid, false) : Promise.resolve(undefined),\n currentArgsRid ? tx.getResourceData(currentArgsRid, false) : Promise.resolve(undefined),\n ]);\n\n // Extract values - in v2, 'blockStorage' contains raw uiState, not wrapped\n const uiState = uiStateData?.data ? cachedDeserialize(uiStateData.data) : {};\n const args = currentArgsData?.data ? cachedDeserialize(currentArgsData.data) : {};\n\n // Create unified state: { args, uiState }\n const unifiedState = {\n args,\n uiState,\n };\n\n const blockStorageFieldName = projectFieldName(block.id, \"blockStorage\");\n\n // Write new unified blockStorage field (overwrite existing)\n const stateR = tx.createJsonGzValue(unifiedState);\n const stateF = field(rid, blockStorageFieldName);\n tx.createField(stateF, \"Dynamic\", stateR);\n\n // Initialize currentPrerunArgs from currentArgs (for legacy blocks, prerunArgs = args)\n if (currentArgsRid) {\n const prerunArgsR = tx.createJsonGzValue(args);\n const prerunArgsF = field(rid, projectFieldName(block.id, \"currentPrerunArgs\"));\n tx.createField(prerunArgsF, \"Dynamic\", prerunArgsR);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,eAAsB,uBAAuB,IAAc,KAAiB;AAC1E,OAAM,GAAG,YAAY,oBAAoB,OAAO,OAAO;EACrD,IAAI,gBAAgB,MAAM,GAAG,cAAsB,KAAKA,uCAAiB;AACzE,MAAI,kBAAkBC,2CAAsB;AAG5C,MAAI,kBAAkBC,0CAAiB;AACrC,SAA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C,MAAK,MAAM,SAASC,qCAAU,UAAU,EAAE;EAExC,MAAM,mBAAmBE,uCAAiB,MAAM,IAAI,UAAuC;EAC3F,MAAM,uBAAuBA,uCAAiB,MAAM,IAAI,cAAc;EAEtE,MAAM,aAAa,SAAS,IAAI,iBAAiB;EACjD,MAAM,iBAAiB,SAAS,IAAI,qBAAqB;EAGzD,MAAM,CAAC,aAAa,mBAAmB,MAAM,QAAQ,IAAI,CACvD,aAAa,GAAG,gBAAgB,YAAY,MAAM,GAAG,QAAQ,QAAQ,OAAU,EAC/E,iBAAiB,GAAG,gBAAgB,gBAAgB,MAAM,GAAG,QAAQ,QAAQ,OAAU,CACxF,CAAC;EAGF,MAAM,UAAU,aAAa,yDAAyB,YAAY,KAAK,GAAG,EAAE;EAC5E,MAAM,OAAO,iBAAiB,yDAAyB,gBAAgB,KAAK,GAAG,EAAE;EAGjF,MAAM,eAAe;GACnB;GACA;GACD;EAED,MAAM,wBAAwBA,uCAAiB,MAAM,IAAI,eAAe;EAGxE,MAAM,SAAS,GAAG,kBAAkB,aAAa;EACjD,MAAM,8CAAe,KAAK,sBAAsB;AAChD,KAAG,YAAY,QAAQ,WAAW,OAAO;AAGzC,MAAI,gBAAgB;GAClB,MAAM,cAAc,GAAG,kBAAkB,KAAK;GAC9C,MAAM,mDAAoB,KAAKA,uCAAiB,MAAM,IAAI,oBAAoB,CAAC;AAC/E,MAAG,YAAY,aAAa,WAAW,YAAY"}
|
|
@@ -3,6 +3,7 @@ import { allBlocks } from "../model/project_model_util.js";
|
|
|
3
3
|
import { BlockFrontendStateKeyPrefixV1, SchemaVersionV1 } from "../model/project_model_v1.js";
|
|
4
4
|
import { cachedDeserialize } from "@milaboratories/ts-helpers";
|
|
5
5
|
import { field, isNullResourceId } from "@milaboratories/pl-client";
|
|
6
|
+
import { UiError } from "@milaboratories/pl-model-common";
|
|
6
7
|
|
|
7
8
|
//#region src/mutator/migration.ts
|
|
8
9
|
/**
|
|
@@ -24,7 +25,7 @@ async function applyProjectMigrations(pl, rid) {
|
|
|
24
25
|
schemaVersion = SchemaVersionV3;
|
|
25
26
|
}
|
|
26
27
|
if (schemaVersion === SchemaVersionV3) schemaVersion = SchemaVersionCurrent;
|
|
27
|
-
if (schemaVersion !== SchemaVersionCurrent) throw new
|
|
28
|
+
if (schemaVersion !== SchemaVersionCurrent) throw new UiError(`This project was created with a newer version of Platforma. Please update to the latest version to open it.`);
|
|
28
29
|
tx.setKValue(rid, SchemaVersionKey, JSON.stringify(SchemaVersionCurrent));
|
|
29
30
|
await tx.commit();
|
|
30
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.js","names":[],"sources":["../../src/mutator/migration.ts"],"sourcesContent":["import type { PlClient, PlTransaction, ResourceId } from \"@milaboratories/pl-client\";\nimport type { ProjectField, ProjectStructure } from \"../model/project_model\";\nimport {\n projectFieldName,\n ProjectStructureKey,\n SchemaVersionCurrent,\n SchemaVersionKey,\n SchemaVersionV2,\n SchemaVersionV3,\n} from \"../model/project_model\";\nimport { BlockFrontendStateKeyPrefixV1, SchemaVersionV1 } from \"../model/project_model_v1\";\nimport { field, isNullResourceId } from \"@milaboratories/pl-client\";\nimport { cachedDeserialize } from \"@milaboratories/ts-helpers\";\nimport { allBlocks } from \"../model/project_model_util\";\n\n/**\n * Migrates the project to the latest schema version.\n *\n * @param pl - The client to use.\n * @param rid - The resource id of the project.\n */\nexport async function applyProjectMigrations(pl: PlClient, rid: ResourceId) {\n await pl.withWriteTx(\"ProjectMigration\", async (tx) => {\n let schemaVersion = await tx.getKValueJson<string>(rid, SchemaVersionKey);\n if (schemaVersion === SchemaVersionCurrent) return;\n\n // Apply migrations in sequence\n if (schemaVersion === SchemaVersionV1) {\n await migrateV1ToV2(tx, rid);\n schemaVersion = SchemaVersionV2;\n }\n\n if (schemaVersion === SchemaVersionV2) {\n await migrateV2ToV3(tx, rid);\n schemaVersion = SchemaVersionV3;\n }\n\n if (schemaVersion === SchemaVersionV3) {\n // V3 → V4: production context chain + staging re-render.\n // The actual chain building and staging reset happens in fixProblemsAndMigrate()\n // (called from ProjectMutator.load). This migration step just bumps the schema\n // to prevent older clients from operating on the new project structure.\n schemaVersion = SchemaVersionCurrent;\n }\n\n if (schemaVersion !== SchemaVersionCurrent) {\n throw new
|
|
1
|
+
{"version":3,"file":"migration.js","names":[],"sources":["../../src/mutator/migration.ts"],"sourcesContent":["import { UiError } from \"@milaboratories/pl-model-common\";\nimport type { PlClient, PlTransaction, ResourceId } from \"@milaboratories/pl-client\";\nimport type { ProjectField, ProjectStructure } from \"../model/project_model\";\nimport {\n projectFieldName,\n ProjectStructureKey,\n SchemaVersionCurrent,\n SchemaVersionKey,\n SchemaVersionV2,\n SchemaVersionV3,\n} from \"../model/project_model\";\nimport { BlockFrontendStateKeyPrefixV1, SchemaVersionV1 } from \"../model/project_model_v1\";\nimport { field, isNullResourceId } from \"@milaboratories/pl-client\";\nimport { cachedDeserialize } from \"@milaboratories/ts-helpers\";\nimport { allBlocks } from \"../model/project_model_util\";\n\n/**\n * Migrates the project to the latest schema version.\n *\n * @param pl - The client to use.\n * @param rid - The resource id of the project.\n */\nexport async function applyProjectMigrations(pl: PlClient, rid: ResourceId) {\n await pl.withWriteTx(\"ProjectMigration\", async (tx) => {\n let schemaVersion = await tx.getKValueJson<string>(rid, SchemaVersionKey);\n if (schemaVersion === SchemaVersionCurrent) return;\n\n // Apply migrations in sequence\n if (schemaVersion === SchemaVersionV1) {\n await migrateV1ToV2(tx, rid);\n schemaVersion = SchemaVersionV2;\n }\n\n if (schemaVersion === SchemaVersionV2) {\n await migrateV2ToV3(tx, rid);\n schemaVersion = SchemaVersionV3;\n }\n\n if (schemaVersion === SchemaVersionV3) {\n // V3 → V4: production context chain + staging re-render.\n // The actual chain building and staging reset happens in fixProblemsAndMigrate()\n // (called from ProjectMutator.load). This migration step just bumps the schema\n // to prevent older clients from operating on the new project structure.\n schemaVersion = SchemaVersionCurrent;\n }\n\n if (schemaVersion !== SchemaVersionCurrent) {\n throw new UiError(\n `This project was created with a newer version of Platforma. Please update to the latest version to open it.`,\n );\n }\n\n tx.setKValue(rid, SchemaVersionKey, JSON.stringify(SchemaVersionCurrent));\n await tx.commit();\n });\n}\n\n/**\n * Migrates the project from schema version 1 to 2.\n *\n * Summary of changes:\n * - uiState is now stored in a field instead of a KV\n *\n * @param tx - The transaction to use.\n * @param rid - The resource id of the project.\n */\nasync function migrateV1ToV2(tx: PlTransaction, rid: ResourceId) {\n const [structure, allKV] = await Promise.all([\n tx.getKValueJson<ProjectStructure>(rid, ProjectStructureKey),\n tx.listKeyValues(rid),\n ]);\n const kvMap = new Map<string, Uint8Array>(allKV.map((kv) => [kv.key, kv.value]));\n for (const block of allBlocks(structure)) {\n const kvKey = BlockFrontendStateKeyPrefixV1 + block.id;\n const uiState = kvMap.get(kvKey);\n const valueJson = uiState ? cachedDeserialize(uiState) : {};\n const uiStateR = tx.createJsonGzValue(valueJson);\n const uiStateF = field(rid, projectFieldName(block.id, \"blockStorage\"));\n tx.createField(uiStateF, \"Dynamic\", uiStateR);\n tx.deleteKValue(rid, kvKey);\n }\n}\n\n/**\n * Migrates the project from schema version 2 to 3.\n *\n * Summary of changes:\n * - Introduces unified 'blockStorage' field containing { args, uiState }\n * - Adds 'currentPrerunArgs' field for staging/prerun rendering\n * - For each block:\n * 1. Read existing 'blockStorage' field (contains uiState in v2)\n * 2. Read existing 'currentArgs' field (contains args)\n * 3. Create unified state = { args: currentArgs, uiState: oldState }\n * 4. Write to new {blockId}-blockStorage field (overwrites)\n * 5. Initialize {blockId}-currentPrerunArgs (same as prodArgs for v1/v2 blocks)\n * - Note: currentArgs and prodArgs fields remain for compatibility layer\n *\n * @param tx - The transaction to use.\n * @param rid - The resource id of the project.\n */\nasync function migrateV2ToV3(tx: PlTransaction, rid: ResourceId) {\n const [structure, fullResourceState] = await Promise.all([\n tx.getKValueJson<ProjectStructure>(rid, ProjectStructureKey),\n tx.getResourceData(rid, true),\n ]);\n\n // Build a map of field name -> resource id for quick lookup\n const fieldMap = new Map<string, ResourceId>();\n for (const f of fullResourceState.fields) {\n if (!isNullResourceId(f.value)) {\n fieldMap.set(f.name, f.value);\n }\n }\n\n for (const block of allBlocks(structure)) {\n // Read existing field values\n const uiStateFieldName = projectFieldName(block.id, \"uiState\" as ProjectField[\"fieldName\"]);\n const currentArgsFieldName = projectFieldName(block.id, \"currentArgs\");\n\n const uiStateRid = fieldMap.get(uiStateFieldName);\n const currentArgsRid = fieldMap.get(currentArgsFieldName);\n\n // Read field data in parallel where available\n const [uiStateData, currentArgsData] = await Promise.all([\n uiStateRid ? tx.getResourceData(uiStateRid, false) : Promise.resolve(undefined),\n currentArgsRid ? tx.getResourceData(currentArgsRid, false) : Promise.resolve(undefined),\n ]);\n\n // Extract values - in v2, 'blockStorage' contains raw uiState, not wrapped\n const uiState = uiStateData?.data ? cachedDeserialize(uiStateData.data) : {};\n const args = currentArgsData?.data ? cachedDeserialize(currentArgsData.data) : {};\n\n // Create unified state: { args, uiState }\n const unifiedState = {\n args,\n uiState,\n };\n\n const blockStorageFieldName = projectFieldName(block.id, \"blockStorage\");\n\n // Write new unified blockStorage field (overwrite existing)\n const stateR = tx.createJsonGzValue(unifiedState);\n const stateF = field(rid, blockStorageFieldName);\n tx.createField(stateF, \"Dynamic\", stateR);\n\n // Initialize currentPrerunArgs from currentArgs (for legacy blocks, prerunArgs = args)\n if (currentArgsRid) {\n const prerunArgsR = tx.createJsonGzValue(args);\n const prerunArgsF = field(rid, projectFieldName(block.id, \"currentPrerunArgs\"));\n tx.createField(prerunArgsF, \"Dynamic\", prerunArgsR);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,eAAsB,uBAAuB,IAAc,KAAiB;AAC1E,OAAM,GAAG,YAAY,oBAAoB,OAAO,OAAO;EACrD,IAAI,gBAAgB,MAAM,GAAG,cAAsB,KAAK,iBAAiB;AACzE,MAAI,kBAAkB,qBAAsB;AAG5C,MAAI,kBAAkB,iBAAiB;AACrC,S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IjC,MAAK,MAAM,SAAS,UAAU,UAAU,EAAE;EAExC,MAAM,mBAAmB,iBAAiB,MAAM,IAAI,UAAuC;EAC3F,MAAM,uBAAuB,iBAAiB,MAAM,IAAI,cAAc;EAEtE,MAAM,aAAa,SAAS,IAAI,iBAAiB;EACjD,MAAM,iBAAiB,SAAS,IAAI,qBAAqB;EAGzD,MAAM,CAAC,aAAa,mBAAmB,MAAM,QAAQ,IAAI,CACvD,aAAa,GAAG,gBAAgB,YAAY,MAAM,GAAG,QAAQ,QAAQ,OAAU,EAC/E,iBAAiB,GAAG,gBAAgB,gBAAgB,MAAM,GAAG,QAAQ,QAAQ,OAAU,CACxF,CAAC;EAGF,MAAM,UAAU,aAAa,OAAO,kBAAkB,YAAY,KAAK,GAAG,EAAE;EAC5E,MAAM,OAAO,iBAAiB,OAAO,kBAAkB,gBAAgB,KAAK,GAAG,EAAE;EAGjF,MAAM,eAAe;GACnB;GACA;GACD;EAED,MAAM,wBAAwB,iBAAiB,MAAM,IAAI,eAAe;EAGxE,MAAM,SAAS,GAAG,kBAAkB,aAAa;EACjD,MAAM,SAAS,MAAM,KAAK,sBAAsB;AAChD,KAAG,YAAY,QAAQ,WAAW,OAAO;AAGzC,MAAI,gBAAgB;GAClB,MAAM,cAAc,GAAG,kBAAkB,KAAK;GAC9C,MAAM,cAAc,MAAM,KAAK,iBAAiB,MAAM,IAAI,oBAAoB,CAAC;AAC/E,MAAG,YAAY,aAAa,WAAW,YAAY"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-middle-layer",
|
|
3
|
-
"version": "1.53.
|
|
3
|
+
"version": "1.53.3",
|
|
4
4
|
"description": "Pl Middle Layer",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -30,23 +30,23 @@
|
|
|
30
30
|
"utility-types": "^3.11.0",
|
|
31
31
|
"yaml": "^2.8.0",
|
|
32
32
|
"zod": "~3.23.8",
|
|
33
|
+
"@milaboratories/computable": "2.9.0",
|
|
33
34
|
"@milaboratories/pf-driver": "1.2.0",
|
|
34
35
|
"@milaboratories/pl-client": "2.18.2",
|
|
35
36
|
"@milaboratories/pl-deployments": "2.16.2",
|
|
36
|
-
"@milaboratories/computable": "2.9.0",
|
|
37
|
-
"@milaboratories/pf-spec-driver": "1.1.0",
|
|
38
|
-
"@milaboratories/pl-drivers": "1.12.4",
|
|
39
37
|
"@milaboratories/pl-http": "1.2.4",
|
|
40
|
-
"@milaboratories/pl-
|
|
41
|
-
"@milaboratories/pl-model-backend": "1.2.2",
|
|
38
|
+
"@milaboratories/pl-drivers": "1.12.4",
|
|
42
39
|
"@milaboratories/pl-errors": "1.2.2",
|
|
40
|
+
"@milaboratories/pl-model-backend": "1.2.2",
|
|
41
|
+
"@milaboratories/pf-spec-driver": "1.1.0",
|
|
43
42
|
"@milaboratories/pl-model-common": "1.29.0",
|
|
44
43
|
"@milaboratories/pl-model-middle-layer": "1.16.0",
|
|
45
44
|
"@milaboratories/resolve-helper": "1.1.3",
|
|
45
|
+
"@platforma-sdk/block-tools": "2.7.2",
|
|
46
46
|
"@milaboratories/ts-helpers": "1.7.3",
|
|
47
|
+
"@milaboratories/pl-tree": "1.9.3",
|
|
47
48
|
"@platforma-sdk/model": "1.61.1",
|
|
48
|
-
"@platforma-sdk/workflow-tengo": "5.11.0"
|
|
49
|
-
"@platforma-sdk/block-tools": "2.7.2"
|
|
49
|
+
"@platforma-sdk/workflow-tengo": "5.11.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/node": "~24.5.2",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"semver": "^7.7.2",
|
|
56
56
|
"typescript": "~5.9.3",
|
|
57
57
|
"vitest": "^4.0.18",
|
|
58
|
-
"@milaboratories/ts-builder": "1.3.0",
|
|
59
58
|
"@milaboratories/build-configs": "1.5.2",
|
|
59
|
+
"@milaboratories/ts-builder": "1.3.0",
|
|
60
60
|
"@milaboratories/ts-configs": "1.2.2"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
package/src/mutator/migration.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UiError } from "@milaboratories/pl-model-common";
|
|
1
2
|
import type { PlClient, PlTransaction, ResourceId } from "@milaboratories/pl-client";
|
|
2
3
|
import type { ProjectField, ProjectStructure } from "../model/project_model";
|
|
3
4
|
import {
|
|
@@ -44,7 +45,9 @@ export async function applyProjectMigrations(pl: PlClient, rid: ResourceId) {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
if (schemaVersion !== SchemaVersionCurrent) {
|
|
47
|
-
throw new
|
|
48
|
+
throw new UiError(
|
|
49
|
+
`This project was created with a newer version of Platforma. Please update to the latest version to open it.`,
|
|
50
|
+
);
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
tx.setKValue(rid, SchemaVersionKey, JSON.stringify(SchemaVersionCurrent));
|