Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/SDK/Language/Android.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public function getFiles(): array
'destination' => '/library/src/main/java/{{ sdk.namespace | caseSlash }}/Query.kt',
'template' => '/android/library/src/main/java/io/package/Query.kt.twig',
],
[
'scope' => 'default',
'destination' => '/library/src/main/java/{{ sdk.namespace | caseSlash }}/Operator.kt',
'template' => '/android/library/src/main/java/io/package/Operator.kt.twig',
],
[
'scope' => 'default',
'destination' => '/library/src/main/java/{{ sdk.namespace | caseSlash }}/exceptions/{{spec.title | caseUcfirst}}Exception.kt',
Expand Down
5 changes: 5 additions & 0 deletions src/SDK/Language/Apple.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public function getFiles(): array
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Query.swift',
'template' => 'swift/Sources/Query.swift.twig',
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Operator.swift',
'template' => 'swift/Sources/Operator.swift.twig',
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Models/UploadProgress.swift',
Expand Down
10 changes: 10 additions & 0 deletions src/SDK/Language/Dart.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ public function getFiles(): array
'destination' => '/lib/query.dart',
'template' => 'dart/lib/query.dart.twig',
],
[
'scope' => 'default',
'destination' => '/lib/operator.dart',
'template' => 'dart/lib/operator.dart.twig',
],
[
'scope' => 'default',
'destination' => '/lib/{{ language.params.packageName }}.dart',
Expand Down Expand Up @@ -432,6 +437,11 @@ public function getFiles(): array
'destination' => '/test/query_test.dart',
'template' => 'dart/test/query_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/operator_test.dart',
'template' => 'dart/test/operator_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/role_test.dart',
Expand Down
10 changes: 10 additions & 0 deletions src/SDK/Language/Deno.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,21 @@ public function getFiles(): array
'destination' => 'src/query.ts',
'template' => 'deno/src/query.ts.twig',
],
[
'scope' => 'default',
'destination' => 'src/operator.ts',
'template' => 'deno/src/operator.ts.twig',
],
[
'scope' => 'default',
'destination' => 'test/query.test.ts',
'template' => 'deno/test/query.test.ts.twig',
],
[
'scope' => 'default',
'destination' => 'test/operator.test.ts',
'template' => 'deno/test/operator.test.ts.twig',
],
[
'scope' => 'default',
'destination' => 'src/inputFile.ts',
Expand Down
5 changes: 5 additions & 0 deletions src/SDK/Language/DotNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ public function getFiles(): array
'destination' => '{{ spec.title | caseUcfirst }}/Query.cs',
'template' => 'dotnet/Package/Query.cs.twig',
],
[
'scope' => 'default',
'destination' => '{{ spec.title | caseUcfirst }}/Operator.cs',
'template' => 'dotnet/Package/Operator.cs.twig',
],
[
'scope' => 'default',
'destination' => '{{ spec.title | caseUcfirst }}/Role.cs',
Expand Down
10 changes: 10 additions & 0 deletions src/SDK/Language/Flutter.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public function getFiles(): array
'destination' => '/lib/query.dart',
'template' => 'dart/lib/query.dart.twig',
],
[
'scope' => 'default',
'destination' => '/lib/operator.dart',
'template' => 'dart/lib/operator.dart.twig',
],
[
'scope' => 'definition',
'destination' => '/lib/src/models/{{definition.name | caseSnake }}.dart',
Expand Down Expand Up @@ -275,6 +280,11 @@ public function getFiles(): array
'destination' => '/test/query_test.dart',
'template' => 'dart/test/query_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/operator_test.dart',
'template' => 'dart/test/operator_test.dart.twig',
],
[
'scope' => 'default',
'destination' => '/test/role_test.dart',
Expand Down
5 changes: 5 additions & 0 deletions src/SDK/Language/Go.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ public function getFiles(): array
'destination' => 'query/query.go',
'template' => 'go/query.go.twig',
],
[
'scope' => 'default',
'destination' => 'operator/operator.go',
'template' => 'go/operator.go.twig',
],
[
'scope' => 'default',
'destination' => 'permission/permission.go',
Expand Down
5 changes: 5 additions & 0 deletions src/SDK/Language/Kotlin.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ public function getFiles(): array
'destination' => '/src/main/kotlin/{{ sdk.namespace | caseSlash }}/Query.kt',
'template' => '/kotlin/src/main/kotlin/io/appwrite/Query.kt.twig',
],
[
'scope' => 'default',
'destination' => '/src/main/kotlin/{{ sdk.namespace | caseSlash }}/Operator.kt',
'template' => '/kotlin/src/main/kotlin/io/appwrite/Operator.kt.twig',
],
[
'scope' => 'default',
'destination' => '/src/main/kotlin/{{ sdk.namespace | caseSlash }}/coroutines/Callback.kt',
Expand Down
5 changes: 5 additions & 0 deletions src/SDK/Language/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ public function getFiles(): array
'destination' => 'src/query.ts',
'template' => 'web/src/query.ts.twig',
],
[
'scope' => 'default',
'destination' => 'src/operator.ts',
'template' => 'node/src/operator.ts.twig',
],
[
'scope' => 'default',
'destination' => 'README.md',
Expand Down
10 changes: 10 additions & 0 deletions src/SDK/Language/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ public function getFiles(): array
'destination' => 'tests/{{ spec.title | caseUcfirst}}/QueryTest.php',
'template' => 'php/tests/QueryTest.php.twig',
],
[
'scope' => 'default',
'destination' => 'src/{{ spec.title | caseUcfirst}}/Operator.php',
'template' => 'php/src/Operator.php.twig',
],
[
'scope' => 'default',
'destination' => 'tests/{{ spec.title | caseUcfirst}}/OperatorTest.php',
'template' => 'php/tests/OperatorTest.php.twig',
],
[
'scope' => 'default',
'destination' => 'src/{{ spec.title | caseUcfirst}}/InputFile.php',
Expand Down
5 changes: 5 additions & 0 deletions src/SDK/Language/Python.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ public function getFiles(): array
'destination' => '{{ spec.title | caseSnake}}/query.py',
'template' => 'python/package/query.py.twig',
],
[
'scope' => 'default',
'destination' => '{{ spec.title | caseSnake}}/operator.py',
'template' => 'python/package/operator.py.twig',
],
[
'scope' => 'default',
'destination' => '{{ spec.title | caseSnake}}/exception.py',
Expand Down
5 changes: 5 additions & 0 deletions src/SDK/Language/ReactNative.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public function getFiles(): array
'destination' => 'src/query.ts',
'template' => 'react-native/src/query.ts.twig',
],
[
'scope' => 'default',
'destination' => 'src/operator.ts',
'template' => 'react-native/src/operator.ts.twig',
],
[
'scope' => 'default',
'destination' => 'README.md',
Expand Down
5 changes: 5 additions & 0 deletions src/SDK/Language/Ruby.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ public function getFiles(): array
'destination' => 'lib/{{ spec.title | caseDash }}/query.rb',
'template' => 'ruby/lib/container/query.rb.twig',
],
[
'scope' => 'default',
'destination' => 'lib/{{ spec.title | caseDash }}/operator.rb',
'template' => 'ruby/lib/container/operator.rb.twig',
],
[
'scope' => 'default',
'destination' => 'lib/{{ spec.title | caseDash }}/service.rb',
Expand Down
5 changes: 5 additions & 0 deletions src/SDK/Language/Swift.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ public function getFiles(): array
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Query.swift',
'template' => 'swift/Sources/Query.swift.twig',
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Operator.swift',
'template' => 'swift/Sources/Operator.swift.twig',
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Models/UploadProgress.swift',
Expand Down
5 changes: 5 additions & 0 deletions src/SDK/Language/Web.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public function getFiles(): array
'destination' => 'src/query.ts',
'template' => 'web/src/query.ts.twig',
],
[
'scope' => 'default',
'destination' => 'src/operator.ts',
'template' => 'web/src/operator.ts.twig',
],
[
'scope' => 'default',
'destination' => 'README.md',
Expand Down
130 changes: 130 additions & 0 deletions templates/android/library/src/main/java/io/package/Operator.kt.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package {{ sdk.namespace | caseDot }}

import {{ sdk.namespace | caseDot }}.extensions.toJson

enum class Condition(val value: String) {
EQUAL("equal"),
NOT_EQUAL("notEqual"),
GREATER_THAN("greaterThan"),
GREATER_THAN_EQUAL("greaterThanEqual"),
LESS_THAN("lessThan"),
LESS_THAN_EQUAL("lessThanEqual"),
CONTAINS("contains"),
IS_NULL("isNull"),
IS_NOT_NULL("isNotNull");

override fun toString() = value
}

class Operator(
val method: String,
val values: List<Any?>? = null,
) {
override fun toString() = this.toJson()

companion object {
fun increment(value: Number = 1, max: Number? = null): String {
require(!value.toDouble().isNaN() && !value.toDouble().isInfinite()) { "Value cannot be NaN or Infinity" }
max?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Max cannot be NaN or Infinity" } }
val values = mutableListOf<Any?>(value)
max?.let { values.add(it) }
return Operator("increment", values).toJson()
}

fun decrement(value: Number = 1, min: Number? = null): String {
require(!value.toDouble().isNaN() && !value.toDouble().isInfinite()) { "Value cannot be NaN or Infinity" }
min?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Min cannot be NaN or Infinity" } }
val values = mutableListOf<Any?>(value)
min?.let { values.add(it) }
return Operator("decrement", values).toJson()
}

fun multiply(factor: Number, max: Number? = null): String {
require(!factor.toDouble().isNaN() && !factor.toDouble().isInfinite()) { "Factor cannot be NaN or Infinity" }
max?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Max cannot be NaN or Infinity" } }
val values = mutableListOf<Any?>(factor)
max?.let { values.add(it) }
return Operator("multiply", values).toJson()
}

fun divide(divisor: Number, min: Number? = null): String {
require(!divisor.toDouble().isNaN() && !divisor.toDouble().isInfinite()) { "Divisor cannot be NaN or Infinity" }
min?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Min cannot be NaN or Infinity" } }
require(divisor.toDouble() != 0.0) { "Divisor cannot be zero" }
val values = mutableListOf<Any?>(divisor)
min?.let { values.add(it) }
return Operator("divide", values).toJson()
}

fun modulo(divisor: Number): String {
require(!divisor.toDouble().isNaN() && !divisor.toDouble().isInfinite()) { "Divisor cannot be NaN or Infinity" }
require(divisor.toDouble() != 0.0) { "Divisor cannot be zero" }
return Operator("modulo", listOf(divisor)).toJson()
}

fun power(exponent: Number, max: Number? = null): String {
require(!exponent.toDouble().isNaN() && !exponent.toDouble().isInfinite()) { "Exponent cannot be NaN or Infinity" }
max?.let { require(!it.toDouble().isNaN() && !it.toDouble().isInfinite()) { "Max cannot be NaN or Infinity" } }
val values = mutableListOf<Any?>(exponent)
max?.let { values.add(it) }
return Operator("power", values).toJson()
}

fun arrayAppend(values: List<Any?>): String {
return Operator("arrayAppend", values).toJson()
}

fun arrayPrepend(values: List<Any?>): String {
return Operator("arrayPrepend", values).toJson()
}

fun arrayInsert(index: Int, value: Any): String {
return Operator("arrayInsert", listOf(index, value)).toJson()
}

fun arrayRemove(value: Any): String {
return Operator("arrayRemove", listOf(value)).toJson()
}

fun arrayUnique(): String {
return Operator("arrayUnique", emptyList()).toJson()
}

fun arrayIntersect(values: List<Any?>): String {
return Operator("arrayIntersect", values).toJson()
}

fun arrayDiff(values: List<Any?>): String {
return Operator("arrayDiff", values).toJson()
}

fun arrayFilter(condition: Condition, value: Any? = null): String {
val values = listOf<Any?>(condition.value, value)
return Operator("arrayFilter", values).toJson()
}

fun concat(value: Any): String {
return Operator("concat", listOf(value)).toJson()
}

fun replace(search: String, replace: String): String {
return Operator("replace", listOf(search, replace)).toJson()
}

fun toggle(): String {
return Operator("toggle", emptyList()).toJson()
}

fun dateAddDays(days: Int): String {
return Operator("dateAddDays", listOf(days)).toJson()
}

fun dateSubDays(days: Int): String {
return Operator("dateSubDays", listOf(days)).toJson()
}

fun dateSetNow(): String {
return Operator("dateSetNow", emptyList()).toJson()
}
}
}
Loading
Loading