@seedprotocol/sdk 0.7.10 → 0.7.11-next.1384.g8b47246
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/README.md +1 -1
- package/dist/{Item-oPnmIehk.js → Item-Ld1iPicQ.js} +2051 -412
- package/dist/Item-Ld1iPicQ.js.map +1 -0
- package/dist/{ModelProperty-D2vJozmW.js → ModelProperty-C8gTx4pO.js} +32 -33
- package/dist/ModelProperty-C8gTx4pO.js.map +1 -0
- package/dist/{Schema-BMXRF4j9.js → Schema-BzeBUZxi.js} +19 -19
- package/dist/{Schema-BMXRF4j9.js.map → Schema-BzeBUZxi.js.map} +1 -1
- package/dist/{SchemaValidationService-CieGrj5c.js → SchemaValidationService-CW0s7V7R.js} +5 -6
- package/dist/{SchemaValidationService-CieGrj5c.js.map → SchemaValidationService-CW0s7V7R.js.map} +1 -1
- package/dist/arweaveContentTags-Bh4wCTal.js +51 -0
- package/dist/arweaveContentTags-Bh4wCTal.js.map +1 -0
- package/dist/dist/{index.node-BfiBriEq.d.ts → index.node-DV1OXCp0.d.ts} +25 -29
- package/dist/dist/{index.node-BfiBriEq.d.ts.map → index.node-DV1OXCp0.d.ts.map} +1 -1
- package/dist/dist/platform.node.d.ts +1 -1
- package/dist/download-Cvac_VGu.js +394 -0
- package/dist/download-Cvac_VGu.js.map +1 -0
- package/dist/{eas-FZPPqxqe.js → eas-CdhfODXL.js} +10 -11
- package/dist/{eas-FZPPqxqe.js.map → eas-CdhfODXL.js.map} +1 -1
- package/dist/ensureImageLocal-DNM6c2yD.js +176 -0
- package/dist/ensureImageLocal-DNM6c2yD.js.map +1 -0
- package/dist/{errors-CnT0fSMK.js → errors-DKxFSvb3.js} +179 -87
- package/dist/errors-DKxFSvb3.js.map +1 -0
- package/dist/{getPublishPayload-DKuEaq96.js → getPublishPayload-CLrAcZwr.js} +7 -7
- package/dist/{getPublishPayload-DKuEaq96.js.map → getPublishPayload-CLrAcZwr.js.map} +1 -1
- package/dist/{getPublishPendingDiff-CH5xLMjU.js → getPublishPendingDiff-DiPff8pS.js} +12 -13
- package/dist/{getPublishPendingDiff-CH5xLMjU.js.map → getPublishPendingDiff-DiPff8pS.js.map} +1 -1
- package/dist/{getPublishUploads-DivYpgNw.js → getPublishUploads-DFcgc27c.js} +6 -5
- package/dist/{getPublishUploads-DivYpgNw.js.map → getPublishUploads-DFcgc27c.js.map} +1 -1
- package/dist/index-9udoYObJ.js +25 -0
- package/dist/index-9udoYObJ.js.map +1 -0
- package/dist/{index-Gh42_47r.js → index-Cdm7Q7el.js} +17 -15
- package/dist/index-Cdm7Q7el.js.map +1 -0
- package/dist/{index-DXRhFg1N.js → index-CghAYA-z.js} +6 -7
- package/dist/index-CghAYA-z.js.map +1 -0
- package/dist/{index.browser-DQstVvRV.js → index.browser-D9oC-KKx.js} +41 -40
- package/dist/index.browser-D9oC-KKx.js.map +1 -0
- package/dist/{index.node-BfiBriEq.js → index.node-DV1OXCp0.js} +7 -31
- package/dist/index.node-DV1OXCp0.js.map +1 -0
- package/dist/main.js +19 -16
- package/dist/main.js.map +1 -1
- package/dist/{modelPropertyRecordSchemas-DEe-lYhn.js → modelPropertyRecordSchemas-se4QMXSi.js} +9 -12
- package/dist/{modelPropertyRecordSchemas-DEe-lYhn.js.map → modelPropertyRecordSchemas-se4QMXSi.js.map} +1 -1
- package/dist/node.js +6 -7
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +7 -8
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.node.js +1 -1
- package/dist/{property-iNW1N3vm.js → property-Broz_CWj.js} +8 -11
- package/dist/property-Broz_CWj.js.map +1 -0
- package/dist/{publishGraph-CRn_N3NT.js → publishGraph-DnWoWZRP.js} +4 -4
- package/dist/{publishGraph-CRn_N3NT.js.map → publishGraph-DnWoWZRP.js.map} +1 -1
- package/dist/{readHtmlBodyForStorageSeed-B7HgPmq6.js → readHtmlBodyForStorageSeed-FvwYPn4m.js} +9 -11
- package/dist/{readHtmlBodyForStorageSeed-B7HgPmq6.js.map → readHtmlBodyForStorageSeed-FvwYPn4m.js.map} +1 -1
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/initialize.d.ts.map +1 -1
- package/dist/src/Model/index.d.ts +0 -2
- package/dist/src/Model/index.d.ts.map +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts +1 -3
- package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/browser/workers/FileDownloader.d.ts +1 -0
- package/dist/src/browser/workers/FileDownloader.d.ts.map +1 -1
- package/dist/src/browser/workers/ImageResizer.d.ts +1 -0
- package/dist/src/browser/workers/ImageResizer.d.ts.map +1 -1
- package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
- package/dist/src/client/actors/saveAppState.d.ts.map +1 -1
- package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/src/db/read/metadataProperty.d.ts +1 -1
- package/dist/src/db/read/metadataProperty.d.ts.map +1 -1
- package/dist/src/db/read/resolveModelRecord.d.ts +0 -20
- package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -1
- package/dist/src/db/write/createMetadata.d.ts +1 -8
- package/dist/src/db/write/createMetadata.d.ts.map +1 -1
- package/dist/src/db/write/removeLocalCopiesForAddresses.d.ts +0 -5
- package/dist/src/db/write/removeLocalCopiesForAddresses.d.ts.map +1 -1
- package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
- package/dist/src/events/files/download.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/helpers/easPropertyCanonical.d.ts +1 -1
- package/dist/src/helpers/easPropertyCanonical.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityLifecycle.d.ts +0 -2
- package/dist/src/helpers/entity/entityLifecycle.d.ts.map +1 -1
- package/dist/src/helpers/environment.d.ts +0 -13
- package/dist/src/helpers/environment.d.ts.map +1 -1
- package/dist/src/helpers/index.d.ts +0 -4
- package/dist/src/helpers/index.d.ts.map +1 -1
- package/dist/src/helpers/itemStorageFile.d.ts +0 -11
- package/dist/src/helpers/itemStorageFile.d.ts.map +1 -1
- package/dist/src/helpers/propertySchemaUid.d.ts +7 -5
- package/dist/src/helpers/propertySchemaUid.d.ts.map +1 -1
- package/dist/src/helpers/storageDir.d.ts +0 -2
- package/dist/src/helpers/storageDir.d.ts.map +1 -1
- package/dist/src/node/db/Db.d.ts +0 -2
- package/dist/src/node/db/Db.d.ts.map +1 -1
- package/dist/src/node/helpers/FileManager.d.ts +0 -2
- package/dist/src/node/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/node/index.d.ts +2 -2
- package/dist/src/node/index.d.ts.map +1 -1
- package/dist/src/outbox/index.d.ts +5 -5
- package/dist/src/outbox/index.d.ts.map +1 -1
- package/dist/{syncDbWithEas-FuyqoEKk.js → syncDbWithEas-Dj_8VqM7.js} +24 -23
- package/dist/syncDbWithEas-Dj_8VqM7.js.map +1 -0
- package/dist/tabEvents-BnBzIdEi.js +1408 -0
- package/dist/tabEvents-BnBzIdEi.js.map +1 -0
- package/dist/{tolerantWebAccess-zEseJ2zT.js → tolerantWebAccess-CNfvmR3m.js} +8 -9
- package/dist/{tolerantWebAccess-zEseJ2zT.js.map → tolerantWebAccess-CNfvmR3m.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-B9JRwr5T.js → updateSeedRevokedAt-D-3SLW-D.js} +3 -2
- package/dist/{updateSeedRevokedAt-B9JRwr5T.js.map → updateSeedRevokedAt-D-3SLW-D.js.map} +1 -1
- package/package.json +7 -12
- package/dist/Item-oPnmIehk.js.map +0 -1
- package/dist/ModelProperty-D2vJozmW.js.map +0 -1
- package/dist/errors-CnT0fSMK.js.map +0 -1
- package/dist/index-CZMWKXLM.js +0 -27
- package/dist/index-CZMWKXLM.js.map +0 -1
- package/dist/index-DXRhFg1N.js.map +0 -1
- package/dist/index-Gh42_47r.js.map +0 -1
- package/dist/index.browser-DQstVvRV.js.map +0 -1
- package/dist/index.node-BfiBriEq.js.map +0 -1
- package/dist/property-iNW1N3vm.js.map +0 -1
- package/dist/src/db/read/getItemProperty.d.ts +0 -6
- package/dist/src/db/read/getItemProperty.d.ts.map +0 -1
- package/dist/src/db/read/isSeedRevoked.d.ts +0 -7
- package/dist/src/db/read/isSeedRevoked.d.ts.map +0 -1
- package/dist/src/db/write/saveMetadata.d.ts +0 -3
- package/dist/src/db/write/saveMetadata.d.ts.map +0 -1
- package/dist/src/db/write/updateMetadata.d.ts +0 -13
- package/dist/src/db/write/updateMetadata.d.ts.map +0 -1
- package/dist/src/types/fileManager.d.ts +0 -13
- package/dist/src/types/fileManager.d.ts.map +0 -1
- package/dist/syncDbWithEas-FuyqoEKk.js.map +0 -1
- package/dist/tabEvents-DT5ez6io.js +0 -3830
- package/dist/tabEvents-DT5ez6io.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { fromCallback, setup, assign, createActor, waitFor, fromPromise } from 'xstate';
|
|
2
|
-
import {
|
|
2
|
+
import { aE as isActorStopped, X as applyContextUpdate, Y as isInternalUpdate, aF as differsFromOriginals, bm as writeModelToDb, bn as writePropertyToDb, a0 as isEntityTornDown, aI as onEntityTeardown, Z as evictionLog, a1 as sameEntity, a2 as DEFAULT_READY_TIMEOUT_MS, a3 as createReactiveProxy, a4 as runEntityLoad, a5 as waitForEntityReady, A as AmbiguousModelError, a7 as EntityUnloadedError, a8 as entityStatus, I as Item, a6 as evictEntities, aa as releaseEntity, ab as destroyEntity, bo as currentNameMatchLevels, bp as renameModelInDb, ap as modelPropertiesToObject, af as EntityCache, ac as isClientReady, aV as MachineIds, b8 as normalizeAddressConfig, ao as nameMatchLevels, aj as loadNameMatchLevels, a9 as inDefinitionsTransaction, bq as insertModelStubs, b9 as normalizeAddressList, br as warnOnInvalidNameMatch, ad as upsertSchemaRow, bs as refreshCachedProperties, ar as easPropertyNameForPublish, H as findSeedRow, ag as normalizePublisher, aT as resolvePublisherFromSeedRow, az as matchMetadataProperty, aA as metadataRowsOfProperty, aB as METADATA_LATEST_FIRST_ORDER_SQL, bt as resolveMetadataProperty, as as metadataStorageName, bu as lookupPropertySchemaUid, U as getItemStorageSubdir, ay as getItemStorageLocalFileName, bv as deleteStagedFile, bw as storageFileName, bx as STORAGE_SUBDIR, by as resolveNewSeedFields, bz as stageStorageContent, bA as requireStagedFile, r as registerOutboxApplier, k as outboxOpValue, bB as findSetConflict, bC as recordPropertyEdit, d as OutboxOpDeferredError, bD as startOutbox, e as OutboxOpFailedError, q as OwnershipError, u as isItemOwned, D as compareMetadataRowsLatestFirst, bE as createSeed, bF as storageValueRowOf, P as getLatestVersionRow, S as parseListPropertyValueFromStorage, aU as ClientManagerState, bG as ClientManagerEvents, b5 as isLocalUnsealedDraft, T as writeInBatches, an as selectInBatches, bH as getWatchedAddressesFromDb, bI as getOwnedAddressesFromDb, bJ as setEntityUnloadGraceMs, bK as stopOutbox, bL as evictAllEntities, bM as registerClientActor } from './Item-Ld1iPicQ.js';
|
|
3
3
|
import debug from 'debug';
|
|
4
4
|
import { B as BaseDb, l as properties, d as models$1, j as modelSchemas, t as schemas, f as easSyncProcesses, a as appState, w as BaseFileManager, b as modelUids, s as seeds, v as versions, m as metadata$1, p as pendingWrites, h as htmlEmbeddedImageCoPublish, e as arweaveL1FinalizeJobs, r as publishProcesses } from './BaseFileManager-DLou1TZS.js';
|
|
5
|
-
import { aI as writeModelToDb, aJ as writePropertyToDb, m as generateId, p as isInternalSchema, A as AmbiguousModelError, aK as currentNameMatchLevels, aL as renameModelInDb, s as isClientReady, a as TProperty, ay as withDbTabLock, af as MachineIds, ap as isLeaderTab, aM as postTabMessage, aN as onTabMessage, ax as whenLeaderTab, aO as listenForOtherTabsEvents, F as isBrowser, $ as isNode, aP as startTabCoordination, aq as normalizeAddressConfig, aQ as isTestOrSeedDev, L as nameMatchLevels, C as loadNameMatchLevels, aD as withSeedDbLock, q as inDefinitionsTransaction, aR as insertModelStubs, G as emitAcrossTabs, a8 as ADDRESSES_PERSISTED_EVENT, ar as normalizeAddressList, aS as warnOnInvalidNameMatch, u as upsertSchemaRow, aT as refreshCachedProperties, g as normalizePropertyRecordSchema, M as ModelPropertyDataTypes, j as findSeedRow, aU as tryWithTabLock, Y as getItemStorageSubdir, _ as getItemStorageLocalFileName, aV as notifyFileSaved, ad as ImageSize, n as normalizeDataType, ab as ClientManagerState, aW as ClientManagerEvents, at as parseAddressesPersistedPayload, x as normalizePublisher, w as writeInBatches, K as selectInBatches, ae as LOCAL_COPIES_REMOVED_EVENT, aX as getWatchedAddressesFromDb, aY as getOwnedAddressesFromDb, aZ as CLIENT_NOT_INITIALIZED, a_ as stopTabCoordination, a$ as registerClientActor } from './tabEvents-DT5ez6io.js';
|
|
6
5
|
import { seedGatewayConfigFromSeedConfig, setPreferredArweaveReadBaseUrls, resolveSeedGatewayEndpoints, setResolvedSeedGatewayEndpoints, BaseArweaveClient, ensureReadGatewaySelected, DEFAULT_ARWEAVE_HOST } from '@seedprotocol/arweave';
|
|
7
6
|
import 'pluralize';
|
|
8
7
|
import { localNamesInBestMatchTier, configureEasReadChain, matchEasModelSchemas, whenEasReadChainSettled, getEasReadChainId, DEFAULT_EAS_CHAIN_ID, isEasReadChainConfigured, easName, isValidEasAttestationUid } from '@seedprotocol/eas';
|
|
8
|
+
import { k as generateId, l as isInternalSchema, a as TProperty, N as withDbTabLock, C as isLeaderTab, a0 as postTabMessage, a1 as onTabMessage, K as whenLeaderTab, a2 as listenForOtherTabsEvents, o as isBrowser, u as isNode, a3 as startTabCoordination, W as withSeedDbLock, p as emitAcrossTabs, A as ADDRESSES_PERSISTED_EVENT, g as normalizePropertyRecordSchema, M as ModelPropertyDataTypes, n as normalizeDataType, a4 as tryWithTabLock, a5 as notifyFileSaved, I as ImageSize, G as parseAddressesPersistedPayload, L as LOCAL_COPIES_REMOVED_EVENT, a6 as CLIENT_NOT_INITIALIZED, a7 as stopTabCoordination } from './tabEvents-BnBzIdEi.js';
|
|
9
9
|
import { eq, and, isNull, or, inArray, isNotNull, ne, desc, count, sql, like } from 'drizzle-orm';
|
|
10
10
|
import { Type } from '@sinclair/typebox';
|
|
11
11
|
import { isEqual } from 'lodash-es';
|
|
@@ -36,10 +36,10 @@ const validateModel = fromCallback(({ sendBack, input: { context }, self }) => {
|
|
|
36
36
|
const _validateModel = async () => {
|
|
37
37
|
try {
|
|
38
38
|
// Use dynamic imports to break circular dependencies
|
|
39
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
39
|
+
const validationServiceMod = await import('./SchemaValidationService-CW0s7V7R.js');
|
|
40
40
|
const { SchemaValidationService } = validationServiceMod;
|
|
41
41
|
const validationService = new SchemaValidationService();
|
|
42
|
-
const _mod_0 = await import('./Schema-
|
|
42
|
+
const _mod_0 = await import('./Schema-BzeBUZxi.js');
|
|
43
43
|
const _ns_0 = _mod_0.a;
|
|
44
44
|
const schemaMod = _ns_0;
|
|
45
45
|
const { Schema } = schemaMod;
|
|
@@ -320,7 +320,7 @@ async function createModelProperties(model, propertyDefinitions) {
|
|
|
320
320
|
throw new Error('Model ID, file ID, and name are required to create properties');
|
|
321
321
|
}
|
|
322
322
|
logger$f(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
|
|
323
|
-
const { ModelProperty } = await import('./ModelProperty-
|
|
323
|
+
const { ModelProperty } = await import('./ModelProperty-C8gTx4pO.js');
|
|
324
324
|
const { and, eq } = await import('drizzle-orm');
|
|
325
325
|
const db = BaseDb.getAppDb();
|
|
326
326
|
for (const [propName, propData] of Object.entries(propertyDefinitions)) {
|
|
@@ -338,8 +338,8 @@ async function createModelProperties(model, propertyDefinitions) {
|
|
|
338
338
|
: undefined;
|
|
339
339
|
// Otherwise use provided ID or generate a random one
|
|
340
340
|
// IDs should be generated in the import process before creating properties
|
|
341
|
-
const _mod_1 = await import('./tabEvents-
|
|
342
|
-
const _ns_1 = _mod_1.
|
|
341
|
+
const _mod_1 = await import('./tabEvents-BnBzIdEi.js');
|
|
342
|
+
const _ns_1 = _mod_1.ak;
|
|
343
343
|
const { generateId } = _ns_1;
|
|
344
344
|
const propertyFileId = propData.id || propertyRecord?.schemaFileId || generateId();
|
|
345
345
|
logger$f(`Creating property "${propName}" with fileId "${propertyFileId}"`);
|
|
@@ -356,8 +356,8 @@ async function createModelProperties(model, propertyDefinitions) {
|
|
|
356
356
|
}
|
|
357
357
|
else if (refModelName) {
|
|
358
358
|
// Fallback: resolve the ref by name within this model's schema
|
|
359
|
-
const _mod_2 = await import('./
|
|
360
|
-
const _ns_2 = _mod_2.
|
|
359
|
+
const _mod_2 = await import('./Item-Ld1iPicQ.js');
|
|
360
|
+
const _ns_2 = _mod_2.bO;
|
|
361
361
|
const { resolveModelRecord } = _ns_2;
|
|
362
362
|
const refModelRecord = await resolveModelRecord(refModelName, { schemaName }, db);
|
|
363
363
|
if (refModelRecord?.id) {
|
|
@@ -452,7 +452,7 @@ const write = async (input) => {
|
|
|
452
452
|
});
|
|
453
453
|
}
|
|
454
454
|
// Imported here: the validation service imports the Schema barrel, which imports this module's callers
|
|
455
|
-
const { SchemaValidationService } = await import('./SchemaValidationService-
|
|
455
|
+
const { SchemaValidationService } = await import('./SchemaValidationService-CW0s7V7R.js');
|
|
456
456
|
const data = input.data();
|
|
457
457
|
const { errors } = new SchemaValidationService().validatePropertyStructure(data);
|
|
458
458
|
if (errors.length > 0) {
|
|
@@ -613,7 +613,7 @@ const createPropertyInstances = async (propertyFileIds, since) => {
|
|
|
613
613
|
return;
|
|
614
614
|
}
|
|
615
615
|
try {
|
|
616
|
-
const mod = await import('./ModelProperty-
|
|
616
|
+
const mod = await import('./ModelProperty-C8gTx4pO.js');
|
|
617
617
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
618
618
|
if (!ModelProperty) {
|
|
619
619
|
logger$d('createPropertyInstances: ModelProperty not available from dynamic import');
|
|
@@ -827,7 +827,7 @@ async function loadModel(context, isStopped) {
|
|
|
827
827
|
// Step 2: Fallback to Schema context (only if database doesn't have the model)
|
|
828
828
|
// This handles the case where model exists in schema file but not yet in database
|
|
829
829
|
try {
|
|
830
|
-
const _mod_5 = await import('./Schema-
|
|
830
|
+
const _mod_5 = await import('./Schema-BzeBUZxi.js');
|
|
831
831
|
const _ns_5 = _mod_5.a;
|
|
832
832
|
const { Schema } = _ns_5;
|
|
833
833
|
// Stopped meanwhile (unloaded, or evicted with its schema): don't load the schema again
|
|
@@ -995,7 +995,7 @@ async function loadModel(context, isStopped) {
|
|
|
995
995
|
}
|
|
996
996
|
// Mark schema as draft when a new model is created so saveNewVersion() can persist it
|
|
997
997
|
try {
|
|
998
|
-
const _mod_8 = await import('./Schema-
|
|
998
|
+
const _mod_8 = await import('./Schema-BzeBUZxi.js');
|
|
999
999
|
const _ns_8 = _mod_8.a;
|
|
1000
1000
|
const { Schema } = _ns_8;
|
|
1001
1001
|
if (!isStopped()) {
|
|
@@ -1089,7 +1089,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
|
|
|
1089
1089
|
// Lazy import cache for ModelProperty to avoid circular dependency
|
|
1090
1090
|
// Eagerly start loading to minimize delay on first access
|
|
1091
1091
|
let ModelPropertyClass = null;
|
|
1092
|
-
const modelPropertyImportPromise = import('./ModelProperty-
|
|
1092
|
+
const modelPropertyImportPromise = import('./ModelProperty-C8gTx4pO.js')
|
|
1093
1093
|
.then(module => {
|
|
1094
1094
|
ModelPropertyClass = module.ModelProperty;
|
|
1095
1095
|
return ModelPropertyClass;
|
|
@@ -1598,8 +1598,8 @@ class Model {
|
|
|
1598
1598
|
if (db) {
|
|
1599
1599
|
const since = evictionLog.now();
|
|
1600
1600
|
try {
|
|
1601
|
-
const _mod_9 = await import('./
|
|
1602
|
-
const _ns_9 = _mod_9.
|
|
1601
|
+
const _mod_9 = await import('./Item-Ld1iPicQ.js');
|
|
1602
|
+
const _ns_9 = _mod_9.bO;
|
|
1603
1603
|
const { resolveModelRecord, getModelSchemaName } = _ns_9;
|
|
1604
1604
|
const resolved = scope.modelFileId
|
|
1605
1605
|
? await resolveModelRecord(undefined, { modelFileId: scope.modelFileId }, db)
|
|
@@ -1645,8 +1645,8 @@ class Model {
|
|
|
1645
1645
|
}
|
|
1646
1646
|
const since = options?.since ?? evictionLog.now();
|
|
1647
1647
|
try {
|
|
1648
|
-
const _mod_10 = await import('./
|
|
1649
|
-
const _ns_10 = _mod_10.
|
|
1648
|
+
const _mod_10 = await import('./Item-Ld1iPicQ.js');
|
|
1649
|
+
const _ns_10 = _mod_10.bO;
|
|
1650
1650
|
const { resolveModelRecord, getModelSchemaName } = _ns_10;
|
|
1651
1651
|
const resolved = await resolveModelRecord(modelName, schemaName ? { schemaName, strict: true } : {}, db);
|
|
1652
1652
|
if (!resolved?.schemaFileId) {
|
|
@@ -2147,8 +2147,8 @@ class Model {
|
|
|
2147
2147
|
if (modelRecord) {
|
|
2148
2148
|
const modelId = modelRecord.id;
|
|
2149
2149
|
const { detachModelRows } = await import('./detachRowsBeforeDelete-BZr_0iZU.js');
|
|
2150
|
-
const _mod_11 = await import('./
|
|
2151
|
-
const _ns_11 = _mod_11.
|
|
2150
|
+
const _mod_11 = await import('./Item-Ld1iPicQ.js');
|
|
2151
|
+
const _ns_11 = _mod_11.bQ;
|
|
2152
2152
|
const { inDefinitionsTransaction } = _ns_11;
|
|
2153
2153
|
// The model's rows go together or not at all
|
|
2154
2154
|
await inDefinitionsTransaction(async (tx) => {
|
|
@@ -2164,7 +2164,7 @@ class Model {
|
|
|
2164
2164
|
getModelProperty()?.evictForModel({ modelName, schemaName, modelId: dbId });
|
|
2165
2165
|
if (schemaName && modelName) {
|
|
2166
2166
|
// Imported here, not at module load: Model and Schema import each other.
|
|
2167
|
-
const _mod_12 = await import('./Schema-
|
|
2167
|
+
const _mod_12 = await import('./Schema-BzeBUZxi.js');
|
|
2168
2168
|
const _ns_12 = _mod_12.a;
|
|
2169
2169
|
const { Schema } = _ns_12;
|
|
2170
2170
|
const schema = await Schema.find({ schemaName, waitForReady: false });
|
|
@@ -2203,8 +2203,8 @@ class Model {
|
|
|
2203
2203
|
return undefined;
|
|
2204
2204
|
}
|
|
2205
2205
|
// Model names are only unique per schema: find this model's row by its id (schemaFileId).
|
|
2206
|
-
const _mod_13 = await import('./
|
|
2207
|
-
const _ns_13 = _mod_13.
|
|
2206
|
+
const _mod_13 = await import('./Item-Ld1iPicQ.js');
|
|
2207
|
+
const _ns_13 = _mod_13.bO;
|
|
2208
2208
|
const { resolveModelRecord } = _ns_13;
|
|
2209
2209
|
const modelRecord = await resolveModelRecord(modelName, { modelFileId: context.id, schemaName: context.schemaName }, db);
|
|
2210
2210
|
if (!modelRecord?.id) {
|
|
@@ -2382,7 +2382,6 @@ var Model$1 = /*#__PURE__*/Object.freeze({
|
|
|
2382
2382
|
});
|
|
2383
2383
|
|
|
2384
2384
|
// Export the Model class
|
|
2385
|
-
const TModelValues = Type.Record(Type.String(), Type.Any());
|
|
2386
2385
|
const TModelSchema = Type.Record(Type.String(), TProperty);
|
|
2387
2386
|
|
|
2388
2387
|
let writeTail = Promise.resolve();
|
|
@@ -2585,7 +2584,7 @@ function toRunSyncArg(options) {
|
|
|
2585
2584
|
return undefined;
|
|
2586
2585
|
}
|
|
2587
2586
|
const runEasSync = fromPromise(async ({ input, }) => {
|
|
2588
|
-
const { runSyncFromEas } = await import('./syncDbWithEas-
|
|
2587
|
+
const { runSyncFromEas } = await import('./syncDbWithEas-Dj_8VqM7.js');
|
|
2589
2588
|
// Sync checks for rows and then inserts the rest (no unique index on uids), so syncs in
|
|
2590
2589
|
// different tabs take turns. A sync can run for minutes, so wait without a timeout.
|
|
2591
2590
|
await withDbTabLock('eas-sync', async () => {
|
|
@@ -3000,11 +2999,6 @@ const saveAppState = fromCallback(({ sendBack, input: { key, value } }) => {
|
|
|
3000
2999
|
try {
|
|
3001
3000
|
const appDb = BaseDb.getAppDb();
|
|
3002
3001
|
if (!appDb) {
|
|
3003
|
-
// In test environments, continue anyway
|
|
3004
|
-
if (isTestOrSeedDev()) {
|
|
3005
|
-
logger$a('[client/actors] [saveAppState] App DB not found, but continuing in test environment');
|
|
3006
|
-
return;
|
|
3007
|
-
}
|
|
3008
3002
|
throw new Error('App DB not found');
|
|
3009
3003
|
}
|
|
3010
3004
|
const result = await appDb.insert(appState)
|
|
@@ -3022,11 +3016,6 @@ const saveAppState = fromCallback(({ sendBack, input: { key, value } }) => {
|
|
|
3022
3016
|
}
|
|
3023
3017
|
catch (error) {
|
|
3024
3018
|
logger$a('[client/actors] [saveAppState] Error saving app state:', error);
|
|
3025
|
-
// In test environments, continue anyway
|
|
3026
|
-
if (isTestOrSeedDev()) {
|
|
3027
|
-
logger$a('[client/actors] [saveAppState] Continuing despite error in test environment');
|
|
3028
|
-
return;
|
|
3029
|
-
}
|
|
3030
3019
|
throw error;
|
|
3031
3020
|
}
|
|
3032
3021
|
};
|
|
@@ -3040,23 +3029,12 @@ const saveAppState = fromCallback(({ sendBack, input: { key, value } }) => {
|
|
|
3040
3029
|
})
|
|
3041
3030
|
.catch((error) => {
|
|
3042
3031
|
logger$a('[client/actors] [saveAppState] Error in promise chain:', error);
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
value,
|
|
3050
|
-
});
|
|
3051
|
-
}
|
|
3052
|
-
else {
|
|
3053
|
-
sendBack({
|
|
3054
|
-
type: 'saveAppStateError',
|
|
3055
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
3056
|
-
key,
|
|
3057
|
-
value,
|
|
3058
|
-
});
|
|
3059
|
-
}
|
|
3032
|
+
sendBack({
|
|
3033
|
+
type: 'saveAppStateError',
|
|
3034
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
3035
|
+
key,
|
|
3036
|
+
value,
|
|
3037
|
+
});
|
|
3060
3038
|
});
|
|
3061
3039
|
});
|
|
3062
3040
|
|
|
@@ -3205,7 +3183,7 @@ async function addModelsToDb(context) {
|
|
|
3205
3183
|
timeout = setTimeout(() => reject(new Error('EAS query timeout after 10 seconds')), 10000);
|
|
3206
3184
|
});
|
|
3207
3185
|
// The lookup and the model_uids rule sync uses too (each name at its nameMatch level).
|
|
3208
|
-
const { getModelSchemasFromEas } = await import('./eas-
|
|
3186
|
+
const { getModelSchemasFromEas } = await import('./eas-CdhfODXL.js');
|
|
3209
3187
|
const lookups = await localModelSchemaLookups([...modelNamesWithRows]);
|
|
3210
3188
|
// Cleared, so a finished lookup doesn't keep a Node process alive for 10 s.
|
|
3211
3189
|
const schemas = await Promise.race([getModelSchemasFromEas(lookups), timeoutPromise]).finally(() => clearTimeout(timeout));
|
|
@@ -3221,12 +3199,7 @@ async function addModelsToDb(context) {
|
|
|
3221
3199
|
}
|
|
3222
3200
|
}
|
|
3223
3201
|
catch (error) {
|
|
3224
|
-
|
|
3225
|
-
logger$8('[client/actors] [addModelsToDb] Warning: Could not fetch schemas from EAS (background):', error.message);
|
|
3226
|
-
}
|
|
3227
|
-
else {
|
|
3228
|
-
logger$8('[client/actors] [addModelsToDb] Error fetching schemas (background):', error.message);
|
|
3229
|
-
}
|
|
3202
|
+
logger$8('[client/actors] [addModelsToDb] Error fetching schemas (background):', error.message);
|
|
3230
3203
|
// Probably offline: the startup sync waits for this lookup, so try again.
|
|
3231
3204
|
modelUidsRetry.schedule();
|
|
3232
3205
|
}
|
|
@@ -3245,9 +3218,7 @@ async function addModelsToDb(context) {
|
|
|
3245
3218
|
}
|
|
3246
3219
|
catch (error) {
|
|
3247
3220
|
logger$8('[client/actors] [addModelsToDb] Error:', error);
|
|
3248
|
-
|
|
3249
|
-
if (!isTestOrSeedDev())
|
|
3250
|
-
throw error;
|
|
3221
|
+
throw error;
|
|
3251
3222
|
}
|
|
3252
3223
|
}
|
|
3253
3224
|
|
|
@@ -3426,11 +3397,6 @@ async function saveConfig(context) {
|
|
|
3426
3397
|
try {
|
|
3427
3398
|
const appDb = BaseDb.getAppDb();
|
|
3428
3399
|
if (!appDb) {
|
|
3429
|
-
// In test environments, continue anyway
|
|
3430
|
-
if (isTestOrSeedDev()) {
|
|
3431
|
-
logger$6('[internal/actors] [saveConfig] App DB not found, but continuing in test environment');
|
|
3432
|
-
return;
|
|
3433
|
-
}
|
|
3434
3400
|
throw new Error('App DB not found');
|
|
3435
3401
|
}
|
|
3436
3402
|
const endpointsValueString = JSON.stringify(endpoints);
|
|
@@ -3484,11 +3450,6 @@ async function saveConfig(context) {
|
|
|
3484
3450
|
}
|
|
3485
3451
|
catch (error) {
|
|
3486
3452
|
logger$6('[internal/actors] [saveConfig] Error saving config:', error);
|
|
3487
|
-
// In test environments, continue anyway
|
|
3488
|
-
if (isTestOrSeedDev()) {
|
|
3489
|
-
logger$6('[internal/actors] [saveConfig] Continuing despite error in test environment');
|
|
3490
|
-
return;
|
|
3491
|
-
}
|
|
3492
3453
|
throw error;
|
|
3493
3454
|
}
|
|
3494
3455
|
};
|
|
@@ -3920,8 +3881,8 @@ async function applySchemaFile(source, options = {}) {
|
|
|
3920
3881
|
if (!schemaRecord) {
|
|
3921
3882
|
warnOnEasNameCollisions(file);
|
|
3922
3883
|
warnOnInvalidNameMatch(file);
|
|
3923
|
-
const _mod_14 = await import('./
|
|
3924
|
-
const _ns_14 = _mod_14.
|
|
3884
|
+
const _mod_14 = await import('./Item-Ld1iPicQ.js');
|
|
3885
|
+
const _ns_14 = _mod_14.bR;
|
|
3925
3886
|
const { addModelsToDb, broadcastSchemasInvalidate } = _ns_14;
|
|
3926
3887
|
const modelFileIds = new Map(Object.entries(file.models).map(([name, model]) => [name, model.id]));
|
|
3927
3888
|
const propertyDefinitions = schemaFilePropertyDefinitions(file);
|
|
@@ -4072,8 +4033,8 @@ async function resolveSchemaRow(row, db = BaseDb.getAppDb()) {
|
|
|
4072
4033
|
metadata: { ...schema.metadata, name: row.name },
|
|
4073
4034
|
};
|
|
4074
4035
|
if (row.id && db) {
|
|
4075
|
-
const _mod_15 = await import('./
|
|
4076
|
-
const _ns_15 = _mod_15.
|
|
4036
|
+
const _mod_15 = await import('./Item-Ld1iPicQ.js');
|
|
4037
|
+
const _ns_15 = _mod_15.bR;
|
|
4077
4038
|
const { loadModelsFromDbForSchema, mergeDbModelsIntoSchemaModels } = _ns_15;
|
|
4078
4039
|
const dbModels = await loadModelsFromDbForSchema(row.id, db);
|
|
4079
4040
|
if (Object.keys(dbModels).length > 0) {
|
|
@@ -4679,6 +4640,22 @@ const getVersionData = async ({ localId, seedLocalId, uid, }, db = BaseDb.getApp
|
|
|
4679
4640
|
return queryRows[0];
|
|
4680
4641
|
};
|
|
4681
4642
|
|
|
4643
|
+
/**
|
|
4644
|
+
* The publisher a seed's version and property rows take: the seed's own (its `publisher`, else the
|
|
4645
|
+
* attester of its stored attestation). Undefined for a draft that belongs to no wallet yet; those
|
|
4646
|
+
* rows are then claimed together with their seed (claimUnpublishedDrafts).
|
|
4647
|
+
*/
|
|
4648
|
+
async function getSeedPublisher(seedLocalId,
|
|
4649
|
+
/** The database or transaction to read; the app database by default. */
|
|
4650
|
+
db = BaseDb.getAppDb()) {
|
|
4651
|
+
if (!seedLocalId)
|
|
4652
|
+
return undefined;
|
|
4653
|
+
const row = await findSeedRow({ localId: seedLocalId }, db);
|
|
4654
|
+
if (!row)
|
|
4655
|
+
return undefined;
|
|
4656
|
+
return normalizePublisher(resolvePublisherFromSeedRow(row));
|
|
4657
|
+
}
|
|
4658
|
+
|
|
4682
4659
|
const logger$1 = debug('seedSdk:write:updateItemPropertyValue');
|
|
4683
4660
|
const updateItemPropertyValue = async ({ localId: localIdParam, propertyName, newValue, seedUid, seedLocalId, modelName, refSeedType, refResolvedValue, refResolvedDisplayValue, versionLocalId, versionUid, schemaUid, localStorageDir, dataType, refValueType, retract, }, options = {}) => {
|
|
4684
4661
|
if (!localIdParam && !seedLocalId) {
|
|
@@ -4739,7 +4716,9 @@ const updateItemPropertyValue = async ({ localId: localIdParam, propertyName, ne
|
|
|
4739
4716
|
rows = newestRows.slice(0, 1);
|
|
4740
4717
|
}
|
|
4741
4718
|
if (rows && rows.length > 0) {
|
|
4742
|
-
const { localId, uid, propertyId: propertyIdFromDb, propertyName: propertyNameFromDb, propertyValue: propertyValueFromDb, modelType, seedLocalId: seedLocalIdFromDb, versionLocalId, schemaUid, easDataType, refSeedType: refSeedTypeFromDb, refResolvedValue: refResolvedValueFromDb, retract: retractFromDb, } = rows[0];
|
|
4719
|
+
const { localId, uid, propertyId: propertyIdFromDb, propertyName: propertyNameFromDb, propertyValue: propertyValueFromDb, modelType, seedLocalId: seedLocalIdFromDb, versionLocalId, schemaUid: schemaUidFromDb, easDataType, refSeedType: refSeedTypeFromDb, refResolvedValue: refResolvedValueFromDb, retract: retractFromDb, } = rows[0];
|
|
4720
|
+
// The resolved schema uid fills in a row stored before its schema was known.
|
|
4721
|
+
const rowSchemaUid = schemaUidFromDb || schemaUid;
|
|
4743
4722
|
// Stored model types are the model's EAS name (ADR 0008): `blog_post` for BlogPost.
|
|
4744
4723
|
const modelTypeForName = modelName ? easName(modelName) : undefined;
|
|
4745
4724
|
if (propertyValueFromDb === newValue &&
|
|
@@ -4749,7 +4728,7 @@ const updateItemPropertyValue = async ({ localId: localIdParam, propertyName, ne
|
|
|
4749
4728
|
(refResolvedValueFromDb ?? null) === (refResolvedValue ?? null) &&
|
|
4750
4729
|
!!retractFromDb === !!retractValue) {
|
|
4751
4730
|
logger$1(`[db/write] [updateItemPropertyValue] value is the same as most recent record for property: ${propertyNameFromDb}`);
|
|
4752
|
-
return localId == null ? undefined : { localId, uid: uid ?? null, schemaUid:
|
|
4731
|
+
return localId == null ? undefined : { localId, uid: uid ?? null, schemaUid: schemaUidFromDb ?? '' };
|
|
4753
4732
|
}
|
|
4754
4733
|
// This means we already have a local-only record so we should just update that one
|
|
4755
4734
|
if (!uid) {
|
|
@@ -4774,11 +4753,14 @@ const updateItemPropertyValue = async ({ localId: localIdParam, propertyName, ne
|
|
|
4774
4753
|
if (propertyIdFromDb == null && property.propertyId != null) {
|
|
4775
4754
|
updatePayload.propertyId = property.propertyId;
|
|
4776
4755
|
}
|
|
4756
|
+
if (!schemaUidFromDb && schemaUid) {
|
|
4757
|
+
updatePayload.schemaUid = schemaUid;
|
|
4758
|
+
}
|
|
4777
4759
|
await appDb
|
|
4778
4760
|
.update(metadata$1)
|
|
4779
4761
|
.set(updatePayload)
|
|
4780
4762
|
.where(eq(metadata$1.localId, localId));
|
|
4781
|
-
return { localId, uid: null, schemaUid:
|
|
4763
|
+
return { localId, uid: null, schemaUid: rowSchemaUid ?? '' };
|
|
4782
4764
|
}
|
|
4783
4765
|
const seedDataFromDb = seedLocalId ? await findSeedRow({ localId: seedLocalId }, appDb) : null;
|
|
4784
4766
|
const versionDataFromDb = versionLocalId ? await getVersionData({ localId: versionLocalId }, appDb) : null;
|
|
@@ -4798,7 +4780,7 @@ const updateItemPropertyValue = async ({ localId: localIdParam, propertyName, ne
|
|
|
4798
4780
|
seedLocalId: seedLocalIdFromDb,
|
|
4799
4781
|
versionLocalId,
|
|
4800
4782
|
versionUid: versionDataFromDb?.uid || null,
|
|
4801
|
-
schemaUid,
|
|
4783
|
+
schemaUid: rowSchemaUid,
|
|
4802
4784
|
easDataType: easDataType || null,
|
|
4803
4785
|
refSeedType: refSeedType || null,
|
|
4804
4786
|
refResolvedValue: refResolvedValue || null,
|
|
@@ -4809,7 +4791,7 @@ const updateItemPropertyValue = async ({ localId: localIdParam, propertyName, ne
|
|
|
4809
4791
|
return {
|
|
4810
4792
|
localId: newLocalId,
|
|
4811
4793
|
uid: null,
|
|
4812
|
-
schemaUid:
|
|
4794
|
+
schemaUid: rowSchemaUid ?? '',
|
|
4813
4795
|
};
|
|
4814
4796
|
}
|
|
4815
4797
|
// Here there are no records for this property on this seed so we should create one
|
|
@@ -4868,6 +4850,116 @@ const createVersion = async ({ seedLocalId, seedUid, seedType, uid, }, options =
|
|
|
4868
4850
|
return newVersionLocalId;
|
|
4869
4851
|
};
|
|
4870
4852
|
|
|
4853
|
+
/** Error thrown when metadata validation fails (e.g. enum violation). */
|
|
4854
|
+
class MetadataValidationError extends Error {
|
|
4855
|
+
constructor(message, validationErrors) {
|
|
4856
|
+
super(message);
|
|
4857
|
+
this.validationErrors = validationErrors;
|
|
4858
|
+
this.name = 'MetadataValidationError';
|
|
4859
|
+
}
|
|
4860
|
+
}
|
|
4861
|
+
const createMetadata = async (metadataValues, propertyRecordSchema, options) => {
|
|
4862
|
+
const appDb = options?.db ?? BaseDb.getAppDb();
|
|
4863
|
+
metadataValues.localId = generateId();
|
|
4864
|
+
// A property row belongs to its seed's wallet (none yet for a draft made with no wallet connected).
|
|
4865
|
+
const publisher = await getSeedPublisher(metadataValues.seedLocalId, appDb);
|
|
4866
|
+
if (publisher) {
|
|
4867
|
+
metadataValues.publisher = publisher;
|
|
4868
|
+
}
|
|
4869
|
+
if (!metadataValues.modelType && metadataValues.modelName) {
|
|
4870
|
+
metadataValues.modelType = easName(metadataValues.modelName);
|
|
4871
|
+
}
|
|
4872
|
+
// property_id is the match key (decision D4); the row is written under the property's storage name.
|
|
4873
|
+
const property = await resolveMetadataProperty({
|
|
4874
|
+
propertyId: metadataValues.propertyId,
|
|
4875
|
+
definitionId: propertyRecordSchema?.id,
|
|
4876
|
+
propertyName: metadataValues.propertyName,
|
|
4877
|
+
modelName: metadataValues.modelName ?? metadataValues.modelType,
|
|
4878
|
+
modelFileId: options?.modelFileId,
|
|
4879
|
+
seedLocalId: metadataValues.seedLocalId,
|
|
4880
|
+
seedUid: metadataValues.seedUid,
|
|
4881
|
+
}, appDb, { onAmbiguousModel: 'none' });
|
|
4882
|
+
if (property) {
|
|
4883
|
+
metadataValues.propertyId = property.id;
|
|
4884
|
+
metadataValues.propertyName = property.storageName;
|
|
4885
|
+
}
|
|
4886
|
+
else if (metadataValues.propertyName && propertyRecordSchema) {
|
|
4887
|
+
metadataValues.propertyName = metadataStorageName(metadataValues.propertyName, propertyRecordSchema);
|
|
4888
|
+
}
|
|
4889
|
+
const isItemStorage = propertyRecordSchema && propertyRecordSchema.storageType === 'ItemStorage';
|
|
4890
|
+
// if (
|
|
4891
|
+
// propertyRecordSchema &&
|
|
4892
|
+
// propertyRecordSchema.localStorageDir &&
|
|
4893
|
+
// isItemStorage
|
|
4894
|
+
// ) {
|
|
4895
|
+
// const filename = `${metadataValues.seedUid || metadataValues.seedLocalId}${propertyRecordSchema.filenameSuffix}`
|
|
4896
|
+
// const filePath = path.join(propertyRecordSchema.localStorageDir, filename)
|
|
4897
|
+
// await fs.promises.writeFile(filePath, metadataValues.propertyValue)
|
|
4898
|
+
// metadataValues.propertyValue = filename
|
|
4899
|
+
// metadataValues.refValueType = 'file'
|
|
4900
|
+
// }
|
|
4901
|
+
// Convert propertyValue to string if it's not already (metadata table expects text)
|
|
4902
|
+
if (metadataValues.propertyValue !== undefined && metadataValues.propertyValue !== null) {
|
|
4903
|
+
if (Array.isArray(metadataValues.propertyValue)) {
|
|
4904
|
+
// List values: JSON array is the storage format (String() would give legacy comma-separated ids)
|
|
4905
|
+
metadataValues.propertyValue = JSON.stringify(metadataValues.propertyValue);
|
|
4906
|
+
}
|
|
4907
|
+
else if (typeof metadataValues.propertyValue !== 'string') {
|
|
4908
|
+
metadataValues.propertyValue = String(metadataValues.propertyValue);
|
|
4909
|
+
}
|
|
4910
|
+
}
|
|
4911
|
+
// Validate against property validation rules (enum, pattern, minLength, maxLength) unless skipped
|
|
4912
|
+
if (!options?.skipValidation &&
|
|
4913
|
+
propertyRecordSchema?.validation &&
|
|
4914
|
+
metadataValues.propertyValue != null &&
|
|
4915
|
+
metadataValues.propertyValue !== '') {
|
|
4916
|
+
const { SchemaValidationService } = await import('./SchemaValidationService-CW0s7V7R.js');
|
|
4917
|
+
const validationService = new SchemaValidationService();
|
|
4918
|
+
const validationResult = validationService.validatePropertyValue(metadataValues.propertyValue, normalizeDataType(propertyRecordSchema.dataType), propertyRecordSchema.validation, propertyRecordSchema.refValueType
|
|
4919
|
+
? normalizeDataType(String(propertyRecordSchema.refValueType))
|
|
4920
|
+
: undefined);
|
|
4921
|
+
if (!validationResult.isValid && validationResult.errors.length > 0) {
|
|
4922
|
+
const validationErrors = validationResult.errors.map((e) => ({
|
|
4923
|
+
field: e.field,
|
|
4924
|
+
message: e.message,
|
|
4925
|
+
code: e.code,
|
|
4926
|
+
}));
|
|
4927
|
+
const message = validationErrors.map((e) => e.message).join('; ');
|
|
4928
|
+
throw new MetadataValidationError(message, validationErrors);
|
|
4929
|
+
}
|
|
4930
|
+
}
|
|
4931
|
+
// With a given db (a transaction), the caller resolves schemaUid first: the lookup may call EAS.
|
|
4932
|
+
// Without one it isn't required for metadata insertion, so a failed lookup leaves it unset.
|
|
4933
|
+
if (!options?.db && !isItemStorage && !metadataValues.schemaUid && metadataValues.propertyName) {
|
|
4934
|
+
const schemaUid = await lookupPropertySchemaUid(metadataValues.propertyName, propertyRecordSchema);
|
|
4935
|
+
if (schemaUid)
|
|
4936
|
+
metadataValues.schemaUid = schemaUid;
|
|
4937
|
+
}
|
|
4938
|
+
let inserted;
|
|
4939
|
+
try {
|
|
4940
|
+
inserted = await appDb
|
|
4941
|
+
.insert(metadata$1)
|
|
4942
|
+
.values({
|
|
4943
|
+
...metadataValues,
|
|
4944
|
+
// Stamped here: a value carried in metadataValues would otherwise win over the column default.
|
|
4945
|
+
createdAt: Date.now(),
|
|
4946
|
+
updatedAt: Date.now(),
|
|
4947
|
+
})
|
|
4948
|
+
.returning();
|
|
4949
|
+
}
|
|
4950
|
+
catch (error) {
|
|
4951
|
+
// Drizzle's message is the full SQL; the driver error that explains it is only on `cause`.
|
|
4952
|
+
const cause = error?.cause;
|
|
4953
|
+
const reason = cause instanceof Error ? cause.message : cause != null ? String(cause) : undefined;
|
|
4954
|
+
throw new Error(`Failed to insert metadata for property ${metadataValues.propertyName}` +
|
|
4955
|
+
(reason ? `: ${reason}` : `: ${error instanceof Error ? error.message : String(error)}`), { cause: error });
|
|
4956
|
+
}
|
|
4957
|
+
if (!inserted || inserted.length === 0) {
|
|
4958
|
+
throw new Error(`Failed to insert metadata record for property ${metadataValues.propertyName}`);
|
|
4959
|
+
}
|
|
4960
|
+
return inserted[0];
|
|
4961
|
+
};
|
|
4962
|
+
|
|
4871
4963
|
/** Absolute path of the file {@link writeItemStorageFile} writes for `target`. */
|
|
4872
4964
|
const getItemStorageFilePath = (target) => BaseFileManager.getFilesPath(getItemStorageSubdir(target.localStorageDir), target.fileName || getItemStorageLocalFileName(target.seedId, target.filenameSuffix));
|
|
4873
4965
|
/**
|
|
@@ -5008,8 +5100,8 @@ async function applyStorageValue(seedLocalId, propertyName, value, db, prepared)
|
|
|
5008
5100
|
const row = prepared
|
|
5009
5101
|
? { ...stored, refResolvedValue: prepared.fileName, schemaUid: prepared.schemaUid, refModelUid: prepared.refModelUid }
|
|
5010
5102
|
: stored;
|
|
5011
|
-
const _mod_16 = await import('./Item-
|
|
5012
|
-
const _ns_16 = _mod_16.
|
|
5103
|
+
const _mod_16 = await import('./Item-Ld1iPicQ.js');
|
|
5104
|
+
const _ns_16 = _mod_16.bS;
|
|
5013
5105
|
const { currentPropertyRow } = _ns_16;
|
|
5014
5106
|
const existing = await currentPropertyRow({ seedLocalId }, {
|
|
5015
5107
|
propertyName,
|
|
@@ -5322,8 +5414,8 @@ function startItemOutbox() {
|
|
|
5322
5414
|
return {};
|
|
5323
5415
|
// Cached, shared with item creation, so a save doesn't wait on the EAS indexer each time.
|
|
5324
5416
|
// Not required for the row; publish resolves the schema again.
|
|
5325
|
-
const _mod_17 = await import('./Item-
|
|
5326
|
-
const _ns_17 = _mod_17.
|
|
5417
|
+
const _mod_17 = await import('./Item-Ld1iPicQ.js');
|
|
5418
|
+
const _ns_17 = _mod_17.bT;
|
|
5327
5419
|
const { lookupPropertySchemaUid } = _ns_17;
|
|
5328
5420
|
return {
|
|
5329
5421
|
schemaUid: await lookupPropertySchemaUid(op.propertyName, value.propertyRecordSchema),
|
|
@@ -6634,5 +6726,5 @@ var errors = /*#__PURE__*/Object.freeze({
|
|
|
6634
6726
|
UnknownModelError: UnknownModelError
|
|
6635
6727
|
});
|
|
6636
6728
|
|
|
6637
|
-
export {
|
|
6638
|
-
//# sourceMappingURL=errors-
|
|
6729
|
+
export { schema as $, INIT_CONFIG_CONFLICT_MESSAGE as A, ItemCreateError as B, ConflictError as C, claimUnpublishedDrafts as D, EAS_CHAIN_ID_APP_STATE_KEY as E, createLocalQueryDataSource as F, easSyncActor as G, getClient as H, ItemCreateValidationError as I, getPublishedSeedRecord as J, getSchemaNameFromId as K, isSeedQueryLocalSourceRegistered as L, Model as M, listCompleteSchemaFiles as N, mergeEasSyncRequestIntents as O, registerSeedQueryLocalSource as P, requestEasSyncFromAddressChange as Q, requestEasSyncFromModelsInit as R, SCHEMA_FILE_FORMAT as S, TModelSchema as T, UnknownModelError as U, sendEasSyncClientRequest as V, setRetriesWhenOnlineEnabled as W, startEasSyncActor as X, unregisterSeedQueryLocalSource as Y, saveDefinition$1 as Z, Model$1 as _, ClientManager as a, SEEDPROTOCOL_Seed_Protocol_v1 as a0, itemAppliers as a1, errors as a2, syncSchemaFromSource as b, transformImportToSchemaFile as c, deleteFiles as d, localModelSchemaLookups as e, listLatestSchemaFiles as f, readSchemaFile as g, applySchemaFile as h, importJsonSchema as i, resolveSchemaRow as j, loadAllSchemasFromDb as k, loadSchemaFromFile as l, getDraftSaveError as m, setupEntityLiveQuery as n, mergeSchemaFiles as o, trackDraftSave as p, queueDraftSave as q, readJsonImportFile as r, startItemOutbox as s, throwItemWriteError as t, waitForEasReadChain as u, assertLocalDbChain as v, writeNextSchemaVersion as w, writeModelUids as x, getContentHash as y, saveDefinition as z };
|
|
6730
|
+
//# sourceMappingURL=errors-DKxFSvb3.js.map
|