@seedprotocol/sdk 0.3.8 → 0.3.9
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/addModel.js +4 -0
- package/dist/addModel.js.map +1 -1
- package/dist/main.js +11 -0
- package/dist/main.js.map +1 -1
- package/dist/src/ItemProperty/index.js +4 -0
- package/dist/src/ItemProperty/index.js.map +1 -0
- package/dist/src/browser/db/Db.d.ts.map +1 -1
- package/dist/src/browser/db/Db.js +35 -8
- package/dist/src/browser/db/Db.js.map +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts +2 -0
- package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/browser/helpers/FileManager.js +20 -8
- package/dist/src/browser/helpers/FileManager.js.map +1 -1
- package/dist/src/browser/index.d.ts +0 -1
- package/dist/src/browser/index.d.ts.map +1 -1
- package/dist/src/browser/react/index.d.ts +2 -1
- package/dist/src/browser/react/index.d.ts.map +1 -1
- package/dist/src/browser/react/model.d.ts +7 -0
- package/dist/src/browser/react/model.d.ts.map +1 -0
- package/dist/src/browser/react/model.js +20 -0
- package/dist/src/browser/react/model.js.map +1 -0
- package/dist/src/browser/react/services.js +1 -1
- package/dist/src/browser/react/services.js.map +1 -1
- package/dist/src/browser/workers/FileDownloader.d.ts.map +1 -1
- package/dist/src/browser/workers/FileDownloader.js +3 -1
- package/dist/src/browser/workers/FileDownloader.js.map +1 -1
- package/dist/src/client/ClientManager.d.ts +21 -12
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/client/ClientManager.js +21 -0
- package/dist/src/client/ClientManager.js.map +1 -1
- package/dist/src/client/actors/saveAppState.d.ts.map +1 -1
- package/dist/src/client/actors/saveAppState.js +0 -1
- package/dist/src/client/actors/saveAppState.js.map +1 -1
- package/dist/src/db/read/getModels.d.ts +2 -0
- package/dist/src/db/read/getModels.d.ts.map +1 -0
- package/dist/src/events/files/download.d.ts.map +1 -1
- package/dist/src/events/files/download.js +0 -1
- package/dist/src/events/files/download.js.map +1 -1
- package/dist/src/events/files/index.d.ts.map +1 -1
- package/dist/src/events/files/index.js +0 -1
- package/dist/src/events/files/index.js.map +1 -1
- package/dist/src/events/services/allItems.d.ts.map +1 -1
- package/dist/src/events/services/allItems.js +0 -1
- package/dist/src/events/services/allItems.js.map +1 -1
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts +2 -0
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/BaseFileManager.js +6 -0
- package/dist/src/helpers/FileManager/BaseFileManager.js.map +1 -1
- package/dist/src/helpers/environment.js +1 -1
- package/dist/src/helpers/environment.js.map +1 -1
- package/dist/src/index.d.ts +8 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/node/helpers/FileManager.d.ts +2 -0
- package/dist/src/node/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/node/helpers/index.d.ts.map +1 -1
- package/dist/src/node/helpers/index.js +0 -1
- package/dist/src/node/helpers/index.js.map +1 -1
- package/dist/src/services/db/actors/migrate.js +1 -1
- package/dist/src/services/db/actors/migrate.js.map +1 -1
- package/dist/src/services/internal/helpers.js +3 -3
- package/dist/src/services/internal/helpers.js.map +1 -1
- package/dist/src/types/model.d.ts +2 -15
- package/dist/src/types/model.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { saveAppState } from '../../db/write/saveAppState.js';
|
|
2
2
|
import filesDownload from './filesDownload.js';
|
|
3
|
+
import debug from 'debug';
|
|
3
4
|
|
|
5
|
+
const logger = debug('seedSdk:browser:workers:FileDownloader');
|
|
4
6
|
class FileDownloader {
|
|
5
7
|
constructor() {
|
|
6
8
|
this.workersArchive = [];
|
|
@@ -17,7 +19,7 @@ class FileDownloader {
|
|
|
17
19
|
const localExcludedTransactions = new Set(excludedTransactions);
|
|
18
20
|
return new Promise((resolve, reject) => {
|
|
19
21
|
worker.onmessage = (e) => {
|
|
20
|
-
|
|
22
|
+
logger('filesDownload main thread onmessage', e.data);
|
|
21
23
|
if (e.data.message === 'excludeTransaction') {
|
|
22
24
|
localExcludedTransactions.add(e.data.transactionId);
|
|
23
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDownloader.js","sources":["../../../../../src/browser/workers/FileDownloader.ts"],"sourcesContent":["import { saveAppState } from '@/db/write/saveAppState.js';\nimport filesDownload from './filesDownload.js'\
|
|
1
|
+
{"version":3,"file":"FileDownloader.js","sources":["../../../../../src/browser/workers/FileDownloader.ts"],"sourcesContent":["import { saveAppState } from '@/db/write/saveAppState.js';\nimport filesDownload from './filesDownload.js'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:browser:workers:FileDownloader')\n\nexport class FileDownloader {\n private cores: number\n private workersArchive: Worker[] = []\n private workerBlobUrl: string\n\n constructor() {\n this.cores = Math.min(navigator.hardwareConcurrency || 4, 4);\n\n this.workerBlobUrl = globalThis.URL.createObjectURL(\n new Blob([filesDownload], { type: 'application/javascript' })\n )\n }\n\n public downloadAll = async ({transactionIds, arweaveHost, excludedTransactions}: DownloadAllFilesParams): Promise<void> => {\n\n if (this.workersArchive.length > 0) {\n for (let i = 0; i < this.workersArchive.length; i++) {\n this.workersArchive[i].terminate()\n delete this.workersArchive[i]\n }\n this.workersArchive = []\n }\n\n const worker = new Worker(this.workerBlobUrl);\n\n this.workersArchive.push(worker)\n\n const localExcludedTransactions = new Set(excludedTransactions)\n\n return new Promise((resolve, reject) => {\n worker.onmessage = (e) => {\n logger('filesDownload main thread onmessage', e.data);\n\n if (e.data.message === 'excludeTransaction') {\n localExcludedTransactions.add(e.data.transactionId)\n }\n\n if (e.data.done) {\n saveAppState('excludedTransactions', JSON.stringify(Array.from(localExcludedTransactions)))\n .then(() => {\n resolve(e.data)\n })\n .catch((error) => {\n reject(error)\n })\n }\n if (e.data.error) {\n reject(e.data.error)\n }\n }\n \n worker.postMessage({\n transactionIds,\n arweaveHost,\n });\n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C,IAAI,CAAC,yBAAyB,CAAC,CAAC;6BACzF,IAAI,CAAC,MAAK;AACT,4BAAA,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AACjB,yBAAC;AACA,6BAAA,KAAK,CAAC,CAAC,KAAK,KAAI;4BACf,MAAM,CAAC,KAAK,CAAC;AACf,yBAAC,CAAC;;AAEJ,oBAAA,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE;AAChB,wBAAA,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;;AAExB,iBAAC;gBAED,MAAM,CAAC,WAAW,CAAC;oBACjB,cAAc;oBACd,WAAW;AACZ,iBAAA,CAAC;AACJ,aAAC,CAAC;AACJ,SAAC;AAlDC,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,mBAAmB,IAAI,CAAC,EAAE,CAAC,CAAC;QAE5D,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,eAAe,CACjD,IAAI,IAAI,CAAC,CAAC,aAAa,CAAC,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC,CAC9D;;AA+CJ;;;;"}
|
|
@@ -1,43 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type ModelDefObj = {
|
|
2
|
+
name: string;
|
|
3
|
+
type: string;
|
|
4
|
+
properties: {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare const clientManager: import("xstate").Actor<import("xstate").StateMachine<import("..").ClientManagerContext, import("xstate").AnyEventObject, {
|
|
9
|
+
[x: string]: import("xstate").ActorRefFromLogic<import("xstate").CallbackActorLogic<import("xstate").EventObject, import("..").FromCallbackInput<import("..").ClientManagerContext>, import("xstate").EventObject>> | undefined;
|
|
3
10
|
}, {
|
|
4
11
|
src: "initialize";
|
|
5
|
-
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("
|
|
12
|
+
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("..").FromCallbackInput<import("..").ClientManagerContext>, import("xstate").EventObject>;
|
|
6
13
|
id: string | undefined;
|
|
7
14
|
}, {
|
|
8
15
|
type: "setAddresses";
|
|
9
16
|
params: import("xstate").NonReducibleUnknown;
|
|
10
|
-
}, never, never, {}, string, import("
|
|
17
|
+
}, never, never, {}, string, import("..").ClientManagerContext, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, import("xstate").MachineConfig<import("..").ClientManagerContext, import("xstate").AnyEventObject, {
|
|
11
18
|
src: "initialize";
|
|
12
|
-
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("
|
|
19
|
+
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("..").FromCallbackInput<import("..").ClientManagerContext>, import("xstate").EventObject>;
|
|
13
20
|
id: string | undefined;
|
|
14
21
|
}, {
|
|
15
22
|
type: "setAddresses";
|
|
16
23
|
params: import("xstate").NonReducibleUnknown;
|
|
17
|
-
}, never, never, string, import("
|
|
24
|
+
}, never, never, string, import("..").ClientManagerContext, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject>>>;
|
|
18
25
|
export declare const ClientManager: {
|
|
19
26
|
isInitialized: () => boolean;
|
|
20
|
-
getService: () => import("xstate").Actor<import("xstate").StateMachine<import("
|
|
21
|
-
[x: string]: import("xstate").ActorRefFromLogic<import("xstate").CallbackActorLogic<import("xstate").EventObject, import("
|
|
27
|
+
getService: () => import("xstate").Actor<import("xstate").StateMachine<import("..").ClientManagerContext, import("xstate").AnyEventObject, {
|
|
28
|
+
[x: string]: import("xstate").ActorRefFromLogic<import("xstate").CallbackActorLogic<import("xstate").EventObject, import("..").FromCallbackInput<import("..").ClientManagerContext>, import("xstate").EventObject>> | undefined;
|
|
22
29
|
}, {
|
|
23
30
|
src: "initialize";
|
|
24
|
-
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("
|
|
31
|
+
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("..").FromCallbackInput<import("..").ClientManagerContext>, import("xstate").EventObject>;
|
|
25
32
|
id: string | undefined;
|
|
26
33
|
}, {
|
|
27
34
|
type: "setAddresses";
|
|
28
35
|
params: import("xstate").NonReducibleUnknown;
|
|
29
|
-
}, never, never, {}, string, import("
|
|
36
|
+
}, never, never, {}, string, import("..").ClientManagerContext, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, import("xstate").MachineConfig<import("..").ClientManagerContext, import("xstate").AnyEventObject, {
|
|
30
37
|
src: "initialize";
|
|
31
|
-
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("
|
|
38
|
+
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("..").FromCallbackInput<import("..").ClientManagerContext>, import("xstate").EventObject>;
|
|
32
39
|
id: string | undefined;
|
|
33
40
|
}, {
|
|
34
41
|
type: "setAddresses";
|
|
35
42
|
params: import("xstate").NonReducibleUnknown;
|
|
36
|
-
}, never, never, string, import("
|
|
43
|
+
}, never, never, string, import("..").ClientManagerContext, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject>>>;
|
|
37
44
|
init: (options: any) => Promise<void>;
|
|
38
45
|
setAddresses: (addresses: string[]) => Promise<void>;
|
|
39
46
|
getAddresses: () => Promise<any>;
|
|
47
|
+
addModel: (modelDef: ModelDefObj) => Promise<void>;
|
|
40
48
|
stop: () => void;
|
|
41
49
|
unload: () => void;
|
|
42
50
|
};
|
|
51
|
+
export {};
|
|
43
52
|
//# sourceMappingURL=ClientManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientManager.d.ts","sourceRoot":"","sources":["../../../src/client/ClientManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ClientManager.d.ts","sourceRoot":"","sources":["../../../src/client/ClientManager.ts"],"names":[],"mappings":"AAcA,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE;QACV,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KACnB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;8JAIxB,CAAA;AAeF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;oBAQF,GAAG;8BAIO,MAAM,EAAE;;yBAab,WAAW;;;CAqBvC,CAAA"}
|
|
@@ -2,6 +2,15 @@ import debug from 'debug';
|
|
|
2
2
|
import { createActor, waitFor } from 'xstate';
|
|
3
3
|
import { clientManagerMachine } from './clientManagerMachine.js';
|
|
4
4
|
import { CLIENT_NOT_INITIALIZED } from '../helpers/constants.js';
|
|
5
|
+
import { BaseDb } from '../db/Db/BaseDb.js';
|
|
6
|
+
import '../seedSchema/SeedSchema.js';
|
|
7
|
+
import '../seedSchema/VersionSchema.js';
|
|
8
|
+
import '../seedSchema/MetadataSchema.js';
|
|
9
|
+
import { appState } from '../seedSchema/AppStateSchema.js';
|
|
10
|
+
import { models } from '../seedSchema/ModelSchema.js';
|
|
11
|
+
import '../seedSchema/ModelUidSchema.js';
|
|
12
|
+
import { eq } from 'drizzle-orm';
|
|
13
|
+
import { getGlobalService } from '../services/global/globalMachine.js';
|
|
5
14
|
|
|
6
15
|
const logger = debug('seedSdk:client');
|
|
7
16
|
const clientManager = createActor(clientManagerMachine, {
|
|
@@ -44,6 +53,18 @@ const ClientManager = {
|
|
|
44
53
|
const results = await db.select().from(appState).where(eq(appState.key, 'addresses'));
|
|
45
54
|
return JSON.parse(results[0]?.value);
|
|
46
55
|
},
|
|
56
|
+
addModel: async (modelDef) => {
|
|
57
|
+
const db = await BaseDb.getAppDb();
|
|
58
|
+
const existingModels = await db.select().from(models).where(eq(models.name, modelDef.name));
|
|
59
|
+
if (existingModels.length > 0) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
await db.insert(models).values({
|
|
63
|
+
name: modelDef.name
|
|
64
|
+
});
|
|
65
|
+
const globalService = getGlobalService();
|
|
66
|
+
globalService.send({ type: 'addModel', modelDef });
|
|
67
|
+
},
|
|
47
68
|
stop: () => {
|
|
48
69
|
ensureInitialized();
|
|
49
70
|
clientManager.stop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientManager.js","sources":["../../../../src/client/ClientManager.ts"],"sourcesContent":["import debug from 'debug'\nimport { createActor, waitFor } from 'xstate'\nimport { clientManagerMachine } from '@/client/clientManagerMachine'\n// import { BaseDb } from '@/db/Db/BaseDb'\n// import { appState } from '@/seedSchema'\n// import { eq } from 'drizzle-orm'\nimport { CLIENT_NOT_INITIALIZED } from '@/helpers/constants'\n\nconst logger = debug('seedSdk:client')\n\nexport const clientManager = createActor(clientManagerMachine, {\n input: {\n isInitialized: false,\n }\n})\n\nconst subscription = clientManager.subscribe(( snapshot ) => {\n logger('ClientManager snapshot.value:', snapshot.value)\n logger('ClientManager snapshot.context.isInitialized:', snapshot.context.isInitialized)\n})\n\nclientManager.start()\n\nconst ensureInitialized = () => {\n if (!clientManager.getSnapshot().context.isInitialized) {\n throw new Error(CLIENT_NOT_INITIALIZED);\n }\n}\n\nexport const ClientManager = {\n isInitialized: () => {\n return clientManager.getSnapshot().context.isInitialized\n },\n getService: () => {\n ensureInitialized();\n return clientManager;\n },\n init: async (options: any) => {\n clientManager.send({ type: 'init', options });\n await waitFor(clientManager, (snapshot) => snapshot.context.isInitialized);\n },\n setAddresses: async (addresses: string[]) => {\n ensureInitialized();\n logger('setAddresses', addresses);\n clientManager.send({ type: 'setAddresses', addresses });\n await waitFor(clientManager, (snapshot) => !snapshot.context.isSaving);\n logger('setAddresses success', addresses);\n },\n getAddresses: async () => {\n ensureInitialized();\n const db = await BaseDb.getAppDb();\n const results = await db.select().from(appState).where(eq(appState.key, 'addresses'));\n return JSON.parse(results[0]?.value);\n },\n stop: () => {\n ensureInitialized();\n clientManager.stop();\n },\n unload: () => {\n ensureInitialized();\n clientManager.stop();\n subscription.unsubscribe();\n },\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ClientManager.js","sources":["../../../../src/client/ClientManager.ts"],"sourcesContent":["import debug from 'debug'\nimport { createActor, waitFor } from 'xstate'\nimport { clientManagerMachine } from '@/client/clientManagerMachine'\n// import { BaseDb } from '@/db/Db/BaseDb'\n// import { appState } from '@/seedSchema'\n// import { eq } from 'drizzle-orm'\nimport { CLIENT_NOT_INITIALIZED } from '@/helpers/constants'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { appState, models } from '@/seedSchema'\nimport { eq } from 'drizzle-orm'\nimport { getGlobalService } from '@/services/global/globalMachine'\n\nconst logger = debug('seedSdk:client')\n\ntype ModelDefObj = {\n name: string\n type: string\n properties: {\n [key: string]: any\n }\n}\n\nexport const clientManager = createActor(clientManagerMachine, {\n input: {\n isInitialized: false,\n }\n})\n\nconst subscription = clientManager.subscribe(( snapshot ) => {\n logger('ClientManager snapshot.value:', snapshot.value)\n logger('ClientManager snapshot.context.isInitialized:', snapshot.context.isInitialized)\n})\n\nclientManager.start()\n\nconst ensureInitialized = () => {\n if (!clientManager.getSnapshot().context.isInitialized) {\n throw new Error(CLIENT_NOT_INITIALIZED);\n }\n}\n\nexport const ClientManager = {\n isInitialized: () => {\n return clientManager.getSnapshot().context.isInitialized\n },\n getService: () => {\n ensureInitialized();\n return clientManager;\n },\n init: async (options: any) => {\n clientManager.send({ type: 'init', options });\n await waitFor(clientManager, (snapshot) => snapshot.context.isInitialized);\n },\n setAddresses: async (addresses: string[]) => {\n ensureInitialized();\n logger('setAddresses', addresses);\n clientManager.send({ type: 'setAddresses', addresses });\n await waitFor(clientManager, (snapshot) => !snapshot.context.isSaving);\n logger('setAddresses success', addresses);\n },\n getAddresses: async () => {\n ensureInitialized();\n const db = await BaseDb.getAppDb();\n const results = await db.select().from(appState).where(eq(appState.key, 'addresses'));\n return JSON.parse(results[0]?.value);\n },\n addModel: async (modelDef: ModelDefObj) => {\n const db = await BaseDb.getAppDb();\n const existingModels = await db.select().from(models).where(eq(models.name, modelDef.name));\n if (existingModels.length > 0) {\n return;\n }\n await db.insert(models).values({\n name: modelDef.name\n })\n const globalService = getGlobalService()\n globalService.send({ type: 'addModel', modelDef });\n },\n stop: () => {\n ensureInitialized();\n clientManager.stop();\n },\n unload: () => {\n ensureInitialized();\n clientManager.stop();\n subscription.unsubscribe();\n },\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAYA,MAAM,MAAM,GAAiB,KAAK,CAAC,gBAAgB,CAAC;AAUvC,MAAA,aAAa,GAAG,WAAW,CAAC,oBAAoB,EAAE;AAC7D,IAAA,KAAK,EAAE;AACL,QAAA,aAAa,EAAE,KAAK;AACrB;AACF,CAAA;AAED,MAAM,YAAY,GAAW,aAAa,CAAC,SAAS,CAAC,CAAE,QAAQ,KAAK;AAClE,IAAA,MAAM,CAAC,+BAA+B,EAAE,QAAQ,CAAC,KAAK,CAAC;IACvD,MAAM,CAAC,+CAA+C,EAAE,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC;AACzF,CAAC,CAAC;AAEF,aAAa,CAAC,KAAK,EAAE;AAErB,MAAM,iBAAiB,GAAG,MAAK;IAC7B,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE;AACtD,QAAA,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;;AAE3C,CAAC;AAEY,MAAA,aAAa,GAAG;IAC3B,aAAa,EAAE,MAAK;QAClB,OAAO,aAAa,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,aAAa;KACzD;IACD,UAAU,EAAE,MAAK;AACf,QAAA,iBAAiB,EAAE;AACnB,QAAA,OAAO,aAAa;KACrB;AACD,IAAA,IAAI,EAAE,OAAO,OAAY,KAAI;QAC3B,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7C,QAAA,MAAM,OAAO,CAAC,a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AAA,CAAC;AACF,QAAA,MAAM,aAAa,GAAG,gBAAgB,EAAE;QACxC,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;KACnD;IACD,IAAI,EAAE,MAAK;AACT,QAAA,iBAAiB,EAAE;QACnB,aAAa,CAAC,IAAI,EAAE;KACrB;IACD,MAAM,EAAE,MAAK;AACX,QAAA,iBAAiB,EAAE;QACnB,aAAa,CAAC,IAAI,EAAE;QACpB,YAAY,CAAC,WAAW,EAAE;KAC3B;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saveAppState.d.ts","sourceRoot":"","sources":["../../../../src/client/actors/saveAppState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAMrC,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"saveAppState.d.ts","sourceRoot":"","sources":["../../../../src/client/actors/saveAppState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAMrC,eAAO,MAAM,YAAY,wGAsCrB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saveAppState.js","sources":["../../../../../src/client/actors/saveAppState.ts"],"sourcesContent":["import { FromCallbackInput } from \"@/types\";\nimport { fromCallback } from \"xstate\";\nimport { ClientManagerContext } from \"@/types\";\nimport { EventObject } from \"xstate\";\nimport debug from \"debug\";\nimport { appState } from \"@/seedSchema\";\n\nconst logger = debug('seedSdk:client:writeToDb')\n\nexport const saveAppState = fromCallback<\nEventObject, \nFromCallbackInput<ClientManagerContext>\n>(\n ({sendBack, input: {key, value}}) => {\n\n const _saveAppState = async () => {\n const { BaseDb } = await import('@/db/Db/BaseDb')\n if (!BaseDb) {\n throw new Error('BaseDb not found')\n }\n const appDb = BaseDb.getAppDb()\n if (!appDb) {\n throw new Error('App DB not found')\n }\n\n
|
|
1
|
+
{"version":3,"file":"saveAppState.js","sources":["../../../../../src/client/actors/saveAppState.ts"],"sourcesContent":["import { FromCallbackInput } from \"@/types\";\nimport { fromCallback } from \"xstate\";\nimport { ClientManagerContext } from \"@/types\";\nimport { EventObject } from \"xstate\";\nimport debug from \"debug\";\nimport { appState } from \"@/seedSchema\";\n\nconst logger = debug('seedSdk:client:writeToDb')\n\nexport const saveAppState = fromCallback<\nEventObject, \nFromCallbackInput<ClientManagerContext>\n>(\n ({sendBack, input: {key, value}}) => {\n\n const _saveAppState = async () => {\n const { BaseDb } = await import('@/db/Db/BaseDb')\n if (!BaseDb) {\n throw new Error('BaseDb not found')\n }\n const appDb = BaseDb.getAppDb()\n if (!appDb) {\n throw new Error('App DB not found')\n }\n\n appDb.insert(appState)\n .values({\n key: key,\n value: JSON.stringify(value),\n })\n .onConflictDoUpdate({\n target: appState.key,\n set: {\n value: JSON.stringify(value),\n },\n })\n \n }\n\n _saveAppState().then(() => {\n sendBack({\n type: 'saveAppStateSuccess',\n key,\n value,\n })\n })\n \n })\n"],"names":[],"mappings":";;;;;;;;;AAOe,KAAK,CAAC,0BAA0B;AAElC,MAAA,YAAY,GAAG,YAAY,CAItC,CAAC,EAAC,QAAQ,EAAE,KAAK,EAAE,EAAC,GAAG,EAAE,KAAK,EAAC,EAAC,KAAI;AAElC,IAAA,MAAM,aAAa,GAAG,YAAW;QAC/B,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,OAAO,uBAAgB,CAAC;QACjD,IAAI,CAAC,MAAM,EAAE;AACX,YAAA,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC;;AAErC,QAAA,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE;QAC/B,IAAI,CAAC,KAAK,EAAE;AACV,YAAA,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC;;AAGrC,QAAA,KAAK,CAAC,MAAM,CAAC,QAAQ;AAClB,aAAA,MAAM,CAAC;AACN,YAAA,GAAG,EAAE,GAAG;AACR,YAAA,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;SAC7B;AACA,aAAA,kBAAkB,CAAC;YAClB,MAAM,EAAE,QAAQ,CAAC,GAAG;AACpB,YAAA,GAAG,EAAE;AACH,gBAAA,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;AAC7B,aAAA;AACF,SAAA,CAAC;AAEN,KAAC;AAED,IAAA,aAAa,EAAE,CAAC,IAAI,CAAC,MAAK;AACxB,QAAA,QAAQ,CAAC;AACP,YAAA,IAAI,EAAE,qBAAqB;YAC3B,GAAG;YACH,KAAK;AACN,SAAA,CAAC;AACJ,KAAC,CAAC;AAEJ,CAAC;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getModels.d.ts","sourceRoot":"","sources":["../../../../src/db/read/getModels.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,oBAOrB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../../src/events/files/download.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,8BAA8B;;;mBAa1C,CAAA;AAED,eAAO,MAAM,oCAAoC,
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../../src/events/files/download.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,8BAA8B;;;mBAa1C,CAAA;AAED,eAAO,MAAM,oCAAoC,oCAmKhD,CAAA"}
|
|
@@ -145,7 +145,6 @@ const downloadAllFilesBinaryRequestHandler = async () => {
|
|
|
145
145
|
logger(error);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
console.log('[download] Calling downloadAllFiles with transactionIdsToDownload', transactionIdsToDownload);
|
|
149
148
|
await BaseFileManager.downloadAllFiles({
|
|
150
149
|
transactionIds: transactionIdsToDownload,
|
|
151
150
|
arweaveHost: ARWEAVE_HOST,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.js","sources":["../../../../../src/events/files/download.ts"],"sourcesContent":["import { syncDbFiles } from '@/services/internal/helpers'\nimport { eventEmitter } from '@/eventBus'\nimport { ARWEAVE_HOST } from '@/services/internal/constants'\nimport { appState } from '@/seedSchema'\nimport { eq } from 'drizzle-orm'\nimport { getAddressesFromDb } from '@/helpers/db'\nimport {\n BaseFileManager,\n} from '@/helpers'\nimport { GET_FILES_METADATA } from '@/schema/file/queries'\nimport debug from 'debug'\nimport { getGlobalService } from '@/services/global/globalMachine'\nimport { waitFor } from 'xstate'\nimport { getMetadata } from '@/db/read/getMetadata'\nimport { saveMetadata } from '@/db/write/saveMetadata'\nimport { GET_TRANSACTION_TAGS } from '@/helpers/ArweaveClient/queries'\nimport { saveAppState } from '@/db/write/saveAppState'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { BaseEasClient, BaseQueryClient, BaseArweaveClient } from '@/helpers'\nimport { getArweave } from '@/helpers/ArweaveClient'\nimport { isBrowser } from '@/helpers/environment'\n\n\nconst logger = debug('seedSdk:files:download')\n\n\nexport const downloadAllFilesRequestHandler = async ({\n endpoints,\n eventId,\n}) => {\n\n if (!isBrowser()) {\n return\n }\n\n await syncDbFiles(endpoints)\n\n eventEmitter.emit('fs.downloadAll.success', { eventId })\n eventEmitter.emit('fs.downloadAllBinary.request', { endpoints })\n}\n\nexport const downloadAllFilesBinaryRequestHandler = async () => {\n let addresses: string[] | undefined\n\n if (BaseDb.isAppDbReady()) {\n addresses = await getAddressesFromDb()\n }\n\n if (!BaseDb.isAppDbReady()) {\n const globalService = getGlobalService()\n const internalService = globalService.getSnapshot().context.internalService\n if (internalService) {\n await waitFor(internalService, (snapshot) => {\n return snapshot.value === 'ready'\n })\n addresses = await getAddressesFromDb()\n }\n }\n\n if (!addresses || addresses.length === 0) {\n return\n }\n\n const queryClient = BaseQueryClient.getQueryClient()\n const easClient = BaseEasClient.getEasClient()\n\n const { filesMetadata } = await queryClient.fetchQuery({\n queryKey: ['getFilesMetadata', ...addresses],\n queryFn: async () =>\n easClient.request(GET_FILES_METADATA, {\n where: {\n attester: {\n in: addresses,\n },\n schema: {\n is: {\n id: {\n equals:\n '0x55fdefb36fcbbaebeb7d6b41dc3a1a9666e4e42154267c889de064faa7ede517',\n },\n },\n },\n },\n }),\n })\n\n await BaseFileManager.createDirIfNotExists('/files')\n await BaseFileManager.createDirIfNotExists('/files/html')\n await BaseFileManager.createDirIfNotExists('/files/json')\n await BaseFileManager.createDirIfNotExists('/files/images')\n\n const appDb = BaseDb.getAppDb()\n\n if (!appDb) {\n console.warn('[fetchAll/actors] [fetchAllBinaryData] seedDb not available')\n return []\n }\n\n const excludedTransactionsQuery = await appDb\n .select()\n .from(appState)\n .where(eq(appState.key, 'excludedTransactions'))\n\n let excludedTransactions = new Set<string>()\n\n if (excludedTransactionsQuery && excludedTransactionsQuery.length === 1) {\n const valueString = excludedTransactionsQuery[0].value\n if (valueString) {\n const excludedTransactionsArray = JSON.parse(valueString)\n excludedTransactions = new Set(excludedTransactionsArray)\n }\n }\n\n const transactionIds = []\n\n for (const fileMetadata of filesMetadata) {\n const json = JSON.parse(fileMetadata.decodedDataJson)\n const transactionId = json[0].value.value\n if (excludedTransactions.has(transactionId)) {\n continue\n }\n transactionIds.push(transactionId)\n }\n\n const arweave = getArweave()\n\n if (!arweave) {\n console.warn(\n '[fetchAll/actors] [fetchAllBinaryData] arweave not available',\n )\n return []\n }\n\n const arweaveClient = BaseArweaveClient.getArweaveClient()\n\n const transactionIdsToDownload = []\n\n for (const transactionId of transactionIds) {\n\n try {\n const res = await fetch(\n `https://${ARWEAVE_HOST}/tx/${transactionId}/status`,\n )\n\n if (res.status !== 200) {\n logger(\n `[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`,\n )\n\n excludedTransactions.add(transactionId)\n\n await saveAppState(\n 'excludedTransactions',\n JSON.stringify(Array.from(excludedTransactions)),\n )\n\n continue\n }\n \n const { tags: tagsResult } = await queryClient.fetchQuery({\n queryKey: ['getTransactionTags', transactionId],\n queryFn: async () =>\n arweaveClient.request(GET_TRANSACTION_TAGS, {\n transactionId,\n }),\n })\n\n const tags = tagsResult.tags || []\n\n if (tagsResult.tags && tagsResult.tags.length > 0) {\n for (const { name, value } of tags) {\n if (name === 'Content-SHA-256') {\n const metadataRecord = await getMetadata({\n storageTransactionId: transactionId,\n })\n\n if (metadataRecord) {\n await saveMetadata(metadataRecord, {\n contentHash: value,\n })\n }\n }\n }\n }\n\n transactionIdsToDownload.push(transactionId)\n\n \n\n } catch (error) {\n logger(error)\n }\n }\n\n
|
|
1
|
+
{"version":3,"file":"download.js","sources":["../../../../../src/events/files/download.ts"],"sourcesContent":["import { syncDbFiles } from '@/services/internal/helpers'\nimport { eventEmitter } from '@/eventBus'\nimport { ARWEAVE_HOST } from '@/services/internal/constants'\nimport { appState } from '@/seedSchema'\nimport { eq } from 'drizzle-orm'\nimport { getAddressesFromDb } from '@/helpers/db'\nimport {\n BaseFileManager,\n} from '@/helpers'\nimport { GET_FILES_METADATA } from '@/schema/file/queries'\nimport debug from 'debug'\nimport { getGlobalService } from '@/services/global/globalMachine'\nimport { waitFor } from 'xstate'\nimport { getMetadata } from '@/db/read/getMetadata'\nimport { saveMetadata } from '@/db/write/saveMetadata'\nimport { GET_TRANSACTION_TAGS } from '@/helpers/ArweaveClient/queries'\nimport { saveAppState } from '@/db/write/saveAppState'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { BaseEasClient, BaseQueryClient, BaseArweaveClient } from '@/helpers'\nimport { getArweave } from '@/helpers/ArweaveClient'\nimport { isBrowser } from '@/helpers/environment'\n\n\nconst logger = debug('seedSdk:files:download')\n\n\nexport const downloadAllFilesRequestHandler = async ({\n endpoints,\n eventId,\n}) => {\n\n if (!isBrowser()) {\n return\n }\n\n await syncDbFiles(endpoints)\n\n eventEmitter.emit('fs.downloadAll.success', { eventId })\n eventEmitter.emit('fs.downloadAllBinary.request', { endpoints })\n}\n\nexport const downloadAllFilesBinaryRequestHandler = async () => {\n let addresses: string[] | undefined\n\n if (BaseDb.isAppDbReady()) {\n addresses = await getAddressesFromDb()\n }\n\n if (!BaseDb.isAppDbReady()) {\n const globalService = getGlobalService()\n const internalService = globalService.getSnapshot().context.internalService\n if (internalService) {\n await waitFor(internalService, (snapshot) => {\n return snapshot.value === 'ready'\n })\n addresses = await getAddressesFromDb()\n }\n }\n\n if (!addresses || addresses.length === 0) {\n return\n }\n\n const queryClient = BaseQueryClient.getQueryClient()\n const easClient = BaseEasClient.getEasClient()\n\n const { filesMetadata } = await queryClient.fetchQuery({\n queryKey: ['getFilesMetadata', ...addresses],\n queryFn: async () =>\n easClient.request(GET_FILES_METADATA, {\n where: {\n attester: {\n in: addresses,\n },\n schema: {\n is: {\n id: {\n equals:\n '0x55fdefb36fcbbaebeb7d6b41dc3a1a9666e4e42154267c889de064faa7ede517',\n },\n },\n },\n },\n }),\n })\n\n await BaseFileManager.createDirIfNotExists('/files')\n await BaseFileManager.createDirIfNotExists('/files/html')\n await BaseFileManager.createDirIfNotExists('/files/json')\n await BaseFileManager.createDirIfNotExists('/files/images')\n\n const appDb = BaseDb.getAppDb()\n\n if (!appDb) {\n console.warn('[fetchAll/actors] [fetchAllBinaryData] seedDb not available')\n return []\n }\n\n const excludedTransactionsQuery = await appDb\n .select()\n .from(appState)\n .where(eq(appState.key, 'excludedTransactions'))\n\n let excludedTransactions = new Set<string>()\n\n if (excludedTransactionsQuery && excludedTransactionsQuery.length === 1) {\n const valueString = excludedTransactionsQuery[0].value\n if (valueString) {\n const excludedTransactionsArray = JSON.parse(valueString)\n excludedTransactions = new Set(excludedTransactionsArray)\n }\n }\n\n const transactionIds = []\n\n for (const fileMetadata of filesMetadata) {\n const json = JSON.parse(fileMetadata.decodedDataJson)\n const transactionId = json[0].value.value\n if (excludedTransactions.has(transactionId)) {\n continue\n }\n transactionIds.push(transactionId)\n }\n\n const arweave = getArweave()\n\n if (!arweave) {\n console.warn(\n '[fetchAll/actors] [fetchAllBinaryData] arweave not available',\n )\n return []\n }\n\n const arweaveClient = BaseArweaveClient.getArweaveClient()\n\n const transactionIdsToDownload = []\n\n for (const transactionId of transactionIds) {\n\n try {\n const res = await fetch(\n `https://${ARWEAVE_HOST}/tx/${transactionId}/status`,\n )\n\n if (res.status !== 200) {\n logger(\n `[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`,\n )\n\n excludedTransactions.add(transactionId)\n\n await saveAppState(\n 'excludedTransactions',\n JSON.stringify(Array.from(excludedTransactions)),\n )\n\n continue\n }\n \n const { tags: tagsResult } = await queryClient.fetchQuery({\n queryKey: ['getTransactionTags', transactionId],\n queryFn: async () =>\n arweaveClient.request(GET_TRANSACTION_TAGS, {\n transactionId,\n }),\n })\n\n const tags = tagsResult.tags || []\n\n if (tagsResult.tags && tagsResult.tags.length > 0) {\n for (const { name, value } of tags) {\n if (name === 'Content-SHA-256') {\n const metadataRecord = await getMetadata({\n storageTransactionId: transactionId,\n })\n\n if (metadataRecord) {\n await saveMetadata(metadataRecord, {\n contentHash: value,\n })\n }\n }\n }\n }\n\n transactionIdsToDownload.push(transactionId)\n\n \n\n } catch (error) {\n logger(error)\n }\n }\n\n await BaseFileManager.downloadAllFiles({\n transactionIds: transactionIdsToDownload,\n arweaveHost: ARWEAVE_HOST,\n excludedTransactions,\n })\n\n await BaseFileManager.resizeAllImages({\n width: 480,\n height: 480,\n })\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,MAAM,GAAG,KAAK,CAAC,wBAAwB,CAAC;AAGvC,MAAM,8BAA8B,GAAG,OAAO,EACnD,SAAS,EACT,OAAO,GACR,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AI,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;gBACjD,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,IAAI,EAAE;AAClC,oBAAA,IAAI,IAAI,KAAK,iBAAiB,EAAE;AAC9B,wBAAA,MAAM,cAAc,GAAG,MAAM,WAAW,CAAC;AACvC,4BAAA,oBAAoB,EAAE,aAAa;AACpC,yBAAA,CAAC;wBAEF,IAAI,cAAc,EAAE;4BAClB,MAAM,YAAY,CAAC,cAAc,EAAE;AACjC,gCAAA,WAAW,EAAE,KAAK;AACnB,6BAAA,CAAC;;;;;AAMV,YAAA,wBAAwB,CAAC,IAAI,CAAC,aAAa,CAAC;;QAI5C,OAAO,KAAK,EAAE;YACd,MAAM,CAAC,KAAK,CAAC;;;IAIjB,MAAM,eAAe,CAAC,gBAAgB,CAAC;AACrC,QAAA,cAAc,EAAE,wBAAwB;AACxC,QAAA,WAAW,EAAE,YAAY;QACzB,oBAAoB;AACrB,KAAA,CAAC;IAEF,MAAM,eAAe,CAAC,eAAe,CAAC;AACpC,QAAA,KAAK,EAAE,GAAG;AACV,QAAA,MAAM,EAAE,GAAG;AACZ,KAAA,CAAC;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/events/files/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/events/files/index.ts"],"names":[],"mappings":"AA0DA,eAAO,MAAM,gBAAgB,YAW5B,CAAA;AAED,eAAO,MAAM,mBAAmB,eAE/B,CAAA;AAED,eAAO,MAAM,eAAe,eAE3B,CAAA"}
|
|
@@ -22,7 +22,6 @@ const fsInitHandler = async () => {
|
|
|
22
22
|
// })
|
|
23
23
|
if (isBrowser()) {
|
|
24
24
|
const FileManager = (await import('../../browser/helpers/FileManager.js')).FileManager;
|
|
25
|
-
console.log('FileManager', FileManager);
|
|
26
25
|
BaseFileManager.setPlatformClass(FileManager);
|
|
27
26
|
}
|
|
28
27
|
// if (!isBrowser()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/events/files/index.ts"],"sourcesContent":["import { eventEmitter } from '@/eventBus'\nimport { downloadAllFilesBinaryRequestHandler, downloadAllFilesRequestHandler } from './download'\nimport { BaseFileManager } from '@/helpers'\nimport { isBrowser } from '@/helpers/environment'\n\n\nlet isInitialized = false\n\n\nconst fsInitHandler = async () => {\n if ( isInitialized ) {\n eventEmitter.emit('fs.init.response', { success: true })\n return\n }\n\n try {\n\n // console.log('fsInitHandler isBrowser', isBrowser())\n\n // console.log({\n // environment: process.env.NEXT_RUNTIME || 'unknown',\n // isServer: typeof window === 'undefined',\n // nodeEnv: process.env.NODE_ENV,\n // // Log what's available in global scope\n // hasWindow: typeof window !== 'undefined',\n // hasDocument: typeof document !== 'undefined',\n // })\n\n if (\n isBrowser()\n ) {\n const FileManager = (await import('../../browser/helpers/FileManager')).FileManager\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/events/files/index.ts"],"sourcesContent":["import { eventEmitter } from '@/eventBus'\nimport { downloadAllFilesBinaryRequestHandler, downloadAllFilesRequestHandler } from './download'\nimport { BaseFileManager } from '@/helpers'\nimport { isBrowser } from '@/helpers/environment'\n\n\nlet isInitialized = false\n\n\nconst fsInitHandler = async () => {\n if ( isInitialized ) {\n eventEmitter.emit('fs.init.response', { success: true })\n return\n }\n\n try {\n\n // console.log('fsInitHandler isBrowser', isBrowser())\n\n // console.log({\n // environment: process.env.NEXT_RUNTIME || 'unknown',\n // isServer: typeof window === 'undefined',\n // nodeEnv: process.env.NODE_ENV,\n // // Log what's available in global scope\n // hasWindow: typeof window !== 'undefined',\n // hasDocument: typeof document !== 'undefined',\n // })\n\n if (\n isBrowser()\n ) {\n const FileManager = (await import('../../browser/helpers/FileManager')).FileManager\n BaseFileManager.setPlatformClass(FileManager)\n }\n\n // if (!isBrowser()) {\n // await import('@/node/helpers/FileManager')\n // }\n\n await BaseFileManager.initializeFileSystem()\n\n isInitialized = true\n\n eventEmitter.emit('fs.init.response', { success: true })\n } catch ( e ) {\n if ( !isInitialized ) {\n console.error('[fs.init] error initializing fs', e)\n eventEmitter.emit('fs.init.response', {\n success: false,\n error: e,\n })\n }\n // TODO: We can ignore this for now but should figure out if this is being called excessively\n }\n}\n\nlet areReady = false\n\nexport const setupFsListeners = () => {\n eventEmitter.addListener(\n 'fs.downloadAll.request',\n downloadAllFilesRequestHandler,\n )\n eventEmitter.addListener(\n 'fs.downloadAllBinary.request',\n downloadAllFilesBinaryRequestHandler,\n )\n eventEmitter.addListener('fs.init', fsInitHandler)\n areReady = true\n}\n\nexport const areFsListenersReady = () => {\n return areReady\n}\n\nexport const isFsInitialized = () => {\n return isInitialized\n}\n"],"names":[],"mappings":";;;;;;AAMA,IAAI,aAAa,GAAG,KAAK;AAGzB,MAAM,aAAa,GAAG,YAAW;IAC/B,IAAK,aAAa,EAAG;QACnB,YAAY,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACxD;;AAGF,IAAA,IAAI;;;;;;;;;;QAaF,IACE,SAAS,EAAE,EACX;YACA,MAAM,WAAW,GAAG,CAAC,MAAM,OAAO,sCAAmC,CAAC,EAAE,WAAW;AACnF,YAAA,eAAe,CAAC,gBAAgB,CAAC,WAAW,CAAC;;;;;AAO/C,QAAA,MAAM,eAAe,CAAC,oBAAoB,EAAE;QAE5C,aAAa,GAAG,IAAI;QAEpB,YAAY,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;IACxD,OAAQ,CAAC,EAAG;QACZ,IAAK,CAAC,aAAa,EAAG;AACpB,YAAA,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,CAAC,CAAC;AACnD,YAAA,YAAY,CAAC,IAAI,CAAC,kBAAkB,EAAE;AACpC,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,KAAK,EAAE,CAAC;AACT,aAAA,CAAC;;;;AAIR,CAAC;AAED,IAAI,QAAQ,GAAG,KAAK;AAEb,MAAM,gBAAgB,GAAG,MAAK;AACnC,IAAA,YAAY,CAAC,WAAW,CACtB,wBAAwB,EACxB,8BAA8B,CAC/B;AACD,IAAA,YAAY,CAAC,WAAW,CACtB,8BAA8B,EAC9B,oCAAoC,CACrC;AACD,IAAA,YAAY,CAAC,WAAW,CAAC,SAAS,EAAE,aAAa,CAAC;IAClD,QAAQ,GAAG,IAAI;AACjB;AAEO,MAAM,mBAAmB,GAAG,MAAK;AACtC,IAAA,OAAO,QAAQ;AACjB;AAEO,MAAM,eAAe,GAAG,MAAK;AAClC,IAAA,OAAO,aAAa;AACtB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allItems.d.ts","sourceRoot":"","sources":["../../../../src/events/services/allItems.ts"],"names":[],"mappings":"AAIA,KAAK,gBAAgB,GAAG;IACtB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,kBAAkB,UAAiB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"allItems.d.ts","sourceRoot":"","sources":["../../../../src/events/services/allItems.ts"],"names":[],"mappings":"AAIA,KAAK,gBAAgB,GAAG;IACtB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,kBAAkB,UAAiB,gBAAgB,kBAqB/D,CAAA"}
|
|
@@ -10,7 +10,6 @@ const saveServiceHandler = async (event) => {
|
|
|
10
10
|
const nameOfService = `${modelName}Service`;
|
|
11
11
|
const service = globalService.getSnapshot().context[nameOfService];
|
|
12
12
|
if (!service) {
|
|
13
|
-
console.log(`[saveServiceHandler] service not found: ${nameOfService}`);
|
|
14
13
|
return;
|
|
15
14
|
}
|
|
16
15
|
await saveAppState(`snapshot__${modelName}`, JSON.stringify(service.getPersistedSnapshot()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allItems.js","sources":["../../../../../src/events/services/allItems.ts"],"sourcesContent":["import { getGlobalService } from '@/services/global/globalMachine'\n\nimport { saveAppState } from '@/db/write/saveAppState'\n\ntype SaveServiceEvent = {\n modelName: string\n}\n\nexport const saveServiceHandler = async (event: SaveServiceEvent) => {\n const globalService = getGlobalService()\n\n if (!globalService || !globalService.getSnapshot().context) {\n return\n }\n\n const { modelName } = event\n\n const nameOfService: string = `${modelName}Service`\n\n const service = globalService.getSnapshot().context[nameOfService]\n\n if (!service) {\n
|
|
1
|
+
{"version":3,"file":"allItems.js","sources":["../../../../../src/events/services/allItems.ts"],"sourcesContent":["import { getGlobalService } from '@/services/global/globalMachine'\n\nimport { saveAppState } from '@/db/write/saveAppState'\n\ntype SaveServiceEvent = {\n modelName: string\n}\n\nexport const saveServiceHandler = async (event: SaveServiceEvent) => {\n const globalService = getGlobalService()\n\n if (!globalService || !globalService.getSnapshot().context) {\n return\n }\n\n const { modelName } = event\n\n const nameOfService: string = `${modelName}Service`\n\n const service = globalService.getSnapshot().context[nameOfService]\n\n if (!service) {\n return\n }\n\n await saveAppState(\n `snapshot__${modelName}`,\n JSON.stringify(service.getPersistedSnapshot()),\n )\n}\n"],"names":[],"mappings":";;;MAQa,kBAAkB,GAAG,OAAO,KAAuB,KAAI;AAClE,IAAA,MAAM,aAAa,GAAG,gBAAgB,EAAE;IAExC,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE;QAC1D;;AAGF,IAAA,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK;AAE3B,IAAA,MAAM,aAAa,GAAW,CAAG,EAAA,SAAS,SAAS;IAEnD,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC;IAElE,IAAI,CAAC,OAAO,EAAE;QACZ;;AAGF,IAAA,MAAM,YAAY,CAChB,CAAA,UAAA,EAAa,SAAS,CAAA,CAAE,EACxB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAC/C;AACH;;;;"}
|
|
@@ -16,5 +16,7 @@ export declare abstract class BaseFileManager {
|
|
|
16
16
|
static readFileAsBuffer(filePath: string): Promise<Buffer>;
|
|
17
17
|
static readFileAsString(filePath: string): Promise<string>;
|
|
18
18
|
static getFs(): Promise<any>;
|
|
19
|
+
static getParentDirPath(filePath: string): string;
|
|
20
|
+
static getFilenameFromPath(filePath: string): string;
|
|
19
21
|
}
|
|
20
22
|
//# sourceMappingURL=BaseFileManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseFileManager.d.ts","sourceRoot":"","sources":["../../../../src/helpers/FileManager/BaseFileManager.ts"],"names":[],"mappings":"AAAA,8BAAsB,eAAe;IACnC,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAQ;IAC5C,OAAO,CAAC,MAAM,CAAC,YAAY,CAAQ;IAEnC,MAAM,CAAC,aAAa,EAAE,OAAO,eAAe,CAAA;IAE5C,MAAM,CAAC,gBAAgB,CAAE,aAAa,EAAE,OAAO,eAAe;WAIjD,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAUlD,MAAM,CAAC,qBAAqB,CAAE,IAAI,EAAE,MAAM,GAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIzE,MAAM,CAAC,gBAAgB,CAAE,EACE,cAAc,EACd,WAAW,EACX,oBAAoB,GACrB,EAAE,sBAAsB,GAAI,OAAO,CAAC,IAAI,CAAC;IAInE,MAAM,CAAC,WAAW,CAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,iBAAiB,GAAI,OAAO,CAAC,IAAI,CAAC;IAInF,MAAM,CAAC,eAAe,CAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,qBAAqB,GAAI,OAAO,CAAC,IAAI,CAAC;IAIjF,MAAM,CAAC,UAAU,C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E,iBAAiB,GAAI,OAAO,CAAC,IAAI,CAAC;IAInF,MAAM,CAAC,eAAe,CAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,qBAAqB,GAAI,OAAO,CAAC,IAAI,CAAC;IAIjF,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIrD,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAI/C,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WAI/C,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;WAI/E,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAIzC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAInD,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAInD,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC;IAIlC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIjD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CAGrD"}
|
|
@@ -47,6 +47,12 @@ class BaseFileManager {
|
|
|
47
47
|
static async getFs() {
|
|
48
48
|
return this.PlatformClass.getFs();
|
|
49
49
|
}
|
|
50
|
+
static getParentDirPath(filePath) {
|
|
51
|
+
return this.PlatformClass.getParentDirPath(filePath);
|
|
52
|
+
}
|
|
53
|
+
static getFilenameFromPath(filePath) {
|
|
54
|
+
return this.PlatformClass.getFilenameFromPath(filePath);
|
|
55
|
+
}
|
|
50
56
|
}
|
|
51
57
|
BaseFileManager.fileSystemInitialized = false;
|
|
52
58
|
BaseFileManager.initializing = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseFileManager.js","sources":["../../../../../src/helpers/FileManager/BaseFileManager.ts"],"sourcesContent":["export abstract class BaseFileManager {\n private static fileSystemInitialized = false\n private static initializing = false\n\n static PlatformClass: typeof BaseFileManager\n\n static setPlatformClass( platformClass: typeof BaseFileManager ) {\n this.PlatformClass = platformClass\n }\n\n static async initializeFileSystem(): Promise<void> {\n if (this.initializing || this.fileSystemInitialized) {\n return Promise.resolve()\n }\n this.initializing = true\n await this.PlatformClass.initializeFileSystem()\n this.fileSystemInitialized = true\n this.initializing = false\n }\n\n static getContentUrlFromPath( path: string ): Promise<string | undefined> {\n return this.PlatformClass.getContentUrlFromPath(path)\n }\n\n static downloadAllFiles( {\n transactionIds,\n arweaveHost,\n excludedTransactions,\n }: DownloadAllFilesParams ): Promise<void> {\n return this.PlatformClass.downloadAllFiles({ transactionIds, arweaveHost, excludedTransactions })\n }\n\n static resizeImage( { filePath, width, height }: ResizeImageParams ): Promise<void> {\n return this.PlatformClass.resizeImage({ filePath, width, height })\n }\n\n static resizeAllImages( { width, height }: ResizeAllImagesParams ): Promise<void> {\n return this.PlatformClass.resizeAllImages({ width, height })\n }\n\n static pathExists(filePath: string): Promise<boolean> {\n return this.PlatformClass.pathExists(filePath)\n }\n\n static createDirIfNotExists(filePath: string): Promise<void> {\n return this.PlatformClass.createDirIfNotExists(filePath)\n }\n\n static async waitForFile(filePath: string): Promise<boolean> {\n return this.PlatformClass.waitForFile(filePath)\n }\n\n static async saveFile(filePath: string, content: string | Blob | ArrayBuffer): Promise<void> {\n return this.PlatformClass.saveFile(filePath, content)\n }\n\n static async readFile(filePath: string): Promise<File> {\n return this.PlatformClass.readFile(filePath)\n }\n\n static async readFileAsBuffer(filePath: string): Promise<Buffer> {\n return this.PlatformClass.readFileAsBuffer(filePath)\n }\n\n static async readFileAsString(filePath: string): Promise<string> {\n return this.PlatformClass.readFileAsString(filePath)\n }\n\n static async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AoB,CAAC,QAAgB,EAAA;QAC1C,OAAO,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,QAAQ,CAAC;;AAG1D,IAAA,aAAa,WAAW,CAAC,QAAgB,EAAA;QACvC,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC;;AAGjD,IAAA,aAAa,QAAQ,CAAC,QAAgB,EAAE,OAAoC,EAAA;QAC1E,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;;AAGvD,IAAA,aAAa,QAAQ,CAAC,QAAgB,EAAA;QACpC,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC;;AAG9C,IAAA,aAAa,gBAAgB,CAAC,QAAgB,EAAA;QAC5C,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,CAAC;;AAGtD,IAAA,aAAa,gBAAgB,CAAC,QAAgB,EAAA;QAC5C,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,CAAC;;IAGtD,aAAa,KAAK,GAAA;AAChB,QAAA,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE;;;
|
|
1
|
+
{"version":3,"file":"BaseFileManager.js","sources":["../../../../../src/helpers/FileManager/BaseFileManager.ts"],"sourcesContent":["export abstract class BaseFileManager {\n private static fileSystemInitialized = false\n private static initializing = false\n\n static PlatformClass: typeof BaseFileManager\n\n static setPlatformClass( platformClass: typeof BaseFileManager ) {\n this.PlatformClass = platformClass\n }\n\n static async initializeFileSystem(): Promise<void> {\n if (this.initializing || this.fileSystemInitialized) {\n return Promise.resolve()\n }\n this.initializing = true\n await this.PlatformClass.initializeFileSystem()\n this.fileSystemInitialized = true\n this.initializing = false\n }\n\n static getContentUrlFromPath( path: string ): Promise<string | undefined> {\n return this.PlatformClass.getContentUrlFromPath(path)\n }\n\n static downloadAllFiles( {\n transactionIds,\n arweaveHost,\n excludedTransactions,\n }: DownloadAllFilesParams ): Promise<void> {\n return this.PlatformClass.downloadAllFiles({ transactionIds, arweaveHost, excludedTransactions })\n }\n\n static resizeImage( { filePath, width, height }: ResizeImageParams ): Promise<void> {\n return this.PlatformClass.resizeImage({ filePath, width, height })\n }\n\n static resizeAllImages( { width, height }: ResizeAllImagesParams ): Promise<void> {\n return this.PlatformClass.resizeAllImages({ width, height })\n }\n\n static pathExists(filePath: string): Promise<boolean> {\n return this.PlatformClass.pathExists(filePath)\n }\n\n static createDirIfNotExists(filePath: string): Promise<void> {\n return this.PlatformClass.createDirIfNotExists(filePath)\n }\n\n static async waitForFile(filePath: string): Promise<boolean> {\n return this.PlatformClass.waitForFile(filePath)\n }\n\n static async saveFile(filePath: string, content: string | Blob | ArrayBuffer): Promise<void> {\n return this.PlatformClass.saveFile(filePath, content)\n }\n\n static async readFile(filePath: string): Promise<File> {\n return this.PlatformClass.readFile(filePath)\n }\n\n static async readFileAsBuffer(filePath: string): Promise<Buffer> {\n return this.PlatformClass.readFileAsBuffer(filePath)\n }\n\n static async readFileAsString(filePath: string): Promise<string> {\n return this.PlatformClass.readFileAsString(filePath)\n }\n\n static async getFs(): Promise<any> {\n return this.PlatformClass.getFs()\n }\n\n static getParentDirPath(filePath: string): string {\n return this.PlatformClass.getParentDirPath(filePath)\n }\n\n static getFilenameFromPath(filePath: string): string {\n return this.PlatformClass.getFilenameFromPath(filePath)\n }\n}\n"],"names":[],"mappings":"MAAsB,eAAe,CAAA;IAMnC,OAAO,gBAAgB,CAAE,aAAqC,EAAA;AAC5D,QAAA,IAAI,CAAC,aAAa,GAAG,aAAa;;IAGpC,aAAa,oBAAoB,GAAA;QAC/B,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,qBAAqB,EAAE;AACnD,YAAA,OAAO,OAAO,CAAC,OAAO,EAAE;;AAE1B,QAAA,IAAI,CAAC,YAAY,GAAG,IAAI;AACxB,QAAA,MAAM,IAAI,CAAC,aAAa,CAAC,oBAAoB,EAAE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CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC;;AAG9C,IAAA,aAAa,gBAAgB,CAAC,QAAgB,EAAA;QAC5C,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,CAAC;;AAGtD,IAAA,aAAa,gBAAgB,CAAC,QAAgB,EAAA;QAC5C,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,CAAC;;IAGtD,aAAa,KAAK,GAAA;AAChB,QAAA,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE;;IAGnC,OAAO,gBAAgB,CAAC,QAAgB,EAAA;QACtC,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,CAAC;;IAGtD,OAAO,mBAAmB,CAAC,QAAgB,EAAA;QACzC,OAAO,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,QAAQ,CAAC;;;AA5E1C,eAAqB,CAAA,qBAAA,GAAG,KAAK;AAC7B,eAAY,CAAA,YAAA,GAAG,KAAK;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const isBrowser = () => {
|
|
2
|
-
return !isElectron() && typeof
|
|
2
|
+
return !isElectron() && typeof document !== 'undefined' && typeof window !== 'undefined';
|
|
3
3
|
};
|
|
4
4
|
const isReactNative = () => {
|
|
5
5
|
return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.js","sources":["../../../../src/helpers/environment.ts"],"sourcesContent":["export const isNode = (): boolean => {\n return (\n typeof process !== 'undefined' &&\n process.versions != null &&\n process.versions.node != null\n )\n}\n\nexport const isBrowser = (): boolean => {\n return !isElectron() && typeof
|
|
1
|
+
{"version":3,"file":"environment.js","sources":["../../../../src/helpers/environment.ts"],"sourcesContent":["export const isNode = (): boolean => {\n return (\n typeof process !== 'undefined' &&\n process.versions != null &&\n process.versions.node != null\n )\n}\n\nexport const isBrowser = (): boolean => {\n return !isElectron() && typeof document !== 'undefined' && typeof window !== 'undefined'\n}\n\nexport const isReactNative = (): boolean => {\n return typeof navigator !== 'undefined' && navigator.product === 'ReactNative'\n}\n\nexport const isElectron = (): boolean => {\n return typeof process !== 'undefined' && process.versions != null && process.versions.electron != null;\n}\n\nexport const getEnvironment = (): string => {\n if (isBrowser()) {\n return 'browser'\n }\n\n if (isElectron()) {\n return 'electron'\n }\n\n if (isReactNative()) {\n return 'react-native'\n }\n\n return 'node'\n}\n"],"names":[],"mappings":"AAQO,MAAM,SAAS,GAAG,MAAc;AACrC,IAAA,OAAO,CAAC,UAAU,EAAE,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,OAAO,MAAM,KAAK,WAAW;AAC1F;AAEO,MAAM,aAAa,GAAG,MAAc;IACzC,OAAO,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,CAAC,OAAO,KAAK,aAAa;AAChF;AAEO,MAAM,UAAU,GAAG,MAAc;AACtC,IAAA,OAAO,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,IAAI,IAAI;AACxG;AAEO,MAAM,cAAc,GAAG,MAAa;IACzC,IAAI,SAAS,EAAE,EAAE;AACf,QAAA,OAAO,SAAS;;IAGlB,IAAI,UAAU,EAAE,EAAE;AAChB,QAAA,OAAO,UAAU;;IAGnB,IAAI,aAAa,EAAE,EAAE;AACnB,QAAA,OAAO,cAAc;;AAGvB,IAAA,OAAO,MAAM;AACf;;;;"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
export { Model, Property, Image, List, Text, Json, Relation, Boolean, Number, Date, } from './schema';
|
|
2
2
|
export { Item } from './Item';
|
|
3
|
-
export {
|
|
3
|
+
export { ItemProperty } from './ItemProperty';
|
|
4
|
+
export { useItems, useItem, useItemProperties, useCreateItem, useItemProperty, useDeleteItem, useGlobalServiceStatus, usePublishItem, usePersistedSnapshots, useServices, useService, useModels, } from './browser/react';
|
|
5
|
+
export { FileManager as FileManagerBrowser } from './browser/helpers/FileManager';
|
|
6
|
+
export { Db as DbBrowser } from './browser/db/Db';
|
|
7
|
+
export { models, versions, seeds, metadata, } from './seedSchema';
|
|
8
|
+
export { getModels, getModel, getModelNames, } from './stores/modelClass';
|
|
4
9
|
export { getCorrectId, } from './helpers';
|
|
5
10
|
export { eventEmitter, } from './eventBus';
|
|
6
11
|
export { withSeed } from './node/webpack';
|
|
12
|
+
export type { PublishUpload } from './db/read/getPublishUploads';
|
|
7
13
|
export { client } from './client';
|
|
14
|
+
export * from './types';
|
|
8
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,EACL,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,IAAI,GACL,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,EACL,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,IAAI,GACL,MAAM,UAAU,CAAA;AAEjB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EACL,QAAQ,EACR,OAAO,EACP,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,UAAU,EACV,SAAS,GACV,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAC,WAAW,IAAI,kBAAkB,EAAC,MAAM,+BAA+B,CAAA;AAC/E,OAAO,EAAC,EAAE,IAAI,SAAS,EAAC,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,MAAM,cAAc,CAAA;AAEhE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,aAAa,GAAE,MAAM,qBAAqB,CAAA;AAEvE,OAAO,EAAE,YAAY,GAAG,MAAM,WAAW,CAAA;AAEzC,OAAO,EACL,YAAY,GACb,MAAM,YAAY,CAAA;AAInB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAGhE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,cAAc,SAAS,CAAA"}
|
|
@@ -9,6 +9,8 @@ declare class FileManager extends BaseFileManager {
|
|
|
9
9
|
static createDirIfNotExists(filePath: string): Promise<void>;
|
|
10
10
|
static readFileAsBuffer(filePath: string): Promise<Buffer>;
|
|
11
11
|
static readFile(filePath: string): Promise<File>;
|
|
12
|
+
static getParentDirPath(filePath: string): string;
|
|
13
|
+
static getFilenameFromPath(filePath: string): string;
|
|
12
14
|
}
|
|
13
15
|
export { FileManager };
|
|
14
16
|
//# sourceMappingURL=FileManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileManager.d.ts","sourceRoot":"","sources":["../../../../src/node/helpers/FileManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAA;
|
|
1
|
+
{"version":3,"file":"FileManager.d.ts","sourceRoot":"","sources":["../../../../src/node/helpers/FileManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAA;AAGvE,cAAM,WAAY,SAAQ,eAAe;WAE1B,qBAAqB,CAAE,IAAI,EAAE,MAAM,GAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;WAMlE,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;WAIrC,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;WAMjC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;WAM5B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;WAMhC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WAM9C,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAMrD,gBAAgB,CAAE,QAAQ,EAAE,MAAM,GAAI,OAAO,CAAC,MAAM,CAAC;WAIrD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIjD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CAIrD;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/node/helpers/index.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,WAAW,GAAU,CAAC,YAAY,MAAM,KAAG,OAAO,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/node/helpers/index.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,WAAW,GAAU,CAAC,YAAY,MAAM,KAAG,OAAO,CAAC,CAAC,CA6BhE,CAAA;AAED,eAAO,MAAM,wBAAwB,QAC9B,MAAM,aACA,MAAM,kBAoBlB,CAAA"}
|
|
@@ -13,7 +13,6 @@ const getTsImport = async (filePath) => {
|
|
|
13
13
|
logger(`Typescript file not found at ${filePath}`);
|
|
14
14
|
throw new Error(`Typescript file not found at ${filePath}`);
|
|
15
15
|
}
|
|
16
|
-
console.log('filePath', filePath);
|
|
17
16
|
let result;
|
|
18
17
|
try {
|
|
19
18
|
result = await tsImport.load(filePath, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/node/helpers/index.ts"],"sourcesContent":["import fs from 'fs'\nimport * as tsImport from 'ts-import'\nimport { LoadMode } from 'ts-import'\nimport path from 'path'\nimport { glob } from 'glob'\nimport { rimraf } from 'rimraf'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:helpers')\n\nexport const getTsImport = async <T>(filePath: string): Promise<T> => {\n // Check if the config file exists\n if (!fs.existsSync(filePath)) {\n logger(`Typescript file not found at ${filePath}`)\n throw new Error(`Typescript file not found at ${filePath}`)\n }\n\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/node/helpers/index.ts"],"sourcesContent":["import fs from 'fs'\nimport * as tsImport from 'ts-import'\nimport { LoadMode } from 'ts-import'\nimport path from 'path'\nimport { glob } from 'glob'\nimport { rimraf } from 'rimraf'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:helpers')\n\nexport const getTsImport = async <T>(filePath: string): Promise<T> => {\n // Check if the config file exists\n if (!fs.existsSync(filePath)) {\n logger(`Typescript file not found at ${filePath}`)\n throw new Error(`Typescript file not found at ${filePath}`)\n }\n\n let result\n\n try {\n result = await tsImport.load(filePath, {\n mode: LoadMode.Compile,\n compileOptions: {\n compilerOptions: {\n experimentalDecorators: true,\n emitDecoratorMetadata: true,\n },\n },\n }).catch((e) => {\n logger('Error loading ts file:', e)\n throw e\n })\n\n } catch ( e ) {\n console.error(e)\n }\n\n\n return result\n}\n\nexport const deleteFilesWithExtension = async (\n dir: string,\n extension: string,\n) => {\n const pattern = path.join(dir, `**/*${extension}`)\n glob(pattern, (err, files) => {\n if (err) {\n logger('Error finding files:', err)\n return\n }\n\n for (const file of files) {\n // TODO: Change this whole thing to be async?\n rimraf(file, (err) => {\n if (err) {\n logger('Error deleting file:', err)\n } else {\n logger(`Deleted: ${file}`)\n }\n })\n }\n })\n}\n"],"names":[],"mappings":";;;;;;;;AAQA,MAAM,MAAM,GAAG,KAAK,CAAC,iBAAiB,CAAC;MAE1B,WAAW,GAAG,OAAU,QAAgB,KAAgB;;IAEnE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;AAC5B,QAAA,MAAM,CAAC,CAAA,6BAAA,EAAgC,QAAQ,CAAA,CAAE,CAAC;AAClD,QAAA,MAAM,IAAI,KAAK,CAAC,gCAAgC,QAAQ,CAAA,CAAE,CAAC;;AAG7D,IAAA,IAAI,MAAM;AAEV,IAAA,IAAI;AACF,QAAA,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE;YACrC,IAAI,EAAE,QAAQ,CAAC,OAAO;AACtB,YAAA,cAAc,EAAE;AACd,gBAAA,eAAe,EAAE;AACf,oBAAA,sBAAsB,EAAE,IAAI;AAC5B,oBAAA,qBAAqB,EAAE,IAAI;AAC5B,iBAAA;AACF,aAAA;AACF,SAAA,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAI;AACb,YAAA,MAAM,CAAC,wBAAwB,EAAE,CAAC,CAAC;AACnC,YAAA,MAAM,CAAC;AACT,SAAC,CAAC;;IAEF,OAAQ,CAAC,EAAG;AACZ,QAAA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;;AAIlB,IAAA,OAAO,MAAM;AACf;;;;"}
|
|
@@ -30,7 +30,7 @@ const migrate = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
30
30
|
}
|
|
31
31
|
})
|
|
32
32
|
.then(() => {
|
|
33
|
-
|
|
33
|
+
logger('sending db migrating success');
|
|
34
34
|
sendBack({ type: DB_MIGRATING_SUCCESS, dbName });
|
|
35
35
|
});
|
|
36
36
|
return () => { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.js","sources":["../../../../../../src/services/db/actors/migrate.ts"],"sourcesContent":["import { EventObject, fromCallback } from 'xstate'\nimport { DbServiceContext, FromCallbackInput, SqliteWasmResult } from '@/types'\nimport {\n BROWSER_FS_TOP_DIR,\n DB_MIGRATING_SUCCESS,\n} from '@/services/internal/constants'\nimport debug from 'debug'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { isBrowser } from '@/helpers/environment'\nimport { BaseFileManager } from '@/helpers/FileManager/BaseFileManager'\n\nconst logger = debug('seedSdk:services:db:actors:migrate')\n\n\n\nexport const migrate = fromCallback<\n EventObject,\n FromCallbackInput<DbServiceContext>\n>(({ sendBack, input: { context } }) => {\n const { pathToDbDir, dbId, dbName } = context\n\n logger('[db/actors] migrate context', context)\n\n let journalExists = false\n\n\n const _checkForFiles = async (): Promise<void> => {\n const journalPath = `/${pathToDbDir}/meta/_journal.json`\n\n journalExists = await BaseFileManager.pathExists(journalPath)\n\n if (!journalExists && isBrowser()) {\n await BaseFileManager.waitForFile(journalPath, 500, 60000)\n }\n }\n\n const _migrate = async (): Promise<void> => {\n await BaseDb.migrate(pathToDbDir, dbName, dbId)\n }\n\n _checkForFiles()\n .then(() => {\n if (!isBrowser()) {\n return _migrate()\n }\n if (journalExists) {\n return _migrate()\n }\n })\n .then(() => {\n
|
|
1
|
+
{"version":3,"file":"migrate.js","sources":["../../../../../../src/services/db/actors/migrate.ts"],"sourcesContent":["import { EventObject, fromCallback } from 'xstate'\nimport { DbServiceContext, FromCallbackInput, SqliteWasmResult } from '@/types'\nimport {\n BROWSER_FS_TOP_DIR,\n DB_MIGRATING_SUCCESS,\n} from '@/services/internal/constants'\nimport debug from 'debug'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { isBrowser } from '@/helpers/environment'\nimport { BaseFileManager } from '@/helpers/FileManager/BaseFileManager'\n\nconst logger = debug('seedSdk:services:db:actors:migrate')\n\n\n\nexport const migrate = fromCallback<\n EventObject,\n FromCallbackInput<DbServiceContext>\n>(({ sendBack, input: { context } }) => {\n const { pathToDbDir, dbId, dbName } = context\n\n logger('[db/actors] migrate context', context)\n\n let journalExists = false\n\n\n const _checkForFiles = async (): Promise<void> => {\n const journalPath = `/${pathToDbDir}/meta/_journal.json`\n\n journalExists = await BaseFileManager.pathExists(journalPath)\n\n if (!journalExists && isBrowser()) {\n await BaseFileManager.waitForFile(journalPath, 500, 60000)\n }\n }\n\n const _migrate = async (): Promise<void> => {\n await BaseDb.migrate(pathToDbDir, dbName, dbId)\n }\n\n _checkForFiles()\n .then(() => {\n if (!isBrowser()) {\n return _migrate()\n }\n if (journalExists) {\n return _migrate()\n }\n })\n .then(() => {\n logger('sending db migrating success')\n sendBack({ type: DB_MIGRATING_SUCCESS, dbName })\n })\n\n return () => { }\n})\n"],"names":[],"mappings":";;;;;;;AAWA,MAAM,MAAM,GAAG,KAAK,CAAC,oCAAoC,CAAC;AAI7C,MAAA,OAAO,GAAG,YAAY,CAGjC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,KAAI;IACrC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO;AAE7C,IAAA,MAAM,CAAC,6BAA6B,EAAE,OAAO,CAAC;IAE9C,IAAI,aAAa,GAAG,KAAK;AAGzB,IAAA,MAAM,cAAc,GAAG,YAA0B;AAC/C,QAAA,MAAM,WAAW,GAAG,CAAI,CAAA,EAAA,WAAW,qBAAqB;QAExD,aAAa,GAAG,MAAM,eAAe,CAAC,UAAU,CAAC,WAAW,CAAC;AAE7D,QAAA,IAAI,CAAC,aAAa,IAAI,SAAS,EAAE,EAAE;YACjC,MAAM,eAAe,CAAC,WAAW,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,CAAC;;AAE9D,KAAC;AAED,IAAA,MAAM,QAAQ,GAAG,YAA0B;QACzC,MAAM,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC;AACjD,KAAC;AAED,IAAA,cAAc;SACX,IAAI,CAAC,MAAK;AACT,QAAA,IAAI,CAAC,SAAS,EAAE,EAAE;YAChB,OAAO,QAAQ,EAAE;;QAEnB,IAAI,aAAa,EAAE;YACjB,OAAO,QAAQ,EAAE;;AAErB,KAAC;SACA,IAAI,CAAC,MAAK;QACT,MAAM,CAAC,8BAA8B,CAAC;QACtC,QAAQ,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,EAAE,CAAC;AAClD,KAAC,CAAC;AAEJ,IAAA,OAAO,MAAQ,GAAC;AAClB,CAAC;;;;"}
|
|
@@ -12,7 +12,7 @@ const createDirectories = async (dirPath) => {
|
|
|
12
12
|
if (dirPathExists) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
const parentDir =
|
|
15
|
+
const parentDir = BaseFileManager.getParentDirPath(dirPath);
|
|
16
16
|
let parentDirExists = await BaseFileManager.pathExists(parentDir);
|
|
17
17
|
if (!parentDirExists) {
|
|
18
18
|
await createDirectories(parentDir);
|
|
@@ -37,9 +37,9 @@ class FileDownloadManager {
|
|
|
37
37
|
console.error(`No file data from ${url}`);
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
const localDirPath =
|
|
40
|
+
const localDirPath = BaseFileManager.getParentDirPath(localFilePath);
|
|
41
41
|
await createDirectories(localDirPath);
|
|
42
|
-
const filename =
|
|
42
|
+
const filename = BaseFileManager.getFilenameFromPath(localFilePath);
|
|
43
43
|
const regex = /(\d+)[\w_]+\.(sql|json)$/;
|
|
44
44
|
const match = filename.match(regex);
|
|
45
45
|
let migrationNumber;
|