@seedprotocol/sdk 0.7.10 → 0.7.11-next.1396.g883ef47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{BaseFileManager-DLou1TZS.js → BaseFileManager-D-pLXQAp.js} +2 -14
- package/dist/BaseFileManager-D-pLXQAp.js.map +1 -0
- package/dist/{Item-oPnmIehk.js → Item-BU9wIT7l.js} +2053 -412
- package/dist/Item-BU9wIT7l.js.map +1 -0
- package/dist/{ModelProperty-D2vJozmW.js → ModelProperty-Bv7KzP97.js} +40 -38
- package/dist/ModelProperty-Bv7KzP97.js.map +1 -0
- package/dist/{Schema-BMXRF4j9.js → Schema-C_4wv0RP.js} +22 -22
- package/dist/{Schema-BMXRF4j9.js.map → Schema-C_4wv0RP.js.map} +1 -1
- package/dist/{SchemaValidationService-CieGrj5c.js → SchemaValidationService-Dc-lpFQX.js} +9 -7
- package/dist/{SchemaValidationService-CieGrj5c.js.map → SchemaValidationService-Dc-lpFQX.js.map} +1 -1
- package/dist/arweaveContentTags-iW_HcWJA.js +1456 -0
- package/dist/arweaveContentTags-iW_HcWJA.js.map +1 -0
- package/dist/{configurePlatform-WkmvqeTO.js → configurePlatform-BH1YOZpg.js} +2 -2
- package/dist/{configurePlatform-WkmvqeTO.js.map → configurePlatform-BH1YOZpg.js.map} +1 -1
- package/dist/db/drizzle/0030_drop_property_uids.sql +1 -0
- package/dist/db/drizzle/meta/0030_snapshot.json +1638 -0
- package/dist/db/drizzle/meta/_journal.json +8 -1
- package/dist/{detachRowsBeforeDelete-BZr_0iZU.js → detachRowsBeforeDelete-Cie55SoG.js} +4 -6
- package/dist/detachRowsBeforeDelete-Cie55SoG.js.map +1 -0
- package/dist/dist/{BaseFileManager-DLou1TZS.d.ts → BaseFileManager-D-pLXQAp.d.ts} +432 -495
- package/dist/dist/BaseFileManager-D-pLXQAp.d.ts.map +1 -0
- package/dist/dist/{configurePlatform-WkmvqeTO.d.ts → configurePlatform-BH1YOZpg.d.ts} +1 -1
- package/dist/dist/configurePlatform-BH1YOZpg.d.ts.map +1 -0
- package/dist/dist/{index-BjWk0x4-.d.ts → index-2PaIhvOU.d.ts} +1 -64
- package/dist/dist/{index-BjWk0x4-.d.ts.map → index-2PaIhvOU.d.ts.map} +1 -1
- package/dist/dist/{index.node-BfiBriEq.d.ts → index.node-C3rI1upv.d.ts} +25 -281
- package/dist/dist/{index.node-BfiBriEq.d.ts.map → index.node-C3rI1upv.d.ts.map} +1 -1
- package/dist/dist/minimumUpgradeVersion-Dg2MguFf.d.ts +20 -0
- package/dist/dist/minimumUpgradeVersion-Dg2MguFf.d.ts.map +1 -0
- package/dist/dist/platform.node.d.ts +2 -2
- package/dist/download-DHWUPLlK.js +393 -0
- package/dist/download-DHWUPLlK.js.map +1 -0
- package/dist/{eas-FZPPqxqe.js → eas-MXEdKKVc.js} +12 -10
- package/dist/{eas-FZPPqxqe.js.map → eas-MXEdKKVc.js.map} +1 -1
- package/dist/ensureImageLocal-B6suz6FC.js +175 -0
- package/dist/ensureImageLocal-B6suz6FC.js.map +1 -0
- package/dist/{getPublishPayload-DKuEaq96.js → getPublishPayload-Dd3HCYeI.js} +8 -49
- package/dist/getPublishPayload-Dd3HCYeI.js.map +1 -0
- package/dist/{getPublishPendingDiff-CH5xLMjU.js → getPublishPendingDiff-kcTP52Kj.js} +13 -12
- package/dist/{getPublishPendingDiff-CH5xLMjU.js.map → getPublishPendingDiff-kcTP52Kj.js.map} +1 -1
- package/dist/{index-BjWk0x4-.js → index-2PaIhvOU.js} +2 -4
- package/dist/index-2PaIhvOU.js.map +1 -0
- package/dist/index-BXTyvnKb.js +28 -0
- package/dist/index-BXTyvnKb.js.map +1 -0
- package/dist/{index-DXRhFg1N.js → index-CmNqUKQN.js} +10 -8
- package/dist/index-CmNqUKQN.js.map +1 -0
- package/dist/{index-Gh42_47r.js → index-Xs_EDi-_.js} +18 -401
- package/dist/index-Xs_EDi-_.js.map +1 -0
- package/dist/{index.browser-DQstVvRV.js → index.browser-BkcOQGhw.js} +59 -102
- package/dist/index.browser-BkcOQGhw.js.map +1 -0
- package/dist/{index.node-BfiBriEq.js → index.node-C3rI1upv.js} +14 -36
- package/dist/index.node-C3rI1upv.js.map +1 -0
- package/dist/main.js +19 -19
- package/dist/{minimumUpgradeVersion-BDhHvHtr.js → minimumUpgradeVersion-Dg2MguFf.js} +38 -9
- package/dist/minimumUpgradeVersion-Dg2MguFf.js.map +1 -0
- package/dist/{modelPropertyRecordSchemas-DEe-lYhn.js → modelPropertyRecordSchemas-CEac3FB8.js} +10 -10
- package/dist/{modelPropertyRecordSchemas-DEe-lYhn.js.map → modelPropertyRecordSchemas-CEac3FB8.js.map} +1 -1
- package/dist/node.js +14 -12
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +10 -12
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.node.js +5 -5
- package/dist/{property-iNW1N3vm.js → property-4jSqHieb.js} +9 -9
- package/dist/{property-iNW1N3vm.js.map → property-4jSqHieb.js.map} +1 -1
- package/dist/{errors-CnT0fSMK.js → publishErrors-DZXDX3B6.js} +1830 -245
- package/dist/publishErrors-DZXDX3B6.js.map +1 -0
- package/dist/{readHtmlBodyForStorageSeed-B7HgPmq6.js → readHtmlBodyForStorageSeed-Cva1DPzE.js} +10 -12
- package/dist/{readHtmlBodyForStorageSeed-B7HgPmq6.js.map → readHtmlBodyForStorageSeed-Cva1DPzE.js.map} +1 -1
- package/dist/seedSchema/index.ts +0 -1
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts +1 -0
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/initialize.d.ts.map +1 -1
- package/dist/src/Model/index.d.ts +0 -2
- package/dist/src/Model/index.d.ts.map +1 -1
- package/dist/src/browser/db/Db.d.ts.map +1 -1
- package/dist/src/browser/db/drizzleFiles.d.ts +3 -2
- package/dist/src/browser/db/drizzleFiles.d.ts.map +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts +1 -3
- package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/browser/workers/FileDownloader.d.ts +1 -0
- package/dist/src/browser/workers/FileDownloader.d.ts.map +1 -1
- package/dist/src/browser/workers/ImageResizer.d.ts +1 -0
- package/dist/src/browser/workers/ImageResizer.d.ts.map +1 -1
- package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
- package/dist/src/client/actors/saveAppState.d.ts.map +1 -1
- package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/src/db/minimumUpgradeVersion.d.ts +20 -5
- package/dist/src/db/minimumUpgradeVersion.d.ts.map +1 -1
- package/dist/src/db/read/metadataProperty.d.ts +1 -1
- package/dist/src/db/read/metadataProperty.d.ts.map +1 -1
- package/dist/src/db/read/resolveModelRecord.d.ts +0 -20
- package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -1
- package/dist/src/db/write/createMetadata.d.ts +1 -8
- package/dist/src/db/write/createMetadata.d.ts.map +1 -1
- package/dist/src/db/write/removeLocalCopiesForAddresses.d.ts +0 -5
- package/dist/src/db/write/removeLocalCopiesForAddresses.d.ts.map +1 -1
- package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
- package/dist/src/events/files/download.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/helpers/easPropertyCanonical.d.ts +1 -1
- package/dist/src/helpers/easPropertyCanonical.d.ts.map +1 -1
- package/dist/src/helpers/entity/detachRowsBeforeDelete.d.ts +2 -3
- package/dist/src/helpers/entity/detachRowsBeforeDelete.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityLifecycle.d.ts +0 -2
- package/dist/src/helpers/entity/entityLifecycle.d.ts.map +1 -1
- package/dist/src/helpers/environment.d.ts +0 -13
- package/dist/src/helpers/environment.d.ts.map +1 -1
- package/dist/src/helpers/index.d.ts +0 -4
- package/dist/src/helpers/index.d.ts.map +1 -1
- package/dist/src/helpers/itemStorageFile.d.ts +0 -11
- package/dist/src/helpers/itemStorageFile.d.ts.map +1 -1
- package/dist/src/helpers/propertySchemaUid.d.ts +7 -5
- package/dist/src/helpers/propertySchemaUid.d.ts.map +1 -1
- package/dist/src/helpers/storageDir.d.ts +0 -2
- package/dist/src/helpers/storageDir.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/node/db/Db.d.ts +0 -2
- package/dist/src/node/db/Db.d.ts.map +1 -1
- package/dist/src/node/helpers/FileManager.d.ts +0 -2
- package/dist/src/node/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/node/index.d.ts +11 -3
- package/dist/src/node/index.d.ts.map +1 -1
- package/dist/src/outbox/index.d.ts +5 -5
- package/dist/src/outbox/index.d.ts.map +1 -1
- package/dist/src/seedSchema/index.d.ts +0 -1
- package/dist/src/seedSchema/index.d.ts.map +1 -1
- package/dist/{syncDbWithEas-FuyqoEKk.js → syncDbWithEas-V_9gIyHp.js} +25 -23
- package/dist/syncDbWithEas-V_9gIyHp.js.map +1 -0
- package/dist/{tolerantWebAccess-zEseJ2zT.js → tolerantWebAccess-D6hFxREe.js} +11 -13
- package/dist/{tolerantWebAccess-zEseJ2zT.js.map → tolerantWebAccess-D6hFxREe.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-B9JRwr5T.js → updateSeedRevokedAt-CsAoUEEt.js} +4 -3
- package/dist/{updateSeedRevokedAt-B9JRwr5T.js.map → updateSeedRevokedAt-CsAoUEEt.js.map} +1 -1
- package/package.json +7 -12
- package/dist/BaseFileManager-DLou1TZS.js.map +0 -1
- package/dist/Item-oPnmIehk.js.map +0 -1
- package/dist/ModelProperty-D2vJozmW.js.map +0 -1
- package/dist/detachRowsBeforeDelete-BZr_0iZU.js.map +0 -1
- package/dist/dist/BaseFileManager-DLou1TZS.d.ts.map +0 -1
- package/dist/dist/configurePlatform-WkmvqeTO.d.ts.map +0 -1
- package/dist/dist/minimumUpgradeVersion-BDhHvHtr.d.ts +0 -9
- package/dist/dist/minimumUpgradeVersion-BDhHvHtr.d.ts.map +0 -1
- package/dist/errors-CnT0fSMK.js.map +0 -1
- package/dist/getPublishPayload-DKuEaq96.js.map +0 -1
- package/dist/getPublishUploads-DivYpgNw.js +0 -783
- package/dist/getPublishUploads-DivYpgNw.js.map +0 -1
- package/dist/index-BjWk0x4-.js.map +0 -1
- package/dist/index-CZMWKXLM.js +0 -27
- package/dist/index-CZMWKXLM.js.map +0 -1
- package/dist/index-DXRhFg1N.js.map +0 -1
- package/dist/index-Gh42_47r.js.map +0 -1
- package/dist/index.browser-DQstVvRV.js.map +0 -1
- package/dist/index.node-BfiBriEq.js.map +0 -1
- package/dist/minimumUpgradeVersion-BDhHvHtr.js.map +0 -1
- package/dist/publishGraph-CRn_N3NT.js +0 -311
- package/dist/publishGraph-CRn_N3NT.js.map +0 -1
- package/dist/seedSchema/PropertyUidSchema.ts +0 -16
- package/dist/src/db/read/getItemProperty.d.ts +0 -6
- package/dist/src/db/read/getItemProperty.d.ts.map +0 -1
- package/dist/src/db/read/isSeedRevoked.d.ts +0 -7
- package/dist/src/db/read/isSeedRevoked.d.ts.map +0 -1
- package/dist/src/db/write/saveMetadata.d.ts +0 -3
- package/dist/src/db/write/saveMetadata.d.ts.map +0 -1
- package/dist/src/db/write/updateMetadata.d.ts +0 -13
- package/dist/src/db/write/updateMetadata.d.ts.map +0 -1
- package/dist/src/seedSchema/PropertyUidSchema.d.ts +0 -64
- package/dist/src/seedSchema/PropertyUidSchema.d.ts.map +0 -1
- package/dist/src/types/fileManager.d.ts +0 -13
- package/dist/src/types/fileManager.d.ts.map +0 -1
- package/dist/syncDbWithEas-FuyqoEKk.js.map +0 -1
- package/dist/tabEvents-DT5ez6io.js +0 -3830
- package/dist/tabEvents-DT5ez6io.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.node-BfiBriEq.js","sources":["../../src/node/helpers/FileManager.ts","../../src/node/db/singleConnectionTransactions.ts","../../src/node/db/Db.ts","../../src/node/helpers/dotSeedDir.ts","../../src/helpers/dotSeedPath.ts","../../src/node/helpers/resolveFilesDir.ts","../../src/platform/index.node.ts"],"sourcesContent":["import * as fsAsync from 'fs/promises'\nimport * as fs from 'fs'\nimport { BaseFileManager } from '@/helpers/FileManager/BaseFileManager'\nimport type { IFileManager } from '@/helpers/FileManager/IFileManager'\nimport path from 'path'\nimport { pathToFileURL } from 'url'\n\nexport class NodeFileManager implements IFileManager {\n async getFs() {\n return fs\n }\n\n getFsSync() {\n return fs\n }\n\n /** Node has no blob URLs; a file:// URL keeps refResolvedDisplayValue meaningful for server callers. */\n async getContentUrlFromPath(filePath: string): Promise<string | undefined> {\n return pathToFileURL(path.resolve(filePath)).href\n }\n\n async initializeFileSystem(_workingDir?: string): Promise<void> {\n return // No need to initialize file system in node\n }\n\n async downloadAllFiles(): Promise<void> {\n throw new Error('Not implemented')\n }\n\n async resizeImage(): Promise<void> {\n throw new Error('Not implemented')\n }\n\n async resizeAllImages(): Promise<void> {\n throw new Error('Not implemented')\n }\n\n async pathExists(filePath: string): Promise<boolean> {\n return await fsAsync.access(filePath).then(() => true).catch(() => false)\n }\n\n /** Node reads the real file system; nothing is cached. */\n async invalidateCachedPaths(): Promise<void> {}\n\n async getFileSize(filePath: string): Promise<number | null> {\n try {\n const stat = await fsAsync.stat(filePath)\n return stat.size\n } catch {\n return null\n }\n }\n\n async listImageFiles(): Promise<string[]> {\n return this.listFiles('images')\n }\n\n async listFiles(dir: string): Promise<string[]> {\n const targetDir = BaseFileManager.getFilesPath(dir)\n const exists = await this.pathExists(targetDir)\n if (!exists) {\n return []\n }\n const entries = await fsAsync.readdir(targetDir, { withFileTypes: true })\n return entries.filter((entry) => entry.isFile()).map((entry) => entry.name)\n }\n\n async createDirIfNotExists(filePath: string): Promise<void> {\n await fsAsync.mkdir(filePath, { recursive: true })\n }\n\n async waitForFile(filePath: string, interval: number = 1000, timeout: number = 60000): Promise<boolean> {\n const pathExists = await this.pathExists(filePath)\n if (pathExists) {\n return true\n }\n\n return new Promise((resolve, reject) => {\n const startTime = Date.now()\n let isBusy = false\n\n const checkInterval = setInterval(async () => {\n if (isBusy) {\n return\n }\n isBusy = true\n\n try {\n const exists = await this.pathExists(filePath)\n if (exists) {\n clearInterval(checkInterval)\n resolve(true)\n return\n }\n\n if (Date.now() - startTime >= timeout) {\n clearInterval(checkInterval)\n reject(new Error('Timeout exceeded while waiting for file'))\n return\n }\n } catch (error) {\n clearInterval(checkInterval)\n reject(error)\n return\n } finally {\n isBusy = false\n }\n }, interval)\n })\n }\n\n async waitForFileWithContent(filePath: string, interval: number = 100, timeout: number = 5000): Promise<boolean> {\n return this.waitForFile(filePath, interval, timeout)\n }\n\n async saveFile(filePath: string, content: string | Blob | ArrayBuffer): Promise<void> {\n const dir = path.dirname(filePath)\n await fsAsync.mkdir(dir, { recursive: true })\n\n if (typeof content === 'string') {\n await fsAsync.writeFile(filePath, content, 'utf-8')\n } else if (content instanceof Blob) {\n const arrayBuffer = await content.arrayBuffer()\n await fsAsync.writeFile(filePath, new Uint8Array(arrayBuffer))\n } else if (content instanceof ArrayBuffer) {\n await fsAsync.writeFile(filePath, new Uint8Array(content))\n } else {\n throw new Error('Unsupported content type')\n }\n }\n\n saveFileSync(filePath: string, content: string | Blob | ArrayBuffer): void {\n const dir = path.dirname(filePath)\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true })\n }\n\n if (typeof content === 'string') {\n fs.writeFileSync(filePath, content, 'utf-8')\n } else if (content instanceof Blob) {\n throw new Error('Blob content not supported in saveFileSync. Use saveFile() instead or convert to ArrayBuffer first.')\n } else if (content instanceof ArrayBuffer) {\n fs.writeFileSync(filePath, new Uint8Array(content))\n } else {\n throw new Error('Unsupported content type')\n }\n }\n\n async readFileAsBuffer(filePath: string): Promise<Buffer> {\n return await fsAsync.readFile(filePath)\n }\n\n async readFileAsString(filePath: string): Promise<string> {\n return await fsAsync.readFile(filePath, 'utf-8')\n }\n\n async readFile(filePath: string): Promise<File> {\n return new File([await fsAsync.readFile(filePath)], filePath)\n }\n\n readFileSync(filePath: string): File {\n return new File([fs.readFileSync(filePath)], filePath)\n }\n\n getParentDirPath(filePath: string): string {\n return path.dirname(filePath)\n }\n\n getFilenameFromPath(filePath: string): string {\n return path.basename(filePath)\n }\n\n getPathModule(): any {\n return path\n }\n}\n\n/** @deprecated Prefer NodeFileManager */\nexport const FileManager = NodeFileManager\n\nBaseFileManager.configure(new NodeFileManager())\n\nconst _check: IFileManager = new NodeFileManager()\nvoid _check\n","import type { Client } from '@libsql/client'\nimport { drizzle } from 'drizzle-orm/libsql'\nimport { isSqliteBusyError, SQLITE_BUSY_RETRY_DELAYS_MS } from '@/browser/db/sqliteBusyRetry'\n\n/**\n * Transactions on libsql's one connection, with the browser's semantics (ADR 0019).\n *\n * libsql's own `transaction()` hands the transaction the client's connection and opens a new one\n * for everything after, so a process ends up with several connections that lock each other out\n * (SQLITE_BUSY) and, in tests, lost an outbox op's committed insert. Here every statement uses the\n * client's single connection instead:\n *\n * - `transaction(fn)` runs one transaction at a time: BEGIN IMMEDIATE, `fn` on a Drizzle database\n * whose statements go straight to the connection, then COMMIT, or ROLLBACK when `fn` throws.\n * - Statements on the app database (the patched client) wait while a transaction is open, as\n * SQLocal makes them wait in the browser. So `fn` must not use the app database: it would wait\n * for its own transaction.\n * - Statements outside a transaction keep the busy retry: another process may hold the file.\n *\n * libsql 0.5 doesn't reset a statement that failed with SQLITE_BUSY, and that leaves its\n * connection in an implicit transaction that never commits: every later write on it is lost when it\n * closes and never reaches the file (`inTransaction` still reads false). So after a busy error the\n * connection is replaced (`reconnect()`) before anything else runs on it, and a transaction waits\n * for statements that are between attempts.\n */\nexport function createSingleConnectionTransactions(client: Client, schema: Record<string, unknown>) {\n const execute = client.execute.bind(client)\n const batch = client.batch.bind(client)\n\n /** Resolves when the open transaction ends; undefined when none is open. */\n let open: Promise<void> | undefined\n /** The transactions waiting their turn, chained. */\n let queue: Promise<void> = Promise.resolve()\n\n const outsideTransactions = async () => {\n while (open) await open\n }\n\n /** Statements outside transactions that are running or replacing a busy connection. */\n let statementsRunning = 0\n const whenStatementsDone: (() => void)[] = []\n const statementsDone = () =>\n statementsRunning === 0 ? Promise.resolve() : new Promise<void>((resolve) => whenStatementsDone.push(resolve))\n\n const statement = async <T>(run: () => Promise<T>): Promise<T> => {\n for (let attempt = 0; ; attempt++) {\n await outsideTransactions()\n statementsRunning++\n try {\n return await run()\n } catch (error) {\n if (!isSqliteBusyError(error) || attempt >= SQLITE_BUSY_RETRY_DELAYS_MS.length) throw error\n await client.reconnect()\n } finally {\n if (--statementsRunning === 0) for (const resolve of whenStatementsDone.splice(0)) resolve()\n }\n await new Promise((resolve) => setTimeout(resolve, SQLITE_BUSY_RETRY_DELAYS_MS[attempt]))\n }\n }\n\n client.execute = ((...args: Parameters<Client['execute']>) => statement(() => execute(...args))) as Client['execute']\n client.batch = ((...args: Parameters<Client['batch']>) => statement(() => batch(...args))) as Client['batch']\n\n // What Drizzle uses of the client, straight to the connection: the transaction's own statements\n const transactionClient = {\n execute,\n batch,\n protocol: client.protocol,\n get closed() {\n return client.closed\n },\n } as unknown as Client\n const transactionDb = drizzle(transactionClient, { schema })\n\n async function transaction<T>(fn: (tx: typeof transactionDb) => Promise<T>): Promise<T> {\n const previous = queue\n let finished!: () => void\n queue = new Promise<void>((resolve) => (finished = resolve))\n await previous\n let end!: () => void\n open = new Promise<void>((resolve) => (end = resolve))\n try {\n await statementsDone()\n try {\n await execute('BEGIN IMMEDIATE')\n } catch (error) {\n // Busy: BaseDb.transaction retries the whole transaction, on a fresh connection\n if (isSqliteBusyError(error)) await client.reconnect()\n throw error\n }\n try {\n const result = await fn(transactionDb)\n await execute('COMMIT')\n return result\n } catch (error) {\n try {\n await execute('ROLLBACK')\n } catch {\n // Already rolled back (SQLite does on some errors)\n }\n if (isSqliteBusyError(error)) await client.reconnect()\n throw error\n }\n } finally {\n open = undefined\n end()\n finished()\n }\n }\n\n return { transaction }\n}\n","import { BaseDb } from '@/db/Db/BaseDb'\nimport type { IDb } from '@/interfaces/IDb'\nimport path from 'path'\nimport { fileURLToPath } from 'node:url'\nimport debug from 'debug'\nimport { appState } from '@/seedSchema'\nimport fs from 'fs'\nimport { createClient } from '@libsql/client'\nimport { createSingleConnectionTransactions } from './singleConnectionTransactions'\nimport { drizzle } from 'drizzle-orm/libsql'\nimport { migrate } from 'drizzle-orm/libsql/migrator'\nimport * as schema from '@/seedSchema'\nimport { Observable, interval, switchMap, distinctUntilChanged, startWith } from 'rxjs'\nimport { recreateIfOlderThanMinimumUpgradeVersion } from '@/db/minimumUpgradeVersion'\n\nconst logger = debug('seedSdk:node:db:Db')\n\nexport interface DbConfig {\n dbUrl?: string\n /** @deprecated Unused — schema is the static SDK seedSchema + prebuilt SQL migrations */\n schemaDir?: string\n outDir?: string\n}\n\nfunction resolveDbPaths(filesDir: string, config?: DbConfig) {\n const outDir = config?.outDir || path.join(filesDir, 'db')\n const dbPath = config?.dbUrl\n ? (config.dbUrl.startsWith('file:') ? config.dbUrl.replace(/^file:/, '') : config.dbUrl)\n : path.join(outDir, 'seed.db')\n return { outDir, dbPath }\n}\n\n/**\n * The installed @seedprotocol/sdk's dist directory, resolved from this module rather than the\n * working directory (hoisted monorepos, packaged Electron apps and scripts run from elsewhere all\n * differ). The working directory when the package can't be resolved.\n */\nfunction installedSdkDistDir(): string {\n try {\n const { createRequire } = process.getBuiltinModule('node:module')\n const pkgJson = createRequire(import.meta.url).resolve('@seedprotocol/sdk/package.json')\n return path.join(path.dirname(pkgJson), 'dist')\n } catch {\n return process.cwd()\n }\n}\n\n/**\n * Locate prebuilt drizzle migration SQL shipped with the SDK\n * (same files the browser embeds via drizzleFiles.ts).\n */\nexport function resolveSdkDrizzleMigrationsDir(sdkRootDir?: string): string {\n const root = sdkRootDir || installedSdkDistDir()\n\n // Look next to this module first, so the SDK always runs its own migrations\n // whatever the working directory (monorepos, packaged Electron apps, scripts\n // run from elsewhere). Rollup bundles this file into a chunk directly under\n // dist/, next to the copied dist/db/drizzle.\n const moduleDir = path.dirname(fileURLToPath(import.meta.url))\n\n const candidates = [\n path.join(moduleDir, 'db', 'drizzle'), // bundled: dist/<chunk>.js -> dist/db/drizzle\n path.join(moduleDir, '..', '..', 'db', 'drizzle'), // source: src/node/db -> src/db/drizzle\n path.join(moduleDir, '..', 'db', 'drizzle'), // dist layout variants\n path.join(moduleDir, '..', '..', '..', 'src', 'db', 'drizzle'), // dist/node -> src\n path.join(root, 'db', 'drizzle'), // production: sdkRoot is dist/\n path.join(root, 'dist', 'db', 'drizzle'), // sdk package root with built dist\n path.join(root, 'src', 'db', 'drizzle'), // monorepo / sdk-dev\n path.join(root, 'packages', 'sdk', 'src', 'db', 'drizzle'), // monorepo root as cwd\n path.join(root, 'packages', 'sdk', 'dist', 'db', 'drizzle'),\n ]\n\n for (const candidate of candidates) {\n if (fs.existsSync(path.join(candidate, 'meta', '_journal.json'))) {\n return candidate\n }\n }\n\n throw new Error(\n `Could not find SDK drizzle migrations (meta/_journal.json). Searched under: ${candidates.join(', ')}`,\n )\n}\n\nfunction copyDirRecursive(sourceDir: string, targetDir: string) {\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true })\n }\n for (const entry of fs.readdirSync(sourceDir)) {\n const sourcePath = path.join(sourceDir, entry)\n const targetPath = path.join(targetDir, entry)\n const stats = fs.statSync(sourcePath)\n if (stats.isDirectory()) {\n copyDirRecursive(sourcePath, targetPath)\n } else {\n fs.copyFileSync(sourcePath, targetPath)\n }\n }\n}\n\n\n/** The file a local libsql `file:` URL opens; undefined for `:memory:` and remote URLs. */\nconst localDbFilePath = (dbUrl: string): string | undefined => {\n if (!dbUrl.startsWith('file:')) return undefined\n const filePath = dbUrl.slice('file:'.length).split('?')[0]\n if (!filePath || filePath === ':memory:') return undefined\n return filePath.startsWith('//') ? filePath.replace(/^\\/\\/(localhost)?/, '') : filePath\n}\n\nexport class NodeDb implements IDb {\n db: any\n private client: ReturnType<typeof createClient> | undefined\n /** Bumped by close(), so a prepareDb that was running closes what it opened instead of keeping it. */\n private openGeneration = 0\n\n\n getAppDb() {\n return this.db\n }\n\n isAppDbReady() {\n return !!this.db\n }\n\n transactions: ReturnType<typeof createSingleConnectionTransactions> | undefined\n\n async transaction<T>(fn: (tx: any) => Promise<T>): Promise<T> {\n if (!this.db || !this.transactions) throw new Error('Database not prepared')\n return this.transactions.transaction(fn)\n }\n\n /**\n * Copy prebuilt SQL migrations into the app db directory (overwrite to stay current).\n */\n copyDrizzleFiles(filesDir: string, migrationsSourceDir?: string, config?: DbConfig): string {\n const { outDir } = resolveDbPaths(filesDir, config)\n const source = migrationsSourceDir || resolveSdkDrizzleMigrationsDir()\n logger('[Db.copyDrizzleFiles] copying from %s to %s', source, outDir)\n copyDirRecursive(source, outDir)\n return outDir\n }\n\n async prepareDb(filesDir: string, config?: DbConfig) {\n const resolvedFilesDir = path.resolve(filesDir)\n\n if (!fs.existsSync(resolvedFilesDir)) {\n fs.mkdirSync(resolvedFilesDir, { recursive: true })\n }\n\n const { outDir, dbPath } = resolveDbPaths(resolvedFilesDir, config)\n\n if (!fs.existsSync(outDir)) {\n fs.mkdirSync(outDir, { recursive: true })\n }\n\n // Install SDK migration SQL next to the DB (same source of truth as browser)\n this.copyDrizzleFiles(resolvedFilesDir, undefined, config)\n\n const dbUrl = config?.dbUrl\n ? (config.dbUrl.startsWith('file:') ? config.dbUrl : `file:${path.resolve(config.dbUrl)}`)\n : `file:${path.resolve(dbPath)}`\n\n // libsql won't create the database's folder (\"Unable to open connection … 14\").\n const dbFilePath = localDbFilePath(dbUrl)\n if (dbFilePath) {\n fs.mkdirSync(path.dirname(dbFilePath), { recursive: true })\n }\n\n const generation = this.openGeneration\n this.closeOpenDb()\n const client = createClient({ url: dbUrl })\n this.client = client\n // One connection for everything, transactions included (see singleConnectionTransactions)\n this.transactions = createSingleConnectionTransactions(client, schema)\n // Readers in other processes (a CLI on the same file) don't block a commit in WAL\n if (localDbFilePath(dbUrl)) await client.execute('PRAGMA journal_mode = WAL')\n const db = drizzle(client, { schema })\n\n await recreateIfOlderThanMinimumUpgradeVersion(db)\n logger('[Db.prepareDb] running migrations from %s', outDir)\n await migrate(db, { migrationsFolder: outDir })\n if (generation !== this.openGeneration) {\n if (this.client === client) this.closeOpenDb()\n else client.close()\n throw new Error('The database was closed while it was being opened')\n }\n\n this.db = db\n\n return this.db\n }\n\n async close(): Promise<void> {\n this.openGeneration++\n this.closeOpenDb()\n }\n\n /** Closes the libsql client and forgets the database. */\n private closeOpenDb(): void {\n const client = this.client\n this.db = undefined\n this.transactions = undefined\n this.client = undefined\n if (client && !client.closed) client.close()\n }\n\n async connectToDb(_pathToDir: string) {\n return {\n id: this.db ? this.db.constructor.name : '',\n }\n }\n\n async migrate(pathToDbDir: string, _dbName: string, _dbId: string) {\n try {\n if (!this.db) {\n throw new Error('Database not initialized. Call prepareDb first.')\n }\n\n await migrate(this.db, { migrationsFolder: pathToDbDir })\n const queryResult = await this.db.select().from(appState)\n logger('queryResult', queryResult)\n } catch (error: any) {\n const errorMessage = error.message || String(error) || ''\n const errorString = String(error)\n const isMigrationError =\n errorMessage.includes(\"Can't find meta/_journal.json\") ||\n errorMessage.includes('_journal.json') ||\n errorMessage.includes(\"Cannot read properties of undefined\") ||\n errorMessage.includes(\"reading 'dialect'\") ||\n errorMessage.includes('undefined is not an object') ||\n errorString.includes('dialect') ||\n errorString.includes('undefined is not an object')\n\n if (isMigrationError) {\n if (process.env.NODE_ENV === 'test' || process.env.IS_SEED_DEV) {\n logger(\n 'Warning: Migration failed, but continuing in test environment:',\n errorMessage || errorString,\n )\n return this.db\n }\n }\n throw error\n }\n\n return this.db\n }\n\n /**\n * Polling-based liveQuery stub for Node. Prefer browser reactive queries in UI apps.\n */\n liveQuery<T>(query: ((sql: any) => any) | any): Observable<T[]> {\n if (!this.db) {\n throw new Error('Database not initialized. Call prepareDb first.')\n }\n\n const pollInterval = 1000\n\n if (typeof query === 'function') {\n throw new Error(\n 'SQL tag functions are not supported in node liveQuery stub implementation. Use Drizzle query builders instead.',\n )\n }\n\n const queryBuilder = query\n\n return interval(pollInterval).pipe(\n startWith(0),\n switchMap(async () => {\n try {\n const result = await Promise.resolve(queryBuilder)\n return result as T[]\n } catch (error) {\n logger('[Db.liveQuery] Error executing query:', error)\n throw error\n }\n }),\n distinctUntilChanged((prev, curr) => {\n return JSON.stringify(prev) === JSON.stringify(curr)\n }),\n )\n }\n}\n\n/** @deprecated Prefer NodeDb */\nexport const Db = NodeDb\n\nBaseDb.configure(new NodeDb())\n\nconst _check: IDb = new NodeDb()\nvoid _check\n","import path from 'path'\n\n/**\n * The project's `.seed` directory on Node: `<process.cwd()>/.seed`. Apps whose working directory\n * isn't writable (a packaged Electron app's is often `/`) chdir before init or pass an absolute\n * filesDir.\n */\nexport function getDotSeedDir(): string {\n return path.join(process.cwd(), '.seed')\n}\n","/**\n * Whether a relative filesDir already names the .seed directory or a path inside\n * it ('.seed', '.seed/files', './.seed/files'). '.seed-alt/x' is not: it is\n * resolved under .seed like any other relative path.\n */\nexport function isUnderDotSeed(relativePath: string): boolean {\n const firstSegment = relativePath.split(/[\\\\/]+/).find((segment) => segment !== '' && segment !== '.')\n return firstSegment === '.seed'\n}\n","import fs from 'fs'\nimport path from 'path'\nimport { getDotSeedDir } from './dotSeedDir'\nimport { isUnderDotSeed } from '@/helpers/dotSeedPath'\n\n/**\n * The filesDir to use on Node, resolved relative to the .seed directory at the project root.\n * A browser OPFS-style path such as '/app-files' that doesn't exist on disk becomes\n * '.seed/app-files'; a relative path not already under .seed is joined to .seed; other absolute\n * paths are used as-is.\n */\nexport function resolveFilesDir(filesDir: string): string {\n // Not created here: prepareDb creates filesDir (under .seed when it's relative), so an absolute\n // filesDir works from a read-only working directory (e.g. a packaged Electron app's cwd `/`).\n const dotSeedDir = getDotSeedDir()\n\n // Browser OPFS paths are single-level, like '/app-files' or '/files'.\n const pathWithoutLeadingSlash = filesDir.slice(1)\n const isBrowserOpfsPath =\n path.isAbsolute(filesDir) &&\n filesDir.startsWith('/') &&\n pathWithoutLeadingSlash.length > 0 &&\n !pathWithoutLeadingSlash.includes('/') &&\n !fs.existsSync(filesDir)\n\n if (isBrowserOpfsPath) {\n return path.join(dotSeedDir, filesDir.slice(1) || 'app-files')\n }\n if (!path.isAbsolute(filesDir)) {\n return isUnderDotSeed(filesDir) ? path.resolve(filesDir) : path.join(dotSeedDir, filesDir)\n }\n return filesDir\n}\n","import { NodeFileManager } from '@/node/helpers/FileManager'\nimport { NodeDb } from '@/node/db/Db'\nimport { DefaultArweaveClient } from '@seedprotocol/arweave'\nimport { DefaultQueryClient } from '@seedprotocol/eas'\nimport { NodeEasClient } from '@seedprotocol/eas/node'\nimport type { PlatformServices } from './types'\n\nexport function createPlatformServices(): PlatformServices {\n return {\n fileManager: new NodeFileManager(),\n db: new NodeDb(),\n arweaveClient: new DefaultArweaveClient(),\n // Own undici Agent for EAS requests: shorter TLS handshake on Node 24.21+, 30 s keep-alive.\n easClient: new NodeEasClient(),\n queryClient: new DefaultQueryClient(),\n }\n}\n\nexport { configurePlatform } from './configurePlatform'\nexport { resolveFilesDir } from '@/node/helpers/resolveFilesDir'\nexport type { PlatformServices } from './types'\n"],"names":["fs"],"mappings":";;;;;;;;;;;;;;;;;;;MAOa,eAAe,CAAA;AAC1B,IAAA,MAAM,KAAK,GAAA;AACT,QAAA,OAAO,EAAE;IACX;IAEA,SAAS,GAAA;AACP,QAAA,OAAO,EAAE;IACX;;IAGA,MAAM,qBAAqB,CAAC,QAAgB,EAAA;QAC1C,OAAO,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI;IACnD;IAEA,MAAM,oBAAoB,CAAC,WAAoB,EAAA;AAC7C,QAAA,OAAM;IACR;AAEA,IAAA,MAAM,gBAAgB,GAAA;AACpB,QAAA,MAAM,IA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AAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AACjD,IAAA,MAAM,iBAAiB,GACrB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;AACzB,QAAA,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;QACxB,uBAAuB,CAAC,MAAM,GAAG,CAAC;AAClC,QAAA,CAAC,uBAAuB,CAAC,QAAQ,CAAC,GAAG,CAAC;AACtC,QAAA,CAACA,WAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;IAE1B,IAAI,iBAAiB,EAAE;AACrB,QAAA,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;IAChE;IACA,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QAC9B,OAAO,cAAc,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC;IAC5F;AACA,IAAA,OAAO,QAAQ;AACjB;;SCzBgB,sBAAsB,GAAA;IACpC,OAAO;QACL,WAAW,EAAE,IAAI,eAAe,EAAE;QAClC,EAAE,EAAE,IAAI,MAAM,EAAE;QAChB,aAAa,EAAE,IAAI,oBAAoB,EAAE;;QAEzC,SAAS,EAAE,IAAI,aAAa,EAAE;QAC9B,WAAW,EAAE,IAAI,kBAAkB,EAAE;KACtC;AACH;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"minimumUpgradeVersion-BDhHvHtr.js","sources":["../../src/db/minimumUpgradeVersion.ts"],"sourcesContent":["import { sql, type SQL } from 'drizzle-orm'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:db:minimumUpgradeVersion')\n\n/** The oldest SDK whose local database a newer SDK opens as it is. Older ones are recreated. */\nexport const MIN_UPGRADE_SDK_VERSION = '0.7.7'\n\n/**\n * `when` of migration 0020, the first one 0.7.7 doesn't ship: a database that applied it was opened\n * by 0.7.8 or later. SDKs 0.7.2 to 0.7.7 all ship migrations 0000-0019, so the count alone can't\n * tell 0.7.7 from older.\n */\nexport const FIRST_MIGRATION_AFTER_MIN_VERSION_MILLIS = 1792354539632\n\n/**\n * appState key that 0.7.7's first init wrote (its stored-display-URL fix) and no older SDK did. It\n * tells a 0.7.7 database from an older one with the same migrations.\n */\nexport const MIN_VERSION_APP_STATE_KEY = 'storedDisplayUrlsCleared'\n\n/** The part of a Drizzle SQLite database (sqlite-proxy or libsql) the check needs. */\ntype SqlRunner = {\n values: (query: SQL) => Promise<unknown[][]>\n run: (query: SQL) => Promise<unknown>\n}\n\n/** First column of the first row. libsql's rows index like arrays but aren't iterable. */\nconst firstValue = async (db: SqlRunner, query: SQL): Promise<unknown> => (await db.values(query))[0]?.[0]\n\nconst hasTable = async (db: SqlRunner, name: string): Promise<boolean> =>\n (await db.values(sql`SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ${name}`)).length > 0\n\n/**\n * True if an SDK older than {@link MIN_UPGRADE_SDK_VERSION} wrote this database and no newer SDK\n * has opened it since. False for a new (empty) database.\n */\nexport async function isOlderThanMinimumUpgradeVersion(db: SqlRunner): Promise<boolean> {\n if (!(await hasTable(db, '__drizzle_migrations'))) return false\n const lastMigration = await firstValue(db, sql`SELECT MAX(created_at) FROM __drizzle_migrations`)\n if (lastMigration == null) return false\n if (Number(lastMigration) >= FIRST_MIGRATION_AFTER_MIN_VERSION_MILLIS) return false\n if (!(await hasTable(db, 'appState'))) return true\n const marker = await db.values(sql`SELECT 1 FROM appState WHERE key = ${MIN_VERSION_APP_STATE_KEY}`)\n return marker.length === 0\n}\n\n/**\n * Drops every table, view and trigger, so the migrations that follow build the database as on a\n * fresh install. `__drizzle_migrations` goes last: if this stops halfway, the next start still sees\n * an old database and drops the rest.\n */\nasync function dropAllObjects(db: SqlRunner): Promise<void> {\n const rows = await db.values(\n sql`SELECT type, name FROM sqlite_master\n WHERE type IN ('view', 'trigger', 'table') AND name NOT LIKE 'sqlite_%'`,\n )\n const order = { trigger: 0, view: 1, table: 2 } as Record<string, number>\n const objects = rows\n .map((row) => [String(row[0]), String(row[1])] as const)\n .sort(([typeA, nameA], [typeB, nameB]) =>\n order[typeA]! - order[typeB]! ||\n Number(nameA === '__drizzle_migrations') - Number(nameB === '__drizzle_migrations'))\n const foreignKeys = await firstValue(db, sql`PRAGMA foreign_keys`)\n // Dropping a parent table would otherwise run foreign key checks against tables not dropped yet.\n await db.run(sql`PRAGMA foreign_keys = OFF`)\n try {\n for (const [type, name] of objects) {\n await db.run(sql.raw(`DROP ${type.toUpperCase()} IF EXISTS \"${name.replace(/\"/g, '\"\"')}\"`))\n }\n } finally {\n if (Number(foreignKeys) === 1) await db.run(sql`PRAGMA foreign_keys = ON`)\n }\n}\n\n/**\n * Recreates a database an SDK older than {@link MIN_UPGRADE_SDK_VERSION} wrote (decision D1 of the\n * 2026-10 SDK audit): its tables are dropped before migrations run, so everything not yet published\n * is gone and published data comes back through EAS sync. Files under filesDir stay where they are.\n * Call it before migrations, holding the migrate lock. Returns true if it recreated the database.\n */\nexport async function recreateIfOlderThanMinimumUpgradeVersion(db: SqlRunner): Promise<boolean> {\n if (!(await isOlderThanMinimumUpgradeVersion(db))) return false\n console.warn(\n `[seed-protocol] This local database was written by an SDK older than ${MIN_UPGRADE_SDK_VERSION}. ` +\n 'It is being recreated: unpublished items are dropped, and published items come back through EAS sync.',\n )\n await dropAllObjects(db)\n logger('dropped the tables of a database older than %s', MIN_UPGRADE_SDK_VERSION)\n return true\n}\n"],"names":[],"mappings":";;;AAGA,MAAM,MAAM,GAAG,KAAK,CAAC,kCAAkC,CAAC;AAExD;AACO,MAAM,uBAAuB,GAAG,OAAO;AAE9C;;;;AAIG;AACI,MAAM,wCAAwC,GAAG,aAAa;AAErE;;;AAGG;AACI,MAAM,yBAAyB,GAAG,0BAA0B;AAQnE;AACA,MAAM,UAAU,GAAG,OAAO,EAAa,EAAE,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AAc,CAAC,EAAE,CAAC;AACxB,IAAA,MAAM,CAAC,gDAAgD,EAAE,uBAAuB,CAAC;AACjF,IAAA,OAAO,IAAI;AACb;;"}
|
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
import { eq } from 'drizzle-orm';
|
|
2
|
-
import { isValidEasAttestationUid } from '@seedprotocol/eas';
|
|
3
|
-
import { normalizeRelationPropertyValue, resolveSeedIdsFromRefString } from '@seedprotocol/arweave';
|
|
4
|
-
import { B as BaseDb, h as htmlEmbeddedImageCoPublish } from './BaseFileManager-DLou1TZS.js';
|
|
5
|
-
import { j as findSeedRow, Z as ZERO_BYTES32, n as normalizeDataType, M as ModelPropertyDataTypes, k as getPropertyDefinitions, r as resolveModelRecord, l as resolveModelRecordByNameOrType } from './tabEvents-DT5ez6io.js';
|
|
6
|
-
import { M as isVersionRevoked, N as readModelMetadataProperties, P as metadataPropertyNameForms, Q as currentPropertyRow, R as getLatestVersionRow, L as getLatestPublishedVersionRow, S as parseListPropertyValueFromStorage, D as isPublishedSeedRef } from './Item-oPnmIehk.js';
|
|
7
|
-
import 'pluralize';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The local seed row a relation/list/image ref points at, by local id or uid. A uid resolves as
|
|
11
|
-
* {@link findSeedRow} resolves it (the order EAS sync matches seeds in): the old uid of a seed
|
|
12
|
-
* that was unpublished and published again resolves to that seed, through its old version rows.
|
|
13
|
-
* Null when nothing local matches (e.g. a published uid with no local copy).
|
|
14
|
-
*/
|
|
15
|
-
const findRelatedSeedRow = async ({ seedLocalId, seedUid, }) => {
|
|
16
|
-
const row = await findSeedRow({ localId: seedLocalId, uid: seedUid });
|
|
17
|
-
return row ? { seedLocalId: row.localId, seedUid: row.uid, revokedAt: row.revokedAt, type: row.type } : null;
|
|
18
|
-
};
|
|
19
|
-
/** The seed is attested and its attestation is live. */
|
|
20
|
-
const isLivePublishedSeed = (row) => !!row?.seedUid && row.seedUid !== ZERO_BYTES32 && !isVersionRevoked(row.revokedAt);
|
|
21
|
-
/** The seed was attested and that attestation was revoked (unpublished). */
|
|
22
|
-
const isUnpublishedSeed = (row) => !!row?.seedUid && row.seedUid !== ZERO_BYTES32 && isVersionRevoked(row.revokedAt);
|
|
23
|
-
/** Model a relation/list/image property points at, from its definition. */
|
|
24
|
-
function relatedModelNameFromDef(propertyDef) {
|
|
25
|
-
const def = propertyDef;
|
|
26
|
-
if (!def)
|
|
27
|
-
return undefined;
|
|
28
|
-
const dataType = normalizeDataType(def.dataType);
|
|
29
|
-
if (dataType === ModelPropertyDataTypes.Image)
|
|
30
|
-
return 'Image';
|
|
31
|
-
if (dataType === ModelPropertyDataTypes.File)
|
|
32
|
-
return 'File';
|
|
33
|
-
if (dataType === ModelPropertyDataTypes.Html)
|
|
34
|
-
return 'Html';
|
|
35
|
-
return def.ref ?? def.refModelName;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const STORAGE_SEED_TYPES = new Set([
|
|
39
|
-
ModelPropertyDataTypes.Image,
|
|
40
|
-
ModelPropertyDataTypes.File,
|
|
41
|
-
ModelPropertyDataTypes.Html,
|
|
42
|
-
ModelPropertyDataTypes.Json,
|
|
43
|
-
]);
|
|
44
|
-
const isStorageTransactionPropertyName = (name) => name === 'storageTransactionId' || name === 'storage_transaction_id';
|
|
45
|
-
function publishPropertyKind(key, def) {
|
|
46
|
-
const dataType = normalizeDataType(def.dataType);
|
|
47
|
-
const refValueType = normalizeDataType(def.refValueType);
|
|
48
|
-
if (STORAGE_SEED_TYPES.has(dataType))
|
|
49
|
-
return 'storageSeed';
|
|
50
|
-
if (dataType === ModelPropertyDataTypes.Relation) {
|
|
51
|
-
return STORAGE_SEED_TYPES.has(refValueType) ? 'storageSeed' : 'relation';
|
|
52
|
-
}
|
|
53
|
-
if (dataType === ModelPropertyDataTypes.List)
|
|
54
|
-
return def.ref || def.refModelName ? 'list' : 'basic';
|
|
55
|
-
if (def.storageType === 'ItemStorage')
|
|
56
|
-
return 'itemStorage';
|
|
57
|
-
if (isStorageTransactionPropertyName(key))
|
|
58
|
-
return 'storageTransaction';
|
|
59
|
-
return 'basic';
|
|
60
|
-
}
|
|
61
|
-
const isEmptyValue = (value) => value == null || value.trim() === '';
|
|
62
|
-
/** The seed refs a property's stored value names: one (Relation, storage seed) or each list member. */
|
|
63
|
-
function refsOf(value, kind) {
|
|
64
|
-
if (isEmptyValue(value))
|
|
65
|
-
return [];
|
|
66
|
-
if (kind === 'list') {
|
|
67
|
-
return parseListPropertyValueFromStorage(value)
|
|
68
|
-
.map((member) => normalizeRelationPropertyValue(member))
|
|
69
|
-
.filter((ref) => !!ref);
|
|
70
|
-
}
|
|
71
|
-
const ref = normalizeRelationPropertyValue(value);
|
|
72
|
-
return ref ? [ref] : [];
|
|
73
|
-
}
|
|
74
|
-
async function modelOfSeed(seed, modelNameHint) {
|
|
75
|
-
if (seed.modelFileId) {
|
|
76
|
-
const model = await resolveModelRecord(undefined, { modelFileId: seed.modelFileId });
|
|
77
|
-
if (model)
|
|
78
|
-
return model;
|
|
79
|
-
}
|
|
80
|
-
return (await resolveModelRecordByNameOrType(seed.type ?? modelNameHint, {})) ?? undefined;
|
|
81
|
-
}
|
|
82
|
-
/** One seed with its model's properties and their current rows. Undefined when the seed or its model isn't local. */
|
|
83
|
-
async function readNode(seedLocalId, kind, modelNameHint) {
|
|
84
|
-
const db = BaseDb.getAppDb();
|
|
85
|
-
if (!db)
|
|
86
|
-
return undefined;
|
|
87
|
-
const seed = await findSeedRow({ localId: seedLocalId });
|
|
88
|
-
if (!seed)
|
|
89
|
-
return undefined;
|
|
90
|
-
const model = await modelOfSeed(seed, modelNameHint);
|
|
91
|
-
if (!model)
|
|
92
|
-
return undefined;
|
|
93
|
-
const definitions = await getPropertyDefinitions(model.id);
|
|
94
|
-
const metadataProperties = await readModelMetadataProperties(db, model.id);
|
|
95
|
-
const seedUid = isValidEasAttestationUid(seed.uid) ? seed.uid : undefined;
|
|
96
|
-
const seedRef = { seedLocalId: seed.localId, seedUid };
|
|
97
|
-
const properties = [];
|
|
98
|
-
for (const [key, definition] of definitions) {
|
|
99
|
-
const property = metadataProperties.find((p) => p.id === definition._dbId);
|
|
100
|
-
const match = property
|
|
101
|
-
? { property, propertyId: property.id, names: metadataPropertyNameForms(property) }
|
|
102
|
-
: { property: undefined, propertyId: null, names: [key] };
|
|
103
|
-
const row = await currentPropertyRow(seedRef, { match, propertyName: key }, { overlay: false });
|
|
104
|
-
const propertyKind = publishPropertyKind(key, definition);
|
|
105
|
-
properties.push({
|
|
106
|
-
key,
|
|
107
|
-
definition,
|
|
108
|
-
kind: propertyKind,
|
|
109
|
-
row,
|
|
110
|
-
uid: isValidEasAttestationUid(row?.uid) ? row.uid : undefined,
|
|
111
|
-
walked: false,
|
|
112
|
-
deferred: false,
|
|
113
|
-
refs: [],
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
const head = await getLatestVersionRow(seed.localId);
|
|
117
|
-
const published = seedUid ? await getLatestPublishedVersionRow(seed.localId) : null;
|
|
118
|
-
const isFullNode = kind === 'root' || kind === 'draft';
|
|
119
|
-
const embeddedImages = isFullNode
|
|
120
|
-
? await db.select().from(htmlEmbeddedImageCoPublish).where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, seed.localId))
|
|
121
|
-
: [];
|
|
122
|
-
return {
|
|
123
|
-
seedLocalId: seed.localId,
|
|
124
|
-
kind,
|
|
125
|
-
seedUid,
|
|
126
|
-
newSeed: !seedUid || (kind === 'root' && isVersionRevoked(seed.revokedAt)),
|
|
127
|
-
modelName: model.name,
|
|
128
|
-
seedSchemaUid: isValidEasAttestationUid(seed.schemaUid) ? seed.schemaUid : undefined,
|
|
129
|
-
version: {
|
|
130
|
-
localId: head?.localId ?? undefined,
|
|
131
|
-
uid: isValidEasAttestationUid(head?.uid) ? head.uid : undefined,
|
|
132
|
-
publishedUid: published?.uid,
|
|
133
|
-
},
|
|
134
|
-
properties,
|
|
135
|
-
links: [],
|
|
136
|
-
embeddedImages,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
/** The Html property of `node` whose value is the Html storage seed `htmlSeedLocalId`. */
|
|
140
|
-
function htmlPropertyForHtmlSeed(node, htmlSeedLocalId) {
|
|
141
|
-
const want = htmlSeedLocalId.trim();
|
|
142
|
-
return node.properties.find((p) => normalizeDataType(p.definition.dataType) === ModelPropertyDataTypes.Html && p.row?.propertyValue?.trim() === want);
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* The publish graph of the seed `root` (an Item, or any `{ seedLocalId }`). Waits for pending
|
|
146
|
-
* outbox ops first, so every edit made before publishing is in its row (ADR 0019), then reads rows
|
|
147
|
-
* only.
|
|
148
|
-
*/
|
|
149
|
-
async function getPublishGraph(root, options = {}) {
|
|
150
|
-
const { waitForPendingOutboxOps } = await import('./index-CZMWKXLM.js');
|
|
151
|
-
await waitForPendingOutboxOps();
|
|
152
|
-
const rootNode = await readNode(root.seedLocalId, 'root', root.modelName);
|
|
153
|
-
if (!rootNode)
|
|
154
|
-
throw new Error(`Cannot publish ${root.seedLocalId}: no local seed with a known model`);
|
|
155
|
-
const republishRevokedSeed = !!rootNode.seedUid && rootNode.newSeed;
|
|
156
|
-
const forceFullSnapshot = options.publishMode === 'new_version' || republishRevokedSeed;
|
|
157
|
-
const graph = {
|
|
158
|
-
root: rootNode,
|
|
159
|
-
nodes: [],
|
|
160
|
-
forceFullSnapshot,
|
|
161
|
-
republishRevokedSeed,
|
|
162
|
-
unpublishedRelatedItems: [],
|
|
163
|
-
relatedRefUids: new Map(),
|
|
164
|
-
brokenRefs: [],
|
|
165
|
-
missingEmbeddedImages: [],
|
|
166
|
-
};
|
|
167
|
-
const nodes = new Map([[rootNode.seedLocalId, rootNode]]);
|
|
168
|
-
// Items getting a new seed in this publish whose walk hasn't finished: a ref to one is a back edge
|
|
169
|
-
const inProgress = new Set();
|
|
170
|
-
const noteUnpublished = (propertyKey, modelName, seed) => {
|
|
171
|
-
if (graph.unpublishedRelatedItems.some((r) => r.propertyName === propertyKey && r.seedLocalId === seed.seedLocalId))
|
|
172
|
-
return;
|
|
173
|
-
graph.unpublishedRelatedItems.push({
|
|
174
|
-
propertyName: propertyKey,
|
|
175
|
-
modelName: modelName ?? seed.type ?? 'unknown',
|
|
176
|
-
seedLocalId: seed.seedLocalId,
|
|
177
|
-
seedUid: seed.seedUid,
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
const link = (target, owner, propertyKey) => {
|
|
181
|
-
if (!target.links.some((l) => l.seedLocalId === owner.seedLocalId && l.propertyKey === propertyKey)) {
|
|
182
|
-
target.links.push({ seedLocalId: owner.seedLocalId, propertyKey });
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
/**
|
|
186
|
-
* Follows one ref of `property`: a draft target becomes a node (walked now, or already in the
|
|
187
|
-
* graph). Returns the ref with its node, or undefined for a back edge.
|
|
188
|
-
*/
|
|
189
|
-
const follow = async (owner, property, ref) => {
|
|
190
|
-
const list = property.kind === 'list';
|
|
191
|
-
const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(ref);
|
|
192
|
-
if (!seedLocalId && !seedUid) {
|
|
193
|
-
graph.brokenRefs.push({ seedLocalId: owner.seedLocalId, propertyKey: property.key, ref, reason: 'invalid', list });
|
|
194
|
-
return { ref };
|
|
195
|
-
}
|
|
196
|
-
const row = await findRelatedSeedRow({ seedLocalId, seedUid });
|
|
197
|
-
const targetLocalId = row?.seedLocalId ?? seedLocalId;
|
|
198
|
-
if (property.kind !== 'storageSeed' && targetLocalId && inProgress.has(targetLocalId))
|
|
199
|
-
return 'backEdge';
|
|
200
|
-
if (isUnpublishedSeed(row)) {
|
|
201
|
-
const targetNode = nodes.get(row.seedLocalId);
|
|
202
|
-
noteUnpublished(property.key, targetNode?.modelName ?? relatedModelNameFromDef(property.definition), row);
|
|
203
|
-
return { ref, seedLocalId: row.seedLocalId };
|
|
204
|
-
}
|
|
205
|
-
if (isLivePublishedSeed(row)) {
|
|
206
|
-
if (ref !== row.seedUid)
|
|
207
|
-
graph.relatedRefUids.set(ref, row.seedUid);
|
|
208
|
-
return { ref, seedLocalId: row.seedLocalId };
|
|
209
|
-
}
|
|
210
|
-
if (!row) {
|
|
211
|
-
// An attested uid with no local copy is already published: attested as-is
|
|
212
|
-
if (!isPublishedSeedRef(ref)) {
|
|
213
|
-
graph.brokenRefs.push({ seedLocalId: owner.seedLocalId, propertyKey: property.key, ref, reason: 'missing', list });
|
|
214
|
-
}
|
|
215
|
-
return { ref, seedLocalId };
|
|
216
|
-
}
|
|
217
|
-
let node = nodes.get(row.seedLocalId);
|
|
218
|
-
if (!node) {
|
|
219
|
-
const kind = property.kind === 'storageSeed' ? 'storageSeed' : 'draft';
|
|
220
|
-
node = await readNode(row.seedLocalId, kind, relatedModelNameFromDef(property.definition));
|
|
221
|
-
if (!node) {
|
|
222
|
-
graph.brokenRefs.push({ seedLocalId: owner.seedLocalId, propertyKey: property.key, ref, reason: 'missing', list });
|
|
223
|
-
return { ref, seedLocalId: row.seedLocalId };
|
|
224
|
-
}
|
|
225
|
-
nodes.set(node.seedLocalId, node);
|
|
226
|
-
await visit(node);
|
|
227
|
-
}
|
|
228
|
-
return { ref, seedLocalId: node.seedLocalId, node };
|
|
229
|
-
};
|
|
230
|
-
const walkProperty = async (owner, property) => {
|
|
231
|
-
const refs = refsOf(property.row?.propertyValue, property.kind);
|
|
232
|
-
property.walked = refs.length > 0 && (!property.uid || forceFullSnapshot);
|
|
233
|
-
if (!property.walked)
|
|
234
|
-
return;
|
|
235
|
-
// A list member that is a back edge defers the whole list; its other drafts are still published
|
|
236
|
-
const followed = [];
|
|
237
|
-
for (const ref of refs) {
|
|
238
|
-
const result = await follow(owner, property, ref);
|
|
239
|
-
if (result === 'backEdge') {
|
|
240
|
-
property.deferred = true;
|
|
241
|
-
if (property.kind !== 'list')
|
|
242
|
-
return;
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
followed.push(result);
|
|
246
|
-
}
|
|
247
|
-
property.refs = followed;
|
|
248
|
-
if (property.deferred)
|
|
249
|
-
return;
|
|
250
|
-
for (const { node } of followed)
|
|
251
|
-
if (node)
|
|
252
|
-
link(node, owner, property.key);
|
|
253
|
-
};
|
|
254
|
-
const walkEmbeddedImages = async (owner) => {
|
|
255
|
-
const done = new Set();
|
|
256
|
-
for (const row of owner.embeddedImages) {
|
|
257
|
-
if (done.has(row.imageSeedLocalId))
|
|
258
|
-
continue;
|
|
259
|
-
done.add(row.imageSeedLocalId);
|
|
260
|
-
const seed = await findRelatedSeedRow({ seedLocalId: row.imageSeedLocalId });
|
|
261
|
-
if (isUnpublishedSeed(seed)) {
|
|
262
|
-
noteUnpublished(htmlPropertyForHtmlSeed(owner, row.htmlSeedLocalId)?.key ?? 'html', 'Image', seed);
|
|
263
|
-
continue;
|
|
264
|
-
}
|
|
265
|
-
if (isLivePublishedSeed(seed))
|
|
266
|
-
continue;
|
|
267
|
-
if (!seed) {
|
|
268
|
-
graph.missingEmbeddedImages.push({ seedLocalId: owner.seedLocalId, imageSeedLocalId: row.imageSeedLocalId });
|
|
269
|
-
continue;
|
|
270
|
-
}
|
|
271
|
-
if (nodes.has(seed.seedLocalId))
|
|
272
|
-
continue;
|
|
273
|
-
const node = await readNode(seed.seedLocalId, 'embeddedImage', 'Image');
|
|
274
|
-
if (!node) {
|
|
275
|
-
graph.missingEmbeddedImages.push({ seedLocalId: owner.seedLocalId, imageSeedLocalId: row.imageSeedLocalId });
|
|
276
|
-
continue;
|
|
277
|
-
}
|
|
278
|
-
nodes.set(node.seedLocalId, node);
|
|
279
|
-
graph.nodes.push(node);
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
async function visit(node) {
|
|
283
|
-
const full = node.kind === 'root' || node.kind === 'draft';
|
|
284
|
-
if (node.newSeed)
|
|
285
|
-
inProgress.add(node.seedLocalId);
|
|
286
|
-
try {
|
|
287
|
-
if (full) {
|
|
288
|
-
for (const property of node.properties) {
|
|
289
|
-
if (property.kind === 'relation' || property.kind === 'storageSeed')
|
|
290
|
-
await walkProperty(node, property);
|
|
291
|
-
}
|
|
292
|
-
await walkEmbeddedImages(node);
|
|
293
|
-
for (const property of node.properties) {
|
|
294
|
-
if (property.kind === 'list')
|
|
295
|
-
await walkProperty(node, property);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
finally {
|
|
300
|
-
inProgress.delete(node.seedLocalId);
|
|
301
|
-
}
|
|
302
|
-
graph.nodes.push(node);
|
|
303
|
-
}
|
|
304
|
-
await visit(rootNode);
|
|
305
|
-
return graph;
|
|
306
|
-
}
|
|
307
|
-
/** Nodes of `graph` that are full items (the root and model drafts): the owners of Html properties and embedded images. */
|
|
308
|
-
const publishGraphItemNodes = (graph) => graph.nodes.filter((n) => n.kind === 'root' || n.kind === 'draft');
|
|
309
|
-
|
|
310
|
-
export { getPublishGraph as g, htmlPropertyForHtmlSeed as h, publishGraphItemNodes as p };
|
|
311
|
-
//# sourceMappingURL=publishGraph-CRn_N3NT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"publishGraph-CRn_N3NT.js","sources":["../../src/db/read/resolveRelatedSeedRef.ts","../../src/db/read/publishGraph.ts"],"sourcesContent":["import { findSeedRow } from './findSeedRow'\nimport { ZERO_BYTES32 } from '@/helpers/constants'\nimport { isVersionRevoked } from './subqueries/liveVersion'\nimport { ModelPropertyDataTypes, normalizeDataType } from '@/helpers/property'\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\n/**\n * The local seed row a relation/list/image ref points at, by local id or uid. A uid resolves as\n * {@link findSeedRow} resolves it (the order EAS sync matches seeds in): the old uid of a seed\n * that was unpublished and published again resolves to that seed, through its old version rows.\n * 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 row = await findSeedRow({ localId: seedLocalId, uid: seedUid })\n return row ? { seedLocalId: row.localId, seedUid: row.uid, revokedAt: row.revokedAt, type: row.type } : 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","import { eq } from 'drizzle-orm'\nimport { isValidEasAttestationUid } from '@seedprotocol/eas'\nimport { normalizeRelationPropertyValue, resolveSeedIdsFromRefString } from '@seedprotocol/arweave'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { htmlEmbeddedImageCoPublish } from '@/seedSchema/HtmlEmbeddedImageCoPublishSchema'\nimport { findSeedRow, type FoundSeedRow } from '@/db/read/findSeedRow'\nimport { currentPropertyRow, type CurrentPropertyRow } from '@/db/read/currentPropertyRow'\nimport { getLatestVersionRow } from '@/db/read/getLatestVersionRow'\nimport { getLatestPublishedVersionRow } from '@/db/read/getLatestPublishedVersionRow'\nimport { metadataPropertyNameForms, readModelMetadataProperties } from '@/db/read/metadataProperty'\nimport { resolveModelRecord, resolveModelRecordByNameOrType } from '@/db/read/resolveModelRecord'\nimport {\n findRelatedSeedRow,\n isLivePublishedSeed,\n isUnpublishedSeed,\n relatedModelNameFromDef,\n} from '@/db/read/resolveRelatedSeedRef'\nimport { isVersionRevoked } from '@/db/read/subqueries/liveVersion'\nimport type { UnpublishedRelatedItem } from '@/db/read/publishErrors'\nimport { getPropertyDefinitions, type PropertyDefinition } from '@/helpers/propertyDefinition'\nimport { parseListPropertyValueFromStorage } from '@/helpers/listPropertyValueFromStorage'\nimport { isPublishedSeedRef } from '@/helpers/relationSeedRef'\nimport { ModelPropertyDataTypes, normalizeDataType } from '@/helpers/property'\n\n/**\n * The seeds one publish attests, read from rows once (audit T11, decision D3). The payload, the\n * uploads, the cost estimate, the upload-candidate check, the early revoked-ref check, the Html\n * embedded-image passes and EAS schema registration all read this graph; none of them reads an\n * Item or ItemProperty instance.\n *\n * The publish attests the root and every draft (no seed uid yet) reachable from it:\n * - through relation and list-of-relation properties: model items, each with its full property set;\n * - through storage-seed properties (Image, File, Html, Json, or a Relation to one): storage seeds,\n * which attest their own basic properties;\n * - through the root's and the model drafts' Html-embedded image rows (htmlEmbeddedImageCoPublish).\n * Already-published targets are referenced by their current uid and not walked into; revoked ones\n * stop the publish (RelatedItemUnpublishedError).\n *\n * Walk order: depth first; per node, relation and storage-seed properties in model order, then\n * embedded images, then lists. `nodes` is the order nodes finish, so a node comes after the\n * nodes it refers to and the root is last.\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 (one 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. A list with a back reference is deferred whole; its other\n * draft members are still published, unlinked.\n */\n\n/** How a property takes part in a publish. */\nexport type PublishPropertyKind =\n /** Attested with its value. */\n | 'basic'\n /** A Relation to a model item. */\n | 'relation'\n /** A List of Relation. */\n | 'list'\n /** Image, File, Html or Json, or a Relation to one: its value is a storage seed. */\n | 'storageSeed'\n /** The node's own Arweave transaction slot (`storageTransactionId`). */\n | 'storageTransaction'\n /** An ItemStorage file, uploaded inside the node's composite upload. */\n | 'itemStorage'\n\n/** A seed one of a property's values names. */\nexport type PublishGraphRef = {\n /** The value as stored (local id, or uid). */\n ref: string\n /** The local seed it resolves to, also for the old uid of a seed published again since. */\n seedLocalId?: string\n /** The node this publish attests for it (a draft). */\n node?: PublishGraphNode\n}\n\nexport type PublishGraphProperty = {\n /** Schema key. */\n key: string\n definition: PropertyDefinition\n kind: PublishPropertyKind\n /** The property's current row. Publish waits for the outbox first, so no pending overlay. */\n row?: CurrentPropertyRow\n /** The row's attestation uid, when the row is attested. */\n uid?: string\n /**\n * Whether this publish walks the property's refs: it has a value, and no uid unless the\n * publish attests every property (`forceFullSnapshot`).\n */\n walked: boolean\n /** Points back at an item still being walked: left out of this publish. */\n deferred: boolean\n /** Relation, list and storage-seed values: the seeds named, in order. */\n refs: PublishGraphRef[]\n}\n\nexport type PublishGraphNodeKind = 'root' | 'draft' | 'storageSeed' | 'embeddedImage'\n\nexport type EmbeddedImageRow = typeof htmlEmbeddedImageCoPublish.$inferSelect\n\nexport type PublishGraphNode = {\n seedLocalId: string\n kind: PublishGraphNodeKind\n /** The seed's attestation uid; undefined for a draft. */\n seedUid?: string\n /** Gets a new seed attestation: a draft, or a revoked root published again. */\n newSeed: boolean\n modelName: string\n /** `seeds.schema_uid`. */\n seedSchemaUid?: string\n /** The head version row; `publishedUid` is the newest attested one (a draft version may be newer). */\n version: { localId?: string; uid?: string; publishedUid?: string }\n /** Every property of the node's model. */\n properties: PublishGraphProperty[]\n /** Properties in this publish that are filled with this node's new seed uid (propertiesToUpdate). */\n links: { seedLocalId: string; propertyKey: string }[]\n /** Html-embedded image rows of this node (root and model drafts only). */\n embeddedImages: EmbeddedImageRow[]\n}\n\n/** A ref the walk could not follow. */\nexport type PublishGraphBrokenRef = {\n seedLocalId: string\n propertyKey: string\n ref: string\n /** `invalid`: neither a local id nor a uid. `missing`: a local id with no local seed (or no model). */\n reason: 'invalid' | 'missing'\n list: boolean\n}\n\nexport type PublishGraph = {\n root: PublishGraphNode\n /** Every node, in the order the walk finishes them: referenced nodes first, the root last. */\n nodes: PublishGraphNode[]\n /** `new_version`, or a revoked root published again: properties with a uid are attested again. */\n forceFullSnapshot: boolean\n /** The root's seed was revoked: it gets a new seed attestation. */\n republishRevokedSeed: boolean\n /** Refs to seeds whose attestation was revoked; the publish stops with RelatedItemUnpublishedError. */\n unpublishedRelatedItems: UnpublishedRelatedItem[]\n /** Refs (local id, or a republished seed's old uid) to live published seeds, mapped to their current uid. */\n relatedRefUids: Map<string, string>\n brokenRefs: PublishGraphBrokenRef[]\n /** Embedded image rows whose image seed has no local row. */\n missingEmbeddedImages: { seedLocalId: string; imageSeedLocalId: string }[]\n}\n\nexport type PublishMode = 'patch' | 'new_version'\n\nexport type GetPublishGraphOptions = {\n /** `patch` (default): properties with a uid are left out. `new_version`: every property is attested. */\n publishMode?: PublishMode\n}\n\nconst STORAGE_SEED_TYPES = new Set<string>([\n ModelPropertyDataTypes.Image,\n ModelPropertyDataTypes.File,\n ModelPropertyDataTypes.Html,\n ModelPropertyDataTypes.Json,\n])\n\nexport const isStorageTransactionPropertyName = (name: string | undefined): boolean =>\n name === 'storageTransactionId' || name === 'storage_transaction_id'\n\nexport function publishPropertyKind(key: string, def: PropertyDefinition): PublishPropertyKind {\n const dataType = normalizeDataType(def.dataType)\n const refValueType = normalizeDataType(def.refValueType)\n if (STORAGE_SEED_TYPES.has(dataType)) return 'storageSeed'\n if (dataType === ModelPropertyDataTypes.Relation) {\n return STORAGE_SEED_TYPES.has(refValueType) ? 'storageSeed' : 'relation'\n }\n if (dataType === ModelPropertyDataTypes.List) return def.ref || def.refModelName ? 'list' : 'basic'\n if (def.storageType === 'ItemStorage') return 'itemStorage'\n if (isStorageTransactionPropertyName(key)) return 'storageTransaction'\n return 'basic'\n}\n\nconst isEmptyValue = (value: string | null | undefined): boolean => value == null || value.trim() === ''\n\n/** The seed refs a property's stored value names: one (Relation, storage seed) or each list member. */\nfunction refsOf(value: string | null | undefined, kind: PublishPropertyKind): string[] {\n if (isEmptyValue(value)) return []\n if (kind === 'list') {\n return parseListPropertyValueFromStorage(value!)\n .map((member) => normalizeRelationPropertyValue(member))\n .filter((ref): ref is string => !!ref)\n }\n const ref = normalizeRelationPropertyValue(value)\n return ref ? [ref] : []\n}\n\ntype SeedModel = { id: number; name: string }\n\nasync function modelOfSeed(seed: FoundSeedRow, modelNameHint?: string): Promise<SeedModel | undefined> {\n if (seed.modelFileId) {\n const model = await resolveModelRecord(undefined, { modelFileId: seed.modelFileId })\n if (model) return model\n }\n return (await resolveModelRecordByNameOrType(seed.type ?? modelNameHint, {})) ?? undefined\n}\n\n/** One seed with its model's properties and their current rows. Undefined when the seed or its model isn't local. */\nasync function readNode(\n seedLocalId: string,\n kind: PublishGraphNodeKind,\n modelNameHint?: string,\n): Promise<PublishGraphNode | undefined> {\n const db = BaseDb.getAppDb()\n if (!db) return undefined\n const seed = await findSeedRow({ localId: seedLocalId })\n if (!seed) return undefined\n const model = await modelOfSeed(seed, modelNameHint)\n if (!model) return undefined\n\n const definitions = await getPropertyDefinitions(model.id)\n const metadataProperties = await readModelMetadataProperties(db, model.id)\n const seedUid = isValidEasAttestationUid(seed.uid) ? seed.uid! : undefined\n const seedRef = { seedLocalId: seed.localId, seedUid }\n\n const properties: PublishGraphProperty[] = []\n for (const [key, definition] of definitions) {\n const property = metadataProperties.find((p) => p.id === definition._dbId)\n const match = property\n ? { property, propertyId: property.id, names: metadataPropertyNameForms(property) }\n : { property: undefined, propertyId: null, names: [key] }\n const row = await currentPropertyRow(seedRef, { match, propertyName: key }, { overlay: false })\n const propertyKind = publishPropertyKind(key, definition)\n properties.push({\n key,\n definition,\n kind: propertyKind,\n row,\n uid: isValidEasAttestationUid(row?.uid) ? row!.uid! : undefined,\n walked: false,\n deferred: false,\n refs: [],\n })\n }\n\n const head = await getLatestVersionRow(seed.localId)\n const published = seedUid ? await getLatestPublishedVersionRow(seed.localId) : null\n const isFullNode = kind === 'root' || kind === 'draft'\n const embeddedImages = isFullNode\n ? await db.select().from(htmlEmbeddedImageCoPublish).where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, seed.localId))\n : []\n\n return {\n seedLocalId: seed.localId,\n kind,\n seedUid,\n newSeed: !seedUid || (kind === 'root' && isVersionRevoked(seed.revokedAt)),\n modelName: model.name,\n seedSchemaUid: isValidEasAttestationUid(seed.schemaUid) ? seed.schemaUid! : undefined,\n version: {\n localId: head?.localId ?? undefined,\n uid: isValidEasAttestationUid(head?.uid) ? head!.uid! : undefined,\n publishedUid: published?.uid,\n },\n properties,\n links: [],\n embeddedImages,\n }\n}\n\n/** The Html property of `node` whose value is the Html storage seed `htmlSeedLocalId`. */\nexport function htmlPropertyForHtmlSeed(node: PublishGraphNode, htmlSeedLocalId: string): PublishGraphProperty | undefined {\n const want = htmlSeedLocalId.trim()\n return node.properties.find(\n (p) => normalizeDataType(p.definition.dataType) === ModelPropertyDataTypes.Html && p.row?.propertyValue?.trim() === want,\n )\n}\n\n/**\n * The publish graph of the seed `root` (an Item, or any `{ seedLocalId }`). Waits for pending\n * outbox ops first, so every edit made before publishing is in its row (ADR 0019), then reads rows\n * only.\n */\nexport async function getPublishGraph(\n root: { seedLocalId: string; modelName?: string },\n options: GetPublishGraphOptions = {},\n): Promise<PublishGraph> {\n const { waitForPendingOutboxOps } = await import('@/outbox')\n await waitForPendingOutboxOps()\n const rootNode = await readNode(root.seedLocalId, 'root', root.modelName)\n if (!rootNode) throw new Error(`Cannot publish ${root.seedLocalId}: no local seed with a known model`)\n const republishRevokedSeed = !!rootNode.seedUid && rootNode.newSeed\n const forceFullSnapshot = options.publishMode === 'new_version' || republishRevokedSeed\n\n const graph: PublishGraph = {\n root: rootNode,\n nodes: [],\n forceFullSnapshot,\n republishRevokedSeed,\n unpublishedRelatedItems: [],\n relatedRefUids: new Map(),\n brokenRefs: [],\n missingEmbeddedImages: [],\n }\n const nodes = new Map<string, PublishGraphNode>([[rootNode.seedLocalId, rootNode]])\n // Items getting a new seed in this publish whose walk hasn't finished: a ref to one is a back edge\n const inProgress = new Set<string>()\n\n const noteUnpublished = (propertyKey: string, modelName: string | undefined, seed: { seedLocalId: string; seedUid: string; type?: string | null }) => {\n if (graph.unpublishedRelatedItems.some((r) => r.propertyName === propertyKey && r.seedLocalId === seed.seedLocalId)) return\n graph.unpublishedRelatedItems.push({\n propertyName: propertyKey,\n modelName: modelName ?? seed.type ?? 'unknown',\n seedLocalId: seed.seedLocalId,\n seedUid: seed.seedUid,\n })\n }\n\n const link = (target: PublishGraphNode, owner: PublishGraphNode, propertyKey: string) => {\n if (!target.links.some((l) => l.seedLocalId === owner.seedLocalId && l.propertyKey === propertyKey)) {\n target.links.push({ seedLocalId: owner.seedLocalId, propertyKey })\n }\n }\n\n /**\n * Follows one ref of `property`: a draft target becomes a node (walked now, or already in the\n * graph). Returns the ref with its node, or undefined for a back edge.\n */\n const follow = async (\n owner: PublishGraphNode,\n property: PublishGraphProperty,\n ref: string,\n ): Promise<PublishGraphRef | 'backEdge'> => {\n const list = property.kind === 'list'\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(ref)\n if (!seedLocalId && !seedUid) {\n graph.brokenRefs.push({ seedLocalId: owner.seedLocalId, propertyKey: property.key, ref, reason: 'invalid', list })\n return { ref }\n }\n const row = await findRelatedSeedRow({ seedLocalId, seedUid })\n const targetLocalId = row?.seedLocalId ?? seedLocalId\n if (property.kind !== 'storageSeed' && targetLocalId && inProgress.has(targetLocalId)) return 'backEdge'\n if (isUnpublishedSeed(row)) {\n const targetNode = nodes.get(row.seedLocalId)\n noteUnpublished(property.key, targetNode?.modelName ?? relatedModelNameFromDef(property.definition), row)\n return { ref, seedLocalId: row.seedLocalId }\n }\n if (isLivePublishedSeed(row)) {\n if (ref !== row.seedUid) graph.relatedRefUids.set(ref, row.seedUid)\n return { ref, seedLocalId: row.seedLocalId }\n }\n if (!row) {\n // An attested uid with no local copy is already published: attested as-is\n if (!isPublishedSeedRef(ref)) {\n graph.brokenRefs.push({ seedLocalId: owner.seedLocalId, propertyKey: property.key, ref, reason: 'missing', list })\n }\n return { ref, seedLocalId }\n }\n let node = nodes.get(row.seedLocalId)\n if (!node) {\n const kind = property.kind === 'storageSeed' ? 'storageSeed' : 'draft'\n node = await readNode(row.seedLocalId, kind, relatedModelNameFromDef(property.definition))\n if (!node) {\n graph.brokenRefs.push({ seedLocalId: owner.seedLocalId, propertyKey: property.key, ref, reason: 'missing', list })\n return { ref, seedLocalId: row.seedLocalId }\n }\n nodes.set(node.seedLocalId, node)\n await visit(node)\n }\n return { ref, seedLocalId: node.seedLocalId, node }\n }\n\n const walkProperty = async (owner: PublishGraphNode, property: PublishGraphProperty) => {\n const refs = refsOf(property.row?.propertyValue, property.kind)\n property.walked = refs.length > 0 && (!property.uid || forceFullSnapshot)\n if (!property.walked) return\n // A list member that is a back edge defers the whole list; its other drafts are still published\n const followed: PublishGraphRef[] = []\n for (const ref of refs) {\n const result = await follow(owner, property, ref)\n if (result === 'backEdge') {\n property.deferred = true\n if (property.kind !== 'list') return\n continue\n }\n followed.push(result)\n }\n property.refs = followed\n if (property.deferred) return\n for (const { node } of followed) if (node) link(node, owner, property.key)\n }\n\n const walkEmbeddedImages = async (owner: PublishGraphNode) => {\n const done = new Set<string>()\n for (const row of owner.embeddedImages) {\n if (done.has(row.imageSeedLocalId)) continue\n done.add(row.imageSeedLocalId)\n const seed = await findRelatedSeedRow({ seedLocalId: row.imageSeedLocalId })\n if (isUnpublishedSeed(seed)) {\n noteUnpublished(htmlPropertyForHtmlSeed(owner, row.htmlSeedLocalId)?.key ?? 'html', 'Image', seed)\n continue\n }\n if (isLivePublishedSeed(seed)) continue\n if (!seed) {\n graph.missingEmbeddedImages.push({ seedLocalId: owner.seedLocalId, imageSeedLocalId: row.imageSeedLocalId })\n continue\n }\n if (nodes.has(seed.seedLocalId)) continue\n const node = await readNode(seed.seedLocalId, 'embeddedImage', 'Image')\n if (!node) {\n graph.missingEmbeddedImages.push({ seedLocalId: owner.seedLocalId, imageSeedLocalId: row.imageSeedLocalId })\n continue\n }\n nodes.set(node.seedLocalId, node)\n graph.nodes.push(node)\n }\n }\n\n async function visit(node: PublishGraphNode): Promise<void> {\n const full = node.kind === 'root' || node.kind === 'draft'\n if (node.newSeed) inProgress.add(node.seedLocalId)\n try {\n if (full) {\n for (const property of node.properties) {\n if (property.kind === 'relation' || property.kind === 'storageSeed') await walkProperty(node, property)\n }\n await walkEmbeddedImages(node)\n for (const property of node.properties) {\n if (property.kind === 'list') await walkProperty(node, property)\n }\n }\n } finally {\n inProgress.delete(node.seedLocalId)\n }\n graph.nodes.push(node)\n }\n\n await visit(rootNode)\n return graph\n}\n\n/** Nodes of `graph` that are full items (the root and model drafts): the owners of Html properties and embedded images. */\nexport const publishGraphItemNodes = (graph: PublishGraph): PublishGraphNode[] =>\n graph.nodes.filter((n) => n.kind === 'root' || n.kind === 'draft')\n"],"names":[],"mappings":";;;;;;;;AAaA;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG,OAAO,EACvC,WAAW,EACX,OAAO,GAIR,KAAoC;AACnC,IAAA,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AACrE,IAAA,OAAO,GAAG,GAAG,EAAE,WAAW,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,IAAI;AAC9G,CAAC;AAED;AACO,MAAM,mBAAmB,GAAG,CAAC,GAA0B,KAC5D,CAAC,CAAC,GAAG,EAAE,OAAO,IAAI,GAAG,CAAC,OAAO,KAAK,YAAY,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC;AAEpF;AACO,MAAM,iBAAiB,GAAG,CAAC,GAA0B,KAC1D,CAA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C1D,IAAI,IAAI,CAAC,OAAO;AAAE,YAAA,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC;AAClD,QAAA,IAAI;YACF,IAAI,IAAI,EAAE;AACR,gBAAA,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE;oBACtC,IAAI,QAAQ,CAAC,IAAI,KAAK,UAAU,IAAI,QAAQ,CAAC,IAAI,KAAK,aAAa;AAAE,wBAAA,MAAM,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC;gBACzG;AACA,gBAAA,MAAM,kBAAkB,CAAC,IAAI,CAAC;AAC9B,gBAAA,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE;AACtC,oBAAA,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM;AAAE,wBAAA,MAAM,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC;gBAClE;YACF;QACF;gBAAU;AACR,YAAA,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;QACrC;AACA,QAAA,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;IACxB;AAEA,IAAA,MAAM,KAAK,CAAC,QAAQ,CAAC;AACrB,IAAA,OAAO,KAAK;AACd;AAEA;AACO,MAAM,qBAAqB,GAAG,CAAC,KAAmB,KACvD,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO;;"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
|
-
import { relations } from 'drizzle-orm'
|
|
3
|
-
import { properties } from './ModelSchema'
|
|
4
|
-
|
|
5
|
-
export const propertyUids = sqliteTable('property_uids', {
|
|
6
|
-
id: int('id').primaryKey({ autoIncrement: true }),
|
|
7
|
-
uid: text('uid').notNull(),
|
|
8
|
-
propertyId: int('property_id')
|
|
9
|
-
.notNull()
|
|
10
|
-
.unique()
|
|
11
|
-
.references(() => properties.id),
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
export const propertyUidRelations = relations(propertyUids, ({ one }) => ({
|
|
15
|
-
property: one(properties),
|
|
16
|
-
}))
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { MetadataType } from '../../seedSchema';
|
|
2
|
-
type GetItemPropertyProps = Partial<MetadataType>;
|
|
3
|
-
type GetItemPropertyData = (props: GetItemPropertyProps) => Promise<Partial<MetadataType>>;
|
|
4
|
-
export declare const getItemPropertyData: GetItemPropertyData;
|
|
5
|
-
export {};
|
|
6
|
-
//# sourceMappingURL=getItemProperty.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getItemProperty.d.ts","sourceRoot":"","sources":["../../../../src/db/read/getItemProperty.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,YAAY,EAAE,MAAM,cAAc,CAAA;AAGrD,KAAK,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AAEjD,KAAK,mBAAmB,GAAG,CACzB,KAAK,EAAE,oBAAoB,KACxB,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA;AAEnC,eAAO,MAAM,mBAAmB,EAAE,mBAuBjC,CAAA"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* True when the item's seed attestation was revoked (`seeds.revoked_at` set, by unpublish or EAS
|
|
3
|
-
* sync). Such a seed can't take new versions: publishing again creates a new seed attestation
|
|
4
|
-
* (see "Republishing" in docs/ATTESTATION_REVOCATION.md).
|
|
5
|
-
*/
|
|
6
|
-
export declare const isSeedRevoked: (seedLocalId: string | undefined) => Promise<boolean>;
|
|
7
|
-
//# sourceMappingURL=isSeedRevoked.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isSeedRevoked.d.ts","sourceRoot":"","sources":["../../../../src/db/read/isSeedRevoked.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAU,aAAa,MAAM,GAAG,SAAS,KAAG,OAAO,CAAC,OAAO,CAIpF,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"saveMetadata.d.ts","sourceRoot":"","sources":["../../../../src/db/write/saveMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,YAAY,EAAE,MAAM,cAAc,CAAA;AAIrD,eAAO,MAAM,YAAY,GACvB,gBAAgB,OAAO,CAAC,YAAY,CAAC,EACrC,gBAAgB,OAAO,CAAC,YAAY,CAAC,kBAgBtC,CAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { MetadataType } from '../../seedSchema';
|
|
2
|
-
import { BaseDb } from '../Db/BaseDb';
|
|
3
|
-
import { PropertyType } from '../../types';
|
|
4
|
-
type UpdateMetadata = (metadataValues: Partial<MetadataType>, propertyRecordSchema?: PropertyType | undefined, options?: {
|
|
5
|
-
/**
|
|
6
|
-
* The database or transaction to write and read; the app database by default. With one, the
|
|
7
|
-
* EAS schema uid isn't looked up: set `schemaUid` (resolveMetadataSchemaUid) beforehand.
|
|
8
|
-
*/
|
|
9
|
-
db?: ReturnType<typeof BaseDb.getAppDb>;
|
|
10
|
-
}) => Promise<MetadataType>;
|
|
11
|
-
export declare const updateMetadata: UpdateMetadata;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=updateMetadata.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"updateMetadata.d.ts","sourceRoot":"","sources":["../../../../src/db/write/updateMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,YAAY,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAItC,KAAK,cAAc,GAAG,CACpB,cAAc,EAAE,OAAO,CAAC,YAAY,CAAC,EACrC,oBAAoB,CAAC,EAAE,YAAY,GAAG,SAAS,EAC/C,OAAO,CAAC,EAAE;IACR;;;OAGG;IACH,EAAE,CAAC,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAA;CACxC,KACE,OAAO,CAAC,YAAY,CAAC,CAAA;AAE1B,eAAO,MAAM,cAAc,EAAE,cAqD5B,CAAA"}
|