Skip to content

Commit

Permalink
🔧 Use managed package namespace (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
shunkosa authored Sep 7, 2022
1 parent 84796e3 commit f8183d8
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"permissions": []
},
"version": "0.7.0",
"version": "0.8.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"splash": {
Expand Down
6 changes: 3 additions & 3 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export const BACKGROUND_IMAGE_STYLE: ImageStyle = {
top: Dimensions.get('window').height / 2 + height / 2,
};

export const SURVEY_OBJECT = 'GRMS_Survey__c';
export const FIELD_WORKER_CONTACT_FIELD_ON_SURVEY = 'GRMS_FieldWorker__c';
export const SURVEY_DATE_FIELD = 'GRMS_SurveyDate__c';
export const SURVEY_OBJECT = 'GRMS__Survey__c';
export const FIELD_WORKER_CONTACT_FIELD_ON_SURVEY = 'GRMS__FieldWorker__c';
export const SURVEY_DATE_FIELD = 'GRMS__SurveyDate__c';
export const RECORD_TYPE_ID_FIELD = 'RecordTypeId';
export const BACKGROUND_SURVEY_FIELDS = [
{ fieldName: 'Name', fieldType: 'string' },
Expand Down
16 changes: 8 additions & 8 deletions src/services/salesforce/contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { SQLiteContact, SQLiteFieldTypeMapping } from '../../types/sqlite';
*/
export const getCurrentFieldWorker = async () => {
const appUserEmail = await SecureStore.getItemAsync(SECURE_STORE_KEYS.EMAIL);
const query = `SELECT Id, Name FROM Contact WHERE GRMS_LoginEmail__c = '${appUserEmail}' AND GRMS_ContactType__c = 'Field Worker'`;
const query = `SELECT Id, Name FROM Contact WHERE GRMS__LoginEmail__c = '${appUserEmail}' AND GRMS__ContactType__c = 'Field Worker'`;
try {
const records = await fetchSalesforceRecords(query);
logger('DEBUG', 'getCurrentFieldWorker', records);
Expand All @@ -36,18 +36,18 @@ export const storeContacts = async () => {
const fieldWorkerContactId = await storage.load({
key: ASYNC_STORAGE_KEYS.FIELD_WORKER_CONTACT_ID,
});
const junctionQuery = `SELECT Id, GRMS_Client__c, GRMS_Client__r.Name, GRMS_Type__c
FROM GRMS_FieldWorkerClientRelation__c
WHERE GRMS_FieldWorker__c = '${fieldWorkerContactId}'`;
const junctionQuery = `SELECT Id, GRMS__Client__c, GRMS__Client__r.Name, GRMS__Type__c
FROM GRMS__FieldWorkerClientRelation__c
WHERE GRMS__FieldWorker__c = '${fieldWorkerContactId}'`;
try {
const junctionRecords = await fetchSalesforceRecords(junctionQuery);
const contactMap: Map<string, SQLiteContact> = new Map<string, SQLiteContact>(
junctionRecords.map(junctionRecord => [
junctionRecord.GRMS_Client__c,
junctionRecord.GRMS__Client__c,
{
id: junctionRecord.GRMS_Client__c,
name: junctionRecord.GRMS_Client__r.Name,
type: junctionRecord.GRMS_Type__c,
id: junctionRecord.GRMS__Client__c,
name: junctionRecord.GRMS__Client__r.Name,
type: junctionRecord.GRMS__Type__c,
},
])
);
Expand Down
10 changes: 5 additions & 5 deletions src/services/salesforce/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,17 @@ export const storePageLayoutSections = async (layout: DescribeLayout) => {
*/
export const storeLocalization = async () => {
const query =
'SELECT GRMS_Type__c, GRMS_Locale__c, GRMS_OriginalName__c, GRMS_TranslatedLabel__c FROM GRMS_Localization__mdt';
'SELECT GRMS__Type__c, GRMS__Locale__c, GRMS__OriginalName__c, GRMS__TranslatedLabel__c FROM GRMS__Localization__mdt';
const records: Array<LocalizationCustomMetadata> = await fetchSalesforceRecords(query);
if (records.length === 0) {
return;
}
const localizations: Array<SQLiteLocalization> = records.map(r => {
return {
locale: r.GRMS_Locale__c,
type: r.GRMS_Type__c,
name: r.GRMS_OriginalName__c,
label: r.GRMS_TranslatedLabel__c ? r.GRMS_TranslatedLabel__c.replace(/'/g, "''") : '', // escape single quote for sqlite
locale: r.GRMS__Locale__c,
type: r.GRMS__Type__c,
name: r.GRMS__OriginalName__c,
label: r.GRMS__TranslatedLabel__c ? r.GRMS__TranslatedLabel__c.replace(/'/g, "''") : '', // escape single quote for sqlite
};
});
await saveRecords(DB_TABLE.LOCALIZATION, localizations, undefined);
Expand Down
8 changes: 4 additions & 4 deletions src/types/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ export interface DescribePicklistValue {
export interface LocalizationCustomMetadata {
MasterLabel: string;
DeveloperName: string;
GRMS_Locale__c: string;
GRMS_OriginalName__c: string;
GRMS_TranslatedLabel__c: string;
GRMS_Type__c: string;
GRMS__Locale__c: string;
GRMS__OriginalName__c: string;
GRMS__TranslatedLabel__c: string;
GRMS__Type__c: string;
}

export interface CompositeLayoutResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"imageItems" : null,
"label" : "Flower",
"name" : "Flower",
"objectType" : "GRMS_Survey__c"
"objectType" : "GRMS__Survey__c"
},
"httpHeaders" : {
"ETag" : "\"10e6f249\"",
Expand Down Expand Up @@ -165,7 +165,7 @@
"imageItems" : null,
"label" : "Restaurant",
"name" : "Restaurant",
"objectType" : "GRMS_Survey__c"
"objectType" : "GRMS__Survey__c"
},
"httpHeaders" : {
"ETag" : "\"10e6f249\"",
Expand Down Expand Up @@ -252,7 +252,7 @@
"imageItems" : null,
"label" : "System Default",
"name" : "SYSTEM",
"objectType" : "GRMS_Survey__c"
"objectType" : "GRMS__Survey__c"
},
"httpHeaders" : {
"ETag" : "\"10e6f249\"",
Expand Down
10 changes: 5 additions & 5 deletions tests/services/mock/mockDescribeLayoutSingle.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"length": 0,
"mask": null,
"maskType": null,
"name": "GRMS_SurveyDate__c",
"name": "GRMS__SurveyDate__c",
"nameField": false,
"namePointing": false,
"nillable": true,
Expand All @@ -150,7 +150,7 @@
"displayLines": 1,
"tabOrder": 6,
"type": "Field",
"value": "GRMS_SurveyDate__c"
"value": "GRMS__SurveyDate__c"
}
],
"placeholder": false,
Expand Down Expand Up @@ -202,7 +202,7 @@
"length": 18,
"mask": null,
"maskType": null,
"name": "GRMS_FieldWorker__c",
"name": "GRMS__FieldWorker__c",
"nameField": false,
"namePointing": false,
"nillable": true,
Expand All @@ -213,7 +213,7 @@
"queryByDistance": false,
"referenceTargetField": null,
"referenceTo": ["Contact"],
"relationshipName": "GRMS_FieldWorker__r",
"relationshipName": "GRMS__FieldWorker__r",
"relationshipOrder": null,
"restrictedDelete": false,
"restrictedPicklist": false,
Expand All @@ -229,7 +229,7 @@
"displayLines": 1,
"tabOrder": 5,
"type": "Field",
"value": "GRMS_FieldWorker__c"
"value": "GRMS__FieldWorker__c"
}
],
"placeholder": false,
Expand Down
6 changes: 3 additions & 3 deletions tests/services/mock/mockDescribeLayoutsResponseMultiple.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"picklistsForRecordType" : [ ],
"recordTypeId" : "0125h000000kN4aAAE",
"urls" : {
"layout" : "/services/data/v51.0/sobjects/GRMS_Survey__c/describe/layouts/0125h000000kN4aAAE"
"layout" : "/services/data/v51.0/sobjects/GRMS__Survey__c/describe/layouts/0125h000000kN4aAAE"
}
}, {
"active" : true,
Expand All @@ -24,7 +24,7 @@
"picklistsForRecordType" : [ ],
"recordTypeId" : "0125h000000kNJMAA2",
"urls" : {
"layout" : "/services/data/v51.0/sobjects/GRMS_Survey__c/describe/layouts/0125h000000kNJMAA2"
"layout" : "/services/data/v51.0/sobjects/GRMS__Survey__c/describe/layouts/0125h000000kNJMAA2"
}
}, {
"active" : true,
Expand All @@ -37,7 +37,7 @@
"picklistsForRecordType" : [ ],
"recordTypeId" : "012000000000000AAA",
"urls" : {
"layout" : "/services/data/v51.0/sobjects/GRMS_Survey__c/describe/layouts/012000000000000AAA"
"layout" : "/services/data/v51.0/sobjects/GRMS__Survey__c/describe/layouts/012000000000000AAA"
}
} ],
"recordTypeSelectorRequired" : [ true ]
Expand Down
24 changes: 12 additions & 12 deletions tests/services/salesforce.contact.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,53 +101,53 @@ const mockFetchedMultipleContacts = [
mockFetchedJunctionRecords = [
{
Id: 'a015h0000086YjEAAU',
GRMS_Client__c: '0035h000001jAKPAA2',
GRMS_Client__r: {
GRMS__Client__c: '0035h000001jAKPAA2',
GRMS__Client__r: {
attributes: {
type: 'Contact',
url: '/services/data/v50.0/sobjects/Contact/0035h000001jAKPAA2',
},
Name: 'Mary Jones',
},
GRMS_Type__c: null,
GRMS__Type__c: null,
},
{
Id: 'a015h0000086Yj9AAE',
GRMS_Client__c: '0035h000001jAKPAA3',
GRMS_Client__r: {
GRMS__Client__c: '0035h000001jAKPAA3',
GRMS__Client__r: {
attributes: {
type: 'Contact',
url: '/services/data/v50.0/sobjects/Contact/0035h000001jAKPAA3',
},
Name: 'Kary Grant',
},
GRMS_Type__c: null,
GRMS__Type__c: null,
},
];

mockFetchedDuplicatedJunctionRecords = [
{
Id: 'a015h0000086YjEAAU',
GRMS_Client__c: '0035h000001jAKPAA2',
GRMS_Client__r: {
GRMS__Client__c: '0035h000001jAKPAA2',
GRMS__Client__r: {
attributes: {
type: 'Contact',
url: '/services/data/v50.0/sobjects/Contact/0035h000001jAKPAA2',
},
Name: 'Mary Jones',
},
GRMS_Type__c: null,
GRMS__Type__c: null,
},
{
Id: 'a015h0000086Yj9AAE',
GRMS_Client__c: '0035h000001jAKPAA2',
GRMS_Client__r: {
GRMS__Client__c: '0035h000001jAKPAA2',
GRMS__Client__r: {
attributes: {
type: 'Contact',
url: '/services/data/v50.0/sobjects/Contact/0035h000001jAKPAA2',
},
Name: 'Mary Jones',
},
GRMS_Type__c: null,
GRMS__Type__c: null,
},
];

0 comments on commit f8183d8

Please sign in to comment.