web-dc-api 0.0.73 → 0.0.74

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/index.d.ts CHANGED
@@ -3290,11 +3290,11 @@ interface INet {
3290
3290
  interface ICollectionConfig {
3291
3291
  name: string;
3292
3292
  schema: AnySchema;
3293
- indexes?: Index$1[];
3293
+ indexes?: Index$2[];
3294
3294
  writeValidator?: string;
3295
3295
  readFilter?: string;
3296
3296
  }
3297
- interface Index$1 {
3297
+ interface Index$2 {
3298
3298
  path: string;
3299
3299
  unique: boolean;
3300
3300
  }
@@ -3566,7 +3566,7 @@ type InstanceID = string;
3566
3566
  /**
3567
3567
  * Index defines an index configuration
3568
3568
  */
3569
- interface Index {
3569
+ interface Index$1 {
3570
3570
  /**
3571
3571
  * Path to the field to index in dot syntax, e.g., "name.last" or "age".
3572
3572
  */
@@ -3582,7 +3582,7 @@ interface Index {
3582
3582
  /**
3583
3583
  * Index definition for collections
3584
3584
  */
3585
- interface Index {
3585
+ interface Index$1 {
3586
3586
  path: string;
3587
3587
  unique?: boolean;
3588
3588
  }
@@ -3599,7 +3599,7 @@ declare class Collection implements ICollection {
3599
3599
  private vm;
3600
3600
  private writeValidator;
3601
3601
  readFilter: ((reader: any, instance: any) => any) | null;
3602
- indexes: Map<string, Index>;
3602
+ indexes: Map<string, Index$1>;
3603
3603
  constructor(name: string, schema: AnySchema, db: IDB, rawWriteValidator?: string | undefined, rawReadFilter?: string | undefined);
3604
3604
  private compileAndLoadValidator;
3605
3605
  /**
@@ -3697,7 +3697,7 @@ declare class Collection implements ICollection {
3697
3697
  /**
3698
3698
  * 返回当前索引列表
3699
3699
  */
3700
- getIndexes(): Index[];
3700
+ getIndexes(): Index$1[];
3701
3701
  /**
3702
3702
  * 创建基于路径的新索引
3703
3703
  * 使用点语法访问嵌套字段,例如 "name.last"
@@ -3706,7 +3706,7 @@ declare class Collection implements ICollection {
3706
3706
  * 添加索引将覆盖任何已存在的重叠索引值
3707
3707
  * 注意: 这目前不会构建索引。如果在添加新索引之前已添加了项目,它们不会被事后索引。
3708
3708
  */
3709
- addIndex(index: Index, token?: ThreadToken): Promise<void>;
3709
+ addIndex(index: Index$1, token?: ThreadToken): Promise<void>;
3710
3710
  /**
3711
3711
  * 删除指定路径的索引
3712
3712
  */
@@ -3727,7 +3727,7 @@ declare class Collection implements ICollection {
3727
3727
  /**
3728
3728
  * 在项目上添加或移除特定索引
3729
3729
  */
3730
- indexUpdate(field: string, index: Index, txn: any, key: Key$1, input: Uint8Array, deleteOp: boolean): Promise<void>;
3730
+ indexUpdate(field: string, index: Index$1, txn: any, key: Key$1, input: Uint8Array, deleteOp: boolean): Promise<void>;
3731
3731
  }
3732
3732
 
3733
3733
  declare class DB implements App, IDB {
@@ -15388,6 +15388,9 @@ declare namespace dcnet {
15388
15388
 
15389
15389
  /** SetKeyValueReply flag */
15390
15390
  flag?: (number|null);
15391
+
15392
+ /** SetKeyValueReply timestamp */
15393
+ timestamp?: (number|Long|null);
15391
15394
  }
15392
15395
 
15393
15396
  /** Represents a SetKeyValueReply. */
@@ -15402,6 +15405,9 @@ declare namespace dcnet {
15402
15405
  /** SetKeyValueReply flag. */
15403
15406
  public flag: number;
15404
15407
 
15408
+ /** SetKeyValueReply timestamp. */
15409
+ public timestamp: (number|Long);
15410
+
15405
15411
  /**
15406
15412
  * Creates a new SetKeyValueReply instance using the specified properties.
15407
15413
  * @param [properties] Properties to set
@@ -18324,6 +18330,230 @@ declare namespace dcnet {
18324
18330
  public static getTypeUrl(typeUrlPrefix?: string): string;
18325
18331
  }
18326
18332
 
18333
+ /** Properties of a GetUserThemeConfigInfoRequest. */
18334
+ interface IGetUserThemeConfigInfoRequest {
18335
+
18336
+ /** GetUserThemeConfigInfoRequest theme */
18337
+ theme?: (Uint8Array|null);
18338
+
18339
+ /** GetUserThemeConfigInfoRequest appId */
18340
+ appId?: (Uint8Array|null);
18341
+
18342
+ /** GetUserThemeConfigInfoRequest themeAuthor */
18343
+ themeAuthor?: (Uint8Array|null);
18344
+
18345
+ /** GetUserThemeConfigInfoRequest UserPubkey */
18346
+ UserPubkey?: (Uint8Array|null);
18347
+
18348
+ /** GetUserThemeConfigInfoRequest Vaccount */
18349
+ Vaccount?: (Uint8Array|null);
18350
+ }
18351
+
18352
+ /** Represents a GetUserThemeConfigInfoRequest. */
18353
+ class GetUserThemeConfigInfoRequest implements IGetUserThemeConfigInfoRequest {
18354
+
18355
+ /**
18356
+ * Constructs a new GetUserThemeConfigInfoRequest.
18357
+ * @param [properties] Properties to set
18358
+ */
18359
+ constructor(properties?: dcnet.pb.IGetUserThemeConfigInfoRequest);
18360
+
18361
+ /** GetUserThemeConfigInfoRequest theme. */
18362
+ public theme: Uint8Array;
18363
+
18364
+ /** GetUserThemeConfigInfoRequest appId. */
18365
+ public appId: Uint8Array;
18366
+
18367
+ /** GetUserThemeConfigInfoRequest themeAuthor. */
18368
+ public themeAuthor: Uint8Array;
18369
+
18370
+ /** GetUserThemeConfigInfoRequest UserPubkey. */
18371
+ public UserPubkey: Uint8Array;
18372
+
18373
+ /** GetUserThemeConfigInfoRequest Vaccount. */
18374
+ public Vaccount: Uint8Array;
18375
+
18376
+ /**
18377
+ * Creates a new GetUserThemeConfigInfoRequest instance using the specified properties.
18378
+ * @param [properties] Properties to set
18379
+ * @returns GetUserThemeConfigInfoRequest instance
18380
+ */
18381
+ public static create(properties?: dcnet.pb.IGetUserThemeConfigInfoRequest): dcnet.pb.GetUserThemeConfigInfoRequest;
18382
+
18383
+ /**
18384
+ * Encodes the specified GetUserThemeConfigInfoRequest message. Does not implicitly {@link dcnet.pb.GetUserThemeConfigInfoRequest.verify|verify} messages.
18385
+ * @param message GetUserThemeConfigInfoRequest message or plain object to encode
18386
+ * @param [writer] Writer to encode to
18387
+ * @returns Writer
18388
+ */
18389
+ public static encode(message: dcnet.pb.IGetUserThemeConfigInfoRequest, writer?: $protobuf.Writer): $protobuf.Writer;
18390
+
18391
+ /**
18392
+ * Encodes the specified GetUserThemeConfigInfoRequest message, length delimited. Does not implicitly {@link dcnet.pb.GetUserThemeConfigInfoRequest.verify|verify} messages.
18393
+ * @param message GetUserThemeConfigInfoRequest message or plain object to encode
18394
+ * @param [writer] Writer to encode to
18395
+ * @returns Writer
18396
+ */
18397
+ public static encodeDelimited(message: dcnet.pb.IGetUserThemeConfigInfoRequest, writer?: $protobuf.Writer): $protobuf.Writer;
18398
+
18399
+ /**
18400
+ * Decodes a GetUserThemeConfigInfoRequest message from the specified reader or buffer.
18401
+ * @param reader Reader or buffer to decode from
18402
+ * @param [length] Message length if known beforehand
18403
+ * @returns GetUserThemeConfigInfoRequest
18404
+ * @throws {Error} If the payload is not a reader or valid buffer
18405
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
18406
+ */
18407
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): dcnet.pb.GetUserThemeConfigInfoRequest;
18408
+
18409
+ /**
18410
+ * Decodes a GetUserThemeConfigInfoRequest message from the specified reader or buffer, length delimited.
18411
+ * @param reader Reader or buffer to decode from
18412
+ * @returns GetUserThemeConfigInfoRequest
18413
+ * @throws {Error} If the payload is not a reader or valid buffer
18414
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
18415
+ */
18416
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): dcnet.pb.GetUserThemeConfigInfoRequest;
18417
+
18418
+ /**
18419
+ * Verifies a GetUserThemeConfigInfoRequest message.
18420
+ * @param message Plain object to verify
18421
+ * @returns `null` if valid, otherwise the reason why it is not
18422
+ */
18423
+ public static verify(message: { [k: string]: any }): (string|null);
18424
+
18425
+ /**
18426
+ * Creates a GetUserThemeConfigInfoRequest message from a plain object. Also converts values to their respective internal types.
18427
+ * @param object Plain object
18428
+ * @returns GetUserThemeConfigInfoRequest
18429
+ */
18430
+ public static fromObject(object: { [k: string]: any }): dcnet.pb.GetUserThemeConfigInfoRequest;
18431
+
18432
+ /**
18433
+ * Creates a plain object from a GetUserThemeConfigInfoRequest message. Also converts values to other types if specified.
18434
+ * @param message GetUserThemeConfigInfoRequest
18435
+ * @param [options] Conversion options
18436
+ * @returns Plain object
18437
+ */
18438
+ public static toObject(message: dcnet.pb.GetUserThemeConfigInfoRequest, options?: $protobuf.IConversionOptions): { [k: string]: any };
18439
+
18440
+ /**
18441
+ * Converts this GetUserThemeConfigInfoRequest to JSON.
18442
+ * @returns JSON object
18443
+ */
18444
+ public toJSON(): { [k: string]: any };
18445
+
18446
+ /**
18447
+ * Gets the default type url for GetUserThemeConfigInfoRequest
18448
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
18449
+ * @returns The default type url
18450
+ */
18451
+ public static getTypeUrl(typeUrlPrefix?: string): string;
18452
+ }
18453
+
18454
+ /** Properties of a GetUserThemeConfigInfoReply. */
18455
+ interface IGetUserThemeConfigInfoReply {
18456
+
18457
+ /** GetUserThemeConfigInfoReply flag */
18458
+ flag?: (number|null);
18459
+
18460
+ /** GetUserThemeConfigInfoReply authInfo */
18461
+ authInfo?: (Uint8Array|null);
18462
+ }
18463
+
18464
+ /** Represents a GetUserThemeConfigInfoReply. */
18465
+ class GetUserThemeConfigInfoReply implements IGetUserThemeConfigInfoReply {
18466
+
18467
+ /**
18468
+ * Constructs a new GetUserThemeConfigInfoReply.
18469
+ * @param [properties] Properties to set
18470
+ */
18471
+ constructor(properties?: dcnet.pb.IGetUserThemeConfigInfoReply);
18472
+
18473
+ /** GetUserThemeConfigInfoReply flag. */
18474
+ public flag: number;
18475
+
18476
+ /** GetUserThemeConfigInfoReply authInfo. */
18477
+ public authInfo: Uint8Array;
18478
+
18479
+ /**
18480
+ * Creates a new GetUserThemeConfigInfoReply instance using the specified properties.
18481
+ * @param [properties] Properties to set
18482
+ * @returns GetUserThemeConfigInfoReply instance
18483
+ */
18484
+ public static create(properties?: dcnet.pb.IGetUserThemeConfigInfoReply): dcnet.pb.GetUserThemeConfigInfoReply;
18485
+
18486
+ /**
18487
+ * Encodes the specified GetUserThemeConfigInfoReply message. Does not implicitly {@link dcnet.pb.GetUserThemeConfigInfoReply.verify|verify} messages.
18488
+ * @param message GetUserThemeConfigInfoReply message or plain object to encode
18489
+ * @param [writer] Writer to encode to
18490
+ * @returns Writer
18491
+ */
18492
+ public static encode(message: dcnet.pb.IGetUserThemeConfigInfoReply, writer?: $protobuf.Writer): $protobuf.Writer;
18493
+
18494
+ /**
18495
+ * Encodes the specified GetUserThemeConfigInfoReply message, length delimited. Does not implicitly {@link dcnet.pb.GetUserThemeConfigInfoReply.verify|verify} messages.
18496
+ * @param message GetUserThemeConfigInfoReply message or plain object to encode
18497
+ * @param [writer] Writer to encode to
18498
+ * @returns Writer
18499
+ */
18500
+ public static encodeDelimited(message: dcnet.pb.IGetUserThemeConfigInfoReply, writer?: $protobuf.Writer): $protobuf.Writer;
18501
+
18502
+ /**
18503
+ * Decodes a GetUserThemeConfigInfoReply message from the specified reader or buffer.
18504
+ * @param reader Reader or buffer to decode from
18505
+ * @param [length] Message length if known beforehand
18506
+ * @returns GetUserThemeConfigInfoReply
18507
+ * @throws {Error} If the payload is not a reader or valid buffer
18508
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
18509
+ */
18510
+ public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): dcnet.pb.GetUserThemeConfigInfoReply;
18511
+
18512
+ /**
18513
+ * Decodes a GetUserThemeConfigInfoReply message from the specified reader or buffer, length delimited.
18514
+ * @param reader Reader or buffer to decode from
18515
+ * @returns GetUserThemeConfigInfoReply
18516
+ * @throws {Error} If the payload is not a reader or valid buffer
18517
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
18518
+ */
18519
+ public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): dcnet.pb.GetUserThemeConfigInfoReply;
18520
+
18521
+ /**
18522
+ * Verifies a GetUserThemeConfigInfoReply message.
18523
+ * @param message Plain object to verify
18524
+ * @returns `null` if valid, otherwise the reason why it is not
18525
+ */
18526
+ public static verify(message: { [k: string]: any }): (string|null);
18527
+
18528
+ /**
18529
+ * Creates a GetUserThemeConfigInfoReply message from a plain object. Also converts values to their respective internal types.
18530
+ * @param object Plain object
18531
+ * @returns GetUserThemeConfigInfoReply
18532
+ */
18533
+ public static fromObject(object: { [k: string]: any }): dcnet.pb.GetUserThemeConfigInfoReply;
18534
+
18535
+ /**
18536
+ * Creates a plain object from a GetUserThemeConfigInfoReply message. Also converts values to other types if specified.
18537
+ * @param message GetUserThemeConfigInfoReply
18538
+ * @param [options] Conversion options
18539
+ * @returns Plain object
18540
+ */
18541
+ public static toObject(message: dcnet.pb.GetUserThemeConfigInfoReply, options?: $protobuf.IConversionOptions): { [k: string]: any };
18542
+
18543
+ /**
18544
+ * Converts this GetUserThemeConfigInfoReply to JSON.
18545
+ * @returns JSON object
18546
+ */
18547
+ public toJSON(): { [k: string]: any };
18548
+
18549
+ /**
18550
+ * Gets the default type url for GetUserThemeConfigInfoReply
18551
+ * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
18552
+ * @returns The default type url
18553
+ */
18554
+ public static getTypeUrl(typeUrlPrefix?: string): string;
18555
+ }
18556
+
18327
18557
  /** Properties of a GetUserCommentsRequest. */
18328
18558
  interface IGetUserCommentsRequest {
18329
18559
 
@@ -25701,6 +25931,20 @@ declare namespace dcnet {
25701
25931
  */
25702
25932
  public getThemeComments(request: dcnet.pb.IGetThemeCommentsRequest): Promise<dcnet.pb.GetThemeCommentsReply>;
25703
25933
 
25934
+ /**
25935
+ * Calls GetUserThemeConfigInfo.
25936
+ * @param request GetUserThemeConfigInfoRequest message or plain object
25937
+ * @param callback Node-style callback called with the error, if any, and GetUserThemeConfigInfoReply
25938
+ */
25939
+ public getUserThemeConfigInfo(request: dcnet.pb.IGetUserThemeConfigInfoRequest, callback: dcnet.pb.Service.GetUserThemeConfigInfoCallback): void;
25940
+
25941
+ /**
25942
+ * Calls GetUserThemeConfigInfo.
25943
+ * @param request GetUserThemeConfigInfoRequest message or plain object
25944
+ * @returns Promise
25945
+ */
25946
+ public getUserThemeConfigInfo(request: dcnet.pb.IGetUserThemeConfigInfoRequest): Promise<dcnet.pb.GetUserThemeConfigInfoReply>;
25947
+
25704
25948
  /**
25705
25949
  * Calls GetThemeAuthList.
25706
25950
  * @param request GetThemeAuthListRequest message or plain object
@@ -26586,6 +26830,13 @@ declare namespace dcnet {
26586
26830
  */
26587
26831
  type GetThemeCommentsCallback = (error: (Error|null), response?: dcnet.pb.GetThemeCommentsReply) => void;
26588
26832
 
26833
+ /**
26834
+ * Callback as used by {@link dcnet.pb.Service#getUserThemeConfigInfo}.
26835
+ * @param error Error, if any
26836
+ * @param [response] GetUserThemeConfigInfoReply
26837
+ */
26838
+ type GetUserThemeConfigInfoCallback = (error: (Error|null), response?: dcnet.pb.GetUserThemeConfigInfoReply) => void;
26839
+
26589
26840
  /**
26590
26841
  * Callback as used by {@link dcnet.pb.Service#getThemeAuthList}.
26591
26842
  * @param error Error, if any
@@ -26908,7 +27159,7 @@ declare class KeyValueDB {
26908
27159
  private themeAuthor;
26909
27160
  private manager;
26910
27161
  constructor(appId: string, dbname: string, themeAuthor: string, manager: KeyValueManager);
26911
- set(key: string, value: any, indexs?: string, vaccount?: string): Promise<[boolean | null, Error | null]>;
27162
+ set(key: string, value: any, indexs?: string, vaccount?: string): Promise<[boolean | null, number | null, Error | null]>;
26912
27163
  get(key: string, writerPubkey?: string, vaccount?: string): Promise<[string | null, Error | null]>;
26913
27164
  getBatch(keys: string, writerPubkey: string, vaccount: string): Promise<[string | null, Error | null]>;
26914
27165
  getWithIndex(indexKey: string, indexValue: string, limit?: number, seekKey?: string, direction?: Direction, offset?: number, vaccount?: string): Promise<[string | null, Error | null]>;
@@ -26925,7 +27176,7 @@ declare class KeyValueManager {
26925
27176
  doConfigAuth(appId: string, themeAuthor: string, theme: string, authPubkey: string, permission: number, remark: string, vaccount?: string): Promise<[number | null, Error | null]>;
26926
27177
  getAuthList(appId: string, themeAuthor: string, theme: string, vaccount?: string): Promise<[ThemeAuthInfo[] | null, ThemeComment[] | null, Error | null]>;
26927
27178
  setKeyValue(appId: string, themeAuthor: string, theme: string, key: string, value: string, indexs: string, //索引列表,格式为key1:value1$$$key2:value2
26928
- vaccount?: string): Promise<[boolean | null, Error | null]>;
27179
+ vaccount?: string): Promise<[boolean | null, number | null, Error | null]>;
26929
27180
  getValueWithKey(appId: string, themeAuthor: string, theme: string, writerPubkey: string, key: string, vaccount?: string): Promise<[string | null, Error | null]>;
26930
27181
  getValuesWithKeys(appId: string, themeAuthor: string, theme: string, writerPubkey: string, keys: string, vaccount?: string): Promise<[string | null, Error | null]>;
26931
27182
  getWithIndex(appId: string, themeAuthor: string, theme: string, indexKey: string, indexValue: string, seekKey: string, direction: Direction | undefined, offset: number, limit: number, vaccount?: string): Promise<[string | null, Error | null]>;
@@ -26977,16 +27228,24 @@ interface IKeyValueOperations {
26977
27228
  * @param value 值内容
26978
27229
  * @param indexs 索引列表,格式为json字符串:[{key:"indexkey1",type:"string",value:"value"},{key:"indexkey2",type:"number", value:12}],设置索引后,后续查询可以通过索引快速定位
26979
27230
  * @param vaccount 可选的虚拟账户
26980
- * @returns [是否设置成功, 错误信息]
27231
+ * @returns [是否设置成功, 时间戳, 错误信息]
26981
27232
  */
26982
- set(kvdb: KeyValueDB, key: string, value: string, indexs: string, vaccount?: string): Promise<[boolean | null, Error | null]>;
27233
+ set(kvdb: KeyValueDB, key: string, value: string, indexs: string, vaccount?: string): Promise<[boolean | null, number | null, Error | null]>;
27234
+ /**
27235
+ * 获取当前用户设置的指定键的元数据
27236
+ * @param kvdb
27237
+ * @param key
27238
+ * @param vaccount
27239
+ * @returns [值, 错误信息],值的格式: value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
27240
+ */
27241
+ getValueSetByCurrentUser(kvdb: KeyValueDB, key: string, vaccount?: string): Promise<[string | null, Error | null]>;
26983
27242
  /**
26984
27243
  * 获取指定键的值
26985
27244
  * @param kvdb: KeyValueDB,
26986
27245
  * @param key 键名
26987
27246
  * @param writerPubkey 写入者的公钥,如果不指定,则获取所有用户写入的该key的最新值
26988
27247
  * @param vaccount 可选的虚拟账户
26989
- * @returns [值内容, 错误信息] 值的格式: value$$$dckv_extra$$${'timestamp':'%d','opuser':'%s'}
27248
+ * @returns [值内容, 错误信息] 值的格式: value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
26990
27249
  */
26991
27250
  get(kvdb: KeyValueDB, key: string, writerPubkey?: string, vaccount?: string): Promise<[string | null, Error | null]>;
26992
27251
  /**
@@ -26998,7 +27257,7 @@ interface IKeyValueOperations {
26998
27257
  * @param direction 查询方向
26999
27258
  * @param offset 结果偏移量
27000
27259
  * @param vaccount 可选的虚拟账户
27001
- * @returns [值列表生成的json字符串, 错误信息] 每个值的格式: value$$$dckv_extra$$${'timestamp':'%d','opuser':'%s'}
27260
+ * @returns [值列表数组生成的json字符串, 错误信息] 数组的每个元素的格式: key:value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
27002
27261
  */
27003
27262
  getValues(kvdb: KeyValueDB, key: string, options: {
27004
27263
  limit?: number;
@@ -27012,7 +27271,7 @@ interface IKeyValueOperations {
27012
27271
  * @param keys 多个键名,逗号分隔
27013
27272
  * @param writerPubkey 写入者的公钥,可选,默认为主题作者
27014
27273
  * @param vaccount 可选的虚拟账户
27015
- * @returns [JSON格式值内容, 错误信息] 每个值的格式: value$$$dckv_extra$$${'timestamp':'%d','opuser':'%s'}
27274
+ * @returns [值列表数组生成的json字符串, 错误信息] 数组的每个元素的格式: key:value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
27016
27275
  */
27017
27276
  getBatch(kvdb: KeyValueDB, keys: string, writerPubkey?: string, vaccount?: string): Promise<[string | null, Error | null]>;
27018
27277
  /**
@@ -27026,7 +27285,7 @@ interface IKeyValueOperations {
27026
27285
  * @param direction 查询方向 (Forward/Backward)
27027
27286
  * @param limit 返回结果数量限制
27028
27287
  * @param vaccount 可选的虚拟账户
27029
- * @returns [JSON格式查询结果, 错误信息] 每个值的格式: value$$$dckv_extra$$${'timestamp':'%d','opuser':'%s'}
27288
+ * @returns [值列表数组生成的json字符串, 错误信息] 数组的每个元素的格式: key:value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
27030
27289
  */
27031
27290
  getWithIndex(kvdb: KeyValueDB, indexKey: string, indexValue: string, options: {
27032
27291
  type?: string;
@@ -28053,6 +28312,7 @@ declare class KeyValueModule implements DCModule, IKeyValueOperations {
28053
28312
  readonly moduleName = CoreModuleName.KEYVALUE;
28054
28313
  private keyValueManager;
28055
28314
  private initialized;
28315
+ private context;
28056
28316
  /**
28057
28317
  * 初始化键值存储模块
28058
28318
  * @param context DC上下文
@@ -28077,14 +28337,22 @@ declare class KeyValueModule implements DCModule, IKeyValueOperations {
28077
28337
  configAuth(kvdb: KeyValueDB, authPubkey: string, permission: ThemePermission, remark: string, vaccount?: string): Promise<[number | null, Error | null]>;
28078
28338
  getAuthList(kvdb: KeyValueDB, vaccount?: string): Promise<[ThemeAuthInfo[] | null, ThemeComment[] | null, Error | null]>;
28079
28339
  set(kvdb: KeyValueDB, key: string, value: string, indexs: string, //索引列表,格式为json字符串:[{key:"indexkey1",type:"string",value:"value"},{key:"indexkey2",type:"number", value:12}],这里统一转换格式为key1:value1$$$key2:value2
28080
- vaccount?: string): Promise<[boolean | null, Error | null]>;
28340
+ vaccount?: string): Promise<[boolean | null, number | null, Error | null]>;
28341
+ /**
28342
+ * 获取当前用户设置的指定键的元数据
28343
+ * @param kvdb
28344
+ * @param key
28345
+ * @param vaccount
28346
+ * @returns [值, 错误信息],值的格式: value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
28347
+ */
28348
+ getValueSetByCurrentUser(kvdb: KeyValueDB, key: string, vaccount?: string): Promise<[string | null, Error | null]>;
28081
28349
  /**
28082
28350
  * 获取指定键的元数据
28083
28351
  * @param kvdb
28084
28352
  * @param key
28085
28353
  * @param writerPubkey
28086
28354
  * @param vaccount
28087
- * @returns [值, 错误信息],值的格式: value$$$dckv_extra$$${'timestamp':'%d','opuser':'%s'}
28355
+ * @returns [值, 错误信息],值的格式: value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
28088
28356
  */
28089
28357
  get(kvdb: KeyValueDB, key: string, writerPubkey?: string, vaccount?: string): Promise<[string | null, Error | null]>;
28090
28358
  /**
@@ -28095,7 +28363,7 @@ declare class KeyValueModule implements DCModule, IKeyValueOperations {
28095
28363
  * @param seekKey 查询起始键,用于分页查询
28096
28364
  * @param offset 结果偏移量
28097
28365
  * @param vaccount 可选的虚拟账户
28098
- * @returns [值列表生成的json字符串, 错误信息] 每个值的格式: value$$$dckv_extra$$${'timestamp':'%d','opuser':'%s'}
28366
+ * @returns [值列表数组生成的json字符串, 错误信息] 数组的每个元素的格式: key:value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
28099
28367
  */
28100
28368
  getValues(kvdb: KeyValueDB, key: string, options: {
28101
28369
  limit?: number;
@@ -28109,7 +28377,7 @@ declare class KeyValueModule implements DCModule, IKeyValueOperations {
28109
28377
  * @param keys 逗号分隔的键列表
28110
28378
  * @param writerPubkey 可选,指定写入者公钥
28111
28379
  * @param vaccount 可选的虚拟账户
28112
- * @returns [值的JSON字符串, 错误信息] 每个值的格式: value$$$dckv_extra$$${'timestamp':'%d','opuser':'%s'}
28380
+ * @returns [值的数组的JSON字符串, 错误信息] 数组的每个元素的格式: key:value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
28113
28381
  */
28114
28382
  getBatch(kvdb: KeyValueDB, keys: string, writerPubkey?: string, vaccount?: string): Promise<[string | null, Error | null]>;
28115
28383
  /**
@@ -28122,7 +28390,7 @@ declare class KeyValueModule implements DCModule, IKeyValueOperations {
28122
28390
  * @param direction 查询方向
28123
28391
  * @param offset 结果偏移量
28124
28392
  * @param vaccount 可选的虚拟账户
28125
- * @returns [值的JSON字符串, 错误信息] 每个值的格式: value$$$dckv_extra$$${'timestamp':'%d','opuser':'%s'}
28393
+ * @returns [值的数组形式的JSON字符串, 错误信息] 数组的每个元素的格式: key:value$$$dckv_extra$$${'dc_timestamp':'%d','dc_opuser':'%s'}
28126
28394
  */
28127
28395
  getWithIndex(kvdb: KeyValueDB, indexKey: string, indexValue: string, options: {
28128
28396
  type?: string;
@@ -28565,6 +28833,160 @@ declare class DC implements DCContext {
28565
28833
  get util(): UtilModule | null;
28566
28834
  }
28567
28835
 
28836
+ declare abstract class BaseEntity {
28837
+ dc_timestamp?: number;
28838
+ dc_opuser?: string;
28839
+ constructor();
28840
+ protected getPrimaryKey(): string;
28841
+ touch(opuser?: string, timeMs?: number): this;
28842
+ setOpUser(opuser: string): this;
28843
+ validate(): void;
28844
+ static from<T extends BaseEntity>(this: new () => T, data: Partial<T>): T;
28845
+ toJSON(): Record<string, unknown>;
28846
+ }
28847
+
28848
+ type Ctor<T> = new (...args: any[]) => T;
28849
+ declare function composeCompositeIndexValue(values: unknown[]): string;
28850
+ type FindIndexOptions = {
28851
+ type?: "string" | "number" | "boolean" | "date" | "json" | "binary";
28852
+ limit?: number;
28853
+ seekKey?: string;
28854
+ direction?: Direction;
28855
+ offset?: number;
28856
+ vaccount?: string;
28857
+ };
28858
+ type FindValuesOptions = {
28859
+ limit?: number;
28860
+ seekKey?: string;
28861
+ direction?: Direction;
28862
+ offset?: number;
28863
+ vaccount?: string;
28864
+ };
28865
+ declare class EntityRepository<T extends BaseEntity> {
28866
+ private readonly entityCtor;
28867
+ private readonly ops;
28868
+ private readonly db;
28869
+ constructor(entityCtor: Ctor<T>, ops: IKeyValueOperations, db: KeyValueDB);
28870
+ save(entity: T, vaccount?: string): Promise<number>;
28871
+ deleteById(id: string, vaccount?: string): Promise<void>;
28872
+ update(id: string, patch: Partial<T>, vaccount?: string): Promise<T | null>;
28873
+ findById(id: string, writerPubkey?: string, vaccount?: string): Promise<T | null>;
28874
+ findByIndex(indexKey: string, indexValue: string, options?: FindIndexOptions): Promise<T[]>;
28875
+ findOneByIndex(indexKey: string, indexValue: string, options?: Omit<FindIndexOptions, "limit">): Promise<T | null>;
28876
+ getValues(keyPrefix: string, options?: FindValuesOptions): Promise<T[]>;
28877
+ }
28878
+
28879
+ type PrimitiveType = 'string' | 'number' | 'boolean' | 'date' | 'json' | 'binary';
28880
+ interface EntityOptions {
28881
+ name?: string;
28882
+ namespace?: string;
28883
+ ttlSeconds?: number;
28884
+ versioned?: boolean;
28885
+ }
28886
+ interface ColumnOptions<T = unknown> {
28887
+ name?: string;
28888
+ type?: PrimitiveType;
28889
+ required?: boolean;
28890
+ default?: T | (() => T);
28891
+ index?: boolean;
28892
+ unique?: boolean;
28893
+ }
28894
+ type IndexField = string | {
28895
+ field: string;
28896
+ order?: 'asc' | 'desc';
28897
+ };
28898
+ interface IndexOptions {
28899
+ name?: string;
28900
+ fields: IndexField[];
28901
+ unique?: boolean;
28902
+ ttlSeconds?: number;
28903
+ }
28904
+ interface EntityMeta {
28905
+ target: Function;
28906
+ name: string;
28907
+ options: EntityOptions;
28908
+ }
28909
+ interface ColumnMeta {
28910
+ target: Function;
28911
+ propertyKey: string | symbol;
28912
+ options: ColumnOptions;
28913
+ resolvedName: string;
28914
+ }
28915
+ interface NormalizedIndexField {
28916
+ field: string;
28917
+ order: 'asc' | 'desc';
28918
+ }
28919
+ interface IndexMeta {
28920
+ target: Function;
28921
+ name: string;
28922
+ fields: NormalizedIndexField[];
28923
+ unique?: boolean;
28924
+ ttlSeconds?: number;
28925
+ }
28926
+ declare class MetadataStorage {
28927
+ private entities;
28928
+ private columns;
28929
+ private indexes;
28930
+ registerEntity(target: Function, options?: EntityOptions, nameHint?: string): EntityMeta;
28931
+ registerColumn(target: Function, propertyKey: string | symbol, options?: ColumnOptions): ColumnMeta;
28932
+ registerIndex(target: Function, input: {
28933
+ name?: string;
28934
+ fields: IndexField[];
28935
+ unique?: boolean;
28936
+ ttlSeconds?: number;
28937
+ }): void;
28938
+ getEntity(target: Function | object): EntityMeta | undefined;
28939
+ getColumns(target: Function | object): ColumnMeta[];
28940
+ getIndexes(target: Function | object): IndexMeta[];
28941
+ getSchema(target: Function | object): {
28942
+ entity: EntityMeta | undefined;
28943
+ columns: ColumnMeta[];
28944
+ indexes: IndexMeta[];
28945
+ };
28946
+ private defaultIndexName;
28947
+ private makeIndexKey;
28948
+ }
28949
+ declare const metadata: MetadataStorage;
28950
+ declare function Entity(options?: EntityOptions): (valueOrTarget: any, maybeContext?: unknown) => void;
28951
+ declare function Column(options?: ColumnOptions): (a: any, b: any) => void;
28952
+ declare function Index(nameOrOptions: string | IndexOptions, fields?: IndexOptions['fields']): (valueOrTarget: any, maybeContext?: unknown) => void;
28953
+ declare function getEntitySchema(target: Function | object): {
28954
+ entity: EntityMeta | undefined;
28955
+ columns: ColumnMeta[];
28956
+ indexes: IndexMeta[];
28957
+ };
28958
+ declare function getEntityName(target: Function | object): string | undefined;
28959
+ declare function getColumns(target: Function | object): ColumnMeta[];
28960
+ declare function getIndexes(target: Function | object): IndexMeta[];
28961
+
28962
+ type PrintableSchema = {
28963
+ entityName: string;
28964
+ namespace?: string;
28965
+ ttlSeconds?: number;
28966
+ versioned?: boolean;
28967
+ columns: Array<{
28968
+ name: string;
28969
+ type?: string;
28970
+ required?: boolean;
28971
+ unique?: boolean;
28972
+ index?: boolean;
28973
+ default?: unknown;
28974
+ }>;
28975
+ indexes: Array<{
28976
+ name: string;
28977
+ fields: Array<{
28978
+ field: string;
28979
+ order: "asc" | "desc";
28980
+ }>;
28981
+ unique?: boolean;
28982
+ ttlSeconds?: number;
28983
+ }>;
28984
+ };
28985
+ interface FileContentMap {
28986
+ [fileName: string]: string;
28987
+ }
28988
+ declare function extractSchemasFromSources(sources: FileContentMap): Promise<PrintableSchema[]>;
28989
+
28568
28990
  /**
28569
28991
  * 注册 Service Worker 并设置消息监听器
28570
28992
  * @param fileOps 文件操作对象,用于处理IPFS请求
@@ -28643,5 +29065,5 @@ declare global {
28643
29065
  }
28644
29066
  }
28645
29067
 
28646
- export { AIProxyModule, AIStreamResponseFlag, AuthModule, CacheModule, ClientModule, CommentModule, CommentType, CoreModuleName, DC, DatabaseModule, Direction, Ed25519PrivKey, Ed25519PubKey, Errors, FileModule, KeyManager, KeyValueModule, LogLevel, MessageModule, ModuleSystem, NFTBindStatus, OffChainOpTimes, OffChainOpTimesLimit, OffChainSpaceLimit, PeerStatus, ThemePermission, UploadStatus, UtilModule, configureLogger, createLogger, dc_protocol, dial_timeout, isServiceWorkerActive, keyExpire, registerServiceWorker, updateServiceWorker, walletOrigin, walletUrl, walletWindowName };
28647
- export type { AIChatMessage, AIChatMessageRequest, AIMessageContent, AIMessageMediaSource, AIProxyConfig, APPInfo, Account, AccountInfo, DCConnectInfo, DCContext, DCModule, EIP712SignReqMessage, FileTransmit, FunctionDef, IAICallConfig, IAppInfo, IAuthOperations, ICacheOperations, IClientOperations, ICommentOperations, IDatabaseOperations, IFileOperations, IKeyValueOperations, IMessageOperations, IUtilOperations, ModelConfig, OnStreamResponseType, ProxyCallConfig, ResponseMessage, SendMessage, SignHandler, SignReqMessage, SignReqMessageData, SignResponseMessage, ThemeAuthInfo, ThemeComment, ThemeObj, ToolDefinition, User, UserProxyCallConfig };
29068
+ export { AIProxyModule, AIStreamResponseFlag, AuthModule, BaseEntity, CacheModule, ClientModule, Column, CommentModule, CommentType, CoreModuleName, DC, DatabaseModule, Direction, Ed25519PrivKey, Ed25519PubKey, Entity, EntityRepository, Errors, FileModule, Index, KeyManager, KeyValueModule, LogLevel, MessageModule, ModuleSystem, NFTBindStatus, OffChainOpTimes, OffChainOpTimesLimit, OffChainSpaceLimit, PeerStatus, ThemePermission, UploadStatus, UtilModule, composeCompositeIndexValue, configureLogger, createLogger, dc_protocol, dial_timeout, extractSchemasFromSources, getColumns, getEntityName, getEntitySchema, getIndexes, isServiceWorkerActive, keyExpire, metadata, registerServiceWorker, updateServiceWorker, walletOrigin, walletUrl, walletWindowName };
29069
+ export type { AIChatMessage, AIChatMessageRequest, AIMessageContent, AIMessageMediaSource, AIProxyConfig, APPInfo, Account, AccountInfo, ColumnMeta, ColumnOptions, DCConnectInfo, DCContext, DCModule, EIP712SignReqMessage, EntityMeta, EntityOptions, FileTransmit, FindIndexOptions, FindValuesOptions, FunctionDef, IAICallConfig, IAppInfo, IAuthOperations, ICacheOperations, IClientOperations, ICommentOperations, IDatabaseOperations, IFileOperations, IKeyValueOperations, IMessageOperations, IUtilOperations, IndexField, IndexMeta, IndexOptions, ModelConfig, NormalizedIndexField, OnStreamResponseType, PrimitiveType, PrintableSchema, ProxyCallConfig, ResponseMessage, SendMessage, SignHandler, SignReqMessage, SignReqMessageData, SignResponseMessage, ThemeAuthInfo, ThemeComment, ThemeObj, ToolDefinition, User, UserProxyCallConfig };