Skip to content

Commit e25bf34

Browse files
committed
Merge remote-tracking branch 'origin/master' into feat-react-native-sdk
2 parents bbbb5ce + ad80d80 commit e25bf34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+410
-169
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ jobs:
6767
run: composer install
6868

6969
- name: Lint
70-
run: composer lint
70+
run: composer lint

composer.lock

Lines changed: 90 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
11
package {{ sdk.namespace | caseDot }}
22

3+
import java.time.Instant
4+
import kotlin.math.floor
5+
import kotlin.random.Random
6+
37
class ID {
48
companion object {
9+
// Generate an hex ID based on timestamp
10+
// Recreated from https://www.php.net/manual/en/function.uniqid.php
11+
private fun hexTimestamp(): String {
12+
val now = Instant.now()
13+
val sec = now.epochSecond
14+
val usec = (System.nanoTime() / 1000) % 1000
15+
16+
val hexTimestamp = "%08x%05x".format(sec, usec)
17+
18+
return hexTimestamp
19+
}
20+
521
fun custom(id: String): String
622
= id
7-
fun unique(): String
8-
= "unique()"
23+
24+
// Generate a unique ID with padding to have a longer ID
25+
fun unique(padding: Int = 7): String {
26+
val baseId = hexTimestamp()
27+
val randomPadding = (1..padding)
28+
.map { Random.nextInt(0, 16).toString(16) }
29+
.joinToString("")
30+
31+
return baseId + randomPadding
32+
}
933
}
10-
}
34+
}

templates/apple/Sources/Client.swift.twig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,8 @@ extension Client {
542542
return "tvos"
543543
#elseif os(macOS)
544544
return "macos"
545+
#elseif os(visionOS)
546+
return "visionos"
545547
#elseif os(Linux)
546548
return "linux"
547549
#elseif os(Windows)

templates/cli/lib/commands/generic.js.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { globalConfig, localConfig } = require("../config");
66
const { actionRunner, success, parseBool, commandDescriptions, log, parse } = require("../parser");
77
{% if sdk.test != "true" %}
88
const { questionsLogin } = require("../questions");
9-
const { accountCreateEmailSession, accountDeleteSession } = require("./account");
9+
const { accountCreateEmailPasswordSession, accountDeleteSession } = require("./account");
1010

1111
const login = new Command("login")
1212
.description(commandDescriptions['login'])
@@ -18,7 +18,7 @@ const login = new Command("login")
1818

1919
let client = await sdkForConsole(false);
2020

21-
await accountCreateEmailSession({
21+
await accountCreateEmailPasswordSession({
2222
email: answers.email,
2323
password: answers.password,
2424
parseOutput: false,

templates/dart/lib/id.dart.twig

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
1-
part of {{ language.params.packageName }};
1+
part of '{{ language.params.packageName }}.dart';
22

33
/// Helper class to generate ID strings for resources.
44
class ID {
55
ID._();
66

7-
/// Have Appwrite generate a unique ID for you.
8-
static String unique() {
9-
return 'unique()';
7+
// Generate an hex ID based on timestamp
8+
// Recreated from https://www.php.net/manual/en/function.uniqid.php
9+
static String _hexTimestamp() {
10+
final now = DateTime.now();
11+
final sec = (now.millisecondsSinceEpoch / 1000).floor();
12+
final usec = now.microsecondsSinceEpoch - (sec * 1000000);
13+
return sec.toRadixString(16) +
14+
usec.toRadixString(16).padLeft(5, '0');
15+
}
16+
17+
// Generate a unique ID with padding to have a longer ID
18+
static String unique({int padding = 7}) {
19+
String id = _hexTimestamp();
20+
21+
if (padding > 0) {
22+
StringBuffer sb = StringBuffer();
23+
for (var i = 0; i < padding; i++) {
24+
sb.write(Random().nextInt(16).toRadixString(16));
25+
}
26+
27+
id += sb.toString();
28+
}
29+
30+
return id;
1031
}
1132

1233
/// Uses [id] as the ID for the resource.
1334
static String custom(String id) {
1435
return id;
1536
}
16-
}
37+
}

templates/dart/lib/package.dart.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
library {{ language.params.packageName }};
77

88
import 'dart:async';
9+
import 'dart:math';
910
import 'dart:typed_data';
1011
import 'dart:convert';
1112

templates/dart/lib/permission.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
part of {{ language.params.packageName }};
1+
part of '{{ language.params.packageName }}.dart';
22

33
/// Helper class to generate permission strings for resources.
44
class Permission {

templates/dart/lib/query.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
part of {{ language.params.packageName }};
1+
part of '{{ language.params.packageName }}.dart';
22

33

44
/// Helper class to generate query strings.

templates/dart/lib/role.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
part of {{ language.params.packageName }};
1+
part of '{{ language.params.packageName }}.dart';
22

33
/// Helper class to generate role strings for [Permission].
44
class Role {

0 commit comments

Comments
 (0)