Skip to content

Commit 736737a

Browse files
codelessly_api 5.2.0: auth, conditional, forEach and cloud file actions (#36)
* Add auth, conditional, forEach and cloudFiles actions Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VJ3E2NmBuiBkBnmDDmQBcz * Rounded rows and columns, and paint alpha from 8-digit colors Rows and columns take a corner radius like frames, so a card or chip doesn't need an extra frame. A solid paint given as #AARRGGBB keeps its alpha as opacity instead of dropping it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VJ3E2NmBuiBkBnmDDmQBcz * Encode dates in list and map variables as ISO strings Cloud documents carry createdAt and updatedAt as DateTime, which jsonEncode rejects, so a collection loaded into a variable threw and its screen never left the loading state. Dates now read as text. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VJ3E2NmBuiBkBnmDDmQBcz * codelessly_api 5.2.0: auth, conditional, forEach and cloud file actions Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VJ3E2NmBuiBkBnmDDmQBcz --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 938a21d commit 736737a

31 files changed

Lines changed: 819 additions & 11 deletions

‎CHANGELOG.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
## 5.2.0
2+
3+
### New actions
4+
5+
- `AuthAction` (`ActionType.auth`): sign up, sign in, sign out, update the
6+
profile and send a password reset email (`AuthOperation`), with an
7+
optional error variable.
8+
- `ConditionalAction` (`ActionType.conditional`): an expression with
9+
then/else action lists, so action chains can branch.
10+
- `ForEachAction` (`ActionType.forEach`): runs actions for each item of a
11+
list variable.
12+
- `CloudFilesAction` (`ActionType.cloudFiles`): picks and uploads images to
13+
the project's storage, or deletes a file, running nested actions per file.
14+
15+
### Changes
16+
17+
- `RowColumnNode` has a corner radius.
18+
- 8-digit `#AARRGGBB` colors set the paint's opacity when none is given.
19+
- Dates in list and map variables encode as ISO 8601 strings
20+
(`encodeJsonValue`), and `VariableType.fromObjectType` maps `DateTime` to
21+
text.
22+
123
## 5.1.0
224

325
### New nodes

‎lib/src/api/models/action/action.dart‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,19 @@ enum ActionType {
3737
setCloudStorage,
3838

3939
/// Load data from cloud storage.
40-
loadFromCloudStorage;
40+
loadFromCloudStorage,
41+
42+
/// Sign app users in and out.
43+
auth,
44+
45+
/// Branch on an expression.
46+
conditional,
47+
48+
/// Run actions for each item of a list.
49+
forEach,
50+
51+
/// Upload or delete files in cloud storage.
52+
cloudFiles;
4153

4254
/// Displayable string representation of the [ActionType].
4355
String get prettify {
@@ -66,6 +78,14 @@ enum ActionType {
6678
return 'Set Cloud Storage';
6779
case ActionType.loadFromCloudStorage:
6880
return 'Load from Cloud Storage';
81+
case ActionType.auth:
82+
return 'Authentication';
83+
case ActionType.conditional:
84+
return 'If / Else';
85+
case ActionType.forEach:
86+
return 'For Each';
87+
case ActionType.cloudFiles:
88+
return 'Cloud Files';
6989
}
7090
}
7191
}
@@ -139,6 +159,14 @@ abstract class ActionModel with SerializableMixin {
139159
return SetCloudStorageAction.fromJson(json);
140160
case ActionType.loadFromCloudStorage:
141161
return LoadFromCloudStorageAction.fromJson(json);
162+
case ActionType.auth:
163+
return AuthAction.fromJson(json);
164+
case ActionType.conditional:
165+
return ConditionalAction.fromJson(json);
166+
case ActionType.forEach:
167+
return ForEachAction.fromJson(json);
168+
case ActionType.cloudFiles:
169+
return CloudFilesAction.fromJson(json);
142170
}
143171
}
144172

‎lib/src/api/models/action/api_call_action.g.dart‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import 'package:equatable/equatable.dart';
2+
import 'package:json_annotation/json_annotation.dart';
3+
4+
import '../../mixins.dart';
5+
import '../models.dart';
6+
7+
part 'auth_action.g.dart';
8+
9+
/// What an [AuthAction] does to the app's signed-in user.
10+
enum AuthOperation {
11+
/// Signs in with [AuthAction.email] and [AuthAction.password].
12+
signIn,
13+
14+
/// Creates an account with [AuthAction.email] and [AuthAction.password],
15+
/// and sets its display name to [AuthAction.displayName] when given.
16+
signUp,
17+
18+
/// Signs the user out.
19+
signOut,
20+
21+
/// Sets the signed-in user's display name to [AuthAction.displayName].
22+
updateProfile,
23+
24+
/// Sends a password reset email to [AuthAction.email].
25+
sendPasswordResetEmail;
26+
27+
/// A readable name for this operation.
28+
String get label => switch (this) {
29+
signIn => 'Sign In',
30+
signUp => 'Sign Up',
31+
signOut => 'Sign Out',
32+
updateProfile => 'Update Profile',
33+
sendPasswordResetEmail => 'Send Password Reset Email',
34+
};
35+
}
36+
37+
/// Signs app users in and out with email and password.
38+
///
39+
/// The signed-in user is available to layouts as the `auth` variable:
40+
/// `${auth.uid}`, `${auth.email}`, `${auth.displayName}` and
41+
/// `${auth.isSignedIn}`.
42+
///
43+
/// [email], [password] and [displayName] may contain variable paths, e.g.
44+
/// `${email}`. When the operation fails, the action fails, which stops the
45+
/// actions after it, and a readable message is written to [errorVariable]
46+
/// when one is set. On success [errorVariable] is cleared.
47+
@JsonSerializable()
48+
class AuthAction extends ActionModel with Equatable, SerializableMixin {
49+
/// What to do.
50+
final AuthOperation operation;
51+
52+
/// The email address, for [AuthOperation.signIn], [AuthOperation.signUp]
53+
/// and [AuthOperation.sendPasswordResetEmail].
54+
final String email;
55+
56+
/// The password, for [AuthOperation.signIn] and [AuthOperation.signUp].
57+
final String password;
58+
59+
/// The display name, for [AuthOperation.signUp] and
60+
/// [AuthOperation.updateProfile].
61+
final String displayName;
62+
63+
/// A text variable that receives the error message when the operation
64+
/// fails, and is cleared when it succeeds.
65+
final VariableData? errorVariable;
66+
67+
/// Creates an [AuthAction].
68+
AuthAction({
69+
this.operation = AuthOperation.signIn,
70+
this.email = '',
71+
this.password = '',
72+
this.displayName = '',
73+
this.errorVariable,
74+
super.nonBlocking,
75+
super.enabled,
76+
}) : super(type: ActionType.auth);
77+
78+
/// Duplicates this action with the given values replaced.
79+
AuthAction copyWith({
80+
AuthOperation? operation,
81+
String? email,
82+
String? password,
83+
String? displayName,
84+
VariableData? errorVariable,
85+
}) => AuthAction(
86+
operation: operation ?? this.operation,
87+
email: email ?? this.email,
88+
password: password ?? this.password,
89+
displayName: displayName ?? this.displayName,
90+
errorVariable: errorVariable ?? this.errorVariable,
91+
nonBlocking: nonBlocking,
92+
enabled: enabled,
93+
);
94+
95+
@override
96+
List<Object?> get props => [
97+
operation,
98+
email,
99+
password,
100+
displayName,
101+
errorVariable,
102+
];
103+
104+
/// Creates an instance from a JSON object.
105+
factory AuthAction.fromJson(Map json) => _$AuthActionFromJson(json);
106+
107+
@override
108+
Map toJson() => _$AuthActionOmitDefaults(this, _$AuthActionToJson(this));
109+
110+
@override
111+
R? accept<R>(ActionVisitor<R> visitor) => visitor.visitAuthAction(this);
112+
}

‎lib/src/api/models/action/auth_action.g.dart‎

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/call_function_action.g.dart‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)