@byted-apaas/server-sdk-node 1.0.14 → 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 (130) hide show
  1. package/README.md +39 -1
  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 +70 -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 +15 -1
  18. package/context/db/impl/object.js +131 -72
  19. package/context/db/impl/object.js.map +1 -0
  20. package/context/db/impl/oql/ioql.d.ts +8 -0
  21. package/context/db/impl/oql/ioql.js.map +1 -0
  22. package/context/db/impl/oql/oql.d.ts +4 -1
  23. package/context/db/impl/oql/oql.js +10 -1
  24. package/context/db/impl/oql/oql.js.map +1 -0
  25. package/context/db/impl/order.d.ts +1 -1
  26. package/context/db/impl/order.js +1 -1
  27. package/context/db/impl/order.js.map +1 -0
  28. package/context/db/impl/propertiesStore.js +1 -1
  29. package/context/db/impl/propertiesStore.js.map +1 -0
  30. package/context/db/impl/queryBuilder.d.ts +1 -0
  31. package/context/db/impl/queryBuilder.js.map +1 -0
  32. package/context/db/impl/transaction/index.d.ts +6 -3
  33. package/context/db/impl/transaction/index.js +56 -46
  34. package/context/db/impl/transaction/index.js.map +1 -0
  35. package/context/db/impl/transaction/operation.js.map +1 -0
  36. package/context/db/impl/transaction.d.ts +9 -6
  37. package/context/db/impl/transaction.js.map +1 -0
  38. package/context/globalConfig/globalConfig.js.map +1 -0
  39. package/context/integration/IIntegration.d.ts +30 -0
  40. package/context/integration/IIntegration.js +4 -0
  41. package/context/integration/impl/integration.d.ts +16 -0
  42. package/context/integration/impl/integration.js +62 -0
  43. package/context/metadata/components/common.js +3 -3
  44. package/context/metadata/components/common.js.map +1 -0
  45. package/context/metadata/components/components.d.ts +4 -4
  46. package/context/metadata/components/components.js.map +1 -0
  47. package/context/metadata/components/desktop/list.d.ts +3 -3
  48. package/context/metadata/components/desktop/list.js +23 -23
  49. package/context/metadata/components/desktop/list.js.map +1 -0
  50. package/context/metadata/components/desktop/recordDetail.d.ts +2 -2
  51. package/context/metadata/components/desktop/recordDetail.js.map +1 -0
  52. package/context/metadata/components/mobile/list.d.ts +4 -4
  53. package/context/metadata/components/mobile/list.js +1 -1
  54. package/context/metadata/components/mobile/list.js.map +1 -0
  55. package/context/metadata/metadata.d.ts +5 -6
  56. package/context/metadata/metadata.js +5 -6
  57. package/context/metadata/metadata.js.map +1 -0
  58. package/context/metadata/objects/fields.d.ts +6 -6
  59. package/context/metadata/objects/fields.js +57 -57
  60. package/context/metadata/objects/fields.js.map +1 -0
  61. package/context/metadata/objects/fields.util.d.ts +3 -3
  62. package/context/metadata/objects/fields.util.js +21 -21
  63. package/context/metadata/objects/fields.util.js.map +1 -0
  64. package/context/metadata/objects/objects.d.ts +1 -1
  65. package/context/metadata/objects/objects.js +1 -1
  66. package/context/metadata/objects/objects.js.map +1 -0
  67. package/context/metadata/types/common.d.ts +2 -2
  68. package/context/metadata/types/common.js.map +1 -0
  69. package/context/metadata/types/components.d.ts +18 -18
  70. package/context/metadata/types/components.js.map +1 -0
  71. package/context/metadata/types/objects.d.ts +93 -93
  72. package/context/metadata/types/objects.js.map +1 -0
  73. package/context/msg/msg.d.ts +2 -2
  74. package/context/msg/msg.js.map +1 -0
  75. package/context/resources/IResources.d.ts +5 -4
  76. package/context/resources/IResources.js.map +1 -0
  77. package/context/resources/impl/resources.d.ts +1 -0
  78. package/context/resources/impl/resources.js.map +1 -0
  79. package/context/tasks/tasks.d.ts +3 -3
  80. package/context/tasks/tasks.js +5 -5
  81. package/context/tasks/tasks.js.map +1 -0
  82. package/data/index.d.ts +3 -3
  83. package/data/index.js.map +1 -0
  84. package/global/application/flow/flow.d.ts +85 -0
  85. package/global/application/flow/flow.js +2 -0
  86. package/global/global.d.ts +88 -0
  87. package/global/global.js +3 -0
  88. package/hooks/api.d.ts +15 -9
  89. package/hooks/api.js +28 -23
  90. package/hooks/api.js.map +1 -0
  91. package/hooks/hooks.js +41 -0
  92. package/hooks/hooks.js.map +1 -0
  93. package/kunlun/kunlun.d.ts +5 -5
  94. package/kunlun/kunlun.js.map +1 -0
  95. package/kunlun/operator/IOperator.d.ts +16 -16
  96. package/kunlun/operator/IOperator.js.map +1 -0
  97. package/kunlun/operator/impl/expression.d.ts +5 -5
  98. package/kunlun/operator/impl/expression.js +5 -5
  99. package/kunlun/operator/impl/expression.js.map +1 -0
  100. package/kunlun/operator/impl/logic.d.ts +1 -1
  101. package/kunlun/operator/impl/logic.js +56 -39
  102. package/kunlun/operator/impl/logic.js.map +1 -0
  103. package/kunlun/operator/impl/logicV2.d.ts +8 -8
  104. package/kunlun/operator/impl/logicV2.js +23 -24
  105. package/kunlun/operator/impl/operator.d.ts +17 -17
  106. package/kunlun/operator/impl/operator.js +38 -38
  107. package/kunlun/operator/impl/operator.js.map +1 -0
  108. package/kunlun/operator/impl/operatorV2.d.ts +17 -17
  109. package/kunlun/operator/impl/operatorV2.js +38 -38
  110. package/lib/core.d.ts +3 -3
  111. package/lib/core.js.map +1 -0
  112. package/package.json +2 -2
  113. package/request/common.d.ts +1 -1
  114. package/request/common.js +4 -3
  115. package/request/constants.d.ts +1 -1
  116. package/request/constants.js +6 -6
  117. package/request/constants.js.map +1 -0
  118. package/request/faasinfra.d.ts +1 -1
  119. package/request/faasinfra.js +41 -251
  120. package/request/faasinfra.js.map +1 -0
  121. package/request/innerapi.d.ts +13 -12
  122. package/request/innerapi.js +46 -48
  123. package/request/innerapi.js.map +1 -0
  124. package/request/interface.d.ts +16 -15
  125. package/request/interface.js.map +1 -0
  126. package/request/openapi.d.ts +25 -20
  127. package/request/openapi.js +287 -164
  128. package/request/openapi.js.map +1 -0
  129. package/types/types.d.ts +13 -13
  130. package/types/types.js.map +1 -0
package/README.md CHANGED
@@ -1,7 +1,45 @@
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
- ### 版本:1.0.13|兼容升级
22
+ ### 版本:1.0.15|兼容升级
23
+ 新功能:数据操作接口支持指定鉴权身份
24
+ - 不指定: 访问数据模型时, 权限 1.0 应用默认使用系统身份鉴权, 权限 2.0 应用默认使用用户身份鉴权
25
+ - useUserAuth(): 访问数据模型时, 使用用户身份鉴权
26
+ - useSystemAuth(): 访问数据模型时, 使用系统身份鉴权
27
+ ```js
28
+ // 示例
29
+ await context.db.object("obj").findOne();
30
+ await context.db.object("obj").useUserAuth().findOne();
31
+ await context.db.object("obj").useSystemAuth().findOne();
32
+
33
+ await context.db.newTransaction().object("obj").commit();
34
+ await context.db.newTransaction().useUserAuth().object("obj").commit();
35
+ await context.db.newTransaction().useSystemAuth().object("obj").commit();
36
+
37
+ await context.db.oql("SELECT _id FROM obj").execute();
38
+ await context.db.oql("SELECT _id FROM obj").useUserAuth().execute();
39
+ await context.db.oql("SELECT _id FROM obj").useSystemAuth().execute();
40
+ ```
41
+
42
+ ### 版本:1.0.14|兼容升级
5
43
  新功能:支持流式查询 findStream
6
44
  ```js
7
45
  await context.db.object("_user").findStream(async (records) => {
@@ -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,21 +77,29 @@ 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
+ /**
90
+ * 用户级鉴权
91
+ */
92
+ useUserAuth(): this;
93
+ /**
94
+ * 系统级鉴权
95
+ */
96
+ useSystemAuth(): this;
89
97
  }
90
98
  export interface _IKAsyncEndpoint<T> {
91
99
  /**
92
100
  * 批量创建记录(为异步任务)
93
101
  * @param recordMapList 用于创建的多条记录
94
- * @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'}]
95
103
  */
96
104
  batchCreateAsync(recordMapList: _Cond<T>[]): Promise<{
97
105
  taskID: number;
@@ -113,11 +121,19 @@ export interface _IKAsyncEndpoint<T> {
113
121
  /**
114
122
  * 根据 _id 批量更新记录(为异步任务)
115
123
  * @param recordMapList 用于更新的多条记录,需对 _id 赋值
116
- * @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'}]
117
125
  */
118
126
  batchUpdateAsync(recordMapList: _Cond<T>[]): Promise<{
119
127
  taskID: number;
120
128
  }>;
129
+ /**
130
+ * 用户级鉴权
131
+ */
132
+ useUserAuth(): this;
133
+ /**
134
+ * 系统级鉴权
135
+ */
136
+ useSystemAuth(): this;
121
137
  }
122
138
  export interface _IKQuery<T> {
123
139
  /**
@@ -126,8 +142,8 @@ export interface _IKQuery<T> {
126
142
  * 无需入参,返回全部符合条件的记录
127
143
  * @example
128
144
  * ```
129
- * context.db.object("_user").where({
130
- * gender: "male"
145
+ * application.data.object('_user').where({
146
+ * gender: 'male'
131
147
  * }).findAll()
132
148
  * ```
133
149
  */
@@ -137,7 +153,7 @@ export interface _IKQuery<T> {
137
153
  * @param handler 业务处理函数
138
154
  * @example
139
155
  * ```
140
- * await context.db.object("_user").findStream(async (records) => {
156
+ * await application.data.object('_user').findStream(async (records) => {
141
157
  * // doSomething ...
142
158
  * });
143
159
  * ```
@@ -147,8 +163,8 @@ export interface _IKQuery<T> {
147
163
  * 无需入参,返回符合条件的记录,单次返回 200 条
148
164
  * @example
149
165
  * ```
150
- * context.db.object("_user").where({
151
- * gender: "male"
166
+ * application.data.object('_user').where({
167
+ * gender: 'male'
152
168
  * }).find()
153
169
  * ```
154
170
  */
@@ -157,8 +173,8 @@ export interface _IKQuery<T> {
157
173
  * 无需入参,返回排在第一位的记录
158
174
  * @example
159
175
  * ```
160
- * context.db.object("_user").where({
161
- * gender: "male"
176
+ * application.data.object('_user').where({
177
+ * gender: 'male'
162
178
  * }).findOne()
163
179
  * ```
164
180
  */
@@ -168,7 +184,7 @@ export interface _IKQuery<T> {
168
184
  * @param fieldApiNames 排序依据的字段数组,按先后顺序确定优先级
169
185
  * @example
170
186
  * ```
171
- * context.db.object("_user").orderBy(["_email", "_phoneNumber"]).find()
187
+ * application.data.object('_user').orderBy(['_email', '_phoneNumber']).find()
172
188
  * ```
173
189
  */
174
190
  orderBy<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -177,7 +193,7 @@ export interface _IKQuery<T> {
177
193
  * @param fieldApiNames 排序依据的字段,按先后顺序确定优先级,用逗号分隔
178
194
  * @example
179
195
  * ```
180
- * context.db.object("_user").orderBy("_email", "_phoneNumber").find()
196
+ * application.data.object('_user').orderBy('_email', '_phoneNumber').find()
181
197
  * ```
182
198
  */
183
199
  orderBy<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -186,7 +202,7 @@ export interface _IKQuery<T> {
186
202
  * @param fieldApiNames 排序依据的字段数组,按先后顺序确定优先级
187
203
  * @example
188
204
  * ```
189
- * context.db.object("_user").orderByDesc("_email", "_phoneNumber").find()
205
+ * application.data.object('_user').orderByDesc('_email', '_phoneNumber').find()
190
206
  * ```
191
207
  */
192
208
  orderByDesc<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -195,7 +211,7 @@ export interface _IKQuery<T> {
195
211
  * @param fieldApiNames 排序依据的字段,按先后顺序确定优先级,用逗号分隔
196
212
  * @example
197
213
  * ```
198
- * context.db.object("_user").orderByDesc("_email", "_phoneNumber").find()
214
+ * application.data.object('_user').orderByDesc('_email', '_phoneNumber').find()
199
215
  * ```
200
216
  */
201
217
  orderByDesc<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -204,7 +220,7 @@ export interface _IKQuery<T> {
204
220
  * @param fieldApiNames 需返回的字段数组
205
221
  * @example
206
222
  * ```
207
- * context.db.object("_user").select(["_name", "_email"]).find()
223
+ * application.data.object('_user').select(['_name', '_email']).find()
208
224
  * ```
209
225
  */
210
226
  select<K extends keyof T>(fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
@@ -213,18 +229,18 @@ export interface _IKQuery<T> {
213
229
  * @param fieldApiNames 需返回的字段,用逗号分隔
214
230
  * @example
215
231
  * ```
216
- * context.db.object("_user").select("_name", "_email").find()
232
+ * application.data.object('_user').select('_name', '_email').find()
217
233
  * ```
218
234
  */
219
235
  select<K extends keyof T>(...fieldApiNames: K[]): Omit<_IKQuery<T>, 'findAll'>;
220
236
  /**
221
237
  * 设置查询条件
222
238
  * @param conditionMap 对字段赋值以指定查询筛选条件
223
- * @paramExample {gender: "male"}
239
+ * @paramExample {gender: 'male'}
224
240
  * @example
225
241
  * ```
226
- * context.db.object("_user").where({
227
- * gender: "male"
242
+ * application.data.object('_user').where({
243
+ * gender: 'male'
228
244
  * }).find()
229
245
  * ```
230
246
  */
@@ -233,13 +249,23 @@ export interface _IKQuery<T> {
233
249
  * 设置查询条件
234
250
  */
235
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'>;
236
262
  /**
237
263
  * 指定分页查询的数量
238
264
  * @param limit 分页查询的数量
239
265
  * @paramExample 10
240
266
  * @example
241
267
  * ```
242
- * context.db.object("_user").limit(10)
268
+ * application.data.object('_user').limit(10)
243
269
  * ```
244
270
  */
245
271
  limit(limit: number): Omit<_IKQuery<T>, 'findAll'>;
@@ -249,7 +275,7 @@ export interface _IKQuery<T> {
249
275
  * @paramExample 0
250
276
  * @example
251
277
  * ```
252
- * context.db.object("_user").offset(0)
278
+ * application.data.object('_user').offset(0)
253
279
  * ```
254
280
  */
255
281
  offset(offset: number): Omit<_IKQuery<T>, 'findAll'>;
@@ -257,8 +283,16 @@ export interface _IKQuery<T> {
257
283
  * 指定条件的行数
258
284
  * @example
259
285
  * ```
260
- * context.db.object("_user").count()
286
+ * application.data.object('_user').count()
261
287
  * ```
262
288
  */
263
289
  count(): Promise<number>;
290
+ /**
291
+ * 用户级鉴权
292
+ */
293
+ useUserAuth(): this;
294
+ /**
295
+ * 系统级鉴权
296
+ */
297
+ useSystemAuth(): this;
264
298
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IObject.js","sourceRoot":"","sources":["IObject.ts"],"names":[],"mappings":""}