Skip to content
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(interactions): use pako instead of fflate in RN #10278

Merged

Conversation

ashwinkumar6
Copy link
Member

Description of changes

fflat lib is used in interactions to gzip data.

This lib uses .cjs files which would throw an error during build in RN apps. RN apps would need to resolve this by adding the following in metro config file

resolver: {
  sourceExts: [...sourceExts, "cjs"]
}

To avoid this, use an alternative lib pako instead of fflate in RN. For web continue using fflate since it's bundle size is much smaller than pako

Description of how you validated changes

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor

@elorzafe elorzafe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Thanks @ashwinkumar6 🎉

Copy link
Member

@Samaritan1011001 Samaritan1011001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you! 🎉

Copy link
Member

@cshfang cshfang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still have a minor question around the typing of InteractionsMessage. I don't think it's blocking but some comments describing why the guard is needed could be helpful as it's not intuitive from looking at typing alone.

Comment on lines +167 to +169
if (typeof content !== 'object') {
return Promise.reject('invalid content type');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this check in place because, at runtime, it is possible for the message to not be string | InteractionsMessage? From looking at typing, it does not seem possible for a message with messageType of voice to have a content that isn't object.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chatted offline about this. The issue is in the typing as I understand it. We should probably update the typing to be able to infer voice or text message (and therefore the content type) but we can do so in a separate PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed it's inferring to union type because of the way the type is defined.
So a guard clause is required

export type InteractionsTextMessage = {
	content: string;
	options: {
		messageType: 'text';
	};
};

export type InteractionsVoiceMessage = {
	content: object;
	options: {
		messageType: 'voice';
	};
};

export type InteractionsMessage =
	| InteractionsTextMessage
	| InteractionsVoiceMessage;

@codecov-commenter
Copy link

Codecov Report

Merging #10278 (b8e1a95) into main (840086d) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main   #10278      +/-   ##
==========================================
+ Coverage   84.40%   84.42%   +0.01%     
==========================================
  Files         258      258              
  Lines       18691    18694       +3     
  Branches     4017     4019       +2     
==========================================
+ Hits        15777    15782       +5     
+ Misses       2824     2822       -2     
  Partials       90       90              
Impacted Files Coverage Δ
...kages/interactions/src/Providers/AWSLexProvider.ts 96.15% <100.00%> (+1.41%) ⬆️
.../src/Providers/AWSLexProviderHelper/commonUtils.ts 85.71% <100.00%> (-3.18%) ⬇️
...ctions/src/Providers/AWSLexProviderHelper/utils.ts 92.85% <100.00%> (+0.54%) ⬆️
...ges/interactions/src/Providers/AWSLexV2Provider.ts 96.96% <100.00%> (+1.09%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@elorzafe elorzafe merged commit 0c804e4 into aws-amplify:main Sep 1, 2022
stocaaro added a commit that referenced this pull request Sep 13, 2022
commit 1ad20b2
Author: Ivan Artemiev <29709626+iartemiev@users.noreply.github.com>
Date:   Fri Sep 9 13:26:20 2022 -0400

    fix(cache): use named import when exporting from aws-amplify (#10305)

commit 59c3452
Author: aws-amplify-bot <aws@amazon.com>
Date:   Thu Sep 8 23:09:27 2022 +0000

    chore(release): update version.ts [ci skip]

commit ebabd7e
Author: aws-amplify-bot <aws@amazon.com>
Date:   Thu Sep 8 23:07:08 2022 +0000

    chore(release): Publish [ci skip]

     - @aws-amplify/ui-angular@1.0.62
     - @aws-amplify/ui-components@1.9.33
     - @aws-amplify/ui-react@1.2.53
     - @aws-amplify/ui-storybook@2.0.53
     - @aws-amplify/ui-vue@1.1.47
     - @aws-amplify/analytics@5.2.20
     - @aws-amplify/api-graphql@2.3.17
     - @aws-amplify/api-rest@2.0.53
     - @aws-amplify/api@4.0.53
     - @aws-amplify/auth@4.6.6
     - aws-amplify-angular@6.0.53
     - aws-amplify-react@5.1.36
     - aws-amplify@4.3.35
     - @aws-amplify/cache@4.0.55
     - @aws-amplify/core@4.7.4
     - @aws-amplify/datastore-storage-adapter@1.3.13
     - @aws-amplify/datastore@3.12.10
     - @aws-amplify/geo@1.3.16
     - @aws-amplify/interactions@4.1.1
     - @aws-amplify/predictions@4.0.53
     - @aws-amplify/pubsub@4.5.3
     - @aws-amplify/pushnotification@4.3.32
     - @aws-amplify/storage@4.5.6
     - @aws-amplify/xr@3.0.53

commit 4505892
Author: Manoj NB <manojnb@amazon.com>
Date:   Thu Sep 8 15:29:37 2022 -0700

    chore: preparing release

commit 89cdfd3
Author: Aaron S <94858815+stocaaro@users.noreply.github.com>
Date:   Thu Sep 8 15:39:39 2022 -0500

    fix(pubsub): Fix vite build issue (#10298)

commit 1862cc7
Author: aws-amplify-bot <aws@amazon.com>
Date:   Thu Sep 1 22:12:21 2022 +0000

    chore(release): update version.ts [ci skip]

commit 29e6603
Author: aws-amplify-bot <aws@amazon.com>
Date:   Thu Sep 1 22:09:49 2022 +0000

    chore(release): Publish [ci skip]

     - @aws-amplify/ui-angular@1.0.61
     - @aws-amplify/ui-components@1.9.32
     - @aws-amplify/ui-react@1.2.52
     - @aws-amplify/ui-storybook@2.0.52
     - @aws-amplify/ui-vue@1.1.46
     - @aws-amplify/analytics@5.2.19
     - @aws-amplify/api-graphql@2.3.16
     - @aws-amplify/api-rest@2.0.52
     - @aws-amplify/api@4.0.52
     - @aws-amplify/auth@4.6.5
     - aws-amplify-angular@6.0.52
     - aws-amplify-react@5.1.35
     - aws-amplify@4.3.34
     - @aws-amplify/cache@4.0.54
     - @aws-amplify/core@4.7.3
     - @aws-amplify/datastore-storage-adapter@1.3.12
     - @aws-amplify/datastore@3.12.9
     - @aws-amplify/geo@1.3.15
     - @aws-amplify/interactions@4.1.0
     - @aws-amplify/predictions@4.0.52
     - @aws-amplify/pubsub@4.5.2
     - @aws-amplify/pushnotification@4.3.31
     - @aws-amplify/storage@4.5.5
     - @aws-amplify/xr@3.0.52

commit 8717733
Author: elorzafe <elorzafe@amazon.com>
Date:   Thu Sep 1 14:11:10 2022 -0700

    chore: preparing release

commit 11e735b
Author: Francisco Rodriguez <frodriguez.cs@gmail.com>
Date:   Thu Sep 1 13:13:20 2022 -0700

    chore(@aws-amplify/interactions): adding lex v2 integ test (#10282)

    * Adding lexv2 integ test to pipeline

commit 0c804e4
Author: Ashwin Kumar <ashwinkumar2468@gmail.com>
Date:   Wed Aug 31 18:06:56 2022 -0700

    fix(@aws-amplify/interactions): use pako instead of fflate in RN (#10278)

    * fix(interactions): use pako instead of fflate in RN

commit 840086d
Author: Ashwin Kumar <ashwinkumar2468@gmail.com>
Date:   Wed Aug 31 12:57:56 2022 -0700

    fix(@aws-amplify/interactions): add audio type Uint8Array to lexV1 (#10273)

    * fix(interactions): add audio type Uint8Array to lexV1

commit 91fdcd9
Author: Ashwin Kumar <ashwinkumar2468@gmail.com>
Date:   Tue Aug 30 13:35:56 2022 -0700

    feat(@aws-amplify/interactions): Add LexV2 support to interactions (#10217)

    * Add Interactions LexV2Provider and React example (#10167)

    Co-authored-by: Lucas Picchi <picchi.lucas@gmail.com>
    Co-authored-by: Sridhar <ashwsrir@bcd07413f71a.ant.amazon.com>
    Co-authored-by: Francisco Rodriguez <frodriguez.cs@gmail.com>

commit 98dd9f2
Author: Dane Pilcher <dppilche@amazon.com>
Date:   Tue Aug 30 13:29:46 2022 -0600

    fix(datastore): clear before start with nextjs (#10234)

commit 7f2534d
Author: Ashwin Kumar <ashwinkumar2468@gmail.com>
Date:   Fri Aug 26 14:45:22 2022 -0700

    feat(@aws-amplify/interactions): call onComplete callback with entire response (#10248)

    * feat(interactions): call onComplete callback with entire response

commit 511751a
Author: Jon Wire <iambipedal@gmail.com>
Date:   Thu Aug 25 11:52:56 2022 -0500

    chore: fixed build, minimatch dep (#10261)

commit 4217e83
Author: aws-amplify-bot <aws@amazon.com>
Date:   Tue Aug 23 23:14:03 2022 +0000

    chore(release): update version.ts [ci skip]

commit da29d79
Author: aws-amplify-bot <aws@amazon.com>
Date:   Tue Aug 23 23:11:11 2022 +0000

    chore(release): Publish [ci skip]

     - @aws-amplify/ui-angular@1.0.60
     - @aws-amplify/ui-components@1.9.31
     - @aws-amplify/ui-react@1.2.51
     - @aws-amplify/ui-storybook@2.0.51
     - @aws-amplify/ui-vue@1.1.45
     - @aws-amplify/analytics@5.2.18
     - @aws-amplify/api-graphql@2.3.15
     - @aws-amplify/api-rest@2.0.51
     - @aws-amplify/api@4.0.51
     - @aws-amplify/auth@4.6.4
     - aws-amplify-angular@6.0.51
     - aws-amplify-react@5.1.34
     - aws-amplify@4.3.33
     - @aws-amplify/cache@4.0.53
     - @aws-amplify/core@4.7.2
     - @aws-amplify/datastore-storage-adapter@1.3.11
     - @aws-amplify/datastore@3.12.8
     - @aws-amplify/geo@1.3.14
     - @aws-amplify/interactions@4.0.51
     - @aws-amplify/predictions@4.0.51
     - @aws-amplify/pubsub@4.5.1
     - @aws-amplify/pushnotification@4.3.30
     - @aws-amplify/storage@4.5.4
     - @aws-amplify/xr@3.0.51

commit 7d65e44
Author: Aaron S <stocaaro@stocad.com>
Date:   Tue Aug 23 17:34:16 2022 -0500

    chore: preparing release

commit 01aad60
Author: Ashwin Kumar <ashwinkumar2468@gmail.com>
Date:   Mon Aug 22 18:05:49 2022 -0700

    fix(interactions): fix addPluggable API (#10250)

    * fix(interactions): fix addPluggable API

    * fix(interactions): remove Add a invalid pluggable test

    Co-authored-by: Sridhar <ashwsrir@bcd07413f71a.ant.amazon.com>

commit 2b54c1a
Author: aws-amplify-bot <aws@amazon.com>
Date:   Thu Aug 18 23:50:36 2022 +0000

    chore(release): update version.ts [ci skip]

commit 2e016a6
Author: aws-amplify-bot <aws@amazon.com>
Date:   Thu Aug 18 23:47:58 2022 +0000

    chore(release): Publish [ci skip]

     - @aws-amplify/ui-angular@1.0.59
     - @aws-amplify/ui-components@1.9.30
     - @aws-amplify/ui-react@1.2.50
     - @aws-amplify/ui-storybook@2.0.50
     - @aws-amplify/ui-vue@1.1.44
     - @aws-amplify/analytics@5.2.17
     - @aws-amplify/api-graphql@2.3.14
     - @aws-amplify/api-rest@2.0.50
     - @aws-amplify/api@4.0.50
     - @aws-amplify/auth@4.6.3
     - aws-amplify-angular@6.0.50
     - aws-amplify-react@5.1.33
     - aws-amplify@4.3.32
     - @aws-amplify/cache@4.0.52
     - @aws-amplify/core@4.7.1
     - @aws-amplify/datastore-storage-adapter@1.3.10
     - @aws-amplify/datastore@3.12.7
     - @aws-amplify/geo@1.3.13
     - @aws-amplify/interactions@4.0.50
     - @aws-amplify/predictions@4.0.50
     - @aws-amplify/pubsub@4.5.0
     - @aws-amplify/pushnotification@4.3.29
     - @aws-amplify/storage@4.5.3
     - @aws-amplify/xr@3.0.50

commit 543014d
Author: Katie Goines <katiegoi@amazon.com>
Date:   Thu Aug 18 16:08:51 2022 -0700

    chore: preparing release

commit d6cb7f9
Author: Aaron S <94858815+stocaaro@users.noreply.github.com>
Date:   Thu Aug 18 16:39:46 2022 -0500

    fix(pubsub): Connection Ack verification bug (#10200)

    * fex(pubsub): Add distinct RN Reachibility implementation

    * fix(PubSub): Monitor tests

    * fix(pubsub): Connection Ack verification bug

    * Fix the test

    * fix: Add tests to cover the fixed bug

    * Update packages/pubsub/src/Providers/AWSAppSyncRealTimeProvider/index.ts

    Co-authored-by: Francisco Rodriguez <elorzafe@amazon.com>

    * Update packages/pubsub/__tests__/AWSAppSyncRealTimeProvider.test.ts

    Co-authored-by: Francisco Rodriguez <elorzafe@amazon.com>

    * Test fix

    * Fix test

    Co-authored-by: Francisco Rodriguez <elorzafe@amazon.com>

commit f28918b
Author: Aaron S <94858815+stocaaro@users.noreply.github.com>
Date:   Wed Aug 17 15:55:05 2022 -0500

    feat: PubSub Connection state tracking for MQTT and IoT providers (#10136)

    * feat: PubSub Connection state tracking for MQTT and IoT providers

    * fix: Add disconnect message on connection lost

commit d4c3955
Author: Ashwin Kumar <ashwinkumar2468@gmail.com>
Date:   Wed Aug 17 10:25:13 2022 -0700

    fix(interactions): fix configure default provider (#10215)

    * fix(interactions): fix configure default provider

    * chore: pin @types/lodash version in aws-amplify-angular

    Co-authored-by: Sridhar <ashwsrir@bcd07413f71a.ant.amazon.com>

commit f54b645
Author: Aaron S <94858815+stocaaro@users.noreply.github.com>
Date:   Wed Aug 17 11:05:26 2022 -0500

    fix: An update to @types/lodash breaks the build - specify last working version to unblock (#10221)

commit 51a4598
Author: Ashwin Kumar <ashwinkumar2468@gmail.com>
Date:   Tue Aug 16 11:33:45 2022 -0700

    fix:(@aws-amplify/interactions): refactor-lex-v1 (#10155)

commit 0ce6b95
Author: aws-amplify-bot <aws@amazon.com>
Date:   Tue Aug 16 00:14:15 2022 +0000

    chore(release): update version.ts [ci skip]

commit d885ec2
Author: aws-amplify-bot <aws@amazon.com>
Date:   Tue Aug 16 00:11:38 2022 +0000

    chore(release): Publish [ci skip]

     - @aws-amplify/ui-angular@1.0.58
     - @aws-amplify/ui-components@1.9.29
     - @aws-amplify/ui-react@1.2.49
     - @aws-amplify/ui-storybook@2.0.49
     - @aws-amplify/ui-vue@1.1.43
     - @aws-amplify/analytics@5.2.16
     - @aws-amplify/api-graphql@2.3.13
     - @aws-amplify/api-rest@2.0.49
     - @aws-amplify/api@4.0.49
     - @aws-amplify/auth@4.6.2
     - aws-amplify-angular@6.0.49
     - aws-amplify-react@5.1.32
     - aws-amplify@4.3.31
     - @aws-amplify/cache@4.0.51
     - @aws-amplify/core@4.7.0
     - @aws-amplify/datastore-storage-adapter@1.3.9
     - @aws-amplify/datastore@3.12.6
     - @aws-amplify/geo@1.3.12
     - @aws-amplify/interactions@4.0.49
     - @aws-amplify/predictions@4.0.49
     - @aws-amplify/pubsub@4.4.10
     - @aws-amplify/pushnotification@4.3.28
     - @aws-amplify/storage@4.5.2
     - @aws-amplify/xr@3.0.49

commit 80cf2c8
Author: elorzafe <elorzafe@amazon.com>
Date:   Mon Aug 15 14:49:48 2022 -0700

    chore: preparing release

commit f6e61b8
Author: elorzafe <elorzafe@amazon.com>
Date:   Mon Aug 15 14:44:29 2022 -0700

    Revert "ci: automate GitHub releases with lerna (#10189)"

    This reverts commit f59fa9f.

commit 74383d7
Author: Francisco Rodriguez <frodriguez.cs@gmail.com>
Date:   Thu Aug 11 14:11:06 2022 -0700

    chore: ci: Disabling integ_rn_ios_datastore_sqlite_adapter test (#10193)

    * Disabling integ_rn_ios_datastore_sqlite_adapter test

    * Update config.yml

commit f59fa9f
Author: Ashwin Kumar <ashwinkumar2468@gmail.com>
Date:   Thu Aug 11 09:05:50 2022 -0700

    ci: automate GitHub releases with lerna (#10189)

    Co-authored-by: Sridhar <ashwsrir@bcd07413f71a.ant.amazon.com>
    Co-authored-by: Francisco Rodriguez <frodriguez.cs@gmail.com>

commit 92cef8a
Author: Ashika <35131273+ashika01@users.noreply.github.com>
Date:   Tue Aug 9 16:55:55 2022 -0700

    Fix: Analytics Type issue (#10185)

    * kinesis fix

commit 5f427f3
Author: Aaron S <94858815+stocaaro@users.noreply.github.com>
Date:   Tue Aug 9 17:45:34 2022 -0500

    fix(pubsub): Add distinct RN Reachibility implementation (#10175)

    * fix(pubsub): Add distinct RN Reachibility implementation

    * fix(PubSub): Fix monitor tests

commit 88f118e
Author: Ashika Kasiviswanathan Arumugakarthik <akasivis@amazon.com>
Date:   Tue Aug 9 15:04:13 2022 -0700

    Revert "kinesis fix"

    This reverts commit 763609b.

commit 4e0e22b
Author: Ashika Kasiviswanathan Arumugakarthik <akasivis@amazon.com>
Date:   Tue Aug 9 15:03:59 2022 -0700

    Revert "update personalize type to accomodate string"

    This reverts commit 9326beb.

commit 9326beb
Author: Ashika Kasiviswanathan Arumugakarthik <akasivis@amazon.com>
Date:   Tue Aug 9 14:39:19 2022 -0700

    update personalize type to accomodate string

commit 763609b
Author: Ashika Kasiviswanathan Arumugakarthik <akasivis@amazon.com>
Date:   Tue Aug 9 12:27:47 2022 -0700

    kinesis fix

commit 850788c
Author: Katie Goines <30757403+katiegoines@users.noreply.github.com>
Date:   Mon Aug 8 17:15:40 2022 -0700

    Updating config.yml to mitigate circle CI pipeline failures from outdated Xcode image (#10158)

    * updating config.yml for testing changes to staging

    * removing android integ tests for now

    * Update config.yml

    * removing code used for testing

    Co-authored-by: Francisco Rodriguez <frodriguez.cs@gmail.com>

commit 88a9ec9
Author: Ivan Artemiev <29709626+iartemiev@users.noreply.github.com>
Date:   Fri Aug 5 16:31:56 2022 -0400

    fix(datastore): make di context fields private (#10162)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants