@seedprotocol/sdk 0.7.9 → 0.7.10-next.1353.g74aeeed
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{BaseFileManager-BAlySv8w.js → BaseFileManager-DLou1TZS.js} +5 -1
- package/dist/BaseFileManager-DLou1TZS.js.map +1 -0
- package/dist/{Item-Bf4kWKpH.js → Item-oPnmIehk.js} +571 -346
- package/dist/Item-oPnmIehk.js.map +1 -0
- package/dist/{ModelProperty-BlaEgb_U.js → ModelProperty-D2vJozmW.js} +95 -62
- package/dist/ModelProperty-D2vJozmW.js.map +1 -0
- package/dist/{Schema-J_1f6p0c.js → Schema-BMXRF4j9.js} +88 -52
- package/dist/Schema-BMXRF4j9.js.map +1 -0
- package/dist/{SchemaValidationService-CnmKyzR-.js → SchemaValidationService-CieGrj5c.js} +5 -5
- package/dist/{SchemaValidationService-CnmKyzR-.js.map → SchemaValidationService-CieGrj5c.js.map} +1 -1
- package/dist/{errors-C1qUEZ7A.js → browserSupport-C64rX-2I.js} +38 -2
- package/dist/browserSupport-C64rX-2I.js.map +1 -0
- package/dist/{configurePlatform-CiOJ1R3q.js → configurePlatform-WkmvqeTO.js} +2 -2
- package/dist/{configurePlatform-CiOJ1R3q.js.map → configurePlatform-WkmvqeTO.js.map} +1 -1
- package/dist/{detachRowsBeforeDelete-sEaUwlOU.js → detachRowsBeforeDelete-BZr_0iZU.js} +2 -2
- package/dist/{detachRowsBeforeDelete-sEaUwlOU.js.map → detachRowsBeforeDelete-BZr_0iZU.js.map} +1 -1
- package/dist/dist/{BaseFileManager-BAlySv8w.d.ts → BaseFileManager-DLou1TZS.d.ts} +3 -1
- package/dist/dist/BaseFileManager-DLou1TZS.d.ts.map +1 -0
- package/dist/dist/{configurePlatform-CiOJ1R3q.d.ts → configurePlatform-WkmvqeTO.d.ts} +1 -1
- package/dist/dist/configurePlatform-WkmvqeTO.d.ts.map +1 -0
- package/dist/dist/{index-D0V-mjCV.d.ts → index-BjWk0x4-.d.ts} +1 -1
- package/dist/dist/{index-D0V-mjCV.d.ts.map → index-BjWk0x4-.d.ts.map} +1 -1
- package/dist/dist/{index.node-CYPemH-t.d.ts → index.node-BfiBriEq.d.ts} +7 -1
- package/dist/dist/{index.node-CYPemH-t.d.ts.map → index.node-BfiBriEq.d.ts.map} +1 -1
- package/dist/dist/platform.node.d.ts +2 -2
- package/dist/{eas-wB_fQ8Tc.js → eas-FZPPqxqe.js} +5 -5
- package/dist/{eas-wB_fQ8Tc.js.map → eas-FZPPqxqe.js.map} +1 -1
- package/dist/{errors-DLSoqSHG.js → errors-CnT0fSMK.js} +185 -97
- package/dist/errors-CnT0fSMK.js.map +1 -0
- package/dist/{getPublishPayload-BnIwpwz1.js → getPublishPayload-DKuEaq96.js} +8 -8
- package/dist/{getPublishPayload-BnIwpwz1.js.map → getPublishPayload-DKuEaq96.js.map} +1 -1
- package/dist/{getPublishPendingDiff-D6_-A5ns.js → getPublishPendingDiff-CH5xLMjU.js} +7 -7
- package/dist/{getPublishPendingDiff-D6_-A5ns.js.map → getPublishPendingDiff-CH5xLMjU.js.map} +1 -1
- package/dist/{getPublishUploads-sS6JfPgz.js → getPublishUploads-DivYpgNw.js} +7 -7
- package/dist/{getPublishUploads-sS6JfPgz.js.map → getPublishUploads-DivYpgNw.js.map} +1 -1
- package/dist/{index-D0V-mjCV.js → index-BjWk0x4-.js} +2 -2
- package/dist/index-BjWk0x4-.js.map +1 -0
- package/dist/{index-CYGWPoOx.js → index-CZMWKXLM.js} +7 -7
- package/dist/index-CZMWKXLM.js.map +1 -0
- package/dist/{index-BVBmz_cc.js → index-DXRhFg1N.js} +7 -7
- package/dist/index-DXRhFg1N.js.map +1 -0
- package/dist/{index-DmTtj1nk.js → index-Gh42_47r.js} +402 -20
- package/dist/index-Gh42_47r.js.map +1 -0
- package/dist/{index.browser-CUmBVYen.js → index.browser-DQstVvRV.js} +46 -10
- package/dist/index.browser-DQstVvRV.js.map +1 -0
- package/dist/{index.node-CYPemH-t.js → index.node-BfiBriEq.js} +31 -4
- package/dist/index.node-BfiBriEq.js.map +1 -0
- package/dist/main.js +17 -16
- package/dist/main.js.map +1 -1
- package/dist/{modelPropertyRecordSchemas-C7UgA5TH.js → modelPropertyRecordSchemas-DEe-lYhn.js} +5 -5
- package/dist/{modelPropertyRecordSchemas-C7UgA5TH.js.map → modelPropertyRecordSchemas-DEe-lYhn.js.map} +1 -1
- package/dist/node.js +8 -8
- package/dist/platform.browser.js +6 -6
- package/dist/platform.node.js +4 -4
- package/dist/{property-BxUYznH0.js → property-iNW1N3vm.js} +8 -8
- package/dist/{property-BxUYznH0.js.map → property-iNW1N3vm.js.map} +1 -1
- package/dist/{publishGraph-EcB40Uii.js → publishGraph-CRn_N3NT.js} +5 -5
- package/dist/{publishGraph-EcB40Uii.js.map → publishGraph-CRn_N3NT.js.map} +1 -1
- package/dist/{readHtmlBodyForStorageSeed-D6KPtWoR.js → readHtmlBodyForStorageSeed-B7HgPmq6.js} +10 -10
- package/dist/{readHtmlBodyForStorageSeed-D6KPtWoR.js.map → readHtmlBodyForStorageSeed-B7HgPmq6.js.map} +1 -1
- package/dist/src/Item/Item.d.ts +26 -5
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts +20 -5
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/loadProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/propertyWrite.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/src/Model/Model.d.ts +45 -34
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts +31 -13
- package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/src/Schema/Schema.d.ts +36 -27
- package/dist/src/Schema/Schema.d.ts.map +1 -1
- package/dist/src/archive/exportArchive.d.ts +57 -0
- package/dist/src/archive/exportArchive.d.ts.map +1 -0
- package/dist/src/browser/db/Db.d.ts +5 -0
- 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/browser/helpers/tolerantWebAccess.d.ts +12 -1
- package/dist/src/browser/helpers/tolerantWebAccess.d.ts.map +1 -1
- package/dist/src/client/ClientManager.d.ts +14 -4
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/db/Db/BaseDb.d.ts +2 -0
- package/dist/src/db/Db/BaseDb.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/errors.d.ts +11 -0
- package/dist/src/helpers/FileManager/errors.d.ts.map +1 -1
- package/dist/src/helpers/browserSupport.d.ts +23 -0
- package/dist/src/helpers/browserSupport.d.ts.map +1 -0
- package/dist/src/helpers/cachedPropertyRefresh.d.ts +6 -6
- package/dist/src/helpers/cachedPropertyRefresh.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityCache.d.ts +45 -3
- package/dist/src/helpers/entity/entityCache.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityLifecycle.d.ts +21 -3
- package/dist/src/helpers/entity/entityLifecycle.d.ts.map +1 -1
- package/dist/src/helpers/propertyDefinition.d.ts +2 -0
- package/dist/src/helpers/propertyDefinition.d.ts.map +1 -1
- package/dist/src/helpers/schemaApply.d.ts.map +1 -1
- package/dist/src/helpers/tabCoordinator.d.ts +9 -2
- package/dist/src/helpers/tabCoordinator.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/interfaces/IDb.d.ts +6 -0
- package/dist/src/interfaces/IDb.d.ts.map +1 -1
- package/dist/src/node/db/Db.d.ts +6 -0
- package/dist/src/node/db/Db.d.ts.map +1 -1
- package/dist/src/outbox/conflicts.d.ts.map +1 -1
- package/dist/src/outbox/outbox.d.ts +6 -0
- package/dist/src/outbox/outbox.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +16 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/{syncDbWithEas-CA7PvBgu.js → syncDbWithEas-FuyqoEKk.js} +14 -14
- package/dist/{syncDbWithEas-CA7PvBgu.js.map → syncDbWithEas-FuyqoEKk.js.map} +1 -1
- package/dist/{tabEvents-CaVmngqr.js → tabEvents-DT5ez6io.js} +38 -12
- package/dist/tabEvents-DT5ez6io.js.map +1 -0
- package/dist/{tolerantWebAccess-BJqViq08.js → tolerantWebAccess-zEseJ2zT.js} +53 -13
- package/dist/tolerantWebAccess-zEseJ2zT.js.map +1 -0
- package/dist/{updateSeedRevokedAt-BL9Bg-G7.js → updateSeedRevokedAt-B9JRwr5T.js} +3 -3
- package/dist/{updateSeedRevokedAt-BL9Bg-G7.js.map → updateSeedRevokedAt-B9JRwr5T.js.map} +1 -1
- package/package.json +10 -12
- package/dist/BaseFileManager-BAlySv8w.js.map +0 -1
- package/dist/Item-Bf4kWKpH.js.map +0 -1
- package/dist/ModelProperty-BlaEgb_U.js.map +0 -1
- package/dist/Schema-J_1f6p0c.js.map +0 -1
- package/dist/dist/BaseFileManager-BAlySv8w.d.ts.map +0 -1
- package/dist/dist/configurePlatform-CiOJ1R3q.d.ts.map +0 -1
- package/dist/errors-C1qUEZ7A.js.map +0 -1
- package/dist/errors-DLSoqSHG.js.map +0 -1
- package/dist/index-BVBmz_cc.js.map +0 -1
- package/dist/index-CYGWPoOx.js.map +0 -1
- package/dist/index-D0V-mjCV.js.map +0 -1
- package/dist/index-DmTtj1nk.js.map +0 -1
- package/dist/index.browser-CUmBVYen.js.map +0 -1
- package/dist/index.node-CYPemH-t.js.map +0 -1
- package/dist/tabEvents-CaVmngqr.js.map +0 -1
- package/dist/tolerantWebAccess-BJqViq08.js.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { fromCallback, setup, assign, createActor, waitFor } from 'xstate';
|
|
2
|
-
import { M as Model, F as saveDefinition } from './errors-
|
|
3
|
-
import { r as resolveModelRecord, n as normalizeDataType, m as generateId, a2 as definitionOnlyFields, a3 as persistDefinitionFields, a4 as getPropertyDefinition, a5 as propertyDefinitionFromRow, M as ModelPropertyDataTypes, a6 as
|
|
2
|
+
import { M as Model, F as saveDefinition } from './errors-CnT0fSMK.js';
|
|
3
|
+
import { r as resolveModelRecord, n as normalizeDataType, m as generateId, a2 as definitionOnlyFields, a3 as persistDefinitionFields, a4 as getPropertyDefinition, a5 as propertyDefinitionFromRow, M as ModelPropertyDataTypes, a6 as addCachedPropertyRefresher } from './tabEvents-DT5ez6io.js';
|
|
4
4
|
import 'pluralize';
|
|
5
5
|
import '@seedprotocol/eas';
|
|
6
|
-
import { B as BaseDb, d as models, l as properties, t as schemas, j as modelSchemas, w as BaseFileManager } from './BaseFileManager-
|
|
7
|
-
import {
|
|
6
|
+
import { B as BaseDb, d as models, l as properties, t as schemas, j as modelSchemas, w as BaseFileManager } from './BaseFileManager-DLou1TZS.js';
|
|
7
|
+
import { ak as isActorStopped, T as applyContextUpdate, U as isInternalUpdate, al as differsFromOriginals, V as evictionLog, a8 as modelPropertiesToObject, Z as DEFAULT_READY_TIMEOUT_MS, _ as createReactiveProxy, am as onEntityTeardown, $ as runEntityLoad, a0 as waitForEntityReady, W as holdChild, X as isEntityTornDown, a2 as EntityUnloadedError, a3 as entityStatus, a1 as evictEntities, a4 as releaseEntity, a5 as destroyEntity, a6 as EntityCache } from './Item-oPnmIehk.js';
|
|
8
8
|
import debug from 'debug';
|
|
9
9
|
import '@seedprotocol/arweave';
|
|
10
10
|
import { eq, and, inArray } from 'drizzle-orm';
|
|
11
|
-
import { S as Schema } from './Schema-
|
|
11
|
+
import { S as Schema } from './Schema-BMXRF4j9.js';
|
|
12
12
|
import '@sinclair/typebox';
|
|
13
13
|
import 'lodash-es';
|
|
14
14
|
import '@noble/hashes/sha3';
|
|
@@ -19,7 +19,7 @@ import 'nanoid';
|
|
|
19
19
|
import 'nanoid-dictionary';
|
|
20
20
|
import '@noble/hashes/sha256';
|
|
21
21
|
import 'rxjs';
|
|
22
|
-
import './SchemaValidationService-
|
|
22
|
+
import './SchemaValidationService-CieGrj5c.js';
|
|
23
23
|
import '@sinclair/typebox/value';
|
|
24
24
|
|
|
25
25
|
const logger$3 = debug('seedSdk:modelProperty:actors:saveToSchema');
|
|
@@ -30,14 +30,14 @@ const logger$3 = debug('seedSdk:modelProperty:actors:saveToSchema');
|
|
|
30
30
|
*/
|
|
31
31
|
async function getSchemaNameFromModel(modelName) {
|
|
32
32
|
// Get the latest schema files and find which one contains this model
|
|
33
|
-
const _mod_0 = await import('./errors-
|
|
33
|
+
const _mod_0 = await import('./errors-CnT0fSMK.js');
|
|
34
34
|
const _ns_0 = _mod_0.a5;
|
|
35
35
|
const schemaHelpersMod = _ns_0;
|
|
36
36
|
const { listLatestSchemaFiles } = schemaHelpersMod;
|
|
37
37
|
const latestSchemas = await listLatestSchemaFiles();
|
|
38
38
|
for (const schema of latestSchemas) {
|
|
39
39
|
try {
|
|
40
|
-
const _mod_1 = await import('./BaseFileManager-
|
|
40
|
+
const _mod_1 = await import('./BaseFileManager-DLou1TZS.js');
|
|
41
41
|
const _ns_1 = _mod_1.A;
|
|
42
42
|
const fileManagerMod = _ns_1;
|
|
43
43
|
const { BaseFileManager } = fileManagerMod;
|
|
@@ -57,7 +57,7 @@ async function getSchemaNameFromModel(modelName) {
|
|
|
57
57
|
const saveToSchema = fromCallback(({ sendBack, input: { context }, self }) => {
|
|
58
58
|
const _saveToSchema = async () => {
|
|
59
59
|
// Use dynamic import to break circular dependency
|
|
60
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
60
|
+
const validationServiceMod = await import('./SchemaValidationService-CieGrj5c.js');
|
|
61
61
|
const { SchemaValidationService } = validationServiceMod;
|
|
62
62
|
const validationService = new SchemaValidationService();
|
|
63
63
|
// Validate property structure before saving
|
|
@@ -76,22 +76,22 @@ const saveToSchema = fromCallback(({ sendBack, input: { context }, self }) => {
|
|
|
76
76
|
throw new Error(`Model not found for modelId: ${context.modelId}`);
|
|
77
77
|
}
|
|
78
78
|
// Persist to database only - schema file is updated only when user calls Schema.saveNewVersion()
|
|
79
|
-
const _mod_2 = await import('./tabEvents-
|
|
80
|
-
const _ns_2 = _mod_2.
|
|
79
|
+
const _mod_2 = await import('./tabEvents-DT5ez6io.js');
|
|
80
|
+
const _ns_2 = _mod_2.bk;
|
|
81
81
|
const dbMod = _ns_2;
|
|
82
82
|
const { savePropertyToDb } = dbMod;
|
|
83
83
|
await savePropertyToDb(context);
|
|
84
84
|
// Mark schema as draft so user knows to save
|
|
85
85
|
const schemaName = context._schemaName ?? (await getSchemaNameFromModel(context.modelName));
|
|
86
86
|
if (schemaName) {
|
|
87
|
-
const _mod_3 = await import('./Schema-
|
|
87
|
+
const _mod_3 = await import('./Schema-BMXRF4j9.js');
|
|
88
88
|
const _ns_3 = _mod_3.a;
|
|
89
89
|
const schemaMod = _ns_3;
|
|
90
90
|
const { Schema } = schemaMod;
|
|
91
91
|
// Stopped meanwhile (unloaded, or evicted with its schema): don't load the schema again
|
|
92
92
|
if (isActorStopped(self))
|
|
93
93
|
return;
|
|
94
|
-
const schema = await Schema.find({ schemaName, waitForReady: false
|
|
94
|
+
const schema = await Schema.find({ schemaName, waitForReady: false });
|
|
95
95
|
schema?.getService().send({
|
|
96
96
|
type: 'markAsDraft',
|
|
97
97
|
propertyKey: `${context.modelName}:${context.name}`,
|
|
@@ -122,8 +122,8 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
122
122
|
const schemaFileIdForResolve = fullContext._propertyFileId || (typeof fullContext.id === 'string' ? fullContext.id : undefined);
|
|
123
123
|
if (schemaFileIdForResolve && (fullContext.modelName === undefined || fullContext.dataType === undefined)) {
|
|
124
124
|
try {
|
|
125
|
-
const _mod_4 = await import('./tabEvents-
|
|
126
|
-
const _ns_4 = _mod_4.
|
|
125
|
+
const _mod_4 = await import('./tabEvents-DT5ez6io.js');
|
|
126
|
+
const _ns_4 = _mod_4.bh;
|
|
127
127
|
const { resolveModelRecord, resolvePropertyModelRecord } = _ns_4;
|
|
128
128
|
const fromDb = await resolvePropertyModelRecord(schemaFileIdForResolve);
|
|
129
129
|
if (fromDb) {
|
|
@@ -161,8 +161,8 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
161
161
|
if (fullContext.modelName && fullContext.name && schemaFileId) {
|
|
162
162
|
logger$2(`[compareAndMarkDraft] _originalValues not set, but saving to database anyway for property ${context.modelName}:${context.name} (schemaFileId: ${schemaFileId})`);
|
|
163
163
|
try {
|
|
164
|
-
const _mod_5 = await import('./tabEvents-
|
|
165
|
-
const _ns_5 = _mod_5.
|
|
164
|
+
const _mod_5 = await import('./tabEvents-DT5ez6io.js');
|
|
165
|
+
const _ns_5 = _mod_5.bk;
|
|
166
166
|
const dbMod = _ns_5;
|
|
167
167
|
const { savePropertyToDb } = dbMod;
|
|
168
168
|
// Ensure _propertyFileId is set for savePropertyToDb to find the property
|
|
@@ -223,8 +223,8 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
223
223
|
logger$2(`Property ${fullContext.modelName}:${fullContext.name} has changes, marking as edited`);
|
|
224
224
|
logger$2(`[compareAndMarkDraft] Context when saving: id=${fullContext.id}, _propertyFileId=${fullContext._propertyFileId}, name=${fullContext.name}, _originalValues.name=${fullContext._originalValues?.name}`);
|
|
225
225
|
// Use dynamic import to break circular dependency
|
|
226
|
-
const _mod_6 = await import('./tabEvents-
|
|
227
|
-
const _ns_6 = _mod_6.
|
|
226
|
+
const _mod_6 = await import('./tabEvents-DT5ez6io.js');
|
|
227
|
+
const _ns_6 = _mod_6.bk;
|
|
228
228
|
const dbMod = _ns_6;
|
|
229
229
|
const { savePropertyToDb } = dbMod;
|
|
230
230
|
// Save to database (but not JSON file) - always save to DB when there are changes
|
|
@@ -239,14 +239,14 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
239
239
|
// Mark schema as draft if schema name is available
|
|
240
240
|
if (fullContext._schemaName) {
|
|
241
241
|
// Get the Schema instance and mark it as draft
|
|
242
|
-
const _mod_7 = await import('./Schema-
|
|
242
|
+
const _mod_7 = await import('./Schema-BMXRF4j9.js');
|
|
243
243
|
const _ns_7 = _mod_7.a;
|
|
244
244
|
const schemaMod = _ns_7;
|
|
245
245
|
const { Schema } = schemaMod;
|
|
246
246
|
// Stopped meanwhile (unloaded, or evicted with its schema): don't load the schema again
|
|
247
247
|
if (isActorStopped(self))
|
|
248
248
|
return;
|
|
249
|
-
const schema = await Schema.find({ schemaName: fullContext._schemaName, waitForReady: false
|
|
249
|
+
const schema = await Schema.find({ schemaName: fullContext._schemaName, waitForReady: false });
|
|
250
250
|
// Send event to Schema machine to mark as draft
|
|
251
251
|
schema?.getService().send({
|
|
252
252
|
type: 'markAsDraft',
|
|
@@ -259,7 +259,7 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
259
259
|
logger$2(`Property ${fullContext.modelName}:${fullContext.name} has no changes`);
|
|
260
260
|
// Clear isEdited flag in database
|
|
261
261
|
try {
|
|
262
|
-
const _mod_8 = await import('./index-
|
|
262
|
+
const _mod_8 = await import('./index-BjWk0x4-.js');
|
|
263
263
|
const _ns_8 = _mod_8.s;
|
|
264
264
|
const seedSchemaMod = _ns_8;
|
|
265
265
|
const { properties: propertiesTable } = seedSchemaMod;
|
|
@@ -268,8 +268,8 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
268
268
|
const db = BaseDb.getAppDb();
|
|
269
269
|
if (db && fullContext.modelName && fullContext.name) {
|
|
270
270
|
// Find this property's model (model names are only unique per schema)
|
|
271
|
-
const _mod_9 = await import('./tabEvents-
|
|
272
|
-
const _ns_9 = _mod_9.
|
|
271
|
+
const _mod_9 = await import('./tabEvents-DT5ez6io.js');
|
|
272
|
+
const _ns_9 = _mod_9.bh;
|
|
273
273
|
const { resolveModelRecord } = _ns_9;
|
|
274
274
|
const modelRecord = await resolveModelRecord(fullContext.modelName, {
|
|
275
275
|
modelId: typeof fullContext.modelId === 'number' ? fullContext.modelId : undefined,
|
|
@@ -326,8 +326,8 @@ const validateProperty = fromCallback(({ sendBack, input: { context }, self }) =
|
|
|
326
326
|
const schemaFileId = typeof context.id === 'string' ? context.id : undefined;
|
|
327
327
|
if (schemaFileId && (fullContext.modelName === undefined || fullContext.dataType === undefined)) {
|
|
328
328
|
try {
|
|
329
|
-
const _mod_10 = await import('./tabEvents-
|
|
330
|
-
const _ns_10 = _mod_10.
|
|
329
|
+
const _mod_10 = await import('./tabEvents-DT5ez6io.js');
|
|
330
|
+
const _ns_10 = _mod_10.bh;
|
|
331
331
|
const { resolveModelRecord, resolvePropertyModelRecord } = _ns_10;
|
|
332
332
|
// Try pending write first (property row may not exist yet)
|
|
333
333
|
if (fullContext.modelName === undefined && schemaFileId) {
|
|
@@ -360,10 +360,10 @@ const validateProperty = fromCallback(({ sendBack, input: { context }, self }) =
|
|
|
360
360
|
fullContext = { ...fullContext, dataType: (fullContext.dataType ?? context._originalValues?.dataType) || 'Text' };
|
|
361
361
|
}
|
|
362
362
|
// Use dynamic imports to break circular dependencies
|
|
363
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
363
|
+
const validationServiceMod = await import('./SchemaValidationService-CieGrj5c.js');
|
|
364
364
|
const { SchemaValidationService } = validationServiceMod;
|
|
365
365
|
const validationService = new SchemaValidationService();
|
|
366
|
-
const _mod_11 = await import('./Schema-
|
|
366
|
+
const _mod_11 = await import('./Schema-BMXRF4j9.js');
|
|
367
367
|
const _ns_11 = _mod_11.a;
|
|
368
368
|
const schemaMod = _ns_11;
|
|
369
369
|
const { Schema } = schemaMod;
|
|
@@ -379,7 +379,7 @@ const validateProperty = fromCallback(({ sendBack, input: { context }, self }) =
|
|
|
379
379
|
return;
|
|
380
380
|
if (fullContext._schemaName && fullContext.modelName) {
|
|
381
381
|
try {
|
|
382
|
-
const schema = await Schema.find({ schemaName: fullContext._schemaName, waitForReady: false
|
|
382
|
+
const schema = await Schema.find({ schemaName: fullContext._schemaName, waitForReady: false });
|
|
383
383
|
if (!schema)
|
|
384
384
|
throw new Error(`No schema named "${fullContext._schemaName}"`);
|
|
385
385
|
const schemaSnapshot = schema.getService().getSnapshot();
|
|
@@ -870,8 +870,8 @@ class ModelProperty {
|
|
|
870
870
|
return fallbackIsEdited;
|
|
871
871
|
}
|
|
872
872
|
// Find this property's model (by modelId when known; model names are only unique per schema)
|
|
873
|
-
const _mod_12 = await import('./tabEvents-
|
|
874
|
-
const _ns_12 = _mod_12.
|
|
873
|
+
const _mod_12 = await import('./tabEvents-DT5ez6io.js');
|
|
874
|
+
const _ns_12 = _mod_12.bh;
|
|
875
875
|
const { resolveModelRecord } = _ns_12;
|
|
876
876
|
const modelRecord = await resolveModelRecord(property.modelName, this._ownerModelScope(property), db);
|
|
877
877
|
const modelRecords = modelRecord ? [modelRecord] : [];
|
|
@@ -908,8 +908,8 @@ class ModelProperty {
|
|
|
908
908
|
return undefined;
|
|
909
909
|
}
|
|
910
910
|
// Resolve the ref within the owning model's schema
|
|
911
|
-
const _mod_13 = await import('./tabEvents-
|
|
912
|
-
const _ns_13 = _mod_13.
|
|
911
|
+
const _mod_13 = await import('./tabEvents-DT5ez6io.js');
|
|
912
|
+
const _ns_13 = _mod_13.bh;
|
|
913
913
|
const { resolveRefModelRecord } = _ns_13;
|
|
914
914
|
const refModelRecord = await resolveRefModelRecord(refModelName, property ? this._ownerModelScope(property) : { schemaName: this._getSnapshotContext()._schemaName }, db);
|
|
915
915
|
if (refModelRecord?.id) {
|
|
@@ -954,8 +954,8 @@ class ModelProperty {
|
|
|
954
954
|
}
|
|
955
955
|
}
|
|
956
956
|
if (!model && modelId) {
|
|
957
|
-
const _mod_14 = await import('./tabEvents-
|
|
958
|
-
const _ns_14 = _mod_14.
|
|
957
|
+
const _mod_14 = await import('./tabEvents-DT5ez6io.js');
|
|
958
|
+
const _ns_14 = _mod_14.bh;
|
|
959
959
|
const { resolveModelRecord } = _ns_14;
|
|
960
960
|
const modelFileId = (await resolveModelRecord(property.modelName, { modelId }))?.schemaFileId;
|
|
961
961
|
model = modelFileId ? Model.peek(modelFileId) : undefined;
|
|
@@ -968,10 +968,7 @@ class ModelProperty {
|
|
|
968
968
|
try {
|
|
969
969
|
// An eviction of the model's schema since this instance was built (it may already be
|
|
970
970
|
// stopped) must not re-create the model.
|
|
971
|
-
model = await Model.getByNameAsync(property.modelName, undefined, {
|
|
972
|
-
since: this._since,
|
|
973
|
-
hold: false,
|
|
974
|
-
});
|
|
971
|
+
model = await Model.getByNameAsync(property.modelName, undefined, { since: this._since });
|
|
975
972
|
}
|
|
976
973
|
catch {
|
|
977
974
|
model = undefined;
|
|
@@ -1122,7 +1119,7 @@ class ModelProperty {
|
|
|
1122
1119
|
const waitForReady = options?.waitForReady !== false;
|
|
1123
1120
|
const readyTimeout = options?.readyTimeout ?? DEFAULT_READY_TIMEOUT_MS;
|
|
1124
1121
|
const schemaName = options?.schemaName;
|
|
1125
|
-
const hold = options?.hold
|
|
1122
|
+
const hold = options?.hold === true;
|
|
1126
1123
|
// An id the caller passed (not one generated below): the cache may have that property
|
|
1127
1124
|
const givenId = typeof property.id === 'string' ? property.id : (property._propertyFileId ?? undefined);
|
|
1128
1125
|
// Handle 'type' field from JSON schema format - convert to 'dataType'
|
|
@@ -1207,7 +1204,7 @@ class ModelProperty {
|
|
|
1207
1204
|
this.cache.holdInstance(instance);
|
|
1208
1205
|
if (!waitForReady)
|
|
1209
1206
|
return instance;
|
|
1210
|
-
return
|
|
1207
|
+
return ModelProperty.readyOrRelease(instance, readyTimeout, hold);
|
|
1211
1208
|
}
|
|
1212
1209
|
const newInstance = new this(propertyWithId);
|
|
1213
1210
|
// Set schema name before async operations so the model lookup is scoped to the right schema
|
|
@@ -1227,6 +1224,7 @@ class ModelProperty {
|
|
|
1227
1224
|
return context;
|
|
1228
1225
|
},
|
|
1229
1226
|
sendUpdate: (instance, prop, value) => {
|
|
1227
|
+
instance._assertLoaded(`set ${prop} on`);
|
|
1230
1228
|
const currentContext = instance._getSnapshotContext();
|
|
1231
1229
|
if (currentContext[prop] === value)
|
|
1232
1230
|
return; // No-op, avoid triggering machine
|
|
@@ -1273,7 +1271,19 @@ class ModelProperty {
|
|
|
1273
1271
|
});
|
|
1274
1272
|
if (!waitForReady)
|
|
1275
1273
|
return proxiedInstance;
|
|
1276
|
-
return
|
|
1274
|
+
return ModelProperty.readyOrRelease(proxiedInstance, readyTimeout, hold);
|
|
1275
|
+
}
|
|
1276
|
+
/** The property once ready; a call that took a hold gives it back when it isn't ready in time. */
|
|
1277
|
+
static async readyOrRelease(property, timeout, held) {
|
|
1278
|
+
try {
|
|
1279
|
+
await waitForEntityReady(property, { timeout });
|
|
1280
|
+
}
|
|
1281
|
+
catch (error) {
|
|
1282
|
+
if (held)
|
|
1283
|
+
property.unload();
|
|
1284
|
+
throw error;
|
|
1285
|
+
}
|
|
1286
|
+
return property;
|
|
1277
1287
|
}
|
|
1278
1288
|
/**
|
|
1279
1289
|
* Writes the row of a property ModelProperty.create made, under the model row its modelId (row id
|
|
@@ -1360,20 +1370,28 @@ class ModelProperty {
|
|
|
1360
1370
|
if (owner)
|
|
1361
1371
|
holdChild(owner, instance, this.cache);
|
|
1362
1372
|
}
|
|
1363
|
-
/** The cached ModelProperty with this propertyFileId
|
|
1364
|
-
static getById(propertyFileId) {
|
|
1365
|
-
return this.cache.peek(propertyFileId);
|
|
1373
|
+
/** The cached ModelProperty with this propertyFileId. Takes no hold unless `hold: true`. */
|
|
1374
|
+
static getById(propertyFileId, options) {
|
|
1375
|
+
return options?.hold ? this.cache.hold(propertyFileId) : this.cache.peek(propertyFileId);
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Takes one more hold on a cached, running instance, released with `unload()`. False (and no
|
|
1379
|
+
* hold) when the instance isn't cached or was stopped.
|
|
1380
|
+
*/
|
|
1381
|
+
static retain(instance) {
|
|
1382
|
+
return instance.getService().getSnapshot().status === 'active' && this.cache.holdInstance(instance);
|
|
1366
1383
|
}
|
|
1367
1384
|
/**
|
|
1368
1385
|
* Create or get ModelProperty instance by propertyFileId
|
|
1369
|
-
* Queries the database to find the property if not cached
|
|
1386
|
+
* Queries the database to find the property if not cached. Takes no hold unless `hold: true`
|
|
1387
|
+
* (its model holds it either way).
|
|
1370
1388
|
*/
|
|
1371
1389
|
static async createById(propertyFileId, options) {
|
|
1372
1390
|
if (!propertyFileId) {
|
|
1373
1391
|
return undefined;
|
|
1374
1392
|
}
|
|
1375
1393
|
// Cached (an app may have created it before its model's load got here): its model holds it too
|
|
1376
|
-
const cachedInstance = this.getById(propertyFileId);
|
|
1394
|
+
const cachedInstance = this.getById(propertyFileId, options);
|
|
1377
1395
|
if (cachedInstance) {
|
|
1378
1396
|
this.holdForModel(cachedInstance);
|
|
1379
1397
|
return cachedInstance;
|
|
@@ -1431,7 +1449,7 @@ class ModelProperty {
|
|
|
1431
1449
|
}
|
|
1432
1450
|
}
|
|
1433
1451
|
// Create ModelProperty instance (sync for createById so we can send updateContext)
|
|
1434
|
-
const instance = this.create(propertyData, { waitForReady: false, hold:
|
|
1452
|
+
const instance = this.create(propertyData, { waitForReady: false, hold: options?.hold });
|
|
1435
1453
|
// Loaded for its model (Model's property list), not held by a caller
|
|
1436
1454
|
this.holdForModel(instance);
|
|
1437
1455
|
// Set isEdited from database after creation
|
|
@@ -1517,25 +1535,27 @@ class ModelProperty {
|
|
|
1517
1535
|
}
|
|
1518
1536
|
/**
|
|
1519
1537
|
* Find ModelProperty instance by propertyFileId
|
|
1520
|
-
* Waits for the property to be fully loaded (idle state) by default
|
|
1538
|
+
* Waits for the property to be fully loaded (idle state) by default. Takes no hold unless
|
|
1539
|
+
* `hold: true`; a call that throws keeps none.
|
|
1521
1540
|
* @param options - Find options including propertyFileId and wait configuration
|
|
1522
1541
|
* @returns ModelProperty instance if found, undefined otherwise
|
|
1523
1542
|
*/
|
|
1524
|
-
static async find({ propertyFileId, waitForReady = true, readyTimeout = DEFAULT_READY_TIMEOUT_MS, }) {
|
|
1543
|
+
static async find({ propertyFileId, waitForReady = true, readyTimeout = DEFAULT_READY_TIMEOUT_MS, hold = false, }) {
|
|
1525
1544
|
if (!propertyFileId) {
|
|
1526
1545
|
return undefined;
|
|
1527
1546
|
}
|
|
1528
|
-
const property = ModelProperty.
|
|
1547
|
+
const property = await ModelProperty.createById(propertyFileId, { hold });
|
|
1529
1548
|
if (property && waitForReady)
|
|
1530
|
-
await
|
|
1549
|
+
await ModelProperty.readyOrRelease(property, readyTimeout, hold);
|
|
1531
1550
|
return property;
|
|
1532
1551
|
}
|
|
1533
1552
|
/**
|
|
1534
1553
|
* Get all ModelProperty instances for a model.
|
|
1535
1554
|
* Loads property rows from DB for the given modelFileId, creates instances via createById, optionally waits for idle.
|
|
1555
|
+
* Takes no holds unless `hold: true`.
|
|
1536
1556
|
*/
|
|
1537
1557
|
static async all(modelFileId, options) {
|
|
1538
|
-
const { waitForReady = false, readyTimeout = DEFAULT_READY_TIMEOUT_MS } = options ?? {};
|
|
1558
|
+
const { waitForReady = false, readyTimeout = DEFAULT_READY_TIMEOUT_MS, hold = false } = options ?? {};
|
|
1539
1559
|
if (!modelFileId) {
|
|
1540
1560
|
return [];
|
|
1541
1561
|
}
|
|
@@ -1552,6 +1572,10 @@ class ModelProperty {
|
|
|
1552
1572
|
if (waitForReady && instances.length > 0) {
|
|
1553
1573
|
await Promise.all(instances.map((property) => waitForEntityReady(property, { timeout: readyTimeout })));
|
|
1554
1574
|
}
|
|
1575
|
+
// Once nothing can throw, so a failed call keeps no holds
|
|
1576
|
+
if (hold)
|
|
1577
|
+
for (const property of instances)
|
|
1578
|
+
this.cache.holdInstance(property);
|
|
1555
1579
|
return instances;
|
|
1556
1580
|
}
|
|
1557
1581
|
/**
|
|
@@ -1613,6 +1637,14 @@ class ModelProperty {
|
|
|
1613
1637
|
static getPendingModelId(propertyFileId) {
|
|
1614
1638
|
return this.pendingWrites.get(propertyFileId)?.modelId;
|
|
1615
1639
|
}
|
|
1640
|
+
/** Throws EntityUnloadedError, naming the property, when this instance was destroyed or evicted. */
|
|
1641
|
+
_assertLoaded(action) {
|
|
1642
|
+
if (!isEntityTornDown(this))
|
|
1643
|
+
return;
|
|
1644
|
+
const { modelName, name, id } = this._getSnapshotContext();
|
|
1645
|
+
throw new EntityUnloadedError(`Cannot ${action} property ${modelName ?? '?'}.${name ?? '?'} (${id ?? 'no id'}): this ModelProperty instance ` +
|
|
1646
|
+
'was destroyed or evicted. Look the property up again (ModelProperty.find).');
|
|
1647
|
+
}
|
|
1616
1648
|
getService() {
|
|
1617
1649
|
return this._service;
|
|
1618
1650
|
}
|
|
@@ -1671,6 +1703,7 @@ class ModelProperty {
|
|
|
1671
1703
|
return { isValid: errors.length === 0, errors };
|
|
1672
1704
|
}
|
|
1673
1705
|
save() {
|
|
1706
|
+
this._assertLoaded('save');
|
|
1674
1707
|
const snapshot = this._service.getSnapshot();
|
|
1675
1708
|
const isAlreadySaving = typeof snapshot.value === 'object' && snapshot.value !== null && 'saveToSchema' in snapshot.value;
|
|
1676
1709
|
if (isAlreadySaving) {
|
|
@@ -1730,8 +1763,8 @@ class ModelProperty {
|
|
|
1730
1763
|
});
|
|
1731
1764
|
}
|
|
1732
1765
|
/**
|
|
1733
|
-
* Releases this caller's hold
|
|
1734
|
-
*
|
|
1766
|
+
* Releases this caller's hold, if it took one. The property stays cached (see
|
|
1767
|
+
* `ModelProperty.cache`); only `destroy`, eviction or client stop stop it.
|
|
1735
1768
|
*/
|
|
1736
1769
|
unload() {
|
|
1737
1770
|
releaseEntity(this, ModelProperty.cache);
|
|
@@ -1754,7 +1787,7 @@ class ModelProperty {
|
|
|
1754
1787
|
.where(eq(properties.schemaFileId, propertyFileId))
|
|
1755
1788
|
.limit(1);
|
|
1756
1789
|
if (row) {
|
|
1757
|
-
const { detachPropertyRows } = await import('./detachRowsBeforeDelete-
|
|
1790
|
+
const { detachPropertyRows } = await import('./detachRowsBeforeDelete-BZr_0iZU.js');
|
|
1758
1791
|
await detachPropertyRows(db, [row.id]);
|
|
1759
1792
|
await db.delete(properties).where(eq(properties.id, row.id));
|
|
1760
1793
|
}
|
|
@@ -1765,7 +1798,7 @@ class ModelProperty {
|
|
|
1765
1798
|
const schemaName = context._schemaName ?? (db ? await this._resolveSchemaNameForDestroy(db, context) : undefined);
|
|
1766
1799
|
if (!schemaName)
|
|
1767
1800
|
return;
|
|
1768
|
-
const schema = await Schema.find({ schemaName, waitForReady: false
|
|
1801
|
+
const schema = await Schema.find({ schemaName, waitForReady: false });
|
|
1769
1802
|
const schemaContext = schema?.getService().getSnapshot().context;
|
|
1770
1803
|
if (schema && schemaContext?.models?.[modelName]?.properties?.[propertyName]) {
|
|
1771
1804
|
const updatedModels = { ...schemaContext.models };
|
|
@@ -1779,13 +1812,13 @@ class ModelProperty {
|
|
|
1779
1812
|
}
|
|
1780
1813
|
}
|
|
1781
1814
|
/**
|
|
1782
|
-
* Cached under its id (schemaFileId) and `modelName:name` (ADR 0014).
|
|
1783
|
-
*
|
|
1815
|
+
* Cached under its id (schemaFileId) and `modelName:name` (ADR 0014). Stays cached with no holds
|
|
1816
|
+
* until it is destroyed or evicted (`unloadUnheld: false`), as Schema and Model do.
|
|
1784
1817
|
*/
|
|
1785
|
-
ModelProperty.cache = new EntityCache();
|
|
1818
|
+
ModelProperty.cache = new EntityCache({ unloadUnheld: false });
|
|
1786
1819
|
// Pending writes tracking
|
|
1787
1820
|
ModelProperty.pendingWrites = new Map();
|
|
1788
|
-
|
|
1821
|
+
addCachedPropertyRefresher((propertyFileIds) => ModelProperty.refreshFromDb(propertyFileIds));
|
|
1789
1822
|
|
|
1790
1823
|
var ModelProperty$1 = /*#__PURE__*/Object.freeze({
|
|
1791
1824
|
__proto__: null,
|
|
@@ -1793,4 +1826,4 @@ var ModelProperty$1 = /*#__PURE__*/Object.freeze({
|
|
|
1793
1826
|
});
|
|
1794
1827
|
|
|
1795
1828
|
export { ModelProperty };
|
|
1796
|
-
//# sourceMappingURL=ModelProperty-
|
|
1829
|
+
//# sourceMappingURL=ModelProperty-D2vJozmW.js.map
|