From 7f282789d89c897a1966038e500a21703cc0691f Mon Sep 17 00:00:00 2001 From: Volker Andres Date: Mon, 11 May 2020 16:14:42 +0300 Subject: [PATCH 1/4] allow look up of convertible types also in nested maps --- README.md | 3 +- dist/import.d.ts | 1 + dist/import.js | 25 ++++++---- dist/import.js.map | 2 +- src/import.ts | 116 ++++++++++++++++++++++++++++++++++++--------- 5 files changed, 115 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 7e9f9ea..88c5291 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ firebase firestore:delete [options] <> #### For local JSON -Usually the date, location & reference is not converted correctly when you backup the Firestore database. In order to import correctly, you have to pass to parameters for the options: +Usually the date, location & reference are not converted correctly when you backup the Firestore database. In order to import correctly, you have to pass to parameters for the options: ```javascript // Import options @@ -93,6 +93,7 @@ const options = { dates: ['date1', 'date1.date2', 'date1.date2.date3'], geos: ['location', 'locations'], refs: ['refKey'], + nested: true // look up the data keys also in nested maps }; ``` diff --git a/dist/import.d.ts b/dist/import.d.ts index 49f36f0..fa4a71f 100644 --- a/dist/import.d.ts +++ b/dist/import.d.ts @@ -2,6 +2,7 @@ export interface IImportOptions { dates?: string[]; geos?: string[]; refs?: string[]; + nested?: boolean; } /** * Restore data to firestore diff --git a/dist/import.js b/dist/import.js index f3b0255..3f20aa2 100644 --- a/dist/import.js +++ b/dist/import.js @@ -9,17 +9,26 @@ if(op[0]===6&&_.label0){updateTime(options.dates,data);} +_f.push(_g);_h=0;_j.label=8;case 8:if(!(_h<_f.length))return[3,11];subIndex=_f[_h];revivedSubCollection={};subCollectionPath=collectionName+"/"+docId+"/"+subIndex;revivedSubCollection[subCollectionPath]=subCollections[subIndex];return[4,updateCollection(db,revivedSubCollection,options)];case 9:_j.sent();_j.label=10;case 10:_h++;return[3,8];case 11:_e++;return[3,2];case 12:_i++;return[3,1];case 13:return[2];}});});};var startUpdating=function(db,collectionName,docId,data,options){if(options.dates&&options.dates.length>0){options.dates.forEach(function(date){if(data.hasOwnProperty(date)){if(Array.isArray(data[date])){data[date]=data[date].map(function(d){return makeTime(d);});} +else{data[date]=makeTime(data[date]);}} +if(options.nested){traverseObjects(data,function(value){if(!value.hasOwnProperty(date)){return null;} +value[date]=makeTime(value[date]);return value;});}});} if(options.refs&&options.refs.length>0){options.refs.forEach(function(ref){if(data.hasOwnProperty(ref)){if(Array.isArray(data[ref])){data[ref]=data[ref].map(function(ref){return db.doc(ref);});} -else{data[ref]=db.doc(data[ref]);}}});} -if(options.geos&&options.geos.length>0){options.geos.forEach(function(geo){if(data.hasOwnProperty(geo)){if(Array.isArray(data[geo])){data[geo]=data[geo].map(function(geoValues){return new admin.firestore.GeoPoint(geoValues._latitude,geoValues._longitude);});} -else{data[geo]=new admin.firestore.GeoPoint(data[geo]._latitude,data[geo]._longitude);}}});} -return new Promise(function(resolve,reject){db.collection(collectionName).doc(docId).set(data).then(function(){console.log(docId+" was successfully added to firestore!");resolve({status:true,message:docId+" was successfully added to firestore!"});}).catch(function(error){console.log(error);reject({status:false,message:error.message});});});}; \ No newline at end of file +else{data[ref]=db.doc(data[ref]);}} +if(options.nested){traverseObjects(data,function(value){if(!value.hasOwnProperty(ref)){return null;} +value[ref]=db.doc(data[ref]);return value;});}});} +if(options.geos&&options.geos.length>0){var makeGeoPoint_1=function(geoValues){if(!geoValues._latitude||!geoValues._longitude){return null;} +return new admin.firestore.GeoPoint(geoValues._latitude,geoValues._longitude);};options.geos.forEach(function(geo){if(data.hasOwnProperty(geo)){if(Array.isArray(data[geo])){data[geo]=data[geo].map(function(geoValues){return makeGeoPoint_1(geoValues);});} +else{data[geo]=makeGeoPoint_1(data[geo]);}} +if(options.nested){traverseObjects(data,function(value){if(!value.hasOwnProperty(geo)){return null;} +value[geo]=makeGeoPoint_1(value[geo]);return value;});}});} +return new Promise(function(resolve,reject){db.collection(collectionName).doc(docId).set(data).then(function(){console.log(docId+" was successfully added to firestore!");resolve({status:true,message:docId+" was successfully added to firestore!"});}).catch(function(error){console.log(error);reject({status:false,message:error.message});});});};var isObject=function(test){return(test===null||test===void 0?void 0:test.constructor)===Object;};var traverseObjects=function(data,callback){for(var _i=0,_a=Object.entries(data);_i<_a.length;_i++){var _b=_a[_i],key=_b[0],value=_b[1];if(!isObject(value)){continue;} +var checkResult=callback(value);if(checkResult){data[key]=checkResult;continue;} +traverseObjects(data[key],callback);}}; \ No newline at end of file diff --git a/dist/import.js.map b/dist/import.js.map index 7770e62..95c903b 100644 --- a/dist/import.js.map +++ b/dist/import.js.map @@ -1 +1 @@ -{"version":3,"file":"import.js","sourceRoot":"","sources":["../src/import.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAwB;AACxB,6BAAmC;AACnC,oDAAuC;AAQvC;;;;GAIG;AACH,IAAM,UAAU,GAAG,UAAC,SAAS,EAAE,WAAW;IACxC,SAAS,CAAC,OAAO,CAAC,UAAA,CAAC;QACjB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,UAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;gBAC9C,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAA;aAC9C;;gBAAM,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;QAC9B,CAAC,EAAE,WAAW,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED;;;;;GAKG;AACU,QAAA,OAAO,GAAG,UACrB,QAAgB,EAChB,OAAuB;IAEvB,IAAM,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;IAE5B,OAAO,IAAI,OAAO,C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I,CAAE,WAAW,MAAK,MAAM,CAAC;AACtC,CAAC,CAAA;AAED;;;;;GAKG;AACH,IAAM,eAAe,GAAG,UAAC,IAAS,EAAE,QAAkB;IACpD,KAA2B,UAAoB,EAApB,KAAA,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAApB,cAAoB,EAApB,IAAoB,EAAE;QAAtC,IAAA,WAAY,EAAX,WAAG,EAAE,aAAK;QACpB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACpB,SAAS;SACV;QAED,IAAM,WAAW,GAAQ,QAAQ,CAAC,KAAK,CAAC,CAAA;QACxC,IAAI,WAAW,EAAE;YACf,IAAI,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;YACxB,SAAS;SACV;QAED,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;KACtC;AACH,CAAC,CAAA"} \ No newline at end of file diff --git a/src/import.ts b/src/import.ts index 0958acf..7ea0e64 100644 --- a/src/import.ts +++ b/src/import.ts @@ -6,21 +6,18 @@ export interface IImportOptions { dates?: string[] geos?: string[] refs?: string[] + nested?: boolean } /** - * Convert time array in document object - * @param dateArray - * @param documentObj + * Convert time array in a Date object + * @param firebaseTimestamp */ -const updateTime = (dateArray, documentObj): void => { - dateArray.forEach(c => { - c.split('.').reduce((acc, cur, i, a) => { - if (!a[i + 1] && acc[cur] && acc[cur]._seconds) { - acc[cur] = new Date(acc[cur]._seconds * 1000) - } else return acc[cur] || {} - }, documentObj) - }) +const makeTime = (firebaseTimestamp: {_seconds: number, _nanoseconds: number}): Date => { + if (!firebaseTimestamp._seconds) { + return null; + } + return new Date(firebaseTimestamp._seconds * 1000); } /** @@ -151,7 +148,27 @@ const startUpdating = ( ) => { // Update date value if (options.dates && options.dates.length > 0) { - updateTime(options.dates, data) + options.dates.forEach(date => { + if (data.hasOwnProperty(date)) { + // check type of the date + if (Array.isArray(data[date])) { + data[date] = data[date].map(d => makeTime(d)) + } else { + data[date] = makeTime(data[date]) + } + } + + if (options.nested) { + traverseObjects(data, (value) => { + if (!value.hasOwnProperty(date)) { + return null; + } + + value[date] = makeTime(value[date]); + return value; + }); + } + }); } // reference key @@ -165,28 +182,53 @@ const startUpdating = ( data[ref] = db.doc(data[ref]) } } + + if (options.nested) { + traverseObjects(data, (value) => { + if (!value.hasOwnProperty(ref)) { + return null; + } + + value[ref] = db.doc(data[ref]); + return value; + }); + } }) } // Enter geo value if (options.geos && options.geos.length > 0) { + const makeGeoPoint = (geoValues: {_latitude: number, _longitude: number}) => { + if (!geoValues._latitude || !geoValues._longitude) { + return null; + } + + return new admin.firestore.GeoPoint( + geoValues._latitude, + geoValues._longitude + ); + }; + options.geos.forEach(geo => { if (data.hasOwnProperty(geo)) { // array of geo locations if (Array.isArray(data[geo])) { - data[geo] = data[geo].map(geoValues => { - return new admin.firestore.GeoPoint( - geoValues._latitude, - geoValues._longitude - ) - }) + data[geo] = data[geo].map(geoValues => makeGeoPoint(geoValues)) } else { - data[geo] = new admin.firestore.GeoPoint( - data[geo]._latitude, - data[geo]._longitude - ) + data[geo] = makeGeoPoint(data[geo]) } } + + if (options.nested) { + traverseObjects(data, (value) => { + if (!value.hasOwnProperty(geo)) { + return null; + } + + value[geo] = makeGeoPoint(value[geo]); + return value; + }); + } }) } @@ -210,3 +252,33 @@ const startUpdating = ( }) }) } + +/** + * Check if the parameter is an Object + * @param test + */ +const isObject = (test: any) => { + return test?.constructor === Object; +} + +/** + * Traverse given data, until there is no sub node anymore + * Executes the callback function for every sub node found + * @param data + * @param callback + */ +const traverseObjects = (data: any, callback: Function) => { + for (const [key, value] of Object.entries(data)) { + if (!isObject(value)) { + continue; + } + + const checkResult: any = callback(value) + if (checkResult) { + data[key] = checkResult; + continue; + } + + traverseObjects(data[key], callback); + } +} From dde772160e85b5e8443de36b0a2487c148a3b21b Mon Sep 17 00:00:00 2001 From: Dale Nguyen Date: Mon, 25 May 2020 23:24:39 -0400 Subject: [PATCH 2/4] Edited gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ea0e5e4..fe7418e 100644 --- a/.gitignore +++ b/.gitignore @@ -58,4 +58,5 @@ typings/ .env # test folder -test/serviceAccountKey.json \ No newline at end of file +test/serviceAccountKey.json +.idea \ No newline at end of file From d98236b151617209c558ce2ab3d1c55d00edd459 Mon Sep 17 00:00:00 2001 From: Dale Nguyen Date: Tue, 26 May 2020 00:41:45 -0400 Subject: [PATCH 3/4] Added support for nested geo --- CHANGELOG.md | 7 ++ dist/helper.d.ts | 20 +++++ dist/helper.js | 40 ++++++++++ dist/helper.js.map | 1 + dist/import.d.ts | 7 +- dist/import.js | 25 +++---- dist/import.js.map | 2 +- dist/index.d.ts | 4 +- dist/index.js.map | 2 +- package.json | 3 +- src/helper.ts | 50 +++++++++++++ src/import.ts | 136 ++++++++++------------------------ src/index.ts | 34 ++++----- test/firestore.spec.ts | 90 +++++++++++----------- test/import-to-firestore.json | 9 +++ 15 files changed, 247 insertions(+), 183 deletions(-) create mode 100644 dist/helper.d.ts create mode 100644 dist/helper.js create mode 100644 dist/helper.js.map create mode 100644 src/helper.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index c5f8caa..5a4b2e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,13 @@ --- +## [0.6.0] - 2020-05-26 + +#### - :nail_care: [Polish] + +- Updated new pacakges +- Added support for nested geo #47 + ## [0.5.0] - 2020-04-05 #### - :nail_care: [Polish] diff --git a/dist/helper.d.ts b/dist/helper.d.ts new file mode 100644 index 0000000..66195ee --- /dev/null +++ b/dist/helper.d.ts @@ -0,0 +1,20 @@ +export interface IImportOptions { + dates?: string[]; + geos?: string[]; + refs?: string[]; +} +/** + * Convert time array in a Date object + * @param firebaseTimestamp + */ +export declare const makeTime: (firebaseTimestamp: { + _seconds: number; + _nanoseconds: number; +}) => Date; +/** + * Traverse given data, until there is no sub node anymore + * Executes the callback function for every sub node found + * @param data + * @param callback + */ +export declare const traverseObjects: (data: any, callback: Function) => void; diff --git a/dist/helper.js b/dist/helper.js new file mode 100644 index 0000000..fad82b4 --- /dev/null +++ b/dist/helper.js @@ -0,0 +1,40 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Convert time array in a Date object + * @param firebaseTimestamp + */ +exports.makeTime = function (firebaseTimestamp) { + if (!firebaseTimestamp._seconds) { + return null; + } + return new Date(firebaseTimestamp._seconds * 1000); +}; +/** + * Check if the parameter is an Object + * @param test + */ +var isObject = function (test) { + return (test === null || test === void 0 ? void 0 : test.constructor) === Object; +}; +/** + * Traverse given data, until there is no sub node anymore + * Executes the callback function for every sub node found + * @param data + * @param callback + */ +exports.traverseObjects = function (data, callback) { + for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) { + var _b = _a[_i], key = _b[0], value = _b[1]; + if (!isObject(value)) { + continue; + } + var checkResult = callback(value); + if (checkResult) { + data[key] = checkResult; + continue; + } + exports.traverseObjects(data[key], callback); + } +}; +//# sourceMappingURL=helper.js.map \ No newline at end of file diff --git a/dist/helper.js.map b/dist/helper.js.map new file mode 100644 index 0000000..2d9dc1e --- /dev/null +++ b/dist/helper.js.map @@ -0,0 +1 @@ +{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":";;AAMA;;;GAGG;AAEU,QAAA,QAAQ,GAAG,UAAC,iBAGxB;IACC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE;QAC/B,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,IAAI,IAAI,CAAC,iBAAiB,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAA;AACpD,CAAC,CAAA;AAED;;;GAGG;AACH,IAAM,QAAQ,GAAG,UAAC,IAAS;IACzB,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,MAAK,MAAM,CAAA;AACrC,CAAC,CAAA;AAED;;;;;GAKG;AACU,QAAA,eAAe,GAAG,UAAC,IAAS,EAAE,QAAkB;IAC3D,KAA2B,UAAoB,EAApB,KAAA,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAApB,cAAoB,EAApB,IAAoB,EAAE;QAAtC,IAAA,WAAY,EAAX,WAAG,EAAE,aAAK;QACpB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACpB,SAAQ;SACT;QAED,IAAM,WAAW,GAAQ,QAAQ,CAAC,KAAK,CAAC,CAAA;QACxC,IAAI,WAAW,EAAE;YACf,IAAI,CAAC,GAAG,CAAC,GAAG,WAAW,CAAA;YACvB,SAAQ;SACT;QAED,uBAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAA;KACrC;AACH,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/import.d.ts b/dist/import.d.ts index fa4a71f..94191f4 100644 --- a/dist/import.d.ts +++ b/dist/import.d.ts @@ -1,9 +1,4 @@ -export interface IImportOptions { - dates?: string[]; - geos?: string[]; - refs?: string[]; - nested?: boolean; -} +import { IImportOptions } from './helper'; /** * Restore data to firestore * diff --git a/dist/import.js b/dist/import.js index 3f20aa2..8f187cb 100644 --- a/dist/import.js +++ b/dist/import.js @@ -9,26 +9,21 @@ if(op[0]===6&&_.label0){options.dates.forEach(function(date){if(data.hasOwnProperty(date)){if(Array.isArray(data[date])){data[date]=data[date].map(function(d){return makeTime(d);});} -else{data[date]=makeTime(data[date]);}} -if(options.nested){traverseObjects(data,function(value){if(!value.hasOwnProperty(date)){return null;} -value[date]=makeTime(value[date]);return value;});}});} +_f.push(_g);_h=0;_j.label=8;case 8:if(!(_h<_f.length))return[3,11];subIndex=_f[_h];revivedSubCollection={};subCollectionPath=collectionName+"/"+docId+"/"+subIndex;revivedSubCollection[subCollectionPath]=subCollections[subIndex];return[4,updateCollection(db,revivedSubCollection,options)];case 9:_j.sent();_j.label=10;case 10:_h++;return[3,8];case 11:_e++;return[3,2];case 12:_i++;return[3,1];case 13:return[2];}});});};var startUpdating=function(db,collectionName,docId,data,options){if(options.dates&&options.dates.length>0){options.dates.forEach(function(date){if(data.hasOwnProperty(date)){if(Array.isArray(data[date])){data[date]=data[date].map(function(d){return helper_1.makeTime(d);});} +else{data[date]=helper_1.makeTime(data[date]);}} +if(date.indexOf('.')>-1){helper_1.traverseObjects(data,function(value){if(!value.hasOwnProperty('_seconds')){return null;} +return helper_1.makeTime(value);});}});} if(options.refs&&options.refs.length>0){options.refs.forEach(function(ref){if(data.hasOwnProperty(ref)){if(Array.isArray(data[ref])){data[ref]=data[ref].map(function(ref){return db.doc(ref);});} -else{data[ref]=db.doc(data[ref]);}} -if(options.nested){traverseObjects(data,function(value){if(!value.hasOwnProperty(ref)){return null;} -value[ref]=db.doc(data[ref]);return value;});}});} +else{data[ref]=db.doc(data[ref]);}}});} if(options.geos&&options.geos.length>0){var makeGeoPoint_1=function(geoValues){if(!geoValues._latitude||!geoValues._longitude){return null;} return new admin.firestore.GeoPoint(geoValues._latitude,geoValues._longitude);};options.geos.forEach(function(geo){if(data.hasOwnProperty(geo)){if(Array.isArray(data[geo])){data[geo]=data[geo].map(function(geoValues){return makeGeoPoint_1(geoValues);});} else{data[geo]=makeGeoPoint_1(data[geo]);}} -if(options.nested){traverseObjects(data,function(value){if(!value.hasOwnProperty(geo)){return null;} -value[geo]=makeGeoPoint_1(value[geo]);return value;});}});} -return new Promise(function(resolve,reject){db.collection(collectionName).doc(docId).set(data).then(function(){console.log(docId+" was successfully added to firestore!");resolve({status:true,message:docId+" was successfully added to firestore!"});}).catch(function(error){console.log(error);reject({status:false,message:error.message});});});};var isObject=function(test){return(test===null||test===void 0?void 0:test.constructor)===Object;};var traverseObjects=function(data,callback){for(var _i=0,_a=Object.entries(data);_i<_a.length;_i++){var _b=_a[_i],key=_b[0],value=_b[1];if(!isObject(value)){continue;} -var checkResult=callback(value);if(checkResult){data[key]=checkResult;continue;} -traverseObjects(data[key],callback);}}; \ No newline at end of file +if(geo.indexOf('.')>-1){helper_1.traverseObjects(data,function(value){if(!value.hasOwnProperty('_latitude')){return null;} +return makeGeoPoint_1(value);});}});} +return new Promise(function(resolve,reject){db.collection(collectionName).doc(docId).set(data).then(function(){console.log(docId+" was successfully added to firestore!");resolve({status:true,message:docId+" was successfully added to firestore!",});}).catch(function(error){console.log(error);reject({status:false,message:error.message,});});});}; \ No newline at end of file diff --git a/dist/import.js.map b/dist/import.js.map index 95c903b..f7792b4 100644 --- a/dist/import.js.map +++ b/dist/import.js.map @@ -1 +1 @@ -{"version":3,"file":"import.js","sourceRoot":"","sources":["../src/import.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAwB;AACxB,6BAAmC;AACnC,oDAAuC;AASvC;;;GAGG;AACH,IAAM,QAAQ,GAAG,UAAC,iBAA2D;IAC3E,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE;QAC/B,OAAO,IAAI,CAAC;KACb;IACD,OAAO,IAAI,IAAI,CAAC,iBAAiB,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;AACrD,CAAC,CAAA;AAED;;;;;GAKG;AACU,QAAA,OAAO,GAAG,UACrB,QAAgB,EAChB,OAAuB;IAEvB,IAAM,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;IAE5B,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QACjC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,IAAI,OAAO,GAAG,QAAQ,CAAA;YAEtB,gBAAgB,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC;iBACnC,IAAI,CAAC;gBACJ,OAAO,CAAC;oBACN,MAAM,EAAE,IAAI;oBACZ,OAAO,EAAE,mCAAmC;iBAC7C,CAAC,CAAA;YACJ,CAAC,CAAC;iBACD,KAAK,CAAC,UAAA,KAAK;gBACV,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAA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CAAC,UAAA,SAAS,IAAI,OAAA,cAAY,CAAC,SAAS,CAAC,EAAvB,CAAuB,CAAC,CAAA;iBAChE;qBAAM;oBACL,IAAI,CAAC,GAAG,CAAC,GAAG,cAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;iBACpC;aACF;YAED,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;gBACzB,wBAAe,CAAC,IAAI,EAAE,UAAA,KAAK;oBACzB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE;wBACtC,OAAO,IAAI,CAAA;qBACZ;oBACD,OAAO,cAAY,CAAC,KAAK,CAAC,CAAA;gBAC5B,CAAC,CAAC,CAAA;aACH;QACH,CAAC,CAAC,CAAA;KACH;IAED,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QACjC,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC;aAC1B,GAAG,CAAC,KAAK,CAAC;aACV,GAAG,CAAC,IAAI,CAAC;aACT,IAAI,CAAC;YACJ,OAAO,CAAC,GAAG,CAAI,KAAK,0CAAuC,CAAC,CAAA;YAC5D,OAAO,CAAC;gBACN,MAAM,EAAE,IAAI;gBACZ,OAAO,EAAK,KAAK,0CAAuC;aACzD,CAAC,CAAA;QACJ,CAAC,CAAC;aACD,KAAK,CAAC,UAAA,KAAK;YACV,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;YAClB,MAAM,CAAC;gBACL,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts index 93d12c7..76dd407 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,5 +1,5 @@ import * as admin from 'firebase-admin'; -import * as restoreService from './import'; +import { IImportOptions } from './helper'; /** * Initialize Firebase App * @@ -21,7 +21,7 @@ export declare const backup: (collectionName: string) => Promise; * @param fileName * @param options */ -export declare const restore: (fileName: string, options?: restoreService.IImportOptions) => Promise; +export declare const restore: (fileName: string, options?: IImportOptions) => Promise; /** * Get all collections data * @param {Array} collectionNameArray diff --git a/dist/index.js.map b/dist/index.js.map index 015528d..b7e4bba 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAwC;AAgC/B,sBAAK;AA/Bd,uDAA2C;AAC3C,sDAA0C;AAE1C;;;;;;GAMG;AACU,QAAA,aAAa,GAAG,UAC3B,cAAsB,EACtB,WAAmB,EACnB,IAAkB;IAAlB,qBAAA,EAAA,kBAAkB;IAElB,IACE,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QACvB,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,EACpD;QACA,KAAK,CAAC,aAAa,CACjB;YACE,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC;YACjD,WAAW,EAAE,WAAW;SACzB,EACD,IAAI,CACL,CAAC;QACF,KAAK,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,CAAC;KAC7D;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAIF;;;;;GAKG;AACU,QAAA,MAAM,GAAG,UAAC,cAAsB;IAC3C,OAAO,aAAa,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;GAIG;AACU,QAAA,OAAO,GAAG,UACrB,QAAgB,EAChB,OAA2C;IAA3C,wBAAA,EAAA,YAA2C;IAE3C,OAAO,cAAc,CAA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CAAA;AAED;;;GAGG;AACU,QAAA,OAAO,GAAG,UAAC,mBAAuC;IAAvC,oCAAA,EAAA,wBAAuC;IAC7D,OAAO,aAAa,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAA;AAC7D,CAAC,CAAA"} \ No newline at end of file diff --git a/package.json b/package.json index e2ff0a6..2ef92bc 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,11 @@ { "name": "firestore-export-import", - "version": "0.5.0", + "version": "0.6.0", "description": "NPM package for backup and restore Firebase Firestore", "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { + "watch": "tsc -w", "test": "mocha --timeout 60000 --exit -r ts-node/register test/**/*.spec.ts", "build": "tsc --skipLibCheck && npm run minify", "minify": "jsmin -o dist/index.js dist/index.js && jsmin -o dist/import.js dist/import.js && jsmin -o dist/export.js dist/export.js" diff --git a/src/helper.ts b/src/helper.ts new file mode 100644 index 0000000..5ec7bdf --- /dev/null +++ b/src/helper.ts @@ -0,0 +1,50 @@ +export interface IImportOptions { + dates?: string[] + geos?: string[] + refs?: string[] +} + +/** + * Convert time array in a Date object + * @param firebaseTimestamp + */ + +export const makeTime = (firebaseTimestamp: { + _seconds: number + _nanoseconds: number +}): Date => { + if (!firebaseTimestamp._seconds) { + return null + } + return new Date(firebaseTimestamp._seconds * 1000) +} + +/** + * Check if the parameter is an Object + * @param test + */ +const isObject = (test: any) => { + return test?.constructor === Object +} + +/** + * Traverse given data, until there is no sub node anymore + * Executes the callback function for every sub node found + * @param data + * @param callback + */ +export const traverseObjects = (data: any, callback: Function) => { + for (const [key, value] of Object.entries(data)) { + if (!isObject(value)) { + continue + } + + const checkResult: any = callback(value) + if (checkResult) { + data[key] = checkResult + continue + } + + traverseObjects(data[key], callback) + } +} diff --git a/src/import.ts b/src/import.ts index 7ea0e64..99566e7 100644 --- a/src/import.ts +++ b/src/import.ts @@ -1,24 +1,7 @@ import * as fs from 'fs' import { v1 as uuidv1 } from 'uuid' import * as admin from 'firebase-admin' - -export interface IImportOptions { - dates?: string[] - geos?: string[] - refs?: string[] - nested?: boolean -} - -/** - * Convert time array in a Date object - * @param firebaseTimestamp - */ -const makeTime = (firebaseTimestamp: {_seconds: number, _nanoseconds: number}): Date => { - if (!firebaseTimestamp._seconds) { - return null; - } - return new Date(firebaseTimestamp._seconds * 1000); -} +import { makeTime, traverseObjects, IImportOptions } from './helper' /** * Restore data to firestore @@ -40,14 +23,14 @@ export const restore = ( .then(() => { resolve({ status: true, - message: 'Collection successfully imported!' + message: 'Collection successfully imported!', }) }) .catch(error => { reject({ status: false, message: error.message }) }) } else { - fs.readFile(fileName, 'utf8', function(err, data) { + fs.readFile(fileName, 'utf8', function (err, data) { if (err) { console.log(err) reject({ status: false, message: err.message }) @@ -60,7 +43,7 @@ export const restore = ( .then(() => { resolve({ status: true, - message: 'Collection successfully imported!' + message: 'Collection successfully imported!', }) }) .catch(error => { @@ -148,27 +131,26 @@ const startUpdating = ( ) => { // Update date value if (options.dates && options.dates.length > 0) { - options.dates.forEach(date => { - if (data.hasOwnProperty(date)) { - // check type of the date - if (Array.isArray(data[date])) { - data[date] = data[date].map(d => makeTime(d)) - } else { - data[date] = makeTime(data[date]) - } + options.dates.forEach(date => { + if (data.hasOwnProperty(date)) { + // check type of the date + if (Array.isArray(data[date])) { + data[date] = data[date].map(d => makeTime(d)) + } else { + data[date] = makeTime(data[date]) } + } - if (options.nested) { - traverseObjects(data, (value) => { - if (!value.hasOwnProperty(date)) { - return null; - } - - value[date] = makeTime(value[date]); - return value; - }); - } - }); + // Check for nested date + if (date.indexOf('.') > -1) { + traverseObjects(data, value => { + if (!value.hasOwnProperty('_seconds')) { + return null + } + return makeTime(value) + }) + } + }) } // reference key @@ -182,32 +164,24 @@ const startUpdating = ( data[ref] = db.doc(data[ref]) } } - - if (options.nested) { - traverseObjects(data, (value) => { - if (!value.hasOwnProperty(ref)) { - return null; - } - - value[ref] = db.doc(data[ref]); - return value; - }); - } }) } // Enter geo value if (options.geos && options.geos.length > 0) { - const makeGeoPoint = (geoValues: {_latitude: number, _longitude: number}) => { + const makeGeoPoint = (geoValues: { + _latitude: number + _longitude: number + }) => { if (!geoValues._latitude || !geoValues._longitude) { - return null; + return null } return new admin.firestore.GeoPoint( - geoValues._latitude, - geoValues._longitude - ); - }; + geoValues._latitude, + geoValues._longitude + ) + } options.geos.forEach(geo => { if (data.hasOwnProperty(geo)) { @@ -219,15 +193,13 @@ const startUpdating = ( } } - if (options.nested) { - traverseObjects(data, (value) => { - if (!value.hasOwnProperty(geo)) { - return null; + if (geo.indexOf('.') > -1) { + traverseObjects(data, value => { + if (!value.hasOwnProperty('_latitude')) { + return null } - - value[geo] = makeGeoPoint(value[geo]); - return value; - }); + return makeGeoPoint(value) + }) } }) } @@ -240,45 +212,15 @@ const startUpdating = ( console.log(`${docId} was successfully added to firestore!`) resolve({ status: true, - message: `${docId} was successfully added to firestore!` + message: `${docId} was successfully added to firestore!`, }) }) .catch(error => { console.log(error) reject({ status: false, - message: error.message + message: error.message, }) }) }) } - -/** - * Check if the parameter is an Object - * @param test - */ -const isObject = (test: any) => { - return test?.constructor === Object; -} - -/** - * Traverse given data, until there is no sub node anymore - * Executes the callback function for every sub node found - * @param data - * @param callback - */ -const traverseObjects = (data: any, callback: Function) => { - for (const [key, value] of Object.entries(data)) { - if (!isObject(value)) { - continue; - } - - const checkResult: any = callback(value) - if (checkResult) { - data[key] = checkResult; - continue; - } - - traverseObjects(data[key], callback); - } -} diff --git a/src/index.ts b/src/index.ts index 5afd9ae..29a41df 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,7 @@ -import * as admin from 'firebase-admin'; -import * as restoreService from './import'; -import * as backupService from './export'; +import * as admin from 'firebase-admin' +import * as restoreService from './import' +import * as backupService from './export' +import { IImportOptions } from './helper' /** * Initialize Firebase App @@ -24,13 +25,13 @@ export const initializeApp = ( databaseURL: databaseURL, }, name - ); - admin.firestore().settings({ timestampsInSnapshots: true }); + ) + admin.firestore().settings({ timestampsInSnapshots: true }) } - return true; -}; + return true +} -export { admin }; +export { admin } /** * Backup data from firestore @@ -39,25 +40,22 @@ export { admin }; * @return {json} */ export const backup = (collectionName: string) => { - return backupService.backup(collectionName); -}; + return backupService.backup(collectionName) +} /** * Restore data to firestore * @param fileName * @param options */ -export const restore = ( - fileName: string, - options: restoreService.IImportOptions = {} -) => { - return restoreService.restore(fileName, options); -}; +export const restore = (fileName: string, options: IImportOptions = {}) => { + return restoreService.restore(fileName, options) +} /** * Get all collections data * @param {Array} collectionNameArray */ export const backups = (collectionNameArray: Array = []) => { - return backupService.getAllCollections(collectionNameArray); -}; + return backupService.getAllCollections(collectionNameArray) +} diff --git a/test/firestore.spec.ts b/test/firestore.spec.ts index dcf6f5f..59ef901 100644 --- a/test/firestore.spec.ts +++ b/test/firestore.spec.ts @@ -1,86 +1,92 @@ -import { expect } from 'chai'; -import request from 'request-promise'; -import * as firestoreService from '../dist'; -import { serviceAccount } from './serviceAccount'; +import { expect } from 'chai' +import request from 'request-promise' +import * as firestoreService from '../dist' +import { serviceAccount } from './serviceAccount' const app = firestoreService.initializeApp( serviceAccount, serviceAccount.databaseUrl -); +) const backupAPI = - 'https://firebasestorage.googleapis.com/v0/b/firbase-function-helper-qa.appspot.com/o/import-to-firestore.json?alt=media&token=a0530902-8983-45a4-90c2-72c345c7a3d5'; + 'https://firebasestorage.googleapis.com/v0/b/firbase-function-helper-qa.appspot.com/o/import-to-firestore.json?alt=media&token=a0530902-8983-45a4-90c2-72c345c7a3d5' describe('initializeApp function test', () => { it('Initialize app', () => { - expect(app).to.equal(true); - }); + expect(app).to.equal(true) + }) it('Restore data from API', async () => { - const backupData = await request(backupAPI); + const backupData = await request(backupAPI) const status = await firestoreService.restore(JSON.parse(backupData), { dates: ['date'], geos: ['location'], - }); - expect(status.status).ok; - }); + }) + expect(status.status).ok + }) it('Get all collections', async () => { try { - const all = await firestoreService.backups(); - expect(Object.keys(all).length).is.greaterThan(0); + const all = await firestoreService.backups() + expect(Object.keys(all).length).is.greaterThan(0) } catch (error) { - console.log(error); + console.log(error) } - }); + }) it('Get an array of collections', async () => { - const all = await firestoreService.backups(['test', 'users']); - expect(Object.keys(all).length).is.equal(2); - }); + const all = await firestoreService.backups(['test', 'users']) + expect(Object.keys(all).length).is.equal(2) + }) it('Restore data with document id', async () => { let status = await firestoreService.restore( 'test/import-to-firestore.json', { dates: ['date', 'schedule.time', 'three.level.time'], - geos: ['location', 'locations'], - refs: ['secondRef', 'arrayRef'], + geos: ['location', 'locations', 'locationNested.geopoints'], + refs: ['secondRef', 'arrayRef', 'nestedRef.secondRef'], } - ); - expect(status.status).ok; + ) + expect(status.status).ok - const result = await firestoreService.backup('test'); + const result = await firestoreService.backup('test') - expect(result.test['first-key'].email).is.equal('dungnq@itbox4vn.com'); - expect(result.test['first-key'].schedule.time._seconds).equals(1534046400); - expect(typeof result.test['first-key'].secondRef).is.equal('object'); + expect(result.test['first-key'].email).is.equal('dungnq@itbox4vn.com') + expect(result.test['first-key'].schedule.time._seconds).equals(1534046400) + expect(result.test['first-key'].three.level.time._seconds).equals( + 1534046400 + ) + expect(typeof result.test['first-key'].secondRef).is.equal('object') // locations - expect(result.test['first-key'].location._latitude).equal(49.290683); - expect(result.test['first-key'].locations[0]._latitude).equal(50.290683); - expect(result.test['first-key'].locations[1]._latitude).equal(51.290683); + expect(result.test['first-key'].location._latitude).equal(49.290683) + expect(result.test['first-key'].locations[0]._latitude).equal(50.290683) + expect(result.test['first-key'].locations[1]._latitude).equal(51.290683) + expect(result.test['first-key'].locationNested.geopoint._latitude).equal( + 49.290683 + ) expect( result.test['first-key'].subCollection['test/first-key/details'][ '33J2A10u5902CXagoBP6' ].dogName - ).is.equal('hello'); - }); + ).is.equal('hello') + }) it('Restore data as an array without document id', async () => { let status = await firestoreService.restore( 'test/import-array-to-firestore.json' - ); - expect(status.status).ok; - }); + ) + expect(status.status).ok + }) it('Get a colection with sub-collection', async () => { try { - const data = await firestoreService.backup('test'); - const subCol = data['test']['first-key']['subCollection']; + const data = await firestoreService.backup('test') + const subCol = data['test']['first-key']['subCollection'] - expect(subCol).is.exist; - expect(Object.values(subCol).length).is.greaterThan(0); + expect(subCol).is.exist + expect(Object.values(subCol).length).is.greaterThan(0) } catch (error) { - console.log(error); + console.log(error) } - }); -}); + }) +}) diff --git a/test/import-to-firestore.json b/test/import-to-firestore.json index 08055e0..b9c765c 100644 --- a/test/import-to-firestore.json +++ b/test/import-to-firestore.json @@ -28,6 +28,12 @@ "_latitude": 49.290683, "_longitude": -123.133956 }, + "locationNested": { + "geopoint": { + "_latitude": 49.290683, + "_longitude": -123.133956 + } + }, "locations": [ { "_latitude": 50.290683, @@ -41,6 +47,9 @@ "email": "dungnq@itbox4vn.com", "secondRef": "test/second-key", "arrayRef": ["test/second-key", "test/second-key"], + "nestedRef": { + "secondRef": "test/second-key" + }, "subCollection": { "test/first-key/details": { "33J2A10u5902CXagoBP6": { From 2657451bd953411b9802da5cd67c0a429251a5f0 Mon Sep 17 00:00:00 2001 From: Dale Nguyen Date: Tue, 26 May 2020 00:44:03 -0400 Subject: [PATCH 4/4] updated packages --- package.json | 10 ++-- yarn.lock | 160 +++++++++++++++++++++++++-------------------------- 2 files changed, 85 insertions(+), 85 deletions(-) diff --git a/package.json b/package.json index 2ef92bc..293f866 100644 --- a/package.json +++ b/package.json @@ -31,18 +31,18 @@ "devDependencies": { "@types/chai": "^4.2.11", "@types/mocha": "^7.0.2", - "@types/node": "^13.11.0", + "@types/node": "^14.0.5", "chai": "^4.2.0", "jsmin": "^1.0.1", "minimist": "^1.2.5", - "mocha": "^7.1.1", + "mocha": "^7.2.0", "request": "^2.88.2", "request-promise": "^4.2.5", - "ts-node": "^8.8.2", - "typescript": "^3.8.3" + "ts-node": "^8.10.1", + "typescript": "^3.9.3" }, "dependencies": { - "firebase-admin": "^8.10.0" + "firebase-admin": "^8.12.1" }, "resolutions": { "minimist": "1.2.5" diff --git a/yarn.lock b/yarn.lock index a4294e9..15b1f12 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,55 +2,55 @@ # yarn lockfile v1 -"@firebase/app-types@0.5.2": - version "0.5.2" - resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.5.2.tgz#3d9e86283b6b37d9384e42eecd04df9fae384466" - integrity sha512-k3zRi9gXyWrymu8OL6DA1Pz7eo+sKVBopX5ouOjQwozAZ55WhelifPC99WHmLWo8sAokNM0XDyzM7loOA5yliQ== - -"@firebase/auth-interop-types@0.1.3": - version "0.1.3" - resolved "https://registry.yarnpkg.com/@firebase/auth-interop-types/-/auth-interop-types-0.1.3.tgz#ee28e96c795bde1d92670af2c26d6c32d468ffdc" - integrity sha512-Fd0MJ8hHw/MasNTJz7vl5jnMMs71X6pY/VqN0V6lqdP5HKTuyPVnffJ1d2Vb6uCLZ1D7nXAer4YWj9cOrNLPAQ== - -"@firebase/component@0.1.6": - version "0.1.6" - resolved "https://registry.yarnpkg.com/@firebase/component/-/component-0.1.6.tgz#e983f0630ae3f01003ead85330c1fe3cd2623c1f" - integrity sha512-dm5pVhm+sU8ag1M3hY6vleA/H7Ed8sKRxbm4TAKhtjGHDejPXxnK0meTNydJ3MwisHWlwzGuzIEhb223K7FFxA== - dependencies: - "@firebase/util" "0.2.41" - tslib "1.10.0" - -"@firebase/database-types@0.4.12": - version "0.4.12" - resolved "https://registry.yarnpkg.com/@firebase/database-types/-/database-types-0.4.12.tgz#f6946e8605260f1c38a7db1b858d3d42e30bcbf4" - integrity sha512-PVCTQRG9fnN1cam3Qr91+WzsCf9tO+lmUcPEb0uvafSFVhvx2U9OZOlYDdM5hS0MMHTNXI7Ywmc33EheIlLmMw== - dependencies: - "@firebase/app-types" "0.5.2" - -"@firebase/database@^0.5.17": - version "0.5.22" - resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.5.22.tgz#347e8f5d0fae2b7d50dbc2a39ee6fb35dfa37fc9" - integrity sha512-3CVsmLFscFIAFOjjVhlT6HzFOhS0TKVbjhixp64oVZMOshp9qPHtHIytf6QXRAypbtZMPFAMGnhNu0pmPW/vtg== - dependencies: - "@firebase/auth-interop-types" "0.1.3" - "@firebase/component" "0.1.6" - "@firebase/database-types" "0.4.12" - "@firebase/logger" "0.1.36" - "@firebase/util" "0.2.41" +"@firebase/app-types@0.6.1": + version "0.6.1" + resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.6.1.tgz#dcbd23030a71c0c74fc95d4a3f75ba81653850e9" + integrity sha512-L/ZnJRAq7F++utfuoTKX4CLBG5YR7tFO3PLzG1/oXXKEezJ0kRL3CMRoueBEmTCzVb/6SIs2Qlaw++uDgi5Xyg== + +"@firebase/auth-interop-types@0.1.5": + version "0.1.5" + resolved "https://registry.yarnpkg.com/@firebase/auth-interop-types/-/auth-interop-types-0.1.5.tgz#9fc9bd7c879f16b8d1bb08373a0f48c3a8b74557" + integrity sha512-88h74TMQ6wXChPA6h9Q3E1Jg6TkTHep2+k63OWg3s0ozyGVMeY+TTOti7PFPzq5RhszQPQOoCi59es4MaRvgCw== + +"@firebase/component@0.1.12": + version "0.1.12" + resolved "https://registry.yarnpkg.com/@firebase/component/-/component-0.1.12.tgz#deb511c92c5c6f60995207312b7ede8c7076fdb2" + integrity sha512-03w800MxR/EW1m7N0Q46WNcngwdDIHDWpFPHTdbZEI6U/HuLks5RJQlBxWqb1P73nYPkN8YP3U8gTdqrDpqY3Q== + dependencies: + "@firebase/util" "0.2.47" + tslib "1.11.1" + +"@firebase/database-types@0.5.1": + version "0.5.1" + resolved "https://registry.yarnpkg.com/@firebase/database-types/-/database-types-0.5.1.tgz#fab2f3fb48eec374a9f435ed21e138635cb9b71c" + integrity sha512-onQxom1ZBYBJ648w/VNRzUewovEDAH7lvnrrpCd69ukkyrMk6rGEO/PQ9BcNEbhlNtukpsqRS0oNOFlHs0FaSA== + dependencies: + "@firebase/app-types" "0.6.1" + +"@firebase/database@^0.6.0": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.6.3.tgz#d85471938a0a9d9169f1f37f8f9d2dec7ef32f8b" + integrity sha512-gHoCISHQVLoq+rGu+PorYxMkhsjhXov3ocBxz/0uVdznNhrbKkAZaEKF+dIAsUPDlwSYeZuwWuik7xcV3DtRaw== + dependencies: + "@firebase/auth-interop-types" "0.1.5" + "@firebase/component" "0.1.12" + "@firebase/database-types" "0.5.1" + "@firebase/logger" "0.2.4" + "@firebase/util" "0.2.47" faye-websocket "0.11.3" - tslib "1.10.0" + tslib "1.11.1" -"@firebase/logger@0.1.36": - version "0.1.36" - resolved "https://registry.yarnpkg.com/@firebase/logger/-/logger-0.1.36.tgz#e8c634008d382169e30e944a9bf0ee02cdd88490" - integrity sha512-5Z0ryTtzRk7kjUb0/18r10oXYu8mSPAjgdbLowRBP6HdSJB7BDiUIRS7iATSmUBZLTArdroSiFJ29m7YDfm/cw== +"@firebase/logger@0.2.4": + version "0.2.4" + resolved "https://registry.yarnpkg.com/@firebase/logger/-/logger-0.2.4.tgz#276e7c482f462b5b24b188257cf162b3b2cd3ad6" + integrity sha512-akHkOU7izYB1okp/B5sxClGjjw6KvZdSHyjNM5pKd67Zg5W6PsbkI/GFNv21+y6LkUkJwDRbdeDgJoYXWT3mMA== -"@firebase/util@0.2.41": - version "0.2.41" - resolved "https://registry.yarnpkg.com/@firebase/util/-/util-0.2.41.tgz#36a0e0deb05a67b8ca79ec559d7a9859a46da519" - integrity sha512-QRu3wjU5I0ZBWrf4wgrEBYu5K5tkHjETMDPMY8WYCeekKB13k2MuJzHBjQVuStEOU7j6ygTAA0B8vXI/6B5D0g== +"@firebase/util@0.2.47": + version "0.2.47" + resolved "https://registry.yarnpkg.com/@firebase/util/-/util-0.2.47.tgz#c5e02bbba7aa0786f29cc516b2e2ee17e0c1f4a4" + integrity sha512-RjcIvcfswyxYhf0OMXod+qeI/933wl9FGLIszf0/O1yMZ/s8moXcse7xnOpMjmQPRLB9vHzCMoxW5X90kKg/bQ== dependencies: - tslib "1.10.0" + tslib "1.11.1" "@google-cloud/common@^2.1.1": version "2.4.0" @@ -229,10 +229,10 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.17.tgz#7a183163a9e6ff720d86502db23ba4aade5999b8" integrity sha512-gpNnRnZP3VWzzj5k3qrpRC6Rk3H/uclhAVo1aIvwzK5p5cOrs9yEyQ8H/HBsBY0u5rrWxXEiVPQ0dEB6pkjE8Q== -"@types/node@^13.11.0": - version "13.11.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b" - integrity sha512-uM4mnmsIIPK/yeO+42F2RQhGUIs39K2RFmugcJANppXe6J1nvH87PvzPZYpza7Xhhs8Yn9yIAVdLZ84z61+0xQ== +"@types/node@^14.0.5": + version "14.0.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.5.tgz#3d03acd3b3414cf67faf999aed11682ed121f22b" + integrity sha512-90hiq6/VqtQgX8Sp0EzeIsv3r+ellbGj4URKj5j30tLlZvRUpnAe9YbYnjl3pJM93GyXU0tghHhvXHq+5rnCKA== "@types/node@^8.10.59": version "8.10.59" @@ -776,12 +776,12 @@ find-up@3.0.0, find-up@^3.0.0: dependencies: locate-path "^3.0.0" -firebase-admin@^8.10.0: - version "8.10.0" - resolved "https://registry.yarnpkg.com/firebase-admin/-/firebase-admin-8.10.0.tgz#4a838aec52df49845eba07ad59a40b4df996e815" - integrity sha512-QzJZ1sBh9xzKjb44aP6m1duy0Xe1ixexwh0eaOt1CkJYCOq2b6bievK4GNWMl5yGQ7FFBEbZO6hyDi+5wrctcg== +firebase-admin@^8.12.1: + version "8.12.1" + resolved "https://registry.yarnpkg.com/firebase-admin/-/firebase-admin-8.12.1.tgz#a380c43a9e6ba37dfbe42211a253dd890a442063" + integrity sha512-DZ4Q7QQJYaO2BhnhZLrhL+mGRTCLS5WrxjbJtuKGmbKRBepwMhx++EQA5yhnGnIXgDHnp5SrZnVKygNdXtH8BQ== dependencies: - "@firebase/database" "^0.5.17" + "@firebase/database" "^0.6.0" "@types/node" "^8.10.59" dicer "^0.3.0" jsonwebtoken "8.1.0" @@ -1423,17 +1423,17 @@ minimist@1.2.5, minimist@^1.2.5: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== -mkdirp@0.5.3: - version "0.5.3" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.3.tgz#5a514b7179259287952881e94410ec5465659f8c" - integrity sha512-P+2gwrFqx8lhew375MQHHeTlY8AuOJSrGf0R5ddkEndUkmwpgUob/vQuBD1V22/Cw1/lJr4x+EjllSezBThzBg== +mkdirp@0.5.5: + version "0.5.5" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" + integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== dependencies: minimist "^1.2.5" -mocha@^7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-7.1.1.tgz#89fbb30d09429845b1bb893a830bf5771049a441" - integrity sha512-3qQsu3ijNS3GkWcccT5Zw0hf/rWvu1fTN9sPvEd81hlwsr30GX2GcDSSoBxo24IR8FelmrAydGC6/1J5QQP4WA== +mocha@^7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-7.2.0.tgz#01cc227b00d875ab1eed03a75106689cfed5a604" + integrity sha512-O9CIypScywTVpNaRrCAgoUnJgozpIofjKUYmJhiCIJMiuYnLI6otcb1/kpW9/n/tJODHGZ7i8aLQoDVsMtOKQQ== dependencies: ansi-colors "3.2.3" browser-stdout "1.3.1" @@ -1448,7 +1448,7 @@ mocha@^7.1.1: js-yaml "3.13.1" log-symbols "3.0.0" minimatch "3.0.4" - mkdirp "0.5.3" + mkdirp "0.5.5" ms "2.1.1" node-environment-flags "1.0.6" object.assign "4.1.0" @@ -1796,10 +1796,10 @@ snakeize@^0.1.0: resolved "https://registry.yarnpkg.com/snakeize/-/snakeize-0.1.0.tgz#10c088d8b58eb076b3229bb5a04e232ce126422d" integrity sha1-EMCI2LWOsHazIpu1oE4jLOEmQi0= -source-map-support@^0.5.6: - version "0.5.16" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.16.tgz#0ae069e7fe3ba7538c64c98515e35339eac5a042" - integrity sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ== +source-map-support@^0.5.17: + version "0.5.19" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" + integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== dependencies: buffer-from "^1.0.0" source-map "^0.6.0" @@ -1977,21 +1977,21 @@ tough-cookie@^2.3.3, tough-cookie@~2.5.0: psl "^1.1.28" punycode "^2.1.1" -ts-node@^8.8.2: - version "8.8.2" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.8.2.tgz#0b39e690bee39ea5111513a9d2bcdc0bc121755f" - integrity sha512-duVj6BpSpUpD/oM4MfhO98ozgkp3Gt9qIp3jGxwU2DFvl/3IRaEAvbLa8G60uS7C77457e/m5TMowjedeRxI1Q== +ts-node@^8.10.1: + version "8.10.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.10.1.tgz#77da0366ff8afbe733596361d2df9a60fc9c9bd3" + integrity sha512-bdNz1L4ekHiJul6SHtZWs1ujEKERJnHs4HxN7rjTyyVOFf3HaJ6sLqe6aPG62XTzAB/63pKRh5jTSWL0D7bsvw== dependencies: arg "^4.1.0" diff "^4.0.1" make-error "^1.1.1" - source-map-support "^0.5.6" + source-map-support "^0.5.17" yn "3.1.1" -tslib@1.10.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" - integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== +tslib@1.11.1: + version "1.11.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35" + integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA== tunnel-agent@^0.6.0: version "0.6.0" @@ -2022,10 +2022,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^3.8.3: - version "3.8.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061" - integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w== +typescript@^3.9.3: + version "3.9.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.3.tgz#d3ac8883a97c26139e42df5e93eeece33d610b8a" + integrity sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ== unique-string@^2.0.0: version "2.0.0"