New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

firestore-typescript-implementation

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firestore-typescript-implementation - npm Package Compare versions

Comparing version 0.1.9 to 0.1.10

3

dist/Database/Collection/collection.d.ts
import { ICollection } from './ICollection/i-collection';
import { IDocument } from './Document/IDocument/i-document';
export declare class Collection<T> implements ICollection<T> {
private _default;
private collection;
Documents: IDocument<T>;
constructor();
constructor(_default: string);
setCollection(paths: string[]): string;

@@ -8,0 +9,0 @@ getCollection(): string;

import { Collection } from './Collection/collection';
import { IDatabase } from './IDatabase/i-database';
export declare class Database<T> extends Collection<T> implements IDatabase<T> {
private _defaultCollection;
/**
*
*/
constructor(_defaultCollection: string);
}

@@ -1281,6 +1281,14 @@ 'use strict';

var Collection = /*#__PURE__*/function () {
function Collection() {
this.collection = '';
this.resetCollecion(this.collection);
this.Documents = new Document(this.collection);
function Collection(_default) {
this._default = _default;
this.collection = this._default;
console.log("Default Collection : " + _default);
console.log("1 ==> Init doc set collection " + _default);
this.Documents = new Document(_default);
console.log("2 ==> Reset doc collection set collection " + _default);
this.resetCollecion(_default);
console.log("3 ==> Set this database global collection " + this._default);
console.log("" + this._default);
console.log("to += " + _default);
this._default = _default;
}

@@ -1316,4 +1324,15 @@

function Database() {
return _Collection.apply(this, arguments) || this;
/**
*
*/
function Database(_defaultCollection) {
var _this;
_this = _Collection.call(this, _defaultCollection) || this;
_this._defaultCollection = _defaultCollection;
_this.resetCollecion(_defaultCollection);
_defaultCollection = _this._defaultCollection;
return _this;
}

@@ -1324,7 +1343,19 @@

admin.initializeApp();
var Firestore = /*#__PURE__*/function (_Database) {
_inheritsLoose(Firestore, _Database);
function Firestore() {
return _Database.apply(this, arguments) || this;
/**
* Firestore instance will set your collections in local storage and data,
* This data is stile overiden by the database collection instance as a defalut value
*/
function Firestore(_storeCollection) {
var _this;
_this = _Database.call(this, _storeCollection[0]) || this;
_this._storeCollection = _storeCollection;
_this._storeCollection = _storeCollection;
_this._storeCollection[0] = _this.setCollection(_storeCollection);
console.log("Init ==> firestore instance will set your collection first " + _this._storeCollection[0]);
return _this;
}

@@ -1331,0 +1362,0 @@

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("firebase-admin");function e(t,e,r,n,o,i,c){try{var a=t[i](c),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,o)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(o,i){var c=t.apply(r,n);function a(t){e(c,o,i,a,u,"next",t)}function u(t){e(c,o,i,a,u,"throw",t)}a(void 0)}))}}function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var o,i=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",c=n.toStringTag||"@@toStringTag";function a(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{a({},"")}catch(t){a=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),i=new L(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var c=r.delegate;if(c){var a=x(c,r);if(a){if(a===l)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};a(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(D([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=p.prototype=f.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){a(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,i){function c(){return new e((function(n,c){!function n(o,i,c,a){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,c,a)}),(function(t){n("throw",t,c,a)})):e.resolve(f).then((function(t){l.value=t,c(l)}),(function(t){return n("throw",t,c,a)}))}a(u.arg)}(o,i,n,c)}))}return n=n?n.then(c,c):c()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function D(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:E}}function E(){return{value:void 0,done:!0}}return h.prototype=p,a(g,"constructor",p),a(p,"constructor",h),h.displayName=a(p,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,a(t,c,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(w.prototype),a(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var c=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?c:c.next().then((function(t){return t.done?t.value:c.next()}))},m(g),a(g,c,"Generator"),a(g,o,(function(){return this})),a(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=D,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return c.type="throw",c.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(a&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var c=i?i.completion:{};return c.type=t,c.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(c)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:D(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(o={exports:{}}),o.exports),c=function(){function e(t){this.collection=t}var n=e.prototype;return n.addDocument=function(){var e=r(i.mark((function e(r){var n;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.firestore().collection(this.collection).add(r);case 2:return n=e.sent,console.log(JSON.parse(JSON.stringify(r))),e.next=6,n.get();case 6:return e.abrupt("return",e.sent.data());case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.addDocumentWithUid=function(){var e=r(i.mark((function e(r,n){var o;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.firestore().doc(r).collection(this.collection).add(n);case 2:return o=e.sent,console.log(JSON.parse(JSON.stringify(n))),e.next=6,o.get();case 6:return e.abrupt("return",e.sent.data());case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),e}(),a=function(){function e(t){this.collection=t}var n=e.prototype;return n.documentById=function(){var e=r(i.mark((function e(r){var n,o;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.firestore().collection(this.collection).listDocuments();case 2:if(void 0!==(n=e.sent.find((function(t){return t.id===r})))){e.next=8;break}e.t0=null,e.next=11;break;case 8:return e.next=10,n.get();case 10:e.t0=e.sent;case 11:return e.abrupt("return",void 0===(o=e.t0)?null:null==o?void 0:o.data());case 13:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getDocuments=function(){var e=r(i.mark((function e(){var r,n,o,c,a;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=[],e.next=3,t.firestore().collection(this.collection).get();case 3:for(n=e.sent.docs,o=0;o<n.length;o++)c=n[o].data(),a=c,null!==r?r.push(a):new Array(a);return e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}(),u=function(){function e(t){this.collection=t}return e.prototype.updateDocument=function(){var e=r(i.mark((function e(r,n){var o;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.firestore().collection(this.collection).listDocuments();case 2:if(void 0===(o=e.sent.find((function(t){return t.id===r})))){e.next=10;break}return e.next=7,o.update(n);case 7:e.t0=e.sent,e.next=11;break;case 10:e.t0=null;case 11:return e.abrupt("return",null==typeof e.t0?null:n);case 13:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),e}(),s=function(){function e(t){this.collection=t,this._response=null}return e.prototype.deleteDocument=function(){var e=r(i.mark((function e(r){var n,o,c;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.firestore().collection(this.collection).listDocuments();case 2:if(void 0===(n=e.sent.find((function(t){return t.id===r})))){e.next=10;break}return e.next=7,n.get();case 7:e.t0=e.sent,e.next=11;break;case 10:e.t0=null;case 11:return c=null==(o=e.t0)?void 0:o.data(),e.next=15,null==n?void 0:n.delete();case 15:return e.abrupt("return",c);case 16:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}(),l=function(){function t(t){this.collection=t,this.addDoc=new c(this.collection),this.getDoc=new a(this.collection),this.updateDoc=new u(this.collection),this.deleteDoc=new s(this.collection)}var e=t.prototype;return e.update=function(){var t=r(i.mark((function t(e,r){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.updateDoc.updateDocument(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.delete=function(){var t=r(i.mark((function t(e){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.deleteDoc.deleteDocument(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.add=function(){var t=r(i.mark((function t(e,r){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null===e&&void 0===e){t.next=6;break}return t.next=3,this.addDoc.addDocumentWithUid(e,r);case 3:t.t0=t.sent,t.next=9;break;case 6:return t.next=8,this.addDoc.addDocument(r);case 8:t.t0=t.sent;case 9:return t.abrupt("return",t.t0);case 10:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.get=function(){var t=r(i.mark((function t(e){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null===e&&void 0===e){t.next=6;break}return t.next=3,this.getDoc.documentById(e);case 3:t.t0=t.sent,t.next=9;break;case 6:return t.next=8,this.getDoc.getDocuments();case 8:t.t0=t.sent;case 9:return t.abrupt("return",t.t0);case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(),f=function(t){function e(){return t.apply(this,arguments)||this}return n(e,t),e}(function(t){function e(){return t.apply(this,arguments)||this}return n(e,t),e}(function(){function t(){this.collection="",this.resetCollecion(this.collection),this.Documents=new l(this.collection)}var e=t.prototype;return e.setCollection=function(t){for(var e="",r=0;r<t.length;r++)e+=r!==t.length?t[r]+"/":""+t[r];return this.collection=e,this.resetCollecion(this.collection)},e.getCollection=function(){return this.collection},e.resetCollecion=function(t){return this.Documents=new l(t),t},t}()));t.initializeApp(),exports.Firestore=f;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("firebase-admin");function e(t,e,r,n,o,i,c){try{var a=t[i](c),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,o)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(o,i){var c=t.apply(r,n);function a(t){e(c,o,i,a,u,"next",t)}function u(t){e(c,o,i,a,u,"throw",t)}a(void 0)}))}}function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var o,i=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",c=n.toStringTag||"@@toStringTag";function a(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{a({},"")}catch(t){a=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),i=new k(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var c=r.delegate;if(c){var a=x(c,r);if(a){if(a===l)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};a(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(L([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=p.prototype=f.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){a(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,i){function c(){return new e((function(n,c){!function n(o,i,c,a){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,c,a)}),(function(t){n("throw",t,c,a)})):e.resolve(f).then((function(t){l.value=t,c(l)}),(function(t){return n("throw",t,c,a)}))}a(u.arg)}(o,i,n,c)}))}return n=n?n.then(c,c):c()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function L(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:D}}function D(){return{value:void 0,done:!0}}return h.prototype=p,a(g,"constructor",p),a(p,"constructor",h),h.displayName=a(p,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,a(t,c,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(w.prototype),a(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var c=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?c:c.next().then((function(t){return t.done?t.value:c.next()}))},m(g),a(g,c,"Generator"),a(g,o,(function(){return this})),a(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return c.type="throw",c.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(a&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var c=i?i.completion:{};return c.type=t,c.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(c)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(o={exports:{}}),o.exports),c=function(){function e(t){this.collection=t}var n=e.prototype;return n.addDocument=function(){var e=r(i.mark((function e(r){var n;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.firestore().collection(this.collection).add(r);case 2:return n=e.sent,console.log(JSON.parse(JSON.stringify(r))),e.next=6,n.get();case 6:return e.abrupt("return",e.sent.data());case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.addDocumentWithUid=function(){var e=r(i.mark((function e(r,n){var o;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.firestore().doc(r).collection(this.collection).add(n);case 2:return o=e.sent,console.log(JSON.parse(JSON.stringify(n))),e.next=6,o.get();case 6:return e.abrupt("return",e.sent.data());case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),e}(),a=function(){function e(t){this.collection=t}var n=e.prototype;return n.documentById=function(){var e=r(i.mark((function e(r){var n,o;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.firestore().collection(this.collection).listDocuments();case 2:if(void 0!==(n=e.sent.find((function(t){return t.id===r})))){e.next=8;break}e.t0=null,e.next=11;break;case 8:return e.next=10,n.get();case 10:e.t0=e.sent;case 11:return e.abrupt("return",void 0===(o=e.t0)?null:null==o?void 0:o.data());case 13:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getDocuments=function(){var e=r(i.mark((function e(){var r,n,o,c,a;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=[],e.next=3,t.firestore().collection(this.collection).get();case 3:for(n=e.sent.docs,o=0;o<n.length;o++)c=n[o].data(),a=c,null!==r?r.push(a):new Array(a);return e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}(),u=function(){function e(t){this.collection=t}return e.prototype.updateDocument=function(){var e=r(i.mark((function e(r,n){var o;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.firestore().collection(this.collection).listDocuments();case 2:if(void 0===(o=e.sent.find((function(t){return t.id===r})))){e.next=10;break}return e.next=7,o.update(n);case 7:e.t0=e.sent,e.next=11;break;case 10:e.t0=null;case 11:return e.abrupt("return",null==typeof e.t0?null:n);case 13:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),e}(),s=function(){function e(t){this.collection=t,this._response=null}return e.prototype.deleteDocument=function(){var e=r(i.mark((function e(r){var n,o,c;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.firestore().collection(this.collection).listDocuments();case 2:if(void 0===(n=e.sent.find((function(t){return t.id===r})))){e.next=10;break}return e.next=7,n.get();case 7:e.t0=e.sent,e.next=11;break;case 10:e.t0=null;case 11:return c=null==(o=e.t0)?void 0:o.data(),e.next=15,null==n?void 0:n.delete();case 15:return e.abrupt("return",c);case 16:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}(),l=function(){function t(t){this.collection=t,this.addDoc=new c(this.collection),this.getDoc=new a(this.collection),this.updateDoc=new u(this.collection),this.deleteDoc=new s(this.collection)}var e=t.prototype;return e.update=function(){var t=r(i.mark((function t(e,r){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.updateDoc.updateDocument(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.delete=function(){var t=r(i.mark((function t(e){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.deleteDoc.deleteDocument(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.add=function(){var t=r(i.mark((function t(e,r){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null===e&&void 0===e){t.next=6;break}return t.next=3,this.addDoc.addDocumentWithUid(e,r);case 3:t.t0=t.sent,t.next=9;break;case 6:return t.next=8,this.addDoc.addDocument(r);case 8:t.t0=t.sent;case 9:return t.abrupt("return",t.t0);case 10:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.get=function(){var t=r(i.mark((function t(e){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null===e&&void 0===e){t.next=6;break}return t.next=3,this.getDoc.documentById(e);case 3:t.t0=t.sent,t.next=9;break;case 6:return t.next=8,this.getDoc.getDocuments();case 8:t.t0=t.sent;case 9:return t.abrupt("return",t.t0);case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(),f=function(t){function e(e){var r;return(r=t.call(this,e)||this)._defaultCollection=e,r.resetCollecion(e),e=r._defaultCollection,r}return n(e,t),e}(function(){function t(t){this._default=t,this.collection=this._default,console.log("Default Collection : "+t),console.log("1 ==> Init doc set collection "+t),this.Documents=new l(t),console.log("2 ==> Reset doc collection set collection "+t),this.resetCollecion(t),console.log("3 ==> Set this database global collection "+this._default),console.log(""+this._default),console.log("to += "+t),this._default=t}var e=t.prototype;return e.setCollection=function(t){for(var e="",r=0;r<t.length;r++)e+=r!==t.length?t[r]+"/":""+t[r];return this.collection=e,this.resetCollecion(this.collection)},e.getCollection=function(){return this.collection},e.resetCollecion=function(t){return this.Documents=new l(t),t},t}());t.initializeApp();var h=function(t){function e(e){var r;return(r=t.call(this,e[0])||this)._storeCollection=e,r._storeCollection=e,r._storeCollection[0]=r.setCollection(e),console.log("Init ==> firestore instance will set your collection first "+r._storeCollection[0]),r}return n(e,t),e}(f);t.initializeApp(),exports.Firestore=h;
//# sourceMappingURL=firestore-typescript-implementation.cjs.production.min.js.map

@@ -1277,6 +1277,14 @@ import { firestore, initializeApp } from 'firebase-admin';

var Collection = /*#__PURE__*/function () {
function Collection() {
this.collection = '';
this.resetCollecion(this.collection);
this.Documents = new Document(this.collection);
function Collection(_default) {
this._default = _default;
this.collection = this._default;
console.log("Default Collection : " + _default);
console.log("1 ==> Init doc set collection " + _default);
this.Documents = new Document(_default);
console.log("2 ==> Reset doc collection set collection " + _default);
this.resetCollecion(_default);
console.log("3 ==> Set this database global collection " + this._default);
console.log("" + this._default);
console.log("to += " + _default);
this._default = _default;
}

@@ -1312,4 +1320,15 @@

function Database() {
return _Collection.apply(this, arguments) || this;
/**
*
*/
function Database(_defaultCollection) {
var _this;
_this = _Collection.call(this, _defaultCollection) || this;
_this._defaultCollection = _defaultCollection;
_this.resetCollecion(_defaultCollection);
_defaultCollection = _this._defaultCollection;
return _this;
}

@@ -1320,7 +1339,19 @@

initializeApp();
var Firestore = /*#__PURE__*/function (_Database) {
_inheritsLoose(Firestore, _Database);
function Firestore() {
return _Database.apply(this, arguments) || this;
/**
* Firestore instance will set your collections in local storage and data,
* This data is stile overiden by the database collection instance as a defalut value
*/
function Firestore(_storeCollection) {
var _this;
_this = _Database.call(this, _storeCollection[0]) || this;
_this._storeCollection = _storeCollection;
_this._storeCollection = _storeCollection;
_this._storeCollection[0] = _this.setCollection(_storeCollection);
console.log("Init ==> firestore instance will set your collection first " + _this._storeCollection[0]);
return _this;
}

@@ -1327,0 +1358,0 @@

import { Database } from './Database/database';
import { IFirestore } from './IFirestore/i-firestore';
export declare class Firestore<T> extends Database<T> implements IFirestore<T> {
private readonly _storeCollection;
/**
* Firestore instance will set your collections in local storage and data,
* This data is stile overiden by the database collection instance as a defalut value
*/
constructor(_storeCollection: string[]);
}
{
"version": "0.1.9",
"version": "0.1.10",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -6,8 +6,14 @@ import { ICollection } from './ICollection/i-collection';

export class Collection<T> implements ICollection<T> {
private collection = '';
private collection = this._default;
Documents: IDocument<T>;
constructor() {
this.resetCollecion(this.collection);
this.Documents = new Document<T>(this.collection);
constructor(private _default: string) {
console.log(`Default Collection : ${_default}`);
console.log(`1 ==> Init doc set collection ${_default}`);
this.Documents = new Document<T>(_default);
console.log(`2 ==> Reset doc collection set collection ${_default}`);
this.resetCollecion(_default);
console.log(`3 ==> Set this database global collection ${this._default}`);
console.log(`${this._default}`);
console.log(`to += ${_default}`);
this._default = _default;
}

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

import { Collection } from './Collection/collection';
import { IDatabase } from './IDatabase/i-database';
export class Database<T> extends Collection<T> implements IDatabase<T> {}
export class Database<T> extends Collection<T> implements IDatabase<T> {
/**
*
*/
constructor(private _defaultCollection: string) {
super(_defaultCollection);
this.resetCollecion(_defaultCollection);
_defaultCollection = this._defaultCollection;
}
}

@@ -0,4 +1,19 @@

import * as admin from 'firebase-admin';
import { Database } from './Database/database';
import { IFirestore } from './IFirestore/i-firestore';
export class Firestore<T> extends Database<T> implements IFirestore<T> {}
admin.initializeApp();
export class Firestore<T> extends Database<T> implements IFirestore<T> {
/**
* Firestore instance will set your collections in local storage and data,
* This data is stile overiden by the database collection instance as a defalut value
*/
constructor(private readonly _storeCollection: string[]) {
super(_storeCollection[0]);
this._storeCollection = _storeCollection;
this._storeCollection[0] = this.setCollection(_storeCollection);
console.log(
`Init ==> firestore instance will set your collection first ${this._storeCollection[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

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