@prosopo/provider 0.1.16 → 0.1.17
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/coverage/tmp/coverage-14066-1690288461446-0.json +1 -0
- package/dist/api/admin.d.ts +2 -0
- package/dist/api/admin.d.ts.map +1 -0
- package/dist/api/admin.js +58 -0
- package/dist/api/admin.js.map +1 -0
- package/dist/{api.d.ts → api/captcha.d.ts} +1 -1
- package/dist/api/captcha.d.ts.map +1 -0
- package/dist/{api.js → api/captcha.js} +53 -34
- package/dist/api/captcha.js.map +1 -0
- package/dist/batch/commitments.d.ts +5 -6
- package/dist/batch/commitments.d.ts.map +1 -1
- package/dist/batch/commitments.js +57 -58
- package/dist/batch/commitments.js.map +1 -1
- package/dist/batch/index.d.ts +1 -1
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js +14 -4
- package/dist/batch/index.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -8
- package/dist/index.js.map +1 -1
- package/dist/scheduler.d.ts +2 -1
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +26 -12
- package/dist/scheduler.js.map +1 -1
- package/dist/tasks/calculateSolutions.d.ts +10 -0
- package/dist/tasks/calculateSolutions.d.ts.map +1 -0
- package/dist/tasks/calculateSolutions.js +90 -0
- package/dist/tasks/calculateSolutions.js.map +1 -0
- package/dist/tasks/index.d.ts +2 -1
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/index.js +3 -5
- package/dist/tasks/index.js.map +1 -1
- package/dist/tasks/tasks.d.ts +8 -8
- package/dist/tasks/tasks.d.ts.map +1 -1
- package/dist/tasks/tasks.js +81 -116
- package/dist/tasks/tasks.js.map +1 -1
- package/dist/util.d.ts +9 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +47 -29
- package/dist/util.js.map +1 -1
- package/package.json +68 -69
- package/dist/api.d.ts.map +0 -1
- package/dist/api.js.map +0 -1
package/dist/scheduler.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2021-2022 Prosopo (UK) Ltd.
|
|
3
2
|
//
|
|
4
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -14,21 +13,36 @@
|
|
|
14
13
|
// limitations under the License.
|
|
15
14
|
// [object Object]
|
|
16
15
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
import { BatchCommitmentsTask } from './batch/commitments.js';
|
|
17
|
+
import { CalculateSolutionsTask } from './tasks/calculateSolutions.js';
|
|
18
|
+
import { CronJob } from 'cron';
|
|
19
|
+
import { ProsopoEnvError } from '@prosopo/common';
|
|
20
|
+
import { ProviderEnvironment } from '@prosopo/env';
|
|
21
|
+
export async function calculateSolutionsScheduler(pair, config) {
|
|
22
|
+
const env = new ProviderEnvironment(pair, config);
|
|
23
23
|
await env.isReady();
|
|
24
|
-
const tasks = new
|
|
25
|
-
const job = new
|
|
26
|
-
env.logger.debug('
|
|
27
|
-
tasks.
|
|
24
|
+
const tasks = new CalculateSolutionsTask(env);
|
|
25
|
+
const job = new CronJob(process.argv[2], () => {
|
|
26
|
+
env.logger.debug('CalculateSolutionsTask....');
|
|
27
|
+
tasks.run().catch((err) => {
|
|
28
|
+
env.logger.error(err);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
job.start();
|
|
32
|
+
}
|
|
33
|
+
export async function batchCommitScheduler(pair, config) {
|
|
34
|
+
const env = new ProviderEnvironment(pair, config);
|
|
35
|
+
await env.isReady();
|
|
36
|
+
if (env.db === undefined) {
|
|
37
|
+
throw new ProsopoEnvError('DATABASE.DATABASE_UNDEFINED');
|
|
38
|
+
}
|
|
39
|
+
const tasks = new BatchCommitmentsTask(config.batchCommit, env.contractInterface, env.db, 0n, env.logger);
|
|
40
|
+
const job = new CronJob(process.argv[2], () => {
|
|
41
|
+
env.logger.debug('BatchCommitmentsTask....');
|
|
42
|
+
tasks.run().catch((err) => {
|
|
28
43
|
env.logger.error(err);
|
|
29
44
|
});
|
|
30
45
|
});
|
|
31
46
|
job.start();
|
|
32
47
|
}
|
|
33
|
-
exports.default = default_1;
|
|
34
48
|
//# sourceMappingURL=scheduler.js.map
|
package/dist/scheduler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.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,kBAAkB;AAClB,sCAAsC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAG9B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAElD,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,IAAiB,EAAE,MAAqB;IACtF,MAAM,GAAG,GAAG,IAAI,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACjD,MAAM,GAAG,CAAC,OAAO,EAAE,CAAA;IACnB,MAAM,KAAK,GAAG,IAAI,sBAAsB,CAAC,GAAG,CAAC,CAAA;IAC7C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,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asks } from './tasks.js';
|
|
3
|
+
export declare class CalculateSolutionsTask extends Tasks {
|
|
4
|
+
constructor(env: ProviderEnvironment);
|
|
5
|
+
/**
|
|
6
|
+
* Apply new captcha solutions to captcha dataset and recalculate merkle tree
|
|
7
|
+
*/
|
|
8
|
+
run(): Promise<number>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=calculateSolutions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculateSolutions.d.ts","sourceRoot":"","sources":["../../src/tasks/calculateSolutions.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGlC,qBAAa,sBAAuB,SAAQ,KAAK;gBACjC,GAAG,EAAE,mBAAmB;IAKpC;;OAEG;IACG,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;CAmE/B"}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
import { CaptchaStates } from '@prosopo/types';
|
|
15
|
+
import { ProsopoEnvError, getLogger } from '@prosopo/common';
|
|
16
|
+
import { ScheduledTaskNames } from '@prosopo/types';
|
|
17
|
+
import { Tasks } from './tasks.js';
|
|
18
|
+
import { calculateNewSolutions, checkIfTaskIsRunning, updateSolutions } from '../util.js';
|
|
19
|
+
import { captchaSort } from '@prosopo/datasets';
|
|
20
|
+
export class CalculateSolutionsTask extends Tasks {
|
|
21
|
+
constructor(env) {
|
|
22
|
+
super(env);
|
|
23
|
+
this.logger = getLogger(env.config.logLevel, 'CalculateSolutionsTask');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Apply new captcha solutions to captcha dataset and recalculate merkle tree
|
|
27
|
+
*/
|
|
28
|
+
async run() {
|
|
29
|
+
try {
|
|
30
|
+
const taskRunning = await checkIfTaskIsRunning(ScheduledTaskNames.CalculateSolution, this.db);
|
|
31
|
+
if (!taskRunning) {
|
|
32
|
+
// Get the current datasetId from the contract
|
|
33
|
+
const provider = (await this.contract.methods.getProvider(this.contract.pair.address, {})).value
|
|
34
|
+
.unwrap()
|
|
35
|
+
.unwrap();
|
|
36
|
+
// Get any unsolved CAPTCHA challenges from the database for this datasetId
|
|
37
|
+
const unsolvedCaptchas = await this.db.getAllCaptchasByDatasetId(provider.datasetId.toString(), CaptchaStates.Unsolved);
|
|
38
|
+
// edge case when a captcha dataset contains no unsolved CAPTCHA challenges
|
|
39
|
+
if (!unsolvedCaptchas) {
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
// Sort the unsolved CAPTCHA challenges by their captchaId
|
|
43
|
+
const unsolvedSorted = unsolvedCaptchas.sort(captchaSort);
|
|
44
|
+
this.logger.info(`There are ${unsolvedSorted.length} unsolved CAPTCHA challenges`);
|
|
45
|
+
// Get the solution configuration from the config file
|
|
46
|
+
const requiredNumberOfSolutions = this.captchaSolutionConfig.requiredNumberOfSolutions;
|
|
47
|
+
const winningPercentage = this.captchaSolutionConfig.solutionWinningPercentage;
|
|
48
|
+
const winningNumberOfSolutions = Math.round(requiredNumberOfSolutions * (winningPercentage / 100));
|
|
49
|
+
if (unsolvedSorted && unsolvedSorted.length > 0) {
|
|
50
|
+
const captchaIds = unsolvedSorted.map((captcha) => captcha.captchaId);
|
|
51
|
+
const solutions = (await this.db.getAllDappUserSolutions(captchaIds)) || [];
|
|
52
|
+
const solutionsToUpdate = calculateNewSolutions(solutions, winningNumberOfSolutions);
|
|
53
|
+
if (solutionsToUpdate.rows().length > 0) {
|
|
54
|
+
this.logger.info(`There are ${solutionsToUpdate.rows().length} CAPTCHA challenges to update with solutions`);
|
|
55
|
+
try {
|
|
56
|
+
const captchaIdsToUpdate = [...solutionsToUpdate['captchaId'].values()];
|
|
57
|
+
const commitmentIds = solutions
|
|
58
|
+
.filter((s) => captchaIdsToUpdate.indexOf(s.captchaId) > -1)
|
|
59
|
+
.map((s) => s.commitmentId);
|
|
60
|
+
const dataset = await this.db.getDataset(provider.datasetId.toString());
|
|
61
|
+
dataset.captchas = updateSolutions(solutionsToUpdate, dataset.captchas, this.logger);
|
|
62
|
+
// store new solutions in database
|
|
63
|
+
await this.providerSetDataset(dataset);
|
|
64
|
+
// mark user solutions as used to calculate new solutions
|
|
65
|
+
await this.db.flagProcessedDappUserSolutions(captchaIdsToUpdate);
|
|
66
|
+
// mark user commitments as used to calculate new solutions
|
|
67
|
+
await this.db.flagProcessedDappUserCommitments(commitmentIds);
|
|
68
|
+
// remove old captcha challenges from database
|
|
69
|
+
await this.db.removeCaptchas(captchaIdsToUpdate);
|
|
70
|
+
return solutionsToUpdate.rows().length;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
this.logger.error(error);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this.logger.info(`There are no CAPTCHA challenges that require their solutions to be updated`);
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
throw new ProsopoEnvError(error, 'GENERAL.CALCULATE_CAPTCHA_SOLUTION');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=calculateSolutions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculateSolutions.js","sourceRoot":"","sources":["../../src/tasks/calculateSolutions.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,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC7C,YAAY,GAAwB;QAChC,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAA;IAC1E,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG;QACL,IAAI;YACA,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAA;YAC7F,IAAI,CAAC,WAAW,EAAE;gBACd,8CAA8C;gBAC9C,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAA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F,OAAO,CAAC,CAAA;iBACX;aACJ;YACD,OAAO,CAAC,CAAA;SACX;QAAC,OAAO,KAAK,EAAE;YACZ,MAAM,IAAI,eAAe,CAAC,KAAK,EAAE,oCAAoC,CAAC,CAAA;SACzE;IACL,CAAC;CACJ"}
|
package/dist/tasks/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":"AAaA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":"AAaA,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA"}
|
package/dist/tasks/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
// Copyright 2021-2022 Prosopo (UK) Ltd.
|
|
1
|
+
// Copyright 2021-2023 Prosopo (UK) Ltd.
|
|
5
2
|
//
|
|
6
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -14,5 +11,6 @@ const tslib_1 = require("tslib");
|
|
|
14
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
12
|
// See the License for the specific language governing permissions and
|
|
16
13
|
// limitations under the License.
|
|
17
|
-
|
|
14
|
+
export * from './tasks.js';
|
|
15
|
+
export * from './calculateSolutions.js';
|
|
18
16
|
//# sourceMappingURL=index.js.map
|
package/dist/tasks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tasks/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,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA"}
|
package/dist/tasks/tasks.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ArgumentTypes, Captcha, CaptchaConfig, CaptchaSolution, CaptchaSolutionConfig, CaptchaWithProof, DappUserSolutionResult, DatasetRaw, Hash, PendingCaptchaRequest } from '@prosopo/types';
|
|
1
|
+
import { ArgumentTypes, Captcha, CaptchaConfig, CaptchaSolution, CaptchaSolutionConfig, CaptchaWithProof, DappUserSolutionResult, DatasetRaw, DatasetWithIds, Hash, PendingCaptchaRequest, ProsopoConfig, Provider, ProviderRegistered } from '@prosopo/types';
|
|
2
|
+
import { Header } from '@polkadot/types/interfaces';
|
|
2
3
|
import { CaptchaMerkleTree } from '@prosopo/datasets';
|
|
3
4
|
import { Database, UserCommitmentRecord } from '@prosopo/types-database';
|
|
4
|
-
import { Header } from '@polkadot/types/interfaces/runtime/index';
|
|
5
5
|
import { Logger } from '@prosopo/common';
|
|
6
6
|
import { ProsopoCaptchaContract } from '@prosopo/contract';
|
|
7
7
|
import { ProviderEnvironment } from '@prosopo/types-env';
|
|
@@ -15,6 +15,7 @@ export declare class Tasks {
|
|
|
15
15
|
captchaConfig: CaptchaConfig;
|
|
16
16
|
captchaSolutionConfig: CaptchaSolutionConfig;
|
|
17
17
|
logger: Logger;
|
|
18
|
+
config: ProsopoConfig;
|
|
18
19
|
constructor(env: ProviderEnvironment);
|
|
19
20
|
providerSetDatasetFromFile(file: JSON): Promise<SubmittableResult | undefined>;
|
|
20
21
|
providerSetDataset(datasetRaw: DatasetRaw): Promise<SubmittableResult | undefined>;
|
|
@@ -40,9 +41,9 @@ export declare class Tasks {
|
|
|
40
41
|
*/
|
|
41
42
|
dappIsActive(dappAccount: string): Promise<boolean>;
|
|
42
43
|
/**
|
|
43
|
-
*
|
|
44
|
+
* Gets provider status in contract
|
|
44
45
|
*/
|
|
45
|
-
|
|
46
|
+
providerStatus(): Promise<ProviderRegistered>;
|
|
46
47
|
/**
|
|
47
48
|
* Validate length of received captchas array matches length of captchas found in database
|
|
48
49
|
* Validate that the datasetId is the same for all captchas and is equal to the datasetId on the stored captchas
|
|
@@ -78,10 +79,6 @@ export declare class Tasks {
|
|
|
78
79
|
captchas: CaptchaWithProof[];
|
|
79
80
|
requestHash: string;
|
|
80
81
|
}>;
|
|
81
|
-
/**
|
|
82
|
-
* Apply new captcha solutions to captcha dataset and recalculate merkle tree
|
|
83
|
-
*/
|
|
84
|
-
calculateCaptchaSolutions(): Promise<number>;
|
|
85
82
|
/**
|
|
86
83
|
* Block by block search for blockNo
|
|
87
84
|
*/
|
|
@@ -104,5 +101,8 @@ export declare class Tasks {
|
|
|
104
101
|
private getPaymentInfo;
|
|
105
102
|
getDappUserCommitmentById(commitmentId: string): Promise<UserCommitmentRecord>;
|
|
106
103
|
getDappUserCommitmentByAccount(userAccount: string): Promise<UserCommitmentRecord | undefined>;
|
|
104
|
+
getProviderDetails(): Promise<Provider>;
|
|
105
|
+
/** Get the dataset from the databse */
|
|
106
|
+
getProviderDataset(datasetId: string): Promise<DatasetWithIds>;
|
|
107
107
|
}
|
|
108
108
|
//# sourceMappingURL=tasks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/tasks/tasks.ts"],"names":[],"mappings":"AAaA,OAAO,EACH,aAAa,EACb,OAAO,EACP,aAAa,EACb,eAAe,EACf,qBAAqB,
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/tasks/tasks.ts"],"names":[],"mappings":"AAaA,OAAO,EACH,aAAa,EACb,OAAO,EACP,aAAa,EACb,eAAe,EACf,qBAAqB,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