@seedprotocol/sdk 0.7.5-next.850.g9ab585b → 0.7.5
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/{BasePathResolver-CsZHPrk9.js → BasePathResolver-CBTXCMFL.js} +20 -6
- package/dist/BasePathResolver-CBTXCMFL.js.map +1 -0
- package/dist/{ClientManager-DETTj0_z.js → ClientManager-DRf4uuei.js} +348 -222
- package/dist/ClientManager-DRf4uuei.js.map +1 -0
- package/dist/{Item-TMrVEPeX.js → Item-DTJPMjFk.js} +241 -157
- package/dist/Item-DTJPMjFk.js.map +1 -0
- package/dist/{ModelProperty-Bw6N8OMK.js → ModelProperty-Dto5C0om.js} +66 -31
- package/dist/ModelProperty-Dto5C0om.js.map +1 -0
- package/dist/{Schema-VLenyJDy.js → Schema-8DxGcORY.js} +39 -37
- package/dist/{Schema-VLenyJDy.js.map → Schema-8DxGcORY.js.map} +1 -1
- package/dist/{SchemaValidationService-CLGadxgf.js → SchemaValidationService-CE92y1TT.js} +6 -6
- package/dist/{SchemaValidationService-CLGadxgf.js.map → SchemaValidationService-CE92y1TT.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-C8fSvzy2.js → backfillMetadataPropertyIds-CRqp-BqX.js} +3 -3
- package/dist/{backfillMetadataPropertyIds-C8fSvzy2.js.map → backfillMetadataPropertyIds-CRqp-BqX.js.map} +1 -1
- package/dist/{configurePlatform-C3E0BS3u.js → configurePlatform-D4aGjKNk.js} +2 -2
- package/dist/{configurePlatform-C3E0BS3u.js.map → configurePlatform-D4aGjKNk.js.map} +1 -1
- package/dist/{detachRowsBeforeDelete-D1gTseFW.js → detachRowsBeforeDelete-BVetHtn2.js} +2 -2
- package/dist/{detachRowsBeforeDelete-D1gTseFW.js.map → detachRowsBeforeDelete-BVetHtn2.js.map} +1 -1
- package/dist/discardNewDraft-CEOouygG.js +78 -0
- package/dist/discardNewDraft-CEOouygG.js.map +1 -0
- package/dist/{eas-A82zVNQ9.js → eas-D7jvWMnI.js} +3 -3
- package/dist/{eas-A82zVNQ9.js.map → eas-D7jvWMnI.js.map} +1 -1
- package/dist/{errors-CWKup8tw.js → errors-CIrbsN_i.js} +46 -39
- package/dist/errors-CIrbsN_i.js.map +1 -0
- package/dist/{getItem-ChieGxJV.js → getItem-CxU_kT5W.js} +4 -4
- package/dist/{getItem-ChieGxJV.js.map → getItem-CxU_kT5W.js.map} +1 -1
- package/dist/{getPublishPayload-CWfjl8PM.js → getPublishPayload-DTjOKd3y.js} +13 -13
- package/dist/{getPublishPayload-CWfjl8PM.js.map → getPublishPayload-DTjOKd3y.js.map} +1 -1
- package/dist/{getPublishUploads-cLbSEXLk.js → getPublishUploads-CVTBo_OV.js} +506 -45
- package/dist/getPublishUploads-CVTBo_OV.js.map +1 -0
- package/dist/{index-CXkcz4hT.js → index-CMxEil8T.js} +8 -8
- package/dist/index-CMxEil8T.js.map +1 -0
- package/dist/{index-CURf9L4d.js → index-DWK-LOUY.js} +2 -2
- package/dist/index-DWK-LOUY.js.map +1 -0
- package/dist/{index.browser-47W0fJPw.js → index.browser-shRXMeB3.js} +11 -11
- package/dist/{index.browser-47W0fJPw.js.map → index.browser-shRXMeB3.js.map} +1 -1
- package/dist/{index.node-BiQhZQvH.js → index.node-DAKJNYp5.js} +20 -6
- package/dist/index.node-DAKJNYp5.js.map +1 -0
- package/dist/main.js +89 -504
- package/dist/main.js.map +1 -1
- package/dist/{mimeTypes-DHAHC4eZ.js → mimeTypes-C9r76DCH.js} +7 -2
- package/dist/{mimeTypes-DHAHC4eZ.js.map → mimeTypes-C9r76DCH.js.map} +1 -1
- package/dist/node.js +10 -10
- package/dist/platform.browser.js +6 -6
- package/dist/platform.node.js +4 -4
- package/dist/{property-tgPI5hMu.js → property-lz9yIpyA.js} +6 -6
- package/dist/{property-tgPI5hMu.js.map → property-lz9yIpyA.js.map} +1 -1
- package/dist/{propertyValidationRules-BLVxTejW.js → propertyValidationRules-LuIwoQoJ.js} +6 -6
- package/dist/{propertyValidationRules-BLVxTejW.js.map → propertyValidationRules-LuIwoQoJ.js.map} +1 -1
- package/dist/{publishDraftGraph-FAfecR_4.js → publishDraftGraph-CgSLPKvQ.js} +6 -6
- package/dist/{publishDraftGraph-FAfecR_4.js.map → publishDraftGraph-CgSLPKvQ.js.map} +1 -1
- package/dist/{resetAmbiguousLegacyItemData-kz2PYdZi.js → resetAmbiguousLegacyItemData-CuamkAAh.js} +2 -2
- package/dist/{resetAmbiguousLegacyItemData-kz2PYdZi.js.map → resetAmbiguousLegacyItemData-CuamkAAh.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-Dm1E4ebt.js → resolveModelForSyncedSeed-BbSctSvz.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-Dm1E4ebt.js.map → resolveModelForSyncedSeed-BbSctSvz.js.map} +1 -1
- package/dist/src/Item/Item.d.ts +9 -1
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Item/errors.d.ts +3 -1
- package/dist/src/Item/errors.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/Model/service/actors/createModelProperties.d.ts.map +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts +17 -0
- package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/src/Schema/Schema.d.ts.map +1 -1
- package/dist/src/client/ClientManager.d.ts +2 -2
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
- package/dist/src/db/alignRowPublishers.d.ts +25 -0
- package/dist/src/db/alignRowPublishers.d.ts.map +1 -0
- package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
- package/dist/src/db/read/getSchemaUidForModel.d.ts.map +1 -1
- package/dist/src/db/read/getSeedPublisher.d.ts +7 -0
- package/dist/src/db/read/getSeedPublisher.d.ts.map +1 -0
- package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -1
- package/dist/src/db/write/applyArweaveL1TransactionIdLocal.d.ts +5 -3
- package/dist/src/db/write/applyArweaveL1TransactionIdLocal.d.ts.map +1 -1
- package/dist/src/db/write/claimUnpublishedDrafts.d.ts +4 -2
- package/dist/src/db/write/claimUnpublishedDrafts.d.ts.map +1 -1
- package/dist/src/db/write/createMetadata.d.ts.map +1 -1
- package/dist/src/db/write/createNewItem.d.ts.map +1 -1
- package/dist/src/db/write/createSeed.d.ts.map +1 -1
- package/dist/src/db/write/createVersion.d.ts.map +1 -1
- package/dist/src/db/write/discardNewDraft.d.ts +8 -0
- package/dist/src/db/write/discardNewDraft.d.ts.map +1 -0
- package/dist/src/db/write/restoreDataItemIdsOverwrittenByL1.d.ts +18 -0
- package/dist/src/db/write/restoreDataItemIdsOverwrittenByL1.d.ts.map +1 -0
- package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts +13 -2
- package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts.map +1 -1
- package/dist/src/helpers/ownership.d.ts +9 -12
- package/dist/src/helpers/ownership.d.ts.map +1 -1
- package/dist/src/helpers/publishConfig.d.ts +9 -4
- package/dist/src/helpers/publishConfig.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/node/db/Db.d.ts.map +1 -1
- package/dist/{syncDbWithEas-CMCAihFh.js → syncDbWithEas-CrAY9Rl2.js} +13 -13
- package/dist/{syncDbWithEas-CMCAihFh.js.map → syncDbWithEas-CrAY9Rl2.js.map} +1 -1
- package/dist/{tabEvents-BEAmMncP.js → tabEvents-BGBYV65P.js} +4 -4
- package/dist/{tabEvents-BEAmMncP.js.map → tabEvents-BGBYV65P.js.map} +1 -1
- package/dist/{tolerantWebAccess-CqiDGEyR.js → tolerantWebAccess-DVHCEulL.js} +7 -7
- package/dist/{tolerantWebAccess-CqiDGEyR.js.map → tolerantWebAccess-DVHCEulL.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-Bw3uEStt.js → updateSeedRevokedAt-Dy5J8CfQ.js} +3 -3
- package/dist/{updateSeedRevokedAt-Bw3uEStt.js.map → updateSeedRevokedAt-Dy5J8CfQ.js.map} +1 -1
- package/package.json +5 -5
- package/dist/BasePathResolver-CsZHPrk9.js.map +0 -1
- package/dist/ClientManager-DETTj0_z.js.map +0 -1
- package/dist/Item-TMrVEPeX.js.map +0 -1
- package/dist/ModelProperty-Bw6N8OMK.js.map +0 -1
- package/dist/errors-CWKup8tw.js.map +0 -1
- package/dist/getPublishUploads-cLbSEXLk.js.map +0 -1
- package/dist/index-CURf9L4d.js.map +0 -1
- package/dist/index-CXkcz4hT.js.map +0 -1
- package/dist/index.node-BiQhZQvH.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { fromCallback, setup, assign, createActor } from 'xstate';
|
|
2
|
-
import { i as isActorStopped, w as writeProcessMachine, c as currentEvictionEpoch, M as Model, b as anyEvictionSince, s as schemaEvictedSince } from './errors-
|
|
3
|
-
import {
|
|
2
|
+
import { i as isActorStopped, w as writeProcessMachine, c as currentEvictionEpoch, M as Model, b as anyEvictionSince, s as schemaEvictedSince } from './errors-CIrbsN_i.js';
|
|
3
|
+
import { B as BaseDb, t as models, v as properties, A as schemas, r as modelSchemas, ap as getModelIdByFileId, n as normalizeDataType, al as generateId, M as ModelPropertyDataTypes, h as BaseFileManager, aq as getModelId, ar as setCachedPropertyRefresher } from './BasePathResolver-CBTXCMFL.js';
|
|
4
4
|
import 'pluralize';
|
|
5
5
|
import '@seedprotocol/eas';
|
|
6
6
|
import { eq, and, inArray } from 'drizzle-orm';
|
|
7
7
|
import { modelPropertiesToObject } from './model-oHA3YhOd.js';
|
|
8
8
|
import debug from 'debug';
|
|
9
|
-
import { S as Schema } from './Schema-
|
|
10
|
-
import { D as DEFAULT_READY_TIMEOUT_MS,
|
|
11
|
-
import './ClientManager-
|
|
9
|
+
import { S as Schema } from './Schema-8DxGcORY.js';
|
|
10
|
+
import { D as DEFAULT_READY_TIMEOUT_MS, d as waitForEntityIdle, m as createReactiveProxy, n as findEntity, o as forceRemoveFromCaches, q as runDestroyLifecycle } from './Item-DTJPMjFk.js';
|
|
11
|
+
import './ClientManager-DRf4uuei.js';
|
|
12
12
|
import 'lodash-es';
|
|
13
|
-
import './tabEvents-
|
|
13
|
+
import './tabEvents-BGBYV65P.js';
|
|
14
14
|
import '@seedprotocol/arweave';
|
|
15
15
|
import '@noble/hashes/sha3';
|
|
16
16
|
import '@noble/hashes/utils';
|
|
@@ -20,7 +20,7 @@ import 'drizzle-orm/sqlite-core';
|
|
|
20
20
|
import 'nanoid';
|
|
21
21
|
import 'nanoid-dictionary';
|
|
22
22
|
import '@noble/hashes/sha256';
|
|
23
|
-
import './SchemaValidationService-
|
|
23
|
+
import './SchemaValidationService-CE92y1TT.js';
|
|
24
24
|
import '@sinclair/typebox/value';
|
|
25
25
|
import 'rxjs';
|
|
26
26
|
|
|
@@ -32,14 +32,14 @@ const logger$3 = debug('seedSdk:modelProperty:actors:saveToSchema');
|
|
|
32
32
|
*/
|
|
33
33
|
async function getSchemaNameFromModel(modelName) {
|
|
34
34
|
// Get the latest schema files and find which one contains this model
|
|
35
|
-
const _mod_0 = await import('./ClientManager-
|
|
36
|
-
const _ns_0 = _mod_0.
|
|
35
|
+
const _mod_0 = await import('./ClientManager-DRf4uuei.js');
|
|
36
|
+
const _ns_0 = _mod_0.M;
|
|
37
37
|
const schemaHelpersMod = _ns_0;
|
|
38
38
|
const { listLatestSchemaFiles } = schemaHelpersMod;
|
|
39
39
|
const latestSchemas = await listLatestSchemaFiles();
|
|
40
40
|
for (const schema of latestSchemas) {
|
|
41
41
|
try {
|
|
42
|
-
const _mod_1 = await import('./BasePathResolver-
|
|
42
|
+
const _mod_1 = await import('./BasePathResolver-CBTXCMFL.js');
|
|
43
43
|
const _ns_1 = _mod_1.bc;
|
|
44
44
|
const fileManagerMod = _ns_1;
|
|
45
45
|
const { BaseFileManager } = fileManagerMod;
|
|
@@ -59,7 +59,7 @@ async function getSchemaNameFromModel(modelName) {
|
|
|
59
59
|
const saveToSchema = fromCallback(({ sendBack, input: { context }, self }) => {
|
|
60
60
|
const _saveToSchema = async () => {
|
|
61
61
|
// Use dynamic import to break circular dependency
|
|
62
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
62
|
+
const validationServiceMod = await import('./SchemaValidationService-CE92y1TT.js');
|
|
63
63
|
const { SchemaValidationService } = validationServiceMod;
|
|
64
64
|
const validationService = new SchemaValidationService();
|
|
65
65
|
// Validate property structure before saving
|
|
@@ -78,7 +78,7 @@ const saveToSchema = fromCallback(({ sendBack, input: { context }, self }) => {
|
|
|
78
78
|
throw new Error(`Model not found for modelId: ${context.modelId}`);
|
|
79
79
|
}
|
|
80
80
|
// Persist to database only - schema file is updated only when user calls Schema.saveNewVersion()
|
|
81
|
-
const _mod_2 = await import('./BasePathResolver-
|
|
81
|
+
const _mod_2 = await import('./BasePathResolver-CBTXCMFL.js');
|
|
82
82
|
const _ns_2 = _mod_2.bg;
|
|
83
83
|
const dbMod = _ns_2;
|
|
84
84
|
const { savePropertyToDb } = dbMod;
|
|
@@ -86,7 +86,7 @@ const saveToSchema = fromCallback(({ sendBack, input: { context }, self }) => {
|
|
|
86
86
|
// Mark schema as draft so user knows to save
|
|
87
87
|
const schemaName = context._schemaName ?? (await getSchemaNameFromModel(context.modelName));
|
|
88
88
|
if (schemaName) {
|
|
89
|
-
const _mod_3 = await import('./Schema-
|
|
89
|
+
const _mod_3 = await import('./Schema-8DxGcORY.js');
|
|
90
90
|
const _ns_3 = _mod_3.b;
|
|
91
91
|
const schemaMod = _ns_3;
|
|
92
92
|
const { Schema } = schemaMod;
|
|
@@ -124,7 +124,7 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
124
124
|
const schemaFileIdForResolve = fullContext._propertyFileId || (typeof fullContext.id === 'string' ? fullContext.id : undefined);
|
|
125
125
|
if (schemaFileIdForResolve && (fullContext.modelName === undefined || fullContext.dataType === undefined)) {
|
|
126
126
|
try {
|
|
127
|
-
const _mod_4 = await import('./BasePathResolver-
|
|
127
|
+
const _mod_4 = await import('./BasePathResolver-CBTXCMFL.js');
|
|
128
128
|
const _ns_4 = _mod_4.bg;
|
|
129
129
|
const dbMod = _ns_4;
|
|
130
130
|
const { getPropertyModelNameAndDataType, getModelNameByModelId } = dbMod;
|
|
@@ -171,7 +171,7 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
171
171
|
if (fullContext.modelName && fullContext.name && schemaFileId) {
|
|
172
172
|
logger$2(`[compareAndMarkDraft] _originalValues not set, but saving to database anyway for property ${context.modelName}:${context.name} (schemaFileId: ${schemaFileId})`);
|
|
173
173
|
try {
|
|
174
|
-
const _mod_5 = await import('./BasePathResolver-
|
|
174
|
+
const _mod_5 = await import('./BasePathResolver-CBTXCMFL.js');
|
|
175
175
|
const _ns_5 = _mod_5.bg;
|
|
176
176
|
const dbMod = _ns_5;
|
|
177
177
|
const { savePropertyToDb } = dbMod;
|
|
@@ -233,7 +233,7 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
233
233
|
logger$2(`Property ${fullContext.modelName}:${fullContext.name} has changes, marking as edited`);
|
|
234
234
|
logger$2(`[compareAndMarkDraft] Context when saving: id=${fullContext.id}, _propertyFileId=${fullContext._propertyFileId}, name=${fullContext.name}, _originalValues.name=${fullContext._originalValues?.name}`);
|
|
235
235
|
// Use dynamic import to break circular dependency
|
|
236
|
-
const _mod_6 = await import('./BasePathResolver-
|
|
236
|
+
const _mod_6 = await import('./BasePathResolver-CBTXCMFL.js');
|
|
237
237
|
const _ns_6 = _mod_6.bg;
|
|
238
238
|
const dbMod = _ns_6;
|
|
239
239
|
const { savePropertyToDb } = dbMod;
|
|
@@ -249,7 +249,7 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
249
249
|
// Mark schema as draft if schema name is available
|
|
250
250
|
if (fullContext._schemaName) {
|
|
251
251
|
// Get the Schema instance and mark it as draft
|
|
252
|
-
const _mod_7 = await import('./Schema-
|
|
252
|
+
const _mod_7 = await import('./Schema-8DxGcORY.js');
|
|
253
253
|
const _ns_7 = _mod_7.b;
|
|
254
254
|
const schemaMod = _ns_7;
|
|
255
255
|
const { Schema } = schemaMod;
|
|
@@ -271,7 +271,7 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
271
271
|
logger$2(`Property ${fullContext.modelName}:${fullContext.name} has no changes`);
|
|
272
272
|
// Clear isEdited flag in database
|
|
273
273
|
try {
|
|
274
|
-
const _mod_8 = await import('./index-
|
|
274
|
+
const _mod_8 = await import('./index-DWK-LOUY.js');
|
|
275
275
|
const _ns_8 = _mod_8.s;
|
|
276
276
|
const seedSchemaMod = _ns_8;
|
|
277
277
|
const { properties: propertiesTable, models: modelsTable } = seedSchemaMod;
|
|
@@ -280,7 +280,7 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
280
280
|
const db = BaseDb.getAppDb();
|
|
281
281
|
if (db && fullContext.modelName && fullContext.name) {
|
|
282
282
|
// Find this property's model (model names are only unique per schema)
|
|
283
|
-
const _mod_9 = await import('./BasePathResolver-
|
|
283
|
+
const _mod_9 = await import('./BasePathResolver-CBTXCMFL.js');
|
|
284
284
|
const _ns_9 = _mod_9.bf;
|
|
285
285
|
const { resolveModelRecord } = _ns_9;
|
|
286
286
|
const modelRecord = await resolveModelRecord(fullContext.modelName, {
|
|
@@ -340,7 +340,7 @@ const validateProperty = fromCallback(({ sendBack, input: { context }, self }) =
|
|
|
340
340
|
// Brief wait so trackPendingWrite from ModelProperty.create() has time to run (it's in setTimeout(0))
|
|
341
341
|
await new Promise((r) => setTimeout(r, 60));
|
|
342
342
|
try {
|
|
343
|
-
const _mod_10 = await import('./BasePathResolver-
|
|
343
|
+
const _mod_10 = await import('./BasePathResolver-CBTXCMFL.js');
|
|
344
344
|
const _ns_10 = _mod_10.bg;
|
|
345
345
|
const dbMod = _ns_10;
|
|
346
346
|
const { getPropertyModelNameAndDataType, getModelNameByModelId } = dbMod;
|
|
@@ -394,10 +394,10 @@ const validateProperty = fromCallback(({ sendBack, input: { context }, self }) =
|
|
|
394
394
|
fullContext = { ...fullContext, dataType: (fullContext.dataType ?? context._originalValues?.dataType) || 'Text' };
|
|
395
395
|
}
|
|
396
396
|
// Use dynamic imports to break circular dependencies
|
|
397
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
397
|
+
const validationServiceMod = await import('./SchemaValidationService-CE92y1TT.js');
|
|
398
398
|
const { SchemaValidationService } = validationServiceMod;
|
|
399
399
|
const validationService = new SchemaValidationService();
|
|
400
|
-
const _mod_11 = await import('./Schema-
|
|
400
|
+
const _mod_11 = await import('./Schema-8DxGcORY.js');
|
|
401
401
|
const _ns_11 = _mod_11.b;
|
|
402
402
|
const schemaMod = _ns_11;
|
|
403
403
|
const { Schema } = schemaMod;
|
|
@@ -1027,7 +1027,7 @@ class ModelProperty {
|
|
|
1027
1027
|
return fallbackIsEdited;
|
|
1028
1028
|
}
|
|
1029
1029
|
// Find this property's model (by modelId when known; model names are only unique per schema)
|
|
1030
|
-
const _mod_12 = await import('./BasePathResolver-
|
|
1030
|
+
const _mod_12 = await import('./BasePathResolver-CBTXCMFL.js');
|
|
1031
1031
|
const _ns_12 = _mod_12.bf;
|
|
1032
1032
|
const { resolveModelRecord } = _ns_12;
|
|
1033
1033
|
const modelRecord = await resolveModelRecord(property.modelName, this._ownerModelScope(property), db);
|
|
@@ -1065,7 +1065,7 @@ class ModelProperty {
|
|
|
1065
1065
|
return undefined;
|
|
1066
1066
|
}
|
|
1067
1067
|
// Resolve the ref within the owning model's schema
|
|
1068
|
-
const _mod_13 = await import('./BasePathResolver-
|
|
1068
|
+
const _mod_13 = await import('./BasePathResolver-CBTXCMFL.js');
|
|
1069
1069
|
const _ns_13 = _mod_13.bf;
|
|
1070
1070
|
const { resolveRefModelRecord } = _ns_13;
|
|
1071
1071
|
const refModelRecord = await resolveRefModelRecord(refModelName, property ? this._ownerModelScope(property) : { schemaName: this._getSnapshotContext()._schemaName }, db);
|
|
@@ -1111,7 +1111,7 @@ class ModelProperty {
|
|
|
1111
1111
|
}
|
|
1112
1112
|
}
|
|
1113
1113
|
if (!model && modelId) {
|
|
1114
|
-
const _mod_14 = await import('./BasePathResolver-
|
|
1114
|
+
const _mod_14 = await import('./BasePathResolver-CBTXCMFL.js');
|
|
1115
1115
|
const _ns_14 = _mod_14.bf;
|
|
1116
1116
|
const { resolveModelRecord } = _ns_14;
|
|
1117
1117
|
const modelFileId = (await resolveModelRecord(property.modelName, { modelId }))?.schemaFileId;
|
|
@@ -1339,7 +1339,8 @@ class ModelProperty {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
// Check if instance exists in cache
|
|
1341
1341
|
if (this.instanceCache.has(cacheKey)) {
|
|
1342
|
-
const
|
|
1342
|
+
const cachedEntry = this.instanceCache.get(cacheKey);
|
|
1343
|
+
const { instance, refCount } = cachedEntry;
|
|
1343
1344
|
const cachedContext = instance._getSnapshotContext();
|
|
1344
1345
|
// Update cached instance if new property data has fields that the cached instance doesn't have
|
|
1345
1346
|
// This handles cases where the property was created without ref initially, but now we have ref from schema
|
|
@@ -1368,7 +1369,7 @@ class ModelProperty {
|
|
|
1368
1369
|
});
|
|
1369
1370
|
}
|
|
1370
1371
|
this.instanceCache.set(cacheKey, {
|
|
1371
|
-
|
|
1372
|
+
...cachedEntry,
|
|
1372
1373
|
refCount: refCount + 1,
|
|
1373
1374
|
});
|
|
1374
1375
|
if (!waitForReady)
|
|
@@ -1588,6 +1589,18 @@ class ModelProperty {
|
|
|
1588
1589
|
index(id);
|
|
1589
1590
|
});
|
|
1590
1591
|
}
|
|
1592
|
+
/**
|
|
1593
|
+
* Turns the caller's hold from the create call just made into model ownership: the instance stays
|
|
1594
|
+
* cached and running for its model, and app holders' unload calls don't stop it.
|
|
1595
|
+
* @internal Used by the model's property loading.
|
|
1596
|
+
*/
|
|
1597
|
+
static adoptForModel(instance) {
|
|
1598
|
+
for (const [key, entry] of this.instanceCache) {
|
|
1599
|
+
if (entry.instance._service !== instance._service)
|
|
1600
|
+
continue;
|
|
1601
|
+
this.instanceCache.set(key, { ...entry, refCount: Math.max(0, entry.refCount - 1), modelOwned: true });
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1591
1604
|
/**
|
|
1592
1605
|
* Get ModelProperty instance by propertyFileId from static cache
|
|
1593
1606
|
*/
|
|
@@ -1694,6 +1707,8 @@ class ModelProperty {
|
|
|
1694
1707
|
}
|
|
1695
1708
|
// Create ModelProperty instance (sync for createById so we can send updateContext)
|
|
1696
1709
|
const instance = this.create(propertyData, { waitForReady: false });
|
|
1710
|
+
// Loaded for its model (Model's property list, the model machine), not held by a caller.
|
|
1711
|
+
this.adoptForModel(instance);
|
|
1697
1712
|
// Set isEdited from database after creation
|
|
1698
1713
|
if (isEditedFromDb) {
|
|
1699
1714
|
instance._service.send({
|
|
@@ -2020,9 +2035,24 @@ class ModelProperty {
|
|
|
2020
2035
|
}
|
|
2021
2036
|
}
|
|
2022
2037
|
}
|
|
2038
|
+
/**
|
|
2039
|
+
* Releases this caller's hold. The instance is shared: it keeps running while other callers hold
|
|
2040
|
+
* it, or while its model owns it (a model's properties are stopped when the model is evicted).
|
|
2041
|
+
* An instance nobody else holds is stopped and leaves the cache.
|
|
2042
|
+
*/
|
|
2023
2043
|
unload() {
|
|
2024
|
-
|
|
2025
|
-
|
|
2044
|
+
const entries = [...ModelProperty.instanceCache.entries()].filter(([, entry]) => entry.instance._service === this._service);
|
|
2045
|
+
if (entries.length > 0) {
|
|
2046
|
+
const [, first] = entries[0];
|
|
2047
|
+
const refCount = Math.max(0, first.refCount - 1);
|
|
2048
|
+
if (refCount > 0 || first.modelOwned) {
|
|
2049
|
+
for (const [key, entry] of entries)
|
|
2050
|
+
ModelProperty.instanceCache.set(key, { ...entry, refCount });
|
|
2051
|
+
return;
|
|
2052
|
+
}
|
|
2053
|
+
for (const [key] of entries)
|
|
2054
|
+
ModelProperty.instanceCache.delete(key);
|
|
2055
|
+
}
|
|
2026
2056
|
try {
|
|
2027
2057
|
this._service.stop();
|
|
2028
2058
|
}
|
|
@@ -2078,7 +2108,7 @@ class ModelProperty {
|
|
|
2078
2108
|
.where(and(eq(schemas.name, schemaName), eq(models.name, modelName), eq(properties.name, propertyName)))
|
|
2079
2109
|
.limit(1);
|
|
2080
2110
|
if (propertyRecords.length > 0 && propertyRecords[0].propertyId != null) {
|
|
2081
|
-
const { detachPropertyRows } = await import('./detachRowsBeforeDelete-
|
|
2111
|
+
const { detachPropertyRows } = await import('./detachRowsBeforeDelete-BVetHtn2.js');
|
|
2082
2112
|
await detachPropertyRows(db, [propertyRecords[0].propertyId]);
|
|
2083
2113
|
await db
|
|
2084
2114
|
.delete(properties)
|
|
@@ -2102,6 +2132,11 @@ class ModelProperty {
|
|
|
2102
2132
|
});
|
|
2103
2133
|
}
|
|
2104
2134
|
}
|
|
2135
|
+
/**
|
|
2136
|
+
* `refCount` counts app holders (ModelProperty.create callers that haven't unloaded). `modelOwned`
|
|
2137
|
+
* marks an instance its model created or loaded: the model keeps it until the model is evicted,
|
|
2138
|
+
* so it isn't stopped when the app's holders unload it.
|
|
2139
|
+
*/
|
|
2105
2140
|
ModelProperty.instanceCache = new Map();
|
|
2106
2141
|
/**
|
|
2107
2142
|
* propertyFileId -> where the instance with that id is cached, so getById doesn't scan the cache
|
|
@@ -2122,4 +2157,4 @@ var ModelProperty$1 = /*#__PURE__*/Object.freeze({
|
|
|
2122
2157
|
});
|
|
2123
2158
|
|
|
2124
2159
|
export { ModelProperty };
|
|
2125
|
-
//# sourceMappingURL=ModelProperty-
|
|
2160
|
+
//# sourceMappingURL=ModelProperty-Dto5C0om.js.map
|