@prosopo/database 0.2.13 → 0.2.15

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.
@@ -3,11 +3,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const common = require("@prosopo/common");
4
4
  const types = require("@prosopo/types");
5
5
  const typesDatabase = require("@prosopo/types-database");
6
- require("../contracts/captcha/dist/index.cjs");
6
+ const typesReturns = require("@prosopo/captcha-contract/types-returns");
7
7
  const mongodb = require("mongodb");
8
- const util = require("@polkadot/util");
8
+ const is = require("@polkadot/util/is");
9
9
  const mongoose = require("mongoose");
10
- const captcha = require("../contracts/captcha/dist/types-arguments/captcha.cjs");
11
10
  mongoose.set("strictQuery", false);
12
11
  const DEFAULT_ENDPOINT = "mongodb://127.0.0.1:27017";
13
12
  class ProsopoDatabase extends common.AsyncFactory {
@@ -33,41 +32,56 @@ class ProsopoDatabase extends common.AsyncFactory {
33
32
  * @description Connect to the database and set the various tables
34
33
  */
35
34
  async connect() {
36
- return new Promise((resolve, reject) => {
37
- if (this.connection) {
38
- resolve();
39
- }
40
- this.logger.info(`Mongo url: ${this.url.replace(/\w+:\w+/, "<Credentials>")}`);
41
- this.connection = mongoose.createConnection(this.url, {
42
- dbName: this.dbname,
43
- serverApi: mongodb.ServerApiVersion.v1
44
- });
45
- this.tables = {
46
- captcha: this.connection.models.Captcha || this.connection.model("Captcha", typesDatabase.CaptchaRecordSchema),
47
- dataset: this.connection.models.Dataset || this.connection.model("Dataset", typesDatabase.DatasetRecordSchema),
48
- solution: this.connection.models.Solution || this.connection.model("Solution", typesDatabase.SolutionRecordSchema),
49
- commitment: this.connection.models.UserCommitment || this.connection.model("UserCommitment", typesDatabase.UserCommitmentRecordSchema),
50
- usersolution: this.connection.models.UserSolution || this.connection.model("UserSolution", typesDatabase.UserSolutionRecordSchema),
51
- pending: this.connection.models.Pending || this.connection.model("Pending", typesDatabase.PendingRecordSchema),
52
- scheduler: this.connection.models.Scheduler || this.connection.model("Scheduler", typesDatabase.ScheduledTaskRecordSchema)
53
- };
54
- this.connection.once("open", resolve).on("error", (e) => {
55
- this.logger.warn(`mongoose connection error`);
56
- if (e.message.code === "ETIMEDOUT") {
57
- this.logger.error(e);
58
- mongoose.connect(this.url);
35
+ const MAX_RETRIES = 3;
36
+ const RETRY_INTERVAL_MS = 1e3;
37
+ for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
38
+ try {
39
+ if (this.connection) {
40
+ return;
59
41
  }
60
- this.logger.error(e);
61
- reject(new common.ProsopoEnvError(e, "DATABASE.CONNECT_ERROR", {}, this.url));
62
- });
63
- });
42
+ await new Promise((resolve, reject) => {
43
+ this.logger.info(`Mongo url: ${this.url.replace(/\w+:\w+/, "<Credentials>")}`);
44
+ this.connection = mongoose.createConnection(this.url, {
45
+ dbName: this.dbname,
46
+ serverApi: mongodb.ServerApiVersion.v1
47
+ });
48
+ this.tables = {
49
+ captcha: this.connection.models.Captcha || this.connection.model("Captcha", typesDatabase.CaptchaRecordSchema),
50
+ dataset: this.connection.models.Dataset || this.connection.model("Dataset", typesDatabase.DatasetRecordSchema),
51
+ solution: this.connection.models.Solution || this.connection.model("Solution", typesDatabase.SolutionRecordSchema),
52
+ commitment: this.connection.models.UserCommitment || this.connection.model("UserCommitment", typesDatabase.UserCommitmentRecordSchema),
53
+ usersolution: this.connection.models.UserSolution || this.connection.model("UserSolution", typesDatabase.UserSolutionRecordSchema),
54
+ pending: this.connection.models.Pending || this.connection.model("Pending", typesDatabase.PendingRecordSchema),
55
+ scheduler: this.connection.models.Scheduler || this.connection.model("Scheduler", typesDatabase.ScheduledTaskRecordSchema)
56
+ };
57
+ this.connection.once("open", resolve).on("error", (e) => {
58
+ var _a;
59
+ this.logger.warn(`mongoose connection error`);
60
+ this.logger.error(e);
61
+ if (attempt === MAX_RETRIES) {
62
+ reject(new common.ProsopoEnvError(e, "DATABASE.CONNECT_ERROR", {}, this.url));
63
+ } else {
64
+ (_a = this.connection) == null ? void 0 : _a.removeAllListeners("error");
65
+ }
66
+ });
67
+ });
68
+ return;
69
+ } catch (e) {
70
+ if (attempt < MAX_RETRIES) {
71
+ this.logger.info(`Attempt ${attempt} failed, retrying in ${RETRY_INTERVAL_MS / 1e3} seconds...`);
72
+ await new Promise((resolve) => setTimeout(resolve, RETRY_INTERVAL_MS));
73
+ } else {
74
+ throw e;
75
+ }
76
+ }
77
+ }
64
78
  }
65
79
  /** Close connection to the database */
66
80
  async close() {
67
- this.logger.info(`Closing connection to ${this.url}`);
81
+ this.logger.debug(`Closing connection to ${this.url}`);
68
82
  await new Promise(async (resolve, reject) => {
69
83
  mongoose.connection.close().then(() => {
70
- this.logger.info(`Connection to ${this.url} closed`);
84
+ this.logger.debug(`Connection to ${this.url} closed`);
71
85
  resolve();
72
86
  }).catch(reject);
73
87
  });
@@ -79,7 +93,7 @@ class ProsopoDatabase extends common.AsyncFactory {
79
93
  async storeDataset(dataset) {
80
94
  var _a, _b, _c;
81
95
  try {
82
- this.logger.info(`Storing dataset in database`);
96
+ this.logger.debug(`Storing dataset in database`);
83
97
  const parsedDataset = types.DatasetWithIdsAndTreeSchema.parse(dataset);
84
98
  const datasetDoc = {
85
99
  datasetId: parsedDataset.datasetId,
@@ -93,14 +107,14 @@ class ProsopoDatabase extends common.AsyncFactory {
93
107
  { $set: datasetDoc },
94
108
  { upsert: true }
95
109
  ));
96
- const captchaDocs = parsedDataset.captchas.map(({ solution, ...captcha2 }, index) => ({
97
- ...captcha2,
110
+ const captchaDocs = parsedDataset.captchas.map(({ solution, ...captcha }, index) => ({
111
+ ...captcha,
98
112
  datasetId: parsedDataset.datasetId,
99
113
  datasetContentId: parsedDataset.datasetContentId,
100
114
  index,
101
115
  solved: !!(solution == null ? void 0 : solution.length)
102
116
  }));
103
- this.logger.info(`Inserting captcha records`);
117
+ this.logger.debug(`Inserting captcha records`);
104
118
  if (captchaDocs.length) {
105
119
  await ((_b = this.tables) == null ? void 0 : _b.captcha.bulkWrite(
106
120
  captchaDocs.map((captchaDoc) => ({
@@ -112,15 +126,15 @@ class ProsopoDatabase extends common.AsyncFactory {
112
126
  }))
113
127
  ));
114
128
  }
115
- const captchaSolutionDocs = parsedDataset.captchas.filter(({ solution }) => solution == null ? void 0 : solution.length).map((captcha2) => ({
116
- captchaId: captcha2.captchaId,
117
- captchaContentId: captcha2.captchaContentId,
118
- solution: captcha2.solution,
119
- salt: captcha2.salt,
129
+ const captchaSolutionDocs = parsedDataset.captchas.filter(({ solution }) => solution == null ? void 0 : solution.length).map((captcha) => ({
130
+ captchaId: captcha.captchaId,
131
+ captchaContentId: captcha.captchaContentId,
132
+ solution: captcha.solution,
133
+ salt: captcha.salt,
120
134
  datasetId: parsedDataset.datasetId,
121
135
  datasetContentId: parsedDataset.datasetContentId
122
136
  }));
123
- this.logger.info(`Inserting solution records`);
137
+ this.logger.debug(`Inserting solution records`);
124
138
  if (captchaSolutionDocs.length) {
125
139
  await ((_c = this.tables) == null ? void 0 : _c.solution.bulkWrite(
126
140
  captchaSolutionDocs.map((captchaSolutionDoc) => ({
@@ -132,11 +146,19 @@ class ProsopoDatabase extends common.AsyncFactory {
132
146
  }))
133
147
  ));
134
148
  }
135
- this.logger.info(`Dataset stored in database`);
149
+ this.logger.debug(`Dataset stored in database`);
136
150
  } catch (err) {
137
151
  throw new common.ProsopoEnvError(err, "DATABASE.DATASET_LOAD_FAILED");
138
152
  }
139
153
  }
154
+ /** @description Get solutions for a dataset
155
+ * @param {string} datasetId
156
+ */
157
+ async getSolutions(datasetId) {
158
+ var _a;
159
+ const docs = await ((_a = this.tables) == null ? void 0 : _a.solution.find({ datasetId }).lean());
160
+ return docs ? docs : [];
161
+ }
140
162
  /** @description Get a dataset from the database
141
163
  * @param {string} datasetId
142
164
  */
@@ -182,7 +204,7 @@ class ProsopoDatabase extends common.AsyncFactory {
182
204
  */
183
205
  async getRandomCaptcha(solved, datasetId, size) {
184
206
  var _a;
185
- if (!util.isHex(datasetId)) {
207
+ if (!is.isHex(datasetId)) {
186
208
  throw new common.ProsopoEnvError("DATABASE.INVALID_HASH", this.getRandomCaptcha.name, {}, datasetId);
187
209
  }
188
210
  const sampleSize = size ? Math.abs(Math.trunc(size)) : 1;
@@ -233,13 +255,13 @@ class ProsopoDatabase extends common.AsyncFactory {
233
255
  * @param {Captcha} captcha
234
256
  * @param {string} datasetId the id of the data set
235
257
  */
236
- async updateCaptcha(captcha2, datasetId) {
258
+ async updateCaptcha(captcha, datasetId) {
237
259
  var _a;
238
- if (!util.isHex(datasetId)) {
260
+ if (!is.isHex(datasetId)) {
239
261
  throw new common.ProsopoEnvError("DATABASE.INVALID_HASH", this.updateCaptcha.name, {}, datasetId);
240
262
  }
241
263
  try {
242
- await ((_a = this.tables) == null ? void 0 : _a.captcha.updateOne({ datasetId }, { $set: captcha2 }, { upsert: false }));
264
+ await ((_a = this.tables) == null ? void 0 : _a.captcha.updateOne({ datasetId }, { $set: captcha }, { upsert: false }));
243
265
  } catch (err) {
244
266
  throw new common.ProsopoEnvError(err);
245
267
  }
@@ -256,7 +278,7 @@ class ProsopoDatabase extends common.AsyncFactory {
256
278
  */
257
279
  async getDatasetDetails(datasetId) {
258
280
  var _a;
259
- if (!util.isHex(datasetId)) {
281
+ if (!is.isHex(datasetId)) {
260
282
  throw new common.ProsopoEnvError("DATABASE.INVALID_HASH", this.getDatasetDetails.name, {}, datasetId);
261
283
  }
262
284
  const doc = await ((_a = this.tables) == null ? void 0 : _a.dataset.findOne({ datasetId }).lean());
@@ -279,15 +301,15 @@ class ProsopoDatabase extends common.AsyncFactory {
279
301
  commitmentRecord,
280
302
  { upsert: true }
281
303
  ));
282
- const ops = captchas.map((captcha2) => ({
304
+ const ops = captchas.map((captcha) => ({
283
305
  updateOne: {
284
- filter: { commitmentId: commit.id, captchaId: captcha2.captchaId },
306
+ filter: { commitmentId: commit.id, captchaId: captcha.captchaId },
285
307
  update: {
286
308
  $set: {
287
- captchaId: captcha2.captchaId,
288
- captchaContentId: captcha2.captchaContentId,
289
- salt: captcha2.salt,
290
- solution: captcha2.solution,
309
+ captchaId: captcha.captchaId,
310
+ captchaContentId: captcha.captchaContentId,
311
+ salt: captcha.salt,
312
+ solution: captcha.solution,
291
313
  commitmentId: commit.id,
292
314
  processed: false
293
315
  }
@@ -343,7 +365,7 @@ class ProsopoDatabase extends common.AsyncFactory {
343
365
  */
344
366
  async storeDappUserPending(userAccount, requestHash, salt, deadlineTimestamp, requestedAtBlock) {
345
367
  var _a;
346
- if (!util.isHex(requestHash)) {
368
+ if (!is.isHex(requestHash)) {
347
369
  throw new common.ProsopoEnvError("DATABASE.INVALID_HASH", this.storeDappUserPending.name, {}, requestHash);
348
370
  }
349
371
  const pendingRecord = {
@@ -361,7 +383,7 @@ class ProsopoDatabase extends common.AsyncFactory {
361
383
  */
362
384
  async getDappUserPending(requestHash) {
363
385
  var _a;
364
- if (!util.isHex(requestHash)) {
386
+ if (!is.isHex(requestHash)) {
365
387
  throw new common.ProsopoEnvError("DATABASE.INVALID_HASH", this.getDappUserPending.name, {}, requestHash);
366
388
  }
367
389
  const doc = await ((_a = this.tables) == null ? void 0 : _a.pending.findOne({ requestHash }).lean());
@@ -375,7 +397,7 @@ class ProsopoDatabase extends common.AsyncFactory {
375
397
  */
376
398
  async updateDappUserPendingStatus(userAccount, requestHash, approve) {
377
399
  var _a;
378
- if (!util.isHex(requestHash)) {
400
+ if (!is.isHex(requestHash)) {
379
401
  throw new common.ProsopoEnvError("DATABASE.INVALID_HASH", this.updateDappUserPendingStatus.name, {}, requestHash);
380
402
  }
381
403
  await ((_a = this.tables) == null ? void 0 : _a.pending.updateOne(
@@ -447,7 +469,7 @@ class ProsopoDatabase extends common.AsyncFactory {
447
469
  }
448
470
  async getRandomSolvedCaptchasFromSingleDataset(datasetId, size) {
449
471
  var _a;
450
- if (!util.isHex(datasetId)) {
472
+ if (!is.isHex(datasetId)) {
451
473
  throw new common.ProsopoEnvError(
452
474
  "DATABASE.INVALID_HASH",
453
475
  this.getRandomSolvedCaptchasFromSingleDataset.name,
@@ -519,7 +541,7 @@ class ProsopoDatabase extends common.AsyncFactory {
519
541
  try {
520
542
  await ((_b = (_a = this.tables) == null ? void 0 : _a.commitment) == null ? void 0 : _b.findOneAndUpdate(
521
543
  { id: commitmentId },
522
- { $set: { status: captcha.CaptchaStatus.approved } },
544
+ { $set: { status: typesReturns.CaptchaStatus.approved } },
523
545
  { upsert: false }
524
546
  ).lean());
525
547
  } catch (err) {
@@ -1,16 +1,3 @@
1
- // Copyright 2021-2023 Prosopo (UK) Ltd.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
1
  import { DatabaseTypes } from '@prosopo/types';
15
2
  import { ProsopoDatabase as MongoDatabase } from './mongo.js';
16
3
  import { MongoMemoryDatabase } from './mongoMemory.js';
@@ -1 +1 @@
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,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,eAAe,IAAI,aAAa,EAAE,MAAM,YAAY,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,MAAM,CAAC,MAAM,SAAS,GAAG;IACrB,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,aAAa;IAC3C,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,mBAAmB;CAC1D,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/databases/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,eAAe,IAAI,aAAa,EAAE,MAAM,YAAY,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,MAAM,CAAC,MAAM,SAAS,GAAG;IACrB,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,aAAa;IAC3C,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,mBAAmB;CAC1D,CAAA"}
@@ -1,16 +1,10 @@
1
1
  /// <reference types="mongoose/types/connection.js" />
2
2
  import { AsyncFactory, Logger } from '@prosopo/common';
3
3
  import { Captcha, CaptchaSolution, CaptchaStates, DatasetBase, DatasetWithIds, DatasetWithIdsAndTree, PendingCaptchaRequest, ScheduledTaskNames, ScheduledTaskResult, ScheduledTaskStatus } from '@prosopo/types';
4
- import { Database, ScheduledTaskRecord, Tables, UserCommitmentRecord, UserSolutionRecord } from '@prosopo/types-database';
5
- import { Hash } from '@prosopo/captcha-contract';
4
+ import { Database, ScheduledTaskRecord, SolutionRecord, Tables, UserCommitmentRecord, UserSolutionRecord } from '@prosopo/types-database';
5
+ import { Hash } from '@prosopo/captcha-contract/types-returns';
6
6
  import { DeleteResult } from 'mongodb';
7
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
8
  export declare class ProsopoDatabase extends AsyncFactory implements Database {
15
9
  url: string;
16
10
  tables?: Tables;
@@ -19,141 +13,40 @@ export declare class ProsopoDatabase extends AsyncFactory implements Database {
19
13
  logger: Logger;
20
14
  constructor();
21
15
  init(url: string, dbname: string, logger: Logger, authSource?: string): Promise<this>;
22
- /**
23
- * @description Connect to the database and set the various tables
24
- */
25
16
  connect(): Promise<void>;
26
- /** Close connection to the database */
27
17
  close(): Promise<void>;
28
- /**
29
- * @description Load a dataset to the database
30
- * @param {Dataset} dataset
31
- */
32
18
  storeDataset(dataset: DatasetWithIdsAndTree): Promise<void>;
33
- /** @description Get a dataset from the database
34
- * @param {string} datasetId
35
- */
19
+ getSolutions(datasetId: string): Promise<SolutionRecord[]>;
36
20
  getDataset(datasetId: string): Promise<DatasetWithIds>;
37
- /**
38
- * @description Get random captchas that are solved or not solved
39
- * @param {boolean} solved `true` when captcha is solved
40
- * @param {string} datasetId the id of the data set
41
- * @param {number} size the number of records to be returned
42
- */
43
21
  getRandomCaptcha(solved: boolean, datasetId: Hash, size?: number): Promise<Captcha[] | undefined>;
44
- /**
45
- * @description Get captchas by id
46
- * @param {string[]} captchaId
47
- */
48
22
  getCaptchaById(captchaId: string[]): Promise<Captcha[] | undefined>;
49
- /**
50
- * @description Update a captcha
51
- * @param {Captcha} captcha
52
- * @param {string} datasetId the id of the data set
53
- */
54
23
  updateCaptcha(captcha: Captcha, datasetId: Hash): Promise<void>;
55
- /**
56
- * @description Remove captchas
57
- */
58
24
  removeCaptchas(captchaIds: string[]): Promise<void>;
59
- /**
60
- * @description Get a dataset by Id
61
- */
62
25
  getDatasetDetails(datasetId: Hash): Promise<DatasetBase>;
63
- /**
64
- * @description Store a Dapp User's captcha solution commitment
65
- */
66
26
  storeDappUserSolution(captchas: CaptchaSolution[], commit: UserCommitmentRecord): Promise<void>;
67
- /** @description Get processed Dapp User captcha solutions from the user solution table
68
- */
69
27
  getProcessedDappUserSolutions(): Promise<UserSolutionRecord[]>;
70
- /** @description Get processed Dapp User captcha commitments from the commitments table
71
- */
72
28
  getProcessedDappUserCommitments(): Promise<UserCommitmentRecord[]>;
73
- /** @description Get Dapp User captcha commitments from the commitments table that have not been batched on-chain
74
- */
75
29
  getUnbatchedDappUserCommitments(): Promise<UserCommitmentRecord[]>;
76
- /** @description Get Dapp User captcha commitments from the commitments table that have been batched on-chain
77
- */
78
30
  getBatchedDappUserCommitments(): Promise<UserCommitmentRecord[]>;
79
- /** @description Remove processed Dapp User captcha solutions from the user solution table
80
- */
81
31
  removeProcessedDappUserSolutions(commitmentIds: string[]): Promise<DeleteResult | undefined>;
82
- /** @description Remove processed Dapp User captcha commitments from the user commitments table
83
- */
84
32
  removeProcessedDappUserCommitments(commitmentIds: string[]): Promise<DeleteResult | undefined>;
85
- /**
86
- * @description Store a Dapp User's pending record
87
- */
88
33
  storeDappUserPending(userAccount: string, requestHash: string, salt: string, deadlineTimestamp: number, requestedAtBlock: number): Promise<void>;
89
- /**
90
- * @description Get a Dapp user's pending record
91
- */
92
34
  getDappUserPending(requestHash: string): Promise<PendingCaptchaRequest>;
93
- /**
94
- * @description Update a Dapp User's pending record
95
- */
96
35
  updateDappUserPendingStatus(userAccount: string, requestHash: string, approve: boolean): Promise<void>;
97
- /**
98
- * @description Get all unsolved captchas
99
- */
100
36
  getAllCaptchasByDatasetId(datasetId: string, state?: CaptchaStates): Promise<Captcha[] | undefined>;
101
- /**
102
- * @description Get all dapp user solutions by captchaIds
103
- */
104
37
  getAllDappUserSolutions(captchaId: string[]): Promise<UserSolutionRecord[] | undefined>;
105
38
  getDatasetIdWithSolvedCaptchasOfSizeN(solvedCaptchaCount: number): Promise<string>;
106
39
  getRandomSolvedCaptchasFromSingleDataset(datasetId: string, size: number): Promise<CaptchaSolution[]>;
107
- /**
108
- * @description Get dapp user solution by ID
109
- * @param {string[]} commitmentId
110
- */
111
40
  getDappUserSolutionById(commitmentId: string): Promise<UserSolutionRecord | undefined>;
112
- /**
113
- * @description Get dapp user commitment by user account
114
- * @param commitmentId
115
- */
116
41
  getDappUserCommitmentById(commitmentId: string): Promise<UserCommitmentRecord | undefined>;
117
- /**
118
- * @description Get dapp user commitment by user account
119
- * @param {string[]} userAccount
120
- */
121
42
  getDappUserCommitmentByAccount(userAccount: string): Promise<UserCommitmentRecord[]>;
122
- /**
123
- * @description Approve a dapp user's solution
124
- * @param {string[]} commitmentId
125
- */
126
43
  approveDappUserCommitment(commitmentId: string): Promise<void>;
127
- /**
128
- * @description Flag a dapp user's solutions as used by calculated solution
129
- * @param {string[]} captchaIds
130
- */
131
44
  flagProcessedDappUserSolutions(captchaIds: Hash[]): Promise<void>;
132
- /**
133
- * @description Flag dapp users' commitments as used by calculated solution
134
- * @param {string[]} commitmentIds
135
- */
136
45
  flagProcessedDappUserCommitments(commitmentIds: Hash[]): Promise<void>;
137
- /**
138
- * @description Flag dapp users' commitments as used by calculated solution
139
- * @param {string[]} commitmentIds
140
- */
141
46
  flagBatchedDappUserCommitments(commitmentIds: Hash[]): Promise<void>;
142
- /**
143
- * @description Get the last batch commit time or return 0 if none
144
- */
145
47
  getLastBatchCommitTime(): Promise<Date>;
146
- /**
147
- * @description Get a scheduled task status record by task ID and status
148
- */
149
48
  getScheduledTaskStatus(taskId: string, status: ScheduledTaskStatus): Promise<ScheduledTaskRecord | undefined>;
150
- /**
151
- * @description Get the most recent scheduled task status record for a given task
152
- */
153
49
  getLastScheduledTaskStatus(task: ScheduledTaskNames, status?: ScheduledTaskStatus): Promise<ScheduledTaskRecord | undefined>;
154
- /**
155
- * @description Store the status of a scheduled task and an optional result
156
- */
157
50
  storeScheduledTaskStatus(taskId: `0x${string}`, task: ScheduledTaskNames, status: ScheduledTaskStatus, result?: ScheduledTaskResult): Promise<void>;
158
51
  }
159
52
  //# sourceMappingURL=mongo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mongo.d.ts","sourceRoot":"","sources":["../../src/databases/mongo.ts"],"names":[],"mappings":";AAcA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAqC,MAAM,iBAAiB,CAAA;AACzF,OAAO,EACH,OAAO,EACP,eAAe,EACf,aAAa,EACb,WAAW,EACX,cAAc,EACd,qBAAqB,EAErB,q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