@prosopo/types-database 0.1.19 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +15 -0
- package/dist/cjs/types/index.cjs +14 -0
- package/dist/cjs/types/mongo.cjs +139 -0
- package/package.json +11 -4
- package/vite.cjs.config.ts +6 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
+
require("./types/index.cjs");
|
4
|
+
const mongo = require("./types/mongo.cjs");
|
5
|
+
exports.CaptchaRecordSchema = mongo.CaptchaRecordSchema;
|
6
|
+
exports.DatasetRecordSchema = mongo.DatasetRecordSchema;
|
7
|
+
exports.PendingRecordSchema = mongo.PendingRecordSchema;
|
8
|
+
exports.ScheduledTaskRecordSchema = mongo.ScheduledTaskRecordSchema;
|
9
|
+
exports.ScheduledTaskSchema = mongo.ScheduledTaskSchema;
|
10
|
+
exports.SolutionRecordSchema = mongo.SolutionRecordSchema;
|
11
|
+
exports.UserCommitmentRecordSchema = mongo.UserCommitmentRecordSchema;
|
12
|
+
exports.UserCommitmentSchema = mongo.UserCommitmentSchema;
|
13
|
+
exports.UserCommitmentWithSolutionsSchema = mongo.UserCommitmentWithSolutionsSchema;
|
14
|
+
exports.UserSolutionRecordSchema = mongo.UserSolutionRecordSchema;
|
15
|
+
exports.UserSolutionSchema = mongo.UserSolutionSchema;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
+
const mongo = require("./mongo.cjs");
|
4
|
+
exports.CaptchaRecordSchema = mongo.CaptchaRecordSchema;
|
5
|
+
exports.DatasetRecordSchema = mongo.DatasetRecordSchema;
|
6
|
+
exports.PendingRecordSchema = mongo.PendingRecordSchema;
|
7
|
+
exports.ScheduledTaskRecordSchema = mongo.ScheduledTaskRecordSchema;
|
8
|
+
exports.ScheduledTaskSchema = mongo.ScheduledTaskSchema;
|
9
|
+
exports.SolutionRecordSchema = mongo.SolutionRecordSchema;
|
10
|
+
exports.UserCommitmentRecordSchema = mongo.UserCommitmentRecordSchema;
|
11
|
+
exports.UserCommitmentSchema = mongo.UserCommitmentSchema;
|
12
|
+
exports.UserCommitmentWithSolutionsSchema = mongo.UserCommitmentWithSolutionsSchema;
|
13
|
+
exports.UserSolutionRecordSchema = mongo.UserSolutionRecordSchema;
|
14
|
+
exports.UserSolutionSchema = mongo.UserSolutionSchema;
|
@@ -0,0 +1,139 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
+
const types = require("@prosopo/types");
|
4
|
+
const mongoose = require("mongoose");
|
5
|
+
const zod = require("zod");
|
6
|
+
const UserCommitmentSchema = zod.z.object({
|
7
|
+
userAccount: zod.z.string(),
|
8
|
+
dappContract: zod.z.string(),
|
9
|
+
datasetId: zod.z.string(),
|
10
|
+
providerAccount: zod.z.string(),
|
11
|
+
id: zod.z.string(),
|
12
|
+
status: zod.z.nativeEnum(types.ArgumentTypes.CaptchaStatus),
|
13
|
+
userSignature: zod.z.array(zod.z.number()),
|
14
|
+
completedAt: zod.z.number(),
|
15
|
+
requestedAt: zod.z.number(),
|
16
|
+
processed: zod.z.boolean(),
|
17
|
+
batched: zod.z.boolean()
|
18
|
+
});
|
19
|
+
const CaptchaRecordSchema = new mongoose.Schema({
|
20
|
+
captchaId: { type: String, required: true },
|
21
|
+
captchaContentId: { type: String, required: true },
|
22
|
+
assetURI: { type: String, required: false },
|
23
|
+
datasetId: { type: String, required: true },
|
24
|
+
datasetContentId: { type: String, required: true },
|
25
|
+
solved: { type: Boolean, required: true },
|
26
|
+
target: { type: String, required: true },
|
27
|
+
salt: { type: String, required: true },
|
28
|
+
items: {
|
29
|
+
type: [
|
30
|
+
new mongoose.Schema(
|
31
|
+
{
|
32
|
+
hash: { type: String, required: true },
|
33
|
+
data: { type: String, required: true },
|
34
|
+
type: { type: String, required: true }
|
35
|
+
},
|
36
|
+
{ _id: false }
|
37
|
+
)
|
38
|
+
],
|
39
|
+
required: true
|
40
|
+
}
|
41
|
+
});
|
42
|
+
CaptchaRecordSchema.index({ captchaId: 1 });
|
43
|
+
const UserCommitmentRecordSchema = new mongoose.Schema({
|
44
|
+
userAccount: { type: String, required: true },
|
45
|
+
dappContract: { type: String, required: true },
|
46
|
+
providerAccount: { type: String, required: true },
|
47
|
+
datasetId: { type: String, required: true },
|
48
|
+
id: { type: String, required: true },
|
49
|
+
status: { type: String, required: true },
|
50
|
+
requestedAt: { type: Number, required: true },
|
51
|
+
completedAt: { type: Number, required: true },
|
52
|
+
userSignature: { type: [Number], required: true },
|
53
|
+
processed: { type: Boolean, required: true },
|
54
|
+
batched: { type: Boolean, required: true }
|
55
|
+
});
|
56
|
+
UserCommitmentRecordSchema.index({ id: -1 });
|
57
|
+
const DatasetRecordSchema = new mongoose.Schema({
|
58
|
+
contentTree: { type: [[String]], required: true },
|
59
|
+
datasetContentId: { type: String, required: true },
|
60
|
+
datasetId: { type: String, required: true },
|
61
|
+
format: { type: String, required: true },
|
62
|
+
solutionTree: { type: [[String]], required: true }
|
63
|
+
});
|
64
|
+
DatasetRecordSchema.index({ datasetId: 1 });
|
65
|
+
const SolutionRecordSchema = new mongoose.Schema({
|
66
|
+
captchaId: { type: String, required: true },
|
67
|
+
captchaContentId: { type: String, required: true },
|
68
|
+
datasetId: { type: String, required: true },
|
69
|
+
datasetContentId: { type: String, required: true },
|
70
|
+
salt: { type: String, required: true },
|
71
|
+
solution: { type: [String], required: true }
|
72
|
+
});
|
73
|
+
SolutionRecordSchema.index({ captchaId: 1 });
|
74
|
+
const UserSolutionSchema = types.CaptchaSolutionSchema.extend({
|
75
|
+
processed: zod.z.boolean(),
|
76
|
+
commitmentId: zod.z.string()
|
77
|
+
});
|
78
|
+
const UserSolutionRecordSchema = new mongoose.Schema(
|
79
|
+
{
|
80
|
+
captchaId: { type: String, required: true },
|
81
|
+
captchaContentId: { type: String, required: true },
|
82
|
+
salt: { type: String, required: true },
|
83
|
+
solution: [{ type: String, required: true }],
|
84
|
+
processed: { type: Boolean, required: true },
|
85
|
+
commitmentId: { type: String, required: true }
|
86
|
+
},
|
87
|
+
{ _id: false }
|
88
|
+
);
|
89
|
+
UserSolutionRecordSchema.index({ captchaId: 1 });
|
90
|
+
const UserCommitmentWithSolutionsSchema = UserCommitmentSchema.extend({
|
91
|
+
captchas: zod.z.array(UserSolutionSchema)
|
92
|
+
});
|
93
|
+
const PendingRecordSchema = new mongoose.Schema({
|
94
|
+
accountId: { type: String, required: true },
|
95
|
+
pending: { type: Boolean, required: true },
|
96
|
+
salt: { type: String, required: true },
|
97
|
+
requestHash: { type: String, required: true },
|
98
|
+
deadlineTimestamp: { type: Number, required: true },
|
99
|
+
// unix timestamp
|
100
|
+
requestedAtBlock: { type: Number, required: true }
|
101
|
+
});
|
102
|
+
PendingRecordSchema.index({ requestHash: -1 });
|
103
|
+
const ScheduledTaskSchema = zod.z.object({
|
104
|
+
taskId: zod.z.string(),
|
105
|
+
processName: zod.z.nativeEnum(types.ScheduledTaskNames),
|
106
|
+
datetime: zod.z.date(),
|
107
|
+
status: zod.z.nativeEnum(types.ScheduledTaskStatus),
|
108
|
+
result: zod.z.object({
|
109
|
+
data: zod.z.any().optional(),
|
110
|
+
error: zod.z.any().optional()
|
111
|
+
}).optional()
|
112
|
+
});
|
113
|
+
const ScheduledTaskRecordSchema = new mongoose.Schema({
|
114
|
+
taskId: { type: String, required: true },
|
115
|
+
processName: { type: String, enum: types.ScheduledTaskNames, required: true },
|
116
|
+
datetime: { type: Date, required: true },
|
117
|
+
status: { type: String, enum: types.ScheduledTaskStatus, require: true },
|
118
|
+
result: {
|
119
|
+
type: new mongoose.Schema(
|
120
|
+
{
|
121
|
+
error: { type: String, required: false },
|
122
|
+
data: { type: Object, required: false }
|
123
|
+
},
|
124
|
+
{ _id: false }
|
125
|
+
),
|
126
|
+
required: false
|
127
|
+
}
|
128
|
+
});
|
129
|
+
exports.CaptchaRecordSchema = CaptchaRecordSchema;
|
130
|
+
exports.DatasetRecordSchema = DatasetRecordSchema;
|
131
|
+
exports.PendingRecordSchema = PendingRecordSchema;
|
132
|
+
exports.ScheduledTaskRecordSchema = ScheduledTaskRecordSchema;
|
133
|
+
exports.ScheduledTaskSchema = ScheduledTaskSchema;
|
134
|
+
exports.SolutionRecordSchema = SolutionRecordSchema;
|
135
|
+
exports.UserCommitmentRecordSchema = UserCommitmentRecordSchema;
|
136
|
+
exports.UserCommitmentSchema = UserCommitmentSchema;
|
137
|
+
exports.UserCommitmentWithSolutionsSchema = UserCommitmentWithSolutionsSchema;
|
138
|
+
exports.UserSolutionRecordSchema = UserSolutionRecordSchema;
|
139
|
+
exports.UserSolutionSchema = UserSolutionSchema;
|
package/package.json
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosopo/types-database",
|
3
|
-
"version": "0.1
|
3
|
+
"version": "0.2.1",
|
4
4
|
"description": "Types for prosopo database",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"type": "module",
|
7
|
+
"exports": {
|
8
|
+
".": {
|
9
|
+
"import": "./dist/index.js",
|
10
|
+
"require": "./dist/cjs/index.cjs"
|
11
|
+
}
|
12
|
+
},
|
7
13
|
"scripts": {
|
8
14
|
"clean": "tsc --build --clean",
|
9
|
-
"build": "tsc --build --verbose",
|
15
|
+
"build": "tsc --build --verbose tsconfig.json",
|
16
|
+
"build:cjs": "npx vite --config vite.cjs.config.ts build",
|
10
17
|
"lint": "npx eslint .",
|
11
18
|
"lint:fix": "npx eslint . --fix --config ../../.eslintrc.js"
|
12
19
|
},
|
@@ -22,8 +29,8 @@
|
|
22
29
|
"homepage": "https://github.com/prosopo/captcha#readme",
|
23
30
|
"dependencies": {
|
24
31
|
"@polkadot/types": "10.9.1",
|
25
|
-
"@prosopo/common": "
|
26
|
-
"@prosopo/types": "
|
32
|
+
"@prosopo/common": "0.2.1",
|
33
|
+
"@prosopo/types": "0.2.1",
|
27
34
|
"mongodb": "5.8.0",
|
28
35
|
"mongoose": "^7.3.3",
|
29
36
|
"zod": "^3.17.9"
|