@seedprotocol/sdk 0.7.3-next.613.g79a8dfd → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{db-CQt-gcAl.js → BasePathResolver-Cm4apKRb.js} +2041 -127
- package/dist/BasePathResolver-Cm4apKRb.js.map +1 -0
- package/dist/{ClientManager-DDA9956Y.js → ClientManager-i3nJASkg.js} +664 -277
- package/dist/ClientManager-i3nJASkg.js.map +1 -0
- package/dist/{Item-D4FigtYS.js → Item-DBFchXpC.js} +495 -219
- package/dist/Item-DBFchXpC.js.map +1 -0
- package/dist/{ModelProperty-BDt6AU2h.js → ModelProperty-BS49g01Y.js} +167 -47
- package/dist/ModelProperty-BS49g01Y.js.map +1 -0
- package/dist/{Schema-B8xqLWkL.js → Schema-CpMNEnUO.js} +53 -42
- package/dist/Schema-CpMNEnUO.js.map +1 -0
- package/dist/{SchemaValidationService-BPxkfDLU.js → SchemaValidationService-DieV4KL-.js} +13 -14
- package/dist/{SchemaValidationService-BPxkfDLU.js.map → SchemaValidationService-DieV4KL-.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-DuTPcv8t.js → backfillMetadataPropertyIds-DSoOoTnX.js} +14 -7
- package/dist/{backfillMetadataPropertyIds-DuTPcv8t.js.map → backfillMetadataPropertyIds-DSoOoTnX.js.map} +1 -1
- package/dist/{configurePlatform-YcOiDQBZ.js → configurePlatform-D0lQGAMQ.js} +8 -7
- package/dist/{configurePlatform-YcOiDQBZ.js.map → configurePlatform-D0lQGAMQ.js.map} +1 -1
- package/dist/detachRowsBeforeDelete-S0q-DJPT.js +50 -0
- package/dist/detachRowsBeforeDelete-S0q-DJPT.js.map +1 -0
- package/dist/{eas-CpOD74Ke.js → eas-6pjU-OuX.js} +9 -8
- package/dist/eas-6pjU-OuX.js.map +1 -0
- package/dist/{getItem-B_OoFkd7.js → getItem-CxBNZ-WL.js} +13 -11
- package/dist/{getItem-B_OoFkd7.js.map → getItem-CxBNZ-WL.js.map} +1 -1
- package/dist/{getPublishPayload-Xl3sRkR-.js → getPublishPayload-CTCvRUoU.js} +50 -18
- package/dist/getPublishPayload-CTCvRUoU.js.map +1 -0
- package/dist/getPublishUploads-SFHCbf_y.js +648 -0
- package/dist/getPublishUploads-SFHCbf_y.js.map +1 -0
- package/dist/{index-Xl1_4Lmb.js → index-8O3Uow-Y.js} +125 -57
- package/dist/index-8O3Uow-Y.js.map +1 -0
- package/dist/{index-CSOQFAOn.js → index-AVFTVp1m.js} +2 -2
- package/dist/index-AVFTVp1m.js.map +1 -0
- package/dist/index-Cvt5UBz4.js +30 -0
- package/dist/index-Cvt5UBz4.js.map +1 -0
- package/dist/{index.browser-CjTe0vt1.js → index.browser-DBhxRoe8.js} +554 -165
- package/dist/index.browser-DBhxRoe8.js.map +1 -0
- package/dist/{index.node-Cfa7npS6.js → index.node-CJhlcNHM.js} +25 -13
- package/dist/index.node-CJhlcNHM.js.map +1 -0
- package/dist/main.js +30 -47
- package/dist/main.js.map +1 -1
- package/dist/mimeTypes-DHAHC4eZ.js +204 -0
- package/dist/mimeTypes-DHAHC4eZ.js.map +1 -0
- package/dist/node.js +19 -21
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +13 -11
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.node.js +18 -5
- package/dist/platform.node.js.map +1 -1
- package/dist/{property-BrXkY1Rg.js → property-DwPD283A.js} +14 -12
- package/dist/property-DwPD283A.js.map +1 -0
- package/dist/{publishDraftGraph-X0Wr9txE.js → publishDraftGraph-BOn3_Occ.js} +6 -9
- package/dist/{publishDraftGraph-X0Wr9txE.js.map → publishDraftGraph-BOn3_Occ.js.map} +1 -1
- package/dist/{resetAmbiguousLegacyItemData-Ci6PM_vC.js → resetAmbiguousLegacyItemData-BkYmBeJc.js} +14 -3
- package/dist/{resetAmbiguousLegacyItemData-Ci6PM_vC.js.map → resetAmbiguousLegacyItemData-BkYmBeJc.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-DFVdnYq8.js → resolveModelForSyncedSeed-BL24nLa7.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-DFVdnYq8.js.map → resolveModelForSyncedSeed-BL24nLa7.js.map} +1 -1
- package/dist/src/Item/Item.d.ts +21 -3
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Item/service/actors/runPublish.d.ts +11 -2
- package/dist/src/Item/service/actors/runPublish.d.ts.map +1 -1
- package/dist/src/Item/service/itemMachineSingle.d.ts +12 -2
- package/dist/src/Item/service/itemMachineSingle.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts +5 -3
- package/dist/src/ItemProperty/ItemProperty.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/saveItemStorage.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
- package/dist/src/Model/Model.d.ts +10 -4
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/Model/index.d.ts +2 -2
- package/dist/src/ModelProperty/ModelProperty.d.ts +10 -2
- package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +3 -0
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts.map +1 -1
- package/dist/src/Schema/Schema.d.ts +2 -2
- package/dist/src/Schema/Schema.d.ts.map +1 -1
- package/dist/src/Schema/index.d.ts +0 -1
- package/dist/src/Schema/index.d.ts.map +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts +4 -1
- package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/browser/helpers/tolerantWebAccess.d.ts +79 -4
- package/dist/src/browser/helpers/tolerantWebAccess.d.ts.map +1 -1
- package/dist/src/browser/workers/FileDownloader.d.ts +19 -4
- package/dist/src/browser/workers/FileDownloader.d.ts.map +1 -1
- package/dist/src/browser/workers/filesDownload.d.ts.map +1 -1
- package/dist/src/client/ClientManager.d.ts +30 -11
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/client/actors/platformClassesInit.d.ts +6 -0
- package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/src/client/actors/processSchemaFiles.d.ts.map +1 -1
- package/dist/src/client/actors/saveConfig.d.ts +13 -6
- package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
- package/dist/src/db/migrateLegacyItemStorageRows.d.ts +57 -0
- package/dist/src/db/migrateLegacyItemStorageRows.d.ts.map +1 -0
- package/dist/src/db/read/getCompositeChildPaths.d.ts +13 -0
- package/dist/src/db/read/getCompositeChildPaths.d.ts.map +1 -0
- package/dist/src/db/read/getItems.d.ts.map +1 -1
- package/dist/src/db/read/getPublishPayload.d.ts +1 -1
- package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/src/db/read/getPublishUploads.d.ts +32 -3
- package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
- package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -1
- package/dist/src/db/write/claimUnpublishedDrafts.d.ts +2 -0
- package/dist/src/db/write/claimUnpublishedDrafts.d.ts.map +1 -1
- package/dist/src/db/write/convertVerbatimItemStorageRow.d.ts +44 -0
- package/dist/src/db/write/convertVerbatimItemStorageRow.d.ts.map +1 -0
- package/dist/src/db/write/createNewItem.d.ts.map +1 -1
- package/dist/src/eventBus.d.ts +5 -0
- package/dist/src/eventBus.d.ts.map +1 -1
- package/dist/src/events/files/download.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts +3 -3
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/IFileManager.d.ts +25 -1
- package/dist/src/helpers/FileManager/IFileManager.d.ts.map +1 -1
- package/dist/src/helpers/arweaveContentTags.d.ts +33 -0
- package/dist/src/helpers/arweaveContentTags.d.ts.map +1 -0
- package/dist/src/helpers/cachedPropertyRefresh.d.ts +12 -0
- package/dist/src/helpers/cachedPropertyRefresh.d.ts.map +1 -0
- package/dist/src/helpers/compositeUpload.d.ts +28 -0
- package/dist/src/helpers/compositeUpload.d.ts.map +1 -0
- package/dist/src/helpers/db.d.ts +3 -0
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/helpers/easSdk.d.ts +16 -0
- package/dist/src/helpers/easSdk.d.ts.map +1 -0
- package/dist/src/helpers/entity/detachRowsBeforeDelete.d.ts +16 -0
- package/dist/src/helpers/entity/detachRowsBeforeDelete.d.ts.map +1 -0
- package/dist/src/helpers/entity/entityDestroy.d.ts +2 -0
- package/dist/src/helpers/entity/entityDestroy.d.ts.map +1 -1
- package/dist/src/helpers/itemStorageFile.d.ts +57 -0
- package/dist/src/helpers/itemStorageFile.d.ts.map +1 -0
- package/dist/src/helpers/mapWithConcurrency.d.ts +7 -0
- package/dist/src/helpers/mapWithConcurrency.d.ts.map +1 -0
- package/dist/src/helpers/mimeTypes.d.ts +43 -0
- package/dist/src/helpers/mimeTypes.d.ts.map +1 -0
- package/dist/src/helpers/ownership.d.ts +28 -4
- package/dist/src/helpers/ownership.d.ts.map +1 -1
- package/dist/src/helpers/property/index.d.ts +37 -51
- package/dist/src/helpers/property/index.d.ts.map +1 -1
- package/dist/src/helpers/publishConfig.d.ts +27 -8
- package/dist/src/helpers/publishConfig.d.ts.map +1 -1
- package/dist/src/helpers/storageDir.d.ts +16 -0
- package/dist/src/helpers/storageDir.d.ts.map +1 -0
- package/dist/src/helpers/tabCoordinator.d.ts +5 -1
- package/dist/src/helpers/tabCoordinator.d.ts.map +1 -1
- package/dist/src/helpers/tabEvents.d.ts +23 -2
- package/dist/src/helpers/tabEvents.d.ts.map +1 -1
- package/dist/src/helpers/updateSchema.d.ts +5 -0
- package/dist/src/helpers/updateSchema.d.ts.map +1 -1
- package/dist/src/helpers/waitForEntityIdle.d.ts +5 -0
- package/dist/src/helpers/waitForEntityIdle.d.ts.map +1 -1
- package/dist/src/imports/json.d.ts +9 -0
- package/dist/src/imports/json.d.ts.map +1 -1
- package/dist/src/index.d.ts +11 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/interfaces/IItem.d.ts +7 -1
- package/dist/src/interfaces/IItem.d.ts.map +1 -1
- package/dist/src/node/db/Db.d.ts.map +1 -1
- package/dist/src/node/helpers/PathResolver.d.ts.map +1 -1
- package/dist/src/node/index.d.ts +8 -1
- package/dist/src/node/index.d.ts.map +1 -1
- package/dist/src/platform/index.browser.d.ts +2 -0
- package/dist/src/platform/index.browser.d.ts.map +1 -1
- package/dist/src/platform/index.node.d.ts +2 -0
- package/dist/src/platform/index.node.d.ts.map +1 -1
- package/dist/src/types/fileManager.d.ts +3 -14
- package/dist/src/types/fileManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +12 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/machines.d.ts +2 -0
- package/dist/src/types/machines.d.ts.map +1 -1
- package/dist/src/types/property.d.ts +8 -0
- package/dist/src/types/property.d.ts.map +1 -1
- package/dist/src/types/publish.d.ts +14 -0
- package/dist/src/types/publish.d.ts.map +1 -1
- package/dist/{syncDbWithEas-BU-jZ5bJ.js → syncDbWithEas-Bv2Fe38J.js} +17 -17
- package/dist/{syncDbWithEas-BU-jZ5bJ.js.map → syncDbWithEas-Bv2Fe38J.js.map} +1 -1
- package/dist/tabEvents-9s2WCYw-.js +335 -0
- package/dist/tabEvents-9s2WCYw-.js.map +1 -0
- package/dist/tolerantWebAccess-iUu80pAP.js +551 -0
- package/dist/tolerantWebAccess-iUu80pAP.js.map +1 -0
- package/dist/{updateSeedRevokedAt-iLpzae1i.js → updateSeedRevokedAt-zBfi931j.js} +3 -3
- package/dist/{updateSeedRevokedAt-iLpzae1i.js.map → updateSeedRevokedAt-zBfi931j.js.map} +1 -1
- package/package.json +11 -12
- package/src/node/easLodashRegister.js +4 -0
- package/dist/BasePathResolver-BdxCSIzn.js +0 -679
- package/dist/BasePathResolver-BdxCSIzn.js.map +0 -1
- package/dist/ClientManager-DDA9956Y.js.map +0 -1
- package/dist/Item-D4FigtYS.js.map +0 -1
- package/dist/ModelProperty-BDt6AU2h.js.map +0 -1
- package/dist/Schema-B8xqLWkL.js.map +0 -1
- package/dist/cjs/ModelProperty-B-cZm1yU.js +0 -1977
- package/dist/cjs/ModelProperty-B-cZm1yU.js.map +0 -1
- package/dist/cjs/Schema-STP972Xw.js +0 -5256
- package/dist/cjs/Schema-STP972Xw.js.map +0 -1
- package/dist/cjs/SchemaValidationService-CKNW1bKg.js +0 -778
- package/dist/cjs/SchemaValidationService-CKNW1bKg.js.map +0 -1
- package/dist/cjs/backfillMetadataPropertyIds-CP3y1skt.js +0 -89
- package/dist/cjs/backfillMetadataPropertyIds-CP3y1skt.js.map +0 -1
- package/dist/cjs/eas-CAnUC4wd.js +0 -138
- package/dist/cjs/eas-CAnUC4wd.js.map +0 -1
- package/dist/cjs/getItem-CWgb3e9G.js +0 -58
- package/dist/cjs/getItem-CWgb3e9G.js.map +0 -1
- package/dist/cjs/getPublishPayload-BsZWiJ03.js +0 -1603
- package/dist/cjs/getPublishPayload-BsZWiJ03.js.map +0 -1
- package/dist/cjs/getPublishUploads-BQr8aMVP.js +0 -495
- package/dist/cjs/getPublishUploads-BQr8aMVP.js.map +0 -1
- package/dist/cjs/index-nA5PxBSs.js +0 -70
- package/dist/cjs/index-nA5PxBSs.js.map +0 -1
- package/dist/cjs/index-usKaANAq.js +0 -22171
- package/dist/cjs/index-usKaANAq.js.map +0 -1
- package/dist/cjs/index.browser-BSf8HpnU.js +0 -22
- package/dist/cjs/index.browser-BSf8HpnU.js.map +0 -1
- package/dist/cjs/property-xMwPhQ5N.js +0 -327
- package/dist/cjs/property-xMwPhQ5N.js.map +0 -1
- package/dist/cjs/publishDraftGraph-BRWlR1KO.js +0 -403
- package/dist/cjs/publishDraftGraph-BRWlR1KO.js.map +0 -1
- package/dist/cjs/resetAmbiguousLegacyItemData-8nfkj9rz.js +0 -116
- package/dist/cjs/resetAmbiguousLegacyItemData-8nfkj9rz.js.map +0 -1
- package/dist/cjs/resolveModelForSyncedSeed-kYRuDWYw.js +0 -49
- package/dist/cjs/resolveModelForSyncedSeed-kYRuDWYw.js.map +0 -1
- package/dist/cjs/syncDbWithEas-DqRhV8o2.js +0 -886
- package/dist/cjs/syncDbWithEas-DqRhV8o2.js.map +0 -1
- package/dist/db-CQt-gcAl.js.map +0 -1
- package/dist/eas-CpOD74Ke.js.map +0 -1
- package/dist/getPublishPayload-Xl3sRkR-.js.map +0 -1
- package/dist/getPublishUploads-DHP01KgU.js +0 -484
- package/dist/getPublishUploads-DHP01KgU.js.map +0 -1
- package/dist/index-BGt4_oPO.js +0 -31
- package/dist/index-BGt4_oPO.js.map +0 -1
- package/dist/index-CSOQFAOn.js.map +0 -1
- package/dist/index-Xl1_4Lmb.js.map +0 -1
- package/dist/index.browser-CjTe0vt1.js.map +0 -1
- package/dist/index.node-Cfa7npS6.js.map +0 -1
- package/dist/main.cjs +0 -84
- package/dist/main.cjs.map +0 -1
- package/dist/property-BrXkY1Rg.js.map +0 -1
- package/dist/tabEvents-BZJMY5uK.js +0 -1344
- package/dist/tabEvents-BZJMY5uK.js.map +0 -1
- package/dist/tolerantWebAccess-BZ2RA_mb.js +0 -160
- package/dist/tolerantWebAccess-BZ2RA_mb.js.map +0 -1
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import { fromCallback, setup, assign, createActor } from 'xstate';
|
|
2
|
-
import '
|
|
3
|
-
import {
|
|
4
|
-
import { x as getModelIdByFileId, n as normalizeDataType, y as getModelId } from './db-CQt-gcAl.js';
|
|
2
|
+
import { i as isActorStopped, w as writeProcessMachine, c as currentEvictionEpoch, M as Model, b as anyEvictionSince, s as schemaEvictedSince } from './index-8O3Uow-Y.js';
|
|
3
|
+
import { E as BaseDb, s as models, u as properties, z as schemas, q as modelSchemas, ai as getModelIdByFileId, n as normalizeDataType, $ as generateId, M as ModelPropertyDataTypes, J as BaseFileManager, aj as getModelId, ak as setCachedPropertyRefresher } from './BasePathResolver-Cm4apKRb.js';
|
|
5
4
|
import 'pluralize';
|
|
6
|
-
import {
|
|
7
|
-
import { eq, and } from 'drizzle-orm';
|
|
5
|
+
import { eq, and, inArray } from 'drizzle-orm';
|
|
8
6
|
import { modelPropertiesToObject } from './model-DGMe-TTm.js';
|
|
9
7
|
import debug from 'debug';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import '
|
|
8
|
+
import { S as Schema } from './Schema-CpMNEnUO.js';
|
|
9
|
+
import { D as DEFAULT_READY_TIMEOUT_MS, n as waitForEntityIdle, o as createReactiveProxy, q as findEntity, t as forceRemoveFromCaches, u as runDestroyLifecycle } from './Item-DBFchXpC.js';
|
|
10
|
+
import './ClientManager-i3nJASkg.js';
|
|
11
|
+
import 'lodash-es';
|
|
12
|
+
import './tabEvents-9s2WCYw-.js';
|
|
14
13
|
import '@seedprotocol/arweave';
|
|
15
14
|
import '@seedprotocol/eas';
|
|
16
15
|
import '@noble/hashes/sha3';
|
|
17
16
|
import '@noble/hashes/utils';
|
|
18
17
|
import '@seedprotocol/query';
|
|
19
|
-
import 'lodash-es';
|
|
20
18
|
import 'drizzle-orm/casing';
|
|
21
19
|
import '@sinclair/typebox';
|
|
22
20
|
import 'drizzle-orm/sqlite-core';
|
|
23
21
|
import 'nanoid';
|
|
24
22
|
import 'nanoid-dictionary';
|
|
25
|
-
import '
|
|
23
|
+
import '@noble/hashes/sha256';
|
|
24
|
+
import './SchemaValidationService-DieV4KL-.js';
|
|
26
25
|
import '@sinclair/typebox/value';
|
|
27
26
|
import 'rxjs';
|
|
28
27
|
|
|
@@ -34,15 +33,15 @@ const logger$3 = debug('seedSdk:modelProperty:actors:saveToSchema');
|
|
|
34
33
|
*/
|
|
35
34
|
async function getSchemaNameFromModel(modelName) {
|
|
36
35
|
// Get the latest schema files and find which one contains this model
|
|
37
|
-
const _mod_0 = await import('./ClientManager-
|
|
38
|
-
const _ns_0 = _mod_0.
|
|
36
|
+
const _mod_0 = await import('./ClientManager-i3nJASkg.js');
|
|
37
|
+
const _ns_0 = _mod_0.K;
|
|
39
38
|
const schemaHelpersMod = _ns_0;
|
|
40
39
|
const { listLatestSchemaFiles } = schemaHelpersMod;
|
|
41
40
|
const latestSchemas = await listLatestSchemaFiles();
|
|
42
41
|
for (const schema of latestSchemas) {
|
|
43
42
|
try {
|
|
44
|
-
const _mod_1 = await import('./BasePathResolver-
|
|
45
|
-
const _ns_1 = _mod_1.
|
|
43
|
+
const _mod_1 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
44
|
+
const _ns_1 = _mod_1.a_;
|
|
46
45
|
const fileManagerMod = _ns_1;
|
|
47
46
|
const { BaseFileManager } = fileManagerMod;
|
|
48
47
|
const content = await BaseFileManager.readFileAsString(schema.filePath);
|
|
@@ -61,7 +60,7 @@ async function getSchemaNameFromModel(modelName) {
|
|
|
61
60
|
const saveToSchema = fromCallback(({ sendBack, input: { context }, self }) => {
|
|
62
61
|
const _saveToSchema = async () => {
|
|
63
62
|
// Use dynamic import to break circular dependency
|
|
64
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
63
|
+
const validationServiceMod = await import('./SchemaValidationService-DieV4KL-.js');
|
|
65
64
|
const { SchemaValidationService } = validationServiceMod;
|
|
66
65
|
const validationService = new SchemaValidationService();
|
|
67
66
|
// Validate property structure before saving
|
|
@@ -80,15 +79,15 @@ const saveToSchema = fromCallback(({ sendBack, input: { context }, self }) => {
|
|
|
80
79
|
throw new Error(`Model not found for modelId: ${context.modelId}`);
|
|
81
80
|
}
|
|
82
81
|
// Persist to database only - schema file is updated only when user calls Schema.saveNewVersion()
|
|
83
|
-
const _mod_2 = await import('./
|
|
84
|
-
const _ns_2 = _mod_2.
|
|
82
|
+
const _mod_2 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
83
|
+
const _ns_2 = _mod_2.b2;
|
|
85
84
|
const dbMod = _ns_2;
|
|
86
85
|
const { savePropertyToDb } = dbMod;
|
|
87
86
|
await savePropertyToDb(context);
|
|
88
87
|
// Mark schema as draft so user knows to save
|
|
89
88
|
const schemaName = context._schemaName ?? (await getSchemaNameFromModel(context.modelName));
|
|
90
89
|
if (schemaName) {
|
|
91
|
-
const _mod_3 = await import('./Schema-
|
|
90
|
+
const _mod_3 = await import('./Schema-CpMNEnUO.js');
|
|
92
91
|
const _ns_3 = _mod_3.b;
|
|
93
92
|
const schemaMod = _ns_3;
|
|
94
93
|
const { Schema } = schemaMod;
|
|
@@ -126,8 +125,8 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
126
125
|
const schemaFileIdForResolve = fullContext._propertyFileId || (typeof fullContext.id === 'string' ? fullContext.id : undefined);
|
|
127
126
|
if (schemaFileIdForResolve && (fullContext.modelName === undefined || fullContext.dataType === undefined)) {
|
|
128
127
|
try {
|
|
129
|
-
const _mod_4 = await import('./
|
|
130
|
-
const _ns_4 = _mod_4.
|
|
128
|
+
const _mod_4 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
129
|
+
const _ns_4 = _mod_4.b2;
|
|
131
130
|
const dbMod = _ns_4;
|
|
132
131
|
const { getPropertyModelNameAndDataType, getModelNameByModelId } = dbMod;
|
|
133
132
|
let fromDb;
|
|
@@ -173,8 +172,8 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
173
172
|
if (fullContext.modelName && fullContext.name && schemaFileId) {
|
|
174
173
|
logger$2(`[compareAndMarkDraft] _originalValues not set, but saving to database anyway for property ${context.modelName}:${context.name} (schemaFileId: ${schemaFileId})`);
|
|
175
174
|
try {
|
|
176
|
-
const _mod_5 = await import('./
|
|
177
|
-
const _ns_5 = _mod_5.
|
|
175
|
+
const _mod_5 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
176
|
+
const _ns_5 = _mod_5.b2;
|
|
178
177
|
const dbMod = _ns_5;
|
|
179
178
|
const { savePropertyToDb } = dbMod;
|
|
180
179
|
// Ensure _propertyFileId is set for savePropertyToDb to find the property
|
|
@@ -235,8 +234,8 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
235
234
|
logger$2(`Property ${fullContext.modelName}:${fullContext.name} has changes, marking as edited`);
|
|
236
235
|
logger$2(`[compareAndMarkDraft] Context when saving: id=${fullContext.id}, _propertyFileId=${fullContext._propertyFileId}, name=${fullContext.name}, _originalValues.name=${fullContext._originalValues?.name}`);
|
|
237
236
|
// Use dynamic import to break circular dependency
|
|
238
|
-
const _mod_6 = await import('./
|
|
239
|
-
const _ns_6 = _mod_6.
|
|
237
|
+
const _mod_6 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
238
|
+
const _ns_6 = _mod_6.b2;
|
|
240
239
|
const dbMod = _ns_6;
|
|
241
240
|
const { savePropertyToDb } = dbMod;
|
|
242
241
|
// Save to database (but not JSON file) - always save to DB when there are changes
|
|
@@ -251,7 +250,7 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
251
250
|
// Mark schema as draft if schema name is available
|
|
252
251
|
if (fullContext._schemaName) {
|
|
253
252
|
// Get the Schema instance and mark it as draft
|
|
254
|
-
const _mod_7 = await import('./Schema-
|
|
253
|
+
const _mod_7 = await import('./Schema-CpMNEnUO.js');
|
|
255
254
|
const _ns_7 = _mod_7.b;
|
|
256
255
|
const schemaMod = _ns_7;
|
|
257
256
|
const { Schema } = schemaMod;
|
|
@@ -273,7 +272,7 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
273
272
|
logger$2(`Property ${fullContext.modelName}:${fullContext.name} has no changes`);
|
|
274
273
|
// Clear isEdited flag in database
|
|
275
274
|
try {
|
|
276
|
-
const _mod_8 = await import('./index-
|
|
275
|
+
const _mod_8 = await import('./index-AVFTVp1m.js');
|
|
277
276
|
const _ns_8 = _mod_8.s;
|
|
278
277
|
const seedSchemaMod = _ns_8;
|
|
279
278
|
const { properties: propertiesTable, models: modelsTable } = seedSchemaMod;
|
|
@@ -282,8 +281,8 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
282
281
|
const db = BaseDb.getAppDb();
|
|
283
282
|
if (db && fullContext.modelName && fullContext.name) {
|
|
284
283
|
// Find this property's model (model names are only unique per schema)
|
|
285
|
-
const _mod_9 = await import('./
|
|
286
|
-
const _ns_9 = _mod_9.
|
|
284
|
+
const _mod_9 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
285
|
+
const _ns_9 = _mod_9.b1;
|
|
287
286
|
const { resolveModelRecord } = _ns_9;
|
|
288
287
|
const modelRecord = await resolveModelRecord(fullContext.modelName, {
|
|
289
288
|
modelId: typeof fullContext.modelId === 'number' ? fullContext.modelId : undefined,
|
|
@@ -342,8 +341,8 @@ const validateProperty = fromCallback(({ sendBack, input: { context }, self }) =
|
|
|
342
341
|
// Brief wait so trackPendingWrite from ModelProperty.create() has time to run (it's in setTimeout(0))
|
|
343
342
|
await new Promise((r) => setTimeout(r, 60));
|
|
344
343
|
try {
|
|
345
|
-
const _mod_10 = await import('./
|
|
346
|
-
const _ns_10 = _mod_10.
|
|
344
|
+
const _mod_10 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
345
|
+
const _ns_10 = _mod_10.b2;
|
|
347
346
|
const dbMod = _ns_10;
|
|
348
347
|
const { getPropertyModelNameAndDataType, getModelNameByModelId } = dbMod;
|
|
349
348
|
// Try pending write first (property row may not exist yet)
|
|
@@ -396,10 +395,10 @@ const validateProperty = fromCallback(({ sendBack, input: { context }, self }) =
|
|
|
396
395
|
fullContext = { ...fullContext, dataType: (fullContext.dataType ?? context._originalValues?.dataType) || 'Text' };
|
|
397
396
|
}
|
|
398
397
|
// Use dynamic imports to break circular dependencies
|
|
399
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
398
|
+
const validationServiceMod = await import('./SchemaValidationService-DieV4KL-.js');
|
|
400
399
|
const { SchemaValidationService } = validationServiceMod;
|
|
401
400
|
const validationService = new SchemaValidationService();
|
|
402
|
-
const _mod_11 = await import('./Schema-
|
|
401
|
+
const _mod_11 = await import('./Schema-CpMNEnUO.js');
|
|
403
402
|
const _ns_11 = _mod_11.b;
|
|
404
403
|
const schemaMod = _ns_11;
|
|
405
404
|
const { Schema } = schemaMod;
|
|
@@ -623,6 +622,16 @@ const modelPropertyMachine = setup({
|
|
|
623
622
|
_schemaName: event.schemaName,
|
|
624
623
|
})),
|
|
625
624
|
},
|
|
625
|
+
// The property's row and schema file already have these values (e.g. after a schema update reloaded
|
|
626
|
+
// them), so unlike updateContext it isn't an edit: no validation, draft marking or saveToSchema.
|
|
627
|
+
syncedFromStorage: {
|
|
628
|
+
actions: assign(({ context, event }) => ({
|
|
629
|
+
...event.values,
|
|
630
|
+
_originalValues: context._originalValues
|
|
631
|
+
? { ...context._originalValues, ...event.values }
|
|
632
|
+
: context._originalValues,
|
|
633
|
+
})),
|
|
634
|
+
},
|
|
626
635
|
destroyStarted: {
|
|
627
636
|
actions: assign({ _destroyError: null }),
|
|
628
637
|
},
|
|
@@ -1019,8 +1028,8 @@ class ModelProperty {
|
|
|
1019
1028
|
return fallbackIsEdited;
|
|
1020
1029
|
}
|
|
1021
1030
|
// Find this property's model (by modelId when known; model names are only unique per schema)
|
|
1022
|
-
const _mod_12 = await import('./
|
|
1023
|
-
const _ns_12 = _mod_12.
|
|
1031
|
+
const _mod_12 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
1032
|
+
const _ns_12 = _mod_12.b1;
|
|
1024
1033
|
const { resolveModelRecord } = _ns_12;
|
|
1025
1034
|
const modelRecord = await resolveModelRecord(property.modelName, this._ownerModelScope(property), db);
|
|
1026
1035
|
const modelRecords = modelRecord ? [modelRecord] : [];
|
|
@@ -1057,8 +1066,8 @@ class ModelProperty {
|
|
|
1057
1066
|
return undefined;
|
|
1058
1067
|
}
|
|
1059
1068
|
// Resolve the ref within the owning model's schema
|
|
1060
|
-
const _mod_13 = await import('./
|
|
1061
|
-
const _ns_13 = _mod_13.
|
|
1069
|
+
const _mod_13 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
1070
|
+
const _ns_13 = _mod_13.b1;
|
|
1062
1071
|
const { resolveRefModelRecord } = _ns_13;
|
|
1063
1072
|
const refModelRecord = await resolveRefModelRecord(refModelName, property ? this._ownerModelScope(property) : { schemaName: this._getSnapshotContext()._schemaName }, db);
|
|
1064
1073
|
if (refModelRecord?.id) {
|
|
@@ -1103,8 +1112,8 @@ class ModelProperty {
|
|
|
1103
1112
|
}
|
|
1104
1113
|
}
|
|
1105
1114
|
if (!model && modelId) {
|
|
1106
|
-
const _mod_14 = await import('./
|
|
1107
|
-
const _ns_14 = _mod_14.
|
|
1115
|
+
const _mod_14 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
1116
|
+
const _ns_14 = _mod_14.b1;
|
|
1108
1117
|
const { resolveModelRecord } = _ns_14;
|
|
1109
1118
|
const modelFileId = (await resolveModelRecord(property.modelName, { modelId }))?.schemaFileId;
|
|
1110
1119
|
model = modelFileId ? Model.getById(modelFileId) : undefined;
|
|
@@ -1266,7 +1275,7 @@ class ModelProperty {
|
|
|
1266
1275
|
throw new Error('Property is required');
|
|
1267
1276
|
}
|
|
1268
1277
|
const waitForReady = options?.waitForReady !== false;
|
|
1269
|
-
const readyTimeout = options?.readyTimeout ??
|
|
1278
|
+
const readyTimeout = options?.readyTimeout ?? DEFAULT_READY_TIMEOUT_MS;
|
|
1270
1279
|
const schemaName = options?.schemaName;
|
|
1271
1280
|
// Handle 'type' field from JSON schema format - convert to 'dataType'
|
|
1272
1281
|
// Normalize to PascalCase so lowercase values from JSON (e.g. 'text') work
|
|
@@ -1398,7 +1407,16 @@ class ModelProperty {
|
|
|
1398
1407
|
// A _dbId means the data was loaded from an existing row (createById, getPropertySchema), so
|
|
1399
1408
|
// there's nothing to write. Writing it back anyway raced deletes of that row's model (FK error).
|
|
1400
1409
|
const isPersisted = typeof propertyWithId._dbId === 'number';
|
|
1410
|
+
// Settles when the row write finishes; create() waits for it when waitForReady is on, so a
|
|
1411
|
+
// failed write rejects create() instead of resolving with nothing in the DB.
|
|
1412
|
+
let writeDone = Promise.resolve();
|
|
1401
1413
|
if (hasModelId && propertyFileId && !isPersisted) {
|
|
1414
|
+
let resolveWrite;
|
|
1415
|
+
let rejectWrite;
|
|
1416
|
+
writeDone = new Promise((resolve, reject) => {
|
|
1417
|
+
resolveWrite = resolve;
|
|
1418
|
+
rejectWrite = reject;
|
|
1419
|
+
});
|
|
1402
1420
|
// Wait for writeProcess to be spawned (it's spawned in idle state entry action)
|
|
1403
1421
|
// Retry a few times if writeProcess isn't available yet
|
|
1404
1422
|
let retries = 0;
|
|
@@ -1407,8 +1425,10 @@ class ModelProperty {
|
|
|
1407
1425
|
const service = proxiedInstance.getService();
|
|
1408
1426
|
const snapshot = service.getSnapshot();
|
|
1409
1427
|
// Unloaded or evicted (e.g. Schema.destroy) before the write started: nothing to write to
|
|
1410
|
-
if (isActorStopped(service))
|
|
1428
|
+
if (isActorStopped(service)) {
|
|
1429
|
+
resolveWrite();
|
|
1411
1430
|
return;
|
|
1431
|
+
}
|
|
1412
1432
|
if (snapshot.value === 'idle' && snapshot.context.writeProcess) {
|
|
1413
1433
|
const writeProcess = snapshot.context.writeProcess;
|
|
1414
1434
|
// Resolve dbModelId - convert from string (modelFileId) to number (database ID) if needed
|
|
@@ -1446,11 +1466,14 @@ class ModelProperty {
|
|
|
1446
1466
|
logger(`ERROR: Cannot write property "${property.name}" - no modelId available`);
|
|
1447
1467
|
console.error(`[ModelProperty.create] ERROR: Cannot write property "${property.name}" - no modelId available. modelId: ${propertyWithId.modelId}, modelName: ${propertyWithId.modelName}`);
|
|
1448
1468
|
// Don't clear pending write here - it might resolve later
|
|
1469
|
+
rejectWrite(new Error(`Cannot write property "${property.name}": model ${propertyWithId.modelName ?? propertyWithId.modelId} has no database row`));
|
|
1449
1470
|
return;
|
|
1450
1471
|
}
|
|
1451
1472
|
// Resolving the modelId awaited the DB; the instance may have been stopped meanwhile
|
|
1452
|
-
if (isActorStopped(service))
|
|
1473
|
+
if (isActorStopped(service)) {
|
|
1474
|
+
resolveWrite();
|
|
1453
1475
|
return;
|
|
1476
|
+
}
|
|
1454
1477
|
// Track pending write now that we have the resolved modelId
|
|
1455
1478
|
this.trackPendingWrite(propertyFileId, resolvedModelId);
|
|
1456
1479
|
logger(`Triggering write process for property "${property.name}" (modelId: ${resolvedModelId}, propertyFileId: ${propertyFileId})`);
|
|
@@ -1459,6 +1482,7 @@ class ModelProperty {
|
|
|
1459
1482
|
if (currentWriteState.value === 'success') {
|
|
1460
1483
|
// Write already succeeded
|
|
1461
1484
|
void this.completePendingWrite(propertyFileId, resolvedModelId);
|
|
1485
|
+
resolveWrite();
|
|
1462
1486
|
}
|
|
1463
1487
|
else {
|
|
1464
1488
|
// Set up subscription to catch future state changes
|
|
@@ -1467,6 +1491,7 @@ class ModelProperty {
|
|
|
1467
1491
|
writeSubscription.unsubscribe();
|
|
1468
1492
|
logger(`[writeProcess subscription] Write succeeded for property "${property.name}" (propertyFileId: ${propertyFileId})`);
|
|
1469
1493
|
void this.completePendingWrite(propertyFileId, resolvedModelId);
|
|
1494
|
+
resolveWrite();
|
|
1470
1495
|
}
|
|
1471
1496
|
else if (writeSnapshot.value === 'error') {
|
|
1472
1497
|
writeSubscription.unsubscribe();
|
|
@@ -1475,6 +1500,7 @@ class ModelProperty {
|
|
|
1475
1500
|
logger(`Write process error details:`, errorContext.error);
|
|
1476
1501
|
// Mark pending write as error
|
|
1477
1502
|
this.clearPendingWrite(propertyFileId, 'error');
|
|
1503
|
+
rejectWrite(new Error(`Failed to write property "${property.name}": ${errorContext.error?.message || 'Unknown error'}`));
|
|
1478
1504
|
}
|
|
1479
1505
|
});
|
|
1480
1506
|
}
|
|
@@ -1503,14 +1529,25 @@ class ModelProperty {
|
|
|
1503
1529
|
console.error(`[ModelProperty.create] ERROR: writeProcess not available after ${maxRetries} retries for property "${property.name}" (propertyFileId: ${propertyFileId})`);
|
|
1504
1530
|
// Mark as error if we couldn't even start the write process
|
|
1505
1531
|
this.clearPendingWrite(propertyFileId, 'error');
|
|
1532
|
+
rejectWrite(new Error(`Failed to write property "${property.name}": its write process never started`));
|
|
1506
1533
|
}
|
|
1507
1534
|
};
|
|
1508
1535
|
// Start checking after a short delay to allow state machine to initialize
|
|
1509
1536
|
setTimeout(checkAndSend, 0);
|
|
1510
1537
|
}
|
|
1511
|
-
if (!waitForReady)
|
|
1538
|
+
if (!waitForReady) {
|
|
1539
|
+
// Nobody awaits the write; failures are already logged above.
|
|
1540
|
+
writeDone.catch(() => { });
|
|
1512
1541
|
return proxiedInstance;
|
|
1513
|
-
|
|
1542
|
+
}
|
|
1543
|
+
let timer;
|
|
1544
|
+
const writeWithin = Promise.race([
|
|
1545
|
+
writeDone,
|
|
1546
|
+
new Promise((_, reject) => {
|
|
1547
|
+
timer = setTimeout(() => reject(new Error(`Property "${property.name}" was not written within ${readyTimeout}ms`)), readyTimeout);
|
|
1548
|
+
}),
|
|
1549
|
+
]).finally(() => clearTimeout(timer));
|
|
1550
|
+
return Promise.all([waitForEntityIdle(proxiedInstance, { timeout: readyTimeout }), writeWithin]).then(() => proxiedInstance);
|
|
1514
1551
|
}
|
|
1515
1552
|
/** Whether an idIndex entry still points at a cached instance with that id. */
|
|
1516
1553
|
static isIndexEntryCurrent(propertyFileId, entry) {
|
|
@@ -1659,13 +1696,93 @@ class ModelProperty {
|
|
|
1659
1696
|
}
|
|
1660
1697
|
return instance;
|
|
1661
1698
|
}
|
|
1699
|
+
/**
|
|
1700
|
+
* Give cached instances of these properties the values their rows now have (e.g. after a schema
|
|
1701
|
+
* update reloaded them: renamed, dataType or storage changed). Nothing else updates them: createById
|
|
1702
|
+
* and the Model's property refresh return a cached instance as is. A renamed instance's
|
|
1703
|
+
* "modelName:oldName" cache entry is re-keyed so creating the property by its new name finds it.
|
|
1704
|
+
* Instances with unsaved edits are left alone, as addModelsToDb leaves edited rows alone.
|
|
1705
|
+
*/
|
|
1706
|
+
static async refreshFromDb(propertyFileIds) {
|
|
1707
|
+
const ids = new Set(propertyFileIds.filter(Boolean));
|
|
1708
|
+
if (ids.size === 0)
|
|
1709
|
+
return;
|
|
1710
|
+
const db = BaseDb.getAppDb();
|
|
1711
|
+
if (!db)
|
|
1712
|
+
return;
|
|
1713
|
+
const rows = await db
|
|
1714
|
+
.select({
|
|
1715
|
+
schemaFileId: properties.schemaFileId,
|
|
1716
|
+
name: properties.name,
|
|
1717
|
+
dataType: properties.dataType,
|
|
1718
|
+
refModelId: properties.refModelId,
|
|
1719
|
+
refModelName: models.name,
|
|
1720
|
+
refValueType: properties.refValueType,
|
|
1721
|
+
required: properties.required,
|
|
1722
|
+
storageType: properties.storageType,
|
|
1723
|
+
localStorageDir: properties.localStorageDir,
|
|
1724
|
+
filenameSuffix: properties.filenameSuffix,
|
|
1725
|
+
})
|
|
1726
|
+
.from(properties)
|
|
1727
|
+
.leftJoin(models, eq(models.id, properties.refModelId))
|
|
1728
|
+
.where(inArray(properties.schemaFileId, [...ids]));
|
|
1729
|
+
for (const row of rows) {
|
|
1730
|
+
const propertyFileId = row.schemaFileId;
|
|
1731
|
+
if (!propertyFileId || !row.name)
|
|
1732
|
+
continue;
|
|
1733
|
+
const dataType = row.dataType;
|
|
1734
|
+
const rowValues = {
|
|
1735
|
+
name: row.name,
|
|
1736
|
+
dataType,
|
|
1737
|
+
refValueType: row.refValueType ?? undefined,
|
|
1738
|
+
required: row.required ?? false,
|
|
1739
|
+
storageType: row.storageType ?? undefined,
|
|
1740
|
+
localStorageDir: row.localStorageDir ?? undefined,
|
|
1741
|
+
filenameSuffix: row.filenameSuffix ?? undefined,
|
|
1742
|
+
};
|
|
1743
|
+
if (row.refModelId) {
|
|
1744
|
+
rowValues.refModelId = row.refModelId;
|
|
1745
|
+
if (row.refModelName) {
|
|
1746
|
+
rowValues.ref = row.refModelName;
|
|
1747
|
+
rowValues.refModelName = row.refModelName;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
else if (dataType !== ModelPropertyDataTypes.Relation && dataType !== ModelPropertyDataTypes.List) {
|
|
1751
|
+
// No longer a reference. (A Relation/List row without refModelId may just not have its
|
|
1752
|
+
// referenced model's row yet, so keep the instance's ref then.)
|
|
1753
|
+
rowValues.refModelId = undefined;
|
|
1754
|
+
rowValues.ref = undefined;
|
|
1755
|
+
rowValues.refModelName = undefined;
|
|
1756
|
+
}
|
|
1757
|
+
for (const [cacheKey, entry] of [...this.instanceCache.entries()]) {
|
|
1758
|
+
const { instance } = entry;
|
|
1759
|
+
if (isActorStopped(instance._service))
|
|
1760
|
+
continue;
|
|
1761
|
+
const context = instance._getSnapshotContext();
|
|
1762
|
+
if (context.id !== propertyFileId || context._isEdited)
|
|
1763
|
+
continue;
|
|
1764
|
+
const changed = Object.fromEntries(Object.entries(rowValues).filter(([key, value]) => context[key] !== value));
|
|
1765
|
+
if (Object.keys(changed).length === 0)
|
|
1766
|
+
continue;
|
|
1767
|
+
instance._service.send({ type: 'syncedFromStorage', values: changed });
|
|
1768
|
+
const newCacheKey = changed.name && context.modelName ? `${context.modelName}:${changed.name}` : undefined;
|
|
1769
|
+
if (newCacheKey && cacheKey === `${context.modelName}:${context.name}` && !this.instanceCache.has(newCacheKey)) {
|
|
1770
|
+
this.instanceCache.delete(cacheKey);
|
|
1771
|
+
this.instanceCache.set(newCacheKey, entry);
|
|
1772
|
+
if (this.idIndex.get(propertyFileId)?.instance === instance) {
|
|
1773
|
+
this.idIndex.set(propertyFileId, { cacheKey: newCacheKey, instance });
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1662
1779
|
/**
|
|
1663
1780
|
* Find ModelProperty instance by propertyFileId
|
|
1664
1781
|
* Waits for the property to be fully loaded (idle state) by default
|
|
1665
1782
|
* @param options - Find options including propertyFileId and wait configuration
|
|
1666
1783
|
* @returns ModelProperty instance if found, undefined otherwise
|
|
1667
1784
|
*/
|
|
1668
|
-
static async find({ propertyFileId, waitForReady = true, readyTimeout =
|
|
1785
|
+
static async find({ propertyFileId, waitForReady = true, readyTimeout = DEFAULT_READY_TIMEOUT_MS, }) {
|
|
1669
1786
|
if (!propertyFileId) {
|
|
1670
1787
|
return undefined;
|
|
1671
1788
|
}
|
|
@@ -1682,7 +1799,7 @@ class ModelProperty {
|
|
|
1682
1799
|
* Loads property rows from DB for the given modelFileId, creates instances via createById, optionally waits for idle.
|
|
1683
1800
|
*/
|
|
1684
1801
|
static async all(modelFileId, options) {
|
|
1685
|
-
const { waitForReady = false, readyTimeout =
|
|
1802
|
+
const { waitForReady = false, readyTimeout = DEFAULT_READY_TIMEOUT_MS } = options ?? {};
|
|
1686
1803
|
if (!modelFileId) {
|
|
1687
1804
|
return [];
|
|
1688
1805
|
}
|
|
@@ -1954,6 +2071,8 @@ class ModelProperty {
|
|
|
1954
2071
|
.where(and(eq(schemas.name, schemaName), eq(models.name, modelName), eq(properties.name, propertyName)))
|
|
1955
2072
|
.limit(1);
|
|
1956
2073
|
if (propertyRecords.length > 0 && propertyRecords[0].propertyId != null) {
|
|
2074
|
+
const { detachPropertyRows } = await import('./detachRowsBeforeDelete-S0q-DJPT.js');
|
|
2075
|
+
await detachPropertyRows(db, [propertyRecords[0].propertyId]);
|
|
1957
2076
|
await db
|
|
1958
2077
|
.delete(properties)
|
|
1959
2078
|
.where(eq(properties.id, propertyRecords[0].propertyId));
|
|
@@ -1988,6 +2107,7 @@ ModelProperty.instanceCache = new Map();
|
|
|
1988
2107
|
ModelProperty.idIndex = new Map();
|
|
1989
2108
|
// Pending writes tracking
|
|
1990
2109
|
ModelProperty.pendingWrites = new Map();
|
|
2110
|
+
setCachedPropertyRefresher((propertyFileIds) => ModelProperty.refreshFromDb(propertyFileIds));
|
|
1991
2111
|
|
|
1992
2112
|
var ModelProperty$1 = /*#__PURE__*/Object.freeze({
|
|
1993
2113
|
__proto__: null,
|
|
@@ -1995,4 +2115,4 @@ var ModelProperty$1 = /*#__PURE__*/Object.freeze({
|
|
|
1995
2115
|
});
|
|
1996
2116
|
|
|
1997
2117
|
export { ModelProperty };
|
|
1998
|
-
//# sourceMappingURL=ModelProperty-
|
|
2118
|
+
//# sourceMappingURL=ModelProperty-BS49g01Y.js.map
|