mirror of
https://github.com/logto-io/logto.git
synced 2025-03-17 22:31:28 -05:00
chore: upgrade configs
This commit is contained in:
parent
4c384a7715
commit
ed4db56254
38 changed files with 621 additions and 529 deletions
|
@ -42,7 +42,8 @@
|
|||
"peerDependencyRules": {
|
||||
"allowedVersions": {
|
||||
"react": "^18.0.0",
|
||||
"jest": "^29.1.2"
|
||||
"jest": "^29.1.2",
|
||||
"stylelint": "^15.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -67,8 +67,8 @@
|
|||
"zod": "^3.20.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@silverhand/eslint-config": "1.3.0",
|
||||
"@silverhand/ts-config": "1.2.1",
|
||||
"@silverhand/eslint-config": "2.0.1",
|
||||
"@silverhand/ts-config": "2.0.0",
|
||||
"@types/inquirer": "^9.0.0",
|
||||
"@types/jest": "^29.1.2",
|
||||
"@types/node": "^18.11.18",
|
||||
|
@ -76,21 +76,15 @@
|
|||
"@types/sinon": "^10.0.13",
|
||||
"@types/tar": "^6.1.2",
|
||||
"@types/yargs": "^17.0.13",
|
||||
"eslint": "^8.21.0",
|
||||
"eslint": "^8.34.0",
|
||||
"jest": "^29.3.1",
|
||||
"lint-staged": "^13.0.0",
|
||||
"prettier": "^2.8.1",
|
||||
"prettier": "^2.8.2",
|
||||
"sinon": "^15.0.0",
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "@silverhand",
|
||||
"rules": {
|
||||
"complexity": [
|
||||
"error",
|
||||
11
|
||||
]
|
||||
},
|
||||
"ignorePatterns": [
|
||||
"src/package-json.ts"
|
||||
]
|
||||
|
|
|
@ -40,7 +40,7 @@ const validRotateKeys = Object.freeze([
|
|||
LogtoOidcConfigKey.CookieKeys,
|
||||
] as const);
|
||||
|
||||
type ValidateRotateKeyFunction = (key: string) => asserts key is typeof validRotateKeys[number];
|
||||
type ValidateRotateKeyFunction = (key: string) => asserts key is (typeof validRotateKeys)[number];
|
||||
|
||||
const validateRotateKey: ValidateRotateKeyFunction = (key) => {
|
||||
// Using `.includes()` will result a type error
|
||||
|
@ -159,12 +159,14 @@ const rotateConfig: CommandModule<unknown, { key: string; tenantId: string }> =
|
|||
const original = parsed.success ? parsed.data : [];
|
||||
|
||||
// No need for default. It's already exhaustive
|
||||
// eslint-disable-next-line default-case
|
||||
switch (key) {
|
||||
case LogtoOidcConfigKey.PrivateKeys:
|
||||
case LogtoOidcConfigKey.PrivateKeys: {
|
||||
return [await generateOidcPrivateKey(), ...original];
|
||||
case LogtoOidcConfigKey.CookieKeys:
|
||||
}
|
||||
|
||||
case LogtoOidcConfigKey.CookieKeys: {
|
||||
return [generateOidcCookieKey(), ...original];
|
||||
}
|
||||
}
|
||||
};
|
||||
const rotated = await getValue();
|
||||
|
|
|
@ -11,7 +11,7 @@ import { createTables, seedTables } from './tables.js';
|
|||
|
||||
const seedChoices = Object.freeze(['all', 'oidc'] as const);
|
||||
|
||||
type SeedChoice = typeof seedChoices[number];
|
||||
type SeedChoice = (typeof seedChoices)[number];
|
||||
|
||||
export const seedByPool = async (pool: DatabasePool, type: SeedChoice) => {
|
||||
await pool.transaction(async (connection) => {
|
||||
|
|
|
@ -31,7 +31,7 @@ export const updateValueByKey = async <T extends LogtoConfigKey>(
|
|||
pool: CommonQueryMethods,
|
||||
tenantId: string,
|
||||
key: T,
|
||||
value: z.infer<typeof logtoConfigGuards[T]>
|
||||
value: z.infer<(typeof logtoConfigGuards)[T]>
|
||||
) =>
|
||||
pool.query(
|
||||
sql`
|
||||
|
|
|
@ -31,11 +31,11 @@
|
|||
"@parcel/transformer-mdx": "2.8.3",
|
||||
"@parcel/transformer-sass": "2.8.3",
|
||||
"@parcel/transformer-svg-react": "2.8.3",
|
||||
"@silverhand/eslint-config": "1.3.0",
|
||||
"@silverhand/eslint-config-react": "1.3.0",
|
||||
"@silverhand/eslint-config": "2.0.1",
|
||||
"@silverhand/eslint-config-react": "2.0.1",
|
||||
"@silverhand/essentials": "2.1.0",
|
||||
"@silverhand/ts-config": "1.2.1",
|
||||
"@silverhand/ts-config-react": "1.2.1",
|
||||
"@silverhand/ts-config": "2.0.0",
|
||||
"@silverhand/ts-config-react": "2.0.0",
|
||||
"@tsconfig/docusaurus": "^1.0.5",
|
||||
"@types/color": "^3.0.3",
|
||||
"@types/mdx": "^2.0.1",
|
||||
|
@ -54,7 +54,7 @@
|
|||
"deep-object-diff": "^1.1.7",
|
||||
"deepmerge": "^4.2.2",
|
||||
"dnd-core": "^16.0.0",
|
||||
"eslint": "^8.21.0",
|
||||
"eslint": "^8.34.0",
|
||||
"history": "^5.3.0",
|
||||
"i18next": "^21.8.16",
|
||||
"i18next-browser-languagedetector": "^6.1.4",
|
||||
|
@ -67,7 +67,7 @@
|
|||
"parcel": "2.8.3",
|
||||
"postcss": "^8.4.6",
|
||||
"postcss-modules": "^4.3.0",
|
||||
"prettier": "^2.8.1",
|
||||
"prettier": "^2.8.2",
|
||||
"process": "^0.11.10",
|
||||
"prop-types": "^15.8.1",
|
||||
"react": "^18.0.0",
|
||||
|
@ -107,10 +107,7 @@
|
|||
"@mdx/components/*": "./src/mdx-components/$1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "@silverhand/react",
|
||||
"rules": {
|
||||
"complexity": "off"
|
||||
}
|
||||
"extends": "@silverhand/react"
|
||||
},
|
||||
"stylelint": {
|
||||
"extends": "@silverhand/eslint-config-react/.stylelintrc"
|
||||
|
|
|
@ -4,12 +4,17 @@ import type { TipBubblePlacement } from '.';
|
|||
|
||||
export const getVerticalOffset = (placement: TipBubblePlacement) => {
|
||||
switch (placement) {
|
||||
case 'top':
|
||||
case 'top': {
|
||||
return -16;
|
||||
case 'bottom':
|
||||
}
|
||||
|
||||
case 'bottom': {
|
||||
return 16;
|
||||
default:
|
||||
}
|
||||
|
||||
default: {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -19,12 +24,17 @@ export const getHorizontalOffset = (
|
|||
): number => {
|
||||
if (placement === 'top' || placement === 'bottom') {
|
||||
switch (horizontalAlignment) {
|
||||
case 'start':
|
||||
case 'start': {
|
||||
return -32;
|
||||
case 'end':
|
||||
}
|
||||
|
||||
case 'end': {
|
||||
return 32;
|
||||
default:
|
||||
}
|
||||
|
||||
default: {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return placement === 'left' ? -32 : 32;
|
||||
|
@ -33,12 +43,17 @@ export const getHorizontalOffset = (
|
|||
|
||||
export const getVerticalAlignment = (placement: TipBubblePlacement): VerticalAlignment => {
|
||||
switch (placement) {
|
||||
case 'top':
|
||||
case 'top': {
|
||||
return 'top';
|
||||
case 'bottom':
|
||||
}
|
||||
|
||||
case 'bottom': {
|
||||
return 'bottom';
|
||||
default:
|
||||
}
|
||||
|
||||
default: {
|
||||
return 'middle';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -47,11 +62,16 @@ export const getHorizontalAlignment = (
|
|||
fallback: HorizontalAlignment
|
||||
): HorizontalAlignment => {
|
||||
switch (placement) {
|
||||
case 'right':
|
||||
case 'right': {
|
||||
return 'start';
|
||||
case 'left':
|
||||
}
|
||||
|
||||
case 'left': {
|
||||
return 'end';
|
||||
default:
|
||||
}
|
||||
|
||||
default: {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@ type Props = {
|
|||
// A very rough duck type, but good enough to guard against mistakes while
|
||||
// allowing customization
|
||||
function isTabItem(comp: ReactElement): comp is ReactElement<TabItemProps> {
|
||||
return typeof comp.props.value !== 'undefined';
|
||||
return comp.props.value !== undefined;
|
||||
}
|
||||
|
||||
const Tabs = ({ className, children }: Props): JSX.Element => {
|
||||
|
@ -63,8 +63,10 @@ const Tabs = ({ className, children }: Props): JSX.Element => {
|
|||
null;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
focusElement?.focus();
|
||||
|
|
|
@ -23,24 +23,41 @@ const getSampleProjectUrl = (sdk: SupportedSdk) => {
|
|||
const githubUrlPrefix = 'https://github.com/logto-io';
|
||||
|
||||
switch (sdk) {
|
||||
case SupportedSdk.iOS:
|
||||
case SupportedSdk.iOS: {
|
||||
return `${githubUrlPrefix}/swift/tree/master/Demos/SwiftUI%20Demo`;
|
||||
case SupportedSdk.Android:
|
||||
}
|
||||
|
||||
case SupportedSdk.Android: {
|
||||
return `${githubUrlPrefix}/kotlin/tree/master/android-sample-kotlin`;
|
||||
case SupportedSdk.React:
|
||||
}
|
||||
|
||||
case SupportedSdk.React: {
|
||||
return `${githubUrlPrefix}/js/tree/master/packages/react-sample`;
|
||||
case SupportedSdk.Vue:
|
||||
}
|
||||
|
||||
case SupportedSdk.Vue: {
|
||||
return `${githubUrlPrefix}/js/tree/master/packages/vue-sample`;
|
||||
case SupportedSdk.Vanilla:
|
||||
}
|
||||
|
||||
case SupportedSdk.Vanilla: {
|
||||
return `${githubUrlPrefix}/js/tree/master/packages/browser-sample`;
|
||||
case SupportedSdk.Next:
|
||||
}
|
||||
|
||||
case SupportedSdk.Next: {
|
||||
return `${githubUrlPrefix}/js/tree/master/packages/next-sample`;
|
||||
case SupportedSdk.Express:
|
||||
}
|
||||
|
||||
case SupportedSdk.Express: {
|
||||
return `${githubUrlPrefix}/js/tree/master/packages/express-sample`;
|
||||
case SupportedSdk.Go:
|
||||
}
|
||||
|
||||
case SupportedSdk.Go: {
|
||||
return `${githubUrlPrefix}/go/tree/master/gin-sample`;
|
||||
default:
|
||||
}
|
||||
|
||||
default: {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -73,8 +73,8 @@
|
|||
"zod": "^3.20.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@silverhand/eslint-config": "1.3.0",
|
||||
"@silverhand/ts-config": "1.2.1",
|
||||
"@silverhand/eslint-config": "2.0.1",
|
||||
"@silverhand/ts-config": "2.0.0",
|
||||
"@types/debug": "^4.1.7",
|
||||
"@types/etag": "^1.8.1",
|
||||
"@types/http-errors": "^1.8.2",
|
||||
|
@ -92,7 +92,7 @@
|
|||
"@types/sinon": "^10.0.13",
|
||||
"@types/supertest": "^2.0.11",
|
||||
"copyfiles": "^2.4.1",
|
||||
"eslint": "^8.21.0",
|
||||
"eslint": "^8.34.0",
|
||||
"http-errors": "^1.6.3",
|
||||
"jest": "^29.1.2",
|
||||
"jest-matcher-specific-error": "^1.0.0",
|
||||
|
@ -100,7 +100,7 @@
|
|||
"node-mocks-http": "^1.12.1",
|
||||
"nodemon": "^2.0.19",
|
||||
"openapi-types": "^12.0.0",
|
||||
"prettier": "^2.8.1",
|
||||
"prettier": "^2.8.2",
|
||||
"sinon": "^15.0.0",
|
||||
"supertest": "^6.2.2",
|
||||
"typescript": "^4.9.4"
|
||||
|
@ -109,25 +109,7 @@
|
|||
"node": "^18.12.0"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "@silverhand",
|
||||
"rules": {
|
||||
"complexity": [
|
||||
"error",
|
||||
11
|
||||
],
|
||||
"default-case": "off",
|
||||
"import/extensions": "off"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.test.ts"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/ban-ts-comment": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
"extends": "@silverhand"
|
||||
},
|
||||
"prettier": "@silverhand/eslint-config/.prettierrc"
|
||||
}
|
||||
|
|
|
@ -28,14 +28,18 @@ export default function koaConnectorErrorHandler<StateT, ContextT>(): Middleware
|
|||
case ConnectorErrorCodes.InvalidRequestParameters:
|
||||
case ConnectorErrorCodes.InsufficientRequestParameters:
|
||||
case ConnectorErrorCodes.InvalidConfig:
|
||||
case ConnectorErrorCodes.InvalidResponse:
|
||||
case ConnectorErrorCodes.InvalidResponse: {
|
||||
throw new RequestError({ code: `connector.${code}`, status: 400 }, data);
|
||||
}
|
||||
|
||||
case ConnectorErrorCodes.SocialAuthCodeInvalid:
|
||||
case ConnectorErrorCodes.SocialAccessTokenInvalid:
|
||||
case ConnectorErrorCodes.SocialIdTokenInvalid:
|
||||
case ConnectorErrorCodes.AuthorizationFailed:
|
||||
case ConnectorErrorCodes.AuthorizationFailed: {
|
||||
throw new RequestError({ code: `connector.${code}`, status: 401 }, data);
|
||||
case ConnectorErrorCodes.TemplateNotFound:
|
||||
}
|
||||
|
||||
case ConnectorErrorCodes.TemplateNotFound: {
|
||||
throw new RequestError(
|
||||
{
|
||||
code: `connector.${code}`,
|
||||
|
@ -43,10 +47,13 @@ export default function koaConnectorErrorHandler<StateT, ContextT>(): Middleware
|
|||
},
|
||||
data
|
||||
);
|
||||
case ConnectorErrorCodes.NotImplemented:
|
||||
throw new RequestError({ code: `connector.${code}`, status: 501 }, data);
|
||||
}
|
||||
|
||||
default:
|
||||
case ConnectorErrorCodes.NotImplemented: {
|
||||
throw new RequestError({ code: `connector.${code}`, status: 501 }, data);
|
||||
}
|
||||
|
||||
default: {
|
||||
throw new RequestError(
|
||||
{
|
||||
code: `connector.${code}`,
|
||||
|
@ -55,6 +62,7 @@ export default function koaConnectorErrorHandler<StateT, ContextT>(): Middleware
|
|||
},
|
||||
data
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -44,7 +44,7 @@ export default function koaOIDCErrorHandler<StateT, ContextT>(): Middleware<Stat
|
|||
case errors.UnsupportedGrantType:
|
||||
case errors.UnsupportedResponseMode:
|
||||
case errors.UnsupportedResponseType:
|
||||
case errors.InvalidGrant:
|
||||
case errors.InvalidGrant: {
|
||||
throw new RequestError(
|
||||
{
|
||||
// Manually mapped all OIDC error name to the LogtoErrorCode
|
||||
|
@ -56,7 +56,9 @@ export default function koaOIDCErrorHandler<StateT, ContextT>(): Middleware<Stat
|
|||
},
|
||||
data
|
||||
);
|
||||
case errors.SessionNotFound:
|
||||
}
|
||||
|
||||
case errors.SessionNotFound: {
|
||||
throw new RequestError(
|
||||
{
|
||||
code: 'session.not_found',
|
||||
|
@ -66,7 +68,9 @@ export default function koaOIDCErrorHandler<StateT, ContextT>(): Middleware<Stat
|
|||
},
|
||||
data
|
||||
);
|
||||
case errors.InsufficientScope:
|
||||
}
|
||||
|
||||
case errors.InsufficientScope: {
|
||||
throw new RequestError(
|
||||
{
|
||||
code: 'oidc.insufficient_scope',
|
||||
|
@ -76,7 +80,9 @@ export default function koaOIDCErrorHandler<StateT, ContextT>(): Middleware<Stat
|
|||
},
|
||||
data
|
||||
);
|
||||
default:
|
||||
}
|
||||
|
||||
default: {
|
||||
throw new RequestError(
|
||||
{
|
||||
code: 'oidc.provider_error',
|
||||
|
@ -86,6 +92,7 @@ export default function koaOIDCErrorHandler<StateT, ContextT>(): Middleware<Stat
|
|||
},
|
||||
data
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -130,12 +130,17 @@ export default function initOidc(envSet: EnvSet, queries: Queries, libraries: Li
|
|||
interactions: {
|
||||
url: (_, interaction) => {
|
||||
switch (interaction.prompt.name) {
|
||||
case 'login':
|
||||
case 'login': {
|
||||
return routes.signIn.credentials;
|
||||
case 'consent':
|
||||
}
|
||||
|
||||
case 'consent': {
|
||||
return routes.signIn.consent;
|
||||
default:
|
||||
}
|
||||
|
||||
default: {
|
||||
throw new Error(`Prompt not supported: ${interaction.prompt.name}`);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
@ -15,10 +15,13 @@ export const getConstantClientMetadata = (
|
|||
const getTokenEndpointAuthMethod = (): ClientAuthMethod => {
|
||||
switch (type) {
|
||||
case ApplicationType.Native:
|
||||
case ApplicationType.SPA:
|
||||
case ApplicationType.SPA: {
|
||||
return 'none';
|
||||
default:
|
||||
}
|
||||
|
||||
default: {
|
||||
return 'client_secret_basic';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -10,25 +10,30 @@ import { exportJWK as joseExportJWK } from 'jose';
|
|||
|
||||
const getCalculateKidComponents = (jwk: JWK) => {
|
||||
switch (jwk.kty) {
|
||||
case 'RSA':
|
||||
case 'RSA': {
|
||||
return {
|
||||
e: jwk.e,
|
||||
kty: 'RSA',
|
||||
n: jwk.n,
|
||||
};
|
||||
case 'EC':
|
||||
}
|
||||
|
||||
case 'EC': {
|
||||
return {
|
||||
crv: jwk.crv,
|
||||
kty: 'EC',
|
||||
x: jwk.x,
|
||||
y: jwk.y,
|
||||
};
|
||||
case 'OKP':
|
||||
}
|
||||
|
||||
case 'OKP': {
|
||||
return {
|
||||
crv: jwk.crv,
|
||||
kty: 'OKP',
|
||||
x: jwk.x,
|
||||
};
|
||||
}
|
||||
default:
|
||||
}
|
||||
};
|
||||
|
|
|
@ -159,28 +159,38 @@ export const parseSearchParamsForSearch = (
|
|||
|
||||
const getJointModeSql = (mode: SearchJointMode) => {
|
||||
switch (mode) {
|
||||
case SearchJointMode.And:
|
||||
case SearchJointMode.And: {
|
||||
return sql` and `;
|
||||
case SearchJointMode.Or:
|
||||
}
|
||||
|
||||
case SearchJointMode.Or: {
|
||||
return sql` or `;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const getMatchModeOperator = (match: SearchMatchMode, isCaseSensitive: boolean) => {
|
||||
switch (match) {
|
||||
case SearchMatchMode.Exact:
|
||||
case SearchMatchMode.Exact: {
|
||||
return sql`=`;
|
||||
case SearchMatchMode.Like:
|
||||
}
|
||||
|
||||
case SearchMatchMode.Like: {
|
||||
return isCaseSensitive ? sql`~~` : sql`~~*`;
|
||||
case SearchMatchMode.SimilarTo:
|
||||
}
|
||||
|
||||
case SearchMatchMode.SimilarTo: {
|
||||
assertThat(
|
||||
isCaseSensitive,
|
||||
new TypeError('Cannot use case-insensitive match for `similar to`.')
|
||||
);
|
||||
|
||||
return sql`similar to`;
|
||||
case SearchMatchMode.Posix:
|
||||
}
|
||||
|
||||
case SearchMatchMode.Posix: {
|
||||
return isCaseSensitive ? sql`~` : sql`~*`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -63,16 +63,19 @@ const zodStringCheckToSwaggerFormat = (zodStringCheck: ZodStringCheck) => {
|
|||
case 'url':
|
||||
case 'uuid':
|
||||
case 'cuid':
|
||||
case 'regex':
|
||||
case 'regex': {
|
||||
return kind;
|
||||
}
|
||||
|
||||
case 'min':
|
||||
case 'max':
|
||||
case 'max': {
|
||||
// Do nothing here
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
default: {
|
||||
throw new RequestError('swagger.invalid_zod_type', zodStringCheck);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -107,23 +110,30 @@ const zodLiteralToSwagger = (zodLiteral: ZodLiteral<unknown>): OpenAPIV3.SchemaO
|
|||
const { value } = zodLiteral;
|
||||
|
||||
switch (typeof value) {
|
||||
case 'boolean':
|
||||
case 'boolean': {
|
||||
return {
|
||||
type: 'boolean',
|
||||
format: String(value),
|
||||
};
|
||||
case 'number':
|
||||
}
|
||||
|
||||
case 'number': {
|
||||
return {
|
||||
type: 'number',
|
||||
format: String(value),
|
||||
};
|
||||
case 'string':
|
||||
}
|
||||
|
||||
case 'string': {
|
||||
return {
|
||||
type: 'string',
|
||||
format: value === '' ? 'empty' : `"${value}"`,
|
||||
};
|
||||
default:
|
||||
}
|
||||
|
||||
default: {
|
||||
throw new RequestError('swagger.invalid_zod_type', zodLiteral);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -23,21 +23,21 @@
|
|||
"@logto/schemas": "workspace:*",
|
||||
"@parcel/core": "2.8.3",
|
||||
"@parcel/transformer-sass": "2.8.3",
|
||||
"@silverhand/eslint-config": "1.3.0",
|
||||
"@silverhand/eslint-config-react": "1.3.0",
|
||||
"@silverhand/ts-config": "1.2.1",
|
||||
"@silverhand/ts-config-react": "1.2.1",
|
||||
"@silverhand/eslint-config": "2.0.1",
|
||||
"@silverhand/eslint-config-react": "2.0.1",
|
||||
"@silverhand/ts-config": "2.0.0",
|
||||
"@silverhand/ts-config-react": "2.0.0",
|
||||
"@types/react": "^18.0.0",
|
||||
"@types/react-dom": "^18.0.0",
|
||||
"buffer": "^5.7.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.21.0",
|
||||
"eslint": "^8.34.0",
|
||||
"i18next": "^21.8.16",
|
||||
"i18next-browser-languagedetector": "^6.1.4",
|
||||
"lint-staged": "^13.0.0",
|
||||
"parcel": "2.8.3",
|
||||
"postcss": "^8.4.6",
|
||||
"prettier": "^2.8.1",
|
||||
"prettier": "^2.8.2",
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0",
|
||||
"react-i18next": "^11.18.3",
|
||||
|
@ -60,10 +60,7 @@
|
|||
"@/*": "./src/$1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "@silverhand/react",
|
||||
"rules": {
|
||||
"complexity": "off"
|
||||
}
|
||||
"extends": "@silverhand/react"
|
||||
},
|
||||
"stylelint": {
|
||||
"extends": "@silverhand/eslint-config-react/.stylelintrc"
|
||||
|
|
|
@ -26,21 +26,21 @@
|
|||
"@logto/node": "1.0.0-rc.0",
|
||||
"@logto/schemas": "workspace:*",
|
||||
"@peculiar/webcrypto": "^1.3.3",
|
||||
"@silverhand/eslint-config": "1.3.0",
|
||||
"@silverhand/eslint-config": "2.0.1",
|
||||
"@silverhand/essentials": "2.1.0",
|
||||
"@silverhand/ts-config": "1.2.1",
|
||||
"@silverhand/ts-config": "2.0.0",
|
||||
"@types/jest": "^29.1.2",
|
||||
"@types/jest-environment-puppeteer": "^5.0.2",
|
||||
"@types/node": "^18.11.18",
|
||||
"dotenv": "^16.0.0",
|
||||
"eslint": "^8.21.0",
|
||||
"eslint": "^8.34.0",
|
||||
"got": "^12.5.3",
|
||||
"jest": "^29.1.2",
|
||||
"jest-puppeteer": "^7.0.0",
|
||||
"node-fetch": "^3.3.0",
|
||||
"openapi-schema-validator": "^12.0.0",
|
||||
"openapi-types": "^12.0.0",
|
||||
"prettier": "^2.8.1",
|
||||
"prettier": "^2.8.2",
|
||||
"puppeteer": "^19.0.0",
|
||||
"text-encoder": "^0.0.4",
|
||||
"typescript": "^4.9.4"
|
||||
|
|
|
@ -36,8 +36,6 @@ describe('admin console user search params', () => {
|
|||
const emailSuffix = ['@gmail.com', '@foo.bar', '@geek.best'];
|
||||
const phonePrefix = ['101', '102', '202'];
|
||||
|
||||
// We can make sure this
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
// eslint-disable-next-line @silverhand/fp/no-mutation
|
||||
users = await Promise.all(
|
||||
rawNames.map((raw, index) => {
|
||||
|
@ -61,7 +59,6 @@ describe('admin console user search params', () => {
|
|||
);
|
||||
})
|
||||
);
|
||||
/* eslint-enable @typescript-eslint/no-non-null-assertion */
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
@ -158,8 +155,6 @@ describe('admin console user search params', () => {
|
|||
});
|
||||
|
||||
it('should accept multiple value for exact match 2', async () => {
|
||||
// We can make sure this
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
const { headers, json } = await getUsers<User[]>([
|
||||
['search.id', users[0]!.id],
|
||||
['search.id', users[1]!.id],
|
||||
|
@ -169,7 +164,6 @@ describe('admin console user search params', () => {
|
|||
['mode.id', 'exact'],
|
||||
['isCaseSensitive', 'true'],
|
||||
]);
|
||||
/* eslint-enable @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
expect(headers['total-number']).toEqual('3');
|
||||
expect(
|
||||
|
|
|
@ -39,12 +39,12 @@
|
|||
"zod": "^3.20.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@silverhand/eslint-config": "1.3.0",
|
||||
"@silverhand/ts-config": "1.2.1",
|
||||
"@silverhand/eslint-config": "2.0.1",
|
||||
"@silverhand/ts-config": "2.0.0",
|
||||
"buffer": "^5.7.1",
|
||||
"eslint": "^8.21.0",
|
||||
"eslint": "^8.34.0",
|
||||
"lint-staged": "^13.0.0",
|
||||
"prettier": "^2.8.1",
|
||||
"prettier": "^2.8.2",
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
"engines": {
|
||||
|
|
|
@ -39,11 +39,11 @@
|
|||
"zod": "^3.20.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@silverhand/eslint-config": "1.3.0",
|
||||
"@silverhand/ts-config": "1.2.1",
|
||||
"eslint": "^8.21.0",
|
||||
"@silverhand/eslint-config": "2.0.1",
|
||||
"@silverhand/ts-config": "2.0.0",
|
||||
"eslint": "^8.34.0",
|
||||
"lint-staged": "^13.0.0",
|
||||
"prettier": "^2.8.1",
|
||||
"prettier": "^2.8.2",
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
"eslintConfig": {
|
||||
|
|
|
@ -40,19 +40,19 @@
|
|||
"node": "^18.12.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@silverhand/eslint-config": "1.3.0",
|
||||
"@silverhand/eslint-config": "2.0.1",
|
||||
"@silverhand/essentials": "2.1.0",
|
||||
"@silverhand/ts-config": "1.2.1",
|
||||
"@silverhand/ts-config": "2.0.0",
|
||||
"@types/inquirer": "^9.0.0",
|
||||
"@types/jest": "^29.1.2",
|
||||
"@types/node": "^18.11.18",
|
||||
"@types/pluralize": "^0.0.29",
|
||||
"camelcase": "^7.0.0",
|
||||
"eslint": "^8.21.0",
|
||||
"eslint": "^8.34.0",
|
||||
"jest": "^29.1.2",
|
||||
"lint-staged": "^13.0.0",
|
||||
"pluralize": "^8.0.0",
|
||||
"prettier": "^2.8.1",
|
||||
"prettier": "^2.8.2",
|
||||
"roarr": "^7.11.0",
|
||||
"slonik": "^30.0.0",
|
||||
"slonik-sql-tag-raw": "^1.1.4",
|
||||
|
|
|
@ -58,22 +58,19 @@ export const generateSchema = ({ name, fields }: TableWithType) => {
|
|||
'',
|
||||
`const guard: Guard<${modelName}> = z.object({`,
|
||||
|
||||
...fields.map(
|
||||
// eslint-disable-next-line complexity
|
||||
({ name, type, isArray, isEnum, nullable, tsType, isString, maxLength }) => {
|
||||
if (tsType) {
|
||||
return ` ${camelcase(name)}: ${camelcase(tsType)}Guard${conditionalString(
|
||||
nullable && '.nullable()'
|
||||
)},`;
|
||||
}
|
||||
|
||||
return ` ${camelcase(name)}: z.${
|
||||
isEnum ? `nativeEnum(${type})` : `${type}()`
|
||||
}${conditionalString(isString && maxLength && `.max(${maxLength})`)}${conditionalString(
|
||||
isArray && '.array()'
|
||||
)}${conditionalString(nullable && '.nullable()')},`;
|
||||
...fields.map(({ name, type, isArray, isEnum, nullable, tsType, isString, maxLength }) => {
|
||||
if (tsType) {
|
||||
return ` ${camelcase(name)}: ${camelcase(tsType)}Guard${conditionalString(
|
||||
nullable && '.nullable()'
|
||||
)},`;
|
||||
}
|
||||
),
|
||||
|
||||
return ` ${camelcase(name)}: z.${
|
||||
isEnum ? `nativeEnum(${type})` : `${type}()`
|
||||
}${conditionalString(isString && maxLength && `.max(${maxLength})`)}${conditionalString(
|
||||
isArray && '.array()'
|
||||
)}${conditionalString(nullable && '.nullable()')},`;
|
||||
}),
|
||||
' });',
|
||||
'',
|
||||
`export const ${camelcase(name, {
|
||||
|
|
|
@ -121,8 +121,10 @@ export const getType = (
|
|||
case 'time':
|
||||
case 'timetz':
|
||||
case 'interval':
|
||||
case 'name':
|
||||
case 'name': {
|
||||
return 'string';
|
||||
}
|
||||
|
||||
case 'int2':
|
||||
case 'int4':
|
||||
case 'int8':
|
||||
|
@ -134,13 +136,19 @@ export const getType = (
|
|||
case 'oid':
|
||||
case 'date':
|
||||
case 'timestamp':
|
||||
case 'timestamptz':
|
||||
case 'timestamptz': {
|
||||
return 'number';
|
||||
case 'boolean': // https://www.postgresql.org/docs/14/datatype-boolean.html
|
||||
}
|
||||
|
||||
case 'boolean': {
|
||||
// https://www.postgresql.org/docs/14/datatype-boolean.html
|
||||
return 'boolean';
|
||||
}
|
||||
|
||||
case 'json':
|
||||
case 'jsonb':
|
||||
case 'jsonb': {
|
||||
return 'Record<string, unknown>';
|
||||
}
|
||||
default:
|
||||
}
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ export type HookEventPayload = {
|
|||
sessionId?: string;
|
||||
userAgent?: string;
|
||||
userId?: string;
|
||||
user?: Pick<User, typeof userInfoSelectFields[number]>;
|
||||
user?: Pick<User, (typeof userInfoSelectFields)[number]>;
|
||||
application?: Pick<Application, 'id' | 'type' | 'name' | 'description'>;
|
||||
} & Record<string, unknown>;
|
||||
|
||||
|
|
|
@ -26,9 +26,7 @@ export type SystemKey = AlterationStateKey;
|
|||
export type SystemType = AlterationStateType;
|
||||
export type SystemGuard = typeof alterationStateGuard;
|
||||
|
||||
export const systemKeys: readonly SystemKey[] = Object.freeze([
|
||||
...Object.values(AlterationStateKey),
|
||||
]);
|
||||
export const systemKeys: readonly SystemKey[] = Object.freeze(Object.values(AlterationStateKey));
|
||||
|
||||
export const systemGuards: SystemGuard = Object.freeze({
|
||||
...alterationStateGuard,
|
||||
|
|
|
@ -15,7 +15,7 @@ export const userInfoSelectFields = Object.freeze([
|
|||
'isSuspended',
|
||||
] as const);
|
||||
|
||||
export type UserInfo<Keys extends keyof CreateUser = typeof userInfoSelectFields[number]> = Pick<
|
||||
export type UserInfo<Keys extends keyof CreateUser = (typeof userInfoSelectFields)[number]> = Pick<
|
||||
CreateUser,
|
||||
Keys
|
||||
>;
|
||||
|
|
|
@ -34,14 +34,14 @@
|
|||
"devDependencies": {
|
||||
"@logto/connector-kit": "workspace:*",
|
||||
"@logto/core-kit": "workspace:*",
|
||||
"@silverhand/eslint-config": "1.3.0",
|
||||
"@silverhand/ts-config": "1.2.1",
|
||||
"@silverhand/eslint-config": "2.0.1",
|
||||
"@silverhand/ts-config": "2.0.0",
|
||||
"@types/jest": "^29.1.2",
|
||||
"@types/node": "^18.11.18",
|
||||
"eslint": "^8.21.0",
|
||||
"eslint": "^8.34.0",
|
||||
"jest": "^29.1.2",
|
||||
"lint-staged": "^13.0.0",
|
||||
"prettier": "^2.8.1",
|
||||
"prettier": "^2.8.2",
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
"engines": {
|
||||
|
|
|
@ -14,8 +14,8 @@ export const conditionalArraySql = <T>(
|
|||
) => (value.length > 0 ? buildSql(value) : sql``);
|
||||
|
||||
export const autoSetFields = Object.freeze(['createdAt', 'updatedAt'] as const);
|
||||
export type OmitAutoSetFields<T> = Omit<T, typeof autoSetFields[number]>;
|
||||
export type ExcludeAutoSetFields<T> = Exclude<T, typeof autoSetFields[number]>;
|
||||
export type OmitAutoSetFields<T> = Omit<T, (typeof autoSetFields)[number]>;
|
||||
export type ExcludeAutoSetFields<T> = Exclude<T, (typeof autoSetFields)[number]>;
|
||||
export const excludeAutoSetFields = <T extends string>(fields: readonly T[]) =>
|
||||
Object.freeze(
|
||||
fields.filter(
|
||||
|
@ -34,7 +34,7 @@ export const excludeAutoSetFields = <T extends string>(fields: readonly T[]) =>
|
|||
* @param value The value to convert.
|
||||
* @returns A primitive that can be saved into database.
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
|
||||
export const convertToPrimitiveOrSql = (
|
||||
key: string,
|
||||
value: NonNullable<SchemaValue> | null
|
||||
|
|
|
@ -40,12 +40,12 @@
|
|||
"zod": "^3.20.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@silverhand/eslint-config": "1.3.0",
|
||||
"@silverhand/ts-config": "1.2.1",
|
||||
"@silverhand/eslint-config": "2.0.1",
|
||||
"@silverhand/ts-config": "2.0.0",
|
||||
"@types/node": "^18.11.18",
|
||||
"eslint": "^8.21.0",
|
||||
"eslint": "^8.34.0",
|
||||
"lint-staged": "^13.0.0",
|
||||
"prettier": "^2.8.1",
|
||||
"prettier": "^2.8.2",
|
||||
"tslib": "^2.4.1",
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
|
|
|
@ -48,19 +48,19 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@jest/types": "^29.0.3",
|
||||
"@silverhand/eslint-config": "1.3.0",
|
||||
"@silverhand/eslint-config-react": "1.3.0",
|
||||
"@silverhand/eslint-config": "2.0.1",
|
||||
"@silverhand/eslint-config-react": "2.0.1",
|
||||
"@silverhand/essentials": "2.1.0",
|
||||
"@silverhand/ts-config": "1.2.1",
|
||||
"@silverhand/ts-config": "2.0.0",
|
||||
"@types/color": "^3.0.3",
|
||||
"@types/jest": "^29.0.3",
|
||||
"@types/node": "^18.11.18",
|
||||
"@types/react": "^18.0.20",
|
||||
"eslint": "^8.21.0",
|
||||
"eslint": "^8.34.0",
|
||||
"jest": "^29.0.3",
|
||||
"lint-staged": "^13.0.0",
|
||||
"postcss": "^8.4.6",
|
||||
"prettier": "^2.8.1",
|
||||
"prettier": "^2.8.2",
|
||||
"stylelint": "^15.0.0",
|
||||
"tslib": "^2.4.1",
|
||||
"typescript": "^4.9.4"
|
||||
|
|
|
@ -39,14 +39,14 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@jest/types": "^29.0.3",
|
||||
"@silverhand/eslint-config": "1.3.0",
|
||||
"@silverhand/ts-config": "1.2.1",
|
||||
"@silverhand/eslint-config": "2.0.1",
|
||||
"@silverhand/ts-config": "2.0.0",
|
||||
"@types/jest": "^29.0.3",
|
||||
"@types/node": "^18.11.18",
|
||||
"eslint": "^8.21.0",
|
||||
"eslint": "^8.34.0",
|
||||
"jest": "^29.0.3",
|
||||
"lint-staged": "^13.0.0",
|
||||
"prettier": "^2.8.1",
|
||||
"prettier": "^2.8.2",
|
||||
"tslib": "^2.4.1",
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
|
|
|
@ -28,12 +28,12 @@
|
|||
"@parcel/transformer-svg-react": "2.8.3",
|
||||
"@peculiar/webcrypto": "^1.3.3",
|
||||
"@react-spring/web": "^9.6.1",
|
||||
"@silverhand/eslint-config": "1.3.0",
|
||||
"@silverhand/eslint-config-react": "1.3.0",
|
||||
"@silverhand/eslint-config": "2.0.1",
|
||||
"@silverhand/eslint-config-react": "2.0.1",
|
||||
"@silverhand/essentials": "2.1.0",
|
||||
"@silverhand/jest-config": "1.2.2",
|
||||
"@silverhand/ts-config": "1.2.1",
|
||||
"@silverhand/ts-config-react": "1.2.1",
|
||||
"@silverhand/ts-config": "2.0.0",
|
||||
"@silverhand/ts-config-react": "2.0.0",
|
||||
"@testing-library/react": "^13.3.0",
|
||||
"@types/color": "^3.0.3",
|
||||
"@types/jest": "^29.1.2",
|
||||
|
@ -45,7 +45,7 @@
|
|||
"classnames": "^2.3.1",
|
||||
"color": "^4.2.3",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.21.0",
|
||||
"eslint": "^8.34.0",
|
||||
"i18next": "^21.8.16",
|
||||
"i18next-browser-languagedetector": "^6.1.4",
|
||||
"jest": "^29.1.2",
|
||||
|
@ -58,7 +58,7 @@
|
|||
"parcel": "2.8.3",
|
||||
"postcss": "^8.4.6",
|
||||
"postcss-modules": "^4.3.0",
|
||||
"prettier": "^2.8.1",
|
||||
"prettier": "^2.8.2",
|
||||
"react": "^18.0.0",
|
||||
"react-device-detect": "^2.2.2",
|
||||
"react-dom": "^18.0.0",
|
||||
|
@ -91,7 +91,6 @@
|
|||
"eslintConfig": {
|
||||
"extends": "@silverhand/react",
|
||||
"rules": {
|
||||
"complexity": "off",
|
||||
"jsx-a11y/no-autofocus": "off"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -138,7 +138,7 @@ const VerificationCode = ({
|
|||
const previousTarget = inputReferences.current[targetId - 1];
|
||||
|
||||
switch (key) {
|
||||
case 'Backspace':
|
||||
case 'Backspace': {
|
||||
event.preventDefault();
|
||||
|
||||
if (value) {
|
||||
|
@ -152,24 +152,32 @@ const VerificationCode = ({
|
|||
}
|
||||
|
||||
break;
|
||||
case 'ArrowLeft':
|
||||
}
|
||||
|
||||
case 'ArrowLeft': {
|
||||
event.preventDefault();
|
||||
previousTarget?.focus();
|
||||
break;
|
||||
case 'ArrowRight':
|
||||
}
|
||||
|
||||
case 'ArrowRight': {
|
||||
event.preventDefault();
|
||||
nextTarget?.focus();
|
||||
break;
|
||||
}
|
||||
case '+':
|
||||
case '-':
|
||||
case 'e':
|
||||
case '.':
|
||||
case 'ArrowUp':
|
||||
case 'ArrowDown':
|
||||
case 'ArrowDown': {
|
||||
event.preventDefault();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
[codes, onChange]
|
||||
|
|
|
@ -37,7 +37,7 @@ const useRequiredProfileErrorHandler = ({ replace, linkSocial, flow }: Options =
|
|||
|
||||
switch (missingProfile) {
|
||||
case MissingProfile.password:
|
||||
case MissingProfile.username:
|
||||
case MissingProfile.username: {
|
||||
navigate(
|
||||
{
|
||||
pathname: `/${UserFlow.continue}/${missingProfile}`,
|
||||
|
@ -45,9 +45,10 @@ const useRequiredProfileErrorHandler = ({ replace, linkSocial, flow }: Options =
|
|||
{ replace, state: { flow } }
|
||||
);
|
||||
break;
|
||||
}
|
||||
case MissingProfile.email:
|
||||
case MissingProfile.phone:
|
||||
case MissingProfile.emailOrPhone:
|
||||
case MissingProfile.emailOrPhone: {
|
||||
navigate(
|
||||
{
|
||||
pathname: `/${UserFlow.continue}/${missingProfile}`,
|
||||
|
@ -56,6 +57,7 @@ const useRequiredProfileErrorHandler = ({ replace, linkSocial, flow }: Options =
|
|||
{ replace, state: { registeredSocialIdentity, flow } }
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
setToast(error.message);
|
||||
|
|
|
@ -38,12 +38,17 @@ export const getGeneralIdentifierErrorMessage = (
|
|||
|
||||
export const validateIdentifierField = (type: IdentifierInputType, value: string) => {
|
||||
switch (type) {
|
||||
case SignInIdentifier.Username:
|
||||
case SignInIdentifier.Username: {
|
||||
return validateUsername(value);
|
||||
case SignInIdentifier.Email:
|
||||
}
|
||||
|
||||
case SignInIdentifier.Email: {
|
||||
return validateEmail(value);
|
||||
case SignInIdentifier.Phone:
|
||||
}
|
||||
|
||||
case SignInIdentifier.Phone: {
|
||||
return validatePhone(value);
|
||||
}
|
||||
default:
|
||||
}
|
||||
};
|
||||
|
|
685
pnpm-lock.yaml
generated
685
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue