mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Add product for new personal plan
Summary: Adds the new personal plan as a product that will be available in the future. Can be enabled along with other plan-related via an environment variable. Test Plan: Browser tests and existing tests. Reviewers: jarek Reviewed By: jarek Subscribers: dsagal Differential Revision: https://phab.getgrist.com/D3533
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import {Features, FREE_PERSONAL_PLAN, Product as IProduct, TEAM_FREE_PLAN, TEAM_PLAN} from 'app/common/Features';
|
||||
import {Features, Product as IProduct, PERSONAL_FREE_PLAN, PERSONAL_LEGACY_PLAN, TEAM_FREE_PLAN,
|
||||
TEAM_PLAN} from 'app/common/Features';
|
||||
import {nativeValues} from 'app/gen-server/lib/values';
|
||||
import * as assert from 'assert';
|
||||
import {BillingAccount} from 'app/gen-server/entity/BillingAccount';
|
||||
import {BaseEntity, Column, Connection, Entity, OneToMany, PrimaryGeneratedColumn} from 'typeorm';
|
||||
|
||||
/**
|
||||
* A summary of features used in 'starter' plans.
|
||||
* A summary of features available in legacy personal sites.
|
||||
*/
|
||||
export const starterFeatures: Features = {
|
||||
export const personalLegacyFeatures: Features = {
|
||||
workspaces: true,
|
||||
// no vanity domain
|
||||
maxDocsPerOrg: 10,
|
||||
@@ -27,14 +28,27 @@ export const teamFeatures: Features = {
|
||||
|
||||
/**
|
||||
* A summary of features available in free team sites.
|
||||
* At time of writing, this is a placeholder, as free sites are fleshed out.
|
||||
*/
|
||||
export const teamFreeFeatures: Features = {
|
||||
workspaces: true,
|
||||
vanityDomain: true,
|
||||
maxSharesPerWorkspace: 0, // all workspace shares need to be org members.
|
||||
maxSharesPerDoc: 2,
|
||||
maxDocsPerOrg: 20,
|
||||
snapshotWindow: { count: 30, unit: 'days' },
|
||||
baseMaxRowsPerDocument: 5000,
|
||||
baseMaxApiUnitsPerDocumentPerDay: 5000,
|
||||
baseMaxDataSizePerDocument: 5000 * 2 * 1024, // 2KB per row
|
||||
baseMaxAttachmentsBytesPerDocument: 1 * 1024 * 1024 * 1024, // 1GB
|
||||
gracePeriodDays: 14,
|
||||
};
|
||||
|
||||
/**
|
||||
* A summary of features available in free personal sites.
|
||||
*/
|
||||
export const personalFreeFeatures: Features = {
|
||||
workspaces: true,
|
||||
maxSharesPerWorkspace: 0, // workspace sharing is disabled.
|
||||
maxSharesPerDoc: 2,
|
||||
snapshotWindow: { count: 30, unit: 'days' },
|
||||
baseMaxRowsPerDocument: 5000,
|
||||
baseMaxApiUnitsPerDocumentPerDay: 5000,
|
||||
@@ -96,12 +110,10 @@ export const PRODUCTS: IProduct[] = [
|
||||
name: 'stub',
|
||||
features: {},
|
||||
},
|
||||
|
||||
// These are products set up in stripe.
|
||||
// TODO: this is not true anymore
|
||||
// This is a product for legacy personal accounts/orgs.
|
||||
{
|
||||
name: FREE_PERSONAL_PLAN,
|
||||
features: starterFeatures,
|
||||
name: PERSONAL_LEGACY_PLAN,
|
||||
features: personalLegacyFeatures,
|
||||
},
|
||||
{
|
||||
name: 'professional', // deprecated, can be removed once no longer referred to in stripe.
|
||||
@@ -122,6 +134,10 @@ export const PRODUCTS: IProduct[] = [
|
||||
name: TEAM_FREE_PLAN,
|
||||
features: teamFreeFeatures
|
||||
},
|
||||
{
|
||||
name: PERSONAL_FREE_PLAN,
|
||||
features: personalFreeFeatures,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -130,11 +146,18 @@ export const PRODUCTS: IProduct[] = [
|
||||
*/
|
||||
export function getDefaultProductNames() {
|
||||
const defaultProduct = process.env.GRIST_DEFAULT_PRODUCT;
|
||||
// TODO: can be removed once new deal is released.
|
||||
const personalFreePlan = process.env.NEW_DEAL === 'true'
|
||||
? PERSONAL_FREE_PLAN : PERSONAL_LEGACY_PLAN;
|
||||
return {
|
||||
personal: defaultProduct || FREE_PERSONAL_PLAN, // Personal site start off on a functional plan.
|
||||
teamInitial: defaultProduct || 'stub', // Team site starts off on a limited plan, requiring subscription.
|
||||
teamCancel: 'suspended', // Team site that has been 'turned off'.
|
||||
team: defaultProduct || TEAM_PLAN, // Functional team site.
|
||||
// Personal site start off on a functional plan.
|
||||
personal: defaultProduct || personalFreePlan,
|
||||
// Team site starts off on a limited plan, requiring subscription.
|
||||
teamInitial: defaultProduct || 'stub',
|
||||
// Team site that has been 'turned off'.
|
||||
teamCancel: 'suspended',
|
||||
// Functional team site.
|
||||
team: defaultProduct || TEAM_PLAN,
|
||||
teamFree: defaultProduct || TEAM_FREE_PLAN,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ import {Group} from "app/gen-server/entity/Group";
|
||||
import {Login} from "app/gen-server/entity/Login";
|
||||
import {AccessOption, AccessOptionWithRole, Organization} from "app/gen-server/entity/Organization";
|
||||
import {Pref} from "app/gen-server/entity/Pref";
|
||||
import {getDefaultProductNames, Product, starterFeatures} from "app/gen-server/entity/Product";
|
||||
import {getDefaultProductNames, personalFreeFeatures, personalLegacyFeatures,
|
||||
Product} from "app/gen-server/entity/Product";
|
||||
import {Secret} from "app/gen-server/entity/Secret";
|
||||
import {User} from "app/gen-server/entity/User";
|
||||
import {Workspace} from "app/gen-server/entity/Workspace";
|
||||
@@ -811,7 +812,7 @@ export class HomeDBManager extends EventEmitter {
|
||||
id: 0,
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
domain: this.mergedOrgDomain(),
|
||||
domain: this.mergedOrgDomain(),
|
||||
name: 'Anonymous',
|
||||
owner: this.makeFullUser(this.getAnonymousUser()),
|
||||
access: 'viewers',
|
||||
@@ -820,7 +821,8 @@ export class HomeDBManager extends EventEmitter {
|
||||
individual: true,
|
||||
product: {
|
||||
name: 'anonymous',
|
||||
features: starterFeatures,
|
||||
features: process.env.NEW_DEAL === 'true'
|
||||
? personalFreeFeatures : personalLegacyFeatures,
|
||||
},
|
||||
isManager: false,
|
||||
inGoodStanding: true,
|
||||
|
||||
Reference in New Issue
Block a user