Skip to content

Commit

Permalink
fix: Added Enum for Keys.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Aug 4, 2023
1 parent 24d7562 commit 88f6c99
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/katana_cli/lib/command/code/collection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ typedef ${className}ModelRefPath = _\$${className}ModelPath;
/// ```
typedef ${className}ModelInitialCollection = _\$${className}ModelInitialCollection;
/// [Enum] of the name of the value defined in ${className}Model.
typedef ${className}ModelKeys = _\$${className}ModelKeys;
/// Document class for storing ${className}Model.
typedef ${className}ModelDocument = _\$${className}ModelDocument;
Expand Down
4 changes: 3 additions & 1 deletion packages/katana_cli/lib/command/code/document.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ typedef ${className}ModelRefPath = _\$${className}ModelPath;
/// ```
typedef ${className}ModelInitialDocument = _\$${className}ModelInitialDocument;
/// [Enum] of the name of the value defined in ${className}Model.
typedef ${className}ModelKeys = _\$${className}ModelKeys;
/// Document class for storing ${className}Model.
typedef ${className}ModelDocument = _\$${className}ModelDocument;
""";
}
}
3 changes: 3 additions & 0 deletions packages/katana_cli/lib/command/code/value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ class ${className}Value with _\$${className}Value {
/// ```
static const form = _\$${className}ValueFormQuery();
}
/// [Enum] of the name of the value defined in ${className}Value.
typedef ${className}ValueKeys = _\$${className}ValueKeys;
""";
}
}
11 changes: 11 additions & 0 deletions packages/masamune_builder/lib/form/form_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ List<Spec> formValueClass(
bool autoDisposeWhenUnreferenced,
) {
return [
Enum(
(e) => e
..name = "_\$${model.name}Keys"
..values.addAll([
...model.parameters.map((param) {
return EnumValue(
(v) => v..name = param.name,
);
}),
]),
),
Class(
(c) => c
..name = "_\$${model.name}FormQuery"
Expand Down
11 changes: 11 additions & 0 deletions packages/masamune_builder/lib/model/model_class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ List<Spec> modelClass(
),
]),
),
Enum(
(e) => e
..name = "_\$${model.name}Keys"
..values.addAll([
...model.parameters.map((param) {
return EnumValue(
(v) => v..name = param.name,
);
}),
]),
),
];
}

Expand Down
2 changes: 1 addition & 1 deletion packages/masamune_builder/lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ Builder masamuneBuilderFactory(BuilderOptions options) {
],
".m.dart",
header:
"// GENERATED CODE - DO NOT MODIFY BY HAND\r\n\r\n// ignore_for_file: unused_field, unused_element, require_trailing_commas, prefer_const_constructors, unnecessary_overrides, prefer_const_literals_to_create_immutables, unnecessary_null_in_if_null_operators, library_prefixes, directives_ordering, no_leading_underscores_for_local_identifiers, unnecessary_brace_in_string_interps, unnecessary_type_check, library_private_types_in_public_api, unnecessary_nullable_for_final_variable_declarations",
"// GENERATED CODE - DO NOT MODIFY BY HAND\r\n\r\n// ignore_for_file: unused_field, unused_element, require_trailing_commas, prefer_const_constructors, unnecessary_overrides, prefer_const_literals_to_create_immutables, unnecessary_null_in_if_null_operators, library_prefixes, directives_ordering, no_leading_underscores_for_local_identifiers, unnecessary_brace_in_string_interps, unnecessary_type_check, library_private_types_in_public_api, unnecessary_nullable_for_final_variable_declarations, prefer_const_declarations",
);
}
2 changes: 1 addition & 1 deletion packages/masamune_builder/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ packages:
path: "../masamune_annotation"
relative: true
source: path
version: "2.2.0"
version: "2.2.1"
matcher:
dependency: transitive
description:
Expand Down

0 comments on commit 88f6c99

Please sign in to comment.