@seedprotocol/sdk 0.7.3-next.654.g52217f6 → 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-D9K_f5cF.js → BasePathResolver-Cm4apKRb.js} +2041 -127
- package/dist/BasePathResolver-Cm4apKRb.js.map +1 -0
- package/dist/{ClientManager-C-QXqUK9.js → ClientManager-i3nJASkg.js} +249 -147
- package/dist/ClientManager-i3nJASkg.js.map +1 -0
- package/dist/{Item-C7sUUu2B.js → Item-DBFchXpC.js} +259 -169
- package/dist/Item-DBFchXpC.js.map +1 -0
- package/dist/{ModelProperty-DJxeOOrc.js → ModelProperty-BS49g01Y.js} +166 -47
- package/dist/ModelProperty-BS49g01Y.js.map +1 -0
- package/dist/{Schema-fXtvd-yL.js → Schema-CpMNEnUO.js} +53 -42
- package/dist/Schema-CpMNEnUO.js.map +1 -0
- package/dist/{SchemaValidationService-CvRS2HSO.js → SchemaValidationService-DieV4KL-.js} +15 -17
- package/dist/{SchemaValidationService-CvRS2HSO.js.map → SchemaValidationService-DieV4KL-.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-SXW-8C64.js → backfillMetadataPropertyIds-DSoOoTnX.js} +14 -7
- package/dist/{backfillMetadataPropertyIds-SXW-8C64.js.map → backfillMetadataPropertyIds-DSoOoTnX.js.map} +1 -1
- package/dist/{configurePlatform-BRw2j0ZN.js → configurePlatform-D0lQGAMQ.js} +5 -7
- package/dist/{configurePlatform-BRw2j0ZN.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-DHxfswCt.js → eas-6pjU-OuX.js} +6 -8
- package/dist/eas-6pjU-OuX.js.map +1 -0
- package/dist/{getItem-d6N_aM6S.js → getItem-CxBNZ-WL.js} +10 -11
- package/dist/{getItem-d6N_aM6S.js.map → getItem-CxBNZ-WL.js.map} +1 -1
- package/dist/{getPublishPayload-BHrxVtzY.js → getPublishPayload-CTCvRUoU.js} +50 -18
- package/dist/getPublishPayload-CTCvRUoU.js.map +1 -0
- package/dist/{getPublishUploads-BEqRiKIS.js → getPublishUploads-SFHCbf_y.js} +13 -22
- package/dist/{getPublishUploads-BEqRiKIS.js.map → getPublishUploads-SFHCbf_y.js.map} +1 -1
- package/dist/{index-s15q14rm.js → index-8O3Uow-Y.js} +125 -57
- package/dist/index-8O3Uow-Y.js.map +1 -0
- package/dist/{index-DglvthOk.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-Cm06tP4X.js → index.browser-DBhxRoe8.js} +11 -10
- package/dist/{index.browser-Cm06tP4X.js.map → index.browser-DBhxRoe8.js.map} +1 -1
- package/dist/{index.node-C30dmFgn.js → index.node-CJhlcNHM.js} +25 -13
- package/dist/index.node-CJhlcNHM.js.map +1 -0
- package/dist/main.js +27 -32
- package/dist/main.js.map +1 -1
- package/dist/node.js +19 -22
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +9 -9
- package/dist/platform.node.js +18 -5
- package/dist/platform.node.js.map +1 -1
- package/dist/{property-DhmmYAvQ.js → property-DwPD283A.js} +11 -12
- package/dist/property-DwPD283A.js.map +1 -0
- package/dist/{publishDraftGraph-yYP74WRt.js → publishDraftGraph-BOn3_Occ.js} +6 -9
- package/dist/{publishDraftGraph-yYP74WRt.js.map → publishDraftGraph-BOn3_Occ.js.map} +1 -1
- package/dist/{resetAmbiguousLegacyItemData-Bk0QyDW8.js → resetAmbiguousLegacyItemData-BkYmBeJc.js} +14 -3
- package/dist/{resetAmbiguousLegacyItemData-Bk0QyDW8.js.map → resetAmbiguousLegacyItemData-BkYmBeJc.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-8cAzvUFd.js → resolveModelForSyncedSeed-BL24nLa7.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-8cAzvUFd.js.map → resolveModelForSyncedSeed-BL24nLa7.js.map} +1 -1
- package/dist/src/Item/Item.d.ts +20 -2
- 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/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/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/db/read/getPublishPayload.d.ts +1 -1
- package/dist/src/db/read/getPublishPayload.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/eventBus.d.ts +5 -0
- package/dist/src/eventBus.d.ts.map +1 -1
- package/dist/src/helpers/cachedPropertyRefresh.d.ts +12 -0
- package/dist/src/helpers/cachedPropertyRefresh.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/ownership.d.ts +9 -1
- 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/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 +6 -4
- 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/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/{syncDbWithEas--HUA9WNb.js → syncDbWithEas-Bv2Fe38J.js} +15 -16
- package/dist/syncDbWithEas-Bv2Fe38J.js.map +1 -0
- package/dist/tabEvents-9s2WCYw-.js +335 -0
- package/dist/tabEvents-9s2WCYw-.js.map +1 -0
- package/dist/{tolerantWebAccess-BZYWt09Y.js → tolerantWebAccess-iUu80pAP.js} +9 -9
- package/dist/{tolerantWebAccess-BZYWt09Y.js.map → tolerantWebAccess-iUu80pAP.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-D_EG-q3b.js → updateSeedRevokedAt-zBfi931j.js} +3 -3
- package/dist/{updateSeedRevokedAt-D_EG-q3b.js.map → updateSeedRevokedAt-zBfi931j.js.map} +1 -1
- package/package.json +11 -12
- package/src/node/easLodashRegister.js +4 -0
- package/dist/BasePathResolver-CfSfMW5_.js +0 -676
- package/dist/BasePathResolver-CfSfMW5_.js.map +0 -1
- package/dist/ClientManager-C-QXqUK9.js.map +0 -1
- package/dist/Item-C7sUUu2B.js.map +0 -1
- package/dist/ModelProperty-DJxeOOrc.js.map +0 -1
- package/dist/Schema-fXtvd-yL.js.map +0 -1
- package/dist/cjs/ModelProperty-DXZ39Wyv.js +0 -1978
- package/dist/cjs/ModelProperty-DXZ39Wyv.js.map +0 -1
- package/dist/cjs/Schema-DdP109QD.js +0 -5257
- package/dist/cjs/Schema-DdP109QD.js.map +0 -1
- package/dist/cjs/SchemaValidationService-CSXxx7sQ.js +0 -779
- package/dist/cjs/SchemaValidationService-CSXxx7sQ.js.map +0 -1
- package/dist/cjs/backfillMetadataPropertyIds-CPYoaMl4.js +0 -90
- package/dist/cjs/backfillMetadataPropertyIds-CPYoaMl4.js.map +0 -1
- package/dist/cjs/eas-B2YDQssV.js +0 -139
- package/dist/cjs/eas-B2YDQssV.js.map +0 -1
- package/dist/cjs/getItem-DgnaQzbE.js +0 -59
- package/dist/cjs/getItem-DgnaQzbE.js.map +0 -1
- package/dist/cjs/getPublishPayload-CqlqRdot.js +0 -1604
- package/dist/cjs/getPublishPayload-CqlqRdot.js.map +0 -1
- package/dist/cjs/getPublishUploads-DsXY9S4U.js +0 -872
- package/dist/cjs/getPublishUploads-DsXY9S4U.js.map +0 -1
- package/dist/cjs/index-BHaWOwNF.js +0 -71
- package/dist/cjs/index-BHaWOwNF.js.map +0 -1
- package/dist/cjs/index-C4XlgCJ4.js +0 -22801
- package/dist/cjs/index-C4XlgCJ4.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-fa0iju0J.js +0 -328
- package/dist/cjs/property-fa0iju0J.js.map +0 -1
- package/dist/cjs/publishDraftGraph-3ASwAlD7.js +0 -403
- package/dist/cjs/publishDraftGraph-3ASwAlD7.js.map +0 -1
- package/dist/cjs/resetAmbiguousLegacyItemData-Bu_MBBYt.js +0 -117
- package/dist/cjs/resetAmbiguousLegacyItemData-Bu_MBBYt.js.map +0 -1
- package/dist/cjs/resolveModelForSyncedSeed-BANIiuFU.js +0 -49
- package/dist/cjs/resolveModelForSyncedSeed-BANIiuFU.js.map +0 -1
- package/dist/cjs/syncDbWithEas-CrmxxmUW.js +0 -887
- package/dist/cjs/syncDbWithEas-CrmxxmUW.js.map +0 -1
- package/dist/db-D9K_f5cF.js.map +0 -1
- package/dist/eas-DHxfswCt.js.map +0 -1
- package/dist/getPublishPayload-BHrxVtzY.js.map +0 -1
- package/dist/index-CiMEoGu3.js +0 -32
- package/dist/index-CiMEoGu3.js.map +0 -1
- package/dist/index-DglvthOk.js.map +0 -1
- package/dist/index-s15q14rm.js.map +0 -1
- package/dist/index.node-C30dmFgn.js.map +0 -1
- package/dist/main.cjs +0 -85
- package/dist/main.cjs.map +0 -1
- package/dist/property-DhmmYAvQ.js.map +0 -1
- package/dist/syncDbWithEas--HUA9WNb.js.map +0 -1
- package/dist/tabEvents-DguZpCCv.js +0 -1580
- package/dist/tabEvents-DguZpCCv.js.map +0 -1
|
@@ -1,29 +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-D9K_f5cF.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
23
|
import '@noble/hashes/sha256';
|
|
26
|
-
import './SchemaValidationService-
|
|
24
|
+
import './SchemaValidationService-DieV4KL-.js';
|
|
27
25
|
import '@sinclair/typebox/value';
|
|
28
26
|
import 'rxjs';
|
|
29
27
|
|
|
@@ -35,15 +33,15 @@ const logger$3 = debug('seedSdk:modelProperty:actors:saveToSchema');
|
|
|
35
33
|
*/
|
|
36
34
|
async function getSchemaNameFromModel(modelName) {
|
|
37
35
|
// Get the latest schema files and find which one contains this model
|
|
38
|
-
const _mod_0 = await import('./ClientManager-
|
|
39
|
-
const _ns_0 = _mod_0.
|
|
36
|
+
const _mod_0 = await import('./ClientManager-i3nJASkg.js');
|
|
37
|
+
const _ns_0 = _mod_0.K;
|
|
40
38
|
const schemaHelpersMod = _ns_0;
|
|
41
39
|
const { listLatestSchemaFiles } = schemaHelpersMod;
|
|
42
40
|
const latestSchemas = await listLatestSchemaFiles();
|
|
43
41
|
for (const schema of latestSchemas) {
|
|
44
42
|
try {
|
|
45
|
-
const _mod_1 = await import('./BasePathResolver-
|
|
46
|
-
const _ns_1 = _mod_1.
|
|
43
|
+
const _mod_1 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
44
|
+
const _ns_1 = _mod_1.a_;
|
|
47
45
|
const fileManagerMod = _ns_1;
|
|
48
46
|
const { BaseFileManager } = fileManagerMod;
|
|
49
47
|
const content = await BaseFileManager.readFileAsString(schema.filePath);
|
|
@@ -62,7 +60,7 @@ async function getSchemaNameFromModel(modelName) {
|
|
|
62
60
|
const saveToSchema = fromCallback(({ sendBack, input: { context }, self }) => {
|
|
63
61
|
const _saveToSchema = async () => {
|
|
64
62
|
// Use dynamic import to break circular dependency
|
|
65
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
63
|
+
const validationServiceMod = await import('./SchemaValidationService-DieV4KL-.js');
|
|
66
64
|
const { SchemaValidationService } = validationServiceMod;
|
|
67
65
|
const validationService = new SchemaValidationService();
|
|
68
66
|
// Validate property structure before saving
|
|
@@ -81,15 +79,15 @@ const saveToSchema = fromCallback(({ sendBack, input: { context }, self }) => {
|
|
|
81
79
|
throw new Error(`Model not found for modelId: ${context.modelId}`);
|
|
82
80
|
}
|
|
83
81
|
// Persist to database only - schema file is updated only when user calls Schema.saveNewVersion()
|
|
84
|
-
const _mod_2 = await import('./
|
|
85
|
-
const _ns_2 = _mod_2.
|
|
82
|
+
const _mod_2 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
83
|
+
const _ns_2 = _mod_2.b2;
|
|
86
84
|
const dbMod = _ns_2;
|
|
87
85
|
const { savePropertyToDb } = dbMod;
|
|
88
86
|
await savePropertyToDb(context);
|
|
89
87
|
// Mark schema as draft so user knows to save
|
|
90
88
|
const schemaName = context._schemaName ?? (await getSchemaNameFromModel(context.modelName));
|
|
91
89
|
if (schemaName) {
|
|
92
|
-
const _mod_3 = await import('./Schema-
|
|
90
|
+
const _mod_3 = await import('./Schema-CpMNEnUO.js');
|
|
93
91
|
const _ns_3 = _mod_3.b;
|
|
94
92
|
const schemaMod = _ns_3;
|
|
95
93
|
const { Schema } = schemaMod;
|
|
@@ -127,8 +125,8 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
127
125
|
const schemaFileIdForResolve = fullContext._propertyFileId || (typeof fullContext.id === 'string' ? fullContext.id : undefined);
|
|
128
126
|
if (schemaFileIdForResolve && (fullContext.modelName === undefined || fullContext.dataType === undefined)) {
|
|
129
127
|
try {
|
|
130
|
-
const _mod_4 = await import('./
|
|
131
|
-
const _ns_4 = _mod_4.
|
|
128
|
+
const _mod_4 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
129
|
+
const _ns_4 = _mod_4.b2;
|
|
132
130
|
const dbMod = _ns_4;
|
|
133
131
|
const { getPropertyModelNameAndDataType, getModelNameByModelId } = dbMod;
|
|
134
132
|
let fromDb;
|
|
@@ -174,8 +172,8 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
174
172
|
if (fullContext.modelName && fullContext.name && schemaFileId) {
|
|
175
173
|
logger$2(`[compareAndMarkDraft] _originalValues not set, but saving to database anyway for property ${context.modelName}:${context.name} (schemaFileId: ${schemaFileId})`);
|
|
176
174
|
try {
|
|
177
|
-
const _mod_5 = await import('./
|
|
178
|
-
const _ns_5 = _mod_5.
|
|
175
|
+
const _mod_5 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
176
|
+
const _ns_5 = _mod_5.b2;
|
|
179
177
|
const dbMod = _ns_5;
|
|
180
178
|
const { savePropertyToDb } = dbMod;
|
|
181
179
|
// Ensure _propertyFileId is set for savePropertyToDb to find the property
|
|
@@ -236,8 +234,8 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
236
234
|
logger$2(`Property ${fullContext.modelName}:${fullContext.name} has changes, marking as edited`);
|
|
237
235
|
logger$2(`[compareAndMarkDraft] Context when saving: id=${fullContext.id}, _propertyFileId=${fullContext._propertyFileId}, name=${fullContext.name}, _originalValues.name=${fullContext._originalValues?.name}`);
|
|
238
236
|
// Use dynamic import to break circular dependency
|
|
239
|
-
const _mod_6 = await import('./
|
|
240
|
-
const _ns_6 = _mod_6.
|
|
237
|
+
const _mod_6 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
238
|
+
const _ns_6 = _mod_6.b2;
|
|
241
239
|
const dbMod = _ns_6;
|
|
242
240
|
const { savePropertyToDb } = dbMod;
|
|
243
241
|
// Save to database (but not JSON file) - always save to DB when there are changes
|
|
@@ -252,7 +250,7 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
252
250
|
// Mark schema as draft if schema name is available
|
|
253
251
|
if (fullContext._schemaName) {
|
|
254
252
|
// Get the Schema instance and mark it as draft
|
|
255
|
-
const _mod_7 = await import('./Schema-
|
|
253
|
+
const _mod_7 = await import('./Schema-CpMNEnUO.js');
|
|
256
254
|
const _ns_7 = _mod_7.b;
|
|
257
255
|
const schemaMod = _ns_7;
|
|
258
256
|
const { Schema } = schemaMod;
|
|
@@ -274,7 +272,7 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
274
272
|
logger$2(`Property ${fullContext.modelName}:${fullContext.name} has no changes`);
|
|
275
273
|
// Clear isEdited flag in database
|
|
276
274
|
try {
|
|
277
|
-
const _mod_8 = await import('./index-
|
|
275
|
+
const _mod_8 = await import('./index-AVFTVp1m.js');
|
|
278
276
|
const _ns_8 = _mod_8.s;
|
|
279
277
|
const seedSchemaMod = _ns_8;
|
|
280
278
|
const { properties: propertiesTable, models: modelsTable } = seedSchemaMod;
|
|
@@ -283,8 +281,8 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context }, self }
|
|
|
283
281
|
const db = BaseDb.getAppDb();
|
|
284
282
|
if (db && fullContext.modelName && fullContext.name) {
|
|
285
283
|
// Find this property's model (model names are only unique per schema)
|
|
286
|
-
const _mod_9 = await import('./
|
|
287
|
-
const _ns_9 = _mod_9.
|
|
284
|
+
const _mod_9 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
285
|
+
const _ns_9 = _mod_9.b1;
|
|
288
286
|
const { resolveModelRecord } = _ns_9;
|
|
289
287
|
const modelRecord = await resolveModelRecord(fullContext.modelName, {
|
|
290
288
|
modelId: typeof fullContext.modelId === 'number' ? fullContext.modelId : undefined,
|
|
@@ -343,8 +341,8 @@ const validateProperty = fromCallback(({ sendBack, input: { context }, self }) =
|
|
|
343
341
|
// Brief wait so trackPendingWrite from ModelProperty.create() has time to run (it's in setTimeout(0))
|
|
344
342
|
await new Promise((r) => setTimeout(r, 60));
|
|
345
343
|
try {
|
|
346
|
-
const _mod_10 = await import('./
|
|
347
|
-
const _ns_10 = _mod_10.
|
|
344
|
+
const _mod_10 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
345
|
+
const _ns_10 = _mod_10.b2;
|
|
348
346
|
const dbMod = _ns_10;
|
|
349
347
|
const { getPropertyModelNameAndDataType, getModelNameByModelId } = dbMod;
|
|
350
348
|
// Try pending write first (property row may not exist yet)
|
|
@@ -397,10 +395,10 @@ const validateProperty = fromCallback(({ sendBack, input: { context }, self }) =
|
|
|
397
395
|
fullContext = { ...fullContext, dataType: (fullContext.dataType ?? context._originalValues?.dataType) || 'Text' };
|
|
398
396
|
}
|
|
399
397
|
// Use dynamic imports to break circular dependencies
|
|
400
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
398
|
+
const validationServiceMod = await import('./SchemaValidationService-DieV4KL-.js');
|
|
401
399
|
const { SchemaValidationService } = validationServiceMod;
|
|
402
400
|
const validationService = new SchemaValidationService();
|
|
403
|
-
const _mod_11 = await import('./Schema-
|
|
401
|
+
const _mod_11 = await import('./Schema-CpMNEnUO.js');
|
|
404
402
|
const _ns_11 = _mod_11.b;
|
|
405
403
|
const schemaMod = _ns_11;
|
|
406
404
|
const { Schema } = schemaMod;
|
|
@@ -624,6 +622,16 @@ const modelPropertyMachine = setup({
|
|
|
624
622
|
_schemaName: event.schemaName,
|
|
625
623
|
})),
|
|
626
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
|
+
},
|
|
627
635
|
destroyStarted: {
|
|
628
636
|
actions: assign({ _destroyError: null }),
|
|
629
637
|
},
|
|
@@ -1020,8 +1028,8 @@ class ModelProperty {
|
|
|
1020
1028
|
return fallbackIsEdited;
|
|
1021
1029
|
}
|
|
1022
1030
|
// Find this property's model (by modelId when known; model names are only unique per schema)
|
|
1023
|
-
const _mod_12 = await import('./
|
|
1024
|
-
const _ns_12 = _mod_12.
|
|
1031
|
+
const _mod_12 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
1032
|
+
const _ns_12 = _mod_12.b1;
|
|
1025
1033
|
const { resolveModelRecord } = _ns_12;
|
|
1026
1034
|
const modelRecord = await resolveModelRecord(property.modelName, this._ownerModelScope(property), db);
|
|
1027
1035
|
const modelRecords = modelRecord ? [modelRecord] : [];
|
|
@@ -1058,8 +1066,8 @@ class ModelProperty {
|
|
|
1058
1066
|
return undefined;
|
|
1059
1067
|
}
|
|
1060
1068
|
// Resolve the ref within the owning model's schema
|
|
1061
|
-
const _mod_13 = await import('./
|
|
1062
|
-
const _ns_13 = _mod_13.
|
|
1069
|
+
const _mod_13 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
1070
|
+
const _ns_13 = _mod_13.b1;
|
|
1063
1071
|
const { resolveRefModelRecord } = _ns_13;
|
|
1064
1072
|
const refModelRecord = await resolveRefModelRecord(refModelName, property ? this._ownerModelScope(property) : { schemaName: this._getSnapshotContext()._schemaName }, db);
|
|
1065
1073
|
if (refModelRecord?.id) {
|
|
@@ -1104,8 +1112,8 @@ class ModelProperty {
|
|
|
1104
1112
|
}
|
|
1105
1113
|
}
|
|
1106
1114
|
if (!model && modelId) {
|
|
1107
|
-
const _mod_14 = await import('./
|
|
1108
|
-
const _ns_14 = _mod_14.
|
|
1115
|
+
const _mod_14 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
1116
|
+
const _ns_14 = _mod_14.b1;
|
|
1109
1117
|
const { resolveModelRecord } = _ns_14;
|
|
1110
1118
|
const modelFileId = (await resolveModelRecord(property.modelName, { modelId }))?.schemaFileId;
|
|
1111
1119
|
model = modelFileId ? Model.getById(modelFileId) : undefined;
|
|
@@ -1267,7 +1275,7 @@ class ModelProperty {
|
|
|
1267
1275
|
throw new Error('Property is required');
|
|
1268
1276
|
}
|
|
1269
1277
|
const waitForReady = options?.waitForReady !== false;
|
|
1270
|
-
const readyTimeout = options?.readyTimeout ??
|
|
1278
|
+
const readyTimeout = options?.readyTimeout ?? DEFAULT_READY_TIMEOUT_MS;
|
|
1271
1279
|
const schemaName = options?.schemaName;
|
|
1272
1280
|
// Handle 'type' field from JSON schema format - convert to 'dataType'
|
|
1273
1281
|
// Normalize to PascalCase so lowercase values from JSON (e.g. 'text') work
|
|
@@ -1399,7 +1407,16 @@ class ModelProperty {
|
|
|
1399
1407
|
// A _dbId means the data was loaded from an existing row (createById, getPropertySchema), so
|
|
1400
1408
|
// there's nothing to write. Writing it back anyway raced deletes of that row's model (FK error).
|
|
1401
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();
|
|
1402
1413
|
if (hasModelId && propertyFileId && !isPersisted) {
|
|
1414
|
+
let resolveWrite;
|
|
1415
|
+
let rejectWrite;
|
|
1416
|
+
writeDone = new Promise((resolve, reject) => {
|
|
1417
|
+
resolveWrite = resolve;
|
|
1418
|
+
rejectWrite = reject;
|
|
1419
|
+
});
|
|
1403
1420
|
// Wait for writeProcess to be spawned (it's spawned in idle state entry action)
|
|
1404
1421
|
// Retry a few times if writeProcess isn't available yet
|
|
1405
1422
|
let retries = 0;
|
|
@@ -1408,8 +1425,10 @@ class ModelProperty {
|
|
|
1408
1425
|
const service = proxiedInstance.getService();
|
|
1409
1426
|
const snapshot = service.getSnapshot();
|
|
1410
1427
|
// Unloaded or evicted (e.g. Schema.destroy) before the write started: nothing to write to
|
|
1411
|
-
if (isActorStopped(service))
|
|
1428
|
+
if (isActorStopped(service)) {
|
|
1429
|
+
resolveWrite();
|
|
1412
1430
|
return;
|
|
1431
|
+
}
|
|
1413
1432
|
if (snapshot.value === 'idle' && snapshot.context.writeProcess) {
|
|
1414
1433
|
const writeProcess = snapshot.context.writeProcess;
|
|
1415
1434
|
// Resolve dbModelId - convert from string (modelFileId) to number (database ID) if needed
|
|
@@ -1447,11 +1466,14 @@ class ModelProperty {
|
|
|
1447
1466
|
logger(`ERROR: Cannot write property "${property.name}" - no modelId available`);
|
|
1448
1467
|
console.error(`[ModelProperty.create] ERROR: Cannot write property "${property.name}" - no modelId available. modelId: ${propertyWithId.modelId}, modelName: ${propertyWithId.modelName}`);
|
|
1449
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`));
|
|
1450
1470
|
return;
|
|
1451
1471
|
}
|
|
1452
1472
|
// Resolving the modelId awaited the DB; the instance may have been stopped meanwhile
|
|
1453
|
-
if (isActorStopped(service))
|
|
1473
|
+
if (isActorStopped(service)) {
|
|
1474
|
+
resolveWrite();
|
|
1454
1475
|
return;
|
|
1476
|
+
}
|
|
1455
1477
|
// Track pending write now that we have the resolved modelId
|
|
1456
1478
|
this.trackPendingWrite(propertyFileId, resolvedModelId);
|
|
1457
1479
|
logger(`Triggering write process for property "${property.name}" (modelId: ${resolvedModelId}, propertyFileId: ${propertyFileId})`);
|
|
@@ -1460,6 +1482,7 @@ class ModelProperty {
|
|
|
1460
1482
|
if (currentWriteState.value === 'success') {
|
|
1461
1483
|
// Write already succeeded
|
|
1462
1484
|
void this.completePendingWrite(propertyFileId, resolvedModelId);
|
|
1485
|
+
resolveWrite();
|
|
1463
1486
|
}
|
|
1464
1487
|
else {
|
|
1465
1488
|
// Set up subscription to catch future state changes
|
|
@@ -1468,6 +1491,7 @@ class ModelProperty {
|
|
|
1468
1491
|
writeSubscription.unsubscribe();
|
|
1469
1492
|
logger(`[writeProcess subscription] Write succeeded for property "${property.name}" (propertyFileId: ${propertyFileId})`);
|
|
1470
1493
|
void this.completePendingWrite(propertyFileId, resolvedModelId);
|
|
1494
|
+
resolveWrite();
|
|
1471
1495
|
}
|
|
1472
1496
|
else if (writeSnapshot.value === 'error') {
|
|
1473
1497
|
writeSubscription.unsubscribe();
|
|
@@ -1476,6 +1500,7 @@ class ModelProperty {
|
|
|
1476
1500
|
logger(`Write process error details:`, errorContext.error);
|
|
1477
1501
|
// Mark pending write as error
|
|
1478
1502
|
this.clearPendingWrite(propertyFileId, 'error');
|
|
1503
|
+
rejectWrite(new Error(`Failed to write property "${property.name}": ${errorContext.error?.message || 'Unknown error'}`));
|
|
1479
1504
|
}
|
|
1480
1505
|
});
|
|
1481
1506
|
}
|
|
@@ -1504,14 +1529,25 @@ class ModelProperty {
|
|
|
1504
1529
|
console.error(`[ModelProperty.create] ERROR: writeProcess not available after ${maxRetries} retries for property "${property.name}" (propertyFileId: ${propertyFileId})`);
|
|
1505
1530
|
// Mark as error if we couldn't even start the write process
|
|
1506
1531
|
this.clearPendingWrite(propertyFileId, 'error');
|
|
1532
|
+
rejectWrite(new Error(`Failed to write property "${property.name}": its write process never started`));
|
|
1507
1533
|
}
|
|
1508
1534
|
};
|
|
1509
1535
|
// Start checking after a short delay to allow state machine to initialize
|
|
1510
1536
|
setTimeout(checkAndSend, 0);
|
|
1511
1537
|
}
|
|
1512
|
-
if (!waitForReady)
|
|
1538
|
+
if (!waitForReady) {
|
|
1539
|
+
// Nobody awaits the write; failures are already logged above.
|
|
1540
|
+
writeDone.catch(() => { });
|
|
1513
1541
|
return proxiedInstance;
|
|
1514
|
-
|
|
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);
|
|
1515
1551
|
}
|
|
1516
1552
|
/** Whether an idIndex entry still points at a cached instance with that id. */
|
|
1517
1553
|
static isIndexEntryCurrent(propertyFileId, entry) {
|
|
@@ -1660,13 +1696,93 @@ class ModelProperty {
|
|
|
1660
1696
|
}
|
|
1661
1697
|
return instance;
|
|
1662
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
|
+
}
|
|
1663
1779
|
/**
|
|
1664
1780
|
* Find ModelProperty instance by propertyFileId
|
|
1665
1781
|
* Waits for the property to be fully loaded (idle state) by default
|
|
1666
1782
|
* @param options - Find options including propertyFileId and wait configuration
|
|
1667
1783
|
* @returns ModelProperty instance if found, undefined otherwise
|
|
1668
1784
|
*/
|
|
1669
|
-
static async find({ propertyFileId, waitForReady = true, readyTimeout =
|
|
1785
|
+
static async find({ propertyFileId, waitForReady = true, readyTimeout = DEFAULT_READY_TIMEOUT_MS, }) {
|
|
1670
1786
|
if (!propertyFileId) {
|
|
1671
1787
|
return undefined;
|
|
1672
1788
|
}
|
|
@@ -1683,7 +1799,7 @@ class ModelProperty {
|
|
|
1683
1799
|
* Loads property rows from DB for the given modelFileId, creates instances via createById, optionally waits for idle.
|
|
1684
1800
|
*/
|
|
1685
1801
|
static async all(modelFileId, options) {
|
|
1686
|
-
const { waitForReady = false, readyTimeout =
|
|
1802
|
+
const { waitForReady = false, readyTimeout = DEFAULT_READY_TIMEOUT_MS } = options ?? {};
|
|
1687
1803
|
if (!modelFileId) {
|
|
1688
1804
|
return [];
|
|
1689
1805
|
}
|
|
@@ -1955,6 +2071,8 @@ class ModelProperty {
|
|
|
1955
2071
|
.where(and(eq(schemas.name, schemaName), eq(models.name, modelName), eq(properties.name, propertyName)))
|
|
1956
2072
|
.limit(1);
|
|
1957
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]);
|
|
1958
2076
|
await db
|
|
1959
2077
|
.delete(properties)
|
|
1960
2078
|
.where(eq(properties.id, propertyRecords[0].propertyId));
|
|
@@ -1989,6 +2107,7 @@ ModelProperty.instanceCache = new Map();
|
|
|
1989
2107
|
ModelProperty.idIndex = new Map();
|
|
1990
2108
|
// Pending writes tracking
|
|
1991
2109
|
ModelProperty.pendingWrites = new Map();
|
|
2110
|
+
setCachedPropertyRefresher((propertyFileIds) => ModelProperty.refreshFromDb(propertyFileIds));
|
|
1992
2111
|
|
|
1993
2112
|
var ModelProperty$1 = /*#__PURE__*/Object.freeze({
|
|
1994
2113
|
__proto__: null,
|
|
@@ -1996,4 +2115,4 @@ var ModelProperty$1 = /*#__PURE__*/Object.freeze({
|
|
|
1996
2115
|
});
|
|
1997
2116
|
|
|
1998
2117
|
export { ModelProperty };
|
|
1999
|
-
//# sourceMappingURL=ModelProperty-
|
|
2118
|
+
//# sourceMappingURL=ModelProperty-BS49g01Y.js.map
|