@euler-edu/nest 0.0.0-stage → 7.0.1-beta0
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/lib/.tsbuildinfo +1 -0
- package/lib/connection/mongo/index.d.ts +3 -0
- package/lib/connection/mongo/index.d.ts.map +1 -0
- package/lib/connection/mongo/index.js +19 -0
- package/lib/connection/mongo/index.js.map +1 -0
- package/lib/connection/mongo/mongo.module.d.ts +5 -0
- package/lib/connection/mongo/mongo.module.d.ts.map +1 -0
- package/lib/connection/mongo/mongo.module.js +30 -0
- package/lib/connection/mongo/mongo.module.js.map +1 -0
- package/lib/connection/mongo/mongo.service.d.ts +21 -0
- package/lib/connection/mongo/mongo.service.d.ts.map +1 -0
- package/lib/connection/mongo/mongo.service.js +57 -0
- package/lib/connection/mongo/mongo.service.js.map +1 -0
- package/lib/connection/mongo/oj-main/contest.d.ts +399 -0
- package/lib/connection/mongo/oj-main/contest.d.ts.map +1 -0
- package/lib/connection/mongo/oj-main/contest.js +55 -0
- package/lib/connection/mongo/oj-main/contest.js.map +1 -0
- package/lib/connection/mongo/oj-main/index.d.ts +8 -0
- package/lib/connection/mongo/oj-main/index.d.ts.map +1 -0
- package/lib/connection/mongo/oj-main/index.js +18 -0
- package/lib/connection/mongo/oj-main/index.js.map +1 -0
- package/lib/connection/mongo/oj-main/mail.d.ts +55 -0
- package/lib/connection/mongo/oj-main/mail.d.ts.map +1 -0
- package/lib/connection/mongo/oj-main/mail.js +44 -0
- package/lib/connection/mongo/oj-main/mail.js.map +1 -0
- package/lib/connection/mongo/oj-main/problem.d.ts +103 -0
- package/lib/connection/mongo/oj-main/problem.d.ts.map +1 -0
- package/lib/connection/mongo/oj-main/problem.js +29 -0
- package/lib/connection/mongo/oj-main/problem.js.map +1 -0
- package/lib/connection/mongo/oj-main/record.d.ts +47 -0
- package/lib/connection/mongo/oj-main/record.d.ts.map +1 -0
- package/lib/connection/mongo/oj-main/record.js +26 -0
- package/lib/connection/mongo/oj-main/record.js.map +1 -0
- package/lib/connection/mongo/oj-main/sourceconsole.d.ts +67 -0
- package/lib/connection/mongo/oj-main/sourceconsole.d.ts.map +1 -0
- package/lib/connection/mongo/oj-main/sourceconsole.js +19 -0
- package/lib/connection/mongo/oj-main/sourceconsole.js.map +1 -0
- package/lib/connection/mongo/oj-main/sourcesubmit.d.ts +175 -0
- package/lib/connection/mongo/oj-main/sourcesubmit.d.ts.map +1 -0
- package/lib/connection/mongo/oj-main/sourcesubmit.js +47 -0
- package/lib/connection/mongo/oj-main/sourcesubmit.js.map +1 -0
- package/lib/connection/mongo/oj-main/user.d.ts +131 -0
- package/lib/connection/mongo/oj-main/user.d.ts.map +1 -0
- package/lib/connection/mongo/oj-main/user.js +35 -0
- package/lib/connection/mongo/oj-main/user.js.map +1 -0
- package/lib/connection/mongo/oj-sq/index.d.ts +3 -0
- package/lib/connection/mongo/oj-sq/index.d.ts.map +1 -0
- package/lib/connection/mongo/oj-sq/index.js +8 -0
- package/lib/connection/mongo/oj-sq/index.js.map +1 -0
- package/lib/connection/mongo/oj-sq/scoringRequest.d.ts +291 -0
- package/lib/connection/mongo/oj-sq/scoringRequest.d.ts.map +1 -0
- package/lib/connection/mongo/oj-sq/scoringRequest.js +58 -0
- package/lib/connection/mongo/oj-sq/scoringRequest.js.map +1 -0
- package/lib/connection/mongo/oj-sq/scoringServer.d.ts +39 -0
- package/lib/connection/mongo/oj-sq/scoringServer.d.ts.map +1 -0
- package/lib/connection/mongo/oj-sq/scoringServer.js +12 -0
- package/lib/connection/mongo/oj-sq/scoringServer.js.map +1 -0
- package/lib/connection/redis/index.d.ts +3 -0
- package/lib/connection/redis/index.d.ts.map +1 -0
- package/lib/connection/redis/index.js +19 -0
- package/lib/connection/redis/index.js.map +1 -0
- package/lib/connection/redis/redis.module.d.ts +5 -0
- package/lib/connection/redis/redis.module.d.ts.map +1 -0
- package/lib/connection/redis/redis.module.js +30 -0
- package/lib/connection/redis/redis.module.js.map +1 -0
- package/lib/connection/redis/redis.service.d.ts +35 -0
- package/lib/connection/redis/redis.service.d.ts.map +1 -0
- package/lib/connection/redis/redis.service.js +85 -0
- package/lib/connection/redis/redis.service.js.map +1 -0
- package/lib/connection/s3/index.d.ts +3 -0
- package/lib/connection/s3/index.d.ts.map +1 -0
- package/lib/connection/s3/index.js +19 -0
- package/lib/connection/s3/index.js.map +1 -0
- package/lib/connection/s3/s3.module.d.ts +11 -0
- package/lib/connection/s3/s3.module.d.ts.map +1 -0
- package/lib/connection/s3/s3.module.js +57 -0
- package/lib/connection/s3/s3.module.js.map +1 -0
- package/lib/connection/s3/s3.service.d.ts +54 -0
- package/lib/connection/s3/s3.service.d.ts.map +1 -0
- package/lib/connection/s3/s3.service.js +253 -0
- package/lib/connection/s3/s3.service.js.map +1 -0
- package/lib/connection/social/index.d.ts +3 -0
- package/lib/connection/social/index.d.ts.map +1 -0
- package/lib/connection/social/index.js +19 -0
- package/lib/connection/social/index.js.map +1 -0
- package/lib/connection/social/social.module.d.ts +3 -0
- package/lib/connection/social/social.module.d.ts.map +1 -0
- package/lib/connection/social/social.module.js +21 -0
- package/lib/connection/social/social.module.js.map +1 -0
- package/lib/connection/social/social.service.d.ts +16 -0
- package/lib/connection/social/social.service.d.ts.map +1 -0
- package/lib/connection/social/social.service.js +230 -0
- package/lib/connection/social/social.service.js.map +1 -0
- package/lib/connection/sqs/index.d.ts +3 -0
- package/lib/connection/sqs/index.d.ts.map +1 -0
- package/lib/connection/sqs/index.js +19 -0
- package/lib/connection/sqs/index.js.map +1 -0
- package/lib/connection/sqs/sqs.module.d.ts +5 -0
- package/lib/connection/sqs/sqs.module.d.ts.map +1 -0
- package/lib/connection/sqs/sqs.module.js +31 -0
- package/lib/connection/sqs/sqs.module.js.map +1 -0
- package/lib/connection/sqs/sqs.service.d.ts +28 -0
- package/lib/connection/sqs/sqs.service.d.ts.map +1 -0
- package/lib/connection/sqs/sqs.service.js +122 -0
- package/lib/connection/sqs/sqs.service.js.map +1 -0
- package/lib/constants/metadata.d.ts +5 -0
- package/lib/constants/metadata.d.ts.map +1 -0
- package/lib/constants/metadata.js +8 -0
- package/lib/constants/metadata.js.map +1 -0
- package/lib/decorators/auth.decorator.d.ts +15 -0
- package/lib/decorators/auth.decorator.d.ts.map +1 -0
- package/lib/decorators/auth.decorator.js +65 -0
- package/lib/decorators/auth.decorator.js.map +1 -0
- package/lib/decorators/client.decorator.d.ts +9 -0
- package/lib/decorators/client.decorator.d.ts.map +1 -0
- package/lib/decorators/client.decorator.js +49 -0
- package/lib/decorators/client.decorator.js.map +1 -0
- package/lib/decorators/endpoint.decorator.d.ts +3 -0
- package/lib/decorators/endpoint.decorator.d.ts.map +1 -0
- package/lib/decorators/endpoint.decorator.js +96 -0
- package/lib/decorators/endpoint.decorator.js.map +1 -0
- package/lib/decorators/index.d.ts +8 -0
- package/lib/decorators/index.d.ts.map +1 -0
- package/lib/decorators/index.js +24 -0
- package/lib/decorators/index.js.map +1 -0
- package/lib/decorators/mongo.decorator.d.ts +8 -0
- package/lib/decorators/mongo.decorator.d.ts.map +1 -0
- package/lib/decorators/mongo.decorator.js +115 -0
- package/lib/decorators/mongo.decorator.js.map +1 -0
- package/lib/decorators/socket.decorator.d.ts +5 -0
- package/lib/decorators/socket.decorator.d.ts.map +1 -0
- package/lib/decorators/socket.decorator.js +28 -0
- package/lib/decorators/socket.decorator.js.map +1 -0
- package/lib/decorators/sqs.decorator.d.ts +4 -0
- package/lib/decorators/sqs.decorator.d.ts.map +1 -0
- package/lib/decorators/sqs.decorator.js +8 -0
- package/lib/decorators/sqs.decorator.js.map +1 -0
- package/lib/decorators/swagger.decorator.d.ts +2 -0
- package/lib/decorators/swagger.decorator.d.ts.map +1 -0
- package/lib/decorators/swagger.decorator.js +8 -0
- package/lib/decorators/swagger.decorator.js.map +1 -0
- package/lib/filters/global.filters.d.ts +16 -0
- package/lib/filters/global.filters.d.ts.map +1 -0
- package/lib/filters/global.filters.js +75 -0
- package/lib/filters/global.filters.js.map +1 -0
- package/lib/filters/index.d.ts +2 -0
- package/lib/filters/index.d.ts.map +1 -0
- package/lib/filters/index.js +18 -0
- package/lib/filters/index.js.map +1 -0
- package/lib/guards/auth.guard.d.ts +13 -0
- package/lib/guards/auth.guard.d.ts.map +1 -0
- package/lib/guards/auth.guard.js +61 -0
- package/lib/guards/auth.guard.js.map +1 -0
- package/lib/guards/endpoint.guard.d.ts +4 -0
- package/lib/guards/endpoint.guard.d.ts.map +1 -0
- package/lib/guards/endpoint.guard.js +39 -0
- package/lib/guards/endpoint.guard.js.map +1 -0
- package/lib/guards/global.guard.d.ts +10 -0
- package/lib/guards/global.guard.d.ts.map +1 -0
- package/lib/guards/global.guard.js +139 -0
- package/lib/guards/global.guard.js.map +1 -0
- package/lib/guards/index.d.ts +5 -0
- package/lib/guards/index.d.ts.map +1 -0
- package/lib/guards/index.js +21 -0
- package/lib/guards/index.js.map +1 -0
- package/lib/guards/socket.guard.d.ts +4 -0
- package/lib/guards/socket.guard.d.ts.map +1 -0
- package/lib/guards/socket.guard.js +35 -0
- package/lib/guards/socket.guard.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/lib/logger/index.d.ts +3 -0
- package/lib/logger/index.d.ts.map +1 -0
- package/lib/logger/index.js +21 -0
- package/lib/logger/index.js.map +1 -0
- package/lib/logger/logger.module.d.ts +3 -0
- package/lib/logger/logger.module.d.ts.map +1 -0
- package/lib/logger/logger.module.js +46 -0
- package/lib/logger/logger.module.js.map +1 -0
- package/lib/recaptcha/index.d.ts +3 -0
- package/lib/recaptcha/index.d.ts.map +1 -0
- package/lib/recaptcha/index.js +19 -0
- package/lib/recaptcha/index.js.map +1 -0
- package/lib/recaptcha/recaptcha.module.d.ts +3 -0
- package/lib/recaptcha/recaptcha.module.d.ts.map +1 -0
- package/lib/recaptcha/recaptcha.module.js +21 -0
- package/lib/recaptcha/recaptcha.module.js.map +1 -0
- package/lib/recaptcha/recaptcha.service.d.ts +5 -0
- package/lib/recaptcha/recaptcha.service.d.ts.map +1 -0
- package/lib/recaptcha/recaptcha.service.js +46 -0
- package/lib/recaptcha/recaptcha.service.js.map +1 -0
- package/lib/utils/image/index.d.ts +4 -0
- package/lib/utils/image/index.d.ts.map +1 -0
- package/lib/utils/image/index.js +16 -0
- package/lib/utils/image/index.js.map +1 -0
- package/lib/utils/jwt/index.d.ts +2 -0
- package/lib/utils/jwt/index.d.ts.map +1 -0
- package/lib/utils/jwt/index.js +38 -0
- package/lib/utils/jwt/index.js.map +1 -0
- package/lib/utils/logger/index.d.ts +45 -0
- package/lib/utils/logger/index.d.ts.map +1 -0
- package/lib/utils/logger/index.js +59 -0
- package/lib/utils/logger/index.js.map +1 -0
- package/lib/utils/mongo/index.d.ts +2 -0
- package/lib/utils/mongo/index.d.ts.map +1 -0
- package/lib/utils/mongo/index.js +6 -0
- package/lib/utils/mongo/index.js.map +1 -0
- package/lib/utils/swagger/index.d.ts +7 -0
- package/lib/utils/swagger/index.d.ts.map +1 -0
- package/lib/utils/swagger/index.js +29 -0
- package/lib/utils/swagger/index.js.map +1 -0
- package/package.json +62 -3
- package/README.md +0 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scoringServerSchema = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
exports.scoringServerSchema = new mongoose_1.Schema({
|
|
6
|
+
name: { type: String, required: true, unique: true },
|
|
7
|
+
type: { type: String, required: true },
|
|
8
|
+
last_scoring_request_at: { type: Date, required: false },
|
|
9
|
+
created_at: { type: Date, required: true },
|
|
10
|
+
updated_at: { type: Date, required: true },
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=scoringServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoringServer.js","sourceRoot":"","sources":["../../../../src/connection/mongo/oj-sq/scoringServer.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAErB,QAAA,mBAAmB,GAAG,IAAI,iBAAM,CAAC;IAC5C,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IACpD,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACtC,uBAAuB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE;IACxD,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC1C,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;CAC3C,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/redis/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./redis.module"), exports);
|
|
18
|
+
__exportStar(require("./redis.service"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/redis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,kDAAgC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.module.d.ts","sourceRoot":"","sources":["../../../src/connection/redis/redis.module.ts"],"names":[],"mappings":"AAIA,qBAIa,iBAAiB;CAAG;AAEjC,qBAIa,iBAAiB;CAAG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.RedisOjAuthModule = exports.RedisOjRankModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const redis_service_1 = require("./redis.service");
|
|
12
|
+
let RedisOjRankModule = class RedisOjRankModule {
|
|
13
|
+
};
|
|
14
|
+
exports.RedisOjRankModule = RedisOjRankModule;
|
|
15
|
+
exports.RedisOjRankModule = RedisOjRankModule = __decorate([
|
|
16
|
+
(0, common_1.Module)({
|
|
17
|
+
providers: [redis_service_1.RedisOjRankService],
|
|
18
|
+
exports: [redis_service_1.RedisOjRankService],
|
|
19
|
+
})
|
|
20
|
+
], RedisOjRankModule);
|
|
21
|
+
let RedisOjAuthModule = class RedisOjAuthModule {
|
|
22
|
+
};
|
|
23
|
+
exports.RedisOjAuthModule = RedisOjAuthModule;
|
|
24
|
+
exports.RedisOjAuthModule = RedisOjAuthModule = __decorate([
|
|
25
|
+
(0, common_1.Module)({
|
|
26
|
+
providers: [redis_service_1.RedisOjAuthService],
|
|
27
|
+
exports: [redis_service_1.RedisOjAuthService],
|
|
28
|
+
})
|
|
29
|
+
], RedisOjAuthModule);
|
|
30
|
+
//# sourceMappingURL=redis.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.module.js","sourceRoot":"","sources":["../../../src/connection/redis/redis.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AAExC,mDAAyE;AAMlE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,8CAAiB;4BAAjB,iBAAiB;IAJ7B,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,kCAAkB,CAAC;QAC/B,OAAO,EAAE,CAAC,kCAAkB,CAAC;KAC9B,CAAC;GACW,iBAAiB,CAAG;AAM1B,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,8CAAiB;4BAAjB,iBAAiB;IAJ7B,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,kCAAkB,CAAC;QAC/B,OAAO,EAAE,CAAC,kCAAkB,CAAC;KAC9B,CAAC;GACW,iBAAiB,CAAG"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createClient } from 'redis';
|
|
2
|
+
import { z } from '@euler-edu/schema';
|
|
3
|
+
export declare class RedisOjRankService {
|
|
4
|
+
private readonly logger;
|
|
5
|
+
client: ReturnType<typeof createClient>;
|
|
6
|
+
readonly prefix: {
|
|
7
|
+
readonly rank: "rank:";
|
|
8
|
+
};
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
11
|
+
export declare class RedisOjAuthService {
|
|
12
|
+
private readonly logger;
|
|
13
|
+
client: ReturnType<typeof createClient>;
|
|
14
|
+
readonly prefix: {
|
|
15
|
+
readonly refreshToken: "refreshToken:";
|
|
16
|
+
};
|
|
17
|
+
readonly schema: {
|
|
18
|
+
readonly refreshToken: z.ZodObject<{
|
|
19
|
+
deviceId: z.ZodString;
|
|
20
|
+
refreshToken: z.ZodString;
|
|
21
|
+
issuedBy: z.ZodLiteral<"oj-api">;
|
|
22
|
+
issuedAt: z.ZodISODateTime;
|
|
23
|
+
expiredAt: z.ZodISODateTime;
|
|
24
|
+
clientMetadata: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
ip: z.ZodOptional<z.ZodString>;
|
|
26
|
+
location: z.ZodOptional<z.ZodString>;
|
|
27
|
+
browser: z.ZodOptional<z.ZodString>;
|
|
28
|
+
os: z.ZodOptional<z.ZodString>;
|
|
29
|
+
device: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
};
|
|
33
|
+
constructor();
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=redis.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.service.d.ts","sourceRoot":"","sources":["../../../src/connection/redis/redis.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAGtC,qBACa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IACvD,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IAC/C,SAAgB,MAAM;;MAEX;;CAeZ;AAED,qBACa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IACvD,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IAC/C,SAAgB,MAAM;;MAEX;IACX,SAAgB,MAAM;;;;;;;;;;;;;;;MAiBX;;CAeZ"}
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
var RedisOjRankService_1, RedisOjAuthService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.RedisOjAuthService = exports.RedisOjRankService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const redis_1 = require("redis");
|
|
19
|
+
const schema_1 = require("@euler-edu/schema");
|
|
20
|
+
const constants_1 = __importDefault(require("@euler-edu/utils/constants"));
|
|
21
|
+
let RedisOjRankService = RedisOjRankService_1 = class RedisOjRankService {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.logger = new common_1.Logger(RedisOjRankService_1.name);
|
|
24
|
+
this.prefix = {
|
|
25
|
+
rank: 'rank:',
|
|
26
|
+
};
|
|
27
|
+
this.client = (0, redis_1.createClient)({
|
|
28
|
+
url: constants_1.default.url.redis.ojRankUrl,
|
|
29
|
+
});
|
|
30
|
+
this.client.on('ready', () => {
|
|
31
|
+
this.logger.log('Redis-oj-rank-DB is connected');
|
|
32
|
+
});
|
|
33
|
+
this.client.on('error', err => {
|
|
34
|
+
this.logger.error(err);
|
|
35
|
+
});
|
|
36
|
+
this.client.connect();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.RedisOjRankService = RedisOjRankService;
|
|
40
|
+
exports.RedisOjRankService = RedisOjRankService = RedisOjRankService_1 = __decorate([
|
|
41
|
+
(0, common_1.Injectable)(),
|
|
42
|
+
__metadata("design:paramtypes", [])
|
|
43
|
+
], RedisOjRankService);
|
|
44
|
+
let RedisOjAuthService = RedisOjAuthService_1 = class RedisOjAuthService {
|
|
45
|
+
constructor() {
|
|
46
|
+
this.logger = new common_1.Logger(RedisOjAuthService_1.name);
|
|
47
|
+
this.prefix = {
|
|
48
|
+
refreshToken: 'refreshToken:',
|
|
49
|
+
};
|
|
50
|
+
this.schema = {
|
|
51
|
+
refreshToken: schema_1.z.object({
|
|
52
|
+
deviceId: schema_1.z.string().trim().min(1),
|
|
53
|
+
refreshToken: schema_1.z.string().trim().min(1),
|
|
54
|
+
issuedBy: schema_1.z.literal('oj-api'),
|
|
55
|
+
issuedAt: schema_1.z.iso.datetime({ offset: true }),
|
|
56
|
+
expiredAt: schema_1.z.iso.datetime({ offset: true }),
|
|
57
|
+
clientMetadata: schema_1.z
|
|
58
|
+
.object({
|
|
59
|
+
ip: schema_1.z.string().trim().min(1).optional(),
|
|
60
|
+
location: schema_1.z.string().trim().min(1).optional(),
|
|
61
|
+
browser: schema_1.z.string().trim().min(1).optional(),
|
|
62
|
+
os: schema_1.z.string().trim().min(1).optional(),
|
|
63
|
+
device: schema_1.z.string().trim().min(1).optional(),
|
|
64
|
+
})
|
|
65
|
+
.optional(),
|
|
66
|
+
}),
|
|
67
|
+
};
|
|
68
|
+
this.client = (0, redis_1.createClient)({
|
|
69
|
+
url: constants_1.default.url.redis.ojAuthUrl,
|
|
70
|
+
});
|
|
71
|
+
this.client.on('ready', () => {
|
|
72
|
+
this.logger.log('Redis-oj-auth-DB is connected');
|
|
73
|
+
});
|
|
74
|
+
this.client.on('error', err => {
|
|
75
|
+
this.logger.error(err);
|
|
76
|
+
});
|
|
77
|
+
this.client.connect();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
exports.RedisOjAuthService = RedisOjAuthService;
|
|
81
|
+
exports.RedisOjAuthService = RedisOjAuthService = RedisOjAuthService_1 = __decorate([
|
|
82
|
+
(0, common_1.Injectable)(),
|
|
83
|
+
__metadata("design:paramtypes", [])
|
|
84
|
+
], RedisOjAuthService);
|
|
85
|
+
//# sourceMappingURL=redis.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.service.js","sourceRoot":"","sources":["../../../src/connection/redis/redis.service.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/s3/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./s3.module"), exports);
|
|
18
|
+
__exportStar(require("./s3.service"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/s3/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,+CAA6B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class S3OjPublicModule {
|
|
2
|
+
}
|
|
3
|
+
export declare class S3OjArchivesModule {
|
|
4
|
+
}
|
|
5
|
+
export declare class S3OjScoringStorageModule {
|
|
6
|
+
}
|
|
7
|
+
export declare class S3OjProblemModule {
|
|
8
|
+
}
|
|
9
|
+
export declare class S3OjSourceModule {
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=s3.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.module.d.ts","sourceRoot":"","sources":["../../../src/connection/s3/s3.module.ts"],"names":[],"mappings":"AAUA,qBAIa,gBAAgB;CAAG;AAEhC,qBAIa,kBAAkB;CAAG;AAElC,qBAIa,wBAAwB;CAAG;AAExC,qBAIa,iBAAiB;CAAG;AAEjC,qBAIa,gBAAgB;CAAG"}
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.S3OjSourceModule = exports.S3OjProblemModule = exports.S3OjScoringStorageModule = exports.S3OjArchivesModule = exports.S3OjPublicModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const s3_service_1 = require("./s3.service");
|
|
12
|
+
let S3OjPublicModule = class S3OjPublicModule {
|
|
13
|
+
};
|
|
14
|
+
exports.S3OjPublicModule = S3OjPublicModule;
|
|
15
|
+
exports.S3OjPublicModule = S3OjPublicModule = __decorate([
|
|
16
|
+
(0, common_1.Module)({
|
|
17
|
+
providers: [s3_service_1.S3OjPublicService],
|
|
18
|
+
exports: [s3_service_1.S3OjPublicService],
|
|
19
|
+
})
|
|
20
|
+
], S3OjPublicModule);
|
|
21
|
+
let S3OjArchivesModule = class S3OjArchivesModule {
|
|
22
|
+
};
|
|
23
|
+
exports.S3OjArchivesModule = S3OjArchivesModule;
|
|
24
|
+
exports.S3OjArchivesModule = S3OjArchivesModule = __decorate([
|
|
25
|
+
(0, common_1.Module)({
|
|
26
|
+
providers: [s3_service_1.S3OjArchivesService],
|
|
27
|
+
exports: [s3_service_1.S3OjArchivesService],
|
|
28
|
+
})
|
|
29
|
+
], S3OjArchivesModule);
|
|
30
|
+
let S3OjScoringStorageModule = class S3OjScoringStorageModule {
|
|
31
|
+
};
|
|
32
|
+
exports.S3OjScoringStorageModule = S3OjScoringStorageModule;
|
|
33
|
+
exports.S3OjScoringStorageModule = S3OjScoringStorageModule = __decorate([
|
|
34
|
+
(0, common_1.Module)({
|
|
35
|
+
providers: [s3_service_1.S3OjScoringStorageService],
|
|
36
|
+
exports: [s3_service_1.S3OjScoringStorageService],
|
|
37
|
+
})
|
|
38
|
+
], S3OjScoringStorageModule);
|
|
39
|
+
let S3OjProblemModule = class S3OjProblemModule {
|
|
40
|
+
};
|
|
41
|
+
exports.S3OjProblemModule = S3OjProblemModule;
|
|
42
|
+
exports.S3OjProblemModule = S3OjProblemModule = __decorate([
|
|
43
|
+
(0, common_1.Module)({
|
|
44
|
+
providers: [s3_service_1.S3OjProblemService],
|
|
45
|
+
exports: [s3_service_1.S3OjProblemService],
|
|
46
|
+
})
|
|
47
|
+
], S3OjProblemModule);
|
|
48
|
+
let S3OjSourceModule = class S3OjSourceModule {
|
|
49
|
+
};
|
|
50
|
+
exports.S3OjSourceModule = S3OjSourceModule;
|
|
51
|
+
exports.S3OjSourceModule = S3OjSourceModule = __decorate([
|
|
52
|
+
(0, common_1.Module)({
|
|
53
|
+
providers: [s3_service_1.S3OjSourceService],
|
|
54
|
+
exports: [s3_service_1.S3OjSourceService],
|
|
55
|
+
})
|
|
56
|
+
], S3OjSourceModule);
|
|
57
|
+
//# sourceMappingURL=s3.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.module.js","sourceRoot":"","sources":["../../../src/connection/s3/s3.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AAExC,6CAMsB;AAMf,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAAG,CAAA;AAAnB,4CAAgB;2BAAhB,gBAAgB;IAJ5B,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,8BAAiB,CAAC;QAC9B,OAAO,EAAE,CAAC,8BAAiB,CAAC;KAC7B,CAAC;GACW,gBAAgB,CAAG;AAMzB,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAAG,CAAA;AAArB,gDAAkB;6BAAlB,kBAAkB;IAJ9B,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,gCAAmB,CAAC;QAChC,OAAO,EAAE,CAAC,gCAAmB,CAAC;KAC/B,CAAC;GACW,kBAAkB,CAAG;AAM3B,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;CAAG,CAAA;AAA3B,4DAAwB;mCAAxB,wBAAwB;IAJpC,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,sCAAyB,CAAC;QACtC,OAAO,EAAE,CAAC,sCAAyB,CAAC;KACrC,CAAC;GACW,wBAAwB,CAAG;AAMjC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,8CAAiB;4BAAjB,iBAAiB;IAJ7B,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,+BAAkB,CAAC;QAC/B,OAAO,EAAE,CAAC,+BAAkB,CAAC;KAC9B,CAAC;GACW,iBAAiB,CAAG;AAM1B,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAAG,CAAA;AAAnB,4CAAgB;2BAAhB,gBAAgB;IAJ5B,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,8BAAiB,CAAC;QAC9B,OAAO,EAAE,CAAC,8BAAiB,CAAC;KAC7B,CAAC;GACW,gBAAgB,CAAG"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type ListObjectsV2Output } from '@aws-sdk/client-s3';
|
|
2
|
+
type ObjectVersion = {
|
|
3
|
+
Size?: number;
|
|
4
|
+
Key?: string;
|
|
5
|
+
VersionId?: string;
|
|
6
|
+
IsLatest?: boolean;
|
|
7
|
+
LastModified?: Date;
|
|
8
|
+
};
|
|
9
|
+
declare abstract class S3Service {
|
|
10
|
+
private readonly s3BucketName;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
constructor(s3BucketName: string);
|
|
13
|
+
getList(directoryPath?: string): Promise<NonNullable<ListObjectsV2Output['Contents']>>;
|
|
14
|
+
getObjectExists(filePath: string, versionId?: string): Promise<boolean>;
|
|
15
|
+
getObject(filePath: string, versionId?: string): Promise<string>;
|
|
16
|
+
getObjectVersions(filePath: string): Promise<ObjectVersion[]>;
|
|
17
|
+
createUploadUrl(filePath: string, options?: {
|
|
18
|
+
expiresIn?: number;
|
|
19
|
+
contentType?: string;
|
|
20
|
+
maxSizeBytes?: number;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
url: string;
|
|
23
|
+
fields: Record<string, string>;
|
|
24
|
+
}>;
|
|
25
|
+
createDownloadUrl(filePath: string, options?: {
|
|
26
|
+
expiresIn?: number;
|
|
27
|
+
}): Promise<string>;
|
|
28
|
+
pushObject(filePath: string, fileContent: string | Buffer, contentType?: string): Promise<{
|
|
29
|
+
Key: string;
|
|
30
|
+
VersionId?: string;
|
|
31
|
+
}>;
|
|
32
|
+
deleteObject(filePath: string, versionId?: string): Promise<void>;
|
|
33
|
+
syncObject(filePath: string, localPath: string): Promise<{
|
|
34
|
+
key: string;
|
|
35
|
+
versionId: string;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
export declare class S3OjPublicService extends S3Service {
|
|
39
|
+
constructor();
|
|
40
|
+
}
|
|
41
|
+
export declare class S3OjArchivesService extends S3Service {
|
|
42
|
+
constructor();
|
|
43
|
+
}
|
|
44
|
+
export declare class S3OjScoringStorageService extends S3Service {
|
|
45
|
+
constructor();
|
|
46
|
+
}
|
|
47
|
+
export declare class S3OjProblemService extends S3Service {
|
|
48
|
+
constructor();
|
|
49
|
+
}
|
|
50
|
+
export declare class S3OjSourceService extends S3Service {
|
|
51
|
+
constructor();
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=s3.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.service.d.ts","sourceRoot":"","sources":["../../../src/connection/s3/s3.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EAGzB,MAAM,oBAAoB,CAAC;AAmB5B,KAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,IAAI,CAAC;CACrB,CAAC;AAKF,uBAAe,SAAS;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8B;gBAEzC,YAAY,EAAE,MAAM;IAI1B,OAAO,CACX,aAAa,GAAE,MAAW,GACzB,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAAC;IAyBlD,eAAe,CACnB,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,CAAC;IAwBb,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAehE,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAuB7D,eAAe,CACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GACA,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;IAoBrD,iBAAiB,CACrB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAC/B,OAAO,CAAC,MAAM,CAAC;IAiBZ,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAmBzC,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAajE,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CA8B/C;AAED,qBACa,iBAAkB,SAAQ,SAAS;;CAI/C;AAED,qBACa,mBAAoB,SAAQ,SAAS;;CAIjD;AAED,qBACa,yBAA0B,SAAQ,SAAS;;CAIvD;AAED,qBACa,kBAAmB,SAAQ,SAAS;;CAIhD;AAED,qBACa,iBAAkB,SAAQ,SAAS;;CAI/C"}
|
|
@@ -0,0 +1,253 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.S3OjSourceService = exports.S3OjProblemService = exports.S3OjScoringStorageService = exports.S3OjArchivesService = exports.S3OjPublicService = void 0;
|
|
16
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
17
|
+
const s3_presigned_post_1 = require("@aws-sdk/s3-presigned-post");
|
|
18
|
+
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
19
|
+
const common_1 = require("@nestjs/common");
|
|
20
|
+
const fs_1 = __importDefault(require("fs"));
|
|
21
|
+
const constants_1 = __importDefault(require("@euler-edu/utils/constants"));
|
|
22
|
+
const s3 = new client_s3_1.S3({
|
|
23
|
+
apiVersion: '2006-03-01',
|
|
24
|
+
region: constants_1.default.secrets.aws.region,
|
|
25
|
+
});
|
|
26
|
+
const s3Client = new client_s3_1.S3Client({
|
|
27
|
+
apiVersion: '2006-03-01',
|
|
28
|
+
region: constants_1.default.secrets.aws.region,
|
|
29
|
+
});
|
|
30
|
+
const byLatest = (a, b) => (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0);
|
|
31
|
+
class S3Service {
|
|
32
|
+
constructor(s3BucketName) {
|
|
33
|
+
this.logger = new common_1.Logger(S3Service.name);
|
|
34
|
+
this.s3BucketName = s3BucketName;
|
|
35
|
+
}
|
|
36
|
+
async getList(directoryPath = '') {
|
|
37
|
+
const contents = [];
|
|
38
|
+
let continuationToken;
|
|
39
|
+
do {
|
|
40
|
+
const data = await s3
|
|
41
|
+
.listObjectsV2({
|
|
42
|
+
Bucket: this.s3BucketName,
|
|
43
|
+
Prefix: directoryPath,
|
|
44
|
+
ContinuationToken: continuationToken,
|
|
45
|
+
})
|
|
46
|
+
.catch(err => {
|
|
47
|
+
this.logger.error(err);
|
|
48
|
+
throw new Error('Failed to list objects in S3 bucket');
|
|
49
|
+
});
|
|
50
|
+
if (data.Contents)
|
|
51
|
+
contents.push(...data.Contents);
|
|
52
|
+
continuationToken = data.IsTruncated
|
|
53
|
+
? data.NextContinuationToken
|
|
54
|
+
: undefined;
|
|
55
|
+
} while (continuationToken);
|
|
56
|
+
return contents;
|
|
57
|
+
}
|
|
58
|
+
async getObjectExists(filePath, versionId) {
|
|
59
|
+
try {
|
|
60
|
+
await s3.headObject({
|
|
61
|
+
Bucket: this.s3BucketName,
|
|
62
|
+
Key: filePath,
|
|
63
|
+
VersionId: versionId,
|
|
64
|
+
});
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
const statusCode = err?.$metadata?.httpStatusCode ?? err?.$response?.statusCode;
|
|
69
|
+
const errorName = err?.name;
|
|
70
|
+
if (statusCode === 404 ||
|
|
71
|
+
errorName === 'NotFound' ||
|
|
72
|
+
errorName === 'NoSuchKey') {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
this.logger.error(err);
|
|
76
|
+
throw new Error('Failed to check object existence in S3 bucket');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async getObject(filePath, versionId) {
|
|
80
|
+
const data = await s3
|
|
81
|
+
.getObject({
|
|
82
|
+
Bucket: this.s3BucketName,
|
|
83
|
+
Key: filePath,
|
|
84
|
+
VersionId: versionId,
|
|
85
|
+
})
|
|
86
|
+
.catch(err => {
|
|
87
|
+
this.logger.error(err);
|
|
88
|
+
throw new Error('Failed to get object from S3 bucket');
|
|
89
|
+
});
|
|
90
|
+
if (!data.Body)
|
|
91
|
+
throw new Error('Not Found');
|
|
92
|
+
return await data.Body.transformToString();
|
|
93
|
+
}
|
|
94
|
+
async getObjectVersions(filePath) {
|
|
95
|
+
const data = await s3
|
|
96
|
+
.listObjectVersions({
|
|
97
|
+
Bucket: this.s3BucketName,
|
|
98
|
+
Prefix: filePath,
|
|
99
|
+
})
|
|
100
|
+
.catch(err => {
|
|
101
|
+
this.logger.error(err);
|
|
102
|
+
throw new Error('Failed to list object versions in S3 bucket');
|
|
103
|
+
});
|
|
104
|
+
if (!data.Versions)
|
|
105
|
+
throw new Error('data does not have Versions');
|
|
106
|
+
return data.Versions.filter(({ Key }) => Key === filePath)
|
|
107
|
+
.map(({ Size, Key, VersionId, IsLatest, LastModified }) => ({
|
|
108
|
+
Size,
|
|
109
|
+
Key,
|
|
110
|
+
VersionId,
|
|
111
|
+
IsLatest,
|
|
112
|
+
LastModified,
|
|
113
|
+
}))
|
|
114
|
+
.sort(byLatest);
|
|
115
|
+
}
|
|
116
|
+
async createUploadUrl(filePath, options) {
|
|
117
|
+
const { url, fields } = await (0, s3_presigned_post_1.createPresignedPost)(s3Client, {
|
|
118
|
+
Bucket: this.s3BucketName,
|
|
119
|
+
Key: filePath,
|
|
120
|
+
Conditions: [
|
|
121
|
+
['content-length-range', 0, options?.maxSizeBytes || 5 * 1024 * 1024],
|
|
122
|
+
],
|
|
123
|
+
Fields: {
|
|
124
|
+
...(options?.contentType
|
|
125
|
+
? { 'Content-Type': options.contentType }
|
|
126
|
+
: {}),
|
|
127
|
+
},
|
|
128
|
+
Expires: options?.expiresIn || 900,
|
|
129
|
+
}).catch(err => {
|
|
130
|
+
this.logger.error(err);
|
|
131
|
+
throw new Error('Failed to create upload URL for S3 object');
|
|
132
|
+
});
|
|
133
|
+
return { url, fields };
|
|
134
|
+
}
|
|
135
|
+
async createDownloadUrl(filePath, options) {
|
|
136
|
+
const command = new client_s3_1.GetObjectCommand({
|
|
137
|
+
Bucket: this.s3BucketName,
|
|
138
|
+
Key: filePath,
|
|
139
|
+
});
|
|
140
|
+
const url = await (0, s3_request_presigner_1.getSignedUrl)(s3Client, command, {
|
|
141
|
+
expiresIn: options?.expiresIn || 900,
|
|
142
|
+
}).catch(err => {
|
|
143
|
+
this.logger.error(err);
|
|
144
|
+
throw new Error('Failed to create download URL for S3 object');
|
|
145
|
+
});
|
|
146
|
+
return url;
|
|
147
|
+
}
|
|
148
|
+
async pushObject(filePath, fileContent, contentType) {
|
|
149
|
+
const data = await s3
|
|
150
|
+
.putObject({
|
|
151
|
+
Bucket: this.s3BucketName,
|
|
152
|
+
Key: filePath,
|
|
153
|
+
Body: fileContent,
|
|
154
|
+
ContentType: contentType,
|
|
155
|
+
})
|
|
156
|
+
.catch(err => {
|
|
157
|
+
this.logger.error(err);
|
|
158
|
+
throw new Error('Failed to push object to S3 bucket');
|
|
159
|
+
});
|
|
160
|
+
return { Key: filePath, VersionId: data.VersionId };
|
|
161
|
+
}
|
|
162
|
+
async deleteObject(filePath, versionId) {
|
|
163
|
+
await s3
|
|
164
|
+
.deleteObject({
|
|
165
|
+
Bucket: this.s3BucketName,
|
|
166
|
+
Key: filePath,
|
|
167
|
+
VersionId: versionId,
|
|
168
|
+
})
|
|
169
|
+
.catch(err => {
|
|
170
|
+
this.logger.error(err);
|
|
171
|
+
throw new Error('Failed to delete object from S3 bucket');
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async syncObject(filePath, localPath) {
|
|
175
|
+
const versions = await this.getObjectVersions(filePath);
|
|
176
|
+
const versionId = versions[0]?.VersionId;
|
|
177
|
+
if (!versionId)
|
|
178
|
+
throw new Error('Not Found');
|
|
179
|
+
const data = await s3
|
|
180
|
+
.getObject({
|
|
181
|
+
Bucket: this.s3BucketName,
|
|
182
|
+
Key: filePath,
|
|
183
|
+
VersionId: versionId,
|
|
184
|
+
})
|
|
185
|
+
.catch(err => {
|
|
186
|
+
this.logger.error(err);
|
|
187
|
+
throw new Error('Failed to get object from S3 bucket');
|
|
188
|
+
});
|
|
189
|
+
if (!data.Body)
|
|
190
|
+
throw new Error('Not Found');
|
|
191
|
+
await new Promise((resolve, reject) => {
|
|
192
|
+
const fileStream = fs_1.default.createWriteStream(localPath);
|
|
193
|
+
const bodyStream = data.Body;
|
|
194
|
+
bodyStream
|
|
195
|
+
.pipe(fileStream)
|
|
196
|
+
.on('finish', () => resolve())
|
|
197
|
+
.on('error', reject);
|
|
198
|
+
bodyStream.on('error', reject);
|
|
199
|
+
});
|
|
200
|
+
return { key: filePath, versionId };
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
let S3OjPublicService = class S3OjPublicService extends S3Service {
|
|
204
|
+
constructor() {
|
|
205
|
+
super(constants_1.default.secrets.s3.ojPublicBucket.name);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
exports.S3OjPublicService = S3OjPublicService;
|
|
209
|
+
exports.S3OjPublicService = S3OjPublicService = __decorate([
|
|
210
|
+
(0, common_1.Injectable)(),
|
|
211
|
+
__metadata("design:paramtypes", [])
|
|
212
|
+
], S3OjPublicService);
|
|
213
|
+
let S3OjArchivesService = class S3OjArchivesService extends S3Service {
|
|
214
|
+
constructor() {
|
|
215
|
+
super(constants_1.default.secrets.s3.ojArchivesBucket.name);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
exports.S3OjArchivesService = S3OjArchivesService;
|
|
219
|
+
exports.S3OjArchivesService = S3OjArchivesService = __decorate([
|
|
220
|
+
(0, common_1.Injectable)(),
|
|
221
|
+
__metadata("design:paramtypes", [])
|
|
222
|
+
], S3OjArchivesService);
|
|
223
|
+
let S3OjScoringStorageService = class S3OjScoringStorageService extends S3Service {
|
|
224
|
+
constructor() {
|
|
225
|
+
super(constants_1.default.secrets.s3.ojScoringStorageBucket.name);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
exports.S3OjScoringStorageService = S3OjScoringStorageService;
|
|
229
|
+
exports.S3OjScoringStorageService = S3OjScoringStorageService = __decorate([
|
|
230
|
+
(0, common_1.Injectable)(),
|
|
231
|
+
__metadata("design:paramtypes", [])
|
|
232
|
+
], S3OjScoringStorageService);
|
|
233
|
+
let S3OjProblemService = class S3OjProblemService extends S3Service {
|
|
234
|
+
constructor() {
|
|
235
|
+
super(constants_1.default.secrets.s3.ojProblemBucket.name);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
exports.S3OjProblemService = S3OjProblemService;
|
|
239
|
+
exports.S3OjProblemService = S3OjProblemService = __decorate([
|
|
240
|
+
(0, common_1.Injectable)(),
|
|
241
|
+
__metadata("design:paramtypes", [])
|
|
242
|
+
], S3OjProblemService);
|
|
243
|
+
let S3OjSourceService = class S3OjSourceService extends S3Service {
|
|
244
|
+
constructor() {
|
|
245
|
+
super(constants_1.default.secrets.s3.ojSourceBucket.name);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
exports.S3OjSourceService = S3OjSourceService;
|
|
249
|
+
exports.S3OjSourceService = S3OjSourceService = __decorate([
|
|
250
|
+
(0, common_1.Injectable)(),
|
|
251
|
+
__metadata("design:paramtypes", [])
|
|
252
|
+
], S3OjSourceService);
|
|
253
|
+
//# sourceMappingURL=s3.service.js.map
|