web-dc-api 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/dc.min.js +1 -1
  3. package/dist/esm/index.js +1 -1
  4. package/dist/index.d.ts +934 -878
  5. package/package.json +4 -8
  6. package/dist/cjs/helia-core-B1Xqha7a.js +0 -1
  7. package/dist/cjs/helia-core-D8Uv1KjQ.js +0 -1
  8. package/dist/cjs/polkadot-api-7PhQf3ws.js +0 -1
  9. package/dist/cjs/polkadot-api-CtrJVWuZ.js +0 -1
  10. package/dist/esm/chunks/helia-core-BxMqyK2Y.js +0 -1
  11. package/dist/esm/chunks/helia-core-DMXRpcO-.js +0 -1
  12. package/dist/esm/chunks/polkadot-api-5Y9Bw8VT.js +0 -1
  13. package/dist/esm/chunks/polkadot-api-D69Ioun_.js +0 -1
  14. package/lib/common/blowfish/block.ts +0 -259
  15. package/lib/common/blowfish/cipher.ts +0 -144
  16. package/lib/common/blowfish/const.ts +0 -195
  17. package/lib/common/chain.ts +0 -469
  18. package/lib/common/commonclient.ts +0 -202
  19. package/lib/common/constants.ts +0 -55
  20. package/lib/common/dc-key/ed25519.ts +0 -343
  21. package/lib/common/dc-key/keyManager.ts +0 -424
  22. package/lib/common/dcapi.ts +0 -98
  23. package/lib/common/dcutil.ts +0 -627
  24. package/lib/common/define.ts +0 -70
  25. package/lib/common/error.ts +0 -67
  26. package/lib/common/grpc-dc.ts +0 -104
  27. package/lib/common/module-system.ts +0 -184
  28. package/lib/common/service-worker.ts +0 -234
  29. package/lib/common/types/types.ts +0 -344
  30. package/lib/dc.ts +0 -701
  31. package/lib/implements/account/client.ts +0 -185
  32. package/lib/implements/account/manager.ts +0 -683
  33. package/lib/implements/aiproxy/client.ts +0 -357
  34. package/lib/implements/aiproxy/manager.ts +0 -670
  35. package/lib/implements/cache/client.ts +0 -105
  36. package/lib/implements/cache/manager.ts +0 -127
  37. package/lib/implements/comment/client.ts +0 -982
  38. package/lib/implements/comment/manager.ts +0 -1151
  39. package/lib/implements/dc/client.ts +0 -51
  40. package/lib/implements/dc/manager.ts +0 -33
  41. package/lib/implements/file/client.ts +0 -253
  42. package/lib/implements/file/file-cache-manager.ts +0 -142
  43. package/lib/implements/file/manager.ts +0 -1240
  44. package/lib/implements/file/seekableFileStream.ts +0 -344
  45. package/lib/implements/file/streamwriter.ts +0 -322
  46. package/lib/implements/keyvalue/client.ts +0 -376
  47. package/lib/implements/keyvalue/manager.ts +0 -759
  48. package/lib/implements/message/client.ts +0 -250
  49. package/lib/implements/message/manager.ts +0 -215
  50. package/lib/implements/threaddb/cbor/coding.ts +0 -62
  51. package/lib/implements/threaddb/cbor/event.ts +0 -336
  52. package/lib/implements/threaddb/cbor/node.ts +0 -542
  53. package/lib/implements/threaddb/cbor/record.ts +0 -398
  54. package/lib/implements/threaddb/common/AsyncMutex.ts +0 -24
  55. package/lib/implements/threaddb/common/addrinfo.ts +0 -135
  56. package/lib/implements/threaddb/common/dispatcher.ts +0 -81
  57. package/lib/implements/threaddb/common/idbstore-adapter.ts +0 -260
  58. package/lib/implements/threaddb/common/json-patcher.ts +0 -204
  59. package/lib/implements/threaddb/common/key.ts +0 -290
  60. package/lib/implements/threaddb/common/level-adapter.ts +0 -235
  61. package/lib/implements/threaddb/common/lineReader.ts +0 -79
  62. package/lib/implements/threaddb/common/logstore.ts +0 -215
  63. package/lib/implements/threaddb/common/transformed-datastore.ts +0 -308
  64. package/lib/implements/threaddb/core/app.ts +0 -206
  65. package/lib/implements/threaddb/core/core.ts +0 -230
  66. package/lib/implements/threaddb/core/db.ts +0 -249
  67. package/lib/implements/threaddb/core/event.ts +0 -54
  68. package/lib/implements/threaddb/core/head.ts +0 -89
  69. package/lib/implements/threaddb/core/identity.ts +0 -171
  70. package/lib/implements/threaddb/core/logstore.ts +0 -137
  71. package/lib/implements/threaddb/core/options.ts +0 -14
  72. package/lib/implements/threaddb/core/record.ts +0 -54
  73. package/lib/implements/threaddb/db/collection.ts +0 -1910
  74. package/lib/implements/threaddb/db/db.ts +0 -698
  75. package/lib/implements/threaddb/db/json2Query.ts +0 -192
  76. package/lib/implements/threaddb/db/query.ts +0 -524
  77. package/lib/implements/threaddb/dbclient.ts +0 -543
  78. package/lib/implements/threaddb/dbmanager.ts +0 -1906
  79. package/lib/implements/threaddb/lsstoreds/addr_book.ts +0 -549
  80. package/lib/implements/threaddb/lsstoreds/cache.ts +0 -36
  81. package/lib/implements/threaddb/lsstoreds/cyclic_batch.ts +0 -87
  82. package/lib/implements/threaddb/lsstoreds/global.ts +0 -151
  83. package/lib/implements/threaddb/lsstoreds/headbook.ts +0 -373
  84. package/lib/implements/threaddb/lsstoreds/keybook.ts +0 -297
  85. package/lib/implements/threaddb/lsstoreds/logstore.ts +0 -29
  86. package/lib/implements/threaddb/lsstoreds/metadata.ts +0 -223
  87. package/lib/implements/threaddb/net/define.ts +0 -149
  88. package/lib/implements/threaddb/net/grpcClient.ts +0 -589
  89. package/lib/implements/threaddb/net/grpcserver.ts +0 -146
  90. package/lib/implements/threaddb/net/net.ts +0 -2047
  91. package/lib/implements/threaddb/pb/lstore.proto +0 -38
  92. package/lib/implements/threaddb/pb/lstore.ts +0 -393
  93. package/lib/implements/threaddb/pb/lstore_pb.d.ts +0 -433
  94. package/lib/implements/threaddb/pb/lstore_pb.js +0 -1085
  95. package/lib/implements/threaddb/pb/net.proto +0 -194
  96. package/lib/implements/threaddb/pb/net_pb.d.ts +0 -2349
  97. package/lib/implements/threaddb/pb/net_pb.js +0 -5525
  98. package/lib/implements/threaddb/pb/proto-custom-types.ts +0 -212
  99. package/lib/implements/util/client.ts +0 -72
  100. package/lib/implements/util/manager.ts +0 -146
  101. package/lib/implements/wallet/manager.ts +0 -671
  102. package/lib/index.ts +0 -57
  103. package/lib/interfaces/DCContext.ts +0 -51
  104. package/lib/interfaces/aiproxy-interface.ts +0 -145
  105. package/lib/interfaces/auth-interface.ts +0 -118
  106. package/lib/interfaces/cache-interface.ts +0 -22
  107. package/lib/interfaces/client-interface.ts +0 -11
  108. package/lib/interfaces/comment-interface.ts +0 -167
  109. package/lib/interfaces/components/news-component.ts +0 -0
  110. package/lib/interfaces/database-interface.ts +0 -169
  111. package/lib/interfaces/file-interface.ts +0 -120
  112. package/lib/interfaces/index.ts +0 -10
  113. package/lib/interfaces/keyvalue-interface.ts +0 -156
  114. package/lib/interfaces/message-interface.ts +0 -22
  115. package/lib/interfaces/util-interface.ts +0 -31
  116. package/lib/modules/aiproxy-module.ts +0 -246
  117. package/lib/modules/auth-module.ts +0 -753
  118. package/lib/modules/cache-module.ts +0 -99
  119. package/lib/modules/client-module.ts +0 -71
  120. package/lib/modules/comment-module.ts +0 -429
  121. package/lib/modules/components/news-components.ts +0 -390
  122. package/lib/modules/database-module.ts +0 -598
  123. package/lib/modules/file-module.ts +0 -291
  124. package/lib/modules/index.ts +0 -13
  125. package/lib/modules/keyvalue-module.ts +0 -379
  126. package/lib/modules/message-module.ts +0 -107
  127. package/lib/modules/util-module.ts +0 -148
  128. package/lib/polyfills/process-env-browser.ts +0 -1
  129. package/lib/proto/datasource.ts +0 -93
  130. package/lib/proto/dcnet.proto +0 -1601
  131. package/lib/proto/dcnet_proto.d.ts +0 -22857
  132. package/lib/proto/dcnet_proto.js +0 -55204
  133. package/lib/proto/dcnet_proto_sparse.js +0 -55166
  134. package/lib/proto/oidfetch.proto +0 -25
  135. package/lib/proto/oidfetch_proto.d.ts +0 -585
  136. package/lib/proto/oidfetch_proto.js +0 -1247
  137. package/lib/serverless/babel-browser.ts +0 -39
  138. package/lib/serverless/base_entity.ts +0 -78
  139. package/lib/serverless/base_repository.ts +0 -414
  140. package/lib/serverless/browser_schema_extractor.ts +0 -283
  141. package/lib/serverless/decorator_factory.ts +0 -322
  142. package/lib/util/BrowserLineReader.ts +0 -73
  143. package/lib/util/base64.ts +0 -105
  144. package/lib/util/bcrypt.ts +0 -206
  145. package/lib/util/curve25519Encryption.ts +0 -418
  146. package/lib/util/dccrypt.ts +0 -73
  147. package/lib/util/logger.ts +0 -104
  148. package/lib/util/utils.ts +0 -289
@@ -1,169 +0,0 @@
1
- import ThreadID from "@textile/threads-id";
2
- import { ICollectionConfig, IDBInfo } from "../implements/threaddb/core/core";
3
-
4
- /**
5
- * 数据库操作接口,这个数据库主要由threadid确保唯一,servicekey,readkey多重加密来确保数据安全,其中readkey永远不离开用户,servicekey会在DC云端的TEE环境中参与数据备份
6
- * 提供基于ThreadDB的分布式数据库管理功能
7
- */
8
- export interface IDatabaseOperations {
9
-
10
-
11
- /**
12
- * 初始化数据库管理器
13
- * 创建数据库操作所需的组件和服务
14
- * @returns 错误信息
15
- */
16
- initDBManager(): Promise<Error| null>;
17
-
18
- /**
19
- * 创建新数据库
20
- * @param name 数据库名称
21
- * @param b32Rk base32编码的读取密钥
22
- * @param b32Sk base32编码的服务密钥
23
- * @param jsonCollections 集合配置数组,定义数据库中的集合结构
24
- * @returns 创建的线程ID和错误信息
25
- */
26
- newDB(
27
- name: string,
28
- b32Rk: string,
29
- b32Sk: string,
30
- jsonCollections: ICollectionConfig[]
31
- ): Promise<[string| null, Error | null]>;
32
-
33
- /**
34
- * 从分布式网络同步数据库
35
- * @param threadid 线程ID
36
- * @param dbname 数据库名称
37
- * @param dbAddr 数据库地址
38
- * @param b32Rk base32编码的读取密钥
39
- * @param b32Sk base32编码的服务密钥
40
- * @param block 是否阻塞等待同步完成
41
- * @param collectionInfos 集合配置数组,定义数据库中的集合结构
42
- * @returns 错误信息或null表示成功
43
- */
44
- syncDbFromDC(
45
- threadid: string,
46
- dbname: string,
47
- dbAddr: string,
48
- b32Rk: string,
49
- b32Sk: string,
50
- block: boolean,
51
- collectionInfos: ICollectionConfig[]
52
- ): Promise<Error| null>;
53
-
54
- /**
55
- * 刷新数据库,从分布式网络获取最新数据
56
- * @param threadid 数据库线程ID
57
- * @returns 错误信息或null表示成功
58
- */
59
- refreshDBFromDC(threadid: string): Promise<Error | null>;
60
-
61
- /**
62
- * 同步数据库到分布式网络
63
- * @param tId 线程ID
64
- * @returns 错误信息或null表示成功
65
- */
66
- syncDBToDC(tId: string): Promise<Error | null>;
67
-
68
-
69
- /**
70
- * 获取数据库信息
71
- * @param id threaddbID
72
- * @returns 数据库信息字符串,或错误
73
- */
74
- getDBInfo(id: string): Promise<[IDBInfo|null, Error|null]> ;
75
-
76
-
77
- /**
78
- * 升级集合结构
79
- * @param threadId 线程ID
80
- * @param collections 集合配置列表
81
- * @returns 错误信息或null
82
- */
83
- upgradeCollections(threadId: string, collections: ICollectionConfig[]): Promise<Error | null> ;
84
-
85
- /**
86
- * 关闭数据库管理器
87
- * @throws 关闭失败时抛出错误
88
- */
89
- close(): Promise<Error | null>;
90
-
91
- /**
92
- * 在集合中创建新对象实例
93
- * @param threadId 线程ID
94
- * @param collectionName 集合名称
95
- * @param jsonInstance JSON字符串表示的实例对象
96
- * @returns 创建的实例ID,或错误
97
- */
98
- create(threadId: string, collectionName: string, jsonInstance: string): Promise<[string| null, Error | null]>;
99
-
100
- /**
101
- * 通过ID删除实例
102
- * @param threadId 线程ID
103
- * @param collectionName 集合名称
104
- * @param instanceID 要删除的实例ID
105
- * @throws 删除失败时抛出错误
106
- */
107
- delete(threadId: string, collectionName: string, instanceID: string): Promise<Error | null>;
108
-
109
- /**
110
- * 更新已存在的实例
111
- * @param threadId 线程ID
112
- * @param collectionName 集合名称
113
- * @param instance JSON字符串表示的实例对象
114
- * @throws 更新失败时抛出错误
115
- */
116
- save(threadId: string, collectionName: string, instance: string): Promise<Error | null>;
117
-
118
- /**
119
- * 批量删除多个实例
120
- * @param threadId 线程ID
121
- * @param collectionName 集合名称
122
- * @param instanceIDs 逗号分隔或JSON数组表示的实例ID列表
123
- * @throws 删除失败时抛出错误
124
- */
125
- deleteMany(threadId: string, collectionName: string, instanceIDs: string): Promise<Error | null>;
126
-
127
- /**
128
- * 检查指定实例是否存在
129
- * @param threadId 线程ID
130
- * @param collectionName 集合名称
131
- * @param instanceID 要检查的实例ID
132
- * @returns 布尔值表示实例是否存在
133
- */
134
- has(threadId: string, collectionName: string, instanceID: string): Promise<boolean>;
135
-
136
- /**
137
- * 根据查询条件查找实例
138
- * @param threadId 线程ID
139
- * @param collectionName 集合名称
140
- * @param queryString JSON字符串表示的查询条件,
141
- * 格式举例:(condition表示and条件组合, ors表示或条件组合, sort表示排序, seek表示分页)
142
- * 格式1: `{"condition":"age=80 and name='John'"}`,"sort":{"fieldPath":"age","desc":true}}`
143
- * 格式2: `{"ors":[{"condition":"age = 21 and name = 'foo'"}]}`
144
- * 格式3: `{"condition":"age > 21 ","ors":[{"condition":"age = 21 and name = 'foo'"}],"sort":{"fieldPath":"age","desc":true},skip:10,"seek":"01fyc691gh671nf0s8qpt0ych8"}`
145
- * @returns JSON字符串表示的查询结果
146
- * @throws 查询失败时抛出错误
147
- */
148
- find(threadId: string, collectionName: string, queryString?: string): Promise<[string | null, Error | null]>;
149
-
150
- /**
151
- * 通过ID查找实例
152
- * @param threadId 线程ID
153
- * @param collectionName 集合名称
154
- * @param instanceID 实例ID
155
- * @returns JSON字符串表示的实例
156
- * @throws 查询失败时抛出错误
157
- */
158
- findByID(threadId: string, collectionName: string, instanceID: string): Promise<[string | null, Error | null]>;
159
-
160
- /**
161
- * 获取在指定时间后被修改的实例ID列表
162
- * @param threadId 线程ID
163
- * @param collectionName 集合名称
164
- * @param time 时间戳(毫秒)
165
- * @returns JSON字符串表示的实例ID列表
166
- * @throws 查询失败时抛出错误
167
- */
168
- modifiedSince(threadId: string, collectionName: string, time: number): Promise<[string | null, Error | null]>;
169
- }
@@ -1,120 +0,0 @@
1
- import { SeekableFileStream } from "../implements/file/seekableFileStream";
2
-
3
- /**
4
- * 文件操作接口
5
- * 提供文件上传、下载、缓存等功能
6
- */
7
- export interface IFileOperations {
8
- /**
9
- * 获取可寻址文件流
10
- * @param ipfsPath IPFS路径或CID
11
- * @param decryptKey 解密密钥,base32的symmetric key
12
- * @returns 可寻址文件流实例
13
- */
14
- getSeekableFileStream(
15
- ipfsPath: string,
16
- decryptKey: string
17
- ): Promise<SeekableFileStream>;
18
-
19
- /**
20
- * 清理文件缓存
21
- * @param pathname 可选的特定路径,不提供则清除所有缓存
22
- */
23
- clearFileCache(pathname?: string): void;
24
-
25
- /**
26
- * 获取缓存统计信息
27
- * @returns 包含缓存总数和键列表的统计对象
28
- */
29
- getCacheStats(): [{ total: number, keys: string[] } | null, Error | null];
30
-
31
- /**
32
- * 获取文件内容
33
- * @param cid 文件的内容标识符
34
- * @param decryptKey 解密密钥
35
- * @returns 文件的字节数组,失败则返回undefined
36
- */
37
- getFile(cid: string, decryptKey: string): Promise<[Uint8Array | null, Error | null]>;
38
-
39
- /**
40
- * 创建文件可读流
41
- * @param cid 文件的内容标识符
42
- * @param decryptKey 解密密钥
43
- * @returns 可读流对象,失败则返回null
44
- */
45
- createFileStream(
46
- cid: string,
47
- decryptKey: string
48
- ): Promise<ReadableStream<Uint8Array> | null>;
49
-
50
- /**
51
- * 添加文件到存储
52
- * @param file 要上传的文件对象
53
- * @param enkey 加密密钥
54
- * @param onUpdateTransmitSize 传输进度回调函数
55
- * @returns 添加结果
56
- */
57
- addFile(
58
- file: File,
59
- enkey: string,
60
- onUpdateTransmitSize: (status: number, size: number) => void
61
- ): Promise<[string | null, Error | null]>;
62
-
63
- /**
64
- * 添加文件夹到存储
65
- * @param files 要上传的文件夹下的文件列表
66
- * @param enkey 加密密钥,base32的symmetric key
67
- * @param onUpdateTransmitCount 传输进度回调函数
68
- * @returns 添加结果
69
- */
70
- addFolder(
71
- files: FileList,
72
- enkey: string,
73
- onUpdateTransmitCount: (
74
- status: number,
75
- total: number,
76
- process: number
77
- ) => void
78
- ): Promise<[string | null, Error | null]>;
79
-
80
-
81
-
82
-
83
- /**
84
- * 获取文件夹下的所有文件,包括内容(支持多级目录递归)
85
- * @param cid 根目录的CID
86
- * @param decryptKey 解密密钥
87
- * @param recursive 是否递归获取子目录,默认false(保持向后兼容)
88
- * @returns 文件列表:[{Name:文件或目录名,Type:0-文件 1-目录,Size:大小,Hash:文件或目录cid,Path:完整路径}]
89
- */
90
- getFolderFileListWithContent(
91
- cid: string,
92
- decryptKey: string,
93
- recursive: boolean
94
- ): Promise<[Array<{Name: string; Type: number; Size: number; Hash: string; Path: string, Content?: Uint8Array}> | null, Error | null]> ;
95
-
96
- /**
97
- * 获取文件夹下的文件列表(支持多级目录递归)
98
- * @param cid 根目录的CID
99
- * @param flag 是否需要连接节点
100
- * @param recursive 是否递归获取子目录,默认false(保持向后兼容)
101
- * @returns 返回JSON格式的文件列表:[{Name:文件或目录名,Type:0-文件 1-目录,Size:大小,Hash:文件或目录cid,Path:完整路径}]
102
- */
103
- getFolderFileList(
104
- cid: string,
105
- flag: number,
106
- recursive: boolean
107
- ): Promise<[Array<{Name: string; Type: number; Size: number; Hash: string; Path: string, Content?: Uint8Array}> | null, Error | null]> ;
108
- /**
109
- * 创建自定义文件列表
110
- * @param filesMap 文件列表,可以是Map或Record对象
111
- * @param rootFolderName 根文件夹名称
112
- * @returns 自定义文件列表对象
113
- */
114
- createCustomFileList(
115
- filesMap:
116
- | Map<string, string | Uint8Array | ArrayBuffer>
117
- | Record<string, string | Uint8Array | ArrayBuffer>,
118
- rootFolderName: string
119
- ): [FileList | null, Error | null];
120
- }
@@ -1,10 +0,0 @@
1
- export type {IAuthOperations} from './auth-interface';
2
- export type {IClientOperations} from './client-interface';
3
- export type {IDatabaseOperations} from './database-interface';
4
- export type {IFileOperations} from './file-interface';
5
- export type {IMessageOperations} from './message-interface';
6
- export type {IKeyValueOperations} from './keyvalue-interface';
7
- export type {ICommentOperations} from './comment-interface';
8
- export type {ICacheOperations} from './cache-interface';
9
- export type {DCContext} from './DCContext';
10
- export type {IUtilOperations} from './util-interface';
@@ -1,156 +0,0 @@
1
- import { Direction } from "../common/define";
2
- import { ThemePermission } from "../common/constants";
3
- import { ThemeAuthInfo, ThemeComment } from "../common/types/types";
4
- import { KeyValueStoreType, KeyValueDB } from "../implements/keyvalue/manager";
5
-
6
- /**
7
- * 键值存储操作接口
8
- * 提供分布式键值存储的创建、权限管理和数据操作功能
9
- */
10
- export interface IKeyValueOperations {
11
- /**
12
- * 创建key-value存储库
13
- * @param appId 应用ID
14
- * @param theme 库主题名称
15
- * @param space 分配的存储空间大小(字节)
16
- * @param type 存储主题类型 1:鉴权主题(读写都需要鉴权) 2:公共主题(默认所有用户可读,写需要鉴权)
17
- * @returns 创建的keyvalue数据库实例和可能的错误信息
18
- */
19
- createStore(appId: string,theme: string, space: number, type: KeyValueStoreType): Promise<[KeyValueDB|null, Error | null]>;
20
-
21
- /**
22
- * 获取指定主题的keyvalue数据库
23
- * @param appId 应用ID
24
- * @param theme 主题名称
25
- * @param themeAuthor 数据库创建者的公钥
26
- * @returns keyvalue数据库实例
27
- */
28
- getStore(appId: string, theme: string, themeAuthor: string): Promise<[KeyValueDB|null, Error | null]> ;
29
-
30
- /**
31
- * 配置主题的授权信息
32
- * @param kvdb keyvalue数据库实例
33
- * @param authPubkey 被授权者的公钥
34
- * @param permission 权限级别
35
- * @param remark 备注信息
36
- * @param vaccount 可选的虚拟账户
37
- * @returns [授权状态码, 错误信息]
38
- */
39
- configAuth(
40
- kvdb: KeyValueDB,
41
- authPubkey: string,
42
- permission: ThemePermission,
43
- remark: string,
44
- vaccount?: string
45
- ): Promise<[number | null, Error | null]>;
46
-
47
- /**
48
- * 获取主题的授权列表
49
- * @param kvdb keyvalue数据库实例
50
- * @param vaccount 可选的虚拟账户
51
- * @returns [授权列表,含签名的原始授权列表, 错误信息]
52
- */
53
- getAuthList(
54
- kvdb: KeyValueDB,
55
- vaccount?: string
56
- ): Promise<[ThemeAuthInfo[]|null,ThemeComment[] | null, Error | null]>;
57
-
58
- /**
59
- * 设置键值对,支持索引功能
60
- * @param kvdb: KeyValueDB,
61
- * @param key 键名
62
- * @param value 值内容
63
- * @param indexs 索引列表,格式为json字符串:[{key:"indexkey1",type:"string",value:"value"},{key:"indexkey2",type:"number", value:12}],设置索引后,后续查询可以通过索引快速定位
64
- * @param vaccount 可选的虚拟账户
65
- * @returns [是否设置成功, 时间戳, 错误信息]
66
- */
67
- set(
68
- kvdb: KeyValueDB,
69
- key: string,
70
- value: string,
71
- indexs: string,
72
- vaccount?: string
73
- ): Promise<[boolean | null, number | null, Error | null]>;
74
-
75
-
76
- /**
77
- * 获取当前用户设置的指定键的元数据
78
- * @param kvdb
79
- * @param key
80
- * @param vaccount
81
- * @returns [值, 错误信息],值的格式: value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
82
- */
83
- getValueSetByCurrentUser(kvdb: KeyValueDB, key: string,vaccount?: string): Promise<[string | null, Error | null]> ;
84
-
85
-
86
- /**
87
- * 获取指定键的值
88
- * @param kvdb: KeyValueDB,
89
- * @param key 键名
90
- * @param writerPubkey 写入者的公钥,如果不指定,则获取所有用户写入的该key的最新值
91
- * @param vaccount 可选的虚拟账户
92
- * @returns [值内容, 错误信息] 值的格式: value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
93
- */
94
- get(
95
- kvdb: KeyValueDB,
96
- key: string,
97
- writerPubkey?: string,
98
- vaccount?: string
99
- ): Promise<[string | null, Error | null]>;
100
-
101
-
102
- /**
103
- * 获取指定键的值列表,按key的字典序排序
104
- * @param kvdb: KeyValueDB,
105
- * @param key 键名
106
- * @param limit 返回结果数量限制
107
- * @param seekKey 查询起始键,用于分页查询
108
- * @param direction 查询方向
109
- * @param offset 结果偏移量
110
- * @param vaccount 可选的虚拟账户
111
- * @returns [值列表数组生成的json字符串, 错误信息] 数组的每个元素的格式: key:value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
112
- */
113
- getValues(
114
- kvdb: KeyValueDB,
115
- key: string,
116
- options: { limit?: number; seekKey?: string; direction?: Direction; offset?: number } ,
117
- vaccount?: string
118
- ): Promise<[string | null, Error | null]>;
119
-
120
-
121
- /**
122
- * 批量获取多个键的值
123
- * @param kvdb: KeyValueDB,
124
- * @param keys 多个键名,逗号分隔
125
- * @param writerPubkey 写入者的公钥,可选,默认为主题作者
126
- * @param vaccount 可选的虚拟账户
127
- * @returns [值列表数组生成的json字符串, 错误信息] 数组的每个元素的格式: key:value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
128
- */
129
- getBatch(
130
- kvdb: KeyValueDB,
131
- keys: string,
132
- writerPubkey?: string,
133
- vaccount?: string
134
- ): Promise<[string | null, Error | null]>;
135
-
136
- /**
137
- * 通过索引查询键值对
138
- * @param kvdb: KeyValueDB,
139
- * @param indexKey 索引键名
140
- * @param indexValue 索引值
141
- * @param type 索引值类型
142
- * @param seekKey 查询起始键
143
- * @param offset 结果偏移量
144
- * @param direction 查询方向 (Forward/Backward)
145
- * @param limit 返回结果数量限制
146
- * @param vaccount 可选的虚拟账户
147
- * @returns [值列表数组生成的json字符串, 错误信息] 数组的每个元素的格式: key:value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
148
- */
149
- getWithIndex(
150
- kvdb: KeyValueDB,
151
- indexKey: string,
152
- indexValue: string,
153
- options: { type?:string; limit?: number; seekKey?: string; direction?: Direction; offset?: number } ,
154
- vaccount?: string
155
- ): Promise<[string | null, Error | null]>;
156
- }
@@ -1,22 +0,0 @@
1
- import { dcnet } from "../../lib/proto/dcnet_proto";
2
-
3
- /**
4
- * 消息操作接口
5
- * 提供用户消息盒子的收发功能
6
- */
7
- export interface IMessageOperations {
8
- /**
9
- * 发送消息到用户消息盒子
10
- * @param receiver 接收者的公钥或账号标识
11
- * @param msg 消息内容
12
- * @returns 发送结果,包含消息ID和时间戳
13
- */
14
- sendMsgToUserBox(receiver: string, msg: string): Promise<[number | null, Error | null]>;
15
-
16
- /**
17
- * 从用户消息盒子获取消息
18
- * @param limit 可选,限制返回消息的最大数量,默认由系统决定
19
- * @returns 消息列表,按时间顺序排列
20
- */
21
- getMsgFromUserBox(limit?: number): Promise<[dcnet.pb.IUserMsg[] | null, Error | null]>;
22
- }
@@ -1,31 +0,0 @@
1
- import { IAppInfo } from '../../lib/common/types/types';
2
- import { SymmetricKey, Key as ThreadKey } from '../implements/threaddb/common/key';
3
- import { IFileOperations } from './file-interface';
4
-
5
-
6
- export interface IUtilOperations {
7
- createSymmetricKey(): SymmetricKey;
8
- createThreadKey(): ThreadKey;
9
- /**
10
- * 设置应用信息,发布应用时调用
11
- * @param appId string 应用ID
12
- * @param fid
13
- * @param domain
14
- * @param owner
15
- * @param rewarder
16
- */
17
- setAppInfo(appId: string,fid:string,domain:string,owner?: string,rewarder?: string): Promise<[boolean|null, Error | null]>;
18
- getAppInfo(appId: string): Promise<[IAppInfo|null, Error | null]>;
19
-
20
- /**
21
- * 处理IPFS请求
22
- * @param data 请求数据
23
- * @param port 消息端口
24
- * @param fileOps 文件操作对象
25
- */
26
- handleIpfsRequest(
27
- data: { id: string, pathname: string, range?: string },
28
- port: MessagePort,
29
- fileOps?: IFileOperations
30
- ): Promise<void>
31
- }