@nocobase/client 0.14.0-alpha.3 → 0.14.0-alpha.4

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/es/index.mjs CHANGED
@@ -2032,6 +2032,19 @@ class APIClient extends APIClient$1 {
2032
2032
  });
2033
2033
  super.interceptors();
2034
2034
  this.useNotificationMiddleware();
2035
+ this.axios.interceptors.response.use(
2036
+ (response) => {
2037
+ return response;
2038
+ },
2039
+ (error2) => {
2040
+ var _a, _b;
2041
+ const errs = ((_b = (_a = error2 == null ? void 0 : error2.response) == null ? void 0 : _a.data) == null ? void 0 : _b.errors) || [{ message: "Server error" }];
2042
+ if (errs.find((error22) => error22.code === "ROLE_NOT_FOUND_ERR")) {
2043
+ this.auth.setRole(null);
2044
+ }
2045
+ throw error2;
2046
+ }
2047
+ );
2035
2048
  }
2036
2049
  useNotificationMiddleware() {
2037
2050
  this.axios.interceptors.response.use(
@@ -2267,7 +2280,7 @@ const useSaveCurrentUserValues$1 = () => {
2267
2280
  run() {
2268
2281
  return __async(this, null, function* () {
2269
2282
  yield form.submit();
2270
- yield api.resource("users").changePassword({
2283
+ yield api.resource("auth").changePassword({
2271
2284
  values: form.values
2272
2285
  });
2273
2286
  yield form.reset();
@@ -6041,6 +6054,7 @@ const DuplicateAction = observer((props) => {
6041
6054
  ) : /* @__PURE__ */ jsx(
6042
6055
  Button,
6043
6056
  __spreadProps(__spreadValues({
6057
+ "data-testid": "duplicate-action",
6044
6058
  disabled,
6045
6059
  style: {
6046
6060
  opacity: designable && ((_b = field == null ? void 0 : field.data) == null ? void 0 : _b.hidden) && 0.1
@@ -9840,12 +9854,26 @@ function useIsShowMultipleSwitch() {
9840
9854
  return !field.readPretty && fieldSchema["x-component"] !== "TableField" && hasMultiple && fieldMode !== "SubTable";
9841
9855
  };
9842
9856
  }
9857
+ const getTestId = (schema3) => {
9858
+ var _a;
9859
+ const resource = (_a = schema3 == null ? void 0 : schema3["x-decorator-props"]) == null ? void 0 : _a["resource"];
9860
+ if (resource) {
9861
+ return `${resource}-resource`;
9862
+ }
9863
+ const field = schema3["x-collection-field"];
9864
+ if (field) {
9865
+ return `${field}-field`;
9866
+ }
9867
+ return `${schema3.name}-item`;
9868
+ };
9843
9869
  const BlockItem = (props) => {
9844
9870
  const { className, children } = useProps(props);
9845
9871
  const Designer4 = useDesigner();
9872
+ const schema3 = useFieldSchema();
9846
9873
  return /* @__PURE__ */ jsxs(
9847
9874
  SortableItem,
9848
9875
  {
9876
+ "data-testid": getTestId(schema3),
9849
9877
  className: cls(
9850
9878
  "nb-block-item",
9851
9879
  className,
@@ -10130,7 +10158,7 @@ const useFilterableFields = (collectionName) => {
10130
10158
  return false;
10131
10159
  }
10132
10160
  const fieldInterface = getInterface(field.interface);
10133
- if (!fieldInterface.filterable) {
10161
+ if (!(fieldInterface == null ? void 0 : fieldInterface.filterable)) {
10134
10162
  return false;
10135
10163
  }
10136
10164
  return true;
@@ -10243,6 +10271,7 @@ const DesignableSwitch = () => {
10243
10271
  return /* @__PURE__ */ jsx(Tooltip$1, { title: t("UI Editor"), children: /* @__PURE__ */ jsx(
10244
10272
  Button,
10245
10273
  {
10274
+ "data-testid": "ui-editor-button",
10246
10275
  icon: /* @__PURE__ */ jsx(HighlightOutlined, {}),
10247
10276
  title: t("UI Editor"),
10248
10277
  style,
@@ -10921,7 +10950,7 @@ const useGetFilterFieldOptions = () => {
10921
10950
  return;
10922
10951
  }
10923
10952
  const fieldInterface = getInterface(field.interface);
10924
- if (!fieldInterface.filterable) {
10953
+ if (!(fieldInterface == null ? void 0 : fieldInterface.filterable)) {
10925
10954
  return;
10926
10955
  }
10927
10956
  const { nested, children, operators: operators2 } = fieldInterface.filterable;
@@ -10978,7 +11007,7 @@ const useFilterFieldOptions = (fields2) => {
10978
11007
  return;
10979
11008
  }
10980
11009
  const fieldInterface = getInterface(field.interface);
10981
- if (!fieldInterface.filterable) {
11010
+ if (!(fieldInterface == null ? void 0 : fieldInterface.filterable)) {
10982
11011
  return;
10983
11012
  }
10984
11013
  const { nested, children, operators: operators2 } = fieldInterface.filterable;
@@ -13219,8 +13248,9 @@ const TableColumnDesigner$1 = (props) => {
13219
13248
  title: t("Field component"),
13220
13249
  options: readOnlyMode === "read-pretty" ? [
13221
13250
  { label: t("Title"), value: "Select" },
13251
+ isFileField && { label: t("File manager"), value: "FileManager" },
13222
13252
  { label: t("Tag"), value: "Tag" }
13223
- ] : fieldModeOptions,
13253
+ ].filter(Boolean) : fieldModeOptions,
13224
13254
  value: fieldMode,
13225
13255
  onChange: (mode) => {
13226
13256
  const schema3 = {
@@ -15788,7 +15818,7 @@ const useVariableTypes = (currentCollection, excludes = []) => {
15788
15818
  return;
15789
15819
  }
15790
15820
  const fieldInterface = getInterface(field.interface);
15791
- if (!fieldInterface.filterable) {
15821
+ if (!(fieldInterface == null ? void 0 : fieldInterface.filterable)) {
15792
15822
  return;
15793
15823
  }
15794
15824
  const { nested, children } = fieldInterface.filterable;
@@ -22342,7 +22372,9 @@ const Action = observer(
22342
22372
  }
22343
22373
  return /* @__PURE__ */ jsxs(
22344
22374
  SortableItem,
22345
- __spreadProps(__spreadValues({}, others), {
22375
+ __spreadProps(__spreadValues({
22376
+ "data-testid": `${fieldSchema["x-action"] || fieldSchema.name}-action`
22377
+ }, others), {
22346
22378
  loading: (_b2 = field == null ? void 0 : field.data) == null ? void 0 : _b2.loading,
22347
22379
  icon: icon2 ? /* @__PURE__ */ jsx(Icon, { type: icon2 }) : null,
22348
22380
  disabled,
@@ -32450,9 +32482,13 @@ const ReadPrettyInternalViewer = observer(
32450
32482
  );
32451
32483
  const useTableSelectorProps$1 = () => {
32452
32484
  const field = useField();
32453
- const { multiple, options = [], setSelectedRows, selectedRows: rcSelectRows = [], onChange } = useContext(
32454
- RecordPickerContext
32455
- );
32485
+ const {
32486
+ multiple,
32487
+ options = [],
32488
+ setSelectedRows,
32489
+ selectedRows: rcSelectRows = [],
32490
+ onChange
32491
+ } = useContext(RecordPickerContext);
32456
32492
  const _a = useTableSelectorProps$3(), { onRowSelectionChange, rowKey = "id" } = _a, others = __objRest(_a, ["onRowSelectionChange", "rowKey"]);
32457
32493
  const { setVisible } = useActionContext();
32458
32494
  return __spreadProps(__spreadValues({}, others), {
@@ -32600,14 +32636,15 @@ const InternalFileManager = (props) => {
32600
32636
  ] });
32601
32637
  };
32602
32638
  const FileManageReadPretty = connect((props) => {
32603
- const field = useField();
32604
32639
  const fieldNames = useFieldNames$1(props);
32640
+ const fieldSchema = useFieldSchema();
32605
32641
  const { getField } = useCollection();
32606
- const collectionField = getField(field.props.name);
32642
+ const { getCollectionJoinField } = useCollectionManager();
32643
+ const collectionField = getField(fieldSchema.name) || getCollectionJoinField(fieldSchema["x-collection-field"]);
32607
32644
  const labelUiSchema = useLabelUiSchema$1(collectionField == null ? void 0 : collectionField.target, (fieldNames == null ? void 0 : fieldNames.label) || "label");
32608
32645
  const showFilePicker = isShowFilePicker$1(labelUiSchema);
32609
32646
  if (showFilePicker) {
32610
- return collectionField ? /* @__PURE__ */ jsx(Preview, __spreadProps(__spreadValues({}, props), { fieldNames })) : null;
32647
+ return /* @__PURE__ */ jsx(EllipsisWithTooltip, { ellipsis: true, children: collectionField ? /* @__PURE__ */ jsx(Preview, __spreadProps(__spreadValues({}, props), { fieldNames })) : null });
32611
32648
  } else {
32612
32649
  return /* @__PURE__ */ jsx(ReadPrettyInternalViewer, __spreadValues({}, props));
32613
32650
  }
@@ -32620,33 +32657,34 @@ const InternalNester = observer(
32620
32657
  const insertNester = useInsertSchema("Nester");
32621
32658
  const { options: collectionField } = useAssociationFieldContext();
32622
32659
  const showTitle = (_b = (_a = fieldSchema["x-decorator-props"]) == null ? void 0 : _a.showTitle) != null ? _b : true;
32660
+ const { actionName } = useACLActionParamsContext();
32623
32661
  useEffect(() => {
32624
32662
  insertNester(schema$1.Nester);
32625
32663
  }, []);
32626
- return /* @__PURE__ */ jsx(CollectionProvider, { name: collectionField.target, children: /* @__PURE__ */ jsx(FormLayout, { layout: "vertical", children: /* @__PURE__ */ jsx(
32664
+ return /* @__PURE__ */ jsx(CollectionProvider, { name: collectionField.target, children: /* @__PURE__ */ jsx(ACLCollectionProvider, { actionPath: `${collectionField.target}:${actionName}`, children: /* @__PURE__ */ jsx(FormLayout, { layout: "vertical", children: /* @__PURE__ */ jsx(
32627
32665
  "div",
32628
32666
  {
32629
32667
  className: cx(
32630
32668
  css`
32631
- & .ant-formily-item-layout-vertical {
32632
- margin-bottom: 10px;
32633
- }
32634
- .ant-card-body {
32635
- padding: 15px 20px 5px;
32636
- }
32637
- .ant-divider-horizontal {
32638
- margin: 10px 0;
32639
- }
32640
- `,
32641
- {
32642
- [css`
32669
+ & .ant-formily-item-layout-vertical {
32670
+ margin-bottom: 10px;
32671
+ }
32643
32672
  .ant-card-body {
32644
- padding: 0px 20px 20px 0px;
32673
+ padding: 15px 20px 5px;
32645
32674
  }
32646
- > .ant-card-bordered {
32647
- border: none;
32675
+ .ant-divider-horizontal {
32676
+ margin: 10px 0;
32648
32677
  }
32649
- `]: showTitle === false
32678
+ `,
32679
+ {
32680
+ [css`
32681
+ .ant-card-body {
32682
+ padding: 0px 20px 20px 0px;
32683
+ }
32684
+ > .ant-card-bordered {
32685
+ border: none;
32686
+ }
32687
+ `]: showTitle === false
32650
32688
  }
32651
32689
  ),
32652
32690
  children: /* @__PURE__ */ jsx(
@@ -32661,7 +32699,7 @@ const InternalNester = observer(
32661
32699
  }
32662
32700
  )
32663
32701
  }
32664
- ) }) });
32702
+ ) }) }) });
32665
32703
  },
32666
32704
  { displayName: "InternalNester" }
32667
32705
  );
@@ -32839,6 +32877,7 @@ const InternalSubTable = observer(
32839
32877
  const fieldSchema = useFieldSchema();
32840
32878
  const insert = useInsertSchema("SubTable");
32841
32879
  const { options } = useAssociationFieldContext();
32880
+ const { actionName } = useACLActionParamsContext();
32842
32881
  useEffect(() => {
32843
32882
  insert(schema$1.SubTable);
32844
32883
  field.required = fieldSchema["required"];
@@ -32848,23 +32887,23 @@ const InternalSubTable = observer(
32848
32887
  "Radio.Group": Select,
32849
32888
  "Checkbox.Group": (props) => /* @__PURE__ */ jsx(Select, __spreadValues({ multiple: true, mode: "multiple" }, props))
32850
32889
  });
32851
- return /* @__PURE__ */ jsx(CollectionProvider, { name: options.target, children: /* @__PURE__ */ jsx(
32890
+ return /* @__PURE__ */ jsx(CollectionProvider, { name: options.target, children: /* @__PURE__ */ jsx(ACLCollectionProvider, { actionPath: `${options.target}:${actionName}`, children: /* @__PURE__ */ jsx(
32852
32891
  FormLayout,
32853
32892
  {
32854
32893
  className: css`
32855
- .ant-formily-item-bordered-none {
32856
- .ant-input-number-group-addon {
32857
- border: none !important;
32858
- background: none;
32859
- }
32860
- .ant-checkbox-wrapper {
32861
- margin-left: 8px;
32862
- }
32863
- .ant-table {
32864
- margin: 0px !important;
32894
+ .ant-formily-item-bordered-none {
32895
+ .ant-input-number-group-addon {
32896
+ border: none !important;
32897
+ background: none;
32898
+ }
32899
+ .ant-checkbox-wrapper {
32900
+ margin-left: 8px;
32901
+ }
32902
+ .ant-table {
32903
+ margin: 0px !important;
32904
+ }
32865
32905
  }
32866
- }
32867
- `,
32906
+ `,
32868
32907
  layout: "vertical",
32869
32908
  bordered: false,
32870
32909
  children: /* @__PURE__ */ jsx(
@@ -32888,7 +32927,7 @@ const InternalSubTable = observer(
32888
32927
  }
32889
32928
  )
32890
32929
  }
32891
- ) });
32930
+ ) }) });
32892
32931
  },
32893
32932
  { displayName: "InternalSubTable" }
32894
32933
  );
@@ -33308,7 +33347,7 @@ const useTableColumns$1 = (props) => {
33308
33347
  const { designable } = useDesignable();
33309
33348
  const { exists, render: render2 } = useSchemaInitializer(schema3["x-initializer"]);
33310
33349
  const columns = (_a = schema3.reduceProperties((buf, s2) => {
33311
- if (isColumnComponent$2(s2) && schemaInWhitelist(Object.values(s2.properties || {}).pop(), props == null ? void 0 : props.isSubTable)) {
33350
+ if (isColumnComponent$2(s2) && schemaInWhitelist(Object.values(s2.properties || {}).pop())) {
33312
33351
  return buf.concat([s2]);
33313
33352
  }
33314
33353
  return buf;
@@ -43731,7 +43770,7 @@ const HeaderMenu = ({
43731
43770
  key: "x-designer-button",
43732
43771
  disabled: true,
43733
43772
  style: { padding: "0 8px", order: 9999 },
43734
- label: render2({ style: { background: "none" } }),
43773
+ label: render2({ "data-testid": "add-menu-item-button-in-header", style: { background: "none" } }),
43735
43774
  notdelete: true
43736
43775
  };
43737
43776
  const result = getMenuItems(() => {
@@ -43811,6 +43850,7 @@ const SideMenu = ({
43811
43850
  key: "x-designer-button",
43812
43851
  disabled: true,
43813
43852
  label: render2({
43853
+ "data-testid": "add-menu-item-button-in-side",
43814
43854
  insert: (s2) => {
43815
43855
  const dn = createDesignable({
43816
43856
  t,
@@ -50874,7 +50914,7 @@ const number = {
50874
50914
  }
50875
50915
  }
50876
50916
  },
50877
- availableTypes: ["double"],
50917
+ availableTypes: ["double", "float"],
50878
50918
  hasDefaultValue: true,
50879
50919
  properties: __spreadProps(__spreadValues({}, defaultProps), {
50880
50920
  unique,
@@ -55095,9 +55135,9 @@ const CollectionFields = () => {
55095
55135
  groups2.pf.push(field2);
55096
55136
  } else if (field2.interface) {
55097
55137
  const conf = getInterface(field2.interface);
55098
- if (conf.group === "systemInfo") {
55138
+ if ((conf == null ? void 0 : conf.group) === "systemInfo") {
55099
55139
  groups2.system.push(field2);
55100
- } else if (conf.group === "relation") {
55140
+ } else if ((conf == null ? void 0 : conf.group) === "relation") {
55101
55141
  groups2.association.push(field2);
55102
55142
  } else {
55103
55143
  groups2.general.push(field2);
@@ -55172,7 +55212,6 @@ const CollectionFields = () => {
55172
55212
  );
55173
55213
  const addProps = { type: "primary", database };
55174
55214
  const syncProps = { type: "primary" };
55175
- console.log(dataSource2);
55176
55215
  return /* @__PURE__ */ jsx(ResourceActionProvider, __spreadProps(__spreadValues({}, resourceActionProps), { children: /* @__PURE__ */ jsx(FormContext.Provider, { value: form, children: /* @__PURE__ */ jsxs(FieldContext.Provider, { value: f, children: [
55177
55216
  /* @__PURE__ */ jsxs(
55178
55217
  Space$1,
@@ -57501,6 +57540,7 @@ const useResourceName = () => {
57501
57540
  function useACLRoleContext() {
57502
57541
  const { data, getActionAlias, inResources, getResourceActionParams, getStrategyActionParams } = useACLRolesCheck();
57503
57542
  const allowedActions = useAllowedActions();
57543
+ const { getCollectionJoinField } = useCollectionManager();
57504
57544
  const verifyScope = (actionName, recordPkValue) => {
57505
57545
  const actionAlias = getActionAlias(actionName);
57506
57546
  if (!Array.isArray(allowedActions == null ? void 0 : allowedActions[actionAlias])) {
@@ -57510,7 +57550,9 @@ function useACLRoleContext() {
57510
57550
  };
57511
57551
  return __spreadProps(__spreadValues({}, data), {
57512
57552
  parseAction: (actionPath, options = {}) => {
57553
+ var _a;
57513
57554
  const [resourceName, actionName] = actionPath.split(":");
57555
+ const targetResource = (resourceName == null ? void 0 : resourceName.includes(".")) && ((_a = getCollectionJoinField(resourceName)) == null ? void 0 : _a.target);
57514
57556
  if (!getIgnoreScope(options)) {
57515
57557
  const r = verifyScope(actionName, options.recordPkValue);
57516
57558
  if (r !== null) {
@@ -57520,6 +57562,9 @@ function useACLRoleContext() {
57520
57562
  if (data == null ? void 0 : data.allowAll) {
57521
57563
  return {};
57522
57564
  }
57565
+ if (inResources(targetResource)) {
57566
+ return getResourceActionParams(`${targetResource}:${actionName}`);
57567
+ }
57523
57568
  if (inResources(resourceName)) {
57524
57569
  return getResourceActionParams(actionPath);
57525
57570
  }
@@ -57533,7 +57578,7 @@ const ACLCollectionProvider = (props) => {
57533
57578
  if (allowAll) {
57534
57579
  return props.children;
57535
57580
  }
57536
- const actionPath = schema3 == null ? void 0 : schema3["x-acl-action"];
57581
+ const actionPath = (schema3 == null ? void 0 : schema3["x-acl-action"]) || props.actionPath;
57537
57582
  if (!actionPath) {
57538
57583
  return props.children;
57539
57584
  }
@@ -57541,6 +57586,8 @@ const ACLCollectionProvider = (props) => {
57541
57586
  if (!params) {
57542
57587
  return null;
57543
57588
  }
57589
+ const [_2, actionName] = actionPath.split(":");
57590
+ params.actionName = actionName;
57544
57591
  return /* @__PURE__ */ jsx(ACLActionParamsContext.Provider, { value: params, children: props.children });
57545
57592
  };
57546
57593
  const useACLActionParamsContext = () => {
@@ -57601,7 +57648,8 @@ const ACLCollectionFieldProvider = (props) => {
57601
57648
  const field = useField();
57602
57649
  const { allowAll } = useACLRoleContext();
57603
57650
  const { whitelist } = useACLFieldWhitelist();
57604
- const allowed = whitelist.length > 0 ? whitelist.includes(fieldSchema.name) : true;
57651
+ const [name] = fieldSchema.name.split(".");
57652
+ const allowed = !fieldSchema["x-acl-ignore"] && whitelist.length > 0 ? whitelist.includes(name) : true;
57605
57653
  useEffect(() => {
57606
57654
  if (!allowed) {
57607
57655
  field.required = false;
@@ -59465,6 +59513,7 @@ const PluginManagerLink = () => {
59465
59513
  return /* @__PURE__ */ jsx(Tooltip$1, { title: t("Plugin manager"), children: /* @__PURE__ */ jsx(
59466
59514
  Button,
59467
59515
  {
59516
+ "data-testid": "pm-button",
59468
59517
  icon: /* @__PURE__ */ jsx(ApiOutlined, {}),
59469
59518
  title: t("Plugin manager"),
59470
59519
  onClick: () => {