codeforlife 2.12.7 → 2.14.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/dist/{Countdown-snRYiLrs.js → Countdown-B1ilD_qY.js} +2 -2
- package/dist/{Countdown-snRYiLrs.js.map → Countdown-B1ilD_qY.js.map} +1 -1
- package/dist/{Countdown-CL7dyZrl.cjs → Countdown-DJ5b4A3w.cjs} +2 -2
- package/dist/{Countdown-CL7dyZrl.cjs.map → Countdown-DJ5b4A3w.cjs.map} +1 -1
- package/dist/{LinkButton-CRDs950E.js → LinkButton-BVU_MF2a.js} +2 -2
- package/dist/{LinkButton-CRDs950E.js.map → LinkButton-BVU_MF2a.js.map} +1 -1
- package/dist/{LinkButton-BQMG96aQ.cjs → LinkButton-BbGJHgCY.cjs} +2 -2
- package/dist/{LinkButton-BQMG96aQ.cjs.map → LinkButton-BbGJHgCY.cjs.map} +1 -1
- package/dist/{Navigate-Ch0ljYa-.cjs → Navigate-CioAG5Y-.cjs} +2 -2
- package/dist/{Navigate-Ch0ljYa-.cjs.map → Navigate-CioAG5Y-.cjs.map} +1 -1
- package/dist/{Navigate-Zt9DRJve.js → Navigate-DfeA_eki.js} +2 -2
- package/dist/{Navigate-Zt9DRJve.js.map → Navigate-DfeA_eki.js.map} +1 -1
- package/dist/api/endpoints/index.cjs.js +1 -1
- package/dist/api/endpoints/index.es.js +1 -1
- package/dist/api/index.cjs.js +1 -1
- package/dist/api/index.cjs.js.map +1 -1
- package/dist/api/index.es.js +21 -19
- package/dist/api/index.es.js.map +1 -1
- package/dist/auth-D-8t6wfR.js +238 -0
- package/dist/auth-D-8t6wfR.js.map +1 -0
- package/dist/auth-uyv8Mv88.cjs +2 -0
- package/dist/auth-uyv8Mv88.cjs.map +1 -0
- package/dist/components/form/index.cjs.js +1 -1
- package/dist/components/form/index.es.js +1 -1
- package/dist/components/index.cjs.js +1 -1
- package/dist/components/index.es.js +5 -5
- package/dist/components/page/index.cjs.js +1 -1
- package/dist/components/page/index.es.js +1 -1
- package/dist/components/router/index.cjs.js +1 -1
- package/dist/components/router/index.es.js +2 -2
- package/dist/features/index.cjs.js +1 -1
- package/dist/features/index.cjs.js.map +1 -1
- package/dist/features/index.es.js +13 -14
- package/dist/features/index.es.js.map +1 -1
- package/dist/hooks/index.cjs.js +1 -1
- package/dist/hooks/index.es.js +1 -1
- package/dist/index-C8T09ieQ.cjs +2 -0
- package/dist/index-C8T09ieQ.cjs.map +1 -0
- package/dist/index-Cxq_P-ni.js +242 -0
- package/dist/index-Cxq_P-ni.js.map +1 -0
- package/dist/index-Da4T5FYK.cjs +2 -0
- package/dist/{index-BsxcGeQL.cjs.map → index-Da4T5FYK.cjs.map} +1 -1
- package/dist/{index-uvqsz6fM.js → index-De-EwYmr.js} +4 -5
- package/dist/{index-uvqsz6fM.js.map → index-De-EwYmr.js.map} +1 -1
- package/dist/session-CJM1Czfv.js +33 -0
- package/dist/session-CJM1Czfv.js.map +1 -0
- package/dist/session-J-ezj9cg.cjs +2 -0
- package/dist/session-J-ezj9cg.cjs.map +1 -0
- package/dist/slices/index.cjs.js +1 -1
- package/dist/slices/index.cjs.js.map +1 -1
- package/dist/slices/index.es.js +27 -3
- package/dist/slices/index.es.js.map +1 -1
- package/dist/src/api/createApi.d.ts +4 -1
- package/dist/src/api/endpoints/session.d.ts +3 -2
- package/dist/src/components/page/Page.d.ts +3 -2
- package/dist/src/hooks/auth.d.ts +4 -3
- package/dist/src/slices/index.d.ts +1 -1
- package/dist/src/slices/session.d.ts +2 -10
- package/dist/src/utils/settings.d.ts +37 -0
- package/dist/utils/auth.cjs.js +1 -1
- package/dist/utils/auth.cjs.js.map +1 -1
- package/dist/utils/auth.es.js +18 -18
- package/dist/utils/auth.es.js.map +1 -1
- package/dist/utils/router.cjs.js +1 -1
- package/dist/utils/router.es.js +1 -1
- package/dist/utils/settings.cjs.js +2 -0
- package/dist/utils/settings.cjs.js.map +1 -0
- package/dist/utils/settings.d.ts +2 -0
- package/dist/utils/settings.es.js +37 -0
- package/dist/utils/settings.es.js.map +1 -0
- package/package.json +10 -10
- package/dist/auth-B6anBtxF.js +0 -238
- package/dist/auth-B6anBtxF.js.map +0 -1
- package/dist/auth-C2OUeLmQ.cjs +0 -2
- package/dist/auth-C2OUeLmQ.cjs.map +0 -1
- package/dist/index-B3QkMBQe.cjs +0 -2
- package/dist/index-B3QkMBQe.cjs.map +0 -1
- package/dist/index-BsxcGeQL.cjs +0 -2
- package/dist/index-C08WO83n.js +0 -237
- package/dist/index-C08WO83n.js.map +0 -1
- package/dist/session-CE2U7oL1.cjs +0 -2
- package/dist/session-CE2U7oL1.cjs.map +0 -1
- package/dist/session-COyN01K0.js +0 -33
- package/dist/session-COyN01K0.js.map +0 -1
- package/dist/session-eOp0H-EC.cjs +0 -2
- package/dist/session-eOp0H-EC.cjs.map +0 -1
- package/dist/session-oI-Ht2C8.js +0 -30
- package/dist/session-oI-Ht2C8.js.map +0 -1
- package/dist/settings/index.cjs.js +0 -2
- package/dist/settings/index.cjs.js.map +0 -1
- package/dist/settings/index.d.ts +0 -2
- package/dist/settings/index.es.js +0 -18
- package/dist/settings/index.es.js.map +0 -1
- package/dist/src/settings/custom.d.ts +0 -12
- package/dist/src/settings/index.d.ts +0 -3
- package/dist/src/settings/vite.d.ts +0 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as u, Fragment as a, jsxs as f } from "react/jsx-runtime";
|
|
2
2
|
import { useState as s } from "react";
|
|
3
3
|
import { Typography as h } from "@mui/material";
|
|
4
|
-
import "./auth-
|
|
4
|
+
import "./auth-D-8t6wfR.js";
|
|
5
5
|
import { u as l } from "./general-D7Hqi3gj.js";
|
|
6
6
|
import "react-router";
|
|
7
7
|
import "yup";
|
|
@@ -25,4 +25,4 @@ const d = ({
|
|
|
25
25
|
export {
|
|
26
26
|
d as C
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=Countdown-
|
|
28
|
+
//# sourceMappingURL=Countdown-B1ilD_qY.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Countdown-
|
|
1
|
+
{"version":3,"file":"Countdown-B1ilD_qY.js","sources":["../src/components/Countdown.tsx"],"sourcesContent":["import { type FC, useState } from \"react\"\nimport { Typography, type TypographyProps } from \"@mui/material\"\n\nimport { useCountdown } from \"../hooks\"\n\nexport interface CountdownProps extends Omit<TypographyProps, \"children\"> {\n seconds: number\n start?: boolean\n onEnd: () => void\n}\n\nconst Countdown: FC<CountdownProps> = ({\n seconds,\n start = true,\n onEnd,\n ...typographyProps\n}) => {\n seconds = Math.floor(seconds)\n const _seconds = useCountdown(seconds)[0]\n const [end, setEnd] = useState(!start)\n\n if (_seconds === 0 && !end) {\n setEnd(true)\n onEnd()\n }\n\n seconds = Math.floor(_seconds % 60)\n const minutes = Math.floor(_seconds / 60)\n\n return (\n <>\n {_seconds > 0 && (\n <Typography {...typographyProps}>\n {minutes > 0 && `${minutes} ${minutes > 1 ? \"mins\" : \"min\"} `}\n {seconds > 0 && `${seconds} ${seconds > 1 ? \"secs\" : \"sec\"}`}\n </Typography>\n )}\n </>\n )\n}\n\nexport default Countdown\n"],"names":["Countdown","seconds","start","onEnd","typographyProps","_seconds","useCountdown","end","setEnd","useState","minutes","jsxs","Typography"],"mappings":";;;;;;;;;AAWA,MAAMA,IAAgC,CAAC;AAAA,EACrC,SAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,OAAAC;AAAA,EACA,GAAGC;AACL,MAAM;AACJ,EAAAH,IAAU,KAAK,MAAMA,CAAO;AAC5B,QAAMI,IAAWC,EAAaL,CAAO,EAAE,CAAC,GAClC,CAACM,GAAKC,CAAM,IAAIC,EAAS,CAACP,CAAK;AAErC,EAAIG,MAAa,KAAK,CAACE,MACrBC,EAAO,EAAI,GACXL,EAAA,IAGFF,IAAU,KAAK,MAAMI,IAAW,EAAE;AAClC,QAAMK,IAAU,KAAK,MAAML,IAAW,EAAE;AAExC,gCAEK,UAAAA,IAAW,KACV,gBAAAM,EAACC,GAAA,EAAY,GAAGR,GACb,UAAA;AAAA,IAAAM,IAAU,KAAK,GAAGA,CAAO,IAAIA,IAAU,IAAI,SAAS,KAAK;AAAA,IACzDT,IAAU,KAAK,GAAGA,CAAO,IAAIA,IAAU,IAAI,SAAS,KAAK;AAAA,EAAA,EAAA,CAC5D,EAAA,CAEJ;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const n=require("react/jsx-runtime"),c=require("react"),q=require("@mui/material");require("./auth-
|
|
2
|
-
//# sourceMappingURL=Countdown-
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),c=require("react"),q=require("@mui/material");require("./auth-uyv8Mv88.cjs");const l=require("./general-BPbbmkeX.cjs");require("react-router");require("yup");require("@mui/icons-material");require("./palette-BnIdHKDE.cjs");const h=({seconds:e,start:u=!0,onEnd:i,...o})=>{e=Math.floor(e);const r=l.useCountdown(e)[0],[s,a]=c.useState(!u);r===0&&!s&&(a(!0),i()),e=Math.floor(r%60);const t=Math.floor(r/60);return n.jsx(n.Fragment,{children:r>0&&n.jsxs(q.Typography,{...o,children:[t>0&&`${t} ${t>1?"mins":"min"} `,e>0&&`${e} ${e>1?"secs":"sec"}`]})})};exports.Countdown=h;
|
|
2
|
+
//# sourceMappingURL=Countdown-DJ5b4A3w.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Countdown-
|
|
1
|
+
{"version":3,"file":"Countdown-DJ5b4A3w.cjs","sources":["../src/components/Countdown.tsx"],"sourcesContent":["import { type FC, useState } from \"react\"\nimport { Typography, type TypographyProps } from \"@mui/material\"\n\nimport { useCountdown } from \"../hooks\"\n\nexport interface CountdownProps extends Omit<TypographyProps, \"children\"> {\n seconds: number\n start?: boolean\n onEnd: () => void\n}\n\nconst Countdown: FC<CountdownProps> = ({\n seconds,\n start = true,\n onEnd,\n ...typographyProps\n}) => {\n seconds = Math.floor(seconds)\n const _seconds = useCountdown(seconds)[0]\n const [end, setEnd] = useState(!start)\n\n if (_seconds === 0 && !end) {\n setEnd(true)\n onEnd()\n }\n\n seconds = Math.floor(_seconds % 60)\n const minutes = Math.floor(_seconds / 60)\n\n return (\n <>\n {_seconds > 0 && (\n <Typography {...typographyProps}>\n {minutes > 0 && `${minutes} ${minutes > 1 ? \"mins\" : \"min\"} `}\n {seconds > 0 && `${seconds} ${seconds > 1 ? \"secs\" : \"sec\"}`}\n </Typography>\n )}\n </>\n )\n}\n\nexport default Countdown\n"],"names":["Countdown","seconds","start","onEnd","typographyProps","_seconds","useCountdown","end","setEnd","useState","minutes","jsxs","Typography"],"mappings":"iRAWA,MAAMA,EAAgC,CAAC,CACrC,QAAAC,EACA,MAAAC,EAAQ,GACR,MAAAC,EACA,GAAGC,CACL,IAAM,CACJH,EAAU,KAAK,MAAMA,CAAO,EAC5B,MAAMI,EAAWC,EAAAA,aAAaL,CAAO,EAAE,CAAC,EAClC,CAACM,EAAKC,CAAM,EAAIC,EAAAA,SAAS,CAACP,CAAK,EAEjCG,IAAa,GAAK,CAACE,IACrBC,EAAO,EAAI,EACXL,EAAA,GAGFF,EAAU,KAAK,MAAMI,EAAW,EAAE,EAClC,MAAMK,EAAU,KAAK,MAAML,EAAW,EAAE,EAExC,yBAEK,SAAAA,EAAW,GACVM,EAAAA,KAACC,EAAAA,WAAA,CAAY,GAAGR,EACb,SAAA,CAAAM,EAAU,GAAK,GAAGA,CAAO,IAAIA,EAAU,EAAI,OAAS,KAAK,IACzDT,EAAU,GAAK,GAAGA,CAAO,IAAIA,EAAU,EAAI,OAAS,KAAK,EAAA,CAAA,CAC5D,CAAA,CAEJ,CAEJ"}
|
|
@@ -4,9 +4,9 @@ import "react";
|
|
|
4
4
|
import { Link as m } from "react-router";
|
|
5
5
|
import "@mui/icons-material";
|
|
6
6
|
import "./palette-CYwuLBW7.js";
|
|
7
|
-
import "./auth-
|
|
7
|
+
import "./auth-D-8t6wfR.js";
|
|
8
8
|
const L = (o) => /* @__PURE__ */ t(r, { ...o, component: m });
|
|
9
9
|
export {
|
|
10
10
|
L
|
|
11
11
|
};
|
|
12
|
-
//# sourceMappingURL=LinkButton-
|
|
12
|
+
//# sourceMappingURL=LinkButton-BVU_MF2a.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkButton-
|
|
1
|
+
{"version":3,"file":"LinkButton-BVU_MF2a.js","sources":["../src/components/router/LinkButton.tsx"],"sourcesContent":["import { Button, type ButtonProps } from \"@mui/material\"\nimport { type JSX } from \"react\"\nimport { Link } from \"react-router\"\n\nimport { type LinkProps } from \"../../utils/router\"\n\nexport type LinkButtonProps<\n Override extends \"delta\" | \"to\",\n State extends Record<string, any> = Record<string, any>,\n> = Omit<ButtonProps, \"component\"> & LinkProps<Override, State>\n\n// https://mui.com/material-ui/integrations/routing/#button\nconst LinkButton: {\n (props: LinkButtonProps<\"delta\">): JSX.Element\n <State extends Record<string, any> = Record<string, any>>(\n props: LinkButtonProps<\"to\", State>,\n ): JSX.Element\n} = (props: LinkButtonProps<\"delta\"> | LinkButtonProps<\"to\">) => {\n return <Button {...{ ...props, component: Link }} />\n}\n\nexport default LinkButton\n"],"names":["LinkButton","props","jsx","Button","Link"],"mappings":";;;;;;;AAYA,MAAMA,IAKF,CAACC,MACI,gBAAAC,EAACC,KAAa,GAAGF,GAAO,WAAWG,GAAQ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const r=require("react/jsx-runtime"),t=require("@mui/material");require("react");const n=require("react-router");require("@mui/icons-material");require("./palette-BnIdHKDE.cjs");require("./auth-
|
|
2
|
-
//# sourceMappingURL=LinkButton-
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),t=require("@mui/material");require("react");const n=require("react-router");require("@mui/icons-material");require("./palette-BnIdHKDE.cjs");require("./auth-uyv8Mv88.cjs");const u=e=>r.jsx(t.Button,{...e,component:n.Link});exports.LinkButton=u;
|
|
2
|
+
//# sourceMappingURL=LinkButton-BbGJHgCY.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkButton-
|
|
1
|
+
{"version":3,"file":"LinkButton-BbGJHgCY.cjs","sources":["../src/components/router/LinkButton.tsx"],"sourcesContent":["import { Button, type ButtonProps } from \"@mui/material\"\nimport { type JSX } from \"react\"\nimport { Link } from \"react-router\"\n\nimport { type LinkProps } from \"../../utils/router\"\n\nexport type LinkButtonProps<\n Override extends \"delta\" | \"to\",\n State extends Record<string, any> = Record<string, any>,\n> = Omit<ButtonProps, \"component\"> & LinkProps<Override, State>\n\n// https://mui.com/material-ui/integrations/routing/#button\nconst LinkButton: {\n (props: LinkButtonProps<\"delta\">): JSX.Element\n <State extends Record<string, any> = Record<string, any>>(\n props: LinkButtonProps<\"to\", State>,\n ): JSX.Element\n} = (props: LinkButtonProps<\"delta\"> | LinkButtonProps<\"to\">) => {\n return <Button {...{ ...props, component: Link }} />\n}\n\nexport default LinkButton\n"],"names":["LinkButton","props","jsx","Button","Link"],"mappings":"8NAYA,MAAMA,EAKDC,GACIC,EAAAA,IAACC,EAAAA,QAAa,GAAGF,EAAO,UAAWG,EAAAA,KAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),e=require("@mui/material"),c=require("react"),i=require("react-router");require("@mui/icons-material");require("./palette-BnIdHKDE.cjs");const u=require("./auth-
|
|
2
|
-
//# sourceMappingURL=Navigate-
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),e=require("@mui/material"),c=require("react"),i=require("react-router");require("@mui/icons-material");require("./palette-BnIdHKDE.cjs");const u=require("./auth-uyv8Mv88.cjs"),L=n=>t.jsx(e.Link,{component:i.Link,...n}),a=n=>t.jsx(e.IconButton,{...n,component:i.Link}),k=n=>t.jsx(e.ListItem,{...n,component:i.Link}),m=n=>t.jsx(e.Tab,{...n,component:i.Link}),q=({delta:n,to:o,...s})=>{const r=u.useNavigate();return c.useEffect(()=>{typeof n=="number"?r(n):r(o,s)},[r,n,o,s]),t.jsx(t.Fragment,{})};exports.Link=L;exports.LinkIconButton=a;exports.LinkListItem=k;exports.LinkTab=m;exports.Navigate=q;
|
|
2
|
+
//# sourceMappingURL=Navigate-CioAG5Y-.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Navigate-
|
|
1
|
+
{"version":3,"file":"Navigate-CioAG5Y-.cjs","sources":["../src/components/router/Link.tsx","../src/components/router/LinkIconButton.tsx","../src/components/router/LinkListItem.tsx","../src/components/router/LinkTab.tsx","../src/components/router/Navigate.tsx"],"sourcesContent":["import { Link as MuiLink, type LinkProps as MuiLinkProps } from \"@mui/material\"\nimport { type JSX } from \"react\"\nimport { Link as RouterLink } from \"react-router\"\n\nimport { type LinkProps as RouterLinkProps } from \"../../utils/router\"\n\nexport type LinkProps<\n Override extends \"delta\" | \"to\",\n State extends Record<string, any> = Record<string, any>,\n> = Omit<MuiLinkProps, \"component\"> & RouterLinkProps<Override, State>\n\n// https://mui.com/material-ui/integrations/routing/#link\nconst Link: {\n (props: LinkProps<\"delta\">): JSX.Element\n <State extends Record<string, any> = Record<string, any>>(\n props: LinkProps<\"to\", State>,\n ): JSX.Element\n} = (props: LinkProps<\"delta\"> | LinkProps<\"to\">) => {\n // @ts-expect-error props are assignable\n return <MuiLink component={RouterLink} {...props} />\n}\n\nexport default Link\n","import { IconButton, type IconButtonProps } from \"@mui/material\"\nimport { type JSX } from \"react\"\nimport { Link } from \"react-router\"\n\nimport { type LinkProps } from \"../../utils/router\"\n\nexport type LinkIconButtonProps<\n Override extends \"delta\" | \"to\",\n State extends Record<string, any> = Record<string, any>,\n> = Omit<IconButtonProps, \"component\"> & LinkProps<Override, State>\n\n// https://mui.com/material-ui/integrations/routing/#button\nconst LinkIconButton: {\n (props: LinkIconButtonProps<\"delta\">): JSX.Element\n <State extends Record<string, any> = Record<string, any>>(\n props: LinkIconButtonProps<\"to\", State>,\n ): JSX.Element\n} = (props: LinkIconButtonProps<\"delta\"> | LinkIconButtonProps<\"to\">) => {\n return <IconButton {...{ ...props, component: Link }} />\n}\n\nexport default LinkIconButton\n","import { ListItem, type ListItemProps } from \"@mui/material\"\nimport { type JSX } from \"react\"\nimport { Link } from \"react-router\"\n\nimport { type LinkProps } from \"../../utils/router\"\n\nexport type LinkListItemProps<\n Override extends \"delta\" | \"to\",\n State extends Record<string, any> = Record<string, any>,\n> = Omit<ListItemProps, \"component\"> & LinkProps<Override, State>\n\n// https://mui.com/material-ui/integrations/routing/#list\nconst LinkListItem: {\n (props: LinkListItemProps<\"delta\">): JSX.Element\n <State extends Record<string, any> = Record<string, any>>(\n props: LinkListItemProps<\"to\", State>,\n ): JSX.Element\n} = (props: LinkListItemProps<\"delta\"> | LinkListItemProps<\"to\">) => {\n return <ListItem {...{ ...props, component: Link }} />\n}\n\nexport default LinkListItem\n","import { Tab, type TabProps } from \"@mui/material\"\nimport { type JSX } from \"react\"\nimport { Link } from \"react-router\"\n\nimport { type LinkProps } from \"../../utils/router\"\n\nexport type LinkTabProps<\n Override extends \"delta\" | \"to\",\n State extends Record<string, any> = Record<string, any>,\n> = Omit<TabProps, \"component\"> & LinkProps<Override, State>\n\n// https://mui.com/material-ui/integrations/routing/#tabs\nconst LinkTab: {\n (props: LinkTabProps<\"delta\">): JSX.Element\n <State extends Record<string, any> = Record<string, any>>(\n props: LinkTabProps<\"to\", State>,\n ): JSX.Element\n} = (props: LinkTabProps<\"delta\"> | LinkTabProps<\"to\">) => {\n return <Tab {...{ ...props, component: Link }} />\n}\n\nexport default LinkTab\n","import { type JSX, useEffect } from \"react\"\nimport { type To } from \"react-router\"\n\nimport { type NavigateOptions, useNavigate } from \"../../hooks\"\n\nexport type NavigateProps<\n Override extends \"delta\" | \"to\",\n State extends Record<string, any> = Record<string, any>,\n> = Override extends \"delta\"\n ? { delta: number; to?: undefined }\n : { delta?: undefined; to: To } & NavigateOptions<State>\n\nconst Navigate: {\n (props: NavigateProps<\"delta\">): JSX.Element\n <State extends Record<string, any> = Record<string, any>>(\n props: NavigateProps<\"to\", State>,\n ): JSX.Element\n} = ({\n delta,\n to,\n ...options\n}: NavigateProps<\"delta\"> | NavigateProps<\"to\">) => {\n const navigate = useNavigate()\n\n useEffect(() => {\n if (typeof delta === \"number\") navigate(delta)\n else navigate(to, options)\n }, [navigate, delta, to, options])\n\n return <></>\n}\n\nexport default Navigate\n"],"names":["Link","props","jsx","MuiLink","RouterLink","LinkIconButton","IconButton","LinkListItem","ListItem","LinkTab","Tab","Navigate","delta","to","options","navigate","useNavigate","useEffect","Fragment"],"mappings":"kOAYMA,EAKDC,GAEIC,EAAAA,IAACC,EAAAA,KAAA,CAAQ,UAAWC,EAAAA,KAAa,GAAGH,EAAO,ECP9CI,EAKDJ,GACIC,EAAAA,IAACI,EAAAA,YAAiB,GAAGL,EAAO,UAAWD,EAAAA,KAAQ,ECNlDO,EAKDN,GACIC,EAAAA,IAACM,EAAAA,UAAe,GAAGP,EAAO,UAAWD,EAAAA,KAAQ,ECNhDS,EAKDR,GACIC,EAAAA,IAACQ,EAAAA,KAAU,GAAGT,EAAO,UAAWD,EAAAA,KAAQ,ECN3CW,EAKF,CAAC,CACH,MAAAC,EACA,GAAAC,EACA,GAAGC,CACL,IAAoD,CAClD,MAAMC,EAAWC,EAAAA,YAAA,EAEjBC,OAAAA,EAAAA,UAAU,IAAM,CACV,OAAOL,GAAU,SAAUG,EAASH,CAAK,EACxCG,EAASF,EAAIC,CAAO,CAC3B,EAAG,CAACC,EAAUH,EAAOC,EAAIC,CAAO,CAAC,EAE1BZ,EAAAA,IAAAgB,EAAAA,SAAA,EAAE,CACX"}
|
|
@@ -4,7 +4,7 @@ import { useEffect as L } from "react";
|
|
|
4
4
|
import { Link as o } from "react-router";
|
|
5
5
|
import "@mui/icons-material";
|
|
6
6
|
import "./palette-CYwuLBW7.js";
|
|
7
|
-
import { e as u } from "./auth-
|
|
7
|
+
import { e as u } from "./auth-D-8t6wfR.js";
|
|
8
8
|
const x = (n) => /* @__PURE__ */ t(s, { component: o, ...n }), B = (n) => /* @__PURE__ */ t(a, { ...n, component: o }), T = (n) => /* @__PURE__ */ t(c, { ...n, component: o }), $ = (n) => /* @__PURE__ */ t(p, { ...n, component: o }), j = ({
|
|
9
9
|
delta: n,
|
|
10
10
|
to: e,
|
|
@@ -22,4 +22,4 @@ export {
|
|
|
22
22
|
T as b,
|
|
23
23
|
$ as c
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=Navigate-
|
|
25
|
+
//# sourceMappingURL=Navigate-DfeA_eki.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Navigate-
|
|
1
|
+
{"version":3,"file":"Navigate-DfeA_eki.js","sources":["../src/components/router/Link.tsx","../src/components/router/LinkIconButton.tsx","../src/components/router/LinkListItem.tsx","../src/components/router/LinkTab.tsx","../src/components/router/Navigate.tsx"],"sourcesContent":["import { Link as MuiLink, type LinkProps as MuiLinkProps } from \"@mui/material\"\nimport { type JSX } from \"react\"\nimport { Link as RouterLink } from \"react-router\"\n\nimport { type LinkProps as RouterLinkProps } from \"../../utils/router\"\n\nexport type LinkProps<\n Override extends \"delta\" | \"to\",\n State extends Record<string, any> = Record<string, any>,\n> = Omit<MuiLinkProps, \"component\"> & RouterLinkProps<Override, State>\n\n// https://mui.com/material-ui/integrations/routing/#link\nconst Link: {\n (props: LinkProps<\"delta\">): JSX.Element\n <State extends Record<string, any> = Record<string, any>>(\n props: LinkProps<\"to\", State>,\n ): JSX.Element\n} = (props: LinkProps<\"delta\"> | LinkProps<\"to\">) => {\n // @ts-expect-error props are assignable\n return <MuiLink component={RouterLink} {...props} />\n}\n\nexport default Link\n","import { IconButton, type IconButtonProps } from \"@mui/material\"\nimport { type JSX } from \"react\"\nimport { Link } from \"react-router\"\n\nimport { type LinkProps } from \"../../utils/router\"\n\nexport type LinkIconButtonProps<\n Override extends \"delta\" | \"to\",\n State extends Record<string, any> = Record<string, any>,\n> = Omit<IconButtonProps, \"component\"> & LinkProps<Override, State>\n\n// https://mui.com/material-ui/integrations/routing/#button\nconst LinkIconButton: {\n (props: LinkIconButtonProps<\"delta\">): JSX.Element\n <State extends Record<string, any> = Record<string, any>>(\n props: LinkIconButtonProps<\"to\", State>,\n ): JSX.Element\n} = (props: LinkIconButtonProps<\"delta\"> | LinkIconButtonProps<\"to\">) => {\n return <IconButton {...{ ...props, component: Link }} />\n}\n\nexport default LinkIconButton\n","import { ListItem, type ListItemProps } from \"@mui/material\"\nimport { type JSX } from \"react\"\nimport { Link } from \"react-router\"\n\nimport { type LinkProps } from \"../../utils/router\"\n\nexport type LinkListItemProps<\n Override extends \"delta\" | \"to\",\n State extends Record<string, any> = Record<string, any>,\n> = Omit<ListItemProps, \"component\"> & LinkProps<Override, State>\n\n// https://mui.com/material-ui/integrations/routing/#list\nconst LinkListItem: {\n (props: LinkListItemProps<\"delta\">): JSX.Element\n <State extends Record<string, any> = Record<string, any>>(\n props: LinkListItemProps<\"to\", State>,\n ): JSX.Element\n} = (props: LinkListItemProps<\"delta\"> | LinkListItemProps<\"to\">) => {\n return <ListItem {...{ ...props, component: Link }} />\n}\n\nexport default LinkListItem\n","import { Tab, type TabProps } from \"@mui/material\"\nimport { type JSX } from \"react\"\nimport { Link } from \"react-router\"\n\nimport { type LinkProps } from \"../../utils/router\"\n\nexport type LinkTabProps<\n Override extends \"delta\" | \"to\",\n State extends Record<string, any> = Record<string, any>,\n> = Omit<TabProps, \"component\"> & LinkProps<Override, State>\n\n// https://mui.com/material-ui/integrations/routing/#tabs\nconst LinkTab: {\n (props: LinkTabProps<\"delta\">): JSX.Element\n <State extends Record<string, any> = Record<string, any>>(\n props: LinkTabProps<\"to\", State>,\n ): JSX.Element\n} = (props: LinkTabProps<\"delta\"> | LinkTabProps<\"to\">) => {\n return <Tab {...{ ...props, component: Link }} />\n}\n\nexport default LinkTab\n","import { type JSX, useEffect } from \"react\"\nimport { type To } from \"react-router\"\n\nimport { type NavigateOptions, useNavigate } from \"../../hooks\"\n\nexport type NavigateProps<\n Override extends \"delta\" | \"to\",\n State extends Record<string, any> = Record<string, any>,\n> = Override extends \"delta\"\n ? { delta: number; to?: undefined }\n : { delta?: undefined; to: To } & NavigateOptions<State>\n\nconst Navigate: {\n (props: NavigateProps<\"delta\">): JSX.Element\n <State extends Record<string, any> = Record<string, any>>(\n props: NavigateProps<\"to\", State>,\n ): JSX.Element\n} = ({\n delta,\n to,\n ...options\n}: NavigateProps<\"delta\"> | NavigateProps<\"to\">) => {\n const navigate = useNavigate()\n\n useEffect(() => {\n if (typeof delta === \"number\") navigate(delta)\n else navigate(to, options)\n }, [navigate, delta, to, options])\n\n return <></>\n}\n\nexport default Navigate\n"],"names":["Link","props","jsx","MuiLink","RouterLink","LinkIconButton","IconButton","LinkListItem","ListItem","LinkTab","Tab","Navigate","delta","to","options","navigate","useNavigate","useEffect","Fragment"],"mappings":";;;;;;;AAYA,MAAMA,IAKF,CAACC,MAEI,gBAAAC,EAACC,GAAA,EAAQ,WAAWC,GAAa,GAAGH,GAAO,GCP9CI,IAKF,CAACJ,MACI,gBAAAC,EAACI,KAAiB,GAAGL,GAAO,WAAWD,GAAQ,GCNlDO,IAKF,CAACN,MACI,gBAAAC,EAACM,KAAe,GAAGP,GAAO,WAAWD,GAAQ,GCNhDS,IAKF,CAACR,MACI,gBAAAC,EAACQ,KAAU,GAAGT,GAAO,WAAWD,GAAQ,GCN3CW,IAKF,CAAC;AAAA,EACH,OAAAC;AAAA,EACA,IAAAC;AAAA,EACA,GAAGC;AACL,MAAoD;AAClD,QAAMC,IAAWC,EAAA;AAEjB,SAAAC,EAAU,MAAM;AACd,IAAI,OAAOL,KAAU,WAAUG,EAASH,CAAK,IACxCG,EAASF,GAAIC,CAAO;AAAA,EAC3B,GAAG,CAACC,GAAUH,GAAOC,GAAIC,CAAO,CAAC,GAE1B,gBAAAZ,EAAAgB,GAAA,EAAE;AACX;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@reduxjs/toolkit/query/react");const t=require("../../api-G8CV5bUa.cjs"),s=require("../../urls-2gheISSO.cjs"),i=require("../../session-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@reduxjs/toolkit/query/react");const t=require("../../api-G8CV5bUa.cjs"),s=require("../../urls-2gheISSO.cjs"),i=require("../../session-J-ezj9cg.cjs"),l="AuthFactor";function n(r){return{listAuthFactors:r.query({query:e=>({url:t.buildUrl(s.urls.authFactor.list,{search:e}),method:"GET"}),providesTags:t.tagData(l,{includeListTag:!0})})}}const u="Class";function d(r){return{retrieveClass:r.query({query:e=>({url:t.buildUrl(s.urls.class.detail,{url:{id:e}}),method:"GET"}),providesTags:t.tagData(u)}),listClasses:r.query({query:e=>({url:t.buildUrl(s.urls.class.list,{search:e}),method:"GET"}),providesTags:t.tagData(u,{includeListTag:!0})})}}const a="School";function g(r){return{retrieveSchool:r.query({query:e=>({url:t.buildUrl(s.urls.school.detail,{url:{id:e}}),method:"GET"}),providesTags:t.tagData(a)})}}const o="User";function c(r){return{retrieveUser:r.query({query:e=>({url:t.buildUrl(s.urls.user.detail,{url:{id:e}}),method:"GET"}),providesTags:t.tagData(o)}),listUsers:r.query({query:e=>({url:t.buildUrl(s.urls.user.list,{search:e}),method:"GET"}),providesTags:t.tagData(o,{includeListTag:!0})})}}exports.buildLoginEndpoint=i.buildLoginEndpoint;exports.buildLogoutEndpoint=i.buildLogoutEndpoint;exports.AUTH_FACTOR_TAG=l;exports.CLASS_TAG=u;exports.SCHOOL_TAG=a;exports.USER_TAG=o;exports.getReadAuthFactorEndpoints=n;exports.getReadClassEndpoints=d;exports.getReadSchoolEndpoints=g;exports.getReadUserEndpoints=c;
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@reduxjs/toolkit/query/react";
|
|
2
2
|
import { t, b as s } from "../../api-uh8UKwsU.js";
|
|
3
3
|
import { u as o } from "../../urls-BG788CnL.js";
|
|
4
|
-
import { a as q, b as y } from "../../session-
|
|
4
|
+
import { a as q, b as y } from "../../session-CJM1Czfv.js";
|
|
5
5
|
const a = "AuthFactor";
|
|
6
6
|
function T(e) {
|
|
7
7
|
return {
|
package/dist/api/index.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@reduxjs/toolkit/query/react")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@reduxjs/toolkit/query/react");require("@reduxjs/toolkit");const g=require("../session-J-ezj9cg.cjs"),s=require("../utils/auth.cjs.js"),y=require("../api-G8CV5bUa.cjs"),h=require("../schemas-hIW9-H6-.cjs"),m=require("../urls-2gheISSO.cjs"),u=["User","School","Class","AuthFactor"];function T({serviceApiUrl:p,logoutAction:f,tagTypes:l=[]}){const i=a.fetchBaseQuery({baseUrl:`${p}/`,credentials:"include",prepareHeaders:(e,t)=>{const{type:r,arg:o}=t,d=typeof o=="string"?"GET":o.method||"GET";if(r==="mutation"||!y.isSafeHttpMethod(d)){const c=s.getCsrfCookie();c&&e.set("x-csrftoken",c)}return e}}),n=a.createApi({baseQuery:async(e,t,r)=>{if(t.type==="mutation"&&s.getCsrfCookie()===void 0){const{error:o}=await i({url:"/csrf/cookie/",method:"GET"},t,{});o!==void 0&&console.error(o),s.getCsrfCookie()}return await i(e,t,r)},tagTypes:[...u,...l],endpoints:()=>({})});return n.injectEndpoints({endpoints:e=>({logout:g.buildLogoutEndpoint(n,e,f)})})}exports.schemas=h.schemas;exports.urls=m.urls;exports.createApi=T;exports.tagTypes=u;
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../src/api/tagTypes.ts","../../src/api/createApi.ts"],"sourcesContent":["const tagTypes = [\n // These are the tags for the common models used throughout our system.\n // https://github.com/ocadotechnology/codeforlife-package-python/tree/main/codeforlife/user/models\n // NOTE: Don't use the \"Teacher\" and \"Student\" tags. Use \"User\" instead.\n \"User\",\n \"School\",\n \"Class\",\n \"AuthFactor\",\n] as const\n\nexport default tagTypes\nexport type TagTypes = (typeof tagTypes)[number]\n","import {\n type Api,\n type BaseQueryApi,\n type FetchArgs,\n type FetchBaseQueryError,\n type FetchBaseQueryMeta,\n type MutationDefinition,\n type QueryReturnValue,\n createApi as _createApi,\n type coreModuleName,\n fetchBaseQuery,\n type reactHooksModuleName,\n} from \"@reduxjs/toolkit/query/react\"\
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../src/api/tagTypes.ts","../../src/api/createApi.ts"],"sourcesContent":["const tagTypes = [\n // These are the tags for the common models used throughout our system.\n // https://github.com/ocadotechnology/codeforlife-package-python/tree/main/codeforlife/user/models\n // NOTE: Don't use the \"Teacher\" and \"Student\" tags. Use \"User\" instead.\n \"User\",\n \"School\",\n \"Class\",\n \"AuthFactor\",\n] as const\n\nexport default tagTypes\nexport type TagTypes = (typeof tagTypes)[number]\n","import {\n type Api,\n type BaseQueryApi,\n type FetchArgs,\n type FetchBaseQueryError,\n type FetchBaseQueryMeta,\n type MutationDefinition,\n type QueryReturnValue,\n createApi as _createApi,\n type coreModuleName,\n fetchBaseQuery,\n type reactHooksModuleName,\n} from \"@reduxjs/toolkit/query/react\"\nimport { type ActionCreatorWithoutPayload } from \"@reduxjs/toolkit\"\n\nimport defaultTagTypes, { type TagTypes as DefaultTagTypes } from \"./tagTypes\"\nimport { buildLogoutEndpoint } from \"./endpoints/session\"\nimport { getCsrfCookie } from \"../utils/auth\"\nimport { isSafeHttpMethod } from \"../utils/api\"\n\n// TODO: decide if we want to keep any of this.\n// export function handleResponseError(error: FetchBaseQueryError): void {\n// if (\n// error.status === 400 &&\n// typeof error.data === \"object\" &&\n// error.data !== null\n// ) {\n// // Parse the error's data from snake_case to camelCase.\n// snakeCaseToCamelCase(error.data)\n// } else if (error.status === 401) {\n// // TODO: redirect to appropriate login page based on user type.\n// window.location.href = `${PORTAL_BASE_URL}/login/teacher`\n// } else {\n// // Catch-all error pages by status-code.\n// window.location.href = `${PORTAL_BASE_URL}/error/${\n// [403, 404].includes(error.status as number) ? error.status : 500\n// }`\n// }\n// }\n\nexport default function createApi<TagTypes extends string = never>({\n serviceApiUrl,\n logoutAction,\n tagTypes = [],\n}: {\n serviceApiUrl: string\n logoutAction: ActionCreatorWithoutPayload\n tagTypes?: readonly TagTypes[]\n}): Api<\n (\n args: string | FetchArgs,\n api: BaseQueryApi,\n extraOptions: {},\n ) => Promise<\n QueryReturnValue<unknown, FetchBaseQueryError, FetchBaseQueryMeta>\n >,\n { logout: MutationDefinition<null, any, any, null, any, any> },\n \"api\",\n TagTypes | DefaultTagTypes,\n typeof coreModuleName | typeof reactHooksModuleName\n> {\n const fetch = fetchBaseQuery({\n baseUrl: `${serviceApiUrl}/`,\n credentials: \"include\",\n prepareHeaders: (headers, endpoint) => {\n const { type, arg } = endpoint as typeof endpoint & {\n arg: string | FetchArgs\n }\n const method = typeof arg === \"string\" ? \"GET\" : arg.method || \"GET\"\n\n if (type === \"mutation\" || !isSafeHttpMethod(method)) {\n const csrfToken = getCsrfCookie()\n if (csrfToken) headers.set(\"x-csrftoken\", csrfToken)\n }\n\n return headers\n },\n })\n\n const api = _createApi({\n // https://redux-toolkit.js.org/rtk-query/usage/customizing-queries#implementing-a-custom-basequery\n baseQuery: async (args: string | FetchArgs, api, extraOptions) => {\n if (api.type === \"mutation\" && getCsrfCookie() === undefined) {\n // Get the CSRF token.\n const { error } = await fetch(\n { url: \"/csrf/cookie/\", method: \"GET\" },\n api,\n {},\n )\n\n // Validate we got the CSRF token.\n if (error !== undefined) {\n console.error(error)\n // TODO\n // window.location.href = `${PORTAL_BASE_URL}/error/500`\n }\n if (getCsrfCookie() === undefined) {\n // TODO\n // window.location.href = `${PORTAL_BASE_URL}/error/500`\n }\n }\n\n // Send the HTTP request and fetch the response.\n return await fetch(args, api, extraOptions)\n },\n tagTypes: [...defaultTagTypes, ...tagTypes],\n endpoints: () => ({}),\n })\n\n return api.injectEndpoints({\n endpoints: build => ({\n logout: buildLogoutEndpoint<null, null>(api, build, logoutAction),\n }),\n })\n}\n"],"names":["tagTypes","createApi","serviceApiUrl","logoutAction","fetch","fetchBaseQuery","headers","endpoint","type","arg","method","isSafeHttpMethod","csrfToken","getCsrfCookie","api","_createApi","args","extraOptions","error","defaultTagTypes","build","buildLogoutEndpoint"],"mappings":"iVAAMA,EAAW,CAIf,OACA,SACA,QACA,YACF,ECgCA,SAAwBC,EAA2C,CACjE,cAAAC,EACA,aAAAC,EAAA,SACAH,EAAW,CAAA,CACb,EAgBE,CACA,MAAMI,EAAQC,EAAAA,eAAe,CAC3B,QAAS,GAAGH,CAAa,IACzB,YAAa,UACb,eAAgB,CAACI,EAASC,IAAa,CACrC,KAAM,CAAE,KAAAC,EAAM,IAAAC,CAAA,EAAQF,EAGhBG,EAAS,OAAOD,GAAQ,SAAW,MAAQA,EAAI,QAAU,MAE/D,GAAID,IAAS,YAAc,CAACG,EAAAA,iBAAiBD,CAAM,EAAG,CACpD,MAAME,EAAYC,EAAAA,cAAA,EACdD,GAAWN,EAAQ,IAAI,cAAeM,CAAS,CACrD,CAEA,OAAON,CACT,CAAA,CACD,EAEKQ,EAAMC,EAAAA,UAAW,CAErB,UAAW,MAAOC,EAA0BF,EAAKG,IAAiB,CAChE,GAAIH,EAAI,OAAS,YAAcD,EAAAA,cAAA,IAAoB,OAAW,CAE5D,KAAM,CAAE,MAAAK,CAAA,EAAU,MAAMd,EACtB,CAAE,IAAK,gBAAiB,OAAQ,KAAA,EAChCU,EACA,CAAA,CAAC,EAICI,IAAU,QACZ,QAAQ,MAAMA,CAAK,EAIjBL,EAAAA,cAAA,CAIN,CAGA,OAAO,MAAMT,EAAMY,EAAMF,EAAKG,CAAY,CAC5C,EACA,SAAU,CAAC,GAAGE,EAAiB,GAAGnB,CAAQ,EAC1C,UAAW,KAAO,CAAA,EAAC,CACpB,EAED,OAAOc,EAAI,gBAAgB,CACzB,UAAWM,IAAU,CACnB,OAAQC,EAAAA,oBAAgCP,EAAKM,EAAOjB,CAAY,CAAA,EAClE,CACD,CACH"}
|
package/dist/api/index.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { fetchBaseQuery as
|
|
2
|
-
import
|
|
3
|
-
import { b as
|
|
1
|
+
import { fetchBaseQuery as u, createApi as d } from "@reduxjs/toolkit/query/react";
|
|
2
|
+
import "@reduxjs/toolkit";
|
|
3
|
+
import { b as l } from "../session-CJM1Czfv.js";
|
|
4
4
|
import { getCsrfCookie as s } from "../utils/auth.es.js";
|
|
5
|
-
import { i as
|
|
5
|
+
import { i as y } from "../api-uh8UKwsU.js";
|
|
6
6
|
import { s as C } from "../schemas-UIk-meAN.js";
|
|
7
|
-
import { u as
|
|
8
|
-
const
|
|
7
|
+
import { u as w } from "../urls-BG788CnL.js";
|
|
8
|
+
const g = [
|
|
9
9
|
// These are the tags for the common models used throughout our system.
|
|
10
10
|
// https://github.com/ocadotechnology/codeforlife-package-python/tree/main/codeforlife/user/models
|
|
11
11
|
// NOTE: Don't use the "Teacher" and "Student" tags. Use "User" instead.
|
|
@@ -14,21 +14,23 @@ const y = [
|
|
|
14
14
|
"Class",
|
|
15
15
|
"AuthFactor"
|
|
16
16
|
];
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
function x({
|
|
18
|
+
serviceApiUrl: c,
|
|
19
|
+
logoutAction: p,
|
|
20
|
+
tagTypes: f = []
|
|
21
|
+
}) {
|
|
22
|
+
const i = u({
|
|
23
|
+
baseUrl: `${c}/`,
|
|
22
24
|
credentials: "include",
|
|
23
25
|
prepareHeaders: (t, o) => {
|
|
24
|
-
const { type: r, arg: e } = o,
|
|
25
|
-
if (r === "mutation" || !
|
|
26
|
+
const { type: r, arg: e } = o, m = typeof e == "string" ? "GET" : e.method || "GET";
|
|
27
|
+
if (r === "mutation" || !y(m)) {
|
|
26
28
|
const a = s();
|
|
27
29
|
a && t.set("x-csrftoken", a);
|
|
28
30
|
}
|
|
29
31
|
return t;
|
|
30
32
|
}
|
|
31
|
-
}), n =
|
|
33
|
+
}), n = d({
|
|
32
34
|
// https://redux-toolkit.js.org/rtk-query/usage/customizing-queries#implementing-a-custom-basequery
|
|
33
35
|
baseQuery: async (t, o, r) => {
|
|
34
36
|
if (o.type === "mutation" && s() === void 0) {
|
|
@@ -41,19 +43,19 @@ function b({
|
|
|
41
43
|
}
|
|
42
44
|
return await i(t, o, r);
|
|
43
45
|
},
|
|
44
|
-
tagTypes: [...
|
|
46
|
+
tagTypes: [...g, ...f],
|
|
45
47
|
endpoints: () => ({})
|
|
46
48
|
});
|
|
47
49
|
return n.injectEndpoints({
|
|
48
50
|
endpoints: (t) => ({
|
|
49
|
-
logout:
|
|
51
|
+
logout: l(n, t, p)
|
|
50
52
|
})
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
export {
|
|
54
|
-
|
|
56
|
+
x as createApi,
|
|
55
57
|
C as schemas,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
g as tagTypes,
|
|
59
|
+
w as urls
|
|
58
60
|
};
|
|
59
61
|
//# sourceMappingURL=index.es.js.map
|
package/dist/api/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../src/api/tagTypes.ts","../../src/api/createApi.ts"],"sourcesContent":["const tagTypes = [\n // These are the tags for the common models used throughout our system.\n // https://github.com/ocadotechnology/codeforlife-package-python/tree/main/codeforlife/user/models\n // NOTE: Don't use the \"Teacher\" and \"Student\" tags. Use \"User\" instead.\n \"User\",\n \"School\",\n \"Class\",\n \"AuthFactor\",\n] as const\n\nexport default tagTypes\nexport type TagTypes = (typeof tagTypes)[number]\n","import {\n type Api,\n type BaseQueryApi,\n type FetchArgs,\n type FetchBaseQueryError,\n type FetchBaseQueryMeta,\n type MutationDefinition,\n type QueryReturnValue,\n createApi as _createApi,\n type coreModuleName,\n fetchBaseQuery,\n type reactHooksModuleName,\n} from \"@reduxjs/toolkit/query/react\"\
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../src/api/tagTypes.ts","../../src/api/createApi.ts"],"sourcesContent":["const tagTypes = [\n // These are the tags for the common models used throughout our system.\n // https://github.com/ocadotechnology/codeforlife-package-python/tree/main/codeforlife/user/models\n // NOTE: Don't use the \"Teacher\" and \"Student\" tags. Use \"User\" instead.\n \"User\",\n \"School\",\n \"Class\",\n \"AuthFactor\",\n] as const\n\nexport default tagTypes\nexport type TagTypes = (typeof tagTypes)[number]\n","import {\n type Api,\n type BaseQueryApi,\n type FetchArgs,\n type FetchBaseQueryError,\n type FetchBaseQueryMeta,\n type MutationDefinition,\n type QueryReturnValue,\n createApi as _createApi,\n type coreModuleName,\n fetchBaseQuery,\n type reactHooksModuleName,\n} from \"@reduxjs/toolkit/query/react\"\nimport { type ActionCreatorWithoutPayload } from \"@reduxjs/toolkit\"\n\nimport defaultTagTypes, { type TagTypes as DefaultTagTypes } from \"./tagTypes\"\nimport { buildLogoutEndpoint } from \"./endpoints/session\"\nimport { getCsrfCookie } from \"../utils/auth\"\nimport { isSafeHttpMethod } from \"../utils/api\"\n\n// TODO: decide if we want to keep any of this.\n// export function handleResponseError(error: FetchBaseQueryError): void {\n// if (\n// error.status === 400 &&\n// typeof error.data === \"object\" &&\n// error.data !== null\n// ) {\n// // Parse the error's data from snake_case to camelCase.\n// snakeCaseToCamelCase(error.data)\n// } else if (error.status === 401) {\n// // TODO: redirect to appropriate login page based on user type.\n// window.location.href = `${PORTAL_BASE_URL}/login/teacher`\n// } else {\n// // Catch-all error pages by status-code.\n// window.location.href = `${PORTAL_BASE_URL}/error/${\n// [403, 404].includes(error.status as number) ? error.status : 500\n// }`\n// }\n// }\n\nexport default function createApi<TagTypes extends string = never>({\n serviceApiUrl,\n logoutAction,\n tagTypes = [],\n}: {\n serviceApiUrl: string\n logoutAction: ActionCreatorWithoutPayload\n tagTypes?: readonly TagTypes[]\n}): Api<\n (\n args: string | FetchArgs,\n api: BaseQueryApi,\n extraOptions: {},\n ) => Promise<\n QueryReturnValue<unknown, FetchBaseQueryError, FetchBaseQueryMeta>\n >,\n { logout: MutationDefinition<null, any, any, null, any, any> },\n \"api\",\n TagTypes | DefaultTagTypes,\n typeof coreModuleName | typeof reactHooksModuleName\n> {\n const fetch = fetchBaseQuery({\n baseUrl: `${serviceApiUrl}/`,\n credentials: \"include\",\n prepareHeaders: (headers, endpoint) => {\n const { type, arg } = endpoint as typeof endpoint & {\n arg: string | FetchArgs\n }\n const method = typeof arg === \"string\" ? \"GET\" : arg.method || \"GET\"\n\n if (type === \"mutation\" || !isSafeHttpMethod(method)) {\n const csrfToken = getCsrfCookie()\n if (csrfToken) headers.set(\"x-csrftoken\", csrfToken)\n }\n\n return headers\n },\n })\n\n const api = _createApi({\n // https://redux-toolkit.js.org/rtk-query/usage/customizing-queries#implementing-a-custom-basequery\n baseQuery: async (args: string | FetchArgs, api, extraOptions) => {\n if (api.type === \"mutation\" && getCsrfCookie() === undefined) {\n // Get the CSRF token.\n const { error } = await fetch(\n { url: \"/csrf/cookie/\", method: \"GET\" },\n api,\n {},\n )\n\n // Validate we got the CSRF token.\n if (error !== undefined) {\n console.error(error)\n // TODO\n // window.location.href = `${PORTAL_BASE_URL}/error/500`\n }\n if (getCsrfCookie() === undefined) {\n // TODO\n // window.location.href = `${PORTAL_BASE_URL}/error/500`\n }\n }\n\n // Send the HTTP request and fetch the response.\n return await fetch(args, api, extraOptions)\n },\n tagTypes: [...defaultTagTypes, ...tagTypes],\n endpoints: () => ({}),\n })\n\n return api.injectEndpoints({\n endpoints: build => ({\n logout: buildLogoutEndpoint<null, null>(api, build, logoutAction),\n }),\n })\n}\n"],"names":["tagTypes","createApi","serviceApiUrl","logoutAction","fetch","fetchBaseQuery","headers","endpoint","type","arg","method","isSafeHttpMethod","csrfToken","getCsrfCookie","api","_createApi","args","extraOptions","error","defaultTagTypes","build","buildLogoutEndpoint"],"mappings":";;;;;;;AAAA,MAAMA,IAAW;AAAA;AAAA;AAAA;AAAA,EAIf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;ACgCA,SAAwBC,EAA2C;AAAA,EACjE,eAAAC;AAAA,EACA,cAAAC;AAAA,EAAA,UACAH,IAAW,CAAA;AACb,GAgBE;AACA,QAAMI,IAAQC,EAAe;AAAA,IAC3B,SAAS,GAAGH,CAAa;AAAA,IACzB,aAAa;AAAA,IACb,gBAAgB,CAACI,GAASC,MAAa;AACrC,YAAM,EAAE,MAAAC,GAAM,KAAAC,EAAA,IAAQF,GAGhBG,IAAS,OAAOD,KAAQ,WAAW,QAAQA,EAAI,UAAU;AAE/D,UAAID,MAAS,cAAc,CAACG,EAAiBD,CAAM,GAAG;AACpD,cAAME,IAAYC,EAAA;AAClB,QAAID,KAAWN,EAAQ,IAAI,eAAeM,CAAS;AAAA,MACrD;AAEA,aAAON;AAAA,IACT;AAAA,EAAA,CACD,GAEKQ,IAAMC,EAAW;AAAA;AAAA,IAErB,WAAW,OAAOC,GAA0BF,GAAKG,MAAiB;AAChE,UAAIH,EAAI,SAAS,cAAcD,EAAA,MAAoB,QAAW;AAE5D,cAAM,EAAE,OAAAK,EAAA,IAAU,MAAMd;AAAA,UACtB,EAAE,KAAK,iBAAiB,QAAQ,MAAA;AAAA,UAChCU;AAAAA,UACA,CAAA;AAAA,QAAC;AAIH,QAAII,MAAU,UACZ,QAAQ,MAAMA,CAAK,GAIjBL,EAAA;AAAA,MAIN;AAGA,aAAO,MAAMT,EAAMY,GAAMF,GAAKG,CAAY;AAAA,IAC5C;AAAA,IACA,UAAU,CAAC,GAAGE,GAAiB,GAAGnB,CAAQ;AAAA,IAC1C,WAAW,OAAO,CAAA;AAAA,EAAC,CACpB;AAED,SAAOc,EAAI,gBAAgB;AAAA,IACzB,WAAW,CAAAM,OAAU;AAAA,MACnB,QAAQC,EAAgCP,GAAKM,GAAOjB,CAAY;AAAA,IAAA;AAAA,EAClE,CACD;AACH;"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { jsx as V, Fragment as j } from "react/jsx-runtime";
|
|
2
|
+
import * as L from "yup";
|
|
3
|
+
import { object as E } from "yup";
|
|
4
|
+
import { useEffect as d, useState as J, useCallback as $ } from "react";
|
|
5
|
+
import F from "js-cookie";
|
|
6
|
+
import { useNavigate as T, useLocation as w, useSearchParams as z, useParams as B, createSearchParams as G } from "react-router";
|
|
7
|
+
import { useSelector as H } from "react-redux";
|
|
8
|
+
import "@reduxjs/toolkit/query/react";
|
|
9
|
+
import "@reduxjs/toolkit";
|
|
10
|
+
import { makeOAuth2StorageKey as K, generateOAuth2CodeChallenge as Q } from "./utils/auth.es.js";
|
|
11
|
+
import "@mui/material";
|
|
12
|
+
import { generateSecureRandomString as W } from "./utils/general.es.js";
|
|
13
|
+
import "@mui/icons-material";
|
|
14
|
+
import "./schemas-UIk-meAN.js";
|
|
15
|
+
import "./urls-BG788CnL.js";
|
|
16
|
+
import { tryValidateSync as R } from "./utils/schema.es.js";
|
|
17
|
+
import "./palette-CYwuLBW7.js";
|
|
18
|
+
import { getSessionMetadataCookieName as X } from "./utils/settings.es.js";
|
|
19
|
+
function _() {
|
|
20
|
+
const e = T(), o = q();
|
|
21
|
+
return (a, t = void 0) => {
|
|
22
|
+
if (typeof a == "number") e(a);
|
|
23
|
+
else {
|
|
24
|
+
const { next: r = !0, ...n } = t || {};
|
|
25
|
+
e(
|
|
26
|
+
r && "next" in o ? o.next : a,
|
|
27
|
+
n
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function k() {
|
|
33
|
+
return w();
|
|
34
|
+
}
|
|
35
|
+
function q(e, o) {
|
|
36
|
+
const a = Object.fromEntries(z()[0].entries());
|
|
37
|
+
return e ? R(a, E(e), o) : a;
|
|
38
|
+
}
|
|
39
|
+
function Y(e, o) {
|
|
40
|
+
const a = B();
|
|
41
|
+
return e ? R(a, E(e), o) : a;
|
|
42
|
+
}
|
|
43
|
+
function ve({
|
|
44
|
+
shape: e,
|
|
45
|
+
children: o,
|
|
46
|
+
onValidationError: a,
|
|
47
|
+
onValidationSuccess: t = () => {
|
|
48
|
+
},
|
|
49
|
+
validateOptions: r
|
|
50
|
+
}) {
|
|
51
|
+
const n = Y(e, r), c = _();
|
|
52
|
+
return d(
|
|
53
|
+
() => {
|
|
54
|
+
n ? t(n) : a(c);
|
|
55
|
+
},
|
|
56
|
+
[]
|
|
57
|
+
// eslint-disable-line react-hooks/exhaustive-deps
|
|
58
|
+
), n ? o(n) : /* @__PURE__ */ V(j, {});
|
|
59
|
+
}
|
|
60
|
+
function S(e) {
|
|
61
|
+
return H(e) ? JSON.parse(F.get(X())) : void 0;
|
|
62
|
+
}
|
|
63
|
+
S.predefine = (e) => () => S(e);
|
|
64
|
+
function ye(e, o, a = {}) {
|
|
65
|
+
const { userType: t, next: r = !0 } = a, { pathname: n } = k(), c = _(), u = S(e), i = t && (!u || u.user_type !== t);
|
|
66
|
+
return d(() => {
|
|
67
|
+
i && c({
|
|
68
|
+
pathname: "/login" + {
|
|
69
|
+
teacher: "/teacher",
|
|
70
|
+
student: "/student",
|
|
71
|
+
indy: "/independent"
|
|
72
|
+
}[t],
|
|
73
|
+
search: r ? G({ next: n }).toString() : void 0
|
|
74
|
+
});
|
|
75
|
+
}, [c, i, t, r, n]), i ? /* @__PURE__ */ V(j, {}) : typeof o == "function" ? o(u) : o;
|
|
76
|
+
}
|
|
77
|
+
function Z(e, o = 32, a = "state") {
|
|
78
|
+
const t = K(e, a), r = sessionStorage.getItem(t), [n, c] = J();
|
|
79
|
+
d(() => {
|
|
80
|
+
let i;
|
|
81
|
+
r && r.length === o ? i = r : (i = W(o), sessionStorage.setItem(t, i)), c(i);
|
|
82
|
+
}, [t, r, o]);
|
|
83
|
+
const u = $(() => {
|
|
84
|
+
sessionStorage.removeItem(t), c(void 0);
|
|
85
|
+
}, [t]);
|
|
86
|
+
return [n, u];
|
|
87
|
+
}
|
|
88
|
+
function D(e, o = 128, a = "codeChallenge") {
|
|
89
|
+
const t = K(e, a), r = sessionStorage.getItem(t), [n, c] = J();
|
|
90
|
+
d(() => {
|
|
91
|
+
let i;
|
|
92
|
+
if (r) {
|
|
93
|
+
const s = JSON.parse(r);
|
|
94
|
+
typeof s == "object" && s && "verifier" in s && typeof s.verifier == "string" && s.verifier.length === o && "challenge" in s && typeof s.challenge == "string" && "method" in s && s.method === "S256" && (i = {
|
|
95
|
+
verifier: s.verifier,
|
|
96
|
+
challenge: s.challenge,
|
|
97
|
+
method: s.method
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
i ? c(i) : Q(o).then((s) => {
|
|
101
|
+
sessionStorage.setItem(
|
|
102
|
+
t,
|
|
103
|
+
JSON.stringify(s)
|
|
104
|
+
), c(s);
|
|
105
|
+
}).catch((s) => {
|
|
106
|
+
s && console.error(s);
|
|
107
|
+
});
|
|
108
|
+
}, [t, r, o]);
|
|
109
|
+
const u = $(() => {
|
|
110
|
+
sessionStorage.removeItem(t), c(void 0);
|
|
111
|
+
}, [t]);
|
|
112
|
+
return [n, u];
|
|
113
|
+
}
|
|
114
|
+
function U({
|
|
115
|
+
provider: e,
|
|
116
|
+
authUri: o,
|
|
117
|
+
clientId: a,
|
|
118
|
+
redirectUri: t,
|
|
119
|
+
scope: r,
|
|
120
|
+
responseType: n = "code",
|
|
121
|
+
accessType: c = "offline",
|
|
122
|
+
prompt: u,
|
|
123
|
+
useSessionMetadata: i,
|
|
124
|
+
useLoginMutation: s,
|
|
125
|
+
onCreateSession: C,
|
|
126
|
+
onRetrieveSession: P
|
|
127
|
+
}) {
|
|
128
|
+
const [g, A] = Z(e), [
|
|
129
|
+
{
|
|
130
|
+
verifier: h,
|
|
131
|
+
challenge: I,
|
|
132
|
+
method: x
|
|
133
|
+
} = {},
|
|
134
|
+
O
|
|
135
|
+
] = D(e), [
|
|
136
|
+
M,
|
|
137
|
+
{
|
|
138
|
+
originalArgs: m = {},
|
|
139
|
+
isLoading: N,
|
|
140
|
+
isError: b
|
|
141
|
+
}
|
|
142
|
+
] = s(), v = i(), p = _(), f = q({ code: L.string(), state: L.string() }) || {}, l = k().state || {};
|
|
143
|
+
if (d(() => {
|
|
144
|
+
f.code && f.state && p(".", {
|
|
145
|
+
// Removes the URL containing the search params from the history stack.
|
|
146
|
+
replace: !0,
|
|
147
|
+
// Ensure we don't break the auth flow by navigating to another page.
|
|
148
|
+
next: !1,
|
|
149
|
+
// Store the search params in the page's state instead.
|
|
150
|
+
state: { code: f.code, state: f.state }
|
|
151
|
+
});
|
|
152
|
+
}, [f.code, f.state, p]), d(() => {
|
|
153
|
+
v ? P(v) : (
|
|
154
|
+
// If the state and code verifier have been generated...
|
|
155
|
+
g && h && // ...and the page's state contains a code...
|
|
156
|
+
l.code && // ...and the page's state contains the stored state...
|
|
157
|
+
l.state === g && // ...and the login endpoint was not called with the current values or has
|
|
158
|
+
// not returned an error...
|
|
159
|
+
(m.code !== l.code || m.code_verifier !== h || m.redirect_uri !== t || !b) && // ...and the login endpoint is not currently being called...
|
|
160
|
+
!N && M({
|
|
161
|
+
code: l.code,
|
|
162
|
+
code_verifier: h,
|
|
163
|
+
redirect_uri: t
|
|
164
|
+
}).unwrap().then(C).catch(() => {
|
|
165
|
+
p(".", {
|
|
166
|
+
replace: !0,
|
|
167
|
+
state: {
|
|
168
|
+
notifications: [
|
|
169
|
+
{
|
|
170
|
+
props: {
|
|
171
|
+
error: !0,
|
|
172
|
+
children: "Failed to login. Please try again."
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}).finally(() => {
|
|
179
|
+
A(), O();
|
|
180
|
+
})
|
|
181
|
+
);
|
|
182
|
+
}, [
|
|
183
|
+
p,
|
|
184
|
+
t,
|
|
185
|
+
// State
|
|
186
|
+
g,
|
|
187
|
+
l.state,
|
|
188
|
+
A,
|
|
189
|
+
// Code
|
|
190
|
+
h,
|
|
191
|
+
l.code,
|
|
192
|
+
O,
|
|
193
|
+
// Login
|
|
194
|
+
M,
|
|
195
|
+
N,
|
|
196
|
+
b,
|
|
197
|
+
m.code,
|
|
198
|
+
m.code_verifier,
|
|
199
|
+
m.redirect_uri,
|
|
200
|
+
// Session
|
|
201
|
+
v,
|
|
202
|
+
C,
|
|
203
|
+
P
|
|
204
|
+
]), g && I && x) {
|
|
205
|
+
const y = {
|
|
206
|
+
client_id: a,
|
|
207
|
+
redirect_uri: t,
|
|
208
|
+
scope: r,
|
|
209
|
+
response_type: n,
|
|
210
|
+
access_type: c,
|
|
211
|
+
state: g,
|
|
212
|
+
code_challenge: I,
|
|
213
|
+
code_challenge_method: x
|
|
214
|
+
};
|
|
215
|
+
return u && (y.prompt = u), [
|
|
216
|
+
o + "?" + new URLSearchParams(y).toString(),
|
|
217
|
+
y
|
|
218
|
+
];
|
|
219
|
+
}
|
|
220
|
+
return [];
|
|
221
|
+
}
|
|
222
|
+
const _e = (e) => U(
|
|
223
|
+
// @ts-expect-error value is assignable
|
|
224
|
+
"useSessionMetadata" in e ? e : { ...e, useSessionMetadata: S }
|
|
225
|
+
);
|
|
226
|
+
export {
|
|
227
|
+
ye as a,
|
|
228
|
+
Z as b,
|
|
229
|
+
D as c,
|
|
230
|
+
_e as d,
|
|
231
|
+
_ as e,
|
|
232
|
+
k as f,
|
|
233
|
+
q as g,
|
|
234
|
+
Y as h,
|
|
235
|
+
ve as i,
|
|
236
|
+
S as u
|
|
237
|
+
};
|
|
238
|
+
//# sourceMappingURL=auth-D-8t6wfR.js.map
|