@seedprotocol/sdk 0.7.6 → 0.7.7-next.988.g7046e66
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/{ClientManager-D6YA20jP.js → ClientManager-DdqRofK6.js} +297 -218
- package/dist/ClientManager-DdqRofK6.js.map +1 -0
- package/dist/{Item-B1MH0tXx.js → Item-DmK1PgK9.js} +233 -330
- package/dist/Item-DmK1PgK9.js.map +1 -0
- package/dist/{ModelProperty-Dw6dHdu_.js → ModelProperty-DaJAII87.js} +33 -33
- package/dist/ModelProperty-DaJAII87.js.map +1 -0
- package/dist/{Schema-DppObO6h.js → Schema-DhlbBQs8.js} +49 -58
- package/dist/Schema-DhlbBQs8.js.map +1 -0
- package/dist/{SchemaValidationService-DXQ-D531.js → SchemaValidationService-9KHQAYQ4.js} +9 -9
- package/dist/SchemaValidationService-9KHQAYQ4.js.map +1 -0
- package/dist/{backfillMetadataPropertyIds-Uhzlwg9X.js → backfillMetadataPropertyIds-qoVxUEEl.js} +3 -3
- package/dist/{backfillMetadataPropertyIds-Uhzlwg9X.js.map → backfillMetadataPropertyIds-qoVxUEEl.js.map} +1 -1
- package/dist/{configurePlatform-CVoh3JeR.js → configurePlatform-CazqABrK.js} +2 -2
- package/dist/{configurePlatform-CVoh3JeR.js.map → configurePlatform-CazqABrK.js.map} +1 -1
- package/dist/{detachRowsBeforeDelete-CtmIFpgV.js → detachRowsBeforeDelete-yatbnC27.js} +2 -2
- package/dist/{detachRowsBeforeDelete-CtmIFpgV.js.map → detachRowsBeforeDelete-yatbnC27.js.map} +1 -1
- package/dist/{discardNewDraft-oGYdB5vS.js → discardNewDraft-q1krLqtL.js} +5 -5
- package/dist/{discardNewDraft-oGYdB5vS.js.map → discardNewDraft-q1krLqtL.js.map} +1 -1
- package/dist/dist/{ClientManager-D6YA20jP.d.ts → ClientManager-DdqRofK6.d.ts} +2 -1
- package/dist/dist/ClientManager-DdqRofK6.d.ts.map +1 -0
- package/dist/dist/{Item-B1MH0tXx.d.ts → Item-DmK1PgK9.d.ts} +16 -23
- package/dist/dist/Item-DmK1PgK9.d.ts.map +1 -0
- package/dist/dist/{ModelProperty-Dw6dHdu_.d.ts → ModelProperty-DaJAII87.d.ts} +1 -1
- package/dist/dist/{ModelProperty-Dw6dHdu_.d.ts.map → ModelProperty-DaJAII87.d.ts.map} +1 -1
- package/dist/dist/{Schema-DppObO6h.d.ts → Schema-DhlbBQs8.d.ts} +2 -2
- package/dist/dist/{Schema-DppObO6h.d.ts.map → Schema-DhlbBQs8.d.ts.map} +1 -1
- package/dist/dist/{SchemaValidationService-DXQ-D531.d.ts → SchemaValidationService-9KHQAYQ4.d.ts} +4 -4
- package/dist/dist/{SchemaValidationService-DXQ-D531.d.ts.map → SchemaValidationService-9KHQAYQ4.d.ts.map} +1 -1
- package/dist/dist/{backfillMetadataPropertyIds-Uhzlwg9X.d.ts → backfillMetadataPropertyIds-qoVxUEEl.d.ts} +1 -1
- package/dist/dist/backfillMetadataPropertyIds-qoVxUEEl.d.ts.map +1 -0
- package/dist/dist/{configurePlatform-CVoh3JeR.d.ts → configurePlatform-CazqABrK.d.ts} +1 -1
- package/dist/dist/configurePlatform-CazqABrK.d.ts.map +1 -0
- package/dist/dist/{detachRowsBeforeDelete-CtmIFpgV.d.ts → detachRowsBeforeDelete-yatbnC27.d.ts} +1 -1
- package/dist/dist/detachRowsBeforeDelete-yatbnC27.d.ts.map +1 -0
- package/dist/dist/{discardNewDraft-oGYdB5vS.d.ts → discardNewDraft-q1krLqtL.d.ts} +1 -1
- package/dist/dist/discardNewDraft-q1krLqtL.d.ts.map +1 -0
- package/dist/dist/{eas-CSm5wmry.d.ts → eas-CPYt-QVJ.d.ts} +1 -1
- package/dist/dist/eas-CPYt-QVJ.d.ts.map +1 -0
- package/dist/dist/{errors-3tc6XkCB.d.ts → errors-DuFqGrjo.d.ts} +21 -8
- package/dist/dist/errors-DuFqGrjo.d.ts.map +1 -0
- package/dist/dist/{getItem-DM3a-7XE.d.ts → getItem-DPapr9uy.d.ts} +1 -1
- package/dist/dist/getItem-DPapr9uy.d.ts.map +1 -0
- package/dist/dist/{getPublishPayload-CJF0k5d8.d.ts → getPublishPayload-Dnv38ZW1.d.ts} +1 -1
- package/dist/dist/getPublishPayload-Dnv38ZW1.d.ts.map +1 -0
- package/dist/dist/{getPublishUploads-C7-fYIgX.d.ts → getPublishUploads-Dd7dCxNi.d.ts} +1 -1
- package/dist/dist/{getPublishUploads-C7-fYIgX.d.ts.map → getPublishUploads-Dd7dCxNi.d.ts.map} +1 -1
- package/dist/dist/{index--mmQ3LQu.d.ts → index-CTidoFhC.d.ts} +5 -5
- package/dist/dist/index-CTidoFhC.d.ts.map +1 -0
- package/dist/dist/{index-CrvIcVFJ.d.ts → index-DeUHrBqA.d.ts} +8 -4
- package/dist/dist/index-DeUHrBqA.d.ts.map +1 -0
- package/dist/dist/{index-B7yAoYli.d.ts → index-PnK3Ak9Z.d.ts} +1 -1
- package/dist/dist/{index-B7yAoYli.d.ts.map → index-PnK3Ak9Z.d.ts.map} +1 -1
- package/dist/dist/{index.browser-BmVS-c2C.d.ts → index.browser-CRvkFEhl.d.ts} +4 -4
- package/dist/dist/{index.browser-BmVS-c2C.d.ts.map → index.browser-CRvkFEhl.d.ts.map} +1 -1
- package/dist/dist/{index.node-BKpbCAWt.d.ts → index.node-DQTc7kEl.d.ts} +1 -1
- package/dist/dist/{index.node-BKpbCAWt.d.ts.map → index.node-DQTc7kEl.d.ts.map} +1 -1
- package/dist/dist/platform.browser.d.ts +2 -2
- package/dist/dist/platform.node.d.ts +2 -2
- package/dist/dist/{property-DQ-Owzki.d.ts → property-Dk_5t4-p.d.ts} +3 -3
- package/dist/dist/property-Dk_5t4-p.d.ts.map +1 -0
- package/dist/dist/{propertyValidationRules-BDhFjlwP.d.ts → propertyValidationRules-BtUZdfft.d.ts} +1 -1
- package/dist/dist/propertyValidationRules-BtUZdfft.d.ts.map +1 -0
- package/dist/dist/{publishDraftGraph-CzPd9oe9.d.ts → publishDraftGraph-CN7EsPVb.d.ts} +1 -1
- package/dist/dist/{publishDraftGraph-CzPd9oe9.d.ts.map → publishDraftGraph-CN7EsPVb.d.ts.map} +1 -1
- package/dist/dist/{resetAmbiguousLegacyItemData-cXZm4NuG.d.ts → resetAmbiguousLegacyItemData-DzVlhD9u.d.ts} +1 -1
- package/dist/dist/resetAmbiguousLegacyItemData-DzVlhD9u.d.ts.map +1 -0
- package/dist/dist/{resolveModelForSyncedSeed-BgxtVCHI.d.ts → resolveModelForSyncedSeed-C_BzNN8r.d.ts} +1 -1
- package/dist/dist/resolveModelForSyncedSeed-C_BzNN8r.d.ts.map +1 -0
- package/dist/dist/{syncDbWithEas-Y5GysSCm.d.ts → syncDbWithEas-BMmxPq5o.d.ts} +1 -1
- package/dist/dist/syncDbWithEas-BMmxPq5o.d.ts.map +1 -0
- package/dist/dist/{tabEvents-D9x26vf2.d.ts → tabEvents-DyGJcILs.d.ts} +1 -1
- package/dist/dist/{tabEvents-D9x26vf2.d.ts.map → tabEvents-DyGJcILs.d.ts.map} +1 -1
- package/dist/dist/{tolerantWebAccess-BFU2t-SC.d.ts → tolerantWebAccess-Zxy2EUzu.d.ts} +1 -1
- package/dist/dist/{tolerantWebAccess-BFU2t-SC.d.ts.map → tolerantWebAccess-Zxy2EUzu.d.ts.map} +1 -1
- package/dist/dist/{updateSeedRevokedAt-CCF8WWYS.d.ts → updateSeedRevokedAt-DxhC4ABM.d.ts} +1 -1
- package/dist/dist/updateSeedRevokedAt-DxhC4ABM.d.ts.map +1 -0
- package/dist/{eas-CSm5wmry.js → eas-CPYt-QVJ.js} +4 -4
- package/dist/eas-CPYt-QVJ.js.map +1 -0
- package/dist/{errors-3tc6XkCB.js → errors-DuFqGrjo.js} +55 -41
- package/dist/errors-DuFqGrjo.js.map +1 -0
- package/dist/{getItem-DM3a-7XE.js → getItem-DPapr9uy.js} +4 -4
- package/dist/{getItem-DM3a-7XE.js.map → getItem-DPapr9uy.js.map} +1 -1
- package/dist/{getPublishPayload-CJF0k5d8.js → getPublishPayload-Dnv38ZW1.js} +16 -25
- package/dist/getPublishPayload-Dnv38ZW1.js.map +1 -0
- package/dist/{getPublishUploads-C7-fYIgX.js → getPublishUploads-Dd7dCxNi.js} +10 -10
- package/dist/getPublishUploads-Dd7dCxNi.js.map +1 -0
- package/dist/{index--mmQ3LQu.js → index-CTidoFhC.js} +9 -9
- package/dist/index-CTidoFhC.js.map +1 -0
- package/dist/{index-CrvIcVFJ.js → index-DeUHrBqA.js} +32 -15
- package/dist/index-DeUHrBqA.js.map +1 -0
- package/dist/{index-B7yAoYli.js → index-PnK3Ak9Z.js} +2 -2
- package/dist/index-PnK3Ak9Z.js.map +1 -0
- package/dist/{index.browser-BmVS-c2C.js → index.browser-CRvkFEhl.js} +26 -26
- package/dist/index.browser-CRvkFEhl.js.map +1 -0
- package/dist/{index.node-BKpbCAWt.js → index.node-DQTc7kEl.js} +7 -7
- package/dist/index.node-DQTc7kEl.js.map +1 -0
- package/dist/main.js +155 -26
- package/dist/main.js.map +1 -1
- package/dist/node.js +12 -12
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +5 -5
- package/dist/platform.node.js +4 -4
- package/dist/{property-DQ-Owzki.js → property-Dk_5t4-p.js} +11 -11
- package/dist/property-Dk_5t4-p.js.map +1 -0
- package/dist/{propertyValidationRules-BDhFjlwP.js → propertyValidationRules-BtUZdfft.js} +6 -6
- package/dist/{propertyValidationRules-BDhFjlwP.js.map → propertyValidationRules-BtUZdfft.js.map} +1 -1
- package/dist/{publishDraftGraph-CzPd9oe9.js → publishDraftGraph-CN7EsPVb.js} +7 -7
- package/dist/publishDraftGraph-CN7EsPVb.js.map +1 -0
- package/dist/{resetAmbiguousLegacyItemData-cXZm4NuG.js → resetAmbiguousLegacyItemData-DzVlhD9u.js} +2 -2
- package/dist/{resetAmbiguousLegacyItemData-cXZm4NuG.js.map → resetAmbiguousLegacyItemData-DzVlhD9u.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-BgxtVCHI.js → resolveModelForSyncedSeed-C_BzNN8r.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-BgxtVCHI.js.map → resolveModelForSyncedSeed-C_BzNN8r.js.map} +1 -1
- package/dist/src/Item/Item.d.ts +2 -2
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Item/errors.d.ts +25 -0
- package/dist/src/Item/errors.d.ts.map +1 -1
- package/dist/src/Item/service/actors/loadOrCreateItem.d.ts.map +1 -1
- package/dist/src/Item/service/itemMachineSingle.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts +14 -3
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/resolveRelatedValue.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/index.d.ts +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/index.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveFile.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveHtml.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/propertyMachine.d.ts +1 -6
- package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/src/Schema/Schema.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/loadOrCreateSchema.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/writeSchemaToDb.d.ts.map +1 -1
- package/dist/src/Schema/service/validation/SchemaValidationService.d.ts +1 -1
- package/dist/src/Schema/service/validation/SchemaValidationService.d.ts.map +1 -1
- package/dist/src/Schema/validation.d.ts.map +1 -1
- package/dist/src/browser/db/Db.d.ts +1 -1
- package/dist/src/browser/db/Db.d.ts.map +1 -1
- package/dist/src/browser/helpers/PathResolver.d.ts +2 -2
- package/dist/src/browser/helpers/PathResolver.d.ts.map +1 -1
- package/dist/src/browser/seed.d.ts +1 -1
- package/dist/src/browser/seed.d.ts.map +1 -1
- package/dist/src/browser/workers/imageResize.d.ts.map +1 -1
- package/dist/src/client/BaseClientManager.d.ts +1 -1
- package/dist/src/client/BaseClientManager.d.ts.map +1 -1
- package/dist/src/client/ClientManager.d.ts +1 -0
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
- package/dist/src/client/actors/fileSystemInit.d.ts.map +1 -1
- package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
- package/dist/src/client/constants.d.ts.map +1 -1
- package/dist/src/db/clearStoredDisplayUrls.d.ts +18 -0
- package/dist/src/db/clearStoredDisplayUrls.d.ts.map +1 -0
- package/dist/src/db/read/getItems.d.ts.map +1 -1
- package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/src/db/read/nameMatchLevels.d.ts +7 -3
- package/dist/src/db/read/nameMatchLevels.d.ts.map +1 -1
- package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts +10 -0
- package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts.map +1 -1
- package/dist/src/db/write/deleteItem.d.ts +4 -0
- package/dist/src/db/write/deleteItem.d.ts.map +1 -1
- package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
- package/dist/src/eas.d.ts.map +1 -1
- package/dist/src/events/item/index.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/events/services/allItems.d.ts +1 -1
- package/dist/src/events/services/allItems.d.ts.map +1 -1
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/helpers/file/fetchAll/actors.d.ts.map +1 -1
- package/dist/src/helpers/file/fetchAll/index.d.ts.map +1 -1
- package/dist/src/helpers/schema.d.ts.map +1 -1
- package/dist/src/helpers/updateSchema.d.ts +1 -1
- package/dist/src/helpers/updateSchema.d.ts.map +1 -1
- package/dist/src/imports/json.d.ts.map +1 -1
- package/dist/src/imports/markdown.d.ts +1 -1
- package/dist/src/imports/markdown.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/interfaces/IItem.d.ts +1 -1
- package/dist/src/interfaces/IItem.d.ts.map +1 -1
- package/dist/src/interfaces/IItemProperty.d.ts +5 -1
- package/dist/src/interfaces/IItemProperty.d.ts.map +1 -1
- package/dist/src/services/write/actors/validateEntity.d.ts.map +1 -1
- package/dist/src/services/write/writeProcessMachine.d.ts +3 -4
- package/dist/src/services/write/writeProcessMachine.d.ts.map +1 -1
- package/dist/src/types/fileManager.d.ts.map +1 -1
- package/dist/src/types/item.d.ts +5 -4
- package/dist/src/types/item.d.ts.map +1 -1
- package/dist/src/types/model.d.ts.map +1 -1
- package/dist/src/types/property.d.ts +5 -5
- package/dist/src/types/property.d.ts.map +1 -1
- package/dist/{syncDbWithEas-Y5GysSCm.js → syncDbWithEas-BMmxPq5o.js} +17 -18
- package/dist/syncDbWithEas-BMmxPq5o.js.map +1 -0
- package/dist/{tabEvents-D9x26vf2.js → tabEvents-DyGJcILs.js} +4 -4
- package/dist/{tabEvents-D9x26vf2.js.map → tabEvents-DyGJcILs.js.map} +1 -1
- package/dist/{tolerantWebAccess-BFU2t-SC.js → tolerantWebAccess-Zxy2EUzu.js} +6 -6
- package/dist/{tolerantWebAccess-BFU2t-SC.js.map → tolerantWebAccess-Zxy2EUzu.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-CCF8WWYS.js → updateSeedRevokedAt-DxhC4ABM.js} +3 -3
- package/dist/{updateSeedRevokedAt-CCF8WWYS.js.map → updateSeedRevokedAt-DxhC4ABM.js.map} +1 -1
- package/package.json +6 -6
- package/dist/ClientManager-D6YA20jP.js.map +0 -1
- package/dist/Item-B1MH0tXx.js.map +0 -1
- package/dist/ModelProperty-Dw6dHdu_.js.map +0 -1
- package/dist/Schema-DppObO6h.js.map +0 -1
- package/dist/SchemaValidationService-DXQ-D531.js.map +0 -1
- package/dist/dist/ClientManager-D6YA20jP.d.ts.map +0 -1
- package/dist/dist/Item-B1MH0tXx.d.ts.map +0 -1
- package/dist/dist/backfillMetadataPropertyIds-Uhzlwg9X.d.ts.map +0 -1
- package/dist/dist/configurePlatform-CVoh3JeR.d.ts.map +0 -1
- package/dist/dist/detachRowsBeforeDelete-CtmIFpgV.d.ts.map +0 -1
- package/dist/dist/discardNewDraft-oGYdB5vS.d.ts.map +0 -1
- package/dist/dist/eas-CSm5wmry.d.ts.map +0 -1
- package/dist/dist/errors-3tc6XkCB.d.ts.map +0 -1
- package/dist/dist/getItem-DM3a-7XE.d.ts.map +0 -1
- package/dist/dist/getPublishPayload-CJF0k5d8.d.ts.map +0 -1
- package/dist/dist/index--mmQ3LQu.d.ts.map +0 -1
- package/dist/dist/index-CrvIcVFJ.d.ts.map +0 -1
- package/dist/dist/property-DQ-Owzki.d.ts.map +0 -1
- package/dist/dist/propertyValidationRules-BDhFjlwP.d.ts.map +0 -1
- package/dist/dist/resetAmbiguousLegacyItemData-cXZm4NuG.d.ts.map +0 -1
- package/dist/dist/resolveModelForSyncedSeed-BgxtVCHI.d.ts.map +0 -1
- package/dist/dist/syncDbWithEas-Y5GysSCm.d.ts.map +0 -1
- package/dist/dist/updateSeedRevokedAt-CCF8WWYS.d.ts.map +0 -1
- package/dist/eas-CSm5wmry.js.map +0 -1
- package/dist/errors-3tc6XkCB.js.map +0 -1
- package/dist/getPublishPayload-CJF0k5d8.js.map +0 -1
- package/dist/getPublishUploads-C7-fYIgX.js.map +0 -1
- package/dist/index--mmQ3LQu.js.map +0 -1
- package/dist/index-B7yAoYli.js.map +0 -1
- package/dist/index-CrvIcVFJ.js.map +0 -1
- package/dist/index.browser-BmVS-c2C.js.map +0 -1
- package/dist/index.node-BKpbCAWt.js.map +0 -1
- package/dist/property-DQ-Owzki.js.map +0 -1
- package/dist/publishDraftGraph-CzPd9oe9.js.map +0 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts +0 -5
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts.map +0 -1
- package/dist/src/db/write/recoverDeletedItem.d.ts +0 -5
- package/dist/src/db/write/recoverDeletedItem.d.ts.map +0 -1
- package/dist/src/interfaces/IEasClient.d.ts +0 -3
- package/dist/src/interfaces/IEasClient.d.ts.map +0 -1
- package/dist/syncDbWithEas-Y5GysSCm.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { startCase, isEqual } from 'lodash-es';
|
|
2
|
-
import { B as BaseDb, o as easSyncProcesses, I as eventEmitter, ac as isBrowser, a1 as isNode, aE as normalizeAddressConfig, aS as isTestOrSeedDev, j as appState, aT as downloadAllFilesRequestHandler, aU as downloadAllFilesBinaryRequestHandler, h as BaseFileManager, t as models$1, s as modelUids, C as seeds, aF as normalizeAddressList, A as schemas, aP as loadModelsFromDbForSchema, aM as addSchemaToDb, aJ as isInternalSchema, ai as generateId, aR as clearNameMatchLevels, aV as warnOnInvalidNameMatch, aW as INTERNAL_SCHEMA_IDS, aX as linkModelToSchema, n as normalizeDataType, ab as easPropertyNameForPublish, au as SEED_PROTOCOL_SCHEMA_NAME, r as modelSchemas, m as metadata$1, v as properties, L as resolveItemModelFileId, F as versions, ae as normalizePublisher,
|
|
2
|
+
import { B as BaseDb, o as easSyncProcesses, I as eventEmitter, ac as isBrowser, a1 as isNode, aE as normalizeAddressConfig, aS as isTestOrSeedDev, j as appState, aT as downloadAllFilesRequestHandler, aU as downloadAllFilesBinaryRequestHandler, h as BaseFileManager, ag as loadNameMatchLevels, t as models$1, s as modelUids, C as seeds, aF as normalizeAddressList, A as schemas, aP as loadModelsFromDbForSchema, aM as addSchemaToDb, aJ as isInternalSchema, ai as generateId, aR as clearNameMatchLevels, aV as warnOnInvalidNameMatch, aW as INTERNAL_SCHEMA_IDS, aX as linkModelToSchema, n as normalizeDataType, ab as easPropertyNameForPublish, au as SEED_PROTOCOL_SCHEMA_NAME, r as modelSchemas, m as metadata$1, v as properties, L as resolveItemModelFileId, F as versions, ae as normalizePublisher, p as htmlEmbeddedImageCoPublish, k as arweaveL1FinalizeJobs, z as publishProcesses, aY as getWatchedAddressesFromDb, aZ as getOwnedAddressesFromDb, a_ as CLIENT_NOT_INITIALIZED } from './index-DeUHrBqA.js';
|
|
3
3
|
import debug from 'debug';
|
|
4
4
|
import { createActor, setup, assign, fromPromise, fromCallback, waitFor } from 'xstate';
|
|
5
|
-
import { u as MachineIds, a0 as ClientManagerEvents, a1 as withLockedItemStorageRow, a2 as getItemStorageFilePath, a3 as writeItemStorageFile, e as compareMetadataRowsLatestFirst, w as writeInBatches, a4 as resolvePublisherFromSeedRow, C as ClientManagerState, G as isLocalUnsealedDraft, s as selectInBatches, I as Item } from './Item-
|
|
5
|
+
import { u as MachineIds, a0 as ClientManagerEvents, a1 as withLockedItemStorageRow, a2 as getItemStorageFilePath, a3 as writeItemStorageFile, e as compareMetadataRowsLatestFirst, w as writeInBatches, a4 as resolvePublisherFromSeedRow, C as ClientManagerState, G as isLocalUnsealedDraft, s as selectInBatches, I as Item } from './Item-DmK1PgK9.js';
|
|
6
6
|
import { eq, inArray, and, isNotNull, ne, desc, countDistinct, isNull, or, sql, like } from 'drizzle-orm';
|
|
7
|
-
import { a as withDbTabLock, i as isLeaderTab, c as postTabMessage, o as onTabMessage, w as whenLeaderTab, l as listenForOtherTabsEvents, s as startTabCoordination, b as withSeedDbLock, e as emitAcrossTabs, A as ADDRESSES_PERSISTED_EVENT, p as parseAddressesPersistedPayload, L as LOCAL_COPIES_REMOVED_EVENT } from './tabEvents-
|
|
7
|
+
import { a as withDbTabLock, i as isLeaderTab, c as postTabMessage, o as onTabMessage, w as whenLeaderTab, l as listenForOtherTabsEvents, s as startTabCoordination, b as withSeedDbLock, e as emitAcrossTabs, A as ADDRESSES_PERSISTED_EVENT, p as parseAddressesPersistedPayload, L as LOCAL_COPIES_REMOVED_EVENT } from './tabEvents-DyGJcILs.js';
|
|
8
8
|
import { seedGatewayConfigFromSeedConfig, setPreferredArweaveReadBaseUrls, resolveSeedGatewayEndpoints, setResolvedSeedGatewayEndpoints, BaseArweaveClient, ensureReadGatewaySelected, DEFAULT_ARWEAVE_HOST } from '@seedprotocol/arweave';
|
|
9
9
|
import { configureEasReadChain, easName, BaseQueryClient, BaseEasClient, GET_SCHEMAS, whenEasReadChainSettled, getEasReadChainId, DEFAULT_EAS_CHAIN_ID, isEasReadChainConfigured, isPlaceholderUid, localNamesInBestMatchTier, isValidEasAttestationUid } from '@seedprotocol/eas';
|
|
10
10
|
import 'pluralize';
|
|
@@ -212,7 +212,7 @@ function toRunSyncArg(options) {
|
|
|
212
212
|
return undefined;
|
|
213
213
|
}
|
|
214
214
|
const runEasSync = fromPromise(async ({ input, }) => {
|
|
215
|
-
const { runSyncFromEas } = await import('./syncDbWithEas-
|
|
215
|
+
const { runSyncFromEas } = await import('./syncDbWithEas-BMmxPq5o.js');
|
|
216
216
|
// Sync checks for rows and then inserts the rest (no unique index on uids), so syncs in
|
|
217
217
|
// different tabs take turns. A sync can run for minutes, so wait without a timeout.
|
|
218
218
|
await withDbTabLock('eas-sync', async () => {
|
|
@@ -422,7 +422,7 @@ function newCorrelationId() {
|
|
|
422
422
|
return `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
423
423
|
}
|
|
424
424
|
/** Requests deferred in this tab until it leads, by source; each runs once on takeover. */
|
|
425
|
-
const deferredUntilLeader$
|
|
425
|
+
const deferredUntilLeader$5 = new Set();
|
|
426
426
|
/**
|
|
427
427
|
* Automatic syncs run in the leader tab only (docs/MULTI_TAB.md). A tab that skips one runs it if
|
|
428
428
|
* it later becomes leader, so closing the leader doesn't lose the catch-up sync.
|
|
@@ -433,11 +433,11 @@ function runInLeaderTab(source, request) {
|
|
|
433
433
|
return;
|
|
434
434
|
}
|
|
435
435
|
log(`${source} sync skipped: another tab leads`);
|
|
436
|
-
if (deferredUntilLeader$
|
|
436
|
+
if (deferredUntilLeader$5.has(source))
|
|
437
437
|
return;
|
|
438
|
-
deferredUntilLeader$
|
|
438
|
+
deferredUntilLeader$5.add(source);
|
|
439
439
|
void whenLeaderTab().then(() => {
|
|
440
|
-
deferredUntilLeader$
|
|
440
|
+
deferredUntilLeader$5.delete(source);
|
|
441
441
|
request();
|
|
442
442
|
});
|
|
443
443
|
}
|
|
@@ -511,10 +511,10 @@ var easSyncManager = /*#__PURE__*/Object.freeze({
|
|
|
511
511
|
startEasSyncActor: startEasSyncActor
|
|
512
512
|
});
|
|
513
513
|
|
|
514
|
-
const logger$
|
|
514
|
+
const logger$g = debug('seedSdk:services:events');
|
|
515
515
|
const handleServiceSaveState = (event) => {
|
|
516
|
-
const {
|
|
517
|
-
logger$
|
|
516
|
+
const { serviceId } = event;
|
|
517
|
+
logger$g(`[browser] [service.saveState.request] serviceId: ${serviceId}`);
|
|
518
518
|
// TODO: This is called from Node as well. Do we need it? If so, need to generalize this to all platforms.
|
|
519
519
|
// localStorage.setItem(`seed_sdk_service_${serviceId}`, JSON.stringify(state))
|
|
520
520
|
};
|
|
@@ -532,7 +532,7 @@ const setupAllItemsEventHandlers = () => {
|
|
|
532
532
|
|
|
533
533
|
// AllItems services have been removed - this handler is no longer needed
|
|
534
534
|
// Service state persistence is now handled by entity instances directly
|
|
535
|
-
const saveServiceHandler = async (
|
|
535
|
+
const saveServiceHandler = async (_event) => {
|
|
536
536
|
// AllItems services removed - this functionality is no longer needed
|
|
537
537
|
// Entity instances (Schema, Model, Item) manage their own state
|
|
538
538
|
console.warn('[saveServiceHandler] AllItems services removed - handler is a no-op');
|
|
@@ -563,9 +563,9 @@ function applySeedConfigDefaults(config) {
|
|
|
563
563
|
return { ...config, filesDir, endpoints: next };
|
|
564
564
|
}
|
|
565
565
|
|
|
566
|
-
const logger$
|
|
566
|
+
const logger$f = debug('seedSdk:ClientManager:initialize');
|
|
567
567
|
const platformClassesInit = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
568
|
-
logger$
|
|
568
|
+
logger$f('initialize from ClientManager');
|
|
569
569
|
const { isInitialized } = context;
|
|
570
570
|
if (!event || !('options' in event)) {
|
|
571
571
|
throw new Error('Initialize event must include options');
|
|
@@ -590,7 +590,7 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
|
|
|
590
590
|
if (!config) {
|
|
591
591
|
throw new Error('client.init requires a config');
|
|
592
592
|
}
|
|
593
|
-
const _mod_0 = await import('./configurePlatform-
|
|
593
|
+
const _mod_0 = await import('./configurePlatform-CazqABrK.js');
|
|
594
594
|
const _ns_0 = _mod_0.a;
|
|
595
595
|
const { configurePlatform } = _ns_0;
|
|
596
596
|
if (isBrowser()) {
|
|
@@ -703,7 +703,7 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
|
|
|
703
703
|
};
|
|
704
704
|
});
|
|
705
705
|
|
|
706
|
-
const logger$
|
|
706
|
+
const logger$e = debug('seedSdk:client:writeToDb');
|
|
707
707
|
const saveAppState = fromCallback(({ sendBack, input: { key, value } }) => {
|
|
708
708
|
const _saveAppState = async () => {
|
|
709
709
|
try {
|
|
@@ -711,7 +711,7 @@ const saveAppState = fromCallback(({ sendBack, input: { key, value } }) => {
|
|
|
711
711
|
if (!appDb) {
|
|
712
712
|
// In test environments, continue anyway
|
|
713
713
|
if (isTestOrSeedDev()) {
|
|
714
|
-
logger$
|
|
714
|
+
logger$e('[client/actors] [saveAppState] App DB not found, but continuing in test environment');
|
|
715
715
|
return;
|
|
716
716
|
}
|
|
717
717
|
throw new Error('App DB not found');
|
|
@@ -727,13 +727,13 @@ const saveAppState = fromCallback(({ sendBack, input: { key, value } }) => {
|
|
|
727
727
|
value: JSON.stringify(value),
|
|
728
728
|
},
|
|
729
729
|
});
|
|
730
|
-
logger$
|
|
730
|
+
logger$e('result', result);
|
|
731
731
|
}
|
|
732
732
|
catch (error) {
|
|
733
|
-
logger$
|
|
733
|
+
logger$e('[client/actors] [saveAppState] Error saving app state:', error);
|
|
734
734
|
// In test environments, continue anyway
|
|
735
735
|
if (isTestOrSeedDev()) {
|
|
736
|
-
logger$
|
|
736
|
+
logger$e('[client/actors] [saveAppState] Continuing despite error in test environment');
|
|
737
737
|
return;
|
|
738
738
|
}
|
|
739
739
|
throw error;
|
|
@@ -748,10 +748,10 @@ const saveAppState = fromCallback(({ sendBack, input: { key, value } }) => {
|
|
|
748
748
|
});
|
|
749
749
|
})
|
|
750
750
|
.catch((error) => {
|
|
751
|
-
logger$
|
|
751
|
+
logger$e('[client/actors] [saveAppState] Error in promise chain:', error);
|
|
752
752
|
// In test environments, still send success to allow state machine to progress
|
|
753
753
|
if (isTestOrSeedDev()) {
|
|
754
|
-
logger$
|
|
754
|
+
logger$e('[client/actors] [saveAppState] Sending success despite error in test environment');
|
|
755
755
|
sendBack({
|
|
756
756
|
type: 'saveAppStateSuccess',
|
|
757
757
|
key,
|
|
@@ -787,7 +787,6 @@ const areFsListenersReady = () => {
|
|
|
787
787
|
return areReady;
|
|
788
788
|
};
|
|
789
789
|
|
|
790
|
-
debug('seedSdk:client:actors:fileSystemInit');
|
|
791
790
|
const fileSystemInit = fromCallback(({ sendBack, input: { context }, }) => {
|
|
792
791
|
setupFsListeners();
|
|
793
792
|
if (!areFsListenersReady()) {
|
|
@@ -821,7 +820,7 @@ const fileSystemInit = fromCallback(({ sendBack, input: { context }, }) => {
|
|
|
821
820
|
};
|
|
822
821
|
});
|
|
823
822
|
|
|
824
|
-
const logger$
|
|
823
|
+
const logger$d = debug('seedSdk:client:actors:dbInit');
|
|
825
824
|
const dbInit = fromCallback(({ sendBack, input: { context } }) => {
|
|
826
825
|
const _dbInit = async () => {
|
|
827
826
|
const { filesDir, dbConfig } = context;
|
|
@@ -835,14 +834,14 @@ const dbInit = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
835
834
|
if (!appDb) {
|
|
836
835
|
throw new Error('Database not available after preparation');
|
|
837
836
|
}
|
|
838
|
-
logger$
|
|
837
|
+
logger$d('[client/actors] [dbInit] Database prepared and ready');
|
|
839
838
|
};
|
|
840
839
|
_dbInit()
|
|
841
840
|
.then(() => {
|
|
842
841
|
sendBack({ type: ClientManagerEvents.DB_READY });
|
|
843
842
|
})
|
|
844
843
|
.catch((error) => {
|
|
845
|
-
logger$
|
|
844
|
+
logger$d('Error in dbInit:', error);
|
|
846
845
|
sendBack({
|
|
847
846
|
type: 'error',
|
|
848
847
|
error: error instanceof Error ? error : new Error(String(error))
|
|
@@ -850,7 +849,7 @@ const dbInit = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
850
849
|
});
|
|
851
850
|
});
|
|
852
851
|
|
|
853
|
-
const logger$
|
|
852
|
+
const logger$c = debug('seedSdk:client:actors:addModelsToStore');
|
|
854
853
|
const addModelsToStore = fromCallback(({ sendBack, input: { context } }) => {
|
|
855
854
|
const _addModelsToStore = async () => {
|
|
856
855
|
let { models } = context;
|
|
@@ -864,7 +863,7 @@ const addModelsToStore = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
864
863
|
// Models are now Model instances, no registration needed
|
|
865
864
|
// They should be created via Model.create() and are accessible via Model static methods
|
|
866
865
|
for (const [key] of Object.entries(allModels)) {
|
|
867
|
-
logger$
|
|
866
|
+
logger$c('model available:', key);
|
|
868
867
|
}
|
|
869
868
|
};
|
|
870
869
|
_addModelsToStore()
|
|
@@ -872,7 +871,7 @@ const addModelsToStore = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
872
871
|
sendBack({ type: ClientManagerEvents.ADD_MODELS_TO_STORE_SUCCESS });
|
|
873
872
|
})
|
|
874
873
|
.catch((error) => {
|
|
875
|
-
logger$
|
|
874
|
+
logger$c('[client/actors] [addModelsToStore] Error:', error);
|
|
876
875
|
sendBack({
|
|
877
876
|
type: 'error',
|
|
878
877
|
error: error instanceof Error ? error : new Error(String(error)),
|
|
@@ -880,7 +879,7 @@ const addModelsToStore = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
880
879
|
});
|
|
881
880
|
});
|
|
882
881
|
|
|
883
|
-
const logger$
|
|
882
|
+
const logger$b = debug('seedSdk:client:actors:addModelsToDb');
|
|
884
883
|
/**
|
|
885
884
|
* Returns every `models` row named in `modelNames`, inserting a null-schemaFileId stub for each name
|
|
886
885
|
* with no row yet (the schema import adopts stubs via findOrCreateModelRecord). Check-then-insert:
|
|
@@ -903,7 +902,7 @@ async function ensureModelStubs(appDb, modelNames, filesDir) {
|
|
|
903
902
|
.returning({ id: models$1.id, name: models$1.name, schemaFileId: models$1.schemaFileId }));
|
|
904
903
|
rows.push(...newlyInserted);
|
|
905
904
|
for (const name of modelsToInsert) {
|
|
906
|
-
logger$
|
|
905
|
+
logger$b('[client/actors] [addModelsToDb] inserted model:', name);
|
|
907
906
|
}
|
|
908
907
|
}
|
|
909
908
|
return rows;
|
|
@@ -943,7 +942,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
943
942
|
for (const modelName of modelNames) {
|
|
944
943
|
const foundModel = rowFor(modelName);
|
|
945
944
|
if (!foundModel) {
|
|
946
|
-
logger$
|
|
945
|
+
logger$b('[client/actors] [addModelsToDb] Warning: Could not find or create model:', modelName);
|
|
947
946
|
hasModelsInDb = false;
|
|
948
947
|
continue;
|
|
949
948
|
}
|
|
@@ -955,8 +954,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
955
954
|
}
|
|
956
955
|
// If we have no models to process, still send success (empty models is valid)
|
|
957
956
|
if (schemaDefsByModelName.size === 0) {
|
|
958
|
-
logger$
|
|
959
|
-
sendBack({ type: ClientManagerEvents.ADD_MODELS_TO_DB_SUCCESS });
|
|
957
|
+
logger$b('[client/actors] [addModelsToDb] No models to process, but continuing');
|
|
960
958
|
return;
|
|
961
959
|
}
|
|
962
960
|
const schemaDefs = Array.from(schemaDefsByModelName.values()).map(({ schemaDef }) => schemaDef);
|
|
@@ -1003,15 +1001,15 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1003
1001
|
requestEasSyncFromModelsInit();
|
|
1004
1002
|
}
|
|
1005
1003
|
else {
|
|
1006
|
-
logger$
|
|
1004
|
+
logger$b('[client/actors] [addModelsToDb] No schemas found from EAS, but continuing');
|
|
1007
1005
|
}
|
|
1008
1006
|
}
|
|
1009
1007
|
catch (error) {
|
|
1010
1008
|
if (isTestOrSeedDev()) {
|
|
1011
|
-
logger$
|
|
1009
|
+
logger$b('[client/actors] [addModelsToDb] Warning: Could not fetch schemas from EAS (background):', error.message);
|
|
1012
1010
|
}
|
|
1013
1011
|
else {
|
|
1014
|
-
logger$
|
|
1012
|
+
logger$b('[client/actors] [addModelsToDb] Error fetching schemas (background):', error.message);
|
|
1015
1013
|
}
|
|
1016
1014
|
// Probably offline: the startup sync waits for this lookup, so try again.
|
|
1017
1015
|
modelUidsRetry.schedule();
|
|
@@ -1023,14 +1021,18 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1023
1021
|
return hasModelsInDb;
|
|
1024
1022
|
};
|
|
1025
1023
|
_addModelsToDb()
|
|
1024
|
+
// Model.findByModelType reads the nameMatch levels synchronously: have them before init is ready.
|
|
1025
|
+
.then(() => loadNameMatchLevels().catch((error) => {
|
|
1026
|
+
logger$b('[client/actors] [addModelsToDb] Could not load nameMatch levels:', error);
|
|
1027
|
+
}))
|
|
1026
1028
|
.then(() => {
|
|
1027
1029
|
sendBack({ type: ClientManagerEvents.ADD_MODELS_TO_DB_SUCCESS });
|
|
1028
1030
|
})
|
|
1029
1031
|
.catch((error) => {
|
|
1030
|
-
logger$
|
|
1032
|
+
logger$b('[client/actors] [addModelsToDb] Error:', error);
|
|
1031
1033
|
// In test environments, still send success to allow initialization to complete
|
|
1032
1034
|
if (isTestOrSeedDev()) {
|
|
1033
|
-
logger$
|
|
1035
|
+
logger$b('[client/actors] [addModelsToDb] Continuing despite error in test environment');
|
|
1034
1036
|
sendBack({ type: ClientManagerEvents.ADD_MODELS_TO_DB_SUCCESS });
|
|
1035
1037
|
}
|
|
1036
1038
|
else {
|
|
@@ -1043,7 +1045,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1043
1045
|
return () => { };
|
|
1044
1046
|
});
|
|
1045
1047
|
|
|
1046
|
-
const logger$
|
|
1048
|
+
const logger$a = debug('seedSdk:helpers:localDbChain');
|
|
1047
1049
|
/** appState key recording which EAS chain the local database holds attestations from. */
|
|
1048
1050
|
const EAS_CHAIN_ID_APP_STATE_KEY = 'easChainId';
|
|
1049
1051
|
/**
|
|
@@ -1113,7 +1115,7 @@ async function loadLocalDbChain() {
|
|
|
1113
1115
|
const localChainId = await resolveLocalDbChainId(appDb);
|
|
1114
1116
|
if (localChainId !== undefined) {
|
|
1115
1117
|
configureEasReadChain('localDb', { chainId: localChainId });
|
|
1116
|
-
logger$
|
|
1118
|
+
logger$a('local DB holds chain %d', localChainId);
|
|
1117
1119
|
return;
|
|
1118
1120
|
}
|
|
1119
1121
|
if (isEasReadChainConfigured()) {
|
|
@@ -1139,7 +1141,7 @@ async function assertLocalDbChain() {
|
|
|
1139
1141
|
configureEasReadChain('localDb', { chainId: localChainId ?? chainId });
|
|
1140
1142
|
}
|
|
1141
1143
|
|
|
1142
|
-
const logger$
|
|
1144
|
+
const logger$9 = debug('seedSdk:client:actors:saveConfig');
|
|
1143
1145
|
let warnedKeptStoredAddresses = false;
|
|
1144
1146
|
/**
|
|
1145
1147
|
* Saves the addresses passed to init.
|
|
@@ -1180,13 +1182,13 @@ async function persistInitAddresses(appDb, { addresses, addressesProvided, owned
|
|
|
1180
1182
|
emitAcrossTabs(ADDRESSES_PERSISTED_EVENT, { owned, watched });
|
|
1181
1183
|
}
|
|
1182
1184
|
const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
1183
|
-
logger$
|
|
1185
|
+
logger$9('saveConfig starting');
|
|
1184
1186
|
const { endpoints, addresses, addressesProvided, ownedAddresses, watchedAddresses, arweaveDomain, uploadApiBaseUrl, gatewayTransport, gatewayHyperKey, gatewaySidecarHost, gatewaySidecarPort, gatewayProxyBaseUrl, } = context;
|
|
1185
1187
|
// Validate endpoints - required for proper initialization
|
|
1186
1188
|
// If endpoints are missing or invalid, initialization should fail
|
|
1187
1189
|
if (!endpoints || !endpoints.filePaths || !endpoints.files) {
|
|
1188
1190
|
const error = new Error('saveConfig called with invalid endpoints: endpoints must include both filePaths and files');
|
|
1189
|
-
logger$
|
|
1191
|
+
logger$9('[internal/actors] [saveConfig] Invalid endpoints:', { endpoints });
|
|
1190
1192
|
throw error;
|
|
1191
1193
|
}
|
|
1192
1194
|
const _saveConfig = async () => {
|
|
@@ -1195,7 +1197,7 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1195
1197
|
if (!appDb) {
|
|
1196
1198
|
// In test environments, continue anyway
|
|
1197
1199
|
if (isTestOrSeedDev()) {
|
|
1198
|
-
logger$
|
|
1200
|
+
logger$9('[internal/actors] [saveConfig] App DB not found, but continuing in test environment');
|
|
1199
1201
|
return;
|
|
1200
1202
|
}
|
|
1201
1203
|
throw new Error('App DB not found');
|
|
@@ -1250,10 +1252,10 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1250
1252
|
await loadLocalDbChain();
|
|
1251
1253
|
}
|
|
1252
1254
|
catch (error) {
|
|
1253
|
-
logger$
|
|
1255
|
+
logger$9('[internal/actors] [saveConfig] Error saving config:', error);
|
|
1254
1256
|
// In test environments, continue anyway
|
|
1255
1257
|
if (isTestOrSeedDev()) {
|
|
1256
|
-
logger$
|
|
1258
|
+
logger$9('[internal/actors] [saveConfig] Continuing despite error in test environment');
|
|
1257
1259
|
return;
|
|
1258
1260
|
}
|
|
1259
1261
|
throw error;
|
|
@@ -1262,14 +1264,14 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1262
1264
|
// Init writes run one tab at a time (docs/MULTI_TAB.md).
|
|
1263
1265
|
withSeedDbLock('init', context.filesDir, _saveConfig)
|
|
1264
1266
|
.then(() => {
|
|
1265
|
-
logger$
|
|
1267
|
+
logger$9('[internal/actors] [saveConfig] saveConfig success');
|
|
1266
1268
|
return sendBack({ type: ClientManagerEvents.SAVE_CONFIG_SUCCESS });
|
|
1267
1269
|
})
|
|
1268
1270
|
.catch((error) => {
|
|
1269
|
-
logger$
|
|
1271
|
+
logger$9('[internal/actors] [saveConfig] Error in saveConfig promise chain:', error);
|
|
1270
1272
|
// In test environments, still send success to allow state machine to progress
|
|
1271
1273
|
if (isTestOrSeedDev()) {
|
|
1272
|
-
logger$
|
|
1274
|
+
logger$9('[internal/actors] [saveConfig] Sending success despite error in test environment');
|
|
1273
1275
|
sendBack({ type: ClientManagerEvents.SAVE_CONFIG_SUCCESS });
|
|
1274
1276
|
}
|
|
1275
1277
|
else {
|
|
@@ -1282,7 +1284,7 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1282
1284
|
return () => { };
|
|
1283
1285
|
});
|
|
1284
1286
|
|
|
1285
|
-
const logger$
|
|
1287
|
+
const logger$8 = debug('seedSdk:helpers:schema');
|
|
1286
1288
|
/**
|
|
1287
1289
|
* Sanitize a schema name to be filesystem-safe
|
|
1288
1290
|
* Replaces all special characters (except alphanumeric, hyphens, underscores) with underscores
|
|
@@ -1409,7 +1411,6 @@ async function deleteSchema(name, version, schemaFileId) {
|
|
|
1409
1411
|
}
|
|
1410
1412
|
// Delete the file
|
|
1411
1413
|
const fs = await BaseFileManager.getFs();
|
|
1412
|
-
BaseFileManager.getPathModule();
|
|
1413
1414
|
try {
|
|
1414
1415
|
await fs.promises.unlink(filePath);
|
|
1415
1416
|
}
|
|
@@ -1450,7 +1451,7 @@ async function listSchemaFiles() {
|
|
|
1450
1451
|
continue;
|
|
1451
1452
|
}
|
|
1452
1453
|
}
|
|
1453
|
-
catch
|
|
1454
|
+
catch {
|
|
1454
1455
|
// If we can't read/parse the file, skip it
|
|
1455
1456
|
continue;
|
|
1456
1457
|
}
|
|
@@ -1478,7 +1479,7 @@ async function listCompleteSchemaFiles() {
|
|
|
1478
1479
|
const dirExists = await BaseFileManager.pathExists(workingDir);
|
|
1479
1480
|
if (!dirExists) {
|
|
1480
1481
|
// Directory doesn't exist yet - return empty array (not an error condition)
|
|
1481
|
-
logger$
|
|
1482
|
+
logger$8(`Working directory does not exist yet: ${workingDir}, returning empty schema list`);
|
|
1482
1483
|
return [];
|
|
1483
1484
|
}
|
|
1484
1485
|
const files = await fs.promises.readdir(workingDir);
|
|
@@ -1488,7 +1489,7 @@ async function listCompleteSchemaFiles() {
|
|
|
1488
1489
|
// Ids have no underscores but names can ("My_Schema"), so the id group stops at the first one
|
|
1489
1490
|
const match = file.match(/^(.+?)_(.+)_v(\d+)\.json$/);
|
|
1490
1491
|
if (match) {
|
|
1491
|
-
const [, schemaFileId,
|
|
1492
|
+
const [, schemaFileId, , versionStr] = match;
|
|
1492
1493
|
const version = parseInt(versionStr, 10);
|
|
1493
1494
|
if (!isNaN(version)) {
|
|
1494
1495
|
const filePath = path.join(workingDir, file);
|
|
@@ -1509,7 +1510,7 @@ async function listCompleteSchemaFiles() {
|
|
|
1509
1510
|
});
|
|
1510
1511
|
}
|
|
1511
1512
|
}
|
|
1512
|
-
catch
|
|
1513
|
+
catch {
|
|
1513
1514
|
// If we can't read/parse the file, skip it
|
|
1514
1515
|
continue;
|
|
1515
1516
|
}
|
|
@@ -1615,7 +1616,7 @@ async function loadAllSchemasFromDb() {
|
|
|
1615
1616
|
}
|
|
1616
1617
|
catch (error) {
|
|
1617
1618
|
// If we can't list schema files (e.g., directory doesn't exist yet), continue without file-based loading
|
|
1618
|
-
logger$
|
|
1619
|
+
logger$8(`Error listing complete schema files (continuing with DB data): ${error instanceof Error ? error.message : String(error)}`);
|
|
1619
1620
|
completeSchemaFiles = [];
|
|
1620
1621
|
}
|
|
1621
1622
|
}
|
|
@@ -1668,7 +1669,7 @@ async function loadAllSchemasFromDb() {
|
|
|
1668
1669
|
continue;
|
|
1669
1670
|
}
|
|
1670
1671
|
catch (error) {
|
|
1671
|
-
logger$
|
|
1672
|
+
logger$8(`Error parsing schemaData for ${schemaName}:`, error);
|
|
1672
1673
|
// Fall through to file-based loading
|
|
1673
1674
|
}
|
|
1674
1675
|
}
|
|
@@ -1710,7 +1711,7 @@ async function loadAllSchemasFromDb() {
|
|
|
1710
1711
|
continue;
|
|
1711
1712
|
}
|
|
1712
1713
|
catch (error) {
|
|
1713
|
-
logger$
|
|
1714
|
+
logger$8(`Error loading schema file for ${schemaName}:`, error);
|
|
1714
1715
|
// Fall through to try loading from schemaData if available
|
|
1715
1716
|
}
|
|
1716
1717
|
}
|
|
@@ -1754,7 +1755,7 @@ async function loadAllSchemasFromDb() {
|
|
|
1754
1755
|
continue;
|
|
1755
1756
|
}
|
|
1756
1757
|
catch (error) {
|
|
1757
|
-
logger$
|
|
1758
|
+
logger$8(`Error parsing schemaData for ${schemaName}:`, error);
|
|
1758
1759
|
}
|
|
1759
1760
|
}
|
|
1760
1761
|
}
|
|
@@ -1765,11 +1766,11 @@ async function loadAllSchemasFromDb() {
|
|
|
1765
1766
|
// Only process if not already in result
|
|
1766
1767
|
if (!processedSchemaNames.has(schemaFileInfo.name)) {
|
|
1767
1768
|
if (isInternalSchema(schemaFileInfo.name, schemaFileInfo.schemaFileId)) {
|
|
1768
|
-
logger$
|
|
1769
|
+
logger$8(`STEP 3: skipping internal schema file: ${schemaFileInfo.filePath}`);
|
|
1769
1770
|
continue;
|
|
1770
1771
|
}
|
|
1771
1772
|
try {
|
|
1772
|
-
logger$
|
|
1773
|
+
logger$8(`STEP 3: processing schema file: ${schemaFileInfo.name} from ${schemaFileInfo.filePath}`);
|
|
1773
1774
|
const content = await BaseFileManager.readFileAsString(schemaFileInfo.filePath);
|
|
1774
1775
|
const schemaFile = JSON.parse(content);
|
|
1775
1776
|
// Import this schema to database (mark as non-draft since it's in a file)
|
|
@@ -1789,7 +1790,7 @@ async function loadAllSchemasFromDb() {
|
|
|
1789
1790
|
processedSchemaNames.add(schemaFileInfo.name);
|
|
1790
1791
|
}
|
|
1791
1792
|
catch (error) {
|
|
1792
|
-
logger$
|
|
1793
|
+
logger$8(`Error loading schema file ${schemaFileInfo.filePath}:`, error);
|
|
1793
1794
|
}
|
|
1794
1795
|
}
|
|
1795
1796
|
}
|
|
@@ -1806,7 +1807,7 @@ async function migrateFileSchemasToDb() {
|
|
|
1806
1807
|
if (!db) {
|
|
1807
1808
|
throw new Error('Database not found');
|
|
1808
1809
|
}
|
|
1809
|
-
logger$
|
|
1810
|
+
logger$8('Starting migration of file-based schemas to database');
|
|
1810
1811
|
// Get all complete schema files
|
|
1811
1812
|
const completeSchemas = await listCompleteSchemaFiles();
|
|
1812
1813
|
let migratedCount = 0;
|
|
@@ -1816,7 +1817,7 @@ async function migrateFileSchemasToDb() {
|
|
|
1816
1817
|
const content = await BaseFileManager.readFileAsString(schemaFileInfo.filePath);
|
|
1817
1818
|
const schemaFile = JSON.parse(content);
|
|
1818
1819
|
if (!schemaFile.$schema || !schemaFile.metadata?.name) {
|
|
1819
|
-
logger$
|
|
1820
|
+
logger$8(`Skipping invalid schema file: ${schemaFileInfo.filePath}`);
|
|
1820
1821
|
continue;
|
|
1821
1822
|
}
|
|
1822
1823
|
const schemaName = schemaFile.metadata.name;
|
|
@@ -1838,17 +1839,17 @@ async function migrateFileSchemasToDb() {
|
|
|
1838
1839
|
JSON.stringify(schemaFile, null, 2), // schemaData
|
|
1839
1840
|
false);
|
|
1840
1841
|
migratedCount++;
|
|
1841
|
-
logger$
|
|
1842
|
+
logger$8(`Migrated schema: ${schemaName} v${schemaFile.version}`);
|
|
1842
1843
|
}
|
|
1843
1844
|
else {
|
|
1844
|
-
logger$
|
|
1845
|
+
logger$8(`Schema ${schemaName} already exists in database, skipping`);
|
|
1845
1846
|
}
|
|
1846
1847
|
}
|
|
1847
1848
|
catch (error) {
|
|
1848
|
-
logger$
|
|
1849
|
+
logger$8(`Error migrating schema file ${schemaFileInfo.filePath}:`, error);
|
|
1849
1850
|
}
|
|
1850
1851
|
}
|
|
1851
|
-
logger$
|
|
1852
|
+
logger$8(`Migration complete: ${migratedCount} schemas migrated`);
|
|
1852
1853
|
return migratedCount;
|
|
1853
1854
|
}
|
|
1854
1855
|
/**
|
|
@@ -1901,7 +1902,7 @@ const getDeterministicIdsWithPrefix = (prefix) => {
|
|
|
1901
1902
|
return (suffix) => bytesToHex(prefixHash.clone().update(utf8ToBytes(suffix)).digest()).slice(0, 10);
|
|
1902
1903
|
};
|
|
1903
1904
|
|
|
1904
|
-
const logger$
|
|
1905
|
+
const logger$7 = debug('seedSdk:imports:json');
|
|
1905
1906
|
/**
|
|
1906
1907
|
* Get refValueType from a property object with case-insensitive key lookup.
|
|
1907
1908
|
* Handles refValueType, refvaluetype, ref_value_type, elementType, and legacy items.type / items.Type.
|
|
@@ -1979,7 +1980,7 @@ function getRefValueType(prop) {
|
|
|
1979
1980
|
* @returns Promise that resolves when properties are found, or rejects if not found after max retries
|
|
1980
1981
|
*/
|
|
1981
1982
|
const verifyPropertiesPersisted = async (db, modelId, modelName, maxRetries = 10, retryDelay = 100) => {
|
|
1982
|
-
const _mod_1 = await import('./index-
|
|
1983
|
+
const _mod_1 = await import('./index-DeUHrBqA.js');
|
|
1983
1984
|
const _ns_1 = _mod_1.bd;
|
|
1984
1985
|
const modelSchemaMod = _ns_1;
|
|
1985
1986
|
const { properties: propertiesTable } = modelSchemaMod;
|
|
@@ -1992,11 +1993,11 @@ const verifyPropertiesPersisted = async (db, modelId, modelName, maxRetries = 10
|
|
|
1992
1993
|
.where(eq(propertiesTable.modelId, modelId))
|
|
1993
1994
|
.limit(1);
|
|
1994
1995
|
if (props.length > 0) {
|
|
1995
|
-
logger$
|
|
1996
|
+
logger$7(`Verified properties exist for model "${modelName}" (modelId: ${modelId}) after ${attempt + 1} attempt(s)`);
|
|
1996
1997
|
return;
|
|
1997
1998
|
}
|
|
1998
1999
|
if (attempt < maxRetries - 1) {
|
|
1999
|
-
logger$
|
|
2000
|
+
logger$7(`Properties not yet visible for model "${modelName}" (modelId: ${modelId}), retrying in ${retryDelay}ms (attempt ${attempt + 1}/${maxRetries})`);
|
|
2000
2001
|
await new Promise(resolve => setTimeout(resolve, retryDelay));
|
|
2001
2002
|
}
|
|
2002
2003
|
}
|
|
@@ -2295,7 +2296,7 @@ const readCompleteSchemaFile = async (filePath) => {
|
|
|
2295
2296
|
return schema;
|
|
2296
2297
|
}
|
|
2297
2298
|
catch (error) {
|
|
2298
|
-
logger$
|
|
2299
|
+
logger$7(`Could not read schema file ${filePath}:`, error);
|
|
2299
2300
|
return undefined;
|
|
2300
2301
|
}
|
|
2301
2302
|
};
|
|
@@ -2356,10 +2357,11 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2356
2357
|
// It's file contents - check if it's already a complete schema format
|
|
2357
2358
|
try {
|
|
2358
2359
|
const parsed = JSON.parse(importFilePathOrContents.contents);
|
|
2359
|
-
|
|
2360
|
+
// Without metadata.name it falls through to parseJsonImportContent, which rejects it.
|
|
2361
|
+
if (parsed.$schema && parsed.metadata?.name) {
|
|
2360
2362
|
// It's already a complete schema format - preserve it (id may be missing, will be generated)
|
|
2361
2363
|
originalSchemaFile = parsed;
|
|
2362
|
-
logger$
|
|
2364
|
+
logger$7(`Input is complete schema format (${originalSchemaFile.id ? `preserving ID: ${originalSchemaFile.id}` : 'id will be generated'})`);
|
|
2363
2365
|
}
|
|
2364
2366
|
}
|
|
2365
2367
|
catch {
|
|
@@ -2385,7 +2387,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2385
2387
|
// Check DB for existing schema by name+version (same as minimal path)
|
|
2386
2388
|
const db = BaseDb.getAppDb();
|
|
2387
2389
|
if (db) {
|
|
2388
|
-
const _mod_2 = await import('./index-
|
|
2390
|
+
const _mod_2 = await import('./index-DeUHrBqA.js');
|
|
2389
2391
|
const _ns_2 = _mod_2.bf;
|
|
2390
2392
|
const schemaSchemaMod = _ns_2;
|
|
2391
2393
|
const { schemas: schemasTable } = schemaSchemaMod;
|
|
@@ -2399,16 +2401,16 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2399
2401
|
.limit(1);
|
|
2400
2402
|
if (existingByName.length > 0 && existingByName[0].schemaData) {
|
|
2401
2403
|
const existing = existingByName[0];
|
|
2402
|
-
logger$
|
|
2404
|
+
logger$7(`Idempotency: found existing schema by name+version: ${schemaFile.metadata.name} v${schemaFile.version ?? version}`);
|
|
2403
2405
|
const existingSchema = JSON.parse(existing.schemaData);
|
|
2404
2406
|
const contentMatches = compareSchemaContent(schemaFile, existingSchema);
|
|
2405
|
-
logger$
|
|
2407
|
+
logger$7(`Idempotency: compareSchemaContent=${contentMatches} for ${schemaFile.metadata.name}`);
|
|
2406
2408
|
if (contentMatches) {
|
|
2407
2409
|
if (existing.schemaFileId) {
|
|
2408
2410
|
const workingDir = BaseFileManager.getWorkingDir();
|
|
2409
2411
|
const existingFilePath = getSchemaFilePath(workingDir, schemaFile.metadata.name, schemaFile.version ?? version, existing.schemaFileId);
|
|
2410
2412
|
if (await BaseFileManager.pathExists(existingFilePath)) {
|
|
2411
|
-
logger$
|
|
2413
|
+
logger$7(`Schema ${schemaFile.metadata.name} v${schemaFile.version} already exists with same content, loading existing file`);
|
|
2412
2414
|
return await loadSchemaFromFile(existingFilePath);
|
|
2413
2415
|
}
|
|
2414
2416
|
await BaseFileManager.createDirIfNotExists(workingDir);
|
|
@@ -2416,7 +2418,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2416
2418
|
await BaseFileManager.waitForFileWithContent(existingFilePath, 100, 5000);
|
|
2417
2419
|
return await loadSchemaFromFile(existingFilePath);
|
|
2418
2420
|
}
|
|
2419
|
-
logger$
|
|
2421
|
+
logger$7(`Schema ${schemaFile.metadata.name} v${schemaFile.version} already exists with same content (no schemaFileId), using DB`);
|
|
2420
2422
|
return '';
|
|
2421
2423
|
}
|
|
2422
2424
|
}
|
|
@@ -2432,7 +2434,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2432
2434
|
// processSchemaFiles runs multiple times (React StrictMode, app restarts).
|
|
2433
2435
|
if (!schemaFile.id) {
|
|
2434
2436
|
schemaFile.id = await getDeterministicSchemaFileId(schemaFile);
|
|
2435
|
-
logger$
|
|
2437
|
+
logger$7(`Generated deterministic schema ID for ${schemaFile.metadata.name}:`, schemaFile.id);
|
|
2436
2438
|
}
|
|
2437
2439
|
// A file with this schemaFileId and version is reused only when its content matches. A pinned id
|
|
2438
2440
|
// (one the schema file sets) keeps the same path when the content changes.
|
|
@@ -2441,7 +2443,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2441
2443
|
if (await BaseFileManager.pathExists(existingFilePath)) {
|
|
2442
2444
|
const storedSchema = await readCompleteSchemaFile(existingFilePath);
|
|
2443
2445
|
if (storedSchema && compareSchemaContent(schemaFile, storedSchema)) {
|
|
2444
|
-
logger$
|
|
2446
|
+
logger$7(`Schema file already exists with schemaFileId ${schemaFile.id} and the same content, loading it`);
|
|
2445
2447
|
return await loadSchemaFromFile(existingFilePath);
|
|
2446
2448
|
}
|
|
2447
2449
|
if (!options.replaceStoredFile) {
|
|
@@ -2460,12 +2462,12 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2460
2462
|
for (const [modelName, model] of Object.entries(schemaFile.models || {})) {
|
|
2461
2463
|
if (!model.id) {
|
|
2462
2464
|
model.id = getDeterministicId(modelName);
|
|
2463
|
-
logger$
|
|
2465
|
+
logger$7(`Generated deterministic model ID for ${modelName}:`, model.id);
|
|
2464
2466
|
}
|
|
2465
2467
|
for (const [propName, prop] of Object.entries(model.properties || {})) {
|
|
2466
2468
|
if (!prop.id) {
|
|
2467
2469
|
prop.id = getDeterministicId(modelName + propName);
|
|
2468
|
-
logger$
|
|
2470
|
+
logger$7(`Generated deterministic property ID for ${modelName}.${propName}:`, prop.id);
|
|
2469
2471
|
}
|
|
2470
2472
|
}
|
|
2471
2473
|
}
|
|
@@ -2477,7 +2479,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2477
2479
|
// For minimal imports: check DB for existing schema before creating new file
|
|
2478
2480
|
const db = BaseDb.getAppDb();
|
|
2479
2481
|
if (db) {
|
|
2480
|
-
const _mod_3 = await import('./index-
|
|
2482
|
+
const _mod_3 = await import('./index-DeUHrBqA.js');
|
|
2481
2483
|
const _ns_3 = _mod_3.bf;
|
|
2482
2484
|
const schemaSchemaMod = _ns_3;
|
|
2483
2485
|
const { schemas: schemasTable } = schemaSchemaMod;
|
|
@@ -2501,14 +2503,14 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2501
2503
|
const workingDir = BaseFileManager.getWorkingDir();
|
|
2502
2504
|
const existingFilePath = getSchemaFilePath(workingDir, importData.name, version, existing.schemaFileId);
|
|
2503
2505
|
if (await BaseFileManager.pathExists(existingFilePath)) {
|
|
2504
|
-
logger$
|
|
2506
|
+
logger$7(`Schema ${importData.name} v${version} already exists with same content, loading existing file`);
|
|
2505
2507
|
return await loadSchemaFromFile(existingFilePath);
|
|
2506
2508
|
}
|
|
2507
2509
|
// File missing but schemaData exists - restore file from schemaData
|
|
2508
2510
|
await BaseFileManager.createDirIfNotExists(workingDir);
|
|
2509
2511
|
await BaseFileManager.saveFile(existingFilePath, existing.schemaData);
|
|
2510
2512
|
await BaseFileManager.waitForFileWithContent(existingFilePath, 100, 5000);
|
|
2511
|
-
logger$
|
|
2513
|
+
logger$7(`Restored schema file from schemaData for ${importData.name} v${version}`);
|
|
2512
2514
|
return await loadSchemaFromFile(existingFilePath);
|
|
2513
2515
|
}
|
|
2514
2516
|
// No schemaFileId - restore file from schemaData using id from parsed schema
|
|
@@ -2519,10 +2521,10 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2519
2521
|
await BaseFileManager.createDirIfNotExists(workingDir);
|
|
2520
2522
|
await BaseFileManager.saveFile(existingFilePath, existing.schemaData);
|
|
2521
2523
|
await BaseFileManager.waitForFileWithContent(existingFilePath, 100, 5000);
|
|
2522
|
-
logger$
|
|
2524
|
+
logger$7(`Restored schema file from schemaData for ${importData.name} v${version}`);
|
|
2523
2525
|
return await loadSchemaFromFile(existingFilePath);
|
|
2524
2526
|
}
|
|
2525
|
-
logger$
|
|
2527
|
+
logger$7(`Schema ${importData.name} v${version} already exists with same content (no id), using DB`);
|
|
2526
2528
|
return '';
|
|
2527
2529
|
}
|
|
2528
2530
|
// Content differs - create new version
|
|
@@ -2533,7 +2535,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2533
2535
|
.orderBy(desc(schemasTable.version))
|
|
2534
2536
|
.limit(1);
|
|
2535
2537
|
const newVersion = latestVersionRows.length > 0 ? latestVersionRows[0].version + 1 : version;
|
|
2536
|
-
logger$
|
|
2538
|
+
logger$7(`Schema ${importData.name} content changed, creating new version v${newVersion}`);
|
|
2537
2539
|
schemaFile = transformImportToSchemaFile(importData, newVersion);
|
|
2538
2540
|
version = newVersion;
|
|
2539
2541
|
}
|
|
@@ -2559,7 +2561,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2559
2561
|
// Check if this is an internal SDK schema (should not create files in app directory)
|
|
2560
2562
|
const isInternal = isInternalSchema(schemaFile.metadata.name, schemaFile.id);
|
|
2561
2563
|
if (isInternal) {
|
|
2562
|
-
logger$
|
|
2564
|
+
logger$7(`Skipping file creation for internal schema: ${schemaFile.metadata.name}`);
|
|
2563
2565
|
// For internal schemas, just load to database and store, don't create file
|
|
2564
2566
|
// Extract schema name and version
|
|
2565
2567
|
const schemaName = schemaFile.metadata?.name;
|
|
@@ -2616,7 +2618,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2616
2618
|
// Use fixed internal schema ID if missing (never generate for internal)
|
|
2617
2619
|
if (!schemaFile.id) {
|
|
2618
2620
|
schemaFile.id = INTERNAL_SCHEMA_IDS[0];
|
|
2619
|
-
logger$
|
|
2621
|
+
logger$7('Using fixed internal schema ID:', schemaFile.id);
|
|
2620
2622
|
}
|
|
2621
2623
|
// Extract schemaFileIds from JSON file and generate missing ones BEFORE creating models
|
|
2622
2624
|
// This ensures Model instances are created with correct IDs
|
|
@@ -2626,7 +2628,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2626
2628
|
// Generate model ID if missing
|
|
2627
2629
|
if (!model.id) {
|
|
2628
2630
|
model.id = generateId();
|
|
2629
|
-
logger$
|
|
2631
|
+
logger$7(`Generated model ID for ${modelName}:`, model.id);
|
|
2630
2632
|
// Update the schemaFile object so it's included in schemaData
|
|
2631
2633
|
schemaFile.models[modelName].id = model.id;
|
|
2632
2634
|
}
|
|
@@ -2636,7 +2638,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2636
2638
|
// Generate property ID if missing
|
|
2637
2639
|
if (!prop.id) {
|
|
2638
2640
|
prop.id = generateId();
|
|
2639
|
-
logger$
|
|
2641
|
+
logger$7(`Generated property ID for ${modelName}.${propName}:`, prop.id);
|
|
2640
2642
|
// Update the schemaFile object so it's included in schemaData
|
|
2641
2643
|
schemaFile.models[modelName].properties[propName].id = prop.id;
|
|
2642
2644
|
}
|
|
@@ -2650,7 +2652,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2650
2652
|
// addModelsToDb below writes their rows; the models adopt them once it has run.
|
|
2651
2653
|
const rowsWritten = createRowsWrittenSignal();
|
|
2652
2654
|
const modelDefinitions = await createModelsFromJson(importDataForInternal, modelFileIds, propertyFileIds, rowsWritten.promise);
|
|
2653
|
-
logger$
|
|
2655
|
+
logger$7('loadSchemaFromFile (internal) - modelDefinitions length:', Object.keys(modelDefinitions).length);
|
|
2654
2656
|
// Convert schema file metadata to schema input for database
|
|
2655
2657
|
const schemaInput = {
|
|
2656
2658
|
name: schemaName,
|
|
@@ -2660,7 +2662,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2660
2662
|
updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
|
|
2661
2663
|
};
|
|
2662
2664
|
// Use dynamic import to break circular dependency
|
|
2663
|
-
const _mod_4 = await import('./index-
|
|
2665
|
+
const _mod_4 = await import('./index-DeUHrBqA.js');
|
|
2664
2666
|
const _ns_4 = _mod_4.bi;
|
|
2665
2667
|
const dbMod = _ns_4;
|
|
2666
2668
|
const { addSchemaToDb, addModelsToDb } = dbMod;
|
|
@@ -2682,11 +2684,11 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2682
2684
|
});
|
|
2683
2685
|
// Verify expected models are linked (single attempt - addModelsToDb already confirmed)
|
|
2684
2686
|
const expectedModelNames = Object.keys(schemaFile.models || {});
|
|
2685
|
-
const _mod_5 = await import('./index-
|
|
2687
|
+
const _mod_5 = await import('./index-DeUHrBqA.js');
|
|
2686
2688
|
const _ns_5 = _mod_5.bg;
|
|
2687
2689
|
const modelSchemaSchemaMod = _ns_5;
|
|
2688
2690
|
const { modelSchemas } = modelSchemaSchemaMod;
|
|
2689
|
-
const _mod_6 = await import('./index-
|
|
2691
|
+
const _mod_6 = await import('./index-DeUHrBqA.js');
|
|
2690
2692
|
const _ns_6 = _mod_6.bd;
|
|
2691
2693
|
const modelSchemaMod = _ns_6;
|
|
2692
2694
|
const { models: modelsTable } = modelSchemaMod;
|
|
@@ -2776,7 +2778,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2776
2778
|
}
|
|
2777
2779
|
catch (dbError) {
|
|
2778
2780
|
// Database not available - log warning but continue
|
|
2779
|
-
logger$
|
|
2781
|
+
logger$7('Database not available, skipping database operations:', dbError instanceof Error ? dbError.message : String(dbError));
|
|
2780
2782
|
}
|
|
2781
2783
|
finally {
|
|
2782
2784
|
rowsWritten.settle();
|
|
@@ -2784,7 +2786,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2784
2786
|
// Models are now Model instances, no registration needed
|
|
2785
2787
|
// They should be created via Model.create() and are accessible via Model static methods
|
|
2786
2788
|
for (const [modelName] of Object.entries(modelDefinitions)) {
|
|
2787
|
-
logger$
|
|
2789
|
+
logger$7('loadSchemaFromFile (internal) - model available:', modelName);
|
|
2788
2790
|
}
|
|
2789
2791
|
// Schema is now saved to database
|
|
2790
2792
|
// useSchemas hook will pick it up via database queries
|
|
@@ -2795,7 +2797,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2795
2797
|
// Ensure schema ID is defined (should always be set by this point, but check for safety)
|
|
2796
2798
|
if (!schemaFile.id) {
|
|
2797
2799
|
schemaFile.id = generateId();
|
|
2798
|
-
logger$
|
|
2800
|
+
logger$7('Generated schema ID before file path creation:', schemaFile.id);
|
|
2799
2801
|
}
|
|
2800
2802
|
// Get the target file path using ID-based naming (preferred)
|
|
2801
2803
|
const filePath = getSchemaFilePath(workingDir, schemaFile.metadata.name, version, schemaFile.id);
|
|
@@ -2814,11 +2816,11 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2814
2816
|
const data = JSON.parse(content);
|
|
2815
2817
|
if (data.$schema) {
|
|
2816
2818
|
// File is already a complete schema, just load it
|
|
2817
|
-
logger$
|
|
2819
|
+
logger$7(`Schema file ${filePath} already exists and is complete, loading it`);
|
|
2818
2820
|
return await loadSchemaFromFile(filePath);
|
|
2819
2821
|
}
|
|
2820
2822
|
}
|
|
2821
|
-
catch
|
|
2823
|
+
catch {
|
|
2822
2824
|
// If we can't read the file, proceed with the error
|
|
2823
2825
|
}
|
|
2824
2826
|
}
|
|
@@ -2832,7 +2834,7 @@ async function importSchema(importFilePathOrContents, version, options) {
|
|
|
2832
2834
|
// Compare schemas structurally
|
|
2833
2835
|
if (compareSchemasStructurally(schemaFile, existingSchema)) {
|
|
2834
2836
|
// Schemas match - just load the existing file
|
|
2835
|
-
logger$
|
|
2837
|
+
logger$7(`Schema ${schemaFile.metadata.name} v${version} already exists with matching content, loading it`);
|
|
2836
2838
|
return await loadSchemaFromFile(filePath);
|
|
2837
2839
|
}
|
|
2838
2840
|
else {
|
|
@@ -2888,7 +2890,7 @@ async function applySchemaToDb(schemaFile, modelDefinitions, modelFileIds, prope
|
|
|
2888
2890
|
createdAt: new Date(schemaFile.metadata.createdAt).getTime(),
|
|
2889
2891
|
updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
|
|
2890
2892
|
};
|
|
2891
|
-
const _mod_7 = await import('./index-
|
|
2893
|
+
const _mod_7 = await import('./index-DeUHrBqA.js');
|
|
2892
2894
|
const _ns_7 = _mod_7.bi;
|
|
2893
2895
|
const dbMod = _ns_7;
|
|
2894
2896
|
const { addSchemaToDb, addModelsToDb } = dbMod;
|
|
@@ -2920,7 +2922,7 @@ async function applySchemaToDb(schemaFile, modelDefinitions, modelFileIds, prope
|
|
|
2920
2922
|
* draft (its edits aren't the app's to undo) or a newer version than schemaFile.
|
|
2921
2923
|
*/
|
|
2922
2924
|
async function getModelsDroppedFromStoredSchema(db, schemaFile) {
|
|
2923
|
-
const _mod_8 = await import('./index-
|
|
2925
|
+
const _mod_8 = await import('./index-DeUHrBqA.js');
|
|
2924
2926
|
const _ns_8 = _mod_8.bf;
|
|
2925
2927
|
const { schemas: schemasTable } = _ns_8;
|
|
2926
2928
|
const { eq } = await import('drizzle-orm');
|
|
@@ -2948,10 +2950,10 @@ async function getModelsDroppedFromStoredSchema(db, schemaFile) {
|
|
|
2948
2950
|
}
|
|
2949
2951
|
/** Delete the model_schemas rows linking the named models to the schema. The models and their items stay. */
|
|
2950
2952
|
async function unlinkModelsFromSchema(db, schemaId, modelNames) {
|
|
2951
|
-
const _mod_9 = await import('./index-
|
|
2953
|
+
const _mod_9 = await import('./index-DeUHrBqA.js');
|
|
2952
2954
|
const _ns_9 = _mod_9.bg;
|
|
2953
2955
|
const { modelSchemas } = _ns_9;
|
|
2954
|
-
const _mod_10 = await import('./index-
|
|
2956
|
+
const _mod_10 = await import('./index-DeUHrBqA.js');
|
|
2955
2957
|
const _ns_10 = _mod_10.bd;
|
|
2956
2958
|
const { models: modelsTable } = _ns_10;
|
|
2957
2959
|
const { and, eq, inArray } = await import('drizzle-orm');
|
|
@@ -2963,7 +2965,7 @@ async function unlinkModelsFromSchema(db, schemaId, modelNames) {
|
|
|
2963
2965
|
if (links.length === 0)
|
|
2964
2966
|
return;
|
|
2965
2967
|
await db.delete(modelSchemas).where(inArray(modelSchemas.id, links.map((link) => link.id)));
|
|
2966
|
-
logger$
|
|
2968
|
+
logger$7(`Unlinked models dropped from the schema (schema id ${schemaId}): ${modelNames.join(', ')}`);
|
|
2967
2969
|
}
|
|
2968
2970
|
/**
|
|
2969
2971
|
* Sync a canonical schema from a file path or inlined object to the database.
|
|
@@ -3013,7 +3015,6 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
3013
3015
|
}
|
|
3014
3016
|
// Extract schema name and version
|
|
3015
3017
|
const schemaName = schemaFile.metadata?.name;
|
|
3016
|
-
const version = schemaFile.version;
|
|
3017
3018
|
if (!schemaName) {
|
|
3018
3019
|
throw new Error('Schema name is required in metadata.name');
|
|
3019
3020
|
}
|
|
@@ -3067,7 +3068,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
3067
3068
|
// Generate schema ID if missing (before creating schemaInput)
|
|
3068
3069
|
if (!schemaFile.id) {
|
|
3069
3070
|
schemaFile.id = generateId();
|
|
3070
|
-
logger$
|
|
3071
|
+
logger$7('Generated schema ID for schema file:', schemaFile.id);
|
|
3071
3072
|
}
|
|
3072
3073
|
// Extract schemaFileIds from JSON file and generate missing ones BEFORE creating models
|
|
3073
3074
|
// This ensures Model instances are created with correct IDs
|
|
@@ -3077,7 +3078,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
3077
3078
|
// Generate model ID if missing
|
|
3078
3079
|
if (!model.id) {
|
|
3079
3080
|
model.id = generateId();
|
|
3080
|
-
logger$
|
|
3081
|
+
logger$7(`Generated model ID for ${modelName}:`, model.id);
|
|
3081
3082
|
// Update the schemaFile object so it's included in schemaData
|
|
3082
3083
|
schemaFile.models[modelName].id = model.id;
|
|
3083
3084
|
}
|
|
@@ -3087,7 +3088,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
3087
3088
|
// Generate property ID if missing
|
|
3088
3089
|
if (!prop.id) {
|
|
3089
3090
|
prop.id = generateId();
|
|
3090
|
-
logger$
|
|
3091
|
+
logger$7(`Generated property ID for ${modelName}.${propName}:`, prop.id);
|
|
3091
3092
|
// Update the schemaFile object so it's included in schemaData
|
|
3092
3093
|
schemaFile.models[modelName].properties[propName].id = prop.id;
|
|
3093
3094
|
}
|
|
@@ -3101,7 +3102,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
3101
3102
|
// applySchemaToDb below writes their rows; the models adopt them once it has run.
|
|
3102
3103
|
const rowsWritten = createRowsWrittenSignal();
|
|
3103
3104
|
const modelDefinitions = await createModelsFromJson(importData, modelFileIds, propertyFileIds, rowsWritten.promise);
|
|
3104
|
-
logger$
|
|
3105
|
+
logger$7('loadSchemaFromFile - modelDefinitions length:', Object.keys(modelDefinitions).length);
|
|
3105
3106
|
// Try to add schema and models to database if database is available
|
|
3106
3107
|
try {
|
|
3107
3108
|
const db = BaseDb.getAppDb();
|
|
@@ -3115,11 +3116,11 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
3115
3116
|
]));
|
|
3116
3117
|
const { schemaRecord } = await applySchemaToDb(schemaFile, modelDefinitions, modelFileIds, propertyFileIds, propertyDefinitions).finally(rowsWritten.settle);
|
|
3117
3118
|
// Query the database to get model IDs that were just created
|
|
3118
|
-
const _mod_11 = await import('./index-
|
|
3119
|
+
const _mod_11 = await import('./index-DeUHrBqA.js');
|
|
3119
3120
|
const _ns_11 = _mod_11.bg;
|
|
3120
3121
|
const modelSchemaSchemaMod = _ns_11;
|
|
3121
3122
|
const { modelSchemas } = modelSchemaSchemaMod;
|
|
3122
|
-
const _mod_12 = await import('./index-
|
|
3123
|
+
const _mod_12 = await import('./index-DeUHrBqA.js');
|
|
3123
3124
|
const _ns_12 = _mod_12.bd;
|
|
3124
3125
|
const modelSchemaMod = _ns_12;
|
|
3125
3126
|
const { models: modelsTable } = modelSchemaMod;
|
|
@@ -3167,17 +3168,17 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
3167
3168
|
await new Promise(resolve => setTimeout(resolve, 100));
|
|
3168
3169
|
}
|
|
3169
3170
|
}
|
|
3170
|
-
logger$
|
|
3171
|
+
logger$7(`Verifying properties: found ${modelLinks.length} model links for schema ${schemaName} (id: ${schemaRecord.id})`);
|
|
3171
3172
|
// If we didn't verify via direct lookup, verify via join table
|
|
3172
3173
|
if (!seedModelId || (seedModel.length === 0 || !seedModel[0].id)) {
|
|
3173
3174
|
const seedModelLink = modelLinks.find((link) => link.modelName === 'Seed');
|
|
3174
3175
|
if (seedModelLink && seedModelLink.modelId) {
|
|
3175
|
-
logger$
|
|
3176
|
+
logger$7(`Verifying properties for Seed model via join table (modelId: ${seedModelLink.modelId})`);
|
|
3176
3177
|
await verifyPropertiesPersisted(db, seedModelLink.modelId, 'Seed', 10, 100);
|
|
3177
3178
|
}
|
|
3178
3179
|
else if (modelLinks.length > 0 && modelLinks[0].modelId) {
|
|
3179
3180
|
// Fallback to first model if Seed not found
|
|
3180
|
-
logger$
|
|
3181
|
+
logger$7(`Verifying properties for ${modelLinks[0].modelName} model via join table (modelId: ${modelLinks[0].modelId})`);
|
|
3181
3182
|
await verifyPropertiesPersisted(db, modelLinks[0].modelId, modelLinks[0].modelName || 'unknown', 10, 100);
|
|
3182
3183
|
}
|
|
3183
3184
|
}
|
|
@@ -3185,7 +3186,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
3185
3186
|
// After properties are created (file path), ensure schemaFile has the correct IDs from database
|
|
3186
3187
|
// Query the database to get the actual schemaFileId values that were used
|
|
3187
3188
|
// This ensures schemaData matches what's actually in the database
|
|
3188
|
-
const _mod_13 = await import('./index-
|
|
3189
|
+
const _mod_13 = await import('./index-DeUHrBqA.js');
|
|
3189
3190
|
const _ns_13 = _mod_13.bd;
|
|
3190
3191
|
const modelSchemaMod2 = _ns_13;
|
|
3191
3192
|
const { properties: propertiesTable } = modelSchemaMod2;
|
|
@@ -3210,7 +3211,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
3210
3211
|
const currentId = schemaFile.models[modelName].properties[propRecord.name].id;
|
|
3211
3212
|
if (currentId !== propRecord.schemaFileId) {
|
|
3212
3213
|
schemaFile.models[modelName].properties[propRecord.name].id = propRecord.schemaFileId;
|
|
3213
|
-
logger$
|
|
3214
|
+
logger$7(`Updated schemaFile property ID for ${modelName}.${propRecord.name} from ${currentId} to ${propRecord.schemaFileId}`);
|
|
3214
3215
|
schemaFileUpdated = true;
|
|
3215
3216
|
}
|
|
3216
3217
|
}
|
|
@@ -3221,7 +3222,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
3221
3222
|
// This is important even if nothing changed, to ensure consistency
|
|
3222
3223
|
const updatedSchemaData = JSON.stringify(schemaFile, null, 2);
|
|
3223
3224
|
// Update the schema record in the database with current schemaData
|
|
3224
|
-
const _mod_14 = await import('./index-
|
|
3225
|
+
const _mod_14 = await import('./index-DeUHrBqA.js');
|
|
3225
3226
|
const _ns_14 = _mod_14.bf;
|
|
3226
3227
|
const schemaSchemaMod = _ns_14;
|
|
3227
3228
|
const { schemas: schemasTable } = schemaSchemaMod;
|
|
@@ -3231,16 +3232,16 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
3231
3232
|
.where(eq(schemasTable.id, schemaRecord.id));
|
|
3232
3233
|
clearNameMatchLevels();
|
|
3233
3234
|
if (schemaFileUpdated) {
|
|
3234
|
-
logger$
|
|
3235
|
+
logger$7(`Updated schemaData in database with actual property IDs for schema "${schemaName}"`);
|
|
3235
3236
|
}
|
|
3236
3237
|
else {
|
|
3237
|
-
logger$
|
|
3238
|
+
logger$7(`Verified schemaData in database matches schemaFile for schema "${schemaName}"`);
|
|
3238
3239
|
}
|
|
3239
3240
|
}
|
|
3240
3241
|
}
|
|
3241
3242
|
catch (dbError) {
|
|
3242
3243
|
// Database not available - log warning but continue
|
|
3243
|
-
logger$
|
|
3244
|
+
logger$7('Database not available, skipping database operations:', dbError instanceof Error ? dbError.message : String(dbError));
|
|
3244
3245
|
}
|
|
3245
3246
|
finally {
|
|
3246
3247
|
rowsWritten.settle();
|
|
@@ -3248,7 +3249,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
3248
3249
|
// Models are now Model instances, no registration needed
|
|
3249
3250
|
// They should be created via Model.create() and are accessible via Model static methods
|
|
3250
3251
|
for (const [modelName] of Object.entries(modelDefinitions)) {
|
|
3251
|
-
logger$
|
|
3252
|
+
logger$7('loadSchemaFromFile - model available:', modelName);
|
|
3252
3253
|
}
|
|
3253
3254
|
return schemaFilePath;
|
|
3254
3255
|
}
|
|
@@ -3348,8 +3349,8 @@ const createRowsWrittenSignal = () => {
|
|
|
3348
3349
|
const createModelFromJson = async (modelName, modelDef, schemaName, modelFileId, // Optional modelFileId from JSON file
|
|
3349
3350
|
propertyFileIds, // Optional map of property names to their file IDs from the JSON file
|
|
3350
3351
|
persistedBy) => {
|
|
3351
|
-
const _mod_15 = await import('./errors-
|
|
3352
|
-
const _ns_15 = _mod_15.
|
|
3352
|
+
const _mod_15 = await import('./errors-DuFqGrjo.js');
|
|
3353
|
+
const _ns_15 = _mod_15.j;
|
|
3353
3354
|
const modelMod = _ns_15;
|
|
3354
3355
|
const { Model } = modelMod;
|
|
3355
3356
|
const convertedProperties = jsonPropertiesToSchemaProperties(modelName, modelDef, propertyFileIds);
|
|
@@ -3357,10 +3358,10 @@ persistedBy) => {
|
|
|
3357
3358
|
// Pass id (schemaFileId) if provided to ensure Model instance uses correct ID
|
|
3358
3359
|
// Note: indexes and description are ignored - they remain in JSON for schema file format compliance but are not used by Model instances
|
|
3359
3360
|
if (modelFileId) {
|
|
3360
|
-
logger$
|
|
3361
|
+
logger$7(`Creating schema model "${modelName}" with modelFileId: ${modelFileId}`);
|
|
3361
3362
|
}
|
|
3362
3363
|
else {
|
|
3363
|
-
logger$
|
|
3364
|
+
logger$7(`Warning: Creating schema model "${modelName}" without modelFileId - it will be renamed if duplicates exist`);
|
|
3364
3365
|
}
|
|
3365
3366
|
const modelInstance = Model.create(modelName, schemaName, {
|
|
3366
3367
|
modelFileId: modelFileId, // Pass modelFileId (preferred) as id (schemaFileId) from JSON file
|
|
@@ -3389,7 +3390,7 @@ const createModelsFromJson = async (importData, modelFileIds, propertyFileIds, p
|
|
|
3389
3390
|
// Use modelFileId from map (no fallback to modelDef.id as JsonImportSchema doesn't have id property)
|
|
3390
3391
|
const finalModelFileId = modelFileId;
|
|
3391
3392
|
if (!finalModelFileId) {
|
|
3392
|
-
logger$
|
|
3393
|
+
logger$7(`Warning: No modelFileId found for model "${modelName}" - model will be created without ID`);
|
|
3393
3394
|
}
|
|
3394
3395
|
// Get propertyFileIds for this model if available
|
|
3395
3396
|
const modelPropertyFileIds = propertyFileIds?.get(modelName);
|
|
@@ -3579,7 +3580,7 @@ var SEEDPROTOCOL_Seed_Protocol_v1 = /*#__PURE__*/Object.freeze({
|
|
|
3579
3580
|
version: version
|
|
3580
3581
|
});
|
|
3581
3582
|
|
|
3582
|
-
const logger$
|
|
3583
|
+
const logger$6 = debug('seedSdk:client:actors:processSchemaFiles');
|
|
3583
3584
|
let processSchemaFilesChain = Promise.resolve();
|
|
3584
3585
|
function resolveSchemaFilePath(schemaFile) {
|
|
3585
3586
|
const path = BaseFileManager.getPathModule();
|
|
@@ -3607,7 +3608,7 @@ async function resolveSchemaNameFromSource(source) {
|
|
|
3607
3608
|
}
|
|
3608
3609
|
}
|
|
3609
3610
|
catch (error) {
|
|
3610
|
-
logger$
|
|
3611
|
+
logger$6('Could not resolve schema name from path:', source, error);
|
|
3611
3612
|
}
|
|
3612
3613
|
}
|
|
3613
3614
|
return null;
|
|
@@ -3622,7 +3623,7 @@ function userSchemaLoadError(option, source, error) {
|
|
|
3622
3623
|
// Schema processing can be slow with syncSchemaFromSource, loadAllSchemasFromDb, and OPFS file I/O
|
|
3623
3624
|
const PROCESS_SCHEMA_FILES_TIMEOUT_MS = 120000;
|
|
3624
3625
|
const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
3625
|
-
logger$
|
|
3626
|
+
logger$6('processSchemaFiles started');
|
|
3626
3627
|
let hasResponded = false;
|
|
3627
3628
|
let timeoutId = null;
|
|
3628
3629
|
const reportError = (error) => {
|
|
@@ -3632,7 +3633,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3632
3633
|
clearTimeout(timeoutId);
|
|
3633
3634
|
timeoutId = null;
|
|
3634
3635
|
}
|
|
3635
|
-
logger$
|
|
3636
|
+
logger$6('processSchemaFiles error:', error);
|
|
3636
3637
|
sendBack({
|
|
3637
3638
|
type: 'error',
|
|
3638
3639
|
error: error instanceof Error ? error : new Error(String(error))
|
|
@@ -3646,7 +3647,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3646
3647
|
clearTimeout(timeoutId);
|
|
3647
3648
|
timeoutId = null;
|
|
3648
3649
|
}
|
|
3649
|
-
logger$
|
|
3650
|
+
logger$6('processSchemaFiles completed');
|
|
3650
3651
|
sendBack({ type: ClientManagerEvents.PROCESS_SCHEMA_FILES_SUCCESS });
|
|
3651
3652
|
}
|
|
3652
3653
|
};
|
|
@@ -3658,7 +3659,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3658
3659
|
// Schemas written (or confirmed present) this run — skip redundant loadSchemaFromFile later
|
|
3659
3660
|
const schemasWrittenThisRun = new Set();
|
|
3660
3661
|
// First, load the internal seed-protocol schema
|
|
3661
|
-
logger$
|
|
3662
|
+
logger$6('Loading internal seed-protocol schema');
|
|
3662
3663
|
const internalSchemaData = internalSchema;
|
|
3663
3664
|
const db = BaseDb.getAppDb();
|
|
3664
3665
|
const internalSchemaExists = db
|
|
@@ -3667,21 +3668,21 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3667
3668
|
// Always mark internal schema as written so the DB/file loop does not re-apply it
|
|
3668
3669
|
schemasWrittenThisRun.add(SEED_PROTOCOL_SCHEMA_NAME);
|
|
3669
3670
|
if (internalSchemaExists) {
|
|
3670
|
-
logger$
|
|
3671
|
+
logger$6('Internal seed-protocol schema already in DB, skipping import');
|
|
3671
3672
|
}
|
|
3672
3673
|
else {
|
|
3673
3674
|
try {
|
|
3674
3675
|
// Import the internal schema to database (will create models and add to store)
|
|
3675
3676
|
await importJsonSchema({ contents: JSON.stringify(internalSchemaData) }, internalSchemaData.version);
|
|
3676
|
-
logger$
|
|
3677
|
+
logger$6(`Loaded internal seed-protocol schema v${internalSchemaData.version}`);
|
|
3677
3678
|
}
|
|
3678
3679
|
catch (error) {
|
|
3679
3680
|
// If schema already exists, that's fine - it means it was already loaded
|
|
3680
3681
|
if (error?.message?.includes('already exists')) {
|
|
3681
|
-
logger$
|
|
3682
|
+
logger$6('Internal seed-protocol schema already loaded');
|
|
3682
3683
|
}
|
|
3683
3684
|
else {
|
|
3684
|
-
logger$
|
|
3685
|
+
logger$6('Error loading internal seed-protocol schema:', error);
|
|
3685
3686
|
// Don't fail if internal schema can't be loaded - it might already be in DB
|
|
3686
3687
|
}
|
|
3687
3688
|
}
|
|
@@ -3694,7 +3695,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3694
3695
|
: '';
|
|
3695
3696
|
const schemaId = typeof context.schema === 'object' && context.schema?.id ? String(context.schema.id) : undefined;
|
|
3696
3697
|
if (isInternalSchema(schemaName, schemaId)) {
|
|
3697
|
-
logger$
|
|
3698
|
+
logger$6('Schema is internal (Seed Protocol), already loaded - skipping syncSchemaFromSource');
|
|
3698
3699
|
}
|
|
3699
3700
|
else {
|
|
3700
3701
|
try {
|
|
@@ -3703,7 +3704,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3703
3704
|
if (syncedName) {
|
|
3704
3705
|
schemasWrittenThisRun.add(syncedName);
|
|
3705
3706
|
}
|
|
3706
|
-
logger$
|
|
3707
|
+
logger$6(`Synced canonical schema from ${typeof context.schema === 'string' ? context.schema : 'object'}`);
|
|
3707
3708
|
}
|
|
3708
3709
|
catch (error) {
|
|
3709
3710
|
// A schema the app passed in failed (missing file, bad JSON, DB write). Re-running an
|
|
@@ -3722,7 +3723,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3722
3723
|
if (parsed?.metadata?.name) {
|
|
3723
3724
|
schemasWrittenThisRun.add(String(parsed.metadata.name));
|
|
3724
3725
|
}
|
|
3725
|
-
logger$
|
|
3726
|
+
logger$6(`Loaded schema from ${resolvedPath}`);
|
|
3726
3727
|
}
|
|
3727
3728
|
catch (error) {
|
|
3728
3729
|
throw userSchemaLoadError('schemaFile', context.schemaFile, error);
|
|
@@ -3730,14 +3731,14 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3730
3731
|
}
|
|
3731
3732
|
// Process minimal import files (files without $schema) - skip when canonical schema is set
|
|
3732
3733
|
if (!context.schema) {
|
|
3733
|
-
logger$
|
|
3734
|
+
logger$6('Listing schema files');
|
|
3734
3735
|
let schemaFiles = [];
|
|
3735
3736
|
try {
|
|
3736
3737
|
schemaFiles = await listSchemaFiles();
|
|
3737
|
-
logger$
|
|
3738
|
+
logger$6(`Found ${schemaFiles.length} schema files to process`);
|
|
3738
3739
|
}
|
|
3739
3740
|
catch (error) {
|
|
3740
|
-
logger$
|
|
3741
|
+
logger$6('Error listing schema files (continuing anyway):', error);
|
|
3741
3742
|
schemaFiles = [];
|
|
3742
3743
|
}
|
|
3743
3744
|
for (const schemaFile of schemaFiles) {
|
|
@@ -3748,19 +3749,19 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3748
3749
|
}
|
|
3749
3750
|
}
|
|
3750
3751
|
catch (error) {
|
|
3751
|
-
logger$
|
|
3752
|
+
logger$6(`Error importing schema file ${schemaFile.filePath}:`, error);
|
|
3752
3753
|
}
|
|
3753
3754
|
}
|
|
3754
3755
|
}
|
|
3755
3756
|
// Then, load all schemas using the unified database-first approach
|
|
3756
|
-
logger$
|
|
3757
|
+
logger$6('Loading schemas from database and files');
|
|
3757
3758
|
let allSchemasData = [];
|
|
3758
3759
|
try {
|
|
3759
3760
|
allSchemasData = await loadAllSchemasFromDb();
|
|
3760
|
-
logger$
|
|
3761
|
+
logger$6(`Loaded ${allSchemasData.length} schemas (${allSchemasData.filter(s => s.isDraft).length} drafts, ${allSchemasData.filter(s => !s.isDraft).length} published)`);
|
|
3761
3762
|
}
|
|
3762
3763
|
catch (error) {
|
|
3763
|
-
logger$
|
|
3764
|
+
logger$6('Error loading schemas from database (continuing anyway):', error);
|
|
3764
3765
|
// Continue with empty array - this is not critical for initialization
|
|
3765
3766
|
// Schemas can be loaded on-demand later
|
|
3766
3767
|
allSchemasData = [];
|
|
@@ -3781,13 +3782,13 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3781
3782
|
}
|
|
3782
3783
|
}
|
|
3783
3784
|
catch (error) {
|
|
3784
|
-
logger$
|
|
3785
|
+
logger$6('Error counting linked models (re-applying all schema files):', error);
|
|
3785
3786
|
}
|
|
3786
3787
|
}
|
|
3787
3788
|
for (const schemaData of allSchemasData) {
|
|
3788
3789
|
const schema = schemaData.schema;
|
|
3789
3790
|
const schemaName = schema.metadata?.name || 'unknown';
|
|
3790
|
-
logger$
|
|
3791
|
+
logger$6(`Processing schema: ${schemaName} v${schema.version} (${schemaData.isDraft ? 'draft' : 'published'}, source: ${schemaData.source})`);
|
|
3791
3792
|
// For published schemas (not drafts), load models from file if available
|
|
3792
3793
|
if (!schemaData.isDraft && schema.id) {
|
|
3793
3794
|
// loadAllSchemasFromDb already picked the latest file for this schema (and read it)
|
|
@@ -3817,7 +3818,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3817
3818
|
}
|
|
3818
3819
|
}
|
|
3819
3820
|
catch (error) {
|
|
3820
|
-
logger$
|
|
3821
|
+
logger$6(`Error loading schema file for ${schemaName}:`, error);
|
|
3821
3822
|
}
|
|
3822
3823
|
}
|
|
3823
3824
|
else {
|
|
@@ -3866,11 +3867,11 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3866
3867
|
};
|
|
3867
3868
|
const modelDefinitions = await createModelsFromJson(importData, modelFileIds, propertyFileIds);
|
|
3868
3869
|
Object.assign(allModels, modelDefinitions);
|
|
3869
|
-
logger$
|
|
3870
|
+
logger$6(`Loaded ${Object.keys(modelDefinitions).length} models from schema data for ${schemaName}`);
|
|
3870
3871
|
}
|
|
3871
3872
|
}
|
|
3872
3873
|
catch (error) {
|
|
3873
|
-
logger$
|
|
3874
|
+
logger$6(`Error creating models from schema data for ${schemaName}:`, error);
|
|
3874
3875
|
}
|
|
3875
3876
|
}
|
|
3876
3877
|
}
|
|
@@ -3920,11 +3921,11 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3920
3921
|
};
|
|
3921
3922
|
const modelDefinitions = await createModelsFromJson(importData, modelFileIds, propertyFileIds);
|
|
3922
3923
|
Object.assign(allModels, modelDefinitions);
|
|
3923
|
-
logger$
|
|
3924
|
+
logger$6(`Loaded ${Object.keys(modelDefinitions).length} models from draft schema ${schemaName}`);
|
|
3924
3925
|
}
|
|
3925
3926
|
}
|
|
3926
3927
|
catch (error) {
|
|
3927
|
-
logger$
|
|
3928
|
+
logger$6(`Error creating models from draft schema ${schemaName}:`, error);
|
|
3928
3929
|
}
|
|
3929
3930
|
}
|
|
3930
3931
|
// Schemas are now loaded on-demand via database queries (useSchemas hook uses loadAllSchemasFromDb)
|
|
@@ -4021,7 +4022,7 @@ const convertVerbatimItemStorageRow = async (localId, storage = {}) => {
|
|
|
4021
4022
|
});
|
|
4022
4023
|
};
|
|
4023
4024
|
|
|
4024
|
-
const logger$
|
|
4025
|
+
const logger$5 = debug('seedSdk:db:migrateLegacyItemStorageRows');
|
|
4025
4026
|
/** appState key recording that legacy ItemStorage rows have been written to their files. */
|
|
4026
4027
|
const LEGACY_ITEM_STORAGE_MIGRATION_KEY = 'legacyItemStorageFiles:v1';
|
|
4027
4028
|
/** Runs in a row that left rows unconverted because a file write failed, before giving up. */
|
|
@@ -4175,7 +4176,7 @@ async function migrateLegacyItemStorageRows(options = {}) {
|
|
|
4175
4176
|
});
|
|
4176
4177
|
if (converted) {
|
|
4177
4178
|
result.converted++;
|
|
4178
|
-
logger$
|
|
4179
|
+
logger$5(`wrote ${row.propertyName} of ${row.seedLocalId} to ${converted.filePath}`);
|
|
4179
4180
|
}
|
|
4180
4181
|
else {
|
|
4181
4182
|
result.skipped++;
|
|
@@ -4183,7 +4184,7 @@ async function migrateLegacyItemStorageRows(options = {}) {
|
|
|
4183
4184
|
}
|
|
4184
4185
|
catch (error) {
|
|
4185
4186
|
result.failed++;
|
|
4186
|
-
logger$
|
|
4187
|
+
logger$5(`converting ${row.propertyName} of ${row.seedLocalId} (${row.localId}) failed; left as is`, error);
|
|
4187
4188
|
}
|
|
4188
4189
|
}
|
|
4189
4190
|
const attempts = previousAttempts + 1;
|
|
@@ -4195,24 +4196,24 @@ async function migrateLegacyItemStorageRows(options = {}) {
|
|
|
4195
4196
|
at: Date.now(),
|
|
4196
4197
|
});
|
|
4197
4198
|
if (result.candidates > 0) {
|
|
4198
|
-
logger$
|
|
4199
|
+
logger$5(`legacy ItemStorage rows: ${result.converted} converted, ${result.failed} failed, ` +
|
|
4199
4200
|
`${result.skipped} skipped of ${result.candidates}`);
|
|
4200
4201
|
}
|
|
4201
4202
|
return result;
|
|
4202
4203
|
}
|
|
4203
|
-
let running$
|
|
4204
|
-
let deferredUntilLeader$
|
|
4205
|
-
const runInBackground$
|
|
4206
|
-
running$
|
|
4204
|
+
let running$4;
|
|
4205
|
+
let deferredUntilLeader$4 = false;
|
|
4206
|
+
const runInBackground$4 = () => {
|
|
4207
|
+
running$4 ?? (running$4 = withDbTabLock('item-storage-migration', () => migrateLegacyItemStorageRows())
|
|
4207
4208
|
.then(() => undefined)
|
|
4208
4209
|
.catch((error) => {
|
|
4209
4210
|
// Never fails init: rows stay as they were and publish converts them lazily.
|
|
4210
|
-
logger$
|
|
4211
|
+
logger$5('legacy ItemStorage migration failed', error);
|
|
4211
4212
|
})
|
|
4212
4213
|
.finally(() => {
|
|
4213
|
-
running$
|
|
4214
|
+
running$4 = undefined;
|
|
4214
4215
|
}));
|
|
4215
|
-
return running$
|
|
4216
|
+
return running$4;
|
|
4216
4217
|
};
|
|
4217
4218
|
/**
|
|
4218
4219
|
* Starts {@link migrateLegacyItemStorageRows} in the background once client init has finished
|
|
@@ -4222,19 +4223,19 @@ const runInBackground$3 = () => {
|
|
|
4222
4223
|
*/
|
|
4223
4224
|
function startLegacyItemStorageMigration() {
|
|
4224
4225
|
if (isLeaderTab()) {
|
|
4225
|
-
void runInBackground$
|
|
4226
|
+
void runInBackground$4();
|
|
4226
4227
|
return;
|
|
4227
4228
|
}
|
|
4228
|
-
if (deferredUntilLeader$
|
|
4229
|
+
if (deferredUntilLeader$4)
|
|
4229
4230
|
return;
|
|
4230
|
-
deferredUntilLeader$
|
|
4231
|
+
deferredUntilLeader$4 = true;
|
|
4231
4232
|
void whenLeaderTab().then(() => {
|
|
4232
|
-
deferredUntilLeader$
|
|
4233
|
-
void runInBackground$
|
|
4233
|
+
deferredUntilLeader$4 = false;
|
|
4234
|
+
void runInBackground$4();
|
|
4234
4235
|
});
|
|
4235
4236
|
}
|
|
4236
4237
|
|
|
4237
|
-
const logger$
|
|
4238
|
+
const logger$4 = debug('seedSdk:db:removeForeignAttestationRows');
|
|
4238
4239
|
/** appState key recording that the cleanup below has run on this database. */
|
|
4239
4240
|
const FOREIGN_ATTESTATION_CLEANUP_KEY = 'foreignAttestationRowsRemoved';
|
|
4240
4241
|
/** Lowercased `attester` of a stored attestation JSON; NULL when the JSON is invalid or has none. */
|
|
@@ -4276,7 +4277,7 @@ async function removeForeignAttestationRows() {
|
|
|
4276
4277
|
return { versionRows: foreignVersionUids.length, propertyRows };
|
|
4277
4278
|
}
|
|
4278
4279
|
/** Runs the cleanup unless this database has had it, and records that it has. */
|
|
4279
|
-
async function runOnce$
|
|
4280
|
+
async function runOnce$2() {
|
|
4280
4281
|
const appDb = BaseDb.getAppDb();
|
|
4281
4282
|
const marker = await appDb
|
|
4282
4283
|
.select()
|
|
@@ -4292,22 +4293,22 @@ async function runOnce$1() {
|
|
|
4292
4293
|
.values({ key: FOREIGN_ATTESTATION_CLEANUP_KEY, value })
|
|
4293
4294
|
.onConflictDoUpdate({ target: appState.key, set: { value } });
|
|
4294
4295
|
if (result.versionRows > 0 || result.propertyRows > 0) {
|
|
4295
|
-
logger$
|
|
4296
|
+
logger$4(`removed ${result.versionRows} version and ${result.propertyRows} property rows from other attesters`);
|
|
4296
4297
|
}
|
|
4297
4298
|
}
|
|
4298
|
-
let running$
|
|
4299
|
-
let deferredUntilLeader$
|
|
4300
|
-
const runInBackground$
|
|
4299
|
+
let running$3;
|
|
4300
|
+
let deferredUntilLeader$3 = false;
|
|
4301
|
+
const runInBackground$3 = () => {
|
|
4301
4302
|
// Under the sync's lock, so it can't interleave with a sync writing the same rows.
|
|
4302
|
-
running$
|
|
4303
|
+
running$3 ?? (running$3 = withDbTabLock('eas-sync', runOnce$2, { timeoutMs: Infinity })
|
|
4303
4304
|
.catch((error) => {
|
|
4304
4305
|
// Never fails init: the rows stay until the next sync of their seeds removes them.
|
|
4305
|
-
logger$
|
|
4306
|
+
logger$4('foreign attestation cleanup failed', error);
|
|
4306
4307
|
})
|
|
4307
4308
|
.finally(() => {
|
|
4308
|
-
running$
|
|
4309
|
+
running$3 = undefined;
|
|
4309
4310
|
}));
|
|
4310
|
-
return running$
|
|
4311
|
+
return running$3;
|
|
4311
4312
|
};
|
|
4312
4313
|
/**
|
|
4313
4314
|
* Starts {@link removeForeignAttestationRows} in the background after client init, once per
|
|
@@ -4317,19 +4318,19 @@ const runInBackground$2 = () => {
|
|
|
4317
4318
|
*/
|
|
4318
4319
|
function startForeignAttestationCleanup() {
|
|
4319
4320
|
if (isLeaderTab()) {
|
|
4320
|
-
void runInBackground$
|
|
4321
|
+
void runInBackground$3();
|
|
4321
4322
|
return;
|
|
4322
4323
|
}
|
|
4323
|
-
if (deferredUntilLeader$
|
|
4324
|
+
if (deferredUntilLeader$3)
|
|
4324
4325
|
return;
|
|
4325
|
-
deferredUntilLeader$
|
|
4326
|
+
deferredUntilLeader$3 = true;
|
|
4326
4327
|
void whenLeaderTab().then(() => {
|
|
4327
|
-
deferredUntilLeader$
|
|
4328
|
-
void runInBackground$
|
|
4328
|
+
deferredUntilLeader$3 = false;
|
|
4329
|
+
void runInBackground$3();
|
|
4329
4330
|
});
|
|
4330
4331
|
}
|
|
4331
4332
|
|
|
4332
|
-
const logger$
|
|
4333
|
+
const logger$3 = debug('seedSdk:db:alignRowPublishers');
|
|
4333
4334
|
/** appState key recording that the fix below has run on this database. */
|
|
4334
4335
|
const ROW_PUBLISHERS_ALIGNED_KEY = 'rowPublishersAligned';
|
|
4335
4336
|
/**
|
|
@@ -4395,7 +4396,7 @@ async function alignRowPublishers() {
|
|
|
4395
4396
|
return { versionRows, propertyRows };
|
|
4396
4397
|
}
|
|
4397
4398
|
/** Runs the fix unless this database has had it, and records that it has. */
|
|
4398
|
-
async function runOnce() {
|
|
4399
|
+
async function runOnce$1() {
|
|
4399
4400
|
const appDb = BaseDb.getAppDb();
|
|
4400
4401
|
const marker = await appDb
|
|
4401
4402
|
.select()
|
|
@@ -4411,28 +4412,98 @@ async function runOnce() {
|
|
|
4411
4412
|
.values({ key: ROW_PUBLISHERS_ALIGNED_KEY, value })
|
|
4412
4413
|
.onConflictDoUpdate({ target: appState.key, set: { value } });
|
|
4413
4414
|
if (result.versionRows > 0 || result.propertyRows > 0) {
|
|
4414
|
-
logger$
|
|
4415
|
+
logger$3(`gave ${result.versionRows} version and ${result.propertyRows} property rows their seed's publisher`);
|
|
4415
4416
|
}
|
|
4416
4417
|
}
|
|
4417
|
-
let running$
|
|
4418
|
-
let deferredUntilLeader$
|
|
4419
|
-
const runInBackground$
|
|
4418
|
+
let running$2;
|
|
4419
|
+
let deferredUntilLeader$2 = false;
|
|
4420
|
+
const runInBackground$2 = () => {
|
|
4420
4421
|
// Under the sync's lock: sync writes these rows too.
|
|
4421
|
-
running$
|
|
4422
|
+
running$2 ?? (running$2 = withDbTabLock('eas-sync', runOnce$1, { timeoutMs: Infinity })
|
|
4422
4423
|
.catch((error) => {
|
|
4423
4424
|
// Never fails init: the rows keep their old publisher.
|
|
4424
|
-
logger$
|
|
4425
|
+
logger$3('row publisher fix failed', error);
|
|
4425
4426
|
})
|
|
4426
4427
|
.finally(() => {
|
|
4427
|
-
running$
|
|
4428
|
+
running$2 = undefined;
|
|
4428
4429
|
}));
|
|
4429
|
-
return running$
|
|
4430
|
+
return running$2;
|
|
4430
4431
|
};
|
|
4431
4432
|
/**
|
|
4432
4433
|
* Starts {@link alignRowPublishers} in the background after client init, once per database, like
|
|
4433
4434
|
* the foreign-attestation cleanup. Leader tab only (docs/MULTI_TAB.md). Never throws.
|
|
4434
4435
|
*/
|
|
4435
4436
|
function startAlignRowPublishers() {
|
|
4437
|
+
if (isLeaderTab()) {
|
|
4438
|
+
void runInBackground$2();
|
|
4439
|
+
return;
|
|
4440
|
+
}
|
|
4441
|
+
if (deferredUntilLeader$2)
|
|
4442
|
+
return;
|
|
4443
|
+
deferredUntilLeader$2 = true;
|
|
4444
|
+
void whenLeaderTab().then(() => {
|
|
4445
|
+
deferredUntilLeader$2 = false;
|
|
4446
|
+
void runInBackground$2();
|
|
4447
|
+
});
|
|
4448
|
+
}
|
|
4449
|
+
|
|
4450
|
+
const logger$2 = debug('seedSdk:db:clearStoredDisplayUrls');
|
|
4451
|
+
/** appState key recording that the fix below has run on this database. */
|
|
4452
|
+
const STORED_DISPLAY_URLS_CLEARED_KEY = 'storedDisplayUrlsCleared';
|
|
4453
|
+
/**
|
|
4454
|
+
* Nulls `ref_resolved_display_value` on File and Image rows that hold a session URL. SDK 0.7.5 and
|
|
4455
|
+
* 0.7.6 stored a File's content URL there: a `blob:` URL that is dead after a reload, or a
|
|
4456
|
+
* `file://` URL that breaks when filesDir moves. Readers now mint the URL from the file on disk and
|
|
4457
|
+
* ignore the column for these types; clearing it keeps older readers and direct DB queries from
|
|
4458
|
+
* picking the dead URL up. Returns the number of rows changed.
|
|
4459
|
+
*/
|
|
4460
|
+
async function clearStoredDisplayUrls() {
|
|
4461
|
+
const appDb = BaseDb.getAppDb();
|
|
4462
|
+
const where = and(inArray(metadata$1.refSeedType, ['file', 'image']), or(like(metadata$1.refResolvedDisplayValue, 'blob:%'), like(metadata$1.refResolvedDisplayValue, 'file:%')));
|
|
4463
|
+
const rows = (await appDb.select({ localId: metadata$1.localId }).from(metadata$1).where(where));
|
|
4464
|
+
if (rows.length === 0)
|
|
4465
|
+
return 0;
|
|
4466
|
+
await appDb.update(metadata$1).set({ refResolvedDisplayValue: null }).where(where);
|
|
4467
|
+
return rows.length;
|
|
4468
|
+
}
|
|
4469
|
+
/** Runs the fix unless this database has had it, and records that it has. */
|
|
4470
|
+
async function runOnce() {
|
|
4471
|
+
const appDb = BaseDb.getAppDb();
|
|
4472
|
+
const marker = await appDb
|
|
4473
|
+
.select()
|
|
4474
|
+
.from(appState)
|
|
4475
|
+
.where(eq(appState.key, STORED_DISPLAY_URLS_CLEARED_KEY))
|
|
4476
|
+
.limit(1);
|
|
4477
|
+
if (marker.length > 0)
|
|
4478
|
+
return;
|
|
4479
|
+
const rows = await clearStoredDisplayUrls();
|
|
4480
|
+
const value = JSON.stringify({ rows, at: Date.now() });
|
|
4481
|
+
await appDb
|
|
4482
|
+
.insert(appState)
|
|
4483
|
+
.values({ key: STORED_DISPLAY_URLS_CLEARED_KEY, value })
|
|
4484
|
+
.onConflictDoUpdate({ target: appState.key, set: { value } });
|
|
4485
|
+
if (rows > 0) {
|
|
4486
|
+
logger$2(`cleared stored display URLs on ${rows} File/Image rows`);
|
|
4487
|
+
}
|
|
4488
|
+
}
|
|
4489
|
+
let running$1;
|
|
4490
|
+
let deferredUntilLeader$1 = false;
|
|
4491
|
+
const runInBackground$1 = () => {
|
|
4492
|
+
running$1 ?? (running$1 = runOnce()
|
|
4493
|
+
.catch((error) => {
|
|
4494
|
+
// Never fails init: readers ignore the column for File and Image anyway.
|
|
4495
|
+
logger$2('clearing stored display URLs failed', error);
|
|
4496
|
+
})
|
|
4497
|
+
.finally(() => {
|
|
4498
|
+
running$1 = undefined;
|
|
4499
|
+
}));
|
|
4500
|
+
return running$1;
|
|
4501
|
+
};
|
|
4502
|
+
/**
|
|
4503
|
+
* Starts {@link clearStoredDisplayUrls} in the background after client init, once per database.
|
|
4504
|
+
* Leader tab only (docs/MULTI_TAB.md). Never throws.
|
|
4505
|
+
*/
|
|
4506
|
+
function startClearStoredDisplayUrls() {
|
|
4436
4507
|
if (isLeaderTab()) {
|
|
4437
4508
|
void runInBackground$1();
|
|
4438
4509
|
return;
|
|
@@ -4755,6 +4826,8 @@ const clientManagerMachine = setup({
|
|
|
4755
4826
|
() => startForeignAttestationCleanup(),
|
|
4756
4827
|
// Also once: version and property rows get their seed's publisher (rows from older edits had none).
|
|
4757
4828
|
() => startAlignRowPublishers(),
|
|
4829
|
+
// Also once: File/Image rows lose the session URLs 0.7.5–0.7.6 stored (dead blob: URLs after reload).
|
|
4830
|
+
() => startClearStoredDisplayUrls(),
|
|
4758
4831
|
// Stored model types to the ADR 0008 form (html_page), so exact type filters find old rows.
|
|
4759
4832
|
() => startCanonicalizeModelTypes(),
|
|
4760
4833
|
],
|
|
@@ -5446,10 +5519,28 @@ const INIT_CONFIG_CONFLICT_MESSAGE = 'client.init was already called with a diff
|
|
|
5446
5519
|
'initialised with: pass the same config, or call client.stop() before initialising with a new one. ' +
|
|
5447
5520
|
'To change addresses, use client.setAddresses() (or call init again with the same config and new addresses).';
|
|
5448
5521
|
const ensureInitialized = () => {
|
|
5449
|
-
|
|
5522
|
+
const snapshot = clientManager.getSnapshot();
|
|
5523
|
+
// After stop() the stopped actor's context still says isInitialized, so check its status too.
|
|
5524
|
+
if (snapshot.status !== 'active' || !snapshot.context.isInitialized) {
|
|
5450
5525
|
throw new Error(CLIENT_NOT_INITIALIZED);
|
|
5451
5526
|
}
|
|
5452
5527
|
};
|
|
5528
|
+
const CLIENT_ALREADY_STOPPED_WARNING = 'client.stop() or client.unload() was called after the client had already stopped; this call does nothing. ' +
|
|
5529
|
+
'Remove the extra call, or call client.init() before stopping again.';
|
|
5530
|
+
/** Shared by stop() and unload(). A repeat call after a stop warns and does nothing. */
|
|
5531
|
+
const stopClient = ({ unsubscribe }) => {
|
|
5532
|
+
if (clientManager.getSnapshot().status === 'stopped') {
|
|
5533
|
+
console.warn(CLIENT_ALREADY_STOPPED_WARNING);
|
|
5534
|
+
return;
|
|
5535
|
+
}
|
|
5536
|
+
ensureInitialized();
|
|
5537
|
+
activeInitConfig = undefined;
|
|
5538
|
+
cancelAllRetriesWhenOnline();
|
|
5539
|
+
unregisterSeedQueryLocalSource();
|
|
5540
|
+
clientManager.stop();
|
|
5541
|
+
if (unsubscribe)
|
|
5542
|
+
subscription.unsubscribe();
|
|
5543
|
+
};
|
|
5453
5544
|
const coalescedInit = createCoalescedAsync(async (options) => {
|
|
5454
5545
|
// If the actor is stopped (e.g., from a previous failed test), restart it
|
|
5455
5546
|
const snapshot = clientManager.getSnapshot();
|
|
@@ -5497,7 +5588,7 @@ const coalescedInit = createCoalescedAsync(async (options) => {
|
|
|
5497
5588
|
return snapshot.value === 'platformClassesInit' || snapshot.context.isInitialized;
|
|
5498
5589
|
}, { timeout: 1000 });
|
|
5499
5590
|
}
|
|
5500
|
-
catch
|
|
5591
|
+
catch {
|
|
5501
5592
|
// If we can't transition, continue anyway - the waitFor below will catch any errors
|
|
5502
5593
|
logger('Timeout waiting for state transition, continuing...');
|
|
5503
5594
|
}
|
|
@@ -5677,21 +5768,8 @@ const clientInstance = {
|
|
|
5677
5768
|
});
|
|
5678
5769
|
return () => subscription.unsubscribe();
|
|
5679
5770
|
},
|
|
5680
|
-
stop: () => {
|
|
5681
|
-
|
|
5682
|
-
activeInitConfig = undefined;
|
|
5683
|
-
cancelAllRetriesWhenOnline();
|
|
5684
|
-
unregisterSeedQueryLocalSource();
|
|
5685
|
-
clientManager.stop();
|
|
5686
|
-
},
|
|
5687
|
-
unload: () => {
|
|
5688
|
-
ensureInitialized();
|
|
5689
|
-
activeInitConfig = undefined;
|
|
5690
|
-
cancelAllRetriesWhenOnline();
|
|
5691
|
-
unregisterSeedQueryLocalSource();
|
|
5692
|
-
clientManager.stop();
|
|
5693
|
-
subscription.unsubscribe();
|
|
5694
|
-
},
|
|
5771
|
+
stop: () => stopClient({ unsubscribe: false }),
|
|
5772
|
+
unload: () => stopClient({ unsubscribe: true }),
|
|
5695
5773
|
};
|
|
5696
5774
|
// Export the singleton instance
|
|
5697
5775
|
// This ensures all imports across different files get the same instance
|
|
@@ -5702,6 +5780,7 @@ const getClient = () => {
|
|
|
5702
5780
|
|
|
5703
5781
|
var ClientManager$1 = /*#__PURE__*/Object.freeze({
|
|
5704
5782
|
__proto__: null,
|
|
5783
|
+
CLIENT_ALREADY_STOPPED_WARNING: CLIENT_ALREADY_STOPPED_WARNING,
|
|
5705
5784
|
ClientManager: ClientManager,
|
|
5706
5785
|
INIT_CONFIG_CONFLICT_MESSAGE: INIT_CONFIG_CONFLICT_MESSAGE,
|
|
5707
5786
|
get clientManager () { return clientManager; },
|
|
@@ -5709,4 +5788,4 @@ var ClientManager$1 = /*#__PURE__*/Object.freeze({
|
|
|
5709
5788
|
});
|
|
5710
5789
|
|
|
5711
5790
|
export { requestEasSyncFromEventBus as A, requestEasSyncFromModelsInit as B, ClientManager as C, sendEasSyncClientRequest as D, EAS_CHAIN_ID_APP_STATE_KEY as E, setRetriesWhenOnlineEnabled as F, startEasSyncActor as G, unregisterSeedQueryLocalSource as H, INIT_CONFIG_CONFLICT_MESSAGE as I, createRowsWrittenSignal as J, createModelsFromJson as K, getLatestSchemaVersion as L, jsonPropertiesToSchemaProperties as M, schema as N, ClientManager$1 as O, SEEDPROTOCOL_Seed_Protocol_v1 as S, getContentHash as a, isVerbatimItemStorageDraftRow as b, convertVerbatimItemStorageRow as c, assertLocalDbChain as d, claimUnpublishedDrafts as e, createLocalQueryDataSource as f, getRefValueType as g, hardDeleteLocalSeedsByLocalIds as h, importJsonSchema as i, createSchema as j, easSyncActor as k, loadSchemaFromFile as l, getClient as m, getPublishedSeedRecord as n, getSchemaNameFromId as o, isSeedQueryLocalSourceRegistered as p, listCompleteSchemaFiles as q, readJsonImportFile as r, syncSchemaFromSource as s, transformImportToSchemaFile as t, loadAllSchemasFromDb as u, mergeEasSyncRequestIntents as v, waitForEasReadChain as w, readSchema as x, registerSeedQueryLocalSource as y, requestEasSyncFromAddressChange as z };
|
|
5712
|
-
//# sourceMappingURL=ClientManager-
|
|
5791
|
+
//# sourceMappingURL=ClientManager-DdqRofK6.js.map
|