@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.
Files changed (164) hide show
  1. package/LICENSE +39 -0
  2. package/jest.config.ts +21 -0
  3. package/lib/configs.d.ts +3 -0
  4. package/lib/configs.d.ts.map +1 -0
  5. package/lib/configs.js +30 -0
  6. package/lib/configs.js.map +1 -0
  7. package/lib/document-network-resolver.d.ts +3 -0
  8. package/lib/document-network-resolver.d.ts.map +1 -0
  9. package/lib/document-network-resolver.js +52 -0
  10. package/lib/document-network-resolver.js.map +1 -0
  11. package/lib/entities/document/create-document.d.ts +10 -0
  12. package/lib/entities/document/create-document.d.ts.map +1 -0
  13. package/lib/entities/document/create-document.js +111 -0
  14. package/lib/entities/document/create-document.js.map +1 -0
  15. package/lib/entities/document/document.entity.d.ts +11 -0
  16. package/lib/entities/document/document.entity.d.ts.map +1 -0
  17. package/lib/entities/document/document.entity.js +55 -0
  18. package/lib/entities/document/document.entity.js.map +1 -0
  19. package/lib/entities/document/get-all-documents.d.ts +11 -0
  20. package/lib/entities/document/get-all-documents.d.ts.map +1 -0
  21. package/lib/entities/document/get-all-documents.js +78 -0
  22. package/lib/entities/document/get-all-documents.js.map +1 -0
  23. package/lib/entities/document/get-documens-by-type.d.ts +10 -0
  24. package/lib/entities/document/get-documens-by-type.d.ts.map +1 -0
  25. package/lib/entities/document/get-documens-by-type.js +71 -0
  26. package/lib/entities/document/get-documens-by-type.js.map +1 -0
  27. package/lib/entities/document/get-document-by-id.d.ts +13 -0
  28. package/lib/entities/document/get-document-by-id.d.ts.map +1 -0
  29. package/lib/entities/document/get-document-by-id.js +92 -0
  30. package/lib/entities/document/get-document-by-id.js.map +1 -0
  31. package/lib/entities/document/get-document-correlations.d.ts +10 -0
  32. package/lib/entities/document/get-document-correlations.d.ts.map +1 -0
  33. package/lib/entities/document/get-document-correlations.js +78 -0
  34. package/lib/entities/document/get-document-correlations.js.map +1 -0
  35. package/lib/entities/document/helpers.d.ts +30 -0
  36. package/lib/entities/document/helpers.d.ts.map +1 -0
  37. package/lib/entities/document/helpers.js +196 -0
  38. package/lib/entities/document/helpers.js.map +1 -0
  39. package/lib/entities/document/index.d.ts +10 -0
  40. package/lib/entities/document/index.d.ts.map +1 -0
  41. package/lib/entities/document/index.js +26 -0
  42. package/lib/entities/document/index.js.map +1 -0
  43. package/lib/entities/document/remove-document.d.ts +15 -0
  44. package/lib/entities/document/remove-document.d.ts.map +1 -0
  45. package/lib/entities/document/remove-document.js +94 -0
  46. package/lib/entities/document/remove-document.js.map +1 -0
  47. package/lib/entities/document/update-document.d.ts +10 -0
  48. package/lib/entities/document/update-document.d.ts.map +1 -0
  49. package/lib/entities/document/update-document.js +72 -0
  50. package/lib/entities/document/update-document.js.map +1 -0
  51. package/lib/entities/document-type.entity.d.ts +6 -0
  52. package/lib/entities/document-type.entity.d.ts.map +1 -0
  53. package/lib/entities/document-type.entity.js +32 -0
  54. package/lib/entities/document-type.entity.js.map +1 -0
  55. package/lib/entities/log.entity.d.ts +15 -0
  56. package/lib/entities/log.entity.d.ts.map +1 -0
  57. package/lib/entities/log.entity.js +108 -0
  58. package/lib/entities/log.entity.js.map +1 -0
  59. package/lib/entities/network.entity.d.ts +6 -0
  60. package/lib/entities/network.entity.d.ts.map +1 -0
  61. package/lib/entities/network.entity.js +35 -0
  62. package/lib/entities/network.entity.js.map +1 -0
  63. package/lib/entities/transaction.entity.d.ts +24 -0
  64. package/lib/entities/transaction.entity.d.ts.map +1 -0
  65. package/lib/entities/transaction.entity.js +139 -0
  66. package/lib/entities/transaction.entity.js.map +1 -0
  67. package/lib/entities/wallet.entity.d.ts +10 -0
  68. package/lib/entities/wallet.entity.d.ts.map +1 -0
  69. package/lib/entities/wallet.entity.js +109 -0
  70. package/lib/entities/wallet.entity.js.map +1 -0
  71. package/lib/helpers.d.ts +6 -0
  72. package/lib/helpers.d.ts.map +1 -0
  73. package/lib/helpers.js +98 -0
  74. package/lib/helpers.js.map +1 -0
  75. package/lib/index.d.ts +14 -0
  76. package/lib/index.d.ts.map +1 -0
  77. package/lib/index.js +145 -0
  78. package/lib/index.js.map +1 -0
  79. package/lib/logger.d.ts +14 -0
  80. package/lib/logger.d.ts.map +1 -0
  81. package/lib/logger.js +40 -0
  82. package/lib/logger.js.map +1 -0
  83. package/lib/migration/bootstrap-tables.d.ts +3 -0
  84. package/lib/migration/bootstrap-tables.d.ts.map +1 -0
  85. package/lib/migration/bootstrap-tables.js +8 -0
  86. package/lib/migration/bootstrap-tables.js.map +1 -0
  87. package/lib/migration/index.d.ts +8 -0
  88. package/lib/migration/index.d.ts.map +1 -0
  89. package/lib/migration/index.js +132 -0
  90. package/lib/migration/index.js.map +1 -0
  91. package/lib/migration/migration1/index.d.ts +16 -0
  92. package/lib/migration/migration1/index.d.ts.map +1 -0
  93. package/lib/migration/migration1/index.js +110 -0
  94. package/lib/migration/migration1/index.js.map +1 -0
  95. package/lib/migration/migration1/migrate-v1-data.d.ts +8 -0
  96. package/lib/migration/migration1/migrate-v1-data.d.ts.map +1 -0
  97. package/lib/migration/migration1/migrate-v1-data.js +171 -0
  98. package/lib/migration/migration1/migrate-v1-data.js.map +1 -0
  99. package/lib/migration/migration1/v1-data-store.d.ts +15 -0
  100. package/lib/migration/migration1/v1-data-store.d.ts.map +1 -0
  101. package/lib/migration/migration1/v1-data-store.js +80 -0
  102. package/lib/migration/migration1/v1-data-store.js.map +1 -0
  103. package/lib/migrations/1691498362273-bootstrap.d.ts +7 -0
  104. package/lib/migrations/1691498362273-bootstrap.d.ts.map +1 -0
  105. package/lib/migrations/1691498362273-bootstrap.js +178 -0
  106. package/lib/migrations/1691498362273-bootstrap.js.map +1 -0
  107. package/lib/migrations/index.d.ts +4 -0
  108. package/lib/migrations/index.d.ts.map +1 -0
  109. package/lib/migrations/index.js +5 -0
  110. package/lib/migrations/index.js.map +1 -0
  111. package/lib/migrations-data-source.d.ts +3 -0
  112. package/lib/migrations-data-source.d.ts.map +1 -0
  113. package/lib/migrations-data-source.js +8 -0
  114. package/lib/migrations-data-source.js.map +1 -0
  115. package/lib/typeorm.d.ts +2 -0
  116. package/lib/typeorm.d.ts.map +1 -0
  117. package/lib/typeorm.js +18 -0
  118. package/lib/typeorm.js.map +1 -0
  119. package/lib/types.d.ts +49 -0
  120. package/lib/types.d.ts.map +1 -0
  121. package/lib/types.js +3 -0
  122. package/lib/types.js.map +1 -0
  123. package/package.json +31 -0
  124. package/scripts/publish.sh +3 -0
  125. package/setup-tests.ts +0 -0
  126. package/src/__tests__/index.test.ts +56 -0
  127. package/src/__tests__/v1-data-store.test.ts +24 -0
  128. package/src/configs.ts +28 -0
  129. package/src/document-network-resolver.ts +19 -0
  130. package/src/entities/document/create-document.ts +72 -0
  131. package/src/entities/document/decument.entity.test.ts +135 -0
  132. package/src/entities/document/document.entity.ts +40 -0
  133. package/src/entities/document/get-all-documents.ts +39 -0
  134. package/src/entities/document/get-documens-by-type.ts +30 -0
  135. package/src/entities/document/get-document-by-id.ts +45 -0
  136. package/src/entities/document/get-document-correlations.ts +34 -0
  137. package/src/entities/document/helpers.ts +115 -0
  138. package/src/entities/document/index.ts +9 -0
  139. package/src/entities/document/remove-document.ts +34 -0
  140. package/src/entities/document/update-document.ts +25 -0
  141. package/src/entities/document-type.entity.ts +11 -0
  142. package/src/entities/log.entity.ts +46 -0
  143. package/src/entities/network.entity.ts +14 -0
  144. package/src/entities/transaction.entity.ts +67 -0
  145. package/src/entities/wallet.entity.ts +37 -0
  146. package/src/helpers.ts +52 -0
  147. package/src/index.ts +83 -0
  148. package/src/logger.ts +37 -0
  149. package/src/migration/bootstrap-tables.ts +5 -0
  150. package/src/migration/index.ts +53 -0
  151. package/src/migration/migration1/index.ts +64 -0
  152. package/src/migration/migration1/migrate-v1-data.ts +57 -0
  153. package/src/migration/migration1/v1-data-store.ts +39 -0
  154. package/src/migrations/1691498362273-bootstrap.ts +130 -0
  155. package/src/migrations/index.ts +3 -0
  156. package/src/migrations-data-source.ts +6 -0
  157. package/src/typeorm.ts +1 -0
  158. package/src/types.ts +67 -0
  159. package/test/mock-local-storage.ts +17 -0
  160. package/test/test-utils.ts +23 -0
  161. package/test/wallet.json +209 -0
  162. package/tsconfig.build.json +25 -0
  163. package/tsconfig.build.tsbuildinfo +1 -0
  164. package/tsconfig.json +32 -0
package/LICENSE ADDED
@@ -0,0 +1,39 @@
1
+ The Dock Labs Non-Production License (the “DL-NPL”)
2
+ Copyright (c) 2024 Dock Labs AG.
3
+
4
+ This software and associated documentation files (the "Software") may only be
5
+ used in production, if you (and any entity that you represent) have agreed to,
6
+ and are in compliance with, the Dock Labs Subscription Master Services Agreement
7
+ (MSA), available at https://www.dock.io/master-services-agreement (the “Dock
8
+ Terms”), or other agreement governing the use of the Software, as agreed by you
9
+ and Dock Labs, and otherwise have a valid Dock Labs subscription that is being
10
+ utilized as intended and for its designated purposes.
11
+
12
+ Subject to the foregoing sentence, you are free to modify this Software and
13
+ publish patches to the Software. You agree that Dock Labs and/or its licensors
14
+ (as applicable) retain all right, title and interest in and to all such
15
+ modifications and/or patches, and all such modifications and/or patches may only
16
+ be used, copied, modified, displayed, distributed, or otherwise exploited with a
17
+ valid Dock Labs subscription that is being utilized as intended and for its
18
+ designated purposes. Notwithstanding the foregoing, you may copy and modify the
19
+ Software without obtaining a subscription only for non-production development
20
+ and testing purposes. For the avoidance of doubt, non-production use solely
21
+ consists of internal use of this software within a non-production development or
22
+ test environment which uses fictitious data in non-durable identity credentials.
23
+ You are not granted any other rights beyond what is expressly stated herein.
24
+ Subject to the foregoing, it is forbidden to copy, merge, publish, distribute,
25
+ sublicense, and/or sell the Software.
26
+
27
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
29
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
30
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
31
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33
+
34
+ For all third party components incorporated into the Dock Labs Software, those
35
+ components are licensed under the original license provided by the owner of the
36
+ applicable component.
37
+
38
+ If you have any questions or need further assistance, please contact
39
+ support@dock.io.
package/jest.config.ts ADDED
@@ -0,0 +1,21 @@
1
+ module.exports = {
2
+ testEnvironment: 'node',
3
+ testTimeout: 30000,
4
+ testMatch: [
5
+ "<rootDir>/src/**/!(*.e2e).test.ts"
6
+ ],
7
+ coverageThreshold: {
8
+ global: {
9
+ branches: 10,
10
+ functions: 10,
11
+ lines: 10,
12
+ statements: 10,
13
+ },
14
+ },
15
+ transform: {
16
+ '^.+\\.ts$': 'ts-jest',
17
+ },
18
+ resetMocks: false,
19
+ setupFilesAfterEnv: ['<rootDir>/setup-tests.ts'],
20
+ setupFiles: ['jest-localstorage-mock'],
21
+ };
@@ -0,0 +1,3 @@
1
+ import { DataStoreConfigs } from './types';
2
+ export declare const DEFAULT_CONFIGS: DataStoreConfigs;
3
+ //# sourceMappingURL=configs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../src/configs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAC;AAGzC,eAAO,MAAM,eAAe,EAAE,gBAwB7B,CAAC"}
package/lib/configs.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_CONFIGS = void 0;
4
+ var document_network_resolver_1 = require("./document-network-resolver");
5
+ exports.DEFAULT_CONFIGS = {
6
+ dbType: 'sqlite',
7
+ databasePath: 'dock-wallet-sdk.db',
8
+ documentNetworkResolver: document_network_resolver_1.genericDocumentNetworkResolver,
9
+ networks: [
10
+ {
11
+ name: 'Mainnet',
12
+ id: 'mainnet',
13
+ credentialHostnames: ['creds.dock.io'],
14
+ configs: {
15
+ substrateUrl: 'wss://mainnet-node.dock.io',
16
+ addressPrefix: 22,
17
+ },
18
+ },
19
+ {
20
+ name: 'Testnet',
21
+ id: 'testnet',
22
+ credentialHostnames: ['creds-testnet.dock.io', 'creds-staging.dock.io'],
23
+ configs: {
24
+ substrateUrl: 'wss://knox-1.dock.io',
25
+ addressPrefix: 21,
26
+ },
27
+ },
28
+ ],
29
+ };
30
+ //# sourceMappingURL=configs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configs.js","sourceRoot":"","sources":["../src/configs.ts"],"names":[],"mappings":";;;AACA,yEAA2E;AAE9D,QAAA,eAAe,GAAqB;IAC/C,MAAM,EAAE,QAAQ;IAChB,YAAY,EAAE,oBAAoB;IAClC,uBAAuB,EAAE,0DAA8B;IACvD,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,SAAS;YACf,EAAE,EAAE,SAAS;YACb,mBAAmB,EAAE,CAAC,eAAe,CAAC;YACtC,OAAO,EAAE;gBACP,YAAY,EAAE,4BAA4B;gBAC1C,aAAa,EAAE,EAAE;aAClB;SACF;QACD;YACE,IAAI,EAAE,SAAS;YACf,EAAE,EAAE,SAAS;YACb,mBAAmB,EAAE,CAAC,uBAAuB,EAAE,uBAAuB,CAAC;YACvE,OAAO,EAAE;gBACP,YAAY,EAAE,sBAAsB;gBACpC,aAAa,EAAE,EAAE;aAClB;SACF;KACF;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { DocumentNetworkResolver } from './types';
2
+ export declare const genericDocumentNetworkResolver: DocumentNetworkResolver;
3
+ //# sourceMappingURL=document-network-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-network-resolver.d.ts","sourceRoot":"","sources":["../src/document-network-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,EAIxB,MAAM,SAAS,CAAC;AAIjB,eAAO,MAAM,8BAA8B,EAAE,uBAQ5C,CAAC"}
@@ -0,0 +1,52 @@
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.genericDocumentNetworkResolver = void 0;
40
+ var genericDocumentNetworkResolver = function (_a) {
41
+ var document = _a.document, dataStore = _a.dataStore;
42
+ return __awaiter(void 0, void 0, void 0, function () {
43
+ return __generator(this, function (_b) {
44
+ return [2 /*return*/, {
45
+ networkId: dataStore.networkId,
46
+ isFallback: true,
47
+ }];
48
+ });
49
+ });
50
+ };
51
+ exports.genericDocumentNetworkResolver = genericDocumentNetworkResolver;
52
+ //# sourceMappingURL=document-network-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-network-resolver.js","sourceRoot":"","sources":["../src/document-network-resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,IAAM,8BAA8B,GAA4B,UAAO,EAGtD;QAFtB,QAAQ,cAAA,EACR,SAAS,eAAA;;;YAET,sBAAO;oBACL,SAAS,EAAE,SAAS,CAAC,SAAS;oBAC9B,UAAU,EAAE,IAAI;iBACjB,EAAC;;;CACH,CAAC;AARW,QAAA,8BAA8B,kCAQzC"}
@@ -0,0 +1,10 @@
1
+ import { ContextProps, WalletDocument } from '../../types';
2
+ /**
3
+ * Create document
4
+ * @param dataStore
5
+ * @param json
6
+ */
7
+ export declare function createDocument({ dataStore, json, }: ContextProps & {
8
+ json: any;
9
+ }): Promise<WalletDocument>;
10
+ //# sourceMappingURL=create-document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-document.d.ts","sourceRoot":"","sources":["../../../src/entities/document/create-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,cAAc,EAAC,MAAM,aAAa,CAAC;AAOzD;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EACnC,SAAS,EACT,IAAI,GACL,EAAE,YAAY,GAAG;IAChB,IAAI,EAAE,GAAG,CAAC;CACX,GAAG,OAAO,CAAC,cAAc,CAAC,CAsD1B"}
@@ -0,0 +1,111 @@
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.createDocument = void 0;
40
+ var uuid_1 = require("uuid");
41
+ var document_entity_1 = require("./document.entity");
42
+ var helpers_1 = require("./helpers");
43
+ var get_document_by_id_1 = require("./get-document-by-id");
44
+ var logger_1 = require("../../logger");
45
+ /**
46
+ * Create document
47
+ * @param dataStore
48
+ * @param json
49
+ */
50
+ function createDocument(_a) {
51
+ var dataStore = _a.dataStore, json = _a.json;
52
+ return __awaiter(this, void 0, void 0, function () {
53
+ var existingDocument, _typeRel, networkId, resolution, entity, repository, result;
54
+ return __generator(this, function (_b) {
55
+ switch (_b.label) {
56
+ case 0:
57
+ logger_1.logger.debug("Creating document with id ".concat(json.id, "..."));
58
+ if (!json.id) return [3 /*break*/, 2];
59
+ return [4 /*yield*/, (0, get_document_by_id_1.getDocumentById)({
60
+ dataStore: dataStore,
61
+ id: json.id,
62
+ })];
63
+ case 1:
64
+ existingDocument = _b.sent();
65
+ if (existingDocument) {
66
+ logger_1.logger.debug("Document with id ".concat(json.id, " already exists"));
67
+ throw new Error("Document with id ".concat(json.id, " already exists"));
68
+ }
69
+ _b.label = 2;
70
+ case 2: return [4 /*yield*/, (0, helpers_1.getOrCreateDocumentTypes)({
71
+ dataStore: dataStore,
72
+ types: json.type,
73
+ })];
74
+ case 3:
75
+ _typeRel = _b.sent();
76
+ if (!json.id) {
77
+ json.id = (0, uuid_1.v4)();
78
+ }
79
+ if (!json._networkId) return [3 /*break*/, 4];
80
+ networkId = json._networkId;
81
+ delete json._networkId;
82
+ return [3 /*break*/, 6];
83
+ case 4: return [4 /*yield*/, dataStore.resolveDocumentNetwork({
84
+ document: json,
85
+ dataStore: dataStore,
86
+ })];
87
+ case 5:
88
+ resolution = _b.sent();
89
+ networkId = resolution.networkId;
90
+ _b.label = 6;
91
+ case 6:
92
+ entity = {
93
+ networkId: networkId,
94
+ id: json.id,
95
+ type: json.type,
96
+ _typeRel: _typeRel,
97
+ correlation: json.correlation || [],
98
+ data: JSON.stringify(json),
99
+ };
100
+ repository = dataStore.db.getRepository(document_entity_1.DocumentEntity);
101
+ return [4 /*yield*/, repository.save(entity, helpers_1.saveOptions)];
102
+ case 7:
103
+ result = _b.sent();
104
+ logger_1.logger.debug("Document added to the wallet");
105
+ return [2 /*return*/, result];
106
+ }
107
+ });
108
+ });
109
+ }
110
+ exports.createDocument = createDocument;
111
+ //# sourceMappingURL=create-document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-document.js","sourceRoot":"","sources":["../../../src/entities/document/create-document.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6BAAgC;AAChC,qDAAiD;AACjD,qCAAgE;AAChE,2DAAqD;AACrD,uCAAoC;AAEpC;;;;GAIG;AACH,SAAsB,cAAc,CAAC,EAKpC;QAJC,SAAS,eAAA,EACT,IAAI,UAAA;;;;;;oBAIJ,eAAM,CAAC,KAAK,CAAC,oCAA6B,IAAI,CAAC,EAAE,QAAK,CAAC,CAAC;yBAEpD,IAAI,CAAC,EAAE,EAAP,wBAAO;oBACgB,qBAAM,IAAA,oCAAe,EAAC;4BAC7C,SAAS,WAAA;4BACT,EAAE,EAAE,IAAI,CAAC,EAAE;yBACZ,CAAC,EAAA;;oBAHI,gBAAgB,GAAG,SAGvB;oBAEF,IAAI,gBAAgB,EAAE;wBACpB,eAAM,CAAC,KAAK,CAAC,2BAAoB,IAAI,CAAC,EAAE,oBAAiB,CAAC,CAAC;wBAC3D,MAAM,IAAI,KAAK,CAAC,2BAAoB,IAAI,CAAC,EAAE,oBAAiB,CAAC,CAAC;qBAC/D;;wBAGc,qBAAM,IAAA,kCAAwB,EAAC;wBAC9C,SAAS,WAAA;wBACT,KAAK,EAAE,IAAI,CAAC,IAAI;qBACjB,CAAC,EAAA;;oBAHI,QAAQ,GAAG,SAGf;oBAEF,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE;wBACZ,IAAI,CAAC,EAAE,GAAG,IAAA,SAAI,GAAE,CAAC;qBAClB;yBAIG,IAAI,CAAC,UAAU,EAAf,wBAAe;oBACjB,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;oBAC5B,OAAO,IAAI,CAAC,UAAU,CAAC;;wBAEJ,qBAAM,SAAS,CAAC,sBAAsB,CAAC;wBACxD,QAAQ,EAAE,IAAI;wBACd,SAAS,WAAA;qBACV,CAAC,EAAA;;oBAHI,UAAU,GAAG,SAGjB;oBAEF,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;;;oBAG7B,MAAM,GAAmB;wBAC7B,SAAS,WAAA;wBACT,EAAE,EAAE,IAAI,CAAC,EAAE;wBACX,IAAI,EAAE,IAAI,CAAC,IAAI;wBACf,QAAQ,UAAA;wBACR,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE;wBACnC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;qBAC3B,CAAC;oBAEI,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC,aAAa,CAAC,gCAAc,CAAC,CAAC;oBAE/C,qBAAM,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,qBAAW,CAAC,EAAA;;oBAAnD,MAAM,GAAG,SAA0C;oBAEzD,eAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;oBAE7C,sBAAO,MAAM,EAAC;;;;CACf;AA3DD,wCA2DC"}
@@ -0,0 +1,11 @@
1
+ import { Relation } from '../../typeorm';
2
+ import { DocumentTypeEntity } from '../document-type.entity';
3
+ export declare class DocumentEntity {
4
+ id: string;
5
+ networkId: string;
6
+ type: string[];
7
+ _typeRel: Relation<DocumentTypeEntity[]>;
8
+ correlation: string[];
9
+ data: string;
10
+ }
11
+ //# sourceMappingURL=document.entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.entity.d.ts","sourceRoot":"","sources":["../../../src/entities/document/document.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,QAAQ,EACT,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,kBAAkB,EAAC,MAAM,yBAAyB,CAAC;AAE3D,qBACa,cAAc;IAEzB,EAAE,EAAE,MAAM,CAAC;IAKX,SAAS,EAAE,MAAM,CAAC;IAGlB,IAAI,EAAE,MAAM,EAAE,CAAC;IAQf,QAAQ,EAAE,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAMzC,WAAW,EAAE,MAAM,EAAE,CAAC;IAGtB,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -0,0 +1,55 @@
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 __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DocumentEntity = void 0;
13
+ var typeorm_1 = require("../../typeorm");
14
+ var document_type_entity_1 = require("../document-type.entity");
15
+ var DocumentEntity = /** @class */ (function () {
16
+ function DocumentEntity() {
17
+ }
18
+ __decorate([
19
+ (0, typeorm_1.PrimaryColumn)('text'),
20
+ __metadata("design:type", String)
21
+ ], DocumentEntity.prototype, "id", void 0);
22
+ __decorate([
23
+ (0, typeorm_1.Column)('text', {
24
+ nullable: true,
25
+ }),
26
+ __metadata("design:type", String)
27
+ ], DocumentEntity.prototype, "networkId", void 0);
28
+ __decorate([
29
+ (0, typeorm_1.Column)('simple-array'),
30
+ __metadata("design:type", Array)
31
+ ], DocumentEntity.prototype, "type", void 0);
32
+ __decorate([
33
+ (0, typeorm_1.ManyToMany)(function () { return document_type_entity_1.DocumentTypeEntity; }, function (type) { return type === null || type === void 0 ? void 0 : type.documents; }, {
34
+ cascade: ['insert'],
35
+ eager: true,
36
+ nullable: true,
37
+ }),
38
+ (0, typeorm_1.JoinTable)(),
39
+ __metadata("design:type", Object)
40
+ ], DocumentEntity.prototype, "_typeRel", void 0);
41
+ __decorate([
42
+ (0, typeorm_1.Column)('simple-array'),
43
+ __metadata("design:type", Array)
44
+ ], DocumentEntity.prototype, "correlation", void 0);
45
+ __decorate([
46
+ (0, typeorm_1.Column)('blob'),
47
+ __metadata("design:type", String)
48
+ ], DocumentEntity.prototype, "data", void 0);
49
+ DocumentEntity = __decorate([
50
+ (0, typeorm_1.Entity)()
51
+ ], DocumentEntity);
52
+ return DocumentEntity;
53
+ }());
54
+ exports.DocumentEntity = DocumentEntity;
55
+ //# sourceMappingURL=document.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.entity.js","sourceRoot":"","sources":["../../../src/entities/document/document.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAOuB;AACvB,gEAA2D;AAG3D;IAAA;IA4BA,CAAC;IA1BC;QADC,IAAA,uBAAa,EAAC,MAAM,CAAC;;8CACX;IAKX;QAHC,IAAA,gBAAM,EAAC,MAAM,EAAE;YACd,QAAQ,EAAE,IAAI;SACf,CAAC;;qDACgB;IAGlB;QADC,IAAA,gBAAM,EAAC,cAAc,CAAC;;gDACR;IAQf;QANC,IAAA,oBAAU,EAAC,cAAM,OAAA,yCAAkB,EAAlB,CAAkB,EAAE,UAAA,IAAI,IAAI,OAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,EAAf,CAAe,EAAE;YAC7D,OAAO,EAAE,CAAC,QAAQ,CAAC;YACnB,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,IAAI;SACf,CAAC;QACD,IAAA,mBAAS,GAAE;;oDAC6B;IAMzC;QADC,IAAA,gBAAM,EAAC,cAAc,CAAC;;uDACD;IAGtB;QADC,IAAA,gBAAM,EAAC,MAAM,CAAC;;gDACF;IA3BF,cAAc;QAD1B,IAAA,gBAAM,GAAE;OACI,cAAc,CA4B1B;IAAD,qBAAC;CAAA,AA5BD,IA4BC;AA5BY,wCAAc"}
@@ -0,0 +1,11 @@
1
+ import { WalletDocument, DataStore } from '../../types';
2
+ /**
3
+ * Get all documents
4
+ *
5
+ * @param dataStore
6
+ */
7
+ export declare function getAllDocuments({ dataStore, allNetworks, }: {
8
+ dataStore: DataStore;
9
+ allNetworks?: boolean;
10
+ }): Promise<WalletDocument[]>;
11
+ //# sourceMappingURL=get-all-documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-all-documents.d.ts","sourceRoot":"","sources":["../../../src/entities/document/get-all-documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC;AActD;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,EACpC,SAAS,EACT,WAAW,GACZ,EAAE;IACD,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAa5B"}
@@ -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.getAllDocuments = void 0;
40
+ var helpers_1 = require("./helpers");
41
+ var document_entity_1 = require("./document.entity");
42
+ function toWalletDocumentExpanded(entity) {
43
+ var result = (0, helpers_1.toWalletDocument)(entity);
44
+ if (result) {
45
+ result['_networkId'] = entity.networkId;
46
+ }
47
+ return result;
48
+ }
49
+ /**
50
+ * Get all documents
51
+ *
52
+ * @param dataStore
53
+ */
54
+ function getAllDocuments(_a) {
55
+ var dataStore = _a.dataStore, allNetworks = _a.allNetworks;
56
+ return __awaiter(this, void 0, void 0, function () {
57
+ var repository, entities, mapDocument;
58
+ return __generator(this, function (_b) {
59
+ switch (_b.label) {
60
+ case 0:
61
+ repository = dataStore.db.getRepository(document_entity_1.DocumentEntity);
62
+ return [4 /*yield*/, repository.find({
63
+ where: allNetworks
64
+ ? {}
65
+ : {
66
+ networkId: dataStore.networkId,
67
+ },
68
+ })];
69
+ case 1:
70
+ entities = _b.sent();
71
+ mapDocument = allNetworks ? toWalletDocumentExpanded : helpers_1.toWalletDocument;
72
+ return [2 /*return*/, Promise.all(entities.map(mapDocument))];
73
+ }
74
+ });
75
+ });
76
+ }
77
+ exports.getAllDocuments = getAllDocuments;
78
+ //# sourceMappingURL=get-all-documents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-all-documents.js","sourceRoot":"","sources":["../../../src/entities/document/get-all-documents.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAA2C;AAC3C,qDAAiD;AAEjD,SAAS,wBAAwB,CAAC,MAAsB;IACtD,IAAM,MAAM,GAAG,IAAA,0BAAgB,EAAC,MAAM,CAAC,CAAC;IAExC,IAAI,MAAM,EAAE;QACV,MAAM,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC;KACzC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAsB,eAAe,CAAC,EAMrC;QALC,SAAS,eAAA,EACT,WAAW,iBAAA;;;;;;oBAKL,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC,aAAa,CAAC,gCAAc,CAAC,CAAC;oBAC7C,qBAAM,UAAU,CAAC,IAAI,CAAC;4BACrC,KAAK,EAAE,WAAW;gCAChB,CAAC,CAAC,EAAE;gCACJ,CAAC,CAAC;oCACE,SAAS,EAAE,SAAS,CAAC,SAAS;iCAC/B;yBACN,CAAC,EAAA;;oBANI,QAAQ,GAAG,SAMf;oBAEI,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,0BAAgB,CAAC;oBAE9E,sBAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAC;;;;CAC/C;AAnBD,0CAmBC"}
@@ -0,0 +1,10 @@
1
+ import { ContextProps, WalletDocument } from '../../types';
2
+ /**
3
+ * Get documents by type
4
+ * @param dataStore
5
+ * @param type
6
+ */
7
+ export declare function getDocumentsByType({ dataStore, type, }: ContextProps & {
8
+ type: string;
9
+ }): Promise<WalletDocument[]>;
10
+ //# sourceMappingURL=get-documens-by-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-documens-by-type.d.ts","sourceRoot":"","sources":["../../../src/entities/document/get-documens-by-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,cAAc,EAAC,MAAM,aAAa,CAAC;AAKzD;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,SAAS,EACT,IAAI,GACL,EAAE,YAAY,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAc5B"}
@@ -0,0 +1,71 @@
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.getDocumentsByType = void 0;
40
+ var document_entity_1 = require("./document.entity");
41
+ var helpers_1 = require("./helpers");
42
+ /**
43
+ * Get documents by type
44
+ * @param dataStore
45
+ * @param type
46
+ */
47
+ function getDocumentsByType(_a) {
48
+ var dataStore = _a.dataStore, type = _a.type;
49
+ return __awaiter(this, void 0, void 0, function () {
50
+ var repository, documents, result;
51
+ return __generator(this, function (_b) {
52
+ switch (_b.label) {
53
+ case 0:
54
+ repository = dataStore.db.getRepository(document_entity_1.DocumentEntity);
55
+ documents = repository
56
+ .createQueryBuilder('document')
57
+ .leftJoinAndSelect('document._typeRel', 'documentType')
58
+ .where('documentType.id = :type', { type: type })
59
+ .andWhere('document.networkId = :networkId', {
60
+ networkId: dataStore.networkId,
61
+ });
62
+ return [4 /*yield*/, documents.getMany()];
63
+ case 1:
64
+ result = _b.sent();
65
+ return [2 /*return*/, result.map(helpers_1.toWalletDocument)];
66
+ }
67
+ });
68
+ });
69
+ }
70
+ exports.getDocumentsByType = getDocumentsByType;
71
+ //# sourceMappingURL=get-documens-by-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-documens-by-type.js","sourceRoot":"","sources":["../../../src/entities/document/get-documens-by-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qDAAiD;AAEjD,qCAA2C;AAE3C;;;;GAIG;AACH,SAAsB,kBAAkB,CAAC,EAKxC;QAJC,SAAS,eAAA,EACT,IAAI,UAAA;;;;;;oBAIE,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC,aAAa,CAAC,gCAAc,CAAC,CAAC;oBAExD,SAAS,GAAG,UAAU;yBACzB,kBAAkB,CAAC,UAAU,CAAC;yBAC9B,iBAAiB,CAAC,mBAAmB,EAAE,cAAc,CAAC;yBACtD,KAAK,CAAC,yBAAyB,EAAE,EAAC,IAAI,MAAA,EAAC,CAAC;yBACxC,QAAQ,CAAC,iCAAiC,EAAE;wBAC3C,SAAS,EAAE,SAAS,CAAC,SAAS;qBAC/B,CAAC,CAAC;oBAEU,qBAAM,SAAS,CAAC,OAAO,EAAE,EAAA;;oBAAlC,MAAM,GAAG,SAAyB;oBAExC,sBAAO,MAAM,CAAC,GAAG,CAAC,0BAAgB,CAAC,EAAC;;;;CACrC;AAnBD,gDAmBC"}
@@ -0,0 +1,13 @@
1
+ import { ContextProps, WalletDocument } from '../../types';
2
+ /**
3
+ * Get document by id
4
+ * @param dataStore
5
+ * @param id
6
+ */
7
+ export declare function getDocumentById({ dataStore, id, }: ContextProps & {
8
+ id: string;
9
+ }): Promise<WalletDocument>;
10
+ export declare function getDocumentsById({ dataStore, idList, }: ContextProps & {
11
+ idList: string[];
12
+ }): Promise<WalletDocument>;
13
+ //# sourceMappingURL=get-document-by-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-document-by-id.d.ts","sourceRoot":"","sources":["../../../src/entities/document/get-document-by-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,cAAc,EAAC,MAAM,aAAa,CAAC;AAKzD;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,EACpC,SAAS,EACT,EAAE,GACH,EAAE,YAAY,GAAG;IAChB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,cAAc,CAAC,CAW1B;AAED,wBAAsB,gBAAgB,CAAC,EACrC,SAAS,EACT,MAAM,GACP,EAAE,YAAY,GAAG;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,GAAG,OAAO,CAAC,cAAc,CAAC,CAW1B"}