mirror of
https://github.com/docmost/docmost.git
synced 2026-07-25 16:14:44 +10:00
feat: cloud and ee (#805)
* stripe init git submodules for enterprise modules * * Cloud billing UI - WIP * Proxy websockets in dev mode * Separate workspace login and creation for cloud * Other fixes * feat: billing (cloud) * * add domain service * prepare links from workspace hostname * WIP * Add exchange token generation * Validate JWT token type during verification * domain service * add SkipTransform decorator * * updates (server) * add new packages * new sso migration file * WIP * Fix hostname generation * WIP * WIP * Reduce input error font-size * set max password length * jwt package * license page - WIP * * License management UI * Move license key store to db * add reflector * SSO enforcement * * Add default plan * Add usePlan hook * * Fix auth container margin in mobile * Redirect login and home to select page in cloud * update .gitignore * Default to yearly * * Trial messaging * Handle ended trials * Don't set to readonly on collab disconnect (Cloud) * Refine trial (UI) * Fix bug caused by using jotai optics atom in AppHeader component * configurable database maximum pool * Close SSO form on save * wip * sync * Only show sign-in in cloud * exclude base api part from workspaceId check * close db connection beforeApplicationShutdown * Add health/live endpoint * clear cookie on hostname change * reset currentUser atom * Change text * return 401 if workspace does not match * feat: show user workspace list in cloud login page * sync * Add home path * Prefetch to speed up queries * * Add robots.txt * Disallow login and forgot password routes * wildcard user-agent * Fix space query cache * fix * fix * use space uuid for recent pages * prefetch billing plans * enhance license page * sync
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
import { type Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable('billing')
|
||||
.addColumn('id', 'uuid', (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_uuid_v7()`),
|
||||
)
|
||||
.addColumn('stripe_subscription_id', 'varchar', (col) => col.notNull())
|
||||
.addColumn('stripe_customer_id', 'varchar', (col) => col)
|
||||
.addColumn('status', 'varchar', (col) => col.notNull())
|
||||
.addColumn('quantity', 'int8', (col) => col)
|
||||
.addColumn('amount', 'int8', (col) => col)
|
||||
.addColumn('interval', 'varchar', (col) => col)
|
||||
.addColumn('currency', 'varchar', (col) => col)
|
||||
.addColumn('metadata', 'jsonb', (col) => col)
|
||||
|
||||
.addColumn('stripe_price_id', 'varchar', (col) => col)
|
||||
.addColumn('stripe_item_id', 'varchar', (col) => col)
|
||||
.addColumn('stripe_product_id', 'varchar', (col) => col)
|
||||
|
||||
.addColumn('period_start_at', 'timestamptz', (col) => col.notNull())
|
||||
.addColumn('period_end_at', 'timestamptz', (col) => col)
|
||||
|
||||
.addColumn('cancel_at_period_end', 'boolean', (col) => col)
|
||||
.addColumn('cancel_at', 'timestamptz', (col) => col)
|
||||
.addColumn('canceled_at', 'timestamptz', (col) => col)
|
||||
.addColumn('ended_at', 'timestamptz', (col) => col)
|
||||
|
||||
.addColumn('workspace_id', 'uuid', (col) =>
|
||||
col.references('workspaces.id').onDelete('cascade').notNull(),
|
||||
)
|
||||
.addColumn('created_at', 'timestamptz', (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.addColumn('updated_at', 'timestamptz', (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.addColumn('deleted_at', 'timestamptz', (col) => col)
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.alterTable('billing')
|
||||
.addUniqueConstraint('billing_stripe_subscription_id_unique', [
|
||||
'stripe_subscription_id',
|
||||
])
|
||||
.execute();
|
||||
|
||||
// add new workspace columns
|
||||
await db.schema
|
||||
.alterTable('workspaces')
|
||||
.addColumn('stripe_customer_id', 'varchar', (col) => col)
|
||||
.addColumn('status', 'varchar', (col) => col)
|
||||
.addColumn('plan', 'varchar', (col) => col)
|
||||
.addColumn('billing_email', 'varchar', (col) => col)
|
||||
.addColumn('trial_end_at', 'timestamptz', (col) => col)
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.alterTable('workspaces')
|
||||
.addUniqueConstraint('workspaces_stripe_customer_id_unique', [
|
||||
'stripe_customer_id',
|
||||
])
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.dropTable('billing').execute();
|
||||
|
||||
await db.schema
|
||||
.alterTable('workspaces')
|
||||
.dropColumn('stripe_customer_id')
|
||||
.execute();
|
||||
|
||||
await db.schema.alterTable('workspaces').dropColumn('status').execute();
|
||||
|
||||
await db.schema
|
||||
.alterTable('workspaces')
|
||||
.dropColumn('billing_email')
|
||||
.execute();
|
||||
|
||||
await db.schema.alterTable('workspaces').dropColumn('trial_end_at').execute();
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import { type Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createType('auth_provider_type')
|
||||
.asEnum(['saml', 'oidc', 'google'])
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createTable('auth_providers')
|
||||
.addColumn('id', 'uuid', (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_uuid_v7()`),
|
||||
)
|
||||
.addColumn('name', 'varchar', (col) => col.notNull())
|
||||
.addColumn('type', sql`auth_provider_type`, (col) => col.notNull())
|
||||
|
||||
// SAML
|
||||
.addColumn('saml_url', 'varchar', (col) => col)
|
||||
.addColumn('saml_certificate', 'varchar', (col) => col)
|
||||
|
||||
// OIDC
|
||||
.addColumn('oidc_issuer', 'varchar', (col) => col)
|
||||
.addColumn('oidc_client_id', 'varchar', (col) => col)
|
||||
.addColumn('oidc_client_secret', 'varchar', (col) => col)
|
||||
|
||||
.addColumn('allow_signup', 'boolean', (col) =>
|
||||
col.defaultTo(false).notNull(),
|
||||
)
|
||||
.addColumn('is_enabled', 'boolean', (col) => col.defaultTo(false).notNull())
|
||||
.addColumn('creator_id', 'uuid', (col) =>
|
||||
col.references('users.id').onDelete('set null'),
|
||||
)
|
||||
.addColumn('workspace_id', 'uuid', (col) =>
|
||||
col.references('workspaces.id').onDelete('cascade').notNull(),
|
||||
)
|
||||
.addColumn('created_at', 'timestamptz', (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.addColumn('updated_at', 'timestamptz', (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.addColumn('deleted_at', 'timestamptz', (col) => col)
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createTable('auth_accounts')
|
||||
.addColumn('id', 'uuid', (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_uuid_v7()`),
|
||||
)
|
||||
.addColumn('user_id', 'uuid', (col) =>
|
||||
col.references('users.id').onDelete('cascade').notNull(),
|
||||
)
|
||||
.addColumn('provider_user_id', 'varchar', (col) => col.notNull())
|
||||
.addColumn('auth_provider_id', 'uuid', (col) =>
|
||||
col.references('auth_providers.id').onDelete('cascade'),
|
||||
)
|
||||
.addColumn('workspace_id', 'uuid', (col) =>
|
||||
col.references('workspaces.id').onDelete('cascade').notNull(),
|
||||
)
|
||||
.addColumn('created_at', 'timestamptz', (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.addColumn('updated_at', 'timestamptz', (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.addColumn('deleted_at', 'timestamptz', (col) => col)
|
||||
.addUniqueConstraint('auth_accounts_user_id_auth_provider_id_unique', [
|
||||
'user_id',
|
||||
'auth_provider_id',
|
||||
])
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.alterTable('workspaces')
|
||||
.addColumn('enforce_sso', 'boolean', (col) =>
|
||||
col.defaultTo(false).notNull(),
|
||||
)
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.dropTable('auth_accounts').execute();
|
||||
await db.schema.dropTable('auth_providers').execute();
|
||||
await db.schema.alterTable('workspaces').dropColumn('enforce_sso').execute();
|
||||
await db.schema.dropType('auth_provider_type').execute();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { type Kysely } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.alterTable('workspaces')
|
||||
.addColumn('license_key', 'varchar', (col) => col)
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.alterTable('workspaces').dropColumn('license_key').execute();
|
||||
}
|
||||
Reference in New Issue
Block a user