Skip to content

Commit

Permalink
Merge branch 'master' into feature/rust-codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmossas committed Jun 5, 2024
2 parents 3afee75 + c623b77 commit 74e9ee0
Show file tree
Hide file tree
Showing 59 changed files with 931 additions and 418 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint and Test
name: tests
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
Expand All @@ -19,7 +19,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9.1.3
version: 9.1.4
- name: Install Node.js
uses: actions/setup-node@v3
with:
Expand All @@ -34,7 +34,7 @@ jobs:
- run: pnpm nx affected -t pub -- get # install dart dependencies for affected projects
- run: pnpm run build
- run: pnpm nx affected -t lint
test:
unit-tests:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
permissions:
Expand All @@ -50,7 +50,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9.1.3
version: 9.1.4
- name: Install Node.js
uses: actions/setup-node@v3
with:
Expand All @@ -65,7 +65,7 @@ jobs:
- run: pnpm nx affected -t pub -- get # install dart dependencies for affected projects
- run: pnpm run build
- run: pnpm nx affected -t test
integration-test:
integration-tests:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
permissions:
Expand All @@ -81,19 +81,16 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9.1.3
version: 9.1.4
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: "20.x"
cache: pnpm
- name: Install Node Dependencies
run: pnpm i -r --frozen-lockfile
- name: Set NX Shas
uses: nrwl/nx-set-shas@v3
with:
main-branch-name: master
- name: Install dart dependencies
run: pnpm nx run-many -t pub -- get # install dart dependencies in all dart projects
- run: pnpm run build
- run: pnpm i -r
- run: pnpm run integration-tests
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default defineConfig({

### Typescript App Definition (Recommended)

Arri comes with some useful helpers that reduces the boilerplate of manually creating a JSON definition file. Additionally the validators created with Arri Validate can be used throughout your app.
Arri comes with some useful helpers that reduces the boilerplate of manually creating a JSON definition file. Additionally the validators created with Arri Schema can be used throughout your app.

```ts
// AppDefinition.ts
Expand Down
10 changes: 6 additions & 4 deletions languages/dart/dart-client/lib/request.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert';

import 'package:arri_client/errors.dart';
Expand Down Expand Up @@ -25,7 +26,7 @@ Future<http.Response> arriRequest(
http.Client? httpClient,
HttpMethod method = HttpMethod.get,
Map<String, dynamic>? params,
Map<String, String> Function()? headers,
FutureOr<Map<String, String>> Function()? headers,

/// manually specify specific url query parameters
Map<String, String>? query,
Expand All @@ -40,7 +41,8 @@ Future<http.Response> arriRequest(
"""{"statusCode": 400,"statusMessage":"$defaultErrorMsg"}""",
400,
);
final finalHeaders = {...headers?.call() ?? {}};

final finalHeaders = await headers?.call() ?? {};
if (clientVersion != null && clientVersion.isNotEmpty) {
finalHeaders["client-version"] = clientVersion;
}
Expand Down Expand Up @@ -123,7 +125,7 @@ Future<T> parsedArriRequest<T, E extends Exception>(
http.Client? httpClient,
HttpMethod method = HttpMethod.post,
Map<String, dynamic>? params,
Map<String, String> Function()? headers,
FutureOr<Map<String, String>> Function()? headers,
String? clientVersion,
required T Function(String) parser,
}) async {
Expand All @@ -148,7 +150,7 @@ Future<ArriRequestResult<T>> parsedArriRequestSafe<T>(
http.Client? httpClient,
HttpMethod httpMethod = HttpMethod.get,
Map<String, dynamic>? params,
Map<String, String> Function()? headers,
FutureOr<Map<String, String>> Function()? headers,
required T Function(String) parser,
String? clientVersion,
}) async {
Expand Down
12 changes: 6 additions & 6 deletions languages/dart/dart-client/lib/sse.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ EventSource<T> parsedArriSseRequest<T>(
required HttpMethod method,
required T Function(String data) parser,
Map<String, dynamic>? params,
Map<String, String> Function()? headers,
FutureOr<Map<String, String>> Function()? headers,
Duration? retryDelay,
int? maxRetryCount,
SseHookOnData<T>? onData,
Expand All @@ -37,8 +37,8 @@ EventSource<T> parsedArriSseRequest<T>(
method: method,
parser: parser,
params: params,
headers: () {
final result = headers?.call() ?? {};
headers: () async {
final result = await headers?.call() ?? {};
if (clientVersion != null && clientVersion.isNotEmpty) {
result["client-version"] = clientVersion;
}
Expand All @@ -60,7 +60,7 @@ class EventSource<T> {
final String url;
final HttpMethod method;
final Map<String, dynamic>? _params;
final Map<String, String> Function()? _headers;
final FutureOr<Map<String, String>> Function()? _headers;
String? lastEventId;
StreamController<T>? _streamController;
final Duration _retryDelay;
Expand All @@ -83,7 +83,7 @@ class EventSource<T> {
http.Client? httpClient,
this.method = HttpMethod.get,
Map<String, dynamic>? params,
Map<String, String> Function()? headers,
FutureOr<Map<String, String>> Function()? headers,
Duration retryDelay = Duration.zero,
int? maxRetryCount,
// hooks
Expand Down Expand Up @@ -151,7 +151,7 @@ class EventSource<T> {
if (body.isNotEmpty) {
request.body = body;
}
_headers?.call().forEach((key, value) {
(await _headers?.call())?.forEach((key, value) {
request.headers[key] = value;
});
if (lastEventId != null) {
Expand Down
4 changes: 2 additions & 2 deletions languages/dart/dart-client/lib/ws.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:web_socket_channel/status.dart' as status;
Future<ArriWebsocketController<TServerMessage, TClientMessage>>
arriWebsocketRequest<TServerMessage, TClientMessage>(
String url, {
Map<String, String> Function()? headers,
FutureOr<Map<String, String>> Function()? headers,
required TServerMessage Function(String msg) parser,
required String Function(TClientMessage msg) serializer,
String? clientVersion,
Expand All @@ -18,7 +18,7 @@ Future<ArriWebsocketController<TServerMessage, TClientMessage>>
if (headers != null || clientVersion?.isNotEmpty == true) {
final queryParts = <String>[];
for (final entry
in headers?.call().entries ?? <MapEntry<String, String>>[]) {
in (await headers?.call())?.entries ?? <MapEntry<String, String>>[]) {
queryParts.add("${entry.key}=${entry.value}");
}
if (clientVersion != null) {
Expand Down
7 changes: 7 additions & 0 deletions languages/dart/dart-client/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
"command": "dart pub get",
"cwd": "languages/dart/dart-client"
}
},
"lint": {
"executor": "nx:run-commands",
"options": {
"command": "dart analyze",
"cwd": "languages/dart/dart-client"
}
}
}
}
6 changes: 3 additions & 3 deletions languages/dart/dart-client/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: arri_client
description: Client library needed for the code generated by the arri server library.
version: "0.46.0"
version: "0.49.1"
repository: https://github.com/modiimedia/arri
issue_tracker: https://github.com/modiimedia/arri/issues
environment:
Expand All @@ -9,5 +9,5 @@ dependencies:
http: ">=0.13.0 <2.0.0"
web_socket_channel: ">=2.4.4 <3.0.0"
dev_dependencies:
lints: ^3.0.0
test: ^1.25.1
lints: ^4.0.0
test: ^1.25.6
7 changes: 7 additions & 0 deletions languages/dart/dart-codegen-reference/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
"command": "dart pub",
"cwd": "languages/dart/dart-codegen-reference"
}
},
"lint": {
"executor": "nx:run-commands",
"options": {
"command": "dart analyze",
"cwd": "languages/dart/dart-codegen-reference"
}
}
}
}
6 changes: 3 additions & 3 deletions languages/dart/dart-codegen-reference/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ packages:
path: "../dart-client"
relative: true
source: path
version: "0.46.0"
version: "0.49.1"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -148,10 +148,10 @@ packages:
dependency: "direct dev"
description:
name: lints
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "4.0.0"
logging:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions languages/dart/dart-codegen-reference/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ dependencies:
arri_client:
path: "../dart-client"
dev_dependencies:
lints: ^3.0.0
test: ^1.21.0
lints: ^4.0.0
test: ^1.21.6
13 changes: 7 additions & 6 deletions languages/dart/dart-codegen-reference/reference_client.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// this file was autogenerated by arri
// ignore_for_file: type=lint, unused_field
import "dart:async";
import "dart:convert";
import "package:arri_client/arri_client.dart";
import "package:http/http.dart" as http;
Expand All @@ -8,11 +9,11 @@ class TestClient {
final http.Client? _httpClient;
final String _baseUrl;
final String _clientVersion = "11";
late final Map<String, String> Function()? _headers;
late final FutureOr<Map<String, String>> Function()? _headers;
TestClient({
http.Client? httpClient,
String baseUrl = "",
Map<String, String> Function()? headers,
FutureOr<Map<String, String>> Function()? headers,
}) : _httpClient = httpClient,
_baseUrl = baseUrl,
_headers = headers;
Expand Down Expand Up @@ -44,11 +45,11 @@ class TestClientUsersService {
final http.Client? _httpClient;
final String _baseUrl;
final String _clientVersion = "11";
late final Map<String, String> Function()? _headers;
late final FutureOr<Map<String, String>> Function()? _headers;
TestClientUsersService({
http.Client? httpClient,
String baseUrl = "",
Map<String, String> Function()? headers,
FutureOr<Map<String, String>> Function()? headers,
}) : _httpClient = httpClient,
_baseUrl = baseUrl,
_headers = headers;
Expand Down Expand Up @@ -135,11 +136,11 @@ class TestClientUsersSettingsService {
final http.Client? _httpClient;
final String _baseUrl;
final String _clientVersion = "11";
late final Map<String, String> Function()? _headers;
late final FutureOr<Map<String, String>> Function()? _headers;
TestClientUsersSettingsService({
http.Client? httpClient,
String baseUrl = "",
Map<String, String> Function()? headers,
FutureOr<Map<String, String>> Function()? headers,
}) : _httpClient = httpClient,
_baseUrl = baseUrl,
_headers = headers;
Expand Down
2 changes: 1 addition & 1 deletion languages/dart/dart-codegen/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arrirpc/codegen-dart",
"version": "0.46.0",
"version": "0.49.1",
"type": "module",
"license": "MIT",
"author": { "name": "joshmossas", "url": "https://github.com/joshmossas" },
Expand Down
12 changes: 6 additions & 6 deletions languages/dart/dart-codegen/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ describe("Service Generation", () => {
final http.Client? _httpClient;
final String _baseUrl;
final String _clientVersion = "";
late final Map<String, String> Function()? _headers;
late final FutureOr<Map<String, String>> Function()? _headers;
UserService({
http.Client? httpClient,
String baseUrl = "",
Map<String, String> Function()? headers,
FutureOr<Map<String, String>> Function()? headers,
}) : _httpClient = httpClient,
_baseUrl = baseUrl,
_headers = headers;
Expand Down Expand Up @@ -95,11 +95,11 @@ class UserSettingsService {
final http.Client? _httpClient;
final String _baseUrl;
final String _clientVersion = "";
late final Map<String, String> Function()? _headers;
late final FutureOr<Map<String, String>> Function()? _headers;
UserSettingsService({
http.Client? httpClient,
String baseUrl = "",
Map<String, String> Function()? headers,
FutureOr<Map<String, String>> Function()? headers,
}) : _httpClient = httpClient,
_baseUrl = baseUrl,
_headers = headers;
Expand Down Expand Up @@ -140,11 +140,11 @@ class UserSettingsService {
final http.Client? _httpClient;
final String _baseUrl;
final String _clientVersion = "";
late final Map<String, String> Function()? _headers;
late final FutureOr<Map<String, String>> Function()? _headers;
PostsService({
http.Client? httpClient,
String baseUrl = "",
Map<String, String> Function()? headers,
FutureOr<Map<String, String>> Function()? headers,
}) : _httpClient = httpClient,
_baseUrl = baseUrl,
_headers = headers;
Expand Down
9 changes: 5 additions & 4 deletions languages/dart/dart-codegen/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ ${modelParts.join("\n")}`;
}
return `// this file was autogenerated by arri
// ignore_for_file: type=lint, unused_field
import "dart:async";
import "dart:convert";
import "package:arri_client/arri_client.dart";
import "package:http/http.dart" as http;
Expand All @@ -167,11 +168,11 @@ class ${opts.clientName} {
final http.Client? _httpClient;
final String _baseUrl;
final String _clientVersion = "${def.info?.version ?? ""}";
late final Map<String, String> Function()? _headers;
late final FutureOr<Map<String, String>> Function()? _headers;
${opts.clientName}({
http.Client? httpClient,
String baseUrl = "",
Map<String, String> Function()? headers,
FutureOr<Map<String, String>> Function()? headers,
}) : _httpClient = httpClient,
_baseUrl = baseUrl,
_headers = headers;
Expand Down Expand Up @@ -228,11 +229,11 @@ export function dartServiceFromDefinition(
final http.Client? _httpClient;
final String _baseUrl;
final String _clientVersion = "${opts.versionNumber}";
late final Map<String, String> Function()? _headers;
late final FutureOr<Map<String, String>> Function()? _headers;
${serviceName}Service({
http.Client? httpClient,
String baseUrl = "",
Map<String, String> Function()? headers,
FutureOr<Map<String, String>> Function()? headers,
}) : _httpClient = httpClient,
_baseUrl = baseUrl,
_headers = headers;
Expand Down
2 changes: 1 addition & 1 deletion languages/kotlin/kotlin-codegen/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arrirpc/codegen-kotlin",
"version": "0.46.0",
"version": "0.49.1",
"type": "module",
"license": "MIT",
"author": { "name": "joshmossas", "url": "https://github.com/joshmossas" },
Expand Down
Loading

0 comments on commit 74e9ee0

Please sign in to comment.