@seedprotocol/sdk 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BasePathResolver-DWY_hb8w.js → BasePathResolver-0IHnXxtL.js} +5 -1
- package/dist/BasePathResolver-0IHnXxtL.js.map +1 -0
- package/dist/{ModelProperty-CHIxRLfS.js → ModelProperty-BiDQu5rE.js} +40 -30
- package/dist/ModelProperty-BiDQu5rE.js.map +1 -0
- package/dist/{Schema-BaVOWeUb.js → Schema-qciDB7Nu.js} +43 -39
- package/dist/{Schema-BaVOWeUb.js.map → Schema-qciDB7Nu.js.map} +1 -1
- package/dist/{SchemaValidationService-BX4GcEKY.js → SchemaValidationService-BaOkRjsU.js} +6 -6
- package/dist/{SchemaValidationService-BX4GcEKY.js.map → SchemaValidationService-BaOkRjsU.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-6kBwLScb.js → backfillMetadataPropertyIds-oypxoBXv.js} +3 -3
- package/dist/{backfillMetadataPropertyIds-6kBwLScb.js.map → backfillMetadataPropertyIds-oypxoBXv.js.map} +1 -1
- package/dist/cjs/{ModelProperty-BphJm1e3.js → ModelProperty-DvIIhBnK.js} +17 -17
- package/dist/cjs/{ModelProperty-BphJm1e3.js.map → ModelProperty-DvIIhBnK.js.map} +1 -1
- package/dist/cjs/{Schema-z1fBr4Rv.js → Schema-FdzNqyGo.js} +20 -20
- package/dist/cjs/{Schema-z1fBr4Rv.js.map → Schema-FdzNqyGo.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-DWmIhQqz.js → SchemaValidationService-pxRoOs79.js} +2 -2
- package/dist/cjs/{SchemaValidationService-DWmIhQqz.js.map → SchemaValidationService-pxRoOs79.js.map} +1 -1
- package/dist/cjs/{backfillMetadataPropertyIds--9WN2zaG.js → backfillMetadataPropertyIds-D0o5VwBh.js} +2 -2
- package/dist/cjs/{backfillMetadataPropertyIds--9WN2zaG.js.map → backfillMetadataPropertyIds-D0o5VwBh.js.map} +1 -1
- package/dist/cjs/{eas-YuOI6X_v.js → eas-DSZkoDUn.js} +3 -3
- package/dist/cjs/{eas-YuOI6X_v.js.map → eas-DSZkoDUn.js.map} +1 -1
- package/dist/cjs/{getItem-CKDdJztx.js → getItem-CPcdcFuS.js} +2 -2
- package/dist/cjs/{getItem-CKDdJztx.js.map → getItem-CPcdcFuS.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-DXHDgXU3.js → getPublishPayload-BvmVTKoc.js} +11 -11
- package/dist/cjs/{getPublishPayload-DXHDgXU3.js.map → getPublishPayload-BvmVTKoc.js.map} +1 -1
- package/dist/cjs/{getPublishUploads-yFW9CKSW.js → getPublishUploads-D2VZHZnu.js} +4 -4
- package/dist/cjs/{getPublishUploads-yFW9CKSW.js.map → getPublishUploads-D2VZHZnu.js.map} +1 -1
- package/dist/cjs/{getSegmentedItemProperties-BLdMFDBt.js → getSegmentedItemProperties-Bm1TEvBS.js} +3 -3
- package/dist/cjs/{getSegmentedItemProperties-BLdMFDBt.js.map → getSegmentedItemProperties-Bm1TEvBS.js.map} +1 -1
- package/dist/cjs/{index-WOQkKWSU.js → index-C-POwaLs.js} +445 -315
- package/dist/cjs/index-C-POwaLs.js.map +1 -0
- package/dist/cjs/{index-Bp16LrkZ.js → index-D_ph4zut.js} +3 -3
- package/dist/cjs/index-D_ph4zut.js.map +1 -0
- package/dist/cjs/{property-DSh60oEw.js → property-DkUtJxV2.js} +4 -4
- package/dist/cjs/{property-DSh60oEw.js.map → property-DkUtJxV2.js.map} +1 -1
- package/dist/cjs/{syncDbWithEas-pVjTHk3y.js → syncDbWithEas-DRoys7eo.js} +17 -10
- package/dist/cjs/syncDbWithEas-DRoys7eo.js.map +1 -0
- package/dist/{configurePlatform-CXQCT7N8.js → configurePlatform-Df4BlXwQ.js} +3 -3
- package/dist/{configurePlatform-CXQCT7N8.js.map → configurePlatform-Df4BlXwQ.js.map} +1 -1
- package/dist/{constants-DMHTYMgJ.js → constants-Bre6dTJR.js} +3 -1
- package/dist/constants-Bre6dTJR.js.map +1 -0
- package/dist/{constants-B7aNfB_1.js → constants-CROrIRd-.js} +2 -2
- package/dist/{constants-B7aNfB_1.js.map → constants-CROrIRd-.js.map} +1 -1
- package/dist/{db-CMQ3TG6N.js → db-DVsy4QZe.js} +121 -56
- package/dist/db-DVsy4QZe.js.map +1 -0
- package/dist/{eas-BG3zRyHC.js → eas-z4W41ith.js} +5 -5
- package/dist/{eas-BG3zRyHC.js.map → eas-z4W41ith.js.map} +1 -1
- package/dist/{getItem-BFDi98NG.js → getItem-BiE_b7Fu.js} +6 -6
- package/dist/{getItem-BFDi98NG.js.map → getItem-BiE_b7Fu.js.map} +1 -1
- package/dist/{getPublishPayload-B2D-72EC.js → getPublishPayload-CuRGEZa5.js} +17 -17
- package/dist/{getPublishPayload-B2D-72EC.js.map → getPublishPayload-CuRGEZa5.js.map} +1 -1
- package/dist/{getPublishUploads-D-fMspZI.js → getPublishUploads-CMgzBCzZ.js} +8 -8
- package/dist/{getPublishUploads-D-fMspZI.js.map → getPublishUploads-CMgzBCzZ.js.map} +1 -1
- package/dist/{getSegmentedItemProperties-DzjK6JE5.js → getSegmentedItemProperties-BCCSwTxr.js} +5 -5
- package/dist/{getSegmentedItemProperties-DzjK6JE5.js.map → getSegmentedItemProperties-BCCSwTxr.js.map} +1 -1
- package/dist/{index-BaPbRFSy.js → index-C41UZTmQ.js} +8 -8
- package/dist/index-C41UZTmQ.js.map +1 -0
- package/dist/{index-Dx0RL3Tx.js → index-DjwIC6U3.js} +418 -343
- package/dist/index-DjwIC6U3.js.map +1 -0
- package/dist/{index-DrEkRiuK.js → index-xNWgPtlN.js} +2 -2
- package/dist/index-xNWgPtlN.js.map +1 -0
- package/dist/{index.node-hhs7zosf.js → index.node-DQZ3cPe-.js} +14 -5
- package/dist/index.node-DQZ3cPe-.js.map +1 -0
- package/dist/main.cjs +1 -1
- package/dist/main.js +300 -24
- package/dist/main.js.map +1 -1
- package/dist/node.js +11 -11
- package/dist/platform.browser.js +14 -4
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.node.js +4 -4
- package/dist/{property-B2xdCZz_.js → property-Bs3a4Dna.js} +9 -9
- package/dist/{property-B2xdCZz_.js.map → property-Bs3a4Dna.js.map} +1 -1
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts +1 -0
- package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/client/ClientManager.d.ts +12 -0
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/src/db/read/getItems.d.ts.map +1 -1
- package/dist/src/db/read/summarizePublishWork.d.ts +24 -0
- package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -0
- package/dist/src/db/write/claimUnpublishedDrafts.d.ts +11 -0
- package/dist/src/db/write/claimUnpublishedDrafts.d.ts.map +1 -0
- package/dist/src/db/write/createMetadata.d.ts.map +1 -1
- package/dist/src/db/write/createSeed.d.ts.map +1 -1
- package/dist/src/db/write/createSeeds.d.ts.map +1 -1
- package/dist/src/db/write/createVersion.d.ts.map +1 -1
- package/dist/src/db/write/updateMetadata.d.ts.map +1 -1
- package/dist/src/db/write/updateSeedUid.d.ts.map +1 -1
- package/dist/src/db/write/updateVersionUid.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts +2 -0
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/IFileManager.d.ts +2 -0
- package/dist/src/helpers/FileManager/IFileManager.d.ts.map +1 -1
- package/dist/src/helpers/addresses.d.ts +14 -0
- package/dist/src/helpers/addresses.d.ts.map +1 -1
- package/dist/src/helpers/constants.d.ts.map +1 -1
- package/dist/src/helpers/db.d.ts +2 -2
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/helpers/ownership.d.ts +36 -8
- package/dist/src/helpers/ownership.d.ts.map +1 -1
- package/dist/src/helpers/publishConfig.d.ts +4 -3
- package/dist/src/helpers/publishConfig.d.ts.map +1 -1
- package/dist/src/helpers/reactiveProxy.d.ts +10 -0
- package/dist/src/helpers/reactiveProxy.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/node/helpers/FileManager.d.ts +1 -0
- package/dist/src/node/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +6 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/{syncDbWithEas-B9Riqty1.js → syncDbWithEas-DRpLRxwb.js} +25 -18
- package/dist/syncDbWithEas-DRpLRxwb.js.map +1 -0
- package/dist/{updateSeedRevokedAt-CtRjZiyh.js → updateSeedRevokedAt-F0ZDvwOO.js} +2 -2
- package/dist/{updateSeedRevokedAt-CtRjZiyh.js.map → updateSeedRevokedAt-F0ZDvwOO.js.map} +1 -1
- package/package.json +5 -5
- package/dist/BasePathResolver-DWY_hb8w.js.map +0 -1
- package/dist/ModelProperty-CHIxRLfS.js.map +0 -1
- package/dist/cjs/index-Bp16LrkZ.js.map +0 -1
- package/dist/cjs/index-WOQkKWSU.js.map +0 -1
- package/dist/cjs/syncDbWithEas-pVjTHk3y.js.map +0 -1
- package/dist/constants-DMHTYMgJ.js.map +0 -1
- package/dist/db-CMQ3TG6N.js.map +0 -1
- package/dist/index-BaPbRFSy.js.map +0 -1
- package/dist/index-DrEkRiuK.js.map +0 -1
- package/dist/index-Dx0RL3Tx.js.map +0 -1
- package/dist/index.node-hhs7zosf.js.map +0 -1
- package/dist/syncDbWithEas-B9Riqty1.js.map +0 -1
|
@@ -205,6 +205,10 @@ class BaseFileManager {
|
|
|
205
205
|
static pathExists(filePath) {
|
|
206
206
|
return BaseFileManager.requireImpl().pathExists(filePath);
|
|
207
207
|
}
|
|
208
|
+
/** File size in bytes, or null if the path does not exist / cannot be stated. */
|
|
209
|
+
static getFileSize(filePath) {
|
|
210
|
+
return BaseFileManager.requireImpl().getFileSize(filePath);
|
|
211
|
+
}
|
|
208
212
|
/**
|
|
209
213
|
* Returns a list of filenames in the given directory (e.g. 'images', 'files').
|
|
210
214
|
*/
|
|
@@ -339,14 +343,9 @@ let revokeExecutor = null;
|
|
|
339
343
|
function getRevokeExecutor() {
|
|
340
344
|
return revokeExecutor;
|
|
341
345
|
}
|
|
342
|
-
let getAdditionalSyncAddresses = null;
|
|
343
|
-
function getGetAdditionalSyncAddresses() {
|
|
344
|
-
return getAdditionalSyncAddresses;
|
|
345
|
-
}
|
|
346
346
|
|
|
347
347
|
var publishConfig = /*#__PURE__*/Object.freeze({
|
|
348
348
|
__proto__: null,
|
|
349
|
-
getGetAdditionalSyncAddresses: getGetAdditionalSyncAddresses,
|
|
350
349
|
getPublisherForNewSeedsWithTimeout: getPublisherForNewSeedsWithTimeout,
|
|
351
350
|
getRevokeExecutor: getRevokeExecutor,
|
|
352
351
|
getUploadExecutor: getUploadExecutor
|
|
@@ -1000,7 +999,7 @@ const createPropertyInstances = async (propertyFileIds) => {
|
|
|
1000
999
|
return;
|
|
1001
1000
|
}
|
|
1002
1001
|
try {
|
|
1003
|
-
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-
|
|
1002
|
+
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-DvIIhBnK.js'); });
|
|
1004
1003
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
1005
1004
|
if (!ModelProperty) {
|
|
1006
1005
|
logger$v('createPropertyInstances: ModelProperty not available from dynamic import');
|
|
@@ -1184,7 +1183,7 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
1184
1183
|
// Step 2: Fallback to Schema context (only if database doesn't have the model)
|
|
1185
1184
|
// This handles the case where model exists in schema file but not yet in database
|
|
1186
1185
|
try {
|
|
1187
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-
|
|
1186
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-FdzNqyGo.js'); });
|
|
1188
1187
|
const { Schema } = schemaMod;
|
|
1189
1188
|
const schema = Schema.create(schemaName, { waitForReady: false });
|
|
1190
1189
|
const schemaSnapshot = schema.getService().getSnapshot();
|
|
@@ -1428,7 +1427,7 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
1428
1427
|
}
|
|
1429
1428
|
// Mark schema as draft when a new model is created so saveNewVersion() can persist it
|
|
1430
1429
|
try {
|
|
1431
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-
|
|
1430
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-FdzNqyGo.js'); });
|
|
1432
1431
|
const { Schema } = schemaMod;
|
|
1433
1432
|
const schema = Schema.create(schemaName, { waitForReady: false });
|
|
1434
1433
|
schema.getService().send({ type: 'markAsDraft', propertyKey: 'schema:models' });
|
|
@@ -1472,10 +1471,10 @@ const validateModel = xstate.fromCallback(({ sendBack, input: { context } }) =>
|
|
|
1472
1471
|
const _validateModel = async () => {
|
|
1473
1472
|
try {
|
|
1474
1473
|
// Use dynamic imports to break circular dependencies
|
|
1475
|
-
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
1474
|
+
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-pxRoOs79.js'); });
|
|
1476
1475
|
const { SchemaValidationService } = validationServiceMod;
|
|
1477
1476
|
const validationService = new SchemaValidationService();
|
|
1478
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-
|
|
1477
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-FdzNqyGo.js'); });
|
|
1479
1478
|
const { Schema } = schemaMod;
|
|
1480
1479
|
// Validate model structure
|
|
1481
1480
|
const structureResult = validationService.validateModelStructure(context);
|
|
@@ -1585,7 +1584,7 @@ const createModelProperties = xstate.fromCallback(({ sendBack, input }) => {
|
|
|
1585
1584
|
return;
|
|
1586
1585
|
}
|
|
1587
1586
|
logger$t(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
|
|
1588
|
-
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-
|
|
1587
|
+
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-DvIIhBnK.js'); });
|
|
1589
1588
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
1590
1589
|
if (!ModelProperty) {
|
|
1591
1590
|
logger$t('ModelProperty not available from dynamic import');
|
|
@@ -1688,7 +1687,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1688
1687
|
const structureMsg = `[validateEntity] Validating model structure`;
|
|
1689
1688
|
logger$s(structureMsg);
|
|
1690
1689
|
// Use existing Model validation
|
|
1691
|
-
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
1690
|
+
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-pxRoOs79.js'); });
|
|
1692
1691
|
const { SchemaValidationService } = validationServiceMod;
|
|
1693
1692
|
const validationService = new SchemaValidationService();
|
|
1694
1693
|
// Validate model structure
|
|
@@ -1706,7 +1705,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1706
1705
|
if (entityInput.entityData.schemaName) {
|
|
1707
1706
|
try {
|
|
1708
1707
|
logger$s(`[validateEntity] Validating model against schema "${entityInput.entityData.schemaName}"`);
|
|
1709
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-
|
|
1708
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-FdzNqyGo.js'); });
|
|
1710
1709
|
const { Schema } = schemaMod;
|
|
1711
1710
|
const schema = Schema.create(entityInput.entityData.schemaName, {
|
|
1712
1711
|
waitForReady: false,
|
|
@@ -1742,7 +1741,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1742
1741
|
}
|
|
1743
1742
|
else if (entityInput.entityType === 'modelProperty') {
|
|
1744
1743
|
// Use existing ModelProperty validation
|
|
1745
|
-
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
1744
|
+
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-pxRoOs79.js'); });
|
|
1746
1745
|
const { SchemaValidationService } = validationServiceMod;
|
|
1747
1746
|
const validationService = new SchemaValidationService();
|
|
1748
1747
|
// Validate property structure
|
|
@@ -1757,7 +1756,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1757
1756
|
// If schema name and model name provided, validate against schema
|
|
1758
1757
|
if (entityInput.entityData._schemaName && entityInput.entityData.modelName) {
|
|
1759
1758
|
try {
|
|
1760
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-
|
|
1759
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-FdzNqyGo.js'); });
|
|
1761
1760
|
const { Schema } = schemaMod;
|
|
1762
1761
|
const schema = Schema.create(entityInput.entityData._schemaName, {
|
|
1763
1762
|
waitForReady: false,
|
|
@@ -1786,7 +1785,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1786
1785
|
}
|
|
1787
1786
|
else if (entityInput.entityType === 'schema') {
|
|
1788
1787
|
// Schema validation - use existing validation
|
|
1789
|
-
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
1788
|
+
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-pxRoOs79.js'); });
|
|
1790
1789
|
const { SchemaValidationService } = validationServiceMod;
|
|
1791
1790
|
const validationService = new SchemaValidationService();
|
|
1792
1791
|
const schemaResult = validationService.validateSchema(entityInput.entityData);
|
|
@@ -1865,6 +1864,60 @@ function matchesUniqueConstraintText(text) {
|
|
|
1865
1864
|
(text.includes('2067') && lower.includes('constraint')));
|
|
1866
1865
|
}
|
|
1867
1866
|
|
|
1867
|
+
/**
|
|
1868
|
+
* Lowercase + trim an address for persist and compare.
|
|
1869
|
+
* Does not checksum or validate — test and placeholder addresses must keep working.
|
|
1870
|
+
*/
|
|
1871
|
+
function normalizeHexAddress(addr) {
|
|
1872
|
+
return addr.trim().toLowerCase();
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* Lowercase, drop empties, and dedupe (first-seen order).
|
|
1876
|
+
*/
|
|
1877
|
+
function normalizeAddressList(addrs) {
|
|
1878
|
+
if (!addrs?.length)
|
|
1879
|
+
return [];
|
|
1880
|
+
const seen = new Set();
|
|
1881
|
+
const out = [];
|
|
1882
|
+
for (const addr of addrs) {
|
|
1883
|
+
if (addr == null || addr === '')
|
|
1884
|
+
continue;
|
|
1885
|
+
const normalized = normalizeHexAddress(String(addr));
|
|
1886
|
+
if (!normalized || seen.has(normalized))
|
|
1887
|
+
continue;
|
|
1888
|
+
seen.add(normalized);
|
|
1889
|
+
out.push(normalized);
|
|
1890
|
+
}
|
|
1891
|
+
return out;
|
|
1892
|
+
}
|
|
1893
|
+
/**
|
|
1894
|
+
* Lowercase a publisher stamp. Empty / null → undefined (omit on write).
|
|
1895
|
+
*/
|
|
1896
|
+
function normalizePublisher(publisher) {
|
|
1897
|
+
if (publisher == null || publisher === '')
|
|
1898
|
+
return undefined;
|
|
1899
|
+
const normalized = normalizeHexAddress(publisher);
|
|
1900
|
+
return normalized || undefined;
|
|
1901
|
+
}
|
|
1902
|
+
/**
|
|
1903
|
+
* Normalizes AddressConfiguration to { owned, watched }.
|
|
1904
|
+
* - string[] -> { owned: addresses, watched: [] }
|
|
1905
|
+
* - { owned, watched? } -> { owned, watched: watched ?? [] }
|
|
1906
|
+
* Addresses are lowercased and deduped.
|
|
1907
|
+
*/
|
|
1908
|
+
function normalizeAddressConfig(addresses) {
|
|
1909
|
+
if (!addresses) {
|
|
1910
|
+
return { owned: [], watched: [] };
|
|
1911
|
+
}
|
|
1912
|
+
if (Array.isArray(addresses)) {
|
|
1913
|
+
return { owned: normalizeAddressList(addresses), watched: [] };
|
|
1914
|
+
}
|
|
1915
|
+
return {
|
|
1916
|
+
owned: normalizeAddressList(addresses.owned),
|
|
1917
|
+
watched: normalizeAddressList(addresses.watched),
|
|
1918
|
+
};
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1868
1921
|
const logger$r = debug('seedSdk:helpers:db');
|
|
1869
1922
|
/**
|
|
1870
1923
|
* Resolve property_id from model name/type and property name.
|
|
@@ -3207,13 +3260,13 @@ function parseAddressConfig(value) {
|
|
|
3207
3260
|
try {
|
|
3208
3261
|
const parsed = JSON.parse(value);
|
|
3209
3262
|
if (Array.isArray(parsed)) {
|
|
3210
|
-
return
|
|
3263
|
+
return normalizeAddressConfig(parsed);
|
|
3211
3264
|
}
|
|
3212
3265
|
if (parsed && typeof parsed === 'object' && Array.isArray(parsed.owned)) {
|
|
3213
|
-
return {
|
|
3266
|
+
return normalizeAddressConfig({
|
|
3214
3267
|
owned: parsed.owned,
|
|
3215
3268
|
watched: Array.isArray(parsed.watched) ? parsed.watched : [],
|
|
3216
|
-
};
|
|
3269
|
+
});
|
|
3217
3270
|
}
|
|
3218
3271
|
return null;
|
|
3219
3272
|
}
|
|
@@ -3230,27 +3283,12 @@ const getWatchedAddressesFromDb = async () => {
|
|
|
3230
3283
|
return config?.watched ?? [];
|
|
3231
3284
|
};
|
|
3232
3285
|
/**
|
|
3233
|
-
* Returns addresses for
|
|
3234
|
-
*
|
|
3286
|
+
* Returns persisted owned or watched addresses for list filters.
|
|
3287
|
+
* Does not include `getAdditionalSyncAddresses` (those are extra EAS indexers).
|
|
3235
3288
|
*/
|
|
3236
3289
|
const getAddressesForItemsFilter = async (addressFilter) => {
|
|
3237
3290
|
if (addressFilter === 'owned') {
|
|
3238
|
-
|
|
3239
|
-
let ownedAddresses = await getOwnedAddressesFromDb();
|
|
3240
|
-
const additionalGetter = getGetAdditionalSyncAddresses();
|
|
3241
|
-
if (additionalGetter) {
|
|
3242
|
-
const additional = await additionalGetter();
|
|
3243
|
-
if (additional?.length) {
|
|
3244
|
-
const seen = new Set(ownedAddresses.map((a) => a.toLowerCase()));
|
|
3245
|
-
for (const addr of additional) {
|
|
3246
|
-
if (addr && !seen.has(addr.toLowerCase())) {
|
|
3247
|
-
seen.add(addr.toLowerCase());
|
|
3248
|
-
ownedAddresses = [...ownedAddresses, addr];
|
|
3249
|
-
}
|
|
3250
|
-
}
|
|
3251
|
-
}
|
|
3252
|
-
}
|
|
3253
|
-
return ownedAddresses;
|
|
3291
|
+
return getOwnedAddressesFromDb();
|
|
3254
3292
|
}
|
|
3255
3293
|
return getWatchedAddressesFromDb();
|
|
3256
3294
|
};
|
|
@@ -3827,7 +3865,7 @@ const writeToDatabase = xstate.fromCallback(({ sendBack, input }) => {
|
|
|
3827
3865
|
// initial write completes is not overwritten by the stale requestWrite payload.
|
|
3828
3866
|
let dataToWrite = input.entityData;
|
|
3829
3867
|
try {
|
|
3830
|
-
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-
|
|
3868
|
+
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-DvIIhBnK.js'); });
|
|
3831
3869
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
3832
3870
|
if (ModelProperty && typeof ModelProperty.getById === 'function') {
|
|
3833
3871
|
const instance = ModelProperty.getById(input.entityId);
|
|
@@ -4207,7 +4245,7 @@ const modelMachine = xstate.setup({
|
|
|
4207
4245
|
// Create ModelProperty instances for any new property IDs
|
|
4208
4246
|
if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
|
|
4209
4247
|
// Import and create instances asynchronously (fire-and-forget)
|
|
4210
|
-
Promise.resolve().then(function () { return require('./ModelProperty-
|
|
4248
|
+
Promise.resolve().then(function () { return require('./ModelProperty-DvIIhBnK.js'); }).then(({ ModelProperty }) => {
|
|
4211
4249
|
const createPromises = newPropertyIds.map(async (propertyFileId) => {
|
|
4212
4250
|
try {
|
|
4213
4251
|
const property = await ModelProperty.createById(propertyFileId);
|
|
@@ -4502,6 +4540,111 @@ const modelMachine = xstate.setup({
|
|
|
4502
4540
|
},
|
|
4503
4541
|
});
|
|
4504
4542
|
|
|
4543
|
+
/**
|
|
4544
|
+
* Proxy [[GetOwnProperty]] that stays compatible with the target.
|
|
4545
|
+
* Never overrides an own descriptor, never invents on a non-extensible target,
|
|
4546
|
+
* and never promotes a prototype accessor to an own descriptor.
|
|
4547
|
+
*/
|
|
4548
|
+
function getInvariantSafePropertyDescriptor(target, prop, invent) {
|
|
4549
|
+
const own = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
4550
|
+
if (own)
|
|
4551
|
+
return own;
|
|
4552
|
+
if (!invent)
|
|
4553
|
+
return undefined;
|
|
4554
|
+
if (!Object.isExtensible(target))
|
|
4555
|
+
return undefined;
|
|
4556
|
+
return {
|
|
4557
|
+
enumerable: true,
|
|
4558
|
+
configurable: true,
|
|
4559
|
+
value: invent.value,
|
|
4560
|
+
writable: invent.writable ?? true,
|
|
4561
|
+
};
|
|
4562
|
+
}
|
|
4563
|
+
/**
|
|
4564
|
+
* Creates a reactive Proxy that intercepts property access and assignment
|
|
4565
|
+
* to read from and write to an actor service's context.
|
|
4566
|
+
*
|
|
4567
|
+
* This enables automatic React re-renders when properties change, as the
|
|
4568
|
+
* React hooks subscribe to the actor service which gets updated when properties
|
|
4569
|
+
* are set via the proxy.
|
|
4570
|
+
*
|
|
4571
|
+
* @param config Configuration object
|
|
4572
|
+
* @returns A proxied instance that behaves like the original but with reactive properties
|
|
4573
|
+
*
|
|
4574
|
+
* @note TypeScript's Proxy type doesn't automatically preserve method signatures,
|
|
4575
|
+
* so we use Proxied<T> to ensure all methods and properties are recognized.
|
|
4576
|
+
* The Proxy implementation preserves all methods via Reflect.get, so this is safe.
|
|
4577
|
+
*/
|
|
4578
|
+
function createReactiveProxy(config) {
|
|
4579
|
+
const { instance, trackedProperties, getContext, sendUpdate } = config;
|
|
4580
|
+
// Convert readonly array to regular array for includes() checks
|
|
4581
|
+
const trackedPropsSet = new Set(trackedProperties);
|
|
4582
|
+
// Create the proxy - TypeScript needs explicit type assertion to preserve all methods
|
|
4583
|
+
// The Proxy preserves all methods via Reflect.get, so we assert it maintains type T
|
|
4584
|
+
// Using 'as unknown as T' forces TypeScript to recognize all methods and properties
|
|
4585
|
+
const proxy = new Proxy(instance, {
|
|
4586
|
+
get(target, prop) {
|
|
4587
|
+
// Handle special properties that should not be proxied
|
|
4588
|
+
// These need direct access to the underlying instance
|
|
4589
|
+
if (prop === '_service') {
|
|
4590
|
+
return Reflect.get(target, prop);
|
|
4591
|
+
}
|
|
4592
|
+
// If it's a tracked property, read from actor context
|
|
4593
|
+
if (typeof prop === 'string' && trackedPropsSet.has(prop)) {
|
|
4594
|
+
const context = getContext(instance);
|
|
4595
|
+
return context[prop];
|
|
4596
|
+
}
|
|
4597
|
+
// For methods and non-tracked properties, use Reflect
|
|
4598
|
+
return Reflect.get(target, prop);
|
|
4599
|
+
},
|
|
4600
|
+
set(target, prop, value) {
|
|
4601
|
+
// Handle special properties
|
|
4602
|
+
if (prop === '_service') {
|
|
4603
|
+
return Reflect.set(target, prop, value);
|
|
4604
|
+
}
|
|
4605
|
+
// If it's a tracked property, send update to actor
|
|
4606
|
+
if (typeof prop === 'string' && trackedPropsSet.has(prop)) {
|
|
4607
|
+
sendUpdate(instance, prop, value);
|
|
4608
|
+
return true; // Indicate success
|
|
4609
|
+
}
|
|
4610
|
+
// For non-tracked properties, use Reflect. Also trigger sendUpdate for virtual
|
|
4611
|
+
// 'value' so the callback runs when .value is assigned (e.g. ItemProperty).
|
|
4612
|
+
if (typeof prop === 'string' && prop === 'value') {
|
|
4613
|
+
sendUpdate(instance, prop, value);
|
|
4614
|
+
}
|
|
4615
|
+
return Reflect.set(target, prop, value);
|
|
4616
|
+
},
|
|
4617
|
+
has(target, prop) {
|
|
4618
|
+
// Check if property exists in context or on target
|
|
4619
|
+
if (typeof prop === 'string' && trackedPropsSet.has(prop)) {
|
|
4620
|
+
const context = getContext(instance);
|
|
4621
|
+
return prop in context;
|
|
4622
|
+
}
|
|
4623
|
+
return Reflect.has(target, prop);
|
|
4624
|
+
},
|
|
4625
|
+
ownKeys(target) {
|
|
4626
|
+
// Only return keys that actually exist on the target object
|
|
4627
|
+
// This is required when the target is non-extensible (e.g., frozen by Immer)
|
|
4628
|
+
// Tracked properties are virtual (read from context), so we don't include them here
|
|
4629
|
+
// They're accessible via the get trap, but don't appear in ownKeys
|
|
4630
|
+
return Reflect.ownKeys(target);
|
|
4631
|
+
},
|
|
4632
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
4633
|
+
let invent;
|
|
4634
|
+
if (typeof prop === 'string' && trackedPropsSet.has(prop)) {
|
|
4635
|
+
const context = getContext(instance);
|
|
4636
|
+
if (prop in context) {
|
|
4637
|
+
invent = { value: context[prop] };
|
|
4638
|
+
}
|
|
4639
|
+
}
|
|
4640
|
+
return getInvariantSafePropertyDescriptor(target, prop, invent);
|
|
4641
|
+
}
|
|
4642
|
+
});
|
|
4643
|
+
// Force TypeScript to recognize all methods and properties are preserved
|
|
4644
|
+
// The Proxy implementation preserves all methods via Reflect.get, so this is safe
|
|
4645
|
+
return proxy;
|
|
4646
|
+
}
|
|
4647
|
+
|
|
4505
4648
|
const ENV = (typeof process !== 'undefined' && process.env)
|
|
4506
4649
|
? process.env
|
|
4507
4650
|
: (typeof window !== 'undefined' && window.env)
|
|
@@ -4822,14 +4965,14 @@ const createSeed = async ({ type, seedUid }) => {
|
|
|
4822
4965
|
// if the EAS schema hasn't been published yet
|
|
4823
4966
|
const appDb = BaseDb.getAppDb();
|
|
4824
4967
|
const newSeedLocalId = generateId();
|
|
4825
|
-
const publisher = await getPublisherForNewSeedsWithTimeout();
|
|
4968
|
+
const publisher = normalizePublisher(await getPublisherForNewSeedsWithTimeout());
|
|
4826
4969
|
await appDb.insert(seeds).values({
|
|
4827
4970
|
localId: newSeedLocalId,
|
|
4828
4971
|
type,
|
|
4829
4972
|
uid: seedUid,
|
|
4830
4973
|
createdAt: Date.now(),
|
|
4831
4974
|
schemaUid: schemaUid || null,
|
|
4832
|
-
...(publisher
|
|
4975
|
+
...(publisher && { publisher }),
|
|
4833
4976
|
});
|
|
4834
4977
|
return newSeedLocalId;
|
|
4835
4978
|
};
|
|
@@ -4837,7 +4980,7 @@ const createSeed = async ({ type, seedUid }) => {
|
|
|
4837
4980
|
const createVersion = async ({ seedLocalId, seedUid, seedType, uid, }) => {
|
|
4838
4981
|
const appDb = BaseDb.getAppDb();
|
|
4839
4982
|
const newVersionLocalId = generateId();
|
|
4840
|
-
const publisher = await getPublisherForNewSeedsWithTimeout();
|
|
4983
|
+
const publisher = normalizePublisher(await getPublisherForNewSeedsWithTimeout());
|
|
4841
4984
|
await appDb.insert(versions).values({
|
|
4842
4985
|
localId: newVersionLocalId,
|
|
4843
4986
|
createdAt: Date.now(),
|
|
@@ -4845,7 +4988,7 @@ const createVersion = async ({ seedLocalId, seedUid, seedType, uid, }) => {
|
|
|
4845
4988
|
seedUid: seedUid ?? null,
|
|
4846
4989
|
seedType,
|
|
4847
4990
|
uid: uid ?? null,
|
|
4848
|
-
...(publisher
|
|
4991
|
+
...(publisher && { publisher }),
|
|
4849
4992
|
});
|
|
4850
4993
|
return newVersionLocalId;
|
|
4851
4994
|
};
|
|
@@ -5188,7 +5331,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
5188
5331
|
const schemaNameToTry = model$1?.schemaName;
|
|
5189
5332
|
if (schemaNameToTry) {
|
|
5190
5333
|
try {
|
|
5191
|
-
const { Schema } = await Promise.resolve().then(function () { return require('./Schema-
|
|
5334
|
+
const { Schema } = await Promise.resolve().then(function () { return require('./Schema-FdzNqyGo.js'); });
|
|
5192
5335
|
const schemaInstance = Schema.create(schemaNameToTry, { waitForReady: false });
|
|
5193
5336
|
const schemaContext = schemaInstance.getService().getSnapshot().context;
|
|
5194
5337
|
if (schemaContext.models?.[modelName]?.properties) {
|
|
@@ -5237,7 +5380,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
5237
5380
|
}
|
|
5238
5381
|
}
|
|
5239
5382
|
if (Object.keys(propertySchemas).length === 0) {
|
|
5240
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
5383
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-D_ph4zut.js'); });
|
|
5241
5384
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
5242
5385
|
const KNOWN_MODEL_FALLBACKS = {
|
|
5243
5386
|
Post: {
|
|
@@ -5284,7 +5427,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
5284
5427
|
// Infer propertyRecordSchema from metadata when schema is missing (enables persistence)
|
|
5285
5428
|
let propSchema = propertySchemas[propertyName];
|
|
5286
5429
|
if (!propSchema && isRefTypeFromMeta) {
|
|
5287
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
5430
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-D_ph4zut.js'); });
|
|
5288
5431
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
5289
5432
|
propSchema = {
|
|
5290
5433
|
dataType: refSeedType === 'html' ? ModelPropertyDataTypes.Html
|
|
@@ -5541,9 +5684,9 @@ const runPublish = xstate.fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5541
5684
|
sendBack({ type: 'publishError', error: new Error(`Item not found for seedLocalId: ${seedLocalId}`) });
|
|
5542
5685
|
return;
|
|
5543
5686
|
}
|
|
5544
|
-
const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-
|
|
5687
|
+
const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-D2VZHZnu.js'); });
|
|
5545
5688
|
const { getPublishUploads } = getPublishUploadsMod;
|
|
5546
|
-
const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-
|
|
5689
|
+
const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-BvmVTKoc.js'); });
|
|
5547
5690
|
const { getPublishPayload } = getPublishPayloadMod;
|
|
5548
5691
|
const uploads = await getPublishUploads(item);
|
|
5549
5692
|
let uploadedTransactions = [];
|
|
@@ -5903,6 +6046,8 @@ const INTERNAL_PROPERTY_NAMES = [
|
|
|
5903
6046
|
'_markedForDeletion',
|
|
5904
6047
|
// SDK-internal: wallet address of attester; never publish as property attestation
|
|
5905
6048
|
'publisher',
|
|
6049
|
+
// SDK-internal: Unix timestamp when attestations were revoked; never a schema field
|
|
6050
|
+
'revokedAt',
|
|
5906
6051
|
];
|
|
5907
6052
|
const VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA = '0x13c0fd59d69dbce40501a41f8b37768d26dd2e2bb0cad64615334d84f7b9bdf6';
|
|
5908
6053
|
const defaultAttestationData = {
|
|
@@ -6253,6 +6398,130 @@ async function batchLatestPublishedVersionBySeedLocalIds(seedLocalIds) {
|
|
|
6253
6398
|
return out;
|
|
6254
6399
|
}
|
|
6255
6400
|
|
|
6401
|
+
const READ_ONLY_ERROR = 'Item is read-only: you do not own this item';
|
|
6402
|
+
async function getSeedRowForItem(item) {
|
|
6403
|
+
const appDb = BaseDb.getAppDb();
|
|
6404
|
+
if (!appDb)
|
|
6405
|
+
return null;
|
|
6406
|
+
const conditions = [];
|
|
6407
|
+
if (item.seedLocalId)
|
|
6408
|
+
conditions.push(drizzleOrm.eq(seeds.localId, item.seedLocalId));
|
|
6409
|
+
if (item.seedUid)
|
|
6410
|
+
conditions.push(drizzleOrm.eq(seeds.uid, item.seedUid));
|
|
6411
|
+
if (conditions.length === 0)
|
|
6412
|
+
return null;
|
|
6413
|
+
const seedRows = await appDb
|
|
6414
|
+
.select({
|
|
6415
|
+
publisher: seeds.publisher,
|
|
6416
|
+
attestationRaw: seeds.attestationRaw,
|
|
6417
|
+
uid: seeds.uid,
|
|
6418
|
+
})
|
|
6419
|
+
.from(seeds)
|
|
6420
|
+
.where(conditions.length === 1 ? conditions[0] : drizzleOrm.or(...conditions))
|
|
6421
|
+
.limit(1);
|
|
6422
|
+
if (!seedRows || seedRows.length === 0)
|
|
6423
|
+
return null;
|
|
6424
|
+
return seedRows[0];
|
|
6425
|
+
}
|
|
6426
|
+
/** Resolve publisher from seed row: `publisher` column, else `attestationRaw.attester`. */
|
|
6427
|
+
function resolvePublisherFromSeedRow(row) {
|
|
6428
|
+
if (row.publisher)
|
|
6429
|
+
return row.publisher;
|
|
6430
|
+
if (row.attestationRaw) {
|
|
6431
|
+
try {
|
|
6432
|
+
const parsed = JSON.parse(row.attestationRaw);
|
|
6433
|
+
return parsed.attester ?? null;
|
|
6434
|
+
}
|
|
6435
|
+
catch {
|
|
6436
|
+
return null;
|
|
6437
|
+
}
|
|
6438
|
+
}
|
|
6439
|
+
return null;
|
|
6440
|
+
}
|
|
6441
|
+
/**
|
|
6442
|
+
* Local draft that has never been attested: no publisher, no real uid, no attestationRaw.
|
|
6443
|
+
*/
|
|
6444
|
+
function isLocalUnsealedDraft(row) {
|
|
6445
|
+
const publisher = row.publisher;
|
|
6446
|
+
if (publisher != null && publisher !== '')
|
|
6447
|
+
return false;
|
|
6448
|
+
if (!eas.isPlaceholderUid(row.uid))
|
|
6449
|
+
return false;
|
|
6450
|
+
if (row.attestationRaw != null && row.attestationRaw !== '')
|
|
6451
|
+
return false;
|
|
6452
|
+
return true;
|
|
6453
|
+
}
|
|
6454
|
+
/** Case-insensitive membership in the persisted owned set. */
|
|
6455
|
+
function publisherIsInOwnedSet(publisher, ownedAddresses) {
|
|
6456
|
+
if (publisher == null || publisher === '')
|
|
6457
|
+
return false;
|
|
6458
|
+
const ownedSet = new Set(normalizeAddressList(ownedAddresses));
|
|
6459
|
+
return ownedSet.has(normalizeHexAddress(publisher));
|
|
6460
|
+
}
|
|
6461
|
+
/**
|
|
6462
|
+
* Shared ownership predicate.
|
|
6463
|
+
* - Session has owned addresses: only a publisher in that set is owned (null is never owned).
|
|
6464
|
+
* - Session has no owned addresses: local unsealed drafts are owned so pre-connect authoring works.
|
|
6465
|
+
*/
|
|
6466
|
+
function isSeedRowOwned(row, ownedAddresses) {
|
|
6467
|
+
const publisher = resolvePublisherFromSeedRow(row);
|
|
6468
|
+
if (ownedAddresses.length === 0) {
|
|
6469
|
+
return isLocalUnsealedDraft({ ...row, publisher: publisher ?? row.publisher });
|
|
6470
|
+
}
|
|
6471
|
+
return publisherIsInOwnedSet(publisher, ownedAddresses);
|
|
6472
|
+
}
|
|
6473
|
+
/**
|
|
6474
|
+
* SQL for `addressFilter: 'owned' | 'watched'`. Empty list → no rows (`1=0`).
|
|
6475
|
+
* Compares `lower(publisher)` so checksummed rows match persisted lowercase owned.
|
|
6476
|
+
*/
|
|
6477
|
+
function publisherInAddressListSql(column, addresses) {
|
|
6478
|
+
const normalized = normalizeAddressList(addresses);
|
|
6479
|
+
if (normalized.length === 0) {
|
|
6480
|
+
return drizzleOrm.sql `1=0`;
|
|
6481
|
+
}
|
|
6482
|
+
return drizzleOrm.inArray(drizzleOrm.sql `lower(${column})`, normalized);
|
|
6483
|
+
}
|
|
6484
|
+
/**
|
|
6485
|
+
* Checks if the current user owns the item (publisher is in persisted owned addresses).
|
|
6486
|
+
*
|
|
6487
|
+
* When the session has owned addresses, only a matching publisher is owned —
|
|
6488
|
+
* `publisher IS NULL` is not treated as owned. Call `claimUnpublishedDrafts`
|
|
6489
|
+
* after connect to stamp local drafts.
|
|
6490
|
+
*
|
|
6491
|
+
* When owned is empty, local unsealed drafts (no publisher, no real uid, no
|
|
6492
|
+
* attestationRaw) are still owned so create/edit works before a wallet is connected.
|
|
6493
|
+
*
|
|
6494
|
+
* Does not include `getAdditionalSyncAddresses` (those are extra EAS indexers,
|
|
6495
|
+
* not wallets the user controls).
|
|
6496
|
+
*/
|
|
6497
|
+
async function isItemOwned(item) {
|
|
6498
|
+
const row = await getSeedRowForItem(item);
|
|
6499
|
+
if (!row)
|
|
6500
|
+
return false;
|
|
6501
|
+
const ownedAddresses = await getOwnedAddressesFromDb();
|
|
6502
|
+
return isSeedRowOwned(row, ownedAddresses);
|
|
6503
|
+
}
|
|
6504
|
+
/**
|
|
6505
|
+
* Throws if the item is not owned. Use before write operations (publish, save, destroy).
|
|
6506
|
+
*/
|
|
6507
|
+
async function assertItemOwned(item) {
|
|
6508
|
+
const owned = await isItemOwned(item);
|
|
6509
|
+
if (!owned) {
|
|
6510
|
+
throw new Error(READ_ONLY_ERROR);
|
|
6511
|
+
}
|
|
6512
|
+
}
|
|
6513
|
+
|
|
6514
|
+
var ownership = /*#__PURE__*/Object.freeze({
|
|
6515
|
+
__proto__: null,
|
|
6516
|
+
assertItemOwned: assertItemOwned,
|
|
6517
|
+
isItemOwned: isItemOwned,
|
|
6518
|
+
isLocalUnsealedDraft: isLocalUnsealedDraft,
|
|
6519
|
+
isSeedRowOwned: isSeedRowOwned,
|
|
6520
|
+
publisherInAddressListSql: publisherInAddressListSql,
|
|
6521
|
+
publisherIsInOwnedSet: publisherIsInOwnedSet,
|
|
6522
|
+
resolvePublisherFromSeedRow: resolvePublisherFromSeedRow
|
|
6523
|
+
});
|
|
6524
|
+
|
|
6256
6525
|
/**
|
|
6257
6526
|
* List item rows for list UIs. Only includes seeds that have at least one version.
|
|
6258
6527
|
*
|
|
@@ -6273,16 +6542,11 @@ const getItemsData = async ({ modelName, deleted, includeEas = false, addressFil
|
|
|
6273
6542
|
}
|
|
6274
6543
|
if (addressFilter === 'owned') {
|
|
6275
6544
|
const ownedAddresses = await getAddressesForItemsFilter('owned');
|
|
6276
|
-
|
|
6277
|
-
conditions.push(drizzleOrm.or(drizzleOrm.inArray(seeds.publisher, ownedAddresses), drizzleOrm.isNull(seeds.publisher)));
|
|
6278
|
-
}
|
|
6545
|
+
conditions.push(publisherInAddressListSql(seeds.publisher, ownedAddresses));
|
|
6279
6546
|
}
|
|
6280
6547
|
else if (addressFilter === 'watched') {
|
|
6281
6548
|
const watchedAddresses = await getAddressesForItemsFilter('watched');
|
|
6282
|
-
|
|
6283
|
-
return [];
|
|
6284
|
-
}
|
|
6285
|
-
conditions.push(drizzleOrm.inArray(seeds.publisher, watchedAddresses));
|
|
6549
|
+
conditions.push(publisherInAddressListSql(seeds.publisher, watchedAddresses));
|
|
6286
6550
|
}
|
|
6287
6551
|
if (deleted) {
|
|
6288
6552
|
conditions.push(drizzleOrm.or(drizzleOrm.isNotNull(seeds._markedForDeletion), drizzleOrm.eq(seeds._markedForDeletion, 1)));
|
|
@@ -6524,7 +6788,7 @@ const resolveRelatedValue = xstate.fromCallback(({ sendBack, input: { context }
|
|
|
6524
6788
|
const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
|
|
6525
6789
|
const _resolveRelatedValue = async () => {
|
|
6526
6790
|
// Use dynamic import to break circular dependency
|
|
6527
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
6791
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-D_ph4zut.js'); });
|
|
6528
6792
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
6529
6793
|
if (!propertyValue || !isRelation || populatedFromDb) {
|
|
6530
6794
|
return;
|
|
@@ -6843,6 +7107,7 @@ const updateMetadata = async (metadataValues, propertyRecordSchema) => {
|
|
|
6843
7107
|
}
|
|
6844
7108
|
// Publisher is immutable once set: do not overwrite existing publisher
|
|
6845
7109
|
if (rest.publisher != null && rest.publisher !== '') {
|
|
7110
|
+
rest.publisher = normalizePublisher(rest.publisher) ?? rest.publisher;
|
|
6846
7111
|
const [row] = await appDb
|
|
6847
7112
|
.select({ publisher: metadata$1.publisher })
|
|
6848
7113
|
.from(metadata$1)
|
|
@@ -7527,7 +7792,7 @@ const hydrateFromDb = xstate.fromCallback(({ sendBack, input: { context } }) =>
|
|
|
7527
7792
|
// to use dynamically imported ModelPropertyDataTypes
|
|
7528
7793
|
const _hydrateFromDb = async () => {
|
|
7529
7794
|
// Use dynamic import to break circular dependency
|
|
7530
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
7795
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-D_ph4zut.js'); });
|
|
7531
7796
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
7532
7797
|
const appDb = BaseDb.getAppDb();
|
|
7533
7798
|
const whereClauses = [];
|
|
@@ -7890,7 +8155,7 @@ const loadOrCreateProperty = xstate.fromCallback(({ sendBack, input: { context }
|
|
|
7890
8155
|
};
|
|
7891
8156
|
// Merge with schema from file/DB to get validation rules (enum, pattern, etc.) - properties table doesn't store these
|
|
7892
8157
|
try {
|
|
7893
|
-
const { getPropertySchema } = await Promise.resolve().then(function () { return require('./property-
|
|
8158
|
+
const { getPropertySchema } = await Promise.resolve().then(function () { return require('./property-DkUtJxV2.js'); });
|
|
7894
8159
|
let schemaFromFile = await getPropertySchema(normalizedModelName, propertyName);
|
|
7895
8160
|
if (!schemaFromFile?.validation) {
|
|
7896
8161
|
// Fallback: get validation from schemaData in database (Schema context may not be loaded yet)
|
|
@@ -8355,9 +8620,9 @@ const analyzeInput = xstate.fromCallback(({ sendBack, input: { context, event }
|
|
|
8355
8620
|
}
|
|
8356
8621
|
const _analyzeInput = async () => {
|
|
8357
8622
|
// Use dynamic import to break circular dependency
|
|
8358
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
8623
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-D_ph4zut.js'); });
|
|
8359
8624
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
8360
|
-
const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
8625
|
+
const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-pxRoOs79.js'); });
|
|
8361
8626
|
let propertyName = propertyNameRaw;
|
|
8362
8627
|
if (!propertyName) {
|
|
8363
8628
|
throw new Error('propertyName is required');
|
|
@@ -8525,8 +8790,8 @@ class MetadataValidationError extends Error {
|
|
|
8525
8790
|
const createMetadata = async (metadataValues, propertyRecordSchema, options) => {
|
|
8526
8791
|
const appDb = BaseDb.getAppDb();
|
|
8527
8792
|
metadataValues.localId = generateId();
|
|
8528
|
-
const publisher = await getPublisherForNewSeedsWithTimeout();
|
|
8529
|
-
if (publisher
|
|
8793
|
+
const publisher = normalizePublisher(await getPublisherForNewSeedsWithTimeout());
|
|
8794
|
+
if (publisher) {
|
|
8530
8795
|
metadataValues.publisher = publisher;
|
|
8531
8796
|
}
|
|
8532
8797
|
if (!metadataValues.modelType && metadataValues.modelName) {
|
|
@@ -8555,7 +8820,7 @@ const createMetadata = async (metadataValues, propertyRecordSchema, options) =>
|
|
|
8555
8820
|
propertyRecordSchema?.validation &&
|
|
8556
8821
|
metadataValues.propertyValue != null &&
|
|
8557
8822
|
metadataValues.propertyValue !== '') {
|
|
8558
|
-
const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
8823
|
+
const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-pxRoOs79.js'); });
|
|
8559
8824
|
const validationService = new SchemaValidationService();
|
|
8560
8825
|
const validationResult = validationService.validatePropertyValue(metadataValues.propertyValue, normalizeDataType(propertyRecordSchema.dataType), propertyRecordSchema.validation, propertyRecordSchema.refValueType
|
|
8561
8826
|
? normalizeDataType(String(propertyRecordSchema.refValueType))
|
|
@@ -9148,7 +9413,7 @@ const saveRelation = xstate.fromCallback(({ sendBack, input: { context, event }
|
|
|
9148
9413
|
}
|
|
9149
9414
|
const _saveRelation = async () => {
|
|
9150
9415
|
// Use dynamic import to break circular dependency
|
|
9151
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
9416
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-D_ph4zut.js'); });
|
|
9152
9417
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
9153
9418
|
if (!propertyNameRaw) {
|
|
9154
9419
|
throw new Error('propertyName is required');
|
|
@@ -9897,95 +10162,6 @@ async function runDestroyLifecycle(instance, config) {
|
|
|
9897
10162
|
}
|
|
9898
10163
|
}
|
|
9899
10164
|
|
|
9900
|
-
/**
|
|
9901
|
-
* Creates a reactive Proxy that intercepts property access and assignment
|
|
9902
|
-
* to read from and write to an actor service's context.
|
|
9903
|
-
*
|
|
9904
|
-
* This enables automatic React re-renders when properties change, as the
|
|
9905
|
-
* React hooks subscribe to the actor service which gets updated when properties
|
|
9906
|
-
* are set via the proxy.
|
|
9907
|
-
*
|
|
9908
|
-
* @param config Configuration object
|
|
9909
|
-
* @returns A proxied instance that behaves like the original but with reactive properties
|
|
9910
|
-
*
|
|
9911
|
-
* @note TypeScript's Proxy type doesn't automatically preserve method signatures,
|
|
9912
|
-
* so we use Proxied<T> to ensure all methods and properties are recognized.
|
|
9913
|
-
* The Proxy implementation preserves all methods via Reflect.get, so this is safe.
|
|
9914
|
-
*/
|
|
9915
|
-
function createReactiveProxy(config) {
|
|
9916
|
-
const { instance, trackedProperties, getContext, sendUpdate } = config;
|
|
9917
|
-
// Convert readonly array to regular array for includes() checks
|
|
9918
|
-
const trackedPropsSet = new Set(trackedProperties);
|
|
9919
|
-
// Create the proxy - TypeScript needs explicit type assertion to preserve all methods
|
|
9920
|
-
// The Proxy preserves all methods via Reflect.get, so we assert it maintains type T
|
|
9921
|
-
// Using 'as unknown as T' forces TypeScript to recognize all methods and properties
|
|
9922
|
-
const proxy = new Proxy(instance, {
|
|
9923
|
-
get(target, prop) {
|
|
9924
|
-
// Handle special properties that should not be proxied
|
|
9925
|
-
// These need direct access to the underlying instance
|
|
9926
|
-
if (prop === '_service') {
|
|
9927
|
-
return Reflect.get(target, prop);
|
|
9928
|
-
}
|
|
9929
|
-
// If it's a tracked property, read from actor context
|
|
9930
|
-
if (typeof prop === 'string' && trackedPropsSet.has(prop)) {
|
|
9931
|
-
const context = getContext(instance);
|
|
9932
|
-
return context[prop];
|
|
9933
|
-
}
|
|
9934
|
-
// For methods and non-tracked properties, use Reflect
|
|
9935
|
-
return Reflect.get(target, prop);
|
|
9936
|
-
},
|
|
9937
|
-
set(target, prop, value) {
|
|
9938
|
-
// Handle special properties
|
|
9939
|
-
if (prop === '_service') {
|
|
9940
|
-
return Reflect.set(target, prop, value);
|
|
9941
|
-
}
|
|
9942
|
-
// If it's a tracked property, send update to actor
|
|
9943
|
-
if (typeof prop === 'string' && trackedPropsSet.has(prop)) {
|
|
9944
|
-
sendUpdate(instance, prop, value);
|
|
9945
|
-
return true; // Indicate success
|
|
9946
|
-
}
|
|
9947
|
-
// For non-tracked properties, use Reflect. Also trigger sendUpdate for virtual
|
|
9948
|
-
// 'value' so the callback runs when .value is assigned (e.g. ItemProperty).
|
|
9949
|
-
if (typeof prop === 'string' && prop === 'value') {
|
|
9950
|
-
sendUpdate(instance, prop, value);
|
|
9951
|
-
}
|
|
9952
|
-
return Reflect.set(target, prop, value);
|
|
9953
|
-
},
|
|
9954
|
-
has(target, prop) {
|
|
9955
|
-
// Check if property exists in context or on target
|
|
9956
|
-
if (typeof prop === 'string' && trackedPropsSet.has(prop)) {
|
|
9957
|
-
const context = getContext(instance);
|
|
9958
|
-
return prop in context;
|
|
9959
|
-
}
|
|
9960
|
-
return Reflect.has(target, prop);
|
|
9961
|
-
},
|
|
9962
|
-
ownKeys(target) {
|
|
9963
|
-
// Only return keys that actually exist on the target object
|
|
9964
|
-
// This is required when the target is non-extensible (e.g., frozen by Immer)
|
|
9965
|
-
// Tracked properties are virtual (read from context), so we don't include them here
|
|
9966
|
-
// They're accessible via the get trap, but don't appear in ownKeys
|
|
9967
|
-
return Reflect.ownKeys(target);
|
|
9968
|
-
},
|
|
9969
|
-
getOwnPropertyDescriptor(target, prop) {
|
|
9970
|
-
if (typeof prop === 'string' && trackedPropsSet.has(prop)) {
|
|
9971
|
-
const context = getContext(instance);
|
|
9972
|
-
if (prop in context) {
|
|
9973
|
-
return {
|
|
9974
|
-
enumerable: true,
|
|
9975
|
-
configurable: true,
|
|
9976
|
-
value: context[prop],
|
|
9977
|
-
writable: true,
|
|
9978
|
-
};
|
|
9979
|
-
}
|
|
9980
|
-
}
|
|
9981
|
-
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
9982
|
-
}
|
|
9983
|
-
});
|
|
9984
|
-
// Force TypeScript to recognize all methods and properties are preserved
|
|
9985
|
-
// The Proxy implementation preserves all methods via Reflect.get, so this is safe
|
|
9986
|
-
return proxy;
|
|
9987
|
-
}
|
|
9988
|
-
|
|
9989
10165
|
/** Parent Html property `propertyValue` after publish (66-char seed uid). */
|
|
9990
10166
|
const HTML_PROP_SEED_UID_RE = /^0x[a-fA-F0-9]{64}$/;
|
|
9991
10167
|
// Start loading Model at module load time (non-blocking)
|
|
@@ -10192,7 +10368,7 @@ class ItemProperty {
|
|
|
10192
10368
|
return;
|
|
10193
10369
|
}
|
|
10194
10370
|
// Use dynamic import to break circular dependency
|
|
10195
|
-
const schemaMod = await Promise.resolve().then(function () { return require('./index-
|
|
10371
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-D_ph4zut.js'); });
|
|
10196
10372
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
10197
10373
|
const { context } = snapshot;
|
|
10198
10374
|
const { propertyRecordSchema } = context;
|
|
@@ -11343,7 +11519,8 @@ const updateSeedUid = async ({ seedLocalId, seedUid, publisher, attestationCreat
|
|
|
11343
11519
|
return;
|
|
11344
11520
|
}
|
|
11345
11521
|
const appDb = BaseDb.getAppDb();
|
|
11346
|
-
|
|
11522
|
+
const normalizedPublisher = normalizePublisher(publisher);
|
|
11523
|
+
let shouldSetPublisher = normalizedPublisher != null;
|
|
11347
11524
|
if (shouldSetPublisher) {
|
|
11348
11525
|
const [row] = await appDb
|
|
11349
11526
|
.select({ publisher: seeds.publisher })
|
|
@@ -11358,7 +11535,7 @@ const updateSeedUid = async ({ seedLocalId, seedUid, publisher, attestationCreat
|
|
|
11358
11535
|
.update(seeds)
|
|
11359
11536
|
.set({
|
|
11360
11537
|
uid: seedUid,
|
|
11361
|
-
...(shouldSetPublisher && { publisher }),
|
|
11538
|
+
...(shouldSetPublisher && { publisher: normalizedPublisher }),
|
|
11362
11539
|
...(attestationCreatedAt != null && { attestationCreatedAt }),
|
|
11363
11540
|
updatedAt: Date.now(),
|
|
11364
11541
|
})
|
|
@@ -11500,12 +11677,12 @@ class Item {
|
|
|
11500
11677
|
};
|
|
11501
11678
|
this.getPublishUploads = async (options) => {
|
|
11502
11679
|
// Use dynamic import to break circular dependency
|
|
11503
|
-
const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-
|
|
11680
|
+
const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-D2VZHZnu.js'); });
|
|
11504
11681
|
const { getPublishUploads } = getPublishUploadsMod;
|
|
11505
11682
|
return await getPublishUploads(this, [], undefined, options);
|
|
11506
11683
|
};
|
|
11507
11684
|
this.getPublishPayload = async (uploadedTransactions, options) => {
|
|
11508
|
-
const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-
|
|
11685
|
+
const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-BvmVTKoc.js'); });
|
|
11509
11686
|
const { getPublishPayload } = getPublishPayloadMod;
|
|
11510
11687
|
return await getPublishPayload(this, uploadedTransactions, options);
|
|
11511
11688
|
};
|
|
@@ -11624,6 +11801,7 @@ class Item {
|
|
|
11624
11801
|
'latestVersionUid',
|
|
11625
11802
|
'publishedVersionUid',
|
|
11626
11803
|
'publishedVersionLocalId',
|
|
11804
|
+
'revokedAt',
|
|
11627
11805
|
];
|
|
11628
11806
|
const keysFromInitial = Object.keys(initialValues).filter((key) => !metadataKeys.includes(key));
|
|
11629
11807
|
const schemaNameForModel = initialValues.schemaName;
|
|
@@ -11929,19 +12107,14 @@ class Item {
|
|
|
11929
12107
|
return Reflect.ownKeys(target);
|
|
11930
12108
|
},
|
|
11931
12109
|
getOwnPropertyDescriptor(target, prop) {
|
|
11932
|
-
|
|
12110
|
+
let invent;
|
|
11933
12111
|
if (typeof prop === 'string' && TRACKED_PROPERTIES$1.includes(prop)) {
|
|
11934
12112
|
const context = target._getSnapshotContext();
|
|
11935
12113
|
if (prop in context) {
|
|
11936
|
-
|
|
11937
|
-
enumerable: true,
|
|
11938
|
-
configurable: true,
|
|
11939
|
-
value: context[prop],
|
|
11940
|
-
writable: true,
|
|
11941
|
-
};
|
|
12114
|
+
invent = { value: context[prop] };
|
|
11942
12115
|
}
|
|
11943
12116
|
}
|
|
11944
|
-
return
|
|
12117
|
+
return getInvariantSafePropertyDescriptor(target, prop, invent);
|
|
11945
12118
|
},
|
|
11946
12119
|
});
|
|
11947
12120
|
this.registerItemInInstanceCache(proxiedInstance);
|
|
@@ -12109,19 +12282,14 @@ class Item {
|
|
|
12109
12282
|
return Reflect.ownKeys(target);
|
|
12110
12283
|
},
|
|
12111
12284
|
getOwnPropertyDescriptor(target, prop) {
|
|
12112
|
-
|
|
12285
|
+
let invent;
|
|
12113
12286
|
if (typeof prop === 'string' && TRACKED_PROPERTIES$1.includes(prop)) {
|
|
12114
12287
|
const context = target._getSnapshotContext();
|
|
12115
12288
|
if (prop in context) {
|
|
12116
|
-
|
|
12117
|
-
enumerable: true,
|
|
12118
|
-
configurable: true,
|
|
12119
|
-
value: context[prop],
|
|
12120
|
-
writable: true,
|
|
12121
|
-
};
|
|
12289
|
+
invent = { value: context[prop] };
|
|
12122
12290
|
}
|
|
12123
12291
|
}
|
|
12124
|
-
return
|
|
12292
|
+
return getInvariantSafePropertyDescriptor(target, prop, invent);
|
|
12125
12293
|
},
|
|
12126
12294
|
});
|
|
12127
12295
|
this.registerItemInInstanceCache(proxiedInstance);
|
|
@@ -12433,6 +12601,7 @@ class Item {
|
|
|
12433
12601
|
}
|
|
12434
12602
|
},
|
|
12435
12603
|
enumerable: true,
|
|
12604
|
+
configurable: true,
|
|
12436
12605
|
});
|
|
12437
12606
|
state.definedPropertyNames.add(propertyName);
|
|
12438
12607
|
}
|
|
@@ -13074,24 +13243,6 @@ class ConflictError extends Error {
|
|
|
13074
13243
|
}
|
|
13075
13244
|
}
|
|
13076
13245
|
|
|
13077
|
-
/**
|
|
13078
|
-
* Normalizes AddressConfiguration to { owned, watched }.
|
|
13079
|
-
* - string[] -> { owned: addresses, watched: [] }
|
|
13080
|
-
* - { owned, watched? } -> { owned, watched: watched ?? [] }
|
|
13081
|
-
*/
|
|
13082
|
-
function normalizeAddressConfig(addresses) {
|
|
13083
|
-
if (!addresses) {
|
|
13084
|
-
return { owned: [], watched: [] };
|
|
13085
|
-
}
|
|
13086
|
-
if (Array.isArray(addresses)) {
|
|
13087
|
-
return { owned: addresses, watched: [] };
|
|
13088
|
-
}
|
|
13089
|
-
return {
|
|
13090
|
-
owned: addresses.owned ?? [],
|
|
13091
|
-
watched: addresses.watched ?? [],
|
|
13092
|
-
};
|
|
13093
|
-
}
|
|
13094
|
-
|
|
13095
13246
|
let writeTail = Promise.resolve();
|
|
13096
13247
|
function enqueueEasSyncDbWrite(fn) {
|
|
13097
13248
|
const next = writeTail.then(fn);
|
|
@@ -13188,7 +13339,7 @@ const runEasSync = xstate.fromPromise(async ({ input, }) => {
|
|
|
13188
13339
|
requestPayload: input.requestPayload,
|
|
13189
13340
|
persistedSnapshot: input.runningSnapshot,
|
|
13190
13341
|
});
|
|
13191
|
-
const { runSyncFromEas } = await Promise.resolve().then(function () { return require('./syncDbWithEas-
|
|
13342
|
+
const { runSyncFromEas } = await Promise.resolve().then(function () { return require('./syncDbWithEas-DRoys7eo.js'); });
|
|
13192
13343
|
try {
|
|
13193
13344
|
await runSyncFromEas(toRunSyncArg(input.options));
|
|
13194
13345
|
await finalizeEasSyncProcessRow(rowId, {
|
|
@@ -13972,8 +14123,8 @@ const saveConfig = xstate.fromCallback(({ sendBack, input: { context } }) => {
|
|
|
13972
14123
|
throw new Error('App DB not found');
|
|
13973
14124
|
}
|
|
13974
14125
|
const endpointsValueString = JSON.stringify(endpoints);
|
|
13975
|
-
const owned = ownedAddresses ?? addresses ?? [];
|
|
13976
|
-
const watched = watchedAddresses ?? [];
|
|
14126
|
+
const owned = normalizeAddressList(ownedAddresses ?? addresses ?? []);
|
|
14127
|
+
const watched = normalizeAddressList(watchedAddresses ?? []);
|
|
13977
14128
|
const addressesValueString = JSON.stringify({ owned, watched });
|
|
13978
14129
|
// TODO: Figure out how to define on conflict with multiple rows added
|
|
13979
14130
|
await appDb
|
|
@@ -13988,20 +14139,18 @@ const saveConfig = xstate.fromCallback(({ sendBack, input: { context } }) => {
|
|
|
13988
14139
|
value: endpointsValueString,
|
|
13989
14140
|
},
|
|
13990
14141
|
});
|
|
13991
|
-
|
|
13992
|
-
|
|
13993
|
-
|
|
13994
|
-
|
|
13995
|
-
|
|
14142
|
+
await appDb
|
|
14143
|
+
.insert(appState)
|
|
14144
|
+
.values({
|
|
14145
|
+
key: 'addresses',
|
|
14146
|
+
value: addressesValueString,
|
|
14147
|
+
})
|
|
14148
|
+
.onConflictDoUpdate({
|
|
14149
|
+
target: appState.key,
|
|
14150
|
+
set: {
|
|
13996
14151
|
value: addressesValueString,
|
|
13997
|
-
}
|
|
13998
|
-
|
|
13999
|
-
target: appState.key,
|
|
14000
|
-
set: {
|
|
14001
|
-
value: addressesValueString,
|
|
14002
|
-
},
|
|
14003
|
-
});
|
|
14004
|
-
}
|
|
14152
|
+
},
|
|
14153
|
+
});
|
|
14005
14154
|
await appDb
|
|
14006
14155
|
.insert(appState)
|
|
14007
14156
|
.values({
|
|
@@ -17179,85 +17328,7 @@ function unregisterSeedQueryLocalSource() {
|
|
|
17179
17328
|
registered = false;
|
|
17180
17329
|
}
|
|
17181
17330
|
|
|
17182
|
-
const
|
|
17183
|
-
async function getSeedRowForItem(item) {
|
|
17184
|
-
const appDb = BaseDb.getAppDb();
|
|
17185
|
-
if (!appDb)
|
|
17186
|
-
return null;
|
|
17187
|
-
const conditions = [];
|
|
17188
|
-
if (item.seedLocalId)
|
|
17189
|
-
conditions.push(drizzleOrm.eq(seeds.localId, item.seedLocalId));
|
|
17190
|
-
if (item.seedUid)
|
|
17191
|
-
conditions.push(drizzleOrm.eq(seeds.uid, item.seedUid));
|
|
17192
|
-
if (conditions.length === 0)
|
|
17193
|
-
return null;
|
|
17194
|
-
const seedRows = await appDb
|
|
17195
|
-
.select({
|
|
17196
|
-
publisher: seeds.publisher,
|
|
17197
|
-
attestationRaw: seeds.attestationRaw,
|
|
17198
|
-
uid: seeds.uid,
|
|
17199
|
-
})
|
|
17200
|
-
.from(seeds)
|
|
17201
|
-
.where(conditions.length === 1 ? conditions[0] : drizzleOrm.or(...conditions))
|
|
17202
|
-
.limit(1);
|
|
17203
|
-
if (!seedRows || seedRows.length === 0)
|
|
17204
|
-
return null;
|
|
17205
|
-
return seedRows[0];
|
|
17206
|
-
}
|
|
17207
|
-
/** Resolve publisher from seed row: `publisher` column, else `attestationRaw.attester`. */
|
|
17208
|
-
function resolvePublisherFromSeedRow(row) {
|
|
17209
|
-
if (row.publisher)
|
|
17210
|
-
return row.publisher;
|
|
17211
|
-
if (row.attestationRaw) {
|
|
17212
|
-
try {
|
|
17213
|
-
const parsed = JSON.parse(row.attestationRaw);
|
|
17214
|
-
return parsed.attester ?? null;
|
|
17215
|
-
}
|
|
17216
|
-
catch {
|
|
17217
|
-
return null;
|
|
17218
|
-
}
|
|
17219
|
-
}
|
|
17220
|
-
return null;
|
|
17221
|
-
}
|
|
17222
|
-
/**
|
|
17223
|
-
* Checks if the current user owns the item (publisher is in owned addresses).
|
|
17224
|
-
* Locally created items (no publisher, no attestationRaw) are considered owned.
|
|
17225
|
-
* Includes getAdditionalSyncAddresses (e.g. `modularAccountModuleContract` when configured)
|
|
17226
|
-
* so ownership aligns with EAS sync when the publisher/attester matches those addresses.
|
|
17227
|
-
*/
|
|
17228
|
-
async function isItemOwned(item) {
|
|
17229
|
-
const row = await getSeedRowForItem(item);
|
|
17230
|
-
if (!row)
|
|
17231
|
-
return false;
|
|
17232
|
-
const publisher = resolvePublisherFromSeedRow(row);
|
|
17233
|
-
if (!publisher) {
|
|
17234
|
-
if (!row.uid && !row.attestationRaw) {
|
|
17235
|
-
return true;
|
|
17236
|
-
}
|
|
17237
|
-
return false;
|
|
17238
|
-
}
|
|
17239
|
-
let addressesToCheck = await getOwnedAddressesFromDb();
|
|
17240
|
-
const ownedSet = new Set(addressesToCheck.map((a) => a.toLowerCase()));
|
|
17241
|
-
return ownedSet.has(publisher.toLowerCase());
|
|
17242
|
-
}
|
|
17243
|
-
/**
|
|
17244
|
-
* Throws if the item is not owned. Use before write operations (publish, save, destroy).
|
|
17245
|
-
*/
|
|
17246
|
-
async function assertItemOwned(item) {
|
|
17247
|
-
const owned = await isItemOwned(item);
|
|
17248
|
-
if (!owned) {
|
|
17249
|
-
throw new Error(READ_ONLY_ERROR);
|
|
17250
|
-
}
|
|
17251
|
-
}
|
|
17252
|
-
|
|
17253
|
-
var ownership = /*#__PURE__*/Object.freeze({
|
|
17254
|
-
__proto__: null,
|
|
17255
|
-
assertItemOwned: assertItemOwned,
|
|
17256
|
-
isItemOwned: isItemOwned,
|
|
17257
|
-
resolvePublisherFromSeedRow: resolvePublisherFromSeedRow
|
|
17258
|
-
});
|
|
17259
|
-
|
|
17260
|
-
const emptyResult = () => ({
|
|
17331
|
+
const emptyResult$1 = () => ({
|
|
17261
17332
|
removedSeedLocalIds: [],
|
|
17262
17333
|
removedSeedUids: [],
|
|
17263
17334
|
});
|
|
@@ -17275,11 +17346,11 @@ function normalizeAddresses(addresses) {
|
|
|
17275
17346
|
async function findLocalOnchainCopiesForAddresses(addresses) {
|
|
17276
17347
|
const normalized = normalizeAddresses(addresses);
|
|
17277
17348
|
if (normalized.length === 0) {
|
|
17278
|
-
return emptyResult();
|
|
17349
|
+
return emptyResult$1();
|
|
17279
17350
|
}
|
|
17280
17351
|
const appDb = BaseDb.getAppDb();
|
|
17281
17352
|
if (!appDb) {
|
|
17282
|
-
return emptyResult();
|
|
17353
|
+
return emptyResult$1();
|
|
17283
17354
|
}
|
|
17284
17355
|
const addressSet = new Set(normalized);
|
|
17285
17356
|
const candidateRows = (await appDb
|
|
@@ -17328,6 +17399,57 @@ async function hardDeleteLocalSeedsByLocalIds(seedLocalIds) {
|
|
|
17328
17399
|
await appDb.delete(seeds).where(drizzleOrm.inArray(seeds.localId, seedLocalIds));
|
|
17329
17400
|
}
|
|
17330
17401
|
|
|
17402
|
+
const emptyResult = () => ({
|
|
17403
|
+
seeds: 0,
|
|
17404
|
+
versions: 0,
|
|
17405
|
+
metadata: 0,
|
|
17406
|
+
});
|
|
17407
|
+
/**
|
|
17408
|
+
* Stamp local seeds/versions/metadata that have no publisher and no real uid.
|
|
17409
|
+
* Does not touch sealed rows (real EAS uid or attestationRaw).
|
|
17410
|
+
*/
|
|
17411
|
+
async function claimUnpublishedDrafts(publisher) {
|
|
17412
|
+
const normalized = normalizePublisher(publisher);
|
|
17413
|
+
if (!normalized)
|
|
17414
|
+
return emptyResult();
|
|
17415
|
+
const appDb = BaseDb.getAppDb();
|
|
17416
|
+
if (!appDb)
|
|
17417
|
+
return emptyResult();
|
|
17418
|
+
const now = Date.now();
|
|
17419
|
+
const claimTable = async (table) => {
|
|
17420
|
+
const rows = (await appDb
|
|
17421
|
+
.select({
|
|
17422
|
+
localId: table.localId,
|
|
17423
|
+
uid: table.uid,
|
|
17424
|
+
publisher: table.publisher,
|
|
17425
|
+
attestationRaw: table.attestationRaw,
|
|
17426
|
+
})
|
|
17427
|
+
.from(table));
|
|
17428
|
+
const ids = rows
|
|
17429
|
+
.filter((row) => typeof row.localId === 'string' &&
|
|
17430
|
+
row.localId !== '' &&
|
|
17431
|
+
isLocalUnsealedDraft(row))
|
|
17432
|
+
.map((row) => row.localId);
|
|
17433
|
+
if (ids.length === 0)
|
|
17434
|
+
return 0;
|
|
17435
|
+
await appDb
|
|
17436
|
+
.update(table)
|
|
17437
|
+
.set({ publisher: normalized, updatedAt: now })
|
|
17438
|
+
.where(drizzleOrm.inArray(table.localId, ids));
|
|
17439
|
+
return ids.length;
|
|
17440
|
+
};
|
|
17441
|
+
const [seedCount, versionCount, metadataCount] = await Promise.all([
|
|
17442
|
+
claimTable(seeds),
|
|
17443
|
+
claimTable(versions),
|
|
17444
|
+
claimTable(metadata$1),
|
|
17445
|
+
]);
|
|
17446
|
+
return {
|
|
17447
|
+
seeds: seedCount,
|
|
17448
|
+
versions: versionCount,
|
|
17449
|
+
metadata: metadataCount,
|
|
17450
|
+
};
|
|
17451
|
+
}
|
|
17452
|
+
|
|
17331
17453
|
const logger$3 = debug('seedSdk:client');
|
|
17332
17454
|
const clientManager = xstate.createActor(clientManagerMachine, {
|
|
17333
17455
|
input: {
|
|
@@ -17456,6 +17578,15 @@ const clientInstance = {
|
|
|
17456
17578
|
ensureInitialized();
|
|
17457
17579
|
return getWatchedAddressesFromDb();
|
|
17458
17580
|
},
|
|
17581
|
+
/**
|
|
17582
|
+
* Stamp local seeds/versions/metadata that have no publisher and no real uid.
|
|
17583
|
+
* Sealed rows (real EAS uid or attestationRaw) are left unchanged.
|
|
17584
|
+
* Use after `setAddresses` on connect; `setPublishWallet` does this automatically.
|
|
17585
|
+
*/
|
|
17586
|
+
claimUnpublishedDrafts: async (publisher) => {
|
|
17587
|
+
ensureInitialized();
|
|
17588
|
+
return claimUnpublishedDrafts(publisher);
|
|
17589
|
+
},
|
|
17459
17590
|
/**
|
|
17460
17591
|
* Hard-delete local on-chain seed copies for the given publisher addresses.
|
|
17461
17592
|
* Drafts (no uid / attestationRaw) are kept. Chain is untouched; reconnect can rehydrate via syncFromEas.
|
|
@@ -17706,7 +17837,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
|
|
|
17706
17837
|
// Lazy import cache for ModelProperty to avoid circular dependency
|
|
17707
17838
|
// Eagerly start loading to minimize delay on first access
|
|
17708
17839
|
let ModelPropertyClass = null;
|
|
17709
|
-
const modelPropertyImportPromise = Promise.resolve().then(function () { return require('./ModelProperty-
|
|
17840
|
+
const modelPropertyImportPromise = Promise.resolve().then(function () { return require('./ModelProperty-DvIIhBnK.js'); })
|
|
17710
17841
|
.then(module => {
|
|
17711
17842
|
ModelPropertyClass = module.ModelProperty;
|
|
17712
17843
|
return ModelPropertyClass;
|
|
@@ -17723,7 +17854,7 @@ function getModelProperty() {
|
|
|
17723
17854
|
}
|
|
17724
17855
|
// Lazy import cache for Schema to avoid circular dependency
|
|
17725
17856
|
let SchemaClass = null;
|
|
17726
|
-
const schemaImportPromise = Promise.resolve().then(function () { return require('./Schema-
|
|
17857
|
+
const schemaImportPromise = Promise.resolve().then(function () { return require('./Schema-FdzNqyGo.js'); })
|
|
17727
17858
|
.then(module => {
|
|
17728
17859
|
SchemaClass = module.Schema;
|
|
17729
17860
|
return SchemaClass;
|
|
@@ -18181,37 +18312,25 @@ class Model {
|
|
|
18181
18312
|
getOwnPropertyDescriptor(target, prop) {
|
|
18182
18313
|
// Handle 'name' as an alias for 'modelName'
|
|
18183
18314
|
if (prop === 'name') {
|
|
18184
|
-
|
|
18185
|
-
|
|
18186
|
-
|
|
18187
|
-
configurable: true,
|
|
18188
|
-
value: context.modelName,
|
|
18189
|
-
writable: true,
|
|
18190
|
-
};
|
|
18315
|
+
return getInvariantSafePropertyDescriptor(target, prop, {
|
|
18316
|
+
value: target._getSnapshotContext().modelName,
|
|
18317
|
+
});
|
|
18191
18318
|
}
|
|
18192
18319
|
// Handle 'id' property - returns the modelFileId
|
|
18193
18320
|
if (prop === 'id') {
|
|
18194
|
-
|
|
18195
|
-
|
|
18196
|
-
enumerable: true,
|
|
18197
|
-
configurable: true,
|
|
18198
|
-
value: context.id, // id is now the schemaFileId (string)
|
|
18321
|
+
return getInvariantSafePropertyDescriptor(target, prop, {
|
|
18322
|
+
value: target._getSnapshotContext().id, // id is now the schemaFileId (string)
|
|
18199
18323
|
writable: false, // id is read-only
|
|
18200
|
-
};
|
|
18324
|
+
});
|
|
18201
18325
|
}
|
|
18202
|
-
|
|
18326
|
+
let invent;
|
|
18203
18327
|
if (typeof prop === 'string' && TRACKED_PROPERTIES.includes(prop)) {
|
|
18204
18328
|
const context = target._getSnapshotContext();
|
|
18205
18329
|
if (prop in context) {
|
|
18206
|
-
|
|
18207
|
-
enumerable: true,
|
|
18208
|
-
configurable: true,
|
|
18209
|
-
value: context[prop],
|
|
18210
|
-
writable: true,
|
|
18211
|
-
};
|
|
18330
|
+
invent = { value: context[prop] };
|
|
18212
18331
|
}
|
|
18213
18332
|
}
|
|
18214
|
-
return
|
|
18333
|
+
return getInvariantSafePropertyDescriptor(target, prop, invent);
|
|
18215
18334
|
},
|
|
18216
18335
|
});
|
|
18217
18336
|
// Step 8: Store in new ID-based cache
|
|
@@ -19488,6 +19607,15 @@ class NodeFileManager {
|
|
|
19488
19607
|
async pathExists(filePath) {
|
|
19489
19608
|
return await fsAsync__namespace.access(filePath).then(() => true).catch(() => false);
|
|
19490
19609
|
}
|
|
19610
|
+
async getFileSize(filePath) {
|
|
19611
|
+
try {
|
|
19612
|
+
const stat = await fsAsync__namespace.stat(filePath);
|
|
19613
|
+
return stat.size;
|
|
19614
|
+
}
|
|
19615
|
+
catch {
|
|
19616
|
+
return null;
|
|
19617
|
+
}
|
|
19618
|
+
}
|
|
19491
19619
|
async listImageFiles() {
|
|
19492
19620
|
return this.listFiles('images');
|
|
19493
19621
|
}
|
|
@@ -19628,7 +19756,7 @@ function resolveSdkDrizzleMigrationsDir(sdkRootDir) {
|
|
|
19628
19756
|
})();
|
|
19629
19757
|
// Also resolve relative to this module so temp-cwd tests / odd roots still find
|
|
19630
19758
|
// packages/sdk/src/db/drizzle (or dist/db/drizzle after publish).
|
|
19631
|
-
const moduleDir = path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs/index-
|
|
19759
|
+
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-C-POwaLs.js', document.baseURI).href))));
|
|
19632
19760
|
const candidates = [
|
|
19633
19761
|
path.join(root, 'db', 'drizzle'), // production: sdkRoot is dist/
|
|
19634
19762
|
path.join(root, 'dist', 'db', 'drizzle'), // sdk package root with built dist
|
|
@@ -19698,7 +19826,7 @@ class NodeDb {
|
|
|
19698
19826
|
logger$1('[Db.prepareDb] running migrations from %s', outDir);
|
|
19699
19827
|
await migrator.migrate(db, { migrationsFolder: outDir });
|
|
19700
19828
|
this.db = db;
|
|
19701
|
-
const { backfillMetadataPropertyIds } = await Promise.resolve().then(function () { return require('./backfillMetadataPropertyIds
|
|
19829
|
+
const { backfillMetadataPropertyIds } = await Promise.resolve().then(function () { return require('./backfillMetadataPropertyIds-D0o5VwBh.js'); });
|
|
19702
19830
|
await backfillMetadataPropertyIds();
|
|
19703
19831
|
return this.db;
|
|
19704
19832
|
}
|
|
@@ -20263,6 +20391,8 @@ exports.modelSchemas = modelSchemas;
|
|
|
20263
20391
|
exports.modelUids = modelUids;
|
|
20264
20392
|
exports.models = models$1;
|
|
20265
20393
|
exports.normalizeDataType = normalizeDataType;
|
|
20394
|
+
exports.normalizeHexAddress = normalizeHexAddress;
|
|
20395
|
+
exports.normalizePublisher = normalizePublisher;
|
|
20266
20396
|
exports.parseListPropertyValueFromStorage = parseListPropertyValueFromStorage;
|
|
20267
20397
|
exports.parseMarkdownFrontmatter = parseMarkdownFrontmatter;
|
|
20268
20398
|
exports.processSeedConfig = processSeedConfig;
|
|
@@ -20287,4 +20417,4 @@ exports.versions = versions;
|
|
|
20287
20417
|
exports.waitForEntityIdle = waitForEntityIdle;
|
|
20288
20418
|
exports.withSeed = withSeed;
|
|
20289
20419
|
exports.writeProcessMachine = writeProcessMachine;
|
|
20290
|
-
//# sourceMappingURL=index-
|
|
20420
|
+
//# sourceMappingURL=index-C-POwaLs.js.map
|