-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REFACTOR: Update Naming Convention
- Loading branch information
Showing
59 changed files
with
1,915 additions
and
1,908 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#' Todos Dataset | ||
#' | ||
#' This dataset contains todos for testing the package. | ||
#' | ||
#' @format A data frame with 3 rows and 5 columns: | ||
#' \describe{ | ||
#' \item{id}{Unique identifier for the todo, stored as a UUID string.} | ||
#' \item{task}{Description of the task.} | ||
#' \item{status}{Status of the task.} | ||
#' } | ||
#' @source Generated synthetic data. | ||
"Todos" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,66 @@ | ||
Memory.Storage.Service <- \(broker) { | ||
validate <- Memory.Storage.Validator() | ||
|
||
filter.tables <- \(table) broker[['Get.Tables']]() |> subset(name == table) | ||
filter.entities <- \(entity, table) entity[['id']] |> broker[['SelectWhereId']](table) | ||
filter.tables <- \(table) broker[['get.tables']]() |> subset(name == table) | ||
filter.entities <- \(entity, table) entity[['id']] |> broker[['select.where.Id']](table) | ||
|
||
services <- list() | ||
services[['Create.Table']] <- \(model, table) { | ||
services[['create.table']] <- \(model, table) { | ||
model |> validate[['Model']]() | ||
table |> validate[['Table']]() | ||
|
||
model |> broker[['Create.Table']](table) | ||
model |> broker[['create.table']](table) | ||
} | ||
services[['Seed.Table']] <- \(data, table) { | ||
services[['seed.table']] <- \(data, table) { | ||
data |> validate[['Data']]() | ||
table |> validate[['Table']]() | ||
|
||
data |> broker[['Seed.Table']](table) | ||
data |> broker[['seed.table']](table) | ||
} | ||
services[['Execute.Query']] <- \(...) { | ||
TRUE |> validate[['Not.Implemented']]() | ||
... |> broker[['Execute.Query']]() | ||
services[['execute.query']] <- \(...) { | ||
TRUE |> validate[['not.implemented']]() | ||
... |> broker[['execute.query']]() | ||
} | ||
services[['Add']] <- \(entity, table) { | ||
services[['add']] <- \(entity, table) { | ||
entity |> validate[['Entity']]() | ||
table |> validate[['Table']]() | ||
|
||
table |> filter.tables() |> validate[['Is.Existing.Table']](table) | ||
entity |> filter.entities(table) |> validate[['Is.New.Entity']]() | ||
table |> filter.tables() |> validate[['is.existing.table']](table) | ||
entity |> filter.entities(table) |> validate[['is.new.entity']]() | ||
|
||
entity |> broker[['Insert']](table) | ||
entity |> broker[['insert']](table) | ||
} | ||
services[['Retrieve']] <- \(table, fields) { | ||
services[['retrieve']] <- \(table, fields) { | ||
table |> validate[['Table']]() | ||
|
||
table |> filter.tables() |> validate[['Is.Existing.Table']](table) | ||
table |> filter.tables() |> validate[['is.existing.table']](table) | ||
|
||
table |> broker[['Select']](fields) | ||
table |> broker[['select']](fields) | ||
} | ||
services[['RetrieveWhereId']] <- \(id, table, fields) { | ||
services[['retrieve.where.id']] <- \(id, table, fields) { | ||
id |> validate[['Id']]() | ||
table |> validate[['Table']]() | ||
|
||
table |> filter.tables() |> validate[['Is.Existing.Table']](table) | ||
table |> filter.tables() |> validate[['is.existing.table']](table) | ||
|
||
id |> broker[['SelectWhereId']](table, fields) | ||
id |> broker[['select.where.Id']](table, fields) | ||
} | ||
services[['Modify']] <- \(entity, table) { | ||
services[['modify']] <- \(entity, table) { | ||
entity |> validate[['Entity']]() | ||
table |> validate[['Table']]() | ||
|
||
table |> filter.tables() |> validate[['Is.Existing.Table']](table) | ||
entity |> filter.entities(table) |> validate[['Is.Existing.Entity']]() | ||
table |> filter.tables() |> validate[['is.existing.table']](table) | ||
entity |> filter.entities(table) |> validate[['is.existing.entity']]() | ||
|
||
entity |> broker[['Update']](table) | ||
entity |> broker[['update']](table) | ||
} | ||
services[['Remove']] <- \(id, table) { | ||
services[['remove']] <- \(id, table) { | ||
id |> validate[['Id']]() | ||
table |> validate[['Table']]() | ||
|
||
table |> filter.tables() |> validate[['Is.Existing.Table']](table) | ||
table |> filter.tables() |> validate[['is.existing.table']](table) | ||
|
||
id |> broker[['Delete']](table) | ||
id |> broker[['delete']](table) | ||
} | ||
return(services) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Memory.Storage.Validation.Exceptions <- \() { | ||
exceptions <- list() | ||
exceptions[['not.implemented']] <- \(invoke) { | ||
if(invoke) { | ||
stop('Memory.Storage: not.implemented.', call. = FALSE) | ||
} | ||
} | ||
exceptions[['key.violation']] <- \(invoke) { | ||
if(invoke) { | ||
stop('Memory.Storage: key.violation: Duplicate Primary Key not allowed.', call. = FALSE) | ||
} | ||
} | ||
exceptions[['entity.not.found']] <- \(invoke) { | ||
if(invoke) { | ||
stop('Memory.Storage: entity.not.found: Entity not found in storage.', call. = FALSE) | ||
} | ||
} | ||
exceptions[['table.invalid']] <- \(invoke, table) { | ||
if(invoke) { | ||
stop('Memory.Storage: table.invalid: ', table, ' is not a valid table.', call. = FALSE) | ||
} | ||
} | ||
return(exceptions) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
Memory.Storage.Validator <- \() { | ||
exception <- Memory.Storage.Exceptions() | ||
exception <- Memory.Storage.Validation.Exceptions() | ||
|
||
validators <- Validate::Validator() | ||
validators[['Model']] <- \(model) { | ||
model |> | ||
validators[['Is.Not.NULL']]('model') |> | ||
validators[['Is.Data.Frame']]() |> | ||
validators[['Is.Empty']]() | ||
validators[['is.not.NULL']]('model') |> | ||
validators[['is.data.frame']]() |> | ||
validators[['is.empty']]() | ||
} | ||
validators[['Table']] <- \(table) { | ||
table |> | ||
validators[['Is.Not.NULL']]('table') |> | ||
validators[['Is.Character']]() | ||
validators[['is.not.NULL']]('table') |> | ||
validators[['is.character']]() | ||
} | ||
validators[['Data']] <- \(data) { | ||
data |> | ||
validators[['Is.Not.NULL']]('data') |> | ||
validators[['Is.Data.Frame']]() |> | ||
validators[['Is.Not.Empty']]() | ||
validators[['is.not.NULL']]('data') |> | ||
validators[['is.data.frame']]() |> | ||
validators[['is.not.empty']]() | ||
} | ||
validators[['Entity']] <- \(entity) { | ||
entity |> | ||
validators[['Is.Not.NULL']]('entity') |> | ||
validators[['Is.Data.Frame']]() |> | ||
validators[['Has.One.Row']]() | ||
validators[['is.not.NULL']]('entity') |> | ||
validators[['is.data.frame']]() |> | ||
validators[['has.one.row']]() | ||
} | ||
validators[['Id']] <- \(id) { | ||
id |> | ||
validators[['Is.Not.NULL']]('id') |> | ||
validators[['Is.Character']]() |> | ||
validators[['Is.UUID']]('id') | ||
validators[['is.not.NULL']]('id') |> | ||
validators[['is.character']]() |> | ||
validators[['is.UUID']]('id') | ||
} | ||
validators[['Not.Implemented']] <- \(input) { | ||
input |> exception[['Not.Implemented']]() | ||
validators[['not.implemented']] <- \(input) { | ||
input |> exception[['not.implemented']]() | ||
} | ||
validators[['Is.New.Entity']] <- \(entity) { | ||
entity |> validators[['Is.Empty']]() |> | ||
tryCatch(error=\(...) TRUE |> exception[['Key.Violation']]()) | ||
validators[['is.new.entity']] <- \(entity) { | ||
entity |> validators[['is.empty']]() |> | ||
tryCatch(error=\(...) TRUE |> exception[['key.violation']]()) | ||
} | ||
validators[['Is.Existing.Entity']] <- \(entity) { | ||
entity |> validators[['Has.One.Row']]() |> | ||
tryCatch(error=\(...) TRUE |> exception[['Entity.Not.Found']]()) | ||
validators[['is.existing.entity']] <- \(entity) { | ||
entity |> validators[['has.one.row']]() |> | ||
tryCatch(error=\(...) TRUE |> exception[['entity.not.found']]()) | ||
} | ||
validators[['Is.Existing.Table']] <- \(table, name = NULL) { | ||
table |> validators[['Has.One.Row']]() |> | ||
tryCatch(error=\(...) TRUE |> exception[['Table.Invalid']](name)) | ||
validators[['is.existing.table']] <- \(table, name = NULL) { | ||
table |> validators[['has.one.row']]() |> | ||
tryCatch(error=\(...) TRUE |> exception[['table.invalid']](name)) | ||
} | ||
return(validators) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.