@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,11 +1,9 @@
|
|
|
1
1
|
import { fromCallback, fromPromise, setup, assign, createActor } from 'xstate';
|
|
2
|
-
import {
|
|
2
|
+
import { E as BaseDb, s as models, u as properties, $ as generateId, aF as isInternalSchema, aG as writeModelToDb, aH as writePropertyToDb, aI as addSchemaToDb, q as modelSchemas, z as schemas, F as AmbiguousModelError, aJ as renameModelInDb, a as TProperty } from './BasePathResolver-Cm4apKRb.js';
|
|
3
3
|
import { eq, and, isNull, or } from 'drizzle-orm';
|
|
4
|
-
import { j as generateId } from './tabEvents-DguZpCCv.js';
|
|
5
4
|
import debug from 'debug';
|
|
6
|
-
import {
|
|
7
|
-
import { k as
|
|
8
|
-
import { k as getClient } from './ClientManager-C-QXqUK9.js';
|
|
5
|
+
import { n as waitForEntityIdle, D as DEFAULT_READY_TIMEOUT_MS, $ as getInvariantSafePropertyDescriptor, q as findEntity, C as ClientManagerState, I as Item, a0 as clearDestroySubscriptions, t as forceRemoveFromCaches, a1 as unloadEntity, u as runDestroyLifecycle } from './Item-DBFchXpC.js';
|
|
6
|
+
import { k as getClient } from './ClientManager-i3nJASkg.js';
|
|
9
7
|
import { modelPropertiesToObject } from './model-DGMe-TTm.js';
|
|
10
8
|
import { toSnakeCase } from 'drizzle-orm/casing';
|
|
11
9
|
import { Type } from '@sinclair/typebox';
|
|
@@ -37,7 +35,7 @@ const createPropertyInstances = async (propertyFileIds) => {
|
|
|
37
35
|
return;
|
|
38
36
|
}
|
|
39
37
|
try {
|
|
40
|
-
const mod = await import('./ModelProperty-
|
|
38
|
+
const mod = await import('./ModelProperty-BS49g01Y.js');
|
|
41
39
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
42
40
|
if (!ModelProperty) {
|
|
43
41
|
logger$7('createPropertyInstances: ModelProperty not available from dynamic import');
|
|
@@ -103,11 +101,11 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context }, self })
|
|
|
103
101
|
if (!modelRecord) {
|
|
104
102
|
// Model names are only unique per schema: prefer this schema's row, and otherwise only
|
|
105
103
|
// consider same-name rows that no schema claims yet (never another schema's model).
|
|
106
|
-
const _mod_0 = await import('./BasePathResolver-
|
|
107
|
-
const _ns_0 = _mod_0.
|
|
104
|
+
const _mod_0 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
105
|
+
const _ns_0 = _mod_0.b0;
|
|
108
106
|
const { modelSchemas } = _ns_0;
|
|
109
|
-
const _mod_1 = await import('./BasePathResolver-
|
|
110
|
-
const _ns_1 = _mod_1.
|
|
107
|
+
const _mod_1 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
108
|
+
const _ns_1 = _mod_1.a$;
|
|
111
109
|
const { schemas: schemasTable } = _ns_1;
|
|
112
110
|
let dbModels = await db
|
|
113
111
|
.select({
|
|
@@ -254,7 +252,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context }, self })
|
|
|
254
252
|
// Step 2: Fallback to Schema context (only if database doesn't have the model)
|
|
255
253
|
// This handles the case where model exists in schema file but not yet in database
|
|
256
254
|
try {
|
|
257
|
-
const _mod_2 = await import('./Schema-
|
|
255
|
+
const _mod_2 = await import('./Schema-CpMNEnUO.js');
|
|
258
256
|
const _ns_2 = _mod_2.b;
|
|
259
257
|
const schemaMod = _ns_2;
|
|
260
258
|
const { Schema } = schemaMod;
|
|
@@ -405,12 +403,12 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context }, self })
|
|
|
405
403
|
}
|
|
406
404
|
// Also check database for models (in case they're persisted but not in Schema context)
|
|
407
405
|
if (db) {
|
|
408
|
-
const _mod_3 = await import('./BasePathResolver-
|
|
409
|
-
const _ns_3 = _mod_3.
|
|
406
|
+
const _mod_3 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
407
|
+
const _ns_3 = _mod_3.b0;
|
|
410
408
|
const modelSchemaSchemaMod = _ns_3;
|
|
411
409
|
const { modelSchemas } = modelSchemaSchemaMod;
|
|
412
|
-
const _mod_4 = await import('./BasePathResolver-
|
|
413
|
-
const _ns_4 = _mod_4.
|
|
410
|
+
const _mod_4 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
411
|
+
const _ns_4 = _mod_4.a$;
|
|
414
412
|
const schemaSchemaMod = _ns_4;
|
|
415
413
|
const { schemas: schemasTable } = schemaSchemaMod;
|
|
416
414
|
// Query all models for this schema to check for duplicates (case-insensitive)
|
|
@@ -505,7 +503,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context }, self })
|
|
|
505
503
|
}
|
|
506
504
|
// Mark schema as draft when a new model is created so saveNewVersion() can persist it
|
|
507
505
|
try {
|
|
508
|
-
const _mod_5 = await import('./Schema-
|
|
506
|
+
const _mod_5 = await import('./Schema-CpMNEnUO.js');
|
|
509
507
|
const _ns_5 = _mod_5.b;
|
|
510
508
|
const schemaMod = _ns_5;
|
|
511
509
|
const { Schema } = schemaMod;
|
|
@@ -553,10 +551,10 @@ const validateModel = fromCallback(({ sendBack, input: { context }, self }) => {
|
|
|
553
551
|
const _validateModel = async () => {
|
|
554
552
|
try {
|
|
555
553
|
// Use dynamic imports to break circular dependencies
|
|
556
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
554
|
+
const validationServiceMod = await import('./SchemaValidationService-DieV4KL-.js');
|
|
557
555
|
const { SchemaValidationService } = validationServiceMod;
|
|
558
556
|
const validationService = new SchemaValidationService();
|
|
559
|
-
const _mod_6 = await import('./Schema-
|
|
557
|
+
const _mod_6 = await import('./Schema-CpMNEnUO.js');
|
|
560
558
|
const _ns_6 = _mod_6.b;
|
|
561
559
|
const schemaMod = _ns_6;
|
|
562
560
|
const { Schema } = schemaMod;
|
|
@@ -675,7 +673,7 @@ const createModelProperties = fromCallback(({ sendBack, input, self }) => {
|
|
|
675
673
|
return;
|
|
676
674
|
}
|
|
677
675
|
logger$5(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
|
|
678
|
-
const mod = await import('./ModelProperty-
|
|
676
|
+
const mod = await import('./ModelProperty-BS49g01Y.js');
|
|
679
677
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
680
678
|
if (!ModelProperty) {
|
|
681
679
|
logger$5('ModelProperty not available from dynamic import');
|
|
@@ -700,8 +698,8 @@ const createModelProperties = fromCallback(({ sendBack, input, self }) => {
|
|
|
700
698
|
: undefined;
|
|
701
699
|
// Otherwise use provided ID or generate a random one
|
|
702
700
|
// IDs should be generated in the import process before creating properties
|
|
703
|
-
const _mod_7 = await import('./
|
|
704
|
-
const _ns_7 = _mod_7.
|
|
701
|
+
const _mod_7 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
702
|
+
const _ns_7 = _mod_7.b4;
|
|
705
703
|
const { generateId } = _ns_7;
|
|
706
704
|
const propertyFileId = propData.id || propertyRecord?.schemaFileId || generateId();
|
|
707
705
|
logger$5(`Creating property "${propName}" with fileId "${propertyFileId}"`);
|
|
@@ -718,8 +716,8 @@ const createModelProperties = fromCallback(({ sendBack, input, self }) => {
|
|
|
718
716
|
}
|
|
719
717
|
else if (refModelName) {
|
|
720
718
|
// Fallback: resolve the ref by name within this model's schema
|
|
721
|
-
const _mod_8 = await import('./
|
|
722
|
-
const _ns_8 = _mod_8.
|
|
719
|
+
const _mod_8 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
720
|
+
const _ns_8 = _mod_8.b1;
|
|
723
721
|
const { resolveModelRecord } = _ns_8;
|
|
724
722
|
const refModelRecord = await resolveModelRecord(refModelName, { schemaName }, db);
|
|
725
723
|
if (refModelRecord?.id) {
|
|
@@ -819,7 +817,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
819
817
|
const evictionEpoch = currentEvictionEpoch();
|
|
820
818
|
/** The schema to validate against; throws (validation then skips the schema check) once it was evicted. */
|
|
821
819
|
const schemaForValidation = async (schemaName) => {
|
|
822
|
-
const _mod_9 = await import('./Schema-
|
|
820
|
+
const _mod_9 = await import('./Schema-CpMNEnUO.js');
|
|
823
821
|
const _ns_9 = _mod_9.b;
|
|
824
822
|
const { Schema } = _ns_9;
|
|
825
823
|
if (schemaEvictedSince(schemaName, evictionEpoch)) {
|
|
@@ -837,7 +835,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
837
835
|
const structureMsg = `[validateEntity] Validating model structure`;
|
|
838
836
|
logger$4(structureMsg);
|
|
839
837
|
// Use existing Model validation
|
|
840
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
838
|
+
const validationServiceMod = await import('./SchemaValidationService-DieV4KL-.js');
|
|
841
839
|
const { SchemaValidationService } = validationServiceMod;
|
|
842
840
|
const validationService = new SchemaValidationService();
|
|
843
841
|
// Validate model structure
|
|
@@ -887,7 +885,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
887
885
|
}
|
|
888
886
|
else if (entityInput.entityType === 'modelProperty') {
|
|
889
887
|
// Use existing ModelProperty validation
|
|
890
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
888
|
+
const validationServiceMod = await import('./SchemaValidationService-DieV4KL-.js');
|
|
891
889
|
const { SchemaValidationService } = validationServiceMod;
|
|
892
890
|
const validationService = new SchemaValidationService();
|
|
893
891
|
// Validate property structure
|
|
@@ -927,7 +925,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
927
925
|
}
|
|
928
926
|
else if (entityInput.entityType === 'schema') {
|
|
929
927
|
// Schema validation - use existing validation
|
|
930
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
928
|
+
const validationServiceMod = await import('./SchemaValidationService-DieV4KL-.js');
|
|
931
929
|
const { SchemaValidationService } = validationServiceMod;
|
|
932
930
|
const validationService = new SchemaValidationService();
|
|
933
931
|
const schemaResult = validationService.validateSchema(entityInput.entityData);
|
|
@@ -1016,7 +1014,7 @@ const writeToDatabase = fromCallback(({ sendBack, input }) => {
|
|
|
1016
1014
|
// initial write completes is not overwritten by the stale requestWrite payload.
|
|
1017
1015
|
let dataToWrite = input.entityData;
|
|
1018
1016
|
try {
|
|
1019
|
-
const mod = await import('./ModelProperty-
|
|
1017
|
+
const mod = await import('./ModelProperty-BS49g01Y.js');
|
|
1020
1018
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
1021
1019
|
if (ModelProperty && typeof ModelProperty.getById === 'function') {
|
|
1022
1020
|
const instance = ModelProperty.getById(input.entityId);
|
|
@@ -1410,7 +1408,7 @@ const modelMachine = setup({
|
|
|
1410
1408
|
// Create ModelProperty instances for any new property IDs
|
|
1411
1409
|
if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
|
|
1412
1410
|
// Import and create instances asynchronously (fire-and-forget)
|
|
1413
|
-
import('./ModelProperty-
|
|
1411
|
+
import('./ModelProperty-BS49g01Y.js').then(({ ModelProperty }) => {
|
|
1414
1412
|
if (self.getSnapshot().status === 'stopped')
|
|
1415
1413
|
return;
|
|
1416
1414
|
const createPromises = newPropertyIds.map(async (propertyFileId) => {
|
|
@@ -1915,7 +1913,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
|
|
|
1915
1913
|
// Lazy import cache for ModelProperty to avoid circular dependency
|
|
1916
1914
|
// Eagerly start loading to minimize delay on first access
|
|
1917
1915
|
let ModelPropertyClass = null;
|
|
1918
|
-
const modelPropertyImportPromise = import('./ModelProperty-
|
|
1916
|
+
const modelPropertyImportPromise = import('./ModelProperty-BS49g01Y.js')
|
|
1919
1917
|
.then(module => {
|
|
1920
1918
|
ModelPropertyClass = module.ModelProperty;
|
|
1921
1919
|
return ModelPropertyClass;
|
|
@@ -1930,13 +1928,13 @@ function getModelProperty() {
|
|
|
1930
1928
|
// and the getter will return empty array, which matches the original behavior
|
|
1931
1929
|
return ModelPropertyClass;
|
|
1932
1930
|
}
|
|
1933
|
-
// Lazy import for Schema to avoid circular dependency
|
|
1934
|
-
const schemaImportPromise = (async () => { const _mod_12 = await import('./Schema-fXtvd-yL.js'); return _mod_12.b; })()
|
|
1935
|
-
.then(module => module.Schema)
|
|
1936
|
-
.catch(() => null);
|
|
1937
1931
|
// WeakMap to store mutable state per Model instance
|
|
1938
1932
|
// This avoids issues with read-only properties when instances are frozen by Immer
|
|
1939
1933
|
const modelInstanceState = new WeakMap();
|
|
1934
|
+
// Settles once the properties passed to Model.create exist, or rejects when they can't be created.
|
|
1935
|
+
// The model reaches idle before its write, so idle alone doesn't mean they exist yet. Keyed by the
|
|
1936
|
+
// actor because callers hold the proxy, not the instance.
|
|
1937
|
+
const pendingPropertyCreation = new WeakMap();
|
|
1940
1938
|
// Define tracked properties for the Proxy
|
|
1941
1939
|
// These properties will be read from/written to the actor context
|
|
1942
1940
|
const TRACKED_PROPERTIES = [
|
|
@@ -1995,6 +1993,34 @@ class Model {
|
|
|
1995
1993
|
});
|
|
1996
1994
|
// Note: Property getters/setters are now handled by the Proxy in create()
|
|
1997
1995
|
}
|
|
1996
|
+
/**
|
|
1997
|
+
* Resolves once the model is idle and any properties passed to Model.create exist.
|
|
1998
|
+
* Rejects if it errors, times out, or its properties can't be created.
|
|
1999
|
+
*/
|
|
2000
|
+
static async waitUntilReady(instance, timeout) {
|
|
2001
|
+
const startedAt = Date.now();
|
|
2002
|
+
await waitForEntityIdle(instance, { timeout });
|
|
2003
|
+
const propertyCreation = pendingPropertyCreation.get(instance.getService());
|
|
2004
|
+
if (!propertyCreation)
|
|
2005
|
+
return instance;
|
|
2006
|
+
const remaining = Math.max(0, timeout - (Date.now() - startedAt));
|
|
2007
|
+
let timer;
|
|
2008
|
+
try {
|
|
2009
|
+
await Promise.race([
|
|
2010
|
+
propertyCreation,
|
|
2011
|
+
new Promise((_, reject) => {
|
|
2012
|
+
timer = setTimeout(() => {
|
|
2013
|
+
const modelName = instance.getService().getSnapshot().context.modelName;
|
|
2014
|
+
reject(new Error(`Model "${modelName}" did not finish creating its properties within ${timeout}ms`));
|
|
2015
|
+
}, remaining);
|
|
2016
|
+
}),
|
|
2017
|
+
]);
|
|
2018
|
+
}
|
|
2019
|
+
finally {
|
|
2020
|
+
clearTimeout(timer);
|
|
2021
|
+
}
|
|
2022
|
+
return instance;
|
|
2023
|
+
}
|
|
1998
2024
|
/**
|
|
1999
2025
|
* True when a name-cached instance belongs to a different model than the requested modelFileId.
|
|
2000
2026
|
* A schema re-imported under the same name can give its models new ids while the previous
|
|
@@ -2080,7 +2106,7 @@ class Model {
|
|
|
2080
2106
|
throw new Error('Model name is required');
|
|
2081
2107
|
}
|
|
2082
2108
|
const waitForReady = options?.waitForReady !== false;
|
|
2083
|
-
const readyTimeout = options?.readyTimeout ??
|
|
2109
|
+
const readyTimeout = options?.readyTimeout ?? DEFAULT_READY_TIMEOUT_MS;
|
|
2084
2110
|
// Extract schema name and instance
|
|
2085
2111
|
let schemaName;
|
|
2086
2112
|
let schemaInstance; // Using any to avoid circular dependency with Schema
|
|
@@ -2107,7 +2133,7 @@ class Model {
|
|
|
2107
2133
|
logger(`Model.create: Found instance in ID cache for "${modelName}" (ID: ${id})`);
|
|
2108
2134
|
if (!waitForReady)
|
|
2109
2135
|
return instance;
|
|
2110
|
-
return
|
|
2136
|
+
return this.waitUntilReady(instance, readyTimeout);
|
|
2111
2137
|
}
|
|
2112
2138
|
// Step 2: Check for duplicate names and generate unique name if needed (before checking cache)
|
|
2113
2139
|
// This allows us to create new models with renamed versions when duplicates exist
|
|
@@ -2153,7 +2179,7 @@ class Model {
|
|
|
2153
2179
|
}
|
|
2154
2180
|
if (!waitForReady)
|
|
2155
2181
|
return instance;
|
|
2156
|
-
return
|
|
2182
|
+
return this.waitUntilReady(instance, readyTimeout);
|
|
2157
2183
|
}
|
|
2158
2184
|
}
|
|
2159
2185
|
}
|
|
@@ -2193,7 +2219,7 @@ class Model {
|
|
|
2193
2219
|
}
|
|
2194
2220
|
if (!waitForReady)
|
|
2195
2221
|
return instance;
|
|
2196
|
-
return
|
|
2222
|
+
return this.waitUntilReady(instance, readyTimeout);
|
|
2197
2223
|
}
|
|
2198
2224
|
// Step 7: Create new instance with id in initial context
|
|
2199
2225
|
// This ensures loadOrCreateModel sees the ID immediately
|
|
@@ -2207,6 +2233,32 @@ class Model {
|
|
|
2207
2233
|
if (options?.properties) {
|
|
2208
2234
|
logger(`[Model.create] Created instance with _pendingPropertyDefinitions in initial context (${Object.keys(options.properties).length} properties) for model "${uniqueModelName}"`);
|
|
2209
2235
|
}
|
|
2236
|
+
// Called by the write trigger below when the properties will never be created
|
|
2237
|
+
let failPropertyCreation = () => { };
|
|
2238
|
+
if (options?.properties && Object.keys(options.properties).length > 0) {
|
|
2239
|
+
const service = newInstance.getService();
|
|
2240
|
+
const propertyCreation = new Promise((resolve, reject) => {
|
|
2241
|
+
const subscription = service.subscribe({
|
|
2242
|
+
next: (snapshot) => {
|
|
2243
|
+
if (snapshot.value === 'idle' && !snapshot.context._pendingPropertyDefinitions) {
|
|
2244
|
+
subscription.unsubscribe();
|
|
2245
|
+
resolve();
|
|
2246
|
+
}
|
|
2247
|
+
else if (snapshot.value === 'error') {
|
|
2248
|
+
failPropertyCreation('the model is in an error state');
|
|
2249
|
+
}
|
|
2250
|
+
},
|
|
2251
|
+
complete: () => failPropertyCreation('the model was unloaded'),
|
|
2252
|
+
});
|
|
2253
|
+
failPropertyCreation = (reason) => {
|
|
2254
|
+
subscription.unsubscribe();
|
|
2255
|
+
reject(new Error(`Model "${service.getSnapshot().context.modelName}" could not create its properties: ${reason}`));
|
|
2256
|
+
};
|
|
2257
|
+
});
|
|
2258
|
+
// Only waitUntilReady reports this; without waitForReady nobody awaits it
|
|
2259
|
+
propertyCreation.catch(() => { });
|
|
2260
|
+
pendingPropertyCreation.set(service, propertyCreation);
|
|
2261
|
+
}
|
|
2210
2262
|
// Step 7: Set initial model data if provided
|
|
2211
2263
|
// Note: description is not supported - JSON files can have it but we ignore it at runtime
|
|
2212
2264
|
if (options) {
|
|
@@ -2430,8 +2482,10 @@ class Model {
|
|
|
2430
2482
|
}, 10000);
|
|
2431
2483
|
});
|
|
2432
2484
|
// Unloaded or evicted (e.g. Schema.destroy) while it loaded: a stopped model never writes
|
|
2433
|
-
if (isActorStopped(proxiedInstance._service))
|
|
2485
|
+
if (isActorStopped(proxiedInstance._service)) {
|
|
2486
|
+
failPropertyCreation('the model was unloaded');
|
|
2434
2487
|
return;
|
|
2488
|
+
}
|
|
2435
2489
|
// Only write if validation passed (model is in idle state, not error)
|
|
2436
2490
|
const finalSnapshot = proxiedInstance._service.getSnapshot();
|
|
2437
2491
|
if (finalSnapshot.value === 'idle' && (!finalSnapshot.context._validationErrors || finalSnapshot.context._validationErrors.length === 0)) {
|
|
@@ -2526,6 +2580,7 @@ class Model {
|
|
|
2526
2580
|
_dbId: schemaInstance ? schemaInstance._getSnapshotContext()._dbId : 'N/A',
|
|
2527
2581
|
schemaName: schemaName || 'N/A',
|
|
2528
2582
|
});
|
|
2583
|
+
failPropertyCreation(`its schema "${schemaName}" was not found in the database`);
|
|
2529
2584
|
}
|
|
2530
2585
|
else if (finalSnapshot.context.id) {
|
|
2531
2586
|
// Verify schema exists in database before proceeding (additional safety check)
|
|
@@ -2563,8 +2618,10 @@ class Model {
|
|
|
2563
2618
|
const maxRetries = 10;
|
|
2564
2619
|
const checkAndSend = async () => {
|
|
2565
2620
|
// Unloaded or evicted (e.g. Schema.destroy) before the write started: nothing to write to
|
|
2566
|
-
if (isActorStopped(proxiedInstance._service))
|
|
2621
|
+
if (isActorStopped(proxiedInstance._service)) {
|
|
2622
|
+
failPropertyCreation('the model was unloaded');
|
|
2567
2623
|
return;
|
|
2624
|
+
}
|
|
2568
2625
|
const currentSnapshot = proxiedInstance._service.getSnapshot();
|
|
2569
2626
|
if (currentSnapshot.context.writeProcess) {
|
|
2570
2627
|
// Track pending write (only once it really starts: a stopped model leaves none behind)
|
|
@@ -2619,6 +2676,7 @@ class Model {
|
|
|
2619
2676
|
logger(`Write process failed for model "${finalSnapshot.context.modelName}": ${errorContext.error?.message || 'Unknown error'}`);
|
|
2620
2677
|
logger(`Write process error details:`, errorContext.error);
|
|
2621
2678
|
logger(`Validation errors:`, errorContext.validationErrors);
|
|
2679
|
+
failPropertyCreation(`writing the model failed: ${errorContext.error?.message || 'Unknown error'}`);
|
|
2622
2680
|
}
|
|
2623
2681
|
});
|
|
2624
2682
|
}
|
|
@@ -2639,6 +2697,7 @@ class Model {
|
|
|
2639
2697
|
}
|
|
2640
2698
|
else {
|
|
2641
2699
|
logger(`ERROR: writeProcess not available after ${maxRetries} retries for model "${finalSnapshot.context.modelName}"`);
|
|
2700
|
+
failPropertyCreation('its write process never started');
|
|
2642
2701
|
}
|
|
2643
2702
|
};
|
|
2644
2703
|
// Start checking immediately, but also allow time for entry action to complete
|
|
@@ -2646,20 +2705,23 @@ class Model {
|
|
|
2646
2705
|
}
|
|
2647
2706
|
else {
|
|
2648
2707
|
logger(`Cannot trigger write process: missing schemaId (${schemaId}) or id (${finalSnapshot.context.id})`);
|
|
2708
|
+
failPropertyCreation('it has no id');
|
|
2649
2709
|
}
|
|
2650
2710
|
}
|
|
2651
2711
|
else {
|
|
2652
2712
|
logger(`Model validation failed or model in error state, skipping write process`);
|
|
2713
|
+
failPropertyCreation('the model failed validation');
|
|
2653
2714
|
}
|
|
2654
2715
|
}
|
|
2655
2716
|
catch (error) {
|
|
2656
2717
|
logger(`Failed to trigger write process: ${error instanceof Error ? error.message : String(error)}`);
|
|
2718
|
+
failPropertyCreation(error instanceof Error ? error.message : String(error));
|
|
2657
2719
|
}
|
|
2658
2720
|
});
|
|
2659
2721
|
}
|
|
2660
2722
|
if (!waitForReady)
|
|
2661
2723
|
return proxiedInstance;
|
|
2662
|
-
return
|
|
2724
|
+
return this.waitUntilReady(proxiedInstance, readyTimeout);
|
|
2663
2725
|
}
|
|
2664
2726
|
/**
|
|
2665
2727
|
* Get Model instance by modelFileId (O(1) lookup)
|
|
@@ -2842,8 +2904,8 @@ class Model {
|
|
|
2842
2904
|
const evictionEpoch = options?.evictionEpoch ?? currentEvictionEpoch();
|
|
2843
2905
|
try {
|
|
2844
2906
|
// Query model by name (throws AmbiguousModelError when several schemas define it)
|
|
2845
|
-
const _mod_10 = await import('./
|
|
2846
|
-
const _ns_10 = _mod_10.
|
|
2907
|
+
const _mod_10 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
2908
|
+
const _ns_10 = _mod_10.b1;
|
|
2847
2909
|
const { resolveModelRecord } = _ns_10;
|
|
2848
2910
|
const resolved = await resolveModelRecord(modelName, {}, db);
|
|
2849
2911
|
if (!resolved?.schemaFileId) {
|
|
@@ -2954,7 +3016,7 @@ class Model {
|
|
|
2954
3016
|
* @param options - Find options including lookup parameters and wait configuration
|
|
2955
3017
|
* @returns Model instance if found, undefined otherwise
|
|
2956
3018
|
*/
|
|
2957
|
-
static async find({ modelFileId, modelName, schemaName, waitForReady = true, readyTimeout =
|
|
3019
|
+
static async find({ modelFileId, modelName, schemaName, waitForReady = true, readyTimeout = DEFAULT_READY_TIMEOUT_MS, }) {
|
|
2958
3020
|
return await findEntity({
|
|
2959
3021
|
getById: (id) => Model.getById(id),
|
|
2960
3022
|
createById: (id) => Model.createById(id),
|
|
@@ -3043,10 +3105,11 @@ class Model {
|
|
|
3043
3105
|
/**
|
|
3044
3106
|
* Get all Model instances, optionally filtered by schema.
|
|
3045
3107
|
* When DB is available, loads from DB via getModelsData; otherwise returns from cache.
|
|
3046
|
-
*
|
|
3108
|
+
* With waitForReady, waits for each model to be ready (idle, with any properties from Model.create
|
|
3109
|
+
* created) and leaves out models that error or time out.
|
|
3047
3110
|
*/
|
|
3048
3111
|
static async all(schemaName, options) {
|
|
3049
|
-
const { waitForReady = false, readyTimeout =
|
|
3112
|
+
const { waitForReady = false, readyTimeout = DEFAULT_READY_TIMEOUT_MS } = options ?? {};
|
|
3050
3113
|
const appDb = BaseDb.getAppDb();
|
|
3051
3114
|
if (!appDb) {
|
|
3052
3115
|
const instances = [];
|
|
@@ -3130,11 +3193,13 @@ class Model {
|
|
|
3130
3193
|
}
|
|
3131
3194
|
}
|
|
3132
3195
|
if (waitForReady && instances.length > 0) {
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3196
|
+
// Leave out models that errored or didn't get ready in time. Don't re-read their state afterwards:
|
|
3197
|
+
// a ready model can already be validating again, and it still belongs in the result.
|
|
3198
|
+
const ready = await Promise.all(instances.map((m) => this.waitUntilReady(m, readyTimeout).then(() => true, (error) => {
|
|
3199
|
+
logger(`Model.all: leaving out a model that isn't ready: ${error instanceof Error ? error.message : String(error)}`);
|
|
3200
|
+
return false;
|
|
3136
3201
|
})));
|
|
3137
|
-
return instances.filter((
|
|
3202
|
+
return instances.filter((_, i) => ready[i]);
|
|
3138
3203
|
}
|
|
3139
3204
|
return instances;
|
|
3140
3205
|
}
|
|
@@ -3573,6 +3638,8 @@ class Model {
|
|
|
3573
3638
|
.limit(1);
|
|
3574
3639
|
if (modelRecords.length > 0) {
|
|
3575
3640
|
const modelId = modelRecords[0].id;
|
|
3641
|
+
const { detachModelRows } = await import('./detachRowsBeforeDelete-S0q-DJPT.js');
|
|
3642
|
+
await detachModelRows(db, [typeof modelId === 'string' ? parseInt(modelId, 10) : modelId]);
|
|
3576
3643
|
await db.delete(modelSchemas).where(eq(modelSchemas.modelId, modelId));
|
|
3577
3644
|
await db
|
|
3578
3645
|
.delete(properties)
|
|
@@ -3581,9 +3648,10 @@ class Model {
|
|
|
3581
3648
|
}
|
|
3582
3649
|
}
|
|
3583
3650
|
if (schemaName && modelName) {
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3651
|
+
// Imported here, not at module load: Model and Schema import each other.
|
|
3652
|
+
const _mod_11 = await import('./Schema-CpMNEnUO.js');
|
|
3653
|
+
const _ns_11 = _mod_11.b;
|
|
3654
|
+
const { Schema } = _ns_11;
|
|
3587
3655
|
const schema = Schema.create(schemaName, { waitForReady: false });
|
|
3588
3656
|
const schemaContext = schema.getService().getSnapshot().context;
|
|
3589
3657
|
if (schemaContext.models?.[modelName]) {
|
|
@@ -3618,9 +3686,9 @@ class Model {
|
|
|
3618
3686
|
return undefined;
|
|
3619
3687
|
}
|
|
3620
3688
|
// Model names are only unique per schema: find this model's row by its id (schemaFileId).
|
|
3621
|
-
const
|
|
3622
|
-
const
|
|
3623
|
-
const { resolveModelRecord } =
|
|
3689
|
+
const _mod_12 = await import('./BasePathResolver-Cm4apKRb.js');
|
|
3690
|
+
const _ns_12 = _mod_12.b1;
|
|
3691
|
+
const { resolveModelRecord } = _ns_12;
|
|
3624
3692
|
const modelRecord = await resolveModelRecord(modelName, { modelFileId: context.id, schemaName: context.schemaName }, db);
|
|
3625
3693
|
if (!modelRecord?.id) {
|
|
3626
3694
|
return undefined;
|
|
@@ -3824,4 +3892,4 @@ const TModelValues = Type.Record(Type.String(), Type.Any());
|
|
|
3824
3892
|
const TModelSchema = Type.Record(Type.String(), TProperty);
|
|
3825
3893
|
|
|
3826
3894
|
export { ConflictError as C, Model as M, TModelSchema as T, TModelValues as a, anyEvictionSince as b, currentEvictionEpoch as c, setupEntityLiveQuery as d, writeToDatabase$1 as e, Model$1 as f, isActorStopped as i, schemaEvictedSince as s, writeProcessMachine as w };
|
|
3827
|
-
//# sourceMappingURL=index-
|
|
3895
|
+
//# sourceMappingURL=index-8O3Uow-Y.js.map
|