@oondemand/oon-core-front 0.3.59 → 0.3.61

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/index.js CHANGED
@@ -4502,7 +4502,7 @@ function Sidebar({ app, menu, registry }) {
4502
4502
  // package.json
4503
4503
  var package_default = {
4504
4504
  name: "@oondemand/oon-core-front",
4505
- version: "0.3.59",
4505
+ version: "0.3.61",
4506
4506
  repository: {
4507
4507
  type: "git",
4508
4508
  url: "git+https://github.com/oondemand/oon-platform.git",
@@ -5872,10 +5872,153 @@ function statusPalette(status) {
5872
5872
  if (normalized2.includes("conclu\xEDdo") || normalized2.includes("ativo") || normalized2 === "ok") return "green";
5873
5873
  return "gray";
5874
5874
  }
5875
+ function integrationErrorMessage(error) {
5876
+ const message = error?.message;
5877
+ return typeof message === "string" && message.trim() ? message : "N\xE3o foi poss\xEDvel operar a configura\xE7\xE3o do provedor.";
5878
+ }
5875
5879
  function countActive(values) {
5876
5880
  if (!values) return 0;
5877
5881
  return Object.entries(values).filter(([status]) => !["Conclu\xEDdo", "Arquivado"].includes(status)).reduce((sum, [, count]) => sum + Number(count || 0), 0);
5878
5882
  }
5883
+ var SUMMARY_LABELS = {
5884
+ mode: "Modo",
5885
+ received: "Recebidos",
5886
+ created: "Criados",
5887
+ updated: "Atualizados",
5888
+ skipped: "Ignorados",
5889
+ inactivated: "Inativados",
5890
+ errors: "Erros"
5891
+ };
5892
+ function isRecord(value2) {
5893
+ return Boolean(value2) && typeof value2 === "object" && !Array.isArray(value2);
5894
+ }
5895
+ function primitiveText2(value2) {
5896
+ if (value2 === null || value2 === void 0 || value2 === "") return "\u2014";
5897
+ if (["string", "number", "boolean"].includes(typeof value2)) return String(value2);
5898
+ return JSON.stringify(value2) ?? "\u2014";
5899
+ }
5900
+ function diagnosticMessage(value2) {
5901
+ return value2.error?.message || value2.message || "Erro sem mensagem registrada.";
5902
+ }
5903
+ function diagnosticCode(value2) {
5904
+ return value2.error?.code || value2.code || value2.error?.statusCode || value2.statusCode;
5905
+ }
5906
+ function diagnosticIdentity(value2, position) {
5907
+ const parts = [`Registro ${value2.index !== void 0 ? value2.index + 1 : position + 1}`];
5908
+ if (value2.externalKey !== void 0 && value2.externalKey !== null && value2.externalKey !== "") {
5909
+ parts.push(`chave ${primitiveText2(value2.externalKey)}`);
5910
+ }
5911
+ const code = diagnosticCode(value2);
5912
+ if (code !== void 0 && code !== null && code !== "") parts.push(`c\xF3digo ${String(code)}`);
5913
+ return parts.join(" \xB7 ");
5914
+ }
5915
+ function executionDiagnostics(execution) {
5916
+ const values = [...execution.errors ?? []];
5917
+ if (execution.error?.message && !values.some((item) => diagnosticMessage(item) === execution.error?.message)) {
5918
+ values.push({ error: execution.error });
5919
+ }
5920
+ return values;
5921
+ }
5922
+ function JsonDiagnosticDetails({
5923
+ label,
5924
+ value: value2,
5925
+ count,
5926
+ limited
5927
+ }) {
5928
+ const hasValue = Array.isArray(value2) ? value2.length > 0 : isRecord(value2) ? Object.keys(value2).length > 0 : value2 !== void 0 && value2 !== null && value2 !== "";
5929
+ if (!hasValue) return null;
5930
+ return /* @__PURE__ */ jsxs23("details", { style: { borderTop: "1px solid #e2e8f0", paddingTop: "10px" }, children: [
5931
+ /* @__PURE__ */ jsxs23("summary", { style: { cursor: "pointer", fontWeight: 600, fontSize: "13px" }, children: [
5932
+ label,
5933
+ count !== void 0 ? ` (${count})` : "",
5934
+ limited ? " \xB7 visualiza\xE7\xE3o limitada" : ""
5935
+ ] }),
5936
+ /* @__PURE__ */ jsx38(
5937
+ Box22,
5938
+ {
5939
+ as: "pre",
5940
+ mt: 2,
5941
+ mb: 0,
5942
+ p: 3,
5943
+ overflowX: "auto",
5944
+ borderRadius: "md",
5945
+ bg: "gray.50",
5946
+ fontSize: "xs",
5947
+ whiteSpace: "pre-wrap",
5948
+ wordBreak: "break-word",
5949
+ children: JSON.stringify(value2, null, 2)
5950
+ }
5951
+ )
5952
+ ] });
5953
+ }
5954
+ function ExecutionDetails({ execution }) {
5955
+ const diagnostics = executionDiagnostics(execution);
5956
+ const summary = isRecord(execution.summary) ? execution.summary : {};
5957
+ const summaryEntries = Object.entries(summary).filter(([, value2]) => value2 === null || ["string", "number", "boolean"].includes(typeof value2));
5958
+ return /* @__PURE__ */ jsx38(Box22, { mt: 3, pt: 3, borderTopWidth: "1px", borderColor: "gray.100", children: /* @__PURE__ */ jsxs23(Stack9, { gap: 3, children: [
5959
+ summaryEntries.length ? /* @__PURE__ */ jsxs23(Box22, { children: [
5960
+ /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", fontWeight: "semibold", mb: 2, children: "Resumo da execu\xE7\xE3o" }),
5961
+ /* @__PURE__ */ jsx38(Flex14, { gap: 2, wrap: "wrap", children: summaryEntries.map(([key, value2]) => /* @__PURE__ */ jsxs23(
5962
+ Badge5,
5963
+ {
5964
+ variant: "outline",
5965
+ colorPalette: key === "errors" && Number(value2 ?? 0) > 0 ? "red" : "gray",
5966
+ children: [
5967
+ SUMMARY_LABELS[key] || key,
5968
+ ": ",
5969
+ primitiveText2(value2)
5970
+ ]
5971
+ },
5972
+ key
5973
+ )) })
5974
+ ] }) : null,
5975
+ diagnostics.length ? /* @__PURE__ */ jsxs23(Box22, { children: [
5976
+ /* @__PURE__ */ jsxs23(Flex14, { align: "center", justify: "space-between", gap: 2, mb: 2, wrap: "wrap", children: [
5977
+ /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", fontWeight: "semibold", children: "Erros por registro" }),
5978
+ /* @__PURE__ */ jsxs23(Text23, { fontSize: "xs", color: "gray.500", children: [
5979
+ execution.errorCount ?? diagnostics.length,
5980
+ " erro(s)",
5981
+ execution.errorsLimited ? " \xB7 lista limitada" : ""
5982
+ ] })
5983
+ ] }),
5984
+ /* @__PURE__ */ jsx38(Stack9, { gap: 2, children: diagnostics.map((diagnostic, index) => /* @__PURE__ */ jsxs23(
5985
+ Box22,
5986
+ {
5987
+ p: 3,
5988
+ borderWidth: "1px",
5989
+ borderColor: "red.100",
5990
+ borderRadius: "md",
5991
+ bg: "red.50",
5992
+ children: [
5993
+ /* @__PURE__ */ jsx38(Text23, { fontSize: "xs", color: "gray.600", fontWeight: "semibold", children: diagnosticIdentity(diagnostic, index) }),
5994
+ /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "red.700", children: diagnosticMessage(diagnostic) }),
5995
+ diagnostic.error?.details ? /* @__PURE__ */ jsx38(Text23, { fontSize: "xs", color: "gray.600", mt: 1, children: primitiveText2(diagnostic.error.details) }) : null
5996
+ ]
5997
+ },
5998
+ `${diagnostic.index ?? index}:${diagnosticMessage(diagnostic)}`
5999
+ )) })
6000
+ ] }) : execution.status.toLowerCase().includes("erro") ? /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "red.600", children: execution.message || execution.error?.message || "A execu\xE7\xE3o terminou com erro, mas n\xE3o registrou detalhes adicionais." }) : null,
6001
+ /* @__PURE__ */ jsx38(
6002
+ JsonDiagnosticDetails,
6003
+ {
6004
+ label: "Itens processados",
6005
+ value: execution.items,
6006
+ count: execution.itemCount,
6007
+ limited: execution.itemsLimited
6008
+ }
6009
+ ),
6010
+ /* @__PURE__ */ jsx38(
6011
+ JsonDiagnosticDetails,
6012
+ {
6013
+ label: "Chamadas sanitizadas",
6014
+ value: execution.requests,
6015
+ count: execution.requestCount,
6016
+ limited: execution.requestsLimited
6017
+ }
6018
+ ),
6019
+ /* @__PURE__ */ jsx38(JsonDiagnosticDetails, { label: "Metadados", value: execution.metadata })
6020
+ ] }) });
6021
+ }
5879
6022
  function ProviderConfigurationPanel({ provider }) {
5880
6023
  const { http } = useOonApi();
5881
6024
  const [draft, setDraft] = useState14({
@@ -6100,11 +6243,12 @@ function ProviderConfigurationPanel({ provider }) {
6100
6243
  ] })
6101
6244
  ] }),
6102
6245
  selected?.lastConnectionError ? /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "red.600", children: selected.lastConnectionError }) : null,
6103
- error ? /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "red.600", children: "N\xE3o foi poss\xEDvel operar a configura\xE7\xE3o do provedor." }) : null
6246
+ error ? /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "red.600", children: integrationErrorMessage(error) }) : null
6104
6247
  ] }) });
6105
6248
  }
6106
6249
  function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
6107
6250
  const { http } = useOonApi();
6251
+ const [expandedExecutionId, setExpandedExecutionId] = useState14(null);
6108
6252
  const providers = useQuery8({
6109
6253
  queryKey: ["core-integrations", "health"],
6110
6254
  queryFn: async () => (await http.get("/integrations/health")).data?.results ?? []
@@ -6239,23 +6383,46 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
6239
6383
  ] }),
6240
6384
  /* @__PURE__ */ jsxs23(Box22, { children: [
6241
6385
  /* @__PURE__ */ jsx38(Heading12, { size: "md", mb: 3, children: "Hist\xF3rico" }),
6242
- /* @__PURE__ */ jsx38(Stack9, { gap: 2, children: (history.data ?? []).length === 0 ? /* @__PURE__ */ jsx38(Text23, { color: "gray.400", children: "Nenhuma execu\xE7\xE3o registrada." }) : history.data?.map((execution) => /* @__PURE__ */ jsx38(Box22, { borderWidth: "1px", borderRadius: "md", p: 3, bg: "white", children: /* @__PURE__ */ jsxs23(Flex14, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6243
- /* @__PURE__ */ jsxs23(Box22, { children: [
6244
- /* @__PURE__ */ jsx38(Text23, { fontWeight: "medium", children: execution.title }),
6245
- /* @__PURE__ */ jsxs23(Text23, { fontSize: "sm", color: "gray.500", children: [
6246
- execution.provider,
6247
- " \xB7 ",
6248
- execution.resource || "sem recurso",
6249
- " \xB7 ",
6250
- dateTime(execution.startedAt),
6251
- " \xB7 ",
6252
- execution.durationMs ?? 0,
6253
- " ms"
6386
+ /* @__PURE__ */ jsx38(Stack9, { gap: 2, children: (history.data ?? []).length === 0 ? /* @__PURE__ */ jsx38(Text23, { color: "gray.400", children: "Nenhuma execu\xE7\xE3o registrada." }) : history.data?.map((execution) => {
6387
+ const expanded = expandedExecutionId === execution._id;
6388
+ const diagnosticCount = execution.errorCount ?? execution.errors?.length ?? (execution.error?.message ? 1 : 0);
6389
+ return /* @__PURE__ */ jsxs23(Box22, { borderWidth: "1px", borderRadius: "md", p: 3, bg: "white", children: [
6390
+ /* @__PURE__ */ jsxs23(Flex14, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6391
+ /* @__PURE__ */ jsxs23(Box22, { children: [
6392
+ /* @__PURE__ */ jsx38(Text23, { fontWeight: "medium", children: execution.title }),
6393
+ /* @__PURE__ */ jsxs23(Text23, { fontSize: "sm", color: "gray.500", children: [
6394
+ execution.provider,
6395
+ " \xB7 ",
6396
+ execution.resource || "sem recurso",
6397
+ " \xB7 ",
6398
+ dateTime(execution.startedAt),
6399
+ " \xB7 ",
6400
+ execution.durationMs ?? 0,
6401
+ " ms"
6402
+ ] }),
6403
+ execution.error?.message ? /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "red.600", children: execution.error.message }) : null
6404
+ ] }),
6405
+ /* @__PURE__ */ jsxs23(Flex14, { align: "center", gap: 2, wrap: "wrap", children: [
6406
+ diagnosticCount > 0 ? /* @__PURE__ */ jsxs23(Badge5, { colorPalette: "red", children: [
6407
+ diagnosticCount,
6408
+ " erro(s)"
6409
+ ] }) : null,
6410
+ /* @__PURE__ */ jsx38(Badge5, { colorPalette: statusPalette(execution.status), children: execution.status }),
6411
+ /* @__PURE__ */ jsx38(
6412
+ Button15,
6413
+ {
6414
+ size: "xs",
6415
+ variant: "outline",
6416
+ "aria-expanded": expanded,
6417
+ onClick: () => setExpandedExecutionId((current) => current === execution._id ? null : execution._id),
6418
+ children: expanded ? "Ocultar detalhes" : "Ver detalhes"
6419
+ }
6420
+ )
6421
+ ] })
6254
6422
  ] }),
6255
- execution.error?.message ? /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "red.600", children: execution.error.message }) : null
6256
- ] }),
6257
- /* @__PURE__ */ jsx38(Badge5, { colorPalette: statusPalette(execution.status), children: execution.status })
6258
- ] }) }, execution._id)) })
6423
+ expanded ? /* @__PURE__ */ jsx38(ExecutionDetails, { execution }) : null
6424
+ ] }, execution._id);
6425
+ }) })
6259
6426
  ] })
6260
6427
  ] });
6261
6428
  }