apaas-oapi-client 0.1.40 → 1.0.1

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/README.md CHANGED
@@ -15,15 +15,18 @@
15
15
  - ✅ records 查询(支持分页迭代)
16
16
  - ✅ record 单条查询、单条更新、单条删除
17
17
  - ✅ record 批量创建、批量更新、批量删除
18
+ - ✅ OQL、跨对象搜索、常量对象、数据集列表
18
19
 
19
20
  ### 对象结构管理(Schema)
20
21
  - ✅ **创建数据对象**(批量)
21
22
  - ✅ **更新数据对象**(批量,支持添加/修改/删除字段)
22
23
  - ✅ **删除数据对象**(批量)
24
+ - ✅ **AI 友好的安全编排接口**(响应校验、幂等加字段、三阶段建对象、依赖顺序删除)
23
25
  - ✅ **字段类型完整文档**(20+ 字段类型,含示例)
24
26
 
25
27
  ### 其他功能
26
28
  - ✅ 获取 accessToken(自动刷新)
29
+ - ✅ 工作流人工任务、异步流程状态、飞书集成 token
27
30
  - ✅ **导出数据对象文档为 Markdown**
28
31
  - ✅ 内置 Bottleneck 限流器
29
32
  - ✅ 自定义日志等级
@@ -36,10 +39,10 @@
36
39
 
37
40
  | Skill | 适用场景 |
38
41
  | --- | --- |
39
- | `apaas-shared` | Client 初始化、凭证安全、namespace、token、日志、分页与错误处理 |
40
- | `apaas-object` | 对象列表、字段元数据、记录查询/创建/更新/删除、Markdown 导出 |
42
+ | `apaas-shared` | Client 初始化、凭证安全、namespace、token、日志、OpenAPI 覆盖、分页与错误码处理 |
43
+ | `apaas-object` | 对象列表、字段元数据、记录查询/创建/更新/删除、OQL、跨对象搜索、常量对象、数据集 |
41
44
  | `apaas-schema` | 对象和字段结构管理、字段类型映射、lookup/reference 依赖规则 |
42
- | `apaas-function-flow` | 云函数调用、自动化流程 v1/v2 执行 |
45
+ | `apaas-function-flow` | 云函数调用、自动化流程 v1/v2 执行、工作流人工任务、飞书集成 token |
43
46
  | `apaas-builder` | 页面列表、页面详情、页面访问链接 |
44
47
  | `apaas-global` | 全局选项、环境变量读取与审计 |
45
48
  | `apaas-exchange-attachment` | 用户/部门 ID 交换、附件和头像上传下载 |
@@ -85,6 +88,7 @@ cp -R node_modules/apaas-oapi-client/skills/apaas-* "${CODEX_HOME:-$HOME/.codex}
85
88
  使用建议:
86
89
 
87
90
  - 写入前先用 `apaas-object` 读取真实 metadata。
91
+ - 大量读取优先使用 iterator 或 `apaas-object/references/id-cursor-pagination.md`。
88
92
  - Schema 字段变更前先读 `apaas-schema/references/field-schema-rules.md`。
89
93
  - 删除、批量写入、流程执行都按写操作处理,先确认目标和影响。
90
94
 
@@ -113,8 +117,8 @@ const client = new apaas.Client({
113
117
 
114
118
  await client.init();
115
119
 
116
- // 创建数据对象
117
- await client.schema.create({
120
+ // 安全创建数据对象:空壳 -> 基础字段 -> lookup -> reference_field -> final settings
121
+ await client.schema.createWithStages({
118
122
  objects: [{
119
123
  api_name: 'product',
120
124
  label: { zh_cn: '产品', en_us: 'Product' },
@@ -124,9 +128,19 @@ await client.schema.create({
124
128
  },
125
129
  fields: [
126
130
  {
131
+ operator: 'add',
127
132
  api_name: 'code',
128
133
  label: { zh_cn: '编号', en_us: 'Code' },
129
- type: { name: 'text', settings: { required: true } },
134
+ type: {
135
+ name: 'text',
136
+ settings: {
137
+ required: true,
138
+ unique: false,
139
+ case_sensitive: false,
140
+ multiline: false,
141
+ max_length: 100
142
+ }
143
+ },
130
144
  encrypt_type: 'none'
131
145
  }
132
146
  ]
@@ -141,11 +155,23 @@ await client.schema.update({
141
155
  operator: 'add', // 添加新字段
142
156
  api_name: 'name',
143
157
  label: { zh_cn: '名称', en_us: 'Name' },
144
- type: { name: 'text', settings: { required: true } },
158
+ type: {
159
+ name: 'text',
160
+ settings: {
161
+ required: true,
162
+ unique: false,
163
+ case_sensitive: false,
164
+ multiline: false,
165
+ max_length: 100
166
+ }
167
+ },
145
168
  encrypt_type: 'none'
146
169
  }]
147
170
  }]
148
171
  });
172
+
173
+ // 三层响应校验:请求级错误、data=null 静默失败、item 级失败
174
+ client.schema.checkResponse({ code: '0', data: { items: [] } }, 'schema.update');
149
175
  ```
150
176
 
151
177
  ---
package/UserManual.md CHANGED
@@ -14,6 +14,10 @@ aPaaS 平台有完整的 Open API 能力,但是目前这些能力全都以单
14
14
  - ✅ record 单条更新、批量更新
15
15
 
16
16
  - ✅ record 单条删除、批量删除
17
+
18
+ - ✅ OQL、跨对象搜索、常量对象、数据集列表
19
+
20
+ - ✅ 工作流人工任务、异步流程状态、飞书集成 token
17
21
 
18
22
  - ✅ 内置 Bottleneck 限流器,基于 API 接口配置限流规则
19
23
 
@@ -171,6 +175,32 @@ console.log('Items:', items);
171
175
 
172
176
  ***
173
177
 
178
+ ### **执行 OQL**
179
+
180
+ ```JavaScript
181
+ const res = await client.object.oql({
182
+ query: 'SELECT _id, _name FROM _user WHERE _type = $1 LIMIT 10',
183
+ args: ['_employee']
184
+ });
185
+ console.log(res);
186
+ ```
187
+
188
+ ### **跨对象搜索**
189
+
190
+ ```JavaScript
191
+ const res = await client.object.search.recordsAcrossObjects({
192
+ q: 'Ethan',
193
+ search_objects: [{
194
+ api_name: '_user',
195
+ select: ['_id', '_name'],
196
+ search_fields: ['_name']
197
+ }],
198
+ page_size: 20,
199
+ metadata: 'Label'
200
+ });
201
+ console.log(res);
202
+ ```
203
+
174
204
 
175
205
 
176
206
 
@@ -378,6 +408,40 @@ console.log('✅ 文档导出成功!');
378
408
 
379
409
  ***
380
410
 
411
+ # **🧩 常量对象与数据集**
412
+
413
+ ## **常量对象**
414
+
415
+ 支持 `_currency`、`_country`、`_timeZone`。
416
+
417
+ ```JavaScript
418
+ const currencies = await client.constant.records({
419
+ object_name: '_currency',
420
+ data: {
421
+ limit: 100,
422
+ offset: 0,
423
+ count: false,
424
+ fields: ['_id', '_name']
425
+ }
426
+ });
427
+
428
+ const country = await client.constant.record({
429
+ object_name: '_country',
430
+ record_id: 'CN'
431
+ });
432
+ ```
433
+
434
+ ## **数据集**
435
+
436
+ ```JavaScript
437
+ const datasets = await client.dataset.listWithIterator({
438
+ page_size: 100
439
+ });
440
+ console.log(datasets);
441
+ ```
442
+
443
+ ***
444
+
381
445
 
382
446
 
383
447
  # **📎 附件模块**
@@ -636,6 +700,56 @@ console.log(res);
636
700
  // 返回: { code: "0", msg: "success", data: { errMsg, executionId, status, data, errCode } }
637
701
  ```
638
702
 
703
+ ## **查询异步流程状态**
704
+
705
+ ```JavaScript
706
+ const status = await client.workflow.execution.status({
707
+ execution_id: '1848390852196499'
708
+ });
709
+ console.log(status);
710
+ ```
711
+
712
+ ## **获取流程定义详情**
713
+
714
+ ```JavaScript
715
+ const flow = await client.workflow.definition.detail({
716
+ flow_api_name: 'package_xxx__c__action_xxx'
717
+ });
718
+ console.log(flow);
719
+ ```
720
+
721
+ ## **人工任务**
722
+
723
+ ```JavaScript
724
+ const tasks = await client.workflow.userTask.tasks({
725
+ type: 'pending',
726
+ source: 'assignMe',
727
+ kunlun_user_id: '1783981209205788',
728
+ limit: 20,
729
+ offset: 0
730
+ });
731
+
732
+ await client.workflow.userTask.agree({
733
+ approval_task_id: '1785996265147395',
734
+ user_id: '1783981209205788',
735
+ opinion: '同意'
736
+ });
737
+ ```
738
+
739
+ ***
740
+
741
+ # **🔗 集成模块**
742
+
743
+ ## **飞书集成 Token**
744
+
745
+ ```JavaScript
746
+ const tenantToken = await client.integration.lark.defaultTenantAccessToken();
747
+
748
+ const appToken = await client.integration.lark.appAccessToken({
749
+ lark_integration_api_name: 'larkIntegration_xxx'
750
+ });
751
+ ```
752
+
639
753
  ***
640
754
 
641
755
  <br>
@@ -693,4 +807,4 @@ console.log(client.currentNamespace);
693
807
 
694
808
  > 由 [aPaaS OAPI Client SDK](https://www.npmjs.com/package/apaas-oapi-client) 提供支持,如有问题请提交 Issue 反馈。
695
809
 
696
- ---
810
+ ---
@@ -19,7 +19,12 @@ export interface FieldCreateRule {
19
19
  export declare const SCHEMA_TYPE_BY_METADATA_TYPE: Record<MetadataFieldType, SchemaFieldType>;
20
20
  export declare const OPTION_COLOR_LIST: readonly ["blue", "cyan", "green", "yellow", "orange", "red", "magenta", "purple", "blueMagenta", "grey"];
21
21
  export type OptionColor = typeof OPTION_COLOR_LIST[number];
22
+ export declare const OPTION_COLOR_CODE_BY_NAME: Record<OptionColor, string>;
23
+ export declare const OPTION_COLOR_NAME_BY_CODE: Record<string, OptionColor>;
24
+ export type OptionColorCode = typeof OPTION_COLOR_CODE_BY_NAME[OptionColor];
22
25
  export declare function getOptionColor(index: number): OptionColor;
26
+ export declare function getOptionColorCode(color: OptionColor): OptionColorCode;
27
+ export declare function normalizeOptionColorForSchema(color: unknown): unknown;
23
28
  export declare const OPTION_COLOR_RULES: {
24
29
  readonly allowedColors: readonly ["blue", "cyan", "green", "yellow", "orange", "red", "magenta", "purple", "blueMagenta", "grey"];
25
30
  readonly assignment: "Use OPTION_COLOR_LIST in order and cycle from the beginning when options exceed 10.";
@@ -40,7 +45,10 @@ export declare const OPTION_COLOR_RULES: {
40
45
  readonly typeName: "enum";
41
46
  readonly optionsPath: "type.settings.options";
42
47
  readonly colorPath: "type.settings.options[].color";
43
- readonly sourcePath: "type.settings.option_source";
48
+ readonly colorInput: "SDK accepts metadata color names and normalizes them to OpenAPI color codes before writing.";
49
+ readonly colorCodeByName: Record<"blue" | "cyan" | "green" | "yellow" | "orange" | "red" | "magenta" | "purple" | "blueMagenta" | "grey", string>;
50
+ readonly sourcePath: "type.settings.option_type";
51
+ readonly customSourceValue: "local";
44
52
  readonly globalOptionPath: "type.settings.global_option_api_name";
45
53
  };
46
54
  };
@@ -49,6 +57,35 @@ export declare const SCHEMA_TYPE_MISMATCHES: Array<{
49
57
  metadataType: MetadataFieldType;
50
58
  schemaType: SchemaFieldType;
51
59
  }>;
60
+ export interface SqlTypeMapping {
61
+ /** SQL type regex pattern, case-insensitive. */
62
+ sqlPattern: string;
63
+ /** Mapped aPaaS schema type. */
64
+ schemaType: SchemaFieldType;
65
+ /** Settings derivation rule. */
66
+ settingsMapping: string;
67
+ }
68
+ export declare const SQL_TYPE_TO_SCHEMA_TYPE: SqlTypeMapping[];
69
+ export interface ColumnNameSemanticRule {
70
+ /** Column name regex pattern, case-insensitive. */
71
+ columnPattern: string;
72
+ /** Inferred aPaaS schema type. */
73
+ schemaType: SchemaFieldType;
74
+ /** Inference notes. */
75
+ notes: string;
76
+ }
77
+ export declare const COLUMN_NAME_SEMANTIC_RULES: ColumnNameSemanticRule[];
78
+ export interface SqlConstraintMapping {
79
+ /** SQL constraint. */
80
+ sqlConstraint: string;
81
+ /** Mapped aPaaS settings field. */
82
+ settingsField: string;
83
+ /** Mapped value. */
84
+ settingsValue: string;
85
+ /** Mapping notes. */
86
+ notes: string;
87
+ }
88
+ export declare const SQL_CONSTRAINT_TO_SETTINGS: SqlConstraintMapping[];
52
89
  export declare const BATCH_UPDATE_REQUIREMENTS: {
53
90
  readonly add: "Use operator=add with full field definition.";
54
91
  readonly replace: "Use operator=replace and include full `type` (name + settings). Label-only replace fails.";
@@ -80,8 +80,8 @@ export interface CreateObjectDefinition {
80
80
  label: MultilingualText;
81
81
  /** 对象设置(可选) */
82
82
  settings?: ObjectSettings;
83
- /** 字段列表(必填,至少包含一个自定义字段) */
84
- fields: CreateFieldDefinition[];
83
+ /** 字段列表(可选)。schema.create 会忽略 fields,安全做法是先建空壳,再用 schema.update 添加字段。 */
84
+ fields?: CreateFieldDefinition[];
85
85
  }
86
86
  /**
87
87
  * 更新对象的定义