@seedprotocol/sdk 0.7.9-next.1177.ga3e08ed → 0.7.9-next.1306.g4ff6582
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/BaseFileManager-BAlySv8w.js +650 -0
- package/dist/BaseFileManager-BAlySv8w.js.map +1 -0
- package/dist/{Item-0oDoTPhi.js → Item-Bf4kWKpH.js} +5647 -6573
- package/dist/Item-Bf4kWKpH.js.map +1 -0
- package/dist/{ModelProperty-i5flwzQG.js → ModelProperty-BlaEgb_U.js} +345 -709
- package/dist/ModelProperty-BlaEgb_U.js.map +1 -0
- package/dist/Schema-J_1f6p0c.js +1456 -0
- package/dist/Schema-J_1f6p0c.js.map +1 -0
- package/dist/{SchemaValidationService-DnGKel4V.js → SchemaValidationService-CnmKyzR-.js} +6 -9
- package/dist/{SchemaValidationService-DnGKel4V.js.map → SchemaValidationService-CnmKyzR-.js.map} +1 -1
- package/dist/{configurePlatform-CrMafpMW.js → configurePlatform-CiOJ1R3q.js} +3 -12
- package/dist/configurePlatform-CiOJ1R3q.js.map +1 -0
- package/dist/db/drizzle/0025_add_metadata_retract.sql +1 -0
- package/dist/db/drizzle/0026_add_content_hash_to_schemas.sql +1 -0
- package/dist/db/drizzle/0027_link_metadata_property_ids.sql +74 -0
- package/dist/db/drizzle/0028_add_definition_to_properties.sql +17 -0
- package/dist/db/drizzle/0029_dedupe_chain_uids_add_unique_indexes.sql +120 -0
- package/dist/db/drizzle/meta/0025_snapshot.json +1652 -0
- package/dist/db/drizzle/meta/0026_snapshot.json +1659 -0
- package/dist/db/drizzle/meta/0027_snapshot.json +1659 -0
- package/dist/db/drizzle/meta/0028_snapshot.json +1666 -0
- package/dist/db/drizzle/meta/0029_snapshot.json +1691 -0
- package/dist/db/drizzle/meta/_journal.json +36 -1
- package/dist/{detachRowsBeforeDelete-DXFYSHRR.js → detachRowsBeforeDelete-sEaUwlOU.js} +2 -13
- package/dist/{detachRowsBeforeDelete-DXFYSHRR.js.map → detachRowsBeforeDelete-sEaUwlOU.js.map} +1 -1
- package/dist/dist/{index-Dx_GTdyQ.d.ts → BaseFileManager-BAlySv8w.d.ts} +1424 -2696
- package/dist/dist/BaseFileManager-BAlySv8w.d.ts.map +1 -0
- package/dist/dist/{configurePlatform-CrMafpMW.d.ts → configurePlatform-CiOJ1R3q.d.ts} +1 -1
- package/dist/dist/configurePlatform-CiOJ1R3q.d.ts.map +1 -0
- package/dist/dist/{index-PbnKw2es.d.ts → index-D0V-mjCV.d.ts} +56 -1
- package/dist/dist/{index-PbnKw2es.d.ts.map → index-D0V-mjCV.d.ts.map} +1 -1
- package/dist/dist/{index.node-CzMwMr_d.d.ts → index.node-CYPemH-t.d.ts} +225 -5
- package/dist/dist/{index.node-CzMwMr_d.d.ts.map → index.node-CYPemH-t.d.ts.map} +1 -1
- package/dist/dist/platform.node.d.ts +2 -2
- package/dist/eas-wB_fQ8Tc.js +32 -0
- package/dist/eas-wB_fQ8Tc.js.map +1 -0
- package/dist/errors-DLSoqSHG.js +6550 -0
- package/dist/errors-DLSoqSHG.js.map +1 -0
- package/dist/getPublishPayload-BnIwpwz1.js +760 -0
- package/dist/getPublishPayload-BnIwpwz1.js.map +1 -0
- package/dist/getPublishPendingDiff-D6_-A5ns.js +125 -0
- package/dist/getPublishPendingDiff-D6_-A5ns.js.map +1 -0
- package/dist/getPublishUploads-sS6JfPgz.js +783 -0
- package/dist/getPublishUploads-sS6JfPgz.js.map +1 -0
- package/dist/{index-DJmWkVIK.js → index-BVBmz_cc.js} +11 -14
- package/dist/index-BVBmz_cc.js.map +1 -0
- package/dist/index-CYGWPoOx.js +27 -0
- package/dist/index-CYGWPoOx.js.map +1 -0
- package/dist/{index-PbnKw2es.js → index-D0V-mjCV.js} +2 -2
- package/dist/index-D0V-mjCV.js.map +1 -0
- package/dist/index-DmTtj1nk.js +817 -0
- package/dist/index-DmTtj1nk.js.map +1 -0
- package/dist/{index.browser-i9uPJice.js → index.browser-CUmBVYen.js} +436 -379
- package/dist/index.browser-CUmBVYen.js.map +1 -0
- package/dist/{index.node-CzMwMr_d.js → index.node-CYPemH-t.js} +10 -10
- package/dist/index.node-CYPemH-t.js.map +1 -0
- package/dist/main.js +23 -1105
- package/dist/main.js.map +1 -1
- package/dist/modelPropertyRecordSchemas-C7UgA5TH.js +48 -0
- package/dist/modelPropertyRecordSchemas-C7UgA5TH.js.map +1 -0
- package/dist/node.js +14 -18
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +8 -13
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.node.js +6 -16
- package/dist/platform.node.js.map +1 -1
- package/dist/property-BxUYznH0.js +87 -0
- package/dist/property-BxUYznH0.js.map +1 -0
- package/dist/publishGraph-EcB40Uii.js +311 -0
- package/dist/publishGraph-EcB40Uii.js.map +1 -0
- package/dist/readHtmlBodyForStorageSeed-D6KPtWoR.js +110 -0
- package/dist/readHtmlBodyForStorageSeed-D6KPtWoR.js.map +1 -0
- package/dist/seedSchema/MetadataSchema.ts +3 -0
- package/dist/seedSchema/ModelSchema.ts +4 -0
- package/dist/seedSchema/ModelSchemaSchema.ts +5 -2
- package/dist/seedSchema/PendingWriteSchema.ts +4 -1
- package/dist/seedSchema/SchemaSchema.ts +3 -0
- package/dist/seedSchema/SeedSchema.ts +8 -2
- package/dist/seedSchema/VersionSchema.ts +7 -2
- package/dist/seedSchema/attestedUid.ts +10 -0
- package/dist/src/Item/Item.d.ts +32 -30
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Item/loadItem.d.ts +12 -0
- package/dist/src/Item/loadItem.d.ts.map +1 -0
- package/dist/src/Item/service/itemMachineSingle.d.ts +2 -13
- package/dist/src/Item/service/itemMachineSingle.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts +98 -41
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/loadProperty.d.ts +11 -0
- package/dist/src/ItemProperty/loadProperty.d.ts.map +1 -0
- package/dist/src/ItemProperty/propertyWrite.d.ts +54 -0
- package/dist/src/ItemProperty/propertyWrite.d.ts.map +1 -0
- package/dist/src/ItemProperty/{service/actors/saveValueToDb/rowContext.d.ts → rowContext.d.ts} +1 -1
- package/dist/src/ItemProperty/rowContext.d.ts.map +1 -0
- package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts +6 -0
- package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/modelPropertyRecordSchemas.d.ts +5 -15
- package/dist/src/ItemProperty/service/actors/modelPropertyRecordSchemas.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/propertyMachine.d.ts +3 -46
- package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
- package/dist/src/Model/Model.d.ts +26 -56
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/Model/createModelProperties.d.ts +10 -0
- package/dist/src/Model/createModelProperties.d.ts.map +1 -0
- package/dist/src/Model/loadModel.d.ts +13 -0
- package/dist/src/Model/loadModel.d.ts.map +1 -0
- package/dist/src/Model/service/actors/validateModel.d.ts.map +1 -1
- package/dist/src/Model/service/modelMachine.d.ts +5 -114
- package/dist/src/Model/service/modelMachine.d.ts.map +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts +44 -37
- package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/actors/compareAndMarkDraft.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/actors/validateProperty.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +6 -77
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts.map +1 -1
- package/dist/src/Schema/Schema.d.ts +36 -37
- package/dist/src/Schema/Schema.d.ts.map +1 -1
- package/dist/src/Schema/loadOrCreateSchema.d.ts +21 -0
- package/dist/src/Schema/loadOrCreateSchema.d.ts.map +1 -0
- package/dist/src/Schema/service/schemaMachine.d.ts +7 -125
- package/dist/src/Schema/service/schemaMachine.d.ts.map +1 -1
- package/dist/src/browser/db/Db.d.ts.map +1 -1
- package/dist/src/browser/db/changeFeed.d.ts +2 -18
- package/dist/src/browser/db/changeFeed.d.ts.map +1 -1
- package/dist/src/browser/db/drizzleFiles.d.ts +7 -2
- package/dist/src/browser/db/drizzleFiles.d.ts.map +1 -1
- package/dist/src/browser/workers/filesDownload.d.ts.map +1 -1
- package/dist/src/browser/workers/imageResize.d.ts.map +1 -1
- package/dist/src/client/ClientManager.d.ts +90 -57
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/client/actors/addModelsToDb.d.ts +9 -7
- package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
- package/dist/src/client/actors/dbInit.d.ts +3 -3
- package/dist/src/client/actors/dbInit.d.ts.map +1 -1
- package/dist/src/client/actors/fileSystemInit.d.ts +3 -3
- package/dist/src/client/actors/fileSystemInit.d.ts.map +1 -1
- package/dist/src/client/actors/platformClassesInit.d.ts +10 -5
- package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/src/client/actors/processSchemaFiles.d.ts +18 -3
- package/dist/src/client/actors/processSchemaFiles.d.ts.map +1 -1
- package/dist/src/client/actors/saveConfig.d.ts +6 -3
- package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/src/client/clientManagerMachine.d.ts +22 -20
- package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
- package/dist/src/client/constants.d.ts +1 -9
- package/dist/src/client/constants.d.ts.map +1 -1
- package/dist/src/client/readiness.d.ts +26 -0
- package/dist/src/client/readiness.d.ts.map +1 -0
- package/dist/src/db/read/currentPropertyRow.d.ts +61 -0
- package/dist/src/db/read/currentPropertyRow.d.ts.map +1 -0
- package/dist/src/db/read/findSeedRow.d.ts +20 -0
- package/dist/src/db/read/findSeedRow.d.ts.map +1 -0
- package/dist/src/db/read/findSeedRowsByUid.d.ts +4 -1
- package/dist/src/db/read/findSeedRowsByUid.d.ts.map +1 -1
- package/dist/src/db/read/getAttesterForSeed.d.ts +1 -1
- package/dist/src/db/read/getAttesterForSeed.d.ts.map +1 -1
- package/dist/src/db/read/getItemData.d.ts.map +1 -1
- package/dist/src/db/read/getItemProperties.d.ts +5 -0
- package/dist/src/db/read/getItemProperties.d.ts.map +1 -1
- package/dist/src/db/read/getMetadataAttestationUidsForSeedUid.d.ts.map +1 -1
- package/dist/src/db/read/getModelSchemas.d.ts +0 -7
- package/dist/src/db/read/getModelSchemas.d.ts.map +1 -1
- package/dist/src/db/read/getModelsData.d.ts.map +1 -1
- package/dist/src/db/read/getPropertyClear.d.ts +49 -0
- package/dist/src/db/read/getPropertyClear.d.ts.map +1 -0
- package/dist/src/db/read/getPublishPayload.d.ts +35 -40
- package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/src/db/read/getPublishPendingDiff.d.ts +7 -2
- package/dist/src/db/read/getPublishPendingDiff.d.ts.map +1 -1
- package/dist/src/db/read/getPublishUploads.d.ts +59 -28
- package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
- package/dist/src/db/read/getSchemaUidForModel.d.ts.map +1 -1
- package/dist/src/db/read/getSeedPublishState.d.ts.map +1 -1
- package/dist/src/db/read/getSeedPublisher.d.ts.map +1 -1
- package/dist/src/db/read/getVersionsForSeedUid.d.ts.map +1 -1
- package/dist/src/db/read/isSeedRevoked.d.ts.map +1 -1
- package/dist/src/db/read/localModelSchemaLookups.d.ts +8 -0
- package/dist/src/db/read/localModelSchemaLookups.d.ts.map +1 -0
- package/dist/src/db/read/metadataProperty.d.ts +104 -0
- package/dist/src/db/read/metadataProperty.d.ts.map +1 -0
- package/dist/src/db/read/publishGraph.d.ts +148 -0
- package/dist/src/db/read/publishGraph.d.ts.map +1 -0
- package/dist/src/db/read/resolveModelRecord.d.ts +26 -2
- package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -1
- package/dist/src/db/read/resolveRelatedSeedRef.d.ts +1 -7
- package/dist/src/db/read/resolveRelatedSeedRef.d.ts.map +1 -1
- package/dist/src/db/read/subqueries/metadataLatest.d.ts +3 -1
- package/dist/src/db/read/subqueries/metadataLatest.d.ts.map +1 -1
- package/dist/src/db/read/summarizePublishWork.d.ts +18 -5
- package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -1
- package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts +20 -21
- package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts.map +1 -1
- package/dist/src/db/write/createMetadata.d.ts.map +1 -1
- package/dist/src/db/write/createNewItem.d.ts.map +1 -1
- package/dist/src/db/write/createSeeds.d.ts +5 -1
- package/dist/src/db/write/createSeeds.d.ts.map +1 -1
- package/dist/src/db/write/definitions.d.ts +127 -0
- package/dist/src/db/write/definitions.d.ts.map +1 -0
- package/dist/src/db/write/markPropertyAttestationsRetracted.d.ts +11 -0
- package/dist/src/db/write/markPropertyAttestationsRetracted.d.ts.map +1 -0
- package/dist/src/db/write/mergeChainRows.d.ts +22 -0
- package/dist/src/db/write/mergeChainRows.d.ts.map +1 -0
- package/dist/src/db/write/saveDefinition.d.ts +29 -0
- package/dist/src/db/write/saveDefinition.d.ts.map +1 -0
- package/dist/src/db/write/updateItemPropertyValue.d.ts +2 -0
- package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
- package/dist/src/db/write/updateSeedUid.d.ts +4 -2
- package/dist/src/db/write/updateSeedUid.d.ts.map +1 -1
- package/dist/src/db/write/updateVersionUid.d.ts +12 -4
- package/dist/src/db/write/updateVersionUid.d.ts.map +1 -1
- package/dist/src/db/write/writeModelUids.d.ts +10 -0
- package/dist/src/db/write/writeModelUids.d.ts.map +1 -0
- package/dist/src/eas.d.ts +8 -6
- package/dist/src/eas.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/arweaveContentTags.d.ts +1 -1
- package/dist/src/helpers/arweaveContentTags.d.ts.map +1 -1
- package/dist/src/helpers/compareMetadataRowsLatestFirst.d.ts +27 -12
- package/dist/src/helpers/compareMetadataRowsLatestFirst.d.ts.map +1 -1
- package/dist/src/helpers/constants.d.ts +5 -2
- package/dist/src/helpers/constants.d.ts.map +1 -1
- package/dist/src/helpers/dataUrl.d.ts +10 -0
- package/dist/src/helpers/dataUrl.d.ts.map +1 -0
- package/dist/src/helpers/db.d.ts +54 -105
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/helpers/ensureImageLocal.d.ts.map +1 -1
- package/dist/src/helpers/entity/contextUpdate.d.ts +20 -0
- package/dist/src/helpers/entity/contextUpdate.d.ts.map +1 -0
- package/dist/src/helpers/entity/draftSaveErrors.d.ts +5 -0
- package/dist/src/helpers/entity/draftSaveErrors.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityCache.d.ts +65 -3
- package/dist/src/helpers/entity/entityCache.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityCommon.d.ts +0 -22
- package/dist/src/helpers/entity/entityCommon.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityLifecycle.d.ts +75 -0
- package/dist/src/helpers/entity/entityLifecycle.d.ts.map +1 -0
- package/dist/src/helpers/entity/entityLiveQuery.d.ts +1 -23
- package/dist/src/helpers/entity/entityLiveQuery.d.ts.map +1 -1
- package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts +4 -9
- package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts.map +1 -1
- package/dist/src/helpers/index.d.ts +2 -24
- package/dist/src/helpers/index.d.ts.map +1 -1
- package/dist/src/helpers/localImageBlobUrl.d.ts +7 -0
- package/dist/src/helpers/localImageBlobUrl.d.ts.map +1 -0
- package/dist/src/helpers/mediaRef.d.ts +3 -70
- package/dist/src/helpers/mediaRef.d.ts.map +1 -1
- package/dist/src/helpers/metadataPropertyNames.d.ts +34 -21
- package/dist/src/helpers/metadataPropertyNames.d.ts.map +1 -1
- package/dist/src/helpers/mimeTypes.d.ts +2 -1
- package/dist/src/helpers/mimeTypes.d.ts.map +1 -1
- package/dist/src/helpers/model.d.ts.map +1 -1
- package/dist/src/helpers/ownership.d.ts.map +1 -1
- package/dist/src/helpers/property.d.ts +21 -26
- package/dist/src/helpers/property.d.ts.map +1 -1
- package/dist/src/helpers/propertyDefinition.d.ts +59 -0
- package/dist/src/helpers/propertyDefinition.d.ts.map +1 -0
- package/dist/src/helpers/readHtmlBodyForStorageSeed.d.ts.map +1 -1
- package/dist/src/helpers/relationSeedRef.d.ts +0 -7
- package/dist/src/helpers/relationSeedRef.d.ts.map +1 -1
- package/dist/src/helpers/schema.d.ts +24 -38
- package/dist/src/helpers/schema.d.ts.map +1 -1
- package/dist/src/helpers/schemaApply.d.ts +135 -0
- package/dist/src/helpers/schemaApply.d.ts.map +1 -0
- package/dist/src/helpers/tabEvents.d.ts.map +1 -1
- package/dist/src/helpers/updateSchema.d.ts +2 -18
- package/dist/src/helpers/updateSchema.d.ts.map +1 -1
- package/dist/src/imports/index.d.ts +1 -1
- package/dist/src/imports/index.d.ts.map +1 -1
- package/dist/src/imports/json.d.ts +8 -78
- package/dist/src/imports/json.d.ts.map +1 -1
- package/dist/src/index.d.ts +16 -14
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/interfaces/IItem.d.ts +5 -0
- package/dist/src/interfaces/IItem.d.ts.map +1 -1
- package/dist/src/interfaces/IItemProperty.d.ts +13 -7
- package/dist/src/interfaces/IItemProperty.d.ts.map +1 -1
- package/dist/src/node/db/Db.d.ts.map +1 -1
- package/dist/src/node/index.d.ts +3 -2
- package/dist/src/node/index.d.ts.map +1 -1
- package/dist/src/outbox/conflicts.d.ts +2 -0
- package/dist/src/outbox/conflicts.d.ts.map +1 -1
- package/dist/src/outbox/itemAppliers.d.ts +70 -14
- package/dist/src/outbox/itemAppliers.d.ts.map +1 -1
- package/dist/src/outbox/outbox.d.ts +14 -3
- package/dist/src/outbox/outbox.d.ts.map +1 -1
- package/dist/src/outbox/pendingValues.d.ts +3 -1
- package/dist/src/outbox/pendingValues.d.ts.map +1 -1
- package/dist/src/outbox/storageValueRow.d.ts +7 -0
- package/dist/src/outbox/storageValueRow.d.ts.map +1 -0
- package/dist/src/platform/configurePlatform.d.ts.map +1 -1
- package/dist/src/platform/index.browser.d.ts.map +1 -1
- package/dist/src/platform/index.node.d.ts.map +1 -1
- package/dist/src/seedSchema/MetadataSchema.d.ts +17 -0
- package/dist/src/seedSchema/MetadataSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/ModelSchema.d.ts +19 -0
- package/dist/src/seedSchema/ModelSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/ModelSchemaSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/PendingWriteSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/SchemaSchema.d.ts +19 -0
- package/dist/src/seedSchema/SchemaSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/SeedSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/VersionSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/attestedUid.d.ts +9 -0
- package/dist/src/seedSchema/attestedUid.d.ts.map +1 -0
- package/dist/src/storageValue/content.d.ts +45 -0
- package/dist/src/storageValue/content.d.ts.map +1 -0
- package/dist/src/storageValue/findFile.d.ts +7 -0
- package/dist/src/storageValue/findFile.d.ts.map +1 -0
- package/dist/src/storageValue/resolve.d.ts +71 -0
- package/dist/src/storageValue/resolve.d.ts.map +1 -0
- package/dist/src/storageValue/save.d.ts +24 -0
- package/dist/src/storageValue/save.d.ts.map +1 -0
- package/dist/src/storageValue/stage.d.ts +22 -0
- package/dist/src/storageValue/stage.d.ts.map +1 -0
- package/dist/src/types/db.d.ts +0 -14
- package/dist/src/types/db.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +3 -3
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/machines.d.ts +1 -1
- package/dist/src/types/machines.d.ts.map +1 -1
- package/dist/src/types/property.d.ts +9 -16
- package/dist/src/types/property.d.ts.map +1 -1
- package/dist/src/types/publish.d.ts +1 -1
- package/dist/src/types/publish.d.ts.map +1 -1
- package/dist/{syncDbWithEas-DUu_wjUG.js → syncDbWithEas-CA7PvBgu.js} +142 -168
- package/dist/syncDbWithEas-CA7PvBgu.js.map +1 -0
- package/dist/tabEvents-CaVmngqr.js +3804 -0
- package/dist/tabEvents-CaVmngqr.js.map +1 -0
- package/dist/{tolerantWebAccess-DecKDGen.js → tolerantWebAccess-BJqViq08.js} +10 -15
- package/dist/{tolerantWebAccess-DecKDGen.js.map → tolerantWebAccess-BJqViq08.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-4gO9Hfn2.js → updateSeedRevokedAt-BL9Bg-G7.js} +30 -4
- package/dist/updateSeedRevokedAt-BL9Bg-G7.js.map +1 -0
- package/package.json +6 -6
- package/dist/ClientManager-GZfXErDX.js +0 -5279
- package/dist/ClientManager-GZfXErDX.js.map +0 -1
- package/dist/Item-0oDoTPhi.js.map +0 -1
- package/dist/ModelProperty-i5flwzQG.js.map +0 -1
- package/dist/Schema-PFZwG9Nl.js +0 -4370
- package/dist/Schema-PFZwG9Nl.js.map +0 -1
- package/dist/backfillMetadataPropertyIds-BbxgavEQ.js +0 -72
- package/dist/backfillMetadataPropertyIds-BbxgavEQ.js.map +0 -1
- package/dist/changeFeed-DKdVlUmt.js +0 -726
- package/dist/changeFeed-DKdVlUmt.js.map +0 -1
- package/dist/configurePlatform-CrMafpMW.js.map +0 -1
- package/dist/dist/ClientManager-GZfXErDX.d.ts +0 -952
- package/dist/dist/ClientManager-GZfXErDX.d.ts.map +0 -1
- package/dist/dist/Item-0oDoTPhi.d.ts +0 -1076
- package/dist/dist/Item-0oDoTPhi.d.ts.map +0 -1
- package/dist/dist/ModelProperty-i5flwzQG.d.ts +0 -315
- package/dist/dist/ModelProperty-i5flwzQG.d.ts.map +0 -1
- package/dist/dist/Schema-PFZwG9Nl.d.ts +0 -432
- package/dist/dist/Schema-PFZwG9Nl.d.ts.map +0 -1
- package/dist/dist/SchemaValidationService-DnGKel4V.d.ts +0 -118
- package/dist/dist/SchemaValidationService-DnGKel4V.d.ts.map +0 -1
- package/dist/dist/backfillMetadataPropertyIds-BbxgavEQ.d.ts +0 -7
- package/dist/dist/backfillMetadataPropertyIds-BbxgavEQ.d.ts.map +0 -1
- package/dist/dist/changeFeed-DKdVlUmt.d.ts +0 -160
- package/dist/dist/changeFeed-DKdVlUmt.d.ts.map +0 -1
- package/dist/dist/configurePlatform-CrMafpMW.d.ts.map +0 -1
- package/dist/dist/detachRowsBeforeDelete-DXFYSHRR.d.ts +0 -13
- package/dist/dist/detachRowsBeforeDelete-DXFYSHRR.d.ts.map +0 -1
- package/dist/dist/eas-dyepi5jz.d.ts +0 -12
- package/dist/dist/eas-dyepi5jz.d.ts.map +0 -1
- package/dist/dist/errors-C1qUEZ7A.d.ts +0 -25
- package/dist/dist/errors-C1qUEZ7A.d.ts.map +0 -1
- package/dist/dist/errors-D1zHAqjr.d.ts +0 -515
- package/dist/dist/errors-D1zHAqjr.d.ts.map +0 -1
- package/dist/dist/eventBus-7vxTCc3a.d.ts +0 -18
- package/dist/dist/eventBus-7vxTCc3a.d.ts.map +0 -1
- package/dist/dist/findSeedRowsByUid-CT3sOXXw.d.ts +0 -13
- package/dist/dist/findSeedRowsByUid-CT3sOXXw.d.ts.map +0 -1
- package/dist/dist/getItem-Bhjecbia.d.ts +0 -6
- package/dist/dist/getItem-Bhjecbia.d.ts.map +0 -1
- package/dist/dist/getPublishPayload-DH4rMqXG.d.ts +0 -47
- package/dist/dist/getPublishPayload-DH4rMqXG.d.ts.map +0 -1
- package/dist/dist/getPublishUploads-BzUIDA2G.d.ts +0 -89
- package/dist/dist/getPublishUploads-BzUIDA2G.d.ts.map +0 -1
- package/dist/dist/index-CkYb3wcU.d.ts +0 -14
- package/dist/dist/index-CkYb3wcU.d.ts.map +0 -1
- package/dist/dist/index-DJmWkVIK.d.ts +0 -6
- package/dist/dist/index-DJmWkVIK.d.ts.map +0 -1
- package/dist/dist/index-Dx_GTdyQ.d.ts.map +0 -1
- package/dist/dist/index.browser-i9uPJice.d.ts +0 -9908
- package/dist/dist/index.browser-i9uPJice.d.ts.map +0 -1
- package/dist/dist/mimeTypes-C9r76DCH.d.ts +0 -30
- package/dist/dist/mimeTypes-C9r76DCH.d.ts.map +0 -1
- package/dist/dist/model-oHA3YhOd.d.ts +0 -6
- package/dist/dist/model-oHA3YhOd.d.ts.map +0 -1
- package/dist/dist/modelPropertyRecordSchemas-C5lW9aA-.d.ts +0 -7
- package/dist/dist/modelPropertyRecordSchemas-C5lW9aA-.d.ts.map +0 -1
- package/dist/dist/platform.browser.d.ts +0 -3
- package/dist/dist/platform.browser.d.ts.map +0 -1
- package/dist/dist/property-BwYtg5Q_.d.ts +0 -37
- package/dist/dist/property-BwYtg5Q_.d.ts.map +0 -1
- package/dist/dist/propertyValidationRules-CyHdpcPP.d.ts +0 -13
- package/dist/dist/propertyValidationRules-CyHdpcPP.d.ts.map +0 -1
- package/dist/dist/publishDraftGraph-C5F6b7GK.d.ts +0 -93
- package/dist/dist/publishDraftGraph-C5F6b7GK.d.ts.map +0 -1
- package/dist/dist/resolveModelForSyncedSeed-4gO9Hfn2.d.ts +0 -21
- package/dist/dist/resolveModelForSyncedSeed-4gO9Hfn2.d.ts.map +0 -1
- package/dist/dist/syncDbWithEas-DUu_wjUG.d.ts +0 -13
- package/dist/dist/syncDbWithEas-DUu_wjUG.d.ts.map +0 -1
- package/dist/dist/tolerantWebAccess-DecKDGen.d.ts +0 -113
- package/dist/dist/tolerantWebAccess-DecKDGen.d.ts.map +0 -1
- package/dist/dist/updateSeedRevokedAt-CP606vKs.d.ts +0 -11
- package/dist/dist/updateSeedRevokedAt-CP606vKs.d.ts.map +0 -1
- package/dist/eas-dyepi5jz.js +0 -67
- package/dist/eas-dyepi5jz.js.map +0 -1
- package/dist/errors-D1zHAqjr.js +0 -4006
- package/dist/errors-D1zHAqjr.js.map +0 -1
- package/dist/eventBus-7vxTCc3a.js +0 -64
- package/dist/eventBus-7vxTCc3a.js.map +0 -1
- package/dist/findSeedRowsByUid-CT3sOXXw.js +0 -47
- package/dist/findSeedRowsByUid-CT3sOXXw.js.map +0 -1
- package/dist/getItem-Bhjecbia.js +0 -45
- package/dist/getItem-Bhjecbia.js.map +0 -1
- package/dist/getPublishPayload-DH4rMqXG.js +0 -1634
- package/dist/getPublishPayload-DH4rMqXG.js.map +0 -1
- package/dist/getPublishUploads-BzUIDA2G.js +0 -1080
- package/dist/getPublishUploads-BzUIDA2G.js.map +0 -1
- package/dist/index-CkYb3wcU.js +0 -29
- package/dist/index-CkYb3wcU.js.map +0 -1
- package/dist/index-DJmWkVIK.js.map +0 -1
- package/dist/index-Dx_GTdyQ.js +0 -4745
- package/dist/index-Dx_GTdyQ.js.map +0 -1
- package/dist/index-PbnKw2es.js.map +0 -1
- package/dist/index.browser-i9uPJice.js.map +0 -1
- package/dist/index.node-CzMwMr_d.js.map +0 -1
- package/dist/mimeTypes-C9r76DCH.js +0 -209
- package/dist/mimeTypes-C9r76DCH.js.map +0 -1
- package/dist/model-oHA3YhOd.js +0 -29
- package/dist/model-oHA3YhOd.js.map +0 -1
- package/dist/modelPropertyRecordSchemas-C5lW9aA-.js +0 -94
- package/dist/modelPropertyRecordSchemas-C5lW9aA-.js.map +0 -1
- package/dist/property-BwYtg5Q_.js +0 -289
- package/dist/property-BwYtg5Q_.js.map +0 -1
- package/dist/propertyValidationRules-CyHdpcPP.js +0 -73
- package/dist/propertyValidationRules-CyHdpcPP.js.map +0 -1
- package/dist/publishDraftGraph-C5F6b7GK.js +0 -505
- package/dist/publishDraftGraph-C5F6b7GK.js.map +0 -1
- package/dist/resolveModelForSyncedSeed-4gO9Hfn2.js.map +0 -1
- package/dist/src/Item/service/actors/loadOrCreateItem.d.ts +0 -5
- package/dist/src/Item/service/actors/loadOrCreateItem.d.ts.map +0 -1
- package/dist/src/Item/service/actors/waitForDb.d.ts +0 -4
- package/dist/src/Item/service/actors/waitForDb.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts +0 -5
- package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts +0 -5
- package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/index.d.ts +0 -6
- package/dist/src/ItemProperty/service/actors/saveValueToDb/index.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/rowContext.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveFile.d.ts +0 -24
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveFile.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveHtml.d.ts +0 -5
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveHtml.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts +0 -5
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts +0 -10
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/storageValue.d.ts +0 -22
- package/dist/src/ItemProperty/service/actors/saveValueToDb/storageValue.d.ts.map +0 -1
- package/dist/src/ItemProperty/service/actors/waitForDb.d.ts +0 -4
- package/dist/src/ItemProperty/service/actors/waitForDb.d.ts.map +0 -1
- package/dist/src/Model/service/actors/createModelProperties.d.ts +0 -9
- package/dist/src/Model/service/actors/createModelProperties.d.ts.map +0 -1
- package/dist/src/Model/service/actors/loadOrCreateModel.d.ts +0 -5
- package/dist/src/Model/service/actors/loadOrCreateModel.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/checkExistingSchema.d.ts +0 -5
- package/dist/src/Schema/service/actors/checkExistingSchema.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/createModelInstances.d.ts +0 -11
- package/dist/src/Schema/service/actors/createModelInstances.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/createPropertyInstances.d.ts +0 -12
- package/dist/src/Schema/service/actors/createPropertyInstances.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/validateSchema.d.ts +0 -5
- package/dist/src/Schema/service/actors/validateSchema.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/verifyModelInstancesInCache.d.ts +0 -6
- package/dist/src/Schema/service/actors/verifyModelInstancesInCache.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/verifyModelsInDb.d.ts +0 -7
- package/dist/src/Schema/service/actors/verifyModelsInDb.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/verifyPropertiesInDb.d.ts +0 -8
- package/dist/src/Schema/service/actors/verifyPropertiesInDb.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/verifyPropertyInstancesInCache.d.ts +0 -6
- package/dist/src/Schema/service/actors/verifyPropertyInstancesInCache.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/verifySchemaInDb.d.ts +0 -7
- package/dist/src/Schema/service/actors/verifySchemaInDb.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/writeModelsToDb.d.ts +0 -9
- package/dist/src/Schema/service/actors/writeModelsToDb.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/writePropertiesToDb.d.ts +0 -10
- package/dist/src/Schema/service/actors/writePropertiesToDb.d.ts.map +0 -1
- package/dist/src/Schema/service/actors/writeSchemaToDb.d.ts +0 -11
- package/dist/src/Schema/service/actors/writeSchemaToDb.d.ts.map +0 -1
- package/dist/src/browser/helpers/ArweaveClient.d.ts +0 -14
- package/dist/src/browser/helpers/ArweaveClient.d.ts.map +0 -1
- package/dist/src/browser/helpers/EasClient.d.ts +0 -10
- package/dist/src/browser/helpers/EasClient.d.ts.map +0 -1
- package/dist/src/browser/helpers/QueryClient.d.ts +0 -9
- package/dist/src/browser/helpers/QueryClient.d.ts.map +0 -1
- package/dist/src/client/actors/addModelsToStore.d.ts +0 -4
- package/dist/src/client/actors/addModelsToStore.d.ts.map +0 -1
- package/dist/src/db/backfillMetadataPropertyIds.d.ts +0 -7
- package/dist/src/db/backfillMetadataPropertyIds.d.ts.map +0 -1
- package/dist/src/db/read/getItem.d.ts +0 -3
- package/dist/src/db/read/getItem.d.ts.map +0 -1
- package/dist/src/db/read/getPropertyData.d.ts +0 -4
- package/dist/src/db/read/getPropertyData.d.ts.map +0 -1
- package/dist/src/db/read/getRelatedItemsForPublish.d.ts +0 -10
- package/dist/src/db/read/getRelatedItemsForPublish.d.ts.map +0 -1
- package/dist/src/db/read/getSeedData.d.ts +0 -12
- package/dist/src/db/read/getSeedData.d.ts.map +0 -1
- package/dist/src/db/read/itemLoads.d.ts +0 -20
- package/dist/src/db/read/itemLoads.d.ts.map +0 -1
- package/dist/src/db/read/publishDraftGraph.d.ts +0 -64
- package/dist/src/db/read/publishDraftGraph.d.ts.map +0 -1
- package/dist/src/db/write/linkModelToSchema.d.ts +0 -12
- package/dist/src/db/write/linkModelToSchema.d.ts.map +0 -1
- package/dist/src/helpers/ArweaveClient/BaseArweaveClient.d.ts +0 -2
- package/dist/src/helpers/ArweaveClient/BaseArweaveClient.d.ts.map +0 -1
- package/dist/src/helpers/ArweaveClient/arweaveL1UploadApi.d.ts +0 -2
- package/dist/src/helpers/ArweaveClient/arweaveL1UploadApi.d.ts.map +0 -1
- package/dist/src/helpers/ArweaveClient/selectReadGateway.d.ts +0 -2
- package/dist/src/helpers/ArweaveClient/selectReadGateway.d.ts.map +0 -1
- package/dist/src/helpers/ArweaveClient/uploadApiVerification.d.ts +0 -2
- package/dist/src/helpers/ArweaveClient/uploadApiVerification.d.ts.map +0 -1
- package/dist/src/helpers/EasClient/BaseEasClient.d.ts +0 -2
- package/dist/src/helpers/EasClient/BaseEasClient.d.ts.map +0 -1
- package/dist/src/helpers/QueryClient/BaseQueryClient.d.ts +0 -2
- package/dist/src/helpers/QueryClient/BaseQueryClient.d.ts.map +0 -1
- package/dist/src/helpers/easUid.d.ts +0 -2
- package/dist/src/helpers/easUid.d.ts.map +0 -1
- package/dist/src/helpers/entity/entityDestroy.d.ts +0 -49
- package/dist/src/helpers/entity/entityDestroy.d.ts.map +0 -1
- package/dist/src/helpers/entity/entityFind.d.ts +0 -52
- package/dist/src/helpers/entity/entityFind.d.ts.map +0 -1
- package/dist/src/helpers/entity/entityState.d.ts +0 -28
- package/dist/src/helpers/entity/entityState.d.ts.map +0 -1
- package/dist/src/helpers/entity/entityUnload.d.ts +0 -56
- package/dist/src/helpers/entity/entityUnload.d.ts.map +0 -1
- package/dist/src/helpers/entity/evictionEpoch.d.ts +0 -43
- package/dist/src/helpers/entity/evictionEpoch.d.ts.map +0 -1
- package/dist/src/helpers/entity/index.d.ts +0 -12
- package/dist/src/helpers/entity/index.d.ts.map +0 -1
- package/dist/src/helpers/gateway/gatewayState.d.ts +0 -2
- package/dist/src/helpers/gateway/gatewayState.d.ts.map +0 -1
- package/dist/src/helpers/gateway/resolveSeedGatewayEndpoints.d.ts +0 -2
- package/dist/src/helpers/gateway/resolveSeedGatewayEndpoints.d.ts.map +0 -1
- package/dist/src/helpers/gateway/seedGatewayConfig.d.ts +0 -2
- package/dist/src/helpers/gateway/seedGatewayConfig.d.ts.map +0 -1
- package/dist/src/helpers/getSchemaForItemProperty.d.ts +0 -15
- package/dist/src/helpers/getSchemaForItemProperty.d.ts.map +0 -1
- package/dist/src/helpers/getSegmentedItemProperties.d.ts +0 -10
- package/dist/src/helpers/getSegmentedItemProperties.d.ts.map +0 -1
- package/dist/src/helpers/isSqliteUniqueConstraintError.d.ts +0 -7
- package/dist/src/helpers/isSqliteUniqueConstraintError.d.ts.map +0 -1
- package/dist/src/helpers/propertyValidationRules.d.ts +0 -20
- package/dist/src/helpers/propertyValidationRules.d.ts.map +0 -1
- package/dist/src/helpers/propertyWriteTickets.d.ts +0 -11
- package/dist/src/helpers/propertyWriteTickets.d.ts.map +0 -1
- package/dist/src/helpers/reconcilePropertyDraftRows.d.ts +0 -10
- package/dist/src/helpers/reconcilePropertyDraftRows.d.ts.map +0 -1
- package/dist/src/helpers/waitForEntityIdle.d.ts +0 -21
- package/dist/src/helpers/waitForEntityIdle.d.ts.map +0 -1
- package/dist/src/interfaces/IQueryClient.d.ts +0 -15
- package/dist/src/interfaces/IQueryClient.d.ts.map +0 -1
- package/dist/src/node/helpers/ArweaveClient.d.ts +0 -5
- package/dist/src/node/helpers/ArweaveClient.d.ts.map +0 -1
- package/dist/src/node/helpers/EasClient.d.ts +0 -5
- package/dist/src/node/helpers/EasClient.d.ts.map +0 -1
- package/dist/src/node/helpers/QueryClient.d.ts +0 -5
- package/dist/src/node/helpers/QueryClient.d.ts.map +0 -1
- package/dist/src/services/write/actors/validateEntity.d.ts +0 -6
- package/dist/src/services/write/actors/validateEntity.d.ts.map +0 -1
- package/dist/src/services/write/actors/writeToDatabase.d.ts +0 -14
- package/dist/src/services/write/actors/writeToDatabase.d.ts.map +0 -1
- package/dist/src/services/write/writeProcessMachine.d.ts +0 -56
- package/dist/src/services/write/writeProcessMachine.d.ts.map +0 -1
- package/dist/src/stores/eas.d.ts +0 -2
- package/dist/src/stores/eas.d.ts.map +0 -1
- package/dist/src/types/arweave.d.ts +0 -57
- package/dist/src/types/arweave.d.ts.map +0 -1
- package/dist/src/types/gateway.d.ts +0 -2
- package/dist/src/types/gateway.d.ts.map +0 -1
- package/dist/syncDbWithEas-DUu_wjUG.js.map +0 -1
- package/dist/updateSeedRevokedAt-CP606vKs.js +0 -31
- package/dist/updateSeedRevokedAt-CP606vKs.js.map +0 -1
|
@@ -1,22 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ay as withDbTabLock, az as MIME_TO_EXTENSION, aA as sniffMimeType, ak as contentSha256TagMatches, aB as notifyFilesWrittenOutsideCache, aC as createSessionObjectUrl, aD as withSeedDbLock, aE as countDbStatements, aF as startChangeFeed, aG as countLiveQueryRuns } from './tabEvents-CaVmngqr.js';
|
|
2
|
+
import { B as BaseDb, a as appState, w as BaseFileManager, y as withSqliteBusyRetry } from './BaseFileManager-BAlySv8w.js';
|
|
3
3
|
import { eq, sql } from 'drizzle-orm';
|
|
4
|
-
import { M as MIME_TO_EXTENSION } from './mimeTypes-C9r76DCH.js';
|
|
5
4
|
import debug from 'debug';
|
|
6
5
|
import { F as FileSystemLockedError, D as DatabaseNotPersistentError } from './errors-C1qUEZ7A.js';
|
|
7
6
|
import { drizzle } from 'drizzle-orm/sqlite-proxy';
|
|
8
7
|
import { sha256 } from '@noble/hashes/sha256';
|
|
9
8
|
import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';
|
|
10
|
-
import {
|
|
9
|
+
import { DefaultArweaveClient } from '@seedprotocol/arweave';
|
|
10
|
+
import 'pluralize';
|
|
11
|
+
import { DefaultQueryClient, DefaultEasClient } from '@seedprotocol/eas';
|
|
12
|
+
import { s as schema } from './index-D0V-mjCV.js';
|
|
11
13
|
import { SQLocalDrizzle } from 'sqlocal/drizzle';
|
|
12
14
|
import { r as recreateIfOlderThanMinimumUpgradeVersion } from './minimumUpgradeVersion-BDhHvHtr.js';
|
|
13
15
|
import { throwError, Observable, distinctUntilChanged, finalize, share, ReplaySubject } from 'rxjs';
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
import './configurePlatform-CiOJ1R3q.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* String classification for stored values. Each function is self-contained (no imports, no
|
|
20
|
+
* module-level references) because the download worker gets them as source text: see
|
|
21
|
+
* `browser/workers/filesDownload.ts`.
|
|
22
|
+
*/
|
|
23
|
+
/** MIME type of a `data:` URL, or null. */
|
|
24
|
+
const getMimeType = (base64) => {
|
|
25
|
+
if (!base64) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const result = base64.match(/^data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,/);
|
|
29
|
+
if (result && result.length > 1) {
|
|
30
|
+
return result[1];
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return null; // MIME type could not be determined
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
/** What a stored string looks like: bare base64, a base64 image data URL, or a URL. */
|
|
37
|
+
const getDataTypeFromString = (data) => {
|
|
38
|
+
const nonImageBase64Regex = /^(?!data:image\/(?:jpeg|png|gif|bmp|webp);base64,)[A-Za-z0-9+/=]+$/;
|
|
39
|
+
if (nonImageBase64Regex.test(data)) {
|
|
40
|
+
return 'base64';
|
|
41
|
+
}
|
|
42
|
+
// Regular expression for base64 (simple version, checking for base64 format)
|
|
43
|
+
const imageBase64Regex = /^data:image\/[a-zA-Z]+;base64,[A-Za-z0-9+/]+={0,2}$/;
|
|
44
|
+
if (imageBase64Regex.test(data)) {
|
|
45
|
+
return 'imageBase64';
|
|
46
|
+
}
|
|
47
|
+
// Blob URLs are fetchable but session-scoped; recognize them as url type
|
|
48
|
+
if (data.startsWith('blob:')) {
|
|
49
|
+
return 'url';
|
|
50
|
+
}
|
|
51
|
+
// Regular expression for URL (simple version, checking for common URL format)
|
|
52
|
+
const urlRegex = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/;
|
|
53
|
+
if (urlRegex.test(data)) {
|
|
54
|
+
return 'url';
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
};
|
|
20
58
|
|
|
21
59
|
const KEY = 'excludedTransactions';
|
|
22
60
|
/**
|
|
@@ -53,6 +91,9 @@ async function addExcludedTransactions(transactionIds) {
|
|
|
53
91
|
}
|
|
54
92
|
|
|
55
93
|
var filesDownload = `const SEED_MIME_TO_EXTENSION = ${JSON.stringify(MIME_TO_EXTENSION)};
|
|
94
|
+
const seedSniffMimeType = ${sniffMimeType.toString()};
|
|
95
|
+
const seedGetMimeType = ${getMimeType.toString()};
|
|
96
|
+
const seedGetDataTypeFromString = ${getDataTypeFromString.toString()};
|
|
56
97
|
(
|
|
57
98
|
${function () {
|
|
58
99
|
const identifyString = (str) => {
|
|
@@ -79,35 +120,6 @@ var filesDownload = `const SEED_MIME_TO_EXTENSION = ${JSON.stringify(MIME_TO_EXT
|
|
|
79
120
|
// Default to plain text if unsure
|
|
80
121
|
return 'text';
|
|
81
122
|
};
|
|
82
|
-
const getMimeType = (base64) => {
|
|
83
|
-
if (!base64) {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
const result = base64.match(/^data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,/);
|
|
87
|
-
if (result && result.length > 1) {
|
|
88
|
-
return result[1];
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
return null; // MIME type could not be determined
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
const getDataTypeFromString = (data) => {
|
|
95
|
-
const nonImageBase64Regex = /^(?!data:image\/(?:jpeg|png|gif|bmp|webp);base64,)[A-Za-z0-9+/=]+$/;
|
|
96
|
-
if (nonImageBase64Regex.test(data)) {
|
|
97
|
-
return 'base64';
|
|
98
|
-
}
|
|
99
|
-
// Regular expression for base64 (simple version, checking for base64 format)
|
|
100
|
-
const imageBase64Regex = /^data:image\/[a-zA-Z]+;base64,[A-Za-z0-9+/]+={0,2}$/;
|
|
101
|
-
if (imageBase64Regex.test(data)) {
|
|
102
|
-
return 'imageBase64';
|
|
103
|
-
}
|
|
104
|
-
// Regular expression for URL (simple version, checking for common URL format)
|
|
105
|
-
const urlRegex = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/;
|
|
106
|
-
if (urlRegex.test(data)) {
|
|
107
|
-
return 'url';
|
|
108
|
-
}
|
|
109
|
-
return null;
|
|
110
|
-
};
|
|
111
123
|
const isBinary = (arrayBuffer) => {
|
|
112
124
|
const view = new Uint8Array(arrayBuffer);
|
|
113
125
|
let nonTextCount = 0;
|
|
@@ -284,30 +296,7 @@ var filesDownload = `const SEED_MIME_TO_EXTENSION = ${JSON.stringify(MIME_TO_EXT
|
|
|
284
296
|
*/
|
|
285
297
|
const transformDownloadedContent = async (bytes, _context) => bytes;
|
|
286
298
|
/** True when the bytes start with the signature of an image format the SDK stores in `images/`. */
|
|
287
|
-
const hasImageSignature = (bytes) =>
|
|
288
|
-
const at = (offset, ...sig) => sig.every((b, i) => bytes[offset + i] === b);
|
|
289
|
-
const ascii = (offset, s) => at(offset, ...Array.from(s).map((c) => c.charCodeAt(0)));
|
|
290
|
-
if (at(0, 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a))
|
|
291
|
-
return true; // PNG
|
|
292
|
-
if (at(0, 0xff, 0xd8, 0xff))
|
|
293
|
-
return true; // JPEG
|
|
294
|
-
if (ascii(0, 'GIF87a') || ascii(0, 'GIF89a'))
|
|
295
|
-
return true;
|
|
296
|
-
if (ascii(0, 'RIFF') && ascii(8, 'WEBP'))
|
|
297
|
-
return true;
|
|
298
|
-
if (ascii(0, 'BM'))
|
|
299
|
-
return true; // BMP
|
|
300
|
-
if (at(0, 0x00, 0x00, 0x01, 0x00))
|
|
301
|
-
return true; // ICO
|
|
302
|
-
if (at(0, 0x49, 0x49, 0x2a, 0x00) || at(0, 0x4d, 0x4d, 0x00, 0x2a))
|
|
303
|
-
return true; // TIFF
|
|
304
|
-
if (ascii(4, 'ftyp')) {
|
|
305
|
-
// ISO-BMFF images (AVIF / HEIC); ftyp is also MP4, so check the brand
|
|
306
|
-
const brand = String.fromCharCode(...Array.from(bytes.slice(8, 12)));
|
|
307
|
-
return ['avif', 'avis', 'heic', 'heix', 'heif', 'mif1', 'msf1'].includes(brand);
|
|
308
|
-
}
|
|
309
|
-
return false;
|
|
310
|
-
};
|
|
299
|
+
const hasImageSignature = (bytes) => (seedSniffMimeType(bytes) || '').startsWith('image/');
|
|
311
300
|
/**
|
|
312
301
|
* Content-Types that say nothing about the content: these are sniffed instead. `text/plain` is
|
|
313
302
|
* here because some gateways send it for anything textual.
|
|
@@ -585,7 +574,7 @@ var filesDownload = `const SEED_MIME_TO_EXTENSION = ${JSON.stringify(MIME_TO_EXT
|
|
|
585
574
|
if (textType !== 'json' &&
|
|
586
575
|
textType !== 'base64' &&
|
|
587
576
|
textType !== 'html') {
|
|
588
|
-
const possibleImageType =
|
|
577
|
+
const possibleImageType = seedGetDataTypeFromString(dataString);
|
|
589
578
|
if (!possibleImageType) {
|
|
590
579
|
// Plain text / markdown / anything else textual.
|
|
591
580
|
await saveToFiles(bytes);
|
|
@@ -620,7 +609,7 @@ var filesDownload = `const SEED_MIME_TO_EXTENSION = ${JSON.stringify(MIME_TO_EXT
|
|
|
620
609
|
}
|
|
621
610
|
let fileName = transactionId;
|
|
622
611
|
if (textType === 'base64') {
|
|
623
|
-
const mimeType =
|
|
612
|
+
const mimeType = seedGetMimeType(dataString);
|
|
624
613
|
const isDataUri = dataString.startsWith('data:');
|
|
625
614
|
// Remove the Base64 header if it exists (e.g., "data:image/png;base64,")
|
|
626
615
|
const binaryData = decodeBase64(dataString.split(',').pop() || '');
|
|
@@ -675,7 +664,7 @@ var filesDownload = `const SEED_MIME_TO_EXTENSION = ${JSON.stringify(MIME_TO_EXT
|
|
|
675
664
|
}.toString()}
|
|
676
665
|
)()`;
|
|
677
666
|
|
|
678
|
-
const logger$
|
|
667
|
+
const logger$4 = debug('seedSdk:browser:workers:FileDownloader');
|
|
679
668
|
/**
|
|
680
669
|
* Longest the worker may go without posting anything before the download is failed. The worker
|
|
681
670
|
* posts after every transaction and each gateway request times out after 60s, so this only fires
|
|
@@ -746,7 +735,7 @@ class FileDownloader {
|
|
|
746
735
|
return;
|
|
747
736
|
settled = true;
|
|
748
737
|
cleanup();
|
|
749
|
-
logger$
|
|
738
|
+
logger$4('file download failed', error);
|
|
750
739
|
// Files the worker already wrote are on disk: refresh caches for them anyway.
|
|
751
740
|
if (savedPaths.length) {
|
|
752
741
|
void notifyFilesWrittenOutsideCache(savedPaths).catch(() => { });
|
|
@@ -777,7 +766,7 @@ class FileDownloader {
|
|
|
777
766
|
worker.onmessage = (e) => {
|
|
778
767
|
armWatchdog();
|
|
779
768
|
const data = e.data ?? {};
|
|
780
|
-
logger$
|
|
769
|
+
logger$4('filesDownload main thread onmessage', data);
|
|
781
770
|
if (data.message === 'excludeTransaction') {
|
|
782
771
|
localExcludedTransactions.add(data.transactionId);
|
|
783
772
|
}
|
|
@@ -791,14 +780,14 @@ class FileDownloader {
|
|
|
791
780
|
ok = contentSha256TagMatches(new Uint8Array(data.bytes), String(data.expected ?? ''));
|
|
792
781
|
}
|
|
793
782
|
catch (error) {
|
|
794
|
-
logger$
|
|
783
|
+
logger$4('content verification failed', error);
|
|
795
784
|
}
|
|
796
785
|
worker.postMessage({ message: 'verifyContentResult', requestId: data.requestId, ok });
|
|
797
786
|
return;
|
|
798
787
|
}
|
|
799
788
|
if (data.message === 'compositeChildUnrouted') {
|
|
800
789
|
// No local ItemStorage property for this child (e.g. its item is not synced yet).
|
|
801
|
-
logger$
|
|
790
|
+
logger$4(`composite ${data.transactionId}: no local path for child "${data.name}"; not saved`);
|
|
802
791
|
}
|
|
803
792
|
if (data.message === 'contentVerified') {
|
|
804
793
|
verified.add(data.transactionId);
|
|
@@ -838,7 +827,7 @@ class FileDownloader {
|
|
|
838
827
|
expectedContentHashes,
|
|
839
828
|
compositeChildPaths,
|
|
840
829
|
skipExisting,
|
|
841
|
-
debug: logger$
|
|
830
|
+
debug: logger$4.enabled,
|
|
842
831
|
filesRoot: BaseFileManager.getWorkingDir(),
|
|
843
832
|
});
|
|
844
833
|
}
|
|
@@ -851,7 +840,8 @@ class FileDownloader {
|
|
|
851
840
|
}
|
|
852
841
|
}
|
|
853
842
|
|
|
854
|
-
var imageResize = `(
|
|
843
|
+
var imageResize = `const seedSniffMimeType = ${sniffMimeType.toString()};
|
|
844
|
+
(
|
|
855
845
|
${function () {
|
|
856
846
|
const getFileHandle = async (path, rootHandle = null) => {
|
|
857
847
|
// Split the path into segments
|
|
@@ -905,25 +895,10 @@ var imageResize = `(
|
|
|
905
895
|
/** Infer MIME from magic bytes. OPFS File may have empty type, causing createImageBitmap to fail. */
|
|
906
896
|
async function getBlobWithInferredMime(file) {
|
|
907
897
|
const buf = await file.arrayBuffer();
|
|
908
|
-
const bytes = new Uint8Array(buf);
|
|
909
898
|
let mime = file.type;
|
|
910
899
|
if (!mime || mime === '') {
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
else if (bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47)
|
|
914
|
-
mime = 'image/png';
|
|
915
|
-
else if (bytes[0] === 0x52 && bytes[1] === 0x49 && bytes[2] === 0x46 && bytes[3] === 0x46 && bytes[8] === 0x57 && bytes[9] === 0x45 && bytes[10] === 0x42 && bytes[11] === 0x50)
|
|
916
|
-
mime = 'image/webp';
|
|
917
|
-
else if (bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46)
|
|
918
|
-
mime = 'image/gif';
|
|
919
|
-
else if (bytes[0] === 0x42 && bytes[1] === 0x4d)
|
|
920
|
-
mime = 'image/bmp';
|
|
921
|
-
else if (bytes[4] === 0x66 && bytes[5] === 0x74 && bytes[6] === 0x79 && bytes[7] === 0x70 && bytes[8] === 0x61 && bytes[9] === 0x76 && bytes[10] === 0x69 && bytes[11] === 0x66)
|
|
922
|
-
mime = 'image/avif';
|
|
923
|
-
else if (bytes[4] === 0x66 && bytes[5] === 0x74 && bytes[6] === 0x79 && bytes[7] === 0x70 && bytes[8] === 0x68 && bytes[9] === 0x65 && bytes[10] === 0x69 && bytes[11] === 0x63)
|
|
924
|
-
mime = 'image/heic';
|
|
925
|
-
else
|
|
926
|
-
mime = 'image/jpeg';
|
|
900
|
+
const sniffed = seedSniffMimeType(new Uint8Array(buf));
|
|
901
|
+
mime = sniffed && sniffed.startsWith('image/') ? sniffed : 'image/jpeg';
|
|
927
902
|
}
|
|
928
903
|
return new Blob([buf], { type: mime });
|
|
929
904
|
}
|
|
@@ -1239,7 +1214,7 @@ var imageResize = `(
|
|
|
1239
1214
|
}.toString()}
|
|
1240
1215
|
)()`;
|
|
1241
1216
|
|
|
1242
|
-
const logger$
|
|
1217
|
+
const logger$3 = debug('seedSdk:browser:workers:ImageResizer');
|
|
1243
1218
|
class ImageResizer {
|
|
1244
1219
|
constructor() {
|
|
1245
1220
|
this.workersArchive = new Map();
|
|
@@ -1250,18 +1225,18 @@ class ImageResizer {
|
|
|
1250
1225
|
if (this.workersArchive.has(filePath)) {
|
|
1251
1226
|
const savedWorker = this.workersArchive.get(filePath);
|
|
1252
1227
|
savedWorker?.terminate();
|
|
1253
|
-
logger$
|
|
1228
|
+
logger$3('[ImageResizer.resize] Terminated worker for filePath due to incoming request', filePath);
|
|
1254
1229
|
this.workersArchive.delete(filePath);
|
|
1255
1230
|
}
|
|
1256
1231
|
const worker = new Worker(this.workerBlobUrl);
|
|
1257
1232
|
this.workersArchive.set(filePath, worker);
|
|
1258
1233
|
return new Promise((resolve, reject) => {
|
|
1259
1234
|
worker.onmessage = (e) => {
|
|
1260
|
-
logger$
|
|
1235
|
+
logger$3('[ImageResizer.resize] main thread onmessage', e.data);
|
|
1261
1236
|
if (e.data.done) {
|
|
1262
1237
|
const savedWorker = this.workersArchive.get(filePath);
|
|
1263
1238
|
savedWorker?.terminate();
|
|
1264
|
-
logger$
|
|
1239
|
+
logger$3('[ImageResizer.resize] Terminated worker for filePath due to done', filePath);
|
|
1265
1240
|
this.workersArchive.delete(filePath);
|
|
1266
1241
|
// The worker wrote the variant to OPFS directly; refresh caches here and in other tabs.
|
|
1267
1242
|
notifyFilesWrittenOutsideCache([e.data.filePath]).then(() => resolve(e.data), () => resolve(e.data));
|
|
@@ -1277,7 +1252,7 @@ class ImageResizer {
|
|
|
1277
1252
|
filePath,
|
|
1278
1253
|
width,
|
|
1279
1254
|
height,
|
|
1280
|
-
debug: logger$
|
|
1255
|
+
debug: logger$3.enabled,
|
|
1281
1256
|
});
|
|
1282
1257
|
});
|
|
1283
1258
|
}
|
|
@@ -1315,7 +1290,7 @@ function isSkippableOpfsEntryError(error) {
|
|
|
1315
1290
|
return error instanceof DOMException && SKIPPABLE_ENTRY_ERRORS.has(error.name);
|
|
1316
1291
|
}
|
|
1317
1292
|
|
|
1318
|
-
const logger$
|
|
1293
|
+
const logger$2 = debug('seedSdk:browser:helpers:FileManager');
|
|
1319
1294
|
/**
|
|
1320
1295
|
* Browser-safe path helpers for SDK virtual file paths.
|
|
1321
1296
|
* We intentionally avoid Node/CJS path polyfills here to keep browser bundles ESM-safe.
|
|
@@ -1465,9 +1440,9 @@ class BrowserFileManager {
|
|
|
1465
1440
|
}
|
|
1466
1441
|
async initializeFileSystem(_workingDir) {
|
|
1467
1442
|
const zenfs = await this.getFs();
|
|
1468
|
-
const { TolerantWebAccess, TolerantWebAccessFS } = await import('./tolerantWebAccess-
|
|
1469
|
-
const _mod_0 = await import('./
|
|
1470
|
-
const _ns_0 = _mod_0.
|
|
1443
|
+
const { TolerantWebAccess, TolerantWebAccessFS } = await import('./tolerantWebAccess-BJqViq08.js');
|
|
1444
|
+
const _mod_0 = await import('./tabEvents-CaVmngqr.js');
|
|
1445
|
+
const _ns_0 = _mod_0.bm;
|
|
1471
1446
|
const { queueFilesChangedNotice } = _ns_0;
|
|
1472
1447
|
const { configureSingle } = zenfs;
|
|
1473
1448
|
const configureRoot = async () => {
|
|
@@ -1498,7 +1473,7 @@ class BrowserFileManager {
|
|
|
1498
1473
|
if (attempt === MOUNT_RETRY_DELAYS_MS.length) {
|
|
1499
1474
|
throw new FileSystemLockedError(error);
|
|
1500
1475
|
}
|
|
1501
|
-
logger$
|
|
1476
|
+
logger$2(`OPFS mount attempt ${attempt + 1} failed (${error?.name}); retrying`);
|
|
1502
1477
|
await sleep(MOUNT_RETRY_DELAYS_MS[attempt]);
|
|
1503
1478
|
}
|
|
1504
1479
|
}
|
|
@@ -1535,7 +1510,7 @@ class BrowserFileManager {
|
|
|
1535
1510
|
}
|
|
1536
1511
|
async invalidateNow(filePaths) {
|
|
1537
1512
|
const { mounts } = await this.getFs();
|
|
1538
|
-
const { TolerantWebAccessFS } = await import('./tolerantWebAccess-
|
|
1513
|
+
const { TolerantWebAccessFS } = await import('./tolerantWebAccess-BJqViq08.js');
|
|
1539
1514
|
const mounted = mounts.get('/');
|
|
1540
1515
|
if (!(mounted instanceof TolerantWebAccessFS))
|
|
1541
1516
|
return;
|
|
@@ -1545,7 +1520,7 @@ class BrowserFileManager {
|
|
|
1545
1520
|
await mounted.invalidate(absolute);
|
|
1546
1521
|
}
|
|
1547
1522
|
catch (error) {
|
|
1548
|
-
logger$
|
|
1523
|
+
logger$2(`could not refresh cached ${absolute}`, error);
|
|
1549
1524
|
}
|
|
1550
1525
|
}
|
|
1551
1526
|
}
|
|
@@ -1582,7 +1557,7 @@ class BrowserFileManager {
|
|
|
1582
1557
|
}
|
|
1583
1558
|
catch {
|
|
1584
1559
|
// This is a no-op. We tried to create a directory that already exists.
|
|
1585
|
-
logger$
|
|
1560
|
+
logger$2('Attempted to create a directory that already exists');
|
|
1586
1561
|
}
|
|
1587
1562
|
}
|
|
1588
1563
|
}
|
|
@@ -1604,7 +1579,7 @@ class BrowserFileManager {
|
|
|
1604
1579
|
const startTime = Date.now();
|
|
1605
1580
|
let isBusy = false;
|
|
1606
1581
|
const cancelableInterval = new CancelableInterval(async (stop) => {
|
|
1607
|
-
logger$
|
|
1582
|
+
logger$2('waitForFile', filePath);
|
|
1608
1583
|
if (isBusy) {
|
|
1609
1584
|
return;
|
|
1610
1585
|
}
|
|
@@ -1697,7 +1672,7 @@ class BrowserFileManager {
|
|
|
1697
1672
|
const startTime = Date.now();
|
|
1698
1673
|
let isBusy = false;
|
|
1699
1674
|
const cancelableInterval = new CancelableInterval(async (stop) => {
|
|
1700
|
-
logger$
|
|
1675
|
+
logger$2('waitForFileWithContent', filePath);
|
|
1701
1676
|
if (isBusy) {
|
|
1702
1677
|
return;
|
|
1703
1678
|
}
|
|
@@ -1909,7 +1884,7 @@ class CancelableInterval {
|
|
|
1909
1884
|
}
|
|
1910
1885
|
catch (error) {
|
|
1911
1886
|
if (error instanceof DOMException && error.name === 'AbortError') {
|
|
1912
|
-
logger$
|
|
1887
|
+
logger$2('Previous task was canceled.');
|
|
1913
1888
|
}
|
|
1914
1889
|
else {
|
|
1915
1890
|
console.error('Task error:', error);
|
|
@@ -2386,6 +2361,222 @@ DELETE FROM \`seeds\` WHERE \`local_id\` IN (
|
|
|
2386
2361
|
)
|
|
2387
2362
|
);
|
|
2388
2363
|
`;
|
|
2364
|
+
const migrationSql_0025_add_metadata_retract = `ALTER TABLE \`metadata\` ADD \`retract\` integer;`;
|
|
2365
|
+
const migrationSql_0026_add_content_hash_to_schemas = `ALTER TABLE \`schemas\` ADD \`content_hash\` text;`;
|
|
2366
|
+
const migrationSql_0027_link_metadata_property_ids = `-- Links metadata rows written without property_id to their property (decision D4: readers match
|
|
2367
|
+
-- rows by property_id). Only rows whose seed records its model (seeds.model_file_id) are linked,
|
|
2368
|
+
-- and only to one of that model's properties. Rows that match no property, or several, keep NULL
|
|
2369
|
+
-- and are read by name.
|
|
2370
|
+
--
|
|
2371
|
+
-- First the rows whose stored name is a property's key (unique per model).
|
|
2372
|
+
UPDATE \`metadata\` SET \`property_id\` = (
|
|
2373
|
+
SELECT \`p\`.\`id\` FROM \`seeds\` \`s\`
|
|
2374
|
+
JOIN \`models\` \`m\` ON \`m\`.\`schema_file_id\` = \`s\`.\`model_file_id\`
|
|
2375
|
+
JOIN \`properties\` \`p\` ON \`p\`.\`model_id\` = \`m\`.\`id\`
|
|
2376
|
+
WHERE \`s\`.\`local_id\` = \`metadata\`.\`seed_local_id\` AND \`p\`.\`name\` = \`metadata\`.\`property_name\`
|
|
2377
|
+
)
|
|
2378
|
+
WHERE \`property_id\` IS NULL AND EXISTS (
|
|
2379
|
+
SELECT 1 FROM \`seeds\` \`s\`
|
|
2380
|
+
JOIN \`models\` \`m\` ON \`m\`.\`schema_file_id\` = \`s\`.\`model_file_id\`
|
|
2381
|
+
JOIN \`properties\` \`p\` ON \`p\`.\`model_id\` = \`m\`.\`id\`
|
|
2382
|
+
WHERE \`s\`.\`local_id\` = \`metadata\`.\`seed_local_id\` AND \`p\`.\`name\` = \`metadata\`.\`property_name\`
|
|
2383
|
+
);
|
|
2384
|
+
--> statement-breakpoint
|
|
2385
|
+
-- Then the other stored forms, when exactly one property matches: \`<key>Id\` for an Image, File,
|
|
2386
|
+
-- Html or Relation, and a List of Relation's \`<singular key><Ref>Ids\` (singular as \`key\` minus a
|
|
2387
|
+
-- trailing \`s\` or \`es\`, or \`ies\` → \`y\`; other plurals stay NULL).
|
|
2388
|
+
UPDATE \`metadata\` SET \`property_id\` = (
|
|
2389
|
+
SELECT \`p\`.\`id\` FROM \`seeds\` \`s\`
|
|
2390
|
+
JOIN \`models\` \`m\` ON \`m\`.\`schema_file_id\` = \`s\`.\`model_file_id\`
|
|
2391
|
+
JOIN \`properties\` \`p\` ON \`p\`.\`model_id\` = \`m\`.\`id\`
|
|
2392
|
+
LEFT JOIN \`models\` \`r\` ON \`r\`.\`id\` = \`p\`.\`ref_model_id\`
|
|
2393
|
+
WHERE \`s\`.\`local_id\` = \`metadata\`.\`seed_local_id\` AND (
|
|
2394
|
+
(
|
|
2395
|
+
(\`p\`.\`data_type\` IN ('Image', 'File', 'Html', 'Relation') OR \`p\`.\`ref_value_type\` IN ('Image', 'File', 'Html', 'Relation'))
|
|
2396
|
+
AND \`p\`.\`name\` || 'Id' = \`metadata\`.\`property_name\`
|
|
2397
|
+
) OR (
|
|
2398
|
+
\`p\`.\`data_type\` = 'List' AND \`r\`.\`name\` IS NOT NULL
|
|
2399
|
+
AND length(\`metadata\`.\`property_name\`) > length(\`r\`.\`name\`) + 3
|
|
2400
|
+
AND substr(\`metadata\`.\`property_name\`, -(length(\`r\`.\`name\`) + 3)) = \`r\`.\`name\` || 'Ids'
|
|
2401
|
+
AND (
|
|
2402
|
+
\`p\`.\`name\` IN (
|
|
2403
|
+
substr(\`metadata\`.\`property_name\`, 1, length(\`metadata\`.\`property_name\`) - length(\`r\`.\`name\`) - 3),
|
|
2404
|
+
substr(\`metadata\`.\`property_name\`, 1, length(\`metadata\`.\`property_name\`) - length(\`r\`.\`name\`) - 3) || 's',
|
|
2405
|
+
substr(\`metadata\`.\`property_name\`, 1, length(\`metadata\`.\`property_name\`) - length(\`r\`.\`name\`) - 3) || 'es'
|
|
2406
|
+
) OR (
|
|
2407
|
+
substr(\`metadata\`.\`property_name\`, length(\`metadata\`.\`property_name\`) - length(\`r\`.\`name\`) - 3, 1) = 'y'
|
|
2408
|
+
AND \`p\`.\`name\` = substr(\`metadata\`.\`property_name\`, 1, length(\`metadata\`.\`property_name\`) - length(\`r\`.\`name\`) - 4) || 'ies'
|
|
2409
|
+
)
|
|
2410
|
+
)
|
|
2411
|
+
)
|
|
2412
|
+
)
|
|
2413
|
+
)
|
|
2414
|
+
WHERE \`property_id\` IS NULL AND (
|
|
2415
|
+
SELECT COUNT(*) FROM \`seeds\` \`s\`
|
|
2416
|
+
JOIN \`models\` \`m\` ON \`m\`.\`schema_file_id\` = \`s\`.\`model_file_id\`
|
|
2417
|
+
JOIN \`properties\` \`p\` ON \`p\`.\`model_id\` = \`m\`.\`id\`
|
|
2418
|
+
LEFT JOIN \`models\` \`r\` ON \`r\`.\`id\` = \`p\`.\`ref_model_id\`
|
|
2419
|
+
WHERE \`s\`.\`local_id\` = \`metadata\`.\`seed_local_id\` AND (
|
|
2420
|
+
(
|
|
2421
|
+
(\`p\`.\`data_type\` IN ('Image', 'File', 'Html', 'Relation') OR \`p\`.\`ref_value_type\` IN ('Image', 'File', 'Html', 'Relation'))
|
|
2422
|
+
AND \`p\`.\`name\` || 'Id' = \`metadata\`.\`property_name\`
|
|
2423
|
+
) OR (
|
|
2424
|
+
\`p\`.\`data_type\` = 'List' AND \`r\`.\`name\` IS NOT NULL
|
|
2425
|
+
AND length(\`metadata\`.\`property_name\`) > length(\`r\`.\`name\`) + 3
|
|
2426
|
+
AND substr(\`metadata\`.\`property_name\`, -(length(\`r\`.\`name\`) + 3)) = \`r\`.\`name\` || 'Ids'
|
|
2427
|
+
AND (
|
|
2428
|
+
\`p\`.\`name\` IN (
|
|
2429
|
+
substr(\`metadata\`.\`property_name\`, 1, length(\`metadata\`.\`property_name\`) - length(\`r\`.\`name\`) - 3),
|
|
2430
|
+
substr(\`metadata\`.\`property_name\`, 1, length(\`metadata\`.\`property_name\`) - length(\`r\`.\`name\`) - 3) || 's',
|
|
2431
|
+
substr(\`metadata\`.\`property_name\`, 1, length(\`metadata\`.\`property_name\`) - length(\`r\`.\`name\`) - 3) || 'es'
|
|
2432
|
+
) OR (
|
|
2433
|
+
substr(\`metadata\`.\`property_name\`, length(\`metadata\`.\`property_name\`) - length(\`r\`.\`name\`) - 3, 1) = 'y'
|
|
2434
|
+
AND \`p\`.\`name\` = substr(\`metadata\`.\`property_name\`, 1, length(\`metadata\`.\`property_name\`) - length(\`r\`.\`name\`) - 4) || 'ies'
|
|
2435
|
+
)
|
|
2436
|
+
)
|
|
2437
|
+
)
|
|
2438
|
+
)
|
|
2439
|
+
) = 1;
|
|
2440
|
+
`;
|
|
2441
|
+
const migrationSql_0028_add_definition_to_properties = `ALTER TABLE \`properties\` ADD \`definition\` text;
|
|
2442
|
+
--> statement-breakpoint
|
|
2443
|
+
-- Backfill from the stored schema files: a property row takes the property object whose \`id\` is
|
|
2444
|
+
-- its schema_file_id, from the newest schema version that has one. Rows no stored file names by id
|
|
2445
|
+
-- keep NULL and read their definition from the columns alone.
|
|
2446
|
+
UPDATE \`properties\` SET \`definition\` = (
|
|
2447
|
+
SELECT \`p\`.\`value\`
|
|
2448
|
+
FROM \`schemas\` \`s\`,
|
|
2449
|
+
json_each(CASE WHEN json_valid(\`s\`.\`schema_data\`) THEN \`s\`.\`schema_data\` ELSE '{}' END, '$.models') \`m\`,
|
|
2450
|
+
json_each(\`m\`.\`value\`, '$.properties') \`p\`
|
|
2451
|
+
WHERE \`m\`.\`type\` = 'object'
|
|
2452
|
+
AND json_type(\`m\`.\`value\`, '$.properties') = 'object'
|
|
2453
|
+
AND \`p\`.\`type\` = 'object'
|
|
2454
|
+
AND json_extract(\`p\`.\`value\`, '$.id') = \`properties\`.\`schema_file_id\`
|
|
2455
|
+
ORDER BY \`s\`.\`version\` DESC, \`s\`.\`id\` DESC
|
|
2456
|
+
LIMIT 1
|
|
2457
|
+
) WHERE \`definition\` IS NULL AND \`schema_file_id\` IS NOT NULL;
|
|
2458
|
+
`;
|
|
2459
|
+
const migrationSql_0029_dedupe_chain_uids_add_unique_indexes = `-- Unique keys the writers already assume (SDK audit T9): one model_schemas link per model and
|
|
2460
|
+
-- schema, and one seeds / versions row per attested uid (placeholder uids are left out, see
|
|
2461
|
+
-- seedSchema/attestedUid.ts). Duplicates are merged first. The survivor is the row with local
|
|
2462
|
+
-- children (versions for a seed, metadata for a version), then the oldest; the duplicate's
|
|
2463
|
+
-- references move to it, columns it lacks are copied from the duplicate, and the duplicate is
|
|
2464
|
+
-- deleted.
|
|
2465
|
+
CREATE TABLE \`__t9_seed_merge\` (\`dup_rowid\` integer PRIMARY KEY, \`dup\` text, \`keep\` text);
|
|
2466
|
+
--> statement-breakpoint
|
|
2467
|
+
INSERT INTO \`__t9_seed_merge\` (\`dup_rowid\`, \`dup\`, \`keep\`)
|
|
2468
|
+
SELECT \`rid\`, \`local_id\`, \`keep\` FROM (
|
|
2469
|
+
SELECT \`s\`.\`rowid\` AS \`rid\`, \`s\`.\`local_id\`,
|
|
2470
|
+
first_value(\`s\`.\`local_id\`) OVER \`w\` AS \`keep\`,
|
|
2471
|
+
row_number() OVER \`w\` AS \`rank\`
|
|
2472
|
+
FROM \`seeds\` \`s\`
|
|
2473
|
+
WHERE \`s\`.\`uid\` IS NOT NULL AND trim(\`s\`.\`uid\`) NOT IN ('', 'NULL') AND lower(trim(\`s\`.\`uid\`)) != '0x0000000000000000000000000000000000000000000000000000000000000000'
|
|
2474
|
+
WINDOW \`w\` AS (
|
|
2475
|
+
PARTITION BY \`s\`.\`uid\`
|
|
2476
|
+
ORDER BY (\`s\`.\`local_id\` IS NULL),
|
|
2477
|
+
EXISTS (SELECT 1 FROM \`versions\` \`v\` WHERE \`v\`.\`seed_local_id\` = \`s\`.\`local_id\`) DESC,
|
|
2478
|
+
COALESCE(\`s\`.\`created_at\`, 9223372036854775807), \`s\`.\`rowid\`
|
|
2479
|
+
)
|
|
2480
|
+
)
|
|
2481
|
+
WHERE \`rank\` > 1;
|
|
2482
|
+
--> statement-breakpoint
|
|
2483
|
+
UPDATE \`seeds\` SET
|
|
2484
|
+
\`schema_uid\` = COALESCE(\`schema_uid\`, (SELECT \`d\`.\`schema_uid\` FROM \`__t9_seed_merge\` \`m\` JOIN \`seeds\` \`d\` ON \`d\`.\`rowid\` = \`m\`.\`dup_rowid\` WHERE \`m\`.\`keep\` = \`seeds\`.\`local_id\` AND \`d\`.\`schema_uid\` IS NOT NULL LIMIT 1)),
|
|
2485
|
+
\`type\` = COALESCE(\`type\`, (SELECT \`d\`.\`type\` FROM \`__t9_seed_merge\` \`m\` JOIN \`seeds\` \`d\` ON \`d\`.\`rowid\` = \`m\`.\`dup_rowid\` WHERE \`m\`.\`keep\` = \`seeds\`.\`local_id\` AND \`d\`.\`type\` IS NOT NULL LIMIT 1)),
|
|
2486
|
+
\`model_file_id\` = COALESCE(\`model_file_id\`, (SELECT \`d\`.\`model_file_id\` FROM \`__t9_seed_merge\` \`m\` JOIN \`seeds\` \`d\` ON \`d\`.\`rowid\` = \`m\`.\`dup_rowid\` WHERE \`m\`.\`keep\` = \`seeds\`.\`local_id\` AND \`d\`.\`model_file_id\` IS NOT NULL LIMIT 1)),
|
|
2487
|
+
\`publisher\` = COALESCE(\`publisher\`, (SELECT \`d\`.\`publisher\` FROM \`__t9_seed_merge\` \`m\` JOIN \`seeds\` \`d\` ON \`d\`.\`rowid\` = \`m\`.\`dup_rowid\` WHERE \`m\`.\`keep\` = \`seeds\`.\`local_id\` AND \`d\`.\`publisher\` IS NOT NULL LIMIT 1)),
|
|
2488
|
+
\`attestation_raw\` = COALESCE(\`attestation_raw\`, (SELECT \`d\`.\`attestation_raw\` FROM \`__t9_seed_merge\` \`m\` JOIN \`seeds\` \`d\` ON \`d\`.\`rowid\` = \`m\`.\`dup_rowid\` WHERE \`m\`.\`keep\` = \`seeds\`.\`local_id\` AND \`d\`.\`attestation_raw\` IS NOT NULL LIMIT 1)),
|
|
2489
|
+
\`attestation_created_at\` = COALESCE(\`attestation_created_at\`, (SELECT \`d\`.\`attestation_created_at\` FROM \`__t9_seed_merge\` \`m\` JOIN \`seeds\` \`d\` ON \`d\`.\`rowid\` = \`m\`.\`dup_rowid\` WHERE \`m\`.\`keep\` = \`seeds\`.\`local_id\` AND \`d\`.\`attestation_created_at\` IS NOT NULL LIMIT 1))
|
|
2490
|
+
WHERE \`local_id\` IN (SELECT \`keep\` FROM \`__t9_seed_merge\`);
|
|
2491
|
+
--> statement-breakpoint
|
|
2492
|
+
-- A property row the survivor already has (same attestation uid) is not moved.
|
|
2493
|
+
DELETE FROM \`metadata\`
|
|
2494
|
+
WHERE \`seed_local_id\` IN (SELECT \`dup\` FROM \`__t9_seed_merge\` WHERE \`keep\` IS NOT NULL)
|
|
2495
|
+
AND \`metadata\`.\`uid\` IS NOT NULL AND trim(\`metadata\`.\`uid\`) NOT IN ('', 'NULL') AND lower(trim(\`metadata\`.\`uid\`)) != '0x0000000000000000000000000000000000000000000000000000000000000000'
|
|
2496
|
+
AND EXISTS (
|
|
2497
|
+
SELECT 1 FROM \`metadata\` \`k\` JOIN \`__t9_seed_merge\` \`m\` ON \`k\`.\`seed_local_id\` = \`m\`.\`keep\`
|
|
2498
|
+
WHERE \`m\`.\`dup\` = \`metadata\`.\`seed_local_id\` AND \`k\`.\`uid\` = \`metadata\`.\`uid\`
|
|
2499
|
+
);
|
|
2500
|
+
--> statement-breakpoint
|
|
2501
|
+
UPDATE \`metadata\` SET \`seed_local_id\` = (SELECT \`keep\` FROM \`__t9_seed_merge\` WHERE \`dup\` = \`metadata\`.\`seed_local_id\`)
|
|
2502
|
+
WHERE \`seed_local_id\` IN (SELECT \`dup\` FROM \`__t9_seed_merge\` WHERE \`keep\` IS NOT NULL);
|
|
2503
|
+
--> statement-breakpoint
|
|
2504
|
+
UPDATE \`versions\` SET \`seed_local_id\` = (SELECT \`keep\` FROM \`__t9_seed_merge\` WHERE \`dup\` = \`versions\`.\`seed_local_id\`)
|
|
2505
|
+
WHERE \`seed_local_id\` IN (SELECT \`dup\` FROM \`__t9_seed_merge\` WHERE \`keep\` IS NOT NULL);
|
|
2506
|
+
--> statement-breakpoint
|
|
2507
|
+
UPDATE \`pending_writes\` SET \`seed_local_id\` = (SELECT \`keep\` FROM \`__t9_seed_merge\` WHERE \`dup\` = \`pending_writes\`.\`seed_local_id\`)
|
|
2508
|
+
WHERE \`seed_local_id\` IN (SELECT \`dup\` FROM \`__t9_seed_merge\` WHERE \`keep\` IS NOT NULL);
|
|
2509
|
+
--> statement-breakpoint
|
|
2510
|
+
UPDATE \`publish_processes\` SET \`seed_local_id\` = (SELECT \`keep\` FROM \`__t9_seed_merge\` WHERE \`dup\` = \`publish_processes\`.\`seed_local_id\`)
|
|
2511
|
+
WHERE \`seed_local_id\` IN (SELECT \`dup\` FROM \`__t9_seed_merge\` WHERE \`keep\` IS NOT NULL);
|
|
2512
|
+
--> statement-breakpoint
|
|
2513
|
+
UPDATE \`arweave_l1_finalize_jobs\` SET \`seed_local_id\` = (SELECT \`keep\` FROM \`__t9_seed_merge\` WHERE \`dup\` = \`arweave_l1_finalize_jobs\`.\`seed_local_id\`)
|
|
2514
|
+
WHERE \`seed_local_id\` IN (SELECT \`dup\` FROM \`__t9_seed_merge\` WHERE \`keep\` IS NOT NULL);
|
|
2515
|
+
--> statement-breakpoint
|
|
2516
|
+
UPDATE \`html_embedded_image_co_publish\` SET \`image_seed_local_id\` = (SELECT \`keep\` FROM \`__t9_seed_merge\` WHERE \`dup\` = \`html_embedded_image_co_publish\`.\`image_seed_local_id\`)
|
|
2517
|
+
WHERE \`image_seed_local_id\` IN (SELECT \`dup\` FROM \`__t9_seed_merge\` WHERE \`keep\` IS NOT NULL);
|
|
2518
|
+
--> statement-breakpoint
|
|
2519
|
+
UPDATE OR IGNORE \`html_embedded_image_co_publish\` SET \`parent_seed_local_id\` = (SELECT \`keep\` FROM \`__t9_seed_merge\` WHERE \`dup\` = \`html_embedded_image_co_publish\`.\`parent_seed_local_id\`)
|
|
2520
|
+
WHERE \`parent_seed_local_id\` IN (SELECT \`dup\` FROM \`__t9_seed_merge\` WHERE \`keep\` IS NOT NULL);
|
|
2521
|
+
--> statement-breakpoint
|
|
2522
|
+
DELETE FROM \`html_embedded_image_co_publish\` WHERE \`parent_seed_local_id\` IN (SELECT \`dup\` FROM \`__t9_seed_merge\` WHERE \`keep\` IS NOT NULL);
|
|
2523
|
+
--> statement-breakpoint
|
|
2524
|
+
UPDATE OR IGNORE \`html_embedded_image_co_publish\` SET \`html_seed_local_id\` = (SELECT \`keep\` FROM \`__t9_seed_merge\` WHERE \`dup\` = \`html_embedded_image_co_publish\`.\`html_seed_local_id\`)
|
|
2525
|
+
WHERE \`html_seed_local_id\` IN (SELECT \`dup\` FROM \`__t9_seed_merge\` WHERE \`keep\` IS NOT NULL);
|
|
2526
|
+
--> statement-breakpoint
|
|
2527
|
+
DELETE FROM \`html_embedded_image_co_publish\` WHERE \`html_seed_local_id\` IN (SELECT \`dup\` FROM \`__t9_seed_merge\` WHERE \`keep\` IS NOT NULL);
|
|
2528
|
+
--> statement-breakpoint
|
|
2529
|
+
DELETE FROM \`seeds\` WHERE \`rowid\` IN (SELECT \`dup_rowid\` FROM \`__t9_seed_merge\`);
|
|
2530
|
+
--> statement-breakpoint
|
|
2531
|
+
DROP TABLE \`__t9_seed_merge\`;
|
|
2532
|
+
--> statement-breakpoint
|
|
2533
|
+
CREATE TABLE \`__t9_version_merge\` (\`dup_rowid\` integer PRIMARY KEY, \`dup\` text, \`keep\` text);
|
|
2534
|
+
--> statement-breakpoint
|
|
2535
|
+
INSERT INTO \`__t9_version_merge\` (\`dup_rowid\`, \`dup\`, \`keep\`)
|
|
2536
|
+
SELECT \`rid\`, \`local_id\`, \`keep\` FROM (
|
|
2537
|
+
SELECT \`v\`.\`rowid\` AS \`rid\`, \`v\`.\`local_id\`,
|
|
2538
|
+
first_value(\`v\`.\`local_id\`) OVER \`w\` AS \`keep\`,
|
|
2539
|
+
row_number() OVER \`w\` AS \`rank\`
|
|
2540
|
+
FROM \`versions\` \`v\`
|
|
2541
|
+
WHERE \`v\`.\`uid\` IS NOT NULL AND trim(\`v\`.\`uid\`) NOT IN ('', 'NULL') AND lower(trim(\`v\`.\`uid\`)) != '0x0000000000000000000000000000000000000000000000000000000000000000'
|
|
2542
|
+
WINDOW \`w\` AS (
|
|
2543
|
+
PARTITION BY \`v\`.\`uid\`
|
|
2544
|
+
ORDER BY (\`v\`.\`local_id\` IS NULL),
|
|
2545
|
+
EXISTS (SELECT 1 FROM \`metadata\` \`md\` WHERE \`md\`.\`version_local_id\` = \`v\`.\`local_id\`) DESC,
|
|
2546
|
+
COALESCE(\`v\`.\`created_at\`, 9223372036854775807), \`v\`.\`rowid\`
|
|
2547
|
+
)
|
|
2548
|
+
)
|
|
2549
|
+
WHERE \`rank\` > 1;
|
|
2550
|
+
--> statement-breakpoint
|
|
2551
|
+
UPDATE \`versions\` SET
|
|
2552
|
+
\`seed_uid\` = COALESCE(\`seed_uid\`, (SELECT \`d\`.\`seed_uid\` FROM \`__t9_version_merge\` \`m\` JOIN \`versions\` \`d\` ON \`d\`.\`rowid\` = \`m\`.\`dup_rowid\` WHERE \`m\`.\`keep\` = \`versions\`.\`local_id\` AND \`d\`.\`seed_uid\` IS NOT NULL LIMIT 1)),
|
|
2553
|
+
\`seed_type\` = COALESCE(\`seed_type\`, (SELECT \`d\`.\`seed_type\` FROM \`__t9_version_merge\` \`m\` JOIN \`versions\` \`d\` ON \`d\`.\`rowid\` = \`m\`.\`dup_rowid\` WHERE \`m\`.\`keep\` = \`versions\`.\`local_id\` AND \`d\`.\`seed_type\` IS NOT NULL LIMIT 1)),
|
|
2554
|
+
\`attestation_raw\` = COALESCE(\`attestation_raw\`, (SELECT \`d\`.\`attestation_raw\` FROM \`__t9_version_merge\` \`m\` JOIN \`versions\` \`d\` ON \`d\`.\`rowid\` = \`m\`.\`dup_rowid\` WHERE \`m\`.\`keep\` = \`versions\`.\`local_id\` AND \`d\`.\`attestation_raw\` IS NOT NULL LIMIT 1)),
|
|
2555
|
+
\`attestation_created_at\` = COALESCE(\`attestation_created_at\`, (SELECT \`d\`.\`attestation_created_at\` FROM \`__t9_version_merge\` \`m\` JOIN \`versions\` \`d\` ON \`d\`.\`rowid\` = \`m\`.\`dup_rowid\` WHERE \`m\`.\`keep\` = \`versions\`.\`local_id\` AND \`d\`.\`attestation_created_at\` IS NOT NULL LIMIT 1)),
|
|
2556
|
+
\`publisher\` = COALESCE(\`publisher\`, (SELECT \`d\`.\`publisher\` FROM \`__t9_version_merge\` \`m\` JOIN \`versions\` \`d\` ON \`d\`.\`rowid\` = \`m\`.\`dup_rowid\` WHERE \`m\`.\`keep\` = \`versions\`.\`local_id\` AND \`d\`.\`publisher\` IS NOT NULL LIMIT 1)),
|
|
2557
|
+
\`revoked_at\` = COALESCE(\`revoked_at\`, (SELECT \`d\`.\`revoked_at\` FROM \`__t9_version_merge\` \`m\` JOIN \`versions\` \`d\` ON \`d\`.\`rowid\` = \`m\`.\`dup_rowid\` WHERE \`m\`.\`keep\` = \`versions\`.\`local_id\` AND \`d\`.\`revoked_at\` IS NOT NULL LIMIT 1))
|
|
2558
|
+
WHERE \`local_id\` IN (SELECT \`keep\` FROM \`__t9_version_merge\`);
|
|
2559
|
+
--> statement-breakpoint
|
|
2560
|
+
UPDATE \`metadata\` SET \`version_local_id\` = (SELECT \`keep\` FROM \`__t9_version_merge\` WHERE \`dup\` = \`metadata\`.\`version_local_id\`)
|
|
2561
|
+
WHERE \`version_local_id\` IN (SELECT \`dup\` FROM \`__t9_version_merge\` WHERE \`keep\` IS NOT NULL);
|
|
2562
|
+
--> statement-breakpoint
|
|
2563
|
+
UPDATE \`arweave_l1_finalize_jobs\` SET \`version_local_id\` = (SELECT \`keep\` FROM \`__t9_version_merge\` WHERE \`dup\` = \`arweave_l1_finalize_jobs\`.\`version_local_id\`)
|
|
2564
|
+
WHERE \`version_local_id\` IN (SELECT \`dup\` FROM \`__t9_version_merge\` WHERE \`keep\` IS NOT NULL);
|
|
2565
|
+
--> statement-breakpoint
|
|
2566
|
+
DELETE FROM \`versions\` WHERE \`rowid\` IN (SELECT \`dup_rowid\` FROM \`__t9_version_merge\`);
|
|
2567
|
+
--> statement-breakpoint
|
|
2568
|
+
DROP TABLE \`__t9_version_merge\`;
|
|
2569
|
+
--> statement-breakpoint
|
|
2570
|
+
DELETE FROM \`model_schemas\`
|
|
2571
|
+
WHERE \`model_id\` IS NOT NULL AND \`schema_id\` IS NOT NULL
|
|
2572
|
+
AND \`id\` NOT IN (SELECT MIN(\`id\`) FROM \`model_schemas\` GROUP BY \`model_id\`, \`schema_id\`);
|
|
2573
|
+
--> statement-breakpoint
|
|
2574
|
+
CREATE UNIQUE INDEX \`model_schemas_model_id_schema_id_unique\` ON \`model_schemas\` (\`model_id\`,\`schema_id\`);
|
|
2575
|
+
--> statement-breakpoint
|
|
2576
|
+
CREATE UNIQUE INDEX \`seeds_attested_uid_unique\` ON \`seeds\` (\`uid\`) WHERE "seeds"."uid" IS NOT NULL AND trim("seeds"."uid") NOT IN ('', 'NULL') AND lower(trim("seeds"."uid")) != '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
2577
|
+
--> statement-breakpoint
|
|
2578
|
+
CREATE UNIQUE INDEX \`versions_attested_uid_unique\` ON \`versions\` (\`uid\`) WHERE "versions"."uid" IS NOT NULL AND trim("versions"."uid") NOT IN ('', 'NULL') AND lower(trim("versions"."uid")) != '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
2579
|
+
`;
|
|
2389
2580
|
// Journal JSON file
|
|
2390
2581
|
const journalJson = `{
|
|
2391
2582
|
"version": "7",
|
|
@@ -2565,16 +2756,52 @@ const journalJson = `{
|
|
|
2565
2756
|
"when": 1792576238054,
|
|
2566
2757
|
"tag": "0024_merge_republished_ghost_seeds",
|
|
2567
2758
|
"breakpoints": true
|
|
2759
|
+
},
|
|
2760
|
+
{
|
|
2761
|
+
"idx": 25,
|
|
2762
|
+
"version": "6",
|
|
2763
|
+
"when": 1792585560172,
|
|
2764
|
+
"tag": "0025_add_metadata_retract",
|
|
2765
|
+
"breakpoints": true
|
|
2766
|
+
},
|
|
2767
|
+
{
|
|
2768
|
+
"idx": 26,
|
|
2769
|
+
"version": "6",
|
|
2770
|
+
"when": 1792587787468,
|
|
2771
|
+
"tag": "0026_add_content_hash_to_schemas",
|
|
2772
|
+
"breakpoints": true
|
|
2773
|
+
},
|
|
2774
|
+
{
|
|
2775
|
+
"idx": 27,
|
|
2776
|
+
"version": "6",
|
|
2777
|
+
"when": 1792587787964,
|
|
2778
|
+
"tag": "0027_link_metadata_property_ids",
|
|
2779
|
+
"breakpoints": true
|
|
2780
|
+
},
|
|
2781
|
+
{
|
|
2782
|
+
"idx": 28,
|
|
2783
|
+
"version": "6",
|
|
2784
|
+
"when": 1792596417502,
|
|
2785
|
+
"tag": "0028_add_definition_to_properties",
|
|
2786
|
+
"breakpoints": true
|
|
2787
|
+
},
|
|
2788
|
+
{
|
|
2789
|
+
"idx": 29,
|
|
2790
|
+
"version": "6",
|
|
2791
|
+
"when": 1792596480144,
|
|
2792
|
+
"tag": "0029_dedupe_chain_uids_add_unique_indexes",
|
|
2793
|
+
"breakpoints": true
|
|
2568
2794
|
}
|
|
2569
2795
|
]
|
|
2570
|
-
}
|
|
2796
|
+
}
|
|
2797
|
+
`;
|
|
2571
2798
|
// Snapshot JSON file - this is large, so we'll import it dynamically if needed
|
|
2572
2799
|
// For now, we'll read it from the actual file if ?raw works, otherwise we'll need to embed it
|
|
2573
2800
|
const snapshotJson = `{
|
|
2574
|
-
"id": "3264e54f-0bb8-4116-87e8-b059b4ac1ae7",
|
|
2575
|
-
"prevId": "7767667b-3cf0-4630-b1ff-02913f2f35ad",
|
|
2576
2801
|
"version": "6",
|
|
2577
2802
|
"dialect": "sqlite",
|
|
2803
|
+
"id": "0937d0b1-f4ea-4ae1-885b-7173e7b786b9",
|
|
2804
|
+
"prevId": "083c3909-4feb-4b61-bf23-fa806a60b826",
|
|
2578
2805
|
"tables": {
|
|
2579
2806
|
"appState": {
|
|
2580
2807
|
"name": "appState",
|
|
@@ -3155,6 +3382,13 @@ const snapshotJson = `{
|
|
|
3155
3382
|
"primaryKey": false,
|
|
3156
3383
|
"notNull": false,
|
|
3157
3384
|
"autoincrement": false
|
|
3385
|
+
},
|
|
3386
|
+
"retract": {
|
|
3387
|
+
"name": "retract",
|
|
3388
|
+
"type": "integer",
|
|
3389
|
+
"primaryKey": false,
|
|
3390
|
+
"notNull": false,
|
|
3391
|
+
"autoincrement": false
|
|
3158
3392
|
}
|
|
3159
3393
|
},
|
|
3160
3394
|
"indexes": {
|
|
@@ -3185,15 +3419,15 @@ const snapshotJson = `{
|
|
|
3185
3419
|
"metadata_property_id_properties_id_fk": {
|
|
3186
3420
|
"name": "metadata_property_id_properties_id_fk",
|
|
3187
3421
|
"tableFrom": "metadata",
|
|
3422
|
+
"tableTo": "properties",
|
|
3188
3423
|
"columnsFrom": [
|
|
3189
3424
|
"property_id"
|
|
3190
3425
|
],
|
|
3191
|
-
"tableTo": "properties",
|
|
3192
3426
|
"columnsTo": [
|
|
3193
3427
|
"id"
|
|
3194
3428
|
],
|
|
3195
|
-
"
|
|
3196
|
-
"
|
|
3429
|
+
"onDelete": "no action",
|
|
3430
|
+
"onUpdate": "no action"
|
|
3197
3431
|
}
|
|
3198
3432
|
},
|
|
3199
3433
|
"compositePrimaryKeys": {},
|
|
@@ -3332,6 +3566,13 @@ const snapshotJson = `{
|
|
|
3332
3566
|
"primaryKey": false,
|
|
3333
3567
|
"notNull": false,
|
|
3334
3568
|
"autoincrement": false
|
|
3569
|
+
},
|
|
3570
|
+
"definition": {
|
|
3571
|
+
"name": "definition",
|
|
3572
|
+
"type": "text",
|
|
3573
|
+
"primaryKey": false,
|
|
3574
|
+
"notNull": false,
|
|
3575
|
+
"autoincrement": false
|
|
3335
3576
|
}
|
|
3336
3577
|
},
|
|
3337
3578
|
"indexes": {
|
|
@@ -3355,28 +3596,28 @@ const snapshotJson = `{
|
|
|
3355
3596
|
"properties_model_id_models_id_fk": {
|
|
3356
3597
|
"name": "properties_model_id_models_id_fk",
|
|
3357
3598
|
"tableFrom": "properties",
|
|
3599
|
+
"tableTo": "models",
|
|
3358
3600
|
"columnsFrom": [
|
|
3359
3601
|
"model_id"
|
|
3360
3602
|
],
|
|
3361
|
-
"tableTo": "models",
|
|
3362
3603
|
"columnsTo": [
|
|
3363
3604
|
"id"
|
|
3364
3605
|
],
|
|
3365
|
-
"
|
|
3366
|
-
"
|
|
3606
|
+
"onDelete": "no action",
|
|
3607
|
+
"onUpdate": "no action"
|
|
3367
3608
|
},
|
|
3368
3609
|
"properties_ref_model_id_models_id_fk": {
|
|
3369
3610
|
"name": "properties_ref_model_id_models_id_fk",
|
|
3370
3611
|
"tableFrom": "properties",
|
|
3612
|
+
"tableTo": "models",
|
|
3371
3613
|
"columnsFrom": [
|
|
3372
3614
|
"ref_model_id"
|
|
3373
3615
|
],
|
|
3374
|
-
"tableTo": "models",
|
|
3375
3616
|
"columnsTo": [
|
|
3376
3617
|
"id"
|
|
3377
3618
|
],
|
|
3378
|
-
"
|
|
3379
|
-
"
|
|
3619
|
+
"onDelete": "no action",
|
|
3620
|
+
"onUpdate": "no action"
|
|
3380
3621
|
}
|
|
3381
3622
|
},
|
|
3382
3623
|
"compositePrimaryKeys": {},
|
|
@@ -3408,33 +3649,42 @@ const snapshotJson = `{
|
|
|
3408
3649
|
"autoincrement": false
|
|
3409
3650
|
}
|
|
3410
3651
|
},
|
|
3411
|
-
"indexes": {
|
|
3652
|
+
"indexes": {
|
|
3653
|
+
"model_schemas_model_id_schema_id_unique": {
|
|
3654
|
+
"name": "model_schemas_model_id_schema_id_unique",
|
|
3655
|
+
"columns": [
|
|
3656
|
+
"model_id",
|
|
3657
|
+
"schema_id"
|
|
3658
|
+
],
|
|
3659
|
+
"isUnique": true
|
|
3660
|
+
}
|
|
3661
|
+
},
|
|
3412
3662
|
"foreignKeys": {
|
|
3413
3663
|
"model_schemas_model_id_models_id_fk": {
|
|
3414
3664
|
"name": "model_schemas_model_id_models_id_fk",
|
|
3415
3665
|
"tableFrom": "model_schemas",
|
|
3666
|
+
"tableTo": "models",
|
|
3416
3667
|
"columnsFrom": [
|
|
3417
3668
|
"model_id"
|
|
3418
3669
|
],
|
|
3419
|
-
"tableTo": "models",
|
|
3420
3670
|
"columnsTo": [
|
|
3421
3671
|
"id"
|
|
3422
3672
|
],
|
|
3423
|
-
"
|
|
3424
|
-
"
|
|
3673
|
+
"onDelete": "no action",
|
|
3674
|
+
"onUpdate": "no action"
|
|
3425
3675
|
},
|
|
3426
3676
|
"model_schemas_schema_id_schemas_id_fk": {
|
|
3427
3677
|
"name": "model_schemas_schema_id_schemas_id_fk",
|
|
3428
3678
|
"tableFrom": "model_schemas",
|
|
3679
|
+
"tableTo": "schemas",
|
|
3429
3680
|
"columnsFrom": [
|
|
3430
3681
|
"schema_id"
|
|
3431
3682
|
],
|
|
3432
|
-
"tableTo": "schemas",
|
|
3433
3683
|
"columnsTo": [
|
|
3434
3684
|
"id"
|
|
3435
3685
|
],
|
|
3436
|
-
"
|
|
3437
|
-
"
|
|
3686
|
+
"onDelete": "no action",
|
|
3687
|
+
"onUpdate": "no action"
|
|
3438
3688
|
}
|
|
3439
3689
|
},
|
|
3440
3690
|
"compositePrimaryKeys": {},
|
|
@@ -3479,15 +3729,15 @@ const snapshotJson = `{
|
|
|
3479
3729
|
"model_uids_model_id_models_id_fk": {
|
|
3480
3730
|
"name": "model_uids_model_id_models_id_fk",
|
|
3481
3731
|
"tableFrom": "model_uids",
|
|
3732
|
+
"tableTo": "models",
|
|
3482
3733
|
"columnsFrom": [
|
|
3483
3734
|
"model_id"
|
|
3484
3735
|
],
|
|
3485
|
-
"tableTo": "models",
|
|
3486
3736
|
"columnsTo": [
|
|
3487
3737
|
"id"
|
|
3488
3738
|
],
|
|
3489
|
-
"
|
|
3490
|
-
"
|
|
3739
|
+
"onDelete": "no action",
|
|
3740
|
+
"onUpdate": "no action"
|
|
3491
3741
|
}
|
|
3492
3742
|
},
|
|
3493
3743
|
"compositePrimaryKeys": {},
|
|
@@ -3701,15 +3951,15 @@ const snapshotJson = `{
|
|
|
3701
3951
|
"property_uids_property_id_properties_id_fk": {
|
|
3702
3952
|
"name": "property_uids_property_id_properties_id_fk",
|
|
3703
3953
|
"tableFrom": "property_uids",
|
|
3954
|
+
"tableTo": "properties",
|
|
3704
3955
|
"columnsFrom": [
|
|
3705
3956
|
"property_id"
|
|
3706
3957
|
],
|
|
3707
|
-
"tableTo": "properties",
|
|
3708
3958
|
"columnsTo": [
|
|
3709
3959
|
"id"
|
|
3710
3960
|
],
|
|
3711
|
-
"
|
|
3712
|
-
"
|
|
3961
|
+
"onDelete": "no action",
|
|
3962
|
+
"onUpdate": "no action"
|
|
3713
3963
|
}
|
|
3714
3964
|
},
|
|
3715
3965
|
"compositePrimaryKeys": {},
|
|
@@ -3890,6 +4140,13 @@ const snapshotJson = `{
|
|
|
3890
4140
|
"notNull": false,
|
|
3891
4141
|
"autoincrement": false
|
|
3892
4142
|
},
|
|
4143
|
+
"content_hash": {
|
|
4144
|
+
"name": "content_hash",
|
|
4145
|
+
"type": "text",
|
|
4146
|
+
"primaryKey": false,
|
|
4147
|
+
"notNull": false,
|
|
4148
|
+
"autoincrement": false
|
|
4149
|
+
},
|
|
3893
4150
|
"created_at": {
|
|
3894
4151
|
"name": "created_at",
|
|
3895
4152
|
"type": "integer",
|
|
@@ -4028,6 +4285,14 @@ const snapshotJson = `{
|
|
|
4028
4285
|
"type"
|
|
4029
4286
|
],
|
|
4030
4287
|
"isUnique": false
|
|
4288
|
+
},
|
|
4289
|
+
"seeds_attested_uid_unique": {
|
|
4290
|
+
"name": "seeds_attested_uid_unique",
|
|
4291
|
+
"columns": [
|
|
4292
|
+
"uid"
|
|
4293
|
+
],
|
|
4294
|
+
"isUnique": true,
|
|
4295
|
+
"where": "\\"seeds\\".\\"uid\\" IS NOT NULL AND trim(\\"seeds\\".\\"uid\\") NOT IN ('', 'NULL') AND lower(trim(\\"seeds\\".\\"uid\\")) != '0x0000000000000000000000000000000000000000000000000000000000000000'"
|
|
4031
4296
|
}
|
|
4032
4297
|
},
|
|
4033
4298
|
"foreignKeys": {},
|
|
@@ -4196,6 +4461,14 @@ const snapshotJson = `{
|
|
|
4196
4461
|
"seed_local_id"
|
|
4197
4462
|
],
|
|
4198
4463
|
"isUnique": false
|
|
4464
|
+
},
|
|
4465
|
+
"versions_attested_uid_unique": {
|
|
4466
|
+
"name": "versions_attested_uid_unique",
|
|
4467
|
+
"columns": [
|
|
4468
|
+
"uid"
|
|
4469
|
+
],
|
|
4470
|
+
"isUnique": true,
|
|
4471
|
+
"where": "\\"versions\\".\\"uid\\" IS NOT NULL AND trim(\\"versions\\".\\"uid\\") NOT IN ('', 'NULL') AND lower(trim(\\"versions\\".\\"uid\\")) != '0x0000000000000000000000000000000000000000000000000000000000000000'"
|
|
4199
4472
|
}
|
|
4200
4473
|
},
|
|
4201
4474
|
"foreignKeys": {},
|
|
@@ -4207,9 +4480,9 @@ const snapshotJson = `{
|
|
|
4207
4480
|
"views": {},
|
|
4208
4481
|
"enums": {},
|
|
4209
4482
|
"_meta": {
|
|
4210
|
-
"columns": {},
|
|
4211
4483
|
"schemas": {},
|
|
4212
|
-
"tables": {}
|
|
4484
|
+
"tables": {},
|
|
4485
|
+
"columns": {}
|
|
4213
4486
|
},
|
|
4214
4487
|
"internal": {
|
|
4215
4488
|
"indexes": {}
|
|
@@ -4244,6 +4517,11 @@ var drizzleFiles = /*#__PURE__*/Object.freeze({
|
|
|
4244
4517
|
migrationSql_0022_add_read_indexes: migrationSql_0022_add_read_indexes,
|
|
4245
4518
|
migrationSql_0023_add_entity_changes: migrationSql_0023_add_entity_changes,
|
|
4246
4519
|
migrationSql_0024_merge_republished_ghost_seeds: migrationSql_0024_merge_republished_ghost_seeds,
|
|
4520
|
+
migrationSql_0025_add_metadata_retract: migrationSql_0025_add_metadata_retract,
|
|
4521
|
+
migrationSql_0026_add_content_hash_to_schemas: migrationSql_0026_add_content_hash_to_schemas,
|
|
4522
|
+
migrationSql_0027_link_metadata_property_ids: migrationSql_0027_link_metadata_property_ids,
|
|
4523
|
+
migrationSql_0028_add_definition_to_properties: migrationSql_0028_add_definition_to_properties,
|
|
4524
|
+
migrationSql_0029_dedupe_chain_uids_add_unique_indexes: migrationSql_0029_dedupe_chain_uids_add_unique_indexes,
|
|
4247
4525
|
snapshotJson: snapshotJson
|
|
4248
4526
|
});
|
|
4249
4527
|
|
|
@@ -4304,7 +4582,7 @@ async function applyEmbeddedMigrations(db, migrations, migrationsTable = '__driz
|
|
|
4304
4582
|
}
|
|
4305
4583
|
}
|
|
4306
4584
|
|
|
4307
|
-
const logger$
|
|
4585
|
+
const logger$1 = debug('seedSdk:browser:db:createSqlocalDrizzle');
|
|
4308
4586
|
/** First sqlocal work can include sqlite-wasm fetch; keep this long to avoid false positives. */
|
|
4309
4587
|
const SQLOCAL_FIRST_QUERY_TIMEOUT_MS = 90000;
|
|
4310
4588
|
const HTTP_MODULE_WORKER_URL = /^https?:/i;
|
|
@@ -4425,7 +4703,7 @@ function installModuleWorkerBlobWrap(onWorkerFailed) {
|
|
|
4425
4703
|
const error = new Error(filename
|
|
4426
4704
|
? `sqlocal worker failed to start (${event.type}): ${message} [${filename}]`
|
|
4427
4705
|
: `sqlocal worker failed to start (${event.type}): ${message}`);
|
|
4428
|
-
logger$
|
|
4706
|
+
logger$1('[createSqlocalDrizzle] worker failed', error.message);
|
|
4429
4707
|
onWorkerFailed(error);
|
|
4430
4708
|
};
|
|
4431
4709
|
worker.addEventListener('error', fail);
|
|
@@ -4440,7 +4718,7 @@ function installModuleWorkerBlobWrap(onWorkerFailed) {
|
|
|
4440
4718
|
};
|
|
4441
4719
|
}
|
|
4442
4720
|
|
|
4443
|
-
const logger
|
|
4721
|
+
const logger = debug('seedSdk:browser:db:Db');
|
|
4444
4722
|
class BrowserDb {
|
|
4445
4723
|
constructor() {
|
|
4446
4724
|
/** Live queries by SQL + params while they have subscribers; see liveQuery. */
|
|
@@ -4453,7 +4731,7 @@ class BrowserDb {
|
|
|
4453
4731
|
return !!this.appDb;
|
|
4454
4732
|
}
|
|
4455
4733
|
async prepareDb(filesDir) {
|
|
4456
|
-
logger
|
|
4734
|
+
logger('[Db.prepareDb] preparing database');
|
|
4457
4735
|
this.filesDir = filesDir;
|
|
4458
4736
|
// Another tab may be preparing the same database: run file copies, migrations and the
|
|
4459
4737
|
// one-time data fixes one tab at a time. See docs/MULTI_TAB.md.
|
|
@@ -4484,7 +4762,7 @@ class BrowserDb {
|
|
|
4484
4762
|
if (waitMs === undefined) {
|
|
4485
4763
|
throw new DatabaseNotPersistentError(`SQLocal opened a "${storageType}" database instead of OPFS`, globalThis.crossOriginIsolated === true ? 'vfs' : 'headers');
|
|
4486
4764
|
}
|
|
4487
|
-
logger
|
|
4765
|
+
logger(`[Db.prepareDb] SQLocal opened a "${storageType}" database; retrying in ${waitMs} ms`);
|
|
4488
4766
|
await new Promise((resolve) => setTimeout(resolve, waitMs));
|
|
4489
4767
|
}
|
|
4490
4768
|
}
|
|
@@ -4505,11 +4783,6 @@ class BrowserDb {
|
|
|
4505
4783
|
entries: [],
|
|
4506
4784
|
}, null, 2));
|
|
4507
4785
|
}
|
|
4508
|
-
// Wait for journal file to be fully written before proceeding with migration
|
|
4509
|
-
// This is critical in browser/OPFS where writes may not be immediately readable
|
|
4510
|
-
logger$1('[Db.prepareDb] waiting for journal file to be fully written...');
|
|
4511
|
-
await BaseFileManager.waitForFileWithContent(journalFilePath, 100, 5000);
|
|
4512
|
-
logger$1('[Db.prepareDb] journal file is ready');
|
|
4513
4786
|
// SQLite's OPFS VFS needs SharedArrayBuffer and Atomics. Without them SQLocal quietly
|
|
4514
4787
|
// opens an in-memory database, so fail before starting the worker.
|
|
4515
4788
|
if (typeof SharedArrayBuffer === 'undefined' || typeof Atomics === 'undefined') {
|
|
@@ -4530,24 +4803,19 @@ class BrowserDb {
|
|
|
4530
4803
|
const db = drizzle(driver, batchDriver, {
|
|
4531
4804
|
schema,
|
|
4532
4805
|
});
|
|
4533
|
-
logger
|
|
4806
|
+
logger('[Db.prepareDb] database prepared');
|
|
4534
4807
|
await raceSqlocalStartup((async () => {
|
|
4535
4808
|
await recreateIfOlderThanMinimumUpgradeVersion(db);
|
|
4536
4809
|
await this.runMigrations(db);
|
|
4537
4810
|
this.appDb = db;
|
|
4538
|
-
const { backfillMetadataPropertyIds } = await import('./backfillMetadataPropertyIds-BbxgavEQ.js');
|
|
4539
|
-
await backfillMetadataPropertyIds();
|
|
4540
4811
|
// Loaded Items and ItemProperties hear about row changes through it (ADR 0020). Started
|
|
4541
|
-
// after the
|
|
4542
|
-
await startChangeFeed(db, {
|
|
4543
|
-
liveQuery: (query) => this.liveQuery(query),
|
|
4544
|
-
sql: ((...args) => sqlocalDrizzle.sql(...args)),
|
|
4545
|
-
});
|
|
4812
|
+
// after the migrations above, so their log rows aren't dispatched.
|
|
4813
|
+
await startChangeFeed(db, { liveQuery: (query) => this.liveQuery(query) });
|
|
4546
4814
|
})(), workerFailed);
|
|
4547
4815
|
return this.appDb;
|
|
4548
4816
|
}
|
|
4549
4817
|
catch (error) {
|
|
4550
|
-
logger
|
|
4818
|
+
logger('[Db.prepareDb] error', JSON.stringify(error));
|
|
4551
4819
|
throw error;
|
|
4552
4820
|
}
|
|
4553
4821
|
}
|
|
@@ -4555,7 +4823,7 @@ class BrowserDb {
|
|
|
4555
4823
|
return undefined;
|
|
4556
4824
|
}
|
|
4557
4825
|
async copyDrizzleFiles(filesDir) {
|
|
4558
|
-
logger
|
|
4826
|
+
logger('[Db.copyDrizzleFiles] copying drizzle migration files');
|
|
4559
4827
|
try {
|
|
4560
4828
|
// Ensure db directory exists
|
|
4561
4829
|
const dbDirPath = `${filesDir}/db`;
|
|
@@ -4567,7 +4835,7 @@ class BrowserDb {
|
|
|
4567
4835
|
const journal = JSON.parse(journalJson);
|
|
4568
4836
|
const entries = journal.entries || [];
|
|
4569
4837
|
if (entries.length === 0) {
|
|
4570
|
-
logger
|
|
4838
|
+
logger('[Db.copyDrizzleFiles] no migration entries found in journal');
|
|
4571
4839
|
return;
|
|
4572
4840
|
}
|
|
4573
4841
|
// Copy each migration SQL file (always overwrite to ensure they're up-to-date)
|
|
@@ -4581,16 +4849,16 @@ class BrowserDb {
|
|
|
4581
4849
|
const migrationVarName = `migrationSql_${tag}`;
|
|
4582
4850
|
const migrationContent = drizzleFiles[migrationVarName];
|
|
4583
4851
|
if (!migrationContent) {
|
|
4584
|
-
logger
|
|
4852
|
+
logger(`[Db.copyDrizzleFiles] ERROR: No migration content found for ${migrationFileName} (variable: ${migrationVarName})`);
|
|
4585
4853
|
throw new Error(`No migration content found for ${migrationFileName}. Expected variable: ${migrationVarName}`);
|
|
4586
4854
|
}
|
|
4587
4855
|
await BaseFileManager.saveFile(migrationPath, migrationContent.trim());
|
|
4588
|
-
logger
|
|
4856
|
+
logger(`[Db.copyDrizzleFiles] copied/updated migration SQL file: ${migrationFileName}`);
|
|
4589
4857
|
}
|
|
4590
4858
|
// Copy journal JSON file (always overwrite to ensure it's up-to-date with all migrations)
|
|
4591
4859
|
const journalPath = `${metaDirPath}/_journal.json`;
|
|
4592
4860
|
await BaseFileManager.saveFile(journalPath, journalJson);
|
|
4593
|
-
logger
|
|
4861
|
+
logger('[Db.copyDrizzleFiles] copied/updated journal JSON file');
|
|
4594
4862
|
// Copy snapshot JSON file (use the latest snapshot based on the highest idx in journal)
|
|
4595
4863
|
// Snapshot files are named like: 0000_snapshot.json, 0001_snapshot.json, etc.
|
|
4596
4864
|
// The tag format is like "0000_married_malice", so we extract the numeric prefix
|
|
@@ -4601,11 +4869,11 @@ class BrowserDb {
|
|
|
4601
4869
|
const snapshotPath = `${metaDirPath}/${snapshotFileName}`;
|
|
4602
4870
|
// Always overwrite snapshot to ensure it's up-to-date
|
|
4603
4871
|
await BaseFileManager.saveFile(snapshotPath, snapshotJson);
|
|
4604
|
-
logger
|
|
4605
|
-
logger
|
|
4872
|
+
logger(`[Db.copyDrizzleFiles] copied/updated snapshot JSON file: ${snapshotFileName}`);
|
|
4873
|
+
logger('[Db.copyDrizzleFiles] drizzle files copied successfully');
|
|
4606
4874
|
}
|
|
4607
4875
|
catch (error) {
|
|
4608
|
-
logger
|
|
4876
|
+
logger('[Db.copyDrizzleFiles] error copying drizzle files', error);
|
|
4609
4877
|
// Don't throw - the files might already exist or migration might work without them
|
|
4610
4878
|
// The migration will fail later if the files are truly needed
|
|
4611
4879
|
}
|
|
@@ -4614,12 +4882,12 @@ class BrowserDb {
|
|
|
4614
4882
|
async runMigrations(db, _pathToDbDir) {
|
|
4615
4883
|
try {
|
|
4616
4884
|
const migrations = getEmbeddedMigrations();
|
|
4617
|
-
logger
|
|
4885
|
+
logger('[Db.runMigrations] embedded migrations', migrations.length);
|
|
4618
4886
|
await applyEmbeddedMigrations(db, migrations, undefined, (queries, migration) => this.runMigrationQueries(db, queries, canRunInTransaction(migration)));
|
|
4619
|
-
logger
|
|
4887
|
+
logger('[Db.runMigrations] migrations completed');
|
|
4620
4888
|
}
|
|
4621
4889
|
catch (error) {
|
|
4622
|
-
logger
|
|
4890
|
+
logger('[Db.runMigrations] error', JSON.stringify(error));
|
|
4623
4891
|
throw error;
|
|
4624
4892
|
}
|
|
4625
4893
|
}
|
|
@@ -4726,12 +4994,12 @@ class BrowserDb {
|
|
|
4726
4994
|
countRun();
|
|
4727
4995
|
subscriber.next(data);
|
|
4728
4996
|
}, (err) => {
|
|
4729
|
-
logger
|
|
4997
|
+
logger('[BaseDb.liveQuery] SQLocal reactiveQuery error:', err);
|
|
4730
4998
|
subscriber.error(err);
|
|
4731
4999
|
});
|
|
4732
5000
|
}
|
|
4733
5001
|
catch (error) {
|
|
4734
|
-
logger
|
|
5002
|
+
logger('[BaseDb.liveQuery] SQLocal reactiveQuery setup failed:', error);
|
|
4735
5003
|
subscriber.error(error);
|
|
4736
5004
|
return;
|
|
4737
5005
|
}
|
|
@@ -4780,224 +5048,13 @@ function liveQueryKey(statement) {
|
|
|
4780
5048
|
}
|
|
4781
5049
|
}
|
|
4782
5050
|
|
|
4783
|
-
const logger = debug("seedSdk:browser:ArweaveClient");
|
|
4784
|
-
// Cached Arweave instance (keyed by gateway so setHost / protocol changes apply)
|
|
4785
|
-
let _arweaveInstance = null;
|
|
4786
|
-
let _arweaveGatewayKey = null;
|
|
4787
|
-
/**
|
|
4788
|
-
* Get or create the Arweave instance for browser
|
|
4789
|
-
*/
|
|
4790
|
-
const getArweaveInstance = () => {
|
|
4791
|
-
const gatewayKey = `${BaseArweaveClient.getProtocol()}://${BaseArweaveClient.getHost()}`;
|
|
4792
|
-
if (_arweaveInstance && _arweaveGatewayKey === gatewayKey) {
|
|
4793
|
-
return _arweaveInstance;
|
|
4794
|
-
}
|
|
4795
|
-
_arweaveGatewayKey = gatewayKey;
|
|
4796
|
-
const apiConfig = BaseArweaveClient.getArweaveJsApiConfig();
|
|
4797
|
-
// Handle both ES modules and CommonJS exports from arweave package
|
|
4798
|
-
if ("default" in Arweave && typeof Arweave.default?.init === "function") {
|
|
4799
|
-
_arweaveInstance = Arweave.default.init(apiConfig);
|
|
4800
|
-
}
|
|
4801
|
-
else {
|
|
4802
|
-
_arweaveInstance = Arweave.init(apiConfig);
|
|
4803
|
-
}
|
|
4804
|
-
return _arweaveInstance;
|
|
4805
|
-
};
|
|
4806
|
-
class BrowserArweaveClient {
|
|
4807
|
-
getArweaveClient() {
|
|
4808
|
-
return new GraphQLClient(BaseArweaveClient.getEndpoint());
|
|
4809
|
-
}
|
|
4810
|
-
async getTransactionStatus(transactionId) {
|
|
4811
|
-
return fetchTransactionStatusAcrossGateways(transactionId);
|
|
4812
|
-
}
|
|
4813
|
-
async getTransactionData(transactionId, options) {
|
|
4814
|
-
// Preferred gateways (usually the one the item was uploaded through) serve it before L1 does.
|
|
4815
|
-
// `/raw` is already decoded, so skip them when the caller asked for undecoded data.
|
|
4816
|
-
const preferred = options?.decode === false ? [] : getPreferredArweaveReadBaseUrls();
|
|
4817
|
-
for (const base of preferred) {
|
|
4818
|
-
const response = await fetchArweaveRawFromBaseUrl(base, transactionId);
|
|
4819
|
-
if (!response)
|
|
4820
|
-
continue;
|
|
4821
|
-
try {
|
|
4822
|
-
if (options?.string) {
|
|
4823
|
-
return await response.text();
|
|
4824
|
-
}
|
|
4825
|
-
return new Uint8Array(await response.arrayBuffer());
|
|
4826
|
-
}
|
|
4827
|
-
catch (error) {
|
|
4828
|
-
logger("Error reading preferred gateway response:", error);
|
|
4829
|
-
}
|
|
4830
|
-
}
|
|
4831
|
-
// Path-prefixed proxies (app-server Hyper proxy) are not supported by arweave.init host;
|
|
4832
|
-
// fetch via getRawUrl so /api/seed-gateway/... works.
|
|
4833
|
-
if (BaseArweaveClient.getGatewayPath()) {
|
|
4834
|
-
const response = await fetch(BaseArweaveClient.getRawUrl(transactionId));
|
|
4835
|
-
if (!response.ok) {
|
|
4836
|
-
throw new Error(`Failed to fetch transaction data: HTTP ${response.status}`);
|
|
4837
|
-
}
|
|
4838
|
-
if (options?.string) {
|
|
4839
|
-
return response.text();
|
|
4840
|
-
}
|
|
4841
|
-
return new Uint8Array(await response.arrayBuffer());
|
|
4842
|
-
}
|
|
4843
|
-
const arweave = getArweaveInstance();
|
|
4844
|
-
try {
|
|
4845
|
-
const data = await arweave.transactions.getData(transactionId, {
|
|
4846
|
-
decode: options?.decode ?? true,
|
|
4847
|
-
string: options?.string ?? false,
|
|
4848
|
-
});
|
|
4849
|
-
if (options?.string && typeof data === "string") {
|
|
4850
|
-
return data;
|
|
4851
|
-
}
|
|
4852
|
-
// Ensure we return Uint8Array
|
|
4853
|
-
if (data instanceof Uint8Array) {
|
|
4854
|
-
return data;
|
|
4855
|
-
}
|
|
4856
|
-
// Handle string data when not requesting string
|
|
4857
|
-
if (typeof data === "string") {
|
|
4858
|
-
return new TextEncoder().encode(data);
|
|
4859
|
-
}
|
|
4860
|
-
return data;
|
|
4861
|
-
}
|
|
4862
|
-
catch (error) {
|
|
4863
|
-
logger("Error fetching transaction data:", error);
|
|
4864
|
-
throw error;
|
|
4865
|
-
}
|
|
4866
|
-
}
|
|
4867
|
-
async getTransactionTags(transactionId) {
|
|
4868
|
-
const client = this.getArweaveClient();
|
|
4869
|
-
try {
|
|
4870
|
-
const result = await client.request(GET_TRANSACTION_TAGS, { transactionId });
|
|
4871
|
-
if (!result.tags?.tags) {
|
|
4872
|
-
return [];
|
|
4873
|
-
}
|
|
4874
|
-
return result.tags.tags.map((tag) => ({
|
|
4875
|
-
name: tag.name,
|
|
4876
|
-
value: tag.value,
|
|
4877
|
-
}));
|
|
4878
|
-
}
|
|
4879
|
-
catch (error) {
|
|
4880
|
-
logger("Error fetching transaction tags:", error);
|
|
4881
|
-
return [];
|
|
4882
|
-
}
|
|
4883
|
-
}
|
|
4884
|
-
async createTransaction(data, options) {
|
|
4885
|
-
const arweave = getArweaveInstance();
|
|
4886
|
-
const tx = await arweave.createTransaction({
|
|
4887
|
-
data,
|
|
4888
|
-
});
|
|
4889
|
-
// Add tags if provided
|
|
4890
|
-
if (options?.tags) {
|
|
4891
|
-
for (const tag of options.tags) {
|
|
4892
|
-
tx.addTag(tag.name, tag.value);
|
|
4893
|
-
}
|
|
4894
|
-
}
|
|
4895
|
-
return tx;
|
|
4896
|
-
}
|
|
4897
|
-
async downloadFiles(params) {
|
|
4898
|
-
const { transactionIds, excludedTransactions } = params;
|
|
4899
|
-
const results = [];
|
|
4900
|
-
const baseUrl = BaseArweaveClient.getBaseUrl();
|
|
4901
|
-
for (const transactionId of transactionIds) {
|
|
4902
|
-
// Skip excluded transactions
|
|
4903
|
-
if (excludedTransactions?.has(transactionId)) {
|
|
4904
|
-
continue;
|
|
4905
|
-
}
|
|
4906
|
-
try {
|
|
4907
|
-
const url = `${baseUrl}/raw/${transactionId}`;
|
|
4908
|
-
const response = await fetch(url);
|
|
4909
|
-
if (!response.ok) {
|
|
4910
|
-
results.push({
|
|
4911
|
-
transactionId,
|
|
4912
|
-
success: false,
|
|
4913
|
-
error: `HTTP ${response.status}: ${response.statusText}`,
|
|
4914
|
-
});
|
|
4915
|
-
continue;
|
|
4916
|
-
}
|
|
4917
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
4918
|
-
const data = new Uint8Array(arrayBuffer);
|
|
4919
|
-
// Detect content type
|
|
4920
|
-
const contentType = response.headers.get("content-type") || undefined;
|
|
4921
|
-
results.push({
|
|
4922
|
-
transactionId,
|
|
4923
|
-
success: true,
|
|
4924
|
-
contentType,
|
|
4925
|
-
data,
|
|
4926
|
-
});
|
|
4927
|
-
}
|
|
4928
|
-
catch (error) {
|
|
4929
|
-
logger(`Error downloading transaction ${transactionId}:`, error);
|
|
4930
|
-
results.push({
|
|
4931
|
-
transactionId,
|
|
4932
|
-
success: false,
|
|
4933
|
-
error: error instanceof Error ? error.message : String(error),
|
|
4934
|
-
});
|
|
4935
|
-
}
|
|
4936
|
-
}
|
|
4937
|
-
return results;
|
|
4938
|
-
}
|
|
4939
|
-
}
|
|
4940
|
-
BaseArweaveClient.configure(new BrowserArweaveClient());
|
|
4941
|
-
|
|
4942
|
-
class BrowserEasClient {
|
|
4943
|
-
/** Reads the endpoint per call so SDK / publish chain config applied after import takes effect. */
|
|
4944
|
-
getEasClient() {
|
|
4945
|
-
const url = getEasEndpoint();
|
|
4946
|
-
if (this.easClient?.url !== url) {
|
|
4947
|
-
this.easClient = { url, client: createEasGraphQLClient(url) };
|
|
4948
|
-
}
|
|
4949
|
-
return this.easClient.client;
|
|
4950
|
-
}
|
|
4951
|
-
}
|
|
4952
|
-
BaseEasClient.configure(new BrowserEasClient());
|
|
4953
|
-
|
|
4954
|
-
/**
|
|
4955
|
-
* Cached results are only reused within a query's staleTime (0 unless the caller sets one), so
|
|
4956
|
-
* they don't need to outlive that by much. Nothing persists this cache.
|
|
4957
|
-
*/
|
|
4958
|
-
const QUERY_GC_TIME_MS = 1000 * 60 * 5;
|
|
4959
|
-
class BrowserQueryClient {
|
|
4960
|
-
getQueryClient() {
|
|
4961
|
-
if (this.queryClient)
|
|
4962
|
-
return this.queryClient;
|
|
4963
|
-
const reactQueryClient = new QueryClient({
|
|
4964
|
-
defaultOptions: {
|
|
4965
|
-
queries: {
|
|
4966
|
-
networkMode: 'offlineFirst',
|
|
4967
|
-
gcTime: QUERY_GC_TIME_MS,
|
|
4968
|
-
},
|
|
4969
|
-
},
|
|
4970
|
-
});
|
|
4971
|
-
const queryClient = {
|
|
4972
|
-
fetchQuery: async (options) => {
|
|
4973
|
-
const { queryKey, queryFn, networkMode, staleTime } = options;
|
|
4974
|
-
return reactQueryClient.query({
|
|
4975
|
-
queryKey,
|
|
4976
|
-
queryFn,
|
|
4977
|
-
networkMode: networkMode,
|
|
4978
|
-
staleTime,
|
|
4979
|
-
});
|
|
4980
|
-
},
|
|
4981
|
-
getQueryData: (queryKey) => {
|
|
4982
|
-
return reactQueryClient.getQueryData(queryKey);
|
|
4983
|
-
},
|
|
4984
|
-
removeQueries: async (filters) => {
|
|
4985
|
-
await reactQueryClient.removeQueries(filters);
|
|
4986
|
-
},
|
|
4987
|
-
};
|
|
4988
|
-
this.queryClient = queryClient;
|
|
4989
|
-
return queryClient;
|
|
4990
|
-
}
|
|
4991
|
-
}
|
|
4992
|
-
BaseQueryClient.configure(new BrowserQueryClient());
|
|
4993
|
-
|
|
4994
5051
|
function createPlatformServices() {
|
|
4995
5052
|
return {
|
|
4996
5053
|
fileManager: new BrowserFileManager(),
|
|
4997
5054
|
db: new BrowserDb(),
|
|
4998
|
-
arweaveClient: new
|
|
4999
|
-
easClient: new
|
|
5000
|
-
queryClient: new
|
|
5055
|
+
arweaveClient: new DefaultArweaveClient(),
|
|
5056
|
+
easClient: new DefaultEasClient(),
|
|
5057
|
+
queryClient: new DefaultQueryClient(),
|
|
5001
5058
|
};
|
|
5002
5059
|
}
|
|
5003
5060
|
/**
|
|
@@ -5009,4 +5066,4 @@ function resolveFilesDir(filesDir) {
|
|
|
5009
5066
|
}
|
|
5010
5067
|
|
|
5011
5068
|
export { createPlatformServices as c, isSkippableOpfsEntryError as i, resolveFilesDir as r };
|
|
5012
|
-
//# sourceMappingURL=index.browser-
|
|
5069
|
+
//# sourceMappingURL=index.browser-CUmBVYen.js.map
|