@seedprotocol/sdk 0.5.1 → 0.5.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 (111) hide show
  1. package/dist/{ModelProperty-D-ysg8zA.js → ModelProperty-BBXBvgvy.js} +19 -18
  2. package/dist/ModelProperty-BBXBvgvy.js.map +1 -0
  3. package/dist/{Schema-CyCftnKI.js → Schema-xAt7jWlW.js} +36 -36
  4. package/dist/{Schema-CyCftnKI.js.map → Schema-xAt7jWlW.js.map} +1 -1
  5. package/dist/{SchemaValidationService-POM6jHbJ.js → SchemaValidationService-CLzAdBm-.js} +5 -4
  6. package/dist/{SchemaValidationService-POM6jHbJ.js.map → SchemaValidationService-CLzAdBm-.js.map} +1 -1
  7. package/dist/{backfillMetadataPropertyIds-DzZw57iJ.js → backfillMetadataPropertyIds-DBVaIs7O.js} +2 -2
  8. package/dist/{backfillMetadataPropertyIds-DzZw57iJ.js.map → backfillMetadataPropertyIds-DBVaIs7O.js.map} +1 -1
  9. package/dist/cjs/{ModelProperty-CmuGJvyi.js → ModelProperty-Dgd4tGrB.js} +18 -18
  10. package/dist/cjs/{ModelProperty-CmuGJvyi.js.map → ModelProperty-Dgd4tGrB.js.map} +1 -1
  11. package/dist/cjs/{Schema-gpFnZMhB.js → Schema-dkd-eo3B.js} +21 -21
  12. package/dist/cjs/{Schema-gpFnZMhB.js.map → Schema-dkd-eo3B.js.map} +1 -1
  13. package/dist/cjs/{SchemaValidationService-E3xTSRai.js → SchemaValidationService-BMnjcVWV.js} +3 -3
  14. package/dist/cjs/{SchemaValidationService-E3xTSRai.js.map → SchemaValidationService-BMnjcVWV.js.map} +1 -1
  15. package/dist/cjs/{backfillMetadataPropertyIds-_bivrvRs.js → backfillMetadataPropertyIds-ClLuj3s6.js} +3 -3
  16. package/dist/cjs/{backfillMetadataPropertyIds-_bivrvRs.js.map → backfillMetadataPropertyIds-ClLuj3s6.js.map} +1 -1
  17. package/dist/cjs/{eas-BwDKJmlb.js → eas-nWAzbl_F.js} +4 -4
  18. package/dist/cjs/{eas-BwDKJmlb.js.map → eas-nWAzbl_F.js.map} +1 -1
  19. package/dist/cjs/{getItem-MShQw3sz.js → getItem-B08FgglK.js} +3 -3
  20. package/dist/cjs/{getItem-MShQw3sz.js.map → getItem-B08FgglK.js.map} +1 -1
  21. package/dist/cjs/{getPublishPayload-C1nOOXp_.js → getPublishPayload-B_G_6qkE.js} +12 -12
  22. package/dist/cjs/{getPublishPayload-C1nOOXp_.js.map → getPublishPayload-B_G_6qkE.js.map} +1 -1
  23. package/dist/cjs/{getPublishUploads-BjgxgrKD.js → getPublishUploads-Dt-DS-lo.js} +5 -5
  24. package/dist/cjs/{getPublishUploads-BjgxgrKD.js.map → getPublishUploads-Dt-DS-lo.js.map} +1 -1
  25. package/dist/cjs/{getSegmentedItemProperties-Cuw7wcxb.js → getSegmentedItemProperties-BDGbeDW7.js} +3 -3
  26. package/dist/cjs/{getSegmentedItemProperties-Cuw7wcxb.js.map → getSegmentedItemProperties-BDGbeDW7.js.map} +1 -1
  27. package/dist/cjs/{index-vk2DeF2D.js → index-CRBI6dSD.js} +475 -58
  28. package/dist/cjs/index-CRBI6dSD.js.map +1 -0
  29. package/dist/cjs/{index-9Z2FOvLD.js → index-Dx19j60c.js} +4 -4
  30. package/dist/cjs/index-Dx19j60c.js.map +1 -0
  31. package/dist/cjs/{ownership-DhWda0J9.js → ownership-3Tc1-Yrc.js} +3 -3
  32. package/dist/cjs/{ownership-DhWda0J9.js.map → ownership-3Tc1-Yrc.js.map} +1 -1
  33. package/dist/cjs/{property-D3Ww2_Qh.js → property-628qAHpN.js} +5 -5
  34. package/dist/cjs/{property-D3Ww2_Qh.js.map → property-628qAHpN.js.map} +1 -1
  35. package/dist/cjs/{syncDbWithEas-Dht3_7UD.js → syncDbWithEas-DOBtMPw-.js} +46 -49
  36. package/dist/cjs/syncDbWithEas-DOBtMPw-.js.map +1 -0
  37. package/dist/{configurePlatform-R5neRbQ9.js → configurePlatform-Ce6NIKRP.js} +3 -2
  38. package/dist/{configurePlatform-R5neRbQ9.js.map → configurePlatform-Ce6NIKRP.js.map} +1 -1
  39. package/dist/{constants-B5S5JPDK.js → constants-slkc9uq0.js} +13 -18
  40. package/dist/constants-slkc9uq0.js.map +1 -0
  41. package/dist/{db-Cvh84NY7.js → db-CSmK0c3e.js} +9 -9
  42. package/dist/{db-Cvh84NY7.js.map → db-CSmK0c3e.js.map} +1 -1
  43. package/dist/{eas-D9b7z2Wn.js → eas-rx1grht5.js} +5 -4
  44. package/dist/eas-rx1grht5.js.map +1 -0
  45. package/dist/{getItem-B81V3m4S.js → getItem-hPBJU5JF.js} +5 -4
  46. package/dist/{getItem-B81V3m4S.js.map → getItem-hPBJU5JF.js.map} +1 -1
  47. package/dist/{getPublishPayload-CNYsn8-6.js → getPublishPayload-5ugovGK5.js} +16 -15
  48. package/dist/getPublishPayload-5ugovGK5.js.map +1 -0
  49. package/dist/{getPublishUploads-D9rPHkB7.js → getPublishUploads-CdWeci-s.js} +7 -6
  50. package/dist/{getPublishUploads-D9rPHkB7.js.map → getPublishUploads-CdWeci-s.js.map} +1 -1
  51. package/dist/{getSegmentedItemProperties-Bg3_b-b1.js → getSegmentedItemProperties-DV2LHElJ.js} +4 -4
  52. package/dist/{getSegmentedItemProperties-Bg3_b-b1.js.map → getSegmentedItemProperties-DV2LHElJ.js.map} +1 -1
  53. package/dist/{index-oi4roUVf.js → index-CcH2e0Zr.js} +6 -5
  54. package/dist/index-CcH2e0Zr.js.map +1 -0
  55. package/dist/{index--F3Wolt5.js → index-ClwdGWfr.js} +477 -45
  56. package/dist/index-ClwdGWfr.js.map +1 -0
  57. package/dist/{index.node-Bow8kHew.js → index.node-CrXwRoiB.js} +2 -2
  58. package/dist/{index.node-Bow8kHew.js.map → index.node-CrXwRoiB.js.map} +1 -1
  59. package/dist/main.cjs +3 -6
  60. package/dist/main.cjs.map +1 -1
  61. package/dist/main.js +19 -18
  62. package/dist/main.js.map +1 -1
  63. package/dist/node.js +30 -9
  64. package/dist/node.js.map +1 -1
  65. package/dist/{ownership-BF_ZUKIp.js → ownership-58i0iyD9.js} +5 -4
  66. package/dist/{ownership-BF_ZUKIp.js.map → ownership-58i0iyD9.js.map} +1 -1
  67. package/dist/platform.browser.js +16 -3
  68. package/dist/platform.browser.js.map +1 -1
  69. package/dist/platform.node.js +1 -1
  70. package/dist/{property-BdyDfcSc.js → property-CKhOxRNt.js} +8 -7
  71. package/dist/property-CKhOxRNt.js.map +1 -0
  72. package/dist/src/Item/service/actors/saveDataToDb.d.ts.map +1 -1
  73. package/dist/src/browser/helpers/ArweaveClient.d.ts.map +1 -1
  74. package/dist/src/client/ClientManager.d.ts.map +1 -1
  75. package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
  76. package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
  77. package/dist/src/db/read/getItemData.d.ts +8 -0
  78. package/dist/src/db/read/getItemData.d.ts.map +1 -1
  79. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  80. package/dist/src/helpers/gateway/resolveSeedGatewayEndpoints.d.ts +1 -1
  81. package/dist/src/helpers/gateway/resolveSeedGatewayEndpoints.d.ts.map +1 -1
  82. package/dist/src/helpers/index.d.ts +1 -5
  83. package/dist/src/helpers/index.d.ts.map +1 -1
  84. package/dist/src/helpers/mediaRef.d.ts +3 -0
  85. package/dist/src/helpers/mediaRef.d.ts.map +1 -1
  86. package/dist/src/index.d.ts +4 -0
  87. package/dist/src/index.d.ts.map +1 -1
  88. package/dist/src/node/webpack/index.d.ts +4 -1
  89. package/dist/src/node/webpack/index.d.ts.map +1 -1
  90. package/dist/src/query/createLocalQueryDataSource.d.ts +6 -0
  91. package/dist/src/query/createLocalQueryDataSource.d.ts.map +1 -0
  92. package/dist/src/query/index.d.ts +4 -0
  93. package/dist/src/query/index.d.ts.map +1 -0
  94. package/dist/src/query/registerSeedQueryLocalSource.d.ts +25 -0
  95. package/dist/src/query/registerSeedQueryLocalSource.d.ts.map +1 -0
  96. package/dist/src/types/machines.d.ts +2 -0
  97. package/dist/src/types/machines.d.ts.map +1 -1
  98. package/dist/{syncDbWithEas-DMOJHtkP.js → syncDbWithEas-GsaXzTIY.js} +50 -52
  99. package/dist/syncDbWithEas-GsaXzTIY.js.map +1 -0
  100. package/package.json +5 -5
  101. package/dist/ModelProperty-D-ysg8zA.js.map +0 -1
  102. package/dist/cjs/index-9Z2FOvLD.js.map +0 -1
  103. package/dist/cjs/index-vk2DeF2D.js.map +0 -1
  104. package/dist/cjs/syncDbWithEas-Dht3_7UD.js.map +0 -1
  105. package/dist/constants-B5S5JPDK.js.map +0 -1
  106. package/dist/eas-D9b7z2Wn.js.map +0 -1
  107. package/dist/getPublishPayload-CNYsn8-6.js.map +0 -1
  108. package/dist/index--F3Wolt5.js.map +0 -1
  109. package/dist/index-oi4roUVf.js.map +0 -1
  110. package/dist/property-BdyDfcSc.js.map +0 -1
  111. package/dist/syncDbWithEas-DMOJHtkP.js.map +0 -1
@@ -1,11 +1,11 @@
1
1
  import { waitFor, fromCallback, fromPromise, setup, assign, stateIn, createActor, isMachineSnapshot } from 'xstate';
2
2
  import { B as BaseDb, m as models$1, p as properties, s as seeds, j as modelUids, v as versions, f as metadata$1, r as schemas, i as modelSchemas, a as BaseFileManager, b as appState, e as easSyncProcesses, t as BasePathResolver } from './BasePathResolver-BDgc7c4T.js';
3
3
  import { eq, and, isNotNull, not, or, max, count, getTableColumns, sql, isNull, desc, inArray, gt } from 'drizzle-orm';
4
- import { n as normalizeDataType, t as toSnakeCase, o as MachineIds, w as getStorageTransactionIdForSeedUid, x as convertTxIdToImage, M as ModelPropertyDataTypes, y as getDataTypeFromString, z as getMimeType, l as getCorrectId, A as ClientManagerEvents, C as ClientManagerState, c as TProperty } from './constants-B5S5JPDK.js';
4
+ import { n as normalizeDataType, t as toSnakeCase, o as MachineIds, v as getStorageTransactionIdForSeedUid, w as convertTxIdToImage, M as ModelPropertyDataTypes, x as getDataTypeFromString, y as getMimeType, l as getCorrectId, z as ClientManagerEvents, C as ClientManagerState, c as TProperty } from './constants-slkc9uq0.js';
5
5
  import debug from 'debug';
6
6
  import { customAlphabet } from 'nanoid';
7
7
  import { alphanumeric } from 'nanoid-dictionary';
8
- import { writeModelToDb, writePropertyToDb, addSchemaToDb, getAddressesForItemsFilter, getAllAddressesFromDb, escapeSqliteString, getPropertyIdForModelAndName, loadModelsFromDbForSchema, getWatchedAddressesFromDb, getOwnedAddressesFromDb, renameModelInDb } from './db-Cvh84NY7.js';
8
+ import { writeModelToDb, writePropertyToDb, addSchemaToDb, getAddressesForItemsFilter, getAllAddressesFromDb, escapeSqliteString, getPropertyIdForModelAndName, loadModelsFromDbForSchema, getWatchedAddressesFromDb, getOwnedAddressesFromDb, renameModelInDb } from './db-CSmK0c3e.js';
9
9
  import pluralize from 'pluralize';
10
10
  import { BaseQueryClient, BaseEasClient, GET_SCHEMAS, getSchemaUidForModelFromCache, setSchemaUidForModel, GET_PROPERTIES, pickLatestPropertyAttestationsByRefAndSchema, isValidEasAttestationUid, getEasSchemaUidForSchemaDefinition, GET_FILES_METADATA, GET_SCHEMA_BY_NAME } from '@seedprotocol/eas';
11
11
  import { ZERO_BYTES32, INTERNAL_PROPERTY_NAMES, INTERNAL_DATA_TYPES, ImageSize, PROPERTY_NAMES_EXEMPT_FROM_ID_SUFFIX_STRIP, isInternalSchema, INTERNAL_SCHEMA_IDS, SEED_PROTOCOL_SCHEMA_NAME, CLIENT_NOT_INITIALIZED } from './constants-DMHTYMgJ.js';
@@ -14,6 +14,7 @@ import { startCase, throttle, upperFirst, camelCase, orderBy } from 'lodash-es';
14
14
  import { toSnakeCase as toSnakeCase$1 } from 'drizzle-orm/casing';
15
15
  import { ensureReadGatewaySelected, BaseArweaveClient, getResolvedSeedGatewayEndpoints, getReadGatewayHostsForConfig, getDefaultArweaveReadGatewayHostsOrdered, getArweaveReadGatewayHostsForPrimary, seedGatewayConfigFromSeedConfig, resolveSeedGatewayEndpoints, setResolvedSeedGatewayEndpoints, DEFAULT_ARWEAVE_HOST } from '@seedprotocol/arweave';
16
16
  import * as sha3 from 'js-sha3';
17
+ import { clearLocalQuerySource, registerLocalQuerySource, getSeed } from '@seedprotocol/query';
17
18
  import { Type } from '@sinclair/typebox';
18
19
 
19
20
  /**
@@ -282,7 +283,7 @@ const createPropertyInstances = async (propertyFileIds) => {
282
283
  return;
283
284
  }
284
285
  try {
285
- const mod = await import('./ModelProperty-D-ysg8zA.js');
286
+ const mod = await import('./ModelProperty-BBXBvgvy.js');
286
287
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
287
288
  if (!ModelProperty) {
288
289
  logger$s('createPropertyInstances: ModelProperty not available from dynamic import');
@@ -466,7 +467,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context } }) => {
466
467
  // Step 2: Fallback to Schema context (only if database doesn't have the model)
467
468
  // This handles the case where model exists in schema file but not yet in database
468
469
  try {
469
- const _mod_0 = await import('./Schema-CyCftnKI.js');
470
+ const _mod_0 = await import('./Schema-xAt7jWlW.js');
470
471
  const _ns_0 = _mod_0.b;
471
472
  const schemaMod = _ns_0;
472
473
  const { Schema } = schemaMod;
@@ -716,7 +717,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context } }) => {
716
717
  }
717
718
  // Mark schema as draft when a new model is created so saveNewVersion() can persist it
718
719
  try {
719
- const _mod_3 = await import('./Schema-CyCftnKI.js');
720
+ const _mod_3 = await import('./Schema-xAt7jWlW.js');
720
721
  const _ns_3 = _mod_3.b;
721
722
  const schemaMod = _ns_3;
722
723
  const { Schema } = schemaMod;
@@ -762,10 +763,10 @@ const validateModel = fromCallback(({ sendBack, input: { context } }) => {
762
763
  const _validateModel = async () => {
763
764
  try {
764
765
  // Use dynamic imports to break circular dependencies
765
- const validationServiceMod = await import('./SchemaValidationService-POM6jHbJ.js');
766
+ const validationServiceMod = await import('./SchemaValidationService-CLzAdBm-.js');
766
767
  const { SchemaValidationService } = validationServiceMod;
767
768
  const validationService = new SchemaValidationService();
768
- const _mod_4 = await import('./Schema-CyCftnKI.js');
769
+ const _mod_4 = await import('./Schema-xAt7jWlW.js');
769
770
  const _ns_4 = _mod_4.b;
770
771
  const schemaMod = _ns_4;
771
772
  const { Schema } = schemaMod;
@@ -877,7 +878,7 @@ const createModelProperties = fromCallback(({ sendBack, input }) => {
877
878
  return;
878
879
  }
879
880
  logger$q(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
880
- const mod = await import('./ModelProperty-D-ysg8zA.js');
881
+ const mod = await import('./ModelProperty-BBXBvgvy.js');
881
882
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
882
883
  if (!ModelProperty) {
883
884
  logger$q('ModelProperty not available from dynamic import');
@@ -980,7 +981,7 @@ const validateEntity = fromPromise(async ({ input }) => {
980
981
  const structureMsg = `[validateEntity] Validating model structure`;
981
982
  logger$p(structureMsg);
982
983
  // Use existing Model validation
983
- const validationServiceMod = await import('./SchemaValidationService-POM6jHbJ.js');
984
+ const validationServiceMod = await import('./SchemaValidationService-CLzAdBm-.js');
984
985
  const { SchemaValidationService } = validationServiceMod;
985
986
  const validationService = new SchemaValidationService();
986
987
  // Validate model structure
@@ -998,7 +999,7 @@ const validateEntity = fromPromise(async ({ input }) => {
998
999
  if (entityInput.entityData.schemaName) {
999
1000
  try {
1000
1001
  logger$p(`[validateEntity] Validating model against schema "${entityInput.entityData.schemaName}"`);
1001
- const _mod_5 = await import('./Schema-CyCftnKI.js');
1002
+ const _mod_5 = await import('./Schema-xAt7jWlW.js');
1002
1003
  const _ns_5 = _mod_5.b;
1003
1004
  const schemaMod = _ns_5;
1004
1005
  const { Schema } = schemaMod;
@@ -1036,7 +1037,7 @@ const validateEntity = fromPromise(async ({ input }) => {
1036
1037
  }
1037
1038
  else if (entityInput.entityType === 'modelProperty') {
1038
1039
  // Use existing ModelProperty validation
1039
- const validationServiceMod = await import('./SchemaValidationService-POM6jHbJ.js');
1040
+ const validationServiceMod = await import('./SchemaValidationService-CLzAdBm-.js');
1040
1041
  const { SchemaValidationService } = validationServiceMod;
1041
1042
  const validationService = new SchemaValidationService();
1042
1043
  // Validate property structure
@@ -1051,7 +1052,7 @@ const validateEntity = fromPromise(async ({ input }) => {
1051
1052
  // If schema name and model name provided, validate against schema
1052
1053
  if (entityInput.entityData._schemaName && entityInput.entityData.modelName) {
1053
1054
  try {
1054
- const _mod_6 = await import('./Schema-CyCftnKI.js');
1055
+ const _mod_6 = await import('./Schema-xAt7jWlW.js');
1055
1056
  const _ns_6 = _mod_6.b;
1056
1057
  const schemaMod = _ns_6;
1057
1058
  const { Schema } = schemaMod;
@@ -1082,7 +1083,7 @@ const validateEntity = fromPromise(async ({ input }) => {
1082
1083
  }
1083
1084
  else if (entityInput.entityType === 'schema') {
1084
1085
  // Schema validation - use existing validation
1085
- const validationServiceMod = await import('./SchemaValidationService-POM6jHbJ.js');
1086
+ const validationServiceMod = await import('./SchemaValidationService-CLzAdBm-.js');
1086
1087
  const { SchemaValidationService } = validationServiceMod;
1087
1088
  const validationService = new SchemaValidationService();
1088
1089
  const schemaResult = validationService.validateSchema(entityInput.entityData);
@@ -1155,7 +1156,7 @@ const writeToDatabase = fromCallback(({ sendBack, input }) => {
1155
1156
  // initial write completes is not overwritten by the stale requestWrite payload.
1156
1157
  let dataToWrite = input.entityData;
1157
1158
  try {
1158
- const mod = await import('./ModelProperty-D-ysg8zA.js');
1159
+ const mod = await import('./ModelProperty-BBXBvgvy.js');
1159
1160
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
1160
1161
  if (ModelProperty && typeof ModelProperty.getById === 'function') {
1161
1162
  const instance = ModelProperty.getById(input.entityId);
@@ -1535,7 +1536,7 @@ const modelMachine = setup({
1535
1536
  // Create ModelProperty instances for any new property IDs
1536
1537
  if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
1537
1538
  // Import and create instances asynchronously (fire-and-forget)
1538
- import('./ModelProperty-D-ysg8zA.js').then(({ ModelProperty }) => {
1539
+ import('./ModelProperty-BBXBvgvy.js').then(({ ModelProperty }) => {
1539
1540
  const createPromises = newPropertyIds.map(async (propertyFileId) => {
1540
1541
  try {
1541
1542
  const property = await ModelProperty.createById(propertyFileId);
@@ -2433,7 +2434,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
2433
2434
  const schemaNameToTry = model$1?.schemaName;
2434
2435
  if (schemaNameToTry) {
2435
2436
  try {
2436
- const _mod_7 = await import('./Schema-CyCftnKI.js');
2437
+ const _mod_7 = await import('./Schema-xAt7jWlW.js');
2437
2438
  const _ns_7 = _mod_7.b;
2438
2439
  const { Schema } = _ns_7;
2439
2440
  const schemaInstance = Schema.create(schemaNameToTry, { waitForReady: false });
@@ -2486,7 +2487,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
2486
2487
  }
2487
2488
  }
2488
2489
  if (Object.keys(propertySchemas).length === 0) {
2489
- const schemaMod = await import('./index-oi4roUVf.js');
2490
+ const schemaMod = await import('./index-CcH2e0Zr.js');
2490
2491
  const { ModelPropertyDataTypes } = schemaMod;
2491
2492
  const KNOWN_MODEL_FALLBACKS = {
2492
2493
  Post: {
@@ -2533,7 +2534,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
2533
2534
  // Infer propertyRecordSchema from metadata when schema is missing (enables persistence)
2534
2535
  let propSchema = propertySchemas[propertyName];
2535
2536
  if (!propSchema && isRefTypeFromMeta) {
2536
- const schemaMod = await import('./index-oi4roUVf.js');
2537
+ const schemaMod = await import('./index-CcH2e0Zr.js');
2537
2538
  const { ModelPropertyDataTypes } = schemaMod;
2538
2539
  propSchema = {
2539
2540
  dataType: refSeedType === 'html' ? ModelPropertyDataTypes.Html
@@ -2790,9 +2791,9 @@ const runPublish = fromCallback(({ sendBack, input: { context } }) => {
2790
2791
  sendBack({ type: 'publishError', error: new Error(`Item not found for seedLocalId: ${seedLocalId}`) });
2791
2792
  return;
2792
2793
  }
2793
- const getPublishUploadsMod = await import('./getPublishUploads-D9rPHkB7.js');
2794
+ const getPublishUploadsMod = await import('./getPublishUploads-CdWeci-s.js');
2794
2795
  const { getPublishUploads } = getPublishUploadsMod;
2795
- const getPublishPayloadMod = await import('./getPublishPayload-CNYsn8-6.js');
2796
+ const getPublishPayloadMod = await import('./getPublishPayload-5ugovGK5.js');
2796
2797
  const { getPublishPayload } = getPublishPayloadMod;
2797
2798
  const uploads = await getPublishUploads(item);
2798
2799
  let uploadedTransactions = [];
@@ -3173,6 +3174,14 @@ async function getLatestPublishedVersionRow(seedLocalId) {
3173
3174
  }
3174
3175
 
3175
3176
  const logger$j = debug('seedSdk:db:read:getItemData');
3177
+ /**
3178
+ * Assemble flat ItemData for Item / liveQuery / draft-head authoring.
3179
+ *
3180
+ * For **published chain JSON** (Seed → latest attested Version → properties),
3181
+ * prefer `getPublishedSeedRecord` from `@seedprotocol/sdk` or
3182
+ * `getSeed` / `queryBySchema` from `@seedprotocol/query`. This function remains
3183
+ * the correct path for local-head / draft-wins property selection used by Item.
3184
+ */
3176
3185
  const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
3177
3186
  if (!seedLocalId && !seedUid) {
3178
3187
  throw new Error('[db/queries] [getItem] no seedLocalId or seedUid');
@@ -3632,7 +3641,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
3632
3641
  const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
3633
3642
  const _resolveRelatedValue = async () => {
3634
3643
  // Use dynamic import to break circular dependency
3635
- const schemaMod = await import('./index-oi4roUVf.js');
3644
+ const schemaMod = await import('./index-CcH2e0Zr.js');
3636
3645
  const { ModelPropertyDataTypes } = schemaMod;
3637
3646
  if (!propertyValue || !isRelation || populatedFromDb) {
3638
3647
  return;
@@ -4494,7 +4503,7 @@ async function fetchHtmlViaRawAcrossGateways(txId) {
4494
4503
  return undefined;
4495
4504
  try {
4496
4505
  const resolved = getResolvedSeedGatewayEndpoints();
4497
- if (!resolved || resolved.activePath !== 'hyper-sidecar') {
4506
+ if (!resolved || (resolved.activePath !== 'hyper-sidecar' && resolved.activePath !== 'http-proxy')) {
4498
4507
  const { ensureReadGatewaySelected } = await import('@seedprotocol/arweave');
4499
4508
  await ensureReadGatewaySelected().catch(() => { });
4500
4509
  }
@@ -4635,7 +4644,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
4635
4644
  // to use dynamically imported ModelPropertyDataTypes
4636
4645
  const _hydrateFromDb = async () => {
4637
4646
  // Use dynamic import to break circular dependency
4638
- const schemaMod = await import('./index-oi4roUVf.js');
4647
+ const schemaMod = await import('./index-CcH2e0Zr.js');
4639
4648
  const { ModelPropertyDataTypes } = schemaMod;
4640
4649
  const appDb = BaseDb.getAppDb();
4641
4650
  const whereClauses = [];
@@ -4998,7 +5007,7 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
4998
5007
  };
4999
5008
  // Merge with schema from file/DB to get validation rules (enum, pattern, etc.) - properties table doesn't store these
5000
5009
  try {
5001
- const { getPropertySchema } = await import('./property-BdyDfcSc.js');
5010
+ const { getPropertySchema } = await import('./property-CKhOxRNt.js');
5002
5011
  let schemaFromFile = await getPropertySchema(normalizedModelName, propertyName);
5003
5012
  if (!schemaFromFile?.validation) {
5004
5013
  // Fallback: get validation from schemaData in database (Schema context may not be loaded yet)
@@ -5467,9 +5476,9 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
5467
5476
  }
5468
5477
  const _analyzeInput = async () => {
5469
5478
  // Use dynamic import to break circular dependency
5470
- const schemaMod = await import('./index-oi4roUVf.js');
5479
+ const schemaMod = await import('./index-CcH2e0Zr.js');
5471
5480
  const { ModelPropertyDataTypes } = schemaMod;
5472
- const { SchemaValidationService } = await import('./SchemaValidationService-POM6jHbJ.js');
5481
+ const { SchemaValidationService } = await import('./SchemaValidationService-CLzAdBm-.js');
5473
5482
  let propertyName = propertyNameRaw;
5474
5483
  if (!propertyName) {
5475
5484
  throw new Error('propertyName is required');
@@ -5667,7 +5676,7 @@ const createMetadata = async (metadataValues, propertyRecordSchema, options) =>
5667
5676
  propertyRecordSchema?.validation &&
5668
5677
  metadataValues.propertyValue != null &&
5669
5678
  metadataValues.propertyValue !== '') {
5670
- const { SchemaValidationService } = await import('./SchemaValidationService-POM6jHbJ.js');
5679
+ const { SchemaValidationService } = await import('./SchemaValidationService-CLzAdBm-.js');
5671
5680
  const validationService = new SchemaValidationService();
5672
5681
  const validationResult = validationService.validatePropertyValue(metadataValues.propertyValue, normalizeDataType(propertyRecordSchema.dataType), propertyRecordSchema.validation, propertyRecordSchema.refValueType
5673
5682
  ? normalizeDataType(String(propertyRecordSchema.refValueType))
@@ -6260,7 +6269,7 @@ const saveRelation = fromCallback(({ sendBack, input: { context, event } }) => {
6260
6269
  }
6261
6270
  const _saveRelation = async () => {
6262
6271
  // Use dynamic import to break circular dependency
6263
- const schemaMod = await import('./index-oi4roUVf.js');
6272
+ const schemaMod = await import('./index-CcH2e0Zr.js');
6264
6273
  const { ModelPropertyDataTypes } = schemaMod;
6265
6274
  if (!propertyNameRaw) {
6266
6275
  throw new Error('propertyName is required');
@@ -7304,7 +7313,7 @@ class ItemProperty {
7304
7313
  return;
7305
7314
  }
7306
7315
  // Use dynamic import to break circular dependency
7307
- const schemaMod = await import('./index-oi4roUVf.js');
7316
+ const schemaMod = await import('./index-CcH2e0Zr.js');
7308
7317
  const { ModelPropertyDataTypes } = schemaMod;
7309
7318
  const { context } = snapshot;
7310
7319
  const { propertyRecordSchema } = context;
@@ -8215,7 +8224,7 @@ class ItemProperty {
8215
8224
  }
8216
8225
  async save() {
8217
8226
  const ctx = this._getSnapshotContext();
8218
- const { assertItemOwned } = await import('./ownership-BF_ZUKIp.js');
8227
+ const { assertItemOwned } = await import('./ownership-58i0iyD9.js');
8219
8228
  await assertItemOwned({
8220
8229
  seedLocalId: ctx?.seedLocalId ?? undefined,
8221
8230
  seedUid: ctx?.seedUid ?? undefined,
@@ -8556,7 +8565,7 @@ class Item {
8556
8565
  });
8557
8566
  };
8558
8567
  this.unpublish = async () => {
8559
- const { assertItemOwned } = await import('./ownership-BF_ZUKIp.js');
8568
+ const { assertItemOwned } = await import('./ownership-58i0iyD9.js');
8560
8569
  const { getRevokeExecutor } = await Promise.resolve().then(function () { return publishConfig; });
8561
8570
  await assertItemOwned(this);
8562
8571
  const seedUid = this.seedUid;
@@ -8580,7 +8589,7 @@ class Item {
8580
8589
  this._service.send({ type: 'updateContext', revokedAt });
8581
8590
  };
8582
8591
  this.publish = async () => {
8583
- const { assertItemOwned } = await import('./ownership-BF_ZUKIp.js');
8592
+ const { assertItemOwned } = await import('./ownership-58i0iyD9.js');
8584
8593
  await assertItemOwned(this);
8585
8594
  this._service.send({ type: 'startPublish' });
8586
8595
  return new Promise((resolve, reject) => {
@@ -8616,12 +8625,12 @@ class Item {
8616
8625
  };
8617
8626
  this.getPublishUploads = async (options) => {
8618
8627
  // Use dynamic import to break circular dependency
8619
- const getPublishUploadsMod = await import('./getPublishUploads-D9rPHkB7.js');
8628
+ const getPublishUploadsMod = await import('./getPublishUploads-CdWeci-s.js');
8620
8629
  const { getPublishUploads } = getPublishUploadsMod;
8621
8630
  return await getPublishUploads(this, [], undefined, options);
8622
8631
  };
8623
8632
  this.getPublishPayload = async (uploadedTransactions, options) => {
8624
- const getPublishPayloadMod = await import('./getPublishPayload-CNYsn8-6.js');
8633
+ const getPublishPayloadMod = await import('./getPublishPayload-5ugovGK5.js');
8625
8634
  const { getPublishPayload } = getPublishPayloadMod;
8626
8635
  return await getPublishPayload(this, uploadedTransactions, options);
8627
8636
  };
@@ -10123,7 +10132,7 @@ class Item {
10123
10132
  * Destroy the item: soft delete in DB, remove from caches, clean up subscriptions, stop service.
10124
10133
  */
10125
10134
  async destroy() {
10126
- const { assertItemOwned } = await import('./ownership-BF_ZUKIp.js');
10135
+ const { assertItemOwned } = await import('./ownership-58i0iyD9.js');
10127
10136
  await assertItemOwned(this);
10128
10137
  const context = this._getSnapshotContext();
10129
10138
  const cacheKeys = Item.collectInstanceCacheKeysForInstance(this);
@@ -10279,7 +10288,7 @@ const runEasSync = fromPromise(async ({ input, }) => {
10279
10288
  requestPayload: input.requestPayload,
10280
10289
  persistedSnapshot: input.runningSnapshot,
10281
10290
  });
10282
- const { runSyncFromEas } = await import('./syncDbWithEas-DMOJHtkP.js');
10291
+ const { runSyncFromEas } = await import('./syncDbWithEas-GsaXzTIY.js');
10283
10292
  try {
10284
10293
  await runSyncFromEas(toRunSyncArg(input.options));
10285
10294
  await finalizeEasSyncProcessRow(rowId, {
@@ -10558,7 +10567,7 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
10558
10567
  }
10559
10568
  // Prefer the condition-resolved factory when available; fall back to explicit
10560
10569
  // platform imports so source/vitest resolution stays reliable.
10561
- const { configurePlatform } = await import('./configurePlatform-R5neRbQ9.js');
10570
+ const { configurePlatform } = await import('./configurePlatform-Ce6NIKRP.js');
10562
10571
  if (isBrowser()) {
10563
10572
  const { createPlatformServices } = await import('./platform.browser.js');
10564
10573
  configurePlatform(createPlatformServices());
@@ -10636,6 +10645,7 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
10636
10645
  gatewayHyperKey: resolvedGateway.gatewayHyperKey,
10637
10646
  gatewaySidecarHost: gatewayConfig.hyper?.localSidecarHost,
10638
10647
  gatewaySidecarPort: gatewayConfig.hyper?.localSidecarPort,
10648
+ gatewayProxyBaseUrl: resolvedGateway.proxyBaseUrl ?? gatewayConfig.proxyBaseUrl,
10639
10649
  addresses: normalizedAddresses.owned,
10640
10650
  ownedAddresses: normalizedAddresses.owned,
10641
10651
  watchedAddresses: normalizedAddresses.watched,
@@ -10645,7 +10655,7 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
10645
10655
  schema,
10646
10656
  syncFromEasOnAddressChange: options.syncFromEasOnAddressChange ?? true,
10647
10657
  } });
10648
- if (resolvedGateway.activePath !== 'hyper-sidecar') {
10658
+ if (resolvedGateway.activePath !== 'hyper-sidecar' && resolvedGateway.activePath !== 'http-proxy') {
10649
10659
  void ensureReadGatewaySelected().catch(() => {
10650
10660
  /* non-blocking warm-up for read gateway probe */
10651
10661
  });
@@ -10984,7 +10994,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
10984
10994
  const logger$5 = debug('seedSdk:client:actors:saveConfig');
10985
10995
  const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
10986
10996
  logger$5('saveConfig starting');
10987
- const { endpoints, addresses, ownedAddresses, watchedAddresses, arweaveDomain, uploadApiBaseUrl, gatewayTransport, gatewayHyperKey, gatewaySidecarHost, gatewaySidecarPort, } = context;
10997
+ const { endpoints, addresses, ownedAddresses, watchedAddresses, arweaveDomain, uploadApiBaseUrl, gatewayTransport, gatewayHyperKey, gatewaySidecarHost, gatewaySidecarPort, gatewayProxyBaseUrl, } = context;
10988
10998
  // Validate endpoints - required for proper initialization
10989
10999
  // If endpoints are missing or invalid, initialization should fail
10990
11000
  if (!endpoints || !endpoints.filePaths || !endpoints.files) {
@@ -11064,6 +11074,7 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
11064
11074
  if (gatewaySidecarPort != null) {
11065
11075
  await persistKey('gatewaySidecarPort', String(gatewaySidecarPort));
11066
11076
  }
11077
+ await persistKey('gatewayProxyBaseUrl', gatewayProxyBaseUrl);
11067
11078
  }
11068
11079
  catch (error) {
11069
11080
  logger$5('[internal/actors] [saveConfig] Error saving config:', error);
@@ -12252,7 +12263,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
12252
12263
  updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
12253
12264
  };
12254
12265
  // Use dynamic import to break circular dependency
12255
- const dbMod = await import('./db-Cvh84NY7.js');
12266
+ const dbMod = await import('./db-CSmK0c3e.js');
12256
12267
  const { addSchemaToDb, addModelsToDb } = dbMod;
12257
12268
  // Try to add schema and models to database if database is available
12258
12269
  try {
@@ -12479,7 +12490,7 @@ async function applySchemaToDb(schemaFile, modelDefinitions, modelFileIds, prope
12479
12490
  createdAt: new Date(schemaFile.metadata.createdAt).getTime(),
12480
12491
  updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
12481
12492
  };
12482
- const dbMod = await import('./db-Cvh84NY7.js');
12493
+ const dbMod = await import('./db-CSmK0c3e.js');
12483
12494
  const { addSchemaToDb, addModelsToDb } = dbMod;
12484
12495
  const db = BaseDb.getAppDb();
12485
12496
  if (!db) {
@@ -13685,6 +13696,423 @@ const clientManagerMachine = setup({
13685
13696
  },
13686
13697
  });
13687
13698
 
13699
+ function msToUnixSeconds(ms) {
13700
+ if (ms == null || !Number.isFinite(ms))
13701
+ return 0;
13702
+ // Heuristic: values already in seconds are small; ms are large
13703
+ if (ms > 1e12)
13704
+ return Math.floor(ms / 1000);
13705
+ if (ms > 1e10)
13706
+ return Math.floor(ms / 1000);
13707
+ return Math.floor(ms);
13708
+ }
13709
+ function toSnakeCaseName(name) {
13710
+ return name
13711
+ .replace(/([a-z0-9])([A-Z])/g, '$1_$2')
13712
+ .replace(/([A-Z])([A-Z][a-z])/g, '$1_$2')
13713
+ .toLowerCase();
13714
+ }
13715
+ function parsePropertyValue(raw) {
13716
+ if (raw == null)
13717
+ return '';
13718
+ const t = raw.trim();
13719
+ if ((t.startsWith('[') && t.endsWith(']')) ||
13720
+ (t.startsWith('{') && t.endsWith('}'))) {
13721
+ try {
13722
+ return JSON.parse(t);
13723
+ }
13724
+ catch {
13725
+ return raw;
13726
+ }
13727
+ }
13728
+ return raw;
13729
+ }
13730
+ function attestationFromRaw(raw) {
13731
+ if (!raw || !raw.trim())
13732
+ return null;
13733
+ try {
13734
+ const parsed = JSON.parse(raw);
13735
+ if (parsed && typeof parsed.id === 'string')
13736
+ return parsed;
13737
+ }
13738
+ catch {
13739
+ // fall through
13740
+ }
13741
+ return null;
13742
+ }
13743
+ function seedRowToAttestation(row) {
13744
+ if (!row.uid || !isValidEasAttestationUid(row.uid))
13745
+ return null;
13746
+ const fromRaw = attestationFromRaw(row.attestationRaw);
13747
+ if (fromRaw) {
13748
+ const schemaName = row.schemaName ??
13749
+ fromRaw.schema?.schemaNames?.[0]?.name ??
13750
+ row.type ??
13751
+ 'unknown';
13752
+ return {
13753
+ ...fromRaw,
13754
+ id: row.uid,
13755
+ schema: {
13756
+ schemaNames: [{ name: schemaName }],
13757
+ },
13758
+ timeCreated: fromRaw.timeCreated ||
13759
+ msToUnixSeconds(row.attestationCreatedAt),
13760
+ attester: fromRaw.attester ?? row.publisher ?? undefined,
13761
+ schemaId: fromRaw.schemaId || row.schemaUid || '',
13762
+ };
13763
+ }
13764
+ const schemaName = row.schemaName ?? row.type ?? 'unknown';
13765
+ return {
13766
+ id: row.uid,
13767
+ decodedDataJson: '',
13768
+ refUID: '0x0000000000000000000000000000000000000000000000000000000000000000',
13769
+ schemaId: row.schemaUid || '',
13770
+ timeCreated: msToUnixSeconds(row.attestationCreatedAt),
13771
+ attester: row.publisher ?? undefined,
13772
+ schema: { schemaNames: [{ name: schemaName }] },
13773
+ };
13774
+ }
13775
+ function versionRowToAttestation(row) {
13776
+ if (!row.uid || !isValidEasAttestationUid(row.uid))
13777
+ return null;
13778
+ if (!row.seedUid)
13779
+ return null;
13780
+ const fromRaw = attestationFromRaw(row.attestationRaw);
13781
+ if (fromRaw) {
13782
+ return {
13783
+ ...fromRaw,
13784
+ id: row.uid,
13785
+ refUID: row.seedUid,
13786
+ timeCreated: fromRaw.timeCreated ||
13787
+ msToUnixSeconds(row.attestationCreatedAt),
13788
+ attester: fromRaw.attester ?? row.publisher ?? undefined,
13789
+ };
13790
+ }
13791
+ return {
13792
+ id: row.uid,
13793
+ decodedDataJson: '',
13794
+ refUID: row.seedUid,
13795
+ schemaId: '',
13796
+ timeCreated: msToUnixSeconds(row.attestationCreatedAt),
13797
+ attester: row.publisher ?? undefined,
13798
+ };
13799
+ }
13800
+ function metadataRowToAttestation(row) {
13801
+ if (!row.uid || !isValidEasAttestationUid(row.uid))
13802
+ return null;
13803
+ if (!row.versionUid)
13804
+ return null;
13805
+ const fromRaw = attestationFromRaw(row.attestationRaw);
13806
+ if (fromRaw) {
13807
+ return {
13808
+ ...fromRaw,
13809
+ id: row.uid,
13810
+ refUID: row.versionUid,
13811
+ schemaId: fromRaw.schemaId || row.schemaUid || '',
13812
+ timeCreated: fromRaw.timeCreated ||
13813
+ msToUnixSeconds(row.attestationCreatedAt),
13814
+ attester: fromRaw.attester ?? row.publisher ?? undefined,
13815
+ };
13816
+ }
13817
+ const name = row.propertyName
13818
+ ? toSnakeCaseName(row.propertyName)
13819
+ : 'unknown';
13820
+ const value = parsePropertyValue(row.propertyValue);
13821
+ const type = row.easDataType || 'string';
13822
+ return {
13823
+ id: row.uid,
13824
+ decodedDataJson: JSON.stringify([{ value: { name, value, type } }]),
13825
+ refUID: row.versionUid,
13826
+ schemaId: row.schemaUid || '',
13827
+ timeCreated: msToUnixSeconds(row.attestationCreatedAt),
13828
+ attester: row.publisher ?? undefined,
13829
+ };
13830
+ }
13831
+ async function resolveSchemaNameForSeedType(appDb, seedType) {
13832
+ if (!seedType)
13833
+ return null;
13834
+ const normalized = startCase(seedType);
13835
+ try {
13836
+ const schemaRows = await appDb
13837
+ .select({ schemaName: schemas.name })
13838
+ .from(models$1)
13839
+ .innerJoin(modelSchemas, eq(models$1.id, modelSchemas.modelId))
13840
+ .innerJoin(schemas, eq(modelSchemas.schemaId, schemas.id))
13841
+ .where(eq(models$1.name, normalized))
13842
+ .limit(1);
13843
+ if (schemaRows[0]?.schemaName)
13844
+ return schemaRows[0].schemaName;
13845
+ }
13846
+ catch {
13847
+ // ignore
13848
+ }
13849
+ return seedType;
13850
+ }
13851
+ function monthBoundsUnix(year, month) {
13852
+ const startDate = new Date(year, month - 1, 1);
13853
+ const endDate = new Date(year, month, 0, 23, 59, 59);
13854
+ const startTs = Math.floor(startDate.getTime() / 1000);
13855
+ const endTs = Math.floor(endDate.getTime() / 1000) + 1;
13856
+ return { startTs, endTs };
13857
+ }
13858
+ async function listPublishedSeedRows(schemaName, opts) {
13859
+ const appDb = BaseDb.getAppDb();
13860
+ if (!appDb)
13861
+ return [];
13862
+ const snakeType = schemaName.includes('_')
13863
+ ? schemaName
13864
+ : schemaName.replace(/([A-Z])/g, (m, i) => i === 0 ? m.toLowerCase() : `_${m.toLowerCase()}`);
13865
+ // Prefer exact type match (EAS schema names are usually lowercase singular)
13866
+ const typeCandidates = Array.from(new Set([schemaName, schemaName.toLowerCase(), snakeType.toLowerCase()]));
13867
+ const rows = await appDb
13868
+ .select({
13869
+ uid: seeds.uid,
13870
+ schemaUid: seeds.schemaUid,
13871
+ type: seeds.type,
13872
+ publisher: seeds.publisher,
13873
+ attestationRaw: seeds.attestationRaw,
13874
+ attestationCreatedAt: seeds.attestationCreatedAt,
13875
+ revokedAt: seeds.revokedAt,
13876
+ markedForDeletion: seeds._markedForDeletion,
13877
+ })
13878
+ .from(seeds)
13879
+ .where(and(inArray(seeds.type, typeCandidates), isNotNull(seeds.uid), or(isNull(seeds.revokedAt), eq(seeds.revokedAt, 0)), or(isNull(seeds._markedForDeletion), eq(seeds._markedForDeletion, 0))))
13880
+ .orderBy(desc(seeds.attestationCreatedAt));
13881
+ const out = [];
13882
+ for (const row of rows) {
13883
+ if (!row.uid || !isValidEasAttestationUid(row.uid))
13884
+ continue;
13885
+ // Must have at least one published version
13886
+ const versionRows = await appDb
13887
+ .select({
13888
+ uid: versions.uid,
13889
+ })
13890
+ .from(versions)
13891
+ .where(eq(versions.seedUid, row.uid))
13892
+ .orderBy(desc(versions.createdAt));
13893
+ const hasPublished = versionRows.some((v) => v.uid && isValidEasAttestationUid(v.uid));
13894
+ if (!hasPublished)
13895
+ continue;
13896
+ const schemaResolved = await resolveSchemaNameForSeedType(appDb, row.type);
13897
+ const att = seedRowToAttestation({
13898
+ ...row,
13899
+ schemaName: schemaResolved === schemaName ? schemaName : (schemaResolved ?? schemaName),
13900
+ });
13901
+ if (!att)
13902
+ continue;
13903
+ // Force requested schema name so assembleSeeds filters correctly
13904
+ att.schema = { schemaNames: [{ name: schemaName }] };
13905
+ if (opts?.startTs != null || opts?.endTs != null) {
13906
+ const t = att.timeCreated;
13907
+ if (opts.startTs != null && t < opts.startTs)
13908
+ continue;
13909
+ if (opts.endTs != null && t >= opts.endTs)
13910
+ continue;
13911
+ }
13912
+ out.push(att);
13913
+ }
13914
+ return out;
13915
+ }
13916
+ /**
13917
+ * SDK local QueryDataSource: published Seeds/Versions/metadata from SQLite.
13918
+ */
13919
+ function createLocalQueryDataSource() {
13920
+ return {
13921
+ kind: 'local',
13922
+ async getSeedByUid(seedUid) {
13923
+ const appDb = BaseDb.getAppDb();
13924
+ if (!appDb || !seedUid)
13925
+ return null;
13926
+ const rows = await appDb
13927
+ .select({
13928
+ uid: seeds.uid,
13929
+ schemaUid: seeds.schemaUid,
13930
+ type: seeds.type,
13931
+ publisher: seeds.publisher,
13932
+ attestationRaw: seeds.attestationRaw,
13933
+ attestationCreatedAt: seeds.attestationCreatedAt,
13934
+ revokedAt: seeds.revokedAt,
13935
+ })
13936
+ .from(seeds)
13937
+ .where(eq(seeds.uid, seedUid))
13938
+ .limit(1);
13939
+ const row = rows[0];
13940
+ if (!row?.uid || !isValidEasAttestationUid(row.uid))
13941
+ return null;
13942
+ if (row.revokedAt != null && row.revokedAt !== 0)
13943
+ return null;
13944
+ const schemaName = await resolveSchemaNameForSeedType(appDb, row.type);
13945
+ return seedRowToAttestation({ ...row, schemaName });
13946
+ },
13947
+ async listSeedsBySchemaName(schemaName, opts) {
13948
+ const all = await listPublishedSeedRows(schemaName);
13949
+ return all.slice(opts.skip, opts.skip + opts.limit);
13950
+ },
13951
+ async listSeedsBySchemaNameForMonth(schemaName, year, month) {
13952
+ const { startTs, endTs } = monthBoundsUnix(year, month);
13953
+ return listPublishedSeedRows(schemaName, { startTs, endTs });
13954
+ },
13955
+ async getVersionsForSeed(seedUid) {
13956
+ return this.getVersionsForSeeds([seedUid]);
13957
+ },
13958
+ async getVersionsForSeeds(seedUids) {
13959
+ const appDb = BaseDb.getAppDb();
13960
+ if (!appDb || seedUids.length === 0)
13961
+ return [];
13962
+ const rows = await appDb
13963
+ .select({
13964
+ uid: versions.uid,
13965
+ seedUid: versions.seedUid,
13966
+ publisher: versions.publisher,
13967
+ attestationRaw: versions.attestationRaw,
13968
+ attestationCreatedAt: versions.attestationCreatedAt,
13969
+ })
13970
+ .from(versions)
13971
+ .where(inArray(versions.seedUid, seedUids));
13972
+ const out = [];
13973
+ for (const row of rows) {
13974
+ const att = versionRowToAttestation(row);
13975
+ if (att)
13976
+ out.push(att);
13977
+ }
13978
+ return out;
13979
+ },
13980
+ async getPropertiesForVersionUids(versionUids) {
13981
+ const appDb = BaseDb.getAppDb();
13982
+ if (!appDb || versionUids.length === 0)
13983
+ return [];
13984
+ const rows = await appDb
13985
+ .select({
13986
+ uid: metadata$1.uid,
13987
+ schemaUid: metadata$1.schemaUid,
13988
+ propertyName: metadata$1.propertyName,
13989
+ propertyValue: metadata$1.propertyValue,
13990
+ easDataType: metadata$1.easDataType,
13991
+ versionUid: metadata$1.versionUid,
13992
+ publisher: metadata$1.publisher,
13993
+ attestationRaw: metadata$1.attestationRaw,
13994
+ attestationCreatedAt: metadata$1.attestationCreatedAt,
13995
+ })
13996
+ .from(metadata$1)
13997
+ .where(inArray(metadata$1.versionUid, versionUids));
13998
+ const out = [];
13999
+ for (const row of rows) {
14000
+ const att = metadataRowToAttestation(row);
14001
+ if (att)
14002
+ out.push(att);
14003
+ }
14004
+ return out;
14005
+ },
14006
+ async getSeedsByUids(uids) {
14007
+ const appDb = BaseDb.getAppDb();
14008
+ if (!appDb || uids.length === 0)
14009
+ return [];
14010
+ const rows = await appDb
14011
+ .select({
14012
+ uid: seeds.uid,
14013
+ schemaUid: seeds.schemaUid,
14014
+ type: seeds.type,
14015
+ publisher: seeds.publisher,
14016
+ attestationRaw: seeds.attestationRaw,
14017
+ attestationCreatedAt: seeds.attestationCreatedAt,
14018
+ revokedAt: seeds.revokedAt,
14019
+ })
14020
+ .from(seeds)
14021
+ .where(inArray(seeds.uid, uids));
14022
+ const out = [];
14023
+ for (const row of rows) {
14024
+ if (row.revokedAt != null && row.revokedAt !== 0)
14025
+ continue;
14026
+ const schemaName = await resolveSchemaNameForSeedType(appDb, row.type);
14027
+ const att = seedRowToAttestation({ ...row, schemaName });
14028
+ if (att)
14029
+ out.push(att);
14030
+ }
14031
+ return out;
14032
+ },
14033
+ async readStorageBody(ref) {
14034
+ try {
14035
+ if (ref.localPathHint) {
14036
+ const text = await BaseFileManager.readFileAsString(ref.localPathHint);
14037
+ if (text)
14038
+ return text;
14039
+ }
14040
+ // Common layout: html/{name}.html under filesDir
14041
+ if (typeof ref.value === 'string') {
14042
+ const v = ref.value.trim();
14043
+ // Absolute or relative file path already on disk
14044
+ if (v.includes('/') && !v.startsWith('http')) {
14045
+ try {
14046
+ const text = await BaseFileManager.readFileAsString(v);
14047
+ if (text)
14048
+ return text;
14049
+ }
14050
+ catch {
14051
+ // try under html/
14052
+ }
14053
+ }
14054
+ const htmlPath = BaseFileManager.getFilesPath('html', v.endsWith('.html') ? v : `${v}.html`);
14055
+ try {
14056
+ const text = await BaseFileManager.readFileAsString(htmlPath);
14057
+ if (text)
14058
+ return text;
14059
+ }
14060
+ catch {
14061
+ // fall through
14062
+ }
14063
+ }
14064
+ }
14065
+ catch {
14066
+ return null;
14067
+ }
14068
+ return null;
14069
+ },
14070
+ };
14071
+ }
14072
+
14073
+ let registered = false;
14074
+ /**
14075
+ * Register the SDK SQLite/files adapter with `@seedprotocol/query`.
14076
+ * Safe to call multiple times; re-registers with a fresh adapter instance.
14077
+ * No-op when the app DB is not ready yet (unless `force`).
14078
+ */
14079
+ function registerSeedQueryLocalSource(options) {
14080
+ if (!options?.force && !BaseDb.isAppDbReady()) {
14081
+ return false;
14082
+ }
14083
+ try {
14084
+ registerLocalQuerySource(createLocalQueryDataSource());
14085
+ registered = true;
14086
+ return true;
14087
+ }
14088
+ catch (err) {
14089
+ console.warn('[sdk/query] registerSeedQueryLocalSource failed:', err);
14090
+ return false;
14091
+ }
14092
+ }
14093
+ /** Unregister local query source (tests / client unload). */
14094
+ function unregisterSeedQueryLocalSource() {
14095
+ clearLocalQuerySource();
14096
+ registered = false;
14097
+ }
14098
+ function isSeedQueryLocalSourceRegistered() {
14099
+ return registered;
14100
+ }
14101
+ /**
14102
+ * Thin published-JSON helper: `getSeed` via the local (or auto) query source.
14103
+ * Does not touch Item / drafts / liveQuery.
14104
+ *
14105
+ * Prefer this (or `@seedprotocol/query` `getSeed` / `queryBySchema`) for
14106
+ * canonical published Seed JSON. Use `getItemData` / Item for draft-head authoring.
14107
+ */
14108
+ async function getPublishedSeedRecord(seedUid, options) {
14109
+ if (!registered) {
14110
+ registerSeedQueryLocalSource();
14111
+ }
14112
+ const source = options?.source ?? 'local';
14113
+ return getSeed(seedUid, { ...options, source });
14114
+ }
14115
+
13688
14116
  const logger$1 = debug('seedSdk:client');
13689
14117
  const clientManager = createActor(clientManagerMachine, {
13690
14118
  input: {
@@ -13789,6 +14217,8 @@ const clientInstance = {
13789
14217
  }
13790
14218
  throw error;
13791
14219
  }
14220
+ // Wire `@seedprotocol/query` local source once DB is ready
14221
+ registerSeedQueryLocalSource({ force: true });
13792
14222
  },
13793
14223
  setAddresses: async (addresses) => {
13794
14224
  ensureInitialized();
@@ -13850,10 +14280,12 @@ const clientInstance = {
13850
14280
  },
13851
14281
  stop: () => {
13852
14282
  ensureInitialized();
14283
+ unregisterSeedQueryLocalSource();
13853
14284
  clientManager.stop();
13854
14285
  },
13855
14286
  unload: () => {
13856
14287
  ensureInitialized();
14288
+ unregisterSeedQueryLocalSource();
13857
14289
  clientManager.stop();
13858
14290
  subscription.unsubscribe();
13859
14291
  },
@@ -14036,7 +14468,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
14036
14468
  // Lazy import cache for ModelProperty to avoid circular dependency
14037
14469
  // Eagerly start loading to minimize delay on first access
14038
14470
  let ModelPropertyClass = null;
14039
- const modelPropertyImportPromise = import('./ModelProperty-D-ysg8zA.js')
14471
+ const modelPropertyImportPromise = import('./ModelProperty-BBXBvgvy.js')
14040
14472
  .then(module => {
14041
14473
  ModelPropertyClass = module.ModelProperty;
14042
14474
  return ModelPropertyClass;
@@ -14053,7 +14485,7 @@ function getModelProperty() {
14053
14485
  }
14054
14486
  // Lazy import cache for Schema to avoid circular dependency
14055
14487
  let SchemaClass = null;
14056
- const schemaImportPromise = (async () => { const _mod_26 = await import('./Schema-CyCftnKI.js'); return _mod_26.b; })()
14488
+ const schemaImportPromise = (async () => { const _mod_26 = await import('./Schema-xAt7jWlW.js'); return _mod_26.b; })()
14057
14489
  .then(module => {
14058
14490
  SchemaClass = module.Schema;
14059
14491
  return SchemaClass;
@@ -15793,5 +16225,5 @@ var Model$1 = /*#__PURE__*/Object.freeze({
15793
16225
  const TModelValues = Type.Record(Type.String(), Type.Any());
15794
16226
  const TModelSchema = Type.Record(Type.String(), TProperty);
15795
16227
 
15796
- export { requestEasSyncFromAddressChange as $, compareMetadataRowsLatestFirst as A, ADDRESSES_PERSISTED_EVENT as B, ClientManager as C, parseAddressesPersistedPayload as D, getClient as E, createNewItem as F, getVersionData$1 as G, getMetadataLatest as H, Item as I, loadAllSchemasFromDb as J, propertyMachine as K, setUploadExecutor as L, Model as M, getUploadExecutor as N, setGetPublisherForNewSeeds as O, getGetPublisherForNewSeeds as P, setRevokeExecutor as Q, getRevokeExecutor as R, setAdditionalSyncAddresses as S, TModelValues as T, createSchema as U, readSchema as V, listCompleteSchemaFiles as W, getSchemaNameFromId as X, easSyncActor as Y, startEasSyncActor as Z, sendEasSyncClientRequest as _, TModelSchema as a, requestEasSyncFromEventBus as a0, requestEasSyncFromModelsInit as a1, mergeEasSyncRequestIntents as a2, createModelsFromJson as a3, getLatestSchemaVersion as a4, createModelFromJson as a5, ConflictError as a6, unloadEntity as a7, clearDestroySubscriptions as a8, setupEntityLiveQuery as a9, publishConfig as aa, generateId$1 as ab, model as ac, getPropertyData$1 as ad, Item$1 as ae, schema as af, SEEDPROTOCOL_Seed_Protocol_v1 as ag, Model$1 as ah, getContentHash as b, getItemData as c, getEasSchemaUidForModel as d, getLatestPublishedVersionRow as e, getEasSchemaForItemProperty as f, getGetAdditionalSyncAddresses as g, ItemProperty as h, eventEmitter as i, getRefValueType as j, importJsonSchema as k, loadSchemaFromFile as l, modelPropertiesToObject as m, readJsonImportFile as n, scheduleBulkFilesDownloadFromEasSync as o, parseListPropertyValueFromStorage as p, generateId as q, resolveStorageNameToSchemaName as r, syncSchemaFromSource as s, transformImportToSchemaFile as t, waitForEntityIdle as u, createReactiveProxy as v, writeProcessMachine as w, findEntity as x, forceRemoveFromCaches as y, runDestroyLifecycle as z };
15797
- //# sourceMappingURL=index--F3Wolt5.js.map
16228
+ export { listCompleteSchemaFiles as $, compareMetadataRowsLatestFirst as A, ADDRESSES_PERSISTED_EVENT as B, ClientManager as C, parseAddressesPersistedPayload as D, getClient as E, createNewItem as F, getVersionData$1 as G, getMetadataLatest as H, Item as I, loadAllSchemasFromDb as J, propertyMachine as K, createLocalQueryDataSource as L, Model as M, registerSeedQueryLocalSource as N, unregisterSeedQueryLocalSource as O, isSeedQueryLocalSourceRegistered as P, getPublishedSeedRecord as Q, setUploadExecutor as R, getUploadExecutor as S, TModelValues as T, setGetPublisherForNewSeeds as U, getGetPublisherForNewSeeds as V, setRevokeExecutor as W, getRevokeExecutor as X, setAdditionalSyncAddresses as Y, createSchema as Z, readSchema as _, TModelSchema as a, getSchemaNameFromId as a0, easSyncActor as a1, startEasSyncActor as a2, sendEasSyncClientRequest as a3, requestEasSyncFromAddressChange as a4, requestEasSyncFromEventBus as a5, requestEasSyncFromModelsInit as a6, mergeEasSyncRequestIntents as a7, createModelsFromJson as a8, getLatestSchemaVersion as a9, createModelFromJson as aa, ConflictError as ab, unloadEntity as ac, clearDestroySubscriptions as ad, setupEntityLiveQuery as ae, publishConfig as af, generateId$1 as ag, model as ah, getPropertyData$1 as ai, Item$1 as aj, schema as ak, SEEDPROTOCOL_Seed_Protocol_v1 as al, Model$1 as am, getContentHash as b, getItemData as c, getEasSchemaUidForModel as d, getLatestPublishedVersionRow as e, getEasSchemaForItemProperty as f, getGetAdditionalSyncAddresses as g, eventEmitter as h, generateId as i, ItemProperty as j, getRefValueType as k, importJsonSchema as l, modelPropertiesToObject as m, loadSchemaFromFile as n, readJsonImportFile as o, parseListPropertyValueFromStorage as p, syncSchemaFromSource as q, resolveStorageNameToSchemaName as r, scheduleBulkFilesDownloadFromEasSync as s, transformImportToSchemaFile as t, waitForEntityIdle as u, createReactiveProxy as v, writeProcessMachine as w, findEntity as x, forceRemoveFromCaches as y, runDestroyLifecycle as z };
16229
+ //# sourceMappingURL=index-ClwdGWfr.js.map