@seedprotocol/sdk 0.4.9 → 0.4.11
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/{ArweaveClient-sN5h2FvY.js → ArweaveClient-CwXE3NCK.js} +3 -3
- package/dist/{ArweaveClient-sN5h2FvY.js.map → ArweaveClient-CwXE3NCK.js.map} +1 -1
- package/dist/{ArweaveClient-DFqnm5Kj.js → ArweaveClient-DyhvHiIT.js} +3 -3
- package/dist/{ArweaveClient-DFqnm5Kj.js.map → ArweaveClient-DyhvHiIT.js.map} +1 -1
- package/dist/{Db-DIythELU.js → Db-Dr6gWq8d.js} +3 -3
- package/dist/{Db-DIythELU.js.map → Db-Dr6gWq8d.js.map} +1 -1
- package/dist/{Db-Dz17KxVs.js → Db-mH9nSDfI.js} +3 -3
- package/dist/{Db-Dz17KxVs.js.map → Db-mH9nSDfI.js.map} +1 -1
- package/dist/{EasClient-BadfcFDk.js → EasClient-Yh-t7zEA.js} +2 -2
- package/dist/{EasClient-DosbWaZN.js.map → EasClient-Yh-t7zEA.js.map} +1 -1
- package/dist/{EasClient-DosbWaZN.js → EasClient-aggdMFrc.js} +2 -2
- package/dist/{EasClient-BadfcFDk.js.map → EasClient-aggdMFrc.js.map} +1 -1
- package/dist/{FileManager-Wthr5yHO.js → FileManager-ClU_rIR0.js} +2 -2
- package/dist/{FileManager-Wthr5yHO.js.map → FileManager-ClU_rIR0.js.map} +1 -1
- package/dist/{FileManager-BHuVNWT3.js → FileManager-Dl2DD4Uc.js} +2 -2
- package/dist/{FileManager-BHuVNWT3.js.map → FileManager-Dl2DD4Uc.js.map} +1 -1
- package/dist/{ModelProperty-B9Z2DRxI.js → ModelProperty-gBmew8gY.js} +94 -18
- package/dist/ModelProperty-gBmew8gY.js.map +1 -0
- package/dist/{PathResolver-NEpTSgQK.js → PathResolver-CILJPhz1.js} +2 -2
- package/dist/{PathResolver-NEpTSgQK.js.map → PathResolver-CILJPhz1.js.map} +1 -1
- package/dist/{PathResolver-Cd1PZDLG.js → PathResolver-CfA_D3wa.js} +2 -2
- package/dist/{PathResolver-Cd1PZDLG.js.map → PathResolver-CfA_D3wa.js.map} +1 -1
- package/dist/{QueryClient-C9U8oZUe.js → QueryClient-BdpWYoxo.js} +2 -2
- package/dist/{QueryClient-C9U8oZUe.js.map → QueryClient-BdpWYoxo.js.map} +1 -1
- package/dist/{QueryClient-ndmA8MYL.js → QueryClient-Dl_P8u5s.js} +2 -2
- package/dist/{QueryClient-ndmA8MYL.js.map → QueryClient-Dl_P8u5s.js.map} +1 -1
- package/dist/{Schema-D1-HjT8z.js → Schema-B-vCLIuU.js} +21 -21
- package/dist/{Schema-D1-HjT8z.js.map → Schema-B-vCLIuU.js.map} +1 -1
- package/dist/{SchemaValidationService-CIXKzSpb.js → SchemaValidationService-C_iTQIjR.js} +2 -2
- package/dist/{SchemaValidationService-CIXKzSpb.js.map → SchemaValidationService-C_iTQIjR.js.map} +1 -1
- package/dist/cjs/{ModelProperty-09hNvSBl.js → ModelProperty-DcAM5M8T.js} +94 -18
- package/dist/cjs/ModelProperty-DcAM5M8T.js.map +1 -0
- package/dist/cjs/{Schema-BcwvUABB.js → Schema-B6ifYEhD.js} +20 -20
- package/dist/cjs/{Schema-BcwvUABB.js.map → Schema-B6ifYEhD.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-zty4nfCu.js → SchemaValidationService-OFyzZIUX.js} +2 -2
- package/dist/cjs/{SchemaValidationService-zty4nfCu.js.map → SchemaValidationService-OFyzZIUX.js.map} +1 -1
- package/dist/cjs/{getItem-Dlb5YSQn.js → getItem-CAYQYTpg.js} +2 -2
- package/dist/cjs/{getItem-Dlb5YSQn.js.map → getItem-CAYQYTpg.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-BqL06sEI.js → getPublishPayload-CBuGIazw.js} +5 -5
- package/dist/cjs/{getPublishPayload-BqL06sEI.js.map → getPublishPayload-CBuGIazw.js.map} +1 -1
- package/dist/cjs/{getPublishUploads-oukGI2N6.js → getPublishUploads-B7bB1OGg.js} +3 -3
- package/dist/cjs/{getPublishUploads-oukGI2N6.js.map → getPublishUploads-B7bB1OGg.js.map} +1 -1
- package/dist/cjs/{getSegmentedItemProperties-JT984OOp.js → getSegmentedItemProperties-MVZ-0mQG.js} +2 -2
- package/dist/cjs/{getSegmentedItemProperties-JT984OOp.js.map → getSegmentedItemProperties-MVZ-0mQG.js.map} +1 -1
- package/dist/cjs/{index-jubgGeM2.js → index-6P4MEsbO.js} +2 -2
- package/dist/cjs/index-6P4MEsbO.js.map +1 -0
- package/dist/cjs/{index-BLETlVgA.js → index-CA4i5TA7.js} +105 -46
- package/dist/cjs/index-CA4i5TA7.js.map +1 -0
- package/dist/cjs/{ownership-vfvyz3KJ.js → ownership-5TQ-v2CF.js} +2 -2
- package/dist/cjs/{ownership-vfvyz3KJ.js.map → ownership-5TQ-v2CF.js.map} +1 -1
- package/dist/{getItem-f9rNUz7I.js → getItem-xpxRXqHI.js} +2 -2
- package/dist/{getItem-f9rNUz7I.js.map → getItem-xpxRXqHI.js.map} +1 -1
- package/dist/{getPublishPayload-BBI_j9I2.js → getPublishPayload-CBeCMSeQ.js} +5 -5
- package/dist/{getPublishPayload-BBI_j9I2.js.map → getPublishPayload-CBeCMSeQ.js.map} +1 -1
- package/dist/{getPublishUploads-BFM94w5S.js → getPublishUploads-NITxWWDD.js} +3 -3
- package/dist/{getPublishUploads-BFM94w5S.js.map → getPublishUploads-NITxWWDD.js.map} +1 -1
- package/dist/{getSegmentedItemProperties-Di9vevKz.js → getSegmentedItemProperties-CYzNtJxH.js} +2 -2
- package/dist/{getSegmentedItemProperties-Di9vevKz.js.map → getSegmentedItemProperties-CYzNtJxH.js.map} +1 -1
- package/dist/{index-CSAVWKeA.js → index-BC0xKxkf.js} +3 -3
- package/dist/index-BC0xKxkf.js.map +1 -0
- package/dist/{index-j8WN8W6V.js → index-B_apqB1Q.js} +120 -61
- package/dist/index-B_apqB1Q.js.map +1 -0
- package/dist/{index-ajj6SHkh.js → index-CcXvJ2H7.js} +2 -2
- package/dist/index-CcXvJ2H7.js.map +1 -0
- package/dist/main.cjs +1 -1
- package/dist/main.js +11 -11
- package/dist/node.js +10 -10
- package/dist/{ownership-DLNI17NE.js → ownership-C7Afj3yr.js} +2 -2
- package/dist/{ownership-DLNI17NE.js.map → ownership-C7Afj3yr.js.map} +1 -1
- package/dist/{property-C6qoOzLG.js → property-C2gviIFJ.js} +4 -4
- package/dist/{property-C6qoOzLG.js.map → property-C2gviIFJ.js.map} +1 -1
- package/dist/{queries-jMaUn86w.js → queries-BFzkFn4Y.js} +2 -2
- package/dist/{queries-jMaUn86w.js.map → queries-BFzkFn4Y.js.map} +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts +5 -0
- 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/validateProperty.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts.map +1 -1
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/services/write/actors/writeToDatabase.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/ModelProperty-B9Z2DRxI.js.map +0 -1
- package/dist/cjs/ModelProperty-09hNvSBl.js.map +0 -1
- package/dist/cjs/index-BLETlVgA.js.map +0 -1
- package/dist/cjs/index-jubgGeM2.js.map +0 -1
- package/dist/index-CSAVWKeA.js.map +0 -1
- package/dist/index-ajj6SHkh.js.map +0 -1
- package/dist/index-j8WN8W6V.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { fromCallback, setup, assign, createActor } from 'xstate';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
|
-
import { j as BaseDb, af as writeProcessMachine, u as models, v as properties, M as Model, r as modelPropertiesToObject, a0 as schemas, U as modelSchemas, n as normalizeDataType,
|
|
3
|
+
import { j as BaseDb, af as writeProcessMachine, u as models, v as properties, M as Model, r as modelPropertiesToObject, a0 as schemas, U as modelSchemas, ag as getModelIdByFileId, n as normalizeDataType, ah as generateId, ai as waitForEntityIdle, aj as createReactiveProxy, ak as findEntity, C as BaseFileManager, al as forceRemoveFromCaches, am as runDestroyLifecycle, an as getModelId } from './index-B_apqB1Q.js';
|
|
4
4
|
import 'pluralize';
|
|
5
5
|
import { eq, and } from 'drizzle-orm';
|
|
6
6
|
import debug from 'debug';
|
|
7
|
-
import { S as Schema } from './Schema-
|
|
7
|
+
import { S as Schema } from './Schema-B-vCLIuU.js';
|
|
8
8
|
import 'drizzle-orm/sqlite-core';
|
|
9
9
|
import 'nanoid';
|
|
10
10
|
import 'nanoid-dictionary';
|
|
@@ -15,7 +15,7 @@ import 'drizzle-orm/casing';
|
|
|
15
15
|
import 'eventemitter3';
|
|
16
16
|
import 'arweave';
|
|
17
17
|
import '@sinclair/typebox';
|
|
18
|
-
import './SchemaValidationService-
|
|
18
|
+
import './SchemaValidationService-C_iTQIjR.js';
|
|
19
19
|
import '@sinclair/typebox/value';
|
|
20
20
|
|
|
21
21
|
const logger$3 = debug('seedSdk:modelProperty:actors:saveToSchema');
|
|
@@ -26,14 +26,14 @@ const logger$3 = debug('seedSdk:modelProperty:actors:saveToSchema');
|
|
|
26
26
|
*/
|
|
27
27
|
async function getSchemaNameFromModel(modelName) {
|
|
28
28
|
// Get the latest schema files and find which one contains this model
|
|
29
|
-
const _mod_0 = await import('./index-
|
|
29
|
+
const _mod_0 = await import('./index-B_apqB1Q.js');
|
|
30
30
|
const _ns_0 = _mod_0.aZ;
|
|
31
31
|
const schemaHelpersMod = _ns_0;
|
|
32
32
|
const { listLatestSchemaFiles } = schemaHelpersMod;
|
|
33
33
|
const latestSchemas = await listLatestSchemaFiles();
|
|
34
34
|
for (const schema of latestSchemas) {
|
|
35
35
|
try {
|
|
36
|
-
const _mod_1 = await import('./index-
|
|
36
|
+
const _mod_1 = await import('./index-B_apqB1Q.js');
|
|
37
37
|
const _ns_1 = _mod_1.aX;
|
|
38
38
|
const fileManagerMod = _ns_1;
|
|
39
39
|
const { BaseFileManager } = fileManagerMod;
|
|
@@ -53,7 +53,7 @@ async function getSchemaNameFromModel(modelName) {
|
|
|
53
53
|
const saveToSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
54
54
|
const _saveToSchema = async () => {
|
|
55
55
|
// Use dynamic import to break circular dependency
|
|
56
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
56
|
+
const validationServiceMod = await import('./SchemaValidationService-C_iTQIjR.js');
|
|
57
57
|
const { SchemaValidationService } = validationServiceMod;
|
|
58
58
|
const validationService = new SchemaValidationService();
|
|
59
59
|
// Validate property structure before saving
|
|
@@ -72,7 +72,7 @@ const saveToSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
72
72
|
throw new Error(`Model not found for modelId: ${context.modelId}`);
|
|
73
73
|
}
|
|
74
74
|
// Persist to database only - schema file is updated only when user calls Schema.saveNewVersion()
|
|
75
|
-
const _mod_2 = await import('./index-
|
|
75
|
+
const _mod_2 = await import('./index-B_apqB1Q.js');
|
|
76
76
|
const _ns_2 = _mod_2.aY;
|
|
77
77
|
const dbMod = _ns_2;
|
|
78
78
|
const { savePropertyToDb } = dbMod;
|
|
@@ -80,7 +80,7 @@ const saveToSchema = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
80
80
|
// Mark schema as draft so user knows to save
|
|
81
81
|
const schemaName = context._schemaName ?? (await getSchemaNameFromModel(context.modelName));
|
|
82
82
|
if (schemaName) {
|
|
83
|
-
const _mod_3 = await import('./Schema-
|
|
83
|
+
const _mod_3 = await import('./Schema-B-vCLIuU.js');
|
|
84
84
|
const _ns_3 = _mod_3.b;
|
|
85
85
|
const schemaMod = _ns_3;
|
|
86
86
|
const { Schema } = schemaMod;
|
|
@@ -115,7 +115,7 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
115
115
|
const schemaFileIdForResolve = fullContext._propertyFileId || (typeof fullContext.id === 'string' ? fullContext.id : undefined);
|
|
116
116
|
if (schemaFileIdForResolve && (fullContext.modelName === undefined || fullContext.dataType === undefined)) {
|
|
117
117
|
try {
|
|
118
|
-
const _mod_4 = await import('./index-
|
|
118
|
+
const _mod_4 = await import('./index-B_apqB1Q.js');
|
|
119
119
|
const _ns_4 = _mod_4.aY;
|
|
120
120
|
const dbMod = _ns_4;
|
|
121
121
|
const { getPropertyModelNameAndDataType, getModelNameByModelId } = dbMod;
|
|
@@ -156,13 +156,16 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
156
156
|
if (!fullContext._originalValues) {
|
|
157
157
|
logger$2('No original values to compare against');
|
|
158
158
|
logger$2(`[compareAndMarkDraft] Context: modelName=${fullContext.modelName}, name=${fullContext.name}, id=${fullContext.id}, _propertyFileId=${fullContext._propertyFileId}`);
|
|
159
|
+
// #region agent log
|
|
160
|
+
fetch('http://127.0.0.1:7242/ingest/0978b378-ebae-46bf-8fd3-134ef2e16cdd', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '9ee076' }, body: JSON.stringify({ sessionId: '9ee076', location: 'compareAndMarkDraft.ts:noOriginalValues', message: 'compareAndMarkDraft early path - no _originalValues', data: { name: fullContext.name, modelName: fullContext.modelName, schemaFileId: schemaFileId, willSave: !!(fullContext.modelName && fullContext.name && schemaFileId) }, timestamp: Date.now(), hypothesisId: 'A' }) }).catch(() => { });
|
|
161
|
+
// #endregion
|
|
159
162
|
// If we have a name and modelName, try to save to database anyway
|
|
160
163
|
// This ensures name changes are persisted even if _originalValues isn't initialized yet
|
|
161
164
|
// We need either schemaFileId (id or _propertyFileId) to find the property in the database
|
|
162
165
|
if (fullContext.modelName && fullContext.name && schemaFileId) {
|
|
163
166
|
logger$2(`[compareAndMarkDraft] _originalValues not set, but saving to database anyway for property ${context.modelName}:${context.name} (schemaFileId: ${schemaFileId})`);
|
|
164
167
|
try {
|
|
165
|
-
const _mod_5 = await import('./index-
|
|
168
|
+
const _mod_5 = await import('./index-B_apqB1Q.js');
|
|
166
169
|
const _ns_5 = _mod_5.aY;
|
|
167
170
|
const dbMod = _ns_5;
|
|
168
171
|
const { savePropertyToDb } = dbMod;
|
|
@@ -186,6 +189,9 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
186
189
|
return;
|
|
187
190
|
}
|
|
188
191
|
logger$2(`[compareAndMarkDraft] Comparing: context.name=${fullContext.name}, _originalValues.name=${fullContext._originalValues?.name}`);
|
|
192
|
+
// #region agent log
|
|
193
|
+
fetch('http://127.0.0.1:7242/ingest/0978b378-ebae-46bf-8fd3-134ef2e16cdd', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '9ee076' }, body: JSON.stringify({ sessionId: '9ee076', location: 'compareAndMarkDraft.ts:beforeHasChanges', message: 'compareAndMarkDraft before hasChanges', data: { name: fullContext.name, originalName: fullContext._originalValues?.name, id: fullContext.id, schemaFileId: fullContext._propertyFileId || fullContext.id }, timestamp: Date.now(), hypothesisId: 'A' }) }).catch(() => { });
|
|
194
|
+
// #endregion
|
|
189
195
|
// Compare current values with original
|
|
190
196
|
// Only compare property fields, not internal fields
|
|
191
197
|
const propertyFields = ['name', 'dataType', 'ref', 'refModelName', 'refModelId', 'refValueType', 'storageType', 'localStorageDir', 'filenameSuffix', 'modelName', 'modelId'];
|
|
@@ -223,8 +229,11 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
223
229
|
if (hasChanges) {
|
|
224
230
|
logger$2(`Property ${fullContext.modelName}:${fullContext.name} has changes, marking as edited`);
|
|
225
231
|
logger$2(`[compareAndMarkDraft] Context when saving: id=${fullContext.id}, _propertyFileId=${fullContext._propertyFileId}, name=${fullContext.name}, _originalValues.name=${fullContext._originalValues?.name}`);
|
|
232
|
+
// #region agent log
|
|
233
|
+
fetch('http://127.0.0.1:7242/ingest/0978b378-ebae-46bf-8fd3-134ef2e16cdd', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '9ee076' }, body: JSON.stringify({ sessionId: '9ee076', location: 'compareAndMarkDraft.ts:hasChanges-callingSave', message: 'compareAndMarkDraft calling savePropertyToDb', data: { name: fullContext.name, originalName: fullContext._originalValues?.name, schemaFileId: fullContext._propertyFileId || fullContext.id }, timestamp: Date.now(), hypothesisId: 'A' }) }).catch(() => { });
|
|
234
|
+
// #endregion
|
|
226
235
|
// Use dynamic import to break circular dependency
|
|
227
|
-
const _mod_6 = await import('./index-
|
|
236
|
+
const _mod_6 = await import('./index-B_apqB1Q.js');
|
|
228
237
|
const _ns_6 = _mod_6.aY;
|
|
229
238
|
const dbMod = _ns_6;
|
|
230
239
|
const { savePropertyToDb } = dbMod;
|
|
@@ -232,15 +241,23 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
232
241
|
try {
|
|
233
242
|
await savePropertyToDb(fullContext);
|
|
234
243
|
logger$2(`[compareAndMarkDraft] Successfully saved property ${fullContext.modelName}:${fullContext.name} to database`);
|
|
244
|
+
// #region agent log
|
|
245
|
+
fetch('http://127.0.0.1:7242/ingest/0978b378-ebae-46bf-8fd3-134ef2e16cdd', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '9ee076' }, body: JSON.stringify({ sessionId: '9ee076', location: 'compareAndMarkDraft.ts:savePropertyToDbSuccess', message: 'savePropertyToDb completed successfully', data: { name: fullContext.name }, timestamp: Date.now(), hypothesisId: 'A' }) }).catch(() => { });
|
|
246
|
+
// #endregion
|
|
235
247
|
}
|
|
236
248
|
catch (error) {
|
|
237
249
|
logger$2(`[compareAndMarkDraft] Error saving property to database: ${error}`);
|
|
250
|
+
// #region agent log
|
|
251
|
+
if (typeof fetch === 'function') {
|
|
252
|
+
fetch('http://127.0.0.1:7242/ingest/0978b378-ebae-46bf-8fd3-134ef2e16cdd', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '9ee076' }, body: JSON.stringify({ sessionId: '9ee076', location: 'compareAndMarkDraft.ts:savePropertyToDbError', message: 'savePropertyToDb FAILED', data: { name: fullContext.name, error: String(error) }, timestamp: Date.now(), hypothesisId: 'B' }) }).catch(() => { });
|
|
253
|
+
}
|
|
254
|
+
// #endregion
|
|
238
255
|
throw error;
|
|
239
256
|
}
|
|
240
257
|
// Mark schema as draft if schema name is available
|
|
241
258
|
if (fullContext._schemaName) {
|
|
242
259
|
// Get the Schema instance and mark it as draft
|
|
243
|
-
const _mod_7 = await import('./Schema-
|
|
260
|
+
const _mod_7 = await import('./Schema-B-vCLIuU.js');
|
|
244
261
|
const _ns_7 = _mod_7.b;
|
|
245
262
|
const schemaMod = _ns_7;
|
|
246
263
|
const { Schema } = schemaMod;
|
|
@@ -259,7 +276,7 @@ const compareAndMarkDraft = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
259
276
|
logger$2(`Property ${fullContext.modelName}:${fullContext.name} has no changes`);
|
|
260
277
|
// Clear isEdited flag in database
|
|
261
278
|
try {
|
|
262
|
-
const _mod_8 = await import('./index-
|
|
279
|
+
const _mod_8 = await import('./index-CcXvJ2H7.js');
|
|
263
280
|
const _ns_8 = _mod_8.s;
|
|
264
281
|
const seedSchemaMod = _ns_8;
|
|
265
282
|
const { properties: propertiesTable, models: modelsTable } = seedSchemaMod;
|
|
@@ -325,7 +342,7 @@ const validateProperty = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
325
342
|
// Brief wait so trackPendingWrite from ModelProperty.create() has time to run (it's in setTimeout(0))
|
|
326
343
|
await new Promise((r) => setTimeout(r, 60));
|
|
327
344
|
try {
|
|
328
|
-
const _mod_9 = await import('./index-
|
|
345
|
+
const _mod_9 = await import('./index-B_apqB1Q.js');
|
|
329
346
|
const _ns_9 = _mod_9.aY;
|
|
330
347
|
const dbMod = _ns_9;
|
|
331
348
|
const { getPropertyModelNameAndDataType, getModelNameByModelId } = dbMod;
|
|
@@ -379,16 +396,21 @@ const validateProperty = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
379
396
|
fullContext = { ...fullContext, dataType: (fullContext.dataType ?? context._originalValues?.dataType) || 'Text' };
|
|
380
397
|
}
|
|
381
398
|
// Use dynamic imports to break circular dependencies
|
|
382
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
399
|
+
const validationServiceMod = await import('./SchemaValidationService-C_iTQIjR.js');
|
|
383
400
|
const { SchemaValidationService } = validationServiceMod;
|
|
384
401
|
const validationService = new SchemaValidationService();
|
|
385
|
-
const _mod_10 = await import('./Schema-
|
|
402
|
+
const _mod_10 = await import('./Schema-B-vCLIuU.js');
|
|
386
403
|
const _ns_10 = _mod_10.b;
|
|
387
404
|
const schemaMod = _ns_10;
|
|
388
405
|
const { Schema } = schemaMod;
|
|
389
406
|
// Validate property structure
|
|
390
407
|
const structureResult = validationService.validatePropertyStructure(fullContext);
|
|
391
408
|
if (!structureResult.isValid) {
|
|
409
|
+
// #region agent log
|
|
410
|
+
if (typeof fetch === 'function') {
|
|
411
|
+
fetch('http://127.0.0.1:7242/ingest/0978b378-ebae-46bf-8fd3-134ef2e16cdd', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '9ee076' }, body: JSON.stringify({ sessionId: '9ee076', location: 'validateProperty.ts:structureInvalid', message: 'validateProperty structure validation FAILED', data: { name: fullContext.name, errors: structureResult.errors?.map((e) => e.message || e.code) }, timestamp: Date.now(), hypothesisId: 'D' }) }).catch(() => { });
|
|
412
|
+
}
|
|
413
|
+
// #endregion
|
|
392
414
|
sendBack({ type: 'validationError', errors: structureResult.errors });
|
|
393
415
|
return;
|
|
394
416
|
}
|
|
@@ -428,6 +450,11 @@ const validateProperty = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
428
450
|
return true; // Critical error
|
|
429
451
|
});
|
|
430
452
|
if (criticalErrors.length > 0) {
|
|
453
|
+
// #region agent log
|
|
454
|
+
if (typeof fetch === 'function') {
|
|
455
|
+
fetch('http://127.0.0.1:7242/ingest/0978b378-ebae-46bf-8fd3-134ef2e16cdd', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '9ee076' }, body: JSON.stringify({ sessionId: '9ee076', location: 'validateProperty.ts:schemaCriticalErrors', message: 'validateProperty schema validation FAILED (critical)', data: { name: fullContext.name, isRenamed: !!(fullContext._originalValues?.name && fullContext._originalValues.name !== fullContext.name), criticalErrors: criticalErrors?.map((e) => e.message || e.code) }, timestamp: Date.now(), hypothesisId: 'D' }) }).catch(() => { });
|
|
456
|
+
}
|
|
457
|
+
// #endregion
|
|
431
458
|
sendBack({ type: 'validationError', errors: criticalErrors });
|
|
432
459
|
return;
|
|
433
460
|
}
|
|
@@ -512,6 +539,11 @@ const modelPropertyMachine = setup({
|
|
|
512
539
|
updateContext: {
|
|
513
540
|
actions: assign(({ context, event }) => {
|
|
514
541
|
const newContext = Object.assign({}, context);
|
|
542
|
+
// #region agent log
|
|
543
|
+
if (event.name !== undefined && event.name !== context.name) {
|
|
544
|
+
fetch('http://127.0.0.1:7242/ingest/0978b378-ebae-46bf-8fd3-134ef2e16cdd', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '9ee076' }, body: JSON.stringify({ sessionId: '9ee076', location: 'modelPropertyMachine.ts:updateContext', message: 'Name change via updateContext', data: { oldName: context.name, newName: event.name, id: context.id, _propertyFileId: context._propertyFileId, hasOriginalValues: !!context._originalValues }, timestamp: Date.now(), hypothesisId: 'A' }) }).catch(() => { });
|
|
545
|
+
}
|
|
546
|
+
// #endregion
|
|
515
547
|
// Check if this is only updating internal fields
|
|
516
548
|
const onlyInternalFields = Object.keys(event).every((key) => {
|
|
517
549
|
return key === 'type' || key.startsWith('_');
|
|
@@ -1138,6 +1170,41 @@ class ModelProperty {
|
|
|
1138
1170
|
// If we can't get schema name, that's okay - it will be set later if needed
|
|
1139
1171
|
}
|
|
1140
1172
|
}
|
|
1173
|
+
/**
|
|
1174
|
+
* Resolve schema name from DB when _schemaName is missing (e.g. destroy ran before _setSchemaName finished).
|
|
1175
|
+
* Uses context.id (schemaFileId) and context.modelId to query properties → model_schemas → schemas.
|
|
1176
|
+
*/
|
|
1177
|
+
async _resolveSchemaNameForDestroy(db, context) {
|
|
1178
|
+
try {
|
|
1179
|
+
let modelId = context.modelId;
|
|
1180
|
+
const schemaFileId = context.id ?? context._propertyFileId;
|
|
1181
|
+
// If we don't have modelId, get it from the property row by schemaFileId
|
|
1182
|
+
if (modelId == null && schemaFileId) {
|
|
1183
|
+
const propRows = await db
|
|
1184
|
+
.select({ modelId: properties.modelId })
|
|
1185
|
+
.from(properties)
|
|
1186
|
+
.where(eq(properties.schemaFileId, schemaFileId))
|
|
1187
|
+
.limit(1);
|
|
1188
|
+
if (propRows.length > 0 && propRows[0].modelId != null) {
|
|
1189
|
+
modelId = propRows[0].modelId;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
if (modelId == null)
|
|
1193
|
+
return undefined;
|
|
1194
|
+
// Resolve modelFileId (string) to database ID (number) if needed - modelSchemas.modelId expects number
|
|
1195
|
+
const modelIdNum = typeof modelId === 'string' ? await getModelIdByFileId(modelId) : modelId;
|
|
1196
|
+
const modelSchemaRecords = await db
|
|
1197
|
+
.select({ schemaName: schemas.name })
|
|
1198
|
+
.from(modelSchemas)
|
|
1199
|
+
.innerJoin(schemas, eq(modelSchemas.schemaId, schemas.id))
|
|
1200
|
+
.where(eq(modelSchemas.modelId, modelIdNum))
|
|
1201
|
+
.limit(1);
|
|
1202
|
+
return modelSchemaRecords.length > 0 ? modelSchemaRecords[0].schemaName ?? undefined : undefined;
|
|
1203
|
+
}
|
|
1204
|
+
catch {
|
|
1205
|
+
return undefined;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1141
1208
|
/**
|
|
1142
1209
|
* Manually set the schema name for this property
|
|
1143
1210
|
* Useful when you know the schema name from context (e.g., when working with Schema instances)
|
|
@@ -1425,6 +1492,11 @@ class ModelProperty {
|
|
|
1425
1492
|
const modelName = modelRecords[0].name;
|
|
1426
1493
|
// Build property data
|
|
1427
1494
|
// id is now the schemaFileId (string), _dbId is the database integer ID
|
|
1495
|
+
// #region agent log
|
|
1496
|
+
if (typeof fetch === 'function') {
|
|
1497
|
+
fetch('http://127.0.0.1:7242/ingest/0978b378-ebae-46bf-8fd3-134ef2e16cdd', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '9ee076' }, body: JSON.stringify({ sessionId: '9ee076', location: 'ModelProperty.ts:createById', message: 'createById loading from DB', data: { propertyFileId, name: propertyRecord.name, modelName }, timestamp: Date.now(), hypothesisId: 'E' }) }).catch(() => { });
|
|
1498
|
+
}
|
|
1499
|
+
// #endregion
|
|
1428
1500
|
const propertyData = {
|
|
1429
1501
|
id: propertyFileId, // schemaFileId (string) - public ID
|
|
1430
1502
|
_dbId: propertyRecord.id ?? undefined, // Database integer ID - internal only
|
|
@@ -1681,11 +1753,15 @@ class ModelProperty {
|
|
|
1681
1753
|
getService: (instance) => instance._service,
|
|
1682
1754
|
doDestroy: async () => {
|
|
1683
1755
|
const db = BaseDb.getAppDb();
|
|
1684
|
-
|
|
1756
|
+
let schemaName = context._schemaName;
|
|
1685
1757
|
const modelName = context.modelName;
|
|
1686
1758
|
const propertyName = context.name;
|
|
1687
1759
|
if (!modelName || !propertyName)
|
|
1688
1760
|
return;
|
|
1761
|
+
// Resolve schema name from DB when _schemaName is missing (e.g. destroy ran before _setSchemaName finished)
|
|
1762
|
+
if (!schemaName && db) {
|
|
1763
|
+
schemaName = await this._resolveSchemaNameForDestroy(db, context);
|
|
1764
|
+
}
|
|
1689
1765
|
if (db && schemaName) {
|
|
1690
1766
|
const propertyRecords = await db
|
|
1691
1767
|
.select({ propertyId: properties.id })
|
|
@@ -1728,4 +1804,4 @@ var ModelProperty$1 = /*#__PURE__*/Object.freeze({
|
|
|
1728
1804
|
});
|
|
1729
1805
|
|
|
1730
1806
|
export { ModelProperty };
|
|
1731
|
-
//# sourceMappingURL=ModelProperty-
|
|
1807
|
+
//# sourceMappingURL=ModelProperty-gBmew8gY.js.map
|