-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: at_commons 4.0.0 uptake in at_Client #1192
Conversation
…ndencies # Conflicts: # packages/at_client/CHANGELOG.md
…to update_atclient_dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR has a lot of files changed
Via the "Files Changed" tab), please add a brief explanation of the reason for each change (at least the first time it appears - e.g. the change from atKey.key ?? ''
to atKey.key
appears in many place - please explain why.)
Please also consider for every change here whether it is a breaking change for the at_client package
@@ -41,7 +41,7 @@ class AtCollectionMethodImpl { | |||
_logger.finest('Self key to be used : $atKey'); | |||
var atOperationItemStatus = AtOperationItemStatus( | |||
atSign: atKey.sharedBy ?? '', | |||
key: atKey.key ?? '', | |||
key: atKey.key, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Earlier, the AtKey.key is a nullable variable, but the named argument "key" does not accept NULL value. Hence defaulted to empty string in case of null. In at_commons-4.0.0, the AtKey.key is prefixed with late and "?" (which denotes that variable can be null) is removed because key can never be null in AtKey,
..metadata!.ccd = objectLifeCycleOptions?.cascadeDelete ?? true | ||
..metadata!.ttl = objectLifeCycleOptions?.timeToLive?.inMilliseconds | ||
..metadata!.ttb = objectLifeCycleOptions?.timeToBirth?.inMilliseconds | ||
..metadata.ccd = objectLifeCycleOptions?.cascadeDelete ?? true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In at_commons-> AtKey, updated the "metadata" field from nullable field (removed "?"). With the change, the field is defaulted to Metadata instance - "Metadata metadata = Metadata();"
..sharedWith = atKey.sharedWith | ||
..atKey = keyWithNamespace | ||
..sharedBy = atKey.sharedBy; | ||
var builder = DeleteVerbBuilder()..atKey = atKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fields of AtKey are now substituted with AtKey instances in all verb builders. The atKey object is directly assigned, and the code responsible for assigning fields of atKey has been removed
@@ -470,7 +451,7 @@ class AtClientImpl implements AtClient, AtSignChangeListener { | |||
|
|||
@visibleForTesting | |||
ensureLowerCase(AtKey atKey) { | |||
if ((atKey.key != null && upperCaseRegex.hasMatch(atKey.key!)) || | |||
if (upperCaseRegex.hasMatch(atKey.key) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since Atkey.key is modified as a non null variable in at_commons, removed the non-null assertion operator
@@ -487,12 +468,12 @@ class AtClientImpl implements AtClient, AtSignChangeListener { | |||
if (atKey.sharedBy.isNull) { | |||
atKey.sharedBy = _atSign; | |||
} | |||
if (atKey.metadata!.namespaceAware) { | |||
if (atKey.metadata.namespaceAware) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since Atkey.metadata is modified as a non null variable (defaulted to "Metadata()"), removed the non-null assertion operator
..isBinary = metadata.isBinary | ||
..isEncrypted = metadata.isEncrypted | ||
..dataSignature = metadata.dataSignature | ||
..atKey = atKey |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fields of AtKey are now substituted with AtKey instances in all verb builders. The atKey object is directly assigned, and the code responsible for assigning fields of atKey has been removed
..operation = AtConstants.updateMeta; | ||
|
||
var updateMetaResult = await getSecondary() | ||
.executeVerb(builder, sync: SyncUtil.shouldSync(updateKey!)); | ||
.executeVerb(builder, sync: SyncUtil.shouldSync(updateKey)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since Atkey.key is modified as a non null variable in at_commons, removed the non-null assertion operator
@@ -949,7 +920,7 @@ class AtClientImpl implements AtClient, AtSignChangeListener { | |||
PriorityEnum? priority, | |||
StrategyEnum? strategy, | |||
int? latestN, | |||
String? notifier = SYSTEM, | |||
String? notifier = AtConstants.system, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced the use of legacy at_constants (which are now removed from at_commons -4.0.0) with new references to new AtConstants file
(atKey.metadata != null && | ||
atKey.metadata!.isPublic! && | ||
!atKey.metadata!.isCached)) { | ||
(atKey.metadata.isPublic && !atKey.metadata.isCached)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since AtKey.metadata is not null and boolean fields in Metadata have default values instead of null, removed the null check and non null assertion operator
(metaData[CCD].toLowerCase() == 'true') | ||
? builder.ccd = true | ||
: builder.ccd = false; | ||
if (metaData[AtConstants.ttl] != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AT_TTL, AT_TTB, AT_TTR...which is are a part of "at_constants_legacy.dart" which is deprecated and removed in at_commons-4.0.0. The "at_constants_legacy.dart" is replaced with "at_constants.dart" in at_commons.
@@ -12,8 +12,6 @@ class GetRequestTransformer implements RequestTransformer<AtKey, VerbBuilder> { | |||
|
|||
@override | |||
VerbBuilder transform(AtKey atKey, {RequestOptions? requestOptions}) { | |||
// Set the default metadata if not already set. | |||
atKey.metadata ??= Metadata(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since AtKey.metadata is defaulted to "Metadata()". Hence removed the above line.
@@ -21,8 +21,6 @@ class NotificationRequestTransformer | |||
@override | |||
Future<NotifyVerbBuilder> transform( | |||
NotificationParams notificationParams) async { | |||
// If metadata is not set, initialize Metadata instance. | |||
notificationParams.atKey.metadata ??= Metadata(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since AtKey.metadata is defaulted to "Metadata()". Hence removed the above line.
builder.ivNonce = notificationParams.atKey.metadata?.ivNonce; | ||
builder.skeEncKeyName = notificationParams.atKey.metadata?.skeEncKeyName; | ||
builder.skeEncAlgo = notificationParams.atKey.metadata?.skeEncAlgo; | ||
builder.atKey.metadata.ttl = notificationParams.atKey.metadata.ttl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fields of AtKey and Metadata are now substituted with AtKey instances in all verb builders. The metadata values are assigned to the metadata fields in the atKey.metadata.
if (tuple.one.metadata != null && | ||
tuple.one.metadata!.isBinary != null && | ||
tuple.one.metadata!.isBinary!) { | ||
if (tuple.one.metadata.isBinary) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since in AtKey.metadata is defaulted to "Metadata()" and boolean fields in metadata have default values, removed null check.
..sharedBy = atNotification.from | ||
..metadata = atNotification.metadata; | ||
..sharedBy = atNotification.from; | ||
if (atNotification.metadata != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since AtKey.metadata does not hold null value, added a null check before assigning the metadata.
@gkc: Added comments explaining the changes. We have ensured not to introduce any breaking changes. @purnimavenkatasubbu has completed a round of testing with mobile apps with this branch and no bugs are reported. |
atKey.metadata ??= Metadata(); | ||
String keyWithNamespace; | ||
if (atKey.metadata!.namespaceAware) { | ||
keyWithNamespace = AtClientUtil.getKeyWithNameSpace(atKey, _preference!); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the namespace fixing no longer required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By assigning atKey directly to the verb builder, key construction utilizes AtKey.toString(), appending the namespace to the key. For the key we do not want namespace to be appended, leaving the namespace fields unset or initializing them to an empty string will suffice.
However, when the user doesn't set a namespace for the AtKey, the earlier practice involved appending the namespace from the AtClientPreferences when namespaceAware is set to "true" is missing here. Will add the code where if atKey.namespace is null or empty and namespaceAware is true, then set the namespace from AtClientPreference.namespace
..isBinary = | ||
(atKey.metadata?.isBinary != null) ? atKey.metadata?.isBinary! : false | ||
..isLocal = atKey.isLocal; | ||
..atKey = (AtKey() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you creating a new atKey object here? Can't we just use the one that was passed as a method parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AtKey received from the put method is assigned to the UpdateVerbBuilder.atKey. Removed the above because we not have assign each field of atKey to the atKey in UpdateVerbBuilder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more requests and comments
Thank you both |
This reverts commit 57cb917.
…ace from at_client preferences and assign AtKey to UpdateVerbBuilder directly
…to update_atclient_dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sitaram-kalluri @purnimavenkatasubbu Please can you do another round of testing of atmospherePro, atBuzz and at_talk with this branch, just to make sure
@gkc : Sure, will do a round of testing with apps and keep you updated. |
I did a quick round of sanity testing with atMospherePro, atBuzz, and atTalk pointing to this branch of at_client. It looks good. Attaching below POTs |
- What I did
Updated the following dependencies
Also made updates as per the at_commons:4.0.0 changes
Updated the melos.yaml temporarily to avoid at_client being picked from the path. This causes "dart run melos bootstrap" to fail because at_client_mobile is compatible with at_commons-4.0.0 while at_client is upgraded to 4.0.0. This does not affect the mobile apps. Once the at_client_mobile is compatible with at_commons-4.0.0 will revert the change.
- How to verify it
All the unit, functional, and end2end tests should pass
All the apps should work fine
- Description for the changelog