CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/lib/api/schema/accounts/sign-up.ts
Views: 688
1
import { SignUpIssues } from "lib/types/sign-up";
2
import { z } from "../../framework";
3
4
import { FailedAPIOperationSchema } from "../common";
5
6
import { AccountIdSchema } from "./common";
7
8
// OpenAPI spec
9
//
10
export const SignUpInputSchema = z
11
.object({
12
email: z
13
.string()
14
.email()
15
.describe(
16
"Email address of new user. TIP: If you want to pass in an email like [email protected], use '%2B' in place of '+'",
17
),
18
password: z.string().describe("Initial password of new user."),
19
firstName: z.string().describe("First name"),
20
lastName: z.string().describe("Last name"),
21
terms: z
22
.boolean()
23
.describe("Must be set to 'true' to indicate acceptance of ToS."),
24
registrationToken: z
25
.string()
26
.optional()
27
.describe("If required, enter a currently valid registration token."),
28
tags: z.array(z.string()).optional().describe("Tag users"),
29
publicPathId: z
30
.string()
31
.optional()
32
.describe("ID of published document, used to get a license ID"),
33
signupReason: z.string().optional(),
34
})
35
.describe(
36
"Create a new account. In production, this is not available for all users and requires additional trust! For on-premises, this functionality is only available for administrators.",
37
);
38
39
const IssuesSchema = z.object({
40
terms: z.string().optional().describe("Problem with ToS"),
41
email: z.string().optional().describe("Problem with the email address"),
42
password: z.string().optional().describe("Problem with the password"),
43
api: z.string().optional().describe("Problem with the API"),
44
});
45
46
export const SignUpOutputSchema = z.union([
47
z.union([
48
z.object({
49
account_id: AccountIdSchema.describe("Account ID"),
50
}),
51
z
52
.object({
53
issues: IssuesSchema,
54
})
55
.describe("Reporting back possible issues creating a new account."),
56
]),
57
FailedAPIOperationSchema,
58
]);
59
60
export type SignUpInput = z.infer<typeof SignUpInputSchema>;
61
export type SignUpOutput = z.infer<typeof SignUpOutputSchema>;
62
63
// consistency check
64
export const _1: Required<SignUpIssues> = {} as Required<
65
z.infer<typeof IssuesSchema>
66
>;
67
68