2022-09-14 14:29:12 +02:00
|
|
|
import { FromSchema } from 'json-schema-to-ts';
|
|
|
|
import { userSchema } from './user-schema';
|
|
|
|
import { roleSchema } from './role-schema';
|
|
|
|
|
|
|
|
export const publicSignupTokenSchema = {
|
|
|
|
$id: '#/components/schemas/publicSignupTokenSchema',
|
2023-04-21 13:26:54 +02:00
|
|
|
description:
|
|
|
|
'Used for transporting a [public invite link](https://docs.getunleash.io/reference/public-signup#public-sign-up-tokens)',
|
2022-09-14 14:29:12 +02:00
|
|
|
type: 'object',
|
|
|
|
additionalProperties: false,
|
2022-09-26 12:06:30 +02:00
|
|
|
required: [
|
|
|
|
'secret',
|
|
|
|
'url',
|
|
|
|
'name',
|
|
|
|
'expiresAt',
|
|
|
|
'createdAt',
|
|
|
|
'createdBy',
|
2022-09-30 13:01:32 +02:00
|
|
|
'enabled',
|
2022-09-26 12:06:30 +02:00
|
|
|
'role',
|
|
|
|
],
|
2022-09-14 14:29:12 +02:00
|
|
|
properties: {
|
|
|
|
secret: {
|
2023-04-21 13:26:54 +02:00
|
|
|
description:
|
|
|
|
'The actual value of the token. This is the part that is used by Unleash to create an invite link',
|
2022-09-14 14:29:12 +02:00
|
|
|
type: 'string',
|
2023-04-21 13:26:54 +02:00
|
|
|
example: 'a3c84b25409ea8ca1782ef17f94a42fc',
|
2022-09-14 14:29:12 +02:00
|
|
|
},
|
2022-09-26 12:06:30 +02:00
|
|
|
url: {
|
2022-10-10 14:32:34 +02:00
|
|
|
description:
|
|
|
|
'The public signup link for the token. Users who follow this link will be taken to a signup page where they can create an Unleash user.',
|
2022-09-26 12:06:30 +02:00
|
|
|
type: 'string',
|
2023-07-31 11:04:13 +02:00
|
|
|
nullable: true,
|
2023-04-21 13:26:54 +02:00
|
|
|
example:
|
|
|
|
'https://sandbox.getunleash.io/enterprise/new-user?invite=a3c84b25409ea8ca1782ef17f94a42fc',
|
2022-09-26 12:06:30 +02:00
|
|
|
},
|
2022-09-14 14:29:12 +02:00
|
|
|
name: {
|
2023-04-21 13:26:54 +02:00
|
|
|
description: "The token's name. Only for displaying in the UI",
|
2022-09-14 14:29:12 +02:00
|
|
|
type: 'string',
|
2023-04-21 13:26:54 +02:00
|
|
|
example: 'Invite public viewers',
|
2022-09-14 14:29:12 +02:00
|
|
|
},
|
2022-09-30 13:01:32 +02:00
|
|
|
enabled: {
|
2023-04-21 13:26:54 +02:00
|
|
|
description:
|
|
|
|
'Whether the token is active. This property will always be `false` for a token that has expired.',
|
2022-09-30 13:01:32 +02:00
|
|
|
type: 'boolean',
|
2023-04-21 13:26:54 +02:00
|
|
|
example: true,
|
2022-09-30 13:01:32 +02:00
|
|
|
},
|
2022-09-14 14:29:12 +02:00
|
|
|
expiresAt: {
|
|
|
|
type: 'string',
|
2023-04-21 13:26:54 +02:00
|
|
|
description: 'The time when the token will expire.',
|
2022-09-14 14:29:12 +02:00
|
|
|
format: 'date-time',
|
2023-04-21 13:26:54 +02:00
|
|
|
example: '2023-04-12T11:13:31.960Z',
|
2022-09-14 14:29:12 +02:00
|
|
|
},
|
|
|
|
createdAt: {
|
|
|
|
type: 'string',
|
|
|
|
format: 'date-time',
|
2023-04-21 13:26:54 +02:00
|
|
|
description: 'When the token was created.',
|
|
|
|
example: '2023-04-12T11:13:31.960Z',
|
2022-09-14 14:29:12 +02:00
|
|
|
},
|
|
|
|
createdBy: {
|
2023-04-21 13:26:54 +02:00
|
|
|
description: "The creator's email or username",
|
|
|
|
example: 'someone@example.com',
|
2022-09-14 14:29:12 +02:00
|
|
|
type: 'string',
|
|
|
|
nullable: true,
|
|
|
|
},
|
|
|
|
users: {
|
|
|
|
type: 'array',
|
2022-10-10 15:12:11 +02:00
|
|
|
description: 'Array of users that have signed up using the token.',
|
2022-09-14 14:29:12 +02:00
|
|
|
items: {
|
|
|
|
$ref: '#/components/schemas/userSchema',
|
|
|
|
},
|
|
|
|
nullable: true,
|
|
|
|
},
|
|
|
|
role: {
|
2022-10-10 14:32:34 +02:00
|
|
|
description:
|
|
|
|
'Users who sign up using this token will be given this role.',
|
2022-09-14 14:29:12 +02:00
|
|
|
$ref: '#/components/schemas/roleSchema',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
schemas: {
|
|
|
|
userSchema,
|
|
|
|
roleSchema,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
export type PublicSignupTokenSchema = FromSchema<
|
|
|
|
typeof publicSignupTokenSchema
|
|
|
|
>;
|