From efbb642a6d8a2353ca587d220e810b9c93b91c22 Mon Sep 17 00:00:00 2001 From: Angelo Reale <12191809+angeloreale@users.noreply.github.com> Date: Sat, 10 Feb 2024 13:39:18 +0100 Subject: [PATCH 01/12] ar(feat) update action types --- .eslintignore | 3 +- lib/actions/actions-init.tsx | 12 +++++- lib/actions/db-users-actions.tsx | 2 +- lib/model/interfaces/mdb-init-interface.ts | 2 +- lib/model/mdb-connector.ts | 2 +- lib/types/actions.d.ts | 42 +++++++++++-------- lib/types/index.ts | 8 ++-- .../molecules/divider/client/divider-view.tsx | 15 +++++++ .../divider/client/divider.module.css | 8 ++++ .../system/molecules/divider/client/index.ts | 2 + .../system/molecules/divider/divider.tsx | 9 ++++ .../system/molecules/divider/index.ts | 2 + .../divider/server/divider-controller.tsx | 16 +++++++ .../system/molecules/divider/server/index.ts | 2 + src/app/components/system/molecules/index.ts | 4 ++ tsconfig.json | 2 +- 16 files changed, 103 insertions(+), 28 deletions(-) create mode 100644 src/app/components/system/molecules/divider/client/divider-view.tsx create mode 100644 src/app/components/system/molecules/divider/client/divider.module.css create mode 100644 src/app/components/system/molecules/divider/client/index.ts create mode 100644 src/app/components/system/molecules/divider/divider.tsx create mode 100644 src/app/components/system/molecules/divider/index.ts create mode 100644 src/app/components/system/molecules/divider/server/divider-controller.tsx create mode 100644 src/app/components/system/molecules/divider/server/index.ts create mode 100644 src/app/components/system/molecules/index.ts diff --git a/.eslintignore b/.eslintignore index 28f92eb7..ce55757a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,4 +5,5 @@ # temporary system/ components/ -nsx/ \ No newline at end of file +nsx/ +mock/ \ No newline at end of file diff --git a/lib/actions/actions-init.tsx b/lib/actions/actions-init.tsx index 59f0baa3..9c388e67 100644 --- a/lib/actions/actions-init.tsx +++ b/lib/actions/actions-init.tsx @@ -1,14 +1,22 @@ // actions-init.tsx /* eslint-disable react-hooks/exhaustive-deps, react-hooks/rules-of-hooks */ 'use client'; -import type { ISupportedContexts, IActionBack, IAction, IStatus, ICreateAction, IDispatch, IPayload } from '@types'; +import type { + ISupportedContexts, + IActionBack, + IActionDispatch, + IStatus, + ICreateAction, + IDispatch, + IPayload, +} from '@types'; import { createLogMessage, fluxLog as log } from '@log'; import { useState, useEffect, useContext, useRef } from 'react'; export const CreateAction: ICreateAction = ({ action, type, verb, context }: IActionBack) => - ({ cb }: IAction) => { + ({ cb }: IActionDispatch) => { // eslint-disable-next-line @typescript-eslint/no-unused-vars const noop: IDispatch = async (...payload: IPayload): Promise => {}; diff --git a/lib/actions/db-users-actions.tsx b/lib/actions/db-users-actions.tsx index 8b68bed8..9b22d2e8 100644 --- a/lib/actions/db-users-actions.tsx +++ b/lib/actions/db-users-actions.tsx @@ -9,7 +9,7 @@ import { AuthContext } from '@state'; /* public */ export const ALoadUserMeta = BuildAction(CreateAction, { action: 'hydrate', - type: 'users', + type: 'database', verb: 'load user meta', context: AuthContext, }); diff --git a/lib/model/interfaces/mdb-init-interface.ts b/lib/model/interfaces/mdb-init-interface.ts index 3f238658..966fc9cd 100644 --- a/lib/model/interfaces/mdb-init-interface.ts +++ b/lib/model/interfaces/mdb-init-interface.ts @@ -44,7 +44,7 @@ oplog._.decorateLog = ({ type, action, verb, status, message, priority }) => { // console.log("@@@ decorating log @@@") if (!messageState.get) return { type, action, verb, status, message, priority }; const statusMessage: ILogContext = { - type: type || 'mongodb', + type: type || 'database', action: action || messageState.get().action, verb: verb || messageState.get().verb, status: status || messageState.get().status, diff --git a/lib/model/mdb-connector.ts b/lib/model/mdb-connector.ts index 0beabade..8b7e4cbd 100644 --- a/lib/model/mdb-connector.ts +++ b/lib/model/mdb-connector.ts @@ -37,7 +37,7 @@ const genPromise = (name = '') => { } log({ - type: 'connector', + type: 'database', action: 'init', verb: 'connect', status: 'connecting-to', diff --git a/lib/types/actions.d.ts b/lib/types/actions.d.ts index 72f8f424..de282028 100644 --- a/lib/types/actions.d.ts +++ b/lib/types/actions.d.ts @@ -1,24 +1,32 @@ // actions.d.ts import type { Context } from 'react'; -export type ActionT = 'init' | 'login' | 'logout' | 'hydrate' | 'update_db' | 'schema-enforcing'; -export type ActionTypes = 'init' | 'auth' | 'rickmorty' | string; -export type ActionAuthNames = - | 'load user' - | 'load user meta' - | 'unload user' - | 'load characters' - | 'unload characters' - | 'decorate characters' - | 'add char to favorites'; - -export type ActionDBNames = 'database' | 'collection' | 'relations' | 'connect'; +export type _NexusIAction = 'update_db' | 'schema-enforcing'; +export type NexusIAction = 'init' | 'login' | 'logout' | 'hydrate'; +export type CommonIAction = 'like'; +export type RMIActionypes = CommonIAction<'like'>; +export type IActionTypes = NexusIAction | RMIActionypes; + +export type NexusActionContexts = 'init' | 'auth' | 'ubiquity' | 'database'; +export type ServicesActionContexts = 'rickmorty' | 'image-uploader'; +export type ActionContexts = NexusActionContexts | ServicesActionContexts; + +export type ActionAuthVerbs = 'load user' | 'load user meta' | 'unload user'; +export type ActionDBVerbs = 'database' | 'collection' | 'relations' | 'connect'; +export type ActionRMVerbs = 'load characters' | 'unload characters' | 'decorate characters' | 'add char to favorites'; + +export type ActionVerbs = ActionAuthVerbs | ActionRMVerbs | ActionDBVerbs; + +export interface IAction { + action: IActionTypes; + type: ActionContexts; +} export type ISupportedContexts = IAuthContext | IRMContext | ILogContext; export interface ILogContext { - action?: ActionT; - type?: ActionTypes; - verb?: ActionAuthNames | ActionDBNames; + action?: IActionTypes; + type?: ActionContexts; + verb?: ActionVerbs; status?: string; message?: string; category?: string; @@ -47,7 +55,7 @@ export interface IActionBack extends ILogContext { context: Context; } -export interface IAction { +export interface IActionDispatch { cb?: Array<() => void>; } @@ -76,7 +84,7 @@ export interface IACharacterPayload { cid?: number; } -export type ICreateAction = (options: IActionBack) => (_options: IAction) => [boolean | undefined, IDispatch]; +export type ICreateAction = (options: IActionBack) => (_options: IActionDispatch) => [boolean | undefined, IDispatch]; export type IAPayload = IALoginPayload | IACharacterPayload; export type IDPayload = IDAddToFavPayload; diff --git a/lib/types/index.ts b/lib/types/index.ts index 79b539ee..878aaa2a 100644 --- a/lib/types/index.ts +++ b/lib/types/index.ts @@ -8,12 +8,12 @@ export type { UserSchema, User, UserDecoration, OrgDecoration, IFeature } from ' // actions export type { - ActionT, - ActionTypes, - ActionAuthNames, + IAction, + IActionTypes, + ActionAuthVerbs, ISupportedContexts, + IActionDispatch, IActionBack, - IAction, IStatus, IALoginPayload, IDAddToFavPayload, diff --git a/src/app/components/system/molecules/divider/client/divider-view.tsx b/src/app/components/system/molecules/divider/client/divider-view.tsx new file mode 100644 index 00000000..857f3395 --- /dev/null +++ b/src/app/components/system/molecules/divider/client/divider-view.tsx @@ -0,0 +1,15 @@ +// @atoms/button-view.tsx +'use client'; +import { clsx } from "clsx" +import styles from "./divider.module.css" + +interface VDividerProps extends React.HTMLProps { +} + +export const NVDivider = ({ children, ...regularHtmlProps }: VDividerProps) => { + const classes = clsx({ + [styles.nexus__divider]: regularHtmlProps.type !== "hidden", + }) + /* remember server/client isomorphism */ + return
; +}; diff --git a/src/app/components/system/molecules/divider/client/divider.module.css b/src/app/components/system/molecules/divider/client/divider.module.css new file mode 100644 index 00000000..645a7f15 --- /dev/null +++ b/src/app/components/system/molecules/divider/client/divider.module.css @@ -0,0 +1,8 @@ +/* button.module.css */ +.nexus__divider { +widht: 100; +color: var(--nexus-main-fg); +border: 1px solid var(--nexus-main-fg); +margin-top: 32px; +margin-bottom: 32px; +} diff --git a/src/app/components/system/molecules/divider/client/index.ts b/src/app/components/system/molecules/divider/client/index.ts new file mode 100644 index 00000000..3de86ad7 --- /dev/null +++ b/src/app/components/system/molecules/divider/client/index.ts @@ -0,0 +1,2 @@ +// @atoms/button/client/index.ts +export { NVDivider } from './divider-view'; diff --git a/src/app/components/system/molecules/divider/divider.tsx b/src/app/components/system/molecules/divider/divider.tsx new file mode 100644 index 00000000..52efb346 --- /dev/null +++ b/src/app/components/system/molecules/divider/divider.tsx @@ -0,0 +1,9 @@ +// button.tsx +'use server'; +import { NCInput } from './server'; + +export const Input = () => { + return
+ +
; +}; diff --git a/src/app/components/system/molecules/divider/index.ts b/src/app/components/system/molecules/divider/index.ts new file mode 100644 index 00000000..7235373c --- /dev/null +++ b/src/app/components/system/molecules/divider/index.ts @@ -0,0 +1,2 @@ +// index.ts +export { NVDivider as Divider } from './client'; diff --git a/src/app/components/system/molecules/divider/server/divider-controller.tsx b/src/app/components/system/molecules/divider/server/divider-controller.tsx new file mode 100644 index 00000000..7a4312a9 --- /dev/null +++ b/src/app/components/system/molecules/divider/server/divider-controller.tsx @@ -0,0 +1,16 @@ +// // @atoms/button-controller.ts +// 'use server'; +// // import "server-only" + +// // import type { UserSchema } from "@types" +// // import { NVButton } from "./button-view"; + +// interface NCButtonProps {} + +// export const NCButton = async ({}: NCButtonProps) => { +// console.log('--- button controller'); +// // const props: ISignInData = await getProvidersData(); +// // const providers: IAuthProviders[] = props?.providers || []; +// return
LOREM SERVER
; +// // return ; +// }; diff --git a/src/app/components/system/molecules/divider/server/index.ts b/src/app/components/system/molecules/divider/server/index.ts new file mode 100644 index 00000000..996545f2 --- /dev/null +++ b/src/app/components/system/molecules/divider/server/index.ts @@ -0,0 +1,2 @@ +// // @atoms/button/server/index.ts +// export { NCButton } from './button-controller'; diff --git a/src/app/components/system/molecules/index.ts b/src/app/components/system/molecules/index.ts new file mode 100644 index 00000000..636562ec --- /dev/null +++ b/src/app/components/system/molecules/index.ts @@ -0,0 +1,4 @@ +// @atoms/index.ts +export { Button } from './button' +export { Input } from './input' +export { Divider } from './divider' \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index a679384e..d2576657 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -51,5 +51,5 @@ }, }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules", "**/nsx/**/*", "**/system/**/*"], + "exclude": ["node_modules", "**/nsx/**/*", "**/system/**/*", "**/mock/**/*"], } From ff47cc40358c99164aa9947c58ab2dc03b8120df Mon Sep 17 00:00:00 2001 From: Angelo Reale <12191809+angeloreale@users.noreply.github.com> Date: Sat, 10 Feb 2024 13:44:21 +0100 Subject: [PATCH 02/12] ar(feat) add authorization types --- lib/types/authorization.d.ts | 25 +++++++++++++++++++++++++ lib/types/index.ts | 3 +++ 2 files changed, 28 insertions(+) create mode 100644 lib/types/authorization.d.ts diff --git a/lib/types/authorization.d.ts b/lib/types/authorization.d.ts new file mode 100644 index 00000000..af2a9ec8 --- /dev/null +++ b/lib/types/authorization.d.ts @@ -0,0 +1,25 @@ +// authorization.d.ts +import type { IAction } from '@types'; + +export interface IAbility { + actions: IAction[]; + roles: Record[]; + name: string; + status: EAbilityStatus; +} + +export enum EAbilityStatus { + 'inactive' = 0, + 'active' = 1, + 'deprecated' = 2, +} + +export enum EUserOrgRoles { + 'SUPERUSER' = 0, + 'ADMIN' = 1, + 'MANAGER' = 2, + 'PRODUCER' = 3, + 'MEMBER' = 4, + 'SPECTATOR' = 5, + 'EVERYONE' = 6, +} diff --git a/lib/types/index.ts b/lib/types/index.ts index 878aaa2a..f9c35cc3 100644 --- a/lib/types/index.ts +++ b/lib/types/index.ts @@ -28,5 +28,8 @@ export type { ILogger, } from './actions'; +// authorization +export type { IAbility, EAbilityStatus, EUserOrgRoles } from './authorization'; + // system export type { Tposition, TpositionX, TpositionY, Tsize, Tthemes } from './atoms'; From 14c1da538642aaa8bcf6253b11b3338377db1682 Mon Sep 17 00:00:00 2001 From: Angelo Reale <12191809+angeloreale@users.noreply.github.com> Date: Sat, 10 Feb 2024 14:01:01 +0100 Subject: [PATCH 03/12] ar(feat) add services types --- lib/types/currencies.d.ts | 206 ++++++++++++++++++++++++++ lib/types/index.ts | 5 +- lib/types/model.d.ts | 294 -------------------------------------- lib/types/services.d.ts | 79 ++++++++++ 4 files changed, 289 insertions(+), 295 deletions(-) create mode 100644 lib/types/currencies.d.ts create mode 100644 lib/types/services.d.ts diff --git a/lib/types/currencies.d.ts b/lib/types/currencies.d.ts new file mode 100644 index 00000000..ff5817b8 --- /dev/null +++ b/lib/types/currencies.d.ts @@ -0,0 +1,206 @@ +// currencies.d.ts +/* trad + IMPORTANT: still need to be completely validated + */ + +export enum ETraditionalCurrencies { + AED = 'United Arab Emirates Dirham', + AFN = 'Afghan Afghani', + ALL = 'Albanian Lek', + AMD = 'Armenian Dram', + ANG = 'Netherlands Antillean Guilder', + AOA = 'Angolan Kwanza', + ARS = 'Argentine Peso', + AUD = 'Australian Dollar', + AWG = 'Aruban Florin', + AZN = 'Azerbaijani Manat', + BAM = 'Bosnia-Herzegovina Convertible Mark', + BBD = 'Barbadian Dollar', + BDT = 'Bangladeshi Taka', + BGN = 'Bulgarian Lev', + BHD = 'Bahraini Dinar', + BIF = 'Burundian Franc', + BMD = 'Bermudian Dollar', + BND = 'Brunei Dollar', + BOB = 'Bolivian Boliviano', + BRL = 'Brazilian Real', + BSD = 'Bahamian Dollar', + BTN = 'Bhutanese Ngultrum', + BWP = 'Botswanan Pula', + BYN = 'Belarusian Ruble', + BZD = 'Belize Dollar', + CAD = 'Canadian Dollar', + CDF = 'Congolese Franc', + CHF = 'Swiss Franc', + CLP = 'Chilean Peso', + CNY = 'Chinese Yuan', + COP = 'Colombian Peso', + CRC = 'Costa Rican Colón', + CUP = 'Cuban Peso', + CVE = 'Cape Verdean Escudo', + CZK = 'Czech Republic Koruna', + DJF = 'Djiboutian Franc', + DKK = 'Danish Krone', + DOP = 'Dominican Peso', + DZD = 'Algerian Dinar', + EGP = 'Egyptian Pound', + ERN = 'Eritrean Nakfa', + ETB = 'Ethiopian Birr', + EUR = 'Euro', + FJD = 'Fijian Dollar', + FKP = 'Falkland Islands Pound', + FOK = 'Faroese Króna', + FXP = 'Metropolitan France Franc', + GEL = 'Georgian Lari', + GGP = 'Guernsey Pound', + GHS = 'Ghanaian Cedi', + GIP = 'Gibraltar Pound', + GMD = 'Gambian Dalasi', + GNF = 'Guinean Franc', + GTQ = 'Guatemalan Quetzal', + GYD = 'Guyanaese Dollar', + HKD = 'Hong Kong Dollar', + HNL = 'Honduran Lempira', + HRK = 'Croatian Kuna', + HTG = 'Haitian Gourde', + HUF = 'Hungarian Forint', + IDR = 'Indonesian Rupiah', + ILS = 'Israeli New Shekel', + IMP = 'Isle of Man Pound', + INR = 'Indian Rupee', + IQD = 'Iraqi Dinar', + IRR = 'Iranian Rial', + ISK = 'Icelandic Króna', + JEP = 'Jersey Pound', + JMD = 'Jamaican Dollar', + JOD = 'Jordanian Dinar', + JPY = 'Japanese Yen', + KES = 'Kenyan Shilling', + KGS = 'Kyrgystani Som', + KHR = 'Cambodian Riel', + KID = 'Kiribati Dollar', + KRW = 'South Korean Won', + KWD = 'Kuwaiti Dinar', + KYD = 'Cayman Islands Dollar', + KZT = 'Kazakhstani Tenge', + LAK = 'Laotian Kip', + LBP = 'Lebanese Pound', + LKR = 'Sri Lankan Rupee', + LRD = 'Liberian Dollar', + LSL = 'Lesotho Loti', + LYD = 'Libyan Dinar', + MAD = 'Moroccan Dirham', + MDL = 'Moldovan Leu', + MGA = 'Malagasy Ariary', + MKD = 'Macedonian Denar', + MMK = 'Myanmar Kyat', + MNT = 'Mongolian Tugrik', + MOP = 'Macanese Pataca', + MRU = 'Mauritanian Ouguiya', + MUR = 'Mauritian Rupee', + MVR = 'Maldivian Rufiyaa', + MWK = 'Malawian Kwacha', + MXN = 'Mexican Peso', + MYR = 'Malaysian Ringgit', + MZN = 'Mozambican Metical', + NAD = 'Namibian Dollar', + NGN = 'Nigerian Naira', + NIO = 'Nicaraguan Córdoba', + NOK = 'Norwegian Krone', + NPR = 'Nepalese Rupee', + NZD = 'New Zealand Dollar', + OMR = 'Omani Rial', + PAB = 'Panamanian Balboa', + PEN = 'Peruvian Nuevo Sol', + PGK = 'Papua New Guinean Kina', + PHP = 'Philippine Peso', + PKR = 'Pakistani Rupee', + PLN = 'Polish Złoty', + PYG = 'Paraguayan Guarani', + QAR = 'Qatari Rial', + RON = 'Romanian Leu', + RSD = 'Serbian Dinar', + RUB = 'Russian Ruble', + RWF = 'Rwandan Franc', + SAR = 'Saudi Riyal', + SBD = 'Solomon Islands Dollar', + SCR = 'Seychellois Rupee', + SDG = 'Sudanese Pound', + SEK = 'Swedish Krona', + SGD = 'Singapore Dollar', + SHP = 'Saint Helena Pound', + SIT = 'Slovenian Tolar', + SKK = 'Slovak Koruna', + SLL = 'Sierra Leonean Leone', + SOS = 'Somali Shilling', + SRD = 'Surinamese Dollar', + SSP = 'South Sudanese Pound', + STN = 'São Tomé and Príncipe Dobra', + SVC = 'Salvadoran Colón', + SYP = 'Syrian Pound', + SZL = 'Swazi Lilangeni', + THB = 'Thai Baht', + TJS = 'Tajikistani Somoni', + TMT = 'Turkmenistani Manat', + TND = 'Tunisian Dinar', + TOP = 'Tongan Paʻanga', + TRY = 'Turkish Lira', + TTD = 'Trinidad and Tobago Dollar', + TVD = 'Tuvaluan Dollar', + TWD = 'New Taiwan Dollar', + TZS = 'Tanzanian Shilling', + UAH = 'Ukrainian Hryvnia', + UGX = 'Ugandan Shilling', + USD = 'United States Dollar', + UYU = 'Uruguayan Peso', + UZS = 'Uzbekistan Som', + VES = 'Venezuelan Bolívar', + VND = 'Vietnamese Đồng', + VUV = 'Vanuatu Vatu', + WST = 'Samoan Tala', + XAF = 'Central African CFA franc', + XCD = 'Eastern Caribbean Dollar', + XDR = 'Special Drawing Rights', + XOF = 'West African CFA franc', + XPF = 'CFP Franc', + YER = 'Yemeni Rial', + ZAR = 'South African Rand', + ZMW = 'Zambian Kwacha', + ZWL = 'Zimbabwean Dollar', +} + +/* crypto */ +export enum ECryptoCurrencies { + ADA = 'Cardano', + ALGO = 'Algorand', + ATOM = 'Cosmos', + AVAX = 'Avalanche', + BCH = 'Bitcoin Cash', + BNB = 'Binance Coin', + BTC = 'Bitcoin', + DOT = 'Polkadot', + DOGE = 'Dogecoin', + EGLD = 'Elrond', + EOS = 'EOS.IO', + ETH = 'Ethereum', + FIL = 'Filecoin', + ICX = 'ICON', + LINK = 'Chainlink', + LTC = 'Litecoin', + MATIC = 'Polygon', + MIOTA = 'IOTA', + MKR = 'Maker', + NEO = 'NEO', + SOL = 'Solana', + TRX = 'Tron', + UNI = 'Uniswap', + USDT = 'Tether', + VET = 'VeChain', + XEM = 'NEM', + XLM = 'Stellar', + XMR = 'Monero', + XRP = 'Ripple', + XTZ = 'Tezos', + YFI = 'yearn.finance', + ZEC = 'Zcash', +} diff --git a/lib/types/index.ts b/lib/types/index.ts index f9c35cc3..b25d7ad3 100644 --- a/lib/types/index.ts +++ b/lib/types/index.ts @@ -4,7 +4,7 @@ export type { IAuthContext, IRMContext, INCharacter, IDCharacter, History } from './contexts'; // model -export type { UserSchema, User, UserDecoration, OrgDecoration, IFeature } from './model'; +export type { UserSchema, User, UserDecoration, OrgDecoration } from './model'; // actions export type { @@ -31,5 +31,8 @@ export type { // authorization export type { IAbility, EAbilityStatus, EUserOrgRoles } from './authorization'; +// services +export type { IFeature } from './services'; + // system export type { Tposition, TpositionX, TpositionY, Tsize, Tthemes } from './atoms'; diff --git a/lib/types/model.d.ts b/lib/types/model.d.ts index 53dce7da..0b71da11 100644 --- a/lib/types/model.d.ts +++ b/lib/types/model.d.ts @@ -35,22 +35,6 @@ export interface OrgDecoration { }; } -export enum EUserOrgRoles { - 'SUPERUSER' = 0, - 'ADMIN' = 1, - 'MANAGER' = 2, - 'PRODUCER' = 3, - 'MEMBER' = 4, - 'SPECTATOR' = 5, -} - -export interface DUserOrgAmbiRelation { - role: EUserOrgRoles[]; - _id: ObjectID /* uid */; - org: string; - name: string; -} - export type IAddress = PostalAddress; /* nexus db: billing collection */ @@ -79,79 +63,6 @@ export enum EBillingCycles { } /* org db: projects collection */ -export interface IProject { - _id: ObjectID /* pid */; - name: string; - services: DProjectServiceRelation[]; -} - -export interface DProjectOrgRelation {} - -/* nexus db: services collection */ -export enum EServiceTypes { - /* core */ - 'DCS' = 0, - 'DBS' = 1, - 'DWS' = 2, - 'DVS' = 3, - 'DFS' = 4, - /* extra */ - 'RM' = 999999999, - 'EC' = 999999998, -} - -export enum EServiceStatuses { - 'deactivated' = 0, - 'created' = 1, - 'activated' = 2, - 'enabled' = 3, - 'running' = 4, - 'paused' = 5, - 'stopped' = 6, - 'disabled' = 7, - 'deactivated' = 8, - 'deleted' = 9, - 'deliquent' = 10, -} - -export interface IService { - _id: ObjectID /* sid */; - name: string; - type: EServiceTypes; - createdOn: Date; - status: EServiceStatuses; - statusModified: Date; - cost: number; - cycle: EBillingCycles; - version: string; - features: IFeature[]; -} - -export interface IFeature { - name: string; - status: IFeatureStatus; - version: string; -} - -export enum IFeatureStatus { - 'inactive' = 0, - 'ghost' = 1, - 'active' = 2, - 'beta' = 3, - 'nightly' = 4, -} - -export interface IServiceFeatureStatus { - status: EServiceStatuses; - name: IService['name']; - sid: IService['_id']; -} - -export type DProjectServiceRelation = IServiceFeatureStatus[]; - -export interface DServiceOrgRelation { - enabled: IServiceFeatureStatus[]; -} /* nexus db: to-do: billing collection */ export interface IBillingData {} @@ -160,211 +71,6 @@ export interface DBillingOrgRelation {} /* currencies: to-do: move to a different type file */ -/* trad - IMPORTANT: still need to be completely validated - */ -export enum ETraditionalCurrencies { - AED = 'United Arab Emirates Dirham', - AFN = 'Afghan Afghani', - ALL = 'Albanian Lek', - AMD = 'Armenian Dram', - ANG = 'Netherlands Antillean Guilder', - AOA = 'Angolan Kwanza', - ARS = 'Argentine Peso', - AUD = 'Australian Dollar', - AWG = 'Aruban Florin', - AZN = 'Azerbaijani Manat', - BAM = 'Bosnia-Herzegovina Convertible Mark', - BBD = 'Barbadian Dollar', - BDT = 'Bangladeshi Taka', - BGN = 'Bulgarian Lev', - BHD = 'Bahraini Dinar', - BIF = 'Burundian Franc', - BMD = 'Bermudian Dollar', - BND = 'Brunei Dollar', - BOB = 'Bolivian Boliviano', - BRL = 'Brazilian Real', - BSD = 'Bahamian Dollar', - BTN = 'Bhutanese Ngultrum', - BWP = 'Botswanan Pula', - BYN = 'Belarusian Ruble', - BZD = 'Belize Dollar', - CAD = 'Canadian Dollar', - CDF = 'Congolese Franc', - CHF = 'Swiss Franc', - CLP = 'Chilean Peso', - CNY = 'Chinese Yuan', - COP = 'Colombian Peso', - CRC = 'Costa Rican Colón', - CUP = 'Cuban Peso', - CVE = 'Cape Verdean Escudo', - CZK = 'Czech Republic Koruna', - DJF = 'Djiboutian Franc', - DKK = 'Danish Krone', - DOP = 'Dominican Peso', - DZD = 'Algerian Dinar', - EGP = 'Egyptian Pound', - ERN = 'Eritrean Nakfa', - ETB = 'Ethiopian Birr', - EUR = 'Euro', - FJD = 'Fijian Dollar', - FKP = 'Falkland Islands Pound', - FOK = 'Faroese Króna', - FXP = 'Metropolitan France Franc', - GEL = 'Georgian Lari', - GGP = 'Guernsey Pound', - GHS = 'Ghanaian Cedi', - GIP = 'Gibraltar Pound', - GMD = 'Gambian Dalasi', - GNF = 'Guinean Franc', - GTQ = 'Guatemalan Quetzal', - GYD = 'Guyanaese Dollar', - HKD = 'Hong Kong Dollar', - HNL = 'Honduran Lempira', - HRK = 'Croatian Kuna', - HTG = 'Haitian Gourde', - HUF = 'Hungarian Forint', - IDR = 'Indonesian Rupiah', - ILS = 'Israeli New Shekel', - IMP = 'Isle of Man Pound', - INR = 'Indian Rupee', - IQD = 'Iraqi Dinar', - IRR = 'Iranian Rial', - ISK = 'Icelandic Króna', - JEP = 'Jersey Pound', - JMD = 'Jamaican Dollar', - JOD = 'Jordanian Dinar', - JPY = 'Japanese Yen', - KES = 'Kenyan Shilling', - KGS = 'Kyrgystani Som', - KHR = 'Cambodian Riel', - KID = 'Kiribati Dollar', - KRW = 'South Korean Won', - KWD = 'Kuwaiti Dinar', - KYD = 'Cayman Islands Dollar', - KZT = 'Kazakhstani Tenge', - LAK = 'Laotian Kip', - LBP = 'Lebanese Pound', - LKR = 'Sri Lankan Rupee', - LRD = 'Liberian Dollar', - LSL = 'Lesotho Loti', - LYD = 'Libyan Dinar', - MAD = 'Moroccan Dirham', - MDL = 'Moldovan Leu', - MGA = 'Malagasy Ariary', - MKD = 'Macedonian Denar', - MMK = 'Myanmar Kyat', - MNT = 'Mongolian Tugrik', - MOP = 'Macanese Pataca', - MRU = 'Mauritanian Ouguiya', - MUR = 'Mauritian Rupee', - MVR = 'Maldivian Rufiyaa', - MWK = 'Malawian Kwacha', - MXN = 'Mexican Peso', - MYR = 'Malaysian Ringgit', - MZN = 'Mozambican Metical', - NAD = 'Namibian Dollar', - NGN = 'Nigerian Naira', - NIO = 'Nicaraguan Córdoba', - NOK = 'Norwegian Krone', - NPR = 'Nepalese Rupee', - NZD = 'New Zealand Dollar', - OMR = 'Omani Rial', - PAB = 'Panamanian Balboa', - PEN = 'Peruvian Nuevo Sol', - PGK = 'Papua New Guinean Kina', - PHP = 'Philippine Peso', - PKR = 'Pakistani Rupee', - PLN = 'Polish Złoty', - PYG = 'Paraguayan Guarani', - QAR = 'Qatari Rial', - RON = 'Romanian Leu', - RSD = 'Serbian Dinar', - RUB = 'Russian Ruble', - RWF = 'Rwandan Franc', - SAR = 'Saudi Riyal', - SBD = 'Solomon Islands Dollar', - SCR = 'Seychellois Rupee', - SDG = 'Sudanese Pound', - SEK = 'Swedish Krona', - SGD = 'Singapore Dollar', - SHP = 'Saint Helena Pound', - SIT = 'Slovenian Tolar', - SKK = 'Slovak Koruna', - SLL = 'Sierra Leonean Leone', - SOS = 'Somali Shilling', - SRD = 'Surinamese Dollar', - SSP = 'South Sudanese Pound', - STN = 'São Tomé and Príncipe Dobra', - SVC = 'Salvadoran Colón', - SYP = 'Syrian Pound', - SZL = 'Swazi Lilangeni', - THB = 'Thai Baht', - TJS = 'Tajikistani Somoni', - TMT = 'Turkmenistani Manat', - TND = 'Tunisian Dinar', - TOP = 'Tongan Paʻanga', - TRY = 'Turkish Lira', - TTD = 'Trinidad and Tobago Dollar', - TVD = 'Tuvaluan Dollar', - TWD = 'New Taiwan Dollar', - TZS = 'Tanzanian Shilling', - UAH = 'Ukrainian Hryvnia', - UGX = 'Ugandan Shilling', - USD = 'United States Dollar', - UYU = 'Uruguayan Peso', - UZS = 'Uzbekistan Som', - VES = 'Venezuelan Bolívar', - VND = 'Vietnamese Đồng', - VUV = 'Vanuatu Vatu', - WST = 'Samoan Tala', - XAF = 'Central African CFA franc', - XCD = 'Eastern Caribbean Dollar', - XDR = 'Special Drawing Rights', - XOF = 'West African CFA franc', - XPF = 'CFP Franc', - YER = 'Yemeni Rial', - ZAR = 'South African Rand', - ZMW = 'Zambian Kwacha', - ZWL = 'Zimbabwean Dollar', -} - -/* crypto */ -export enum ECryptoCurrencies { - ADA = 'Cardano', - ALGO = 'Algorand', - ATOM = 'Cosmos', - AVAX = 'Avalanche', - BCH = 'Bitcoin Cash', - BNB = 'Binance Coin', - BTC = 'Bitcoin', - DOT = 'Polkadot', - DOGE = 'Dogecoin', - EGLD = 'Elrond', - EOS = 'EOS.IO', - ETH = 'Ethereum', - FIL = 'Filecoin', - ICX = 'ICON', - LINK = 'Chainlink', - LTC = 'Litecoin', - MATIC = 'Polygon', - MIOTA = 'IOTA', - MKR = 'Maker', - NEO = 'NEO', - SOL = 'Solana', - TRX = 'Tron', - UNI = 'Uniswap', - USDT = 'Tether', - VET = 'VeChain', - XEM = 'NEM', - XLM = 'Stellar', - XMR = 'Monero', - XRP = 'Ripple', - XTZ = 'Tezos', - YFI = 'yearn.finance', - ZEC = 'Zcash', -} - export type ECurrency = ETraditionalCurrencies | ECryptoCurrencies; // Example usage diff --git a/lib/types/services.d.ts b/lib/types/services.d.ts new file mode 100644 index 00000000..4d660ff7 --- /dev/null +++ b/lib/types/services.d.ts @@ -0,0 +1,79 @@ +// services.d.ts +import type { IAbility } from '@ types'; + +export enum EServiceTypes { + /* core */ + 'DCS' = 0, + 'DBS' = 1, + 'DWS' = 2, + 'DVS' = 3, + 'DFS' = 4, + /* extra */ + 'RM' = 999999999, + 'EC' = 999999998, +} + +export enum EServiceStatuses { + 'deactivated' = 0, + 'created' = 1, + 'active' = 2, + 'enabled' = 3, + 'running' = 4, + 'paused' = 5, + 'stopped' = 6, + 'disabled' = 7, + 'inactive' = 8, + 'deleted' = 9, + 'delinquent' = 10, +} + +export interface IService { + _id: ObjectID /* sid */; + name: string; + type: Record; + createdOn: Date; + status: Record; + statusModified: Date; + // cost: number; + // cycle: EBillingCycles; + version: string; + features: IFeature[]; +} + +/* facading sensitive service-> org data */ +export interface IServiceUserAmbiRelation { + _id: ObjectID /* sid */; + name: string; + type: EServiceTypes; + status: EServiceStatuses; + statusModified: Date; + version: string; + features: IFeature[]; + projects: DProjectServiceRelation[]; +} + +/* features */ +export interface IFeature { + name: string; + status: Record; + version: string; + abilities: IAbility[]; +} + +export enum EFeatureStatus { + 'inactive' = 0, + 'ghost' = 1, + 'active' = 2, + 'beta' = 3, + 'nightly' = 4, +} + +export interface IProject { + name: string; + status: Record; + service: IService<'name'>; + sid: IService<'_id'>; +} + +export type DProjectOrgRelation = IProject[]; +export type DServiceOrgRelation = IService[]; From 35b475f4517be255a26bbdd048b47a37000defea Mon Sep 17 00:00:00 2001 From: Angelo Reale <12191809+angeloreale@users.noreply.github.com> Date: Sat, 10 Feb 2024 14:09:01 +0100 Subject: [PATCH 04/12] ar(feat) update users types --- lib/types/currencies.d.ts | 2 ++ lib/types/index.ts | 7 +++++-- lib/types/model.d.ts | 21 +-------------------- lib/types/users.d.ts | 30 ++++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 22 deletions(-) create mode 100644 lib/types/users.d.ts diff --git a/lib/types/currencies.d.ts b/lib/types/currencies.d.ts index ff5817b8..12a7138c 100644 --- a/lib/types/currencies.d.ts +++ b/lib/types/currencies.d.ts @@ -204,3 +204,5 @@ export enum ECryptoCurrencies { YFI = 'yearn.finance', ZEC = 'Zcash', } + +export type ECurrency = ETraditionalCurrencies | ECryptoCurrencies; diff --git a/lib/types/index.ts b/lib/types/index.ts index b25d7ad3..ea908f1d 100644 --- a/lib/types/index.ts +++ b/lib/types/index.ts @@ -4,7 +4,10 @@ export type { IAuthContext, IRMContext, INCharacter, IDCharacter, History } from './contexts'; // model -export type { UserSchema, User, UserDecoration, OrgDecoration } from './model'; +export type { OrgDecoration } from './model'; + +// users +export type { UserSchema, User, UserDecoration } from './users'; // actions export type { @@ -32,7 +35,7 @@ export type { export type { IAbility, EAbilityStatus, EUserOrgRoles } from './authorization'; // services -export type { IFeature } from './services'; +export type { IFeature, IProject, IServiceUserAmbiRelation } from './services'; // system export type { Tposition, TpositionX, TpositionY, Tsize, Tthemes } from './atoms'; diff --git a/lib/types/model.d.ts b/lib/types/model.d.ts index 0b71da11..cab6304f 100644 --- a/lib/types/model.d.ts +++ b/lib/types/model.d.ts @@ -1,26 +1,11 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ // IMPORTANT: above rule is temporary ^, until file split + schema wrap // model.d.ts -import type { User } from 'next-auth'; -import type { INCharacter } from '@types'; +import type { INCharacter, DUserOrgAmbiRelation } from '@types'; import type { ObjectID } from 'mongodb'; import type { PostalAddress } from '@types/json-schmea'; -export { User }; - /* nexus db */ -export interface UserDecoration { - _id?: ObjectID /* uid */; - /* temp optional */ - username?: string; - bio?: string; - organizations: DUserOrgAmbiRelation[]; - rickmorty: { - favorites: { - characters: INCharacter['id'][]; - }; - }; -} export interface OrgDecoration { _id?: ObjectID /* uid */; @@ -69,10 +54,6 @@ export interface IBillingData {} export interface DBillingOrgRelation {} -/* currencies: to-do: move to a different type file */ - -export type ECurrency = ETraditionalCurrencies | ECryptoCurrencies; - // Example usage // const usdCurrency: TraditionalCurrencies = TraditionalCurrencies.USD; // const btcCryptocurrency: Cryptocurrencies = Cryptocurrencies.BTC; diff --git a/lib/types/users.d.ts b/lib/types/users.d.ts new file mode 100644 index 00000000..e3d04210 --- /dev/null +++ b/lib/types/users.d.ts @@ -0,0 +1,30 @@ +// users.d.ts +import type { IProject, IServiceUserAmbiRelation, IAbility, EUserOrgRoles, INCharacter } from '@types'; +import type { User } from 'next-auth'; +export { User }; + +export interface UserDecoration { + /* email comes from next auth */ + _id?: ObjectID /* uid */; + /* temp optional */ + username?: string; + bio?: string; + organizations: DUserOrgAmbiRelation[]; + rickmorty: { + favorites: { + characters: INCharacter['id'][]; + }; + }; +} + +export interface DUserOrgAmbiRelation { + role: EUserOrgRoles[]; + abilities: IAbility[]; + services: IServiceUserAmbiRelation[]; + projects: IProject[]; + _id: ObjectID /* uid */; + org: string; + user: string; +} + +export interface UserSchema extends User, UserDecoration {} From b79ec50b4dc9baa7aeb8ab366b6deacf172527bc Mon Sep 17 00:00:00 2001 From: Angelo Reale <12191809+angeloreale@users.noreply.github.com> Date: Sat, 10 Feb 2024 14:15:55 +0100 Subject: [PATCH 05/12] ar(feat) update orgs typesdefault schema --- lib/model/interfaces/mdb-init-interface.ts | 9 +++++ lib/types/index.ts | 5 ++- lib/types/model.d.ts | 39 ---------------------- lib/types/orgs.d.ts | 27 +++++++++++++++ 4 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 lib/types/orgs.d.ts diff --git a/lib/model/interfaces/mdb-init-interface.ts b/lib/model/interfaces/mdb-init-interface.ts index 966fc9cd..534e2705 100644 --- a/lib/model/interfaces/mdb-init-interface.ts +++ b/lib/model/interfaces/mdb-init-interface.ts @@ -196,6 +196,15 @@ const _UserSchema: UserDecoration = { const _OrgSchema: OrgDecoration = { name: defaultOrg, members: [], + projects: { + active: [], + inactive: [], + archived: [], + }, + services: { + enabled: [], + available: [], + }, rickmorty_meta: { favorites: { characters: [] as INCharacter['id'][], diff --git a/lib/types/index.ts b/lib/types/index.ts index ea908f1d..8b3ecd17 100644 --- a/lib/types/index.ts +++ b/lib/types/index.ts @@ -4,11 +4,14 @@ export type { IAuthContext, IRMContext, INCharacter, IDCharacter, History } from './contexts'; // model -export type { OrgDecoration } from './model'; +export type {} from './model'; // users export type { UserSchema, User, UserDecoration } from './users'; +// orgs +export type { OrgDecoration } from './orgs'; + // actions export type { IAction, diff --git a/lib/types/model.d.ts b/lib/types/model.d.ts index cab6304f..bf774f26 100644 --- a/lib/types/model.d.ts +++ b/lib/types/model.d.ts @@ -1,25 +1,10 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ // IMPORTANT: above rule is temporary ^, until file split + schema wrap // model.d.ts -import type { INCharacter, DUserOrgAmbiRelation } from '@types'; -import type { ObjectID } from 'mongodb'; import type { PostalAddress } from '@types/json-schmea'; /* nexus db */ -export interface OrgDecoration { - _id?: ObjectID /* uid */; - /* temp optional */ - name?: string; - bio?: string; - members: DUserOrgAmbiRelation[]; - rickmorty_meta: { - favorites: { - characters: INCharacter['id'][]; - }; - }; -} - export type IAddress = PostalAddress; /* nexus db: billing collection */ @@ -84,27 +69,3 @@ closeOrgCap status dividend */ export interface IUserTokenData {} - -export interface DOrgUserRelation {} - -/* orgs collection */ -export interface OrgSchema { - _id: ObjectID /* oid */; - name: string; - billing: IBillingData; - krn: IOrgTokenData; - addresses: IAddress[]; - websites: string[]; - members: DUserOrgAmbiRelation[]; - projects: DProjectOrgRelation[]; - services: { - available: DServiceOrgRelation[]; - }; - rickmorty: { - favorites: { - characters: INCharacter['id'][]; - }; - }; -} - -export interface UserSchema extends User, UserDecoration {} diff --git a/lib/types/orgs.d.ts b/lib/types/orgs.d.ts new file mode 100644 index 00000000..87c229a3 --- /dev/null +++ b/lib/types/orgs.d.ts @@ -0,0 +1,27 @@ +// orgs.d.ts +import type { DUserOrgAmbiRelation, DProjectOrgRelation, DServiceOrgRelation, INCharacter } from '@types'; + +export interface OrgDecoration { + _id?: ObjectID /* uid */; + /* temp optional */ + name?: string; + // billing: IBillingData; + // krn: IOrgTokenData; + // addresses: IAddress[]; + // websites: string[]; + members: DUserOrgAmbiRelation[]; + projects: { + active: DProjectOrgRelation[]; + inactive: DProjectOrgRelation[]; + archived: DProjectOrgRelation[]; + }; + services: { + available: DServiceOrgRelation[]; + enabled: DServiceOrgRelation[]; + }; + rickmorty_meta: { + favorites: { + characters: INCharacter['id'][]; + }; + }; +} From 23db83e87fe684bab83134b76478bfd4bc9e3772 Mon Sep 17 00:00:00 2001 From: Angelo Reale <12191809+angeloreale@users.noreply.github.com> Date: Sat, 10 Feb 2024 14:19:50 +0100 Subject: [PATCH 06/12] ar(feat) finish types split --- lib/types/billing.d.ts | 31 +++++++++++++++++ lib/types/common.d.ts | 4 +++ lib/types/currencies.d.ts | 3 ++ lib/types/fincore.d.ts | 29 ++++++++++++++++ lib/types/model.d.ts | 71 --------------------------------------- 5 files changed, 67 insertions(+), 71 deletions(-) create mode 100644 lib/types/billing.d.ts create mode 100644 lib/types/common.d.ts create mode 100644 lib/types/fincore.d.ts delete mode 100644 lib/types/model.d.ts diff --git a/lib/types/billing.d.ts b/lib/types/billing.d.ts new file mode 100644 index 00000000..bfe53278 --- /dev/null +++ b/lib/types/billing.d.ts @@ -0,0 +1,31 @@ +/* eslint-disable @typescript-eslint/no-empty-interface */ +// IMPORTANT: above rule is temporary ^, until file split + schema wrap +// billing.d.ts +/* nexus db: to-do: billing collection */ + +export interface IBillingData {} + +export enum EBillingCycles { + /* core */ + '1M' = 0, + '1H' = 1, + '1D' = 2, + '1W' = 3, + '2W' = 4, + '1M' = 5, + '2M' = 6, + '1Q' = 7, + '2Q' = 8, + '3Q' = 9, + '1Y' = 10, + /* pending */ + '2Y' = 11, + '3Y' = 12, + '4Y' = 13, + '5Y' = 14, + '10Y' = 15, +} + +export interface IBillingData {} + +export interface DBillingOrgRelation {} diff --git a/lib/types/common.d.ts b/lib/types/common.d.ts new file mode 100644 index 00000000..3ddceb47 --- /dev/null +++ b/lib/types/common.d.ts @@ -0,0 +1,4 @@ +// common.d.ts +import type { PostalAddress } from '@types/json-schmea'; + +export type IAddress = PostalAddress; diff --git a/lib/types/currencies.d.ts b/lib/types/currencies.d.ts index 12a7138c..ce37b8af 100644 --- a/lib/types/currencies.d.ts +++ b/lib/types/currencies.d.ts @@ -2,6 +2,9 @@ /* trad IMPORTANT: still need to be completely validated */ +// Example usage +// const usdCurrency: TraditionalCurrencies = TraditionalCurrencies.USD; +// const btcCryptocurrency: Cryptocurrencies = Cryptocurrencies.BTC; export enum ETraditionalCurrencies { AED = 'United Arab Emirates Dirham', diff --git a/lib/types/fincore.d.ts b/lib/types/fincore.d.ts new file mode 100644 index 00000000..86ecbb08 --- /dev/null +++ b/lib/types/fincore.d.ts @@ -0,0 +1,29 @@ +/* eslint-disable @typescript-eslint/no-empty-interface */ +// IMPORTANT: above rule is temporary ^, until file split + schema wrap +// fincore.d.ts +/* nexus db: to-do: krn collection */ + +export interface IToken { + value: number; + currency: ECurrency; +} + +/* +OpenTokenValue +timeOpen +timeClose +closeTokenValue openOrgCap +closeOrgCap status +dividend +*/ +export interface IOrgTokenData {} + +/* +OpenTokenValue +timeOpen +timeClose +closeTokenValue openOrgCap +closeOrgCap status +dividend +*/ +export interface IUserTokenData {} diff --git a/lib/types/model.d.ts b/lib/types/model.d.ts deleted file mode 100644 index bf774f26..00000000 --- a/lib/types/model.d.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* eslint-disable @typescript-eslint/no-empty-interface */ -// IMPORTANT: above rule is temporary ^, until file split + schema wrap -// model.d.ts -import type { PostalAddress } from '@types/json-schmea'; - -/* nexus db */ - -export type IAddress = PostalAddress; - -/* nexus db: billing collection */ - -export interface IBillingData {} - -export enum EBillingCycles { - /* core */ - '1M' = 0, - '1H' = 1, - '1D' = 2, - '1W' = 3, - '2W' = 4, - '1M' = 5, - '2M' = 6, - '1Q' = 7, - '2Q' = 8, - '3Q' = 9, - '1Y' = 10, - /* pending */ - '2Y' = 11, - '3Y' = 12, - '4Y' = 13, - '5Y' = 14, - '10Y' = 15, -} - -/* org db: projects collection */ - -/* nexus db: to-do: billing collection */ -export interface IBillingData {} - -export interface DBillingOrgRelation {} - -// Example usage -// const usdCurrency: TraditionalCurrencies = TraditionalCurrencies.USD; -// const btcCryptocurrency: Cryptocurrencies = Cryptocurrencies.BTC; - -/* nexus db: to-do: krn collection */ - -export interface IToken { - value: number; - currency: ECurrency; -} - -/* -OpenTokenValue -timeOpen -timeClose -closeTokenValue openOrgCap -closeOrgCap status -dividend -*/ -export interface IOrgTokenData {} - -/* -OpenTokenValue -timeOpen -timeClose -closeTokenValue openOrgCap -closeOrgCap status -dividend -*/ -export interface IUserTokenData {} From 7a52bea7d22ad5b170e5c4b75525cc7c8fe5fa32 Mon Sep 17 00:00:00 2001 From: Angelo Reale <12191809+angeloreale@users.noreply.github.com> Date: Sat, 10 Feb 2024 14:40:58 +0100 Subject: [PATCH 07/12] ar(feat) removing hardcoded strings and pointing to SST --- lib/model/interfaces/mdb-init-interface.ts | 19 ++++++++++--------- lib/types/constants/db.ts | 18 ++++++++++++++++++ lib/types/constants/index.ts | 3 +++ lib/types/db.d.ts | 3 +++ lib/types/index.ts | 4 ++-- tsconfig.json | 2 ++ 6 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 lib/types/constants/db.ts create mode 100644 lib/types/constants/index.ts create mode 100644 lib/types/db.d.ts diff --git a/lib/model/interfaces/mdb-init-interface.ts b/lib/model/interfaces/mdb-init-interface.ts index 534e2705..dc8b135a 100644 --- a/lib/model/interfaces/mdb-init-interface.ts +++ b/lib/model/interfaces/mdb-init-interface.ts @@ -2,6 +2,7 @@ // mdb-init-interface.ts import { v4 as uuid } from 'uuid'; import type { UserSchema, INCharacter, UserDecoration, OrgDecoration, ILogger, ILogContext } from '@types'; +import { ECollections } from "@constants" import { default as MongoConnector, _setDb as setDb } from '../mdb-connector'; import { DATABASE_STRING as databaseName, @@ -14,7 +15,7 @@ import { patience } from './helpers'; import { dbLog } from '@log'; /* to-do: move types to declaration file */ -type Tdbs = 'nexus' | 'organizations' | 'test' | string; +type Tdbs = 'nexus' | 'orgs' | 'test' | string; interface IDBGeneric { [x: string]: { @@ -276,11 +277,11 @@ const init = async ({ name }: { name: string }) => { Instance.private = {}; Instance.private.loadUsers = async () => { - const users = await Instance.users.db.collection('users'); + const users = await Instance.users.db.collection(ECollections.USERS); return users; }; Instance.private.reloadUsers = async () => { - const users = await Instance.users.db.collection('users'); + const users = await Instance.users.db.collection(ECollections.USERS); Instance.private.users = users; return users; }; @@ -289,11 +290,11 @@ const init = async ({ name }: { name: string }) => { /* (PVT) orgs */ if (process.env.NEXUS_MODE === 'full') { Instance.private.loadOrgs = async () => { - const orgs = await Instance.orgs.db.collection('organizations'); + const orgs = await Instance.orgs.db.collection(ECollections.ORGS); return orgs; }; Instance.private.reloadOrgs = async () => { - const orgs = await Instance.orgs.db.collection('organizations'); + const orgs = await Instance.orgs.db.collection(ECollections.ORGS); Instance.private.orgs = orgs; return orgs; }; @@ -307,7 +308,7 @@ const init = async ({ name }: { name: string }) => { Instance.private.defineUserSchema = await defineSchema( { db: userDatabaseName || databaseName, - collection: 'users', + collection: ECollections.USERS, schema: _UserSchema, docQuery: undefined, }, @@ -322,7 +323,7 @@ const init = async ({ name }: { name: string }) => { const initiator = await defineSchema( { db: userDatabaseName || databaseName, - collection: 'users', + collection: ECollections.USERS, schema: _UserSchema, docQuery: { email }, }, @@ -338,7 +339,7 @@ const init = async ({ name }: { name: string }) => { Instance.private.defineOrgSchema = await defineSchema( { db: orgsDatabaseName || databaseName, - collection: 'organizations', + collection: ECollections.ORGS, schema: _OrgSchema, }, Instance.private.orgs, @@ -365,7 +366,7 @@ const init = async ({ name }: { name: string }) => { /* IMPORTANT: to-do: extract method to add to org */ const userQuerySchema = { db: userDatabaseName || databaseName, - collection: 'users', + collection: ECollections.USERS, schema: _userQuerySchema, }; diff --git a/lib/types/constants/db.ts b/lib/types/constants/db.ts new file mode 100644 index 00000000..a71aa8ca --- /dev/null +++ b/lib/types/constants/db.ts @@ -0,0 +1,18 @@ +// db.enums.ts +enum ENexusCollections { + USERS = 'users', + ABILITIES = 'abilities', + FINCORE = 'fincore', +} + +enum EOrgCollections { + ORGS = 'organizations', + BILLING = 'billing', + SERVICES = 'services', + FEATURES = 'features', +} + +export const ECollections = { + ...ENexusCollections, + ...EOrgCollections, +}; \ No newline at end of file diff --git a/lib/types/constants/index.ts b/lib/types/constants/index.ts new file mode 100644 index 00000000..1c5b9c10 --- /dev/null +++ b/lib/types/constants/index.ts @@ -0,0 +1,3 @@ +// index.ts + +export { ECollections } from "./db" \ No newline at end of file diff --git a/lib/types/db.d.ts b/lib/types/db.d.ts new file mode 100644 index 00000000..968cfeeb --- /dev/null +++ b/lib/types/db.d.ts @@ -0,0 +1,3 @@ +// db.d.ts +import type { ECollections } from './constants' +export type ICollections = typeof ECollections; diff --git a/lib/types/index.ts b/lib/types/index.ts index 8b3ecd17..d9121e66 100644 --- a/lib/types/index.ts +++ b/lib/types/index.ts @@ -3,8 +3,8 @@ // contexts export type { IAuthContext, IRMContext, INCharacter, IDCharacter, History } from './contexts'; -// model -export type {} from './model'; +// db +export type { ICollections } from './db'; // users export type { UserSchema, User, UserDecoration } from './users'; diff --git a/tsconfig.json b/tsconfig.json index d2576657..7acbfab5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -33,6 +33,8 @@ "@log/*": ["./lib/log/*"], "@types": ["./lib/types"], "@types/*": ["./lib/types/*"], + "@constants": ["./lib/types/constants"], + "@constants/*": ["./lib/types/constants/*"], "@auth": ["./lib/auth"], "@auth/adapter": ["./src/app/api/auth/[...nextauth]"], "@auth/adapter/*": ["./src/app/api/auth/[...nextauth]/*"], From 4123a927d2fe4939ecc0fd258484ec5c12cdb32c Mon Sep 17 00:00:00 2001 From: Angelo Reale <12191809+angeloreale@users.noreply.github.com> Date: Sat, 10 Feb 2024 16:29:46 +0100 Subject: [PATCH 08/12] ar(feat) decorating schemas for init data layer --- lib/model/index.ts | 1 + lib/model/interfaces/index.ts | 2 +- lib/model/interfaces/mdb-init-interface.ts | 2 +- lib/model/schemas/org.ts | 96 ++++++++++++++++++++++ lib/model/schemas/relations.ts | 13 +++ lib/model/schemas/user.ts | 25 ++++++ lib/types/actions.d.ts | 8 +- lib/types/authorization.d.ts | 24 ++---- lib/types/constants/authorization.ts | 16 ++++ lib/types/constants/db.ts | 2 +- lib/types/constants/index.ts | 4 +- lib/types/constants/services.ts | 53 ++++++++++++ lib/types/db.d.ts | 2 +- lib/types/index.ts | 5 +- lib/types/orgs.d.ts | 10 +-- lib/types/services.d.ts | 56 +++---------- tsconfig.json | 4 +- 17 files changed, 243 insertions(+), 80 deletions(-) create mode 100644 lib/model/schemas/org.ts create mode 100644 lib/model/schemas/relations.ts create mode 100644 lib/model/schemas/user.ts create mode 100644 lib/types/constants/authorization.ts create mode 100644 lib/types/constants/services.ts diff --git a/lib/model/index.ts b/lib/model/index.ts index 84f192ea..16b607aa 100644 --- a/lib/model/index.ts +++ b/lib/model/index.ts @@ -10,6 +10,7 @@ export { DATABASE_STRING, DATABASE_USERS_STRING, DATABASE_ORGS_STRING, + DEFAULT_ORG, } from './interfaces'; /* rm-decorators */ diff --git a/lib/model/interfaces/index.ts b/lib/model/interfaces/index.ts index 325b6807..dd0c65a8 100644 --- a/lib/model/interfaces/index.ts +++ b/lib/model/interfaces/index.ts @@ -3,7 +3,7 @@ /* mdb-ifaces */ /* const */ -export { DATABASE_STRING, DATABASE_USERS_STRING, DATABASE_ORGS_STRING } from './constants'; +export { DATABASE_STRING, DATABASE_USERS_STRING, DATABASE_ORGS_STRING, DEFAULT_ORG } from './constants'; // default methods export { NexusInterface } from './mdb-init-interface'; diff --git a/lib/model/interfaces/mdb-init-interface.ts b/lib/model/interfaces/mdb-init-interface.ts index dc8b135a..a15cc3d2 100644 --- a/lib/model/interfaces/mdb-init-interface.ts +++ b/lib/model/interfaces/mdb-init-interface.ts @@ -2,7 +2,7 @@ // mdb-init-interface.ts import { v4 as uuid } from 'uuid'; import type { UserSchema, INCharacter, UserDecoration, OrgDecoration, ILogger, ILogContext } from '@types'; -import { ECollections } from "@constants" +import { ECollections } from '@constants'; import { default as MongoConnector, _setDb as setDb } from '../mdb-connector'; import { DATABASE_STRING as databaseName, diff --git a/lib/model/schemas/org.ts b/lib/model/schemas/org.ts new file mode 100644 index 00000000..40de6ea3 --- /dev/null +++ b/lib/model/schemas/org.ts @@ -0,0 +1,96 @@ +// org.ts +import type { + NexusActionTypes, + IActionTypes, + IServiceUserAmbiRelation, + IFeature, + OrgDecoration, + INCharacter, +} from '@types'; +import { EFeatureStatus, EServiceTypes, EServiceStatus, EServiceNames } from '@constants'; +import { DEFAULT_ORG } from '@model'; +import { defaultAbilities } from '@schema/user'; + +interface INexusSet extends Set { + gimme?: (value: string) => string[] | []; +} +// // @ts-ignore: reference error +// const NexusSet: INexusSet = () => {} +// NexusSet.prototype.gimme = (value:string) => { +// // @ts-ignore: reference error +// if(this?.has && this.has(value)) return [value] +// return [] +// } + +// // from stackoverflow: https://stackoverflow.com/a/5136392 +// function inherit (obj: Function, base: Function) { +// var tmp = function () {}; +// tmp.prototype = base.prototype; +// // @ts-ignore: reference error +// obj.prototype = new tmp(); +// obj.prototype.constructor = obj; +// }; + +// inherit(NexusSet, Set) + +const publicNexusActions: Set = new Set(['init', 'login', 'logout', 'hydrate']); + +const commonActions: INexusSet = new Set(['like']); +commonActions.gimme = (value: string) => { + if (commonActions.has(value)) return [value]; + return []; +}; + +export const defaultRMActions = [...publicNexusActions, ...commonActions.gimme('like')]; + +export const defaultRMFeatures: Set = new Set([ + { + name: 'love-characters', + status: EFeatureStatus.active, + version: '0.0.1', + abilities: defaultAbilities, + }, +]); + +export const RMServiceSchema: IServiceUserAmbiRelation = { + name: EServiceNames.SERV_RM, + type: EServiceTypes.RM, + createdOn: new Date(), + status: EServiceStatus.active, + statusModified: new Date(), + version: '1.0.0', + features: [...defaultRMFeatures], +}; + +export const defaultServices = { + [EServiceNames.SERV_RM]: RMServiceSchema, +}; + +export const defaultProjects = { + [EServiceNames.SERV_RM]: { + name: 'myorg-default-rm-index', + status: 'active', + /* + to-finish: walk the default services + service: defaultServices.get(‘rickmorty’).name, + sid: unknown (NEEDS DEFINE RELATIONS) + */ + }, +}; + +export const _OrgSchema: OrgDecoration = { + name: DEFAULT_ORG, + members: [], + services: { + enabled: defaultServices, + available: defaultServices, + }, + projects: { + active: defaultProjects, + }, + rickmorty_meta: { + favorites: { + characters: [] as INCharacter['id'][], + }, + }, +}; diff --git a/lib/model/schemas/relations.ts b/lib/model/schemas/relations.ts new file mode 100644 index 00000000..ffb56af2 --- /dev/null +++ b/lib/model/schemas/relations.ts @@ -0,0 +1,13 @@ +// relations.ts +import { EUserOrgRoles } from '@constants'; +import { defaultAbilities } from '@schema/user'; +import { defaultProjects, defaultServices } from '@schema/org'; + +export const defaultOrgMemberRelation = { + role: [EUserOrgRoles.MEMBER], + abilities: [...defaultAbilities], + services: defaultServices, + projects: defaultProjects, + org: 'name', + user: 'email', +}; diff --git a/lib/model/schemas/user.ts b/lib/model/schemas/user.ts new file mode 100644 index 00000000..4f22e2da --- /dev/null +++ b/lib/model/schemas/user.ts @@ -0,0 +1,25 @@ +// user.ts +/* schemas */ +import type { IAbility, UserDecoration, INCharacter, DUserOrgAmbiRelation } from '@types'; +import { EUserOrgRoles, EAbilityStatus } from '@constants'; +import { defaultRMActions } from '@schema/org'; + +/* to finish, use hashmap */ +export const defaultAbilities: IAbility[] = [ + { + name: 'like-stuff', + contexts: ['all'], + actions: [...defaultRMActions], + roles: [EUserOrgRoles.EVERYONE], + status: EAbilityStatus.active, + }, +]; + +export const _UserSchema: UserDecoration = { + rickmorty: { + favorites: { + characters: [] as INCharacter['id'][], + }, + }, + organizations: [] as DUserOrgAmbiRelation[], +}; diff --git a/lib/types/actions.d.ts b/lib/types/actions.d.ts index de282028..f53b9608 100644 --- a/lib/types/actions.d.ts +++ b/lib/types/actions.d.ts @@ -1,10 +1,10 @@ // actions.d.ts import type { Context } from 'react'; -export type _NexusIAction = 'update_db' | 'schema-enforcing'; -export type NexusIAction = 'init' | 'login' | 'logout' | 'hydrate'; +export type _NexusActionTypes = 'update_db' | 'schema-enforcing'; +export type NexusActionTypes = 'init' | 'login' | 'logout' | 'hydrate'; export type CommonIAction = 'like'; -export type RMIActionypes = CommonIAction<'like'>; -export type IActionTypes = NexusIAction | RMIActionypes; +export type RMActionTypes = CommonIAction<'like'>; +export type IActionTypes = NexusActionTypes | RMActionTypes; export type NexusActionContexts = 'init' | 'auth' | 'ubiquity' | 'database'; export type ServicesActionContexts = 'rickmorty' | 'image-uploader'; diff --git a/lib/types/authorization.d.ts b/lib/types/authorization.d.ts index af2a9ec8..18049fd9 100644 --- a/lib/types/authorization.d.ts +++ b/lib/types/authorization.d.ts @@ -1,25 +1,11 @@ // authorization.d.ts -import type { IAction } from '@types'; +import type { IActionTypes } from '@types'; +import type { EAbilityStatus } from '@constants'; export interface IAbility { - actions: IAction[]; - roles: Record[]; + actions: IActionTypes[]; + roles: EUserOrgRoles[]; + contexts: IService<'name'>[]; name: string; status: EAbilityStatus; } - -export enum EAbilityStatus { - 'inactive' = 0, - 'active' = 1, - 'deprecated' = 2, -} - -export enum EUserOrgRoles { - 'SUPERUSER' = 0, - 'ADMIN' = 1, - 'MANAGER' = 2, - 'PRODUCER' = 3, - 'MEMBER' = 4, - 'SPECTATOR' = 5, - 'EVERYONE' = 6, -} diff --git a/lib/types/constants/authorization.ts b/lib/types/constants/authorization.ts new file mode 100644 index 00000000..28bda57b --- /dev/null +++ b/lib/types/constants/authorization.ts @@ -0,0 +1,16 @@ +// authorization.ts +export enum EAbilityStatus { + 'inactive' = 0, + 'active' = 1, + 'deprecated' = 2, +} + +export enum EUserOrgRoles { + 'SUPERUSER' = 0, + 'ADMIN' = 1, + 'MANAGER' = 2, + 'PRODUCER' = 3, + 'MEMBER' = 4, + 'SPECTATOR' = 5, + 'EVERYONE' = 6, +} diff --git a/lib/types/constants/db.ts b/lib/types/constants/db.ts index a71aa8ca..de29ad2c 100644 --- a/lib/types/constants/db.ts +++ b/lib/types/constants/db.ts @@ -15,4 +15,4 @@ enum EOrgCollections { export const ECollections = { ...ENexusCollections, ...EOrgCollections, -}; \ No newline at end of file +}; diff --git a/lib/types/constants/index.ts b/lib/types/constants/index.ts index 1c5b9c10..718321a9 100644 --- a/lib/types/constants/index.ts +++ b/lib/types/constants/index.ts @@ -1,3 +1,5 @@ // index.ts -export { ECollections } from "./db" \ No newline at end of file +export { ECollections } from './db'; +export { EServiceTypes, EServiceStatus, EFeatureStatus, EServiceNames } from './services'; +export { EAbilityStatus, EUserOrgRoles } from './authorization'; diff --git a/lib/types/constants/services.ts b/lib/types/constants/services.ts new file mode 100644 index 00000000..c3be6189 --- /dev/null +++ b/lib/types/constants/services.ts @@ -0,0 +1,53 @@ +// services.ts +export enum EServiceNames { + /* core */ + SERV_VBM = 'The Vibe Modulator', + /* extra */ + SERV_RM = 'The Rick and Morty Index', + SERV_EC = 'The Eezy Content Uploader', +} + +export enum EServiceTypes { + /* core */ + 'DCS' = 0, + 'DBS' = 1, + 'DWS' = 2, + 'DVS' = 3, + 'DFS' = 4, + /* extra */ + 'RM' = 999999999, + 'EC' = 999999998, +} + +export enum EServiceStatus { + 'deactivated' = 0, + 'created' = 1, + 'active' = 2, + 'enabled' = 3, + 'running' = 4, + 'paused' = 5, + 'stopped' = 6, + 'disabled' = 7, + 'inactive' = 8, + 'deleted' = 9, + 'delinquent' = 10, +} + +export enum EFeatureStatus { + 'inactive' = 0, + 'ghost' = 1, + 'active' = 2, + 'beta' = 3, + 'nightly' = 4, +} + +export const EServices = { + [EServiceNames.SERV_VBM]: { + name: EServiceNames.SERV_VBM, + type: EServiceTypes.DCS, + }, + [EServiceNames.SERV_RM]: { + name: EServiceNames.SERV_RM, + type: EServiceTypes.RM, + }, +}; diff --git a/lib/types/db.d.ts b/lib/types/db.d.ts index 968cfeeb..0508b96a 100644 --- a/lib/types/db.d.ts +++ b/lib/types/db.d.ts @@ -1,3 +1,3 @@ // db.d.ts -import type { ECollections } from './constants' +import type { ECollections } from './constants'; export type ICollections = typeof ECollections; diff --git a/lib/types/index.ts b/lib/types/index.ts index d9121e66..c53eeb2a 100644 --- a/lib/types/index.ts +++ b/lib/types/index.ts @@ -7,7 +7,7 @@ export type { IAuthContext, IRMContext, INCharacter, IDCharacter, History } from export type { ICollections } from './db'; // users -export type { UserSchema, User, UserDecoration } from './users'; +export type { UserSchema, User, UserDecoration, DUserOrgAmbiRelation } from './users'; // orgs export type { OrgDecoration } from './orgs'; @@ -32,10 +32,11 @@ export type { IDispatchPayload, ILogContext, ILogger, + NexusActionTypes, } from './actions'; // authorization -export type { IAbility, EAbilityStatus, EUserOrgRoles } from './authorization'; +export type { IAbility } from './authorization'; // services export type { IFeature, IProject, IServiceUserAmbiRelation } from './services'; diff --git a/lib/types/orgs.d.ts b/lib/types/orgs.d.ts index 87c229a3..395f4e11 100644 --- a/lib/types/orgs.d.ts +++ b/lib/types/orgs.d.ts @@ -11,13 +11,13 @@ export interface OrgDecoration { // websites: string[]; members: DUserOrgAmbiRelation[]; projects: { - active: DProjectOrgRelation[]; - inactive: DProjectOrgRelation[]; - archived: DProjectOrgRelation[]; + active?: DProjectOrgRelation; + inactive?: DProjectOrgRelation; + archived?: DProjectOrgRelation; }; services: { - available: DServiceOrgRelation[]; - enabled: DServiceOrgRelation[]; + available?: DServiceOrgRelation; + enabled?: DServiceOrgRelation; }; rickmorty_meta: { favorites: { diff --git a/lib/types/services.d.ts b/lib/types/services.d.ts index 4d660ff7..6707e198 100644 --- a/lib/types/services.d.ts +++ b/lib/types/services.d.ts @@ -1,38 +1,13 @@ // services.d.ts -import type { IAbility } from '@ types'; - -export enum EServiceTypes { - /* core */ - 'DCS' = 0, - 'DBS' = 1, - 'DWS' = 2, - 'DVS' = 3, - 'DFS' = 4, - /* extra */ - 'RM' = 999999999, - 'EC' = 999999998, -} - -export enum EServiceStatuses { - 'deactivated' = 0, - 'created' = 1, - 'active' = 2, - 'enabled' = 3, - 'running' = 4, - 'paused' = 5, - 'stopped' = 6, - 'disabled' = 7, - 'inactive' = 8, - 'deleted' = 9, - 'delinquent' = 10, -} +import type { IAbility } from '@types'; +import type { EServiceTypes, EServiceStatus, EFeatureStatus } from '@constants'; export interface IService { - _id: ObjectID /* sid */; + _id?: ObjectID /* sid */; name: string; type: Record; createdOn: Date; - status: Record; + status: Record; statusModified: Date; // cost: number; // cycle: EBillingCycles; @@ -42,38 +17,31 @@ export interface IService { /* facading sensitive service-> org data */ export interface IServiceUserAmbiRelation { - _id: ObjectID /* sid */; + _id?: ObjectID /* sid */; name: string; type: EServiceTypes; - status: EServiceStatuses; + createdOn: Date; + status: EServiceStatus; statusModified: Date; version: string; features: IFeature[]; - projects: DProjectServiceRelation[]; + // projects: DProjectServiceRelation[]; } /* features */ export interface IFeature { name: string; - status: Record; + status: EFeatureStatus; version: string; abilities: IAbility[]; } -export enum EFeatureStatus { - 'inactive' = 0, - 'ghost' = 1, - 'active' = 2, - 'beta' = 3, - 'nightly' = 4, -} - export interface IProject { name: string; - status: Record; + status: Record; service: IService<'name'>; sid: IService<'_id'>; } -export type DProjectOrgRelation = IProject[]; -export type DServiceOrgRelation = IService[]; +export type DProjectOrgRelation = Record, IProject>; +export type DServiceOrgRelation = Record, IService>; diff --git a/tsconfig.json b/tsconfig.json index 7acbfab5..ee5b6612 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es5", + "target": "es2015", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, @@ -25,6 +25,8 @@ "@atoms/*": ["./src/app/components/system/atoms/*"], "@model": ["./lib/model"], "@model/*": ["./lib/model/*"], + "@schema": ["./lib/model/schemas"], + "@schema/*": ["./lib/model/schemas/*"], "@view": ["./lib/view"], "@view/*": ["./lib/view/*"], "@pragmas": ["./lib/view/adapters/"], From 573fea0588850d87061cf969a9a3a2a383d2b192 Mon Sep 17 00:00:00 2001 From: Angelo Reale <12191809+angeloreale@users.noreply.github.com> Date: Sat, 10 Feb 2024 18:59:03 +0100 Subject: [PATCH 09/12] ar(qa) minute and verbs --- lib/model/mdb-connector.ts | 2 +- lib/types/actions.d.ts | 2 +- lib/types/billing.d.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/model/mdb-connector.ts b/lib/model/mdb-connector.ts index 8b7e4cbd..2ec1f9eb 100644 --- a/lib/model/mdb-connector.ts +++ b/lib/model/mdb-connector.ts @@ -39,7 +39,7 @@ const genPromise = (name = '') => { log({ type: 'database', action: 'init', - verb: 'connect', + verb: 'connect to database', status: 'connecting-to', message: domain, }); diff --git a/lib/types/actions.d.ts b/lib/types/actions.d.ts index f53b9608..4cca0824 100644 --- a/lib/types/actions.d.ts +++ b/lib/types/actions.d.ts @@ -11,7 +11,7 @@ export type ServicesActionContexts = 'rickmorty' | 'image-uploader'; export type ActionContexts = NexusActionContexts | ServicesActionContexts; export type ActionAuthVerbs = 'load user' | 'load user meta' | 'unload user'; -export type ActionDBVerbs = 'database' | 'collection' | 'relations' | 'connect'; +export type ActionDBVerbs = 'load database' | 'load collection' | 'define relations' | 'connect to database'; export type ActionRMVerbs = 'load characters' | 'unload characters' | 'decorate characters' | 'add char to favorites'; export type ActionVerbs = ActionAuthVerbs | ActionRMVerbs | ActionDBVerbs; diff --git a/lib/types/billing.d.ts b/lib/types/billing.d.ts index bfe53278..edec70d9 100644 --- a/lib/types/billing.d.ts +++ b/lib/types/billing.d.ts @@ -7,7 +7,7 @@ export interface IBillingData {} export enum EBillingCycles { /* core */ - '1M' = 0, + '1m' = 0, '1H' = 1, '1D' = 2, '1W' = 3, From 2f032ca98795d54f3513e4e3498751d5685b3fb0 Mon Sep 17 00:00:00 2001 From: Angelo Reale <12191809+angeloreale@users.noreply.github.com> Date: Sat, 10 Feb 2024 19:28:27 +0100 Subject: [PATCH 10/12] ar(qa) fuzzy abilities --- lib/model/schemas/org.ts | 37 ++++++++++++--------------------- lib/model/schemas/relations.ts | 2 +- lib/model/schemas/user.ts | 8 ++++--- lib/types/authorization.d.ts | 32 +++++++++++++++++++++++++++- lib/types/constants/index.ts | 2 +- lib/types/constants/services.ts | 8 +++++++ lib/types/index.ts | 4 ++-- lib/types/services.d.ts | 15 +++++++++---- lib/types/users.d.ts | 4 ++-- 9 files changed, 74 insertions(+), 38 deletions(-) diff --git a/lib/model/schemas/org.ts b/lib/model/schemas/org.ts index 40de6ea3..f9998f7f 100644 --- a/lib/model/schemas/org.ts +++ b/lib/model/schemas/org.ts @@ -3,7 +3,7 @@ import type { NexusActionTypes, IActionTypes, IServiceUserAmbiRelation, - IFeature, + IFeatureSet, OrgDecoration, INCharacter, } from '@types'; @@ -14,24 +14,6 @@ import { defaultAbilities } from '@schema/user'; interface INexusSet extends Set { gimme?: (value: string) => string[] | []; } -// // @ts-ignore: reference error -// const NexusSet: INexusSet = () => {} -// NexusSet.prototype.gimme = (value:string) => { -// // @ts-ignore: reference error -// if(this?.has && this.has(value)) return [value] -// return [] -// } - -// // from stackoverflow: https://stackoverflow.com/a/5136392 -// function inherit (obj: Function, base: Function) { -// var tmp = function () {}; -// tmp.prototype = base.prototype; -// // @ts-ignore: reference error -// obj.prototype = new tmp(); -// obj.prototype.constructor = obj; -// }; - -// inherit(NexusSet, Set) const publicNexusActions: Set = new Set(['init', 'login', 'logout', 'hydrate']); @@ -41,16 +23,23 @@ commonActions.gimme = (value: string) => { return []; }; -export const defaultRMActions = [...publicNexusActions, ...commonActions.gimme('like')]; +export const nominalRMActions = [...publicNexusActions, ...commonActions.gimme('like')]; -export const defaultRMFeatures: Set = new Set([ - { +export const defaultRMActions = nominalRMActions.reduce((acc, actionType) => { + return { + ...acc, + [actionType]: true, + }; +}, {}); + +export const defaultRMFeatures: IFeatureSet = { + 'love-characters': { name: 'love-characters', status: EFeatureStatus.active, version: '0.0.1', abilities: defaultAbilities, }, -]); +}; export const RMServiceSchema: IServiceUserAmbiRelation = { name: EServiceNames.SERV_RM, @@ -59,7 +48,7 @@ export const RMServiceSchema: IServiceUserAmbiRelation = { status: EServiceStatus.active, statusModified: new Date(), version: '1.0.0', - features: [...defaultRMFeatures], + features: defaultRMFeatures, }; export const defaultServices = { diff --git a/lib/model/schemas/relations.ts b/lib/model/schemas/relations.ts index ffb56af2..4142309c 100644 --- a/lib/model/schemas/relations.ts +++ b/lib/model/schemas/relations.ts @@ -5,7 +5,7 @@ import { defaultProjects, defaultServices } from '@schema/org'; export const defaultOrgMemberRelation = { role: [EUserOrgRoles.MEMBER], - abilities: [...defaultAbilities], + abilities: defaultAbilities, services: defaultServices, projects: defaultProjects, org: 'name', diff --git a/lib/model/schemas/user.ts b/lib/model/schemas/user.ts index 4f22e2da..83dfb644 100644 --- a/lib/model/schemas/user.ts +++ b/lib/model/schemas/user.ts @@ -1,16 +1,18 @@ // user.ts /* schemas */ -import type { IAbility, UserDecoration, INCharacter, DUserOrgAmbiRelation } from '@types'; +import type { IFuzzyAbilities, UserDecoration, INCharacter, DUserOrgAmbiRelation } from '@types'; import { EUserOrgRoles, EAbilityStatus } from '@constants'; import { defaultRMActions } from '@schema/org'; /* to finish, use hashmap */ -export const defaultAbilities: IAbility[] = [ +export const defaultAbilities: IFuzzyAbilities = [ { name: 'like-stuff', contexts: ['all'], - actions: [...defaultRMActions], + actions: defaultRMActions, roles: [EUserOrgRoles.EVERYONE], + restrictions: {}, + allowances: {}, status: EAbilityStatus.active, }, ]; diff --git a/lib/types/authorization.d.ts b/lib/types/authorization.d.ts index 18049fd9..d4769a9b 100644 --- a/lib/types/authorization.d.ts +++ b/lib/types/authorization.d.ts @@ -1,11 +1,41 @@ // authorization.d.ts import type { IActionTypes } from '@types'; -import type { EAbilityStatus } from '@constants'; +import type { EAbilityStatus, EFeatures } from '@constants'; export interface IAbility { actions: IActionTypes[]; roles: EUserOrgRoles[]; contexts: IService<'name'>[]; + restrictions: IFuzzyAbilities; name: string; status: EAbilityStatus; } + +export interface IUniversalAbilityMap { + none: IFuzzyAbilities; +} + +export type IFuzzyAbilities = { + [x in keyof EFeatures]: EFeatures; +}; + +export type AbilityFuzziesT = 'age' | 'idv' | 'addv' | 'role'; + +/* e.g. geoRestrictions +ICountryAbilitiesMap { + [country]: IFuzzyAbilities +} + +use cases: +feature geoRestrictions, +service geoRestrictions, +projects geoRestrictions (allows user set) + +IAnyAbilityMap { + [yourCriteria]: IFuzzyAbilities +} + +abilities can belong to projects, features or services +abilities can map to roles, which is more performant than roles mapping to abilities. + +*/ diff --git a/lib/types/constants/index.ts b/lib/types/constants/index.ts index 718321a9..43d57fb1 100644 --- a/lib/types/constants/index.ts +++ b/lib/types/constants/index.ts @@ -1,5 +1,5 @@ // index.ts export { ECollections } from './db'; -export { EServiceTypes, EServiceStatus, EFeatureStatus, EServiceNames } from './services'; +export { EServiceTypes, EServiceStatus, EFeatureStatus, EServiceNames, EFeatures } from './services'; export { EAbilityStatus, EUserOrgRoles } from './authorization'; diff --git a/lib/types/constants/services.ts b/lib/types/constants/services.ts index c3be6189..3583fe1b 100644 --- a/lib/types/constants/services.ts +++ b/lib/types/constants/services.ts @@ -33,6 +33,14 @@ export enum EServiceStatus { 'delinquent' = 10, } +export enum ERMFeatures { + 'love-characters' = 0, +} + +export const EFeatures = { + ...ERMFeatures +} + export enum EFeatureStatus { 'inactive' = 0, 'ghost' = 1, diff --git a/lib/types/index.ts b/lib/types/index.ts index c53eeb2a..e7b898e2 100644 --- a/lib/types/index.ts +++ b/lib/types/index.ts @@ -36,10 +36,10 @@ export type { } from './actions'; // authorization -export type { IAbility } from './authorization'; +export type { IAbility, IFuzzyAbilities } from './authorization'; // services -export type { IFeature, IProject, IServiceUserAmbiRelation } from './services'; +export type { IFeature, IFeatureSet, IProject, IServiceUserAmbiRelation } from './services'; // system export type { Tposition, TpositionX, TpositionY, Tsize, Tthemes } from './atoms'; diff --git a/lib/types/services.d.ts b/lib/types/services.d.ts index 6707e198..cadb526d 100644 --- a/lib/types/services.d.ts +++ b/lib/types/services.d.ts @@ -1,5 +1,5 @@ // services.d.ts -import type { IAbility } from '@types'; +import type { IFuzzyAbilities } from '@types'; import type { EServiceTypes, EServiceStatus, EFeatureStatus } from '@constants'; export interface IService { @@ -13,6 +13,7 @@ export interface IService { // cycle: EBillingCycles; version: string; features: IFeature[]; + abilities: IFuzzyAbilities; } /* facading sensitive service-> org data */ @@ -24,8 +25,7 @@ export interface IServiceUserAmbiRelation { status: EServiceStatus; statusModified: Date; version: string; - features: IFeature[]; - // projects: DProjectServiceRelation[]; + features: IFeatureSet; } /* features */ @@ -33,13 +33,20 @@ export interface IFeature { name: string; status: EFeatureStatus; version: string; - abilities: IAbility[]; + abilities: IFuzzyAbilities; +} + +export type IFeatureSet = { + [x in keyof IFeature]: IFeature; } +export type AbilityFuzziesT = 'age' | 'idv' | 'addv' | 'role'; + export interface IProject { name: string; status: Record; service: IService<'name'>; + abilities: IFuzzyAbilities; sid: IService<'_id'>; } diff --git a/lib/types/users.d.ts b/lib/types/users.d.ts index e3d04210..1d9ce442 100644 --- a/lib/types/users.d.ts +++ b/lib/types/users.d.ts @@ -1,5 +1,5 @@ // users.d.ts -import type { IProject, IServiceUserAmbiRelation, IAbility, EUserOrgRoles, INCharacter } from '@types'; +import type { IProject, IServiceUserAmbiRelation, EUserOrgRoles, INCharacter } from '@types'; import type { User } from 'next-auth'; export { User }; @@ -19,7 +19,7 @@ export interface UserDecoration { export interface DUserOrgAmbiRelation { role: EUserOrgRoles[]; - abilities: IAbility[]; + abilities: IFuzzyAbilities; services: IServiceUserAmbiRelation[]; projects: IProject[]; _id: ObjectID /* uid */; From 3d19495b7010341f58e9142b83a4e1439d6e042a Mon Sep 17 00:00:00 2001 From: Angelo Reale <12191809+angeloreale@users.noreply.github.com> Date: Sat, 10 Feb 2024 19:55:27 +0100 Subject: [PATCH 11/12] ar(qa) generic db names --- lib/model/{interfaces => }/constants.ts | 0 lib/model/index.ts | 2 +- lib/model/interfaces/index.ts | 1 - lib/model/interfaces/mdb-init-interface.ts | 28 +++++++++------------- lib/types/constants/db.ts | 8 +++++++ lib/types/constants/index.ts | 2 +- lib/types/constants/services.ts | 4 ++-- lib/types/services.d.ts | 2 +- 8 files changed, 24 insertions(+), 23 deletions(-) rename lib/model/{interfaces => }/constants.ts (100%) diff --git a/lib/model/interfaces/constants.ts b/lib/model/constants.ts similarity index 100% rename from lib/model/interfaces/constants.ts rename to lib/model/constants.ts diff --git a/lib/model/index.ts b/lib/model/index.ts index 16b607aa..2fe4d8f2 100644 --- a/lib/model/index.ts +++ b/lib/model/index.ts @@ -11,7 +11,7 @@ export { DATABASE_USERS_STRING, DATABASE_ORGS_STRING, DEFAULT_ORG, -} from './interfaces'; +} from './constants'; /* rm-decorators */ export { decorateRMCharacters } from './decorators'; diff --git a/lib/model/interfaces/index.ts b/lib/model/interfaces/index.ts index dd0c65a8..4a55ecd1 100644 --- a/lib/model/interfaces/index.ts +++ b/lib/model/interfaces/index.ts @@ -3,7 +3,6 @@ /* mdb-ifaces */ /* const */ -export { DATABASE_STRING, DATABASE_USERS_STRING, DATABASE_ORGS_STRING, DEFAULT_ORG } from './constants'; // default methods export { NexusInterface } from './mdb-init-interface'; diff --git a/lib/model/interfaces/mdb-init-interface.ts b/lib/model/interfaces/mdb-init-interface.ts index a15cc3d2..9f1a3214 100644 --- a/lib/model/interfaces/mdb-init-interface.ts +++ b/lib/model/interfaces/mdb-init-interface.ts @@ -4,19 +4,13 @@ import { v4 as uuid } from 'uuid'; import type { UserSchema, INCharacter, UserDecoration, OrgDecoration, ILogger, ILogContext } from '@types'; import { ECollections } from '@constants'; import { default as MongoConnector, _setDb as setDb } from '../mdb-connector'; -import { - DATABASE_STRING as databaseName, - DATABASE_USERS_STRING as userDatabaseName, - DATABASE_ORGS_STRING as orgsDatabaseName, - DEFAULT_ORG as defaultOrg, -} from './constants'; +import { DEFAULT_ORG as defaultOrg } from '@model'; +import { EDBs } from '@constants'; + import { patience } from './helpers'; import { dbLog } from '@log'; -/* to-do: move types to declaration file */ -type Tdbs = 'nexus' | 'orgs' | 'test' | string; - interface IDBGeneric { [x: string]: { db: unknown; @@ -215,12 +209,12 @@ const _OrgSchema: OrgDecoration = { /* private */ -const prepare = async (name: Tdbs): Promise => { +async function prepare(name: (typeof EDBs)[DB]): Promise { const conn = await MongoConnector; const db_conn = await setDb(name); const db = await db_conn.db(name); return db; -}; +} // IMPORTANT: to-do: to enforce on existing docs (not on insert only) const createSchemaQuery = () => { @@ -257,7 +251,7 @@ const Instance: any = {}; /* private methods */ /* 0. init */ const init = async ({ name }: { name: string }) => { - const usersDb = userDatabaseName || databaseName; + const usersDb = EDBs.USERS || EDBs.DEFAULT; const _users = { status: 'loading', @@ -269,7 +263,7 @@ const init = async ({ name }: { name: string }) => { if (process.env.NEXUS_MODE === 'full') { const _orgs = { status: 'loading', - db: await prepare(orgsDatabaseName), + db: await prepare(EDBs.ORGS), }; Instance.orgs = _orgs; @@ -307,7 +301,7 @@ const init = async ({ name }: { name: string }) => { Instance.private.defineUserSchema = await defineSchema( { - db: userDatabaseName || databaseName, + db: EDBs.USERS || EDBs.DEFAULT, collection: ECollections.USERS, schema: _UserSchema, docQuery: undefined, @@ -322,7 +316,7 @@ const init = async ({ name }: { name: string }) => { const initiator = await defineSchema( { - db: userDatabaseName || databaseName, + db: EDBs.USERS || EDBs.DEFAULT, collection: ECollections.USERS, schema: _UserSchema, docQuery: { email }, @@ -338,7 +332,7 @@ const init = async ({ name }: { name: string }) => { Instance.private.defineOrgSchema = await defineSchema( { - db: orgsDatabaseName || databaseName, + db: EDBs.ORGS || EDBs.DEFAULT, collection: ECollections.ORGS, schema: _OrgSchema, }, @@ -365,7 +359,7 @@ const init = async ({ name }: { name: string }) => { /* IMPORTANT: to-do: extract method to add to org */ const userQuerySchema = { - db: userDatabaseName || databaseName, + db: EDBs.USERS || EDBs.DEFAULT, collection: ECollections.USERS, schema: _userQuerySchema, }; diff --git a/lib/types/constants/db.ts b/lib/types/constants/db.ts index de29ad2c..e6db09ef 100644 --- a/lib/types/constants/db.ts +++ b/lib/types/constants/db.ts @@ -1,4 +1,12 @@ // db.enums.ts +import { DATABASE_STRING, DATABASE_USERS_STRING, DATABASE_ORGS_STRING } from '@model'; + +export const EDBs = { + DEFAULT: DATABASE_STRING || 'test', + USERS: DATABASE_USERS_STRING || DATABASE_STRING || 'auth', + ORGS: DATABASE_ORGS_STRING || DATABASE_STRING || 'organizations', +}; + enum ENexusCollections { USERS = 'users', ABILITIES = 'abilities', diff --git a/lib/types/constants/index.ts b/lib/types/constants/index.ts index 43d57fb1..9e44f183 100644 --- a/lib/types/constants/index.ts +++ b/lib/types/constants/index.ts @@ -1,5 +1,5 @@ // index.ts -export { ECollections } from './db'; +export { ECollections, EDBs } from './db'; export { EServiceTypes, EServiceStatus, EFeatureStatus, EServiceNames, EFeatures } from './services'; export { EAbilityStatus, EUserOrgRoles } from './authorization'; diff --git a/lib/types/constants/services.ts b/lib/types/constants/services.ts index 3583fe1b..dcec3331 100644 --- a/lib/types/constants/services.ts +++ b/lib/types/constants/services.ts @@ -38,8 +38,8 @@ export enum ERMFeatures { } export const EFeatures = { - ...ERMFeatures -} + ...ERMFeatures, +}; export enum EFeatureStatus { 'inactive' = 0, diff --git a/lib/types/services.d.ts b/lib/types/services.d.ts index cadb526d..85505a43 100644 --- a/lib/types/services.d.ts +++ b/lib/types/services.d.ts @@ -38,7 +38,7 @@ export interface IFeature { export type IFeatureSet = { [x in keyof IFeature]: IFeature; -} +}; export type AbilityFuzziesT = 'age' | 'idv' | 'addv' | 'role'; From ccec9d15437d572a8a9a5295028b7c4b1e61ae8e Mon Sep 17 00:00:00 2001 From: Angelo Reale <12191809+angeloreale@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:06:50 +0100 Subject: [PATCH 12/12] ar(qa) lower es target --- lib/model/constants.ts | 2 +- lib/model/schemas/org.ts | 7 ++--- lib/types/services.d.ts | 1 + .../molecules/divider/client/divider-view.tsx | 26 +++++++++---------- .../divider/client/divider.module.css | 2 ++ .../system/molecules/divider/client/index.ts | 4 +-- .../system/molecules/divider/divider.tsx | 16 ++++++------ .../system/molecules/divider/index.ts | 4 +-- tsconfig.json | 2 +- 9 files changed, 34 insertions(+), 30 deletions(-) diff --git a/lib/model/constants.ts b/lib/model/constants.ts index d4dd5c12..275234ca 100644 --- a/lib/model/constants.ts +++ b/lib/model/constants.ts @@ -5,7 +5,7 @@ let usersDatabase = ''; let defaultOrg = ''; let DATABASE_USERS_STRING = ''; let DATABASE_ORGS_STRING = ''; -let DEFAULT_ORG = 'demo'; +let DEFAULT_ORG = 'community'; /* lean */ if (process.env.NEXUS_MODE !== 'full') { diff --git a/lib/model/schemas/org.ts b/lib/model/schemas/org.ts index f9998f7f..ed08cdcc 100644 --- a/lib/model/schemas/org.ts +++ b/lib/model/schemas/org.ts @@ -15,7 +15,8 @@ interface INexusSet extends Set { gimme?: (value: string) => string[] | []; } -const publicNexusActions: Set = new Set(['init', 'login', 'logout', 'hydrate']); +const publicNexusActions: Set = new Set(['init', 'login', 'logout', 'hydrate'] as NexusActionTypes[]); +const iterablePublicActions: NexusActionTypes[] = Array.from(publicNexusActions); const commonActions: INexusSet = new Set(['like']); commonActions.gimme = (value: string) => { @@ -23,9 +24,9 @@ commonActions.gimme = (value: string) => { return []; }; -export const nominalRMActions = [...publicNexusActions, ...commonActions.gimme('like')]; +export const nominalRMActions = [...iterablePublicActions, commonActions.gimme('like')]; -export const defaultRMActions = nominalRMActions.reduce((acc, actionType) => { +export const defaultRMActions = nominalRMActions.reduce((acc, actionType: IActionTypes) => { return { ...acc, [actionType]: true, diff --git a/lib/types/services.d.ts b/lib/types/services.d.ts index 85505a43..a923528d 100644 --- a/lib/types/services.d.ts +++ b/lib/types/services.d.ts @@ -10,6 +10,7 @@ export interface IService { status: Record; statusModified: Date; // cost: number; + // currency: ECurrency // cycle: EBillingCycles; version: string; features: IFeature[]; diff --git a/src/app/components/system/molecules/divider/client/divider-view.tsx b/src/app/components/system/molecules/divider/client/divider-view.tsx index 857f3395..3fe6951d 100644 --- a/src/app/components/system/molecules/divider/client/divider-view.tsx +++ b/src/app/components/system/molecules/divider/client/divider-view.tsx @@ -1,15 +1,15 @@ -// @atoms/button-view.tsx -'use client'; -import { clsx } from "clsx" -import styles from "./divider.module.css" +// // @atoms/button-view.tsx +// 'use client'; +// import { clsx } from "clsx" +// import styles from "./divider.module.css" -interface VDividerProps extends React.HTMLProps { -} +// interface VDividerProps extends React.HTMLProps { +// } -export const NVDivider = ({ children, ...regularHtmlProps }: VDividerProps) => { - const classes = clsx({ - [styles.nexus__divider]: regularHtmlProps.type !== "hidden", - }) - /* remember server/client isomorphism */ - return
; -}; +// export const NVDivider = ({ children, ...regularHtmlProps }: VDividerProps) => { +// const classes = clsx({ +// [styles.nexus__divider]: regularHtmlProps.type !== "hidden", +// }) +// /* remember server/client isomorphism */ +// return
; +// }; diff --git a/src/app/components/system/molecules/divider/client/divider.module.css b/src/app/components/system/molecules/divider/client/divider.module.css index 645a7f15..673f5cf3 100644 --- a/src/app/components/system/molecules/divider/client/divider.module.css +++ b/src/app/components/system/molecules/divider/client/divider.module.css @@ -1,4 +1,5 @@ /* button.module.css */ +/* .nexus__divider { widht: 100; color: var(--nexus-main-fg); @@ -6,3 +7,4 @@ border: 1px solid var(--nexus-main-fg); margin-top: 32px; margin-bottom: 32px; } +*/ \ No newline at end of file diff --git a/src/app/components/system/molecules/divider/client/index.ts b/src/app/components/system/molecules/divider/client/index.ts index 3de86ad7..c55c3785 100644 --- a/src/app/components/system/molecules/divider/client/index.ts +++ b/src/app/components/system/molecules/divider/client/index.ts @@ -1,2 +1,2 @@ -// @atoms/button/client/index.ts -export { NVDivider } from './divider-view'; +// // @atoms/button/client/index.ts +// export { NVDivider } from './divider-view'; diff --git a/src/app/components/system/molecules/divider/divider.tsx b/src/app/components/system/molecules/divider/divider.tsx index 52efb346..c9175028 100644 --- a/src/app/components/system/molecules/divider/divider.tsx +++ b/src/app/components/system/molecules/divider/divider.tsx @@ -1,9 +1,9 @@ -// button.tsx -'use server'; -import { NCInput } from './server'; +// // button.tsx +// 'use server'; +// import { NCInput } from './server'; -export const Input = () => { - return
- -
; -}; +// export const Input = () => { +// return
+// +//
; +// }; diff --git a/src/app/components/system/molecules/divider/index.ts b/src/app/components/system/molecules/divider/index.ts index 7235373c..d7c5b624 100644 --- a/src/app/components/system/molecules/divider/index.ts +++ b/src/app/components/system/molecules/divider/index.ts @@ -1,2 +1,2 @@ -// index.ts -export { NVDivider as Divider } from './client'; +// // index.ts +// export { NVDivider as Divider } from './client'; diff --git a/tsconfig.json b/tsconfig.json index ee5b6612..78c76d04 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es2015", + "target": "es5", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true,