@byted-apaas/server-sdk-node 0.0.1-beta.3

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 (163) hide show
  1. package/LICENSE +7 -0
  2. package/NOTICE +3 -0
  3. package/README.md +1 -0
  4. package/application/application.d.ts +27 -0
  5. package/application/application.js +2 -0
  6. package/application/application.ts +40 -0
  7. package/application/function/function.d.ts +14 -0
  8. package/application/function/function.js +21 -0
  9. package/application/function/function.ts +37 -0
  10. package/application/impl/common.d.ts +2 -0
  11. package/application/impl/common.js +50 -0
  12. package/application/impl/common.ts +50 -0
  13. package/application/impl/impl.d.ts +16 -0
  14. package/application/impl/impl.js +38 -0
  15. package/application/impl/impl.ts +48 -0
  16. package/constants/constants.d.ts +10 -0
  17. package/constants/constants.js +15 -0
  18. package/constants/constants.ts +15 -0
  19. package/context/context.d.ts +74 -0
  20. package/context/context.js +25 -0
  21. package/context/context.ts +130 -0
  22. package/context/db/db.d.ts +73 -0
  23. package/context/db/db.js +4 -0
  24. package/context/db/db.ts +80 -0
  25. package/context/db/impl/IObject.d.ts +251 -0
  26. package/context/db/impl/IObject.js +5 -0
  27. package/context/db/impl/IObject.ts +247 -0
  28. package/context/db/impl/db.d.ts +61 -0
  29. package/context/db/impl/db.js +86 -0
  30. package/context/db/impl/db.ts +95 -0
  31. package/context/db/impl/object.d.ts +92 -0
  32. package/context/db/impl/object.js +524 -0
  33. package/context/db/impl/object.ts +631 -0
  34. package/context/db/impl/oql/ioql.d.ts +6 -0
  35. package/context/db/impl/oql/ioql.js +4 -0
  36. package/context/db/impl/oql/ioql.ts +9 -0
  37. package/context/db/impl/oql/oql.d.ts +8 -0
  38. package/context/db/impl/oql/oql.js +21 -0
  39. package/context/db/impl/oql/oql.ts +25 -0
  40. package/context/db/impl/order.d.ts +9 -0
  41. package/context/db/impl/order.js +15 -0
  42. package/context/db/impl/order.ts +19 -0
  43. package/context/db/impl/propertiesStore.d.ts +8 -0
  44. package/context/db/impl/propertiesStore.js +29 -0
  45. package/context/db/impl/propertiesStore.ts +31 -0
  46. package/context/db/impl/queryBuilder.d.ts +29 -0
  47. package/context/db/impl/queryBuilder.js +78 -0
  48. package/context/db/impl/queryBuilder.ts +106 -0
  49. package/context/db/impl/transaction/index.d.ts +20 -0
  50. package/context/db/impl/transaction/index.js +277 -0
  51. package/context/db/impl/transaction/index.ts +340 -0
  52. package/context/db/impl/transaction/operation.d.ts +27 -0
  53. package/context/db/impl/transaction/operation.js +69 -0
  54. package/context/db/impl/transaction/operation.ts +72 -0
  55. package/context/db/impl/transaction.d.ts +67 -0
  56. package/context/db/impl/transaction.js +4 -0
  57. package/context/db/impl/transaction.ts +79 -0
  58. package/context/globalConfig/globalConfig.d.ts +7 -0
  59. package/context/globalConfig/globalConfig.js +16 -0
  60. package/context/globalConfig/globalConfig.ts +14 -0
  61. package/context/metadata/components/common.d.ts +6 -0
  62. package/context/metadata/components/common.js +17 -0
  63. package/context/metadata/components/common.ts +22 -0
  64. package/context/metadata/components/components.d.ts +12 -0
  65. package/context/metadata/components/components.js +19 -0
  66. package/context/metadata/components/components.ts +22 -0
  67. package/context/metadata/components/desktop/list.d.ts +16 -0
  68. package/context/metadata/components/desktop/list.js +402 -0
  69. package/context/metadata/components/desktop/list.ts +457 -0
  70. package/context/metadata/components/desktop/recordDetail.d.ts +11 -0
  71. package/context/metadata/components/desktop/recordDetail.js +53 -0
  72. package/context/metadata/components/desktop/recordDetail.ts +67 -0
  73. package/context/metadata/components/mobile/list.d.ts +24 -0
  74. package/context/metadata/components/mobile/list.js +145 -0
  75. package/context/metadata/components/mobile/list.ts +179 -0
  76. package/context/metadata/metadata.d.ts +61 -0
  77. package/context/metadata/metadata.js +103 -0
  78. package/context/metadata/metadata.ts +178 -0
  79. package/context/metadata/objects/fields.d.ts +130 -0
  80. package/context/metadata/objects/fields.js +334 -0
  81. package/context/metadata/objects/fields.ts +457 -0
  82. package/context/metadata/objects/fields.util.d.ts +40 -0
  83. package/context/metadata/objects/fields.util.js +319 -0
  84. package/context/metadata/objects/fields.util.ts +360 -0
  85. package/context/metadata/objects/objects.d.ts +11 -0
  86. package/context/metadata/objects/objects.js +20 -0
  87. package/context/metadata/objects/objects.ts +30 -0
  88. package/context/metadata/types/common.d.ts +6 -0
  89. package/context/metadata/types/common.js +9 -0
  90. package/context/metadata/types/common.ts +13 -0
  91. package/context/metadata/types/components.d.ts +90 -0
  92. package/context/metadata/types/components.js +4 -0
  93. package/context/metadata/types/components.ts +108 -0
  94. package/context/metadata/types/objects.d.ts +226 -0
  95. package/context/metadata/types/objects.js +4 -0
  96. package/context/metadata/types/objects.ts +254 -0
  97. package/context/msg/msg.d.ts +38 -0
  98. package/context/msg/msg.js +35 -0
  99. package/context/msg/msg.ts +52 -0
  100. package/context/resources/IResources.d.ts +66 -0
  101. package/context/resources/IResources.js +2 -0
  102. package/context/resources/IResources.ts +73 -0
  103. package/context/resources/impl/resources.d.ts +42 -0
  104. package/context/resources/impl/resources.js +150 -0
  105. package/context/resources/impl/resources.ts +173 -0
  106. package/context/tasks/tasks.d.ts +33 -0
  107. package/context/tasks/tasks.js +139 -0
  108. package/context/tasks/tasks.ts +159 -0
  109. package/data/index.d.ts +27 -0
  110. package/data/index.js +4 -0
  111. package/data/index.ts +30 -0
  112. package/hooks/api.d.ts +61 -0
  113. package/hooks/api.js +327 -0
  114. package/hooks/api.ts +341 -0
  115. package/hooks/hooks.d.ts +1 -0
  116. package/hooks/hooks.js +88 -0
  117. package/hooks/hooks.ts +100 -0
  118. package/kunlun/kunlun.d.ts +55 -0
  119. package/kunlun/kunlun.js +58 -0
  120. package/kunlun/kunlun.ts +72 -0
  121. package/kunlun/operator/IOperator.d.ts +158 -0
  122. package/kunlun/operator/IOperator.js +4 -0
  123. package/kunlun/operator/IOperator.ts +166 -0
  124. package/kunlun/operator/impl/expression.d.ts +47 -0
  125. package/kunlun/operator/impl/expression.js +56 -0
  126. package/kunlun/operator/impl/expression.ts +74 -0
  127. package/kunlun/operator/impl/logic.d.ts +50 -0
  128. package/kunlun/operator/impl/logic.js +509 -0
  129. package/kunlun/operator/impl/logic.ts +598 -0
  130. package/kunlun/operator/impl/logicV2.d.ts +58 -0
  131. package/kunlun/operator/impl/logicV2.js +200 -0
  132. package/kunlun/operator/impl/logicV2.ts +254 -0
  133. package/kunlun/operator/impl/operator.d.ts +179 -0
  134. package/kunlun/operator/impl/operator.js +222 -0
  135. package/kunlun/operator/impl/operator.ts +258 -0
  136. package/kunlun/operator/impl/operatorV2.d.ts +180 -0
  137. package/kunlun/operator/impl/operatorV2.js +216 -0
  138. package/kunlun/operator/impl/operatorV2.ts +249 -0
  139. package/lib/core.d.ts +4 -0
  140. package/lib/core.js +19 -0
  141. package/lib/core.ts +7 -0
  142. package/package.json +50 -0
  143. package/request/common.d.ts +13 -0
  144. package/request/common.js +87 -0
  145. package/request/common.ts +91 -0
  146. package/request/constants.d.ts +10 -0
  147. package/request/constants.js +25 -0
  148. package/request/constants.ts +25 -0
  149. package/request/faasinfra.d.ts +8 -0
  150. package/request/faasinfra.js +358 -0
  151. package/request/faasinfra.ts +393 -0
  152. package/request/innerapi.d.ts +67 -0
  153. package/request/innerapi.js +1412 -0
  154. package/request/innerapi.ts +1648 -0
  155. package/request/interface.d.ts +95 -0
  156. package/request/interface.js +41 -0
  157. package/request/interface.ts +169 -0
  158. package/request/openapi.d.ts +69 -0
  159. package/request/openapi.js +1014 -0
  160. package/request/openapi.ts +1223 -0
  161. package/types/types.d.ts +79 -0
  162. package/types/types.js +4 -0
  163. package/types/types.ts +108 -0
@@ -0,0 +1,254 @@
1
+ // Copyright 2022 ByteDance Ltd. and/or its affiliates
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import {I18ns} from "./common";
5
+
6
+ export interface BaseFieldType {
7
+ type: string;
8
+ apiName: string;
9
+ label: I18ns;
10
+ }
11
+
12
+ export interface KTextFieldType extends BaseFieldType {
13
+ required: boolean; // 默认值:false
14
+ unique: boolean; // 默认值:false
15
+ caseSensitive: boolean; // unique 为 false 时生效,默认值:true
16
+ multiline: boolean; // 默认值:false
17
+ maxLength: number; // 默认值:1000
18
+ validationRegex: string; // 正则校验的表达式
19
+ errorMsg: I18ns;
20
+ }
21
+
22
+ export interface RichTextType extends BaseFieldType {
23
+ required: boolean; // 默认值:false
24
+ maxLength: number;
25
+ }
26
+
27
+ export interface MultilingualType extends BaseFieldType {
28
+ required: boolean; // 默认值:false
29
+ unique: boolean; // 默认值:false
30
+ caseSensitive: boolean; // unique 为 ture 时生效,默认值:true
31
+ multiline: boolean; // 默认值:false
32
+ maxLength: number; // 默认值:1000
33
+ }
34
+
35
+ export interface NumberType extends BaseFieldType {
36
+ required: boolean; // 默认值:false
37
+ unique: boolean; // 默认值:false
38
+ displayAsPercentage: boolean; // 默认值:false
39
+ decimalPlacesNumber: number;
40
+ }
41
+
42
+ export interface KDateType extends BaseFieldType {
43
+ required: boolean; // 默认值:false
44
+ }
45
+
46
+ export interface DateTimeType extends BaseFieldType {
47
+ required: boolean; // 默认值:false
48
+ }
49
+
50
+ export type SubOptionType = {
51
+ label: I18ns;
52
+ apiName: string;
53
+ description: I18ns;
54
+ color: ("grey" | "blue" | "cyan" | "green" | "yellow" | "orange" | "red" | "magenta" | "purple" | "blueMagenta"); // 按色阶顺序给默认值
55
+ active: boolean; // 默认值: true
56
+ }
57
+
58
+ export interface OptionType extends BaseFieldType {
59
+ required: boolean; // 默认值:false
60
+ multiple: boolean; // 默认值:false
61
+ optionSource: ("custom" | "global"); // 对应选项字段的「选项来源」属性(分为「自定义选项」和「使用全局选项), 默认值:"custom"
62
+ globalOptionApiName: string; // 关联全局选项的 apiName(创建字段时,设定 optionSource 为 "custom",则无需传入,且生成的元数据中不包含该属性)
63
+ optionList: SubOptionType[];
64
+ }
65
+
66
+ export interface Email extends BaseFieldType {
67
+ required: boolean; // 默认值:false
68
+ unique: boolean; // 默认值:false
69
+ }
70
+
71
+ export interface MobileNumber extends BaseFieldType {
72
+ required: boolean; // 默认值:false
73
+ unique: boolean; // 默认值:false
74
+ }
75
+
76
+ export interface Boolean extends BaseFieldType {
77
+ descriptionWhenTrue: I18ns;
78
+ descriptionWhenFalse: I18ns;
79
+ defaultValue: boolean;
80
+ }
81
+
82
+ export interface AvatarOrLogo extends BaseFieldType {
83
+ displayStyle: ("square" | "round"); // 默认值:"square"
84
+ }
85
+
86
+ export interface SortConditionType {
87
+ fieldApiName: string;
88
+ sort: ("asc" | "desc") // 默认值:"asc"
89
+ }
90
+
91
+ type ConditionType = {
92
+ left: {
93
+ objectApiName: string;
94
+ fieldApiName: string;
95
+ };
96
+ operator: ("eq" | "neq" | "in" | "notIn" | "empty" | "notEmpty" | "lte" | "gte" | "hasAllOf" | "hasNoneOf" | "hasAnyOf");
97
+ valueType: ("reference" | "specified");
98
+ right: (object | string); // 当 valueType 为 "reference" 时,值类型同 left 属性;若为 "specified",值类型则为固定的字符串值
99
+ }
100
+
101
+ type CriterionType = {
102
+ conditions: ConditionType[]; // filter 条件
103
+ logic: string;
104
+ }
105
+
106
+ export type FilterType = {
107
+ label: string; // 对应为查找字段设置过滤条件中的「名称」属性
108
+ needTriggerCriterion: boolean; // 默认值:false
109
+ triggerCriterion: CriterionType
110
+ criterion: CriterionType
111
+ errorMsg: I18ns;
112
+ }
113
+
114
+ export interface Lookup extends BaseFieldType {
115
+ required: boolean; // 默认值:false
116
+ multiple: boolean; // 默认值:false,对应查找字段的「关联记录数」属性(分为「单条」和「多条」)
117
+ objectApiName: string; // 字段 look up 的对象
118
+ hierarchy: boolean; // 默认值:false,multiple 为 false 时生效
119
+ displayStyle: ("search" | "dropDown" | "tree"); // 默认值:"dropDown",对应查找字段的「关联记录展示方式」属性,仅当 hierarchy 为 true 时才可设置为 "tree"
120
+ sortConditions: SortConditionType[];
121
+ filter: FilterType[];
122
+ }
123
+
124
+ export interface FormulaType extends BaseFieldType {
125
+ returnType: string; // 对应公式字段的「公式返回值类型」属性
126
+ formula: I18ns;
127
+ }
128
+
129
+ export interface AutoIDType extends BaseFieldType {
130
+ generateMethod: ("random" | "incremental"); // 默认值: "random"
131
+ digitsNumber: number;
132
+ prefix: string;
133
+ suffix: string;
134
+ }
135
+
136
+ export interface ReferenceFieldType extends BaseFieldType {
137
+ guideFieldApiName: string;
138
+ fieldApiName: string;
139
+ }
140
+
141
+ export interface FileType extends BaseFieldType {
142
+ required: boolean; // 默认值: false
143
+ multiple: boolean; // 默认值: false
144
+ fileTypes: string[]; // 支持 "jpeg"|"jpg"|"png"|"gif"|"pdf"|"docx"|"doc"|"xlsx"|"xls"|"pptx"|"ppt"|"csv"|"txt"|"json"|"mp4"|"zip"|"rar",同时支持 "*.doc" 的描述方式,当为空数组,或 null、undefined 时,默认支持「全部类型」
145
+ }
146
+
147
+ export interface BackLookuType extends BaseFieldType {
148
+ objectApiName: string;
149
+ fieldApiName: string; // 由于下游提供仍是 api ID 版本,因此禁用
150
+ }
151
+
152
+ export interface CompositeType extends BaseFieldType {
153
+ compositeTypeApiName: string; // 关联组合类型的 apiName,「主子对象」需求调整后,将不存在该 key
154
+ subFields: BaseFieldType[]; // 组合类型中的子字段的元数据
155
+ required: boolean; // 默认值: false
156
+ multiple: boolean; // 默认值: false
157
+ }
158
+
159
+ export interface ExtractSingleRecordType extends BaseFieldType {
160
+ compositeTypeApiName: string; // 关联组合类型的 apiName,「主子对象」需求调整后,将调整为「子表单」类型字段的 apiName
161
+ subFields: BaseFieldType[]; // 组合类型中的子字段的元数据
162
+ filter: FilterType[];
163
+ sortConditions: SortConditionType[];
164
+ recordPosition: number; // 默认值: 1,对应多值取单值字段的「返回记录」(分为「第一条」、「最后一条」和「第 {{n}} 条」),取值为正整数时为相应位置的记录,取值为 -1 时为「最后一条」记录
165
+ }
166
+
167
+ export type FieldType = {
168
+ "allow_search": boolean,
169
+ "api_name": string,
170
+ "calculated": boolean,
171
+ "description": I18ns,
172
+ "domain": number,
173
+ "encryption_mode": string,
174
+ "field_permission": number,
175
+ "formula_id": number,
176
+ "id": number,
177
+ "indexed": number,
178
+ "inherit_settings": object,
179
+ "is_encrypted": boolean,
180
+ "is_inherit": boolean,
181
+ "is_progress_field": boolean,
182
+ "label": I18ns,
183
+ "namespace": string,
184
+ "object_api_name": string,
185
+ "object_id": number,
186
+ "order": number,
187
+ "required": boolean,
188
+ "tenant_id": number,
189
+ "type": {
190
+ "name": string,
191
+ "settings": {
192
+ "multiline": boolean,
193
+ "text_version": number,
194
+ "decimal_places": number,
195
+ "display_as_percentage": boolean,
196
+ "placeholder": object,
197
+ "max_length": number,
198
+ "regexp_expression": string,
199
+ "regexp_err_msg": I18ns,
200
+ "is_array": boolean,
201
+ "option_type": string,
202
+ "related_to_global_option": {
203
+ "apiName": string,
204
+ "id": number,
205
+ "name": string,
206
+ },
207
+ "options": {
208
+ "name": I18ns,
209
+ "api_name": string,
210
+ "description": I18ns,
211
+ "color_id": string,
212
+ "active": boolean,
213
+ }[],
214
+ "description_if_true": I18ns,
215
+ "description_if_false": I18ns,
216
+ "display_style": string,
217
+ "default_value": boolean,
218
+ "referenced_object_api_name": string,
219
+ "is_hierarchy": boolean,
220
+ "return_type": string,
221
+ "formulas": I18ns,
222
+ "generation_method": string,
223
+ "digits": number,
224
+ "prefix": string,
225
+ "suffix": string,
226
+ "target_referenced_object_api_name": string,
227
+ "target_reference_field_api_name": string,
228
+ "multiple": boolean,
229
+ "mime_types": string[],
230
+ "related_to_object_api_name": string,
231
+ "related_to_field_api_name": string,
232
+ "related_to_api_name": string,
233
+ "related_to_fields": object[],
234
+ "filter": FilterType[],
235
+ "sort": {
236
+ "field": string,
237
+ "type": "string",
238
+ "direction": ("asc" | "desc")
239
+ }[],
240
+ "filter_record": {
241
+ "index": number,
242
+ "type": string,
243
+ },
244
+ "is_extract": boolean,
245
+ }
246
+ },
247
+ "unique_type": number,
248
+ "updated_at": number,
249
+ "updated_by": {
250
+ "avatar": object,
251
+ "id": number,
252
+ "name": string,
253
+ },
254
+ }
@@ -0,0 +1,38 @@
1
+ import * as common from "@byted-apaas/server-common-node";
2
+ import Multilingual = common.fieldType.Multilingual;
3
+ export declare type _IconType = "success" | "error" | "progress" | "info";
4
+ export declare class _NotifyCenter {
5
+ /**
6
+ * 消息中心推送消息
7
+ * @param msg 消息
8
+ */
9
+ create(msg: {
10
+ icon: _IconType;
11
+ percent: Number;
12
+ target_users: number[];
13
+ title: Multilingual;
14
+ detail: Multilingual;
15
+ }): Promise<number>;
16
+ /**
17
+ * 消息中心更新消息
18
+ * @param msgId 消息 ID
19
+ * @param msg 消息
20
+ */
21
+ update(msgId: number, msg: {
22
+ icon?: _IconType;
23
+ percent?: Number;
24
+ target_users?: number[];
25
+ title?: Multilingual;
26
+ detail?: Multilingual;
27
+ }): Promise<void>;
28
+ }
29
+ /**
30
+ * 消息类
31
+ */
32
+ export declare class Message {
33
+ /**
34
+ * 消息中心
35
+ */
36
+ notifyCenter: _NotifyCenter;
37
+ constructor();
38
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ // Copyright 2022 ByteDance Ltd. and/or its affiliates
3
+ // SPDX-License-Identifier: MIT
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.Message = exports._NotifyCenter = void 0;
6
+ const Request = require("../../request/interface");
7
+ class _NotifyCenter {
8
+ /**
9
+ * 消息中心推送消息
10
+ * @param msg 消息
11
+ */
12
+ async create(msg) {
13
+ return await Request.GetInstance().createMessage(msg);
14
+ }
15
+ ;
16
+ /**
17
+ * 消息中心更新消息
18
+ * @param msgId 消息 ID
19
+ * @param msg 消息
20
+ */
21
+ async update(msgId, msg) {
22
+ return await Request.GetInstance().updateMessage(msgId, msg);
23
+ }
24
+ ;
25
+ }
26
+ exports._NotifyCenter = _NotifyCenter;
27
+ /**
28
+ * 消息类
29
+ */
30
+ class Message {
31
+ constructor() {
32
+ this.notifyCenter = new _NotifyCenter();
33
+ }
34
+ }
35
+ exports.Message = Message;
@@ -0,0 +1,52 @@
1
+ // Copyright 2022 ByteDance Ltd. and/or its affiliates
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import * as Request from "../../request/interface";
5
+ import * as common from "@byted-apaas/server-common-node"
6
+ import Multilingual = common.fieldType.Multilingual
7
+
8
+ export type _IconType = "success" | "error" | "progress" | "info"
9
+
10
+ export class _NotifyCenter {
11
+ /**
12
+ * 消息中心推送消息
13
+ * @param msg 消息
14
+ */
15
+ public async create(msg: {
16
+ icon: _IconType,
17
+ percent: Number,
18
+ target_users: number[],
19
+ title: Multilingual,
20
+ detail: Multilingual,
21
+ }): Promise<number> {
22
+ return await Request.GetInstance().createMessage(msg);
23
+ };
24
+ /**
25
+ * 消息中心更新消息
26
+ * @param msgId 消息 ID
27
+ * @param msg 消息
28
+ */
29
+ public async update(msgId: number, msg: {
30
+ icon?: _IconType,
31
+ percent?: Number,
32
+ target_users?: number[],
33
+ title?: Multilingual,
34
+ detail?: Multilingual,
35
+ }): Promise<void> {
36
+ return await Request.GetInstance().updateMessage(msgId, msg);
37
+ };
38
+ }
39
+
40
+ /**
41
+ * 消息类
42
+ */
43
+ export class Message {
44
+ /**
45
+ * 消息中心
46
+ */
47
+ notifyCenter: _NotifyCenter;
48
+
49
+ constructor() {
50
+ this.notifyCenter = new _NotifyCenter();
51
+ }
52
+ }
@@ -0,0 +1,66 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { Stream } from "stream";
4
+ import { UploadFileResp } from "../../request/interface";
5
+ export interface _FileInfo {
6
+ id: string;
7
+ }
8
+ export interface _IKunlunFile {
9
+ /**
10
+ * 上传文件
11
+ * @param filePath 文件路径
12
+ * @param expire 文件过期时间,可选,单位:秒
13
+ */
14
+ upload(filePath: string, expire?: number): Promise<UploadFileResp>;
15
+ /**
16
+ * 上传文件
17
+ * @param stream 文件流
18
+ * @param expire 文件过期时间,可选,单位:秒
19
+ */
20
+ upload(stream: Stream, expire?: number): Promise<UploadFileResp>;
21
+ /**
22
+ * 下载文件
23
+ * @param fileToken 文件令牌
24
+ */
25
+ download(fileToken: string): Promise<Buffer>;
26
+ /**
27
+ * 下载文件
28
+ * @param fileToken 文件令牌
29
+ * @param filePath 文件保存的路径
30
+ */
31
+ download(fileToken: string, filePath: string): Promise<void>;
32
+ /**
33
+ * 下载文件
34
+ * @param fileInfo 文件信息
35
+ */
36
+ download(fileInfo: _FileInfo): Promise<Buffer>;
37
+ /**
38
+ * 下载文件
39
+ * @param fileInfo 文件信息
40
+ * @param filePath 文件保存的路径
41
+ */
42
+ download(fileInfo: _FileInfo, filePath: string): Promise<void>;
43
+ }
44
+ export declare type FileUploadResult = {
45
+ fileId: string;
46
+ type: string;
47
+ name: string;
48
+ size: number;
49
+ };
50
+ export declare type UploadAvatarResult = {
51
+ ImageId: string;
52
+ PreviewImageId: string;
53
+ };
54
+ export interface _IOpenSDKFile {
55
+ Upload(fileName: string, path: string): Promise<FileUploadResult>;
56
+ Upload(fileName: string, reader: Stream): Promise<FileUploadResult>;
57
+ Upload(fileName: string, buffer: Buffer): Promise<FileUploadResult>;
58
+ UploadAvatar(fileName: string, path: string): Promise<UploadAvatarResult>;
59
+ UploadAvatar(fileName: string, reader: Stream): Promise<UploadAvatarResult>;
60
+ UploadAvatar(fileName: string, buffer: Buffer): Promise<UploadAvatarResult>;
61
+ Download(fileID: string): Promise<Buffer>;
62
+ DownloadAvatar(imageID: string): Promise<Buffer>;
63
+ }
64
+ export interface _IOpenSDKResources {
65
+ file: _IOpenSDKFile;
66
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,73 @@
1
+ import { Stream } from "stream";
2
+ import { _KunlunOpenSDKFile } from "./impl/resources";
3
+ import { UploadFileResp } from "../../request/interface";
4
+
5
+ export interface _FileInfo {
6
+ id: string;
7
+ }
8
+
9
+ export interface _IKunlunFile {
10
+ /**
11
+ * 上传文件
12
+ * @param filePath 文件路径
13
+ * @param expire 文件过期时间,可选,单位:秒
14
+ */
15
+ upload(filePath: string, expire?: number): Promise<UploadFileResp>;
16
+ /**
17
+ * 上传文件
18
+ * @param stream 文件流
19
+ * @param expire 文件过期时间,可选,单位:秒
20
+ */
21
+ upload(stream: Stream, expire?: number): Promise<UploadFileResp>;
22
+ /**
23
+ * 下载文件
24
+ * @param fileToken 文件令牌
25
+ */
26
+ download(fileToken: string): Promise<Buffer>;
27
+
28
+ /**
29
+ * 下载文件
30
+ * @param fileToken 文件令牌
31
+ * @param filePath 文件保存的路径
32
+ */
33
+ download(fileToken: string, filePath: string): Promise<void>;
34
+
35
+ /**
36
+ * 下载文件
37
+ * @param fileInfo 文件信息
38
+ */
39
+ download(fileInfo: _FileInfo): Promise<Buffer>;
40
+
41
+ /**
42
+ * 下载文件
43
+ * @param fileInfo 文件信息
44
+ * @param filePath 文件保存的路径
45
+ */
46
+ download(fileInfo: _FileInfo, filePath: string): Promise<void>;
47
+ }
48
+
49
+ export type FileUploadResult = {
50
+ fileId: string;
51
+ type: string;
52
+ name: string;
53
+ size: number;
54
+ };
55
+
56
+ export type UploadAvatarResult = {
57
+ ImageId: string;
58
+ PreviewImageId: string;
59
+ };
60
+ export interface _IOpenSDKFile {
61
+ Upload(fileName: string, path: string): Promise<FileUploadResult>;
62
+ Upload(fileName: string, reader: Stream): Promise<FileUploadResult>;
63
+ Upload(fileName: string, buffer: Buffer): Promise<FileUploadResult>;
64
+ UploadAvatar(fileName: string, path: string): Promise<UploadAvatarResult>;
65
+ UploadAvatar(fileName: string, reader: Stream): Promise<UploadAvatarResult>;
66
+ UploadAvatar(fileName: string, buffer: Buffer): Promise<UploadAvatarResult>;
67
+ Download(fileID: string): Promise<Buffer>;
68
+ DownloadAvatar(imageID: string): Promise<Buffer>;
69
+ }
70
+
71
+ export interface _IOpenSDKResources {
72
+ file: _IOpenSDKFile;
73
+ }
@@ -0,0 +1,42 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { Stream } from "stream";
4
+ import { _FileInfo, _IKunlunFile, _IOpenSDKFile, UploadAvatarResult, FileUploadResult } from "../IResources";
5
+ import * as Request from "../../../request/interface";
6
+ import { AppCtx } from "../../../application/application";
7
+ export declare class _KunlunOpenSDKFile implements _IOpenSDKFile {
8
+ appCtx: AppCtx;
9
+ constructor(appCtx: AppCtx);
10
+ Upload(fileName: string, path: string): Promise<FileUploadResult>;
11
+ Upload(fileName: string, reader: Stream): Promise<FileUploadResult>;
12
+ Upload(fileName: string, buffer: Buffer): Promise<FileUploadResult>;
13
+ UploadAvatar(fileName: string, path: string): Promise<UploadAvatarResult>;
14
+ UploadAvatar(fileName: string, reader: Stream): Promise<UploadAvatarResult>;
15
+ UploadAvatar(fileName: string, buffer: Buffer): Promise<UploadAvatarResult>;
16
+ Download(fileID: string): Promise<Buffer>;
17
+ DownloadAvatar(imageID: string): Promise<Buffer>;
18
+ }
19
+ export declare class _KunlunFile implements _IKunlunFile {
20
+ download(fileToken: string): Promise<Buffer>;
21
+ download(fileToken: string, filePath?: string): Promise<void>;
22
+ download(fileToken: _FileInfo): Promise<Buffer>;
23
+ download(fileInfo: _FileInfo, filePath: string): Promise<void>;
24
+ upload(filePath: string): Promise<Request.UploadFileResp>;
25
+ upload(stream: Stream): Promise<Request.UploadFileResp>;
26
+ upload(filePath: string, expire: number): Promise<Request.UploadFileResp>;
27
+ upload(stream: Stream, expire: number): Promise<Request.UploadFileResp>;
28
+ }
29
+ /**
30
+ * OpenSDK 静态资源操作类
31
+ */
32
+ export declare class _OpenSDKResources {
33
+ file: _IOpenSDKFile;
34
+ constructor(appCtx: AppCtx);
35
+ }
36
+ /**
37
+ * 静态资源操作类
38
+ */
39
+ export declare class _Resources {
40
+ file: _IKunlunFile;
41
+ constructor();
42
+ }