@byted-apaas/server-sdk-node 1.0.15 → 1.0.16-beta.16

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 (128) hide show
  1. package/README.md +18 -0
  2. package/application/application.d.ts +10 -8
  3. package/application/impl/impl.d.ts +8 -6
  4. package/application/impl/impl.js +6 -4
  5. package/constants/constants.js +4 -4
  6. package/constants/constants.js.map +1 -0
  7. package/context/context.d.ts +2 -71
  8. package/context/context.js +0 -16
  9. package/context/context.js.map +1 -0
  10. package/context/db/db.d.ts +12 -20
  11. package/context/db/db.js.map +1 -0
  12. package/context/db/impl/IObject.d.ts +46 -36
  13. package/context/db/impl/IObject.js.map +1 -0
  14. package/context/db/impl/db.d.ts +9 -9
  15. package/context/db/impl/db.js +6 -6
  16. package/context/db/impl/db.js.map +1 -0
  17. package/context/db/impl/object.d.ts +2 -0
  18. package/context/db/impl/object.js +74 -50
  19. package/context/db/impl/object.js.map +1 -0
  20. package/context/db/impl/oql/ioql.js.map +1 -0
  21. package/context/db/impl/oql/oql.d.ts +1 -1
  22. package/context/db/impl/oql/oql.js.map +1 -0
  23. package/context/db/impl/order.d.ts +1 -1
  24. package/context/db/impl/order.js +1 -1
  25. package/context/db/impl/order.js.map +1 -0
  26. package/context/db/impl/propertiesStore.js +1 -1
  27. package/context/db/impl/propertiesStore.js.map +1 -0
  28. package/context/db/impl/queryBuilder.d.ts +1 -0
  29. package/context/db/impl/queryBuilder.js.map +1 -0
  30. package/context/db/impl/transaction/index.d.ts +3 -3
  31. package/context/db/impl/transaction/index.js +46 -45
  32. package/context/db/impl/transaction/index.js.map +1 -0
  33. package/context/db/impl/transaction/operation.js.map +1 -0
  34. package/context/db/impl/transaction.d.ts +1 -6
  35. package/context/db/impl/transaction.js.map +1 -0
  36. package/context/globalConfig/globalConfig.js.map +1 -0
  37. package/context/integration/IIntegration.d.ts +30 -0
  38. package/context/integration/IIntegration.js +4 -0
  39. package/context/integration/impl/integration.d.ts +16 -0
  40. package/context/integration/impl/integration.js +62 -0
  41. package/context/metadata/components/common.js +3 -3
  42. package/context/metadata/components/common.js.map +1 -0
  43. package/context/metadata/components/components.d.ts +4 -4
  44. package/context/metadata/components/components.js.map +1 -0
  45. package/context/metadata/components/desktop/list.d.ts +3 -3
  46. package/context/metadata/components/desktop/list.js +23 -23
  47. package/context/metadata/components/desktop/list.js.map +1 -0
  48. package/context/metadata/components/desktop/recordDetail.d.ts +2 -2
  49. package/context/metadata/components/desktop/recordDetail.js.map +1 -0
  50. package/context/metadata/components/mobile/list.d.ts +4 -4
  51. package/context/metadata/components/mobile/list.js +1 -1
  52. package/context/metadata/components/mobile/list.js.map +1 -0
  53. package/context/metadata/metadata.d.ts +5 -6
  54. package/context/metadata/metadata.js +5 -6
  55. package/context/metadata/metadata.js.map +1 -0
  56. package/context/metadata/objects/fields.d.ts +6 -6
  57. package/context/metadata/objects/fields.js +57 -57
  58. package/context/metadata/objects/fields.js.map +1 -0
  59. package/context/metadata/objects/fields.util.d.ts +3 -3
  60. package/context/metadata/objects/fields.util.js +21 -21
  61. package/context/metadata/objects/fields.util.js.map +1 -0
  62. package/context/metadata/objects/objects.d.ts +1 -1
  63. package/context/metadata/objects/objects.js +1 -1
  64. package/context/metadata/objects/objects.js.map +1 -0
  65. package/context/metadata/types/common.d.ts +2 -2
  66. package/context/metadata/types/common.js.map +1 -0
  67. package/context/metadata/types/components.d.ts +18 -18
  68. package/context/metadata/types/components.js.map +1 -0
  69. package/context/metadata/types/objects.d.ts +93 -93
  70. package/context/metadata/types/objects.js.map +1 -0
  71. package/context/msg/msg.d.ts +2 -2
  72. package/context/msg/msg.js.map +1 -0
  73. package/context/resources/IResources.d.ts +5 -4
  74. package/context/resources/IResources.js.map +1 -0
  75. package/context/resources/impl/resources.d.ts +1 -0
  76. package/context/resources/impl/resources.js.map +1 -0
  77. package/context/tasks/tasks.d.ts +3 -3
  78. package/context/tasks/tasks.js +5 -5
  79. package/context/tasks/tasks.js.map +1 -0
  80. package/data/index.d.ts +3 -3
  81. package/data/index.js.map +1 -0
  82. package/global/application/flow/flow.d.ts +85 -0
  83. package/global/application/flow/flow.js +2 -0
  84. package/global/global.d.ts +88 -0
  85. package/global/global.js +3 -0
  86. package/hooks/api.d.ts +15 -9
  87. package/hooks/api.js +28 -23
  88. package/hooks/api.js.map +1 -0
  89. package/hooks/hooks.js +41 -0
  90. package/hooks/hooks.js.map +1 -0
  91. package/kunlun/kunlun.d.ts +5 -5
  92. package/kunlun/kunlun.js.map +1 -0
  93. package/kunlun/operator/IOperator.d.ts +16 -16
  94. package/kunlun/operator/IOperator.js.map +1 -0
  95. package/kunlun/operator/impl/expression.d.ts +5 -5
  96. package/kunlun/operator/impl/expression.js +5 -5
  97. package/kunlun/operator/impl/expression.js.map +1 -0
  98. package/kunlun/operator/impl/logic.d.ts +1 -1
  99. package/kunlun/operator/impl/logic.js +56 -39
  100. package/kunlun/operator/impl/logic.js.map +1 -0
  101. package/kunlun/operator/impl/logicV2.d.ts +8 -8
  102. package/kunlun/operator/impl/logicV2.js +23 -24
  103. package/kunlun/operator/impl/operator.d.ts +17 -17
  104. package/kunlun/operator/impl/operator.js +38 -38
  105. package/kunlun/operator/impl/operator.js.map +1 -0
  106. package/kunlun/operator/impl/operatorV2.d.ts +17 -17
  107. package/kunlun/operator/impl/operatorV2.js +38 -38
  108. package/lib/core.d.ts +3 -3
  109. package/lib/core.js.map +1 -0
  110. package/package.json +2 -2
  111. package/request/common.d.ts +1 -1
  112. package/request/common.js +4 -3
  113. package/request/constants.d.ts +1 -1
  114. package/request/constants.js +6 -6
  115. package/request/constants.js.map +1 -0
  116. package/request/faasinfra.d.ts +1 -1
  117. package/request/faasinfra.js +41 -251
  118. package/request/faasinfra.js.map +1 -0
  119. package/request/innerapi.d.ts +2 -1
  120. package/request/innerapi.js +3 -5
  121. package/request/innerapi.js.map +1 -0
  122. package/request/interface.d.ts +5 -4
  123. package/request/interface.js.map +1 -0
  124. package/request/openapi.d.ts +14 -9
  125. package/request/openapi.js +216 -153
  126. package/request/openapi.js.map +1 -0
  127. package/types/types.d.ts +13 -13
  128. package/types/types.js.map +1 -0
package/README.md CHANGED
@@ -1,5 +1,23 @@
1
1
  ## aPaaS @byted-apaas/server-sdk-node 版本说明:
2
2
 
3
+ ### 版本:1.0.18|兼容升级
4
+ 优化:包结构调整,参考文档:
5
+
6
+ -------
7
+ ### 版本:1.0.18|兼容升级
8
+ 新功能:支持开发者获取飞书集成 app access token 及 tenant access token
9
+
10
+ -------
11
+ ### 版本:1.0.17|兼容升级
12
+ 优化:废弃 flow.variables & flow.updateVariable 相关 API
13
+
14
+ -------
15
+ ### 版本:1.0.16|兼容升级
16
+ 新功能:支持模糊查询 fuzzySearch
17
+ ```js
18
+ await context.db.object("obj").fuzzySearch("keyword", ["field1", "field2"]).find();
19
+ ```
20
+
3
21
  -------
4
22
  ### 版本:1.0.15|兼容升级
5
23
  新功能:数据操作接口支持指定鉴权身份
@@ -1,9 +1,10 @@
1
- import { _IOpenSDKResources } from "../context/resources/IResources";
2
- import { ITool, IToolsExtra } from "@byted-apaas/server-common-node/kunlun/tool/Itool";
3
- import { AppCredential } from "@byted-apaas/server-common-node/credential/credential";
4
- import { IDBSync } from "../context/db/db";
5
- import { IFunction } from "./function/function";
6
- import { PlatformEnvType } from "@byted-apaas/server-common-node/constants/constants";
1
+ import { _IOpenSDKResources } from '../context/resources/IResources';
2
+ import { ITool, IToolsExtra } from '@byted-apaas/server-common-node/kunlun/tool/Itool';
3
+ import { AppCredential } from '@byted-apaas/server-common-node/credential/credential';
4
+ import { IDBSync } from '../context/db/db';
5
+ import { IFunction } from './function/function';
6
+ import { PlatformEnvType } from '@byted-apaas/server-common-node/constants/constants';
7
+ import { _IIntegration } from '../context/integration/IIntegration';
7
8
  /**
8
9
  * IApplication 为 OpenSDK 能力的核心接口
9
10
  * - data: 元数据相关能力
@@ -14,16 +15,17 @@ export interface IApplication {
14
15
  data: IDBSync;
15
16
  resources: _IOpenSDKResources;
16
17
  tools: ITool & IToolsExtra;
18
+ integration: _IIntegration;
17
19
  cloudfunction(funcName: string): IFunction;
18
20
  env(platformEnvType: PlatformEnvType): IApplication;
19
21
  localDebugMode(): IApplication;
20
22
  setLaneName(laneName: string): IApplication;
21
23
  }
22
- export type AppMode = 'openSDK' | 'faasSDK';
24
+ export declare type AppMode = 'openSDK' | 'faasSDK';
23
25
  export interface AppCtx {
24
26
  mode: AppMode;
25
27
  env?: PlatformEnvType;
26
28
  credential: AppCredential;
27
- debugType?: "0" | "2";
29
+ debugType?: '0' | '2';
28
30
  x_tt_env?: string;
29
31
  }
@@ -1,14 +1,16 @@
1
- import { ITool, IToolsExtra } from "@byted-apaas/server-common-node/kunlun/tool/Itool";
2
- import { IFunction } from "../function/function";
3
- import { IApplication } from "../application";
4
- import { _IOpenSDKResources } from "../../context/resources/IResources";
5
- import { IDBSync } from "../../context/db/db";
6
- import { PlatformEnvType } from "@byted-apaas/server-common-node/constants/constants";
1
+ import { ITool, IToolsExtra } from '@byted-apaas/server-common-node/kunlun/tool/Itool';
2
+ import { IFunction } from '../function/function';
3
+ import { IApplication } from '../application';
4
+ import { _IOpenSDKResources } from '../../context/resources/IResources';
5
+ import { IDBSync } from '../../context/db/db';
6
+ import { PlatformEnvType } from '@byted-apaas/server-common-node/constants/constants';
7
+ import { _IIntegration } from '../../context/integration/IIntegration';
7
8
  export declare class Application implements IApplication {
8
9
  private appCtx;
9
10
  data: IDBSync;
10
11
  resources: _IOpenSDKResources;
11
12
  tools: ITool & IToolsExtra;
13
+ integration: _IIntegration;
12
14
  constructor(clientID: string, clientSecret: string);
13
15
  cloudfunction(funcName: string): IFunction;
14
16
  env(platformEnvType: PlatformEnvType): IApplication;
@@ -8,16 +8,18 @@ const function_1 = require("../function/function");
8
8
  const common_1 = require("../../request/common");
9
9
  const resources_1 = require("../../context/resources/impl/resources");
10
10
  const constants_1 = require("@byted-apaas/server-common-node/constants/constants");
11
+ const integration_1 = require("../../context/integration/impl/integration");
11
12
  class Application {
12
13
  constructor(clientID, clientSecret) {
13
14
  this.appCtx = {
14
- mode: "openSDK",
15
+ mode: 'openSDK',
15
16
  credential: new credential_1.AppCredential(clientID, clientSecret),
16
- debugType: constants_1.DefaultDebugType ? constants_1.DefaultDebugType : "2",
17
- env: "online"
17
+ debugType: constants_1.DefaultDebugType ? constants_1.DefaultDebugType : '2',
18
+ env: 'online',
18
19
  };
19
20
  this.data = new db_1.ApplicationDB(this.appCtx);
20
21
  this.resources = new resources_1._OpenSDKResources(this.appCtx);
22
+ this.integration = new integration_1._OpenSDKIntegration(this.appCtx);
21
23
  this.tools = new tool_1.Tool();
22
24
  this.tools.getTenantInfo = async () => {
23
25
  return await (0, common_1.getTenantInfo)(this.appCtx);
@@ -32,7 +34,7 @@ class Application {
32
34
  }
33
35
  // 设置本地调试模式
34
36
  localDebugMode() {
35
- this.appCtx.debugType = "2";
37
+ this.appCtx.debugType = '2';
36
38
  return this;
37
39
  }
38
40
  setLaneName(laneName) {
@@ -4,15 +4,15 @@
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.triggerType = exports.httpStatusCodes = exports.httpHeaderKeys = exports.notifyModel = void 0;
6
6
  exports.notifyModel = {
7
- key: "ee.kunlun.cloudfunction.faas_buildin",
7
+ key: 'ee.kunlun.cloudfunction.faas_buildin',
8
8
  };
9
9
  exports.httpHeaderKeys = {
10
- statusCode: "X-Kunlun-Status-Code",
11
- location: "Location",
10
+ statusCode: 'X-Kunlun-Status-Code',
11
+ location: 'Location',
12
12
  };
13
13
  exports.httpStatusCodes = {
14
14
  redirect: 302,
15
15
  };
16
16
  exports.triggerType = {
17
- defaultTrigger: "default-trigger"
17
+ defaultTrigger: 'default-trigger',
18
18
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG;IACvB,GAAG,EAAE,sCAAsC;CAC9C,CAAA;AAEY,QAAA,cAAc,GAAG;IAC1B,UAAU,EAAE,sBAAsB;IAClC,QAAQ,EAAE,UAAU;CACvB,CAAA;AAEY,QAAA,eAAe,GAAG;IAC3B,QAAQ,EAAE,GAAG;CAChB,CAAA"}
@@ -1,74 +1,5 @@
1
- import { _Resources } from "./resources/impl/resources";
2
- import { Tasks } from "./tasks/tasks";
3
- import { Message } from "./msg/msg";
4
- import { IDBGetter } from "./db/db";
5
1
  import { Context as CommonContext } from '@byted-apaas/server-common-node';
6
- import { IMetaData } from "./metadata/metadata";
7
- export declare class Context<T, mt, cf, gv> extends CommonContext implements IContext<T, mt, cf, gv> {
8
- /**
9
- * 操作数据库中的记录数据
10
- */
11
- db: IDBGetter<T, mt>;
12
- /**
13
- * 元数据读写
14
- */
15
- metadata: IMetaData<mt>;
16
- /**
17
- * 静态资源类操作
18
- */
19
- resources: _Resources;
20
- /**
21
- * 全局函数
22
- * @param funcName 函数名
23
- */
24
- function(funcName: cf): {
25
- invoke: (params: any) => Promise<any>;
26
- };
27
- /**
28
- * 任务操作
29
- */
30
- tasks: Tasks<cf>;
31
- /**
32
- * 向消息中心推送及更新消息
33
- */
34
- msg: Message;
35
- /**
36
- * 根据 apiName 获取对应的全局变量
37
- * @param apiName 全局变量的 API Name
38
- */
39
- getVar<Key extends keyof gv>(apiName: Key): Promise<gv[Key]>;
2
+ export declare class Context extends CommonContext implements IContext {
40
3
  }
41
- export interface IContext<T, mt = {}, cf = "", gv = {}> {
42
- /**
43
- * 操作数据库中的记录数据
44
- */
45
- db: IDBGetter<T, mt>;
46
- /**
47
- * 元数据读写
48
- */
49
- metadata: IMetaData<mt>;
50
- /**
51
- * 静态资源类操作
52
- */
53
- resources: _Resources;
54
- /**
55
- * 全局函数
56
- * @param funcName 函数名
57
- */
58
- function(funcName: cf): {
59
- invoke: (params: any) => Promise<any>;
60
- };
61
- /**
62
- * 任务操作
63
- */
64
- tasks: Tasks<cf>;
65
- /**
66
- * 向消息中心推送及更新消息
67
- */
68
- msg: Message;
69
- /**
70
- * 根据 apiName 获取对应的全局变量
71
- * @param apiName 全局变量的 API Name
72
- */
73
- getVar<Key extends keyof gv>(apiName: Key): Promise<gv[Key]>;
4
+ export interface IContext {
74
5
  }
@@ -4,22 +4,6 @@
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.Context = void 0;
6
6
  const server_common_node_1 = require("@byted-apaas/server-common-node");
7
- // TODO MERGE cf
8
7
  class Context extends server_common_node_1.Context {
9
- /**
10
- * 全局函数
11
- * @param funcName 函数名
12
- */
13
- function(funcName) {
14
- return null;
15
- }
16
- /**
17
- * 根据 apiName 获取对应的全局变量
18
- * @param apiName 全局变量的 API Name
19
- */
20
- async getVar(apiName) {
21
- return null;
22
- }
23
- ;
24
8
  }
25
9
  exports.Context = Context;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["context.ts"],"names":[],"mappings":";;;AAIA,8DAAqE;AAGrE,gBAAgB;AAEhB,MAAa,OAAmB,SAAQ,uBAAgB;IAcpD;;;OAGG;IACH,QAAQ,CAAC,QAAyB;QAC9B,OAAO,IAAI,CAAC;IAChB,CAAC;CAiCJ;AArDD,0BAqDC"}
@@ -1,14 +1,10 @@
1
- import { currentObjApiName } from '../../data';
2
1
  import { _IKAllEndpoint, _IKSyncEndpoint, _IKQuery } from './impl/IObject';
3
2
  import { ITransactionGetter } from './impl/transaction';
4
3
  import { IOql } from './impl/oql/ioql';
5
4
  /**
6
- * - IDBGetter 是声明 DB interface 的顶级入口,在使用时应该避免直接使用 IDB 和 IDBWithCurrentObject
7
- * 应该直接使用 IDBGetter。
8
- * - 目前 IDBGetter 支持的是 currentObject 方法的动态声明,使用泛型实现,期望传入的 T 是 Context 结构。
9
- * - 如果 Context 有 objectApiName 属性,则拥有 .db.currentObject 和 .db.transaction.currentObject
5
+ * IDBGetter 是声明 DB interface 的顶级入口
10
6
  */
11
- export type IDBGetter<T, mt> = T extends {
7
+ export declare type IDBGetter<T, mt> = T extends {
12
8
  'objectApiName': string;
13
9
  } ? IDB<T, mt> & IDBWithCurrentObject<{}, mt> : IDB<{}, mt>;
14
10
  /**
@@ -20,8 +16,8 @@ export interface IDB<T, mt> {
20
16
  * @param objectApiName 指定对象的 ApiName
21
17
  * @example
22
18
  * ```
23
- * context.db.object("_user").where({
24
- * gender: "male"
19
+ * application.data.object('_user').where({
20
+ * gender: 'male'
25
21
  * }).find()
26
22
  * ```
27
23
  */
@@ -30,12 +26,12 @@ export interface IDB<T, mt> {
30
26
  * 创建一个新的空事务
31
27
  * @example
32
28
  * ```
33
- * let tx = context.db.newTransaction();
34
- * let user = tx.object("_user").registerCreate({
35
- * _name: new kunlun.type.Multilingual({ zh: "用户1", en: "user1" }),
29
+ * let tx = application.data.newTransaction();
30
+ * let user = tx.object('_user').registerCreate({
31
+ * _name: new application.constants.type.Multilingual({ zh: '用户1', en: 'user1' }),
36
32
  * });
37
- * let contract = tx.object("contract").registerCreate({
38
- * _name: new kunlun.type.Multilingual({ zh: "用户1的合同", en: "user1's contract" }),
33
+ * let contract = tx.object('contract').registerCreate({
34
+ * _name: new application.constants.type.Multilingual({ zh: '用户1的合同', en: 'user1's contract' }),
39
35
  * user: {id: user._id}
40
36
  * });
41
37
  * await tx.commit();
@@ -47,7 +43,7 @@ export interface IDB<T, mt> {
47
43
  * @param oql OQL 语句
48
44
  * @example
49
45
  * ```
50
- * let users = await context.db.oql("select _email from _user").execute();
46
+ * let users = await application.data.oql('select _email from _user').execute();
51
47
  * ```
52
48
  */
53
49
  oql(oql: string): IOql;
@@ -57,8 +53,8 @@ export interface IDB<T, mt> {
57
53
  * @param nameArgs 用于替换 OQL 语句中的占位符
58
54
  * @example
59
55
  * ```
60
- * let employees = await context.db.oql("select _email from _user where _type = $user_type",{
61
- * "user_type": "_employee",
56
+ * let employees = await application.data.oql('select _email from _user where _type = $user_type',{
57
+ * 'user_type': '_employee',
62
58
  * }).execute();
63
59
  * ```
64
60
  */
@@ -68,10 +64,6 @@ export interface IDB<T, mt> {
68
64
  * IDBWithCurrentObject 经由 IDBGetter 返回,是 DB 的动态增加的接口结构
69
65
  */
70
66
  export interface IDBWithCurrentObject<T, mt> {
71
- /**
72
- * 无需入参,操作当前对象的记录数据
73
- */
74
- currentObject(): _IKAllEndpoint<mt[currentObjApiName]> & _IKQuery<mt[currentObjApiName]>;
75
67
  }
76
68
  /**
77
69
  * IDBSync 仅包含同步调用接口,当前应用场景为 OpenSDK
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.js","sourceRoot":"","sources":["db.ts"],"names":[],"mappings":""}
@@ -5,13 +5,13 @@ export interface _IKSyncEndpoint<T> {
5
5
  /**
6
6
  * 创建记录
7
7
  * @param recordMap 用于创建的一条记录
8
- * @paramExample {_name: "John", age: 19, gender: "male"}
8
+ * @paramExample {_name: 'John', age: 19, gender: 'male'}
9
9
  * @example
10
10
  * ```
11
- * context.db.object("_department").create({
12
- * _name: new kunlun.type.Multilingual({ zh: "部门" }),
11
+ * application.data.object('_department').create({
12
+ * _name: new application.constants.type.Multilingual({ zh: '部门' }),
13
13
  * _manager: { _id: 1660000000 },
14
- * _status: "_active"
14
+ * _status: '_active'
15
15
  * })
16
16
  * ```
17
17
  */
@@ -23,7 +23,7 @@ export interface _IKSyncEndpoint<T> {
23
23
  * @param recordID 用于删除的一条记录的 ID
24
24
  * @example
25
25
  * ```
26
- * context.db.object("_user").delete(123456789123)
26
+ * application.data.object('_user').delete(123456789123)
27
27
  * ```
28
28
  */
29
29
  delete(recordID: number): Promise<void>;
@@ -32,7 +32,7 @@ export interface _IKSyncEndpoint<T> {
32
32
  * @param record 用于删除的一条完整记录
33
33
  * @example
34
34
  * ```
35
- * context.db.object("_user").delete(context.targetRecord.original)
35
+ * application.data.object('_user').delete(context.targetRecord.original)
36
36
  * ```
37
37
  */
38
38
  delete(record: _Cond<T>): Promise<void>;
@@ -40,11 +40,11 @@ export interface _IKSyncEndpoint<T> {
40
40
  * 指定 _id 后,更新对应记录
41
41
  * @param _id 主键
42
42
  * @param recordMap 用于更新的一条记录
43
- * @paramExample {_name: "John", age: 19, gender: "male"}
43
+ * @paramExample {_name: 'John', age: 19, gender: 'male'}
44
44
  * @example
45
45
  * ```
46
- * context.db.object("_user").update(1660000000, {
47
- * gender: "male"
46
+ * application.data.object('_user').update(1660000000, {
47
+ * gender: 'male'
48
48
  * })
49
49
  * ```
50
50
  */
@@ -52,12 +52,12 @@ export interface _IKSyncEndpoint<T> {
52
52
  /**
53
53
  * 指定 _id 后,更新对应记录
54
54
  * @param recordMap 用于更新的一条记录,需对 _id 赋值
55
- * @paramExample {_id: 1660000000, _name: "John", age: 19, gender: "male"}
55
+ * @paramExample {_id: 1660000000, _name: 'John', age: 19, gender: 'male'}
56
56
  * @example
57
57
  * ```
58
- * context.db.object("_user").update({
58
+ * application.data.object('_user').update({
59
59
  * _id: 1660000000,
60
- * gender: "male"
60
+ * gender: 'male'
61
61
  * })
62
62
  * ```
63
63
  */
@@ -65,7 +65,7 @@ export interface _IKSyncEndpoint<T> {
65
65
  /**
66
66
  * 批量创建记录
67
67
  * @param recordMapList 多条用于创建的记录数据组成的数组
68
- * @paramExample [{_name: "John", age: 19, gender: "male"}, {_name: "Alis", age: 16, gender: "female"}]
68
+ * @paramExample [{_name: 'John', age: 19, gender: 'male'}, {_name: 'Alis', age: 16, gender: 'female'}]
69
69
  */
70
70
  batchCreate(recordMapList: _Cond<T>[]): Promise<number[]>;
71
71
  /**
@@ -77,13 +77,13 @@ export interface _IKSyncEndpoint<T> {
77
77
  /**
78
78
  * 批量删除记录
79
79
  * @param recordList 多条用于删除的记录数据组成的数组,记录数据需对 _id 赋值
80
- * @paramExample [{_id: 1001, _name: "John", gender: "male"}, {_id: 1002, _name: "Alis", gender: "female"}]
80
+ * @paramExample [{_id: 1001, _name: 'John', gender: 'male'}, {_id: 1002, _name: 'Alis', gender: 'female'}]
81
81
  */
82
82
  batchDelete(recordList: _Cond<T>[]): Promise<void>;
83
83
  /**
84
84
  * 根据 _id 批量更新记录
85
85
  * @param recordMapList 多条用于更新的记录数据组成的数组,记录数据需对 _id 赋值
86
- * @paramExample [{_id: 1001, _name: "John", gender: "male"}, {_id: 1002, _name: "Alis", gender: "female"}]
86
+ * @paramExample [{_id: 1001, _name: 'John', gender: 'male'}, {_id: 1002, _name: 'Alis', gender: 'female'}]
87
87
  */
88
88
  batchUpdate(recordMapList: _Cond<T>[]): Promise<void>;
89
89
  /**
@@ -99,7 +99,7 @@ export interface _IKAsyncEndpoint<T> {
99
99
  /**
100
100
  * 批量创建记录(为异步任务)
101
101
  * @param recordMapList 用于创建的多条记录
102
- * @paramExample [{_name: "John", age: 19, gender: "male"}, {_name: "Alis", age: 16, gender: "female"}]
102
+ * @paramExample [{_name: 'John', age: 19, gender: 'male'}, {_name: 'Alis', age: 16, gender: 'female'}]
103
103
  */
104
104
  batchCreateAsync(recordMapList: _Cond<T>[]): Promise<{
105
105
  taskID: number;
@@ -121,7 +121,7 @@ export interface _IKAsyncEndpoint<T> {
121
121
  /**
122
122
  * 根据 _id 批量更新记录(为异步任务)
123
123
  * @param recordMapList 用于更新的多条记录,需对 _id 赋值
124
- * @paramExample [{_id: 1001, _name: "John", gender: "male"}, {_id: 1002, _name: "Alis", gender: "female"}]
124
+ * @paramExample [{_id: 1001, _name: 'John', gender: 'male'}, {_id: 1002, _name: 'Alis', gender: 'female'}]
125
125
  */
126
126
  batchUpdateAsync(recordMapList: _Cond<T>[]): Promise<{
127
127
  taskID: number;
@@ -142,8 +142,8 @@ export interface _IKQuery<T> {
142
142
  * 无需入参,返回全部符合条件的记录
143
143
  * @example
144
144
  * ```
145
- * context.db.object("_user").where({
146
- * gender: "male"
145
+ * application.data.object('_user').where({
146
+ * gender: 'male'
147
147
  * }).findAll()
148
148
  * ```
149
149
  */
@@ -153,7 +153,7 @@ export interface _IKQuery<T> {
153
153
  * @param handler 业务处理函数
154
154
  * @example
155
155
  * ```
156
- * await context.db.object("_user").findStream(async (records) => {
156
+ * await application.data.object('_user').findStream(async (records) => {
157
157
  * // doSomething ...
158
158
  * });
159
159
  * ```
@@ -163,8 +163,8 @@ export interface _IKQuery<T> {
163
163
  * 无需入参,返回符合条件的记录,单次返回 200 条
164
164
  * @example
165
165
  * ```
166
- * context.db.object("_user").where({
167
- * gender: "male"
166
+ * application.data.object('_user').where({
167
+ * gender: 'male'
168
168
  * }).find()
169
169
  * ```
170
170
  */
@@ -173,8 +173,8 @@ export interface _IKQuery<T> {
173
173
  * 无需入参,返回排在第一位的记录
174
174
  * @example
175
175
  * ```
176
- * context.db.object("_user").where({
177
- * gender: "male"
176
+ * application.data.object('_user').where({
177
+ * gender: 'male'
178
178
  * }).findOne()
179
179
  * ```
180
180
  */
@@ -184,7 +184,7 @@ export interface _IKQuery<T> {
184
184
  * @param fieldApiNames 排序依据的字段数组,按先后顺序确定优先级
185
185
  * @example
186
186
  * ```
187
- * context.db.object("_user").orderBy(["_email", "_phoneNumber"]).find()
187
+ * application.data.object('_user').orderBy(['_email', '_phoneNumber']).find()
188
188
  * ```
189
189
  */
190
190
  orderBy<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -193,7 +193,7 @@ export interface _IKQuery<T> {
193
193
  * @param fieldApiNames 排序依据的字段,按先后顺序确定优先级,用逗号分隔
194
194
  * @example
195
195
  * ```
196
- * context.db.object("_user").orderBy("_email", "_phoneNumber").find()
196
+ * application.data.object('_user').orderBy('_email', '_phoneNumber').find()
197
197
  * ```
198
198
  */
199
199
  orderBy<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -202,7 +202,7 @@ export interface _IKQuery<T> {
202
202
  * @param fieldApiNames 排序依据的字段数组,按先后顺序确定优先级
203
203
  * @example
204
204
  * ```
205
- * context.db.object("_user").orderByDesc("_email", "_phoneNumber").find()
205
+ * application.data.object('_user').orderByDesc('_email', '_phoneNumber').find()
206
206
  * ```
207
207
  */
208
208
  orderByDesc<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -211,7 +211,7 @@ export interface _IKQuery<T> {
211
211
  * @param fieldApiNames 排序依据的字段,按先后顺序确定优先级,用逗号分隔
212
212
  * @example
213
213
  * ```
214
- * context.db.object("_user").orderByDesc("_email", "_phoneNumber").find()
214
+ * application.data.object('_user').orderByDesc('_email', '_phoneNumber').find()
215
215
  * ```
216
216
  */
217
217
  orderByDesc<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -220,7 +220,7 @@ export interface _IKQuery<T> {
220
220
  * @param fieldApiNames 需返回的字段数组
221
221
  * @example
222
222
  * ```
223
- * context.db.object("_user").select(["_name", "_email"]).find()
223
+ * application.data.object('_user').select(['_name', '_email']).find()
224
224
  * ```
225
225
  */
226
226
  select<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -229,18 +229,18 @@ export interface _IKQuery<T> {
229
229
  * @param fieldApiNames 需返回的字段,用逗号分隔
230
230
  * @example
231
231
  * ```
232
- * context.db.object("_user").select("_name", "_email").find()
232
+ * application.data.object('_user').select('_name', '_email').find()
233
233
  * ```
234
234
  */
235
235
  select<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
236
236
  /**
237
237
  * 设置查询条件
238
238
  * @param conditionMap 对字段赋值以指定查询筛选条件
239
- * @paramExample {gender: "male"}
239
+ * @paramExample {gender: 'male'}
240
240
  * @example
241
241
  * ```
242
- * context.db.object("_user").where({
243
- * gender: "male"
242
+ * application.data.object('_user').where({
243
+ * gender: 'male'
244
244
  * }).find()
245
245
  * ```
246
246
  */
@@ -249,13 +249,23 @@ export interface _IKQuery<T> {
249
249
  * 设置查询条件
250
250
  */
251
251
  where(): Omit<_IKQuery<T>, 'findAll'>;
252
+ /**
253
+ * 模糊查询:与 where 之间是与关系
254
+ * @param keyword 模糊查询的关键字,必填且不可以为空串
255
+ * @param fieldAPINames 『可搜索字段』的字段列表,不可为空
256
+ * @example
257
+ * ```
258
+ * application.data.object('_user').fuzzySearch('张三', ['_name']).find()
259
+ * ```
260
+ */
261
+ fuzzySearch(keyword: string, fieldAPINames: string[]): Omit<_IKQuery<T>, 'findAll'>;
252
262
  /**
253
263
  * 指定分页查询的数量
254
264
  * @param limit 分页查询的数量
255
265
  * @paramExample 10
256
266
  * @example
257
267
  * ```
258
- * context.db.object("_user").limit(10)
268
+ * application.data.object('_user').limit(10)
259
269
  * ```
260
270
  */
261
271
  limit(limit: number): Omit<_IKQuery<T>, 'findAll'>;
@@ -265,7 +275,7 @@ export interface _IKQuery<T> {
265
275
  * @paramExample 0
266
276
  * @example
267
277
  * ```
268
- * context.db.object("_user").offset(0)
278
+ * application.data.object('_user').offset(0)
269
279
  * ```
270
280
  */
271
281
  offset(offset: number): Omit<_IKQuery<T>, 'findAll'>;
@@ -273,7 +283,7 @@ export interface _IKQuery<T> {
273
283
  * 指定条件的行数
274
284
  * @example
275
285
  * ```
276
- * context.db.object("_user").count()
286
+ * application.data.object('_user').count()
277
287
  * ```
278
288
  */
279
289
  count(): Promise<number>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IObject.js","sourceRoot":"","sources":["IObject.ts"],"names":[],"mappings":""}
@@ -2,8 +2,8 @@ import { _IKAllEndpoint, _IKSyncEndpoint, _IKQuery } from './IObject';
2
2
  import { ITransactionGetter } from './transaction';
3
3
  import { IDB, IDBSync, IDBWithCurrentObject } from '../db';
4
4
  import { currentObjApiName, metadataMap } from '../../../data/index';
5
- import { IOql } from "./oql/ioql";
6
- import { AppCtx } from "../../../application/application";
5
+ import { IOql } from './oql/ioql';
6
+ import { AppCtx } from '../../../application/application';
7
7
  export declare class DB<T, mt = metadataMap> implements IDB<T, mt> {
8
8
  objectApiName: string;
9
9
  constructor(objectApiName?: string);
@@ -12,8 +12,8 @@ export declare class DB<T, mt = metadataMap> implements IDB<T, mt> {
12
12
  * @param objectApiName 指定对象的 ApiName
13
13
  * @example
14
14
  * ```
15
- * context.db.object("_user").where({
16
- * gender: "male"
15
+ * context.db.object('_user').where({
16
+ * gender: 'male'
17
17
  * }).find()
18
18
  * ```
19
19
  */
@@ -23,11 +23,11 @@ export declare class DB<T, mt = metadataMap> implements IDB<T, mt> {
23
23
  * @example
24
24
  * ```
25
25
  * let tx = context.db.newTransaction();
26
- * let user = tx.object("_user").registerCreate({
27
- * _name: new kunlun.type.Multilingual({ zh: "用户1", en: "user1" }),
26
+ * let user = tx.object('_user').registerCreate({
27
+ * _name: new kunlun.type.Multilingual({ zh: '用户1', en: 'user1' }),
28
28
  * });
29
- * let contract = tx.object("contract").registerCreate({
30
- * _name: new kunlun.type.Multilingual({ zh: "用户1的合同", en: "user1's contract" }),
29
+ * let contract = tx.object('contract').registerCreate({
30
+ * _name: new kunlun.type.Multilingual({ zh: '用户1的合同', en: 'user1's contract' }),
31
31
  * user: {id: user._id}
32
32
  * });
33
33
  * await tx.commit();
@@ -39,7 +39,7 @@ export declare class DB<T, mt = metadataMap> implements IDB<T, mt> {
39
39
  * @param oql 指定 OQL 语句
40
40
  * @example
41
41
  * ```
42
- * let users = await context.db.oql("select _email from _user").execute();
42
+ * let users = await context.db.oql('select _email from _user').execute();
43
43
  * ```
44
44
  */
45
45
  oql(oql: string): IOql;