@seedprotocol/sdk 0.7.8-next.1071.g2a141c1 → 0.7.8
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-Bv15o3Oz.js → ClientManager-B1r_8P5Z.js} +37 -40
- package/dist/ClientManager-B1r_8P5Z.js.map +1 -0
- package/dist/{Item-tX3kpbj4.js → Item-CjTEShfk.js} +384 -399
- package/dist/Item-CjTEShfk.js.map +1 -0
- package/dist/{ModelProperty-N-3gBfu5.js → ModelProperty-C3749Wjq.js} +36 -36
- package/dist/{ModelProperty-N-3gBfu5.js.map → ModelProperty-C3749Wjq.js.map} +1 -1
- package/dist/{Schema-CY3OxwKS.js → Schema-CX9CTtho.js} +35 -35
- package/dist/{Schema-CY3OxwKS.js.map → Schema-CX9CTtho.js.map} +1 -1
- package/dist/{SchemaValidationService-BR2ABK2r.js → SchemaValidationService-T5mqnY8q.js} +6 -6
- package/dist/{SchemaValidationService-BR2ABK2r.js.map → SchemaValidationService-T5mqnY8q.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-vc_1RoDT.js → backfillMetadataPropertyIds-DWWkh-Ex.js} +3 -3
- package/dist/{backfillMetadataPropertyIds-vc_1RoDT.js.map → backfillMetadataPropertyIds-DWWkh-Ex.js.map} +1 -1
- package/dist/{tabEvents-BuorBItJ.js → changeFeed-DcsZ7deG.js} +369 -10
- package/dist/changeFeed-DcsZ7deG.js.map +1 -0
- package/dist/{configurePlatform-D-Pj9gTx.js → configurePlatform-AWild9o4.js} +2 -2
- package/dist/{configurePlatform-D-Pj9gTx.js.map → configurePlatform-AWild9o4.js.map} +1 -1
- package/dist/db/drizzle/0022_add_read_indexes.sql +5 -0
- package/dist/db/drizzle/0023_add_entity_changes.sql +48 -0
- package/dist/db/drizzle/meta/0022_snapshot.json +1585 -0
- package/dist/db/drizzle/meta/0023_snapshot.json +1645 -0
- package/dist/db/drizzle/meta/_journal.json +14 -0
- package/dist/{detachRowsBeforeDelete-sK1ye2W6.js → detachRowsBeforeDelete-Bo_pky-R.js} +2 -2
- package/dist/{detachRowsBeforeDelete-sK1ye2W6.js.map → detachRowsBeforeDelete-Bo_pky-R.js.map} +1 -1
- package/dist/dist/{ClientManager-Bv15o3Oz.d.ts → ClientManager-B1r_8P5Z.d.ts} +1 -1
- package/dist/dist/ClientManager-B1r_8P5Z.d.ts.map +1 -0
- package/dist/dist/{Item-tX3kpbj4.d.ts → Item-CjTEShfk.d.ts} +3 -2
- package/dist/dist/Item-CjTEShfk.d.ts.map +1 -0
- package/dist/dist/{ModelProperty-N-3gBfu5.d.ts → ModelProperty-C3749Wjq.d.ts} +1 -1
- package/dist/dist/{ModelProperty-N-3gBfu5.d.ts.map → ModelProperty-C3749Wjq.d.ts.map} +1 -1
- package/dist/dist/{Schema-CY3OxwKS.d.ts → Schema-CX9CTtho.d.ts} +2 -2
- package/dist/dist/{Schema-CY3OxwKS.d.ts.map → Schema-CX9CTtho.d.ts.map} +1 -1
- package/dist/dist/{SchemaValidationService-BR2ABK2r.d.ts → SchemaValidationService-T5mqnY8q.d.ts} +1 -1
- package/dist/dist/{SchemaValidationService-BR2ABK2r.d.ts.map → SchemaValidationService-T5mqnY8q.d.ts.map} +1 -1
- package/dist/dist/{backfillMetadataPropertyIds-vc_1RoDT.d.ts → backfillMetadataPropertyIds-DWWkh-Ex.d.ts} +1 -1
- package/dist/dist/backfillMetadataPropertyIds-DWWkh-Ex.d.ts.map +1 -0
- package/dist/dist/{tabEvents-BuorBItJ.d.ts → changeFeed-DcsZ7deG.d.ts} +101 -36
- package/dist/dist/changeFeed-DcsZ7deG.d.ts.map +1 -0
- package/dist/dist/{configurePlatform-D-Pj9gTx.d.ts → configurePlatform-AWild9o4.d.ts} +1 -1
- package/dist/dist/configurePlatform-AWild9o4.d.ts.map +1 -0
- package/dist/dist/{detachRowsBeforeDelete-sK1ye2W6.d.ts → detachRowsBeforeDelete-Bo_pky-R.d.ts} +1 -1
- package/dist/dist/detachRowsBeforeDelete-Bo_pky-R.d.ts.map +1 -0
- package/dist/dist/{eas-BSQxj7gN.d.ts → eas--9vtNkma.d.ts} +1 -1
- package/dist/dist/eas--9vtNkma.d.ts.map +1 -0
- package/dist/dist/{errors-a4Tj6hly.d.ts → errors-rIWK7gwJ.d.ts} +1 -1
- package/dist/dist/{errors-a4Tj6hly.d.ts.map → errors-rIWK7gwJ.d.ts.map} +1 -1
- package/dist/dist/{getItem-Ctps9gSs.d.ts → getItem-5j22EWWE.d.ts} +1 -1
- package/dist/dist/getItem-5j22EWWE.d.ts.map +1 -0
- package/dist/dist/{getPublishPayload-C2g5pPD2.d.ts → getPublishPayload-BGl2SaGK.d.ts} +1 -1
- package/dist/dist/{getPublishPayload-C2g5pPD2.d.ts.map → getPublishPayload-BGl2SaGK.d.ts.map} +1 -1
- package/dist/dist/{getPublishUploads-CaJHy3SL.d.ts → getPublishUploads-DVsDx6Xf.d.ts} +1 -1
- package/dist/dist/{getPublishUploads-CaJHy3SL.d.ts.map → getPublishUploads-DVsDx6Xf.d.ts.map} +1 -1
- package/dist/dist/{index-s73wD_LC.d.ts → index-C0SetTd1.d.ts} +1190 -1065
- package/dist/dist/index-C0SetTd1.d.ts.map +1 -0
- package/dist/dist/{index-BgEwcREa.d.ts → index-CJK3F_MK.d.ts} +13 -13
- package/dist/dist/index-CJK3F_MK.d.ts.map +1 -0
- package/dist/dist/{index-B6hPWSM4.d.ts → index-CZQrNqvq.d.ts} +130 -13
- package/dist/dist/{index-B6hPWSM4.d.ts.map → index-CZQrNqvq.d.ts.map} +1 -1
- package/dist/dist/{index-bOwhhJJL.d.ts → index-Dp4uyZYx.d.ts} +5 -5
- package/dist/dist/index-Dp4uyZYx.d.ts.map +1 -0
- package/dist/dist/{index.browser-C7iZp7mx.d.ts → index.browser-Ll71Y_Dl.d.ts} +391 -39
- package/dist/dist/{index.browser-C7iZp7mx.d.ts.map → index.browser-Ll71Y_Dl.d.ts.map} +1 -1
- package/dist/dist/{index.node-MPVTJR2J.d.ts → index.node-CgltN0cC.d.ts} +517 -49
- package/dist/dist/{index.node-MPVTJR2J.d.ts.map → index.node-CgltN0cC.d.ts.map} +1 -1
- package/dist/dist/modelPropertyRecordSchemas-C_lYTzMr.d.ts +7 -0
- package/dist/dist/modelPropertyRecordSchemas-C_lYTzMr.d.ts.map +1 -0
- package/dist/dist/platform.browser.d.ts +2 -2
- package/dist/dist/platform.node.d.ts +2 -2
- package/dist/dist/{property-mP9mOZ2L.d.ts → property-pcDxNEpy.d.ts} +3 -3
- package/dist/dist/property-pcDxNEpy.d.ts.map +1 -0
- package/dist/dist/{propertyValidationRules-DwzrYA7c.d.ts → propertyValidationRules-BEjN0f3-.d.ts} +6 -1
- package/dist/dist/propertyValidationRules-BEjN0f3-.d.ts.map +1 -0
- package/dist/dist/{publishDraftGraph-BzYVblZZ.d.ts → publishDraftGraph-I5yKe1Xz.d.ts} +1 -1
- package/dist/dist/{publishDraftGraph-BzYVblZZ.d.ts.map → publishDraftGraph-I5yKe1Xz.d.ts.map} +1 -1
- package/dist/dist/{resetAmbiguousLegacyItemData-B_IUQA09.d.ts → resetAmbiguousLegacyItemData-0Tin9-JK.d.ts} +1 -1
- package/dist/dist/resetAmbiguousLegacyItemData-0Tin9-JK.d.ts.map +1 -0
- package/dist/dist/{resolveModelForSyncedSeed-H-4tmU6l.d.ts → resolveModelForSyncedSeed-C5KXn6ex.d.ts} +1 -1
- package/dist/dist/resolveModelForSyncedSeed-C5KXn6ex.d.ts.map +1 -0
- package/dist/dist/{syncDbWithEas-y5VF623G.d.ts → syncDbWithEas-b4fESZ7C.d.ts} +1 -1
- package/dist/dist/syncDbWithEas-b4fESZ7C.d.ts.map +1 -0
- package/dist/dist/{tolerantWebAccess-DoI7QYT-.d.ts → tolerantWebAccess-CIpS7RLk.d.ts} +1 -1
- package/dist/dist/{tolerantWebAccess-DoI7QYT-.d.ts.map → tolerantWebAccess-CIpS7RLk.d.ts.map} +1 -1
- package/dist/dist/{updateSeedRevokedAt-BIzkbsUd.d.ts → updateSeedRevokedAt-CR4zwn-6.d.ts} +1 -1
- package/dist/dist/updateSeedRevokedAt-CR4zwn-6.d.ts.map +1 -0
- package/dist/{eas-BSQxj7gN.js → eas--9vtNkma.js} +3 -3
- package/dist/{eas-BSQxj7gN.js.map → eas--9vtNkma.js.map} +1 -1
- package/dist/{errors-a4Tj6hly.js → errors-rIWK7gwJ.js} +35 -35
- package/dist/{errors-a4Tj6hly.js.map → errors-rIWK7gwJ.js.map} +1 -1
- package/dist/{getItem-Ctps9gSs.js → getItem-5j22EWWE.js} +5 -5
- package/dist/{getItem-Ctps9gSs.js.map → getItem-5j22EWWE.js.map} +1 -1
- package/dist/{getPublishPayload-C2g5pPD2.js → getPublishPayload-BGl2SaGK.js} +14 -14
- package/dist/{getPublishPayload-C2g5pPD2.js.map → getPublishPayload-BGl2SaGK.js.map} +1 -1
- package/dist/{getPublishUploads-CaJHy3SL.js → getPublishUploads-DVsDx6Xf.js} +7 -7
- package/dist/{getPublishUploads-CaJHy3SL.js.map → getPublishUploads-DVsDx6Xf.js.map} +1 -1
- package/dist/{index-s73wD_LC.js → index-C0SetTd1.js} +52 -13
- package/dist/index-C0SetTd1.js.map +1 -0
- package/dist/{index-BgEwcREa.js → index-CJK3F_MK.js} +8 -8
- package/dist/index-CJK3F_MK.js.map +1 -0
- package/dist/{index-B6hPWSM4.js → index-CZQrNqvq.js} +3 -2
- package/dist/index-CZQrNqvq.js.map +1 -0
- package/dist/{index-bOwhhJJL.js → index-Dp4uyZYx.js} +8 -8
- package/dist/index-Dp4uyZYx.js.map +1 -0
- package/dist/{index.browser-C7iZp7mx.js → index.browser-Ll71Y_Dl.js} +243 -18
- package/dist/index.browser-Ll71Y_Dl.js.map +1 -0
- package/dist/{index.node-MPVTJR2J.js → index.node-CgltN0cC.js} +50 -15
- package/dist/index.node-CgltN0cC.js.map +1 -0
- package/dist/main.js +23 -30
- package/dist/main.js.map +1 -1
- package/dist/modelPropertyRecordSchemas-C_lYTzMr.js +94 -0
- package/dist/modelPropertyRecordSchemas-C_lYTzMr.js.map +1 -0
- package/dist/node.js +11 -11
- package/dist/platform.browser.js +5 -5
- package/dist/platform.node.js +4 -4
- package/dist/{property-mP9mOZ2L.js → property-pcDxNEpy.js} +7 -7
- package/dist/{property-mP9mOZ2L.js.map → property-pcDxNEpy.js.map} +1 -1
- package/dist/propertyValidationRules-BEjN0f3-.js +73 -0
- package/dist/propertyValidationRules-BEjN0f3-.js.map +1 -0
- package/dist/{publishDraftGraph-BzYVblZZ.js → publishDraftGraph-I5yKe1Xz.js} +6 -6
- package/dist/{publishDraftGraph-BzYVblZZ.js.map → publishDraftGraph-I5yKe1Xz.js.map} +1 -1
- package/dist/{resetAmbiguousLegacyItemData-B_IUQA09.js → resetAmbiguousLegacyItemData-0Tin9-JK.js} +2 -2
- package/dist/{resetAmbiguousLegacyItemData-B_IUQA09.js.map → resetAmbiguousLegacyItemData-0Tin9-JK.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-H-4tmU6l.js → resolveModelForSyncedSeed-C5KXn6ex.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-H-4tmU6l.js.map → resolveModelForSyncedSeed-C5KXn6ex.js.map} +1 -1
- package/dist/seedSchema/EntityChangeSchema.ts +28 -0
- package/dist/seedSchema/MetadataSchema.ts +12 -4
- package/dist/seedSchema/SeedSchema.ts +9 -3
- package/dist/seedSchema/VersionSchema.ts +9 -4
- package/dist/seedSchema/index.ts +1 -0
- package/dist/src/Item/Item.d.ts +2 -1
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Item/service/actors/loadOrCreateItem.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/modelPropertyRecordSchemas.d.ts +21 -0
- package/dist/src/ItemProperty/service/actors/modelPropertyRecordSchemas.d.ts.map +1 -0
- package/dist/src/browser/db/Db.d.ts +2 -2
- package/dist/src/browser/db/Db.d.ts.map +1 -1
- package/dist/src/browser/db/changeFeed.d.ts +77 -0
- package/dist/src/browser/db/changeFeed.d.ts.map +1 -0
- package/dist/src/browser/db/drizzleFiles.d.ts +4 -2
- package/dist/src/browser/db/drizzleFiles.d.ts.map +1 -1
- package/dist/src/db/write/applyArweaveL1TransactionIdLocal.d.ts.map +1 -1
- package/dist/src/db/write/claimUnpublishedDrafts.d.ts.map +1 -1
- package/dist/src/db/write/createMetadata.d.ts.map +1 -1
- package/dist/src/db/write/createSeed.d.ts.map +1 -1
- package/dist/src/db/write/createVersion.d.ts.map +1 -1
- package/dist/src/db/write/restoreDataItemIdsOverwrittenByL1.d.ts.map +1 -1
- package/dist/src/db/write/saveMetadata.d.ts.map +1 -1
- package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
- package/dist/src/db/write/updateSeedRevokedAt.d.ts.map +1 -1
- package/dist/src/db/write/updateSeedUid.d.ts.map +1 -1
- package/dist/src/db/write/updateVersionUid.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/helpers/propertyValidationRules.d.ts +8 -0
- package/dist/src/helpers/propertyValidationRules.d.ts.map +1 -1
- package/dist/src/helpers/timing.d.ts +36 -0
- package/dist/src/helpers/timing.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/node/db/singleConnectionTransactions.d.ts +6 -0
- package/dist/src/node/db/singleConnectionTransactions.d.ts.map +1 -1
- package/dist/src/outbox/itemAppliers.d.ts.map +1 -1
- package/dist/src/outbox/outbox.d.ts +2 -0
- package/dist/src/outbox/outbox.d.ts.map +1 -1
- package/dist/src/outbox/pendingValues.d.ts.map +1 -1
- package/dist/src/seedSchema/EntityChangeSchema.d.ts +126 -0
- package/dist/src/seedSchema/EntityChangeSchema.d.ts.map +1 -0
- package/dist/src/seedSchema/MetadataSchema.d.ts +4 -4
- package/dist/src/seedSchema/MetadataSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/SeedSchema.d.ts +4 -4
- package/dist/src/seedSchema/SeedSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/VersionSchema.d.ts +4 -4
- package/dist/src/seedSchema/VersionSchema.d.ts.map +1 -1
- package/dist/src/seedSchema/index.d.ts +1 -0
- package/dist/src/seedSchema/index.d.ts.map +1 -1
- package/dist/{syncDbWithEas-y5VF623G.js → syncDbWithEas-b4fESZ7C.js} +17 -23
- package/dist/syncDbWithEas-b4fESZ7C.js.map +1 -0
- package/dist/{tolerantWebAccess-DoI7QYT-.js → tolerantWebAccess-CIpS7RLk.js} +6 -6
- package/dist/{tolerantWebAccess-DoI7QYT-.js.map → tolerantWebAccess-CIpS7RLk.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-BIzkbsUd.js → updateSeedRevokedAt-CR4zwn-6.js} +5 -6
- package/dist/updateSeedRevokedAt-CR4zwn-6.js.map +1 -0
- package/package.json +6 -6
- package/dist/ClientManager-Bv15o3Oz.js.map +0 -1
- package/dist/Item-tX3kpbj4.js.map +0 -1
- package/dist/dist/ClientManager-Bv15o3Oz.d.ts.map +0 -1
- package/dist/dist/Item-tX3kpbj4.d.ts.map +0 -1
- package/dist/dist/backfillMetadataPropertyIds-vc_1RoDT.d.ts.map +0 -1
- package/dist/dist/configurePlatform-D-Pj9gTx.d.ts.map +0 -1
- package/dist/dist/detachRowsBeforeDelete-sK1ye2W6.d.ts.map +0 -1
- package/dist/dist/eas-BSQxj7gN.d.ts.map +0 -1
- package/dist/dist/getItem-Ctps9gSs.d.ts.map +0 -1
- package/dist/dist/index-BgEwcREa.d.ts.map +0 -1
- package/dist/dist/index-bOwhhJJL.d.ts.map +0 -1
- package/dist/dist/index-s73wD_LC.d.ts.map +0 -1
- package/dist/dist/property-mP9mOZ2L.d.ts.map +0 -1
- package/dist/dist/propertyValidationRules-DwzrYA7c.d.ts.map +0 -1
- package/dist/dist/resetAmbiguousLegacyItemData-B_IUQA09.d.ts.map +0 -1
- package/dist/dist/resolveModelForSyncedSeed-H-4tmU6l.d.ts.map +0 -1
- package/dist/dist/syncDbWithEas-y5VF623G.d.ts.map +0 -1
- package/dist/dist/tabEvents-BuorBItJ.d.ts.map +0 -1
- package/dist/dist/updateSeedRevokedAt-BIzkbsUd.d.ts.map +0 -1
- package/dist/index-B6hPWSM4.js.map +0 -1
- package/dist/index-BgEwcREa.js.map +0 -1
- package/dist/index-bOwhhJJL.js.map +0 -1
- package/dist/index-s73wD_LC.js.map +0 -1
- package/dist/index.browser-C7iZp7mx.js.map +0 -1
- package/dist/index.node-MPVTJR2J.js.map +0 -1
- package/dist/propertyValidationRules-DwzrYA7c.js +0 -51
- package/dist/propertyValidationRules-DwzrYA7c.js.map +0 -1
- package/dist/syncDbWithEas-y5VF623G.js.map +0 -1
- package/dist/tabEvents-BuorBItJ.js.map +0 -1
- package/dist/updateSeedRevokedAt-BIzkbsUd.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publishDraftGraph-BzYVblZZ.js","sources":["../../src/helpers/reconcilePropertyDraftRows.ts","../../src/helpers/getSegmentedItemProperties.ts","../../src/db/read/isSeedRevoked.ts","../../src/db/read/resolveRelatedSeedRef.ts","../../src/db/read/publishDraftGraph.ts"],"sourcesContent":["import { eq, sql } from 'drizzle-orm'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { metadata } from '@/seedSchema'\nimport { isPlaceholderUid } from '@/helpers/easUid'\nimport { METADATA_LATEST_FIRST_ORDER_SQL } from '@/helpers/compareMetadataRowsLatestFirst'\nimport type { IItem } from '@/interfaces'\n\n/**\n * Points each property whose context holds a published row's uid at the property's newest row when\n * that row is a draft, clearing the uid. Publish skips a property with a uid in patch mode, so an\n * edit the context missed (another tab's write, a metadata update the live query dropped while the\n * property was saving) would never attest. The value in the context is left alone.\n */\nexport const reconcilePropertyDraftRows = async (item: IItem<any>): Promise<void> => {\n const stale = item.properties.filter((property) => property.uid && property.localId)\n const seedLocalId = item.seedLocalId\n if (stale.length === 0 || !seedLocalId) return\n const appDb = BaseDb.getAppDb()\n if (!appDb) return\n\n const rows = await appDb\n .select({ localId: metadata.localId, uid: metadata.uid, propertyName: metadata.propertyName })\n .from(metadata)\n .where(eq(metadata.seedLocalId, seedLocalId))\n .orderBy(sql.raw(METADATA_LATEST_FIRST_ORDER_SQL))\n\n for (const property of stale) {\n // The context's row gives the stored property name (relations and lists store a variant).\n const current = rows.find((row: { localId: string | null }) => row.localId === property.localId)\n if (!current?.propertyName) continue\n const newest = rows.find((row: { propertyName: string | null }) => row.propertyName === current.propertyName)\n if (!newest?.localId || newest.localId === current.localId || !isPlaceholderUid(newest.uid)) continue\n property.getService().send({ type: 'updateContext', localId: newest.localId, uid: undefined })\n }\n}\n","import { UploadProperty } from '@/db/read/getPublishUploads'\nimport { IItem } from '@/interfaces'\nimport { ModelPropertyDataTypes, normalizeDataType } from '@/Schema'\nimport { getPropertySchema, TProperty } from '@/helpers/property'\nimport { getItemModelScope, resolveModelRecord, type ModelScope } from '@/db/read/resolveModelRecord'\nimport type { Static } from '@sinclair/typebox'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { models, properties } from '@/seedSchema'\nimport { eq, and } from 'drizzle-orm'\nimport { camelCase, upperFirst } from 'lodash-es'\nimport { reconcilePropertyDraftRows } from '@/helpers/reconcilePropertyDraftRows'\n\nconst matchesDataType = (\n actual: string | undefined,\n expected: ModelPropertyDataTypes | string,\n): boolean => normalizeDataType(actual) === expected\nasync function resolvePropertyDef(\n modelName: string,\n propertyName: string,\n scope: ModelScope,\n): Promise<{ dataType?: string; ref?: string; refValueType?: string; storageType?: string; localStorageDir?: string; filenameSuffix?: string; required?: boolean } | undefined> {\n const schema = await getPropertySchema(modelName, propertyName, scope)\n if (schema) return schema\n const db = BaseDb.getAppDb()\n if (!db) return undefined\n try {\n const normalizedModelName = upperFirst(camelCase(modelName))\n const modelRecord = await resolveModelRecord(normalizedModelName, scope, db)\n const modelRecords = modelRecord ? [modelRecord] : []\n if (modelRecords.length === 0 || !modelRecords[0].id) return undefined\n const propertyRecords = await db\n .select()\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRecords[0].id),\n eq(properties.name, propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length === 0) return undefined\n const propRecord = propertyRecords[0]\n let refModelName: string | undefined\n if (propRecord.refModelId != null) {\n const refModelRows = await db\n .select({ name: models.name })\n .from(models)\n .where(eq(models.id, propRecord.refModelId))\n .limit(1)\n refModelName = refModelRows[0]?.name ?? undefined\n }\n return {\n dataType: propRecord.dataType,\n ref: refModelName ?? undefined,\n refValueType: propRecord.refValueType || undefined,\n storageType: propRecord.storageType || undefined,\n localStorageDir: propRecord.localStorageDir || undefined,\n filenameSuffix: propRecord.filenameSuffix || undefined,\n required: propRecord.required ?? undefined,\n }\n } catch {\n return undefined\n }\n}\n\nexport const getSegmentedItemProperties = async (item: IItem<any>) => {\n const itemBasicProperties = []\n const itemRelationProperties = []\n const itemListProperties = []\n const itemUploadProperties: UploadProperty[] = []\n const itemImageProperties = []\n const itemStorageProperties = []\n let itemStorageTransactionProperty: UploadProperty | undefined\n let itemScope: ModelScope | undefined\n\n // Publish decides from each property's uid; it must name the property's newest row.\n await reconcilePropertyDraftRows(item)\n\n for (const itemProperty of item.properties) {\n let propertyDef = itemProperty.propertyDef\n // When propertyDef is missing (e.g. external app, Model not registered), resolve inline\n // so properties are not skipped and metadata attestations can be created\n if (!propertyDef && item.modelName) {\n itemScope ??= await getItemModelScope(item as any)\n const resolved = await resolvePropertyDef(item.modelName, itemProperty.propertyName, itemScope)\n if (resolved) {\n itemProperty.getService().send({ type: 'updateContext', propertyRecordSchema: resolved })\n propertyDef = resolved as Static<typeof TProperty>\n } else {\n // Last resort: Model and DB don't have schema. Use Text so property routes to\n // itemBasicProperties and can be attested (covers title, description, etc.)\n const fallbackDef = { dataType: 'Text' as const }\n itemProperty.getService().send({ type: 'updateContext', propertyRecordSchema: fallbackDef })\n propertyDef = fallbackDef as Static<typeof TProperty>\n }\n }\n if (!propertyDef) {\n continue\n }\n\n const isItemStorage =\n propertyDef.storageType &&\n propertyDef.storageType === 'ItemStorage'\n\n\n const isStorageTransaction =\n itemProperty.propertyName === 'storageTransactionId' ||\n itemProperty.propertyName === 'storage_transaction_id'\n\n const isStorageSeedType =\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Image) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.File) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Html) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Json) ||\n (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation) &&\n (matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Image) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.File) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Html) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Json)))\n\n if (isStorageSeedType) {\n itemImageProperties.push(itemProperty)\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation)) {\n itemRelationProperties.push(itemProperty)\n }\n continue\n }\n\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation)) {\n itemRelationProperties.push(itemProperty)\n continue\n }\n\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.List)) {\n // List-of-relations: ref present, goes to processListProperty\n // List-of-primitives: ref absent, treat as basic property\n const listRef =\n propertyDef.ref || (propertyDef as { refModelName?: string }).refModelName\n if (listRef) {\n itemListProperties.push(itemProperty)\n } else {\n itemBasicProperties.push(itemProperty)\n }\n continue\n }\n\n if (isItemStorage) {\n itemStorageProperties.push(itemProperty)\n continue\n }\n\n if (isStorageTransaction) {\n itemStorageTransactionProperty = { itemProperty, childProperties: [] }\n continue\n }\n\n itemBasicProperties.push(itemProperty)\n }\n\n if (itemStorageTransactionProperty && itemStorageProperties.length > 0) {\n itemStorageTransactionProperty.childProperties = itemStorageProperties\n }\n\n if (itemStorageTransactionProperty) {\n itemUploadProperties.push(itemStorageTransactionProperty)\n }\n\n return {\n itemBasicProperties,\n itemRelationProperties,\n itemListProperties,\n itemUploadProperties,\n itemImageProperties,\n }\n}\n","import { BaseDb } from '@/db/Db/BaseDb'\nimport { seeds } from '@/seedSchema'\nimport { eq } from 'drizzle-orm'\nimport { isVersionRevoked } from './subqueries/liveVersion'\n\n/**\n * True when the item's seed attestation was revoked (`seeds.revoked_at` set, by unpublish or EAS\n * sync). Such a seed can't take new versions: publishing again creates a new seed attestation\n * (see \"Republishing\" in docs/ATTESTATION_REVOCATION.md).\n */\nexport const isSeedRevoked = async (seedLocalId: string | undefined): Promise<boolean> => {\n if (!seedLocalId) return false\n const appDb = BaseDb.getAppDb()\n if (!appDb) return false\n const [row] = await appDb\n .select({ revokedAt: seeds.revokedAt })\n .from(seeds)\n .where(eq(seeds.localId, seedLocalId))\n .limit(1)\n return isVersionRevoked(row?.revokedAt)\n}\n","import { BaseDb } from '@/db/Db/BaseDb'\nimport { seeds, versions } from '@/seedSchema'\nimport { and, eq, isNotNull } from 'drizzle-orm'\nimport { ZERO_BYTES32 } from '@/helpers/constants'\nimport { isVersionRevoked } from './subqueries/liveVersion'\nimport { ModelPropertyDataTypes, normalizeDataType } from '@/helpers/property'\nimport type { IItem } from '@/interfaces'\n\nexport type RelatedSeedRow = {\n seedLocalId: string\n /** The seed's current uid (null while it was never published). */\n seedUid: string | null\n revokedAt: number | null\n type: string | null\n}\n\nconst selectSeed = {\n seedLocalId: seeds.localId,\n seedUid: seeds.uid,\n revokedAt: seeds.revokedAt,\n type: seeds.type,\n}\n\n/**\n * The local seed row a relation/list/image ref points at, by local id or uid. A uid that is no\n * seed's current uid can be the old uid of a seed that was unpublished and published again (a new\n * seed attestation, same local seed): its old version rows still record it, so it resolves to that\n * seed. Null when nothing local matches (e.g. a published uid with no local copy).\n */\nexport const findRelatedSeedRow = async ({\n seedLocalId,\n seedUid,\n}: {\n seedLocalId?: string\n seedUid?: string\n}): Promise<RelatedSeedRow | null> => {\n const appDb = BaseDb.getAppDb()\n if (!appDb) return null\n if (seedLocalId) {\n const [row] = await appDb.select(selectSeed).from(seeds).where(eq(seeds.localId, seedLocalId)).limit(1)\n if (row?.seedLocalId) return row as RelatedSeedRow\n }\n if (!seedUid || seedUid === ZERO_BYTES32) return null\n const [byUid] = await appDb.select(selectSeed).from(seeds).where(eq(seeds.uid, seedUid)).limit(1)\n if (byUid?.seedLocalId) return byUid as RelatedSeedRow\n const [version] = await appDb\n .select({ seedLocalId: versions.seedLocalId })\n .from(versions)\n .where(and(eq(versions.seedUid, seedUid), isNotNull(versions.seedLocalId)))\n .limit(1)\n if (!version?.seedLocalId) return null\n const [republished] = await appDb\n .select(selectSeed)\n .from(seeds)\n .where(eq(seeds.localId, version.seedLocalId))\n .limit(1)\n return republished?.seedLocalId ? (republished as RelatedSeedRow) : null\n}\n\n/** The seed is attested and its attestation is live. */\nexport const isLivePublishedSeed = (row: RelatedSeedRow | null): row is RelatedSeedRow & { seedUid: string } =>\n !!row?.seedUid && row.seedUid !== ZERO_BYTES32 && !isVersionRevoked(row.revokedAt)\n\n/** The seed was attested and that attestation was revoked (unpublished). */\nexport const isUnpublishedSeed = (row: RelatedSeedRow | null): row is RelatedSeedRow & { seedUid: string } =>\n !!row?.seedUid && row.seedUid !== ZERO_BYTES32 && isVersionRevoked(row.revokedAt)\n\n/** Model a relation/list/image property points at, from its definition. */\nexport function relatedModelNameFromDef(propertyDef: unknown): string | undefined {\n const def = propertyDef as { dataType?: string; ref?: string; refModelName?: string } | undefined\n if (!def) return undefined\n const dataType = normalizeDataType(def.dataType)\n if (dataType === ModelPropertyDataTypes.Image) return 'Image'\n if (dataType === ModelPropertyDataTypes.File) return 'File'\n if (dataType === ModelPropertyDataTypes.Html) return 'Html'\n return def.ref ?? def.refModelName\n}\n\n/**\n * Name of the item's Html property whose value is the Html seed `htmlSeedLocalId`: the property\n * that refers to the images embedded in that Html (htmlEmbeddedImageCoPublish rows).\n */\nexport function htmlPropertyNameForHtmlSeed(item: IItem<any>, htmlSeedLocalId: string): string {\n const want = htmlSeedLocalId.trim()\n for (const p of item.properties ?? []) {\n if (normalizeDataType(p.propertyDef?.dataType) !== ModelPropertyDataTypes.Html) continue\n const snap = p.getService().getSnapshot()\n const value = 'context' in snap ? (snap.context as { propertyValue?: unknown }).propertyValue : undefined\n if (typeof value === 'string' && value.trim() === want) return p.propertyName\n }\n return 'html'\n}\n","import { ZERO_BYTES32 } from '@/helpers/constants'\nimport { parseListPropertyValueFromStorage } from '@/helpers/listPropertyValueFromStorage'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport {\n isPublishedSeedRef,\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '@/helpers/relationSeedRef'\nimport type { IItem, IItemProperty } from '@/interfaces'\nimport { findRelatedSeedRow } from '@/db/read/resolveRelatedSeedRef'\nimport { isSeedRevoked } from '@/db/read/isSeedRevoked'\n\n/**\n * The draft items a publish of an item carries along, and how it walks to them.\n *\n * A publish attests the item and every draft item (no seed uid yet) reachable from it through\n * relation and list-of-relation properties, each with its full property set. Already-published\n * targets are referenced by their current uid and not walked into; revoked ones stop the publish\n * (RelatedItemUnpublishedError). getPublishPayload, getPublishUploads, getPublishUploadData (publish\n * package), summarizePublishWork and the Html-embedded image co-publish all walk this graph in the\n * same order: depth first, properties in item order (relations, then lists), list members in order.\n *\n * Cycles: an item can only attest the uid of a seed published before it in the same publish, so a\n * ref back to an item still being walked (an ancestor that gets a new seed in this publish) can't be\n * attested. Such a property is deferred: left out of this publish (it keeps no uid, so the next\n * publish of its item attests it, with the target's uid). For A ↔ B reached from A, A attests B's\n * uid and B's relation to A is deferred.\n */\n\n/** Relation properties that point at model items (not Image/File/Html/Json storage seeds). */\nexport function draftWalkProperties(segmented: {\n itemRelationProperties: IItemProperty<any>[]\n itemImageProperties: IItemProperty<any>[]\n itemListProperties: IItemProperty<any>[]\n}): { relationProperties: IItemProperty<any>[]; listProperties: IItemProperty<any>[] } {\n const storage = new Set(segmented.itemImageProperties)\n return {\n relationProperties: segmented.itemRelationProperties.filter((p) => !storage.has(p)),\n listProperties: segmented.itemListProperties,\n }\n}\n\nconst propertyContext = (prop: IItemProperty<any>): Record<string, unknown> | null => {\n const snapshot = prop.getService().getSnapshot()\n return snapshot && 'context' in snapshot\n ? ((snapshot as { context?: Record<string, unknown> }).context ?? null)\n : null\n}\n\n/** Seed refs held by a relation property (one) or a list property (each member). */\nexport function propertySeedRefs(prop: IItemProperty<any>, isList: boolean): string[] {\n const context = propertyContext(prop)\n if (!context) return []\n let value = context.propertyValue\n if (isList) {\n if (typeof value === 'string') value = parseListPropertyValueFromStorage(value)\n const arr = Array.isArray(value) ? value : value != null ? [value] : []\n return arr\n .map((v) =>\n v && typeof v === 'object'\n ? normalizeRelationPropertyValue(\n (v as { seedLocalId?: string; localId?: string }).seedLocalId ??\n (v as { localId?: string }).localId ??\n (v as { seedUid?: string }).seedUid ??\n (v as { uid?: string }).uid,\n )\n : normalizeRelationPropertyValue(v),\n )\n .filter((v): v is string => !!v)\n }\n const ref = normalizeRelationPropertyValue(value)\n return ref ? [ref] : []\n}\n\nconst isZeroUid = (uid: string | undefined | null): boolean => !uid || uid === ZERO_BYTES32\n\n/** The item gets a new seed attestation in this publish: a draft, or a revoked seed published again. */\nexport async function getsNewSeed(item: IItem<any>): Promise<boolean> {\n return isZeroUid(item.seedUid) || (await isSeedRevoked(item.seedLocalId))\n}\n\n/** Local seed id a ref points at (also for a republished seed's old uid), or undefined. */\nexport async function resolveRefSeedLocalId(ref: string): Promise<string | undefined> {\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(ref)\n if (!seedLocalId && !seedUid) return undefined\n const row = await findRelatedSeedRow({ seedLocalId, seedUid })\n return row?.seedLocalId ?? seedLocalId\n}\n\nexport type PublishDraftGraphNode = {\n item: IItem<any>\n /** The relation or list property the walk first reached the item through. */\n via: IItemProperty<any>\n viaList: boolean\n}\n\nexport type PublishDraftGraph = {\n /** Draft items reachable from the root (root excluded), in the order the walk finishes them. */\n drafts: PublishDraftGraphNode[]\n /** Properties pointing back at an item still being walked; left out of this publish. */\n deferredProperties: Set<IItemProperty<any>>\n /** For each deferred property, the seeds (local ids) of its back references. */\n backReferences: Map<IItemProperty<any>, Set<string>>\n}\n\nexport type GetPublishDraftGraphOptions = {\n /** `new_version` / republish: properties that already have a uid are attested (and walked) again. */\n forceFullSnapshot?: boolean\n /**\n * Throw like getPublishUploads always did when a relation holds an invalid value or a local id\n * with no local item. Otherwise such refs are skipped (getPublishPayload reports them).\n */\n strict?: boolean\n}\n\n/** Would the publish attest this property (so walk its refs)? Same rule as getPublishPayload. */\nfunction walksProperty(prop: IItemProperty<any>, forceFullSnapshot: boolean): boolean {\n if (prop.uid && !forceFullSnapshot) return false\n const ctx = propertyContext(prop)\n const value = ctx?.propertyValue\n return value != null && value !== '' && !(Array.isArray(value) && value.length === 0)\n}\n\nasync function loadItem(seedLocalId: string): Promise<IItem<any> | undefined> {\n const { getItem } = await import('./getItem')\n try {\n return (await getItem({ seedLocalId })) ?? undefined\n } catch {\n return undefined\n }\n}\n\nexport async function getPublishDraftGraph(\n root: IItem<any>,\n options?: GetPublishDraftGraphOptions,\n): Promise<PublishDraftGraph> {\n const forceFullSnapshot = options?.forceFullSnapshot === true\n const strict = options?.strict === true\n const drafts: PublishDraftGraphNode[] = []\n const deferredProperties = new Set<IItemProperty<any>>()\n const backReferences = new Map<IItemProperty<any>, Set<string>>()\n const visited = new Set<string>([root.seedLocalId])\n const inProgress = new Set<string>()\n if (await getsNewSeed(root)) inProgress.add(root.seedLocalId)\n\n /** Draft target of a ref, or undefined (published, revoked, unknown). */\n const draftTarget = async (\n prop: IItemProperty<any>,\n ref: string,\n isList: boolean,\n ): Promise<{ seedLocalId: string; item?: IItem<any> } | undefined> => {\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(ref)\n if (!seedLocalId && !seedUid) {\n if (strict && !isList) {\n throw new Error(`Invalid relation value for ${prop.propertyName}: expected local seed id or 0x uid`)\n }\n return undefined\n }\n const row = await findRelatedSeedRow({ seedLocalId, seedUid })\n const targetLocalId = row?.seedLocalId ?? seedLocalId\n if (!targetLocalId) return undefined\n // An item getting a new seed in this publish, still being walked (also the root when it is a\n // revoked seed published again): a back edge, whatever its current uid.\n if (inProgress.has(targetLocalId)) return { seedLocalId: targetLocalId }\n // Published (live or revoked): referenced by uid / reported, never walked into.\n if (row && !isZeroUid(row.seedUid)) return undefined\n if (visited.has(targetLocalId)) return { seedLocalId: targetLocalId }\n const item = await loadItem(targetLocalId)\n if (!item) {\n if (strict && !isList && !isPublishedSeedRef(ref)) {\n throw new Error(`No relatedItem found for ${prop.propertyName}`)\n }\n return undefined\n }\n if (!isZeroUid(item.seedUid)) return undefined\n return { seedLocalId: targetLocalId, item }\n }\n\n const visit = async (item: IItem<any>): Promise<void> => {\n const segmented = await getSegmentedItemProperties(item)\n const { relationProperties, listProperties } = draftWalkProperties(segmented)\n const walk = async (prop: IItemProperty<any>, isList: boolean) => {\n if (!walksProperty(prop, forceFullSnapshot)) return\n const targets: { seedLocalId: string; item?: IItem<any> }[] = []\n for (const ref of propertySeedRefs(prop, isList)) {\n const t = await draftTarget(prop, ref, isList)\n if (t) targets.push(t)\n }\n const back = targets.filter((t) => inProgress.has(t.seedLocalId)).map((t) => t.seedLocalId)\n if (back.length > 0) {\n deferredProperties.add(prop)\n backReferences.set(prop, new Set(back))\n }\n for (const t of targets) {\n if (!t.item || visited.has(t.seedLocalId)) continue\n visited.add(t.seedLocalId)\n inProgress.add(t.seedLocalId)\n await visit(t.item)\n inProgress.delete(t.seedLocalId)\n drafts.push({ item: t.item, via: prop, viaList: isList })\n }\n }\n for (const prop of relationProperties) await walk(prop, false)\n for (const prop of listProperties) await walk(prop, true)\n }\n\n await visit(root)\n return { drafts, deferredProperties, backReferences }\n}\n"],"names":[],"mapp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;AAAE,YAAA,MAAM,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;AAC3D,IAAA,CAAC;AAED,IAAA,MAAM,KAAK,CAAC,IAAI,CAAC;AACjB,IAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE;AACvD;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"publishDraftGraph-I5yKe1Xz.js","sources":["../../src/helpers/reconcilePropertyDraftRows.ts","../../src/helpers/getSegmentedItemProperties.ts","../../src/db/read/isSeedRevoked.ts","../../src/db/read/resolveRelatedSeedRef.ts","../../src/db/read/publishDraftGraph.ts"],"sourcesContent":["import { eq, sql } from 'drizzle-orm'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { metadata } from '@/seedSchema'\nimport { isPlaceholderUid } from '@/helpers/easUid'\nimport { METADATA_LATEST_FIRST_ORDER_SQL } from '@/helpers/compareMetadataRowsLatestFirst'\nimport type { IItem } from '@/interfaces'\n\n/**\n * Points each property whose context holds a published row's uid at the property's newest row when\n * that row is a draft, clearing the uid. Publish skips a property with a uid in patch mode, so an\n * edit the context missed (another tab's write, a metadata update the live query dropped while the\n * property was saving) would never attest. The value in the context is left alone.\n */\nexport const reconcilePropertyDraftRows = async (item: IItem<any>): Promise<void> => {\n const stale = item.properties.filter((property) => property.uid && property.localId)\n const seedLocalId = item.seedLocalId\n if (stale.length === 0 || !seedLocalId) return\n const appDb = BaseDb.getAppDb()\n if (!appDb) return\n\n const rows = await appDb\n .select({ localId: metadata.localId, uid: metadata.uid, propertyName: metadata.propertyName })\n .from(metadata)\n .where(eq(metadata.seedLocalId, seedLocalId))\n .orderBy(sql.raw(METADATA_LATEST_FIRST_ORDER_SQL))\n\n for (const property of stale) {\n // The context's row gives the stored property name (relations and lists store a variant).\n const current = rows.find((row: { localId: string | null }) => row.localId === property.localId)\n if (!current?.propertyName) continue\n const newest = rows.find((row: { propertyName: string | null }) => row.propertyName === current.propertyName)\n if (!newest?.localId || newest.localId === current.localId || !isPlaceholderUid(newest.uid)) continue\n property.getService().send({ type: 'updateContext', localId: newest.localId, uid: undefined })\n }\n}\n","import { UploadProperty } from '@/db/read/getPublishUploads'\nimport { IItem } from '@/interfaces'\nimport { ModelPropertyDataTypes, normalizeDataType } from '@/Schema'\nimport { getPropertySchema, TProperty } from '@/helpers/property'\nimport { getItemModelScope, resolveModelRecord, type ModelScope } from '@/db/read/resolveModelRecord'\nimport type { Static } from '@sinclair/typebox'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { models, properties } from '@/seedSchema'\nimport { eq, and } from 'drizzle-orm'\nimport { camelCase, upperFirst } from 'lodash-es'\nimport { reconcilePropertyDraftRows } from '@/helpers/reconcilePropertyDraftRows'\n\nconst matchesDataType = (\n actual: string | undefined,\n expected: ModelPropertyDataTypes | string,\n): boolean => normalizeDataType(actual) === expected\nasync function resolvePropertyDef(\n modelName: string,\n propertyName: string,\n scope: ModelScope,\n): Promise<{ dataType?: string; ref?: string; refValueType?: string; storageType?: string; localStorageDir?: string; filenameSuffix?: string; required?: boolean } | undefined> {\n const schema = await getPropertySchema(modelName, propertyName, scope)\n if (schema) return schema\n const db = BaseDb.getAppDb()\n if (!db) return undefined\n try {\n const normalizedModelName = upperFirst(camelCase(modelName))\n const modelRecord = await resolveModelRecord(normalizedModelName, scope, db)\n const modelRecords = modelRecord ? [modelRecord] : []\n if (modelRecords.length === 0 || !modelRecords[0].id) return undefined\n const propertyRecords = await db\n .select()\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRecords[0].id),\n eq(properties.name, propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length === 0) return undefined\n const propRecord = propertyRecords[0]\n let refModelName: string | undefined\n if (propRecord.refModelId != null) {\n const refModelRows = await db\n .select({ name: models.name })\n .from(models)\n .where(eq(models.id, propRecord.refModelId))\n .limit(1)\n refModelName = refModelRows[0]?.name ?? undefined\n }\n return {\n dataType: propRecord.dataType,\n ref: refModelName ?? undefined,\n refValueType: propRecord.refValueType || undefined,\n storageType: propRecord.storageType || undefined,\n localStorageDir: propRecord.localStorageDir || undefined,\n filenameSuffix: propRecord.filenameSuffix || undefined,\n required: propRecord.required ?? undefined,\n }\n } catch {\n return undefined\n }\n}\n\nexport const getSegmentedItemProperties = async (item: IItem<any>) => {\n const itemBasicProperties = []\n const itemRelationProperties = []\n const itemListProperties = []\n const itemUploadProperties: UploadProperty[] = []\n const itemImageProperties = []\n const itemStorageProperties = []\n let itemStorageTransactionProperty: UploadProperty | undefined\n let itemScope: ModelScope | undefined\n\n // Publish decides from each property's uid; it must name the property's newest row.\n await reconcilePropertyDraftRows(item)\n\n for (const itemProperty of item.properties) {\n let propertyDef = itemProperty.propertyDef\n // When propertyDef is missing (e.g. external app, Model not registered), resolve inline\n // so properties are not skipped and metadata attestations can be created\n if (!propertyDef && item.modelName) {\n itemScope ??= await getItemModelScope(item as any)\n const resolved = await resolvePropertyDef(item.modelName, itemProperty.propertyName, itemScope)\n if (resolved) {\n itemProperty.getService().send({ type: 'updateContext', propertyRecordSchema: resolved })\n propertyDef = resolved as Static<typeof TProperty>\n } else {\n // Last resort: Model and DB don't have schema. Use Text so property routes to\n // itemBasicProperties and can be attested (covers title, description, etc.)\n const fallbackDef = { dataType: 'Text' as const }\n itemProperty.getService().send({ type: 'updateContext', propertyRecordSchema: fallbackDef })\n propertyDef = fallbackDef as Static<typeof TProperty>\n }\n }\n if (!propertyDef) {\n continue\n }\n\n const isItemStorage =\n propertyDef.storageType &&\n propertyDef.storageType === 'ItemStorage'\n\n\n const isStorageTransaction =\n itemProperty.propertyName === 'storageTransactionId' ||\n itemProperty.propertyName === 'storage_transaction_id'\n\n const isStorageSeedType =\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Image) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.File) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Html) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Json) ||\n (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation) &&\n (matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Image) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.File) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Html) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Json)))\n\n if (isStorageSeedType) {\n itemImageProperties.push(itemProperty)\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation)) {\n itemRelationProperties.push(itemProperty)\n }\n continue\n }\n\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation)) {\n itemRelationProperties.push(itemProperty)\n continue\n }\n\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.List)) {\n // List-of-relations: ref present, goes to processListProperty\n // List-of-primitives: ref absent, treat as basic property\n const listRef =\n propertyDef.ref || (propertyDef as { refModelName?: string }).refModelName\n if (listRef) {\n itemListProperties.push(itemProperty)\n } else {\n itemBasicProperties.push(itemProperty)\n }\n continue\n }\n\n if (isItemStorage) {\n itemStorageProperties.push(itemProperty)\n continue\n }\n\n if (isStorageTransaction) {\n itemStorageTransactionProperty = { itemProperty, childProperties: [] }\n continue\n }\n\n itemBasicProperties.push(itemProperty)\n }\n\n if (itemStorageTransactionProperty && itemStorageProperties.length > 0) {\n itemStorageTransactionProperty.childProperties = itemStorageProperties\n }\n\n if (itemStorageTransactionProperty) {\n itemUploadProperties.push(itemStorageTransactionProperty)\n }\n\n return {\n itemBasicProperties,\n itemRelationProperties,\n itemListProperties,\n itemUploadProperties,\n itemImageProperties,\n }\n}\n","import { BaseDb } from '@/db/Db/BaseDb'\nimport { seeds } from '@/seedSchema'\nimport { eq } from 'drizzle-orm'\nimport { isVersionRevoked } from './subqueries/liveVersion'\n\n/**\n * True when the item's seed attestation was revoked (`seeds.revoked_at` set, by unpublish or EAS\n * sync). Such a seed can't take new versions: publishing again creates a new seed attestation\n * (see \"Republishing\" in docs/ATTESTATION_REVOCATION.md).\n */\nexport const isSeedRevoked = async (seedLocalId: string | undefined): Promise<boolean> => {\n if (!seedLocalId) return false\n const appDb = BaseDb.getAppDb()\n if (!appDb) return false\n const [row] = await appDb\n .select({ revokedAt: seeds.revokedAt })\n .from(seeds)\n .where(eq(seeds.localId, seedLocalId))\n .limit(1)\n return isVersionRevoked(row?.revokedAt)\n}\n","import { BaseDb } from '@/db/Db/BaseDb'\nimport { seeds, versions } from '@/seedSchema'\nimport { and, eq, isNotNull } from 'drizzle-orm'\nimport { ZERO_BYTES32 } from '@/helpers/constants'\nimport { isVersionRevoked } from './subqueries/liveVersion'\nimport { ModelPropertyDataTypes, normalizeDataType } from '@/helpers/property'\nimport type { IItem } from '@/interfaces'\n\nexport type RelatedSeedRow = {\n seedLocalId: string\n /** The seed's current uid (null while it was never published). */\n seedUid: string | null\n revokedAt: number | null\n type: string | null\n}\n\nconst selectSeed = {\n seedLocalId: seeds.localId,\n seedUid: seeds.uid,\n revokedAt: seeds.revokedAt,\n type: seeds.type,\n}\n\n/**\n * The local seed row a relation/list/image ref points at, by local id or uid. A uid that is no\n * seed's current uid can be the old uid of a seed that was unpublished and published again (a new\n * seed attestation, same local seed): its old version rows still record it, so it resolves to that\n * seed. Null when nothing local matches (e.g. a published uid with no local copy).\n */\nexport const findRelatedSeedRow = async ({\n seedLocalId,\n seedUid,\n}: {\n seedLocalId?: string\n seedUid?: string\n}): Promise<RelatedSeedRow | null> => {\n const appDb = BaseDb.getAppDb()\n if (!appDb) return null\n if (seedLocalId) {\n const [row] = await appDb.select(selectSeed).from(seeds).where(eq(seeds.localId, seedLocalId)).limit(1)\n if (row?.seedLocalId) return row as RelatedSeedRow\n }\n if (!seedUid || seedUid === ZERO_BYTES32) return null\n const [byUid] = await appDb.select(selectSeed).from(seeds).where(eq(seeds.uid, seedUid)).limit(1)\n if (byUid?.seedLocalId) return byUid as RelatedSeedRow\n const [version] = await appDb\n .select({ seedLocalId: versions.seedLocalId })\n .from(versions)\n .where(and(eq(versions.seedUid, seedUid), isNotNull(versions.seedLocalId)))\n .limit(1)\n if (!version?.seedLocalId) return null\n const [republished] = await appDb\n .select(selectSeed)\n .from(seeds)\n .where(eq(seeds.localId, version.seedLocalId))\n .limit(1)\n return republished?.seedLocalId ? (republished as RelatedSeedRow) : null\n}\n\n/** The seed is attested and its attestation is live. */\nexport const isLivePublishedSeed = (row: RelatedSeedRow | null): row is RelatedSeedRow & { seedUid: string } =>\n !!row?.seedUid && row.seedUid !== ZERO_BYTES32 && !isVersionRevoked(row.revokedAt)\n\n/** The seed was attested and that attestation was revoked (unpublished). */\nexport const isUnpublishedSeed = (row: RelatedSeedRow | null): row is RelatedSeedRow & { seedUid: string } =>\n !!row?.seedUid && row.seedUid !== ZERO_BYTES32 && isVersionRevoked(row.revokedAt)\n\n/** Model a relation/list/image property points at, from its definition. */\nexport function relatedModelNameFromDef(propertyDef: unknown): string | undefined {\n const def = propertyDef as { dataType?: string; ref?: string; refModelName?: string } | undefined\n if (!def) return undefined\n const dataType = normalizeDataType(def.dataType)\n if (dataType === ModelPropertyDataTypes.Image) return 'Image'\n if (dataType === ModelPropertyDataTypes.File) return 'File'\n if (dataType === ModelPropertyDataTypes.Html) return 'Html'\n return def.ref ?? def.refModelName\n}\n\n/**\n * Name of the item's Html property whose value is the Html seed `htmlSeedLocalId`: the property\n * that refers to the images embedded in that Html (htmlEmbeddedImageCoPublish rows).\n */\nexport function htmlPropertyNameForHtmlSeed(item: IItem<any>, htmlSeedLocalId: string): string {\n const want = htmlSeedLocalId.trim()\n for (const p of item.properties ?? []) {\n if (normalizeDataType(p.propertyDef?.dataType) !== ModelPropertyDataTypes.Html) continue\n const snap = p.getService().getSnapshot()\n const value = 'context' in snap ? (snap.context as { propertyValue?: unknown }).propertyValue : undefined\n if (typeof value === 'string' && value.trim() === want) return p.propertyName\n }\n return 'html'\n}\n","import { ZERO_BYTES32 } from '@/helpers/constants'\nimport { parseListPropertyValueFromStorage } from '@/helpers/listPropertyValueFromStorage'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport {\n isPublishedSeedRef,\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '@/helpers/relationSeedRef'\nimport type { IItem, IItemProperty } from '@/interfaces'\nimport { findRelatedSeedRow } from '@/db/read/resolveRelatedSeedRef'\nimport { isSeedRevoked } from '@/db/read/isSeedRevoked'\n\n/**\n * The draft items a publish of an item carries along, and how it walks to them.\n *\n * A publish attests the item and every draft item (no seed uid yet) reachable from it through\n * relation and list-of-relation properties, each with its full property set. Already-published\n * targets are referenced by their current uid and not walked into; revoked ones stop the publish\n * (RelatedItemUnpublishedError). getPublishPayload, getPublishUploads, getPublishUploadData (publish\n * package), summarizePublishWork and the Html-embedded image co-publish all walk this graph in the\n * same order: depth first, properties in item order (relations, then lists), list members in order.\n *\n * Cycles: an item can only attest the uid of a seed published before it in the same publish, so a\n * ref back to an item still being walked (an ancestor that gets a new seed in this publish) can't be\n * attested. Such a property is deferred: left out of this publish (it keeps no uid, so the next\n * publish of its item attests it, with the target's uid). For A ↔ B reached from A, A attests B's\n * uid and B's relation to A is deferred.\n */\n\n/** Relation properties that point at model items (not Image/File/Html/Json storage seeds). */\nexport function draftWalkProperties(segmented: {\n itemRelationProperties: IItemProperty<any>[]\n itemImageProperties: IItemProperty<any>[]\n itemListProperties: IItemProperty<any>[]\n}): { relationProperties: IItemProperty<any>[]; listProperties: IItemProperty<any>[] } {\n const storage = new Set(segmented.itemImageProperties)\n return {\n relationProperties: segmented.itemRelationProperties.filter((p) => !storage.has(p)),\n listProperties: segmented.itemListProperties,\n }\n}\n\nconst propertyContext = (prop: IItemProperty<any>): Record<string, unknown> | null => {\n const snapshot = prop.getService().getSnapshot()\n return snapshot && 'context' in snapshot\n ? ((snapshot as { context?: Record<string, unknown> }).context ?? null)\n : null\n}\n\n/** Seed refs held by a relation property (one) or a list property (each member). */\nexport function propertySeedRefs(prop: IItemProperty<any>, isList: boolean): string[] {\n const context = propertyContext(prop)\n if (!context) return []\n let value = context.propertyValue\n if (isList) {\n if (typeof value === 'string') value = parseListPropertyValueFromStorage(value)\n const arr = Array.isArray(value) ? value : value != null ? [value] : []\n return arr\n .map((v) =>\n v && typeof v === 'object'\n ? normalizeRelationPropertyValue(\n (v as { seedLocalId?: string; localId?: string }).seedLocalId ??\n (v as { localId?: string }).localId ??\n (v as { seedUid?: string }).seedUid ??\n (v as { uid?: string }).uid,\n )\n : normalizeRelationPropertyValue(v),\n )\n .filter((v): v is string => !!v)\n }\n const ref = normalizeRelationPropertyValue(value)\n return ref ? [ref] : []\n}\n\nconst isZeroUid = (uid: string | undefined | null): boolean => !uid || uid === ZERO_BYTES32\n\n/** The item gets a new seed attestation in this publish: a draft, or a revoked seed published again. */\nexport async function getsNewSeed(item: IItem<any>): Promise<boolean> {\n return isZeroUid(item.seedUid) || (await isSeedRevoked(item.seedLocalId))\n}\n\n/** Local seed id a ref points at (also for a republished seed's old uid), or undefined. */\nexport async function resolveRefSeedLocalId(ref: string): Promise<string | undefined> {\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(ref)\n if (!seedLocalId && !seedUid) return undefined\n const row = await findRelatedSeedRow({ seedLocalId, seedUid })\n return row?.seedLocalId ?? seedLocalId\n}\n\nexport type PublishDraftGraphNode = {\n item: IItem<any>\n /** The relation or list property the walk first reached the item through. */\n via: IItemProperty<any>\n viaList: boolean\n}\n\nexport type PublishDraftGraph = {\n /** Draft items reachable from the root (root excluded), in the order the walk finishes them. */\n drafts: PublishDraftGraphNode[]\n /** Properties pointing back at an item still being walked; left out of this publish. */\n deferredProperties: Set<IItemProperty<any>>\n /** For each deferred property, the seeds (local ids) of its back references. */\n backReferences: Map<IItemProperty<any>, Set<string>>\n}\n\nexport type GetPublishDraftGraphOptions = {\n /** `new_version` / republish: properties that already have a uid are attested (and walked) again. */\n forceFullSnapshot?: boolean\n /**\n * Throw like getPublishUploads always did when a relation holds an invalid value or a local id\n * with no local item. Otherwise such refs are skipped (getPublishPayload reports them).\n */\n strict?: boolean\n}\n\n/** Would the publish attest this property (so walk its refs)? Same rule as getPublishPayload. */\nfunction walksProperty(prop: IItemProperty<any>, forceFullSnapshot: boolean): boolean {\n if (prop.uid && !forceFullSnapshot) return false\n const ctx = propertyContext(prop)\n const value = ctx?.propertyValue\n return value != null && value !== '' && !(Array.isArray(value) && value.length === 0)\n}\n\nasync function loadItem(seedLocalId: string): Promise<IItem<any> | undefined> {\n const { getItem } = await import('./getItem')\n try {\n return (await getItem({ seedLocalId })) ?? undefined\n } catch {\n return undefined\n }\n}\n\nexport async function getPublishDraftGraph(\n root: IItem<any>,\n options?: GetPublishDraftGraphOptions,\n): Promise<PublishDraftGraph> {\n const forceFullSnapshot = options?.forceFullSnapshot === true\n const strict = options?.strict === true\n const drafts: PublishDraftGraphNode[] = []\n const deferredProperties = new Set<IItemProperty<any>>()\n const backReferences = new Map<IItemProperty<any>, Set<string>>()\n const visited = new Set<string>([root.seedLocalId])\n const inProgress = new Set<string>()\n if (await getsNewSeed(root)) inProgress.add(root.seedLocalId)\n\n /** Draft target of a ref, or undefined (published, revoked, unknown). */\n const draftTarget = async (\n prop: IItemProperty<any>,\n ref: string,\n isList: boolean,\n ): Promise<{ seedLocalId: string; item?: IItem<any> } | undefined> => {\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(ref)\n if (!seedLocalId && !seedUid) {\n if (strict && !isList) {\n throw new Error(`Invalid relation value for ${prop.propertyName}: expected local seed id or 0x uid`)\n }\n return undefined\n }\n const row = await findRelatedSeedRow({ seedLocalId, seedUid })\n const targetLocalId = row?.seedLocalId ?? seedLocalId\n if (!targetLocalId) return undefined\n // An item getting a new seed in this publish, still being walked (also the root when it is a\n // revoked seed published again): a back edge, whatever its current uid.\n if (inProgress.has(targetLocalId)) return { seedLocalId: targetLocalId }\n // Published (live or revoked): referenced by uid / reported, never walked into.\n if (row && !isZeroUid(row.seedUid)) return undefined\n if (visited.has(targetLocalId)) return { seedLocalId: targetLocalId }\n const item = await loadItem(targetLocalId)\n if (!item) {\n if (strict && !isList && !isPublishedSeedRef(ref)) {\n throw new Error(`No relatedItem found for ${prop.propertyName}`)\n }\n return undefined\n }\n if (!isZeroUid(item.seedUid)) return undefined\n return { seedLocalId: targetLocalId, item }\n }\n\n const visit = async (item: IItem<any>): Promise<void> => {\n const segmented = await getSegmentedItemProperties(item)\n const { relationProperties, listProperties } = draftWalkProperties(segmented)\n const walk = async (prop: IItemProperty<any>, isList: boolean) => {\n if (!walksProperty(prop, forceFullSnapshot)) return\n const targets: { seedLocalId: string; item?: IItem<any> }[] = []\n for (const ref of propertySeedRefs(prop, isList)) {\n const t = await draftTarget(prop, ref, isList)\n if (t) targets.push(t)\n }\n const back = targets.filter((t) => inProgress.has(t.seedLocalId)).map((t) => t.seedLocalId)\n if (back.length > 0) {\n deferredProperties.add(prop)\n backReferences.set(prop, new Set(back))\n }\n for (const t of targets) {\n if (!t.item || visited.has(t.seedLocalId)) continue\n visited.add(t.seedLocalId)\n inProgress.add(t.seedLocalId)\n await visit(t.item)\n inProgress.delete(t.seedLocalId)\n drafts.push({ item: t.item, via: prop, viaList: isList })\n }\n }\n for (const prop of relationProperties) await walk(prop, false)\n for (const prop of listProperties) await walk(prop, true)\n }\n\n await visit(root)\n return { drafts, deferredProperties, backReferences }\n}\n"],"names":[],"mappings":";;;;;;;;;AAOA;;;;;AAKG;AACI,MAAM,0BAA0B,GAAG,OAAO,IAAgB,KAAmB;IAClF,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC;AACpF,IAAA,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW;AACpC,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,WAAW;QAAE;AACxC,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE;AAC/B,IAAA,IAAI,CAAC,KAAK;QAAE;IAEZ,MA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BAAkB,CAAC,GAAG,CAAC,IAAI,CAAC;gBAC5B,cAAc,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;YACzC;AACA,YAAA,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE;AACvB,gBAAA,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC;oBAAE;AAC3C,gBAAA,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC;AAC1B,gBAAA,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC;AAC7B,gBAAA,MAAM,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACnB,gBAAA,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC;AAChC,gBAAA,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;YAC3D;AACF,QAAA,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,kBAAkB;AAAE,YAAA,MAAM,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC;QAC9D,KAAK,MAAM,IAAI,IAAI,cAAc;AAAE,YAAA,MAAM,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;AAC3D,IAAA,CAAC;AAED,IAAA,MAAM,KAAK,CAAC,IAAI,CAAC;AACjB,IAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE;AACvD;;;;;;;;;;"}
|
package/dist/{resetAmbiguousLegacyItemData-B_IUQA09.js → resetAmbiguousLegacyItemData-0Tin9-JK.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { eq, and, isNull, isNotNull } from 'drizzle-orm';
|
|
2
2
|
import { easName } from '@seedprotocol/eas';
|
|
3
3
|
import debug from 'debug';
|
|
4
|
-
import {
|
|
4
|
+
import { G as BaseDb, h as appState, C as seeds, B as schemas, t as models, r as modelSchemas, p as htmlEmbeddedImageCoPublish, j as arweaveL1FinalizeJobs, E as uploadProcesses, A as publishProcesses, l as easSyncProcesses, m as metadata, F as versions } from './index-C0SetTd1.js';
|
|
5
5
|
import '@seedprotocol/arweave';
|
|
6
6
|
import 'xstate';
|
|
7
7
|
import 'pluralize';
|
|
@@ -95,4 +95,4 @@ const resetAmbiguousLegacyItemData = async () => {
|
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
export { LEGACY_ITEM_MODEL_CHECK_KEY, resetAmbiguousLegacyItemData };
|
|
98
|
-
//# sourceMappingURL=resetAmbiguousLegacyItemData-
|
|
98
|
+
//# sourceMappingURL=resetAmbiguousLegacyItemData-0Tin9-JK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resetAmbiguousLegacyItemData-
|
|
1
|
+
{"version":3,"file":"resetAmbiguousLegacyItemData-0Tin9-JK.js","sources":["../../src/db/resetAmbiguousLegacyItemData.ts"],"sourcesContent":["import { eq, isNotNull, isNull, and } from 'drizzle-orm'\nimport { easName } from '@seedprotocol/eas'\nimport debug from 'debug'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport {\n appState,\n arweaveL1FinalizeJobs,\n easSyncProcesses,\n htmlEmbeddedImageCoPublish,\n metadata,\n models,\n publishProcesses,\n schemas,\n seeds,\n uploadProcesses,\n modelSchemas,\n versions,\n} from '@/seedSchema'\n\nconst logger = debug('seedSdk:db:resetAmbiguousLegacyItemData')\n\n/** appState key recording that the one-time check after migration 0015 has run. */\nexport const LEGACY_ITEM_MODEL_CHECK_KEY = 'legacyItemModelCheck:v1'\n\n/**\n * One-time check after seeds.model_file_id was introduced (migration 0015). Seeds from before then\n * that couldn't be backfilled have no model; if their model name now exists in more than one schema\n * there is no way to tell which model they belong to. In that case the local item data (seeds,\n * versions, metadata and the jobs that reference them) is cleared, keeping schemas and models;\n * published items come back on the next EAS sync.\n *\n * Runs once (not on every start): EAS-synced seeds also lack model_file_id until\n * resolveModelForSyncedSeed exists, and re-checking would clear the DB after every sync.\n * TODO: replace the reset with a migration path once there is real user data at stake.\n *\n * @returns true if item data was cleared\n */\nexport const resetAmbiguousLegacyItemData = async (): Promise<boolean> => {\n const db = BaseDb.getAppDb()\n if (!db) return false\n\n const done = await db.select({ key: appState.key }).from(appState).where(eq(appState.key, LEGACY_ITEM_MODEL_CHECK_KEY)).limit(1)\n if (done.length > 0) return false\n\n const markDone = () =>\n db\n .insert(appState)\n .values({ key: LEGACY_ITEM_MODEL_CHECK_KEY, value: String(Date.now()), createdAt: Date.now(), updatedAt: Date.now() })\n .onConflictDoNothing()\n\n const legacyTypes = (await db\n .selectDistinct({ type: seeds.type })\n .from(seeds)\n .where(and(isNull(seeds.modelFileId), isNotNull(seeds.type)))) as { type: string }[]\n if (legacyTypes.length === 0) {\n await markDone()\n return false\n }\n\n // Which seed types (snake_case model names) map to models in more than one schema\n const linkedModels = (await db\n .select({ modelId: models.id, modelName: models.name, schemaName: schemas.name })\n .from(models)\n .innerJoin(modelSchemas, eq(models.id, modelSchemas.modelId))\n .innerJoin(schemas, eq(modelSchemas.schemaId, schemas.id))) as {\n modelId: number\n modelName: string\n schemaName: string\n }[]\n const byType = new Map<string, { modelIds: Set<number>; schemaNames: Set<string> }>()\n for (const row of linkedModels) {\n const type = easName(row.modelName)\n const entry = byType.get(type) ?? { modelIds: new Set(), schemaNames: new Set() }\n entry.modelIds.add(row.modelId)\n entry.schemaNames.add(row.schemaName)\n byType.set(type, entry)\n }\n const ambiguous = legacyTypes\n .map(({ type }) => ({ type, entry: byType.get(type) }))\n .filter(({ entry }) => entry && entry.modelIds.size > 1)\n\n if (ambiguous.length === 0) {\n await markDone()\n return false\n }\n\n const details = ambiguous\n .map(({ type, entry }) => `\"${type}\" (schemas: ${[...entry!.schemaNames].sort().join(', ')})`)\n .join('; ')\n console.warn(\n `[seed-protocol] Clearing local item data: items created before this SDK version don't record ` +\n `which model they belong to, and these model names now exist in more than one schema: ${details}. ` +\n `Schemas and models are kept; published items will be restored by the next EAS sync.`,\n )\n logger(`Clearing item data for ambiguous legacy seed types: ${details}`)\n\n for (const table of [\n htmlEmbeddedImageCoPublish,\n arweaveL1FinalizeJobs,\n uploadProcesses,\n publishProcesses,\n easSyncProcesses,\n metadata,\n versions,\n seeds,\n ]) {\n await db.delete(table)\n }\n await markDone()\n return true\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAmBA,MAAM,MAAM,GAAG,KAAK,CAAC,yCAAyC,CAAC;AAE/D;AACO,MAAM,2BAA2B,GAAG;AAE3C;;;;;;;;;;;;AAYG;AACI,MAAM,4BAA4B,GAAG,YAA6B;AACvE,IAAA,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE;AAC5B,IAAA,IAAI,CAAC,EAAE;AAAE,QAAA,OAAO,KAAK;AAErB,IAAA,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,2BAA2B,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAChI,IAAA,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;AAAE,QAAA,OAAO,KAAK;AAEjC,IAAA,MAAM,QAAQ,GAAG,MACf;SACG,MAAM,CAAC,QAAQ;AACf,SAAA,MAAM,CAAC,EAAE,GAAG,EAAE,2BAA2B,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE;AACpH,SAAA,mBAAmB,EAAE;AAE1B,IAAA,MAAM,WAAW,IAAI,MAAM;SACxB,cAAc,CAAC,EAAE,IAAI,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|
|
2
|
+
import { I as AmbiguousModelError, J as eventEmitter } from './index-C0SetTd1.js';
|
|
3
3
|
|
|
4
4
|
const logger = debug('seedSdk:db:read:resolveModelForSyncedSeed');
|
|
5
5
|
/** Emitted when background work skips a seed whose model name exists in several schemas. */
|
|
@@ -43,4 +43,4 @@ const skipSeedOnAmbiguousModel = async (seed, context, work) => {
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
export { MODEL_AMBIGUOUS_EVENT as M, resolveModelForSyncedSeed as r, skipSeedOnAmbiguousModel as s };
|
|
46
|
-
//# sourceMappingURL=resolveModelForSyncedSeed-
|
|
46
|
+
//# sourceMappingURL=resolveModelForSyncedSeed-C5KXn6ex.js.map
|
package/dist/{resolveModelForSyncedSeed-H-4tmU6l.js.map → resolveModelForSyncedSeed-C5KXn6ex.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveModelForSyncedSeed-
|
|
1
|
+
{"version":3,"file":"resolveModelForSyncedSeed-C5KXn6ex.js","sources":["../../src/db/read/resolveModelForSyncedSeed.ts"],"sourcesContent":["import debug from 'debug'\nimport { eventEmitter } from '@/eventBus'\nimport { AmbiguousModelError } from '@/Model/errors'\n\nconst logger = debug('seedSdk:db:read:resolveModelForSyncedSeed')\n\n/** Emitted when background work skips a seed whose model name exists in several schemas. */\nexport const MODEL_AMBIGUOUS_EVENT = 'model:ambiguous' as const\n\nexport type ModelAmbiguousEventPayload = {\n modelName: string\n schemaNames: string[]\n seedLocalId?: string\n seedUid?: string\n /** What was being done when the seed was skipped (e.g. 'easSync.metadata'). */\n context: string\n}\n\nexport type SyncedSeedInfo = {\n seedUid?: string | null\n seedLocalId?: string | null\n /** seeds.type as synced from EAS (the EAS schema name, i.e. snake_case model name). */\n modelType?: string | null\n /** EAS schema UID of the seed attestation. */\n schemaUid?: string | null\n}\n\n/**\n * Seam for matching an EAS-synced seed to a local model (its schemaFileId).\n *\n * EAS identifies a seed's model only by name (`bytes32 <model_name>`), so when several local schemas\n * define a model with that name the seed alone can't say which one it is. The original plan was to\n * match by the seed's properties and metadata; docs/adr/0006-schema-scoped-seeds.md replaced it.\n *\n * TODO(eas-synced-seed-model-resolution): not implemented yet. Returns undefined, so callers fall\n * back to the name, which throws AmbiguousModelError when the name is ambiguous.\n */\nexport const resolveModelForSyncedSeed = async (_seed: SyncedSeedInfo): Promise<string | undefined> => {\n return undefined\n}\n\n/**\n * Run background work for one seed; if it hits an ambiguous model name, log, emit\n * MODEL_AMBIGUOUS_EVENT and return undefined (skip) instead of failing the whole job. Loading the\n * item directly still throws, so the problem surfaces where the app touches it.\n */\nexport const skipSeedOnAmbiguousModel = async <T>(\n seed: { seedLocalId?: string | null; seedUid?: string | null },\n context: string,\n work: () => Promise<T>,\n): Promise<T | undefined> => {\n try {\n return await work()\n } catch (error) {\n if (!(error instanceof AmbiguousModelError)) throw error\n logger(`Skipping seed ${seed.seedLocalId ?? seed.seedUid} in ${context}: ${error.message}`)\n const payload: ModelAmbiguousEventPayload = {\n modelName: error.modelName,\n schemaNames: error.schemaNames,\n seedLocalId: seed.seedLocalId ?? undefined,\n seedUid: seed.seedUid ?? undefined,\n context,\n }\n eventEmitter.emit(MODEL_AMBIGUOUS_EVENT, payload)\n return undefined\n }\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,MAAM,GAAG,KAAK,CAAC,2CAA2C,CAAC;AAEjE;AACO,MAAM,qBAAqB,GAAG;AAoBrC;;;;;;;;;AASG;MACU,yBAAyB,GAAG,OAAO,KAAqB,KAAiC;AACpG,IAAA,OAAO,SAAS;AAClB;AAEA;;;;AAIG;AACI,MAAM,wBAAwB,GAAG,OACtC,IAA8D,EAC9D,OAAe,EACf,IAAsB,KACI;AAC1B,IAAA,IAAI;QACF,OAAO,MAAM,IAAI,EAAE;IACrB;IAAE,OAAO,KAAK,EAAE;AACd,QAAA,IAAI,EAAE,KAAK,YAAY,mBAAmB,CAAC;AAAE,YAAA,MAAM,KAAK;AACxD,QAAA,MAAM,CAAC,CAAA,cAAA,EAAiB,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,OAAO,CAAA,IAAA,EAAO,OAAO,CAAA,EAAA,EAAK,KAAK,CAAC,OAAO,CAAA,CAAE,CAAC;AAC3F,QAAA,MAAM,OAAO,GAA+B;YAC1C,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,WAAW,EAAE,KAAK,CAAC,WAAW;AAC9B,YAAA,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,SAAS;AAC1C,YAAA,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,SAAS;YAClC,OAAO;SACR;AACD,QAAA,YAAY,CAAC,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC;AACjD,QAAA,OAAO,SAAS;IAClB;AACF;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { index, int, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
import { InferSelectModel } from 'drizzle-orm'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The entity change log (ADR 0020): one row per row written to `seeds`, `versions` or `metadata`,
|
|
6
|
+
* inserted by triggers (migration 0023), so it commits or rolls back with the write. The browser's
|
|
7
|
+
* change feed reads it to tell loaded Items and ItemProperties which seeds changed. Nothing else
|
|
8
|
+
* writes it; the leader tab prunes rows older than 10 minutes.
|
|
9
|
+
*/
|
|
10
|
+
export const entityChanges = sqliteTable(
|
|
11
|
+
'entity_changes',
|
|
12
|
+
{
|
|
13
|
+
seq: int('seq').primaryKey({ autoIncrement: true }),
|
|
14
|
+
/** `seeds` | `versions` | `metadata` */
|
|
15
|
+
tbl: text('tbl').notNull(),
|
|
16
|
+
seedLocalId: text('seed_local_id'),
|
|
17
|
+
seedUid: text('seed_uid'),
|
|
18
|
+
/** Set for `metadata` rows only. */
|
|
19
|
+
propertyName: text('property_name'),
|
|
20
|
+
/** Unix ms when the trigger ran. */
|
|
21
|
+
at: int('at').notNull(),
|
|
22
|
+
},
|
|
23
|
+
(table) => ({
|
|
24
|
+
at: index('entity_changes_at').on(table.at),
|
|
25
|
+
}),
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
export type EntityChangeType = InferSelectModel<typeof entityChanges>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { int, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
1
|
+
import { index, int, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
2
|
import { InferSelectModel } from 'drizzle-orm'
|
|
3
3
|
import { properties } from './ModelSchema'
|
|
4
4
|
|
|
@@ -24,8 +24,13 @@ export const metadata = sqliteTable('metadata', {
|
|
|
24
24
|
attestationRaw: text('attestation_raw'),
|
|
25
25
|
attestationCreatedAt: int('attestation_created_at'),
|
|
26
26
|
contentHash: text('content_hash'),
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
// Set on insert when the writer leaves it out. No $onUpdate: readers rank rows by
|
|
28
|
+
// COALESCE(attestation_created_at, created_at), and some writers move it on purpose.
|
|
29
|
+
createdAt: int('created_at').$defaultFn(() => Date.now()),
|
|
30
|
+
// Set on every insert and update unless the writer passes a value.
|
|
31
|
+
updatedAt: int('updated_at')
|
|
32
|
+
.$defaultFn(() => Date.now())
|
|
33
|
+
.$onUpdate(() => Date.now()),
|
|
29
34
|
publisher: text('publisher'),
|
|
30
35
|
// Unix seconds when this row's attestation was revoked on EAS; null while it's live (or for a
|
|
31
36
|
// local, unpublished row). EAS sync keeps only the canonical attestation per (version, property
|
|
@@ -36,6 +41,9 @@ export const metadata = sqliteTable('metadata', {
|
|
|
36
41
|
// attestation (uid null, ref_value_type 'file', value = the transaction id): that attestation's
|
|
37
42
|
// uid. Null for every other row. Marks the row as published content, not a local draft.
|
|
38
43
|
derivedFromUid: text('derived_from_uid'),
|
|
39
|
-
})
|
|
44
|
+
}, (table) => [
|
|
45
|
+
index('metadata_seed_local_id_property_name_idx').on(table.seedLocalId, table.propertyName),
|
|
46
|
+
index('metadata_seed_uid_idx').on(table.seedUid),
|
|
47
|
+
])
|
|
40
48
|
|
|
41
49
|
export type MetadataType = InferSelectModel<typeof metadata>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InferSelectModel } from 'drizzle-orm'
|
|
2
|
-
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
import { index, int, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
3
3
|
|
|
4
4
|
export const seeds = sqliteTable(
|
|
5
5
|
'seeds',
|
|
@@ -14,11 +14,17 @@ export const seeds = sqliteTable(
|
|
|
14
14
|
publisher: text('publisher'),
|
|
15
15
|
attestationRaw: text('attestation_raw'),
|
|
16
16
|
attestationCreatedAt: int('attestation_created_at'),
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// Set on insert when the writer leaves it out. No $onUpdate: readers rank rows by
|
|
18
|
+
// COALESCE(attestation_created_at, created_at), and some writers move it on purpose.
|
|
19
|
+
createdAt: int('created_at').$defaultFn(() => Date.now()),
|
|
20
|
+
// Set on every insert and update unless the writer passes a value.
|
|
21
|
+
updatedAt: int('updated_at')
|
|
22
|
+
.$defaultFn(() => Date.now())
|
|
23
|
+
.$onUpdate(() => Date.now()),
|
|
19
24
|
_markedForDeletion: int('_marked_for_deletion'),
|
|
20
25
|
revokedAt: int('revoked_at'),
|
|
21
26
|
},
|
|
27
|
+
(table) => [index('seeds_uid_idx').on(table.uid), index('seeds_type_idx').on(table.type)],
|
|
22
28
|
// {
|
|
23
29
|
// triggers: [
|
|
24
30
|
// sql<string>`CREATE TRIGGER IF NOT EXISTS seeds_created_at_trigger
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
1
|
+
import { index, int, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
2
|
import { InferSelectModel } from 'drizzle-orm'
|
|
3
3
|
|
|
4
4
|
export const versions = sqliteTable('versions', {
|
|
@@ -8,8 +8,13 @@ export const versions = sqliteTable('versions', {
|
|
|
8
8
|
seedUid: text('seed_uid'),
|
|
9
9
|
seedType: text('seed_type'),
|
|
10
10
|
note: text('note'),
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
// Set on insert when the writer leaves it out. No $onUpdate: readers rank rows by
|
|
12
|
+
// COALESCE(attestation_created_at, created_at), and some writers move it on purpose.
|
|
13
|
+
createdAt: int('created_at').$defaultFn(() => Date.now()),
|
|
14
|
+
// Set on every insert and update unless the writer passes a value.
|
|
15
|
+
updatedAt: int('updated_at')
|
|
16
|
+
.$defaultFn(() => Date.now())
|
|
17
|
+
.$onUpdate(() => Date.now()),
|
|
13
18
|
attestationCreatedAt: int('attestation_created_at'),
|
|
14
19
|
attestationRaw: text('attestation_raw'),
|
|
15
20
|
publisher: text('publisher'),
|
|
@@ -18,6 +23,6 @@ export const versions = sqliteTable('versions', {
|
|
|
18
23
|
* unpublish time until sync confirms it). Null while live or unpublished.
|
|
19
24
|
*/
|
|
20
25
|
revokedAt: int('revoked_at'),
|
|
21
|
-
})
|
|
26
|
+
}, (table) => [index('versions_seed_local_id_idx').on(table.seedLocalId)])
|
|
22
27
|
|
|
23
28
|
export type VersionsType = InferSelectModel<typeof versions>
|
package/dist/seedSchema/index.ts
CHANGED
package/dist/src/Item/Item.d.ts
CHANGED
|
@@ -102,9 +102,10 @@ export declare class Item<T extends ModelValues<ModelSchema>> implements IItem<T
|
|
|
102
102
|
* The ID can be either seedUid or seedLocalId
|
|
103
103
|
* @param id - seedUid or seedLocalId
|
|
104
104
|
* @param modelName - Optional model name for querying
|
|
105
|
+
* @param idKind - 'localId' when the id was given as a seedLocalId: looked up as one first
|
|
105
106
|
* @returns Item instance or undefined if not found
|
|
106
107
|
*/
|
|
107
|
-
static createById(id: string, modelName?: string): Promise<Item<any> | undefined>;
|
|
108
|
+
static createById(id: string, modelName?: string, idKind?: 'localId'): Promise<Item<any> | undefined>;
|
|
108
109
|
static find({ modelName, seedLocalId, seedUid, waitForReady, readyTimeout, }: ItemFindProps & {
|
|
109
110
|
waitForReady?: boolean;
|
|
110
111
|
readyTimeout?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../src/Item/Item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAYpE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAI3C,OAAO,EACL,2BAA2B,EAC3B,QAAQ,EACR,aAAa,EACb,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACb,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAA;AACtC,OAAO,EACL,YAAY,EACZ,YAAY,EAKb,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../src/Item/Item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAYpE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAI3C,OAAO,EACL,2BAA2B,EAC3B,QAAQ,EACR,aAAa,EACb,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACb,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAA;AACtC,OAAO,EACL,YAAY,EAC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AAE,GAAG,OAAO;IAqB3E;;;OAGG;IACH,IAAI,UAAU,IAAI,aAAa,EAAE,CA4BhC;IAED;;;OAGG;IACH,IAAI,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAOtD;IAED;;;OAGG;IACH,IAAI,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAEjD;IAED,IAAI,oBAAoB,IAAI,MAAM,CAEjC;IAED,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,IAAI,sBAAsB,IAAI,MAAM,CAEnC;IAED,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAWlC;IAED;;;OAGG;IACH,OAAO,CAAC,2BAA2B;IAwYnC;;;OAGG;IACH,MAAM,IAAI,IAAI;IA8Bd;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAmC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadOrCreateItem.d.ts","sourceRoot":"","sources":["../../../../../src/Item/service/actors/loadOrCreateItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"loadOrCreateItem.d.ts","sourceRoot":"","sources":["../../../../../src/Item/service/actors/loadOrCreateItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AA2TjD,eAAO,MAAM,gBAAgB,2GA+N3B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemProperty.d.ts","sourceRoot":"","sources":["../../../src/ItemProperty/ItemProperty.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{"version":3,"file":"loadOrCreateProperty.d.ts","sourceRoot":"","sources":["../../../../../src/ItemProperty/service/actors/loadOrCreateProperty.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AA2BzD,eAAO,MAAM,oBAAoB,0GAsX/B,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BaseDb } from '../../../db/Db/BaseDb';
|
|
2
|
+
type Db = NonNullable<ReturnType<typeof BaseDb.getAppDb>>;
|
|
3
|
+
export type PropertyRecordSchema = {
|
|
4
|
+
id: number;
|
|
5
|
+
dataType: string;
|
|
6
|
+
ref?: string;
|
|
7
|
+
refValueType?: string;
|
|
8
|
+
storageType?: string;
|
|
9
|
+
localStorageDir?: string;
|
|
10
|
+
filenameSuffix?: string;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
validation?: unknown;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Every property's record schema for one model, read from the database (properties table, ref
|
|
16
|
+
* model names, validation rules from the schema), keyed by property name. Empty when the model has
|
|
17
|
+
* no row. Rejects when the model can't be resolved (e.g. an ambiguous name).
|
|
18
|
+
*/
|
|
19
|
+
export declare function loadModelPropertyRecordSchemas(modelName: string, modelFileId: string | undefined, db: Db): Promise<Map<string, PropertyRecordSchema>>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=modelPropertyRecordSchemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelPropertyRecordSchemas.d.ts","sourceRoot":"","sources":["../../../../../src/ItemProperty/service/actors/modelPropertyRecordSchemas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAM5C,KAAK,EAAE,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEzD,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AASD;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,EAAE,EAAE,EAAE,GACL,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAW5C"}
|
|
@@ -9,6 +9,8 @@ export declare class BrowserDb implements IDb {
|
|
|
9
9
|
dbId: string | undefined;
|
|
10
10
|
appDb: SqliteRemoteDatabase<Record<string, unknown>> | undefined;
|
|
11
11
|
sqlocalInstance: SQLocalDrizzle | undefined;
|
|
12
|
+
/** Live queries by SQL + params while they have subscribers; see liveQuery. */
|
|
13
|
+
private sharedLiveQueries;
|
|
12
14
|
getAppDb(): SqliteRemoteDatabase<Record<string, unknown>> | undefined;
|
|
13
15
|
isAppDbReady(): boolean;
|
|
14
16
|
prepareDb(filesDir: string): Promise<SqliteRemoteDatabase<Record<string, unknown>> | undefined>;
|
|
@@ -56,6 +58,4 @@ export declare class BrowserDb implements IDb {
|
|
|
56
58
|
*/
|
|
57
59
|
liveQuery<T>(query: ((sql: any) => any) | any): Observable<T[]>;
|
|
58
60
|
}
|
|
59
|
-
/** @deprecated Prefer BrowserDb */
|
|
60
|
-
export declare const Db: typeof BrowserDb;
|
|
61
61
|
//# sourceMappingURL=Db.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Db.d.ts","sourceRoot":"","sources":["../../../../src/browser/db/Db.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Db.d.ts","sourceRoot":"","sources":["../../../../src/browser/db/Db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEvC,OAAO,EAAW,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AASzE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAMhD,OAAO,EAAE,UAAU,EAAoE,MAAM,MAAM,CAAA;AAInG,qBAAa,SAAU,YAAW,GAAG;IAEnC,gBAAgB,EAAE,GAAG,CAAA;IACrB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,KAAK,EAAE,oBAAoB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAA;IAChE,eAAe,EAAE,cAAc,GAAG,SAAS,CAAA;IAC3C,+EAA+E;IAC/E,OAAO,CAAC,iBAAiB,CAA2C;IAGpE,QAAQ;IAIR,YAAY;IAIN,SAAS,CAAC,QAAQ,EAAE,MAAM;YAWlB,eAAe;IA+KvB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAO5D,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmEvD,wEAAwE;YAC1D,aAAa;IAiB3B,+GAA+G;YACjG,mBAAmB;IAoBjC;;;;;OAKG;IACG,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,oBAAoB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAkBjG,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQjF;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,SAAS,CAAC,CAAC,EACT,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC,GAAG,GAAG,GAC/B,UAAU,CAAC,CAAC,EAAE,CAAC;CAwEnB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Observable } from 'rxjs';
|
|
2
|
+
import type { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy';
|
|
3
|
+
/**
|
|
4
|
+
* One feed per tab over the entity_changes log (ADR 0020). A single reactive query watches
|
|
5
|
+
* `max(seq)`; when it rises, the feed reads the new log rows and calls the listeners registered
|
|
6
|
+
* for each changed row's seed. Loaded Items and ItemProperties register here instead of holding a
|
|
7
|
+
* liveQuery each, so a write re-runs the reads of the entities it touched, not of every loaded one.
|
|
8
|
+
*
|
|
9
|
+
* Other tabs' writes arrive the same way: SQLocal's effects broadcast re-runs this tab's
|
|
10
|
+
* `max(seq)` query.
|
|
11
|
+
*/
|
|
12
|
+
export type EntityChangeTable = 'seeds' | 'versions' | 'metadata';
|
|
13
|
+
export type ChangeWatch = {
|
|
14
|
+
seedLocalId?: string | null;
|
|
15
|
+
seedUid?: string | null;
|
|
16
|
+
tables: EntityChangeTable[];
|
|
17
|
+
/** Metadata rows count only for these property names; every metadata row counts when omitted. */
|
|
18
|
+
propertyNames?: string[];
|
|
19
|
+
};
|
|
20
|
+
/** Log rows older than this are pruned by the leader tab. */
|
|
21
|
+
export declare const ENTITY_CHANGES_RETENTION_MS: number;
|
|
22
|
+
/** The leader prunes at most this often. */
|
|
23
|
+
export declare const ENTITY_CHANGES_PRUNE_EVERY_MS = 60000;
|
|
24
|
+
type FeedDb = SqliteRemoteDatabase<Record<string, unknown>>;
|
|
25
|
+
type LiveQuery = <T>(query: (sql: any) => any) => Observable<T[]>;
|
|
26
|
+
/** SQLocal's `sql` template tag: runs the statement and resolves to its rows. */
|
|
27
|
+
type SqlTag = (strings: TemplateStringsArray, ...params: unknown[]) => Promise<Record<string, unknown>[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Calls `listener` after a committed write to one of `watch.tables` for the watched seed, matched
|
|
30
|
+
* by local id or (case-insensitively) by uid. A read of the log that has several matching rows
|
|
31
|
+
* calls it once. When the tab missed rows (its cursor is older than the oldest kept row), every
|
|
32
|
+
* listener is called once. Returns the unregister function.
|
|
33
|
+
*/
|
|
34
|
+
export declare function watchEntityChanges(watch: ChangeWatch, listener: () => void): () => void;
|
|
35
|
+
/**
|
|
36
|
+
* Watches `watch` and runs `read` once per dispatch, handing its result to `onRows` when it differs
|
|
37
|
+
* from the last one handed over. A read that finishes after a newer one started is dropped, so an
|
|
38
|
+
* older result never replaces a newer one.
|
|
39
|
+
*
|
|
40
|
+
* Pass `since` (the `changeFeedCursor()` taken before the caller's own initial read) to run `read`
|
|
41
|
+
* once right away when the feed moved on in between: a change dispatched before this watch was
|
|
42
|
+
* registered would otherwise be missed. Pass `immediate` to run it once right away regardless, as
|
|
43
|
+
* a liveQuery's first emission does.
|
|
44
|
+
*/
|
|
45
|
+
export declare function watchEntityRows<T>(watch: ChangeWatch, read: () => Promise<T>, onRows: (rows: T) => void, options?: {
|
|
46
|
+
since?: number;
|
|
47
|
+
immediate?: boolean;
|
|
48
|
+
onError?: (error: unknown) => void;
|
|
49
|
+
}): {
|
|
50
|
+
unsubscribe: () => void;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Runs an SQL-tag query once, the way BaseDb.liveQuery's query function is written
|
|
54
|
+
* (`(sql) => sql\`SELECT ...\``), so an entity can keep its liveQuery's text for its feed reads.
|
|
55
|
+
*/
|
|
56
|
+
export declare function queryEntityRows<T>(query: (sql: any) => any): Promise<T[]>;
|
|
57
|
+
/** Whether this tab's feed runs (a browser database is open); Node has none. */
|
|
58
|
+
export declare function isChangeFeedRunning(): boolean;
|
|
59
|
+
/** The seq of the newest log row this tab has dispatched. */
|
|
60
|
+
export declare function changeFeedCursor(): number;
|
|
61
|
+
/** Registered watches, for tests. */
|
|
62
|
+
export declare function activeChangeWatches(): ChangeWatch[];
|
|
63
|
+
/** Deletes log rows older than ENTITY_CHANGES_RETENTION_MS. Deleting doesn't raise max(seq), so it dispatches nothing. */
|
|
64
|
+
export declare function pruneEntityChanges(db: FeedDb, now?: number): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Starts this tab's feed on `db` (once its migrations ran), at the newest seq allocated so far:
|
|
67
|
+
* entities do their own initial read. A second call replaces the first feed.
|
|
68
|
+
*/
|
|
69
|
+
export declare function startChangeFeed(db: FeedDb, { liveQuery, sql: sqlTag }: {
|
|
70
|
+
liveQuery: LiveQuery;
|
|
71
|
+
sql: SqlTag;
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
export declare function stopChangeFeed(): void;
|
|
74
|
+
/** Tests only: drops every watch and the prune clock. */
|
|
75
|
+
export declare function resetChangeFeedForTests(): void;
|
|
76
|
+
export {};
|
|
77
|
+
//# sourceMappingURL=changeFeed.d.ts.map
|