mirror of
https://github.com/logto-io/logto.git
synced 2024-12-23 20:33:16 -05:00
refactor(core): reduce parameter
This commit is contained in:
parent
e6d3db6e80
commit
34ca8b9c6f
3 changed files with 11 additions and 12 deletions
|
@ -3,7 +3,6 @@ import {
|
|||
type OrganizationRole,
|
||||
type OrganizationRoleKeys,
|
||||
OrganizationRoles,
|
||||
OrganizationScopes,
|
||||
} from '@logto/schemas';
|
||||
import { UniqueIntegrityConstraintViolationError } from 'slonik';
|
||||
import { z } from 'zod';
|
||||
|
@ -85,7 +84,7 @@ export default function organizationRoleRoutes<T extends AuthedRouter>(
|
|||
}
|
||||
);
|
||||
|
||||
router.addRelationRoutes(OrganizationScopes, rolesScopes, 'scopes');
|
||||
router.addRelationRoutes(rolesScopes, 'scopes');
|
||||
|
||||
originalRouter.use(router.routes());
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Organizations, Users } from '@logto/schemas';
|
||||
import { Organizations } from '@logto/schemas';
|
||||
|
||||
import SchemaRouter, { SchemaActions } from '#src/utils/SchemaRouter.js';
|
||||
|
||||
|
@ -14,7 +14,7 @@ export default function organizationRoutes<T extends AuthedRouter>(
|
|||
) {
|
||||
const router = new SchemaRouter(Organizations, new SchemaActions(organizations));
|
||||
|
||||
router.addRelationRoutes(Users, organizations.relations.users);
|
||||
router.addRelationRoutes(organizations.relations.users);
|
||||
|
||||
originalRouter.use(router.routes());
|
||||
}
|
||||
|
|
|
@ -268,21 +268,21 @@ export default class SchemaRouter<
|
|||
* singular form with `Ids` suffix. For example, if the relation schema's table name is
|
||||
* `organization_roles`, the `[relationSchemaIds]` will be `organizationRoleIds`.
|
||||
*
|
||||
* @param relationSchema The schema of the relation to be added.
|
||||
* @param relationQueries The queries for the relation.
|
||||
* @param relationQueries The queries class for the relation.
|
||||
* @param pathname The pathname of the relation. If not provided, it will be
|
||||
* the camel case of the relation schema's table name.
|
||||
* @see {@link RelationQueries} for the `relationQueries` configuration.
|
||||
*/
|
||||
addRelationRoutes<
|
||||
RelationKey extends string,
|
||||
RelationCreateSchema extends Partial<SchemaLike<RelationKey> & { id: string }>,
|
||||
RelationSchema extends SchemaLike<RelationKey> & { id: string },
|
||||
RelationCreateSchema extends Partial<SchemaLike<string> & { id: string }>,
|
||||
RelationSchema extends SchemaLike<string> & { id: string },
|
||||
>(
|
||||
relationSchema: GeneratedSchema<RelationKey, RelationCreateSchema, RelationSchema>,
|
||||
relationQueries: RelationQueries<[typeof this.schema, typeof relationSchema]>,
|
||||
pathname = tableToPathname(relationSchema.table)
|
||||
relationQueries: RelationQueries<
|
||||
[typeof this.schema, GeneratedSchema<string, RelationCreateSchema, RelationSchema>]
|
||||
>,
|
||||
pathname = tableToPathname(relationQueries.schemas[1].table)
|
||||
) {
|
||||
const relationSchema = relationQueries.schemas[1];
|
||||
const columns = {
|
||||
schemaId: camelCaseSchemaId(this.schema),
|
||||
relationSchemaId: camelCaseSchemaId(relationSchema),
|
||||
|
|
Loading…
Reference in a new issue