@seedprotocol/sdk 0.5.2 → 0.6.0
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-BDgc7c4T.js → BasePathResolver-DWY_hb8w.js} +2 -2
- package/dist/{BasePathResolver-BDgc7c4T.js.map → BasePathResolver-DWY_hb8w.js.map} +1 -1
- package/dist/{ModelProperty-BBXBvgvy.js → ModelProperty-DGJf78CS.js} +21 -21
- package/dist/{ModelProperty-BBXBvgvy.js.map → ModelProperty-DGJf78CS.js.map} +1 -1
- package/dist/{Schema-xAt7jWlW.js → Schema-Drmce3q-.js} +39 -39
- package/dist/{Schema-xAt7jWlW.js.map → Schema-Drmce3q-.js.map} +1 -1
- package/dist/{SchemaValidationService-CLzAdBm-.js → SchemaValidationService-a_sfnpDV.js} +5 -5
- package/dist/{SchemaValidationService-CLzAdBm-.js.map → SchemaValidationService-a_sfnpDV.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-DBVaIs7O.js → backfillMetadataPropertyIds-CZcOi-cK.js} +3 -3
- package/dist/{backfillMetadataPropertyIds-DBVaIs7O.js.map → backfillMetadataPropertyIds-CZcOi-cK.js.map} +1 -1
- package/dist/cjs/{ModelProperty-Dgd4tGrB.js → ModelProperty-BA26rMV8.js} +17 -17
- package/dist/cjs/{ModelProperty-Dgd4tGrB.js.map → ModelProperty-BA26rMV8.js.map} +1 -1
- package/dist/cjs/{Schema-dkd-eo3B.js → Schema-Hgwq3L34.js} +20 -20
- package/dist/cjs/{Schema-dkd-eo3B.js.map → Schema-Hgwq3L34.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-BMnjcVWV.js → SchemaValidationService-DVmOGZao.js} +2 -2
- package/dist/cjs/{SchemaValidationService-BMnjcVWV.js.map → SchemaValidationService-DVmOGZao.js.map} +1 -1
- package/dist/cjs/{backfillMetadataPropertyIds-ClLuj3s6.js → backfillMetadataPropertyIds-BWJI4eCj.js} +2 -2
- package/dist/cjs/{backfillMetadataPropertyIds-ClLuj3s6.js.map → backfillMetadataPropertyIds-BWJI4eCj.js.map} +1 -1
- package/dist/cjs/{eas-nWAzbl_F.js → eas-BJ8FtbU9.js} +3 -3
- package/dist/cjs/{eas-nWAzbl_F.js.map → eas-BJ8FtbU9.js.map} +1 -1
- package/dist/cjs/{getItem-B08FgglK.js → getItem-DdBKeEEU.js} +2 -2
- package/dist/cjs/{getItem-B08FgglK.js.map → getItem-DdBKeEEU.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-B_G_6qkE.js → getPublishPayload-DSBLjMKl.js} +11 -11
- package/dist/cjs/{getPublishPayload-B_G_6qkE.js.map → getPublishPayload-DSBLjMKl.js.map} +1 -1
- package/dist/cjs/{getPublishUploads-Dt-DS-lo.js → getPublishUploads-DMKnK2_R.js} +4 -4
- package/dist/cjs/{getPublishUploads-Dt-DS-lo.js.map → getPublishUploads-DMKnK2_R.js.map} +1 -1
- package/dist/cjs/{getSegmentedItemProperties-BDGbeDW7.js → getSegmentedItemProperties-D0ZzTmvi.js} +3 -3
- package/dist/cjs/{getSegmentedItemProperties-BDGbeDW7.js.map → getSegmentedItemProperties-D0ZzTmvi.js.map} +1 -1
- package/dist/cjs/{index-CRBI6dSD.js → index-BD1b6zAi.js} +498 -40
- package/dist/cjs/index-BD1b6zAi.js.map +1 -0
- package/dist/cjs/{index-Dx19j60c.js → index-DQggpLqI.js} +3 -3
- package/dist/cjs/index-DQggpLqI.js.map +1 -0
- package/dist/cjs/index.browser-BSf8HpnU.js.map +1 -1
- package/dist/cjs/{property-628qAHpN.js → property-D4IB0zBz.js} +4 -4
- package/dist/cjs/{property-628qAHpN.js.map → property-D4IB0zBz.js.map} +1 -1
- package/dist/cjs/{syncDbWithEas-DOBtMPw-.js → syncDbWithEas-BYvFJc7N.js} +6 -6
- package/dist/cjs/{syncDbWithEas-DOBtMPw-.js.map → syncDbWithEas-BYvFJc7N.js.map} +1 -1
- package/dist/{configurePlatform-Ce6NIKRP.js → configurePlatform-CXQCT7N8.js} +3 -3
- package/dist/{configurePlatform-Ce6NIKRP.js.map → configurePlatform-CXQCT7N8.js.map} +1 -1
- package/dist/{constants-slkc9uq0.js → constants-B7aNfB_1.js} +3 -3
- package/dist/constants-B7aNfB_1.js.map +1 -0
- package/dist/constants-DMHTYMgJ.js.map +1 -1
- package/dist/{db-CSmK0c3e.js → db-Bad8QKfZ.js} +18 -18
- package/dist/{db-CSmK0c3e.js.map → db-Bad8QKfZ.js.map} +1 -1
- package/dist/{eas-rx1grht5.js → eas-BB9hVW68.js} +6 -6
- package/dist/{eas-rx1grht5.js.map → eas-BB9hVW68.js.map} +1 -1
- package/dist/{getItem-hPBJU5JF.js → getItem-Cina46nb.js} +5 -5
- package/dist/{getItem-hPBJU5JF.js.map → getItem-Cina46nb.js.map} +1 -1
- package/dist/{getPublishPayload-5ugovGK5.js → getPublishPayload-BEO52UOv.js} +16 -16
- package/dist/{getPublishPayload-5ugovGK5.js.map → getPublishPayload-BEO52UOv.js.map} +1 -1
- package/dist/{getPublishUploads-CdWeci-s.js → getPublishUploads-CJjfqJi9.js} +7 -7
- package/dist/{getPublishUploads-CdWeci-s.js.map → getPublishUploads-CJjfqJi9.js.map} +1 -1
- package/dist/{getSegmentedItemProperties-DV2LHElJ.js → getSegmentedItemProperties-CbzFDgFr.js} +5 -5
- package/dist/{getSegmentedItemProperties-DV2LHElJ.js.map → getSegmentedItemProperties-CbzFDgFr.js.map} +1 -1
- package/dist/{index-ClwdGWfr.js → index-B4In0GEO.js} +428 -64
- package/dist/index-B4In0GEO.js.map +1 -0
- package/dist/index-DNOCl06b.js +28 -0
- package/dist/index-DNOCl06b.js.map +1 -0
- package/dist/{index-QMrBK-L3.js → index-DrEkRiuK.js} +2 -2
- package/dist/index-DrEkRiuK.js.map +1 -0
- package/dist/{index.node-CrXwRoiB.js → index.node-CnP9s4cV.js} +4 -4
- package/dist/{index.node-CrXwRoiB.js.map → index.node-CnP9s4cV.js.map} +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.js +19 -20
- package/dist/main.js.map +1 -1
- package/dist/node.js +10 -10
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +4 -4
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.node.js +3 -3
- package/dist/{property-CKhOxRNt.js → property-DIN1zQ_c.js} +8 -8
- package/dist/{property-CKhOxRNt.js.map → property-DIN1zQ_c.js.map} +1 -1
- package/dist/src/Item/Item.d.ts +5 -0
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Item/service/itemMachineSingle.d.ts +2 -2
- package/dist/src/Item/service/itemMachineSingle.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts +1 -1
- package/dist/src/ItemProperty/service/propertyMachine.d.ts +2 -2
- package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
- package/dist/src/Model/service/modelMachine.d.ts +10 -18
- package/dist/src/Model/service/modelMachine.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +5 -13
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts.map +1 -1
- package/dist/src/Schema/service/addModelsMachine.d.ts +8 -8
- package/dist/src/Schema/service/addModelsMachine.d.ts.map +1 -1
- package/dist/src/Schema/service/schemaMachine.d.ts +22 -30
- package/dist/src/Schema/service/schemaMachine.d.ts.map +1 -1
- package/dist/src/client/ClientManager.d.ts +16 -6
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/client/clientManagerMachine.d.ts +2 -2
- package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
- package/dist/src/client/events.d.ts +7 -0
- package/dist/src/client/events.d.ts.map +1 -1
- package/dist/src/db/write/removeLocalCopiesForAddresses.d.ts +20 -0
- package/dist/src/db/write/removeLocalCopiesForAddresses.d.ts.map +1 -0
- package/dist/src/events/item/easSyncManager.d.ts +2 -2
- package/dist/src/events/item/easSyncManager.d.ts.map +1 -1
- package/dist/src/helpers/file/download/index.d.ts +2 -2
- package/dist/src/helpers/file/download/index.d.ts.map +1 -1
- package/dist/src/helpers/file/fetchAll/index.d.ts +2 -2
- package/dist/src/helpers/file/fetchAll/index.d.ts.map +1 -1
- package/dist/src/helpers/mediaRef.d.ts +2 -2
- package/dist/src/helpers/mediaRef.d.ts.map +1 -1
- package/dist/src/helpers/ownership.d.ts +7 -0
- package/dist/src/helpers/ownership.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/services/publish/publishMachine.d.ts +1 -1
- package/dist/src/services/publish/publishMachine.d.ts.map +1 -1
- package/dist/src/services/write/writeProcessMachine.d.ts +2 -6
- package/dist/src/services/write/writeProcessMachine.d.ts.map +1 -1
- package/dist/{syncDbWithEas-GsaXzTIY.js → syncDbWithEas-ceVUuWSZ.js} +13 -13
- package/dist/{syncDbWithEas-GsaXzTIY.js.map → syncDbWithEas-ceVUuWSZ.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-Ba0OhDQj.js → updateSeedRevokedAt-CtRjZiyh.js} +2 -2
- package/dist/{updateSeedRevokedAt-Ba0OhDQj.js.map → updateSeedRevokedAt-CtRjZiyh.js.map} +1 -1
- package/package.json +23 -6
- package/dist/cjs/index-CRBI6dSD.js.map +0 -1
- package/dist/cjs/index-Dx19j60c.js.map +0 -1
- package/dist/cjs/ownership-3Tc1-Yrc.js +0 -105
- package/dist/cjs/ownership-3Tc1-Yrc.js.map +0 -1
- package/dist/constants-slkc9uq0.js.map +0 -1
- package/dist/index-CcH2e0Zr.js +0 -23
- package/dist/index-CcH2e0Zr.js.map +0 -1
- package/dist/index-ClwdGWfr.js.map +0 -1
- package/dist/index-QMrBK-L3.js.map +0 -1
- package/dist/ownership-58i0iyD9.js +0 -106
- package/dist/ownership-58i0iyD9.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { waitFor, fromCallback, fromPromise, setup, assign, stateIn, createActor, isMachineSnapshot } from 'xstate';
|
|
2
|
-
import {
|
|
2
|
+
import { a as BaseDb, m as models$1, p as properties, r as seeds, j as modelUids, v as versions, b as metadata$1, s as schemas, i as modelSchemas, B as BaseFileManager, c as appState, f as easSyncProcesses, t as BasePathResolver, h as htmlEmbeddedImageCoPublish, d as arweaveL1FinalizeJobs, q as publishProcesses } from './BasePathResolver-DWY_hb8w.js';
|
|
3
3
|
import { eq, and, isNotNull, not, or, max, count, getTableColumns, sql, isNull, desc, inArray, gt } from 'drizzle-orm';
|
|
4
|
-
import { n as normalizeDataType, t as toSnakeCase, o as MachineIds, v as getStorageTransactionIdForSeedUid, w as convertTxIdToImage, M as ModelPropertyDataTypes, x as getDataTypeFromString, y as getMimeType, l as getCorrectId, z as ClientManagerEvents, C as ClientManagerState,
|
|
4
|
+
import { n as normalizeDataType, t as toSnakeCase, o as MachineIds, v as getStorageTransactionIdForSeedUid, w as convertTxIdToImage, M as ModelPropertyDataTypes, x as getDataTypeFromString, y as getMimeType, l as getCorrectId, z as ClientManagerEvents, C as ClientManagerState, d as TProperty } from './constants-B7aNfB_1.js';
|
|
5
5
|
import debug from 'debug';
|
|
6
6
|
import { customAlphabet } from 'nanoid';
|
|
7
7
|
import { alphanumeric } from 'nanoid-dictionary';
|
|
8
|
-
import { writeModelToDb, writePropertyToDb, addSchemaToDb, getAddressesForItemsFilter, getAllAddressesFromDb, escapeSqliteString, getPropertyIdForModelAndName, loadModelsFromDbForSchema,
|
|
8
|
+
import { writeModelToDb, writePropertyToDb, addSchemaToDb, getAddressesForItemsFilter, getAllAddressesFromDb, escapeSqliteString, getPropertyIdForModelAndName, loadModelsFromDbForSchema, getOwnedAddressesFromDb, getWatchedAddressesFromDb, renameModelInDb } from './db-Bad8QKfZ.js';
|
|
9
9
|
import pluralize from 'pluralize';
|
|
10
10
|
import { BaseQueryClient, BaseEasClient, GET_SCHEMAS, getSchemaUidForModelFromCache, setSchemaUidForModel, GET_PROPERTIES, pickLatestPropertyAttestationsByRefAndSchema, isValidEasAttestationUid, getEasSchemaUidForSchemaDefinition, GET_FILES_METADATA, GET_SCHEMA_BY_NAME } from '@seedprotocol/eas';
|
|
11
11
|
import { ZERO_BYTES32, INTERNAL_PROPERTY_NAMES, INTERNAL_DATA_TYPES, ImageSize, PROPERTY_NAMES_EXEMPT_FROM_ID_SUFFIX_STRIP, isInternalSchema, INTERNAL_SCHEMA_IDS, SEED_PROTOCOL_SCHEMA_NAME, CLIENT_NOT_INITIALIZED } from './constants-DMHTYMgJ.js';
|
|
@@ -283,7 +283,7 @@ const createPropertyInstances = async (propertyFileIds) => {
|
|
|
283
283
|
return;
|
|
284
284
|
}
|
|
285
285
|
try {
|
|
286
|
-
const mod = await import('./ModelProperty-
|
|
286
|
+
const mod = await import('./ModelProperty-DGJf78CS.js');
|
|
287
287
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
288
288
|
if (!ModelProperty) {
|
|
289
289
|
logger$s('createPropertyInstances: ModelProperty not available from dynamic import');
|
|
@@ -467,7 +467,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
467
467
|
// Step 2: Fallback to Schema context (only if database doesn't have the model)
|
|
468
468
|
// This handles the case where model exists in schema file but not yet in database
|
|
469
469
|
try {
|
|
470
|
-
const _mod_0 = await import('./Schema-
|
|
470
|
+
const _mod_0 = await import('./Schema-Drmce3q-.js');
|
|
471
471
|
const _ns_0 = _mod_0.b;
|
|
472
472
|
const schemaMod = _ns_0;
|
|
473
473
|
const { Schema } = schemaMod;
|
|
@@ -617,11 +617,11 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
617
617
|
}
|
|
618
618
|
// Also check database for models (in case they're persisted but not in Schema context)
|
|
619
619
|
if (db) {
|
|
620
|
-
const _mod_1 = await import('./BasePathResolver-
|
|
620
|
+
const _mod_1 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
621
621
|
const _ns_1 = _mod_1.x;
|
|
622
622
|
const modelSchemaSchemaMod = _ns_1;
|
|
623
623
|
const { modelSchemas } = modelSchemaSchemaMod;
|
|
624
|
-
const _mod_2 = await import('./BasePathResolver-
|
|
624
|
+
const _mod_2 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
625
625
|
const _ns_2 = _mod_2.S;
|
|
626
626
|
const schemaSchemaMod = _ns_2;
|
|
627
627
|
const { schemas: schemasTable } = schemaSchemaMod;
|
|
@@ -717,7 +717,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
717
717
|
}
|
|
718
718
|
// Mark schema as draft when a new model is created so saveNewVersion() can persist it
|
|
719
719
|
try {
|
|
720
|
-
const _mod_3 = await import('./Schema-
|
|
720
|
+
const _mod_3 = await import('./Schema-Drmce3q-.js');
|
|
721
721
|
const _ns_3 = _mod_3.b;
|
|
722
722
|
const schemaMod = _ns_3;
|
|
723
723
|
const { Schema } = schemaMod;
|
|
@@ -763,10 +763,10 @@ const validateModel = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
763
763
|
const _validateModel = async () => {
|
|
764
764
|
try {
|
|
765
765
|
// Use dynamic imports to break circular dependencies
|
|
766
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
766
|
+
const validationServiceMod = await import('./SchemaValidationService-a_sfnpDV.js');
|
|
767
767
|
const { SchemaValidationService } = validationServiceMod;
|
|
768
768
|
const validationService = new SchemaValidationService();
|
|
769
|
-
const _mod_4 = await import('./Schema-
|
|
769
|
+
const _mod_4 = await import('./Schema-Drmce3q-.js');
|
|
770
770
|
const _ns_4 = _mod_4.b;
|
|
771
771
|
const schemaMod = _ns_4;
|
|
772
772
|
const { Schema } = schemaMod;
|
|
@@ -878,7 +878,7 @@ const createModelProperties = fromCallback(({ sendBack, input }) => {
|
|
|
878
878
|
return;
|
|
879
879
|
}
|
|
880
880
|
logger$q(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
|
|
881
|
-
const mod = await import('./ModelProperty-
|
|
881
|
+
const mod = await import('./ModelProperty-DGJf78CS.js');
|
|
882
882
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
883
883
|
if (!ModelProperty) {
|
|
884
884
|
logger$q('ModelProperty not available from dynamic import');
|
|
@@ -981,7 +981,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
981
981
|
const structureMsg = `[validateEntity] Validating model structure`;
|
|
982
982
|
logger$p(structureMsg);
|
|
983
983
|
// Use existing Model validation
|
|
984
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
984
|
+
const validationServiceMod = await import('./SchemaValidationService-a_sfnpDV.js');
|
|
985
985
|
const { SchemaValidationService } = validationServiceMod;
|
|
986
986
|
const validationService = new SchemaValidationService();
|
|
987
987
|
// Validate model structure
|
|
@@ -999,7 +999,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
999
999
|
if (entityInput.entityData.schemaName) {
|
|
1000
1000
|
try {
|
|
1001
1001
|
logger$p(`[validateEntity] Validating model against schema "${entityInput.entityData.schemaName}"`);
|
|
1002
|
-
const _mod_5 = await import('./Schema-
|
|
1002
|
+
const _mod_5 = await import('./Schema-Drmce3q-.js');
|
|
1003
1003
|
const _ns_5 = _mod_5.b;
|
|
1004
1004
|
const schemaMod = _ns_5;
|
|
1005
1005
|
const { Schema } = schemaMod;
|
|
@@ -1037,7 +1037,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
1037
1037
|
}
|
|
1038
1038
|
else if (entityInput.entityType === 'modelProperty') {
|
|
1039
1039
|
// Use existing ModelProperty validation
|
|
1040
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
1040
|
+
const validationServiceMod = await import('./SchemaValidationService-a_sfnpDV.js');
|
|
1041
1041
|
const { SchemaValidationService } = validationServiceMod;
|
|
1042
1042
|
const validationService = new SchemaValidationService();
|
|
1043
1043
|
// Validate property structure
|
|
@@ -1052,7 +1052,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
1052
1052
|
// If schema name and model name provided, validate against schema
|
|
1053
1053
|
if (entityInput.entityData._schemaName && entityInput.entityData.modelName) {
|
|
1054
1054
|
try {
|
|
1055
|
-
const _mod_6 = await import('./Schema-
|
|
1055
|
+
const _mod_6 = await import('./Schema-Drmce3q-.js');
|
|
1056
1056
|
const _ns_6 = _mod_6.b;
|
|
1057
1057
|
const schemaMod = _ns_6;
|
|
1058
1058
|
const { Schema } = schemaMod;
|
|
@@ -1083,7 +1083,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
1083
1083
|
}
|
|
1084
1084
|
else if (entityInput.entityType === 'schema') {
|
|
1085
1085
|
// Schema validation - use existing validation
|
|
1086
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
1086
|
+
const validationServiceMod = await import('./SchemaValidationService-a_sfnpDV.js');
|
|
1087
1087
|
const { SchemaValidationService } = validationServiceMod;
|
|
1088
1088
|
const validationService = new SchemaValidationService();
|
|
1089
1089
|
const schemaResult = validationService.validateSchema(entityInput.entityData);
|
|
@@ -1156,7 +1156,7 @@ const writeToDatabase = fromCallback(({ sendBack, input }) => {
|
|
|
1156
1156
|
// initial write completes is not overwritten by the stale requestWrite payload.
|
|
1157
1157
|
let dataToWrite = input.entityData;
|
|
1158
1158
|
try {
|
|
1159
|
-
const mod = await import('./ModelProperty-
|
|
1159
|
+
const mod = await import('./ModelProperty-DGJf78CS.js');
|
|
1160
1160
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
1161
1161
|
if (ModelProperty && typeof ModelProperty.getById === 'function') {
|
|
1162
1162
|
const instance = ModelProperty.getById(input.entityId);
|
|
@@ -1536,7 +1536,7 @@ const modelMachine = setup({
|
|
|
1536
1536
|
// Create ModelProperty instances for any new property IDs
|
|
1537
1537
|
if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
|
|
1538
1538
|
// Import and create instances asynchronously (fire-and-forget)
|
|
1539
|
-
import('./ModelProperty-
|
|
1539
|
+
import('./ModelProperty-DGJf78CS.js').then(({ ModelProperty }) => {
|
|
1540
1540
|
const createPromises = newPropertyIds.map(async (propertyFileId) => {
|
|
1541
1541
|
try {
|
|
1542
1542
|
const property = await ModelProperty.createById(propertyFileId);
|
|
@@ -2434,7 +2434,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
2434
2434
|
const schemaNameToTry = model$1?.schemaName;
|
|
2435
2435
|
if (schemaNameToTry) {
|
|
2436
2436
|
try {
|
|
2437
|
-
const _mod_7 = await import('./Schema-
|
|
2437
|
+
const _mod_7 = await import('./Schema-Drmce3q-.js');
|
|
2438
2438
|
const _ns_7 = _mod_7.b;
|
|
2439
2439
|
const { Schema } = _ns_7;
|
|
2440
2440
|
const schemaInstance = Schema.create(schemaNameToTry, { waitForReady: false });
|
|
@@ -2468,7 +2468,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
2468
2468
|
if (Object.keys(propertySchemas).length === 0) {
|
|
2469
2469
|
try {
|
|
2470
2470
|
const { listCompleteSchemaFiles } = await Promise.resolve().then(function () { return schema; });
|
|
2471
|
-
const _mod_8 = await import('./BasePathResolver-
|
|
2471
|
+
const _mod_8 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
2472
2472
|
const _ns_8 = _mod_8.w;
|
|
2473
2473
|
const { BaseFileManager } = _ns_8;
|
|
2474
2474
|
const schemaFiles = await listCompleteSchemaFiles();
|
|
@@ -2487,7 +2487,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
2487
2487
|
}
|
|
2488
2488
|
}
|
|
2489
2489
|
if (Object.keys(propertySchemas).length === 0) {
|
|
2490
|
-
const schemaMod = await import('./index-
|
|
2490
|
+
const schemaMod = await import('./index-DNOCl06b.js');
|
|
2491
2491
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
2492
2492
|
const KNOWN_MODEL_FALLBACKS = {
|
|
2493
2493
|
Post: {
|
|
@@ -2534,7 +2534,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
2534
2534
|
// Infer propertyRecordSchema from metadata when schema is missing (enables persistence)
|
|
2535
2535
|
let propSchema = propertySchemas[propertyName];
|
|
2536
2536
|
if (!propSchema && isRefTypeFromMeta) {
|
|
2537
|
-
const schemaMod = await import('./index-
|
|
2537
|
+
const schemaMod = await import('./index-DNOCl06b.js');
|
|
2538
2538
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
2539
2539
|
propSchema = {
|
|
2540
2540
|
dataType: refSeedType === 'html' ? ModelPropertyDataTypes.Html
|
|
@@ -2791,9 +2791,9 @@ const runPublish = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2791
2791
|
sendBack({ type: 'publishError', error: new Error(`Item not found for seedLocalId: ${seedLocalId}`) });
|
|
2792
2792
|
return;
|
|
2793
2793
|
}
|
|
2794
|
-
const getPublishUploadsMod = await import('./getPublishUploads-
|
|
2794
|
+
const getPublishUploadsMod = await import('./getPublishUploads-CJjfqJi9.js');
|
|
2795
2795
|
const { getPublishUploads } = getPublishUploadsMod;
|
|
2796
|
-
const getPublishPayloadMod = await import('./getPublishPayload-
|
|
2796
|
+
const getPublishPayloadMod = await import('./getPublishPayload-BEO52UOv.js');
|
|
2797
2797
|
const { getPublishPayload } = getPublishPayloadMod;
|
|
2798
2798
|
const uploads = await getPublishUploads(item);
|
|
2799
2799
|
let uploadedTransactions = [];
|
|
@@ -3641,7 +3641,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3641
3641
|
const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
|
|
3642
3642
|
const _resolveRelatedValue = async () => {
|
|
3643
3643
|
// Use dynamic import to break circular dependency
|
|
3644
|
-
const schemaMod = await import('./index-
|
|
3644
|
+
const schemaMod = await import('./index-DNOCl06b.js');
|
|
3645
3645
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
3646
3646
|
if (!propertyValue || !isRelation || populatedFromDb) {
|
|
3647
3647
|
return;
|
|
@@ -4644,7 +4644,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4644
4644
|
// to use dynamically imported ModelPropertyDataTypes
|
|
4645
4645
|
const _hydrateFromDb = async () => {
|
|
4646
4646
|
// Use dynamic import to break circular dependency
|
|
4647
|
-
const schemaMod = await import('./index-
|
|
4647
|
+
const schemaMod = await import('./index-DNOCl06b.js');
|
|
4648
4648
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
4649
4649
|
const appDb = BaseDb.getAppDb();
|
|
4650
4650
|
const whereClauses = [];
|
|
@@ -5007,14 +5007,14 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
5007
5007
|
};
|
|
5008
5008
|
// Merge with schema from file/DB to get validation rules (enum, pattern, etc.) - properties table doesn't store these
|
|
5009
5009
|
try {
|
|
5010
|
-
const { getPropertySchema } = await import('./property-
|
|
5010
|
+
const { getPropertySchema } = await import('./property-DIN1zQ_c.js');
|
|
5011
5011
|
let schemaFromFile = await getPropertySchema(normalizedModelName, propertyName);
|
|
5012
5012
|
if (!schemaFromFile?.validation) {
|
|
5013
5013
|
// Fallback: get validation from schemaData in database (Schema context may not be loaded yet)
|
|
5014
|
-
const _mod_9 = await import('./BasePathResolver-
|
|
5014
|
+
const _mod_9 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
5015
5015
|
const _ns_9 = _mod_9.S;
|
|
5016
5016
|
const { schemas: schemasTable } = _ns_9;
|
|
5017
|
-
const _mod_10 = await import('./BasePathResolver-
|
|
5017
|
+
const _mod_10 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
5018
5018
|
const _ns_10 = _mod_10.x;
|
|
5019
5019
|
const { modelSchemas } = _ns_10;
|
|
5020
5020
|
const modelSchemaRows = await db
|
|
@@ -5476,9 +5476,9 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
5476
5476
|
}
|
|
5477
5477
|
const _analyzeInput = async () => {
|
|
5478
5478
|
// Use dynamic import to break circular dependency
|
|
5479
|
-
const schemaMod = await import('./index-
|
|
5479
|
+
const schemaMod = await import('./index-DNOCl06b.js');
|
|
5480
5480
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
5481
|
-
const { SchemaValidationService } = await import('./SchemaValidationService-
|
|
5481
|
+
const { SchemaValidationService } = await import('./SchemaValidationService-a_sfnpDV.js');
|
|
5482
5482
|
let propertyName = propertyNameRaw;
|
|
5483
5483
|
if (!propertyName) {
|
|
5484
5484
|
throw new Error('propertyName is required');
|
|
@@ -5676,7 +5676,7 @@ const createMetadata = async (metadataValues, propertyRecordSchema, options) =>
|
|
|
5676
5676
|
propertyRecordSchema?.validation &&
|
|
5677
5677
|
metadataValues.propertyValue != null &&
|
|
5678
5678
|
metadataValues.propertyValue !== '') {
|
|
5679
|
-
const { SchemaValidationService } = await import('./SchemaValidationService-
|
|
5679
|
+
const { SchemaValidationService } = await import('./SchemaValidationService-a_sfnpDV.js');
|
|
5680
5680
|
const validationService = new SchemaValidationService();
|
|
5681
5681
|
const validationResult = validationService.validatePropertyValue(metadataValues.propertyValue, normalizeDataType(propertyRecordSchema.dataType), propertyRecordSchema.validation, propertyRecordSchema.refValueType
|
|
5682
5682
|
? normalizeDataType(String(propertyRecordSchema.refValueType))
|
|
@@ -6269,7 +6269,7 @@ const saveRelation = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
6269
6269
|
}
|
|
6270
6270
|
const _saveRelation = async () => {
|
|
6271
6271
|
// Use dynamic import to break circular dependency
|
|
6272
|
-
const schemaMod = await import('./index-
|
|
6272
|
+
const schemaMod = await import('./index-DNOCl06b.js');
|
|
6273
6273
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
6274
6274
|
if (!propertyNameRaw) {
|
|
6275
6275
|
throw new Error('propertyName is required');
|
|
@@ -7313,7 +7313,7 @@ class ItemProperty {
|
|
|
7313
7313
|
return;
|
|
7314
7314
|
}
|
|
7315
7315
|
// Use dynamic import to break circular dependency
|
|
7316
|
-
const schemaMod = await import('./index-
|
|
7316
|
+
const schemaMod = await import('./index-DNOCl06b.js');
|
|
7317
7317
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
7318
7318
|
const { context } = snapshot;
|
|
7319
7319
|
const { propertyRecordSchema } = context;
|
|
@@ -7484,7 +7484,7 @@ class ItemProperty {
|
|
|
7484
7484
|
const normalizedRefValueType = normalizeDataType(propertyRecordSchema?.refValueType);
|
|
7485
7485
|
const propertyNames = getMetadataPropertyNamesForQuery(propertyName, normalizedDataType, normalizedRefValueType);
|
|
7486
7486
|
const propertyNameVariant = propertyNames.length > 1 ? propertyNames[1] : undefined;
|
|
7487
|
-
const _mod_11 = await import('./index-
|
|
7487
|
+
const _mod_11 = await import('./index-DrEkRiuK.js');
|
|
7488
7488
|
const _ns_11 = _mod_11.s;
|
|
7489
7489
|
const seedSchemaMod = _ns_11;
|
|
7490
7490
|
const { metadata } = seedSchemaMod;
|
|
@@ -8224,7 +8224,7 @@ class ItemProperty {
|
|
|
8224
8224
|
}
|
|
8225
8225
|
async save() {
|
|
8226
8226
|
const ctx = this._getSnapshotContext();
|
|
8227
|
-
const { assertItemOwned } = await
|
|
8227
|
+
const { assertItemOwned } = await Promise.resolve().then(function () { return ownership; });
|
|
8228
8228
|
await assertItemOwned({
|
|
8229
8229
|
seedLocalId: ctx?.seedLocalId ?? undefined,
|
|
8230
8230
|
seedUid: ctx?.seedUid ?? undefined,
|
|
@@ -8317,7 +8317,7 @@ class ItemProperty {
|
|
|
8317
8317
|
if (!propertyName || (!seedLocalId && !seedUid))
|
|
8318
8318
|
return;
|
|
8319
8319
|
if (db) {
|
|
8320
|
-
const _mod_12 = await import('./index-
|
|
8320
|
+
const _mod_12 = await import('./index-DrEkRiuK.js');
|
|
8321
8321
|
const _ns_12 = _mod_12.s;
|
|
8322
8322
|
const seedSchemaMod = _ns_12;
|
|
8323
8323
|
const { metadata } = seedSchemaMod;
|
|
@@ -8565,7 +8565,7 @@ class Item {
|
|
|
8565
8565
|
});
|
|
8566
8566
|
};
|
|
8567
8567
|
this.unpublish = async () => {
|
|
8568
|
-
const { assertItemOwned } = await
|
|
8568
|
+
const { assertItemOwned } = await Promise.resolve().then(function () { return ownership; });
|
|
8569
8569
|
const { getRevokeExecutor } = await Promise.resolve().then(function () { return publishConfig; });
|
|
8570
8570
|
await assertItemOwned(this);
|
|
8571
8571
|
const seedUid = this.seedUid;
|
|
@@ -8589,7 +8589,7 @@ class Item {
|
|
|
8589
8589
|
this._service.send({ type: 'updateContext', revokedAt });
|
|
8590
8590
|
};
|
|
8591
8591
|
this.publish = async () => {
|
|
8592
|
-
const { assertItemOwned } = await
|
|
8592
|
+
const { assertItemOwned } = await Promise.resolve().then(function () { return ownership; });
|
|
8593
8593
|
await assertItemOwned(this);
|
|
8594
8594
|
this._service.send({ type: 'startPublish' });
|
|
8595
8595
|
return new Promise((resolve, reject) => {
|
|
@@ -8625,12 +8625,12 @@ class Item {
|
|
|
8625
8625
|
};
|
|
8626
8626
|
this.getPublishUploads = async (options) => {
|
|
8627
8627
|
// Use dynamic import to break circular dependency
|
|
8628
|
-
const getPublishUploadsMod = await import('./getPublishUploads-
|
|
8628
|
+
const getPublishUploadsMod = await import('./getPublishUploads-CJjfqJi9.js');
|
|
8629
8629
|
const { getPublishUploads } = getPublishUploadsMod;
|
|
8630
8630
|
return await getPublishUploads(this, [], undefined, options);
|
|
8631
8631
|
};
|
|
8632
8632
|
this.getPublishPayload = async (uploadedTransactions, options) => {
|
|
8633
|
-
const getPublishPayloadMod = await import('./getPublishPayload-
|
|
8633
|
+
const getPublishPayloadMod = await import('./getPublishPayload-BEO52UOv.js');
|
|
8634
8634
|
const { getPublishPayload } = getPublishPayloadMod;
|
|
8635
8635
|
return await getPublishPayload(this, uploadedTransactions, options);
|
|
8636
8636
|
};
|
|
@@ -9102,11 +9102,11 @@ class Item {
|
|
|
9102
9102
|
let modelRecords;
|
|
9103
9103
|
// If we have a schema name, join with modelSchemas to filter by schema
|
|
9104
9104
|
if (schemaName) {
|
|
9105
|
-
const _mod_13 = await import('./BasePathResolver-
|
|
9105
|
+
const _mod_13 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
9106
9106
|
const _ns_13 = _mod_13.x;
|
|
9107
9107
|
const modelSchemaSchemaMod = _ns_13;
|
|
9108
9108
|
const { modelSchemas } = modelSchemaSchemaMod;
|
|
9109
|
-
const _mod_14 = await import('./BasePathResolver-
|
|
9109
|
+
const _mod_14 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
9110
9110
|
const _ns_14 = _mod_14.S;
|
|
9111
9111
|
const schemaSchemaMod = _ns_14;
|
|
9112
9112
|
const { schemas: schemasTable } = schemaSchemaMod;
|
|
@@ -9287,6 +9287,39 @@ class Item {
|
|
|
9287
9287
|
}
|
|
9288
9288
|
return null;
|
|
9289
9289
|
}
|
|
9290
|
+
/**
|
|
9291
|
+
* Drop cached Item instances for the given seed local ids / uids without soft-deleting DB rows.
|
|
9292
|
+
* Used by local purge (`removeLocalCopiesForAddresses`) before hard-deleting rows.
|
|
9293
|
+
*/
|
|
9294
|
+
static dropCachedInstancesForSeedIds(ids) {
|
|
9295
|
+
const uniqueIds = [
|
|
9296
|
+
...new Set(ids.filter((id) => typeof id === 'string' && id.length > 0)),
|
|
9297
|
+
];
|
|
9298
|
+
const seenInstances = new Set();
|
|
9299
|
+
for (const id of uniqueIds) {
|
|
9300
|
+
const entry = this.findItemInstanceCacheEntryById(id);
|
|
9301
|
+
if (entry && !seenInstances.has(entry.instance)) {
|
|
9302
|
+
seenInstances.add(entry.instance);
|
|
9303
|
+
const instance = entry.instance;
|
|
9304
|
+
const cacheKeys = this.collectInstanceCacheKeysForInstance(instance);
|
|
9305
|
+
clearDestroySubscriptions(instance, {
|
|
9306
|
+
instanceState: itemInstanceState,
|
|
9307
|
+
onUnload: (inst) => inst._subscription?.unsubscribe(),
|
|
9308
|
+
});
|
|
9309
|
+
forceRemoveFromCaches(instance, {
|
|
9310
|
+
getCacheKeys: () => cacheKeys,
|
|
9311
|
+
caches: [Item.instanceCache],
|
|
9312
|
+
});
|
|
9313
|
+
try {
|
|
9314
|
+
instance._service.stop();
|
|
9315
|
+
}
|
|
9316
|
+
catch {
|
|
9317
|
+
// Service may already be stopped
|
|
9318
|
+
}
|
|
9319
|
+
}
|
|
9320
|
+
ItemProperty.clearInstanceCacheForItem(id);
|
|
9321
|
+
}
|
|
9322
|
+
}
|
|
9290
9323
|
/**
|
|
9291
9324
|
* Create Item instance by ID (queries database if not in cache)
|
|
9292
9325
|
* The ID can be either seedUid or seedLocalId
|
|
@@ -9375,7 +9408,7 @@ class Item {
|
|
|
9375
9408
|
if (!appDb || Item.instanceCache.size === 0) {
|
|
9376
9409
|
return;
|
|
9377
9410
|
}
|
|
9378
|
-
const _mod_15 = await import('./index-
|
|
9411
|
+
const _mod_15 = await import('./index-DrEkRiuK.js');
|
|
9379
9412
|
const _ns_15 = _mod_15.s;
|
|
9380
9413
|
const { metadata } = _ns_15;
|
|
9381
9414
|
const { eq, and } = await import('drizzle-orm');
|
|
@@ -9826,7 +9859,7 @@ class Item {
|
|
|
9826
9859
|
itemActor.send(event);
|
|
9827
9860
|
};
|
|
9828
9861
|
try {
|
|
9829
|
-
const _mod_16 = await import('./index-
|
|
9862
|
+
const _mod_16 = await import('./index-DrEkRiuK.js');
|
|
9830
9863
|
const _ns_16 = _mod_16.s;
|
|
9831
9864
|
const seedSchemaMod = _ns_16;
|
|
9832
9865
|
const { seeds, versions, metadata } = seedSchemaMod;
|
|
@@ -10132,7 +10165,7 @@ class Item {
|
|
|
10132
10165
|
* Destroy the item: soft delete in DB, remove from caches, clean up subscriptions, stop service.
|
|
10133
10166
|
*/
|
|
10134
10167
|
async destroy() {
|
|
10135
|
-
const { assertItemOwned } = await
|
|
10168
|
+
const { assertItemOwned } = await Promise.resolve().then(function () { return ownership; });
|
|
10136
10169
|
await assertItemOwned(this);
|
|
10137
10170
|
const context = this._getSnapshotContext();
|
|
10138
10171
|
const cacheKeys = Item.collectInstanceCacheKeysForInstance(this);
|
|
@@ -10288,7 +10321,7 @@ const runEasSync = fromPromise(async ({ input, }) => {
|
|
|
10288
10321
|
requestPayload: input.requestPayload,
|
|
10289
10322
|
persistedSnapshot: input.runningSnapshot,
|
|
10290
10323
|
});
|
|
10291
|
-
const { runSyncFromEas } = await import('./syncDbWithEas-
|
|
10324
|
+
const { runSyncFromEas } = await import('./syncDbWithEas-ceVUuWSZ.js');
|
|
10292
10325
|
try {
|
|
10293
10326
|
await runSyncFromEas(toRunSyncArg(input.options));
|
|
10294
10327
|
await finalizeEasSyncProcessRow(rowId, {
|
|
@@ -10567,7 +10600,7 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
|
|
|
10567
10600
|
}
|
|
10568
10601
|
// Prefer the condition-resolved factory when available; fall back to explicit
|
|
10569
10602
|
// platform imports so source/vitest resolution stays reliable.
|
|
10570
|
-
const { configurePlatform } = await import('./configurePlatform-
|
|
10603
|
+
const { configurePlatform } = await import('./configurePlatform-CXQCT7N8.js');
|
|
10571
10604
|
if (isBrowser()) {
|
|
10572
10605
|
const { createPlatformServices } = await import('./platform.browser.js');
|
|
10573
10606
|
configurePlatform(createPlatformServices());
|
|
@@ -11196,6 +11229,50 @@ const readSchema = async (name, version, schemaFileId) => {
|
|
|
11196
11229
|
throw new Error(`Failed to read schema ${name} v${version}: ${error instanceof Error ? error.message : String(error)}`);
|
|
11197
11230
|
}
|
|
11198
11231
|
};
|
|
11232
|
+
/**
|
|
11233
|
+
* Update an existing schema file
|
|
11234
|
+
* @param schema - The updated schema object (must have same name and version as existing)
|
|
11235
|
+
* @param schemaFileId - Schema file ID (required)
|
|
11236
|
+
* @throws Error if schema doesn't exist
|
|
11237
|
+
*/
|
|
11238
|
+
async function updateSchema(schema, schemaFileId) {
|
|
11239
|
+
if (!schema.name || !schema.version) {
|
|
11240
|
+
throw new Error('Schema must have a name and version');
|
|
11241
|
+
}
|
|
11242
|
+
const filePath = getSchemaFilePath$1(schema.name, schema.version, schemaFileId);
|
|
11243
|
+
// Check if schema exists
|
|
11244
|
+
const exists = await BaseFileManager.pathExists(filePath);
|
|
11245
|
+
if (!exists) {
|
|
11246
|
+
throw new Error(`Schema ${schema.name} v${schema.version} does not exist`);
|
|
11247
|
+
}
|
|
11248
|
+
// Write updated schema to file
|
|
11249
|
+
const content = JSON.stringify(schema, null, 2);
|
|
11250
|
+
await BaseFileManager.saveFile(filePath, content);
|
|
11251
|
+
}
|
|
11252
|
+
/**
|
|
11253
|
+
* Delete a schema file
|
|
11254
|
+
* @param name - The name of the schema
|
|
11255
|
+
* @param version - The version of the schema
|
|
11256
|
+
* @param schemaFileId - Schema file ID (required)
|
|
11257
|
+
* @throws Error if schema doesn't exist
|
|
11258
|
+
*/
|
|
11259
|
+
async function deleteSchema(name, version, schemaFileId) {
|
|
11260
|
+
const filePath = getSchemaFilePath$1(name, version, schemaFileId);
|
|
11261
|
+
// Check if schema exists
|
|
11262
|
+
const exists = await BaseFileManager.pathExists(filePath);
|
|
11263
|
+
if (!exists) {
|
|
11264
|
+
throw new Error(`Schema ${name} v${version} does not exist`);
|
|
11265
|
+
}
|
|
11266
|
+
// Delete the file
|
|
11267
|
+
const fs = await BaseFileManager.getFs();
|
|
11268
|
+
BaseFileManager.getPathModule();
|
|
11269
|
+
try {
|
|
11270
|
+
await fs.promises.unlink(filePath);
|
|
11271
|
+
}
|
|
11272
|
+
catch (error) {
|
|
11273
|
+
throw new Error(`Failed to delete schema ${name} v${version}: ${error instanceof Error ? error.message : String(error)}`);
|
|
11274
|
+
}
|
|
11275
|
+
}
|
|
11199
11276
|
/**
|
|
11200
11277
|
* List all schema files in the working directory
|
|
11201
11278
|
* Only returns files that are NOT already complete schema files (i.e., files without $schema field)
|
|
@@ -11306,6 +11383,24 @@ async function listCompleteSchemaFiles() {
|
|
|
11306
11383
|
throw new Error(`Failed to list complete schemas: ${error instanceof Error ? error.message : String(error)}`);
|
|
11307
11384
|
}
|
|
11308
11385
|
}
|
|
11386
|
+
/**
|
|
11387
|
+
* Find a schema by name (returns the latest version if multiple versions exist)
|
|
11388
|
+
* @param name - The name of the schema
|
|
11389
|
+
* @returns The schema with the highest version, or null if not found
|
|
11390
|
+
*/
|
|
11391
|
+
async function findSchemaByName(name) {
|
|
11392
|
+
const schemas = await listCompleteSchemaFiles();
|
|
11393
|
+
const matchingSchemas = schemas.filter((s) => s.name === name);
|
|
11394
|
+
if (matchingSchemas.length === 0) {
|
|
11395
|
+
return null;
|
|
11396
|
+
}
|
|
11397
|
+
// Find the schema with the highest version
|
|
11398
|
+
const latest = matchingSchemas.reduce((prev, current) => current.version > prev.version ? current : prev);
|
|
11399
|
+
if (!latest.schemaFileId) {
|
|
11400
|
+
throw new Error(`Schema ${latest.name} v${latest.version} is missing schemaFileId`);
|
|
11401
|
+
}
|
|
11402
|
+
return readSchema(latest.name, latest.version, latest.schemaFileId);
|
|
11403
|
+
}
|
|
11309
11404
|
/**
|
|
11310
11405
|
* Get the latest version number for a schema by name
|
|
11311
11406
|
* Only considers complete schema files (with $schema field)
|
|
@@ -11338,6 +11433,27 @@ async function listLatestSchemaFiles() {
|
|
|
11338
11433
|
}
|
|
11339
11434
|
return Array.from(schemaMap.values());
|
|
11340
11435
|
}
|
|
11436
|
+
/**
|
|
11437
|
+
* Filter an array of schemas to only include the latest version for each schema name
|
|
11438
|
+
* Works with any object that has a name (via metadata.name or name property) and a version property
|
|
11439
|
+
* @param schemas - Array of schema objects
|
|
11440
|
+
* @returns Array containing only the latest version of each schema
|
|
11441
|
+
*/
|
|
11442
|
+
function filterLatestSchemas(schemas) {
|
|
11443
|
+
// Group by schema name and keep only the latest version of each
|
|
11444
|
+
const schemaMap = new Map();
|
|
11445
|
+
for (const schema of schemas) {
|
|
11446
|
+
const schemaName = schema.metadata?.name || schema.name;
|
|
11447
|
+
if (!schemaName) {
|
|
11448
|
+
continue; // Skip schemas without a name
|
|
11449
|
+
}
|
|
11450
|
+
const existing = schemaMap.get(schemaName);
|
|
11451
|
+
if (!existing || schema.version > existing.version) {
|
|
11452
|
+
schemaMap.set(schemaName, schema);
|
|
11453
|
+
}
|
|
11454
|
+
}
|
|
11455
|
+
return Array.from(schemaMap.values());
|
|
11456
|
+
}
|
|
11341
11457
|
/**
|
|
11342
11458
|
* Unified schema loading function that queries database first, then merges with files
|
|
11343
11459
|
* Returns all schemas with their draft status and source information
|
|
@@ -11531,6 +11647,62 @@ async function loadAllSchemasFromDb() {
|
|
|
11531
11647
|
}
|
|
11532
11648
|
return result;
|
|
11533
11649
|
}
|
|
11650
|
+
/**
|
|
11651
|
+
* Migration helper: Migrate existing file-based schemas to the database
|
|
11652
|
+
* This function should be called once to migrate existing schema files to the new database-first approach
|
|
11653
|
+
* All existing schemas will be marked as published (isDraft = false) since they already exist in files
|
|
11654
|
+
* @returns Number of schemas migrated
|
|
11655
|
+
*/
|
|
11656
|
+
async function migrateFileSchemasToDb() {
|
|
11657
|
+
const db = BaseDb.getAppDb();
|
|
11658
|
+
if (!db) {
|
|
11659
|
+
throw new Error('Database not found');
|
|
11660
|
+
}
|
|
11661
|
+
logger$4('Starting migration of file-based schemas to database');
|
|
11662
|
+
// Get all complete schema files
|
|
11663
|
+
const completeSchemas = await listCompleteSchemaFiles();
|
|
11664
|
+
let migratedCount = 0;
|
|
11665
|
+
for (const schemaFileInfo of completeSchemas) {
|
|
11666
|
+
try {
|
|
11667
|
+
// Read the schema file
|
|
11668
|
+
const content = await BaseFileManager.readFileAsString(schemaFileInfo.filePath);
|
|
11669
|
+
const schemaFile = JSON.parse(content);
|
|
11670
|
+
if (!schemaFile.$schema || !schemaFile.metadata?.name) {
|
|
11671
|
+
logger$4(`Skipping invalid schema file: ${schemaFileInfo.filePath}`);
|
|
11672
|
+
continue;
|
|
11673
|
+
}
|
|
11674
|
+
const schemaName = schemaFile.metadata.name;
|
|
11675
|
+
// Check if schema already exists in database
|
|
11676
|
+
const existingSchemas = await db
|
|
11677
|
+
.select()
|
|
11678
|
+
.from(schemas)
|
|
11679
|
+
.where(eq(schemas.name, schemaName))
|
|
11680
|
+
.limit(1);
|
|
11681
|
+
// Only migrate if it doesn't exist or if existing record doesn't have schemaFileId
|
|
11682
|
+
if (existingSchemas.length === 0 || !existingSchemas[0].schemaFileId) {
|
|
11683
|
+
// Add schema to database as published (isDraft = false)
|
|
11684
|
+
await addSchemaToDb({
|
|
11685
|
+
name: schemaName,
|
|
11686
|
+
version: schemaFile.version,
|
|
11687
|
+
createdAt: new Date(schemaFile.metadata.createdAt).getTime(),
|
|
11688
|
+
updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
|
|
11689
|
+
}, schemaFile.id, // schemaFileId
|
|
11690
|
+
JSON.stringify(schemaFile, null, 2), // schemaData
|
|
11691
|
+
false);
|
|
11692
|
+
migratedCount++;
|
|
11693
|
+
logger$4(`Migrated schema: ${schemaName} v${schemaFile.version}`);
|
|
11694
|
+
}
|
|
11695
|
+
else {
|
|
11696
|
+
logger$4(`Schema ${schemaName} already exists in database, skipping`);
|
|
11697
|
+
}
|
|
11698
|
+
}
|
|
11699
|
+
catch (error) {
|
|
11700
|
+
logger$4(`Error migrating schema file ${schemaFileInfo.filePath}:`, error);
|
|
11701
|
+
}
|
|
11702
|
+
}
|
|
11703
|
+
logger$4(`Migration complete: ${migratedCount} schemas migrated`);
|
|
11704
|
+
return migratedCount;
|
|
11705
|
+
}
|
|
11534
11706
|
/**
|
|
11535
11707
|
* Extract the schema name from a schemaId string
|
|
11536
11708
|
* @param schemaId - Schema ID in the format `${schemaName}-${schemaVersion}`
|
|
@@ -11550,13 +11722,18 @@ function getSchemaNameFromId(schemaId) {
|
|
|
11550
11722
|
var schema = /*#__PURE__*/Object.freeze({
|
|
11551
11723
|
__proto__: null,
|
|
11552
11724
|
createSchema: createSchema,
|
|
11725
|
+
deleteSchema: deleteSchema,
|
|
11726
|
+
filterLatestSchemas: filterLatestSchemas,
|
|
11727
|
+
findSchemaByName: findSchemaByName,
|
|
11553
11728
|
getLatestSchemaVersion: getLatestSchemaVersion,
|
|
11554
11729
|
getSchemaNameFromId: getSchemaNameFromId,
|
|
11555
11730
|
listCompleteSchemaFiles: listCompleteSchemaFiles,
|
|
11556
11731
|
listLatestSchemaFiles: listLatestSchemaFiles,
|
|
11557
11732
|
listSchemaFiles: listSchemaFiles,
|
|
11558
11733
|
loadAllSchemasFromDb: loadAllSchemasFromDb,
|
|
11559
|
-
|
|
11734
|
+
migrateFileSchemasToDb: migrateFileSchemasToDb,
|
|
11735
|
+
readSchema: readSchema,
|
|
11736
|
+
updateSchema: updateSchema
|
|
11560
11737
|
});
|
|
11561
11738
|
|
|
11562
11739
|
const { sha3_256 } = sha3;
|
|
@@ -11650,7 +11827,7 @@ function getRefValueType(prop) {
|
|
|
11650
11827
|
* @returns Promise that resolves when properties are found, or rejects if not found after max retries
|
|
11651
11828
|
*/
|
|
11652
11829
|
const verifyPropertiesPersisted = async (db, modelId, modelName, maxRetries = 10, retryDelay = 100) => {
|
|
11653
|
-
const _mod_17 = await import('./BasePathResolver-
|
|
11830
|
+
const _mod_17 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
11654
11831
|
const _ns_17 = _mod_17.M;
|
|
11655
11832
|
const modelSchemaMod = _ns_17;
|
|
11656
11833
|
const { properties: propertiesTable } = modelSchemaMod;
|
|
@@ -11998,7 +12175,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
|
|
|
11998
12175
|
// Check DB for existing schema by name+version (same as minimal path)
|
|
11999
12176
|
const db = BaseDb.getAppDb();
|
|
12000
12177
|
if (db) {
|
|
12001
|
-
const _mod_18 = await import('./BasePathResolver-
|
|
12178
|
+
const _mod_18 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
12002
12179
|
const _ns_18 = _mod_18.S;
|
|
12003
12180
|
const schemaSchemaMod = _ns_18;
|
|
12004
12181
|
const { schemas: schemasTable } = schemaSchemaMod;
|
|
@@ -12082,7 +12259,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
|
|
|
12082
12259
|
// For minimal imports: check DB for existing schema before creating new file
|
|
12083
12260
|
const db = BaseDb.getAppDb();
|
|
12084
12261
|
if (db) {
|
|
12085
|
-
const _mod_19 = await import('./BasePathResolver-
|
|
12262
|
+
const _mod_19 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
12086
12263
|
const _ns_19 = _mod_19.S;
|
|
12087
12264
|
const schemaSchemaMod = _ns_19;
|
|
12088
12265
|
const { schemas: schemasTable } = schemaSchemaMod;
|
|
@@ -12263,7 +12440,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
|
|
|
12263
12440
|
updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
|
|
12264
12441
|
};
|
|
12265
12442
|
// Use dynamic import to break circular dependency
|
|
12266
|
-
const dbMod = await import('./db-
|
|
12443
|
+
const dbMod = await import('./db-Bad8QKfZ.js');
|
|
12267
12444
|
const { addSchemaToDb, addModelsToDb } = dbMod;
|
|
12268
12445
|
// Try to add schema and models to database if database is available
|
|
12269
12446
|
try {
|
|
@@ -12283,11 +12460,11 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
|
|
|
12283
12460
|
});
|
|
12284
12461
|
// Verify expected models are linked (single attempt - addModelsToDb already confirmed)
|
|
12285
12462
|
const expectedModelNames = Object.keys(schemaFile.models || {});
|
|
12286
|
-
const _mod_20 = await import('./BasePathResolver-
|
|
12463
|
+
const _mod_20 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
12287
12464
|
const _ns_20 = _mod_20.x;
|
|
12288
12465
|
const modelSchemaSchemaMod = _ns_20;
|
|
12289
12466
|
const { modelSchemas } = modelSchemaSchemaMod;
|
|
12290
|
-
const _mod_21 = await import('./BasePathResolver-
|
|
12467
|
+
const _mod_21 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
12291
12468
|
const _ns_21 = _mod_21.M;
|
|
12292
12469
|
const modelSchemaMod = _ns_21;
|
|
12293
12470
|
const { models: modelsTable } = modelSchemaMod;
|
|
@@ -12490,7 +12667,7 @@ async function applySchemaToDb(schemaFile, modelDefinitions, modelFileIds, prope
|
|
|
12490
12667
|
createdAt: new Date(schemaFile.metadata.createdAt).getTime(),
|
|
12491
12668
|
updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
|
|
12492
12669
|
};
|
|
12493
|
-
const dbMod = await import('./db-
|
|
12670
|
+
const dbMod = await import('./db-Bad8QKfZ.js');
|
|
12494
12671
|
const { addSchemaToDb, addModelsToDb } = dbMod;
|
|
12495
12672
|
const db = BaseDb.getAppDb();
|
|
12496
12673
|
if (!db) {
|
|
@@ -12648,11 +12825,11 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
12648
12825
|
if (db) {
|
|
12649
12826
|
const { schemaRecord } = await applySchemaToDb(schemaFile, modelDefinitions, modelFileIds, propertyFileIds);
|
|
12650
12827
|
// Query the database to get model IDs that were just created
|
|
12651
|
-
const _mod_22 = await import('./BasePathResolver-
|
|
12828
|
+
const _mod_22 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
12652
12829
|
const _ns_22 = _mod_22.x;
|
|
12653
12830
|
const modelSchemaSchemaMod = _ns_22;
|
|
12654
12831
|
const { modelSchemas } = modelSchemaSchemaMod;
|
|
12655
|
-
const _mod_23 = await import('./BasePathResolver-
|
|
12832
|
+
const _mod_23 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
12656
12833
|
const _ns_23 = _mod_23.M;
|
|
12657
12834
|
const modelSchemaMod = _ns_23;
|
|
12658
12835
|
const { models: modelsTable } = modelSchemaMod;
|
|
@@ -12718,7 +12895,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
12718
12895
|
// After properties are created (file path), ensure schemaFile has the correct IDs from database
|
|
12719
12896
|
// Query the database to get the actual schemaFileId values that were used
|
|
12720
12897
|
// This ensures schemaData matches what's actually in the database
|
|
12721
|
-
const _mod_24 = await import('./BasePathResolver-
|
|
12898
|
+
const _mod_24 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
12722
12899
|
const _ns_24 = _mod_24.M;
|
|
12723
12900
|
const modelSchemaMod2 = _ns_24;
|
|
12724
12901
|
const { properties: propertiesTable } = modelSchemaMod2;
|
|
@@ -12754,7 +12931,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
12754
12931
|
// This is important even if nothing changed, to ensure consistency
|
|
12755
12932
|
const updatedSchemaData = JSON.stringify(schemaFile, null, 2);
|
|
12756
12933
|
// Update the schema record in the database with current schemaData
|
|
12757
|
-
const _mod_25 = await import('./BasePathResolver-
|
|
12934
|
+
const _mod_25 = await import('./BasePathResolver-DWY_hb8w.js');
|
|
12758
12935
|
const _ns_25 = _mod_25.S;
|
|
12759
12936
|
const schemaSchemaMod = _ns_25;
|
|
12760
12937
|
const { schemas: schemasTable } = schemaSchemaMod;
|
|
@@ -13435,6 +13612,8 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
13435
13612
|
|
|
13436
13613
|
/** Emitted by the client manager after `app_state.addresses` is written (post-`setAddresses`). */
|
|
13437
13614
|
const ADDRESSES_PERSISTED_EVENT = 'addresses.persisted';
|
|
13615
|
+
/** Emitted after hard-deleting local on-chain seed copies for publisher addresses. */
|
|
13616
|
+
const LOCAL_COPIES_REMOVED_EVENT = 'localCopies.removed';
|
|
13438
13617
|
function parseAddressesPersistedPayload(value) {
|
|
13439
13618
|
if (!value || typeof value !== 'object') {
|
|
13440
13619
|
return { owned: [], watched: [] };
|
|
@@ -14113,6 +14292,168 @@ async function getPublishedSeedRecord(seedUid, options) {
|
|
|
14113
14292
|
return getSeed(seedUid, { ...options, source });
|
|
14114
14293
|
}
|
|
14115
14294
|
|
|
14295
|
+
const READ_ONLY_ERROR = 'Item is read-only: you do not own this item';
|
|
14296
|
+
async function getSeedRowForItem(item) {
|
|
14297
|
+
const appDb = BaseDb.getAppDb();
|
|
14298
|
+
if (!appDb)
|
|
14299
|
+
return null;
|
|
14300
|
+
const conditions = [];
|
|
14301
|
+
if (item.seedLocalId)
|
|
14302
|
+
conditions.push(eq(seeds.localId, item.seedLocalId));
|
|
14303
|
+
if (item.seedUid)
|
|
14304
|
+
conditions.push(eq(seeds.uid, item.seedUid));
|
|
14305
|
+
if (conditions.length === 0)
|
|
14306
|
+
return null;
|
|
14307
|
+
const seedRows = await appDb
|
|
14308
|
+
.select({
|
|
14309
|
+
publisher: seeds.publisher,
|
|
14310
|
+
attestationRaw: seeds.attestationRaw,
|
|
14311
|
+
uid: seeds.uid,
|
|
14312
|
+
})
|
|
14313
|
+
.from(seeds)
|
|
14314
|
+
.where(conditions.length === 1 ? conditions[0] : or(...conditions))
|
|
14315
|
+
.limit(1);
|
|
14316
|
+
if (!seedRows || seedRows.length === 0)
|
|
14317
|
+
return null;
|
|
14318
|
+
return seedRows[0];
|
|
14319
|
+
}
|
|
14320
|
+
/** Resolve publisher from seed row: `publisher` column, else `attestationRaw.attester`. */
|
|
14321
|
+
function resolvePublisherFromSeedRow(row) {
|
|
14322
|
+
if (row.publisher)
|
|
14323
|
+
return row.publisher;
|
|
14324
|
+
if (row.attestationRaw) {
|
|
14325
|
+
try {
|
|
14326
|
+
const parsed = JSON.parse(row.attestationRaw);
|
|
14327
|
+
return parsed.attester ?? null;
|
|
14328
|
+
}
|
|
14329
|
+
catch {
|
|
14330
|
+
return null;
|
|
14331
|
+
}
|
|
14332
|
+
}
|
|
14333
|
+
return null;
|
|
14334
|
+
}
|
|
14335
|
+
/**
|
|
14336
|
+
* Checks if the current user owns the item (publisher is in owned addresses).
|
|
14337
|
+
* Locally created items (no publisher, no attestationRaw) are considered owned.
|
|
14338
|
+
* Includes getAdditionalSyncAddresses (e.g. `modularAccountModuleContract` when configured)
|
|
14339
|
+
* so ownership aligns with EAS sync when the publisher/attester matches those addresses.
|
|
14340
|
+
*/
|
|
14341
|
+
async function isItemOwned(item) {
|
|
14342
|
+
const row = await getSeedRowForItem(item);
|
|
14343
|
+
if (!row)
|
|
14344
|
+
return false;
|
|
14345
|
+
const publisher = resolvePublisherFromSeedRow(row);
|
|
14346
|
+
if (!publisher) {
|
|
14347
|
+
if (!row.uid && !row.attestationRaw) {
|
|
14348
|
+
return true;
|
|
14349
|
+
}
|
|
14350
|
+
return false;
|
|
14351
|
+
}
|
|
14352
|
+
let addressesToCheck = await getOwnedAddressesFromDb();
|
|
14353
|
+
const additionalGetter = getGetAdditionalSyncAddresses();
|
|
14354
|
+
if (additionalGetter) {
|
|
14355
|
+
const additional = await additionalGetter();
|
|
14356
|
+
if (additional?.length) {
|
|
14357
|
+
const seen = new Set(addressesToCheck.map((a) => a.toLowerCase()));
|
|
14358
|
+
for (const addr of additional) {
|
|
14359
|
+
if (addr && !seen.has(addr.toLowerCase())) {
|
|
14360
|
+
seen.add(addr.toLowerCase());
|
|
14361
|
+
addressesToCheck = [...addressesToCheck, addr];
|
|
14362
|
+
}
|
|
14363
|
+
}
|
|
14364
|
+
}
|
|
14365
|
+
}
|
|
14366
|
+
const ownedSet = new Set(addressesToCheck.map((a) => a.toLowerCase()));
|
|
14367
|
+
return ownedSet.has(publisher.toLowerCase());
|
|
14368
|
+
}
|
|
14369
|
+
/**
|
|
14370
|
+
* Throws if the item is not owned. Use before write operations (publish, save, destroy).
|
|
14371
|
+
*/
|
|
14372
|
+
async function assertItemOwned(item) {
|
|
14373
|
+
const owned = await isItemOwned(item);
|
|
14374
|
+
if (!owned) {
|
|
14375
|
+
throw new Error(READ_ONLY_ERROR);
|
|
14376
|
+
}
|
|
14377
|
+
}
|
|
14378
|
+
|
|
14379
|
+
var ownership = /*#__PURE__*/Object.freeze({
|
|
14380
|
+
__proto__: null,
|
|
14381
|
+
assertItemOwned: assertItemOwned,
|
|
14382
|
+
isItemOwned: isItemOwned,
|
|
14383
|
+
resolvePublisherFromSeedRow: resolvePublisherFromSeedRow
|
|
14384
|
+
});
|
|
14385
|
+
|
|
14386
|
+
const emptyResult = () => ({
|
|
14387
|
+
removedSeedLocalIds: [],
|
|
14388
|
+
removedSeedUids: [],
|
|
14389
|
+
});
|
|
14390
|
+
function normalizeAddresses(addresses) {
|
|
14391
|
+
return [
|
|
14392
|
+
...new Set(addresses
|
|
14393
|
+
.filter((a) => typeof a === 'string' && a.length > 0)
|
|
14394
|
+
.map((a) => a.toLowerCase())),
|
|
14395
|
+
];
|
|
14396
|
+
}
|
|
14397
|
+
/**
|
|
14398
|
+
* Find local on-chain seed copies for the given publisher addresses (no delete).
|
|
14399
|
+
* Drafts (no uid and no attestationRaw) are excluded.
|
|
14400
|
+
*/
|
|
14401
|
+
async function findLocalOnchainCopiesForAddresses(addresses) {
|
|
14402
|
+
const normalized = normalizeAddresses(addresses);
|
|
14403
|
+
if (normalized.length === 0) {
|
|
14404
|
+
return emptyResult();
|
|
14405
|
+
}
|
|
14406
|
+
const appDb = BaseDb.getAppDb();
|
|
14407
|
+
if (!appDb) {
|
|
14408
|
+
return emptyResult();
|
|
14409
|
+
}
|
|
14410
|
+
const addressSet = new Set(normalized);
|
|
14411
|
+
const candidateRows = (await appDb
|
|
14412
|
+
.select({
|
|
14413
|
+
localId: seeds.localId,
|
|
14414
|
+
uid: seeds.uid,
|
|
14415
|
+
publisher: seeds.publisher,
|
|
14416
|
+
attestationRaw: seeds.attestationRaw,
|
|
14417
|
+
})
|
|
14418
|
+
.from(seeds)
|
|
14419
|
+
.where(or(isNotNull(seeds.uid), isNotNull(seeds.attestationRaw))));
|
|
14420
|
+
const matched = candidateRows.filter((row) => {
|
|
14421
|
+
if (!row.localId)
|
|
14422
|
+
return false;
|
|
14423
|
+
const publisher = resolvePublisherFromSeedRow(row);
|
|
14424
|
+
return publisher != null && addressSet.has(publisher.toLowerCase());
|
|
14425
|
+
});
|
|
14426
|
+
return {
|
|
14427
|
+
removedSeedLocalIds: matched.map((r) => r.localId).filter(Boolean),
|
|
14428
|
+
removedSeedUids: matched
|
|
14429
|
+
.map((r) => r.uid)
|
|
14430
|
+
.filter((u) => typeof u === 'string' && u.length > 0),
|
|
14431
|
+
};
|
|
14432
|
+
}
|
|
14433
|
+
/**
|
|
14434
|
+
* Hard-delete the given seed local ids and related local rows (cascade).
|
|
14435
|
+
* Does not touch schemas, app_state, or chain.
|
|
14436
|
+
*/
|
|
14437
|
+
async function hardDeleteLocalSeedsByLocalIds(seedLocalIds) {
|
|
14438
|
+
if (seedLocalIds.length === 0)
|
|
14439
|
+
return;
|
|
14440
|
+
const appDb = BaseDb.getAppDb();
|
|
14441
|
+
if (!appDb)
|
|
14442
|
+
return;
|
|
14443
|
+
await appDb
|
|
14444
|
+
.delete(htmlEmbeddedImageCoPublish)
|
|
14445
|
+
.where(or(inArray(htmlEmbeddedImageCoPublish.parentSeedLocalId, seedLocalIds), inArray(htmlEmbeddedImageCoPublish.htmlSeedLocalId, seedLocalIds), inArray(htmlEmbeddedImageCoPublish.imageSeedLocalId, seedLocalIds)));
|
|
14446
|
+
await appDb
|
|
14447
|
+
.delete(arweaveL1FinalizeJobs)
|
|
14448
|
+
.where(inArray(arweaveL1FinalizeJobs.seedLocalId, seedLocalIds));
|
|
14449
|
+
await appDb
|
|
14450
|
+
.delete(publishProcesses)
|
|
14451
|
+
.where(inArray(publishProcesses.seedLocalId, seedLocalIds));
|
|
14452
|
+
await appDb.delete(metadata$1).where(inArray(metadata$1.seedLocalId, seedLocalIds));
|
|
14453
|
+
await appDb.delete(versions).where(inArray(versions.seedLocalId, seedLocalIds));
|
|
14454
|
+
await appDb.delete(seeds).where(inArray(seeds.localId, seedLocalIds));
|
|
14455
|
+
}
|
|
14456
|
+
|
|
14116
14457
|
const logger$1 = debug('seedSdk:client');
|
|
14117
14458
|
const clientManager = createActor(clientManagerMachine, {
|
|
14118
14459
|
input: {
|
|
@@ -14241,6 +14582,29 @@ const clientInstance = {
|
|
|
14241
14582
|
ensureInitialized();
|
|
14242
14583
|
return getWatchedAddressesFromDb();
|
|
14243
14584
|
},
|
|
14585
|
+
/**
|
|
14586
|
+
* Hard-delete local on-chain seed copies for the given publisher addresses.
|
|
14587
|
+
* Drafts (no uid / attestationRaw) are kept. Chain is untouched; reconnect can rehydrate via syncFromEas.
|
|
14588
|
+
*/
|
|
14589
|
+
removeLocalCopiesForAddresses: async (addresses) => {
|
|
14590
|
+
ensureInitialized();
|
|
14591
|
+
const list = Array.isArray(addresses) ? addresses : [];
|
|
14592
|
+
const matched = await findLocalOnchainCopiesForAddresses(list);
|
|
14593
|
+
const cacheIds = [
|
|
14594
|
+
...matched.removedSeedLocalIds,
|
|
14595
|
+
...matched.removedSeedUids,
|
|
14596
|
+
];
|
|
14597
|
+
if (cacheIds.length > 0) {
|
|
14598
|
+
Item.dropCachedInstancesForSeedIds(cacheIds);
|
|
14599
|
+
}
|
|
14600
|
+
await hardDeleteLocalSeedsByLocalIds(matched.removedSeedLocalIds);
|
|
14601
|
+
eventEmitter.emit(LOCAL_COPIES_REMOVED_EVENT, {
|
|
14602
|
+
addresses: list,
|
|
14603
|
+
removedSeedLocalIds: matched.removedSeedLocalIds,
|
|
14604
|
+
removedSeedUids: matched.removedSeedUids,
|
|
14605
|
+
});
|
|
14606
|
+
return matched;
|
|
14607
|
+
},
|
|
14244
14608
|
/**
|
|
14245
14609
|
* Syncs item attestations from EAS for the configured models and given addresses.
|
|
14246
14610
|
* Uses owned + watched addresses from DB when addresses are not provided.
|
|
@@ -14468,7 +14832,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
|
|
|
14468
14832
|
// Lazy import cache for ModelProperty to avoid circular dependency
|
|
14469
14833
|
// Eagerly start loading to minimize delay on first access
|
|
14470
14834
|
let ModelPropertyClass = null;
|
|
14471
|
-
const modelPropertyImportPromise = import('./ModelProperty-
|
|
14835
|
+
const modelPropertyImportPromise = import('./ModelProperty-DGJf78CS.js')
|
|
14472
14836
|
.then(module => {
|
|
14473
14837
|
ModelPropertyClass = module.ModelProperty;
|
|
14474
14838
|
return ModelPropertyClass;
|
|
@@ -14485,7 +14849,7 @@ function getModelProperty() {
|
|
|
14485
14849
|
}
|
|
14486
14850
|
// Lazy import cache for Schema to avoid circular dependency
|
|
14487
14851
|
let SchemaClass = null;
|
|
14488
|
-
const schemaImportPromise = (async () => { const _mod_26 = await import('./Schema-
|
|
14852
|
+
const schemaImportPromise = (async () => { const _mod_26 = await import('./Schema-Drmce3q-.js'); return _mod_26.b; })()
|
|
14489
14853
|
.then(module => {
|
|
14490
14854
|
SchemaClass = module.Schema;
|
|
14491
14855
|
return SchemaClass;
|
|
@@ -16225,5 +16589,5 @@ var Model$1 = /*#__PURE__*/Object.freeze({
|
|
|
16225
16589
|
const TModelValues = Type.Record(Type.String(), Type.Any());
|
|
16226
16590
|
const TModelSchema = Type.Record(Type.String(), TProperty);
|
|
16227
16591
|
|
|
16228
|
-
export {
|
|
16229
|
-
//# sourceMappingURL=index-
|
|
16592
|
+
export { registerSeedQueryLocalSource as $, compareMetadataRowsLatestFirst as A, ADDRESSES_PERSISTED_EVENT as B, ClientManager as C, createLocalQueryDataSource as D, createNewItem as E, createSchema as F, easSyncActor as G, getClient as H, Item as I, getGetPublisherForNewSeeds as J, getMetadataLatest as K, LOCAL_COPIES_REMOVED_EVENT as L, Model as M, getPublishedSeedRecord as N, getRevokeExecutor as O, getSchemaNameFromId as P, getUploadExecutor as Q, getVersionData$1 as R, isItemOwned as S, TModelSchema as T, isSeedQueryLocalSourceRegistered as U, listCompleteSchemaFiles as V, loadAllSchemasFromDb as W, mergeEasSyncRequestIntents as X, parseAddressesPersistedPayload as Y, propertyMachine as Z, readSchema as _, TModelValues as a, requestEasSyncFromAddressChange as a0, requestEasSyncFromEventBus as a1, requestEasSyncFromModelsInit as a2, sendEasSyncClientRequest as a3, setAdditionalSyncAddresses as a4, setGetPublisherForNewSeeds as a5, setRevokeExecutor as a6, setUploadExecutor as a7, startEasSyncActor as a8, unregisterSeedQueryLocalSource as a9, createModelsFromJson as aa, getLatestSchemaVersion as ab, createModelFromJson as ac, ConflictError as ad, unloadEntity as ae, clearDestroySubscriptions as af, setupEntityLiveQuery as ag, publishConfig as ah, generateId$1 as ai, model as aj, getPropertyData$1 as ak, Item$1 as al, schema as am, SEEDPROTOCOL_Seed_Protocol_v1 as an, Model$1 as ao, getItemData as b, getEasSchemaUidForModel as c, getLatestPublishedVersionRow as d, getEasSchemaForItemProperty as e, eventEmitter as f, getContentHash as g, generateId as h, getGetAdditionalSyncAddresses as i, ItemProperty as j, getRefValueType as k, importJsonSchema as l, modelPropertiesToObject as m, loadSchemaFromFile as n, readJsonImportFile as o, parseListPropertyValueFromStorage as p, syncSchemaFromSource as q, resolveStorageNameToSchemaName as r, scheduleBulkFilesDownloadFromEasSync as s, transformImportToSchemaFile as t, waitForEntityIdle as u, createReactiveProxy as v, writeProcessMachine as w, findEntity as x, forceRemoveFromCaches as y, runDestroyLifecycle as z };
|
|
16593
|
+
//# sourceMappingURL=index-B4In0GEO.js.map
|