mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
removed deprecated code
This commit is contained in:
parent
36a4edd93a
commit
0f9a560bdd
@ -1,69 +0,0 @@
|
||||
import { CrudTypeOf, createCrud } from "../../crud";
|
||||
import { yupBoolean, yupMixed, yupNumber, yupObject, yupString } from "../../schema-fields";
|
||||
|
||||
const baseApiKeysReadSchema = yupObject({
|
||||
id: yupString().required(),
|
||||
description: yupString().required(),
|
||||
expires_at_millis: yupNumber().required(),
|
||||
manually_revoked_at_millis: yupNumber().optional(),
|
||||
created_at_millis: yupNumber().required(),
|
||||
});
|
||||
|
||||
// Used for the result of the create endpoint
|
||||
export const apiKeysCreateInputSchema = yupObject({
|
||||
description: yupString().required(),
|
||||
expires_at_millis: yupNumber().required(),
|
||||
has_publishable_client_key: yupBoolean().required(),
|
||||
has_secret_server_key: yupBoolean().required(),
|
||||
has_super_secret_admin_key: yupBoolean().required(),
|
||||
});
|
||||
|
||||
export const apiKeysCreateOutputSchema = baseApiKeysReadSchema.concat(yupObject({
|
||||
publishable_client_key: yupString().optional(),
|
||||
secret_server_key: yupString().optional(),
|
||||
super_secret_admin_key: yupString().optional(),
|
||||
}).required());
|
||||
|
||||
// Used for list, read and update endpoints after the initial creation
|
||||
export const apiKeysCrudAdminObfuscatedReadSchema = baseApiKeysReadSchema.concat(yupObject({
|
||||
publishable_client_key: yupObject({
|
||||
last_four: yupString().required(),
|
||||
}).optional(),
|
||||
secret_server_key: yupObject({
|
||||
last_four: yupString().required(),
|
||||
}).optional(),
|
||||
super_secret_admin_key: yupObject({
|
||||
last_four: yupString().required(),
|
||||
}).optional(),
|
||||
}));
|
||||
|
||||
export const apiKeysCrudAdminUpdateSchema = yupObject({
|
||||
description: yupString().optional(),
|
||||
revoked: yupBoolean().oneOf([true]).optional(),
|
||||
}).required();
|
||||
|
||||
export const apiKeysCrudAdminDeleteSchema = yupMixed();
|
||||
|
||||
export const apiKeysCrud = createCrud({
|
||||
adminReadSchema: apiKeysCrudAdminObfuscatedReadSchema,
|
||||
adminUpdateSchema: apiKeysCrudAdminUpdateSchema,
|
||||
adminDeleteSchema: apiKeysCrudAdminDeleteSchema,
|
||||
docs: {
|
||||
adminList: {
|
||||
hidden: true,
|
||||
},
|
||||
adminRead: {
|
||||
hidden: true,
|
||||
},
|
||||
adminCreate: {
|
||||
hidden: true,
|
||||
},
|
||||
adminUpdate: {
|
||||
hidden: true,
|
||||
},
|
||||
adminDelete: {
|
||||
hidden: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
export type ApiKeysCrud = CrudTypeOf<typeof apiKeysCrud>;
|
||||
@ -1,56 +0,0 @@
|
||||
import { CrudTypeOf, createCrud } from "../../crud";
|
||||
import { usersCrudServerReadSchema, usersCrudServerUpdateSchema, usersCrudServerDeleteSchema } from "./users";
|
||||
|
||||
const clientUpdateSchema = usersCrudServerUpdateSchema.pick([
|
||||
"display_name",
|
||||
"client_metadata",
|
||||
"selected_team_id",
|
||||
]).required();
|
||||
|
||||
const serverUpdateSchema = usersCrudServerUpdateSchema;
|
||||
|
||||
const clientReadSchema = usersCrudServerReadSchema.pick([
|
||||
"project_id",
|
||||
"id",
|
||||
"primary_email",
|
||||
"primary_email_verified",
|
||||
"display_name",
|
||||
"client_metadata",
|
||||
"profile_image_url",
|
||||
"signed_up_at_millis",
|
||||
"has_password",
|
||||
"auth_with_email",
|
||||
"oauth_providers",
|
||||
"selected_team_id",
|
||||
"selected_team",
|
||||
]).nullable().defined();
|
||||
|
||||
const serverReadSchema = usersCrudServerReadSchema.nullable().defined();
|
||||
|
||||
const serverDeleteSchema = usersCrudServerDeleteSchema;
|
||||
|
||||
export const currentUserCrud = createCrud({
|
||||
clientReadSchema,
|
||||
serverReadSchema,
|
||||
clientUpdateSchema,
|
||||
serverUpdateSchema,
|
||||
serverDeleteSchema,
|
||||
docs: {
|
||||
clientRead: {
|
||||
summary: 'Get current user',
|
||||
description: 'Gets the currently authenticated user.',
|
||||
tags: ['Users'],
|
||||
},
|
||||
clientUpdate: {
|
||||
summary: 'Update current user',
|
||||
description: 'Updates the currently authenticated user. Only the values provided will be updated.',
|
||||
tags: ['Users'],
|
||||
},
|
||||
clientDelete: {
|
||||
summary: 'Delete current user',
|
||||
description: 'Deletes the currently authenticated user. Use this with caution.',
|
||||
tags: ['Users'],
|
||||
},
|
||||
},
|
||||
});
|
||||
export type CurrentUserCrud = CrudTypeOf<typeof currentUserCrud>;
|
||||
@ -1,49 +0,0 @@
|
||||
import { CrudTypeOf, createCrud } from "../../crud";
|
||||
import { jsonSchema, yupMixed, yupObject, yupString } from "../../schema-fields";
|
||||
|
||||
export type EmailTemplateType = typeof emailTemplateTypes[number];
|
||||
export const emailTemplateTypes = ['EMAIL_VERIFICATION', 'PASSWORD_RESET', 'MAGIC_LINK', 'TEAM_INVITATION'] as const;
|
||||
|
||||
export const emailTemplateServerReadSchema = yupObject({
|
||||
type: yupString().oneOf(emailTemplateTypes).required(),
|
||||
subject: yupString().required(),
|
||||
content: jsonSchema.required(),
|
||||
}).required();
|
||||
|
||||
export const emailTemplateCrudServerUpdateSchema = yupObject({
|
||||
content: jsonSchema.required(),
|
||||
subject: yupString().required(),
|
||||
}).required();
|
||||
|
||||
export const emailTemplateCrudServerDeleteSchema = yupMixed();
|
||||
|
||||
export const emailTemplateCrudServerCreateSchema = yupObject({
|
||||
type: yupString().oneOf(emailTemplateTypes).required(),
|
||||
content: jsonSchema.required(),
|
||||
subject: yupString().required(),
|
||||
}).required();
|
||||
|
||||
export const emailTemplateCrud = createCrud({
|
||||
serverReadSchema: emailTemplateServerReadSchema,
|
||||
serverUpdateSchema: emailTemplateCrudServerUpdateSchema,
|
||||
serverCreateSchema: emailTemplateCrudServerCreateSchema,
|
||||
serverDeleteSchema: emailTemplateCrudServerDeleteSchema,
|
||||
docs: {
|
||||
serverRead: {
|
||||
hidden: true,
|
||||
},
|
||||
serverCreate: {
|
||||
hidden: true,
|
||||
},
|
||||
serverUpdate: {
|
||||
hidden: true,
|
||||
},
|
||||
serverDelete: {
|
||||
hidden: true,
|
||||
},
|
||||
serverList: {
|
||||
hidden: true,
|
||||
}
|
||||
}
|
||||
});
|
||||
export type EmailTemplateCrud = CrudTypeOf<typeof emailTemplateCrud>;
|
||||
@ -1,16 +0,0 @@
|
||||
import { CrudTypeOf, createCrud } from "../../crud";
|
||||
import { yupObject, yupString } from "../../schema-fields";
|
||||
|
||||
export const accessTokenReadSchema = yupObject({
|
||||
access_token: yupString().required(),
|
||||
}).required();
|
||||
|
||||
export const accessTokenCreateSchema = yupObject({
|
||||
scope: yupString().optional(),
|
||||
}).required();
|
||||
|
||||
export const accessTokenCrud = createCrud({
|
||||
clientReadSchema: accessTokenReadSchema,
|
||||
clientCreateSchema: accessTokenCreateSchema,
|
||||
});
|
||||
export type AccessTokenCrud = CrudTypeOf<typeof accessTokenCrud>;
|
||||
@ -1,122 +0,0 @@
|
||||
import { CrudTypeOf, createCrud } from "../../crud";
|
||||
import * as schemaFields from "../../schema-fields";
|
||||
import { yupArray, yupObject, yupRequiredWhen, yupString } from "../../schema-fields";
|
||||
|
||||
const teamPermissionSchema = yupObject({
|
||||
id: yupString().required(),
|
||||
}).required();
|
||||
|
||||
const oauthProviderSchema = yupObject({
|
||||
id: schemaFields.oauthIdSchema.required(),
|
||||
enabled: schemaFields.oauthEnabledSchema.required(),
|
||||
type: schemaFields.oauthTypeSchema.required(),
|
||||
client_id: yupRequiredWhen(schemaFields.oauthClientIdSchema, 'type', 'standard'),
|
||||
client_secret: yupRequiredWhen(schemaFields.oauthClientSecretSchema, 'type', 'standard'),
|
||||
});
|
||||
|
||||
const emailConfigSchema = yupObject({
|
||||
type: schemaFields.emailTypeSchema.required(),
|
||||
host: yupRequiredWhen(schemaFields.emailHostSchema, 'type', 'standard'),
|
||||
port: yupRequiredWhen(schemaFields.emailPortSchema, 'type', 'standard'),
|
||||
username: yupRequiredWhen(schemaFields.emailUsernameSchema, 'type', 'standard'),
|
||||
password: yupRequiredWhen(schemaFields.emailPasswordSchema, 'type', 'standard'),
|
||||
sender_name: yupRequiredWhen(schemaFields.emailSenderNameSchema, 'type', 'standard'),
|
||||
sender_email: yupRequiredWhen(schemaFields.emailSenderEmailSchema, 'type', 'standard'),
|
||||
});
|
||||
|
||||
const domainSchema = yupObject({
|
||||
domain: schemaFields.projectTrustedDomainSchema.required(),
|
||||
handler_path: schemaFields.handlerPathSchema.required(),
|
||||
});
|
||||
|
||||
export const projectsCrudAdminReadSchema = yupObject({
|
||||
id: schemaFields.projectIdSchema.required(),
|
||||
display_name: schemaFields.projectDisplayNameSchema.required(),
|
||||
description: schemaFields.projectDescriptionSchema.optional(),
|
||||
created_at_millis: schemaFields.projectCreatedAtMillisSchema.required(),
|
||||
user_count: schemaFields.projectUserCountSchema.required(),
|
||||
is_production_mode: schemaFields.projectIsProductionModeSchema.required(),
|
||||
config: yupObject({
|
||||
id: schemaFields.projectConfigIdSchema.required(),
|
||||
allow_localhost: schemaFields.projectAllowLocalhostSchema.required(),
|
||||
credential_enabled: schemaFields.projectCredentialEnabledSchema.required(),
|
||||
magic_link_enabled: schemaFields.projectMagicLinkEnabledSchema.required(),
|
||||
oauth_providers: yupArray(oauthProviderSchema.required()).required(),
|
||||
domains: yupArray(domainSchema.required()).required(),
|
||||
email_config: emailConfigSchema.required(),
|
||||
team_creator_default_permissions: yupArray(teamPermissionSchema.required()).required(),
|
||||
team_member_default_permissions: yupArray(teamPermissionSchema.required()).required(),
|
||||
}).required(),
|
||||
}).required();
|
||||
|
||||
export const projectsCrudClientReadSchema = yupObject({
|
||||
id: schemaFields.projectIdSchema.required(),
|
||||
display_name: schemaFields.projectDisplayNameSchema.required(),
|
||||
config: yupObject({
|
||||
credential_enabled: schemaFields.projectCredentialEnabledSchema.required(),
|
||||
magic_link_enabled: schemaFields.projectMagicLinkEnabledSchema.required(),
|
||||
oauth_providers: yupArray(yupObject({
|
||||
id: schemaFields.oauthIdSchema.required(),
|
||||
}).required()).required(),
|
||||
}).required(),
|
||||
}).required();
|
||||
|
||||
|
||||
export const projectsCrudAdminUpdateSchema = yupObject({
|
||||
display_name: schemaFields.projectDisplayNameSchema.optional(),
|
||||
description: schemaFields.projectDescriptionSchema.optional(),
|
||||
is_production_mode: schemaFields.projectIsProductionModeSchema.optional(),
|
||||
config: yupObject({
|
||||
credential_enabled: schemaFields.projectCredentialEnabledSchema.optional(),
|
||||
magic_link_enabled: schemaFields.projectMagicLinkEnabledSchema.optional(),
|
||||
allow_localhost: schemaFields.projectAllowLocalhostSchema.optional(),
|
||||
create_team_on_sign_up: schemaFields.projectCreateTeamOnSignUpSchema.optional(),
|
||||
email_config: emailConfigSchema.optional().default(undefined),
|
||||
domains: yupArray(domainSchema.required()).optional().default(undefined),
|
||||
oauth_providers: yupArray(oauthProviderSchema.required()).optional().default(undefined),
|
||||
team_creator_default_permissions: yupArray(teamPermissionSchema.required()).optional(),
|
||||
team_member_default_permissions: yupArray(teamPermissionSchema.required()).optional(),
|
||||
}).optional().default(undefined),
|
||||
}).required();
|
||||
|
||||
export const projectsCrudAdminCreateSchema = projectsCrudAdminUpdateSchema.concat(yupObject({
|
||||
display_name: schemaFields.projectDisplayNameSchema.required(),
|
||||
}).required());
|
||||
|
||||
export const projectsCrud = createCrud({
|
||||
clientReadSchema: projectsCrudClientReadSchema,
|
||||
adminReadSchema: projectsCrudAdminReadSchema,
|
||||
adminUpdateSchema: projectsCrudAdminUpdateSchema,
|
||||
docs: {
|
||||
clientRead: {
|
||||
summary: 'Get the current project',
|
||||
description: 'Get the current project information including display name, oauth providers and authentication methods. Useful for display the available login options to the user.',
|
||||
tags: ['Projects'],
|
||||
},
|
||||
adminRead: {
|
||||
summary: 'Get the current project',
|
||||
description: 'Get the current project information and configuration including display name, oauth providers, email configuration, etc.',
|
||||
tags: ['Projects'],
|
||||
},
|
||||
adminUpdate: {
|
||||
summary: 'Update the current project',
|
||||
description: 'Update the current project information and configuration including display name, oauth providers, email configuration, etc.',
|
||||
tags: ['Projects'],
|
||||
},
|
||||
},
|
||||
});
|
||||
export type ProjectsCrud = CrudTypeOf<typeof projectsCrud>;
|
||||
|
||||
export const internalProjectsCrud = createCrud({
|
||||
clientReadSchema: projectsCrudAdminReadSchema,
|
||||
clientCreateSchema: projectsCrudAdminCreateSchema,
|
||||
docs: {
|
||||
clientList: {
|
||||
hidden: true,
|
||||
},
|
||||
clientCreate: {
|
||||
hidden: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
export type InternalProjectsCrud = CrudTypeOf<typeof internalProjectsCrud>;
|
||||
@ -1,29 +0,0 @@
|
||||
import { CrudTypeOf, createCrud } from "../../crud";
|
||||
import { yupMixed, yupObject } from "../../schema-fields";
|
||||
|
||||
export const teamMembershipsCrudServerReadSchema = yupObject({
|
||||
}).required();
|
||||
|
||||
export const teamMembershipsCrudServerCreateSchema = yupObject({
|
||||
}).required();
|
||||
|
||||
export const teamMembershipsCrudServerDeleteSchema = yupMixed();
|
||||
|
||||
export const teamMembershipsCrud = createCrud({
|
||||
serverReadSchema: teamMembershipsCrudServerReadSchema,
|
||||
serverCreateSchema: teamMembershipsCrudServerCreateSchema,
|
||||
serverDeleteSchema: teamMembershipsCrudServerDeleteSchema,
|
||||
docs: {
|
||||
serverCreate: {
|
||||
summary: "Add a user to a team",
|
||||
description: "",
|
||||
tags: ["Teams"],
|
||||
},
|
||||
serverDelete: {
|
||||
summary: "Remove a user from a team",
|
||||
description: "",
|
||||
tags: ["Teams"],
|
||||
},
|
||||
},
|
||||
});
|
||||
export type TeamMembershipsCrud = CrudTypeOf<typeof teamMembershipsCrud>;
|
||||
@ -1,98 +0,0 @@
|
||||
import { CrudTypeOf, createCrud } from "../../crud";
|
||||
import * as schemaFields from "../../schema-fields";
|
||||
import { yupMixed, yupObject } from "../../schema-fields";
|
||||
|
||||
// Team permissions
|
||||
|
||||
export const teamPermissionsCrudClientReadSchema = yupObject({
|
||||
id: schemaFields.teamPermissionDefinitionIdSchema.required(),
|
||||
user_id: schemaFields.userIdSchema.required(),
|
||||
team_id: schemaFields.teamIdSchema.required(),
|
||||
}).required();
|
||||
|
||||
export const teamPermissionsCrudServerCreateSchema = yupObject({
|
||||
}).required();
|
||||
|
||||
export const teamPermissionsCrudServerDeleteSchema = yupMixed();
|
||||
|
||||
export const teamPermissionsCrud = createCrud({
|
||||
clientReadSchema: teamPermissionsCrudClientReadSchema,
|
||||
serverCreateSchema: teamPermissionsCrudServerCreateSchema,
|
||||
serverDeleteSchema: teamPermissionsCrudServerDeleteSchema,
|
||||
docs: {
|
||||
clientList: {
|
||||
summary: "List team permissions of the current user",
|
||||
description: "user_id=me needs to be set",
|
||||
tags: ["Permissions"],
|
||||
},
|
||||
serverList: {
|
||||
summary: "List team permissions of a user",
|
||||
description: "Query and filter the permission with team_id, user_id, and permission_id",
|
||||
tags: ["Permissions"],
|
||||
},
|
||||
serverCreate: {
|
||||
summary: "Grant a team permission to a user",
|
||||
description: "Grant a team permission to a user (the team permission must be created first on the Stack dashboard)",
|
||||
tags: ["Permissions"],
|
||||
},
|
||||
serverDelete: {
|
||||
summary: "Revoke a team permission from a user",
|
||||
description: "Revoke a team permission from a user",
|
||||
tags: ["Permissions"],
|
||||
},
|
||||
},
|
||||
});
|
||||
export type TeamPermissionsCrud = CrudTypeOf<typeof teamPermissionsCrud>;
|
||||
|
||||
// Team permission definitions
|
||||
|
||||
export const teamPermissionDefinitionsCrudServerReadSchema = yupObject({
|
||||
id: schemaFields.teamPermissionDefinitionIdSchema.required(),
|
||||
description: schemaFields.teamPermissionDescriptionSchema.optional(),
|
||||
contained_permission_ids: schemaFields.containedPermissionIdsSchema.required()
|
||||
}).required();
|
||||
|
||||
export const teamPermissionDefinitionsCrudServerCreateSchema = yupObject({
|
||||
id: schemaFields.customTeamPermissionDefinitionIdSchema.required(),
|
||||
description: schemaFields.teamPermissionDescriptionSchema.optional(),
|
||||
contained_permission_ids: schemaFields.containedPermissionIdsSchema.optional()
|
||||
}).required();
|
||||
|
||||
export const teamPermissionDefinitionsCrudServerUpdateSchema = yupObject({
|
||||
id: schemaFields.customTeamPermissionDefinitionIdSchema.required(),
|
||||
description: schemaFields.teamPermissionDescriptionSchema.optional(),
|
||||
contained_permission_ids: schemaFields.containedPermissionIdsSchema.optional()
|
||||
}).required();
|
||||
|
||||
export const teamPermissionDefinitionsCrudServerDeleteSchema = yupMixed();
|
||||
|
||||
export const teamPermissionDefinitionsCrud = createCrud({
|
||||
serverReadSchema: teamPermissionDefinitionsCrudServerReadSchema,
|
||||
serverCreateSchema: teamPermissionDefinitionsCrudServerCreateSchema,
|
||||
serverUpdateSchema: teamPermissionDefinitionsCrudServerUpdateSchema,
|
||||
serverDeleteSchema: teamPermissionDefinitionsCrudServerDeleteSchema,
|
||||
docs: {
|
||||
serverList: {
|
||||
summary: "List team permission definitions",
|
||||
description: "Query and filter the permission with team_id, user_id, and permission_id (the equivalent of listing permissions on the Stack dashboard)",
|
||||
tags: ["Permissions"],
|
||||
},
|
||||
serverCreate: {
|
||||
summary: "Create a new team permission definition",
|
||||
description: "Create a new permission definition (the equivalent of creating a new permission on the Stack dashboard)",
|
||||
tags: ["Permissions"],
|
||||
},
|
||||
serverUpdate: {
|
||||
summary: "Update a team permission definition",
|
||||
description: "Update a permission definition (the equivalent of updating a permission on the Stack dashboard)",
|
||||
tags: ["Permissions"],
|
||||
},
|
||||
serverDelete: {
|
||||
summary: "Delete a team permission definition",
|
||||
description: "Delete a permission definition (the equivalent of deleting a permission on the Stack dashboard)",
|
||||
tags: ["Permissions"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type TeamPermissionDefinitionsCrud = CrudTypeOf<typeof teamPermissionDefinitionsCrud>;
|
||||
@ -1,85 +0,0 @@
|
||||
import { CrudTypeOf, createCrud } from "../../crud";
|
||||
import * as fieldSchema from "../../schema-fields";
|
||||
import { yupMixed, yupObject } from "../../schema-fields";
|
||||
|
||||
// Read
|
||||
export const teamsCrudClientReadSchema = yupObject({
|
||||
id: fieldSchema.teamIdSchema.required(),
|
||||
display_name: fieldSchema.teamDisplayNameSchema.required(),
|
||||
}).required();
|
||||
export const teamsCrudServerReadSchema = teamsCrudClientReadSchema.concat(yupObject({
|
||||
created_at_millis: fieldSchema.teamCreatedAtMillisSchema.required(),
|
||||
}).required());
|
||||
|
||||
// Update
|
||||
export const teamsCrudClientUpdateSchema = yupObject({
|
||||
display_name: fieldSchema.teamDisplayNameSchema.optional(),
|
||||
}).required();
|
||||
export const teamsCrudServerUpdateSchema = teamsCrudClientUpdateSchema.concat(yupObject({
|
||||
}).required());
|
||||
|
||||
// Create
|
||||
export const teamsCrudClientCreateSchema = teamsCrudClientUpdateSchema.concat(yupObject({
|
||||
display_name: fieldSchema.teamDisplayNameSchema.required(),
|
||||
}).required());
|
||||
export const teamsCrudServerCreateSchema = teamsCrudServerUpdateSchema.concat(yupObject({
|
||||
display_name: fieldSchema.teamDisplayNameSchema.required(),
|
||||
}).required());
|
||||
|
||||
// Delete
|
||||
export const teamsCrudClientDeleteSchema = yupMixed();
|
||||
export const teamsCrudServerDeleteSchema = teamsCrudClientDeleteSchema;
|
||||
|
||||
export const teamsCrud = createCrud({
|
||||
clientReadSchema: teamsCrudClientReadSchema,
|
||||
// clientUpdateSchema: teamsCrudClientUpdateSchema,
|
||||
clientCreateSchema: teamsCrudClientCreateSchema,
|
||||
// clientDeleteSchema: teamsCrudClientDeleteSchema,
|
||||
serverReadSchema: teamsCrudServerReadSchema,
|
||||
serverUpdateSchema: teamsCrudServerUpdateSchema,
|
||||
serverCreateSchema: teamsCrudServerCreateSchema,
|
||||
serverDeleteSchema: teamsCrudServerDeleteSchema,
|
||||
docs: {
|
||||
clientList: {
|
||||
summary: "List teams",
|
||||
description: "List all the teams that the current user is a member of.",
|
||||
tags: ["Teams"],
|
||||
},
|
||||
clientCreate: {
|
||||
summary: "Create a team",
|
||||
description: "Create a new team and add the current user as a member.",
|
||||
tags: ["Teams"],
|
||||
},
|
||||
clientRead: {
|
||||
summary: "Get a team",
|
||||
description: "Get a team that the current user is a member of.",
|
||||
tags: ["Teams"],
|
||||
},
|
||||
serverCreate: {
|
||||
summary: "Create a team",
|
||||
description: "Create a new team and add the current user as a member.",
|
||||
tags: ["Teams"],
|
||||
},
|
||||
serverList: {
|
||||
summary: "List teams",
|
||||
description: "List all the teams in the project.",
|
||||
tags: ["Teams"],
|
||||
},
|
||||
serverRead: {
|
||||
summary: "Get a team",
|
||||
description: "Get a team by ID.",
|
||||
tags: ["Teams"],
|
||||
},
|
||||
serverUpdate: {
|
||||
summary: "Update a team",
|
||||
description: "Update a team by ID.",
|
||||
tags: ["Teams"],
|
||||
},
|
||||
serverDelete: {
|
||||
summary: "Delete a team",
|
||||
description: "Delete a team by ID.",
|
||||
tags: ["Teams"],
|
||||
},
|
||||
},
|
||||
});
|
||||
export type TeamsCrud = CrudTypeOf<typeof teamsCrud>;
|
||||
@ -1,81 +0,0 @@
|
||||
import { CrudTypeOf, createCrud } from "../../crud";
|
||||
import * as fieldSchema from "../../schema-fields";
|
||||
|
||||
export const usersCrudServerUpdateSchema = fieldSchema.yupObject({
|
||||
display_name: fieldSchema.userDisplayNameSchema.optional(),
|
||||
profile_image_url: fieldSchema.profileImageUrlSchema.optional(),
|
||||
client_metadata: fieldSchema.userClientMetadataSchema.optional(),
|
||||
server_metadata: fieldSchema.userServerMetadataSchema.optional(),
|
||||
primary_email: fieldSchema.primaryEmailSchema.nullable().optional(),
|
||||
primary_email_verified: fieldSchema.primaryEmailVerifiedSchema.optional(),
|
||||
primary_email_auth_enabled: fieldSchema.yupBoolean().optional().meta({ openapiField: { description: "Whether the primary email can be used to sign into this user's account", exampleValue: true } }),
|
||||
password: fieldSchema.yupString().nullable().meta({ openapiField: { description: 'A new password for the user, overwriting the old one (if it exists).', exampleValue: 'password' } }),
|
||||
selected_team_id: fieldSchema.selectedTeamIdSchema.nullable().optional(),
|
||||
}).required();
|
||||
|
||||
export const usersCrudServerReadSchema = fieldSchema.yupObject({
|
||||
project_id: fieldSchema.projectIdSchema.required(),
|
||||
id: fieldSchema.userIdSchema.required(),
|
||||
primary_email: fieldSchema.primaryEmailSchema.nullable().defined(),
|
||||
primary_email_verified: fieldSchema.primaryEmailVerifiedSchema.required(),
|
||||
display_name: fieldSchema.userDisplayNameSchema.nullable().defined(),
|
||||
// TODO give this one the type of an actual team
|
||||
selected_team: fieldSchema.yupMixed().nullable().defined(),
|
||||
selected_team_id: fieldSchema.selectedTeamIdSchema.nullable().defined(),
|
||||
profile_image_url: fieldSchema.profileImageUrlSchema.nullable().defined(),
|
||||
signed_up_at_millis: fieldSchema.signedUpAtMillisSchema.required(),
|
||||
has_password: fieldSchema.yupBoolean().required().meta({ openapiField: { description: 'Whether the user has a password associated with their account', exampleValue: true } }),
|
||||
auth_with_email: fieldSchema.yupBoolean().required().meta({ openapiField: { description: 'Whether the user can authenticate with their primary e-mail. If set to true, the user can log-in with credentials and/or magic link, if enabled in the project settings.', exampleValue: true } }),
|
||||
oauth_providers: fieldSchema.yupArray(fieldSchema.yupObject({
|
||||
provider_id: fieldSchema.yupString().required(),
|
||||
account_id: fieldSchema.yupString().required(),
|
||||
email: fieldSchema.yupString().nullable(),
|
||||
}).required()).required().meta({ openapiField: { description: 'A list of OAuth providers connected to this account', exampleValue: ['google', 'github'] } }),
|
||||
client_metadata: fieldSchema.userClientMetadataSchema,
|
||||
server_metadata: fieldSchema.userServerMetadataSchema,
|
||||
}).required();
|
||||
|
||||
export const usersCrudServerCreateSchema = usersCrudServerUpdateSchema.omit(['selected_team_id']).concat(fieldSchema.yupObject({
|
||||
oauth_providers: fieldSchema.yupArray(fieldSchema.yupObject({
|
||||
provider_id: fieldSchema.yupString().required(),
|
||||
account_id: fieldSchema.yupString().required(),
|
||||
email: fieldSchema.yupString().nullable().defined().default(null),
|
||||
}).required()).optional(),
|
||||
}).required());
|
||||
|
||||
export const usersCrudServerDeleteSchema = fieldSchema.yupMixed();
|
||||
|
||||
export const usersCrud = createCrud({
|
||||
serverReadSchema: usersCrudServerReadSchema,
|
||||
serverUpdateSchema: usersCrudServerUpdateSchema,
|
||||
serverCreateSchema: usersCrudServerCreateSchema,
|
||||
serverDeleteSchema: usersCrudServerDeleteSchema,
|
||||
docs: {
|
||||
serverCreate: {
|
||||
tags: ["Users"],
|
||||
summary: 'Create user',
|
||||
description: 'Creates a new user. E-mail authentication is always enabled, and no password is set, meaning the only way to authenticate the newly created user is through magic link.',
|
||||
},
|
||||
serverRead: {
|
||||
tags: ["Users"],
|
||||
summary: 'Get user',
|
||||
description: 'Gets a user by user ID.',
|
||||
},
|
||||
serverUpdate: {
|
||||
tags: ["Users"],
|
||||
summary: 'Update user',
|
||||
description: 'Updates a user. Only the values provided will be updated.',
|
||||
},
|
||||
serverDelete: {
|
||||
tags: ["Users"],
|
||||
summary: 'Delete user',
|
||||
description: 'Deletes a user. Use this with caution.',
|
||||
},
|
||||
serverList: {
|
||||
tags: ["Users"],
|
||||
summary: 'List users',
|
||||
description: 'Lists all the users in the project.',
|
||||
},
|
||||
},
|
||||
});
|
||||
export type UsersCrud = CrudTypeOf<typeof usersCrud>;
|
||||
Loading…
Reference in New Issue
Block a user