Files
2026-05-27 23:29:53 +01:00

68 lines
2.9 KiB
Plaintext

-- Define constants for site states (bitwise flags)
DEFINE PARAM OVERWRITE $SITE_STATE_ACTIVE VALUE 1; -- 0001
DEFINE PARAM OVERWRITE $SITE_STATE_MAINTENANCE VALUE 2; -- 0010
DEFINE PARAM OVERWRITE $SITE_STATE_SUSPENDED VALUE 4; -- 0100
DEFINE PARAM OVERWRITE $SITE_STATE_ARCHIVED VALUE 8; -- 1000
DEFINE TABLE OVERWRITE site SCHEMAFULL;
DEFINE FIELD OVERWRITE organization_id ON site TYPE record<organization>
ASSERT $value != NONE;
DEFINE FIELD OVERWRITE name ON site TYPE string
ASSERT $value != NONE
AND string::len($value) > 0
AND string::len($value) <= 100;
DEFINE FIELD OVERWRITE slug ON site TYPE option<string>;
DEFINE FIELD OVERWRITE domains ON site TYPE array<string>
ASSERT $value != NONE;
DEFINE FIELD OVERWRITE settings ON site TYPE object;
DEFINE FIELD OVERWRITE settings.maintenance_mode ON site TYPE bool DEFAULT false;
DEFINE FIELD OVERWRITE settings.theme ON site TYPE object;
DEFINE FIELD OVERWRITE settings.theme.primary_color ON site TYPE string DEFAULT '#000033';
DEFINE FIELD OVERWRITE settings.theme.secondary_color ON site TYPE string DEFAULT '#000066';
DEFINE FIELD OVERWRITE settings.theme.font_family ON site TYPE string DEFAULT '';
DEFINE FIELD OVERWRITE settings.features ON site TYPE array<string> DEFAULT [];
-- Push notification settings
DEFINE FIELD OVERWRITE settings.push ON site TYPE option<object>;
DEFINE FIELD OVERWRITE settings.push.apple ON site TYPE option<object>;
DEFINE FIELD OVERWRITE settings.push.apple.key_id ON site TYPE string;
DEFINE FIELD OVERWRITE settings.push.apple.team_id ON site TYPE string;
DEFINE FIELD OVERWRITE settings.push.apple.bundle_id ON site TYPE string;
DEFINE FIELD OVERWRITE settings.push.apple.key_path ON site TYPE string;
DEFINE FIELD OVERWRITE settings.push.apple.environment ON site TYPE string DEFAULT 'sandbox';
DEFINE FIELD OVERWRITE settings.push.firebase ON site TYPE option<object>;
DEFINE FIELD OVERWRITE settings.push.firebase.server_key ON site TYPE string;
DEFINE FIELD OVERWRITE settings.push.firebase.project_id ON site TYPE string;
DEFINE FIELD OVERWRITE state ON site TYPE number
ASSERT $value INSIDE [1, 2, 4, 8]
DEFAULT 1;
DEFINE FIELD OVERWRITE created_at ON site TYPE string
DEFAULT time::format(time::now(), "%+");
DEFINE FIELD OVERWRITE updated_at ON site TYPE string
DEFAULT time::format(time::now(), "%+")
VALUE time::format(time::now(), "%+");
DEFINE INDEX OVERWRITE site_organization ON site FIELDS organization_id;
DEFINE INDEX OVERWRITE site_name_org ON site FIELDS organization_id, name UNIQUE;
DEFINE INDEX OVERWRITE site_domains ON site FIELDS domains UNIQUE;
DEFINE INDEX OVERWRITE site_state ON site FIELDS state;
-- Domain pattern search across the per-row domain array.
DEFINE FUNCTION OVERWRITE fn::domain::search($domains: array<string>, $domainSearch: string) -> bool {
FOR $domain IN $domains {
IF string::matches($domainSearch, $domain) {
return true;
};
};
return false;
};