@seedprotocol/sdk 0.7.5-next.871.g8788c94 → 0.7.5

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.
Files changed (82) hide show
  1. package/dist/{BasePathResolver-B-fK7_N_.js → BasePathResolver-CBTXCMFL.js} +18 -4
  2. package/dist/BasePathResolver-CBTXCMFL.js.map +1 -0
  3. package/dist/{ClientManager-C7VkO5Hg.js → ClientManager-DRf4uuei.js} +48 -48
  4. package/dist/ClientManager-DRf4uuei.js.map +1 -0
  5. package/dist/{Item-BDmsdNTQ.js → Item-DTJPMjFk.js} +69 -56
  6. package/dist/Item-DTJPMjFk.js.map +1 -0
  7. package/dist/{ModelProperty-Cqw6yn7y.js → ModelProperty-Dto5C0om.js} +65 -30
  8. package/dist/ModelProperty-Dto5C0om.js.map +1 -0
  9. package/dist/{Schema-BJLYOUgp.js → Schema-8DxGcORY.js} +38 -36
  10. package/dist/{Schema-BJLYOUgp.js.map → Schema-8DxGcORY.js.map} +1 -1
  11. package/dist/{SchemaValidationService-CzybXLiS.js → SchemaValidationService-CE92y1TT.js} +6 -6
  12. package/dist/{SchemaValidationService-CzybXLiS.js.map → SchemaValidationService-CE92y1TT.js.map} +1 -1
  13. package/dist/{backfillMetadataPropertyIds-DAsETfD_.js → backfillMetadataPropertyIds-CRqp-BqX.js} +3 -3
  14. package/dist/{backfillMetadataPropertyIds-DAsETfD_.js.map → backfillMetadataPropertyIds-CRqp-BqX.js.map} +1 -1
  15. package/dist/{configurePlatform-CFQF_i1T.js → configurePlatform-D4aGjKNk.js} +2 -2
  16. package/dist/{configurePlatform-CFQF_i1T.js.map → configurePlatform-D4aGjKNk.js.map} +1 -1
  17. package/dist/{detachRowsBeforeDelete-D4gxxk46.js → detachRowsBeforeDelete-BVetHtn2.js} +2 -2
  18. package/dist/{detachRowsBeforeDelete-D4gxxk46.js.map → detachRowsBeforeDelete-BVetHtn2.js.map} +1 -1
  19. package/dist/{discardNewDraft-g8w3uHFM.js → discardNewDraft-CEOouygG.js} +5 -5
  20. package/dist/{discardNewDraft-g8w3uHFM.js.map → discardNewDraft-CEOouygG.js.map} +1 -1
  21. package/dist/{eas-BcXZ2hIn.js → eas-D7jvWMnI.js} +3 -3
  22. package/dist/{eas-BcXZ2hIn.js.map → eas-D7jvWMnI.js.map} +1 -1
  23. package/dist/{errors-CCMxedOB.js → errors-CIrbsN_i.js} +43 -38
  24. package/dist/errors-CIrbsN_i.js.map +1 -0
  25. package/dist/{getItem-BUs1Xa48.js → getItem-CxU_kT5W.js} +4 -4
  26. package/dist/{getItem-BUs1Xa48.js.map → getItem-CxU_kT5W.js.map} +1 -1
  27. package/dist/{getPublishPayload-CwNOhnir.js → getPublishPayload-DTjOKd3y.js} +13 -13
  28. package/dist/{getPublishPayload-CwNOhnir.js.map → getPublishPayload-DTjOKd3y.js.map} +1 -1
  29. package/dist/{getPublishUploads-pEOrXJbF.js → getPublishUploads-CVTBo_OV.js} +6 -6
  30. package/dist/{getPublishUploads-pEOrXJbF.js.map → getPublishUploads-CVTBo_OV.js.map} +1 -1
  31. package/dist/{index-zAs84LDi.js → index-CMxEil8T.js} +8 -8
  32. package/dist/index-CMxEil8T.js.map +1 -0
  33. package/dist/{index-BQSK-r_A.js → index-DWK-LOUY.js} +2 -2
  34. package/dist/index-DWK-LOUY.js.map +1 -0
  35. package/dist/{index.browser-irwaBIj0.js → index.browser-shRXMeB3.js} +10 -10
  36. package/dist/{index.browser-irwaBIj0.js.map → index.browser-shRXMeB3.js.map} +1 -1
  37. package/dist/{index.node-BYkndQN7.js → index.node-DAKJNYp5.js} +20 -6
  38. package/dist/index.node-DAKJNYp5.js.map +1 -0
  39. package/dist/main.js +22 -22
  40. package/dist/node.js +10 -10
  41. package/dist/platform.browser.js +5 -5
  42. package/dist/platform.node.js +4 -4
  43. package/dist/{property-5AD2naVS.js → property-lz9yIpyA.js} +6 -6
  44. package/dist/{property-5AD2naVS.js.map → property-lz9yIpyA.js.map} +1 -1
  45. package/dist/{propertyValidationRules-Bdgz0Nrr.js → propertyValidationRules-LuIwoQoJ.js} +6 -6
  46. package/dist/{propertyValidationRules-Bdgz0Nrr.js.map → propertyValidationRules-LuIwoQoJ.js.map} +1 -1
  47. package/dist/{publishDraftGraph-DGhC9ifI.js → publishDraftGraph-CgSLPKvQ.js} +6 -6
  48. package/dist/{publishDraftGraph-DGhC9ifI.js.map → publishDraftGraph-CgSLPKvQ.js.map} +1 -1
  49. package/dist/{resetAmbiguousLegacyItemData-HSB77N9c.js → resetAmbiguousLegacyItemData-CuamkAAh.js} +2 -2
  50. package/dist/{resetAmbiguousLegacyItemData-HSB77N9c.js.map → resetAmbiguousLegacyItemData-CuamkAAh.js.map} +1 -1
  51. package/dist/{resolveModelForSyncedSeed-CAKAJgr6.js → resolveModelForSyncedSeed-BbSctSvz.js} +2 -2
  52. package/dist/{resolveModelForSyncedSeed-CAKAJgr6.js.map → resolveModelForSyncedSeed-BbSctSvz.js.map} +1 -1
  53. package/dist/src/Item/Item.d.ts +5 -0
  54. package/dist/src/Item/Item.d.ts.map +1 -1
  55. package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
  56. package/dist/src/Model/Model.d.ts.map +1 -1
  57. package/dist/src/Model/service/actors/createModelProperties.d.ts.map +1 -1
  58. package/dist/src/ModelProperty/ModelProperty.d.ts +17 -0
  59. package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
  60. package/dist/src/Schema/Schema.d.ts.map +1 -1
  61. package/dist/src/client/ClientManager.d.ts +2 -2
  62. package/dist/src/client/ClientManager.d.ts.map +1 -1
  63. package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
  64. package/dist/src/helpers/db.d.ts.map +1 -1
  65. package/dist/src/node/db/Db.d.ts.map +1 -1
  66. package/dist/{syncDbWithEas-BmJXqfgN.js → syncDbWithEas-CrAY9Rl2.js} +13 -13
  67. package/dist/{syncDbWithEas-BmJXqfgN.js.map → syncDbWithEas-CrAY9Rl2.js.map} +1 -1
  68. package/dist/{tabEvents-DXun7vdK.js → tabEvents-BGBYV65P.js} +4 -4
  69. package/dist/{tabEvents-DXun7vdK.js.map → tabEvents-BGBYV65P.js.map} +1 -1
  70. package/dist/{tolerantWebAccess-DXxgX2x7.js → tolerantWebAccess-DVHCEulL.js} +6 -6
  71. package/dist/{tolerantWebAccess-DXxgX2x7.js.map → tolerantWebAccess-DVHCEulL.js.map} +1 -1
  72. package/dist/{updateSeedRevokedAt-DkLSDwUX.js → updateSeedRevokedAt-Dy5J8CfQ.js} +3 -3
  73. package/dist/{updateSeedRevokedAt-DkLSDwUX.js.map → updateSeedRevokedAt-Dy5J8CfQ.js.map} +1 -1
  74. package/package.json +5 -5
  75. package/dist/BasePathResolver-B-fK7_N_.js.map +0 -1
  76. package/dist/ClientManager-C7VkO5Hg.js.map +0 -1
  77. package/dist/Item-BDmsdNTQ.js.map +0 -1
  78. package/dist/ModelProperty-Cqw6yn7y.js.map +0 -1
  79. package/dist/errors-CCMxedOB.js.map +0 -1
  80. package/dist/index-BQSK-r_A.js.map +0 -1
  81. package/dist/index-zAs84LDi.js.map +0 -1
  82. package/dist/index.node-BYkndQN7.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { waitFor, fromCallback, setup, assign, stateIn, createActor, isMachineSnapshot } from 'xstate';
2
- import { B as BaseDb, F as versions, m as metadata, C as seeds, G as resolveStorageNameToSchemaName, a_ as toSchemaPropertyName, A as schemas, t as models, r as modelSchemas, aY as getOwnedAddressesFromDb, a5 as ZERO_BYTES32, aG as normalizeAddressList, am as normalizeHexAddress, aD as getAddressesForItemsFilter, a9 as INTERNAL_PROPERTY_NAMES, h as BaseFileManager, a$ as getStorageTransactionIdForSeedUid, b0 as convertTxIdToImage, i as isDataType, ah as normalizePublisher, n as normalizeDataType, b1 as getMetadataPropertyNamesForQuery, aC as ensureImageLocal, au as ImageSize, b2 as downloadTransactionIdWithDedupe, b3 as resolveMetadataRecord, v as properties, M as ModelPropertyDataTypes, al as generateId, ac as INTERNAL_DATA_TYPES, s as modelUids, ad as listRelationEasPropertyName, ae as easPropertyNameForPublish, N as resolveItemModelFileId, b4 as getPropertyIdForSchemaFileId, L as getPropertyIdForModelAndName, an as toMetadataPropertyName, b5 as getDataTypeFromString, b6 as getMimeType, _ as INTERNAL_STORAGE_MODEL_FILE_IDS, a2 as getItemStorageSubdir, a3 as getItemStorageLocalFileName, g as normalizePropertyRecordSchema, b7 as listRelationStoragePropertyName, b8 as PROPERTY_NAMES_EXEMPT_FROM_ID_SUFFIX_STRIP, R as getCorrectId, I as eventEmitter, b9 as getAlternatePropertyNameForInstanceLookup, aa as isStorageSeedRef } from './BasePathResolver-B-fK7_N_.js';
2
+ import { B as BaseDb, F as versions, m as metadata, C as seeds, G as resolveStorageNameToSchemaName, a_ as toSchemaPropertyName, A as schemas, t as models, r as modelSchemas, aY as getOwnedAddressesFromDb, a5 as ZERO_BYTES32, aG as normalizeAddressList, am as normalizeHexAddress, aD as getAddressesForItemsFilter, a9 as INTERNAL_PROPERTY_NAMES, h as BaseFileManager, a$ as getStorageTransactionIdForSeedUid, b0 as convertTxIdToImage, i as isDataType, ah as normalizePublisher, n as normalizeDataType, b1 as getMetadataPropertyNamesForQuery, aC as ensureImageLocal, au as ImageSize, b2 as downloadTransactionIdWithDedupe, b3 as resolveMetadataRecord, v as properties, M as ModelPropertyDataTypes, al as generateId, ac as INTERNAL_DATA_TYPES, s as modelUids, ad as listRelationEasPropertyName, ae as easPropertyNameForPublish, N as resolveItemModelFileId, b4 as getPropertyIdForSchemaFileId, L as getPropertyIdForModelAndName, an as toMetadataPropertyName, b5 as getDataTypeFromString, b6 as getMimeType, _ as INTERNAL_STORAGE_MODEL_FILE_IDS, a2 as getItemStorageSubdir, a3 as getItemStorageLocalFileName, g as normalizePropertyRecordSchema, b7 as listRelationStoragePropertyName, b8 as PROPERTY_NAMES_EXEMPT_FROM_ID_SUFFIX_STRIP, R as getCorrectId, I as eventEmitter, b9 as getAlternatePropertyNameForInstanceLookup, aa as isStorageSeedRef } from './BasePathResolver-CBTXCMFL.js';
3
3
  import { or, isNull, eq, max, count, and, getTableColumns, sql, desc, inArray, isNotNull, gt } from 'drizzle-orm';
4
4
  import debug from 'debug';
5
5
  import { BehaviorSubject } from 'rxjs';
@@ -7,7 +7,7 @@ import pluralize from 'pluralize';
7
7
  import { startCase, upperFirst, camelCase, orderBy } from 'lodash-es';
8
8
  import { isValidEasAttestationUid, easName, isPlaceholderUid, BaseQueryClient, BaseEasClient, GET_SCHEMAS, getEasSchemaUidForSchemaDefinition, getSchemaUidForModelFromCache, setSchemaUidForModel, cachedSchemaLookup, getEasSchemaUidForExactDefinition } from '@seedprotocol/eas';
9
9
  import { fetchArweaveRawTextAcrossGateways } from '@seedprotocol/arweave';
10
- import { d as notifyFileSaved, f as withTabLock } from './tabEvents-DXun7vdK.js';
10
+ import { d as notifyFileSaved, f as withTabLock } from './tabEvents-BGBYV65P.js';
11
11
  import { modelPropertiesToObject } from './model-oHA3YhOd.js';
12
12
 
13
13
  /**
@@ -580,7 +580,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
580
580
  const itemPropertyMod = await Promise.resolve().then(function () { return ItemProperty$1; });
581
581
  const { ItemProperty } = itemPropertyMod;
582
582
  const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
583
- const _mod_0 = await import('./errors-CCMxedOB.js');
583
+ const _mod_0 = await import('./errors-CIrbsN_i.js');
584
584
  const _ns_0 = _mod_0.h;
585
585
  const { Model } = _ns_0;
586
586
  // Resolve Model and build property schemas (use getByNameAsync for models not yet in cache)
@@ -598,7 +598,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
598
598
  const schemaNameToTry = schemaName ?? model?.schemaName;
599
599
  if (schemaNameToTry) {
600
600
  try {
601
- const _mod_1 = await import('./Schema-BJLYOUgp.js');
601
+ const _mod_1 = await import('./Schema-8DxGcORY.js');
602
602
  const _ns_1 = _mod_1.b;
603
603
  const { Schema } = _ns_1;
604
604
  const schemaInstance = Schema.create(schemaNameToTry, { waitForReady: false });
@@ -614,7 +614,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
614
614
  }
615
615
  if (Object.keys(propertySchemas).length === 0) {
616
616
  try {
617
- const _mod_2 = await import('./ClientManager-C7VkO5Hg.js');
617
+ const _mod_2 = await import('./ClientManager-DRf4uuei.js');
618
618
  const _ns_2 = _mod_2.M;
619
619
  const { loadAllSchemasFromDb } = _ns_2;
620
620
  const allSchemas = await loadAllSchemasFromDb();
@@ -635,10 +635,10 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
635
635
  }
636
636
  if (Object.keys(propertySchemas).length === 0) {
637
637
  try {
638
- const _mod_3 = await import('./ClientManager-C7VkO5Hg.js');
638
+ const _mod_3 = await import('./ClientManager-DRf4uuei.js');
639
639
  const _ns_3 = _mod_3.M;
640
640
  const { listCompleteSchemaFiles } = _ns_3;
641
- const _mod_4 = await import('./BasePathResolver-B-fK7_N_.js');
641
+ const _mod_4 = await import('./BasePathResolver-CBTXCMFL.js');
642
642
  const _ns_4 = _mod_4.bc;
643
643
  const { BaseFileManager } = _ns_4;
644
644
  const schemaFiles = await listCompleteSchemaFiles();
@@ -659,7 +659,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
659
659
  }
660
660
  }
661
661
  if (Object.keys(propertySchemas).length === 0) {
662
- const schemaMod = await import('./index-zAs84LDi.js');
662
+ const schemaMod = await import('./index-CMxEil8T.js');
663
663
  const { ModelPropertyDataTypes } = schemaMod;
664
664
  const KNOWN_MODEL_FALLBACKS = {
665
665
  Post: {
@@ -676,7 +676,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
676
676
  }
677
677
  }
678
678
  // Fallbacks above may return schema-file shape ({ type, model, items }); normalize to dataType/ref/refValueType.
679
- const { normalizePropertyRecordSchema } = await import('./property-5AD2naVS.js');
679
+ const { normalizePropertyRecordSchema } = await import('./property-lz9yIpyA.js');
680
680
  propertySchemas = Object.fromEntries(Object.entries(propertySchemas).map(([name, def]) => [name, normalizePropertyRecordSchema(def)]));
681
681
  // Collapse rows that map to the same instance key (e.g. authorIdentityIds + authors -> authors).
682
682
  // ItemProperty.create cache does not sync propertyValue on hit; processing order would otherwise
@@ -709,7 +709,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
709
709
  // Infer propertyRecordSchema from metadata when schema is missing (enables persistence)
710
710
  let propSchema = propertySchemas[propertyName];
711
711
  if (!propSchema && isRefTypeFromMeta) {
712
- const schemaMod = await import('./index-zAs84LDi.js');
712
+ const schemaMod = await import('./index-CMxEil8T.js');
713
713
  const { ModelPropertyDataTypes } = schemaMod;
714
714
  propSchema = {
715
715
  dataType: refSeedType === 'html' ? ModelPropertyDataTypes.Html
@@ -1711,7 +1711,7 @@ const getItemsData = async ({ modelName, modelFileId, schemaName, deleted, inclu
1711
1711
  conditions.push(eq(seeds.type, easName(modelName)));
1712
1712
  }
1713
1713
  if (!modelFileId && schemaName && modelName) {
1714
- const _mod_5 = await import('./BasePathResolver-B-fK7_N_.js');
1714
+ const _mod_5 = await import('./BasePathResolver-CBTXCMFL.js');
1715
1715
  const _ns_5 = _mod_5.bf;
1716
1716
  const { resolveModelRecord } = _ns_5;
1717
1717
  modelFileId = (await resolveModelRecord(modelName, { schemaName }))?.schemaFileId ?? undefined;
@@ -1994,7 +1994,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
1994
1994
  const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
1995
1995
  const _resolveRelatedValue = async () => {
1996
1996
  // Use dynamic import to break circular dependency
1997
- const schemaMod = await import('./index-zAs84LDi.js');
1997
+ const schemaMod = await import('./index-CMxEil8T.js');
1998
1998
  const { ModelPropertyDataTypes } = schemaMod;
1999
1999
  if (!propertyValue || !isRelation || populatedFromDb) {
2000
2000
  return;
@@ -2429,7 +2429,7 @@ async function readHtmlBodyFromChildStorageArweave(seedLocalId) {
2429
2429
  /* offline / bad tx id */
2430
2430
  }
2431
2431
  try {
2432
- const _mod_6 = await import('./BasePathResolver-B-fK7_N_.js');
2432
+ const _mod_6 = await import('./BasePathResolver-CBTXCMFL.js');
2433
2433
  const _ns_6 = _mod_6.bh;
2434
2434
  const { downloadTransactionIdWithDedupe } = _ns_6;
2435
2435
  await downloadTransactionIdWithDedupe(txId);
@@ -2490,7 +2490,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
2490
2490
  // to use dynamically imported ModelPropertyDataTypes
2491
2491
  const _hydrateFromDb = async () => {
2492
2492
  // Use dynamic import to break circular dependency
2493
- const schemaMod = await import('./index-zAs84LDi.js');
2493
+ const schemaMod = await import('./index-CMxEil8T.js');
2494
2494
  const { ModelPropertyDataTypes } = schemaMod;
2495
2495
  const appDb = BaseDb.getAppDb();
2496
2496
  const whereClauses = [];
@@ -2771,11 +2771,11 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
2771
2771
  const modelNameForNew = context.modelName;
2772
2772
  if (modelNameForNew) {
2773
2773
  try {
2774
- const _mod_7 = await import('./errors-CCMxedOB.js');
2774
+ const _mod_7 = await import('./errors-CIrbsN_i.js');
2775
2775
  const _ns_7 = _mod_7.h;
2776
2776
  const { Model } = _ns_7;
2777
2777
  const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
2778
- const _mod_8 = await import('./BasePathResolver-B-fK7_N_.js');
2778
+ const _mod_8 = await import('./BasePathResolver-CBTXCMFL.js');
2779
2779
  const _ns_8 = _mod_8.bf;
2780
2780
  const { resolveItemModelFileId } = _ns_8;
2781
2781
  const normalizedModelName = upperFirst(camelCase(modelNameForNew));
@@ -2829,7 +2829,7 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
2829
2829
  // It ends up in the context below, and later lookups by name (Model.getByName) can't match it.
2830
2830
  const modelName = context.modelName || (metadataRecord.modelType ? upperFirst(camelCase(metadataRecord.modelType)) : undefined);
2831
2831
  // Model names are only unique per schema: pin lookups to the item's own model row.
2832
- const _mod_9 = await import('./BasePathResolver-B-fK7_N_.js');
2832
+ const _mod_9 = await import('./BasePathResolver-CBTXCMFL.js');
2833
2833
  const _ns_9 = _mod_9.bf;
2834
2834
  const { resolveItemModelFileId, resolveModelRecord } = _ns_9;
2835
2835
  const modelFileId = await resolveItemModelFileId({
@@ -2874,7 +2874,7 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
2874
2874
  required: propRecord.required ?? undefined,
2875
2875
  };
2876
2876
  // Validation rules (enum, pattern, ...) aren't in the properties table
2877
- const { resolvePropertyValidationRules } = await import('./propertyValidationRules-Bdgz0Nrr.js');
2877
+ const { resolvePropertyValidationRules } = await import('./propertyValidationRules-LuIwoQoJ.js');
2878
2878
  const validation = await resolvePropertyValidationRules(normalizedModelName, propertyName, {
2879
2879
  modelFileId: modelRecord?.schemaFileId ?? modelFileId,
2880
2880
  });
@@ -2891,7 +2891,7 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
2891
2891
  }
2892
2892
  if (!propertyRecordSchema && modelName) {
2893
2893
  try {
2894
- const _mod_10 = await import('./errors-CCMxedOB.js');
2894
+ const _mod_10 = await import('./errors-CIrbsN_i.js');
2895
2895
  const _ns_10 = _mod_10.h;
2896
2896
  const { Model } = _ns_10;
2897
2897
  const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
@@ -3354,9 +3354,9 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
3354
3354
  return false;
3355
3355
  }
3356
3356
  // Use dynamic import to break circular dependency
3357
- const schemaMod = await import('./index-zAs84LDi.js');
3357
+ const schemaMod = await import('./index-CMxEil8T.js');
3358
3358
  const { ModelPropertyDataTypes } = schemaMod;
3359
- const { SchemaValidationService } = await import('./SchemaValidationService-CzybXLiS.js');
3359
+ const { SchemaValidationService } = await import('./SchemaValidationService-CE92y1TT.js');
3360
3360
  let propertyName = propertyNameRaw;
3361
3361
  if (!propertyName) {
3362
3362
  throw new Error('propertyName is required');
@@ -3679,7 +3679,7 @@ const createMetadata = async (metadataValues, propertyRecordSchema, options) =>
3679
3679
  propertyRecordSchema?.validation &&
3680
3680
  metadataValues.propertyValue != null &&
3681
3681
  metadataValues.propertyValue !== '') {
3682
- const { SchemaValidationService } = await import('./SchemaValidationService-CzybXLiS.js');
3682
+ const { SchemaValidationService } = await import('./SchemaValidationService-CE92y1TT.js');
3683
3683
  const validationService = new SchemaValidationService();
3684
3684
  const validationResult = validationService.validatePropertyValue(metadataValues.propertyValue, normalizeDataType(propertyRecordSchema.dataType), propertyRecordSchema.validation, propertyRecordSchema.refValueType
3685
3685
  ? normalizeDataType(String(propertyRecordSchema.refValueType))
@@ -4292,7 +4292,7 @@ const saveRelation = fromCallback(({ sendBack, input: { context, event } }) => {
4292
4292
  }
4293
4293
  const _saveRelation = async () => {
4294
4294
  // Use dynamic import to break circular dependency
4295
- const schemaMod = await import('./index-zAs84LDi.js');
4295
+ const schemaMod = await import('./index-CMxEil8T.js');
4296
4296
  const { ModelPropertyDataTypes } = schemaMod;
4297
4297
  if (!propertyNameRaw) {
4298
4298
  throw new Error('propertyName is required');
@@ -5011,10 +5011,10 @@ const getPropertyData = async ({ propertyName, seedLocalId, seedUid, modelName,
5011
5011
  let names = [...getMetadataPropertyNamesForQuery(propertyName)];
5012
5012
  if (modelName) {
5013
5013
  try {
5014
- const _mod_11 = await import('./errors-CCMxedOB.js');
5014
+ const _mod_11 = await import('./errors-CIrbsN_i.js');
5015
5015
  const _ns_11 = _mod_11.h;
5016
5016
  const { Model } = _ns_11;
5017
- const _mod_12 = await import('./BasePathResolver-B-fK7_N_.js');
5017
+ const _mod_12 = await import('./BasePathResolver-CBTXCMFL.js');
5018
5018
  const _ns_12 = _mod_12.bf;
5019
5019
  const { resolveItemModelFileId } = _ns_12;
5020
5020
  // Model names are only unique per schema: use the seed's own model when it is recorded.
@@ -5215,7 +5215,7 @@ const HTML_PROP_SEED_UID_RE = /^0x[a-fA-F0-9]{64}$/;
5215
5215
  */
5216
5216
  const resolvePropertyRecordSchemaFromSchemaData = async (modelName, propertyName, modelType, schemaName) => {
5217
5217
  try {
5218
- const _mod_13 = await import('./ClientManager-C7VkO5Hg.js');
5218
+ const _mod_13 = await import('./ClientManager-DRf4uuei.js');
5219
5219
  const _ns_13 = _mod_13.M;
5220
5220
  const { loadAllSchemasFromDb } = _ns_13;
5221
5221
  const allSchemas = await loadAllSchemasFromDb();
@@ -5269,11 +5269,11 @@ hints = {}) => {
5269
5269
  return undefined;
5270
5270
  }
5271
5271
  try {
5272
- const _mod_14 = await import('./errors-CCMxedOB.js');
5272
+ const _mod_14 = await import('./errors-CIrbsN_i.js');
5273
5273
  const _ns_14 = _mod_14.h;
5274
5274
  const { Model } = _ns_14;
5275
5275
  const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
5276
- const _mod_15 = await import('./BasePathResolver-B-fK7_N_.js');
5276
+ const _mod_15 = await import('./BasePathResolver-CBTXCMFL.js');
5277
5277
  const _ns_15 = _mod_15.bf;
5278
5278
  const { resolveItemModelFileId } = _ns_15;
5279
5279
  const modelFileId = await resolveItemModelFileId(hints);
@@ -5433,7 +5433,7 @@ class ItemProperty {
5433
5433
  return;
5434
5434
  }
5435
5435
  // Use dynamic import to break circular dependency
5436
- const schemaMod = await import('./index-zAs84LDi.js');
5436
+ const schemaMod = await import('./index-CMxEil8T.js');
5437
5437
  const { ModelPropertyDataTypes } = schemaMod;
5438
5438
  const { context } = snapshot;
5439
5439
  const { propertyRecordSchema } = context;
@@ -5510,7 +5510,11 @@ class ItemProperty {
5510
5510
  }
5511
5511
  }
5512
5512
  if (exists && isFile) {
5513
- renderValue = await BaseFileManager.readFileAsString(filePath);
5513
+ // A File's value is its content URL (a blob URL in browsers, file:// in Node), as saveFile
5514
+ // and hydrateFromDb set it. Reading the text here made the value change from the URL to
5515
+ // the file's contents a moment after every save or load.
5516
+ renderValue =
5517
+ context.refResolvedDisplayValue ?? (await BaseFileManager.getContentUrlFromPath(filePath));
5514
5518
  }
5515
5519
  if (!exists) {
5516
5520
  // Keep filename for display when File object is present but not yet saved to disk
@@ -5604,7 +5608,7 @@ class ItemProperty {
5604
5608
  const normalizedRefValueType = normalizeDataType(propertyRecordSchema?.refValueType);
5605
5609
  const propertyNames = getMetadataPropertyNamesForQuery(propertyName, normalizedDataType, normalizedRefValueType);
5606
5610
  const propertyNameVariant = propertyNames.length > 1 ? propertyNames[1] : undefined;
5607
- const _mod_16 = await import('./index-BQSK-r_A.js');
5611
+ const _mod_16 = await import('./index-DWK-LOUY.js');
5608
5612
  const _ns_16 = _mod_16.s;
5609
5613
  const seedSchemaMod = _ns_16;
5610
5614
  const { metadata } = seedSchemaMod;
@@ -5828,7 +5832,7 @@ class ItemProperty {
5828
5832
  const ctx = this._service.getSnapshot().context;
5829
5833
  let modelFileId;
5830
5834
  try {
5831
- const _mod_17 = await import('./BasePathResolver-B-fK7_N_.js');
5835
+ const _mod_17 = await import('./BasePathResolver-CBTXCMFL.js');
5832
5836
  const _ns_17 = _mod_17.bf;
5833
5837
  const { resolveItemModelFileId } = _ns_17;
5834
5838
  modelFileId = await resolveItemModelFileId({
@@ -6191,7 +6195,7 @@ class ItemProperty {
6191
6195
  const propertiesData = await getItemProperties({ seedLocalId, seedUid });
6192
6196
  const instances = [];
6193
6197
  const seenNormalized = new Set();
6194
- const _mod_18 = await import('./BasePathResolver-B-fK7_N_.js');
6198
+ const _mod_18 = await import('./BasePathResolver-CBTXCMFL.js');
6195
6199
  const _ns_18 = _mod_18.bf;
6196
6200
  const { resolveItemModelFileId } = _ns_18;
6197
6201
  const itemModelFileId = await resolveItemModelFileId({ seedLocalId, seedUid });
@@ -6209,7 +6213,7 @@ class ItemProperty {
6209
6213
  }
6210
6214
  else if (baseName) {
6211
6215
  try {
6212
- const _mod_19 = await import('./errors-CCMxedOB.js');
6216
+ const _mod_19 = await import('./errors-CIrbsN_i.js');
6213
6217
  const _ns_19 = _mod_19.h;
6214
6218
  const { Model } = _ns_19;
6215
6219
  const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
@@ -6226,7 +6230,7 @@ class ItemProperty {
6226
6230
  }
6227
6231
  if (modelName && propertyName) {
6228
6232
  try {
6229
- const _mod_20 = await import('./errors-CCMxedOB.js');
6233
+ const _mod_20 = await import('./errors-CIrbsN_i.js');
6230
6234
  const _ns_20 = _mod_20.h;
6231
6235
  const { Model } = _ns_20;
6232
6236
  const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
@@ -6558,7 +6562,7 @@ class ItemProperty {
6558
6562
  if (!propertyName || (!seedLocalId && !seedUid))
6559
6563
  return;
6560
6564
  if (db) {
6561
- const _mod_21 = await import('./index-BQSK-r_A.js');
6565
+ const _mod_21 = await import('./index-DWK-LOUY.js');
6562
6566
  const _ns_21 = _mod_21.s;
6563
6567
  const seedSchemaMod = _ns_21;
6564
6568
  const { metadata } = seedSchemaMod;
@@ -6603,7 +6607,7 @@ const createNewItem = async ({ modelName, modelFileId, ...propertyData }) => {
6603
6607
  }
6604
6608
  const seedType = easName(modelName);
6605
6609
  // Dynamic import to break circular dependency
6606
- const _mod_22 = await import('./errors-CCMxedOB.js');
6610
+ const _mod_22 = await import('./errors-CIrbsN_i.js');
6607
6611
  const _ns_22 = _mod_22.h;
6608
6612
  const modelMod = _ns_22;
6609
6613
  const { Model } = modelMod;
@@ -6617,7 +6621,7 @@ const createNewItem = async ({ modelName, modelFileId, ...propertyData }) => {
6617
6621
  catch (error) {
6618
6622
  // The rows are separate inserts (no transaction): remove what was written so a failure leaves
6619
6623
  // no half-made draft.
6620
- const { discardNewDraft } = await import('./discardNewDraft-g8w3uHFM.js');
6624
+ const { discardNewDraft } = await import('./discardNewDraft-CEOouygG.js');
6621
6625
  await discardNewDraft(newSeedId).catch(() => undefined);
6622
6626
  throw error;
6623
6627
  }
@@ -6798,7 +6802,7 @@ const getModel = () => {
6798
6802
  // the fragile `import(...).then(n => n.X)` chunk-namespace pattern.
6799
6803
  if (!modelImportPromise) {
6800
6804
  modelImportPromise = (async () => {
6801
- const _mod_23 = await import('./errors-CCMxedOB.js');
6805
+ const _mod_23 = await import('./errors-CIrbsN_i.js');
6802
6806
  const _ns_23 = _mod_23.h;
6803
6807
  const mod = _ns_23;
6804
6808
  ModelClass = mod.Model;
@@ -6966,14 +6970,14 @@ class Item {
6966
6970
  };
6967
6971
  this.getPublishUploads = async (options) => {
6968
6972
  // Use dynamic import to break circular dependency
6969
- const _mod_24 = await import('./getPublishUploads-pEOrXJbF.js');
6973
+ const _mod_24 = await import('./getPublishUploads-CVTBo_OV.js');
6970
6974
  const _ns_24 = _mod_24.o;
6971
6975
  const getPublishUploadsMod = _ns_24;
6972
6976
  const { getPublishUploads } = getPublishUploadsMod;
6973
6977
  return await getPublishUploads(this, [], undefined, options);
6974
6978
  };
6975
6979
  this.getPublishPayload = async (uploadedTransactions, options) => {
6976
- const _mod_25 = await import('./getPublishPayload-CwNOhnir.js');
6980
+ const _mod_25 = await import('./getPublishPayload-DTjOKd3y.js');
6977
6981
  const _ns_25 = _mod_25.g;
6978
6982
  const getPublishPayloadMod = _ns_25;
6979
6983
  const { getPublishPayload } = getPublishPayloadMod;
@@ -7235,17 +7239,20 @@ class Item {
7235
7239
  }
7236
7240
  }
7237
7241
  }
7242
+ /** Drops one holder's reference. Returns true while other holders still have the instance. */
7238
7243
  static releaseItemInstanceCacheHold(instance) {
7239
7244
  const keys = this.collectInstanceCacheKeysForInstance(instance);
7240
7245
  if (keys.length === 0)
7241
- return;
7246
+ return false;
7242
7247
  const entry = this.instanceCache.get(keys[0]);
7243
7248
  entry.refCount -= 1;
7244
7249
  if (entry.refCount <= 0) {
7245
7250
  for (const k of keys) {
7246
7251
  this.instanceCache.delete(k);
7247
7252
  }
7253
+ return false;
7248
7254
  }
7255
+ return true;
7249
7256
  }
7250
7257
  /**
7251
7258
  * Idle, and not the shell the item machine can be in when it reaches `idle` before
@@ -7509,7 +7516,7 @@ class Item {
7509
7516
  const db = BaseDb.getAppDb();
7510
7517
  if (db && props.modelName) {
7511
7518
  // Model names are only unique per schema: resolve the exact models row from the most specific scope.
7512
- const _mod_26 = await import('./BasePathResolver-B-fK7_N_.js');
7519
+ const _mod_26 = await import('./BasePathResolver-CBTXCMFL.js');
7513
7520
  const _ns_26 = _mod_26.bf;
7514
7521
  const { resolveModelRecord } = _ns_26;
7515
7522
  const modelRecord = await resolveModelRecord(props.modelName, {
@@ -7518,7 +7525,7 @@ class Item {
7518
7525
  });
7519
7526
  const modelRecords = modelRecord ? [modelRecord] : [];
7520
7527
  if (!modelRecord) {
7521
- const _mod_27 = await import('./errors-CCMxedOB.js');
7528
+ const _mod_27 = await import('./errors-CIrbsN_i.js');
7522
7529
  const _ns_27 = _mod_27.j;
7523
7530
  const { UnknownModelError } = _ns_27;
7524
7531
  throw new UnknownModelError(props.modelName, schemaName ?? modelInstance?.schemaName);
@@ -7529,10 +7536,10 @@ class Item {
7529
7536
  // Scope the constructor's Model lookup to this model's schema (as getItemData does on reload),
7530
7537
  // so a same-named model cached from another schema can't supply the property set.
7531
7538
  if (modelRecord && !props.schemaName) {
7532
- const _mod_28 = await import('./BasePathResolver-B-fK7_N_.js');
7539
+ const _mod_28 = await import('./BasePathResolver-CBTXCMFL.js');
7533
7540
  const _ns_28 = _mod_28.be;
7534
7541
  const { modelSchemas } = _ns_28;
7535
- const _mod_29 = await import('./BasePathResolver-B-fK7_N_.js');
7542
+ const _mod_29 = await import('./BasePathResolver-CBTXCMFL.js');
7536
7543
  const _ns_29 = _mod_29.bd;
7537
7544
  const { schemas: schemasTable } = _ns_29;
7538
7545
  const schemaRows = await db
@@ -7721,7 +7728,7 @@ class Item {
7721
7728
  /* best-effort cache cleanup */
7722
7729
  }
7723
7730
  try {
7724
- const { discardNewDraft } = await import('./discardNewDraft-g8w3uHFM.js');
7731
+ const { discardNewDraft } = await import('./discardNewDraft-CEOouygG.js');
7725
7732
  await discardNewDraft(seedLocalId);
7726
7733
  }
7727
7734
  catch (error) {
@@ -7745,7 +7752,7 @@ class Item {
7745
7752
  }
7746
7753
  catch (error) {
7747
7754
  if (error instanceof ItemPropertySaveValidationError) {
7748
- const _mod_30 = await import('./errors-CCMxedOB.js');
7755
+ const _mod_30 = await import('./errors-CIrbsN_i.js');
7749
7756
  const _ns_30 = _mod_30.j;
7750
7757
  const { ItemCreateValidationError } = _ns_30;
7751
7758
  const created = new ItemCreateValidationError(item.modelName, error.validationErrors.map((e) => ({ property: propertyName, code: e.code, message: e.message })));
@@ -7912,7 +7919,7 @@ class Item {
7912
7919
  if (!appDb || Item.instanceCache.size === 0) {
7913
7920
  return;
7914
7921
  }
7915
- const _mod_31 = await import('./index-BQSK-r_A.js');
7922
+ const _mod_31 = await import('./index-DWK-LOUY.js');
7916
7923
  const _ns_31 = _mod_31.s;
7917
7924
  const { metadata } = _ns_31;
7918
7925
  const { eq, and } = await import('drizzle-orm');
@@ -8075,11 +8082,11 @@ class Item {
8075
8082
  }
8076
8083
  /** Throws ItemCreateValidationError for unknown keys and values that break their property's rules. */
8077
8084
  static async assertValidCreateValues(props, propertyNames, dataTypeByPropertyName, skipKeys) {
8078
- const _mod_32 = await import('./errors-CCMxedOB.js');
8085
+ const _mod_32 = await import('./errors-CIrbsN_i.js');
8079
8086
  const _ns_32 = _mod_32.j;
8080
8087
  const { ItemCreateValidationError } = _ns_32;
8081
- const { getPropertySchema } = await import('./property-5AD2naVS.js');
8082
- const { SchemaValidationService } = await import('./SchemaValidationService-CzybXLiS.js');
8088
+ const { getPropertySchema } = await import('./property-lz9yIpyA.js');
8089
+ const { SchemaValidationService } = await import('./SchemaValidationService-CE92y1TT.js');
8083
8090
  const validationService = new SchemaValidationService();
8084
8091
  const modelName = props.modelName;
8085
8092
  const known = new Set(propertyNames);
@@ -8116,7 +8123,7 @@ class Item {
8116
8123
  // Not JSON: validated as given, and rejected as a non-array
8117
8124
  }
8118
8125
  }
8119
- const { resolvePropertyValidationRules } = await import('./propertyValidationRules-Bdgz0Nrr.js');
8126
+ const { resolvePropertyValidationRules } = await import('./propertyValidationRules-LuIwoQoJ.js');
8120
8127
  const rules = propertySchema?.validation ??
8121
8128
  (await resolvePropertyValidationRules(modelName, key, {
8122
8129
  modelFileId: props.modelFileId,
@@ -8447,7 +8454,7 @@ class Item {
8447
8454
  itemActor.send(event);
8448
8455
  };
8449
8456
  try {
8450
- const _mod_33 = await import('./index-BQSK-r_A.js');
8457
+ const _mod_33 = await import('./index-DWK-LOUY.js');
8451
8458
  const _ns_33 = _mod_33.s;
8452
8459
  const seedSchemaMod = _ns_33;
8453
8460
  const { seeds, versions, metadata } = seedSchemaMod;
@@ -8738,9 +8745,15 @@ class Item {
8738
8745
  });
8739
8746
  }
8740
8747
  }
8748
+ /**
8749
+ * Releases this holder's reference. Item.create, Item.find and createById return the same cached
8750
+ * instance to every caller, so the instance is stopped only when the last holder unloads it.
8751
+ */
8741
8752
  unload() {
8742
8753
  try {
8743
- Item.releaseItemInstanceCacheHold(this);
8754
+ // Others (e.g. another hook showing the same item) still use it: keep it running.
8755
+ if (Item.releaseItemInstanceCacheHold(this))
8756
+ return;
8744
8757
  unloadEntity(this, {
8745
8758
  getCacheKeys: () => [],
8746
8759
  caches: [],
@@ -8812,4 +8825,4 @@ var Item$1 = /*#__PURE__*/Object.freeze({
8812
8825
  });
8813
8826
 
8814
8827
  export { unloadEntity as $, getPublishExecutor as A, getRevokeExecutor as B, ClientManagerState as C, DEFAULT_READY_TIMEOUT_MS as D, getUploadExecutor as E, getVersionData$1 as F, isLocalUnsealedDraft as G, isSeedRowOwned as H, Item as I, localUnsealedDraftSql as J, ownedPublisherSql as K, ownedSeedsSql as L, METADATA_LATEST_FIRST_ORDER_SQL as M, pickLatestMetadataRowPerProperty as N, OwnershipError as O, PUBLISH_NOT_CONFIGURED_MESSAGE as P, placeholderUidSql as Q, propertyMachine as R, publisherInAddressListSql as S, publisherIsInOwnedSet as T, setAdditionalSyncAddresses as U, setGetPublisherForNewSeeds as V, setPublishExecutor as W, setRevokeExecutor as X, setUploadExecutor as Y, getInvariantSafePropertyDescriptor as Z, clearDestroySubscriptions as _, ItemProperty as a, ClientManagerEvents as a0, withLockedItemStorageRow as a1, getItemStorageFilePath as a2, writeItemStorageFile as a3, resolvePublisherFromSeedRow as a4, getPropertyData$1 as a5, Item$1 as a6, ItemPropertySaveValidationError as b, assertItemOwned as c, waitForEntityIdle as d, compareMetadataRowsLatestFirst as e, getEasSchemaUidForModel as f, getItemData as g, getLatestPublishedVersionRow as h, isItemOwned as i, isVersionRevoked as j, chunkValues as k, getGetAdditionalSyncAddresses as l, createReactiveProxy as m, findEntity as n, forceRemoveFromCaches as o, parseListPropertyValueFromStorage as p, runDestroyLifecycle as q, rowsPerInsert as r, selectInBatches as s, isPublishedMetadataRow as t, MachineIds as u, createNewItem as v, writeInBatches as w, getEasSchemaForItemProperty as x, getGetPublisherForNewSeeds as y, getMetadataLatest as z };
8815
- //# sourceMappingURL=Item-BDmsdNTQ.js.map
8828
+ //# sourceMappingURL=Item-DTJPMjFk.js.map