@akanjs/ui 0.9.55 → 0.9.57

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.
Files changed (60) hide show
  1. package/Data/CardList.d.ts +3 -3
  2. package/Data/TableList.d.ts +4 -4
  3. package/Field.d.ts +11 -12
  4. package/Model/Remove.d.ts +3 -1
  5. package/Select.d.ts +2 -2
  6. package/Signal/Arg.d.ts +14 -11
  7. package/Signal/Doc.d.ts +8 -1
  8. package/Signal/GraphQL.d.ts +13 -16
  9. package/Signal/Message.d.ts +12 -15
  10. package/Signal/PubSub.d.ts +13 -15
  11. package/Signal/Response.d.ts +3 -5
  12. package/Signal/RestApi.d.ts +17 -20
  13. package/Signal/WebSocket.d.ts +1 -1
  14. package/System/CSR.d.ts +2 -2
  15. package/System/Common.d.ts +2 -25
  16. package/System/SSR.d.ts +2 -2
  17. package/Table.d.ts +2 -2
  18. package/cjs/Data/Insight.js +1 -1
  19. package/cjs/Data/Item.js +1 -1
  20. package/cjs/Data/ListContainer.js +5 -5
  21. package/cjs/Data/TableList.js +2 -5
  22. package/cjs/Field.js +11 -9
  23. package/cjs/Model/EditModal.js +1 -1
  24. package/cjs/Model/Remove.js +6 -11
  25. package/cjs/Model/ViewEditModal.js +14 -1
  26. package/cjs/Select.js +1 -1
  27. package/cjs/Signal/Arg.js +22 -22
  28. package/cjs/Signal/Doc.js +18 -27
  29. package/cjs/Signal/GraphQL.js +37 -52
  30. package/cjs/Signal/Message.js +25 -53
  31. package/cjs/Signal/Object.js +4 -12
  32. package/cjs/Signal/PubSub.js +20 -54
  33. package/cjs/Signal/Response.js +2 -2
  34. package/cjs/Signal/RestApi.js +63 -79
  35. package/cjs/Signal/WebSocket.js +14 -15
  36. package/cjs/System/CSR.js +5 -10
  37. package/cjs/System/Common.js +6 -6
  38. package/cjs/System/SSR.js +5 -10
  39. package/esm/Data/Insight.js +1 -1
  40. package/esm/Data/Item.js +1 -1
  41. package/esm/Data/ListContainer.js +5 -5
  42. package/esm/Data/TableList.js +2 -5
  43. package/esm/Field.js +12 -10
  44. package/esm/Model/EditModal.js +1 -1
  45. package/esm/Model/Remove.js +7 -12
  46. package/esm/Model/ViewEditModal.js +15 -2
  47. package/esm/Select.js +2 -2
  48. package/esm/Signal/Arg.js +24 -24
  49. package/esm/Signal/Doc.js +17 -26
  50. package/esm/Signal/GraphQL.js +39 -62
  51. package/esm/Signal/Message.js +27 -55
  52. package/esm/Signal/Object.js +4 -12
  53. package/esm/Signal/PubSub.js +22 -56
  54. package/esm/Signal/Response.js +2 -2
  55. package/esm/Signal/RestApi.js +66 -90
  56. package/esm/Signal/WebSocket.js +14 -15
  57. package/esm/System/CSR.js +5 -10
  58. package/esm/System/Common.js +6 -6
  59. package/esm/System/SSR.js +5 -10
  60. package/package.json +1 -1
@@ -83,10 +83,7 @@ function TableList({
83
83
  const cols = (0, import_react.useMemo)(() => {
84
84
  const firstCol = {
85
85
  ...(0, import_Item.convToAntdColumn)(columns[0]),
86
- title: typeof columns[0] !== "string" && columns[0].title ? columns[0].title : l.field(
87
- sliceName,
88
- typeof columns[0] === "string" ? columns[0] : columns[0].key
89
- )
86
+ title: typeof columns[0] !== "string" && columns[0].title ? columns[0].title : l._(`${sliceName}.${typeof columns[0] === "string" ? columns[0] : columns[0].key}`)
90
87
  };
91
88
  return [
92
89
  {
@@ -106,7 +103,7 @@ function TableList({
106
103
  },
107
104
  ...columns.slice(1).map((col) => ({
108
105
  ...(0, import_Item.convToAntdColumn)(col),
109
- title: typeof col !== "string" && col.title ? col.title : l.field(sliceName, typeof col === "string" ? col : col.key)
106
+ title: typeof col !== "string" && col.title ? col.title : l._(`${sliceName}.${typeof col === "string" ? col : col.key}`)
110
107
  })),
111
108
  ...actions ? [
112
109
  {
package/cjs/Field.js CHANGED
@@ -304,7 +304,7 @@ const ToggleSelect = ({
304
304
  btnClassName
305
305
  }) => {
306
306
  const { l } = (0, import_client.usePage)();
307
- const isEnum = items instanceof import_base.Enum;
307
+ const isEnumValue = (0, import_base.isEnum)(items);
308
308
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_client.clsx)("flex flex-col", className), children: [
309
309
  label ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { className: labelClassName, nullable, label, desc }) : null,
310
310
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -313,10 +313,10 @@ const ToggleSelect = ({
313
313
  className: "mt-2",
314
314
  nullable: !!nullable,
315
315
  btnClassName,
316
- items: model && field ? (isEnum ? items.values : items).map((item) => ({
317
- label: l.enum(model, field, item),
316
+ items: model && field ? (isEnumValue ? items.values : items).map((item) => ({
317
+ label: l._(`${items.refName}.${item}`),
318
318
  value: item
319
- })) : isEnum ? items.values : items,
319
+ })) : isEnumValue ? items.values : items,
320
320
  value,
321
321
  onChange: (value2, idx) => {
322
322
  onChange(value2);
@@ -346,17 +346,17 @@ const MultiToggleSelect = ({
346
346
  disabled
347
347
  }) => {
348
348
  const { l } = (0, import_client.usePage)();
349
- const isEnum = items instanceof import_base.Enum;
349
+ const isEnumValue = (0, import_base.isEnum)(items);
350
350
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_client.clsx)("flex flex-col", className), children: [
351
351
  label ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { className: labelClassName, nullable: !!minlength, label, desc }) : null,
352
352
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
353
353
  import_ToggleSelect.ToggleSelect.Multi,
354
354
  {
355
355
  nullable: !minlength,
356
- items: model && field ? (isEnum ? items.values : items).map((item) => ({
357
- label: l.enum(model, field, item),
356
+ items: model && field ? (isEnumValue ? items.values : items).map((item) => ({
357
+ label: l._(`${items.refName}.${item}`),
358
358
  value: item
359
- })) : isEnum ? items.values : items,
359
+ })) : isEnumValue ? items.values : items,
360
360
  value,
361
361
  onChange: (values) => {
362
362
  onChange(values);
@@ -1174,7 +1174,9 @@ const Children = ({
1174
1174
  return renderSelected(model);
1175
1175
  },
1176
1176
  onChange: (modelIds) => {
1177
- onChange(modelIds.map((id) => modelList.get(id)).filter((model) => model !== void 0));
1177
+ onChange(
1178
+ modelIds.map((id) => modelList.get(id)).filter((model) => model !== void 0)
1179
+ );
1178
1180
  },
1179
1181
  onSearch
1180
1182
  }
@@ -199,7 +199,7 @@ function EditModal({
199
199
  children: [
200
200
  modelFormId ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ai.AiOutlineSave, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ai.AiOutlinePlus, {}),
201
201
  l(modelFormId ? "base.updateModel" : "base.createModel", {
202
- model: l.field(names.model, "modelName")
202
+ model: l._(`${names.model}.modelName`)
203
203
  })
204
204
  ]
205
205
  }
@@ -26,10 +26,9 @@ var import_client = require("@akanjs/client");
26
26
  var import_common = require("@akanjs/common");
27
27
  var import_store = require("@akanjs/store");
28
28
  var import_react = require("react");
29
- var import_ai = require("react-icons/ai");
30
29
  var import_Button = require("../Button");
31
30
  var import_Modal = require("../Modal");
32
- function Remove({ className, name, modelId, sliceName, modal, redirect }) {
31
+ function Remove({ className, name, modelId, sliceName, modal, redirect, children }) {
33
32
  const { l } = (0, import_client.usePage)();
34
33
  const [modalOpen, setModalOpen] = (0, import_react.useState)(false);
35
34
  const storeDo = import_store.st.do;
@@ -41,20 +40,16 @@ function Remove({ className, name, modelId, sliceName, modal, redirect }) {
41
40
  }),
42
41
  []
43
42
  );
44
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "inline size-full", children: [
45
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
46
- "button",
43
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
44
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
45
+ "div",
47
46
  {
48
- className: (0, import_client.clsx)("btn text-error btn-sm size-full flex-nowrap whitespace-nowrap", className),
47
+ className: (0, import_client.clsx)("cursor-pointer", className),
49
48
  onClick: (e) => {
50
49
  e.stopPropagation();
51
50
  setModalOpen(true);
52
51
  },
53
- children: [
54
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ai.AiOutlineDelete, {}),
55
- " ",
56
- l("base.remove")
57
- ]
52
+ children
58
53
  }
59
54
  ),
60
55
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -94,7 +94,20 @@ function ViewEditModal({
94
94
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Title, {}),
95
95
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dropdown dropdown-end", children: [
96
96
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { tabIndex: 0, className: "btn btn-square m-1", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_bi.BiDotsVertical, {}) }),
97
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { tabIndex: 0, className: "dropdown-content menu bg-base-100 rounded-box z-[1] p-2 shadow-sm", children: model ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Remove.default, { sliceName, modelId: model.id, modal: null }) }) : null })
97
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { tabIndex: 0, className: "dropdown-content menu bg-base-100 rounded-box z-[1] p-2 shadow-sm", children: model ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
98
+ import_Remove.default,
99
+ {
100
+ className: "text-error flex items-center gap-2",
101
+ sliceName,
102
+ modelId: model.id,
103
+ modal: null,
104
+ children: [
105
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_bi.BiTrash, {}),
106
+ " ",
107
+ l("base.remove")
108
+ ]
109
+ }
110
+ ) }) }) : null })
98
111
  ] })
99
112
  ] }),
100
113
  action: modelModal === "view" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
package/cjs/Select.js CHANGED
@@ -53,7 +53,7 @@ const Select = ({
53
53
  const { l } = (0, import_client.usePage)();
54
54
  const [isOpen, setIsOpen] = (0, import_react.useState)(false);
55
55
  const labeledOptions = (0, import_react.useMemo)(
56
- () => options instanceof import_base.Enum ? options.values.map((v) => ({
56
+ () => (0, import_base.isEnum)(options) ? options.values.map((v) => ({
57
57
  label: typeof v === "string" ? v : typeof v === "object" ? JSON.stringify(v) : String(v),
58
58
  value: v
59
59
  })) : options[0]?.label && options[0]?.value ? options : options.map((v) => ({ label: v, value: v })),
package/cjs/Signal/Arg.js CHANGED
@@ -43,7 +43,7 @@ var import_Object = __toESM(require("./Object"));
43
43
  function Arg({ argType, value, onChange }) {
44
44
  return argType === "ID" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Arg.ID, { value, onChange }) : argType === "Int" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Arg.Int, { value, onChange }) : argType === "Float" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Arg.Float, { value, onChange }) : argType === "String" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Arg.String, { value, onChange }) : argType === "Boolean" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Arg.Boolean, { value, onChange }) : argType === "Date" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Arg.Date, { value, onChange }) : argType === "JSON" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Arg.Json, { value, onChange }) : argType === "Upload" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Arg.Upload, { value, onChange }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
45
45
  }
46
- const ArgTable = ({ sigMeta, gqlMeta, argMetas }) => {
46
+ const ArgTable = ({ refName, gqlKey, argMetas }) => {
47
47
  const { l } = (0, import_client.usePage)();
48
48
  const onCopy = (text) => {
49
49
  void navigator.clipboard.writeText(text);
@@ -58,14 +58,14 @@ const ArgTable = ({ sigMeta, gqlMeta, argMetas }) => {
58
58
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { className: "text-center", children: "Description" })
59
59
  ] }) }),
60
60
  argMetas.map((argMeta, idx) => {
61
- const [argRef, argArrDepth] = (0, import_base.getNonArrayModel)(argMeta.returns());
61
+ const argRef = import_constant.constantInfo.getModelRef(argMeta.refName, argMeta.modelType);
62
62
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { className: "font-normal", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
63
63
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: argMeta.name }),
64
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "text-center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Object.default.Type, { objRef: argRef, arrDepth: argArrDepth }) }),
64
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "text-center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Object.default.Type, { objRef: argRef, arrDepth: argMeta.arrDepth }) }),
65
65
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { width: argMeta.argsOption.enum ? "20%" : "10%", className: "text-center", children: argMeta.argsOption.enum ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex flex-col gap-2", children: argMeta.argsOption.enum.map((opt, idx2) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
66
66
  "button",
67
67
  {
68
- "data-tip": l.enum(sigMeta.refName, argMeta.name, opt),
68
+ "data-tip": l._(`${argMeta.argsOption.enum?.refName}.${opt}`),
69
69
  onClick: () => {
70
70
  onCopy(opt);
71
71
  },
@@ -74,19 +74,19 @@ const ArgTable = ({ sigMeta, gqlMeta, argMetas }) => {
74
74
  },
75
75
  idx2
76
76
  ) }, idx2)) }) : "-" }),
77
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "text-center", children: l.arg(sigMeta.refName, gqlMeta.key, argMeta.name) }),
78
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "text-center", children: l.argdesc(sigMeta.refName, gqlMeta.key, argMeta.name) })
77
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "text-center", children: l._(`${refName}.signal.${gqlKey}.arg.${argMeta.name}`) }),
78
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "text-center", children: l._(`${refName}.signal.${gqlKey}.arg.${argMeta.name}.desc`) })
79
79
  ] }) }, idx);
80
80
  })
81
81
  ] });
82
82
  };
83
83
  Arg.Table = ArgTable;
84
- const ArgParam = ({ argMeta, value, onChange }) => {
85
- const [argRef, argArrDepth] = (0, import_base.getNonArrayModel)(argMeta.returns());
84
+ const ArgParam = ({ gqlKey, argMeta, value, onChange }) => {
85
+ const argRef = import_constant.constantInfo.getModelRef(argMeta.refName, argMeta.modelType);
86
86
  if (!(0, import_base.isGqlScalar)(argRef))
87
- throw new Error(`Param arg - ${argMeta.key}/${argMeta.name} must be scalar`);
88
- else if (argArrDepth > 0)
89
- throw new Error(`Param arg - ${argMeta.key}/${argMeta.name} must not be array`);
87
+ throw new Error(`Param arg - ${gqlKey}/${argMeta.name} must be scalar`);
88
+ else if (argMeta.arrDepth > 0)
89
+ throw new Error(`Param arg - ${gqlKey}/${argMeta.name} must not be array`);
90
90
  const argType = (0, import_constant.getGqlTypeStr)(argRef);
91
91
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex w-full items-center gap-2", children: [
92
92
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "w-36 pl-2", children: [
@@ -97,19 +97,19 @@ const ArgParam = ({ argMeta, value, onChange }) => {
97
97
  ] });
98
98
  };
99
99
  Arg.Param = ArgParam;
100
- const ArgQuery = ({ argMeta, value, onChange }) => {
101
- const [argRef, argArrDepth] = (0, import_base.getNonArrayModel)(argMeta.returns());
100
+ const ArgQuery = ({ gqlKey, argMeta, value, onChange }) => {
101
+ const argRef = import_constant.constantInfo.getModelRef(argMeta.refName, argMeta.modelType);
102
102
  if (!(0, import_base.isGqlScalar)(argRef))
103
- throw new Error(`Query arg - ${argMeta.key}/${argMeta.name} must be scalar`);
104
- else if (argArrDepth > 1)
105
- throw new Error(`Query arg - ${argMeta.key}/${argMeta.name} must not be more than 2D array`);
103
+ throw new Error(`Query arg - ${gqlKey}/${argMeta.name} must be scalar`);
104
+ else if (argMeta.arrDepth > 1)
105
+ throw new Error(`Query arg - ${gqlKey}/${argMeta.name} must not be more than 2D array`);
106
106
  const argType = (0, import_constant.getGqlTypeStr)(argRef);
107
107
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
108
108
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "w-36 pl-2", children: [
109
109
  "- ",
110
110
  argMeta.name
111
111
  ] }),
112
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-full", children: argArrDepth && Array.isArray(value) ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
112
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-full", children: argMeta.arrDepth > 0 && Array.isArray(value) ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
113
113
  value.map((val, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
114
114
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
115
115
  Arg,
@@ -146,12 +146,12 @@ const ArgQuery = ({ argMeta, value, onChange }) => {
146
146
  ] });
147
147
  };
148
148
  Arg.Query = ArgQuery;
149
- const ArgFormData = ({ argMeta, value, onChange }) => {
150
- const [argRef, argArrDepth] = (0, import_base.getNonArrayModel)(argMeta.returns());
149
+ const ArgFormData = ({ gqlKey, argMeta, value, onChange }) => {
150
+ const argRef = import_constant.constantInfo.getModelRef(argMeta.refName, argMeta.modelType);
151
151
  if ((0, import_constant.getGqlTypeStr)(argRef) !== "Upload")
152
- throw new Error(`FormData arg - ${argMeta.key}/${argMeta.name} must be Upload`);
153
- else if (argArrDepth < 1)
154
- throw new Error(`FormData arg - ${argMeta.key}/${argMeta.name} must be array`);
152
+ throw new Error(`FormData arg - ${gqlKey}/${argMeta.name} must be Upload`);
153
+ else if (argMeta.arrDepth < 1)
154
+ throw new Error(`FormData arg - ${gqlKey}/${argMeta.name} must be array`);
155
155
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex w-full items-center gap-2", children: [
156
156
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "w-36 pl-2", children: [
157
157
  "- ",
package/cjs/Signal/Doc.js CHANGED
@@ -49,12 +49,20 @@ var import_WebSocket = __toESM(require("./WebSocket"));
49
49
  function Doc() {
50
50
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {});
51
51
  }
52
- const DocSetting = () => {
52
+ const DocSetting = ({
53
+ guardNames = ["Public"],
54
+ roleTypes = ["Public", "User", "Admin", "SuperAdmin"],
55
+ roleKeys = { me: "Admin", self: "User" }
56
+ }) => {
53
57
  const trySignalType = import_store.st.use.trySignalType();
54
58
  const tryRoles = import_store.st.use.tryRoles();
55
59
  const tryAccount = import_store.st.use.tryAccount();
56
- const tryRoleForAll = import_signal.roleTypes.every((roleType) => tryRoles.includes(roleType));
60
+ (0, import_react.useEffect)(() => {
61
+ import_store.st.set({ tryRoles: [...roleTypes] });
62
+ }, []);
63
+ const tryRoleForAll = roleTypes.every((roleType) => tryRoles.includes(roleType));
57
64
  const baseUrl = trySignalType === "graphql" ? import_signal.client.uri : import_signal.client.uri.replace("/graphql", "");
65
+ const currentRoles = Object.entries(roleKeys).filter(([key, roleType]) => !!tryAccount[key]).map(([key, roleType]) => roleType);
58
66
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex w-full flex-wrap items-center justify-between gap-4", children: [
59
67
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-1 items-center gap-1", children: [
60
68
  "BaseURL:",
@@ -101,12 +109,12 @@ const DocSetting = () => {
101
109
  className: `btn btn-secondary btn-sm ${tryRoleForAll ? "" : "btn-outline"}`,
102
110
  onClick: () => {
103
111
  if (!tryRoleForAll)
104
- import_store.st.do.setTryRoles([...import_signal.roleTypes]);
112
+ import_store.st.do.setTryRoles([...roleTypes]);
105
113
  },
106
114
  children: "All"
107
115
  }
108
116
  ),
109
- import_signal.roleTypes.map((roleType) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
117
+ roleTypes.map((roleType) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
110
118
  "button",
111
119
  {
112
120
  className: `btn btn-secondary btn-sm ${!tryRoleForAll && tryRoles.includes(roleType) ? "" : "btn-outline"}`,
@@ -125,14 +133,10 @@ const DocSetting = () => {
125
133
  ] }),
126
134
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-1", children: [
127
135
  "Auth:",
128
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DocAuthModal, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { className: `btn btn-sm ${!tryAccount.me && !tryAccount.self ? "btn-neutral" : "btn-warning"} `, children: [
136
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DocAuthModal, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { className: `btn btn-sm ${currentRoles.length > 0 ? "btn-warning" : "btn-neutral"} `, children: [
129
137
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_bi.BiLock, {}),
130
138
  " ",
131
- [
132
- tryAccount.me ? "Admin" : null,
133
- tryAccount.self ? "User" : null,
134
- !tryAccount.me && !tryAccount.self ? "Public" : null
135
- ].filter((roleType) => !!roleType).join(",")
139
+ currentRoles.length > 0 ? currentRoles.join(", ") : "Public"
136
140
  ] }) })
137
141
  ] })
138
142
  ] });
@@ -186,18 +190,7 @@ const DocAuthModal = ({ children }) => {
186
190
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Input.Input, { inputClassName: "w-full", value: jwt ?? "", onChange: setJwt, validate: () => true })
187
191
  ] }),
188
192
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "w-full", children: [
189
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
190
- "Account Decoded",
191
- !decodedAccount?.me && !decodedAccount?.self ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "badge badge-primary", children: "Public" }) : null,
192
- decodedAccount?.me?.roles.map((role) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "badge badge-warning", children: [
193
- "Admin-",
194
- role
195
- ] }, role)),
196
- decodedAccount?.self?.roles.map((role) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "badge badge-neutral", children: [
197
- "User-",
198
- role
199
- ] }, role))
200
- ] }),
193
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex items-center gap-2", children: "Account Decoded" }),
201
194
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative", children: [
202
195
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
203
196
  import_Input.Input.TextArea,
@@ -222,10 +215,8 @@ const DocAuthModal = ({ children }) => {
222
215
  };
223
216
  Doc.AuthModal = DocAuthModal;
224
217
  const DocSignals = () => {
225
- const sigRefs = (0, import_signal.getAllSignalRefs)();
226
- const refNames = [...new Set(sigRefs.map((sigRef) => (0, import_signal.getSigMeta)(sigRef).refName))].sort(
227
- (a, b) => (0, import_common.lowerlize)(a) > (0, import_common.lowerlize)(b) ? 1 : -1
228
- );
218
+ const signals = global.signals;
219
+ const refNames = signals.map((signal) => signal.refName).sort((a, b) => (0, import_common.lowerlize)(a) > (0, import_common.lowerlize)(b) ? 1 : -1);
229
220
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: refNames.map((refName, idx) => {
230
221
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "px-5 pb-5 text-3xl font-bold", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DocSignal, { refName }) }, idx);
231
222
  }) });
@@ -246,7 +237,7 @@ const Zone = ({ refName, openAll }) => {
246
237
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-3xl font-bold", children: refName }),
247
238
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mb-5", children: [
248
239
  " - ",
249
- l.field(refName, "modelDesc")
240
+ l._(`${refName}.modelDesc`)
250
241
  ] }),
251
242
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-2xl font-bold", children: "APIs" }),
252
243
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DocSetting, {}),
@@ -48,43 +48,39 @@ function GraphQL() {
48
48
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {});
49
49
  }
50
50
  const GraphQLEndpoints = ({ refName, openAll }) => {
51
- const sigRefs = (0, import_signal.getSignalRefsOnStorage)(refName);
51
+ const signals = global.signals;
52
+ const signal = signals.find((signal2) => signal2.refName === refName);
52
53
  const tryRoles = import_store.st.use.tryRoles();
53
- const gqlInfos = sigRefs.reduce(
54
- (acc, sigRef) => [...acc, ...(0, import_signal.getGqlMetas)(sigRef).map((gqlMeta) => ({ key: gqlMeta.key, gqlMeta, sigRef }))],
55
- []
56
- ).sort((a, b) => a.key > b.key ? 1 : -1).filter(({ gqlMeta }) => gqlMeta.signalOption.onlyFor !== "restapi").filter(({ gqlMeta }) => {
57
- if (gqlMeta.type === "Pubsub" || gqlMeta.type === "Message")
54
+ if (!signal)
55
+ return null;
56
+ const gqlInfos = global.Object.entries(signal.endpoint).sort(([keyA], [keyB]) => keyA > keyB ? 1 : -1).filter(([key, gqlMeta]) => gqlMeta.signalOption?.onlyFor !== "restapi").filter(([key, gqlMeta]) => {
57
+ if (gqlMeta.type !== "query" && gqlMeta.type !== "mutation")
58
58
  return false;
59
- if (gqlMeta.guards.includes("Public") && tryRoles.includes("Public"))
59
+ if (gqlMeta.signalOption?.guards?.includes("Public") && tryRoles.includes("Public"))
60
60
  return true;
61
- if ((gqlMeta.guards.includes("User") || gqlMeta.guards.includes("Every")) && tryRoles.includes("User"))
61
+ if ((gqlMeta.signalOption?.guards?.includes("User") || gqlMeta.signalOption?.guards?.includes("Every")) && tryRoles.includes("User"))
62
62
  return true;
63
- if ((gqlMeta.guards.includes("Admin") || gqlMeta.guards.includes("Every")) && tryRoles.includes("Admin"))
63
+ if ((gqlMeta.signalOption?.guards?.includes("Admin") || gqlMeta.signalOption?.guards?.includes("Every")) && tryRoles.includes("Admin"))
64
64
  return true;
65
- if (gqlMeta.guards.includes("SuperAdmin") && tryRoles.includes("SuperAdmin"))
65
+ if ((gqlMeta.signalOption?.guards?.includes("SuperAdmin") || gqlMeta.signalOption?.guards?.includes("Every")) && tryRoles.includes("SuperAdmin"))
66
66
  return true;
67
67
  return false;
68
68
  });
69
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: gqlInfos.map(({ gqlMeta, sigRef }, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphQLEndpoint, { sigRef, gqlMeta, open: openAll }, idx)) });
69
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: gqlInfos.map(([gqlKey, gqlMeta], idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphQLEndpoint, { refName, gqlKey, gqlMeta, open: openAll }, idx)) });
70
70
  };
71
71
  GraphQL.Endpoints = GraphQLEndpoints;
72
- const GraphQLEndpoint = ({ sigRef, gqlMeta, open }) => {
72
+ const GraphQLEndpoint = ({ refName, gqlKey, gqlMeta, open }) => {
73
73
  const { l } = (0, import_client.usePage)();
74
- const sigMeta = (0, import_signal.getSigMeta)(sigRef);
75
74
  const [viewStatus, setViewStatus] = (0, import_react.useState)("doc");
76
- const [argMetas] = (0, import_signal.getArgMetas)(sigRef, gqlMeta.key);
77
- const gqlArgMetas = argMetas.filter((argMeta) => argMeta.type !== "Upload");
78
- const uploadArgMetas = argMetas.filter((argMeta) => argMeta.type === "Upload");
79
75
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "collapse-arrow bg-base-300 collapse my-1", children: [
80
76
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: open }),
81
77
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "collapse-title text-xl", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-3", children: [
82
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `btn btn-xs w-16 ${gqlMeta.type === "Query" ? "btn-success" : "btn-accent"}`, children: gqlMeta.type }),
83
- gqlMeta.key,
78
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `btn btn-xs w-16 ${gqlMeta.type === "query" ? "btn-success" : "btn-accent"}`, children: gqlMeta.type }),
79
+ gqlKey,
84
80
  " ",
85
81
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "text-sm", children: [
86
82
  "(",
87
- l.api(sigMeta.refName, gqlMeta.key),
83
+ l._(`${refName}.signal.${gqlKey}`),
88
84
  ")"
89
85
  ] })
90
86
  ] }) }),
@@ -92,9 +88,9 @@ const GraphQLEndpoint = ({ sigRef, gqlMeta, open }) => {
92
88
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mt-4 text-lg", children: [
93
89
  "Description",
94
90
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("hr", { className: "my-2 border-[0.1px] border-gray-400" }),
95
- gqlMeta.guards.some((guard) => guard !== "None") ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2 pb-3 pl-3 text-base font-normal", children: [
91
+ gqlMeta.signalOption?.guards?.some((guard) => guard !== "None") ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2 pb-3 pl-3 text-base font-normal", children: [
96
92
  "- Guards:",
97
- gqlMeta.guards.map((guard) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
93
+ gqlMeta.signalOption.guards.map((guard) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
98
94
  "span",
99
95
  {
100
96
  className: `badge ${guard === "Public" ? "badge-success" : guard === "SuperAdmin" ? "badge-error" : guard === "Admin" ? "badge-error" : guard === "User" ? "badge-accent" : guard === "Owner" ? "badge-accent" : guard === "Every" ? "badge-warning" : ""}`,
@@ -105,7 +101,7 @@ const GraphQLEndpoint = ({ sigRef, gqlMeta, open }) => {
105
101
  ] }) : null,
106
102
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pb-3 pl-3 text-base font-normal", children: [
107
103
  "- ",
108
- l.apidesc(sigMeta.refName, gqlMeta.key)
104
+ l._(`${refName}.signal.${gqlKey}.desc`)
109
105
  ] })
110
106
  ] }),
111
107
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "my-4 flex w-full gap-5 px-5", children: [
@@ -136,31 +132,25 @@ const GraphQLEndpoint = ({ sigRef, gqlMeta, open }) => {
136
132
  }
137
133
  )
138
134
  ] }),
139
- viewStatus === "doc" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
140
- GraphQLInterface,
141
- {
142
- sigRef,
143
- gqlMeta,
144
- gqlArgMetas,
145
- uploadArgMetas
146
- }
147
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphQLTry, { sigRef, gqlMeta, gqlArgMetas, uploadArgMetas })
135
+ viewStatus === "doc" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphQLInterface, { refName, gqlKey, gqlMeta }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GraphQLTry, { gqlKey, gqlMeta })
148
136
  ] })
149
137
  ] });
150
138
  };
151
139
  GraphQL.Endpoint = GraphQLEndpoint;
152
- const GraphQLInterface = ({ sigRef, gqlMeta, gqlArgMetas, uploadArgMetas }) => {
153
- const sigMeta = (0, import_signal.getSigMeta)(sigRef);
154
- const [returnRef, arrDepth] = (0, import_base.getNonArrayModel)(gqlMeta.returns());
140
+ const GraphQLInterface = ({ refName, gqlKey, gqlMeta }) => {
141
+ const returnRef = import_constant.constantInfo.getModelRef(gqlMeta.returns.refName, gqlMeta.returns.modelType);
142
+ const arrDepth = gqlMeta.returns.arrDepth;
155
143
  const isReturnModelType = !(0, import_base.isGqlScalar)(returnRef);
144
+ const uploadArgMetas = gqlMeta.args.filter((argMeta) => argMeta.type === "Upload");
145
+ const gqlArgMetas = gqlMeta.args.filter((argMeta) => argMeta.type !== "Upload");
156
146
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-4", children: [
157
147
  uploadArgMetas.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
158
148
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-lg", children: "Form data upload" }),
159
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "bg-base-100 overflow-x-auto rounded-md p-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Arg.default.Table, { sigMeta, gqlMeta, argMetas: uploadArgMetas }) })
149
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "bg-base-100 overflow-x-auto rounded-md p-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Arg.default.Table, { refName, gqlKey, argMetas: uploadArgMetas }) })
160
150
  ] }) : null,
161
151
  gqlArgMetas.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "text-start", children: [
162
152
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-start text-xl font-bold", children: "Variables" }),
163
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "bg-base-100 mt-3 overflow-x-auto rounded-md p-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Arg.default.Table, { sigMeta, gqlMeta, argMetas: gqlArgMetas }) })
153
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "bg-base-100 mt-3 overflow-x-auto rounded-md p-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Arg.default.Table, { refName, gqlKey, argMetas: gqlArgMetas }) })
164
154
  ] }) : null,
165
155
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-lg font-bold", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex w-full flex-col gap-2 rounded-md font-normal md:flex-col", children: [
166
156
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "w-full text-start md:w-full", children: [
@@ -173,27 +163,21 @@ const GraphQLInterface = ({ sigRef, gqlMeta, gqlArgMetas, uploadArgMetas }) => {
173
163
  ] }),
174
164
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "w-full text-start md:w-full", children: [
175
165
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xl font-bold", children: "Response Example" }),
176
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Response.default.Example, { sigRef, gqlMeta }) })
166
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Response.default.Example, { gqlMeta }) })
177
167
  ] })
178
168
  ] }) })
179
169
  ] });
180
170
  };
181
171
  GraphQL.Interface = GraphQLInterface;
182
- const GraphQLTry = ({ sigRef, gqlMeta, gqlArgMetas, uploadArgMetas }) => {
172
+ const GraphQLTry = ({ gqlKey, gqlMeta }) => {
183
173
  const tryJwt = import_store.st.use.tryJwt();
184
- const [modelRef, arrDepth] = (0, import_base.getNonArrayModel)(gqlMeta.returns());
174
+ const modelRef = import_constant.constantInfo.getModelRef(gqlMeta.returns.refName, gqlMeta.returns.modelType);
175
+ const uploadArgMetas = gqlMeta.args.filter((argMeta) => argMeta.type === "Upload");
176
+ const gqlArgMetas = gqlMeta.args.filter((argMeta) => argMeta.type !== "Upload");
185
177
  const isScalar = (0, import_base.isGqlScalar)(modelRef);
186
- const returnRef = isScalar || arrDepth === 0 ? modelRef : import_constant.constantInfo.isFull(modelRef) ? import_constant.constantInfo.getDatabase(import_constant.constantInfo.getRefName(modelRef)).light : modelRef;
187
- const gqlStr = (0, import_react.useMemo)(
188
- () => (0, import_signal.getGqlStr)(
189
- modelRef,
190
- gqlMeta.key,
191
- [...gqlArgMetas, ...uploadArgMetas].sort((a, b) => a.idx - b.idx),
192
- returnRef
193
- ),
194
- []
195
- );
196
- const requestExample = (0, import_react.useMemo)(() => JSON.stringify((0, import_signal.makeRequestExample)(sigRef, gqlMeta.key), null, 2), []);
178
+ const returnRef = isScalar || gqlMeta.returns.arrDepth === 0 ? modelRef : import_constant.constantInfo.isFull(modelRef) ? import_constant.constantInfo.getDatabase(import_constant.constantInfo.getRefName(modelRef)).light : modelRef;
179
+ const gqlStr = (0, import_react.useMemo)(() => (0, import_signal.getGqlStr)(modelRef, gqlKey, gqlMeta, returnRef), []);
180
+ const requestExample = (0, import_react.useMemo)(() => JSON.stringify((0, import_signal.makeRequestExample)(gqlMeta), null, 2), []);
197
181
  const [gqlRequest, setGqlRequest] = (0, import_react.useState)(requestExample);
198
182
  const [uploadRequest, setUploadRequest] = (0, import_react.useState)({});
199
183
  const [response, setResponse] = (0, import_react.useState)({
@@ -203,8 +187,8 @@ const GraphQLTry = ({ sigRef, gqlMeta, gqlArgMetas, uploadArgMetas }) => {
203
187
  const onSend = async () => {
204
188
  setResponse({ status: "loading", data: null });
205
189
  const request = { ...JSON.parse(gqlRequest), ...uploadRequest };
206
- const argData = [...gqlArgMetas, ...uploadArgMetas].sort((a, b) => a.idx - b.idx).map((argMeta) => request[argMeta.name]);
207
- const fetchFn = import_signal.fetch[gqlMeta.key].bind(import_signal.fetch);
190
+ const argData = gqlMeta.args.map((argMeta) => request[argMeta.name]);
191
+ const fetchFn = import_signal.fetch[gqlKey].bind(import_signal.fetch);
208
192
  const data = await fetchFn(...argData, {
209
193
  token: tryJwt,
210
194
  onError: (data2) => {
@@ -219,6 +203,7 @@ const GraphQLTry = ({ sigRef, gqlMeta, gqlArgMetas, uploadArgMetas }) => {
219
203
  uploadArgMetas.map((argMeta) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
220
204
  import_Arg.default.FormData,
221
205
  {
206
+ gqlKey,
222
207
  argMeta,
223
208
  value: uploadRequest[argMeta.name],
224
209
  onChange: (fileList) => {