@docknetwork/wallet-sdk-data-store 0.4.1
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/LICENSE +39 -0
- package/jest.config.ts +21 -0
- package/lib/configs.d.ts +3 -0
- package/lib/configs.d.ts.map +1 -0
- package/lib/configs.js +30 -0
- package/lib/configs.js.map +1 -0
- package/lib/document-network-resolver.d.ts +3 -0
- package/lib/document-network-resolver.d.ts.map +1 -0
- package/lib/document-network-resolver.js +52 -0
- package/lib/document-network-resolver.js.map +1 -0
- package/lib/entities/document/create-document.d.ts +10 -0
- package/lib/entities/document/create-document.d.ts.map +1 -0
- package/lib/entities/document/create-document.js +111 -0
- package/lib/entities/document/create-document.js.map +1 -0
- package/lib/entities/document/document.entity.d.ts +11 -0
- package/lib/entities/document/document.entity.d.ts.map +1 -0
- package/lib/entities/document/document.entity.js +55 -0
- package/lib/entities/document/document.entity.js.map +1 -0
- package/lib/entities/document/get-all-documents.d.ts +11 -0
- package/lib/entities/document/get-all-documents.d.ts.map +1 -0
- package/lib/entities/document/get-all-documents.js +78 -0
- package/lib/entities/document/get-all-documents.js.map +1 -0
- package/lib/entities/document/get-documens-by-type.d.ts +10 -0
- package/lib/entities/document/get-documens-by-type.d.ts.map +1 -0
- package/lib/entities/document/get-documens-by-type.js +71 -0
- package/lib/entities/document/get-documens-by-type.js.map +1 -0
- package/lib/entities/document/get-document-by-id.d.ts +13 -0
- package/lib/entities/document/get-document-by-id.d.ts.map +1 -0
- package/lib/entities/document/get-document-by-id.js +92 -0
- package/lib/entities/document/get-document-by-id.js.map +1 -0
- package/lib/entities/document/get-document-correlations.d.ts +10 -0
- package/lib/entities/document/get-document-correlations.d.ts.map +1 -0
- package/lib/entities/document/get-document-correlations.js +78 -0
- package/lib/entities/document/get-document-correlations.js.map +1 -0
- package/lib/entities/document/helpers.d.ts +30 -0
- package/lib/entities/document/helpers.d.ts.map +1 -0
- package/lib/entities/document/helpers.js +196 -0
- package/lib/entities/document/helpers.js.map +1 -0
- package/lib/entities/document/index.d.ts +10 -0
- package/lib/entities/document/index.d.ts.map +1 -0
- package/lib/entities/document/index.js +26 -0
- package/lib/entities/document/index.js.map +1 -0
- package/lib/entities/document/remove-document.d.ts +15 -0
- package/lib/entities/document/remove-document.d.ts.map +1 -0
- package/lib/entities/document/remove-document.js +94 -0
- package/lib/entities/document/remove-document.js.map +1 -0
- package/lib/entities/document/update-document.d.ts +10 -0
- package/lib/entities/document/update-document.d.ts.map +1 -0
- package/lib/entities/document/update-document.js +72 -0
- package/lib/entities/document/update-document.js.map +1 -0
- package/lib/entities/document-type.entity.d.ts +6 -0
- package/lib/entities/document-type.entity.d.ts.map +1 -0
- package/lib/entities/document-type.entity.js +32 -0
- package/lib/entities/document-type.entity.js.map +1 -0
- package/lib/entities/log.entity.d.ts +15 -0
- package/lib/entities/log.entity.d.ts.map +1 -0
- package/lib/entities/log.entity.js +108 -0
- package/lib/entities/log.entity.js.map +1 -0
- package/lib/entities/network.entity.d.ts +6 -0
- package/lib/entities/network.entity.d.ts.map +1 -0
- package/lib/entities/network.entity.js +35 -0
- package/lib/entities/network.entity.js.map +1 -0
- package/lib/entities/transaction.entity.d.ts +24 -0
- package/lib/entities/transaction.entity.d.ts.map +1 -0
- package/lib/entities/transaction.entity.js +139 -0
- package/lib/entities/transaction.entity.js.map +1 -0
- package/lib/entities/wallet.entity.d.ts +10 -0
- package/lib/entities/wallet.entity.d.ts.map +1 -0
- package/lib/entities/wallet.entity.js +109 -0
- package/lib/entities/wallet.entity.js.map +1 -0
- package/lib/helpers.d.ts +6 -0
- package/lib/helpers.d.ts.map +1 -0
- package/lib/helpers.js +98 -0
- package/lib/helpers.js.map +1 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +145 -0
- package/lib/index.js.map +1 -0
- package/lib/logger.d.ts +14 -0
- package/lib/logger.d.ts.map +1 -0
- package/lib/logger.js +40 -0
- package/lib/logger.js.map +1 -0
- package/lib/migration/bootstrap-tables.d.ts +3 -0
- package/lib/migration/bootstrap-tables.d.ts.map +1 -0
- package/lib/migration/bootstrap-tables.js +8 -0
- package/lib/migration/bootstrap-tables.js.map +1 -0
- package/lib/migration/index.d.ts +8 -0
- package/lib/migration/index.d.ts.map +1 -0
- package/lib/migration/index.js +132 -0
- package/lib/migration/index.js.map +1 -0
- package/lib/migration/migration1/index.d.ts +16 -0
- package/lib/migration/migration1/index.d.ts.map +1 -0
- package/lib/migration/migration1/index.js +110 -0
- package/lib/migration/migration1/index.js.map +1 -0
- package/lib/migration/migration1/migrate-v1-data.d.ts +8 -0
- package/lib/migration/migration1/migrate-v1-data.d.ts.map +1 -0
- package/lib/migration/migration1/migrate-v1-data.js +171 -0
- package/lib/migration/migration1/migrate-v1-data.js.map +1 -0
- package/lib/migration/migration1/v1-data-store.d.ts +15 -0
- package/lib/migration/migration1/v1-data-store.d.ts.map +1 -0
- package/lib/migration/migration1/v1-data-store.js +80 -0
- package/lib/migration/migration1/v1-data-store.js.map +1 -0
- package/lib/migrations/1691498362273-bootstrap.d.ts +7 -0
- package/lib/migrations/1691498362273-bootstrap.d.ts.map +1 -0
- package/lib/migrations/1691498362273-bootstrap.js +178 -0
- package/lib/migrations/1691498362273-bootstrap.js.map +1 -0
- package/lib/migrations/index.d.ts +4 -0
- package/lib/migrations/index.d.ts.map +1 -0
- package/lib/migrations/index.js +5 -0
- package/lib/migrations/index.js.map +1 -0
- package/lib/migrations-data-source.d.ts +3 -0
- package/lib/migrations-data-source.d.ts.map +1 -0
- package/lib/migrations-data-source.js +8 -0
- package/lib/migrations-data-source.js.map +1 -0
- package/lib/typeorm.d.ts +2 -0
- package/lib/typeorm.d.ts.map +1 -0
- package/lib/typeorm.js +18 -0
- package/lib/typeorm.js.map +1 -0
- package/lib/types.d.ts +49 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/package.json +31 -0
- package/scripts/publish.sh +3 -0
- package/setup-tests.ts +0 -0
- package/src/__tests__/index.test.ts +56 -0
- package/src/__tests__/v1-data-store.test.ts +24 -0
- package/src/configs.ts +28 -0
- package/src/document-network-resolver.ts +19 -0
- package/src/entities/document/create-document.ts +72 -0
- package/src/entities/document/decument.entity.test.ts +135 -0
- package/src/entities/document/document.entity.ts +40 -0
- package/src/entities/document/get-all-documents.ts +39 -0
- package/src/entities/document/get-documens-by-type.ts +30 -0
- package/src/entities/document/get-document-by-id.ts +45 -0
- package/src/entities/document/get-document-correlations.ts +34 -0
- package/src/entities/document/helpers.ts +115 -0
- package/src/entities/document/index.ts +9 -0
- package/src/entities/document/remove-document.ts +34 -0
- package/src/entities/document/update-document.ts +25 -0
- package/src/entities/document-type.entity.ts +11 -0
- package/src/entities/log.entity.ts +46 -0
- package/src/entities/network.entity.ts +14 -0
- package/src/entities/transaction.entity.ts +67 -0
- package/src/entities/wallet.entity.ts +37 -0
- package/src/helpers.ts +52 -0
- package/src/index.ts +83 -0
- package/src/logger.ts +37 -0
- package/src/migration/bootstrap-tables.ts +5 -0
- package/src/migration/index.ts +53 -0
- package/src/migration/migration1/index.ts +64 -0
- package/src/migration/migration1/migrate-v1-data.ts +57 -0
- package/src/migration/migration1/v1-data-store.ts +39 -0
- package/src/migrations/1691498362273-bootstrap.ts +130 -0
- package/src/migrations/index.ts +3 -0
- package/src/migrations-data-source.ts +6 -0
- package/src/typeorm.ts +1 -0
- package/src/types.ts +67 -0
- package/test/mock-local-storage.ts +17 -0
- package/test/test-utils.ts +23 -0
- package/test/wallet.json +209 -0
- package/tsconfig.build.json +25 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +32 -0
|
@@ -0,0 +1,92 @@
|
|
|
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 (g && (g = 0, op[0] && (_ = 0)), _) 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.getDocumentsById = exports.getDocumentById = void 0;
|
|
40
|
+
var helpers_1 = require("./helpers");
|
|
41
|
+
var document_entity_1 = require("./document.entity");
|
|
42
|
+
var typeorm_1 = require("typeorm");
|
|
43
|
+
/**
|
|
44
|
+
* Get document by id
|
|
45
|
+
* @param dataStore
|
|
46
|
+
* @param id
|
|
47
|
+
*/
|
|
48
|
+
function getDocumentById(_a) {
|
|
49
|
+
var dataStore = _a.dataStore, id = _a.id;
|
|
50
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
+
var repository, entity;
|
|
52
|
+
return __generator(this, function (_b) {
|
|
53
|
+
switch (_b.label) {
|
|
54
|
+
case 0:
|
|
55
|
+
repository = dataStore.db.getRepository(document_entity_1.DocumentEntity);
|
|
56
|
+
return [4 /*yield*/, repository.findOne({
|
|
57
|
+
where: {
|
|
58
|
+
id: id,
|
|
59
|
+
networkId: dataStore.networkId,
|
|
60
|
+
},
|
|
61
|
+
})];
|
|
62
|
+
case 1:
|
|
63
|
+
entity = _b.sent();
|
|
64
|
+
return [2 /*return*/, (0, helpers_1.toWalletDocument)(entity)];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
exports.getDocumentById = getDocumentById;
|
|
70
|
+
function getDocumentsById(_a) {
|
|
71
|
+
var dataStore = _a.dataStore, idList = _a.idList;
|
|
72
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
+
var repository, entities;
|
|
74
|
+
return __generator(this, function (_b) {
|
|
75
|
+
switch (_b.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
repository = dataStore.db.getRepository(document_entity_1.DocumentEntity);
|
|
78
|
+
return [4 /*yield*/, repository.find({
|
|
79
|
+
where: {
|
|
80
|
+
id: (0, typeorm_1.In)(idList),
|
|
81
|
+
networkId: dataStore.networkId,
|
|
82
|
+
},
|
|
83
|
+
})];
|
|
84
|
+
case 1:
|
|
85
|
+
entities = _b.sent();
|
|
86
|
+
return [2 /*return*/, entities.map(helpers_1.toWalletDocument)];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
exports.getDocumentsById = getDocumentsById;
|
|
92
|
+
//# sourceMappingURL=get-document-by-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-document-by-id.js","sourceRoot":"","sources":["../../../src/entities/document/get-document-by-id.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAA2C;AAC3C,qDAAiD;AACjD,mCAA2B;AAE3B;;;;GAIG;AACH,SAAsB,eAAe,CAAC,EAKrC;QAJC,SAAS,eAAA,EACT,EAAE,QAAA;;;;;;oBAII,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC,aAAa,CAAC,gCAAc,CAAC,CAAC;oBAE/C,qBAAM,UAAU,CAAC,OAAO,CAAC;4BACtC,KAAK,EAAE;gCACL,EAAE,EAAE,EAAE;gCACN,SAAS,EAAE,SAAS,CAAC,SAAS;6BAC/B;yBACF,CAAC,EAAA;;oBALI,MAAM,GAAG,SAKb;oBAEF,sBAAO,IAAA,0BAAgB,EAAC,MAAM,CAAC,EAAC;;;;CACjC;AAhBD,0CAgBC;AAED,SAAsB,gBAAgB,CAAC,EAKtC;QAJC,SAAS,eAAA,EACT,MAAM,YAAA;;;;;;oBAIA,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC,aAAa,CAAC,gCAAc,CAAC,CAAC;oBAE7C,qBAAM,UAAU,CAAC,IAAI,CAAC;4BACrC,KAAK,EAAE;gCACL,EAAE,EAAE,IAAA,YAAE,EAAC,MAAM,CAAC;gCACd,SAAS,EAAE,SAAS,CAAC,SAAS;6BAC/B;yBACF,CAAC,EAAA;;oBALI,QAAQ,GAAG,SAKf;oBAEF,sBAAO,QAAQ,CAAC,GAAG,CAAC,0BAAgB,CAAC,EAAC;;;;CACvC;AAhBD,4CAgBC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ContextProps, WalletDocument } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Get related documents
|
|
4
|
+
* @param dataStore
|
|
5
|
+
* @param type
|
|
6
|
+
*/
|
|
7
|
+
export declare function getDocumentCorrelations({ dataStore, documentId, }: ContextProps & {
|
|
8
|
+
documentId: string;
|
|
9
|
+
}): Promise<WalletDocument[]>;
|
|
10
|
+
//# sourceMappingURL=get-document-correlations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-document-correlations.d.ts","sourceRoot":"","sources":["../../../src/entities/document/get-document-correlations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,cAAc,EAAC,MAAM,aAAa,CAAC;AAKzD;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,EAC5C,SAAS,EACT,UAAU,GACX,EAAE,YAAY,GAAG;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAkB5B"}
|
|
@@ -0,0 +1,78 @@
|
|
|
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 (g && (g = 0, op[0] && (_ = 0)), _) 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.getDocumentCorrelations = void 0;
|
|
40
|
+
var document_entity_1 = require("./document.entity");
|
|
41
|
+
var typeorm_1 = require("../../typeorm");
|
|
42
|
+
var helpers_1 = require("./helpers");
|
|
43
|
+
/**
|
|
44
|
+
* Get related documents
|
|
45
|
+
* @param dataStore
|
|
46
|
+
* @param type
|
|
47
|
+
*/
|
|
48
|
+
function getDocumentCorrelations(_a) {
|
|
49
|
+
var dataStore = _a.dataStore, documentId = _a.documentId;
|
|
50
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
+
var repository, entity, data;
|
|
52
|
+
return __generator(this, function (_b) {
|
|
53
|
+
switch (_b.label) {
|
|
54
|
+
case 0:
|
|
55
|
+
repository = dataStore.db.getRepository(document_entity_1.DocumentEntity);
|
|
56
|
+
return [4 /*yield*/, repository.findOne({
|
|
57
|
+
where: {
|
|
58
|
+
id: documentId,
|
|
59
|
+
networkId: dataStore.networkId,
|
|
60
|
+
},
|
|
61
|
+
})];
|
|
62
|
+
case 1:
|
|
63
|
+
entity = _b.sent();
|
|
64
|
+
return [4 /*yield*/, repository.find({
|
|
65
|
+
where: {
|
|
66
|
+
id: (0, typeorm_1.In)(entity.correlation),
|
|
67
|
+
networkId: dataStore.networkId,
|
|
68
|
+
},
|
|
69
|
+
})];
|
|
70
|
+
case 2:
|
|
71
|
+
data = _b.sent();
|
|
72
|
+
return [2 /*return*/, data.map(helpers_1.toWalletDocument)];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
exports.getDocumentCorrelations = getDocumentCorrelations;
|
|
78
|
+
//# sourceMappingURL=get-document-correlations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-document-correlations.js","sourceRoot":"","sources":["../../../src/entities/document/get-document-correlations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qDAAiD;AACjD,yCAAiC;AACjC,qCAA2C;AAE3C;;;;GAIG;AACH,SAAsB,uBAAuB,CAAC,EAK7C;QAJC,SAAS,eAAA,EACT,UAAU,gBAAA;;;;;;oBAIJ,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC,aAAa,CAAC,gCAAc,CAAC,CAAC;oBAE/C,qBAAM,UAAU,CAAC,OAAO,CAAC;4BACtC,KAAK,EAAE;gCACL,EAAE,EAAE,UAAU;gCACd,SAAS,EAAE,SAAS,CAAC,SAAS;6BAC/B;yBACF,CAAC,EAAA;;oBALI,MAAM,GAAG,SAKb;oBAEW,qBAAM,UAAU,CAAC,IAAI,CAAC;4BACjC,KAAK,EAAE;gCACL,EAAE,EAAE,IAAA,YAAE,EAAC,MAAM,CAAC,WAAW,CAAC;gCAC1B,SAAS,EAAE,SAAS,CAAC,SAAS;6BAC/B;yBACF,CAAC,EAAA;;oBALI,IAAI,GAAG,SAKX;oBAEF,sBAAO,IAAI,CAAC,GAAG,CAAC,0BAAgB,CAAC,EAAC;;;;CACnC;AAvBD,0DAuBC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ContextProps, WalletDocument } from '../../types';
|
|
2
|
+
import { DocumentTypeEntity } from '../document-type.entity';
|
|
3
|
+
import { DocumentEntity } from './document.entity';
|
|
4
|
+
/**
|
|
5
|
+
* Get document by id
|
|
6
|
+
* @param dataStore
|
|
7
|
+
* @param types
|
|
8
|
+
*/
|
|
9
|
+
export declare function getOrCreateDocumentTypes({ dataStore, types, }: ContextProps & {
|
|
10
|
+
types: string | string[];
|
|
11
|
+
}): Promise<DocumentTypeEntity[]>;
|
|
12
|
+
export declare function findDocumentEntitiesById({ dataStore, entityIds, }: ContextProps & {
|
|
13
|
+
entityIds: string[];
|
|
14
|
+
}): Promise<DocumentEntity[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Convert document entity to wallet document
|
|
17
|
+
* @param entity
|
|
18
|
+
*/
|
|
19
|
+
export declare function toWalletDocument(entity: DocumentEntity): WalletDocument;
|
|
20
|
+
/**
|
|
21
|
+
* Convert wallet document to document entity
|
|
22
|
+
* @param walletDocument
|
|
23
|
+
*/
|
|
24
|
+
export declare function toDocumentEntity({ dataStore, document, }: ContextProps & {
|
|
25
|
+
document: any;
|
|
26
|
+
}): Promise<DocumentEntity>;
|
|
27
|
+
export declare const saveOptions: {
|
|
28
|
+
transaction: boolean;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/entities/document/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,cAAc,EAAC,MAAM,aAAa,CAAC;AACzD,OAAO,EAAC,kBAAkB,EAAC,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAGjD;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,EAC7C,SAAS,EACT,KAAK,GACN,EAAE,YAAY,GAAG;IAChB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC1B,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA+BhC;AAED,wBAAsB,wBAAwB,CAAC,EAC7C,SAAS,EACT,SAAS,GACV,EAAE,YAAY,GAAG;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAS5B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAYvE;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,SAAS,EACT,QAAQ,GACT,EAAE,YAAY,GAAG;IAChB,QAAQ,EAAE,GAAG,CAAC;CACf,GAAG,OAAO,CAAC,cAAc,CAAC,CAe1B;AAED,eAAO,MAAM,WAAW;;CAIvB,CAAC"}
|
|
@@ -0,0 +1,196 @@
|
|
|
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 (g && (g = 0, op[0] && (_ = 0)), _) 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
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.saveOptions = exports.toDocumentEntity = exports.toWalletDocument = exports.findDocumentEntitiesById = exports.getOrCreateDocumentTypes = void 0;
|
|
54
|
+
var document_type_entity_1 = require("../document-type.entity");
|
|
55
|
+
var assert_1 = __importDefault(require("assert"));
|
|
56
|
+
var logger_1 = require("../../logger");
|
|
57
|
+
var document_entity_1 = require("./document.entity");
|
|
58
|
+
var typeorm_1 = require("../../typeorm");
|
|
59
|
+
/**
|
|
60
|
+
* Get document by id
|
|
61
|
+
* @param dataStore
|
|
62
|
+
* @param types
|
|
63
|
+
*/
|
|
64
|
+
function getOrCreateDocumentTypes(_a) {
|
|
65
|
+
var dataStore = _a.dataStore, types = _a.types;
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var typeRepository, typeEntityList, types_1, types_1_1, type, typeEntity, e_1_1;
|
|
68
|
+
var e_1, _b;
|
|
69
|
+
return __generator(this, function (_c) {
|
|
70
|
+
switch (_c.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
(0, assert_1.default)(!!types, 'Document type must be provided');
|
|
73
|
+
logger_1.logger.debug("getOrCreateDocumentTypes: ".concat(JSON.stringify(types)));
|
|
74
|
+
if (!Array.isArray(types)) {
|
|
75
|
+
types = [types];
|
|
76
|
+
}
|
|
77
|
+
typeRepository = dataStore.db.getRepository(document_type_entity_1.DocumentTypeEntity);
|
|
78
|
+
typeEntityList = [];
|
|
79
|
+
_c.label = 1;
|
|
80
|
+
case 1:
|
|
81
|
+
_c.trys.push([1, 8, 9, 10]);
|
|
82
|
+
types_1 = __values(types), types_1_1 = types_1.next();
|
|
83
|
+
_c.label = 2;
|
|
84
|
+
case 2:
|
|
85
|
+
if (!!types_1_1.done) return [3 /*break*/, 7];
|
|
86
|
+
type = types_1_1.value;
|
|
87
|
+
return [4 /*yield*/, typeRepository.findOne({
|
|
88
|
+
where: {
|
|
89
|
+
id: type,
|
|
90
|
+
},
|
|
91
|
+
})];
|
|
92
|
+
case 3:
|
|
93
|
+
typeEntity = _c.sent();
|
|
94
|
+
if (!!typeEntity) return [3 /*break*/, 5];
|
|
95
|
+
typeEntity = typeRepository.create({
|
|
96
|
+
id: type,
|
|
97
|
+
});
|
|
98
|
+
return [4 /*yield*/, typeRepository.save(typeEntity)];
|
|
99
|
+
case 4:
|
|
100
|
+
_c.sent();
|
|
101
|
+
_c.label = 5;
|
|
102
|
+
case 5:
|
|
103
|
+
typeEntityList.push(typeEntity);
|
|
104
|
+
_c.label = 6;
|
|
105
|
+
case 6:
|
|
106
|
+
types_1_1 = types_1.next();
|
|
107
|
+
return [3 /*break*/, 2];
|
|
108
|
+
case 7: return [3 /*break*/, 10];
|
|
109
|
+
case 8:
|
|
110
|
+
e_1_1 = _c.sent();
|
|
111
|
+
e_1 = { error: e_1_1 };
|
|
112
|
+
return [3 /*break*/, 10];
|
|
113
|
+
case 9:
|
|
114
|
+
try {
|
|
115
|
+
if (types_1_1 && !types_1_1.done && (_b = types_1.return)) _b.call(types_1);
|
|
116
|
+
}
|
|
117
|
+
finally { if (e_1) throw e_1.error; }
|
|
118
|
+
return [7 /*endfinally*/];
|
|
119
|
+
case 10: return [2 /*return*/, typeEntityList];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
exports.getOrCreateDocumentTypes = getOrCreateDocumentTypes;
|
|
125
|
+
function findDocumentEntitiesById(_a) {
|
|
126
|
+
var dataStore = _a.dataStore, entityIds = _a.entityIds;
|
|
127
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
+
var repository, entities;
|
|
129
|
+
return __generator(this, function (_b) {
|
|
130
|
+
switch (_b.label) {
|
|
131
|
+
case 0:
|
|
132
|
+
(0, assert_1.default)(!!entityIds, 'Document ids must be provided');
|
|
133
|
+
repository = dataStore.db.getRepository(document_entity_1.DocumentEntity);
|
|
134
|
+
return [4 /*yield*/, repository.findBy({
|
|
135
|
+
id: (0, typeorm_1.In)(entityIds),
|
|
136
|
+
})];
|
|
137
|
+
case 1:
|
|
138
|
+
entities = _b.sent();
|
|
139
|
+
return [2 /*return*/, entities];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
exports.findDocumentEntitiesById = findDocumentEntitiesById;
|
|
145
|
+
/**
|
|
146
|
+
* Convert document entity to wallet document
|
|
147
|
+
* @param entity
|
|
148
|
+
*/
|
|
149
|
+
function toWalletDocument(entity) {
|
|
150
|
+
if (!entity) {
|
|
151
|
+
return entity;
|
|
152
|
+
}
|
|
153
|
+
var result = JSON.parse(entity.data);
|
|
154
|
+
if (!result.id) {
|
|
155
|
+
result.id = entity.id;
|
|
156
|
+
}
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
exports.toWalletDocument = toWalletDocument;
|
|
160
|
+
/**
|
|
161
|
+
* Convert wallet document to document entity
|
|
162
|
+
* @param walletDocument
|
|
163
|
+
*/
|
|
164
|
+
function toDocumentEntity(_a) {
|
|
165
|
+
var dataStore = _a.dataStore, document = _a.document;
|
|
166
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
167
|
+
var type, _typeRel;
|
|
168
|
+
return __generator(this, function (_b) {
|
|
169
|
+
switch (_b.label) {
|
|
170
|
+
case 0:
|
|
171
|
+
type = document.type || [];
|
|
172
|
+
return [4 /*yield*/, getOrCreateDocumentTypes({
|
|
173
|
+
dataStore: dataStore,
|
|
174
|
+
types: document.type,
|
|
175
|
+
})];
|
|
176
|
+
case 1:
|
|
177
|
+
_typeRel = _b.sent();
|
|
178
|
+
return [2 /*return*/, {
|
|
179
|
+
id: document.id,
|
|
180
|
+
type: type,
|
|
181
|
+
data: JSON.stringify(document),
|
|
182
|
+
_typeRel: _typeRel,
|
|
183
|
+
correlation: document.correlation || [],
|
|
184
|
+
networkId: dataStore.networkId,
|
|
185
|
+
}];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
exports.toDocumentEntity = toDocumentEntity;
|
|
191
|
+
exports.saveOptions = {
|
|
192
|
+
// Android is having issues when running multiple document saves in a short period of time
|
|
193
|
+
// We will disable transactions for now until we find a better solution
|
|
194
|
+
transaction: false,
|
|
195
|
+
};
|
|
196
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/entities/document/helpers.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './document.entity';
|
|
2
|
+
export * from './create-document';
|
|
3
|
+
export * from './helpers';
|
|
4
|
+
export * from './get-documens-by-type';
|
|
5
|
+
export * from './get-document-by-id';
|
|
6
|
+
export * from './get-all-documents';
|
|
7
|
+
export * from './update-document';
|
|
8
|
+
export * from './remove-document';
|
|
9
|
+
export * from './get-document-correlations';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/document/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./document.entity"), exports);
|
|
18
|
+
__exportStar(require("./create-document"), exports);
|
|
19
|
+
__exportStar(require("./helpers"), exports);
|
|
20
|
+
__exportStar(require("./get-documens-by-type"), exports);
|
|
21
|
+
__exportStar(require("./get-document-by-id"), exports);
|
|
22
|
+
__exportStar(require("./get-all-documents"), exports);
|
|
23
|
+
__exportStar(require("./update-document"), exports);
|
|
24
|
+
__exportStar(require("./remove-document"), exports);
|
|
25
|
+
__exportStar(require("./get-document-correlations"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entities/document/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,oDAAkC;AAClC,4CAA0B;AAC1B,yDAAuC;AACvC,uDAAqC;AACrC,sDAAoC;AACpC,oDAAkC;AAClC,oDAAkC;AAClC,8DAA4C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ContextProps } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Remove document
|
|
4
|
+
* @param dataStore
|
|
5
|
+
* @param id
|
|
6
|
+
*/
|
|
7
|
+
export declare function removeDocument({ dataStore, id, }: ContextProps & {
|
|
8
|
+
id: string;
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Remove all documents
|
|
12
|
+
* @param dataStore
|
|
13
|
+
*/
|
|
14
|
+
export declare function removeAllDocuments({ dataStore, }: ContextProps): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=remove-document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-document.d.ts","sourceRoot":"","sources":["../../../src/entities/document/remove-document.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAIzC;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EACnC,SAAS,EACT,EAAE,GACH,EAAE,YAAY,GAAG;IAAC,EAAE,EAAE,MAAM,CAAA;CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAS7C;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,SAAS,GACV,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9B"}
|
|
@@ -0,0 +1,94 @@
|
|
|
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 (g && (g = 0, op[0] && (_ = 0)), _) 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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.removeAllDocuments = exports.removeDocument = void 0;
|
|
43
|
+
var assert_1 = __importDefault(require("assert"));
|
|
44
|
+
var document_entity_1 = require("./document.entity");
|
|
45
|
+
var logger_1 = require("../../logger");
|
|
46
|
+
/**
|
|
47
|
+
* Remove document
|
|
48
|
+
* @param dataStore
|
|
49
|
+
* @param id
|
|
50
|
+
*/
|
|
51
|
+
function removeDocument(_a) {
|
|
52
|
+
var dataStore = _a.dataStore, id = _a.id;
|
|
53
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
+
var repository;
|
|
55
|
+
return __generator(this, function (_b) {
|
|
56
|
+
switch (_b.label) {
|
|
57
|
+
case 0:
|
|
58
|
+
(0, assert_1.default)(!!id, 'Document id is required');
|
|
59
|
+
logger_1.logger.debug("Removing document with id ".concat(id));
|
|
60
|
+
repository = dataStore.db.getRepository(document_entity_1.DocumentEntity);
|
|
61
|
+
return [4 /*yield*/, repository.delete({
|
|
62
|
+
id: id,
|
|
63
|
+
networkId: dataStore.networkId,
|
|
64
|
+
})];
|
|
65
|
+
case 1:
|
|
66
|
+
_b.sent();
|
|
67
|
+
return [2 /*return*/];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
exports.removeDocument = removeDocument;
|
|
73
|
+
/**
|
|
74
|
+
* Remove all documents
|
|
75
|
+
* @param dataStore
|
|
76
|
+
*/
|
|
77
|
+
function removeAllDocuments(_a) {
|
|
78
|
+
var dataStore = _a.dataStore;
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
var repository;
|
|
81
|
+
return __generator(this, function (_b) {
|
|
82
|
+
switch (_b.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
repository = dataStore.db.getRepository(document_entity_1.DocumentEntity);
|
|
85
|
+
return [4 /*yield*/, repository.delete({})];
|
|
86
|
+
case 1:
|
|
87
|
+
_b.sent();
|
|
88
|
+
return [2 /*return*/];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
exports.removeAllDocuments = removeAllDocuments;
|
|
94
|
+
//# sourceMappingURL=remove-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-document.js","sourceRoot":"","sources":["../../../src/entities/document/remove-document.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA4B;AAE5B,qDAAiD;AACjD,uCAAsC;AAEtC;;;;GAIG;AACH,SAAsB,cAAc,CAAC,EAGP;QAF5B,SAAS,eAAA,EACT,EAAE,QAAA;;;;;;oBAEF,IAAA,gBAAM,EAAC,CAAC,CAAC,EAAE,EAAE,yBAAyB,CAAC,CAAC;oBAExC,eAAM,CAAC,KAAK,CAAC,oCAA6B,EAAE,CAAE,CAAC,CAAC;oBAC1C,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC,aAAa,CAAC,gCAAc,CAAC,CAAC;oBAC9D,qBAAM,UAAU,CAAC,MAAM,CAAC;4BACtB,EAAE,IAAA;4BACF,SAAS,EAAE,SAAS,CAAC,SAAS;yBAC/B,CAAC,EAAA;;oBAHF,SAGE,CAAC;;;;;CACJ;AAZD,wCAYC;AAED;;;GAGG;AACH,SAAsB,kBAAkB,CAAC,EAE1B;QADb,SAAS,eAAA;;;;;;oBAEH,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC,aAAa,CAAC,gCAAc,CAAC,CAAC;oBAC9D,qBAAM,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,EAAA;;oBAA3B,SAA2B,CAAC;;;;;CAC7B;AALD,gDAKC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ContextProps, WalletDocument } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Update document
|
|
4
|
+
* @param dataStore
|
|
5
|
+
* @param document
|
|
6
|
+
*/
|
|
7
|
+
export declare function updateDocument({ dataStore, document, }: ContextProps & {
|
|
8
|
+
document: WalletDocument;
|
|
9
|
+
}): Promise<WalletDocument>;
|
|
10
|
+
//# sourceMappingURL=update-document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-document.d.ts","sourceRoot":"","sources":["../../../src/entities/document/update-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAK3D;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EACnC,SAAS,EACT,QAAQ,GACT,EAAE,YAAY,GAAG;IAAC,QAAQ,EAAE,cAAc,CAAA;CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAWrE"}
|