@seedprotocol/sdk 0.4.6 → 0.4.7
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-DLKAaS3K.js → ArweaveClient-BdQaTOZ4.js} +3 -3
- package/dist/ArweaveClient-BdQaTOZ4.js.map +1 -0
- package/dist/{ArweaveClient-Caio37h1.js → ArweaveClient-nrTU_rhU.js} +3 -3
- package/dist/ArweaveClient-nrTU_rhU.js.map +1 -0
- package/dist/{Db-DJAG-5Di.js → Db-CWKaeNQH.js} +3 -102
- package/dist/Db-CWKaeNQH.js.map +1 -0
- package/dist/{Db-C9fppVRl.js → Db-Cq4q88X_.js} +21 -5
- package/dist/Db-Cq4q88X_.js.map +1 -0
- package/dist/{EasClient-DQGAIj-b.js → EasClient-Du9_TULE.js} +2 -2
- package/dist/EasClient-Du9_TULE.js.map +1 -0
- package/dist/{EasClient-T7Nx9185.js → EasClient-ZCIE6UQq.js} +2 -2
- package/dist/EasClient-ZCIE6UQq.js.map +1 -0
- package/dist/{FileManager-BohtoKYo.js → FileManager-Cub9icdd.js} +2 -2
- package/dist/FileManager-Cub9icdd.js.map +1 -0
- package/dist/{FileManager-d64CkqXy.js → FileManager-HSFEess-.js} +2 -2
- package/dist/FileManager-HSFEess-.js.map +1 -0
- package/dist/Item/Item.d.ts +2 -0
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/service/actors/loadOrCreateItem.d.ts.map +1 -1
- package/dist/Item/service/itemMachineSingle.d.ts.map +1 -1
- package/dist/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +1 -1
- package/dist/Model/Model.d.ts +5 -0
- package/dist/Model/Model.d.ts.map +1 -1
- package/dist/{ModelProperty-Cpd9xiIM.js → ModelProperty-D4zaeIOT.js} +22 -22
- package/dist/ModelProperty-D4zaeIOT.js.map +1 -0
- package/dist/{PathResolver-D6M0rzKV.js → PathResolver-DVLBs_qi.js} +2 -2
- package/dist/PathResolver-DVLBs_qi.js.map +1 -0
- package/dist/{PathResolver-CLZUWoX2.js → PathResolver-T1yEDECb.js} +2 -2
- package/dist/PathResolver-T1yEDECb.js.map +1 -0
- package/dist/{QueryClient-COQ_Rs4-.js → QueryClient-DcKDQuwz.js} +2 -2
- package/dist/QueryClient-DcKDQuwz.js.map +1 -0
- package/dist/{QueryClient-BUoz2Vb0.js → QueryClient-Vs9KN5kS.js} +2 -2
- package/dist/QueryClient-Vs9KN5kS.js.map +1 -0
- package/dist/{Schema-BZKBy5Tx.js → Schema-SbwqmoMM.js} +36 -36
- package/dist/Schema-SbwqmoMM.js.map +1 -0
- package/dist/{SchemaValidationService-F8No7BHp.js → SchemaValidationService-DHGIw4Nx.js} +2 -2
- package/dist/SchemaValidationService-DHGIw4Nx.js.map +1 -0
- package/dist/browser/db/drizzleFiles.d.ts +3 -2
- package/dist/browser/db/drizzleFiles.d.ts.map +1 -1
- package/dist/browser/react/item.d.ts +2 -0
- package/dist/browser/react/item.d.ts.map +1 -1
- package/dist/cjs/{ModelProperty-B4pV91tc.js → ModelProperty-DpjD0o0E.js} +16 -16
- package/dist/cjs/{ModelProperty-B4pV91tc.js.map → ModelProperty-DpjD0o0E.js.map} +1 -1
- package/dist/cjs/{Schema-TErl3J36.js → Schema-DkSBMBwz.js} +21 -21
- package/dist/cjs/{Schema-TErl3J36.js.map → Schema-DkSBMBwz.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-p5BbJV9T.js → SchemaValidationService-O3FCMROl.js} +2 -2
- package/dist/cjs/{SchemaValidationService-p5BbJV9T.js.map → SchemaValidationService-O3FCMROl.js.map} +1 -1
- package/dist/cjs/{getItem-BrnLfC12.js → getItem-BeAVMk54.js} +2 -2
- package/dist/cjs/{getItem-BrnLfC12.js.map → getItem-BeAVMk54.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-BcjCN_bD.js → getPublishPayload-CoLriAMV.js} +5 -5
- package/dist/cjs/{getPublishPayload-BcjCN_bD.js.map → getPublishPayload-CoLriAMV.js.map} +1 -1
- package/dist/cjs/{getPublishUploads-5_oXzwol.js → getPublishUploads-DDsT9zZ6.js} +3 -3
- package/dist/cjs/{getPublishUploads-5_oXzwol.js.map → getPublishUploads-DDsT9zZ6.js.map} +1 -1
- package/dist/cjs/{getSegmentedItemProperties-WFdizUDv.js → getSegmentedItemProperties-DGR0utR5.js} +2 -2
- package/dist/cjs/{getSegmentedItemProperties-WFdizUDv.js.map → getSegmentedItemProperties-DGR0utR5.js.map} +1 -1
- package/dist/cjs/{index-CXI4VF1H.js → index-B95Ng80C.js} +326 -180
- package/dist/cjs/index-B95Ng80C.js.map +1 -0
- package/dist/cjs/{index-BrmvhXsG.js → index-CvcOtzbi.js} +2 -2
- package/dist/cjs/index-CvcOtzbi.js.map +1 -0
- package/dist/cjs/ownership-Dm5ER1nI.js +103 -0
- package/dist/cjs/ownership-Dm5ER1nI.js.map +1 -0
- package/dist/client/ClientManager.d.ts +54 -43
- package/dist/client/ClientManager.d.ts.map +1 -1
- package/dist/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/client/clientManagerMachine.d.ts.map +1 -1
- package/dist/db/drizzle/drizzle/0004_add_publisher_to_seeds.sql +1 -0
- package/dist/db/drizzle/drizzle/meta/0004_snapshot.json +857 -0
- package/dist/db/drizzle/drizzle/meta/_journal.json +7 -0
- package/dist/db/read/getItemData.d.ts.map +1 -1
- package/dist/db/read/getItems.d.ts +2 -0
- package/dist/db/read/getItems.d.ts.map +1 -1
- package/dist/db/write/createNewItem.d.ts.map +1 -1
- package/dist/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/{getItem-DaQVdeae.js → getItem-CqrJt-Ee.js} +2 -2
- package/dist/getItem-CqrJt-Ee.js.map +1 -0
- package/dist/{getPublishPayload-CWiLI1yd.js → getPublishPayload-BRgULCf3.js} +5 -5
- package/dist/getPublishPayload-BRgULCf3.js.map +1 -0
- package/dist/{getPublishUploads-DhvcKD_9.js → getPublishUploads-B0WArDfp.js} +3 -3
- package/dist/getPublishUploads-B0WArDfp.js.map +1 -0
- package/dist/{getSegmentedItemProperties-Cp4kcWIF.js → getSegmentedItemProperties-DZL9Ymd4.js} +2 -2
- package/dist/getSegmentedItemProperties-DZL9Ymd4.js.map +1 -0
- package/dist/helpers/addresses.d.ts +12 -0
- package/dist/helpers/addresses.d.ts.map +1 -0
- package/dist/helpers/db.d.ts +11 -0
- package/dist/helpers/db.d.ts.map +1 -1
- package/dist/helpers/ownership.d.ts +16 -0
- package/dist/helpers/ownership.d.ts.map +1 -0
- package/dist/{index-DBy53qbb.js → index-BIPPEMVY.js} +2 -2
- package/dist/index-BIPPEMVY.js.map +1 -0
- package/dist/{index-LfXKx_PE.js → index-BnF3MRZ8.js} +3 -3
- package/dist/index-BnF3MRZ8.js.map +1 -0
- package/dist/{index-Dk73a7JE.js → index-zsq08F5p.js} +342 -98
- package/dist/index-zsq08F5p.js.map +1 -0
- package/dist/main.cjs +1 -1
- package/dist/main.js +18 -15
- package/dist/main.js.map +1 -1
- package/dist/node/db/Db.d.ts.map +1 -1
- package/dist/node.js +10 -10
- package/dist/node.js.map +1 -1
- package/dist/ownership-CSsweVap.js +85 -0
- package/dist/ownership-CSsweVap.js.map +1 -0
- package/dist/{property-1o2MvYTm.js → property-Cqh_o0zx.js} +5 -5
- package/dist/property-Cqh_o0zx.js.map +1 -0
- package/dist/{queries-DA4G0iEN.js → queries-DSBgjcJJ.js} +2 -2
- package/dist/queries-DSBgjcJJ.js.map +1 -0
- package/dist/seedSchema/ModelSchemaSchema.d.ts +1 -1
- package/dist/seedSchema/ModelSchemaSchema.ts +4 -4
- package/dist/seedSchema/ModelUidSchema.ts +1 -1
- package/dist/seedSchema/PropertyUidSchema.ts +1 -1
- package/dist/seedSchema/SeedSchema.d.ts +19 -0
- package/dist/seedSchema/SeedSchema.d.ts.map +1 -1
- package/dist/seedSchema/SeedSchema.ts +1 -0
- package/dist/seedSchema/index.d.ts +10 -10
- package/dist/seedSchema/index.d.ts.map +1 -1
- package/dist/seedSchema/index.ts +10 -10
- package/dist/types/index.d.ts +11 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/item.d.ts +1 -0
- package/dist/types/item.d.ts.map +1 -1
- package/dist/types/machines.d.ts +2 -0
- package/dist/types/machines.d.ts.map +1 -1
- package/dist/vite.js.map +1 -1
- package/package.json +2 -9
- package/dist/ArweaveClient-Caio37h1.js.map +0 -1
- package/dist/ArweaveClient-DLKAaS3K.js.map +0 -1
- package/dist/Db-C9fppVRl.js.map +0 -1
- package/dist/Db-DJAG-5Di.js.map +0 -1
- package/dist/EasClient-DQGAIj-b.js.map +0 -1
- package/dist/EasClient-T7Nx9185.js.map +0 -1
- package/dist/FileManager-BohtoKYo.js.map +0 -1
- package/dist/FileManager-d64CkqXy.js.map +0 -1
- package/dist/ModelProperty-Cpd9xiIM.js.map +0 -1
- package/dist/PathResolver-CLZUWoX2.js.map +0 -1
- package/dist/PathResolver-D6M0rzKV.js.map +0 -1
- package/dist/QueryClient-BUoz2Vb0.js.map +0 -1
- package/dist/QueryClient-COQ_Rs4-.js.map +0 -1
- package/dist/Schema-BZKBy5Tx.js.map +0 -1
- package/dist/SchemaValidationService-F8No7BHp.js.map +0 -1
- package/dist/cjs/index-BrmvhXsG.js.map +0 -1
- package/dist/cjs/index-CXI4VF1H.js.map +0 -1
- package/dist/getItem-DaQVdeae.js.map +0 -1
- package/dist/getPublishPayload-CWiLI1yd.js.map +0 -1
- package/dist/getPublishUploads-DhvcKD_9.js.map +0 -1
- package/dist/getSegmentedItemProperties-Cp4kcWIF.js.map +0 -1
- package/dist/index-DBy53qbb.js.map +0 -1
- package/dist/index-Dk73a7JE.js.map +0 -1
- package/dist/index-LfXKx_PE.js.map +0 -1
- package/dist/property-1o2MvYTm.js.map +0 -1
- package/dist/queries-DA4G0iEN.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { waitFor, fromCallback, fromPromise, setup, assign, createActor } from 'xstate';
|
|
2
2
|
import { sqliteTable, integer, text, unique, int, blob } from 'drizzle-orm/sqlite-core';
|
|
3
|
-
import { relations, eq, and, isNull, isNotNull, not, or, max, count, getTableColumns, sql,
|
|
3
|
+
import { relations, eq, and, isNull, isNotNull, not, or, max, count, getTableColumns, sql, inArray, gt, desc } from 'drizzle-orm';
|
|
4
4
|
import { customAlphabet } from 'nanoid';
|
|
5
5
|
import * as nanoIdDictionary from 'nanoid-dictionary';
|
|
6
6
|
import debug from 'debug';
|
|
7
7
|
import pluralize from 'pluralize';
|
|
8
8
|
import { ZeroAddress } from 'ethers';
|
|
9
9
|
import { BehaviorSubject } from 'rxjs';
|
|
10
|
-
import { startCase, orderBy, throttle
|
|
10
|
+
import { startCase, upperFirst, camelCase, orderBy, throttle } from 'lodash-es';
|
|
11
11
|
import { toSnakeCase as toSnakeCase$1 } from 'drizzle-orm/casing';
|
|
12
12
|
import EventEmitter from 'eventemitter3';
|
|
13
13
|
import 'arweave';
|
|
@@ -607,7 +607,7 @@ const createPropertyInstances = async (propertyFileIds) => {
|
|
|
607
607
|
return;
|
|
608
608
|
}
|
|
609
609
|
try {
|
|
610
|
-
const mod = await import('./ModelProperty-
|
|
610
|
+
const mod = await import('./ModelProperty-D4zaeIOT.js');
|
|
611
611
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
612
612
|
if (!ModelProperty) {
|
|
613
613
|
logger$s('createPropertyInstances: ModelProperty not available from dynamic import');
|
|
@@ -796,7 +796,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
796
796
|
// Step 2: Fallback to Schema context (only if database doesn't have the model)
|
|
797
797
|
// This handles the case where model exists in schema file but not yet in database
|
|
798
798
|
try {
|
|
799
|
-
const _mod_0 = await import('./Schema-
|
|
799
|
+
const _mod_0 = await import('./Schema-SbwqmoMM.js');
|
|
800
800
|
const _ns_0 = _mod_0.b;
|
|
801
801
|
const schemaMod = _ns_0;
|
|
802
802
|
const { Schema } = schemaMod;
|
|
@@ -1042,7 +1042,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1042
1042
|
}
|
|
1043
1043
|
// Mark schema as draft when a new model is created so saveNewVersion() can persist it
|
|
1044
1044
|
try {
|
|
1045
|
-
const _mod_1 = await import('./Schema-
|
|
1045
|
+
const _mod_1 = await import('./Schema-SbwqmoMM.js');
|
|
1046
1046
|
const _ns_1 = _mod_1.b;
|
|
1047
1047
|
const schemaMod = _ns_1;
|
|
1048
1048
|
const { Schema } = schemaMod;
|
|
@@ -1088,10 +1088,10 @@ const validateModel = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1088
1088
|
const _validateModel = async () => {
|
|
1089
1089
|
try {
|
|
1090
1090
|
// Use dynamic imports to break circular dependencies
|
|
1091
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
1091
|
+
const validationServiceMod = await import('./SchemaValidationService-DHGIw4Nx.js');
|
|
1092
1092
|
const { SchemaValidationService } = validationServiceMod;
|
|
1093
1093
|
const validationService = new SchemaValidationService();
|
|
1094
|
-
const _mod_2 = await import('./Schema-
|
|
1094
|
+
const _mod_2 = await import('./Schema-SbwqmoMM.js');
|
|
1095
1095
|
const _ns_2 = _mod_2.b;
|
|
1096
1096
|
const schemaMod = _ns_2;
|
|
1097
1097
|
const { Schema } = schemaMod;
|
|
@@ -1205,7 +1205,7 @@ const createModelProperties = fromCallback(({ sendBack, input }) => {
|
|
|
1205
1205
|
return;
|
|
1206
1206
|
}
|
|
1207
1207
|
logger$q(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
|
|
1208
|
-
const mod = await import('./ModelProperty-
|
|
1208
|
+
const mod = await import('./ModelProperty-D4zaeIOT.js');
|
|
1209
1209
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
1210
1210
|
if (!ModelProperty) {
|
|
1211
1211
|
logger$q('ModelProperty not available from dynamic import');
|
|
@@ -1310,7 +1310,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
1310
1310
|
logger$p(structureMsg);
|
|
1311
1311
|
console.log(structureMsg); // Always log to console
|
|
1312
1312
|
// Use existing Model validation
|
|
1313
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
1313
|
+
const validationServiceMod = await import('./SchemaValidationService-DHGIw4Nx.js');
|
|
1314
1314
|
const { SchemaValidationService } = validationServiceMod;
|
|
1315
1315
|
const validationService = new SchemaValidationService();
|
|
1316
1316
|
// Validate model structure
|
|
@@ -1329,7 +1329,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
1329
1329
|
if (entityInput.entityData.schemaName) {
|
|
1330
1330
|
try {
|
|
1331
1331
|
logger$p(`[validateEntity] Validating model against schema "${entityInput.entityData.schemaName}"`);
|
|
1332
|
-
const _mod_3 = await import('./Schema-
|
|
1332
|
+
const _mod_3 = await import('./Schema-SbwqmoMM.js');
|
|
1333
1333
|
const _ns_3 = _mod_3.b;
|
|
1334
1334
|
const schemaMod = _ns_3;
|
|
1335
1335
|
const { Schema } = schemaMod;
|
|
@@ -1367,7 +1367,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
1367
1367
|
}
|
|
1368
1368
|
else if (entityInput.entityType === 'modelProperty') {
|
|
1369
1369
|
// Use existing ModelProperty validation
|
|
1370
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
1370
|
+
const validationServiceMod = await import('./SchemaValidationService-DHGIw4Nx.js');
|
|
1371
1371
|
const { SchemaValidationService } = validationServiceMod;
|
|
1372
1372
|
const validationService = new SchemaValidationService();
|
|
1373
1373
|
// Validate property structure
|
|
@@ -1382,7 +1382,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
1382
1382
|
// If schema name and model name provided, validate against schema
|
|
1383
1383
|
if (entityInput.entityData._schemaName && entityInput.entityData.modelName) {
|
|
1384
1384
|
try {
|
|
1385
|
-
const _mod_4 = await import('./Schema-
|
|
1385
|
+
const _mod_4 = await import('./Schema-SbwqmoMM.js');
|
|
1386
1386
|
const _ns_4 = _mod_4.b;
|
|
1387
1387
|
const schemaMod = _ns_4;
|
|
1388
1388
|
const { Schema } = schemaMod;
|
|
@@ -1413,7 +1413,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
1413
1413
|
}
|
|
1414
1414
|
else if (entityInput.entityType === 'schema') {
|
|
1415
1415
|
// Schema validation - use existing validation
|
|
1416
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
1416
|
+
const validationServiceMod = await import('./SchemaValidationService-DHGIw4Nx.js');
|
|
1417
1417
|
const { SchemaValidationService } = validationServiceMod;
|
|
1418
1418
|
const validationService = new SchemaValidationService();
|
|
1419
1419
|
const schemaResult = validationService.validateSchema(entityInput.entityData);
|
|
@@ -1450,6 +1450,7 @@ const seeds = sqliteTable('seeds', {
|
|
|
1450
1450
|
uid: text('uid'),
|
|
1451
1451
|
schemaUid: text('schema_uid'),
|
|
1452
1452
|
type: text('type'),
|
|
1453
|
+
publisher: text('publisher'),
|
|
1453
1454
|
attestationRaw: text('attestation_raw'),
|
|
1454
1455
|
attestationCreatedAt: int('attestation_created_at'),
|
|
1455
1456
|
createdAt: int('created_at'),
|
|
@@ -1944,7 +1945,7 @@ async function checkIfPropertyIsEdited(modelName, propertyName, schemaFileValue)
|
|
|
1944
1945
|
const cacheKey = `${modelName}:${propertyName}`;
|
|
1945
1946
|
// First, check the in-memory cache (for current session edits)
|
|
1946
1947
|
// Robust dynamic import for consumer re-bundling (named or default export)
|
|
1947
|
-
const mod = await import('./ModelProperty-
|
|
1948
|
+
const mod = await import('./ModelProperty-D4zaeIOT.js');
|
|
1948
1949
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
1949
1950
|
if (!ModelProperty) {
|
|
1950
1951
|
logger$o('ModelProperty not available from dynamic import');
|
|
@@ -2624,13 +2625,49 @@ const savePropertyToDb = async (property) => {
|
|
|
2624
2625
|
logger$o(`Created property ${property.modelName}:${property.name} in database`);
|
|
2625
2626
|
}
|
|
2626
2627
|
};
|
|
2627
|
-
|
|
2628
|
+
function parseAddressConfig(value) {
|
|
2629
|
+
if (!value)
|
|
2630
|
+
return null;
|
|
2631
|
+
try {
|
|
2632
|
+
const parsed = JSON.parse(value);
|
|
2633
|
+
if (Array.isArray(parsed)) {
|
|
2634
|
+
return { owned: parsed, watched: [] };
|
|
2635
|
+
}
|
|
2636
|
+
if (parsed && typeof parsed === 'object' && Array.isArray(parsed.owned)) {
|
|
2637
|
+
return {
|
|
2638
|
+
owned: parsed.owned,
|
|
2639
|
+
watched: Array.isArray(parsed.watched) ? parsed.watched : [],
|
|
2640
|
+
};
|
|
2641
|
+
}
|
|
2642
|
+
return null;
|
|
2643
|
+
}
|
|
2644
|
+
catch {
|
|
2645
|
+
return null;
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
const getOwnedAddressesFromDb = async () => {
|
|
2649
|
+
const config = await getAddressConfigFromDb();
|
|
2650
|
+
return config?.owned ?? [];
|
|
2651
|
+
};
|
|
2652
|
+
const getWatchedAddressesFromDb = async () => {
|
|
2653
|
+
const config = await getAddressConfigFromDb();
|
|
2654
|
+
return config?.watched ?? [];
|
|
2655
|
+
};
|
|
2656
|
+
/**
|
|
2657
|
+
* Returns owned + watched addresses. Use for EAS sync and file download.
|
|
2658
|
+
*/
|
|
2659
|
+
const getAllAddressesFromDb = async () => {
|
|
2660
|
+
const config = await getAddressConfigFromDb();
|
|
2661
|
+
if (!config)
|
|
2662
|
+
return [];
|
|
2663
|
+
return [...config.owned, ...config.watched];
|
|
2664
|
+
};
|
|
2665
|
+
async function getAddressConfigFromDb() {
|
|
2628
2666
|
const appDb = BaseDb.getAppDb();
|
|
2629
2667
|
if (!appDb) {
|
|
2630
2668
|
return new Promise((resolve) => {
|
|
2631
2669
|
setTimeout(async () => {
|
|
2632
|
-
|
|
2633
|
-
resolve(addresses);
|
|
2670
|
+
resolve(await getAddressConfigFromDb());
|
|
2634
2671
|
}, 500);
|
|
2635
2672
|
});
|
|
2636
2673
|
}
|
|
@@ -2640,14 +2677,25 @@ const getAddressesFromDb = async () => {
|
|
|
2640
2677
|
.where(eq(appState.key, 'addresses'))
|
|
2641
2678
|
.limit(1);
|
|
2642
2679
|
if (!appStatesRecords || appStatesRecords.length === 0) {
|
|
2643
|
-
|
|
2680
|
+
return null;
|
|
2644
2681
|
}
|
|
2645
|
-
const
|
|
2646
|
-
|
|
2647
|
-
|
|
2682
|
+
const addressArrayString = appStatesRecords[0].value;
|
|
2683
|
+
return parseAddressConfig(addressArrayString);
|
|
2684
|
+
}
|
|
2685
|
+
const getAddressesFromDb = async () => {
|
|
2686
|
+
const config = await getAddressConfigFromDb();
|
|
2687
|
+
if (!config || config.owned.length === 0) {
|
|
2648
2688
|
throw new Error('No addresses found');
|
|
2649
2689
|
}
|
|
2650
|
-
return
|
|
2690
|
+
return config.owned;
|
|
2691
|
+
};
|
|
2692
|
+
/**
|
|
2693
|
+
* Like getAddressesFromDb but returns [] instead of throwing when no addresses are configured.
|
|
2694
|
+
* Returns owned addresses. Use getAllAddressesFromDb for sync (owned + watched).
|
|
2695
|
+
*/
|
|
2696
|
+
const getAddressesFromDbOptional = async () => {
|
|
2697
|
+
const config = await getAddressConfigFromDb();
|
|
2698
|
+
return config?.owned ?? [];
|
|
2651
2699
|
};
|
|
2652
2700
|
/**
|
|
2653
2701
|
* Write model to database and create model_schemas join entry
|
|
@@ -3109,14 +3157,18 @@ var db = /*#__PURE__*/Object.freeze({
|
|
|
3109
3157
|
createOrUpdate: createOrUpdate,
|
|
3110
3158
|
escapeSqliteString: escapeSqliteString,
|
|
3111
3159
|
getAddressesFromDb: getAddressesFromDb,
|
|
3160
|
+
getAddressesFromDbOptional: getAddressesFromDbOptional,
|
|
3161
|
+
getAllAddressesFromDb: getAllAddressesFromDb,
|
|
3112
3162
|
getModelId: getModelId,
|
|
3113
3163
|
getModelIdByFileId: getModelIdByFileId,
|
|
3114
3164
|
getModelNameByModelId: getModelNameByModelId,
|
|
3115
3165
|
getObjectForRow: getObjectForRow,
|
|
3166
|
+
getOwnedAddressesFromDb: getOwnedAddressesFromDb,
|
|
3116
3167
|
getPropertyModelNameAndDataType: getPropertyModelNameAndDataType,
|
|
3117
3168
|
getSchemaId: getSchemaId,
|
|
3118
3169
|
getSchemaIdByFileId: getSchemaIdByFileId,
|
|
3119
3170
|
getSqlResultObject: getSqlResultObject,
|
|
3171
|
+
getWatchedAddressesFromDb: getWatchedAddressesFromDb,
|
|
3120
3172
|
loadModelsFromDbForSchema: loadModelsFromDbForSchema,
|
|
3121
3173
|
renameModelInDb: renameModelInDb,
|
|
3122
3174
|
savePropertyToDb: savePropertyToDb,
|
|
@@ -3170,7 +3222,7 @@ const writeToDatabase = fromCallback(({ sendBack, input }) => {
|
|
|
3170
3222
|
// initial write completes is not overwritten by the stale requestWrite payload.
|
|
3171
3223
|
let dataToWrite = input.entityData;
|
|
3172
3224
|
try {
|
|
3173
|
-
const mod = await import('./ModelProperty-
|
|
3225
|
+
const mod = await import('./ModelProperty-D4zaeIOT.js');
|
|
3174
3226
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
3175
3227
|
if (ModelProperty && typeof ModelProperty.getById === 'function') {
|
|
3176
3228
|
const instance = ModelProperty.getById(input.entityId);
|
|
@@ -3561,7 +3613,7 @@ const modelMachine = setup({
|
|
|
3561
3613
|
// Create ModelProperty instances for any new property IDs
|
|
3562
3614
|
if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
|
|
3563
3615
|
// Import and create instances asynchronously (fire-and-forget)
|
|
3564
|
-
import('./ModelProperty-
|
|
3616
|
+
import('./ModelProperty-D4zaeIOT.js').then(({ ModelProperty }) => {
|
|
3565
3617
|
const createPromises = newPropertyIds.map(async (propertyFileId) => {
|
|
3566
3618
|
try {
|
|
3567
3619
|
const property = await ModelProperty.createById(propertyFileId);
|
|
@@ -4527,13 +4579,15 @@ var versionData = /*#__PURE__*/Object.freeze({
|
|
|
4527
4579
|
|
|
4528
4580
|
const logger$k = debug('seedSdk:item:actors:loadOrCreateItem');
|
|
4529
4581
|
/**
|
|
4530
|
-
* Create ItemProperty instances for all metadata records to ensure they're cached
|
|
4582
|
+
* Create ItemProperty instances for all metadata records to ensure they're cached.
|
|
4583
|
+
* Passes propertyRecordSchema from Model when available (Fix 3: enables value persistence for runtime-created models).
|
|
4531
4584
|
* @param metadataRows - Array of metadata records to create ItemProperty instances for
|
|
4532
4585
|
* @param seedLocalId - Seed local ID
|
|
4533
4586
|
* @param seedUid - Seed UID
|
|
4587
|
+
* @param modelName - Model name for resolving propertyRecordSchema from Model
|
|
4534
4588
|
* @returns Map of propertyName -> ItemProperty instance
|
|
4535
4589
|
*/
|
|
4536
|
-
const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid) => {
|
|
4590
|
+
const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, modelName) => {
|
|
4537
4591
|
const propertyInstances = new Map();
|
|
4538
4592
|
if (metadataRows.length === 0) {
|
|
4539
4593
|
return propertyInstances;
|
|
@@ -4541,20 +4595,40 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid) =
|
|
|
4541
4595
|
try {
|
|
4542
4596
|
const itemPropertyMod = await Promise.resolve().then(function () { return ItemProperty$1; });
|
|
4543
4597
|
const { ItemProperty } = itemPropertyMod;
|
|
4544
|
-
|
|
4598
|
+
const { modelPropertiesToObject } = await Promise.resolve().then(function () { return model; });
|
|
4599
|
+
const { Model } = await Promise.resolve().then(function () { return Model$1; });
|
|
4600
|
+
// Resolve Model and build property schemas for propertyRecordSchema (Fix 3)
|
|
4601
|
+
let propertySchemas = {};
|
|
4602
|
+
const model$1 = Model.getByName(modelName);
|
|
4603
|
+
if (model$1?.properties?.length) {
|
|
4604
|
+
propertySchemas = modelPropertiesToObject(model$1.properties);
|
|
4605
|
+
}
|
|
4606
|
+
// Create instances for all metadata records in parallel with propertyRecordSchema
|
|
4545
4607
|
const createPromises = metadataRows.map(async (metaRow) => {
|
|
4546
4608
|
try {
|
|
4547
|
-
const
|
|
4548
|
-
|
|
4609
|
+
const propertyName = metaRow.propertyName;
|
|
4610
|
+
if (!propertyName) {
|
|
4611
|
+
logger$k(`Metadata row missing propertyName, skipping`);
|
|
4612
|
+
return;
|
|
4613
|
+
}
|
|
4614
|
+
const createProps = {
|
|
4615
|
+
propertyName,
|
|
4549
4616
|
seedLocalId,
|
|
4550
4617
|
seedUid,
|
|
4551
|
-
|
|
4618
|
+
modelName,
|
|
4619
|
+
propertyValue: metaRow.propertyValue ?? undefined,
|
|
4620
|
+
versionLocalId: metaRow.versionLocalId ?? undefined,
|
|
4621
|
+
versionUid: metaRow.versionUid ?? undefined,
|
|
4622
|
+
schemaUid: metaRow.schemaUid ?? undefined,
|
|
4623
|
+
propertyRecordSchema: propertySchemas[propertyName] ?? undefined,
|
|
4624
|
+
};
|
|
4625
|
+
const property = ItemProperty.create(createProps, { waitForReady: false });
|
|
4552
4626
|
if (property) {
|
|
4553
|
-
propertyInstances.set(
|
|
4554
|
-
logger$k(`Created/cached ItemProperty instance for propertyName "${
|
|
4627
|
+
propertyInstances.set(propertyName, property);
|
|
4628
|
+
logger$k(`Created/cached ItemProperty instance for propertyName "${propertyName}" with propertyRecordSchema: ${!!createProps.propertyRecordSchema}`);
|
|
4555
4629
|
}
|
|
4556
4630
|
else {
|
|
4557
|
-
logger$k(`ItemProperty.
|
|
4631
|
+
logger$k(`ItemProperty.create returned undefined for propertyName "${propertyName}"`);
|
|
4558
4632
|
}
|
|
4559
4633
|
}
|
|
4560
4634
|
catch (error) {
|
|
@@ -4574,7 +4648,6 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid) =
|
|
|
4574
4648
|
const loadOrCreateItem = fromCallback(({ sendBack, input: { context } }) => {
|
|
4575
4649
|
const _loadOrCreateItem = async () => {
|
|
4576
4650
|
const { seedLocalId, seedUid, modelName } = context;
|
|
4577
|
-
console.log(`[loadOrCreateItem] Called for modelName: ${modelName}, seedLocalId: ${seedLocalId}, seedUid: ${seedUid}`);
|
|
4578
4651
|
logger$k(`loadOrCreateItem called for modelName: ${modelName}, seedLocalId: ${seedLocalId}, seedUid: ${seedUid}`);
|
|
4579
4652
|
if (!seedLocalId && !seedUid) {
|
|
4580
4653
|
throw new Error('seedLocalId or seedUid is required');
|
|
@@ -4686,16 +4759,11 @@ const loadOrCreateItem = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4686
4759
|
.from(metadata$1)
|
|
4687
4760
|
.where(and(eq(metadata$1.seedLocalId, resolvedSeedLocalId), eq(metadata$1.versionLocalId, latestVersionLocalId)));
|
|
4688
4761
|
logger$k(`Found ${metadataRecords.length} metadata records for version ${latestVersionLocalId}`);
|
|
4689
|
-
console.log(`[loadOrCreateItem] Found ${metadataRecords.length} metadata records for version ${latestVersionLocalId}`);
|
|
4690
|
-
if (metadataRecords.length > 0) {
|
|
4691
|
-
console.log(`[loadOrCreateItem] Metadata property names:`, metadataRecords.map((r) => r.propertyName));
|
|
4692
|
-
}
|
|
4693
4762
|
// Step 4: Create ItemProperty instances from metadata records
|
|
4694
4763
|
// This ensures they're in the cache when Item.properties getter is called
|
|
4695
4764
|
const propertyInstances = metadataRecords.length > 0
|
|
4696
|
-
? await createItemPropertyInstances(metadataRecords, resolvedSeedLocalId, resolvedSeedUid)
|
|
4765
|
+
? await createItemPropertyInstances(metadataRecords, resolvedSeedLocalId, resolvedSeedUid, modelName)
|
|
4697
4766
|
: new Map();
|
|
4698
|
-
console.log(`[loadOrCreateItem] Created ${propertyInstances.size} property instances:`, Array.from(propertyInstances.keys()));
|
|
4699
4767
|
// Step 5: Return loaded item data with property instances
|
|
4700
4768
|
sendBack({
|
|
4701
4769
|
type: 'loadOrCreateItemSuccess',
|
|
@@ -4740,9 +4808,9 @@ const runPublish = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4740
4808
|
sendBack({ type: 'publishError', error: new Error(`Item not found for seedLocalId: ${seedLocalId}`) });
|
|
4741
4809
|
return;
|
|
4742
4810
|
}
|
|
4743
|
-
const getPublishUploadsMod = await import('./getPublishUploads-
|
|
4811
|
+
const getPublishUploadsMod = await import('./getPublishUploads-B0WArDfp.js');
|
|
4744
4812
|
const { getPublishUploads } = getPublishUploadsMod;
|
|
4745
|
-
const getPublishPayloadMod = await import('./getPublishPayload-
|
|
4813
|
+
const getPublishPayloadMod = await import('./getPublishPayload-BRgULCf3.js');
|
|
4746
4814
|
const { getPublishPayload } = getPublishPayloadMod;
|
|
4747
4815
|
await getPublishUploads(item);
|
|
4748
4816
|
// For first iteration: no Arweave sign/upload - pass empty uploadedTransactions.
|
|
@@ -4915,14 +4983,18 @@ const itemMachineSingle = setup({
|
|
|
4915
4983
|
actions: assign(({ context, event }) => {
|
|
4916
4984
|
const item = event.item;
|
|
4917
4985
|
const existingPropertyInstances = context.propertyInstances || new Map();
|
|
4918
|
-
|
|
4919
|
-
// Merge property instances from loadOrCreateItem
|
|
4986
|
+
// Merge property instances from loadOrCreateItem (Fix 2: preserve existing when it has propertyRecordSchema and incoming doesn't)
|
|
4920
4987
|
if (item.propertyInstances) {
|
|
4921
4988
|
for (const [propertyName, propertyInstance] of item.propertyInstances) {
|
|
4989
|
+
const existing = existingPropertyInstances.get(propertyName);
|
|
4990
|
+
const existingHasSchema = existing?.propertyDef;
|
|
4991
|
+
const incomingHasSchema = propertyInstance?.propertyDef;
|
|
4992
|
+
if (existingHasSchema && !incomingHasSchema) {
|
|
4993
|
+
continue; // Preserve existing instance with schema
|
|
4994
|
+
}
|
|
4922
4995
|
existingPropertyInstances.set(propertyName, propertyInstance);
|
|
4923
4996
|
}
|
|
4924
4997
|
}
|
|
4925
|
-
console.log(`[itemMachine] After merge, total propertyInstances:`, Array.from(existingPropertyInstances.keys()));
|
|
4926
4998
|
return {
|
|
4927
4999
|
...context,
|
|
4928
5000
|
seedLocalId: item.seedLocalId || context.seedLocalId,
|
|
@@ -5278,6 +5350,26 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
|
5278
5350
|
}
|
|
5279
5351
|
const seedRow = seedRows[0];
|
|
5280
5352
|
const resolvedSeedLocalId = seedRow.seedLocalId;
|
|
5353
|
+
// Fix 5: Derive schemaName for multi-schema Model resolution (models -> model_schemas -> schemas)
|
|
5354
|
+
let schemaName;
|
|
5355
|
+
const normalizedModelName = modelName ? startCase(modelName) : (seedRow.type ? startCase(seedRow.type) : undefined);
|
|
5356
|
+
if (appDb && normalizedModelName) {
|
|
5357
|
+
try {
|
|
5358
|
+
const schemaRows = await appDb
|
|
5359
|
+
.select({ schemaName: schemas.name })
|
|
5360
|
+
.from(models$1)
|
|
5361
|
+
.innerJoin(modelSchemas, eq(models$1.id, modelSchemas.modelId))
|
|
5362
|
+
.innerJoin(schemas, eq(modelSchemas.schemaId, schemas.id))
|
|
5363
|
+
.where(eq(models$1.name, normalizedModelName))
|
|
5364
|
+
.limit(1);
|
|
5365
|
+
if (schemaRows.length > 0 && schemaRows[0].schemaName) {
|
|
5366
|
+
schemaName = schemaRows[0].schemaName;
|
|
5367
|
+
}
|
|
5368
|
+
}
|
|
5369
|
+
catch (error) {
|
|
5370
|
+
logger$i('[getItemData] Error deriving schemaName:', error);
|
|
5371
|
+
}
|
|
5372
|
+
}
|
|
5281
5373
|
// Now get version data if it exists - query versions table directly
|
|
5282
5374
|
let versionRow = {
|
|
5283
5375
|
versionsCount: 0,
|
|
@@ -5308,6 +5400,7 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
|
5308
5400
|
let itemData = {
|
|
5309
5401
|
...seedRow,
|
|
5310
5402
|
...versionRow,
|
|
5403
|
+
schemaName,
|
|
5311
5404
|
};
|
|
5312
5405
|
const propertiesData = await getItemProperties({
|
|
5313
5406
|
seedLocalId,
|
|
@@ -5331,12 +5424,28 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
|
5331
5424
|
return itemData;
|
|
5332
5425
|
};
|
|
5333
5426
|
|
|
5334
|
-
const getItemsData = async ({ modelName, deleted, }) => {
|
|
5427
|
+
const getItemsData = async ({ modelName, deleted, includeEas = false, addressFilter, }) => {
|
|
5335
5428
|
const appDb = BaseDb.getAppDb();
|
|
5336
5429
|
const conditions = [];
|
|
5430
|
+
if (!includeEas) {
|
|
5431
|
+
conditions.push(or(isNull(seeds.uid), eq(seeds.uid, '')));
|
|
5432
|
+
}
|
|
5337
5433
|
if (modelName) {
|
|
5338
5434
|
conditions.push(eq(seeds.type, toSnakeCase$1(modelName)));
|
|
5339
5435
|
}
|
|
5436
|
+
if (addressFilter === 'owned') {
|
|
5437
|
+
const ownedAddresses = await getOwnedAddressesFromDb();
|
|
5438
|
+
if (ownedAddresses.length > 0) {
|
|
5439
|
+
conditions.push(or(inArray(seeds.publisher, ownedAddresses), isNull(seeds.publisher)));
|
|
5440
|
+
}
|
|
5441
|
+
}
|
|
5442
|
+
else if (addressFilter === 'watched') {
|
|
5443
|
+
const watchedAddresses = await getWatchedAddressesFromDb();
|
|
5444
|
+
if (watchedAddresses.length === 0) {
|
|
5445
|
+
return [];
|
|
5446
|
+
}
|
|
5447
|
+
conditions.push(inArray(seeds.publisher, watchedAddresses));
|
|
5448
|
+
}
|
|
5340
5449
|
if (deleted) {
|
|
5341
5450
|
conditions.push(or(isNotNull(seeds._markedForDeletion), eq(seeds._markedForDeletion, 1)));
|
|
5342
5451
|
}
|
|
@@ -5828,7 +5937,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5828
5937
|
const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
|
|
5829
5938
|
const _resolveRelatedValue = async () => {
|
|
5830
5939
|
// Use dynamic import to break circular dependency
|
|
5831
|
-
const schemaMod = await import('./index-
|
|
5940
|
+
const schemaMod = await import('./index-BnF3MRZ8.js');
|
|
5832
5941
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
5833
5942
|
if (!propertyValue || !isRelation || populatedFromDb) {
|
|
5834
5943
|
return;
|
|
@@ -6167,7 +6276,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
6167
6276
|
// to use dynamically imported ModelPropertyDataTypes
|
|
6168
6277
|
const _hydrateFromDb = async () => {
|
|
6169
6278
|
// Use dynamic import to break circular dependency
|
|
6170
|
-
const schemaMod = await import('./index-
|
|
6279
|
+
const schemaMod = await import('./index-BnF3MRZ8.js');
|
|
6171
6280
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
6172
6281
|
const appDb = BaseDb.getAppDb();
|
|
6173
6282
|
const whereClauses = [];
|
|
@@ -6398,8 +6507,8 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
6398
6507
|
const modelName = metadataRecord.modelType || context.modelName;
|
|
6399
6508
|
if (modelName) {
|
|
6400
6509
|
try {
|
|
6401
|
-
// Normalize to PascalCase
|
|
6402
|
-
const normalizedModelName =
|
|
6510
|
+
// Normalize snake_case to PascalCase: "test_post" -> "TestPost" (startCase gives "Test Post" which fails)
|
|
6511
|
+
const normalizedModelName = upperFirst(camelCase(modelName));
|
|
6403
6512
|
// Query properties table to get property schema
|
|
6404
6513
|
const modelRecords = await db
|
|
6405
6514
|
.select({ id: models$1.id })
|
|
@@ -6430,6 +6539,28 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
6430
6539
|
// Continue without propertyRecordSchema
|
|
6431
6540
|
}
|
|
6432
6541
|
}
|
|
6542
|
+
if (!propertyRecordSchema && modelName) {
|
|
6543
|
+
try {
|
|
6544
|
+
const { Model } = await Promise.resolve().then(function () { return Model$1; });
|
|
6545
|
+
const { modelPropertiesToObject } = await Promise.resolve().then(function () { return model; });
|
|
6546
|
+
const normalizedModelName = upperFirst(camelCase(modelName));
|
|
6547
|
+
// Try PascalCase first ("post" -> "Post"); then findByModelType for names with spaces ("new_model" -> "New model")
|
|
6548
|
+
let model$1 = Model.getByName(normalizedModelName);
|
|
6549
|
+
if (!model$1?.properties?.length) {
|
|
6550
|
+
model$1 = Model.findByModelType(toSnakeCase$1(modelName));
|
|
6551
|
+
}
|
|
6552
|
+
if (model$1?.properties?.length) {
|
|
6553
|
+
const schemas = modelPropertiesToObject(model$1.properties);
|
|
6554
|
+
propertyRecordSchema = schemas[propertyName];
|
|
6555
|
+
if (propertyRecordSchema) {
|
|
6556
|
+
logger$f(`Fallback: loaded propertyRecordSchema from Model for propertyName "${propertyName}"`);
|
|
6557
|
+
}
|
|
6558
|
+
}
|
|
6559
|
+
}
|
|
6560
|
+
catch (error) {
|
|
6561
|
+
logger$f(`Fallback Model lookup failed for propertyName "${propertyName}": ${error}`);
|
|
6562
|
+
}
|
|
6563
|
+
}
|
|
6433
6564
|
// Return loaded property data
|
|
6434
6565
|
sendBack({
|
|
6435
6566
|
type: 'loadOrCreatePropertySuccess',
|
|
@@ -6641,7 +6772,7 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
6641
6772
|
}
|
|
6642
6773
|
const _analyzeInput = async () => {
|
|
6643
6774
|
// Use dynamic import to break circular dependency
|
|
6644
|
-
const schemaMod = await import('./index-
|
|
6775
|
+
const schemaMod = await import('./index-BnF3MRZ8.js');
|
|
6645
6776
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
6646
6777
|
let propertyName = propertyNameRaw;
|
|
6647
6778
|
if (!propertyName) {
|
|
@@ -6999,7 +7130,7 @@ const saveRelation = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
6999
7130
|
}
|
|
7000
7131
|
const _saveRelation = async () => {
|
|
7001
7132
|
// Use dynamic import to break circular dependency
|
|
7002
|
-
const schemaMod = await import('./index-
|
|
7133
|
+
const schemaMod = await import('./index-BnF3MRZ8.js');
|
|
7003
7134
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
7004
7135
|
if (!propertyNameRaw) {
|
|
7005
7136
|
throw new Error('propertyName is required');
|
|
@@ -7702,6 +7833,32 @@ Promise.resolve().then(function () { return Model$1; }).then(module => {
|
|
|
7702
7833
|
// Return a default module structure to maintain type consistency
|
|
7703
7834
|
return {};
|
|
7704
7835
|
});
|
|
7836
|
+
/**
|
|
7837
|
+
* Resolve propertyRecordSchema from in-memory Model (Fix 6: enables value persistence when useItemProperty path doesn't go through loadOrCreateItem).
|
|
7838
|
+
* Tries getByName(pascalCase) first; if that fails (e.g. "New model" vs "NewModel"), falls back to findByModelType(modelType).
|
|
7839
|
+
*/
|
|
7840
|
+
const resolvePropertyRecordSchemaFromModel = async (modelName, propertyName, modelType) => {
|
|
7841
|
+
if (!modelName && !modelType)
|
|
7842
|
+
return undefined;
|
|
7843
|
+
try {
|
|
7844
|
+
const { Model } = await Promise.resolve().then(function () { return Model$1; });
|
|
7845
|
+
const { modelPropertiesToObject } = await Promise.resolve().then(function () { return model; });
|
|
7846
|
+
let model$1 = modelName ? Model.getByName(modelName) : undefined;
|
|
7847
|
+
if (!model$1?.properties?.length && modelType) {
|
|
7848
|
+
model$1 = Model.findByModelType(modelType);
|
|
7849
|
+
}
|
|
7850
|
+
if (!model$1?.properties?.length)
|
|
7851
|
+
return undefined;
|
|
7852
|
+
const schemas = modelPropertiesToObject(model$1.properties);
|
|
7853
|
+
const schema = schemas[propertyName];
|
|
7854
|
+
return schema;
|
|
7855
|
+
}
|
|
7856
|
+
catch {
|
|
7857
|
+
return undefined;
|
|
7858
|
+
}
|
|
7859
|
+
};
|
|
7860
|
+
/** Convert modelType (snake_case from DB) to Model name (PascalCase). startCase adds spaces ("Test Post"); Model names are "TestPost". */
|
|
7861
|
+
const modelTypeToModelName = (modelType) => modelType ? upperFirst(camelCase(modelType)) : '';
|
|
7705
7862
|
const logger$d = debug('seedSdk:property:class');
|
|
7706
7863
|
// Define tracked properties for the Proxy
|
|
7707
7864
|
// These properties will be read from/written to the actor context
|
|
@@ -7798,7 +7955,7 @@ class ItemProperty {
|
|
|
7798
7955
|
return;
|
|
7799
7956
|
}
|
|
7800
7957
|
// Use dynamic import to break circular dependency
|
|
7801
|
-
const schemaMod = await import('./index-
|
|
7958
|
+
const schemaMod = await import('./index-BnF3MRZ8.js');
|
|
7802
7959
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
7803
7960
|
const { context } = snapshot;
|
|
7804
7961
|
const { propertyRecordSchema } = context;
|
|
@@ -7912,7 +8069,7 @@ class ItemProperty {
|
|
|
7912
8069
|
setupState.subscriptionSetUp = true;
|
|
7913
8070
|
logger(`[ItemProperty._setupLiveQuerySubscription] Setting up liveQuery for propertyName: ${propertyName}, seedLocalId: ${seedLocalId}`);
|
|
7914
8071
|
try {
|
|
7915
|
-
const _mod_5 = await import('./index-
|
|
8072
|
+
const _mod_5 = await import('./index-BIPPEMVY.js');
|
|
7916
8073
|
const _ns_5 = _mod_5.s;
|
|
7917
8074
|
const seedSchemaMod = _ns_5;
|
|
7918
8075
|
const { metadata } = seedSchemaMod;
|
|
@@ -8189,10 +8346,14 @@ class ItemProperty {
|
|
|
8189
8346
|
return undefined;
|
|
8190
8347
|
}
|
|
8191
8348
|
// Ensure modelName for constructor: metadata may have modelType only, or neither (e.g. when Item passes it)
|
|
8349
|
+
// Use modelTypeToModelName: modelType is snake_case ("test_post"); Model names are PascalCase ("TestPost")
|
|
8192
8350
|
const data = propertyData;
|
|
8193
8351
|
const modelName = data.modelName ??
|
|
8194
|
-
((data.modelType ?
|
|
8195
|
-
|
|
8352
|
+
((data.modelType ? modelTypeToModelName(data.modelType) : '') || modelNameOption || '');
|
|
8353
|
+
// Fix 6: resolve propertyRecordSchema from Model so value setter can persist (useItemProperty path)
|
|
8354
|
+
// Pass modelType for fallback: "New model" -> "new_model" can't be reversed to exact name; findByModelType handles it
|
|
8355
|
+
const propertyRecordSchema = await resolvePropertyRecordSchemaFromModel(modelName, propertyName, data.modelType);
|
|
8356
|
+
foundProperty = ItemProperty.create({ ...propertyData, modelName, propertyRecordSchema }, { waitForReady: false });
|
|
8196
8357
|
}
|
|
8197
8358
|
if (!foundProperty) {
|
|
8198
8359
|
return undefined;
|
|
@@ -8215,9 +8376,16 @@ class ItemProperty {
|
|
|
8215
8376
|
const propertiesData = await getItemProperties({ seedLocalId, seedUid });
|
|
8216
8377
|
const instances = [];
|
|
8217
8378
|
for (const data of propertiesData) {
|
|
8379
|
+
const d = data;
|
|
8380
|
+
const modelName = d.modelName ?? (d.modelType ? modelTypeToModelName(d.modelType) : '') ?? '';
|
|
8381
|
+
// Fix 6: resolve propertyRecordSchema from Model so value setter can persist
|
|
8382
|
+
const propertyRecordSchema = d.propertyName
|
|
8383
|
+
? await resolvePropertyRecordSchemaFromModel(modelName, d.propertyName, d.modelType)
|
|
8384
|
+
: undefined;
|
|
8218
8385
|
const createProps = {
|
|
8219
8386
|
...data,
|
|
8220
|
-
modelName
|
|
8387
|
+
modelName,
|
|
8388
|
+
propertyRecordSchema,
|
|
8221
8389
|
};
|
|
8222
8390
|
const instance = this.create(createProps, { waitForReady: false });
|
|
8223
8391
|
if (instance) {
|
|
@@ -8352,10 +8520,15 @@ class ItemProperty {
|
|
|
8352
8520
|
});
|
|
8353
8521
|
}
|
|
8354
8522
|
async save() {
|
|
8523
|
+
const ctx = this._getSnapshotContext();
|
|
8524
|
+
const { assertItemOwned } = await import('./ownership-CSsweVap.js');
|
|
8525
|
+
await assertItemOwned({
|
|
8526
|
+
seedLocalId: ctx?.seedLocalId ?? undefined,
|
|
8527
|
+
seedUid: ctx?.seedUid ?? undefined,
|
|
8528
|
+
});
|
|
8355
8529
|
await waitFor(this._service, (snapshot) => !snapshot.context.isSaving && snapshot.value === 'idle', {
|
|
8356
8530
|
timeout: 10000,
|
|
8357
8531
|
});
|
|
8358
|
-
const ctx = this._getSnapshotContext();
|
|
8359
8532
|
const canonicalId = ctx?.seedLocalId ?? ctx?.seedUid;
|
|
8360
8533
|
if (canonicalId) {
|
|
8361
8534
|
eventEmitter.emit('itemProperty.saved', { seedLocalId: ctx.seedLocalId, seedUid: ctx.seedUid });
|
|
@@ -8432,7 +8605,7 @@ class ItemProperty {
|
|
|
8432
8605
|
if (!propertyName || (!seedLocalId && !seedUid))
|
|
8433
8606
|
return;
|
|
8434
8607
|
if (db) {
|
|
8435
|
-
const _mod_6 = await import('./index-
|
|
8608
|
+
const _mod_6 = await import('./index-BIPPEMVY.js');
|
|
8436
8609
|
const _ns_6 = _mod_6.s;
|
|
8437
8610
|
const seedSchemaMod = _ns_6;
|
|
8438
8611
|
const { metadata } = seedSchemaMod;
|
|
@@ -8483,11 +8656,18 @@ const createNewItem = async ({ modelName, ...propertyData }) => {
|
|
|
8483
8656
|
const { Model } = modelMod;
|
|
8484
8657
|
const model = await Model.getByNameAsync(modelName);
|
|
8485
8658
|
const propertySchemas = model?.properties ? modelPropertiesToObject(model.properties) : undefined;
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8659
|
+
// Build set of all properties to create metadata for: union of model schema + propertyData
|
|
8660
|
+
// This ensures we create metadata for ALL model properties even when creating with no initial values
|
|
8661
|
+
// (fixes first-item persistence: loadOrCreateItem needs metadata rows to run createItemPropertyInstances)
|
|
8662
|
+
const allPropertyNames = new Set(Object.keys(propertyData));
|
|
8663
|
+
if (propertySchemas) {
|
|
8664
|
+
for (const name of Object.keys(propertySchemas)) {
|
|
8665
|
+
allPropertyNames.add(name);
|
|
8666
|
+
}
|
|
8667
|
+
}
|
|
8668
|
+
for (const propertyName of allPropertyNames) {
|
|
8669
|
+
const propertyValue = propertyData[propertyName];
|
|
8670
|
+
const propertyRecordSchema = propertySchemas?.[propertyName];
|
|
8491
8671
|
await createMetadata({
|
|
8492
8672
|
seedLocalId: newSeedId,
|
|
8493
8673
|
versionLocalId: newVersionId,
|
|
@@ -8654,6 +8834,8 @@ class Item {
|
|
|
8654
8834
|
});
|
|
8655
8835
|
};
|
|
8656
8836
|
this.publish = async () => {
|
|
8837
|
+
const { assertItemOwned } = await import('./ownership-CSsweVap.js');
|
|
8838
|
+
await assertItemOwned(this);
|
|
8657
8839
|
this._service.send({ type: 'startPublish' });
|
|
8658
8840
|
return new Promise((resolve, reject) => {
|
|
8659
8841
|
let wasPublishing = false;
|
|
@@ -8688,13 +8870,13 @@ class Item {
|
|
|
8688
8870
|
};
|
|
8689
8871
|
this.getPublishUploads = async () => {
|
|
8690
8872
|
// Use dynamic import to break circular dependency
|
|
8691
|
-
const getPublishUploadsMod = await import('./getPublishUploads-
|
|
8873
|
+
const getPublishUploadsMod = await import('./getPublishUploads-B0WArDfp.js');
|
|
8692
8874
|
const { getPublishUploads } = getPublishUploadsMod;
|
|
8693
8875
|
return await getPublishUploads(this);
|
|
8694
8876
|
};
|
|
8695
8877
|
this.getPublishPayload = async (uploadedTransactions) => {
|
|
8696
8878
|
// Use dynamic import to break circular dependency
|
|
8697
|
-
const getPublishPayloadMod = await import('./getPublishPayload-
|
|
8879
|
+
const getPublishPayloadMod = await import('./getPublishPayload-BRgULCf3.js');
|
|
8698
8880
|
const { getPublishPayload } = getPublishPayloadMod;
|
|
8699
8881
|
return await getPublishPayload(this, uploadedTransactions);
|
|
8700
8882
|
};
|
|
@@ -9225,8 +9407,8 @@ class Item {
|
|
|
9225
9407
|
}
|
|
9226
9408
|
}
|
|
9227
9409
|
static async all(modelName, deleted, options) {
|
|
9228
|
-
const { waitForReady = false, readyTimeout = 5000 } = options ?? {};
|
|
9229
|
-
const itemsData = await getItemsData({ modelName, deleted });
|
|
9410
|
+
const { waitForReady = false, readyTimeout = 5000, includeEas = false, addressFilter, } = options ?? {};
|
|
9411
|
+
const itemsData = await getItemsData({ modelName, deleted, includeEas, addressFilter });
|
|
9230
9412
|
const itemInstances = [];
|
|
9231
9413
|
for (const itemData of itemsData) {
|
|
9232
9414
|
itemInstances.push(await Item.create({
|
|
@@ -9563,7 +9745,7 @@ class Item {
|
|
|
9563
9745
|
setupState.subscriptionSetUp = true;
|
|
9564
9746
|
logger(`[Item._setupLiveQuerySubscription] Setting up liveQuery for seedLocalId: ${seedLocalId}`);
|
|
9565
9747
|
try {
|
|
9566
|
-
const _mod_7 = await import('./index-
|
|
9748
|
+
const _mod_7 = await import('./index-BIPPEMVY.js');
|
|
9567
9749
|
const _ns_7 = _mod_7.s;
|
|
9568
9750
|
const seedSchemaMod = _ns_7;
|
|
9569
9751
|
const { seeds, versions, metadata } = seedSchemaMod;
|
|
@@ -9844,6 +10026,8 @@ class Item {
|
|
|
9844
10026
|
* Destroy the item: soft delete in DB, remove from caches, clean up subscriptions, stop service.
|
|
9845
10027
|
*/
|
|
9846
10028
|
async destroy() {
|
|
10029
|
+
const { assertItemOwned } = await import('./ownership-CSsweVap.js');
|
|
10030
|
+
await assertItemOwned(this);
|
|
9847
10031
|
const context = this._getSnapshotContext();
|
|
9848
10032
|
const cacheKey = context.seedUid || context.seedLocalId;
|
|
9849
10033
|
const cacheKeys = cacheKey ? [cacheKey] : [];
|
|
@@ -9885,6 +10069,24 @@ class ConflictError extends Error {
|
|
|
9885
10069
|
}
|
|
9886
10070
|
}
|
|
9887
10071
|
|
|
10072
|
+
/**
|
|
10073
|
+
* Normalizes AddressConfiguration to { owned, watched }.
|
|
10074
|
+
* - string[] -> { owned: addresses, watched: [] }
|
|
10075
|
+
* - { owned, watched? } -> { owned, watched: watched ?? [] }
|
|
10076
|
+
*/
|
|
10077
|
+
function normalizeAddressConfig(addresses) {
|
|
10078
|
+
if (!addresses) {
|
|
10079
|
+
return { owned: [], watched: [] };
|
|
10080
|
+
}
|
|
10081
|
+
if (Array.isArray(addresses)) {
|
|
10082
|
+
return { owned: addresses, watched: [] };
|
|
10083
|
+
}
|
|
10084
|
+
return {
|
|
10085
|
+
owned: addresses.owned ?? [],
|
|
10086
|
+
watched: addresses.watched ?? [],
|
|
10087
|
+
};
|
|
10088
|
+
}
|
|
10089
|
+
|
|
9888
10090
|
const isNode = () => {
|
|
9889
10091
|
return (typeof process !== 'undefined' &&
|
|
9890
10092
|
process.versions != null &&
|
|
@@ -10024,6 +10226,7 @@ const saveEasSeedsToDb = async ({ itemSeeds }) => {
|
|
|
10024
10226
|
uid: seed.id,
|
|
10025
10227
|
schemaUid: seed.schemaId,
|
|
10026
10228
|
type: seed.schema.schemaNames[0].name,
|
|
10229
|
+
publisher: seed.attester,
|
|
10027
10230
|
createdAt: Date.now(),
|
|
10028
10231
|
attestationCreatedAt: seed.timeCreated * 1000,
|
|
10029
10232
|
attestationRaw,
|
|
@@ -10343,6 +10546,10 @@ const getRelatedSeedsAndVersions = async () => {
|
|
|
10343
10546
|
});
|
|
10344
10547
|
};
|
|
10345
10548
|
const syncDbWithEasHandler = throttle(async (_) => {
|
|
10549
|
+
const addresses = await getAllAddressesFromDb();
|
|
10550
|
+
if (!addresses || addresses.length === 0) {
|
|
10551
|
+
return;
|
|
10552
|
+
}
|
|
10346
10553
|
const appDb = BaseDb.getAppDb();
|
|
10347
10554
|
const { schemaStringToModelRecord } = await getModelSchemas();
|
|
10348
10555
|
const modelSchemas = await getModelSchemasFromEas();
|
|
@@ -10380,7 +10587,6 @@ const syncDbWithEasHandler = throttle(async (_) => {
|
|
|
10380
10587
|
if (schemaUids.length === 0) {
|
|
10381
10588
|
return;
|
|
10382
10589
|
}
|
|
10383
|
-
const addresses = await getAddressesFromDb();
|
|
10384
10590
|
const itemSeeds = await getSeedsFromSchemaUids({
|
|
10385
10591
|
schemaUids,
|
|
10386
10592
|
addresses,
|
|
@@ -10482,21 +10688,21 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
|
|
|
10482
10688
|
let PathResolver;
|
|
10483
10689
|
let EasClient;
|
|
10484
10690
|
if (isBrowser()) {
|
|
10485
|
-
FileManager = (await import('./FileManager-
|
|
10486
|
-
Db = (await import('./Db-
|
|
10487
|
-
QueryClient = (await import('./QueryClient-
|
|
10488
|
-
ArweaveClient = (await import('./ArweaveClient-
|
|
10489
|
-
PathResolver = (await import('./PathResolver-
|
|
10490
|
-
EasClient = (await import('./EasClient-
|
|
10691
|
+
FileManager = (await import('./FileManager-Cub9icdd.js')).FileManager;
|
|
10692
|
+
Db = (await import('./Db-Cq4q88X_.js')).Db;
|
|
10693
|
+
QueryClient = (await import('./QueryClient-Vs9KN5kS.js')).QueryClient;
|
|
10694
|
+
ArweaveClient = (await import('./ArweaveClient-nrTU_rhU.js')).ArweaveClient;
|
|
10695
|
+
PathResolver = (await import('./PathResolver-T1yEDECb.js')).PathResolver;
|
|
10696
|
+
EasClient = (await import('./EasClient-ZCIE6UQq.js')).EasClient;
|
|
10491
10697
|
}
|
|
10492
10698
|
else if (isNode()) {
|
|
10493
10699
|
console.log('isNode');
|
|
10494
|
-
FileManager = (await import('./FileManager-
|
|
10495
|
-
Db = (await import('./Db-
|
|
10496
|
-
QueryClient = (await import('./QueryClient-
|
|
10497
|
-
ArweaveClient = (await import('./ArweaveClient-
|
|
10498
|
-
PathResolver = (await import('./PathResolver-
|
|
10499
|
-
EasClient = (await import('./EasClient-
|
|
10700
|
+
FileManager = (await import('./FileManager-HSFEess-.js')).FileManager;
|
|
10701
|
+
Db = (await import('./Db-CWKaeNQH.js')).Db;
|
|
10702
|
+
QueryClient = (await import('./QueryClient-DcKDQuwz.js')).QueryClient;
|
|
10703
|
+
ArweaveClient = (await import('./ArweaveClient-BdQaTOZ4.js')).ArweaveClient;
|
|
10704
|
+
PathResolver = (await import('./PathResolver-DVLBs_qi.js')).PathResolver;
|
|
10705
|
+
EasClient = (await import('./EasClient-Du9_TULE.js')).EasClient;
|
|
10500
10706
|
}
|
|
10501
10707
|
else {
|
|
10502
10708
|
throw new Error(`Unable to determine environment. isBrowser()=${isBrowser()}, isNode()=${isNode()}. Platform-specific implementations could not be loaded.`);
|
|
@@ -10556,11 +10762,14 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
|
|
|
10556
10762
|
}
|
|
10557
10763
|
// If it's an absolute path that exists or is a valid filesystem path, use it as-is
|
|
10558
10764
|
}
|
|
10765
|
+
const normalizedAddresses = normalizeAddressConfig(addresses);
|
|
10559
10766
|
sendBack({ type: 'updateContext', context: {
|
|
10560
10767
|
models: models || {},
|
|
10561
10768
|
endpoints,
|
|
10562
10769
|
arweaveDomain,
|
|
10563
|
-
addresses:
|
|
10770
|
+
addresses: normalizedAddresses.owned,
|
|
10771
|
+
ownedAddresses: normalizedAddresses.owned,
|
|
10772
|
+
watchedAddresses: normalizedAddresses.watched,
|
|
10564
10773
|
filesDir: normalizedFilesDir,
|
|
10565
10774
|
dbConfig,
|
|
10566
10775
|
} });
|
|
@@ -10744,7 +10953,7 @@ const downloadAllFilesRequestHandler = async ({ endpoints, eventId, }) => {
|
|
|
10744
10953
|
const downloadAllFilesBinaryRequestHandler = async () => {
|
|
10745
10954
|
let addresses;
|
|
10746
10955
|
if (BaseDb.isAppDbReady()) {
|
|
10747
|
-
addresses = await
|
|
10956
|
+
addresses = await getAllAddressesFromDb();
|
|
10748
10957
|
}
|
|
10749
10958
|
if (!BaseDb.isAppDbReady()) {
|
|
10750
10959
|
// Wait for ClientManager to be ready (DB_INIT state or later)
|
|
@@ -10761,7 +10970,7 @@ const downloadAllFilesBinaryRequestHandler = async () => {
|
|
|
10761
10970
|
state === 'addModelsToDb' ||
|
|
10762
10971
|
state === 'idle';
|
|
10763
10972
|
}, { timeout: 30000 });
|
|
10764
|
-
addresses = await
|
|
10973
|
+
addresses = await getAllAddressesFromDb();
|
|
10765
10974
|
}
|
|
10766
10975
|
if (!addresses || addresses.length === 0) {
|
|
10767
10976
|
return;
|
|
@@ -11113,7 +11322,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
11113
11322
|
const logger$5 = debug('seedSdk:client:actors:saveConfig');
|
|
11114
11323
|
const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
11115
11324
|
logger$5('saveConfig starting');
|
|
11116
|
-
const { endpoints, addresses, arweaveDomain } = context;
|
|
11325
|
+
const { endpoints, addresses, ownedAddresses, watchedAddresses, arweaveDomain } = context;
|
|
11117
11326
|
// Validate endpoints - required for proper initialization
|
|
11118
11327
|
// If endpoints are missing or invalid, initialization should fail
|
|
11119
11328
|
if (!endpoints || !endpoints.filePaths || !endpoints.files) {
|
|
@@ -11133,7 +11342,9 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
11133
11342
|
throw new Error('App DB not found');
|
|
11134
11343
|
}
|
|
11135
11344
|
const endpointsValueString = JSON.stringify(endpoints);
|
|
11136
|
-
const
|
|
11345
|
+
const owned = ownedAddresses ?? addresses ?? [];
|
|
11346
|
+
const watched = watchedAddresses ?? [];
|
|
11347
|
+
const addressesValueString = JSON.stringify({ owned, watched });
|
|
11137
11348
|
// TODO: Figure out how to define on conflict with multiple rows added
|
|
11138
11349
|
await appDb
|
|
11139
11350
|
.insert(appState)
|
|
@@ -11147,7 +11358,7 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
11147
11358
|
value: endpointsValueString,
|
|
11148
11359
|
},
|
|
11149
11360
|
});
|
|
11150
|
-
if (
|
|
11361
|
+
if (owned.length > 0 || watched.length > 0) {
|
|
11151
11362
|
await appDb
|
|
11152
11363
|
.insert(appState)
|
|
11153
11364
|
.values({
|
|
@@ -13226,14 +13437,17 @@ const clientManagerMachine = setup({
|
|
|
13226
13437
|
actions: [
|
|
13227
13438
|
assign(({ event, spawn }) => {
|
|
13228
13439
|
const { addresses } = event;
|
|
13440
|
+
const normalized = normalizeAddressConfig(addresses);
|
|
13229
13441
|
spawn('saveAppState', {
|
|
13230
13442
|
input: {
|
|
13231
13443
|
key: 'addresses',
|
|
13232
|
-
value:
|
|
13444
|
+
value: { owned: normalized.owned, watched: normalized.watched },
|
|
13233
13445
|
},
|
|
13234
13446
|
});
|
|
13235
13447
|
return {
|
|
13236
|
-
addresses,
|
|
13448
|
+
addresses: normalized.owned,
|
|
13449
|
+
ownedAddresses: normalized.owned,
|
|
13450
|
+
watchedAddresses: normalized.watched,
|
|
13237
13451
|
isSaving: true,
|
|
13238
13452
|
};
|
|
13239
13453
|
})
|
|
@@ -13306,6 +13520,8 @@ const clientInstance = {
|
|
|
13306
13520
|
isSaving: false,
|
|
13307
13521
|
endpoints: undefined,
|
|
13308
13522
|
addresses: undefined,
|
|
13523
|
+
ownedAddresses: undefined,
|
|
13524
|
+
watchedAddresses: undefined,
|
|
13309
13525
|
models: undefined,
|
|
13310
13526
|
arweaveDomain: undefined,
|
|
13311
13527
|
filesDir: undefined,
|
|
@@ -13360,9 +13576,17 @@ const clientInstance = {
|
|
|
13360
13576
|
},
|
|
13361
13577
|
getAddresses: async () => {
|
|
13362
13578
|
ensureInitialized();
|
|
13363
|
-
const
|
|
13364
|
-
const
|
|
13365
|
-
return
|
|
13579
|
+
const owned = await getOwnedAddressesFromDb();
|
|
13580
|
+
const watched = await getWatchedAddressesFromDb();
|
|
13581
|
+
return { owned, watched };
|
|
13582
|
+
},
|
|
13583
|
+
getOwnedAddresses: async () => {
|
|
13584
|
+
ensureInitialized();
|
|
13585
|
+
return getOwnedAddressesFromDb();
|
|
13586
|
+
},
|
|
13587
|
+
getWatchedAddresses: async () => {
|
|
13588
|
+
ensureInitialized();
|
|
13589
|
+
return getWatchedAddressesFromDb();
|
|
13366
13590
|
},
|
|
13367
13591
|
addModel: async (modelDef) => {
|
|
13368
13592
|
const db = await BaseDb.getAppDb();
|
|
@@ -13572,7 +13796,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
|
|
|
13572
13796
|
// Lazy import cache for ModelProperty to avoid circular dependency
|
|
13573
13797
|
// Eagerly start loading to minimize delay on first access
|
|
13574
13798
|
let ModelPropertyClass = null;
|
|
13575
|
-
const modelPropertyImportPromise = import('./ModelProperty-
|
|
13799
|
+
const modelPropertyImportPromise = import('./ModelProperty-D4zaeIOT.js')
|
|
13576
13800
|
.then(module => {
|
|
13577
13801
|
ModelPropertyClass = module.ModelProperty;
|
|
13578
13802
|
return ModelPropertyClass;
|
|
@@ -13589,7 +13813,7 @@ function getModelProperty() {
|
|
|
13589
13813
|
}
|
|
13590
13814
|
// Lazy import cache for Schema to avoid circular dependency
|
|
13591
13815
|
let SchemaClass = null;
|
|
13592
|
-
const schemaImportPromise = (async () => { const _mod_8 = await import('./Schema-
|
|
13816
|
+
const schemaImportPromise = (async () => { const _mod_8 = await import('./Schema-SbwqmoMM.js'); return _mod_8.b; })()
|
|
13593
13817
|
.then(module => {
|
|
13594
13818
|
SchemaClass = module.Schema;
|
|
13595
13819
|
return SchemaClass;
|
|
@@ -14105,7 +14329,11 @@ class Model {
|
|
|
14105
14329
|
// Step 11: Register with schema if requested, OR trigger write if properties are provided
|
|
14106
14330
|
// If properties are provided, we need to write the model to get modelId for property creation
|
|
14107
14331
|
// If schema provided, trigger write process instead of registration
|
|
14108
|
-
|
|
14332
|
+
// When schemaName is passed as string (e.g. useCreateModel), we must trigger write so runtime-created
|
|
14333
|
+
// models get persisted to DB and show up in useModels (which queries the database).
|
|
14334
|
+
const shouldTriggerWrite = (registerWithSchema && schemaInstance) ||
|
|
14335
|
+
(options?.properties && Object.keys(options.properties).length > 0) ||
|
|
14336
|
+
typeof schemaNameOrSchema === 'string';
|
|
14109
14337
|
if (shouldTriggerWrite) {
|
|
14110
14338
|
queueMicrotask(async () => {
|
|
14111
14339
|
try {
|
|
@@ -14388,6 +14616,22 @@ class Model {
|
|
|
14388
14616
|
}
|
|
14389
14617
|
return undefined;
|
|
14390
14618
|
}
|
|
14619
|
+
/**
|
|
14620
|
+
* Find Model by modelType (snake_case from DB/metadata).
|
|
14621
|
+
* Handles model names with spaces: "new_model" -> finds "New model" (toSnakeCase("New model") === "new_model").
|
|
14622
|
+
*/
|
|
14623
|
+
static findByModelType(modelType) {
|
|
14624
|
+
if (!modelType)
|
|
14625
|
+
return undefined;
|
|
14626
|
+
for (const [nameKey, id] of this.instanceCacheByName.entries()) {
|
|
14627
|
+
const parts = nameKey.split(':', 2);
|
|
14628
|
+
const cachedModelName = parts[1];
|
|
14629
|
+
if (cachedModelName && toSnakeCase$1(cachedModelName) === modelType) {
|
|
14630
|
+
return this.getById(id);
|
|
14631
|
+
}
|
|
14632
|
+
}
|
|
14633
|
+
return undefined;
|
|
14634
|
+
}
|
|
14391
14635
|
/**
|
|
14392
14636
|
* Get all Model instances for a schema from cache only (synchronous).
|
|
14393
14637
|
* Includes models created at runtime via Model.create() that may not yet be in schema context.
|
|
@@ -15422,5 +15666,5 @@ const Date$1 = () => PropertyConstructor(Property.Date());
|
|
|
15422
15666
|
Type.Record(Type.String(), Type.Any());
|
|
15423
15667
|
Type.Record(Type.String(), TProperty);
|
|
15424
15668
|
|
|
15425
|
-
export {
|
|
15426
|
-
//# sourceMappingURL=index-
|
|
15669
|
+
export { graphql as $, appState as A, Boolean$1 as B, SEED_CONFIG_FALLBACKS as C, Date$1 as D, EAS_ENDPOINT as E, config as F, metadata$1 as G, modelRelations as H, Image as I, Json as J, modelSchemas as K, List as L, Model as M, Number$1 as N, modelUids as O, Property as P, modelsRelations as Q, Relation as R, SEED_CONFIG_FILE as S, TPropertyDataType as T, propertiesRelations as U, VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA as V, propertyUidRelations as W, propertyUids as X, schemas as Y, ZERO_BYTES32 as Z, versions as _, ModelPropertyDataTypes as a, getItemData as a0, Item as a1, saveAppState as a2, addModelsToDb$1 as a3, SCHEMA_NJK as a4, ItemProperty as a5, eventEmitter as a6, ClientManager as a7, INIT_SCRIPT_SUCCESS_MESSAGE as a8, SCHEMA_TS as a9, getSeedsFromSchemaUids as aA, SeedModels as aB, getArweaveUrlForTransaction as aC, createSchema as aD, readSchema as aE, listCompleteSchemaFiles as aF, getSchemaNameFromId as aG, getLatestSchemaVersion as aH, createModelsFromJson as aI, SEED_PROTOCOL_SCHEMA_NAME as aJ, addSchemaToDb as aK, loadModelsFromDbForSchema as aL, isInternalSchema as aM, createModelFromJson as aN, ConflictError as aO, unloadEntity as aP, clearDestroySubscriptions as aQ, setupEntityLiveQuery as aR, ModelSchema as aS, BaseFileManager$1 as aT, db as aU, schema as aV, SEEDPROTOCOL_Seed_Protocol_v1 as aW, Model$1 as aX, importJsonSchema as aa, loadSchemaFromFile as ab, readJsonImportFile as ac, transformImportToSchemaFile as ad, writeProcessMachine as ae, generateId as af, waitForEntityIdle as ag, createReactiveProxy as ah, findEntity as ai, forceRemoveFromCaches as aj, runDestroyLifecycle as ak, getModelIdByFileId as al, getModelId as am, getClient as an, ClientManagerState as ao, getVersionData$1 as ap, createNewItem as aq, loadAllSchemasFromDb as ar, getSeedsBySchemaName as as, GET_SEEDS as at, getItemVersionsFromEas as au, getItemPropertiesFromEas as av, setSchemaUidForSchemaDefinition as aw, parseEasRelationPropertyName as ax, getModelSchemasFromEas as ay, getSchemaUidBySchemaName as az, TStorageType as b, TProperty as c, TPropertyConstructor as d, PropertyMetadataKey as e, PropertyConstructor as f, Text as g, TValidationRules as h, getOwnedAddressesFromDb as i, BaseDb as j, getSchemaUidForModel as k, getCorrectId as l, defaultAttestationData as m, INTERNAL_DATA_TYPES as n, getSchemaUidForSchemaDefinition as o, getSchemaForItemProperty as p, modelPropertiesToObject as q, models$1 as r, seeds as s, toSnakeCase as t, properties as u, BaseQueryClient as v, BaseArweaveClient as w, BasePathResolver as x, BaseEasClient as y, BaseFileManager as z };
|
|
15670
|
+
//# sourceMappingURL=index-zsq08F5p.js.map
|