apaas-oapi-client 0.1.39 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { LoggerLevel } from './logger';
2
2
  import { FIELD_TYPES, SYSTEM_FIELDS, LANGUAGE_CODES, SCHEMA_GUIDELINES, CREATE_OBJECT_EXAMPLE, UPDATE_OBJECT_ADD_FIELD_EXAMPLE, UPDATE_OBJECT_REPLACE_FIELD_EXAMPLE, UPDATE_OBJECT_REMOVE_FIELD_EXAMPLE, UPDATE_OBJECT_SETTINGS_EXAMPLE, getSystemFields, getCustomFieldTypes, getFieldType, isSystemField, createMultilingualText, extractMultilingualText, type FieldTypeMetadata, type MultilingualText, type ObjectSettings, type FieldTypeDefinition, type EncryptType, type FieldOperator, type CreateFieldDefinition, type UpdateFieldDefinition, type CreateObjectDefinition, type UpdateObjectDefinition } from './field-types';
3
+ import { SCHEMA_TYPE_BY_METADATA_TYPE, OPTION_COLOR_LIST, OPTION_COLOR_CODE_BY_NAME, OPTION_COLOR_NAME_BY_CODE, OPTION_COLOR_RULES, FIELD_SCHEMA_RULES, SCHEMA_TYPE_MISMATCHES, SQL_TYPE_TO_SCHEMA_TYPE, COLUMN_NAME_SEMANTIC_RULES, SQL_CONSTRAINT_TO_SETTINGS, BATCH_UPDATE_REQUIREMENTS, getOptionColor, getOptionColorCode, normalizeOptionColorForSchema, type MetadataFieldType, type SchemaFieldType, type FieldCreateRule, type OptionColor, type OptionColorCode, type SqlTypeMapping, type ColumnNameSemanticRule, type SqlConstraintMapping } from './field-schema-rules';
4
+ import { SCHEMA_BATCH_SIZE, addFieldsIdempotent, batchExecute, buildFieldRemovalPlan, checkSchemaResponse, createSchemaObjectShells, createSchemaObjectsInStages, deleteAllCustomObjects, isSystemSchemaName, normalizeSchemaObjectsForWrite, splitSchemaFieldsByDependency, validateSchemaResponse, verifySchemaObjects, type DeleteAllCustomObjectsOptions, type DeleteAllCustomObjectsResult, type SchemaAddFieldsOptions, type SchemaAddFieldsResult, type SchemaBatchExecuteOptions, type SchemaBatchExecuteResult, type SchemaBatchInfo, type SchemaCreateObjectsInStagesOptions, type SchemaCreateObjectsInStagesResult, type SchemaCreateShellsOptions, type SchemaCreateShellsResult, type SchemaFieldRemovalPlan, type SchemaManagedObjectDefinition, type SchemaObjectVerification, type SchemaResponse, type SchemaResponseFailure, type SchemaResponseFailureLayer, type SchemaResponseItem, type SchemaResponseValidationOptions, type SchemaResponseValidationResult, type SchemaStageFieldDefinition, type SchemaVerificationOptions, type SchemaVerificationResult } from './schema-utils';
3
5
  /**
4
6
  * 批量操作结果
5
7
  */
@@ -97,6 +99,7 @@ declare class Client {
97
99
  * 获取当前 namespace
98
100
  */
99
101
  get currentNamespace(): string;
102
+ private authHeaders;
100
103
  /**
101
104
  * 对象模块
102
105
  */
@@ -234,7 +237,53 @@ declare class Client {
234
237
  object_name: string;
235
238
  data?: any;
236
239
  }) => Promise<any>;
240
+ /**
241
+ * 跨对象搜索记录
242
+ * @description 在最多 5 个对象中按搜索词查询记录
243
+ * @param params 请求体,包含 q、search_objects、page_token、page_size、metadata 等
244
+ */
245
+ recordsAcrossObjects: (params: {
246
+ q: string;
247
+ search_objects: Array<{
248
+ api_name: string;
249
+ select?: string[];
250
+ search_fields?: string[];
251
+ filter?: any;
252
+ order_by?: any[];
253
+ }>;
254
+ page_token?: string;
255
+ page_size?: number;
256
+ metadata?: "Label" | "SearchLayout" | string;
257
+ }) => Promise<any>;
258
+ /**
259
+ * 跨对象搜索记录 - 自动 page_token 分页
260
+ */
261
+ recordsAcrossObjectsWithIterator: (params: {
262
+ q: string;
263
+ search_objects: Array<{
264
+ api_name: string;
265
+ select?: string[];
266
+ search_fields?: string[];
267
+ filter?: any;
268
+ order_by?: any[];
269
+ }>;
270
+ page_token?: string;
271
+ page_size?: number;
272
+ metadata?: "Label" | "SearchLayout" | string;
273
+ }) => Promise<{
274
+ items: any[];
275
+ lastResponse: any;
276
+ }>;
237
277
  };
278
+ /**
279
+ * 执行 OQL
280
+ * @description 执行对象查询语言,支持匿名参数 args 和具名参数 namedArgs
281
+ */
282
+ oql: (params: {
283
+ query: string;
284
+ args?: any[];
285
+ namedArgs?: Record<string, any>;
286
+ }) => Promise<any>;
238
287
  create: {
239
288
  /**
240
289
  * 单条记录创建
@@ -375,6 +424,48 @@ declare class Client {
375
424
  }>;
376
425
  };
377
426
  };
427
+ /**
428
+ * 常量对象模块
429
+ */
430
+ constant: {
431
+ /**
432
+ * 查询常量对象列表。object_name 可取 _currency、_country、_timeZone。
433
+ */
434
+ records: (params: {
435
+ object_name: "_currency" | "_country" | "_timeZone" | string;
436
+ data?: {
437
+ limit?: number;
438
+ offset?: number;
439
+ count?: boolean;
440
+ fields?: string[] | string;
441
+ quickSearch?: string;
442
+ filter?: any[];
443
+ sort?: any[];
444
+ };
445
+ }) => Promise<any>;
446
+ /**
447
+ * 查询常量对象单条记录详情。
448
+ */
449
+ record: (params: {
450
+ object_name: "_currency" | "_country" | "_timeZone" | string;
451
+ record_id: string;
452
+ }) => Promise<any>;
453
+ metadata: {
454
+ /**
455
+ * 获取常量对象元数据。
456
+ */
457
+ fields: (params: {
458
+ object_name: "_currency" | "_country" | "_timeZone" | string;
459
+ }) => Promise<any>;
460
+ /**
461
+ * 获取常量对象字段详情。
462
+ */
463
+ field: (params: {
464
+ object_name: "_currency" | "_country" | "_timeZone" | string;
465
+ field_name: string;
466
+ }) => Promise<any>;
467
+ };
468
+ };
378
469
  /**
379
470
  * 部门 ID 交换模块
380
471
  */
@@ -425,6 +516,33 @@ declare class Client {
425
516
  retryOptions?: RetryOptions;
426
517
  }) => Promise<BatchResult<any>>;
427
518
  };
519
+ /**
520
+ * 集成模块
521
+ */
522
+ integration: {
523
+ lark: {
524
+ /**
525
+ * 获取默认飞书集成 tenantAccessToken。
526
+ */
527
+ defaultTenantAccessToken: () => Promise<any>;
528
+ /**
529
+ * 获取默认飞书集成 appAccessToken。
530
+ */
531
+ defaultAppAccessToken: () => Promise<any>;
532
+ /**
533
+ * 获取自定义飞书集成 tenantAccessToken。
534
+ */
535
+ tenantAccessToken: (params: {
536
+ lark_integration_api_name: string;
537
+ }) => Promise<any>;
538
+ /**
539
+ * 获取自定义飞书集成 appAccessToken。
540
+ */
541
+ appAccessToken: (params: {
542
+ lark_integration_api_name: string;
543
+ }) => Promise<any>;
544
+ };
545
+ };
428
546
  /**
429
547
  * 云函数模块
430
548
  */
@@ -625,6 +743,44 @@ declare class Client {
625
743
  }>;
626
744
  };
627
745
  };
746
+ /**
747
+ * 数据集模块
748
+ */
749
+ dataset: {
750
+ /**
751
+ * 查询数据集列表。
752
+ */
753
+ list: (params?: {
754
+ keyword?: string;
755
+ order_by?: {
756
+ field?: "create_time" | "update_time" | string;
757
+ direction?: "asc" | "desc" | string;
758
+ } | string;
759
+ page_type?: "cursor" | "offset";
760
+ page_size?: number;
761
+ page_token?: string;
762
+ offset?: number | string;
763
+ created_by?: string[];
764
+ updated_by?: string[];
765
+ }) => Promise<any>;
766
+ /**
767
+ * 查询全部数据集 - 默认使用 cursor 分页。
768
+ */
769
+ listWithIterator: (params?: {
770
+ keyword?: string;
771
+ order_by?: {
772
+ field?: "create_time" | "update_time" | string;
773
+ direction?: "asc" | "desc" | string;
774
+ } | string;
775
+ page_size?: number;
776
+ created_by?: string[];
777
+ updated_by?: string[];
778
+ }) => Promise<{
779
+ total: number;
780
+ datasets: any[];
781
+ lastResponse: any;
782
+ }>;
783
+ };
628
784
  /**
629
785
  * 自动化流程模块
630
786
  */
@@ -668,6 +824,136 @@ declare class Client {
668
824
  }) => Promise<any>;
669
825
  };
670
826
  };
827
+ /**
828
+ * 流程模块
829
+ */
830
+ workflow: {
831
+ execution: {
832
+ /**
833
+ * 查询异步流程状态。
834
+ */
835
+ status: (params: {
836
+ execution_id: string | number;
837
+ }) => Promise<any>;
838
+ };
839
+ definition: {
840
+ /**
841
+ * 获取流程定义详情。
842
+ */
843
+ detail: (params: {
844
+ flow_api_name: string;
845
+ }) => Promise<any>;
846
+ };
847
+ userTask: {
848
+ /**
849
+ * 获取包含人工任务的流程列表。
850
+ */
851
+ flows: (params: {
852
+ limit: number;
853
+ offset?: number;
854
+ }) => Promise<any>;
855
+ /**
856
+ * 获取包含人工任务的流程实例 ID 列表。
857
+ */
858
+ instanceIds: (params: {
859
+ page_size?: number;
860
+ page_token?: string;
861
+ start_time?: string | number;
862
+ end_time?: string | number;
863
+ api_ids?: string[];
864
+ }) => Promise<any>;
865
+ /**
866
+ * 获取流程实例详情。
867
+ */
868
+ instanceDetail: (params: {
869
+ approval_instance_id: string;
870
+ includes?: string[];
871
+ }) => Promise<any>;
872
+ /**
873
+ * 批量获取流程实例的任务列表。
874
+ */
875
+ instanceTasks: (params: {
876
+ approval_instance_ids: Array<string | number>;
877
+ task_status?: string;
878
+ }) => Promise<any>;
879
+ /**
880
+ * 获取任务列表。
881
+ */
882
+ tasks: (params: {
883
+ type: "archived" | "pending" | string;
884
+ source: "fromMe" | "assignMe" | "CCMe" | string;
885
+ kunlun_user_id: string;
886
+ limit?: number | string;
887
+ offset?: number | string;
888
+ start_time?: string | number;
889
+ end_time?: string | number;
890
+ api_ids?: string[];
891
+ }) => Promise<any>;
892
+ /**
893
+ * 获取任务详情。
894
+ */
895
+ detail: (params: {
896
+ task_id: string;
897
+ }) => Promise<any>;
898
+ agree: (params: {
899
+ approval_task_id: string;
900
+ user_id: string;
901
+ opinion?: string;
902
+ }) => Promise<any>;
903
+ reject: (params: {
904
+ approval_task_id: string;
905
+ user_id: string;
906
+ opinion?: string;
907
+ }) => Promise<any>;
908
+ transfer: (params: {
909
+ approval_task_id: string;
910
+ user_id: string;
911
+ from_user_ids: string[];
912
+ to_user_ids: string[];
913
+ opinion?: string;
914
+ }) => Promise<any>;
915
+ addAssignee: (params: {
916
+ approval_task_id: string;
917
+ user_id: string;
918
+ approvers: string[];
919
+ add_assignee_type: "currentAndAddAssign" | "afterAndAddAssign" | string;
920
+ opinion?: string;
921
+ }) => Promise<any>;
922
+ cc: (params: {
923
+ task_id: string;
924
+ cc_user_ids: string[];
925
+ operator_user_id: string;
926
+ }) => Promise<any>;
927
+ expedite: (params: {
928
+ task_id: string;
929
+ expediting_user_ids: string[];
930
+ operator_user_id: string;
931
+ opinion?: string;
932
+ }) => Promise<any>;
933
+ cancelInstance: (params: {
934
+ approval_instance_id: string;
935
+ user_id: string;
936
+ opinion?: string;
937
+ }) => Promise<any>;
938
+ rollbackPoints: (params: {
939
+ task_id: string;
940
+ operator_user_id: string;
941
+ }) => Promise<any>;
942
+ rollback: (params: {
943
+ task_id: string;
944
+ operator_user_id: string;
945
+ to_task_id: string;
946
+ opinion?: string;
947
+ }) => Promise<any>;
948
+ startChat: (params: {
949
+ task_id: string;
950
+ operator_user_id: string;
951
+ invite_user_ids?: string[];
952
+ chat_id?: string;
953
+ chat_name?: string;
954
+ }) => Promise<any>;
955
+ };
956
+ };
671
957
  /**
672
958
  * 数据对象结构管理模块(Schema)
673
959
  */
@@ -690,7 +976,7 @@ declare class Client {
690
976
  display_name?: string;
691
977
  search_layout?: string[];
692
978
  };
693
- fields: Array<{
979
+ fields?: Array<{
694
980
  api_name: string;
695
981
  label: {
696
982
  zh_cn: string;
@@ -798,10 +1084,53 @@ declare class Client {
798
1084
  delete: (params: {
799
1085
  api_names: string[];
800
1086
  }) => Promise<any>;
1087
+ /**
1088
+ * 校验 schema 写接口响应,覆盖请求级错误、data=null 静默失败、item 级失败。
1089
+ */
1090
+ checkResponse: typeof checkSchemaResponse;
1091
+ /**
1092
+ * 返回 schema 写接口响应校验结果,不抛错。
1093
+ */
1094
+ validateResponse: typeof validateSchemaResponse;
1095
+ /**
1096
+ * 按 schema 单批 10 个对象的限制分批执行。
1097
+ */
1098
+ batchExecute: typeof batchExecute;
1099
+ /**
1100
+ * 创建对象空壳。会移除 fields,并将 display/search 临时指向 _id。
1101
+ */
1102
+ createShells: (params: {
1103
+ objects: SchemaManagedObjectDefinition[];
1104
+ } & SchemaCreateShellsOptions) => Promise<SchemaCreateShellsResult>;
1105
+ /**
1106
+ * 幂等添加字段:先读 metadata,跳过已存在字段,再调用 schema.update。
1107
+ */
1108
+ addFieldsIdempotent: (params: {
1109
+ object_name: string;
1110
+ fields: SchemaStageFieldDefinition[];
1111
+ } & SchemaAddFieldsOptions) => Promise<SchemaAddFieldsResult>;
1112
+ /**
1113
+ * 三阶段创建对象:空壳 -> 基础字段 -> lookup -> reference_field -> final settings。
1114
+ */
1115
+ createWithStages: (params: {
1116
+ objects: SchemaManagedObjectDefinition[];
1117
+ } & SchemaCreateObjectsInStagesOptions) => Promise<SchemaCreateObjectsInStagesResult>;
1118
+ /**
1119
+ * 写后验证对象和字段,可选导出 Markdown。
1120
+ */
1121
+ verifyObjects: (params: {
1122
+ object_names: string[];
1123
+ } & SchemaVerificationOptions) => Promise<SchemaVerificationResult>;
1124
+ /**
1125
+ * 删除全部自定义对象。高风险操作,必须显式传 confirm: true。
1126
+ */
1127
+ deleteAllCustomObjects: (params: DeleteAllCustomObjectsOptions & {
1128
+ confirm: true;
1129
+ }) => Promise<DeleteAllCustomObjectsResult>;
801
1130
  };
802
1131
  }
803
1132
  export declare const apaas: {
804
1133
  Client: typeof Client;
805
1134
  };
806
- export type { BatchResult, RetryOptions, FieldTypeMetadata, MultilingualText, ObjectSettings, FieldTypeDefinition, EncryptType, FieldOperator, CreateFieldDefinition, UpdateFieldDefinition, CreateObjectDefinition, UpdateObjectDefinition };
807
- export { FIELD_TYPES, SYSTEM_FIELDS, LANGUAGE_CODES, SCHEMA_GUIDELINES, CREATE_OBJECT_EXAMPLE, UPDATE_OBJECT_ADD_FIELD_EXAMPLE, UPDATE_OBJECT_REPLACE_FIELD_EXAMPLE, UPDATE_OBJECT_REMOVE_FIELD_EXAMPLE, UPDATE_OBJECT_SETTINGS_EXAMPLE, getSystemFields, getCustomFieldTypes, getFieldType, isSystemField, createMultilingualText, extractMultilingualText };
1135
+ export type { BatchResult, RetryOptions, FieldTypeMetadata, MultilingualText, ObjectSettings, FieldTypeDefinition, EncryptType, FieldOperator, CreateFieldDefinition, UpdateFieldDefinition, CreateObjectDefinition, UpdateObjectDefinition, MetadataFieldType, SchemaFieldType, FieldCreateRule, OptionColor, OptionColorCode, SqlTypeMapping, ColumnNameSemanticRule, SqlConstraintMapping, DeleteAllCustomObjectsOptions, DeleteAllCustomObjectsResult, SchemaAddFieldsOptions, SchemaAddFieldsResult, SchemaBatchExecuteOptions, SchemaBatchExecuteResult, SchemaBatchInfo, SchemaCreateObjectsInStagesOptions, SchemaCreateObjectsInStagesResult, SchemaCreateShellsOptions, SchemaCreateShellsResult, SchemaFieldRemovalPlan, SchemaManagedObjectDefinition, SchemaObjectVerification, SchemaResponse, SchemaResponseFailure, SchemaResponseFailureLayer, SchemaResponseItem, SchemaResponseValidationOptions, SchemaResponseValidationResult, SchemaStageFieldDefinition, SchemaVerificationOptions, SchemaVerificationResult };
1136
+ export { FIELD_TYPES, SYSTEM_FIELDS, LANGUAGE_CODES, SCHEMA_GUIDELINES, CREATE_OBJECT_EXAMPLE, UPDATE_OBJECT_ADD_FIELD_EXAMPLE, UPDATE_OBJECT_REPLACE_FIELD_EXAMPLE, UPDATE_OBJECT_REMOVE_FIELD_EXAMPLE, UPDATE_OBJECT_SETTINGS_EXAMPLE, getSystemFields, getCustomFieldTypes, getFieldType, isSystemField, createMultilingualText, extractMultilingualText, SCHEMA_TYPE_BY_METADATA_TYPE, OPTION_COLOR_LIST, OPTION_COLOR_CODE_BY_NAME, OPTION_COLOR_NAME_BY_CODE, OPTION_COLOR_RULES, FIELD_SCHEMA_RULES, SCHEMA_TYPE_MISMATCHES, SQL_TYPE_TO_SCHEMA_TYPE, COLUMN_NAME_SEMANTIC_RULES, SQL_CONSTRAINT_TO_SETTINGS, BATCH_UPDATE_REQUIREMENTS, getOptionColor, getOptionColorCode, normalizeOptionColorForSchema, SCHEMA_BATCH_SIZE, addFieldsIdempotent, batchExecute, buildFieldRemovalPlan, checkSchemaResponse, createSchemaObjectShells, createSchemaObjectsInStages, deleteAllCustomObjects, isSystemSchemaName, normalizeSchemaObjectsForWrite, splitSchemaFieldsByDependency, validateSchemaResponse, verifySchemaObjects };