@lark-project/js-sdk 2.0.8-dev.5 → 2.0.8-dev.7

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
@@ -3,6 +3,7 @@
3
3
  - 「Add」新增 Button 计划表单元按钮 Context
4
4
  - 「Add」新增 Button 视图批量按钮 Context
5
5
  - 「Add」新增 ContainerModal 关闭时配置二次确认弹窗
6
+ - 「Add」新增 Navigation.getHostname 获取当前域名
6
7
  - 「Deprecated」弃用 Context activeWorkItem
7
8
  ## 2.0.7 (2025/01/23)
8
9
  - 「Add」新增 Control onWorkItemFormValueChanged / getDisplayInfo / openFullScreenPlugin
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.5";
637
+ SDKClient.version = "2.0.8-dev.7";
628
638
 
629
639
  // src/types/biz.ts
630
640
  var AttributeType = /* @__PURE__ */ ((AttributeType2) => {
@@ -705,6 +715,14 @@ var CustomComponentType = /* @__PURE__ */ ((CustomComponentType2) => {
705
715
  CustomComponentType2["Schedule"] = "schedule";
706
716
  return CustomComponentType2;
707
717
  })(CustomComponentType || {});
718
+ var SubFieldType = /* @__PURE__ */ ((SubFieldType2) => {
719
+ SubFieldType2["FieldNumber"] = "number";
720
+ SubFieldType2["FieldMultiText"] = "text";
721
+ SubFieldType2["FieldTreeSelect"] = "tree-multi-select";
722
+ SubFieldType2["FieldDatePrecise"] = "date";
723
+ SubFieldType2["FieldMultiUser"] = "multi-user";
724
+ return SubFieldType2;
725
+ })(SubFieldType || {});
708
726
 
709
727
  // src/errors/CustomError.ts
710
728
  var CustomError = class extends Error {
@@ -765,7 +783,19 @@ var InvalidParamsError = class extends CustomError {
765
783
  message: "invalid params error",
766
784
  originMessage: options.originMessage
767
785
  });
786
+ this.errCode = -1;
787
+ this.errMsg = "unkown error";
768
788
  this.name = "InvalidParamsError";
789
+ this.errMsg = this.originMessage;
790
+ this._parseErrorCode();
791
+ }
792
+ _parseErrorCode() {
793
+ try {
794
+ const { errCode, errMsg } = JSON.parse(this.originMessage);
795
+ errCode !== void 0 && (this.errCode = errCode);
796
+ errMsg !== void 0 && (this.errMsg = errMsg);
797
+ } catch (e) {
798
+ }
769
799
  }
770
800
  };
771
801
 
@@ -795,6 +825,7 @@ export {
795
825
  Control,
796
826
  CustomComponent,
797
827
  CustomComponentType,
828
+ ExField,
798
829
  Field,
799
830
  FieldType,
800
831
  FlowMode,
@@ -817,6 +848,7 @@ export {
817
848
  Shared,
818
849
  Space,
819
850
  Storage,
851
+ SubFieldType,
820
852
  Tab,
821
853
  Toast,
822
854
  Utils,
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,
@@ -82,6 +83,7 @@ __export(src_exports, {
82
83
  Shared: () => Shared,
83
84
  Space: () => Space,
84
85
  Storage: () => Storage,
86
+ SubFieldType: () => SubFieldType,
85
87
  Tab: () => Tab,
86
88
  Toast: () => Toast,
87
89
  Utils: () => Utils,
@@ -505,6 +507,16 @@ _a24 = IMPL_KEY;
505
507
  */
506
508
  CustomComponent[_a24] = "customComponent";
507
509
 
510
+ // src/features/ExField.ts
511
+ var _a25;
512
+ var ExField = class extends BaseModel {
513
+ };
514
+ _a25 = IMPL_KEY;
515
+ /**
516
+ * @internal
517
+ */
518
+ ExField[_a25] = "exField";
519
+
508
520
  // src/client.ts
509
521
  function getImplClass(decl, impls) {
510
522
  return impls == null ? void 0 : impls[decl[IMPL_KEY]];
@@ -689,7 +701,7 @@ var SDKClient = _SDKClient;
689
701
  /**
690
702
  * SDK 版本号
691
703
  */
692
- SDKClient.version = "2.0.8-dev.5";
704
+ SDKClient.version = "2.0.8-dev.7";
693
705
 
694
706
  // src/types/biz.ts
695
707
  var AttributeType = /* @__PURE__ */ ((AttributeType2) => {
@@ -770,6 +782,14 @@ var CustomComponentType = /* @__PURE__ */ ((CustomComponentType2) => {
770
782
  CustomComponentType2["Schedule"] = "schedule";
771
783
  return CustomComponentType2;
772
784
  })(CustomComponentType || {});
785
+ var SubFieldType = /* @__PURE__ */ ((SubFieldType2) => {
786
+ SubFieldType2["FieldNumber"] = "number";
787
+ SubFieldType2["FieldMultiText"] = "text";
788
+ SubFieldType2["FieldTreeSelect"] = "tree-multi-select";
789
+ SubFieldType2["FieldDatePrecise"] = "date";
790
+ SubFieldType2["FieldMultiUser"] = "multi-user";
791
+ return SubFieldType2;
792
+ })(SubFieldType || {});
773
793
 
774
794
  // src/errors/CustomError.ts
775
795
  var CustomError = class extends Error {
@@ -830,7 +850,19 @@ var InvalidParamsError = class extends CustomError {
830
850
  message: "invalid params error",
831
851
  originMessage: options.originMessage
832
852
  });
853
+ this.errCode = -1;
854
+ this.errMsg = "unkown error";
833
855
  this.name = "InvalidParamsError";
856
+ this.errMsg = this.originMessage;
857
+ this._parseErrorCode();
858
+ }
859
+ _parseErrorCode() {
860
+ try {
861
+ const { errCode, errMsg } = JSON.parse(this.originMessage);
862
+ errCode !== void 0 && (this.errCode = errCode);
863
+ errMsg !== void 0 && (this.errMsg = errMsg);
864
+ } catch (e) {
865
+ }
834
866
  }
835
867
  };
836
868
 
@@ -861,6 +893,7 @@ var src_default = SDKClient;
861
893
  Control,
862
894
  CustomComponent,
863
895
  CustomComponentType,
896
+ ExField,
864
897
  Field,
865
898
  FieldType,
866
899
  FlowMode,
@@ -883,6 +916,7 @@ var src_default = SDKClient;
883
916
  Shared,
884
917
  Space,
885
918
  Storage,
919
+ SubFieldType,
886
920
  Tab,
887
921
  Toast,
888
922
  Utils,
@@ -697,6 +697,89 @@ 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: string;
742
+ name: string;
743
+ children?: ExFieldConfig[];
744
+ }
745
+ interface ExFieldValidateMsg {
746
+ /**
747
+ * code 为 200 时 msg 按照正常成功数据返回外
748
+ * 401 | 401 | 403 | 404 | 405 | 406 按照 InvalidParams 类型异常返回,可以通过该异常的 errCode、errMsg 属性查看具体出错原因
749
+ * 其余执行过程异常按照 InternalError 异常抛出
750
+ * 具体的 code 和对应的 msg 信息及解释可参考开发者手册的详细介绍
751
+ */
752
+ code: 200 | 401 | 401 | 403 | 404 | 405 | 406;
753
+ msg: string;
754
+ }
755
+ declare enum SubFieldType {
756
+ /**
757
+ * 数字类型
758
+ */
759
+ FieldNumber = "number",
760
+ /**
761
+ * 多行文本
762
+ * 字段类型为 text
763
+ * 在字段模型中和单行文本字段的区别为 multi = true
764
+ */
765
+ FieldMultiText = "text",
766
+ /**
767
+ * 级联多选
768
+ * 如果写入不存在的选项可能导致接口报错/提示
769
+ */
770
+ FieldTreeSelect = "tree-multi-select",
771
+ /**
772
+ * 时间+日期
773
+ * 字段类型为 date
774
+ * 在字段模型中和普通日期字段的区别是本时间精确度为 "YYYY-MM-DD HH:mm:ss"(普通为 YYYY-MM-DD)
775
+ */
776
+ FieldDatePrecise = "date",
777
+ /**
778
+ * 多选人员
779
+ * 如果写入不存在的人员可能导致接口报错/提示
780
+ */
781
+ FieldMultiUser = "multi-user"
782
+ }
700
783
  /**
701
784
  * 构成弹窗配置
702
785
  */
@@ -1047,12 +1130,13 @@ declare abstract class Navigation extends BaseModel {
1047
1130
  private static load;
1048
1131
  /**
1049
1132
  * @public
1050
- * only web 2.0
1051
- * 读取当前页面地址的 origin
1133
+ * mobile version ≥ 7.41.0
1134
+ * 读取当前页面地址的 hostname
1052
1135
  */
1053
- abstract getOrigin(): Promise<string>;
1136
+ abstract getHostname(): Promise<string>;
1054
1137
  /**
1055
- *
1138
+ * @public
1139
+ * only web 2.0
1056
1140
  * 读取当前完整的页面地址
1057
1141
  */
1058
1142
  abstract getHref(): Promise<string>;
@@ -1840,6 +1924,70 @@ declare abstract class CustomComponent extends BaseModel {
1840
1924
  };
1841
1925
  }
1842
1926
 
1927
+ /**
1928
+ * @public
1929
+ * 自定义组件构成
1930
+ */
1931
+ declare abstract class ExField extends BaseModel {
1932
+ /**
1933
+ * @internal
1934
+ */
1935
+ protected static [IMPL_KEY]: string;
1936
+ abstract getContext: () => Promise<ExFieldFeatureContext>;
1937
+ abstract getProps: () => Promise<ExFieldProps>;
1938
+ /**
1939
+ * only for form
1940
+ * 用于监听 props 变更
1941
+ * @param callback 返回插件字段新的 props
1942
+ * @param watchKeys 监听的 key,只能监听属性的 key(不能监听 api key),不传默认监听所有 key。监听的 key 对应的值变更会触发回调
1943
+ * @returns
1944
+ */
1945
+ abstract watch: (callback: (next: ExFieldProps | Record<string, never>) => void, watchKeys?: (keyof ExFieldProps)[]) => Promise<Off>;
1946
+ abstract saveFieldValue: (value: ExFieldValueType) => Promise<ExFieldValidateMsg>;
1947
+ abstract getFieldConfig: () => Promise<ExFieldConfig>;
1948
+ /**
1949
+ * 获取新建工作项表单项的值
1950
+ * mobile version ≥ 7.29.0
1951
+ * @param keys 需要获取的工作项属性 / 字段 ID 列表,一次限制读取 10 个 keys
1952
+ * @param keys.key 工作项属性 / 字段 ID
1953
+ * @param keys.type 类型
1954
+ * 工作项属性 name 为 FieldType.text,工作项属性 template 为 FieldType.number
1955
+ * 控件 role_owners 为 FieldType.control
1956
+ */
1957
+ abstract getCreateWorkItemFormItemValues(keys: Array<{
1958
+ key: string | AttributeType;
1959
+ type: Exclude<FieldType, FieldType.richText | FieldType.singleSignal | FieldType.multiSignal | FieldType.singleVoting | FieldType.multiVoting | FieldType.simpleVoting>;
1960
+ }>): Promise<Record<string | AttributeType, any>>;
1961
+ /**
1962
+ * 监听工作项表单项值变化
1963
+ * @param options.watchKeys 需要监听的工作项 字段 ID 列表
1964
+ * @param callback 当监听值发生变化时触发,changedValue 为变化的 kv
1965
+ */
1966
+ abstract onWorkItemFormValueChanged(options: {
1967
+ watchKeys: Array<{
1968
+ key: string | AttributeType;
1969
+ type: Exclude<FieldType, FieldType.richText | FieldType.singleSignal | FieldType.multiSignal | FieldType.singleVoting | FieldType.multiVoting | FieldType.simpleVoting>;
1970
+ }>;
1971
+ }, callback: (changedValue: Record<string, unknown>) => void): Promise<Off>;
1972
+ /**
1973
+ * only web for table
1974
+ * 打开全屏插件
1975
+ */
1976
+ abstract getTableCellInitProps(): Promise<ExFieldProps>;
1977
+ /**
1978
+ * only mobile 7.35.0+
1979
+ * 获取插件的展示态信息
1980
+ */
1981
+ abstract getDisplayInfo(): Promise<{
1982
+ display_height: number;
1983
+ }>;
1984
+ /**
1985
+ * only mobile 7.35.0+
1986
+ * 打开全屏插件
1987
+ */
1988
+ abstract openFullScreenPlugin(): void;
1989
+ }
1990
+
1843
1991
  /**
1844
1992
  * @public
1845
1993
  * SDKClient 的配置项
@@ -2029,9 +2177,12 @@ declare class OutOfLimitError extends CustomError {
2029
2177
  * 请求参数异常
2030
2178
  */
2031
2179
  declare class InvalidParamsError extends CustomError {
2180
+ errCode: number;
2181
+ errMsg: string;
2032
2182
  constructor(options: {
2033
2183
  originMessage: string;
2034
2184
  });
2185
+ _parseErrorCode(): void;
2035
2186
  }
2036
2187
 
2037
2188
  /**
@@ -2053,4 +2204,4 @@ declare class NotSupportedError extends CustomError {
2053
2204
  * @packageDocumentation
2054
2205
  */
2055
2206
 
2056
- 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 };
2207
+ 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.5",
3
+ "version": "2.0.8-dev.7",
4
4
  "runtimeMinVersions": {
5
5
  "web": "2.1.0",
6
6
  "mobile": "1.1.0"