@seedprotocol/sdk 0.6.0 → 0.6.2

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 (127) hide show
  1. package/dist/{BasePathResolver-DWY_hb8w.js → BasePathResolver-0IHnXxtL.js} +5 -1
  2. package/dist/BasePathResolver-0IHnXxtL.js.map +1 -0
  3. package/dist/{ModelProperty-DGJf78CS.js → ModelProperty-DMjKVphl.js} +39 -29
  4. package/dist/ModelProperty-DMjKVphl.js.map +1 -0
  5. package/dist/{Schema-Drmce3q-.js → Schema-cK2z7wet.js} +42 -38
  6. package/dist/{Schema-Drmce3q-.js.map → Schema-cK2z7wet.js.map} +1 -1
  7. package/dist/{SchemaValidationService-a_sfnpDV.js → SchemaValidationService-B3pQ_q-9.js} +5 -5
  8. package/dist/{SchemaValidationService-a_sfnpDV.js.map → SchemaValidationService-B3pQ_q-9.js.map} +1 -1
  9. package/dist/{backfillMetadataPropertyIds-CZcOi-cK.js → backfillMetadataPropertyIds-C-YLFeI2.js} +3 -3
  10. package/dist/{backfillMetadataPropertyIds-CZcOi-cK.js.map → backfillMetadataPropertyIds-C-YLFeI2.js.map} +1 -1
  11. package/dist/cjs/{ModelProperty-BA26rMV8.js → ModelProperty-CCwtTuvi.js} +17 -17
  12. package/dist/cjs/{ModelProperty-BA26rMV8.js.map → ModelProperty-CCwtTuvi.js.map} +1 -1
  13. package/dist/cjs/{Schema-Hgwq3L34.js → Schema-DU28JWKv.js} +20 -20
  14. package/dist/cjs/{Schema-Hgwq3L34.js.map → Schema-DU28JWKv.js.map} +1 -1
  15. package/dist/cjs/{SchemaValidationService-DVmOGZao.js → SchemaValidationService-BOYI1syg.js} +2 -2
  16. package/dist/cjs/{SchemaValidationService-DVmOGZao.js.map → SchemaValidationService-BOYI1syg.js.map} +1 -1
  17. package/dist/cjs/{backfillMetadataPropertyIds-BWJI4eCj.js → backfillMetadataPropertyIds-CrvyL7Xq.js} +2 -2
  18. package/dist/cjs/{backfillMetadataPropertyIds-BWJI4eCj.js.map → backfillMetadataPropertyIds-CrvyL7Xq.js.map} +1 -1
  19. package/dist/cjs/{eas-BJ8FtbU9.js → eas-D-Casv2P.js} +3 -3
  20. package/dist/cjs/{eas-BJ8FtbU9.js.map → eas-D-Casv2P.js.map} +1 -1
  21. package/dist/cjs/{getItem-DdBKeEEU.js → getItem-BPAs0Jxp.js} +2 -2
  22. package/dist/cjs/{getItem-DdBKeEEU.js.map → getItem-BPAs0Jxp.js.map} +1 -1
  23. package/dist/cjs/{getPublishPayload-DSBLjMKl.js → getPublishPayload-BeoNRCLY.js} +13 -11
  24. package/dist/cjs/getPublishPayload-BeoNRCLY.js.map +1 -0
  25. package/dist/cjs/{getPublishUploads-DMKnK2_R.js → getPublishUploads-C75vy7nb.js} +4 -4
  26. package/dist/cjs/{getPublishUploads-DMKnK2_R.js.map → getPublishUploads-C75vy7nb.js.map} +1 -1
  27. package/dist/cjs/{getSegmentedItemProperties-D0ZzTmvi.js → getSegmentedItemProperties-CDmkM9Yc.js} +3 -3
  28. package/dist/cjs/{getSegmentedItemProperties-D0ZzTmvi.js.map → getSegmentedItemProperties-CDmkM9Yc.js.map} +1 -1
  29. package/dist/cjs/{index-BD1b6zAi.js → index-BbfxH7OY.js} +321 -189
  30. package/dist/cjs/index-BbfxH7OY.js.map +1 -0
  31. package/dist/cjs/{index-DQggpLqI.js → index-CA6kGjZH.js} +3 -3
  32. package/dist/cjs/index-CA6kGjZH.js.map +1 -0
  33. package/dist/cjs/{property-D4IB0zBz.js → property-aeBSv5CF.js} +4 -4
  34. package/dist/cjs/{property-D4IB0zBz.js.map → property-aeBSv5CF.js.map} +1 -1
  35. package/dist/cjs/{syncDbWithEas-BYvFJc7N.js → syncDbWithEas-ChvunkwQ.js} +17 -10
  36. package/dist/cjs/syncDbWithEas-ChvunkwQ.js.map +1 -0
  37. package/dist/{configurePlatform-CXQCT7N8.js → configurePlatform-Df4BlXwQ.js} +3 -3
  38. package/dist/{configurePlatform-CXQCT7N8.js.map → configurePlatform-Df4BlXwQ.js.map} +1 -1
  39. package/dist/{constants-B7aNfB_1.js → constants-CROrIRd-.js} +2 -2
  40. package/dist/{constants-B7aNfB_1.js.map → constants-CROrIRd-.js.map} +1 -1
  41. package/dist/{db-Bad8QKfZ.js → db-BwVuO1tO.js} +121 -56
  42. package/dist/db-BwVuO1tO.js.map +1 -0
  43. package/dist/{eas-BB9hVW68.js → eas-C0H0EbDo.js} +5 -5
  44. package/dist/{eas-BB9hVW68.js.map → eas-C0H0EbDo.js.map} +1 -1
  45. package/dist/{getItem-Cina46nb.js → getItem-Cxa-rKqh.js} +5 -5
  46. package/dist/{getItem-Cina46nb.js.map → getItem-Cxa-rKqh.js.map} +1 -1
  47. package/dist/{getPublishPayload-BEO52UOv.js → getPublishPayload-DmOu0I29.js} +18 -16
  48. package/dist/getPublishPayload-DmOu0I29.js.map +1 -0
  49. package/dist/{getPublishUploads-CJjfqJi9.js → getPublishUploads-gWv4tDyT.js} +7 -7
  50. package/dist/{getPublishUploads-CJjfqJi9.js.map → getPublishUploads-gWv4tDyT.js.map} +1 -1
  51. package/dist/{getSegmentedItemProperties-CbzFDgFr.js → getSegmentedItemProperties-BfIBZbR7.js} +5 -5
  52. package/dist/{getSegmentedItemProperties-CbzFDgFr.js.map → getSegmentedItemProperties-BfIBZbR7.js.map} +1 -1
  53. package/dist/{index-B4In0GEO.js → index-C1pktvdj.js} +293 -214
  54. package/dist/index-C1pktvdj.js.map +1 -0
  55. package/dist/{index-DNOCl06b.js → index-DAwvrNga.js} +7 -7
  56. package/dist/index-DAwvrNga.js.map +1 -0
  57. package/dist/{index-DrEkRiuK.js → index-xNWgPtlN.js} +2 -2
  58. package/dist/index-xNWgPtlN.js.map +1 -0
  59. package/dist/{index.node-CnP9s4cV.js → index.node-DqC_o5EN.js} +13 -4
  60. package/dist/index.node-DqC_o5EN.js.map +1 -0
  61. package/dist/main.cjs +1 -1
  62. package/dist/main.js +315 -31
  63. package/dist/main.js.map +1 -1
  64. package/dist/node.js +10 -10
  65. package/dist/platform.browser.js +14 -4
  66. package/dist/platform.browser.js.map +1 -1
  67. package/dist/platform.node.js +3 -3
  68. package/dist/{property-DIN1zQ_c.js → property-eMrSbAWU.js} +8 -8
  69. package/dist/{property-DIN1zQ_c.js.map → property-eMrSbAWU.js.map} +1 -1
  70. package/dist/src/Item/Item.d.ts.map +1 -1
  71. package/dist/src/browser/helpers/FileManager.d.ts +1 -0
  72. package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
  73. package/dist/src/client/ClientManager.d.ts +12 -0
  74. package/dist/src/client/ClientManager.d.ts.map +1 -1
  75. package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
  76. package/dist/src/db/read/getItems.d.ts.map +1 -1
  77. package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
  78. package/dist/src/db/read/summarizePublishWork.d.ts +24 -0
  79. package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -0
  80. package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts +4 -2
  81. package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts.map +1 -1
  82. package/dist/src/db/write/claimUnpublishedDrafts.d.ts +11 -0
  83. package/dist/src/db/write/claimUnpublishedDrafts.d.ts.map +1 -0
  84. package/dist/src/db/write/createMetadata.d.ts.map +1 -1
  85. package/dist/src/db/write/createSeed.d.ts.map +1 -1
  86. package/dist/src/db/write/createSeeds.d.ts.map +1 -1
  87. package/dist/src/db/write/createVersion.d.ts.map +1 -1
  88. package/dist/src/db/write/updateMetadata.d.ts.map +1 -1
  89. package/dist/src/db/write/updateSeedUid.d.ts.map +1 -1
  90. package/dist/src/db/write/updateVersionUid.d.ts.map +1 -1
  91. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  92. package/dist/src/helpers/FileManager/BaseFileManager.d.ts +2 -0
  93. package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
  94. package/dist/src/helpers/FileManager/IFileManager.d.ts +2 -0
  95. package/dist/src/helpers/FileManager/IFileManager.d.ts.map +1 -1
  96. package/dist/src/helpers/addresses.d.ts +14 -0
  97. package/dist/src/helpers/addresses.d.ts.map +1 -1
  98. package/dist/src/helpers/db.d.ts +2 -2
  99. package/dist/src/helpers/db.d.ts.map +1 -1
  100. package/dist/src/helpers/ownership.d.ts +36 -8
  101. package/dist/src/helpers/ownership.d.ts.map +1 -1
  102. package/dist/src/helpers/publishConfig.d.ts +4 -3
  103. package/dist/src/helpers/publishConfig.d.ts.map +1 -1
  104. package/dist/src/index.d.ts +4 -1
  105. package/dist/src/index.d.ts.map +1 -1
  106. package/dist/src/node/helpers/FileManager.d.ts +1 -0
  107. package/dist/src/node/helpers/FileManager.d.ts.map +1 -1
  108. package/dist/src/types/index.d.ts +6 -1
  109. package/dist/src/types/index.d.ts.map +1 -1
  110. package/dist/{syncDbWithEas-ceVUuWSZ.js → syncDbWithEas-c9Xe17zq.js} +24 -17
  111. package/dist/syncDbWithEas-c9Xe17zq.js.map +1 -0
  112. package/dist/{updateSeedRevokedAt-CtRjZiyh.js → updateSeedRevokedAt-F0ZDvwOO.js} +2 -2
  113. package/dist/{updateSeedRevokedAt-CtRjZiyh.js.map → updateSeedRevokedAt-F0ZDvwOO.js.map} +1 -1
  114. package/package.json +5 -5
  115. package/dist/BasePathResolver-DWY_hb8w.js.map +0 -1
  116. package/dist/ModelProperty-DGJf78CS.js.map +0 -1
  117. package/dist/cjs/getPublishPayload-DSBLjMKl.js.map +0 -1
  118. package/dist/cjs/index-BD1b6zAi.js.map +0 -1
  119. package/dist/cjs/index-DQggpLqI.js.map +0 -1
  120. package/dist/cjs/syncDbWithEas-BYvFJc7N.js.map +0 -1
  121. package/dist/db-Bad8QKfZ.js.map +0 -1
  122. package/dist/getPublishPayload-BEO52UOv.js.map +0 -1
  123. package/dist/index-B4In0GEO.js.map +0 -1
  124. package/dist/index-DNOCl06b.js.map +0 -1
  125. package/dist/index-DrEkRiuK.js.map +0 -1
  126. package/dist/index.node-CnP9s4cV.js.map +0 -1
  127. package/dist/syncDbWithEas-ceVUuWSZ.js.map +0 -1
@@ -205,6 +205,10 @@ class BaseFileManager {
205
205
  static pathExists(filePath) {
206
206
  return BaseFileManager.requireImpl().pathExists(filePath);
207
207
  }
208
+ /** File size in bytes, or null if the path does not exist / cannot be stated. */
209
+ static getFileSize(filePath) {
210
+ return BaseFileManager.requireImpl().getFileSize(filePath);
211
+ }
208
212
  /**
209
213
  * Returns a list of filenames in the given directory (e.g. 'images', 'files').
210
214
  */
@@ -339,14 +343,9 @@ let revokeExecutor = null;
339
343
  function getRevokeExecutor() {
340
344
  return revokeExecutor;
341
345
  }
342
- let getAdditionalSyncAddresses = null;
343
- function getGetAdditionalSyncAddresses() {
344
- return getAdditionalSyncAddresses;
345
- }
346
346
 
347
347
  var publishConfig = /*#__PURE__*/Object.freeze({
348
348
  __proto__: null,
349
- getGetAdditionalSyncAddresses: getGetAdditionalSyncAddresses,
350
349
  getPublisherForNewSeedsWithTimeout: getPublisherForNewSeedsWithTimeout,
351
350
  getRevokeExecutor: getRevokeExecutor,
352
351
  getUploadExecutor: getUploadExecutor
@@ -1000,7 +999,7 @@ const createPropertyInstances = async (propertyFileIds) => {
1000
999
  return;
1001
1000
  }
1002
1001
  try {
1003
- const mod = await Promise.resolve().then(function () { return require('./ModelProperty-BA26rMV8.js'); });
1002
+ const mod = await Promise.resolve().then(function () { return require('./ModelProperty-CCwtTuvi.js'); });
1004
1003
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
1005
1004
  if (!ModelProperty) {
1006
1005
  logger$v('createPropertyInstances: ModelProperty not available from dynamic import');
@@ -1184,7 +1183,7 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
1184
1183
  // Step 2: Fallback to Schema context (only if database doesn't have the model)
1185
1184
  // This handles the case where model exists in schema file but not yet in database
1186
1185
  try {
1187
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-Hgwq3L34.js'); });
1186
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DU28JWKv.js'); });
1188
1187
  const { Schema } = schemaMod;
1189
1188
  const schema = Schema.create(schemaName, { waitForReady: false });
1190
1189
  const schemaSnapshot = schema.getService().getSnapshot();
@@ -1428,7 +1427,7 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
1428
1427
  }
1429
1428
  // Mark schema as draft when a new model is created so saveNewVersion() can persist it
1430
1429
  try {
1431
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-Hgwq3L34.js'); });
1430
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DU28JWKv.js'); });
1432
1431
  const { Schema } = schemaMod;
1433
1432
  const schema = Schema.create(schemaName, { waitForReady: false });
1434
1433
  schema.getService().send({ type: 'markAsDraft', propertyKey: 'schema:models' });
@@ -1472,10 +1471,10 @@ const validateModel = xstate.fromCallback(({ sendBack, input: { context } }) =>
1472
1471
  const _validateModel = async () => {
1473
1472
  try {
1474
1473
  // Use dynamic imports to break circular dependencies
1475
- const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-DVmOGZao.js'); });
1474
+ const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-BOYI1syg.js'); });
1476
1475
  const { SchemaValidationService } = validationServiceMod;
1477
1476
  const validationService = new SchemaValidationService();
1478
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-Hgwq3L34.js'); });
1477
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DU28JWKv.js'); });
1479
1478
  const { Schema } = schemaMod;
1480
1479
  // Validate model structure
1481
1480
  const structureResult = validationService.validateModelStructure(context);
@@ -1585,7 +1584,7 @@ const createModelProperties = xstate.fromCallback(({ sendBack, input }) => {
1585
1584
  return;
1586
1585
  }
1587
1586
  logger$t(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
1588
- const mod = await Promise.resolve().then(function () { return require('./ModelProperty-BA26rMV8.js'); });
1587
+ const mod = await Promise.resolve().then(function () { return require('./ModelProperty-CCwtTuvi.js'); });
1589
1588
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
1590
1589
  if (!ModelProperty) {
1591
1590
  logger$t('ModelProperty not available from dynamic import');
@@ -1688,7 +1687,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
1688
1687
  const structureMsg = `[validateEntity] Validating model structure`;
1689
1688
  logger$s(structureMsg);
1690
1689
  // Use existing Model validation
1691
- const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-DVmOGZao.js'); });
1690
+ const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-BOYI1syg.js'); });
1692
1691
  const { SchemaValidationService } = validationServiceMod;
1693
1692
  const validationService = new SchemaValidationService();
1694
1693
  // Validate model structure
@@ -1706,7 +1705,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
1706
1705
  if (entityInput.entityData.schemaName) {
1707
1706
  try {
1708
1707
  logger$s(`[validateEntity] Validating model against schema "${entityInput.entityData.schemaName}"`);
1709
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-Hgwq3L34.js'); });
1708
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DU28JWKv.js'); });
1710
1709
  const { Schema } = schemaMod;
1711
1710
  const schema = Schema.create(entityInput.entityData.schemaName, {
1712
1711
  waitForReady: false,
@@ -1742,7 +1741,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
1742
1741
  }
1743
1742
  else if (entityInput.entityType === 'modelProperty') {
1744
1743
  // Use existing ModelProperty validation
1745
- const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-DVmOGZao.js'); });
1744
+ const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-BOYI1syg.js'); });
1746
1745
  const { SchemaValidationService } = validationServiceMod;
1747
1746
  const validationService = new SchemaValidationService();
1748
1747
  // Validate property structure
@@ -1757,7 +1756,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
1757
1756
  // If schema name and model name provided, validate against schema
1758
1757
  if (entityInput.entityData._schemaName && entityInput.entityData.modelName) {
1759
1758
  try {
1760
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-Hgwq3L34.js'); });
1759
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DU28JWKv.js'); });
1761
1760
  const { Schema } = schemaMod;
1762
1761
  const schema = Schema.create(entityInput.entityData._schemaName, {
1763
1762
  waitForReady: false,
@@ -1786,7 +1785,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
1786
1785
  }
1787
1786
  else if (entityInput.entityType === 'schema') {
1788
1787
  // Schema validation - use existing validation
1789
- const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-DVmOGZao.js'); });
1788
+ const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-BOYI1syg.js'); });
1790
1789
  const { SchemaValidationService } = validationServiceMod;
1791
1790
  const validationService = new SchemaValidationService();
1792
1791
  const schemaResult = validationService.validateSchema(entityInput.entityData);
@@ -1865,6 +1864,60 @@ function matchesUniqueConstraintText(text) {
1865
1864
  (text.includes('2067') && lower.includes('constraint')));
1866
1865
  }
1867
1866
 
1867
+ /**
1868
+ * Lowercase + trim an address for persist and compare.
1869
+ * Does not checksum or validate — test and placeholder addresses must keep working.
1870
+ */
1871
+ function normalizeHexAddress(addr) {
1872
+ return addr.trim().toLowerCase();
1873
+ }
1874
+ /**
1875
+ * Lowercase, drop empties, and dedupe (first-seen order).
1876
+ */
1877
+ function normalizeAddressList(addrs) {
1878
+ if (!addrs?.length)
1879
+ return [];
1880
+ const seen = new Set();
1881
+ const out = [];
1882
+ for (const addr of addrs) {
1883
+ if (addr == null || addr === '')
1884
+ continue;
1885
+ const normalized = normalizeHexAddress(String(addr));
1886
+ if (!normalized || seen.has(normalized))
1887
+ continue;
1888
+ seen.add(normalized);
1889
+ out.push(normalized);
1890
+ }
1891
+ return out;
1892
+ }
1893
+ /**
1894
+ * Lowercase a publisher stamp. Empty / null → undefined (omit on write).
1895
+ */
1896
+ function normalizePublisher(publisher) {
1897
+ if (publisher == null || publisher === '')
1898
+ return undefined;
1899
+ const normalized = normalizeHexAddress(publisher);
1900
+ return normalized || undefined;
1901
+ }
1902
+ /**
1903
+ * Normalizes AddressConfiguration to { owned, watched }.
1904
+ * - string[] -> { owned: addresses, watched: [] }
1905
+ * - { owned, watched? } -> { owned, watched: watched ?? [] }
1906
+ * Addresses are lowercased and deduped.
1907
+ */
1908
+ function normalizeAddressConfig(addresses) {
1909
+ if (!addresses) {
1910
+ return { owned: [], watched: [] };
1911
+ }
1912
+ if (Array.isArray(addresses)) {
1913
+ return { owned: normalizeAddressList(addresses), watched: [] };
1914
+ }
1915
+ return {
1916
+ owned: normalizeAddressList(addresses.owned),
1917
+ watched: normalizeAddressList(addresses.watched),
1918
+ };
1919
+ }
1920
+
1868
1921
  const logger$r = debug('seedSdk:helpers:db');
1869
1922
  /**
1870
1923
  * Resolve property_id from model name/type and property name.
@@ -3207,13 +3260,13 @@ function parseAddressConfig(value) {
3207
3260
  try {
3208
3261
  const parsed = JSON.parse(value);
3209
3262
  if (Array.isArray(parsed)) {
3210
- return { owned: parsed, watched: [] };
3263
+ return normalizeAddressConfig(parsed);
3211
3264
  }
3212
3265
  if (parsed && typeof parsed === 'object' && Array.isArray(parsed.owned)) {
3213
- return {
3266
+ return normalizeAddressConfig({
3214
3267
  owned: parsed.owned,
3215
3268
  watched: Array.isArray(parsed.watched) ? parsed.watched : [],
3216
- };
3269
+ });
3217
3270
  }
3218
3271
  return null;
3219
3272
  }
@@ -3230,27 +3283,12 @@ const getWatchedAddressesFromDb = async () => {
3230
3283
  return config?.watched ?? [];
3231
3284
  };
3232
3285
  /**
3233
- * Returns addresses for useItems/getItemsData addressFilter.
3234
- * Encapsulates owned (with additional sync addresses) and watched logic.
3286
+ * Returns persisted owned or watched addresses for list filters.
3287
+ * Does not include `getAdditionalSyncAddresses` (those are extra EAS indexers).
3235
3288
  */
3236
3289
  const getAddressesForItemsFilter = async (addressFilter) => {
3237
3290
  if (addressFilter === 'owned') {
3238
- const { getGetAdditionalSyncAddresses } = await Promise.resolve().then(function () { return publishConfig; });
3239
- let ownedAddresses = await getOwnedAddressesFromDb();
3240
- const additionalGetter = getGetAdditionalSyncAddresses();
3241
- if (additionalGetter) {
3242
- const additional = await additionalGetter();
3243
- if (additional?.length) {
3244
- const seen = new Set(ownedAddresses.map((a) => a.toLowerCase()));
3245
- for (const addr of additional) {
3246
- if (addr && !seen.has(addr.toLowerCase())) {
3247
- seen.add(addr.toLowerCase());
3248
- ownedAddresses = [...ownedAddresses, addr];
3249
- }
3250
- }
3251
- }
3252
- }
3253
- return ownedAddresses;
3291
+ return getOwnedAddressesFromDb();
3254
3292
  }
3255
3293
  return getWatchedAddressesFromDb();
3256
3294
  };
@@ -3827,7 +3865,7 @@ const writeToDatabase = xstate.fromCallback(({ sendBack, input }) => {
3827
3865
  // initial write completes is not overwritten by the stale requestWrite payload.
3828
3866
  let dataToWrite = input.entityData;
3829
3867
  try {
3830
- const mod = await Promise.resolve().then(function () { return require('./ModelProperty-BA26rMV8.js'); });
3868
+ const mod = await Promise.resolve().then(function () { return require('./ModelProperty-CCwtTuvi.js'); });
3831
3869
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
3832
3870
  if (ModelProperty && typeof ModelProperty.getById === 'function') {
3833
3871
  const instance = ModelProperty.getById(input.entityId);
@@ -4207,7 +4245,7 @@ const modelMachine = xstate.setup({
4207
4245
  // Create ModelProperty instances for any new property IDs
4208
4246
  if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
4209
4247
  // Import and create instances asynchronously (fire-and-forget)
4210
- Promise.resolve().then(function () { return require('./ModelProperty-BA26rMV8.js'); }).then(({ ModelProperty }) => {
4248
+ Promise.resolve().then(function () { return require('./ModelProperty-CCwtTuvi.js'); }).then(({ ModelProperty }) => {
4211
4249
  const createPromises = newPropertyIds.map(async (propertyFileId) => {
4212
4250
  try {
4213
4251
  const property = await ModelProperty.createById(propertyFileId);
@@ -4822,14 +4860,14 @@ const createSeed = async ({ type, seedUid }) => {
4822
4860
  // if the EAS schema hasn't been published yet
4823
4861
  const appDb = BaseDb.getAppDb();
4824
4862
  const newSeedLocalId = generateId();
4825
- const publisher = await getPublisherForNewSeedsWithTimeout();
4863
+ const publisher = normalizePublisher(await getPublisherForNewSeedsWithTimeout());
4826
4864
  await appDb.insert(seeds).values({
4827
4865
  localId: newSeedLocalId,
4828
4866
  type,
4829
4867
  uid: seedUid,
4830
4868
  createdAt: Date.now(),
4831
4869
  schemaUid: schemaUid || null,
4832
- ...(publisher != null && publisher !== '' && { publisher }),
4870
+ ...(publisher && { publisher }),
4833
4871
  });
4834
4872
  return newSeedLocalId;
4835
4873
  };
@@ -4837,7 +4875,7 @@ const createSeed = async ({ type, seedUid }) => {
4837
4875
  const createVersion = async ({ seedLocalId, seedUid, seedType, uid, }) => {
4838
4876
  const appDb = BaseDb.getAppDb();
4839
4877
  const newVersionLocalId = generateId();
4840
- const publisher = await getPublisherForNewSeedsWithTimeout();
4878
+ const publisher = normalizePublisher(await getPublisherForNewSeedsWithTimeout());
4841
4879
  await appDb.insert(versions).values({
4842
4880
  localId: newVersionLocalId,
4843
4881
  createdAt: Date.now(),
@@ -4845,7 +4883,7 @@ const createVersion = async ({ seedLocalId, seedUid, seedType, uid, }) => {
4845
4883
  seedUid: seedUid ?? null,
4846
4884
  seedType,
4847
4885
  uid: uid ?? null,
4848
- ...(publisher != null && publisher !== '' && { publisher }),
4886
+ ...(publisher && { publisher }),
4849
4887
  });
4850
4888
  return newVersionLocalId;
4851
4889
  };
@@ -5188,7 +5226,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
5188
5226
  const schemaNameToTry = model$1?.schemaName;
5189
5227
  if (schemaNameToTry) {
5190
5228
  try {
5191
- const { Schema } = await Promise.resolve().then(function () { return require('./Schema-Hgwq3L34.js'); });
5229
+ const { Schema } = await Promise.resolve().then(function () { return require('./Schema-DU28JWKv.js'); });
5192
5230
  const schemaInstance = Schema.create(schemaNameToTry, { waitForReady: false });
5193
5231
  const schemaContext = schemaInstance.getService().getSnapshot().context;
5194
5232
  if (schemaContext.models?.[modelName]?.properties) {
@@ -5237,7 +5275,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
5237
5275
  }
5238
5276
  }
5239
5277
  if (Object.keys(propertySchemas).length === 0) {
5240
- const schemaMod = await Promise.resolve().then(function () { return require('./index-DQggpLqI.js'); });
5278
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-CA6kGjZH.js'); });
5241
5279
  const { ModelPropertyDataTypes } = schemaMod;
5242
5280
  const KNOWN_MODEL_FALLBACKS = {
5243
5281
  Post: {
@@ -5284,7 +5322,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
5284
5322
  // Infer propertyRecordSchema from metadata when schema is missing (enables persistence)
5285
5323
  let propSchema = propertySchemas[propertyName];
5286
5324
  if (!propSchema && isRefTypeFromMeta) {
5287
- const schemaMod = await Promise.resolve().then(function () { return require('./index-DQggpLqI.js'); });
5325
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-CA6kGjZH.js'); });
5288
5326
  const { ModelPropertyDataTypes } = schemaMod;
5289
5327
  propSchema = {
5290
5328
  dataType: refSeedType === 'html' ? ModelPropertyDataTypes.Html
@@ -5541,9 +5579,9 @@ const runPublish = xstate.fromCallback(({ sendBack, input: { context } }) => {
5541
5579
  sendBack({ type: 'publishError', error: new Error(`Item not found for seedLocalId: ${seedLocalId}`) });
5542
5580
  return;
5543
5581
  }
5544
- const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-DMKnK2_R.js'); });
5582
+ const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-C75vy7nb.js'); });
5545
5583
  const { getPublishUploads } = getPublishUploadsMod;
5546
- const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-DSBLjMKl.js'); });
5584
+ const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-BeoNRCLY.js'); });
5547
5585
  const { getPublishPayload } = getPublishPayloadMod;
5548
5586
  const uploads = await getPublishUploads(item);
5549
5587
  let uploadedTransactions = [];
@@ -6253,6 +6291,130 @@ async function batchLatestPublishedVersionBySeedLocalIds(seedLocalIds) {
6253
6291
  return out;
6254
6292
  }
6255
6293
 
6294
+ const READ_ONLY_ERROR = 'Item is read-only: you do not own this item';
6295
+ async function getSeedRowForItem(item) {
6296
+ const appDb = BaseDb.getAppDb();
6297
+ if (!appDb)
6298
+ return null;
6299
+ const conditions = [];
6300
+ if (item.seedLocalId)
6301
+ conditions.push(drizzleOrm.eq(seeds.localId, item.seedLocalId));
6302
+ if (item.seedUid)
6303
+ conditions.push(drizzleOrm.eq(seeds.uid, item.seedUid));
6304
+ if (conditions.length === 0)
6305
+ return null;
6306
+ const seedRows = await appDb
6307
+ .select({
6308
+ publisher: seeds.publisher,
6309
+ attestationRaw: seeds.attestationRaw,
6310
+ uid: seeds.uid,
6311
+ })
6312
+ .from(seeds)
6313
+ .where(conditions.length === 1 ? conditions[0] : drizzleOrm.or(...conditions))
6314
+ .limit(1);
6315
+ if (!seedRows || seedRows.length === 0)
6316
+ return null;
6317
+ return seedRows[0];
6318
+ }
6319
+ /** Resolve publisher from seed row: `publisher` column, else `attestationRaw.attester`. */
6320
+ function resolvePublisherFromSeedRow(row) {
6321
+ if (row.publisher)
6322
+ return row.publisher;
6323
+ if (row.attestationRaw) {
6324
+ try {
6325
+ const parsed = JSON.parse(row.attestationRaw);
6326
+ return parsed.attester ?? null;
6327
+ }
6328
+ catch {
6329
+ return null;
6330
+ }
6331
+ }
6332
+ return null;
6333
+ }
6334
+ /**
6335
+ * Local draft that has never been attested: no publisher, no real uid, no attestationRaw.
6336
+ */
6337
+ function isLocalUnsealedDraft(row) {
6338
+ const publisher = row.publisher;
6339
+ if (publisher != null && publisher !== '')
6340
+ return false;
6341
+ if (!eas.isPlaceholderUid(row.uid))
6342
+ return false;
6343
+ if (row.attestationRaw != null && row.attestationRaw !== '')
6344
+ return false;
6345
+ return true;
6346
+ }
6347
+ /** Case-insensitive membership in the persisted owned set. */
6348
+ function publisherIsInOwnedSet(publisher, ownedAddresses) {
6349
+ if (publisher == null || publisher === '')
6350
+ return false;
6351
+ const ownedSet = new Set(normalizeAddressList(ownedAddresses));
6352
+ return ownedSet.has(normalizeHexAddress(publisher));
6353
+ }
6354
+ /**
6355
+ * Shared ownership predicate.
6356
+ * - Session has owned addresses: only a publisher in that set is owned (null is never owned).
6357
+ * - Session has no owned addresses: local unsealed drafts are owned so pre-connect authoring works.
6358
+ */
6359
+ function isSeedRowOwned(row, ownedAddresses) {
6360
+ const publisher = resolvePublisherFromSeedRow(row);
6361
+ if (ownedAddresses.length === 0) {
6362
+ return isLocalUnsealedDraft({ ...row, publisher: publisher ?? row.publisher });
6363
+ }
6364
+ return publisherIsInOwnedSet(publisher, ownedAddresses);
6365
+ }
6366
+ /**
6367
+ * SQL for `addressFilter: 'owned' | 'watched'`. Empty list → no rows (`1=0`).
6368
+ * Compares `lower(publisher)` so checksummed rows match persisted lowercase owned.
6369
+ */
6370
+ function publisherInAddressListSql(column, addresses) {
6371
+ const normalized = normalizeAddressList(addresses);
6372
+ if (normalized.length === 0) {
6373
+ return drizzleOrm.sql `1=0`;
6374
+ }
6375
+ return drizzleOrm.inArray(drizzleOrm.sql `lower(${column})`, normalized);
6376
+ }
6377
+ /**
6378
+ * Checks if the current user owns the item (publisher is in persisted owned addresses).
6379
+ *
6380
+ * When the session has owned addresses, only a matching publisher is owned —
6381
+ * `publisher IS NULL` is not treated as owned. Call `claimUnpublishedDrafts`
6382
+ * after connect to stamp local drafts.
6383
+ *
6384
+ * When owned is empty, local unsealed drafts (no publisher, no real uid, no
6385
+ * attestationRaw) are still owned so create/edit works before a wallet is connected.
6386
+ *
6387
+ * Does not include `getAdditionalSyncAddresses` (those are extra EAS indexers,
6388
+ * not wallets the user controls).
6389
+ */
6390
+ async function isItemOwned(item) {
6391
+ const row = await getSeedRowForItem(item);
6392
+ if (!row)
6393
+ return false;
6394
+ const ownedAddresses = await getOwnedAddressesFromDb();
6395
+ return isSeedRowOwned(row, ownedAddresses);
6396
+ }
6397
+ /**
6398
+ * Throws if the item is not owned. Use before write operations (publish, save, destroy).
6399
+ */
6400
+ async function assertItemOwned(item) {
6401
+ const owned = await isItemOwned(item);
6402
+ if (!owned) {
6403
+ throw new Error(READ_ONLY_ERROR);
6404
+ }
6405
+ }
6406
+
6407
+ var ownership = /*#__PURE__*/Object.freeze({
6408
+ __proto__: null,
6409
+ assertItemOwned: assertItemOwned,
6410
+ isItemOwned: isItemOwned,
6411
+ isLocalUnsealedDraft: isLocalUnsealedDraft,
6412
+ isSeedRowOwned: isSeedRowOwned,
6413
+ publisherInAddressListSql: publisherInAddressListSql,
6414
+ publisherIsInOwnedSet: publisherIsInOwnedSet,
6415
+ resolvePublisherFromSeedRow: resolvePublisherFromSeedRow
6416
+ });
6417
+
6256
6418
  /**
6257
6419
  * List item rows for list UIs. Only includes seeds that have at least one version.
6258
6420
  *
@@ -6273,16 +6435,11 @@ const getItemsData = async ({ modelName, deleted, includeEas = false, addressFil
6273
6435
  }
6274
6436
  if (addressFilter === 'owned') {
6275
6437
  const ownedAddresses = await getAddressesForItemsFilter('owned');
6276
- if (ownedAddresses.length > 0) {
6277
- conditions.push(drizzleOrm.or(drizzleOrm.inArray(seeds.publisher, ownedAddresses), drizzleOrm.isNull(seeds.publisher)));
6278
- }
6438
+ conditions.push(publisherInAddressListSql(seeds.publisher, ownedAddresses));
6279
6439
  }
6280
6440
  else if (addressFilter === 'watched') {
6281
6441
  const watchedAddresses = await getAddressesForItemsFilter('watched');
6282
- if (watchedAddresses.length === 0) {
6283
- return [];
6284
- }
6285
- conditions.push(drizzleOrm.inArray(seeds.publisher, watchedAddresses));
6442
+ conditions.push(publisherInAddressListSql(seeds.publisher, watchedAddresses));
6286
6443
  }
6287
6444
  if (deleted) {
6288
6445
  conditions.push(drizzleOrm.or(drizzleOrm.isNotNull(seeds._markedForDeletion), drizzleOrm.eq(seeds._markedForDeletion, 1)));
@@ -6524,7 +6681,7 @@ const resolveRelatedValue = xstate.fromCallback(({ sendBack, input: { context }
6524
6681
  const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
6525
6682
  const _resolveRelatedValue = async () => {
6526
6683
  // Use dynamic import to break circular dependency
6527
- const schemaMod = await Promise.resolve().then(function () { return require('./index-DQggpLqI.js'); });
6684
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-CA6kGjZH.js'); });
6528
6685
  const { ModelPropertyDataTypes } = schemaMod;
6529
6686
  if (!propertyValue || !isRelation || populatedFromDb) {
6530
6687
  return;
@@ -6843,6 +7000,7 @@ const updateMetadata = async (metadataValues, propertyRecordSchema) => {
6843
7000
  }
6844
7001
  // Publisher is immutable once set: do not overwrite existing publisher
6845
7002
  if (rest.publisher != null && rest.publisher !== '') {
7003
+ rest.publisher = normalizePublisher(rest.publisher) ?? rest.publisher;
6846
7004
  const [row] = await appDb
6847
7005
  .select({ publisher: metadata$1.publisher })
6848
7006
  .from(metadata$1)
@@ -7527,7 +7685,7 @@ const hydrateFromDb = xstate.fromCallback(({ sendBack, input: { context } }) =>
7527
7685
  // to use dynamically imported ModelPropertyDataTypes
7528
7686
  const _hydrateFromDb = async () => {
7529
7687
  // Use dynamic import to break circular dependency
7530
- const schemaMod = await Promise.resolve().then(function () { return require('./index-DQggpLqI.js'); });
7688
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-CA6kGjZH.js'); });
7531
7689
  const { ModelPropertyDataTypes } = schemaMod;
7532
7690
  const appDb = BaseDb.getAppDb();
7533
7691
  const whereClauses = [];
@@ -7890,7 +8048,7 @@ const loadOrCreateProperty = xstate.fromCallback(({ sendBack, input: { context }
7890
8048
  };
7891
8049
  // Merge with schema from file/DB to get validation rules (enum, pattern, etc.) - properties table doesn't store these
7892
8050
  try {
7893
- const { getPropertySchema } = await Promise.resolve().then(function () { return require('./property-D4IB0zBz.js'); });
8051
+ const { getPropertySchema } = await Promise.resolve().then(function () { return require('./property-aeBSv5CF.js'); });
7894
8052
  let schemaFromFile = await getPropertySchema(normalizedModelName, propertyName);
7895
8053
  if (!schemaFromFile?.validation) {
7896
8054
  // Fallback: get validation from schemaData in database (Schema context may not be loaded yet)
@@ -8355,9 +8513,9 @@ const analyzeInput = xstate.fromCallback(({ sendBack, input: { context, event }
8355
8513
  }
8356
8514
  const _analyzeInput = async () => {
8357
8515
  // Use dynamic import to break circular dependency
8358
- const schemaMod = await Promise.resolve().then(function () { return require('./index-DQggpLqI.js'); });
8516
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-CA6kGjZH.js'); });
8359
8517
  const { ModelPropertyDataTypes } = schemaMod;
8360
- const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-DVmOGZao.js'); });
8518
+ const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-BOYI1syg.js'); });
8361
8519
  let propertyName = propertyNameRaw;
8362
8520
  if (!propertyName) {
8363
8521
  throw new Error('propertyName is required');
@@ -8525,8 +8683,8 @@ class MetadataValidationError extends Error {
8525
8683
  const createMetadata = async (metadataValues, propertyRecordSchema, options) => {
8526
8684
  const appDb = BaseDb.getAppDb();
8527
8685
  metadataValues.localId = generateId();
8528
- const publisher = await getPublisherForNewSeedsWithTimeout();
8529
- if (publisher != null && publisher !== '') {
8686
+ const publisher = normalizePublisher(await getPublisherForNewSeedsWithTimeout());
8687
+ if (publisher) {
8530
8688
  metadataValues.publisher = publisher;
8531
8689
  }
8532
8690
  if (!metadataValues.modelType && metadataValues.modelName) {
@@ -8555,7 +8713,7 @@ const createMetadata = async (metadataValues, propertyRecordSchema, options) =>
8555
8713
  propertyRecordSchema?.validation &&
8556
8714
  metadataValues.propertyValue != null &&
8557
8715
  metadataValues.propertyValue !== '') {
8558
- const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-DVmOGZao.js'); });
8716
+ const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-BOYI1syg.js'); });
8559
8717
  const validationService = new SchemaValidationService();
8560
8718
  const validationResult = validationService.validatePropertyValue(metadataValues.propertyValue, normalizeDataType(propertyRecordSchema.dataType), propertyRecordSchema.validation, propertyRecordSchema.refValueType
8561
8719
  ? normalizeDataType(String(propertyRecordSchema.refValueType))
@@ -9148,7 +9306,7 @@ const saveRelation = xstate.fromCallback(({ sendBack, input: { context, event }
9148
9306
  }
9149
9307
  const _saveRelation = async () => {
9150
9308
  // Use dynamic import to break circular dependency
9151
- const schemaMod = await Promise.resolve().then(function () { return require('./index-DQggpLqI.js'); });
9309
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-CA6kGjZH.js'); });
9152
9310
  const { ModelPropertyDataTypes } = schemaMod;
9153
9311
  if (!propertyNameRaw) {
9154
9312
  throw new Error('propertyName is required');
@@ -10192,7 +10350,7 @@ class ItemProperty {
10192
10350
  return;
10193
10351
  }
10194
10352
  // Use dynamic import to break circular dependency
10195
- const schemaMod = await Promise.resolve().then(function () { return require('./index-DQggpLqI.js'); });
10353
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-CA6kGjZH.js'); });
10196
10354
  const { ModelPropertyDataTypes } = schemaMod;
10197
10355
  const { context } = snapshot;
10198
10356
  const { propertyRecordSchema } = context;
@@ -11343,7 +11501,8 @@ const updateSeedUid = async ({ seedLocalId, seedUid, publisher, attestationCreat
11343
11501
  return;
11344
11502
  }
11345
11503
  const appDb = BaseDb.getAppDb();
11346
- let shouldSetPublisher = publisher != null && publisher !== '';
11504
+ const normalizedPublisher = normalizePublisher(publisher);
11505
+ let shouldSetPublisher = normalizedPublisher != null;
11347
11506
  if (shouldSetPublisher) {
11348
11507
  const [row] = await appDb
11349
11508
  .select({ publisher: seeds.publisher })
@@ -11358,7 +11517,7 @@ const updateSeedUid = async ({ seedLocalId, seedUid, publisher, attestationCreat
11358
11517
  .update(seeds)
11359
11518
  .set({
11360
11519
  uid: seedUid,
11361
- ...(shouldSetPublisher && { publisher }),
11520
+ ...(shouldSetPublisher && { publisher: normalizedPublisher }),
11362
11521
  ...(attestationCreatedAt != null && { attestationCreatedAt }),
11363
11522
  updatedAt: Date.now(),
11364
11523
  })
@@ -11500,12 +11659,12 @@ class Item {
11500
11659
  };
11501
11660
  this.getPublishUploads = async (options) => {
11502
11661
  // Use dynamic import to break circular dependency
11503
- const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-DMKnK2_R.js'); });
11662
+ const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-C75vy7nb.js'); });
11504
11663
  const { getPublishUploads } = getPublishUploadsMod;
11505
11664
  return await getPublishUploads(this, [], undefined, options);
11506
11665
  };
11507
11666
  this.getPublishPayload = async (uploadedTransactions, options) => {
11508
- const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-DSBLjMKl.js'); });
11667
+ const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-BeoNRCLY.js'); });
11509
11668
  const { getPublishPayload } = getPublishPayloadMod;
11510
11669
  return await getPublishPayload(this, uploadedTransactions, options);
11511
11670
  };
@@ -13074,24 +13233,6 @@ class ConflictError extends Error {
13074
13233
  }
13075
13234
  }
13076
13235
 
13077
- /**
13078
- * Normalizes AddressConfiguration to { owned, watched }.
13079
- * - string[] -> { owned: addresses, watched: [] }
13080
- * - { owned, watched? } -> { owned, watched: watched ?? [] }
13081
- */
13082
- function normalizeAddressConfig(addresses) {
13083
- if (!addresses) {
13084
- return { owned: [], watched: [] };
13085
- }
13086
- if (Array.isArray(addresses)) {
13087
- return { owned: addresses, watched: [] };
13088
- }
13089
- return {
13090
- owned: addresses.owned ?? [],
13091
- watched: addresses.watched ?? [],
13092
- };
13093
- }
13094
-
13095
13236
  let writeTail = Promise.resolve();
13096
13237
  function enqueueEasSyncDbWrite(fn) {
13097
13238
  const next = writeTail.then(fn);
@@ -13188,7 +13329,7 @@ const runEasSync = xstate.fromPromise(async ({ input, }) => {
13188
13329
  requestPayload: input.requestPayload,
13189
13330
  persistedSnapshot: input.runningSnapshot,
13190
13331
  });
13191
- const { runSyncFromEas } = await Promise.resolve().then(function () { return require('./syncDbWithEas-BYvFJc7N.js'); });
13332
+ const { runSyncFromEas } = await Promise.resolve().then(function () { return require('./syncDbWithEas-ChvunkwQ.js'); });
13192
13333
  try {
13193
13334
  await runSyncFromEas(toRunSyncArg(input.options));
13194
13335
  await finalizeEasSyncProcessRow(rowId, {
@@ -13972,8 +14113,8 @@ const saveConfig = xstate.fromCallback(({ sendBack, input: { context } }) => {
13972
14113
  throw new Error('App DB not found');
13973
14114
  }
13974
14115
  const endpointsValueString = JSON.stringify(endpoints);
13975
- const owned = ownedAddresses ?? addresses ?? [];
13976
- const watched = watchedAddresses ?? [];
14116
+ const owned = normalizeAddressList(ownedAddresses ?? addresses ?? []);
14117
+ const watched = normalizeAddressList(watchedAddresses ?? []);
13977
14118
  const addressesValueString = JSON.stringify({ owned, watched });
13978
14119
  // TODO: Figure out how to define on conflict with multiple rows added
13979
14120
  await appDb
@@ -13988,20 +14129,18 @@ const saveConfig = xstate.fromCallback(({ sendBack, input: { context } }) => {
13988
14129
  value: endpointsValueString,
13989
14130
  },
13990
14131
  });
13991
- if (owned.length > 0 || watched.length > 0) {
13992
- await appDb
13993
- .insert(appState)
13994
- .values({
13995
- key: 'addresses',
14132
+ await appDb
14133
+ .insert(appState)
14134
+ .values({
14135
+ key: 'addresses',
14136
+ value: addressesValueString,
14137
+ })
14138
+ .onConflictDoUpdate({
14139
+ target: appState.key,
14140
+ set: {
13996
14141
  value: addressesValueString,
13997
- })
13998
- .onConflictDoUpdate({
13999
- target: appState.key,
14000
- set: {
14001
- value: addressesValueString,
14002
- },
14003
- });
14004
- }
14142
+ },
14143
+ });
14005
14144
  await appDb
14006
14145
  .insert(appState)
14007
14146
  .values({
@@ -17179,85 +17318,7 @@ function unregisterSeedQueryLocalSource() {
17179
17318
  registered = false;
17180
17319
  }
17181
17320
 
17182
- const READ_ONLY_ERROR = 'Item is read-only: you do not own this item';
17183
- async function getSeedRowForItem(item) {
17184
- const appDb = BaseDb.getAppDb();
17185
- if (!appDb)
17186
- return null;
17187
- const conditions = [];
17188
- if (item.seedLocalId)
17189
- conditions.push(drizzleOrm.eq(seeds.localId, item.seedLocalId));
17190
- if (item.seedUid)
17191
- conditions.push(drizzleOrm.eq(seeds.uid, item.seedUid));
17192
- if (conditions.length === 0)
17193
- return null;
17194
- const seedRows = await appDb
17195
- .select({
17196
- publisher: seeds.publisher,
17197
- attestationRaw: seeds.attestationRaw,
17198
- uid: seeds.uid,
17199
- })
17200
- .from(seeds)
17201
- .where(conditions.length === 1 ? conditions[0] : drizzleOrm.or(...conditions))
17202
- .limit(1);
17203
- if (!seedRows || seedRows.length === 0)
17204
- return null;
17205
- return seedRows[0];
17206
- }
17207
- /** Resolve publisher from seed row: `publisher` column, else `attestationRaw.attester`. */
17208
- function resolvePublisherFromSeedRow(row) {
17209
- if (row.publisher)
17210
- return row.publisher;
17211
- if (row.attestationRaw) {
17212
- try {
17213
- const parsed = JSON.parse(row.attestationRaw);
17214
- return parsed.attester ?? null;
17215
- }
17216
- catch {
17217
- return null;
17218
- }
17219
- }
17220
- return null;
17221
- }
17222
- /**
17223
- * Checks if the current user owns the item (publisher is in owned addresses).
17224
- * Locally created items (no publisher, no attestationRaw) are considered owned.
17225
- * Includes getAdditionalSyncAddresses (e.g. `modularAccountModuleContract` when configured)
17226
- * so ownership aligns with EAS sync when the publisher/attester matches those addresses.
17227
- */
17228
- async function isItemOwned(item) {
17229
- const row = await getSeedRowForItem(item);
17230
- if (!row)
17231
- return false;
17232
- const publisher = resolvePublisherFromSeedRow(row);
17233
- if (!publisher) {
17234
- if (!row.uid && !row.attestationRaw) {
17235
- return true;
17236
- }
17237
- return false;
17238
- }
17239
- let addressesToCheck = await getOwnedAddressesFromDb();
17240
- const ownedSet = new Set(addressesToCheck.map((a) => a.toLowerCase()));
17241
- return ownedSet.has(publisher.toLowerCase());
17242
- }
17243
- /**
17244
- * Throws if the item is not owned. Use before write operations (publish, save, destroy).
17245
- */
17246
- async function assertItemOwned(item) {
17247
- const owned = await isItemOwned(item);
17248
- if (!owned) {
17249
- throw new Error(READ_ONLY_ERROR);
17250
- }
17251
- }
17252
-
17253
- var ownership = /*#__PURE__*/Object.freeze({
17254
- __proto__: null,
17255
- assertItemOwned: assertItemOwned,
17256
- isItemOwned: isItemOwned,
17257
- resolvePublisherFromSeedRow: resolvePublisherFromSeedRow
17258
- });
17259
-
17260
- const emptyResult = () => ({
17321
+ const emptyResult$1 = () => ({
17261
17322
  removedSeedLocalIds: [],
17262
17323
  removedSeedUids: [],
17263
17324
  });
@@ -17275,11 +17336,11 @@ function normalizeAddresses(addresses) {
17275
17336
  async function findLocalOnchainCopiesForAddresses(addresses) {
17276
17337
  const normalized = normalizeAddresses(addresses);
17277
17338
  if (normalized.length === 0) {
17278
- return emptyResult();
17339
+ return emptyResult$1();
17279
17340
  }
17280
17341
  const appDb = BaseDb.getAppDb();
17281
17342
  if (!appDb) {
17282
- return emptyResult();
17343
+ return emptyResult$1();
17283
17344
  }
17284
17345
  const addressSet = new Set(normalized);
17285
17346
  const candidateRows = (await appDb
@@ -17328,6 +17389,57 @@ async function hardDeleteLocalSeedsByLocalIds(seedLocalIds) {
17328
17389
  await appDb.delete(seeds).where(drizzleOrm.inArray(seeds.localId, seedLocalIds));
17329
17390
  }
17330
17391
 
17392
+ const emptyResult = () => ({
17393
+ seeds: 0,
17394
+ versions: 0,
17395
+ metadata: 0,
17396
+ });
17397
+ /**
17398
+ * Stamp local seeds/versions/metadata that have no publisher and no real uid.
17399
+ * Does not touch sealed rows (real EAS uid or attestationRaw).
17400
+ */
17401
+ async function claimUnpublishedDrafts(publisher) {
17402
+ const normalized = normalizePublisher(publisher);
17403
+ if (!normalized)
17404
+ return emptyResult();
17405
+ const appDb = BaseDb.getAppDb();
17406
+ if (!appDb)
17407
+ return emptyResult();
17408
+ const now = Date.now();
17409
+ const claimTable = async (table) => {
17410
+ const rows = (await appDb
17411
+ .select({
17412
+ localId: table.localId,
17413
+ uid: table.uid,
17414
+ publisher: table.publisher,
17415
+ attestationRaw: table.attestationRaw,
17416
+ })
17417
+ .from(table));
17418
+ const ids = rows
17419
+ .filter((row) => typeof row.localId === 'string' &&
17420
+ row.localId !== '' &&
17421
+ isLocalUnsealedDraft(row))
17422
+ .map((row) => row.localId);
17423
+ if (ids.length === 0)
17424
+ return 0;
17425
+ await appDb
17426
+ .update(table)
17427
+ .set({ publisher: normalized, updatedAt: now })
17428
+ .where(drizzleOrm.inArray(table.localId, ids));
17429
+ return ids.length;
17430
+ };
17431
+ const [seedCount, versionCount, metadataCount] = await Promise.all([
17432
+ claimTable(seeds),
17433
+ claimTable(versions),
17434
+ claimTable(metadata$1),
17435
+ ]);
17436
+ return {
17437
+ seeds: seedCount,
17438
+ versions: versionCount,
17439
+ metadata: metadataCount,
17440
+ };
17441
+ }
17442
+
17331
17443
  const logger$3 = debug('seedSdk:client');
17332
17444
  const clientManager = xstate.createActor(clientManagerMachine, {
17333
17445
  input: {
@@ -17456,6 +17568,15 @@ const clientInstance = {
17456
17568
  ensureInitialized();
17457
17569
  return getWatchedAddressesFromDb();
17458
17570
  },
17571
+ /**
17572
+ * Stamp local seeds/versions/metadata that have no publisher and no real uid.
17573
+ * Sealed rows (real EAS uid or attestationRaw) are left unchanged.
17574
+ * Use after `setAddresses` on connect; `setPublishWallet` does this automatically.
17575
+ */
17576
+ claimUnpublishedDrafts: async (publisher) => {
17577
+ ensureInitialized();
17578
+ return claimUnpublishedDrafts(publisher);
17579
+ },
17459
17580
  /**
17460
17581
  * Hard-delete local on-chain seed copies for the given publisher addresses.
17461
17582
  * Drafts (no uid / attestationRaw) are kept. Chain is untouched; reconnect can rehydrate via syncFromEas.
@@ -17706,7 +17827,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
17706
17827
  // Lazy import cache for ModelProperty to avoid circular dependency
17707
17828
  // Eagerly start loading to minimize delay on first access
17708
17829
  let ModelPropertyClass = null;
17709
- const modelPropertyImportPromise = Promise.resolve().then(function () { return require('./ModelProperty-BA26rMV8.js'); })
17830
+ const modelPropertyImportPromise = Promise.resolve().then(function () { return require('./ModelProperty-CCwtTuvi.js'); })
17710
17831
  .then(module => {
17711
17832
  ModelPropertyClass = module.ModelProperty;
17712
17833
  return ModelPropertyClass;
@@ -17723,7 +17844,7 @@ function getModelProperty() {
17723
17844
  }
17724
17845
  // Lazy import cache for Schema to avoid circular dependency
17725
17846
  let SchemaClass = null;
17726
- const schemaImportPromise = Promise.resolve().then(function () { return require('./Schema-Hgwq3L34.js'); })
17847
+ const schemaImportPromise = Promise.resolve().then(function () { return require('./Schema-DU28JWKv.js'); })
17727
17848
  .then(module => {
17728
17849
  SchemaClass = module.Schema;
17729
17850
  return SchemaClass;
@@ -19488,6 +19609,15 @@ class NodeFileManager {
19488
19609
  async pathExists(filePath) {
19489
19610
  return await fsAsync__namespace.access(filePath).then(() => true).catch(() => false);
19490
19611
  }
19612
+ async getFileSize(filePath) {
19613
+ try {
19614
+ const stat = await fsAsync__namespace.stat(filePath);
19615
+ return stat.size;
19616
+ }
19617
+ catch {
19618
+ return null;
19619
+ }
19620
+ }
19491
19621
  async listImageFiles() {
19492
19622
  return this.listFiles('images');
19493
19623
  }
@@ -19628,7 +19758,7 @@ function resolveSdkDrizzleMigrationsDir(sdkRootDir) {
19628
19758
  })();
19629
19759
  // Also resolve relative to this module so temp-cwd tests / odd roots still find
19630
19760
  // packages/sdk/src/db/drizzle (or dist/db/drizzle after publish).
19631
- const moduleDir = path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs/index-BD1b6zAi.js', document.baseURI).href))));
19761
+ const moduleDir = path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs/index-BbfxH7OY.js', document.baseURI).href))));
19632
19762
  const candidates = [
19633
19763
  path.join(root, 'db', 'drizzle'), // production: sdkRoot is dist/
19634
19764
  path.join(root, 'dist', 'db', 'drizzle'), // sdk package root with built dist
@@ -19698,7 +19828,7 @@ class NodeDb {
19698
19828
  logger$1('[Db.prepareDb] running migrations from %s', outDir);
19699
19829
  await migrator.migrate(db, { migrationsFolder: outDir });
19700
19830
  this.db = db;
19701
- const { backfillMetadataPropertyIds } = await Promise.resolve().then(function () { return require('./backfillMetadataPropertyIds-BWJI4eCj.js'); });
19831
+ const { backfillMetadataPropertyIds } = await Promise.resolve().then(function () { return require('./backfillMetadataPropertyIds-CrvyL7Xq.js'); });
19702
19832
  await backfillMetadataPropertyIds();
19703
19833
  return this.db;
19704
19834
  }
@@ -20263,6 +20393,8 @@ exports.modelSchemas = modelSchemas;
20263
20393
  exports.modelUids = modelUids;
20264
20394
  exports.models = models$1;
20265
20395
  exports.normalizeDataType = normalizeDataType;
20396
+ exports.normalizeHexAddress = normalizeHexAddress;
20397
+ exports.normalizePublisher = normalizePublisher;
20266
20398
  exports.parseListPropertyValueFromStorage = parseListPropertyValueFromStorage;
20267
20399
  exports.parseMarkdownFrontmatter = parseMarkdownFrontmatter;
20268
20400
  exports.processSeedConfig = processSeedConfig;
@@ -20287,4 +20419,4 @@ exports.versions = versions;
20287
20419
  exports.waitForEntityIdle = waitForEntityIdle;
20288
20420
  exports.withSeed = withSeed;
20289
20421
  exports.writeProcessMachine = writeProcessMachine;
20290
- //# sourceMappingURL=index-BD1b6zAi.js.map
20422
+ //# sourceMappingURL=index-BbfxH7OY.js.map