@seedprotocol/sdk 0.4.6 → 0.4.7
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-DLKAaS3K.js → ArweaveClient-BdQaTOZ4.js} +3 -3
- package/dist/ArweaveClient-BdQaTOZ4.js.map +1 -0
- package/dist/{ArweaveClient-Caio37h1.js → ArweaveClient-nrTU_rhU.js} +3 -3
- package/dist/ArweaveClient-nrTU_rhU.js.map +1 -0
- package/dist/{Db-DJAG-5Di.js → Db-CWKaeNQH.js} +3 -102
- package/dist/Db-CWKaeNQH.js.map +1 -0
- package/dist/{Db-C9fppVRl.js → Db-Cq4q88X_.js} +21 -5
- package/dist/Db-Cq4q88X_.js.map +1 -0
- package/dist/{EasClient-DQGAIj-b.js → EasClient-Du9_TULE.js} +2 -2
- package/dist/EasClient-Du9_TULE.js.map +1 -0
- package/dist/{EasClient-T7Nx9185.js → EasClient-ZCIE6UQq.js} +2 -2
- package/dist/EasClient-ZCIE6UQq.js.map +1 -0
- package/dist/{FileManager-BohtoKYo.js → FileManager-Cub9icdd.js} +2 -2
- package/dist/FileManager-Cub9icdd.js.map +1 -0
- package/dist/{FileManager-d64CkqXy.js → FileManager-HSFEess-.js} +2 -2
- package/dist/FileManager-HSFEess-.js.map +1 -0
- package/dist/Item/Item.d.ts +2 -0
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/service/actors/loadOrCreateItem.d.ts.map +1 -1
- package/dist/Item/service/itemMachineSingle.d.ts.map +1 -1
- package/dist/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +1 -1
- package/dist/Model/Model.d.ts +5 -0
- package/dist/Model/Model.d.ts.map +1 -1
- package/dist/{ModelProperty-Cpd9xiIM.js → ModelProperty-D4zaeIOT.js} +22 -22
- package/dist/ModelProperty-D4zaeIOT.js.map +1 -0
- package/dist/{PathResolver-D6M0rzKV.js → PathResolver-DVLBs_qi.js} +2 -2
- package/dist/PathResolver-DVLBs_qi.js.map +1 -0
- package/dist/{PathResolver-CLZUWoX2.js → PathResolver-T1yEDECb.js} +2 -2
- package/dist/PathResolver-T1yEDECb.js.map +1 -0
- package/dist/{QueryClient-COQ_Rs4-.js → QueryClient-DcKDQuwz.js} +2 -2
- package/dist/QueryClient-DcKDQuwz.js.map +1 -0
- package/dist/{QueryClient-BUoz2Vb0.js → QueryClient-Vs9KN5kS.js} +2 -2
- package/dist/QueryClient-Vs9KN5kS.js.map +1 -0
- package/dist/{Schema-BZKBy5Tx.js → Schema-SbwqmoMM.js} +36 -36
- package/dist/Schema-SbwqmoMM.js.map +1 -0
- package/dist/{SchemaValidationService-F8No7BHp.js → SchemaValidationService-DHGIw4Nx.js} +2 -2
- package/dist/SchemaValidationService-DHGIw4Nx.js.map +1 -0
- package/dist/browser/db/drizzleFiles.d.ts +3 -2
- package/dist/browser/db/drizzleFiles.d.ts.map +1 -1
- package/dist/browser/react/item.d.ts +2 -0
- package/dist/browser/react/item.d.ts.map +1 -1
- package/dist/cjs/{ModelProperty-B4pV91tc.js → ModelProperty-DpjD0o0E.js} +16 -16
- package/dist/cjs/{ModelProperty-B4pV91tc.js.map → ModelProperty-DpjD0o0E.js.map} +1 -1
- package/dist/cjs/{Schema-TErl3J36.js → Schema-DkSBMBwz.js} +21 -21
- package/dist/cjs/{Schema-TErl3J36.js.map → Schema-DkSBMBwz.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-p5BbJV9T.js → SchemaValidationService-O3FCMROl.js} +2 -2
- package/dist/cjs/{SchemaValidationService-p5BbJV9T.js.map → SchemaValidationService-O3FCMROl.js.map} +1 -1
- package/dist/cjs/{getItem-BrnLfC12.js → getItem-BeAVMk54.js} +2 -2
- package/dist/cjs/{getItem-BrnLfC12.js.map → getItem-BeAVMk54.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-BcjCN_bD.js → getPublishPayload-CoLriAMV.js} +5 -5
- package/dist/cjs/{getPublishPayload-BcjCN_bD.js.map → getPublishPayload-CoLriAMV.js.map} +1 -1
- package/dist/cjs/{getPublishUploads-5_oXzwol.js → getPublishUploads-DDsT9zZ6.js} +3 -3
- package/dist/cjs/{getPublishUploads-5_oXzwol.js.map → getPublishUploads-DDsT9zZ6.js.map} +1 -1
- package/dist/cjs/{getSegmentedItemProperties-WFdizUDv.js → getSegmentedItemProperties-DGR0utR5.js} +2 -2
- package/dist/cjs/{getSegmentedItemProperties-WFdizUDv.js.map → getSegmentedItemProperties-DGR0utR5.js.map} +1 -1
- package/dist/cjs/{index-CXI4VF1H.js → index-B95Ng80C.js} +326 -180
- package/dist/cjs/index-B95Ng80C.js.map +1 -0
- package/dist/cjs/{index-BrmvhXsG.js → index-CvcOtzbi.js} +2 -2
- package/dist/cjs/index-CvcOtzbi.js.map +1 -0
- package/dist/cjs/ownership-Dm5ER1nI.js +103 -0
- package/dist/cjs/ownership-Dm5ER1nI.js.map +1 -0
- package/dist/client/ClientManager.d.ts +54 -43
- package/dist/client/ClientManager.d.ts.map +1 -1
- package/dist/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/client/clientManagerMachine.d.ts.map +1 -1
- package/dist/db/drizzle/drizzle/0004_add_publisher_to_seeds.sql +1 -0
- package/dist/db/drizzle/drizzle/meta/0004_snapshot.json +857 -0
- package/dist/db/drizzle/drizzle/meta/_journal.json +7 -0
- package/dist/db/read/getItemData.d.ts.map +1 -1
- package/dist/db/read/getItems.d.ts +2 -0
- package/dist/db/read/getItems.d.ts.map +1 -1
- package/dist/db/write/createNewItem.d.ts.map +1 -1
- package/dist/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/{getItem-DaQVdeae.js → getItem-CqrJt-Ee.js} +2 -2
- package/dist/getItem-CqrJt-Ee.js.map +1 -0
- package/dist/{getPublishPayload-CWiLI1yd.js → getPublishPayload-BRgULCf3.js} +5 -5
- package/dist/getPublishPayload-BRgULCf3.js.map +1 -0
- package/dist/{getPublishUploads-DhvcKD_9.js → getPublishUploads-B0WArDfp.js} +3 -3
- package/dist/getPublishUploads-B0WArDfp.js.map +1 -0
- package/dist/{getSegmentedItemProperties-Cp4kcWIF.js → getSegmentedItemProperties-DZL9Ymd4.js} +2 -2
- package/dist/getSegmentedItemProperties-DZL9Ymd4.js.map +1 -0
- package/dist/helpers/addresses.d.ts +12 -0
- package/dist/helpers/addresses.d.ts.map +1 -0
- package/dist/helpers/db.d.ts +11 -0
- package/dist/helpers/db.d.ts.map +1 -1
- package/dist/helpers/ownership.d.ts +16 -0
- package/dist/helpers/ownership.d.ts.map +1 -0
- package/dist/{index-DBy53qbb.js → index-BIPPEMVY.js} +2 -2
- package/dist/index-BIPPEMVY.js.map +1 -0
- package/dist/{index-LfXKx_PE.js → index-BnF3MRZ8.js} +3 -3
- package/dist/index-BnF3MRZ8.js.map +1 -0
- package/dist/{index-Dk73a7JE.js → index-zsq08F5p.js} +342 -98
- package/dist/index-zsq08F5p.js.map +1 -0
- package/dist/main.cjs +1 -1
- package/dist/main.js +18 -15
- package/dist/main.js.map +1 -1
- package/dist/node/db/Db.d.ts.map +1 -1
- package/dist/node.js +10 -10
- package/dist/node.js.map +1 -1
- package/dist/ownership-CSsweVap.js +85 -0
- package/dist/ownership-CSsweVap.js.map +1 -0
- package/dist/{property-1o2MvYTm.js → property-Cqh_o0zx.js} +5 -5
- package/dist/property-Cqh_o0zx.js.map +1 -0
- package/dist/{queries-DA4G0iEN.js → queries-DSBgjcJJ.js} +2 -2
- package/dist/queries-DSBgjcJJ.js.map +1 -0
- package/dist/seedSchema/ModelSchemaSchema.d.ts +1 -1
- package/dist/seedSchema/ModelSchemaSchema.ts +4 -4
- package/dist/seedSchema/ModelUidSchema.ts +1 -1
- package/dist/seedSchema/PropertyUidSchema.ts +1 -1
- package/dist/seedSchema/SeedSchema.d.ts +19 -0
- package/dist/seedSchema/SeedSchema.d.ts.map +1 -1
- package/dist/seedSchema/SeedSchema.ts +1 -0
- package/dist/seedSchema/index.d.ts +10 -10
- package/dist/seedSchema/index.d.ts.map +1 -1
- package/dist/seedSchema/index.ts +10 -10
- package/dist/types/index.d.ts +11 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/item.d.ts +1 -0
- package/dist/types/item.d.ts.map +1 -1
- package/dist/types/machines.d.ts +2 -0
- package/dist/types/machines.d.ts.map +1 -1
- package/dist/vite.js.map +1 -1
- package/package.json +2 -9
- package/dist/ArweaveClient-Caio37h1.js.map +0 -1
- package/dist/ArweaveClient-DLKAaS3K.js.map +0 -1
- package/dist/Db-C9fppVRl.js.map +0 -1
- package/dist/Db-DJAG-5Di.js.map +0 -1
- package/dist/EasClient-DQGAIj-b.js.map +0 -1
- package/dist/EasClient-T7Nx9185.js.map +0 -1
- package/dist/FileManager-BohtoKYo.js.map +0 -1
- package/dist/FileManager-d64CkqXy.js.map +0 -1
- package/dist/ModelProperty-Cpd9xiIM.js.map +0 -1
- package/dist/PathResolver-CLZUWoX2.js.map +0 -1
- package/dist/PathResolver-D6M0rzKV.js.map +0 -1
- package/dist/QueryClient-BUoz2Vb0.js.map +0 -1
- package/dist/QueryClient-COQ_Rs4-.js.map +0 -1
- package/dist/Schema-BZKBy5Tx.js.map +0 -1
- package/dist/SchemaValidationService-F8No7BHp.js.map +0 -1
- package/dist/cjs/index-BrmvhXsG.js.map +0 -1
- package/dist/cjs/index-CXI4VF1H.js.map +0 -1
- package/dist/getItem-DaQVdeae.js.map +0 -1
- package/dist/getPublishPayload-CWiLI1yd.js.map +0 -1
- package/dist/getPublishUploads-DhvcKD_9.js.map +0 -1
- package/dist/getSegmentedItemProperties-Cp4kcWIF.js.map +0 -1
- package/dist/index-DBy53qbb.js.map +0 -1
- package/dist/index-Dk73a7JE.js.map +0 -1
- package/dist/index-LfXKx_PE.js.map +0 -1
- package/dist/property-1o2MvYTm.js.map +0 -1
- package/dist/queries-DA4G0iEN.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { w as BaseArweaveClient } from './index-zsq08F5p.js';
|
|
2
2
|
import { GraphQLClient } from 'graphql-request';
|
|
3
3
|
import Arweave from 'arweave';
|
|
4
|
-
import { G as GET_TRANSACTION_TAGS } from './queries-
|
|
4
|
+
import { G as GET_TRANSACTION_TAGS } from './queries-DSBgjcJJ.js';
|
|
5
5
|
import debug from 'debug';
|
|
6
6
|
import 'xstate';
|
|
7
7
|
import 'drizzle-orm/sqlite-core';
|
|
@@ -199,4 +199,4 @@ class ArweaveClient extends BaseArweaveClient {
|
|
|
199
199
|
BaseArweaveClient.setPlatformClass(ArweaveClient);
|
|
200
200
|
|
|
201
201
|
export { ArweaveClient };
|
|
202
|
-
//# sourceMappingURL=ArweaveClient-
|
|
202
|
+
//# sourceMappingURL=ArweaveClient-BdQaTOZ4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArweaveClient-BdQaTOZ4.js","sources":["../src/node/helpers/ArweaveClient.ts"],"sourcesContent":["import { BaseArweaveClient } from '@/helpers/ArweaveClient/BaseArweaveClient';\nimport { GraphQLClient } from 'graphql-request';\nimport Arweave from 'arweave';\nimport type {\n TransactionStatus,\n TransactionTag,\n GetDataOptions,\n DownloadFilesParams,\n DownloadResult,\n CreateTransactionOptions,\n} from '@/types/arweave';\nimport { GET_TRANSACTION_TAGS } from '@/helpers/ArweaveClient/queries';\nimport debug from 'debug';\n\nconst logger = debug('seedSdk:node:ArweaveClient');\n\n// Cached Arweave instance\nlet _arweaveInstance: Arweave | null = null;\n\n/**\n * Get or create the Arweave instance for Node.js\n */\nconst getArweaveInstance = (): Arweave => {\n if (_arweaveInstance) {\n return _arweaveInstance;\n }\n\n const host = BaseArweaveClient.getHost();\n\n // Handle both ES modules and CommonJS exports from arweave package\n if ('default' in Arweave && typeof (Arweave as any).default?.init === 'function') {\n _arweaveInstance = (Arweave as any).default.init({\n host,\n protocol: 'https',\n });\n } else {\n _arweaveInstance = Arweave.init({\n host,\n protocol: 'https',\n });\n }\n\n return _arweaveInstance!;\n};\n\nclass ArweaveClient extends BaseArweaveClient {\n /**\n * Get the GraphQL client for Arweave queries\n */\n static getArweaveClient(): GraphQLClient {\n return new GraphQLClient(BaseArweaveClient.getEndpoint());\n }\n\n /**\n * Get the status of a transaction\n */\n static async getTransactionStatus(transactionId: string): Promise<TransactionStatus> {\n const url = BaseArweaveClient.getStatusUrl(transactionId);\n \n try {\n const response = await fetch(url);\n \n if (response.status === 404) {\n return {\n status: 404,\n confirmed: null,\n };\n }\n\n if (!response.ok) {\n return {\n status: response.status,\n confirmed: null,\n };\n }\n\n const data = await response.json();\n return {\n status: 200,\n confirmed: {\n block_height: data.block_height,\n block_indep_hash: data.block_indep_hash,\n number_of_confirmations: data.number_of_confirmations,\n },\n };\n } catch (error) {\n logger('Error fetching transaction status:', error);\n return {\n status: 500,\n confirmed: null,\n };\n }\n }\n\n /**\n * Get transaction data\n */\n static async getTransactionData(\n transactionId: string,\n options?: GetDataOptions\n ): Promise<Uint8Array | string> {\n const arweave = getArweaveInstance();\n\n try {\n const data = await arweave.transactions.getData(transactionId, {\n decode: options?.decode ?? true,\n string: options?.string ?? false,\n });\n\n if (options?.string && typeof data === 'string') {\n return data;\n }\n\n // Ensure we return Uint8Array\n if (data instanceof Uint8Array) {\n return data;\n }\n\n // Handle string data when not requesting string\n if (typeof data === 'string') {\n return new TextEncoder().encode(data);\n }\n\n return data as Uint8Array;\n } catch (error) {\n logger('Error fetching transaction data:', error);\n throw error;\n }\n }\n\n /**\n * Get transaction tags via GraphQL\n */\n static async getTransactionTags(transactionId: string): Promise<TransactionTag[]> {\n const client = this.getArweaveClient();\n \n try {\n const result = await client.request(GET_TRANSACTION_TAGS, { transactionId });\n \n if (!result.tags?.tags) {\n return [];\n }\n\n return result.tags.tags.map((tag: { name: string; value: string }) => ({\n name: tag.name,\n value: tag.value,\n }));\n } catch (error) {\n logger('Error fetching transaction tags:', error);\n return [];\n }\n }\n\n /**\n * Create a new unsigned transaction\n */\n static async createTransaction(\n data: string | Uint8Array,\n options?: CreateTransactionOptions\n ): Promise<any> {\n const arweave = getArweaveInstance();\n\n const tx = await arweave.createTransaction({\n data,\n });\n\n // Add tags if provided\n if (options?.tags) {\n for (const tag of options.tags) {\n tx.addTag(tag.name, tag.value);\n }\n }\n\n return tx;\n }\n\n /**\n * Download multiple files from Arweave\n */\n static async downloadFiles(params: DownloadFilesParams): Promise<DownloadResult[]> {\n const { transactionIds, excludedTransactions } = params;\n const results: DownloadResult[] = [];\n const host = BaseArweaveClient.getHost();\n\n for (const transactionId of transactionIds) {\n // Skip excluded transactions\n if (excludedTransactions?.has(transactionId)) {\n continue;\n }\n\n try {\n const url = `https://${host}/raw/${transactionId}`;\n const response = await fetch(url);\n\n if (!response.ok) {\n results.push({\n transactionId,\n success: false,\n error: `HTTP ${response.status}: ${response.statusText}`,\n });\n continue;\n }\n\n const arrayBuffer = await response.arrayBuffer();\n const data = new Uint8Array(arrayBuffer);\n\n // Detect content type\n const contentType = response.headers.get('content-type') || undefined;\n\n results.push({\n transactionId,\n success: true,\n contentType,\n data,\n });\n } catch (error) {\n logger(`Error downloading transaction ${transactionId}:`, error);\n results.push({\n transactionId,\n success: false,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n return results;\n }\n}\n\nBaseArweaveClient.setPlatformClass(ArweaveClient);\n\nexport { ArweaveClient };"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAcA,MAAM,MAAM,GAAG,KAAK,CAAC,4BAA4B,CAAC;AAElD;AACA,IAAI,gBAAgB,GAAmB,IAAI;AAE3C;;AAEG;AACH,MAAM,kBAAkB,GAAG,MAAc;IACvC,IAAI,gBAAgB,EAAE;AACpB,QAAA,OAAO,gBAAgB;IACzB;AAEA,IAAA,MAAM,IAAI,GAAG,iBAAiB,CAAC,OAAO,EAAE;;AAGxC,IAAA,IAAI,SAAS,IAAI,OAAO,IAAI,OAAQ,OAAe,CAAC,OAAO,EAAE,IAAI,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C,GAAG,CAAC;AAEjC,gBAAA,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;oBAChB,OAAO,CAAC,IAAI,CAAC;wBACX,aAAa;AACb,wBAAA,OAAO,EAAE,KAAK;wBACd,KAAK,EAAE,QAAQ,QAAQ,CAAC,MAAM,CAAA,EAAA,EAAK,QAAQ,CAAC,UAAU,CAAA,CAAE;AACzD,qBAAA,CAAC;oBACF;gBACF;AAEA,gBAAA,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE;AAChD,gBAAA,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC;;AAGxC,gBAAA,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,SAAS;gBAErE,OAAO,CAAC,IAAI,CAAC;oBACX,aAAa;AACb,oBAAA,OAAO,EAAE,IAAI;oBACb,WAAW;oBACX,IAAI;AACL,iBAAA,CAAC;YACJ;YAAE,OAAO,KAAK,EAAE;AACd,gBAAA,MAAM,CAAC,CAAA,8BAAA,EAAiC,aAAa,GAAG,EAAE,KAAK,CAAC;gBAChE,OAAO,CAAC,IAAI,CAAC;oBACX,aAAa;AACb,oBAAA,OAAO,EAAE,KAAK;AACd,oBAAA,KAAK,EAAE,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;AAC9D,iBAAA,CAAC;YACJ;QACF;AAEA,QAAA,OAAO,OAAO;IAChB;AACD;AAED,iBAAiB,CAAC,gBAAgB,CAAC,aAAa,CAAC;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { w as BaseArweaveClient } from './index-zsq08F5p.js';
|
|
2
2
|
import { GraphQLClient } from 'graphql-request';
|
|
3
3
|
import Arweave from 'arweave';
|
|
4
|
-
import { G as GET_TRANSACTION_TAGS } from './queries-
|
|
4
|
+
import { G as GET_TRANSACTION_TAGS } from './queries-DSBgjcJJ.js';
|
|
5
5
|
import debug from 'debug';
|
|
6
6
|
import 'xstate';
|
|
7
7
|
import 'drizzle-orm/sqlite-core';
|
|
@@ -199,4 +199,4 @@ class ArweaveClient extends BaseArweaveClient {
|
|
|
199
199
|
BaseArweaveClient.setPlatformClass(ArweaveClient);
|
|
200
200
|
|
|
201
201
|
export { ArweaveClient };
|
|
202
|
-
//# sourceMappingURL=ArweaveClient-
|
|
202
|
+
//# sourceMappingURL=ArweaveClient-nrTU_rhU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArweaveClient-nrTU_rhU.js","sources":["../src/browser/helpers/ArweaveClient.ts"],"sourcesContent":["import { BaseArweaveClient } from \"@/helpers/ArweaveClient/BaseArweaveClient\";\nimport { GraphQLClient } from \"graphql-request\";\nimport Arweave from \"arweave\";\nimport type {\n TransactionStatus,\n TransactionTag,\n GetDataOptions,\n DownloadFilesParams,\n DownloadResult,\n CreateTransactionOptions,\n} from \"@/types/arweave\";\nimport { GET_TRANSACTION_TAGS } from \"@/helpers/ArweaveClient/queries\";\nimport debug from \"debug\";\n\nconst logger = debug(\"seedSdk:browser:ArweaveClient\");\n\n// Cached Arweave instance\nlet _arweaveInstance: Arweave | null = null;\n\n/**\n * Get or create the Arweave instance for browser\n */\nconst getArweaveInstance = (): Arweave => {\n if (_arweaveInstance) {\n return _arweaveInstance;\n }\n\n const host = BaseArweaveClient.getHost();\n\n // Handle both ES modules and CommonJS exports from arweave package\n if (\"default\" in Arweave && typeof (Arweave as any).default?.init === \"function\") {\n _arweaveInstance = (Arweave as any).default.init({\n host,\n protocol: \"https\",\n });\n } else {\n _arweaveInstance = Arweave.init({\n host,\n protocol: \"https\",\n });\n }\n\n return _arweaveInstance!;\n};\n\nclass ArweaveClient extends BaseArweaveClient {\n /**\n * Get the GraphQL client for Arweave queries\n */\n static getArweaveClient(): GraphQLClient {\n return new GraphQLClient(BaseArweaveClient.getEndpoint());\n }\n\n /**\n * Get the status of a transaction\n */\n static async getTransactionStatus(transactionId: string): Promise<TransactionStatus> {\n const url = BaseArweaveClient.getStatusUrl(transactionId);\n \n try {\n const response = await fetch(url);\n \n if (response.status === 404) {\n return {\n status: 404,\n confirmed: null,\n };\n }\n\n if (!response.ok) {\n return {\n status: response.status,\n confirmed: null,\n };\n }\n\n const data = await response.json();\n return {\n status: 200,\n confirmed: {\n block_height: data.block_height,\n block_indep_hash: data.block_indep_hash,\n number_of_confirmations: data.number_of_confirmations,\n },\n };\n } catch (error) {\n logger(\"Error fetching transaction status:\", error);\n return {\n status: 500,\n confirmed: null,\n };\n }\n }\n\n /**\n * Get transaction data\n */\n static async getTransactionData(\n transactionId: string,\n options?: GetDataOptions\n ): Promise<Uint8Array | string> {\n const arweave = getArweaveInstance();\n\n try {\n const data = await arweave.transactions.getData(transactionId, {\n decode: options?.decode ?? true,\n string: options?.string ?? false,\n });\n\n if (options?.string && typeof data === \"string\") {\n return data;\n }\n\n // Ensure we return Uint8Array\n if (data instanceof Uint8Array) {\n return data;\n }\n\n // Handle string data when not requesting string\n if (typeof data === \"string\") {\n return new TextEncoder().encode(data);\n }\n\n return data as Uint8Array;\n } catch (error) {\n logger(\"Error fetching transaction data:\", error);\n throw error;\n }\n }\n\n /**\n * Get transaction tags via GraphQL\n */\n static async getTransactionTags(transactionId: string): Promise<TransactionTag[]> {\n const client = this.getArweaveClient();\n \n try {\n const result = await client.request(GET_TRANSACTION_TAGS, { transactionId });\n \n if (!result.tags?.tags) {\n return [];\n }\n\n return result.tags.tags.map((tag: { name: string; value: string }) => ({\n name: tag.name,\n value: tag.value,\n }));\n } catch (error) {\n logger(\"Error fetching transaction tags:\", error);\n return [];\n }\n }\n\n /**\n * Create a new unsigned transaction\n */\n static async createTransaction(\n data: string | Uint8Array,\n options?: CreateTransactionOptions\n ): Promise<any> {\n const arweave = getArweaveInstance();\n\n const tx = await arweave.createTransaction({\n data,\n });\n\n // Add tags if provided\n if (options?.tags) {\n for (const tag of options.tags) {\n tx.addTag(tag.name, tag.value);\n }\n }\n\n return tx;\n }\n\n /**\n * Download multiple files from Arweave\n */\n static async downloadFiles(params: DownloadFilesParams): Promise<DownloadResult[]> {\n const { transactionIds, excludedTransactions } = params;\n const results: DownloadResult[] = [];\n const host = BaseArweaveClient.getHost();\n\n for (const transactionId of transactionIds) {\n // Skip excluded transactions\n if (excludedTransactions?.has(transactionId)) {\n continue;\n }\n\n try {\n const url = `https://${host}/raw/${transactionId}`;\n const response = await fetch(url);\n\n if (!response.ok) {\n results.push({\n transactionId,\n success: false,\n error: `HTTP ${response.status}: ${response.statusText}`,\n });\n continue;\n }\n\n const arrayBuffer = await response.arrayBuffer();\n const data = new Uint8Array(arrayBuffer);\n\n // Detect content type\n const contentType = response.headers.get(\"content-type\") || undefined;\n\n results.push({\n transactionId,\n success: true,\n contentType,\n data,\n });\n } catch (error) {\n logger(`Error downloading transaction ${transactionId}:`, error);\n results.push({\n transactionId,\n success: false,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n return results;\n }\n}\n\nBaseArweaveClient.setPlatformClass(ArweaveClient);\n\nexport { ArweaveClient };"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAcA,MAAM,MAAM,GAAG,KAAK,CAAC,+BAA+B,CAAC;AAErD;AACA,IAAI,gBAAgB,GAAmB,IAAI;AAE3C;;AAEG;AACH,MAAM,kBAAkB,GAAG,MAAc;IACvC,IAAI,gBAAgB,EAAE;AACpB,QAAA,OAAO,gBAAgB;IACzB;AAEA,IAAA,MAAM,IAAI,GAAG,iBAAiB,CAAC,OAAO,EAAE;;AAGxC,IAAA,IAAI,SAAS,IAAI,OAAO,IAAI,OAAQ,OAAe,CAAC,OAAO,EAAE,IAAI,KAAK,UAAU,EAAE;AAChF,QAAA,gBAAgB,GAAI,OAAe,CAAC,OAAO,CAAC,IAAI,CAAC;YAC/C,IAAI;AACJ,YAAA,QAAQ,EAAE,OAAO;AAClB,SAAA,CAAC;IACJ;SAAO;AACL,QAAA,gBAAgB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AAC,MAAM,CAAA,EAAA,EAAK,QAAQ,CAAC,UAAU,CAAA,CAAE;AACzD,qBAAA,CAAC;oBACF;gBACF;AAEA,gBAAA,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE;AAChD,gBAAA,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC;;AAGxC,gBAAA,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,SAAS;gBAErE,OAAO,CAAC,IAAI,CAAC;oBACX,aAAa;AACb,oBAAA,OAAO,EAAE,IAAI;oBACb,WAAW;oBACX,IAAI;AACL,iBAAA,CAAC;YACJ;YAAE,OAAO,KAAK,EAAE;AACd,gBAAA,MAAM,CAAC,CAAA,8BAAA,EAAiC,aAAa,GAAG,EAAE,KAAK,CAAC;gBAChE,OAAO,CAAC,IAAI,CAAC;oBACX,aAAa;AACb,oBAAA,OAAO,EAAE,KAAK;AACd,oBAAA,KAAK,EAAE,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;AAC9D,iBAAA,CAAC;YACJ;QACF;AAEA,QAAA,OAAO,OAAO;IAChB;AACD;AAED,iBAAiB,CAAC,gBAAgB,CAAC,aAAa,CAAC;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as BaseDb, A as appState } from './index-zsq08F5p.js';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import debug from 'debug';
|
|
4
|
-
import { s as schema } from './index-
|
|
4
|
+
import { s as schema } from './index-BIPPEMVY.js';
|
|
5
5
|
import fs__default from 'fs';
|
|
6
6
|
import { createClient } from '@libsql/client';
|
|
7
7
|
import { drizzle } from 'drizzle-orm/libsql';
|
|
@@ -73,105 +73,6 @@ class Db extends BaseDb {
|
|
|
73
73
|
// You can inspect what will happen before applying
|
|
74
74
|
await apply();
|
|
75
75
|
this.db = db;
|
|
76
|
-
// OLD CODE: Resolve better-sqlite3 from project's node_modules first, then fall back to SDK's node_modules
|
|
77
|
-
// This is important for tests and when the SDK is used as a dependency
|
|
78
|
-
// const projectDir = path.dirname(filesDir) // filesDir is .seed, so projectDir is the project root
|
|
79
|
-
// const projectBetterSqlite3Path = path.join(projectDir, 'node_modules', 'better-sqlite3')
|
|
80
|
-
//
|
|
81
|
-
// let Database: any
|
|
82
|
-
// try {
|
|
83
|
-
// const fs = await import('fs')
|
|
84
|
-
// if (fs.existsSync(projectBetterSqlite3Path)) {
|
|
85
|
-
// // Try to resolve from project's node_modules using the full path
|
|
86
|
-
// // For Bun, we can try importing directly from the path
|
|
87
|
-
// try {
|
|
88
|
-
// // First try using createRequire (works in Node.js)
|
|
89
|
-
// const { createRequire } = await import('module')
|
|
90
|
-
// const projectRequire = createRequire(path.join(projectDir, 'package.json'))
|
|
91
|
-
// const betterSqlite3Module = projectRequire('better-sqlite3')
|
|
92
|
-
// Database = betterSqlite3Module.default || betterSqlite3Module
|
|
93
|
-
// logger('[node/db/Db] Using better-sqlite3 from project node_modules via createRequire')
|
|
94
|
-
// } catch (requireError: any) {
|
|
95
|
-
// // If createRequire fails (e.g., in Bun), try direct path import
|
|
96
|
-
// logger('[node/db/Db] createRequire failed, trying direct import:', requireError.message)
|
|
97
|
-
// const betterSqlite3MainPath = path.join(projectBetterSqlite3Path, 'lib', 'database.js')
|
|
98
|
-
// if (fs.existsSync(betterSqlite3MainPath)) {
|
|
99
|
-
// // Use dynamic import with the full path
|
|
100
|
-
// const betterSqlite3Module = await import(betterSqlite3MainPath)
|
|
101
|
-
// Database = betterSqlite3Module.default || betterSqlite3Module.Database || betterSqlite3Module
|
|
102
|
-
// logger('[node/db/Db] Using better-sqlite3 from project node_modules via direct import')
|
|
103
|
-
// } else {
|
|
104
|
-
// throw new Error(`better-sqlite3 main file not found at ${betterSqlite3MainPath}`)
|
|
105
|
-
// }
|
|
106
|
-
// }
|
|
107
|
-
// } else {
|
|
108
|
-
// // Fall back to regular import (from SDK's node_modules)
|
|
109
|
-
// const betterSqlite3Module = await import('better-sqlite3')
|
|
110
|
-
// Database = betterSqlite3Module.default || betterSqlite3Module
|
|
111
|
-
// logger('[node/db/Db] Using better-sqlite3 from SDK node_modules')
|
|
112
|
-
// }
|
|
113
|
-
// } catch (importError: any) {
|
|
114
|
-
// logger('[node/db/Db] Error importing better-sqlite3:', importError.message)
|
|
115
|
-
// logger('[node/db/Db] projectDir:', projectDir)
|
|
116
|
-
// logger('[node/db/Db] projectBetterSqlite3Path:', projectBetterSqlite3Path)
|
|
117
|
-
// throw new Error(`Failed to import better-sqlite3: ${importError.message}. Please install better-sqlite3 in your project.`)
|
|
118
|
-
// }
|
|
119
|
-
// OLD CODE: Create Database instance
|
|
120
|
-
// const sqlite = new Database(dbPath)
|
|
121
|
-
//
|
|
122
|
-
// OLD CODE: Create drizzle instance with the Database
|
|
123
|
-
// const {drizzle} = await import('drizzle-orm/better-sqlite3')
|
|
124
|
-
// this.db = drizzle(sqlite, {
|
|
125
|
-
// logger: true,
|
|
126
|
-
// })
|
|
127
|
-
// // NEW CODE: Use libsql instead of better-sqlite3
|
|
128
|
-
// // Resolve @libsql/client from project's node_modules first, then fall back to SDK's node_modules
|
|
129
|
-
// const projectDir = path.dirname(filesDir) // filesDir is .seed, so projectDir is the project root
|
|
130
|
-
// const projectLibsqlClientPath = path.join(projectDir, 'node_modules', '@libsql', 'client')
|
|
131
|
-
// let createClient: any
|
|
132
|
-
// try {
|
|
133
|
-
// const fs = await import('fs')
|
|
134
|
-
// if (fs.existsSync(projectLibsqlClientPath)) {
|
|
135
|
-
// // Try to resolve from project's node_modules using the full path
|
|
136
|
-
// try {
|
|
137
|
-
// // First try using createRequire (works in Node.js)
|
|
138
|
-
// const { createRequire } = await import('module')
|
|
139
|
-
// const projectRequire = createRequire(path.join(projectDir, 'package.json'))
|
|
140
|
-
// const libsqlClientModule = projectRequire('@libsql/client')
|
|
141
|
-
// createClient = libsqlClientModule.createClient || libsqlClientModule.default?.createClient || libsqlClientModule.default
|
|
142
|
-
// logger('[node/db/Db] Using @libsql/client from project node_modules via createRequire')
|
|
143
|
-
// } catch (requireError: any) {
|
|
144
|
-
// // If createRequire fails, try direct import
|
|
145
|
-
// logger('[node/db/Db] createRequire failed, trying direct import:', requireError.message)
|
|
146
|
-
// const libsqlClientModule = await import('@libsql/client')
|
|
147
|
-
// createClient = libsqlClientModule.createClient
|
|
148
|
-
// logger('[node/db/Db] Using @libsql/client from project node_modules via direct import')
|
|
149
|
-
// }
|
|
150
|
-
// } else {
|
|
151
|
-
// // Fall back to regular import (from SDK's node_modules)
|
|
152
|
-
// const libsqlClientModule = await import('@libsql/client')
|
|
153
|
-
// createClient = libsqlClientModule.createClient
|
|
154
|
-
// logger('[node/db/Db] Using @libsql/client from SDK node_modules')
|
|
155
|
-
// }
|
|
156
|
-
// } catch (importError: any) {
|
|
157
|
-
// logger('[node/db/Db] Error importing @libsql/client:', importError.message)
|
|
158
|
-
// logger('[node/db/Db] projectDir:', projectDir)
|
|
159
|
-
// logger('[node/db/Db] projectLibsqlClientPath:', projectLibsqlClientPath)
|
|
160
|
-
// throw new Error(`Failed to import @libsql/client: ${importError.message}. Please install @libsql/client in your project.`)
|
|
161
|
-
// }
|
|
162
|
-
// // Convert file path to file: URL for libsql
|
|
163
|
-
// // If dbPath is already a file: URL, use it as is, otherwise convert it
|
|
164
|
-
// const dbUrl = dbPath.startsWith('file:') ? dbPath : `file:${path.resolve(dbPath)}`
|
|
165
|
-
// // Create libsql client instance
|
|
166
|
-
// const client = createClient({ url: dbUrl })
|
|
167
|
-
// // Create drizzle instance with the libsql client
|
|
168
|
-
// const {drizzle} = await import('drizzle-orm/libsql')
|
|
169
|
-
// this.db = drizzle(client, {
|
|
170
|
-
// logger: true,
|
|
171
|
-
// })
|
|
172
|
-
// if (!this.db) {
|
|
173
|
-
// throw new Error('Db not found')
|
|
174
|
-
// }
|
|
175
76
|
return this.db;
|
|
176
77
|
}
|
|
177
78
|
static async connectToDb(pathToDir) {
|
|
@@ -342,4 +243,4 @@ class Db extends BaseDb {
|
|
|
342
243
|
BaseDb.setPlatformClass(Db);
|
|
343
244
|
|
|
344
245
|
export { Db };
|
|
345
|
-
//# sourceMappingURL=Db-
|
|
246
|
+
//# sourceMappingURL=Db-CWKaeNQH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Db-CWKaeNQH.js","sources":["../src/node/db/Db.ts"],"sourcesContent":["import { BaseDb } from \"@/db/Db/BaseDb\";\nimport { IDb } from \"@/interfaces\";\nimport path from \"path\";\nimport { DrizzleConfig, } from \"drizzle-orm\";\nimport debug from 'debug'\nimport { appState } from '@/seedSchema'\nimport fs from 'fs'\nimport { createClient } from '@libsql/client'\nimport { drizzle } from 'drizzle-orm/libsql'\nimport { pushSQLiteSchema } from 'drizzle-kit/api'\nimport * as schema from '@/seedSchema'\nimport { Observable, interval, switchMap, distinctUntilChanged, startWith } from 'rxjs'\n\nconst logger = debug('seedSdk:node:db:Db')\n\nexport interface DbConfig {\n dbUrl?: string\n schemaDir?: string\n outDir?: string\n}\n\nconst getConfig = async (dotSeedDir: string, config?: DbConfig) => {\n // Create config inline - config values can be passed in or use defaults\n const drizzleKitMod = await import('drizzle-kit')\n const { defineConfig } = drizzleKitMod\n const appSchemaDir = config?.schemaDir || path.join(dotSeedDir, 'schema')\n const outDir = config?.outDir || `${dotSeedDir}/db`\n const dbUrl = config?.dbUrl || `${dotSeedDir}/db/seed.db`\n\n const nodeDbConfig = defineConfig({\n schema: appSchemaDir,\n dialect: 'sqlite',\n out: outDir,\n dbCredentials: {\n url: dbUrl,\n }\n }) as DrizzleConfig & { dbCredentials: { url: string } }\n\n return nodeDbConfig\n}\n\nclass Db extends BaseDb implements IDb {\n static db: any\n\n constructor() {\n super()\n }\n\n static getAppDb() {\n return this.db\n }\n\n static isAppDbReady() {\n return true\n }\n\n static async prepareDb(filesDir: string, config?: DbConfig) {\n // Resolve and normalize the filesDir path\n const resolvedFilesDir = path.resolve(filesDir)\n \n // Ensure the filesDir exists first (parent directory)\n if (!fs.existsSync(resolvedFilesDir)) {\n fs.mkdirSync(resolvedFilesDir, { recursive: true })\n }\n \n const nodeDbConfig = await getConfig(resolvedFilesDir, config)\n const dbPath = nodeDbConfig.dbCredentials?.url || path.join(resolvedFilesDir, 'db', 'seed.db')\n\n // Ensure the database directory exists\n const dbDir = path.dirname(dbPath)\n const dbDirExists = fs.existsSync(dbDir)\n if (!dbDirExists) {\n fs.mkdirSync(dbDir, { recursive: true })\n }\n \n // Use the dbUrl from config if provided, otherwise construct from filesDir\n const dbUrl = config?.dbUrl \n ? (config.dbUrl.startsWith('file:') ? config.dbUrl : `file:${path.resolve(config.dbUrl)}`)\n : `file:${path.resolve(dbPath)}`\n const client = createClient({ url: dbUrl })\n \n const db = drizzle(client, {schema})\n \n const { apply, hasDataLoss, warnings, statementsToExecute } = await pushSQLiteSchema(schema, db);\n \n // You can inspect what will happen before applying\n await apply();\n\n this.db = db\n\n return this.db\n }\n\n static async connectToDb(pathToDir: string,) {\n\n return {\n id: this.db ? this.db.constructor.name : ''\n }\n }\n\n static async migrate(pathToDbDir: string, dbName: string, dbId: string) {\n const fs = await import('fs')\n const path = await import('path')\n \n // Ensure meta directory and _journal.json exist\n const metaDir = path.join(pathToDbDir, 'meta')\n const journalPath = path.join(metaDir, '_journal.json')\n \n try {\n if (!fs.existsSync(metaDir)) {\n fs.mkdirSync(metaDir, { recursive: true })\n }\n \n // Create a minimal _journal.json if it doesn't exist\n if (!fs.existsSync(journalPath)) {\n const minimalJournal = {\n version: \"7\",\n dialect: \"sqlite\",\n entries: []\n }\n fs.writeFileSync(journalPath, JSON.stringify(minimalJournal, null, 2))\n logger('Created minimal _journal.json file')\n } else {\n // Verify the journal file is valid JSON\n try {\n const journalContent = fs.readFileSync(journalPath, 'utf-8')\n const journal = JSON.parse(journalContent)\n if (!journal.dialect || !journal.version) {\n // Fix invalid journal\n const fixedJournal = {\n version: journal.version || \"7\",\n dialect: journal.dialect || \"sqlite\",\n entries: journal.entries || []\n }\n fs.writeFileSync(journalPath, JSON.stringify(fixedJournal, null, 2))\n logger('Fixed invalid _journal.json file')\n }\n } catch (parseError) {\n // If journal is invalid, recreate it\n const minimalJournal = {\n version: \"7\",\n dialect: \"sqlite\",\n entries: []\n }\n fs.writeFileSync(journalPath, JSON.stringify(minimalJournal, null, 2))\n logger('Recreated corrupted _journal.json file')\n }\n }\n } catch (error: any) {\n logger('Warning: Could not create meta/_journal.json:', error.message)\n // Continue anyway - the migrator might handle it\n }\n \n try {\n if (!this.db) {\n throw new Error('Database not initialized. Call prepareDb first.')\n }\n \n // OLD CODE: const {migrate} = await import('drizzle-orm/better-sqlite3/migrator')\n // migrationsFolder should point to the directory containing migration SQL files\n // In drizzle-kit, migrations are generated in the 'out' directory (which is pathToDbDir)\n // migrate(this.db, { migrationsFolder: pathToDbDir })\n \n // NEW CODE: Use libsql migrator\n const migratorMod = await import('drizzle-orm/libsql/migrator')\n const { migrate } = migratorMod\n // migrationsFolder should point to the directory containing migration SQL files\n // In drizzle-kit, migrations are generated in the 'out' directory (which is pathToDbDir)\n await migrate(this.db, { migrationsFolder: pathToDbDir })\n const queryResult = await this.db.select().from(appState)\n logger('queryResult', queryResult)\n } catch (error: any) {\n // Handle various migration errors gracefully in test environments\n const errorMessage = error.message || String(error) || ''\n const errorString = String(error)\n const isMigrationError = \n errorMessage.includes(\"Can't find meta/_journal.json\") || \n errorMessage.includes('_journal.json') ||\n errorMessage.includes(\"Cannot read properties of undefined\") ||\n errorMessage.includes(\"reading 'dialect'\") ||\n errorMessage.includes(\"undefined is not an object\") ||\n errorString.includes(\"dialect\") ||\n errorString.includes(\"undefined is not an object\")\n \n if (isMigrationError) {\n if (process.env.NODE_ENV === 'test' || process.env.IS_SEED_DEV) {\n logger('Warning: Migration failed, but continuing in test environment:', errorMessage || errorString)\n // Try to query the database anyway to see if it's usable\n try {\n if (this.db) {\n const queryResult = await this.db.select().from(appState)\n logger('Database is accessible despite migration error')\n return this.db\n }\n } catch (queryError) {\n logger('Database query also failed, but continuing in test environment')\n return this.db\n }\n }\n }\n throw error\n }\n\n return this.db\n }\n\n /**\n * Execute a reactive query that emits new results whenever the underlying data changes.\n * \n * NOTE: This is a stub implementation using polling. For production use, consider enhancing\n * with database triggers, change streams, or other real-time mechanisms.\n * \n * Currently supports Drizzle query builders. SQL tag functions are not supported in node\n * environment (use browser implementation for SQL tag functions).\n * \n * @param query - Drizzle query builder (SQL tag functions not supported in node)\n * @returns Observable that emits arrays of query results\n * \n * @example\n * ```typescript\n * import { models } from '@/seedSchema'\n * import { eq } from 'drizzle-orm'\n * \n * const appDb = Db.getAppDb()\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.db) {\n throw new Error('Database not initialized. Call prepareDb first.')\n }\n \n // Polling interval (configurable, default: 1000ms)\n const pollInterval = 1000\n \n // Check if query is a function (SQL tag function) - not supported in node stub\n if (typeof query === 'function') {\n throw new Error('SQL tag functions are not supported in node liveQuery stub implementation. Use Drizzle query builders instead.')\n }\n \n // For Drizzle query builders, we need to execute them\n // Store the query builder for polling\n const queryBuilder = query\n \n return interval(pollInterval).pipe(\n startWith(0), // Execute immediately on subscription\n switchMap(async () => {\n try {\n // Execute the Drizzle query builder\n // Drizzle query builders return promises when executed\n const result = await Promise.resolve(queryBuilder)\n return result as T[]\n } catch (error) {\n logger('[Db.liveQuery] Error executing query:', error)\n throw error\n }\n }),\n distinctUntilChanged((prev, curr) => {\n // Only emit if results actually changed\n // Use JSON.stringify for deep comparison\n return JSON.stringify(prev) === JSON.stringify(curr)\n })\n )\n }\n}\n\nBaseDb.setPlatformClass(Db)\n\nexport { Db }\n"],"names":["fs"],"mappings":";;;;;;;;;;;;;;;;;;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AGA,MAAM,YAAY,GAAG,IAAI;;AAGzB,QAAA,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;AAC/B,YAAA,MAAM,IAAI,KAAK,CAAC,gHAAgH,CAAC;QACnI;;;QAIA,MAAM,YAAY,GAAG,KAAK;AAE1B,QAAA,OAAO,QAAQ,CAAC,YAAY,CAAC,CAAC,IAAI,CAChC,SAAS,CAAC,CAAC,CAAC;QACZ,SAAS,CAAC,YAAW;AACnB,YAAA,IAAI;;;gBAGF,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;AAClD,gBAAA,OAAO,MAAa;YACtB;YAAE,OAAO,KAAK,EAAE;AACd,gBAAA,MAAM,CAAC,uCAAuC,EAAE,KAAK,CAAC;AACtD,gBAAA,MAAM,KAAK;YACb;QACF,CAAC,CAAC,EACF,oBAAoB,CAAC,CAAC,IAAI,EAAE,IAAI,KAAI;;;AAGlC,YAAA,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QACtD,CAAC,CAAC,CACH;IACH;AACD;AAED,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as BaseDb, z as BaseFileManager } from './index-zsq08F5p.js';
|
|
2
2
|
import debug from 'debug';
|
|
3
3
|
import { sql } from 'drizzle-orm';
|
|
4
4
|
import { readMigrationFiles } from 'drizzle-orm/migrator';
|
|
5
5
|
import { drizzle } from 'drizzle-orm/sqlite-proxy';
|
|
6
6
|
import { migrate } from 'drizzle-orm/sqlite-proxy/migrator';
|
|
7
|
-
import { s as schema } from './index-
|
|
7
|
+
import { s as schema } from './index-BIPPEMVY.js';
|
|
8
8
|
import { SQLocalDrizzle } from 'sqlocal/drizzle';
|
|
9
9
|
import { Observable, distinctUntilChanged } from 'rxjs';
|
|
10
10
|
import 'xstate';
|
|
@@ -151,6 +151,7 @@ CREATE UNIQUE INDEX \`unique_schema_schema_file_id\` ON \`schemas\` (\`schema_fi
|
|
|
151
151
|
const migrationSql_0003_cultured_senator_kelly = `ALTER TABLE \`models\` ADD \`is_edited\` integer;--> statement-breakpoint
|
|
152
152
|
ALTER TABLE \`properties\` ADD \`is_edited\` integer;--> statement-breakpoint
|
|
153
153
|
ALTER TABLE \`schemas\` ADD \`is_edited\` integer;`;
|
|
154
|
+
const migrationSql_0004_add_publisher_to_seeds = `ALTER TABLE \`seeds\` ADD \`publisher\` text;`;
|
|
154
155
|
// Journal JSON file
|
|
155
156
|
const journalJson = `{
|
|
156
157
|
"version": "7",
|
|
@@ -183,6 +184,13 @@ const journalJson = `{
|
|
|
183
184
|
"when": 1768415440282,
|
|
184
185
|
"tag": "0003_cultured_senator_kelly",
|
|
185
186
|
"breakpoints": true
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"idx": 4,
|
|
190
|
+
"version": "6",
|
|
191
|
+
"when": 1768500000000,
|
|
192
|
+
"tag": "0004_add_publisher_to_seeds",
|
|
193
|
+
"breakpoints": true
|
|
186
194
|
}
|
|
187
195
|
]
|
|
188
196
|
}`;
|
|
@@ -191,8 +199,8 @@ const journalJson = `{
|
|
|
191
199
|
const snapshotJson = `{
|
|
192
200
|
"version": "6",
|
|
193
201
|
"dialect": "sqlite",
|
|
194
|
-
"id": "
|
|
195
|
-
"prevId": "
|
|
202
|
+
"id": "6450cc9b-cbee-45c0-92ff-794e832eb2ea",
|
|
203
|
+
"prevId": "0e6a6a99-2eb1-4b1d-815b-3d45dcae04a1",
|
|
196
204
|
"tables": {
|
|
197
205
|
"appState": {
|
|
198
206
|
"name": "appState",
|
|
@@ -888,6 +896,13 @@ const snapshotJson = `{
|
|
|
888
896
|
"notNull": false,
|
|
889
897
|
"autoincrement": false
|
|
890
898
|
},
|
|
899
|
+
"publisher": {
|
|
900
|
+
"name": "publisher",
|
|
901
|
+
"type": "text",
|
|
902
|
+
"primaryKey": false,
|
|
903
|
+
"notNull": false,
|
|
904
|
+
"autoincrement": false
|
|
905
|
+
},
|
|
891
906
|
"attestation_raw": {
|
|
892
907
|
"name": "attestation_raw",
|
|
893
908
|
"type": "text",
|
|
@@ -1046,6 +1061,7 @@ var drizzleFiles = /*#__PURE__*/Object.freeze({
|
|
|
1046
1061
|
migrationSql_0001_sweet_bruce_banner: migrationSql_0001_sweet_bruce_banner,
|
|
1047
1062
|
migrationSql_0002_bitter_proudstar: migrationSql_0002_bitter_proudstar,
|
|
1048
1063
|
migrationSql_0003_cultured_senator_kelly: migrationSql_0003_cultured_senator_kelly,
|
|
1064
|
+
migrationSql_0004_add_publisher_to_seeds: migrationSql_0004_add_publisher_to_seeds,
|
|
1049
1065
|
snapshotJson: snapshotJson
|
|
1050
1066
|
});
|
|
1051
1067
|
|
|
@@ -1511,4 +1527,4 @@ class Db extends BaseDb {
|
|
|
1511
1527
|
}
|
|
1512
1528
|
|
|
1513
1529
|
export { Db };
|
|
1514
|
-
//# sourceMappingURL=Db-
|
|
1530
|
+
//# sourceMappingURL=Db-Cq4q88X_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Db-Cq4q88X_.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 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\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}`\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\": \"6450cc9b-cbee-45c0-92ff-794e832eb2ea\",\n \"prevId\": \"0e6a6a99-2eb1-4b1d-815b-3d45dcae04a1\",\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_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 },\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 \"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 },\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_models_id_fk\": {\n \"name\": \"property_uids_property_id_models_id_fk\",\n \"tableFrom\": \"property_uids\",\n \"tableTo\": \"models\",\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 \"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 },\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 \"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 },\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 this.appDb = drizzle(\n driver, \n batchDriver, \n { \n schema, \n })\n\n logger('[Db.prepareDb] database prepared')\n\n await this.migrate()\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 static async migrate(): Promise<void> {\n\n if (!this.appDb) {\n throw new Error('Database not prepared')\n }\n\n const pathToDbDir = `${this.filesDir}/db`\n\n try {\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 await drizzleMigrate(\n this.appDb,\n async (queriesToRun) => {\n logger('queriesToRun', queriesToRun)\n for (const query of queriesToRun) {\n logger('query', query)\n await this.appDb?.run(sql.raw(query))\n }\n },\n {\n migrationsFolder: pathToDbDir,\n },\n )\n\n logger('[Db.migrate] migrations completed')\n \n } catch (error) {\n logger('[Db.migrate] error', JSON.stringify(error))\n throw error\n }\n \n\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 // Call SQLocal's reactiveQuery\n const reactiveQueryResult = this.sqlocalInstance!.reactiveQuery(query)\n \n // Subscribe to SQLocal's subscription API\n const subscription = reactiveQueryResult.subscribe(\n (data: Record<string, any>[]) => {\n // Emit data through RxJS Observable (cast to T[] since SQLocal returns Record<string, any>[])\n subscriber.next(data as T[])\n },\n (err: Error) => {\n console.error('[BaseDb.liveQuery] SQLocal reactiveQuery error:', err)\n // Emit error through RxJS Observable\n subscriber.error(err)\n }\n )\n \n // Cleanup: unsubscribe when Observable is unsubscribed\n return () => {\n subscription.unsubscribe()\n }\n })\n \n // Use distinctUntilChanged with JSON.stringify comparison\n // The comparator returns true if values are the same (skip emission)\n return baseObservable.pipe(\n distinctUntilChanged((prev, curr) => {\n // On first emission, prev will be undefined, so we always emit\n if (prev === undefined) {\n return false // false = different, so emit\n }\n \n // Compare using JSON.stringify\n try {\n const prevJson = JSON.stringify(prev)\n const currJson = JSON.stringify(curr)\n // Return true if same (skip), false if different (emit)\n return prevJson === currJson\n } catch (error) {\n // If JSON.stringify fails, fall back to reference equality\n console.warn('[BaseDb.liveQuery] distinctUntilChanged: JSON.stringify failed, using reference equality', error)\n return prev === curr\n }\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;AAEvG;AACO,MAAM,WAAW,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwCzB;AAEF;AACA;AACO,MAAM,YAAY,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;;gBAErC,OAAO,QAAQ,KAAK,QAAQ;YAC9B;YAAE,OAAO,KAAK,EAAE;;AAEd,gBAAA,OAAO,CAAC,IAAI,CAAC,0FAA0F,EAAE,KAAK,CAAC;gBAC/G,OAAO,IAAI,KAAK,IAAI;YACtB;QACF,CAAC,CAAC,CACH;IACH;AACD;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { y as BaseEasClient, E as EAS_ENDPOINT } from './index-zsq08F5p.js';
|
|
2
2
|
import { GraphQLClient } from 'graphql-request';
|
|
3
3
|
import 'xstate';
|
|
4
4
|
import 'drizzle-orm/sqlite-core';
|
|
@@ -26,4 +26,4 @@ class EasClient extends BaseEasClient {
|
|
|
26
26
|
BaseEasClient.setPlatformClass(EasClient);
|
|
27
27
|
|
|
28
28
|
export { EasClient };
|
|
29
|
-
//# sourceMappingURL=EasClient-
|
|
29
|
+
//# sourceMappingURL=EasClient-Du9_TULE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EasClient-Du9_TULE.js","sources":["../src/node/helpers/EasClient.ts"],"sourcesContent":["import { BaseEasClient } from \"@/helpers/EasClient/BaseEasClient\"\nimport { EAS_ENDPOINT } from \"@/client/constants\"\nimport { GraphQLClient } from \"graphql-request\"\n\nclass EasClient extends BaseEasClient {\n static getEasClient() {\n if (!this.easClient) {\n this.easClient = new GraphQLClient(EAS_ENDPOINT)\n }\n return this.easClient\n }\n\n}\n\nBaseEasClient.setPlatformClass(EasClient)\n\nexport { EasClient }"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAIA,MAAM,SAAU,SAAQ,aAAa,CAAA;AACnC,IAAA,OAAO,YAAY,GAAA;AACjB,QAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,SAAS,GAAG,IAAI,aAAa,CAAC,YAAY,CAAC;QAClD;QACA,OAAO,IAAI,CAAC,SAAS;IACvB;AAED;AAED,aAAa,CAAC,gBAAgB,CAAC,SAAS,CAAC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { y as BaseEasClient, E as EAS_ENDPOINT } from './index-zsq08F5p.js';
|
|
2
2
|
import { GraphQLClient } from 'graphql-request';
|
|
3
3
|
import 'xstate';
|
|
4
4
|
import 'drizzle-orm/sqlite-core';
|
|
@@ -26,4 +26,4 @@ class EasClient extends BaseEasClient {
|
|
|
26
26
|
BaseEasClient.setPlatformClass(EasClient);
|
|
27
27
|
|
|
28
28
|
export { EasClient };
|
|
29
|
-
//# sourceMappingURL=EasClient-
|
|
29
|
+
//# sourceMappingURL=EasClient-ZCIE6UQq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EasClient-ZCIE6UQq.js","sources":["../src/browser/helpers/EasClient.ts"],"sourcesContent":["import { BaseEasClient } from '@/helpers/EasClient/BaseEasClient'\nimport { EAS_ENDPOINT } from '@/client/constants'\nimport { GraphQLClient } from 'graphql-request'\n\nclass EasClient extends BaseEasClient {\n static getEasClient() {\n if (!this.easClient) {\n this.easClient = new GraphQLClient(EAS_ENDPOINT)\n }\n return this.easClient\n }\n}\n\nBaseEasClient.setPlatformClass(EasClient)\n\nexport { EasClient }\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAIA,MAAM,SAAU,SAAQ,aAAa,CAAA;AACnC,IAAA,OAAO,YAAY,GAAA;AACjB,QAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,SAAS,GAAG,IAAI,aAAa,CAAC,YAAY,CAAC;QAClD;QACA,OAAO,IAAI,CAAC,SAAS;IACvB;AACD;AAED,aAAa,CAAC,gBAAgB,CAAC,SAAS,CAAC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a2 as saveAppState, z as BaseFileManager } from './index-zsq08F5p.js';
|
|
2
2
|
import debug from 'debug';
|
|
3
3
|
import path from 'path-browserify';
|
|
4
4
|
import 'xstate';
|
|
@@ -1150,4 +1150,4 @@ class CancelableInterval {
|
|
|
1150
1150
|
}
|
|
1151
1151
|
|
|
1152
1152
|
export { FileManager };
|
|
1153
|
-
//# sourceMappingURL=FileManager-
|
|
1153
|
+
//# sourceMappingURL=FileManager-Cub9icdd.js.map
|