chore: Add the generated code and migrations that were gitignored (#102)

This commit is contained in:
Marcelo Mendonça Soares 2026-07-09 11:25:28 -03:00 • committed by GitHub
commit 20b23a1a9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 108827 additions and 101 deletions

View file

@ -11,6 +11,3 @@ build/
# Directory created by dartdoc
doc/api/
# Migrations do not need to be committed, as they are only for testing
lib/migrations/

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,992 @@
/// AUTOGENERATED BY SERVERPOD create-migration - DO NOT EDIT BY HAND
/// Merging: resolve registry conflicts the same as migration_registry.txt.
part of '../migration_registry.dart';
class _Migration20260703114646971 implements MigrationVersionSql {
@override
String get version => '20260703114646971';
@override
String get moduleName => 'serverpod_offline_sync';
@override
String get migrationSql => '''BEGIN;
--
-- ACTION CREATE TABLE
--
CREATE TABLE "crdt_data_fields" (
"id" INTEGER PRIMARY KEY,
"hlcDatetime" INTEGER NOT NULL,
"hlcCounter" INTEGER NOT NULL,
"rowId" INTEGER NOT NULL,
"columnId" INTEGER NOT NULL,
"nodeId" INTEGER NOT NULL,
CONSTRAINT "crdt_data_fields_fk_0" FOREIGN KEY ("rowId") REFERENCES "crdt_data_rows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT "crdt_data_fields_fk_1" FOREIGN KEY ("columnId") REFERENCES "crdt_schema_columns" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT "crdt_data_fields_fk_2" FOREIGN KEY ("nodeId") REFERENCES "crdt_nodes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_data_fields_row_column_idx" ON "crdt_data_fields" ("rowId", "columnId");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "crdt_data_foreign_key" (
"id" INTEGER PRIMARY KEY,
"fieldId" INTEGER NOT NULL,
"attemptedValue" BLOB,
"visibleValue" BLOB,
"overrideReason" INTEGER,
CONSTRAINT "crdt_data_foreign_key_fk_0" FOREIGN KEY ("fieldId") REFERENCES "crdt_data_fields" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_data_foreign_key_field_idx" ON "crdt_data_foreign_key" ("fieldId");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "crdt_data_rows" (
"id" INTEGER PRIMARY KEY,
"hlcDatetime" INTEGER NOT NULL,
"hlcCounter" INTEGER NOT NULL,
"scopeId" INTEGER NOT NULL,
"tblId" INTEGER NOT NULL,
"uuidRowId" BLOB NOT NULL,
"nodeId" INTEGER NOT NULL,
"visibility" INTEGER NOT NULL DEFAULT (0),
CONSTRAINT "crdt_data_rows_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT "crdt_data_rows_fk_1" FOREIGN KEY ("tblId") REFERENCES "crdt_schema_tables" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT "crdt_data_rows_fk_2" FOREIGN KEY ("nodeId") REFERENCES "crdt_nodes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_data_rows_scope_tbl_row_idx" ON "crdt_data_rows" ("scopeId", "tblId", "uuidRowId");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "crdt_data_tombstone" (
"id" INTEGER PRIMARY KEY,
"hlcDatetime" INTEGER NOT NULL,
"hlcCounter" INTEGER NOT NULL,
"rowId" INTEGER NOT NULL,
"nodeId" INTEGER NOT NULL,
"clFlag" INTEGER NOT NULL,
"reason" INTEGER NOT NULL,
CONSTRAINT "crdt_data_tombstone_fk_0" FOREIGN KEY ("rowId") REFERENCES "crdt_data_rows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT "crdt_data_tombstone_fk_1" FOREIGN KEY ("nodeId") REFERENCES "crdt_nodes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_data_tombstone_row_idx" ON "crdt_data_tombstone" ("rowId");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "crdt_nodes" (
"id" INTEGER PRIMARY KEY,
"uuidNodeId" BLOB NOT NULL DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
"lastHlc" BLOB
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_nodes__uuidNodeId__unique_idx" ON "crdt_nodes" ("uuidNodeId");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "crdt_schema_columns" (
"id" INTEGER PRIMARY KEY,
"tblId" INTEGER NOT NULL,
"name" TEXT NOT NULL,
CONSTRAINT "crdt_schema_columns_fk_0" FOREIGN KEY ("tblId") REFERENCES "crdt_schema_tables" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_schema_columns_table_column_idx" ON "crdt_schema_columns" ("tblId", "name");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "crdt_schema_tables" (
"id" INTEGER PRIMARY KEY,
"name" TEXT NOT NULL
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_schema_tables__name__unique_idx" ON "crdt_schema_tables" ("name");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "crdt_scope_members" (
"id" INTEGER PRIMARY KEY,
"scopeId" INTEGER NOT NULL,
"userUuid" BLOB NOT NULL,
"role" TEXT NOT NULL,
CONSTRAINT "crdt_scope_members_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_scope_member_unique_idx" ON "crdt_scope_members" ("userUuid", "scopeId");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "crdt_scope_nodes" (
"id" INTEGER PRIMARY KEY,
"scopeId" INTEGER NOT NULL,
"nodeId" INTEGER NOT NULL,
"lastReceivedHlc" BLOB,
CONSTRAINT "crdt_scope_nodes_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT "crdt_scope_nodes_fk_1" FOREIGN KEY ("nodeId") REFERENCES "crdt_nodes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_scope_node_unique_idx" ON "crdt_scope_nodes" ("scopeId", "nodeId");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "crdt_scopes" (
"id" INTEGER PRIMARY KEY,
"uuidScopeId" BLOB NOT NULL DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
"currentNodeId" INTEGER,
CONSTRAINT "crdt_scopes_fk_0" FOREIGN KEY ("currentNodeId") REFERENCES "crdt_nodes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_scopes__uuidScopeId__unique_idx" ON "crdt_scopes" ("uuidScopeId");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "crdt_sync_integrity_violations" (
"id" INTEGER PRIMARY KEY,
"type" TEXT NOT NULL,
"domainTableName" TEXT NOT NULL,
"uuidRowId" BLOB NOT NULL,
"ownerScopeUuid" BLOB,
"incomingScopeUuid" BLOB NOT NULL,
"operation" TEXT NOT NULL,
"uuidNodeId" BLOB,
"crdtDataRowId" INTEGER,
"hlcDatetime" INTEGER,
"hlcCounter" INTEGER,
"firstSeenAt" INTEGER NOT NULL,
"lastSeenAt" INTEGER NOT NULL,
"occurrences" INTEGER NOT NULL
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_sync_integrity_violations_key_idx" ON "crdt_sync_integrity_violations" ("type", "operation", "domainTableName", "uuidRowId", "ownerScopeUuid", "incomingScopeUuid");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "serverpod_cloud_storage" (
"id" INTEGER PRIMARY KEY,
"storageId" TEXT NOT NULL,
"path" TEXT NOT NULL,
"addedTime" INTEGER NOT NULL,
"expiration" INTEGER,
"byteData" BLOB NOT NULL,
"verified" INTEGER NOT NULL
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "serverpod_cloud_storage_path_idx" ON "serverpod_cloud_storage" ("storageId", "path");
CREATE INDEX "serverpod_cloud_storage_expiration" ON "serverpod_cloud_storage" ("expiration");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "serverpod_cloud_storage_direct_upload" (
"id" INTEGER PRIMARY KEY,
"storageId" TEXT NOT NULL,
"path" TEXT NOT NULL,
"expiration" INTEGER NOT NULL,
"authKey" TEXT NOT NULL
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "serverpod_cloud_storage_direct_upload_storage_path" ON "serverpod_cloud_storage_direct_upload" ("storageId", "path");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "serverpod_future_call" (
"id" INTEGER PRIMARY KEY,
"name" TEXT NOT NULL,
"time" INTEGER NOT NULL,
"serializedObject" TEXT,
"serverId" TEXT NOT NULL,
"identifier" TEXT,
"scheduling" TEXT
) STRICT;
-- Indexes
CREATE INDEX "serverpod_future_call_time_idx" ON "serverpod_future_call" ("time");
CREATE INDEX "serverpod_future_call_serverId_idx" ON "serverpod_future_call" ("serverId");
CREATE INDEX "serverpod_future_call_identifier_idx" ON "serverpod_future_call" ("identifier");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "serverpod_future_call_claim" (
"id" INTEGER PRIMARY KEY,
"futureCallId" INTEGER,
"lastHeartbeatTime" INTEGER NOT NULL,
CONSTRAINT "serverpod_future_call_claim_fk_0" FOREIGN KEY ("futureCallId") REFERENCES "serverpod_future_call" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "future_call_unique_idx" ON "serverpod_future_call_claim" ("futureCallId");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "serverpod_health_connection_info" (
"id" INTEGER PRIMARY KEY,
"serverId" TEXT NOT NULL,
"timestamp" INTEGER NOT NULL,
"active" INTEGER NOT NULL,
"closing" INTEGER NOT NULL,
"idle" INTEGER NOT NULL,
"granularity" INTEGER NOT NULL
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "serverpod_health_connection_info_timestamp_idx" ON "serverpod_health_connection_info" ("timestamp", "serverId", "granularity");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "serverpod_health_metric" (
"id" INTEGER PRIMARY KEY,
"name" TEXT NOT NULL,
"serverId" TEXT NOT NULL,
"timestamp" INTEGER NOT NULL,
"isHealthy" INTEGER NOT NULL,
"value" REAL NOT NULL,
"granularity" INTEGER NOT NULL
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "serverpod_health_metric_timestamp_idx" ON "serverpod_health_metric" ("timestamp", "serverId", "name", "granularity");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "serverpod_log" (
"id" INTEGER PRIMARY KEY,
"sessionLogId" INTEGER NOT NULL,
"messageId" INTEGER,
"reference" TEXT,
"serverId" TEXT NOT NULL,
"time" INTEGER NOT NULL,
"logLevel" INTEGER NOT NULL,
"message" TEXT NOT NULL,
"error" TEXT,
"stackTrace" TEXT,
"order" INTEGER NOT NULL,
CONSTRAINT "serverpod_log_fk_0" FOREIGN KEY ("sessionLogId") REFERENCES "serverpod_session_log" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE INDEX "serverpod_log_sessionLogId_idx" ON "serverpod_log" ("sessionLogId", "order");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "serverpod_message_log" (
"id" INTEGER PRIMARY KEY,
"sessionLogId" INTEGER NOT NULL,
"serverId" TEXT NOT NULL,
"messageId" INTEGER NOT NULL,
"endpoint" TEXT NOT NULL,
"messageName" TEXT NOT NULL,
"duration" REAL NOT NULL,
"error" TEXT,
"stackTrace" TEXT,
"slow" INTEGER NOT NULL,
"order" INTEGER NOT NULL,
CONSTRAINT "serverpod_message_log_fk_0" FOREIGN KEY ("sessionLogId") REFERENCES "serverpod_session_log" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE INDEX "serverpod_message_log_sessionLogId_idx" ON "serverpod_message_log" ("sessionLogId", "order");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "serverpod_method" (
"id" INTEGER PRIMARY KEY,
"endpoint" TEXT NOT NULL,
"method" TEXT NOT NULL
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "serverpod_method_endpoint_method_idx" ON "serverpod_method" ("endpoint", "method");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "serverpod_migrations" (
"id" INTEGER PRIMARY KEY,
"module" TEXT NOT NULL,
"version" TEXT NOT NULL,
"timestamp" INTEGER
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "serverpod_migrations_ids" ON "serverpod_migrations" ("module");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "serverpod_query_log" (
"id" INTEGER PRIMARY KEY,
"serverId" TEXT NOT NULL,
"sessionLogId" INTEGER NOT NULL,
"messageId" INTEGER,
"query" TEXT NOT NULL,
"duration" REAL NOT NULL,
"numRows" INTEGER,
"error" TEXT,
"stackTrace" TEXT,
"slow" INTEGER NOT NULL,
"order" INTEGER NOT NULL,
CONSTRAINT "serverpod_query_log_fk_0" FOREIGN KEY ("sessionLogId") REFERENCES "serverpod_session_log" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE INDEX "serverpod_query_log_sessionLogId_idx" ON "serverpod_query_log" ("sessionLogId", "order");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "serverpod_readwrite_test" (
"id" INTEGER PRIMARY KEY,
"number" INTEGER NOT NULL
) STRICT;
--
-- ACTION CREATE TABLE
--
CREATE TABLE "serverpod_runtime_settings" (
"id" INTEGER PRIMARY KEY,
"logSettings" TEXT NOT NULL,
"logSettingsOverrides" TEXT NOT NULL,
"logServiceCalls" INTEGER NOT NULL,
"logMalformedCalls" INTEGER NOT NULL
) STRICT;
--
-- ACTION CREATE TABLE
--
CREATE TABLE "serverpod_session_log" (
"id" INTEGER PRIMARY KEY,
"serverId" TEXT NOT NULL,
"time" INTEGER NOT NULL,
"module" TEXT,
"endpoint" TEXT,
"method" TEXT,
"duration" REAL,
"numQueries" INTEGER,
"slow" INTEGER,
"error" TEXT,
"stackTrace" TEXT,
"authenticatedUserId" INTEGER,
"userId" TEXT,
"isOpen" INTEGER,
"touched" INTEGER NOT NULL
) STRICT;
-- Indexes
CREATE INDEX "serverpod_session_log_serverid_idx" ON "serverpod_session_log" ("serverId");
CREATE INDEX "serverpod_session_log_time_idx" ON "serverpod_session_log" ("time");
CREATE INDEX "serverpod_session_log_touched_idx" ON "serverpod_session_log" ("touched");
CREATE INDEX "serverpod_session_log_isopen_idx" ON "serverpod_session_log" ("isOpen");
--
-- STORE COLUMN TYPES FOR MIGRATIONS
--
DROP TABLE IF EXISTS "serverpod_sqlite_schema";
CREATE TABLE "serverpod_sqlite_schema" (
"table_name" TEXT NOT NULL,
"column_name" TEXT NOT NULL,
"column_type" TEXT NOT NULL,
"column_vector_dimension" INTEGER,
PRIMARY KEY ("table_name", "column_name")
);
INSERT INTO "serverpod_sqlite_schema" VALUES
('crdt_data_fields', 'hlcDatetime', 'timestampWithoutTimeZone', NULL),
('crdt_data_foreign_key', 'attemptedValue', 'uuid', NULL),
('crdt_data_foreign_key', 'visibleValue', 'uuid', NULL),
('crdt_data_rows', 'hlcDatetime', 'timestampWithoutTimeZone', NULL),
('crdt_data_rows', 'uuidRowId', 'uuid', NULL),
('crdt_data_tombstone', 'hlcDatetime', 'timestampWithoutTimeZone', NULL),
('crdt_nodes', 'uuidNodeId', 'uuid', NULL),
('crdt_nodes', 'lastHlc', 'jsonb', NULL),
('crdt_scope_members', 'userUuid', 'uuid', NULL),
('crdt_scope_nodes', 'lastReceivedHlc', 'jsonb', NULL),
('crdt_scopes', 'uuidScopeId', 'uuid', NULL),
('crdt_sync_integrity_violations', 'uuidRowId', 'uuid', NULL),
('crdt_sync_integrity_violations', 'ownerScopeUuid', 'uuid', NULL),
('crdt_sync_integrity_violations', 'incomingScopeUuid', 'uuid', NULL),
('crdt_sync_integrity_violations', 'uuidNodeId', 'uuid', NULL),
('crdt_sync_integrity_violations', 'hlcDatetime', 'timestampWithoutTimeZone', NULL),
('crdt_sync_integrity_violations', 'firstSeenAt', 'timestampWithoutTimeZone', NULL),
('crdt_sync_integrity_violations', 'lastSeenAt', 'timestampWithoutTimeZone', NULL),
('serverpod_cloud_storage', 'addedTime', 'timestampWithoutTimeZone', NULL),
('serverpod_cloud_storage', 'expiration', 'timestampWithoutTimeZone', NULL),
('serverpod_cloud_storage', 'verified', 'boolean', NULL),
('serverpod_cloud_storage_direct_upload', 'expiration', 'timestampWithoutTimeZone', NULL),
('serverpod_future_call', 'time', 'timestampWithoutTimeZone', NULL),
('serverpod_future_call', 'scheduling', 'json', NULL),
('serverpod_future_call_claim', 'lastHeartbeatTime', 'timestampWithoutTimeZone', NULL),
('serverpod_health_connection_info', 'timestamp', 'timestampWithoutTimeZone', NULL),
('serverpod_health_metric', 'timestamp', 'timestampWithoutTimeZone', NULL),
('serverpod_health_metric', 'isHealthy', 'boolean', NULL),
('serverpod_log', 'time', 'timestampWithoutTimeZone', NULL),
('serverpod_message_log', 'slow', 'boolean', NULL),
('serverpod_migrations', 'timestamp', 'timestampWithoutTimeZone', NULL),
('serverpod_query_log', 'slow', 'boolean', NULL),
('serverpod_runtime_settings', 'logSettings', 'json', NULL),
('serverpod_runtime_settings', 'logSettingsOverrides', 'json', NULL),
('serverpod_runtime_settings', 'logServiceCalls', 'boolean', NULL),
('serverpod_runtime_settings', 'logMalformedCalls', 'boolean', NULL),
('serverpod_session_log', 'time', 'timestampWithoutTimeZone', NULL),
('serverpod_session_log', 'slow', 'boolean', NULL),
('serverpod_session_log', 'isOpen', 'boolean', NULL),
('serverpod_session_log', 'touched', 'timestampWithoutTimeZone', NULL);
--
-- MIGRATION VERSION FOR serverpod_offline_sync
--
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
VALUES ('serverpod_offline_sync', '20260703114646971', (unixepoch('now', 'subsecond') * 1000))
ON CONFLICT ("module")
DO UPDATE SET "version" = '20260703114646971', "timestamp" = (unixepoch('now', 'subsecond') * 1000);
--
-- MIGRATION VERSION FOR serverpod
--
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
VALUES ('serverpod', '20260416151914983-insights-perf', (unixepoch('now', 'subsecond') * 1000))
ON CONFLICT ("module")
DO UPDATE SET "version" = '20260416151914983-insights-perf', "timestamp" = (unixepoch('now', 'subsecond') * 1000);
COMMIT;
''';
@override
String get definitionSql => '''BEGIN;
--
-- Class CrdtDataField as table crdt_data_fields
--
CREATE TABLE "crdt_data_fields" (
"id" INTEGER PRIMARY KEY,
"hlcDatetime" INTEGER NOT NULL,
"hlcCounter" INTEGER NOT NULL,
"rowId" INTEGER NOT NULL,
"columnId" INTEGER NOT NULL,
"nodeId" INTEGER NOT NULL,
CONSTRAINT "crdt_data_fields_fk_0" FOREIGN KEY ("rowId") REFERENCES "crdt_data_rows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT "crdt_data_fields_fk_1" FOREIGN KEY ("columnId") REFERENCES "crdt_schema_columns" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT "crdt_data_fields_fk_2" FOREIGN KEY ("nodeId") REFERENCES "crdt_nodes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_data_fields_row_column_idx" ON "crdt_data_fields" ("rowId", "columnId");
--
-- Class CrdtDataForeignKey as table crdt_data_foreign_key
--
CREATE TABLE "crdt_data_foreign_key" (
"id" INTEGER PRIMARY KEY,
"fieldId" INTEGER NOT NULL,
"attemptedValue" BLOB,
"visibleValue" BLOB,
"overrideReason" INTEGER,
CONSTRAINT "crdt_data_foreign_key_fk_0" FOREIGN KEY ("fieldId") REFERENCES "crdt_data_fields" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_data_foreign_key_field_idx" ON "crdt_data_foreign_key" ("fieldId");
--
-- Class CrdtDataRow as table crdt_data_rows
--
CREATE TABLE "crdt_data_rows" (
"id" INTEGER PRIMARY KEY,
"hlcDatetime" INTEGER NOT NULL,
"hlcCounter" INTEGER NOT NULL,
"scopeId" INTEGER NOT NULL,
"tblId" INTEGER NOT NULL,
"uuidRowId" BLOB NOT NULL,
"nodeId" INTEGER NOT NULL,
"visibility" INTEGER NOT NULL DEFAULT (0),
CONSTRAINT "crdt_data_rows_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT "crdt_data_rows_fk_1" FOREIGN KEY ("tblId") REFERENCES "crdt_schema_tables" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT "crdt_data_rows_fk_2" FOREIGN KEY ("nodeId") REFERENCES "crdt_nodes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_data_rows_scope_tbl_row_idx" ON "crdt_data_rows" ("scopeId", "tblId", "uuidRowId");
--
-- Class CrdtDataDeleted as table crdt_data_tombstone
--
CREATE TABLE "crdt_data_tombstone" (
"id" INTEGER PRIMARY KEY,
"hlcDatetime" INTEGER NOT NULL,
"hlcCounter" INTEGER NOT NULL,
"rowId" INTEGER NOT NULL,
"nodeId" INTEGER NOT NULL,
"clFlag" INTEGER NOT NULL,
"reason" INTEGER NOT NULL,
CONSTRAINT "crdt_data_tombstone_fk_0" FOREIGN KEY ("rowId") REFERENCES "crdt_data_rows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT "crdt_data_tombstone_fk_1" FOREIGN KEY ("nodeId") REFERENCES "crdt_nodes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_data_tombstone_row_idx" ON "crdt_data_tombstone" ("rowId");
--
-- Class CrdtNode as table crdt_nodes
--
CREATE TABLE "crdt_nodes" (
"id" INTEGER PRIMARY KEY,
"uuidNodeId" BLOB NOT NULL DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
"lastHlc" BLOB
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_nodes__uuidNodeId__unique_idx" ON "crdt_nodes" ("uuidNodeId");
--
-- Class CrdtSchemaColumn as table crdt_schema_columns
--
CREATE TABLE "crdt_schema_columns" (
"id" INTEGER PRIMARY KEY,
"tblId" INTEGER NOT NULL,
"name" TEXT NOT NULL,
CONSTRAINT "crdt_schema_columns_fk_0" FOREIGN KEY ("tblId") REFERENCES "crdt_schema_tables" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_schema_columns_table_column_idx" ON "crdt_schema_columns" ("tblId", "name");
--
-- Class CrdtSchemaTable as table crdt_schema_tables
--
CREATE TABLE "crdt_schema_tables" (
"id" INTEGER PRIMARY KEY,
"name" TEXT NOT NULL
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_schema_tables__name__unique_idx" ON "crdt_schema_tables" ("name");
--
-- Class CrdtScopeMember as table crdt_scope_members
--
CREATE TABLE "crdt_scope_members" (
"id" INTEGER PRIMARY KEY,
"scopeId" INTEGER NOT NULL,
"userUuid" BLOB NOT NULL,
"role" TEXT NOT NULL,
CONSTRAINT "crdt_scope_members_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_scope_member_unique_idx" ON "crdt_scope_members" ("userUuid", "scopeId");
--
-- Class CrdtScopeNode as table crdt_scope_nodes
--
CREATE TABLE "crdt_scope_nodes" (
"id" INTEGER PRIMARY KEY,
"scopeId" INTEGER NOT NULL,
"nodeId" INTEGER NOT NULL,
"lastReceivedHlc" BLOB,
CONSTRAINT "crdt_scope_nodes_fk_0" FOREIGN KEY ("scopeId") REFERENCES "crdt_scopes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT "crdt_scope_nodes_fk_1" FOREIGN KEY ("nodeId") REFERENCES "crdt_nodes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_scope_node_unique_idx" ON "crdt_scope_nodes" ("scopeId", "nodeId");
--
-- Class CrdtScope as table crdt_scopes
--
CREATE TABLE "crdt_scopes" (
"id" INTEGER PRIMARY KEY,
"uuidScopeId" BLOB NOT NULL DEFAULT (unhex(printf('%012x', CAST(unixepoch('now', 'subsecond') * 1000 AS INTEGER)) || '7' || substr(hex(randomblob(2)), 2, 3) || substr('89AB', 1 + (abs(random()) % 4), 1) || substr(hex(randomblob(8)), 2, 15))),
"currentNodeId" INTEGER,
CONSTRAINT "crdt_scopes_fk_0" FOREIGN KEY ("currentNodeId") REFERENCES "crdt_nodes" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_scopes__uuidScopeId__unique_idx" ON "crdt_scopes" ("uuidScopeId");
--
-- Class CrdtSyncIntegrityViolation as table crdt_sync_integrity_violations
--
CREATE TABLE "crdt_sync_integrity_violations" (
"id" INTEGER PRIMARY KEY,
"type" TEXT NOT NULL,
"domainTableName" TEXT NOT NULL,
"uuidRowId" BLOB NOT NULL,
"ownerScopeUuid" BLOB,
"incomingScopeUuid" BLOB NOT NULL,
"operation" TEXT NOT NULL,
"uuidNodeId" BLOB,
"crdtDataRowId" INTEGER,
"hlcDatetime" INTEGER,
"hlcCounter" INTEGER,
"firstSeenAt" INTEGER NOT NULL,
"lastSeenAt" INTEGER NOT NULL,
"occurrences" INTEGER NOT NULL
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "crdt_sync_integrity_violations_key_idx" ON "crdt_sync_integrity_violations" ("type", "operation", "domainTableName", "uuidRowId", "ownerScopeUuid", "incomingScopeUuid");
--
-- Class CloudStorageEntry as table serverpod_cloud_storage
--
CREATE TABLE "serverpod_cloud_storage" (
"id" INTEGER PRIMARY KEY,
"storageId" TEXT NOT NULL,
"path" TEXT NOT NULL,
"addedTime" INTEGER NOT NULL,
"expiration" INTEGER,
"byteData" BLOB NOT NULL,
"verified" INTEGER NOT NULL
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "serverpod_cloud_storage_path_idx" ON "serverpod_cloud_storage" ("storageId", "path");
CREATE INDEX "serverpod_cloud_storage_expiration" ON "serverpod_cloud_storage" ("expiration");
--
-- Class CloudStorageDirectUploadEntry as table serverpod_cloud_storage_direct_upload
--
CREATE TABLE "serverpod_cloud_storage_direct_upload" (
"id" INTEGER PRIMARY KEY,
"storageId" TEXT NOT NULL,
"path" TEXT NOT NULL,
"expiration" INTEGER NOT NULL,
"authKey" TEXT NOT NULL
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "serverpod_cloud_storage_direct_upload_storage_path" ON "serverpod_cloud_storage_direct_upload" ("storageId", "path");
--
-- Class FutureCallEntry as table serverpod_future_call
--
CREATE TABLE "serverpod_future_call" (
"id" INTEGER PRIMARY KEY,
"name" TEXT NOT NULL,
"time" INTEGER NOT NULL,
"serializedObject" TEXT,
"serverId" TEXT NOT NULL,
"identifier" TEXT,
"scheduling" TEXT
) STRICT;
-- Indexes
CREATE INDEX "serverpod_future_call_time_idx" ON "serverpod_future_call" ("time");
CREATE INDEX "serverpod_future_call_serverId_idx" ON "serverpod_future_call" ("serverId");
CREATE INDEX "serverpod_future_call_identifier_idx" ON "serverpod_future_call" ("identifier");
--
-- Class FutureCallClaimEntry as table serverpod_future_call_claim
--
CREATE TABLE "serverpod_future_call_claim" (
"id" INTEGER PRIMARY KEY,
"futureCallId" INTEGER,
"lastHeartbeatTime" INTEGER NOT NULL,
CONSTRAINT "serverpod_future_call_claim_fk_0" FOREIGN KEY ("futureCallId") REFERENCES "serverpod_future_call" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "future_call_unique_idx" ON "serverpod_future_call_claim" ("futureCallId");
--
-- Class ServerHealthConnectionInfo as table serverpod_health_connection_info
--
CREATE TABLE "serverpod_health_connection_info" (
"id" INTEGER PRIMARY KEY,
"serverId" TEXT NOT NULL,
"timestamp" INTEGER NOT NULL,
"active" INTEGER NOT NULL,
"closing" INTEGER NOT NULL,
"idle" INTEGER NOT NULL,
"granularity" INTEGER NOT NULL
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "serverpod_health_connection_info_timestamp_idx" ON "serverpod_health_connection_info" ("timestamp", "serverId", "granularity");
--
-- Class ServerHealthMetric as table serverpod_health_metric
--
CREATE TABLE "serverpod_health_metric" (
"id" INTEGER PRIMARY KEY,
"name" TEXT NOT NULL,
"serverId" TEXT NOT NULL,
"timestamp" INTEGER NOT NULL,
"isHealthy" INTEGER NOT NULL,
"value" REAL NOT NULL,
"granularity" INTEGER NOT NULL
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "serverpod_health_metric_timestamp_idx" ON "serverpod_health_metric" ("timestamp", "serverId", "name", "granularity");
--
-- Class LogEntry as table serverpod_log
--
CREATE TABLE "serverpod_log" (
"id" INTEGER PRIMARY KEY,
"sessionLogId" INTEGER NOT NULL,
"messageId" INTEGER,
"reference" TEXT,
"serverId" TEXT NOT NULL,
"time" INTEGER NOT NULL,
"logLevel" INTEGER NOT NULL,
"message" TEXT NOT NULL,
"error" TEXT,
"stackTrace" TEXT,
"order" INTEGER NOT NULL,
CONSTRAINT "serverpod_log_fk_0" FOREIGN KEY ("sessionLogId") REFERENCES "serverpod_session_log" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE INDEX "serverpod_log_sessionLogId_idx" ON "serverpod_log" ("sessionLogId", "order");
--
-- Class MessageLogEntry as table serverpod_message_log
--
CREATE TABLE "serverpod_message_log" (
"id" INTEGER PRIMARY KEY,
"sessionLogId" INTEGER NOT NULL,
"serverId" TEXT NOT NULL,
"messageId" INTEGER NOT NULL,
"endpoint" TEXT NOT NULL,
"messageName" TEXT NOT NULL,
"duration" REAL NOT NULL,
"error" TEXT,
"stackTrace" TEXT,
"slow" INTEGER NOT NULL,
"order" INTEGER NOT NULL,
CONSTRAINT "serverpod_message_log_fk_0" FOREIGN KEY ("sessionLogId") REFERENCES "serverpod_session_log" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE INDEX "serverpod_message_log_sessionLogId_idx" ON "serverpod_message_log" ("sessionLogId", "order");
--
-- Class MethodInfo as table serverpod_method
--
CREATE TABLE "serverpod_method" (
"id" INTEGER PRIMARY KEY,
"endpoint" TEXT NOT NULL,
"method" TEXT NOT NULL
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "serverpod_method_endpoint_method_idx" ON "serverpod_method" ("endpoint", "method");
--
-- Class DatabaseMigrationVersion as table serverpod_migrations
--
CREATE TABLE "serverpod_migrations" (
"id" INTEGER PRIMARY KEY,
"module" TEXT NOT NULL,
"version" TEXT NOT NULL,
"timestamp" INTEGER
) STRICT;
-- Indexes
CREATE UNIQUE INDEX "serverpod_migrations_ids" ON "serverpod_migrations" ("module");
--
-- Class QueryLogEntry as table serverpod_query_log
--
CREATE TABLE "serverpod_query_log" (
"id" INTEGER PRIMARY KEY,
"serverId" TEXT NOT NULL,
"sessionLogId" INTEGER NOT NULL,
"messageId" INTEGER,
"query" TEXT NOT NULL,
"duration" REAL NOT NULL,
"numRows" INTEGER,
"error" TEXT,
"stackTrace" TEXT,
"slow" INTEGER NOT NULL,
"order" INTEGER NOT NULL,
CONSTRAINT "serverpod_query_log_fk_0" FOREIGN KEY ("sessionLogId") REFERENCES "serverpod_session_log" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
) STRICT;
-- Indexes
CREATE INDEX "serverpod_query_log_sessionLogId_idx" ON "serverpod_query_log" ("sessionLogId", "order");
--
-- Class ReadWriteTestEntry as table serverpod_readwrite_test
--
CREATE TABLE "serverpod_readwrite_test" (
"id" INTEGER PRIMARY KEY,
"number" INTEGER NOT NULL
) STRICT;
--
-- Class RuntimeSettings as table serverpod_runtime_settings
--
CREATE TABLE "serverpod_runtime_settings" (
"id" INTEGER PRIMARY KEY,
"logSettings" TEXT NOT NULL,
"logSettingsOverrides" TEXT NOT NULL,
"logServiceCalls" INTEGER NOT NULL,
"logMalformedCalls" INTEGER NOT NULL
) STRICT;
--
-- Class SessionLogEntry as table serverpod_session_log
--
CREATE TABLE "serverpod_session_log" (
"id" INTEGER PRIMARY KEY,
"serverId" TEXT NOT NULL,
"time" INTEGER NOT NULL,
"module" TEXT,
"endpoint" TEXT,
"method" TEXT,
"duration" REAL,
"numQueries" INTEGER,
"slow" INTEGER,
"error" TEXT,
"stackTrace" TEXT,
"authenticatedUserId" INTEGER,
"userId" TEXT,
"isOpen" INTEGER,
"touched" INTEGER NOT NULL
) STRICT;
-- Indexes
CREATE INDEX "serverpod_session_log_serverid_idx" ON "serverpod_session_log" ("serverId");
CREATE INDEX "serverpod_session_log_time_idx" ON "serverpod_session_log" ("time");
CREATE INDEX "serverpod_session_log_touched_idx" ON "serverpod_session_log" ("touched");
CREATE INDEX "serverpod_session_log_isopen_idx" ON "serverpod_session_log" ("isOpen");
--
-- STORE COLUMN TYPES FOR MIGRATIONS
--
DROP TABLE IF EXISTS "serverpod_sqlite_schema";
CREATE TABLE "serverpod_sqlite_schema" (
"table_name" TEXT NOT NULL,
"column_name" TEXT NOT NULL,
"column_type" TEXT NOT NULL,
"column_vector_dimension" INTEGER,
PRIMARY KEY ("table_name", "column_name")
);
INSERT INTO "serverpod_sqlite_schema" VALUES
('crdt_data_fields', 'hlcDatetime', 'timestampWithoutTimeZone', NULL),
('crdt_data_foreign_key', 'attemptedValue', 'uuid', NULL),
('crdt_data_foreign_key', 'visibleValue', 'uuid', NULL),
('crdt_data_rows', 'hlcDatetime', 'timestampWithoutTimeZone', NULL),
('crdt_data_rows', 'uuidRowId', 'uuid', NULL),
('crdt_data_tombstone', 'hlcDatetime', 'timestampWithoutTimeZone', NULL),
('crdt_nodes', 'uuidNodeId', 'uuid', NULL),
('crdt_nodes', 'lastHlc', 'jsonb', NULL),
('crdt_scope_members', 'userUuid', 'uuid', NULL),
('crdt_scope_nodes', 'lastReceivedHlc', 'jsonb', NULL),
('crdt_scopes', 'uuidScopeId', 'uuid', NULL),
('crdt_sync_integrity_violations', 'uuidRowId', 'uuid', NULL),
('crdt_sync_integrity_violations', 'ownerScopeUuid', 'uuid', NULL),
('crdt_sync_integrity_violations', 'incomingScopeUuid', 'uuid', NULL),
('crdt_sync_integrity_violations', 'uuidNodeId', 'uuid', NULL),
('crdt_sync_integrity_violations', 'hlcDatetime', 'timestampWithoutTimeZone', NULL),
('crdt_sync_integrity_violations', 'firstSeenAt', 'timestampWithoutTimeZone', NULL),
('crdt_sync_integrity_violations', 'lastSeenAt', 'timestampWithoutTimeZone', NULL),
('serverpod_cloud_storage', 'addedTime', 'timestampWithoutTimeZone', NULL),
('serverpod_cloud_storage', 'expiration', 'timestampWithoutTimeZone', NULL),
('serverpod_cloud_storage', 'verified', 'boolean', NULL),
('serverpod_cloud_storage_direct_upload', 'expiration', 'timestampWithoutTimeZone', NULL),
('serverpod_future_call', 'time', 'timestampWithoutTimeZone', NULL),
('serverpod_future_call', 'scheduling', 'json', NULL),
('serverpod_future_call_claim', 'lastHeartbeatTime', 'timestampWithoutTimeZone', NULL),
('serverpod_health_connection_info', 'timestamp', 'timestampWithoutTimeZone', NULL),
('serverpod_health_metric', 'timestamp', 'timestampWithoutTimeZone', NULL),
('serverpod_health_metric', 'isHealthy', 'boolean', NULL),
('serverpod_log', 'time', 'timestampWithoutTimeZone', NULL),
('serverpod_message_log', 'slow', 'boolean', NULL),
('serverpod_migrations', 'timestamp', 'timestampWithoutTimeZone', NULL),
('serverpod_query_log', 'slow', 'boolean', NULL),
('serverpod_runtime_settings', 'logSettings', 'json', NULL),
('serverpod_runtime_settings', 'logSettingsOverrides', 'json', NULL),
('serverpod_runtime_settings', 'logServiceCalls', 'boolean', NULL),
('serverpod_runtime_settings', 'logMalformedCalls', 'boolean', NULL),
('serverpod_session_log', 'time', 'timestampWithoutTimeZone', NULL),
('serverpod_session_log', 'slow', 'boolean', NULL),
('serverpod_session_log', 'isOpen', 'boolean', NULL),
('serverpod_session_log', 'touched', 'timestampWithoutTimeZone', NULL);
--
-- MIGRATION VERSION FOR serverpod_offline_sync
--
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
VALUES ('serverpod_offline_sync', '20260703114646971', (unixepoch('now', 'subsecond') * 1000))
ON CONFLICT ("module")
DO UPDATE SET "version" = '20260703114646971', "timestamp" = (unixepoch('now', 'subsecond') * 1000);
--
-- MIGRATION VERSION FOR serverpod
--
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
VALUES ('serverpod', '20260416151914983-insights-perf', (unixepoch('now', 'subsecond') * 1000))
ON CONFLICT ("module")
DO UPDATE SET "version" = '20260416151914983-insights-perf', "timestamp" = (unixepoch('now', 'subsecond') * 1000);
COMMIT;
''';
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,19 @@
/// AUTOGENERATED BY SERVERPOD create-migration - DO NOT EDIT BY HAND
/// Merging: resolve registry conflicts the same as migration_registry.txt.
library;
import 'package:serverpod_database/serverpod_database.dart';
part '20260703114646971/migration.dart';
/// Migration registry for the client-side database.
class MigrationRegistry {
/// Ordered list of all client-side database migrations.
/// New migrations are always appended at the end.
static final List<MigrationVersionSql> migrations = [
_Migration20260703114646971(),
];
/// List of all client-side database migration versions.
static List<String> get versions => migrations.map((m) => m.version).toList();
}

View file

@ -0,0 +1,53 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_client/serverpod_client.dart' as _i1;
import 'dart:async' as _i2;
import 'package:serverpod_offline_sync_client/src/protocol/sync/stream_event.dart'
as _i3;
/// Endpoint for CRDT-based offline-first synchronization.
/// {@category Endpoint}
class EndpointCrdtSync extends _i1.EndpointRef {
EndpointCrdtSync(_i1.EndpointCaller caller) : super(caller);
@override
String get name => 'serverpod_offline_sync.crdtSync';
/// Opens a bidirectional CRDT sync session with the authenticated client.
_i2.Stream<_i3.CrdtSyncStreamEvent> sync({
required _i2.Stream<_i3.CrdtSyncStreamEvent> changes,
required bool once,
}) =>
caller.callStreamingServerEndpoint<
_i2.Stream<_i3.CrdtSyncStreamEvent>,
_i3.CrdtSyncStreamEvent
>(
'serverpod_offline_sync.crdtSync',
'sync',
{'once': once},
{'changes': changes},
);
}
class Caller extends _i1.ModuleEndpointCaller {
Caller(_i1.ServerpodClientShared client) : super(client) {
crdtSync = EndpointCrdtSync(this);
}
late final EndpointCrdtSync crdtSync;
@override
Map<String, _i1.EndpointRef> get endpointRefLookup => {
'serverpod_offline_sync.crdtSync': crdtSync,
};
}

View file

@ -0,0 +1,885 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: dead_code, unnecessary_null_comparison
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_offline_sync_shared/serverpod_offline_sync_shared.dart'
as _i1;
import 'package:serverpod_database/serverpod_database.dart' as _i2;
import '../data/row.dart' as _i3;
import '../node/node.dart' as _i4;
import '../data/deleted_reason.dart' as _i5;
import 'package:serverpod_client/serverpod_client.dart' as _i6;
import 'package:serverpod_offline_sync_client/src/protocol/protocol.dart'
as _i7;
/// CRDT visibility generation table.
///
/// This table stores materialized monotone CLFlag metadata after a visibility
/// change event has been recorded.
abstract class CrdtDataDeleted extends _i1.BaseHlc
implements _i2.TableRow<int?> {
CrdtDataDeleted._({
this.id,
required super.hlcDatetime,
required super.hlcCounter,
this.row,
required this.rowId,
required this.nodeId,
this.node,
required this.clFlag,
required this.reason,
});
factory CrdtDataDeleted({
int? id,
required DateTime hlcDatetime,
required int hlcCounter,
_i3.CrdtDataRow? row,
required int rowId,
required int nodeId,
_i4.CrdtNode? node,
required int clFlag,
required _i5.CrdtDataDeletedReason reason,
}) = _CrdtDataDeletedImpl;
factory CrdtDataDeleted.fromJson(Map<String, dynamic> jsonSerialization) {
return CrdtDataDeleted(
id: jsonSerialization['id'] as int?,
hlcDatetime: _i6.DateTimeJsonExtension.fromJson(
jsonSerialization['hlcDatetime'],
),
hlcCounter: jsonSerialization['hlcCounter'] as int,
row: jsonSerialization['row'] == null
? null
: _i7.Protocol().deserialize<_i3.CrdtDataRow>(
jsonSerialization['row'],
),
rowId: jsonSerialization['rowId'] as int,
nodeId: jsonSerialization['nodeId'] as int,
node: jsonSerialization['node'] == null
? null
: _i7.Protocol().deserialize<_i4.CrdtNode>(jsonSerialization['node']),
clFlag: jsonSerialization['clFlag'] as int,
reason: _i5.CrdtDataDeletedReason.fromJson(
(jsonSerialization['reason'] as int),
),
);
}
static final t = CrdtDataDeletedTable();
static const db = CrdtDataDeletedRepository._();
@override
int? id;
/// Row whose visibility is tracked.
_i3.CrdtDataRow? row;
int rowId;
int nodeId;
/// The node that updated the field.
_i4.CrdtNode? node;
/// Monotone causal-length flag. Odd values are visible and even values are deleted.
int clFlag;
/// Why the row entered its current visibility generation.
_i5.CrdtDataDeletedReason reason;
@override
_i2.Table<int?> get table => t;
/// Returns a shallow copy of this [CrdtDataDeleted]
/// with some or all fields replaced by the given arguments.
@override
@_i6.useResult
CrdtDataDeleted copyWith({
int? id,
DateTime? hlcDatetime,
int? hlcCounter,
_i3.CrdtDataRow? row,
int? rowId,
int? nodeId,
_i4.CrdtNode? node,
int? clFlag,
_i5.CrdtDataDeletedReason? reason,
});
@override
Map<String, dynamic> toJson() {
return {
'__className__': 'serverpod_offline_sync.CrdtDataDeleted',
if (id != null) 'id': id,
'hlcDatetime': hlcDatetime.toJson(),
'hlcCounter': hlcCounter,
if (row != null) 'row': row?.toJson(),
'rowId': rowId,
'nodeId': nodeId,
if (node != null) 'node': node?.toJson(),
'clFlag': clFlag,
'reason': reason.toJson(),
};
}
static CrdtDataDeletedInclude include({
_i3.CrdtDataRowInclude? row,
_i4.CrdtNodeInclude? node,
}) {
return CrdtDataDeletedInclude._(
row: row,
node: node,
);
}
static CrdtDataDeletedIncludeList includeList({
_i2.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
int? limit,
int? offset,
_i2.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i2.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
CrdtDataDeletedInclude? include,
}) {
return CrdtDataDeletedIncludeList._(
where: where,
limit: limit,
offset: offset,
orderBy: orderBy?.call(CrdtDataDeleted.t),
orderDescending: // ignore: deprecated_member_use_from_same_package
orderDescending,
orderByList: orderByList?.call(CrdtDataDeleted.t),
include: include,
);
}
@override
String toString() {
return _i6.SerializationManager.encode(this);
}
}
class _Undefined {}
class _CrdtDataDeletedImpl extends CrdtDataDeleted {
_CrdtDataDeletedImpl({
int? id,
required DateTime hlcDatetime,
required int hlcCounter,
_i3.CrdtDataRow? row,
required int rowId,
required int nodeId,
_i4.CrdtNode? node,
required int clFlag,
required _i5.CrdtDataDeletedReason reason,
}) : super._(
id: id,
hlcDatetime: hlcDatetime,
hlcCounter: hlcCounter,
row: row,
rowId: rowId,
nodeId: nodeId,
node: node,
clFlag: clFlag,
reason: reason,
);
/// Returns a shallow copy of this [CrdtDataDeleted]
/// with some or all fields replaced by the given arguments.
@_i6.useResult
@override
CrdtDataDeleted copyWith({
Object? id = _Undefined,
DateTime? hlcDatetime,
int? hlcCounter,
Object? row = _Undefined,
int? rowId,
int? nodeId,
Object? node = _Undefined,
int? clFlag,
_i5.CrdtDataDeletedReason? reason,
}) {
return CrdtDataDeleted(
id: id is int? ? id : this.id,
hlcDatetime: hlcDatetime ?? this.hlcDatetime,
hlcCounter: hlcCounter ?? this.hlcCounter,
row: row is _i3.CrdtDataRow? ? row : this.row?.copyWith(),
rowId: rowId ?? this.rowId,
nodeId: nodeId ?? this.nodeId,
node: node is _i4.CrdtNode? ? node : this.node?.copyWith(),
clFlag: clFlag ?? this.clFlag,
reason: reason ?? this.reason,
);
}
}
class CrdtDataDeletedUpdateTable extends _i2.UpdateTable<CrdtDataDeletedTable> {
CrdtDataDeletedUpdateTable(super.table);
_i2.ColumnValue<DateTime, DateTime> hlcDatetime(DateTime value) =>
_i2.ColumnValue(
table.hlcDatetime,
value,
);
_i2.ColumnValue<int, int> hlcCounter(int value) => _i2.ColumnValue(
table.hlcCounter,
value,
);
_i2.ColumnValue<int, int> rowId(int value) => _i2.ColumnValue(
table.rowId,
value,
);
_i2.ColumnValue<int, int> nodeId(int value) => _i2.ColumnValue(
table.nodeId,
value,
);
_i2.ColumnValue<int, int> clFlag(int value) => _i2.ColumnValue(
table.clFlag,
value,
);
_i2.ColumnValue<_i5.CrdtDataDeletedReason, _i5.CrdtDataDeletedReason> reason(
_i5.CrdtDataDeletedReason value,
) => _i2.ColumnValue(
table.reason,
value,
);
}
class CrdtDataDeletedTable extends _i2.Table<int?> {
CrdtDataDeletedTable({super.tableRelation})
: super(tableName: 'crdt_data_tombstone') {
updateTable = CrdtDataDeletedUpdateTable(this);
hlcDatetime = _i2.ColumnDateTime(
'hlcDatetime',
this,
);
hlcCounter = _i2.ColumnInt(
'hlcCounter',
this,
);
rowId = _i2.ColumnInt(
'rowId',
this,
);
nodeId = _i2.ColumnInt(
'nodeId',
this,
);
clFlag = _i2.ColumnInt(
'clFlag',
this,
);
reason = _i2.ColumnEnum(
'reason',
this,
_i2.EnumSerialization.byIndex,
);
}
late final CrdtDataDeletedUpdateTable updateTable;
/// The datetime component of the HLC timestamp.
late final _i2.ColumnDateTime hlcDatetime;
/// The counter component of the HLC timestamp.
late final _i2.ColumnInt hlcCounter;
/// Row whose visibility is tracked.
_i3.CrdtDataRowTable? _row;
late final _i2.ColumnInt rowId;
late final _i2.ColumnInt nodeId;
/// The node that updated the field.
_i4.CrdtNodeTable? _node;
/// Monotone causal-length flag. Odd values are visible and even values are deleted.
late final _i2.ColumnInt clFlag;
/// Why the row entered its current visibility generation.
late final _i2.ColumnEnum<_i5.CrdtDataDeletedReason> reason;
_i3.CrdtDataRowTable get row {
if (_row != null) return _row!;
_row = _i2.createRelationTable(
relationFieldName: 'row',
field: CrdtDataDeleted.t.rowId,
foreignField: _i3.CrdtDataRow.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i3.CrdtDataRowTable(tableRelation: foreignTableRelation),
);
return _row!;
}
_i4.CrdtNodeTable get node {
if (_node != null) return _node!;
_node = _i2.createRelationTable(
relationFieldName: 'node',
field: CrdtDataDeleted.t.nodeId,
foreignField: _i4.CrdtNode.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i4.CrdtNodeTable(tableRelation: foreignTableRelation),
);
return _node!;
}
@override
List<_i2.Column> get columns => [
id,
hlcDatetime,
hlcCounter,
rowId,
nodeId,
clFlag,
reason,
];
@override
_i2.Table? getRelationTable(String relationField) {
if (relationField == 'row') {
return row;
}
if (relationField == 'node') {
return node;
}
return null;
}
}
class CrdtDataDeletedInclude extends _i2.IncludeObject {
CrdtDataDeletedInclude._({
_i3.CrdtDataRowInclude? row,
_i4.CrdtNodeInclude? node,
}) {
_row = row;
_node = node;
}
_i3.CrdtDataRowInclude? _row;
_i4.CrdtNodeInclude? _node;
@override
Map<String, _i2.Include?> get includes => {
'row': _row,
'node': _node,
};
@override
_i2.Table<int?> get table => CrdtDataDeleted.t;
}
class CrdtDataDeletedIncludeList extends _i2.IncludeList {
CrdtDataDeletedIncludeList._({
_i2.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
super.limit,
super.offset,
super.orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
super.orderDescending,
super.orderByList,
super.include,
}) {
super.where = where?.call(CrdtDataDeleted.t);
}
@override
Map<String, _i2.Include?> get includes => include?.includes ?? {};
@override
_i2.Table<int?> get table => CrdtDataDeleted.t;
}
class CrdtDataDeletedRepository {
const CrdtDataDeletedRepository._();
final attachRow = const CrdtDataDeletedAttachRowRepository._();
/// Returns a list of [CrdtDataDeleted]s matching the given query parameters.
///
/// Use [where] to specify which items to include in the return value.
/// If none is specified, all items will be returned.
///
/// To specify the order of the items use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// The maximum number of items can be set by [limit]. If no limit is set,
/// all items matching the query will be returned.
///
/// [offset] defines how many items to skip, after which [limit] (or all)
/// items are read from the database.
///
/// ```dart
/// var persons = await Persons.db.find(
/// session,
/// where: (t) => t.lastName.equals('Jones'),
/// orderBy: (t) => t.firstName,
/// limit: 100,
/// );
/// ```
Future<List<CrdtDataDeleted>> find(
_i2.DatabaseSession session, {
_i2.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
int? limit,
int? offset,
_i2.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i2.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_i2.Transaction? transaction,
CrdtDataDeletedInclude? include,
_i2.LockMode? lockMode,
_i2.LockBehavior? lockBehavior,
}) async {
return session.db.find<CrdtDataDeleted>(
where: where?.call(CrdtDataDeleted.t),
orderBy: orderBy?.call(CrdtDataDeleted.t),
orderByList: orderByList?.call(CrdtDataDeleted.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
limit: limit,
offset: offset,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Returns the first matching [CrdtDataDeleted] matching the given query parameters.
///
/// Use [where] to specify which items to include in the return value.
/// If none is specified, all items will be returned.
///
/// To specify the order use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// [offset] defines how many items to skip, after which the next one will be picked.
///
/// ```dart
/// var youngestPerson = await Persons.db.findFirstRow(
/// session,
/// where: (t) => t.lastName.equals('Jones'),
/// orderBy: (t) => t.age,
/// );
/// ```
Future<CrdtDataDeleted?> findFirstRow(
_i2.DatabaseSession session, {
_i2.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
int? offset,
_i2.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i2.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_i2.Transaction? transaction,
CrdtDataDeletedInclude? include,
_i2.LockMode? lockMode,
_i2.LockBehavior? lockBehavior,
}) async {
return session.db.findFirstRow<CrdtDataDeleted>(
where: where?.call(CrdtDataDeleted.t),
orderBy: orderBy?.call(CrdtDataDeleted.t),
orderByList: orderByList?.call(CrdtDataDeleted.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
offset: offset,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Finds a single [CrdtDataDeleted] by its [id] or null if no such row exists.
Future<CrdtDataDeleted?> findById(
_i2.DatabaseSession session,
int id, {
_i2.Transaction? transaction,
CrdtDataDeletedInclude? include,
_i2.LockMode? lockMode,
_i2.LockBehavior? lockBehavior,
}) async {
return session.db.findById<CrdtDataDeleted>(
id,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Inserts all [CrdtDataDeleted]s in the list and returns the inserted rows.
///
/// The returned [CrdtDataDeleted]s will have their `id` fields set.
///
/// This is an atomic operation, meaning that if one of the rows fails to
/// insert, none of the rows will be inserted.
///
/// If [ignoreConflicts] is set to `true`, rows that conflict with existing
/// rows are silently skipped, and only the successfully inserted rows are
/// returned.
///
/// If [noReturn] is set to `true`, the inserted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataDeleted>> insert(
_i2.DatabaseSession session,
List<CrdtDataDeleted> rows, {
_i2.Transaction? transaction,
bool ignoreConflicts = false,
bool noReturn = false,
}) async {
return session.db.insert<CrdtDataDeleted>(
rows,
transaction: transaction,
ignoreConflicts: ignoreConflicts,
noReturn: noReturn,
);
}
/// Inserts a single [CrdtDataDeleted] and returns the inserted row.
///
/// The returned [CrdtDataDeleted] will have its `id` field set.
Future<CrdtDataDeleted> insertRow(
_i2.DatabaseSession session,
CrdtDataDeleted row, {
_i2.Transaction? transaction,
}) async {
return session.db.insertRow<CrdtDataDeleted>(
row,
transaction: transaction,
);
}
/// Upserts all [CrdtDataDeleted]s in the list and returns the resulting rows.
///
/// If a row conflicts on the given [conflictColumns], the existing row is
/// updated with the new values. Otherwise, a new row is inserted.
///
/// If [updateColumns] is provided, only those columns will be updated on
/// conflict. If null, all non-conflict, non-id columns are updated.
///
/// If [updateWhere] is provided, the update only applies to rows matching the
/// given expression. Conflicting rows that don't match are skipped and not
/// returned, so the resulting list may be shorter than [rows].
///
/// The returned [CrdtDataDeleted]s will have their `id` fields set.
///
/// This is an atomic operation, meaning that if one of the rows fails,
/// none of the rows will be affected.
///
/// If [noReturn] is set to `true`, the resulting rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataDeleted>> upsert(
_i2.DatabaseSession session,
List<CrdtDataDeleted> rows, {
required _i2.ColumnSelections<CrdtDataDeletedTable> conflictColumns,
_i2.ColumnSelections<CrdtDataDeletedTable>? updateColumns,
_i2.WhereExpressionBuilder<CrdtDataDeletedTable>? updateWhere,
_i2.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.upsert<CrdtDataDeleted>(
rows,
conflictColumns: conflictColumns(CrdtDataDeleted.t),
updateColumns: updateColumns?.call(CrdtDataDeleted.t),
updateWhere: updateWhere?.call(CrdtDataDeleted.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Upserts a single [CrdtDataDeleted] and returns the resulting row.
///
/// If the row conflicts on the given [conflictColumns], the existing row is
/// updated. Otherwise, a new row is inserted.
///
/// If [updateColumns] is provided, only those columns will be updated on
/// conflict. If null, all non-conflict, non-id columns are updated.
///
/// If [updateWhere] is provided, the update only applies when the existing
/// row matches the expression. Returns `null` if no row was affected — for
/// example when [updateWhere] does not match the conflicting row.
///
/// The returned [CrdtDataDeleted] will have its `id` field set.
Future<CrdtDataDeleted?> upsertRow(
_i2.DatabaseSession session,
CrdtDataDeleted row, {
required _i2.ColumnSelections<CrdtDataDeletedTable> conflictColumns,
_i2.ColumnSelections<CrdtDataDeletedTable>? updateColumns,
_i2.WhereExpressionBuilder<CrdtDataDeletedTable>? updateWhere,
_i2.Transaction? transaction,
}) async {
return session.db.upsertRow<CrdtDataDeleted>(
row,
conflictColumns: conflictColumns(CrdtDataDeleted.t),
updateColumns: updateColumns?.call(CrdtDataDeleted.t),
updateWhere: updateWhere?.call(CrdtDataDeleted.t),
transaction: transaction,
);
}
/// Updates all [CrdtDataDeleted]s in the list and returns the updated rows. If
/// [columns] is provided, only those columns will be updated. Defaults to
/// all columns.
/// This is an atomic operation, meaning that if one of the rows fails to
/// update, none of the rows will be updated.
///
/// If [noReturn] is set to `true`, the updated rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataDeleted>> update(
_i2.DatabaseSession session,
List<CrdtDataDeleted> rows, {
_i2.ColumnSelections<CrdtDataDeletedTable>? columns,
_i2.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.update<CrdtDataDeleted>(
rows,
columns: columns?.call(CrdtDataDeleted.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Updates a single [CrdtDataDeleted]. The row needs to have its id set.
/// Optionally, a list of [columns] can be provided to only update those
/// columns. Defaults to all columns.
Future<CrdtDataDeleted> updateRow(
_i2.DatabaseSession session,
CrdtDataDeleted row, {
_i2.ColumnSelections<CrdtDataDeletedTable>? columns,
_i2.Transaction? transaction,
}) async {
return session.db.updateRow<CrdtDataDeleted>(
row,
columns: columns?.call(CrdtDataDeleted.t),
transaction: transaction,
);
}
/// Updates a single [CrdtDataDeleted] by its [id] with the specified [columnValues].
/// Returns the updated row or null if no row with the given id exists.
Future<CrdtDataDeleted?> updateById(
_i2.DatabaseSession session,
int id, {
required _i2.ColumnValueListBuilder<CrdtDataDeletedUpdateTable>
columnValues,
_i2.Transaction? transaction,
}) async {
return session.db.updateById<CrdtDataDeleted>(
id,
columnValues: columnValues(CrdtDataDeleted.t.updateTable),
transaction: transaction,
);
}
/// Updates all [CrdtDataDeleted]s matching the [where] expression with the specified [columnValues].
/// Returns the list of updated rows.
///
/// If [noReturn] is set to `true`, the updated rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataDeleted>> updateWhere(
_i2.DatabaseSession session, {
required _i2.ColumnValueListBuilder<CrdtDataDeletedUpdateTable>
columnValues,
required _i2.WhereExpressionBuilder<CrdtDataDeletedTable> where,
int? limit,
int? offset,
_i2.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i2.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.updateWhere<CrdtDataDeleted>(
columnValues: columnValues(CrdtDataDeleted.t.updateTable),
where: where(CrdtDataDeleted.t),
limit: limit,
offset: offset,
orderBy: orderBy?.call(CrdtDataDeleted.t),
orderByList: orderByList?.call(CrdtDataDeleted.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
transaction: transaction,
noReturn: noReturn,
);
}
/// Deletes all [CrdtDataDeleted]s in the list and returns the deleted rows.
///
/// To specify the order of the returned rows use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// This is an atomic operation, meaning that if one of the rows fail to
/// be deleted, none of the rows will be deleted.
///
/// If [noReturn] is set to `true`, the deleted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataDeleted>> delete(
_i2.DatabaseSession session,
List<CrdtDataDeleted> rows, {
_i2.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i2.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_i2.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.delete<CrdtDataDeleted>(
rows,
orderBy: orderBy?.call(CrdtDataDeleted.t),
orderByList: orderByList?.call(CrdtDataDeleted.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
transaction: transaction,
noReturn: noReturn,
);
}
/// Deletes a single [CrdtDataDeleted].
Future<CrdtDataDeleted> deleteRow(
_i2.DatabaseSession session,
CrdtDataDeleted row, {
_i2.Transaction? transaction,
}) async {
return session.db.deleteRow<CrdtDataDeleted>(
row,
transaction: transaction,
);
}
/// Deletes all rows matching the [where] expression.
///
/// To specify the order of the returned rows use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// If [noReturn] is set to `true`, the deleted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataDeleted>> deleteWhere(
_i2.DatabaseSession session, {
required _i2.WhereExpressionBuilder<CrdtDataDeletedTable> where,
_i2.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i2.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_i2.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.deleteWhere<CrdtDataDeleted>(
where: where(CrdtDataDeleted.t),
orderBy: orderBy?.call(CrdtDataDeleted.t),
orderByList: orderByList?.call(CrdtDataDeleted.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
transaction: transaction,
noReturn: noReturn,
);
}
/// Counts the number of rows matching the [where] expression. If omitted,
/// will return the count of all rows in the table.
Future<int> count(
_i2.DatabaseSession session, {
_i2.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
int? limit,
_i2.Transaction? transaction,
}) async {
return session.db.count<CrdtDataDeleted>(
where: where?.call(CrdtDataDeleted.t),
limit: limit,
transaction: transaction,
);
}
/// Acquires row-level locks on [CrdtDataDeleted] rows matching the [where] expression.
Future<void> lockRows(
_i2.DatabaseSession session, {
required _i2.WhereExpressionBuilder<CrdtDataDeletedTable> where,
required _i2.LockMode lockMode,
required _i2.Transaction transaction,
_i2.LockBehavior lockBehavior = _i2.LockBehavior.wait,
}) async {
return session.db.lockRows<CrdtDataDeleted>(
where: where(CrdtDataDeleted.t),
lockMode: lockMode,
lockBehavior: lockBehavior,
transaction: transaction,
);
}
}
class CrdtDataDeletedAttachRowRepository {
const CrdtDataDeletedAttachRowRepository._();
/// Creates a relation between the given [CrdtDataDeleted] and [CrdtDataRow]
/// by setting the [CrdtDataDeleted]'s foreign key `rowId` to refer to the [CrdtDataRow].
Future<void> row(
_i2.DatabaseSession session,
CrdtDataDeleted crdtDataDeleted,
_i3.CrdtDataRow row, {
_i2.Transaction? transaction,
}) async {
if (crdtDataDeleted.id == null) {
throw ArgumentError.notNull('crdtDataDeleted.id');
}
if (row.id == null) {
throw ArgumentError.notNull('row.id');
}
var $crdtDataDeleted = crdtDataDeleted.copyWith(rowId: row.id);
await session.db.updateRow<CrdtDataDeleted>(
$crdtDataDeleted,
columns: [CrdtDataDeleted.t.rowId],
transaction: transaction,
);
}
/// Creates a relation between the given [CrdtDataDeleted] and [CrdtNode]
/// by setting the [CrdtDataDeleted]'s foreign key `nodeId` to refer to the [CrdtNode].
Future<void> node(
_i2.DatabaseSession session,
CrdtDataDeleted crdtDataDeleted,
_i4.CrdtNode node, {
_i2.Transaction? transaction,
}) async {
if (crdtDataDeleted.id == null) {
throw ArgumentError.notNull('crdtDataDeleted.id');
}
if (node.id == null) {
throw ArgumentError.notNull('node.id');
}
var $crdtDataDeleted = crdtDataDeleted.copyWith(nodeId: node.id);
await session.db.updateRow<CrdtDataDeleted>(
$crdtDataDeleted,
columns: [CrdtDataDeleted.t.nodeId],
transaction: transaction,
);
}
}

View file

@ -0,0 +1,48 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_client/serverpod_client.dart' as _i1;
/// Why a synced user tombstone changed row visibility.
enum CrdtDataDeletedReason implements _i1.SerializableModel {
userInsert,
userReinsert,
userDelete,
userCascadeDelete,
uniqueLoser
;
static CrdtDataDeletedReason fromJson(int index) {
switch (index) {
case 0:
return CrdtDataDeletedReason.userInsert;
case 1:
return CrdtDataDeletedReason.userReinsert;
case 2:
return CrdtDataDeletedReason.userDelete;
case 3:
return CrdtDataDeletedReason.userCascadeDelete;
case 4:
return CrdtDataDeletedReason.uniqueLoser;
default:
throw ArgumentError(
'Value "$index" cannot be converted to "CrdtDataDeletedReason"',
);
}
}
@override
int toJson() => index;
@override
String toString() => name;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,811 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: dead_code, unnecessary_null_comparison
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_database/serverpod_database.dart' as _i1;
import '../data/field.dart' as _i2;
import 'package:serverpod_client/serverpod_client.dart' as _i3;
import '../data/foreign_key_override_reason.dart' as _i4;
import 'package:serverpod_offline_sync_client/src/protocol/protocol.dart'
as _i5;
/// CRDT field foreign key value and projection table.
///
/// This table stores the user/attempted foreign key value for a CRDT field and
/// the materialized foreign key projection for that value. CrdtDataField stores
/// only HLC metadata, so FK columns store their durable attempted value here.
///
/// Repairs must be recomputable from merged CRDT row, field, and tombstone
/// facts plus this attempted FK value. The projection columns record what was
/// materialized into the domain row; they do not decide business semantics or
/// create user field updates during merge.
abstract class CrdtDataForeignKey implements _i1.TableRow<int?> {
CrdtDataForeignKey._({
this.id,
this.field,
required this.fieldId,
required this.attemptedValue,
this.visibleValue,
this.overrideReason,
});
factory CrdtDataForeignKey({
int? id,
_i2.CrdtDataField? field,
required int fieldId,
required _i3.UuidValue? attemptedValue,
_i3.UuidValue? visibleValue,
_i4.CrdtForeignKeyOverrideReason? overrideReason,
}) = _CrdtDataForeignKeyImpl;
factory CrdtDataForeignKey.fromJson(Map<String, dynamic> jsonSerialization) {
return CrdtDataForeignKey(
id: jsonSerialization['id'] as int?,
field: jsonSerialization['field'] == null
? null
: _i5.Protocol().deserialize<_i2.CrdtDataField>(
jsonSerialization['field'],
),
fieldId: jsonSerialization['fieldId'] as int,
attemptedValue: jsonSerialization['attemptedValue'] == null
? null
: _i3.UuidValueJsonExtension.fromJson(
jsonSerialization['attemptedValue'],
),
visibleValue: jsonSerialization['visibleValue'] == null
? null
: _i3.UuidValueJsonExtension.fromJson(
jsonSerialization['visibleValue'],
),
overrideReason: jsonSerialization['overrideReason'] == null
? null
: _i4.CrdtForeignKeyOverrideReason.fromJson(
(jsonSerialization['overrideReason'] as int),
),
);
}
static final t = CrdtDataForeignKeyTable();
static const db = CrdtDataForeignKeyRepository._();
@override
int? id;
/// The field that the foreign key belongs to.
_i2.CrdtDataField? field;
int fieldId;
/// The user-attempted foreign key value that the CRDT field currently carries.
///
/// This may be null for nullable foreign keys. This is durable FK field-value
/// storage for CRDT columns whose CrdtDataField row stores only HLC metadata.
_i3.UuidValue? attemptedValue;
/// The foreign key value that is currently visible in the actual data row
/// when an override is active (overrideReason is non-null).
_i3.UuidValue? visibleValue;
/// The authoritative indicator and reason for an active projection override.
///
/// This is the single source of truth for whether an override is active:
/// non-null means an override is active; null means no override. It also
/// names the cause of the override. The FK resolver recomputes it from merged
/// row, field, and tombstone facts.
_i4.CrdtForeignKeyOverrideReason? overrideReason;
@override
_i1.Table<int?> get table => t;
/// Returns a shallow copy of this [CrdtDataForeignKey]
/// with some or all fields replaced by the given arguments.
@_i3.useResult
CrdtDataForeignKey copyWith({
int? id,
_i2.CrdtDataField? field,
int? fieldId,
_i3.UuidValue? attemptedValue,
_i3.UuidValue? visibleValue,
_i4.CrdtForeignKeyOverrideReason? overrideReason,
});
@override
Map<String, dynamic> toJson() {
return {
'__className__': 'serverpod_offline_sync.CrdtDataForeignKey',
if (id != null) 'id': id,
if (field != null) 'field': field?.toJson(),
'fieldId': fieldId,
if (attemptedValue != null) 'attemptedValue': attemptedValue?.toJson(),
if (visibleValue != null) 'visibleValue': visibleValue?.toJson(),
if (overrideReason != null) 'overrideReason': overrideReason?.toJson(),
};
}
static CrdtDataForeignKeyInclude include({_i2.CrdtDataFieldInclude? field}) {
return CrdtDataForeignKeyInclude._(field: field);
}
static CrdtDataForeignKeyIncludeList includeList({
_i1.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
int? limit,
int? offset,
_i1.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
CrdtDataForeignKeyInclude? include,
}) {
return CrdtDataForeignKeyIncludeList._(
where: where,
limit: limit,
offset: offset,
orderBy: orderBy?.call(CrdtDataForeignKey.t),
orderDescending: // ignore: deprecated_member_use_from_same_package
orderDescending,
orderByList: orderByList?.call(CrdtDataForeignKey.t),
include: include,
);
}
@override
String toString() {
return _i3.SerializationManager.encode(this);
}
}
class _Undefined {}
class _CrdtDataForeignKeyImpl extends CrdtDataForeignKey {
_CrdtDataForeignKeyImpl({
int? id,
_i2.CrdtDataField? field,
required int fieldId,
required _i3.UuidValue? attemptedValue,
_i3.UuidValue? visibleValue,
_i4.CrdtForeignKeyOverrideReason? overrideReason,
}) : super._(
id: id,
field: field,
fieldId: fieldId,
attemptedValue: attemptedValue,
visibleValue: visibleValue,
overrideReason: overrideReason,
);
/// Returns a shallow copy of this [CrdtDataForeignKey]
/// with some or all fields replaced by the given arguments.
@_i3.useResult
@override
CrdtDataForeignKey copyWith({
Object? id = _Undefined,
Object? field = _Undefined,
int? fieldId,
Object? attemptedValue = _Undefined,
Object? visibleValue = _Undefined,
Object? overrideReason = _Undefined,
}) {
return CrdtDataForeignKey(
id: id is int? ? id : this.id,
field: field is _i2.CrdtDataField? ? field : this.field?.copyWith(),
fieldId: fieldId ?? this.fieldId,
attemptedValue: attemptedValue is _i3.UuidValue?
? attemptedValue
: this.attemptedValue,
visibleValue: visibleValue is _i3.UuidValue?
? visibleValue
: this.visibleValue,
overrideReason: overrideReason is _i4.CrdtForeignKeyOverrideReason?
? overrideReason
: this.overrideReason,
);
}
}
class CrdtDataForeignKeyUpdateTable
extends _i1.UpdateTable<CrdtDataForeignKeyTable> {
CrdtDataForeignKeyUpdateTable(super.table);
_i1.ColumnValue<int, int> fieldId(int value) => _i1.ColumnValue(
table.fieldId,
value,
);
_i1.ColumnValue<_i3.UuidValue, _i3.UuidValue> attemptedValue(
_i3.UuidValue? value,
) => _i1.ColumnValue(
table.attemptedValue,
value,
);
_i1.ColumnValue<_i3.UuidValue, _i3.UuidValue> visibleValue(
_i3.UuidValue? value,
) => _i1.ColumnValue(
table.visibleValue,
value,
);
_i1.ColumnValue<
_i4.CrdtForeignKeyOverrideReason,
_i4.CrdtForeignKeyOverrideReason
>
overrideReason(_i4.CrdtForeignKeyOverrideReason? value) => _i1.ColumnValue(
table.overrideReason,
value,
);
}
class CrdtDataForeignKeyTable extends _i1.Table<int?> {
CrdtDataForeignKeyTable({super.tableRelation})
: super(tableName: 'crdt_data_foreign_key') {
updateTable = CrdtDataForeignKeyUpdateTable(this);
fieldId = _i1.ColumnInt(
'fieldId',
this,
);
attemptedValue = _i1.ColumnUuid(
'attemptedValue',
this,
);
visibleValue = _i1.ColumnUuid(
'visibleValue',
this,
);
overrideReason = _i1.ColumnEnum(
'overrideReason',
this,
_i1.EnumSerialization.byIndex,
);
}
late final CrdtDataForeignKeyUpdateTable updateTable;
/// The field that the foreign key belongs to.
_i2.CrdtDataFieldTable? _field;
late final _i1.ColumnInt fieldId;
/// The user-attempted foreign key value that the CRDT field currently carries.
///
/// This may be null for nullable foreign keys. This is durable FK field-value
/// storage for CRDT columns whose CrdtDataField row stores only HLC metadata.
late final _i1.ColumnUuid attemptedValue;
/// The foreign key value that is currently visible in the actual data row
/// when an override is active (overrideReason is non-null).
late final _i1.ColumnUuid visibleValue;
/// The authoritative indicator and reason for an active projection override.
///
/// This is the single source of truth for whether an override is active:
/// non-null means an override is active; null means no override. It also
/// names the cause of the override. The FK resolver recomputes it from merged
/// row, field, and tombstone facts.
late final _i1.ColumnEnum<_i4.CrdtForeignKeyOverrideReason> overrideReason;
_i2.CrdtDataFieldTable get field {
if (_field != null) return _field!;
_field = _i1.createRelationTable(
relationFieldName: 'field',
field: CrdtDataForeignKey.t.fieldId,
foreignField: _i2.CrdtDataField.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i2.CrdtDataFieldTable(tableRelation: foreignTableRelation),
);
return _field!;
}
@override
List<_i1.Column> get columns => [
id,
fieldId,
attemptedValue,
visibleValue,
overrideReason,
];
@override
_i1.Table? getRelationTable(String relationField) {
if (relationField == 'field') {
return field;
}
return null;
}
}
class CrdtDataForeignKeyInclude extends _i1.IncludeObject {
CrdtDataForeignKeyInclude._({_i2.CrdtDataFieldInclude? field}) {
_field = field;
}
_i2.CrdtDataFieldInclude? _field;
@override
Map<String, _i1.Include?> get includes => {'field': _field};
@override
_i1.Table<int?> get table => CrdtDataForeignKey.t;
}
class CrdtDataForeignKeyIncludeList extends _i1.IncludeList {
CrdtDataForeignKeyIncludeList._({
_i1.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
super.limit,
super.offset,
super.orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
super.orderDescending,
super.orderByList,
super.include,
}) {
super.where = where?.call(CrdtDataForeignKey.t);
}
@override
Map<String, _i1.Include?> get includes => include?.includes ?? {};
@override
_i1.Table<int?> get table => CrdtDataForeignKey.t;
}
class CrdtDataForeignKeyRepository {
const CrdtDataForeignKeyRepository._();
final attachRow = const CrdtDataForeignKeyAttachRowRepository._();
/// Returns a list of [CrdtDataForeignKey]s matching the given query parameters.
///
/// Use [where] to specify which items to include in the return value.
/// If none is specified, all items will be returned.
///
/// To specify the order of the items use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// The maximum number of items can be set by [limit]. If no limit is set,
/// all items matching the query will be returned.
///
/// [offset] defines how many items to skip, after which [limit] (or all)
/// items are read from the database.
///
/// ```dart
/// var persons = await Persons.db.find(
/// session,
/// where: (t) => t.lastName.equals('Jones'),
/// orderBy: (t) => t.firstName,
/// limit: 100,
/// );
/// ```
Future<List<CrdtDataForeignKey>> find(
_i1.DatabaseSession session, {
_i1.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
int? limit,
int? offset,
_i1.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_i1.Transaction? transaction,
CrdtDataForeignKeyInclude? include,
_i1.LockMode? lockMode,
_i1.LockBehavior? lockBehavior,
}) async {
return session.db.find<CrdtDataForeignKey>(
where: where?.call(CrdtDataForeignKey.t),
orderBy: orderBy?.call(CrdtDataForeignKey.t),
orderByList: orderByList?.call(CrdtDataForeignKey.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
limit: limit,
offset: offset,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Returns the first matching [CrdtDataForeignKey] matching the given query parameters.
///
/// Use [where] to specify which items to include in the return value.
/// If none is specified, all items will be returned.
///
/// To specify the order use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// [offset] defines how many items to skip, after which the next one will be picked.
///
/// ```dart
/// var youngestPerson = await Persons.db.findFirstRow(
/// session,
/// where: (t) => t.lastName.equals('Jones'),
/// orderBy: (t) => t.age,
/// );
/// ```
Future<CrdtDataForeignKey?> findFirstRow(
_i1.DatabaseSession session, {
_i1.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
int? offset,
_i1.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_i1.Transaction? transaction,
CrdtDataForeignKeyInclude? include,
_i1.LockMode? lockMode,
_i1.LockBehavior? lockBehavior,
}) async {
return session.db.findFirstRow<CrdtDataForeignKey>(
where: where?.call(CrdtDataForeignKey.t),
orderBy: orderBy?.call(CrdtDataForeignKey.t),
orderByList: orderByList?.call(CrdtDataForeignKey.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
offset: offset,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Finds a single [CrdtDataForeignKey] by its [id] or null if no such row exists.
Future<CrdtDataForeignKey?> findById(
_i1.DatabaseSession session,
int id, {
_i1.Transaction? transaction,
CrdtDataForeignKeyInclude? include,
_i1.LockMode? lockMode,
_i1.LockBehavior? lockBehavior,
}) async {
return session.db.findById<CrdtDataForeignKey>(
id,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Inserts all [CrdtDataForeignKey]s in the list and returns the inserted rows.
///
/// The returned [CrdtDataForeignKey]s will have their `id` fields set.
///
/// This is an atomic operation, meaning that if one of the rows fails to
/// insert, none of the rows will be inserted.
///
/// If [ignoreConflicts] is set to `true`, rows that conflict with existing
/// rows are silently skipped, and only the successfully inserted rows are
/// returned.
///
/// If [noReturn] is set to `true`, the inserted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataForeignKey>> insert(
_i1.DatabaseSession session,
List<CrdtDataForeignKey> rows, {
_i1.Transaction? transaction,
bool ignoreConflicts = false,
bool noReturn = false,
}) async {
return session.db.insert<CrdtDataForeignKey>(
rows,
transaction: transaction,
ignoreConflicts: ignoreConflicts,
noReturn: noReturn,
);
}
/// Inserts a single [CrdtDataForeignKey] and returns the inserted row.
///
/// The returned [CrdtDataForeignKey] will have its `id` field set.
Future<CrdtDataForeignKey> insertRow(
_i1.DatabaseSession session,
CrdtDataForeignKey row, {
_i1.Transaction? transaction,
}) async {
return session.db.insertRow<CrdtDataForeignKey>(
row,
transaction: transaction,
);
}
/// Upserts all [CrdtDataForeignKey]s in the list and returns the resulting rows.
///
/// If a row conflicts on the given [conflictColumns], the existing row is
/// updated with the new values. Otherwise, a new row is inserted.
///
/// If [updateColumns] is provided, only those columns will be updated on
/// conflict. If null, all non-conflict, non-id columns are updated.
///
/// If [updateWhere] is provided, the update only applies to rows matching the
/// given expression. Conflicting rows that don't match are skipped and not
/// returned, so the resulting list may be shorter than [rows].
///
/// The returned [CrdtDataForeignKey]s will have their `id` fields set.
///
/// This is an atomic operation, meaning that if one of the rows fails,
/// none of the rows will be affected.
///
/// If [noReturn] is set to `true`, the resulting rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataForeignKey>> upsert(
_i1.DatabaseSession session,
List<CrdtDataForeignKey> rows, {
required _i1.ColumnSelections<CrdtDataForeignKeyTable> conflictColumns,
_i1.ColumnSelections<CrdtDataForeignKeyTable>? updateColumns,
_i1.WhereExpressionBuilder<CrdtDataForeignKeyTable>? updateWhere,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.upsert<CrdtDataForeignKey>(
rows,
conflictColumns: conflictColumns(CrdtDataForeignKey.t),
updateColumns: updateColumns?.call(CrdtDataForeignKey.t),
updateWhere: updateWhere?.call(CrdtDataForeignKey.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Upserts a single [CrdtDataForeignKey] and returns the resulting row.
///
/// If the row conflicts on the given [conflictColumns], the existing row is
/// updated. Otherwise, a new row is inserted.
///
/// If [updateColumns] is provided, only those columns will be updated on
/// conflict. If null, all non-conflict, non-id columns are updated.
///
/// If [updateWhere] is provided, the update only applies when the existing
/// row matches the expression. Returns `null` if no row was affected — for
/// example when [updateWhere] does not match the conflicting row.
///
/// The returned [CrdtDataForeignKey] will have its `id` field set.
Future<CrdtDataForeignKey?> upsertRow(
_i1.DatabaseSession session,
CrdtDataForeignKey row, {
required _i1.ColumnSelections<CrdtDataForeignKeyTable> conflictColumns,
_i1.ColumnSelections<CrdtDataForeignKeyTable>? updateColumns,
_i1.WhereExpressionBuilder<CrdtDataForeignKeyTable>? updateWhere,
_i1.Transaction? transaction,
}) async {
return session.db.upsertRow<CrdtDataForeignKey>(
row,
conflictColumns: conflictColumns(CrdtDataForeignKey.t),
updateColumns: updateColumns?.call(CrdtDataForeignKey.t),
updateWhere: updateWhere?.call(CrdtDataForeignKey.t),
transaction: transaction,
);
}
/// Updates all [CrdtDataForeignKey]s in the list and returns the updated rows. If
/// [columns] is provided, only those columns will be updated. Defaults to
/// all columns.
/// This is an atomic operation, meaning that if one of the rows fails to
/// update, none of the rows will be updated.
///
/// If [noReturn] is set to `true`, the updated rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataForeignKey>> update(
_i1.DatabaseSession session,
List<CrdtDataForeignKey> rows, {
_i1.ColumnSelections<CrdtDataForeignKeyTable>? columns,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.update<CrdtDataForeignKey>(
rows,
columns: columns?.call(CrdtDataForeignKey.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Updates a single [CrdtDataForeignKey]. The row needs to have its id set.
/// Optionally, a list of [columns] can be provided to only update those
/// columns. Defaults to all columns.
Future<CrdtDataForeignKey> updateRow(
_i1.DatabaseSession session,
CrdtDataForeignKey row, {
_i1.ColumnSelections<CrdtDataForeignKeyTable>? columns,
_i1.Transaction? transaction,
}) async {
return session.db.updateRow<CrdtDataForeignKey>(
row,
columns: columns?.call(CrdtDataForeignKey.t),
transaction: transaction,
);
}
/// Updates a single [CrdtDataForeignKey] by its [id] with the specified [columnValues].
/// Returns the updated row or null if no row with the given id exists.
Future<CrdtDataForeignKey?> updateById(
_i1.DatabaseSession session,
int id, {
required _i1.ColumnValueListBuilder<CrdtDataForeignKeyUpdateTable>
columnValues,
_i1.Transaction? transaction,
}) async {
return session.db.updateById<CrdtDataForeignKey>(
id,
columnValues: columnValues(CrdtDataForeignKey.t.updateTable),
transaction: transaction,
);
}
/// Updates all [CrdtDataForeignKey]s matching the [where] expression with the specified [columnValues].
/// Returns the list of updated rows.
///
/// If [noReturn] is set to `true`, the updated rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataForeignKey>> updateWhere(
_i1.DatabaseSession session, {
required _i1.ColumnValueListBuilder<CrdtDataForeignKeyUpdateTable>
columnValues,
required _i1.WhereExpressionBuilder<CrdtDataForeignKeyTable> where,
int? limit,
int? offset,
_i1.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
_i1.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.updateWhere<CrdtDataForeignKey>(
columnValues: columnValues(CrdtDataForeignKey.t.updateTable),
where: where(CrdtDataForeignKey.t),
limit: limit,
offset: offset,
orderBy: orderBy?.call(CrdtDataForeignKey.t),
orderByList: orderByList?.call(CrdtDataForeignKey.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
transaction: transaction,
noReturn: noReturn,
);
}
/// Deletes all [CrdtDataForeignKey]s in the list and returns the deleted rows.
///
/// To specify the order of the returned rows use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// This is an atomic operation, meaning that if one of the rows fail to
/// be deleted, none of the rows will be deleted.
///
/// If [noReturn] is set to `true`, the deleted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataForeignKey>> delete(
_i1.DatabaseSession session,
List<CrdtDataForeignKey> rows, {
_i1.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.delete<CrdtDataForeignKey>(
rows,
orderBy: orderBy?.call(CrdtDataForeignKey.t),
orderByList: orderByList?.call(CrdtDataForeignKey.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
transaction: transaction,
noReturn: noReturn,
);
}
/// Deletes a single [CrdtDataForeignKey].
Future<CrdtDataForeignKey> deleteRow(
_i1.DatabaseSession session,
CrdtDataForeignKey row, {
_i1.Transaction? transaction,
}) async {
return session.db.deleteRow<CrdtDataForeignKey>(
row,
transaction: transaction,
);
}
/// Deletes all rows matching the [where] expression.
///
/// To specify the order of the returned rows use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// If [noReturn] is set to `true`, the deleted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataForeignKey>> deleteWhere(
_i1.DatabaseSession session, {
required _i1.WhereExpressionBuilder<CrdtDataForeignKeyTable> where,
_i1.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.deleteWhere<CrdtDataForeignKey>(
where: where(CrdtDataForeignKey.t),
orderBy: orderBy?.call(CrdtDataForeignKey.t),
orderByList: orderByList?.call(CrdtDataForeignKey.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
transaction: transaction,
noReturn: noReturn,
);
}
/// Counts the number of rows matching the [where] expression. If omitted,
/// will return the count of all rows in the table.
Future<int> count(
_i1.DatabaseSession session, {
_i1.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
int? limit,
_i1.Transaction? transaction,
}) async {
return session.db.count<CrdtDataForeignKey>(
where: where?.call(CrdtDataForeignKey.t),
limit: limit,
transaction: transaction,
);
}
/// Acquires row-level locks on [CrdtDataForeignKey] rows matching the [where] expression.
Future<void> lockRows(
_i1.DatabaseSession session, {
required _i1.WhereExpressionBuilder<CrdtDataForeignKeyTable> where,
required _i1.LockMode lockMode,
required _i1.Transaction transaction,
_i1.LockBehavior lockBehavior = _i1.LockBehavior.wait,
}) async {
return session.db.lockRows<CrdtDataForeignKey>(
where: where(CrdtDataForeignKey.t),
lockMode: lockMode,
lockBehavior: lockBehavior,
transaction: transaction,
);
}
}
class CrdtDataForeignKeyAttachRowRepository {
const CrdtDataForeignKeyAttachRowRepository._();
/// Creates a relation between the given [CrdtDataForeignKey] and [CrdtDataField]
/// by setting the [CrdtDataForeignKey]'s foreign key `fieldId` to refer to the [CrdtDataField].
Future<void> field(
_i1.DatabaseSession session,
CrdtDataForeignKey crdtDataForeignKey,
_i2.CrdtDataField field, {
_i1.Transaction? transaction,
}) async {
if (crdtDataForeignKey.id == null) {
throw ArgumentError.notNull('crdtDataForeignKey.id');
}
if (field.id == null) {
throw ArgumentError.notNull('field.id');
}
var $crdtDataForeignKey = crdtDataForeignKey.copyWith(fieldId: field.id);
await session.db.updateRow<CrdtDataForeignKey>(
$crdtDataForeignKey,
columns: [CrdtDataForeignKey.t.fieldId],
transaction: transaction,
);
}
}

View file

@ -0,0 +1,52 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_client/serverpod_client.dart' as _i1;
/// Why a foreign key projection override is active.
enum CrdtForeignKeyOverrideReason implements _i1.SerializableModel {
/// The attempted parent target is hidden or missing and the FK projection
/// set the column to null.
setNull,
/// The attempted parent target is hidden or missing and the FK projection
/// set the column to the default value.
setDefault,
/// The attempted parent target is hidden or missing and the FK projection
/// cannot repair the value (restrict, no action, cascade, or the column is
/// non-nullable), so the row is hidden by projection while the attempt is
/// preserved.
missingParent
;
static CrdtForeignKeyOverrideReason fromJson(int index) {
switch (index) {
case 0:
return CrdtForeignKeyOverrideReason.setNull;
case 1:
return CrdtForeignKeyOverrideReason.setDefault;
case 2:
return CrdtForeignKeyOverrideReason.missingParent;
default:
throw ArgumentError(
'Value "$index" cannot be converted to "CrdtForeignKeyOverrideReason"',
);
}
}
@override
int toJson() => index;
@override
String toString() => name;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,54 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_client/serverpod_client.dart' as _i1;
/// Materialized visibility state for a CRDT row.
///
/// Visible states are listed first, hidden states last. A row is visible when
/// its serialized index is less than or equal to [foreignKeyRestrictRestore].
enum CrdtDataRowVisibility implements _i1.SerializableModel {
userInsert,
userReinsert,
foreignKeyRestrictRestore,
userDelete,
userCascadeDelete,
foreignKeyCascade
;
static CrdtDataRowVisibility fromJson(int index) {
switch (index) {
case 0:
return CrdtDataRowVisibility.userInsert;
case 1:
return CrdtDataRowVisibility.userReinsert;
case 2:
return CrdtDataRowVisibility.foreignKeyRestrictRestore;
case 3:
return CrdtDataRowVisibility.userDelete;
case 4:
return CrdtDataRowVisibility.userCascadeDelete;
case 5:
return CrdtDataRowVisibility.foreignKeyCascade;
default:
throw ArgumentError(
'Value "$index" cannot be converted to "CrdtDataRowVisibility"',
);
}
}
@override
int toJson() => index;
@override
String toString() => name;
}

View file

@ -0,0 +1,61 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: no_leading_underscores_for_library_prefixes
import '../protocol.dart' as _i1;
import 'package:serverpod_client/serverpod_client.dart' as _i2;
import '../data/deleted_reason.dart' as _i3;
import 'package:serverpod_offline_sync_client/src/protocol/protocol.dart'
as _i4;
import 'package:serverpod_offline_sync_shared/serverpod_offline_sync_shared.dart'
as _i5;
part 'delete.dart';
part 'insert.dart';
part 'update.dart';
/// A remote CRDT change to merge.
sealed class CrdtMergeChange extends _i5.BaseHlc
implements _i2.SerializableModel {
CrdtMergeChange({
required super.hlcDatetime,
required super.hlcCounter,
required this.uuidScopeId,
required this.tableName,
required this.uuidRowId,
required this.uuidNodeId,
});
/// The scope this change belongs to.
_i2.UuidValue uuidScopeId;
/// The table receiving the change.
String tableName;
/// The domain row identifier receiving the change.
_i2.UuidValue uuidRowId;
/// The remote node that produced the change.
_i2.UuidValue uuidNodeId;
/// Returns a shallow copy of this [CrdtMergeChange]
/// with some or all fields replaced by the given arguments.
@_i2.useResult
CrdtMergeChange copyWith({
DateTime? hlcDatetime,
int? hlcCounter,
_i2.UuidValue? uuidScopeId,
String? tableName,
_i2.UuidValue? uuidRowId,
_i2.UuidValue? uuidNodeId,
});
}
class _Undefined {}

View file

@ -0,0 +1,149 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member
part of 'change.dart';
/// A remote visibility CLFlag update to merge.
abstract class CrdtMergeDelete extends _i1.CrdtMergeChange
implements _i2.SerializableModel {
CrdtMergeDelete._({
required super.hlcDatetime,
required super.hlcCounter,
required super.uuidScopeId,
required super.tableName,
required super.uuidRowId,
required super.uuidNodeId,
required this.clFlag,
required this.reason,
});
factory CrdtMergeDelete({
required DateTime hlcDatetime,
required int hlcCounter,
required _i2.UuidValue uuidScopeId,
required String tableName,
required _i2.UuidValue uuidRowId,
required _i2.UuidValue uuidNodeId,
required int clFlag,
required _i3.CrdtDataDeletedReason reason,
}) = _CrdtMergeDeleteImpl;
factory CrdtMergeDelete.fromJson(Map<String, dynamic> jsonSerialization) {
return CrdtMergeDelete(
hlcDatetime: _i2.DateTimeJsonExtension.fromJson(
jsonSerialization['hlcDatetime'],
),
hlcCounter: jsonSerialization['hlcCounter'] as int,
uuidScopeId: _i2.UuidValueJsonExtension.fromJson(
jsonSerialization['uuidScopeId'],
),
tableName: jsonSerialization['tableName'] as String,
uuidRowId: _i2.UuidValueJsonExtension.fromJson(
jsonSerialization['uuidRowId'],
),
uuidNodeId: _i2.UuidValueJsonExtension.fromJson(
jsonSerialization['uuidNodeId'],
),
clFlag: jsonSerialization['clFlag'] as int,
reason: _i3.CrdtDataDeletedReason.fromJson(
(jsonSerialization['reason'] as int),
),
);
}
/// Monotone causal-length flag. Odd values are visible and even values are deleted.
int clFlag;
/// Why the row entered its current visibility generation.
_i3.CrdtDataDeletedReason reason;
/// Returns a shallow copy of this [CrdtMergeDelete]
/// with some or all fields replaced by the given arguments.
@override
@_i2.useResult
CrdtMergeDelete copyWith({
DateTime? hlcDatetime,
int? hlcCounter,
_i2.UuidValue? uuidScopeId,
String? tableName,
_i2.UuidValue? uuidRowId,
_i2.UuidValue? uuidNodeId,
int? clFlag,
_i3.CrdtDataDeletedReason? reason,
});
@override
Map<String, dynamic> toJson() {
return {
'__className__': 'serverpod_offline_sync.CrdtMergeDelete',
'hlcDatetime': hlcDatetime.toJson(),
'hlcCounter': hlcCounter,
'uuidScopeId': uuidScopeId.toJson(),
'tableName': tableName,
'uuidRowId': uuidRowId.toJson(),
'uuidNodeId': uuidNodeId.toJson(),
'clFlag': clFlag,
'reason': reason.toJson(),
};
}
@override
String toString() {
return _i2.SerializationManager.encode(this);
}
}
class _CrdtMergeDeleteImpl extends CrdtMergeDelete {
_CrdtMergeDeleteImpl({
required DateTime hlcDatetime,
required int hlcCounter,
required _i2.UuidValue uuidScopeId,
required String tableName,
required _i2.UuidValue uuidRowId,
required _i2.UuidValue uuidNodeId,
required int clFlag,
required _i3.CrdtDataDeletedReason reason,
}) : super._(
hlcDatetime: hlcDatetime,
hlcCounter: hlcCounter,
uuidScopeId: uuidScopeId,
tableName: tableName,
uuidRowId: uuidRowId,
uuidNodeId: uuidNodeId,
clFlag: clFlag,
reason: reason,
);
/// Returns a shallow copy of this [CrdtMergeDelete]
/// with some or all fields replaced by the given arguments.
@_i2.useResult
@override
CrdtMergeDelete copyWith({
DateTime? hlcDatetime,
int? hlcCounter,
_i2.UuidValue? uuidScopeId,
String? tableName,
_i2.UuidValue? uuidRowId,
_i2.UuidValue? uuidNodeId,
int? clFlag,
_i3.CrdtDataDeletedReason? reason,
}) {
return CrdtMergeDelete(
hlcDatetime: hlcDatetime ?? this.hlcDatetime,
hlcCounter: hlcCounter ?? this.hlcCounter,
uuidScopeId: uuidScopeId ?? this.uuidScopeId,
tableName: tableName ?? this.tableName,
uuidRowId: uuidRowId ?? this.uuidRowId,
uuidNodeId: uuidNodeId ?? this.uuidNodeId,
clFlag: clFlag ?? this.clFlag,
reason: reason ?? this.reason,
);
}
}

View file

@ -0,0 +1,137 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member
part of 'change.dart';
/// A remote row insertion to merge.
abstract class CrdtMergeInsert extends _i1.CrdtMergeChange
implements _i2.SerializableModel {
CrdtMergeInsert._({
required super.hlcDatetime,
required super.hlcCounter,
required super.uuidScopeId,
required super.tableName,
required super.uuidRowId,
required super.uuidNodeId,
required this.data,
});
factory CrdtMergeInsert({
required DateTime hlcDatetime,
required int hlcCounter,
required _i2.UuidValue uuidScopeId,
required String tableName,
required _i2.UuidValue uuidRowId,
required _i2.UuidValue uuidNodeId,
required dynamic data,
}) = _CrdtMergeInsertImpl;
factory CrdtMergeInsert.fromJson(Map<String, dynamic> jsonSerialization) {
return CrdtMergeInsert(
hlcDatetime: _i2.DateTimeJsonExtension.fromJson(
jsonSerialization['hlcDatetime'],
),
hlcCounter: jsonSerialization['hlcCounter'] as int,
uuidScopeId: _i2.UuidValueJsonExtension.fromJson(
jsonSerialization['uuidScopeId'],
),
tableName: jsonSerialization['tableName'] as String,
uuidRowId: _i2.UuidValueJsonExtension.fromJson(
jsonSerialization['uuidRowId'],
),
uuidNodeId: _i2.UuidValueJsonExtension.fromJson(
jsonSerialization['uuidNodeId'],
),
data: _i4.Protocol().deserializeDynamicFieldValue(
jsonSerialization['data'],
),
);
}
/// The serialized domain row payload for the insert.
dynamic data;
/// Returns a shallow copy of this [CrdtMergeInsert]
/// with some or all fields replaced by the given arguments.
@override
@_i2.useResult
CrdtMergeInsert copyWith({
DateTime? hlcDatetime,
int? hlcCounter,
_i2.UuidValue? uuidScopeId,
String? tableName,
_i2.UuidValue? uuidRowId,
_i2.UuidValue? uuidNodeId,
dynamic data,
});
@override
Map<String, dynamic> toJson() {
return {
'__className__': 'serverpod_offline_sync.CrdtMergeInsert',
'hlcDatetime': hlcDatetime.toJson(),
'hlcCounter': hlcCounter,
'uuidScopeId': uuidScopeId.toJson(),
'tableName': tableName,
'uuidRowId': uuidRowId.toJson(),
'uuidNodeId': uuidNodeId.toJson(),
'data': _i4.Protocol().dynamicFieldToJson(data),
};
}
@override
String toString() {
return _i2.SerializationManager.encode(this);
}
}
class _CrdtMergeInsertImpl extends CrdtMergeInsert {
_CrdtMergeInsertImpl({
required DateTime hlcDatetime,
required int hlcCounter,
required _i2.UuidValue uuidScopeId,
required String tableName,
required _i2.UuidValue uuidRowId,
required _i2.UuidValue uuidNodeId,
required dynamic data,
}) : super._(
hlcDatetime: hlcDatetime,
hlcCounter: hlcCounter,
uuidScopeId: uuidScopeId,
tableName: tableName,
uuidRowId: uuidRowId,
uuidNodeId: uuidNodeId,
data: data,
);
/// Returns a shallow copy of this [CrdtMergeInsert]
/// with some or all fields replaced by the given arguments.
@_i2.useResult
@override
CrdtMergeInsert copyWith({
DateTime? hlcDatetime,
int? hlcCounter,
_i2.UuidValue? uuidScopeId,
String? tableName,
_i2.UuidValue? uuidRowId,
_i2.UuidValue? uuidNodeId,
Object? data = _Undefined,
}) {
return CrdtMergeInsert(
hlcDatetime: hlcDatetime ?? this.hlcDatetime,
hlcCounter: hlcCounter ?? this.hlcCounter,
uuidScopeId: uuidScopeId ?? this.uuidScopeId,
tableName: tableName ?? this.tableName,
uuidRowId: uuidRowId ?? this.uuidRowId,
uuidNodeId: uuidNodeId ?? this.uuidNodeId,
data: data != _Undefined ? data : this.data,
);
}
}

View file

@ -0,0 +1,149 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member
part of 'change.dart';
/// A remote field update to merge.
abstract class CrdtMergeUpdate extends _i1.CrdtMergeChange
implements _i2.SerializableModel {
CrdtMergeUpdate._({
required super.hlcDatetime,
required super.hlcCounter,
required super.uuidScopeId,
required super.tableName,
required super.uuidRowId,
required super.uuidNodeId,
required this.columnName,
required this.value,
});
factory CrdtMergeUpdate({
required DateTime hlcDatetime,
required int hlcCounter,
required _i2.UuidValue uuidScopeId,
required String tableName,
required _i2.UuidValue uuidRowId,
required _i2.UuidValue uuidNodeId,
required String columnName,
required dynamic value,
}) = _CrdtMergeUpdateImpl;
factory CrdtMergeUpdate.fromJson(Map<String, dynamic> jsonSerialization) {
return CrdtMergeUpdate(
hlcDatetime: _i2.DateTimeJsonExtension.fromJson(
jsonSerialization['hlcDatetime'],
),
hlcCounter: jsonSerialization['hlcCounter'] as int,
uuidScopeId: _i2.UuidValueJsonExtension.fromJson(
jsonSerialization['uuidScopeId'],
),
tableName: jsonSerialization['tableName'] as String,
uuidRowId: _i2.UuidValueJsonExtension.fromJson(
jsonSerialization['uuidRowId'],
),
uuidNodeId: _i2.UuidValueJsonExtension.fromJson(
jsonSerialization['uuidNodeId'],
),
columnName: jsonSerialization['columnName'] as String,
value: _i4.Protocol().deserializeDynamicFieldValue(
jsonSerialization['value'],
),
);
}
/// The updated database column name.
String columnName;
/// The serialized new value for the column.
dynamic value;
/// Returns a shallow copy of this [CrdtMergeUpdate]
/// with some or all fields replaced by the given arguments.
@override
@_i2.useResult
CrdtMergeUpdate copyWith({
DateTime? hlcDatetime,
int? hlcCounter,
_i2.UuidValue? uuidScopeId,
String? tableName,
_i2.UuidValue? uuidRowId,
_i2.UuidValue? uuidNodeId,
String? columnName,
dynamic value,
});
@override
Map<String, dynamic> toJson() {
return {
'__className__': 'serverpod_offline_sync.CrdtMergeUpdate',
'hlcDatetime': hlcDatetime.toJson(),
'hlcCounter': hlcCounter,
'uuidScopeId': uuidScopeId.toJson(),
'tableName': tableName,
'uuidRowId': uuidRowId.toJson(),
'uuidNodeId': uuidNodeId.toJson(),
'columnName': columnName,
'value': _i4.Protocol().dynamicFieldToJson(value),
};
}
@override
String toString() {
return _i2.SerializationManager.encode(this);
}
}
class _CrdtMergeUpdateImpl extends CrdtMergeUpdate {
_CrdtMergeUpdateImpl({
required DateTime hlcDatetime,
required int hlcCounter,
required _i2.UuidValue uuidScopeId,
required String tableName,
required _i2.UuidValue uuidRowId,
required _i2.UuidValue uuidNodeId,
required String columnName,
required dynamic value,
}) : super._(
hlcDatetime: hlcDatetime,
hlcCounter: hlcCounter,
uuidScopeId: uuidScopeId,
tableName: tableName,
uuidRowId: uuidRowId,
uuidNodeId: uuidNodeId,
columnName: columnName,
value: value,
);
/// Returns a shallow copy of this [CrdtMergeUpdate]
/// with some or all fields replaced by the given arguments.
@_i2.useResult
@override
CrdtMergeUpdate copyWith({
DateTime? hlcDatetime,
int? hlcCounter,
_i2.UuidValue? uuidScopeId,
String? tableName,
_i2.UuidValue? uuidRowId,
_i2.UuidValue? uuidNodeId,
String? columnName,
Object? value = _Undefined,
}) {
return CrdtMergeUpdate(
hlcDatetime: hlcDatetime ?? this.hlcDatetime,
hlcCounter: hlcCounter ?? this.hlcCounter,
uuidScopeId: uuidScopeId ?? this.uuidScopeId,
tableName: tableName ?? this.tableName,
uuidRowId: uuidRowId ?? this.uuidRowId,
uuidNodeId: uuidNodeId ?? this.uuidNodeId,
columnName: columnName ?? this.columnName,
value: value != _Undefined ? value : this.value,
);
}
}

View file

@ -0,0 +1,634 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_database/serverpod_database.dart' as _i1;
import 'package:serverpod_client/serverpod_client.dart' as _i2;
import 'package:serverpod_offline_sync_shared/serverpod_offline_sync_shared.dart'
as _i3;
/// CRDT nodes table.
///
/// This table stores stable CRDT replica identities that have been seen.
abstract class CrdtNode implements _i1.TableRow<int?> {
CrdtNode._({
this.id,
_i2.UuidValue? uuidNodeId,
this.lastHlc,
}) : uuidNodeId = uuidNodeId ?? const _i2.Uuid().v7obj();
factory CrdtNode({
int? id,
_i2.UuidValue? uuidNodeId,
_i3.Hlc? lastHlc,
}) = _CrdtNodeImpl;
factory CrdtNode.fromJson(Map<String, dynamic> jsonSerialization) {
return CrdtNode(
id: jsonSerialization['id'] as int?,
uuidNodeId: jsonSerialization['uuidNodeId'] == null
? null
: _i2.UuidValueJsonExtension.fromJson(
jsonSerialization['uuidNodeId'],
),
lastHlc: jsonSerialization['lastHlc'] == null
? null
: _i3.Hlc.fromJson(jsonSerialization['lastHlc']),
);
}
static final t = CrdtNodeTable();
static const db = CrdtNodeRepository._();
@override
int? id;
/// Stable unique identifier for the replica/database install.
_i2.UuidValue uuidNodeId;
/// Last HLC generated by the local replica when this row is the current node.
_i3.Hlc? lastHlc;
@override
_i1.Table<int?> get table => t;
/// Returns a shallow copy of this [CrdtNode]
/// with some or all fields replaced by the given arguments.
@_i2.useResult
CrdtNode copyWith({
int? id,
_i2.UuidValue? uuidNodeId,
_i3.Hlc? lastHlc,
});
@override
Map<String, dynamic> toJson() {
return {
'__className__': 'serverpod_offline_sync.CrdtNode',
if (id != null) 'id': id,
'uuidNodeId': uuidNodeId.toJson(),
if (lastHlc != null) 'lastHlc': lastHlc?.toJson(),
};
}
static CrdtNodeInclude include() {
return CrdtNodeInclude._();
}
static CrdtNodeIncludeList includeList({
_i1.WhereExpressionBuilder<CrdtNodeTable>? where,
int? limit,
int? offset,
_i1.OrderByBuilder<CrdtNodeTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtNodeTable>? orderByList,
CrdtNodeInclude? include,
}) {
return CrdtNodeIncludeList._(
where: where,
limit: limit,
offset: offset,
orderBy: orderBy?.call(CrdtNode.t),
orderDescending: // ignore: deprecated_member_use_from_same_package
orderDescending,
orderByList: orderByList?.call(CrdtNode.t),
include: include,
);
}
@override
String toString() {
return _i2.SerializationManager.encode(this);
}
}
class _Undefined {}
class _CrdtNodeImpl extends CrdtNode {
_CrdtNodeImpl({
int? id,
_i2.UuidValue? uuidNodeId,
_i3.Hlc? lastHlc,
}) : super._(
id: id,
uuidNodeId: uuidNodeId,
lastHlc: lastHlc,
);
/// Returns a shallow copy of this [CrdtNode]
/// with some or all fields replaced by the given arguments.
@_i2.useResult
@override
CrdtNode copyWith({
Object? id = _Undefined,
_i2.UuidValue? uuidNodeId,
Object? lastHlc = _Undefined,
}) {
return CrdtNode(
id: id is int? ? id : this.id,
uuidNodeId: uuidNodeId ?? this.uuidNodeId,
lastHlc: lastHlc is _i3.Hlc? ? lastHlc : this.lastHlc?.copyWith(),
);
}
}
class CrdtNodeUpdateTable extends _i1.UpdateTable<CrdtNodeTable> {
CrdtNodeUpdateTable(super.table);
_i1.ColumnValue<_i2.UuidValue, _i2.UuidValue> uuidNodeId(
_i2.UuidValue value,
) => _i1.ColumnValue(
table.uuidNodeId,
value,
);
_i1.ColumnValue<_i3.Hlc, _i3.Hlc> lastHlc(_i3.Hlc? value) => _i1.ColumnValue(
table.lastHlc,
value,
);
}
class CrdtNodeTable extends _i1.Table<int?> {
CrdtNodeTable({super.tableRelation}) : super(tableName: 'crdt_nodes') {
updateTable = CrdtNodeUpdateTable(this);
uuidNodeId = _i1.ColumnUuid(
'uuidNodeId',
this,
hasDefault: true,
);
lastHlc = _i1.ColumnStructured<_i3.Hlc>(
'lastHlc',
this,
);
}
late final CrdtNodeUpdateTable updateTable;
/// Stable unique identifier for the replica/database install.
late final _i1.ColumnUuid uuidNodeId;
/// Last HLC generated by the local replica when this row is the current node.
late final _i1.ColumnStructured<_i3.Hlc> lastHlc;
@override
List<_i1.Column> get columns => [
id,
uuidNodeId,
lastHlc,
];
}
class CrdtNodeInclude extends _i1.IncludeObject {
CrdtNodeInclude._();
@override
Map<String, _i1.Include?> get includes => {};
@override
_i1.Table<int?> get table => CrdtNode.t;
}
class CrdtNodeIncludeList extends _i1.IncludeList {
CrdtNodeIncludeList._({
_i1.WhereExpressionBuilder<CrdtNodeTable>? where,
super.limit,
super.offset,
super.orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
super.orderDescending,
super.orderByList,
super.include,
}) {
super.where = where?.call(CrdtNode.t);
}
@override
Map<String, _i1.Include?> get includes => include?.includes ?? {};
@override
_i1.Table<int?> get table => CrdtNode.t;
}
class CrdtNodeRepository {
const CrdtNodeRepository._();
/// Returns a list of [CrdtNode]s matching the given query parameters.
///
/// Use [where] to specify which items to include in the return value.
/// If none is specified, all items will be returned.
///
/// To specify the order of the items use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// The maximum number of items can be set by [limit]. If no limit is set,
/// all items matching the query will be returned.
///
/// [offset] defines how many items to skip, after which [limit] (or all)
/// items are read from the database.
///
/// ```dart
/// var persons = await Persons.db.find(
/// session,
/// where: (t) => t.lastName.equals('Jones'),
/// orderBy: (t) => t.firstName,
/// limit: 100,
/// );
/// ```
Future<List<CrdtNode>> find(
_i1.DatabaseSession session, {
_i1.WhereExpressionBuilder<CrdtNodeTable>? where,
int? limit,
int? offset,
_i1.OrderByBuilder<CrdtNodeTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtNodeTable>? orderByList,
_i1.Transaction? transaction,
_i1.LockMode? lockMode,
_i1.LockBehavior? lockBehavior,
}) async {
return session.db.find<CrdtNode>(
where: where?.call(CrdtNode.t),
orderBy: orderBy?.call(CrdtNode.t),
orderByList: orderByList?.call(CrdtNode.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
limit: limit,
offset: offset,
transaction: transaction,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Returns the first matching [CrdtNode] matching the given query parameters.
///
/// Use [where] to specify which items to include in the return value.
/// If none is specified, all items will be returned.
///
/// To specify the order use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// [offset] defines how many items to skip, after which the next one will be picked.
///
/// ```dart
/// var youngestPerson = await Persons.db.findFirstRow(
/// session,
/// where: (t) => t.lastName.equals('Jones'),
/// orderBy: (t) => t.age,
/// );
/// ```
Future<CrdtNode?> findFirstRow(
_i1.DatabaseSession session, {
_i1.WhereExpressionBuilder<CrdtNodeTable>? where,
int? offset,
_i1.OrderByBuilder<CrdtNodeTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtNodeTable>? orderByList,
_i1.Transaction? transaction,
_i1.LockMode? lockMode,
_i1.LockBehavior? lockBehavior,
}) async {
return session.db.findFirstRow<CrdtNode>(
where: where?.call(CrdtNode.t),
orderBy: orderBy?.call(CrdtNode.t),
orderByList: orderByList?.call(CrdtNode.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
offset: offset,
transaction: transaction,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Finds a single [CrdtNode] by its [id] or null if no such row exists.
Future<CrdtNode?> findById(
_i1.DatabaseSession session,
int id, {
_i1.Transaction? transaction,
_i1.LockMode? lockMode,
_i1.LockBehavior? lockBehavior,
}) async {
return session.db.findById<CrdtNode>(
id,
transaction: transaction,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Inserts all [CrdtNode]s in the list and returns the inserted rows.
///
/// The returned [CrdtNode]s will have their `id` fields set.
///
/// This is an atomic operation, meaning that if one of the rows fails to
/// insert, none of the rows will be inserted.
///
/// If [ignoreConflicts] is set to `true`, rows that conflict with existing
/// rows are silently skipped, and only the successfully inserted rows are
/// returned.
///
/// If [noReturn] is set to `true`, the inserted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtNode>> insert(
_i1.DatabaseSession session,
List<CrdtNode> rows, {
_i1.Transaction? transaction,
bool ignoreConflicts = false,
bool noReturn = false,
}) async {
return session.db.insert<CrdtNode>(
rows,
transaction: transaction,
ignoreConflicts: ignoreConflicts,
noReturn: noReturn,
);
}
/// Inserts a single [CrdtNode] and returns the inserted row.
///
/// The returned [CrdtNode] will have its `id` field set.
Future<CrdtNode> insertRow(
_i1.DatabaseSession session,
CrdtNode row, {
_i1.Transaction? transaction,
}) async {
return session.db.insertRow<CrdtNode>(
row,
transaction: transaction,
);
}
/// Upserts all [CrdtNode]s in the list and returns the resulting rows.
///
/// If a row conflicts on the given [conflictColumns], the existing row is
/// updated with the new values. Otherwise, a new row is inserted.
///
/// If [updateColumns] is provided, only those columns will be updated on
/// conflict. If null, all non-conflict, non-id columns are updated.
///
/// If [updateWhere] is provided, the update only applies to rows matching the
/// given expression. Conflicting rows that don't match are skipped and not
/// returned, so the resulting list may be shorter than [rows].
///
/// The returned [CrdtNode]s will have their `id` fields set.
///
/// This is an atomic operation, meaning that if one of the rows fails,
/// none of the rows will be affected.
///
/// If [noReturn] is set to `true`, the resulting rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtNode>> upsert(
_i1.DatabaseSession session,
List<CrdtNode> rows, {
required _i1.ColumnSelections<CrdtNodeTable> conflictColumns,
_i1.ColumnSelections<CrdtNodeTable>? updateColumns,
_i1.WhereExpressionBuilder<CrdtNodeTable>? updateWhere,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.upsert<CrdtNode>(
rows,
conflictColumns: conflictColumns(CrdtNode.t),
updateColumns: updateColumns?.call(CrdtNode.t),
updateWhere: updateWhere?.call(CrdtNode.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Upserts a single [CrdtNode] and returns the resulting row.
///
/// If the row conflicts on the given [conflictColumns], the existing row is
/// updated. Otherwise, a new row is inserted.
///
/// If [updateColumns] is provided, only those columns will be updated on
/// conflict. If null, all non-conflict, non-id columns are updated.
///
/// If [updateWhere] is provided, the update only applies when the existing
/// row matches the expression. Returns `null` if no row was affected — for
/// example when [updateWhere] does not match the conflicting row.
///
/// The returned [CrdtNode] will have its `id` field set.
Future<CrdtNode?> upsertRow(
_i1.DatabaseSession session,
CrdtNode row, {
required _i1.ColumnSelections<CrdtNodeTable> conflictColumns,
_i1.ColumnSelections<CrdtNodeTable>? updateColumns,
_i1.WhereExpressionBuilder<CrdtNodeTable>? updateWhere,
_i1.Transaction? transaction,
}) async {
return session.db.upsertRow<CrdtNode>(
row,
conflictColumns: conflictColumns(CrdtNode.t),
updateColumns: updateColumns?.call(CrdtNode.t),
updateWhere: updateWhere?.call(CrdtNode.t),
transaction: transaction,
);
}
/// Updates all [CrdtNode]s in the list and returns the updated rows. If
/// [columns] is provided, only those columns will be updated. Defaults to
/// all columns.
/// This is an atomic operation, meaning that if one of the rows fails to
/// update, none of the rows will be updated.
///
/// If [noReturn] is set to `true`, the updated rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtNode>> update(
_i1.DatabaseSession session,
List<CrdtNode> rows, {
_i1.ColumnSelections<CrdtNodeTable>? columns,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.update<CrdtNode>(
rows,
columns: columns?.call(CrdtNode.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Updates a single [CrdtNode]. The row needs to have its id set.
/// Optionally, a list of [columns] can be provided to only update those
/// columns. Defaults to all columns.
Future<CrdtNode> updateRow(
_i1.DatabaseSession session,
CrdtNode row, {
_i1.ColumnSelections<CrdtNodeTable>? columns,
_i1.Transaction? transaction,
}) async {
return session.db.updateRow<CrdtNode>(
row,
columns: columns?.call(CrdtNode.t),
transaction: transaction,
);
}
/// Updates a single [CrdtNode] by its [id] with the specified [columnValues].
/// Returns the updated row or null if no row with the given id exists.
Future<CrdtNode?> updateById(
_i1.DatabaseSession session,
int id, {
required _i1.ColumnValueListBuilder<CrdtNodeUpdateTable> columnValues,
_i1.Transaction? transaction,
}) async {
return session.db.updateById<CrdtNode>(
id,
columnValues: columnValues(CrdtNode.t.updateTable),
transaction: transaction,
);
}
/// Updates all [CrdtNode]s matching the [where] expression with the specified [columnValues].
/// Returns the list of updated rows.
///
/// If [noReturn] is set to `true`, the updated rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtNode>> updateWhere(
_i1.DatabaseSession session, {
required _i1.ColumnValueListBuilder<CrdtNodeUpdateTable> columnValues,
required _i1.WhereExpressionBuilder<CrdtNodeTable> where,
int? limit,
int? offset,
_i1.OrderByBuilder<CrdtNodeTable>? orderBy,
_i1.OrderByListBuilder<CrdtNodeTable>? orderByList,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.updateWhere<CrdtNode>(
columnValues: columnValues(CrdtNode.t.updateTable),
where: where(CrdtNode.t),
limit: limit,
offset: offset,
orderBy: orderBy?.call(CrdtNode.t),
orderByList: orderByList?.call(CrdtNode.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
transaction: transaction,
noReturn: noReturn,
);
}
/// Deletes all [CrdtNode]s in the list and returns the deleted rows.
///
/// To specify the order of the returned rows use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// This is an atomic operation, meaning that if one of the rows fail to
/// be deleted, none of the rows will be deleted.
///
/// If [noReturn] is set to `true`, the deleted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtNode>> delete(
_i1.DatabaseSession session,
List<CrdtNode> rows, {
_i1.OrderByBuilder<CrdtNodeTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtNodeTable>? orderByList,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.delete<CrdtNode>(
rows,
orderBy: orderBy?.call(CrdtNode.t),
orderByList: orderByList?.call(CrdtNode.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
transaction: transaction,
noReturn: noReturn,
);
}
/// Deletes a single [CrdtNode].
Future<CrdtNode> deleteRow(
_i1.DatabaseSession session,
CrdtNode row, {
_i1.Transaction? transaction,
}) async {
return session.db.deleteRow<CrdtNode>(
row,
transaction: transaction,
);
}
/// Deletes all rows matching the [where] expression.
///
/// To specify the order of the returned rows use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// If [noReturn] is set to `true`, the deleted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtNode>> deleteWhere(
_i1.DatabaseSession session, {
required _i1.WhereExpressionBuilder<CrdtNodeTable> where,
_i1.OrderByBuilder<CrdtNodeTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtNodeTable>? orderByList,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.deleteWhere<CrdtNode>(
where: where(CrdtNode.t),
orderBy: orderBy?.call(CrdtNode.t),
orderByList: orderByList?.call(CrdtNode.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
transaction: transaction,
noReturn: noReturn,
);
}
/// Counts the number of rows matching the [where] expression. If omitted,
/// will return the count of all rows in the table.
Future<int> count(
_i1.DatabaseSession session, {
_i1.WhereExpressionBuilder<CrdtNodeTable>? where,
int? limit,
_i1.Transaction? transaction,
}) async {
return session.db.count<CrdtNode>(
where: where?.call(CrdtNode.t),
limit: limit,
transaction: transaction,
);
}
/// Acquires row-level locks on [CrdtNode] rows matching the [where] expression.
Future<void> lockRows(
_i1.DatabaseSession session, {
required _i1.WhereExpressionBuilder<CrdtNodeTable> where,
required _i1.LockMode lockMode,
required _i1.Transaction transaction,
_i1.LockBehavior lockBehavior = _i1.LockBehavior.wait,
}) async {
return session.db.lockRows<CrdtNode>(
where: where(CrdtNode.t),
lockMode: lockMode,
lockBehavior: lockBehavior,
transaction: transaction,
);
}
}

View file

@ -0,0 +1,923 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: dead_code, unnecessary_null_comparison
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_database/serverpod_database.dart' as _i1;
import 'package:serverpod_client/serverpod_client.dart' as _i2;
import '../node/node.dart' as _i3;
import '../node/scope_node.dart' as _i4;
import 'package:serverpod_offline_sync_client/src/protocol/protocol.dart'
as _i5;
/// CRDT scopes table.
///
/// Normalized storage for scope IDs. The normalized data table references this
/// by integer id instead of storing the scope id string.
abstract class CrdtScope implements _i1.TableRow<int?> {
CrdtScope._({
this.id,
_i2.UuidValue? uuidScopeId,
this.currentNodeId,
this.currentNode,
this.nodes,
}) : uuidScopeId = uuidScopeId ?? const _i2.Uuid().v7obj();
factory CrdtScope({
int? id,
_i2.UuidValue? uuidScopeId,
int? currentNodeId,
_i3.CrdtNode? currentNode,
List<_i4.CrdtScopeNode>? nodes,
}) = _CrdtScopeImpl;
factory CrdtScope.fromJson(Map<String, dynamic> jsonSerialization) {
return CrdtScope(
id: jsonSerialization['id'] as int?,
uuidScopeId: jsonSerialization['uuidScopeId'] == null
? null
: _i2.UuidValueJsonExtension.fromJson(
jsonSerialization['uuidScopeId'],
),
currentNodeId: jsonSerialization['currentNodeId'] as int?,
currentNode: jsonSerialization['currentNode'] == null
? null
: _i5.Protocol().deserialize<_i3.CrdtNode>(
jsonSerialization['currentNode'],
),
nodes: jsonSerialization['nodes'] == null
? null
: _i5.Protocol().deserialize<List<_i4.CrdtScopeNode>>(
jsonSerialization['nodes'],
),
);
}
static final t = CrdtScopeTable();
static const db = CrdtScopeRepository._();
@override
int? id;
/// Scope identifier string.
_i2.UuidValue uuidScopeId;
int? currentNodeId;
/// The current node id of the scope.
_i3.CrdtNode? currentNode;
/// The nodes associated with the scope and their per-scope checkpoints.
List<_i4.CrdtScopeNode>? nodes;
@override
_i1.Table<int?> get table => t;
/// Returns a shallow copy of this [CrdtScope]
/// with some or all fields replaced by the given arguments.
@_i2.useResult
CrdtScope copyWith({
int? id,
_i2.UuidValue? uuidScopeId,
int? currentNodeId,
_i3.CrdtNode? currentNode,
List<_i4.CrdtScopeNode>? nodes,
});
@override
Map<String, dynamic> toJson() {
return {
'__className__': 'serverpod_offline_sync.CrdtScope',
if (id != null) 'id': id,
'uuidScopeId': uuidScopeId.toJson(),
if (currentNodeId != null) 'currentNodeId': currentNodeId,
if (currentNode != null) 'currentNode': currentNode?.toJson(),
if (nodes != null) 'nodes': nodes?.toJson(valueToJson: (v) => v.toJson()),
};
}
static CrdtScopeInclude include({
_i3.CrdtNodeInclude? currentNode,
_i4.CrdtScopeNodeIncludeList? nodes,
}) {
return CrdtScopeInclude._(
currentNode: currentNode,
nodes: nodes,
);
}
static CrdtScopeIncludeList includeList({
_i1.WhereExpressionBuilder<CrdtScopeTable>? where,
int? limit,
int? offset,
_i1.OrderByBuilder<CrdtScopeTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtScopeTable>? orderByList,
CrdtScopeInclude? include,
}) {
return CrdtScopeIncludeList._(
where: where,
limit: limit,
offset: offset,
orderBy: orderBy?.call(CrdtScope.t),
orderDescending: // ignore: deprecated_member_use_from_same_package
orderDescending,
orderByList: orderByList?.call(CrdtScope.t),
include: include,
);
}
@override
String toString() {
return _i2.SerializationManager.encode(this);
}
}
class _Undefined {}
class _CrdtScopeImpl extends CrdtScope {
_CrdtScopeImpl({
int? id,
_i2.UuidValue? uuidScopeId,
int? currentNodeId,
_i3.CrdtNode? currentNode,
List<_i4.CrdtScopeNode>? nodes,
}) : super._(
id: id,
uuidScopeId: uuidScopeId,
currentNodeId: currentNodeId,
currentNode: currentNode,
nodes: nodes,
);
/// Returns a shallow copy of this [CrdtScope]
/// with some or all fields replaced by the given arguments.
@_i2.useResult
@override
CrdtScope copyWith({
Object? id = _Undefined,
_i2.UuidValue? uuidScopeId,
Object? currentNodeId = _Undefined,
Object? currentNode = _Undefined,
Object? nodes = _Undefined,
}) {
return CrdtScope(
id: id is int? ? id : this.id,
uuidScopeId: uuidScopeId ?? this.uuidScopeId,
currentNodeId: currentNodeId is int? ? currentNodeId : this.currentNodeId,
currentNode: currentNode is _i3.CrdtNode?
? currentNode
: this.currentNode?.copyWith(),
nodes: nodes is List<_i4.CrdtScopeNode>?
? nodes
: this.nodes?.map((e0) => e0.copyWith()).toList(),
);
}
}
class CrdtScopeUpdateTable extends _i1.UpdateTable<CrdtScopeTable> {
CrdtScopeUpdateTable(super.table);
_i1.ColumnValue<_i2.UuidValue, _i2.UuidValue> uuidScopeId(
_i2.UuidValue value,
) => _i1.ColumnValue(
table.uuidScopeId,
value,
);
_i1.ColumnValue<int, int> currentNodeId(int? value) => _i1.ColumnValue(
table.currentNodeId,
value,
);
}
class CrdtScopeTable extends _i1.Table<int?> {
CrdtScopeTable({super.tableRelation}) : super(tableName: 'crdt_scopes') {
updateTable = CrdtScopeUpdateTable(this);
uuidScopeId = _i1.ColumnUuid(
'uuidScopeId',
this,
hasDefault: true,
);
currentNodeId = _i1.ColumnInt(
'currentNodeId',
this,
);
}
late final CrdtScopeUpdateTable updateTable;
/// Scope identifier string.
late final _i1.ColumnUuid uuidScopeId;
late final _i1.ColumnInt currentNodeId;
/// The current node id of the scope.
_i3.CrdtNodeTable? _currentNode;
/// The nodes associated with the scope and their per-scope checkpoints.
_i4.CrdtScopeNodeTable? ___nodes;
/// The nodes associated with the scope and their per-scope checkpoints.
_i1.ManyRelation<_i4.CrdtScopeNodeTable>? _nodes;
_i3.CrdtNodeTable get currentNode {
if (_currentNode != null) return _currentNode!;
_currentNode = _i1.createRelationTable(
relationFieldName: 'currentNode',
field: CrdtScope.t.currentNodeId,
foreignField: _i3.CrdtNode.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i3.CrdtNodeTable(tableRelation: foreignTableRelation),
);
return _currentNode!;
}
_i4.CrdtScopeNodeTable get __nodes {
if (___nodes != null) return ___nodes!;
___nodes = _i1.createRelationTable(
relationFieldName: '__nodes',
field: CrdtScope.t.id,
foreignField: _i4.CrdtScopeNode.t.scopeId,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i4.CrdtScopeNodeTable(tableRelation: foreignTableRelation),
);
return ___nodes!;
}
_i1.ManyRelation<_i4.CrdtScopeNodeTable> get nodes {
if (_nodes != null) return _nodes!;
var relationTable = _i1.createRelationTable(
relationFieldName: 'nodes',
field: CrdtScope.t.id,
foreignField: _i4.CrdtScopeNode.t.scopeId,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i4.CrdtScopeNodeTable(tableRelation: foreignTableRelation),
);
_nodes = _i1.ManyRelation<_i4.CrdtScopeNodeTable>(
tableWithRelations: relationTable,
table: _i4.CrdtScopeNodeTable(
tableRelation: relationTable.tableRelation!.lastRelation,
),
);
return _nodes!;
}
@override
List<_i1.Column> get columns => [
id,
uuidScopeId,
currentNodeId,
];
@override
_i1.Table? getRelationTable(String relationField) {
if (relationField == 'currentNode') {
return currentNode;
}
if (relationField == 'nodes') {
return __nodes;
}
return null;
}
}
class CrdtScopeInclude extends _i1.IncludeObject {
CrdtScopeInclude._({
_i3.CrdtNodeInclude? currentNode,
_i4.CrdtScopeNodeIncludeList? nodes,
}) {
_currentNode = currentNode;
_nodes = nodes;
}
_i3.CrdtNodeInclude? _currentNode;
_i4.CrdtScopeNodeIncludeList? _nodes;
@override
Map<String, _i1.Include?> get includes => {
'currentNode': _currentNode,
'nodes': _nodes,
};
@override
_i1.Table<int?> get table => CrdtScope.t;
}
class CrdtScopeIncludeList extends _i1.IncludeList {
CrdtScopeIncludeList._({
_i1.WhereExpressionBuilder<CrdtScopeTable>? where,
super.limit,
super.offset,
super.orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
super.orderDescending,
super.orderByList,
super.include,
}) {
super.where = where?.call(CrdtScope.t);
}
@override
Map<String, _i1.Include?> get includes => include?.includes ?? {};
@override
_i1.Table<int?> get table => CrdtScope.t;
}
class CrdtScopeRepository {
const CrdtScopeRepository._();
final attach = const CrdtScopeAttachRepository._();
final attachRow = const CrdtScopeAttachRowRepository._();
final detach = const CrdtScopeDetachRepository._();
final detachRow = const CrdtScopeDetachRowRepository._();
/// Returns a list of [CrdtScope]s matching the given query parameters.
///
/// Use [where] to specify which items to include in the return value.
/// If none is specified, all items will be returned.
///
/// To specify the order of the items use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// The maximum number of items can be set by [limit]. If no limit is set,
/// all items matching the query will be returned.
///
/// [offset] defines how many items to skip, after which [limit] (or all)
/// items are read from the database.
///
/// ```dart
/// var persons = await Persons.db.find(
/// session,
/// where: (t) => t.lastName.equals('Jones'),
/// orderBy: (t) => t.firstName,
/// limit: 100,
/// );
/// ```
Future<List<CrdtScope>> find(
_i1.DatabaseSession session, {
_i1.WhereExpressionBuilder<CrdtScopeTable>? where,
int? limit,
int? offset,
_i1.OrderByBuilder<CrdtScopeTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtScopeTable>? orderByList,
_i1.Transaction? transaction,
CrdtScopeInclude? include,
_i1.LockMode? lockMode,
_i1.LockBehavior? lockBehavior,
}) async {
return session.db.find<CrdtScope>(
where: where?.call(CrdtScope.t),
orderBy: orderBy?.call(CrdtScope.t),
orderByList: orderByList?.call(CrdtScope.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
limit: limit,
offset: offset,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Returns the first matching [CrdtScope] matching the given query parameters.
///
/// Use [where] to specify which items to include in the return value.
/// If none is specified, all items will be returned.
///
/// To specify the order use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// [offset] defines how many items to skip, after which the next one will be picked.
///
/// ```dart
/// var youngestPerson = await Persons.db.findFirstRow(
/// session,
/// where: (t) => t.lastName.equals('Jones'),
/// orderBy: (t) => t.age,
/// );
/// ```
Future<CrdtScope?> findFirstRow(
_i1.DatabaseSession session, {
_i1.WhereExpressionBuilder<CrdtScopeTable>? where,
int? offset,
_i1.OrderByBuilder<CrdtScopeTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtScopeTable>? orderByList,
_i1.Transaction? transaction,
CrdtScopeInclude? include,
_i1.LockMode? lockMode,
_i1.LockBehavior? lockBehavior,
}) async {
return session.db.findFirstRow<CrdtScope>(
where: where?.call(CrdtScope.t),
orderBy: orderBy?.call(CrdtScope.t),
orderByList: orderByList?.call(CrdtScope.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
offset: offset,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Finds a single [CrdtScope] by its [id] or null if no such row exists.
Future<CrdtScope?> findById(
_i1.DatabaseSession session,
int id, {
_i1.Transaction? transaction,
CrdtScopeInclude? include,
_i1.LockMode? lockMode,
_i1.LockBehavior? lockBehavior,
}) async {
return session.db.findById<CrdtScope>(
id,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Inserts all [CrdtScope]s in the list and returns the inserted rows.
///
/// The returned [CrdtScope]s will have their `id` fields set.
///
/// This is an atomic operation, meaning that if one of the rows fails to
/// insert, none of the rows will be inserted.
///
/// If [ignoreConflicts] is set to `true`, rows that conflict with existing
/// rows are silently skipped, and only the successfully inserted rows are
/// returned.
///
/// If [noReturn] is set to `true`, the inserted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtScope>> insert(
_i1.DatabaseSession session,
List<CrdtScope> rows, {
_i1.Transaction? transaction,
bool ignoreConflicts = false,
bool noReturn = false,
}) async {
return session.db.insert<CrdtScope>(
rows,
transaction: transaction,
ignoreConflicts: ignoreConflicts,
noReturn: noReturn,
);
}
/// Inserts a single [CrdtScope] and returns the inserted row.
///
/// The returned [CrdtScope] will have its `id` field set.
Future<CrdtScope> insertRow(
_i1.DatabaseSession session,
CrdtScope row, {
_i1.Transaction? transaction,
}) async {
return session.db.insertRow<CrdtScope>(
row,
transaction: transaction,
);
}
/// Upserts all [CrdtScope]s in the list and returns the resulting rows.
///
/// If a row conflicts on the given [conflictColumns], the existing row is
/// updated with the new values. Otherwise, a new row is inserted.
///
/// If [updateColumns] is provided, only those columns will be updated on
/// conflict. If null, all non-conflict, non-id columns are updated.
///
/// If [updateWhere] is provided, the update only applies to rows matching the
/// given expression. Conflicting rows that don't match are skipped and not
/// returned, so the resulting list may be shorter than [rows].
///
/// The returned [CrdtScope]s will have their `id` fields set.
///
/// This is an atomic operation, meaning that if one of the rows fails,
/// none of the rows will be affected.
///
/// If [noReturn] is set to `true`, the resulting rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtScope>> upsert(
_i1.DatabaseSession session,
List<CrdtScope> rows, {
required _i1.ColumnSelections<CrdtScopeTable> conflictColumns,
_i1.ColumnSelections<CrdtScopeTable>? updateColumns,
_i1.WhereExpressionBuilder<CrdtScopeTable>? updateWhere,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.upsert<CrdtScope>(
rows,
conflictColumns: conflictColumns(CrdtScope.t),
updateColumns: updateColumns?.call(CrdtScope.t),
updateWhere: updateWhere?.call(CrdtScope.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Upserts a single [CrdtScope] and returns the resulting row.
///
/// If the row conflicts on the given [conflictColumns], the existing row is
/// updated. Otherwise, a new row is inserted.
///
/// If [updateColumns] is provided, only those columns will be updated on
/// conflict. If null, all non-conflict, non-id columns are updated.
///
/// If [updateWhere] is provided, the update only applies when the existing
/// row matches the expression. Returns `null` if no row was affected — for
/// example when [updateWhere] does not match the conflicting row.
///
/// The returned [CrdtScope] will have its `id` field set.
Future<CrdtScope?> upsertRow(
_i1.DatabaseSession session,
CrdtScope row, {
required _i1.ColumnSelections<CrdtScopeTable> conflictColumns,
_i1.ColumnSelections<CrdtScopeTable>? updateColumns,
_i1.WhereExpressionBuilder<CrdtScopeTable>? updateWhere,
_i1.Transaction? transaction,
}) async {
return session.db.upsertRow<CrdtScope>(
row,
conflictColumns: conflictColumns(CrdtScope.t),
updateColumns: updateColumns?.call(CrdtScope.t),
updateWhere: updateWhere?.call(CrdtScope.t),
transaction: transaction,
);
}
/// Updates all [CrdtScope]s in the list and returns the updated rows. If
/// [columns] is provided, only those columns will be updated. Defaults to
/// all columns.
/// This is an atomic operation, meaning that if one of the rows fails to
/// update, none of the rows will be updated.
///
/// If [noReturn] is set to `true`, the updated rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtScope>> update(
_i1.DatabaseSession session,
List<CrdtScope> rows, {
_i1.ColumnSelections<CrdtScopeTable>? columns,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.update<CrdtScope>(
rows,
columns: columns?.call(CrdtScope.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Updates a single [CrdtScope]. The row needs to have its id set.
/// Optionally, a list of [columns] can be provided to only update those
/// columns. Defaults to all columns.
Future<CrdtScope> updateRow(
_i1.DatabaseSession session,
CrdtScope row, {
_i1.ColumnSelections<CrdtScopeTable>? columns,
_i1.Transaction? transaction,
}) async {
return session.db.updateRow<CrdtScope>(
row,
columns: columns?.call(CrdtScope.t),
transaction: transaction,
);
}
/// Updates a single [CrdtScope] by its [id] with the specified [columnValues].
/// Returns the updated row or null if no row with the given id exists.
Future<CrdtScope?> updateById(
_i1.DatabaseSession session,
int id, {
required _i1.ColumnValueListBuilder<CrdtScopeUpdateTable> columnValues,
_i1.Transaction? transaction,
}) async {
return session.db.updateById<CrdtScope>(
id,
columnValues: columnValues(CrdtScope.t.updateTable),
transaction: transaction,
);
}
/// Updates all [CrdtScope]s matching the [where] expression with the specified [columnValues].
/// Returns the list of updated rows.
///
/// If [noReturn] is set to `true`, the updated rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtScope>> updateWhere(
_i1.DatabaseSession session, {
required _i1.ColumnValueListBuilder<CrdtScopeUpdateTable> columnValues,
required _i1.WhereExpressionBuilder<CrdtScopeTable> where,
int? limit,
int? offset,
_i1.OrderByBuilder<CrdtScopeTable>? orderBy,
_i1.OrderByListBuilder<CrdtScopeTable>? orderByList,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.updateWhere<CrdtScope>(
columnValues: columnValues(CrdtScope.t.updateTable),
where: where(CrdtScope.t),
limit: limit,
offset: offset,
orderBy: orderBy?.call(CrdtScope.t),
orderByList: orderByList?.call(CrdtScope.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
transaction: transaction,
noReturn: noReturn,
);
}
/// Deletes all [CrdtScope]s in the list and returns the deleted rows.
///
/// To specify the order of the returned rows use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// This is an atomic operation, meaning that if one of the rows fail to
/// be deleted, none of the rows will be deleted.
///
/// If [noReturn] is set to `true`, the deleted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtScope>> delete(
_i1.DatabaseSession session,
List<CrdtScope> rows, {
_i1.OrderByBuilder<CrdtScopeTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtScopeTable>? orderByList,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.delete<CrdtScope>(
rows,
orderBy: orderBy?.call(CrdtScope.t),
orderByList: orderByList?.call(CrdtScope.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
transaction: transaction,
noReturn: noReturn,
);
}
/// Deletes a single [CrdtScope].
Future<CrdtScope> deleteRow(
_i1.DatabaseSession session,
CrdtScope row, {
_i1.Transaction? transaction,
}) async {
return session.db.deleteRow<CrdtScope>(
row,
transaction: transaction,
);
}
/// Deletes all rows matching the [where] expression.
///
/// To specify the order of the returned rows use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// If [noReturn] is set to `true`, the deleted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtScope>> deleteWhere(
_i1.DatabaseSession session, {
required _i1.WhereExpressionBuilder<CrdtScopeTable> where,
_i1.OrderByBuilder<CrdtScopeTable>? orderBy,
@Deprecated('Use desc() on the orderBy column instead.')
bool orderDescending = false,
_i1.OrderByListBuilder<CrdtScopeTable>? orderByList,
_i1.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.deleteWhere<CrdtScope>(
where: where(CrdtScope.t),
orderBy: orderBy?.call(CrdtScope.t),
orderByList: orderByList?.call(CrdtScope.t),
orderDescending: // ignore: deprecated_member_use
orderDescending,
transaction: transaction,
noReturn: noReturn,
);
}
/// Counts the number of rows matching the [where] expression. If omitted,
/// will return the count of all rows in the table.
Future<int> count(
_i1.DatabaseSession session, {
_i1.WhereExpressionBuilder<CrdtScopeTable>? where,
int? limit,
_i1.Transaction? transaction,
}) async {
return session.db.count<CrdtScope>(
where: where?.call(CrdtScope.t),
limit: limit,
transaction: transaction,
);
}
/// Acquires row-level locks on [CrdtScope] rows matching the [where] expression.
Future<void> lockRows(
_i1.DatabaseSession session, {
required _i1.WhereExpressionBuilder<CrdtScopeTable> where,
required _i1.LockMode lockMode,
required _i1.Transaction transaction,
_i1.LockBehavior lockBehavior = _i1.LockBehavior.wait,
}) async {
return session.db.lockRows<CrdtScope>(
where: where(CrdtScope.t),
lockMode: lockMode,
lockBehavior: lockBehavior,
transaction: transaction,
);
}
}
class CrdtScopeAttachRepository {
const CrdtScopeAttachRepository._();
/// Creates a relation between this [CrdtScope] and the given [CrdtScopeNode]s
/// by setting each [CrdtScopeNode]'s foreign key `scopeId` to refer to this [CrdtScope].
Future<void> nodes(
_i1.DatabaseSession session,
CrdtScope crdtScope,
List<_i4.CrdtScopeNode> crdtScopeNode, {
_i1.Transaction? transaction,
}) async {
if (crdtScopeNode.any((e) => e.id == null)) {
throw ArgumentError.notNull('crdtScopeNode.id');
}
if (crdtScope.id == null) {
throw ArgumentError.notNull('crdtScope.id');
}
var $crdtScopeNode = crdtScopeNode
.map((e) => e.copyWith(scopeId: crdtScope.id))
.toList();
await session.db.update<_i4.CrdtScopeNode>(
$crdtScopeNode,
columns: [_i4.CrdtScopeNode.t.scopeId],
transaction: transaction,
);
}
}
class CrdtScopeAttachRowRepository {
const CrdtScopeAttachRowRepository._();
/// Creates a relation between the given [CrdtScope] and [CrdtNode]
/// by setting the [CrdtScope]'s foreign key `currentNodeId` to refer to the [CrdtNode].
Future<void> currentNode(
_i1.DatabaseSession session,
CrdtScope crdtScope,
_i3.CrdtNode currentNode, {
_i1.Transaction? transaction,
}) async {
if (crdtScope.id == null) {
throw ArgumentError.notNull('crdtScope.id');
}
if (currentNode.id == null) {
throw ArgumentError.notNull('currentNode.id');
}
var $crdtScope = crdtScope.copyWith(currentNodeId: currentNode.id);
await session.db.updateRow<CrdtScope>(
$crdtScope,
columns: [CrdtScope.t.currentNodeId],
transaction: transaction,
);
}
/// Creates a relation between this [CrdtScope] and the given [CrdtScopeNode]
/// by setting the [CrdtScopeNode]'s foreign key `scopeId` to refer to this [CrdtScope].
Future<void> nodes(
_i1.DatabaseSession session,
CrdtScope crdtScope,
_i4.CrdtScopeNode crdtScopeNode, {
_i1.Transaction? transaction,
}) async {
if (crdtScopeNode.id == null) {
throw ArgumentError.notNull('crdtScopeNode.id');
}
if (crdtScope.id == null) {
throw ArgumentError.notNull('crdtScope.id');
}
var $crdtScopeNode = crdtScopeNode.copyWith(scopeId: crdtScope.id);
await session.db.updateRow<_i4.CrdtScopeNode>(
$crdtScopeNode,
columns: [_i4.CrdtScopeNode.t.scopeId],
transaction: transaction,
);
}
}
class CrdtScopeDetachRepository {
const CrdtScopeDetachRepository._();
/// Detaches the relation between this [CrdtScope] and the given [CrdtScopeNode]
/// by setting the [CrdtScopeNode]'s foreign key `scopeId` to `null`.
///
/// This removes the association between the two models without deleting
/// the related record.
Future<void> nodes(
_i1.DatabaseSession session,
List<_i4.CrdtScopeNode> crdtScopeNode, {
_i1.Transaction? transaction,
}) async {
if (crdtScopeNode.any((e) => e.id == null)) {
throw ArgumentError.notNull('crdtScopeNode.id');
}
var $crdtScopeNode = crdtScopeNode
.map((e) => e.copyWith(scopeId: null))
.toList();
await session.db.update<_i4.CrdtScopeNode>(
$crdtScopeNode,
columns: [_i4.CrdtScopeNode.t.scopeId],
transaction: transaction,
);
}
}
class CrdtScopeDetachRowRepository {
const CrdtScopeDetachRowRepository._();
/// Detaches the relation between this [CrdtScope] and the [CrdtNode] set in `currentNode`
/// by setting the [CrdtScope]'s foreign key `currentNodeId` to `null`.
///
/// This removes the association between the two models without deleting
/// the related record.
Future<void> currentNode(
_i1.DatabaseSession session,
CrdtScope crdtScope, {
_i1.Transaction? transaction,
}) async {
if (crdtScope.id == null) {
throw ArgumentError.notNull('crdtScope.id');
}
var $crdtScope = crdtScope.copyWith(currentNodeId: null);
await session.db.updateRow<CrdtScope>(
$crdtScope,
columns: [CrdtScope.t.currentNodeId],
transaction: transaction,
);
}
/// Detaches the relation between this [CrdtScope] and the given [CrdtScopeNode]
/// by setting the [CrdtScopeNode]'s foreign key `scopeId` to `null`.
///
/// This removes the association between the two models without deleting
/// the related record.
Future<void> nodes(
_i1.DatabaseSession session,
_i4.CrdtScopeNode crdtScopeNode, {
_i1.Transaction? transaction,
}) async {
if (crdtScopeNode.id == null) {
throw ArgumentError.notNull('crdtScopeNode.id');
}
var $crdtScopeNode = crdtScopeNode.copyWith(scopeId: null);
await session.db.updateRow<_i4.CrdtScopeNode>(
$crdtScopeNode,
columns: [_i4.CrdtScopeNode.t.scopeId],
transaction: transaction,
);
}
}

Some files were not shown because too many files have changed in this diff Show more