Compare commits

...

10 commits

1848 changed files with 339205 additions and 18 deletions

23
admin_dashboard/client/.gitignore vendored Normal file
View file

@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View file

@ -0,0 +1,70 @@
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\
You may also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

View file

@ -0,0 +1,6 @@
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}

19698
admin_dashboard/client/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,52 @@
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@mui/icons-material": "^5.15.14",
"@mui/material": "^5.15.14",
"@mui/x-data-grid": "^7.1.0",
"@nivo/bar": "^0.85.1",
"@nivo/core": "^0.85.1",
"@nivo/geo": "^0.85.1",
"@nivo/line": "^0.85.1",
"@nivo/pie": "^0.85.1",
"@reduxjs/toolkit": "^2.2.3",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-datepicker": "^4.8.0",
"react-dom": "^18.2.0",
"react-redux": "^9.1.0",
"react-router-dom": "^6.22.3",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="dashboard.png" type="image/x-icon">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app"/>
<title>JTP Dashboard</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

View file

@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View file

@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View file

@ -0,0 +1,51 @@
import { CssBaseline, ThemeProvider } from "@mui/material";
import { createTheme } from "@mui/material/styles";
import { useMemo } from "react";
import { useSelector } from "react-redux";
import { BrowserRouter, Navigate, Route, Routes } from "react-router-dom";
import { themeSettings } from "theme";
import Layout from "pages/layout/Layout";
import Dashboard from "pages/dashboard/Dashboard";
import Products from "pages/products/Products";
import Customers from "pages/customers/Customers";
import Transactions from "pages/transactions/Transactions";
import Geography from "pages/geography/Geography";
import Overview from "pages/overview/Overview";
import Daily from "pages/dailyStat/Daily";
import Monthly from "pages/monthlyStat/Monthly";
import Breakdown from "pages/breakdown/Breakdown";
function App() {
const mode = useSelector((state) => state.global.mode);
const theme = useMemo(() => createTheme(themeSettings(mode)), [mode]);
return (
<div className="app">
<BrowserRouter>
<ThemeProvider theme={theme}>
<CssBaseline />
<Routes>
<Route element = {<Layout/>}>
<Route path="/" element={<Navigate to="/dashboard" replace />} />
<Route path="/dashboard" element={<Dashboard/>} />
<Route path="/products" element={<Products/>} />
<Route path="/customers" element={<Customers/>} />
<Route path="/transactions" element={<Transactions/>} />
<Route path="/geography" element={<Geography/>} />
<Route path="/overview" element={<Overview/>} />
<Route path="/daily" element={<Daily/>}/>
<Route path="/monthly" element={<Monthly/>}/>
<Route path="/breakdown" element={<Breakdown/>}/>
</Route>
</Routes>
</ThemeProvider>
</BrowserRouter>
</div>
);
}
export default App;

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 MiB

View file

@ -0,0 +1,124 @@
import React from 'react'
import { ResponsivePie } from '@nivo/pie'
import { Box, Typography, useTheme } from "@mui/material";
import { useGetSalesQuery } from 'state/api';
const BreakdownChart = ({ isDashboard = false }) => {
const theme = useTheme();
const {data, isLoading} = useGetSalesQuery();
if (!data || isLoading) return "Loading...";
const colors = [
theme.palette.secondary[500],
theme.palette.secondary[300],
theme.palette.secondary[300],
theme.palette.secondary[500],
];
const formattedData = Object.entries(data.salesByCategory).map(
([category, sales], i) => ({
id: category,
label: category,
value: sales,
color: colors[i],
})
);
return (
<Box height={isDashboard ? "400px" : "100%"} width={undefined} minHeight={isDashboard ? "325px" : undefined} minWidth={isDashboard ? "325px" : undefined} position="relative">
<ResponsivePie data={formattedData}
theme={{
axis: {
domain: {
line: {
stroke: theme.palette.secondary[200],
},
},
legend: {
text: {
fill: theme.palette.secondary[200],
},
},
ticks: {
line: {
stroke: theme.palette.secondary[200],
strokeWidth: 1,
},
text: {
fill: theme.palette.secondary[200],
},
},
},
legends: {
text: {
fill: theme.palette.secondary[200],
},
},
tooltip: {
container: {
color: theme.palette.primary.main,
},
},
}}
colors={{ datum: "data.color" }}
margin={
isDashboard
? { top: 40, right: 80, bottom: 100, left: 50 }
: { top: 40, right: 80, bottom: 80, left: 80 }
}
sortByValue={true}
innerRadius={0.45}
activeOuterRadiusOffset={8}
borderWidth={1}
borderColor={{
from: "color",
modifiers: [["darker", 0.2]],
}}
enableArcLinkLabels={!isDashboard}
arcLinkLabelsTextColor={theme.palette.secondary[200]}
arcLinkLabelsThickness={2}
arcLinkLabelsColor={{ from: "color" }}
arcLabelsSkipAngle={10}
arcLabelsTextColor={{
from: "color",
modifiers: [["darker", 2]],
}}
legends={[
{
anchor: "bottom",
direction: "row",
justify: false,
translateX: isDashboard ? 20 : 0,
translateY: isDashboard ? 50 : 56,
itemsSpacing: 0,
itemWidth: 85,
itemHeight: 18,
itemTextColor: "#999",
itemDirection: "left-to-right",
itemOpacity: 1,
symbolSize: 18,
symbolShape: "circle",
effects: [
{
on: "hover",
style: {
itemTextColor: theme.palette.primary[500],
},
},
],
},
]}
/>
<Box position="absolute" top="50%" left="50%" color={theme.palette.secondary[400]} textAlign="center" pointerEvents="none" sx={{transform: isDashboard ? "translate(-75%, -170%)" : "translate(-50%, -100%)",}}>
<Typography variant="h6">
{!isDashboard && "Total:"} ${data.yearlySalesTotal}
</Typography>
</Box>
</Box>
)
}
export default BreakdownChart

View file

@ -0,0 +1,33 @@
import React from 'react'
import { Search } from '@mui/icons-material'
import { IconButton, TextField, InputAdornment } from '@mui/material'
import { GridToolbarDensitySelector, GridToolbarContainer, GridToolbarExport, GridToolbarColumnsButton } from '@mui/x-data-grid'
import FlexBetween from './FlexBetween'
const DataGridCustomToolbar = ({ searchInput, setSearchInput, setSearch}) => {
return (
<GridToolbarContainer>
<FlexBetween width="100%">
<FlexBetween>
<GridToolbarColumnsButton />
<GridToolbarDensitySelector slotProps={{ tooltip: { title: 'Change density' } }}/>
<GridToolbarExport slotProps={{ tooltip: { title: 'Export data' }, }}/>
</FlexBetween>
<TextField label="Search..." sx={{width: "15rem", mt: "1rem"}} onChange={(e) => setSearchInput(e.target.value)} value={searchInput} InputProps={{
endAdornment: (
<InputAdornment position='end'>
<IconButton onClick={() => {
setSearch(searchInput);
setSearchInput("");
}}>
<Search/>
</IconButton>
</InputAdornment>
)
}}/>
</FlexBetween>
</GridToolbarContainer>
)
}
export default DataGridCustomToolbar

View file

@ -0,0 +1,10 @@
const { Box } = require("@mui/material");
const { styled } = require("@mui/system");
const FlexBetween =styled(Box)({
display: "flex",
justifyContent: "space-between",
alignItems: "center"
});
export default FlexBetween;

View file

@ -0,0 +1,20 @@
import { Typography, Box, useTheme } from "@mui/material"
const Header = ({title, subtitle}) => {
const theme = useTheme();
return (
<Box>
<Typography variant="h2" color={theme.palette.secondary[100]} fontWeight="bold" sx={{mb: "5px"}}>
{title}
</Typography>
<Typography variant="h5" color={theme.palette.secondary[300]} >
{subtitle}
</Typography>
</Box>
)
}
export default Header

View file

@ -0,0 +1,67 @@
import React, { useState } from 'react'
import { LightModeOutlined, DarkModeOutlined, Menu as MenuIcon, Search, SettingsOutlined, ArrowDropDownOutlined } from '@mui/icons-material'
import FlexBetween from './FlexBetween'
import { useDispatch } from 'react-redux'
import { setMode } from 'state'
import ProfileImg from "assets/admin.jpg"
import { AppBar, Box, Button, IconButton, InputBase, Menu, MenuItem, Toolbar, useTheme } from '@mui/material'
const Navbar = ({user, sidebarOpen, setSidebarOpen,}) => {
const dispatch = useDispatch();
const theme = useTheme();
const [anchorEl, setAnchorEl] = useState(null);
const isOpen = Boolean(anchorEl);
const handleClick = (ev) => setAnchorEl(ev.currentTarget);
const handleClose = () => setAnchorEl(null)
return (
<AppBar sx={{position: "static", background: "none", boxShadow: "none"}}>
<Toolbar sx={{justifyContent: "space-between"}}>
{/*Left side*/}
<FlexBetween>
<IconButton onClick={() => setSidebarOpen(!sidebarOpen)} >
<MenuIcon/>
</IconButton>
<FlexBetween backgroundColor={theme.palette.background.alt} borderRadius="10px" gap="3rem" p="0.1rem 1rem">
<InputBase placeholder='Search...'/>
<IconButton>
<Search/>
</IconButton>
</FlexBetween>
</FlexBetween>
{/*Right side*/}
<FlexBetween gap="1rem">
<IconButton onClick={() => dispatch(setMode())}>
{theme.palette.mode === 'dark' ? (
<DarkModeOutlined sx={{fontSize: "25px"}}/>
) : (
<LightModeOutlined sx={{fontSize: "25px"}}/>
)}
</IconButton>
<IconButton>
<SettingsOutlined sx={{fontSize: "25px"}}/>
</IconButton>
<FlexBetween>
<Button onClick={handleClick} sx={{display: "flex", justifyContent: "space-between", alignItems: "center", textTransform: "none", gap: "0.5rem"}}>
<Box component="img" alt="profile" src={ProfileImg} height="35px" width="35px" borderRadius="50%" sx={{objectFit: "cover"}}/>
{/*<Box textAlign="left">
<Typography fontWeight="bold" fontSize="0.8rem" sx={{color: theme.palette.secondary[100]}}>
{user.name}
</Typography>
</Box>*/}
<ArrowDropDownOutlined sx={{color: theme.palette.secondary[300], fontSize: "25px"}}/>
</Button>
<Menu anchorEl={anchorEl} open={isOpen} onClose={handleClose} anchorOrigin={{ vertical: "bottom", horizontal: "center"}}>
<MenuItem onClick={handleClose}>Log Out</MenuItem>
</Menu>
</FlexBetween>
</FlexBetween>
</Toolbar>
</AppBar>
)
}
export default Navbar

View file

@ -0,0 +1,157 @@
import React, { useMemo } from 'react'
import {ResponsiveLine} from "@nivo/line"
import { useTheme } from '@emotion/react'
import { useGetSalesQuery } from 'state/api';
const OverviewChart = ({ isDashboard = false, view }) => {
const theme = useTheme();
const {data, isLoading} = useGetSalesQuery();
const [totalSalesLine, totalUnitsLine] = useMemo(() => {
if(!data) return [];
const { monthlyData } = data;
const totalSalesLine = {
id: "totalSales",
color: theme.palette.secondary.main,
data: [],
};
const totalUnitsLine = {
id: "totalUnits",
color: theme.palette.secondary[600],
data: [],
};
Object.values(monthlyData).reduce(
(acc, {month, totalSales, totalUnits}) => {
const curSales = acc.sales + totalSales;
const curUnits = acc.units + totalUnits;
totalSalesLine.data = [...totalSalesLine.data, { x: month, y: curSales },];
totalUnitsLine.data = [...totalUnitsLine.data, { x: month, y: curUnits },];
return {sales: curSales, units: curUnits};
},
{sales: 0, units: 0}
);
return [[totalSalesLine], [totalUnitsLine]];
}, [data]);
if (!data || isLoading) return "Loading...";
return (
<ResponsiveLine data={view === "sales" ? totalSalesLine : totalUnitsLine}
theme={{
axis: {
domain: {
line: {
stroke: theme.palette.secondary[200],
},
},
legend: {
text: {
fill: theme.palette.secondary[200],
},
},
ticks: {
line: {
stroke: theme.palette.secondary[200],
strokeWidth: 1,
},
text: {
fill: theme.palette.secondary[200],
},
},
},
legends: {
text: {
fill: theme.palette.secondary[200],
},
},
tooltip: {
container: {
color: theme.palette.primary.main,
},
},
}}
margin={{ top: 20, right: 50, bottom: 50, left: 70 }}
xScale={{ type: "point" }}
yScale={{
type: "linear",
min: "auto",
max: "auto",
stacked: false,
reverse: false,
}}
yFormat=" >-.2f"
curve="catmullRom"
enableArea={isDashboard}
axisTop={null}
axisRight={null}
axisBottom={{
format: (v) => {
if (isDashboard) return v.slice(0, 3);
return v;
},
orient: "bottom",
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
legend: isDashboard ? "" : "Month",
legendOffset: 36,
legendPosition: "middle",
}}
axisLeft={{
orient: "left",
tickValues: 5,
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
legend: isDashboard
? ""
: `Total ${view === "sales" ? "Revenue" : "Units"} for Year`,
legendOffset: -60,
legendPosition: "middle",
}}
enableGridX={true}
enableGridY={true}
pointSize={10}
pointColor={{ theme: "background" }}
pointBorderWidth={2}
pointBorderColor={{ from: "serieColor" }}
pointLabelYOffset={-12}
useMesh={true}
legends={
!isDashboard
? [
{
anchor: "bottom-right",
direction: "column",
justify: false,
translateX: 30,
translateY: -40,
itemsSpacing: 0,
itemDirection: "left-to-right",
itemWidth: 80,
itemHeight: 20,
itemOpacity: 0.75,
symbolSize: 12,
symbolShape: "circle",
symbolBorderColor: "rgba(0, 0, 0, .5)",
effects: [
{
on: "hover",
style: {
itemBackground: "rgba(0, 0, 0, .03)",
itemOpacity: 1,
},
},
],
},
]
: undefined
}
/>
)
}
export default OverviewChart

View file

@ -0,0 +1,150 @@
import React from 'react'
import { Box, Divider, Drawer, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText, Typography, useTheme } from '@mui/material'
import { SettingsOutlined, ChevronLeft, ChevronRightOutlined, HomeOutlined, Groups2Outlined, ReceiptLongOutlined, PublicOutlined,
TodayOutlined, CalendarMonthOutlined, PieChartOutlined } from '@mui/icons-material'
import CategoryOutlinedIcon from '@mui/icons-material/CategoryOutlined';
import PlagiarismOutlinedIcon from '@mui/icons-material/PlagiarismOutlined';
import { useLocation, useNavigate } from 'react-router-dom'
import { useEffect, useState } from 'react'
import FlexBetween from './FlexBetween'
import ProfileImg from 'assets/admin.jpg'
const navItems = [
{
text: "Dashboard",
icon: <HomeOutlined />
},
{
text: "Client Facing",
icon: null,
},
{
text: "Products",
icon: <CategoryOutlinedIcon />
},
{
text: "Customers",
icon: <Groups2Outlined />
},
{
text: "Transactions",
icon: <ReceiptLongOutlined />
},
{
text: "Geography",
icon: <PublicOutlined />
},
{
text: "Sales",
icon: null,
},
{
text: "Overview",
icon: <PlagiarismOutlinedIcon />
},
{
text: "Daily",
icon: <TodayOutlined />
},
{
text: "Monthly",
icon: <CalendarMonthOutlined />
},
{
text: "Breakdown",
icon: <PieChartOutlined />
},
]
const Sidebar = ({user, drawerWidth, sidebarOpen, setSidebarOpen, nonMobile,}) => {
const {pathname} = useLocation();
const [active, setActive] = useState("");
const navigate = useNavigate();
const theme = useTheme();
useEffect(() => {
setActive(pathname.substring(1));
}, [pathname])
return (
<Box component="nav">
{sidebarOpen && (
<Drawer open={sidebarOpen} onClose={() => setSidebarOpen(false)} variant="persistent" anchor="left"
sx={{width: drawerWidth, "& .MuiDrawer-paper" : {
color: theme.palette.secondary[200],
backgroundColor: theme.palette.background.alt,
boxSizing: "border-box",
borderWidth: nonMobile ? 0 : "2px",
width: drawerWidth
}}}>
<Box width="100%">
<Box m="1.5rem 2rem 2rem 3rem">
<FlexBetween color={theme.palette.secondary.main}>
<Box display="flex" alignItems="center" gap="0.5rem">
<Typography variant='h5' fontWeight="bold">
Analytics Dashboard
</Typography>
</Box>
{!nonMobile && (
<IconButton onClick={() => setSidebarOpen(!sidebarOpen)}>
<ChevronLeft />
</IconButton>
)}
</FlexBetween>
</Box>
<List>
{navItems.map(({text, icon}) => {
if(!icon){
return(
<Typography key={text} sx={{m:"2.25rem 0 1rem 3rem"}}>
{text}
</Typography>
)
}
const lowerCaseText = text.toLowerCase();
return(
<ListItem key={text} disablePadding>
<ListItemButton onClick={() => {
navigate(`/${lowerCaseText}`);
setActive(lowerCaseText);}}
sx={{
backgroundColor: active === lowerCaseText ? theme.palette.secondary[300] : "transparent",
color: active === lowerCaseText ? theme.palette.primary[500] : theme.palette.secondary[100],}}>
<ListItemIcon sx={{ml: "2rem", color: active === lowerCaseText ? theme.palette.primary[500] : theme.palette.secondary[200],}}>
{icon}
</ListItemIcon>
<ListItemText primary={text} />
{active === lowerCaseText && (
<ChevronRightOutlined sx={{ml: "auto"}} />
)}
</ListItemButton>
</ListItem>
);
})}
</List>
</Box>
<Box position="absolute" bottom="2rem">
<Divider />
<FlexBetween textTransform="none" gap="0.8rem" m="1.5rem 2rem 0 2rem">
<Box component="img" alt="profile" src={ProfileImg} height="35px" width="35px" borderRadius="50%" sx={{objectFit: "cover"}} />
<Box textAlign="left">
<Typography fontWeight="bold" fontSize="1rem" sx={{color: theme.palette.secondary[100]}}>
{user.name}
</Typography>
<Typography fontSize="0.7rem" sx={{color: theme.palette.secondary[200]}}>
{user.occupation}
</Typography>
</Box>
<SettingsOutlined sx={{color: theme.palette.secondary[300], fontSize: '25px'}}/>
</FlexBetween>
</Box>
</Drawer>
)}
</Box>
)
}
export default Sidebar

View file

@ -0,0 +1,24 @@
import React from 'react'
import { Box, Typography, useTheme } from "@mui/material";
import FlexBetween from "./FlexBetween";
const StatBox = ({ title, value, increase, icon, description }) => {
const theme = useTheme();
return (
<Box gridColumn="span 2" gridRow="span 1" display="flex" flexDirection="column" justifyContent="space-between" p="1.25rem 1rem" flex="1 1 100%" backgroundColor={theme.palette.background.alt} borderRadius="0.55rem">
<FlexBetween>
<Typography variant="h6" sx={{ color: theme.palette.secondary[100] }}>{title}</Typography>{icon}
</FlexBetween>
<Typography variant="h3" fontWeight="600" sx={{ color: theme.palette.secondary[200] }}>{value}</Typography>
<FlexBetween gap="1rem">
<Typography variant="h5" fontStyle="italic" sx={{ color: theme.palette.secondary.light }}>{increase}</Typography>
<Typography>{description}</Typography>
</FlexBetween>
</Box>
)
}
export default StatBox

View file

@ -0,0 +1,6 @@
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap');
html, body, #root, .app{
height: 100%;
width: 100%;
font-family: "Lora", serif;
}

View file

@ -0,0 +1,32 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import { configureStore } from '@reduxjs/toolkit';
import globalReducer from "state"
import { Provider } from 'react-redux';
import { setupListeners } from '@reduxjs/toolkit/query';
import { api } from "state/api";
const store = configureStore({
reducer: {
global: globalReducer,
[api.reducerPath]: api.reducer,
},
middleware: (getDefault) => getDefault().concat(api.middleware)
});
setupListeners(store.dispatch);
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<Provider store={store}>
<App />
</Provider>
</React.StrictMode>
);

View file

@ -0,0 +1,17 @@
import { Box } from '@mui/material'
import BreakdownChart from 'components/BreakdownChart'
import Header from 'components/Header'
import React from 'react'
const Breakdown = () => {
return (
<Box m="1.5rem 2.5rem">
<Header title="Breakdown" subtitle="Breakdown of Sales By Category"/>
<Box mt="40px" height="75vh">
<BreakdownChart />
</Box>
</Box>
)
}
export default Breakdown

View file

@ -0,0 +1,62 @@
import React from 'react'
import { Box } from '@mui/material'
import { DataGrid } from '@mui/x-data-grid'
import { useGetCustomersQuery } from 'state/api'
import Header from 'components/Header'
const Customers = () => {
const {data, isLoading} = useGetCustomersQuery();
const columns = [
{
field: "_id",
headerName: "ID",
flex: 1,
},
{
field: "name",
headerName: "Name",
flex: 0.5,
},
{
field: "email",
headerName: "Email",
flex: 1,
},
{
field: "phoneNumber",
headerName: "Phone Number",
flex: 0.5,
renderCell: (params) => {
return params.value.replace(/^(\d{3})(\d{3})(\d{4})/, "($1)$2-$3");
},
},
{
field: "country",
headerName: "Country",
flex: 0.4,
},
{
field: "occupation",
headerName: "Occupation",
flex: 1,
},
{
field: "role",
headerName: "Role",
flex: 0.5,
},
]
return (
<Box m="1.5rem 2.5rem">
<Header title="Customers" subtitle="List of customers"/>
<Box mt="40px" height="75vh" >
<DataGrid loading={isLoading || !data} getRowId={(row) => row._id} rows={data || []} columns={columns}/>
</Box>
</Box>
)
}
export default Customers

View file

@ -0,0 +1,176 @@
import { Box, useTheme } from '@mui/material'
import Header from 'components/Header'
import React, { useState, useMemo } from 'react'
import { useGetSalesQuery } from 'state/api';
import DatePicker from 'react-datepicker';
import "react-datepicker/dist/react-datepicker.css";
import { ResponsiveLine } from '@nivo/line';
const Daily = () => {
const [startDate, setStartDate] = useState(new Date("2021-02-01"));
const [endDate, setEndDate] = useState(new Date("2021-03-01"));
const { data } = useGetSalesQuery();
const theme = useTheme();
const [formattedData] = useMemo(() => {
if (!data) return [];
const { dailyData } = data;
const totalSalesLine = {
id: "totalSales",
color: theme.palette.secondary.main,
data: [],
};
const totalUnitsLine = {
id: "totalUnits",
color: theme.palette.secondary[600],
data: [],
};
Object.values(dailyData).forEach(({ date, totalSales, totalUnits }) => {
const dateFormatted = new Date(date);
if (dateFormatted >= startDate && dateFormatted <= endDate) {
const splitDate = date.substring(date.indexOf("-") + 1);
totalSalesLine.data = [
...totalSalesLine.data,
{ x: splitDate, y: totalSales },
];
totalUnitsLine.data = [
...totalUnitsLine.data,
{ x: splitDate, y: totalUnits },
];
}
});
const formattedData = [totalSalesLine, totalUnitsLine];
return [formattedData];
}, [data, startDate, endDate]);
return (
<Box m="1.5rem 2.5rem">
<Header title="Daily sales" subtitle="Chart of daily sales"/>
<Box height="75vh">
<Box display="flex" justifyContent="flex-end">
<Box>
<DatePicker selected={startDate} onChange={(date) => setStartDate(date)} selectsStart startDate={startDate} endDate={endDate} />
</Box>
<Box>
<DatePicker selected={endDate} onChange={(date) => setEndDate(date)} selectsEnd startDate={startDate} endDate={endDate} minDate={startDate} />
</Box>
</Box>
{data ? (
<ResponsiveLine data={formattedData}
theme={{
axis: {
domain: {
line: {
stroke: theme.palette.secondary[200],
},
},
legend: {
text: {
fill: theme.palette.secondary[200],
},
},
ticks: {
line: {
stroke: theme.palette.secondary[200],
strokeWidth: 1,
},
text: {
fill: theme.palette.secondary[200],
},
},
},
legends: {
text: {
fill: theme.palette.secondary[200],
},
},
tooltip: {
container: {
color: theme.palette.primary.main,
},
},
}}
colors={{ datum: "color" }}
margin={{ top: 50, right: 50, bottom: 70, left: 60 }}
xScale={{ type: "point" }}
yScale={{
type: "linear",
min: "auto",
max: "auto",
stacked: false,
reverse: false,
}}
yFormat=" >-.2f"
curve="catmullRom"
axisTop={null}
axisRight={null}
axisBottom={{
orient: "bottom",
tickSize: 5,
tickPadding: 5,
tickRotation: 90,
legend: "Month",
legendOffset: 60,
legendPosition: "middle",
}}
axisLeft={{
orient: "left",
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
legend: "Total",
legendOffset: -50,
legendPosition: "middle",
}}
enableGridX={false}
enableGridY={false}
pointSize={10}
pointColor={{ theme: "background" }}
pointBorderWidth={2}
pointBorderColor={{ from: "serieColor" }}
pointLabelYOffset={-12}
useMesh={true}
legends={[
{
anchor: "top-right",
direction: "column",
justify: false,
translateX: 50,
translateY: 0,
itemsSpacing: 0,
itemDirection: "left-to-right",
itemWidth: 80,
itemHeight: 20,
itemOpacity: 0.75,
symbolSize: 12,
symbolShape: "circle",
symbolBorderColor: "rgba(0, 0, 0, .5)",
effects: [
{
on: "hover",
style: {
itemBackground: "rgba(0, 0, 0, .03)",
itemOpacity: 1,
},
},
],
},
]}
/>
) : (
<>Loading...</>
)}
</Box>
</Box>
)
}
export default Daily

View file

@ -0,0 +1,96 @@
import { Box, Button, Typography, useTheme, useMediaQuery, } from '@mui/material'
import FlexBetween from 'components/FlexBetween'
import Header from 'components/Header'
import React from 'react'
import { DownloadOutlined, Email, PointOfSale, PersonAdd, Traffic } from "@mui/icons-material";
import { DataGrid } from '@mui/x-data-grid';
import BreakdownChart from 'components/BreakdownChart';
import OverviewChart from 'components/OverviewChart';
import { useGetDashboardQuery } from 'state/api';
import StatBox from 'components/StatBox';
const Dashboard = () => {
const theme = useTheme();
const isNonMediumScreens = useMediaQuery("(min-width: 1200px)");
const { data, isLoading } = useGetDashboardQuery();
console.log(data)
const columns = [
{
field: "_id",
headerName: "ID",
flex: 1,
},
{
field: "userId",
headerName: "User ID",
flex: 1,
},
{
field: "createdAt",
headerName: "CreatedAt",
flex: 1,
},
{
field: "products",
headerName: "# of Products",
flex: 0.5,
sortable: false,
renderCell: (params) => params.value.length,
},
{
field: "cost",
headerName: "Cost",
flex: 1,
renderCell: (params) => `$${Number(params.value).toFixed(2)}`,
},
];
return (
<Box m="1.5rem 2.5rem">
<FlexBetween>
<Header title="Dashboard"/>
<Box>
<Button sx={{ backgroundColor: theme.palette.secondary.light, color: theme.palette.background.alt, fontSize: "14px", fontWeight: "bold", padding: "10px 20px", }}>
<DownloadOutlined sx={{ mr: "10px" }} /> Download Reports
</Button>
</Box>
</FlexBetween>
<Box mt="20px" display="grid" gridTemplateColumns="repeat(12, 1fr)" gridAutoRows="160px" gap="20px" sx={{"& > div": { gridColumn: isNonMediumScreens ? undefined : "span 12" }}}>
<StatBox title="Total Customers" value={data && data.totalCustomers} increase="+14%" description="Since last month"
icon={<Email sx={{ color: theme.palette.secondary[300], fontSize: "26px" }}/>}/>
<StatBox title="Sales Today" value={data && data.todayStats.totalSales} increase="+21%" description="Since last month"
icon={<PointOfSale sx={{ color: theme.palette.secondary[300], fontSize: "26px" }}/>}/>
<Box gridColumn="span 8" gridRow="span 2" backgroundColor={theme.palette.background.alt} p="1rem" borderRadius="0.55rem">
<OverviewChart view="sales" isDashboard={true} />
</Box>
<StatBox title="Monthly Sales" value={data && data.thisMonthStats.totalSales} increase="+5%" description="Since last month"
icon={<PersonAdd sx={{ color: theme.palette.secondary[300], fontSize: "26px" }}/>}/>
<StatBox title="Yearly Sales" value={data && data.yearlySalesTotal} increase="+43%" description="Since last month"
icon={<Traffic sx={{ color: theme.palette.secondary[300], fontSize: "26px" }}/>}/>
<Box gridColumn="span 8" gridRow="span 3" sx={{"& .MuiDataGrid-root": {border: "none", borderRadius: "5rem",},
"& .MuiDataGrid-cell": {borderBottom: "none",},
"& .MuiDataGrid-columnHeaders": {backgroundColor: theme.palette.background.alt, color: theme.palette.secondary[100], borderBottom: "none",},
"& .MuiDataGrid-virtualScroller": {backgroundColor: theme.palette.background.alt,},
"& .MuiDataGrid-footerContainer": {backgroundColor: theme.palette.background.alt, color: theme.palette.secondary[100], borderTop: "none",},
"& .MuiDataGrid-toolbarContainer .MuiButton-text": {color: `${theme.palette.secondary[200]} !important`,},}}>
<DataGrid loading={isLoading || !data} getRowId={(row) => row._id} rows={(data && data.transactions) || []} columns={columns}/>
</Box>
<Box gridColumn="span 4" gridRow="span 3" backgroundColor={theme.palette.background.alt} p="1.5rem" borderRadius="0.55rem">
<Typography variant="h6" sx={{ color: theme.palette.secondary[100] }}> Sales By Category</Typography>
<BreakdownChart isDashboard={true} />
<Typography p="0 0.6rem" fontSize="0.8rem" sx={{ color: theme.palette.secondary[200] }}>
Breakdown of real states and information via category for revenue made for this year and total sales.
</Typography>
</Box>
</Box>
</Box>
)
}
export default Dashboard

View file

@ -0,0 +1,88 @@
import { Box, useTheme } from '@mui/material'
import Header from 'components/Header'
import { useGetGeographyQuery } from 'state/api'
import { ResponsiveChoropleth } from '@nivo/geo'
import { geographyData } from 'state/geographyData'
const Geography = () => {
const theme = useTheme();
const {data} = useGetGeographyQuery();
return (
<Box m="1.5rem 2.5rem">
<Header title="Geography" subtitle="Find your user location "/>
<Box mt="40px" height="75vh" border={`1px solid ${theme.palette.secondary[200]}`} borderRadius="4px">
{data? (
<ResponsiveChoropleth data={data}
theme={{
axis: {
domain: {
line: {
stroke: theme.palette.secondary[200],
},
},
legend: {
text: {
fill: theme.palette.secondary[200],
},
},
ticks: {
line: {
stroke: theme.palette.secondary[200],
strokeWidth: 1,
},
text: {
fill: theme.palette.secondary[200],
},
},
},
legends: {
text: {
fill: theme.palette.secondary[200],
},
},
tooltip: {
container: {
color: theme.palette.primary.main,
},
},
}}
features={geographyData.features}
margin={{ top: 0, right: 0, bottom: 0, left: -50 }}
colors="YlGnBu"
domain={[0, 60]}
unknownColor="#666666"
label="properties.name"
valueFormat=".2s"
projectionScale={150}
projectionTranslation={[0.45, 0.6]}
projectionRotation={[0, 0, 0]}
borderWidth={1.3}
borderColor="#ADBC9F"
legends={[
{
anchor: "bottom-right",
direction: "column",
justify: true,
translateX: 0,
translateY: -125,
itemsSpacing: 0,
itemWidth: 94,
itemHeight: 18,
itemDirection: "left-to-right",
itemTextColor: theme.palette.secondary[200],
itemOpacity: 0.85,
symbolSize: 18,
},
]}/>
) : (
<>Loading...</>
)}
</Box>
</Box>
)
}
export default Geography

View file

@ -0,0 +1,30 @@
import React, { useState } from 'react'
import { Outlet } from 'react-router-dom'
import { Box, useMediaQuery } from '@mui/material'
import { useSelector } from 'react-redux'
import Navbar from 'components/Navbar'
import Sidebar from 'components/Sidebar'
import { useGetUserQuery } from 'state/api'
const Layout = () => {
const nonMobile = useMediaQuery("(min-width: 600px)");
const [sidebarOpen, setSidebarOpen] = useState(true);
const userId = useSelector((state) => state.global.userId);
const { data } = useGetUserQuery(userId);
return (
<Box display={nonMobile ? "flex" : "block"} width="100%" height="100%">
<Sidebar user={data || {}} nonMobile = {nonMobile} drawerWidth = "250px" sidebarOpen={sidebarOpen} setSidebarOpen={setSidebarOpen} />
<Box flexGrow={1}>
<Navbar user={data || {}} sidebarOpen={sidebarOpen} setSidebarOpen={setSidebarOpen}/>
<Outlet />
</Box>
</Box>
)
}
export default Layout

View file

@ -0,0 +1,157 @@
import { useTheme } from '@emotion/react'
import { Box } from '@mui/material'
import { ResponsiveLine } from '@nivo/line'
import Header from 'components/Header'
import React, { useMemo } from 'react'
import { useGetSalesQuery } from 'state/api'
const Monthly = () => {
const theme = useTheme();
const {data} = useGetSalesQuery();
const [formattedData] = useMemo(() => {
if (!data) return [];
const {monthlyData} = data;
const totalSalesLine = {
id: "totalSales",
color: theme.palette.secondary.main,
data: [],
};
const totalUnitsLine = {
id: "totalUnits",
color: theme.palette.secondary[600],
data: [],
};
Object.values(monthlyData).forEach(({ month, totalSales, totalUnits }) => {
totalSalesLine.data = [
...totalSalesLine.data,
{ x: month, y: totalSales },
];
totalUnitsLine.data = [
...totalUnitsLine.data,
{ x: month, y: totalUnits },
];
});
const formattedData = [totalSalesLine, totalUnitsLine];
return [formattedData];
}, [data]);
return (
<Box m="1.5rem 2.5rem">
<Header title="Monthly sales" subtitle="Chart of monthly sales"/>
<Box height="75vh">
{data ? (
<ResponsiveLine
data={formattedData}
theme={{
axis: {
domain: {
line: {
stroke: theme.palette.secondary[200],
},
},
legend: {
text: {
fill: theme.palette.secondary[200],
},
},
ticks: {
line: {
stroke: theme.palette.secondary[200],
strokeWidth: 1,
},
text: {
fill: theme.palette.secondary[200],
},
},
},
legends: {
text: {
fill: theme.palette.secondary[200],
},
},
tooltip: {
container: {
color: theme.palette.primary.main,
},
},
}}
colors={{ datum: "color" }}
margin={{ top: 50, right: 50, bottom: 70, left: 60 }}
xScale={{ type: "point" }}
yScale={{
type: "linear",
min: "auto",
max: "auto",
stacked: false,
reverse: false,
}}
yFormat=" >-.2f"
curve="catmullRom"
axisTop={null}
axisRight={null}
axisBottom={{
orient: "bottom",
tickSize: 5,
tickPadding: 5,
tickRotation: 90,
legend: "Month",
legendOffset: 60,
legendPosition: "middle",
}}
axisLeft={{
orient: "left",
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
legend: "Total",
legendOffset: -50,
legendPosition: "middle",
}}
enableGridX={false}
enableGridY={false}
pointSize={10}
pointColor={{ theme: "background" }}
pointBorderWidth={2}
pointBorderColor={{ from: "serieColor" }}
pointLabelYOffset={-12}
useMesh={true}
legends={[
{
anchor: "top-right",
direction: "column",
justify: false,
translateX: 50,
translateY: 0,
itemsSpacing: 0,
itemDirection: "left-to-right",
itemWidth: 80,
itemHeight: 20,
itemOpacity: 0.75,
symbolSize: 12,
symbolShape: "circle",
symbolBorderColor: "rgba(0, 0, 0, .5)",
effects: [
{
on: "hover",
style: {
itemBackground: "rgba(0, 0, 0, .03)",
itemOpacity: 1,
},
},
],
},
]}
/>
) : (
<>Loading...</>
)}
</Box>
</Box>
)
}
export default Monthly

View file

@ -0,0 +1,27 @@
import { Box, FormControl, InputLabel, MenuItem, Select } from '@mui/material'
import Header from 'components/Header'
import OverviewChart from 'components/OverviewChart';
import React, { useState } from 'react'
const Overview = () => {
const [view, setView] = useState("units");
return (
<Box m="1.5rem 2.5rem">
<Header title="Overview" subtitle="Overview of general revenue and profit"/>
<Box height="75vh" mt="2rem">
<FormControl>
<InputLabel>View</InputLabel>
<Select label="View" value={view} onChange={(e) => setView(e.target.value)}>
<MenuItem value="sales">Sales</MenuItem>
<MenuItem value="units">Unit</MenuItem>
</Select>
</FormControl>
<OverviewChart view={view}/>
</Box>
</Box>
)
}
export default Overview

View file

@ -0,0 +1,65 @@
import React, {useState} from 'react'
import { Box, Card, CardActions, CardContent, Collapse, Button, Typography, Rating, useTheme, useMediaQuery } from '@mui/material'
import { useGetProductsQuery } from 'state/api'
import Header from "components/Header"
const Product = ({ _id, name, description, price, rating, category, supply, stat}) => {
const theme =useTheme();
const [isexpanded, setIsExpanded] = useState(false);
return(
<Card sx={{backgroundImage: "none", backgroundColor: theme.palette.background.alt, borderRadius: "0.5rem"}}>
<CardContent>
<Typography sx={{fontSize: "14px"}} color={theme.palette.secondary[300]} gutterBottom>
{category}
</Typography>
<Typography variant='h5' component="div">
{name}
</Typography>
<Typography sx={{mb: "1.5rem"}} color={theme.palette.secondary[400]}>
${Number(price).toFixed(2)}
</Typography>
<Rating value={rating} readOnly/>
<Typography variant='body2'>
{description}
</Typography>
</CardContent>
<CardActions>
<Button onClick={() => setIsExpanded(!isexpanded)} variant='prinary' size='small'>More</Button>
</CardActions>
<Collapse in={isexpanded} timeout="auto" unmountOnExit sx={{color: theme.palette.neutral[300]}}>
<CardContent>
<Typography>id: {_id}</Typography>
<Typography>Supply left: {supply}</Typography>
<Typography>Yealy sales This year: {stat.yaerlySalesTotal}</Typography>
<Typography>Yearly units sold this year:{stat.yaerlyTotalSoldUnit}</Typography>
</CardContent>
</Collapse>
</Card>
)
}
const Products = () => {
const {data, isloading} = useGetProductsQuery();
const nonMobile = useMediaQuery("(min-width: 800px)");
return (
<Box m="1.5rem 2.5rem">
<Header title="Products" subtitle="List of products"/>
{data || isloading ? (
<Box mt="20px" display="grid" gridTemplateColumns="repeat(4, minmax(0, 1fr))" justifyContent="space-between" rowGap="20px" columnGap="1.5%" sx={{"& > div" : {gridColumn: nonMobile ? undefined : "span 4"}}}>
{data.map(({_id, name, description, price, rating, category, supply, stat}) => (
<Product key={_id} _id={_id} name={name} description={description} price={price} rating={rating} category={category} supply={supply} stat={stat}/>
))}
</Box>
) : <>Loading...</>}
</Box>
)
}
export default Products

View file

@ -0,0 +1,79 @@
import React, {useState} from 'react'
import Header from 'components/Header'
import { Box } from '@mui/material'
import { DataGrid } from '@mui/x-data-grid'
import { useGetTransactionsQuery } from 'state/api'
import DataGridCustomToolbar from "components/DataGridCustomToolbar"
const Transactions = () => {
const [page, setPage] = useState(0);
const [pageSize, setPageSize] = useState(25);
const [sort, setSort] = useState({});
const [search, setSearch] = useState("");
const [searchInput, setSearchInput] = useState("");
const {data, isLoading} = useGetTransactionsQuery({
page, pageSize, sort: JSON.stringify(sort), search,
});
console.log(data)
const columns = [
{
field: "_id",
headerName: "ID",
flex: 1,
},
{
field: "userId",
headerName: "User ID",
flex: 1,
},
{
field: "createdAt",
headerName: "CreatedAt",
flex: 1,
},
{
field: "products",
headerName: "Number of Products",
flex: 0.5,
sortable: false,
renderCell: (params) => params.value.length
},
{
field: "cost",
headerName: "Cost",
flex: 1,
renderCell: (params) => `$${Number(params.value).toFixed(2)}`
},
];
return (
<Box m="1.5rem 2.5rem">
<Header title="Transactions" subtitle="List of transactions"/>
<Box height="80vh">
<DataGrid
loading={isLoading || !data}
getRowId={(row) => row._id}
rows={(data && data.transactions) || []}
columns={columns}
rowCount={(data && data.total) || 0}
pagination
page={page}
pageSize={pageSize}
paginationMode="server"
sortingMode="server"
onPageChange={(newPage) => setPage(newPage)}
onPageSizeChange={(newPageSize) => setPageSize(newPageSize)}
onSortModelChange={(newSortModel) => setSort(...newSortModel)}
rowsPerPageOptions={[25, 50, 100]}
slots={{toolbar: DataGridCustomToolbar}}
slotProps={{
toolbar: { searchInput, setSearchInput, setSearch}
}}
/>
</Box>
</Box>
)
}
export default Transactions

View file

@ -0,0 +1,43 @@
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"
export const api = createApi({
baseQuery: fetchBaseQuery({baseUrl: process.env.REACT_APP_BASE_URL}),
reducerPath: "adminApi",
tagTypes: ["User", "Products", "Customers", "Transactions", "Geography", "Sales", "Dashboard" ],
endpoints: (build) => ({
getUser: build.query({
query: (id) => `general/user/${id}`,
providesTags: ["User"]
}),
getProducts: build.query({
query: () => "client/products",
providesTags: ["Products"],
}),
getCustomers: build.query({
query: () => "client/customers",
providesTags: ["Customers"],
}),
getTransactions: build.query({
query: ({page, pageSize, sort, search}) => ({
url: "client/transactions",
method: "GET",
params: {page, pageSize, sort, search},
}),
providesTags: ["Transactions"]
}),
getGeography: build.query({
query: () => "client/geography",
providesTags: ["Geography"],
}),
getSales: build.query({
query: () => "sales/sales",
providesTags: ["Sales"]
}),
getDashboard: build.query({
query: () => "general/dashboard",
providesTags: ["Dashboard"]
})
})
})
export const {useGetUserQuery, useGetProductsQuery, useGetCustomersQuery, useGetTransactionsQuery, useGetGeographyQuery, useGetSalesQuery, useGetDashboardQuery} = api;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,19 @@
import { createSlice } from "@reduxjs/toolkit";
const initialState = {
mode: "dark",
userId: "63701cc1f03239b7f700000f", //63701cc1f03239b7f700000e
};
export const globalSlice = createSlice({
name: "global",
initialState,
reducers: {
setMode: (state) => {
state.mode = state.mode === 'light' ? "dark" : "light";
},
},
});
export const {setMode} = globalSlice.actions;
export default globalSlice.reducer;

View file

@ -0,0 +1,135 @@
export const tokensDark = {
grey: {
0: "#ffffff",
10: "#f6f6f6",
50: "#f0f0f0",
100: "#e0e0e0",
200: "#c2c2c2",
300: "#a3a3a3",
400: "#858585",
500: "#666666",
600: "#525252",
700: "#3d3d3d",
800: "#292929",
900: "#141414",
1000: "#000000",
},
primary: { //black
100: "#cecece",
200: "#9e9e9e",
300: "#6d6d6d",
400: "#3d3d3d",
500: "#0c0c0c",
600: "#0a0a0a",
700: "#070707",
800: "#050505",
900: "#020202"
},
secondary: { //green
100: "#e1f6f8",
200: "#c3eef1",
300: "#a6e5eb",
400: "#88dde4",
500: "#6ad4dd",
600: "#55aab1",
700: "#407f85",
800: "#2a5558",
900: "#152a2c"
},
};
function reverseTokens(tokensDark) {
const reversedTokens = {};
Object.entries(tokensDark).forEach(([key, val]) => {
const keys = Object.keys(val);
const values = Object.values(val);
const length = keys.length;
const reversedObj = {};
for (let i = 0; i < length; i++) {
reversedObj[keys[i]] = values[length - i - 1];
}
reversedTokens[key] = reversedObj;
});
return reversedTokens;
}
export const tokensLight = reverseTokens(tokensDark);
// mui theme settings
export const themeSettings = (mode) => {
return {
palette: {
mode: mode,
...(mode === "dark"
? {
// palette values for dark mode
primary: {
...tokensDark.primary,
main: tokensDark.primary[400],
light: tokensDark.primary[400],
},
secondary: {
...tokensDark.secondary,
main: tokensDark.secondary[300],
},
neutral: {
...tokensDark.grey,
main: tokensDark.grey[500],
},
background: {
default: tokensDark.primary[600],
alt: tokensDark.primary[500],
},
}
: {
// palette values for light mode
primary: {
...tokensLight.primary,
main: tokensDark.grey[50],
light: tokensDark.grey[100],
},
secondary: {
...tokensLight.secondary,
main: tokensDark.secondary[600],
light: tokensDark.secondary[700],
},
neutral: {
...tokensLight.grey,
main: tokensDark.grey[500],
},
background: {
default: tokensDark.grey[0],
alt: tokensDark.grey[50],
},
}),
},
typography: {
fontFamily: ["Lora", "serif"].join(","),
fontSize: 12,
h1: {
fontFamily: ["Lora", "serif"].join(","),
fontSize: 40,
},
h2: {
fontFamily: ["Lora", "serif"].join(","),
fontSize: 32,
},
h3: {
fontFamily: ["Lora", "serif"].join(","),
fontSize: 24,
},
h4: {
fontFamily: ["Lora", "serif"].join(","),
fontSize: 20,
},
h5: {
fontFamily: ["Lora", "serif"].join(","),
fontSize: 16,
},
h6: {
fontFamily: ["Lora", "serif"].join(","),
fontSize: 14,
},
},
};
};

2
admin_dashboard/server/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
.env
data

View file

@ -0,0 +1,90 @@
import Product from "../models/Product.js";
import ProductStat from "../models/ProductStat.js";
import Transaction from "../models/Transaction.js";
import User from "../models/User.js"
import getCountryIso3 from "country-iso-2-to-3"
export const getProducts = async(req, res) => {
try {
const products = await Product.find();
const productStats = await Promise.all(
products.map(async(product) => {
const stat = await ProductStat.find({
productId: product._id
})
return{
...product._doc, stat,
}
})
);
res.status(200).json(productStats)
} catch (error) {
res.status(404).json({message: error.message})
}
};
export const getCustomers = async(req, res) => {
try {
const customers = await User.find({role: "user"}).select("-password");
res.status(200).json(customers);
} catch (error) {
res.status(404).json({message: error.message})
}
};
export const getTransactions = async(req, res) => {
try {
const {page = 1, pageSize = 25, sort = null, search = ""} = req.query;
const generateSort = () => {
const sortParsed = JSON.parse(sort);
const sortFormatted = {
[sortParsed.field]: (sortParsed.sort = "asc" ? 1 : -1),
};
return sortFormatted;
};
const sortFormatted = Boolean(sort) ? generateSort() : {};
const transactions = await Transaction.find({
$or: [
{cost: {$regex: new RegExp(search, "i")}},
{userId: {$regex: new RegExp(search, "i")}},
],
})
.sort(sortFormatted).skip(page * pageSize).limit(pageSize);
const total = await Transaction.countDocuments({
name: {$regex: search, $options: "i"},
});
res.status(200).json({transactions, total,});
} catch (error) {
res.status(404).json({message: error.message})
}
};
export const getGeography = async(req, res) => {
try {
const users = await User.find();
const mapLocations = users.reduce((acc, {country}) => {
const countryISO3 = getCountryIso3(country);
if(!acc [countryISO3]){
acc[countryISO3] = 0;
}
acc[countryISO3]++;
return acc;
}, {});
const formattedLocations = Object.entries(mapLocations).map(
([country, count]) => {
return{id: country, value: count}
}
);
res.status(200).json(formattedLocations)
} catch (error) {
res.status(404).json({message: error.message})
}
}

View file

@ -0,0 +1,39 @@
import User from "../models/User.js";
import Stat from "../models/Stat.js"
import Transaction from "../models/Transaction.js"
export const getUser = async(req, res) => {
try {
const { id } = req.params;
const user = await User.findById(id);
res.status(200).json(user);
} catch (error) {
res.status(404).json({message: error.message})
}
};
export const getDashboardStats = async(req, res) => {
try {
const currerntMonth = "November";
const currentYear = 2021;
const currenrtDay = "2021-04-15";
const transactions = await Transaction.find().limit(50).sort({createdOn: -1});
const stat = await Stat.find({year: currentYear});
const {totalCustomers, yearlyTotalSoldUnits, yearlySalesTotal, monthlyData, salesByCategory} = stat[0]
const thisMonthStats = stat[0].monthlyData.find(({month}) => {
return month === currerntMonth;
});
const todayStats = stat[0].dailyData.find(({date}) => {
return date === currenrtDay;
});
res.status(200).json({totalCustomers, yearlyTotalSoldUnits, yearlySalesTotal, monthlyData, salesByCategory, thisMonthStats, todayStats, transactions})
} catch (error) {
res.status(404).json({message: error.message})
}
}

View file

@ -0,0 +1,12 @@
import mongoose from "mongoose"
import User from "../models/User.js"
export const getAdmins = async(req, res) => {
try {
const admins = await User.find({ role: "admin"}).select("-password");
res.status(200).json(admins);
} catch (error) {
res.status(404).json({message: error.message})
}
}

View file

@ -0,0 +1,14 @@
import Stat from "../models/Stat.js"
export const getSales =async(req, res) => {
try {
const stats = await Stat.find();
res.status(200).json(stats[0]);
} catch (error) {
res.status(404).json({message: error.message})
}
}

View file

@ -0,0 +1,56 @@
import express from "express"
import bodyParser from "body-parser"
import mongoose from "mongoose"
import cors from "cors"
import dotenv from "dotenv"
import helmet from "helmet"
import morgan from "morgan"
import clientRoutes from "./routes/client.js"
import generalRoutes from "./routes/general.js"
import managmentRoutes from "./routes/management.js"
import saleRoutes from "./routes/sales.js"
import User from "./models/User.js"
import {dataUser, dataProduct, dataProductStat, dataTransaction, dataOverallStat} from "./data/index.js"
import Product from "./models/Product.js"
import ProductStat from "./models/ProductStat.js"
import Transaction from "./models/Transaction.js"
import Stat from "./models/Stat.js"
//configuration setup
dotenv.config();
const app = express();
app.use(express.json());
app.use(helmet());
app.use(helmet.crossOriginResourcePolicy({policy: "cross-origin"})); //cross origin sharing request
app.use(morgan("common"));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cors());
//routes
app.use("/client", clientRoutes);
app.use("/general", generalRoutes);
app.use("/management", managmentRoutes);
app.use("/sales", saleRoutes);
//mongoose setup
const PORT = process.env.PORT || 9000;
mongoose.connect(process.env.MONGO_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
}).then(() => {
app.listen(PORT, () => console.log(`Server Port: ${PORT}`));
//===** one time add to data base **===//
//Product.insertMany(dataProduct);
//ProductStat.insertMany(dataProductStat);
//User.insertMany(dataUser);
//Transaction.insertMany(dataTransaction);
//Stat.insertMany(dataOverallStat);
}).catch((error) => console.log(`${error} didn't connect`))

View file

@ -0,0 +1,16 @@
import mongoose from "mongoose"
const ProductSchema = new mongoose.Schema(
{
name: String,
price: Number,
description: String,
category: String,
rating: Number,
supply: Number,
},
{timestamps: true}
);
const Product = mongoose.model("Product", ProductSchema);
export default Product;

View file

@ -0,0 +1,26 @@
import mongoose from "mongoose"
const ProductStatSchema = new mongoose.Schema(
{
productId: String,
yearlySaleTotal: Number,
yearlyTotalSoldUnits: Number,
year: Number,
monthlyData: [
{
month: String,
totalSales: Number,
totalUnits: Number,
}
],
dailyData: {
date: String,
totalSales: Number,
totalUnits: Number,
}
},
{timestamps: true}
);
const ProductStat = mongoose.model("ProductStat", ProductStatSchema);
export default ProductStat;

View file

@ -0,0 +1,32 @@
import mongoose from "mongoose"
const StatSchema = new mongoose.Schema(
{
totalCustomers: Number,
yearlySalesTotal: Number,
yearlyTotalSoldUnits: Number,
yaer: Number,
monthlyData: [
{
month: String,
totalSales: Number,
totalUnits: Number,
},
],
dailyData: [
{
date: String,
totalSales: Number,
totalUnits: Number,
},
],
salesByCategory:{
type: Map,
of: Number,
},
},
{timestamps: true}
);
const Stat = mongoose.model("Stat", StatSchema);
export default Stat;

View file

@ -0,0 +1,17 @@
import mongoose from "mongoose"
const TransactionSchema = new mongoose.Schema(
{
userId: String,
cost: String,
products: {
type: [mongoose.Types.ObjectId],
of: Number,
},
},
{timestamps: true}
);
const Transaction = mongoose.model("Transaction", TransactionSchema);
export default Transaction

View file

@ -0,0 +1,38 @@
import mongoose from "mongoose"
const UserSchema = new mongoose.Schema(
{
name: {
type: String,
required: true,
min: 2,
max: 100,
},
email: {
type: String,
required: true,
max: 50,
unique: true,
},
password: {
type: String,
required: true,
min: 5,
},
city: String,
state: String,
country: String,
occupation: String,
phoneNumber: String,
transactions: Array,
role: {
type: String,
enum: ["user", "admin", "superadmin"],
default: "admin"
},
},
{timestamps: true}
);
const User = mongoose.model("User", UserSchema);
export default User;

1
admin_dashboard/server/node_modules/.bin/mime generated vendored Symbolic link
View file

@ -0,0 +1 @@
../mime/cli.js

1
admin_dashboard/server/node_modules/.bin/nodemon generated vendored Symbolic link
View file

@ -0,0 +1 @@
../nodemon/bin/nodemon.js

1
admin_dashboard/server/node_modules/.bin/nodetouch generated vendored Symbolic link
View file

@ -0,0 +1 @@
../touch/bin/nodetouch.js

1
admin_dashboard/server/node_modules/.bin/nopt generated vendored Symbolic link
View file

@ -0,0 +1 @@
../nopt/bin/nopt.js

1
admin_dashboard/server/node_modules/.bin/semver generated vendored Symbolic link
View file

@ -0,0 +1 @@
../semver/bin/semver.js

1335
admin_dashboard/server/node_modules/.package-lock.json generated vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,22 @@
Copyright (c) 2014 Dmitry Tsvettsikh
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,4 @@
import mod from "./node.js";
export default mod;
export const saslprep = mod.saslprep;

View file

@ -0,0 +1,5 @@
declare const saslprep: (args_0: string, args_1?: {
allowUnassigned?: boolean | undefined;
} | undefined) => string;
export = saslprep;
//# sourceMappingURL=browser.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,QAAQ;;wBAAmC,CAAC;AAIlD,SAAS,QAAQ,CAAC"}

View file

@ -0,0 +1,12 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const index_1 = __importDefault(require("./index"));
const memory_code_points_1 = require("./memory-code-points");
const code_points_data_browser_1 = __importDefault(require("./code-points-data-browser"));
const codePoints = (0, memory_code_points_1.createMemoryCodePoints)(code_points_data_browser_1.default);
const saslprep = index_1.default.bind(null, codePoints);
Object.assign(saslprep, { saslprep, default: saslprep });
module.exports = saslprep;
//# sourceMappingURL=browser.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":";;;;AAAA,oDAAgC;AAChC,6DAA8D;AAC9D,0FAA8C;AAE9C,MAAM,UAAU,GAAG,IAAA,2CAAsB,EAAC,kCAAI,CAAC,CAAC;AAEhD,MAAM,QAAQ,GAAG,eAAS,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;AAEzD,iBAAS,QAAQ,CAAC"}

View file

@ -0,0 +1,4 @@
/// <reference types="node" />
declare const data: Buffer;
export default data;
//# sourceMappingURL=code-points-data-browser.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"code-points-data-browser.d.ts","sourceRoot":"","sources":["../src/code-points-data-browser.ts"],"names":[],"mappings":";AAAA,QAAA,MAAM,IAAI,QAGT,CAAC;AACF,eAAe,IAAI,CAAC"}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
{"version":3,"file":"code-points-data-browser.js","sourceRoot":"","sources":["../src/code-points-data-browser.ts"],"names":[],"mappings":";;AAAA,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CACtB,8sliBAA8sliB,EAC9sliB,QAAQ,CACT,CAAC;AACF,kBAAe,IAAI,CAAC"}

View file

@ -0,0 +1,4 @@
/// <reference types="node" />
declare const _default: Buffer;
export default _default;
//# sourceMappingURL=code-points-data.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"code-points-data.d.ts","sourceRoot":"","sources":["../src/code-points-data.ts"],"names":[],"mappings":";;AAEA,wBAKE"}

View file

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const zlib_1 = require("zlib");
exports.default = (0, zlib_1.gunzipSync)(Buffer.from('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', 'base64'));
//# sourceMappingURL=code-points-data.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"code-points-data.js","sourceRoot":"","sources":["../src/code-points-data.ts"],"names":[],"mappings":";;AAAA,+BAAkC;AAElC,kBAAe,IAAA,iBAAU,EACvB,MAAM,CAAC,IAAI,CACT,0nFAA0nF,EAC1nF,QAAQ,CACT,CACF,CAAC"}

View file

@ -0,0 +1,7 @@
export declare const unassigned_code_points: Set<number>;
export declare const commonly_mapped_to_nothing: Set<number>;
export declare const non_ASCII_space_characters: Set<number>;
export declare const prohibited_characters: Set<number>;
export declare const bidirectional_r_al: Set<number>;
export declare const bidirectional_l: Set<number>;
//# sourceMappingURL=code-points-src.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"code-points-src.d.ts","sourceRoot":"","sources":["../src/code-points-src.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,sBAAsB,aA6YjC,CAAC;AAMH,eAAO,MAAM,0BAA0B,aAIrC,CAAC;AAMH,eAAO,MAAM,0BAA0B,aASrC,CAAC;AAMH,eAAO,MAAM,qBAAqB,aA6GhC,CAAC;AAMH,eAAO,MAAM,kBAAkB,aAmC7B,CAAC;AAMH,eAAO,MAAM,eAAe,aAyW1B,CAAC"}

View file

@ -0,0 +1,881 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bidirectional_l = exports.bidirectional_r_al = exports.prohibited_characters = exports.non_ASCII_space_characters = exports.commonly_mapped_to_nothing = exports.unassigned_code_points = void 0;
const util_1 = require("./util");
exports.unassigned_code_points = new Set([
0x0221,
...(0, util_1.range)(0x0234, 0x024f),
...(0, util_1.range)(0x02ae, 0x02af),
...(0, util_1.range)(0x02ef, 0x02ff),
...(0, util_1.range)(0x0350, 0x035f),
...(0, util_1.range)(0x0370, 0x0373),
...(0, util_1.range)(0x0376, 0x0379),
...(0, util_1.range)(0x037b, 0x037d),
...(0, util_1.range)(0x037f, 0x0383),
0x038b,
0x038d,
0x03a2,
0x03cf,
...(0, util_1.range)(0x03f7, 0x03ff),
0x0487,
0x04cf,
...(0, util_1.range)(0x04f6, 0x04f7),
...(0, util_1.range)(0x04fa, 0x04ff),
...(0, util_1.range)(0x0510, 0x0530),
...(0, util_1.range)(0x0557, 0x0558),
0x0560,
0x0588,
...(0, util_1.range)(0x058b, 0x0590),
0x05a2,
0x05ba,
...(0, util_1.range)(0x05c5, 0x05cf),
...(0, util_1.range)(0x05eb, 0x05ef),
...(0, util_1.range)(0x05f5, 0x060b),
...(0, util_1.range)(0x060d, 0x061a),
...(0, util_1.range)(0x061c, 0x061e),
0x0620,
...(0, util_1.range)(0x063b, 0x063f),
...(0, util_1.range)(0x0656, 0x065f),
...(0, util_1.range)(0x06ee, 0x06ef),
0x06ff,
0x070e,
...(0, util_1.range)(0x072d, 0x072f),
...(0, util_1.range)(0x074b, 0x077f),
...(0, util_1.range)(0x07b2, 0x0900),
0x0904,
...(0, util_1.range)(0x093a, 0x093b),
...(0, util_1.range)(0x094e, 0x094f),
...(0, util_1.range)(0x0955, 0x0957),
...(0, util_1.range)(0x0971, 0x0980),
0x0984,
...(0, util_1.range)(0x098d, 0x098e),
...(0, util_1.range)(0x0991, 0x0992),
0x09a9,
0x09b1,
...(0, util_1.range)(0x09b3, 0x09b5),
...(0, util_1.range)(0x09ba, 0x09bb),
0x09bd,
...(0, util_1.range)(0x09c5, 0x09c6),
...(0, util_1.range)(0x09c9, 0x09ca),
...(0, util_1.range)(0x09ce, 0x09d6),
...(0, util_1.range)(0x09d8, 0x09db),
0x09de,
...(0, util_1.range)(0x09e4, 0x09e5),
...(0, util_1.range)(0x09fb, 0x0a01),
...(0, util_1.range)(0x0a03, 0x0a04),
...(0, util_1.range)(0x0a0b, 0x0a0e),
...(0, util_1.range)(0x0a11, 0x0a12),
0x0a29,
0x0a31,
0x0a34,
0x0a37,
...(0, util_1.range)(0x0a3a, 0x0a3b),
0x0a3d,
...(0, util_1.range)(0x0a43, 0x0a46),
...(0, util_1.range)(0x0a49, 0x0a4a),
...(0, util_1.range)(0x0a4e, 0x0a58),
0x0a5d,
...(0, util_1.range)(0x0a5f, 0x0a65),
...(0, util_1.range)(0x0a75, 0x0a80),
0x0a84,
0x0a8c,
0x0a8e,
0x0a92,
0x0aa9,
0x0ab1,
0x0ab4,
...(0, util_1.range)(0x0aba, 0x0abb),
0x0ac6,
0x0aca,
...(0, util_1.range)(0x0ace, 0x0acf),
...(0, util_1.range)(0x0ad1, 0x0adf),
...(0, util_1.range)(0x0ae1, 0x0ae5),
...(0, util_1.range)(0x0af0, 0x0b00),
0x0b04,
...(0, util_1.range)(0x0b0d, 0x0b0e),
...(0, util_1.range)(0x0b11, 0x0b12),
0x0b29,
0x0b31,
...(0, util_1.range)(0x0b34, 0x0b35),
...(0, util_1.range)(0x0b3a, 0x0b3b),
...(0, util_1.range)(0x0b44, 0x0b46),
...(0, util_1.range)(0x0b49, 0x0b4a),
...(0, util_1.range)(0x0b4e, 0x0b55),
...(0, util_1.range)(0x0b58, 0x0b5b),
0x0b5e,
...(0, util_1.range)(0x0b62, 0x0b65),
...(0, util_1.range)(0x0b71, 0x0b81),
0x0b84,
...(0, util_1.range)(0x0b8b, 0x0b8d),
0x0b91,
...(0, util_1.range)(0x0b96, 0x0b98),
0x0b9b,
0x0b9d,
...(0, util_1.range)(0x0ba0, 0x0ba2),
...(0, util_1.range)(0x0ba5, 0x0ba7),
...(0, util_1.range)(0x0bab, 0x0bad),
0x0bb6,
...(0, util_1.range)(0x0bba, 0x0bbd),
...(0, util_1.range)(0x0bc3, 0x0bc5),
0x0bc9,
...(0, util_1.range)(0x0bce, 0x0bd6),
...(0, util_1.range)(0x0bd8, 0x0be6),
...(0, util_1.range)(0x0bf3, 0x0c00),
0x0c04,
0x0c0d,
0x0c11,
0x0c29,
0x0c34,
...(0, util_1.range)(0x0c3a, 0x0c3d),
0x0c45,
0x0c49,
...(0, util_1.range)(0x0c4e, 0x0c54),
...(0, util_1.range)(0x0c57, 0x0c5f),
...(0, util_1.range)(0x0c62, 0x0c65),
...(0, util_1.range)(0x0c70, 0x0c81),
0x0c84,
0x0c8d,
0x0c91,
0x0ca9,
0x0cb4,
...(0, util_1.range)(0x0cba, 0x0cbd),
0x0cc5,
0x0cc9,
...(0, util_1.range)(0x0cce, 0x0cd4),
...(0, util_1.range)(0x0cd7, 0x0cdd),
0x0cdf,
...(0, util_1.range)(0x0ce2, 0x0ce5),
...(0, util_1.range)(0x0cf0, 0x0d01),
0x0d04,
0x0d0d,
0x0d11,
0x0d29,
...(0, util_1.range)(0x0d3a, 0x0d3d),
...(0, util_1.range)(0x0d44, 0x0d45),
0x0d49,
...(0, util_1.range)(0x0d4e, 0x0d56),
...(0, util_1.range)(0x0d58, 0x0d5f),
...(0, util_1.range)(0x0d62, 0x0d65),
...(0, util_1.range)(0x0d70, 0x0d81),
0x0d84,
...(0, util_1.range)(0x0d97, 0x0d99),
0x0db2,
0x0dbc,
...(0, util_1.range)(0x0dbe, 0x0dbf),
...(0, util_1.range)(0x0dc7, 0x0dc9),
...(0, util_1.range)(0x0dcb, 0x0dce),
0x0dd5,
0x0dd7,
...(0, util_1.range)(0x0de0, 0x0df1),
...(0, util_1.range)(0x0df5, 0x0e00),
...(0, util_1.range)(0x0e3b, 0x0e3e),
...(0, util_1.range)(0x0e5c, 0x0e80),
0x0e83,
...(0, util_1.range)(0x0e85, 0x0e86),
0x0e89,
...(0, util_1.range)(0x0e8b, 0x0e8c),
...(0, util_1.range)(0x0e8e, 0x0e93),
0x0e98,
0x0ea0,
0x0ea4,
0x0ea6,
...(0, util_1.range)(0x0ea8, 0x0ea9),
0x0eac,
0x0eba,
...(0, util_1.range)(0x0ebe, 0x0ebf),
0x0ec5,
0x0ec7,
...(0, util_1.range)(0x0ece, 0x0ecf),
...(0, util_1.range)(0x0eda, 0x0edb),
...(0, util_1.range)(0x0ede, 0x0eff),
0x0f48,
...(0, util_1.range)(0x0f6b, 0x0f70),
...(0, util_1.range)(0x0f8c, 0x0f8f),
0x0f98,
0x0fbd,
...(0, util_1.range)(0x0fcd, 0x0fce),
...(0, util_1.range)(0x0fd0, 0x0fff),
0x1022,
0x1028,
0x102b,
...(0, util_1.range)(0x1033, 0x1035),
...(0, util_1.range)(0x103a, 0x103f),
...(0, util_1.range)(0x105a, 0x109f),
...(0, util_1.range)(0x10c6, 0x10cf),
...(0, util_1.range)(0x10f9, 0x10fa),
...(0, util_1.range)(0x10fc, 0x10ff),
...(0, util_1.range)(0x115a, 0x115e),
...(0, util_1.range)(0x11a3, 0x11a7),
...(0, util_1.range)(0x11fa, 0x11ff),
0x1207,
0x1247,
0x1249,
...(0, util_1.range)(0x124e, 0x124f),
0x1257,
0x1259,
...(0, util_1.range)(0x125e, 0x125f),
0x1287,
0x1289,
...(0, util_1.range)(0x128e, 0x128f),
0x12af,
0x12b1,
...(0, util_1.range)(0x12b6, 0x12b7),
0x12bf,
0x12c1,
...(0, util_1.range)(0x12c6, 0x12c7),
0x12cf,
0x12d7,
0x12ef,
0x130f,
0x1311,
...(0, util_1.range)(0x1316, 0x1317),
0x131f,
0x1347,
...(0, util_1.range)(0x135b, 0x1360),
...(0, util_1.range)(0x137d, 0x139f),
...(0, util_1.range)(0x13f5, 0x1400),
...(0, util_1.range)(0x1677, 0x167f),
...(0, util_1.range)(0x169d, 0x169f),
...(0, util_1.range)(0x16f1, 0x16ff),
0x170d,
...(0, util_1.range)(0x1715, 0x171f),
...(0, util_1.range)(0x1737, 0x173f),
...(0, util_1.range)(0x1754, 0x175f),
0x176d,
0x1771,
...(0, util_1.range)(0x1774, 0x177f),
...(0, util_1.range)(0x17dd, 0x17df),
...(0, util_1.range)(0x17ea, 0x17ff),
0x180f,
...(0, util_1.range)(0x181a, 0x181f),
...(0, util_1.range)(0x1878, 0x187f),
...(0, util_1.range)(0x18aa, 0x1dff),
...(0, util_1.range)(0x1e9c, 0x1e9f),
...(0, util_1.range)(0x1efa, 0x1eff),
...(0, util_1.range)(0x1f16, 0x1f17),
...(0, util_1.range)(0x1f1e, 0x1f1f),
...(0, util_1.range)(0x1f46, 0x1f47),
...(0, util_1.range)(0x1f4e, 0x1f4f),
0x1f58,
0x1f5a,
0x1f5c,
0x1f5e,
...(0, util_1.range)(0x1f7e, 0x1f7f),
0x1fb5,
0x1fc5,
...(0, util_1.range)(0x1fd4, 0x1fd5),
0x1fdc,
...(0, util_1.range)(0x1ff0, 0x1ff1),
0x1ff5,
0x1fff,
...(0, util_1.range)(0x2053, 0x2056),
...(0, util_1.range)(0x2058, 0x205e),
...(0, util_1.range)(0x2064, 0x2069),
...(0, util_1.range)(0x2072, 0x2073),
...(0, util_1.range)(0x208f, 0x209f),
...(0, util_1.range)(0x20b2, 0x20cf),
...(0, util_1.range)(0x20eb, 0x20ff),
...(0, util_1.range)(0x213b, 0x213c),
...(0, util_1.range)(0x214c, 0x2152),
...(0, util_1.range)(0x2184, 0x218f),
...(0, util_1.range)(0x23cf, 0x23ff),
...(0, util_1.range)(0x2427, 0x243f),
...(0, util_1.range)(0x244b, 0x245f),
0x24ff,
...(0, util_1.range)(0x2614, 0x2615),
0x2618,
...(0, util_1.range)(0x267e, 0x267f),
...(0, util_1.range)(0x268a, 0x2700),
0x2705,
...(0, util_1.range)(0x270a, 0x270b),
0x2728,
0x274c,
0x274e,
...(0, util_1.range)(0x2753, 0x2755),
0x2757,
...(0, util_1.range)(0x275f, 0x2760),
...(0, util_1.range)(0x2795, 0x2797),
0x27b0,
...(0, util_1.range)(0x27bf, 0x27cf),
...(0, util_1.range)(0x27ec, 0x27ef),
...(0, util_1.range)(0x2b00, 0x2e7f),
0x2e9a,
...(0, util_1.range)(0x2ef4, 0x2eff),
...(0, util_1.range)(0x2fd6, 0x2fef),
...(0, util_1.range)(0x2ffc, 0x2fff),
0x3040,
...(0, util_1.range)(0x3097, 0x3098),
...(0, util_1.range)(0x3100, 0x3104),
...(0, util_1.range)(0x312d, 0x3130),
0x318f,
...(0, util_1.range)(0x31b8, 0x31ef),
...(0, util_1.range)(0x321d, 0x321f),
...(0, util_1.range)(0x3244, 0x3250),
...(0, util_1.range)(0x327c, 0x327e),
...(0, util_1.range)(0x32cc, 0x32cf),
0x32ff,
...(0, util_1.range)(0x3377, 0x337a),
...(0, util_1.range)(0x33de, 0x33df),
0x33ff,
...(0, util_1.range)(0x4db6, 0x4dff),
...(0, util_1.range)(0x9fa6, 0x9fff),
...(0, util_1.range)(0xa48d, 0xa48f),
...(0, util_1.range)(0xa4c7, 0xabff),
...(0, util_1.range)(0xd7a4, 0xd7ff),
...(0, util_1.range)(0xfa2e, 0xfa2f),
...(0, util_1.range)(0xfa6b, 0xfaff),
...(0, util_1.range)(0xfb07, 0xfb12),
...(0, util_1.range)(0xfb18, 0xfb1c),
0xfb37,
0xfb3d,
0xfb3f,
0xfb42,
0xfb45,
...(0, util_1.range)(0xfbb2, 0xfbd2),
...(0, util_1.range)(0xfd40, 0xfd4f),
...(0, util_1.range)(0xfd90, 0xfd91),
...(0, util_1.range)(0xfdc8, 0xfdcf),
...(0, util_1.range)(0xfdfd, 0xfdff),
...(0, util_1.range)(0xfe10, 0xfe1f),
...(0, util_1.range)(0xfe24, 0xfe2f),
...(0, util_1.range)(0xfe47, 0xfe48),
0xfe53,
0xfe67,
...(0, util_1.range)(0xfe6c, 0xfe6f),
0xfe75,
...(0, util_1.range)(0xfefd, 0xfefe),
0xff00,
...(0, util_1.range)(0xffbf, 0xffc1),
...(0, util_1.range)(0xffc8, 0xffc9),
...(0, util_1.range)(0xffd0, 0xffd1),
...(0, util_1.range)(0xffd8, 0xffd9),
...(0, util_1.range)(0xffdd, 0xffdf),
0xffe7,
...(0, util_1.range)(0xffef, 0xfff8),
...(0, util_1.range)(0x10000, 0x102ff),
0x1031f,
...(0, util_1.range)(0x10324, 0x1032f),
...(0, util_1.range)(0x1034b, 0x103ff),
...(0, util_1.range)(0x10426, 0x10427),
...(0, util_1.range)(0x1044e, 0x1cfff),
...(0, util_1.range)(0x1d0f6, 0x1d0ff),
...(0, util_1.range)(0x1d127, 0x1d129),
...(0, util_1.range)(0x1d1de, 0x1d3ff),
0x1d455,
0x1d49d,
...(0, util_1.range)(0x1d4a0, 0x1d4a1),
...(0, util_1.range)(0x1d4a3, 0x1d4a4),
...(0, util_1.range)(0x1d4a7, 0x1d4a8),
0x1d4ad,
0x1d4ba,
0x1d4bc,
0x1d4c1,
0x1d4c4,
0x1d506,
...(0, util_1.range)(0x1d50b, 0x1d50c),
0x1d515,
0x1d51d,
0x1d53a,
0x1d53f,
0x1d545,
...(0, util_1.range)(0x1d547, 0x1d549),
0x1d551,
...(0, util_1.range)(0x1d6a4, 0x1d6a7),
...(0, util_1.range)(0x1d7ca, 0x1d7cd),
...(0, util_1.range)(0x1d800, 0x1fffd),
...(0, util_1.range)(0x2a6d7, 0x2f7ff),
...(0, util_1.range)(0x2fa1e, 0x2fffd),
...(0, util_1.range)(0x30000, 0x3fffd),
...(0, util_1.range)(0x40000, 0x4fffd),
...(0, util_1.range)(0x50000, 0x5fffd),
...(0, util_1.range)(0x60000, 0x6fffd),
...(0, util_1.range)(0x70000, 0x7fffd),
...(0, util_1.range)(0x80000, 0x8fffd),
...(0, util_1.range)(0x90000, 0x9fffd),
...(0, util_1.range)(0xa0000, 0xafffd),
...(0, util_1.range)(0xb0000, 0xbfffd),
...(0, util_1.range)(0xc0000, 0xcfffd),
...(0, util_1.range)(0xd0000, 0xdfffd),
0xe0000,
...(0, util_1.range)(0xe0002, 0xe001f),
...(0, util_1.range)(0xe0080, 0xefffd),
]);
exports.commonly_mapped_to_nothing = new Set([
0x00ad, 0x034f, 0x1806, 0x180b, 0x180c, 0x180d, 0x200b, 0x200c, 0x200d,
0x2060, 0xfe00, 0xfe01, 0xfe02, 0xfe03, 0xfe04, 0xfe05, 0xfe06, 0xfe07,
0xfe08, 0xfe09, 0xfe0a, 0xfe0b, 0xfe0c, 0xfe0d, 0xfe0e, 0xfe0f, 0xfeff,
]);
exports.non_ASCII_space_characters = new Set([
0x00a0, 0x1680,
0x2000, 0x2001, 0x2002,
0x2003, 0x2004,
0x2005, 0x2006,
0x2007, 0x2008,
0x2009, 0x200a,
0x200b, 0x202f,
0x205f, 0x3000,
]);
exports.prohibited_characters = new Set([
...exports.non_ASCII_space_characters,
...(0, util_1.range)(0, 0x001f),
0x007f,
...(0, util_1.range)(0x0080, 0x009f),
0x06dd,
0x070f,
0x180e,
0x200c,
0x200d,
0x2028,
0x2029,
0x2060,
0x2061,
0x2062,
0x2063,
...(0, util_1.range)(0x206a, 0x206f),
0xfeff,
...(0, util_1.range)(0xfff9, 0xfffc),
...(0, util_1.range)(0x1d173, 0x1d17a),
...(0, util_1.range)(0xe000, 0xf8ff),
...(0, util_1.range)(0xf0000, 0xffffd),
...(0, util_1.range)(0x100000, 0x10fffd),
...(0, util_1.range)(0xfdd0, 0xfdef),
...(0, util_1.range)(0xfffe, 0xffff),
...(0, util_1.range)(0x1fffe, 0x1ffff),
...(0, util_1.range)(0x2fffe, 0x2ffff),
...(0, util_1.range)(0x3fffe, 0x3ffff),
...(0, util_1.range)(0x4fffe, 0x4ffff),
...(0, util_1.range)(0x5fffe, 0x5ffff),
...(0, util_1.range)(0x6fffe, 0x6ffff),
...(0, util_1.range)(0x7fffe, 0x7ffff),
...(0, util_1.range)(0x8fffe, 0x8ffff),
...(0, util_1.range)(0x9fffe, 0x9ffff),
...(0, util_1.range)(0xafffe, 0xaffff),
...(0, util_1.range)(0xbfffe, 0xbffff),
...(0, util_1.range)(0xcfffe, 0xcffff),
...(0, util_1.range)(0xdfffe, 0xdffff),
...(0, util_1.range)(0xefffe, 0xeffff),
...(0, util_1.range)(0x10fffe, 0x10ffff),
...(0, util_1.range)(0xd800, 0xdfff),
0xfff9,
0xfffa,
0xfffb,
0xfffc,
0xfffd,
...(0, util_1.range)(0x2ff0, 0x2ffb),
0x0340,
0x0341,
0x200e,
0x200f,
0x202a,
0x202b,
0x202c,
0x202d,
0x202e,
0x206a,
0x206b,
0x206c,
0x206d,
0x206e,
0x206f,
0xe0001,
...(0, util_1.range)(0xe0020, 0xe007f),
]);
exports.bidirectional_r_al = new Set([
0x05be,
0x05c0,
0x05c3,
...(0, util_1.range)(0x05d0, 0x05ea),
...(0, util_1.range)(0x05f0, 0x05f4),
0x061b,
0x061f,
...(0, util_1.range)(0x0621, 0x063a),
...(0, util_1.range)(0x0640, 0x064a),
...(0, util_1.range)(0x066d, 0x066f),
...(0, util_1.range)(0x0671, 0x06d5),
0x06dd,
...(0, util_1.range)(0x06e5, 0x06e6),
...(0, util_1.range)(0x06fa, 0x06fe),
...(0, util_1.range)(0x0700, 0x070d),
0x0710,
...(0, util_1.range)(0x0712, 0x072c),
...(0, util_1.range)(0x0780, 0x07a5),
0x07b1,
0x200f,
0xfb1d,
...(0, util_1.range)(0xfb1f, 0xfb28),
...(0, util_1.range)(0xfb2a, 0xfb36),
...(0, util_1.range)(0xfb38, 0xfb3c),
0xfb3e,
...(0, util_1.range)(0xfb40, 0xfb41),
...(0, util_1.range)(0xfb43, 0xfb44),
...(0, util_1.range)(0xfb46, 0xfbb1),
...(0, util_1.range)(0xfbd3, 0xfd3d),
...(0, util_1.range)(0xfd50, 0xfd8f),
...(0, util_1.range)(0xfd92, 0xfdc7),
...(0, util_1.range)(0xfdf0, 0xfdfc),
...(0, util_1.range)(0xfe70, 0xfe74),
...(0, util_1.range)(0xfe76, 0xfefc),
]);
exports.bidirectional_l = new Set([
...(0, util_1.range)(0x0041, 0x005a),
...(0, util_1.range)(0x0061, 0x007a),
0x00aa,
0x00b5,
0x00ba,
...(0, util_1.range)(0x00c0, 0x00d6),
...(0, util_1.range)(0x00d8, 0x00f6),
...(0, util_1.range)(0x00f8, 0x0220),
...(0, util_1.range)(0x0222, 0x0233),
...(0, util_1.range)(0x0250, 0x02ad),
...(0, util_1.range)(0x02b0, 0x02b8),
...(0, util_1.range)(0x02bb, 0x02c1),
...(0, util_1.range)(0x02d0, 0x02d1),
...(0, util_1.range)(0x02e0, 0x02e4),
0x02ee,
0x037a,
0x0386,
...(0, util_1.range)(0x0388, 0x038a),
0x038c,
...(0, util_1.range)(0x038e, 0x03a1),
...(0, util_1.range)(0x03a3, 0x03ce),
...(0, util_1.range)(0x03d0, 0x03f5),
...(0, util_1.range)(0x0400, 0x0482),
...(0, util_1.range)(0x048a, 0x04ce),
...(0, util_1.range)(0x04d0, 0x04f5),
...(0, util_1.range)(0x04f8, 0x04f9),
...(0, util_1.range)(0x0500, 0x050f),
...(0, util_1.range)(0x0531, 0x0556),
...(0, util_1.range)(0x0559, 0x055f),
...(0, util_1.range)(0x0561, 0x0587),
0x0589,
0x0903,
...(0, util_1.range)(0x0905, 0x0939),
...(0, util_1.range)(0x093d, 0x0940),
...(0, util_1.range)(0x0949, 0x094c),
0x0950,
...(0, util_1.range)(0x0958, 0x0961),
...(0, util_1.range)(0x0964, 0x0970),
...(0, util_1.range)(0x0982, 0x0983),
...(0, util_1.range)(0x0985, 0x098c),
...(0, util_1.range)(0x098f, 0x0990),
...(0, util_1.range)(0x0993, 0x09a8),
...(0, util_1.range)(0x09aa, 0x09b0),
0x09b2,
...(0, util_1.range)(0x09b6, 0x09b9),
...(0, util_1.range)(0x09be, 0x09c0),
...(0, util_1.range)(0x09c7, 0x09c8),
...(0, util_1.range)(0x09cb, 0x09cc),
0x09d7,
...(0, util_1.range)(0x09dc, 0x09dd),
...(0, util_1.range)(0x09df, 0x09e1),
...(0, util_1.range)(0x09e6, 0x09f1),
...(0, util_1.range)(0x09f4, 0x09fa),
...(0, util_1.range)(0x0a05, 0x0a0a),
...(0, util_1.range)(0x0a0f, 0x0a10),
...(0, util_1.range)(0x0a13, 0x0a28),
...(0, util_1.range)(0x0a2a, 0x0a30),
...(0, util_1.range)(0x0a32, 0x0a33),
...(0, util_1.range)(0x0a35, 0x0a36),
...(0, util_1.range)(0x0a38, 0x0a39),
...(0, util_1.range)(0x0a3e, 0x0a40),
...(0, util_1.range)(0x0a59, 0x0a5c),
0x0a5e,
...(0, util_1.range)(0x0a66, 0x0a6f),
...(0, util_1.range)(0x0a72, 0x0a74),
0x0a83,
...(0, util_1.range)(0x0a85, 0x0a8b),
0x0a8d,
...(0, util_1.range)(0x0a8f, 0x0a91),
...(0, util_1.range)(0x0a93, 0x0aa8),
...(0, util_1.range)(0x0aaa, 0x0ab0),
...(0, util_1.range)(0x0ab2, 0x0ab3),
...(0, util_1.range)(0x0ab5, 0x0ab9),
...(0, util_1.range)(0x0abd, 0x0ac0),
0x0ac9,
...(0, util_1.range)(0x0acb, 0x0acc),
0x0ad0,
0x0ae0,
...(0, util_1.range)(0x0ae6, 0x0aef),
...(0, util_1.range)(0x0b02, 0x0b03),
...(0, util_1.range)(0x0b05, 0x0b0c),
...(0, util_1.range)(0x0b0f, 0x0b10),
...(0, util_1.range)(0x0b13, 0x0b28),
...(0, util_1.range)(0x0b2a, 0x0b30),
...(0, util_1.range)(0x0b32, 0x0b33),
...(0, util_1.range)(0x0b36, 0x0b39),
...(0, util_1.range)(0x0b3d, 0x0b3e),
0x0b40,
...(0, util_1.range)(0x0b47, 0x0b48),
...(0, util_1.range)(0x0b4b, 0x0b4c),
0x0b57,
...(0, util_1.range)(0x0b5c, 0x0b5d),
...(0, util_1.range)(0x0b5f, 0x0b61),
...(0, util_1.range)(0x0b66, 0x0b70),
0x0b83,
...(0, util_1.range)(0x0b85, 0x0b8a),
...(0, util_1.range)(0x0b8e, 0x0b90),
...(0, util_1.range)(0x0b92, 0x0b95),
...(0, util_1.range)(0x0b99, 0x0b9a),
0x0b9c,
...(0, util_1.range)(0x0b9e, 0x0b9f),
...(0, util_1.range)(0x0ba3, 0x0ba4),
...(0, util_1.range)(0x0ba8, 0x0baa),
...(0, util_1.range)(0x0bae, 0x0bb5),
...(0, util_1.range)(0x0bb7, 0x0bb9),
...(0, util_1.range)(0x0bbe, 0x0bbf),
...(0, util_1.range)(0x0bc1, 0x0bc2),
...(0, util_1.range)(0x0bc6, 0x0bc8),
...(0, util_1.range)(0x0bca, 0x0bcc),
0x0bd7,
...(0, util_1.range)(0x0be7, 0x0bf2),
...(0, util_1.range)(0x0c01, 0x0c03),
...(0, util_1.range)(0x0c05, 0x0c0c),
...(0, util_1.range)(0x0c0e, 0x0c10),
...(0, util_1.range)(0x0c12, 0x0c28),
...(0, util_1.range)(0x0c2a, 0x0c33),
...(0, util_1.range)(0x0c35, 0x0c39),
...(0, util_1.range)(0x0c41, 0x0c44),
...(0, util_1.range)(0x0c60, 0x0c61),
...(0, util_1.range)(0x0c66, 0x0c6f),
...(0, util_1.range)(0x0c82, 0x0c83),
...(0, util_1.range)(0x0c85, 0x0c8c),
...(0, util_1.range)(0x0c8e, 0x0c90),
...(0, util_1.range)(0x0c92, 0x0ca8),
...(0, util_1.range)(0x0caa, 0x0cb3),
...(0, util_1.range)(0x0cb5, 0x0cb9),
0x0cbe,
...(0, util_1.range)(0x0cc0, 0x0cc4),
...(0, util_1.range)(0x0cc7, 0x0cc8),
...(0, util_1.range)(0x0cca, 0x0ccb),
...(0, util_1.range)(0x0cd5, 0x0cd6),
0x0cde,
...(0, util_1.range)(0x0ce0, 0x0ce1),
...(0, util_1.range)(0x0ce6, 0x0cef),
...(0, util_1.range)(0x0d02, 0x0d03),
...(0, util_1.range)(0x0d05, 0x0d0c),
...(0, util_1.range)(0x0d0e, 0x0d10),
...(0, util_1.range)(0x0d12, 0x0d28),
...(0, util_1.range)(0x0d2a, 0x0d39),
...(0, util_1.range)(0x0d3e, 0x0d40),
...(0, util_1.range)(0x0d46, 0x0d48),
...(0, util_1.range)(0x0d4a, 0x0d4c),
0x0d57,
...(0, util_1.range)(0x0d60, 0x0d61),
...(0, util_1.range)(0x0d66, 0x0d6f),
...(0, util_1.range)(0x0d82, 0x0d83),
...(0, util_1.range)(0x0d85, 0x0d96),
...(0, util_1.range)(0x0d9a, 0x0db1),
...(0, util_1.range)(0x0db3, 0x0dbb),
0x0dbd,
...(0, util_1.range)(0x0dc0, 0x0dc6),
...(0, util_1.range)(0x0dcf, 0x0dd1),
...(0, util_1.range)(0x0dd8, 0x0ddf),
...(0, util_1.range)(0x0df2, 0x0df4),
...(0, util_1.range)(0x0e01, 0x0e30),
...(0, util_1.range)(0x0e32, 0x0e33),
...(0, util_1.range)(0x0e40, 0x0e46),
...(0, util_1.range)(0x0e4f, 0x0e5b),
...(0, util_1.range)(0x0e81, 0x0e82),
0x0e84,
...(0, util_1.range)(0x0e87, 0x0e88),
0x0e8a,
0x0e8d,
...(0, util_1.range)(0x0e94, 0x0e97),
...(0, util_1.range)(0x0e99, 0x0e9f),
...(0, util_1.range)(0x0ea1, 0x0ea3),
0x0ea5,
0x0ea7,
...(0, util_1.range)(0x0eaa, 0x0eab),
...(0, util_1.range)(0x0ead, 0x0eb0),
...(0, util_1.range)(0x0eb2, 0x0eb3),
0x0ebd,
...(0, util_1.range)(0x0ec0, 0x0ec4),
0x0ec6,
...(0, util_1.range)(0x0ed0, 0x0ed9),
...(0, util_1.range)(0x0edc, 0x0edd),
...(0, util_1.range)(0x0f00, 0x0f17),
...(0, util_1.range)(0x0f1a, 0x0f34),
0x0f36,
0x0f38,
...(0, util_1.range)(0x0f3e, 0x0f47),
...(0, util_1.range)(0x0f49, 0x0f6a),
0x0f7f,
0x0f85,
...(0, util_1.range)(0x0f88, 0x0f8b),
...(0, util_1.range)(0x0fbe, 0x0fc5),
...(0, util_1.range)(0x0fc7, 0x0fcc),
0x0fcf,
...(0, util_1.range)(0x1000, 0x1021),
...(0, util_1.range)(0x1023, 0x1027),
...(0, util_1.range)(0x1029, 0x102a),
0x102c,
0x1031,
0x1038,
...(0, util_1.range)(0x1040, 0x1057),
...(0, util_1.range)(0x10a0, 0x10c5),
...(0, util_1.range)(0x10d0, 0x10f8),
0x10fb,
...(0, util_1.range)(0x1100, 0x1159),
...(0, util_1.range)(0x115f, 0x11a2),
...(0, util_1.range)(0x11a8, 0x11f9),
...(0, util_1.range)(0x1200, 0x1206),
...(0, util_1.range)(0x1208, 0x1246),
0x1248,
...(0, util_1.range)(0x124a, 0x124d),
...(0, util_1.range)(0x1250, 0x1256),
0x1258,
...(0, util_1.range)(0x125a, 0x125d),
...(0, util_1.range)(0x1260, 0x1286),
0x1288,
...(0, util_1.range)(0x128a, 0x128d),
...(0, util_1.range)(0x1290, 0x12ae),
0x12b0,
...(0, util_1.range)(0x12b2, 0x12b5),
...(0, util_1.range)(0x12b8, 0x12be),
0x12c0,
...(0, util_1.range)(0x12c2, 0x12c5),
...(0, util_1.range)(0x12c8, 0x12ce),
...(0, util_1.range)(0x12d0, 0x12d6),
...(0, util_1.range)(0x12d8, 0x12ee),
...(0, util_1.range)(0x12f0, 0x130e),
0x1310,
...(0, util_1.range)(0x1312, 0x1315),
...(0, util_1.range)(0x1318, 0x131e),
...(0, util_1.range)(0x1320, 0x1346),
...(0, util_1.range)(0x1348, 0x135a),
...(0, util_1.range)(0x1361, 0x137c),
...(0, util_1.range)(0x13a0, 0x13f4),
...(0, util_1.range)(0x1401, 0x1676),
...(0, util_1.range)(0x1681, 0x169a),
...(0, util_1.range)(0x16a0, 0x16f0),
...(0, util_1.range)(0x1700, 0x170c),
...(0, util_1.range)(0x170e, 0x1711),
...(0, util_1.range)(0x1720, 0x1731),
...(0, util_1.range)(0x1735, 0x1736),
...(0, util_1.range)(0x1740, 0x1751),
...(0, util_1.range)(0x1760, 0x176c),
...(0, util_1.range)(0x176e, 0x1770),
...(0, util_1.range)(0x1780, 0x17b6),
...(0, util_1.range)(0x17be, 0x17c5),
...(0, util_1.range)(0x17c7, 0x17c8),
...(0, util_1.range)(0x17d4, 0x17da),
0x17dc,
...(0, util_1.range)(0x17e0, 0x17e9),
...(0, util_1.range)(0x1810, 0x1819),
...(0, util_1.range)(0x1820, 0x1877),
...(0, util_1.range)(0x1880, 0x18a8),
...(0, util_1.range)(0x1e00, 0x1e9b),
...(0, util_1.range)(0x1ea0, 0x1ef9),
...(0, util_1.range)(0x1f00, 0x1f15),
...(0, util_1.range)(0x1f18, 0x1f1d),
...(0, util_1.range)(0x1f20, 0x1f45),
...(0, util_1.range)(0x1f48, 0x1f4d),
...(0, util_1.range)(0x1f50, 0x1f57),
0x1f59,
0x1f5b,
0x1f5d,
...(0, util_1.range)(0x1f5f, 0x1f7d),
...(0, util_1.range)(0x1f80, 0x1fb4),
...(0, util_1.range)(0x1fb6, 0x1fbc),
0x1fbe,
...(0, util_1.range)(0x1fc2, 0x1fc4),
...(0, util_1.range)(0x1fc6, 0x1fcc),
...(0, util_1.range)(0x1fd0, 0x1fd3),
...(0, util_1.range)(0x1fd6, 0x1fdb),
...(0, util_1.range)(0x1fe0, 0x1fec),
...(0, util_1.range)(0x1ff2, 0x1ff4),
...(0, util_1.range)(0x1ff6, 0x1ffc),
0x200e,
0x2071,
0x207f,
0x2102,
0x2107,
...(0, util_1.range)(0x210a, 0x2113),
0x2115,
...(0, util_1.range)(0x2119, 0x211d),
0x2124,
0x2126,
0x2128,
...(0, util_1.range)(0x212a, 0x212d),
...(0, util_1.range)(0x212f, 0x2131),
...(0, util_1.range)(0x2133, 0x2139),
...(0, util_1.range)(0x213d, 0x213f),
...(0, util_1.range)(0x2145, 0x2149),
...(0, util_1.range)(0x2160, 0x2183),
...(0, util_1.range)(0x2336, 0x237a),
0x2395,
...(0, util_1.range)(0x249c, 0x24e9),
...(0, util_1.range)(0x3005, 0x3007),
...(0, util_1.range)(0x3021, 0x3029),
...(0, util_1.range)(0x3031, 0x3035),
...(0, util_1.range)(0x3038, 0x303c),
...(0, util_1.range)(0x3041, 0x3096),
...(0, util_1.range)(0x309d, 0x309f),
...(0, util_1.range)(0x30a1, 0x30fa),
...(0, util_1.range)(0x30fc, 0x30ff),
...(0, util_1.range)(0x3105, 0x312c),
...(0, util_1.range)(0x3131, 0x318e),
...(0, util_1.range)(0x3190, 0x31b7),
...(0, util_1.range)(0x31f0, 0x321c),
...(0, util_1.range)(0x3220, 0x3243),
...(0, util_1.range)(0x3260, 0x327b),
...(0, util_1.range)(0x327f, 0x32b0),
...(0, util_1.range)(0x32c0, 0x32cb),
...(0, util_1.range)(0x32d0, 0x32fe),
...(0, util_1.range)(0x3300, 0x3376),
...(0, util_1.range)(0x337b, 0x33dd),
...(0, util_1.range)(0x33e0, 0x33fe),
...(0, util_1.range)(0x3400, 0x4db5),
...(0, util_1.range)(0x4e00, 0x9fa5),
...(0, util_1.range)(0xa000, 0xa48c),
...(0, util_1.range)(0xac00, 0xd7a3),
...(0, util_1.range)(0xd800, 0xfa2d),
...(0, util_1.range)(0xfa30, 0xfa6a),
...(0, util_1.range)(0xfb00, 0xfb06),
...(0, util_1.range)(0xfb13, 0xfb17),
...(0, util_1.range)(0xff21, 0xff3a),
...(0, util_1.range)(0xff41, 0xff5a),
...(0, util_1.range)(0xff66, 0xffbe),
...(0, util_1.range)(0xffc2, 0xffc7),
...(0, util_1.range)(0xffca, 0xffcf),
...(0, util_1.range)(0xffd2, 0xffd7),
...(0, util_1.range)(0xffda, 0xffdc),
...(0, util_1.range)(0x10300, 0x1031e),
...(0, util_1.range)(0x10320, 0x10323),
...(0, util_1.range)(0x10330, 0x1034a),
...(0, util_1.range)(0x10400, 0x10425),
...(0, util_1.range)(0x10428, 0x1044d),
...(0, util_1.range)(0x1d000, 0x1d0f5),
...(0, util_1.range)(0x1d100, 0x1d126),
...(0, util_1.range)(0x1d12a, 0x1d166),
...(0, util_1.range)(0x1d16a, 0x1d172),
...(0, util_1.range)(0x1d183, 0x1d184),
...(0, util_1.range)(0x1d18c, 0x1d1a9),
...(0, util_1.range)(0x1d1ae, 0x1d1dd),
...(0, util_1.range)(0x1d400, 0x1d454),
...(0, util_1.range)(0x1d456, 0x1d49c),
...(0, util_1.range)(0x1d49e, 0x1d49f),
0x1d4a2,
...(0, util_1.range)(0x1d4a5, 0x1d4a6),
...(0, util_1.range)(0x1d4a9, 0x1d4ac),
...(0, util_1.range)(0x1d4ae, 0x1d4b9),
0x1d4bb,
...(0, util_1.range)(0x1d4bd, 0x1d4c0),
...(0, util_1.range)(0x1d4c2, 0x1d4c3),
...(0, util_1.range)(0x1d4c5, 0x1d505),
...(0, util_1.range)(0x1d507, 0x1d50a),
...(0, util_1.range)(0x1d50d, 0x1d514),
...(0, util_1.range)(0x1d516, 0x1d51c),
...(0, util_1.range)(0x1d51e, 0x1d539),
...(0, util_1.range)(0x1d53b, 0x1d53e),
...(0, util_1.range)(0x1d540, 0x1d544),
0x1d546,
...(0, util_1.range)(0x1d54a, 0x1d550),
...(0, util_1.range)(0x1d552, 0x1d6a3),
...(0, util_1.range)(0x1d6a8, 0x1d7c9),
...(0, util_1.range)(0x20000, 0x2a6d6),
...(0, util_1.range)(0x2f800, 0x2fa1d),
...(0, util_1.range)(0xf0000, 0xffffd),
...(0, util_1.range)(0x100000, 0x10fffd),
]);
//# sourceMappingURL=code-points-src.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=generate-code-points.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"generate-code-points.d.ts","sourceRoot":"","sources":["../src/generate-code-points.ts"],"names":[],"mappings":""}

View file

@ -0,0 +1,69 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const zlib_1 = require("zlib");
const sparse_bitfield_1 = __importDefault(require("sparse-bitfield"));
const codePoints = __importStar(require("./code-points-src"));
const fs_1 = require("fs");
if (!process.env.GENERATE_CODE_POINTS) {
process.exitCode = 0;
process.exit();
}
const unassigned_code_points = (0, sparse_bitfield_1.default)();
const commonly_mapped_to_nothing = (0, sparse_bitfield_1.default)();
const non_ascii_space_characters = (0, sparse_bitfield_1.default)();
const prohibited_characters = (0, sparse_bitfield_1.default)();
const bidirectional_r_al = (0, sparse_bitfield_1.default)();
const bidirectional_l = (0, sparse_bitfield_1.default)();
function traverse(bits, src) {
for (const code of src.keys()) {
bits.set(code, true);
}
const buffer = bits.toBuffer();
return Buffer.concat([createSize(buffer), buffer]);
}
function createSize(buffer) {
const buf = Buffer.alloc(4);
buf.writeUInt32BE(buffer.length);
return buf;
}
const memory = [];
memory.push(traverse(unassigned_code_points, codePoints.unassigned_code_points), traverse(commonly_mapped_to_nothing, codePoints.commonly_mapped_to_nothing), traverse(non_ascii_space_characters, codePoints.non_ASCII_space_characters), traverse(prohibited_characters, codePoints.prohibited_characters), traverse(bidirectional_r_al, codePoints.bidirectional_r_al), traverse(bidirectional_l, codePoints.bidirectional_l));
const fsStream = (0, fs_1.createWriteStream)(process.argv[2]);
fsStream.write(`import { gunzipSync } from 'zlib';
export default gunzipSync(
Buffer.from(
'${(0, zlib_1.gzipSync)(Buffer.concat(memory), { level: 9 }).toString('base64')}',
'base64'
)
);
`);
const fsStreamUncompressedData = (0, fs_1.createWriteStream)(process.argv[3]);
fsStreamUncompressedData.write(`const data = Buffer.from('${Buffer.concat(memory).toString('base64')}', 'base64');\nexport default data;\n`);
//# sourceMappingURL=generate-code-points.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"generate-code-points.js","sourceRoot":"","sources":["../src/generate-code-points.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAgC;AAChC,sEAAuC;AACvC,8DAAgD;AAChD,2BAAuC;AAEvC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE;IAErC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,EAAE,CAAC;CAChB;AAED,MAAM,sBAAsB,GAAG,IAAA,yBAAQ,GAAE,CAAC;AAC1C,MAAM,0BAA0B,GAAG,IAAA,yBAAQ,GAAE,CAAC;AAC9C,MAAM,0BAA0B,GAAG,IAAA,yBAAQ,GAAE,CAAC;AAC9C,MAAM,qBAAqB,GAAG,IAAA,yBAAQ,GAAE,CAAC;AACzC,MAAM,kBAAkB,GAAG,IAAA,yBAAQ,GAAE,CAAC;AACtC,MAAM,eAAe,GAAG,IAAA,yBAAQ,GAAE,CAAC;AAMnC,SAAS,QAAQ,CAAC,IAA+B,EAAE,GAAgB;IACjE,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE;QAC7B,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;KACtB;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,UAAU,CAAC,MAAc;IAChC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5B,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEjC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,MAAM,GAAa,EAAE,CAAC;AAE5B,MAAM,CAAC,IAAI,CACT,QAAQ,CAAC,sBAAsB,EAAE,UAAU,CAAC,sBAAsB,CAAC,EACnE,QAAQ,CAAC,0BAA0B,EAAE,UAAU,CAAC,0BAA0B,CAAC,EAC3E,QAAQ,CAAC,0BAA0B,EAAE,UAAU,CAAC,0BAA0B,CAAC,EAC3E,QAAQ,CAAC,qBAAqB,EAAE,UAAU,CAAC,qBAAqB,CAAC,EACjE,QAAQ,CAAC,kBAAkB,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAC3D,QAAQ,CAAC,eAAe,EAAE,UAAU,CAAC,eAAe,CAAC,CACtD,CAAC;AAEF,MAAM,QAAQ,GAAG,IAAA,sBAAiB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACpD,QAAQ,CAAC,KAAK,CACZ;;;;OAIK,IAAA,eAAQ,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;;;;CAItE,CACA,CAAC;AAEF,MAAM,wBAAwB,GAAG,IAAA,sBAAiB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpE,wBAAwB,CAAC,KAAK,CAC5B,6BAA6B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CACzD,QAAQ,CACT,uCAAuC,CACzC,CAAC"}

View file

@ -0,0 +1,11 @@
import type { createMemoryCodePoints } from './memory-code-points';
declare function saslprep({ unassigned_code_points, commonly_mapped_to_nothing, non_ASCII_space_characters, prohibited_characters, bidirectional_r_al, bidirectional_l, }: ReturnType<typeof createMemoryCodePoints>, input: string, opts?: {
allowUnassigned?: boolean;
}): string;
declare namespace saslprep {
export var saslprep: typeof import(".");
var _a: typeof import(".");
export { _a as default };
}
export = saslprep;
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAsCnE,iBAAS,QAAQ,CACf,EACE,sBAAsB,EACtB,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GAChB,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,EAC5C,KAAK,EAAE,MAAM,EACb,IAAI,GAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAO,GACvC,MAAM,CAqGR;kBAhHQ,QAAQ;;;;;AAoHjB,SAAS,QAAQ,CAAC"}

View file

@ -0,0 +1,65 @@
"use strict";
const getCodePoint = (character) => character.codePointAt(0);
const first = (x) => x[0];
const last = (x) => x[x.length - 1];
function toCodePoints(input) {
const codepoints = [];
const size = input.length;
for (let i = 0; i < size; i += 1) {
const before = input.charCodeAt(i);
if (before >= 0xd800 && before <= 0xdbff && size > i + 1) {
const next = input.charCodeAt(i + 1);
if (next >= 0xdc00 && next <= 0xdfff) {
codepoints.push((before - 0xd800) * 0x400 + next - 0xdc00 + 0x10000);
i += 1;
continue;
}
}
codepoints.push(before);
}
return codepoints;
}
function saslprep({ unassigned_code_points, commonly_mapped_to_nothing, non_ASCII_space_characters, prohibited_characters, bidirectional_r_al, bidirectional_l, }, input, opts = {}) {
const mapping2space = non_ASCII_space_characters;
const mapping2nothing = commonly_mapped_to_nothing;
if (typeof input !== 'string') {
throw new TypeError('Expected string.');
}
if (input.length === 0) {
return '';
}
const mapped_input = toCodePoints(input)
.map((character) => (mapping2space.get(character) ? 0x20 : character))
.filter((character) => !mapping2nothing.get(character));
const normalized_input = String.fromCodePoint
.apply(null, mapped_input)
.normalize('NFKC');
const normalized_map = toCodePoints(normalized_input);
const hasProhibited = normalized_map.some((character) => prohibited_characters.get(character));
if (hasProhibited) {
throw new Error('Prohibited character, see https://tools.ietf.org/html/rfc4013#section-2.3');
}
if (opts.allowUnassigned !== true) {
const hasUnassigned = normalized_map.some((character) => unassigned_code_points.get(character));
if (hasUnassigned) {
throw new Error('Unassigned code point, see https://tools.ietf.org/html/rfc4013#section-2.5');
}
}
const hasBidiRAL = normalized_map.some((character) => bidirectional_r_al.get(character));
const hasBidiL = normalized_map.some((character) => bidirectional_l.get(character));
if (hasBidiRAL && hasBidiL) {
throw new Error('String must not contain RandALCat and LCat at the same time,' +
' see https://tools.ietf.org/html/rfc3454#section-6');
}
const isFirstBidiRAL = bidirectional_r_al.get(getCodePoint(first(normalized_input)));
const isLastBidiRAL = bidirectional_r_al.get(getCodePoint(last(normalized_input)));
if (hasBidiRAL && !(isFirstBidiRAL && isLastBidiRAL)) {
throw new Error('Bidirectional RandALCat character must be the first and the last' +
' character of the string, see https://tools.ietf.org/html/rfc3454#section-6');
}
return normalized_input;
}
saslprep.saslprep = saslprep;
saslprep.default = saslprep;
module.exports = saslprep;
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}

View file

@ -0,0 +1,11 @@
/// <reference types="node" />
import bitfield from 'sparse-bitfield';
export declare function createMemoryCodePoints(data: Buffer): {
unassigned_code_points: bitfield.BitFieldInstance;
commonly_mapped_to_nothing: bitfield.BitFieldInstance;
non_ASCII_space_characters: bitfield.BitFieldInstance;
prohibited_characters: bitfield.BitFieldInstance;
bidirectional_r_al: bitfield.BitFieldInstance;
bidirectional_l: bitfield.BitFieldInstance;
};
//# sourceMappingURL=memory-code-points.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"memory-code-points.d.ts","sourceRoot":"","sources":["../src/memory-code-points.ts"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM;;;;;;;EA+BlD"}

View file

@ -0,0 +1,33 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createMemoryCodePoints = void 0;
const sparse_bitfield_1 = __importDefault(require("sparse-bitfield"));
function createMemoryCodePoints(data) {
let offset = 0;
function read() {
const size = data.readUInt32BE(offset);
offset += 4;
const codepoints = data.slice(offset, offset + size);
offset += size;
return (0, sparse_bitfield_1.default)({ buffer: codepoints });
}
const unassigned_code_points = read();
const commonly_mapped_to_nothing = read();
const non_ASCII_space_characters = read();
const prohibited_characters = read();
const bidirectional_r_al = read();
const bidirectional_l = read();
return {
unassigned_code_points,
commonly_mapped_to_nothing,
non_ASCII_space_characters,
prohibited_characters,
bidirectional_r_al,
bidirectional_l,
};
}
exports.createMemoryCodePoints = createMemoryCodePoints;
//# sourceMappingURL=memory-code-points.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"memory-code-points.js","sourceRoot":"","sources":["../src/memory-code-points.ts"],"names":[],"mappings":";;;;;;AAAA,sEAAuC;AAEvC,SAAgB,sBAAsB,CAAC,IAAY;IACjD,IAAI,MAAM,GAAG,CAAC,CAAC;IAKf,SAAS,IAAI;QACX,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACvC,MAAM,IAAI,CAAC,CAAC;QAEZ,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;QACrD,MAAM,IAAI,IAAI,CAAC;QAEf,OAAO,IAAA,yBAAQ,EAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,sBAAsB,GAAG,IAAI,EAAE,CAAC;IACtC,MAAM,0BAA0B,GAAG,IAAI,EAAE,CAAC;IAC1C,MAAM,0BAA0B,GAAG,IAAI,EAAE,CAAC;IAC1C,MAAM,qBAAqB,GAAG,IAAI,EAAE,CAAC;IACrC,MAAM,kBAAkB,GAAG,IAAI,EAAE,CAAC;IAClC,MAAM,eAAe,GAAG,IAAI,EAAE,CAAC;IAE/B,OAAO;QACL,sBAAsB;QACtB,0BAA0B;QAC1B,0BAA0B;QAC1B,qBAAqB;QACrB,kBAAkB;QAClB,eAAe;KAChB,CAAC;AACJ,CAAC;AA/BD,wDA+BC"}

View file

@ -0,0 +1,10 @@
declare function saslprep(input: string, opts?: {
allowUnassigned?: boolean;
}): string;
declare namespace saslprep {
export var saslprep: typeof import("./node");
var _a: typeof import("./node");
export { _a as default };
}
export = saslprep;
//# sourceMappingURL=node.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAMA,iBAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAE7E;kBAFQ,QAAQ;;;;;AAOjB,SAAS,QAAQ,CAAC"}

View file

@ -0,0 +1,15 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const index_1 = __importDefault(require("./index"));
const memory_code_points_1 = require("./memory-code-points");
const code_points_data_1 = __importDefault(require("./code-points-data"));
const codePoints = (0, memory_code_points_1.createMemoryCodePoints)(code_points_data_1.default);
function saslprep(input, opts) {
return (0, index_1.default)(codePoints, input, opts);
}
saslprep.saslprep = saslprep;
saslprep.default = saslprep;
module.exports = saslprep;
//# sourceMappingURL=node.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":";;;;AAAA,oDAAgC;AAChC,6DAA8D;AAC9D,0EAAsC;AAEtC,MAAM,UAAU,GAAG,IAAA,2CAAsB,EAAC,0BAAI,CAAC,CAAC;AAEhD,SAAS,QAAQ,CAAC,KAAa,EAAE,IAAoC;IACnE,OAAO,IAAA,eAAS,EAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC7B,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC;AAE5B,iBAAS,QAAQ,CAAC"}

View file

@ -0,0 +1,2 @@
export declare function range(from: number, to: number): number[];
//# sourceMappingURL=util.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAGA,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAQxD"}

View file

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.range = void 0;
function range(from, to) {
const list = new Array(to - from + 1);
for (let i = 0; i < list.length; i += 1) {
list[i] = from + i;
}
return list;
}
exports.range = range;
//# sourceMappingURL=util.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAGA,SAAgB,KAAK,CAAC,IAAY,EAAE,EAAU;IAE5C,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;IAEtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACvC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;KACpB;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AARD,sBAQC"}

View file

@ -0,0 +1,87 @@
{
"name": "@mongodb-js/saslprep",
"description": "SASLprep: Stringprep Profile for User Names and Passwords, rfc4013",
"keywords": [
"sasl",
"saslprep",
"stringprep",
"rfc4013",
"4013"
],
"author": "Dmitry Tsvettsikh <me@reklatsmasters.com>",
"publishConfig": {
"access": "public"
},
"main": "dist/node.js",
"bugs": {
"url": "https://jira.mongodb.org/projects/COMPASS/issues",
"email": "compass@mongodb.com"
},
"homepage": "https://github.com/mongodb-js/devtools-shared/tree/main/packages/saslprep",
"version": "1.1.5",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist"
],
"license": "MIT",
"exports": {
"browser": {
"types": "./dist/browser.d.ts",
"default": "./dist/browser.js"
},
"import": {
"types": "./dist/node.d.ts",
"default": "./dist/.esm-wrapper.mjs"
},
"require": {
"types": "./dist/node.d.ts",
"default": "./dist/node.js"
}
},
"types": "./dist/node.d.ts",
"scripts": {
"gen-code-points": "ts-node src/generate-code-points.ts src/code-points-data.ts src/code-points-data-browser.ts",
"bootstrap": "npm run compile",
"prepublishOnly": "npm run compile",
"compile": "npm run gen-code-points && tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs",
"typecheck": "tsc --noEmit",
"eslint": "eslint",
"prettier": "prettier",
"lint": "npm run eslint . && npm run prettier -- --check .",
"depcheck": "depcheck",
"check": "npm run typecheck && npm run lint && npm run depcheck",
"check-ci": "npm run check",
"test": "mocha",
"test-cov": "nyc -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test",
"test-watch": "npm run test -- --watch",
"test-ci": "npm run test-cov",
"reformat": "npm run prettier -- --write ."
},
"dependencies": {
"sparse-bitfield": "^3.0.3"
},
"devDependencies": {
"@mongodb-js/eslint-config-devtools": "0.9.10",
"@mongodb-js/mocha-config-devtools": "^1.0.3",
"@mongodb-js/prettier-config-devtools": "^1.0.1",
"@mongodb-js/tsconfig-devtools": "^1.0.1",
"@types/chai": "^4.2.21",
"@types/mocha": "^9.0.0",
"@types/node": "^17.0.35",
"@types/sinon-chai": "^3.2.5",
"@types/sparse-bitfield": "^3.0.1",
"chai": "^4.3.6",
"depcheck": "^1.4.1",
"eslint": "^7.25.0",
"gen-esm-wrapper": "^1.1.0",
"mocha": "^8.4.0",
"nyc": "^15.1.0",
"prettier": "^2.3.2",
"sinon": "^9.2.3",
"typescript": "^5.0.4"
},
"gitHead": "b6736f06dcac6a3891093586a554beec598997b0"
}

View file

@ -0,0 +1,29 @@
# saslprep
_Note: This is a fork of the original [`saslprep`](https://www.npmjs.com/package/saslprep) npm package
and provides equivalent functionality._
Stringprep Profile for User Names and Passwords, [rfc4013](https://tools.ietf.org/html/rfc4013)
### Usage
```js
const saslprep = require('@mongodb-js/saslprep');
saslprep('password\u00AD'); // password
saslprep('password\u0007'); // Error: prohibited character
```
### API
##### `saslprep(input: String, opts: Options): String`
Normalize user name or password.
##### `Options.allowUnassigned: bool`
A special behavior for unassigned code points, see https://tools.ietf.org/html/rfc4013#section-2.5. Disabled by default.
## License
MIT, 2017-2019 (c) Dmitriy Tsvettsikh

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE

View file

@ -0,0 +1,15 @@
# Installation
> `npm install --save @types/webidl-conversions`
# Summary
This package contains type definitions for webidl-conversions (https://github.com/jsdom/webidl-conversions#readme).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/webidl-conversions.
### Additional Details
* Last updated: Tue, 07 Nov 2023 15:11:36 GMT
* Dependencies: none
# Credits
These definitions were written by [ExE Boss](https://github.com/ExE-Boss), and [BendingBender](https://github.com/BendingBender).

View file

@ -0,0 +1,91 @@
declare namespace WebIDLConversions {
interface Globals {
[key: string]: unknown;
Number: (value?: unknown) => number;
String: (value?: unknown) => string;
TypeError: new(message?: string) => TypeError;
}
interface Options {
context?: string | undefined;
globals?: Globals | undefined;
}
interface IntegerOptions extends Options {
enforceRange?: boolean | undefined;
clamp?: boolean | undefined;
}
interface StringOptions extends Options {
treatNullAsEmptyString?: boolean | undefined;
}
interface BufferSourceOptions extends Options {
allowShared?: boolean | undefined;
}
type IntegerConversion = (V: unknown, opts?: IntegerOptions) => number;
type StringConversion = (V: unknown, opts?: StringOptions) => string;
type NumberConversion = (V: unknown, opts?: Options) => number;
}
declare const WebIDLConversions: {
any<V>(V: V, opts?: WebIDLConversions.Options): V;
undefined(V?: unknown, opts?: WebIDLConversions.Options): void;
boolean(V: unknown, opts?: WebIDLConversions.Options): boolean;
byte(V: unknown, opts?: WebIDLConversions.IntegerOptions): number;
octet(V: unknown, opts?: WebIDLConversions.IntegerOptions): number;
short(V: unknown, opts?: WebIDLConversions.IntegerOptions): number;
["unsigned short"](V: unknown, opts?: WebIDLConversions.IntegerOptions): number;
long(V: unknown, opts?: WebIDLConversions.IntegerOptions): number;
["unsigned long"](V: unknown, opts?: WebIDLConversions.IntegerOptions): number;
["long long"](V: unknown, opts?: WebIDLConversions.IntegerOptions): number;
["unsigned long long"](V: unknown, opts?: WebIDLConversions.IntegerOptions): number;
double(V: unknown, opts?: WebIDLConversions.Options): number;
["unrestricted double"](V: unknown, opts?: WebIDLConversions.Options): number;
float(V: unknown, opts?: WebIDLConversions.Options): number;
["unrestricted float"](V: unknown, opts?: WebIDLConversions.Options): number;
DOMString(V: unknown, opts?: WebIDLConversions.StringOptions): string;
ByteString(V: unknown, opts?: WebIDLConversions.StringOptions): string;
USVString(V: unknown, opts?: WebIDLConversions.StringOptions): string;
object<V>(V: V, opts?: WebIDLConversions.Options): V extends object ? V : V & object;
ArrayBuffer(
V: unknown,
opts?: WebIDLConversions.BufferSourceOptions & { allowShared?: false | undefined },
): ArrayBuffer;
ArrayBuffer(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): ArrayBufferLike;
DataView(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): DataView;
Int8Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Int8Array;
Int16Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Int16Array;
Int32Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Int32Array;
Uint8Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Uint8Array;
Uint16Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Uint16Array;
Uint32Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Uint32Array;
Uint8ClampedArray(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Uint8ClampedArray;
Float32Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Float32Array;
Float64Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Float64Array;
ArrayBufferView(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): ArrayBufferView;
BufferSource(
V: unknown,
opts?: WebIDLConversions.BufferSourceOptions & { allowShared?: false | undefined },
): ArrayBuffer | ArrayBufferView;
BufferSource(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): ArrayBufferLike | ArrayBufferView;
DOMTimeStamp(V: unknown, opts?: WebIDLConversions.Options): number;
};
// This can't use ES6 style exports, as those can't have spaces in export names.
export = WebIDLConversions;

View file

@ -0,0 +1,30 @@
{
"name": "@types/webidl-conversions",
"version": "7.0.3",
"description": "TypeScript definitions for webidl-conversions",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/webidl-conversions",
"license": "MIT",
"contributors": [
{
"name": "ExE Boss",
"githubUsername": "ExE-Boss",
"url": "https://github.com/ExE-Boss"
},
{
"name": "BendingBender",
"githubUsername": "BendingBender",
"url": "https://github.com/BendingBender"
}
],
"main": "",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/webidl-conversions"
},
"scripts": {},
"dependencies": {},
"typesPublisherContentHash": "ff1514e10869784e8b7cca9c4099a4213d3f14b48c198b1bf116300df94bf608",
"typeScriptVersion": "4.5"
}

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE

View file

@ -0,0 +1,15 @@
# Installation
> `npm install --save @types/whatwg-url`
# Summary
This package contains type definitions for whatwg-url (https://github.com/jsdom/whatwg-url#readme).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/whatwg-url.
### Additional Details
* Last updated: Tue, 09 Jan 2024 19:06:33 GMT
* Dependencies: [@types/webidl-conversions](https://npmjs.com/package/@types/webidl-conversions)
# Credits
These definitions were written by [Alexander Marks](https://github.com/aomarks), [ExE Boss](https://github.com/ExE-Boss), and [BendingBender](https://github.com/BendingBender).

View file

@ -0,0 +1,169 @@
/// <reference lib="es2020"/>
/** https://url.spec.whatwg.org/#url-representation */
export interface URLRecord {
scheme: string;
username: string;
password: string;
host: string | number | IPv6Address | null;
port: number | null;
path: string | string[];
query: string | null;
fragment: string | null;
}
/** https://url.spec.whatwg.org/#concept-ipv6 */
export type IPv6Address = [number, number, number, number, number, number, number, number];
/** https://url.spec.whatwg.org/#url-class */
export class URL {
constructor(url: string, base?: string | URL);
get href(): string;
set href(V: string);
get origin(): string;
get protocol(): string;
set protocol(V: string);
get username(): string;
set username(V: string);
get password(): string;
set password(V: string);
get host(): string;
set host(V: string);
get hostname(): string;
set hostname(V: string);
get port(): string;
set port(V: string);
get pathname(): string;
set pathname(V: string);
get search(): string;
set search(V: string);
get searchParams(): URLSearchParams;
get hash(): string;
set hash(V: string);
toJSON(): string;
readonly [Symbol.toStringTag]: "URL";
}
/** https://url.spec.whatwg.org/#interface-urlsearchparams */
export class URLSearchParams {
constructor(
init?:
| ReadonlyArray<readonly [name: string, value: string]>
| Iterable<readonly [name: string, value: string]>
| { readonly [name: string]: string }
| string,
);
append(name: string, value: string): void;
delete(name: string): void;
get(name: string): string | null;
getAll(name: string): string[];
has(name: string): boolean;
set(name: string, value: string): void;
sort(): void;
keys(): IterableIterator<string>;
values(): IterableIterator<string>;
entries(): IterableIterator<[name: string, value: string]>;
forEach<THIS_ARG = void>(
callback: (this: THIS_ARG, value: string, name: string, searchParams: this) => void,
thisArg?: THIS_ARG,
): void;
readonly [Symbol.toStringTag]: "URLSearchParams";
[Symbol.iterator](): IterableIterator<[name: string, value: string]>;
}
/** https://url.spec.whatwg.org/#concept-url-parser */
export function parseURL(input: string, options?: { readonly baseURL?: URLRecord | undefined }): URLRecord | null;
/** https://url.spec.whatwg.org/#concept-basic-url-parser */
export function basicURLParse(
input: string,
options?: {
baseURL?: URLRecord | undefined;
url?: URLRecord | undefined;
stateOverride?: StateOverride | undefined;
},
): URLRecord | null;
/** https://url.spec.whatwg.org/#scheme-start-state */
export type StateOverride =
| "scheme start"
| "scheme"
| "no scheme"
| "special relative or authority"
| "path or authority"
| "relative"
| "relative slash"
| "special authority slashes"
| "special authority ignore slashes"
| "authority"
| "host"
| "hostname"
| "port"
| "file"
| "file slash"
| "file host"
| "path start"
| "path"
| "opaque path"
| "query"
| "fragment";
/** https://url.spec.whatwg.org/#concept-url-serializer */
export function serializeURL(urlRecord: URLRecord, excludeFragment?: boolean): string;
/** https://url.spec.whatwg.org/#concept-host-serializer */
export function serializeHost(host: string | number | IPv6Address): string;
/** https://url.spec.whatwg.org/#url-path-serializer */
export function serializePath(urlRecord: URLRecord): string;
/** https://url.spec.whatwg.org/#serialize-an-integer */
export function serializeInteger(number: number): string;
/** https://html.spec.whatwg.org#ascii-serialisation-of-an-origin */
export function serializeURLOrigin(urlRecord: URLRecord): string;
/** https://url.spec.whatwg.org/#set-the-username */
export function setTheUsername(urlRecord: URLRecord, username: string): void;
/** https://url.spec.whatwg.org/#set-the-password */
export function setThePassword(urlRecord: URLRecord, password: string): void;
/** https://url.spec.whatwg.org/#url-opaque-path */
export function hasAnOpaquePath(urlRecord: URLRecord): boolean;
/** https://url.spec.whatwg.org/#cannot-have-a-username-password-port */
export function cannotHaveAUsernamePasswordPort(urlRecord: URLRecord): boolean;
/** https://url.spec.whatwg.org/#percent-decode */
export function percentDecodeBytes(buffer: TypedArray): Uint8Array;
/** https://url.spec.whatwg.org/#percent-decode-string */
export function percentDecodeString(string: string): Uint8Array;
export type TypedArray =
| Uint8Array
| Uint8ClampedArray
| Uint16Array
| Uint32Array
| Int8Array
| Int16Array
| Int32Array
| Float32Array
| Float64Array;

View file

@ -0,0 +1,22 @@
import { Globals } from "webidl-conversions";
import { implementation as URLSearchParamsImpl } from "./URLSearchParams-impl";
declare class URLImpl {
constructor(globalObject: Globals, constructorArgs: readonly [url: string, base?: string]);
href: string;
readonly origin: string;
protocol: string;
username: string;
password: string;
host: string;
hostname: string;
port: string;
pathname: string;
search: string;
readonly searchParams: URLSearchParamsImpl;
hash: string;
toJSON(): string;
}
export { URLImpl as implementation };

Some files were not shown because too many files have changed in this diff Show more