From 23562f539d1e6bfb9e42a4a156a86e88a9dc7ef5 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 11:44:26 +0300 Subject: [PATCH 001/139] wip --- example/lib/main.dart | 6 ++++- lib/deno_postgres_interop.dart | 1 + lib/src/query_client.dart | 25 ++++++++++++++++---- lib/src/transaction_options.dart | 40 ++++++++++++++++++++++++++++++++ pubspec.yaml | 4 +++- tools/add_imports/pubspec.yaml | 2 +- 6 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 lib/src/transaction_options.dart diff --git a/example/lib/main.dart b/example/lib/main.dart index 29818f2..aa7b6de 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -9,7 +9,11 @@ Future fetch(Request _) async { final client = Client(dbUrl); await client.connect(); - final result = await client.transaction('transaction', transaction); + final result = await client.transaction( + 'transaction', + transaction, + TransactionOptions(isolationLevel: IsolationLevel.serializable), + ); await client.end(); return Response(result.rows.map(rowToPrettyString).join('\n\n')); diff --git a/lib/deno_postgres_interop.dart b/lib/deno_postgres_interop.dart index 779b81d..abba095 100644 --- a/lib/deno_postgres_interop.dart +++ b/lib/deno_postgres_interop.dart @@ -5,3 +5,4 @@ export 'src/client.dart'; export 'src/query_client.dart'; export 'src/query_object_result.dart'; export 'src/transaction.dart'; +export 'src/transaction_options.dart'; diff --git a/lib/src/query_client.dart b/lib/src/query_client.dart index fddd6b2..2bc4580 100644 --- a/lib/src/query_client.dart +++ b/lib/src/query_client.dart @@ -3,6 +3,7 @@ import 'dart:js_util'; import 'package:deno_postgres_interop/src/query_object_result.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'; /// [postgres@v0.17.0/QueryClient](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient). @@ -18,17 +19,31 @@ extension QueryClientProps on QueryClient { Future end() => callFutureMethod(this, 'end'); /// [postgres@v0.17.0/QueryClient/createTransaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_createTransaction_0). - Transaction createTransaction(String name) => - callMethod(this, 'createTransaction', [name]); + Transaction createTransaction(String name, [TransactionOptions? options]) => + callMethod( + this, + 'createTransaction', + [ + name, + if (options != null) options, + // jsify({ + // if (options.isolationLevel != null) + // 'isolation_level': options.isolationLevel?.name, + // if (options.isReadOnly != null) 'read_only': options.isReadOnly, + // if (options.snapshot != null) 'snapshot': options.snapshot, + // }), + ], + ); /// Convinience wrapper for [createTransaction], /// [TransactionProps.begin], /// and [TransactionProps.commit]. Future transaction( String name, - Future Function(Transaction) f, - ) async { - final transaction = createTransaction(name); + Future Function(Transaction) f, [ + TransactionOptions? options, + ]) async { + final transaction = createTransaction(name, options); await transaction.begin(); final result = await f(transaction); await transaction.commit(); diff --git a/lib/src/transaction_options.dart b/lib/src/transaction_options.dart new file mode 100644 index 0000000..47a5ba5 --- /dev/null +++ b/lib/src/transaction_options.dart @@ -0,0 +1,40 @@ +import 'dart:js_interop'; +import 'dart:js_util'; + +/// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) +@JS() +class TransactionOptions { + /// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) + external String? get snapshot; + + /// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) + factory TransactionOptions({ + IsolationLevel? isolationLevel, + bool? isReadOnly, + String? snapshot, + }) => + jsify({ + if (isolationLevel != null) 'isolation_level': isolationLevel.name, + if (isReadOnly != null) 'read_only': isReadOnly, + if (snapshot != null) 'snapshot': snapshot, + }) as TransactionOptions; +} + +extension TransactionOptionsProps on TransactionOptions { + IsolationLevel? get isolationLevel { + final jsProperty = getProperty(this, 'isolation_level'); + + return jsProperty == null ? null : IsolationLevel.parse(jsProperty); + } + + bool? get isReadOnly => getProperty(this, 'read_only'); +} + +enum IsolationLevel { + readCommited, + repeatableRead, + serializable; + + static IsolationLevel parse(String string) => + values.firstWhere((e) => e.name == string); +} diff --git a/pubspec.yaml b/pubspec.yaml index 08ae5cb..27cc4a1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,9 @@ version: 0.0.1 repository: https://github.com/solid-software/deno_postgres_interop environment: - sdk: ^3.0.0 + # https://github.com/invertase/dart_edge/issues/50 + # Tested with 3.0.6, but others should work too + sdk: '>=3.0.0 <3.1.0' dev_dependencies: solid_lints: 0.0.19 diff --git a/tools/add_imports/pubspec.yaml b/tools/add_imports/pubspec.yaml index c5d5d16..a69e3c3 100644 --- a/tools/add_imports/pubspec.yaml +++ b/tools/add_imports/pubspec.yaml @@ -3,7 +3,7 @@ description: add_imports. version: 1.0.0 environment: - sdk: ^3.1.0 + sdk: ^3.0.0 dependencies: args: ^2.4.2 From bd265f766ed448b614fbe19afa52674584eb4f82 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 13:35:28 +0300 Subject: [PATCH 002/139] fix --- tools/add_imports/bin/add_imports.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/add_imports/bin/add_imports.dart b/tools/add_imports/bin/add_imports.dart index b7f7385..44dfbdb 100644 --- a/tools/add_imports/bin/add_imports.dart +++ b/tools/add_imports/bin/add_imports.dart @@ -39,7 +39,7 @@ String createNewSource(String sourceString, Config config) { .toList(); return [ - ...[config.importStringForClass, (e) => 'self.$e = $e'] + ...[config.importStringForClass, (e) => 'self.$e = $e;'] .map(classes.map) .flattened, sourceString, From 6320938fd5e03b426619553d9152715597db7a7e Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 13:52:30 +0300 Subject: [PATCH 003/139] rm commented-out code --- lib/src/query_client.dart | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/src/query_client.dart b/lib/src/query_client.dart index 2bc4580..96cf79a 100644 --- a/lib/src/query_client.dart +++ b/lib/src/query_client.dart @@ -26,12 +26,6 @@ extension QueryClientProps on QueryClient { [ name, if (options != null) options, - // jsify({ - // if (options.isolationLevel != null) - // 'isolation_level': options.isolationLevel?.name, - // if (options.isReadOnly != null) 'read_only': options.isReadOnly, - // if (options.snapshot != null) 'snapshot': options.snapshot, - // }), ], ); From a84b79004595b563a7d634e1ba72c3395be4e372 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 13:56:52 +0300 Subject: [PATCH 004/139] extract to file --- lib/deno_postgres_interop.dart | 1 + lib/src/isolation_level.dart | 8 ++++++++ lib/src/transaction_options.dart | 12 +++--------- 3 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 lib/src/isolation_level.dart diff --git a/lib/deno_postgres_interop.dart b/lib/deno_postgres_interop.dart index abba095..1299943 100644 --- a/lib/deno_postgres_interop.dart +++ b/lib/deno_postgres_interop.dart @@ -2,6 +2,7 @@ library; export 'src/client.dart'; +export 'src/isolation_level.dart'; export 'src/query_client.dart'; export 'src/query_object_result.dart'; export 'src/transaction.dart'; diff --git a/lib/src/isolation_level.dart b/lib/src/isolation_level.dart new file mode 100644 index 0000000..652d80a --- /dev/null +++ b/lib/src/isolation_level.dart @@ -0,0 +1,8 @@ +enum IsolationLevel { + readCommited, + repeatableRead, + serializable; + + static IsolationLevel parse(String string) => + values.firstWhere((e) => e.name == string); +} diff --git a/lib/src/transaction_options.dart b/lib/src/transaction_options.dart index 47a5ba5..7a252e7 100644 --- a/lib/src/transaction_options.dart +++ b/lib/src/transaction_options.dart @@ -1,6 +1,8 @@ import 'dart:js_interop'; import 'dart:js_util'; +import 'package:deno_postgres_interop/src/isolation_level.dart'; + /// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) @JS() class TransactionOptions { @@ -20,6 +22,7 @@ class TransactionOptions { }) as TransactionOptions; } +/// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) extension TransactionOptionsProps on TransactionOptions { IsolationLevel? get isolationLevel { final jsProperty = getProperty(this, 'isolation_level'); @@ -29,12 +32,3 @@ extension TransactionOptionsProps on TransactionOptions { bool? get isReadOnly => getProperty(this, 'read_only'); } - -enum IsolationLevel { - readCommited, - repeatableRead, - serializable; - - static IsolationLevel parse(String string) => - values.firstWhere((e) => e.name == string); -} From 94c408f12cfb1dd50e6fa17a6c8f4c2ea135d04c Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 14:00:40 +0300 Subject: [PATCH 005/139] add comments --- lib/src/transaction_options.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/transaction_options.dart b/lib/src/transaction_options.dart index 7a252e7..20fa52d 100644 --- a/lib/src/transaction_options.dart +++ b/lib/src/transaction_options.dart @@ -6,10 +6,10 @@ import 'package:deno_postgres_interop/src/isolation_level.dart'; /// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) @JS() class TransactionOptions { - /// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) + /// [postgres@v0.17.0/TransactionOptions/snapshot](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) external String? get snapshot; - /// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) + /// [postgres@v0.17.0/TransactionOptions/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) factory TransactionOptions({ IsolationLevel? isolationLevel, bool? isReadOnly, @@ -24,11 +24,13 @@ class TransactionOptions { /// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) extension TransactionOptionsProps on TransactionOptions { + /// [postgres@v0.17.0/TransactionOptions/isolation_level](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) IsolationLevel? get isolationLevel { final jsProperty = getProperty(this, 'isolation_level'); return jsProperty == null ? null : IsolationLevel.parse(jsProperty); } + /// [postgres@v0.17.0/TransactionOptions/read_only](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) bool? get isReadOnly => getProperty(this, 'read_only'); } From 2a319c2485bcf726e8836ea77de5d91c3c5b89b2 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 14:18:12 +0300 Subject: [PATCH 006/139] docs --- lib/src/isolation_level.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/src/isolation_level.dart b/lib/src/isolation_level.dart index 652d80a..3b2016a 100644 --- a/lib/src/isolation_level.dart +++ b/lib/src/isolation_level.dart @@ -1,8 +1,15 @@ +/// https://www.postgresql.org/docs/current/transaction-iso.html enum IsolationLevel { - readCommited, + /// [postgresql/Transaction Isolation/Read Committed Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-READ-COMMITTED) + readCommitted, + + /// [postgresql/Transaction Isolation/Repeatable Read Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-REPEATABLE-READ) repeatableRead, + + /// [postgresql/Transaction Isolation/Serializable Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-SERIALIZABLE) serializable; + /// Parses a string containing an [IsolationLevel] literal into its instance. static IsolationLevel parse(String string) => values.firstWhere((e) => e.name == string); } From 24155e415e6dc306ef91fb4109f8462e2c63f22c Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 14:22:33 +0300 Subject: [PATCH 007/139] fix --- .github/workflows/on-pr-push-code-check.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index b0a4fb3..7218a65 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -27,6 +27,9 @@ jobs: - name: Setup dart uses: dart-lang/setup-dart@v1 + # https://github.com/invertase/dart_edge/issues/50 + # Tested with 3.0.6, but others should work too + sdk: 3.0.0 - name: Get main dependencies run: dart pub get From 0f3d68bfee155dbf3a30497f851d801bebeba9c1 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 14:23:15 +0300 Subject: [PATCH 008/139] upd --- .github/workflows/on-pr-push-code-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index 7218a65..e3b5b11 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -27,6 +27,7 @@ jobs: - name: Setup dart uses: dart-lang/setup-dart@v1 + with: # https://github.com/invertase/dart_edge/issues/50 # Tested with 3.0.6, but others should work too sdk: 3.0.0 From 7b4d2fafb0f45a62219f9b312408d12ad9c4900d Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 14:51:30 +0300 Subject: [PATCH 009/139] test --- .github/workflows/on-pr-push-code-check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index e3b5b11..20b971b 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -45,7 +45,8 @@ jobs: fatal-infos: true - name: Dart Code Metrics - uses: solid-software/dart-code-metrics-action@v5 + # uses: solid-software/dart-code-metrics-action@v5 + uses: danylo-safonov-solid/dart-code-metrics-action@c5492b1e9ecc9a1f1a5a0981cf8bacde118dc198 with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From a28b5c5602a299b13442015099b7cfe9fcaeda98 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 15:00:08 +0300 Subject: [PATCH 010/139] upd --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index 20b971b..af89851 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@c5492b1e9ecc9a1f1a5a0981cf8bacde118dc198 + uses: danylo-safonov-solid/dart-code-metrics-action@8b2008387123fb34450d20cf2ec01fa2a9f6223e with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From ecdc8d0431a5926bfa814445d18e53a3e5404e28 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 15:12:19 +0300 Subject: [PATCH 011/139] flutter_version --- .github/workflows/on-pr-push-code-check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index af89851..03d99d1 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,11 +46,12 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@8b2008387123fb34450d20cf2ec01fa2a9f6223e + uses: danylo-safonov-solid/dart-code-metrics-action@4f9d94bee90dbe82ab62a7caff4c875c3c7782e9 with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true fatal_style: true + flutter_version: 3.10.6 - name: Check formatting run: dart format . --set-exit-if-changed From df9edb44942253850d7570647224467466bd2653 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 15:19:59 +0300 Subject: [PATCH 012/139] test --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index 03d99d1..238ce6c 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@4f9d94bee90dbe82ab62a7caff4c875c3c7782e9 + uses: danylo-safonov-solid/dart-code-metrics-action@18cceffb34691b10ecad47c8abad2457e5c521d9 with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From e509352212ae8673d774eab458396a2565603976 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 15:37:32 +0300 Subject: [PATCH 013/139] ? --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index 238ce6c..cbeb653 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@18cceffb34691b10ecad47c8abad2457e5c521d9 + uses: danylo-safonov-solid/dart-code-metrics-action@53a7db8768fa5dc4742e93efd9349d9366e9f84b with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From d163aea5f5c8e9bddea2537d917c4dfde540f101 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 17:18:15 +0300 Subject: [PATCH 014/139] blessrng --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index cbeb653..74745b0 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@53a7db8768fa5dc4742e93efd9349d9366e9f84b + uses: danylo-safonov-solid/dart-code-metrics-action@758380d191edc7ba5e11eae52b58c55820d225f0 with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From e117e55a10afdee3222bdafa9cf197e2b1bc60b3 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 17:23:21 +0300 Subject: [PATCH 015/139] blessRNG --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index 74745b0..4e6813d 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@758380d191edc7ba5e11eae52b58c55820d225f0 + uses: danylo-safonov-solid/dart-code-metrics-action@ee8dcd918f689fcfbf4fa08608570d2e6e0c892d with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From 64703e03d7bb9f686a237f85161ca9f4360e3b67 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 18:12:42 +0300 Subject: [PATCH 016/139] experiment --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index 4e6813d..7243643 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@ee8dcd918f689fcfbf4fa08608570d2e6e0c892d + uses: danylo-safonov-solid/dart-code-metrics-action@2c268fc1fcd484b028dcfeda40299712e0012f52 with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From 851c27e43abed659541556a58b3a50fd21364de9 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 18:17:17 +0300 Subject: [PATCH 017/139] up --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index 7243643..7b49646 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@2c268fc1fcd484b028dcfeda40299712e0012f52 + uses: danylo-safonov-solid/dart-code-metrics-action@fac84deb1a1c8b72ffbf8fa5cf5c50c79636476b with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From 1ad4cda07b05f33f355771a2e42a7cf79b87179a Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 18:37:37 +0300 Subject: [PATCH 018/139] ultra bless --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index 7b49646..78b9457 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@fac84deb1a1c8b72ffbf8fa5cf5c50c79636476b + uses: danylo-safonov-solid/dart-code-metrics-action@1658cf1c10d874ee7b61cd687c262d9e8ee903dd with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From 97d2d09740a3a396410ad2d0c5a71ef25ae520e7 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 18:40:51 +0300 Subject: [PATCH 019/139] . --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index 78b9457..aaf4664 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@1658cf1c10d874ee7b61cd687c262d9e8ee903dd + uses: danylo-safonov-solid/dart-code-metrics-action@709a20982f3bf418922fbd358e2ab76f42020572 with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From 1e9ec88c5cbf4cd8cd3be2d5fc1c9681ba00d670 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 18:43:29 +0300 Subject: [PATCH 020/139] maybe closer --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index aaf4664..109f283 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@709a20982f3bf418922fbd358e2ab76f42020572 + uses: danylo-safonov-solid/dart-code-metrics-action@ed342c01ff5fe4e0334c372ee3e20cfaf0e5e32f with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From 7dae9bc213e8f73f58dea535c7d27536128f71e7 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 18:46:14 +0300 Subject: [PATCH 021/139] not bruh --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index 109f283..f5e7fdf 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@ed342c01ff5fe4e0334c372ee3e20cfaf0e5e32f + uses: danylo-safonov-solid/dart-code-metrics-action@4374c8498bb821d4370b1b2d2ac46966f8a52174 with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From 3867137f86ea3954efc59a103d6505c0dbf8aa46 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 18:52:20 +0300 Subject: [PATCH 022/139] please --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index f5e7fdf..af024c4 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@4374c8498bb821d4370b1b2d2ac46966f8a52174 + uses: danylo-safonov-solid/dart-code-metrics-action@2f4a9236822a5012b6ae52195602c16c9afc721a with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From cef2fdb40ce428b88765209b5b9dfae7d5589e0f Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 18:55:45 +0300 Subject: [PATCH 023/139] <> --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index af024c4..056aafa 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@2f4a9236822a5012b6ae52195602c16c9afc721a + uses: danylo-safonov-solid/dart-code-metrics-action@ce5c1d377c8109df481babe99a4469bec50544d4 with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From 6b80cdf2e289da894c2d69d5d7bd03d5071ffede Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 18:58:52 +0300 Subject: [PATCH 024/139] 777 --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index 056aafa..23903e4 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@ce5c1d377c8109df481babe99a4469bec50544d4 + uses: danylo-safonov-solid/dart-code-metrics-action@6c19d4b6dcc89e6d55ae92539c2f3d4e6c258448 with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From d60906e3708b48127c93e929d180c8306051b20f Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 19:18:53 +0300 Subject: [PATCH 025/139] pls --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index 23903e4..8d375ce 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@6c19d4b6dcc89e6d55ae92539c2f3d4e6c258448 + uses: danylo-safonov-solid/dart-code-metrics-action@5a5d5eb2d8f8797a94a6e3b1613a587a9ed52ddc with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From 1dca1a2edb9209bb178d5348d50f450fe5a95271 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 19:34:14 +0300 Subject: [PATCH 026/139] ultra please --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index 8d375ce..769eaa9 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@5a5d5eb2d8f8797a94a6e3b1613a587a9ed52ddc + uses: danylo-safonov-solid/dart-code-metrics-action@3ba8b1139e034c745105b8cb5e4b2d1de39f5169 with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From 6ecd4c62d3928ea0ebb09cce15ce798cfd8e5094 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 19:35:40 +0300 Subject: [PATCH 027/139] pls --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index 769eaa9..eedfef0 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@3ba8b1139e034c745105b8cb5e4b2d1de39f5169 + uses: danylo-safonov-solid/dart-code-metrics-action@4d6fe0ae1e8d98f392fd3c4e5133a24e311c5c93 with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From 492f9459405ab7ebab23e0a9e08b880b3971a9f9 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 13 Sep 2023 19:43:18 +0300 Subject: [PATCH 028/139] hope --- .github/workflows/on-pr-push-code-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index eedfef0..b213bda 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -46,7 +46,7 @@ jobs: - name: Dart Code Metrics # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@4d6fe0ae1e8d98f392fd3c4e5133a24e311c5c93 + uses: danylo-safonov-solid/dart-code-metrics-action@897a72a57f186bf52c09ad25d07f437f4c789d4a with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true From 969c37c769afb22200cefa35052a00f625d65bc7 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 07:53:13 +0300 Subject: [PATCH 029/139] fix --- .github/workflows/on-pr-push-code-check.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index b213bda..e3b5b11 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -45,13 +45,11 @@ jobs: fatal-infos: true - name: Dart Code Metrics - # uses: solid-software/dart-code-metrics-action@v5 - uses: danylo-safonov-solid/dart-code-metrics-action@897a72a57f186bf52c09ad25d07f437f4c789d4a + uses: solid-software/dart-code-metrics-action@v5 with: github_token: ${{ secrets.GITHUB_TOKEN }} fatal_warnings: true fatal_style: true - flutter_version: 3.10.6 - name: Check formatting run: dart format . --set-exit-if-changed From 3a033a80f615df337bada512b312cc034a84cc54 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 07:57:49 +0300 Subject: [PATCH 030/139] fix --- .github/workflows/on-pr-push-code-check.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index e3b5b11..80864f8 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -44,12 +44,14 @@ jobs: with: fatal-infos: true - - name: Dart Code Metrics - uses: solid-software/dart-code-metrics-action@v5 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - fatal_warnings: true - fatal_style: true + # https://github.com/invertase/dart_edge/issues/50 + # dcm action uses stable, which is >=3.1 already, so it doesn't work + # - name: Dart Code Metrics + # uses: solid-software/dart-code-metrics-action@v5 + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # fatal_warnings: true + # fatal_style: true - name: Check formatting run: dart format . --set-exit-if-changed From a764848026a25590b38a0452c3205b5499e3910a Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 08:03:41 +0300 Subject: [PATCH 031/139] versions --- .github/workflows/on-pr-push-code-check.yml | 17 +++++++++++------ example/pubspec.yaml | 4 +++- pubspec.yaml | 4 +++- tools/add_imports/pubspec.yaml | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/on-pr-push-code-check.yml b/.github/workflows/on-pr-push-code-check.yml index b0a4fb3..194db84 100644 --- a/.github/workflows/on-pr-push-code-check.yml +++ b/.github/workflows/on-pr-push-code-check.yml @@ -27,6 +27,9 @@ jobs: - name: Setup dart uses: dart-lang/setup-dart@v1 + with: + # https://github.com/invertase/dart_edge/issues/50 + sdk: 3.0.0 - name: Get main dependencies run: dart pub get @@ -40,12 +43,14 @@ jobs: with: fatal-infos: true - - name: Dart Code Metrics - uses: solid-software/dart-code-metrics-action@v5 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - fatal_warnings: true - fatal_style: true + # https://github.com/invertase/dart_edge/issues/50 + # dcm action uses stable, which is >=3.1 already, so it doesn't work + # - name: Dart Code Metrics + # uses: solid-software/dart-code-metrics-action@v5 + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # fatal_warnings: true + # fatal_style: true - name: Check formatting run: dart format . --set-exit-if-changed diff --git a/example/pubspec.yaml b/example/pubspec.yaml index fc968b5..a3123a8 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,7 +4,9 @@ version: 1.0.0 publish_to: none environment: - sdk: ^3.0.0 + # https://github.com/invertase/dart_edge/issues/50 + # Tested with 3.0.6, but others should work too + sdk: '>=3.0.0 <3.1.0' dependencies: deno_postgres_interop: diff --git a/pubspec.yaml b/pubspec.yaml index 08ae5cb..27cc4a1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,9 @@ version: 0.0.1 repository: https://github.com/solid-software/deno_postgres_interop environment: - sdk: ^3.0.0 + # https://github.com/invertase/dart_edge/issues/50 + # Tested with 3.0.6, but others should work too + sdk: '>=3.0.0 <3.1.0' dev_dependencies: solid_lints: 0.0.19 diff --git a/tools/add_imports/pubspec.yaml b/tools/add_imports/pubspec.yaml index c5d5d16..a69e3c3 100644 --- a/tools/add_imports/pubspec.yaml +++ b/tools/add_imports/pubspec.yaml @@ -3,7 +3,7 @@ description: add_imports. version: 1.0.0 environment: - sdk: ^3.1.0 + sdk: ^3.0.0 dependencies: args: ^2.4.2 From f6bb9dcf537ffff92df0eb9a9ce566e67d4bdcbc Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 08:14:46 +0300 Subject: [PATCH 032/139] fix --- tools/add_imports/bin/add_imports.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/add_imports/bin/add_imports.dart b/tools/add_imports/bin/add_imports.dart index b7f7385..44dfbdb 100644 --- a/tools/add_imports/bin/add_imports.dart +++ b/tools/add_imports/bin/add_imports.dart @@ -39,7 +39,7 @@ String createNewSource(String sourceString, Config config) { .toList(); return [ - ...[config.importStringForClass, (e) => 'self.$e = $e'] + ...[config.importStringForClass, (e) => 'self.$e = $e;'] .map(classes.map) .flattened, sourceString, From 458db563975276c98ddde4b0d528e48622b8fccc Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 11:38:54 +0300 Subject: [PATCH 033/139] init? --- example/lib/main.dart | 3 ++- lib/src/query_client.dart | 11 ++++++----- lib/src/query_object.dart | 30 ++++++++++++++++++++++++++++++ lib/src/transaction.dart | 11 ++++++----- 4 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 lib/src/query_object.dart diff --git a/example/lib/main.dart b/example/lib/main.dart index aa7b6de..212791b 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -22,8 +22,9 @@ Future fetch(Request _) async { Future> transaction(Transaction transaction) async { await transaction.queryObject( 'UPDATE public."User" ' - "SET username='user${transaction.hashCode}' " + r'SET username=$1 ' "WHERE last_name='user'", + ["'user${transaction.hashCode}'" as dynamic], ); await Future.delayed(const Duration(seconds: 10)); diff --git a/lib/src/query_client.dart b/lib/src/query_client.dart index 96cf79a..220e711 100644 --- a/lib/src/query_client.dart +++ b/lib/src/query_client.dart @@ -1,6 +1,7 @@ import 'dart:js_interop'; import 'dart:js_util'; +import 'package:deno_postgres_interop/src/query_object.dart'; import 'package:deno_postgres_interop/src/query_object_result.dart'; import 'package:deno_postgres_interop/src/transaction.dart'; import 'package:deno_postgres_interop/src/transaction_options.dart'; @@ -46,9 +47,9 @@ extension QueryClientProps on QueryClient { } /// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). - Future> queryObject(String query) => callFutureMethod( - this, - 'queryObject', - [query], - ); + Future> queryObject( + String query, [ + QueryArguments arguments, + ]) => + queryObjectCommon(this, query, arguments); } diff --git a/lib/src/query_object.dart b/lib/src/query_object.dart new file mode 100644 index 0000000..a7b9bbb --- /dev/null +++ b/lib/src/query_object.dart @@ -0,0 +1,30 @@ +import 'package:deno_postgres_interop/deno_postgres_interop.dart'; +import 'package:deno_postgres_interop/src/util.dart'; + +/// [postgres@v0.17.0/QueryArguments](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryArguments) +typedef QueryArguments = Object?; + +/// Common method between all Clients. +/// +/// [postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_0). +/// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). +Future> queryObjectCommon( + Object queryable, + String query, [ + Object? arguments, +]) { + final isCorrectArgumentsType = arguments is List || + arguments is Map || + arguments == null; + + if (!isCorrectArgumentsType) throw 'Incorrect type for "arguments"'; + + return callFutureMethod( + queryable, + 'queryObject', + [ + query, + if (arguments != null) arguments, + ], + ); +} diff --git a/lib/src/transaction.dart b/lib/src/transaction.dart index e367c62..80bfe85 100644 --- a/lib/src/transaction.dart +++ b/lib/src/transaction.dart @@ -1,5 +1,6 @@ import 'dart:js_interop'; +import 'package:deno_postgres_interop/src/query_object.dart'; import 'package:deno_postgres_interop/src/query_object_result.dart'; import 'package:deno_postgres_interop/src/util.dart'; @@ -16,9 +17,9 @@ extension TransactionProps on Transaction { Future commit() => callFutureMethod(this, 'commit'); /// [postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_0). - Future> queryObject(String query) => callFutureMethod( - this, - 'queryObject', - [query], - ); + Future> queryObject( + String query, [ + QueryArguments arguments, + ]) => + queryObjectCommon(this, query, arguments); } From 96f8f1327114e47f5110d6f6a061d8dd903d548e Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 12:12:08 +0300 Subject: [PATCH 034/139] done? --- example/lib/main.dart | 2 +- lib/src/query_object.dart | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 212791b..b3a01fb 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -24,7 +24,7 @@ Future> transaction(Transaction transaction) async { 'UPDATE public."User" ' r'SET username=$1 ' "WHERE last_name='user'", - ["'user${transaction.hashCode}'" as dynamic], + ["'user${transaction.hashCode}'"], ); await Future.delayed(const Duration(seconds: 10)); diff --git a/lib/src/query_object.dart b/lib/src/query_object.dart index a7b9bbb..58ae571 100644 --- a/lib/src/query_object.dart +++ b/lib/src/query_object.dart @@ -13,11 +13,17 @@ Future> queryObjectCommon( String query, [ Object? arguments, ]) { - final isCorrectArgumentsType = arguments is List || + final isCorrectType = arguments is List || arguments is Map || arguments == null; - if (!isCorrectArgumentsType) throw 'Incorrect type for "arguments"'; + if (!isCorrectType) { + throw ArgumentError.value( + arguments, + 'arguments', + 'Accepted types are List and Map.', + ); + } return callFutureMethod( queryable, From 6ffc520c653a58e3e605930637fd66f38c781c62 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 12:14:51 +0300 Subject: [PATCH 035/139] fix --- lib/deno_postgres_interop.dart | 1 + lib/src/query_client.dart | 2 +- lib/src/query_object.dart | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/deno_postgres_interop.dart b/lib/deno_postgres_interop.dart index 1299943..720e5c9 100644 --- a/lib/deno_postgres_interop.dart +++ b/lib/deno_postgres_interop.dart @@ -4,6 +4,7 @@ library; export 'src/client.dart'; export 'src/isolation_level.dart'; export 'src/query_client.dart'; +export 'src/query_object.dart' show QueryArguments; export 'src/query_object_result.dart'; export 'src/transaction.dart'; export 'src/transaction_options.dart'; diff --git a/lib/src/query_client.dart b/lib/src/query_client.dart index 220e711..4c785ed 100644 --- a/lib/src/query_client.dart +++ b/lib/src/query_client.dart @@ -49,7 +49,7 @@ extension QueryClientProps on QueryClient { /// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). Future> queryObject( String query, [ - QueryArguments arguments, + QueryArguments? arguments, ]) => queryObjectCommon(this, query, arguments); } diff --git a/lib/src/query_object.dart b/lib/src/query_object.dart index 58ae571..491ff58 100644 --- a/lib/src/query_object.dart +++ b/lib/src/query_object.dart @@ -2,7 +2,7 @@ import 'package:deno_postgres_interop/deno_postgres_interop.dart'; import 'package:deno_postgres_interop/src/util.dart'; /// [postgres@v0.17.0/QueryArguments](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryArguments) -typedef QueryArguments = Object?; +typedef QueryArguments = Object; /// Common method between all Clients. /// @@ -11,7 +11,7 @@ typedef QueryArguments = Object?; Future> queryObjectCommon( Object queryable, String query, [ - Object? arguments, + QueryArguments? arguments, ]) { final isCorrectType = arguments is List || arguments is Map || From 305f2b88b2dbedcd7248333b861430f0836d5273 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 12:22:02 +0300 Subject: [PATCH 036/139] upd --- lib/src/transaction.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/transaction.dart b/lib/src/transaction.dart index 80bfe85..583595d 100644 --- a/lib/src/transaction.dart +++ b/lib/src/transaction.dart @@ -19,7 +19,7 @@ extension TransactionProps on Transaction { /// [postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_0). Future> queryObject( String query, [ - QueryArguments arguments, + QueryArguments? arguments, ]) => queryObjectCommon(this, query, arguments); } From 1612dfb8d5b152367d1fbce8c4dd1f604d542904 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 13:55:53 +0300 Subject: [PATCH 037/139] part --- lib/src/query_client.dart | 9 ++++++++- lib/src/session.dart | 21 +++++++++++++++++++++ lib/src/transport.dart | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 lib/src/session.dart create mode 100644 lib/src/transport.dart diff --git a/lib/src/query_client.dart b/lib/src/query_client.dart index 4c785ed..9a57a1a 100644 --- a/lib/src/query_client.dart +++ b/lib/src/query_client.dart @@ -3,16 +3,23 @@ import 'dart:js_util'; import 'package:deno_postgres_interop/src/query_object.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'; /// [postgres@v0.17.0/QueryClient](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient). @JS() -class QueryClient {} +class QueryClient { + /// [postgres@v0.17.0/QueryClient/session](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#accessor_session) + external Session get session; +} /// [postgres@v0.17.0/QueryClient](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient). extension QueryClientProps on QueryClient { + /// [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'); + /// [postgres@v0.17.0/QueryClient/connect](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_connect_0). Future connect() => callFutureMethod(this, 'connect'); diff --git a/lib/src/session.dart b/lib/src/session.dart new file mode 100644 index 0000000..29f235c --- /dev/null +++ b/lib/src/session.dart @@ -0,0 +1,21 @@ +import 'dart:js_interop'; +import 'dart:js_util'; + +import 'package:deno_postgres_interop/src/transport.dart'; + +/// https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session +@JS() +class Session { + external int? get pid; + external bool? get tls; +} + +extension SessionProps on Session { + String? get currentTransacton => getProperty(this, 'current_transaction'); + + Transport? get transport { + final string = getProperty(this, 'transport'); + + return string == null ? null : Transport.parse(string); + } +} diff --git a/lib/src/transport.dart b/lib/src/transport.dart new file mode 100644 index 0000000..bbd007b --- /dev/null +++ b/lib/src/transport.dart @@ -0,0 +1,14 @@ +/// This indicates the protocol used to connect to the database. +/// +/// The two supported transports are TCP and Unix sockets. +enum Transport { + /// TCP. + tcp, + + /// Unix sockets. + socket; + + /// Parses a string containing an [Transport] literal into its instance. + static Transport parse(String string) => + values.firstWhere((e) => e.name == string); +} From 209977ff403944577d709ee4429c220858ae45de Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 14:05:58 +0300 Subject: [PATCH 038/139] add placeholders --- lib/src/query_client.dart | 53 +++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/lib/src/query_client.dart b/lib/src/query_client.dart index 9a57a1a..7a32f3b 100644 --- a/lib/src/query_client.dart +++ b/lib/src/query_client.dart @@ -20,12 +20,16 @@ extension QueryClientProps on QueryClient { /// [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'); + /// [postgres@v0.17.0/QueryClient/closeConnection](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_closeConnection_0) + Future closeConnection() => callFutureMethod(this, 'closeConnection'); + + /// [postgres@v0.17.0/QueryClient/resetSessionMetadata](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_resetSessionMetadata_0) + Future resetSessionMetadata() => + callFutureMethod(this, 'resetSessionMetadata'); + /// [postgres@v0.17.0/QueryClient/connect](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_connect_0). Future connect() => callFutureMethod(this, 'connect'); - /// [postgres@v0.17.0/QueryClient/end](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_end_0). - Future end() => callFutureMethod(this, 'end'); - /// [postgres@v0.17.0/QueryClient/createTransaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_createTransaction_0). Transaction createTransaction(String name, [TransactionOptions? options]) => callMethod( @@ -37,6 +41,42 @@ extension QueryClientProps on QueryClient { ], ); + /// [postgres@v0.17.0/QueryClient/end](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_end_0). + Future end() => callFutureMethod(this, 'end'); + + // queryArray>( + // query: string, + // args?: QueryArguments, + // ): Promise> + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_0 + + // queryArray>( + // config: QueryOptions + // ): Promise> + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_1 + + // queryArray>( + // strings: TemplateStringsArray, + // ...args: unknown[], + // ): Promise> + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_2 + + /// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). + Future> queryObject( + String query, [ + QueryArguments? arguments, + ]) => + queryObjectCommon(this, query, arguments); + + // queryObject(config: QueryObjectOptions): Promise> + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_1 + + // queryObject( + // query: TemplateStringsArray, + // ...args: unknown[], + // ): Promise> + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_2 + /// Convinience wrapper for [createTransaction], /// [TransactionProps.begin], /// and [TransactionProps.commit]. @@ -52,11 +92,4 @@ extension QueryClientProps on QueryClient { return result; } - - /// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). - Future> queryObject( - String query, [ - QueryArguments? arguments, - ]) => - queryObjectCommon(this, query, arguments); } From f773417a69352453e2afcbe4cbdade6b13848739 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 14:14:25 +0300 Subject: [PATCH 039/139] exports --- lib/deno_postgres_interop.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/deno_postgres_interop.dart b/lib/deno_postgres_interop.dart index 720e5c9..ebcff42 100644 --- a/lib/deno_postgres_interop.dart +++ b/lib/deno_postgres_interop.dart @@ -6,5 +6,7 @@ export 'src/isolation_level.dart'; export 'src/query_client.dart'; export 'src/query_object.dart' show QueryArguments; export 'src/query_object_result.dart'; +export 'src/session.dart'; export 'src/transaction.dart'; export 'src/transaction_options.dart'; +export 'src/transport.dart'; From c1fd25bf3c00ad0f4811a6962bfa9f43c5a37cb6 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 14:17:04 +0300 Subject: [PATCH 040/139] fixes --- lib/src/isolation_level.dart | 2 +- lib/src/session.dart | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/isolation_level.dart b/lib/src/isolation_level.dart index 3b2016a..ff7179c 100644 --- a/lib/src/isolation_level.dart +++ b/lib/src/isolation_level.dart @@ -1,4 +1,4 @@ -/// https://www.postgresql.org/docs/current/transaction-iso.html +/// [postgresql/Transaction Isolation](https://www.postgresql.org/docs/current/transaction-iso.html) enum IsolationLevel { /// [postgresql/Transaction Isolation/Read Committed Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-READ-COMMITTED) readCommitted, diff --git a/lib/src/session.dart b/lib/src/session.dart index 29f235c..cf63b01 100644 --- a/lib/src/session.dart +++ b/lib/src/session.dart @@ -3,13 +3,14 @@ import 'dart:js_util'; import 'package:deno_postgres_interop/src/transport.dart'; -/// https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session +/// [deno-postgres@v0.17.0/Session](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Session). @JS() class Session { external int? get pid; 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 { String? get currentTransacton => getProperty(this, 'current_transaction'); From a21505eb05f4d4c351391e24211618c55d50e167 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 14:19:00 +0300 Subject: [PATCH 041/139] fixes --- lib/src/isolation_level.dart | 8 ++++---- lib/src/query_client.dart | 8 ++++---- lib/src/query_object.dart | 2 +- lib/src/transaction_options.dart | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/src/isolation_level.dart b/lib/src/isolation_level.dart index ff7179c..afb85bf 100644 --- a/lib/src/isolation_level.dart +++ b/lib/src/isolation_level.dart @@ -1,12 +1,12 @@ -/// [postgresql/Transaction Isolation](https://www.postgresql.org/docs/current/transaction-iso.html) +/// [postgresql/Transaction Isolation](https://www.postgresql.org/docs/current/transaction-iso.html). enum IsolationLevel { - /// [postgresql/Transaction Isolation/Read Committed Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-READ-COMMITTED) + /// [postgresql/Transaction Isolation/Read Committed Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-READ-COMMITTED). readCommitted, - /// [postgresql/Transaction Isolation/Repeatable Read Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-REPEATABLE-READ) + /// [postgresql/Transaction Isolation/Repeatable Read Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-REPEATABLE-READ). repeatableRead, - /// [postgresql/Transaction Isolation/Serializable Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-SERIALIZABLE) + /// [postgresql/Transaction Isolation/Serializable Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-SERIALIZABLE). serializable; /// Parses a string containing an [IsolationLevel] literal into its instance. diff --git a/lib/src/query_client.dart b/lib/src/query_client.dart index 7a32f3b..8596b0a 100644 --- a/lib/src/query_client.dart +++ b/lib/src/query_client.dart @@ -11,19 +11,19 @@ import 'package:deno_postgres_interop/src/util.dart'; /// [postgres@v0.17.0/QueryClient](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient). @JS() class QueryClient { - /// [postgres@v0.17.0/QueryClient/session](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#accessor_session) + /// [postgres@v0.17.0/QueryClient/session](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#accessor_session). external Session get session; } /// [postgres@v0.17.0/QueryClient](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient). extension QueryClientProps on QueryClient { - /// [postgres@v0.17.0/QueryClient/connected](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#accessor_connected) + /// [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'); - /// [postgres@v0.17.0/QueryClient/closeConnection](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_closeConnection_0) + /// [postgres@v0.17.0/QueryClient/closeConnection](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_closeConnection_0). Future closeConnection() => callFutureMethod(this, 'closeConnection'); - /// [postgres@v0.17.0/QueryClient/resetSessionMetadata](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_resetSessionMetadata_0) + /// [postgres@v0.17.0/QueryClient/resetSessionMetadata](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_resetSessionMetadata_0). Future resetSessionMetadata() => callFutureMethod(this, 'resetSessionMetadata'); diff --git a/lib/src/query_object.dart b/lib/src/query_object.dart index 491ff58..ed0074d 100644 --- a/lib/src/query_object.dart +++ b/lib/src/query_object.dart @@ -1,7 +1,7 @@ import 'package:deno_postgres_interop/deno_postgres_interop.dart'; import 'package:deno_postgres_interop/src/util.dart'; -/// [postgres@v0.17.0/QueryArguments](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryArguments) +/// [postgres@v0.17.0/QueryArguments](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryArguments). typedef QueryArguments = Object; /// Common method between all Clients. diff --git a/lib/src/transaction_options.dart b/lib/src/transaction_options.dart index 20fa52d..bb1c924 100644 --- a/lib/src/transaction_options.dart +++ b/lib/src/transaction_options.dart @@ -3,13 +3,13 @@ import 'dart:js_util'; import 'package:deno_postgres_interop/src/isolation_level.dart'; -/// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) +/// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). @JS() class TransactionOptions { - /// [postgres@v0.17.0/TransactionOptions/snapshot](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) + /// [postgres@v0.17.0/TransactionOptions/snapshot](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). external String? get snapshot; - /// [postgres@v0.17.0/TransactionOptions/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) + /// [postgres@v0.17.0/TransactionOptions/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). factory TransactionOptions({ IsolationLevel? isolationLevel, bool? isReadOnly, @@ -22,15 +22,15 @@ class TransactionOptions { }) as TransactionOptions; } -/// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) +/// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). extension TransactionOptionsProps on TransactionOptions { - /// [postgres@v0.17.0/TransactionOptions/isolation_level](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) + /// [postgres@v0.17.0/TransactionOptions/isolation_level](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). IsolationLevel? get isolationLevel { final jsProperty = getProperty(this, 'isolation_level'); return jsProperty == null ? null : IsolationLevel.parse(jsProperty); } - /// [postgres@v0.17.0/TransactionOptions/read_only](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) + /// [postgres@v0.17.0/TransactionOptions/read_only](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). bool? get isReadOnly => getProperty(this, 'read_only'); } From 4b4a4ecf05b7d23e3d0f0b31b1e04d33271c7fed Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 14:20:26 +0300 Subject: [PATCH 042/139] more fixes --- lib/src/session.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/session.dart b/lib/src/session.dart index cf63b01..083fb31 100644 --- a/lib/src/session.dart +++ b/lib/src/session.dart @@ -6,14 +6,19 @@ 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(this, 'transport'); From 242629aa8a4f875ab20a2ba33b1fa9a7b658a801 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 14:22:07 +0300 Subject: [PATCH 043/139] source --- lib/src/transport.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/transport.dart b/lib/src/transport.dart index bbd007b..f3116cc 100644 --- a/lib/src/transport.dart +++ b/lib/src/transport.dart @@ -1,6 +1,7 @@ /// This indicates the protocol used to connect to the database. /// /// The two supported transports are TCP and Unix sockets. +/// [source](https://deno.land/x/postgres@v0.17.0/client.ts?source=#L43) enum Transport { /// TCP. tcp, From 8bde0c3ef119c7401e2da33a338ee11042c0a141 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 19:37:45 +0300 Subject: [PATCH 044/139] todo --- lib/src/query_client.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/query_client.dart b/lib/src/query_client.dart index 8596b0a..27172df 100644 --- a/lib/src/query_client.dart +++ b/lib/src/query_client.dart @@ -44,17 +44,20 @@ extension QueryClientProps on QueryClient { /// [postgres@v0.17.0/QueryClient/end](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_end_0). Future end() => callFutureMethod(this, 'end'); + // TODO: // queryArray>( // query: string, // args?: QueryArguments, // ): Promise> // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_0 + // TODO: // queryArray>( // config: QueryOptions // ): Promise> // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_1 + // TODO: // queryArray>( // strings: TemplateStringsArray, // ...args: unknown[], @@ -68,9 +71,11 @@ extension QueryClientProps on QueryClient { ]) => queryObjectCommon(this, query, arguments); + // TODO: // queryObject(config: QueryObjectOptions): Promise> // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_1 + // TODO: // queryObject( // query: TemplateStringsArray, // ...args: unknown[], From 42967fe28eba1dd99c2702e14840effbb7b6d125 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 19:59:13 +0300 Subject: [PATCH 045/139] clientOptions --- lib/src/client.dart | 10 ++++++++++ lib/src/client_options.dart | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 lib/src/client_options.dart diff --git a/lib/src/client.dart b/lib/src/client.dart index d989c45..f0e252f 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -1,5 +1,8 @@ import 'dart:js_interop'; +import 'dart:js_util'; +import 'package:deno_postgres_interop/deno_postgres_interop.dart'; +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). @@ -7,4 +10,11 @@ import 'package:deno_postgres_interop/src/query_client.dart'; 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); } diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart new file mode 100644 index 0000000..cb3533f --- /dev/null +++ b/lib/src/client_options.dart @@ -0,0 +1,36 @@ +import 'dart:js_interop'; + +/// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions) +@JS() +class ClientOptions { + /// [deno-postgres@v0.17.0/]() + external String get applicationName; + + /// [deno-postgres@v0.17.0/]() + // external Partial get connection; + + /// [deno-postgres@v0.17.0/]() + external String get database; + + /// [deno-postgres@v0.17.0/]() + external String get hostname; + + // TODO: convert + /// [deno-postgres@v0.17.0/]() + // external Transport get host_type; + + /// [deno-postgres@v0.17.0/]() + // external String | Record get options; + + /// [deno-postgres@v0.17.0/]() + external String get password; + + /// [deno-postgres@v0.17.0/]() + // external String | number get port; + + /// [deno-postgres@v0.17.0/]() + // external Partial get tls; + + /// [deno-postgres@v0.17.0/]() + external String get user; +} From 832646f767f209883c3d3eaca2cbdfa3cc8bd47c Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 14 Sep 2023 20:41:15 +0300 Subject: [PATCH 046/139] info --- README.md | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/README.md b/README.md index 05204a5..7f267ef 100644 --- a/README.md +++ b/README.md @@ -42,3 +42,81 @@ The main scenario is Supabase Edge Functions, but it should also work for other Note: your filename may differ from the example 5. You can use the function now. + +## Implemented classes/types/interfaces +- [ ] mod.ts + - [ ] Client + - [ ] constructor + - [ ] with no parameters + - [x] `ConnectionString` + - [ ] `ClientOptions` + - [ ] ConnectionError + - [ ] Pool + - [ ] PoolClient + - [ ] PostgresError + - [ ] QueryClient + - [ ] connected + - [ ] session + - [ ] closeConnection + - [ ] resetSessionMetadata + - [ ] connect + - [ ] createTransaction + - [ ] end + - [ ] queryArray + - [ ] `(query: string, args?: QueryArguments)` + - [ ] `(config: QueryOptions)` + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] queryObject + - [ ] `(query: string, args?: QueryArguments)` + - [ ] `(config: QueryObjectOptions)` + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] Savepoint + - [ ] Transaction + - [ ] isolation_level + - [ ] savepoints + - [ ] begin + - [ ] commit + - [ ] getSavepoint + - [ ] getSavepoints + - [ ] getSnapshot + - [ ] queryArray + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] `(config: QueryOptions)` + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] queryObject + - [ ] `(query: string, args?: QueryArguments)` + - [ ] `(config: QueryObjectOptions)` + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] rollback + - [ ] `(savepoint?: string | Savepoint)` + - [ ] `(options?: { savepoint?: string | Savepoint; })` + - [ ] `(options?: { chain?: boolean; })` + - [ ] savepoint + - [ ] TransactionError + - [ ] ClientOptions + - [ ] applicationName: string + - [ ] connection + - [ ] database + - [ ] hostname + - [ ] host_type + - [ ] options + - [ ] password + - [ ] port + - [ ] tls + - [ ] user + - [ ] ConnectionOptions + - [ ] QueryOobjectOptions + - [ ] QueryOptions + - [ ] Session + - [ ] current_transaction + - [ ] pid + - [ ] tls + - [ ] transport + - [ ] TLSOptions + - [x] ConnectionString + - [x] TransactionOptions + +- [ ] deps.ts +- client.ts - see mod.ts +- pool.ts - see mod.ts + From 5bed91cf262c83f2637a1b7883d1167855823b68 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 08:48:57 +0300 Subject: [PATCH 047/139] remove things that are implemented --- README.md | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/README.md b/README.md index 7f267ef..171c2fe 100644 --- a/README.md +++ b/README.md @@ -43,39 +43,28 @@ The main scenario is Supabase Edge Functions, but it should also work for other 5. You can use the function now. -## Implemented classes/types/interfaces +## Unimplemented - [ ] mod.ts - [ ] Client - [ ] constructor - [ ] with no parameters - - [x] `ConnectionString` - [ ] `ClientOptions` - [ ] ConnectionError - [ ] Pool - [ ] PoolClient - [ ] PostgresError - [ ] QueryClient - - [ ] connected - - [ ] session - - [ ] closeConnection - - [ ] resetSessionMetadata - - [ ] connect - - [ ] createTransaction - - [ ] end - [ ] queryArray - [ ] `(query: string, args?: QueryArguments)` - [ ] `(config: QueryOptions)` - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - [ ] queryObject - - [ ] `(query: string, args?: QueryArguments)` - [ ] `(config: QueryObjectOptions)` - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - [ ] Savepoint - [ ] Transaction - [ ] isolation_level - [ ] savepoints - - [ ] begin - - [ ] commit - [ ] getSavepoint - [ ] getSavepoints - [ ] getSnapshot @@ -84,7 +73,6 @@ The main scenario is Supabase Edge Functions, but it should also work for other - [ ] `(config: QueryOptions)` - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - [ ] queryObject - - [ ] `(query: string, args?: QueryArguments)` - [ ] `(config: QueryObjectOptions)` - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - [ ] rollback @@ -94,16 +82,11 @@ The main scenario is Supabase Edge Functions, but it should also work for other - [ ] savepoint - [ ] TransactionError - [ ] ClientOptions - - [ ] applicationName: string - [ ] connection - - [ ] database - - [ ] hostname - [ ] host_type - [ ] options - - [ ] password - [ ] port - [ ] tls - - [ ] user - [ ] ConnectionOptions - [ ] QueryOobjectOptions - [ ] QueryOptions @@ -113,8 +96,6 @@ The main scenario is Supabase Edge Functions, but it should also work for other - [ ] tls - [ ] transport - [ ] TLSOptions - - [x] ConnectionString - - [x] TransactionOptions - [ ] deps.ts - client.ts - see mod.ts From 44905a2ca31f83873fbe076b75769e58d2afe8cf Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 08:59:42 +0300 Subject: [PATCH 048/139] simplify checklist --- README.md | 103 ++++++++++++++++++++++++------------------------------ 1 file changed, 46 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index 171c2fe..2764112 100644 --- a/README.md +++ b/README.md @@ -44,60 +44,49 @@ The main scenario is Supabase Edge Functions, but it should also work for other 5. You can use the function now. ## Unimplemented -- [ ] mod.ts - - [ ] Client - - [ ] constructor - - [ ] with no parameters - - [ ] `ClientOptions` - - [ ] ConnectionError - - [ ] Pool - - [ ] PoolClient - - [ ] PostgresError - - [ ] QueryClient - - [ ] queryArray - - [ ] `(query: string, args?: QueryArguments)` - - [ ] `(config: QueryOptions)` - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - - [ ] queryObject - - [ ] `(config: QueryObjectOptions)` - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - - [ ] Savepoint - - [ ] Transaction - - [ ] isolation_level - - [ ] savepoints - - [ ] getSavepoint - - [ ] getSavepoints - - [ ] getSnapshot - - [ ] queryArray - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - - [ ] `(config: QueryOptions)` - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - - [ ] queryObject - - [ ] `(config: QueryObjectOptions)` - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - - [ ] rollback - - [ ] `(savepoint?: string | Savepoint)` - - [ ] `(options?: { savepoint?: string | Savepoint; })` - - [ ] `(options?: { chain?: boolean; })` - - [ ] savepoint - - [ ] TransactionError - - [ ] ClientOptions - - [ ] connection - - [ ] host_type - - [ ] options - - [ ] port - - [ ] tls - - [ ] ConnectionOptions - - [ ] QueryOobjectOptions - - [ ] QueryOptions - - [ ] Session - - [ ] current_transaction - - [ ] pid - - [ ] tls - - [ ] transport - - [ ] TLSOptions - -- [ ] deps.ts -- client.ts - see mod.ts -- pool.ts - see mod.ts - +- [ ] Client + - [ ] constructor + - [ ] with no parameters + - [ ] `ClientOptions` +- [ ] ConnectionError +- [ ] Pool +- [ ] PoolClient +- [ ] PostgresError +- [ ] QueryClient + - [ ] queryArray + - [ ] `(query: string, args?: QueryArguments)` + - [ ] `(config: QueryOptions)` + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] queryObject + - [ ] `(config: QueryObjectOptions)` + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` +- [ ] Savepoint +- [ ] Transaction + - [ ] isolation_level + - [ ] savepoints + - [ ] getSavepoint + - [ ] getSavepoints + - [ ] getSnapshot + - [ ] queryArray + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] `(config: QueryOptions)` + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] queryObject + - [ ] `(config: QueryObjectOptions)` + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] rollback + - [ ] `(savepoint?: string | Savepoint)` + - [ ] `(options?: { savepoint?: string | Savepoint; })` + - [ ] `(options?: { chain?: boolean; })` + - [ ] savepoint +- [ ] TransactionError +- [ ] ClientOptions + - [ ] connection + - [ ] host_type + - [ ] options + - [ ] port + - [ ] tls +- [ ] ConnectionOptions +- [ ] QueryOobjectOptions +- [ ] QueryOptions +- [ ] TLSOptions From 8954ba7b8e69f472d7600fd114e383c10d288b0e Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 09:00:58 +0300 Subject: [PATCH 049/139] align --- README.md | 64 +++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 2764112..b0b17ed 100644 --- a/README.md +++ b/README.md @@ -45,47 +45,47 @@ The main scenario is Supabase Edge Functions, but it should also work for other ## Unimplemented - [ ] Client - - [ ] constructor - - [ ] with no parameters - - [ ] `ClientOptions` + - [ ] constructor + - [ ] with no parameters + - [ ] `ClientOptions` - [ ] ConnectionError - [ ] Pool - [ ] PoolClient - [ ] PostgresError - [ ] QueryClient - - [ ] queryArray - - [ ] `(query: string, args?: QueryArguments)` - - [ ] `(config: QueryOptions)` - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - - [ ] queryObject - - [ ] `(config: QueryObjectOptions)` - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] queryArray + - [ ] `(query: string, args?: QueryArguments)` + - [ ] `(config: QueryOptions)` + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] queryObject + - [ ] `(config: QueryObjectOptions)` + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - [ ] Savepoint - [ ] Transaction - - [ ] isolation_level - - [ ] savepoints - - [ ] getSavepoint - - [ ] getSavepoints - - [ ] getSnapshot - - [ ] queryArray - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - - [ ] `(config: QueryOptions)` - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - - [ ] queryObject - - [ ] `(config: QueryObjectOptions)` - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - - [ ] rollback - - [ ] `(savepoint?: string | Savepoint)` - - [ ] `(options?: { savepoint?: string | Savepoint; })` - - [ ] `(options?: { chain?: boolean; })` - - [ ] savepoint + - [ ] isolation_level + - [ ] savepoints + - [ ] getSavepoint + - [ ] getSavepoints + - [ ] getSnapshot + - [ ] queryArray + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] `(config: QueryOptions)` + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] queryObject + - [ ] `(config: QueryObjectOptions)` + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] rollback + - [ ] `(savepoint?: string | Savepoint)` + - [ ] `(options?: { savepoint?: string | Savepoint; })` + - [ ] `(options?: { chain?: boolean; })` + - [ ] savepoint - [ ] TransactionError - [ ] ClientOptions - - [ ] connection - - [ ] host_type - - [ ] options - - [ ] port - - [ ] tls + - [ ] connection + - [ ] host_type + - [ ] options + - [ ] port + - [ ] tls - [ ] ConnectionOptions - [ ] QueryOobjectOptions - [ ] QueryOptions From bb547a36890560b1ffb5052715b1562d63c03bbb Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 09:02:45 +0300 Subject: [PATCH 050/139] extract checklist --- README.md | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b0b17ed..80acfb3 100644 --- a/README.md +++ b/README.md @@ -53,13 +53,6 @@ The main scenario is Supabase Edge Functions, but it should also work for other - [ ] PoolClient - [ ] PostgresError - [ ] QueryClient - - [ ] queryArray - - [ ] `(query: string, args?: QueryArguments)` - - [ ] `(config: QueryOptions)` - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - - [ ] queryObject - - [ ] `(config: QueryObjectOptions)` - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - [ ] Savepoint - [ ] Transaction - [ ] isolation_level @@ -67,13 +60,6 @@ The main scenario is Supabase Edge Functions, but it should also work for other - [ ] getSavepoint - [ ] getSavepoints - [ ] getSnapshot - - [ ] queryArray - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - - [ ] `(config: QueryOptions)` - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - - [ ] queryObject - - [ ] `(config: QueryObjectOptions)` - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - [ ] rollback - [ ] `(savepoint?: string | Savepoint)` - [ ] `(options?: { savepoint?: string | Savepoint; })` @@ -90,3 +76,12 @@ The main scenario is Supabase Edge Functions, but it should also work for other - [ ] QueryOobjectOptions - [ ] QueryOptions - [ ] TLSOptions + +Common for clients: + - [ ] queryArray + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] `(config: QueryOptions)` + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` + - [ ] queryObject + - [ ] `(config: QueryObjectOptions)` + - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` From 2b3ca574ef9a1098920d96b6c2622a75d173bd86 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 09:08:13 +0300 Subject: [PATCH 051/139] more implemented --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 80acfb3..fa00c4b 100644 --- a/README.md +++ b/README.md @@ -44,10 +44,6 @@ The main scenario is Supabase Edge Functions, but it should also work for other 5. You can use the function now. ## Unimplemented -- [ ] Client - - [ ] constructor - - [ ] with no parameters - - [ ] `ClientOptions` - [ ] ConnectionError - [ ] Pool - [ ] PoolClient From f388fcdedf65b5d8a08390782ac4e14c3c447866 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 10:55:02 +0300 Subject: [PATCH 052/139] upd --- README.md | 11 ++----- lib/src/savepoint.dart | 5 ++++ lib/src/transaction.dart | 64 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 lib/src/savepoint.dart diff --git a/README.md b/README.md index fa00c4b..ccb96a9 100644 --- a/README.md +++ b/README.md @@ -51,15 +51,10 @@ The main scenario is Supabase Edge Functions, but it should also work for other - [ ] QueryClient - [ ] Savepoint - [ ] Transaction - - [ ] isolation_level - - [ ] savepoints - - [ ] getSavepoint - - [ ] getSavepoints - - [ ] getSnapshot + - [ ] constructor - [ ] rollback - - [ ] `(savepoint?: string | Savepoint)` - - [ ] `(options?: { savepoint?: string | Savepoint; })` - - [ ] `(options?: { chain?: boolean; })` + - [ ] `(options: { savepoint?: string | Savepoint; })` + - [ ] `(options: { chain?: boolean; })` - [ ] savepoint - [ ] TransactionError - [ ] ClientOptions diff --git a/lib/src/savepoint.dart b/lib/src/savepoint.dart new file mode 100644 index 0000000..8c54280 --- /dev/null +++ b/lib/src/savepoint.dart @@ -0,0 +1,5 @@ +import 'dart:js_interop'; + +// TODO: +@JS() +class Savepoint {} diff --git a/lib/src/transaction.dart b/lib/src/transaction.dart index 583595d..b57d211 100644 --- a/lib/src/transaction.dart +++ b/lib/src/transaction.dart @@ -1,25 +1,87 @@ import 'dart:js_interop'; +import 'dart:js_util'; +import 'package:deno_postgres_interop/src/isolation_level.dart'; import 'package:deno_postgres_interop/src/query_object.dart'; import 'package:deno_postgres_interop/src/query_object_result.dart'; +import 'package:deno_postgres_interop/src/savepoint.dart'; import 'package:deno_postgres_interop/src/util.dart'; /// [postgres@v0.17.0/Transaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction). @JS() -class Transaction {} +class Transaction { + external List get savepoints; + external Savepoint? getSavepoint(String name); +} /// [postgres@v0.17.0/Transaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction). extension TransactionProps on Transaction { + /// [postgres@v0.17.0/Transaction/isolation_level](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#accessor_isolation_level). + IsolationLevel get isolationLevel => getProperty(this, 'isolation_name'); + /// [postgres@v0.17.0/Transaction/begin](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_begin_0). Future begin() => callFutureMethod(this, 'begin'); /// [postgres@v0.17.0/Transaction/commit](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_commit_0). Future commit() => callFutureMethod(this, 'commit'); + List getActiveSavepointsNames() => + callMethod(this, 'getSavepoints', []); + + Future get snapshot => callFutureMethod(this, 'getSnapshot'); + + // TODO: + // queryArray>( + // query: string, + // args?: QueryArguments, + // ): Promise> + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_0 + + // TODO: + // queryArray>( + // config: QueryOptions + // ): Promise> + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_1 + + // TODO: + // queryArray>( + // strings: TemplateStringsArray, + // ...args: unknown[], + // ): Promise> + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_2 + /// [postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_0). Future> queryObject( String query, [ QueryArguments? arguments, ]) => queryObjectCommon(this, query, arguments); + + // TODO: + // queryObject(config: QueryObjectOptions): Promise> + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_1 + + // TODO: + // queryObject( + // query: TemplateStringsArray, + // ...args: unknown[], + // ): Promise> + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_2 + + Future rollback(Savepoint? savepoint) => callFutureMethod( + this, + 'rollback', + [if (savepoint != null) savepoint], + ); + + // TODO: + // rollback(options?: { savepoint?: string | Savepoint; }): Promise + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_rollback_1 + + // TODO: + // rollback(options?: { chain?: boolean; }): Promise + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_rollback_2 + + Future rollbackByName(String savepoint) => + callFutureMethod(this, 'rollback', [savepoint]); } From 6fa5994e62de91d58c1f4b35b5cddb59974785ed Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 11:02:27 +0300 Subject: [PATCH 053/139] upd --- README.md | 1 - lib/src/transaction.dart | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ccb96a9..69942d9 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,6 @@ The main scenario is Supabase Edge Functions, but it should also work for other - [ ] rollback - [ ] `(options: { savepoint?: string | Savepoint; })` - [ ] `(options: { chain?: boolean; })` - - [ ] savepoint - [ ] TransactionError - [ ] ClientOptions - [ ] connection diff --git a/lib/src/transaction.dart b/lib/src/transaction.dart index b57d211..252bb93 100644 --- a/lib/src/transaction.dart +++ b/lib/src/transaction.dart @@ -84,4 +84,7 @@ extension TransactionProps on Transaction { Future rollbackByName(String savepoint) => callFutureMethod(this, 'rollback', [savepoint]); + + Future createSavepoint(String name) => + callFutureMethod(this, 'savepoint', [name]); } From 34c4fec81761868c4baca30aebb5ef8b3e13fb3a Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 11:42:13 +0300 Subject: [PATCH 054/139] Savepoint --- README.md | 1 - lib/src/client.dart | 2 +- lib/src/promise.dart | 21 +++++++++++++++++++++ lib/src/savepoint.dart | 25 ++++++++++++++++++++++++- 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 lib/src/promise.dart diff --git a/README.md b/README.md index 69942d9..8101c56 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,6 @@ The main scenario is Supabase Edge Functions, but it should also work for other - [ ] PoolClient - [ ] PostgresError - [ ] QueryClient -- [ ] Savepoint - [ ] Transaction - [ ] constructor - [ ] rollback diff --git a/lib/src/client.dart b/lib/src/client.dart index f0e252f..ee914e6 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -16,5 +16,5 @@ class Client extends QueryClient { 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); + factory Client.empty() => callConstructor('Client', null); } diff --git a/lib/src/promise.dart b/lib/src/promise.dart new file mode 100644 index 0000000..63e5ab6 --- /dev/null +++ b/lib/src/promise.dart @@ -0,0 +1,21 @@ +import 'dart:js_interop'; +import 'dart:js_util'; + +typedef Resolver = void Function(T result); + +typedef Executor = void Function(Resolver resolve, Function reject); + +@JS() +class Promise { + external Promise(Executor executor); + + external Promise then(Resolver onFulfilled, [Function onRejected]); +} + +Promise futureToPromise(Future future) { + return Promise( + allowInterop((resolve, reject) { + future.then(resolve, onError: reject); + }), + ); +} diff --git a/lib/src/savepoint.dart b/lib/src/savepoint.dart index 8c54280..bd3ef11 100644 --- a/lib/src/savepoint.dart +++ b/lib/src/savepoint.dart @@ -1,5 +1,28 @@ import 'dart:js_interop'; +import 'dart:js_util'; + +import 'package:deno_postgres_interop/src/promise.dart'; +import 'package:deno_postgres_interop/src/util.dart'; // TODO: @JS() -class Savepoint {} +class Savepoint { + factory Savepoint( + String name, + Future Function(String name) updateCallback, + Future Function(String name) releaseCallback, + ) => + callConstructor('Savepoint', [ + name, + (String name) => futureToPromise(updateCallback(name)), + (String name) => futureToPromise(releaseCallback(name)), + ]); +} + +extension SavepointProps on Savepoint { + int get instancesCount => getProperty(this, 'instances'); + + Future release() => callFutureMethod(this, 'release'); + + Future update() => callFutureMethod(this, 'update'); +} From 9d788be636594e0f3633284b34a1d83fd0fb321a Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 13:22:09 +0300 Subject: [PATCH 055/139] fix comments --- lib/src/isolation_level.dart | 8 ++++---- lib/src/query_object.dart | 2 +- lib/src/transaction_options.dart | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/src/isolation_level.dart b/lib/src/isolation_level.dart index 3b2016a..afb85bf 100644 --- a/lib/src/isolation_level.dart +++ b/lib/src/isolation_level.dart @@ -1,12 +1,12 @@ -/// https://www.postgresql.org/docs/current/transaction-iso.html +/// [postgresql/Transaction Isolation](https://www.postgresql.org/docs/current/transaction-iso.html). enum IsolationLevel { - /// [postgresql/Transaction Isolation/Read Committed Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-READ-COMMITTED) + /// [postgresql/Transaction Isolation/Read Committed Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-READ-COMMITTED). readCommitted, - /// [postgresql/Transaction Isolation/Repeatable Read Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-REPEATABLE-READ) + /// [postgresql/Transaction Isolation/Repeatable Read Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-REPEATABLE-READ). repeatableRead, - /// [postgresql/Transaction Isolation/Serializable Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-SERIALIZABLE) + /// [postgresql/Transaction Isolation/Serializable Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-SERIALIZABLE). serializable; /// Parses a string containing an [IsolationLevel] literal into its instance. diff --git a/lib/src/query_object.dart b/lib/src/query_object.dart index 491ff58..ed0074d 100644 --- a/lib/src/query_object.dart +++ b/lib/src/query_object.dart @@ -1,7 +1,7 @@ import 'package:deno_postgres_interop/deno_postgres_interop.dart'; import 'package:deno_postgres_interop/src/util.dart'; -/// [postgres@v0.17.0/QueryArguments](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryArguments) +/// [postgres@v0.17.0/QueryArguments](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryArguments). typedef QueryArguments = Object; /// Common method between all Clients. diff --git a/lib/src/transaction_options.dart b/lib/src/transaction_options.dart index 20fa52d..bb1c924 100644 --- a/lib/src/transaction_options.dart +++ b/lib/src/transaction_options.dart @@ -3,13 +3,13 @@ import 'dart:js_util'; import 'package:deno_postgres_interop/src/isolation_level.dart'; -/// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) +/// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). @JS() class TransactionOptions { - /// [postgres@v0.17.0/TransactionOptions/snapshot](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) + /// [postgres@v0.17.0/TransactionOptions/snapshot](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). external String? get snapshot; - /// [postgres@v0.17.0/TransactionOptions/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) + /// [postgres@v0.17.0/TransactionOptions/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). factory TransactionOptions({ IsolationLevel? isolationLevel, bool? isReadOnly, @@ -22,15 +22,15 @@ class TransactionOptions { }) as TransactionOptions; } -/// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) +/// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). extension TransactionOptionsProps on TransactionOptions { - /// [postgres@v0.17.0/TransactionOptions/isolation_level](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) + /// [postgres@v0.17.0/TransactionOptions/isolation_level](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). IsolationLevel? get isolationLevel { final jsProperty = getProperty(this, 'isolation_level'); return jsProperty == null ? null : IsolationLevel.parse(jsProperty); } - /// [postgres@v0.17.0/TransactionOptions/read_only](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions) + /// [postgres@v0.17.0/TransactionOptions/read_only](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). bool? get isReadOnly => getProperty(this, 'read_only'); } From d14616ddb3108a98931512053c50ef4fc140fdf6 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 13:41:56 +0300 Subject: [PATCH 056/139] promise docs --- lib/src/promise.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/src/promise.dart b/lib/src/promise.dart index 63e5ab6..e8d3998 100644 --- a/lib/src/promise.dart +++ b/lib/src/promise.dart @@ -1,17 +1,17 @@ import 'dart:js_interop'; import 'dart:js_util'; -typedef Resolver = void Function(T result); - -typedef Executor = void Function(Resolver resolve, Function reject); +typedef _Resolver = void Function(T result); +typedef _Executor = void Function(_Resolver resolve, Function reject); +/// JS [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) interop. @JS() class Promise { - external Promise(Executor executor); - - external Promise then(Resolver onFulfilled, [Function onRejected]); + /// [js/Promise/constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise). + external Promise(_Executor executor); } +/// Convert darts [Future] to js' [Promise]. Promise futureToPromise(Future future) { return Promise( allowInterop((resolve, reject) { From 9985a6688493faa3adf149fb665dce68137f5f0f Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 13:44:23 +0300 Subject: [PATCH 057/139] savepoint comments --- lib/src/savepoint.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/src/savepoint.dart b/lib/src/savepoint.dart index bd3ef11..b80d2db 100644 --- a/lib/src/savepoint.dart +++ b/lib/src/savepoint.dart @@ -4,9 +4,10 @@ import 'dart:js_util'; import 'package:deno_postgres_interop/src/promise.dart'; import 'package:deno_postgres_interop/src/util.dart'; -// TODO: +/// [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 Function(String name) updateCallback, @@ -19,10 +20,14 @@ class Savepoint { ]); } +/// [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 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 update() => callFutureMethod(this, 'update'); } From 7dfe833f946a71f958e90913f4b31922c973bee7 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 14:03:30 +0300 Subject: [PATCH 058/139] ClientOptions comments --- lib/src/client_options.dart | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart index cb3533f..c4adac6 100644 --- a/lib/src/client_options.dart +++ b/lib/src/client_options.dart @@ -1,36 +1,39 @@ import 'dart:js_interop'; -/// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions) +/// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). @JS() class ClientOptions { - /// [deno-postgres@v0.17.0/]() + /// [deno-postgres@v0.17.0/ClientOptions/applicationName](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_applicationName). external String get applicationName; - /// [deno-postgres@v0.17.0/]() - // external Partial get connection; - - /// [deno-postgres@v0.17.0/]() + /// [deno-postgres@v0.17.0/ClientOptions/database](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_database). external String get database; - /// [deno-postgres@v0.17.0/]() + /// [deno-postgres@v0.17.0/ClientOptions/hostname](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_hostname). external String get hostname; + /// [deno-postgres@v0.17.0/ClientOptions/password](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_password). + external String get password; + + /// [deno-postgres@v0.17.0/ClientOptions/user](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_user). + external String get user; +} + +/// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). +extension ClientOptionsProps on ClientOptions { + /// [deno-postgres@v0.17.0/ClientOptions/connection](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_connection). + // external Partial get connection; + // TODO: convert - /// [deno-postgres@v0.17.0/]() + /// [deno-postgres@v0.17.0/ClientOptions/host_type](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_host_type). // external Transport get host_type; - /// [deno-postgres@v0.17.0/]() + /// [deno-postgres@v0.17.0/ClientOptions/options](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_options). // external String | Record get options; - /// [deno-postgres@v0.17.0/]() - external String get password; - - /// [deno-postgres@v0.17.0/]() + /// [deno-postgres@v0.17.0/ClientOptions/port](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_port). // external String | number get port; - /// [deno-postgres@v0.17.0/]() + /// [deno-postgres@v0.17.0/ClientOptions/tls](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_tls). // external Partial get tls; - - /// [deno-postgres@v0.17.0/]() - external String get user; } From c2328146bae0d78548fb1adb9c6b4c32bc55e8f6 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 14:08:38 +0300 Subject: [PATCH 059/139] hosttype --- lib/src/client_options.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart index c4adac6..eff0bae 100644 --- a/lib/src/client_options.dart +++ b/lib/src/client_options.dart @@ -1,4 +1,7 @@ import 'dart:js_interop'; +import 'dart:js_util'; + +import 'package:deno_postgres_interop/src/transport.dart'; /// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). @JS() @@ -24,9 +27,8 @@ extension ClientOptionsProps on ClientOptions { /// [deno-postgres@v0.17.0/ClientOptions/connection](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_connection). // external Partial get connection; - // TODO: convert /// [deno-postgres@v0.17.0/ClientOptions/host_type](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_host_type). - // external Transport get host_type; + Transport get hostType => Transport.parse(getProperty(this, 'host_type')); /// [deno-postgres@v0.17.0/ClientOptions/options](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_options). // external String | Record get options; From 62c347f0854ed5445767ccb4128ed8b6e9b81ef9 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 14:16:08 +0300 Subject: [PATCH 060/139] partialconnectionoptions upd --- lib/src/client_options.dart | 3 ++- lib/src/partial_connection_options.dart | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 lib/src/partial_connection_options.dart diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart index eff0bae..d5b5b56 100644 --- a/lib/src/client_options.dart +++ b/lib/src/client_options.dart @@ -1,6 +1,7 @@ import 'dart:js_interop'; import 'dart:js_util'; +import 'package:deno_postgres_interop/src/partial_connection_options.dart'; import 'package:deno_postgres_interop/src/transport.dart'; /// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). @@ -25,7 +26,7 @@ class ClientOptions { /// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). extension ClientOptionsProps on ClientOptions { /// [deno-postgres@v0.17.0/ClientOptions/connection](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_connection). - // external Partial get connection; + external PartialConnectionOptions get connection; /// [deno-postgres@v0.17.0/ClientOptions/host_type](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_host_type). Transport get hostType => Transport.parse(getProperty(this, 'host_type')); diff --git a/lib/src/partial_connection_options.dart b/lib/src/partial_connection_options.dart new file mode 100644 index 0000000..96a2b79 --- /dev/null +++ b/lib/src/partial_connection_options.dart @@ -0,0 +1,12 @@ +import 'dart:js_interop'; + +/// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ConnectionOptions) +/// but [partial](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype) (everything is optional). +@JS() +class PartialConnectionOptions { + /// [deno-postgres@v0.17.0/ConnectionOptions/attempts](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ConnectionOptions#prop_attempts). + external int? get attempts; + + /// [deno-postgres@v0.17.0/ConnectionOptions/interval](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ConnectionOptions#interval). + // external int? get interval; +} From 1017a5717ee45e6bb5ad5c6a2b0ce62416c0ad51 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 14:24:33 +0300 Subject: [PATCH 061/139] partialTLSOptions --- lib/src/partial_tls_options.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/src/partial_tls_options.dart diff --git a/lib/src/partial_tls_options.dart b/lib/src/partial_tls_options.dart new file mode 100644 index 0000000..26ff9f7 --- /dev/null +++ b/lib/src/partial_tls_options.dart @@ -0,0 +1,15 @@ +import 'dart:js_interop'; + +/// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TLSOptions) +/// but [partial](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype) (everything is optional). +@JS() +class PartialTLSOptions { + /// [deno-postgres@v0.17.0/ConnectionOptions/enabled](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TLSOptions#prop_enabled). + external bool? get enabled; + + /// [deno-postgres@v0.17.0/ConnectionOptions/enforce](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TLSOptions#prop_enforce). + external bool? get enforce; + + /// [deno-postgres@v0.17.0/ConnectionOptions/caCertificates](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TLSOptions#prop_caCertificates). + external List? get caCertificates; +} From 547a29c9164d3f4bab011ff5668c4fe7d28d96e2 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 14:28:23 +0300 Subject: [PATCH 062/139] uncomment --- lib/src/client_options.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart index d5b5b56..1756ef0 100644 --- a/lib/src/client_options.dart +++ b/lib/src/client_options.dart @@ -2,6 +2,7 @@ import 'dart:js_interop'; import 'dart:js_util'; import 'package:deno_postgres_interop/src/partial_connection_options.dart'; +import 'package:deno_postgres_interop/src/partial_tls_options.dart'; import 'package:deno_postgres_interop/src/transport.dart'; /// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). @@ -38,5 +39,5 @@ extension ClientOptionsProps on ClientOptions { // external String | number get port; /// [deno-postgres@v0.17.0/ClientOptions/tls](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_tls). - // external Partial get tls; + external PartialTLSOptions get tls; } From 196ee80c33094c8f05a46e09a499bacc711caefe Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 21:23:01 +0300 Subject: [PATCH 063/139] progress --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 8101c56..e7a102f 100644 --- a/README.md +++ b/README.md @@ -56,11 +56,8 @@ The main scenario is Supabase Edge Functions, but it should also work for other - [ ] `(options: { chain?: boolean; })` - [ ] TransactionError - [ ] ClientOptions - - [ ] connection - - [ ] host_type - [ ] options - [ ] port - - [ ] tls - [ ] ConnectionOptions - [ ] QueryOobjectOptions - [ ] QueryOptions From 14d1469d7104e6c3a6a0748bda8242fcb93a5a4c Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Fri, 15 Sep 2023 22:39:39 +0300 Subject: [PATCH 064/139] partially resolve queryObject --- lib/src/client_common.dart | 59 +++++++++++++++++++++++++++++++ lib/src/query_client.dart | 30 +++++++++++++++- lib/src/query_object.dart | 36 ------------------- lib/src/query_object_options.dart | 15 ++++++++ 4 files changed, 103 insertions(+), 37 deletions(-) create mode 100644 lib/src/client_common.dart delete mode 100644 lib/src/query_object.dart create mode 100644 lib/src/query_object_options.dart diff --git a/lib/src/client_common.dart b/lib/src/client_common.dart new file mode 100644 index 0000000..8fcc571 --- /dev/null +++ b/lib/src/client_common.dart @@ -0,0 +1,59 @@ +import 'package:deno_postgres_interop/deno_postgres_interop.dart'; +import 'package:deno_postgres_interop/src/query_object_options.dart'; +import 'package:deno_postgres_interop/src/util.dart'; + +/// [postgres@v0.17.0/QueryArguments](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryArguments). +typedef QueryArguments = Object; + +/// This class hosts common interops for clients. +class ClientCommon { + /// Common method between all Clients. + /// + /// [postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_0). + /// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). + static Future> queryObject( + Object queryable, + String query, [ + QueryArguments? arguments, + ]) { + final isCorrectType = arguments is List || + arguments is Map || + arguments == null; + + if (!isCorrectType) { + throw ArgumentError.value( + arguments, + 'arguments', + 'Accepted types are List and Map.', + ); + } + + return callFutureMethod( + queryable, + 'queryObject', + [ + query, + if (arguments != null) arguments, + ], + ); + } + + /// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_1). + static Future> queryObjectWithOptions( + QueryObjectOptions config, + ) => + throw UnimplementedError(); // TODO: + + // This one won't be implemented because it doesn't make much sense for dart, + // the query here is of type TemplateStringsArray which is used in + // [tagged templates](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates). + // + // [related issue](https://github.com/dart-lang/language/issues/1988). + // + // [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_2). + // Future> queryObjectWithOptions( + // List query, + // List args, + // ) => + // throw UnimplementedError(); +} diff --git a/lib/src/query_client.dart b/lib/src/query_client.dart index 4c785ed..2a2a1b6 100644 --- a/lib/src/query_client.dart +++ b/lib/src/query_client.dart @@ -1,7 +1,9 @@ import 'dart:js_interop'; import 'dart:js_util'; +import 'package:deno_postgres_interop/src/client_common.dart'; import 'package:deno_postgres_interop/src/query_object.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/transaction.dart'; import 'package:deno_postgres_interop/src/transaction_options.dart'; @@ -46,10 +48,36 @@ extension QueryClientProps on QueryClient { return result; } + // TODO: + // queryArray>( + // query: string, + // args?: QueryArguments, + // ): Promise> + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_0 + + // TODO: + // queryArray>( + // config: QueryOptions + // ): Promise> + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_1 + + // TODO: + // queryArray>( + // strings: TemplateStringsArray, + // ...args: unknown[], + // ): Promise> + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_2 + /// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). Future> queryObject( String query, [ QueryArguments? arguments, ]) => - queryObjectCommon(this, query, arguments); + ClientCommon.queryObject(this, query, arguments); + + /// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_1). + Future> queryObjectWithOptions( + QueryObjectOptions config, + ) => + ClientCommon.queryObjectWithOptions(config); } diff --git a/lib/src/query_object.dart b/lib/src/query_object.dart deleted file mode 100644 index ed0074d..0000000 --- a/lib/src/query_object.dart +++ /dev/null @@ -1,36 +0,0 @@ -import 'package:deno_postgres_interop/deno_postgres_interop.dart'; -import 'package:deno_postgres_interop/src/util.dart'; - -/// [postgres@v0.17.0/QueryArguments](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryArguments). -typedef QueryArguments = Object; - -/// Common method between all Clients. -/// -/// [postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_0). -/// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). -Future> queryObjectCommon( - Object queryable, - String query, [ - QueryArguments? arguments, -]) { - final isCorrectType = arguments is List || - arguments is Map || - arguments == null; - - if (!isCorrectType) { - throw ArgumentError.value( - arguments, - 'arguments', - 'Accepted types are List and Map.', - ); - } - - return callFutureMethod( - queryable, - 'queryObject', - [ - query, - if (arguments != null) arguments, - ], - ); -} diff --git a/lib/src/query_object_options.dart b/lib/src/query_object_options.dart new file mode 100644 index 0000000..ec6fa8e --- /dev/null +++ b/lib/src/query_object_options.dart @@ -0,0 +1,15 @@ +import 'dart:js_interop'; +import 'dart:js_util'; + +/// [postgres@v0.17.0/QueryObjectOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryObjectOptions). +@JS() +class QueryObjectOptions { + /// [postgres@v0.17.0/QueryObjectOptions/fields](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#prop_fields). + external List? get fields; +} + +/// [postgres@v0.17.0/QueryObjectOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryObjectOptions). +extension QueryObjectOptionsProps on QueryObjectOptions { + /// [postgres@v0.17.0/QueryObjectOptions/camelcase](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#prop_camelcase). + bool? get isCamelcase => getProperty(this, 'camelcase'); +} From 0f0a0c5f1fc8706a1c1da81a1325339c62ce808b Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 16:48:23 +0300 Subject: [PATCH 065/139] upd --- lib/src/client_common.dart | 31 +++++++++++++++++++++++++++++-- lib/src/query_array_result.dart | 6 ++++++ lib/src/query_client.dart | 31 ++++++++++++------------------- lib/src/query_object_result.dart | 4 +++- lib/src/query_result.dart | 4 ++++ 5 files changed, 54 insertions(+), 22 deletions(-) create mode 100644 lib/src/query_array_result.dart create mode 100644 lib/src/query_result.dart diff --git a/lib/src/client_common.dart b/lib/src/client_common.dart index 8fcc571..ec96288 100644 --- a/lib/src/client_common.dart +++ b/lib/src/client_common.dart @@ -1,4 +1,5 @@ import 'package:deno_postgres_interop/deno_postgres_interop.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/util.dart'; @@ -7,8 +8,33 @@ typedef QueryArguments = Object; /// This class hosts common interops for clients. class ClientCommon { - /// Common method between all Clients. - /// + /// [postgres@v0.17.0/Transaction/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryArray_0). + /// [postgres@v0.17.0/QueryClient/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_0). + static Future> queryArray( + String query, [ + QueryArguments? args, + ]) => + throw UnimplementedError(); // TODO: + + /// [postgres@v0.17.0/Transaction/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryArray_1). + /// [postgres@v0.17.0/QueryClient/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_1). + static Future> queryArrayWithOptions( + QueryObjectOptions config, + ) => + throw UnimplementedError(); // TODO: + + // This one won't be implemented because it doesn't make much sense for dart, + // the query here is of type TemplateStringsArray which is used in + // [tagged templates](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates). + // + // [related issue](https://github.com/dart-lang/language/issues/1988). + // + // queryArray>( + // strings: TemplateStringsArray, + // ...args: unknown[], + // ): Promise> + // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_2 + /// [postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_0). /// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). static Future> queryObject( @@ -38,6 +64,7 @@ class ClientCommon { ); } + /// [postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_1). /// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_1). static Future> queryObjectWithOptions( QueryObjectOptions config, diff --git a/lib/src/query_array_result.dart b/lib/src/query_array_result.dart new file mode 100644 index 0000000..01303e4 --- /dev/null +++ b/lib/src/query_array_result.dart @@ -0,0 +1,6 @@ +import 'dart:js_interop'; + +import 'package:deno_postgres_interop/src/query_result.dart'; + +@JS() +class QueryArrayResult extends QueryResult {} diff --git a/lib/src/query_client.dart b/lib/src/query_client.dart index 2a2a1b6..94aee17 100644 --- a/lib/src/query_client.dart +++ b/lib/src/query_client.dart @@ -2,7 +2,7 @@ import 'dart:js_interop'; import 'dart:js_util'; import 'package:deno_postgres_interop/src/client_common.dart'; -import 'package:deno_postgres_interop/src/query_object.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/transaction.dart'; @@ -48,25 +48,18 @@ extension QueryClientProps on QueryClient { return result; } - // TODO: - // queryArray>( - // query: string, - // args?: QueryArguments, - // ): Promise> - // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_0 - - // TODO: - // queryArray>( - // config: QueryOptions - // ): Promise> - // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_1 + /// [postgres@v0.17.0/QueryClient/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_0). + Future> queryArray( + String query, [ + QueryArguments? args, + ]) => + ClientCommon.queryArray(query, args); - // TODO: - // queryArray>( - // strings: TemplateStringsArray, - // ...args: unknown[], - // ): Promise> - // https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_2 + /// [postgres@v0.17.0/QueryClient/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_1). + Future> queryArrayWithOptions( + QueryObjectOptions config, + ) => + ClientCommon.queryArrayWithOptions(config); /// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). Future> queryObject( diff --git a/lib/src/query_object_result.dart b/lib/src/query_object_result.dart index 23ed729..815b490 100644 --- a/lib/src/query_object_result.dart +++ b/lib/src/query_object_result.dart @@ -1,9 +1,11 @@ import 'dart:js_interop'; import 'dart:js_util'; +import 'package:deno_postgres_interop/src/query_result.dart'; + /// [postgres@v0.17.0/QueryObjectResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult). @JS() -class QueryObjectResult { +class QueryObjectResult extends QueryResult { /// [postgres@v0.17.0/QueryObjectResult/columns](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult#prop_columns). external List? get columns; } diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart new file mode 100644 index 0000000..88e04d2 --- /dev/null +++ b/lib/src/query_result.dart @@ -0,0 +1,4 @@ +import 'dart:js_interop'; + +@JS() +class QueryResult {} From 4fbcdf46a064592aab6a5ad894de9b4e402e986a Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 16:52:25 +0300 Subject: [PATCH 066/139] upd --- lib/deno_postgres_interop.dart | 1 - lib/src/client_common.dart | 3 +++ lib/src/query_client.dart | 6 +++--- lib/src/transaction.dart | 25 +++++++++++++++++++++++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/lib/deno_postgres_interop.dart b/lib/deno_postgres_interop.dart index 720e5c9..1299943 100644 --- a/lib/deno_postgres_interop.dart +++ b/lib/deno_postgres_interop.dart @@ -4,7 +4,6 @@ library; export 'src/client.dart'; export 'src/isolation_level.dart'; export 'src/query_client.dart'; -export 'src/query_object.dart' show QueryArguments; export 'src/query_object_result.dart'; export 'src/transaction.dart'; export 'src/transaction_options.dart'; diff --git a/lib/src/client_common.dart b/lib/src/client_common.dart index ec96288..20d0c66 100644 --- a/lib/src/client_common.dart +++ b/lib/src/client_common.dart @@ -11,6 +11,7 @@ class ClientCommon { /// [postgres@v0.17.0/Transaction/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryArray_0). /// [postgres@v0.17.0/QueryClient/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_0). static Future> queryArray( + Object queryable, String query, [ QueryArguments? args, ]) => @@ -19,6 +20,7 @@ class ClientCommon { /// [postgres@v0.17.0/Transaction/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryArray_1). /// [postgres@v0.17.0/QueryClient/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_1). static Future> queryArrayWithOptions( + Object queryable, QueryObjectOptions config, ) => throw UnimplementedError(); // TODO: @@ -67,6 +69,7 @@ class ClientCommon { /// [postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_1). /// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_1). static Future> queryObjectWithOptions( + Object queryable, QueryObjectOptions config, ) => throw UnimplementedError(); // TODO: diff --git a/lib/src/query_client.dart b/lib/src/query_client.dart index 94aee17..e10c7cd 100644 --- a/lib/src/query_client.dart +++ b/lib/src/query_client.dart @@ -53,13 +53,13 @@ extension QueryClientProps on QueryClient { String query, [ QueryArguments? args, ]) => - ClientCommon.queryArray(query, args); + ClientCommon.queryArray(this, query, args); /// [postgres@v0.17.0/QueryClient/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_1). Future> queryArrayWithOptions( QueryObjectOptions config, ) => - ClientCommon.queryArrayWithOptions(config); + ClientCommon.queryArrayWithOptions(this, config); /// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). Future> queryObject( @@ -72,5 +72,5 @@ extension QueryClientProps on QueryClient { Future> queryObjectWithOptions( QueryObjectOptions config, ) => - ClientCommon.queryObjectWithOptions(config); + ClientCommon.queryObjectWithOptions(this, config); } diff --git a/lib/src/transaction.dart b/lib/src/transaction.dart index 583595d..2da1aed 100644 --- a/lib/src/transaction.dart +++ b/lib/src/transaction.dart @@ -1,6 +1,8 @@ import 'dart:js_interop'; -import 'package:deno_postgres_interop/src/query_object.dart'; +import 'package:deno_postgres_interop/src/client_common.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/util.dart'; @@ -16,10 +18,29 @@ extension TransactionProps on Transaction { /// [postgres@v0.17.0/Transaction/commit](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_commit_0). Future commit() => callFutureMethod(this, 'commit'); + /// [postgres@v0.17.0/Transaction/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryArray_0). + Future> queryArray( + String query, [ + QueryArguments? args, + ]) => + ClientCommon.queryArray(this, query, args); + + /// [postgres@v0.17.0/Transaction/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryArray_1). + Future> queryArrayWithOptions( + QueryObjectOptions config, + ) => + ClientCommon.queryArrayWithOptions(this, config); + /// [postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_0). Future> queryObject( String query, [ QueryArguments? arguments, ]) => - queryObjectCommon(this, query, arguments); + ClientCommon.queryObject(this, query, arguments); + + /// [postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_1). + Future> queryObjectWithOptions( + QueryObjectOptions config, + ) => + ClientCommon.queryObjectWithOptions(this, config); } From abaf4c6d007d78f71b62a41a28de7dc28eba7124 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 17:37:05 +0300 Subject: [PATCH 067/139] big upd --- lib/src/query_array_result.dart | 9 ++++++- lib/src/query_client.dart | 4 +-- lib/src/query_object_result.dart | 3 +++ lib/src/query_result.dart | 45 +++++++++++++++++++++++++++++++- lib/src/transaction.dart | 4 +-- 5 files changed, 59 insertions(+), 6 deletions(-) diff --git a/lib/src/query_array_result.dart b/lib/src/query_array_result.dart index 01303e4..7bd9733 100644 --- a/lib/src/query_array_result.dart +++ b/lib/src/query_array_result.dart @@ -2,5 +2,12 @@ import 'dart:js_interop'; import 'package:deno_postgres_interop/src/query_result.dart'; +/// [postgres@v0.17.0/QueryArrayResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryArrayResult). @JS() -class QueryArrayResult extends QueryResult {} +class QueryArrayResult> extends QueryResult { + /// [postgres@v0.17.0/QueryArrayResult/rows](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryArrayResult#prop_rows). + external List get rows; + + /// [postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). + external factory QueryArrayResult(Query query); +} diff --git a/lib/src/query_client.dart b/lib/src/query_client.dart index e10c7cd..faa5173 100644 --- a/lib/src/query_client.dart +++ b/lib/src/query_client.dart @@ -49,14 +49,14 @@ extension QueryClientProps on QueryClient { } /// [postgres@v0.17.0/QueryClient/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_0). - Future> queryArray( + Future> queryArray>( String query, [ QueryArguments? args, ]) => ClientCommon.queryArray(this, query, args); /// [postgres@v0.17.0/QueryClient/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_1). - Future> queryArrayWithOptions( + Future> queryArrayWithOptions>( QueryObjectOptions config, ) => ClientCommon.queryArrayWithOptions(this, config); diff --git a/lib/src/query_object_result.dart b/lib/src/query_object_result.dart index 815b490..6135cb6 100644 --- a/lib/src/query_object_result.dart +++ b/lib/src/query_object_result.dart @@ -8,6 +8,9 @@ import 'package:deno_postgres_interop/src/query_result.dart'; class QueryObjectResult extends QueryResult { /// [postgres@v0.17.0/QueryObjectResult/columns](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult#prop_columns). external List? get columns; + + /// [postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). + external factory QueryObjectResult(Query query); } /// [postgres@v0.17.0/QueryObjectResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult). diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart index 88e04d2..94b2279 100644 --- a/lib/src/query_result.dart +++ b/lib/src/query_result.dart @@ -1,4 +1,47 @@ import 'dart:js_interop'; +import 'dart:js_util'; @JS() -class QueryResult {} + +/// [postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult) +class QueryResult { + /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_command + external CommandType get command; + + /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_rowCount + external int? get rowCount; + + /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#accessor_rowDescription + external RowDescription? get rowDescription; + + /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_warnings + external List get warnings; + + /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0 + external factory QueryResult(Query query); + + /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_handleCommandComplete_0 + external void handleCommandComplete(String commandTag); + + /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_loadColumnDescriptions_0 + external void loadColumnDescriptions(RowDescription description); +} + +extension QueryResultProps on QueryResult { + /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_insertRow_0 + void insertRow(List row) => callMethod(this, 'insertRow', [row]); +} + +// TODO: + +class Uint8Array {} + +class Notice {} + +class CommandType {} + +class Query {} + +class ResultType {} + +class RowDescription {} diff --git a/lib/src/transaction.dart b/lib/src/transaction.dart index 2da1aed..54ee899 100644 --- a/lib/src/transaction.dart +++ b/lib/src/transaction.dart @@ -19,14 +19,14 @@ extension TransactionProps on Transaction { Future commit() => callFutureMethod(this, 'commit'); /// [postgres@v0.17.0/Transaction/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryArray_0). - Future> queryArray( + Future> queryArray>( String query, [ QueryArguments? args, ]) => ClientCommon.queryArray(this, query, args); /// [postgres@v0.17.0/Transaction/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryArray_1). - Future> queryArrayWithOptions( + Future> queryArrayWithOptions>( QueryObjectOptions config, ) => ClientCommon.queryArrayWithOptions(this, config); From f59ef2737a068e543b97e81d008837ce863edef7 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 17:39:18 +0300 Subject: [PATCH 068/139] fix --- lib/src/client_common.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/src/client_common.dart b/lib/src/client_common.dart index 20d0c66..cd2d14e 100644 --- a/lib/src/client_common.dart +++ b/lib/src/client_common.dart @@ -10,7 +10,7 @@ typedef QueryArguments = Object; class ClientCommon { /// [postgres@v0.17.0/Transaction/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryArray_0). /// [postgres@v0.17.0/QueryClient/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_0). - static Future> queryArray( + static Future> queryArray>( Object queryable, String query, [ QueryArguments? args, @@ -19,11 +19,12 @@ class ClientCommon { /// [postgres@v0.17.0/Transaction/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryArray_1). /// [postgres@v0.17.0/QueryClient/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_1). - static Future> queryArrayWithOptions( + static Future> + queryArrayWithOptions>( Object queryable, QueryObjectOptions config, ) => - throw UnimplementedError(); // TODO: + throw UnimplementedError(); // TODO: // This one won't be implemented because it doesn't make much sense for dart, // the query here is of type TemplateStringsArray which is used in From c206335158ddb0a76139f7066c8d1167bf7e5827 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 17:45:36 +0300 Subject: [PATCH 069/139] split by files --- lib/src/command_type.dart | 1 + lib/src/notice.dart | 1 + lib/src/query.dart | 1 + lib/src/query_array_result.dart | 2 ++ lib/src/query_object_result.dart | 2 ++ lib/src/query_result.dart | 40 ++++++++++++++------------------ lib/src/result_type.dart | 1 + lib/src/row_description.dart | 1 + lib/src/uint_8_array.dart | 1 + 9 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 lib/src/command_type.dart create mode 100644 lib/src/notice.dart create mode 100644 lib/src/query.dart create mode 100644 lib/src/result_type.dart create mode 100644 lib/src/row_description.dart create mode 100644 lib/src/uint_8_array.dart diff --git a/lib/src/command_type.dart b/lib/src/command_type.dart new file mode 100644 index 0000000..09c6393 --- /dev/null +++ b/lib/src/command_type.dart @@ -0,0 +1 @@ +class CommandType {} diff --git a/lib/src/notice.dart b/lib/src/notice.dart new file mode 100644 index 0000000..6bdc8fe --- /dev/null +++ b/lib/src/notice.dart @@ -0,0 +1 @@ +class Notice {} diff --git a/lib/src/query.dart b/lib/src/query.dart new file mode 100644 index 0000000..4bc1c2c --- /dev/null +++ b/lib/src/query.dart @@ -0,0 +1 @@ +class Query {} diff --git a/lib/src/query_array_result.dart b/lib/src/query_array_result.dart index 7bd9733..dbd67b2 100644 --- a/lib/src/query_array_result.dart +++ b/lib/src/query_array_result.dart @@ -1,6 +1,8 @@ import 'dart:js_interop'; +import 'package:deno_postgres_interop/src/query.dart'; import 'package:deno_postgres_interop/src/query_result.dart'; +import 'package:deno_postgres_interop/src/result_type.dart'; /// [postgres@v0.17.0/QueryArrayResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryArrayResult). @JS() diff --git a/lib/src/query_object_result.dart b/lib/src/query_object_result.dart index 6135cb6..a245bd4 100644 --- a/lib/src/query_object_result.dart +++ b/lib/src/query_object_result.dart @@ -1,7 +1,9 @@ import 'dart:js_interop'; import 'dart:js_util'; +import 'package:deno_postgres_interop/src/query.dart'; import 'package:deno_postgres_interop/src/query_result.dart'; +import 'package:deno_postgres_interop/src/result_type.dart'; /// [postgres@v0.17.0/QueryObjectResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult). @JS() diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart index 94b2279..e343e42 100644 --- a/lib/src/query_result.dart +++ b/lib/src/query_result.dart @@ -1,47 +1,41 @@ import 'dart:js_interop'; import 'dart:js_util'; +import 'package:deno_postgres_interop/src/command_type.dart'; +import 'package:deno_postgres_interop/src/notice.dart'; +import 'package:deno_postgres_interop/src/query.dart'; +import 'package:deno_postgres_interop/src/result_type.dart'; +import 'package:deno_postgres_interop/src/row_description.dart'; +import 'package:deno_postgres_interop/src/uint_8_array.dart'; + @JS() -/// [postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult) +/// [postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). class QueryResult { - /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_command + /// [postgres@v0.17.0/QueryResult/command](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_command). external CommandType get command; - /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_rowCount + /// [postgres@v0.17.0/QueryResult/rowCount](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_rowCount). external int? get rowCount; - /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#accessor_rowDescription + /// [postgres@v0.17.0/QueryResult/rowDescription](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#accessor_rowDescription). external RowDescription? get rowDescription; - /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_warnings + /// [postgres@v0.17.0/QueryResult/warnings](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_warnings). external List get warnings; - /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0 + /// [postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). external factory QueryResult(Query query); - /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_handleCommandComplete_0 + /// [postgres@v0.17.0/QueryResult/handleCommandComplete](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_handleCommandComplete_0). external void handleCommandComplete(String commandTag); - /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_loadColumnDescriptions_0 + /// [postgres@v0.17.0/QueryResult/loadColumnDescriptions](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_loadColumnDescriptions_0). external void loadColumnDescriptions(RowDescription description); } +/// [postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). extension QueryResultProps on QueryResult { - /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_insertRow_0 + /// [postgres@v0.17.0/QueryResult/insertRow](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_insertRow_0). void insertRow(List row) => callMethod(this, 'insertRow', [row]); } - -// TODO: - -class Uint8Array {} - -class Notice {} - -class CommandType {} - -class Query {} - -class ResultType {} - -class RowDescription {} diff --git a/lib/src/result_type.dart b/lib/src/result_type.dart new file mode 100644 index 0000000..66ce6bc --- /dev/null +++ b/lib/src/result_type.dart @@ -0,0 +1 @@ +class ResultType {} diff --git a/lib/src/row_description.dart b/lib/src/row_description.dart new file mode 100644 index 0000000..3c9cf2d --- /dev/null +++ b/lib/src/row_description.dart @@ -0,0 +1 @@ +class RowDescription {} diff --git a/lib/src/uint_8_array.dart b/lib/src/uint_8_array.dart new file mode 100644 index 0000000..5e853d3 --- /dev/null +++ b/lib/src/uint_8_array.dart @@ -0,0 +1 @@ +class Uint8Array {} From d15417ee359ff6d46ba169295373997d4d34ebcf Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 18:19:17 +0300 Subject: [PATCH 070/139] init --- lib/src/command_type.dart | 1 + lib/src/notice.dart | 1 + lib/src/query.dart | 1 + lib/src/query_result.dart | 41 ++++++++++++++++++++++++++++++++++++ lib/src/result_type.dart | 1 + lib/src/row_description.dart | 1 + lib/src/uint_8_array.dart | 1 + 7 files changed, 47 insertions(+) create mode 100644 lib/src/command_type.dart create mode 100644 lib/src/notice.dart create mode 100644 lib/src/query.dart create mode 100644 lib/src/query_result.dart create mode 100644 lib/src/result_type.dart create mode 100644 lib/src/row_description.dart create mode 100644 lib/src/uint_8_array.dart diff --git a/lib/src/command_type.dart b/lib/src/command_type.dart new file mode 100644 index 0000000..09c6393 --- /dev/null +++ b/lib/src/command_type.dart @@ -0,0 +1 @@ +class CommandType {} diff --git a/lib/src/notice.dart b/lib/src/notice.dart new file mode 100644 index 0000000..6bdc8fe --- /dev/null +++ b/lib/src/notice.dart @@ -0,0 +1 @@ +class Notice {} diff --git a/lib/src/query.dart b/lib/src/query.dart new file mode 100644 index 0000000..4bc1c2c --- /dev/null +++ b/lib/src/query.dart @@ -0,0 +1 @@ +class Query {} diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart new file mode 100644 index 0000000..e343e42 --- /dev/null +++ b/lib/src/query_result.dart @@ -0,0 +1,41 @@ +import 'dart:js_interop'; +import 'dart:js_util'; + +import 'package:deno_postgres_interop/src/command_type.dart'; +import 'package:deno_postgres_interop/src/notice.dart'; +import 'package:deno_postgres_interop/src/query.dart'; +import 'package:deno_postgres_interop/src/result_type.dart'; +import 'package:deno_postgres_interop/src/row_description.dart'; +import 'package:deno_postgres_interop/src/uint_8_array.dart'; + +@JS() + +/// [postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). +class QueryResult { + /// [postgres@v0.17.0/QueryResult/command](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_command). + external CommandType get command; + + /// [postgres@v0.17.0/QueryResult/rowCount](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_rowCount). + external int? get rowCount; + + /// [postgres@v0.17.0/QueryResult/rowDescription](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#accessor_rowDescription). + external RowDescription? get rowDescription; + + /// [postgres@v0.17.0/QueryResult/warnings](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_warnings). + external List get warnings; + + /// [postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). + external factory QueryResult(Query query); + + /// [postgres@v0.17.0/QueryResult/handleCommandComplete](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_handleCommandComplete_0). + external void handleCommandComplete(String commandTag); + + /// [postgres@v0.17.0/QueryResult/loadColumnDescriptions](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_loadColumnDescriptions_0). + external void loadColumnDescriptions(RowDescription description); +} + +/// [postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). +extension QueryResultProps on QueryResult { + /// [postgres@v0.17.0/QueryResult/insertRow](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_insertRow_0). + void insertRow(List row) => callMethod(this, 'insertRow', [row]); +} diff --git a/lib/src/result_type.dart b/lib/src/result_type.dart new file mode 100644 index 0000000..66ce6bc --- /dev/null +++ b/lib/src/result_type.dart @@ -0,0 +1 @@ +class ResultType {} diff --git a/lib/src/row_description.dart b/lib/src/row_description.dart new file mode 100644 index 0000000..3c9cf2d --- /dev/null +++ b/lib/src/row_description.dart @@ -0,0 +1 @@ +class RowDescription {} diff --git a/lib/src/uint_8_array.dart b/lib/src/uint_8_array.dart new file mode 100644 index 0000000..5e853d3 --- /dev/null +++ b/lib/src/uint_8_array.dart @@ -0,0 +1 @@ +class Uint8Array {} From db75396455cceff59567e79459b502a2093757a9 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 18:28:55 +0300 Subject: [PATCH 071/139] CommandType --- lib/src/command_type.dart | 28 +++++++++++++++++++++++++++- lib/src/query_result.dart | 8 +++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/lib/src/command_type.dart b/lib/src/command_type.dart index 09c6393..13a781f 100644 --- a/lib/src/command_type.dart +++ b/lib/src/command_type.dart @@ -1 +1,27 @@ -class CommandType {} +/// All sql commands. +enum CommandType { + /// insert. + insert, + + /// delete. + delete, + + /// update. + update, + + /// select. + select, + + /// move. + move, + + /// fetch. + fetch, + + /// copy. + copy; + + /// Parses a string containing an [CommandType] literal into its instance. + static CommandType parse(String string) => + values.firstWhere((e) => e.name.toUpperCase() == string); +} diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart index e343e42..fad1043 100644 --- a/lib/src/query_result.dart +++ b/lib/src/query_result.dart @@ -12,9 +12,6 @@ import 'package:deno_postgres_interop/src/uint_8_array.dart'; /// [postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). class QueryResult { - /// [postgres@v0.17.0/QueryResult/command](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_command). - external CommandType get command; - /// [postgres@v0.17.0/QueryResult/rowCount](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_rowCount). external int? get rowCount; @@ -38,4 +35,9 @@ class QueryResult { extension QueryResultProps on QueryResult { /// [postgres@v0.17.0/QueryResult/insertRow](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_insertRow_0). void insertRow(List row) => callMethod(this, 'insertRow', [row]); + + /// [postgres@v0.17.0/QueryResult/command](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_command). + CommandType get command => CommandType.parse( + getProperty(this, 'command'), + ); } From 737d5fb70b65235e72987544c25e4d485436baa8 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 18:42:06 +0300 Subject: [PATCH 072/139] notice --- lib/src/notice.dart | 99 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/lib/src/notice.dart b/lib/src/notice.dart index 6bdc8fe..a1579ef 100644 --- a/lib/src/notice.dart +++ b/lib/src/notice.dart @@ -1 +1,98 @@ -class Notice {} +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). +@JS() +class Notice { + /// [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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + external String? get routine; + + /// [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, + required String message, + String? detail, + String? hint, + String? position, + String? internalPosition, + String? internalQuery, + String? where, + String? schema, + String? table, + String? column, + String? dataType, + String? constraint, + String? file, + String? line, + String? routine, + }) { + return jsify({ + 'severity': severity, + 'code': code, + 'message': message, + if (detail != null) 'detail': detail, + if (hint != null) 'hint': hint, + if (position != null) 'position': position, + if (internalPosition != null) 'internalPosition': internalPosition, + if (internalQuery != null) 'internalQuery': internalQuery, + if (where != null) 'where': where, + if (schema != null) 'schema': schema, + if (table != null) 'table': table, + if (column != null) 'column': column, + if (dataType != null) 'dataType': dataType, + if (constraint != null) 'constraint': constraint, + if (file != null) 'file': file, + if (line != null) 'line': line, + if (routine != null) 'routine': routine, + }) as Notice; + } +} From c1f6a1d2f0b085ef594e099e6dbc89dca6ec2868 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 18:51:19 +0300 Subject: [PATCH 073/139] ResultType --- lib/src/result_type.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/src/result_type.dart b/lib/src/result_type.dart index 66ce6bc..cfdb9d0 100644 --- a/lib/src/result_type.dart +++ b/lib/src/result_type.dart @@ -1 +1,12 @@ -class ResultType {} +/// [postgres@v0.17.0/ResultType](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=ResultType). +enum ResultType { + /// array. + array, + + /// object. + object; + + /// Parses a string containing an [ResultType] literal into its instance. + static ResultType parse(String string) => + values.firstWhere((e) => e.name.toUpperCase() == string); +} From 91f9831f8c308d0c01a349eaedc3722322b5f6eb Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 19:08:25 +0300 Subject: [PATCH 074/139] working type --- example/lib/main.dart | 7 ++++++- lib/src/query_object_result.dart | 9 ++++++++- lib/src/query_result.dart | 8 +++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index b3a01fb..a6c4888 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -16,7 +16,12 @@ Future fetch(Request _) async { ); await client.end(); - return Response(result.rows.map(rowToPrettyString).join('\n\n')); + return Response( + [ + result.command, + ...result.rows.map(rowToPrettyString), + ].join('\n\n'), + ); } Future> transaction(Transaction transaction) async { diff --git a/lib/src/query_object_result.dart b/lib/src/query_object_result.dart index 23ed729..a245bd4 100644 --- a/lib/src/query_object_result.dart +++ b/lib/src/query_object_result.dart @@ -1,11 +1,18 @@ import 'dart:js_interop'; import 'dart:js_util'; +import 'package:deno_postgres_interop/src/query.dart'; +import 'package:deno_postgres_interop/src/query_result.dart'; +import 'package:deno_postgres_interop/src/result_type.dart'; + /// [postgres@v0.17.0/QueryObjectResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult). @JS() -class QueryObjectResult { +class QueryObjectResult extends QueryResult { /// [postgres@v0.17.0/QueryObjectResult/columns](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult#prop_columns). external List? get columns; + + /// [postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). + external factory QueryObjectResult(Query query); } /// [postgres@v0.17.0/QueryObjectResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult). diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart index fad1043..237a825 100644 --- a/lib/src/query_result.dart +++ b/lib/src/query_result.dart @@ -21,6 +21,9 @@ class QueryResult { /// [postgres@v0.17.0/QueryResult/warnings](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_warnings). external List get warnings; + /// [postgres@v0.17.0/QueryResult/command](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_command). + external CommandType get command; + /// [postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). external factory QueryResult(Query query); @@ -35,9 +38,4 @@ class QueryResult { extension QueryResultProps on QueryResult { /// [postgres@v0.17.0/QueryResult/insertRow](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_insertRow_0). void insertRow(List row) => callMethod(this, 'insertRow', [row]); - - /// [postgres@v0.17.0/QueryResult/command](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_command). - CommandType get command => CommandType.parse( - getProperty(this, 'command'), - ); } From da3208f0ca5fbaef3018f234c5b9c745b88e68d5 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 19:23:44 +0300 Subject: [PATCH 075/139] placeholders --- lib/src/query.dart | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/lib/src/query.dart b/lib/src/query.dart index 4bc1c2c..45893e8 100644 --- a/lib/src/query.dart +++ b/lib/src/query.dart @@ -1 +1,35 @@ -class Query {} +import 'dart:js_interop'; + +import 'package:deno_postgres_interop/src/result_type.dart'; + +@JS() +class Query { +// new +// Query(config: QueryObjectOptions, result_type: T) + +// new +// Query( +// text: string, +// result_type: T, +// args?: QueryArguments, +// ) + +// new +// Query( +// config_or_text: string | QueryObjectOptions, +// result_type: T, +// args?: QueryArguments, +// ) + +// args: EncodedArg[] + +// optional +// camelcase: boolean + +// optional +// fields: string[] + +// result_type: ResultType + +// text: string +} From d3f8d9056d0a29d30af66328b21eeb0600541673 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 19:51:19 +0300 Subject: [PATCH 076/139] working --- example/lib/main.dart | 7 ++++++- lib/deno_postgres_interop.dart | 2 ++ lib/src/command_type.dart | 27 +++++++++++++++++++++++++++ lib/src/query.dart | 4 ++++ lib/src/query_object_result.dart | 8 +++++++- lib/src/query_result.dart | 16 ++++++++++++++++ 6 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 lib/src/command_type.dart create mode 100644 lib/src/query.dart create mode 100644 lib/src/query_result.dart diff --git a/example/lib/main.dart b/example/lib/main.dart index b3a01fb..5f04316 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -16,7 +16,12 @@ Future fetch(Request _) async { ); await client.end(); - return Response(result.rows.map(rowToPrettyString).join('\n\n')); + return Response( + [ + result.command == CommandType.select, + ...result.rows.map(rowToPrettyString), + ].join('\n\n'), + ); } Future> transaction(Transaction transaction) async { diff --git a/lib/deno_postgres_interop.dart b/lib/deno_postgres_interop.dart index 720e5c9..1ba90c6 100644 --- a/lib/deno_postgres_interop.dart +++ b/lib/deno_postgres_interop.dart @@ -2,9 +2,11 @@ library; export 'src/client.dart'; +export 'src/command_type.dart'; export 'src/isolation_level.dart'; export 'src/query_client.dart'; export 'src/query_object.dart' show QueryArguments; export 'src/query_object_result.dart'; +export 'src/query_result.dart'; export 'src/transaction.dart'; export 'src/transaction_options.dart'; diff --git a/lib/src/command_type.dart b/lib/src/command_type.dart new file mode 100644 index 0000000..13a781f --- /dev/null +++ b/lib/src/command_type.dart @@ -0,0 +1,27 @@ +/// All sql commands. +enum CommandType { + /// insert. + insert, + + /// delete. + delete, + + /// update. + update, + + /// select. + select, + + /// move. + move, + + /// fetch. + fetch, + + /// copy. + copy; + + /// Parses a string containing an [CommandType] literal into its instance. + static CommandType parse(String string) => + values.firstWhere((e) => e.name.toUpperCase() == string); +} diff --git a/lib/src/query.dart b/lib/src/query.dart new file mode 100644 index 0000000..c1c05ff --- /dev/null +++ b/lib/src/query.dart @@ -0,0 +1,4 @@ +import 'dart:js_interop'; + +@JS() +class Query {} diff --git a/lib/src/query_object_result.dart b/lib/src/query_object_result.dart index 23ed729..2fe92ee 100644 --- a/lib/src/query_object_result.dart +++ b/lib/src/query_object_result.dart @@ -1,11 +1,17 @@ import 'dart:js_interop'; import 'dart:js_util'; +import 'package:deno_postgres_interop/src/query.dart'; +import 'package:deno_postgres_interop/src/query_result.dart'; + /// [postgres@v0.17.0/QueryObjectResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult). @JS() -class QueryObjectResult { +class QueryObjectResult extends QueryResult { /// [postgres@v0.17.0/QueryObjectResult/columns](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult#prop_columns). external List? get columns; + + /// [postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). + external factory QueryObjectResult(Query query); } /// [postgres@v0.17.0/QueryObjectResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult). diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart new file mode 100644 index 0000000..2d11580 --- /dev/null +++ b/lib/src/query_result.dart @@ -0,0 +1,16 @@ +import 'dart:js_interop'; +import 'dart:js_util'; + +import 'package:deno_postgres_interop/src/command_type.dart'; + +/// [postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). +@JS() +class QueryResult {} + +/// [postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). +extension QueryResultProps on QueryResult { + /// [postgres@v0.17.0/QueryResult/command](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_command). + CommandType get command => CommandType.parse( + getProperty(this, 'command'), + ); +} From c92dd81962ad856981e84e11cfcf9d35b96e8fe6 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 19:54:32 +0300 Subject: [PATCH 077/139] more consistent comments --- lib/src/isolation_level.dart | 8 ++++---- lib/src/query.dart | 1 + lib/src/query_client.dart | 12 ++++++------ lib/src/query_object.dart | 6 +++--- lib/src/query_object_result.dart | 10 +++++----- lib/src/query_result.dart | 6 +++--- lib/src/transaction.dart | 10 +++++----- lib/src/transaction_options.dart | 12 ++++++------ 8 files changed, 33 insertions(+), 32 deletions(-) diff --git a/lib/src/isolation_level.dart b/lib/src/isolation_level.dart index afb85bf..26295e6 100644 --- a/lib/src/isolation_level.dart +++ b/lib/src/isolation_level.dart @@ -1,12 +1,12 @@ -/// [postgresql/Transaction Isolation](https://www.postgresql.org/docs/current/transaction-iso.html). +/// [deno-postgres@0.17.0/Transaction Isolation](https://www.postgresql.org/docs/current/transaction-iso.html). enum IsolationLevel { - /// [postgresql/Transaction Isolation/Read Committed Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-READ-COMMITTED). + /// [deno-postgres@0.17.0/Transaction Isolation/Read Committed Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-READ-COMMITTED). readCommitted, - /// [postgresql/Transaction Isolation/Repeatable Read Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-REPEATABLE-READ). + /// [deno-postgres@0.17.0/Transaction Isolation/Repeatable Read Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-REPEATABLE-READ). repeatableRead, - /// [postgresql/Transaction Isolation/Serializable Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-SERIALIZABLE). + /// [deno-postgres@0.17.0/Transaction Isolation/Serializable Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-SERIALIZABLE). serializable; /// Parses a string containing an [IsolationLevel] literal into its instance. diff --git a/lib/src/query.dart b/lib/src/query.dart index c1c05ff..cd45632 100644 --- a/lib/src/query.dart +++ b/lib/src/query.dart @@ -1,4 +1,5 @@ import 'dart:js_interop'; +/// [deno-postgres@0.17.0/Query](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query). @JS() class Query {} diff --git a/lib/src/query_client.dart b/lib/src/query_client.dart index 4c785ed..180d6ba 100644 --- a/lib/src/query_client.dart +++ b/lib/src/query_client.dart @@ -7,19 +7,19 @@ 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'; -/// [postgres@v0.17.0/QueryClient](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient). +/// [deno-postgres@v0.17.0/QueryClient](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient). @JS() class QueryClient {} -/// [postgres@v0.17.0/QueryClient](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient). +/// [deno-postgres@v0.17.0/QueryClient](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient). extension QueryClientProps on QueryClient { - /// [postgres@v0.17.0/QueryClient/connect](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_connect_0). + /// [deno-postgres@v0.17.0/QueryClient/connect](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_connect_0). Future connect() => callFutureMethod(this, 'connect'); - /// [postgres@v0.17.0/QueryClient/end](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_end_0). + /// [deno-postgres@v0.17.0/QueryClient/end](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_end_0). Future end() => callFutureMethod(this, 'end'); - /// [postgres@v0.17.0/QueryClient/createTransaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_createTransaction_0). + /// [deno-postgres@v0.17.0/QueryClient/createTransaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_createTransaction_0). Transaction createTransaction(String name, [TransactionOptions? options]) => callMethod( this, @@ -46,7 +46,7 @@ extension QueryClientProps on QueryClient { return result; } - /// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). + /// [deno-postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). Future> queryObject( String query, [ QueryArguments? arguments, diff --git a/lib/src/query_object.dart b/lib/src/query_object.dart index ed0074d..b45bea8 100644 --- a/lib/src/query_object.dart +++ b/lib/src/query_object.dart @@ -1,13 +1,13 @@ import 'package:deno_postgres_interop/deno_postgres_interop.dart'; import 'package:deno_postgres_interop/src/util.dart'; -/// [postgres@v0.17.0/QueryArguments](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryArguments). +/// [deno-postgres@v0.17.0/QueryArguments](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryArguments). typedef QueryArguments = Object; /// Common method between all Clients. /// -/// [postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_0). -/// [postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). +/// [deno-postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_0). +/// [deno-postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_0). Future> queryObjectCommon( Object queryable, String query, [ diff --git a/lib/src/query_object_result.dart b/lib/src/query_object_result.dart index 2fe92ee..796335a 100644 --- a/lib/src/query_object_result.dart +++ b/lib/src/query_object_result.dart @@ -4,19 +4,19 @@ import 'dart:js_util'; import 'package:deno_postgres_interop/src/query.dart'; import 'package:deno_postgres_interop/src/query_result.dart'; -/// [postgres@v0.17.0/QueryObjectResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult). +/// [deno-postgres@v0.17.0/QueryObjectResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult). @JS() class QueryObjectResult extends QueryResult { - /// [postgres@v0.17.0/QueryObjectResult/columns](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult#prop_columns). + /// [deno-postgres@v0.17.0/QueryObjectResult/columns](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult#prop_columns). external List? get columns; - /// [postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). + /// [deno-postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). external factory QueryObjectResult(Query query); } -/// [postgres@v0.17.0/QueryObjectResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult). +/// [deno-postgres@v0.17.0/QueryObjectResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult). extension QueryObjectResultProps on QueryObjectResult { - /// [postgres@v0.17.0/QueryObjectResult/rows](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult#prop_rows). + /// [deno-postgres@v0.17.0/QueryObjectResult/rows](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult#prop_rows). List> get rows => // ignore: cast_nullable_to_non_nullable (dartify(getProperty(this, 'rows')) as List) diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart index 2d11580..c3db0e5 100644 --- a/lib/src/query_result.dart +++ b/lib/src/query_result.dart @@ -3,13 +3,13 @@ import 'dart:js_util'; import 'package:deno_postgres_interop/src/command_type.dart'; -/// [postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). +/// [deno-postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). @JS() class QueryResult {} -/// [postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). +/// [deno-postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). extension QueryResultProps on QueryResult { - /// [postgres@v0.17.0/QueryResult/command](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_command). + /// [deno-postgres@v0.17.0/QueryResult/command](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_command). CommandType get command => CommandType.parse( getProperty(this, 'command'), ); diff --git a/lib/src/transaction.dart b/lib/src/transaction.dart index 583595d..88b4cd0 100644 --- a/lib/src/transaction.dart +++ b/lib/src/transaction.dart @@ -4,19 +4,19 @@ import 'package:deno_postgres_interop/src/query_object.dart'; import 'package:deno_postgres_interop/src/query_object_result.dart'; import 'package:deno_postgres_interop/src/util.dart'; -/// [postgres@v0.17.0/Transaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction). +/// [deno-postgres@v0.17.0/Transaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction). @JS() class Transaction {} -/// [postgres@v0.17.0/Transaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction). +/// [deno-postgres@v0.17.0/Transaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction). extension TransactionProps on Transaction { - /// [postgres@v0.17.0/Transaction/begin](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_begin_0). + /// [deno-postgres@v0.17.0/Transaction/begin](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_begin_0). Future begin() => callFutureMethod(this, 'begin'); - /// [postgres@v0.17.0/Transaction/commit](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_commit_0). + /// [deno-postgres@v0.17.0/Transaction/commit](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_commit_0). Future commit() => callFutureMethod(this, 'commit'); - /// [postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_0). + /// [deno-postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_0). Future> queryObject( String query, [ QueryArguments? arguments, diff --git a/lib/src/transaction_options.dart b/lib/src/transaction_options.dart index bb1c924..65108c6 100644 --- a/lib/src/transaction_options.dart +++ b/lib/src/transaction_options.dart @@ -3,13 +3,13 @@ import 'dart:js_util'; import 'package:deno_postgres_interop/src/isolation_level.dart'; -/// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). +/// [deno-postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). @JS() class TransactionOptions { - /// [postgres@v0.17.0/TransactionOptions/snapshot](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). + /// [deno-postgres@v0.17.0/TransactionOptions/snapshot](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). external String? get snapshot; - /// [postgres@v0.17.0/TransactionOptions/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). + /// [deno-postgres@v0.17.0/TransactionOptions/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). factory TransactionOptions({ IsolationLevel? isolationLevel, bool? isReadOnly, @@ -22,15 +22,15 @@ class TransactionOptions { }) as TransactionOptions; } -/// [postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). +/// [deno-postgres@v0.17.0/TransactionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). extension TransactionOptionsProps on TransactionOptions { - /// [postgres@v0.17.0/TransactionOptions/isolation_level](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). + /// [deno-postgres@v0.17.0/TransactionOptions/isolation_level](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). IsolationLevel? get isolationLevel { final jsProperty = getProperty(this, 'isolation_level'); return jsProperty == null ? null : IsolationLevel.parse(jsProperty); } - /// [postgres@v0.17.0/TransactionOptions/read_only](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). + /// [deno-postgres@v0.17.0/TransactionOptions/read_only](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TransactionOptions). bool? get isReadOnly => getProperty(this, 'read_only'); } From 13750a9fc4ed254f033bafad0f8e7072d2b8c5bd Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 20:43:46 +0300 Subject: [PATCH 078/139] rowdescription --- lib/src/row_description.dart | 73 +++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/lib/src/row_description.dart b/lib/src/row_description.dart index 3c9cf2d..b8c4dde 100644 --- a/lib/src/row_description.dart +++ b/lib/src/row_description.dart @@ -1 +1,72 @@ -class RowDescription {} +import 'dart:js_util'; + +/// [deno-postgres@v0.17.0/RowDescription](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=RowDescription). +class RowDescription { + /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=RowDescription#ctor_0 + external factory RowDescription(int columnsCount, List columns); +} + +/// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). +class Column { + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external String get name; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get tableOid; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get index; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get typeOid; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get columnLength; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get typeModifier; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column#ctor_0). + factory Column({ + required String name, + required int tableOid, + required int index, + required int typeOid, + required int columnLength, + required int typeModifier, + required ColumnFormat format, + }) => + callConstructor('Column', [ + name, + tableOid, + index, + typeOid, + columnLength, + typeModifier, + format.id, + ]); +} + +/// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). +extension ColumnProps on Column { + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + ColumnFormat get format => ColumnFormat.values + .firstWhere((e) => e.id == getProperty(this, 'format')); +} + +/// enum Format { +/// TEXT = 0, +/// BINARY = 1, +/// } +enum ColumnFormat { + /// text. + text(0), + + /// binary. + binary(1); + + /// Used for interop. + final int id; + + const ColumnFormat(this.id); +} From fd0274e3657aa644c621ede3c90f952e3ae2a255 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 21:01:37 +0300 Subject: [PATCH 079/139] query --- lib/src/query.dart | 63 ++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/lib/src/query.dart b/lib/src/query.dart index 9f39e31..97a5cc3 100644 --- a/lib/src/query.dart +++ b/lib/src/query.dart @@ -1,36 +1,49 @@ import 'dart:js_interop'; +import 'dart:js_util'; +import 'package:deno_postgres_interop/src/query_object.dart'; import 'package:deno_postgres_interop/src/result_type.dart'; /// [deno-postgres@v0.17.0/Query](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query). @JS() class Query { -// new -// Query(config: QueryObjectOptions, result_type: T) - -// new -// Query( -// text: string, -// result_type: T, -// args?: QueryArguments, -// ) - -// new -// Query( -// config_or_text: string | QueryObjectOptions, -// result_type: T, -// args?: QueryArguments, -// ) - -// args: EncodedArg[] + /// [deno-postgres@v0.17.0/Query/args](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#prop_args). + external List args; + + /// [deno-postgres@v0.17.0/Query/args](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#prop_fields). + external List? get fields; + + /// [deno-postgres@v0.17.0/Query/args](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#prop_text). + external String get text; + + /// [deno-postgres@v0.17.0/Query/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#ctor_0). + /// [deno-postgres@v0.17.0/Query/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#ctor_2). + factory Query.withConfig({ + required QueryObjectOptions config, + required T resultType, + QueryArguments? args, + }) => + callConstructor('Query', [config, resultType, args]) as Query; + + /// [deno-postgres@v0.17.0/Query/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#ctor_1). + /// [deno-postgres@v0.17.0/Query/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#ctor_2). + factory Query.withArgs({ + required String text, + required T resultType, + QueryArguments? args, + }) => + callConstructor('Query', [text, resultType, args]) as Query; +} -// optional -// camelcase: boolean +/// [deno-postgres@v0.17.0/Query](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query). +extension QueryProps on Query { + /// [deno-postgres@v0.17.0/Query/args](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#prop_result_type). + ResultType get resultType => getProperty(this, 'result_type'); -// optional -// fields: string[] + /// [deno-postgres@v0.17.0/Query/args](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#prop_camelcase). + bool? get isCamelCase => getProperty(this, 'camelcase'); +} -// result_type: ResultType +class QueryObjectOptions {} -// text: string -} +class EncodedArg {} From 330b1fab865ec4646ece3150102fc86708c88b1f Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 21:04:59 +0300 Subject: [PATCH 080/139] split by files --- lib/src/encoded_arg.dart | 1 + lib/src/query.dart | 6 ++---- lib/src/query_object_options.dart | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 lib/src/encoded_arg.dart create mode 100644 lib/src/query_object_options.dart diff --git a/lib/src/encoded_arg.dart b/lib/src/encoded_arg.dart new file mode 100644 index 0000000..1f4f0ba --- /dev/null +++ b/lib/src/encoded_arg.dart @@ -0,0 +1 @@ +class EncodedArg {} diff --git a/lib/src/query.dart b/lib/src/query.dart index 97a5cc3..f02d4ee 100644 --- a/lib/src/query.dart +++ b/lib/src/query.dart @@ -1,7 +1,9 @@ import 'dart:js_interop'; import 'dart:js_util'; +import 'package:deno_postgres_interop/src/encoded_arg.dart'; import 'package:deno_postgres_interop/src/query_object.dart'; +import 'package:deno_postgres_interop/src/query_object_options.dart'; import 'package:deno_postgres_interop/src/result_type.dart'; /// [deno-postgres@v0.17.0/Query](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query). @@ -43,7 +45,3 @@ extension QueryProps on Query { /// [deno-postgres@v0.17.0/Query/args](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#prop_camelcase). bool? get isCamelCase => getProperty(this, 'camelcase'); } - -class QueryObjectOptions {} - -class EncodedArg {} diff --git a/lib/src/query_object_options.dart b/lib/src/query_object_options.dart new file mode 100644 index 0000000..59a277b --- /dev/null +++ b/lib/src/query_object_options.dart @@ -0,0 +1 @@ +class QueryObjectOptions {} From 53ffeba7d9d5529941ff0315cad6e9f33250a628 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 21:15:26 +0300 Subject: [PATCH 081/139] queryObjectOptions --- lib/src/query_object_options.dart | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/src/query_object_options.dart b/lib/src/query_object_options.dart index 59a277b..0b07f2a 100644 --- a/lib/src/query_object_options.dart +++ b/lib/src/query_object_options.dart @@ -1 +1,22 @@ -class QueryObjectOptions {} +import 'dart:js_util'; + +/// [deno-postgres@v0.17.0/QueryObjectOptions](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectOptions). +class QueryObjectOptions { + /// [deno-postgres@v0.17.0/QueryObjectOptions/fields](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectOptions#prop_fields). + external List? get fields; + + /// [deno-postgres@v0.17.0/QueryObjectOptions](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectOptions). + factory QueryObjectOptions({List? fields, bool? isCamelCase}) => + jsify( + { + if (isCamelCase != null) 'camelcase': isCamelCase, + if (fields != null) 'fields': fields, + }, + ) as QueryObjectOptions; +} + +/// [deno-postgres@v0.17.0/QueryObjectOptions](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectOptions). +extension QueryObjectOptionsProps on QueryObjectOptions { + /// [deno-postgres@v0.17.0/QueryObjectOptions/camelcase](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectOptions#prop_camelcase). + bool? get isCamelCase => getProperty(this, 'camelcase'); +} From 2be332b6943e1ce2581c97c229c49c0a1cf7573f Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 21:25:01 +0300 Subject: [PATCH 082/139] uint8 --- lib/src/encoded_arg.dart | 1 - lib/src/query.dart | 4 ++-- lib/src/query_result.dart | 3 +-- lib/src/uint_8_array.dart | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) delete mode 100644 lib/src/encoded_arg.dart delete mode 100644 lib/src/uint_8_array.dart diff --git a/lib/src/encoded_arg.dart b/lib/src/encoded_arg.dart deleted file mode 100644 index 1f4f0ba..0000000 --- a/lib/src/encoded_arg.dart +++ /dev/null @@ -1 +0,0 @@ -class EncodedArg {} diff --git a/lib/src/query.dart b/lib/src/query.dart index f02d4ee..9d60959 100644 --- a/lib/src/query.dart +++ b/lib/src/query.dart @@ -1,7 +1,6 @@ import 'dart:js_interop'; import 'dart:js_util'; -import 'package:deno_postgres_interop/src/encoded_arg.dart'; import 'package:deno_postgres_interop/src/query_object.dart'; import 'package:deno_postgres_interop/src/query_object_options.dart'; import 'package:deno_postgres_interop/src/result_type.dart'; @@ -10,7 +9,8 @@ import 'package:deno_postgres_interop/src/result_type.dart'; @JS() class Query { /// [deno-postgres@v0.17.0/Query/args](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#prop_args). - external List args; + /// null | string | Uint8Array + external List args; /// [deno-postgres@v0.17.0/Query/args](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#prop_fields). external List? get fields; diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart index e483d0b..1134e8d 100644 --- a/lib/src/query_result.dart +++ b/lib/src/query_result.dart @@ -6,7 +6,6 @@ import 'package:deno_postgres_interop/src/notice.dart'; import 'package:deno_postgres_interop/src/query.dart'; import 'package:deno_postgres_interop/src/result_type.dart'; import 'package:deno_postgres_interop/src/row_description.dart'; -import 'package:deno_postgres_interop/src/uint_8_array.dart'; /// [deno-postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). @JS() @@ -33,7 +32,7 @@ class QueryResult { /// [deno-postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). extension QueryResultProps on QueryResult { /// [deno-postgres@v0.17.0/QueryResult/insertRow](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#method_insertRow_0). - void insertRow(List row) => callMethod(this, 'insertRow', [row]); + void insertRow(List> row) => callMethod(this, 'insertRow', [row]); /// [deno-postgres@v0.17.0/QueryResult/command](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_command). CommandType get command => CommandType.parse( diff --git a/lib/src/uint_8_array.dart b/lib/src/uint_8_array.dart deleted file mode 100644 index 5e853d3..0000000 --- a/lib/src/uint_8_array.dart +++ /dev/null @@ -1 +0,0 @@ -class Uint8Array {} From 6ebfab95e26c44d096313090832d67da93f62492 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 21:59:02 +0300 Subject: [PATCH 083/139] init --- example/lib/main.dart | 1 + lib/deno_postgres_interop.dart | 1 + lib/src/query.dart | 11 ++++++++++- lib/src/query_result.dart | 7 ++++++- lib/src/result_type.dart | 12 ++++++++++++ 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 lib/src/result_type.dart diff --git a/example/lib/main.dart b/example/lib/main.dart index 5f04316..1ae92a5 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -19,6 +19,7 @@ Future fetch(Request _) async { return Response( [ result.command == CommandType.select, + result.query.resultType, ...result.rows.map(rowToPrettyString), ].join('\n\n'), ); diff --git a/lib/deno_postgres_interop.dart b/lib/deno_postgres_interop.dart index 1ba90c6..9bcb816 100644 --- a/lib/deno_postgres_interop.dart +++ b/lib/deno_postgres_interop.dart @@ -4,6 +4,7 @@ library; export 'src/client.dart'; export 'src/command_type.dart'; export 'src/isolation_level.dart'; +export 'src/query.dart'; export 'src/query_client.dart'; export 'src/query_object.dart' show QueryArguments; export 'src/query_object_result.dart'; diff --git a/lib/src/query.dart b/lib/src/query.dart index e9bb596..5c54db3 100644 --- a/lib/src/query.dart +++ b/lib/src/query.dart @@ -1,5 +1,14 @@ import 'dart:js_interop'; +import 'dart:js_util'; + +import 'package:deno_postgres_interop/src/result_type.dart'; /// [deno-postgres@v0.17.0/Query](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query). @JS() -class Query {} +class Query {} + +/// [deno-postgres@v0.17.0/Query](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query). +extension QueryProps on Query { + /// [deno-postgres@v0.17.0/Query/result_type](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#prop_result_type). + ResultType get resultType => getProperty(this, 'result_type'); +} diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart index c3db0e5..cbc9adf 100644 --- a/lib/src/query_result.dart +++ b/lib/src/query_result.dart @@ -2,10 +2,15 @@ import 'dart:js_interop'; import 'dart:js_util'; import 'package:deno_postgres_interop/src/command_type.dart'; +import 'package:deno_postgres_interop/src/query.dart'; +import 'package:deno_postgres_interop/src/result_type.dart'; /// [deno-postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). @JS() -class QueryResult {} +class QueryResult { + /// [deno-postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). + external Query get query; +} /// [deno-postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). extension QueryResultProps on QueryResult { diff --git a/lib/src/result_type.dart b/lib/src/result_type.dart new file mode 100644 index 0000000..cfdb9d0 --- /dev/null +++ b/lib/src/result_type.dart @@ -0,0 +1,12 @@ +/// [postgres@v0.17.0/ResultType](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=ResultType). +enum ResultType { + /// array. + array, + + /// object. + object; + + /// Parses a string containing an [ResultType] literal into its instance. + static ResultType parse(String string) => + values.firstWhere((e) => e.name.toUpperCase() == string); +} From 20e5d3fe52ea62f6e94b926f374aa02c956d4a72 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 22:00:23 +0300 Subject: [PATCH 084/139] mini upd --- lib/src/query.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/query.dart b/lib/src/query.dart index 5c54db3..5f898b2 100644 --- a/lib/src/query.dart +++ b/lib/src/query.dart @@ -10,5 +10,7 @@ class Query {} /// [deno-postgres@v0.17.0/Query](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query). extension QueryProps on Query { /// [deno-postgres@v0.17.0/Query/result_type](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#prop_result_type). - ResultType get resultType => getProperty(this, 'result_type'); + ResultType get resultType => ResultType.parse( + getProperty(this, 'result_type'), + ); } From 8f965ff80ee104822fdcf0c1f9e9c18bccd37d45 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 22:17:01 +0300 Subject: [PATCH 085/139] working --- lib/src/query.dart | 5 ++--- lib/src/result_type.dart | 4 ---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/src/query.dart b/lib/src/query.dart index 5f898b2..39edd68 100644 --- a/lib/src/query.dart +++ b/lib/src/query.dart @@ -10,7 +10,6 @@ class Query {} /// [deno-postgres@v0.17.0/Query](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query). extension QueryProps on Query { /// [deno-postgres@v0.17.0/Query/result_type](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#prop_result_type). - ResultType get resultType => ResultType.parse( - getProperty(this, 'result_type'), - ); + ResultType get resultType => + ResultType.values[getProperty(this, 'result_type')]; } diff --git a/lib/src/result_type.dart b/lib/src/result_type.dart index cfdb9d0..22bcf84 100644 --- a/lib/src/result_type.dart +++ b/lib/src/result_type.dart @@ -5,8 +5,4 @@ enum ResultType { /// object. object; - - /// Parses a string containing an [ResultType] literal into its instance. - static ResultType parse(String string) => - values.firstWhere((e) => e.name.toUpperCase() == string); } From 8075339194cc1b4d1f5b90f457e99c5111ddc604 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Mon, 18 Sep 2023 22:23:00 +0300 Subject: [PATCH 086/139] remove generic --- lib/src/query.dart | 4 ++-- lib/src/query_object_result.dart | 2 +- lib/src/query_result.dart | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/src/query.dart b/lib/src/query.dart index 39edd68..8d612bb 100644 --- a/lib/src/query.dart +++ b/lib/src/query.dart @@ -5,10 +5,10 @@ import 'package:deno_postgres_interop/src/result_type.dart'; /// [deno-postgres@v0.17.0/Query](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query). @JS() -class Query {} +class Query {} /// [deno-postgres@v0.17.0/Query](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query). -extension QueryProps on Query { +extension QueryProps on Query { /// [deno-postgres@v0.17.0/Query/result_type](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#prop_result_type). ResultType get resultType => ResultType.values[getProperty(this, 'result_type')]; diff --git a/lib/src/query_object_result.dart b/lib/src/query_object_result.dart index 796335a..56b3e1f 100644 --- a/lib/src/query_object_result.dart +++ b/lib/src/query_object_result.dart @@ -11,7 +11,7 @@ class QueryObjectResult extends QueryResult { external List? get columns; /// [deno-postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). - external factory QueryObjectResult(Query query); + external factory QueryObjectResult(Query query); } /// [deno-postgres@v0.17.0/QueryObjectResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectResult). diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart index cbc9adf..fbff5e6 100644 --- a/lib/src/query_result.dart +++ b/lib/src/query_result.dart @@ -3,13 +3,12 @@ import 'dart:js_util'; import 'package:deno_postgres_interop/src/command_type.dart'; import 'package:deno_postgres_interop/src/query.dart'; -import 'package:deno_postgres_interop/src/result_type.dart'; /// [deno-postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). @JS() class QueryResult { /// [deno-postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). - external Query get query; + external Query get query; } /// [deno-postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). From 99010b34c68b7a835d87042b889eacff29de96b6 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 16:45:05 +0300 Subject: [PATCH 087/139] upd --- example/lib/main.dart | 8 ++++++++ lib/src/query_object_options.dart | 2 ++ lib/src/row_description.dart | 11 ++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 1ae92a5..3de8f95 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -18,6 +18,14 @@ Future fetch(Request _) async { return Response( [ + 'warnings = ${result.warnings}', + ''' +rowDescription = + columnCount = ${result.rowDescription?.columnCount} + columns = +${result.rowDescription?.columns.map((e) => ' name = ${e.name}').join('\n')} + ''', + 'rowCount = ${result.rowCount}', result.command == CommandType.select, result.query.resultType, ...result.rows.map(rowToPrettyString), diff --git a/lib/src/query_object_options.dart b/lib/src/query_object_options.dart index 0b07f2a..09a269e 100644 --- a/lib/src/query_object_options.dart +++ b/lib/src/query_object_options.dart @@ -1,6 +1,8 @@ +import 'dart:js_interop'; import 'dart:js_util'; /// [deno-postgres@v0.17.0/QueryObjectOptions](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectOptions). +@JS() class QueryObjectOptions { /// [deno-postgres@v0.17.0/QueryObjectOptions/fields](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectOptions#prop_fields). external List? get fields; diff --git a/lib/src/row_description.dart b/lib/src/row_description.dart index b8c4dde..e683d16 100644 --- a/lib/src/row_description.dart +++ b/lib/src/row_description.dart @@ -1,12 +1,21 @@ +import 'dart:js_interop'; import 'dart:js_util'; /// [deno-postgres@v0.17.0/RowDescription](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=RowDescription). +@JS() class RowDescription { /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=RowDescription#ctor_0 - external factory RowDescription(int columnsCount, List columns); + external int get columnCount; + + /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=RowDescription#ctor_0 + external List get columns; + + /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=RowDescription#ctor_0 + external factory RowDescription(int columnCount, List columns); } /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). +@JS() class Column { /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). external String get name; From ee30c72360b53d9cb53d28b423c73cb236b6564e Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 17:11:42 +0300 Subject: [PATCH 088/139] init --- example/lib/main.dart | 6 +++ lib/src/query_result.dart | 4 ++ lib/src/row_description.dart | 81 ++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 lib/src/row_description.dart diff --git a/example/lib/main.dart b/example/lib/main.dart index 1ae92a5..3ac3c71 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -19,6 +19,12 @@ Future fetch(Request _) async { return Response( [ result.command == CommandType.select, + ''' +rowDescription = + columnCount = ${result.rowDescription?.columnCount} + columns = +${result.rowDescription?.columns.map((e) => ' name = ${e.name}').join('\n')} + ''', result.query.resultType, ...result.rows.map(rowToPrettyString), ].join('\n\n'), diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart index fbff5e6..19cb16d 100644 --- a/lib/src/query_result.dart +++ b/lib/src/query_result.dart @@ -3,12 +3,16 @@ import 'dart:js_util'; import 'package:deno_postgres_interop/src/command_type.dart'; import 'package:deno_postgres_interop/src/query.dart'; +import 'package:deno_postgres_interop/src/row_description.dart'; /// [deno-postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). @JS() class QueryResult { /// [deno-postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). external Query get query; + + /// [deno-postgres@v0.17.0/QueryResult/rowDescription](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#accessor_rowDescription). + external RowDescription? get rowDescription; } /// [deno-postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). diff --git a/lib/src/row_description.dart b/lib/src/row_description.dart new file mode 100644 index 0000000..e683d16 --- /dev/null +++ b/lib/src/row_description.dart @@ -0,0 +1,81 @@ +import 'dart:js_interop'; +import 'dart:js_util'; + +/// [deno-postgres@v0.17.0/RowDescription](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=RowDescription). +@JS() +class RowDescription { + /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=RowDescription#ctor_0 + external int get columnCount; + + /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=RowDescription#ctor_0 + external List get columns; + + /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=RowDescription#ctor_0 + external factory RowDescription(int columnCount, List columns); +} + +/// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). +@JS() +class Column { + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external String get name; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get tableOid; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get index; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get typeOid; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get columnLength; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get typeModifier; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column#ctor_0). + factory Column({ + required String name, + required int tableOid, + required int index, + required int typeOid, + required int columnLength, + required int typeModifier, + required ColumnFormat format, + }) => + callConstructor('Column', [ + name, + tableOid, + index, + typeOid, + columnLength, + typeModifier, + format.id, + ]); +} + +/// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). +extension ColumnProps on Column { + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + ColumnFormat get format => ColumnFormat.values + .firstWhere((e) => e.id == getProperty(this, 'format')); +} + +/// enum Format { +/// TEXT = 0, +/// BINARY = 1, +/// } +enum ColumnFormat { + /// text. + text(0), + + /// binary. + binary(1); + + /// Used for interop. + final int id; + + const ColumnFormat(this.id); +} From 9000f589556d403c900df7014095c32fabf42791 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 17:29:45 +0300 Subject: [PATCH 089/139] upd --- lib/src/column.dart | 68 +++++++++++++++++++++++++++++++++++ lib/src/row_description.dart | 69 ++---------------------------------- 2 files changed, 70 insertions(+), 67 deletions(-) create mode 100644 lib/src/column.dart diff --git a/lib/src/column.dart b/lib/src/column.dart new file mode 100644 index 0000000..725c5dd --- /dev/null +++ b/lib/src/column.dart @@ -0,0 +1,68 @@ +import 'dart:js_interop'; +import 'dart:js_util'; + +/// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). +@JS() +class Column { + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external String get name; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get tableOid; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get index; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get typeOid; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get columnLength; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + external int get typeModifier; + + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column#ctor_0). + factory Column({ + required String name, + required int tableOid, + required int index, + required int typeOid, + required int columnLength, + required int typeModifier, + required ColumnFormat format, + }) => + callConstructor('Column', [ + name, + tableOid, + index, + typeOid, + columnLength, + typeModifier, + format.id, + ]); +} + +/// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). +extension ColumnProps on Column { + /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). + ColumnFormat get format => ColumnFormat.values + .firstWhere((e) => e.id == getProperty(this, 'format')); +} + +/// enum Format { +/// TEXT = 0, +/// BINARY = 1, +/// } +enum ColumnFormat { + /// text. + text(0), + + /// binary. + binary(1); + + /// Used for interop. + final int id; + + const ColumnFormat(this.id); +} diff --git a/lib/src/row_description.dart b/lib/src/row_description.dart index e683d16..9db68c4 100644 --- a/lib/src/row_description.dart +++ b/lib/src/row_description.dart @@ -1,5 +1,6 @@ import 'dart:js_interop'; -import 'dart:js_util'; + +import 'package:deno_postgres_interop/src/column.dart'; /// [deno-postgres@v0.17.0/RowDescription](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=RowDescription). @JS() @@ -13,69 +14,3 @@ class RowDescription { /// https://deno.land/x/postgres@v0.17.0/query/query.ts?s=RowDescription#ctor_0 external factory RowDescription(int columnCount, List columns); } - -/// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). -@JS() -class Column { - /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). - external String get name; - - /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). - external int get tableOid; - - /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). - external int get index; - - /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). - external int get typeOid; - - /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). - external int get columnLength; - - /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). - external int get typeModifier; - - /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column#ctor_0). - factory Column({ - required String name, - required int tableOid, - required int index, - required int typeOid, - required int columnLength, - required int typeModifier, - required ColumnFormat format, - }) => - callConstructor('Column', [ - name, - tableOid, - index, - typeOid, - columnLength, - typeModifier, - format.id, - ]); -} - -/// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). -extension ColumnProps on Column { - /// [deno-postgres@v0.17.0/Column](https://deno.land/x/postgres@v0.17.0/query/decode.ts?s=Column). - ColumnFormat get format => ColumnFormat.values - .firstWhere((e) => e.id == getProperty(this, 'format')); -} - -/// enum Format { -/// TEXT = 0, -/// BINARY = 1, -/// } -enum ColumnFormat { - /// text. - text(0), - - /// binary. - binary(1); - - /// Used for interop. - final int id; - - const ColumnFormat(this.id); -} From 3252e45f1e533f21cc892e0d3c734caf8dc6d0ab Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 17:51:36 +0300 Subject: [PATCH 090/139] init --- example/lib/main.dart | 1 + lib/src/notice.dart | 98 +++++++++++++++++++++++++++++++++++++++ lib/src/query_result.dart | 4 ++ 3 files changed, 103 insertions(+) create mode 100644 lib/src/notice.dart diff --git a/example/lib/main.dart b/example/lib/main.dart index 3ac3c71..a837448 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -19,6 +19,7 @@ Future fetch(Request _) async { return Response( [ result.command == CommandType.select, + 'warnings = ${result.warnings}', ''' rowDescription = columnCount = ${result.rowDescription?.columnCount} diff --git a/lib/src/notice.dart b/lib/src/notice.dart new file mode 100644 index 0000000..a1579ef --- /dev/null +++ b/lib/src/notice.dart @@ -0,0 +1,98 @@ +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). +@JS() +class Notice { + /// [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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + 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). + external String? get routine; + + /// [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, + required String message, + String? detail, + String? hint, + String? position, + String? internalPosition, + String? internalQuery, + String? where, + String? schema, + String? table, + String? column, + String? dataType, + String? constraint, + String? file, + String? line, + String? routine, + }) { + return jsify({ + 'severity': severity, + 'code': code, + 'message': message, + if (detail != null) 'detail': detail, + if (hint != null) 'hint': hint, + if (position != null) 'position': position, + if (internalPosition != null) 'internalPosition': internalPosition, + if (internalQuery != null) 'internalQuery': internalQuery, + if (where != null) 'where': where, + if (schema != null) 'schema': schema, + if (table != null) 'table': table, + if (column != null) 'column': column, + if (dataType != null) 'dataType': dataType, + if (constraint != null) 'constraint': constraint, + if (file != null) 'file': file, + if (line != null) 'line': line, + if (routine != null) 'routine': routine, + }) as Notice; + } +} diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart index 19cb16d..eccac89 100644 --- a/lib/src/query_result.dart +++ b/lib/src/query_result.dart @@ -2,12 +2,16 @@ import 'dart:js_interop'; import 'dart:js_util'; import 'package:deno_postgres_interop/src/command_type.dart'; +import 'package:deno_postgres_interop/src/notice.dart'; import 'package:deno_postgres_interop/src/query.dart'; import 'package:deno_postgres_interop/src/row_description.dart'; /// [deno-postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). @JS() class QueryResult { + /// [deno-postgres@v0.17.0/QueryResult/warnings](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_warnings). + external List get warnings; + /// [deno-postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). external Query get query; From 3ff98197df7de8e9eb633425baaef9b4fea1af5f Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 17:57:11 +0300 Subject: [PATCH 091/139] rm duplicate --- example/lib/main.dart | 9 --------- 1 file changed, 9 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index aff8c47..8c30d03 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -23,15 +23,6 @@ Future fetch(Request _) async { rowDescription = columnCount = ${result.rowDescription?.columnCount} columns = -${result.rowDescription?.columns.map((e) => ' name = ${e.name}').join('\n')} - ''', - 'rowCount = ${result.rowCount}', - result.command == CommandType.select, - 'warnings = ${result.warnings}', - ''' -rowDescription = - columnCount = ${result.rowDescription?.columnCount} - columns = ${result.rowDescription?.columns.map((e) => ' name = ${e.name}').join('\n')} ''', result.query.resultType, From 69f02683b9b4cb5db3d8009f320d49faa62c38f4 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 17:57:36 +0300 Subject: [PATCH 092/139] restore --- example/lib/main.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/example/lib/main.dart b/example/lib/main.dart index 8c30d03..a837448 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -18,6 +18,7 @@ Future fetch(Request _) async { return Response( [ + result.command == CommandType.select, 'warnings = ${result.warnings}', ''' rowDescription = From 7c2474a4ad83dc157eeea0599af75d58253985da Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 17:58:15 +0300 Subject: [PATCH 093/139] restore order --- lib/src/query_result.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart index 13bc9cc..bad643d 100644 --- a/lib/src/query_result.dart +++ b/lib/src/query_result.dart @@ -9,9 +9,6 @@ import 'package:deno_postgres_interop/src/row_description.dart'; /// [deno-postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). @JS() class QueryResult { - /// [deno-postgres@v0.17.0/QueryResult/rowDescription](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#accessor_rowDescription). - external RowDescription? get rowDescription; - /// [deno-postgres@v0.17.0/QueryResult/rowCount](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_rowCount). external int? get rowCount; @@ -21,6 +18,9 @@ class QueryResult { /// [deno-postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). external Query get query; + /// [deno-postgres@v0.17.0/QueryResult/rowDescription](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#accessor_rowDescription). + external RowDescription? get rowDescription; + /// [deno-postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). external factory QueryResult(Query query); From 5516b9fcc4d0a9b19b3a6b799b637a68f73ceafa Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 21:09:44 +0300 Subject: [PATCH 094/139] part --- lib/src/client_configuration.dart | 18 +++++++++++ lib/src/client_options.dart | 15 +++++++++ lib/src/pool.dart | 51 +++++++++++++++++++++++++++++++ lib/src/pool_client.dart | 17 +++++++++++ lib/src/transport.dart | 2 ++ lib/src/undefined.dart | 5 +++ 6 files changed, 108 insertions(+) create mode 100644 lib/src/client_configuration.dart create mode 100644 lib/src/client_options.dart create mode 100644 lib/src/pool.dart create mode 100644 lib/src/pool_client.dart create mode 100644 lib/src/transport.dart create mode 100644 lib/src/undefined.dart diff --git a/lib/src/client_configuration.dart b/lib/src/client_configuration.dart new file mode 100644 index 0000000..fe36635 --- /dev/null +++ b/lib/src/client_configuration.dart @@ -0,0 +1,18 @@ +import 'dart:js_interop'; + +import 'package:deno_postgres_interop/src/transport.dart'; + +/// [deno-postgres@v0.17.0/ClientConfiguration](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration). +@JS() +class ClientConfiguration { + external String get applicationName; + // external ConnectionOptions get connection; + external String get database; + external String get hostname; + external Transport get host_type; + // external Record get options; + external String? get password; + external int get port; + // external TLSOptions get tls; + external String get user; +} diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart new file mode 100644 index 0000000..597c4bb --- /dev/null +++ b/lib/src/client_options.dart @@ -0,0 +1,15 @@ +import 'package:deno_postgres_interop/src/transport.dart'; + +/// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). +class ClientOptions { + external String get applicationName; + // external Partial get connection; + external String get database; + external String get hostname; + external Transport get host_type; +// external String | Record get options; + external String get password; +// external String | number get port; + // external Partial get tls; + external String get user; +} diff --git a/lib/src/pool.dart b/lib/src/pool.dart new file mode 100644 index 0000000..a44cdd2 --- /dev/null +++ b/lib/src/pool.dart @@ -0,0 +1,51 @@ +import 'dart:js_util'; + +import 'package:deno_postgres_interop/src/client_options.dart'; +import 'package:deno_postgres_interop/src/undefined.dart'; + +/// [deno-postgres@v0.17.0/Pool](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Pool). +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({ + required int size, + bool? lazy, + }) => + callConstructor('Pool', [ + undefined, + size, + if (lazy != null) lazy, + ]); + + /// [deno-postgres@v0.17.0/Pool/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Pool#ctor_0). + factory Pool.withOptions({ + required ClientOptions connectionParams, + required int size, + bool? lazy, + }) => + callConstructor('Pool', [ + connectionParams, + size, + if (lazy != null) lazy, + ]); + + /// [deno-postgres@v0.17.0/Pool/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Pool#ctor_0). + factory Pool.withString({ + required String connectionString, + required int size, + bool? lazy, + }) => + callConstructor('Pool', [ + connectionString, + size, + if (lazy != null) lazy, + ]); + +// available: number +// size: number + +// connect(): Promise + +// end(): Promise + +// initialized(): Promise +} diff --git a/lib/src/pool_client.dart b/lib/src/pool_client.dart new file mode 100644 index 0000000..6b7defb --- /dev/null +++ b/lib/src/pool_client.dart @@ -0,0 +1,17 @@ +import 'dart:js_interop'; + +import 'package:deno_postgres_interop/src/client_configuration.dart'; +import 'package:deno_postgres_interop/src/query_client.dart'; + +/// [deno-postgres@v0.17.0/PoolClient](https://deno.land/x/postgres@v0.17.0/mod.ts?s=PoolClient). +@JS() +class PoolClient extends QueryClient { + /// [deno-postgres@v0.17.0/PoolClient/constructor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=PoolClient#ctor_0). + external factory PoolClient( + ClientConfiguration config, + void Function() releaseCallback, + ); + + /// [deno-postgres@v0.17.0/PoolClient/constructor/release](https://deno.land/x/postgres@v0.17.0/mod.ts?s=PoolClient#method_release_0). + external void release(); +} diff --git a/lib/src/transport.dart b/lib/src/transport.dart new file mode 100644 index 0000000..293ceec --- /dev/null +++ b/lib/src/transport.dart @@ -0,0 +1,2 @@ +// // "tcp" | "socket" +class Transport {} diff --git a/lib/src/undefined.dart b/lib/src/undefined.dart new file mode 100644 index 0000000..d259be9 --- /dev/null +++ b/lib/src/undefined.dart @@ -0,0 +1,5 @@ +// The js undefined +import 'dart:js_interop'; + +@JS() +external dynamic get undefined; From 38540f168e608f3730fb535ef38101fadbb534b5 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 21:16:40 +0300 Subject: [PATCH 095/139] more prope --- lib/src/client_options.dart | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart index 597c4bb..79d48be 100644 --- a/lib/src/client_options.dart +++ b/lib/src/client_options.dart @@ -1,15 +1,39 @@ +import 'dart:js_util'; + import 'package:deno_postgres_interop/src/transport.dart'; /// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). class ClientOptions { + /// [deno-postgres@v0.17.0/ClientOptions/applicationName](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_applicationName). external String get applicationName; + + /// [deno-postgres@v0.17.0/ClientOptions/connection](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_connection). // external Partial get connection; + + /// [deno-postgres@v0.17.0/ClientOptions/database](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_database). external String get database; + + /// [deno-postgres@v0.17.0/ClientOptions/hostname](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_hostname). external String get hostname; - external Transport get host_type; -// external String | Record get options; + + /// [deno-postgres@v0.17.0/ClientOptions/options](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_options). + // external String | Record get options; + + /// [deno-postgres@v0.17.0/ClientOptions/password](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_password). external String get password; -// external String | number get port; + + /// [deno-postgres@v0.17.0/ClientOptions/port](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_port). + // external String | number get port; + + /// [deno-postgres@v0.17.0/ClientOptions/tls](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_tls). // external Partial get tls; + + /// [deno-postgres@v0.17.0/ClientOptions/user](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_applicationName/user). external String get user; } + +/// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). +extension ClientOptionsProps on ClientOptions { + /// [deno-postgres@v0.17.0/ClientOptions/host_type](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_host_type). + Transport get hostType => getProperty(this, 'host_type'); +} From b0391f12848bdea10b899cf3b51f2538f32b8d6f Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 21:20:35 +0300 Subject: [PATCH 096/139] upd --- lib/src/client_configuration.dart | 31 ++++++++++++++++++++++++++++--- lib/src/connection_options.dart | 1 + lib/src/tls_options.dart | 1 + 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 lib/src/connection_options.dart create mode 100644 lib/src/tls_options.dart diff --git a/lib/src/client_configuration.dart b/lib/src/client_configuration.dart index fe36635..5ff9fb0 100644 --- a/lib/src/client_configuration.dart +++ b/lib/src/client_configuration.dart @@ -1,18 +1,43 @@ import 'dart:js_interop'; +import 'dart:js_util'; +import 'package:deno_postgres_interop/src/connection_options.dart'; +import 'package:deno_postgres_interop/src/tls_options.dart'; import 'package:deno_postgres_interop/src/transport.dart'; /// [deno-postgres@v0.17.0/ClientConfiguration](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration). @JS() class ClientConfiguration { + /// [deno-postgres@v0.17.0/ClientConfiguration/applicationName](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration#prop_applicationName). external String get applicationName; - // external ConnectionOptions get connection; + + /// [deno-postgres@v0.17.0/ClientConfiguration/connection](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration#prop_connection). + external ConnectionOptions get connection; + + /// [deno-postgres@v0.17.0/ClientConfiguration/database](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration#prop_database). external String get database; + + /// [deno-postgres@v0.17.0/ClientConfiguration/hostname](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration#prop_hostname). external String get hostname; - external Transport get host_type; + + /// [deno-postgres@v0.17.0/ClientConfiguration/options](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration#prop_options). // external Record get options; + + /// [deno-postgres@v0.17.0/ClientConfiguration/password](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration#prop_password). external String? get password; + + /// [deno-postgres@v0.17.0/ClientConfiguration/port](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration#prop_port). external int get port; - // external TLSOptions get tls; + + /// [deno-postgres@v0.17.0/ClientConfiguration/tls](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration#prop_tls). + external TLSOptions get tls; + + /// [deno-postgres@v0.17.0/ClientConfiguration/user](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration#prop_user). external String get user; } + +/// [deno-postgres@v0.17.0/ClientConfiguration](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration). +extension ClientConfigurationProps on ClientConfiguration { + /// [deno-postgres@v0.17.0/ClientConfiguration/host_type](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration#prop_host_type). + Transport get hostType => getProperty(this, 'host_type'); +} diff --git a/lib/src/connection_options.dart b/lib/src/connection_options.dart new file mode 100644 index 0000000..c25a615 --- /dev/null +++ b/lib/src/connection_options.dart @@ -0,0 +1 @@ +class ConnectionOptions {} diff --git a/lib/src/tls_options.dart b/lib/src/tls_options.dart new file mode 100644 index 0000000..2ff4582 --- /dev/null +++ b/lib/src/tls_options.dart @@ -0,0 +1 @@ +class TLSOptions {} From 747a4b8db519e448cc179bc7ce2aa242c60c2e76 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 21:31:29 +0300 Subject: [PATCH 097/139] fix --- lib/src/connection_options.dart | 1 + lib/src/isolation_level.dart | 8 ++++---- lib/src/tls_options.dart | 1 + lib/src/transport.dart | 2 +- lib/src/undefined.dart | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/src/connection_options.dart b/lib/src/connection_options.dart index c25a615..933ac1e 100644 --- a/lib/src/connection_options.dart +++ b/lib/src/connection_options.dart @@ -1 +1,2 @@ +/// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ConnectionOptions). class ConnectionOptions {} diff --git a/lib/src/isolation_level.dart b/lib/src/isolation_level.dart index 46ee541..2c0a48f 100644 --- a/lib/src/isolation_level.dart +++ b/lib/src/isolation_level.dart @@ -1,12 +1,12 @@ -/// [deno-postgres@v0.17.0/Transaction Isolation](https://www.postgresql.org/docs/current/transaction-iso.html). +/// [Transaction Isolation](https://www.postgresql.org/docs/current/transaction-iso.html). enum IsolationLevel { - /// [deno-postgres@v0.17.0/Transaction Isolation/Read Committed Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-READ-COMMITTED). + /// [Transaction Isolation/Read Committed Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-READ-COMMITTED). readCommitted, - /// [deno-postgres@v0.17.0/Transaction Isolation/Repeatable Read Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-REPEATABLE-READ). + /// [Transaction Isolation/Repeatable Read Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-REPEATABLE-READ). repeatableRead, - /// [deno-postgres@v0.17.0/Transaction Isolation/Serializable Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-SERIALIZABLE). + /// [Transaction Isolation/Serializable Isolation Level](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-SERIALIZABLE). serializable; /// Parses a string containing an [IsolationLevel] literal into its instance. diff --git a/lib/src/tls_options.dart b/lib/src/tls_options.dart index 2ff4582..7ac8dfe 100644 --- a/lib/src/tls_options.dart +++ b/lib/src/tls_options.dart @@ -1 +1,2 @@ +/// [deno-postgres@v0.17.0/TLSOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TLSOptions). class TLSOptions {} diff --git a/lib/src/transport.dart b/lib/src/transport.dart index 293ceec..c913319 100644 --- a/lib/src/transport.dart +++ b/lib/src/transport.dart @@ -1,2 +1,2 @@ -// // "tcp" | "socket" +/// "tcp" | "socket" class Transport {} diff --git a/lib/src/undefined.dart b/lib/src/undefined.dart index d259be9..4615e4c 100644 --- a/lib/src/undefined.dart +++ b/lib/src/undefined.dart @@ -1,5 +1,5 @@ -// The js undefined import 'dart:js_interop'; +/// The js' undefined. @JS() external dynamic get undefined; From da1e5bb9c1a55f12ba1373d4459c1ed0c98ac73e Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 21:33:48 +0300 Subject: [PATCH 098/139] todos --- lib/src/connection_options.dart | 1 + lib/src/tls_options.dart | 1 + lib/src/transport.dart | 1 + 3 files changed, 3 insertions(+) diff --git a/lib/src/connection_options.dart b/lib/src/connection_options.dart index 933ac1e..7102a49 100644 --- a/lib/src/connection_options.dart +++ b/lib/src/connection_options.dart @@ -1,2 +1,3 @@ +// TODO: /// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ConnectionOptions). class ConnectionOptions {} diff --git a/lib/src/tls_options.dart b/lib/src/tls_options.dart index 7ac8dfe..a457bb3 100644 --- a/lib/src/tls_options.dart +++ b/lib/src/tls_options.dart @@ -1,2 +1,3 @@ +// TODO: /// [deno-postgres@v0.17.0/TLSOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TLSOptions). class TLSOptions {} diff --git a/lib/src/transport.dart b/lib/src/transport.dart index c913319..ea72431 100644 --- a/lib/src/transport.dart +++ b/lib/src/transport.dart @@ -1,2 +1,3 @@ +// TODO: /// "tcp" | "socket" class Transport {} From f4608b0ef9e85a14ee79e1ad921452f176e89136 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 21:39:37 +0300 Subject: [PATCH 099/139] upd --- lib/src/client_configuration.dart | 2 +- lib/src/client_options.dart | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/src/client_configuration.dart b/lib/src/client_configuration.dart index 5ff9fb0..04da92d 100644 --- a/lib/src/client_configuration.dart +++ b/lib/src/client_configuration.dart @@ -21,7 +21,7 @@ class ClientConfiguration { external String get hostname; /// [deno-postgres@v0.17.0/ClientConfiguration/options](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration#prop_options). - // external Record get options; + external Map get options; /// [deno-postgres@v0.17.0/ClientConfiguration/password](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration#prop_password). external String? get password; diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart index 79d48be..a283e6b 100644 --- a/lib/src/client_options.dart +++ b/lib/src/client_options.dart @@ -16,9 +16,6 @@ class ClientOptions { /// [deno-postgres@v0.17.0/ClientOptions/hostname](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_hostname). external String get hostname; - /// [deno-postgres@v0.17.0/ClientOptions/options](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_options). - // external String | Record get options; - /// [deno-postgres@v0.17.0/ClientOptions/password](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_password). external String get password; @@ -36,4 +33,23 @@ class ClientOptions { extension ClientOptionsProps on ClientOptions { /// [deno-postgres@v0.17.0/ClientOptions/host_type](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_host_type). Transport get hostType => getProperty(this, 'host_type'); + + /// [deno-postgres@v0.17.0/ClientOptions/options](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_options). + /// + /// Either this or [optionsMap] is null. + String? get optionsString { + final prop = getProperty(this, 'options'); + + return prop is! String ? null : prop; + } + + /// [deno-postgres@v0.17.0/ClientOptions/options](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_options). + /// + /// Either this or [optionsString] is null. + // external Map? get options; + Map? get optionsMap { + final prop = getProperty(this, 'options'); + + return prop is String ? null : prop as Map; + } } From 6cf6999296f82a0794fd706747ba8d9f1eab8b81 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 21:57:36 +0300 Subject: [PATCH 100/139] constructor --- lib/src/client_configuration.dart | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/src/client_configuration.dart b/lib/src/client_configuration.dart index 04da92d..b989092 100644 --- a/lib/src/client_configuration.dart +++ b/lib/src/client_configuration.dart @@ -34,6 +34,32 @@ class ClientConfiguration { /// [deno-postgres@v0.17.0/ClientConfiguration/user](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration#prop_user). external String get user; + + /// [deno-postgres@v0.17.0/ClientConfiguration](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration). + factory ClientConfiguration({ + required String applicationName, + required ConnectionOptions connection, + required String database, + required String hostname, + required String options, + required int port, + required TLSOptions tls, + required String user, + required Transport hostType, + String? password, + }) => + jsify({ + 'applicationName': applicationName, + 'connection': connection, + 'database': database, + 'hostname': hostname, + 'options': options, + if (password != null) 'password': password, + 'port': port, + 'tls': tls, + 'user': user, + 'hostType': hostType, + }) as ClientConfiguration; } /// [deno-postgres@v0.17.0/ClientConfiguration](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration). From 0e7420e713a69662c524a93560c9edf15cfe9198 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 22:01:15 +0300 Subject: [PATCH 101/139] parse --- lib/src/client_configuration.dart | 4 ++-- lib/src/transport.dart | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/src/client_configuration.dart b/lib/src/client_configuration.dart index b989092..005019a 100644 --- a/lib/src/client_configuration.dart +++ b/lib/src/client_configuration.dart @@ -58,12 +58,12 @@ class ClientConfiguration { 'port': port, 'tls': tls, 'user': user, - 'hostType': hostType, + 'hostType': hostType.name, }) as ClientConfiguration; } /// [deno-postgres@v0.17.0/ClientConfiguration](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration). extension ClientConfigurationProps on ClientConfiguration { /// [deno-postgres@v0.17.0/ClientConfiguration/host_type](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ClientConfiguration#prop_host_type). - Transport get hostType => getProperty(this, 'host_type'); + Transport get hostType => Transport.parse(getProperty(this, 'host_type')); } diff --git a/lib/src/transport.dart b/lib/src/transport.dart index ea72431..1223791 100644 --- a/lib/src/transport.dart +++ b/lib/src/transport.dart @@ -1,3 +1,12 @@ -// TODO: -/// "tcp" | "socket" -class Transport {} +/// TCP | SOCKET. +enum Transport { + /// tcp. + tcp, + + /// socket. + socket; + + /// Parses a string containing an [Transport] literal into its instance. + static Transport parse(String string) => + values.firstWhere((e) => e.name == string); +} From f6d66083a4447183a3ef8d088d51df0e630237a7 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Tue, 19 Sep 2023 22:10:17 +0300 Subject: [PATCH 102/139] todo --- lib/src/client_options.dart | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart index a283e6b..2b59ec6 100644 --- a/lib/src/client_options.dart +++ b/lib/src/client_options.dart @@ -7,6 +7,7 @@ class ClientOptions { /// [deno-postgres@v0.17.0/ClientOptions/applicationName](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_applicationName). external String get applicationName; + // TODO: /// [deno-postgres@v0.17.0/ClientOptions/connection](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_connection). // external Partial get connection; @@ -19,9 +20,7 @@ class ClientOptions { /// [deno-postgres@v0.17.0/ClientOptions/password](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_password). external String get password; - /// [deno-postgres@v0.17.0/ClientOptions/port](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_port). - // external String | number get port; - + // TODO: /// [deno-postgres@v0.17.0/ClientOptions/tls](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_tls). // external Partial get tls; @@ -40,16 +39,33 @@ extension ClientOptionsProps on ClientOptions { String? get optionsString { final prop = getProperty(this, 'options'); - return prop is! String ? null : prop; + return prop is String ? prop : null; } /// [deno-postgres@v0.17.0/ClientOptions/options](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_options). /// /// Either this or [optionsString] is null. - // external Map? get options; Map? get optionsMap { final prop = getProperty(this, 'options'); return prop is String ? null : prop as Map; } + + /// [deno-postgres@v0.17.0/ClientOptions/port](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_port). + /// + /// Either this or [port] is null. + String? get portString { + final prop = getProperty(this, 'port'); + + return prop is String ? prop : null; + } + + /// [deno-postgres@v0.17.0/ClientOptions/port](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_port). + /// + /// Either this or [portString] is null. + int? get port { + final prop = getProperty(this, 'port'); + + return prop is int ? prop : null; + } } From e6a36d008a19fe28a8cec6c4561a8c75fd23ad1b Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 18:03:25 +0300 Subject: [PATCH 103/139] upd --- lib/src/client_options.dart | 33 ++++++++++++++----- .../partial/partial_connection_options.dart | 22 +++++++++++++ lib/src/partial/partial_tls_options.dart | 18 ++++++++++ 3 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 lib/src/partial/partial_connection_options.dart create mode 100644 lib/src/partial/partial_tls_options.dart diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart index 2b59ec6..6f2b95c 100644 --- a/lib/src/client_options.dart +++ b/lib/src/client_options.dart @@ -1,5 +1,7 @@ import 'dart:js_util'; +import 'package:deno_postgres_interop/src/partial/partial_connection_options.dart'; +import 'package:deno_postgres_interop/src/partial/partial_tls_options.dart'; import 'package:deno_postgres_interop/src/transport.dart'; /// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). @@ -7,10 +9,6 @@ class ClientOptions { /// [deno-postgres@v0.17.0/ClientOptions/applicationName](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_applicationName). external String get applicationName; - // TODO: - /// [deno-postgres@v0.17.0/ClientOptions/connection](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_connection). - // external Partial get connection; - /// [deno-postgres@v0.17.0/ClientOptions/database](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_database). external String get database; @@ -20,10 +18,6 @@ class ClientOptions { /// [deno-postgres@v0.17.0/ClientOptions/password](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_password). external String get password; - // TODO: - /// [deno-postgres@v0.17.0/ClientOptions/tls](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_tls). - // external Partial get tls; - /// [deno-postgres@v0.17.0/ClientOptions/user](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_applicationName/user). external String get user; } @@ -68,4 +62,27 @@ extension ClientOptionsProps on ClientOptions { return prop is int ? prop : null; } + + /// [deno-postgres@v0.17.0/ClientOptions/connection](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_connection). + PartialConnectionOptions? get connection { + final map = + dartify(getProperty(this, 'connection')) as Map?; + + if (map == null) return null; + + final intervalProp = map['interval']; + + return PartialConnectionOptions( + attempts: map['attempts'] as int?, + interval: intervalProp is int ? intervalProp : null, + nextInterval: intervalProp is! int + ? intervalProp as int Function(int previousInterval)? + : null, + ); + } + + /// [deno-postgres@v0.17.0/ClientOptions/tls](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_tls). + PartialTLSOptions get tls { + // TODO: + } } diff --git a/lib/src/partial/partial_connection_options.dart b/lib/src/partial/partial_connection_options.dart new file mode 100644 index 0000000..f50c131 --- /dev/null +++ b/lib/src/partial/partial_connection_options.dart @@ -0,0 +1,22 @@ +/// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions +class PartialConnectionOptions { + /// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions#prop_attempts + final int? attempts; + + /// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions#prop_interval + /// + /// Either this or [interval] is null. + final int Function(int previousInterval)? nextInterval; + + /// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions#prop_interval + /// + /// Either this or [nextInterval] is null. + final int? interval; + + /// constructor. + PartialConnectionOptions({ + required this.attempts, + required this.nextInterval, + required this.interval, + }); +} diff --git a/lib/src/partial/partial_tls_options.dart b/lib/src/partial/partial_tls_options.dart new file mode 100644 index 0000000..8f46424 --- /dev/null +++ b/lib/src/partial/partial_tls_options.dart @@ -0,0 +1,18 @@ +/// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=TLSOptions +class PartialTLSOptions { + /// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=TLSOptions#prop_enabled + final bool? isEnabled; + + /// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=TLSOptions#prop_enfroce + final bool? isTLSEnforced; + + /// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=TLSOptions#prop_caCertificates + final List? caCertificates; + + /// constructor. + PartialTLSOptions({ + required this.isEnabled, + required this.isTLSEnforced, + required this.caCertificates, + }); +} From 2a99e770301660e173ff44fe10bf48b13f682100 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 18:19:19 +0300 Subject: [PATCH 104/139] upd --- lib/src/client_options.dart | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart index 6f2b95c..ff1c4f2 100644 --- a/lib/src/client_options.dart +++ b/lib/src/client_options.dart @@ -82,7 +82,16 @@ extension ClientOptionsProps on ClientOptions { } /// [deno-postgres@v0.17.0/ClientOptions/tls](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_tls). - PartialTLSOptions get tls { - // TODO: + PartialTLSOptions? get tls { + final map = + dartify(getProperty(this, 'connection')) as Map?; + + if (map == null) return null; + + return PartialTLSOptions( + caCertificates: map['caCertificates'] as List?, + isEnabled: map['enabled'] as bool?, + isTLSEnforced: map['enforced'] as bool?, + ); } } From b396b87f4473d0904a3d299aacd85bd6352ebf61 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 18:21:06 +0300 Subject: [PATCH 105/139] fix comments --- lib/src/partial/partial_tls_options.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/partial/partial_tls_options.dart b/lib/src/partial/partial_tls_options.dart index 8f46424..634df97 100644 --- a/lib/src/partial/partial_tls_options.dart +++ b/lib/src/partial/partial_tls_options.dart @@ -1,12 +1,12 @@ -/// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=TLSOptions +/// [deno-postgres@v0.17.0/TLSOptions](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=TLSOptions). class PartialTLSOptions { - /// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=TLSOptions#prop_enabled + /// [deno-postgres@v0.17.0/TLSOptions/enabled](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=TLSOptions#prop_enabled). final bool? isEnabled; - /// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=TLSOptions#prop_enfroce + /// [deno-postgres@v0.17.0/TLSOptions/enfroce](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=TLSOptions#prop_enfroce). final bool? isTLSEnforced; - /// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=TLSOptions#prop_caCertificates + /// [deno-postgres@v0.17.0/TLSOptions/caCertificates](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=TLSOptions#prop_caCertificates). final List? caCertificates; /// constructor. From be46787155e7c39b731082b108cd631ae552f134 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 18:23:01 +0300 Subject: [PATCH 106/139] upd --- lib/src/partial/partial_connection_options.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/partial/partial_connection_options.dart b/lib/src/partial/partial_connection_options.dart index f50c131..3a939b4 100644 --- a/lib/src/partial/partial_connection_options.dart +++ b/lib/src/partial/partial_connection_options.dart @@ -1,14 +1,14 @@ -/// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions +/// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions). class PartialConnectionOptions { - /// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions#prop_attempts + /// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions#prop_attempts). final int? attempts; - /// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions#prop_interval + /// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions#prop_interval). /// /// Either this or [interval] is null. final int Function(int previousInterval)? nextInterval; - /// https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions#prop_interval + /// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions#prop_interval). /// /// Either this or [nextInterval] is null. final int? interval; @@ -18,5 +18,5 @@ class PartialConnectionOptions { required this.attempts, required this.nextInterval, required this.interval, - }); + }) : assert(interval == null || nextInterval == null); } From 63bb9de8f76fb80d37438652348578ca9a043fba Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 18:35:44 +0300 Subject: [PATCH 107/139] upd --- lib/src/pool.dart | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/src/pool.dart b/lib/src/pool.dart index a44cdd2..5669484 100644 --- a/lib/src/pool.dart +++ b/lib/src/pool.dart @@ -1,7 +1,9 @@ import 'dart:js_util'; import 'package:deno_postgres_interop/src/client_options.dart'; +import 'package:deno_postgres_interop/src/pool_client.dart'; 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). class Pool { @@ -39,13 +41,23 @@ class Pool { size, if (lazy != null) lazy, ]); +} + +/// [deno-postgres@v0.17.0/Pool](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Pool). +extension PoolProps on Pool { + /// [deno-postgres@v0.17.0/Pool/size](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Pool#prop_size). + int get connectionsCount => getProperty(this, 'size'); -// available: number -// size: number + /// [deno-postgres@v0.17.0/Pool/available](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Pool#prop_available). + int get openConnectionsCount => getProperty(this, 'available'); -// connect(): Promise + /// [deno-postgres@v0.17.0/Pool/connect](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Pool#method_connect_0). + Future connect() => callFutureMethod(this, 'connect'); -// end(): Promise + /// [deno-postgres@v0.17.0/Pool/end](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Pool#method_end_0). + Future end() => callFutureMethod(this, 'end'); -// initialized(): Promise + /// [deno-postgres@v0.17.0/Pool/initialized](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Pool#method_initialized_0). + Future initializedConnectionsCount() => + callFutureMethod(this, 'initialized'); } From 08caea6e52ba0db6c1ede5c6ad7a72897858221b Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 19:20:24 +0300 Subject: [PATCH 108/139] upd --- lib/src/client_options.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart index ff1c4f2..2c262d6 100644 --- a/lib/src/client_options.dart +++ b/lib/src/client_options.dart @@ -7,25 +7,25 @@ import 'package:deno_postgres_interop/src/transport.dart'; /// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). class ClientOptions { /// [deno-postgres@v0.17.0/ClientOptions/applicationName](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_applicationName). - external String get applicationName; + external String? get applicationName; /// [deno-postgres@v0.17.0/ClientOptions/database](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_database). - external String get database; + external String? get database; /// [deno-postgres@v0.17.0/ClientOptions/hostname](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_hostname). - external String get hostname; + external String? get hostname; /// [deno-postgres@v0.17.0/ClientOptions/password](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_password). - external String get password; + external String? get password; /// [deno-postgres@v0.17.0/ClientOptions/user](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_applicationName/user). - external String get user; + external String? get user; } /// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). extension ClientOptionsProps on ClientOptions { /// [deno-postgres@v0.17.0/ClientOptions/host_type](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_host_type). - Transport get hostType => getProperty(this, 'host_type'); + Transport get hostType => Transport.parse(getProperty(this, 'host_type')); /// [deno-postgres@v0.17.0/ClientOptions/options](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_options). /// From ac91006966fa2b37be0bb824337598e0ae3caa9e Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 19:31:52 +0300 Subject: [PATCH 109/139] constructor --- lib/src/client_options.dart | 57 +++++++++++++++++++++++- lib/src/partial/partial_tls_options.dart | 4 +- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart index 2c262d6..744c92f 100644 --- a/lib/src/client_options.dart +++ b/lib/src/client_options.dart @@ -1,3 +1,4 @@ +import 'dart:js_interop'; import 'dart:js_util'; import 'package:deno_postgres_interop/src/partial/partial_connection_options.dart'; @@ -5,6 +6,7 @@ import 'package:deno_postgres_interop/src/partial/partial_tls_options.dart'; import 'package:deno_postgres_interop/src/transport.dart'; /// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). +@JS() class ClientOptions { /// [deno-postgres@v0.17.0/ClientOptions/applicationName](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_applicationName). external String? get applicationName; @@ -20,6 +22,59 @@ class ClientOptions { /// [deno-postgres@v0.17.0/ClientOptions/user](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_applicationName/user). external String? get user; + + /// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). + factory ClientOptions({ + String? applicationName, + PartialConnectionOptions? connection, + String? database, + String? hostname, + Transport? hostType, + String? optionsString, + Map? optionsMap, + String? password, + String? portString, + int? port, + PartialTLSOptions? tls, + String? user, + }) { + assert(optionsString == null || optionsMap == null); + assert(portString == null || port == null); + + return jsify( + { + if (applicationName != null) 'applicationName': applicationName, + if (connection != null) + 'connection': jsify({ + if (connection.attempts != null) 'attempts': connection.attempts, + if (connection.nextInterval != null) + 'interval': connection.nextInterval + else if (connection.interval != null) + 'interval': connection.interval, + }), + if (database != null) 'database': database, + if (hostname != null) 'hostname': hostname, + if (hostType != null) 'host_type': hostType.name, + if (optionsString != null) + 'options': optionsString + else if (optionsMap != null) + 'options': jsify(optionsMap), + if (password != null) 'password': password, + if (portString != null) + 'port': portString + else if (port != null) + 'port': port, + if (tls != null) + 'tls': jsify({ + if (tls.isEnabled != null) 'enabled': tls.isEnabled, + if (tls.isEnforced != null) 'enforce': tls.isEnforced, + if (tls.caCertificates != null) + 'caCertificates': tls.caCertificates, + }), + if (user != null) 'user': user, + }, + ) as ClientOptions; + } } /// [deno-postgres@v0.17.0/ClientOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions). @@ -91,7 +146,7 @@ extension ClientOptionsProps on ClientOptions { return PartialTLSOptions( caCertificates: map['caCertificates'] as List?, isEnabled: map['enabled'] as bool?, - isTLSEnforced: map['enforced'] as bool?, + isEnforced: map['enforced'] as bool?, ); } } diff --git a/lib/src/partial/partial_tls_options.dart b/lib/src/partial/partial_tls_options.dart index 634df97..c5bc0fc 100644 --- a/lib/src/partial/partial_tls_options.dart +++ b/lib/src/partial/partial_tls_options.dart @@ -4,7 +4,7 @@ class PartialTLSOptions { final bool? isEnabled; /// [deno-postgres@v0.17.0/TLSOptions/enfroce](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=TLSOptions#prop_enfroce). - final bool? isTLSEnforced; + final bool? isEnforced; /// [deno-postgres@v0.17.0/TLSOptions/caCertificates](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=TLSOptions#prop_caCertificates). final List? caCertificates; @@ -12,7 +12,7 @@ class PartialTLSOptions { /// constructor. PartialTLSOptions({ required this.isEnabled, - required this.isTLSEnforced, + required this.isEnforced, required this.caCertificates, }); } From f5c57688eddc96f37804eb238bdcdd0e87929e0e Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 19:34:43 +0300 Subject: [PATCH 110/139] upd --- lib/src/client_options.dart | 17 ++--------------- lib/src/partial/partial_connection_options.dart | 11 +++++++++++ lib/src/partial/partial_tls_options.dart | 9 +++++++++ 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart index 744c92f..842e7c7 100644 --- a/lib/src/client_options.dart +++ b/lib/src/client_options.dart @@ -44,14 +44,7 @@ class ClientOptions { return jsify( { if (applicationName != null) 'applicationName': applicationName, - if (connection != null) - 'connection': jsify({ - if (connection.attempts != null) 'attempts': connection.attempts, - if (connection.nextInterval != null) - 'interval': connection.nextInterval - else if (connection.interval != null) - 'interval': connection.interval, - }), + if (connection != null) 'connection': jsify(connection.asMap()), if (database != null) 'database': database, if (hostname != null) 'hostname': hostname, if (hostType != null) 'host_type': hostType.name, @@ -64,13 +57,7 @@ class ClientOptions { 'port': portString else if (port != null) 'port': port, - if (tls != null) - 'tls': jsify({ - if (tls.isEnabled != null) 'enabled': tls.isEnabled, - if (tls.isEnforced != null) 'enforce': tls.isEnforced, - if (tls.caCertificates != null) - 'caCertificates': tls.caCertificates, - }), + if (tls != null) 'tls': jsify(tls.asMap()), if (user != null) 'user': user, }, ) as ClientOptions; diff --git a/lib/src/partial/partial_connection_options.dart b/lib/src/partial/partial_connection_options.dart index 3a939b4..6d0e7ec 100644 --- a/lib/src/partial/partial_connection_options.dart +++ b/lib/src/partial/partial_connection_options.dart @@ -19,4 +19,15 @@ class PartialConnectionOptions { required this.nextInterval, required this.interval, }) : assert(interval == null || nextInterval == null); + + /// used for jsify. + Map asMap() { + return { + if (attempts != null) 'attempts': attempts, + if (nextInterval != null) + 'interval': nextInterval + else if (interval != null) + 'interval': interval, + }; + } } diff --git a/lib/src/partial/partial_tls_options.dart b/lib/src/partial/partial_tls_options.dart index c5bc0fc..fb68773 100644 --- a/lib/src/partial/partial_tls_options.dart +++ b/lib/src/partial/partial_tls_options.dart @@ -15,4 +15,13 @@ class PartialTLSOptions { required this.isEnforced, required this.caCertificates, }); + + /// used for jsify. + Map asMap() { + return { + if (isEnabled != null) 'enabled': isEnabled, + if (isEnforced != null) 'enforce': isEnforced, + if (caCertificates != null) 'caCertificates': caCertificates, + }; + } } From 24cb622a356723a05c6da067c446d9e633a0f1e0 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 19:42:19 +0300 Subject: [PATCH 111/139] upd --- lib/src/client_options.dart | 12 +----------- lib/src/partial/partial_connection_options.dart | 13 +++++++++++++ lib/src/partial/partial_tls_options.dart | 6 ++++++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/src/client_options.dart b/lib/src/client_options.dart index 842e7c7..0bb2ca1 100644 --- a/lib/src/client_options.dart +++ b/lib/src/client_options.dart @@ -110,17 +110,7 @@ extension ClientOptionsProps on ClientOptions { final map = dartify(getProperty(this, 'connection')) as Map?; - if (map == null) return null; - - final intervalProp = map['interval']; - - return PartialConnectionOptions( - attempts: map['attempts'] as int?, - interval: intervalProp is int ? intervalProp : null, - nextInterval: intervalProp is! int - ? intervalProp as int Function(int previousInterval)? - : null, - ); + return map == null ? null : PartialConnectionOptions.fromMap(map); } /// [deno-postgres@v0.17.0/ClientOptions/tls](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ClientOptions#prop_tls). diff --git a/lib/src/partial/partial_connection_options.dart b/lib/src/partial/partial_connection_options.dart index 6d0e7ec..4920511 100644 --- a/lib/src/partial/partial_connection_options.dart +++ b/lib/src/partial/partial_connection_options.dart @@ -20,6 +20,19 @@ class PartialConnectionOptions { required this.interval, }) : assert(interval == null || nextInterval == null); + /// used for interop. + factory PartialConnectionOptions.fromMap(Map map) { + final intervalProp = map['interval']; + + return PartialConnectionOptions( + attempts: map['attempts'] as int?, + interval: intervalProp is int ? intervalProp : null, + nextInterval: intervalProp is! int + ? intervalProp as int Function(int previousInterval)? + : null, + ); + } + /// used for jsify. Map asMap() { return { diff --git a/lib/src/partial/partial_tls_options.dart b/lib/src/partial/partial_tls_options.dart index fb68773..64f4fd9 100644 --- a/lib/src/partial/partial_tls_options.dart +++ b/lib/src/partial/partial_tls_options.dart @@ -16,6 +16,12 @@ class PartialTLSOptions { required this.caCertificates, }); + /// used for interop. + PartialTLSOptions.fromMap(Map map) + : caCertificates = map['caCertificates'] as List?, + isEnabled = map['enabled'] as bool?, + isEnforced = map['enforced'] as bool?; + /// used for jsify. Map asMap() { return { From 68545d5993d125550602a807a1c4241e83b08f9a Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 19:47:05 +0300 Subject: [PATCH 112/139] export --- lib/deno_postgres_interop.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/deno_postgres_interop.dart b/lib/deno_postgres_interop.dart index 9bcb816..1604841 100644 --- a/lib/deno_postgres_interop.dart +++ b/lib/deno_postgres_interop.dart @@ -2,12 +2,21 @@ library; export 'src/client.dart'; +export 'src/client_configuration.dart'; +export 'src/client_options.dart'; export 'src/command_type.dart'; +export 'src/connection_options.dart'; export 'src/isolation_level.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_client.dart'; export 'src/query_object.dart' show QueryArguments; export 'src/query_object_result.dart'; export 'src/query_result.dart'; +export 'src/tls_options.dart'; export 'src/transaction.dart'; export 'src/transaction_options.dart'; +export 'src/transport.dart'; From 1eafda388f975ec5ea549f1ca70871ec0493b1a7 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 19:54:35 +0300 Subject: [PATCH 113/139] tls options --- lib/src/tls_options.dart | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/src/tls_options.dart b/lib/src/tls_options.dart index a457bb3..f38be24 100644 --- a/lib/src/tls_options.dart +++ b/lib/src/tls_options.dart @@ -1,3 +1,30 @@ -// TODO: +import 'dart:js_interop'; +import 'dart:js_util'; + /// [deno-postgres@v0.17.0/TLSOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TLSOptions). -class TLSOptions {} +@JS() +class TLSOptions { + /// [deno-postgres@v0.17.0/TLSOptions/caCertificates](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TLSOptions#prop_caCertificates). + external List get caCertificates; + + /// [deno-postgres@v0.17.0/TLSOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TLSOptions). + factory TLSOptions({ + required List caCertificates, + required bool isEnabled, + required bool isEnforced, + }) => + jsify({ + 'caCertificates': caCertificates, + 'enabled': isEnabled, + 'enforce': isEnforced, + }) as TLSOptions; +} + +/// [deno-postgres@v0.17.0/TLSOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TLSOptions). +class TLSOptionsProps { + /// [deno-postgres@v0.17.0/TLSOptions/enabled](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TLSOptions#prop_enabled). + bool get isEnabled => getProperty(this, 'isEnabled'); + + /// [deno-postgres@v0.17.0/TLSOptions/enforce](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TLSOptions#prop_enforce). + bool get isEnforced => getProperty(this, 'enforce'); +} From 8cfa653d9dfd3cae0fc5febb8827374c14bb1e10 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 20:02:59 +0300 Subject: [PATCH 114/139] finish? --- lib/src/connection_options.dart | 48 +++++++++++++++++-- .../partial/partial_connection_options.dart | 6 +-- lib/src/partial/partial_tls_options.dart | 6 +-- lib/src/tls_options.dart | 2 +- 4 files changed, 52 insertions(+), 10 deletions(-) diff --git a/lib/src/connection_options.dart b/lib/src/connection_options.dart index 7102a49..aec2693 100644 --- a/lib/src/connection_options.dart +++ b/lib/src/connection_options.dart @@ -1,3 +1,45 @@ -// TODO: -/// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=ConnectionOptions). -class ConnectionOptions {} +import 'dart:js_interop'; +import 'dart:js_util'; + +/// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions). +@JS() +class ConnectionOptions { + /// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions#prop_attempts). + external int get attempts; + + /// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions). + factory ConnectionOptions({ + required int attempts, + int Function(int previousInterval)? nextInterval, + int? interval, + }) { + assert(nextInterval == null || interval == null); + + return jsify({ + if (interval != null) 'interval': interval, + if (nextInterval != null) 'interval': nextInterval, + 'attempts': attempts, + }) as ConnectionOptions; + } +} + +/// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions). +extension ConnectionOptionsProps on ConnectionOptions { + /// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions#prop_interval). + /// + /// Either this or [interval] is null. + int Function(int previousInterval)? get nextInterval { + final prop = getProperty(this, 'interval'); + + return prop is int ? null : prop as int Function(int previousInterval); + } + + /// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions#prop_interval). + /// + /// Either this or [nextInterval] is null. + int? get interval { + final prop = getProperty(this, 'interval'); + + return prop is int ? prop : null; + } +} diff --git a/lib/src/partial/partial_connection_options.dart b/lib/src/partial/partial_connection_options.dart index 4920511..9c52164 100644 --- a/lib/src/partial/partial_connection_options.dart +++ b/lib/src/partial/partial_connection_options.dart @@ -15,9 +15,9 @@ class PartialConnectionOptions { /// constructor. PartialConnectionOptions({ - required this.attempts, - required this.nextInterval, - required this.interval, + this.attempts, + this.nextInterval, + this.interval, }) : assert(interval == null || nextInterval == null); /// used for interop. diff --git a/lib/src/partial/partial_tls_options.dart b/lib/src/partial/partial_tls_options.dart index 64f4fd9..4b2c300 100644 --- a/lib/src/partial/partial_tls_options.dart +++ b/lib/src/partial/partial_tls_options.dart @@ -11,9 +11,9 @@ class PartialTLSOptions { /// constructor. PartialTLSOptions({ - required this.isEnabled, - required this.isEnforced, - required this.caCertificates, + this.isEnabled, + this.isEnforced, + this.caCertificates, }); /// used for interop. diff --git a/lib/src/tls_options.dart b/lib/src/tls_options.dart index f38be24..077a707 100644 --- a/lib/src/tls_options.dart +++ b/lib/src/tls_options.dart @@ -21,7 +21,7 @@ class TLSOptions { } /// [deno-postgres@v0.17.0/TLSOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TLSOptions). -class TLSOptionsProps { +extension TLSOptionsProps on TLSOptions { /// [deno-postgres@v0.17.0/TLSOptions/enabled](https://deno.land/x/postgres@v0.17.0/mod.ts?s=TLSOptions#prop_enabled). bool get isEnabled => getProperty(this, 'isEnabled'); From e671dcc266c45dbf93116282bd70c8afe7baf1b4 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 20:04:19 +0300 Subject: [PATCH 115/139] upd --- lib/src/connection_options.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/connection_options.dart b/lib/src/connection_options.dart index aec2693..ed8e5cf 100644 --- a/lib/src/connection_options.dart +++ b/lib/src/connection_options.dart @@ -16,8 +16,10 @@ class ConnectionOptions { assert(nextInterval == null || interval == null); return jsify({ - if (interval != null) 'interval': interval, - if (nextInterval != null) 'interval': nextInterval, + if (interval != null) + 'interval': interval + else if (nextInterval != null) + 'interval': nextInterval, 'attempts': attempts, }) as ConnectionOptions; } From f1b6395983773a7988635e6c3b82755ff8fabdc2 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 20:16:27 +0300 Subject: [PATCH 116/139] last --- lib/src/connection_options.dart | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/src/connection_options.dart b/lib/src/connection_options.dart index ed8e5cf..9ccc7aa 100644 --- a/lib/src/connection_options.dart +++ b/lib/src/connection_options.dart @@ -1,6 +1,8 @@ import 'dart:js_interop'; import 'dart:js_util'; +import 'package:deno_postgres_interop/src/partial/partial_connection_options.dart'; + /// [deno-postgres@v0.17.0/ConnectionOptions](https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts?s=ConnectionOptions). @JS() class ConnectionOptions { @@ -13,15 +15,13 @@ class ConnectionOptions { int Function(int previousInterval)? nextInterval, int? interval, }) { - assert(nextInterval == null || interval == null); - - return jsify({ - if (interval != null) - 'interval': interval - else if (nextInterval != null) - 'interval': nextInterval, - 'attempts': attempts, - }) as ConnectionOptions; + return jsify( + PartialConnectionOptions( + attempts: attempts, + nextInterval: nextInterval, + interval: interval, + ).asMap(), + ) as ConnectionOptions; } } From ac208bc845965e878b4f7178a418597b0d071809 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 20:57:58 +0300 Subject: [PATCH 117/139] upd --- lib/src/encoded_arg.dart | 1 + lib/src/query_object_options.dart | 4 +++- lib/src/query_options.dart | 35 +++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 lib/src/encoded_arg.dart create mode 100644 lib/src/query_options.dart diff --git a/lib/src/encoded_arg.dart b/lib/src/encoded_arg.dart new file mode 100644 index 0000000..1f4f0ba --- /dev/null +++ b/lib/src/encoded_arg.dart @@ -0,0 +1 @@ +class EncodedArg {} diff --git a/lib/src/query_object_options.dart b/lib/src/query_object_options.dart index 09a269e..50514f8 100644 --- a/lib/src/query_object_options.dart +++ b/lib/src/query_object_options.dart @@ -1,9 +1,11 @@ import 'dart:js_interop'; import 'dart:js_util'; +import 'package:deno_postgres_interop/src/query_options.dart'; + /// [deno-postgres@v0.17.0/QueryObjectOptions](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectOptions). @JS() -class QueryObjectOptions { +class QueryObjectOptions extends QueryOptions { /// [deno-postgres@v0.17.0/QueryObjectOptions/fields](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryObjectOptions#prop_fields). external List? get fields; diff --git a/lib/src/query_options.dart b/lib/src/query_options.dart new file mode 100644 index 0000000..e499395 --- /dev/null +++ b/lib/src/query_options.dart @@ -0,0 +1,35 @@ +import 'dart:js_interop'; +import 'dart:js_util'; + +import 'package:deno_postgres_interop/deno_postgres_interop.dart'; +import 'package:deno_postgres_interop/src/encoded_arg.dart'; + +/// [deno-postgres@v0.17.0/QueryOptions](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryOptions). +@JS() +class QueryOptions { + /// [deno-postgres@v0.17.0/QueryOptions/args](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryOptions#prop_args). + external QueryArguments? get args; + + /// [deno-postgres@v0.17.0/QueryOptions/encoder](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryOptions#prop_encoder). + external EncodedArg Function(dynamic arg)? get encoder; + + /// [deno-postgres@v0.17.0/QueryOptions/name](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryOptions#prop_name). + external String? get name; + + /// [deno-postgres@v0.17.0/QueryOptions/text](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryOptions#prop_text. + external String get text; + + /// [deno-postgres@v0.17.0/QueryOptions](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryOptions). + factory QueryOptions({ + required String text, + QueryArguments? args, + EncodedArg Function(dynamic arg)? encoder, + String? name, + }) => + jsify({ + if (args != null) 'args': args, + if (encoder != null) 'encoder': encoder, + if (name != null) 'name': name, + 'text': text, + }) as QueryOptions; +} From 26f47f367b3d68ad1814b72398116b478354c483 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 21:17:48 +0300 Subject: [PATCH 118/139] upd --- lib/src/encoded_arg.dart | 1 - lib/src/query_options.dart | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 lib/src/encoded_arg.dart diff --git a/lib/src/encoded_arg.dart b/lib/src/encoded_arg.dart deleted file mode 100644 index 1f4f0ba..0000000 --- a/lib/src/encoded_arg.dart +++ /dev/null @@ -1 +0,0 @@ -class EncodedArg {} diff --git a/lib/src/query_options.dart b/lib/src/query_options.dart index e499395..1dcd1c3 100644 --- a/lib/src/query_options.dart +++ b/lib/src/query_options.dart @@ -2,7 +2,9 @@ import 'dart:js_interop'; import 'dart:js_util'; import 'package:deno_postgres_interop/deno_postgres_interop.dart'; -import 'package:deno_postgres_interop/src/encoded_arg.dart'; + +/// [deno-postgres@v0.17.0/EncodedArg](https://deno.land/x/postgres@v0.17.0/query/encode.ts?s=EncodedArg). +typedef EncodedArg = dynamic; /// [deno-postgres@v0.17.0/QueryOptions](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryOptions). @JS() From 986eed2c3d128c9c624150d740d1beaf593ba4a1 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 21:21:26 +0300 Subject: [PATCH 119/139] upd --- lib/src/encoded_arg.dart | 2 ++ lib/src/query.dart | 4 ++-- lib/src/query_options.dart | 4 +--- 3 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 lib/src/encoded_arg.dart diff --git a/lib/src/encoded_arg.dart b/lib/src/encoded_arg.dart new file mode 100644 index 0000000..cefa164 --- /dev/null +++ b/lib/src/encoded_arg.dart @@ -0,0 +1,2 @@ +/// [deno-postgres@v0.17.0/EncodedArg](https://deno.land/x/postgres@v0.17.0/query/encode.ts?s=EncodedArg). +typedef EncodedArg = dynamic; diff --git a/lib/src/query.dart b/lib/src/query.dart index fbe5324..4166f29 100644 --- a/lib/src/query.dart +++ b/lib/src/query.dart @@ -1,6 +1,7 @@ import 'dart:js_interop'; import 'dart:js_util'; +import 'package:deno_postgres_interop/src/encoded_arg.dart'; import 'package:deno_postgres_interop/src/query_object.dart'; import 'package:deno_postgres_interop/src/query_object_options.dart'; import 'package:deno_postgres_interop/src/result_type.dart'; @@ -9,8 +10,7 @@ import 'package:deno_postgres_interop/src/result_type.dart'; @JS() class Query { /// [deno-postgres@v0.17.0/Query/args](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#prop_args). - /// null | string | Uint8Array - external List args; + external List args; /// [deno-postgres@v0.17.0/Query/args](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=Query#prop_fields). external List? get fields; diff --git a/lib/src/query_options.dart b/lib/src/query_options.dart index 1dcd1c3..e499395 100644 --- a/lib/src/query_options.dart +++ b/lib/src/query_options.dart @@ -2,9 +2,7 @@ import 'dart:js_interop'; import 'dart:js_util'; import 'package:deno_postgres_interop/deno_postgres_interop.dart'; - -/// [deno-postgres@v0.17.0/EncodedArg](https://deno.land/x/postgres@v0.17.0/query/encode.ts?s=EncodedArg). -typedef EncodedArg = dynamic; +import 'package:deno_postgres_interop/src/encoded_arg.dart'; /// [deno-postgres@v0.17.0/QueryOptions](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryOptions). @JS() From 1769b8896263f285f79536a8e5a37351fb6ac906 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 22:14:40 +0300 Subject: [PATCH 120/139] revert --- lib/src/query_object_options.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/query_object_options.dart b/lib/src/query_object_options.dart index 0162db9..44d211c 100644 --- a/lib/src/query_object_options.dart +++ b/lib/src/query_object_options.dart @@ -22,5 +22,5 @@ class QueryObjectOptions extends QueryOptions { /// [deno-postgres@v0.17.0/QueryObjectOptions](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryObjectOptions). extension QueryObjectOptionsProps on QueryObjectOptions { /// [deno-postgres@v0.17.0/QueryObjectOptions/camelcase](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#prop_camelcase). - bool? get isCamelcase => getProperty(this, 'camelcase'); + bool? get isCamelCase => getProperty(this, 'camelcase'); } From d092ed9d56ace529d0a6706d7d669b3472d9f12a Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 22:16:28 +0300 Subject: [PATCH 121/139] revert --- lib/src/query_result.dart | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart index ed4f5b0..bad643d 100644 --- a/lib/src/query_result.dart +++ b/lib/src/query_result.dart @@ -9,21 +9,18 @@ import 'package:deno_postgres_interop/src/row_description.dart'; /// [deno-postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). @JS() class QueryResult { - /// [deno-postgres@v0.17.0/QueryResult/command](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_command). - external CommandType get command; - /// [deno-postgres@v0.17.0/QueryResult/rowCount](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_rowCount). external int? get rowCount; - /// [deno-postgres@v0.17.0/QueryResult/rowDescription](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#accessor_rowDescription). - external RowDescription? get rowDescription; - /// [deno-postgres@v0.17.0/QueryResult/warnings](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_warnings). external List get warnings; /// [deno-postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). external Query get query; + /// [deno-postgres@v0.17.0/QueryResult/rowDescription](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#accessor_rowDescription). + external RowDescription? get rowDescription; + /// [deno-postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). external factory QueryResult(Query query); From 5f4ad6c6fc71f4fe81a55ad3789cc6c15ad1e807 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 22:37:28 +0300 Subject: [PATCH 122/139] upd --- lib/src/client_common.dart | 60 +++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/lib/src/client_common.dart b/lib/src/client_common.dart index 153b295..f1d5d88 100644 --- a/lib/src/client_common.dart +++ b/lib/src/client_common.dart @@ -13,9 +13,9 @@ class ClientCommon { static Future> queryArray>( Object queryable, String query, [ - QueryArguments? args, + QueryArguments? arguments, ]) => - throw UnimplementedError(); // TODO: + _query('queryArray', queryable, query, arguments); /// [deno-postgres@v0.17.0/Transaction/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryArray_1). /// [deno-postgres@v0.17.0/QueryClient/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryArray_1). @@ -44,28 +44,8 @@ class ClientCommon { Object queryable, String query, [ QueryArguments? arguments, - ]) { - final isCorrectType = arguments is List || - arguments is Map || - arguments == null; - - if (!isCorrectType) { - throw ArgumentError.value( - arguments, - 'arguments', - 'Accepted types are List and Map.', - ); - } - - return callFutureMethod( - queryable, - 'queryObject', - [ - query, - if (arguments != null) arguments, - ], - ); - } + ]) => + _query('queryObject', queryable, query, arguments); /// [deno-postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_1). /// [deno-postgres@v0.17.0/QueryClient/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=QueryClient#method_queryObject_1). @@ -87,4 +67,36 @@ class ClientCommon { // List args, // ) => // throw UnimplementedError(); + + static Future _query( + String function, + Object queryable, + String query, [ + QueryArguments? arguments, + ]) { + _assertQueryArgumentsOrNull(arguments); + + return callFutureMethod( + queryable, + function, + [ + query, + if (arguments != null) arguments, + ], + ); + } +} + +void _assertQueryArgumentsOrNull(QueryArguments? arguments) { + final isCorrectType = arguments is List || + arguments is Map || + arguments == null; + + if (!isCorrectType) { + throw ArgumentError.value( + arguments, + 'arguments', + 'Accepted types are List and Map.', + ); + } } From dbc929f5ecdf6f7f3ee0d5556a90329742243431 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 22:48:24 +0300 Subject: [PATCH 123/139] upd --- lib/src/client_common.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/client_common.dart b/lib/src/client_common.dart index f1d5d88..d980085 100644 --- a/lib/src/client_common.dart +++ b/lib/src/client_common.dart @@ -24,7 +24,7 @@ class ClientCommon { Object queryable, QueryObjectOptions config, ) => - throw UnimplementedError(); // TODO: + callFutureMethod(queryable, 'queryArray', [config]); // This one won't be implemented because it doesn't make much sense for dart, // the query here is of type TemplateStringsArray which is used in @@ -53,7 +53,7 @@ class ClientCommon { Object queryable, QueryObjectOptions config, ) => - throw UnimplementedError(); // TODO: + callFutureMethod(queryable, 'queryObject', [config]); // This one won't be implemented because it doesn't make much sense for dart, // the query here is of type TemplateStringsArray which is used in From 1bbb7e63295000b1da0e5391575eee919217f9ae Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 23:08:31 +0300 Subject: [PATCH 124/139] fix --- lib/src/client.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index ee914e6..dd66f08 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -1,7 +1,6 @@ import 'dart:js_interop'; import 'dart:js_util'; -import 'package:deno_postgres_interop/deno_postgres_interop.dart'; import 'package:deno_postgres_interop/src/client_options.dart'; import 'package:deno_postgres_interop/src/query_client.dart'; From 6a427609164216993bfa608649c8cb117614525a Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 23:09:28 +0300 Subject: [PATCH 125/139] restore --- lib/src/transaction.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/transaction.dart b/lib/src/transaction.dart index c446460..cbbef8b 100644 --- a/lib/src/transaction.dart +++ b/lib/src/transaction.dart @@ -66,9 +66,9 @@ extension TransactionProps on Transaction { /// [deno-postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_0). Future> queryObject( String query, [ - QueryArguments? args, + QueryArguments? arguments, ]) => - ClientCommon.queryObject(this, query, args); + ClientCommon.queryObject(this, query, arguments); /// [deno-postgres@v0.17.0/Transaction/queryObject](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryObject_1). Future> queryObjectWithOptions( From 6807f24572a6416fa461834e6098be62c7139b4a Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 23:12:48 +0300 Subject: [PATCH 126/139] add comments --- lib/src/transaction.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/src/transaction.dart b/lib/src/transaction.dart index cbbef8b..3328b26 100644 --- a/lib/src/transaction.dart +++ b/lib/src/transaction.dart @@ -45,6 +45,7 @@ extension TransactionProps on Transaction { ) => ClientCommon.queryArrayWithOptions(this, config); + /// [deno-postgres@v0.17.0/Transaction/rollback](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_rollback_0). Future rollback(Savepoint? savepoint) => callFutureMethod( this, 'rollback', @@ -53,13 +54,15 @@ extension TransactionProps on Transaction { // TODO: // rollback(options?: { savepoint?: string | Savepoint; }): Promise - // https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_rollback_1 + + /// [deno-postgres@v0.17.0/Transaction/rollback](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_rollback_0). Future rollbackByName(String savepoint) => callFutureMethod(this, 'rollback', [savepoint]); // TODO: // rollback(options?: { chain?: boolean; }): Promise - // https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_rollback_2 + + /// [deno-postgres@v0.17.0/Transaction/savepoint](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_savepoint_0). Future createSavepoint(String name) => callFutureMethod(this, 'savepoint', [name]); From d1f834a00dfbfe09c669d24b72ddfa42993dfb64 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 23:19:14 +0300 Subject: [PATCH 127/139] comments --- lib/src/transaction.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/transaction.dart b/lib/src/transaction.dart index 3328b26..2bfe0df 100644 --- a/lib/src/transaction.dart +++ b/lib/src/transaction.dart @@ -12,7 +12,10 @@ import 'package:deno_postgres_interop/src/util.dart'; /// [deno-postgres@v0.17.0/Transaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction). @JS() class Transaction { + /// [deno-postgres@v0.17.0/Transaction/savepoints](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#accessor_savepoints). external List get savepoints; + + /// [deno-postgres@v0.17.0/Transaction/getSavepoint](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_getSavepoint_0). external Savepoint? getSavepoint(String name); } @@ -27,9 +30,11 @@ extension TransactionProps on Transaction { /// [deno-postgres@v0.17.0/Transaction/commit](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_commit_0). Future commit() => callFutureMethod(this, 'commit'); + /// [deno-postgres@v0.17.0/Transaction/getSavepoints](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_getSavepoints_0). List getActiveSavepointsNames() => callMethod(this, 'getSavepoints', []); + /// [deno-postgres@v0.17.0/Transaction/getSnapshot](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_getSnapshot_0). Future get snapshot => callFutureMethod(this, 'getSnapshot'); /// [deno-postgres@v0.17.0/Transaction/queryArray](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_queryArray_0). From 2a995de4fe652a16704015f85aa5e54ab7b454e6 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 23:29:02 +0300 Subject: [PATCH 128/139] update unimplemented --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index 21c95d2..eb8948f 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,6 @@ The main scenario is Supabase Edge Functions, but it should also work for other ## Unimplemented - [ ] ConnectionError -- [ ] Pool -- [ ] PoolClient - [ ] PostgresError - [ ] QueryClient - [ ] Transaction @@ -55,9 +53,6 @@ The main scenario is Supabase Edge Functions, but it should also work for other - [ ] `(options: { savepoint?: string | Savepoint; })` - [ ] `(options: { chain?: boolean; })` - [ ] TransactionError -- [ ] ClientOptions - - [ ] options - - [ ] port - [ ] ConnectionOptions - [ ] QueryOobjectOptions - [ ] QueryOptions From 740a82b0cd499c8db21cb90426c2fdfd306084e2 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 23:31:48 +0300 Subject: [PATCH 129/139] upd --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index eb8948f..5c36afb 100644 --- a/README.md +++ b/README.md @@ -53,10 +53,6 @@ The main scenario is Supabase Edge Functions, but it should also work for other - [ ] `(options: { savepoint?: string | Savepoint; })` - [ ] `(options: { chain?: boolean; })` - [ ] TransactionError -- [ ] ConnectionOptions -- [ ] QueryOobjectOptions -- [ ] QueryOptions -- [ ] TLSOptions Common for clients: - [ ] queryArray From 4579d59416f93b1914f6b91e296cad6f2a6c3d45 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 23:32:23 +0300 Subject: [PATCH 130/139] upd --- README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.md b/README.md index 5c36afb..f8abcb5 100644 --- a/README.md +++ b/README.md @@ -53,12 +53,3 @@ The main scenario is Supabase Edge Functions, but it should also work for other - [ ] `(options: { savepoint?: string | Savepoint; })` - [ ] `(options: { chain?: boolean; })` - [ ] TransactionError - -Common for clients: - - [ ] queryArray - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - - [ ] `(config: QueryOptions)` - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` - - [ ] queryObject - - [ ] `(config: QueryObjectOptions)` - - [ ] `(strings: TemplateStringsArray, ...args: unknown[])` From 0047c9b21b7612a6d57f58ca9f4d400d636a0027 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Wed, 20 Sep 2023 23:34:07 +0300 Subject: [PATCH 131/139] upd --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f8abcb5..3ff5d2b 100644 --- a/README.md +++ b/README.md @@ -44,12 +44,16 @@ The main scenario is Supabase Edge Functions, but it should also work for other 5. You can use the function now. ## Unimplemented -- [ ] ConnectionError -- [ ] PostgresError - [ ] QueryClient -- [ ] Transaction + + +- Transaction - [ ] constructor - [ ] rollback - [ ] `(options: { savepoint?: string | Savepoint; })` - [ ] `(options: { chain?: boolean; })` -- [ ] TransactionError + +- errors: + - [ ] TransactionError + - [ ] ConnectionError + - [ ] PostgresError From d947da8988be36d5274a4b9057b1374313c15e4f Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 21 Sep 2023 17:04:43 +0300 Subject: [PATCH 132/139] upd --- README.md | 3 --- lib/src/transaction.dart | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3ff5d2b..3aca62b 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,6 @@ The main scenario is Supabase Edge Functions, but it should also work for other - Transaction - [ ] constructor - - [ ] rollback - - [ ] `(options: { savepoint?: string | Savepoint; })` - - [ ] `(options: { chain?: boolean; })` - errors: - [ ] TransactionError diff --git a/lib/src/transaction.dart b/lib/src/transaction.dart index 2bfe0df..93512cf 100644 --- a/lib/src/transaction.dart +++ b/lib/src/transaction.dart @@ -51,22 +51,29 @@ extension TransactionProps on Transaction { ClientCommon.queryArrayWithOptions(this, config); /// [deno-postgres@v0.17.0/Transaction/rollback](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_rollback_0). - Future rollback(Savepoint? savepoint) => callFutureMethod( + Future rollback([Savepoint? savepoint]) => callFutureMethod( this, 'rollback', [if (savepoint != null) savepoint], ); - // TODO: - // rollback(options?: { savepoint?: string | Savepoint; }): Promise + // [deno-postgres@v0.17.0/Transaction/rollback](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_rollback_1). + // this has the same functionality as [rollback] and [rollbackByName] + // so it won't be implemented. + + /// [deno-postgres@v0.17.0/Transaction/rollback](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_rollback_2). + Future rollbackWithChain() => callFutureMethod( + this, + 'rollback', + [ + jsify({'chain': true}), + ], + ); /// [deno-postgres@v0.17.0/Transaction/rollback](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_rollback_0). Future rollbackByName(String savepoint) => callFutureMethod(this, 'rollback', [savepoint]); - // TODO: - // rollback(options?: { chain?: boolean; }): Promise - /// [deno-postgres@v0.17.0/Transaction/savepoint](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_savepoint_0). Future createSavepoint(String name) => callFutureMethod(this, 'savepoint', [name]); From 89fdb19f14ef386a61764f3a24b0e0964976b13e Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 21 Sep 2023 18:26:23 +0300 Subject: [PATCH 133/139] transaction --- README.md | 4 ---- lib/src/transaction.dart | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3aca62b..3f08f3c 100644 --- a/README.md +++ b/README.md @@ -46,10 +46,6 @@ The main scenario is Supabase Edge Functions, but it should also work for other ## Unimplemented - [ ] QueryClient - -- Transaction - - [ ] constructor - - errors: - [ ] TransactionError - [ ] ConnectionError diff --git a/lib/src/transaction.dart b/lib/src/transaction.dart index 93512cf..ead4403 100644 --- a/lib/src/transaction.dart +++ b/lib/src/transaction.dart @@ -3,10 +3,16 @@ import 'dart:js_util'; import 'package:deno_postgres_interop/src/client_common.dart'; import 'package:deno_postgres_interop/src/isolation_level.dart'; +import 'package:deno_postgres_interop/src/promise.dart'; +import 'package:deno_postgres_interop/src/query.dart'; import 'package:deno_postgres_interop/src/query_array_result.dart'; +import 'package:deno_postgres_interop/src/query_client.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/query_result.dart'; import 'package:deno_postgres_interop/src/savepoint.dart'; +import 'package:deno_postgres_interop/src/transaction_options.dart'; +import 'package:deno_postgres_interop/src/undefined.dart'; import 'package:deno_postgres_interop/src/util.dart'; /// [deno-postgres@v0.17.0/Transaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction). @@ -15,6 +21,25 @@ class Transaction { /// [deno-postgres@v0.17.0/Transaction/savepoints](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#accessor_savepoints). external List get savepoints; + /// [deno-postgres@v0.17.0/Transaction/construtor](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#ctor_0). + factory Transaction({ + required String name, + required QueryClient client, + required Future Function(Query query) executeQueryCallback, + required void Function(String? name) updateClientLockCallback, + TransactionOptions? options, + }) => + callConstructor( + 'Transaction', + [ + name, + if (options != null) options else undefined, + client, + (Query query) => futureToPromise(executeQueryCallback(query)), + updateClientLockCallback, + ], + ); + /// [deno-postgres@v0.17.0/Transaction/getSavepoint](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_getSavepoint_0). external Savepoint? getSavepoint(String name); } From 162e09fc62c61b5c0845d8a4ab3222f0347a97ee Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 21 Sep 2023 18:46:29 +0300 Subject: [PATCH 134/139] fin --- README.md | 8 -------- lib/src/connection.dart | 1 + lib/src/query_client.dart | 7 +++++-- 3 files changed, 6 insertions(+), 10 deletions(-) create mode 100644 lib/src/connection.dart diff --git a/README.md b/README.md index 3f08f3c..60320a8 100644 --- a/README.md +++ b/README.md @@ -42,11 +42,3 @@ The main scenario is Supabase Edge Functions, but it should also work for other Note: your filename may differ from the example 5. You can use the function now. - -## Unimplemented -- [ ] QueryClient - -- errors: - - [ ] TransactionError - - [ ] ConnectionError - - [ ] PostgresError diff --git a/lib/src/connection.dart b/lib/src/connection.dart new file mode 100644 index 0000000..b026934 --- /dev/null +++ b/lib/src/connection.dart @@ -0,0 +1 @@ +class Connection {} diff --git a/lib/src/query_client.dart b/lib/src/query_client.dart index 93e28a7..4482bc6 100644 --- a/lib/src/query_client.dart +++ b/lib/src/query_client.dart @@ -2,6 +2,7 @@ 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'; @@ -15,6 +16,9 @@ import 'package:deno_postgres_interop/src/util.dart'; 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). @@ -26,8 +30,7 @@ extension QueryClientProps on QueryClient { Future 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). - Future resetSessionMetadata() => - callFutureMethod(this, 'resetSessionMetadata'); + 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 connect() => callFutureMethod(this, 'connect'); From 4973815d592aef4399d64437f30730ba2af1b8d1 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 21 Sep 2023 19:00:42 +0300 Subject: [PATCH 135/139] upd --- lib/src/connection.dart | 49 ++++++++++++++++++++++++++++++++++++++++- lib/src/pool.dart | 2 ++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/lib/src/connection.dart b/lib/src/connection.dart index b026934..55242f5 100644 --- a/lib/src/connection.dart +++ b/lib/src/connection.dart @@ -1 +1,48 @@ -class Connection {} +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/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 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 end() => callFutureMethod(this, 'end'); + + // https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_query_0 + // query(query: Query): Promise + + // https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_query_1 + // query(query: Query): Promise + + // https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_startup_0 + // startup(is_reconnection: boolean) +} diff --git a/lib/src/pool.dart b/lib/src/pool.dart index 5669484..7309075 100644 --- a/lib/src/pool.dart +++ b/lib/src/pool.dart @@ -1,3 +1,4 @@ +import 'dart:js_interop'; import 'dart:js_util'; import 'package:deno_postgres_interop/src/client_options.dart'; @@ -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({ From 1757b65412856303c9d5924a043038b0dd832a28 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 21 Sep 2023 19:03:44 +0300 Subject: [PATCH 136/139] impl --- lib/src/connection.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/src/connection.dart b/lib/src/connection.dart index 55242f5..4a8cff5 100644 --- a/lib/src/connection.dart +++ b/lib/src/connection.dart @@ -3,6 +3,8 @@ 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'; @@ -37,11 +39,10 @@ extension ConnectionProps on Connection { /// [deno-postgres@v0.17.0/Connection/end](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_end_0). Future end() => callFutureMethod(this, 'end'); - // https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_query_0 - // query(query: Query): Promise - - // https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_query_1 - // query(query: Query): Promise + /// [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 queryArray(Query query) => + callFutureMethod(this, 'query', [query]); // https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_startup_0 // startup(is_reconnection: boolean) From b0810ce65d071648d2e9845816d9ad358e7c3647 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 21 Sep 2023 19:05:09 +0300 Subject: [PATCH 137/139] seemps good --- lib/src/connection.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/connection.dart b/lib/src/connection.dart index 4a8cff5..2fca61e 100644 --- a/lib/src/connection.dart +++ b/lib/src/connection.dart @@ -44,6 +44,7 @@ extension ConnectionProps on Connection { Future queryArray(Query query) => callFutureMethod(this, 'query', [query]); - // https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_startup_0 - // startup(is_reconnection: boolean) + /// [deno-postgres@v0.17.0/Connection/startup](https://deno.land/x/postgres@v0.17.0/connection/connection.ts?s=Connection#method_startup_0). + Future startup({required bool isReconnection}) => + callFutureMethod(this, 'startup', [isReconnection]); } From 49e84a5885b5829aeb62ecb6bf2dce8f27daeb58 Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 21 Sep 2023 19:39:30 +0300 Subject: [PATCH 138/139] upd --- lib/src/transaction.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/src/transaction.dart b/lib/src/transaction.dart index ead4403..abe9455 100644 --- a/lib/src/transaction.dart +++ b/lib/src/transaction.dart @@ -47,13 +47,20 @@ class Transaction { /// [deno-postgres@v0.17.0/Transaction](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction). extension TransactionProps on Transaction { /// [deno-postgres@v0.17.0/Transaction/isolation_level](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#accessor_isolation_level). - IsolationLevel get isolationLevel => getProperty(this, 'isolation_name'); + IsolationLevel get isolationLevel => + IsolationLevel.parse(getProperty(this, 'isolation_name')); /// [deno-postgres@v0.17.0/Transaction/begin](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_begin_0). Future begin() => callFutureMethod(this, 'begin'); /// [deno-postgres@v0.17.0/Transaction/commit](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_commit_0). - Future commit() => callFutureMethod(this, 'commit'); + Future commit({bool? chain}) => callFutureMethod( + this, + 'commit', + [ + if (chain != null) {'chain': chain}, + ], + ); /// [deno-postgres@v0.17.0/Transaction/getSavepoints](https://deno.land/x/postgres@v0.17.0/mod.ts?s=Transaction#method_getSavepoints_0). List getActiveSavepointsNames() => From 82f0d475249218ee1fd3876e2a66b82ee0529b3f Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid Date: Thu, 21 Sep 2023 21:16:34 +0300 Subject: [PATCH 139/139] exports --- lib/deno_postgres_interop.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/deno_postgres_interop.dart b/lib/deno_postgres_interop.dart index da4b0f5..adabff9 100644 --- a/lib/deno_postgres_interop.dart +++ b/lib/deno_postgres_interop.dart @@ -4,17 +4,25 @@ 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';