@prosopo/database 0.1.16 → 0.1.18
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/package.json +35 -34
- package/dist/databases/index.d.ts +0 -7
- package/dist/databases/index.d.ts.map +0 -1
- package/dist/databases/index.js +0 -24
- package/dist/databases/index.js.map +0 -1
- package/dist/databases/mongo.d.ts +0 -143
- package/dist/databases/mongo.d.ts.map +0 -1
- package/dist/databases/mongo.js +0 -566
- package/dist/databases/mongo.js.map +0 -1
- package/dist/databases/mongoMemory.d.ts +0 -6
- package/dist/databases/mongoMemory.d.ts.map +0 -1
- package/dist/databases/mongoMemory.js +0 -15
- package/dist/databases/mongoMemory.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -5
- package/dist/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
2
|
+
"name": "@prosopo/database",
|
|
3
|
+
"version": "0.1.18",
|
|
4
|
+
"description": "Prosopo database plugins for provider",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"clean": "tsc --build --clean",
|
|
9
|
+
"build": "tsc --build --verbose",
|
|
10
|
+
"lint": "npx eslint .",
|
|
11
|
+
"lint:fix": "npx eslint . --fix --config ../../.eslintrc.js"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+ssh://git@github.com/prosopo/captcha.git"
|
|
16
|
+
},
|
|
17
|
+
"author": "Prosopo Limited",
|
|
18
|
+
"license": "Apache-2.0",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/prosopo/captcha/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/prosopo/captcha#readme",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@prosopo/common": "^0.1.18",
|
|
25
|
+
"@prosopo/types": "^0.1.18",
|
|
26
|
+
"@prosopo/types-database": "^0.1.18",
|
|
27
|
+
"mongodb": "5.8.0",
|
|
28
|
+
"mongodb-memory-server": "^8.7.2",
|
|
29
|
+
"mongoose": "^7.3.3",
|
|
30
|
+
"zod": "^3.17.9"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"tslib": "^2.6.2",
|
|
34
|
+
"typescript": "^5.1.6"
|
|
35
|
+
},
|
|
36
|
+
"sideEffects": false
|
|
36
37
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/databases/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,IAAI,aAAa,EAAE,MAAM,SAAS,CAAA;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,eAAO,MAAM,SAAS;;;CAGrB,CAAA"}
|
package/dist/databases/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Databases = void 0;
|
|
4
|
-
// Copyright 2021-2022 Prosopo (UK) Ltd.
|
|
5
|
-
//
|
|
6
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
// you may not use this file except in compliance with the License.
|
|
8
|
-
// You may obtain a copy of the License at
|
|
9
|
-
//
|
|
10
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
//
|
|
12
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
// See the License for the specific language governing permissions and
|
|
16
|
-
// limitations under the License.
|
|
17
|
-
const types_1 = require("@prosopo/types");
|
|
18
|
-
const mongo_1 = require("./mongo");
|
|
19
|
-
const mongoMemory_1 = require("./mongoMemory");
|
|
20
|
-
exports.Databases = {
|
|
21
|
-
[types_1.DatabaseTypes.Values.mongo]: mongo_1.ProsopoDatabase,
|
|
22
|
-
[types_1.DatabaseTypes.Values.mongoMemory]: mongoMemory_1.MongoMemoryDatabase,
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/databases/index.ts"],"names":[],"mappings":";;;AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,0CAA8C;AAC9C,mCAA0D;AAC1D,+CAAmD;AACtC,QAAA,SAAS,GAAG;IACrB,CAAC,qBAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,uBAAa;IAC3C,CAAC,qBAAa,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,iCAAmB;CAC1D,CAAA"}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
/// <reference types="mongoose/types/connection" />
|
|
2
|
-
import { Captcha, CaptchaSolution, CaptchaStates, DatasetBase, DatasetWithIds, DatasetWithIdsAndTree, PendingCaptchaRequest, ScheduledTaskNames, ScheduledTaskResult, ScheduledTaskStatus } from '@prosopo/types';
|
|
3
|
-
import { Database, ScheduledTaskRecord, Tables, UserCommitmentRecord, UserSolutionRecord } from '@prosopo/types-database';
|
|
4
|
-
import { ArgumentTypes } from '@prosopo/types';
|
|
5
|
-
import { AsyncFactory, Logger } from '@prosopo/common';
|
|
6
|
-
import { DeleteResult } from 'mongodb';
|
|
7
|
-
import { Connection } from 'mongoose';
|
|
8
|
-
/**
|
|
9
|
-
* Returns the Database object through which Providers can put and get captchas
|
|
10
|
-
* @param {string} url The database endpoint
|
|
11
|
-
* @param {string} dbname The database name
|
|
12
|
-
* @return {ProsopoDatabase} Database layer
|
|
13
|
-
*/
|
|
14
|
-
export declare class ProsopoDatabase extends AsyncFactory implements Database {
|
|
15
|
-
url: string;
|
|
16
|
-
tables?: Tables;
|
|
17
|
-
dbname: string;
|
|
18
|
-
connection?: Connection;
|
|
19
|
-
logger: Logger;
|
|
20
|
-
init(url: string, dbname: string, logger: Logger, authSource?: string): Promise<this>;
|
|
21
|
-
/**
|
|
22
|
-
* @description Connect to the database and set the various tables
|
|
23
|
-
*/
|
|
24
|
-
connect(): Promise<void>;
|
|
25
|
-
/** Close connection to the database */
|
|
26
|
-
close(): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* @description Load a dataset to the database
|
|
29
|
-
* @param {Dataset} dataset
|
|
30
|
-
*/
|
|
31
|
-
storeDataset(dataset: DatasetWithIdsAndTree): Promise<void>;
|
|
32
|
-
/** @description Get a dataset from the database
|
|
33
|
-
* @param {string} datasetId
|
|
34
|
-
*/
|
|
35
|
-
getDataset(datasetId: string): Promise<DatasetWithIds>;
|
|
36
|
-
/**
|
|
37
|
-
* @description Get random captchas that are solved or not solved
|
|
38
|
-
* @param {boolean} solved `true` when captcha is solved
|
|
39
|
-
* @param {string} datasetId the id of the data set
|
|
40
|
-
* @param {number} size the number of records to be returned
|
|
41
|
-
*/
|
|
42
|
-
getRandomCaptcha(solved: boolean, datasetId: ArgumentTypes.Hash, size?: number): Promise<Captcha[] | undefined>;
|
|
43
|
-
/**
|
|
44
|
-
* @description Get captchas by id
|
|
45
|
-
* @param {string[]} captchaId
|
|
46
|
-
*/
|
|
47
|
-
getCaptchaById(captchaId: string[]): Promise<Captcha[] | undefined>;
|
|
48
|
-
/**
|
|
49
|
-
* @description Update a captcha
|
|
50
|
-
* @param {Captcha} captcha
|
|
51
|
-
* @param {string} datasetId the id of the data set
|
|
52
|
-
*/
|
|
53
|
-
updateCaptcha(captcha: Captcha, datasetId: ArgumentTypes.Hash): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* @description Remove captchas
|
|
56
|
-
*/
|
|
57
|
-
removeCaptchas(captchaIds: string[]): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* @description Get a dataset by Id
|
|
60
|
-
*/
|
|
61
|
-
getDatasetDetails(datasetId: ArgumentTypes.Hash): Promise<DatasetBase>;
|
|
62
|
-
/**
|
|
63
|
-
* @description Store a Dapp User's captcha solution commitment
|
|
64
|
-
*/
|
|
65
|
-
storeDappUserSolution(captchas: CaptchaSolution[], commit: UserCommitmentRecord): Promise<void>;
|
|
66
|
-
/** @description Get processed Dapp User captcha solutions from the user solution table
|
|
67
|
-
*/
|
|
68
|
-
getProcessedDappUserSolutions(): Promise<UserSolutionRecord[]>;
|
|
69
|
-
/** @description Get processed Dapp User captcha commitments from the commitments table
|
|
70
|
-
*/
|
|
71
|
-
getProcessedDappUserCommitments(): Promise<UserCommitmentRecord[]>;
|
|
72
|
-
/** @description Remove processed Dapp User captcha solutions from the user solution table
|
|
73
|
-
*/
|
|
74
|
-
removeProcessedDappUserSolutions(commitmentIds: string[]): Promise<DeleteResult | undefined>;
|
|
75
|
-
/** @description Remove processed Dapp User captcha commitments from the user commitments table
|
|
76
|
-
*/
|
|
77
|
-
removeProcessedDappUserCommitments(commitmentIds: string[]): Promise<DeleteResult | undefined>;
|
|
78
|
-
/**
|
|
79
|
-
* @description Store a Dapp User's pending record
|
|
80
|
-
*/
|
|
81
|
-
storeDappUserPending(userAccount: string, requestHash: string, salt: string, deadlineTimestamp: number, requestedAtBlock: number): Promise<void>;
|
|
82
|
-
/**
|
|
83
|
-
* @description Get a Dapp user's pending record
|
|
84
|
-
*/
|
|
85
|
-
getDappUserPending(requestHash: string): Promise<PendingCaptchaRequest>;
|
|
86
|
-
/**
|
|
87
|
-
* @description Update a Dapp User's pending record
|
|
88
|
-
*/
|
|
89
|
-
updateDappUserPendingStatus(userAccount: string, requestHash: string, approve: boolean): Promise<void>;
|
|
90
|
-
/**
|
|
91
|
-
* @description Get all unsolved captchas
|
|
92
|
-
*/
|
|
93
|
-
getAllCaptchasByDatasetId(datasetId: string, state?: CaptchaStates): Promise<Captcha[] | undefined>;
|
|
94
|
-
/**
|
|
95
|
-
* @description Get all dapp user solutions by captchaIds
|
|
96
|
-
*/
|
|
97
|
-
getAllDappUserSolutions(captchaId: string[]): Promise<UserSolutionRecord[] | undefined>;
|
|
98
|
-
getDatasetIdWithSolvedCaptchasOfSizeN(solvedCaptchaCount: any): Promise<string>;
|
|
99
|
-
getRandomSolvedCaptchasFromSingleDataset(datasetId: string, size: number): Promise<CaptchaSolution[]>;
|
|
100
|
-
/**
|
|
101
|
-
* @description Get dapp user solution by ID
|
|
102
|
-
* @param {string[]} commitmentId
|
|
103
|
-
*/
|
|
104
|
-
getDappUserSolutionById(commitmentId: string): Promise<UserSolutionRecord | undefined>;
|
|
105
|
-
/**
|
|
106
|
-
* @description Get dapp user commitment by user account
|
|
107
|
-
* @param commitmentId
|
|
108
|
-
*/
|
|
109
|
-
getDappUserCommitmentById(commitmentId: string): Promise<UserCommitmentRecord | undefined>;
|
|
110
|
-
/**
|
|
111
|
-
* @description Get dapp user commitment by user account
|
|
112
|
-
* @param {string[]} userAccount
|
|
113
|
-
*/
|
|
114
|
-
getDappUserCommitmentByAccount(userAccount: string): Promise<UserCommitmentRecord[]>;
|
|
115
|
-
/**
|
|
116
|
-
* @description Approve a dapp user's solution
|
|
117
|
-
* @param {string[]} commitmentId
|
|
118
|
-
*/
|
|
119
|
-
approveDappUserCommitment(commitmentId: string): Promise<void>;
|
|
120
|
-
/**
|
|
121
|
-
* @description Flag a dapp user's solutions as used by calculated solution
|
|
122
|
-
* @param {string[]} captchaIds
|
|
123
|
-
*/
|
|
124
|
-
flagUsedDappUserSolutions(captchaIds: string[]): Promise<void>;
|
|
125
|
-
/**
|
|
126
|
-
* @description Flag dapp users' commitments as used by calculated solution
|
|
127
|
-
* @param {string[]} commitmentIds
|
|
128
|
-
*/
|
|
129
|
-
flagUsedDappUserCommitments(commitmentIds: string[]): Promise<void>;
|
|
130
|
-
/**
|
|
131
|
-
* @description Get the last batch commit time or return 0 if none
|
|
132
|
-
*/
|
|
133
|
-
getLastBatchCommitTime(): Promise<Date>;
|
|
134
|
-
/**
|
|
135
|
-
* @description Get the last batch commit time or return 0 if none
|
|
136
|
-
*/
|
|
137
|
-
getLastScheduledTask(task: ScheduledTaskNames): Promise<ScheduledTaskRecord | undefined>;
|
|
138
|
-
/**
|
|
139
|
-
* @description Store the status of a scheduled task and an optional result
|
|
140
|
-
*/
|
|
141
|
-
storeScheduledTaskStatus(taskId: `0x${string}`, task: ScheduledTaskNames, status: ScheduledTaskStatus, result?: ScheduledTaskResult): Promise<void>;
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=mongo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongo.d.ts","sourceRoot":"","sources":["../../src/databases/mongo.ts"],"names":[],"mappings":";AAcA,OAAO,EACH,OAAO,EACP,eAAe,EACf,aAAa,EAEb,WAAW,EACX,cAAc,EACd,qBAAqB,EAErB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAEH,QAAQ,EAGR,mBAAmB,EAKnB,MAAM,EACN,oBAA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: true });
|
|
3
|
-
exports.ProsopoDatabase = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
6
|
-
// Copyright 2021-2022 Prosopo (UK) Ltd.
|
|
7
|
-
//
|
|
8
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
-
// you may not use this file except in compliance with the License.
|
|
10
|
-
// You may obtain a copy of the License at
|
|
11
|
-
//
|
|
12
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
//
|
|
14
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
15
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
-
// See the License for the specific language governing permissions and
|
|
18
|
-
// limitations under the License.
|
|
19
|
-
const types_1 = require("@prosopo/types");
|
|
20
|
-
const types_database_1 = require("@prosopo/types-database");
|
|
21
|
-
const util_1 = require("@polkadot/util");
|
|
22
|
-
const common_1 = require("@prosopo/common");
|
|
23
|
-
const mongoose_1 = tslib_1.__importDefault(require("mongoose"));
|
|
24
|
-
mongoose_1.default.set('strictQuery', false);
|
|
25
|
-
// mongodb://username:password@127.0.0.1:27017
|
|
26
|
-
const DEFAULT_ENDPOINT = 'mongodb://127.0.0.1:27017';
|
|
27
|
-
/**
|
|
28
|
-
* Returns the Database object through which Providers can put and get captchas
|
|
29
|
-
* @param {string} url The database endpoint
|
|
30
|
-
* @param {string} dbname The database name
|
|
31
|
-
* @return {ProsopoDatabase} Database layer
|
|
32
|
-
*/
|
|
33
|
-
class ProsopoDatabase extends common_1.AsyncFactory {
|
|
34
|
-
url;
|
|
35
|
-
tables;
|
|
36
|
-
dbname;
|
|
37
|
-
connection;
|
|
38
|
-
logger;
|
|
39
|
-
async init(url, dbname, logger, authSource) {
|
|
40
|
-
const authSourceString = authSource ? `?authSource=${authSource}` : '';
|
|
41
|
-
const separator = url.slice(-1) === '/' ? '' : '/';
|
|
42
|
-
this.url = `${url || DEFAULT_ENDPOINT}${separator}${dbname}${authSourceString}`;
|
|
43
|
-
this.dbname = dbname;
|
|
44
|
-
this.logger = logger;
|
|
45
|
-
return this;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* @description Connect to the database and set the various tables
|
|
49
|
-
*/
|
|
50
|
-
async connect() {
|
|
51
|
-
return new Promise((resolve, reject) => {
|
|
52
|
-
if (this.connection) {
|
|
53
|
-
resolve();
|
|
54
|
-
}
|
|
55
|
-
this.logger.info(`Mongo url: ${this.url}`);
|
|
56
|
-
this.connection = mongoose_1.default.createConnection(this.url, { dbName: this.dbname });
|
|
57
|
-
this.tables = {
|
|
58
|
-
captcha: this.connection.models.Captcha || this.connection.model('Captcha', types_database_1.CaptchaRecordSchema),
|
|
59
|
-
dataset: this.connection.models.Dataset || this.connection.model('Dataset', types_database_1.DatasetRecordSchema),
|
|
60
|
-
solution: this.connection.models.Solution || this.connection.model('Solution', types_database_1.SolutionRecordSchema),
|
|
61
|
-
commitment: this.connection.models.UserCommitment ||
|
|
62
|
-
this.connection.model('UserCommitment', types_database_1.UserCommitmentRecordSchema),
|
|
63
|
-
usersolution: this.connection.models.UserSolution ||
|
|
64
|
-
this.connection.model('UserSolution', types_database_1.UserSolutionRecordSchema),
|
|
65
|
-
pending: this.connection.models.Pending || this.connection.model('Pending', types_database_1.PendingRecordSchema),
|
|
66
|
-
scheduler: this.connection.models.Scheduler || this.connection.model('Scheduler', types_database_1.ScheduledTaskRecordSchema),
|
|
67
|
-
};
|
|
68
|
-
this.connection.once('open', resolve).on('error', (e) => {
|
|
69
|
-
this.logger.warn(`mongoose connection error`);
|
|
70
|
-
if (e.message.code === 'ETIMEDOUT') {
|
|
71
|
-
this.logger.error(e);
|
|
72
|
-
mongoose_1.default.connect(this.url);
|
|
73
|
-
}
|
|
74
|
-
this.logger.error(e);
|
|
75
|
-
reject(new common_1.ProsopoEnvError(e, 'DATABASE.CONNECT_ERROR', {}, this.url));
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
/** Close connection to the database */
|
|
80
|
-
async close() {
|
|
81
|
-
this.logger.info(`Closing connection to ${this.url}`);
|
|
82
|
-
await new Promise(async (resolve, reject) => {
|
|
83
|
-
mongoose_1.default.connection
|
|
84
|
-
.close()
|
|
85
|
-
.then(() => {
|
|
86
|
-
this.logger.info(`Connection to ${this.url} closed`);
|
|
87
|
-
resolve();
|
|
88
|
-
})
|
|
89
|
-
.catch(reject);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* @description Load a dataset to the database
|
|
94
|
-
* @param {Dataset} dataset
|
|
95
|
-
*/
|
|
96
|
-
async storeDataset(dataset) {
|
|
97
|
-
try {
|
|
98
|
-
const parsedDataset = types_1.DatasetWithIdsAndTreeSchema.parse(dataset);
|
|
99
|
-
const datasetDoc = {
|
|
100
|
-
datasetId: parsedDataset.datasetId,
|
|
101
|
-
datasetContentId: parsedDataset.datasetContentId,
|
|
102
|
-
format: parsedDataset.format,
|
|
103
|
-
contentTree: parsedDataset.contentTree,
|
|
104
|
-
solutionTree: parsedDataset.solutionTree,
|
|
105
|
-
};
|
|
106
|
-
await this.tables?.dataset.updateOne({ datasetId: parsedDataset.datasetId }, { $set: datasetDoc }, { upsert: true });
|
|
107
|
-
// put the dataset id on each of the captcha docs and remove the solution
|
|
108
|
-
const captchaDocs = parsedDataset.captchas.map(({ solution, ...captcha }, index) => ({
|
|
109
|
-
...captcha,
|
|
110
|
-
datasetId: parsedDataset.datasetId,
|
|
111
|
-
datasetContentId: parsedDataset.datasetContentId,
|
|
112
|
-
index,
|
|
113
|
-
solved: !!solution?.length,
|
|
114
|
-
}));
|
|
115
|
-
// create a bulk upsert operation and execute
|
|
116
|
-
if (captchaDocs.length) {
|
|
117
|
-
await this.tables?.captcha.bulkWrite(captchaDocs.map((captchaDoc) => ({
|
|
118
|
-
updateOne: {
|
|
119
|
-
filter: { captchaId: captchaDoc.captchaId },
|
|
120
|
-
update: { $set: captchaDoc },
|
|
121
|
-
upsert: true,
|
|
122
|
-
},
|
|
123
|
-
})));
|
|
124
|
-
}
|
|
125
|
-
// insert any captcha solutions into the solutions collection
|
|
126
|
-
const captchaSolutionDocs = parsedDataset.captchas
|
|
127
|
-
.filter(({ solution }) => solution?.length)
|
|
128
|
-
.map((captcha) => ({
|
|
129
|
-
captchaId: captcha.captchaId,
|
|
130
|
-
captchaContentId: captcha.captchaContentId,
|
|
131
|
-
solution: captcha.solution,
|
|
132
|
-
salt: captcha.salt,
|
|
133
|
-
datasetId: parsedDataset.datasetId,
|
|
134
|
-
datasetContentId: parsedDataset.datasetContentId,
|
|
135
|
-
}));
|
|
136
|
-
// create a bulk upsert operation and execute
|
|
137
|
-
if (captchaSolutionDocs.length) {
|
|
138
|
-
await this.tables?.solution.bulkWrite(captchaSolutionDocs.map((captchaSolutionDoc) => ({
|
|
139
|
-
updateOne: {
|
|
140
|
-
filter: { captchaId: captchaSolutionDoc.captchaId },
|
|
141
|
-
update: { $set: captchaSolutionDoc },
|
|
142
|
-
upsert: true,
|
|
143
|
-
},
|
|
144
|
-
})));
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
catch (err) {
|
|
148
|
-
throw new common_1.ProsopoEnvError(err, 'DATABASE.DATASET_LOAD_FAILED');
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
/** @description Get a dataset from the database
|
|
152
|
-
* @param {string} datasetId
|
|
153
|
-
*/
|
|
154
|
-
async getDataset(datasetId) {
|
|
155
|
-
const datasetDoc = await this.tables?.dataset
|
|
156
|
-
.findOne({ datasetId: datasetId })
|
|
157
|
-
.lean();
|
|
158
|
-
if (datasetDoc) {
|
|
159
|
-
const { datasetContentId, format, contentTree, solutionTree } = datasetDoc;
|
|
160
|
-
const captchas = (await this.tables?.captcha.find({ datasetId }).lean()) || [];
|
|
161
|
-
const solutions = (await this.tables?.solution.find({ datasetId }).lean()) || [];
|
|
162
|
-
const solutionsKeyed = {};
|
|
163
|
-
for (const solution of solutions) {
|
|
164
|
-
solutionsKeyed[solution.captchaId] = solution;
|
|
165
|
-
}
|
|
166
|
-
return {
|
|
167
|
-
datasetId,
|
|
168
|
-
datasetContentId,
|
|
169
|
-
format,
|
|
170
|
-
contentTree,
|
|
171
|
-
solutionTree,
|
|
172
|
-
captchas: captchas.map((captchaDoc) => {
|
|
173
|
-
const { captchaId, captchaContentId, items, target, salt, solved } = captchaDoc;
|
|
174
|
-
return {
|
|
175
|
-
captchaId,
|
|
176
|
-
captchaContentId,
|
|
177
|
-
solved,
|
|
178
|
-
salt,
|
|
179
|
-
items,
|
|
180
|
-
target,
|
|
181
|
-
solution: solved && solutionsKeyed[captchaId] ? solutionsKeyed[captchaId].solution : null,
|
|
182
|
-
};
|
|
183
|
-
}),
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
throw new common_1.ProsopoEnvError('DATABASE.DATASET_GET_FAILED', undefined, {}, datasetId);
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* @description Get random captchas that are solved or not solved
|
|
190
|
-
* @param {boolean} solved `true` when captcha is solved
|
|
191
|
-
* @param {string} datasetId the id of the data set
|
|
192
|
-
* @param {number} size the number of records to be returned
|
|
193
|
-
*/
|
|
194
|
-
async getRandomCaptcha(solved, datasetId, size) {
|
|
195
|
-
if (!(0, util_1.isHex)(datasetId)) {
|
|
196
|
-
throw new common_1.ProsopoEnvError('DATABASE.INVALID_HASH', this.getRandomCaptcha.name, {}, datasetId);
|
|
197
|
-
}
|
|
198
|
-
const sampleSize = size ? Math.abs(Math.trunc(size)) : 1;
|
|
199
|
-
const cursor = this.tables?.captcha.aggregate([
|
|
200
|
-
{ $match: { datasetId, solved } },
|
|
201
|
-
{ $sample: { size: sampleSize } },
|
|
202
|
-
{
|
|
203
|
-
$project: {
|
|
204
|
-
datasetId: 1,
|
|
205
|
-
datasetContentId: 1,
|
|
206
|
-
captchaId: 1,
|
|
207
|
-
captchaContentId: 1,
|
|
208
|
-
items: 1,
|
|
209
|
-
target: 1,
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
]);
|
|
213
|
-
const docs = await cursor;
|
|
214
|
-
if (docs && docs.length) {
|
|
215
|
-
// drop the _id field
|
|
216
|
-
return docs.map(({ _id, ...keepAttrs }) => keepAttrs);
|
|
217
|
-
}
|
|
218
|
-
throw new common_1.ProsopoEnvError('DATABASE.CAPTCHA_GET_FAILED', this.getRandomCaptcha.name, {}, {
|
|
219
|
-
solved: solved,
|
|
220
|
-
datasetId: datasetId,
|
|
221
|
-
size: size,
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* @description Get captchas by id
|
|
226
|
-
* @param {string[]} captchaId
|
|
227
|
-
*/
|
|
228
|
-
async getCaptchaById(captchaId) {
|
|
229
|
-
const cursor = this.tables?.captcha.find({ captchaId: { $in: captchaId } }).lean();
|
|
230
|
-
const docs = await cursor;
|
|
231
|
-
if (docs && docs.length) {
|
|
232
|
-
// drop the _id field
|
|
233
|
-
return docs.map(({ _id, ...keepAttrs }) => keepAttrs);
|
|
234
|
-
}
|
|
235
|
-
throw new common_1.ProsopoEnvError('DATABASE.CAPTCHA_GET_FAILED', this.getCaptchaById.name, {}, captchaId);
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* @description Update a captcha
|
|
239
|
-
* @param {Captcha} captcha
|
|
240
|
-
* @param {string} datasetId the id of the data set
|
|
241
|
-
*/
|
|
242
|
-
async updateCaptcha(captcha, datasetId) {
|
|
243
|
-
if (!(0, util_1.isHex)(datasetId)) {
|
|
244
|
-
throw new common_1.ProsopoEnvError('DATABASE.INVALID_HASH', this.updateCaptcha.name, {}, datasetId);
|
|
245
|
-
}
|
|
246
|
-
try {
|
|
247
|
-
await this.tables?.captcha.updateOne({ datasetId }, { $set: captcha }, { upsert: false });
|
|
248
|
-
}
|
|
249
|
-
catch (err) {
|
|
250
|
-
throw new common_1.ProsopoEnvError(err, this.updateCaptcha.name, {}, datasetId);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* @description Remove captchas
|
|
255
|
-
*/
|
|
256
|
-
async removeCaptchas(captchaIds) {
|
|
257
|
-
await this.tables?.captcha.deleteMany({ captchaId: { $in: captchaIds } });
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* @description Get a dataset by Id
|
|
261
|
-
*/
|
|
262
|
-
async getDatasetDetails(datasetId) {
|
|
263
|
-
if (!(0, util_1.isHex)(datasetId)) {
|
|
264
|
-
throw new common_1.ProsopoEnvError('DATABASE.INVALID_HASH', this.getDatasetDetails.name, {}, datasetId);
|
|
265
|
-
}
|
|
266
|
-
const doc = await this.tables?.dataset.findOne({ datasetId }).lean();
|
|
267
|
-
if (doc) {
|
|
268
|
-
return doc;
|
|
269
|
-
}
|
|
270
|
-
throw new common_1.ProsopoEnvError('DATABASE.DATASET_GET_FAILED', this.getDatasetDetails.name, {}, datasetId);
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* @description Store a Dapp User's captcha solution commitment
|
|
274
|
-
*/
|
|
275
|
-
async storeDappUserSolution(captchas, commit) {
|
|
276
|
-
const commitmentRecord = types_database_1.UserCommitmentSchema.parse(commit);
|
|
277
|
-
if (captchas.length) {
|
|
278
|
-
await this.tables?.commitment.updateOne({
|
|
279
|
-
id: commit.id,
|
|
280
|
-
}, commitmentRecord, { upsert: true });
|
|
281
|
-
const ops = captchas.map((captcha) => ({
|
|
282
|
-
updateOne: {
|
|
283
|
-
filter: { commitmentId: commit.id, captchaId: captcha.captchaId },
|
|
284
|
-
update: {
|
|
285
|
-
$set: {
|
|
286
|
-
captchaId: captcha.captchaId,
|
|
287
|
-
captchaContentId: captcha.captchaContentId,
|
|
288
|
-
salt: captcha.salt,
|
|
289
|
-
solution: captcha.solution,
|
|
290
|
-
commitmentId: commit.id,
|
|
291
|
-
processed: false,
|
|
292
|
-
},
|
|
293
|
-
},
|
|
294
|
-
upsert: true,
|
|
295
|
-
},
|
|
296
|
-
}));
|
|
297
|
-
await this.tables?.usersolution.bulkWrite(ops);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
/** @description Get processed Dapp User captcha solutions from the user solution table
|
|
301
|
-
*/
|
|
302
|
-
async getProcessedDappUserSolutions() {
|
|
303
|
-
const docs = await this.tables?.usersolution.find({ processed: true }).lean();
|
|
304
|
-
return docs ? docs.map((doc) => types_database_1.UserSolutionSchema.parse(doc)) : [];
|
|
305
|
-
}
|
|
306
|
-
/** @description Get processed Dapp User captcha commitments from the commitments table
|
|
307
|
-
*/
|
|
308
|
-
async getProcessedDappUserCommitments() {
|
|
309
|
-
const docs = await this.tables?.commitment.find({ processed: true }).lean();
|
|
310
|
-
return docs ? docs.map((doc) => types_database_1.UserCommitmentSchema.parse(doc)) : [];
|
|
311
|
-
}
|
|
312
|
-
/** @description Remove processed Dapp User captcha solutions from the user solution table
|
|
313
|
-
*/
|
|
314
|
-
async removeProcessedDappUserSolutions(commitmentIds) {
|
|
315
|
-
return await this.tables?.usersolution.deleteMany({ processed: true, commitmentId: { $in: commitmentIds } });
|
|
316
|
-
}
|
|
317
|
-
/** @description Remove processed Dapp User captcha commitments from the user commitments table
|
|
318
|
-
*/
|
|
319
|
-
async removeProcessedDappUserCommitments(commitmentIds) {
|
|
320
|
-
return await this.tables?.commitment.deleteMany({ processed: true, id: { $in: commitmentIds } });
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* @description Store a Dapp User's pending record
|
|
324
|
-
*/
|
|
325
|
-
async storeDappUserPending(userAccount, requestHash, salt, deadlineTimestamp, requestedAtBlock) {
|
|
326
|
-
if (!(0, util_1.isHex)(requestHash)) {
|
|
327
|
-
throw new common_1.ProsopoEnvError('DATABASE.INVALID_HASH', this.storeDappUserPending.name, {}, requestHash);
|
|
328
|
-
}
|
|
329
|
-
const pendingRecord = {
|
|
330
|
-
accountId: userAccount,
|
|
331
|
-
pending: true,
|
|
332
|
-
salt,
|
|
333
|
-
requestHash,
|
|
334
|
-
deadlineTimestamp,
|
|
335
|
-
requestedAtBlock,
|
|
336
|
-
};
|
|
337
|
-
await this.tables?.pending.updateOne({ requestHash: requestHash }, { $set: pendingRecord }, { upsert: true });
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* @description Get a Dapp user's pending record
|
|
341
|
-
*/
|
|
342
|
-
async getDappUserPending(requestHash) {
|
|
343
|
-
if (!(0, util_1.isHex)(requestHash)) {
|
|
344
|
-
throw new common_1.ProsopoEnvError('DATABASE.INVALID_HASH', this.getDappUserPending.name, {}, requestHash);
|
|
345
|
-
}
|
|
346
|
-
const doc = await this.tables?.pending
|
|
347
|
-
.findOne({ requestHash: requestHash })
|
|
348
|
-
.lean();
|
|
349
|
-
if (doc) {
|
|
350
|
-
return doc;
|
|
351
|
-
}
|
|
352
|
-
throw new common_1.ProsopoEnvError('DATABASE.PENDING_RECORD_NOT_FOUND', this.getDappUserPending.name);
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* @description Update a Dapp User's pending record
|
|
356
|
-
*/
|
|
357
|
-
async updateDappUserPendingStatus(userAccount, requestHash, approve) {
|
|
358
|
-
if (!(0, util_1.isHex)(requestHash)) {
|
|
359
|
-
throw new common_1.ProsopoEnvError('DATABASE.INVALID_HASH', this.updateDappUserPendingStatus.name, {}, requestHash);
|
|
360
|
-
}
|
|
361
|
-
await this.tables?.pending.updateOne({ requestHash: requestHash }, {
|
|
362
|
-
$set: {
|
|
363
|
-
accountId: userAccount,
|
|
364
|
-
pending: false,
|
|
365
|
-
approved: approve,
|
|
366
|
-
requestHash,
|
|
367
|
-
},
|
|
368
|
-
}, { upsert: true });
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* @description Get all unsolved captchas
|
|
372
|
-
*/
|
|
373
|
-
async getAllCaptchasByDatasetId(datasetId, state) {
|
|
374
|
-
const cursor = this.tables?.captcha
|
|
375
|
-
.find({
|
|
376
|
-
datasetId,
|
|
377
|
-
solved: state === types_1.CaptchaStates.Solved,
|
|
378
|
-
})
|
|
379
|
-
.lean();
|
|
380
|
-
const docs = await cursor;
|
|
381
|
-
if (docs) {
|
|
382
|
-
// drop the _id field
|
|
383
|
-
return docs.map(({ _id, ...keepAttrs }) => keepAttrs);
|
|
384
|
-
}
|
|
385
|
-
throw new common_1.ProsopoEnvError('DATABASE.CAPTCHA_GET_FAILED');
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* @description Get all dapp user solutions by captchaIds
|
|
389
|
-
*/
|
|
390
|
-
async getAllDappUserSolutions(captchaId) {
|
|
391
|
-
const cursor = this.tables?.usersolution?.find({ captchaId: { $in: captchaId } }).lean();
|
|
392
|
-
const docs = await cursor;
|
|
393
|
-
if (docs) {
|
|
394
|
-
// drop the _id field
|
|
395
|
-
return docs.map(({ _id, ...keepAttrs }) => keepAttrs);
|
|
396
|
-
}
|
|
397
|
-
throw new common_1.ProsopoEnvError('DATABASE.SOLUTION_GET_FAILED');
|
|
398
|
-
}
|
|
399
|
-
async getDatasetIdWithSolvedCaptchasOfSizeN(solvedCaptchaCount) {
|
|
400
|
-
const cursor = this.tables?.solution.aggregate([
|
|
401
|
-
{
|
|
402
|
-
$match: {},
|
|
403
|
-
},
|
|
404
|
-
{
|
|
405
|
-
$group: {
|
|
406
|
-
_id: '$datasetId',
|
|
407
|
-
count: { $sum: 1 },
|
|
408
|
-
},
|
|
409
|
-
},
|
|
410
|
-
{
|
|
411
|
-
$match: {
|
|
412
|
-
count: { $gte: solvedCaptchaCount },
|
|
413
|
-
},
|
|
414
|
-
},
|
|
415
|
-
{
|
|
416
|
-
$sample: { size: 1 },
|
|
417
|
-
},
|
|
418
|
-
]);
|
|
419
|
-
const docs = await cursor;
|
|
420
|
-
if (docs && docs.length) {
|
|
421
|
-
// return the _id field
|
|
422
|
-
return docs[0]._id;
|
|
423
|
-
}
|
|
424
|
-
throw new common_1.ProsopoEnvError('DATABASE.DATASET_WITH_SOLUTIONS_GET_FAILED');
|
|
425
|
-
}
|
|
426
|
-
async getRandomSolvedCaptchasFromSingleDataset(datasetId, size) {
|
|
427
|
-
//const datasetId = await this.getDatasetIdWithSolvedCaptchasOfSizeN(size);
|
|
428
|
-
if (!(0, util_1.isHex)(datasetId)) {
|
|
429
|
-
throw new common_1.ProsopoEnvError('DATABASE.INVALID_HASH', this.getRandomSolvedCaptchasFromSingleDataset.name, {}, datasetId);
|
|
430
|
-
}
|
|
431
|
-
const sampleSize = size ? Math.abs(Math.trunc(size)) : 1;
|
|
432
|
-
const cursor = this.tables?.solution.aggregate([
|
|
433
|
-
{ $match: { datasetId } },
|
|
434
|
-
{ $sample: { size: sampleSize } },
|
|
435
|
-
{
|
|
436
|
-
$project: {
|
|
437
|
-
captchaId: 1,
|
|
438
|
-
captchaContentId: 1,
|
|
439
|
-
solution: 1,
|
|
440
|
-
},
|
|
441
|
-
},
|
|
442
|
-
]);
|
|
443
|
-
const docs = await cursor;
|
|
444
|
-
if (docs && docs.length) {
|
|
445
|
-
return docs;
|
|
446
|
-
}
|
|
447
|
-
throw new common_1.ProsopoEnvError('DATABASE.SOLUTION_GET_FAILED');
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* @description Get dapp user solution by ID
|
|
451
|
-
* @param {string[]} commitmentId
|
|
452
|
-
*/
|
|
453
|
-
async getDappUserSolutionById(commitmentId) {
|
|
454
|
-
const cursor = this.tables?.usersolution
|
|
455
|
-
?.findOne({
|
|
456
|
-
commitmentId: commitmentId,
|
|
457
|
-
}, { projection: { _id: 0 } })
|
|
458
|
-
.lean();
|
|
459
|
-
const doc = await cursor;
|
|
460
|
-
if (doc) {
|
|
461
|
-
return doc;
|
|
462
|
-
}
|
|
463
|
-
throw new common_1.ProsopoEnvError('DATABASE.SOLUTION_GET_FAILED', this.getCaptchaById.name, {}, commitmentId);
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* @description Get dapp user commitment by user account
|
|
467
|
-
* @param commitmentId
|
|
468
|
-
*/
|
|
469
|
-
async getDappUserCommitmentById(commitmentId) {
|
|
470
|
-
const commitmentCursor = this.tables?.commitment?.findOne({ id: commitmentId }).lean();
|
|
471
|
-
const doc = await commitmentCursor;
|
|
472
|
-
return doc ? types_database_1.UserCommitmentSchema.parse(doc) : undefined;
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* @description Get dapp user commitment by user account
|
|
476
|
-
* @param {string[]} userAccount
|
|
477
|
-
*/
|
|
478
|
-
async getDappUserCommitmentByAccount(userAccount) {
|
|
479
|
-
const docs = await this.tables?.commitment
|
|
480
|
-
?.find({ userAccount })
|
|
481
|
-
.lean();
|
|
482
|
-
return docs ? docs : [];
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* @description Approve a dapp user's solution
|
|
486
|
-
* @param {string[]} commitmentId
|
|
487
|
-
*/
|
|
488
|
-
async approveDappUserCommitment(commitmentId) {
|
|
489
|
-
try {
|
|
490
|
-
await this.tables?.commitment
|
|
491
|
-
?.findOneAndUpdate({ id: commitmentId }, { $set: { status: types_1.CaptchaStatus.approved } }, { upsert: false })
|
|
492
|
-
.lean();
|
|
493
|
-
}
|
|
494
|
-
catch (err) {
|
|
495
|
-
throw new common_1.ProsopoEnvError(err, 'DATABASE.SOLUTION_APPROVE_FAILED', {}, commitmentId);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* @description Flag a dapp user's solutions as used by calculated solution
|
|
500
|
-
* @param {string[]} captchaIds
|
|
501
|
-
*/
|
|
502
|
-
async flagUsedDappUserSolutions(captchaIds) {
|
|
503
|
-
try {
|
|
504
|
-
await this.tables?.usersolution
|
|
505
|
-
?.updateMany({ captchaId: { $in: captchaIds } }, { $set: { processed: true } }, { upsert: false })
|
|
506
|
-
.lean();
|
|
507
|
-
}
|
|
508
|
-
catch (err) {
|
|
509
|
-
throw new common_1.ProsopoEnvError(err, 'DATABASE.SOLUTION_FLAG_FAILED', {}, captchaIds);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* @description Flag dapp users' commitments as used by calculated solution
|
|
514
|
-
* @param {string[]} commitmentIds
|
|
515
|
-
*/
|
|
516
|
-
async flagUsedDappUserCommitments(commitmentIds) {
|
|
517
|
-
try {
|
|
518
|
-
const distinctCommitmentIds = [...new Set(commitmentIds)];
|
|
519
|
-
await this.tables?.commitment
|
|
520
|
-
?.updateMany({ id: { $in: distinctCommitmentIds } }, { $set: { processed: true } }, { upsert: false })
|
|
521
|
-
.lean();
|
|
522
|
-
}
|
|
523
|
-
catch (err) {
|
|
524
|
-
throw new common_1.ProsopoEnvError(err, 'DATABASE.COMMITMENT_FLAG_FAILED', {}, commitmentIds);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
/**
|
|
528
|
-
* @description Get the last batch commit time or return 0 if none
|
|
529
|
-
*/
|
|
530
|
-
async getLastBatchCommitTime() {
|
|
531
|
-
const cursor = this.tables?.scheduler
|
|
532
|
-
?.findOne({ processName: types_1.ScheduledTaskNames.BatchCommitment, status: types_1.ScheduledTaskStatus.Completed })
|
|
533
|
-
.sort({ timestamp: -1 });
|
|
534
|
-
const doc = await cursor?.lean();
|
|
535
|
-
if (doc) {
|
|
536
|
-
return doc.datetime;
|
|
537
|
-
}
|
|
538
|
-
return new Date(0);
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* @description Get the last batch commit time or return 0 if none
|
|
542
|
-
*/
|
|
543
|
-
async getLastScheduledTask(task) {
|
|
544
|
-
const cursor = await this.tables?.scheduler
|
|
545
|
-
?.findOne({ processName: task })
|
|
546
|
-
.sort({ datetime: -1 })
|
|
547
|
-
.lean();
|
|
548
|
-
return cursor ? cursor : undefined;
|
|
549
|
-
}
|
|
550
|
-
/**
|
|
551
|
-
* @description Store the status of a scheduled task and an optional result
|
|
552
|
-
*/
|
|
553
|
-
async storeScheduledTaskStatus(taskId, task, status, result) {
|
|
554
|
-
const now = new Date();
|
|
555
|
-
const doc = types_database_1.ScheduledTaskSchema.parse({
|
|
556
|
-
taskId,
|
|
557
|
-
processName: task,
|
|
558
|
-
datetime: now,
|
|
559
|
-
status,
|
|
560
|
-
...(result && { result }),
|
|
561
|
-
});
|
|
562
|
-
await this.tables?.scheduler.create(doc);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
exports.ProsopoDatabase = ProsopoDatabase;
|
|
566
|
-
//# sourceMappingURL=mongo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongo.js","sourceRoot":"","sources":["../../src/databases/mongo.ts"],"names":[],"mappings":";;;;AAAA,6DAA6D;AAC7D,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,0CAauB;AACvB,4DAiBgC;AAChC,yCAAsC;AAGtC,4CAAuE;AAEvE,gEAA+C;AAE/C,kBAAQ,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA;AAElC,8CAA8C;AAC9C,MAAM,gBAAgB,GAAG,2BAA2B,CAAA;AAEpD;;;;;GAKG;AACH,MAAa,eAAgB,SAAQ,qBAAY;IAC7C,GAAG,CAAQ;IACX,MAAM,CAAS;IACf,MAAM,CAAQ;IACd,UAAU,CAAa;IACvB,MAAM,CAAQ;IAEP,KAAK,CAAC,IAAI,CAAC,GAAW,EAAE,MAAc,EAAE,MAAc,EAAE,UAAmB;QAC9E,MAAM,gBAAgB,GAAG,UAAU,CAAC,CAAC,CAAC,eAAe,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QACtE,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC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QAAQ,CAAA;SACtB;QAED,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAA;IACtB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB,CAAC,IAAwB;QAC/C,MAAM,MAAM,GAA2C,MAAM,IAAI,CAAC,MAAM,EAAE,SAAS;YAC/E,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;aAC/B,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC;aACtB,IAAI,EAAE,CAAA;QACX,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;IACtC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,wBAAwB,CAC1B,MAAqB,EACrB,IAAwB,EACxB,MAA2B,EAC3B,MAA4B;QAE5B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;QACtB,MAAM,GAAG,GAAG,oCAAmB,CAAC,KAAK,CAAC;YAClC,MAAM;YACN,WAAW,EAAE,IAAI;YACjB,QAAQ,EAAE,GAAG;YACb,MAAM;YACN,GAAG,CAAC,MAAM,IAAI,EAAE,MAAM,EAAE,CAAC;SAC5B,CAAC,CAAA;QACF,MAAM,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC5C,CAAC;CACJ;AAroBD,0CAqoBC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@prosopo/common';
|
|
2
|
-
import { ProsopoDatabase as MongoDatabase } from './mongo';
|
|
3
|
-
export declare class MongoMemoryDatabase extends MongoDatabase {
|
|
4
|
-
init(url: string, dbname: string, logger: Logger, authSource?: string): Promise<this>;
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=mongoMemory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongoMemory.d.ts","sourceRoot":"","sources":["../../src/databases/mongoMemory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,eAAe,IAAI,aAAa,EAAE,MAAM,SAAS,CAAA;AAG1D,qBAAa,mBAAoB,SAAQ,aAAa;IACnC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAMvG"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MongoMemoryDatabase = void 0;
|
|
4
|
-
const mongo_1 = require("./mongo");
|
|
5
|
-
const mongodb_memory_server_1 = require("mongodb-memory-server");
|
|
6
|
-
class MongoMemoryDatabase extends mongo_1.ProsopoDatabase {
|
|
7
|
-
async init(url, dbname, logger, authSource) {
|
|
8
|
-
const mongod = await mongodb_memory_server_1.MongoMemoryServer.create();
|
|
9
|
-
const mongoMemoryURL = mongod.getUri();
|
|
10
|
-
await super.init(mongoMemoryURL, dbname, logger, authSource);
|
|
11
|
-
return this;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.MongoMemoryDatabase = MongoMemoryDatabase;
|
|
15
|
-
//# sourceMappingURL=mongoMemory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongoMemory.js","sourceRoot":"","sources":["../../src/databases/mongoMemory.ts"],"names":[],"mappings":";;;AACA,mCAA0D;AAC1D,iEAAyD;AAEzD,MAAa,mBAAoB,SAAQ,uBAAa;IACzC,KAAK,CAAC,IAAI,CAAC,GAAW,EAAE,MAAc,EAAE,MAAc,EAAE,UAAmB;QAChF,MAAM,MAAM,GAAG,MAAM,yCAAiB,CAAC,MAAM,EAAE,CAAA;QAC/C,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,CAAA;QACtC,MAAM,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAA;QAC5D,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AAPD,kDAOC"}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
|
package/dist/index.js
DELETED
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sDAA2B"}
|