2022-03-15 10:45:20 +00:00
|
|
|
export interface SnapshotWindow {
|
|
|
|
count: number;
|
2022-03-30 11:45:37 +00:00
|
|
|
unit: 'days' | 'month' | 'year';
|
2022-03-15 10:45:20 +00:00
|
|
|
}
|
|
|
|
|
2022-05-26 06:47:26 +00:00
|
|
|
// Information about the product associated with an org or orgs.
|
|
|
|
export interface Product {
|
|
|
|
name: string;
|
|
|
|
features: Features;
|
|
|
|
}
|
|
|
|
|
2022-06-08 17:54:00 +00:00
|
|
|
|
2020-07-21 13:20:51 +00:00
|
|
|
// A product is essentially a list of flags and limits that we may enforce/support.
|
|
|
|
export interface Features {
|
|
|
|
vanityDomain?: boolean; // are user-selected domains allowed (unenforced) (default: true)
|
|
|
|
|
|
|
|
workspaces?: boolean; // are workspaces shown in web interface (default: true)
|
|
|
|
// (this was intended as something we can turn off to shut down
|
|
|
|
// web access to content while leaving access to billing)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Some optional limits. Since orgs can change plans, limits will typically be checked
|
|
|
|
* at the point of creation. E.g. adding someone new to a document, or creating a
|
|
|
|
* new document. If, after an operation, the limit would be exceeded, that operation
|
|
|
|
* is denied. That means it is possible to exceed limits if the limits were not in
|
|
|
|
* place when shares/docs were originally being added. The action that would need
|
|
|
|
* to be taken when infringement is pre-existing is not so obvious.
|
|
|
|
*/
|
|
|
|
|
|
|
|
maxSharesPerDoc?: number; // Maximum number of users that can be granted access to a
|
|
|
|
// particular doc. Doesn't count users granted access at
|
|
|
|
// workspace or organization level. Doesn't count billable
|
|
|
|
// users if applicable (default: unlimited)
|
|
|
|
|
|
|
|
maxSharesPerDocPerRole?: {[role: string]: number}; // As maxSharesPerDoc, but
|
|
|
|
// for specific roles. Roles are named as in app/common/roles.
|
|
|
|
// Applied independently to maxSharesPerDoc.
|
|
|
|
// (default: unlimited)
|
|
|
|
maxSharesPerWorkspace?: number; // Maximum number of users that can be granted access to
|
|
|
|
// a particular workspace. Doesn't count users granted access
|
|
|
|
// at organizational level, or billable users (default: unlimited)
|
|
|
|
|
|
|
|
maxDocsPerOrg?: number; // Maximum number of documents allowed per org.
|
|
|
|
// (default: unlimited)
|
|
|
|
maxWorkspacesPerOrg?: number; // Maximum number of workspaces allowed per org.
|
|
|
|
// (default: unlimited)
|
|
|
|
|
|
|
|
readOnlyDocs?: boolean; // if set, docs can only be read, not written.
|
2022-02-02 19:30:50 +00:00
|
|
|
|
2022-03-15 10:45:20 +00:00
|
|
|
snapshotWindow?: SnapshotWindow; // if set, controls how far back snapshots are kept.
|
2022-02-02 19:30:50 +00:00
|
|
|
|
|
|
|
baseMaxRowsPerDocument?: number; // If set, establishes a default maximum on the
|
|
|
|
// number of rows (total) in a single document.
|
|
|
|
// Actual max for a document may be higher.
|
|
|
|
baseMaxApiUnitsPerDocumentPerDay?: number; // Similar for api calls.
|
2022-03-30 11:45:37 +00:00
|
|
|
baseMaxDataSizePerDocument?: number; // Similar maximum for number of bytes of 'normal' data in a document
|
2022-04-14 12:19:36 +00:00
|
|
|
baseMaxAttachmentsBytesPerDocument?: number; // Similar maximum for total number of bytes used
|
|
|
|
// for attached files in a document
|
(core) Grace period and delete-only mode when exceeding row limit
Summary:
Builds upon https://phab.getgrist.com/D3328
- Add HomeDB column `Document.gracePeriodStart`
- When the row count moves above the limit, set it to the current date. When it moves below, set it to null.
- Add DataLimitStatus type indicating if the document is approaching the limit, is in a grace period, or is in delete only mode if the grace period started at least 14 days ago. Compute it in ActiveDoc and send it to client when opening.
- Only allow certain user actions when in delete-only mode.
Follow-up tasks related to this diff:
- When DataLimitStatus in the client is non-empty, show a banner to the appropriate users.
- Only send DataLimitStatus to users with the appropriate access. There's no risk landing this now since real users will only see null until free team sites are released.
- Update DataLimitStatus immediately in the client when it changes, e.g. when user actions are applied or the product is changed. Right now it's only sent when the document loads.
- Update row limit, grace period start, and data limit status in ActiveDoc when the product changes, i.e. the user upgrades/downgrades.
- Account for data size when computing data limit status, not just row counts.
See also the tasks mentioned in https://phab.getgrist.com/D3331
Test Plan: Extended FreeTeam nbrowser test, testing the 4 statuses.
Reviewers: georgegevoian
Reviewed By: georgegevoian
Differential Revision: https://phab.getgrist.com/D3331
2022-03-24 12:05:51 +00:00
|
|
|
|
|
|
|
gracePeriodDays?: number; // Duration of the grace period in days, before entering delete-only mode
|
2023-07-05 15:36:45 +00:00
|
|
|
|
|
|
|
baseMaxAssistantCalls?: number; // Maximum number of AI assistant calls. Defaults to 0 if not set, use -1 to indicate
|
|
|
|
// unbound limit. This is total limit, not per month or per day, it is used as a seed
|
|
|
|
// value for the limits table. To create a per-month limit, there must be a separate
|
|
|
|
// task that resets the usage in the limits table.
|
2020-07-21 13:20:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether it is possible to add members at the org level. There's no flag
|
|
|
|
// for this right now, it isn't enforced at the API level, it is just a bluff.
|
|
|
|
// For now, when maxWorkspacesPerOrg is 1, we should assume members can't be added
|
|
|
|
// to org (even though this is not enforced).
|
|
|
|
export function canAddOrgMembers(features: Features): boolean {
|
|
|
|
return features.maxWorkspacesPerOrg !== 1;
|
|
|
|
}
|
2022-05-26 06:47:26 +00:00
|
|
|
|
2022-07-26 17:49:35 +00:00
|
|
|
|
|
|
|
export const PERSONAL_LEGACY_PLAN = 'starter';
|
|
|
|
export const PERSONAL_FREE_PLAN = 'personalFree';
|
2022-06-29 10:19:20 +00:00
|
|
|
export const TEAM_FREE_PLAN = 'teamFree';
|
|
|
|
export const TEAM_PLAN = 'team';
|
|
|
|
|
2022-07-08 19:09:22 +00:00
|
|
|
export const displayPlanName: { [key: string]: string } = {
|
2022-07-26 17:49:35 +00:00
|
|
|
[PERSONAL_LEGACY_PLAN]: 'Free Personal (Legacy)',
|
|
|
|
[PERSONAL_FREE_PLAN]: 'Free Personal',
|
2022-07-08 19:09:22 +00:00
|
|
|
[TEAM_FREE_PLAN]: 'Team Free',
|
2023-08-08 02:52:17 +00:00
|
|
|
[TEAM_PLAN]: 'Pro'
|
2022-07-08 19:09:22 +00:00
|
|
|
} as const;
|
|
|
|
|
2022-07-26 17:49:35 +00:00
|
|
|
// Returns true if `planName` is for a personal product.
|
|
|
|
export function isPersonalPlan(planName: string): boolean {
|
|
|
|
return isFreePersonalPlan(planName);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if `planName` is for a free personal product.
|
|
|
|
export function isFreePersonalPlan(planName: string): boolean {
|
|
|
|
return [PERSONAL_LEGACY_PLAN, PERSONAL_FREE_PLAN].includes(planName);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if `planName` is for a legacy product.
|
|
|
|
export function isLegacyPlan(planName: string): boolean {
|
|
|
|
return isFreeLegacyPlan(planName);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if `planName` is for a free legacy product.
|
|
|
|
export function isFreeLegacyPlan(planName: string): boolean {
|
|
|
|
return [PERSONAL_LEGACY_PLAN].includes(planName);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if `planName` is for a team product.
|
|
|
|
export function isTeamPlan(planName: string): boolean {
|
|
|
|
return !isPersonalPlan(planName);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if `planName` is for a free team product.
|
|
|
|
export function isFreeTeamPlan(planName: string): boolean {
|
|
|
|
return [TEAM_FREE_PLAN].includes(planName);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if `planName` is for a free product.
|
|
|
|
export function isFreePlan(planName: string): boolean {
|
|
|
|
return (
|
|
|
|
isFreePersonalPlan(planName) ||
|
|
|
|
isFreeTeamPlan(planName) ||
|
|
|
|
isFreeLegacyPlan(planName) ||
|
|
|
|
planName === 'Free'
|
|
|
|
);
|
2022-05-26 06:47:26 +00:00
|
|
|
}
|