Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryClient & Transaction #7

Merged
merged 160 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
23562f5
wip
danylo-safonov-solid Sep 13, 2023
bd265f7
fix
danylo-safonov-solid Sep 13, 2023
6320938
rm commented-out code
danylo-safonov-solid Sep 13, 2023
a84b790
extract to file
danylo-safonov-solid Sep 13, 2023
94c408f
add comments
danylo-safonov-solid Sep 13, 2023
2a319c2
docs
danylo-safonov-solid Sep 13, 2023
24155e4
fix
danylo-safonov-solid Sep 13, 2023
0f3d68b
upd
danylo-safonov-solid Sep 13, 2023
7b4d2fa
test
danylo-safonov-solid Sep 13, 2023
a28b5c5
upd
danylo-safonov-solid Sep 13, 2023
ecdc8d0
flutter_version
danylo-safonov-solid Sep 13, 2023
df9edb4
test
danylo-safonov-solid Sep 13, 2023
e509352
?
danylo-safonov-solid Sep 13, 2023
d163aea
blessrng
danylo-safonov-solid Sep 13, 2023
e117e55
blessRNG
danylo-safonov-solid Sep 13, 2023
64703e0
experiment
danylo-safonov-solid Sep 13, 2023
851c27e
up
danylo-safonov-solid Sep 13, 2023
1ad4cda
ultra bless
danylo-safonov-solid Sep 13, 2023
97d2d09
.
danylo-safonov-solid Sep 13, 2023
1e9ec88
maybe closer
danylo-safonov-solid Sep 13, 2023
7dae9bc
not bruh
danylo-safonov-solid Sep 13, 2023
3867137
please
danylo-safonov-solid Sep 13, 2023
cef2fdb
<>
danylo-safonov-solid Sep 13, 2023
6b80cdf
777
danylo-safonov-solid Sep 13, 2023
d60906e
pls
danylo-safonov-solid Sep 13, 2023
1dca1a2
ultra please
danylo-safonov-solid Sep 13, 2023
6ecd4c6
pls
danylo-safonov-solid Sep 13, 2023
492f945
hope
danylo-safonov-solid Sep 13, 2023
969c37c
fix
danylo-safonov-solid Sep 14, 2023
3a033a8
fix
danylo-safonov-solid Sep 14, 2023
a764848
versions
danylo-safonov-solid Sep 14, 2023
8c6be21
merge
danylo-safonov-solid Sep 14, 2023
f6bb9dc
fix
danylo-safonov-solid Sep 14, 2023
b77bada
Merge branch 'bugfix' into lock-dart
danylo-safonov-solid Sep 14, 2023
7d92ba6
Merge branch 'lock-dart' into isolation-level
danylo-safonov-solid Sep 14, 2023
458db56
init?
danylo-safonov-solid Sep 14, 2023
96f8f13
done?
danylo-safonov-solid Sep 14, 2023
6ffc520
fix
danylo-safonov-solid Sep 14, 2023
305f2b8
upd
danylo-safonov-solid Sep 14, 2023
1612dfb
part
danylo-safonov-solid Sep 14, 2023
209977f
add placeholders
danylo-safonov-solid Sep 14, 2023
f773417
exports
danylo-safonov-solid Sep 14, 2023
c1fd25b
fixes
danylo-safonov-solid Sep 14, 2023
a21505e
fixes
danylo-safonov-solid Sep 14, 2023
4b4a4ec
more fixes
danylo-safonov-solid Sep 14, 2023
242629a
source
danylo-safonov-solid Sep 14, 2023
8bde0c3
todo
danylo-safonov-solid Sep 14, 2023
42967fe
clientOptions
danylo-safonov-solid Sep 14, 2023
832646f
info
danylo-safonov-solid Sep 14, 2023
5bed91c
remove things that are implemented
danylo-safonov-solid Sep 15, 2023
ee7936e
sync
danylo-safonov-solid Sep 15, 2023
44905a2
simplify checklist
danylo-safonov-solid Sep 15, 2023
8954ba7
align
danylo-safonov-solid Sep 15, 2023
bb547a3
extract checklist
danylo-safonov-solid Sep 15, 2023
2b3ca57
more implemented
danylo-safonov-solid Sep 15, 2023
f388fcd
upd
danylo-safonov-solid Sep 15, 2023
6fa5994
upd
danylo-safonov-solid Sep 15, 2023
34c4fec
Savepoint
danylo-safonov-solid Sep 15, 2023
9d788be
fix comments
danylo-safonov-solid Sep 15, 2023
8c4acfe
Merge branch 'fix-comments' into complete-interop1
danylo-safonov-solid Sep 15, 2023
54d4f1e
Merge branch 'main' into complete-interop1
danylo-safonov-solid Sep 15, 2023
d14616d
promise docs
danylo-safonov-solid Sep 15, 2023
9985a66
savepoint comments
danylo-safonov-solid Sep 15, 2023
7dfe833
ClientOptions comments
danylo-safonov-solid Sep 15, 2023
c232814
hosttype
danylo-safonov-solid Sep 15, 2023
62c347f
partialconnectionoptions upd
danylo-safonov-solid Sep 15, 2023
1017a57
partialTLSOptions
danylo-safonov-solid Sep 15, 2023
547a29c
uncomment
danylo-safonov-solid Sep 15, 2023
196ee80
progress
danylo-safonov-solid Sep 15, 2023
14d1469
partially resolve queryObject
danylo-safonov-solid Sep 15, 2023
0f0a0c5
upd
danylo-safonov-solid Sep 18, 2023
4fbcdf4
upd
danylo-safonov-solid Sep 18, 2023
abaf4c6
big upd
danylo-safonov-solid Sep 18, 2023
f59ef27
fix
danylo-safonov-solid Sep 18, 2023
c206335
split by files
danylo-safonov-solid Sep 18, 2023
d15417e
init
danylo-safonov-solid Sep 18, 2023
db75396
CommandType
danylo-safonov-solid Sep 18, 2023
737d5fb
notice
danylo-safonov-solid Sep 18, 2023
c1f6a1d
ResultType
danylo-safonov-solid Sep 18, 2023
91f9831
working type
danylo-safonov-solid Sep 18, 2023
da3208f
placeholders
danylo-safonov-solid Sep 18, 2023
d3f8d90
working
danylo-safonov-solid Sep 18, 2023
c92dd81
more consistent comments
danylo-safonov-solid Sep 18, 2023
eefbfd2
sync
danylo-safonov-solid Sep 18, 2023
efae6a2
sync
danylo-safonov-solid Sep 18, 2023
13750a9
rowdescription
danylo-safonov-solid Sep 18, 2023
fd0274e
query
danylo-safonov-solid Sep 18, 2023
330b1fa
split by files
danylo-safonov-solid Sep 18, 2023
53ffeba
queryObjectOptions
danylo-safonov-solid Sep 18, 2023
2be332b
uint8
danylo-safonov-solid Sep 18, 2023
6ebfab9
init
danylo-safonov-solid Sep 18, 2023
20e5d3f
mini upd
danylo-safonov-solid Sep 18, 2023
8f965ff
working
danylo-safonov-solid Sep 18, 2023
8075339
remove generic
danylo-safonov-solid Sep 18, 2023
3f8c731
sync
danylo-safonov-solid Sep 18, 2023
16dd4b5
sync
danylo-safonov-solid Sep 19, 2023
99010b3
upd
danylo-safonov-solid Sep 19, 2023
ee30c72
init
danylo-safonov-solid Sep 19, 2023
9000f58
upd
danylo-safonov-solid Sep 19, 2023
2c06285
sync
danylo-safonov-solid Sep 19, 2023
3252e45
init
danylo-safonov-solid Sep 19, 2023
0168f8d
sync
danylo-safonov-solid Sep 19, 2023
3ff9819
rm duplicate
danylo-safonov-solid Sep 19, 2023
69f0268
restore
danylo-safonov-solid Sep 19, 2023
7c2474a
restore order
danylo-safonov-solid Sep 19, 2023
b1652e1
sync
danylo-safonov-solid Sep 19, 2023
03714ff
sync
danylo-safonov-solid Sep 19, 2023
1d670fb
sync
danylo-safonov-solid Sep 19, 2023
5516b9f
part
danylo-safonov-solid Sep 19, 2023
38540f1
more prope
danylo-safonov-solid Sep 19, 2023
b0391f1
upd
danylo-safonov-solid Sep 19, 2023
747a4b8
fix
danylo-safonov-solid Sep 19, 2023
da1e5bb
todos
danylo-safonov-solid Sep 19, 2023
f4608b0
upd
danylo-safonov-solid Sep 19, 2023
6cf6999
constructor
danylo-safonov-solid Sep 19, 2023
0e7420e
parse
danylo-safonov-solid Sep 19, 2023
f6d6608
todo
danylo-safonov-solid Sep 19, 2023
e6a36d0
upd
danylo-safonov-solid Sep 20, 2023
d1080ab
Merge branch 'main' into PoolClient
danylo-safonov-solid Sep 20, 2023
2a99e77
upd
danylo-safonov-solid Sep 20, 2023
b396b87
fix comments
danylo-safonov-solid Sep 20, 2023
be46787
upd
danylo-safonov-solid Sep 20, 2023
63bb9de
upd
danylo-safonov-solid Sep 20, 2023
08caea6
upd
danylo-safonov-solid Sep 20, 2023
ac91006
constructor
danylo-safonov-solid Sep 20, 2023
f5c5768
upd
danylo-safonov-solid Sep 20, 2023
24cb622
upd
danylo-safonov-solid Sep 20, 2023
68545d5
export
danylo-safonov-solid Sep 20, 2023
1eafda3
tls options
danylo-safonov-solid Sep 20, 2023
8cfa653
finish?
danylo-safonov-solid Sep 20, 2023
e671dcc
upd
danylo-safonov-solid Sep 20, 2023
f1b6395
last
danylo-safonov-solid Sep 20, 2023
67aab73
Merge branch 'PoolClient' into QueryResult
danylo-safonov-solid Sep 20, 2023
ac208bc
upd
danylo-safonov-solid Sep 20, 2023
26f47f3
upd
danylo-safonov-solid Sep 20, 2023
986eed2
upd
danylo-safonov-solid Sep 20, 2023
d4542bb
sync
danylo-safonov-solid Sep 20, 2023
1769b88
revert
danylo-safonov-solid Sep 20, 2023
d092ed9
revert
danylo-safonov-solid Sep 20, 2023
5f4ad6c
upd
danylo-safonov-solid Sep 20, 2023
dbc929f
upd
danylo-safonov-solid Sep 20, 2023
74d4e6e
sync
danylo-safonov-solid Sep 20, 2023
8474d2c
sync
danylo-safonov-solid Sep 20, 2023
1bbb7e6
fix
danylo-safonov-solid Sep 20, 2023
6a42760
restore
danylo-safonov-solid Sep 20, 2023
6807f24
add comments
danylo-safonov-solid Sep 20, 2023
d1f834a
comments
danylo-safonov-solid Sep 20, 2023
2a995de
update unimplemented
danylo-safonov-solid Sep 20, 2023
740a82b
upd
danylo-safonov-solid Sep 20, 2023
4579d59
upd
danylo-safonov-solid Sep 20, 2023
0047c9b
upd
danylo-safonov-solid Sep 20, 2023
d947da8
upd
danylo-safonov-solid Sep 21, 2023
89fdb19
transaction
danylo-safonov-solid Sep 21, 2023
162e09f
fin
danylo-safonov-solid Sep 21, 2023
4973815
upd
danylo-safonov-solid Sep 21, 2023
1757b65
impl
danylo-safonov-solid Sep 21, 2023
b0810ce
seemps good
danylo-safonov-solid Sep 21, 2023
49e84a5
upd
danylo-safonov-solid Sep 21, 2023
90963a4
sync
danylo-safonov-solid Sep 21, 2023
82f0d47
exports
danylo-safonov-solid Sep 21, 2023
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
9 changes: 9 additions & 0 deletions lib/deno_postgres_interop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,26 @@ library;
export 'src/client.dart';
export 'src/client_configuration.dart';
export 'src/client_options.dart';
export 'src/column.dart';
export 'src/command_type.dart';
export 'src/connection.dart';
export 'src/connection_options.dart';
export 'src/encoded_arg.dart';
export 'src/isolation_level.dart';
export 'src/notice.dart';
export 'src/partial/partial_connection_options.dart';
export 'src/partial/partial_tls_options.dart';
export 'src/pool.dart';
export 'src/pool_client.dart';
export 'src/query.dart';
export 'src/query_array_result.dart';
export 'src/query_client.dart';
export 'src/query_object_result.dart';
export 'src/query_result.dart';
export 'src/result_type.dart';
export 'src/row_description.dart';
export 'src/savepoint.dart';
export 'src/session.dart';
export 'src/tls_options.dart';
export 'src/transaction.dart';
export 'src/transaction_options.dart';
Expand Down
9 changes: 9 additions & 0 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import 'dart:js_interop';
import 'dart:js_util';

import 'package:deno_postgres_interop/src/client_options.dart';
import 'package:deno_postgres_interop/src/query_client.dart';

/// [deno-postgres@v0.17.0/Client](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Client).
@JS()
class Client extends QueryClient {
/// [deno-postgres@v0.17.0/Client/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Client#ctor_0).
external factory Client(String dbUrl);

/// [deno-postgres@v0.17.0/Client/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Client#ctor_0).
factory Client.config(ClientOptions config) =>
callConstructor('Client', [config]);

/// [deno-postgres@v0.17.0/Client/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Client#ctor_0).
factory Client.empty() => callConstructor('Client', null);
}
50 changes: 50 additions & 0 deletions lib/src/connection.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import 'dart:js_interop';
import 'dart:js_util';

import 'package:deno_postgres_interop/src/client_configuration.dart';
import 'package:deno_postgres_interop/src/promise.dart';
import 'package:deno_postgres_interop/src/query.dart';
import 'package:deno_postgres_interop/src/query_result.dart';
import 'package:deno_postgres_interop/src/transport.dart';
import 'package:deno_postgres_interop/src/util.dart';

/// [deno-postgres@v0.17.0/Connection](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection).
@JS()
class Connection {
/// [deno-postgres@v0.17.0/Connection/connected](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#accessor_pid).
external int get pid;

/// [deno-postgres@v0.17.0/Connection/constructor](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#ctor_0).
factory Connection({
required ClientConfiguration connectionParams,
required Future<void> Function() disconnectionCallback,
}) =>
callConstructor(
'Connection',
[connectionParams, () => futureToPromise(disconnectionCallback())],
);
}

/// [deno-postgres@v0.17.0/Connection](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection).
extension ConnectionProps on Connection {
/// [deno-postgres@v0.17.0/Connection/connected](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#prop_connected).
bool get isConnected => getProperty(this, 'connected');

/// [deno-postgres@v0.17.0/Connection/tls](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#accessor_tls).
bool get isCarriedOverTLS => getProperty(this, 'tls');

/// [deno-postgres@v0.17.0/Connection/transport](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#accessor_transport).
Transport get transport => Transport.parse(getProperty(this, 'transport'));

/// [deno-postgres@v0.17.0/Connection/end](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_end_0).
Future<void> end() => callFutureMethod(this, 'end');

/// [deno-postgres@v0.17.0/Connection/query](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_query_0).
/// [deno-postgres@v0.17.0/Connection/query](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_query_1).
Future<T> queryArray<T extends QueryResult>(Query query) =>
callFutureMethod(this, 'query', [query]);

/// [deno-postgres@v0.17.0/Connection/startup](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_startup_0).
Future<void> startup({required bool isReconnection}) =>
callFutureMethod(this, 'startup', [isReconnection]);
}
38 changes: 19 additions & 19 deletions lib/src/notice.dart
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
import 'dart:js_interop';
import 'dart:js_util';

/// [postgres@v0.17.0/Notice](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice).
/// [deno-postgres@v0.17.0/Notice](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice).
@JS()
class Notice {
/// [postgres@v0.17.0/Notice/severity](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_severity).
/// [deno-postgres@v0.17.0/Notice/severity](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_severity).
external String get severity;

/// [postgres@v0.17.0/Notice/code](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_code).
/// [deno-postgres@v0.17.0/Notice/code](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_code).
external String get code;

/// [postgres@v0.17.0/Notice/message](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_message).
/// [deno-postgres@v0.17.0/Notice/message](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_message).
external String get message;

/// [postgres@v0.17.0/Notice/detail](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_detail).
/// [deno-postgres@v0.17.0/Notice/detail](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_detail).
external String? get detail;

/// [postgres@v0.17.0/Notice/hint](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_hint).
/// [deno-postgres@v0.17.0/Notice/hint](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_hint).
external String? get hint;

/// [postgres@v0.17.0/Notice/position](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_position).
/// [deno-postgres@v0.17.0/Notice/position](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_position).
external String? get position;

/// [postgres@v0.17.0/Notice/internalPosition](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_internalPosition).
/// [deno-postgres@v0.17.0/Notice/internalPosition](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_internalPosition).
external String? get internalPosition;

/// [postgres@v0.17.0/Notice/internalQuery](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_internalQuery).
/// [deno-postgres@v0.17.0/Notice/internalQuery](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_internalQuery).
external String? get internalQuery;

/// [postgres@v0.17.0/Notice/where](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_where).
/// [deno-postgres@v0.17.0/Notice/where](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_where).
external String? get where;

/// [postgres@v0.17.0/Notice/schema](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_schema).
/// [deno-postgres@v0.17.0/Notice/schema](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_schema).
external String? get schema;

/// [postgres@v0.17.0/Notice/table](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_table).
/// [deno-postgres@v0.17.0/Notice/table](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_table).
external String? get table;

/// [postgres@v0.17.0/Notice/column](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_column).
/// [deno-postgres@v0.17.0/Notice/column](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_column).
external String? get column;

/// [postgres@v0.17.0/Notice/dataType](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_dataType).
/// [deno-postgres@v0.17.0/Notice/dataType](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_dataType).
external String? get dataType;

/// [postgres@v0.17.0/Notice/constraint](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_constraint).
/// [deno-postgres@v0.17.0/Notice/constraint](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_constraint).
external String? get constraint;

/// [postgres@v0.17.0/Notice/file](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_file).
/// [deno-postgres@v0.17.0/Notice/file](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_file).
external String? get file;

/// [postgres@v0.17.0/Notice/line](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_line).
/// [deno-postgres@v0.17.0/Notice/line](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_line).
external String? get line;

/// [postgres@v0.17.0/Notice/routine](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_routine).
/// [deno-postgres@v0.17.0/Notice/routine](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_routine).
external String? get routine;

/// [postgres@v0.17.0/Notice](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice).
/// [deno-postgres@v0.17.0/Notice](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice).
factory Notice({
required String severity,
required String code,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/pool.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:js_interop';
import 'dart:js_util';

import 'package:deno_postgres_interop/src/client_options.dart';
Expand All @@ -6,6 +7,7 @@ import 'package:deno_postgres_interop/src/undefined.dart';
import 'package:deno_postgres_interop/src/util.dart';

/// [deno-postgres@v0.17.0/Pool](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Pool).
@JS()
class Pool {
/// [deno-postgres@v0.17.0/Pool/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Pool#ctor_0).
factory Pool({
Expand Down
21 changes: 21 additions & 0 deletions lib/src/promise.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'dart:js_interop';
import 'dart:js_util';

typedef _Resolver<T> = void Function(T result);
typedef _Executor<T> = void Function(_Resolver<T> resolve, Function reject);

/// JS [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) interop.
@JS()
class Promise<T> {
/// [js/Promise/constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise).
external Promise(_Executor<T> executor);
}

/// Convert darts [Future] to js' [Promise].
Promise<T> futureToPromise<T>(Future<T> future) {
return Promise<T>(
allowInterop((resolve, reject) {
future.then(resolve, onError: reject);
}),
);
}
19 changes: 18 additions & 1 deletion lib/src/query_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,36 @@ import 'dart:js_interop';
import 'dart:js_util';

import 'package:deno_postgres_interop/src/client_common.dart';
import 'package:deno_postgres_interop/src/connection.dart';
import 'package:deno_postgres_interop/src/query_array_result.dart';
import 'package:deno_postgres_interop/src/query_object_options.dart';
import 'package:deno_postgres_interop/src/query_object_result.dart';
import 'package:deno_postgres_interop/src/session.dart';
import 'package:deno_postgres_interop/src/transaction.dart';
import 'package:deno_postgres_interop/src/transaction_options.dart';
import 'package:deno_postgres_interop/src/util.dart';

/// [deno-postgres@v0.17.0/QueryClient](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient).
@JS()
class QueryClient {}
class QueryClient {
/// [deno-postgres@v0.17.0/QueryClient/session](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#accessor_session).
external Session get session;

/// [deno-postgres@v0.17.0/QueryClient/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#ctor_0).
external factory QueryClient(Connection connection);
}

/// [deno-postgres@v0.17.0/QueryClient](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient).
extension QueryClientProps on QueryClient {
/// [deno-postgres@v0.17.0/QueryClient/connected](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#accessor_connected).
bool get isConnected => getProperty(this, 'connected');

/// [deno-postgres@v0.17.0/QueryClient/closeConnection](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_closeConnection_0).
Future<void> closeConnection() => callFutureMethod(this, 'closeConnection');

/// [deno-postgres@v0.17.0/QueryClient/resetSessionMetadata](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_resetSessionMetadata_0).
void resetSessionMetadata() => callMethod(this, 'resetSessionMetadata', []);

/// [deno-postgres@v0.17.0/QueryClient/connect](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_connect_0).
Future<void> connect() => callFutureMethod(this, 'connect');

Expand Down
33 changes: 33 additions & 0 deletions lib/src/savepoint.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'dart:js_interop';
import 'dart:js_util';

import 'package:deno_postgres_interop/src/promise.dart';
import 'package:deno_postgres_interop/src/util.dart';

/// [deno-postgres@v0.17.0/Savepoint](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Savepoint).
@JS()
class Savepoint {
/// [deno-postgres@v0.17.0/Savepoint/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Savepoint#ctor_0).
factory Savepoint(
String name,
Future<void> Function(String name) updateCallback,
Future<void> Function(String name) releaseCallback,
) =>
callConstructor('Savepoint', [
name,
(String name) => futureToPromise(updateCallback(name)),
(String name) => futureToPromise(releaseCallback(name)),
]);
}

/// [deno-postgres@v0.17.0/Savepoint](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Savepoint).
extension SavepointProps on Savepoint {
/// [deno-postgres@v0.17.0/Savepoint/instances](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Savepoint#accessor_instances).
int get instancesCount => getProperty(this, 'instances');

/// [deno-postgres@v0.17.0/Savepoint/instances](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Savepoint#method_release_0).
Future<void> release() => callFutureMethod(this, 'release');

/// [deno-postgres@v0.17.0/Savepoint/instances](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Savepoint#method_update_0).
Future<void> update() => callFutureMethod(this, 'update');
}
27 changes: 27 additions & 0 deletions lib/src/session.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'dart:js_interop';
import 'dart:js_util';

import 'package:deno_postgres_interop/src/transport.dart';

/// [deno-postgres@v0.17.0/Session](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session).
@JS()
class Session {
/// [deno-postgres@v0.17.0/Session/pid](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session#prop_pid)
external int? get pid;

/// [deno-postgres@v0.17.0/Session/tls](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session#prop_tls)
external bool? get tls;
}

/// [deno-postgres@v0.17.0/Session](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session).
extension SessionProps on Session {
/// [deno-postgres@v0.17.0/Session/current_transaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session#prop_current_transaction)
String? get currentTransacton => getProperty(this, 'current_transaction');

/// [deno-postgres@v0.17.0/Session/transport](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session#prop_transport)
Transport? get transport {
final string = getProperty<String?>(this, 'transport');

return string == null ? null : Transport.parse(string);
}
}
Loading
Loading