Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions apps/api/migrations/20261117104308_add_site_status/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE "core_site_status" (
"id" integer PRIMARY KEY DEFAULT 1,
"offline" boolean DEFAULT false NOT NULL,
"message" jsonb DEFAULT '[]' NOT NULL,
"opensAt" timestamp with time zone,
"showCountdown" boolean DEFAULT true NOT NULL,
"changedAt" timestamp with time zone DEFAULT now() NOT NULL,
"changedById" integer,
"updatedAt" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "core_site_status" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
ALTER TABLE "core_site_status" ADD CONSTRAINT "core_site_status_changedById_core_users_id_fkey" FOREIGN KEY ("changedById") REFERENCES "core_users"("id") ON DELETE SET NULL;
225 changes: 225 additions & 0 deletions apps/api/migrations/20261117104308_add_site_status/snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
{
"type": "diff",
"version": "9",
"dialect": "postgres",
"id": "7453f5c0-b352-419a-bc5e-314a1576c86f",
"prevIds": [
"20d31aad-bc7f-4e35-b1f6-059bd8899c2b"
],
"footprints": [
{
"statementType": "create_table",
"statementTarget": [
"table",
"public",
"core_site_status"
],
"writes": [
"s|tbl|public.core_site_status",
"n|tbl|public.core_site_status",
"e|tbl|public.core_site_status",
"n|rel|public.core_site_status",
"n|type|public.core_site_status",
"n|rel|public.core_site_status_pkey"
],
"reads": [
"n|sch|public"
]
},
{
"statementType": "create_fk",
"statementTarget": [
"table",
"public",
"core_site_status"
],
"writes": [
"s|fk|public.core_site_status.core_site_status_changedById_core_users_id_fkey",
"n|fk|public.core_site_status.core_site_status_changedById_core_users_id_fkey",
"e|fk|public.core_site_status.core_site_status_changedById_core_users_id_fkey",
"n|con|public.core_site_status.core_site_status_changedById_core_users_id_fkey"
],
"reads": [
"n|tbl|public.core_site_status",
"n|sch|public",
"n|tbl|public.core_users",
"n|sch|public",
"n|col|public.core_site_status.changedById",
"n|col|public.core_users.id",
"e|uniqueness|public.core_users.id"
]
}
],
"deltas": [
{
"op": "create",
"row": {
"schema": "public",
"name": "core_site_status",
"isRlsEnabled": true,
"entityType": "tables"
}
},
{
"op": "create",
"row": {
"schema": "public",
"table": "core_site_status",
"name": "id",
"type": "integer",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "1",
"generated": null,
"identity": null,
"entityType": "columns"
}
},
{
"op": "create",
"row": {
"schema": "public",
"table": "core_site_status",
"name": "offline",
"type": "boolean",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "false",
"generated": null,
"identity": null,
"entityType": "columns"
}
},
{
"op": "create",
"row": {
"schema": "public",
"table": "core_site_status",
"name": "message",
"type": "jsonb",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "'[]'",
"generated": null,
"identity": null,
"entityType": "columns"
}
},
{
"op": "create",
"row": {
"schema": "public",
"table": "core_site_status",
"name": "opensAt",
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": false,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"entityType": "columns"
}
},
{
"op": "create",
"row": {
"schema": "public",
"table": "core_site_status",
"name": "showCountdown",
"type": "boolean",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "true",
"generated": null,
"identity": null,
"entityType": "columns"
}
},
{
"op": "create",
"row": {
"schema": "public",
"table": "core_site_status",
"name": "changedAt",
"type": "timestamp with time zone",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"entityType": "columns"
}
},
{
"op": "create",
"row": {
"schema": "public",
"table": "core_site_status",
"name": "changedById",
"type": "integer",
"typeSchema": null,
"notNull": false,
"dimensions": 0,
"default": null,
"generated": null,
"identity": null,
"entityType": "columns"
}
},
{
"op": "create",
"row": {
"schema": "public",
"table": "core_site_status",
"name": "updatedAt",
"type": "timestamp",
"typeSchema": null,
"notNull": true,
"dimensions": 0,
"default": "now()",
"generated": null,
"identity": null,
"entityType": "columns"
}
},
{
"op": "create",
"row": {
"schema": "public",
"table": "core_site_status",
"name": "core_site_status_changedById_core_users_id_fkey",
"nameExplicit": false,
"columns": [
"changedById"
],
"schemaTo": "public",
"tableTo": "core_users",
"columnsTo": [
"id"
],
"onUpdate": "NO ACTION",
"onDelete": "SET NULL",
"entityType": "fks"
}
},
{
"op": "create",
"row": {
"schema": "public",
"table": "core_site_status",
"name": "core_site_status_pkey",
"columns": [
"id"
],
"nameExplicit": false,
"entityType": "pks"
}
}
]
}
44 changes: 44 additions & 0 deletions apps/web/content/docs/dev/events/built-in-events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,50 @@ these events for side effects such as a thank-you notification.
**A listener would** send a receipt notification, post to a sales channel, or
clear a cached page that shows the buyer's purchases.

## Site status events

One name, exported from `@vitnode/api/events/site` as
`siteStatusUpdatedEvent`. It fires **after** the save has committed and the
cached status is expired.

| Event | Payload | Fires when |
| --------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------- |
| `site.status.updated` | `{ offline, switched, opensAt, changedById }` | An admin switches the site off or on, or edits its message, in the **Site status** card on **AdminCP → Debug Panel** |

<Accordions>
<Accordion title="site.status.updated">

Emitted by `PUT /admin/site/status`. A save that only edits the offline
message fires it too, with `switched: false`. See
[Site offline mode](/docs/dev/site-offline-mode).

<TypeTable
type={{
offline: {
description: 'Whether the site is offline after this save.',
type: 'boolean',
},
switched: {
description: 'Whether this save flipped `offline`.',
type: 'boolean',
},
opensAt: {
description: 'The planned opening time as an ISO string, or `null` without a countdown.',
type: 'string | null',
},
changedById: {
description: 'Id of the admin who saved it.',
type: 'number | null',
},
}}
/>

**A listener would** post "We're back!" to a chat webhook when
`switched && !offline`.

</Accordion>
</Accordions>

## Page layout events

One name, exported from `@vitnode/api/events/pages` as
Expand Down
1 change: 1 addition & 0 deletions apps/web/content/docs/dev/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"cli",
"deployments",
"updates",
"site-offline-mode",
"debugging",
"swagger",
"contribution",
Expand Down
Binary file added apps/web/content/docs/dev/site-offline-admin.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading