@seedprotocol/sdk 0.7.5 → 0.7.6
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/README.md +2 -2
- package/dist/{ClientManager-DRf4uuei.js → ClientManager-D6YA20jP.js} +207 -149
- package/dist/ClientManager-D6YA20jP.js.map +1 -0
- package/dist/{Item-DTJPMjFk.js → Item-B1MH0tXx.js} +126 -86
- package/dist/Item-B1MH0tXx.js.map +1 -0
- package/dist/{ModelProperty-Dto5C0om.js → ModelProperty-Dw6dHdu_.js} +37 -37
- package/dist/{ModelProperty-Dto5C0om.js.map → ModelProperty-Dw6dHdu_.js.map} +1 -1
- package/dist/{Schema-8DxGcORY.js → Schema-DppObO6h.js} +62 -212
- package/dist/Schema-DppObO6h.js.map +1 -0
- package/dist/{SchemaValidationService-CE92y1TT.js → SchemaValidationService-DXQ-D531.js} +6 -6
- package/dist/{SchemaValidationService-CE92y1TT.js.map → SchemaValidationService-DXQ-D531.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-CRqp-BqX.js → backfillMetadataPropertyIds-Uhzlwg9X.js} +3 -3
- package/dist/{backfillMetadataPropertyIds-CRqp-BqX.js.map → backfillMetadataPropertyIds-Uhzlwg9X.js.map} +1 -1
- package/dist/configurePlatform-CVoh3JeR.js +81 -0
- package/dist/configurePlatform-CVoh3JeR.js.map +1 -0
- package/dist/{detachRowsBeforeDelete-BVetHtn2.js → detachRowsBeforeDelete-CtmIFpgV.js} +2 -2
- package/dist/{detachRowsBeforeDelete-BVetHtn2.js.map → detachRowsBeforeDelete-CtmIFpgV.js.map} +1 -1
- package/dist/{discardNewDraft-CEOouygG.js → discardNewDraft-oGYdB5vS.js} +5 -5
- package/dist/{discardNewDraft-CEOouygG.js.map → discardNewDraft-oGYdB5vS.js.map} +1 -1
- package/dist/dist/ClientManager-D6YA20jP.d.ts +933 -0
- package/dist/dist/ClientManager-D6YA20jP.d.ts.map +1 -0
- package/dist/dist/Item-B1MH0tXx.d.ts +898 -0
- package/dist/dist/Item-B1MH0tXx.d.ts.map +1 -0
- package/dist/dist/ModelProperty-Dw6dHdu_.d.ts +315 -0
- package/dist/dist/ModelProperty-Dw6dHdu_.d.ts.map +1 -0
- package/dist/dist/Schema-DppObO6h.d.ts +601 -0
- package/dist/dist/Schema-DppObO6h.d.ts.map +1 -0
- package/dist/dist/SchemaValidationService-DXQ-D531.d.ts +118 -0
- package/dist/dist/SchemaValidationService-DXQ-D531.d.ts.map +1 -0
- package/dist/dist/backfillMetadataPropertyIds-Uhzlwg9X.d.ts +7 -0
- package/dist/dist/backfillMetadataPropertyIds-Uhzlwg9X.d.ts.map +1 -0
- package/dist/dist/configurePlatform-CVoh3JeR.d.ts +30 -0
- package/dist/dist/configurePlatform-CVoh3JeR.d.ts.map +1 -0
- package/dist/dist/detachRowsBeforeDelete-CtmIFpgV.d.ts +13 -0
- package/dist/dist/detachRowsBeforeDelete-CtmIFpgV.d.ts.map +1 -0
- package/dist/dist/discardNewDraft-oGYdB5vS.d.ts +8 -0
- package/dist/dist/discardNewDraft-oGYdB5vS.d.ts.map +1 -0
- package/dist/dist/eas-CSm5wmry.d.ts +12 -0
- package/dist/dist/eas-CSm5wmry.d.ts.map +1 -0
- package/dist/dist/errors-3tc6XkCB.d.ts +487 -0
- package/dist/dist/errors-3tc6XkCB.d.ts.map +1 -0
- package/dist/dist/errors-Do7v6RKu.d.ts +22 -0
- package/dist/dist/errors-Do7v6RKu.d.ts.map +1 -0
- package/dist/dist/getItem-DM3a-7XE.d.ts +6 -0
- package/dist/dist/getItem-DM3a-7XE.d.ts.map +1 -0
- package/dist/dist/getPublishPayload-CJF0k5d8.d.ts +47 -0
- package/dist/dist/getPublishPayload-CJF0k5d8.d.ts.map +1 -0
- package/dist/dist/getPublishUploads-C7-fYIgX.d.ts +89 -0
- package/dist/dist/getPublishUploads-C7-fYIgX.d.ts.map +1 -0
- package/dist/dist/index--mmQ3LQu.d.ts +6 -0
- package/dist/dist/index--mmQ3LQu.d.ts.map +1 -0
- package/dist/dist/index-B7yAoYli.d.ts +2752 -0
- package/dist/dist/index-B7yAoYli.d.ts.map +1 -0
- package/dist/dist/index-CrvIcVFJ.d.ts +4475 -0
- package/dist/dist/index-CrvIcVFJ.d.ts.map +1 -0
- package/dist/dist/index.browser-BmVS-c2C.d.ts +8445 -0
- package/dist/dist/index.browser-BmVS-c2C.d.ts.map +1 -0
- package/dist/dist/index.node-BKpbCAWt.d.ts +11123 -0
- package/dist/dist/index.node-BKpbCAWt.d.ts.map +1 -0
- package/dist/dist/mimeTypes-C9r76DCH.d.ts +30 -0
- package/dist/dist/mimeTypes-C9r76DCH.d.ts.map +1 -0
- package/dist/dist/model-oHA3YhOd.d.ts +6 -0
- package/dist/dist/model-oHA3YhOd.d.ts.map +1 -0
- package/dist/dist/platform.browser.d.ts +3 -0
- package/dist/dist/platform.browser.d.ts.map +1 -0
- package/dist/dist/platform.node.d.ts +3 -0
- package/dist/dist/platform.node.d.ts.map +1 -0
- package/dist/dist/property-DQ-Owzki.d.ts +37 -0
- package/dist/dist/property-DQ-Owzki.d.ts.map +1 -0
- package/dist/dist/propertyValidationRules-BDhFjlwP.d.ts +8 -0
- package/dist/dist/propertyValidationRules-BDhFjlwP.d.ts.map +1 -0
- package/dist/dist/publishDraftGraph-CzPd9oe9.d.ts +76 -0
- package/dist/dist/publishDraftGraph-CzPd9oe9.d.ts.map +1 -0
- package/dist/dist/resetAmbiguousLegacyItemData-cXZm4NuG.d.ts +17 -0
- package/dist/dist/resetAmbiguousLegacyItemData-cXZm4NuG.d.ts.map +1 -0
- package/dist/dist/resolveModelForSyncedSeed-BgxtVCHI.d.ts +21 -0
- package/dist/dist/resolveModelForSyncedSeed-BgxtVCHI.d.ts.map +1 -0
- package/dist/dist/syncDbWithEas-Y5GysSCm.d.ts +22 -0
- package/dist/dist/syncDbWithEas-Y5GysSCm.d.ts.map +1 -0
- package/dist/dist/tabEvents-D9x26vf2.d.ts +81 -0
- package/dist/dist/tabEvents-D9x26vf2.d.ts.map +1 -0
- package/dist/dist/tolerantWebAccess-BFU2t-SC.d.ts +113 -0
- package/dist/dist/tolerantWebAccess-BFU2t-SC.d.ts.map +1 -0
- package/dist/dist/updateSeedRevokedAt-CCF8WWYS.d.ts +11 -0
- package/dist/dist/updateSeedRevokedAt-CCF8WWYS.d.ts.map +1 -0
- package/dist/drizzle.js +2 -0
- package/dist/drizzle.js.map +1 -0
- package/dist/{eas-D7jvWMnI.js → eas-CSm5wmry.js} +3 -3
- package/dist/{eas-D7jvWMnI.js.map → eas-CSm5wmry.js.map} +1 -1
- package/dist/{errors-CIrbsN_i.js → errors-3tc6XkCB.js} +81 -36
- package/dist/errors-3tc6XkCB.js.map +1 -0
- package/dist/errors-Do7v6RKu.js +34 -0
- package/dist/errors-Do7v6RKu.js.map +1 -0
- package/dist/{getItem-CxU_kT5W.js → getItem-DM3a-7XE.js} +4 -4
- package/dist/{getItem-CxU_kT5W.js.map → getItem-DM3a-7XE.js.map} +1 -1
- package/dist/{getPublishPayload-DTjOKd3y.js → getPublishPayload-CJF0k5d8.js} +31 -25
- package/dist/getPublishPayload-CJF0k5d8.js.map +1 -0
- package/dist/{getPublishUploads-CVTBo_OV.js → getPublishUploads-C7-fYIgX.js} +6 -6
- package/dist/{getPublishUploads-CVTBo_OV.js.map → getPublishUploads-C7-fYIgX.js.map} +1 -1
- package/dist/{index-CMxEil8T.js → index--mmQ3LQu.js} +8 -8
- package/dist/index--mmQ3LQu.js.map +1 -0
- package/dist/{index-DWK-LOUY.js → index-B7yAoYli.js} +2 -2
- package/dist/index-B7yAoYli.js.map +1 -0
- package/dist/{BasePathResolver-CBTXCMFL.js → index-CrvIcVFJ.js} +304 -285
- package/dist/index-CrvIcVFJ.js.map +1 -0
- package/dist/{index.browser-shRXMeB3.js → index.browser-BmVS-c2C.js} +34 -44
- package/dist/index.browser-BmVS-c2C.js.map +1 -0
- package/dist/{index.node-DAKJNYp5.js → index.node-BKpbCAWt.js} +43 -7
- package/dist/index.node-BKpbCAWt.js.map +1 -0
- package/dist/main.js +23 -24
- package/dist/main.js.map +1 -1
- package/dist/node.js +13 -10
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +7 -7
- package/dist/platform.node.js +4 -4
- package/dist/{property-lz9yIpyA.js → property-DQ-Owzki.js} +7 -7
- package/dist/{property-lz9yIpyA.js.map → property-DQ-Owzki.js.map} +1 -1
- package/dist/{propertyValidationRules-LuIwoQoJ.js → propertyValidationRules-BDhFjlwP.js} +10 -10
- package/dist/{propertyValidationRules-LuIwoQoJ.js.map → propertyValidationRules-BDhFjlwP.js.map} +1 -1
- package/dist/{publishDraftGraph-CgSLPKvQ.js → publishDraftGraph-CzPd9oe9.js} +41 -8
- package/dist/publishDraftGraph-CzPd9oe9.js.map +1 -0
- package/dist/{resetAmbiguousLegacyItemData-CuamkAAh.js → resetAmbiguousLegacyItemData-cXZm4NuG.js} +2 -2
- package/dist/{resetAmbiguousLegacyItemData-CuamkAAh.js.map → resetAmbiguousLegacyItemData-cXZm4NuG.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-BbSctSvz.js → resolveModelForSyncedSeed-BgxtVCHI.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-BbSctSvz.js.map → resolveModelForSyncedSeed-BgxtVCHI.js.map} +1 -1
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/initialize.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/rowContext.d.ts +10 -0
- package/dist/src/ItemProperty/service/actors/saveValueToDb/rowContext.d.ts.map +1 -0
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveFile.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveHtml.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/propertyMachine.d.ts +20 -20
- package/dist/src/Model/Model.d.ts +8 -0
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts +1 -1
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +3 -3
- package/dist/src/Schema/service/actors/checkExistingSchema.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/loadOrCreateSchema.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/writeModelsToDb.d.ts.map +1 -1
- package/dist/src/browser/db/Db.d.ts.map +1 -1
- package/dist/src/browser/helpers/ArweaveClient.d.ts.map +1 -1
- package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
- package/dist/src/client/actors/platformClassesInit.d.ts +1 -7
- package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/src/client/actors/saveAppState.d.ts.map +1 -1
- package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/src/client/seedConfigDefaults.d.ts +10 -0
- package/dist/src/client/seedConfigDefaults.d.ts.map +1 -0
- package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/src/db/write/updateItemPropertyValue.d.ts +6 -0
- package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
- package/dist/src/drizzle/index.d.ts +7 -0
- package/dist/src/drizzle/index.d.ts.map +1 -0
- package/dist/src/events/files/download.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/errors.d.ts +11 -0
- package/dist/src/helpers/FileManager/errors.d.ts.map +1 -1
- package/dist/src/helpers/db.d.ts +14 -0
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/helpers/dotSeedPath.d.ts +7 -0
- package/dist/src/helpers/dotSeedPath.d.ts.map +1 -0
- package/dist/src/helpers/entity/entityLiveQuery.d.ts.map +1 -1
- package/dist/src/helpers/environment.d.ts +5 -0
- package/dist/src/helpers/environment.d.ts.map +1 -1
- package/dist/src/helpers/getSegmentedItemProperties.d.ts.map +1 -1
- package/dist/src/helpers/metadataPropertyNames.d.ts +10 -0
- package/dist/src/helpers/metadataPropertyNames.d.ts.map +1 -1
- package/dist/src/helpers/reconcilePropertyDraftRows.d.ts +9 -0
- package/dist/src/helpers/reconcilePropertyDraftRows.d.ts.map +1 -0
- package/dist/src/helpers/updateSchema.d.ts.map +1 -1
- package/dist/src/imports/index.d.ts +1 -1
- package/dist/src/imports/index.d.ts.map +1 -1
- package/dist/src/imports/json.d.ts +18 -5
- package/dist/src/imports/json.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/node/helpers/resolveFilesDir.d.ts +8 -0
- package/dist/src/node/helpers/resolveFilesDir.d.ts.map +1 -0
- package/dist/src/node/webpack/index.d.ts +2 -0
- package/dist/src/node/webpack/index.d.ts.map +1 -1
- package/dist/src/platform/index.browser.d.ts +5 -0
- package/dist/src/platform/index.browser.d.ts.map +1 -1
- package/dist/src/platform/index.node.d.ts +1 -0
- package/dist/src/platform/index.node.d.ts.map +1 -1
- package/dist/src/stores/eas.d.ts +1 -1
- package/dist/src/stores/eas.d.ts.map +1 -1
- package/dist/src/types/import.d.ts +15 -0
- package/dist/src/types/import.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +8 -4
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/{syncDbWithEas-CrAY9Rl2.js → syncDbWithEas-Y5GysSCm.js} +17 -13
- package/dist/syncDbWithEas-Y5GysSCm.js.map +1 -0
- package/dist/{tabEvents-BGBYV65P.js → tabEvents-D9x26vf2.js} +4 -4
- package/dist/{tabEvents-BGBYV65P.js.map → tabEvents-D9x26vf2.js.map} +1 -1
- package/dist/{tolerantWebAccess-DVHCEulL.js → tolerantWebAccess-BFU2t-SC.js} +8 -8
- package/dist/{tolerantWebAccess-DVHCEulL.js.map → tolerantWebAccess-BFU2t-SC.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-Dy5J8CfQ.js → updateSeedRevokedAt-CCF8WWYS.js} +3 -3
- package/dist/{updateSeedRevokedAt-Dy5J8CfQ.js.map → updateSeedRevokedAt-CCF8WWYS.js.map} +1 -1
- package/package.json +31 -31
- package/dist/BasePathResolver-CBTXCMFL.js.map +0 -1
- package/dist/ClientManager-DRf4uuei.js.map +0 -1
- package/dist/Item-DTJPMjFk.js.map +0 -1
- package/dist/Schema-8DxGcORY.js.map +0 -1
- package/dist/configurePlatform-D4aGjKNk.js +0 -31
- package/dist/configurePlatform-D4aGjKNk.js.map +0 -1
- package/dist/errors-CIrbsN_i.js.map +0 -1
- package/dist/errors-CrBxGWah.js +0 -17
- package/dist/errors-CrBxGWah.js.map +0 -1
- package/dist/getPublishPayload-DTjOKd3y.js.map +0 -1
- package/dist/index-CMxEil8T.js.map +0 -1
- package/dist/index-DWK-LOUY.js.map +0 -1
- package/dist/index.browser-shRXMeB3.js.map +0 -1
- package/dist/index.node-DAKJNYp5.js.map +0 -1
- package/dist/publishDraftGraph-CgSLPKvQ.js.map +0 -1
- package/dist/src/client/nodeEndpointDefaults.d.ts +0 -8
- package/dist/src/client/nodeEndpointDefaults.d.ts.map +0 -1
- package/dist/syncDbWithEas-CrAY9Rl2.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { fromCallback, setup, assign, createActor } from 'xstate';
|
|
2
|
-
import {
|
|
3
|
-
import { g as getRefValueType, J as createModelsFromJson, q as listCompleteSchemaFiles,
|
|
2
|
+
import { au as SEED_PROTOCOL_SCHEMA_NAME, B as BaseDb, A as schemas, aM as addSchemaToDb, i as isDataType, M as ModelPropertyDataTypes, ai as generateId, N as addModelsToDb, t as models, r as modelSchemas, v as properties, h as BaseFileManager, aP as loadModelsFromDbForSchema, aQ as mergeDbModelsIntoSchemaModels, aJ as isInternalSchema, aR as clearNameMatchLevels } from './index-CrvIcVFJ.js';
|
|
3
|
+
import { g as getRefValueType, J as createRowsWrittenSignal, K as createModelsFromJson, q as listCompleteSchemaFiles, L as getLatestSchemaVersion, l as loadSchemaFromFile, M as jsonPropertiesToSchemaProperties, u as loadAllSchemasFromDb, m as getClient } from './ClientManager-D6YA20jP.js';
|
|
4
4
|
import { eq, desc, and } from 'drizzle-orm';
|
|
5
5
|
import debug from 'debug';
|
|
6
|
-
import { c as currentEvictionEpoch, w as writeProcessMachine, t as trackDraftSave, M as Model, g as getDraftSaveError, C as ConflictError, r as recordSchemaDestroy, f as finishSchemaDestroy, d as setupEntityLiveQuery } from './errors-
|
|
6
|
+
import { c as currentEvictionEpoch, w as writeProcessMachine, t as trackDraftSave, M as Model, g as getDraftSaveError, C as ConflictError, r as recordSchemaDestroy, f as finishSchemaDestroy, d as setupEntityLiveQuery } from './errors-3tc6XkCB.js';
|
|
7
7
|
import 'pluralize';
|
|
8
8
|
import '@seedprotocol/eas';
|
|
9
|
-
import { SchemaValidationService } from './SchemaValidationService-
|
|
10
|
-
import { D as DEFAULT_READY_TIMEOUT_MS, d as waitForEntityIdle, m as createReactiveProxy, n as findEntity, C as ClientManagerState, _ as clearDestroySubscriptions, o as forceRemoveFromCaches, $ as unloadEntity, q as runDestroyLifecycle } from './Item-
|
|
9
|
+
import { SchemaValidationService } from './SchemaValidationService-DXQ-D531.js';
|
|
10
|
+
import { D as DEFAULT_READY_TIMEOUT_MS, d as waitForEntityIdle, m as createReactiveProxy, n as findEntity, C as ClientManagerState, _ as clearDestroySubscriptions, o as forceRemoveFromCaches, $ as unloadEntity, q as runDestroyLifecycle } from './Item-B1MH0tXx.js';
|
|
11
11
|
|
|
12
12
|
const logger$d = debug('seedSdk:schema:actors:loadOrCreateSchema');
|
|
13
13
|
/**
|
|
@@ -51,7 +51,7 @@ const createModelInstances$2 = async (modelIds, evictionEpoch) => {
|
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
try {
|
|
54
|
-
const _mod_0 = await import('./errors-
|
|
54
|
+
const _mod_0 = await import('./errors-3tc6XkCB.js');
|
|
55
55
|
const _ns_0 = _mod_0.h;
|
|
56
56
|
const modelMod = _ns_0;
|
|
57
57
|
const { Model } = modelMod;
|
|
@@ -168,7 +168,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
168
168
|
// For Seed Protocol, always load from internal file, never create new
|
|
169
169
|
logger$d(`Loading internal Seed Protocol schema from SDK`);
|
|
170
170
|
try {
|
|
171
|
-
const _mod_1 = await import('./ClientManager-
|
|
171
|
+
const _mod_1 = await import('./ClientManager-D6YA20jP.js');
|
|
172
172
|
const _ns_1 = _mod_1.S;
|
|
173
173
|
const internalSchema = _ns_1;
|
|
174
174
|
const schemaFile = internalSchema.default;
|
|
@@ -270,15 +270,17 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
270
270
|
propertyFileIds.set(modelName, propIds);
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
-
// Convert JSON models to Model classes, passing modelFileIds and propertyFileIds so Model instances use correct IDs
|
|
274
|
-
|
|
273
|
+
// Convert JSON models to Model classes, passing modelFileIds and propertyFileIds so Model instances use correct IDs.
|
|
274
|
+
// addModelsToDb below writes their rows; the models adopt them once it has run.
|
|
275
|
+
const rowsWritten = createRowsWrittenSignal();
|
|
276
|
+
const modelDefinitions = await createModelsFromJson(importData, modelFileIds, propertyFileIds, schemaRecord ? rowsWritten.promise : undefined);
|
|
275
277
|
// Add models to database and link them to the schema with schemaFileIds
|
|
276
278
|
if (Object.keys(modelDefinitions).length > 0 && schemaRecord) {
|
|
277
279
|
await addModelsToDb(modelDefinitions, schemaRecord, undefined, {
|
|
278
280
|
schemaFileId: schemaFile.id,
|
|
279
281
|
modelFileIds,
|
|
280
282
|
propertyFileIds,
|
|
281
|
-
});
|
|
283
|
+
}).finally(rowsWritten.settle);
|
|
282
284
|
logger$d(`Added ${Object.keys(modelDefinitions).length} models and their properties to database for Seed Protocol schema`);
|
|
283
285
|
// Verify properties are persisted (important for browser environments)
|
|
284
286
|
// Query the database to get model IDs that were just created
|
|
@@ -415,8 +417,10 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
415
417
|
propertyFileIds.set(modelName, propIds);
|
|
416
418
|
}
|
|
417
419
|
}
|
|
418
|
-
// Convert JSON models to Model classes, passing modelFileIds and propertyFileIds so Model instances use correct IDs
|
|
419
|
-
|
|
420
|
+
// Convert JSON models to Model classes, passing modelFileIds and propertyFileIds so Model instances use correct IDs.
|
|
421
|
+
// addModelsToDb below writes their rows; the models adopt them once it has run.
|
|
422
|
+
const rowsWritten = createRowsWrittenSignal();
|
|
423
|
+
const modelDefinitions = await createModelsFromJson(importData, modelFileIds, propertyFileIds, rowsWritten.promise);
|
|
420
424
|
// Verify all expected models are in modelDefinitions
|
|
421
425
|
const missingFromDefinitions = expectedModelNames.filter(name => !Object.keys(modelDefinitions).includes(name));
|
|
422
426
|
if (missingFromDefinitions.length > 0) {
|
|
@@ -427,7 +431,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
427
431
|
schemaFileId: schemaFile.id,
|
|
428
432
|
modelFileIds,
|
|
429
433
|
propertyFileIds,
|
|
430
|
-
});
|
|
434
|
+
}).finally(rowsWritten.settle);
|
|
431
435
|
logger$d(`Added ${Object.keys(modelDefinitions).length} models and their properties to database for existing Seed Protocol schema`);
|
|
432
436
|
// Small delay to ensure database writes are visible (important for browser environments)
|
|
433
437
|
await new Promise(resolve => setTimeout(resolve, 200));
|
|
@@ -663,7 +667,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
663
667
|
// Ensure models are populated (fallback for seed-protocol if missing)
|
|
664
668
|
if ((!mergedModels || Object.keys(mergedModels).length === 0) && schemaName === 'Seed Protocol') {
|
|
665
669
|
try {
|
|
666
|
-
const _mod_2 = await import('./ClientManager-
|
|
670
|
+
const _mod_2 = await import('./ClientManager-D6YA20jP.js');
|
|
667
671
|
const _ns_2 = _mod_2.S;
|
|
668
672
|
const internalSchema = _ns_2;
|
|
669
673
|
const internalSchemaFile = internalSchema.default;
|
|
@@ -681,40 +685,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
681
685
|
if (Object.keys(dbModels).length > 0) {
|
|
682
686
|
logger$d(`Found ${Object.keys(dbModels).length} models in database for schema ${schemaName}: ${Object.keys(dbModels).join(', ')}`);
|
|
683
687
|
// Merge: database models take precedence for properties, but preserve schemaData models for full structure
|
|
684
|
-
mergedModels =
|
|
685
|
-
...mergedModels,
|
|
686
|
-
...dbModels,
|
|
687
|
-
};
|
|
688
|
-
// For models that exist in both, merge properties (database properties override)
|
|
689
|
-
// When a property was renamed in DB, schemaData has old name and DB has new name (same schemaFileId).
|
|
690
|
-
// Remove schemaData properties whose id matches a DB property's schemaFileId to avoid duplicates.
|
|
691
|
-
for (const [modelName, dbModel] of Object.entries(dbModels)) {
|
|
692
|
-
if (mergedModels[modelName]) {
|
|
693
|
-
const schemaDataProps = mergedModels[modelName].properties || {};
|
|
694
|
-
const dbProps = dbModel.properties || {};
|
|
695
|
-
const dbSchemaFileIds = new Set();
|
|
696
|
-
for (const dbProp of Object.values(dbProps)) {
|
|
697
|
-
if (dbProp.schemaFileId) {
|
|
698
|
-
dbSchemaFileIds.add(dbProp.schemaFileId);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
const filteredSchemaDataProps = {};
|
|
702
|
-
for (const [propName, prop] of Object.entries(schemaDataProps)) {
|
|
703
|
-
const propId = prop.id || prop.schemaFileId;
|
|
704
|
-
if (propId && dbSchemaFileIds.has(propId)) {
|
|
705
|
-
continue;
|
|
706
|
-
}
|
|
707
|
-
filteredSchemaDataProps[propName] = prop;
|
|
708
|
-
}
|
|
709
|
-
mergedModels[modelName] = {
|
|
710
|
-
...mergedModels[modelName],
|
|
711
|
-
properties: {
|
|
712
|
-
...filteredSchemaDataProps,
|
|
713
|
-
...dbProps,
|
|
714
|
-
},
|
|
715
|
-
};
|
|
716
|
-
}
|
|
717
|
-
}
|
|
688
|
+
mergedModels = mergeDbModelsIntoSchemaModels(mergedModels, dbModels);
|
|
718
689
|
}
|
|
719
690
|
}
|
|
720
691
|
// Create new schemaFile object with merged models (read-only approach)
|
|
@@ -781,40 +752,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
781
752
|
logger$d(`Found ${Object.keys(dbModels).length} models in database for draft schema ${schemaName}: ${Object.keys(dbModels).join(', ')}`);
|
|
782
753
|
// Merge: database models take precedence for properties, but preserve schemaData models for full structure
|
|
783
754
|
let mergedModels = { ...(schemaFile.models || {}) };
|
|
784
|
-
mergedModels =
|
|
785
|
-
...mergedModels,
|
|
786
|
-
...dbModels,
|
|
787
|
-
};
|
|
788
|
-
// For models that exist in both, merge properties (database properties override)
|
|
789
|
-
// When a property was renamed in DB, schemaData has old name and DB has new name (same schemaFileId).
|
|
790
|
-
// Remove schemaData properties whose id matches a DB property's schemaFileId to avoid duplicates.
|
|
791
|
-
for (const [modelName, dbModel] of Object.entries(dbModels)) {
|
|
792
|
-
if (mergedModels[modelName]) {
|
|
793
|
-
const schemaDataProps = mergedModels[modelName].properties || {};
|
|
794
|
-
const dbProps = dbModel.properties || {};
|
|
795
|
-
const dbSchemaFileIds = new Set();
|
|
796
|
-
for (const dbProp of Object.values(dbProps)) {
|
|
797
|
-
if (dbProp.schemaFileId) {
|
|
798
|
-
dbSchemaFileIds.add(dbProp.schemaFileId);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
const filteredSchemaDataProps = {};
|
|
802
|
-
for (const [propName, prop] of Object.entries(schemaDataProps)) {
|
|
803
|
-
const propId = prop.id || prop.schemaFileId;
|
|
804
|
-
if (propId && dbSchemaFileIds.has(propId)) {
|
|
805
|
-
continue;
|
|
806
|
-
}
|
|
807
|
-
filteredSchemaDataProps[propName] = prop;
|
|
808
|
-
}
|
|
809
|
-
mergedModels[modelName] = {
|
|
810
|
-
...mergedModels[modelName],
|
|
811
|
-
properties: {
|
|
812
|
-
...filteredSchemaDataProps,
|
|
813
|
-
...dbProps,
|
|
814
|
-
},
|
|
815
|
-
};
|
|
816
|
-
}
|
|
817
|
-
}
|
|
755
|
+
mergedModels = mergeDbModelsIntoSchemaModels(mergedModels, dbModels);
|
|
818
756
|
// Update schemaFile with merged models
|
|
819
757
|
schemaFile.models = mergedModels;
|
|
820
758
|
}
|
|
@@ -894,7 +832,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
894
832
|
// Ensure models are populated (fallback for seed-protocol if missing)
|
|
895
833
|
if ((!mergedModels || Object.keys(mergedModels).length === 0) && schemaName === 'Seed Protocol') {
|
|
896
834
|
try {
|
|
897
|
-
const _mod_3 = await import('./ClientManager-
|
|
835
|
+
const _mod_3 = await import('./ClientManager-D6YA20jP.js');
|
|
898
836
|
const _ns_3 = _mod_3.S;
|
|
899
837
|
const internalSchema = _ns_3;
|
|
900
838
|
const internalSchemaFile = internalSchema.default;
|
|
@@ -912,40 +850,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
912
850
|
if (Object.keys(dbModels).length > 0) {
|
|
913
851
|
logger$d(`Found ${Object.keys(dbModels).length} models in database for schema ${schemaName}: ${Object.keys(dbModels).join(', ')}`);
|
|
914
852
|
// Merge: database models take precedence for properties, but preserve file models for full structure
|
|
915
|
-
mergedModels =
|
|
916
|
-
...mergedModels,
|
|
917
|
-
...dbModels,
|
|
918
|
-
};
|
|
919
|
-
// For models that exist in both, merge properties (database properties override)
|
|
920
|
-
// When a property was renamed in DB, schemaData has old name and DB has new name (same schemaFileId).
|
|
921
|
-
// Remove schemaData properties whose id matches a DB property's schemaFileId to avoid duplicates.
|
|
922
|
-
for (const [modelName, dbModel] of Object.entries(dbModels)) {
|
|
923
|
-
if (mergedModels[modelName]) {
|
|
924
|
-
const schemaDataProps = mergedModels[modelName].properties || {};
|
|
925
|
-
const dbProps = dbModel.properties || {};
|
|
926
|
-
const dbSchemaFileIds = new Set();
|
|
927
|
-
for (const dbProp of Object.values(dbProps)) {
|
|
928
|
-
if (dbProp.schemaFileId) {
|
|
929
|
-
dbSchemaFileIds.add(dbProp.schemaFileId);
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
const filteredSchemaDataProps = {};
|
|
933
|
-
for (const [propName, prop] of Object.entries(schemaDataProps)) {
|
|
934
|
-
const propId = prop.id || prop.schemaFileId;
|
|
935
|
-
if (propId && dbSchemaFileIds.has(propId)) {
|
|
936
|
-
continue;
|
|
937
|
-
}
|
|
938
|
-
filteredSchemaDataProps[propName] = prop;
|
|
939
|
-
}
|
|
940
|
-
mergedModels[modelName] = {
|
|
941
|
-
...mergedModels[modelName],
|
|
942
|
-
properties: {
|
|
943
|
-
...filteredSchemaDataProps,
|
|
944
|
-
...dbProps,
|
|
945
|
-
},
|
|
946
|
-
};
|
|
947
|
-
}
|
|
948
|
-
}
|
|
853
|
+
mergedModels = mergeDbModelsIntoSchemaModels(mergedModels, dbModels);
|
|
949
854
|
}
|
|
950
855
|
}
|
|
951
856
|
// Create new schemaFile object with merged models (read-only approach)
|
|
@@ -985,7 +890,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
985
890
|
// Ensure models are populated (fallback for seed-protocol if missing)
|
|
986
891
|
if ((!mergedModels || Object.keys(mergedModels).length === 0) && schemaName === 'Seed Protocol') {
|
|
987
892
|
try {
|
|
988
|
-
const _mod_4 = await import('./ClientManager-
|
|
893
|
+
const _mod_4 = await import('./ClientManager-D6YA20jP.js');
|
|
989
894
|
const _ns_4 = _mod_4.S;
|
|
990
895
|
const internalSchema = _ns_4;
|
|
991
896
|
const internalSchemaFile = internalSchema.default;
|
|
@@ -1003,40 +908,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1003
908
|
if (Object.keys(dbModels).length > 0) {
|
|
1004
909
|
logger$d(`Found ${Object.keys(dbModels).length} models in database for schema ${schemaName}: ${Object.keys(dbModels).join(', ')}`);
|
|
1005
910
|
// Merge: database models take precedence for properties, but preserve schemaData models for full structure
|
|
1006
|
-
mergedModels =
|
|
1007
|
-
...mergedModels,
|
|
1008
|
-
...dbModels,
|
|
1009
|
-
};
|
|
1010
|
-
// For models that exist in both, merge properties (database properties override)
|
|
1011
|
-
// When a property was renamed in DB, schemaData has old name and DB has new name (same schemaFileId).
|
|
1012
|
-
// Remove schemaData properties whose id matches a DB property's schemaFileId to avoid duplicates.
|
|
1013
|
-
for (const [modelName, dbModel] of Object.entries(dbModels)) {
|
|
1014
|
-
if (mergedModels[modelName]) {
|
|
1015
|
-
const schemaDataProps = mergedModels[modelName].properties || {};
|
|
1016
|
-
const dbProps = dbModel.properties || {};
|
|
1017
|
-
const dbSchemaFileIds = new Set();
|
|
1018
|
-
for (const dbProp of Object.values(dbProps)) {
|
|
1019
|
-
if (dbProp.schemaFileId) {
|
|
1020
|
-
dbSchemaFileIds.add(dbProp.schemaFileId);
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
const filteredSchemaDataProps = {};
|
|
1024
|
-
for (const [propName, prop] of Object.entries(schemaDataProps)) {
|
|
1025
|
-
const propId = prop.id || prop.schemaFileId;
|
|
1026
|
-
if (propId && dbSchemaFileIds.has(propId)) {
|
|
1027
|
-
continue;
|
|
1028
|
-
}
|
|
1029
|
-
filteredSchemaDataProps[propName] = prop;
|
|
1030
|
-
}
|
|
1031
|
-
mergedModels[modelName] = {
|
|
1032
|
-
...mergedModels[modelName],
|
|
1033
|
-
properties: {
|
|
1034
|
-
...filteredSchemaDataProps,
|
|
1035
|
-
...dbProps,
|
|
1036
|
-
},
|
|
1037
|
-
};
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
911
|
+
mergedModels = mergeDbModelsIntoSchemaModels(mergedModels, dbModels);
|
|
1040
912
|
}
|
|
1041
913
|
}
|
|
1042
914
|
// Create new schemaFile object with merged models (read-only approach)
|
|
@@ -1073,7 +945,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1073
945
|
// If schemaData is missing, try to load from internal schema file for seed-protocol
|
|
1074
946
|
if (!dbSchema.schemaData && schemaName === 'Seed Protocol') {
|
|
1075
947
|
try {
|
|
1076
|
-
const _mod_5 = await import('./ClientManager-
|
|
948
|
+
const _mod_5 = await import('./ClientManager-D6YA20jP.js');
|
|
1077
949
|
const _ns_5 = _mod_5.S;
|
|
1078
950
|
const internalSchema = _ns_5;
|
|
1079
951
|
const schemaFile = internalSchema.default;
|
|
@@ -1184,7 +1056,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1184
1056
|
// Ensure models are populated (fallback for seed-protocol if missing)
|
|
1185
1057
|
if ((!mergedModels || Object.keys(mergedModels).length === 0) && schemaName === 'Seed Protocol') {
|
|
1186
1058
|
try {
|
|
1187
|
-
const _mod_6 = await import('./ClientManager-
|
|
1059
|
+
const _mod_6 = await import('./ClientManager-D6YA20jP.js');
|
|
1188
1060
|
const _ns_6 = _mod_6.S;
|
|
1189
1061
|
const internalSchema = _ns_6;
|
|
1190
1062
|
const internalSchemaFile = internalSchema.default;
|
|
@@ -1511,7 +1383,7 @@ const createModelInstances$1 = async (modelIds, evictionEpoch) => {
|
|
|
1511
1383
|
return;
|
|
1512
1384
|
}
|
|
1513
1385
|
try {
|
|
1514
|
-
const _mod_7 = await import('./errors-
|
|
1386
|
+
const _mod_7 = await import('./errors-3tc6XkCB.js');
|
|
1515
1387
|
const _ns_7 = _mod_7.h;
|
|
1516
1388
|
const mod = _ns_7;
|
|
1517
1389
|
const Model = mod?.Model ?? mod?.default;
|
|
@@ -1560,7 +1432,7 @@ const checkExistingSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1560
1432
|
if (isInternal && schemaName === SEED_PROTOCOL_SCHEMA_NAME) {
|
|
1561
1433
|
// For Seed Protocol, check if it exists in database
|
|
1562
1434
|
try {
|
|
1563
|
-
const _mod_8 = await import('./ClientManager-
|
|
1435
|
+
const _mod_8 = await import('./ClientManager-D6YA20jP.js');
|
|
1564
1436
|
const _ns_8 = _mod_8.S;
|
|
1565
1437
|
const internalSchema = _ns_8;
|
|
1566
1438
|
const schemaFile = internalSchema.default;
|
|
@@ -1702,20 +1574,7 @@ const checkExistingSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1702
1574
|
if (dbSchema.id) {
|
|
1703
1575
|
const dbModels = await loadModelsFromDbForSchema(dbSchema.id);
|
|
1704
1576
|
if (Object.keys(dbModels).length > 0) {
|
|
1705
|
-
|
|
1706
|
-
mergedModels = { ...mergedModels, ...dbModels };
|
|
1707
|
-
for (const [modelName, dbModel] of Object.entries(dbModels)) {
|
|
1708
|
-
if (mergedModels[modelName]) {
|
|
1709
|
-
mergedModels[modelName] = {
|
|
1710
|
-
...mergedModels[modelName],
|
|
1711
|
-
properties: {
|
|
1712
|
-
...mergedModels[modelName].properties,
|
|
1713
|
-
...dbModel.properties,
|
|
1714
|
-
},
|
|
1715
|
-
};
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
schemaFile.models = mergedModels;
|
|
1577
|
+
schemaFile.models = mergeDbModelsIntoSchemaModels(schemaFile.models, dbModels);
|
|
1719
1578
|
}
|
|
1720
1579
|
}
|
|
1721
1580
|
}
|
|
@@ -1758,20 +1617,7 @@ const checkExistingSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1758
1617
|
if (schemaFile && dbSchema.id) {
|
|
1759
1618
|
const dbModels = await loadModelsFromDbForSchema(dbSchema.id);
|
|
1760
1619
|
if (Object.keys(dbModels).length > 0) {
|
|
1761
|
-
|
|
1762
|
-
mergedModels = { ...mergedModels, ...dbModels };
|
|
1763
|
-
for (const [modelName, dbModel] of Object.entries(dbModels)) {
|
|
1764
|
-
if (mergedModels[modelName]) {
|
|
1765
|
-
mergedModels[modelName] = {
|
|
1766
|
-
...mergedModels[modelName],
|
|
1767
|
-
properties: {
|
|
1768
|
-
...mergedModels[modelName].properties,
|
|
1769
|
-
...dbModel.properties,
|
|
1770
|
-
},
|
|
1771
|
-
};
|
|
1772
|
-
}
|
|
1773
|
-
}
|
|
1774
|
-
schemaFile.models = mergedModels;
|
|
1620
|
+
schemaFile.models = mergeDbModelsIntoSchemaModels(schemaFile.models, dbModels);
|
|
1775
1621
|
}
|
|
1776
1622
|
}
|
|
1777
1623
|
}
|
|
@@ -1922,7 +1768,7 @@ const writeSchemaToDb = fromCallback(({ sendBack, input }) => {
|
|
|
1922
1768
|
if (isInternal && schemaName === SEED_PROTOCOL_SCHEMA_NAME) {
|
|
1923
1769
|
// For Seed Protocol, load from internal file
|
|
1924
1770
|
logger$b(`Loading internal Seed Protocol schema from SDK`);
|
|
1925
|
-
const _mod_9 = await import('./ClientManager-
|
|
1771
|
+
const _mod_9 = await import('./ClientManager-D6YA20jP.js');
|
|
1926
1772
|
const _ns_9 = _mod_9.S;
|
|
1927
1773
|
const internalSchema = _ns_9;
|
|
1928
1774
|
finalSchema = internalSchema.default;
|
|
@@ -2247,15 +2093,17 @@ const writeModelsToDb = fromCallback(({ sendBack, input }) => {
|
|
|
2247
2093
|
propertyFileIds.set(modelName, propIds);
|
|
2248
2094
|
}
|
|
2249
2095
|
}
|
|
2250
|
-
// Convert JSON models to Model classes
|
|
2251
|
-
|
|
2096
|
+
// Convert JSON models to Model classes. addModelsToDb below writes their rows; the models adopt them
|
|
2097
|
+
// once it has run.
|
|
2098
|
+
const rowsWritten = createRowsWrittenSignal();
|
|
2099
|
+
const modelDefinitions = await createModelsFromJson(importData, modelFileIds, propertyFileIds, rowsWritten.promise);
|
|
2252
2100
|
// Add models to database
|
|
2253
2101
|
if (Object.keys(modelDefinitions).length > 0) {
|
|
2254
2102
|
await addModelsToDb(modelDefinitions, schemaRecord, undefined, {
|
|
2255
2103
|
schemaFileId: schema.id,
|
|
2256
2104
|
modelFileIds,
|
|
2257
2105
|
propertyFileIds,
|
|
2258
|
-
});
|
|
2106
|
+
}).finally(rowsWritten.settle);
|
|
2259
2107
|
logger$9(`Added ${Object.keys(modelDefinitions).length} models and their properties to database`);
|
|
2260
2108
|
}
|
|
2261
2109
|
// Extract model IDs that were written
|
|
@@ -2393,7 +2241,7 @@ const createModelInstances = fromCallback(({ sendBack, input }) => {
|
|
|
2393
2241
|
return;
|
|
2394
2242
|
}
|
|
2395
2243
|
try {
|
|
2396
|
-
const _mod_10 = await import('./errors-
|
|
2244
|
+
const _mod_10 = await import('./errors-3tc6XkCB.js');
|
|
2397
2245
|
const _ns_10 = _mod_10.h;
|
|
2398
2246
|
const modelMod = _ns_10;
|
|
2399
2247
|
const { Model } = modelMod;
|
|
@@ -2482,7 +2330,7 @@ const verifyModelInstancesInCache = fromCallback(({ sendBack, input }) => {
|
|
|
2482
2330
|
}
|
|
2483
2331
|
try {
|
|
2484
2332
|
const result = await verifyWithRetry$2(async () => {
|
|
2485
|
-
const _mod_11 = await import('./errors-
|
|
2333
|
+
const _mod_11 = await import('./errors-3tc6XkCB.js');
|
|
2486
2334
|
const _ns_11 = _mod_11.h;
|
|
2487
2335
|
const modelMod = _ns_11;
|
|
2488
2336
|
const { Model } = modelMod;
|
|
@@ -2541,8 +2389,8 @@ const writePropertiesToDb = fromCallback(({ sendBack, input }) => {
|
|
|
2541
2389
|
const _write = async () => {
|
|
2542
2390
|
const { modelIds } = input;
|
|
2543
2391
|
try {
|
|
2544
|
-
const _mod_12 = await import('./
|
|
2545
|
-
const _ns_12 = _mod_12.
|
|
2392
|
+
const _mod_12 = await import('./index-CrvIcVFJ.js');
|
|
2393
|
+
const _ns_12 = _mod_12.bd;
|
|
2546
2394
|
const modelSchemaMod = _ns_12;
|
|
2547
2395
|
const { models: modelsTable, properties: propertiesTable } = modelSchemaMod;
|
|
2548
2396
|
const drizzleMod = await import('drizzle-orm');
|
|
@@ -2731,9 +2579,9 @@ const createPropertyInstances = fromCallback(({ sendBack, input }) => {
|
|
|
2731
2579
|
return;
|
|
2732
2580
|
}
|
|
2733
2581
|
try {
|
|
2734
|
-
const modProp = await import('./ModelProperty-
|
|
2582
|
+
const modProp = await import('./ModelProperty-Dw6dHdu_.js');
|
|
2735
2583
|
const ModelProperty = modProp?.ModelProperty ?? modProp?.default;
|
|
2736
|
-
const _mod_13 = await import('./errors-
|
|
2584
|
+
const _mod_13 = await import('./errors-3tc6XkCB.js');
|
|
2737
2585
|
const _ns_13 = _mod_13.h;
|
|
2738
2586
|
const modModel = _ns_13;
|
|
2739
2587
|
const Model = modModel?.Model ?? modModel?.default;
|
|
@@ -2840,7 +2688,7 @@ const verifyPropertyInstancesInCache = fromCallback(({ sendBack, input }) => {
|
|
|
2840
2688
|
}
|
|
2841
2689
|
try {
|
|
2842
2690
|
const result = await verifyWithRetry(async () => {
|
|
2843
|
-
const mod = await import('./ModelProperty-
|
|
2691
|
+
const mod = await import('./ModelProperty-Dw6dHdu_.js');
|
|
2844
2692
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
2845
2693
|
if (!ModelProperty) {
|
|
2846
2694
|
throw new Error('ModelProperty not available from dynamic import');
|
|
@@ -3848,8 +3696,6 @@ async function loadSchemaWithRenames(schemaFilePath, modelRenames) {
|
|
|
3848
3696
|
propertyFileIds.set(modelName, propIds);
|
|
3849
3697
|
}
|
|
3850
3698
|
}
|
|
3851
|
-
// Convert JSON models to Model classes, passing modelFileIds and propertyFileIds so Model instances use correct IDs
|
|
3852
|
-
const modelDefinitions = await createModelsFromJson(importData, modelFileIds, propertyFileIds);
|
|
3853
3699
|
// Convert schema file metadata to schema input for database
|
|
3854
3700
|
const schemaInput = {
|
|
3855
3701
|
name: schemaName,
|
|
@@ -3862,8 +3708,8 @@ async function loadSchemaWithRenames(schemaFilePath, modelRenames) {
|
|
|
3862
3708
|
updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
|
|
3863
3709
|
};
|
|
3864
3710
|
// Use dynamic import to break circular dependency
|
|
3865
|
-
const _mod_14 = await import('./
|
|
3866
|
-
const _ns_14 = _mod_14.
|
|
3711
|
+
const _mod_14 = await import('./index-CrvIcVFJ.js');
|
|
3712
|
+
const _ns_14 = _mod_14.bi;
|
|
3867
3713
|
const dbMod = _ns_14;
|
|
3868
3714
|
const { addSchemaToDb, addModelsToDb } = dbMod;
|
|
3869
3715
|
// Add schema to database with schemaFileId
|
|
@@ -3874,13 +3720,17 @@ async function loadSchemaWithRenames(schemaFilePath, modelRenames) {
|
|
|
3874
3720
|
modelName,
|
|
3875
3721
|
jsonPropertiesToSchemaProperties(modelName, modelDef, propertyFileIds.get(modelName)),
|
|
3876
3722
|
]));
|
|
3723
|
+
// Convert JSON models to Model classes, passing modelFileIds and propertyFileIds so Model instances use correct IDs.
|
|
3724
|
+
// addModelsToDb below writes their rows; the models adopt them once it has run.
|
|
3725
|
+
const rowsWritten = createRowsWrittenSignal();
|
|
3726
|
+
const modelDefinitions = await createModelsFromJson(importData, modelFileIds, propertyFileIds, rowsWritten.promise);
|
|
3877
3727
|
// Add models to database with model renames handled and schemaFileIds
|
|
3878
3728
|
await addModelsToDb(modelDefinitions, schemaRecord, modelRenames, {
|
|
3879
3729
|
schemaFileId: schemaFile.id,
|
|
3880
3730
|
modelFileIds,
|
|
3881
3731
|
propertyFileIds,
|
|
3882
3732
|
propertyDefinitions,
|
|
3883
|
-
});
|
|
3733
|
+
}).finally(rowsWritten.settle);
|
|
3884
3734
|
// Models are now Model instances, no registration needed
|
|
3885
3735
|
// They should be created via Model.create() and are accessible via Model static methods
|
|
3886
3736
|
for (const [modelName] of Object.entries(modelDefinitions)) {
|
|
@@ -3982,8 +3832,8 @@ async function renameModelProperty(schemaName, modelName, oldPropertyName, newPr
|
|
|
3982
3832
|
await BaseFileManager.waitForFileWithContent(newFilePath);
|
|
3983
3833
|
logger$1(`Renamed property ${oldPropertyName} to ${newPropertyName} in schema ${schemaName} v${newVersion}`);
|
|
3984
3834
|
// Migrate metadata rows so ItemProperty values follow the new name (prevents duplicate ItemProperties)
|
|
3985
|
-
const _mod_15 = await import('./
|
|
3986
|
-
const _ns_15 = _mod_15.
|
|
3835
|
+
const _mod_15 = await import('./index-CrvIcVFJ.js');
|
|
3836
|
+
const _ns_15 = _mod_15.bi;
|
|
3987
3837
|
const { migrateMetadataForPropertyRename } = _ns_15;
|
|
3988
3838
|
const migratedCount = await migrateMetadataForPropertyRename(modelName, oldPropertyName, newPropertyName, oldProperty.id, { schemaName });
|
|
3989
3839
|
if (migratedCount > 0) {
|
|
@@ -4979,7 +4829,7 @@ class Schema {
|
|
|
4979
4829
|
const modelDbId = modelInstance.getService().getSnapshot().context._dbId;
|
|
4980
4830
|
const db = BaseDb.getAppDb();
|
|
4981
4831
|
if (propertyContexts.length === 0 && modelDbId && db) {
|
|
4982
|
-
const { ModelProperty } = await import('./ModelProperty-
|
|
4832
|
+
const { ModelProperty } = await import('./ModelProperty-Dw6dHdu_.js');
|
|
4983
4833
|
const rows = await db.select().from(properties).where(eq(properties.modelId, modelDbId));
|
|
4984
4834
|
propertyContexts = rows.map((row) => {
|
|
4985
4835
|
const cached = row.schemaFileId ? ModelProperty.getById(row.schemaFileId) : undefined;
|
|
@@ -5145,7 +4995,7 @@ class Schema {
|
|
|
5145
4995
|
savedSchema: publishedSchema,
|
|
5146
4996
|
});
|
|
5147
4997
|
// Clear edited flags on all ModelProperty instances and in database
|
|
5148
|
-
const modelPropertyMod = await import('./ModelProperty-
|
|
4998
|
+
const modelPropertyMod = await import('./ModelProperty-Dw6dHdu_.js');
|
|
5149
4999
|
const { ModelProperty } = modelPropertyMod;
|
|
5150
5000
|
for (const propertyKey of context._editedProperties) {
|
|
5151
5001
|
const [modelName, propertyName] = propertyKey.split(':');
|
|
@@ -5169,8 +5019,8 @@ class Schema {
|
|
|
5169
5019
|
try {
|
|
5170
5020
|
if (db && modelName && propertyName) {
|
|
5171
5021
|
// Find this schema's model by name
|
|
5172
|
-
const _mod_16 = await import('./
|
|
5173
|
-
const _ns_16 = _mod_16.
|
|
5022
|
+
const _mod_16 = await import('./index-CrvIcVFJ.js');
|
|
5023
|
+
const _ns_16 = _mod_16.bh;
|
|
5174
5024
|
const { resolveModelRecord } = _ns_16;
|
|
5175
5025
|
const modelRecord = await resolveModelRecord(modelName, { schemaName: thisSchemaName }, db);
|
|
5176
5026
|
const modelRecords = modelRecord ? [modelRecord] : [];
|
|
@@ -5799,10 +5649,10 @@ class Schema {
|
|
|
5799
5649
|
// instances too, or a re-import would get them back with dangling _dbIds.
|
|
5800
5650
|
if (schemaName) {
|
|
5801
5651
|
const evictedModelNames = Model.evictForSchema(schemaName);
|
|
5802
|
-
const { ModelProperty } = await import('./ModelProperty-
|
|
5652
|
+
const { ModelProperty } = await import('./ModelProperty-Dw6dHdu_.js');
|
|
5803
5653
|
ModelProperty.evictForModels(evictedModelNames, schemaName);
|
|
5804
5654
|
// Evicting stops new writes but not ones already running; let those land before deleting their rows
|
|
5805
|
-
const _mod_17 = await import('./errors-
|
|
5655
|
+
const _mod_17 = await import('./errors-3tc6XkCB.js');
|
|
5806
5656
|
const _ns_17 = _mod_17.e;
|
|
5807
5657
|
const { waitForInFlightWrites } = _ns_17;
|
|
5808
5658
|
await waitForInFlightWrites();
|
|
@@ -5835,7 +5685,7 @@ class Schema {
|
|
|
5835
5685
|
.map((r) => r.modelId)
|
|
5836
5686
|
.filter((id) => id != null)),
|
|
5837
5687
|
];
|
|
5838
|
-
const { detachModelRows } = await import('./detachRowsBeforeDelete-
|
|
5688
|
+
const { detachModelRows } = await import('./detachRowsBeforeDelete-CtmIFpgV.js');
|
|
5839
5689
|
await detachModelRows(db, modelIds);
|
|
5840
5690
|
await db.delete(modelSchemas).where(inArray(modelSchemas.schemaId, schemaIds));
|
|
5841
5691
|
for (const modelId of modelIds) {
|
|
@@ -5850,8 +5700,8 @@ class Schema {
|
|
|
5850
5700
|
// the destroyed schema back on the next Schema.all().
|
|
5851
5701
|
// Match on name as well as id: versions imported from complete schema files can each
|
|
5852
5702
|
// have their own id, and any version left behind would bring the schema back.
|
|
5853
|
-
const _mod_18 = await import('./ClientManager-
|
|
5854
|
-
const _ns_18 = _mod_18.
|
|
5703
|
+
const _mod_18 = await import('./ClientManager-D6YA20jP.js');
|
|
5704
|
+
const _ns_18 = _mod_18.N;
|
|
5855
5705
|
const { listCompleteSchemaFiles } = _ns_18;
|
|
5856
5706
|
const files = await listCompleteSchemaFiles().catch(() => []);
|
|
5857
5707
|
const fs = await BaseFileManager.getFs();
|
|
@@ -6046,4 +5896,4 @@ var Schema$1 = /*#__PURE__*/Object.freeze({
|
|
|
6046
5896
|
});
|
|
6047
5897
|
|
|
6048
5898
|
export { Schema as S, deletePropertyFromModel as a, Schema$1 as b, deleteModelFromSchema as d, renameModelProperty as r, schemaMachine as s, updateModelProperties as u };
|
|
6049
|
-
//# sourceMappingURL=Schema-
|
|
5899
|
+
//# sourceMappingURL=Schema-DppObO6h.js.map
|