@nocobase/client 0.14.0-alpha.2 → 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,
@@ -28274,6 +28306,10 @@ const getWebSocketURL = () => {
28274
28306
  const subApp = getSubAppName();
28275
28307
  const queryString = subApp ? `?__appName=${subApp}` : "";
28276
28308
  if (process.env.WEBSOCKET_URL) {
28309
+ const url2 = new URL(process.env.WEBSOCKET_URL);
28310
+ if (url2.hostname === "localhost") {
28311
+ return `${location.protocol === "https:" ? "wss" : "ws"}://${location.hostname}:${url2.port}/ws${queryString}`;
28312
+ }
28277
28313
  return `${process.env.WEBSOCKET_URL}${queryString}`;
28278
28314
  }
28279
28315
  try {
@@ -32446,9 +32482,13 @@ const ReadPrettyInternalViewer = observer(
32446
32482
  );
32447
32483
  const useTableSelectorProps$1 = () => {
32448
32484
  const field = useField();
32449
- const { multiple, options = [], setSelectedRows, selectedRows: rcSelectRows = [], onChange } = useContext(
32450
- RecordPickerContext
32451
- );
32485
+ const {
32486
+ multiple,
32487
+ options = [],
32488
+ setSelectedRows,
32489
+ selectedRows: rcSelectRows = [],
32490
+ onChange
32491
+ } = useContext(RecordPickerContext);
32452
32492
  const _a = useTableSelectorProps$3(), { onRowSelectionChange, rowKey = "id" } = _a, others = __objRest(_a, ["onRowSelectionChange", "rowKey"]);
32453
32493
  const { setVisible } = useActionContext();
32454
32494
  return __spreadProps(__spreadValues({}, others), {
@@ -32596,14 +32636,15 @@ const InternalFileManager = (props) => {
32596
32636
  ] });
32597
32637
  };
32598
32638
  const FileManageReadPretty = connect((props) => {
32599
- const field = useField();
32600
32639
  const fieldNames = useFieldNames$1(props);
32640
+ const fieldSchema = useFieldSchema();
32601
32641
  const { getField } = useCollection();
32602
- const collectionField = getField(field.props.name);
32642
+ const { getCollectionJoinField } = useCollectionManager();
32643
+ const collectionField = getField(fieldSchema.name) || getCollectionJoinField(fieldSchema["x-collection-field"]);
32603
32644
  const labelUiSchema = useLabelUiSchema$1(collectionField == null ? void 0 : collectionField.target, (fieldNames == null ? void 0 : fieldNames.label) || "label");
32604
32645
  const showFilePicker = isShowFilePicker$1(labelUiSchema);
32605
32646
  if (showFilePicker) {
32606
- 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 });
32607
32648
  } else {
32608
32649
  return /* @__PURE__ */ jsx(ReadPrettyInternalViewer, __spreadValues({}, props));
32609
32650
  }
@@ -32616,33 +32657,34 @@ const InternalNester = observer(
32616
32657
  const insertNester = useInsertSchema("Nester");
32617
32658
  const { options: collectionField } = useAssociationFieldContext();
32618
32659
  const showTitle = (_b = (_a = fieldSchema["x-decorator-props"]) == null ? void 0 : _a.showTitle) != null ? _b : true;
32660
+ const { actionName } = useACLActionParamsContext();
32619
32661
  useEffect(() => {
32620
32662
  insertNester(schema$1.Nester);
32621
32663
  }, []);
32622
- 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(
32623
32665
  "div",
32624
32666
  {
32625
32667
  className: cx(
32626
32668
  css`
32627
- & .ant-formily-item-layout-vertical {
32628
- margin-bottom: 10px;
32629
- }
32630
- .ant-card-body {
32631
- padding: 15px 20px 5px;
32632
- }
32633
- .ant-divider-horizontal {
32634
- margin: 10px 0;
32635
- }
32636
- `,
32637
- {
32638
- [css`
32669
+ & .ant-formily-item-layout-vertical {
32670
+ margin-bottom: 10px;
32671
+ }
32639
32672
  .ant-card-body {
32640
- padding: 0px 20px 20px 0px;
32673
+ padding: 15px 20px 5px;
32641
32674
  }
32642
- > .ant-card-bordered {
32643
- border: none;
32675
+ .ant-divider-horizontal {
32676
+ margin: 10px 0;
32644
32677
  }
32645
- `]: 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
32646
32688
  }
32647
32689
  ),
32648
32690
  children: /* @__PURE__ */ jsx(
@@ -32657,7 +32699,7 @@ const InternalNester = observer(
32657
32699
  }
32658
32700
  )
32659
32701
  }
32660
- ) }) });
32702
+ ) }) }) });
32661
32703
  },
32662
32704
  { displayName: "InternalNester" }
32663
32705
  );
@@ -32835,6 +32877,7 @@ const InternalSubTable = observer(
32835
32877
  const fieldSchema = useFieldSchema();
32836
32878
  const insert = useInsertSchema("SubTable");
32837
32879
  const { options } = useAssociationFieldContext();
32880
+ const { actionName } = useACLActionParamsContext();
32838
32881
  useEffect(() => {
32839
32882
  insert(schema$1.SubTable);
32840
32883
  field.required = fieldSchema["required"];
@@ -32844,23 +32887,23 @@ const InternalSubTable = observer(
32844
32887
  "Radio.Group": Select,
32845
32888
  "Checkbox.Group": (props) => /* @__PURE__ */ jsx(Select, __spreadValues({ multiple: true, mode: "multiple" }, props))
32846
32889
  });
32847
- 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(
32848
32891
  FormLayout,
32849
32892
  {
32850
32893
  className: css`
32851
- .ant-formily-item-bordered-none {
32852
- .ant-input-number-group-addon {
32853
- border: none !important;
32854
- background: none;
32855
- }
32856
- .ant-checkbox-wrapper {
32857
- margin-left: 8px;
32858
- }
32859
- .ant-table {
32860
- 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
+ }
32861
32905
  }
32862
- }
32863
- `,
32906
+ `,
32864
32907
  layout: "vertical",
32865
32908
  bordered: false,
32866
32909
  children: /* @__PURE__ */ jsx(
@@ -32884,7 +32927,7 @@ const InternalSubTable = observer(
32884
32927
  }
32885
32928
  )
32886
32929
  }
32887
- ) });
32930
+ ) }) });
32888
32931
  },
32889
32932
  { displayName: "InternalSubTable" }
32890
32933
  );
@@ -33304,7 +33347,7 @@ const useTableColumns$1 = (props) => {
33304
33347
  const { designable } = useDesignable();
33305
33348
  const { exists, render: render2 } = useSchemaInitializer(schema3["x-initializer"]);
33306
33349
  const columns = (_a = schema3.reduceProperties((buf, s2) => {
33307
- 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())) {
33308
33351
  return buf.concat([s2]);
33309
33352
  }
33310
33353
  return buf;
@@ -43727,7 +43770,7 @@ const HeaderMenu = ({
43727
43770
  key: "x-designer-button",
43728
43771
  disabled: true,
43729
43772
  style: { padding: "0 8px", order: 9999 },
43730
- label: render2({ style: { background: "none" } }),
43773
+ label: render2({ "data-testid": "add-menu-item-button-in-header", style: { background: "none" } }),
43731
43774
  notdelete: true
43732
43775
  };
43733
43776
  const result = getMenuItems(() => {
@@ -43807,6 +43850,7 @@ const SideMenu = ({
43807
43850
  key: "x-designer-button",
43808
43851
  disabled: true,
43809
43852
  label: render2({
43853
+ "data-testid": "add-menu-item-button-in-side",
43810
43854
  insert: (s2) => {
43811
43855
  const dn = createDesignable({
43812
43856
  t,
@@ -50870,7 +50914,7 @@ const number = {
50870
50914
  }
50871
50915
  }
50872
50916
  },
50873
- availableTypes: ["double"],
50917
+ availableTypes: ["double", "float"],
50874
50918
  hasDefaultValue: true,
50875
50919
  properties: __spreadProps(__spreadValues({}, defaultProps), {
50876
50920
  unique,
@@ -55091,9 +55135,9 @@ const CollectionFields = () => {
55091
55135
  groups2.pf.push(field2);
55092
55136
  } else if (field2.interface) {
55093
55137
  const conf = getInterface(field2.interface);
55094
- if (conf.group === "systemInfo") {
55138
+ if ((conf == null ? void 0 : conf.group) === "systemInfo") {
55095
55139
  groups2.system.push(field2);
55096
- } else if (conf.group === "relation") {
55140
+ } else if ((conf == null ? void 0 : conf.group) === "relation") {
55097
55141
  groups2.association.push(field2);
55098
55142
  } else {
55099
55143
  groups2.general.push(field2);
@@ -55168,7 +55212,6 @@ const CollectionFields = () => {
55168
55212
  );
55169
55213
  const addProps = { type: "primary", database };
55170
55214
  const syncProps = { type: "primary" };
55171
- console.log(dataSource2);
55172
55215
  return /* @__PURE__ */ jsx(ResourceActionProvider, __spreadProps(__spreadValues({}, resourceActionProps), { children: /* @__PURE__ */ jsx(FormContext.Provider, { value: form, children: /* @__PURE__ */ jsxs(FieldContext.Provider, { value: f, children: [
55173
55216
  /* @__PURE__ */ jsxs(
55174
55217
  Space$1,
@@ -56712,7 +56755,7 @@ const TabTitle = observer(
56712
56755
  const TabBar = ({ item }) => {
56713
56756
  const { t } = useTranslation();
56714
56757
  const compile2 = useCompile();
56715
- return /* @__PURE__ */ jsxs("span", { children: [
56758
+ return /* @__PURE__ */ jsxs(Space$1, { children: [
56716
56759
  /* @__PURE__ */ jsx(Badge, { color: item.color }),
56717
56760
  t(compile2(item.name))
56718
56761
  ] });
@@ -57497,6 +57540,7 @@ const useResourceName = () => {
57497
57540
  function useACLRoleContext() {
57498
57541
  const { data, getActionAlias, inResources, getResourceActionParams, getStrategyActionParams } = useACLRolesCheck();
57499
57542
  const allowedActions = useAllowedActions();
57543
+ const { getCollectionJoinField } = useCollectionManager();
57500
57544
  const verifyScope = (actionName, recordPkValue) => {
57501
57545
  const actionAlias = getActionAlias(actionName);
57502
57546
  if (!Array.isArray(allowedActions == null ? void 0 : allowedActions[actionAlias])) {
@@ -57506,7 +57550,9 @@ function useACLRoleContext() {
57506
57550
  };
57507
57551
  return __spreadProps(__spreadValues({}, data), {
57508
57552
  parseAction: (actionPath, options = {}) => {
57553
+ var _a;
57509
57554
  const [resourceName, actionName] = actionPath.split(":");
57555
+ const targetResource = (resourceName == null ? void 0 : resourceName.includes(".")) && ((_a = getCollectionJoinField(resourceName)) == null ? void 0 : _a.target);
57510
57556
  if (!getIgnoreScope(options)) {
57511
57557
  const r = verifyScope(actionName, options.recordPkValue);
57512
57558
  if (r !== null) {
@@ -57516,6 +57562,9 @@ function useACLRoleContext() {
57516
57562
  if (data == null ? void 0 : data.allowAll) {
57517
57563
  return {};
57518
57564
  }
57565
+ if (inResources(targetResource)) {
57566
+ return getResourceActionParams(`${targetResource}:${actionName}`);
57567
+ }
57519
57568
  if (inResources(resourceName)) {
57520
57569
  return getResourceActionParams(actionPath);
57521
57570
  }
@@ -57529,7 +57578,7 @@ const ACLCollectionProvider = (props) => {
57529
57578
  if (allowAll) {
57530
57579
  return props.children;
57531
57580
  }
57532
- const actionPath = schema3 == null ? void 0 : schema3["x-acl-action"];
57581
+ const actionPath = (schema3 == null ? void 0 : schema3["x-acl-action"]) || props.actionPath;
57533
57582
  if (!actionPath) {
57534
57583
  return props.children;
57535
57584
  }
@@ -57537,6 +57586,8 @@ const ACLCollectionProvider = (props) => {
57537
57586
  if (!params) {
57538
57587
  return null;
57539
57588
  }
57589
+ const [_2, actionName] = actionPath.split(":");
57590
+ params.actionName = actionName;
57540
57591
  return /* @__PURE__ */ jsx(ACLActionParamsContext.Provider, { value: params, children: props.children });
57541
57592
  };
57542
57593
  const useACLActionParamsContext = () => {
@@ -57597,7 +57648,8 @@ const ACLCollectionFieldProvider = (props) => {
57597
57648
  const field = useField();
57598
57649
  const { allowAll } = useACLRoleContext();
57599
57650
  const { whitelist } = useACLFieldWhitelist();
57600
- 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;
57601
57653
  useEffect(() => {
57602
57654
  if (!allowed) {
57603
57655
  field.required = false;
@@ -59461,6 +59513,7 @@ const PluginManagerLink = () => {
59461
59513
  return /* @__PURE__ */ jsx(Tooltip$1, { title: t("Plugin manager"), children: /* @__PURE__ */ jsx(
59462
59514
  Button,
59463
59515
  {
59516
+ "data-testid": "pm-button",
59464
59517
  icon: /* @__PURE__ */ jsx(ApiOutlined, {}),
59465
59518
  title: t("Plugin manager"),
59466
59519
  onClick: () => {