fixed some type errors
Some checks failed
Publish Alpha Package to npm / publish (push) Has been cancelled
Some checks failed
Publish Alpha Package to npm / publish (push) Has been cancelled
This commit is contained in:
parent
dd920d26ce
commit
be3763d988
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@debros/network",
|
"name": "@debros/network",
|
||||||
"version": "0.0.21-alpha",
|
"version": "0.0.22-alpha",
|
||||||
"description": "Debros network core functionality for IPFS, libp2p and OrbitDB",
|
"description": "Debros network core functionality for IPFS, libp2p and OrbitDB",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
66
pnpm-lock.yaml
generated
66
pnpm-lock.yaml
generated
@ -1276,8 +1276,8 @@ packages:
|
|||||||
'@types/babel__core@7.20.5':
|
'@types/babel__core@7.20.5':
|
||||||
resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==}
|
resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==}
|
||||||
|
|
||||||
'@types/babel__generator@7.6.8':
|
'@types/babel__generator@7.27.0':
|
||||||
resolution: {integrity: sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==}
|
resolution: {integrity: sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==}
|
||||||
|
|
||||||
'@types/babel__template@7.4.4':
|
'@types/babel__template@7.4.4':
|
||||||
resolution: {integrity: sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==}
|
resolution: {integrity: sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==}
|
||||||
@ -1333,6 +1333,9 @@ packages:
|
|||||||
'@types/node@22.13.16':
|
'@types/node@22.13.16':
|
||||||
resolution: {integrity: sha512-15tM+qA4Ypml/N7kyRdvfRjBQT2RL461uF1Bldn06K0Nzn1lY3nAPgHlsVrJxdZ9WhZiW0Fmc1lOYMtDsAuB3w==}
|
resolution: {integrity: sha512-15tM+qA4Ypml/N7kyRdvfRjBQT2RL461uF1Bldn06K0Nzn1lY3nAPgHlsVrJxdZ9WhZiW0Fmc1lOYMtDsAuB3w==}
|
||||||
|
|
||||||
|
'@types/node@22.14.0':
|
||||||
|
resolution: {integrity: sha512-Kmpl+z84ILoG+3T/zQFyAJsU6EPTmOCj8/2+83fSN6djd6I4o7uOuGIH6vq3PrjY5BGitSbFuMN18j3iknubbA==}
|
||||||
|
|
||||||
'@types/qs@6.9.18':
|
'@types/qs@6.9.18':
|
||||||
resolution: {integrity: sha512-kK7dgTYDyGqS+e2Q4aK9X3D7q234CIZ1Bv0q/7Z5IwRDoADNU81xXJK/YVyLbLTZCoIwUoDoffFeF+p/eIklAA==}
|
resolution: {integrity: sha512-kK7dgTYDyGqS+e2Q4aK9X3D7q234CIZ1Bv0q/7Z5IwRDoADNU81xXJK/YVyLbLTZCoIwUoDoffFeF+p/eIklAA==}
|
||||||
|
|
||||||
@ -1657,8 +1660,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==}
|
resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
|
||||||
caniuse-lite@1.0.30001707:
|
caniuse-lite@1.0.30001712:
|
||||||
resolution: {integrity: sha512-3qtRjw/HQSMlDWf+X79N206fepf4SOOU6SQLMaq/0KkZLmSjPxAkBOQQ+FxbHKfHmYLZFfdWsO3KA90ceHPSnw==}
|
resolution: {integrity: sha512-MBqPpGYYdQ7/hfKiet9SCI+nmN5/hp4ZzveOJubl5DTAMa5oggjAuoi0Z4onBpKPFI2ePGnQuQIzF3VxDjDJig==}
|
||||||
|
|
||||||
catering@2.1.1:
|
catering@2.1.1:
|
||||||
resolution: {integrity: sha512-K7Qy8O9p76sL3/3m7/zLKbRkyOlSZAgzEaLhyj2mXS8PsCud2Eo4hAb8aLtZqHh0QGqLcb9dlJSu6lHRVENm1w==}
|
resolution: {integrity: sha512-K7Qy8O9p76sL3/3m7/zLKbRkyOlSZAgzEaLhyj2mXS8PsCud2Eo4hAb8aLtZqHh0QGqLcb9dlJSu6lHRVENm1w==}
|
||||||
@ -1890,8 +1893,8 @@ packages:
|
|||||||
ee-first@1.1.1:
|
ee-first@1.1.1:
|
||||||
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
|
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
|
||||||
|
|
||||||
electron-to-chromium@1.5.129:
|
electron-to-chromium@1.5.134:
|
||||||
resolution: {integrity: sha512-JlXUemX4s0+9f8mLqib/bHH8gOHf5elKS6KeWG3sk3xozb/JTq/RLXIv8OKUWiK4Ah00Wm88EFj5PYkFr4RUPA==}
|
resolution: {integrity: sha512-zSwzrLg3jNP3bwsLqWHmS5z2nIOQ5ngMnfMZOWWtXnqqQkPVyOipxK98w+1beLw1TB+EImPNcG8wVP/cLVs2Og==}
|
||||||
|
|
||||||
emoji-regex@10.4.0:
|
emoji-regex@10.4.0:
|
||||||
resolution: {integrity: sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==}
|
resolution: {integrity: sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==}
|
||||||
@ -2330,8 +2333,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==}
|
resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==}
|
||||||
engines: {node: '>= 4'}
|
engines: {node: '>= 4'}
|
||||||
|
|
||||||
image-size@1.2.0:
|
image-size@1.2.1:
|
||||||
resolution: {integrity: sha512-4S8fwbO6w3GeCVN6OPtA9I5IGKkcDMPcKndtUlpJuCwu7JLjtj7JZpwqLuyY2nrmQT3AWsCJLSKPsc2mPBSl3w==}
|
resolution: {integrity: sha512-rH+46sQJ2dlwfjfhCyNx5thzrv+dtmBIhPHk0zgRUukHzZ/kRueTJXoYYsclBaKcSMBWuGbOFXtioLpzTb5euw==}
|
||||||
engines: {node: '>=16.x'}
|
engines: {node: '>=16.x'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
@ -3778,6 +3781,9 @@ packages:
|
|||||||
undici-types@6.20.0:
|
undici-types@6.20.0:
|
||||||
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
|
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
|
||||||
|
|
||||||
|
undici-types@6.21.0:
|
||||||
|
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
|
||||||
|
|
||||||
undici@6.21.2:
|
undici@6.21.2:
|
||||||
resolution: {integrity: sha512-uROZWze0R0itiAKVPsYhFov9LxrPMHLMEQFszeI2gCN6bnIIZ8twzBCJcN2LJrBBLfrP0t1FW0g+JmKVl8Vk1g==}
|
resolution: {integrity: sha512-uROZWze0R0itiAKVPsYhFov9LxrPMHLMEQFszeI2gCN6bnIIZ8twzBCJcN2LJrBBLfrP0t1FW0g+JmKVl8Vk1g==}
|
||||||
engines: {node: '>=18.17'}
|
engines: {node: '>=18.17'}
|
||||||
@ -5143,14 +5149,14 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@jest/fake-timers': 29.7.0
|
'@jest/fake-timers': 29.7.0
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 22.13.16
|
'@types/node': 22.14.0
|
||||||
jest-mock: 29.7.0
|
jest-mock: 29.7.0
|
||||||
|
|
||||||
'@jest/fake-timers@29.7.0':
|
'@jest/fake-timers@29.7.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@sinonjs/fake-timers': 10.3.0
|
'@sinonjs/fake-timers': 10.3.0
|
||||||
'@types/node': 22.13.16
|
'@types/node': 22.14.0
|
||||||
jest-message-util: 29.7.0
|
jest-message-util: 29.7.0
|
||||||
jest-mock: 29.7.0
|
jest-mock: 29.7.0
|
||||||
jest-util: 29.7.0
|
jest-util: 29.7.0
|
||||||
@ -5184,7 +5190,7 @@ snapshots:
|
|||||||
'@jest/schemas': 29.6.3
|
'@jest/schemas': 29.6.3
|
||||||
'@types/istanbul-lib-coverage': 2.0.6
|
'@types/istanbul-lib-coverage': 2.0.6
|
||||||
'@types/istanbul-reports': 3.0.4
|
'@types/istanbul-reports': 3.0.4
|
||||||
'@types/node': 22.13.16
|
'@types/node': 22.14.0
|
||||||
'@types/yargs': 17.0.33
|
'@types/yargs': 17.0.33
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
|
|
||||||
@ -5964,11 +5970,11 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@babel/parser': 7.27.0
|
'@babel/parser': 7.27.0
|
||||||
'@babel/types': 7.27.0
|
'@babel/types': 7.27.0
|
||||||
'@types/babel__generator': 7.6.8
|
'@types/babel__generator': 7.27.0
|
||||||
'@types/babel__template': 7.4.4
|
'@types/babel__template': 7.4.4
|
||||||
'@types/babel__traverse': 7.20.7
|
'@types/babel__traverse': 7.20.7
|
||||||
|
|
||||||
'@types/babel__generator@7.6.8':
|
'@types/babel__generator@7.27.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/types': 7.27.0
|
'@babel/types': 7.27.0
|
||||||
|
|
||||||
@ -6011,7 +6017,7 @@ snapshots:
|
|||||||
|
|
||||||
'@types/graceful-fs@4.1.9':
|
'@types/graceful-fs@4.1.9':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 22.13.16
|
'@types/node': 22.14.0
|
||||||
|
|
||||||
'@types/http-errors@2.0.4': {}
|
'@types/http-errors@2.0.4': {}
|
||||||
|
|
||||||
@ -6042,6 +6048,10 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
undici-types: 6.20.0
|
undici-types: 6.20.0
|
||||||
|
|
||||||
|
'@types/node@22.14.0':
|
||||||
|
dependencies:
|
||||||
|
undici-types: 6.21.0
|
||||||
|
|
||||||
'@types/qs@6.9.18': {}
|
'@types/qs@6.9.18': {}
|
||||||
|
|
||||||
'@types/range-parser@1.2.7': {}
|
'@types/range-parser@1.2.7': {}
|
||||||
@ -6428,8 +6438,8 @@ snapshots:
|
|||||||
|
|
||||||
browserslist@4.24.4:
|
browserslist@4.24.4:
|
||||||
dependencies:
|
dependencies:
|
||||||
caniuse-lite: 1.0.30001707
|
caniuse-lite: 1.0.30001712
|
||||||
electron-to-chromium: 1.5.129
|
electron-to-chromium: 1.5.134
|
||||||
node-releases: 2.0.19
|
node-releases: 2.0.19
|
||||||
update-browserslist-db: 1.1.3(browserslist@4.24.4)
|
update-browserslist-db: 1.1.3(browserslist@4.24.4)
|
||||||
|
|
||||||
@ -6477,7 +6487,7 @@ snapshots:
|
|||||||
|
|
||||||
camelcase@6.3.0: {}
|
camelcase@6.3.0: {}
|
||||||
|
|
||||||
caniuse-lite@1.0.30001707: {}
|
caniuse-lite@1.0.30001712: {}
|
||||||
|
|
||||||
catering@2.1.1: {}
|
catering@2.1.1: {}
|
||||||
|
|
||||||
@ -6494,7 +6504,7 @@ snapshots:
|
|||||||
|
|
||||||
chrome-launcher@0.15.2:
|
chrome-launcher@0.15.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 22.13.16
|
'@types/node': 22.14.0
|
||||||
escape-string-regexp: 4.0.0
|
escape-string-regexp: 4.0.0
|
||||||
is-wsl: 2.2.0
|
is-wsl: 2.2.0
|
||||||
lighthouse-logger: 1.4.2
|
lighthouse-logger: 1.4.2
|
||||||
@ -6503,7 +6513,7 @@ snapshots:
|
|||||||
|
|
||||||
chromium-edge-launcher@0.2.0:
|
chromium-edge-launcher@0.2.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 22.13.16
|
'@types/node': 22.14.0
|
||||||
escape-string-regexp: 4.0.0
|
escape-string-regexp: 4.0.0
|
||||||
is-wsl: 2.2.0
|
is-wsl: 2.2.0
|
||||||
lighthouse-logger: 1.4.2
|
lighthouse-logger: 1.4.2
|
||||||
@ -6698,7 +6708,7 @@ snapshots:
|
|||||||
|
|
||||||
ee-first@1.1.1: {}
|
ee-first@1.1.1: {}
|
||||||
|
|
||||||
electron-to-chromium@1.5.129: {}
|
electron-to-chromium@1.5.134: {}
|
||||||
|
|
||||||
emoji-regex@10.4.0: {}
|
emoji-regex@10.4.0: {}
|
||||||
|
|
||||||
@ -7187,7 +7197,7 @@ snapshots:
|
|||||||
|
|
||||||
ignore@5.3.2: {}
|
ignore@5.3.2: {}
|
||||||
|
|
||||||
image-size@1.2.0:
|
image-size@1.2.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
queue: 6.0.2
|
queue: 6.0.2
|
||||||
|
|
||||||
@ -7507,7 +7517,7 @@ snapshots:
|
|||||||
'@jest/environment': 29.7.0
|
'@jest/environment': 29.7.0
|
||||||
'@jest/fake-timers': 29.7.0
|
'@jest/fake-timers': 29.7.0
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 22.13.16
|
'@types/node': 22.14.0
|
||||||
jest-mock: 29.7.0
|
jest-mock: 29.7.0
|
||||||
jest-util: 29.7.0
|
jest-util: 29.7.0
|
||||||
|
|
||||||
@ -7517,7 +7527,7 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/graceful-fs': 4.1.9
|
'@types/graceful-fs': 4.1.9
|
||||||
'@types/node': 22.13.16
|
'@types/node': 22.14.0
|
||||||
anymatch: 3.1.3
|
anymatch: 3.1.3
|
||||||
fb-watchman: 2.0.2
|
fb-watchman: 2.0.2
|
||||||
graceful-fs: 4.2.11
|
graceful-fs: 4.2.11
|
||||||
@ -7544,7 +7554,7 @@ snapshots:
|
|||||||
jest-mock@29.7.0:
|
jest-mock@29.7.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 22.13.16
|
'@types/node': 22.14.0
|
||||||
jest-util: 29.7.0
|
jest-util: 29.7.0
|
||||||
|
|
||||||
jest-regex-util@29.6.3: {}
|
jest-regex-util@29.6.3: {}
|
||||||
@ -7552,7 +7562,7 @@ snapshots:
|
|||||||
jest-util@29.7.0:
|
jest-util@29.7.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jest/types': 29.6.3
|
'@jest/types': 29.6.3
|
||||||
'@types/node': 22.13.16
|
'@types/node': 22.14.0
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
ci-info: 3.9.0
|
ci-info: 3.9.0
|
||||||
graceful-fs: 4.2.11
|
graceful-fs: 4.2.11
|
||||||
@ -7569,7 +7579,7 @@ snapshots:
|
|||||||
|
|
||||||
jest-worker@29.7.0:
|
jest-worker@29.7.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 22.13.16
|
'@types/node': 22.14.0
|
||||||
jest-util: 29.7.0
|
jest-util: 29.7.0
|
||||||
merge-stream: 2.0.0
|
merge-stream: 2.0.0
|
||||||
supports-color: 8.1.1
|
supports-color: 8.1.1
|
||||||
@ -7944,7 +7954,7 @@ snapshots:
|
|||||||
flow-enums-runtime: 0.0.6
|
flow-enums-runtime: 0.0.6
|
||||||
graceful-fs: 4.2.11
|
graceful-fs: 4.2.11
|
||||||
hermes-parser: 0.25.1
|
hermes-parser: 0.25.1
|
||||||
image-size: 1.2.0
|
image-size: 1.2.1
|
||||||
invariant: 2.2.4
|
invariant: 2.2.4
|
||||||
jest-worker: 29.7.0
|
jest-worker: 29.7.0
|
||||||
jsc-safe-url: 0.2.4
|
jsc-safe-url: 0.2.4
|
||||||
@ -8884,6 +8894,8 @@ snapshots:
|
|||||||
|
|
||||||
undici-types@6.20.0: {}
|
undici-types@6.20.0: {}
|
||||||
|
|
||||||
|
undici-types@6.21.0: {}
|
||||||
|
|
||||||
undici@6.21.2: {}
|
undici@6.21.2: {}
|
||||||
|
|
||||||
unicode-canonical-property-names-ecmascript@2.0.1: {}
|
unicode-canonical-property-names-ecmascript@2.0.1: {}
|
||||||
|
57
src/index.ts
57
src/index.ts
@ -3,7 +3,6 @@ import { config, defaultConfig, type DebrosConfig } from './config';
|
|||||||
import { validateConfig, type ValidationResult } from './ipfs/config/configValidator';
|
import { validateConfig, type ValidationResult } from './ipfs/config/configValidator';
|
||||||
|
|
||||||
// Database service exports (new abstracted layer)
|
// Database service exports (new abstracted layer)
|
||||||
import dbService from './db/dbService';
|
|
||||||
import {
|
import {
|
||||||
init as initDB,
|
init as initDB,
|
||||||
create,
|
create,
|
||||||
@ -23,33 +22,39 @@ import {
|
|||||||
getMetrics,
|
getMetrics,
|
||||||
resetMetrics,
|
resetMetrics,
|
||||||
closeConnection,
|
closeConnection,
|
||||||
stop as stopDB
|
stop as stopDB,
|
||||||
} from './db/dbService';
|
} from './db/dbService';
|
||||||
import { ErrorCode, StoreType } from './db/types';
|
import { ErrorCode, StoreType } from './db/types';
|
||||||
|
|
||||||
// Import types
|
// Import types
|
||||||
import type {
|
import type {
|
||||||
Transaction,
|
Transaction,
|
||||||
CreateResult,
|
CreateResult,
|
||||||
UpdateResult,
|
UpdateResult,
|
||||||
PaginatedResult,
|
PaginatedResult,
|
||||||
ListOptions,
|
ListOptions,
|
||||||
QueryOptions,
|
QueryOptions,
|
||||||
FileUploadResult,
|
FileUploadResult,
|
||||||
FileResult,
|
FileResult,
|
||||||
CollectionSchema,
|
CollectionSchema,
|
||||||
SchemaDefinition,
|
SchemaDefinition,
|
||||||
Metrics
|
Metrics,
|
||||||
} from './db/types';
|
} from './db/types';
|
||||||
|
|
||||||
import { DBError } from './db/core/error';
|
import { DBError } from './db/core/error';
|
||||||
|
|
||||||
// Legacy exports (internal use only, not exposed in default export)
|
// Legacy exports (internal use only, not exposed in default export)
|
||||||
import { init as initIpfs, stop as stopIpfs, getHelia } from './ipfs/ipfsService';
|
import { getConnectedPeers, logPeersStatus } from './ipfs/ipfsService';
|
||||||
import { init as initOrbitDB, openDB } from './orbit/orbitDBService';
|
|
||||||
|
// Load balancer exports
|
||||||
|
import loadBalancerController from './ipfs/loadBalancerController';
|
||||||
|
|
||||||
// Logger exports
|
// Logger exports
|
||||||
import logger, { createServiceLogger, createDebrosLogger, type LoggerOptions } from './utils/logger';
|
import logger, {
|
||||||
|
createServiceLogger,
|
||||||
|
createDebrosLogger,
|
||||||
|
type LoggerOptions,
|
||||||
|
} from './utils/logger';
|
||||||
|
|
||||||
// Export public API
|
// Export public API
|
||||||
export {
|
export {
|
||||||
@ -59,7 +64,7 @@ export {
|
|||||||
validateConfig,
|
validateConfig,
|
||||||
type DebrosConfig,
|
type DebrosConfig,
|
||||||
type ValidationResult,
|
type ValidationResult,
|
||||||
|
|
||||||
// Database Service (Main public API)
|
// Database Service (Main public API)
|
||||||
initDB,
|
initDB,
|
||||||
create,
|
create,
|
||||||
@ -82,7 +87,12 @@ export {
|
|||||||
stopDB,
|
stopDB,
|
||||||
ErrorCode,
|
ErrorCode,
|
||||||
StoreType,
|
StoreType,
|
||||||
|
|
||||||
|
// Load Balancer
|
||||||
|
loadBalancerController,
|
||||||
|
getConnectedPeers,
|
||||||
|
logPeersStatus,
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
type Transaction,
|
type Transaction,
|
||||||
type DBError,
|
type DBError,
|
||||||
@ -96,7 +106,7 @@ export {
|
|||||||
type FileUploadResult,
|
type FileUploadResult,
|
||||||
type FileResult,
|
type FileResult,
|
||||||
type Metrics,
|
type Metrics,
|
||||||
|
|
||||||
// Logger
|
// Logger
|
||||||
logger,
|
logger,
|
||||||
createServiceLogger,
|
createServiceLogger,
|
||||||
@ -130,8 +140,11 @@ export default {
|
|||||||
closeConnection,
|
closeConnection,
|
||||||
stop: stopDB,
|
stop: stopDB,
|
||||||
ErrorCode,
|
ErrorCode,
|
||||||
StoreType
|
StoreType,
|
||||||
},
|
},
|
||||||
|
loadBalancerController,
|
||||||
|
logPeersStatus,
|
||||||
|
getConnectedPeers,
|
||||||
logger,
|
logger,
|
||||||
createServiceLogger,
|
createServiceLogger,
|
||||||
};
|
};
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
// ]
|
// ]
|
||||||
// },
|
// },
|
||||||
},
|
},
|
||||||
"include": ["src/**/*", "orbitdb.d.ts"],
|
"include": ["src/**/*", "orbitdb.d.ts", "types.d.ts"],
|
||||||
"exclude": ["coverage", "dist", "eslint.config.js", "node_modules"],
|
"exclude": ["coverage", "dist", "eslint.config.js", "node_modules"],
|
||||||
"ts-node": {
|
"ts-node": {
|
||||||
"esm": true
|
"esm": true
|
||||||
|
114
types.d.ts
vendored
114
types.d.ts
vendored
@ -2,8 +2,8 @@
|
|||||||
// Project: https://github.com/debros/anchat-relay
|
// Project: https://github.com/debros/anchat-relay
|
||||||
// Definitions by: Debros Team
|
// Definitions by: Debros Team
|
||||||
|
|
||||||
declare module "@debros/network" {
|
declare module '@debros/network' {
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from 'express';
|
||||||
|
|
||||||
// Config types
|
// Config types
|
||||||
export interface DebrosConfig {
|
export interface DebrosConfig {
|
||||||
@ -51,7 +51,7 @@ declare module "@debros/network" {
|
|||||||
DOCSTORE = 'docstore',
|
DOCSTORE = 'docstore',
|
||||||
FEED = 'feed',
|
FEED = 'feed',
|
||||||
EVENTLOG = 'eventlog',
|
EVENTLOG = 'eventlog',
|
||||||
COUNTER = 'counter'
|
COUNTER = 'counter',
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error handling
|
// Error handling
|
||||||
@ -65,7 +65,7 @@ declare module "@debros/network" {
|
|||||||
FILE_NOT_FOUND = 'ERR_FILE_NOT_FOUND',
|
FILE_NOT_FOUND = 'ERR_FILE_NOT_FOUND',
|
||||||
INVALID_PARAMETERS = 'ERR_INVALID_PARAMS',
|
INVALID_PARAMETERS = 'ERR_INVALID_PARAMS',
|
||||||
CONNECTION_ERROR = 'ERR_CONNECTION',
|
CONNECTION_ERROR = 'ERR_CONNECTION',
|
||||||
STORE_TYPE_ERROR = 'ERR_STORE_TYPE'
|
STORE_TYPE_ERROR = 'ERR_STORE_TYPE',
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DBError extends Error {
|
export class DBError extends Error {
|
||||||
@ -182,38 +182,75 @@ declare module "@debros/network" {
|
|||||||
|
|
||||||
// Database Operations
|
// Database Operations
|
||||||
export function initDB(connectionId?: string): Promise<string>;
|
export function initDB(connectionId?: string): Promise<string>;
|
||||||
export function create<T extends Record<string, any>>(collection: string, id: string, data: Omit<T, 'createdAt' | 'updatedAt'>, options?: { connectionId?: string, storeType?: StoreType }): Promise<CreateResult>;
|
export function create<T extends Record<string, any>>(
|
||||||
export function get<T extends Record<string, any>>(collection: string, id: string, options?: { connectionId?: string; skipCache?: boolean, storeType?: StoreType }): Promise<T | null>;
|
collection: string,
|
||||||
export function update<T extends Record<string, any>>(collection: string, id: string, data: Partial<Omit<T, 'createdAt' | 'updatedAt'>>, options?: { connectionId?: string; upsert?: boolean, storeType?: StoreType }): Promise<UpdateResult>;
|
id: string,
|
||||||
export function remove(collection: string, id: string, options?: { connectionId?: string, storeType?: StoreType }): Promise<boolean>;
|
data: Omit<T, 'createdAt' | 'updatedAt'>,
|
||||||
export function list<T extends Record<string, any>>(collection: string, options?: ListOptions): Promise<PaginatedResult<T>>;
|
options?: { connectionId?: string; storeType?: StoreType },
|
||||||
export function query<T extends Record<string, any>>(collection: string, filter: (doc: T) => boolean, options?: QueryOptions): Promise<PaginatedResult<T>>;
|
): Promise<CreateResult>;
|
||||||
|
export function get<T extends Record<string, any>>(
|
||||||
|
collection: string,
|
||||||
|
id: string,
|
||||||
|
options?: { connectionId?: string; skipCache?: boolean; storeType?: StoreType },
|
||||||
|
): Promise<T | null>;
|
||||||
|
export function update<T extends Record<string, any>>(
|
||||||
|
collection: string,
|
||||||
|
id: string,
|
||||||
|
data: Partial<Omit<T, 'createdAt' | 'updatedAt'>>,
|
||||||
|
options?: { connectionId?: string; upsert?: boolean; storeType?: StoreType },
|
||||||
|
): Promise<UpdateResult>;
|
||||||
|
export function remove(
|
||||||
|
collection: string,
|
||||||
|
id: string,
|
||||||
|
options?: { connectionId?: string; storeType?: StoreType },
|
||||||
|
): Promise<boolean>;
|
||||||
|
export function list<T extends Record<string, any>>(
|
||||||
|
collection: string,
|
||||||
|
options?: ListOptions,
|
||||||
|
): Promise<PaginatedResult<T>>;
|
||||||
|
export function query<T extends Record<string, any>>(
|
||||||
|
collection: string,
|
||||||
|
filter: (doc: T) => boolean,
|
||||||
|
options?: QueryOptions,
|
||||||
|
): Promise<PaginatedResult<T>>;
|
||||||
|
|
||||||
// Schema operations
|
// Schema operations
|
||||||
export function defineSchema(collection: string, schema: CollectionSchema): void;
|
export function defineSchema(collection: string, schema: CollectionSchema): void;
|
||||||
|
|
||||||
// Transaction operations
|
// Transaction operations
|
||||||
export function createTransaction(connectionId?: string): Transaction;
|
export function createTransaction(connectionId?: string): Transaction;
|
||||||
export function commitTransaction(transaction: Transaction): Promise<{ success: boolean; results: any[] }>;
|
export function commitTransaction(
|
||||||
|
transaction: Transaction,
|
||||||
|
): Promise<{ success: boolean; results: any[] }>;
|
||||||
|
|
||||||
// Index operations
|
// Index operations
|
||||||
export function createIndex(collection: string, field: string, options?: { connectionId?: string, storeType?: StoreType }): Promise<boolean>;
|
export function createIndex(
|
||||||
|
collection: string,
|
||||||
|
field: string,
|
||||||
|
options?: { connectionId?: string; storeType?: StoreType },
|
||||||
|
): Promise<boolean>;
|
||||||
|
|
||||||
// Subscription API
|
// Subscription API
|
||||||
export function subscribe(event: 'document:created' | 'document:updated' | 'document:deleted', callback: (data: any) => void): () => void;
|
export function subscribe(
|
||||||
|
event: 'document:created' | 'document:updated' | 'document:deleted',
|
||||||
|
callback: (data: any) => void,
|
||||||
|
): () => void;
|
||||||
|
|
||||||
// File operations
|
// File operations
|
||||||
export function uploadFile(fileData: Buffer, options?: { filename?: string; connectionId?: string; metadata?: Record<string, any>; }): Promise<FileUploadResult>;
|
export function uploadFile(
|
||||||
|
fileData: Buffer,
|
||||||
|
options?: { filename?: string; connectionId?: string; metadata?: Record<string, any> },
|
||||||
|
): Promise<FileUploadResult>;
|
||||||
export function getFile(cid: string, options?: { connectionId?: string }): Promise<FileResult>;
|
export function getFile(cid: string, options?: { connectionId?: string }): Promise<FileResult>;
|
||||||
export function deleteFile(cid: string, options?: { connectionId?: string }): Promise<boolean>;
|
export function deleteFile(cid: string, options?: { connectionId?: string }): Promise<boolean>;
|
||||||
|
|
||||||
// Connection management
|
// Connection management
|
||||||
export function closeConnection(connectionId: string): Promise<boolean>;
|
export function closeConnection(connectionId: string): Promise<boolean>;
|
||||||
|
|
||||||
// Metrics
|
// Metrics
|
||||||
export function getMetrics(): Metrics;
|
export function getMetrics(): Metrics;
|
||||||
export function resetMetrics(): void;
|
export function resetMetrics(): void;
|
||||||
|
|
||||||
// Stop
|
// Stop
|
||||||
export function stopDB(): Promise<void>;
|
export function stopDB(): Promise<void>;
|
||||||
|
|
||||||
@ -227,6 +264,26 @@ declare module "@debros/network" {
|
|||||||
export function createServiceLogger(name: string, options?: LoggerOptions): any;
|
export function createServiceLogger(name: string, options?: LoggerOptions): any;
|
||||||
export function createDebrosLogger(options?: LoggerOptions): any;
|
export function createDebrosLogger(options?: LoggerOptions): any;
|
||||||
|
|
||||||
|
// Load Balancer
|
||||||
|
export interface LoadBalancerControllerModule {
|
||||||
|
getNodeInfo: (req: Request, res: Response, next: NextFunction) => void;
|
||||||
|
getOptimalPeer: (req: Request, res: Response, next: NextFunction) => void;
|
||||||
|
getAllPeers: (req: Request, res: Response, next: NextFunction) => void;
|
||||||
|
}
|
||||||
|
export const loadBalancerController: LoadBalancerControllerModule;
|
||||||
|
|
||||||
|
export const getConnectedPeers: () => Map<
|
||||||
|
string,
|
||||||
|
{
|
||||||
|
lastSeen: number;
|
||||||
|
load: number;
|
||||||
|
publicAddress: string;
|
||||||
|
fingerprint: string;
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
|
||||||
|
export const logPeersStatus: () => void;
|
||||||
|
|
||||||
// Default export
|
// Default export
|
||||||
const defaultExport: {
|
const defaultExport: {
|
||||||
config: DebrosConfig;
|
config: DebrosConfig;
|
||||||
@ -254,8 +311,19 @@ declare module "@debros/network" {
|
|||||||
ErrorCode: typeof ErrorCode;
|
ErrorCode: typeof ErrorCode;
|
||||||
StoreType: typeof StoreType;
|
StoreType: typeof StoreType;
|
||||||
};
|
};
|
||||||
|
loadBalancerController: LoadBalancerControllerModule;
|
||||||
|
getConnectedPeers: () => Map<
|
||||||
|
string,
|
||||||
|
{
|
||||||
|
lastSeen: number;
|
||||||
|
load: number;
|
||||||
|
publicAddress: string;
|
||||||
|
fingerprint: string;
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
logPeersStatus: () => void;
|
||||||
logger: any;
|
logger: any;
|
||||||
createServiceLogger: typeof createServiceLogger;
|
createServiceLogger: typeof createServiceLogger;
|
||||||
};
|
};
|
||||||
export default defaultExport;
|
export default defaultExport;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user