Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amplify-frontend-android

Package Overview
Dependencies
Maintainers
5
Versions
578
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amplify-frontend-android - npm Package Compare versions

Comparing version 3.4.1 to 3.5.0-beta.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [3.5.0-beta.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-frontend-android@3.4.1...amplify-frontend-android@3.5.0-beta.0) (2023-02-07)
### Features
* generate analytics/notifications customer config sections ([df75892](https://github.com/aws-amplify/amplify-cli/commit/df75892ccbead85cf56bb1e5efd3cdf6c52df0db))
## [3.4.1](https://github.com/aws-amplify/amplify-cli/compare/amplify-frontend-android@3.4.0...amplify-frontend-android@3.4.1) (2023-02-02)

@@ -8,0 +19,0 @@

2

index.js

@@ -33,3 +33,3 @@ const path = require('path');

* @param {metaWithOutput} amplifyResources
* @param {cloudMetaWithOuput} amplifyCloudResources
* @param {cloudMetaWithOutput} amplifyCloudResources
* @param {string} exportPath path to where the files need to be written

@@ -36,0 +36,0 @@ */

@@ -8,2 +8,3 @@ function generateConfig(context, newAWSConfig) {

constructAnalytics(metadata, amplifyConfig);
constructNotifications(metadata, amplifyConfig);
constructApi(metadata, amplifyConfig);

@@ -29,2 +30,39 @@ // Auth plugin with entire awsconfiguration contained required for Native GA release

/**
* update amplifyConfiguration notifications channel sections with pinpoint appId
* and region if present and enabled in amplify-meta.json notification output section
* @param {*} metadata - contents of amplify-meta.json
* @param {*} amplifyConfiguration - contents of amplifyconfiguration.json
*/
function constructNotifications(metadata, amplifyConfiguration) {
// ignore APNS channel as it not supported for iOS frontend
const notificationChannelsMap = {
'SMS': 'awsPinpointSmsNotificationsPlugin',
'EMAIL': 'awsPinpointEmailNotificationsPlugin',
'FCM': 'awsPinpointPushNotificationsPlugin',
'InAppMessaging': 'awsPinpointInAppMessagingNotificationsPlugin',
}
const categoryName = 'notifications';
if (metadata[categoryName] && Object.keys(metadata[categoryName]).length > 0) {
const r = Object.keys(metadata[categoryName])[0]; // only one resource in analytics
const resourceMeta = metadata[categoryName][r];
if (resourceMeta.output) {
for (const [channel, plugin] of Object.entries(notificationChannelsMap)) {
const channelOutput = resourceMeta.output[channel];
if (channelOutput && channelOutput.Enabled) {
amplifyConfiguration[categoryName] = amplifyConfiguration[categoryName] ?? {};
amplifyConfiguration[categoryName].plugins = amplifyConfiguration[categoryName].plugins ?? {};
amplifyConfiguration[categoryName].plugins[plugin] = {};
amplifyConfiguration[categoryName].plugins[plugin] = {
appId: channelOutput.ApplicationId,
region: resourceMeta.output.Region,
};
}
}
}
}
}
function constructAnalytics(metadata, amplifyConfig) {

@@ -218,3 +256,3 @@ const categoryName = 'analytics';

}
if(resourceMeta.isDefault === true) {
if (resourceMeta.isDefault === true) {
defaultMap = mapName;

@@ -227,3 +265,3 @@ }

placeIndexConfig.items.push(placeIndexName);
if(resourceMeta.isDefault === true) {
if (resourceMeta.isDefault === true) {
defaultPlaceIndex = placeIndexName;

@@ -254,2 +292,3 @@ }

generateConfig,
constructNotifications,
};

@@ -94,4 +94,3 @@ const constants = require('./constants');

const newAWSConfig = getNewAWSConfigObject(context, amplifyResources, cloudAmplifyResources);
const amplifyConfig = amplifyConfigHelper.generateConfig(context, newAWSConfig);
return amplifyConfig;
return amplifyConfigHelper.generateConfig(context, newAWSConfig);
}

@@ -98,0 +97,0 @@

{
"name": "amplify-frontend-android",
"version": "3.4.1",
"version": "3.5.0-beta.0",
"description": "amplify-cli front-end plugin for Android project",

@@ -18,2 +18,6 @@ "repository": {

],
"scripts": {
"test": "jest --logHeapUsage",
"test-watch": "yarn test --watch"
},
"dependencies": {

@@ -24,3 +28,3 @@ "fs-extra": "^8.1.0",

},
"gitHead": "5370e8badb701f018ddc7459b3bf0ee7c80a7444"
"gitHead": "e6d05226913d2126030ffefe10d75252e5280cff"
}

@@ -8,81 +8,122 @@ const configHelper = require('../../amplify-frontend-android/lib/amplify-config-helper');

describe('generate maps and search configuration', () => {
const mockAmplifyMeta = {
providers: {
awscloudformation: {
Region: 'us-west-2'
}
},
geo: {
map12345: constructMapMeta('map12345', 'VectorEsriStreets', false),
index12345: constructPlaceIndexMeta('index12345', false),
defaultMap12345: constructMapMeta('defaultMap12345', 'VectorEsriStreets', true),
defaultIndex12345: constructPlaceIndexMeta('defaultIndex12345', true)
}
const mockAmplifyMeta = {
providers: {
awscloudformation: {
Region: 'us-west-2'
}
},
geo: {
map12345: constructMapMeta('map12345', 'VectorEsriStreets', false),
index12345: constructPlaceIndexMeta('index12345', false),
defaultMap12345: constructMapMeta('defaultMap12345', 'VectorEsriStreets', true),
defaultIndex12345: constructPlaceIndexMeta('defaultIndex12345', true)
}
};
function constructMapMeta(mapName, mapStyle, isDefault, region) {
return {
service: mapServiceName,
output: {
Style: mapStyle,
Name: mapName,
Region: region
},
isDefault: isDefault
};
}
function constructMapMeta(mapName, mapStyle, isDefault, region) {
return {
service: mapServiceName,
output: {
Style: mapStyle,
Name: mapName,
Region: region
},
isDefault: isDefault
};
}
function constructPlaceIndexMeta(indexName, isDefault, region) {
return {
service: placeIndexServiceName,
output: {
Name: indexName,
Region: region
},
isDefault: isDefault
};
}
let mockContext = {}
beforeEach(() => {
jest.clearAllMocks();
mockContext = {
amplify: {
getProjectMeta: jest.fn()
}
};
mockContext.amplify.getProjectMeta = jest.fn().mockReturnValue(mockAmplifyMeta);
});
function constructPlaceIndexMeta(indexName, isDefault, region) {
return {
service: placeIndexServiceName,
output: {
Name: indexName,
Region: region
},
isDefault: isDefault
};
}
let mockContext = {}
beforeEach(() => {
jest.clearAllMocks();
mockContext = {
amplify: {
getProjectMeta: jest.fn()
}
};
mockContext.amplify.getProjectMeta = jest.fn().mockReturnValue(mockAmplifyMeta);
});
it('generates correct configuration for maps and search geo resources without Region CFN output', () => {
const generatedConfig = configHelper.generateConfig(mockContext, {});
expect(generatedConfig).toMatchSnapshot();
});
it('generates correct configuration for maps and search geo resources without Region CFN output', () => {
const generatedConfig = configHelper.generateConfig(mockContext, {});
expect(generatedConfig).toMatchSnapshot();
});
it('does not add any geo configuration if no maps or search is added', () => {
mockAmplifyMeta.geo = {};
mockContext.amplify.getProjectMeta = jest.fn().mockReturnValue(mockAmplifyMeta);
const generatedConfig = configHelper.generateConfig(mockContext, {});
expect(generatedConfig).toMatchSnapshot();
});
it('does not add any geo configuration if no maps or search is added', () => {
mockAmplifyMeta.geo = {};
mockContext.amplify.getProjectMeta = jest.fn().mockReturnValue(mockAmplifyMeta);
const generatedConfig = configHelper.generateConfig(mockContext, {});
expect(generatedConfig).toMatchSnapshot();
it('generates correct configuration for maps and search geo resources with Region as CFN output', () => {
const resourceRegion = 'eu-west-1';
const projectRegion = 'eu-west-2';
mockContext.amplify.getProjectMeta = jest.fn().mockReturnValue({
providers: {
awscloudformation: {
Region: projectRegion
}
},
geo: {
map12345: constructMapMeta('map12345', 'VectorEsriStreets', false, resourceRegion),
index12345: constructPlaceIndexMeta('index12345', false, resourceRegion),
defaultMap12345: constructMapMeta('defaultMap12345', 'VectorEsriStreets', true, resourceRegion),
defaultIndex12345: constructPlaceIndexMeta('defaultIndex12345', true, resourceRegion)
}
});
const generatedConfig = configHelper.generateConfig(mockContext, {});
expect(generatedConfig.geo.plugins.awsLocationGeoPlugin.region).toEqual(resourceRegion);
expect(generatedConfig).toMatchSnapshot();
});
});
it('generates correct configuration for maps and search geo resources with Region as CFN output', () => {
const resourceRegion = 'eu-west-1';
const projectRegion = 'eu-west-2';
mockContext.amplify.getProjectMeta = jest.fn().mockReturnValue({
providers: {
awscloudformation: {
Region: projectRegion
}
describe('customer pinpoint configuration', () => {
it('generates correct notifications channel pinpoint configuration', () => {
const amplifyMeta = {
'notifications': {
'amplifyplayground': {
'service': 'Pinpoint',
'output': {
'Region': 'us-east-1',
'InAppMessaging': {
'Enabled': true,
'ApplicationId': 'fake'
},
geo: {
map12345: constructMapMeta('map12345', 'VectorEsriStreets', false, resourceRegion),
index12345: constructPlaceIndexMeta('index12345', false, resourceRegion),
defaultMap12345: constructMapMeta('defaultMap12345', 'VectorEsriStreets', true, resourceRegion),
defaultIndex12345: constructPlaceIndexMeta('defaultIndex12345', true, resourceRegion)
'SMS': {
'ApplicationId': 'fake',
'Enabled': true,
}
});
const generatedConfig = configHelper.generateConfig(mockContext, {});
expect(generatedConfig.geo.plugins.awsLocationGeoPlugin.region).toEqual(resourceRegion);
expect(generatedConfig).toMatchSnapshot();
});
},
}
}
};
const amplifyConfiguration = {};
configHelper.constructNotifications(amplifyMeta, amplifyConfiguration);
const expectedAmplifyConfiguration = {
notifications: {
plugins: {
awsPinpointSmsNotificationsPlugin: {
appId: 'fake',
region: 'us-east-1'
},
awsPinpointInAppMessagingNotificationsPlugin: {
appId: 'fake',
region: 'us-east-1'
}
}
}
}
expect(amplifyConfiguration).toMatchObject(expectedAmplifyConfiguration)
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc