@lark-project/js-sdk 2.0.8-dev.1 → 2.0.8-dev.10

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/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@
2
2
  ## 2.0.8 (2025/03/20)
3
3
  - 「Add」新增 Button 计划表单元按钮 Context
4
4
  - 「Add」新增 Button 视图批量按钮 Context
5
+ - 「Add」新增 ContainerModal 关闭时配置二次确认弹窗
6
+ - 「Add」新增 Navigation.getHostname 获取当前域名
7
+ - 「Deprecated」弃用 Context activeWorkItem
5
8
  ## 2.0.7 (2025/01/23)
6
9
  - 「Add」新增 Control onWorkItemFormValueChanged / getDisplayInfo / openFullScreenPlugin
7
10
  - 「Add」新增 Button onWorkItemFormValueChanged
package/dist/es/index.js CHANGED
@@ -440,6 +440,16 @@ _a24 = IMPL_KEY;
440
440
  */
441
441
  CustomComponent[_a24] = "customComponent";
442
442
 
443
+ // src/features/ExField.ts
444
+ var _a25;
445
+ var ExField = class extends BaseModel {
446
+ };
447
+ _a25 = IMPL_KEY;
448
+ /**
449
+ * @internal
450
+ */
451
+ ExField[_a25] = "exField";
452
+
443
453
  // src/client.ts
444
454
  function getImplClass(decl, impls) {
445
455
  return impls == null ? void 0 : impls[decl[IMPL_KEY]];
@@ -624,7 +634,7 @@ var SDKClient = _SDKClient;
624
634
  /**
625
635
  * SDK 版本号
626
636
  */
627
- SDKClient.version = "2.0.8-dev.1";
637
+ SDKClient.version = "2.0.8-dev.10";
628
638
 
629
639
  // src/types/biz.ts
630
640
  var AttributeType = /* @__PURE__ */ ((AttributeType2) => {
@@ -709,7 +719,7 @@ var CustomComponentType = /* @__PURE__ */ ((CustomComponentType2) => {
709
719
  // src/errors/CustomError.ts
710
720
  var CustomError = class extends Error {
711
721
  constructor(options) {
712
- super(options.message);
722
+ super(`${options.message}, ${options.originMessage}`);
713
723
  this.originMessage = options.originMessage;
714
724
  }
715
725
  };
@@ -765,7 +775,19 @@ var InvalidParamsError = class extends CustomError {
765
775
  message: "invalid params error",
766
776
  originMessage: options.originMessage
767
777
  });
778
+ this.errCode = -1;
779
+ this.errMsg = "unkown error";
768
780
  this.name = "InvalidParamsError";
781
+ this.errMsg = this.originMessage;
782
+ this._parseErrorCode();
783
+ }
784
+ _parseErrorCode() {
785
+ try {
786
+ const { errCode, errMsg } = JSON.parse(this.originMessage);
787
+ errCode !== void 0 && (this.errCode = errCode);
788
+ errMsg !== void 0 && (this.errMsg = errMsg);
789
+ } catch (e) {
790
+ }
769
791
  }
770
792
  };
771
793
 
@@ -795,6 +817,7 @@ export {
795
817
  Control,
796
818
  CustomComponent,
797
819
  CustomComponentType,
820
+ ExField,
798
821
  Field,
799
822
  FieldType,
800
823
  FlowMode,
package/dist/lib/index.js CHANGED
@@ -60,6 +60,7 @@ __export(src_exports, {
60
60
  Control: () => Control,
61
61
  CustomComponent: () => CustomComponent,
62
62
  CustomComponentType: () => CustomComponentType,
63
+ ExField: () => ExField,
63
64
  Field: () => Field,
64
65
  FieldType: () => FieldType,
65
66
  FlowMode: () => FlowMode,
@@ -505,6 +506,16 @@ _a24 = IMPL_KEY;
505
506
  */
506
507
  CustomComponent[_a24] = "customComponent";
507
508
 
509
+ // src/features/ExField.ts
510
+ var _a25;
511
+ var ExField = class extends BaseModel {
512
+ };
513
+ _a25 = IMPL_KEY;
514
+ /**
515
+ * @internal
516
+ */
517
+ ExField[_a25] = "exField";
518
+
508
519
  // src/client.ts
509
520
  function getImplClass(decl, impls) {
510
521
  return impls == null ? void 0 : impls[decl[IMPL_KEY]];
@@ -689,7 +700,7 @@ var SDKClient = _SDKClient;
689
700
  /**
690
701
  * SDK 版本号
691
702
  */
692
- SDKClient.version = "2.0.8-dev.1";
703
+ SDKClient.version = "2.0.8-dev.10";
693
704
 
694
705
  // src/types/biz.ts
695
706
  var AttributeType = /* @__PURE__ */ ((AttributeType2) => {
@@ -774,7 +785,7 @@ var CustomComponentType = /* @__PURE__ */ ((CustomComponentType2) => {
774
785
  // src/errors/CustomError.ts
775
786
  var CustomError = class extends Error {
776
787
  constructor(options) {
777
- super(options.message);
788
+ super(`${options.message}, ${options.originMessage}`);
778
789
  this.originMessage = options.originMessage;
779
790
  }
780
791
  };
@@ -830,7 +841,19 @@ var InvalidParamsError = class extends CustomError {
830
841
  message: "invalid params error",
831
842
  originMessage: options.originMessage
832
843
  });
844
+ this.errCode = -1;
845
+ this.errMsg = "unkown error";
833
846
  this.name = "InvalidParamsError";
847
+ this.errMsg = this.originMessage;
848
+ this._parseErrorCode();
849
+ }
850
+ _parseErrorCode() {
851
+ try {
852
+ const { errCode, errMsg } = JSON.parse(this.originMessage);
853
+ errCode !== void 0 && (this.errCode = errCode);
854
+ errMsg !== void 0 && (this.errMsg = errMsg);
855
+ } catch (e) {
856
+ }
834
857
  }
835
858
  };
836
859
 
@@ -861,6 +884,7 @@ var src_default = SDKClient;
861
884
  Control,
862
885
  CustomComponent,
863
886
  CustomComponentType,
887
+ ExField,
864
888
  Field,
865
889
  FieldType,
866
890
  FlowMode,
@@ -697,6 +697,88 @@ interface CustomComponentProps {
697
697
  disabled?: boolean;
698
698
  };
699
699
  }
700
+ /** ----------------------- 拓展字段构成类型 ----------------------- */
701
+ interface ExFieldFeatureContext {
702
+ /**
703
+ * 拓展字段当前所属空间标识
704
+ */
705
+ spaceId: string;
706
+ /**
707
+ * 拓展字段当前所属工作项类型标识
708
+ */
709
+ workObjectId: string;
710
+ /**
711
+ * 拓展字段当前所属工作项实例标识
712
+ * 新建页表单内该值为空
713
+ */
714
+ workItemId?: number;
715
+ /**
716
+ * 当前节点标识
717
+ * 适用场景:详情页为节点流时,且当前拓展字段位于节点表单内,该字段才有数据
718
+ */
719
+ nodeId?: string;
720
+ }
721
+ type FieldNumberValue = number;
722
+ type FieldMultiTextValue = string;
723
+ type FieldTreeSelectOptionValue = string[];
724
+ type FieldDatePreciseValue = string | number;
725
+ type FieldMultiUserValue = string[];
726
+ type FieldValue = FieldNumberValue | FieldMultiTextValue | FieldTreeSelectOptionValue | FieldDatePreciseValue | FieldMultiUserValue;
727
+ interface ExCompoundFieldValueType {
728
+ field_key: string;
729
+ field_value: {
730
+ field_key: string;
731
+ value?: FieldValue;
732
+ }[][];
733
+ }
734
+ type ExFieldValueType = ExCompoundFieldValueType;
735
+ interface ExFieldProps {
736
+ value: ExFieldValueType;
737
+ disabled?: boolean;
738
+ }
739
+ interface ExFieldConfig {
740
+ key: string;
741
+ type: FieldType.compoundField | SubFieldType;
742
+ name: string;
743
+ children?: ExFieldConfig[];
744
+ }
745
+ interface ExFieldValidateMsg {
746
+ /**
747
+ * code 为 200 时 msg 按照正常成功数据返回外
748
+ * 401 | 402 | 403 | 404 | 405 | 406 按照 InvalidParams 类型异常返回,可以通过该异常的 errCode、errMsg 属性查看具体出错原因
749
+ * 其余执行过程异常按照 InternalError 异常抛出
750
+ * 具体的 code 和对应的 msg 信息及解释可参考开发者手册的详细介绍
751
+ */
752
+ code: 200 | 401 | 402 | 403 | 404 | 405 | 406;
753
+ msg: string;
754
+ }
755
+ type SubFieldType =
756
+ /**
757
+ * 数字类型
758
+ */
759
+ FieldType.number
760
+ /**
761
+ * 多行文本
762
+ * 字段类型为 text
763
+ * 在字段模型中和单行文本字段的区别为 multi = true
764
+ */
765
+ | FieldType.text
766
+ /**
767
+ * 级联多选
768
+ * 如果写入不存在的选项可能导致接口报错/提示
769
+ */
770
+ | FieldType.treeMultiSelect
771
+ /**
772
+ * 时间+日期
773
+ * 字段类型为 date
774
+ * 在字段模型中和普通日期字段的区别是本时间精确度为 "YYYY-MM-DD HH:mm:ss"(普通为 YYYY-MM-DD)
775
+ */
776
+ | FieldType.date
777
+ /**
778
+ * 多选人员
779
+ * 如果写入不存在的人员可能导致接口报错/提示
780
+ */
781
+ | FieldType.multiUser;
700
782
  /**
701
783
  * 构成弹窗配置
702
784
  */
@@ -776,6 +858,7 @@ declare abstract class Context extends BaseModel {
776
858
  */
777
859
  abstract loginUser: User;
778
860
  /**
861
+ * @deprecated 请使用各功能构成的上下文读取当前的工作项信息,如 JSSDK.Button.getContext()
779
862
  * 当前打开的工作项(仅工作项详情页可用)
780
863
  */
781
864
  abstract activeWorkItem?: BriefWorkItem;
@@ -1045,6 +1128,14 @@ declare abstract class Navigation extends BaseModel {
1045
1128
  */
1046
1129
  private static load;
1047
1130
  /**
1131
+ * @public
1132
+ * mobile version ≥ 7.41.0
1133
+ * 读取当前页面地址的 hostname
1134
+ */
1135
+ abstract getHostname(): Promise<string>;
1136
+ /**
1137
+ * @public
1138
+ * only web 2.0
1048
1139
  * 读取当前完整的页面地址
1049
1140
  */
1050
1141
  abstract getHref(): Promise<string>;
@@ -1832,6 +1923,70 @@ declare abstract class CustomComponent extends BaseModel {
1832
1923
  };
1833
1924
  }
1834
1925
 
1926
+ /**
1927
+ * @public
1928
+ * 自定义组件构成
1929
+ */
1930
+ declare abstract class ExField extends BaseModel {
1931
+ /**
1932
+ * @internal
1933
+ */
1934
+ protected static [IMPL_KEY]: string;
1935
+ abstract getContext: () => Promise<ExFieldFeatureContext>;
1936
+ abstract getProps: () => Promise<ExFieldProps>;
1937
+ /**
1938
+ * only for form
1939
+ * 用于监听 props 变更
1940
+ * @param callback 返回插件字段新的 props
1941
+ * @param watchKeys 监听的 key,只能监听属性的 key(不能监听 api key),不传默认监听所有 key。监听的 key 对应的值变更会触发回调
1942
+ * @returns
1943
+ */
1944
+ abstract watch: (callback: (next: ExFieldProps | Record<string, never>) => void, watchKeys?: (keyof ExFieldProps)[]) => Promise<Off>;
1945
+ abstract saveFieldValue: (value: ExFieldValueType) => Promise<ExFieldValidateMsg>;
1946
+ abstract getFieldConfig: () => Promise<ExFieldConfig>;
1947
+ /**
1948
+ * 获取新建工作项表单项的值
1949
+ * mobile version ≥ 7.29.0
1950
+ * @param keys 需要获取的工作项属性 / 字段 ID 列表,一次限制读取 10 个 keys
1951
+ * @param keys.key 工作项属性 / 字段 ID
1952
+ * @param keys.type 类型
1953
+ * 工作项属性 name 为 FieldType.text,工作项属性 template 为 FieldType.number
1954
+ * 控件 role_owners 为 FieldType.control
1955
+ */
1956
+ abstract getCreateWorkItemFormItemValues(keys: Array<{
1957
+ key: string | AttributeType;
1958
+ type: Exclude<FieldType, FieldType.richText | FieldType.singleSignal | FieldType.multiSignal | FieldType.singleVoting | FieldType.multiVoting | FieldType.simpleVoting>;
1959
+ }>): Promise<Record<string | AttributeType, any>>;
1960
+ /**
1961
+ * 监听工作项表单项值变化
1962
+ * @param options.watchKeys 需要监听的工作项 字段 ID 列表
1963
+ * @param callback 当监听值发生变化时触发,changedValue 为变化的 kv
1964
+ */
1965
+ abstract onWorkItemFormValueChanged(options: {
1966
+ watchKeys: Array<{
1967
+ key: string | AttributeType;
1968
+ type: Exclude<FieldType, FieldType.richText | FieldType.singleSignal | FieldType.multiSignal | FieldType.singleVoting | FieldType.multiVoting | FieldType.simpleVoting>;
1969
+ }>;
1970
+ }, callback: (changedValue: Record<string, unknown>) => void): Promise<Off>;
1971
+ /**
1972
+ * only web for table
1973
+ * 打开全屏插件
1974
+ */
1975
+ abstract getTableCellInitProps(): Promise<ExFieldProps>;
1976
+ /**
1977
+ * only mobile 7.35.0+
1978
+ * 获取插件的展示态信息
1979
+ */
1980
+ abstract getDisplayInfo(): Promise<{
1981
+ display_height: number;
1982
+ }>;
1983
+ /**
1984
+ * only mobile 7.35.0+
1985
+ * 打开全屏插件
1986
+ */
1987
+ abstract openFullScreenPlugin(): void;
1988
+ }
1989
+
1835
1990
  /**
1836
1991
  * @public
1837
1992
  * SDKClient 的配置项
@@ -2021,9 +2176,12 @@ declare class OutOfLimitError extends CustomError {
2021
2176
  * 请求参数异常
2022
2177
  */
2023
2178
  declare class InvalidParamsError extends CustomError {
2179
+ errCode: number;
2180
+ errMsg: string;
2024
2181
  constructor(options: {
2025
2182
  originMessage: string;
2026
2183
  });
2184
+ _parseErrorCode(): void;
2027
2185
  }
2028
2186
 
2029
2187
  /**
@@ -2045,4 +2203,4 @@ declare class NotSupportedError extends CustomError {
2045
2203
  * @packageDocumentation
2046
2204
  */
2047
2205
 
2048
- export { ActionSheet, ActionSheetOptions, AttributeType, BatchButtonFeatureContext, BizLine, BriefField, BriefNode, BriefSpace, BriefTemplate, BriefView, BriefWorkItem, BriefWorkObject, Button, ButtonFeatureContext, ButtonScene, Clipboard, ColorScheme, ComponentScheduleIdentity, ComponentScheduleScene, Configuration, ConfigurationFeatureContext, ContainerModal, ContainerModalConfigureOptions, Context, Control, ControlFeatureContext, CreateButtonFeatureContext, CustomComponent, CustomComponentFeatureContext, CustomComponentProps, CustomComponentType, Field, FieldType, FlowMode, IMPL_KEY, IPluginCustomBuildConfig, IRichTextEditorImageUploadComplete, IntegrationFeatureContext, Intercept, InterceptEvent, InterceptFeatureContext, InternalError, InvalidParamsError, Language, MEEGO_BIZ_HUB, Modal, ModalConfirmOptions, ModalOpenOptions, Navigation, NoAuthError, NodeStatus, NotFoundError, NotSupportedError, Off, OutOfLimitError, Page, PageFeatureContext, RichTextEditor, RichTextEditorContent, RichTextEditorOptions, Role, RoleOwners, SDKClient, SDKClientOptions, ScheduleCompValidateMsg, ScheduleCompValueType, ScheduleUnitButtonFeatureContext, Shared, Space, Storage, Tab, TabFeatureContext, Toast, ToastOptions, User, UserInfo, Utils, View, ViewFeatureContext, WbsStatus, WorkItem, WorkItemButtonFeatureContext, WorkItemCreateFormPreset, WorkItemFinder, WorkItemFinderOptions, WorkObject, SDKClient as default, unwatch };
2206
+ export { ActionSheet, ActionSheetOptions, AttributeType, BatchButtonFeatureContext, BizLine, BriefField, BriefNode, BriefSpace, BriefTemplate, BriefView, BriefWorkItem, BriefWorkObject, Button, ButtonFeatureContext, ButtonScene, Clipboard, ColorScheme, ComponentScheduleIdentity, ComponentScheduleScene, Configuration, ConfigurationFeatureContext, ContainerModal, ContainerModalConfigureOptions, Context, Control, ControlFeatureContext, CreateButtonFeatureContext, CustomComponent, CustomComponentFeatureContext, CustomComponentProps, CustomComponentType, ExCompoundFieldValueType, ExField, ExFieldConfig, ExFieldFeatureContext, ExFieldProps, ExFieldValidateMsg, ExFieldValueType, Field, FieldType, FieldValue, FlowMode, IMPL_KEY, IPluginCustomBuildConfig, IRichTextEditorImageUploadComplete, IntegrationFeatureContext, Intercept, InterceptEvent, InterceptFeatureContext, InternalError, InvalidParamsError, Language, MEEGO_BIZ_HUB, Modal, ModalConfirmOptions, ModalOpenOptions, Navigation, NoAuthError, NodeStatus, NotFoundError, NotSupportedError, Off, OutOfLimitError, Page, PageFeatureContext, RichTextEditor, RichTextEditorContent, RichTextEditorOptions, Role, RoleOwners, SDKClient, SDKClientOptions, ScheduleCompValidateMsg, ScheduleCompValueType, ScheduleUnitButtonFeatureContext, Shared, Space, Storage, SubFieldType, Tab, TabFeatureContext, Toast, ToastOptions, User, UserInfo, Utils, View, ViewFeatureContext, WbsStatus, WorkItem, WorkItemButtonFeatureContext, WorkItemCreateFormPreset, WorkItemFinder, WorkItemFinderOptions, WorkObject, SDKClient as default, unwatch };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-project/js-sdk",
3
- "version": "2.0.8-dev.1",
3
+ "version": "2.0.8-dev.10",
4
4
  "runtimeMinVersions": {
5
5
  "web": "2.1.0",
6
6
  "mobile": "1.1.0"