-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update page update dsl (#33)
- Loading branch information
1 parent
8808ae7
commit 62f6e2f
Showing
21 changed files
with
640 additions
and
562 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
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
273 changes: 251 additions & 22 deletions
273
zio-notion-core/src/main/scala/zio/notion/dsl/Column.scala
Large diffs are not rendered by default.
Oops, something went wrong.
21 changes: 2 additions & 19 deletions
21
zio-notion-core/src/main/scala/zio/notion/dsl/ColumnDefinition.scala
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,24 +1,7 @@ | ||
package zio.notion.dsl | ||
|
||
import zio.notion.PropertyUpdater.ColumnMatcher | ||
import zio.notion.model.database.patch.PatchPlan | ||
import zio.notion.model.database.patch.PatchPlan.PropertyType | ||
|
||
trait Definition { | ||
def patchPlan: PatchPlan | ||
def matcher: ColumnMatcher | ||
} | ||
|
||
final case class ColumnDefinition(colName: String, patchPlan: PatchPlan) extends Definition { | ||
def rename(name: String): ColumnDefinition = copy(patchPlan = patchPlan.copy(name = Some(name))) | ||
|
||
def as(propertyType: PropertyType): ColumnDefinition = copy(patchPlan = patchPlan.copy(propertyType = Some(propertyType))) | ||
|
||
override def matcher: ColumnMatcher = ColumnMatcher.One(colName) | ||
} | ||
|
||
final case class ColumnDefinitions(predicate: String => Boolean, patchPlan: PatchPlan) extends Definition { | ||
def as(propertyType: PropertyType): ColumnDefinitions = copy(patchPlan = patchPlan.copy(propertyType = Some(propertyType))) | ||
|
||
override def matcher: ColumnMatcher = ColumnMatcher.Predicate(predicate) | ||
final case class ColumnDefinition(colName: String) { | ||
def patch: PatchedColumnDefinition = PatchedColumnDefinition(colName, PatchPlan.unit) | ||
} |
7 changes: 7 additions & 0 deletions
7
zio-notion-core/src/main/scala/zio/notion/dsl/ColumnDefinitions.scala
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,7 @@ | ||
package zio.notion.dsl | ||
|
||
import zio.notion.model.database.patch.PatchPlan | ||
|
||
final case class ColumnDefinitions(predicate: String => Boolean) { | ||
def patch: PatchedColumnDefinitions = PatchedColumnDefinitions(predicate, PatchPlan.unit) | ||
} |
83 changes: 83 additions & 0 deletions
83
zio-notion-core/src/main/scala/zio/notion/dsl/Columns.scala
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,83 @@ | ||
package zio.notion.dsl | ||
|
||
import zio.notion.PropertyUpdater.ColumnMatcher.Predicate | ||
import zio.notion.dsl.Columns._ | ||
import zio.notion.dsl.PatchedColumn._ | ||
|
||
final case class Columns(predicate: String => Boolean) { | ||
def definition: ColumnDefinitions = columnDefinitionsMatching(predicate) | ||
|
||
def asNumber: NumberDSLConstructor = NumberDSLConstructor(predicate) | ||
|
||
def asTitle: TitleDSLConstructor = TitleDSLConstructor(predicate) | ||
|
||
def asRichText: RichTextDSLConstructor = RichTextDSLConstructor(predicate) | ||
|
||
def asCheckbox: CheckboxDSLConstructor = CheckboxDSLConstructor(predicate) | ||
|
||
def asSelect: SelectDSLConstructor = SelectDSLConstructor(predicate) | ||
|
||
def asMultiSelect: MultiSelectDSLConstructor = MultiSelectDSLConstructor(predicate) | ||
|
||
def asDate: DateDSLConstructor = DateDSLConstructor(predicate) | ||
|
||
def asPeople: PeopleDSLConstructor = PeopleDSLConstructor(predicate) | ||
|
||
def asFiles: FilesDSLConstructor = FilesDSLConstructor(predicate) | ||
|
||
def asUrl: UrlDSLConstructor = UrlDSLConstructor(predicate) | ||
|
||
def asEmail: EmailDSLConstructor = EmailDSLConstructor(predicate) | ||
|
||
def asPhoneNumber: PhoneNumberDSLConstructor = PhoneNumberDSLConstructor(predicate) | ||
} | ||
|
||
object Columns { | ||
final case class TitleDSLConstructor private (predicate: String => Boolean) { | ||
def patch: PatchedColumnTitle = PatchedColumnTitle(Predicate(predicate)) | ||
} | ||
|
||
final case class RichTextDSLConstructor private (predicate: String => Boolean) { | ||
def patch: PatchedColumnRichText = PatchedColumnRichText(Predicate(predicate)) | ||
} | ||
|
||
final case class NumberDSLConstructor private (predicate: String => Boolean) { | ||
def patch: PatchedColumnNumber = PatchedColumnNumber(Predicate(predicate)) | ||
} | ||
|
||
final case class CheckboxDSLConstructor private (predicate: String => Boolean) { | ||
def patch: PatchedColumnCheckbox = PatchedColumnCheckbox(Predicate(predicate)) | ||
} | ||
|
||
final case class SelectDSLConstructor private (predicate: String => Boolean) { | ||
def patch: PatchedColumnSelect = PatchedColumnSelect(Predicate(predicate)) | ||
} | ||
|
||
final case class MultiSelectDSLConstructor private (predicate: String => Boolean) { | ||
def patch: PatchedColumnMultiSelect = PatchedColumnMultiSelect(Predicate(predicate)) | ||
} | ||
|
||
final case class DateDSLConstructor private (predicate: String => Boolean) { | ||
def patch: PatchedColumnDate = PatchedColumnDate(Predicate(predicate)) | ||
} | ||
|
||
final case class PeopleDSLConstructor private (predicate: String => Boolean) { | ||
def patch: PatchedColumnPeople = PatchedColumnPeople(Predicate(predicate)) | ||
} | ||
|
||
final case class FilesDSLConstructor private (predicate: String => Boolean) { | ||
def patch: PatchedColumnFiles = PatchedColumnFiles(Predicate(predicate)) | ||
} | ||
|
||
final case class UrlDSLConstructor private (predicate: String => Boolean) { | ||
def patch: PatchedColumnUrl = PatchedColumnUrl(Predicate(predicate)) | ||
} | ||
|
||
final case class EmailDSLConstructor private (predicate: String => Boolean) { | ||
def patch: PatchedColumnEmail = PatchedColumnEmail(Predicate(predicate)) | ||
} | ||
|
||
final case class PhoneNumberDSLConstructor private (predicate: String => Boolean) { | ||
def patch: PatchedColumnPhoneNumber = PatchedColumnPhoneNumber(Predicate(predicate)) | ||
} | ||
} |
Oops, something went wrong.