@my-devkit/firebase 1.0.106 → 1.0.110
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/aggregate.d.ts +13 -0
- package/dist/aggregate.js +85 -0
- package/dist/aggregate.js.map +1 -0
- package/dist/app-factory.d.ts +31 -0
- package/dist/app-factory.js +331 -0
- package/dist/app-factory.js.map +1 -0
- package/dist/bus.d.ts +17 -0
- package/dist/bus.js +128 -0
- package/dist/bus.js.map +1 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.js +9 -0
- package/dist/constants.js.map +1 -0
- package/dist/context.d.ts +28 -0
- package/dist/context.js +102 -0
- package/dist/context.js.map +1 -0
- package/dist/decorators/controller/body.d.ts +1 -0
- package/dist/decorators/controller/body.js +17 -0
- package/dist/decorators/controller/body.js.map +1 -0
- package/dist/decorators/controller/body.spec.d.ts +1 -0
- package/dist/decorators/controller/body.spec.js +120 -0
- package/dist/decorators/controller/body.spec.js.map +1 -0
- package/dist/decorators/controller/controller.d.ts +1 -0
- package/dist/decorators/controller/controller.js +14 -0
- package/dist/decorators/controller/controller.js.map +1 -0
- package/dist/decorators/controller/controller.spec.d.ts +1 -0
- package/dist/decorators/controller/controller.spec.js +68 -0
- package/dist/decorators/controller/controller.spec.js.map +1 -0
- package/dist/decorators/controller/get.d.ts +1 -0
- package/dist/decorators/controller/get.js +12 -0
- package/dist/decorators/controller/get.js.map +1 -0
- package/dist/decorators/controller/get.spec.d.ts +1 -0
- package/dist/decorators/controller/get.spec.js +87 -0
- package/dist/decorators/controller/get.spec.js.map +1 -0
- package/dist/decorators/controller/index.d.ts +6 -0
- package/dist/decorators/controller/index.js +19 -0
- package/dist/decorators/controller/index.js.map +1 -0
- package/dist/decorators/controller/param.d.ts +1 -0
- package/dist/decorators/controller/param.js +21 -0
- package/dist/decorators/controller/param.js.map +1 -0
- package/dist/decorators/controller/param.spec.d.ts +1 -0
- package/dist/decorators/controller/param.spec.js +113 -0
- package/dist/decorators/controller/param.spec.js.map +1 -0
- package/dist/decorators/controller/post.d.ts +1 -0
- package/dist/decorators/controller/post.js +12 -0
- package/dist/decorators/controller/post.js.map +1 -0
- package/dist/decorators/controller/post.spec.d.ts +1 -0
- package/dist/decorators/controller/post.spec.js +133 -0
- package/dist/decorators/controller/post.spec.js.map +1 -0
- package/dist/decorators/controller/query.d.ts +1 -0
- package/dist/decorators/controller/query.js +21 -0
- package/dist/decorators/controller/query.js.map +1 -0
- package/dist/decorators/controller/query.spec.d.ts +1 -0
- package/dist/decorators/controller/query.spec.js +113 -0
- package/dist/decorators/controller/query.spec.js.map +1 -0
- package/dist/decorators/handler/command-handler.d.ts +1 -0
- package/dist/decorators/handler/command-handler.js +22 -0
- package/dist/decorators/handler/command-handler.js.map +1 -0
- package/dist/decorators/handler/command-handler.spec.d.ts +1 -0
- package/dist/decorators/handler/command-handler.spec.js +211 -0
- package/dist/decorators/handler/command-handler.spec.js.map +1 -0
- package/dist/decorators/handler/event-handler.d.ts +2 -0
- package/dist/decorators/handler/event-handler.js +22 -0
- package/dist/decorators/handler/event-handler.js.map +1 -0
- package/dist/decorators/handler/event-handler.spec.d.ts +1 -0
- package/dist/decorators/handler/event-handler.spec.js +214 -0
- package/dist/decorators/handler/event-handler.spec.js.map +1 -0
- package/dist/decorators/handler/index.d.ts +2 -0
- package/dist/decorators/handler/index.js +15 -0
- package/dist/decorators/handler/index.js.map +1 -0
- package/dist/decorators/index.d.ts +5 -0
- package/dist/decorators/index.js +18 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/injectable.d.ts +1 -0
- package/dist/decorators/injectable.js +11 -0
- package/dist/decorators/injectable.js.map +1 -0
- package/dist/decorators/module.d.ts +18 -0
- package/dist/decorators/module.js +14 -0
- package/dist/decorators/module.js.map +1 -0
- package/dist/decorators/transactional-client.d.ts +1 -0
- package/dist/decorators/transactional-client.js +11 -0
- package/dist/decorators/transactional-client.js.map +1 -0
- package/dist/execution-mode-enum.d.ts +4 -0
- package/dist/execution-mode-enum.js +9 -0
- package/dist/execution-mode-enum.js.map +1 -0
- package/dist/firestore-client.d.ts +29 -0
- package/dist/firestore-client.js +236 -0
- package/dist/firestore-client.js.map +1 -0
- package/dist/handler-helper.d.ts +9 -0
- package/dist/handler-helper.js +159 -0
- package/dist/handler-helper.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/injector.d.ts +7 -0
- package/dist/injector.js +42 -0
- package/dist/injector.js.map +1 -0
- package/dist/interfaces/app-config.d.ts +0 -0
- package/dist/interfaces/app-config.js +1 -0
- package/dist/interfaces/app-config.js.map +1 -0
- package/dist/interfaces/from-array.d.ts +1 -0
- package/dist/interfaces/from-array.js +3 -0
- package/dist/interfaces/from-array.js.map +1 -0
- package/dist/interfaces/index.d.ts +4 -0
- package/dist/interfaces/index.js +17 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/newable.d.ts +1 -0
- package/dist/interfaces/newable.js +3 -0
- package/dist/interfaces/newable.js.map +1 -0
- package/dist/interfaces/transactional-client.d.ts +3 -0
- package/dist/interfaces/transactional-client.js +3 -0
- package/dist/interfaces/transactional-client.js.map +1 -0
- package/dist/interfaces/type.d.ts +3 -0
- package/dist/interfaces/type.js +3 -0
- package/dist/interfaces/type.js.map +1 -0
- package/dist/reflect.d.ts +62 -0
- package/dist/reflect.js +113 -0
- package/dist/reflect.js.map +1 -0
- package/dist/request-method.enum.d.ts +4 -0
- package/dist/request-method.enum.js +9 -0
- package/dist/request-method.enum.js.map +1 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +14 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/middlewares/authentication-middleware.d.ts +3 -0
- package/dist/server/middlewares/authentication-middleware.js +110 -0
- package/dist/server/middlewares/authentication-middleware.js.map +1 -0
- package/dist/server/middlewares/create-context-middleware.d.ts +3 -0
- package/dist/server/middlewares/create-context-middleware.js +55 -0
- package/dist/server/middlewares/create-context-middleware.js.map +1 -0
- package/dist/server/middlewares/error-middleware.d.ts +2 -0
- package/dist/server/middlewares/error-middleware.js +78 -0
- package/dist/server/middlewares/error-middleware.js.map +1 -0
- package/dist/server/middlewares/headers-middleware.d.ts +2 -0
- package/dist/server/middlewares/headers-middleware.js +58 -0
- package/dist/server/middlewares/headers-middleware.js.map +1 -0
- package/dist/server/middlewares/index.d.ts +5 -0
- package/dist/server/middlewares/index.js +18 -0
- package/dist/server/middlewares/index.js.map +1 -0
- package/dist/server/middlewares/not-found-middleware.d.ts +2 -0
- package/dist/server/middlewares/not-found-middleware.js +50 -0
- package/dist/server/middlewares/not-found-middleware.js.map +1 -0
- package/dist/server/server.d.ts +33 -0
- package/dist/server/server.js +139 -0
- package/dist/server/server.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Document } from '@my-devkit/core';
|
|
2
|
+
import { ITransactionalClient } from './interfaces';
|
|
3
|
+
export declare class FirestoreClient implements ITransactionalClient {
|
|
4
|
+
private db;
|
|
5
|
+
private operations;
|
|
6
|
+
private cachedDocuments;
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
_find<T>(path: string): Promise<T>;
|
|
9
|
+
_findWhere<T>(collection: string, whereClauses?: [string, FirestoreClient.Operator, any | any[]][]): Promise<T>;
|
|
10
|
+
_get<T>(path: string): Promise<T>;
|
|
11
|
+
_getAll<T>(collection: string): Promise<T[]>;
|
|
12
|
+
_getWhere<T>(collection: string, whereClauses?: [string, FirestoreClient.Operator, any | any[]][], orderBy?: string): Promise<T[]>;
|
|
13
|
+
createDocument(document: Document): void;
|
|
14
|
+
updateDocument(document: Document): void;
|
|
15
|
+
deleteDocument(document: Document): void;
|
|
16
|
+
private getCollectionReference;
|
|
17
|
+
}
|
|
18
|
+
export declare namespace FirestoreClient {
|
|
19
|
+
interface Operation {
|
|
20
|
+
document: Document;
|
|
21
|
+
action: Action;
|
|
22
|
+
}
|
|
23
|
+
enum Action {
|
|
24
|
+
Create,
|
|
25
|
+
Update,
|
|
26
|
+
Delete
|
|
27
|
+
}
|
|
28
|
+
type Operator = FirebaseFirestore.WhereFilterOp;
|
|
29
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
18
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
19
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
20
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
21
|
+
function step(op) {
|
|
22
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
23
|
+
while (_) try {
|
|
24
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
25
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
26
|
+
switch (op[0]) {
|
|
27
|
+
case 0: case 1: t = op; break;
|
|
28
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
29
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
30
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
31
|
+
default:
|
|
32
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
33
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
34
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
35
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
36
|
+
if (t[2]) _.ops.pop();
|
|
37
|
+
_.trys.pop(); continue;
|
|
38
|
+
}
|
|
39
|
+
op = body.call(thisArg, _);
|
|
40
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
41
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.FirestoreClient = void 0;
|
|
46
|
+
var core_1 = require("@my-devkit/core");
|
|
47
|
+
var firestore_1 = require("firebase-admin/firestore");
|
|
48
|
+
var decorators_1 = require("./decorators");
|
|
49
|
+
var FirestoreClient = /** @class */ (function () {
|
|
50
|
+
function FirestoreClient() {
|
|
51
|
+
this.db = (0, firestore_1.getFirestore)();
|
|
52
|
+
this.operations = [];
|
|
53
|
+
this.cachedDocuments = new Map();
|
|
54
|
+
}
|
|
55
|
+
FirestoreClient_1 = FirestoreClient;
|
|
56
|
+
FirestoreClient.prototype.save = function () {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
var _i, _a, operation;
|
|
59
|
+
return __generator(this, function (_b) {
|
|
60
|
+
switch (_b.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
core_1.Logger.info("Saving ".concat(this.operations.length, " operations"));
|
|
63
|
+
_i = 0, _a = this.operations;
|
|
64
|
+
_b.label = 1;
|
|
65
|
+
case 1:
|
|
66
|
+
if (!(_i < _a.length)) return [3 /*break*/, 9];
|
|
67
|
+
operation = _a[_i];
|
|
68
|
+
if (!(operation.action === FirestoreClient_1.Action.Create)) return [3 /*break*/, 3];
|
|
69
|
+
core_1.Logger.info("Create document ".concat(operation.document._path));
|
|
70
|
+
return [4 /*yield*/, this.db.doc(operation.document._path).set((0, core_1.serialize)(operation.document))];
|
|
71
|
+
case 2:
|
|
72
|
+
_b.sent();
|
|
73
|
+
return [3 /*break*/, 8];
|
|
74
|
+
case 3:
|
|
75
|
+
if (!(operation.action === FirestoreClient_1.Action.Update)) return [3 /*break*/, 5];
|
|
76
|
+
core_1.Logger.info("Update document ".concat(operation.document._path));
|
|
77
|
+
return [4 /*yield*/, this.db.doc(operation.document._path).set((0, core_1.serialize)(operation.document))];
|
|
78
|
+
case 4:
|
|
79
|
+
_b.sent();
|
|
80
|
+
return [3 /*break*/, 8];
|
|
81
|
+
case 5:
|
|
82
|
+
if (!(operation.action === FirestoreClient_1.Action.Delete)) return [3 /*break*/, 7];
|
|
83
|
+
core_1.Logger.info("Delete document ".concat(operation.document._path));
|
|
84
|
+
return [4 /*yield*/, this.db.doc(operation.document._path).delete()];
|
|
85
|
+
case 6:
|
|
86
|
+
_b.sent();
|
|
87
|
+
return [3 /*break*/, 8];
|
|
88
|
+
case 7: throw new Error("Transactional Repository: Not supported action ".concat(operation.action));
|
|
89
|
+
case 8:
|
|
90
|
+
_i++;
|
|
91
|
+
return [3 /*break*/, 1];
|
|
92
|
+
case 9: return [2 /*return*/];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
FirestoreClient.prototype._find = function (path) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
+
var doc, result;
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0:
|
|
103
|
+
core_1.Logger.info("Repository: find ".concat(path));
|
|
104
|
+
if (this.cachedDocuments.has(path)) {
|
|
105
|
+
core_1.Logger.info("Repository: document returned from transaction");
|
|
106
|
+
return [2 /*return*/, this.cachedDocuments.get(path)];
|
|
107
|
+
}
|
|
108
|
+
return [4 /*yield*/, this.db.doc(path).get()];
|
|
109
|
+
case 1:
|
|
110
|
+
doc = _a.sent();
|
|
111
|
+
result = doc.data();
|
|
112
|
+
return [2 /*return*/, result ? (0, core_1.deserialize)(result) : null];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
FirestoreClient.prototype._findWhere = function (collection, whereClauses) {
|
|
118
|
+
if (whereClauses === void 0) { whereClauses = []; }
|
|
119
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
+
var documents;
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
switch (_a.label) {
|
|
123
|
+
case 0: return [4 /*yield*/, this._getWhere(collection, whereClauses)];
|
|
124
|
+
case 1:
|
|
125
|
+
documents = _a.sent();
|
|
126
|
+
if (documents.length > 1) {
|
|
127
|
+
throw new Error("Transactional Repository: Too many documents found (".concat(documents.length, ")"));
|
|
128
|
+
}
|
|
129
|
+
return [2 /*return*/, documents[0] || null];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
FirestoreClient.prototype._get = function (path) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
+
var result;
|
|
137
|
+
return __generator(this, function (_a) {
|
|
138
|
+
switch (_a.label) {
|
|
139
|
+
case 0:
|
|
140
|
+
core_1.Logger.info("Repository: get ".concat(path));
|
|
141
|
+
return [4 /*yield*/, this._find(path)];
|
|
142
|
+
case 1:
|
|
143
|
+
result = _a.sent();
|
|
144
|
+
if (!result) {
|
|
145
|
+
throw new core_1.NotFoundError("Repository: document ".concat(path, " not found"));
|
|
146
|
+
}
|
|
147
|
+
return [2 /*return*/, result];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
FirestoreClient.prototype._getAll = function (collection) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
154
|
+
var documents, querySnapshot;
|
|
155
|
+
return __generator(this, function (_a) {
|
|
156
|
+
switch (_a.label) {
|
|
157
|
+
case 0:
|
|
158
|
+
core_1.Logger.info("Repository: getAll ".concat(collection));
|
|
159
|
+
documents = [];
|
|
160
|
+
return [4 /*yield*/, this.getCollectionReference(collection).get()];
|
|
161
|
+
case 1:
|
|
162
|
+
querySnapshot = _a.sent();
|
|
163
|
+
querySnapshot.forEach(function (doc) {
|
|
164
|
+
documents.push((0, core_1.deserialize)(doc.data()));
|
|
165
|
+
});
|
|
166
|
+
return [2 /*return*/, documents];
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
FirestoreClient.prototype._getWhere = function (collection, whereClauses, orderBy) {
|
|
172
|
+
if (whereClauses === void 0) { whereClauses = []; }
|
|
173
|
+
if (orderBy === void 0) { orderBy = null; }
|
|
174
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175
|
+
var documents, query, querySnapshot;
|
|
176
|
+
return __generator(this, function (_a) {
|
|
177
|
+
switch (_a.label) {
|
|
178
|
+
case 0:
|
|
179
|
+
core_1.Logger.info("Repository: getWhere ".concat(collection, " whereClauses: ").concat(JSON.stringify(whereClauses)));
|
|
180
|
+
documents = [];
|
|
181
|
+
query = this.getCollectionReference(collection);
|
|
182
|
+
whereClauses.forEach(function (where) {
|
|
183
|
+
query = query.where(where[0], where[1], where[2]);
|
|
184
|
+
});
|
|
185
|
+
if (orderBy) {
|
|
186
|
+
query = query.orderBy(orderBy);
|
|
187
|
+
}
|
|
188
|
+
return [4 /*yield*/, query.get()];
|
|
189
|
+
case 1:
|
|
190
|
+
querySnapshot = _a.sent();
|
|
191
|
+
querySnapshot.forEach(function (doc) {
|
|
192
|
+
documents.push((0, core_1.deserialize)(doc.data()));
|
|
193
|
+
});
|
|
194
|
+
return [2 /*return*/, documents];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
FirestoreClient.prototype.createDocument = function (document) {
|
|
200
|
+
this.operations.push({ document: document, action: FirestoreClient_1.Action.Create });
|
|
201
|
+
this.cachedDocuments.set(document._path, document);
|
|
202
|
+
};
|
|
203
|
+
FirestoreClient.prototype.updateDocument = function (document) {
|
|
204
|
+
this.operations.push({ document: document, action: FirestoreClient_1.Action.Update });
|
|
205
|
+
this.cachedDocuments.set(document._path, document);
|
|
206
|
+
};
|
|
207
|
+
FirestoreClient.prototype.deleteDocument = function (document) {
|
|
208
|
+
this.operations.push({ document: document, action: FirestoreClient_1.Action.Delete });
|
|
209
|
+
this.cachedDocuments.delete(document._path);
|
|
210
|
+
};
|
|
211
|
+
FirestoreClient.prototype.getCollectionReference = function (collection) {
|
|
212
|
+
if (collection.startsWith('**/')) {
|
|
213
|
+
return this.db.collectionGroup(collection.replace('**/', ''));
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
return this.db.collection(collection);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
var FirestoreClient_1;
|
|
220
|
+
FirestoreClient = FirestoreClient_1 = __decorate([
|
|
221
|
+
(0, decorators_1.TransactionalClient)(),
|
|
222
|
+
(0, decorators_1.Injectable)()
|
|
223
|
+
], FirestoreClient);
|
|
224
|
+
return FirestoreClient;
|
|
225
|
+
}());
|
|
226
|
+
exports.FirestoreClient = FirestoreClient;
|
|
227
|
+
(function (FirestoreClient) {
|
|
228
|
+
var Action;
|
|
229
|
+
(function (Action) {
|
|
230
|
+
Action[Action["Create"] = 'Create'] = "Create";
|
|
231
|
+
Action[Action["Update"] = 'Update'] = "Update";
|
|
232
|
+
Action[Action["Delete"] = 'Delete'] = "Delete";
|
|
233
|
+
})(Action = FirestoreClient.Action || (FirestoreClient.Action = {}));
|
|
234
|
+
})(FirestoreClient = exports.FirestoreClient || (exports.FirestoreClient = {}));
|
|
235
|
+
exports.FirestoreClient = FirestoreClient;
|
|
236
|
+
//# sourceMappingURL=firestore-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firestore-client.js","sourceRoot":"","sources":["../src/firestore-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAA0F;AAC1F,sDAAwD;AAExD,2CAA+D;AAM/D;IAAA;QACY,OAAE,GAAG,IAAA,wBAAY,GAAE,CAAC;QACpB,eAAU,GAAgC,EAAE,CAAC;QAC7C,oBAAe,GAAG,IAAI,GAAG,EAAoB,CAAC;IA0G1D,CAAC;wBA7GY,eAAe;IAKX,8BAAI,GAAjB;;;;;;wBACI,aAAM,CAAC,IAAI,CAAC,iBAAU,IAAI,CAAC,UAAU,CAAC,MAAM,gBAAa,CAAC,CAAC;8BAEpB,EAAf,KAAA,IAAI,CAAC,UAAU;;;6BAAf,CAAA,cAAe,CAAA;wBAA5B,SAAS;6BACZ,CAAA,SAAS,CAAC,MAAM,KAAK,iBAAe,CAAC,MAAM,CAAC,MAAM,CAAA,EAAlD,wBAAkD;wBAClD,aAAM,CAAC,IAAI,CAAC,0BAAmB,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAE,CAAC,CAAC;wBAC3D,qBAA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tB,0BAAc,QAAQ,YAAA,CAAA;IAC1B,CAAC,EAJW,MAAM,GAAN,sBAAM,KAAN,sBAAM,QAIjB;AAEL,CAAC,EAbgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAa/B;AA5HY,0CAAe"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Aggregate } from './aggregate';
|
|
2
|
+
export declare class HandlerHelper {
|
|
3
|
+
static create<A extends Aggregate, R>(aggregate: A, callback: (a: A) => Promise<R>): Promise<R>;
|
|
4
|
+
static update<A extends Aggregate, R>(aggregateOrId: A | string, callback: (a: A) => Promise<R>): Promise<R>;
|
|
5
|
+
static delete<A extends Aggregate, R>(aggregateOrId: A | string, callback: (a: A) => Promise<R>): Promise<R>;
|
|
6
|
+
private static get client();
|
|
7
|
+
private static publishEvents;
|
|
8
|
+
private static getAggregate;
|
|
9
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.HandlerHelper = void 0;
|
|
40
|
+
var core_1 = require("@my-devkit/core");
|
|
41
|
+
var context_1 = require("./context");
|
|
42
|
+
var execution_mode_enum_1 = require("./execution-mode-enum");
|
|
43
|
+
var firestore_client_1 = require("./firestore-client");
|
|
44
|
+
var HandlerHelper = /** @class */ (function () {
|
|
45
|
+
function HandlerHelper() {
|
|
46
|
+
}
|
|
47
|
+
HandlerHelper.create = function (aggregate, callback) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
49
|
+
var result;
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
switch (_a.label) {
|
|
52
|
+
case 0: return [4 /*yield*/, callback(aggregate)];
|
|
53
|
+
case 1:
|
|
54
|
+
result = _a.sent();
|
|
55
|
+
this.client.createDocument(aggregate);
|
|
56
|
+
return [4 /*yield*/, this.publishEvents(aggregate)];
|
|
57
|
+
case 2:
|
|
58
|
+
_a.sent();
|
|
59
|
+
return [2 /*return*/, result];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
HandlerHelper.update = function (aggregateOrId, callback) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
+
var aggregate, hashBefore, result;
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
switch (_a.label) {
|
|
69
|
+
case 0: return [4 /*yield*/, this.getAggregate(aggregateOrId)];
|
|
70
|
+
case 1:
|
|
71
|
+
aggregate = _a.sent();
|
|
72
|
+
if (aggregate.events.length > 0) {
|
|
73
|
+
core_1.Logger.warn("".concat(aggregate._type, " ").concat(aggregate.id, " has ").concat(aggregate.events.length, " events!!"));
|
|
74
|
+
}
|
|
75
|
+
hashBefore = aggregate.hash;
|
|
76
|
+
return [4 /*yield*/, callback(aggregate)];
|
|
77
|
+
case 2:
|
|
78
|
+
result = _a.sent();
|
|
79
|
+
if (!(aggregate.hash !== hashBefore)) return [3 /*break*/, 4];
|
|
80
|
+
this.client.updateDocument(aggregate);
|
|
81
|
+
return [4 /*yield*/, this.publishEvents(aggregate)];
|
|
82
|
+
case 3:
|
|
83
|
+
_a.sent();
|
|
84
|
+
return [3 /*break*/, 5];
|
|
85
|
+
case 4:
|
|
86
|
+
core_1.Logger.debug("".concat(aggregate._type, " ").concat(aggregate.id, " didn't change, ").concat(aggregate.events.length, " events skipped"));
|
|
87
|
+
aggregate.clearEvents();
|
|
88
|
+
_a.label = 5;
|
|
89
|
+
case 5: return [2 /*return*/, result];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
HandlerHelper.delete = function (aggregateOrId, callback) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
+
var aggregate, result;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0: return [4 /*yield*/, this.getAggregate(aggregateOrId)];
|
|
100
|
+
case 1:
|
|
101
|
+
aggregate = _a.sent();
|
|
102
|
+
return [4 /*yield*/, callback(aggregate)];
|
|
103
|
+
case 2:
|
|
104
|
+
result = _a.sent();
|
|
105
|
+
this.client.deleteDocument(aggregate);
|
|
106
|
+
return [4 /*yield*/, this.publishEvents(aggregate)];
|
|
107
|
+
case 3:
|
|
108
|
+
_a.sent();
|
|
109
|
+
return [2 /*return*/, result];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
Object.defineProperty(HandlerHelper, "client", {
|
|
115
|
+
get: function () {
|
|
116
|
+
return context_1.Context.resolve(firestore_client_1.FirestoreClient);
|
|
117
|
+
},
|
|
118
|
+
enumerable: false,
|
|
119
|
+
configurable: true
|
|
120
|
+
});
|
|
121
|
+
HandlerHelper.publishEvents = function (aggregate) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
123
|
+
var events, _i, events_1, event;
|
|
124
|
+
return __generator(this, function (_a) {
|
|
125
|
+
switch (_a.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
events = aggregate.events;
|
|
128
|
+
aggregate.clearEvents();
|
|
129
|
+
_i = 0, events_1 = events;
|
|
130
|
+
_a.label = 1;
|
|
131
|
+
case 1:
|
|
132
|
+
if (!(_i < events_1.length)) return [3 /*break*/, 4];
|
|
133
|
+
event = events_1[_i];
|
|
134
|
+
return [4 /*yield*/, context_1.Context.bus.publish(event, execution_mode_enum_1.ExecutionMode.Synchronous)];
|
|
135
|
+
case 2:
|
|
136
|
+
_a.sent();
|
|
137
|
+
_a.label = 3;
|
|
138
|
+
case 3:
|
|
139
|
+
_i++;
|
|
140
|
+
return [3 /*break*/, 1];
|
|
141
|
+
case 4: return [2 /*return*/];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
HandlerHelper.getAggregate = function (aggregateOrId) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
if (typeof aggregateOrId === 'string' || aggregateOrId instanceof String) {
|
|
150
|
+
return [2 /*return*/, this.client._find("/aggregates/".concat(aggregateOrId))];
|
|
151
|
+
}
|
|
152
|
+
return [2 /*return*/, aggregateOrId];
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
return HandlerHelper;
|
|
157
|
+
}());
|
|
158
|
+
exports.HandlerHelper = HandlerHelper;
|
|
159
|
+
//# sourceMappingURL=handler-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-helper.js","sourceRoot":"","sources":["../src/handler-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAyC;AAGzC,qCAAoC;AACpC,6DAAsD;AACtD,uDAAqD;AAErD;IAAA;IA4DA,CAAC;IA3DuB,oBAAM,GAA1B,UAAmD,SAAY,EAAE,QAA8B;;;;;4BAC5E,qBAAM,QAAQ,CAAC,SAAS,CAAC,EAAA;;wBAAlC,MAAM,GAAG,SAAyB;wBAExC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;wBACtC,qBAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,EAAA;;wBAAnC,SAAmC,CAAC;wBAEpC,s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C,SAAS,CAAC,EAAA;;wBAAnC,SAAmC,CAAC;wBAEpC,sBAAO,MAAM,EAAC;;;;KACjB;IAED,sBAAmB,uBAAM;aAAzB;YACI,OAAO,iBAAO,CAAC,OAAO,CAAC,kCAAe,CAAC,CAAC;QAC5C,CAAC;;;OAAA;IAEoB,2BAAa,GAAlC,UAAwD,SAAY;;;;;;wBAC1D,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;wBAChC,SAAS,CAAC,WAAW,EAAE,CAAC;8BAEE,EAAN,iBAAM;;;6BAAN,CAAA,oBAAM,CAAA;wBAAf,KAAK;wBACZ,qBAAM,iBAAO,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,mCAAa,CAAC,WAAW,CAAC,EAAA;;wBAA3D,SAA2D,CAAC;;;wBAD5C,IAAM,CAAA;;;;;;KAG7B;IAEoB,0BAAY,GAAjC,UAAuD,aAAyB;;;gBAC5E,IAAI,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,YAAY,MAAM,EAAE;oBACtE,sBAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAI,sBAAe,aAAa,CAAE,CAAC,EAAC;iBAC/D;gBACD,sBAAO,aAAa,EAAC;;;KACxB;IACL,oBAAC;AAAD,CAAC,AA5DD,IA4DC;AA5DY,sCAAa"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./decorators"), exports);
|
|
14
|
+
__exportStar(require("./aggregate"), exports);
|
|
15
|
+
__exportStar(require("./context"), exports);
|
|
16
|
+
__exportStar(require("./app-factory"), exports);
|
|
17
|
+
__exportStar(require("./firestore-client"), exports);
|
|
18
|
+
__exportStar(require("./execution-mode-enum"), exports);
|
|
19
|
+
__exportStar(require("./handler-helper"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA6B;AAC7B,8CAA4B;AAC5B,4CAA0B;AAC1B,gDAA8B;AAC9B,qDAAmC;AACnC,wDAAsC;AACtC,mDAAiC"}
|
package/dist/injector.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Injector = void 0;
|
|
13
|
+
var reflect_1 = require("./reflect");
|
|
14
|
+
var Injector = /** @class */ (function () {
|
|
15
|
+
function Injector() {
|
|
16
|
+
this.instances = new Map();
|
|
17
|
+
this.transactionalClients = [];
|
|
18
|
+
}
|
|
19
|
+
Injector.prototype.resolve = function (target) {
|
|
20
|
+
var _this = this;
|
|
21
|
+
var injectableId = (0, reflect_1.reflect)(target).getInjectableId();
|
|
22
|
+
if (!injectableId) {
|
|
23
|
+
throw new Error("".concat(target.name, " is not injectable"));
|
|
24
|
+
}
|
|
25
|
+
if (!this.instances.has(injectableId)) {
|
|
26
|
+
var tokens = (0, reflect_1.reflect)(target).getParameters();
|
|
27
|
+
var injections = tokens.map(function (token) { return _this.resolve(token); });
|
|
28
|
+
var instance = new (target.bind.apply(target, __spreadArray([void 0], injections, false)))();
|
|
29
|
+
this.instances.set(injectableId, instance);
|
|
30
|
+
if ((0, reflect_1.reflect)(target).isTransactionalClient()) {
|
|
31
|
+
this.transactionalClients.push(instance);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return this.instances.get(injectableId);
|
|
35
|
+
};
|
|
36
|
+
Injector.prototype.getTransactionalClients = function () {
|
|
37
|
+
return __spreadArray([], this.transactionalClients, true);
|
|
38
|
+
};
|
|
39
|
+
return Injector;
|
|
40
|
+
}());
|
|
41
|
+
exports.Injector = Injector;
|
|
42
|
+
//# sourceMappingURL=injector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injector.js","sourceRoot":"","sources":["../src/injector.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAoC;AAEpC;IAAA;QACY,cAAS,GAAG,IAAI,GAAG,EAAe,CAAC;QACnC,yBAAoB,GAA2B,EAAE,CAAC;IAyB9D,CAAC;IAvBU,0BAAO,GAAd,UAAkB,MAAe;QAAjC,iBAkBC;QAjBG,IAAM,YAAY,GAAG,IAAA,iBAAO,EAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC;QACvD,IAAI,CAAC,YAAY,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,UAAG,MAAM,CAAC,IAAI,uBAAoB,CAAC,CAAC;SACvD;QAED,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YACnC,IAAM,MAAM,GAAG,IAAA,iBAAO,EAAC,MAAM,CAAC,CAAC,aAAa,EAAE,CAAC;YAC/C,IAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,KAAI,CAAC,OAAO,CAAM,KAAK,CAAC,EAAxB,CAAwB,CAAC,CAAC;YACjE,IAAM,QAAQ,QAAO,MAAM,YAAN,MAAM,0BAAI,UAAU,YAAC,CAAC;YAC3C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;YAE3C,IAAI,IAAA,iBAAO,EAAC,MAAM,CAAC,CAAC,qBAAqB,EAAE,EAAE;gBACzC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAM,QAAQ,CAAC,CAAC;aACjD;SACJ;QAED,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAEM,0CAAuB,GAA9B;QACI,yBAAW,IAAI,CAAC,oBAAoB,QAAE;IAC1C,CAAC;IACL,eAAC;AAAD,CAAC,AA3BD,IA2BC;AA3BY,4BAAQ"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=app-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-config.js","sourceRoot":"","sources":["../../src/interfaces/app-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type FromArray<T extends ReadonlyArray<unknown>> = T extends ReadonlyArray<infer FromArray> ? FromArray : never;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from-array.js","sourceRoot":"","sources":["../../src/interfaces/from-array.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./newable"), exports);
|
|
14
|
+
__exportStar(require("./from-array"), exports);
|
|
15
|
+
__exportStar(require("./type"), exports);
|
|
16
|
+
__exportStar(require("./transactional-client"), exports);
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA0B;AAC1B,+CAA6B;AAC7B,yCAAuB;AACvB,yDAAuC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type Newable<T> = new () => T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"newable.js","sourceRoot":"","sources":["../../src/interfaces/newable.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactional-client.js","sourceRoot":"","sources":["../../src/interfaces/transactional-client.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/interfaces/type.ts"],"names":[],"mappings":""}
|