Skip to content

Commit

Permalink
Chore/upgrade runtime (#274)
Browse files Browse the repository at this point in the history
* chore: bump pods

* chore: bump pubs

* fix: apply seed colors also to customColors

* fix: adapt to package changes

* chore: upgrade runtime to 5.6.1

* refactor: support new settings methods

* fix: use xcode 16 in codemagic

* fix: comment

* fix: add originalName

* test: add settings by key and reference test
  • Loading branch information
jkoenig134 authored Sep 20, 2024
1 parent 31d95b8 commit 399be90
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 56 deletions.
18 changes: 17 additions & 1 deletion packages/enmeshed_runtime_bridge/assets/index.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,36 @@ void run(EnmeshedRuntime runtime) {
final setting = await session.consumptionServices.settings.getSettingByKey('a-key');
expect(setting.value.value, {'aKey': 'aNewValue'});
});

test('should upsert a relationship setting by key', () async {
const value = {'aKey': 'a-value'};

const reference = 'RELaaaaaaaaaaaaaaaaa';

final upsertSettingResult = await session.consumptionServices.settings.upsertSettingByKey(
'a-key',
value,
reference: reference,
scope: SettingScope.Relationship,
);
expect(upsertSettingResult, isSuccessful<SettingDTO>());
expect(upsertSettingResult.value.value, value);
expect(upsertSettingResult.value.reference, reference);
expect(upsertSettingResult.value.scope, SettingScope.Relationship);

final result = await session.consumptionServices.settings.getSettings();
expect(result, isSuccessful<List<SettingDTO>>());
expect(result.value, hasLength(1));

final getSettingResult = await session.consumptionServices.settings.getSettingByKey(
'a-key',
reference: reference,
scope: SettingScope.Relationship,
);
final setting = getSettingResult.value;
expect(setting.value, value);
expect(setting.reference, reference);
expect(setting.scope, SettingScope.Relationship);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,20 @@ class SettingsFacade {
return Result.fromJson(result.valueToMap(), (x) => SettingDTO.fromJson(x));
}

Future<Result<SettingDTO>> getSettingByKey(String key) async {
Future<Result<SettingDTO>> getSettingByKey(
String key, {
String? reference,
SettingScope? scope,
}) async {
final result = await _evaluator.evaluateJavaScript(
'''const result = await session.consumptionServices.settings.getSettingByKey(request)
if (result.isError) return { error: { message: result.error.message, code: result.error.code } }
return { value: result.value }''',
arguments: {
'request': {
'key': key,
if (reference != null) 'reference': reference,
if (scope != null) 'scope': scope.name,
},
},
);
Expand Down Expand Up @@ -115,7 +121,12 @@ class SettingsFacade {
return Result.fromJson(result.valueToMap(), (x) => SettingDTO.fromJson(x));
}

Future<Result<SettingDTO>> upsertSettingByKey(String key, Map<String, dynamic> value) async {
Future<Result<SettingDTO>> upsertSettingByKey(
String key,
Map<String, dynamic> value, {
String? reference,
SettingScope? scope,
}) async {
final result = await _evaluator.evaluateJavaScript(
'''const result = await session.consumptionServices.settings.upsertSettingByKey(request)
if (result.isError) return { error: { message: result.error.message, code: result.error.code } }
Expand All @@ -124,6 +135,8 @@ class SettingsFacade {
'request': {
'key': key,
'value': value,
if (reference != null) 'reference': reference,
if (scope != null) 'scope': scope.name,
},
},
);
Expand Down
102 changes: 54 additions & 48 deletions packages/enmeshed_runtime_bridge/natives/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/enmeshed_runtime_bridge/natives/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"@js-soft/logging-abstractions": "^1.0.1",
"@js-soft/ts-utils": "^2.3.3",
"@js-soft/web-logger": "^1.0.4",
"@nmshd/app-runtime": "5.4.1",
"@nmshd/runtime": "5.4.1",
"@nmshd/app-runtime": "5.6.1",
"@nmshd/runtime": "5.6.1",
"js-logger": "^1.6.1",
"json-stringify-safe": "^5.0.1",
"lodash": "^4.17.21"
Expand All @@ -24,10 +24,10 @@
"@types/json-stringify-safe": "^5.0.3",
"@types/lodash": "^4.17.7",
"@types/luxon": "^3.4.2",
"@types/node": "^22.5.4",
"@types/node": "^22.5.5",
"esbuild": "^0.23.1",
"luxon": "^3.5.0",
"prettier": "^3.3.3",
"typescript": "^5.5.4"
"typescript": "^5.6.2"
}
}
2 changes: 1 addition & 1 deletion packages/enmeshed_runtime_bridge/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dev_dependencies:
test: any

dependency_overrides:
# needed to compile with Xcode 15
# needed to compile with Xcode 16
# https://github.com/pichillilorenzo/flutter_inappwebview/issues/2221#issuecomment-2348119737
flutter_inappwebview_ios:
git:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class IdentityDVO extends DataViewObject with EquatableMixin {
final bool isSelf;
final bool hasRelationship;
final RelationshipDVO? relationship;
final String? originalName;

const IdentityDVO({
required super.id,
Expand All @@ -29,6 +30,7 @@ class IdentityDVO extends DataViewObject with EquatableMixin {
required this.isSelf,
required this.hasRelationship,
this.relationship,
this.originalName,
});

factory IdentityDVO.fromJson(Map json) => _$IdentityDVOFromJson(Map<String, dynamic>.from(json));
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class RelationshipDVO extends DataViewObject with EquatableMixin {
final Map<String, List<LocalAttributeDVO>> attributeMap;
final Map<String, String> nameMap;
final String templateId;
final String? originalName;

const RelationshipDVO({
required super.id,
Expand All @@ -47,6 +48,7 @@ class RelationshipDVO extends DataViewObject with EquatableMixin {
required this.attributeMap,
required this.nameMap,
required this.templateId,
this.originalName,
});

factory RelationshipDVO.fromJson(Map json) => _$RelationshipDVOFromJson(Map<String, dynamic>.from(json));
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 399be90

Please sign in to comment.