@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.
- package/dist/{ModelProperty-D-ysg8zA.js → ModelProperty-BBXBvgvy.js} +19 -18
- package/dist/ModelProperty-BBXBvgvy.js.map +1 -0
- package/dist/{Schema-CyCftnKI.js → Schema-xAt7jWlW.js} +36 -36
- package/dist/{Schema-CyCftnKI.js.map → Schema-xAt7jWlW.js.map} +1 -1
- package/dist/{SchemaValidationService-POM6jHbJ.js → SchemaValidationService-CLzAdBm-.js} +5 -4
- package/dist/{SchemaValidationService-POM6jHbJ.js.map → SchemaValidationService-CLzAdBm-.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-DzZw57iJ.js → backfillMetadataPropertyIds-DBVaIs7O.js} +2 -2
- package/dist/{backfillMetadataPropertyIds-DzZw57iJ.js.map → backfillMetadataPropertyIds-DBVaIs7O.js.map} +1 -1
- package/dist/cjs/{ModelProperty-CmuGJvyi.js → ModelProperty-Dgd4tGrB.js} +18 -18
- package/dist/cjs/{ModelProperty-CmuGJvyi.js.map → ModelProperty-Dgd4tGrB.js.map} +1 -1
- package/dist/cjs/{Schema-gpFnZMhB.js → Schema-dkd-eo3B.js} +21 -21
- package/dist/cjs/{Schema-gpFnZMhB.js.map → Schema-dkd-eo3B.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-E3xTSRai.js → SchemaValidationService-BMnjcVWV.js} +3 -3
- package/dist/cjs/{SchemaValidationService-E3xTSRai.js.map → SchemaValidationService-BMnjcVWV.js.map} +1 -1
- package/dist/cjs/{backfillMetadataPropertyIds-_bivrvRs.js → backfillMetadataPropertyIds-ClLuj3s6.js} +3 -3
- package/dist/cjs/{backfillMetadataPropertyIds-_bivrvRs.js.map → backfillMetadataPropertyIds-ClLuj3s6.js.map} +1 -1
- package/dist/cjs/{eas-BwDKJmlb.js → eas-nWAzbl_F.js} +4 -4
- package/dist/cjs/{eas-BwDKJmlb.js.map → eas-nWAzbl_F.js.map} +1 -1
- package/dist/cjs/{getItem-MShQw3sz.js → getItem-B08FgglK.js} +3 -3
- package/dist/cjs/{getItem-MShQw3sz.js.map → getItem-B08FgglK.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-C1nOOXp_.js → getPublishPayload-B_G_6qkE.js} +12 -12
- package/dist/cjs/{getPublishPayload-C1nOOXp_.js.map → getPublishPayload-B_G_6qkE.js.map} +1 -1
- package/dist/cjs/{getPublishUploads-BjgxgrKD.js → getPublishUploads-Dt-DS-lo.js} +5 -5
- package/dist/cjs/{getPublishUploads-BjgxgrKD.js.map → getPublishUploads-Dt-DS-lo.js.map} +1 -1
- package/dist/cjs/{getSegmentedItemProperties-Cuw7wcxb.js → getSegmentedItemProperties-BDGbeDW7.js} +3 -3
- package/dist/cjs/{getSegmentedItemProperties-Cuw7wcxb.js.map → getSegmentedItemProperties-BDGbeDW7.js.map} +1 -1
- package/dist/cjs/{index-vk2DeF2D.js → index-CRBI6dSD.js} +475 -58
- package/dist/cjs/index-CRBI6dSD.js.map +1 -0
- package/dist/cjs/{index-9Z2FOvLD.js → index-Dx19j60c.js} +4 -4
- package/dist/cjs/index-Dx19j60c.js.map +1 -0
- package/dist/cjs/{ownership-DhWda0J9.js → ownership-3Tc1-Yrc.js} +3 -3
- package/dist/cjs/{ownership-DhWda0J9.js.map → ownership-3Tc1-Yrc.js.map} +1 -1
- package/dist/cjs/{property-D3Ww2_Qh.js → property-628qAHpN.js} +5 -5
- package/dist/cjs/{property-D3Ww2_Qh.js.map → property-628qAHpN.js.map} +1 -1
- package/dist/cjs/{syncDbWithEas-Dht3_7UD.js → syncDbWithEas-DOBtMPw-.js} +46 -49
- package/dist/cjs/syncDbWithEas-DOBtMPw-.js.map +1 -0
- package/dist/{configurePlatform-R5neRbQ9.js → configurePlatform-Ce6NIKRP.js} +3 -2
- package/dist/{configurePlatform-R5neRbQ9.js.map → configurePlatform-Ce6NIKRP.js.map} +1 -1
- package/dist/{constants-B5S5JPDK.js → constants-slkc9uq0.js} +13 -18
- package/dist/constants-slkc9uq0.js.map +1 -0
- package/dist/{db-Cvh84NY7.js → db-CSmK0c3e.js} +9 -9
- package/dist/{db-Cvh84NY7.js.map → db-CSmK0c3e.js.map} +1 -1
- package/dist/{eas-D9b7z2Wn.js → eas-rx1grht5.js} +5 -4
- package/dist/eas-rx1grht5.js.map +1 -0
- package/dist/{getItem-B81V3m4S.js → getItem-hPBJU5JF.js} +5 -4
- package/dist/{getItem-B81V3m4S.js.map → getItem-hPBJU5JF.js.map} +1 -1
- package/dist/{getPublishPayload-CNYsn8-6.js → getPublishPayload-5ugovGK5.js} +16 -15
- package/dist/getPublishPayload-5ugovGK5.js.map +1 -0
- package/dist/{getPublishUploads-D9rPHkB7.js → getPublishUploads-CdWeci-s.js} +7 -6
- package/dist/{getPublishUploads-D9rPHkB7.js.map → getPublishUploads-CdWeci-s.js.map} +1 -1
- package/dist/{getSegmentedItemProperties-Bg3_b-b1.js → getSegmentedItemProperties-DV2LHElJ.js} +4 -4
- package/dist/{getSegmentedItemProperties-Bg3_b-b1.js.map → getSegmentedItemProperties-DV2LHElJ.js.map} +1 -1
- package/dist/{index-oi4roUVf.js → index-CcH2e0Zr.js} +6 -5
- package/dist/index-CcH2e0Zr.js.map +1 -0
- package/dist/{index--F3Wolt5.js → index-ClwdGWfr.js} +477 -45
- package/dist/index-ClwdGWfr.js.map +1 -0
- package/dist/{index.node-Bow8kHew.js → index.node-CrXwRoiB.js} +2 -2
- package/dist/{index.node-Bow8kHew.js.map → index.node-CrXwRoiB.js.map} +1 -1
- package/dist/main.cjs +3 -6
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +19 -18
- package/dist/main.js.map +1 -1
- package/dist/node.js +30 -9
- package/dist/node.js.map +1 -1
- package/dist/{ownership-BF_ZUKIp.js → ownership-58i0iyD9.js} +5 -4
- package/dist/{ownership-BF_ZUKIp.js.map → ownership-58i0iyD9.js.map} +1 -1
- package/dist/platform.browser.js +16 -3
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.node.js +1 -1
- package/dist/{property-BdyDfcSc.js → property-CKhOxRNt.js} +8 -7
- package/dist/property-CKhOxRNt.js.map +1 -0
- package/dist/src/Item/service/actors/saveDataToDb.d.ts.map +1 -1
- package/dist/src/browser/helpers/ArweaveClient.d.ts.map +1 -1
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/src/db/read/getItemData.d.ts +8 -0
- package/dist/src/db/read/getItemData.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/helpers/gateway/resolveSeedGatewayEndpoints.d.ts +1 -1
- package/dist/src/helpers/gateway/resolveSeedGatewayEndpoints.d.ts.map +1 -1
- package/dist/src/helpers/index.d.ts +1 -5
- package/dist/src/helpers/index.d.ts.map +1 -1
- package/dist/src/helpers/mediaRef.d.ts +3 -0
- package/dist/src/helpers/mediaRef.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/node/webpack/index.d.ts +4 -1
- package/dist/src/node/webpack/index.d.ts.map +1 -1
- package/dist/src/query/createLocalQueryDataSource.d.ts +6 -0
- package/dist/src/query/createLocalQueryDataSource.d.ts.map +1 -0
- package/dist/src/query/index.d.ts +4 -0
- package/dist/src/query/index.d.ts.map +1 -0
- package/dist/src/query/registerSeedQueryLocalSource.d.ts +25 -0
- package/dist/src/query/registerSeedQueryLocalSource.d.ts.map +1 -0
- package/dist/src/types/machines.d.ts +2 -0
- package/dist/src/types/machines.d.ts.map +1 -1
- package/dist/{syncDbWithEas-DMOJHtkP.js → syncDbWithEas-GsaXzTIY.js} +50 -52
- package/dist/syncDbWithEas-GsaXzTIY.js.map +1 -0
- package/package.json +5 -5
- package/dist/ModelProperty-D-ysg8zA.js.map +0 -1
- package/dist/cjs/index-9Z2FOvLD.js.map +0 -1
- package/dist/cjs/index-vk2DeF2D.js.map +0 -1
- package/dist/cjs/syncDbWithEas-Dht3_7UD.js.map +0 -1
- package/dist/constants-B5S5JPDK.js.map +0 -1
- package/dist/eas-D9b7z2Wn.js.map +0 -1
- package/dist/getPublishPayload-CNYsn8-6.js.map +0 -1
- package/dist/index--F3Wolt5.js.map +0 -1
- package/dist/index-oi4roUVf.js.map +0 -1
- package/dist/property-BdyDfcSc.js.map +0 -1
- package/dist/syncDbWithEas-DMOJHtkP.js.map +0 -1
|
@@ -12,6 +12,7 @@ var pluralize = require('pluralize');
|
|
|
12
12
|
var typebox = require('@sinclair/typebox');
|
|
13
13
|
var nanoid = require('nanoid');
|
|
14
14
|
var nanoidDictionary = require('nanoid-dictionary');
|
|
15
|
+
var query = require('@seedprotocol/query');
|
|
15
16
|
var casing = require('drizzle-orm/casing');
|
|
16
17
|
var lodashEs = require('lodash-es');
|
|
17
18
|
var rxjs = require('rxjs');
|
|
@@ -24,7 +25,6 @@ var client = require('@libsql/client');
|
|
|
24
25
|
var libsql = require('drizzle-orm/libsql');
|
|
25
26
|
var migrator = require('drizzle-orm/libsql/migrator');
|
|
26
27
|
var yaml = require('js-yaml');
|
|
27
|
-
require('@seedprotocol/webpack');
|
|
28
28
|
var child_process = require('child_process');
|
|
29
29
|
var node$1 = require('@seedprotocol/arweave/node');
|
|
30
30
|
var node = require('@seedprotocol/eas/node');
|
|
@@ -988,21 +988,6 @@ const convertTxIdToImage = async (txId) => {
|
|
|
988
988
|
const imageBlob = new Blob([uint]);
|
|
989
989
|
return URL.createObjectURL(imageBlob);
|
|
990
990
|
};
|
|
991
|
-
const parseEasRelationPropertyName = (easPropertyName) => {
|
|
992
|
-
// Split the input string on the first underscore
|
|
993
|
-
const [singularProperty, modelName, idSegment] = easPropertyName.split('_');
|
|
994
|
-
// If there are any other parts, assume it is a list (e.g., has 'ids' or other suffix)
|
|
995
|
-
const isList = idSegment === 'ids';
|
|
996
|
-
// Create the final property name by pluralizing the singular part
|
|
997
|
-
const propertyName = singularProperty.endsWith('s')
|
|
998
|
-
? singularProperty
|
|
999
|
-
: singularProperty + 's';
|
|
1000
|
-
return {
|
|
1001
|
-
propertyName, // Plural form of the property name
|
|
1002
|
-
modelName, // Model name extracted from the second part
|
|
1003
|
-
isList, // True if the property is a list (e.g., 'ids' is present)
|
|
1004
|
-
};
|
|
1005
|
-
};
|
|
1006
991
|
|
|
1007
992
|
const logger$v = debug('seedSdk:model:actors:loadOrCreateModel');
|
|
1008
993
|
/**
|
|
@@ -1015,7 +1000,7 @@ const createPropertyInstances = async (propertyFileIds) => {
|
|
|
1015
1000
|
return;
|
|
1016
1001
|
}
|
|
1017
1002
|
try {
|
|
1018
|
-
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-
|
|
1003
|
+
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-Dgd4tGrB.js'); });
|
|
1019
1004
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
1020
1005
|
if (!ModelProperty) {
|
|
1021
1006
|
logger$v('createPropertyInstances: ModelProperty not available from dynamic import');
|
|
@@ -1199,7 +1184,7 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
1199
1184
|
// Step 2: Fallback to Schema context (only if database doesn't have the model)
|
|
1200
1185
|
// This handles the case where model exists in schema file but not yet in database
|
|
1201
1186
|
try {
|
|
1202
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-
|
|
1187
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-dkd-eo3B.js'); });
|
|
1203
1188
|
const { Schema } = schemaMod;
|
|
1204
1189
|
const schema = Schema.create(schemaName, { waitForReady: false });
|
|
1205
1190
|
const schemaSnapshot = schema.getService().getSnapshot();
|
|
@@ -1443,7 +1428,7 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
1443
1428
|
}
|
|
1444
1429
|
// Mark schema as draft when a new model is created so saveNewVersion() can persist it
|
|
1445
1430
|
try {
|
|
1446
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-
|
|
1431
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-dkd-eo3B.js'); });
|
|
1447
1432
|
const { Schema } = schemaMod;
|
|
1448
1433
|
const schema = Schema.create(schemaName, { waitForReady: false });
|
|
1449
1434
|
schema.getService().send({ type: 'markAsDraft', propertyKey: 'schema:models' });
|
|
@@ -1487,10 +1472,10 @@ const validateModel = xstate.fromCallback(({ sendBack, input: { context } }) =>
|
|
|
1487
1472
|
const _validateModel = async () => {
|
|
1488
1473
|
try {
|
|
1489
1474
|
// Use dynamic imports to break circular dependencies
|
|
1490
|
-
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
1475
|
+
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-BMnjcVWV.js'); });
|
|
1491
1476
|
const { SchemaValidationService } = validationServiceMod;
|
|
1492
1477
|
const validationService = new SchemaValidationService();
|
|
1493
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-
|
|
1478
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-dkd-eo3B.js'); });
|
|
1494
1479
|
const { Schema } = schemaMod;
|
|
1495
1480
|
// Validate model structure
|
|
1496
1481
|
const structureResult = validationService.validateModelStructure(context);
|
|
@@ -1600,7 +1585,7 @@ const createModelProperties = xstate.fromCallback(({ sendBack, input }) => {
|
|
|
1600
1585
|
return;
|
|
1601
1586
|
}
|
|
1602
1587
|
logger$t(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
|
|
1603
|
-
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-
|
|
1588
|
+
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-Dgd4tGrB.js'); });
|
|
1604
1589
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
1605
1590
|
if (!ModelProperty) {
|
|
1606
1591
|
logger$t('ModelProperty not available from dynamic import');
|
|
@@ -1703,7 +1688,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1703
1688
|
const structureMsg = `[validateEntity] Validating model structure`;
|
|
1704
1689
|
logger$s(structureMsg);
|
|
1705
1690
|
// Use existing Model validation
|
|
1706
|
-
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
1691
|
+
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-BMnjcVWV.js'); });
|
|
1707
1692
|
const { SchemaValidationService } = validationServiceMod;
|
|
1708
1693
|
const validationService = new SchemaValidationService();
|
|
1709
1694
|
// Validate model structure
|
|
@@ -1721,7 +1706,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1721
1706
|
if (entityInput.entityData.schemaName) {
|
|
1722
1707
|
try {
|
|
1723
1708
|
logger$s(`[validateEntity] Validating model against schema "${entityInput.entityData.schemaName}"`);
|
|
1724
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-
|
|
1709
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-dkd-eo3B.js'); });
|
|
1725
1710
|
const { Schema } = schemaMod;
|
|
1726
1711
|
const schema = Schema.create(entityInput.entityData.schemaName, {
|
|
1727
1712
|
waitForReady: false,
|
|
@@ -1757,7 +1742,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1757
1742
|
}
|
|
1758
1743
|
else if (entityInput.entityType === 'modelProperty') {
|
|
1759
1744
|
// Use existing ModelProperty validation
|
|
1760
|
-
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
1745
|
+
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-BMnjcVWV.js'); });
|
|
1761
1746
|
const { SchemaValidationService } = validationServiceMod;
|
|
1762
1747
|
const validationService = new SchemaValidationService();
|
|
1763
1748
|
// Validate property structure
|
|
@@ -1772,7 +1757,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1772
1757
|
// If schema name and model name provided, validate against schema
|
|
1773
1758
|
if (entityInput.entityData._schemaName && entityInput.entityData.modelName) {
|
|
1774
1759
|
try {
|
|
1775
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-
|
|
1760
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-dkd-eo3B.js'); });
|
|
1776
1761
|
const { Schema } = schemaMod;
|
|
1777
1762
|
const schema = Schema.create(entityInput.entityData._schemaName, {
|
|
1778
1763
|
waitForReady: false,
|
|
@@ -1801,7 +1786,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1801
1786
|
}
|
|
1802
1787
|
else if (entityInput.entityType === 'schema') {
|
|
1803
1788
|
// Schema validation - use existing validation
|
|
1804
|
-
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
1789
|
+
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-BMnjcVWV.js'); });
|
|
1805
1790
|
const { SchemaValidationService } = validationServiceMod;
|
|
1806
1791
|
const validationService = new SchemaValidationService();
|
|
1807
1792
|
const schemaResult = validationService.validateSchema(entityInput.entityData);
|
|
@@ -3842,7 +3827,7 @@ const writeToDatabase = xstate.fromCallback(({ sendBack, input }) => {
|
|
|
3842
3827
|
// initial write completes is not overwritten by the stale requestWrite payload.
|
|
3843
3828
|
let dataToWrite = input.entityData;
|
|
3844
3829
|
try {
|
|
3845
|
-
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-
|
|
3830
|
+
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-Dgd4tGrB.js'); });
|
|
3846
3831
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
3847
3832
|
if (ModelProperty && typeof ModelProperty.getById === 'function') {
|
|
3848
3833
|
const instance = ModelProperty.getById(input.entityId);
|
|
@@ -4222,7 +4207,7 @@ const modelMachine = xstate.setup({
|
|
|
4222
4207
|
// Create ModelProperty instances for any new property IDs
|
|
4223
4208
|
if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
|
|
4224
4209
|
// Import and create instances asynchronously (fire-and-forget)
|
|
4225
|
-
Promise.resolve().then(function () { return require('./ModelProperty-
|
|
4210
|
+
Promise.resolve().then(function () { return require('./ModelProperty-Dgd4tGrB.js'); }).then(({ ModelProperty }) => {
|
|
4226
4211
|
const createPromises = newPropertyIds.map(async (propertyFileId) => {
|
|
4227
4212
|
try {
|
|
4228
4213
|
const property = await ModelProperty.createById(propertyFileId);
|
|
@@ -5203,7 +5188,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
5203
5188
|
const schemaNameToTry = model$1?.schemaName;
|
|
5204
5189
|
if (schemaNameToTry) {
|
|
5205
5190
|
try {
|
|
5206
|
-
const { Schema } = await Promise.resolve().then(function () { return require('./Schema-
|
|
5191
|
+
const { Schema } = await Promise.resolve().then(function () { return require('./Schema-dkd-eo3B.js'); });
|
|
5207
5192
|
const schemaInstance = Schema.create(schemaNameToTry, { waitForReady: false });
|
|
5208
5193
|
const schemaContext = schemaInstance.getService().getSnapshot().context;
|
|
5209
5194
|
if (schemaContext.models?.[modelName]?.properties) {
|
|
@@ -5252,7 +5237,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
5252
5237
|
}
|
|
5253
5238
|
}
|
|
5254
5239
|
if (Object.keys(propertySchemas).length === 0) {
|
|
5255
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
5240
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-Dx19j60c.js'); });
|
|
5256
5241
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
5257
5242
|
const KNOWN_MODEL_FALLBACKS = {
|
|
5258
5243
|
Post: {
|
|
@@ -5299,7 +5284,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
5299
5284
|
// Infer propertyRecordSchema from metadata when schema is missing (enables persistence)
|
|
5300
5285
|
let propSchema = propertySchemas[propertyName];
|
|
5301
5286
|
if (!propSchema && isRefTypeFromMeta) {
|
|
5302
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
5287
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-Dx19j60c.js'); });
|
|
5303
5288
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
5304
5289
|
propSchema = {
|
|
5305
5290
|
dataType: refSeedType === 'html' ? ModelPropertyDataTypes.Html
|
|
@@ -5556,9 +5541,9 @@ const runPublish = xstate.fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5556
5541
|
sendBack({ type: 'publishError', error: new Error(`Item not found for seedLocalId: ${seedLocalId}`) });
|
|
5557
5542
|
return;
|
|
5558
5543
|
}
|
|
5559
|
-
const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-
|
|
5544
|
+
const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-Dt-DS-lo.js'); });
|
|
5560
5545
|
const { getPublishUploads } = getPublishUploadsMod;
|
|
5561
|
-
const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-
|
|
5546
|
+
const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-B_G_6qkE.js'); });
|
|
5562
5547
|
const { getPublishPayload } = getPublishPayloadMod;
|
|
5563
5548
|
const uploads = await getPublishUploads(item);
|
|
5564
5549
|
let uploadedTransactions = [];
|
|
@@ -6072,6 +6057,14 @@ async function getLatestPublishedVersionRow(seedLocalId) {
|
|
|
6072
6057
|
}
|
|
6073
6058
|
|
|
6074
6059
|
const logger$l = debug('seedSdk:db:read:getItemData');
|
|
6060
|
+
/**
|
|
6061
|
+
* Assemble flat ItemData for Item / liveQuery / draft-head authoring.
|
|
6062
|
+
*
|
|
6063
|
+
* For **published chain JSON** (Seed → latest attested Version → properties),
|
|
6064
|
+
* prefer `getPublishedSeedRecord` from `@seedprotocol/sdk` or
|
|
6065
|
+
* `getSeed` / `queryBySchema` from `@seedprotocol/query`. This function remains
|
|
6066
|
+
* the correct path for local-head / draft-wins property selection used by Item.
|
|
6067
|
+
*/
|
|
6075
6068
|
const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
6076
6069
|
if (!seedLocalId && !seedUid) {
|
|
6077
6070
|
throw new Error('[db/queries] [getItem] no seedLocalId or seedUid');
|
|
@@ -6531,7 +6524,7 @@ const resolveRelatedValue = xstate.fromCallback(({ sendBack, input: { context }
|
|
|
6531
6524
|
const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
|
|
6532
6525
|
const _resolveRelatedValue = async () => {
|
|
6533
6526
|
// Use dynamic import to break circular dependency
|
|
6534
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
6527
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-Dx19j60c.js'); });
|
|
6535
6528
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
6536
6529
|
if (!propertyValue || !isRelation || populatedFromDb) {
|
|
6537
6530
|
return;
|
|
@@ -7393,7 +7386,7 @@ async function fetchHtmlViaRawAcrossGateways(txId) {
|
|
|
7393
7386
|
return undefined;
|
|
7394
7387
|
try {
|
|
7395
7388
|
const resolved = arweave.getResolvedSeedGatewayEndpoints();
|
|
7396
|
-
if (!resolved || resolved.activePath !== 'hyper-sidecar') {
|
|
7389
|
+
if (!resolved || (resolved.activePath !== 'hyper-sidecar' && resolved.activePath !== 'http-proxy')) {
|
|
7397
7390
|
const { ensureReadGatewaySelected } = await import('@seedprotocol/arweave');
|
|
7398
7391
|
await ensureReadGatewaySelected().catch(() => { });
|
|
7399
7392
|
}
|
|
@@ -7534,7 +7527,7 @@ const hydrateFromDb = xstate.fromCallback(({ sendBack, input: { context } }) =>
|
|
|
7534
7527
|
// to use dynamically imported ModelPropertyDataTypes
|
|
7535
7528
|
const _hydrateFromDb = async () => {
|
|
7536
7529
|
// Use dynamic import to break circular dependency
|
|
7537
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
7530
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-Dx19j60c.js'); });
|
|
7538
7531
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
7539
7532
|
const appDb = BaseDb.getAppDb();
|
|
7540
7533
|
const whereClauses = [];
|
|
@@ -7897,7 +7890,7 @@ const loadOrCreateProperty = xstate.fromCallback(({ sendBack, input: { context }
|
|
|
7897
7890
|
};
|
|
7898
7891
|
// Merge with schema from file/DB to get validation rules (enum, pattern, etc.) - properties table doesn't store these
|
|
7899
7892
|
try {
|
|
7900
|
-
const { getPropertySchema } = await Promise.resolve().then(function () { return require('./property-
|
|
7893
|
+
const { getPropertySchema } = await Promise.resolve().then(function () { return require('./property-628qAHpN.js'); });
|
|
7901
7894
|
let schemaFromFile = await getPropertySchema(normalizedModelName, propertyName);
|
|
7902
7895
|
if (!schemaFromFile?.validation) {
|
|
7903
7896
|
// Fallback: get validation from schemaData in database (Schema context may not be loaded yet)
|
|
@@ -8362,9 +8355,9 @@ const analyzeInput = xstate.fromCallback(({ sendBack, input: { context, event }
|
|
|
8362
8355
|
}
|
|
8363
8356
|
const _analyzeInput = async () => {
|
|
8364
8357
|
// Use dynamic import to break circular dependency
|
|
8365
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
8358
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-Dx19j60c.js'); });
|
|
8366
8359
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
8367
|
-
const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
8360
|
+
const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-BMnjcVWV.js'); });
|
|
8368
8361
|
let propertyName = propertyNameRaw;
|
|
8369
8362
|
if (!propertyName) {
|
|
8370
8363
|
throw new Error('propertyName is required');
|
|
@@ -8562,7 +8555,7 @@ const createMetadata = async (metadataValues, propertyRecordSchema, options) =>
|
|
|
8562
8555
|
propertyRecordSchema?.validation &&
|
|
8563
8556
|
metadataValues.propertyValue != null &&
|
|
8564
8557
|
metadataValues.propertyValue !== '') {
|
|
8565
|
-
const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
8558
|
+
const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-BMnjcVWV.js'); });
|
|
8566
8559
|
const validationService = new SchemaValidationService();
|
|
8567
8560
|
const validationResult = validationService.validatePropertyValue(metadataValues.propertyValue, normalizeDataType(propertyRecordSchema.dataType), propertyRecordSchema.validation, propertyRecordSchema.refValueType
|
|
8568
8561
|
? normalizeDataType(String(propertyRecordSchema.refValueType))
|
|
@@ -9155,7 +9148,7 @@ const saveRelation = xstate.fromCallback(({ sendBack, input: { context, event }
|
|
|
9155
9148
|
}
|
|
9156
9149
|
const _saveRelation = async () => {
|
|
9157
9150
|
// Use dynamic import to break circular dependency
|
|
9158
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
9151
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-Dx19j60c.js'); });
|
|
9159
9152
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
9160
9153
|
if (!propertyNameRaw) {
|
|
9161
9154
|
throw new Error('propertyName is required');
|
|
@@ -10199,7 +10192,7 @@ class ItemProperty {
|
|
|
10199
10192
|
return;
|
|
10200
10193
|
}
|
|
10201
10194
|
// Use dynamic import to break circular dependency
|
|
10202
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
10195
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-Dx19j60c.js'); });
|
|
10203
10196
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
10204
10197
|
const { context } = snapshot;
|
|
10205
10198
|
const { propertyRecordSchema } = context;
|
|
@@ -11108,7 +11101,7 @@ class ItemProperty {
|
|
|
11108
11101
|
}
|
|
11109
11102
|
async save() {
|
|
11110
11103
|
const ctx = this._getSnapshotContext();
|
|
11111
|
-
const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-
|
|
11104
|
+
const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-3Tc1-Yrc.js'); });
|
|
11112
11105
|
await assertItemOwned({
|
|
11113
11106
|
seedLocalId: ctx?.seedLocalId ?? undefined,
|
|
11114
11107
|
seedUid: ctx?.seedUid ?? undefined,
|
|
@@ -11447,7 +11440,7 @@ class Item {
|
|
|
11447
11440
|
});
|
|
11448
11441
|
};
|
|
11449
11442
|
this.unpublish = async () => {
|
|
11450
|
-
const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-
|
|
11443
|
+
const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-3Tc1-Yrc.js'); });
|
|
11451
11444
|
const { getRevokeExecutor } = await Promise.resolve().then(function () { return publishConfig; });
|
|
11452
11445
|
await assertItemOwned(this);
|
|
11453
11446
|
const seedUid = this.seedUid;
|
|
@@ -11471,7 +11464,7 @@ class Item {
|
|
|
11471
11464
|
this._service.send({ type: 'updateContext', revokedAt });
|
|
11472
11465
|
};
|
|
11473
11466
|
this.publish = async () => {
|
|
11474
|
-
const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-
|
|
11467
|
+
const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-3Tc1-Yrc.js'); });
|
|
11475
11468
|
await assertItemOwned(this);
|
|
11476
11469
|
this._service.send({ type: 'startPublish' });
|
|
11477
11470
|
return new Promise((resolve, reject) => {
|
|
@@ -11507,12 +11500,12 @@ class Item {
|
|
|
11507
11500
|
};
|
|
11508
11501
|
this.getPublishUploads = async (options) => {
|
|
11509
11502
|
// Use dynamic import to break circular dependency
|
|
11510
|
-
const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-
|
|
11503
|
+
const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-Dt-DS-lo.js'); });
|
|
11511
11504
|
const { getPublishUploads } = getPublishUploadsMod;
|
|
11512
11505
|
return await getPublishUploads(this, [], undefined, options);
|
|
11513
11506
|
};
|
|
11514
11507
|
this.getPublishPayload = async (uploadedTransactions, options) => {
|
|
11515
|
-
const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-
|
|
11508
|
+
const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-B_G_6qkE.js'); });
|
|
11516
11509
|
const { getPublishPayload } = getPublishPayloadMod;
|
|
11517
11510
|
return await getPublishPayload(this, uploadedTransactions, options);
|
|
11518
11511
|
};
|
|
@@ -13006,7 +12999,7 @@ class Item {
|
|
|
13006
12999
|
* Destroy the item: soft delete in DB, remove from caches, clean up subscriptions, stop service.
|
|
13007
13000
|
*/
|
|
13008
13001
|
async destroy() {
|
|
13009
|
-
const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-
|
|
13002
|
+
const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-3Tc1-Yrc.js'); });
|
|
13010
13003
|
await assertItemOwned(this);
|
|
13011
13004
|
const context = this._getSnapshotContext();
|
|
13012
13005
|
const cacheKeys = Item.collectInstanceCacheKeysForInstance(this);
|
|
@@ -13162,7 +13155,7 @@ const runEasSync = xstate.fromPromise(async ({ input, }) => {
|
|
|
13162
13155
|
requestPayload: input.requestPayload,
|
|
13163
13156
|
persistedSnapshot: input.runningSnapshot,
|
|
13164
13157
|
});
|
|
13165
|
-
const { runSyncFromEas } = await Promise.resolve().then(function () { return require('./syncDbWithEas-
|
|
13158
|
+
const { runSyncFromEas } = await Promise.resolve().then(function () { return require('./syncDbWithEas-DOBtMPw-.js'); });
|
|
13166
13159
|
try {
|
|
13167
13160
|
await runSyncFromEas(toRunSyncArg(input.options));
|
|
13168
13161
|
await finalizeEasSyncProcessRow(rowId, {
|
|
@@ -13577,6 +13570,7 @@ const platformClassesInit = xstate.fromCallback(({ sendBack, input: { context, e
|
|
|
13577
13570
|
gatewayHyperKey: resolvedGateway.gatewayHyperKey,
|
|
13578
13571
|
gatewaySidecarHost: gatewayConfig.hyper?.localSidecarHost,
|
|
13579
13572
|
gatewaySidecarPort: gatewayConfig.hyper?.localSidecarPort,
|
|
13573
|
+
gatewayProxyBaseUrl: resolvedGateway.proxyBaseUrl ?? gatewayConfig.proxyBaseUrl,
|
|
13580
13574
|
addresses: normalizedAddresses.owned,
|
|
13581
13575
|
ownedAddresses: normalizedAddresses.owned,
|
|
13582
13576
|
watchedAddresses: normalizedAddresses.watched,
|
|
@@ -13586,7 +13580,7 @@ const platformClassesInit = xstate.fromCallback(({ sendBack, input: { context, e
|
|
|
13586
13580
|
schema,
|
|
13587
13581
|
syncFromEasOnAddressChange: options.syncFromEasOnAddressChange ?? true,
|
|
13588
13582
|
} });
|
|
13589
|
-
if (resolvedGateway.activePath !== 'hyper-sidecar') {
|
|
13583
|
+
if (resolvedGateway.activePath !== 'hyper-sidecar' && resolvedGateway.activePath !== 'http-proxy') {
|
|
13590
13584
|
void arweave.ensureReadGatewaySelected().catch(() => {
|
|
13591
13585
|
/* non-blocking warm-up for read gateway probe */
|
|
13592
13586
|
});
|
|
@@ -13925,7 +13919,7 @@ const addModelsToDb = xstate.fromCallback(({ sendBack, input: { context } }) =>
|
|
|
13925
13919
|
const logger$7 = debug('seedSdk:client:actors:saveConfig');
|
|
13926
13920
|
const saveConfig = xstate.fromCallback(({ sendBack, input: { context } }) => {
|
|
13927
13921
|
logger$7('saveConfig starting');
|
|
13928
|
-
const { endpoints, addresses, ownedAddresses, watchedAddresses, arweaveDomain, uploadApiBaseUrl, gatewayTransport, gatewayHyperKey, gatewaySidecarHost, gatewaySidecarPort, } = context;
|
|
13922
|
+
const { endpoints, addresses, ownedAddresses, watchedAddresses, arweaveDomain, uploadApiBaseUrl, gatewayTransport, gatewayHyperKey, gatewaySidecarHost, gatewaySidecarPort, gatewayProxyBaseUrl, } = context;
|
|
13929
13923
|
// Validate endpoints - required for proper initialization
|
|
13930
13924
|
// If endpoints are missing or invalid, initialization should fail
|
|
13931
13925
|
if (!endpoints || !endpoints.filePaths || !endpoints.files) {
|
|
@@ -14005,6 +13999,7 @@ const saveConfig = xstate.fromCallback(({ sendBack, input: { context } }) => {
|
|
|
14005
13999
|
if (gatewaySidecarPort != null) {
|
|
14006
14000
|
await persistKey('gatewaySidecarPort', String(gatewaySidecarPort));
|
|
14007
14001
|
}
|
|
14002
|
+
await persistKey('gatewayProxyBaseUrl', gatewayProxyBaseUrl);
|
|
14008
14003
|
}
|
|
14009
14004
|
catch (error) {
|
|
14010
14005
|
logger$7('[internal/actors] [saveConfig] Error saving config:', error);
|
|
@@ -16500,6 +16495,403 @@ const clientManagerMachine = xstate.setup({
|
|
|
16500
16495
|
},
|
|
16501
16496
|
});
|
|
16502
16497
|
|
|
16498
|
+
function msToUnixSeconds(ms) {
|
|
16499
|
+
if (ms == null || !Number.isFinite(ms))
|
|
16500
|
+
return 0;
|
|
16501
|
+
// Heuristic: values already in seconds are small; ms are large
|
|
16502
|
+
if (ms > 1e12)
|
|
16503
|
+
return Math.floor(ms / 1000);
|
|
16504
|
+
if (ms > 1e10)
|
|
16505
|
+
return Math.floor(ms / 1000);
|
|
16506
|
+
return Math.floor(ms);
|
|
16507
|
+
}
|
|
16508
|
+
function toSnakeCaseName(name) {
|
|
16509
|
+
return name
|
|
16510
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1_$2')
|
|
16511
|
+
.replace(/([A-Z])([A-Z][a-z])/g, '$1_$2')
|
|
16512
|
+
.toLowerCase();
|
|
16513
|
+
}
|
|
16514
|
+
function parsePropertyValue(raw) {
|
|
16515
|
+
if (raw == null)
|
|
16516
|
+
return '';
|
|
16517
|
+
const t = raw.trim();
|
|
16518
|
+
if ((t.startsWith('[') && t.endsWith(']')) ||
|
|
16519
|
+
(t.startsWith('{') && t.endsWith('}'))) {
|
|
16520
|
+
try {
|
|
16521
|
+
return JSON.parse(t);
|
|
16522
|
+
}
|
|
16523
|
+
catch {
|
|
16524
|
+
return raw;
|
|
16525
|
+
}
|
|
16526
|
+
}
|
|
16527
|
+
return raw;
|
|
16528
|
+
}
|
|
16529
|
+
function attestationFromRaw(raw) {
|
|
16530
|
+
if (!raw || !raw.trim())
|
|
16531
|
+
return null;
|
|
16532
|
+
try {
|
|
16533
|
+
const parsed = JSON.parse(raw);
|
|
16534
|
+
if (parsed && typeof parsed.id === 'string')
|
|
16535
|
+
return parsed;
|
|
16536
|
+
}
|
|
16537
|
+
catch {
|
|
16538
|
+
// fall through
|
|
16539
|
+
}
|
|
16540
|
+
return null;
|
|
16541
|
+
}
|
|
16542
|
+
function seedRowToAttestation(row) {
|
|
16543
|
+
if (!row.uid || !eas.isValidEasAttestationUid(row.uid))
|
|
16544
|
+
return null;
|
|
16545
|
+
const fromRaw = attestationFromRaw(row.attestationRaw);
|
|
16546
|
+
if (fromRaw) {
|
|
16547
|
+
const schemaName = row.schemaName ??
|
|
16548
|
+
fromRaw.schema?.schemaNames?.[0]?.name ??
|
|
16549
|
+
row.type ??
|
|
16550
|
+
'unknown';
|
|
16551
|
+
return {
|
|
16552
|
+
...fromRaw,
|
|
16553
|
+
id: row.uid,
|
|
16554
|
+
schema: {
|
|
16555
|
+
schemaNames: [{ name: schemaName }],
|
|
16556
|
+
},
|
|
16557
|
+
timeCreated: fromRaw.timeCreated ||
|
|
16558
|
+
msToUnixSeconds(row.attestationCreatedAt),
|
|
16559
|
+
attester: fromRaw.attester ?? row.publisher ?? undefined,
|
|
16560
|
+
schemaId: fromRaw.schemaId || row.schemaUid || '',
|
|
16561
|
+
};
|
|
16562
|
+
}
|
|
16563
|
+
const schemaName = row.schemaName ?? row.type ?? 'unknown';
|
|
16564
|
+
return {
|
|
16565
|
+
id: row.uid,
|
|
16566
|
+
decodedDataJson: '',
|
|
16567
|
+
refUID: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
16568
|
+
schemaId: row.schemaUid || '',
|
|
16569
|
+
timeCreated: msToUnixSeconds(row.attestationCreatedAt),
|
|
16570
|
+
attester: row.publisher ?? undefined,
|
|
16571
|
+
schema: { schemaNames: [{ name: schemaName }] },
|
|
16572
|
+
};
|
|
16573
|
+
}
|
|
16574
|
+
function versionRowToAttestation(row) {
|
|
16575
|
+
if (!row.uid || !eas.isValidEasAttestationUid(row.uid))
|
|
16576
|
+
return null;
|
|
16577
|
+
if (!row.seedUid)
|
|
16578
|
+
return null;
|
|
16579
|
+
const fromRaw = attestationFromRaw(row.attestationRaw);
|
|
16580
|
+
if (fromRaw) {
|
|
16581
|
+
return {
|
|
16582
|
+
...fromRaw,
|
|
16583
|
+
id: row.uid,
|
|
16584
|
+
refUID: row.seedUid,
|
|
16585
|
+
timeCreated: fromRaw.timeCreated ||
|
|
16586
|
+
msToUnixSeconds(row.attestationCreatedAt),
|
|
16587
|
+
attester: fromRaw.attester ?? row.publisher ?? undefined,
|
|
16588
|
+
};
|
|
16589
|
+
}
|
|
16590
|
+
return {
|
|
16591
|
+
id: row.uid,
|
|
16592
|
+
decodedDataJson: '',
|
|
16593
|
+
refUID: row.seedUid,
|
|
16594
|
+
schemaId: '',
|
|
16595
|
+
timeCreated: msToUnixSeconds(row.attestationCreatedAt),
|
|
16596
|
+
attester: row.publisher ?? undefined,
|
|
16597
|
+
};
|
|
16598
|
+
}
|
|
16599
|
+
function metadataRowToAttestation(row) {
|
|
16600
|
+
if (!row.uid || !eas.isValidEasAttestationUid(row.uid))
|
|
16601
|
+
return null;
|
|
16602
|
+
if (!row.versionUid)
|
|
16603
|
+
return null;
|
|
16604
|
+
const fromRaw = attestationFromRaw(row.attestationRaw);
|
|
16605
|
+
if (fromRaw) {
|
|
16606
|
+
return {
|
|
16607
|
+
...fromRaw,
|
|
16608
|
+
id: row.uid,
|
|
16609
|
+
refUID: row.versionUid,
|
|
16610
|
+
schemaId: fromRaw.schemaId || row.schemaUid || '',
|
|
16611
|
+
timeCreated: fromRaw.timeCreated ||
|
|
16612
|
+
msToUnixSeconds(row.attestationCreatedAt),
|
|
16613
|
+
attester: fromRaw.attester ?? row.publisher ?? undefined,
|
|
16614
|
+
};
|
|
16615
|
+
}
|
|
16616
|
+
const name = row.propertyName
|
|
16617
|
+
? toSnakeCaseName(row.propertyName)
|
|
16618
|
+
: 'unknown';
|
|
16619
|
+
const value = parsePropertyValue(row.propertyValue);
|
|
16620
|
+
const type = row.easDataType || 'string';
|
|
16621
|
+
return {
|
|
16622
|
+
id: row.uid,
|
|
16623
|
+
decodedDataJson: JSON.stringify([{ value: { name, value, type } }]),
|
|
16624
|
+
refUID: row.versionUid,
|
|
16625
|
+
schemaId: row.schemaUid || '',
|
|
16626
|
+
timeCreated: msToUnixSeconds(row.attestationCreatedAt),
|
|
16627
|
+
attester: row.publisher ?? undefined,
|
|
16628
|
+
};
|
|
16629
|
+
}
|
|
16630
|
+
async function resolveSchemaNameForSeedType(appDb, seedType) {
|
|
16631
|
+
if (!seedType)
|
|
16632
|
+
return null;
|
|
16633
|
+
const normalized = lodashEs.startCase(seedType);
|
|
16634
|
+
try {
|
|
16635
|
+
const schemaRows = await appDb
|
|
16636
|
+
.select({ schemaName: schemas.name })
|
|
16637
|
+
.from(models$1)
|
|
16638
|
+
.innerJoin(modelSchemas, drizzleOrm.eq(models$1.id, modelSchemas.modelId))
|
|
16639
|
+
.innerJoin(schemas, drizzleOrm.eq(modelSchemas.schemaId, schemas.id))
|
|
16640
|
+
.where(drizzleOrm.eq(models$1.name, normalized))
|
|
16641
|
+
.limit(1);
|
|
16642
|
+
if (schemaRows[0]?.schemaName)
|
|
16643
|
+
return schemaRows[0].schemaName;
|
|
16644
|
+
}
|
|
16645
|
+
catch {
|
|
16646
|
+
// ignore
|
|
16647
|
+
}
|
|
16648
|
+
return seedType;
|
|
16649
|
+
}
|
|
16650
|
+
function monthBoundsUnix(year, month) {
|
|
16651
|
+
const startDate = new Date(year, month - 1, 1);
|
|
16652
|
+
const endDate = new Date(year, month, 0, 23, 59, 59);
|
|
16653
|
+
const startTs = Math.floor(startDate.getTime() / 1000);
|
|
16654
|
+
const endTs = Math.floor(endDate.getTime() / 1000) + 1;
|
|
16655
|
+
return { startTs, endTs };
|
|
16656
|
+
}
|
|
16657
|
+
async function listPublishedSeedRows(schemaName, opts) {
|
|
16658
|
+
const appDb = BaseDb.getAppDb();
|
|
16659
|
+
if (!appDb)
|
|
16660
|
+
return [];
|
|
16661
|
+
const snakeType = schemaName.includes('_')
|
|
16662
|
+
? schemaName
|
|
16663
|
+
: schemaName.replace(/([A-Z])/g, (m, i) => i === 0 ? m.toLowerCase() : `_${m.toLowerCase()}`);
|
|
16664
|
+
// Prefer exact type match (EAS schema names are usually lowercase singular)
|
|
16665
|
+
const typeCandidates = Array.from(new Set([schemaName, schemaName.toLowerCase(), snakeType.toLowerCase()]));
|
|
16666
|
+
const rows = await appDb
|
|
16667
|
+
.select({
|
|
16668
|
+
uid: seeds.uid,
|
|
16669
|
+
schemaUid: seeds.schemaUid,
|
|
16670
|
+
type: seeds.type,
|
|
16671
|
+
publisher: seeds.publisher,
|
|
16672
|
+
attestationRaw: seeds.attestationRaw,
|
|
16673
|
+
attestationCreatedAt: seeds.attestationCreatedAt,
|
|
16674
|
+
revokedAt: seeds.revokedAt,
|
|
16675
|
+
markedForDeletion: seeds._markedForDeletion,
|
|
16676
|
+
})
|
|
16677
|
+
.from(seeds)
|
|
16678
|
+
.where(drizzleOrm.and(drizzleOrm.inArray(seeds.type, typeCandidates), drizzleOrm.isNotNull(seeds.uid), drizzleOrm.or(drizzleOrm.isNull(seeds.revokedAt), drizzleOrm.eq(seeds.revokedAt, 0)), drizzleOrm.or(drizzleOrm.isNull(seeds._markedForDeletion), drizzleOrm.eq(seeds._markedForDeletion, 0))))
|
|
16679
|
+
.orderBy(drizzleOrm.desc(seeds.attestationCreatedAt));
|
|
16680
|
+
const out = [];
|
|
16681
|
+
for (const row of rows) {
|
|
16682
|
+
if (!row.uid || !eas.isValidEasAttestationUid(row.uid))
|
|
16683
|
+
continue;
|
|
16684
|
+
// Must have at least one published version
|
|
16685
|
+
const versionRows = await appDb
|
|
16686
|
+
.select({
|
|
16687
|
+
uid: versions.uid,
|
|
16688
|
+
})
|
|
16689
|
+
.from(versions)
|
|
16690
|
+
.where(drizzleOrm.eq(versions.seedUid, row.uid))
|
|
16691
|
+
.orderBy(drizzleOrm.desc(versions.createdAt));
|
|
16692
|
+
const hasPublished = versionRows.some((v) => v.uid && eas.isValidEasAttestationUid(v.uid));
|
|
16693
|
+
if (!hasPublished)
|
|
16694
|
+
continue;
|
|
16695
|
+
const schemaResolved = await resolveSchemaNameForSeedType(appDb, row.type);
|
|
16696
|
+
const att = seedRowToAttestation({
|
|
16697
|
+
...row,
|
|
16698
|
+
schemaName: schemaResolved === schemaName ? schemaName : (schemaResolved ?? schemaName),
|
|
16699
|
+
});
|
|
16700
|
+
if (!att)
|
|
16701
|
+
continue;
|
|
16702
|
+
// Force requested schema name so assembleSeeds filters correctly
|
|
16703
|
+
att.schema = { schemaNames: [{ name: schemaName }] };
|
|
16704
|
+
if (opts?.startTs != null || opts?.endTs != null) {
|
|
16705
|
+
const t = att.timeCreated;
|
|
16706
|
+
if (opts.startTs != null && t < opts.startTs)
|
|
16707
|
+
continue;
|
|
16708
|
+
if (opts.endTs != null && t >= opts.endTs)
|
|
16709
|
+
continue;
|
|
16710
|
+
}
|
|
16711
|
+
out.push(att);
|
|
16712
|
+
}
|
|
16713
|
+
return out;
|
|
16714
|
+
}
|
|
16715
|
+
/**
|
|
16716
|
+
* SDK local QueryDataSource: published Seeds/Versions/metadata from SQLite.
|
|
16717
|
+
*/
|
|
16718
|
+
function createLocalQueryDataSource() {
|
|
16719
|
+
return {
|
|
16720
|
+
kind: 'local',
|
|
16721
|
+
async getSeedByUid(seedUid) {
|
|
16722
|
+
const appDb = BaseDb.getAppDb();
|
|
16723
|
+
if (!appDb || !seedUid)
|
|
16724
|
+
return null;
|
|
16725
|
+
const rows = await appDb
|
|
16726
|
+
.select({
|
|
16727
|
+
uid: seeds.uid,
|
|
16728
|
+
schemaUid: seeds.schemaUid,
|
|
16729
|
+
type: seeds.type,
|
|
16730
|
+
publisher: seeds.publisher,
|
|
16731
|
+
attestationRaw: seeds.attestationRaw,
|
|
16732
|
+
attestationCreatedAt: seeds.attestationCreatedAt,
|
|
16733
|
+
revokedAt: seeds.revokedAt,
|
|
16734
|
+
})
|
|
16735
|
+
.from(seeds)
|
|
16736
|
+
.where(drizzleOrm.eq(seeds.uid, seedUid))
|
|
16737
|
+
.limit(1);
|
|
16738
|
+
const row = rows[0];
|
|
16739
|
+
if (!row?.uid || !eas.isValidEasAttestationUid(row.uid))
|
|
16740
|
+
return null;
|
|
16741
|
+
if (row.revokedAt != null && row.revokedAt !== 0)
|
|
16742
|
+
return null;
|
|
16743
|
+
const schemaName = await resolveSchemaNameForSeedType(appDb, row.type);
|
|
16744
|
+
return seedRowToAttestation({ ...row, schemaName });
|
|
16745
|
+
},
|
|
16746
|
+
async listSeedsBySchemaName(schemaName, opts) {
|
|
16747
|
+
const all = await listPublishedSeedRows(schemaName);
|
|
16748
|
+
return all.slice(opts.skip, opts.skip + opts.limit);
|
|
16749
|
+
},
|
|
16750
|
+
async listSeedsBySchemaNameForMonth(schemaName, year, month) {
|
|
16751
|
+
const { startTs, endTs } = monthBoundsUnix(year, month);
|
|
16752
|
+
return listPublishedSeedRows(schemaName, { startTs, endTs });
|
|
16753
|
+
},
|
|
16754
|
+
async getVersionsForSeed(seedUid) {
|
|
16755
|
+
return this.getVersionsForSeeds([seedUid]);
|
|
16756
|
+
},
|
|
16757
|
+
async getVersionsForSeeds(seedUids) {
|
|
16758
|
+
const appDb = BaseDb.getAppDb();
|
|
16759
|
+
if (!appDb || seedUids.length === 0)
|
|
16760
|
+
return [];
|
|
16761
|
+
const rows = await appDb
|
|
16762
|
+
.select({
|
|
16763
|
+
uid: versions.uid,
|
|
16764
|
+
seedUid: versions.seedUid,
|
|
16765
|
+
publisher: versions.publisher,
|
|
16766
|
+
attestationRaw: versions.attestationRaw,
|
|
16767
|
+
attestationCreatedAt: versions.attestationCreatedAt,
|
|
16768
|
+
})
|
|
16769
|
+
.from(versions)
|
|
16770
|
+
.where(drizzleOrm.inArray(versions.seedUid, seedUids));
|
|
16771
|
+
const out = [];
|
|
16772
|
+
for (const row of rows) {
|
|
16773
|
+
const att = versionRowToAttestation(row);
|
|
16774
|
+
if (att)
|
|
16775
|
+
out.push(att);
|
|
16776
|
+
}
|
|
16777
|
+
return out;
|
|
16778
|
+
},
|
|
16779
|
+
async getPropertiesForVersionUids(versionUids) {
|
|
16780
|
+
const appDb = BaseDb.getAppDb();
|
|
16781
|
+
if (!appDb || versionUids.length === 0)
|
|
16782
|
+
return [];
|
|
16783
|
+
const rows = await appDb
|
|
16784
|
+
.select({
|
|
16785
|
+
uid: metadata$1.uid,
|
|
16786
|
+
schemaUid: metadata$1.schemaUid,
|
|
16787
|
+
propertyName: metadata$1.propertyName,
|
|
16788
|
+
propertyValue: metadata$1.propertyValue,
|
|
16789
|
+
easDataType: metadata$1.easDataType,
|
|
16790
|
+
versionUid: metadata$1.versionUid,
|
|
16791
|
+
publisher: metadata$1.publisher,
|
|
16792
|
+
attestationRaw: metadata$1.attestationRaw,
|
|
16793
|
+
attestationCreatedAt: metadata$1.attestationCreatedAt,
|
|
16794
|
+
})
|
|
16795
|
+
.from(metadata$1)
|
|
16796
|
+
.where(drizzleOrm.inArray(metadata$1.versionUid, versionUids));
|
|
16797
|
+
const out = [];
|
|
16798
|
+
for (const row of rows) {
|
|
16799
|
+
const att = metadataRowToAttestation(row);
|
|
16800
|
+
if (att)
|
|
16801
|
+
out.push(att);
|
|
16802
|
+
}
|
|
16803
|
+
return out;
|
|
16804
|
+
},
|
|
16805
|
+
async getSeedsByUids(uids) {
|
|
16806
|
+
const appDb = BaseDb.getAppDb();
|
|
16807
|
+
if (!appDb || uids.length === 0)
|
|
16808
|
+
return [];
|
|
16809
|
+
const rows = await appDb
|
|
16810
|
+
.select({
|
|
16811
|
+
uid: seeds.uid,
|
|
16812
|
+
schemaUid: seeds.schemaUid,
|
|
16813
|
+
type: seeds.type,
|
|
16814
|
+
publisher: seeds.publisher,
|
|
16815
|
+
attestationRaw: seeds.attestationRaw,
|
|
16816
|
+
attestationCreatedAt: seeds.attestationCreatedAt,
|
|
16817
|
+
revokedAt: seeds.revokedAt,
|
|
16818
|
+
})
|
|
16819
|
+
.from(seeds)
|
|
16820
|
+
.where(drizzleOrm.inArray(seeds.uid, uids));
|
|
16821
|
+
const out = [];
|
|
16822
|
+
for (const row of rows) {
|
|
16823
|
+
if (row.revokedAt != null && row.revokedAt !== 0)
|
|
16824
|
+
continue;
|
|
16825
|
+
const schemaName = await resolveSchemaNameForSeedType(appDb, row.type);
|
|
16826
|
+
const att = seedRowToAttestation({ ...row, schemaName });
|
|
16827
|
+
if (att)
|
|
16828
|
+
out.push(att);
|
|
16829
|
+
}
|
|
16830
|
+
return out;
|
|
16831
|
+
},
|
|
16832
|
+
async readStorageBody(ref) {
|
|
16833
|
+
try {
|
|
16834
|
+
if (ref.localPathHint) {
|
|
16835
|
+
const text = await BaseFileManager.readFileAsString(ref.localPathHint);
|
|
16836
|
+
if (text)
|
|
16837
|
+
return text;
|
|
16838
|
+
}
|
|
16839
|
+
// Common layout: html/{name}.html under filesDir
|
|
16840
|
+
if (typeof ref.value === 'string') {
|
|
16841
|
+
const v = ref.value.trim();
|
|
16842
|
+
// Absolute or relative file path already on disk
|
|
16843
|
+
if (v.includes('/') && !v.startsWith('http')) {
|
|
16844
|
+
try {
|
|
16845
|
+
const text = await BaseFileManager.readFileAsString(v);
|
|
16846
|
+
if (text)
|
|
16847
|
+
return text;
|
|
16848
|
+
}
|
|
16849
|
+
catch {
|
|
16850
|
+
// try under html/
|
|
16851
|
+
}
|
|
16852
|
+
}
|
|
16853
|
+
const htmlPath = BaseFileManager.getFilesPath('html', v.endsWith('.html') ? v : `${v}.html`);
|
|
16854
|
+
try {
|
|
16855
|
+
const text = await BaseFileManager.readFileAsString(htmlPath);
|
|
16856
|
+
if (text)
|
|
16857
|
+
return text;
|
|
16858
|
+
}
|
|
16859
|
+
catch {
|
|
16860
|
+
// fall through
|
|
16861
|
+
}
|
|
16862
|
+
}
|
|
16863
|
+
}
|
|
16864
|
+
catch {
|
|
16865
|
+
return null;
|
|
16866
|
+
}
|
|
16867
|
+
return null;
|
|
16868
|
+
},
|
|
16869
|
+
};
|
|
16870
|
+
}
|
|
16871
|
+
|
|
16872
|
+
let registered = false;
|
|
16873
|
+
/**
|
|
16874
|
+
* Register the SDK SQLite/files adapter with `@seedprotocol/query`.
|
|
16875
|
+
* Safe to call multiple times; re-registers with a fresh adapter instance.
|
|
16876
|
+
* No-op when the app DB is not ready yet (unless `force`).
|
|
16877
|
+
*/
|
|
16878
|
+
function registerSeedQueryLocalSource(options) {
|
|
16879
|
+
try {
|
|
16880
|
+
query.registerLocalQuerySource(createLocalQueryDataSource());
|
|
16881
|
+
registered = true;
|
|
16882
|
+
return true;
|
|
16883
|
+
}
|
|
16884
|
+
catch (err) {
|
|
16885
|
+
console.warn('[sdk/query] registerSeedQueryLocalSource failed:', err);
|
|
16886
|
+
return false;
|
|
16887
|
+
}
|
|
16888
|
+
}
|
|
16889
|
+
/** Unregister local query source (tests / client unload). */
|
|
16890
|
+
function unregisterSeedQueryLocalSource() {
|
|
16891
|
+
query.clearLocalQuerySource();
|
|
16892
|
+
registered = false;
|
|
16893
|
+
}
|
|
16894
|
+
|
|
16503
16895
|
const logger$3 = debug('seedSdk:client');
|
|
16504
16896
|
const clientManager = xstate.createActor(clientManagerMachine, {
|
|
16505
16897
|
input: {
|
|
@@ -16604,6 +16996,8 @@ const clientInstance = {
|
|
|
16604
16996
|
}
|
|
16605
16997
|
throw error;
|
|
16606
16998
|
}
|
|
16999
|
+
// Wire `@seedprotocol/query` local source once DB is ready
|
|
17000
|
+
registerSeedQueryLocalSource();
|
|
16607
17001
|
},
|
|
16608
17002
|
setAddresses: async (addresses) => {
|
|
16609
17003
|
ensureInitialized();
|
|
@@ -16665,10 +17059,12 @@ const clientInstance = {
|
|
|
16665
17059
|
},
|
|
16666
17060
|
stop: () => {
|
|
16667
17061
|
ensureInitialized();
|
|
17062
|
+
unregisterSeedQueryLocalSource();
|
|
16668
17063
|
clientManager.stop();
|
|
16669
17064
|
},
|
|
16670
17065
|
unload: () => {
|
|
16671
17066
|
ensureInitialized();
|
|
17067
|
+
unregisterSeedQueryLocalSource();
|
|
16672
17068
|
clientManager.stop();
|
|
16673
17069
|
subscription.unsubscribe();
|
|
16674
17070
|
},
|
|
@@ -16851,7 +17247,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
|
|
|
16851
17247
|
// Lazy import cache for ModelProperty to avoid circular dependency
|
|
16852
17248
|
// Eagerly start loading to minimize delay on first access
|
|
16853
17249
|
let ModelPropertyClass = null;
|
|
16854
|
-
const modelPropertyImportPromise = Promise.resolve().then(function () { return require('./ModelProperty-
|
|
17250
|
+
const modelPropertyImportPromise = Promise.resolve().then(function () { return require('./ModelProperty-Dgd4tGrB.js'); })
|
|
16855
17251
|
.then(module => {
|
|
16856
17252
|
ModelPropertyClass = module.ModelProperty;
|
|
16857
17253
|
return ModelPropertyClass;
|
|
@@ -16868,7 +17264,7 @@ function getModelProperty() {
|
|
|
16868
17264
|
}
|
|
16869
17265
|
// Lazy import cache for Schema to avoid circular dependency
|
|
16870
17266
|
let SchemaClass = null;
|
|
16871
|
-
const schemaImportPromise = Promise.resolve().then(function () { return require('./Schema-
|
|
17267
|
+
const schemaImportPromise = Promise.resolve().then(function () { return require('./Schema-dkd-eo3B.js'); })
|
|
16872
17268
|
.then(module => {
|
|
16873
17269
|
SchemaClass = module.Schema;
|
|
16874
17270
|
return SchemaClass;
|
|
@@ -18773,7 +19169,7 @@ function resolveSdkDrizzleMigrationsDir(sdkRootDir) {
|
|
|
18773
19169
|
})();
|
|
18774
19170
|
// Also resolve relative to this module so temp-cwd tests / odd roots still find
|
|
18775
19171
|
// packages/sdk/src/db/drizzle (or dist/db/drizzle after publish).
|
|
18776
|
-
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-
|
|
19172
|
+
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-CRBI6dSD.js', document.baseURI).href))));
|
|
18777
19173
|
const candidates = [
|
|
18778
19174
|
path.join(root, 'db', 'drizzle'), // production: sdkRoot is dist/
|
|
18779
19175
|
path.join(root, 'dist', 'db', 'drizzle'), // sdk package root with built dist
|
|
@@ -18843,7 +19239,7 @@ class NodeDb {
|
|
|
18843
19239
|
logger$1('[Db.prepareDb] running migrations from %s', outDir);
|
|
18844
19240
|
await migrator.migrate(db, { migrationsFolder: outDir });
|
|
18845
19241
|
this.db = db;
|
|
18846
|
-
const { backfillMetadataPropertyIds } = await Promise.resolve().then(function () { return require('./backfillMetadataPropertyIds-
|
|
19242
|
+
const { backfillMetadataPropertyIds } = await Promise.resolve().then(function () { return require('./backfillMetadataPropertyIds-ClLuj3s6.js'); });
|
|
18847
19243
|
await backfillMetadataPropertyIds();
|
|
18848
19244
|
return this.db;
|
|
18849
19245
|
}
|
|
@@ -19045,6 +19441,27 @@ const saveModelsFromMarkdown = async (filePath, db) => {
|
|
|
19045
19441
|
return modelDefinitions;
|
|
19046
19442
|
};
|
|
19047
19443
|
|
|
19444
|
+
/**
|
|
19445
|
+
* Webpack / Next.js config helper for Seed Protocol apps.
|
|
19446
|
+
*/
|
|
19447
|
+
const withSeed = (config, webpack, isServer) => {
|
|
19448
|
+
config.plugins.push(new webpack.NormalModuleReplacementPlugin(/node:/, (resource) => {
|
|
19449
|
+
resource.request = resource.request.replace(/^node:/, '');
|
|
19450
|
+
}));
|
|
19451
|
+
if (!isServer) {
|
|
19452
|
+
config.resolve.alias['fs'] = '@zenfs/core';
|
|
19453
|
+
config.resolve.alias['node:fs'] = '@zenfs/core';
|
|
19454
|
+
config.resolve.alias['node:path'] = 'path-browserify';
|
|
19455
|
+
config.resolve.alias['path'] = 'path-browserify';
|
|
19456
|
+
}
|
|
19457
|
+
if (isServer) {
|
|
19458
|
+
config.externals.push('@sqlite.org/sqlite-wasm');
|
|
19459
|
+
config.externals.push('chokidar');
|
|
19460
|
+
config.externals.push('arweave');
|
|
19461
|
+
}
|
|
19462
|
+
return config;
|
|
19463
|
+
};
|
|
19464
|
+
|
|
19048
19465
|
const logger = debug('seedSdk:node:helpers:PathResolver');
|
|
19049
19466
|
class NodePathResolver {
|
|
19050
19467
|
/** @deprecated Prefer BasePathResolver static methods or configure(). */
|
|
@@ -19388,7 +19805,6 @@ exports.modelSchemas = modelSchemas;
|
|
|
19388
19805
|
exports.modelUids = modelUids;
|
|
19389
19806
|
exports.models = models$1;
|
|
19390
19807
|
exports.normalizeDataType = normalizeDataType;
|
|
19391
|
-
exports.parseEasRelationPropertyName = parseEasRelationPropertyName;
|
|
19392
19808
|
exports.parseListPropertyValueFromStorage = parseListPropertyValueFromStorage;
|
|
19393
19809
|
exports.parseMarkdownFrontmatter = parseMarkdownFrontmatter;
|
|
19394
19810
|
exports.processSeedConfig = processSeedConfig;
|
|
@@ -19411,5 +19827,6 @@ exports.transformImportToSchemaFile = transformImportToSchemaFile;
|
|
|
19411
19827
|
exports.unloadEntity = unloadEntity;
|
|
19412
19828
|
exports.versions = versions;
|
|
19413
19829
|
exports.waitForEntityIdle = waitForEntityIdle;
|
|
19830
|
+
exports.withSeed = withSeed;
|
|
19414
19831
|
exports.writeProcessMachine = writeProcessMachine;
|
|
19415
|
-
//# sourceMappingURL=index-
|
|
19832
|
+
//# sourceMappingURL=index-CRBI6dSD.js.map
|