Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
-- @suaveplan/api-plugin-export — SurrealDB schema
--
-- Single-table persistence for the `ExportJob` lifecycle. The
-- `SurrealExportStore` writes rows via `UPDATE type::thing('export_job',
-- $id) CONTENT $body RETURN AFTER`. The schema mirrors `ExportJobSchema`
-- field-by-field; field names match the TypeScript shape (camelCase
-- preserved) so `SELECT *` round-trips cleanly into `ExportJob` without
-- a mapping layer.
DEFINE TABLE OVERWRITE export_job SCHEMAFULL;
DEFINE FIELD OVERWRITE format ON export_job TYPE string
ASSERT $value INSIDE ['csv', 'json', 'xlsx'];
DEFINE FIELD OVERWRITE resource ON export_job TYPE string
ASSERT $value != NONE AND string::len(string::trim($value)) > 0;
DEFINE FIELD OVERWRITE status ON export_job TYPE string
ASSERT $value INSIDE ['pending', 'processing', 'completed', 'failed'];
DEFINE FIELD OVERWRITE filters ON export_job TYPE option<object>;
DEFINE FIELD OVERWRITE filename ON export_job TYPE option<string>;
DEFINE FIELD OVERWRITE totalRows ON export_job TYPE option<int>;
DEFINE FIELD OVERWRITE exportedRows ON export_job TYPE option<int>;
DEFINE FIELD OVERWRITE fileSize ON export_job TYPE option<int>;
DEFINE FIELD OVERWRITE error ON export_job TYPE option<string>;
DEFINE FIELD OVERWRITE createdAt ON export_job TYPE string
ASSERT $value != NONE;
DEFINE FIELD OVERWRITE completedAt ON export_job TYPE option<string>;
-- Indexes — every column used as a `WHERE` filter in
-- `SurrealExportStore.list(...)`. `created_at` is the ORDER-BY column
-- so the index makes the default `ORDER BY created_at DESC` path
-- index-only.
DEFINE INDEX OVERWRITE export_job_status_idx ON export_job FIELDS status;
DEFINE INDEX OVERWRITE export_job_format_idx ON export_job FIELDS format;
DEFINE INDEX OVERWRITE export_job_resource_idx ON export_job FIELDS resource;
DEFINE INDEX OVERWRITE export_job_created_idx ON export_job FIELDS createdAt;