@lark-project/js-sdk 2.0.8-dev.0 → 2.0.8-dev.2

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/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.0";
637
+ SDKClient.version = "2.0.8-dev.2";
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._parseErrorCode();
790
+ }
791
+ _parseErrorCode() {
792
+ try {
793
+ const { errCode, errMsg } = JSON.parse(this.originMessage);
794
+ this.errCode = errCode;
795
+ this.errMsg = errMsg;
796
+ } catch (e) {
797
+ this.errMsg = this.originMessage;
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.0";
704
+ SDKClient.version = "2.0.8-dev.2";
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._parseErrorCode();
857
+ }
858
+ _parseErrorCode() {
859
+ try {
860
+ const { errCode, errMsg } = JSON.parse(this.originMessage);
861
+ this.errCode = errCode;
862
+ this.errMsg = errMsg;
863
+ } catch (e) {
864
+ this.errMsg = this.originMessage;
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,
@@ -379,36 +379,10 @@ interface CreateButtonFeatureContext {
379
379
  */
380
380
  viewId?: string;
381
381
  }
382
- /**
383
- * 视图批量按钮上下文
384
- * 适用场景:普通视图、工作项主页视图、工作台视图组件
385
- */
386
- interface BatchButtonFeatureContext {
387
- /**
388
- * 视图所属空间标识
389
- */
390
- spaceId: string;
391
- /**
392
- * 视图所属工作项类型标识
393
- */
394
- workObjectId: string;
395
- /**
396
- * 视图标识
397
- */
398
- viewId?: string;
399
- /**
400
- * 勾选的工作项实例
401
- */
402
- selectedWorkItems: Array<{
403
- spaceId: string;
404
- workObjectId: string;
405
- workItemIds: number[];
406
- }>;
407
- }
408
382
  /**
409
383
  * 按钮构成
410
384
  */
411
- type ButtonFeatureContext = WorkItemButtonFeatureContext | CreateButtonFeatureContext | BatchButtonFeatureContext;
385
+ type ButtonFeatureContext = WorkItemButtonFeatureContext | CreateButtonFeatureContext;
412
386
  /**
413
387
  * 内嵌页面构成
414
388
  * 一个单独的导航入口+内嵌页面
@@ -658,6 +632,71 @@ interface CustomComponentProps {
658
632
  disabled?: boolean;
659
633
  };
660
634
  }
635
+ /** ----------------------- 拓展字段构成类型 ----------------------- */
636
+ interface ExFieldFeatureContext {
637
+ /**
638
+ * 控件当前所属空间标识
639
+ */
640
+ spaceId: string;
641
+ /**
642
+ * 控件当前所属工作项类型标识
643
+ */
644
+ workObjectId: string;
645
+ /**
646
+ * 控件当前所属工作项实例标识
647
+ * 新建页表单内该值为空
648
+ */
649
+ workItemId?: number;
650
+ /**
651
+ * 当前节点标识
652
+ * 适用场景:详情页为节点流时,且当前控件位于节点表单内,该字段才有数据
653
+ */
654
+ nodeId?: string;
655
+ }
656
+ type FieldNumberValue = number;
657
+ type FieldMultiTextValue = string;
658
+ type FieldTreeSelectOptionValue = string[];
659
+ type FieldDatePreciseValue = string | number;
660
+ type FieldMultiUserValue = string[];
661
+ type FieldValue = FieldNumberValue | FieldMultiTextValue | FieldTreeSelectOptionValue | FieldDatePreciseValue | FieldMultiUserValue;
662
+ interface ExCompoundFieldValueType {
663
+ field_key: string;
664
+ field_value: {
665
+ field_key: string;
666
+ value?: FieldValue;
667
+ }[][];
668
+ }
669
+ type ExFieldValueType = ExCompoundFieldValueType;
670
+ interface ExFieldProps {
671
+ value: ExFieldValueType;
672
+ disabled?: boolean;
673
+ }
674
+ interface ExFieldConfig {
675
+ key: string;
676
+ type: string;
677
+ name: string;
678
+ children?: ExFieldConfig[];
679
+ }
680
+ interface ExFieldValidateMsg {
681
+ code: 200 | number;
682
+ msg: string;
683
+ }
684
+ declare enum SubFieldType {
685
+ FieldNumber = "number",
686
+ /**
687
+ * 开发者后台使用 multi-pure-text 作为 type,
688
+ * 工作项后端会转为 text + { multi: true }
689
+ */
690
+ FieldMultiText = "text",
691
+ FieldTreeSelect = "tree-multi-select",
692
+ /**
693
+ * 开发者后台使用 precise_date 作为 type,
694
+ * 工作项后端会转为 date + format "YYYY-MM-DD HH:mm:ss"
695
+ * (普通为 YYYY-MM-DD)
696
+ */
697
+ FieldDatePrecise = "date",
698
+ FieldMultiUser = "multi-user"
699
+ }
661
700
 
662
701
  /**
663
702
  * @internal
@@ -1770,6 +1809,70 @@ declare abstract class CustomComponent extends BaseModel {
1770
1809
  };
1771
1810
  }
1772
1811
 
1812
+ /**
1813
+ * @public
1814
+ * 自定义组件构成
1815
+ */
1816
+ declare abstract class ExField extends BaseModel {
1817
+ /**
1818
+ * @internal
1819
+ */
1820
+ protected static [IMPL_KEY]: string;
1821
+ abstract getContext: () => Promise<ExFieldFeatureContext>;
1822
+ abstract getProps: () => Promise<ExFieldProps>;
1823
+ /**
1824
+ * only for form
1825
+ * 用于监听 props 变更
1826
+ * @param callback 返回插件字段新的 props
1827
+ * @param watchKeys 监听的 key,只能监听属性的 key(不能监听 api key),不传默认监听所有 key。监听的 key 对应的值变更会触发回调
1828
+ * @returns
1829
+ */
1830
+ abstract watch: (callback: (next: ExFieldProps | Record<string, never>) => void, watchKeys?: (keyof ExFieldProps)[]) => Off;
1831
+ abstract saveFieldValue: (value: ExFieldValueType) => Promise<ExFieldValidateMsg>;
1832
+ abstract getFieldConfig: () => Promise<ExFieldConfig>;
1833
+ /**
1834
+ * 获取新建工作项表单项的值
1835
+ * mobile version ≥ 7.29.0
1836
+ * @param keys 需要获取的工作项属性 / 字段 ID 列表,一次限制读取 10 个 keys
1837
+ * @param keys.key 工作项属性 / 字段 ID
1838
+ * @param keys.type 类型
1839
+ * 工作项属性 name 为 FieldType.text,工作项属性 template 为 FieldType.number
1840
+ * 控件 role_owners 为 FieldType.control
1841
+ */
1842
+ abstract getCreateWorkItemFormItemValues(keys: Array<{
1843
+ key: string | AttributeType;
1844
+ type: Exclude<FieldType, FieldType.richText | FieldType.singleSignal | FieldType.multiSignal | FieldType.singleVoting | FieldType.multiVoting | FieldType.simpleVoting>;
1845
+ }>): Promise<Record<string | AttributeType, any>>;
1846
+ /**
1847
+ * 监听工作项表单项值变化
1848
+ * @param options.watchKeys 需要监听的工作项 字段 ID 列表
1849
+ * @param callback 当监听值发生变化时触发,changedValue 为变化的 kv
1850
+ */
1851
+ abstract onWorkItemFormValueChanged(options: {
1852
+ watchKeys: Array<{
1853
+ key: string | AttributeType;
1854
+ type: Exclude<FieldType, FieldType.richText | FieldType.singleSignal | FieldType.multiSignal | FieldType.singleVoting | FieldType.multiVoting | FieldType.simpleVoting>;
1855
+ }>;
1856
+ }, callback: (changedValue: Record<string, unknown>) => void): Promise<Off>;
1857
+ /**
1858
+ * only web for table
1859
+ * 打开全屏插件
1860
+ */
1861
+ abstract getTableCellInitProps(): Promise<ExFieldProps>;
1862
+ /**
1863
+ * only mobile 7.35.0+
1864
+ * 获取插件的展示态信息
1865
+ */
1866
+ abstract getDisplayInfo(): Promise<{
1867
+ display_height: number;
1868
+ }>;
1869
+ /**
1870
+ * only mobile 7.35.0+
1871
+ * 打开全屏插件
1872
+ */
1873
+ abstract openFullScreenPlugin(): void;
1874
+ }
1875
+
1773
1876
  /**
1774
1877
  * @public
1775
1878
  * SDKClient 的配置项
@@ -1959,9 +2062,12 @@ declare class OutOfLimitError extends CustomError {
1959
2062
  * 请求参数异常
1960
2063
  */
1961
2064
  declare class InvalidParamsError extends CustomError {
2065
+ errCode: number;
2066
+ errMsg: string;
1962
2067
  constructor(options: {
1963
2068
  originMessage: string;
1964
2069
  });
2070
+ _parseErrorCode(): void;
1965
2071
  }
1966
2072
 
1967
2073
  /**
@@ -1983,4 +2089,4 @@ declare class NotSupportedError extends CustomError {
1983
2089
  * @packageDocumentation
1984
2090
  */
1985
2091
 
1986
- export { ActionSheet, ActionSheetOptions, AttributeType, BatchButtonFeatureContext, BizLine, BriefField, BriefNode, BriefSpace, BriefTemplate, BriefView, BriefWorkItem, BriefWorkObject, Button, ButtonFeatureContext, ButtonScene, Clipboard, ColorScheme, ComponentScheduleIdentity, ComponentScheduleScene, Configuration, ConfigurationFeatureContext, ContainerModal, 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, Shared, Space, Storage, Tab, TabFeatureContext, Toast, ToastOptions, User, UserInfo, Utils, View, ViewFeatureContext, WbsStatus, WorkItem, WorkItemButtonFeatureContext, WorkItemCreateFormPreset, WorkItemFinder, WorkItemFinderOptions, WorkObject, SDKClient as default, unwatch };
2092
+ export { ActionSheet, ActionSheetOptions, AttributeType, BizLine, BriefField, BriefNode, BriefSpace, BriefTemplate, BriefView, BriefWorkItem, BriefWorkObject, Button, ButtonFeatureContext, ButtonScene, Clipboard, ColorScheme, ComponentScheduleIdentity, ComponentScheduleScene, Configuration, ConfigurationFeatureContext, ContainerModal, 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, 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.0",
3
+ "version": "2.0.8-dev.2",
4
4
  "runtimeMinVersions": {
5
5
  "web": "2.1.0",
6
6
  "mobile": "1.1.0"