@seedprotocol/sdk 0.7.0 → 0.7.2-next.593.gd5bd4ea
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BasePathResolver-ndE8XTpw.js → BasePathResolver-BdxCSIzn.js} +2 -2
- package/dist/{BasePathResolver-ndE8XTpw.js.map → BasePathResolver-BdxCSIzn.js.map} +1 -1
- package/dist/{ClientManager-DLleL_2e.js → ClientManager-ClCwwhwo.js} +28 -23
- package/dist/ClientManager-ClCwwhwo.js.map +1 -0
- package/dist/{Item-zBFWQDU9.js → Item-B9Y4VuK1.js} +140 -74
- package/dist/Item-B9Y4VuK1.js.map +1 -0
- package/dist/{ModelProperty-lth9L37R.js → ModelProperty-BMePcicQ.js} +64 -36
- package/dist/ModelProperty-BMePcicQ.js.map +1 -0
- package/dist/{Schema-DOhlrQ-N.js → Schema-COsEXXaR.js} +106 -58
- package/dist/Schema-COsEXXaR.js.map +1 -0
- package/dist/{SchemaValidationService-DDKr5piy.js → SchemaValidationService-DabGMzSE.js} +7 -8
- package/dist/{SchemaValidationService-DDKr5piy.js.map → SchemaValidationService-DabGMzSE.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-fG3ujaSh.js → backfillMetadataPropertyIds-Ck6fumnm.js} +4 -4
- package/dist/{backfillMetadataPropertyIds-fG3ujaSh.js.map → backfillMetadataPropertyIds-Ck6fumnm.js.map} +1 -1
- package/dist/cjs/{ModelProperty-BEsIHAjk.js → ModelProperty-BT6Un_MB.js} +59 -30
- package/dist/cjs/ModelProperty-BT6Un_MB.js.map +1 -0
- package/dist/cjs/{Schema-qEp5mH1N.js → Schema-BXhXdUsA.js} +93 -44
- package/dist/cjs/Schema-BXhXdUsA.js.map +1 -0
- package/dist/cjs/{SchemaValidationService-CWEnZmOH.js → SchemaValidationService-CC18QDfc.js} +2 -2
- package/dist/cjs/{SchemaValidationService-CWEnZmOH.js.map → SchemaValidationService-CC18QDfc.js.map} +1 -1
- package/dist/cjs/{backfillMetadataPropertyIds-tw8JGMT0.js → backfillMetadataPropertyIds-DEHC9ejq.js} +3 -3
- package/dist/cjs/{backfillMetadataPropertyIds-tw8JGMT0.js.map → backfillMetadataPropertyIds-DEHC9ejq.js.map} +1 -1
- package/dist/cjs/{eas-CLiV2Hmn.js → eas-C3CL0l7l.js} +3 -3
- package/dist/cjs/{eas-CLiV2Hmn.js.map → eas-C3CL0l7l.js.map} +1 -1
- package/dist/cjs/{getItem-DSRtx_68.js → getItem-CrwWYCkj.js} +2 -2
- package/dist/cjs/{getItem-DSRtx_68.js.map → getItem-CrwWYCkj.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-D5-dYtNq.js → getPublishPayload-DRJh7WR0.js} +171 -209
- package/dist/cjs/getPublishPayload-DRJh7WR0.js.map +1 -0
- package/dist/cjs/{getPublishUploads-B5Lq6q-_.js → getPublishUploads-Bh22D3zJ.js} +49 -10
- package/dist/cjs/getPublishUploads-Bh22D3zJ.js.map +1 -0
- package/dist/cjs/{index-B3UDbm1C.js → index-BA1RIYFG.js} +3 -3
- package/dist/cjs/index-BA1RIYFG.js.map +1 -0
- package/dist/cjs/{index-C66AfYDG.js → index-Dls7aMjr.js} +281 -90
- package/dist/cjs/index-Dls7aMjr.js.map +1 -0
- package/dist/cjs/{property-BVJIP7SX.js → property-ZerTWizX.js} +5 -5
- package/dist/cjs/{property-BVJIP7SX.js.map → property-ZerTWizX.js.map} +1 -1
- package/dist/cjs/publishDraftGraph-CPOAcQFf.js +403 -0
- package/dist/cjs/publishDraftGraph-CPOAcQFf.js.map +1 -0
- package/dist/cjs/{resetAmbiguousLegacyItemData-BaZqUui9.js → resetAmbiguousLegacyItemData-adDl4LcT.js} +2 -2
- package/dist/cjs/{resetAmbiguousLegacyItemData-BaZqUui9.js.map → resetAmbiguousLegacyItemData-adDl4LcT.js.map} +1 -1
- package/dist/cjs/{resolveModelForSyncedSeed-CC6dQctx.js → resolveModelForSyncedSeed-DoNThPdL.js} +2 -2
- package/dist/cjs/{resolveModelForSyncedSeed-CC6dQctx.js.map → resolveModelForSyncedSeed-DoNThPdL.js.map} +1 -1
- package/dist/cjs/{syncDbWithEas-Dk96sAG-.js → syncDbWithEas-CYfPkus9.js} +20 -7
- package/dist/cjs/{syncDbWithEas-Dk96sAG-.js.map → syncDbWithEas-CYfPkus9.js.map} +1 -1
- package/dist/{configurePlatform-BMoPG9vY.js → configurePlatform-xU3Hsno3.js} +4 -4
- package/dist/{configurePlatform-BMoPG9vY.js.map → configurePlatform-xU3Hsno3.js.map} +1 -1
- package/dist/{db-BJZN0a0a.js → db-W1g29qsM.js} +31 -27
- package/dist/{db-BJZN0a0a.js.map → db-W1g29qsM.js.map} +1 -1
- package/dist/{eas-B0hsMLqt.js → eas-CSwV6MvB.js} +6 -6
- package/dist/{eas-B0hsMLqt.js.map → eas-CSwV6MvB.js.map} +1 -1
- package/dist/{getItem-DEh4WfHG.js → getItem-BYQeM3DY.js} +5 -6
- package/dist/{getItem-DEh4WfHG.js.map → getItem-BYQeM3DY.js.map} +1 -1
- package/dist/{getPublishPayload-H032DHC7.js → getPublishPayload-D5CQZd-y.js} +167 -206
- package/dist/getPublishPayload-D5CQZd-y.js.map +1 -0
- package/dist/{getPublishUploads-CR66RlGJ.js → getPublishUploads-BGpDsrBp.js} +52 -14
- package/dist/getPublishUploads-BGpDsrBp.js.map +1 -0
- package/dist/{index-6bJuv5Tt.js → index-Bev-hZF-.js} +9 -10
- package/dist/index-Bev-hZF-.js.map +1 -0
- package/dist/{index-B0LgJblD.js → index-CSOQFAOn.js} +2 -2
- package/dist/index-CSOQFAOn.js.map +1 -0
- package/dist/{index-DtfjeuxC.js → index-DRXC5Mra.js} +167 -75
- package/dist/index-DRXC5Mra.js.map +1 -0
- package/dist/{index.browser-CNrqhvEA.js → index.browser-DO20vYuP.js} +9 -9
- package/dist/{index.browser-CNrqhvEA.js.map → index.browser-DO20vYuP.js.map} +1 -1
- package/dist/{index.node-DrHiTuOr.js → index.node-C4iyOhdo.js} +5 -5
- package/dist/{index.node-DrHiTuOr.js.map → index.node-C4iyOhdo.js.map} +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.js +258 -183
- package/dist/main.js.map +1 -1
- package/dist/node.js +14 -15
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +5 -5
- package/dist/platform.node.js +3 -3
- package/dist/{property-D2Nnsmm1.js → property-BT1zDSkd.js} +10 -11
- package/dist/property-BT1zDSkd.js.map +1 -0
- package/dist/publishDraftGraph-Bcfrdj7-.js +405 -0
- package/dist/publishDraftGraph-Bcfrdj7-.js.map +1 -0
- package/dist/{resetAmbiguousLegacyItemData-BqbHNUYk.js → resetAmbiguousLegacyItemData-Ci6PM_vC.js} +2 -2
- package/dist/{resetAmbiguousLegacyItemData-BqbHNUYk.js.map → resetAmbiguousLegacyItemData-Ci6PM_vC.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-DQK6JfXS.js → resolveModelForSyncedSeed-CLlumTBq.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-DQK6JfXS.js.map → resolveModelForSyncedSeed-CLlumTBq.js.map} +1 -1
- package/dist/src/Item/Item.d.ts +11 -0
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts +10 -0
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/Model/Model.d.ts +15 -2
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/Model/service/actors/createModelProperties.d.ts.map +1 -1
- package/dist/src/Model/service/actors/loadOrCreateModel.d.ts.map +1 -1
- package/dist/src/Model/service/actors/validateModel.d.ts.map +1 -1
- package/dist/src/Model/service/modelMachine.d.ts.map +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts +9 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/actors/compareAndMarkDraft.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/actors/saveToSchema.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/actors/validateProperty.d.ts.map +1 -1
- package/dist/src/Schema/Schema.d.ts +7 -0
- package/dist/src/Schema/Schema.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/checkExistingSchema.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/createModelInstances.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/loadOrCreateSchema.d.ts.map +1 -1
- package/dist/src/db/read/getPublishPayload.d.ts +9 -0
- package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/src/db/read/getPublishUploads.d.ts +5 -0
- package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
- package/dist/src/db/read/publishDraftGraph.d.ts +57 -0
- package/dist/src/db/read/publishDraftGraph.d.ts.map +1 -0
- package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityLiveQuery.d.ts.map +1 -1
- package/dist/src/helpers/entity/evictionEpoch.d.ts +18 -0
- package/dist/src/helpers/entity/evictionEpoch.d.ts.map +1 -0
- package/dist/src/helpers/generateId.d.ts +4 -0
- package/dist/src/helpers/generateId.d.ts.map +1 -1
- package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts +28 -6
- package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/query/createLocalQueryDataSource.d.ts.map +1 -1
- package/dist/src/services/write/actors/validateEntity.d.ts.map +1 -1
- package/dist/src/types/item.d.ts +7 -8
- package/dist/src/types/item.d.ts.map +1 -1
- package/dist/{syncDbWithEas-LRKr_NZF.js → syncDbWithEas-BQsXjGhe.js} +15 -16
- package/dist/syncDbWithEas-BQsXjGhe.js.map +1 -0
- package/dist/{tabEvents-DYI2GU7i.js → tabEvents-C9qUKx_z.js} +28 -11
- package/dist/tabEvents-C9qUKx_z.js.map +1 -0
- package/dist/{tolerantWebAccess-CzOBz5M6.js → tolerantWebAccess-B-9bwxbw.js} +6 -6
- package/dist/{tolerantWebAccess-CzOBz5M6.js.map → tolerantWebAccess-B-9bwxbw.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-B58ORbY3.js → updateSeedRevokedAt-D6q0h7pj.js} +3 -3
- package/dist/{updateSeedRevokedAt-B58ORbY3.js.map → updateSeedRevokedAt-D6q0h7pj.js.map} +1 -1
- package/package.json +13 -10
- package/dist/ClientManager-DLleL_2e.js.map +0 -1
- package/dist/Item-zBFWQDU9.js.map +0 -1
- package/dist/ModelProperty-lth9L37R.js.map +0 -1
- package/dist/Schema-DOhlrQ-N.js.map +0 -1
- package/dist/cjs/ModelProperty-BEsIHAjk.js.map +0 -1
- package/dist/cjs/Schema-qEp5mH1N.js.map +0 -1
- package/dist/cjs/getLatestVersionRow-DVizNNoI.js +0 -59
- package/dist/cjs/getLatestVersionRow-DVizNNoI.js.map +0 -1
- package/dist/cjs/getPublishPayload-D5-dYtNq.js.map +0 -1
- package/dist/cjs/getPublishUploads-B5Lq6q-_.js.map +0 -1
- package/dist/cjs/getSegmentedItemProperties-giHO7R3d.js +0 -147
- package/dist/cjs/getSegmentedItemProperties-giHO7R3d.js.map +0 -1
- package/dist/cjs/index-B3UDbm1C.js.map +0 -1
- package/dist/cjs/index-C66AfYDG.js.map +0 -1
- package/dist/generateId-BopUwD8F.js +0 -9
- package/dist/generateId-BopUwD8F.js.map +0 -1
- package/dist/getLatestVersionRow-Brrl1AnW.js +0 -46
- package/dist/getLatestVersionRow-Brrl1AnW.js.map +0 -1
- package/dist/getPublishPayload-H032DHC7.js.map +0 -1
- package/dist/getPublishUploads-CR66RlGJ.js.map +0 -1
- package/dist/getSegmentedItemProperties-C2EJ2G0N.js +0 -147
- package/dist/getSegmentedItemProperties-C2EJ2G0N.js.map +0 -1
- package/dist/index-6bJuv5Tt.js.map +0 -1
- package/dist/index-B0LgJblD.js.map +0 -1
- package/dist/index-DtfjeuxC.js.map +0 -1
- package/dist/property-D2Nnsmm1.js.map +0 -1
- package/dist/src/browser/helpers/index.d.ts +0 -4
- package/dist/src/browser/helpers/index.d.ts.map +0 -1
- package/dist/syncDbWithEas-LRKr_NZF.js.map +0 -1
- package/dist/tabEvents-DYI2GU7i.js.map +0 -1
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var xstate = require('xstate');
|
|
4
4
|
require('reflect-metadata');
|
|
5
|
-
var main_cjs = require('./index-
|
|
5
|
+
var main_cjs = require('./index-Dls7aMjr.js');
|
|
6
6
|
require('pluralize');
|
|
7
7
|
var drizzleOrm = require('drizzle-orm');
|
|
8
8
|
var debug = require('debug');
|
|
9
|
-
var Schema = require('./Schema-
|
|
9
|
+
var Schema = require('./Schema-BXhXdUsA.js');
|
|
10
10
|
require('immer');
|
|
11
11
|
require('drizzle-orm/sqlite-core');
|
|
12
12
|
require('@seedprotocol/arweave');
|
|
@@ -32,7 +32,7 @@ require('js-yaml');
|
|
|
32
32
|
require('child_process');
|
|
33
33
|
require('@seedprotocol/arweave/node');
|
|
34
34
|
require('@seedprotocol/eas/node');
|
|
35
|
-
require('./SchemaValidationService-
|
|
35
|
+
require('./SchemaValidationService-CC18QDfc.js');
|
|
36
36
|
require('@sinclair/typebox/value');
|
|
37
37
|
|
|
38
38
|
const logger$3 = debug('seedSdk:modelProperty:actors:saveToSchema');
|
|
@@ -43,12 +43,12 @@ const logger$3 = debug('seedSdk:modelProperty:actors:saveToSchema');
|
|
|
43
43
|
*/
|
|
44
44
|
async function getSchemaNameFromModel(modelName) {
|
|
45
45
|
// Get the latest schema files and find which one contains this model
|
|
46
|
-
const schemaHelpersMod = await Promise.resolve().then(function () { return require('./index-
|
|
46
|
+
const schemaHelpersMod = await Promise.resolve().then(function () { return require('./index-Dls7aMjr.js'); }).then(function (n) { return n.schema$1; });
|
|
47
47
|
const { listLatestSchemaFiles } = schemaHelpersMod;
|
|
48
48
|
const latestSchemas = await listLatestSchemaFiles();
|
|
49
49
|
for (const schema of latestSchemas) {
|
|
50
50
|
try {
|
|
51
|
-
const fileManagerMod = await Promise.resolve().then(function () { return require('./index-
|
|
51
|
+
const fileManagerMod = await Promise.resolve().then(function () { return require('./index-Dls7aMjr.js'); }).then(function (n) { return n.BaseFileManager$1; });
|
|
52
52
|
const { BaseFileManager } = fileManagerMod;
|
|
53
53
|
const content = await BaseFileManager.readFileAsString(schema.filePath);
|
|
54
54
|
const schemaFile = JSON.parse(content);
|
|
@@ -63,10 +63,10 @@ async function getSchemaNameFromModel(modelName) {
|
|
|
63
63
|
}
|
|
64
64
|
return undefined;
|
|
65
65
|
}
|
|
66
|
-
const saveToSchema = xstate.fromCallback(({ sendBack, input: { context } }) => {
|
|
66
|
+
const saveToSchema = xstate.fromCallback(({ sendBack, input: { context }, self }) => {
|
|
67
67
|
const _saveToSchema = async () => {
|
|
68
68
|
// Use dynamic import to break circular dependency
|
|
69
|
-
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
69
|
+
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-CC18QDfc.js'); });
|
|
70
70
|
const { SchemaValidationService } = validationServiceMod;
|
|
71
71
|
const validationService = new SchemaValidationService();
|
|
72
72
|
// Validate property structure before saving
|
|
@@ -85,14 +85,17 @@ const saveToSchema = xstate.fromCallback(({ sendBack, input: { context } }) => {
|
|
|
85
85
|
throw new Error(`Model not found for modelId: ${context.modelId}`);
|
|
86
86
|
}
|
|
87
87
|
// Persist to database only - schema file is updated only when user calls Schema.saveNewVersion()
|
|
88
|
-
const dbMod = await Promise.resolve().then(function () { return require('./index-
|
|
88
|
+
const dbMod = await Promise.resolve().then(function () { return require('./index-Dls7aMjr.js'); }).then(function (n) { return n.db; });
|
|
89
89
|
const { savePropertyToDb } = dbMod;
|
|
90
90
|
await savePropertyToDb(context);
|
|
91
91
|
// Mark schema as draft so user knows to save
|
|
92
92
|
const schemaName = context._schemaName ?? (await getSchemaNameFromModel(context.modelName));
|
|
93
93
|
if (schemaName) {
|
|
94
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-
|
|
94
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-BXhXdUsA.js'); });
|
|
95
95
|
const { Schema } = schemaMod;
|
|
96
|
+
// Stopped meanwhile (unloaded, or evicted with its schema): don't load the schema again
|
|
97
|
+
if (main_cjs.isActorStopped(self))
|
|
98
|
+
return;
|
|
96
99
|
const schema = Schema.create(schemaName, { waitForReady: false });
|
|
97
100
|
schema.getService().send({
|
|
98
101
|
type: 'markAsDraft',
|
|
@@ -113,7 +116,7 @@ const saveToSchema = xstate.fromCallback(({ sendBack, input: { context } }) => {
|
|
|
113
116
|
});
|
|
114
117
|
|
|
115
118
|
const logger$2 = debug('seedSdk:modelProperty:actors:compareAndMarkDraft');
|
|
116
|
-
const compareAndMarkDraft = xstate.fromCallback(({ sendBack, input: { context } }) => {
|
|
119
|
+
const compareAndMarkDraft = xstate.fromCallback(({ sendBack, input: { context }, self }) => {
|
|
117
120
|
const _compareAndMarkDraft = async () => {
|
|
118
121
|
// Fill modelName/dataType from _originalValues when missing, then from DB by schemaFileId
|
|
119
122
|
let fullContext = {
|
|
@@ -124,7 +127,7 @@ const compareAndMarkDraft = xstate.fromCallback(({ sendBack, input: { context }
|
|
|
124
127
|
const schemaFileIdForResolve = fullContext._propertyFileId || (typeof fullContext.id === 'string' ? fullContext.id : undefined);
|
|
125
128
|
if (schemaFileIdForResolve && (fullContext.modelName === undefined || fullContext.dataType === undefined)) {
|
|
126
129
|
try {
|
|
127
|
-
const dbMod = await Promise.resolve().then(function () { return require('./index-
|
|
130
|
+
const dbMod = await Promise.resolve().then(function () { return require('./index-Dls7aMjr.js'); }).then(function (n) { return n.db; });
|
|
128
131
|
const { getPropertyModelNameAndDataType, getModelNameByModelId } = dbMod;
|
|
129
132
|
let fromDb;
|
|
130
133
|
for (let attempt = 0; attempt < 6; attempt++) {
|
|
@@ -169,7 +172,7 @@ const compareAndMarkDraft = xstate.fromCallback(({ sendBack, input: { context }
|
|
|
169
172
|
if (fullContext.modelName && fullContext.name && schemaFileId) {
|
|
170
173
|
logger$2(`[compareAndMarkDraft] _originalValues not set, but saving to database anyway for property ${context.modelName}:${context.name} (schemaFileId: ${schemaFileId})`);
|
|
171
174
|
try {
|
|
172
|
-
const dbMod = await Promise.resolve().then(function () { return require('./index-
|
|
175
|
+
const dbMod = await Promise.resolve().then(function () { return require('./index-Dls7aMjr.js'); }).then(function (n) { return n.db; });
|
|
173
176
|
const { savePropertyToDb } = dbMod;
|
|
174
177
|
// Ensure _propertyFileId is set for savePropertyToDb to find the property
|
|
175
178
|
const contextWithFileId = {
|
|
@@ -229,7 +232,7 @@ const compareAndMarkDraft = xstate.fromCallback(({ sendBack, input: { context }
|
|
|
229
232
|
logger$2(`Property ${fullContext.modelName}:${fullContext.name} has changes, marking as edited`);
|
|
230
233
|
logger$2(`[compareAndMarkDraft] Context when saving: id=${fullContext.id}, _propertyFileId=${fullContext._propertyFileId}, name=${fullContext.name}, _originalValues.name=${fullContext._originalValues?.name}`);
|
|
231
234
|
// Use dynamic import to break circular dependency
|
|
232
|
-
const dbMod = await Promise.resolve().then(function () { return require('./index-
|
|
235
|
+
const dbMod = await Promise.resolve().then(function () { return require('./index-Dls7aMjr.js'); }).then(function (n) { return n.db; });
|
|
233
236
|
const { savePropertyToDb } = dbMod;
|
|
234
237
|
// Save to database (but not JSON file) - always save to DB when there are changes
|
|
235
238
|
try {
|
|
@@ -243,8 +246,11 @@ const compareAndMarkDraft = xstate.fromCallback(({ sendBack, input: { context }
|
|
|
243
246
|
// Mark schema as draft if schema name is available
|
|
244
247
|
if (fullContext._schemaName) {
|
|
245
248
|
// Get the Schema instance and mark it as draft
|
|
246
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-
|
|
249
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-BXhXdUsA.js'); });
|
|
247
250
|
const { Schema } = schemaMod;
|
|
251
|
+
// Stopped meanwhile (unloaded, or evicted with its schema): don't load the schema again
|
|
252
|
+
if (main_cjs.isActorStopped(self))
|
|
253
|
+
return;
|
|
248
254
|
const schema = Schema.create(fullContext._schemaName, {
|
|
249
255
|
waitForReady: false,
|
|
250
256
|
});
|
|
@@ -260,14 +266,14 @@ const compareAndMarkDraft = xstate.fromCallback(({ sendBack, input: { context }
|
|
|
260
266
|
logger$2(`Property ${fullContext.modelName}:${fullContext.name} has no changes`);
|
|
261
267
|
// Clear isEdited flag in database
|
|
262
268
|
try {
|
|
263
|
-
const seedSchemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
269
|
+
const seedSchemaMod = await Promise.resolve().then(function () { return require('./index-Dls7aMjr.js'); }).then(function (n) { return n.schema; });
|
|
264
270
|
const { properties: propertiesTable, models: modelsTable } = seedSchemaMod;
|
|
265
271
|
const drizzleMod = await import('drizzle-orm');
|
|
266
272
|
const { eq, and } = drizzleMod;
|
|
267
273
|
const db = main_cjs.BaseDb.getAppDb();
|
|
268
274
|
if (db && fullContext.modelName && fullContext.name) {
|
|
269
275
|
// Find this property's model (model names are only unique per schema)
|
|
270
|
-
const { resolveModelRecord } = await Promise.resolve().then(function () { return require('./index-
|
|
276
|
+
const { resolveModelRecord } = await Promise.resolve().then(function () { return require('./index-Dls7aMjr.js'); }).then(function (n) { return n.resolveModelRecord$1; });
|
|
271
277
|
const modelRecord = await resolveModelRecord(fullContext.modelName, {
|
|
272
278
|
modelId: typeof fullContext.modelId === 'number' ? fullContext.modelId : undefined,
|
|
273
279
|
schemaName: fullContext._schemaName,
|
|
@@ -311,7 +317,7 @@ const compareAndMarkDraft = xstate.fromCallback(({ sendBack, input: { context }
|
|
|
311
317
|
});
|
|
312
318
|
|
|
313
319
|
const logger$1 = debug('seedSdk:modelProperty:actors:validateProperty');
|
|
314
|
-
const validateProperty = xstate.fromCallback(({ sendBack, input: { context } }) => {
|
|
320
|
+
const validateProperty = xstate.fromCallback(({ sendBack, input: { context }, self }) => {
|
|
315
321
|
const _validateProperty = async () => {
|
|
316
322
|
// Use full context for validation: fill modelName/dataType from _originalValues when missing, then
|
|
317
323
|
// from DB by schemaFileId (context.id) so just-created renames don't fail structure validation.
|
|
@@ -325,7 +331,7 @@ const validateProperty = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
325
331
|
// Brief wait so trackPendingWrite from ModelProperty.create() has time to run (it's in setTimeout(0))
|
|
326
332
|
await new Promise((r) => setTimeout(r, 60));
|
|
327
333
|
try {
|
|
328
|
-
const dbMod = await Promise.resolve().then(function () { return require('./index-
|
|
334
|
+
const dbMod = await Promise.resolve().then(function () { return require('./index-Dls7aMjr.js'); }).then(function (n) { return n.db; });
|
|
329
335
|
const { getPropertyModelNameAndDataType, getModelNameByModelId } = dbMod;
|
|
330
336
|
// Try pending write first (property row may not exist yet)
|
|
331
337
|
if (fullContext.modelName === undefined && schemaFileId) {
|
|
@@ -377,10 +383,10 @@ const validateProperty = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
377
383
|
fullContext = { ...fullContext, dataType: (fullContext.dataType ?? context._originalValues?.dataType) || 'Text' };
|
|
378
384
|
}
|
|
379
385
|
// Use dynamic imports to break circular dependencies
|
|
380
|
-
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
386
|
+
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-CC18QDfc.js'); });
|
|
381
387
|
const { SchemaValidationService } = validationServiceMod;
|
|
382
388
|
const validationService = new SchemaValidationService();
|
|
383
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-
|
|
389
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-BXhXdUsA.js'); });
|
|
384
390
|
const { Schema } = schemaMod;
|
|
385
391
|
// Validate property structure
|
|
386
392
|
const structureResult = validationService.validatePropertyStructure(fullContext);
|
|
@@ -389,6 +395,9 @@ const validateProperty = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
389
395
|
return;
|
|
390
396
|
}
|
|
391
397
|
// If we have schema name and model name, validate against schema
|
|
398
|
+
// Stopped meanwhile (unloaded, or evicted with its schema): don't load the schema again
|
|
399
|
+
if (main_cjs.isActorStopped(self))
|
|
400
|
+
return;
|
|
392
401
|
if (fullContext._schemaName && fullContext.modelName) {
|
|
393
402
|
try {
|
|
394
403
|
const schema = Schema.create(fullContext._schemaName, {
|
|
@@ -831,6 +840,8 @@ const TPropertyKeys = [
|
|
|
831
840
|
];
|
|
832
841
|
class ModelProperty {
|
|
833
842
|
constructor(property) {
|
|
843
|
+
/** currentEvictionEpoch() at construction: lookups started for this instance don't outlive an eviction. */
|
|
844
|
+
this._evictionEpoch = main_cjs.currentEvictionEpoch();
|
|
834
845
|
// id is now the schemaFileId (string), _dbId is the database integer ID
|
|
835
846
|
// Preserve _propertyFileId if it exists in the property object (from getPropertySchema)
|
|
836
847
|
// Convert null to undefined for optional fields (TypeBox validation expects undefined, not null)
|
|
@@ -993,7 +1004,7 @@ class ModelProperty {
|
|
|
993
1004
|
return fallbackIsEdited;
|
|
994
1005
|
}
|
|
995
1006
|
// Find this property's model (by modelId when known; model names are only unique per schema)
|
|
996
|
-
const { resolveModelRecord } = await Promise.resolve().then(function () { return require('./index-
|
|
1007
|
+
const { resolveModelRecord } = await Promise.resolve().then(function () { return require('./index-Dls7aMjr.js'); }).then(function (n) { return n.resolveModelRecord$1; });
|
|
997
1008
|
const modelRecord = await resolveModelRecord(property.modelName, this._ownerModelScope(property), db);
|
|
998
1009
|
const modelRecords = modelRecord ? [modelRecord] : [];
|
|
999
1010
|
if (modelRecords.length === 0) {
|
|
@@ -1029,7 +1040,7 @@ class ModelProperty {
|
|
|
1029
1040
|
return undefined;
|
|
1030
1041
|
}
|
|
1031
1042
|
// Resolve the ref within the owning model's schema
|
|
1032
|
-
const { resolveRefModelRecord } = await Promise.resolve().then(function () { return require('./index-
|
|
1043
|
+
const { resolveRefModelRecord } = await Promise.resolve().then(function () { return require('./index-Dls7aMjr.js'); }).then(function (n) { return n.resolveModelRecord$1; });
|
|
1033
1044
|
const refModelRecord = await resolveRefModelRecord(refModelName, property ? this._ownerModelScope(property) : { schemaName: this._getSnapshotContext()._schemaName }, db);
|
|
1034
1045
|
if (refModelRecord?.id) {
|
|
1035
1046
|
return refModelRecord.id;
|
|
@@ -1073,13 +1084,21 @@ class ModelProperty {
|
|
|
1073
1084
|
}
|
|
1074
1085
|
}
|
|
1075
1086
|
if (!model && modelId) {
|
|
1076
|
-
const { resolveModelRecord } = await Promise.resolve().then(function () { return require('./index-
|
|
1087
|
+
const { resolveModelRecord } = await Promise.resolve().then(function () { return require('./index-Dls7aMjr.js'); }).then(function (n) { return n.resolveModelRecord$1; });
|
|
1077
1088
|
const modelFileId = (await resolveModelRecord(property.modelName, { modelId }))?.schemaFileId;
|
|
1078
1089
|
model = modelFileId ? main_cjs.Model.getById(modelFileId) : undefined;
|
|
1079
1090
|
}
|
|
1091
|
+
// Evicted (with its schema) or unloaded while the lookups above ran: don't instantiate its model
|
|
1092
|
+
// again from rows that are being deleted.
|
|
1093
|
+
if (!model && main_cjs.isActorStopped(this._service))
|
|
1094
|
+
return undefined;
|
|
1080
1095
|
if (!model) {
|
|
1081
1096
|
try {
|
|
1082
|
-
model
|
|
1097
|
+
// The epoch from when this instance was built: an eviction of the model's schema since
|
|
1098
|
+
// then (this instance may already be stopped) must not re-create the model.
|
|
1099
|
+
model = await main_cjs.Model.getByNameAsync(property.modelName, undefined, {
|
|
1100
|
+
evictionEpoch: this._evictionEpoch,
|
|
1101
|
+
});
|
|
1083
1102
|
}
|
|
1084
1103
|
catch {
|
|
1085
1104
|
model = undefined;
|
|
@@ -1531,7 +1550,7 @@ class ModelProperty {
|
|
|
1531
1550
|
* Create or get ModelProperty instance by propertyFileId
|
|
1532
1551
|
* Queries the database to find the property if not cached
|
|
1533
1552
|
*/
|
|
1534
|
-
static async createById(propertyFileId) {
|
|
1553
|
+
static async createById(propertyFileId, options) {
|
|
1535
1554
|
if (!propertyFileId) {
|
|
1536
1555
|
return undefined;
|
|
1537
1556
|
}
|
|
@@ -1545,10 +1564,7 @@ class ModelProperty {
|
|
|
1545
1564
|
if (!db) {
|
|
1546
1565
|
return undefined;
|
|
1547
1566
|
}
|
|
1548
|
-
|
|
1549
|
-
.select()
|
|
1550
|
-
.from(main_cjs.properties)
|
|
1551
|
-
.limit(100);
|
|
1567
|
+
const evictionEpoch = options?.evictionEpoch ?? main_cjs.currentEvictionEpoch();
|
|
1552
1568
|
const propertyRecords = await db
|
|
1553
1569
|
.select()
|
|
1554
1570
|
.from(main_cjs.properties)
|
|
@@ -1598,6 +1614,19 @@ class ModelProperty {
|
|
|
1598
1614
|
propertyData.ref = refModelRecords[0].name;
|
|
1599
1615
|
}
|
|
1600
1616
|
}
|
|
1617
|
+
// Its model's schema was evicted while we read the rows (e.g. a model's property lookup in flight
|
|
1618
|
+
// during Schema.destroy or test cleanup): don't bring the property back.
|
|
1619
|
+
if (main_cjs.anyEvictionSince(evictionEpoch)) {
|
|
1620
|
+
const schemaRows = await db
|
|
1621
|
+
.select({ name: main_cjs.schemas.name })
|
|
1622
|
+
.from(main_cjs.modelSchemas)
|
|
1623
|
+
.innerJoin(main_cjs.schemas, drizzleOrm.eq(main_cjs.schemas.id, main_cjs.modelSchemas.schemaId))
|
|
1624
|
+
.where(drizzleOrm.eq(main_cjs.modelSchemas.modelId, propertyRecord.modelId));
|
|
1625
|
+
if (schemaRows.length === 0 ||
|
|
1626
|
+
schemaRows.some((row) => main_cjs.schemaEvictedSince(row.name, evictionEpoch))) {
|
|
1627
|
+
return undefined;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1601
1630
|
// Create ModelProperty instance (sync for createById so we can send updateContext)
|
|
1602
1631
|
const instance = this.create(propertyData, { waitForReady: false });
|
|
1603
1632
|
// Set isEdited from database after creation
|
|
@@ -1945,4 +1974,4 @@ var ModelProperty$1 = /*#__PURE__*/Object.freeze({
|
|
|
1945
1974
|
});
|
|
1946
1975
|
|
|
1947
1976
|
exports.ModelProperty = ModelProperty;
|
|
1948
|
-
//# sourceMappingURL=ModelProperty-
|
|
1977
|
+
//# sourceMappingURL=ModelProperty-BT6Un_MB.js.map
|