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

Merge main into open-source main #5

Merged
merged 48 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
73163ce
chore: add hot-reload
hopetambala Jul 17, 2022
fe47602
chore: add messaging api
hopetambala Jul 17, 2022
5fad326
chore: add path
hopetambala Jul 18, 2022
af6262e
test: add auth
hopetambala Jul 18, 2022
0603393
feat: add text messaging
hopetambala Jul 19, 2022
20ccf51
chore: add messaging
hopetambala Jul 21, 2022
3fce700
lint
hopetambala Jul 21, 2022
cbb1122
Merge pull request #497 from hopetambala/PLATFORM-583_2
hopetambala Jul 21, 2022
4c51560
feat: add update user and retrieveUserByObjectId
hopetambala Jul 26, 2022
774c40b
chore: fix linting
hopetambala Sep 4, 2022
0184cc2
test: add updateUser test
hopetambala Sep 4, 2022
93441f4
lint: auth test
hopetambala Sep 4, 2022
f61e231
Merge pull request #498 from hopetambala/PLATFORM-580
hopetambala Sep 4, 2022
ef120e6
chore: move queryUser to node cloudcode
hopetambala Sep 4, 2022
c376181
Merge pull request #499 from hopetambala/PLATFORM-580_v2
hopetambala Sep 4, 2022
2843ccf
chore: linting
hopetambala Sep 4, 2022
b687e22
Merge branch 'master' into PLATFORM-580_v2
hopetambala Sep 4, 2022
e7bbe51
Merge pull request #500 from hopetambala/PLATFORM-580_v2
hopetambala Sep 4, 2022
02bf237
chore: change signup text
hopetambala Sep 4, 2022
3c4772b
Merge branch 'PLATFORM-580_v2' of https://github.com/hopetambala/puen…
hopetambala Sep 4, 2022
9cdf46f
Merge branch 'master' into PLATFORM-580_v2
hopetambala Sep 4, 2022
e5fc96b
feat: add send message api
hopetambala Sep 5, 2022
54ea4b4
chore: add nvm
hopetambala Oct 1, 2022
1374ef8
feat: OFFLINE UPLOADER :tada:
hopetambala Oct 6, 2022
9e5c7cb
chore: figure this out later
hopetambala Oct 6, 2022
d260799
fix: add afterSurveyHouseholdHook
hopetambala Oct 6, 2022
cd5bdb8
lint: update afterSurveyHouseholdHook
hopetambala Oct 6, 2022
108de90
chore: update nvm
hopetambala Oct 6, 2022
c87df11
chore: remove householdrelations
hopetambala Oct 8, 2022
68aebba
chore(release): 1.9.0
hopetambala Oct 10, 2022
79724f8
Merge pull request #509 from hopetambala/PLATFORM-586
hopetambala Oct 11, 2022
33db521
fix: offline post survey hook
hopetambala Nov 4, 2022
47db31d
fix: return statement if no data
hopetambala Nov 8, 2022
7cd293d
lint: fix
hopetambala Nov 8, 2022
80cd351
Merge pull request #513 from hopetambala/PLATFORM-OFFLINE
hopetambala Dec 10, 2022
3ae0126
chore: add logger
hopetambala Dec 10, 2022
dd7826b
chore: lint
hopetambala Dec 11, 2022
b5a9af4
feat: add slackbot to posting
hopetambala Dec 13, 2022
64d9b63
Delete .env.staging
hopetambala Dec 13, 2022
890878a
chore(release): 1.10.0
hopetambala Dec 13, 2022
c5f886d
chore: add logging errors for auth
hopetambala Dec 13, 2022
2658633
chore(release): 1.10.1
hopetambala Dec 13, 2022
2389e81
chore: add slack api via wonky nested package
hopetambala Dec 14, 2022
bc43e08
chore: fix env
hopetambala Dec 14, 2022
dd3b8e5
chore(release): 1.10.2
hopetambala Dec 14, 2022
e8314c3
chore: fix env
hopetambala Dec 14, 2022
25065ad
lint: nested package.json
hopetambala Dec 14, 2022
96f58f5
Merge pull request #526 from hopetambala/PLATFORM-602
hopetambala Dec 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .env.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
PARSE_SERVER_ALLOW_ORIGIN="*"
PARSE_ENV=dev
PARSE_APP_ID="myAppId"
PARSE_JAVASCRIPT_KEY=_PLACEHOLDER_
PARSE_SERVER_URL="http://localhost:1337/parse"
PARSE_SERVER_URL="http://localhost:1337/parse"
PUENTE_SMS_EMAIL_API_URL=http://puentes-messaging-microservice.com
PUENTE_MANAGE_URL=https://sample-puente-manage.app/"

SLACK_TOKEN=""
SLACK_DEV_CHANNEL=""
SLACK_PROD_CHANNEL=""
4 changes: 0 additions & 4 deletions .env.staging

This file was deleted.

59 changes: 32 additions & 27 deletions .github/workflows/jest.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,53 @@
name: Jest Tests

env:
PARSE_ENV : "dev"
PARSE_APP_ID : "myAppId"
PARSE_JAVASCRIPT_KEY : "_PLACEHOLDER_"
PARSE_SERVER_URL : "http://localhost:1337/parse"
PARSE_ENV: "dev"
PARSE_APP_ID: "myAppId"
PARSE_JAVASCRIPT_KEY: "_PLACEHOLDER_"
PARSE_SERVER_URL: "http://localhost:1337/parse"
PUENTE_ENV: "dev"
PUENTE_SMS_EMAIL_API_URL: "http://puentes-messaging-microservice.com"
PUENTE_MANAGE_URL: "https://sample-puente-manage.app/"
SLACK_TOKEN: ""
SLACK_DEV_CHANNEL: ""
SLACK_PROD_CHANNEL: ""

on:
push:
branches:
branches:
- master
- dev
pull_request:
branches:
- master
- dev
branches:
- master
- dev
jobs:
jest-testing:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x,14.x]
node-version: [14.x, 16.x]
services:
mongodb:
image: mongo:4.4
ports:
- 27017:27017
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Puente CloudCode Dependencies
run: |
npm install
- name: Lint
run: |
npm run lint
- name: Start App and Test Jest
run: |
npm run start &
sleep 40 &&
npm run test-github-actions
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Puente CloudCode Dependencies
run: |
npm install
- name: Lint
run: |
npm run lint
- name: Start App and Test Jest
run: |
npm run start &
sleep 40 &&
npm run test-github-actions
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ logs
*.DS_Store
/coverage
.parse.local
.env.staging
.env.prod

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v14.20.1
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,57 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [1.10.2](https://github.com/hopetambala/puente-node-cloudcode/compare/v1.10.1...v1.10.2) (2022-12-14)

### [1.10.1](https://github.com/hopetambala/puente-node-cloudcode/compare/v1.10.0...v1.10.1) (2022-12-13)

## [1.10.0](https://github.com/hopetambala/puente-node-cloudcode/compare/v1.9.0...v1.10.0) (2022-12-13)


### Features

* add slackbot to posting ([b5a9af4](https://github.com/hopetambala/puente-node-cloudcode/commit/b5a9af4ea4843e7339532dfb4ed896abb71804be))


### Bug Fixes

* offline post survey hook ([33db521](https://github.com/hopetambala/puente-node-cloudcode/commit/33db521fa976f1f0f8fe322f8c4449d9a1ab25be))
* return statement if no data ([47db31d](https://github.com/hopetambala/puente-node-cloudcode/commit/47db31db0f0975c8c2b2c683fd3388d05337aa74))

## [1.9.0](https://github.com/hopetambala/puente-node-cloudcode/compare/v1.5.0...v1.9.0) (2022-10-10)


### Features

* add deep linking betweent user and survey ([4b78dc5](https://github.com/hopetambala/puente-node-cloudcode/commit/4b78dc5213ffae6d65f751c47054153488cf63df))
* add deleteUser function ([a63bf26](https://github.com/hopetambala/puente-node-cloudcode/commit/a63bf26b32b3986e1c3844324001bf49c7cfe9b7))
* add send message api ([e5fc96b](https://github.com/hopetambala/puente-node-cloudcode/commit/e5fc96bdc3a447a66202a4a1347a370aff5a05de))
* add text messaging ([0603393](https://github.com/hopetambala/puente-node-cloudcode/commit/06033934b9e8ceb9a0f8ada266970062927ef357))
* add update user and retrieveUserByObjectId ([4c51560](https://github.com/hopetambala/puente-node-cloudcode/commit/4c51560a442e1e5acbccbe0999c56b9547150ee6))
* added expoPushToken function to udpate user ([87b2f1b](https://github.com/hopetambala/puente-node-cloudcode/commit/87b2f1b2a0415b5872ee541d7b23ae6273458a11))
* count service to get unqiue surrveydata created ([89337d0](https://github.com/hopetambala/puente-node-cloudcode/commit/89337d0bfa0b65c7b138afce978143ef0069a713))
* handle looped form submission ([80d5741](https://github.com/hopetambala/puente-node-cloudcode/commit/80d5741e8b2982138ee4b877466e030822598cd7))
* offline moved to node cloud ([30944b3](https://github.com/hopetambala/puente-node-cloudcode/commit/30944b3ca3536ef04763f77f6514d76eaba1ac20))
* OFFLINE UPLOADER :tada: ([1374ef8](https://github.com/hopetambala/puente-node-cloudcode/commit/1374ef83fb9a5419ed8546960f7dbe44b7c52343))
* pictures on any forms work ([79d0a3d](https://github.com/hopetambala/puente-node-cloudcode/commit/79d0a3d0dc9a0954e68549523c5806dd6a1ce37d))
* refactor loop portion of crud to utils ([799837b](https://github.com/hopetambala/puente-node-cloudcode/commit/799837b1cf1354f394ee643e3c36d3dbb9016335))
* update all dependencies! ([eab407c](https://github.com/hopetambala/puente-node-cloudcode/commit/eab407c0a9332736d906c3ecbf1bc99be119897e))
* updated count service to include other parse models ([d5a393a](https://github.com/hopetambala/puente-node-cloudcode/commit/d5a393acd84708fc8559e5d91ecd2001d4441214))


### Bug Fixes

* tests PLATFORM-332 ([a494930](https://github.com/hopetambala/puente-node-cloudcode/commit/a4949300a30c3aa264043acfa2b033e828762a97))
* add afterSurveyHouseholdHook ([d260799](https://github.com/hopetambala/puente-node-cloudcode/commit/d26079979e814d051d164597cbb2d5bf4776f0f2))
* checking if key is a photo ([6fdd4fd](https://github.com/hopetambala/puente-node-cloudcode/commit/6fdd4fdada93163489e16ad111f054fe62346f0e))
* **deps:** update dependency lodash to v4.17.21 [security] ([ea8908a](https://github.com/hopetambala/puente-node-cloudcode/commit/ea8908a6b8349b16ee55f7275d6f27bf94648881))
* lodash require ([0187a33](https://github.com/hopetambala/puente-node-cloudcode/commit/0187a337d815eb5d3af87228475089f4485fdbb2))
* package.json & package-lock.json to reduce vulnerabilities ([7f43954](https://github.com/hopetambala/puente-node-cloudcode/commit/7f4395439f3cb7b61ed005aa476817ba814dea42))
* reason why tests were always failing ([c820b93](https://github.com/hopetambala/puente-node-cloudcode/commit/c820b936dc00e4e6d17bcffd9c75f18a243ce7a3))
* remove all .includes from codebase ([467caca](https://github.com/hopetambala/puente-node-cloudcode/commit/467cacaeea27dcf64f5dcfbb4b36d11046adf3e2))
* sort basic query results ([c20a12a](https://github.com/hopetambala/puente-node-cloudcode/commit/c20a12a37debffa8edbf585b982a9e0ba8dc53be))
* testing ([2fdb6cd](https://github.com/hopetambala/puente-node-cloudcode/commit/2fdb6cd2663725b0a938573dee968fee8eae5641))

## [1.8.0](https://github.com/hopetambala/puente-node-cloudcode/compare/v1.5.0...v1.8.0) (2021-12-18)


Expand Down
35 changes: 35 additions & 0 deletions _tests_/integration/auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ describe('role testing', () => {
let db;
let adminRoleID;
let contribRoleID;
let rollingUserObject;

beforeAll(async () => {
connection = await MongoClient.connect(process.env.MONGO_URL, {
Expand All @@ -22,6 +23,9 @@ describe('role testing', () => {
password: 'dracarys',
email: '[email protected]',
organization: 'got',
restParams: {
runMessaging: false,
},
};
return cloudFunctions.signup(credentials).then((result) => {
const jsonString = JSON.stringify(result);
Expand Down Expand Up @@ -59,6 +63,10 @@ describe('role testing', () => {
email: '[email protected]',
organization: 'got',
phonenumber: 1234567890,
restParams: {
runMessaging: false,
path: 'email',
},
};
return cloudFunctions.signup(credentials).then((result) => {
const jsonString = JSON.stringify(result);
Expand Down Expand Up @@ -106,6 +114,7 @@ describe('role testing', () => {
return cloudFunctions.signin(credentials).then((result) => {
const jsonString = JSON.stringify(result);
const jsonValues = JSON.parse(jsonString);
rollingUserObject = jsonValues;

expect(jsonValues.firstname).toEqual('Jon');
expect(jsonValues.lastname).toEqual('Snow');
Expand All @@ -118,6 +127,32 @@ describe('role testing', () => {
});
});

it('should update the user', async () => {
const originalUserObject = rollingUserObject;

const params = {
objectId: originalUserObject.objectId,
userObject: {
firstname: 'Ron',
lastname: 'Flow',
},
};

return cloudFunctions.updateUser(params).then((result) => {
const jsonString = JSON.stringify(result);
const jsonValues = JSON.parse(jsonString);

expect(jsonValues.firstname).toEqual('Ron');
expect(jsonValues.lastname).toEqual('Flow');
expect(jsonValues.username).toEqual('1234567890');
expect(jsonValues.email).toEqual('[email protected]');
expect(jsonValues.organization).toEqual('got');
expect(jsonValues.role).toEqual('contributor');
expect(jsonValues.adminVerified).toEqual(false);
expect(jsonValues.objectId).toEqual(contribRoleID);
});
});

it('should delete all users', async () => {
const removeParams = [
{
Expand Down
27 changes: 26 additions & 1 deletion _tests_/integration/crud.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,32 @@ describe('crud testing', () => {
});
});

it('should post an object to class with relation to original post with a variety of classes', async () => {
it('should post object to Supplementary Class with Relation to SurveyData', async () => {
const postParams = {
parseParentClass: 'SurveyData',
parseParentClassID: postID1,
parseClass: 'Vitals',
signature: 'Test',
photoFile: 'TestPicture',
parseUser: 'undefined',
localObject: {
height: '6',
weight: '2',
bmi: '30',
bloodPressure: '100/100',
latitude: 4,
longitude: 5,
surveyingOrganization: 'Puente',
},
};
return cloudFunctions.postObjectsToClassWithRelation(postParams).then((result) => {
expect(result.get('height')).toEqual('6');
expect(result.get('weight')).toEqual('2');
expect(result.get('bloodPressure')).toEqual('100/100');
});
});

it('should post an obj to class with relation to post with variety of classes', async () => {
const postParams = {
parseParentClass: 'SurveyData',
parseParentClassID: postID1,
Expand Down
29 changes: 29 additions & 0 deletions _tests_/integration/error.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { MongoClient } = require('mongodb');
const { cloudFunctions } = require('../run-cloud');

describe('crud testing', () => {
let connection;
let db;

beforeAll(async () => {
connection = await MongoClient.connect(process.env.MONGO_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
db = await connection.db();
});

afterAll(async () => {
await connection.close();
await db.close();
});

it('Test error response in SurveyData post when empy params', async () => {
const postParams = {
};
return cloudFunctions.postObjectsToClass(postParams).then((result) => {
const err = 'Error: no request params';
expect(result).toEqual(err);
});
});
});
8 changes: 8 additions & 0 deletions _tests_/integration/roles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ describe('role testing', () => {
password: 'leia',
email: '[email protected]',
organization: 'star-wars',
restParams: {
runMessaging: false,
path: 'email',
},
};
return cloudFunctions.signup(credentials).then((result) => {
const jsonString = JSON.stringify(result);
Expand All @@ -94,6 +98,10 @@ describe('role testing', () => {
email: '[email protected]',
organization: 'star-wars',
phonenumber: '1234567373',
restParams: {
runMessaging: false,
path: 'email',
},
};
return cloudFunctions.signup(credentials).then((result) => {
const jsonString = JSON.stringify(result);
Expand Down
3 changes: 3 additions & 0 deletions _tests_/run-cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ const cloudFunctions = {
addUserPushToken: (params) => Parse.Cloud
.run('addUserPushToken', params)
.then((response) => response),
updateUser: (params) => Parse.Cloud
.run('updateUser', params)
.then((response) => response),
};

module.exports = { cloudFunctions };
5 changes: 5 additions & 0 deletions cloud/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ require('./src/definer/verification.definer');
* Roles Creator and Manager
******************************************** */
require('./src/definer/roles.definer');

/** ********************************************
* Offline Uploader and Manager
******************************************** */
require('./src/definer/offline.definer');
7 changes: 7 additions & 0 deletions cloud/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"@slack/web-api": "^6.8.0",
"axios": "^0.27.2",
"lodash": "^4.17.19"
}
}
14 changes: 7 additions & 7 deletions cloud/src/_utils/loop/loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Loop = {
];
},

postLoopedForm: function postLoopedForm(loopedJson, newFieldsArray, request, mainObject) {
postLoopedForm: function postLoopedForm(loopedJson, newFieldsArray, requestParams, mainObject) {
return new Promise((resolve, reject) => {
Object.entries(loopedJson).forEach(([key, value]) => { // eslint-disable-line
// get looped data and adjust the fields Array for each loopp
Expand All @@ -34,14 +34,14 @@ const Loop = {
element.answer = value[element.title]; // eslint-disable-line
}
});
const newLocalObject = request.params.localObject;
const newLocalObject = requestParams.localObject;
newLocalObject.fields = newFieldsArray;
const postParams = {
parseParentClassID: request.params.parseParentClassID,
parseParentClass: request.params.parseParentClass,
parseUser: request.params.parseUser,
parseClass: request.params.parseClass,
photoFile: request.params.photoFile,
parseParentClassID: requestParams.parseParentClassID,
parseParentClass: requestParams.parseParentClass,
parseUser: requestParams.parseUser,
parseClass: requestParams.parseClass,
photoFile: requestParams.photoFile,
localObject: newLocalObject,
loop: false,
loopParentID: JSON.parse(JSON.stringify(mainObject)).objectId,
Expand Down
Loading
Loading