Socket
Socket
Sign inDemoInstall

firestore-export-import

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firestore-export-import - npm Package Compare versions

Comparing version 0.12.1 to 0.13.0

7

CHANGELOG.md

@@ -14,2 +14,9 @@ # Change log

## [0.13.0] - 2021-03-12
#### - :nail_care: [Polish]
- Updated packages
- Updated types for restore / backup options (Thanks @jdepoix)
## [0.12.1] - 2020-02-26

@@ -16,0 +23,0 @@

7

dist/export.js

@@ -12,6 +12,5 @@ "use strict";var __createBinding=(this&&this.__createBinding)||(Object.create?(function(o,m,k,k2){if(k2===undefined)k2=k;Object.defineProperty(o,k2,{enumerable:true,get:function(){return m[k];}});}):(function(o,m,k,k2){if(k2===undefined)k2=k;o[k2]=m[k];}));var __setModuleDefault=(this&&this.__setModuleDefault)||(Object.create?(function(o,v){Object.defineProperty(o,"default",{enumerable:true,value:v});}):function(o,v){o["default"]=v;});var __importStar=(this&&this.__importStar)||function(mod){if(mod&&mod.__esModule)return mod;var result={};if(mod!=null)for(var k in mod)if(k!=="default"&&Object.prototype.hasOwnProperty.call(mod,k))__createBinding(result,mod,k);__setModuleDefault(result,mod);return result;};var __awaiter=(this&&this.__awaiter)||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value);});}

op=body.call(thisArg,_);}catch(e){op=[6,e];y=0;}finally{f=t=0;}
if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true};}};var __spreadArrays=(this&&this.__spreadArrays)||function(){for(var s=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;for(var r=Array(s),k=0,i=0;i<il;i++)
for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++)
r[k]=a[j];return r;};Object.defineProperty(exports,"__esModule",{value:true});exports.backup=exports.getAllCollections=void 0;var admin=__importStar(require("firebase-admin"));var helper_1=require("./helper");var getAllCollections=function(collectionNameArray,options){return __awaiter(void 0,void 0,void 0,function(){var db,snap,paths,promises,value,all;return __generator(this,function(_a){switch(_a.label){case 0:db=admin.firestore();return[4,db.listCollections()];case 1:snap=_a.sent();paths=collectionNameArray;if(paths.length===0){snap.forEach(function(collection){return paths.push(collection.path);});}
promises=[];paths.forEach(function(segment){var result=exports.backup(segment,options);promises.push(result);});return[4,Promise.all(promises)];case 2:value=_a.sent();all=Object.assign.apply(Object,__spreadArrays([{}],value));return[2,all];}});});};exports.getAllCollections=getAllCollections;var backup=function(collectionName,options){return __awaiter(void 0,void 0,void 0,function(){function addElement(ElementList,element){var newList=Object.assign(ElementList,element);return newList;}
if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true};}};var __spreadArray=(this&&this.__spreadArray)||function(to,from){for(var i=0,il=from.length,j=to.length;i<il;i++,j++)
to[j]=from[i];return to;};Object.defineProperty(exports,"__esModule",{value:true});exports.backup=exports.getAllCollections=void 0;var admin=__importStar(require("firebase-admin"));var helper_1=require("./helper");var getAllCollections=function(collectionNameArray,options){return __awaiter(void 0,void 0,void 0,function(){var db,snap,paths,promises,value,all;return __generator(this,function(_a){switch(_a.label){case 0:db=admin.firestore();return[4,db.listCollections()];case 1:snap=_a.sent();paths=collectionNameArray;if(paths.length===0){snap.forEach(function(collection){return paths.push(collection.path);});}
promises=[];paths.forEach(function(segment){var result=exports.backup(segment,options);promises.push(result);});return[4,Promise.all(promises)];case 2:value=_a.sent();all=Object.assign.apply(Object,__spreadArray([{}],value));return[2,all];}});});};exports.getAllCollections=getAllCollections;var backup=function(collectionName,options){return __awaiter(void 0,void 0,void 0,function(){function addElement(ElementList,element){var newList=Object.assign(ElementList,element);return newList;}
var db,data,collectionRef,documents,_a,docs,_i,docs_1,doc,subCollections,_b,_c,refKey,_d,_e,val,_f,subCollections_1,subCol,subColData,error_1;return __generator(this,function(_g){switch(_g.label){case 0:_g.trys.push([0,12,,13]);db=admin.firestore();data={};data[collectionName]={};collectionRef=db.collection(collectionName);if(!((options===null||options===void 0?void 0:options.queryCollection)!=null))return[3,2];return[4,options.queryCollection(collectionRef)];case 1:_a=_g.sent();return[3,4];case 2:return[4,collectionRef.get()];case 3:_a=_g.sent();_g.label=4;case 4:documents=_a;docs=(options===null||options===void 0?void 0:options.docsFromEachCollection)>0?documents.docs.slice(0,options===null||options===void 0?void 0:options.docsFromEachCollection):documents.docs;_i=0,docs_1=docs;_g.label=5;case 5:if(!(_i<docs_1.length))return[3,11];doc=docs_1[_i];return[4,doc.ref.listCollections()];case 6:subCollections=_g.sent();data[collectionName][doc.id]=doc.data();if(options===null||options===void 0?void 0:options.refs){for(_b=0,_c=options===null||options===void 0?void 0:options.refs;_b<_c.length;_b++){refKey=_c[_b];if(refKey.indexOf('.')>-1){helper_1.traverseObjects(data,function(value){var _a;if(((_a=value.constructor)===null||_a===void 0?void 0:_a.name)!=='DocumentReference'){return null;}

@@ -18,0 +17,0 @@ return helper_1.getPath(value);});}

@@ -12,3 +12,3 @@ import { firestore } from 'firebase-admin/lib/firestore';

refs?: string[];
queryCollection?: <T>(ref: firestore.CollectionReference<firestore.DocumentData>) => Promise<firestore.QuerySnapshot<T>>;
queryCollection?: (ref: firestore.CollectionReference<firestore.DocumentData>) => Promise<firestore.QuerySnapshot<any>>;
}

@@ -15,0 +15,0 @@ export declare const makeGeoPoint: (geoValues: {

@@ -8,2 +8,2 @@ import { IImportOptions } from './helper';

*/
export declare const restore: (fileName: string, options: IImportOptions) => Promise<any>;
export declare const restore: (fileName: string | Object, options: IImportOptions) => Promise<any>;

@@ -24,3 +24,3 @@ import * as admin from 'firebase-admin';

*/
export declare const restore: (fileName: string, options?: IImportOptions) => Promise<any>;
export declare const restore: (fileName: string | Object, options?: IImportOptions) => Promise<any>;
/**

@@ -27,0 +27,0 @@ * Get all collections data

{
"name": "firestore-export-import",
"version": "0.12.1",
"version": "0.13.0",
"description": "NPM package for backup and restore Firebase Firestore",

@@ -34,11 +34,11 @@ "main": "dist/index.js",

"@types/mocha": "^8.2.1",
"@types/node": "^14.14.31",
"chai": "^4.3.0",
"@types/node": "^14.14.34",
"chai": "^4.3.4",
"jsmin": "^1.0.1",
"minimist": "^1.2.5",
"mocha": "^8.3.0",
"mocha": "^8.3.2",
"request": "^2.88.2",
"request-promise": "^4.2.6",
"ts-node": "^9.1.1",
"typescript": "^4.1.5"
"typescript": "^4.2.3"
},

@@ -45,0 +45,0 @@ "dependencies": {

@@ -15,5 +15,5 @@ import * as admin from 'firebase-admin'

refs?: string[]
queryCollection?: <T>(
queryCollection?: (
ref: firestore.CollectionReference<firestore.DocumentData>
) => Promise<firestore.QuerySnapshot<T>>
) => Promise<firestore.QuerySnapshot<any>>
}

@@ -20,0 +20,0 @@

@@ -19,3 +19,3 @@ import * as fs from 'fs'

export const restore = (
fileName: string,
fileName: string | Object,
options: IImportOptions

@@ -22,0 +22,0 @@ ): Promise<any> => {

@@ -47,3 +47,6 @@ import * as admin from 'firebase-admin'

*/
export const restore = (fileName: string, options: IImportOptions = {}) => {
export const restore = (
fileName: string | Object,
options: IImportOptions = {}
) => {
return restoreService.restore(fileName, options)

@@ -50,0 +53,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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