@seedprotocol/sdk 0.4.18 → 0.4.20
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/{ArweaveClient-WfxkMgxb.js → ArweaveClient-C1bakApw.js} +3 -3
- package/dist/{ArweaveClient-WfxkMgxb.js.map → ArweaveClient-C1bakApw.js.map} +1 -1
- package/dist/{ArweaveClient-CpShI0B0.js → ArweaveClient-Ck4wflb3.js} +3 -3
- package/dist/{ArweaveClient-CpShI0B0.js.map → ArweaveClient-Ck4wflb3.js.map} +1 -1
- package/dist/{Db-DWvxJG22.js → Db-CCMLWMi-.js} +133 -6
- package/dist/Db-CCMLWMi-.js.map +1 -0
- package/dist/{Db-29bu0gJx.js → Db-YFg99EDt.js} +4 -4
- package/dist/{Db-29bu0gJx.js.map → Db-YFg99EDt.js.map} +1 -1
- package/dist/{EasClient-BwBg9Kkd.js → EasClient-BmYeAnq7.js} +2 -2
- package/dist/{EasClient-BwBg9Kkd.js.map → EasClient-BmYeAnq7.js.map} +1 -1
- package/dist/{EasClient-CtLqK_qz.js → EasClient-Bqzb-xF2.js} +2 -2
- package/dist/{EasClient-CtLqK_qz.js.map → EasClient-Bqzb-xF2.js.map} +1 -1
- package/dist/{FileManager-DgraLHZS.js → FileManager-Ba1qAT8_.js} +2 -2
- package/dist/{FileManager-DgraLHZS.js.map → FileManager-Ba1qAT8_.js.map} +1 -1
- package/dist/{FileManager-DSihj6Sj.js → FileManager-rVAH7uNp.js} +2 -2
- package/dist/{FileManager-DSihj6Sj.js.map → FileManager-rVAH7uNp.js.map} +1 -1
- package/dist/{ModelProperty-Bz3V3LoI.js → ModelProperty-Csj84uQv.js} +24 -24
- package/dist/{ModelProperty-Bz3V3LoI.js.map → ModelProperty-Csj84uQv.js.map} +1 -1
- package/dist/{PathResolver-DQ5hyu8X.js → PathResolver-B5XBxiLt.js} +2 -2
- package/dist/{PathResolver-DQ5hyu8X.js.map → PathResolver-B5XBxiLt.js.map} +1 -1
- package/dist/{PathResolver-DOu-0k75.js → PathResolver-CzhXp_OH.js} +2 -2
- package/dist/{PathResolver-DOu-0k75.js.map → PathResolver-CzhXp_OH.js.map} +1 -1
- package/dist/{QueryClient-DYaqIx7e.js → QueryClient-5NAcOOvw.js} +2 -2
- package/dist/{QueryClient-DYaqIx7e.js.map → QueryClient-5NAcOOvw.js.map} +1 -1
- package/dist/{QueryClient-CJV1m2rc.js → QueryClient-BqpbpJEP.js} +2 -2
- package/dist/{QueryClient-CJV1m2rc.js.map → QueryClient-BqpbpJEP.js.map} +1 -1
- package/dist/{Schema-CFMbnImW.js → Schema-QjwZN91G.js} +38 -38
- package/dist/{Schema-CFMbnImW.js.map → Schema-QjwZN91G.js.map} +1 -1
- package/dist/{SchemaValidationService-D4ZVetLE.js → SchemaValidationService-Cwkeb4fG.js} +2 -2
- package/dist/{SchemaValidationService-D4ZVetLE.js.map → SchemaValidationService-Cwkeb4fG.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-DptGKVzG.js → backfillMetadataPropertyIds-DCYUHZDQ.js} +2 -2
- package/dist/{backfillMetadataPropertyIds-DptGKVzG.js.map → backfillMetadataPropertyIds-DCYUHZDQ.js.map} +1 -1
- package/dist/cjs/{ModelProperty-TPey_B4m.js → ModelProperty-m4dACdoX.js} +17 -17
- package/dist/cjs/{ModelProperty-TPey_B4m.js.map → ModelProperty-m4dACdoX.js.map} +1 -1
- package/dist/cjs/{Schema-B-IQEtpX.js → Schema-DlSTkGtE.js} +20 -20
- package/dist/cjs/{Schema-B-IQEtpX.js.map → Schema-DlSTkGtE.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-IQ0Gc9HM.js → SchemaValidationService-C06zlv2z.js} +2 -2
- package/dist/cjs/{SchemaValidationService-IQ0Gc9HM.js.map → SchemaValidationService-C06zlv2z.js.map} +1 -1
- package/dist/cjs/{backfillMetadataPropertyIds-BBPgBc2W.js → backfillMetadataPropertyIds-gyFrK_ny.js} +2 -2
- package/dist/cjs/{backfillMetadataPropertyIds-BBPgBc2W.js.map → backfillMetadataPropertyIds-gyFrK_ny.js.map} +1 -1
- package/dist/cjs/{getItem-CWf0OO0F.js → getItem-gFz18nL2.js} +2 -2
- package/dist/cjs/{getItem-CWf0OO0F.js.map → getItem-gFz18nL2.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-muuS1j0F.js → getPublishPayload-DHNfV-GE.js} +18 -10
- package/dist/cjs/getPublishPayload-DHNfV-GE.js.map +1 -0
- package/dist/cjs/{getPublishUploads-CONYV9QQ.js → getPublishUploads-Dt-3g6eW.js} +18 -13
- package/dist/cjs/getPublishUploads-Dt-3g6eW.js.map +1 -0
- package/dist/cjs/{getSegmentedItemProperties-Dl3J_uCe.js → getSegmentedItemProperties-D3XpxCt8.js} +3 -3
- package/dist/cjs/{getSegmentedItemProperties-Dl3J_uCe.js.map → getSegmentedItemProperties-D3XpxCt8.js.map} +1 -1
- package/dist/cjs/{index-D7a8oFJP.js → index-4M2KX6s4.js} +3 -3
- package/dist/cjs/index-4M2KX6s4.js.map +1 -0
- package/dist/cjs/{index-Bte-I6OD.js → index-CHrEZZ71.js} +163 -40
- package/dist/cjs/index-CHrEZZ71.js.map +1 -0
- package/dist/cjs/{ownership-Bxv6CUrH.js → ownership-CC_YF-XC.js} +2 -2
- package/dist/cjs/{ownership-Bxv6CUrH.js.map → ownership-CC_YF-XC.js.map} +1 -1
- package/dist/cjs/{property-xOF5k4ka.js → property-DtCxuPrc.js} +4 -4
- package/dist/cjs/{property-xOF5k4ka.js.map → property-DtCxuPrc.js.map} +1 -1
- package/dist/db/drizzle/drizzle/0010_add_arweave_l1_finalize_jobs.sql +16 -0
- package/dist/db/drizzle/drizzle/meta/0010_snapshot.json +1182 -0
- package/dist/db/drizzle/drizzle/meta/_journal.json +7 -0
- package/dist/{getItem-Hubs_yxu.js → getItem-CpjN3MFQ.js} +2 -2
- package/dist/{getItem-Hubs_yxu.js.map → getItem-CpjN3MFQ.js.map} +1 -1
- package/dist/{getPublishPayload-CqUCIlu1.js → getPublishPayload-CMhy9jfz.js} +21 -13
- package/dist/getPublishPayload-CMhy9jfz.js.map +1 -0
- package/dist/{getPublishUploads-QgfPyhcs.js → getPublishUploads-DTE4SEWk.js} +18 -13
- package/dist/getPublishUploads-DTE4SEWk.js.map +1 -0
- package/dist/{getSegmentedItemProperties-Dzscmm_m.js → getSegmentedItemProperties-DzPjQtcg.js} +3 -3
- package/dist/{getSegmentedItemProperties-Dzscmm_m.js.map → getSegmentedItemProperties-DzPjQtcg.js.map} +1 -1
- package/dist/{index-CtzvJMAE.js → index-C1HlP_fU.js} +190 -55
- package/dist/index-C1HlP_fU.js.map +1 -0
- package/dist/{index-VmIdPfTW.js → index-DvUyNZc9.js} +3 -3
- package/dist/index-DvUyNZc9.js.map +1 -0
- package/dist/{index-QSl4EYun.js → index-dDmXPEJC.js} +3 -2
- package/dist/index-dDmXPEJC.js.map +1 -0
- package/dist/main.cjs +1 -1
- package/dist/main.js +55 -14
- package/dist/main.js.map +1 -1
- package/dist/node.js +10 -10
- package/dist/{ownership-loPNh3_a.js → ownership-C7GyMbsf.js} +2 -2
- package/dist/{ownership-loPNh3_a.js.map → ownership-C7GyMbsf.js.map} +1 -1
- package/dist/{property-D8HimAKw.js → property-BNt7Dkmw.js} +6 -6
- package/dist/{property-D8HimAKw.js.map → property-BNt7Dkmw.js.map} +1 -1
- package/dist/{queries-DPADHnwy.js → queries-D09IIJg_.js} +2 -2
- package/dist/{queries-DPADHnwy.js.map → queries-D09IIJg_.js.map} +1 -1
- package/dist/seedSchema/ArweaveL1FinalizeSchema.ts +28 -0
- package/dist/seedSchema/index.d.ts +3 -0
- package/dist/seedSchema/index.ts +1 -0
- package/dist/src/Item/Item.d.ts +1 -1
- package/dist/src/Item/Item.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/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/src/db/read/getPublishUploads.d.ts +7 -3
- package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
- package/dist/src/db/write/applyArweaveL1TransactionIdLocal.d.ts +12 -0
- package/dist/src/db/write/applyArweaveL1TransactionIdLocal.d.ts.map +1 -0
- package/dist/src/eas.d.ts +6 -0
- package/dist/src/eas.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/helpers/ArweaveClient/arweaveL1UploadApi.d.ts +46 -0
- package/dist/src/helpers/ArweaveClient/arweaveL1UploadApi.d.ts.map +1 -0
- package/dist/src/helpers/constants.d.ts +2 -0
- package/dist/src/helpers/constants.d.ts.map +1 -1
- package/dist/src/helpers/index.d.ts +1 -0
- package/dist/src/helpers/index.d.ts.map +1 -1
- package/dist/src/index.d.ts +7 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/interfaces/IItem.d.ts +1 -1
- package/dist/src/interfaces/IItem.d.ts.map +1 -1
- package/dist/src/seedSchema/ArweaveL1FinalizeSchema.d.ts +233 -0
- package/dist/src/seedSchema/ArweaveL1FinalizeSchema.d.ts.map +1 -0
- package/dist/src/seedSchema/index.d.ts +1 -0
- package/dist/src/seedSchema/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/Db-DWvxJG22.js.map +0 -1
- package/dist/cjs/getPublishPayload-muuS1j0F.js.map +0 -1
- package/dist/cjs/getPublishUploads-CONYV9QQ.js.map +0 -1
- package/dist/cjs/index-Bte-I6OD.js.map +0 -1
- package/dist/cjs/index-D7a8oFJP.js.map +0 -1
- package/dist/getPublishPayload-CqUCIlu1.js.map +0 -1
- package/dist/getPublishUploads-QgfPyhcs.js.map +0 -1
- package/dist/index-CtzvJMAE.js.map +0 -1
- package/dist/index-QSl4EYun.js.map +0 -1
- package/dist/index-VmIdPfTW.js.map +0 -1
package/dist/Db-DWvxJG22.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Db-DWvxJG22.js","sources":["../../src/browser/db/drizzleFiles.ts","../../src/browser/db/Db.ts"],"sourcesContent":["// This file embeds the drizzle migration files as strings for browser runtime\n// These files are copied from packages/sdk/src/db/drizzle at build time\n\n// Individual migration SQL files\nexport const migrationSql_0000_married_malice = `CREATE TABLE \\`appState\\` (\n\t\\`key\\` text,\n\t\\`value\\` text,\n\t\\`created_at\\` integer,\n\t\\`updated_at\\` integer\n);\n--> statement-breakpoint\nCREATE UNIQUE INDEX \\`appState_key_unique\\` ON \\`appState\\` (\\`key\\`);--> statement-breakpoint\nCREATE TABLE \\`config\\` (\n\t\\`id\\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t\\`key\\` text NOT NULL,\n\t\\`text\\` text,\n\t\\`json\\` text,\n\t\\`blob\\` blob\n);\n--> statement-breakpoint\nCREATE TABLE \\`metadata\\` (\n\t\\`local_id\\` text,\n\t\\`uid\\` text,\n\t\\`property_name\\` text,\n\t\\`property_value\\` text,\n\t\\`schema_uid\\` text,\n\t\\`model_type\\` text,\n\t\\`seed_local_id\\` text,\n\t\\`seed_uid\\` text,\n\t\\`version_local_id\\` text,\n\t\\`version_uid\\` text,\n\t\\`eas_data_type\\` text,\n\t\\`ref_value_type\\` text,\n\t\\`ref_schema_uid\\` text,\n\t\\`ref_seed_type\\` text,\n\t\\`ref_resolved_value\\` text,\n\t\\`ref_resolved_display_value\\` text,\n\t\\`local_storage_dir\\` text,\n\t\\`attestation_raw\\` text,\n\t\\`attestation_created_at\\` integer,\n\t\\`content_hash\\` text,\n\t\\`created_at\\` integer,\n\t\\`updated_at\\` integer\n);\n--> statement-breakpoint\nCREATE UNIQUE INDEX \\`metadata_local_id_unique\\` ON \\`metadata\\` (\\`local_id\\`);--> statement-breakpoint\nCREATE TABLE \\`models\\` (\n\t\\`id\\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t\\`name\\` text NOT NULL,\n\t\\`schema_file_id\\` text\n);\n--> statement-breakpoint\nCREATE TABLE \\`properties\\` (\n\t\\`id\\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t\\`name\\` text NOT NULL,\n\t\\`data_type\\` text NOT NULL,\n\t\\`model_id\\` integer NOT NULL,\n\t\\`ref_model_id\\` integer,\n\t\\`ref_value_type\\` text,\n\t\\`schema_file_id\\` text,\n\tFOREIGN KEY (\\`model_id\\`) REFERENCES \\`models\\`(\\`id\\`) ON UPDATE no action ON DELETE no action,\n\tFOREIGN KEY (\\`ref_model_id\\`) REFERENCES \\`models\\`(\\`id\\`) ON UPDATE no action ON DELETE no action\n);\n--> statement-breakpoint\nCREATE UNIQUE INDEX \\`unique_name_model_id\\` ON \\`properties\\` (\\`name\\`,\\`model_id\\`);--> statement-breakpoint\nCREATE TABLE \\`model_schemas\\` (\n\t\\`id\\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t\\`model_id\\` integer,\n\t\\`schema_id\\` integer,\n\tFOREIGN KEY (\\`model_id\\`) REFERENCES \\`models\\`(\\`id\\`) ON UPDATE no action ON DELETE no action,\n\tFOREIGN KEY (\\`schema_id\\`) REFERENCES \\`schemas\\`(\\`id\\`) ON UPDATE no action ON DELETE no action\n);\n--> statement-breakpoint\nCREATE TABLE \\`model_uids\\` (\n\t\\`id\\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t\\`uid\\` text NOT NULL,\n\t\\`model_id\\` integer NOT NULL,\n\tFOREIGN KEY (\\`model_id\\`) REFERENCES \\`models\\`(\\`id\\`) ON UPDATE no action ON DELETE no action\n);\n--> statement-breakpoint\nCREATE UNIQUE INDEX \\`model_uids_model_id_unique\\` ON \\`model_uids\\` (\\`model_id\\`);--> statement-breakpoint\nCREATE TABLE \\`property_uids\\` (\n\t\\`id\\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t\\`uid\\` text NOT NULL,\n\t\\`property_id\\` integer NOT NULL,\n\tFOREIGN KEY (\\`property_id\\`) REFERENCES \\`models\\`(\\`id\\`) ON UPDATE no action ON DELETE no action\n);\n--> statement-breakpoint\nCREATE UNIQUE INDEX \\`property_uids_property_id_unique\\` ON \\`property_uids\\` (\\`property_id\\`);--> statement-breakpoint\nCREATE TABLE \\`schemas\\` (\n\t\\`id\\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t\\`name\\` text NOT NULL,\n\t\\`version\\` integer NOT NULL,\n\t\\`schema_file_id\\` text,\n\t\\`created_at\\` integer,\n\t\\`updated_at\\` integer\n);\n--> statement-breakpoint\nCREATE TABLE \\`seeds\\` (\n\t\\`local_id\\` text,\n\t\\`uid\\` text,\n\t\\`schema_uid\\` text,\n\t\\`type\\` text,\n\t\\`attestation_raw\\` text,\n\t\\`attestation_created_at\\` integer,\n\t\\`created_at\\` integer,\n\t\\`updated_at\\` integer,\n\t\\`_marked_for_deletion\\` integer\n);\n--> statement-breakpoint\nCREATE UNIQUE INDEX \\`seeds_local_id_unique\\` ON \\`seeds\\` (\\`local_id\\`);--> statement-breakpoint\nCREATE TABLE \\`versions\\` (\n\t\\`local_id\\` text,\n\t\\`uid\\` text,\n\t\\`seed_local_id\\` text,\n\t\\`seed_uid\\` text,\n\t\\`seed_type\\` text,\n\t\\`note\\` text,\n\t\\`created_at\\` integer,\n\t\\`updated_at\\` integer,\n\t\\`attestation_created_at\\` integer,\n\t\\`attestation_raw\\` text\n);\n--> statement-breakpoint\nCREATE UNIQUE INDEX \\`versions_local_id_unique\\` ON \\`versions\\` (\\`local_id\\`);`\n\nexport const migrationSql_0001_sweet_bruce_banner = `ALTER TABLE \\`schemas\\` ADD \\`schema_data\\` text;--> statement-breakpoint\nALTER TABLE \\`schemas\\` ADD \\`is_draft\\` integer;`\n\nexport const migrationSql_0002_bitter_proudstar = `CREATE UNIQUE INDEX \\`unique_schema_file_id\\` ON \\`models\\` (\\`schema_file_id\\`);--> statement-breakpoint\nCREATE UNIQUE INDEX \\`unique_property_schema_file_id\\` ON \\`properties\\` (\\`schema_file_id\\`);--> statement-breakpoint\nCREATE UNIQUE INDEX \\`unique_schema_schema_file_id\\` ON \\`schemas\\` (\\`schema_file_id\\`);`\n\nexport const migrationSql_0003_cultured_senator_kelly = `ALTER TABLE \\`models\\` ADD \\`is_edited\\` integer;--> statement-breakpoint\nALTER TABLE \\`properties\\` ADD \\`is_edited\\` integer;--> statement-breakpoint\nALTER TABLE \\`schemas\\` ADD \\`is_edited\\` integer;`\n\nexport const migrationSql_0004_add_publisher_to_seeds = `ALTER TABLE \\`seeds\\` ADD \\`publisher\\` text;`\n\nexport const migrationSql_0005_bright_lily_hollister = `CREATE TABLE \\`publish_processes\\` (\n\t\\`id\\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t\\`seed_local_id\\` text NOT NULL,\n\t\\`model_name\\` text NOT NULL,\n\t\\`schema_id\\` text,\n\t\\`status\\` text NOT NULL,\n\t\\`started_at\\` integer NOT NULL,\n\t\\`completed_at\\` integer,\n\t\\`error_message\\` text,\n\t\\`error_step\\` text,\n\t\\`error_details\\` text,\n\t\\`persisted_snapshot\\` text NOT NULL,\n\t\\`seed_id\\` text,\n\t\\`existing_seed_uid\\` text,\n\t\\`created_at\\` integer,\n\t\\`updated_at\\` integer\n);\n--> statement-breakpoint\nCREATE TABLE \\`upload_processes\\` (\n\t\\`id\\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t\\`reimbursement_confirmed\\` integer NOT NULL,\n\t\\`reimbursement_transaction_id\\` text,\n\t\\`transaction_keys\\` text,\n\t\\`persisted_snapshot\\` text NOT NULL,\n\t\\`created_at\\` integer,\n\t\\`updated_at\\` integer\n);\n`\n\nexport const migrationSql_0006_add_publisher_to_versions_and_metadata = `ALTER TABLE \\`versions\\` ADD \\`publisher\\` text;\n--> statement-breakpoint\nALTER TABLE \\`metadata\\` ADD \\`publisher\\` text;\n`\n\nexport const migrationSql_0007_add_required_to_properties = `ALTER TABLE \\`properties\\` ADD \\`required\\` integer DEFAULT 0;\n`\n\nexport const migrationSql_0008_add_revoked_at_to_seeds = `ALTER TABLE \\`seeds\\` ADD \\`revoked_at\\` integer;\n`\n\nexport const migrationSql_0009_happy_namor = `PRAGMA foreign_keys=OFF;--> statement-breakpoint\nCREATE TABLE \\`__new_property_uids\\` (\n\t\\`id\\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t\\`uid\\` text NOT NULL,\n\t\\`property_id\\` integer NOT NULL,\n\tFOREIGN KEY (\\`property_id\\`) REFERENCES \\`properties\\`(\\`id\\`) ON UPDATE no action ON DELETE no action\n);\n--> statement-breakpoint\nINSERT INTO \\`__new_property_uids\\`(\"id\", \"uid\", \"property_id\") SELECT \"id\", \"uid\", \"property_id\" FROM \\`property_uids\\`;--> statement-breakpoint\nDROP TABLE \\`property_uids\\`;--> statement-breakpoint\nALTER TABLE \\`__new_property_uids\\` RENAME TO \\`property_uids\\`;--> statement-breakpoint\nPRAGMA foreign_keys=ON;--> statement-breakpoint\nCREATE UNIQUE INDEX \\`property_uids_property_id_unique\\` ON \\`property_uids\\` (\\`property_id\\`);--> statement-breakpoint\nALTER TABLE \\`metadata\\` ADD \\`property_id\\` integer REFERENCES properties(id);`\n\n// Journal JSON file\nexport const journalJson = `{\n \"version\": \"7\",\n \"dialect\": \"sqlite\",\n \"entries\": [\n {\n \"idx\": 0,\n \"version\": \"6\",\n \"when\": 1765976502903,\n \"tag\": \"0000_married_malice\",\n \"breakpoints\": true\n },\n {\n \"idx\": 1,\n \"version\": \"6\",\n \"when\": 1766010851770,\n \"tag\": \"0001_sweet_bruce_banner\",\n \"breakpoints\": true\n },\n {\n \"idx\": 2,\n \"version\": \"6\",\n \"when\": 1767621120087,\n \"tag\": \"0002_bitter_proudstar\",\n \"breakpoints\": true\n },\n {\n \"idx\": 3,\n \"version\": \"6\",\n \"when\": 1768415440282,\n \"tag\": \"0003_cultured_senator_kelly\",\n \"breakpoints\": true\n },\n {\n \"idx\": 4,\n \"version\": \"6\",\n \"when\": 1768500000000,\n \"tag\": \"0004_add_publisher_to_seeds\",\n \"breakpoints\": true\n },\n {\n \"idx\": 5,\n \"version\": \"6\",\n \"when\": 1772489937031,\n \"tag\": \"0005_bright_lily_hollister\",\n \"breakpoints\": true\n },\n {\n \"idx\": 6,\n \"version\": \"6\",\n \"when\": 1772600000000,\n \"tag\": \"0006_add_publisher_to_versions_and_metadata\",\n \"breakpoints\": true\n },\n {\n \"idx\": 7,\n \"version\": \"6\",\n \"when\": 1772700000000,\n \"tag\": \"0007_add_required_to_properties\",\n \"breakpoints\": true\n },\n {\n \"idx\": 8,\n \"version\": \"6\",\n \"when\": 1772800000000,\n \"tag\": \"0008_add_revoked_at_to_seeds\",\n \"breakpoints\": true\n },\n {\n \"idx\": 9,\n \"version\": \"6\",\n \"when\": 1773924021107,\n \"tag\": \"0009_happy_namor\",\n \"breakpoints\": true\n }\n ]\n}`\n\n// Snapshot JSON file - this is large, so we'll import it dynamically if needed\n// For now, we'll read it from the actual file if ?raw works, otherwise we'll need to embed it\nexport const snapshotJson = `{\n \"version\": \"6\",\n \"dialect\": \"sqlite\",\n \"id\": \"ff040f54-6cfc-4d32-a572-2f08870c5b85\",\n \"prevId\": \"c8d9e0f1-a2b3-4c8d-9e0f-123456789012\",\n \"tables\": {\n \"appState\": {\n \"name\": \"appState\",\n \"columns\": {\n \"key\": {\n \"name\": \"key\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"value\": {\n \"name\": \"value\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"created_at\": {\n \"name\": \"created_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"updated_at\": {\n \"name\": \"updated_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n }\n },\n \"indexes\": {\n \"appState_key_unique\": {\n \"name\": \"appState_key_unique\",\n \"columns\": [\n \"key\"\n ],\n \"isUnique\": true\n }\n },\n \"foreignKeys\": {},\n \"compositePrimaryKeys\": {},\n \"uniqueConstraints\": {},\n \"checkConstraints\": {}\n },\n \"config\": {\n \"name\": \"config\",\n \"columns\": {\n \"id\": {\n \"name\": \"id\",\n \"type\": \"integer\",\n \"primaryKey\": true,\n \"notNull\": true,\n \"autoincrement\": true\n },\n \"key\": {\n \"name\": \"key\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"text\": {\n \"name\": \"text\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"json\": {\n \"name\": \"json\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"blob\": {\n \"name\": \"blob\",\n \"type\": \"blob\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n }\n },\n \"indexes\": {},\n \"foreignKeys\": {},\n \"compositePrimaryKeys\": {},\n \"uniqueConstraints\": {},\n \"checkConstraints\": {}\n },\n \"metadata\": {\n \"name\": \"metadata\",\n \"columns\": {\n \"local_id\": {\n \"name\": \"local_id\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"uid\": {\n \"name\": \"uid\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"property_id\": {\n \"name\": \"property_id\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"property_name\": {\n \"name\": \"property_name\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"property_value\": {\n \"name\": \"property_value\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"schema_uid\": {\n \"name\": \"schema_uid\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"model_type\": {\n \"name\": \"model_type\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"seed_local_id\": {\n \"name\": \"seed_local_id\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"seed_uid\": {\n \"name\": \"seed_uid\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"version_local_id\": {\n \"name\": \"version_local_id\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"version_uid\": {\n \"name\": \"version_uid\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"eas_data_type\": {\n \"name\": \"eas_data_type\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"ref_value_type\": {\n \"name\": \"ref_value_type\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"ref_schema_uid\": {\n \"name\": \"ref_schema_uid\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"ref_seed_type\": {\n \"name\": \"ref_seed_type\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"ref_resolved_value\": {\n \"name\": \"ref_resolved_value\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"ref_resolved_display_value\": {\n \"name\": \"ref_resolved_display_value\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"local_storage_dir\": {\n \"name\": \"local_storage_dir\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"attestation_raw\": {\n \"name\": \"attestation_raw\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"attestation_created_at\": {\n \"name\": \"attestation_created_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"content_hash\": {\n \"name\": \"content_hash\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"created_at\": {\n \"name\": \"created_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"updated_at\": {\n \"name\": \"updated_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"publisher\": {\n \"name\": \"publisher\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n }\n },\n \"indexes\": {\n \"metadata_local_id_unique\": {\n \"name\": \"metadata_local_id_unique\",\n \"columns\": [\n \"local_id\"\n ],\n \"isUnique\": true\n }\n },\n \"foreignKeys\": {\n \"metadata_property_id_properties_id_fk\": {\n \"name\": \"metadata_property_id_properties_id_fk\",\n \"tableFrom\": \"metadata\",\n \"tableTo\": \"properties\",\n \"columnsFrom\": [\n \"property_id\"\n ],\n \"columnsTo\": [\n \"id\"\n ],\n \"onDelete\": \"no action\",\n \"onUpdate\": \"no action\"\n }\n },\n \"compositePrimaryKeys\": {},\n \"uniqueConstraints\": {},\n \"checkConstraints\": {}\n },\n \"models\": {\n \"name\": \"models\",\n \"columns\": {\n \"id\": {\n \"name\": \"id\",\n \"type\": \"integer\",\n \"primaryKey\": true,\n \"notNull\": true,\n \"autoincrement\": true\n },\n \"name\": {\n \"name\": \"name\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"schema_file_id\": {\n \"name\": \"schema_file_id\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"is_edited\": {\n \"name\": \"is_edited\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n }\n },\n \"indexes\": {\n \"unique_schema_file_id\": {\n \"name\": \"unique_schema_file_id\",\n \"columns\": [\n \"schema_file_id\"\n ],\n \"isUnique\": true\n }\n },\n \"foreignKeys\": {},\n \"compositePrimaryKeys\": {},\n \"uniqueConstraints\": {},\n \"checkConstraints\": {}\n },\n \"properties\": {\n \"name\": \"properties\",\n \"columns\": {\n \"id\": {\n \"name\": \"id\",\n \"type\": \"integer\",\n \"primaryKey\": true,\n \"notNull\": true,\n \"autoincrement\": true\n },\n \"name\": {\n \"name\": \"name\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"data_type\": {\n \"name\": \"data_type\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"model_id\": {\n \"name\": \"model_id\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"ref_model_id\": {\n \"name\": \"ref_model_id\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"ref_value_type\": {\n \"name\": \"ref_value_type\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"schema_file_id\": {\n \"name\": \"schema_file_id\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"is_edited\": {\n \"name\": \"is_edited\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"required\": {\n \"name\": \"required\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n }\n },\n \"indexes\": {\n \"unique_name_model_id\": {\n \"name\": \"unique_name_model_id\",\n \"columns\": [\n \"name\",\n \"model_id\"\n ],\n \"isUnique\": true\n },\n \"unique_property_schema_file_id\": {\n \"name\": \"unique_property_schema_file_id\",\n \"columns\": [\n \"schema_file_id\"\n ],\n \"isUnique\": true\n }\n },\n \"foreignKeys\": {\n \"properties_model_id_models_id_fk\": {\n \"name\": \"properties_model_id_models_id_fk\",\n \"tableFrom\": \"properties\",\n \"tableTo\": \"models\",\n \"columnsFrom\": [\n \"model_id\"\n ],\n \"columnsTo\": [\n \"id\"\n ],\n \"onDelete\": \"no action\",\n \"onUpdate\": \"no action\"\n },\n \"properties_ref_model_id_models_id_fk\": {\n \"name\": \"properties_ref_model_id_models_id_fk\",\n \"tableFrom\": \"properties\",\n \"tableTo\": \"models\",\n \"columnsFrom\": [\n \"ref_model_id\"\n ],\n \"columnsTo\": [\n \"id\"\n ],\n \"onDelete\": \"no action\",\n \"onUpdate\": \"no action\"\n }\n },\n \"compositePrimaryKeys\": {},\n \"uniqueConstraints\": {},\n \"checkConstraints\": {}\n },\n \"model_schemas\": {\n \"name\": \"model_schemas\",\n \"columns\": {\n \"id\": {\n \"name\": \"id\",\n \"type\": \"integer\",\n \"primaryKey\": true,\n \"notNull\": true,\n \"autoincrement\": true\n },\n \"model_id\": {\n \"name\": \"model_id\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"schema_id\": {\n \"name\": \"schema_id\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n }\n },\n \"indexes\": {},\n \"foreignKeys\": {\n \"model_schemas_model_id_models_id_fk\": {\n \"name\": \"model_schemas_model_id_models_id_fk\",\n \"tableFrom\": \"model_schemas\",\n \"tableTo\": \"models\",\n \"columnsFrom\": [\n \"model_id\"\n ],\n \"columnsTo\": [\n \"id\"\n ],\n \"onDelete\": \"no action\",\n \"onUpdate\": \"no action\"\n },\n \"model_schemas_schema_id_schemas_id_fk\": {\n \"name\": \"model_schemas_schema_id_schemas_id_fk\",\n \"tableFrom\": \"model_schemas\",\n \"tableTo\": \"schemas\",\n \"columnsFrom\": [\n \"schema_id\"\n ],\n \"columnsTo\": [\n \"id\"\n ],\n \"onDelete\": \"no action\",\n \"onUpdate\": \"no action\"\n }\n },\n \"compositePrimaryKeys\": {},\n \"uniqueConstraints\": {},\n \"checkConstraints\": {}\n },\n \"model_uids\": {\n \"name\": \"model_uids\",\n \"columns\": {\n \"id\": {\n \"name\": \"id\",\n \"type\": \"integer\",\n \"primaryKey\": true,\n \"notNull\": true,\n \"autoincrement\": true\n },\n \"uid\": {\n \"name\": \"uid\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"model_id\": {\n \"name\": \"model_id\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n }\n },\n \"indexes\": {\n \"model_uids_model_id_unique\": {\n \"name\": \"model_uids_model_id_unique\",\n \"columns\": [\n \"model_id\"\n ],\n \"isUnique\": true\n }\n },\n \"foreignKeys\": {\n \"model_uids_model_id_models_id_fk\": {\n \"name\": \"model_uids_model_id_models_id_fk\",\n \"tableFrom\": \"model_uids\",\n \"tableTo\": \"models\",\n \"columnsFrom\": [\n \"model_id\"\n ],\n \"columnsTo\": [\n \"id\"\n ],\n \"onDelete\": \"no action\",\n \"onUpdate\": \"no action\"\n }\n },\n \"compositePrimaryKeys\": {},\n \"uniqueConstraints\": {},\n \"checkConstraints\": {}\n },\n \"property_uids\": {\n \"name\": \"property_uids\",\n \"columns\": {\n \"id\": {\n \"name\": \"id\",\n \"type\": \"integer\",\n \"primaryKey\": true,\n \"notNull\": true,\n \"autoincrement\": true\n },\n \"uid\": {\n \"name\": \"uid\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"property_id\": {\n \"name\": \"property_id\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n }\n },\n \"indexes\": {\n \"property_uids_property_id_unique\": {\n \"name\": \"property_uids_property_id_unique\",\n \"columns\": [\n \"property_id\"\n ],\n \"isUnique\": true\n }\n },\n \"foreignKeys\": {\n \"property_uids_property_id_properties_id_fk\": {\n \"name\": \"property_uids_property_id_properties_id_fk\",\n \"tableFrom\": \"property_uids\",\n \"tableTo\": \"properties\",\n \"columnsFrom\": [\n \"property_id\"\n ],\n \"columnsTo\": [\n \"id\"\n ],\n \"onDelete\": \"no action\",\n \"onUpdate\": \"no action\"\n }\n },\n \"compositePrimaryKeys\": {},\n \"uniqueConstraints\": {},\n \"checkConstraints\": {}\n },\n \"publish_processes\": {\n \"name\": \"publish_processes\",\n \"columns\": {\n \"id\": {\n \"name\": \"id\",\n \"type\": \"integer\",\n \"primaryKey\": true,\n \"notNull\": true,\n \"autoincrement\": true\n },\n \"seed_local_id\": {\n \"name\": \"seed_local_id\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"model_name\": {\n \"name\": \"model_name\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"schema_id\": {\n \"name\": \"schema_id\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"status\": {\n \"name\": \"status\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"started_at\": {\n \"name\": \"started_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"completed_at\": {\n \"name\": \"completed_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"error_message\": {\n \"name\": \"error_message\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"error_step\": {\n \"name\": \"error_step\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"error_details\": {\n \"name\": \"error_details\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"persisted_snapshot\": {\n \"name\": \"persisted_snapshot\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"seed_id\": {\n \"name\": \"seed_id\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"existing_seed_uid\": {\n \"name\": \"existing_seed_uid\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"created_at\": {\n \"name\": \"created_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"updated_at\": {\n \"name\": \"updated_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n }\n },\n \"indexes\": {},\n \"foreignKeys\": {},\n \"compositePrimaryKeys\": {},\n \"uniqueConstraints\": {},\n \"checkConstraints\": {}\n },\n \"schemas\": {\n \"name\": \"schemas\",\n \"columns\": {\n \"id\": {\n \"name\": \"id\",\n \"type\": \"integer\",\n \"primaryKey\": true,\n \"notNull\": true,\n \"autoincrement\": true\n },\n \"name\": {\n \"name\": \"name\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"version\": {\n \"name\": \"version\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"schema_file_id\": {\n \"name\": \"schema_file_id\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"schema_data\": {\n \"name\": \"schema_data\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"is_draft\": {\n \"name\": \"is_draft\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"is_edited\": {\n \"name\": \"is_edited\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"created_at\": {\n \"name\": \"created_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"updated_at\": {\n \"name\": \"updated_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n }\n },\n \"indexes\": {\n \"unique_schema_schema_file_id\": {\n \"name\": \"unique_schema_schema_file_id\",\n \"columns\": [\n \"schema_file_id\"\n ],\n \"isUnique\": true\n }\n },\n \"foreignKeys\": {},\n \"compositePrimaryKeys\": {},\n \"uniqueConstraints\": {},\n \"checkConstraints\": {}\n },\n \"seeds\": {\n \"name\": \"seeds\",\n \"columns\": {\n \"local_id\": {\n \"name\": \"local_id\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"uid\": {\n \"name\": \"uid\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"schema_uid\": {\n \"name\": \"schema_uid\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"type\": {\n \"name\": \"type\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"publisher\": {\n \"name\": \"publisher\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"attestation_raw\": {\n \"name\": \"attestation_raw\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"attestation_created_at\": {\n \"name\": \"attestation_created_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"created_at\": {\n \"name\": \"created_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"updated_at\": {\n \"name\": \"updated_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"_marked_for_deletion\": {\n \"name\": \"_marked_for_deletion\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"revoked_at\": {\n \"name\": \"revoked_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n }\n },\n \"indexes\": {\n \"seeds_local_id_unique\": {\n \"name\": \"seeds_local_id_unique\",\n \"columns\": [\n \"local_id\"\n ],\n \"isUnique\": true\n }\n },\n \"foreignKeys\": {},\n \"compositePrimaryKeys\": {},\n \"uniqueConstraints\": {},\n \"checkConstraints\": {}\n },\n \"upload_processes\": {\n \"name\": \"upload_processes\",\n \"columns\": {\n \"id\": {\n \"name\": \"id\",\n \"type\": \"integer\",\n \"primaryKey\": true,\n \"notNull\": true,\n \"autoincrement\": true\n },\n \"reimbursement_confirmed\": {\n \"name\": \"reimbursement_confirmed\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"reimbursement_transaction_id\": {\n \"name\": \"reimbursement_transaction_id\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"transaction_keys\": {\n \"name\": \"transaction_keys\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"persisted_snapshot\": {\n \"name\": \"persisted_snapshot\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": true,\n \"autoincrement\": false\n },\n \"created_at\": {\n \"name\": \"created_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"updated_at\": {\n \"name\": \"updated_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n }\n },\n \"indexes\": {},\n \"foreignKeys\": {},\n \"compositePrimaryKeys\": {},\n \"uniqueConstraints\": {},\n \"checkConstraints\": {}\n },\n \"versions\": {\n \"name\": \"versions\",\n \"columns\": {\n \"local_id\": {\n \"name\": \"local_id\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"uid\": {\n \"name\": \"uid\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"seed_local_id\": {\n \"name\": \"seed_local_id\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"seed_uid\": {\n \"name\": \"seed_uid\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"seed_type\": {\n \"name\": \"seed_type\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"note\": {\n \"name\": \"note\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"created_at\": {\n \"name\": \"created_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"updated_at\": {\n \"name\": \"updated_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"attestation_created_at\": {\n \"name\": \"attestation_created_at\",\n \"type\": \"integer\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"attestation_raw\": {\n \"name\": \"attestation_raw\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n },\n \"publisher\": {\n \"name\": \"publisher\",\n \"type\": \"text\",\n \"primaryKey\": false,\n \"notNull\": false,\n \"autoincrement\": false\n }\n },\n \"indexes\": {\n \"versions_local_id_unique\": {\n \"name\": \"versions_local_id_unique\",\n \"columns\": [\n \"local_id\"\n ],\n \"isUnique\": true\n }\n },\n \"foreignKeys\": {},\n \"compositePrimaryKeys\": {},\n \"uniqueConstraints\": {},\n \"checkConstraints\": {}\n }\n },\n \"views\": {},\n \"enums\": {},\n \"_meta\": {\n \"schemas\": {},\n \"tables\": {},\n \"columns\": {}\n },\n \"internal\": {\n \"indexes\": {}\n }\n}`\n","import { BaseDb } from \"@/db/Db/BaseDb\";\nimport { IDb } from \"@/interfaces/IDb\";\nimport debug from \"debug\";\nimport { sql } from \"drizzle-orm\";\nimport { readMigrationFiles } from \"drizzle-orm/migrator\";\nimport { drizzle, SqliteRemoteDatabase } from \"drizzle-orm/sqlite-proxy\";\nimport { migrate as drizzleMigrate } from \"drizzle-orm/sqlite-proxy/migrator\";\nimport { BROWSER_FS_TOP_DIR } from \"@/client/constants\";\nimport { BaseFileManager } from \"@/helpers\";\nimport * as schema from '@/seedSchema'\n// @ts-ignore - sqlocal/drizzle types may not be available during build\nimport { SQLocalDrizzle } from 'sqlocal/drizzle'\nimport {} from 'sqlocal'\nimport * as drizzleFiles from './drizzleFiles'\nimport { journalJson, snapshotJson } from './drizzleFiles'\nimport { Observable, distinctUntilChanged } from 'rxjs'\n\nconst logger = debug('seedSdk:browser:db:Db')\n\n\nclass Db extends BaseDb implements IDb {\n\n static sqliteWasmClient: any\n static filesDir: string | undefined\n static pathToDb: string | undefined\n static dbId: string | undefined\n static appDb: SqliteRemoteDatabase<Record<string, unknown>> | undefined\n static sqlocalInstance: SQLocalDrizzle | undefined\n\n constructor() {\n super()\n }\n\n static getAppDb() {\n return this.appDb\n }\n\n static isAppDbReady() {\n return !!this.appDb\n }\n\n static async prepareDb(filesDir: string) {\n\n logger('[Db.prepareDb] preparing database')\n\n this.filesDir = filesDir\n\n try {\n // Copy drizzle migration files from src/db/drizzle to filesDir/db\n await this.copyDrizzleFiles(filesDir)\n\n // Ensure meta directory exists\n const metaDirPath = `${filesDir}/db/meta`\n await BaseFileManager.createDirIfNotExists(metaDirPath)\n\n // Ensure _journal.json file exists in meta directory\n const journalFilePath = `${metaDirPath}/_journal.json`\n const journalExists = await BaseFileManager.pathExists(journalFilePath)\n if (!journalExists) {\n await BaseFileManager.saveFile(journalFilePath, JSON.stringify({\n version: 1,\n dialect: 'sqlite',\n entries: [],\n }, null, 2))\n }\n\n // Wait for journal file to be fully written before proceeding with migration\n // This is critical in browser/OPFS where writes may not be immediately readable\n logger('[Db.prepareDb] waiting for journal file to be fully written...')\n await BaseFileManager.waitForFileWithContent(journalFilePath, 100, 5000)\n logger('[Db.prepareDb] journal file is ready')\n\n // Initialize SQLocalDrizzle with reactive: true to enable reactive queries\n const sqlocalDrizzle = new SQLocalDrizzle({\n databasePath: `${this.filesDir}/db/seed.db`,\n reactive: true // Enable reactive queries\n })\n \n const { driver, batchDriver } = sqlocalDrizzle\n \n // Store SQLocalDrizzle instance for reactive queries\n this.sqlocalInstance = sqlocalDrizzle\n\n // Create db instance but do NOT set this.appDb yet. restoreFromDb (and other\n // callers of getAppDb()) must not see the db until migrations have completed,\n // otherwise they may query tables (e.g. publish_processes) that don't exist yet.\n const db = drizzle(\n driver,\n batchDriver,\n {\n schema,\n }\n )\n\n logger('[Db.prepareDb] database prepared')\n\n await this.runMigrations(db)\n\n this.appDb = db\n\n const { backfillMetadataPropertyIds } = await import('@/db/backfillMetadataPropertyIds')\n await backfillMetadataPropertyIds()\n\n return this.appDb\n } catch (error) {\n logger('[Db.prepareDb] error', JSON.stringify(error))\n throw error\n }\n }\n\n // static async prepareDb(filesDir: string) {\n // console.log('prepareDb', filesDir)\n // if (Db.sqliteWasmClient) {\n // return this.dbId\n // }\n\n // this.filesDir = filesDir\n // this.pathToDb = `${filesDir}/db/${DB_NAME_APP}.db`\n\n // if (typeof document === 'undefined') {\n // return\n // }\n\n // let promiser\n\n // try {\n\n // let sqlite3Worker1Promiser\n\n // const sqliteWasm = await import('@sqlite.org/sqlite-wasm')\n\n // if (sqliteWasm && sqliteWasm.sqlite3Worker1Promiser) {\n // sqlite3Worker1Promiser = sqliteWasm.sqlite3Worker1Promiser\n // }\n\n // if (!sqlite3Worker1Promiser && window.sqlite3Worker1Promiser) {\n // sqlite3Worker1Promiser = window.sqlite3Worker1Promiser\n // }\n\n // if (!sqlite3Worker1Promiser) {\n // throw new Error('Failed to load sqlite3Worker1Promiser')\n // }\n\n // promiser = await new Promise<(event: string, config: Record<string, unknown>) => Promise<any>>((resolve) => {\n // const _promiser = sqlite3Worker1Promiser({\n // onready: () => {\n // resolve(_promiser);\n // },\n // });\n // }).catch((error) => {\n // console.error('Error from sqlite proxy server: ', JSON.stringify(error))\n // });\n\n // } catch ( e ) {\n // console.error('Error from sqlite proxy server: ', JSON.stringify(e))\n // }\n\n\n // if (!promiser) {\n // throw new Error('Failed to create promiser')\n // }\n\n // this.sqliteWasmClient = promiser\n\n // const responseGet = await this.sqliteWasmClient('config-get', {});\n\n // logger('[Db.prepareDb] Running SQLite3 version', responseGet.result.version.libVersion);\n\n // const responseOpen = await this.sqliteWasmClient('open', {\n // filename: `file:${filesDir}/db/${DB_NAME_APP}.db?vfs=opfs`,\n // });\n // const { dbId } = responseOpen;\n // logger(\n // '[Db.prepareDb] OPFS is available, created persisted database at',\n // responseOpen.result.filename.replace(/^file:(.*?)\\?vfs=opfs/, '$1'),\n // );\n\n // logger('[Db.prepareDb] dbId', dbId)\n \n // this.dbId = dbId\n \n // await this.migrate()\n // }\n\n static async connectToDb(filesDir: string,): Promise<string | undefined> {\n\n\n\n return this.dbId\n }\n\n static async copyDrizzleFiles(filesDir: string): Promise<void> {\n logger('[Db.copyDrizzleFiles] copying drizzle migration files')\n\n try {\n // Ensure db directory exists\n const dbDirPath = `${filesDir}/db`\n await BaseFileManager.createDirIfNotExists(dbDirPath)\n\n // Ensure meta directory exists\n const metaDirPath = `${dbDirPath}/meta`\n await BaseFileManager.createDirIfNotExists(metaDirPath)\n\n // Parse journal JSON to get all migration entries\n const journal = JSON.parse(journalJson)\n const entries = journal.entries || []\n\n if (entries.length === 0) {\n logger('[Db.copyDrizzleFiles] no migration entries found in journal')\n return\n }\n\n // Copy each migration SQL file (always overwrite to ensure they're up-to-date)\n // Each migration is exported as a separate variable (e.g., migrationSql_0000_married_malice)\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i]\n const tag = entry.tag // e.g., \"0000_married_malice\"\n const migrationFileName = `${tag}.sql`\n const migrationPath = `${dbDirPath}/${migrationFileName}`\n \n // Get the SQL for this migration from the exported variable\n const migrationVarName = `migrationSql_${tag}` as keyof typeof drizzleFiles\n const migrationContent = drizzleFiles[migrationVarName] as string | undefined\n \n if (!migrationContent) {\n logger(`[Db.copyDrizzleFiles] ERROR: No migration content found for ${migrationFileName} (variable: ${migrationVarName})`)\n throw new Error(`No migration content found for ${migrationFileName}. Expected variable: ${migrationVarName}`)\n }\n \n await BaseFileManager.saveFile(migrationPath, migrationContent.trim())\n logger(`[Db.copyDrizzleFiles] copied/updated migration SQL file: ${migrationFileName}`)\n }\n\n // Copy journal JSON file (always overwrite to ensure it's up-to-date with all migrations)\n const journalPath = `${metaDirPath}/_journal.json`\n await BaseFileManager.saveFile(journalPath, journalJson)\n logger('[Db.copyDrizzleFiles] copied/updated journal JSON file')\n\n // Copy snapshot JSON file (use the latest snapshot based on the highest idx in journal)\n // Snapshot files are named like: 0000_snapshot.json, 0001_snapshot.json, etc.\n // The tag format is like \"0000_married_malice\", so we extract the numeric prefix\n const latestEntry = entries[entries.length - 1]\n const tagPrefixMatch = latestEntry.tag.match(/^(\\d+_)/)\n const tagPrefix = tagPrefixMatch ? tagPrefixMatch[1] : '0000_'\n const snapshotFileName = `${tagPrefix}snapshot.json`\n const snapshotPath = `${metaDirPath}/${snapshotFileName}`\n // Always overwrite snapshot to ensure it's up-to-date\n await BaseFileManager.saveFile(snapshotPath, snapshotJson)\n logger(`[Db.copyDrizzleFiles] copied/updated snapshot JSON file: ${snapshotFileName}`)\n\n logger('[Db.copyDrizzleFiles] drizzle files copied successfully')\n } catch (error) {\n logger('[Db.copyDrizzleFiles] error copying drizzle files', error)\n // Don't throw - the files might already exist or migration might work without them\n // The migration will fail later if the files are truly needed\n }\n }\n\n /** Internal migration runner. Used by prepareDb before appDb is set. */\n private static async runMigrations(\n db: SqliteRemoteDatabase<Record<string, unknown>>,\n pathToDbDir?: string\n ): Promise<void> {\n const migrationsFolder = pathToDbDir ?? `${this.filesDir}/db`\n\n try {\n logger('[Db.runMigrations] calling readMigrationFiles')\n const migrations = readMigrationFiles({\n migrationsFolder,\n })\n logger('[Db.runMigrations] migrations', migrations)\n\n await drizzleMigrate(\n db,\n async (queriesToRun) => {\n logger('queriesToRun', queriesToRun)\n for (const query of queriesToRun) {\n logger('query', query)\n await db.run(sql.raw(query))\n }\n },\n {\n migrationsFolder,\n },\n )\n logger('[Db.runMigrations] migrations completed')\n } catch (error) {\n logger('[Db.runMigrations] error', JSON.stringify(error))\n throw error\n }\n }\n\n static async migrate(pathToDbDir: string, _dbName: string, _dbId: string): Promise<void> {\n const targetDb = this.appDb\n if (!targetDb) {\n throw new Error('Database not prepared')\n }\n await this.runMigrations(targetDb, pathToDbDir)\n }\n\n // static async migrate(): Promise<void> {\n\n // const schemaGlobString = `${BROWSER_FS_TOP_DIR}/schema/*`\n // const pathToDbDir = `${this.filesDir}/db`\n // const dbName = DB_NAME_APP\n\n // logger('[Db.migrate] running migrations')\n\n // const drizzleDb = drizzle(\n // async (sql, params,) => {\n // try {\n // logger(\n // `executing sql`,\n // sql,\n // )\n\n // const finalResult = await this.exec(sql, params)\n\n // // logger(`finalResult with method: ${method}`, finalResult)\n // // Drizzle always waits for {rows: string[][]} or {rows: string[]} for the return value.\n\n // // When the method is get, you should return a value as {rows: string[]}.\n // // Otherwise, you should return {rows: string[][]}.\n\n // return { rows: finalResult }\n // } catch (e: any) {\n // console.error('Error from sqlite proxy server: ', JSON.stringify(e))\n // return { rows: [] }\n // }\n // },\n // {\n // schema,\n // // logger: true,\n // },\n // )\n\n // try {\n // const zenfs = await BaseFileManager.getFs()\n\n // logger('[Db.migrate] calling readMigrationFiles')\n\n // const migrations = readMigrationFiles({\n // migrationsFolder: pathToDbDir,\n // })\n\n // logger('[Db.migrate] migrations', migrations)\n\n // if (migrations.length > 0) {\n // const incomingMigrationHashes = migrations.map(\n // (migration) => migration.hash,\n // )\n\n // let existingMigrationHashes\n // let rows = []\n\n // try {\n\n // const queryMigrationsTable = await drizzleDb.run(\n // sql.raw(\n // `SELECT name \n // FROM sqlite_master \n // WHERE type='table' \n // AND name='__drizzle_migrations';`,\n // ),\n // )\n\n // logger('queryMigrationsTable', queryMigrationsTable)\n\n // if (queryMigrationsTable && queryMigrationsTable.rows && queryMigrationsTable.rows.length > 0) {\n // const query = await drizzleDb.run(\n // sql.raw(\n // `SELECT hash, created_at\n // FROM main.__drizzle_migrations;`,\n // ),\n // )\n \n // rows = query.rows\n // }\n\n // } catch (e) {\n // rows = []\n // }\n\n // if (rows && rows.length > 0) {\n // existingMigrationHashes = rows.map((row) => row[0])\n // }\n\n // if (existingMigrationHashes) {\n // let shouldRebuildDb = false\n // for (const existingHash of existingMigrationHashes) {\n // if (!incomingMigrationHashes.includes(existingHash)) {\n // shouldRebuildDb = true\n // break\n // }\n // }\n // if (shouldRebuildDb) {\n // await zenfs.promises.unlink(`${pathToDbDir}/${dbName}.db`)\n // }\n // }\n // }\n\n // logger('[Db.migrate] running migrations')\n\n // await drizzleMigrate(\n // drizzleDb,\n // async (queriesToRun) => {\n // // logger('queriesToRun', queriesToRun)\n // for (const query of queriesToRun) {\n // // logger('query', query)\n // await drizzleDb.run(sql.raw(query))\n // }\n // },\n // {\n // migrationsFolder: pathToDbDir,\n // },\n // )\n // } catch (error) {\n // logger('[Db.migrate] error', JSON.stringify(error))\n // // await BaseFileManager.waitForFile(`${pathToDbDir}/meta/_journal.json`)\n\n // // const journalExists = await BaseFileManager.pathExists(\n // // `${pathToDbDir}/meta/_journal.json`,\n // // )\n\n // // if (journalExists) {\n // // await this.migrate(pathToDbDir, dbName,)\n // // }\n\n // // if (!journalExists) {\n // // throw new Error('Failed to migrate database')\n // // }\n\n\n // }\n\n // this.appDb = drizzleDb\n\n // // Old code for migrating the database\n // // const createTempTableQuery = await appDb.run(\n // // sql.raw(\n // // `CREATE TEMP TABLE IF NOT EXISTS temp_last_inserted_id (id INTEGER, table TEXT);`,\n // // ),\n // // )\n // //\n // // logger(\n // // '[db/actors] [migrate] createTempTableQuery',\n // // createTempTableQuery,\n // // )\n\n // // const triggersQuery = await appDb.run(\n // // sql.raw(\n // // `SELECT name\n // // FROM main.sqlite_master\n // // WHERE type = 'trigger';`,\n // // ),\n // // )\n // //\n // // logger('[db/actors] [migrate] triggersQuery', triggersQuery)\n // //\n // // const triggers = triggersQuery.rows.map((row) => row[0])\n // //\n // // const tablesQuery = await appDb.run(\n // // sql.raw(\n // // `SELECT name\n // // FROM main.sqlite_master\n // // WHERE type = 'table';`,\n // // ),\n // // )\n // //\n // // logger('[db/actors] [migrate] tablesQuery', tablesQuery)\n // //\n // // const tableNames = tablesQuery.rows.map((row) => row[0])\n // // logger('[db/actors] [migrate] tableNames', tableNames)\n // // for (const tableName of tableNames) {\n // // const triggerName = `after_insert_${tableName}`\n // // if (triggers.includes(triggerName)) {\n // // continue\n // // }\n // // const createTriggerQuery = await appDb.run(\n // // sql.raw(\n // // `CREATE TRIGGER after_insert_${tableName}\n // // AFTER INSERT ON ${tableName}\n // // BEGIN\n // // DELETE FROM temp_last_inserted_id;\n // // INSERT INTO temp_last_inserted_id (id) VALUES (new.id);\n // // END;`,\n // // ),\n // // )\n // //\n // // logger(\n // // '[db/actors] [migrate] createTriggerQuery',\n // // createTriggerQuery,\n // // )\n // // }\n // }\n\n // static async exec(sql: string, params: any[]) {\n // const rowsToReturnRaw: SqliteWasmResult[] = []\n // const rowsValues: string[][] = []\n \n // // For a single exec command, the callback potentially gets called several times -- once for each row.\n // // So we need to collect all rows into a final array to return (execResult).\n // const rowsToReturn = await new Promise((resolve, reject) => {\n\n\n // this.sqliteWasmClient('exec', {\n // dbId:this.dbId,\n // sql,\n // bind: params,\n // callback: (result) => {\n // // Checks if this is the final callback of the query\n // if (!result || !result.row || !result.rowNumber) {\n // const returnResult = []\n // for (const currRow of rowsToReturnRaw) {\n // returnResult.push(currRow.row)\n // }\n // resolve(returnResult)\n // } else {\n // // If not the final response, add this row to the return array\n // rowsToReturnRaw.push(result)\n // }\n // },\n // }).catch(async (error) => {\n // reject(error)\n // })\n // })\n \n // return rowsToReturn || []\n // }\n\n /**\n * Execute a reactive query that emits new results whenever the underlying data changes.\n * \n * Supports two usage patterns:\n * 1. SQL tag function: liveQuery((sql) => sql`SELECT * FROM models`)\n * 2. Drizzle query builder: liveQuery(db.select().from(models))\n * \n * @param query - SQL query function or Drizzle query builder\n * @returns Observable that emits arrays of query results\n * \n * @example\n * ```typescript\n * // Using SQL tag function\n * const models$ = Db.liveQuery<ModelRow>(\n * (sql) => sql`SELECT * FROM models WHERE schema_file_id = ${schemaId}`\n * )\n * \n * // Using Drizzle query builder\n * const models$ = Db.liveQuery<ModelRow>(\n * appDb.select().from(models).where(eq(models.schemaFileId, schemaId))\n * )\n * \n * models$.subscribe(models => {\n * console.log('Models updated:', models)\n * })\n * ```\n */\n static liveQuery<T>(\n query: ((sql: any) => any) | any\n ): Observable<T[]> {\n if (!this.sqlocalInstance) {\n throw new Error('Database not initialized. Call prepareDb first.')\n }\n \n if (!this.sqlocalInstance.reactiveQuery) {\n throw new Error('Reactive queries not enabled. Initialize SQLocalDrizzle with reactive: true.')\n }\n\n const baseObservable = new Observable<T[]>((subscriber) => {\n const reactiveQueryResult = this.sqlocalInstance!.reactiveQuery(query)\n\n const subscription = reactiveQueryResult.subscribe(\n (data: Record<string, any>[]) => {\n subscriber.next(data as T[])\n },\n (err: Error) => {\n console.error('[BaseDb.liveQuery] SQLocal reactiveQuery error:', err)\n subscriber.error(err)\n }\n )\n\n return () => {\n subscription.unsubscribe()\n }\n })\n\n // Compare stable JSON snapshots via keySelector. SQLocal may reuse one array reference\n // and mutate rows in place; comparing (prev, curr) on the same reference makes\n // JSON.stringify(prev) === JSON.stringify(curr) after mutation and suppresses emissions.\n return baseObservable.pipe(\n distinctUntilChanged(\n (a, b) => a === b,\n (x: T[]) => JSON.stringify(x)\n )\n )\n }\n}\n\nexport { Db }\n"],"names":["drizzleMigrate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAEA;AACO,MAAM,gCAAgC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iFAwHiC;AAE1E,MAAM,oCAAoC,GAAG,CAAA;kDACF;AAE3C,MAAM,kCAAkC,GAAG,CAAA;;0FAEwC;AAEnF,MAAM,wCAAwC,GAAG,CAAA;;mDAEL;AAE5C,MAAM,wCAAwC,GAAG,+CAA+C;AAEhG,MAAM,uCAAuC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BtD;AAEM,MAAM,wDAAwD,GAAG,CAAA;;;CAGvE;AAEM,MAAM,4CAA4C,GAAG,CAAA;CAC3D;AAEM,MAAM,yCAAyC,GAAG,CAAA;CACxD;AAEM,MAAM,6BAA6B,GAAG,CAAA;;;;;;;;;;;;;gFAamC;AAEhF;AACO,MAAM,WAAW,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2EzB;AAEF;AACA;AACO,MAAM,YAAY,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AY,CAAC,WAAW,EAAE;AAC5B,YAAA,CAAC;AACH,QAAA,CAAC,CAAC;;;;AAKF,QAAA,OAAO,cAAc,CAAC,IAAI,CACxB,oBAAoB,CAClB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EACjB,CAAC,CAAM,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAC9B,CACF;IACH;AACD;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPublishPayload-muuS1j0F.js","sources":["../../../src/db/read/getPublishPayload.ts"],"sourcesContent":["// Dynamic import to break circular dependency with getItem -> BaseItem\n// import { getItem } from '@/db/read/getItem'\nimport {\n defaultAttestationData,\n INTERNAL_DATA_TYPES,\n INTERNAL_PROPERTY_NAMES,\n VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n ZERO_BYTES32,\n} from '@/helpers/constants'\nimport {\n AttestationRequest,\n AttestationRequestData,\n} from '@ethereum-attestation-service/eas-sdk'\n\nimport { getEasSchemaForItemProperty } from '@/helpers/getSchemaForItemProperty'\nimport { toSnakeCase } from '@/helpers'\nimport { toSnakeCase as toSnakeCaseDb } from 'drizzle-orm/casing'\nimport pluralize from 'pluralize'\nimport { getEasSchemaUidForModel } from './getSchemaUidForModel'\nimport { getEasSchemaUidForSchemaDefinition } from '@/stores/eas'\nimport { getCorrectId } from '@/helpers'\nimport {\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '@/helpers/relationSeedRef'\nimport { parseListPropertyValueFromStorage } from '@/helpers/listPropertyValueFromStorage'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport { getPropertySchema } from '@/helpers/property'\nimport { modelPropertiesToObject } from '@/helpers/model'\nimport { IItemProperty } from '@/interfaces'\nimport { camelCase, upperFirst } from 'lodash-es'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { models, properties, versions } from '@/seedSchema'\nimport { eq, and, desc } from 'drizzle-orm'\nimport { IItem } from '@/interfaces'\nimport debug from 'debug'\nimport {ethers} from 'ethers'\nimport { ModelPropertyDataTypes } from '@/Schema'\nimport type { ValidationError } from '@/Schema/validation'\nconst logger = debug('seedSdk:db:getPublishPayload')\n\n/** Validation error collected during publish payload building. */\nexport type PublishValidationError = Pick<ValidationError, 'field' | 'message'> & { code?: string }\n\n/** Context for collecting validation errors instead of throwing on first error. */\nexport type PublishValidationContext = { errors: PublishValidationError[] }\n\n/** `patch` (default): new property attestations on the current Version. `new_version`: new Version attestation + attest all properties. */\nexport type PublishMode = 'patch' | 'new_version'\n\nexport type GetPublishPayloadOptions = {\n publishMode?: PublishMode\n}\n\nfunction addValidationError(\n ctx: PublishValidationContext,\n message: string,\n field?: string,\n code = 'publish_validation',\n): void {\n ctx.errors.push({ field: field ?? '', message, code })\n}\n\nfunction isStorageTransactionPropertyName(name: string | undefined): boolean {\n return name === 'storageTransactionId' || name === 'storage_transaction_id'\n}\n\n/**\n * Segmentation or naming variants can leave two rows for the same logical field; keep one\n * resolved slot so processBasicProperties emits a single storage tx attestation.\n */\nfunction replaceStorageTransactionInBasicProperties(\n itemBasicProperties: IItemProperty<any>[],\n resolved: IItemProperty<any>,\n): void {\n const filtered = itemBasicProperties.filter(\n (p) => !isStorageTransactionPropertyName(p.propertyName),\n )\n itemBasicProperties.length = 0\n itemBasicProperties.push(...filtered, resolved)\n}\n\n/** If multiple storageTransactionId ItemProperty rows slipped in, keep one (last wins). */\nfunction dedupeOneStorageTransactionPropertyInList(itemBasicProperties: IItemProperty<any>[]): void {\n const nonStorage: IItemProperty<any>[] = []\n const storage: IItemProperty<any>[] = []\n for (const p of itemBasicProperties) {\n if (isStorageTransactionPropertyName(p.propertyName)) {\n storage.push(p)\n } else {\n nonStorage.push(p)\n }\n }\n if (storage.length <= 1) return\n itemBasicProperties.length = 0\n itemBasicProperties.push(...nonStorage, storage[storage.length - 1]!)\n}\n\n/**\n * Two relation/image props (e.g. content + featureImage) can reference the same File/Image seed.\n * Only one child PublishPayload should exist per related seedLocalId; merge propertiesToUpdate instead.\n */\nfunction mergeChildPublishPayloadIfDuplicateInBatch(\n multiPublishPayload: MultiPublishPayload,\n relatedSeedLocalId: string,\n publishLocalId: string,\n propertySchemaUid: string | undefined,\n): boolean {\n const existing = multiPublishPayload.find((p) => p.localId === relatedSeedLocalId)\n if (!existing) return false\n const pts = existing.propertiesToUpdate ?? []\n const already = pts.some(\n (e) =>\n e.publishLocalId === publishLocalId &&\n String(e.propertySchemaUid ?? '').toLowerCase() ===\n String(propertySchemaUid ?? '').toLowerCase(),\n )\n if (!already) {\n pts.push({ publishLocalId, propertySchemaUid })\n }\n return true\n}\n\nconst getVersionUid = (item: IItem<any>): string => {\n const latestVersion = item.latestVersionUid\n if (latestVersion && typeof latestVersion === 'object' && latestVersion.uid) {\n return latestVersion.uid\n }\n if (latestVersion && typeof latestVersion === 'string') {\n return latestVersion\n }\n return ZERO_BYTES32\n}\n\n/**\n * Resolve versionUid when item.latestVersionUid is empty but item has been published (has seedUid).\n * Tries DB first, then EAS. The contract path never calls updateVersionUid, so the versions table\n * may have uid=NULL. EAS fallback queries attestations where refUID=seedUid (Version attestations).\n */\nasync function resolveVersionUid(\n seedLocalId: string,\n seedUid: string | undefined,\n): Promise<string> {\n if (!seedLocalId || !seedUid || seedUid === ZERO_BYTES32) return ZERO_BYTES32\n\n const appDb = BaseDb.getAppDb()\n if (appDb) {\n const rows = await appDb\n .select({ uid: versions.uid })\n .from(versions)\n .where(eq(versions.seedLocalId, seedLocalId))\n .orderBy(desc(versions.createdAt))\n .limit(1)\n const uid = rows[0]?.uid\n if (uid && uid !== '' && uid !== 'NULL') return uid\n }\n\n try {\n const { getItemVersionsFromEas } = await import('@/eas')\n const attestations = await getItemVersionsFromEas({ seedUids: [seedUid] })\n const latest = attestations?.[0]\n if (latest?.id) return latest.id\n } catch {\n // EAS client may not be initialized or network error\n }\n return ZERO_BYTES32\n}\n\ntype PropertyDataResult = {\n schemaUid: string | undefined\n easDataType: string\n schemaDef: string\n propertyNameForSchema: string\n}\n\nconst getPropertyData = async (\n itemProperty: IItemProperty<any>,\n ctx?: PublishValidationContext,\n): Promise<PropertyDataResult | null> => {\n const dataType = itemProperty.propertyDef?.dataType\n const entry = dataType != null ? INTERNAL_DATA_TYPES[dataType as keyof typeof INTERNAL_DATA_TYPES] : undefined\n const easDataType = entry?.eas\n if (!easDataType) {\n if (ctx) {\n addValidationError(\n ctx,\n `Unknown or unsupported property data type \"${dataType ?? 'undefined'}\" for property: ${itemProperty.propertyName}. Supported types: ${Object.keys(INTERNAL_DATA_TYPES).join(', ')}.`,\n itemProperty.propertyName,\n )\n }\n return null\n }\n\n let schemaUid: string | undefined = itemProperty.schemaUid\n\n const ip = itemProperty as IItemProperty<any> & { storagePropertyName?: string }\n const propertyDefForName = itemProperty.propertyDef as\n | { dataType?: string; ref?: string; refModelName?: string }\n | undefined\n let nameForEas =\n ip.storagePropertyName && ip.storagePropertyName.length > 0\n ? ip.storagePropertyName\n : itemProperty.propertyName\n // Align List-of-relation EAS field name with processListProperty (authorIdentityIds for authors → Identity)\n if (\n propertyDefForName?.dataType === ModelPropertyDataTypes.List &&\n (propertyDefForName.ref || propertyDefForName.refModelName) &&\n !(ip.storagePropertyName && ip.storagePropertyName.length > 0)\n ) {\n const ref = propertyDefForName.ref ?? propertyDefForName.refModelName\n if (ref) {\n const singular = pluralize.singular(itemProperty.propertyName)\n nameForEas = `${singular}${ref}Ids`\n }\n }\n const propertyNameForSchema = toSnakeCase(nameForEas)\n\n const schemaDef = `${easDataType} ${propertyNameForSchema}`\n\n if (!schemaUid) {\n schemaUid = await getEasSchemaUidForSchemaDefinition({ schemaText: schemaDef })\n if (!schemaUid) {\n const schema = await getEasSchemaForItemProperty({\n propertyName: 'version',\n easDataType: 'bytes32',\n })\n if (schema) {\n schemaUid = schema.id\n }\n }\n }\n\n return {\n schemaUid,\n easDataType,\n schemaDef,\n propertyNameForSchema,\n }\n}\n\n/** Resolve propertyDef from Model for properties that lack it (e.g. cached instances\n * created before loadOrCreateProperty was fixed). Ensures both new and existing items get property attestations.\n * Also ensures Relation/Image properties have required from schema when missing (for publish validation). */\nconst ensurePropertyDefs = async (targetItem: IItem<any>) => {\n const toFix = targetItem.properties.filter(\n (p) =>\n targetItem.modelName &&\n (!p.propertyDef || (p.propertyDef?.dataType === 'Relation' && p.propertyDef?.required === undefined)),\n )\n let schema: any\n for (const itemProperty of targetItem.properties) {\n if (!itemProperty.propertyDef && targetItem.modelName) {\n schema = await getPropertySchema(targetItem.modelName, itemProperty.propertyName)\n if (!schema) {\n try {\n const { Model } = await import('@/Model/Model')\n const normalizedModelName = upperFirst(camelCase(targetItem.modelName))\n let model = Model.getByName(normalizedModelName)\n if (!model?.properties?.length) {\n model = Model.findByModelType(toSnakeCaseDb(targetItem.modelName))\n }\n const modelFound = !!model\n const propsCount = model?.properties?.length ?? 0\n const schemaKeys: string[] = []\n if (model?.properties?.length) {\n const schemas = modelPropertiesToObject(model.properties)\n schemaKeys.push(...Object.keys(schemas))\n schema = schemas[itemProperty.propertyName]\n }\n } catch (err) {\n schema = undefined\n }\n }\n if (!schema) {\n const db = BaseDb.getAppDb()\n if (db) {\n try {\n const normalizedModelName = upperFirst(camelCase(targetItem.modelName))\n const modelRecords = await db\n .select({ id: models.id })\n .from(models)\n .where(eq(models.name, normalizedModelName))\n .limit(1)\n if (modelRecords.length > 0 && modelRecords[0].id) {\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, itemProperty.propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length > 0) {\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 schema = {\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 }\n }\n } catch {\n schema = undefined\n }\n }\n }\n if (schema) {\n itemProperty.getService().send({\n type: 'updateContext',\n propertyRecordSchema: schema,\n })\n }\n }\n }\n}\n\n// Lazy import SchemaEncoder to avoid module resolution issues with ts-import\nlet SchemaEncoderClass: typeof import('@ethereum-attestation-service/eas-sdk').SchemaEncoder | null = null\nconst getSchemaEncoder = async () => {\n if (!SchemaEncoderClass) {\n const easSdk = await import('@ethereum-attestation-service/eas-sdk')\n SchemaEncoderClass = easSdk.SchemaEncoder\n }\n return SchemaEncoderClass\n}\n\ntype PublishBuildOpts = { forceFullSnapshot?: boolean }\n\nconst processBasicProperties = async (\n itemBasicProperties: IItemProperty<any>[],\n itemPublishData: PublishPayload,\n ctx: PublishValidationContext,\n buildOpts?: PublishBuildOpts,\n): Promise<PublishPayload> => {\n const forceFullSnapshot = buildOpts?.forceFullSnapshot === true\n for (const basicProperty of itemBasicProperties) {\n // Skip SDK-internal properties (e.g. publisher) - never attest to EAS\n if (INTERNAL_PROPERTY_NAMES.includes(basicProperty.propertyName)) {\n continue\n }\n const snapshot = basicProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n const propertyDef =\n basicProperty.propertyDef ?? (context ? (context as any).propertyRecordSchema : undefined)\n const isFileImageHtml =\n propertyDef?.dataType === ModelPropertyDataTypes.File ||\n propertyDef?.dataType === ModelPropertyDataTypes.Image ||\n propertyDef?.dataType === ModelPropertyDataTypes.Html\n const isJsonStorage =\n propertyDef?.dataType === ModelPropertyDataTypes.Json ||\n propertyDef?.refValueType === ModelPropertyDataTypes.Json\n const isRelation = propertyDef?.dataType === ModelPropertyDataTypes.Relation\n // storageTransactionId is usually Text in the schema; .value still prefers renderValue (URL, label).\n const isStorageTransactionIdProp = isStorageTransactionPropertyName(basicProperty.propertyName)\n // File/Image/Html + Relation + Json storage + storage tx id: use propertyValue (canonical).\n // basicProperty.value prefers renderValue (filename, blob URL, display text)—never use that for publish.\n const preferPropertyValueForPublish =\n isFileImageHtml || isRelation || isJsonStorage || isStorageTransactionIdProp\n let value =\n preferPropertyValueForPublish && context\n ? (context as any).propertyValue\n : ((basicProperty as IItemProperty<any>).value ??\n (context ? (context as any).propertyValue : undefined))\n const hasContext = !!context\n const hasValue = value != null && value !== ''\n const hasUid = !!basicProperty.uid\n const skipReason = !hasContext ? 'no_context' : (!hasValue || hasUid) ? (hasUid ? 'has_uid' : 'no_value') : null\n if (!context) {\n continue\n }\n // Relation + Image/File/Html/Json refs often expose seedLocalId on context.propertyValue while .value is an object — align for encode + resolve hints\n if (\n propertyDef?.dataType === ModelPropertyDataTypes.Relation ||\n isFileImageHtml ||\n isJsonStorage\n ) {\n const pv = (context as any).propertyValue\n if (typeof value === 'object' || value == null) {\n if (typeof pv === 'string' && pv.trim()) value = pv.trim()\n else if (pv && typeof pv === 'object' && typeof pv.seedLocalId === 'string') value = pv.seedLocalId\n }\n }\n if (!value) {\n continue\n }\n // Patch mode skips properties that already have an EAS uid. storageTransactionId must still\n // attest after Arweave upload when we have a tx id; metadata uid can be stale or set without a chain attestation.\n if (basicProperty.uid && !forceFullSnapshot) {\n const allowStorageTxAttestation =\n isStorageTransactionIdProp &&\n typeof value === 'string' &&\n value.trim() !== ''\n if (!allowStorageTxAttestation) {\n continue\n }\n }\n\n const propertyData = await getPropertyData(basicProperty, ctx)\n if (!propertyData) continue\n const { schemaUid, easDataType, schemaDef, propertyNameForSchema } = propertyData\n if (!schemaDef) continue\n\n // Normalize value: string that parses to array (e.g. from browser storage) -> array\n if (schemaDef.startsWith('bytes32[]') && typeof value === 'string' && value.trim().startsWith('[')) {\n try {\n value = JSON.parse(value)\n } catch {\n // fall through to array check\n }\n }\n\n // Legacy comma-separated ids (pre-JSON List storage)\n if (\n schemaDef.startsWith('bytes32[]') &&\n typeof value === 'string' &&\n !value.trim().startsWith('[') &&\n value.includes(',')\n ) {\n value = value\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean)\n }\n\n if (schemaDef.startsWith('bytes32[]') && !Array.isArray(value)) {\n addValidationError(\n ctx,\n `Invalid value for property: ${basicProperty.propertyName}. Expected an array of bytes32, got ${value}.`,\n basicProperty.propertyName,\n )\n continue\n }\n\n // Validate against property validation rules (enum, pattern, minLength, maxLength) before encoding\n if (propertyDef?.validation) {\n const { SchemaValidationService } = await import(\n '@/Schema/service/validation/SchemaValidationService'\n )\n const validationService = new SchemaValidationService()\n const validationResult = validationService.validatePropertyValue(\n value,\n propertyDef.dataType as ModelPropertyDataTypes,\n propertyDef.validation,\n propertyDef.refValueType as string | undefined,\n )\n if (!validationResult.isValid && validationResult.errors.length > 0) {\n const firstError = validationResult.errors[0]\n addValidationError(\n ctx,\n firstError.message,\n basicProperty.propertyName,\n firstError.code ?? 'publish_validation',\n )\n continue\n }\n }\n\n /** Raw id per list slot (nanoid local id or 0x… uid) for resolvePublishPayloadValues after sequential publish */\n let rawListIdsForResolve: string[] | undefined\n if (schemaDef.startsWith('bytes32[]')) {\n const newValues: string[] = []\n const rawIds: string[] = []\n const iterableValue =\n Array.isArray(value) ? value\n : value != null && typeof value[Symbol.iterator] === 'function' ? value\n : []\n for (const seedId of iterableValue) {\n const idStr =\n typeof seedId === 'string'\n ? seedId\n : seedId &&\n typeof seedId === 'object' &&\n (seedId.seedLocalId ?? seedId.seedUid ?? seedId.localId ?? seedId.uid)\n ? String(\n (seedId as { seedLocalId?: string; seedUid?: string }).seedLocalId ??\n (seedId as { seedUid?: string }).seedUid ??\n '',\n )\n : ''\n if (!idStr) continue\n const trimmed = idStr.trim()\n if (!trimmed) continue\n rawIds.push(trimmed)\n if (trimmed.length !== 66 && !trimmed.startsWith('0x')) {\n newValues.push(ethers.encodeBytes32String(trimmed))\n } else {\n newValues.push(trimmed)\n }\n }\n value = newValues\n const needsUidResolve = rawIds.some(\n (id) => id.length !== 66 || !id.startsWith('0x'),\n )\n if (needsUidResolve && rawIds.length > 0) {\n rawListIdsForResolve = rawIds\n }\n }\n\n // uint256 (Date) must be numeric/BigInt; normalize ISO strings to Unix seconds\n if (easDataType === 'uint256' && (typeof value === 'string' || value instanceof Date)) {\n const ms = value instanceof Date ? value.getTime() : new Date(value).getTime()\n value = BigInt(Math.floor(ms / 1000))\n }\n\n let data = [\n {\n name: propertyNameForSchema,\n type: easDataType,\n value,\n },\n ]\n\n let encodedData: string\n try {\n const SchemaEncoder = await getSchemaEncoder()\n const dataEncoder = new SchemaEncoder(schemaDef)\n encodedData = dataEncoder.encodeData(data) as string\n } catch (encodeErr) {\n addValidationError(\n ctx,\n `Failed to encode property ${basicProperty.propertyName}: ${encodeErr instanceof Error ? encodeErr.message : String(encodeErr)}`,\n basicProperty.propertyName,\n )\n continue\n }\n\n // For storageTransactionId, set refUID to versionUid so it references the Version attestation (contract may use when supported)\n const refUid = isStorageTransactionIdProp\n ? itemPublishData.versionUid\n : defaultAttestationData.refUID\n\n const attestationEntry: Omit<AttestationRequest, 'data'> & {\n data: AttestationRequestData[]\n _propertyName?: string\n /** Same as encode step (getPropertyData); resolvePublishPayloadValues must use this, not toSnakeCase(propertyName). */\n _propertyNameForSchema?: string\n _schemaDef?: string\n _unresolvedValue?: string\n _easDataType?: string\n /** Per-slot raw ids (local or 0x) before encodeBytes32String; re-encoded after sequential publish. */\n _rawListIdsForResolve?: string[]\n } = {\n schema: schemaUid!,\n data: [\n {\n ...defaultAttestationData,\n refUID: refUid,\n data: encodedData,\n } as AttestationRequestData,\n ],\n }\n\n // For relation/image properties with seedLocalId, store resolution hints for resolvePublishPayloadValues\n const looksLikeLocalSeedRef =\n typeof value === 'string' &&\n !value.startsWith('0x') &&\n value.length !== 66 &&\n /^[a-zA-Z0-9_-]{10,21}$/.test(value.trim())\n if (\n looksLikeLocalSeedRef &&\n (easDataType === 'bytes32' || easDataType === 'string')\n ) {\n attestationEntry._propertyName = basicProperty.propertyName\n attestationEntry._propertyNameForSchema = propertyNameForSchema\n attestationEntry._schemaDef = schemaDef\n attestationEntry._unresolvedValue = value.trim()\n attestationEntry._easDataType = easDataType\n }\n if (rawListIdsForResolve && rawListIdsForResolve.length > 0) {\n attestationEntry._propertyName = basicProperty.propertyName\n attestationEntry._propertyNameForSchema = propertyNameForSchema\n attestationEntry._schemaDef = schemaDef\n attestationEntry._easDataType = 'bytes32[]'\n attestationEntry._rawListIdsForResolve = rawListIdsForResolve\n }\n\n itemPublishData.listOfAttestations.push(attestationEntry)\n }\n\n return itemPublishData\n}\n\n\nconst processRelationOrImageProperty = async (\n relationOrImageProperty: IItemProperty<any>,\n multiPublishPayload: MultiPublishPayload,\n uploadedTransactions: UploadedTransaction[],\n originalSeedLocalId: string,\n ctx: PublishValidationContext,\n buildOpts?: PublishBuildOpts,\n): Promise<MultiPublishPayload> => {\n const forceFullSnapshot = buildOpts?.forceFullSnapshot === true\n let relationOrImageSchemaUid = relationOrImageProperty.schemaUid\n if (!relationOrImageSchemaUid && relationOrImageProperty.propertyDef) {\n const propertyData = await getPropertyData(relationOrImageProperty, ctx)\n if (!propertyData) return multiPublishPayload\n relationOrImageSchemaUid = propertyData.schemaUid\n }\n if (!relationOrImageSchemaUid) {\n addValidationError(\n ctx,\n `Schema uid not found for relation or image property: ${relationOrImageProperty.propertyName}`,\n relationOrImageProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n const snapshot = relationOrImageProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n return multiPublishPayload\n }\n let value = (context as any).propertyValue\n // File/Image/Html/Json metadata is stored with Id suffix (e.g. \"textId\"); context may not have propertyValue\n // if the property was created from schema before metadata loaded. Fallback to metadata lookup.\n const isStorageSeed =\n relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.File ||\n relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.Image ||\n relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.Html ||\n relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.Json ||\n (relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.Relation &&\n (relationOrImageProperty.propertyDef?.refValueType === ModelPropertyDataTypes.File ||\n relationOrImageProperty.propertyDef?.refValueType === ModelPropertyDataTypes.Image ||\n relationOrImageProperty.propertyDef?.refValueType === ModelPropertyDataTypes.Html ||\n relationOrImageProperty.propertyDef?.refValueType === ModelPropertyDataTypes.Json))\n if (isStorageSeed && ((context as any).seedLocalId || (context as any).seedUid)) {\n const { getPropertyData: getPropertyDataFromDb } = await import('@/db/read/getPropertyData')\n const metaRow = await getPropertyDataFromDb({\n propertyName: relationOrImageProperty.propertyName,\n seedLocalId: (context as any).seedLocalId,\n seedUid: (context as any).seedUid,\n })\n const fromMeta = metaRow?.propertyValue\n if (typeof fromMeta === 'string' && fromMeta.trim() !== '') {\n const idsCtx = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(value) ?? '')\n const idsDb = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(fromMeta) ?? '')\n if (!value) {\n value = fromMeta\n } else if (!idsCtx.seedLocalId && !idsCtx.seedUid && (idsDb.seedLocalId || idsDb.seedUid)) {\n value = fromMeta\n }\n }\n }\n const propertyDef = relationOrImageProperty.propertyDef\n let isRequired = propertyDef?.required === true\n // Resolve required from schema/DB when propertyDef lacks it\n if (!isRequired && relationOrImageProperty.modelName) {\n let schema = await getPropertySchema(\n relationOrImageProperty.modelName,\n relationOrImageProperty.propertyName,\n )\n if (!schema && BaseDb.getAppDb()) {\n const normalizedModelName = upperFirst(camelCase(relationOrImageProperty.modelName))\n const modelRecords = await BaseDb.getAppDb()!\n .select({ id: models.id })\n .from(models)\n .where(eq(models.name, normalizedModelName))\n .limit(1)\n if (modelRecords.length > 0 && modelRecords[0].id) {\n const propertyRecords = await BaseDb.getAppDb()!\n .select()\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRecords[0].id),\n eq(properties.name, relationOrImageProperty.propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length > 0) {\n schema = {\n dataType: propertyRecords[0].dataType,\n ref: undefined,\n required: propertyRecords[0].required ?? undefined,\n } as any\n }\n }\n }\n if (schema?.required === true || (schema as any)?.required === 1) {\n isRequired = true\n }\n }\n\n // Required relation/image/file/html/json with no value: cannot publish\n if (isRequired && !value) {\n const typeLabel =\n propertyDef?.dataType === ModelPropertyDataTypes.File ||\n propertyDef?.refValueType === ModelPropertyDataTypes.File\n ? 'file'\n : propertyDef?.dataType === ModelPropertyDataTypes.Image ||\n propertyDef?.refValueType === ModelPropertyDataTypes.Image\n ? 'image'\n : propertyDef?.dataType === ModelPropertyDataTypes.Html ||\n propertyDef?.refValueType === ModelPropertyDataTypes.Html\n ? 'html'\n : propertyDef?.dataType === ModelPropertyDataTypes.Json ||\n propertyDef?.refValueType === ModelPropertyDataTypes.Json\n ? 'json'\n : 'relation'\n const refLabel = propertyDef?.ref ?? propertyDef?.refModelName ?? 'related'\n addValidationError(\n ctx,\n `Required ${typeLabel} ${relationOrImageProperty.propertyName} has no value. ` +\n `A value pointing to a valid ${refLabel} item is required to publish.`,\n relationOrImageProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n if (!value) {\n return multiPublishPayload\n }\n if (relationOrImageProperty.uid && !forceFullSnapshot) {\n return multiPublishPayload\n }\n\n const normalizedRef = normalizeRelationPropertyValue(value)\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(normalizedRef ?? '')\n\n // Value is not a valid seed reference (local id or 0x uid)\n if (!seedLocalId && !seedUid) {\n if (isRequired) {\n addValidationError(\n ctx,\n `Required relation ${relationOrImageProperty.propertyName} has invalid value: ${JSON.stringify(value)}. ` +\n `Value must be a valid seed reference (localId or uid) pointing to a ${propertyDef?.ref ?? propertyDef?.refModelName ?? 'related'} item.`,\n relationOrImageProperty.propertyName,\n )\n }\n return multiPublishPayload\n }\n\n // Use dynamic import to break circular dependency\n const getItemMod = await import('../../db/read/getItem')\n const { getItem } = getItemMod\n const relatedItem = await getItem({\n seedLocalId,\n seedUid,\n })\n\n // When related item not found (e.g. different DB, not yet created)\n if (!relatedItem) {\n if (isRequired) {\n addValidationError(\n ctx,\n `No related item found for required relation: ${relationOrImageProperty.propertyName}. ` +\n `Value: ${JSON.stringify(value)} (seedLocalId/seedUid). ` +\n `The related item may be missing, in a different database, or the reference may be broken.`,\n relationOrImageProperty.propertyName,\n )\n }\n return multiPublishPayload\n }\n\n // When Image/Relation already has seedUid (published), skip creating its payload—only add the property to parent\n if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {\n return multiPublishPayload\n }\n\n const versionUid = getVersionUid(relatedItem)\n\n let modelName: string | undefined\n\n if (relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.Image) {\n modelName = 'Image'\n }\n\n if (relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.File) {\n modelName = 'File'\n }\n\n if (relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.Html) {\n modelName = 'Html'\n }\n\n if (relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.Relation) {\n const def = relationOrImageProperty.propertyDef as { ref?: string; refModelName?: string }\n modelName = def.ref ?? def.refModelName\n }\n\n if (!modelName) {\n addValidationError(\n ctx,\n `Model name not found for relation or image property: ${relationOrImageProperty.propertyName}`,\n relationOrImageProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n const seedSchemaUid = await getEasSchemaUidForModel(modelName)\n \n if (!seedSchemaUid) {\n addValidationError(\n ctx,\n `Schema UID not found for model: ${modelName}`,\n relationOrImageProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n if (\n mergeChildPublishPayloadIfDuplicateInBatch(\n multiPublishPayload,\n relatedItem.seedLocalId,\n originalSeedLocalId,\n relationOrImageSchemaUid,\n )\n ) {\n return multiPublishPayload\n }\n\n let publishPayload: PublishPayload = {\n localId: relatedItem.seedLocalId,\n seedIsRevocable: true,\n versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n seedUid: seedUid || ZERO_BYTES32,\n seedSchemaUid,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [\n {\n publishLocalId: originalSeedLocalId,\n propertySchemaUid: relationOrImageSchemaUid,\n },\n ],\n }\n\n await ensurePropertyDefs(relatedItem)\n const { itemBasicProperties, itemUploadProperties } =\n await getSegmentedItemProperties(relatedItem)\n\n const relatedStorageUpload = resolveStorageTransactionUploadSlot(\n relatedItem,\n itemUploadProperties,\n )\n if (relatedStorageUpload) {\n const transactionData = findUploadedTxForSeedLocalId(\n uploadedTransactions,\n relatedItem.seedLocalId,\n )\n if (transactionData) {\n const itemProperty = relatedStorageUpload.itemProperty\n // Publish encoding reads context.propertyValue; do not await ItemProperty.save() here — it\n // uses xstate waitFor(10s) for idle and can time out while the machine is busy or still loading.\n itemProperty.getService().send({\n type: 'updateContext',\n propertyValue: transactionData.txId,\n renderValue: transactionData.txId,\n })\n replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty)\n }\n }\n\n for (const p of itemBasicProperties) {\n if (\n isStorageTransactionPropertyName(p.propertyName) &&\n !p.propertyDef &&\n relatedItem.modelName\n ) {\n const schema = await getPropertySchema(relatedItem.modelName, 'storageTransactionId')\n if (schema) {\n p.getService().send({ type: 'updateContext', propertyRecordSchema: schema })\n }\n }\n }\n\n dedupeOneStorageTransactionPropertyInList(itemBasicProperties)\n publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {\n forceFullSnapshot,\n })\n\n multiPublishPayload.push(publishPayload)\n\n return multiPublishPayload\n}\n\nconst processListProperty = async (\n listProperty: IItemProperty<any>,\n multiPublishPayload: MultiPublishPayload,\n originalSeedLocalId: string,\n ctx: PublishValidationContext,\n buildOpts?: PublishBuildOpts,\n): Promise<MultiPublishPayload> => {\n const forceFullSnapshot = buildOpts?.forceFullSnapshot === true\n // processListProperty only handles list-of-relations; list-of-primitives go to itemBasicProperties\n if (!listProperty.propertyDef?.ref) {\n addValidationError(\n ctx,\n `processListProperty requires ref (list of relations). List property \"${listProperty.propertyName}\" has no ref. List-of-primitives should be in itemBasicProperties.`,\n listProperty.propertyName,\n )\n return multiPublishPayload\n }\n let listPropertySchemaUid = listProperty.schemaUid\n if (!listPropertySchemaUid && listProperty.propertyDef) {\n const propertyData = await getPropertyData(listProperty, ctx)\n if (!propertyData) return multiPublishPayload\n listPropertySchemaUid = propertyData.schemaUid\n }\n if (!listPropertySchemaUid) {\n addValidationError(\n ctx,\n `Schema uid not found for list property: ${listProperty.propertyName}`,\n listProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n const snapshot = listProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n return multiPublishPayload\n }\n let value = (context as any).propertyValue\n if (!value) {\n return multiPublishPayload\n }\n if (listProperty.uid && !forceFullSnapshot) {\n return multiPublishPayload\n }\n\n const singularPropertyName = pluralize.singular(listProperty.propertyName)\n const propertyNameForSchema = `${singularPropertyName}${listProperty.propertyDef!.ref}Ids`\n if (typeof value === 'string') {\n value = parseListPropertyValueFromStorage(value)\n }\n\n const iterableValue = Array.isArray(value)\n ? value\n : value != null\n ? [value]\n : []\n\n for (const seedId of iterableValue) {\n const idStr =\n typeof seedId === 'string'\n ? seedId\n : seedId &&\n typeof seedId === 'object' &&\n (seedId.seedLocalId ?? seedId.seedUid ?? seedId.localId ?? seedId.uid)\n if (!idStr) continue\n const { localId: seedLocalId, uid: seedUid } = getCorrectId(idStr)\n if (!seedLocalId && !seedUid) continue\n\n // Use dynamic import to break circular dependency\n const getItemMod = await import('../../db/read/getItem')\n const { getItem } = getItemMod\n const relatedItem = await getItem({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n console.error(\n `No related item found for list property: ${listProperty.propertyName}`,\n )\n continue\n }\n\n if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {\n continue\n }\n\n const versionUid = getVersionUid(relatedItem)\n\n let modelName: string | undefined\n\n if (listProperty.propertyDef?.ref || (listProperty.propertyDef as { refModelName?: string }).refModelName) {\n const def = listProperty.propertyDef as { ref?: string; refModelName?: string }\n modelName = def.ref ?? def.refModelName\n }\n\n if (listProperty.propertyDef?.dataType === ModelPropertyDataTypes.Image) {\n modelName = 'Image'\n }\n\n if (listProperty.propertyDef?.dataType === ModelPropertyDataTypes.File) {\n modelName = 'File'\n }\n\n if (listProperty.propertyDef?.dataType === ModelPropertyDataTypes.Html) {\n modelName = 'Html'\n }\n\n if (!modelName) {\n addValidationError(\n ctx,\n `Model name not found for list property: ${listProperty.propertyName}`,\n listProperty.propertyName,\n )\n continue\n }\n\n const seedSchemaUid = await getEasSchemaUidForModel(modelName)\n \n if (!seedSchemaUid) {\n addValidationError(\n ctx,\n `Schema UID not found for model: ${modelName}`,\n listProperty.propertyName,\n )\n continue\n }\n\n if (\n mergeChildPublishPayloadIfDuplicateInBatch(\n multiPublishPayload,\n relatedItem.seedLocalId,\n originalSeedLocalId,\n listPropertySchemaUid,\n )\n ) {\n continue\n }\n\n let publishPayload: PublishPayload = {\n localId: relatedItem.seedLocalId,\n seedIsRevocable: true,\n versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n seedUid: seedUid || ZERO_BYTES32,\n seedSchemaUid,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [\n {\n publishLocalId: originalSeedLocalId,\n propertySchemaUid: listPropertySchemaUid,\n },\n ],\n }\n\n await ensurePropertyDefs(relatedItem)\n const { itemBasicProperties } = await getSegmentedItemProperties(relatedItem)\n\n dedupeOneStorageTransactionPropertyInList(itemBasicProperties)\n publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {\n forceFullSnapshot,\n })\n\n multiPublishPayload.push(publishPayload)\n }\n\n return multiPublishPayload\n}\n\ntype PublishPayload = {\n localId: string\n seedIsRevocable: boolean\n seedSchemaUid: string\n seedUid: string\n versionSchemaUid: string\n versionUid: string\n listOfAttestations: (Omit<AttestationRequest, 'data'> & {\n data: AttestationRequestData[]\n _propertyName?: string\n _propertyNameForSchema?: string\n _schemaDef?: string\n _unresolvedValue?: string\n _easDataType?: string\n _rawListIdsForResolve?: string[]\n })[]\n propertiesToUpdate: any[]\n}\n\ntype MultiPublishPayload = PublishPayload[]\n\n/**\n * Same EAS schema + same encoded attestation bytes (data field). Intentionally ignores refUID so\n * duplicate storageTransactionId rows that only differ by ref (e.g. 0x0 vs version uid) collapse.\n */\nfunction attestationPayloadDedupeKey(att: PublishPayload['listOfAttestations'][number]): string {\n const schema = String((att as { schema?: string }).schema ?? '').toLowerCase()\n const dataArr = (att as { data?: unknown[] }).data\n const d0 = Array.isArray(dataArr) ? dataArr[0] : undefined\n const dataHex =\n d0 && typeof d0 === 'object' && d0 !== null && 'data' in d0\n ? String((d0 as { data?: string }).data ?? '').toLowerCase()\n : ''\n return `${schema}:${dataHex}`\n}\n\n/**\n * Collapse duplicate rows in listOfAttestations (same schema + encoded payload).\n */\nfunction dedupeListOfAttestationsInEachPayload(payload: MultiPublishPayload): MultiPublishPayload {\n for (const p of payload) {\n const list = p.listOfAttestations ?? []\n if (list.length <= 1) continue\n const seen = new Set<string>()\n const out: PublishPayload['listOfAttestations'] = []\n for (const a of list) {\n const k = attestationPayloadDedupeKey(a)\n if (seen.has(k)) continue\n seen.add(k)\n out.push(a)\n }\n p.listOfAttestations = out\n }\n return payload\n}\n\n/**\n * Merge duplicate PublishPayload rows with the same localId (ordering / batch edge cases).\n * Dedupe listOfAttestations so identical storage tx attestations are not emitted twice.\n */\nfunction dedupeMultiPublishPayloadByLocalId(payload: MultiPublishPayload): MultiPublishPayload {\n const map = new Map<string, PublishPayload>()\n const order: string[] = []\n\n for (const p of payload) {\n const id = p.localId\n const existing = map.get(id)\n if (!existing) {\n map.set(id, p)\n order.push(id)\n continue\n }\n const ptu = [...(existing.propertiesToUpdate ?? [])]\n for (const u of p.propertiesToUpdate ?? []) {\n if (\n !ptu.some(\n (e) =>\n e.publishLocalId === u.publishLocalId &&\n String(e.propertySchemaUid ?? '').toLowerCase() ===\n String(u.propertySchemaUid ?? '').toLowerCase(),\n )\n ) {\n ptu.push(u)\n }\n }\n existing.propertiesToUpdate = ptu\n const seenKeys = new Set((existing.listOfAttestations ?? []).map((a) => attestationPayloadDedupeKey(a)))\n const merged = [...(existing.listOfAttestations ?? [])]\n for (const a of p.listOfAttestations ?? []) {\n const k = attestationPayloadDedupeKey(a)\n if (seenKeys.has(k)) continue\n seenKeys.add(k)\n merged.push(a)\n }\n existing.listOfAttestations = merged\n }\n\n return order.map((id) => map.get(id)!).filter(Boolean) as MultiPublishPayload\n}\n\n/** Map of seed localId -> attestation uid for resolving relation/image property values after dependent seeds are published */\nexport type ResolvedSeedUids = Record<string, string>\n\ntype UploadedTransaction = {\n txId: string\n itemPropertyLocalId?: string\n seedLocalId?: string\n versionLocalId?: string\n itemPropertyName?: string\n}\n\n/** Same shape as UploadProperty in getPublishUploads */\ntype StorageUploadSlot = {\n itemProperty: IItemProperty<any>\n childProperties: IItemProperty<any>[]\n}\n\n/**\n * Child File/Image items may keep storageTransactionId only on the item machine's\n * propertyInstances map; allProperties / item.properties can omit it during publish.\n */\nfunction getStorageTransactionPropertyFromItemInstances(\n item: IItem<any>,\n): IItemProperty<any> | undefined {\n try {\n const svc = (item as { getService?: () => { getSnapshot: () => unknown } }).getService?.()\n if (!svc) return undefined\n const snap = svc.getSnapshot() as {\n context?: { propertyInstances?: Map<string, IItemProperty<any>> }\n }\n const instances = snap.context?.propertyInstances\n if (!instances || !(instances instanceof Map)) return undefined\n const direct =\n instances.get('storageTransactionId') ?? instances.get('storage_transaction_id')\n if (direct) return direct\n for (const [, p] of instances) {\n if (p && isStorageTransactionPropertyName(p.propertyName)) return p\n }\n } catch {\n return undefined\n }\n return undefined\n}\n\n/**\n * Resolve storageTransactionId (+ ItemStorage children) for publish.\n * getSegmentedItemProperties can yield empty itemUploadProperties when the child Item never\n * hydrated storageTransactionId into the upload bucket (e.g. only uri/metadata rows), while\n * getStorageSeedUploads still creates an Arweave upload keyed by child seedLocalId.\n */\nfunction resolveStorageTransactionUploadSlot(\n item: IItem<any>,\n itemUploadProperties: StorageUploadSlot[],\n): StorageUploadSlot | undefined {\n const named = itemUploadProperties.find((u) =>\n isStorageTransactionPropertyName(u.itemProperty.propertyName),\n )\n if (named) return named\n if (itemUploadProperties.length === 1) return itemUploadProperties[0]\n\n const all = (item as { allProperties?: Record<string, IItemProperty<any>> }).allProperties\n const fromInstances = getStorageTransactionPropertyFromItemInstances(item)\n const storagePropEarly =\n all?.['storageTransactionId'] ??\n all?.['storage_transaction_id'] ??\n Object.values(all ?? {}).find(\n (p): p is IItemProperty<any> =>\n !!p && isStorageTransactionPropertyName((p as IItemProperty<any>).propertyName),\n ) ??\n item.properties?.find((p) => isStorageTransactionPropertyName(p.propertyName))\n const storageProp = storagePropEarly ?? fromInstances\n if (!storageProp) return undefined\n\n const childProps =\n item.properties?.filter(\n (p) =>\n p.propertyDef &&\n (p.propertyDef as { storageType?: string }).storageType === 'ItemStorage',\n ) ?? []\n return { itemProperty: storageProp, childProperties: childProps }\n}\n\nfunction findUploadedTxForSeedLocalId(\n uploadedTransactions: UploadedTransaction[],\n seedLocalId: string,\n): UploadedTransaction | undefined {\n const t = seedLocalId.trim()\n return (\n uploadedTransactions.find((u) => u.seedLocalId === t) ??\n uploadedTransactions.find((u) => u.seedLocalId != null && u.seedLocalId.trim() === t)\n )\n}\n\n/** Error thrown when publish validation fails. Includes all validation errors for user to fix. */\nexport class PublishValidationFailedError extends Error {\n constructor(\n message: string,\n public readonly validationErrors: PublishValidationError[],\n ) {\n super(message)\n this.name = 'PublishValidationFailedError'\n }\n}\n\nexport const getPublishPayload = async (\n item: IItem<any>,\n uploadedTransactions: UploadedTransaction[],\n options?: GetPublishPayloadOptions,\n): Promise<MultiPublishPayload> => {\n const validationCtx: PublishValidationContext = { errors: [] }\n const publishMode: PublishMode = options?.publishMode ?? 'patch'\n const forceFullSnapshot = publishMode === 'new_version'\n\n if (publishMode === 'new_version' && (!item.seedUid || item.seedUid === ZERO_BYTES32)) {\n addValidationError(\n validationCtx,\n 'Publishing as a new version requires the item to already have a published Seed attestation (seed UID).',\n 'seedUid',\n 'publish_new_version_requires_seed',\n )\n }\n\n let multiPublishPayload: MultiPublishPayload = []\n\n // Each PublishPayload is generated from a Seed that needs publishing\n\n // First we need to determine all Seeds to publish\n\n // That means the Seed of the Item, plus any Seeds pointed to by Relations\n\n // Check if the item has a schema UID\n let itemSchemaUid = item.schemaUid\n if (!itemSchemaUid) {\n const schemaUid = await getEasSchemaUidForModel(item.modelName)\n if (!schemaUid) {\n addValidationError(validationCtx, `Schema UID not found for model: ${item.modelName}`)\n itemSchemaUid = ZERO_BYTES32 // placeholder so we can continue collecting errors\n } else {\n itemSchemaUid = schemaUid\n }\n }\n\n let versionUid = getVersionUid(item)\n if (versionUid === ZERO_BYTES32 && item.seedUid && item.seedUid !== ZERO_BYTES32) {\n versionUid = await resolveVersionUid(item.seedLocalId, item.seedUid)\n }\n if (forceFullSnapshot && item.seedUid && item.seedUid !== ZERO_BYTES32) {\n versionUid = ZERO_BYTES32\n }\n\n let itemPublishData: PublishPayload = {\n localId: item.seedLocalId,\n seedUid: item.seedUid || ZERO_BYTES32,\n seedIsRevocable: true,\n seedSchemaUid: itemSchemaUid,\n versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [],\n }\n\n await ensurePropertyDefs(item)\n\n const {\n itemBasicProperties,\n itemListProperties,\n itemUploadProperties,\n itemImageProperties,\n itemRelationProperties,\n } = await getSegmentedItemProperties(item)\n\n const relationAndImageProperties = [...itemRelationProperties, ...itemImageProperties]\n\n // Validate required relations have values before processing\n for (const relProp of itemRelationProperties) {\n const snapshot = relProp.getService().getSnapshot()\n const ctx = 'context' in snapshot ? snapshot.context : null\n const val = ctx ? (ctx as any).renderValue ?? (ctx as any).propertyValue : undefined\n if (val != null && typeof val === 'string' && val.trim() !== '') continue\n // No value - check if required from propertyDef or DB\n let isRequired = relProp.propertyDef?.required === true\n if (!isRequired && BaseDb.getAppDb() && item.modelName) {\n const normalizedModelName = upperFirst(camelCase(item.modelName))\n const modelRows = await BaseDb.getAppDb()!\n .select({ id: models.id })\n .from(models)\n .where(eq(models.name, normalizedModelName))\n .limit(1)\n if (modelRows.length > 0) {\n const propRows = await BaseDb.getAppDb()!\n .select({ required: properties.required, refModelId: properties.refModelId })\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRows[0].id),\n eq(properties.name, relProp.propertyName),\n eq(properties.dataType, 'Relation'),\n ),\n )\n .limit(1)\n if (propRows.length > 0 && (propRows[0].required === true || propRows[0].required === 1)) {\n isRequired = true\n }\n }\n }\n if (isRequired) {\n const refModel = relProp.propertyDef?.ref ?? relProp.propertyDef?.refModelName ?? 'related'\n addValidationError(\n validationCtx,\n `Required relation ${relProp.propertyName} has no value. ` +\n `A value pointing to a valid ${refModel} item is required to publish.`,\n relProp.propertyName,\n )\n }\n }\n\n const rootStorageUpload = resolveStorageTransactionUploadSlot(item, itemUploadProperties)\n if (rootStorageUpload) {\n const transactionData = findUploadedTxForSeedLocalId(uploadedTransactions, item.seedLocalId)\n if (transactionData) {\n const itemProperty = rootStorageUpload.itemProperty\n itemProperty.getService().send({\n type: 'updateContext',\n propertyValue: transactionData.txId,\n renderValue: transactionData.txId,\n })\n replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty)\n }\n }\n\n for (const relationProperty of relationAndImageProperties) {\n multiPublishPayload = await processRelationOrImageProperty(\n relationProperty,\n multiPublishPayload,\n uploadedTransactions,\n item.seedLocalId,\n validationCtx,\n { forceFullSnapshot },\n )\n itemBasicProperties.push(relationProperty)\n }\n\n for (const listProperty of itemListProperties) {\n multiPublishPayload = await processListProperty(\n listProperty,\n multiPublishPayload,\n item.seedLocalId,\n validationCtx,\n { forceFullSnapshot },\n )\n itemBasicProperties.push(listProperty)\n }\n\n for (const p of itemBasicProperties) {\n if (isStorageTransactionPropertyName(p.propertyName) && !p.propertyDef && item.modelName) {\n const schema = await getPropertySchema(item.modelName, 'storageTransactionId')\n if (schema) {\n p.getService().send({ type: 'updateContext', propertyRecordSchema: schema })\n }\n }\n }\n\n dedupeOneStorageTransactionPropertyInList(itemBasicProperties)\n itemPublishData = await processBasicProperties(\n itemBasicProperties,\n itemPublishData,\n validationCtx,\n { forceFullSnapshot },\n )\n\n multiPublishPayload.push(itemPublishData)\n\n // Ensure requests are ordered so that when A has propertiesToUpdate pointing to B (publishLocalId),\n // A (the updater) is published before B (the updatee). The contract injects A's seedUid into B's\n // attestation before B is sent to EAS.\n multiPublishPayload = dedupeMultiPublishPayloadByLocalId(multiPublishPayload)\n multiPublishPayload = orderPayloadByDependencies(multiPublishPayload)\n\n // Ensure attestations referenced in propertiesToUpdate have at least one data element.\n // The contract writes the seed UID into data[0].data; empty data causes Panic 50.\n multiPublishPayload = ensurePropertiesToUpdateAttestationsHaveData(multiPublishPayload)\n multiPublishPayload = dedupeListOfAttestationsInEachPayload(multiPublishPayload)\n\n if (validationCtx.errors.length > 0) {\n const combinedMessage = validationCtx.errors.map((e) => e.message).join('\\n')\n throw new PublishValidationFailedError(\n `Validation failed (${validationCtx.errors.length} error${validationCtx.errors.length === 1 ? '' : 's'}):\\n${combinedMessage}`,\n validationCtx.errors,\n )\n }\n\n return multiPublishPayload\n}\n\nexport type ValidateItemForPublishResult = {\n isValid: boolean\n errors: PublishValidationError[]\n}\n\n/**\n * Validates an item for publishing without performing Arweave or EAS work.\n * Use in the checking step to fail fast before creating transactions.\n * Pass empty array for uploadedTransactions when validating before Arweave upload.\n */\nexport const validateItemForPublish = async (\n item: IItem<any>,\n uploadedTransactions: UploadedTransaction[] = [],\n options?: GetPublishPayloadOptions,\n): Promise<ValidateItemForPublishResult> => {\n try {\n await getPublishPayload(item, uploadedTransactions, options)\n return { isValid: true, errors: [] }\n } catch (err) {\n if (err instanceof PublishValidationFailedError) {\n return { isValid: false, errors: err.validationErrors }\n }\n throw err\n }\n}\n\n/**\n * Normalize a schema UID to 0x-prefixed 64-char hex for comparison.\n */\nfunction normalizeSchemaUid(v: string | undefined): string {\n if (v == null || v === '') return ''\n const raw = v.startsWith('0x') ? v.slice(2) : v\n const hex = raw.replace(/[^0-9a-fA-F]/g, '0').padStart(64, '0').slice(-64)\n return ('0x' + hex).toLowerCase()\n}\n\n/**\n * Ensure that when request A has propertiesToUpdate with (publishLocalId: B, propertySchemaUid: X),\n * request B has an attestation for schema X with at least one data element. The contract writes\n * the seed UID into data[0].data; empty data causes Panic 50.\n */\nfunction ensurePropertiesToUpdateAttestationsHaveData(\n payload: MultiPublishPayload,\n): MultiPublishPayload {\n const byLocalId = new Map<string, PublishPayload>()\n for (const p of payload) {\n byLocalId.set(p.localId, p)\n }\n\n const placeholderData: AttestationRequestData = {\n ...defaultAttestationData,\n data: ZERO_BYTES32,\n }\n\n for (const req of payload) {\n for (const pu of req.propertiesToUpdate ?? []) {\n const targetId = (pu as { publishLocalId?: string }).publishLocalId\n const schemaUid = (pu as { propertySchemaUid?: string }).propertySchemaUid\n if (!targetId || !schemaUid) continue\n\n const targetReq = byLocalId.get(targetId)\n if (!targetReq?.listOfAttestations) continue\n\n const wantSchema = normalizeSchemaUid(schemaUid)\n const att = targetReq.listOfAttestations.find(\n (a) => normalizeSchemaUid(a?.schema) === wantSchema,\n )\n if (!att) continue\n\n if (!Array.isArray(att.data) || att.data.length === 0) {\n att.data = [placeholderData]\n }\n }\n }\n\n return payload\n}\n\n/**\n * LocalIds in this batch referenced by attestations (bytes32 / bytes32[]) that must publish before this request.\n */\nfunction collectAttestationLocalRefIds(\n req: PublishPayload,\n allLocalIds: Set<string>,\n): string[] {\n const refs: string[] = []\n for (const a of req.listOfAttestations ?? []) {\n const att = a as {\n _unresolvedValue?: string\n _rawListIdsForResolve?: string[]\n }\n if (att._unresolvedValue && allLocalIds.has(att._unresolvedValue)) {\n refs.push(att._unresolvedValue)\n }\n if (Array.isArray(att._rawListIdsForResolve)) {\n for (const id of att._rawListIdsForResolve) {\n const t = id != null ? String(id).trim() : ''\n if (t && allLocalIds.has(t)) refs.push(t)\n }\n }\n }\n return refs\n}\n\n/**\n * Topological sort (Kahn): edge `from → to` means `from` must publish before `to`.\n * - propertiesToUpdate: updater before updatee (contract injection).\n * - _unresolvedValue / _rawListIdsForResolve: referenced seed before request that encodes the ref.\n * The previous DFS visit could order [Post, Image] when Post appeared first in the input array,\n * so resolvedUids was empty when Post was published and attestations kept local ids.\n */\nfunction orderPayloadByDependencies(payload: MultiPublishPayload): MultiPublishPayload {\n if (payload.length <= 1) return payload\n\n const byLocalId = new Map<string, PublishPayload>()\n const allIds = new Set<string>()\n const indexOrder = new Map<string, number>()\n for (let i = 0; i < payload.length; i++) {\n const p = payload[i]\n byLocalId.set(p.localId, p)\n allIds.add(p.localId)\n indexOrder.set(p.localId, i)\n }\n\n const indegree = new Map<string, number>()\n for (const id of allIds) indegree.set(id, 0)\n\n const adj = new Map<string, Set<string>>()\n\n const addEdge = (from: string, to: string) => {\n if (from === to || !allIds.has(from) || !allIds.has(to)) return\n if (!adj.has(from)) adj.set(from, new Set())\n const set = adj.get(from)!\n if (set.has(to)) return\n set.add(to)\n indegree.set(to, (indegree.get(to) ?? 0) + 1)\n }\n\n for (const p of payload) {\n for (const u of p.propertiesToUpdate ?? []) {\n const targetId = (u as { publishLocalId?: string }).publishLocalId\n if (targetId && targetId !== p.localId) addEdge(p.localId, targetId)\n }\n for (const refId of collectAttestationLocalRefIds(p, allIds)) {\n addEdge(refId, p.localId)\n }\n }\n\n const zero: string[] = []\n for (const id of allIds) {\n if ((indegree.get(id) ?? 0) === 0) zero.push(id)\n }\n zero.sort((a, b) => (indexOrder.get(a) ?? 0) - (indexOrder.get(b) ?? 0))\n\n const result: PublishPayload[] = []\n const queue = zero\n\n while (queue.length > 0) {\n const id = queue.shift()!\n const p = byLocalId.get(id)\n if (p) result.push(p)\n for (const to of adj.get(id) ?? []) {\n const next = (indegree.get(to) ?? 0) - 1\n indegree.set(to, next)\n if (next === 0) {\n queue.push(to)\n queue.sort((a, b) => (indexOrder.get(a) ?? 0) - (indexOrder.get(b) ?? 0))\n }\n }\n }\n\n if (result.length !== payload.length) {\n const seen = new Set(result.map((r) => r.localId))\n for (const p of payload) {\n if (!seen.has(p.localId)) result.push(p)\n }\n }\n\n return result\n}\n\n/** Normalize attestation UID to 32-byte hex for SchemaEncoder bytes32 fields. */\nfunction padUidForBytes32Schema(uid: string): string {\n const t = uid.trim()\n if (!t.startsWith('0x')) return uid\n const hex = t.slice(2).replace(/[^0-9a-fA-F]/g, '')\n if (hex.length === 0) return uid\n return ('0x' + hex.padStart(64, '0').slice(-64)).toLowerCase()\n}\n\n/**\n * Resolves relation/image property values (seedLocalId) to attestation uids after dependent seeds are published.\n * Call after each payload is published, passing the returned attestation uid for that seed's localId.\n * Returns an updated multiPayload with re-encoded attestations where resolution was applied.\n */\nexport const resolvePublishPayloadValues = async (\n multiPayload: MultiPublishPayload,\n resolvedUids: ResolvedSeedUids,\n): Promise<MultiPublishPayload> => {\n if (Object.keys(resolvedUids).length === 0) {\n return multiPayload\n }\n\n const SchemaEncoder = await getSchemaEncoder()\n const result: MultiPublishPayload = []\n\n for (const payload of multiPayload) {\n const updatedAttestations: PublishPayload['listOfAttestations'] = []\n\n for (const attestation of payload.listOfAttestations) {\n const entry = attestation as PublishPayload['listOfAttestations'][0] & {\n _easDataType?: string\n _propertyNameForSchema?: string\n _rawListIdsForResolve?: string[]\n data?: AttestationRequestData[] | AttestationRequestData\n }\n\n const rawList = entry._rawListIdsForResolve\n if (\n rawList &&\n rawList.length > 0 &&\n entry._schemaDef &&\n (entry._propertyNameForSchema || entry._propertyName)\n ) {\n const fieldName =\n entry._propertyNameForSchema ?? toSnakeCase(entry._propertyName as string)\n const resolvedValues: string[] = []\n let allSlotsResolved = true\n for (const id of rawList) {\n const trimmed = id.trim()\n if (trimmed.length === 66 && trimmed.startsWith('0x')) {\n resolvedValues.push(padUidForBytes32Schema(trimmed))\n continue\n }\n const r = resolvedUids[trimmed]\n if (r) {\n resolvedValues.push(padUidForBytes32Schema(r))\n continue\n }\n allSlotsResolved = false\n break\n }\n // Do not encode or clear hints until every slot has a real uid — otherwise sequential\n // publish burns encodeBytes32String(localId) into data and drops _rawListIdsForResolve.\n if (!allSlotsResolved) {\n updatedAttestations.push({\n ...entry,\n data: Array.isArray(entry.data) ? entry.data : [entry.data as AttestationRequestData],\n })\n continue\n }\n const dataEncoder = new SchemaEncoder(entry._schemaDef)\n const encodedData = dataEncoder.encodeData([\n {\n name: fieldName,\n type: 'bytes32[]',\n value: resolvedValues,\n },\n ])\n const baseData = Array.isArray(entry.data) ? entry.data[0] : (entry.data as AttestationRequestData)\n updatedAttestations.push({\n ...entry,\n data: [\n {\n ...baseData,\n data: encodedData,\n } as AttestationRequestData,\n ],\n _rawListIdsForResolve: undefined,\n _easDataType: undefined,\n })\n continue\n }\n\n const resolvedUid = entry._unresolvedValue && resolvedUids[entry._unresolvedValue]\n const easType = (entry._easDataType as 'bytes32' | 'string') || 'bytes32'\n if (resolvedUid && entry._schemaDef && (entry._propertyNameForSchema || entry._propertyName)) {\n const fieldName =\n entry._propertyNameForSchema ?? toSnakeCase(entry._propertyName as string)\n const valueForEncode =\n easType === 'bytes32' ? padUidForBytes32Schema(resolvedUid) : resolvedUid\n const dataEncoder = new SchemaEncoder(entry._schemaDef)\n const encodedData = dataEncoder.encodeData([\n {\n name: fieldName,\n type: easType,\n value: valueForEncode,\n },\n ])\n const baseData = Array.isArray(entry.data) ? entry.data[0] : (entry.data as AttestationRequestData)\n updatedAttestations.push({\n ...entry,\n data: [\n {\n ...baseData,\n data: encodedData,\n } as AttestationRequestData,\n ],\n _unresolvedValue: undefined,\n })\n } else {\n const normalizedEntry: PublishPayload['listOfAttestations'][0] = {\n ...entry,\n data: Array.isArray(entry.data) ? entry.data : [entry.data as AttestationRequestData],\n }\n updatedAttestations.push(normalizedEntry)\n }\n }\n\n result.push({\n ...payload,\n listOfAttestations: updatedAttestations,\n })\n }\n\n return result\n}\n"],"names":["ZERO_BYTES32","BaseDb","versions","eq","desc","INTERNAL_DATA_TYPES","ModelPropertyDataTypes","toSnakeCase","getEasSchemaUidForSchemaDefinition","getEasSchemaForItemProperty","getPropertySchema","upperFirst","camelCase","toSnakeCaseDb","modelPropertiesToObject","models","properties","and","INTERNAL_PROPERTY_NAMES","ethers","defaultAttestationData","resolveSeedIdsFromRefString","normalizeRelationPropertyValue","getEasSchemaUidForModel","VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA","getSegmentedItemProperties","parseListPropertyValueFromStorage","getCorrectId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAsCe,KAAK,CAAC,8BAA8B;AAenD,SAAS,kBAAkB,CACzB,GAA6B,EAC7B,OAAe,EACf,KAAc,EACd,IAAI,GAAG,oBAAoB,EAAA;AAE3B,IAAA,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACxD;AAEA,SAAS,gCAAgC,CAAC,IAAwB,EAAA;AAChE,IAAA,OAAO,IAAI,KAAK,sBAAsB,IAAI,IAAI,KAAK,wBAAwB;AAC7E;AAEA;;;AAGG;AACH,SAAS,0CAA0C,CACjD,mBAAyC,EACzC,QAA4B,EAAA;AAE5B,IAAA,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CACzC,CAAC,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC,CAAC,YAAY,CAAC,CACzD;AACD,IAAA,mBAAmB,CAAC,MAAM,GAAG,CAAC;IAC9B,mBAAmB,CAAC,IAAI,CAAC,GAAG,QAAQ,EAAE,QAAQ,CAAC;AACjD;AAEA;AACA,SAAS,yCAAyC,CAAC,mBAAyC,EAAA;IAC1F,MAAM,UAAU,GAAyB,EAAE;IAC3C,MAAM,OAAO,GAAyB,EAAE;AACxC,IAAA,KA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EAAE,WAAW;AACQ,yBAAA;AAC5B,qBAAA;AACD,oBAAA,gBAAgB,EAAE,SAAS;AAC5B,iBAAA,CAAC;YACJ;iBAAO;AACL,gBAAA,MAAM,eAAe,GAA4C;AAC/D,oBAAA,GAAG,KAAK;oBACR,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,IAA8B,CAAC;iBACtF;AACD,gBAAA,mBAAmB,CAAC,IAAI,CAAC,eAAe,CAAC;YAC3C;QACF;QAEA,MAAM,CAAC,IAAI,CAAC;AACV,YAAA,GAAG,OAAO;AACV,YAAA,kBAAkB,EAAE,mBAAmB;AACxC,SAAA,CAAC;IACJ;AAEA,IAAA,OAAO,MAAM;AACf;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPublishUploads-CONYV9QQ.js","sources":["../../../src/db/read/getPublishUploads.ts"],"sourcesContent":["import { BaseFileManager } from '@/helpers'\nimport {\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '@/helpers/relationSeedRef'\nimport { BaseArweaveClient } from '@/helpers/ArweaveClient/BaseArweaveClient'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport debug from 'debug'\nimport { IItem, IItemProperty } from '@/interfaces'\nimport { getContentHash } from '@/helpers/crypto'\nimport { Item } from '@/Item/Item'\nimport type { ArweaveTransaction } from '@/types/arweave'\nimport { PublishUpload } from '@/types/publish'\n\nconst logger = debug('seedSdk:item:getPublishUploads')\n\nconst EXTENSION_TO_MIME: Record<string, string> = {\n png: 'image/png',\n jpg: 'image/jpeg',\n jpeg: 'image/jpeg',\n gif: 'image/gif',\n webp: 'image/webp',\n svg: 'image/svg+xml',\n html: 'text/html',\n htm: 'text/html',\n json: 'application/json',\n txt: 'text/plain',\n}\n\nconst getMimeTypeFromPath = (filePathOrName: string): string | undefined => {\n const ext = filePathOrName.split('.').pop()?.toLowerCase()\n return ext ? EXTENSION_TO_MIME[ext] : undefined\n}\n\nconst toUint8Array = async (data: Buffer | Blob): Promise<Uint8Array> => {\n if (typeof Blob !== 'undefined' && data instanceof Blob) {\n return new Uint8Array(await data.arrayBuffer())\n }\n return new Uint8Array(data as Buffer)\n}\n\nexport const prepareArweaveTransaction = async (\n data: string | Uint8Array,\n contentHash: string | undefined,\n contentType?: string,\n): Promise<ArweaveTransaction> => {\n const tags: { name: string; value: string }[] = []\n if (contentHash) {\n tags.push({ name: 'Content-SHA-256', value: contentHash })\n logger('contentHash', contentHash)\n logger('adding content hash tag')\n }\n if (contentType) {\n tags.push({ name: 'Content-Type', value: contentType })\n }\n\n const tx = await BaseArweaveClient.createTransaction(data, {\n tags: tags.length ? tags : undefined,\n })\n\n return tx\n}\n\n\nconst getStorageDirForDataType = (dataType: string): string => {\n switch (dataType) {\n case 'Image':\n return BaseFileManager.getFilesPath('images')\n case 'File':\n return BaseFileManager.getFilesPath('files')\n case 'Html':\n return BaseFileManager.getFilesPath('html')\n case 'Json':\n return BaseFileManager.getFilesPath('json')\n default:\n return BaseFileManager.getFilesPath('images')\n }\n}\n\nconst getStorageSeedUploads = async (\n itemStorageSeedProperties: IItemProperty<any>[],\n) => {\n const uploads: PublishUpload[] = []\n\n for (const itemProperty of itemStorageSeedProperties) {\n const snapshot = itemProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n const refResolvedValue = (context as any).refResolvedValue\n if (!refResolvedValue) {\n continue\n }\n\n // propertyValue is the storage seed's seedLocalId; use it for the upload so processRelationOrImageProperty can match\n const { seedLocalId } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId) {\n continue\n }\n\n const dataType =\n itemProperty.propertyDef?.refValueType ??\n itemProperty.propertyDef?.dataType ??\n 'Image'\n const baseDir = getStorageDirForDataType(dataType)\n const filePath = `${baseDir}/${refResolvedValue}`\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n const fileBuffer = await BaseFileManager.readFileAsBuffer(filePath)\n const fileContents = await toUint8Array(fileBuffer)\n\n const contentHash = await getContentHash(fileContents)\n const contentType = getMimeTypeFromPath(refResolvedValue)\n\n const transaction = await prepareArweaveTransaction(\n fileContents,\n contentHash,\n contentType,\n )\n\n uploads.push({\n itemPropertyName: itemProperty.propertyName,\n itemPropertyLocalId: itemProperty.localId,\n seedLocalId,\n versionLocalId: itemProperty.versionLocalId!,\n transactionToSign: transaction,\n })\n }\n\n return uploads\n}\n\nexport type UploadProperty = {\n itemProperty: IItemProperty<any>\n childProperties: IItemProperty<any>[]\n}\ntype ChildUploadData = {\n propertyName: string\n localStoragePath: string\n}\n\n/**\n * True if publish would include at least one Arweave upload (local file / storage seed present).\n * Does not create Arweave transactions or hit the network — use for routing (e.g. skip EAS-only)\n * when {@link getPublishUploads} would fail early (e.g. gateway unreachable during tx creation).\n */\nasync function storageSeedHasUploadCandidates(\n itemStorageSeedProperties: IItemProperty<any>[],\n): Promise<boolean> {\n for (const itemProperty of itemStorageSeedProperties) {\n const snapshot = itemProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n const refResolvedValue = (context as any).refResolvedValue\n if (!refResolvedValue) {\n continue\n }\n\n const { seedLocalId } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId) {\n continue\n }\n\n const dataType =\n itemProperty.propertyDef?.refValueType ??\n itemProperty.propertyDef?.dataType ??\n 'Image'\n const baseDir = getStorageDirForDataType(dataType)\n const filePath = `${baseDir}/${refResolvedValue}`\n\n if (await BaseFileManager.pathExists(filePath)) {\n return true\n }\n }\n\n return false\n}\n\nasync function uploadPropertyWouldUpload(\n uploadProperty: UploadProperty,\n relatedItemProperty?: IItemProperty<any>,\n): Promise<boolean> {\n const childUploads: ChildUploadData[] = []\n\n for (const childProperty of uploadProperty.childProperties) {\n const filePath = childProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n continue\n }\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n childUploads.push({\n propertyName: childProperty.propertyName,\n localStoragePath: filePath,\n })\n }\n\n if (childUploads.length > 0) {\n return true\n }\n\n if (relatedItemProperty && relatedItemProperty.localStoragePath) {\n const filePath = relatedItemProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n return false\n }\n\n return await BaseFileManager.pathExists(filePath)\n }\n\n return false\n}\n\nexport async function itemHasPublishUploadCandidates(\n item: IItem<any>,\n relatedItemProperty?: IItemProperty<any>,\n): Promise<boolean> {\n const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n await getSegmentedItemProperties(item)\n\n for (const uploadProperty of itemUploadProperties) {\n if (await uploadPropertyWouldUpload(uploadProperty, relatedItemProperty)) {\n return true\n }\n }\n\n if (await storageSeedHasUploadCandidates(itemImageProperties)) {\n return true\n }\n\n for (const relationProperty of itemRelationProperties) {\n const snapshot = relationProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n\n if (!propertyValue || relationProperty.uid) {\n continue\n }\n\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId && !seedUid) {\n throw new Error(\n `Invalid relation value for ${relationProperty.propertyName}: expected local seed id or 0x uid`,\n )\n }\n\n const relatedItem = await Item.find({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n if (await itemHasPublishUploadCandidates(relatedItem, relationProperty)) {\n return true\n }\n }\n\n return false\n}\n\nconst processUploadProperty = async (\n uploadProperty: UploadProperty,\n uploads: PublishUpload[],\n relatedItemProperty?: IItemProperty<any>,\n): Promise<PublishUpload[]> => {\n const itemProperty = uploadProperty.itemProperty\n\n const childUploads: ChildUploadData[] = []\n\n for (const childProperty of uploadProperty.childProperties) {\n const filePath = childProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n continue\n }\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n childUploads.push({\n propertyName: childProperty.propertyName,\n localStoragePath: filePath,\n })\n }\n\n let fileContents\n let transaction: ArweaveTransaction\n\n if (!childUploads || childUploads.length === 0) {\n if (relatedItemProperty && relatedItemProperty.localStoragePath) {\n const filePath = relatedItemProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n return uploads\n }\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n return uploads\n }\n\n try {\n const fileBuffer = await BaseFileManager.readFileAsBuffer(filePath)\n fileContents = await toUint8Array(fileBuffer)\n } catch (e) {\n const fs = await BaseFileManager.getFs()\n fileContents = await toUint8Array(fs.readFileSync(filePath))\n }\n }\n if (!fileContents) {\n return uploads\n }\n }\n\n if (childUploads.length > 0) {\n const separator = '===FILE_SEPARATOR==='\n // let compositeFileContents = `${itemProperty.propertyName}${separator}${mainFileContents}`\n let compositeFileContents = ''\n\n for (const childUpload of childUploads) {\n let childUploadContents\n\n const fs = await BaseFileManager.getFs()\n\n try {\n childUploadContents = await fs.promises.readFile(\n childUpload.localStoragePath,\n )\n } catch (e) {\n childUploadContents = fs.readFileSync(childUpload.localStoragePath)\n }\n\n compositeFileContents += `${separator}${childUpload.propertyName}${separator}${childUploadContents}`\n }\n\n if (typeof document !== 'undefined') {\n fileContents = new TextEncoder().encode(compositeFileContents)\n } else {\n fileContents = Buffer.from(compositeFileContents)\n }\n }\n\n if (!fileContents) {\n throw new Error(`No file contents found for ${itemProperty.propertyName}`)\n }\n\n const uint8Array = new Uint8Array(fileContents)\n\n const contentHash = await getContentHash(uint8Array)\n\n let contentType: string | undefined\n if (childUploads.length === 0 && relatedItemProperty?.localStoragePath) {\n contentType = getMimeTypeFromPath(relatedItemProperty.localStoragePath)\n } else if (childUploads.length > 0) {\n contentType = 'application/octet-stream'\n }\n\n transaction = await prepareArweaveTransaction(\n uint8Array,\n contentHash,\n contentType,\n )\n\n let itemPropertyLocalId = relatedItemProperty\n ? relatedItemProperty.localId\n : itemProperty.localId\n let itemPropertyName = relatedItemProperty\n ? relatedItemProperty.propertyName\n : itemProperty.propertyName\n\n uploads.push({\n itemPropertyName,\n itemPropertyLocalId,\n seedLocalId: itemProperty.seedLocalId!,\n versionLocalId: itemProperty.versionLocalId!,\n transactionToSign: transaction,\n })\n\n return uploads\n}\n\nexport const getPublishUploads = async (\n item: IItem<any>,\n uploads: PublishUpload[] = [],\n relatedItemProperty?: IItemProperty<any>,\n) => {\n // if (item.modelName === 'Post') {\n // if (!item.authors) {\n // item.authors = [\n // 'Sr0bIx9Fwj',\n // '0xc2879650e9503a303ceb46f966e55baab480b267dc20cede23ef503622eee6d7',\n // ]\n // }\n // }\n\n const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n await getSegmentedItemProperties(item)\n\n for (const uploadProperty of itemUploadProperties) {\n uploads = await processUploadProperty(\n uploadProperty,\n uploads,\n relatedItemProperty,\n )\n }\n\n const storageSeedUploads = await getStorageSeedUploads(itemImageProperties)\n uploads.push(...storageSeedUploads)\n\n for (const relationProperty of itemRelationProperties) {\n const snapshot = relationProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n\n if (!propertyValue || relationProperty.uid) {\n continue\n }\n\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId && !seedUid) {\n throw new Error(\n `Invalid relation value for ${relationProperty.propertyName}: expected local seed id or 0x uid`,\n )\n }\n\n const relatedItem = await Item.find({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n uploads = await getPublishUploads(relatedItem, uploads, relationProperty)\n }\n\n return uploads\n}\n"],"names":["BaseArweaveClient","BaseFileManager","resolveSeedIdsFromRefString","normalizeRelationPropertyValue","getContentHash","getSegmentedItemProperties","Item"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,MAAM,GAAG,KAAK,CAAC,gCAAgC,CAAC;AAEtD,MAAM,iBAAiB,GAA2B;AAChD,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,GAAG,EAAE,YAAY;AACjB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,GAAG,EAAE,eAAe;AACpB,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,IAAI,EAAE,kBAAkB;AACxB,IAAA,GAAG,EAAE,YAAY;CAClB;AAED,MAAM,mBAAmB,GAAG,CAAC,cAAsB,KAAwB;AACzE,IAAA,MAAM,GAAG,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE;AAC1D,IAAA,OAAO,GAAG,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,SAAS;AACjD,CAAC;AAED,MAAM,YAAY,GAAG,OAAO,IAAmB,KAAyB;IACtE,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,YAAY,IAAI,EAAE;QACvD,OAAO,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;IACjD;AACA,IAAA,OAAO,IAAI,UAAU,CAAC,IAAc,CAAC;AACvC,CAAC;AAEM,MAAM,yBAAyB,GAAG,OACvC,IAAyB,EACzB,WAA+B,EAC/B,WAAoB,KACW;IAC/B,MAAM,IAAI,GAAsC,EAAE;IAClD,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