/** * User fields that should be omitted from general-purpose payloads and public * responses. */ export const UsersOmitedFields = [ "password", "social_id", "verification_status", "date_created", "date_created_code", "date_created_timestamp", "date_updated", "date_updated_code", "date_updated_timestamp", ]; /** * Supported MariaDB collations that can be applied at the database or table * level. */ export const MariaDBCollations = [ "utf8mb4_bin", "utf8mb4_unicode_520_ci", ]; export const MariaDBCharsets = ["utf8mb4"]; /** * Supported editor/content modes for text fields. */ export const TextFieldTypesArray = [ { title: "Plain Text", value: "plain" }, { title: "Markdown", value: "markdown" }, { title: "JSON", value: "json" }, { title: "YAML", value: "yaml" }, { title: "HTML", value: "html" }, { title: "CSS", value: "css" }, { title: "Javascript", value: "javascript" }, { title: "Shell", value: "shell" }, { title: "Code", value: "code" }, ]; /** * Native MariaDB column types supported by the schema builder. */ export const BUN_MARIADB_DATATYPES = [ // Strings & Text { value: "CHAR" }, { value: "VARCHAR" }, { value: "TEXT" }, { value: "TINYTEXT" }, { value: "MEDIUMTEXT" }, { value: "LONGTEXT" }, // Numeric Integers { value: "TINYINT" }, { value: "SMALLINT" }, { value: "MEDIUMINT" }, { value: "INT" }, { value: "BIGINT" }, // Numeric Floats & Exact { value: "FLOAT" }, { value: "DOUBLE" }, { value: "DECIMAL" }, // Binary Layouts { value: "BINARY" }, { value: "VARBINARY" }, { value: "BLOB" }, { value: "TINYBLOB" }, { value: "MEDIUMBLOB" }, { value: "LONGBLOB" }, // Temporal (Dates / Times) { value: "DATE" }, { value: "TIME" }, { value: "DATETIME" }, { value: "TIMESTAMP" }, { value: "YEAR" }, // Core Schema Primitives { value: "BOOLEAN" }, { value: "UUID" }, { value: "JSON" }, { value: "INET6" }, { value: "ENUM" }, { value: "SET" }, { value: "VECTOR" }, ]; /** * Defines a foreign key relationship from one field to another table column. */ export const BUN_MARIADB_ForeignKeyRules = [ "CASCADE", "SET NULL", "RESTRICT", "NO ACTION", ]; export const MariaDBIndexTypes = [ "BTREE", "HASH", "FULLTEXT", "SPATIAL", "VECTOR", ]; /** * Supported logical operators for server-side query generation. */ export const ServerQueryOperators = ["AND", "OR"]; /** * Supported comparison operators for server-side query generation. */ export const ServerQueryEqualities = [ "EQUAL", "LIKE", "LIKE_RAW", "LIKE_LOWER", "LIKE_LOWER_RAW", "NOT LIKE", "NOT LIKE_RAW", "NOT_LIKE_LOWER", "NOT_LIKE_LOWER_RAW", "NOT EQUAL", "REGEXP", "FULLTEXT", "IN", "NOT IN", "BETWEEN", "NOT BETWEEN", "IS NULL", "IS NOT NULL", "IS NOT", "EXISTS", "NOT EXISTS", "GREATER THAN", "GREATER THAN OR EQUAL", "LESS THAN", "LESS THAN OR EQUAL", "MATCH", "MATCH_BOOLEAN", ]; export const SQlComparisons = [ ">", "<>", "<", "=", ">=", "<=", "!=", "IS NOT", "IS", "IS NULL", "IS NOT NULL", "IN", "NOT IN", "LIKE", "NOT LIKE", "GLOB", "NOT GLOB", ]; /** * Uppercase HTTP methods supported by the CRUD helpers. */ export const DataCrudRequestMethods = [ "GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", ]; /** * Lowercase variant of the supported HTTP methods, used where string casing * must match external APIs. */ export const DataCrudRequestMethodsLowerCase = [ "get", "post", "put", "patch", "delete", "options", ]; /** * High-level CRUD actions supported by the DSQL helpers. */ export const DsqlCrudActions = ["insert", "update", "delete", "get"]; /** * Reserved query parameter names used throughout the API layer. */ export const QueryFields = [ "duplicate", "user_id", "delegated_user_id", "db_id", "table_id", "db_slug", ]; /** * Supported Docker Compose service names used by the deployment helpers. */ export const DockerComposeServices = [ "setup", "cron", "reverse-proxy", "webapp", "websocket", "static", "db", "maxscale", "post-db-setup", "web-app-post-db-setup", "post-replica-db-setup", "db-replica-1", "db-replica-2", "db-cron", "web-app-post-db-setup", ]; /** * Supported index strategies for generated schemas. */ export const IndexTypes = ["regular", "full_text", "vector"]; /** * Default fields automatically suggested for new tables. */ export const DefaultFields = [ { fieldName: "id", dataType: "BIGINT", primaryKey: true, autoIncrement: true, notNullValue: true, fieldDescription: "The unique identifier of the record.", }, { fieldName: "created_at", dataType: "BIGINT", fieldDescription: "The time when the record was created. (Unix Timestamp)", }, { fieldName: "updated_at", dataType: "BIGINT", fieldDescription: "The time when the record was updated. (Unix Timestamp)", }, ]; /** * Lifecycle of a queue row. Only `pending` jobs are claimed. * - `done`: acknowledged, kept because of `keep_completed` (otherwise deleted) * - `failed`: used up its attempts (dead letter) * - `cancelled`: removed from the queue with `queue.cancel` */ export const QueueStatuses = [ "pending", "processing", "done", "failed", "cancelled", ]; /** * Fields added to every table with `queue_table: true`. */ export const QueueFields = [ { fieldName: "queue_status", dataType: "ENUM", options: [...QueueStatuses], notNullValue: true, defaultValue: "pending", fieldDescription: "Queue state of the job.", }, { fieldName: "queue_available_at", dataType: "BIGINT", notNullValue: true, defaultValue: 0, fieldDescription: "The job cannot be claimed before this time. (Unix Timestamp, ms)", }, { fieldName: "queue_attempts", dataType: "INT", notNullValue: true, defaultValue: 0, fieldDescription: "How many times the job has been claimed.", }, { fieldName: "queue_lease_expires_at", dataType: "BIGINT", fieldDescription: "When the current claim expires and the job can be reclaimed. (Unix Timestamp, ms)", }, { fieldName: "queue_lock_token", dataType: "VARCHAR", dataLength: 64, fieldDescription: "Token of the current claim. Required to ack, fail or extend the job.", }, { fieldName: "queue_last_error", dataType: "TEXT", fieldDescription: "Error message from the last failed attempt.", }, ]; /** * Queue fields only the queue API may write. `queue_available_at` can be set * on insert and update. */ export const QueueProtectedFields = [ "queue_status", "queue_attempts", "queue_lease_expires_at", "queue_lock_token", "queue_last_error", ]; /** * Indexes added to queue tables. Claims scan `idx_queue_claim` in order, so * `LIMIT` stops the scan early and only the claimed rows get locked. */ export const QueueIndexes = [ { indexName: "idx_queue_claim", indexTableFields: ["queue_status", "queue_available_at"], }, { indexName: "idx_queue_lease", indexTableFields: ["queue_status", "queue_lease_expires_at"], }, ]; export const RequiredENVs = [ "BUN_MARIADB_SERVER_HOST", "BUN_MARIADB_SERVER_PORT", "BUN_MARIADB_SERVER_USERNAME", "BUN_MARIADB_SERVER_PASSWORD", "BUN_MARIADB_SERVER_SSL_KEY_PATH", ];