@seedprotocol/sdk 0.2.20 → 0.2.22
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/{Db-DmVJMUEe.js → Db-BDApWGHx.js} +3 -3
- package/dist/Db-BDApWGHx.js.map +1 -0
- package/dist/{Db-tOm1prXY.js → Db-CKy9qG0k.js} +33 -11
- package/dist/Db-CKy9qG0k.js.map +1 -0
- package/dist/{Item-CUb5EPhJ.js → Item-3FDBdoAb.js} +2 -2
- package/dist/{Item-CUb5EPhJ.js.map → Item-3FDBdoAb.js.map} +1 -1
- package/dist/ItemProperty-BWPn0Aw_.js +39 -0
- package/dist/ItemProperty-BWPn0Aw_.js.map +1 -0
- package/dist/{index-Bo17ctYt.js → index-BgGj2qlg.js} +2 -2
- package/dist/index-BgGj2qlg.js.map +1 -0
- package/dist/{index-BhuLVnLW.js → index-ChcOTyEf.js} +92 -63
- package/dist/index-ChcOTyEf.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/node/db/node.app.db.config.ts +1 -0
- package/dist/{seed.schema.config-DQk8YJHP.js → seed.schema.config-Dg2ak4Ke.js} +2 -2
- package/dist/{seed.schema.config-DQk8YJHP.js.map → seed.schema.config-Dg2ak4Ke.js.map} +1 -1
- package/dist/src/BaseDb.ts +2 -2
- package/dist/src/BaseItem.ts +3 -5
- package/dist/src/Db.ts +37 -3
- package/dist/src/IItem.ts +0 -1
- package/dist/src/IItemProperty.ts +0 -1
- package/dist/src/ItemProperty.ts +9 -0
- package/dist/src/client.ts +4 -2
- package/dist/src/environment.ts +21 -1
- package/dist/src/fetchDbData.ts +1 -1
- package/dist/src/fetchSeeds.ts +1 -1
- package/dist/src/fetchVersions.ts +1 -1
- package/dist/src/globalMachine.ts +6 -2
- package/dist/src/initialize.ts +9 -10
- package/dist/src/internalMachine.ts +2 -0
- package/dist/src/machines.ts +2 -0
- package/dist/src/node.app.db.config.ts +1 -0
- package/dist/src/prepareDb.ts +12 -6
- package/dist/src/processItems.ts +1 -1
- package/dist/src/sqlWasmClient.ts +4 -4
- package/dist/src/updateItemPropertyValue.ts +5 -6
- package/dist/src/validateInput.ts +22 -8
- package/dist/types/src/Item/BaseItem.d.ts +1 -10
- package/dist/types/src/Item/BaseItem.d.ts.map +1 -1
- package/dist/types/src/Item/index.d.ts +2 -2
- package/dist/types/src/Item/index.d.ts.map +1 -1
- package/dist/types/src/Item/service/actors/initialize.d.ts +1 -1
- package/dist/types/src/Item/service/actors/initialize.d.ts.map +1 -1
- package/dist/types/src/ItemProperty/index.d.ts +2 -2
- package/dist/types/src/ItemProperty/index.d.ts.map +1 -1
- package/dist/types/src/browser/db/Db.d.ts +1 -1
- package/dist/types/src/browser/db/Db.d.ts.map +1 -1
- package/dist/types/src/browser/db/sqlWasmClient.d.ts.map +1 -1
- package/dist/types/src/client.d.ts +1 -1
- package/dist/types/src/client.d.ts.map +1 -1
- package/dist/types/src/db/Db/BaseDb.d.ts +1 -1
- package/dist/types/src/db/Db/BaseDb.d.ts.map +1 -1
- package/dist/types/src/db/Db/index.d.ts.map +1 -1
- package/dist/types/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
- package/dist/types/src/helpers/ArweaveClient/index.d.ts.map +1 -1
- package/dist/types/src/helpers/EasClient/index.d.ts.map +1 -1
- package/dist/types/src/helpers/FileManager/index.d.ts.map +1 -1
- package/dist/types/src/helpers/QueryClient/index.d.ts.map +1 -1
- package/dist/types/src/helpers/environment.d.ts +2 -0
- package/dist/types/src/helpers/environment.d.ts.map +1 -1
- package/dist/types/src/interfaces/IItem.d.ts +1 -2
- package/dist/types/src/interfaces/IItem.d.ts.map +1 -1
- package/dist/types/src/interfaces/IItemProperty.d.ts +0 -2
- package/dist/types/src/interfaces/IItemProperty.d.ts.map +1 -1
- package/dist/types/src/node/ItemProperty/ItemProperty.d.ts +6 -0
- package/dist/types/src/node/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/types/src/node/db/Db.d.ts +1 -1
- package/dist/types/src/node/db/Db.d.ts.map +1 -1
- package/dist/types/src/node/db/node.app.db.config.d.ts.map +1 -1
- package/dist/types/src/services/allItems/actors/fetchDbData.d.ts +1 -1
- package/dist/types/src/services/allItems/actors/fetchDbData.d.ts.map +1 -1
- package/dist/types/src/services/allItems/actors/fetchSeeds.d.ts +1 -1
- package/dist/types/src/services/allItems/actors/fetchSeeds.d.ts.map +1 -1
- package/dist/types/src/services/allItems/actors/fetchVersions.d.ts +1 -1
- package/dist/types/src/services/allItems/actors/fetchVersions.d.ts.map +1 -1
- package/dist/types/src/services/allItems/actors/processItems.d.ts +1 -1
- package/dist/types/src/services/allItems/actors/processItems.d.ts.map +1 -1
- package/dist/types/src/services/allItems/itemMachineAll.d.ts +9 -9
- package/dist/types/src/services/global/actors/initialize.d.ts.map +1 -1
- package/dist/types/src/services/global/globalMachine.d.ts.map +1 -1
- package/dist/types/src/services/internal/actors/prepareDb.d.ts +3 -1
- package/dist/types/src/services/internal/actors/prepareDb.d.ts.map +1 -1
- package/dist/types/src/services/internal/actors/validateInput.d.ts +3 -1
- package/dist/types/src/services/internal/actors/validateInput.d.ts.map +1 -1
- package/dist/types/src/services/internal/internalMachine.d.ts +56 -1
- package/dist/types/src/services/internal/internalMachine.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/machines.d.ts +2 -0
- package/dist/types/src/types/machines.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/Db-DmVJMUEe.js.map +0 -1
- package/dist/Db-tOm1prXY.js.map +0 -1
- package/dist/ItemProperty-l0sNRNKZ.js +0 -2
- package/dist/ItemProperty-l0sNRNKZ.js.map +0 -1
- package/dist/index-BhuLVnLW.js.map +0 -1
- package/dist/index-Bo17ctYt.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as BaseDb, g as getAppDb, i as isAppDbReady, c as getSqliteWasmClient } from './index-ChcOTyEf.js';
|
|
2
2
|
import { __awaiter } from 'tslib';
|
|
3
3
|
import debug from 'debug';
|
|
4
4
|
import 'immer';
|
|
@@ -89,7 +89,7 @@ class Db extends BaseDb {
|
|
|
89
89
|
static isAppDbReady() {
|
|
90
90
|
return isAppDbReady();
|
|
91
91
|
}
|
|
92
|
-
static prepareDb() {
|
|
92
|
+
static prepareDb(filesDir) {
|
|
93
93
|
return new Promise((resolve, reject) => {
|
|
94
94
|
const interval = setInterval(() => {
|
|
95
95
|
// TODO: Add a timeout
|
|
@@ -135,4 +135,4 @@ class Db extends BaseDb {
|
|
|
135
135
|
BaseDb.setPlatformClass(Db);
|
|
136
136
|
|
|
137
137
|
export { Db };
|
|
138
|
-
//# sourceMappingURL=Db-
|
|
138
|
+
//# sourceMappingURL=Db-BDApWGHx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Db-BDApWGHx.js","sources":["../../src/services/db/connectionManager.ts","../../src/browser/db/Db.ts"],"sourcesContent":["type SqliteDatabase = {\n open: (filename: string) => Promise<void>\n exec: (sql: string, params?: any[]) => any\n close: () => void\n}\n\nclass SqliteConnectionManager {\n private sqliteModule: SqliteDatabase\n private idleTimeout: number\n private databases: { [key: string]: SqliteDatabase }\n private idleTimers: { [key: string]: NodeJS.Timeout }\n\n constructor(sqliteModule: SqliteDatabase, idleTimeout: number = 300000) {\n // Default idle timeout: 5 minutes\n this.sqliteModule = sqliteModule\n this.idleTimeout = idleTimeout\n this.databases = {}\n this.idleTimers = {}\n }\n\n private resetIdleTimer(dbName: string): void {\n if (this.idleTimers[dbName]) {\n clearTimeout(this.idleTimers[dbName])\n }\n\n this.idleTimers[dbName] = setTimeout(() => {\n this.closeConnection(dbName)\n }, this.idleTimeout)\n }\n\n private async getConnection(dbName: string): Promise<SqliteDatabase> {\n if (this.databases[dbName]) {\n this.resetIdleTimer(dbName)\n return this.databases[dbName]\n }\n\n const db = new this.sqliteModule()\n await db.open(dbName)\n this.databases[dbName] = db\n this.resetIdleTimer(dbName)\n return db\n }\n\n public async execute(\n dbName: string,\n sql: string,\n params: any[] = [],\n ): Promise<any> {\n const db = await this.getConnection(dbName)\n const result = db.exec(sql, params)\n this.resetIdleTimer(dbName)\n return result\n }\n\n public closeConnection(dbName: string): void {\n if (this.databases[dbName]) {\n this.databases[dbName].close()\n delete this.databases[dbName]\n if (this.idleTimers[dbName]) {\n clearTimeout(this.idleTimers[dbName])\n delete this.idleTimers[dbName]\n }\n }\n }\n}\n\nexport { SqliteConnectionManager }\n","import { BaseDb } from \"@/db/Db/BaseDb\";\nimport { IDb } from \"@/interfaces/IDb\";\nimport { getAppDb, getSqliteWasmClient, isAppDbReady } from \"./sqlWasmClient\";\nimport { SqliteConnectionManager } from \"@/services/db\";\nimport debug from \"debug\";\n\nconst logger = debug('app:browser:db:Db')\n\nclass Db extends BaseDb implements IDb {\n constructor() {\n super()\n }\n\n static getAppDb() {\n return getAppDb()\n }\n\n static isAppDbReady() {\n return isAppDbReady()\n }\n\n static prepareDb(filesDir: string) {\n\n return new Promise((resolve, reject) => {\n let sqliteWasmClient\n const interval = setInterval(() => {\n // TODO: Add a timeout\n // TODO: Add a cancel token to the promise so we can prevent more loops starting while we're checking the successful outcome\n getSqliteWasmClient().then((sqliteWasmClient) => {\n\n if (sqliteWasmClient) {\n clearInterval(interval)\n const manager = new SqliteConnectionManager(sqliteWasmClient)\n resolve(manager)\n }\n })\n\n }, 200)\n })\n }\n\n static connectToDb(pathToDir: string, dbName: string) {\n\n return new Promise((resolve, reject) => {\n const interval = setInterval(() => {\n\n // TODO: Add a timeout\n // TODO: Add a cancel token to the promise so we can prevent more loops starting while we're checking the successful outcome\n getSqliteWasmClient().then((sqliteWasmClient) => {\n\n //@ts-ignore\n sqliteWasmClient('config-get', {}).then((response) => {\n logger(response)\n logger('Running SQLite3 version', response.result.version.libVersion)\n\n //@ts-ignore\n sqliteWasmClient('open', {\n filename: `file:${pathToDir}/db/${dbName}.sqlite3?vfs=opfs`,\n }).then((response: { dbId: string, result: { filename: string } }) => {\n\n logger(response)\n const dbId = response.dbId\n logger(\n 'OPFS is available, created persisted database at',\n response.result.filename.replace(/^file:(.*?)\\?vfs=opfs$/, '$1'),\n )\n\n if (dbId) {\n clearInterval(interval)\n resolve(dbId)\n }\n })\n })\n })\n }, 500)\n })\n }\n}\n\nBaseDb.setPlatformClass(Db)\n\nexport { Db }"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,uBAAuB,CAAA;IAM3B,WAAY,CAAA,YAA4B,EAAE,WAAA,GAAsB,MAAM,EAAA;;AAEpE,QAAA,IAAI,CAAC,YAAY,GAAG,YAAY;AAChC,QAAA,IAAI,CAAC,WAAW,GAAG,WAAW;AAC9B,QAAA,IAAI,CAAC,SAAS,GAAG,EAAE;AACnB,QAAA,IAAI,CAAC,UAAU,GAAG,EAAE;;AAGd,IAAA,cAAc,CAAC,MAAc,EAAA;AACnC,QAAA,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;YAC3B,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;;QAGvC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,MAAK;AACxC,YAAA,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;AAC9B,SAAC,EAAE,IAAI,CAAC,WAAW,CAAC;;AAGR,IAAA,aAAa,CAAC,MAAc,EAAA;;AACxC,YAAA,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;AAC1B,gBAAA,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;AAC3B,gBAAA,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;;AAG/B,YAAA,MAAM,EAAE,GAAG,IAAI,IAAI,CAAC,YAAY,EAAE;AAClC,YAAA,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;AACrB,YAAA,IAAI,CAAC,SAAS,CAAC,MA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AE;gCACR,aAAa,CAAC,QAAQ,CAAC;gCACvB,OAAO,CAAC,IAAI,CAAC;;AAEjB,yBAAC,CAAC;AACJ,qBAAC,CAAC;AACJ,iBAAC,CAAC;aACH,EAAE,GAAG,CAAC;AACT,SAAC,CAAC;;AAEL;AAED,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
|
-
import {
|
|
2
|
+
import { b as BaseDb } from './index-ChcOTyEf.js';
|
|
3
3
|
import { defineConfig } from 'drizzle-kit';
|
|
4
4
|
import dotenv from 'dotenv';
|
|
5
|
-
import process from 'node:process';
|
|
5
|
+
import process$1 from 'node:process';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { drizzle } from 'drizzle-orm/better-sqlite3';
|
|
8
8
|
import 'immer';
|
|
@@ -35,15 +35,15 @@ import 'rxjs';
|
|
|
35
35
|
|
|
36
36
|
dotenv.config();
|
|
37
37
|
let sdkRoot = './node_modules/@seedprotocol/sdk';
|
|
38
|
-
if (process.env.IS_SEED_DEV) {
|
|
38
|
+
if (process$1.env.IS_SEED_DEV) {
|
|
39
39
|
sdkRoot = './src';
|
|
40
40
|
}
|
|
41
|
-
let dotSeedDir = path.join(process.cwd(), '.seed');
|
|
42
|
-
if (process.env.IS_SEED_DEV) {
|
|
43
|
-
dotSeedDir = path.join(process.cwd(), '__tests__', '__mocks__', 'project', '.seed');
|
|
41
|
+
let dotSeedDir = path.join(process$1.cwd(), '.seed');
|
|
42
|
+
if (process$1.env.IS_SEED_DEV) {
|
|
43
|
+
dotSeedDir = path.join(process$1.cwd(), '__tests__', '__mocks__', 'browser', 'project', '.seed');
|
|
44
44
|
}
|
|
45
45
|
let schemaDir = `${sdkRoot}/dist/seedSchema/*.ts`;
|
|
46
|
-
if (process.env.IS_SEED_DEV) {
|
|
46
|
+
if (process$1.env.IS_SEED_DEV) {
|
|
47
47
|
schemaDir = `${sdkRoot}/seedSchema/*.ts`;
|
|
48
48
|
}
|
|
49
49
|
var nodeAppDbConfig = defineConfig({
|
|
@@ -55,6 +55,26 @@ var nodeAppDbConfig = defineConfig({
|
|
|
55
55
|
},
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
+
const getConfig = (filesDir) => {
|
|
59
|
+
let sdkRoot = './node_modules/@seedprotocol/sdk';
|
|
60
|
+
if (process.env.IS_SEED_DEV) {
|
|
61
|
+
sdkRoot = './src';
|
|
62
|
+
}
|
|
63
|
+
const dotSeedDir = path.join(filesDir, '.seed');
|
|
64
|
+
let schemaDir = `${sdkRoot}/dist/seedSchema/*.ts`;
|
|
65
|
+
if (process.env.IS_SEED_DEV) {
|
|
66
|
+
schemaDir = `${sdkRoot}/seedSchema/*.ts`;
|
|
67
|
+
}
|
|
68
|
+
const nodeDbConfig = defineConfig({
|
|
69
|
+
schema: schemaDir,
|
|
70
|
+
dialect: 'sqlite',
|
|
71
|
+
out: `${dotSeedDir}/db`,
|
|
72
|
+
dbCredentials: {
|
|
73
|
+
url: `${dotSeedDir}/db/app_db.sqlite3`,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
return nodeDbConfig;
|
|
77
|
+
};
|
|
58
78
|
class Db extends BaseDb {
|
|
59
79
|
constructor() {
|
|
60
80
|
super();
|
|
@@ -65,19 +85,21 @@ class Db extends BaseDb {
|
|
|
65
85
|
static isAppDbReady() {
|
|
66
86
|
return true;
|
|
67
87
|
}
|
|
68
|
-
static prepareDb() {
|
|
88
|
+
static prepareDb(filesDir) {
|
|
69
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
|
|
90
|
+
const nodeDbConfig = getConfig(filesDir);
|
|
91
|
+
return drizzle(nodeDbConfig);
|
|
71
92
|
});
|
|
72
93
|
}
|
|
73
94
|
static connectToDb(pathToDir, dbName) {
|
|
74
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
const nodeDbConfig = getConfig(pathToDir);
|
|
75
97
|
return {
|
|
76
|
-
id: drizzle(
|
|
98
|
+
id: drizzle(nodeDbConfig).$client.name
|
|
77
99
|
};
|
|
78
100
|
});
|
|
79
101
|
}
|
|
80
102
|
}
|
|
81
103
|
|
|
82
104
|
export { Db };
|
|
83
|
-
//# sourceMappingURL=Db-
|
|
105
|
+
//# sourceMappingURL=Db-CKy9qG0k.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Db-CKy9qG0k.js","sources":["../../src/node/db/node.app.db.config.ts","../../src/node/db/Db.ts"],"sourcesContent":["import { defineConfig } from 'drizzle-kit'\nimport dotenv from 'dotenv'\nimport process from 'node:process'\nimport path from 'path'\nimport { DrizzleConfig } from 'drizzle-orm'\n\ndotenv.config()\n\nlet sdkRoot = './node_modules/@seedprotocol/sdk'\n\nif (process.env.IS_SEED_DEV) {\n sdkRoot = './src'\n}\n\nlet dotSeedDir = path.join(process.cwd(), '.seed')\n\nif (process.env.IS_SEED_DEV) {\n dotSeedDir = path.join(\n process.cwd(),\n '__tests__',\n '__mocks__',\n 'browser',\n 'project',\n '.seed',\n )\n}\n\nlet schemaDir = `${sdkRoot}/dist/seedSchema/*.ts`\n\nif (process.env.IS_SEED_DEV) {\n schemaDir = `${sdkRoot}/seedSchema/*.ts`\n}\n\nexport default defineConfig({\n schema: schemaDir,\n dialect: 'sqlite',\n out: `${dotSeedDir}/db`,\n dbCredentials: {\n url: `${dotSeedDir}/db/app_db.sqlite3`,\n },\n}) as DrizzleConfig\n","import { BaseDb } from \"@/db/Db/BaseDb\";\nimport { IDb } from \"@/interfaces\";\nimport nodeAppDbConfig from \"./node.app.db.config\";\nimport { drizzle } from \"drizzle-orm/better-sqlite3\";\nimport { defineConfig } from \"drizzle-kit\";\nimport path from \"path\";\nimport { DrizzleConfig } from \"drizzle-orm/utils\";\n\nconst getConfig = (filesDir: string) => {\n let sdkRoot = './node_modules/@seedprotocol/sdk'\n\n if (process.env.IS_SEED_DEV) {\n sdkRoot = './src'\n }\n const dotSeedDir = path.join(filesDir, '.seed')\n let schemaDir = `${sdkRoot}/dist/seedSchema/*.ts`\n\n if (process.env.IS_SEED_DEV) {\n schemaDir = `${sdkRoot}/seedSchema/*.ts`\n }\n\n const nodeDbConfig = defineConfig({\n schema: schemaDir,\n dialect: 'sqlite',\n out: `${dotSeedDir}/db`,\n dbCredentials: {\n url: `${dotSeedDir}/db/app_db.sqlite3`,\n },\n }) as DrizzleConfig\n\n return nodeDbConfig\n}\n\nexport class Db extends BaseDb implements IDb {\n constructor() {\n super()\n }\n\n static getAppDb() {\n return drizzle(nodeAppDbConfig)\n }\n\n static isAppDbReady() {\n return true\n }\n\n static async prepareDb(filesDir: string) {\n const nodeDbConfig = getConfig(filesDir)\n\n\n return drizzle(nodeDbConfig)\n }\n\n static async connectToDb(pathToDir: string, dbName: string) {\n\n const nodeDbConfig = getConfig(pathToDir)\n\n return {\n id: drizzle(nodeDbConfig).$client.name\n }\n }\n}\n"],"names":["process"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,CAAC,MAAM,EAAE;AAEf,IAAI,OAAO,GAAG,kCAAkC;AAEhD,IAAIA,SAAO,CAAC,GAAG,CAAC,WAAW,EAAE;IAC3B,OAAO,GAAG,OAAO;AACnB;AAEA,IAAI,UAAU,GAAG,IAAI,CAAC,IAAI,CAACA,SAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC;AAElD,IAAIA,SAAO,CAAC,GAAG,CAAC,WAAW,EAAE;IAC3B,UAAU,GAAG,IAAI,CAAC,IAAI,CACpBA,SAAO,CAAC,GAAG,EAAE,EACb,WAAW,EACX,WAAW,EACX,SAAS,EACT,SAAS,EACT,OAAO,CACR;AACH;AAEA,IAAI,SAAS,GAAG,CAAG,EAAA,OAAO,uBAAuB;AAEjD,IAAIA,SAAO,CAAC,GAAG,CAAC,WAAW,EAAE;AAC3B,IAAA,SAAS,GAAG,CAAA,EAAG,OAAO,CAAA,gBAAA,CAAkB;AAC1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,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC;AAGxC,YAAA,OAAO,OAAO,CAAC,YAAY,CAAC;SAC7B,CAAA;AAAA;AAED,IAAA,OAAa,WAAW,CAAC,SAAiB,EAAE,MAAc,EAAA;;AAExD,YAAA,MAAM,YAAY,GAAG,SAAS,CAAC,SAAS,CAAC;YAEzC,OAAO;gBACL,EAAE,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC;aACnC;SACF,CAAA;AAAA;AACF;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BaseItem } from './index-
|
|
1
|
+
import { B as BaseItem } from './index-ChcOTyEf.js';
|
|
2
2
|
import 'immer';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import 'tslib';
|
|
@@ -37,4 +37,4 @@ class Item extends BaseItem {
|
|
|
37
37
|
BaseItem.setPlatformClass(Item);
|
|
38
38
|
|
|
39
39
|
export { Item };
|
|
40
|
-
//# sourceMappingURL=Item-
|
|
40
|
+
//# sourceMappingURL=Item-3FDBdoAb.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item-
|
|
1
|
+
{"version":3,"file":"Item-3FDBdoAb.js","sources":["../../src/node/Item/Item.ts"],"sourcesContent":["import { IItem } from '@/interfaces';\nimport { BaseItem } from '@/Item/BaseItem';\nimport { ModelSchema, ModelValues, NewItemProps } from '@/types';\n\nexport class Item<T extends ModelValues<ModelSchema>> extends BaseItem<T> implements IItem<T> {\n constructor(initialValues: NewItemProps<T>) {\n super(initialValues);\n }\n\n}\n\nBaseItem.setPlatformClass(Item)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIM,MAAO,IAAyC,SAAQ,QAAW,CAAA;AACvE,IAAA,WAAA,CAAY,aAA8B,EAAA;QACxC,KAAK,CAAC,aAAa,CAAC;;AAGvB;AAED,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { a as BaseItemProperty } from './index-ChcOTyEf.js';
|
|
2
|
+
import 'immer';
|
|
3
|
+
import 'reflect-metadata';
|
|
4
|
+
import 'tslib';
|
|
5
|
+
import '@sinclair/typebox';
|
|
6
|
+
import 'drizzle-orm';
|
|
7
|
+
import 'react';
|
|
8
|
+
import 'dayjs';
|
|
9
|
+
import 'nanoid';
|
|
10
|
+
import 'nanoid-dictionary';
|
|
11
|
+
import '@zenfs/core';
|
|
12
|
+
import 'debug';
|
|
13
|
+
import 'drizzle-orm/sqlite-core';
|
|
14
|
+
import './constants-CuI_qYXt.js';
|
|
15
|
+
import '@ethereum-attestation-service/eas-sdk';
|
|
16
|
+
import 'xstate';
|
|
17
|
+
import 'pluralize';
|
|
18
|
+
import 'eventemitter3';
|
|
19
|
+
import 'lodash-es';
|
|
20
|
+
import '@statelyai/inspect';
|
|
21
|
+
import 'drizzle-orm/sqlite-proxy';
|
|
22
|
+
import 'drizzle-orm/sqlite-proxy/migrator';
|
|
23
|
+
import 'drizzle-orm/migrator';
|
|
24
|
+
import 'node:fs';
|
|
25
|
+
import '@zenfs/dom';
|
|
26
|
+
import 'path';
|
|
27
|
+
import 'arweave';
|
|
28
|
+
import 'use-immer';
|
|
29
|
+
import '@xstate/react';
|
|
30
|
+
import 'rxjs';
|
|
31
|
+
|
|
32
|
+
class ItemProperty extends BaseItemProperty {
|
|
33
|
+
constructor(initialValues) {
|
|
34
|
+
super(initialValues);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { ItemProperty };
|
|
39
|
+
//# sourceMappingURL=ItemProperty-BWPn0Aw_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemProperty-BWPn0Aw_.js","sources":["../../src/node/ItemProperty/ItemProperty.ts"],"sourcesContent":["import { IItemProperty } from '@/interfaces'\nimport { BaseItemProperty } from '@/ItemProperty/BaseItemProperty'\nimport { CreatePropertyInstanceProps, ModelSchema, ModelValues, } from '@/types'\n\nexport class ItemProperty<PropertyType> extends BaseItemProperty<PropertyType> implements IItemProperty<PropertyType> {\n constructor(initialValues: Partial<CreatePropertyInstanceProps>) {\n super(initialValues)\n }\n}"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIM,MAAO,YAA2B,SAAQ,gBAA8B,CAAA;AAC5E,IAAA,WAAA,CAAY,aAAmD,EAAA;QAC7D,KAAK,CAAC,aAAa,CAAC;;AAEvB;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { I as Item } from './index-
|
|
1
|
+
export { I as Item } from './index-ChcOTyEf.js';
|
|
2
2
|
import 'immer';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import 'tslib';
|
|
@@ -28,4 +28,4 @@ import 'arweave';
|
|
|
28
28
|
import 'use-immer';
|
|
29
29
|
import '@xstate/react';
|
|
30
30
|
import 'rxjs';
|
|
31
|
-
//# sourceMappingURL=index-
|
|
31
|
+
//# sourceMappingURL=index-BgGj2qlg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BgGj2qlg.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -106,13 +106,35 @@ const ImageSrc = () => PropertyConstructor(Property.ImageSrc());
|
|
|
106
106
|
const Relation = (ref, refValueType) => PropertyConstructor(Property.Relation(ref, refValueType)); // Adjust for actual relation type
|
|
107
107
|
const List = (ref, reValueType) => PropertyConstructor(Property.List(ref, reValueType)); // Adjust for actual list type
|
|
108
108
|
|
|
109
|
+
const isBrowser = () => {
|
|
110
|
+
return !isElectron() && typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
111
|
+
};
|
|
112
|
+
const isReactNative = () => {
|
|
113
|
+
return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
114
|
+
};
|
|
115
|
+
const isElectron = () => {
|
|
116
|
+
return typeof process !== 'undefined' && process.versions != null && process.versions.electron != null;
|
|
117
|
+
};
|
|
118
|
+
const getEnvironment = () => {
|
|
119
|
+
if (isBrowser()) {
|
|
120
|
+
return 'browser';
|
|
121
|
+
}
|
|
122
|
+
if (isElectron()) {
|
|
123
|
+
return 'electron';
|
|
124
|
+
}
|
|
125
|
+
if (isReactNative()) {
|
|
126
|
+
return 'react-native';
|
|
127
|
+
}
|
|
128
|
+
return 'node';
|
|
129
|
+
};
|
|
130
|
+
|
|
109
131
|
let Item$2;
|
|
110
132
|
const initItem = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
111
|
-
if (
|
|
133
|
+
if (isBrowser()) {
|
|
112
134
|
Item$2 = (yield Promise.resolve().then(function () { return Item$1; })).Item;
|
|
113
135
|
}
|
|
114
|
-
|
|
115
|
-
Item$2 = (yield import('./Item-
|
|
136
|
+
if (!isBrowser()) {
|
|
137
|
+
Item$2 = (yield import('./Item-3FDBdoAb.js')).Item;
|
|
116
138
|
}
|
|
117
139
|
});
|
|
118
140
|
|
|
@@ -158,22 +180,23 @@ const Model = (constructor) => {
|
|
|
158
180
|
|
|
159
181
|
let ItemProperty$2;
|
|
160
182
|
const initItemProperty = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
161
|
-
if (
|
|
183
|
+
if (isBrowser()) {
|
|
162
184
|
ItemProperty$2 = (yield Promise.resolve().then(function () { return ItemProperty$1; })).ItemProperty;
|
|
163
185
|
}
|
|
164
|
-
|
|
165
|
-
ItemProperty$2 = (yield import('./ItemProperty-
|
|
186
|
+
if (!isBrowser()) {
|
|
187
|
+
ItemProperty$2 = (yield import('./ItemProperty-BWPn0Aw_.js')).ItemProperty;
|
|
166
188
|
}
|
|
167
189
|
});
|
|
168
190
|
|
|
169
191
|
let Db;
|
|
170
192
|
const initDb = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
171
|
-
if (
|
|
172
|
-
Db = (yield import('./Db-
|
|
193
|
+
if (isBrowser()) {
|
|
194
|
+
Db = (yield import('./Db-BDApWGHx.js')).Db;
|
|
173
195
|
}
|
|
174
|
-
|
|
175
|
-
Db = (yield import('./Db-
|
|
196
|
+
if (!isBrowser()) {
|
|
197
|
+
Db = (yield import('./Db-CKy9qG0k.js')).Db;
|
|
176
198
|
}
|
|
199
|
+
// TODO: Add config for React Native
|
|
177
200
|
});
|
|
178
201
|
|
|
179
202
|
let sqlite3InitModule;
|
|
@@ -226,10 +249,6 @@ const getAppDb = () => {
|
|
|
226
249
|
const isAppDbReady = () => {
|
|
227
250
|
return !!appDb;
|
|
228
251
|
};
|
|
229
|
-
const runQueryForStatement = (statement) => __awaiter(void 0, void 0, void 0, function* () {
|
|
230
|
-
const appDb = getAppDb();
|
|
231
|
-
return appDb.run(sql.raw(statement));
|
|
232
|
-
});
|
|
233
252
|
|
|
234
253
|
const modelStore = new Map();
|
|
235
254
|
const getModels = () => {
|
|
@@ -494,8 +513,8 @@ class BaseDb {
|
|
|
494
513
|
static isAppDbReady() {
|
|
495
514
|
return this.PlatformClass.isAppDbReady();
|
|
496
515
|
}
|
|
497
|
-
static prepareDb() {
|
|
498
|
-
return this.PlatformClass.prepareDb();
|
|
516
|
+
static prepareDb(filesDir) {
|
|
517
|
+
return this.PlatformClass.prepareDb(filesDir);
|
|
499
518
|
}
|
|
500
519
|
static connectToDb(pathToDir, dbName) {
|
|
501
520
|
return this.PlatformClass.connectToDb(pathToDir, dbName);
|
|
@@ -802,7 +821,7 @@ const createMetadata = (metadataValues, propertyRecordSchema) => __awaiter(void
|
|
|
802
821
|
.returning();
|
|
803
822
|
});
|
|
804
823
|
|
|
805
|
-
const createNewItem
|
|
824
|
+
const createNewItem = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
806
825
|
var _b;
|
|
807
826
|
var { modelName } = _a, propertyData = __rest(_a, ["modelName"]);
|
|
808
827
|
if (!modelName) {
|
|
@@ -867,6 +886,9 @@ const getExistingItem = (_a) => __awaiter(void 0, [_a], void 0, function* ({ see
|
|
|
867
886
|
|
|
868
887
|
const initialize$3 = fromCallback(({ sendBack, input: { context } }) => {
|
|
869
888
|
const { seedLocalId, seedUid, ModelClass } = context;
|
|
889
|
+
if (!ModelClass) {
|
|
890
|
+
throw new Error('ModelClass is required');
|
|
891
|
+
}
|
|
870
892
|
const modelName = ModelClass.originalConstructor.name;
|
|
871
893
|
const modelNamePlural = pluralize(modelName);
|
|
872
894
|
const modelTableName = modelNamePlural.toLowerCase();
|
|
@@ -1560,26 +1582,16 @@ const syncDbWithEasHandler = throttle((_) => __awaiter(void 0, void 0, void 0, f
|
|
|
1560
1582
|
trailing: false,
|
|
1561
1583
|
});
|
|
1562
1584
|
|
|
1563
|
-
const isNode = () => {
|
|
1564
|
-
return (typeof process !== 'undefined' &&
|
|
1565
|
-
process.versions != null &&
|
|
1566
|
-
process.versions.node != null);
|
|
1567
|
-
};
|
|
1568
|
-
const isReactNative = () => {
|
|
1569
|
-
return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
1570
|
-
};
|
|
1571
|
-
|
|
1572
1585
|
const logger$o = debug('app:services:global:actors:initialize');
|
|
1573
1586
|
const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
1574
|
-
const { internalService, models, endpoints, arweaveDomain } = context;
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
if (isNode()) {
|
|
1578
|
-
environment = 'node';
|
|
1587
|
+
const { internalService, models, endpoints, arweaveDomain, addresses, } = context;
|
|
1588
|
+
if (!internalService) {
|
|
1589
|
+
throw new Error('internalService is required');
|
|
1579
1590
|
}
|
|
1580
|
-
if (
|
|
1581
|
-
|
|
1591
|
+
if (!models) {
|
|
1592
|
+
throw new Error('models is required');
|
|
1582
1593
|
}
|
|
1594
|
+
let environment = getEnvironment();
|
|
1583
1595
|
let internalSubscription;
|
|
1584
1596
|
const _initFileSystem = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1585
1597
|
return;
|
|
@@ -1684,7 +1696,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1684
1696
|
if (!models$1) {
|
|
1685
1697
|
return;
|
|
1686
1698
|
}
|
|
1687
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
1699
|
+
const { models: SeedModels } = yield import('./seed.schema.config-Dg2ak4Ke.js');
|
|
1688
1700
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
1689
1701
|
let hasModelsInDb = false;
|
|
1690
1702
|
const schemaDefsByModelName = new Map();
|
|
@@ -2297,22 +2309,30 @@ const dbMachine = setup({
|
|
|
2297
2309
|
},
|
|
2298
2310
|
});
|
|
2299
2311
|
|
|
2300
|
-
const validateInput = fromCallback(({ sendBack, input: {
|
|
2301
|
-
const { endpoints, addresses } =
|
|
2302
|
-
|
|
2303
|
-
throw new Error('validateInput called from non-browser context');
|
|
2304
|
-
}
|
|
2312
|
+
const validateInput = fromCallback(({ sendBack, input: { context } }) => {
|
|
2313
|
+
const { endpoints, addresses, arweaveDomain } = context;
|
|
2314
|
+
let { filesDir } = context;
|
|
2305
2315
|
if (!endpoints || !endpoints.filePaths || !endpoints.files) {
|
|
2306
2316
|
throw new Error('validateInput called with invalid endpoints');
|
|
2307
2317
|
}
|
|
2308
2318
|
if (!addresses || !addresses.length) {
|
|
2309
2319
|
throw new Error('validateInput called with invalid addresses');
|
|
2310
2320
|
}
|
|
2321
|
+
if (!filesDir) {
|
|
2322
|
+
if (isBrowser()) {
|
|
2323
|
+
filesDir = '/';
|
|
2324
|
+
}
|
|
2325
|
+
if (!isBrowser()) {
|
|
2326
|
+
throw new Error('validateInput called with invalid filesDir');
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2311
2329
|
const _validateInput = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2312
2330
|
sendBack({
|
|
2313
2331
|
type: INTERNAL_VALIDATING_INPUT_SUCCESS,
|
|
2314
2332
|
endpoints,
|
|
2315
2333
|
addresses,
|
|
2334
|
+
filesDir,
|
|
2335
|
+
arweaveDomain: arweaveDomain || ARWEAVE_HOST,
|
|
2316
2336
|
});
|
|
2317
2337
|
});
|
|
2318
2338
|
_validateInput().then(() => {
|
|
@@ -2320,12 +2340,13 @@ const validateInput = fromCallback(({ sendBack, input: { event } }) => {
|
|
|
2320
2340
|
});
|
|
2321
2341
|
});
|
|
2322
2342
|
|
|
2323
|
-
const prepareDb = fromCallback(({ sendBack }) => {
|
|
2343
|
+
const prepareDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
2344
|
+
const { filesDir } = context;
|
|
2345
|
+
if (!filesDir) {
|
|
2346
|
+
throw new Error('filesDir is required');
|
|
2347
|
+
}
|
|
2324
2348
|
const _prepareDb = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2325
|
-
|
|
2326
|
-
return;
|
|
2327
|
-
}
|
|
2328
|
-
const manager = yield BaseDb.prepareDb();
|
|
2349
|
+
const manager = yield BaseDb.prepareDb(filesDir);
|
|
2329
2350
|
if (manager) {
|
|
2330
2351
|
sendBack({ type: 'prepareDbSuccess', manager });
|
|
2331
2352
|
}
|
|
@@ -3094,6 +3115,8 @@ const internalMachine = setup({
|
|
|
3094
3115
|
actions: assign({
|
|
3095
3116
|
endpoints: ({ event }) => event.endpoints,
|
|
3096
3117
|
addresses: ({ event }) => event.addresses,
|
|
3118
|
+
filesDir: ({ event }) => event.filesDir,
|
|
3119
|
+
arweaveDomain: ({ event }) => event.arweaveDomain,
|
|
3097
3120
|
}),
|
|
3098
3121
|
},
|
|
3099
3122
|
},
|
|
@@ -4041,11 +4064,15 @@ const globalMachine = setup({
|
|
|
4041
4064
|
addedModelRecordsToDb: false,
|
|
4042
4065
|
models: ({ event }) => event.models,
|
|
4043
4066
|
endpoints: ({ event }) => event.endpoints,
|
|
4044
|
-
|
|
4067
|
+
filesDir: ({ event }) => event.filesDir,
|
|
4068
|
+
internalService: ({ spawn, event }) => {
|
|
4045
4069
|
return spawn(internalMachine, {
|
|
4046
4070
|
systemId: MachineIds.INTERNAL,
|
|
4047
4071
|
input: {
|
|
4048
|
-
endpoints:
|
|
4072
|
+
endpoints: event.endpoints,
|
|
4073
|
+
filesDir: event.filesDir,
|
|
4074
|
+
addresses: event.addresses,
|
|
4075
|
+
arweaveDomain: event.arweaveDomain,
|
|
4049
4076
|
},
|
|
4050
4077
|
});
|
|
4051
4078
|
},
|
|
@@ -5490,7 +5517,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5490
5517
|
if (propertyRecordSchema &&
|
|
5491
5518
|
propertyRecordSchema.storageType &&
|
|
5492
5519
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
5493
|
-
const { Item } = yield import('./index-
|
|
5520
|
+
const { Item } = yield import('./index-BgGj2qlg.js');
|
|
5494
5521
|
const item = yield Item.find({
|
|
5495
5522
|
seedLocalId,
|
|
5496
5523
|
modelName,
|
|
@@ -5553,7 +5580,7 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
5553
5580
|
!refResolvedValue) {
|
|
5554
5581
|
safeNewValue = escapeSqliteString(newValue);
|
|
5555
5582
|
}
|
|
5556
|
-
const appDb = getAppDb();
|
|
5583
|
+
const appDb = BaseDb.getAppDb();
|
|
5557
5584
|
const rows = yield appDb
|
|
5558
5585
|
.select()
|
|
5559
5586
|
.from(metadata)
|
|
@@ -5594,7 +5621,7 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
5594
5621
|
ref_resolved_display_value = ${refResolvedDisplayValue ? `'${refResolvedDisplayValue}'` : 'NULL'},
|
|
5595
5622
|
updated_at = ${Date.now()}
|
|
5596
5623
|
WHERE local_id = '${localId}';`;
|
|
5597
|
-
yield
|
|
5624
|
+
yield appDb.run(sql.raw(updatePropertyStatement));
|
|
5598
5625
|
sendItemUpdateEvent({ modelName, seedLocalId, seedUid });
|
|
5599
5626
|
return;
|
|
5600
5627
|
}
|
|
@@ -5632,7 +5659,7 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
5632
5659
|
${refResolvedDisplayValue ? `'${refResolvedDisplayValue}'` : 'NULL'},
|
|
5633
5660
|
${localStorageDir ? `'${localStorageDir}'` : 'NULL'},
|
|
5634
5661
|
${Date.now()});`;
|
|
5635
|
-
yield
|
|
5662
|
+
yield appDb.run(sql.raw(newPropertyStatement));
|
|
5636
5663
|
sendItemUpdateEvent({ modelName, seedLocalId, seedUid });
|
|
5637
5664
|
return;
|
|
5638
5665
|
}
|
|
@@ -5678,7 +5705,7 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
5678
5705
|
${refResolvedDisplayValue ? `'${refResolvedDisplayValue}'` : 'NULL'},
|
|
5679
5706
|
${localStorageDir ? `'${localStorageDir}'` : 'NULL'},
|
|
5680
5707
|
${Date.now()});`;
|
|
5681
|
-
yield
|
|
5708
|
+
yield appDb.run(sql.raw(newPropertyStatement));
|
|
5682
5709
|
sendItemUpdateEvent({ modelName, seedLocalId, seedUid });
|
|
5683
5710
|
});
|
|
5684
5711
|
|
|
@@ -7788,7 +7815,7 @@ const useCreateItem = (modelName) => {
|
|
|
7788
7815
|
return;
|
|
7789
7816
|
}
|
|
7790
7817
|
setIsCreatingItem(true);
|
|
7791
|
-
const { seedLocalId } = yield createNewItem
|
|
7818
|
+
const { seedLocalId } = yield createNewItem(Object.assign({ modelName }, itemData));
|
|
7792
7819
|
yield Item.find({ modelName, seedLocalId });
|
|
7793
7820
|
eventEmitter.emit('item.requestAll', { modelName });
|
|
7794
7821
|
setIsCreatingItem(false);
|
|
@@ -8059,41 +8086,42 @@ const setupServiceHandlers = () => {
|
|
|
8059
8086
|
};
|
|
8060
8087
|
|
|
8061
8088
|
const initEasClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
8062
|
-
if (
|
|
8089
|
+
if (isBrowser()) {
|
|
8063
8090
|
(yield import('./EasClient-Bbxr5rcF.js')).EasClient;
|
|
8064
8091
|
}
|
|
8065
|
-
|
|
8092
|
+
if (!isBrowser()) {
|
|
8066
8093
|
(yield import('./EasClient-BGQRv2-M.js')).EasClient;
|
|
8067
8094
|
}
|
|
8068
8095
|
});
|
|
8069
8096
|
|
|
8070
8097
|
const initQueryClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
8071
|
-
if (
|
|
8098
|
+
if (isBrowser()) {
|
|
8072
8099
|
(yield import('./QueryClient-Dk66c5aw.js')).QueryClient;
|
|
8073
8100
|
}
|
|
8074
|
-
|
|
8101
|
+
if (!isBrowser()) {
|
|
8075
8102
|
(yield import('./QueryClient-CY_4gVB3.js')).QueryClient;
|
|
8076
8103
|
}
|
|
8077
8104
|
});
|
|
8078
8105
|
|
|
8079
8106
|
const initFileManager = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
8080
|
-
if (
|
|
8107
|
+
if (isBrowser()) {
|
|
8081
8108
|
(yield import('./FileManager-BGej9rn4.js')).FileManager;
|
|
8082
8109
|
}
|
|
8083
|
-
|
|
8110
|
+
if (!isBrowser()) {
|
|
8084
8111
|
(yield import('./FileManager-CYXquukS.js')).FileManager;
|
|
8085
8112
|
}
|
|
8086
8113
|
});
|
|
8087
8114
|
|
|
8088
8115
|
const client = {
|
|
8089
|
-
init: (
|
|
8116
|
+
init: (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8117
|
+
const { config, addresses } = options;
|
|
8090
8118
|
yield initItem();
|
|
8091
8119
|
yield initItemProperty();
|
|
8092
8120
|
yield initEasClient();
|
|
8093
8121
|
yield initQueryClient();
|
|
8094
8122
|
yield initFileManager();
|
|
8095
8123
|
yield initDb();
|
|
8096
|
-
const { endpoints, models, arweaveDomain } = config;
|
|
8124
|
+
const { endpoints, models, arweaveDomain, filesDir, } = config;
|
|
8097
8125
|
if (arweaveDomain) {
|
|
8098
8126
|
setArweaveDomain(arweaveDomain);
|
|
8099
8127
|
}
|
|
@@ -8116,8 +8144,9 @@ const client = {
|
|
|
8116
8144
|
models,
|
|
8117
8145
|
addresses,
|
|
8118
8146
|
arweaveDomain,
|
|
8147
|
+
filesDir,
|
|
8119
8148
|
});
|
|
8120
|
-
const { models: internalModels } = yield import('./seed.schema.config-
|
|
8149
|
+
const { models: internalModels } = yield import('./seed.schema.config-Dg2ak4Ke.js');
|
|
8121
8150
|
for (const [key, value] of Object.entries(internalModels)) {
|
|
8122
8151
|
setModel(key, value);
|
|
8123
8152
|
}
|
|
@@ -8164,5 +8193,5 @@ const client = {
|
|
|
8164
8193
|
|
|
8165
8194
|
enableMapSet();
|
|
8166
8195
|
|
|
8167
|
-
export { BaseItem as B, Db as D, Item as I, Json as J, List as L, Model as M, Property as P, Relation as R, Text as T,
|
|
8168
|
-
//# sourceMappingURL=index-
|
|
8196
|
+
export { BaseItem as B, Db as D, Item as I, Json as J, List as L, Model as M, Property as P, Relation as R, Text as T, BaseItemProperty as a, BaseDb as b, getSqliteWasmClient as c, ImageSrc as d, Item$2 as e, ItemProperty$2 as f, getAppDb as g, useItem as h, isAppDbReady as i, useItemProperties as j, useCreateItem as k, useItemProperty as l, useDeleteItem as m, useGlobalServiceStatus as n, usePublishItem as o, usePersistedSnapshots as p, useServices as q, useService as r, getCorrectId as s, getGlobalService as t, useItems as u, eventEmitter as v, withSeed as w, client as x };
|
|
8197
|
+
//# sourceMappingURL=index-ChcOTyEf.js.map
|