@ddd-ts/store-firestore 0.0.0-feat.kraaft.b1feeab
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/firebase.transaction.d.ts +6 -0
- package/dist/firebase.transaction.d.ts.map +1 -0
- package/dist/firebase.transaction.js +11 -0
- package/dist/firebase.transaction.js.map +1 -0
- package/dist/firestore.store.d.ts +6 -0
- package/dist/firestore.store.d.ts.map +1 -0
- package/dist/firestore.store.js +47 -0
- package/dist/firestore.store.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +21 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Firestore } from "firebase-admin/firestore";
|
|
2
|
+
import { TransactionPerformer } from "@ddd-ts/model";
|
|
3
|
+
export declare class FirebaseTransactionPerformer extends TransactionPerformer {
|
|
4
|
+
constructor(db: Firestore);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=firebase.transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase.transaction.d.ts","sourceRoot":"","sources":["../src/firebase.transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,qBAAa,4BAA6B,SAAQ,oBAAoB;gBACxD,EAAE,EAAE,SAAS;CAG1B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FirebaseTransactionPerformer = void 0;
|
|
4
|
+
const model_1 = require("@ddd-ts/model");
|
|
5
|
+
class FirebaseTransactionPerformer extends model_1.TransactionPerformer {
|
|
6
|
+
constructor(db) {
|
|
7
|
+
super((effect) => db.runTransaction(effect));
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.FirebaseTransactionPerformer = FirebaseTransactionPerformer;
|
|
11
|
+
//# sourceMappingURL=firebase.transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase.transaction.js","sourceRoot":"","sources":["../src/firebase.transaction.ts"],"names":[],"mappings":";;;AACA,yCAAqD;AAErD,MAAa,4BAA6B,SAAQ,4BAAoB;IACpE,YAAY,EAAa;QACvB,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,CAAC;CACF;AAJD,oEAIC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Store } from "@ddd-ts/model";
|
|
2
|
+
import { AbstractConstructor } from "@ddd-ts/types";
|
|
3
|
+
export declare function FirestoreStore<Model, Id extends {
|
|
4
|
+
toString(): string;
|
|
5
|
+
}>(collection: string): AbstractConstructor<Store<Model, Id>>;
|
|
6
|
+
//# sourceMappingURL=firestore.store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firestore.store.d.ts","sourceRoot":"","sources":["../src/firestore.store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AASpD,wBAAgB,cAAc,CAAC,KAAK,EAAE,EAAE,SAAS;IAAE,QAAQ,IAAI,MAAM,CAAA;CAAE,EACrE,UAAU,EAAE,MAAM,GACjB,mBAAmB,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAkDvC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FirestoreStore = void 0;
|
|
4
|
+
function FirestoreStore(collection) {
|
|
5
|
+
class FirstoreStore {
|
|
6
|
+
firestore;
|
|
7
|
+
serializer;
|
|
8
|
+
converter;
|
|
9
|
+
_collection;
|
|
10
|
+
constructor(firestore, serializer, converter) {
|
|
11
|
+
this.firestore = firestore;
|
|
12
|
+
this.serializer = serializer;
|
|
13
|
+
this.converter = converter;
|
|
14
|
+
if (this.converter) {
|
|
15
|
+
this._collection = this.firestore
|
|
16
|
+
.collection(collection)
|
|
17
|
+
.withConverter(this.converter);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this._collection = this.firestore.collection(collection);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async save(model, trx) {
|
|
24
|
+
const serialized = this.serializer.serialize(model);
|
|
25
|
+
const ref = this._collection.doc(serialized.id.toString());
|
|
26
|
+
trx ? trx.set(ref, serialized) : await ref.set(serialized);
|
|
27
|
+
}
|
|
28
|
+
async load(id, trx) {
|
|
29
|
+
const ref = this._collection.doc(id.toString());
|
|
30
|
+
const snapshot = trx ? await trx.get(ref) : await ref.get();
|
|
31
|
+
if (!snapshot.exists) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return this.serializer.deserialize(snapshot.data());
|
|
35
|
+
}
|
|
36
|
+
async loadAll() {
|
|
37
|
+
const snapshot = await this._collection.get();
|
|
38
|
+
return snapshot.docs.map((doc) => this.serializer.deserialize(doc.data()));
|
|
39
|
+
}
|
|
40
|
+
async delete(id) {
|
|
41
|
+
await this.firestore.collection(collection).doc(id.toString()).delete();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return FirstoreStore;
|
|
45
|
+
}
|
|
46
|
+
exports.FirestoreStore = FirestoreStore;
|
|
47
|
+
//# sourceMappingURL=firestore.store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firestore.store.js","sourceRoot":"","sources":["../src/firestore.store.ts"],"names":[],"mappings":";;;AAUA,SAAgB,cAAc,CAC5B,UAAkB;IAElB,MAAe,aAAa;QAIR;QACC;QACA;QALnB,WAAW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,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAS,CAAC,CAAC;QAC7D,CAAC;QAED,KAAK,CAAC,OAAO;YACX,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;YAC9C,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAC/B,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAS,CAAC,CAC/C,CAAC;QACJ,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,EAAM;YACjB,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1E,CAAC;KACF;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AApDD,wCAoDC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FirebaseTransactionPerformer = exports.FirestoreStore = void 0;
|
|
4
|
+
var firestore_store_1 = require("./firestore.store");
|
|
5
|
+
Object.defineProperty(exports, "FirestoreStore", { enumerable: true, get: function () { return firestore_store_1.FirestoreStore; } });
|
|
6
|
+
var firebase_transaction_1 = require("./firebase.transaction");
|
|
7
|
+
Object.defineProperty(exports, "FirebaseTransactionPerformer", { enumerable: true, get: function () { return firebase_transaction_1.FirebaseTransactionPerformer; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,+DAAsE;AAA7D,oIAAA,4BAA4B,OAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ddd-ts/store-firestore",
|
|
3
|
+
"version": "0.0.0-feat.kraaft.b1feeab",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"pretest": "docker compose -f docker/docker-compose.yml up -d",
|
|
9
|
+
"test": "yarn pretest; test-runner; e=$?;yarn posttest; exit $e",
|
|
10
|
+
"posttest": "docker compose -f docker/docker-compose.yml down",
|
|
11
|
+
"build": "builder"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@ddd-ts/model": "*",
|
|
15
|
+
"firebase-admin": "^11.5.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@ddd-ts/dev": "*",
|
|
19
|
+
"@ddd-ts/types": "*"
|
|
20
|
+
}
|
|
21
|
+
}
|