@seedprotocol/sdk 0.7.7 → 0.7.8-next.1034.g2acd2a2
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-2GtDWHq6.js → ClientManager-DBKvmJov.js} +64 -36
- package/dist/ClientManager-DBKvmJov.js.map +1 -0
- package/dist/{Item-D6j0IvBP.js → Item-BiMHgg-_.js} +539 -486
- package/dist/Item-BiMHgg-_.js.map +1 -0
- package/dist/{ModelProperty-B52C3CQ2.js → ModelProperty-C1Fzcnbm.js} +50 -51
- package/dist/ModelProperty-C1Fzcnbm.js.map +1 -0
- package/dist/{Schema-O1QLoXv6.js → Schema-COTbavcm.js} +97 -82
- package/dist/Schema-COTbavcm.js.map +1 -0
- package/dist/{SchemaValidationService-BxCbfDaI.js → SchemaValidationService-paOfbcwd.js} +6 -6
- package/dist/{SchemaValidationService-BxCbfDaI.js.map → SchemaValidationService-paOfbcwd.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-CzSbuucw.js → backfillMetadataPropertyIds-BkpBahbz.js} +3 -3
- package/dist/{backfillMetadataPropertyIds-CzSbuucw.js.map → backfillMetadataPropertyIds-BkpBahbz.js.map} +1 -1
- package/dist/{configurePlatform-Bbpw_R4y.js → configurePlatform-_XR45RnJ.js} +2 -2
- package/dist/{configurePlatform-Bbpw_R4y.js.map → configurePlatform-_XR45RnJ.js.map} +1 -1
- package/dist/{detachRowsBeforeDelete-D1TyEMco.js → detachRowsBeforeDelete-C1iapUFl.js} +2 -2
- package/dist/{detachRowsBeforeDelete-D1TyEMco.js.map → detachRowsBeforeDelete-C1iapUFl.js.map} +1 -1
- package/dist/{discardNewDraft-hiVaUVjV.js → discardNewDraft-D4nrwp3T.js} +5 -5
- package/dist/{discardNewDraft-hiVaUVjV.js.map → discardNewDraft-D4nrwp3T.js.map} +1 -1
- package/dist/dist/{ClientManager-2GtDWHq6.d.ts → ClientManager-DBKvmJov.d.ts} +20 -1
- package/dist/dist/ClientManager-DBKvmJov.d.ts.map +1 -0
- package/dist/dist/{Item-D6j0IvBP.d.ts → Item-BiMHgg-_.d.ts} +146 -85
- package/dist/dist/Item-BiMHgg-_.d.ts.map +1 -0
- package/dist/dist/{ModelProperty-B52C3CQ2.d.ts → ModelProperty-C1Fzcnbm.d.ts} +1 -1
- package/dist/dist/{ModelProperty-B52C3CQ2.d.ts.map → ModelProperty-C1Fzcnbm.d.ts.map} +1 -1
- package/dist/dist/{Schema-O1QLoXv6.d.ts → Schema-COTbavcm.d.ts} +11 -4
- package/dist/dist/Schema-COTbavcm.d.ts.map +1 -0
- package/dist/dist/{SchemaValidationService-BxCbfDaI.d.ts → SchemaValidationService-paOfbcwd.d.ts} +1 -1
- package/dist/dist/{SchemaValidationService-BxCbfDaI.d.ts.map → SchemaValidationService-paOfbcwd.d.ts.map} +1 -1
- package/dist/dist/{backfillMetadataPropertyIds-CzSbuucw.d.ts → backfillMetadataPropertyIds-BkpBahbz.d.ts} +1 -1
- package/dist/dist/backfillMetadataPropertyIds-BkpBahbz.d.ts.map +1 -0
- package/dist/dist/{configurePlatform-Bbpw_R4y.d.ts → configurePlatform-_XR45RnJ.d.ts} +1 -1
- package/dist/dist/configurePlatform-_XR45RnJ.d.ts.map +1 -0
- package/dist/dist/{detachRowsBeforeDelete-D1TyEMco.d.ts → detachRowsBeforeDelete-C1iapUFl.d.ts} +1 -1
- package/dist/dist/detachRowsBeforeDelete-C1iapUFl.d.ts.map +1 -0
- package/dist/dist/{discardNewDraft-hiVaUVjV.d.ts → discardNewDraft-D4nrwp3T.d.ts} +1 -1
- package/dist/dist/discardNewDraft-D4nrwp3T.d.ts.map +1 -0
- package/dist/dist/{eas-DOdj-EMK.d.ts → eas-BRVEGT97.d.ts} +1 -1
- package/dist/dist/eas-BRVEGT97.d.ts.map +1 -0
- package/dist/dist/{errors-KM-yq2MD.d.ts → errors-CQagdED2.d.ts} +39 -24
- package/dist/dist/errors-CQagdED2.d.ts.map +1 -0
- package/dist/dist/{getItem-Bh0zv-o1.d.ts → getItem-Jpr1SKIL.d.ts} +1 -1
- package/dist/dist/getItem-Jpr1SKIL.d.ts.map +1 -0
- package/dist/dist/{getPublishPayload-oH8wJhnH.d.ts → getPublishPayload-Bmeqtq4l.d.ts} +1 -1
- package/dist/dist/{getPublishPayload-oH8wJhnH.d.ts.map → getPublishPayload-Bmeqtq4l.d.ts.map} +1 -1
- package/dist/dist/{getPublishUploads-Cex-NBe6.d.ts → getPublishUploads-7nW1kMZV.d.ts} +1 -1
- package/dist/dist/{getPublishUploads-Cex-NBe6.d.ts.map → getPublishUploads-7nW1kMZV.d.ts.map} +1 -1
- package/dist/dist/{index-BbFwftAv.d.ts → index-3_hGVu7v.d.ts} +1 -1
- package/dist/dist/{index-BbFwftAv.d.ts.map → index-3_hGVu7v.d.ts.map} +1 -1
- package/dist/dist/{index-DpgQMIRq.d.ts → index-C-NqjjY_.d.ts} +11 -5
- package/dist/dist/index-C-NqjjY_.d.ts.map +1 -0
- package/dist/dist/{index-BAao3_Po.d.ts → index-DM3zrNtX.d.ts} +5 -5
- package/dist/dist/index-DM3zrNtX.d.ts.map +1 -0
- package/dist/dist/{index.browser-nndbVM7z.d.ts → index.browser-DGoOSs1J.d.ts} +1 -1
- package/dist/dist/{index.browser-nndbVM7z.d.ts.map → index.browser-DGoOSs1J.d.ts.map} +1 -1
- package/dist/dist/{index.node-BUfx-JaP.d.ts → index.node-CTv62R2a.d.ts} +1 -1
- package/dist/dist/{index.node-BUfx-JaP.d.ts.map → index.node-CTv62R2a.d.ts.map} +1 -1
- package/dist/dist/platform.browser.d.ts +2 -2
- package/dist/dist/platform.node.d.ts +2 -2
- package/dist/dist/{property-BDBvImLs.d.ts → property-DaUy4XMe.d.ts} +3 -3
- package/dist/dist/property-DaUy4XMe.d.ts.map +1 -0
- package/dist/dist/{propertyValidationRules-BlfLn4rP.d.ts → propertyValidationRules-DbbWvBzj.d.ts} +1 -1
- package/dist/dist/propertyValidationRules-DbbWvBzj.d.ts.map +1 -0
- package/dist/dist/{publishDraftGraph-CLO85LLz.d.ts → publishDraftGraph-CCa6EzeO.d.ts} +1 -1
- package/dist/dist/{publishDraftGraph-CLO85LLz.d.ts.map → publishDraftGraph-CCa6EzeO.d.ts.map} +1 -1
- package/dist/dist/{resetAmbiguousLegacyItemData-Cy8ik7xk.d.ts → resetAmbiguousLegacyItemData--PN1v53N.d.ts} +1 -1
- package/dist/dist/resetAmbiguousLegacyItemData--PN1v53N.d.ts.map +1 -0
- package/dist/dist/{resolveModelForSyncedSeed-DFr4COc4.d.ts → resolveModelForSyncedSeed-VDzkS6Rs.d.ts} +1 -1
- package/dist/dist/resolveModelForSyncedSeed-VDzkS6Rs.d.ts.map +1 -0
- package/dist/dist/{syncDbWithEas-CAOlw3i-.d.ts → syncDbWithEas-D0gyJ58h.d.ts} +1 -1
- package/dist/dist/syncDbWithEas-D0gyJ58h.d.ts.map +1 -0
- package/dist/dist/{tabEvents-DksXwk3X.d.ts → tabEvents-UH-wNsZC.d.ts} +7 -4
- package/dist/dist/tabEvents-UH-wNsZC.d.ts.map +1 -0
- package/dist/dist/{tolerantWebAccess-CEIjFGf0.d.ts → tolerantWebAccess-CpcTCAZv.d.ts} +1 -1
- package/dist/dist/{tolerantWebAccess-CEIjFGf0.d.ts.map → tolerantWebAccess-CpcTCAZv.d.ts.map} +1 -1
- package/dist/dist/{updateSeedRevokedAt-Cjr35YjE.d.ts → updateSeedRevokedAt-D230zfWk.d.ts} +1 -1
- package/dist/dist/updateSeedRevokedAt-D230zfWk.d.ts.map +1 -0
- package/dist/{eas-DOdj-EMK.js → eas-BRVEGT97.js} +4 -4
- package/dist/{eas-DOdj-EMK.js.map → eas-BRVEGT97.js.map} +1 -1
- package/dist/{errors-KM-yq2MD.js → errors-CQagdED2.js} +222 -275
- package/dist/errors-CQagdED2.js.map +1 -0
- package/dist/{getItem-Bh0zv-o1.js → getItem-Jpr1SKIL.js} +4 -4
- package/dist/{getItem-Bh0zv-o1.js.map → getItem-Jpr1SKIL.js.map} +1 -1
- package/dist/{getPublishPayload-oH8wJhnH.js → getPublishPayload-Bmeqtq4l.js} +15 -15
- package/dist/{getPublishPayload-oH8wJhnH.js.map → getPublishPayload-Bmeqtq4l.js.map} +1 -1
- package/dist/{getPublishUploads-Cex-NBe6.js → getPublishUploads-7nW1kMZV.js} +6 -6
- package/dist/{getPublishUploads-Cex-NBe6.js.map → getPublishUploads-7nW1kMZV.js.map} +1 -1
- package/dist/{index-BbFwftAv.js → index-3_hGVu7v.js} +2 -2
- package/dist/index-3_hGVu7v.js.map +1 -0
- package/dist/{index-DpgQMIRq.js → index-C-NqjjY_.js} +18 -3
- package/dist/index-C-NqjjY_.js.map +1 -0
- package/dist/{index-BAao3_Po.js → index-DM3zrNtX.js} +8 -8
- package/dist/index-DM3zrNtX.js.map +1 -0
- package/dist/{index.browser-nndbVM7z.js → index.browser-DGoOSs1J.js} +27 -18
- package/dist/index.browser-DGoOSs1J.js.map +1 -0
- package/dist/{index.node-BUfx-JaP.js → index.node-CTv62R2a.js} +6 -6
- package/dist/{index.node-BUfx-JaP.js.map → index.node-CTv62R2a.js.map} +1 -1
- package/dist/main.js +24 -24
- package/dist/node.js +11 -11
- package/dist/platform.browser.js +5 -5
- package/dist/platform.node.js +4 -4
- package/dist/{property-BDBvImLs.js → property-DaUy4XMe.js} +9 -11
- package/dist/property-DaUy4XMe.js.map +1 -0
- package/dist/{propertyValidationRules-BlfLn4rP.js → propertyValidationRules-DbbWvBzj.js} +10 -10
- package/dist/{propertyValidationRules-BlfLn4rP.js.map → propertyValidationRules-DbbWvBzj.js.map} +1 -1
- package/dist/{publishDraftGraph-CLO85LLz.js → publishDraftGraph-CCa6EzeO.js} +6 -6
- package/dist/{publishDraftGraph-CLO85LLz.js.map → publishDraftGraph-CCa6EzeO.js.map} +1 -1
- package/dist/{resetAmbiguousLegacyItemData-Cy8ik7xk.js → resetAmbiguousLegacyItemData--PN1v53N.js} +2 -2
- package/dist/{resetAmbiguousLegacyItemData-Cy8ik7xk.js.map → resetAmbiguousLegacyItemData--PN1v53N.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-DFr4COc4.js → resolveModelForSyncedSeed-VDzkS6Rs.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-DFr4COc4.js.map → resolveModelForSyncedSeed-VDzkS6Rs.js.map} +1 -1
- package/dist/src/Item/Item.d.ts +23 -6
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Item/service/itemMachineSingle.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts +38 -6
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
- package/dist/src/Model/Model.d.ts +50 -9
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/Model/service/actors/validateModel.d.ts.map +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/actors/compareAndMarkDraft.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/actors/validateProperty.d.ts.map +1 -1
- package/dist/src/Schema/Schema.d.ts +22 -3
- package/dist/src/Schema/Schema.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/checkExistingSchema.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/createModelInstances.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/loadOrCreateSchema.d.ts.map +1 -1
- package/dist/src/browser/db/Db.d.ts.map +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/client/ClientManager.d.ts +13 -0
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityCache.d.ts +2 -42
- package/dist/src/helpers/entity/entityCache.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityCommon.d.ts +9 -0
- package/dist/src/helpers/entity/entityCommon.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityDestroy.d.ts +13 -7
- package/dist/src/helpers/entity/entityDestroy.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityLiveQuery.d.ts +3 -2
- package/dist/src/helpers/entity/entityLiveQuery.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityState.d.ts +28 -0
- package/dist/src/helpers/entity/entityState.d.ts.map +1 -0
- package/dist/src/helpers/entity/entityUnload.d.ts +3 -2
- package/dist/src/helpers/entity/entityUnload.d.ts.map +1 -1
- package/dist/src/helpers/entity/index.d.ts +1 -0
- package/dist/src/helpers/entity/index.d.ts.map +1 -1
- package/dist/src/helpers/metadataPropertyNames.d.ts +6 -0
- package/dist/src/helpers/metadataPropertyNames.d.ts.map +1 -1
- package/dist/src/helpers/property.d.ts.map +1 -1
- package/dist/src/helpers/reactiveProxy.d.ts +18 -0
- package/dist/src/helpers/reactiveProxy.d.ts.map +1 -1
- package/dist/src/helpers/sessionObjectUrls.d.ts +4 -0
- package/dist/src/helpers/sessionObjectUrls.d.ts.map +1 -0
- package/dist/src/imports/json.d.ts.map +1 -1
- package/dist/{syncDbWithEas-CAOlw3i-.js → syncDbWithEas-D0gyJ58h.js} +19 -19
- package/dist/syncDbWithEas-D0gyJ58h.js.map +1 -0
- package/dist/{tabEvents-DksXwk3X.js → tabEvents-UH-wNsZC.js} +24 -7
- package/dist/tabEvents-UH-wNsZC.js.map +1 -0
- package/dist/{tolerantWebAccess-CEIjFGf0.js → tolerantWebAccess-CpcTCAZv.js} +6 -6
- package/dist/{tolerantWebAccess-CEIjFGf0.js.map → tolerantWebAccess-CpcTCAZv.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-Cjr35YjE.js → updateSeedRevokedAt-D230zfWk.js} +3 -3
- package/dist/{updateSeedRevokedAt-Cjr35YjE.js.map → updateSeedRevokedAt-D230zfWk.js.map} +1 -1
- package/package.json +6 -6
- package/dist/ClientManager-2GtDWHq6.js.map +0 -1
- package/dist/Item-D6j0IvBP.js.map +0 -1
- package/dist/ModelProperty-B52C3CQ2.js.map +0 -1
- package/dist/Schema-O1QLoXv6.js.map +0 -1
- package/dist/dist/ClientManager-2GtDWHq6.d.ts.map +0 -1
- package/dist/dist/Item-D6j0IvBP.d.ts.map +0 -1
- package/dist/dist/Schema-O1QLoXv6.d.ts.map +0 -1
- package/dist/dist/backfillMetadataPropertyIds-CzSbuucw.d.ts.map +0 -1
- package/dist/dist/configurePlatform-Bbpw_R4y.d.ts.map +0 -1
- package/dist/dist/detachRowsBeforeDelete-D1TyEMco.d.ts.map +0 -1
- package/dist/dist/discardNewDraft-hiVaUVjV.d.ts.map +0 -1
- package/dist/dist/eas-DOdj-EMK.d.ts.map +0 -1
- package/dist/dist/errors-KM-yq2MD.d.ts.map +0 -1
- package/dist/dist/getItem-Bh0zv-o1.d.ts.map +0 -1
- package/dist/dist/index-BAao3_Po.d.ts.map +0 -1
- package/dist/dist/index-DpgQMIRq.d.ts.map +0 -1
- package/dist/dist/property-BDBvImLs.d.ts.map +0 -1
- package/dist/dist/propertyValidationRules-BlfLn4rP.d.ts.map +0 -1
- package/dist/dist/resetAmbiguousLegacyItemData-Cy8ik7xk.d.ts.map +0 -1
- package/dist/dist/resolveModelForSyncedSeed-DFr4COc4.d.ts.map +0 -1
- package/dist/dist/syncDbWithEas-CAOlw3i-.d.ts.map +0 -1
- package/dist/dist/tabEvents-DksXwk3X.d.ts.map +0 -1
- package/dist/dist/updateSeedRevokedAt-Cjr35YjE.d.ts.map +0 -1
- package/dist/errors-KM-yq2MD.js.map +0 -1
- package/dist/index-BAao3_Po.js.map +0 -1
- package/dist/index-BbFwftAv.js.map +0 -1
- package/dist/index-DpgQMIRq.js.map +0 -1
- package/dist/index.browser-nndbVM7z.js.map +0 -1
- package/dist/property-BDBvImLs.js.map +0 -1
- package/dist/syncDbWithEas-CAOlw3i-.js.map +0 -1
- package/dist/tabEvents-DksXwk3X.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { fromCallback, setup, assign, createActor } from 'xstate';
|
|
2
|
-
import { au as SEED_PROTOCOL_SCHEMA_NAME, B as BaseDb, A as schemas, aM as addSchemaToDb, i as isDataType, M as ModelPropertyDataTypes,
|
|
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-
|
|
2
|
+
import { au as SEED_PROTOCOL_SCHEMA_NAME, B as BaseDb, A as schemas, aM as addSchemaToDb, i as isDataType, M as ModelPropertyDataTypes, ah 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-C-NqjjY_.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-DBKvmJov.js';
|
|
4
4
|
import { eq, desc, and } from 'drizzle-orm';
|
|
5
5
|
import debug from 'debug';
|
|
6
|
-
import { c as currentEvictionEpoch, w as writeProcessMachine,
|
|
6
|
+
import { c as currentEvictionEpoch, w as writeProcessMachine, M as Model, g as getDraftSaveError, C as ConflictError, r as recordSchemaDestroy, f as finishSchemaDestroy, e as setupEntityLiveQuery, t as trackDraftSave } from './errors-CQagdED2.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,
|
|
9
|
+
import { SchemaValidationService } from './SchemaValidationService-paOfbcwd.js';
|
|
10
|
+
import { $ as ActorKeyedState, D as DEFAULT_READY_TIMEOUT_MS, d as waitForEntityIdle, n as createReactiveProxy, q as findEntity, C as ClientManagerState, a0 as clearDestroySubscriptions, t as forceRemoveFromCaches, a1 as unloadEntity, u as runDestroyLifecycle } from './Item-BiMHgg-_.js';
|
|
11
11
|
|
|
12
12
|
const logger$d = debug('seedSdk:schema:actors:loadOrCreateSchema');
|
|
13
13
|
/**
|
|
@@ -51,8 +51,8 @@ const createModelInstances$2 = async (modelIds, evictionEpoch) => {
|
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
try {
|
|
54
|
-
const _mod_0 = await import('./errors-
|
|
55
|
-
const _ns_0 = _mod_0.
|
|
54
|
+
const _mod_0 = await import('./errors-CQagdED2.js');
|
|
55
|
+
const _ns_0 = _mod_0.i;
|
|
56
56
|
const modelMod = _ns_0;
|
|
57
57
|
const { Model } = modelMod;
|
|
58
58
|
// Create instances for all model IDs in parallel
|
|
@@ -60,7 +60,10 @@ const createModelInstances$2 = async (modelIds, evictionEpoch) => {
|
|
|
60
60
|
const createPromises = modelIds.map(async (modelFileId) => {
|
|
61
61
|
try {
|
|
62
62
|
// Not if the schema was evicted (Schema.destroy, test cleanup) since this load started
|
|
63
|
-
const
|
|
63
|
+
const schemaHold = Model.takeSchemaHold(modelFileId);
|
|
64
|
+
const model = await Model.createById(modelFileId, { evictionEpoch, ...(!schemaHold && { hold: false }) });
|
|
65
|
+
if (!model && schemaHold)
|
|
66
|
+
Model.dropSchemaHold(modelFileId);
|
|
64
67
|
if (model) {
|
|
65
68
|
logger$d(`Created/cached Model instance for modelFileId "${modelFileId}"`);
|
|
66
69
|
}
|
|
@@ -168,7 +171,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
168
171
|
// For Seed Protocol, always load from internal file, never create new
|
|
169
172
|
logger$d(`Loading internal Seed Protocol schema from SDK`);
|
|
170
173
|
try {
|
|
171
|
-
const _mod_1 = await import('./ClientManager-
|
|
174
|
+
const _mod_1 = await import('./ClientManager-DBKvmJov.js');
|
|
172
175
|
const _ns_1 = _mod_1.S;
|
|
173
176
|
const internalSchema = _ns_1;
|
|
174
177
|
const schemaFile = internalSchema.default;
|
|
@@ -667,7 +670,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
667
670
|
// Ensure models are populated (fallback for seed-protocol if missing)
|
|
668
671
|
if ((!mergedModels || Object.keys(mergedModels).length === 0) && schemaName === 'Seed Protocol') {
|
|
669
672
|
try {
|
|
670
|
-
const _mod_2 = await import('./ClientManager-
|
|
673
|
+
const _mod_2 = await import('./ClientManager-DBKvmJov.js');
|
|
671
674
|
const _ns_2 = _mod_2.S;
|
|
672
675
|
const internalSchema = _ns_2;
|
|
673
676
|
const internalSchemaFile = internalSchema.default;
|
|
@@ -832,7 +835,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
832
835
|
// Ensure models are populated (fallback for seed-protocol if missing)
|
|
833
836
|
if ((!mergedModels || Object.keys(mergedModels).length === 0) && schemaName === 'Seed Protocol') {
|
|
834
837
|
try {
|
|
835
|
-
const _mod_3 = await import('./ClientManager-
|
|
838
|
+
const _mod_3 = await import('./ClientManager-DBKvmJov.js');
|
|
836
839
|
const _ns_3 = _mod_3.S;
|
|
837
840
|
const internalSchema = _ns_3;
|
|
838
841
|
const internalSchemaFile = internalSchema.default;
|
|
@@ -887,7 +890,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
887
890
|
// Ensure models are populated (fallback for seed-protocol if missing)
|
|
888
891
|
if ((!mergedModels || Object.keys(mergedModels).length === 0) && schemaName === 'Seed Protocol') {
|
|
889
892
|
try {
|
|
890
|
-
const _mod_4 = await import('./ClientManager-
|
|
893
|
+
const _mod_4 = await import('./ClientManager-DBKvmJov.js');
|
|
891
894
|
const _ns_4 = _mod_4.S;
|
|
892
895
|
const internalSchema = _ns_4;
|
|
893
896
|
const internalSchemaFile = internalSchema.default;
|
|
@@ -937,7 +940,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
937
940
|
// If schemaData is missing, try to load from internal schema file for seed-protocol
|
|
938
941
|
if (!dbSchema.schemaData && schemaName === 'Seed Protocol') {
|
|
939
942
|
try {
|
|
940
|
-
const _mod_5 = await import('./ClientManager-
|
|
943
|
+
const _mod_5 = await import('./ClientManager-DBKvmJov.js');
|
|
941
944
|
const _ns_5 = _mod_5.S;
|
|
942
945
|
const internalSchema = _ns_5;
|
|
943
946
|
const schemaFile = internalSchema.default;
|
|
@@ -1048,7 +1051,7 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1048
1051
|
// Ensure models are populated (fallback for seed-protocol if missing)
|
|
1049
1052
|
if ((!mergedModels || Object.keys(mergedModels).length === 0) && schemaName === 'Seed Protocol') {
|
|
1050
1053
|
try {
|
|
1051
|
-
const _mod_6 = await import('./ClientManager-
|
|
1054
|
+
const _mod_6 = await import('./ClientManager-DBKvmJov.js');
|
|
1052
1055
|
const _ns_6 = _mod_6.S;
|
|
1053
1056
|
const internalSchema = _ns_6;
|
|
1054
1057
|
const internalSchemaFile = internalSchema.default;
|
|
@@ -1375,8 +1378,8 @@ const createModelInstances$1 = async (modelIds, evictionEpoch) => {
|
|
|
1375
1378
|
return;
|
|
1376
1379
|
}
|
|
1377
1380
|
try {
|
|
1378
|
-
const _mod_7 = await import('./errors-
|
|
1379
|
-
const _ns_7 = _mod_7.
|
|
1381
|
+
const _mod_7 = await import('./errors-CQagdED2.js');
|
|
1382
|
+
const _ns_7 = _mod_7.i;
|
|
1380
1383
|
const mod = _ns_7;
|
|
1381
1384
|
const Model = mod?.Model ?? mod?.default;
|
|
1382
1385
|
if (!Model) {
|
|
@@ -1386,7 +1389,10 @@ const createModelInstances$1 = async (modelIds, evictionEpoch) => {
|
|
|
1386
1389
|
const createPromises = modelIds.map(async (modelFileId) => {
|
|
1387
1390
|
try {
|
|
1388
1391
|
// Not if the schema was evicted (Schema.destroy, test cleanup) since this check started
|
|
1389
|
-
const
|
|
1392
|
+
const schemaHold = Model.takeSchemaHold(modelFileId);
|
|
1393
|
+
const model = await Model.createById(modelFileId, { evictionEpoch, ...(!schemaHold && { hold: false }) });
|
|
1394
|
+
if (!model && schemaHold)
|
|
1395
|
+
Model.dropSchemaHold(modelFileId);
|
|
1390
1396
|
if (model) {
|
|
1391
1397
|
logger$c(`Created/cached Model instance for modelFileId "${modelFileId}"`);
|
|
1392
1398
|
}
|
|
@@ -1424,7 +1430,7 @@ const checkExistingSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1424
1430
|
if (isInternal && schemaName === SEED_PROTOCOL_SCHEMA_NAME) {
|
|
1425
1431
|
// For Seed Protocol, check if it exists in database
|
|
1426
1432
|
try {
|
|
1427
|
-
const _mod_8 = await import('./ClientManager-
|
|
1433
|
+
const _mod_8 = await import('./ClientManager-DBKvmJov.js');
|
|
1428
1434
|
const _ns_8 = _mod_8.S;
|
|
1429
1435
|
const internalSchema = _ns_8;
|
|
1430
1436
|
const schemaFile = internalSchema.default;
|
|
@@ -1760,7 +1766,7 @@ const writeSchemaToDb = fromCallback(({ sendBack, input }) => {
|
|
|
1760
1766
|
if (isInternal && schemaName === SEED_PROTOCOL_SCHEMA_NAME) {
|
|
1761
1767
|
// For Seed Protocol, load from internal file
|
|
1762
1768
|
logger$b(`Loading internal Seed Protocol schema from SDK`);
|
|
1763
|
-
const _mod_9 = await import('./ClientManager-
|
|
1769
|
+
const _mod_9 = await import('./ClientManager-DBKvmJov.js');
|
|
1764
1770
|
const _ns_9 = _mod_9.S;
|
|
1765
1771
|
const internalSchema = _ns_9;
|
|
1766
1772
|
finalSchema = internalSchema.default;
|
|
@@ -2233,8 +2239,8 @@ const createModelInstances = fromCallback(({ sendBack, input }) => {
|
|
|
2233
2239
|
return;
|
|
2234
2240
|
}
|
|
2235
2241
|
try {
|
|
2236
|
-
const _mod_10 = await import('./errors-
|
|
2237
|
-
const _ns_10 = _mod_10.
|
|
2242
|
+
const _mod_10 = await import('./errors-CQagdED2.js');
|
|
2243
|
+
const _ns_10 = _mod_10.i;
|
|
2238
2244
|
const modelMod = _ns_10;
|
|
2239
2245
|
const { Model } = modelMod;
|
|
2240
2246
|
// Create instances for all model IDs in parallel
|
|
@@ -2242,7 +2248,10 @@ const createModelInstances = fromCallback(({ sendBack, input }) => {
|
|
|
2242
2248
|
const createPromises = modelIds.map(async (modelFileId) => {
|
|
2243
2249
|
try {
|
|
2244
2250
|
// Not if the schema was evicted (Schema.destroy, test cleanup) since this started
|
|
2245
|
-
const
|
|
2251
|
+
const schemaHold = Model.takeSchemaHold(modelFileId);
|
|
2252
|
+
const model = await Model.createById(modelFileId, { evictionEpoch, ...(!schemaHold && { hold: false }) });
|
|
2253
|
+
if (!model && schemaHold)
|
|
2254
|
+
Model.dropSchemaHold(modelFileId);
|
|
2246
2255
|
if (model) {
|
|
2247
2256
|
logger$7(`Created/cached Model instance for modelFileId "${modelFileId}"`);
|
|
2248
2257
|
return true;
|
|
@@ -2322,8 +2331,8 @@ const verifyModelInstancesInCache = fromCallback(({ sendBack, input }) => {
|
|
|
2322
2331
|
}
|
|
2323
2332
|
try {
|
|
2324
2333
|
const result = await verifyWithRetry$2(async () => {
|
|
2325
|
-
const _mod_11 = await import('./errors-
|
|
2326
|
-
const _ns_11 = _mod_11.
|
|
2334
|
+
const _mod_11 = await import('./errors-CQagdED2.js');
|
|
2335
|
+
const _ns_11 = _mod_11.i;
|
|
2327
2336
|
const modelMod = _ns_11;
|
|
2328
2337
|
const { Model } = modelMod;
|
|
2329
2338
|
// Check each model ID in the cache
|
|
@@ -2331,7 +2340,7 @@ const verifyModelInstancesInCache = fromCallback(({ sendBack, input }) => {
|
|
|
2331
2340
|
const missingIds = [];
|
|
2332
2341
|
for (const modelFileId of modelIds) {
|
|
2333
2342
|
// Try to get instance from cache
|
|
2334
|
-
const instance = Model.
|
|
2343
|
+
const instance = Model.peek(modelFileId);
|
|
2335
2344
|
if (instance) {
|
|
2336
2345
|
verifiedInstances.push(modelFileId);
|
|
2337
2346
|
}
|
|
@@ -2381,8 +2390,8 @@ const writePropertiesToDb = fromCallback(({ sendBack, input }) => {
|
|
|
2381
2390
|
const _write = async () => {
|
|
2382
2391
|
const { modelIds } = input;
|
|
2383
2392
|
try {
|
|
2384
|
-
const _mod_12 = await import('./index-
|
|
2385
|
-
const _ns_12 = _mod_12.
|
|
2393
|
+
const _mod_12 = await import('./index-C-NqjjY_.js');
|
|
2394
|
+
const _ns_12 = _mod_12.be;
|
|
2386
2395
|
const modelSchemaMod = _ns_12;
|
|
2387
2396
|
const { models: modelsTable, properties: propertiesTable } = modelSchemaMod;
|
|
2388
2397
|
const drizzleMod = await import('drizzle-orm');
|
|
@@ -2571,10 +2580,10 @@ const createPropertyInstances = fromCallback(({ sendBack, input }) => {
|
|
|
2571
2580
|
return;
|
|
2572
2581
|
}
|
|
2573
2582
|
try {
|
|
2574
|
-
const modProp = await import('./ModelProperty-
|
|
2583
|
+
const modProp = await import('./ModelProperty-C1Fzcnbm.js');
|
|
2575
2584
|
const ModelProperty = modProp?.ModelProperty ?? modProp?.default;
|
|
2576
|
-
const _mod_13 = await import('./errors-
|
|
2577
|
-
const _ns_13 = _mod_13.
|
|
2585
|
+
const _mod_13 = await import('./errors-CQagdED2.js');
|
|
2586
|
+
const _ns_13 = _mod_13.i;
|
|
2578
2587
|
const modModel = _ns_13;
|
|
2579
2588
|
const Model = modModel?.Model ?? modModel?.default;
|
|
2580
2589
|
if (!ModelProperty || !Model) {
|
|
@@ -2587,7 +2596,7 @@ const createPropertyInstances = fromCallback(({ sendBack, input }) => {
|
|
|
2587
2596
|
let successCount = 0;
|
|
2588
2597
|
// For each model, check if properties are loaded
|
|
2589
2598
|
for (const modelFileId of modelIds) {
|
|
2590
|
-
const model = Model.
|
|
2599
|
+
const model = Model.peek(modelFileId);
|
|
2591
2600
|
if (model && model.properties) {
|
|
2592
2601
|
// Count properties that match our property IDs
|
|
2593
2602
|
for (const prop of model.properties) {
|
|
@@ -2680,7 +2689,7 @@ const verifyPropertyInstancesInCache = fromCallback(({ sendBack, input }) => {
|
|
|
2680
2689
|
}
|
|
2681
2690
|
try {
|
|
2682
2691
|
const result = await verifyWithRetry(async () => {
|
|
2683
|
-
const mod = await import('./ModelProperty-
|
|
2692
|
+
const mod = await import('./ModelProperty-C1Fzcnbm.js');
|
|
2684
2693
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
2685
2694
|
if (!ModelProperty) {
|
|
2686
2695
|
throw new Error('ModelProperty not available from dynamic import');
|
|
@@ -3700,8 +3709,8 @@ async function loadSchemaWithRenames(schemaFilePath, modelRenames) {
|
|
|
3700
3709
|
updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
|
|
3701
3710
|
};
|
|
3702
3711
|
// Use dynamic import to break circular dependency
|
|
3703
|
-
const _mod_14 = await import('./index-
|
|
3704
|
-
const _ns_14 = _mod_14.
|
|
3712
|
+
const _mod_14 = await import('./index-C-NqjjY_.js');
|
|
3713
|
+
const _ns_14 = _mod_14.bj;
|
|
3705
3714
|
const dbMod = _ns_14;
|
|
3706
3715
|
const { addSchemaToDb, addModelsToDb } = dbMod;
|
|
3707
3716
|
// Add schema to database with schemaFileId
|
|
@@ -3824,8 +3833,8 @@ async function renameModelProperty(schemaName, modelName, oldPropertyName, newPr
|
|
|
3824
3833
|
await BaseFileManager.waitForFileWithContent(newFilePath);
|
|
3825
3834
|
logger$1(`Renamed property ${oldPropertyName} to ${newPropertyName} in schema ${schemaName} v${newVersion}`);
|
|
3826
3835
|
// Migrate metadata rows so ItemProperty values follow the new name (prevents duplicate ItemProperties)
|
|
3827
|
-
const _mod_15 = await import('./index-
|
|
3828
|
-
const _ns_15 = _mod_15.
|
|
3836
|
+
const _mod_15 = await import('./index-C-NqjjY_.js');
|
|
3837
|
+
const _ns_15 = _mod_15.bj;
|
|
3829
3838
|
const { migrateMetadataForPropertyRename } = _ns_15;
|
|
3830
3839
|
const migratedCount = await migrateMetadataForPropertyRename(modelName, oldPropertyName, newPropertyName, oldProperty.id, { schemaName });
|
|
3831
3840
|
if (migratedCount > 0) {
|
|
@@ -4083,9 +4092,8 @@ var updateSchema = /*#__PURE__*/Object.freeze({
|
|
|
4083
4092
|
|
|
4084
4093
|
const logger = debug('seedSdk:schema:saveNewVersion');
|
|
4085
4094
|
const saveDraftLogger = debug('seedSdk:schema:saveDraftToDb');
|
|
4086
|
-
//
|
|
4087
|
-
|
|
4088
|
-
const schemaInstanceState = new WeakMap();
|
|
4095
|
+
// Non-serializable resources per Schema instance (subscriptions, timers, etc.)
|
|
4096
|
+
const schemaInstanceState = new ActorKeyedState();
|
|
4089
4097
|
// Cache client initialization state globally to avoid repeated checks
|
|
4090
4098
|
let cachedClientInitialized = null;
|
|
4091
4099
|
let clientCheckTime = 0;
|
|
@@ -4142,18 +4150,18 @@ class Schema {
|
|
|
4142
4150
|
}
|
|
4143
4151
|
const waitForReady = options?.waitForReady !== false;
|
|
4144
4152
|
const readyTimeout = options?.readyTimeout ?? DEFAULT_READY_TIMEOUT_MS;
|
|
4153
|
+
const holds = options?.hold === false ? 0 : 1;
|
|
4145
4154
|
// First, check if we have an instance cached by name
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
refCount: refCount + 1,
|
|
4151
|
-
});
|
|
4155
|
+
const cached = this.instanceCacheByName.get(schemaName);
|
|
4156
|
+
if (cached) {
|
|
4157
|
+
cached.refCount += holds;
|
|
4158
|
+
const { instance } = cached;
|
|
4152
4159
|
if (!waitForReady)
|
|
4153
4160
|
return instance;
|
|
4154
4161
|
return waitForEntityIdle(instance, { timeout: readyTimeout }).then(() => instance);
|
|
4155
4162
|
}
|
|
4156
|
-
// Deduplicate concurrent creates for same schema (prevents many parallel checkExistingSchema loads)
|
|
4163
|
+
// Deduplicate concurrent creates for same schema (prevents many parallel checkExistingSchema loads).
|
|
4164
|
+
// The name cache is set before a pending load is recorded, so a hold was already taken above.
|
|
4157
4165
|
if (waitForReady) {
|
|
4158
4166
|
const pending = this.pendingSchemaByName.get(schemaName);
|
|
4159
4167
|
if (pending) {
|
|
@@ -4366,7 +4374,7 @@ class Schema {
|
|
|
4366
4374
|
// Cache by name initially (will be moved to id-based cache once schemaFileId is available)
|
|
4367
4375
|
this.instanceCacheByName.set(schemaName, {
|
|
4368
4376
|
instance: proxiedInstance,
|
|
4369
|
-
refCount:
|
|
4377
|
+
refCount: holds,
|
|
4370
4378
|
});
|
|
4371
4379
|
const schema = proxiedInstance;
|
|
4372
4380
|
if (!waitForReady)
|
|
@@ -4392,14 +4400,11 @@ class Schema {
|
|
|
4392
4400
|
return;
|
|
4393
4401
|
}
|
|
4394
4402
|
// If we have an instance cached by name, also add it to id-based cache
|
|
4395
|
-
// Keep it in both caches for efficient lookups
|
|
4403
|
+
// Keep it in both caches for efficient lookups, as one entry: one hold count for both keys
|
|
4396
4404
|
if (this.instanceCacheByName.has(schemaName)) {
|
|
4397
4405
|
const cacheEntry = this.instanceCacheByName.get(schemaName);
|
|
4398
4406
|
// Add to ID cache (don't remove from name cache)
|
|
4399
|
-
this.instanceCacheById.set(schemaFileId,
|
|
4400
|
-
instance: cacheEntry.instance,
|
|
4401
|
-
refCount: cacheEntry.refCount, // Use same refCount
|
|
4402
|
-
});
|
|
4407
|
+
this.instanceCacheById.set(schemaFileId, cacheEntry);
|
|
4403
4408
|
logger(`Added schema cache entry to id "${schemaFileId}" (kept in name cache: "${schemaName}")`);
|
|
4404
4409
|
}
|
|
4405
4410
|
}
|
|
@@ -4408,15 +4413,19 @@ class Schema {
|
|
|
4408
4413
|
* Returns null if not found in cache
|
|
4409
4414
|
*/
|
|
4410
4415
|
static getById(schemaFileId) {
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4416
|
+
const entry = this.instanceCacheById.get(schemaFileId);
|
|
4417
|
+
if (!entry)
|
|
4418
|
+
return null;
|
|
4419
|
+
entry.refCount += 1;
|
|
4420
|
+
return entry.instance;
|
|
4421
|
+
}
|
|
4422
|
+
/**
|
|
4423
|
+
* The cached schema with this file id or name, without taking a hold. For SDK code that reads
|
|
4424
|
+
* the schema and doesn't hand it to a caller; callers that keep it use `create` or `find`.
|
|
4425
|
+
*/
|
|
4426
|
+
static peek(schemaFileIdOrName) {
|
|
4427
|
+
return (this.instanceCacheById.get(schemaFileIdOrName)?.instance ??
|
|
4428
|
+
this.instanceCacheByName.get(schemaFileIdOrName)?.instance);
|
|
4420
4429
|
}
|
|
4421
4430
|
/**
|
|
4422
4431
|
* Clear all cached Schema instances.
|
|
@@ -4452,14 +4461,16 @@ class Schema {
|
|
|
4452
4461
|
* Create or get schema instance by schemaFileId
|
|
4453
4462
|
* Queries the database to find the schema name if not cached
|
|
4454
4463
|
* @param schemaFileId - The schema file ID
|
|
4455
|
-
* @returns Schema instance
|
|
4464
|
+
* @returns Schema instance, with a hold taken (unless `hold: false`)
|
|
4456
4465
|
*/
|
|
4457
|
-
static async createById(schemaFileId
|
|
4466
|
+
static async createById(schemaFileId,
|
|
4467
|
+
/** @internal `hold: false` as for `create` */
|
|
4468
|
+
options) {
|
|
4458
4469
|
if (!schemaFileId) {
|
|
4459
4470
|
throw new Error('Schema file ID is required');
|
|
4460
4471
|
}
|
|
4461
4472
|
// First, check if we have an instance cached by ID
|
|
4462
|
-
const cachedInstance = this.getById(schemaFileId);
|
|
4473
|
+
const cachedInstance = options?.hold === false ? this.peek(schemaFileId) : this.getById(schemaFileId);
|
|
4463
4474
|
if (cachedInstance) {
|
|
4464
4475
|
return cachedInstance;
|
|
4465
4476
|
}
|
|
@@ -4483,7 +4494,7 @@ class Schema {
|
|
|
4483
4494
|
throw new Error(`Schema with ID "${schemaFileId}" has no name in database`);
|
|
4484
4495
|
}
|
|
4485
4496
|
// Create schema using the name (this will load from database/file)
|
|
4486
|
-
return this.create(schemaName);
|
|
4497
|
+
return this.create(schemaName, options?.hold === false ? { hold: false } : undefined);
|
|
4487
4498
|
}
|
|
4488
4499
|
/**
|
|
4489
4500
|
* Find schema instance by schemaFileId
|
|
@@ -4512,6 +4523,7 @@ class Schema {
|
|
|
4512
4523
|
* Get instantiated Schema objects for all schemas (from database and files)
|
|
4513
4524
|
* By default, returns only the latest version of each schema and excludes the internal Seed Protocol schema.
|
|
4514
4525
|
* Uses loadAllSchemasFromDb() as the single source of truth, which intelligently merges database and file data.
|
|
4526
|
+
* Takes no holds on the instances it returns: a caller that keeps one uses `Schema.create` or `Schema.find`.
|
|
4515
4527
|
*
|
|
4516
4528
|
* @param options - Configuration options
|
|
4517
4529
|
* @param options.includeAllVersions - If true, returns all versions of each schema. Default: false
|
|
@@ -4570,9 +4582,10 @@ class Schema {
|
|
|
4570
4582
|
}
|
|
4571
4583
|
processedSchemaNames.add(schemaName);
|
|
4572
4584
|
// Try to use schemaFileId to ensure we load the correct version
|
|
4573
|
-
// First check if we have a cached instance by schemaFileId
|
|
4585
|
+
// First check if we have a cached instance by schemaFileId. Schema.all takes no holds: it
|
|
4586
|
+
// lists schemas (useSchemas caches the list and never unloads it).
|
|
4574
4587
|
if (schemaFileId) {
|
|
4575
|
-
const cachedById = this.
|
|
4588
|
+
const cachedById = this.peek(schemaFileId);
|
|
4576
4589
|
if (cachedById) {
|
|
4577
4590
|
// Verify the cached instance has the correct version
|
|
4578
4591
|
const cachedContext = cachedById.getService().getSnapshot().context;
|
|
@@ -4597,16 +4610,16 @@ class Schema {
|
|
|
4597
4610
|
// But to ensure we get the correct version, we'll use createById if we have the schemaFileId
|
|
4598
4611
|
if (schemaFileId) {
|
|
4599
4612
|
try {
|
|
4600
|
-
const instance = await this.createById(schemaFileId);
|
|
4613
|
+
const instance = await this.createById(schemaFileId, { hold: false });
|
|
4601
4614
|
schemaInstances.push(instance);
|
|
4602
4615
|
}
|
|
4603
4616
|
catch {
|
|
4604
4617
|
// Fallback to creating by name if createById fails
|
|
4605
|
-
schemaInstances.push(this.create(schemaName, { waitForReady: false }));
|
|
4618
|
+
schemaInstances.push(this.create(schemaName, { waitForReady: false, hold: false }));
|
|
4606
4619
|
}
|
|
4607
4620
|
}
|
|
4608
4621
|
else {
|
|
4609
|
-
schemaInstances.push(this.create(schemaName, { waitForReady: false }));
|
|
4622
|
+
schemaInstances.push(this.create(schemaName, { waitForReady: false, hold: false }));
|
|
4610
4623
|
}
|
|
4611
4624
|
}
|
|
4612
4625
|
if (waitForReady && schemaInstances.length > 0) {
|
|
@@ -4651,7 +4664,7 @@ class Schema {
|
|
|
4651
4664
|
// Create Schema instances for each unique schema name
|
|
4652
4665
|
const schemaInstances = [];
|
|
4653
4666
|
for (const schemaName of uniqueSchemaNames) {
|
|
4654
|
-
schemaInstances.push(this.create(schemaName, { waitForReady: false }));
|
|
4667
|
+
schemaInstances.push(this.create(schemaName, { waitForReady: false, hold: false }));
|
|
4655
4668
|
}
|
|
4656
4669
|
if (waitForReady && schemaInstances.length > 0) {
|
|
4657
4670
|
await Promise.all(schemaInstances.map((s) => waitForEntityIdle(s, {
|
|
@@ -4712,7 +4725,7 @@ class Schema {
|
|
|
4712
4725
|
const seen = new Set();
|
|
4713
4726
|
const modelInstances = [];
|
|
4714
4727
|
for (const modelFileId of allModelIds) {
|
|
4715
|
-
const model = Model.
|
|
4728
|
+
const model = Model.peek(modelFileId);
|
|
4716
4729
|
if (model && modelFileId && !seen.has(modelFileId)) {
|
|
4717
4730
|
modelInstances.push(model);
|
|
4718
4731
|
seen.add(modelFileId);
|
|
@@ -4821,7 +4834,7 @@ class Schema {
|
|
|
4821
4834
|
const modelDbId = modelInstance.getService().getSnapshot().context._dbId;
|
|
4822
4835
|
const db = BaseDb.getAppDb();
|
|
4823
4836
|
if (propertyContexts.length === 0 && modelDbId && db) {
|
|
4824
|
-
const { ModelProperty } = await import('./ModelProperty-
|
|
4837
|
+
const { ModelProperty } = await import('./ModelProperty-C1Fzcnbm.js');
|
|
4825
4838
|
const rows = await db.select().from(properties).where(eq(properties.modelId, modelDbId));
|
|
4826
4839
|
propertyContexts = rows.map((row) => {
|
|
4827
4840
|
const cached = row.schemaFileId ? ModelProperty.getById(row.schemaFileId) : undefined;
|
|
@@ -4987,7 +5000,7 @@ class Schema {
|
|
|
4987
5000
|
savedSchema: publishedSchema,
|
|
4988
5001
|
});
|
|
4989
5002
|
// Clear edited flags on all ModelProperty instances and in database
|
|
4990
|
-
const modelPropertyMod = await import('./ModelProperty-
|
|
5003
|
+
const modelPropertyMod = await import('./ModelProperty-C1Fzcnbm.js');
|
|
4991
5004
|
const { ModelProperty } = modelPropertyMod;
|
|
4992
5005
|
for (const propertyKey of context._editedProperties) {
|
|
4993
5006
|
const [modelName, propertyName] = propertyKey.split(':');
|
|
@@ -5010,8 +5023,8 @@ class Schema {
|
|
|
5010
5023
|
try {
|
|
5011
5024
|
if (db && modelName && propertyName) {
|
|
5012
5025
|
// Find this schema's model by name
|
|
5013
|
-
const _mod_16 = await import('./index-
|
|
5014
|
-
const _ns_16 = _mod_16.
|
|
5026
|
+
const _mod_16 = await import('./index-C-NqjjY_.js');
|
|
5027
|
+
const _ns_16 = _mod_16.bi;
|
|
5015
5028
|
const { resolveModelRecord } = _ns_16;
|
|
5016
5029
|
const modelRecord = await resolveModelRecord(modelName, { schemaName: thisSchemaName }, db);
|
|
5017
5030
|
const modelRecords = modelRecord ? [modelRecord] : [];
|
|
@@ -5577,6 +5590,8 @@ class Schema {
|
|
|
5577
5590
|
onUnload: () => {
|
|
5578
5591
|
// Clean up WeakMap entry
|
|
5579
5592
|
schemaInstanceState.delete(this);
|
|
5593
|
+
if (context.schemaName)
|
|
5594
|
+
Model.releaseSchemaHolds(context.schemaName);
|
|
5580
5595
|
},
|
|
5581
5596
|
});
|
|
5582
5597
|
}
|
|
@@ -5640,10 +5655,10 @@ class Schema {
|
|
|
5640
5655
|
// instances too, or a re-import would get them back with dangling _dbIds.
|
|
5641
5656
|
if (schemaName) {
|
|
5642
5657
|
const evictedModelNames = Model.evictForSchema(schemaName);
|
|
5643
|
-
const { ModelProperty } = await import('./ModelProperty-
|
|
5658
|
+
const { ModelProperty } = await import('./ModelProperty-C1Fzcnbm.js');
|
|
5644
5659
|
ModelProperty.evictForModels(evictedModelNames, schemaName);
|
|
5645
5660
|
// Evicting stops new writes but not ones already running; let those land before deleting their rows
|
|
5646
|
-
const _mod_17 = await import('./errors-
|
|
5661
|
+
const _mod_17 = await import('./errors-CQagdED2.js');
|
|
5647
5662
|
const _ns_17 = _mod_17.h;
|
|
5648
5663
|
const { waitForInFlightWrites } = _ns_17;
|
|
5649
5664
|
await waitForInFlightWrites();
|
|
@@ -5676,7 +5691,7 @@ class Schema {
|
|
|
5676
5691
|
.map((r) => r.modelId)
|
|
5677
5692
|
.filter((id) => id != null)),
|
|
5678
5693
|
];
|
|
5679
|
-
const { detachModelRows } = await import('./detachRowsBeforeDelete-
|
|
5694
|
+
const { detachModelRows } = await import('./detachRowsBeforeDelete-C1iapUFl.js');
|
|
5680
5695
|
await detachModelRows(db, modelIds);
|
|
5681
5696
|
await db.delete(modelSchemas).where(inArray(modelSchemas.schemaId, schemaIds));
|
|
5682
5697
|
for (const modelId of modelIds) {
|
|
@@ -5691,7 +5706,7 @@ class Schema {
|
|
|
5691
5706
|
// the destroyed schema back on the next Schema.all().
|
|
5692
5707
|
// Match on name as well as id: versions imported from complete schema files can each
|
|
5693
5708
|
// have their own id, and any version left behind would bring the schema back.
|
|
5694
|
-
const _mod_18 = await import('./ClientManager-
|
|
5709
|
+
const _mod_18 = await import('./ClientManager-DBKvmJov.js');
|
|
5695
5710
|
const _ns_18 = _mod_18.N;
|
|
5696
5711
|
const { listCompleteSchemaFiles } = _ns_18;
|
|
5697
5712
|
const files = await listCompleteSchemaFiles().catch(() => []);
|
|
@@ -5810,7 +5825,7 @@ class Schema {
|
|
|
5810
5825
|
// One at a time: an eviction of this schema part way through stops the rest
|
|
5811
5826
|
const evictionEpoch = currentEvictionEpoch();
|
|
5812
5827
|
for (const id of ids) {
|
|
5813
|
-
await Model.createById(id, { evictionEpoch });
|
|
5828
|
+
await Model.createById(id, { evictionEpoch, hold: false });
|
|
5814
5829
|
}
|
|
5815
5830
|
},
|
|
5816
5831
|
queryInitialData: async (schemaId) => {
|
|
@@ -5887,4 +5902,4 @@ var Schema$1 = /*#__PURE__*/Object.freeze({
|
|
|
5887
5902
|
});
|
|
5888
5903
|
|
|
5889
5904
|
export { Schema as S, deletePropertyFromModel as a, Schema$1 as b, deleteModelFromSchema as d, renameModelProperty as r, schemaMachine as s, updateModelProperties as u };
|
|
5890
|
-
//# sourceMappingURL=Schema-
|
|
5905
|
+
//# sourceMappingURL=Schema-COTbavcm.js.map
|