@seedprotocol/sdk 0.7.2 → 0.7.3-next.613.g79a8dfd
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/{ClientManager-ClCwwhwo.js → ClientManager-DDA9956Y.js} +9 -9
- package/dist/{ClientManager-ClCwwhwo.js.map → ClientManager-DDA9956Y.js.map} +1 -1
- package/dist/{Item-B9Y4VuK1.js → Item-D4FigtYS.js} +40 -40
- package/dist/{Item-B9Y4VuK1.js.map → Item-D4FigtYS.js.map} +1 -1
- package/dist/{ModelProperty-BMePcicQ.js → ModelProperty-BDt6AU2h.js} +23 -23
- package/dist/{ModelProperty-BMePcicQ.js.map → ModelProperty-BDt6AU2h.js.map} +1 -1
- package/dist/{Schema-COsEXXaR.js → Schema-B8xqLWkL.js} +28 -28
- package/dist/{Schema-COsEXXaR.js.map → Schema-B8xqLWkL.js.map} +1 -1
- package/dist/{SchemaValidationService-DabGMzSE.js → SchemaValidationService-BPxkfDLU.js} +6 -6
- package/dist/{SchemaValidationService-DabGMzSE.js.map → SchemaValidationService-BPxkfDLU.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-Ck6fumnm.js → backfillMetadataPropertyIds-DuTPcv8t.js} +3 -3
- package/dist/{backfillMetadataPropertyIds-Ck6fumnm.js.map → backfillMetadataPropertyIds-DuTPcv8t.js.map} +1 -1
- package/dist/cjs/{ModelProperty-BT6Un_MB.js → ModelProperty-B-cZm1yU.js} +21 -21
- package/dist/cjs/{ModelProperty-BT6Un_MB.js.map → ModelProperty-B-cZm1yU.js.map} +1 -1
- package/dist/cjs/{Schema-BXhXdUsA.js → Schema-STP972Xw.js} +23 -23
- package/dist/cjs/{Schema-BXhXdUsA.js.map → Schema-STP972Xw.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-CC18QDfc.js → SchemaValidationService-CKNW1bKg.js} +2 -2
- package/dist/cjs/{SchemaValidationService-CC18QDfc.js.map → SchemaValidationService-CKNW1bKg.js.map} +1 -1
- package/dist/cjs/{backfillMetadataPropertyIds-DEHC9ejq.js → backfillMetadataPropertyIds-CP3y1skt.js} +3 -3
- package/dist/cjs/{backfillMetadataPropertyIds-DEHC9ejq.js.map → backfillMetadataPropertyIds-CP3y1skt.js.map} +1 -1
- package/dist/cjs/{eas-C3CL0l7l.js → eas-CAnUC4wd.js} +3 -3
- package/dist/cjs/{eas-C3CL0l7l.js.map → eas-CAnUC4wd.js.map} +1 -1
- package/dist/cjs/{getItem-CrwWYCkj.js → getItem-CWgb3e9G.js} +2 -2
- package/dist/cjs/{getItem-CrwWYCkj.js.map → getItem-CWgb3e9G.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-DRJh7WR0.js → getPublishPayload-BsZWiJ03.js} +11 -11
- package/dist/cjs/{getPublishPayload-DRJh7WR0.js.map → getPublishPayload-BsZWiJ03.js.map} +1 -1
- package/dist/cjs/{getPublishUploads-Bh22D3zJ.js → getPublishUploads-BQr8aMVP.js} +4 -4
- package/dist/cjs/{getPublishUploads-Bh22D3zJ.js.map → getPublishUploads-BQr8aMVP.js.map} +1 -1
- package/dist/cjs/{index-BA1RIYFG.js → index-nA5PxBSs.js} +3 -3
- package/dist/cjs/index-nA5PxBSs.js.map +1 -0
- package/dist/cjs/{index-Dls7aMjr.js → index-usKaANAq.js} +79 -37
- package/dist/cjs/index-usKaANAq.js.map +1 -0
- package/dist/cjs/{property-ZerTWizX.js → property-xMwPhQ5N.js} +5 -5
- package/dist/cjs/{property-ZerTWizX.js.map → property-xMwPhQ5N.js.map} +1 -1
- package/dist/cjs/{publishDraftGraph-CPOAcQFf.js → publishDraftGraph-BRWlR1KO.js} +4 -4
- package/dist/cjs/{publishDraftGraph-CPOAcQFf.js.map → publishDraftGraph-BRWlR1KO.js.map} +1 -1
- package/dist/cjs/{resetAmbiguousLegacyItemData-adDl4LcT.js → resetAmbiguousLegacyItemData-8nfkj9rz.js} +2 -2
- package/dist/cjs/{resetAmbiguousLegacyItemData-adDl4LcT.js.map → resetAmbiguousLegacyItemData-8nfkj9rz.js.map} +1 -1
- package/dist/cjs/{resolveModelForSyncedSeed-DoNThPdL.js → resolveModelForSyncedSeed-kYRuDWYw.js} +2 -2
- package/dist/cjs/{resolveModelForSyncedSeed-DoNThPdL.js.map → resolveModelForSyncedSeed-kYRuDWYw.js.map} +1 -1
- package/dist/cjs/{syncDbWithEas-CYfPkus9.js → syncDbWithEas-DqRhV8o2.js} +7 -7
- package/dist/cjs/{syncDbWithEas-CYfPkus9.js.map → syncDbWithEas-DqRhV8o2.js.map} +1 -1
- package/dist/{configurePlatform-xU3Hsno3.js → configurePlatform-YcOiDQBZ.js} +3 -3
- package/dist/{configurePlatform-xU3Hsno3.js.map → configurePlatform-YcOiDQBZ.js.map} +1 -1
- package/dist/{db-W1g29qsM.js → db-CQt-gcAl.js} +3 -3
- package/dist/{db-W1g29qsM.js.map → db-CQt-gcAl.js.map} +1 -1
- package/dist/{eas-CSwV6MvB.js → eas-CpOD74Ke.js} +4 -4
- package/dist/{eas-CSwV6MvB.js.map → eas-CpOD74Ke.js.map} +1 -1
- package/dist/{getItem-BYQeM3DY.js → getItem-B_OoFkd7.js} +4 -4
- package/dist/{getItem-BYQeM3DY.js.map → getItem-B_OoFkd7.js.map} +1 -1
- package/dist/{getPublishPayload-D5CQZd-y.js → getPublishPayload-Xl3sRkR-.js} +14 -14
- package/dist/{getPublishPayload-D5CQZd-y.js.map → getPublishPayload-Xl3sRkR-.js.map} +1 -1
- package/dist/{getPublishUploads-BGpDsrBp.js → getPublishUploads-DHP01KgU.js} +8 -8
- package/dist/{getPublishUploads-BGpDsrBp.js.map → getPublishUploads-DHP01KgU.js.map} +1 -1
- package/dist/{index-Bev-hZF-.js → index-BGt4_oPO.js} +8 -8
- package/dist/index-BGt4_oPO.js.map +1 -0
- package/dist/{index-DRXC5Mra.js → index-Xl1_4Lmb.js} +23 -23
- package/dist/{index-DRXC5Mra.js.map → index-Xl1_4Lmb.js.map} +1 -1
- package/dist/{index.browser-DO20vYuP.js → index.browser-CjTe0vt1.js} +5 -5
- package/dist/{index.browser-DO20vYuP.js.map → index.browser-CjTe0vt1.js.map} +1 -1
- package/dist/{index.node-C4iyOhdo.js → index.node-Cfa7npS6.js} +2 -2
- package/dist/{index.node-C4iyOhdo.js.map → index.node-Cfa7npS6.js.map} +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.js +24 -24
- package/dist/node.js +9 -9
- package/dist/platform.browser.js +3 -3
- package/dist/platform.node.js +1 -1
- package/dist/{property-BT1zDSkd.js → property-BrXkY1Rg.js} +8 -8
- package/dist/{property-BT1zDSkd.js.map → property-BrXkY1Rg.js.map} +1 -1
- package/dist/{publishDraftGraph-Bcfrdj7-.js → publishDraftGraph-X0Wr9txE.js} +7 -7
- package/dist/{publishDraftGraph-Bcfrdj7-.js.map → publishDraftGraph-X0Wr9txE.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-CLlumTBq.js → resolveModelForSyncedSeed-DFVdnYq8.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-CLlumTBq.js.map → resolveModelForSyncedSeed-DFVdnYq8.js.map} +1 -1
- package/dist/src/helpers/tabLocks.d.ts +11 -1
- package/dist/src/helpers/tabLocks.d.ts.map +1 -1
- package/dist/{syncDbWithEas-BQsXjGhe.js → syncDbWithEas-BU-jZ5bJ.js} +11 -11
- package/dist/{syncDbWithEas-BQsXjGhe.js.map → syncDbWithEas-BU-jZ5bJ.js.map} +1 -1
- package/dist/{tabEvents-C9qUKx_z.js → tabEvents-BZJMY5uK.js} +49 -7
- package/dist/tabEvents-BZJMY5uK.js.map +1 -0
- package/dist/{tolerantWebAccess-B-9bwxbw.js → tolerantWebAccess-BZ2RA_mb.js} +4 -4
- package/dist/{tolerantWebAccess-B-9bwxbw.js.map → tolerantWebAccess-BZ2RA_mb.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-D6q0h7pj.js → updateSeedRevokedAt-iLpzae1i.js} +2 -2
- package/dist/{updateSeedRevokedAt-D6q0h7pj.js.map → updateSeedRevokedAt-iLpzae1i.js.map} +1 -1
- package/package.json +5 -5
- package/dist/cjs/index-BA1RIYFG.js.map +0 -1
- package/dist/cjs/index-Dls7aMjr.js.map +0 -1
- package/dist/index-Bev-hZF-.js.map +0 -1
- package/dist/tabEvents-C9qUKx_z.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelProperty-BT6Un_MB.js","sources":["../../../src/ModelProperty/service/actors/saveToSchema.ts","../../../src/ModelProperty/service/actors/compareAndMarkDraft.ts","../../../src/ModelProperty/service/actors/validateProperty.ts","../../../src/ModelProperty/service/modelPropertyMachine.ts","../../../src/db/read/getModelPropertiesData.ts","../../../src/ModelProperty/ModelProperty.ts"],"sourcesContent":["import { EventObject, fromCallback } from 'xstate'\nimport { isActorStopped } from '@/helpers/entity/entityCommon'\nimport { FromCallbackInput } from '@/types'\nimport { ModelPropertyMachineContext } from '../modelPropertyMachine'\nimport debug from 'debug'\nconst logger = debug('seedSdk:modelProperty:actors:saveToSchema')\n\n/**\n * Get schema name from model\n * This function finds which schema contains the given model\n * Exported so it can be reused by ModelProperty for setting schema name\n */\nexport async function getSchemaNameFromModel(modelName: string): Promise<string | undefined> {\n // Get the latest schema files and find which one contains this model\n const schemaHelpersMod = await import('../../../helpers/schema')\n const { listLatestSchemaFiles } = schemaHelpersMod\n const latestSchemas = await listLatestSchemaFiles()\n\n for (const schema of latestSchemas) {\n try {\n const fileManagerMod = await import('../../../helpers/FileManager/BaseFileManager')\n const { BaseFileManager } = fileManagerMod\n const content = await BaseFileManager.readFileAsString(schema.filePath)\n const schemaFile = JSON.parse(content) as any\n\n if (schemaFile.models && schemaFile.models[modelName]) {\n return schema.name\n }\n } catch (error) {\n logger('Error reading schema file:', error)\n continue\n }\n }\n\n return undefined\n}\n\nexport const saveToSchema = fromCallback<\n EventObject,\n FromCallbackInput<ModelPropertyMachineContext>\n>(({ sendBack, input: { context }, self }) => {\n const _saveToSchema = async (): Promise<void> => {\n // Use dynamic import to break circular dependency\n const validationServiceMod = await import('../../../Schema/service/validation/SchemaValidationService')\n const { SchemaValidationService } = validationServiceMod\n const validationService = new SchemaValidationService()\n \n // Validate property structure before saving\n const validationResult = validationService.validatePropertyStructure(context)\n if (!validationResult.isValid) {\n throw new Error(`Property validation failed: ${validationResult.errors.map(e => e.message).join(', ')}`)\n }\n\n // Validate required fields\n if (!context.name) {\n throw new Error('Property name is required')\n }\n\n if (!context.dataType) {\n throw new Error('Data type is required')\n }\n\n if (!context.modelName) {\n throw new Error(`Model not found for modelId: ${context.modelId}`)\n }\n\n // Persist to database only - schema file is updated only when user calls Schema.saveNewVersion()\n const dbMod = await import('../../../helpers/db')\n const { savePropertyToDb } = dbMod\n await savePropertyToDb(context)\n\n // Mark schema as draft so user knows to save\n const schemaName = context._schemaName ?? (await getSchemaNameFromModel(context.modelName))\n if (schemaName) {\n const schemaMod = await import('../../../Schema/Schema')\n const { Schema } = schemaMod\n // Stopped meanwhile (unloaded, or evicted with its schema): don't load the schema again\n if (isActorStopped(self)) return\n const schema = Schema.create(schemaName, { waitForReady: false }) as import('@/Schema/Schema').Schema\n schema.getService().send({\n type: 'markAsDraft',\n propertyKey: `${context.modelName}:${context.name}`,\n })\n }\n\n logger(`Successfully saved property ${context.modelName}:${context.name} to database`)\n }\n\n _saveToSchema().then(() => {\n sendBack({ type: 'saveToSchemaSuccess' })\n }).catch((error) => {\n logger('Error saving to schema:', error)\n sendBack({ type: 'saveToSchemaError', error })\n })\n\n return () => {\n // Cleanup function (optional)\n }\n})\n","import { EventObject, fromCallback } from 'xstate'\nimport { isActorStopped } from '@/helpers/entity/entityCommon'\nimport { FromCallbackInput } from '@/types'\nimport { ModelPropertyMachineContext } from '../modelPropertyMachine'\n// Dynamic import to break circular dependency: helpers/db -> ModelProperty -> compareAndMarkDraft -> helpers/db\n// import { savePropertyToDb } from '@/helpers/db'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:modelProperty:actors:compareAndMarkDraft')\n\nexport const compareAndMarkDraft = fromCallback<\n EventObject,\n FromCallbackInput<ModelPropertyMachineContext>\n>(({ sendBack, input: { context }, self }) => {\n const _compareAndMarkDraft = async (): Promise<void> => {\n // Fill modelName/dataType from _originalValues when missing, then from DB by schemaFileId\n let fullContext = {\n ...context,\n modelName: context.modelName ?? (context._originalValues as any)?.modelName,\n dataType: context.dataType ?? (context._originalValues as any)?.dataType,\n }\n const schemaFileIdForResolve = fullContext._propertyFileId || (typeof fullContext.id === 'string' ? fullContext.id : undefined)\n if (schemaFileIdForResolve && (fullContext.modelName === undefined || fullContext.dataType === undefined)) {\n try {\n const dbMod = await import('../../../helpers/db')\n const { getPropertyModelNameAndDataType, getModelNameByModelId } = dbMod\n let fromDb: { modelName: string; dataType: string } | undefined\n for (let attempt = 0; attempt < 6; attempt++) {\n fromDb = await getPropertyModelNameAndDataType(schemaFileIdForResolve)\n if (fromDb) break\n if (attempt < 5) await new Promise((r) => setTimeout(r, 40))\n }\n if (fromDb) {\n fullContext = {\n ...fullContext,\n modelName: fullContext.modelName ?? fromDb.modelName,\n dataType: fullContext.dataType ?? fromDb.dataType,\n }\n }\n if (fullContext.modelName === undefined && schemaFileIdForResolve) {\n const mod = await import('../../../ModelProperty/ModelProperty')\n const ModelProperty = mod?.ModelProperty ?? (mod as { default?: unknown })?.default\n const pendingModelId = ModelProperty?.getPendingModelId?.(schemaFileIdForResolve)\n if (pendingModelId != null) {\n const modelName = await getModelNameByModelId(pendingModelId)\n if (modelName) {\n fullContext = { ...fullContext, modelName }\n }\n }\n }\n } catch {\n // ignore\n }\n }\n const schemaFileId = fullContext._propertyFileId || (typeof fullContext.id === 'string' ? fullContext.id : undefined)\n // If _originalValues is not set, we still need to save to database if the property exists\n // This handles the case where the name is changed before _originalValues is initialized\n if (!fullContext._originalValues) {\n logger('No original values to compare against')\n logger(`[compareAndMarkDraft] Context: modelName=${fullContext.modelName}, name=${fullContext.name}, id=${fullContext.id}, _propertyFileId=${fullContext._propertyFileId}`)\n\n // If we have a name and modelName, try to save to database anyway\n // This ensures name changes are persisted even if _originalValues isn't initialized yet\n // We need either schemaFileId (id or _propertyFileId) to find the property in the database\n if (fullContext.modelName && fullContext.name && schemaFileId) {\n logger(`[compareAndMarkDraft] _originalValues not set, but saving to database anyway for property ${context.modelName}:${context.name} (schemaFileId: ${schemaFileId})`)\n try {\n const dbMod = await import('../../../helpers/db')\n const { savePropertyToDb } = dbMod\n // Ensure _propertyFileId is set for savePropertyToDb to find the property\n const contextWithFileId = {\n ...fullContext,\n _propertyFileId: schemaFileId,\n }\n await savePropertyToDb(contextWithFileId)\n logger(`[compareAndMarkDraft] Successfully saved property ${fullContext.modelName}:${fullContext.name} to database (no _originalValues)`)\n } catch (error) {\n logger(`[compareAndMarkDraft] Error saving property to database (no _originalValues): ${error}`)\n // Don't throw - this is a best-effort save, but log the error for debugging\n console.error(`[compareAndMarkDraft] Failed to save property ${fullContext.modelName}:${fullContext.name}:`, error)\n }\n } else {\n logger(`[compareAndMarkDraft] Cannot save property ${fullContext.modelName}:${fullContext.name} - missing required fields (schemaFileId: ${schemaFileId})`)\n }\n return\n }\n\n logger(`[compareAndMarkDraft] Comparing: context.name=${fullContext.name}, _originalValues.name=${fullContext._originalValues?.name}`)\n\n // Compare current values with original\n // Only compare property fields, not internal fields\n const propertyFields = ['name', 'dataType', 'ref', 'refModelName', 'refModelId', 'refValueType', 'storageType', 'localStorageDir', 'filenameSuffix', 'modelName', 'modelId', 'required']\n const hasChanges = propertyFields.some(key => {\n const currentValue = (fullContext as any)[key]\n const originalValue = (fullContext._originalValues as any)?.[key]\n \n // Handle name changes specifically\n if (key === 'name') {\n const nameChanged = currentValue !== originalValue\n if (nameChanged) {\n logger(`[compareAndMarkDraft] Name change detected: \"${originalValue}\" -> \"${currentValue}\"`)\n }\n return nameChanged\n }\n \n // Handle ref fields - compare by name\n if (key === 'ref' || key === 'refModelName') {\n const currentRef = fullContext.refModelName || fullContext.ref\n const originalRef = fullContext._originalValues?.refModelName || fullContext._originalValues?.ref\n // Both undefined/null means no ref, so they're the same\n if (!currentRef && !originalRef) return false\n return currentRef !== originalRef\n }\n \n // For other fields, compare values (handling undefined/null)\n if (currentValue === undefined && originalValue === undefined) return false\n if (currentValue === null && originalValue === null) return false\n if (currentValue === undefined && originalValue === null) return false\n if (currentValue === null && originalValue === undefined) return false\n \n return currentValue !== originalValue\n })\n\n if (hasChanges) {\n logger(`Property ${fullContext.modelName}:${fullContext.name} has changes, marking as edited`)\n logger(`[compareAndMarkDraft] Context when saving: id=${fullContext.id}, _propertyFileId=${fullContext._propertyFileId}, name=${fullContext.name}, _originalValues.name=${fullContext._originalValues?.name}`)\n\n // Use dynamic import to break circular dependency\n const dbMod = await import('../../../helpers/db')\n const { savePropertyToDb } = dbMod\n // Save to database (but not JSON file) - always save to DB when there are changes\n try {\n await savePropertyToDb(fullContext)\n logger(`[compareAndMarkDraft] Successfully saved property ${fullContext.modelName}:${fullContext.name} to database`)\n } catch (error) {\n logger(`[compareAndMarkDraft] Error saving property to database: ${error}`)\n throw error\n }\n\n // Mark schema as draft if schema name is available\n if (fullContext._schemaName) {\n // Get the Schema instance and mark it as draft\n const schemaMod = await import('../../../Schema/Schema')\n const { Schema } = schemaMod\n // Stopped meanwhile (unloaded, or evicted with its schema): don't load the schema again\n if (isActorStopped(self)) return\n const schema = Schema.create(fullContext._schemaName, {\n waitForReady: false,\n }) as import('@/Schema/Schema').Schema\n\n // Send event to Schema machine to mark as draft\n schema.getService().send({\n type: 'markAsDraft',\n propertyKey: `${fullContext.modelName}:${fullContext.name}`,\n })\n }\n } else {\n // No changes - clear edited flag in database and context\n logger(`Property ${fullContext.modelName}:${fullContext.name} has no changes`)\n \n // Clear isEdited flag in database\n try {\n const seedSchemaMod = await import('../../../seedSchema')\n const { properties: propertiesTable, models: modelsTable } = seedSchemaMod\n const drizzleMod = await import('drizzle-orm')\n const { eq, and } = drizzleMod\n \n const db = BaseDb.getAppDb()\n if (db && fullContext.modelName && fullContext.name) {\n // Find this property's model (model names are only unique per schema)\n const { resolveModelRecord } = await import('../../../db/read/resolveModelRecord')\n const modelRecord = await resolveModelRecord(\n fullContext.modelName,\n {\n modelId: typeof fullContext.modelId === 'number' ? fullContext.modelId : undefined,\n schemaName: fullContext._schemaName,\n },\n db,\n )\n const modelRecords = modelRecord ? [modelRecord] : []\n \n if (modelRecords.length > 0) {\n // Find property by name and modelId\n const propertyRecords = await db\n .select({ id: propertiesTable.id })\n .from(propertiesTable)\n .where(\n and(\n eq(propertiesTable.name, fullContext.name),\n eq(propertiesTable.modelId, modelRecords[0].id)\n )\n )\n .limit(1)\n \n if (propertyRecords.length > 0) {\n // Clear isEdited flag in database\n await db\n .update(propertiesTable)\n .set({ isEdited: false })\n .where(eq(propertiesTable.id, propertyRecords[0].id!))\n logger(`Cleared isEdited flag in database for property ${fullContext.modelName}:${fullContext.name}`)\n }\n }\n }\n } catch (error) {\n logger(`Error clearing isEdited flag in database: ${error}`)\n }\n \n sendBack({\n type: 'clearEdited',\n })\n }\n }\n\n _compareAndMarkDraft().then(() => {\n sendBack({ type: 'compareAndMarkDraftSuccess' })\n }).catch((error) => {\n logger('Error comparing and marking draft:', error)\n sendBack({ type: 'compareAndMarkDraftError', error })\n })\n\n return () => {\n // Cleanup function (optional)\n }\n})\n","import { EventObject, fromCallback } from 'xstate'\nimport { isActorStopped } from '@/helpers/entity/entityCommon'\nimport { FromCallbackInput } from '@/types'\nimport { ModelPropertyMachineContext } from '../modelPropertyMachine'\n// Dynamic imports to break circular dependencies:\n// - schema/index -> ... -> validateProperty -> SchemaValidationService -> schema/index\n// - schema/Schema -> ... -> validateProperty -> Schema -> schema/Schema\n// import { SchemaValidationService } from '@/Schema/service/validation/SchemaValidationService'\n// import { Schema } from '@/Schema/Schema'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:modelProperty:actors:validateProperty')\n\nexport const validateProperty = fromCallback<\n EventObject,\n FromCallbackInput<ModelPropertyMachineContext>\n>(({ sendBack, input: { context }, self }) => {\n const _validateProperty = async (): Promise<void> => {\n // Use full context for validation: fill modelName/dataType from _originalValues when missing, then\n // from DB by schemaFileId (context.id) so just-created renames don't fail structure validation.\n let fullContext = {\n ...context,\n modelName: context.modelName ?? (context._originalValues as any)?.modelName,\n dataType: context.dataType ?? (context._originalValues as any)?.dataType,\n }\n const schemaFileId = typeof context.id === 'string' ? context.id : undefined\n if (schemaFileId && (fullContext.modelName === undefined || fullContext.dataType === undefined)) {\n // Brief wait so trackPendingWrite from ModelProperty.create() has time to run (it's in setTimeout(0))\n await new Promise((r) => setTimeout(r, 60))\n try {\n const dbMod = await import('../../../helpers/db')\n const { getPropertyModelNameAndDataType, getModelNameByModelId } = dbMod\n // Try pending write first (property row may not exist yet)\n if (fullContext.modelName === undefined && schemaFileId) {\n const mod = await import('../../../ModelProperty/ModelProperty')\n const ModelProperty = mod?.ModelProperty ?? (mod as { default?: unknown })?.default\n const pendingModelId = ModelProperty?.getPendingModelId?.(schemaFileId)\n if (pendingModelId != null) {\n const modelName = await getModelNameByModelId(pendingModelId)\n if (modelName) {\n fullContext = { ...fullContext, modelName }\n }\n }\n }\n // Then DB property lookup with retry (catches row after initial write)\n let fromDb: { modelName: string; dataType: string } | undefined\n for (let attempt = 0; attempt < 6; attempt++) {\n fromDb = await getPropertyModelNameAndDataType(schemaFileId)\n if (fromDb) break\n if (attempt < 5) await new Promise((r) => setTimeout(r, 40))\n }\n if (fromDb) {\n fullContext = {\n ...fullContext,\n modelName: fullContext.modelName ?? fromDb.modelName,\n dataType: fullContext.dataType ?? fromDb.dataType,\n }\n }\n // If still no modelName, try pending write again (may have been set during retries)\n if (fullContext.modelName === undefined && schemaFileId) {\n const mod = await import('../../../ModelProperty/ModelProperty')\n const ModelProperty = mod?.ModelProperty ?? (mod as { default?: unknown })?.default\n const pendingModelId = ModelProperty?.getPendingModelId?.(schemaFileId)\n if (pendingModelId != null) {\n const modelName = await getModelNameByModelId(pendingModelId)\n if (modelName) {\n fullContext = { ...fullContext, modelName }\n }\n }\n }\n } catch {\n // ignore\n }\n }\n // Last resort for structure validation: TProperty requires dataType; allow name+id to pass if we have schemaFileId\n if (fullContext.dataType === undefined && (fullContext.modelName !== undefined || schemaFileId)) {\n fullContext = { ...fullContext, dataType: (fullContext.dataType ?? (context._originalValues as any)?.dataType) || 'Text' }\n }\n // Use dynamic imports to break circular dependencies\n const validationServiceMod = await import('../../../Schema/service/validation/SchemaValidationService')\n const { SchemaValidationService } = validationServiceMod\n const validationService = new SchemaValidationService()\n const schemaMod = await import('../../../Schema/Schema')\n const { Schema } = schemaMod\n \n // Validate property structure\n const structureResult = validationService.validatePropertyStructure(fullContext)\n \n if (!structureResult.isValid) {\n sendBack({ type: 'validationError', errors: structureResult.errors })\n return\n }\n\n // If we have schema name and model name, validate against schema\n // Stopped meanwhile (unloaded, or evicted with its schema): don't load the schema again\n if (isActorStopped(self)) return\n if (fullContext._schemaName && fullContext.modelName) {\n try {\n const schema = Schema.create(fullContext._schemaName, {\n waitForReady: false,\n }) as import('@/Schema/Schema').Schema\n const schemaSnapshot = schema.getService().getSnapshot()\n const schemaStatus = schemaSnapshot.value\n \n // Only validate against schema if it's loaded (in idle state)\n // If still loading, skip schema validation and only do structure validation\n if (schemaStatus === 'idle') {\n const schemaContext = schemaSnapshot.context\n \n // Check if models are actually loaded\n if (schemaContext.models && Object.keys(schemaContext.models).length > 0) {\n // If property name has changed, validate against the original name (from schema file)\n // This handles the case where a property is renamed - the schema file still has the old name\n const propertyNameToValidate = fullContext._originalValues?.name && fullContext._originalValues.name !== fullContext.name\n ? fullContext._originalValues.name\n : fullContext.name || ''\n \n const schemaResult = validationService.validateProperty(\n schemaContext,\n fullContext.modelName,\n propertyNameToValidate,\n fullContext\n )\n \n if (!schemaResult.isValid) {\n // If property was renamed, some validation errors are expected (like property_not_found, missing_type)\n // Only fail if it's a critical error that's not related to the rename\n const isRenamed = fullContext._originalValues?.name && fullContext._originalValues.name !== fullContext.name\n const criticalErrors = schemaResult.errors.filter(err => {\n // Allow property_not_found and missing_type errors when property is renamed\n if (isRenamed && (err.code === 'property_not_found' || err.code === 'missing_type')) {\n return false // Not critical\n }\n // For non-renamed properties, only allow property_not_found if we're validating with the same name\n if (err.code === 'property_not_found' && propertyNameToValidate === fullContext.name) {\n return false // Not critical\n }\n return true // Critical error\n })\n \n if (criticalErrors.length > 0) {\n sendBack({ type: 'validationError', errors: criticalErrors })\n return\n }\n // Continue with validation - rename-related errors are acceptable\n }\n } else {\n logger('Schema models not loaded yet, skipping schema validation')\n // Continue with structure validation only\n }\n } else {\n logger(`Schema is in ${schemaStatus} state, skipping schema validation`)\n // Continue with structure validation only\n }\n } catch (error) {\n logger('Error validating property against schema:', error)\n // Continue with structure validation only\n }\n }\n\n // All validations passed\n sendBack({ type: 'validationSuccess', errors: [] })\n }\n\n _validateProperty().catch((error) => {\n logger('Error in validateProperty:', error)\n sendBack({\n type: 'validationError',\n errors: [{\n field: 'property',\n message: error instanceof Error ? error.message : 'Unknown validation error',\n code: 'validation_exception',\n severity: 'error' as const,\n }],\n })\n })\n\n return () => {\n // Cleanup function (optional)\n }\n})\n\n","import { assign, setup, ActorRefFrom } from 'xstate'\nimport { Static } from '@sinclair/typebox'\nimport { TProperty } from '@/Schema'\nimport { saveToSchema } from './actors/saveToSchema'\nimport { compareAndMarkDraft } from './actors/compareAndMarkDraft'\nimport { validateProperty } from './actors/validateProperty'\nimport { ValidationError } from '@/Schema/validation'\nimport { writeProcessMachine } from '@/services/write/writeProcessMachine'\n\nexport type ModelPropertyMachineContext = Static<typeof TProperty> & {\n // Store original values from the JSON schema file\n _originalValues?: Partial<Static<typeof TProperty>>\n // Track if this property has been edited\n _isEdited?: boolean\n // Reference to the Schema instance this property belongs to\n _schemaName?: string\n // Validation errors\n _validationErrors?: ValidationError[]\n writeProcess?: ActorRefFrom<typeof writeProcessMachine> | null\n // Property file ID (schemaFileId from JSON schema file) - used for lookups\n _propertyFileId?: string\n // Note: id field (from TProperty) is now the schemaFileId (string)\n // _dbId (from TProperty) stores the database integer ID\n // Destroy failure from the last destroy() (read by destroy hooks)\n _destroyError?: { message: string; name?: string } | null\n}\n\nexport const modelPropertyMachine = setup({\n types: {\n context: {} as ModelPropertyMachineContext,\n input: {} as ModelPropertyMachineContext,\n events: {} as\n | { type: 'updateContext'; [key: string]: any }\n | { type: 'initializeOriginalValues'; originalValues: Partial<Static<typeof TProperty>>; schemaName?: string; isEdited?: boolean }\n | { type: 'clearEdited' }\n | { type: 'setSchemaName'; schemaName: string }\n | { type: 'saveToSchema' }\n | { type: 'saveToSchemaSuccess' }\n | { type: 'saveToSchemaError'; error: Error }\n | { type: 'compareAndMarkDraftSuccess' }\n | { type: 'compareAndMarkDraftError' }\n | { type: 'validateProperty' }\n | { type: 'validationSuccess'; errors: ValidationError[] }\n | { type: 'validationError'; errors: ValidationError[] }\n | { type: 'requestWrite'; data: any }\n | { type: 'destroyStarted' }\n | { type: 'destroyError'; error: unknown },\n },\n actors: {\n saveToSchema,\n compareAndMarkDraft,\n validateProperty,\n writeProcessMachine,\n },\n guards: {\n isPropertyValid: ({ context }) => {\n const valid = !context._validationErrors || context._validationErrors.length === 0\n return valid\n },\n },\n actions: {\n assignValidationErrors: assign(({ context, event }) => {\n if (event.type === 'validationError') {\n return {\n ...context,\n _validationErrors: event.errors,\n }\n }\n return context\n }),\n },\n}).createMachine({\n id: 'modelProperty',\n initial: 'idle',\n context: ({ input }) => {\n const context = input as ModelPropertyMachineContext\n return context\n },\n on: {\n updateContext: {\n actions: assign(({ context, event }) => {\n const newContext = Object.assign({}, context) as any\n\n // Check if this is only updating internal fields\n const onlyInternalFields = Object.keys(event).every((key: string) => {\n return key === 'type' || key.startsWith('_')\n })\n \n // Update the context with new values\n for (let i = 0; i < Object.keys(event).length; i++) {\n const key = Object.keys(event)[i] as string\n if (key === 'type') {\n continue\n }\n let value = (event as any)[key]\n // Convert null to undefined for optional fields (TypeBox validation expects undefined, not null)\n // This is especially important for refValueType, refModelId, etc.\n if (value === null && (key === 'refValueType' || key === 'refModelId' || key === 'ref' || key === 'refModelName')) {\n value = undefined\n }\n newContext[key] = value\n }\n\n // Preserve modelName and dataType from context or _originalValues so validation and savePropertyToDb\n // never run with missing required/needed fields (e.g. when a just-created property is renamed before\n // the full context is available from the creator).\n if (newContext.modelName === undefined && (context._originalValues as any)?.modelName !== undefined) {\n newContext.modelName = (context._originalValues as any).modelName\n }\n if (newContext.dataType === undefined && (context._originalValues as any)?.dataType !== undefined) {\n newContext.dataType = (context._originalValues as any).dataType\n }\n\n // Compare with original values and set _isEdited flag (only for non-internal updates)\n if (!onlyInternalFields && context._originalValues) {\n const hasChanges = Object.keys(event).some((key: string) => {\n if (key === 'type' || key.startsWith('_')) return false\n return newContext[key] !== (context._originalValues as any)?.[key]\n })\n newContext._isEdited = hasChanges\n }\n\n // Clear validation errors on context update (will be re-validated if needed)\n newContext._validationErrors = undefined\n\n // Convert null to undefined for optional fields (TypeBox validation expects undefined, not null)\n // This is especially important for refValueType, refModelId, etc.\n const optionalFields = ['refValueType', 'refModelId', 'ref', 'refModelName']\n for (const field of optionalFields) {\n if (newContext[field] === null) {\n newContext[field] = undefined\n }\n }\n\n return newContext\n }),\n // Only trigger validation and compareAndMarkDraft if we're updating non-internal fields\n guard: ({ event }: { event: any }) => {\n const shouldTransition = !Object.keys(event).every((key: string) => {\n return key === 'type' || key.startsWith('_')\n })\n return shouldTransition\n },\n target: '.validating',\n },\n validateProperty: {\n target: '.validating',\n },\n validationSuccess: {\n actions: assign(({ context, event }) => ({\n ...context,\n _validationErrors: [],\n })),\n },\n validationError: {\n actions: 'assignValidationErrors',\n // Note: State-specific transitions are handled in child states\n // This root handler ensures errors are always assigned to context\n },\n initializeOriginalValues: {\n actions: assign(({ context, event }) => ({\n ...context,\n _originalValues: event.originalValues,\n // Senders don't know the schema name; keep one setSchemaName already stored.\n _schemaName: event.schemaName ?? context._schemaName,\n _isEdited: event.isEdited ?? false,\n _validationErrors: undefined,\n })),\n },\n clearEdited: {\n actions: assign(({ context }) => ({\n ...context,\n _isEdited: false,\n _originalValues: { ...context } as Partial<Static<typeof TProperty>>,\n })),\n },\n setSchemaName: {\n actions: assign(({ context, event }) => ({\n ...context,\n _schemaName: event.schemaName,\n })),\n },\n destroyStarted: {\n actions: assign({ _destroyError: null }),\n },\n destroyError: {\n actions: assign(({ event }) => ({\n _destroyError:\n event.error instanceof Error\n ? { message: event.error.message, name: event.error.name }\n : { message: String(event.error) },\n })),\n },\n },\n states: {\n idle: {\n on: {\n saveToSchema: { target: 'saveToSchema' },\n validateProperty: {\n target: 'validating',\n },\n requestWrite: {\n actions: ({ context, event }) => {\n if (context.writeProcess) {\n context.writeProcess.send({\n type: 'startWrite',\n data: event.data,\n })\n }\n },\n },\n },\n entry: assign({\n writeProcess: ({ spawn, context }) => {\n // Spawn writeProcess if we have id (schemaFileId)\n // New properties will have id generated\n const entityId = context.id\n if (!context.writeProcess && entityId) {\n return spawn(writeProcessMachine, {\n input: {\n entityType: 'modelProperty',\n entityId: String(entityId),\n entityData: context,\n },\n })\n }\n return context.writeProcess\n },\n }),\n },\n validating: {\n on: {\n saveToSchema: { target: 'saveToSchema' },\n validationSuccess: {\n target: 'compareAndMarkDraft',\n actions: assign(({ context }) => ({\n ...context,\n _validationErrors: [],\n })),\n },\n // validationError: Uses root handler for assignment, but needs state-specific transition\n validationError: {\n target: 'idle',\n actions: 'assignValidationErrors',\n },\n },\n invoke: {\n src: 'validateProperty',\n input: ({ context }) => ({ context }),\n },\n },\n compareAndMarkDraft: {\n on: {\n saveToSchema: { target: 'saveToSchema' },\n compareAndMarkDraftSuccess: {\n target: 'idle',\n },\n compareAndMarkDraftError: {\n target: 'idle',\n },\n },\n invoke: {\n src: 'compareAndMarkDraft',\n input: ({ context }) => ({ context }),\n },\n },\n saveToSchema: {\n // Gate the save in a transient child. An `always` on this parent targeting `.saving` re-enters\n // the invoking child on every microstep and never settles (save() ran the process out of memory).\n initial: 'checking',\n on: {\n // Apply updateContext but do not re-invoke saveToSchema actor (avoids infinite loop).\n // Context is updated; in-flight save completes with original context.\n updateContext: [\n {\n guard: ({ context, event }) => {\n const onlyInternal = Object.keys(event).every((k: string) => k === 'type' || k.startsWith('_'))\n return !onlyInternal && event.name !== undefined && event.name !== context.name\n },\n actions: assign(({ context, event }) => {\n const newContext = Object.assign({}, context) as any\n const onlyInternalFields = Object.keys(event).every((key: string) => key === 'type' || key.startsWith('_'))\n for (const key of Object.keys(event) as string[]) {\n if (key === 'type') continue\n let value = (event as any)[key]\n if (value === null && ['refValueType', 'refModelId', 'ref', 'refModelName'].includes(key)) value = undefined\n newContext[key] = value\n }\n if (newContext.modelName === undefined && (context._originalValues as any)?.modelName !== undefined) {\n newContext.modelName = (context._originalValues as any).modelName\n }\n if (newContext.dataType === undefined && (context._originalValues as any)?.dataType !== undefined) {\n newContext.dataType = (context._originalValues as any).dataType\n }\n if (!onlyInternalFields && context._originalValues) {\n const hasChanges = Object.keys(event).some((key: string) => {\n if (key === 'type' || key.startsWith('_')) return false\n return newContext[key] !== (context._originalValues as any)?.[key]\n })\n newContext._isEdited = hasChanges\n }\n newContext._validationErrors = undefined\n return newContext\n }),\n },\n {\n actions: assign(({ context, event }) => {\n const newContext = Object.assign({}, context) as any\n const onlyInternalFields = Object.keys(event).every((key: string) => key === 'type' || key.startsWith('_'))\n for (const key of Object.keys(event) as string[]) {\n if (key === 'type') continue\n let value = (event as any)[key]\n if (value === null && ['refValueType', 'refModelId', 'ref', 'refModelName'].includes(key)) value = undefined\n newContext[key] = value\n }\n if (newContext.modelName === undefined && (context._originalValues as any)?.modelName !== undefined) {\n newContext.modelName = (context._originalValues as any).modelName\n }\n if (newContext.dataType === undefined && (context._originalValues as any)?.dataType !== undefined) {\n newContext.dataType = (context._originalValues as any).dataType\n }\n if (!onlyInternalFields && context._originalValues) {\n const hasChanges = Object.keys(event).some((key: string) => {\n if (key === 'type' || key.startsWith('_')) return false\n return newContext[key] !== (context._originalValues as any)?.[key]\n })\n newContext._isEdited = hasChanges\n }\n newContext._validationErrors = undefined\n return newContext\n }),\n },\n ],\n // validationError: Uses root handler for assignment, but needs state-specific transition\n validationError: {\n target: 'idle',\n actions: 'assignValidationErrors',\n },\n },\n states: {\n checking: {\n always: [\n { guard: 'isPropertyValid', target: 'saving' },\n { target: '#modelProperty.idle' },\n ],\n },\n saving: {\n on: {\n saveToSchemaSuccess: {\n target: '#modelProperty.idle',\n },\n saveToSchemaError: {\n target: '#modelProperty.idle',\n },\n },\n invoke: {\n src: 'saveToSchema',\n input: ({ context }) => ({ context }),\n },\n },\n },\n },\n },\n})\n","import { models as modelsTable, properties as propertiesTable } from '@/seedSchema/ModelSchema'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { eq } from 'drizzle-orm'\n\nexport type ModelPropertyDataRow = {\n id: number\n name: string\n dataType: string\n modelId: number\n refModelId: number | null\n refValueType: string | null\n schemaFileId: string | null\n isEdited: number | null\n}\n\ntype GetModelPropertiesData = (\n modelFileId: string,\n) => Promise<ModelPropertyDataRow[]>\n\n/**\n * Returns property rows for a model identified by modelFileId (model's schemaFileId).\n * Resolves modelFileId -> modelId via models table, then selects all properties where modelId = ?.\n * Each row includes schemaFileId for use with ModelProperty.createById(schemaFileId).\n */\nexport const getModelPropertiesData: GetModelPropertiesData = async (\n modelFileId: string,\n): Promise<ModelPropertyDataRow[]> => {\n const appDb = BaseDb.getAppDb()\n if (!appDb || !modelFileId) {\n return []\n }\n\n const modelRows = await appDb\n .select({ id: modelsTable.id })\n .from(modelsTable)\n .where(eq(modelsTable.schemaFileId, modelFileId))\n .limit(1)\n\n if (modelRows.length === 0) {\n return []\n }\n\n const modelId = modelRows[0].id\n\n const rows = await appDb\n .select()\n .from(propertiesTable)\n .where(eq(propertiesTable.modelId, modelId))\n\n return rows as ModelPropertyDataRow[]\n}\n","import { ActorRefFrom, createActor, SnapshotFrom } from 'xstate'\nimport { Static } from '@sinclair/typebox'\nimport { ModelPropertyDataTypes, TProperty, normalizeDataType } from '@/Schema'\nimport { modelPropertyMachine, ModelPropertyMachineContext } from './service/modelPropertyMachine'\nimport { StorageType } from '@/types'\nimport type { CreateWaitOptions } from '@/types'\nimport { BaseFileManager, generateId } from '@/helpers'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { getModelPropertiesData } from '@/db/read/getModelPropertiesData'\nimport { getModelId, getModelIdByFileId } from '@/helpers/db'\nimport { modelPropertiesToObject } from '@/helpers/model'\nimport { Model } from '@/Model/Model'\nimport { Schema } from '@/Schema/Schema'\nimport { properties as propertiesTable, models as modelsTable } from '@/seedSchema/ModelSchema'\nimport { schemas } from '@/seedSchema/SchemaSchema'\nimport { getSchemaNameFromModel } from './service/actors/saveToSchema'\nimport { modelSchemas } from '@/seedSchema/ModelSchemaSchema'\nimport { and, eq } from 'drizzle-orm'\nimport { createReactiveProxy } from '@/helpers/reactiveProxy'\nimport { waitForEntityIdle } from '@/helpers/waitForEntityIdle'\nimport { findEntity } from '@/helpers/entity/entityFind'\nimport { unloadEntity } from '@/helpers/entity/entityUnload'\nimport { isActorStopped } from '@/helpers/entity/entityCommon'\nimport { anyEvictionSince, currentEvictionEpoch, schemaEvictedSince } from '@/helpers/entity/evictionEpoch'\nimport { forceRemoveFromCaches, runDestroyLifecycle } from '@/helpers/entity/entityDestroy'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:modelProperty:ModelProperty')\n\ntype ModelPropertyService = ActorRefFrom<typeof modelPropertyMachine>\ntype ModelPropertySnapshot = SnapshotFrom<typeof modelPropertyMachine>\n\n// Define the property keys from TProperty\nconst TPropertyKeys = [\n 'id',\n 'name',\n 'dataType',\n 'ref',\n 'modelId',\n 'refModelId',\n 'refValueType',\n 'storageType',\n 'localStorageDir',\n 'filenameSuffix',\n 'modelName',\n 'refModelName',\n] as const\n\nexport class ModelProperty {\n protected static instanceCache: Map<\n string,\n { instance: ModelProperty; refCount: number }\n > = new Map()\n\n /**\n * propertyFileId -> where the instance with that id is cached, so getById doesn't scan the cache\n * (a model's properties are looked up one by one, which made loading one model O(n²)).\n * Every cached instance's current id has an entry: it's added when the instance is cached and\n * again whenever its context id changes (a property is often created with a generated id and\n * then gets its real one). Entries aren't removed when an instance leaves the cache or changes\n * id; getById checks an entry before using it.\n */\n private static idIndex = new Map<string, { cacheKey: string; instance: ModelProperty }>()\n\n // Pending writes tracking\n private static pendingWrites = new Map<string, {\n propertyFileId: string\n modelId: number\n status: 'pending' | 'writing' | 'success' | 'error'\n timestamp: number\n }>()\n \n protected readonly _service: ModelPropertyService\n\n name?: string\n dataType?: ModelPropertyDataTypes\n ref?: string\n modelId?: number\n modelName?: string\n refModelId?: number\n refModelName?: string\n refValueType?: ModelPropertyDataTypes\n storageType?: StorageType\n localStorageDir?: string\n filenameSuffix?: string\n\n /** currentEvictionEpoch() at construction: lookups started for this instance don't outlive an eviction. */\n private readonly _evictionEpoch = currentEvictionEpoch()\n\n constructor(property: Static<typeof TProperty>) {\n // id is now the schemaFileId (string), _dbId is the database integer ID\n // Preserve _propertyFileId if it exists in the property object (from getPropertySchema)\n // Convert null to undefined for optional fields (TypeBox validation expects undefined, not null)\n const serviceInput: ModelPropertyMachineContext = {\n ...property,\n _propertyFileId: (property as any)._propertyFileId || property.id,\n refValueType: property.refValueType ?? undefined,\n refModelId: property.refModelId ?? undefined,\n ref: property.ref ?? undefined,\n refModelName: property.refModelName ?? undefined,\n }\n\n this._service = createActor(modelPropertyMachine, {\n input: serviceInput,\n })\n\n this._service.start()\n\n // Initialize original values from the input property\n this._initializeOriginalValues(property)\n\n // Note: Property getters/setters are now handled by the Proxy in create()\n }\n\n /**\n * Send from fire-and-forget async work (DB lookups started in the constructor), which can finish\n * after the instance was unloaded or evicted with its schema.\n */\n private _sendIfRunning(event: Parameters<ModelPropertyService['send']>[0]): void {\n if (isActorStopped(this._service)) return\n this._service.send(event)\n }\n\n /**\n * Initialize original values and schema name for tracking changes\n * This is called asynchronously after construction\n * If the property was loaded from the database and differs from the schema file,\n * it will be marked as edited.\n */\n private _initializeOriginalValues(property: Static<typeof TProperty>): void {\n // Resolve refModelId if ref/refModelName is provided but refModelId is missing\n const refModelName = property.refModelName || property.ref\n if (refModelName && !property.refModelId) {\n // Resolve refModelId asynchronously and update context\n this._resolveRefModelId(refModelName, property).then((refModelId) => {\n if (refModelId) {\n // Update the context with the resolved refModelId\n this._sendIfRunning({\n type: 'updateContext',\n refModelId,\n })\n }\n }).catch(() => {\n // Ignore errors - model might not exist yet\n })\n }\n\n // Get schema file values to use as \"original\" values\n // This allows us to detect if the property was edited (DB value differs from schema file)\n this._getSchemaFileValues(property).then((schemaFileValues) => {\n // Use schema file values as original (not the current property values)\n // This way, if current values differ from schema file, _isEdited will be true\n const originalValues: Partial<Static<typeof TProperty>> = schemaFileValues || {}\n \n // Compare current property values with schema file values to determine if edited\n // Only compare schema-relevant fields, not database-specific fields like id, modelId\n let isEdited = false\n if (schemaFileValues) {\n // Fields that are schema-relevant and should be compared\n const schemaRelevantFields: (keyof Static<typeof TProperty>)[] = [\n 'dataType',\n 'ref',\n 'refModelName',\n 'refValueType',\n 'storageType',\n 'localStorageDir',\n 'filenameSuffix',\n ]\n \n // Check if any schema-relevant field differs between current property and schema file\n isEdited = schemaRelevantFields.some((key) => {\n const currentValue = (property as any)[key]\n const originalValue = (schemaFileValues as any)[key]\n \n // Handle ref fields - compare by name\n if (key === 'ref' || key === 'refModelName') {\n const currentRef = property.refModelName || property.ref\n const originalRef = schemaFileValues.refModelName || schemaFileValues.ref\n // Both undefined/null means no ref, so they're the same\n if (!currentRef && !originalRef) return false\n return currentRef !== originalRef\n }\n \n // For other fields, compare values (handling undefined/null)\n if (currentValue === undefined && originalValue === undefined) return false\n if (currentValue === null && originalValue === null) return false\n if (currentValue === undefined && originalValue === null) return false\n if (currentValue === null && originalValue === undefined) return false\n \n return currentValue !== originalValue\n })\n } else {\n // No schema file values found - this is a runtime-created property\n // Use current property as original, but mark as edited since it hasn't been exported to file\n TPropertyKeys.forEach((key) => {\n if (property[key] !== undefined) {\n (originalValues as any)[key] = property[key]\n }\n })\n // For runtime-created properties, set isEdited = true initially\n isEdited = true\n }\n\n // Initialize with original values, including isEdited flag\n // Load isEdited from database if property exists in DB (async, fire-and-forget)\n this._loadIsEditedFromDb(property, isEdited).then((isEditedFromDb: boolean) => {\n this._sendIfRunning({\n type: 'initializeOriginalValues',\n originalValues,\n schemaName: undefined, // Will be set later if needed\n isEdited: isEditedFromDb,\n })\n }).catch(() => {\n // If we can't load from DB, use computed isEdited value\n this._sendIfRunning({\n type: 'initializeOriginalValues',\n originalValues,\n schemaName: undefined, // Will be set later if needed\n isEdited,\n })\n })\n }).catch(() => {\n // If we can't get schema file values, use current property as original\n const originalValues: Partial<Static<typeof TProperty>> = {}\n TPropertyKeys.forEach((key) => {\n if (property[key] !== undefined) {\n (originalValues as any)[key] = property[key]\n }\n })\n\n this._sendIfRunning({\n type: 'initializeOriginalValues',\n originalValues,\n schemaName: undefined,\n })\n })\n\n // Get schema name from model asynchronously (fire-and-forget)\n if (property.modelName) {\n this._setSchemaName(property).catch(() => {\n // If we can't get schema name, that's okay - it will be set later if needed\n })\n }\n }\n\n /**\n * Load isEdited flag from database if property exists in DB\n * @param property - The property data\n * @param fallbackIsEdited - Fallback value if property doesn't exist in DB\n * @returns The isEdited flag from database or fallback value\n */\n private async _loadIsEditedFromDb(\n property: Static<typeof TProperty>,\n fallbackIsEdited: boolean,\n ): Promise<boolean> {\n if (!property.modelName || !property.name) {\n return fallbackIsEdited\n }\n\n try {\n const db = BaseDb.getAppDb()\n if (!db) {\n return fallbackIsEdited\n }\n\n // Find this property's model (by modelId when known; model names are only unique per schema)\n const { resolveModelRecord } = await import('@/db/read/resolveModelRecord')\n const modelRecord = await resolveModelRecord(property.modelName, this._ownerModelScope(property), db)\n const modelRecords = modelRecord ? [modelRecord] : []\n \n if (modelRecords.length === 0) {\n return fallbackIsEdited\n }\n\n // Find property by name and modelId\n const propertyRecords = await db\n .select({ isEdited: propertiesTable.isEdited })\n .from(propertiesTable)\n .where(\n and(\n eq(propertiesTable.name, property.name),\n eq(propertiesTable.modelId, modelRecords[0].id)\n )\n )\n .limit(1)\n \n if (propertyRecords.length > 0) {\n return propertyRecords[0].isEdited ?? false\n }\n } catch (error) {\n // Ignore errors - use fallback value\n }\n\n return fallbackIsEdited\n }\n\n /**\n * Resolve refModelId from refModelName by querying the database\n * @param refModelName - The name of the referenced model\n * @returns The database ID of the referenced model, or undefined if not found\n */\n private async _resolveRefModelId(\n refModelName: string,\n property?: Static<typeof TProperty>,\n ): Promise<number | undefined> {\n if (!refModelName) {\n return undefined\n }\n\n try {\n const db = BaseDb.getAppDb()\n if (!db) {\n return undefined\n }\n\n // Resolve the ref within the owning model's schema\n const { resolveRefModelRecord } = await import('@/db/read/resolveModelRecord')\n const refModelRecord = await resolveRefModelRecord(\n refModelName,\n property ? this._ownerModelScope(property) : { schemaName: this._getSnapshotContext()._schemaName },\n db,\n )\n \n if (refModelRecord?.id) {\n return refModelRecord.id\n }\n } catch (error) {\n // Ignore errors - model might not exist yet or database not available\n logger(`Error resolving refModelId for model \"${refModelName}\":`, error)\n }\n\n return undefined\n }\n\n /** Which model this property belongs to: its models row id and/or schema. */\n private _ownerModelScope(property: Static<typeof TProperty>): { modelId?: number; schemaName?: string } {\n const context = this._getSnapshotContext() as { modelId?: number; _schemaName?: string }\n const modelId = (property as { modelId?: number }).modelId ?? context.modelId\n return {\n modelId: typeof modelId === 'number' ? modelId : undefined,\n schemaName: context._schemaName,\n }\n }\n\n /**\n * Get schema file values for this property to use as \"original\" values\n * This allows comparison with database values to detect edits\n */\n private async _getSchemaFileValues(\n property: Static<typeof TProperty>,\n ): Promise<Partial<Static<typeof TProperty>> | undefined> {\n if (!property.modelName || !property.name) {\n return undefined\n }\n\n try {\n const { modelId, schemaName } = this._ownerModelScope(property)\n // Synchronous cache hits first: callers compare against these values right after construction,\n // so an extra await here lets every property look \"edited\" (a draft save each). Only then the\n // DB (by modelId), and never instantiate a Model while its own properties are initializing.\n let model = schemaName ? Model.getByName(property.modelName, schemaName) : undefined\n if (!model) {\n try {\n model = Model.getByName(property.modelName)\n } catch {\n model = undefined // ambiguous name; resolve by modelId below\n }\n }\n if (!model && modelId) {\n const { resolveModelRecord } = await import('@/db/read/resolveModelRecord')\n const modelFileId = (await resolveModelRecord(property.modelName, { modelId }))?.schemaFileId\n model = modelFileId ? Model.getById(modelFileId) : undefined\n }\n // Evicted (with its schema) or unloaded while the lookups above ran: don't instantiate its model\n // again from rows that are being deleted.\n if (!model && isActorStopped(this._service)) return undefined\n if (!model) {\n try {\n // The epoch from when this instance was built: an eviction of the model's schema since\n // then (this instance may already be stopped) must not re-create the model.\n model = await Model.getByNameAsync(property.modelName, undefined, {\n evictionEpoch: this._evictionEpoch,\n })\n } catch {\n model = undefined\n }\n }\n \n if (!model || !model.properties || model.properties.length === 0) {\n return undefined\n }\n\n const schema = modelPropertiesToObject(model.properties)\n // Get the schema file value for this property\n const schemaFileValue = schema[property.name]\n if (!schemaFileValue) {\n return undefined\n }\n\n // Return schema file values as original values\n const originalValues: Partial<Static<typeof TProperty>> = {\n name: property.name,\n modelName: property.modelName,\n dataType: schemaFileValue.dataType,\n storageType: schemaFileValue.storageType,\n localStorageDir: schemaFileValue.localStorageDir,\n filenameSuffix: schemaFileValue.filenameSuffix,\n }\n\n // Handle ref fields\n if (schemaFileValue.ref) {\n originalValues.ref = schemaFileValue.ref\n originalValues.refModelName = schemaFileValue.ref\n // Try to get refModelId from database\n const refModelId = await this._resolveRefModelId(schemaFileValue.ref, property)\n if (refModelId) {\n originalValues.refModelId = refModelId\n }\n }\n\n if (schemaFileValue.refValueType) {\n originalValues.refValueType = schemaFileValue.refValueType\n }\n\n return originalValues\n } catch (error) {\n return undefined\n }\n }\n\n /**\n * Set the schema name for this property by looking it up from the model\n * Tries database first (more reliable), then falls back to schema files\n */\n private async _setSchemaName(property: Static<typeof TProperty>): Promise<void> {\n try {\n // create() sets the schema name right after construction when its caller knows it. Don't look it\n // up then: the file fallback below reads and parses every schema file, per property.\n await Promise.resolve()\n if (this._getSnapshotContext()._schemaName) return\n\n let schemaName: string | undefined\n // From the property data: the instance's own modelId field is never assigned (the reactive proxy\n // serves values from the machine context), so reading this.modelId skipped the DB lookup.\n const { modelId } = this._ownerModelScope(property)\n\n // Try to get schema name from database first (more reliable)\n if (modelId) {\n try {\n const db = BaseDb.getAppDb()\n if (db) {\n const modelSchemaRecords = await db\n .select({\n schemaName: schemas.name,\n })\n .from(modelSchemas)\n .innerJoin(schemas, eq(modelSchemas.schemaId, schemas.id))\n .innerJoin(modelsTable, eq(modelSchemas.modelId, modelsTable.id))\n .where(eq(modelsTable.id, modelId))\n .limit(1)\n\n if (modelSchemaRecords.length > 0) {\n schemaName = modelSchemaRecords[0].schemaName\n }\n }\n } catch (error) {\n // Database lookup failed, continue to file-based lookup\n }\n }\n\n // Fall back to schema file lookup if database didn't work\n if (!schemaName) {\n schemaName = await getSchemaNameFromModel(property.modelName!)\n }\n\n if (schemaName) {\n // Update the context with the schema name using dedicated event\n this._sendIfRunning({\n type: 'setSchemaName',\n schemaName,\n })\n }\n } catch (error) {\n // If we can't get schema name, that's okay - it will be set later if needed\n }\n }\n\n /**\n * Resolve schema name from DB when _schemaName is missing (e.g. destroy ran before _setSchemaName finished).\n * Uses context.id (schemaFileId) and context.modelId to query properties → model_schemas → schemas.\n */\n private async _resolveSchemaNameForDestroy(\n db: NonNullable<ReturnType<typeof BaseDb.getAppDb>>,\n context: ModelPropertyMachineContext,\n ): Promise<string | undefined> {\n try {\n let modelId = context.modelId\n const schemaFileId = context.id ?? context._propertyFileId\n\n // If we don't have modelId, get it from the property row by schemaFileId\n if (modelId == null && schemaFileId) {\n const propRows = await db\n .select({ modelId: propertiesTable.modelId })\n .from(propertiesTable)\n .where(eq(propertiesTable.schemaFileId, schemaFileId))\n .limit(1)\n if (propRows.length > 0 && propRows[0].modelId != null) {\n modelId = propRows[0].modelId\n }\n }\n\n if (modelId == null) return undefined\n\n // Resolve modelFileId (string) to database ID (number) if needed - modelSchemas.modelId expects number\n const modelIdNum: number =\n typeof modelId === 'string' ? await getModelIdByFileId(modelId) : modelId\n\n const modelSchemaRecords = await db\n .select({ schemaName: schemas.name })\n .from(modelSchemas)\n .innerJoin(schemas, eq(modelSchemas.schemaId, schemas.id))\n .where(eq(modelSchemas.modelId, modelIdNum))\n .limit(1)\n\n return modelSchemaRecords.length > 0 ? modelSchemaRecords[0].schemaName ?? undefined : undefined\n } catch {\n return undefined\n }\n }\n\n /**\n * Manually set the schema name for this property\n * Useful when you know the schema name from context (e.g., when working with Schema instances)\n */\n setSchemaName(schemaName: string): void {\n this._service.send({\n type: 'setSchemaName',\n schemaName,\n })\n }\n\n static create(\n property: Static<typeof TProperty>,\n options?: { waitForReady?: false; schemaName?: string },\n ): ModelProperty\n static create(\n property: Static<typeof TProperty>,\n options?: { waitForReady?: true; readyTimeout?: number; schemaName?: string },\n ): Promise<ModelProperty>\n static create(\n property: Static<typeof TProperty>,\n options?: CreateWaitOptions & { schemaName?: string },\n ): ModelProperty | Promise<ModelProperty> {\n if (!property) {\n throw new Error('Property is required')\n }\n\n const waitForReady = options?.waitForReady !== false\n const readyTimeout = options?.readyTimeout ?? 5000\n const schemaName = options?.schemaName\n\n // Handle 'type' field from JSON schema format - convert to 'dataType'\n // Normalize to PascalCase so lowercase values from JSON (e.g. 'text') work\n const propertyWithId = { ...property }\n const rawType = propertyWithId.dataType ?? (propertyWithId as any).type\n if (rawType) {\n propertyWithId.dataType = normalizeDataType(rawType) as ModelPropertyDataTypes\n }\n if (typeof propertyWithId.refValueType === 'string') {\n propertyWithId.refValueType = normalizeDataType(propertyWithId.refValueType) as ModelPropertyDataTypes\n }\n\n // Ensure id (schemaFileId) is set correctly\n // Priority: _propertyFileId > id (if string) > generate new\n // If id is a number (old format), use _propertyFileId instead\n if (typeof propertyWithId.id === 'number') {\n // id is a database integer ID, not schemaFileId - use _propertyFileId if available\n if ((propertyWithId as any)._propertyFileId) {\n propertyWithId.id = (propertyWithId as any)._propertyFileId\n } else {\n // Fallback: generate new schemaFileId (shouldn't happen, but safety)\n propertyWithId.id = generateId()\n logger(`ModelProperty.create: id was a number, generated new schemaFileId \"${propertyWithId.id}\" for property \"${property.name}\"`)\n }\n } else if (!propertyWithId.id && (propertyWithId as any)._propertyFileId) {\n // id is not set but _propertyFileId is available - use it\n propertyWithId.id = (propertyWithId as any)._propertyFileId\n } else if (!propertyWithId.id) {\n // Generate id (schemaFileId) if not provided (for new properties)\n // This ensures new properties can trigger write process\n propertyWithId.id = generateId()\n logger(`ModelProperty.create: Generated new id (schemaFileId) \"${propertyWithId.id}\" for property \"${property.name}\"`)\n }\n\n // Create cache key from modelName and name, or use id\n let cacheKey = propertyWithId.modelName && propertyWithId.name\n ? `${propertyWithId.modelName}:${propertyWithId.name}`\n : propertyWithId.id\n ? `id:${propertyWithId.id}`\n : propertyWithId.name || 'unnamed'\n\n // Model names are only unique per schema: a cached \"Post:title\" may be another schema's\n // property. If the ids say it's a different property, key this one by its own id instead.\n // (Not by file id: the same property is often created first with a generated id, then its real one.)\n const isOtherProperty = (cachedContext: ModelPropertyMachineContext): boolean =>\n (typeof propertyWithId.modelId === 'number' &&\n typeof cachedContext.modelId === 'number' &&\n cachedContext.modelId !== propertyWithId.modelId) ||\n (!!schemaName && !!cachedContext._schemaName && cachedContext._schemaName !== schemaName)\n const cachedByName = this.instanceCache.get(cacheKey)\n if (cachedByName && propertyWithId.id && isOtherProperty(cachedByName.instance._getSnapshotContext())) {\n // Reuse this property's own id-keyed entry if it already has one.\n cacheKey = `id:${propertyWithId.id}`\n for (const [key, { instance }] of this.instanceCache.entries()) {\n if (!key.startsWith('id:')) continue\n const ctx = instance._getSnapshotContext()\n if (ctx.modelName === propertyWithId.modelName && ctx.name === propertyWithId.name && !isOtherProperty(ctx)) {\n cacheKey = key\n break\n }\n }\n }\n\n // Check if instance exists in cache\n if (this.instanceCache.has(cacheKey)) {\n const { instance, refCount } = this.instanceCache.get(cacheKey)!\n const cachedContext = instance._getSnapshotContext()\n \n // Update cached instance if new property data has fields that the cached instance doesn't have\n // This handles cases where the property was created without ref initially, but now we have ref from schema\n const needsUpdate: any = {}\n if (propertyWithId.ref && !cachedContext.ref) {\n needsUpdate.ref = propertyWithId.ref\n }\n if (propertyWithId.refModelName && !cachedContext.refModelName) {\n needsUpdate.refModelName = propertyWithId.refModelName\n }\n if (propertyWithId.refModelId && !cachedContext.refModelId) {\n needsUpdate.refModelId = propertyWithId.refModelId\n }\n \n if (Object.keys(needsUpdate).length > 0) {\n instance._service.send({\n type: 'updateContext',\n ...needsUpdate,\n })\n }\n \n this.instanceCache.set(cacheKey, {\n instance,\n refCount: refCount + 1,\n })\n if (!waitForReady) return instance\n return waitForEntityIdle(instance, { timeout: readyTimeout }).then(\n () => instance,\n )\n }\n\n const newInstance = new this(propertyWithId)\n \n // Set schema name before async operations so getModelId can resolve the correct model\n if (schemaName) {\n newInstance._service.send({\n type: 'setSchemaName',\n schemaName,\n })\n }\n \n // Wrap instance in Proxy for reactive property access\n const proxiedInstance = createReactiveProxy<ModelProperty>({\n instance: newInstance,\n service: newInstance._service,\n trackedProperties: TPropertyKeys,\n getContext: (instance) => {\n const context = instance._getSnapshotContext()\n return context\n },\n sendUpdate: (instance, prop: string, value: any) => {\n const currentContext = instance._getSnapshotContext()\n if ((currentContext as Record<string, unknown>)[prop] === value) return // No-op, avoid triggering machine\n instance._service.send({\n type: 'updateContext',\n [prop]: value,\n })\n },\n })\n \n this.instanceCache.set(cacheKey, {\n instance: proxiedInstance,\n refCount: 1,\n })\n this.indexCachedInstance(cacheKey, proxiedInstance)\n\n // Trigger write process if property has modelId (or modelName) and id (schemaFileId)\n // Wait for service to be ready (idle state) and have writeProcess spawned\n const propertyFileId = propertyWithId.id // id is now the schemaFileId (string)\n const hasModelId = propertyWithId.modelId || propertyWithId.modelName\n // A _dbId means the data was loaded from an existing row (createById, getPropertySchema), so\n // there's nothing to write. Writing it back anyway raced deletes of that row's model (FK error).\n const isPersisted = typeof (propertyWithId as { _dbId?: unknown })._dbId === 'number'\n\n if (hasModelId && propertyFileId && !isPersisted) {\n // Wait for writeProcess to be spawned (it's spawned in idle state entry action)\n // Retry a few times if writeProcess isn't available yet\n let retries = 0\n const maxRetries = 10\n const checkAndSend = async () => {\n const service = proxiedInstance.getService()\n const snapshot = service.getSnapshot()\n // Unloaded or evicted (e.g. Schema.destroy) before the write started: nothing to write to\n if (isActorStopped(service)) return\n \n if (snapshot.value === 'idle' && snapshot.context.writeProcess) {\n const writeProcess = snapshot.context.writeProcess\n \n // Resolve dbModelId - convert from string (modelFileId) to number (database ID) if needed\n let resolvedModelId: number | undefined = undefined\n \n if (propertyWithId.modelId) {\n if (typeof propertyWithId.modelId === 'number') {\n resolvedModelId = propertyWithId.modelId\n } else if (typeof propertyWithId.modelId === 'string') {\n // modelId is a string (modelFileId), need to convert to database ID\n try {\n resolvedModelId = await getModelIdByFileId(propertyWithId.modelId)\n logger(`Converted modelFileId \"${propertyWithId.modelId}\" to database modelId: ${resolvedModelId}`)\n } catch (error) {\n logger(`Failed to convert modelFileId \"${propertyWithId.modelId}\" to database ID: ${error}`)\n console.error(`[ModelProperty.create] Failed to convert modelFileId: ${error}`)\n }\n }\n }\n \n // If we still don't have a modelId, try to resolve it from modelName\n if (!resolvedModelId && propertyWithId.modelName) {\n try {\n // Get schemaName from context if available\n const schemaName = snapshot.context._schemaName\n resolvedModelId = await getModelId(propertyWithId.modelName, schemaName)\n logger(`Resolved modelId for model \"${propertyWithId.modelName}\": ${resolvedModelId}`)\n } catch (error) {\n logger(`Failed to resolve modelId for model \"${propertyWithId.modelName}\": ${error}`)\n console.error(`[ModelProperty.create] Failed to resolve modelId: ${error}`)\n }\n }\n \n if (!resolvedModelId) {\n logger(`ERROR: Cannot write property \"${property.name}\" - no modelId available`)\n console.error(`[ModelProperty.create] ERROR: Cannot write property \"${property.name}\" - no modelId available. modelId: ${propertyWithId.modelId}, modelName: ${propertyWithId.modelName}`)\n // Don't clear pending write here - it might resolve later\n return\n }\n\n // Resolving the modelId awaited the DB; the instance may have been stopped meanwhile\n if (isActorStopped(service)) return\n \n // Track pending write now that we have the resolved modelId\n this.trackPendingWrite(propertyFileId, resolvedModelId)\n \n logger(`Triggering write process for property \"${property.name}\" (modelId: ${resolvedModelId}, propertyFileId: ${propertyFileId})`)\n \n // Check current write state\n const currentWriteState = writeProcess.getSnapshot()\n \n if (currentWriteState.value === 'success') {\n // Write already succeeded\n void this.completePendingWrite(propertyFileId, resolvedModelId)\n } else {\n // Set up subscription to catch future state changes\n const writeSubscription = writeProcess.subscribe((writeSnapshot) => {\n if (writeSnapshot.value === 'success') {\n writeSubscription.unsubscribe()\n logger(`[writeProcess subscription] Write succeeded for property \"${property.name}\" (propertyFileId: ${propertyFileId})`)\n void this.completePendingWrite(propertyFileId, resolvedModelId)\n } else if (writeSnapshot.value === 'error') {\n writeSubscription.unsubscribe()\n const errorContext = writeSnapshot.context\n logger(`Write process failed for property \"${property.name}\" (propertyFileId: ${propertyFileId}): ${errorContext.error?.message || 'Unknown error'}`)\n logger(`Write process error details:`, errorContext.error)\n // Mark pending write as error\n this.clearPendingWrite(propertyFileId, 'error')\n }\n })\n }\n \n const propertyData = {\n modelId: resolvedModelId,\n name: property.name!,\n dataType: property.dataType!,\n refModelId: property.refModelId,\n refValueType: property.refValueType,\n required: property.required,\n storageType: property.storageType,\n localStorageDir: property.localStorageDir,\n filenameSuffix: property.filenameSuffix,\n }\n \n service.send({\n type: 'requestWrite',\n data: propertyData,\n })\n } else if (retries < maxRetries) {\n retries++\n setTimeout(checkAndSend, 50) // Retry after 50ms\n } else {\n logger(`ERROR: writeProcess not available after ${maxRetries} retries for property \"${property.name}\" (propertyFileId: ${propertyFileId})`)\n console.error(`[ModelProperty.create] ERROR: writeProcess not available after ${maxRetries} retries for property \"${property.name}\" (propertyFileId: ${propertyFileId})`)\n // Mark as error if we couldn't even start the write process\n this.clearPendingWrite(propertyFileId, 'error')\n }\n }\n \n // Start checking after a short delay to allow state machine to initialize\n setTimeout(checkAndSend, 0)\n }\n \n if (!waitForReady) return proxiedInstance\n return waitForEntityIdle(proxiedInstance, { timeout: readyTimeout }).then(\n () => proxiedInstance,\n )\n }\n\n /** Whether an idIndex entry still points at a cached instance with that id. */\n private static isIndexEntryCurrent(\n propertyFileId: string,\n entry: { cacheKey: string; instance: ModelProperty },\n ): boolean {\n if (this.instanceCache.get(entry.cacheKey)?.instance !== entry.instance) return false\n try {\n return entry.instance._getSnapshotContext().id === propertyFileId\n } catch {\n return false\n }\n }\n\n /** Add a newly cached instance to idIndex, and keep its entry current when its id changes. */\n private static indexCachedInstance(cacheKey: string, instance: ModelProperty): void {\n const index = (id: string | undefined) => {\n if (!id) return\n const existing = this.idIndex.get(id)\n // Keep the instance cached first, as the old scan in insertion order returned\n if (existing && existing.instance !== instance && this.isIndexEntryCurrent(id, existing)) return\n this.idIndex.set(id, { cacheKey, instance })\n }\n let indexedId = instance._getSnapshotContext().id\n index(indexedId)\n instance._service.subscribe((snapshot) => {\n const id = snapshot.context.id\n if (id === indexedId) return\n indexedId = id\n index(id)\n })\n }\n\n /**\n * Get ModelProperty instance by propertyFileId from static cache\n */\n static getById(propertyFileId: string): ModelProperty | undefined {\n if (!propertyFileId) return undefined\n\n const indexed = this.idIndex.get(propertyFileId)\n if (!indexed) return undefined\n if (this.isIndexEntryCurrent(propertyFileId, indexed)) return indexed.instance\n\n // The indexed instance left the cache or changed id; another cached instance may still have it.\n // Cache key might be \"modelName:propertyName\" or \"id:propertyId\"\n this.idIndex.delete(propertyFileId)\n for (const [cacheKey, { instance }] of this.instanceCache.entries()) {\n // id is now the schemaFileId (string)\n if (instance._getSnapshotContext().id === propertyFileId) {\n this.idIndex.set(propertyFileId, { cacheKey, instance })\n return instance\n }\n }\n\n return undefined\n }\n\n /**\n * Create or get ModelProperty instance by propertyFileId\n * Queries the database to find the property if not cached\n */\n static async createById(\n propertyFileId: string,\n options?: {\n /**\n * currentEvictionEpoch() from when the caller's work started. An eviction of the property's\n * schema since then makes this return undefined instead of re-creating it. Defaults to now.\n */\n evictionEpoch?: number\n },\n ): Promise<ModelProperty | undefined> {\n if (!propertyFileId) {\n return undefined\n }\n\n // First, check if we have an instance cached\n const cachedInstance = this.getById(propertyFileId)\n if (cachedInstance) {\n return cachedInstance\n }\n\n // Query database to get property data from ID\n const db = BaseDb.getAppDb()\n if (!db) {\n return undefined\n }\n const evictionEpoch = options?.evictionEpoch ?? currentEvictionEpoch()\n\n const propertyRecords = await db\n .select()\n .from(propertiesTable)\n .where(eq(propertiesTable.schemaFileId, propertyFileId))\n .limit(1)\n\n if (propertyRecords.length === 0) {\n return undefined\n }\n\n const propertyRecord = propertyRecords[0]\n\n // Get model name\n const modelRecords = await db\n .select({ name: modelsTable.name })\n .from(modelsTable)\n .where(eq(modelsTable.id, propertyRecord.modelId))\n .limit(1)\n\n if (modelRecords.length === 0) {\n return undefined\n }\n\n const modelName = modelRecords[0].name\n\n // Build property data\n // id is now the schemaFileId (string), _dbId is the database integer ID\n const propertyData: Static<typeof TProperty> = {\n id: propertyFileId, // schemaFileId (string) - public ID\n _dbId: propertyRecord.id ?? undefined, // Database integer ID - internal only\n name: propertyRecord.name,\n dataType: propertyRecord.dataType as ModelPropertyDataTypes,\n modelId: propertyRecord.modelId,\n modelName,\n refModelId: propertyRecord.refModelId || undefined,\n refValueType: propertyRecord.refValueType ? (propertyRecord.refValueType as ModelPropertyDataTypes) : undefined,\n required: propertyRecord.required ?? false,\n storageType: (propertyRecord.storageType as StorageType | null) ?? undefined,\n localStorageDir: propertyRecord.localStorageDir ?? undefined,\n filenameSuffix: propertyRecord.filenameSuffix ?? undefined,\n }\n\n // Load isEdited from database\n const isEditedFromDb = propertyRecord.isEdited ?? false\n\n // Get ref model name if applicable\n if (propertyRecord.refModelId) {\n const refModelRecords = await db\n .select({ name: modelsTable.name })\n .from(modelsTable)\n .where(eq(modelsTable.id, propertyRecord.refModelId))\n .limit(1)\n\n if (refModelRecords.length > 0) {\n propertyData.refModelName = refModelRecords[0].name\n propertyData.ref = refModelRecords[0].name\n }\n }\n\n // Its model's schema was evicted while we read the rows (e.g. a model's property lookup in flight\n // during Schema.destroy or test cleanup): don't bring the property back.\n if (anyEvictionSince(evictionEpoch)) {\n const schemaRows = await db\n .select({ name: schemas.name })\n .from(modelSchemas)\n .innerJoin(schemas, eq(schemas.id, modelSchemas.schemaId))\n .where(eq(modelSchemas.modelId, propertyRecord.modelId))\n if (\n schemaRows.length === 0 ||\n schemaRows.some((row: { name: string | null }) => schemaEvictedSince(row.name, evictionEpoch))\n ) {\n return undefined\n }\n }\n\n // Create ModelProperty instance (sync for createById so we can send updateContext)\n const instance = this.create(propertyData, { waitForReady: false })\n \n // Set isEdited from database after creation\n if (isEditedFromDb) {\n instance._service.send({\n type: 'updateContext',\n _isEdited: true,\n })\n }\n \n return instance\n }\n\n /**\n * Find ModelProperty instance by propertyFileId\n * Waits for the property to be fully loaded (idle state) by default\n * @param options - Find options including propertyFileId and wait configuration\n * @returns ModelProperty instance if found, undefined otherwise\n */\n static async find({\n propertyFileId,\n waitForReady = true,\n readyTimeout = 5000,\n }: {\n propertyFileId: string\n waitForReady?: boolean\n readyTimeout?: number\n }): Promise<ModelProperty | undefined> {\n if (!propertyFileId) {\n return undefined\n }\n\n return await findEntity<ModelProperty>(\n {\n getById: (id) => ModelProperty.getById(id),\n createById: (id) => ModelProperty.createById(id),\n },\n { id: propertyFileId },\n {\n waitForReady,\n readyTimeout,\n }\n )\n }\n\n /**\n * Get all ModelProperty instances for a model.\n * Loads property rows from DB for the given modelFileId, creates instances via createById, optionally waits for idle.\n */\n static async all(\n modelFileId: string,\n options?: { waitForReady?: boolean; readyTimeout?: number },\n ): Promise<ModelProperty[]> {\n const { waitForReady = false, readyTimeout = 5000 } = options ?? {}\n if (!modelFileId) {\n return []\n }\n\n const rows = await getModelPropertiesData(modelFileId)\n const instances: ModelProperty[] = []\n\n for (const row of rows) {\n if (row.schemaFileId) {\n const instance = await this.createById(row.schemaFileId)\n if (instance) {\n instances.push(instance)\n }\n }\n }\n\n if (waitForReady && instances.length > 0) {\n await Promise.all(\n instances.map((p) =>\n waitForEntityIdle(p as Parameters<typeof waitForEntityIdle>[0], {\n timeout: readyTimeout,\n }),\n ),\n )\n }\n\n return instances\n }\n\n /**\n * Track a pending write for a property\n */\n static trackPendingWrite(propertyFileId: string, modelId: number): void {\n this.pendingWrites.set(propertyFileId, {\n propertyFileId,\n modelId,\n status: 'pending',\n timestamp: Date.now(),\n })\n }\n\n /**\n * A property write succeeded: add the property to its model's property ids, then drop the pending\n * write. In that order, `Model.properties` (property ids + pending writes) never misses it; in Node,\n * where the Model has no reactive liveQuery, nothing else would add it.\n */\n private static async completePendingWrite(propertyFileId: string, modelId: number): Promise<void> {\n try {\n await Model.refreshPropertiesForDbId(modelId)\n } catch (error) {\n logger(`Refreshing properties of model ${modelId} after writing \"${propertyFileId}\" failed: ${error}`)\n }\n this.clearPendingWrite(propertyFileId, 'success')\n }\n\n /**\n * Clear or update pending write status\n */\n static clearPendingWrite(propertyFileId: string, status: 'success' | 'error' = 'success'): void {\n const write = this.pendingWrites.get(propertyFileId)\n if (write) {\n if (status === 'success') {\n // Remove successful writes from pendingWrites\n this.pendingWrites.delete(propertyFileId)\n logger(`Cleared pending write for property \"${propertyFileId}\" (status: success)`)\n } else {\n // Update status to error but keep in map (for debugging/retry purposes)\n write.status = 'error'\n this.pendingWrites.set(propertyFileId, write)\n logger(`Marked pending write as error for property \"${propertyFileId}\"`)\n }\n }\n }\n\n /**\n * Get all pending property IDs for a model\n */\n static getPendingPropertyIds(modelId: number): string[] {\n return Array.from(this.pendingWrites.entries())\n .filter(([_, write]) => write.modelId === modelId && write.status !== 'error')\n .map(([propertyFileId]) => propertyFileId)\n }\n\n /**\n * Get modelId for a property that has a pending write (row may not be in DB yet).\n * Used to resolve modelName when validating a just-created property rename.\n */\n static getPendingModelId(propertyFileId: string): number | undefined {\n return this.pendingWrites.get(propertyFileId)?.modelId\n }\n\n getService(): ModelPropertyService {\n return this._service\n }\n\n private _getSnapshot(): ModelPropertySnapshot {\n return this._service.getSnapshot() as ModelPropertySnapshot\n }\n\n public _getSnapshotContext(): ModelPropertyMachineContext {\n return this._getSnapshot().context\n }\n\n get path() {\n const workingDir = BaseFileManager.getWorkingDir()\n if (!this.localStorageDir || !this.name || !this.filenameSuffix) {\n return undefined\n }\n return `${workingDir}/${this.localStorageDir}/${this.name}${this.filenameSuffix || ''}`\n }\n\n get status() {\n return this._getSnapshot().value\n }\n\n get isEdited() {\n const context = this._getSnapshotContext()\n // First check in-memory state\n if (context._isEdited !== undefined) {\n return context._isEdited\n }\n // Fall back to reading from database if we have _dbId\n if (context._dbId) {\n // Load from database asynchronously (fire-and-forget for now)\n // For synchronous getter, we'll need to cache it or make it async\n // For now, return false if not in context\n return false\n }\n return false\n }\n\n get validationErrors() {\n return this._getSnapshotContext()._validationErrors || []\n }\n\n get isValid() {\n const errors = this.validationErrors\n return errors.length === 0\n }\n\n /**\n * Validate the property\n * @returns Validation result\n */\n async validate(): Promise<{ isValid: boolean; errors: any[] }> {\n return new Promise((resolve) => {\n let resolved = false\n const subscription = this._service.subscribe((snapshot) => {\n const state = snapshot.value\n // Wait for validation to complete (idle state after validating)\n if (state === 'idle' && !resolved) {\n resolved = true\n subscription.unsubscribe()\n const errors = snapshot.context._validationErrors || []\n resolve({\n isValid: errors.length === 0,\n errors,\n })\n }\n })\n\n this._service.send({ type: 'validateProperty' })\n \n // Timeout fallback\n setTimeout(() => {\n if (!resolved) {\n resolved = true\n subscription.unsubscribe()\n const errors = this._getSnapshotContext()._validationErrors || []\n resolve({\n isValid: errors.length === 0,\n errors,\n })\n }\n }, 5000)\n })\n }\n\n save(): void {\n const snapshot = this._service.getSnapshot()\n const isAlreadySaving =\n typeof snapshot.value === 'object' && snapshot.value !== null && 'saveToSchema' in snapshot.value\n if (isAlreadySaving) {\n return\n }\n const context = snapshot.context\n if (!context._isEdited) return // No changes to persist\n // Validation will happen automatically in the machine before saving\n this._service.send({\n type: 'saveToSchema',\n })\n }\n\n /**\n * Reload property from database\n * This refreshes the actor context with the latest data from the database\n * Note: ModelProperty doesn't have a dedicated load actor, so this will\n * re-initialize from the current property data\n */\n async reload(): Promise<void> {\n // ModelProperty doesn't have a separate load mechanism\n // It's loaded as part of the Model/Schema\n // This method is provided for API consistency\n // To actually reload, you'd need to reload the parent Model or Schema\n logger('ModelProperty.reload() called - ModelProperty is loaded as part of Model/Schema. Reload the parent Model or Schema instead.')\n // No-op for now, but could be enhanced to reload from DB if needed\n }\n\n /**\n * Force-evict cached ModelProperty instances for the given models, ignoring refCounts, and stop\n * their services. Used by Schema.destroy() so a re-imported schema gets fresh instances instead of\n * ones holding a deleted row's _dbId.\n */\n static evictForModels(modelNames: string[], schemaName?: string): void {\n if (modelNames.length === 0) return\n const names = new Set(modelNames)\n for (const [cacheKey, { instance }] of this.instanceCache.entries()) {\n let context: ModelPropertyMachineContext\n try {\n context = instance._getSnapshotContext()\n } catch {\n continue\n }\n if (!context.modelName || !names.has(context.modelName)) continue\n if (schemaName && context._schemaName && context._schemaName !== schemaName) continue\n\n this.instanceCache.delete(cacheKey)\n try {\n instance._service.stop()\n } catch {\n // Service might already be stopped\n }\n }\n }\n\n unload(): void {\n // ModelProperty doesn't have liveQuery subscriptions or complex cache management\n // Just stop the service\n try {\n this._service.stop()\n } catch (error) {\n // Service might already be stopped\n }\n }\n\n /**\n * Destroy the model property: remove from caches, delete from database, update Schema context, stop service.\n */\n async destroy(): Promise<void> {\n const context = this._getSnapshotContext()\n // Stored under \"modelName:name\", or \"id:<id>\" when another schema's same-name property holds that key\n const cacheKeys = [...ModelProperty.instanceCache.entries()]\n .filter(([, entry]) => {\n try {\n return entry.instance._getSnapshotContext().id === context.id\n } catch {\n return false\n }\n })\n .map(([key]) => key)\n if (cacheKeys.length === 0 && context.modelName && context.name) {\n cacheKeys.push(`${context.modelName}:${context.name}`)\n }\n if (cacheKeys.length === 0) return\n\n forceRemoveFromCaches(this, {\n getCacheKeys: () => cacheKeys,\n caches: [ModelProperty.instanceCache as Map<string, unknown>],\n })\n\n await runDestroyLifecycle(this, {\n getService: (instance) =>\n instance._service as { send: (ev: unknown) => void; stop: () => void },\n doDestroy: async () => {\n const db = BaseDb.getAppDb()\n let schemaName = context._schemaName\n const modelName = context.modelName\n const propertyName = context.name\n if (!modelName || !propertyName) return\n\n // Resolve schema name from DB when _schemaName is missing (e.g. destroy ran before _setSchemaName finished)\n if (!schemaName && db) {\n schemaName = await this._resolveSchemaNameForDestroy(db, context)\n }\n\n if (db && schemaName) {\n const propertyRecords = await db\n .select({ propertyId: propertiesTable.id })\n .from(propertiesTable)\n .innerJoin(modelsTable, eq(propertiesTable.modelId, modelsTable.id))\n .innerJoin(modelSchemas, eq(modelsTable.id, modelSchemas.modelId))\n .innerJoin(schemas, eq(modelSchemas.schemaId, schemas.id))\n .where(\n and(\n eq(schemas.name, schemaName),\n eq(modelsTable.name, modelName),\n eq(propertiesTable.name, propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length > 0 && propertyRecords[0].propertyId != null) {\n await db\n .delete(propertiesTable)\n .where(eq(propertiesTable.id, propertyRecords[0].propertyId))\n }\n }\n\n if (schemaName) {\n const schema = Schema.create(schemaName, { waitForReady: false }) as import('@/Schema/Schema').Schema\n const snapshot = schema.getService().getSnapshot()\n const schemaContext = snapshot.context\n if (schemaContext.models?.[modelName]?.properties?.[propertyName]) {\n const updatedModels = { ...schemaContext.models }\n const updatedProperties = { ...updatedModels[modelName].properties }\n delete updatedProperties[propertyName]\n updatedModels[modelName] = { ...updatedModels[modelName], properties: updatedProperties }\n schema.getService().send({ type: 'updateContext', models: updatedModels })\n schema.getService().send({ type: 'markAsDraft', propertyKey: `property:${modelName}:${propertyName}` })\n }\n }\n },\n })\n }\n}\n"],"names":["logger","fromCallback","isActorStopped","BaseDb","setup","writeProcessMachine","assign","modelsTable","eq","propertiesTable","currentEvictionEpoch","createActor","and","Model","modelPropertiesToObject","schemas","modelSchemas","getModelIdByFileId","normalizeDataType","generateId","waitForEntityIdle","createReactiveProxy","getModelId","anyEvictionSince","schemaEvictedSince","findEntity","BaseFileManager","forceRemoveFromCaches","runDestroyLifecycle","Schema"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAMA,QAAM,GAAG,KAAK,CAAC,2CAA2C,CAAC;AAEjE;;;;AAIG;AACI,eAAe,sBAAsB,CAAC,SAAiB,EAAA;;AAE5D,IAAA,MAAM,gBAAgB,GAAG,MAAM,oDAAO,qBAAyB,+CAAC;AAChE,IAAA,MAAM,EAAE,qBAAqB,EAAE,GAAG,gBAAgB;AAClD,IAAA,MAAM,aAAa,GAAG,MAAM,qBAAqB,EAAE;AAEnD,IAAA,KAAK,MAAM,MAAM,IAAI,aAAa,EAAE;AAClC,QAAA,IAAI;AACF,YAAA,MAAM,cAAc,GAAG,MAAM,oDAAO,qBAA8C,wDAAC;AACnF,YAAA,MAAM,EAAE,eAAe,EAAE,GAAG,cAAc;YAC1C,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC;YACvE,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAQ;YAE7C,IAAI,UAAU,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;gBACrD,OAAO,MAAM,CAAC,IAAI;YACpB;QACF;QAAE,OAAO,KAAK,EAAE;AACd,YAAAA,QAAM,CAAC,4BAA4B,EAAE,KAAK,CAAC;YAC3C;QACF;IACF;AAEA,IAAA,OAAO,SAAS;AAClB;AAEO,MAAM,YAAY,GAAGC,mBAAY,CAGtC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,KAAI;AAC3C,IAAA,MAAM,aAAa,GAAG,YAA0B;;AAE9C,QAAA,MAAM,oBAAoB,GAAG,MAAM,oDAAO,uCAA4D,KAAC;AACvG,QAAA,M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UAAU,EAAE;AACpE,wBAAA,OAAO,iBAAiB,CAAC,YAAY,CAAC;AACtC,wBAAA,aAAa,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,aAAa,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,iBAAiB,EAAE;AACzF,wBAAA,MAAM,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;wBAC1E,MAAM,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,SAAS,CAAA,CAAA,EAAI,YAAY,CAAA,CAAE,EAAE,CAAC;oBACzG;gBACF;YACF,CAAC;AACF,SAAA,CAAC;IACJ;;AAhyCiB,aAAA,CAAA,aAAa,GAG1B,IAAI,GAAG,EAAE;AAEb;;;;;;;AAOG;AACY,aAAA,CAAA,OAAO,GAAG,IAAI,GAAG,EAAyD;AAEzF;AACe,aAAA,CAAA,aAAa,GAAG,IAAI,GAAG,EAKlC;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"ModelProperty-B-cZm1yU.js","sources":["../../../src/ModelProperty/service/actors/saveToSchema.ts","../../../src/ModelProperty/service/actors/compareAndMarkDraft.ts","../../../src/ModelProperty/service/actors/validateProperty.ts","../../../src/ModelProperty/service/modelPropertyMachine.ts","../../../src/db/read/getModelPropertiesData.ts","../../../src/ModelProperty/ModelProperty.ts"],"sourcesContent":["import { EventObject, fromCallback } from 'xstate'\nimport { isActorStopped } from '@/helpers/entity/entityCommon'\nimport { FromCallbackInput } from '@/types'\nimport { ModelPropertyMachineContext } from '../modelPropertyMachine'\nimport debug from 'debug'\nconst logger = debug('seedSdk:modelProperty:actors:saveToSchema')\n\n/**\n * Get schema name from model\n * This function finds which schema contains the given model\n * Exported so it can be reused by ModelProperty for setting schema name\n */\nexport async function getSchemaNameFromModel(modelName: string): Promise<string | undefined> {\n // Get the latest schema files and find which one contains this model\n const schemaHelpersMod = await import('../../../helpers/schema')\n const { listLatestSchemaFiles } = schemaHelpersMod\n const latestSchemas = await listLatestSchemaFiles()\n\n for (const schema of latestSchemas) {\n try {\n const fileManagerMod = await import('../../../helpers/FileManager/BaseFileManager')\n const { BaseFileManager } = fileManagerMod\n const content = await BaseFileManager.readFileAsString(schema.filePath)\n const schemaFile = JSON.parse(content) as any\n\n if (schemaFile.models && schemaFile.models[modelName]) {\n return schema.name\n }\n } catch (error) {\n logger('Error reading schema file:', error)\n continue\n }\n }\n\n return undefined\n}\n\nexport const saveToSchema = fromCallback<\n EventObject,\n FromCallbackInput<ModelPropertyMachineContext>\n>(({ sendBack, input: { context }, self }) => {\n const _saveToSchema = async (): Promise<void> => {\n // Use dynamic import to break circular dependency\n const validationServiceMod = await import('../../../Schema/service/validation/SchemaValidationService')\n const { SchemaValidationService } = validationServiceMod\n const validationService = new SchemaValidationService()\n \n // Validate property structure before saving\n const validationResult = validationService.validatePropertyStructure(context)\n if (!validationResult.isValid) {\n throw new Error(`Property validation failed: ${validationResult.errors.map(e => e.message).join(', ')}`)\n }\n\n // Validate required fields\n if (!context.name) {\n throw new Error('Property name is required')\n }\n\n if (!context.dataType) {\n throw new Error('Data type is required')\n }\n\n if (!context.modelName) {\n throw new Error(`Model not found for modelId: ${context.modelId}`)\n }\n\n // Persist to database only - schema file is updated only when user calls Schema.saveNewVersion()\n const dbMod = await import('../../../helpers/db')\n const { savePropertyToDb } = dbMod\n await savePropertyToDb(context)\n\n // Mark schema as draft so user knows to save\n const schemaName = context._schemaName ?? (await getSchemaNameFromModel(context.modelName))\n if (schemaName) {\n const schemaMod = await import('../../../Schema/Schema')\n const { Schema } = schemaMod\n // Stopped meanwhile (unloaded, or evicted with its schema): don't load the schema again\n if (isActorStopped(self)) return\n const schema = Schema.create(schemaName, { waitForReady: false }) as import('@/Schema/Schema').Schema\n schema.getService().send({\n type: 'markAsDraft',\n propertyKey: `${context.modelName}:${context.name}`,\n })\n }\n\n logger(`Successfully saved property ${context.modelName}:${context.name} to database`)\n }\n\n _saveToSchema().then(() => {\n sendBack({ type: 'saveToSchemaSuccess' })\n }).catch((error) => {\n logger('Error saving to schema:', error)\n sendBack({ type: 'saveToSchemaError', error })\n })\n\n return () => {\n // Cleanup function (optional)\n }\n})\n","import { EventObject, fromCallback } from 'xstate'\nimport { isActorStopped } from '@/helpers/entity/entityCommon'\nimport { FromCallbackInput } from '@/types'\nimport { ModelPropertyMachineContext } from '../modelPropertyMachine'\n// Dynamic import to break circular dependency: helpers/db -> ModelProperty -> compareAndMarkDraft -> helpers/db\n// import { savePropertyToDb } from '@/helpers/db'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:modelProperty:actors:compareAndMarkDraft')\n\nexport const compareAndMarkDraft = fromCallback<\n EventObject,\n FromCallbackInput<ModelPropertyMachineContext>\n>(({ sendBack, input: { context }, self }) => {\n const _compareAndMarkDraft = async (): Promise<void> => {\n // Fill modelName/dataType from _originalValues when missing, then from DB by schemaFileId\n let fullContext = {\n ...context,\n modelName: context.modelName ?? (context._originalValues as any)?.modelName,\n dataType: context.dataType ?? (context._originalValues as any)?.dataType,\n }\n const schemaFileIdForResolve = fullContext._propertyFileId || (typeof fullContext.id === 'string' ? fullContext.id : undefined)\n if (schemaFileIdForResolve && (fullContext.modelName === undefined || fullContext.dataType === undefined)) {\n try {\n const dbMod = await import('../../../helpers/db')\n const { getPropertyModelNameAndDataType, getModelNameByModelId } = dbMod\n let fromDb: { modelName: string; dataType: string } | undefined\n for (let attempt = 0; attempt < 6; attempt++) {\n fromDb = await getPropertyModelNameAndDataType(schemaFileIdForResolve)\n if (fromDb) break\n if (attempt < 5) await new Promise((r) => setTimeout(r, 40))\n }\n if (fromDb) {\n fullContext = {\n ...fullContext,\n modelName: fullContext.modelName ?? fromDb.modelName,\n dataType: fullContext.dataType ?? fromDb.dataType,\n }\n }\n if (fullContext.modelName === undefined && schemaFileIdForResolve) {\n const mod = await import('../../../ModelProperty/ModelProperty')\n const ModelProperty = mod?.ModelProperty ?? (mod as { default?: unknown })?.default\n const pendingModelId = ModelProperty?.getPendingModelId?.(schemaFileIdForResolve)\n if (pendingModelId != null) {\n const modelName = await getModelNameByModelId(pendingModelId)\n if (modelName) {\n fullContext = { ...fullContext, modelName }\n }\n }\n }\n } catch {\n // ignore\n }\n }\n const schemaFileId = fullContext._propertyFileId || (typeof fullContext.id === 'string' ? fullContext.id : undefined)\n // If _originalValues is not set, we still need to save to database if the property exists\n // This handles the case where the name is changed before _originalValues is initialized\n if (!fullContext._originalValues) {\n logger('No original values to compare against')\n logger(`[compareAndMarkDraft] Context: modelName=${fullContext.modelName}, name=${fullContext.name}, id=${fullContext.id}, _propertyFileId=${fullContext._propertyFileId}`)\n\n // If we have a name and modelName, try to save to database anyway\n // This ensures name changes are persisted even if _originalValues isn't initialized yet\n // We need either schemaFileId (id or _propertyFileId) to find the property in the database\n if (fullContext.modelName && fullContext.name && schemaFileId) {\n logger(`[compareAndMarkDraft] _originalValues not set, but saving to database anyway for property ${context.modelName}:${context.name} (schemaFileId: ${schemaFileId})`)\n try {\n const dbMod = await import('../../../helpers/db')\n const { savePropertyToDb } = dbMod\n // Ensure _propertyFileId is set for savePropertyToDb to find the property\n const contextWithFileId = {\n ...fullContext,\n _propertyFileId: schemaFileId,\n }\n await savePropertyToDb(contextWithFileId)\n logger(`[compareAndMarkDraft] Successfully saved property ${fullContext.modelName}:${fullContext.name} to database (no _originalValues)`)\n } catch (error) {\n logger(`[compareAndMarkDraft] Error saving property to database (no _originalValues): ${error}`)\n // Don't throw - this is a best-effort save, but log the error for debugging\n console.error(`[compareAndMarkDraft] Failed to save property ${fullContext.modelName}:${fullContext.name}:`, error)\n }\n } else {\n logger(`[compareAndMarkDraft] Cannot save property ${fullContext.modelName}:${fullContext.name} - missing required fields (schemaFileId: ${schemaFileId})`)\n }\n return\n }\n\n logger(`[compareAndMarkDraft] Comparing: context.name=${fullContext.name}, _originalValues.name=${fullContext._originalValues?.name}`)\n\n // Compare current values with original\n // Only compare property fields, not internal fields\n const propertyFields = ['name', 'dataType', 'ref', 'refModelName', 'refModelId', 'refValueType', 'storageType', 'localStorageDir', 'filenameSuffix', 'modelName', 'modelId', 'required']\n const hasChanges = propertyFields.some(key => {\n const currentValue = (fullContext as any)[key]\n const originalValue = (fullContext._originalValues as any)?.[key]\n \n // Handle name changes specifically\n if (key === 'name') {\n const nameChanged = currentValue !== originalValue\n if (nameChanged) {\n logger(`[compareAndMarkDraft] Name change detected: \"${originalValue}\" -> \"${currentValue}\"`)\n }\n return nameChanged\n }\n \n // Handle ref fields - compare by name\n if (key === 'ref' || key === 'refModelName') {\n const currentRef = fullContext.refModelName || fullContext.ref\n const originalRef = fullContext._originalValues?.refModelName || fullContext._originalValues?.ref\n // Both undefined/null means no ref, so they're the same\n if (!currentRef && !originalRef) return false\n return currentRef !== originalRef\n }\n \n // For other fields, compare values (handling undefined/null)\n if (currentValue === undefined && originalValue === undefined) return false\n if (currentValue === null && originalValue === null) return false\n if (currentValue === undefined && originalValue === null) return false\n if (currentValue === null && originalValue === undefined) return false\n \n return currentValue !== originalValue\n })\n\n if (hasChanges) {\n logger(`Property ${fullContext.modelName}:${fullContext.name} has changes, marking as edited`)\n logger(`[compareAndMarkDraft] Context when saving: id=${fullContext.id}, _propertyFileId=${fullContext._propertyFileId}, name=${fullContext.name}, _originalValues.name=${fullContext._originalValues?.name}`)\n\n // Use dynamic import to break circular dependency\n const dbMod = await import('../../../helpers/db')\n const { savePropertyToDb } = dbMod\n // Save to database (but not JSON file) - always save to DB when there are changes\n try {\n await savePropertyToDb(fullContext)\n logger(`[compareAndMarkDraft] Successfully saved property ${fullContext.modelName}:${fullContext.name} to database`)\n } catch (error) {\n logger(`[compareAndMarkDraft] Error saving property to database: ${error}`)\n throw error\n }\n\n // Mark schema as draft if schema name is available\n if (fullContext._schemaName) {\n // Get the Schema instance and mark it as draft\n const schemaMod = await import('../../../Schema/Schema')\n const { Schema } = schemaMod\n // Stopped meanwhile (unloaded, or evicted with its schema): don't load the schema again\n if (isActorStopped(self)) return\n const schema = Schema.create(fullContext._schemaName, {\n waitForReady: false,\n }) as import('@/Schema/Schema').Schema\n\n // Send event to Schema machine to mark as draft\n schema.getService().send({\n type: 'markAsDraft',\n propertyKey: `${fullContext.modelName}:${fullContext.name}`,\n })\n }\n } else {\n // No changes - clear edited flag in database and context\n logger(`Property ${fullContext.modelName}:${fullContext.name} has no changes`)\n \n // Clear isEdited flag in database\n try {\n const seedSchemaMod = await import('../../../seedSchema')\n const { properties: propertiesTable, models: modelsTable } = seedSchemaMod\n const drizzleMod = await import('drizzle-orm')\n const { eq, and } = drizzleMod\n \n const db = BaseDb.getAppDb()\n if (db && fullContext.modelName && fullContext.name) {\n // Find this property's model (model names are only unique per schema)\n const { resolveModelRecord } = await import('../../../db/read/resolveModelRecord')\n const modelRecord = await resolveModelRecord(\n fullContext.modelName,\n {\n modelId: typeof fullContext.modelId === 'number' ? fullContext.modelId : undefined,\n schemaName: fullContext._schemaName,\n },\n db,\n )\n const modelRecords = modelRecord ? [modelRecord] : []\n \n if (modelRecords.length > 0) {\n // Find property by name and modelId\n const propertyRecords = await db\n .select({ id: propertiesTable.id })\n .from(propertiesTable)\n .where(\n and(\n eq(propertiesTable.name, fullContext.name),\n eq(propertiesTable.modelId, modelRecords[0].id)\n )\n )\n .limit(1)\n \n if (propertyRecords.length > 0) {\n // Clear isEdited flag in database\n await db\n .update(propertiesTable)\n .set({ isEdited: false })\n .where(eq(propertiesTable.id, propertyRecords[0].id!))\n logger(`Cleared isEdited flag in database for property ${fullContext.modelName}:${fullContext.name}`)\n }\n }\n }\n } catch (error) {\n logger(`Error clearing isEdited flag in database: ${error}`)\n }\n \n sendBack({\n type: 'clearEdited',\n })\n }\n }\n\n _compareAndMarkDraft().then(() => {\n sendBack({ type: 'compareAndMarkDraftSuccess' })\n }).catch((error) => {\n logger('Error comparing and marking draft:', error)\n sendBack({ type: 'compareAndMarkDraftError', error })\n })\n\n return () => {\n // Cleanup function (optional)\n }\n})\n","import { EventObject, fromCallback } from 'xstate'\nimport { isActorStopped } from '@/helpers/entity/entityCommon'\nimport { FromCallbackInput } from '@/types'\nimport { ModelPropertyMachineContext } from '../modelPropertyMachine'\n// Dynamic imports to break circular dependencies:\n// - schema/index -> ... -> validateProperty -> SchemaValidationService -> schema/index\n// - schema/Schema -> ... -> validateProperty -> Schema -> schema/Schema\n// import { SchemaValidationService } from '@/Schema/service/validation/SchemaValidationService'\n// import { Schema } from '@/Schema/Schema'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:modelProperty:actors:validateProperty')\n\nexport const validateProperty = fromCallback<\n EventObject,\n FromCallbackInput<ModelPropertyMachineContext>\n>(({ sendBack, input: { context }, self }) => {\n const _validateProperty = async (): Promise<void> => {\n // Use full context for validation: fill modelName/dataType from _originalValues when missing, then\n // from DB by schemaFileId (context.id) so just-created renames don't fail structure validation.\n let fullContext = {\n ...context,\n modelName: context.modelName ?? (context._originalValues as any)?.modelName,\n dataType: context.dataType ?? (context._originalValues as any)?.dataType,\n }\n const schemaFileId = typeof context.id === 'string' ? context.id : undefined\n if (schemaFileId && (fullContext.modelName === undefined || fullContext.dataType === undefined)) {\n // Brief wait so trackPendingWrite from ModelProperty.create() has time to run (it's in setTimeout(0))\n await new Promise((r) => setTimeout(r, 60))\n try {\n const dbMod = await import('../../../helpers/db')\n const { getPropertyModelNameAndDataType, getModelNameByModelId } = dbMod\n // Try pending write first (property row may not exist yet)\n if (fullContext.modelName === undefined && schemaFileId) {\n const mod = await import('../../../ModelProperty/ModelProperty')\n const ModelProperty = mod?.ModelProperty ?? (mod as { default?: unknown })?.default\n const pendingModelId = ModelProperty?.getPendingModelId?.(schemaFileId)\n if (pendingModelId != null) {\n const modelName = await getModelNameByModelId(pendingModelId)\n if (modelName) {\n fullContext = { ...fullContext, modelName }\n }\n }\n }\n // Then DB property lookup with retry (catches row after initial write)\n let fromDb: { modelName: string; dataType: string } | undefined\n for (let attempt = 0; attempt < 6; attempt++) {\n fromDb = await getPropertyModelNameAndDataType(schemaFileId)\n if (fromDb) break\n if (attempt < 5) await new Promise((r) => setTimeout(r, 40))\n }\n if (fromDb) {\n fullContext = {\n ...fullContext,\n modelName: fullContext.modelName ?? fromDb.modelName,\n dataType: fullContext.dataType ?? fromDb.dataType,\n }\n }\n // If still no modelName, try pending write again (may have been set during retries)\n if (fullContext.modelName === undefined && schemaFileId) {\n const mod = await import('../../../ModelProperty/ModelProperty')\n const ModelProperty = mod?.ModelProperty ?? (mod as { default?: unknown })?.default\n const pendingModelId = ModelProperty?.getPendingModelId?.(schemaFileId)\n if (pendingModelId != null) {\n const modelName = await getModelNameByModelId(pendingModelId)\n if (modelName) {\n fullContext = { ...fullContext, modelName }\n }\n }\n }\n } catch {\n // ignore\n }\n }\n // Last resort for structure validation: TProperty requires dataType; allow name+id to pass if we have schemaFileId\n if (fullContext.dataType === undefined && (fullContext.modelName !== undefined || schemaFileId)) {\n fullContext = { ...fullContext, dataType: (fullContext.dataType ?? (context._originalValues as any)?.dataType) || 'Text' }\n }\n // Use dynamic imports to break circular dependencies\n const validationServiceMod = await import('../../../Schema/service/validation/SchemaValidationService')\n const { SchemaValidationService } = validationServiceMod\n const validationService = new SchemaValidationService()\n const schemaMod = await import('../../../Schema/Schema')\n const { Schema } = schemaMod\n \n // Validate property structure\n const structureResult = validationService.validatePropertyStructure(fullContext)\n \n if (!structureResult.isValid) {\n sendBack({ type: 'validationError', errors: structureResult.errors })\n return\n }\n\n // If we have schema name and model name, validate against schema\n // Stopped meanwhile (unloaded, or evicted with its schema): don't load the schema again\n if (isActorStopped(self)) return\n if (fullContext._schemaName && fullContext.modelName) {\n try {\n const schema = Schema.create(fullContext._schemaName, {\n waitForReady: false,\n }) as import('@/Schema/Schema').Schema\n const schemaSnapshot = schema.getService().getSnapshot()\n const schemaStatus = schemaSnapshot.value\n \n // Only validate against schema if it's loaded (in idle state)\n // If still loading, skip schema validation and only do structure validation\n if (schemaStatus === 'idle') {\n const schemaContext = schemaSnapshot.context\n \n // Check if models are actually loaded\n if (schemaContext.models && Object.keys(schemaContext.models).length > 0) {\n // If property name has changed, validate against the original name (from schema file)\n // This handles the case where a property is renamed - the schema file still has the old name\n const propertyNameToValidate = fullContext._originalValues?.name && fullContext._originalValues.name !== fullContext.name\n ? fullContext._originalValues.name\n : fullContext.name || ''\n \n const schemaResult = validationService.validateProperty(\n schemaContext,\n fullContext.modelName,\n propertyNameToValidate,\n fullContext\n )\n \n if (!schemaResult.isValid) {\n // If property was renamed, some validation errors are expected (like property_not_found, missing_type)\n // Only fail if it's a critical error that's not related to the rename\n const isRenamed = fullContext._originalValues?.name && fullContext._originalValues.name !== fullContext.name\n const criticalErrors = schemaResult.errors.filter(err => {\n // Allow property_not_found and missing_type errors when property is renamed\n if (isRenamed && (err.code === 'property_not_found' || err.code === 'missing_type')) {\n return false // Not critical\n }\n // For non-renamed properties, only allow property_not_found if we're validating with the same name\n if (err.code === 'property_not_found' && propertyNameToValidate === fullContext.name) {\n return false // Not critical\n }\n return true // Critical error\n })\n \n if (criticalErrors.length > 0) {\n sendBack({ type: 'validationError', errors: criticalErrors })\n return\n }\n // Continue with validation - rename-related errors are acceptable\n }\n } else {\n logger('Schema models not loaded yet, skipping schema validation')\n // Continue with structure validation only\n }\n } else {\n logger(`Schema is in ${schemaStatus} state, skipping schema validation`)\n // Continue with structure validation only\n }\n } catch (error) {\n logger('Error validating property against schema:', error)\n // Continue with structure validation only\n }\n }\n\n // All validations passed\n sendBack({ type: 'validationSuccess', errors: [] })\n }\n\n _validateProperty().catch((error) => {\n logger('Error in validateProperty:', error)\n sendBack({\n type: 'validationError',\n errors: [{\n field: 'property',\n message: error instanceof Error ? error.message : 'Unknown validation error',\n code: 'validation_exception',\n severity: 'error' as const,\n }],\n })\n })\n\n return () => {\n // Cleanup function (optional)\n }\n})\n\n","import { assign, setup, ActorRefFrom } from 'xstate'\nimport { Static } from '@sinclair/typebox'\nimport { TProperty } from '@/Schema'\nimport { saveToSchema } from './actors/saveToSchema'\nimport { compareAndMarkDraft } from './actors/compareAndMarkDraft'\nimport { validateProperty } from './actors/validateProperty'\nimport { ValidationError } from '@/Schema/validation'\nimport { writeProcessMachine } from '@/services/write/writeProcessMachine'\n\nexport type ModelPropertyMachineContext = Static<typeof TProperty> & {\n // Store original values from the JSON schema file\n _originalValues?: Partial<Static<typeof TProperty>>\n // Track if this property has been edited\n _isEdited?: boolean\n // Reference to the Schema instance this property belongs to\n _schemaName?: string\n // Validation errors\n _validationErrors?: ValidationError[]\n writeProcess?: ActorRefFrom<typeof writeProcessMachine> | null\n // Property file ID (schemaFileId from JSON schema file) - used for lookups\n _propertyFileId?: string\n // Note: id field (from TProperty) is now the schemaFileId (string)\n // _dbId (from TProperty) stores the database integer ID\n // Destroy failure from the last destroy() (read by destroy hooks)\n _destroyError?: { message: string; name?: string } | null\n}\n\nexport const modelPropertyMachine = setup({\n types: {\n context: {} as ModelPropertyMachineContext,\n input: {} as ModelPropertyMachineContext,\n events: {} as\n | { type: 'updateContext'; [key: string]: any }\n | { type: 'initializeOriginalValues'; originalValues: Partial<Static<typeof TProperty>>; schemaName?: string; isEdited?: boolean }\n | { type: 'clearEdited' }\n | { type: 'setSchemaName'; schemaName: string }\n | { type: 'saveToSchema' }\n | { type: 'saveToSchemaSuccess' }\n | { type: 'saveToSchemaError'; error: Error }\n | { type: 'compareAndMarkDraftSuccess' }\n | { type: 'compareAndMarkDraftError' }\n | { type: 'validateProperty' }\n | { type: 'validationSuccess'; errors: ValidationError[] }\n | { type: 'validationError'; errors: ValidationError[] }\n | { type: 'requestWrite'; data: any }\n | { type: 'destroyStarted' }\n | { type: 'destroyError'; error: unknown },\n },\n actors: {\n saveToSchema,\n compareAndMarkDraft,\n validateProperty,\n writeProcessMachine,\n },\n guards: {\n isPropertyValid: ({ context }) => {\n const valid = !context._validationErrors || context._validationErrors.length === 0\n return valid\n },\n },\n actions: {\n assignValidationErrors: assign(({ context, event }) => {\n if (event.type === 'validationError') {\n return {\n ...context,\n _validationErrors: event.errors,\n }\n }\n return context\n }),\n },\n}).createMachine({\n id: 'modelProperty',\n initial: 'idle',\n context: ({ input }) => {\n const context = input as ModelPropertyMachineContext\n return context\n },\n on: {\n updateContext: {\n actions: assign(({ context, event }) => {\n const newContext = Object.assign({}, context) as any\n\n // Check if this is only updating internal fields\n const onlyInternalFields = Object.keys(event).every((key: string) => {\n return key === 'type' || key.startsWith('_')\n })\n \n // Update the context with new values\n for (let i = 0; i < Object.keys(event).length; i++) {\n const key = Object.keys(event)[i] as string\n if (key === 'type') {\n continue\n }\n let value = (event as any)[key]\n // Convert null to undefined for optional fields (TypeBox validation expects undefined, not null)\n // This is especially important for refValueType, refModelId, etc.\n if (value === null && (key === 'refValueType' || key === 'refModelId' || key === 'ref' || key === 'refModelName')) {\n value = undefined\n }\n newContext[key] = value\n }\n\n // Preserve modelName and dataType from context or _originalValues so validation and savePropertyToDb\n // never run with missing required/needed fields (e.g. when a just-created property is renamed before\n // the full context is available from the creator).\n if (newContext.modelName === undefined && (context._originalValues as any)?.modelName !== undefined) {\n newContext.modelName = (context._originalValues as any).modelName\n }\n if (newContext.dataType === undefined && (context._originalValues as any)?.dataType !== undefined) {\n newContext.dataType = (context._originalValues as any).dataType\n }\n\n // Compare with original values and set _isEdited flag (only for non-internal updates)\n if (!onlyInternalFields && context._originalValues) {\n const hasChanges = Object.keys(event).some((key: string) => {\n if (key === 'type' || key.startsWith('_')) return false\n return newContext[key] !== (context._originalValues as any)?.[key]\n })\n newContext._isEdited = hasChanges\n }\n\n // Clear validation errors on context update (will be re-validated if needed)\n newContext._validationErrors = undefined\n\n // Convert null to undefined for optional fields (TypeBox validation expects undefined, not null)\n // This is especially important for refValueType, refModelId, etc.\n const optionalFields = ['refValueType', 'refModelId', 'ref', 'refModelName']\n for (const field of optionalFields) {\n if (newContext[field] === null) {\n newContext[field] = undefined\n }\n }\n\n return newContext\n }),\n // Only trigger validation and compareAndMarkDraft if we're updating non-internal fields\n guard: ({ event }: { event: any }) => {\n const shouldTransition = !Object.keys(event).every((key: string) => {\n return key === 'type' || key.startsWith('_')\n })\n return shouldTransition\n },\n target: '.validating',\n },\n validateProperty: {\n target: '.validating',\n },\n validationSuccess: {\n actions: assign(({ context, event }) => ({\n ...context,\n _validationErrors: [],\n })),\n },\n validationError: {\n actions: 'assignValidationErrors',\n // Note: State-specific transitions are handled in child states\n // This root handler ensures errors are always assigned to context\n },\n initializeOriginalValues: {\n actions: assign(({ context, event }) => ({\n ...context,\n _originalValues: event.originalValues,\n // Senders don't know the schema name; keep one setSchemaName already stored.\n _schemaName: event.schemaName ?? context._schemaName,\n _isEdited: event.isEdited ?? false,\n _validationErrors: undefined,\n })),\n },\n clearEdited: {\n actions: assign(({ context }) => ({\n ...context,\n _isEdited: false,\n _originalValues: { ...context } as Partial<Static<typeof TProperty>>,\n })),\n },\n setSchemaName: {\n actions: assign(({ context, event }) => ({\n ...context,\n _schemaName: event.schemaName,\n })),\n },\n destroyStarted: {\n actions: assign({ _destroyError: null }),\n },\n destroyError: {\n actions: assign(({ event }) => ({\n _destroyError:\n event.error instanceof Error\n ? { message: event.error.message, name: event.error.name }\n : { message: String(event.error) },\n })),\n },\n },\n states: {\n idle: {\n on: {\n saveToSchema: { target: 'saveToSchema' },\n validateProperty: {\n target: 'validating',\n },\n requestWrite: {\n actions: ({ context, event }) => {\n if (context.writeProcess) {\n context.writeProcess.send({\n type: 'startWrite',\n data: event.data,\n })\n }\n },\n },\n },\n entry: assign({\n writeProcess: ({ spawn, context }) => {\n // Spawn writeProcess if we have id (schemaFileId)\n // New properties will have id generated\n const entityId = context.id\n if (!context.writeProcess && entityId) {\n return spawn(writeProcessMachine, {\n input: {\n entityType: 'modelProperty',\n entityId: String(entityId),\n entityData: context,\n },\n })\n }\n return context.writeProcess\n },\n }),\n },\n validating: {\n on: {\n saveToSchema: { target: 'saveToSchema' },\n validationSuccess: {\n target: 'compareAndMarkDraft',\n actions: assign(({ context }) => ({\n ...context,\n _validationErrors: [],\n })),\n },\n // validationError: Uses root handler for assignment, but needs state-specific transition\n validationError: {\n target: 'idle',\n actions: 'assignValidationErrors',\n },\n },\n invoke: {\n src: 'validateProperty',\n input: ({ context }) => ({ context }),\n },\n },\n compareAndMarkDraft: {\n on: {\n saveToSchema: { target: 'saveToSchema' },\n compareAndMarkDraftSuccess: {\n target: 'idle',\n },\n compareAndMarkDraftError: {\n target: 'idle',\n },\n },\n invoke: {\n src: 'compareAndMarkDraft',\n input: ({ context }) => ({ context }),\n },\n },\n saveToSchema: {\n // Gate the save in a transient child. An `always` on this parent targeting `.saving` re-enters\n // the invoking child on every microstep and never settles (save() ran the process out of memory).\n initial: 'checking',\n on: {\n // Apply updateContext but do not re-invoke saveToSchema actor (avoids infinite loop).\n // Context is updated; in-flight save completes with original context.\n updateContext: [\n {\n guard: ({ context, event }) => {\n const onlyInternal = Object.keys(event).every((k: string) => k === 'type' || k.startsWith('_'))\n return !onlyInternal && event.name !== undefined && event.name !== context.name\n },\n actions: assign(({ context, event }) => {\n const newContext = Object.assign({}, context) as any\n const onlyInternalFields = Object.keys(event).every((key: string) => key === 'type' || key.startsWith('_'))\n for (const key of Object.keys(event) as string[]) {\n if (key === 'type') continue\n let value = (event as any)[key]\n if (value === null && ['refValueType', 'refModelId', 'ref', 'refModelName'].includes(key)) value = undefined\n newContext[key] = value\n }\n if (newContext.modelName === undefined && (context._originalValues as any)?.modelName !== undefined) {\n newContext.modelName = (context._originalValues as any).modelName\n }\n if (newContext.dataType === undefined && (context._originalValues as any)?.dataType !== undefined) {\n newContext.dataType = (context._originalValues as any).dataType\n }\n if (!onlyInternalFields && context._originalValues) {\n const hasChanges = Object.keys(event).some((key: string) => {\n if (key === 'type' || key.startsWith('_')) return false\n return newContext[key] !== (context._originalValues as any)?.[key]\n })\n newContext._isEdited = hasChanges\n }\n newContext._validationErrors = undefined\n return newContext\n }),\n },\n {\n actions: assign(({ context, event }) => {\n const newContext = Object.assign({}, context) as any\n const onlyInternalFields = Object.keys(event).every((key: string) => key === 'type' || key.startsWith('_'))\n for (const key of Object.keys(event) as string[]) {\n if (key === 'type') continue\n let value = (event as any)[key]\n if (value === null && ['refValueType', 'refModelId', 'ref', 'refModelName'].includes(key)) value = undefined\n newContext[key] = value\n }\n if (newContext.modelName === undefined && (context._originalValues as any)?.modelName !== undefined) {\n newContext.modelName = (context._originalValues as any).modelName\n }\n if (newContext.dataType === undefined && (context._originalValues as any)?.dataType !== undefined) {\n newContext.dataType = (context._originalValues as any).dataType\n }\n if (!onlyInternalFields && context._originalValues) {\n const hasChanges = Object.keys(event).some((key: string) => {\n if (key === 'type' || key.startsWith('_')) return false\n return newContext[key] !== (context._originalValues as any)?.[key]\n })\n newContext._isEdited = hasChanges\n }\n newContext._validationErrors = undefined\n return newContext\n }),\n },\n ],\n // validationError: Uses root handler for assignment, but needs state-specific transition\n validationError: {\n target: 'idle',\n actions: 'assignValidationErrors',\n },\n },\n states: {\n checking: {\n always: [\n { guard: 'isPropertyValid', target: 'saving' },\n { target: '#modelProperty.idle' },\n ],\n },\n saving: {\n on: {\n saveToSchemaSuccess: {\n target: '#modelProperty.idle',\n },\n saveToSchemaError: {\n target: '#modelProperty.idle',\n },\n },\n invoke: {\n src: 'saveToSchema',\n input: ({ context }) => ({ context }),\n },\n },\n },\n },\n },\n})\n","import { models as modelsTable, properties as propertiesTable } from '@/seedSchema/ModelSchema'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { eq } from 'drizzle-orm'\n\nexport type ModelPropertyDataRow = {\n id: number\n name: string\n dataType: string\n modelId: number\n refModelId: number | null\n refValueType: string | null\n schemaFileId: string | null\n isEdited: number | null\n}\n\ntype GetModelPropertiesData = (\n modelFileId: string,\n) => Promise<ModelPropertyDataRow[]>\n\n/**\n * Returns property rows for a model identified by modelFileId (model's schemaFileId).\n * Resolves modelFileId -> modelId via models table, then selects all properties where modelId = ?.\n * Each row includes schemaFileId for use with ModelProperty.createById(schemaFileId).\n */\nexport const getModelPropertiesData: GetModelPropertiesData = async (\n modelFileId: string,\n): Promise<ModelPropertyDataRow[]> => {\n const appDb = BaseDb.getAppDb()\n if (!appDb || !modelFileId) {\n return []\n }\n\n const modelRows = await appDb\n .select({ id: modelsTable.id })\n .from(modelsTable)\n .where(eq(modelsTable.schemaFileId, modelFileId))\n .limit(1)\n\n if (modelRows.length === 0) {\n return []\n }\n\n const modelId = modelRows[0].id\n\n const rows = await appDb\n .select()\n .from(propertiesTable)\n .where(eq(propertiesTable.modelId, modelId))\n\n return rows as ModelPropertyDataRow[]\n}\n","import { ActorRefFrom, createActor, SnapshotFrom } from 'xstate'\nimport { Static } from '@sinclair/typebox'\nimport { ModelPropertyDataTypes, TProperty, normalizeDataType } from '@/Schema'\nimport { modelPropertyMachine, ModelPropertyMachineContext } from './service/modelPropertyMachine'\nimport { StorageType } from '@/types'\nimport type { CreateWaitOptions } from '@/types'\nimport { BaseFileManager, generateId } from '@/helpers'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { getModelPropertiesData } from '@/db/read/getModelPropertiesData'\nimport { getModelId, getModelIdByFileId } from '@/helpers/db'\nimport { modelPropertiesToObject } from '@/helpers/model'\nimport { Model } from '@/Model/Model'\nimport { Schema } from '@/Schema/Schema'\nimport { properties as propertiesTable, models as modelsTable } from '@/seedSchema/ModelSchema'\nimport { schemas } from '@/seedSchema/SchemaSchema'\nimport { getSchemaNameFromModel } from './service/actors/saveToSchema'\nimport { modelSchemas } from '@/seedSchema/ModelSchemaSchema'\nimport { and, eq } from 'drizzle-orm'\nimport { createReactiveProxy } from '@/helpers/reactiveProxy'\nimport { waitForEntityIdle } from '@/helpers/waitForEntityIdle'\nimport { findEntity } from '@/helpers/entity/entityFind'\nimport { unloadEntity } from '@/helpers/entity/entityUnload'\nimport { isActorStopped } from '@/helpers/entity/entityCommon'\nimport { anyEvictionSince, currentEvictionEpoch, schemaEvictedSince } from '@/helpers/entity/evictionEpoch'\nimport { forceRemoveFromCaches, runDestroyLifecycle } from '@/helpers/entity/entityDestroy'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:modelProperty:ModelProperty')\n\ntype ModelPropertyService = ActorRefFrom<typeof modelPropertyMachine>\ntype ModelPropertySnapshot = SnapshotFrom<typeof modelPropertyMachine>\n\n// Define the property keys from TProperty\nconst TPropertyKeys = [\n 'id',\n 'name',\n 'dataType',\n 'ref',\n 'modelId',\n 'refModelId',\n 'refValueType',\n 'storageType',\n 'localStorageDir',\n 'filenameSuffix',\n 'modelName',\n 'refModelName',\n] as const\n\nexport class ModelProperty {\n protected static instanceCache: Map<\n string,\n { instance: ModelProperty; refCount: number }\n > = new Map()\n\n /**\n * propertyFileId -> where the instance with that id is cached, so getById doesn't scan the cache\n * (a model's properties are looked up one by one, which made loading one model O(n²)).\n * Every cached instance's current id has an entry: it's added when the instance is cached and\n * again whenever its context id changes (a property is often created with a generated id and\n * then gets its real one). Entries aren't removed when an instance leaves the cache or changes\n * id; getById checks an entry before using it.\n */\n private static idIndex = new Map<string, { cacheKey: string; instance: ModelProperty }>()\n\n // Pending writes tracking\n private static pendingWrites = new Map<string, {\n propertyFileId: string\n modelId: number\n status: 'pending' | 'writing' | 'success' | 'error'\n timestamp: number\n }>()\n \n protected readonly _service: ModelPropertyService\n\n name?: string\n dataType?: ModelPropertyDataTypes\n ref?: string\n modelId?: number\n modelName?: string\n refModelId?: number\n refModelName?: string\n refValueType?: ModelPropertyDataTypes\n storageType?: StorageType\n localStorageDir?: string\n filenameSuffix?: string\n\n /** currentEvictionEpoch() at construction: lookups started for this instance don't outlive an eviction. */\n private readonly _evictionEpoch = currentEvictionEpoch()\n\n constructor(property: Static<typeof TProperty>) {\n // id is now the schemaFileId (string), _dbId is the database integer ID\n // Preserve _propertyFileId if it exists in the property object (from getPropertySchema)\n // Convert null to undefined for optional fields (TypeBox validation expects undefined, not null)\n const serviceInput: ModelPropertyMachineContext = {\n ...property,\n _propertyFileId: (property as any)._propertyFileId || property.id,\n refValueType: property.refValueType ?? undefined,\n refModelId: property.refModelId ?? undefined,\n ref: property.ref ?? undefined,\n refModelName: property.refModelName ?? undefined,\n }\n\n this._service = createActor(modelPropertyMachine, {\n input: serviceInput,\n })\n\n this._service.start()\n\n // Initialize original values from the input property\n this._initializeOriginalValues(property)\n\n // Note: Property getters/setters are now handled by the Proxy in create()\n }\n\n /**\n * Send from fire-and-forget async work (DB lookups started in the constructor), which can finish\n * after the instance was unloaded or evicted with its schema.\n */\n private _sendIfRunning(event: Parameters<ModelPropertyService['send']>[0]): void {\n if (isActorStopped(this._service)) return\n this._service.send(event)\n }\n\n /**\n * Initialize original values and schema name for tracking changes\n * This is called asynchronously after construction\n * If the property was loaded from the database and differs from the schema file,\n * it will be marked as edited.\n */\n private _initializeOriginalValues(property: Static<typeof TProperty>): void {\n // Resolve refModelId if ref/refModelName is provided but refModelId is missing\n const refModelName = property.refModelName || property.ref\n if (refModelName && !property.refModelId) {\n // Resolve refModelId asynchronously and update context\n this._resolveRefModelId(refModelName, property).then((refModelId) => {\n if (refModelId) {\n // Update the context with the resolved refModelId\n this._sendIfRunning({\n type: 'updateContext',\n refModelId,\n })\n }\n }).catch(() => {\n // Ignore errors - model might not exist yet\n })\n }\n\n // Get schema file values to use as \"original\" values\n // This allows us to detect if the property was edited (DB value differs from schema file)\n this._getSchemaFileValues(property).then((schemaFileValues) => {\n // Use schema file values as original (not the current property values)\n // This way, if current values differ from schema file, _isEdited will be true\n const originalValues: Partial<Static<typeof TProperty>> = schemaFileValues || {}\n \n // Compare current property values with schema file values to determine if edited\n // Only compare schema-relevant fields, not database-specific fields like id, modelId\n let isEdited = false\n if (schemaFileValues) {\n // Fields that are schema-relevant and should be compared\n const schemaRelevantFields: (keyof Static<typeof TProperty>)[] = [\n 'dataType',\n 'ref',\n 'refModelName',\n 'refValueType',\n 'storageType',\n 'localStorageDir',\n 'filenameSuffix',\n ]\n \n // Check if any schema-relevant field differs between current property and schema file\n isEdited = schemaRelevantFields.some((key) => {\n const currentValue = (property as any)[key]\n const originalValue = (schemaFileValues as any)[key]\n \n // Handle ref fields - compare by name\n if (key === 'ref' || key === 'refModelName') {\n const currentRef = property.refModelName || property.ref\n const originalRef = schemaFileValues.refModelName || schemaFileValues.ref\n // Both undefined/null means no ref, so they're the same\n if (!currentRef && !originalRef) return false\n return currentRef !== originalRef\n }\n \n // For other fields, compare values (handling undefined/null)\n if (currentValue === undefined && originalValue === undefined) return false\n if (currentValue === null && originalValue === null) return false\n if (currentValue === undefined && originalValue === null) return false\n if (currentValue === null && originalValue === undefined) return false\n \n return currentValue !== originalValue\n })\n } else {\n // No schema file values found - this is a runtime-created property\n // Use current property as original, but mark as edited since it hasn't been exported to file\n TPropertyKeys.forEach((key) => {\n if (property[key] !== undefined) {\n (originalValues as any)[key] = property[key]\n }\n })\n // For runtime-created properties, set isEdited = true initially\n isEdited = true\n }\n\n // Initialize with original values, including isEdited flag\n // Load isEdited from database if property exists in DB (async, fire-and-forget)\n this._loadIsEditedFromDb(property, isEdited).then((isEditedFromDb: boolean) => {\n this._sendIfRunning({\n type: 'initializeOriginalValues',\n originalValues,\n schemaName: undefined, // Will be set later if needed\n isEdited: isEditedFromDb,\n })\n }).catch(() => {\n // If we can't load from DB, use computed isEdited value\n this._sendIfRunning({\n type: 'initializeOriginalValues',\n originalValues,\n schemaName: undefined, // Will be set later if needed\n isEdited,\n })\n })\n }).catch(() => {\n // If we can't get schema file values, use current property as original\n const originalValues: Partial<Static<typeof TProperty>> = {}\n TPropertyKeys.forEach((key) => {\n if (property[key] !== undefined) {\n (originalValues as any)[key] = property[key]\n }\n })\n\n this._sendIfRunning({\n type: 'initializeOriginalValues',\n originalValues,\n schemaName: undefined,\n })\n })\n\n // Get schema name from model asynchronously (fire-and-forget)\n if (property.modelName) {\n this._setSchemaName(property).catch(() => {\n // If we can't get schema name, that's okay - it will be set later if needed\n })\n }\n }\n\n /**\n * Load isEdited flag from database if property exists in DB\n * @param property - The property data\n * @param fallbackIsEdited - Fallback value if property doesn't exist in DB\n * @returns The isEdited flag from database or fallback value\n */\n private async _loadIsEditedFromDb(\n property: Static<typeof TProperty>,\n fallbackIsEdited: boolean,\n ): Promise<boolean> {\n if (!property.modelName || !property.name) {\n return fallbackIsEdited\n }\n\n try {\n const db = BaseDb.getAppDb()\n if (!db) {\n return fallbackIsEdited\n }\n\n // Find this property's model (by modelId when known; model names are only unique per schema)\n const { resolveModelRecord } = await import('@/db/read/resolveModelRecord')\n const modelRecord = await resolveModelRecord(property.modelName, this._ownerModelScope(property), db)\n const modelRecords = modelRecord ? [modelRecord] : []\n \n if (modelRecords.length === 0) {\n return fallbackIsEdited\n }\n\n // Find property by name and modelId\n const propertyRecords = await db\n .select({ isEdited: propertiesTable.isEdited })\n .from(propertiesTable)\n .where(\n and(\n eq(propertiesTable.name, property.name),\n eq(propertiesTable.modelId, modelRecords[0].id)\n )\n )\n .limit(1)\n \n if (propertyRecords.length > 0) {\n return propertyRecords[0].isEdited ?? false\n }\n } catch (error) {\n // Ignore errors - use fallback value\n }\n\n return fallbackIsEdited\n }\n\n /**\n * Resolve refModelId from refModelName by querying the database\n * @param refModelName - The name of the referenced model\n * @returns The database ID of the referenced model, or undefined if not found\n */\n private async _resolveRefModelId(\n refModelName: string,\n property?: Static<typeof TProperty>,\n ): Promise<number | undefined> {\n if (!refModelName) {\n return undefined\n }\n\n try {\n const db = BaseDb.getAppDb()\n if (!db) {\n return undefined\n }\n\n // Resolve the ref within the owning model's schema\n const { resolveRefModelRecord } = await import('@/db/read/resolveModelRecord')\n const refModelRecord = await resolveRefModelRecord(\n refModelName,\n property ? this._ownerModelScope(property) : { schemaName: this._getSnapshotContext()._schemaName },\n db,\n )\n \n if (refModelRecord?.id) {\n return refModelRecord.id\n }\n } catch (error) {\n // Ignore errors - model might not exist yet or database not available\n logger(`Error resolving refModelId for model \"${refModelName}\":`, error)\n }\n\n return undefined\n }\n\n /** Which model this property belongs to: its models row id and/or schema. */\n private _ownerModelScope(property: Static<typeof TProperty>): { modelId?: number; schemaName?: string } {\n const context = this._getSnapshotContext() as { modelId?: number; _schemaName?: string }\n const modelId = (property as { modelId?: number }).modelId ?? context.modelId\n return {\n modelId: typeof modelId === 'number' ? modelId : undefined,\n schemaName: context._schemaName,\n }\n }\n\n /**\n * Get schema file values for this property to use as \"original\" values\n * This allows comparison with database values to detect edits\n */\n private async _getSchemaFileValues(\n property: Static<typeof TProperty>,\n ): Promise<Partial<Static<typeof TProperty>> | undefined> {\n if (!property.modelName || !property.name) {\n return undefined\n }\n\n try {\n const { modelId, schemaName } = this._ownerModelScope(property)\n // Synchronous cache hits first: callers compare against these values right after construction,\n // so an extra await here lets every property look \"edited\" (a draft save each). Only then the\n // DB (by modelId), and never instantiate a Model while its own properties are initializing.\n let model = schemaName ? Model.getByName(property.modelName, schemaName) : undefined\n if (!model) {\n try {\n model = Model.getByName(property.modelName)\n } catch {\n model = undefined // ambiguous name; resolve by modelId below\n }\n }\n if (!model && modelId) {\n const { resolveModelRecord } = await import('@/db/read/resolveModelRecord')\n const modelFileId = (await resolveModelRecord(property.modelName, { modelId }))?.schemaFileId\n model = modelFileId ? Model.getById(modelFileId) : undefined\n }\n // Evicted (with its schema) or unloaded while the lookups above ran: don't instantiate its model\n // again from rows that are being deleted.\n if (!model && isActorStopped(this._service)) return undefined\n if (!model) {\n try {\n // The epoch from when this instance was built: an eviction of the model's schema since\n // then (this instance may already be stopped) must not re-create the model.\n model = await Model.getByNameAsync(property.modelName, undefined, {\n evictionEpoch: this._evictionEpoch,\n })\n } catch {\n model = undefined\n }\n }\n \n if (!model || !model.properties || model.properties.length === 0) {\n return undefined\n }\n\n const schema = modelPropertiesToObject(model.properties)\n // Get the schema file value for this property\n const schemaFileValue = schema[property.name]\n if (!schemaFileValue) {\n return undefined\n }\n\n // Return schema file values as original values\n const originalValues: Partial<Static<typeof TProperty>> = {\n name: property.name,\n modelName: property.modelName,\n dataType: schemaFileValue.dataType,\n storageType: schemaFileValue.storageType,\n localStorageDir: schemaFileValue.localStorageDir,\n filenameSuffix: schemaFileValue.filenameSuffix,\n }\n\n // Handle ref fields\n if (schemaFileValue.ref) {\n originalValues.ref = schemaFileValue.ref\n originalValues.refModelName = schemaFileValue.ref\n // Try to get refModelId from database\n const refModelId = await this._resolveRefModelId(schemaFileValue.ref, property)\n if (refModelId) {\n originalValues.refModelId = refModelId\n }\n }\n\n if (schemaFileValue.refValueType) {\n originalValues.refValueType = schemaFileValue.refValueType\n }\n\n return originalValues\n } catch (error) {\n return undefined\n }\n }\n\n /**\n * Set the schema name for this property by looking it up from the model\n * Tries database first (more reliable), then falls back to schema files\n */\n private async _setSchemaName(property: Static<typeof TProperty>): Promise<void> {\n try {\n // create() sets the schema name right after construction when its caller knows it. Don't look it\n // up then: the file fallback below reads and parses every schema file, per property.\n await Promise.resolve()\n if (this._getSnapshotContext()._schemaName) return\n\n let schemaName: string | undefined\n // From the property data: the instance's own modelId field is never assigned (the reactive proxy\n // serves values from the machine context), so reading this.modelId skipped the DB lookup.\n const { modelId } = this._ownerModelScope(property)\n\n // Try to get schema name from database first (more reliable)\n if (modelId) {\n try {\n const db = BaseDb.getAppDb()\n if (db) {\n const modelSchemaRecords = await db\n .select({\n schemaName: schemas.name,\n })\n .from(modelSchemas)\n .innerJoin(schemas, eq(modelSchemas.schemaId, schemas.id))\n .innerJoin(modelsTable, eq(modelSchemas.modelId, modelsTable.id))\n .where(eq(modelsTable.id, modelId))\n .limit(1)\n\n if (modelSchemaRecords.length > 0) {\n schemaName = modelSchemaRecords[0].schemaName\n }\n }\n } catch (error) {\n // Database lookup failed, continue to file-based lookup\n }\n }\n\n // Fall back to schema file lookup if database didn't work\n if (!schemaName) {\n schemaName = await getSchemaNameFromModel(property.modelName!)\n }\n\n if (schemaName) {\n // Update the context with the schema name using dedicated event\n this._sendIfRunning({\n type: 'setSchemaName',\n schemaName,\n })\n }\n } catch (error) {\n // If we can't get schema name, that's okay - it will be set later if needed\n }\n }\n\n /**\n * Resolve schema name from DB when _schemaName is missing (e.g. destroy ran before _setSchemaName finished).\n * Uses context.id (schemaFileId) and context.modelId to query properties → model_schemas → schemas.\n */\n private async _resolveSchemaNameForDestroy(\n db: NonNullable<ReturnType<typeof BaseDb.getAppDb>>,\n context: ModelPropertyMachineContext,\n ): Promise<string | undefined> {\n try {\n let modelId = context.modelId\n const schemaFileId = context.id ?? context._propertyFileId\n\n // If we don't have modelId, get it from the property row by schemaFileId\n if (modelId == null && schemaFileId) {\n const propRows = await db\n .select({ modelId: propertiesTable.modelId })\n .from(propertiesTable)\n .where(eq(propertiesTable.schemaFileId, schemaFileId))\n .limit(1)\n if (propRows.length > 0 && propRows[0].modelId != null) {\n modelId = propRows[0].modelId\n }\n }\n\n if (modelId == null) return undefined\n\n // Resolve modelFileId (string) to database ID (number) if needed - modelSchemas.modelId expects number\n const modelIdNum: number =\n typeof modelId === 'string' ? await getModelIdByFileId(modelId) : modelId\n\n const modelSchemaRecords = await db\n .select({ schemaName: schemas.name })\n .from(modelSchemas)\n .innerJoin(schemas, eq(modelSchemas.schemaId, schemas.id))\n .where(eq(modelSchemas.modelId, modelIdNum))\n .limit(1)\n\n return modelSchemaRecords.length > 0 ? modelSchemaRecords[0].schemaName ?? undefined : undefined\n } catch {\n return undefined\n }\n }\n\n /**\n * Manually set the schema name for this property\n * Useful when you know the schema name from context (e.g., when working with Schema instances)\n */\n setSchemaName(schemaName: string): void {\n this._service.send({\n type: 'setSchemaName',\n schemaName,\n })\n }\n\n static create(\n property: Static<typeof TProperty>,\n options?: { waitForReady?: false; schemaName?: string },\n ): ModelProperty\n static create(\n property: Static<typeof TProperty>,\n options?: { waitForReady?: true; readyTimeout?: number; schemaName?: string },\n ): Promise<ModelProperty>\n static create(\n property: Static<typeof TProperty>,\n options?: CreateWaitOptions & { schemaName?: string },\n ): ModelProperty | Promise<ModelProperty> {\n if (!property) {\n throw new Error('Property is required')\n }\n\n const waitForReady = options?.waitForReady !== false\n const readyTimeout = options?.readyTimeout ?? 5000\n const schemaName = options?.schemaName\n\n // Handle 'type' field from JSON schema format - convert to 'dataType'\n // Normalize to PascalCase so lowercase values from JSON (e.g. 'text') work\n const propertyWithId = { ...property }\n const rawType = propertyWithId.dataType ?? (propertyWithId as any).type\n if (rawType) {\n propertyWithId.dataType = normalizeDataType(rawType) as ModelPropertyDataTypes\n }\n if (typeof propertyWithId.refValueType === 'string') {\n propertyWithId.refValueType = normalizeDataType(propertyWithId.refValueType) as ModelPropertyDataTypes\n }\n\n // Ensure id (schemaFileId) is set correctly\n // Priority: _propertyFileId > id (if string) > generate new\n // If id is a number (old format), use _propertyFileId instead\n if (typeof propertyWithId.id === 'number') {\n // id is a database integer ID, not schemaFileId - use _propertyFileId if available\n if ((propertyWithId as any)._propertyFileId) {\n propertyWithId.id = (propertyWithId as any)._propertyFileId\n } else {\n // Fallback: generate new schemaFileId (shouldn't happen, but safety)\n propertyWithId.id = generateId()\n logger(`ModelProperty.create: id was a number, generated new schemaFileId \"${propertyWithId.id}\" for property \"${property.name}\"`)\n }\n } else if (!propertyWithId.id && (propertyWithId as any)._propertyFileId) {\n // id is not set but _propertyFileId is available - use it\n propertyWithId.id = (propertyWithId as any)._propertyFileId\n } else if (!propertyWithId.id) {\n // Generate id (schemaFileId) if not provided (for new properties)\n // This ensures new properties can trigger write process\n propertyWithId.id = generateId()\n logger(`ModelProperty.create: Generated new id (schemaFileId) \"${propertyWithId.id}\" for property \"${property.name}\"`)\n }\n\n // Create cache key from modelName and name, or use id\n let cacheKey = propertyWithId.modelName && propertyWithId.name\n ? `${propertyWithId.modelName}:${propertyWithId.name}`\n : propertyWithId.id\n ? `id:${propertyWithId.id}`\n : propertyWithId.name || 'unnamed'\n\n // Model names are only unique per schema: a cached \"Post:title\" may be another schema's\n // property. If the ids say it's a different property, key this one by its own id instead.\n // (Not by file id: the same property is often created first with a generated id, then its real one.)\n const isOtherProperty = (cachedContext: ModelPropertyMachineContext): boolean =>\n (typeof propertyWithId.modelId === 'number' &&\n typeof cachedContext.modelId === 'number' &&\n cachedContext.modelId !== propertyWithId.modelId) ||\n (!!schemaName && !!cachedContext._schemaName && cachedContext._schemaName !== schemaName)\n const cachedByName = this.instanceCache.get(cacheKey)\n if (cachedByName && propertyWithId.id && isOtherProperty(cachedByName.instance._getSnapshotContext())) {\n // Reuse this property's own id-keyed entry if it already has one.\n cacheKey = `id:${propertyWithId.id}`\n for (const [key, { instance }] of this.instanceCache.entries()) {\n if (!key.startsWith('id:')) continue\n const ctx = instance._getSnapshotContext()\n if (ctx.modelName === propertyWithId.modelName && ctx.name === propertyWithId.name && !isOtherProperty(ctx)) {\n cacheKey = key\n break\n }\n }\n }\n\n // Check if instance exists in cache\n if (this.instanceCache.has(cacheKey)) {\n const { instance, refCount } = this.instanceCache.get(cacheKey)!\n const cachedContext = instance._getSnapshotContext()\n \n // Update cached instance if new property data has fields that the cached instance doesn't have\n // This handles cases where the property was created without ref initially, but now we have ref from schema\n const needsUpdate: any = {}\n if (propertyWithId.ref && !cachedContext.ref) {\n needsUpdate.ref = propertyWithId.ref\n }\n if (propertyWithId.refModelName && !cachedContext.refModelName) {\n needsUpdate.refModelName = propertyWithId.refModelName\n }\n if (propertyWithId.refModelId && !cachedContext.refModelId) {\n needsUpdate.refModelId = propertyWithId.refModelId\n }\n \n if (Object.keys(needsUpdate).length > 0) {\n instance._service.send({\n type: 'updateContext',\n ...needsUpdate,\n })\n }\n \n this.instanceCache.set(cacheKey, {\n instance,\n refCount: refCount + 1,\n })\n if (!waitForReady) return instance\n return waitForEntityIdle(instance, { timeout: readyTimeout }).then(\n () => instance,\n )\n }\n\n const newInstance = new this(propertyWithId)\n \n // Set schema name before async operations so getModelId can resolve the correct model\n if (schemaName) {\n newInstance._service.send({\n type: 'setSchemaName',\n schemaName,\n })\n }\n \n // Wrap instance in Proxy for reactive property access\n const proxiedInstance = createReactiveProxy<ModelProperty>({\n instance: newInstance,\n service: newInstance._service,\n trackedProperties: TPropertyKeys,\n getContext: (instance) => {\n const context = instance._getSnapshotContext()\n return context\n },\n sendUpdate: (instance, prop: string, value: any) => {\n const currentContext = instance._getSnapshotContext()\n if ((currentContext as Record<string, unknown>)[prop] === value) return // No-op, avoid triggering machine\n instance._service.send({\n type: 'updateContext',\n [prop]: value,\n })\n },\n })\n \n this.instanceCache.set(cacheKey, {\n instance: proxiedInstance,\n refCount: 1,\n })\n this.indexCachedInstance(cacheKey, proxiedInstance)\n\n // Trigger write process if property has modelId (or modelName) and id (schemaFileId)\n // Wait for service to be ready (idle state) and have writeProcess spawned\n const propertyFileId = propertyWithId.id // id is now the schemaFileId (string)\n const hasModelId = propertyWithId.modelId || propertyWithId.modelName\n // A _dbId means the data was loaded from an existing row (createById, getPropertySchema), so\n // there's nothing to write. Writing it back anyway raced deletes of that row's model (FK error).\n const isPersisted = typeof (propertyWithId as { _dbId?: unknown })._dbId === 'number'\n\n if (hasModelId && propertyFileId && !isPersisted) {\n // Wait for writeProcess to be spawned (it's spawned in idle state entry action)\n // Retry a few times if writeProcess isn't available yet\n let retries = 0\n const maxRetries = 10\n const checkAndSend = async () => {\n const service = proxiedInstance.getService()\n const snapshot = service.getSnapshot()\n // Unloaded or evicted (e.g. Schema.destroy) before the write started: nothing to write to\n if (isActorStopped(service)) return\n \n if (snapshot.value === 'idle' && snapshot.context.writeProcess) {\n const writeProcess = snapshot.context.writeProcess\n \n // Resolve dbModelId - convert from string (modelFileId) to number (database ID) if needed\n let resolvedModelId: number | undefined = undefined\n \n if (propertyWithId.modelId) {\n if (typeof propertyWithId.modelId === 'number') {\n resolvedModelId = propertyWithId.modelId\n } else if (typeof propertyWithId.modelId === 'string') {\n // modelId is a string (modelFileId), need to convert to database ID\n try {\n resolvedModelId = await getModelIdByFileId(propertyWithId.modelId)\n logger(`Converted modelFileId \"${propertyWithId.modelId}\" to database modelId: ${resolvedModelId}`)\n } catch (error) {\n logger(`Failed to convert modelFileId \"${propertyWithId.modelId}\" to database ID: ${error}`)\n console.error(`[ModelProperty.create] Failed to convert modelFileId: ${error}`)\n }\n }\n }\n \n // If we still don't have a modelId, try to resolve it from modelName\n if (!resolvedModelId && propertyWithId.modelName) {\n try {\n // Get schemaName from context if available\n const schemaName = snapshot.context._schemaName\n resolvedModelId = await getModelId(propertyWithId.modelName, schemaName)\n logger(`Resolved modelId for model \"${propertyWithId.modelName}\": ${resolvedModelId}`)\n } catch (error) {\n logger(`Failed to resolve modelId for model \"${propertyWithId.modelName}\": ${error}`)\n console.error(`[ModelProperty.create] Failed to resolve modelId: ${error}`)\n }\n }\n \n if (!resolvedModelId) {\n logger(`ERROR: Cannot write property \"${property.name}\" - no modelId available`)\n console.error(`[ModelProperty.create] ERROR: Cannot write property \"${property.name}\" - no modelId available. modelId: ${propertyWithId.modelId}, modelName: ${propertyWithId.modelName}`)\n // Don't clear pending write here - it might resolve later\n return\n }\n\n // Resolving the modelId awaited the DB; the instance may have been stopped meanwhile\n if (isActorStopped(service)) return\n \n // Track pending write now that we have the resolved modelId\n this.trackPendingWrite(propertyFileId, resolvedModelId)\n \n logger(`Triggering write process for property \"${property.name}\" (modelId: ${resolvedModelId}, propertyFileId: ${propertyFileId})`)\n \n // Check current write state\n const currentWriteState = writeProcess.getSnapshot()\n \n if (currentWriteState.value === 'success') {\n // Write already succeeded\n void this.completePendingWrite(propertyFileId, resolvedModelId)\n } else {\n // Set up subscription to catch future state changes\n const writeSubscription = writeProcess.subscribe((writeSnapshot) => {\n if (writeSnapshot.value === 'success') {\n writeSubscription.unsubscribe()\n logger(`[writeProcess subscription] Write succeeded for property \"${property.name}\" (propertyFileId: ${propertyFileId})`)\n void this.completePendingWrite(propertyFileId, resolvedModelId)\n } else if (writeSnapshot.value === 'error') {\n writeSubscription.unsubscribe()\n const errorContext = writeSnapshot.context\n logger(`Write process failed for property \"${property.name}\" (propertyFileId: ${propertyFileId}): ${errorContext.error?.message || 'Unknown error'}`)\n logger(`Write process error details:`, errorContext.error)\n // Mark pending write as error\n this.clearPendingWrite(propertyFileId, 'error')\n }\n })\n }\n \n const propertyData = {\n modelId: resolvedModelId,\n name: property.name!,\n dataType: property.dataType!,\n refModelId: property.refModelId,\n refValueType: property.refValueType,\n required: property.required,\n storageType: property.storageType,\n localStorageDir: property.localStorageDir,\n filenameSuffix: property.filenameSuffix,\n }\n \n service.send({\n type: 'requestWrite',\n data: propertyData,\n })\n } else if (retries < maxRetries) {\n retries++\n setTimeout(checkAndSend, 50) // Retry after 50ms\n } else {\n logger(`ERROR: writeProcess not available after ${maxRetries} retries for property \"${property.name}\" (propertyFileId: ${propertyFileId})`)\n console.error(`[ModelProperty.create] ERROR: writeProcess not available after ${maxRetries} retries for property \"${property.name}\" (propertyFileId: ${propertyFileId})`)\n // Mark as error if we couldn't even start the write process\n this.clearPendingWrite(propertyFileId, 'error')\n }\n }\n \n // Start checking after a short delay to allow state machine to initialize\n setTimeout(checkAndSend, 0)\n }\n \n if (!waitForReady) return proxiedInstance\n return waitForEntityIdle(proxiedInstance, { timeout: readyTimeout }).then(\n () => proxiedInstance,\n )\n }\n\n /** Whether an idIndex entry still points at a cached instance with that id. */\n private static isIndexEntryCurrent(\n propertyFileId: string,\n entry: { cacheKey: string; instance: ModelProperty },\n ): boolean {\n if (this.instanceCache.get(entry.cacheKey)?.instance !== entry.instance) return false\n try {\n return entry.instance._getSnapshotContext().id === propertyFileId\n } catch {\n return false\n }\n }\n\n /** Add a newly cached instance to idIndex, and keep its entry current when its id changes. */\n private static indexCachedInstance(cacheKey: string, instance: ModelProperty): void {\n const index = (id: string | undefined) => {\n if (!id) return\n const existing = this.idIndex.get(id)\n // Keep the instance cached first, as the old scan in insertion order returned\n if (existing && existing.instance !== instance && this.isIndexEntryCurrent(id, existing)) return\n this.idIndex.set(id, { cacheKey, instance })\n }\n let indexedId = instance._getSnapshotContext().id\n index(indexedId)\n instance._service.subscribe((snapshot) => {\n const id = snapshot.context.id\n if (id === indexedId) return\n indexedId = id\n index(id)\n })\n }\n\n /**\n * Get ModelProperty instance by propertyFileId from static cache\n */\n static getById(propertyFileId: string): ModelProperty | undefined {\n if (!propertyFileId) return undefined\n\n const indexed = this.idIndex.get(propertyFileId)\n if (!indexed) return undefined\n if (this.isIndexEntryCurrent(propertyFileId, indexed)) return indexed.instance\n\n // The indexed instance left the cache or changed id; another cached instance may still have it.\n // Cache key might be \"modelName:propertyName\" or \"id:propertyId\"\n this.idIndex.delete(propertyFileId)\n for (const [cacheKey, { instance }] of this.instanceCache.entries()) {\n // id is now the schemaFileId (string)\n if (instance._getSnapshotContext().id === propertyFileId) {\n this.idIndex.set(propertyFileId, { cacheKey, instance })\n return instance\n }\n }\n\n return undefined\n }\n\n /**\n * Create or get ModelProperty instance by propertyFileId\n * Queries the database to find the property if not cached\n */\n static async createById(\n propertyFileId: string,\n options?: {\n /**\n * currentEvictionEpoch() from when the caller's work started. An eviction of the property's\n * schema since then makes this return undefined instead of re-creating it. Defaults to now.\n */\n evictionEpoch?: number\n },\n ): Promise<ModelProperty | undefined> {\n if (!propertyFileId) {\n return undefined\n }\n\n // First, check if we have an instance cached\n const cachedInstance = this.getById(propertyFileId)\n if (cachedInstance) {\n return cachedInstance\n }\n\n // Query database to get property data from ID\n const db = BaseDb.getAppDb()\n if (!db) {\n return undefined\n }\n const evictionEpoch = options?.evictionEpoch ?? currentEvictionEpoch()\n\n const propertyRecords = await db\n .select()\n .from(propertiesTable)\n .where(eq(propertiesTable.schemaFileId, propertyFileId))\n .limit(1)\n\n if (propertyRecords.length === 0) {\n return undefined\n }\n\n const propertyRecord = propertyRecords[0]\n\n // Get model name\n const modelRecords = await db\n .select({ name: modelsTable.name })\n .from(modelsTable)\n .where(eq(modelsTable.id, propertyRecord.modelId))\n .limit(1)\n\n if (modelRecords.length === 0) {\n return undefined\n }\n\n const modelName = modelRecords[0].name\n\n // Build property data\n // id is now the schemaFileId (string), _dbId is the database integer ID\n const propertyData: Static<typeof TProperty> = {\n id: propertyFileId, // schemaFileId (string) - public ID\n _dbId: propertyRecord.id ?? undefined, // Database integer ID - internal only\n name: propertyRecord.name,\n dataType: propertyRecord.dataType as ModelPropertyDataTypes,\n modelId: propertyRecord.modelId,\n modelName,\n refModelId: propertyRecord.refModelId || undefined,\n refValueType: propertyRecord.refValueType ? (propertyRecord.refValueType as ModelPropertyDataTypes) : undefined,\n required: propertyRecord.required ?? false,\n storageType: (propertyRecord.storageType as StorageType | null) ?? undefined,\n localStorageDir: propertyRecord.localStorageDir ?? undefined,\n filenameSuffix: propertyRecord.filenameSuffix ?? undefined,\n }\n\n // Load isEdited from database\n const isEditedFromDb = propertyRecord.isEdited ?? false\n\n // Get ref model name if applicable\n if (propertyRecord.refModelId) {\n const refModelRecords = await db\n .select({ name: modelsTable.name })\n .from(modelsTable)\n .where(eq(modelsTable.id, propertyRecord.refModelId))\n .limit(1)\n\n if (refModelRecords.length > 0) {\n propertyData.refModelName = refModelRecords[0].name\n propertyData.ref = refModelRecords[0].name\n }\n }\n\n // Its model's schema was evicted while we read the rows (e.g. a model's property lookup in flight\n // during Schema.destroy or test cleanup): don't bring the property back.\n if (anyEvictionSince(evictionEpoch)) {\n const schemaRows = await db\n .select({ name: schemas.name })\n .from(modelSchemas)\n .innerJoin(schemas, eq(schemas.id, modelSchemas.schemaId))\n .where(eq(modelSchemas.modelId, propertyRecord.modelId))\n if (\n schemaRows.length === 0 ||\n schemaRows.some((row: { name: string | null }) => schemaEvictedSince(row.name, evictionEpoch))\n ) {\n return undefined\n }\n }\n\n // Create ModelProperty instance (sync for createById so we can send updateContext)\n const instance = this.create(propertyData, { waitForReady: false })\n \n // Set isEdited from database after creation\n if (isEditedFromDb) {\n instance._service.send({\n type: 'updateContext',\n _isEdited: true,\n })\n }\n \n return instance\n }\n\n /**\n * Find ModelProperty instance by propertyFileId\n * Waits for the property to be fully loaded (idle state) by default\n * @param options - Find options including propertyFileId and wait configuration\n * @returns ModelProperty instance if found, undefined otherwise\n */\n static async find({\n propertyFileId,\n waitForReady = true,\n readyTimeout = 5000,\n }: {\n propertyFileId: string\n waitForReady?: boolean\n readyTimeout?: number\n }): Promise<ModelProperty | undefined> {\n if (!propertyFileId) {\n return undefined\n }\n\n return await findEntity<ModelProperty>(\n {\n getById: (id) => ModelProperty.getById(id),\n createById: (id) => ModelProperty.createById(id),\n },\n { id: propertyFileId },\n {\n waitForReady,\n readyTimeout,\n }\n )\n }\n\n /**\n * Get all ModelProperty instances for a model.\n * Loads property rows from DB for the given modelFileId, creates instances via createById, optionally waits for idle.\n */\n static async all(\n modelFileId: string,\n options?: { waitForReady?: boolean; readyTimeout?: number },\n ): Promise<ModelProperty[]> {\n const { waitForReady = false, readyTimeout = 5000 } = options ?? {}\n if (!modelFileId) {\n return []\n }\n\n const rows = await getModelPropertiesData(modelFileId)\n const instances: ModelProperty[] = []\n\n for (const row of rows) {\n if (row.schemaFileId) {\n const instance = await this.createById(row.schemaFileId)\n if (instance) {\n instances.push(instance)\n }\n }\n }\n\n if (waitForReady && instances.length > 0) {\n await Promise.all(\n instances.map((p) =>\n waitForEntityIdle(p as Parameters<typeof waitForEntityIdle>[0], {\n timeout: readyTimeout,\n }),\n ),\n )\n }\n\n return instances\n }\n\n /**\n * Track a pending write for a property\n */\n static trackPendingWrite(propertyFileId: string, modelId: number): void {\n this.pendingWrites.set(propertyFileId, {\n propertyFileId,\n modelId,\n status: 'pending',\n timestamp: Date.now(),\n })\n }\n\n /**\n * A property write succeeded: add the property to its model's property ids, then drop the pending\n * write. In that order, `Model.properties` (property ids + pending writes) never misses it; in Node,\n * where the Model has no reactive liveQuery, nothing else would add it.\n */\n private static async completePendingWrite(propertyFileId: string, modelId: number): Promise<void> {\n try {\n await Model.refreshPropertiesForDbId(modelId)\n } catch (error) {\n logger(`Refreshing properties of model ${modelId} after writing \"${propertyFileId}\" failed: ${error}`)\n }\n this.clearPendingWrite(propertyFileId, 'success')\n }\n\n /**\n * Clear or update pending write status\n */\n static clearPendingWrite(propertyFileId: string, status: 'success' | 'error' = 'success'): void {\n const write = this.pendingWrites.get(propertyFileId)\n if (write) {\n if (status === 'success') {\n // Remove successful writes from pendingWrites\n this.pendingWrites.delete(propertyFileId)\n logger(`Cleared pending write for property \"${propertyFileId}\" (status: success)`)\n } else {\n // Update status to error but keep in map (for debugging/retry purposes)\n write.status = 'error'\n this.pendingWrites.set(propertyFileId, write)\n logger(`Marked pending write as error for property \"${propertyFileId}\"`)\n }\n }\n }\n\n /**\n * Get all pending property IDs for a model\n */\n static getPendingPropertyIds(modelId: number): string[] {\n return Array.from(this.pendingWrites.entries())\n .filter(([_, write]) => write.modelId === modelId && write.status !== 'error')\n .map(([propertyFileId]) => propertyFileId)\n }\n\n /**\n * Get modelId for a property that has a pending write (row may not be in DB yet).\n * Used to resolve modelName when validating a just-created property rename.\n */\n static getPendingModelId(propertyFileId: string): number | undefined {\n return this.pendingWrites.get(propertyFileId)?.modelId\n }\n\n getService(): ModelPropertyService {\n return this._service\n }\n\n private _getSnapshot(): ModelPropertySnapshot {\n return this._service.getSnapshot() as ModelPropertySnapshot\n }\n\n public _getSnapshotContext(): ModelPropertyMachineContext {\n return this._getSnapshot().context\n }\n\n get path() {\n const workingDir = BaseFileManager.getWorkingDir()\n if (!this.localStorageDir || !this.name || !this.filenameSuffix) {\n return undefined\n }\n return `${workingDir}/${this.localStorageDir}/${this.name}${this.filenameSuffix || ''}`\n }\n\n get status() {\n return this._getSnapshot().value\n }\n\n get isEdited() {\n const context = this._getSnapshotContext()\n // First check in-memory state\n if (context._isEdited !== undefined) {\n return context._isEdited\n }\n // Fall back to reading from database if we have _dbId\n if (context._dbId) {\n // Load from database asynchronously (fire-and-forget for now)\n // For synchronous getter, we'll need to cache it or make it async\n // For now, return false if not in context\n return false\n }\n return false\n }\n\n get validationErrors() {\n return this._getSnapshotContext()._validationErrors || []\n }\n\n get isValid() {\n const errors = this.validationErrors\n return errors.length === 0\n }\n\n /**\n * Validate the property\n * @returns Validation result\n */\n async validate(): Promise<{ isValid: boolean; errors: any[] }> {\n return new Promise((resolve) => {\n let resolved = false\n const subscription = this._service.subscribe((snapshot) => {\n const state = snapshot.value\n // Wait for validation to complete (idle state after validating)\n if (state === 'idle' && !resolved) {\n resolved = true\n subscription.unsubscribe()\n const errors = snapshot.context._validationErrors || []\n resolve({\n isValid: errors.length === 0,\n errors,\n })\n }\n })\n\n this._service.send({ type: 'validateProperty' })\n \n // Timeout fallback\n setTimeout(() => {\n if (!resolved) {\n resolved = true\n subscription.unsubscribe()\n const errors = this._getSnapshotContext()._validationErrors || []\n resolve({\n isValid: errors.length === 0,\n errors,\n })\n }\n }, 5000)\n })\n }\n\n save(): void {\n const snapshot = this._service.getSnapshot()\n const isAlreadySaving =\n typeof snapshot.value === 'object' && snapshot.value !== null && 'saveToSchema' in snapshot.value\n if (isAlreadySaving) {\n return\n }\n const context = snapshot.context\n if (!context._isEdited) return // No changes to persist\n // Validation will happen automatically in the machine before saving\n this._service.send({\n type: 'saveToSchema',\n })\n }\n\n /**\n * Reload property from database\n * This refreshes the actor context with the latest data from the database\n * Note: ModelProperty doesn't have a dedicated load actor, so this will\n * re-initialize from the current property data\n */\n async reload(): Promise<void> {\n // ModelProperty doesn't have a separate load mechanism\n // It's loaded as part of the Model/Schema\n // This method is provided for API consistency\n // To actually reload, you'd need to reload the parent Model or Schema\n logger('ModelProperty.reload() called - ModelProperty is loaded as part of Model/Schema. Reload the parent Model or Schema instead.')\n // No-op for now, but could be enhanced to reload from DB if needed\n }\n\n /**\n * Force-evict cached ModelProperty instances for the given models, ignoring refCounts, and stop\n * their services. Used by Schema.destroy() so a re-imported schema gets fresh instances instead of\n * ones holding a deleted row's _dbId.\n */\n static evictForModels(modelNames: string[], schemaName?: string): void {\n if (modelNames.length === 0) return\n const names = new Set(modelNames)\n for (const [cacheKey, { instance }] of this.instanceCache.entries()) {\n let context: ModelPropertyMachineContext\n try {\n context = instance._getSnapshotContext()\n } catch {\n continue\n }\n if (!context.modelName || !names.has(context.modelName)) continue\n if (schemaName && context._schemaName && context._schemaName !== schemaName) continue\n\n this.instanceCache.delete(cacheKey)\n try {\n instance._service.stop()\n } catch {\n // Service might already be stopped\n }\n }\n }\n\n unload(): void {\n // ModelProperty doesn't have liveQuery subscriptions or complex cache management\n // Just stop the service\n try {\n this._service.stop()\n } catch (error) {\n // Service might already be stopped\n }\n }\n\n /**\n * Destroy the model property: remove from caches, delete from database, update Schema context, stop service.\n */\n async destroy(): Promise<void> {\n const context = this._getSnapshotContext()\n // Stored under \"modelName:name\", or \"id:<id>\" when another schema's same-name property holds that key\n const cacheKeys = [...ModelProperty.instanceCache.entries()]\n .filter(([, entry]) => {\n try {\n return entry.instance._getSnapshotContext().id === context.id\n } catch {\n return false\n }\n })\n .map(([key]) => key)\n if (cacheKeys.length === 0 && context.modelName && context.name) {\n cacheKeys.push(`${context.modelName}:${context.name}`)\n }\n if (cacheKeys.length === 0) return\n\n forceRemoveFromCaches(this, {\n getCacheKeys: () => cacheKeys,\n caches: [ModelProperty.instanceCache as Map<string, unknown>],\n })\n\n await runDestroyLifecycle(this, {\n getService: (instance) =>\n instance._service as { send: (ev: unknown) => void; stop: () => void },\n doDestroy: async () => {\n const db = BaseDb.getAppDb()\n let schemaName = context._schemaName\n const modelName = context.modelName\n const propertyName = context.name\n if (!modelName || !propertyName) return\n\n // Resolve schema name from DB when _schemaName is missing (e.g. destroy ran before _setSchemaName finished)\n if (!schemaName && db) {\n schemaName = await this._resolveSchemaNameForDestroy(db, context)\n }\n\n if (db && schemaName) {\n const propertyRecords = await db\n .select({ propertyId: propertiesTable.id })\n .from(propertiesTable)\n .innerJoin(modelsTable, eq(propertiesTable.modelId, modelsTable.id))\n .innerJoin(modelSchemas, eq(modelsTable.id, modelSchemas.modelId))\n .innerJoin(schemas, eq(modelSchemas.schemaId, schemas.id))\n .where(\n and(\n eq(schemas.name, schemaName),\n eq(modelsTable.name, modelName),\n eq(propertiesTable.name, propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length > 0 && propertyRecords[0].propertyId != null) {\n await db\n .delete(propertiesTable)\n .where(eq(propertiesTable.id, propertyRecords[0].propertyId))\n }\n }\n\n if (schemaName) {\n const schema = Schema.create(schemaName, { waitForReady: false }) as import('@/Schema/Schema').Schema\n const snapshot = schema.getService().getSnapshot()\n const schemaContext = snapshot.context\n if (schemaContext.models?.[modelName]?.properties?.[propertyName]) {\n const updatedModels = { ...schemaContext.models }\n const updatedProperties = { ...updatedModels[modelName].properties }\n delete updatedProperties[propertyName]\n updatedModels[modelName] = { ...updatedModels[modelName], properties: updatedProperties }\n schema.getService().send({ type: 'updateContext', models: updatedModels })\n schema.getService().send({ type: 'markAsDraft', propertyKey: `property:${modelName}:${propertyName}` })\n }\n }\n },\n })\n }\n}\n"],"names":["logger","fromCallback","isActorStopped","BaseDb","setup","writeProcessMachine","assign","modelsTable","eq","propertiesTable","currentEvictionEpoch","createActor","and","Model","modelPropertiesToObject","schemas","modelSchemas","getModelIdByFileId","normalizeDataType","generateId","waitForEntityIdle","createReactiveProxy","getModelId","anyEvictionSince","schemaEvictedSince","findEntity","BaseFileManager","forceRemoveFromCaches","runDestroyLifecycle","Schema"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAMA,QAAM,GAAG,KAAK,CAAC,2CAA2C,CAAC;AAEjE;;;;AAIG;AACI,eAAe,sBAAsB,CAAC,SAAiB,EAAA;;AAE5D,IAAA,MAAM,gBAAgB,GAAG,MAAM,oDAAO,qBAAyB,+CAAC;AAChE,IAAA,MAAM,EAAE,qBAAqB,EAAE,GAAG,gBAAgB;AAClD,IAAA,MAAM,aAAa,GAAG,MAAM,qBAAqB,EAAE;AAEnD,IAAA,KAAK,MAAM,MAAM,IAAI,aAAa,EAAE;AAClC,QAAA,IAAI;AACF,YAAA,MAAM,cAAc,GAAG,MAAM,oDAAO,qBAA8C,wDAAC;AACnF,YAAA,MAAM,EAAE,eAAe,EAAE,GAAG,cAAc;YAC1C,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC;YACvE,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAQ;YAE7C,IAAI,UAAU,CAAC,M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