@ntalmagor/3drise-common 1.0.3 → 1.0.5
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/build/database.js +1 -8
- package/build/index.d.ts +0 -1
- package/build/index.js +0 -1
- package/build/middlewares/current-user.d.ts +7 -9
- package/build/middlewares/current-user.js +5 -9
- package/build/middlewares/error-handler.js +2 -2
- package/build/middlewares/require-auth.js +2 -2
- package/package.json +3 -5
- package/build/models/Asset.d.ts +0 -52
- package/build/models/Asset.js +0 -133
- package/build/models/Project.d.ts +0 -27
- package/build/models/Project.js +0 -106
- package/build/models/ProjectAsset.d.ts +0 -12
- package/build/models/ProjectAsset.js +0 -58
- package/build/models/ProjectDependency.d.ts +0 -11
- package/build/models/ProjectDependency.js +0 -57
- package/build/models/Transaction.d.ts +0 -22
- package/build/models/Transaction.js +0 -92
- package/build/models/User.d.ts +0 -17
- package/build/models/User.js +0 -79
- package/build/models/UserAsset.d.ts +0 -13
- package/build/models/UserAsset.js +0 -62
- package/build/models/index.d.ts +0 -16
- package/build/models/index.js +0 -54
package/build/database.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
4
|
-
const User_1 = require("./models/User");
|
|
5
|
-
const Project_1 = require("./models/Project");
|
|
6
|
-
const ProjectDependency_1 = require("./models/ProjectDependency");
|
|
7
|
-
const Transaction_1 = require("./models/Transaction");
|
|
8
|
-
const Asset_1 = require("./models/Asset");
|
|
9
|
-
const UserAsset_1 = require("./models/UserAsset");
|
|
10
|
-
const ProjectAsset_1 = require("./models/ProjectAsset");
|
|
11
4
|
const sequelize = new sequelize_typescript_1.Sequelize({
|
|
12
5
|
database: process.env.RISE_MYSQL_DATABASE,
|
|
13
6
|
dialect: 'mysql',
|
|
@@ -15,7 +8,7 @@ const sequelize = new sequelize_typescript_1.Sequelize({
|
|
|
15
8
|
username: process.env.RISE_MYSQL_USER,
|
|
16
9
|
password: process.env.RISE_MYSQL_PASSWORD,
|
|
17
10
|
port: parseInt(process.env.MYSQL_PORT || '3306'),
|
|
18
|
-
models: [
|
|
11
|
+
models: [],
|
|
19
12
|
logging: console.log, // Set to false in production
|
|
20
13
|
pool: {
|
|
21
14
|
max: 10,
|
package/build/index.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ export { default as jwt } from 'jsonwebtoken';
|
|
|
5
5
|
export type { JwtPayload, SignOptions, VerifyOptions } from 'jsonwebtoken';
|
|
6
6
|
export { default as session } from 'cookie-session';
|
|
7
7
|
export { default as sequelize } from './database';
|
|
8
|
-
export * from './models/index';
|
|
9
8
|
export type { RedisType } from './utils/redisClient';
|
|
10
9
|
export * from './errors/bad-request-error';
|
|
11
10
|
export * from './errors/custom-error';
|
package/build/index.js
CHANGED
|
@@ -29,7 +29,6 @@ Object.defineProperty(exports, "session", { enumerable: true, get: function () {
|
|
|
29
29
|
// export { default as getRedisClient } from './utils/redisClient';
|
|
30
30
|
var database_1 = require("./database");
|
|
31
31
|
Object.defineProperty(exports, "sequelize", { enumerable: true, get: function () { return __importDefault(database_1).default; } });
|
|
32
|
-
__exportStar(require("./models/index"), exports);
|
|
33
32
|
__exportStar(require("./errors/bad-request-error"), exports);
|
|
34
33
|
__exportStar(require("./errors/custom-error"), exports);
|
|
35
34
|
__exportStar(require("./errors/database-connection-error"), exports);
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { Request, Response, NextFunction } from 'express';
|
|
2
|
-
interface UserPayload {
|
|
2
|
+
export interface UserPayload {
|
|
3
3
|
id: string;
|
|
4
4
|
email: string;
|
|
5
|
+
userName?: string;
|
|
6
|
+
iat: number;
|
|
5
7
|
exp: number;
|
|
6
|
-
roleId?: string;
|
|
7
8
|
}
|
|
8
|
-
declare
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
currentUser?: UserPayload;
|
|
12
|
-
}
|
|
9
|
+
declare module 'express-serve-static-core' {
|
|
10
|
+
interface Request {
|
|
11
|
+
currentUser?: UserPayload;
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
|
-
export declare const currentUser: (req: Request, res: Response, next: NextFunction) => void
|
|
16
|
-
export {};
|
|
14
|
+
export declare const currentUser: (req: Request, res: Response, next: NextFunction) => void;
|
|
@@ -6,21 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.currentUser = void 0;
|
|
7
7
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
8
|
const currentUser = (req, res, next) => {
|
|
9
|
-
var _a
|
|
10
|
-
|
|
11
|
-
if (!((_b = req.session) === null || _b === void 0 ? void 0 : _b.jwt)) {
|
|
9
|
+
var _a;
|
|
10
|
+
if (!((_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt)) {
|
|
12
11
|
return next();
|
|
13
12
|
}
|
|
14
13
|
try {
|
|
15
14
|
const payload = jsonwebtoken_1.default.verify(req.session.jwt, process.env.JWT_KEY);
|
|
16
|
-
console.log("currentUser middleware", payload);
|
|
17
|
-
const currentTime = Math.floor(Date.now() / 1000);
|
|
18
|
-
if (payload.exp < currentTime) {
|
|
19
|
-
return res.status(401).json({ error: 'Token has expired' });
|
|
20
|
-
}
|
|
21
15
|
req.currentUser = payload;
|
|
22
16
|
}
|
|
23
|
-
catch (err) {
|
|
17
|
+
catch (err) {
|
|
18
|
+
// Invalid or expired token — continue unauthenticated
|
|
19
|
+
}
|
|
24
20
|
next();
|
|
25
21
|
};
|
|
26
22
|
exports.currentUser = currentUser;
|
|
@@ -7,8 +7,8 @@ const errorHandler = (err, req, res, next) => {
|
|
|
7
7
|
return res.status(err.statusCode).send({ errors: err.serializeErrors() });
|
|
8
8
|
}
|
|
9
9
|
console.error(err);
|
|
10
|
-
res.status(
|
|
11
|
-
errors: [{ message: 'Something went wrong' }]
|
|
10
|
+
res.status(500).send({
|
|
11
|
+
errors: [{ message: 'Something went wrong' }],
|
|
12
12
|
});
|
|
13
13
|
};
|
|
14
14
|
exports.errorHandler = errorHandler;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requireAuth = void 0;
|
|
4
|
-
const not_authorized_error_1 = require("../errors/not-authorized-error");
|
|
5
4
|
const requireAuth = (req, res, next) => {
|
|
6
5
|
if (!req.currentUser) {
|
|
7
|
-
|
|
6
|
+
res.status(401).json({ error: 'Not authorized' });
|
|
7
|
+
return;
|
|
8
8
|
}
|
|
9
9
|
next();
|
|
10
10
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ntalmagor/3drise-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -26,11 +26,10 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@aws-sdk/client-s3": "^3.975.0",
|
|
28
28
|
"@types/cookie-session": "^2.0.48",
|
|
29
|
-
"@types/express": "^
|
|
29
|
+
"@types/express": "^5.0.1",
|
|
30
30
|
"@types/jsonwebtoken": "^9.0.5",
|
|
31
|
-
"@types/transform-coordinates": "^1.0.3",
|
|
32
31
|
"@types/uuid": "^10.0.0",
|
|
33
|
-
"cookie-session": "^2.
|
|
32
|
+
"cookie-session": "^2.1.1",
|
|
34
33
|
"express": "^4.18.2",
|
|
35
34
|
"express-validator": "^7.0.1",
|
|
36
35
|
"ioredis": "^5.7.0",
|
|
@@ -39,7 +38,6 @@
|
|
|
39
38
|
"node-nats-streaming": "^0.3.2",
|
|
40
39
|
"sequelize": "^6.37.7",
|
|
41
40
|
"sequelize-typescript": "^2.1.6",
|
|
42
|
-
"transform-coordinates": "^1.0.0",
|
|
43
41
|
"uuid": "^13.0.0"
|
|
44
42
|
}
|
|
45
43
|
}
|
package/build/models/Asset.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Model } from 'sequelize-typescript';
|
|
2
|
-
import { User } from './User';
|
|
3
|
-
import { Project } from './Project';
|
|
4
|
-
export declare enum AssetType {
|
|
5
|
-
MODEL = "model",
|
|
6
|
-
TEXTURE = "texture",
|
|
7
|
-
AUDIO = "audio",
|
|
8
|
-
MATERIAL = "material",
|
|
9
|
-
IMAGE = "image",
|
|
10
|
-
UI_TEMPLATE = "ui_template",
|
|
11
|
-
GALLERY = "gallery",
|
|
12
|
-
HDR = "hdr",
|
|
13
|
-
ANIMATION = "animation"
|
|
14
|
-
}
|
|
15
|
-
export type AssetPayload = {
|
|
16
|
-
creatorId: string;
|
|
17
|
-
projectId?: string;
|
|
18
|
-
name?: string;
|
|
19
|
-
type?: AssetType;
|
|
20
|
-
description?: string;
|
|
21
|
-
path?: string;
|
|
22
|
-
price?: number;
|
|
23
|
-
privacy?: AssetPrivacy;
|
|
24
|
-
vertex?: string;
|
|
25
|
-
fragment?: string;
|
|
26
|
-
uniforms?: object;
|
|
27
|
-
url?: string;
|
|
28
|
-
settings?: object[];
|
|
29
|
-
};
|
|
30
|
-
export declare enum AssetPrivacy {
|
|
31
|
-
PUBLIC = "public",
|
|
32
|
-
PRIVATE = "private"
|
|
33
|
-
}
|
|
34
|
-
export declare class Asset extends Model {
|
|
35
|
-
id: string;
|
|
36
|
-
name: string;
|
|
37
|
-
type: AssetType;
|
|
38
|
-
url: string;
|
|
39
|
-
creatorId: string;
|
|
40
|
-
price?: number;
|
|
41
|
-
privacy: AssetPrivacy;
|
|
42
|
-
description?: string;
|
|
43
|
-
vertex?: string;
|
|
44
|
-
fragment?: string;
|
|
45
|
-
uniforms?: object;
|
|
46
|
-
settings?: object[];
|
|
47
|
-
createdAt: Date;
|
|
48
|
-
updatedAt: Date;
|
|
49
|
-
creator: User;
|
|
50
|
-
owners: User[];
|
|
51
|
-
projects: Project[];
|
|
52
|
-
}
|
package/build/models/Asset.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Asset = exports.AssetPrivacy = exports.AssetType = void 0;
|
|
13
|
-
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
14
|
-
const User_1 = require("./User");
|
|
15
|
-
const Project_1 = require("./Project");
|
|
16
|
-
const UserAsset_1 = require("./UserAsset");
|
|
17
|
-
const ProjectAsset_1 = require("./ProjectAsset");
|
|
18
|
-
var AssetType;
|
|
19
|
-
(function (AssetType) {
|
|
20
|
-
AssetType["MODEL"] = "model";
|
|
21
|
-
AssetType["TEXTURE"] = "texture";
|
|
22
|
-
AssetType["AUDIO"] = "audio";
|
|
23
|
-
AssetType["MATERIAL"] = "material";
|
|
24
|
-
AssetType["IMAGE"] = "image";
|
|
25
|
-
AssetType["UI_TEMPLATE"] = "ui_template";
|
|
26
|
-
AssetType["GALLERY"] = "gallery";
|
|
27
|
-
AssetType["HDR"] = "hdr";
|
|
28
|
-
AssetType["ANIMATION"] = "animation";
|
|
29
|
-
})(AssetType || (exports.AssetType = AssetType = {}));
|
|
30
|
-
var AssetPrivacy;
|
|
31
|
-
(function (AssetPrivacy) {
|
|
32
|
-
AssetPrivacy["PUBLIC"] = "public";
|
|
33
|
-
AssetPrivacy["PRIVATE"] = "private";
|
|
34
|
-
})(AssetPrivacy || (exports.AssetPrivacy = AssetPrivacy = {}));
|
|
35
|
-
let Asset = class Asset extends sequelize_typescript_1.Model {
|
|
36
|
-
};
|
|
37
|
-
exports.Asset = Asset;
|
|
38
|
-
__decorate([
|
|
39
|
-
sequelize_typescript_1.PrimaryKey,
|
|
40
|
-
(0, sequelize_typescript_1.Default)(sequelize_typescript_1.DataType.UUIDV4),
|
|
41
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
42
|
-
__metadata("design:type", String)
|
|
43
|
-
], Asset.prototype, "id", void 0);
|
|
44
|
-
__decorate([
|
|
45
|
-
(0, sequelize_typescript_1.AllowNull)(false),
|
|
46
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(255)),
|
|
47
|
-
__metadata("design:type", String)
|
|
48
|
-
], Asset.prototype, "name", void 0);
|
|
49
|
-
__decorate([
|
|
50
|
-
(0, sequelize_typescript_1.AllowNull)(false),
|
|
51
|
-
(0, sequelize_typescript_1.Column)({
|
|
52
|
-
type: sequelize_typescript_1.DataType.ENUM(...Object.values(AssetType)),
|
|
53
|
-
}),
|
|
54
|
-
__metadata("design:type", String)
|
|
55
|
-
], Asset.prototype, "type", void 0);
|
|
56
|
-
__decorate([
|
|
57
|
-
(0, sequelize_typescript_1.AllowNull)(true),
|
|
58
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TEXT),
|
|
59
|
-
__metadata("design:type", String)
|
|
60
|
-
], Asset.prototype, "url", void 0);
|
|
61
|
-
__decorate([
|
|
62
|
-
(0, sequelize_typescript_1.ForeignKey)(() => User_1.User),
|
|
63
|
-
(0, sequelize_typescript_1.AllowNull)(false),
|
|
64
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
65
|
-
__metadata("design:type", String)
|
|
66
|
-
], Asset.prototype, "creatorId", void 0);
|
|
67
|
-
__decorate([
|
|
68
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DECIMAL(10, 2)),
|
|
69
|
-
__metadata("design:type", Number)
|
|
70
|
-
], Asset.prototype, "price", void 0);
|
|
71
|
-
__decorate([
|
|
72
|
-
(0, sequelize_typescript_1.Column)({
|
|
73
|
-
type: sequelize_typescript_1.DataType.ENUM(...Object.values(AssetPrivacy)),
|
|
74
|
-
defaultValue: AssetPrivacy.PUBLIC,
|
|
75
|
-
}),
|
|
76
|
-
__metadata("design:type", String)
|
|
77
|
-
], Asset.prototype, "privacy", void 0);
|
|
78
|
-
__decorate([
|
|
79
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TEXT),
|
|
80
|
-
__metadata("design:type", String)
|
|
81
|
-
], Asset.prototype, "description", void 0);
|
|
82
|
-
__decorate([
|
|
83
|
-
(0, sequelize_typescript_1.AllowNull)(true),
|
|
84
|
-
(0, sequelize_typescript_1.Default)(null),
|
|
85
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TEXT),
|
|
86
|
-
__metadata("design:type", String)
|
|
87
|
-
], Asset.prototype, "vertex", void 0);
|
|
88
|
-
__decorate([
|
|
89
|
-
(0, sequelize_typescript_1.AllowNull)(true),
|
|
90
|
-
(0, sequelize_typescript_1.Default)(null),
|
|
91
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TEXT),
|
|
92
|
-
__metadata("design:type", String)
|
|
93
|
-
], Asset.prototype, "fragment", void 0);
|
|
94
|
-
__decorate([
|
|
95
|
-
(0, sequelize_typescript_1.AllowNull)(true),
|
|
96
|
-
(0, sequelize_typescript_1.Default)(null),
|
|
97
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.JSON),
|
|
98
|
-
__metadata("design:type", Object)
|
|
99
|
-
], Asset.prototype, "uniforms", void 0);
|
|
100
|
-
__decorate([
|
|
101
|
-
(0, sequelize_typescript_1.AllowNull)(true),
|
|
102
|
-
(0, sequelize_typescript_1.Default)(null),
|
|
103
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.JSON),
|
|
104
|
-
__metadata("design:type", Array)
|
|
105
|
-
], Asset.prototype, "settings", void 0);
|
|
106
|
-
__decorate([
|
|
107
|
-
sequelize_typescript_1.CreatedAt,
|
|
108
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
109
|
-
__metadata("design:type", Date)
|
|
110
|
-
], Asset.prototype, "createdAt", void 0);
|
|
111
|
-
__decorate([
|
|
112
|
-
sequelize_typescript_1.UpdatedAt,
|
|
113
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
114
|
-
__metadata("design:type", Date)
|
|
115
|
-
], Asset.prototype, "updatedAt", void 0);
|
|
116
|
-
__decorate([
|
|
117
|
-
(0, sequelize_typescript_1.BelongsTo)(() => User_1.User, 'creatorId'),
|
|
118
|
-
__metadata("design:type", User_1.User)
|
|
119
|
-
], Asset.prototype, "creator", void 0);
|
|
120
|
-
__decorate([
|
|
121
|
-
(0, sequelize_typescript_1.BelongsToMany)(() => User_1.User, () => UserAsset_1.UserAsset),
|
|
122
|
-
__metadata("design:type", Array)
|
|
123
|
-
], Asset.prototype, "owners", void 0);
|
|
124
|
-
__decorate([
|
|
125
|
-
(0, sequelize_typescript_1.BelongsToMany)(() => Project_1.Project, () => ProjectAsset_1.ProjectAsset),
|
|
126
|
-
__metadata("design:type", Array)
|
|
127
|
-
], Asset.prototype, "projects", void 0);
|
|
128
|
-
exports.Asset = Asset = __decorate([
|
|
129
|
-
(0, sequelize_typescript_1.Table)({
|
|
130
|
-
tableName: 'assets',
|
|
131
|
-
timestamps: true,
|
|
132
|
-
})
|
|
133
|
-
], Asset);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Model } from 'sequelize-typescript';
|
|
2
|
-
import { User } from './User';
|
|
3
|
-
import { ProjectDependency } from './ProjectDependency';
|
|
4
|
-
import { Transaction } from './Transaction';
|
|
5
|
-
import { Asset } from './Asset';
|
|
6
|
-
export declare enum ProjectStatus {
|
|
7
|
-
ACTIVE = "active",
|
|
8
|
-
INACTIVE = "inactive"
|
|
9
|
-
}
|
|
10
|
-
export declare class Project extends Model {
|
|
11
|
-
id: string;
|
|
12
|
-
name: string;
|
|
13
|
-
description?: string;
|
|
14
|
-
settings?: object;
|
|
15
|
-
sceneSettings?: object;
|
|
16
|
-
uiSettings?: object;
|
|
17
|
-
userId: string;
|
|
18
|
-
price?: number;
|
|
19
|
-
status: ProjectStatus;
|
|
20
|
-
createdAt: Date;
|
|
21
|
-
updatedAt: Date;
|
|
22
|
-
owner: User;
|
|
23
|
-
dependencies: ProjectDependency[];
|
|
24
|
-
dependentProjects: ProjectDependency[];
|
|
25
|
-
transactions: Transaction[];
|
|
26
|
-
assets: Asset[];
|
|
27
|
-
}
|
package/build/models/Project.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Project = exports.ProjectStatus = void 0;
|
|
13
|
-
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
14
|
-
const User_1 = require("./User");
|
|
15
|
-
const ProjectDependency_1 = require("./ProjectDependency");
|
|
16
|
-
const Transaction_1 = require("./Transaction");
|
|
17
|
-
const Asset_1 = require("./Asset");
|
|
18
|
-
const ProjectAsset_1 = require("./ProjectAsset");
|
|
19
|
-
var ProjectStatus;
|
|
20
|
-
(function (ProjectStatus) {
|
|
21
|
-
ProjectStatus["ACTIVE"] = "active";
|
|
22
|
-
ProjectStatus["INACTIVE"] = "inactive";
|
|
23
|
-
})(ProjectStatus || (exports.ProjectStatus = ProjectStatus = {}));
|
|
24
|
-
let Project = class Project extends sequelize_typescript_1.Model {
|
|
25
|
-
};
|
|
26
|
-
exports.Project = Project;
|
|
27
|
-
__decorate([
|
|
28
|
-
sequelize_typescript_1.PrimaryKey,
|
|
29
|
-
(0, sequelize_typescript_1.Default)(sequelize_typescript_1.DataType.UUIDV4),
|
|
30
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
31
|
-
__metadata("design:type", String)
|
|
32
|
-
], Project.prototype, "id", void 0);
|
|
33
|
-
__decorate([
|
|
34
|
-
(0, sequelize_typescript_1.AllowNull)(false),
|
|
35
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(255)),
|
|
36
|
-
__metadata("design:type", String)
|
|
37
|
-
], Project.prototype, "name", void 0);
|
|
38
|
-
__decorate([
|
|
39
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TEXT),
|
|
40
|
-
__metadata("design:type", String)
|
|
41
|
-
], Project.prototype, "description", void 0);
|
|
42
|
-
__decorate([
|
|
43
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.JSON),
|
|
44
|
-
__metadata("design:type", Object)
|
|
45
|
-
], Project.prototype, "settings", void 0);
|
|
46
|
-
__decorate([
|
|
47
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.JSON),
|
|
48
|
-
__metadata("design:type", Object)
|
|
49
|
-
], Project.prototype, "sceneSettings", void 0);
|
|
50
|
-
__decorate([
|
|
51
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.JSON),
|
|
52
|
-
__metadata("design:type", Object)
|
|
53
|
-
], Project.prototype, "uiSettings", void 0);
|
|
54
|
-
__decorate([
|
|
55
|
-
(0, sequelize_typescript_1.ForeignKey)(() => User_1.User),
|
|
56
|
-
(0, sequelize_typescript_1.AllowNull)(false),
|
|
57
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
58
|
-
__metadata("design:type", String)
|
|
59
|
-
], Project.prototype, "userId", void 0);
|
|
60
|
-
__decorate([
|
|
61
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DECIMAL(10, 2)),
|
|
62
|
-
__metadata("design:type", Number)
|
|
63
|
-
], Project.prototype, "price", void 0);
|
|
64
|
-
__decorate([
|
|
65
|
-
(0, sequelize_typescript_1.Column)({
|
|
66
|
-
type: sequelize_typescript_1.DataType.ENUM(...Object.values(ProjectStatus)),
|
|
67
|
-
defaultValue: ProjectStatus.ACTIVE,
|
|
68
|
-
}),
|
|
69
|
-
__metadata("design:type", String)
|
|
70
|
-
], Project.prototype, "status", void 0);
|
|
71
|
-
__decorate([
|
|
72
|
-
sequelize_typescript_1.CreatedAt,
|
|
73
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
74
|
-
__metadata("design:type", Date)
|
|
75
|
-
], Project.prototype, "createdAt", void 0);
|
|
76
|
-
__decorate([
|
|
77
|
-
sequelize_typescript_1.UpdatedAt,
|
|
78
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
79
|
-
__metadata("design:type", Date)
|
|
80
|
-
], Project.prototype, "updatedAt", void 0);
|
|
81
|
-
__decorate([
|
|
82
|
-
(0, sequelize_typescript_1.BelongsTo)(() => User_1.User),
|
|
83
|
-
__metadata("design:type", User_1.User)
|
|
84
|
-
], Project.prototype, "owner", void 0);
|
|
85
|
-
__decorate([
|
|
86
|
-
(0, sequelize_typescript_1.HasMany)(() => ProjectDependency_1.ProjectDependency, 'projectId'),
|
|
87
|
-
__metadata("design:type", Array)
|
|
88
|
-
], Project.prototype, "dependencies", void 0);
|
|
89
|
-
__decorate([
|
|
90
|
-
(0, sequelize_typescript_1.HasMany)(() => ProjectDependency_1.ProjectDependency, 'dependentProjectId'),
|
|
91
|
-
__metadata("design:type", Array)
|
|
92
|
-
], Project.prototype, "dependentProjects", void 0);
|
|
93
|
-
__decorate([
|
|
94
|
-
(0, sequelize_typescript_1.HasMany)(() => Transaction_1.Transaction),
|
|
95
|
-
__metadata("design:type", Array)
|
|
96
|
-
], Project.prototype, "transactions", void 0);
|
|
97
|
-
__decorate([
|
|
98
|
-
(0, sequelize_typescript_1.BelongsToMany)(() => Asset_1.Asset, () => ProjectAsset_1.ProjectAsset),
|
|
99
|
-
__metadata("design:type", Array)
|
|
100
|
-
], Project.prototype, "assets", void 0);
|
|
101
|
-
exports.Project = Project = __decorate([
|
|
102
|
-
(0, sequelize_typescript_1.Table)({
|
|
103
|
-
tableName: 'projects',
|
|
104
|
-
timestamps: true,
|
|
105
|
-
})
|
|
106
|
-
], Project);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Model } from 'sequelize-typescript';
|
|
2
|
-
import { Project } from './Project';
|
|
3
|
-
import { Asset } from './Asset';
|
|
4
|
-
export declare class ProjectAsset extends Model {
|
|
5
|
-
id: string;
|
|
6
|
-
projectId: string;
|
|
7
|
-
assetId: string;
|
|
8
|
-
createdAt: Date;
|
|
9
|
-
updatedAt: Date;
|
|
10
|
-
project: Project;
|
|
11
|
-
asset: Asset;
|
|
12
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ProjectAsset = void 0;
|
|
13
|
-
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
14
|
-
const Project_1 = require("./Project");
|
|
15
|
-
const Asset_1 = require("./Asset");
|
|
16
|
-
let ProjectAsset = class ProjectAsset extends sequelize_typescript_1.Model {
|
|
17
|
-
};
|
|
18
|
-
exports.ProjectAsset = ProjectAsset;
|
|
19
|
-
__decorate([
|
|
20
|
-
sequelize_typescript_1.PrimaryKey,
|
|
21
|
-
(0, sequelize_typescript_1.Default)(sequelize_typescript_1.DataType.UUIDV4),
|
|
22
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
23
|
-
__metadata("design:type", String)
|
|
24
|
-
], ProjectAsset.prototype, "id", void 0);
|
|
25
|
-
__decorate([
|
|
26
|
-
(0, sequelize_typescript_1.ForeignKey)(() => Project_1.Project),
|
|
27
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
28
|
-
__metadata("design:type", String)
|
|
29
|
-
], ProjectAsset.prototype, "projectId", void 0);
|
|
30
|
-
__decorate([
|
|
31
|
-
(0, sequelize_typescript_1.ForeignKey)(() => Asset_1.Asset),
|
|
32
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
33
|
-
__metadata("design:type", String)
|
|
34
|
-
], ProjectAsset.prototype, "assetId", void 0);
|
|
35
|
-
__decorate([
|
|
36
|
-
sequelize_typescript_1.CreatedAt,
|
|
37
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
38
|
-
__metadata("design:type", Date)
|
|
39
|
-
], ProjectAsset.prototype, "createdAt", void 0);
|
|
40
|
-
__decorate([
|
|
41
|
-
sequelize_typescript_1.UpdatedAt,
|
|
42
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
43
|
-
__metadata("design:type", Date)
|
|
44
|
-
], ProjectAsset.prototype, "updatedAt", void 0);
|
|
45
|
-
__decorate([
|
|
46
|
-
(0, sequelize_typescript_1.BelongsTo)(() => Project_1.Project),
|
|
47
|
-
__metadata("design:type", Project_1.Project)
|
|
48
|
-
], ProjectAsset.prototype, "project", void 0);
|
|
49
|
-
__decorate([
|
|
50
|
-
(0, sequelize_typescript_1.BelongsTo)(() => Asset_1.Asset),
|
|
51
|
-
__metadata("design:type", Asset_1.Asset)
|
|
52
|
-
], ProjectAsset.prototype, "asset", void 0);
|
|
53
|
-
exports.ProjectAsset = ProjectAsset = __decorate([
|
|
54
|
-
(0, sequelize_typescript_1.Table)({
|
|
55
|
-
tableName: 'project_assets',
|
|
56
|
-
timestamps: true,
|
|
57
|
-
})
|
|
58
|
-
], ProjectAsset);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Model } from 'sequelize-typescript';
|
|
2
|
-
import { Project } from './Project';
|
|
3
|
-
export declare class ProjectDependency extends Model {
|
|
4
|
-
id: string;
|
|
5
|
-
projectId: string;
|
|
6
|
-
dependentProjectId: string;
|
|
7
|
-
createdAt: Date;
|
|
8
|
-
updatedAt: Date;
|
|
9
|
-
project: Project;
|
|
10
|
-
dependentProject: Project;
|
|
11
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ProjectDependency = void 0;
|
|
13
|
-
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
14
|
-
const Project_1 = require("./Project");
|
|
15
|
-
let ProjectDependency = class ProjectDependency extends sequelize_typescript_1.Model {
|
|
16
|
-
};
|
|
17
|
-
exports.ProjectDependency = ProjectDependency;
|
|
18
|
-
__decorate([
|
|
19
|
-
sequelize_typescript_1.PrimaryKey,
|
|
20
|
-
(0, sequelize_typescript_1.Default)(sequelize_typescript_1.DataType.UUIDV4),
|
|
21
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
22
|
-
__metadata("design:type", String)
|
|
23
|
-
], ProjectDependency.prototype, "id", void 0);
|
|
24
|
-
__decorate([
|
|
25
|
-
(0, sequelize_typescript_1.ForeignKey)(() => Project_1.Project),
|
|
26
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
27
|
-
__metadata("design:type", String)
|
|
28
|
-
], ProjectDependency.prototype, "projectId", void 0);
|
|
29
|
-
__decorate([
|
|
30
|
-
(0, sequelize_typescript_1.ForeignKey)(() => Project_1.Project),
|
|
31
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
32
|
-
__metadata("design:type", String)
|
|
33
|
-
], ProjectDependency.prototype, "dependentProjectId", void 0);
|
|
34
|
-
__decorate([
|
|
35
|
-
sequelize_typescript_1.CreatedAt,
|
|
36
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
37
|
-
__metadata("design:type", Date)
|
|
38
|
-
], ProjectDependency.prototype, "createdAt", void 0);
|
|
39
|
-
__decorate([
|
|
40
|
-
sequelize_typescript_1.UpdatedAt,
|
|
41
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
42
|
-
__metadata("design:type", Date)
|
|
43
|
-
], ProjectDependency.prototype, "updatedAt", void 0);
|
|
44
|
-
__decorate([
|
|
45
|
-
(0, sequelize_typescript_1.BelongsTo)(() => Project_1.Project, 'projectId'),
|
|
46
|
-
__metadata("design:type", Project_1.Project)
|
|
47
|
-
], ProjectDependency.prototype, "project", void 0);
|
|
48
|
-
__decorate([
|
|
49
|
-
(0, sequelize_typescript_1.BelongsTo)(() => Project_1.Project, 'dependentProjectId'),
|
|
50
|
-
__metadata("design:type", Project_1.Project)
|
|
51
|
-
], ProjectDependency.prototype, "dependentProject", void 0);
|
|
52
|
-
exports.ProjectDependency = ProjectDependency = __decorate([
|
|
53
|
-
(0, sequelize_typescript_1.Table)({
|
|
54
|
-
tableName: 'project_dependencies',
|
|
55
|
-
timestamps: true,
|
|
56
|
-
})
|
|
57
|
-
], ProjectDependency);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Model } from 'sequelize-typescript';
|
|
2
|
-
import { User } from './User';
|
|
3
|
-
import { Project } from './Project';
|
|
4
|
-
export declare enum TransactionStatus {
|
|
5
|
-
PENDING = "pending",
|
|
6
|
-
COMPLETED = "completed",
|
|
7
|
-
FAILED = "failed"
|
|
8
|
-
}
|
|
9
|
-
export declare class Transaction extends Model {
|
|
10
|
-
id: string;
|
|
11
|
-
projectId: string;
|
|
12
|
-
buyerId: string;
|
|
13
|
-
sellerId: string;
|
|
14
|
-
price: number;
|
|
15
|
-
status: TransactionStatus;
|
|
16
|
-
transactionDate?: Date;
|
|
17
|
-
createdAt: Date;
|
|
18
|
-
updatedAt: Date;
|
|
19
|
-
project: Project;
|
|
20
|
-
buyer: User;
|
|
21
|
-
seller: User;
|
|
22
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Transaction = exports.TransactionStatus = void 0;
|
|
13
|
-
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
14
|
-
const User_1 = require("./User");
|
|
15
|
-
const Project_1 = require("./Project");
|
|
16
|
-
var TransactionStatus;
|
|
17
|
-
(function (TransactionStatus) {
|
|
18
|
-
TransactionStatus["PENDING"] = "pending";
|
|
19
|
-
TransactionStatus["COMPLETED"] = "completed";
|
|
20
|
-
TransactionStatus["FAILED"] = "failed";
|
|
21
|
-
})(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
|
|
22
|
-
let Transaction = class Transaction extends sequelize_typescript_1.Model {
|
|
23
|
-
};
|
|
24
|
-
exports.Transaction = Transaction;
|
|
25
|
-
__decorate([
|
|
26
|
-
sequelize_typescript_1.PrimaryKey,
|
|
27
|
-
(0, sequelize_typescript_1.Default)(sequelize_typescript_1.DataType.UUIDV4),
|
|
28
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
29
|
-
__metadata("design:type", String)
|
|
30
|
-
], Transaction.prototype, "id", void 0);
|
|
31
|
-
__decorate([
|
|
32
|
-
(0, sequelize_typescript_1.ForeignKey)(() => Project_1.Project),
|
|
33
|
-
(0, sequelize_typescript_1.AllowNull)(false),
|
|
34
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
35
|
-
__metadata("design:type", String)
|
|
36
|
-
], Transaction.prototype, "projectId", void 0);
|
|
37
|
-
__decorate([
|
|
38
|
-
(0, sequelize_typescript_1.ForeignKey)(() => User_1.User),
|
|
39
|
-
(0, sequelize_typescript_1.AllowNull)(false),
|
|
40
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
41
|
-
__metadata("design:type", String)
|
|
42
|
-
], Transaction.prototype, "buyerId", void 0);
|
|
43
|
-
__decorate([
|
|
44
|
-
(0, sequelize_typescript_1.ForeignKey)(() => User_1.User),
|
|
45
|
-
(0, sequelize_typescript_1.AllowNull)(false),
|
|
46
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
47
|
-
__metadata("design:type", String)
|
|
48
|
-
], Transaction.prototype, "sellerId", void 0);
|
|
49
|
-
__decorate([
|
|
50
|
-
(0, sequelize_typescript_1.AllowNull)(false),
|
|
51
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DECIMAL(10, 2)),
|
|
52
|
-
__metadata("design:type", Number)
|
|
53
|
-
], Transaction.prototype, "price", void 0);
|
|
54
|
-
__decorate([
|
|
55
|
-
(0, sequelize_typescript_1.Column)({
|
|
56
|
-
type: sequelize_typescript_1.DataType.ENUM(...Object.values(TransactionStatus)),
|
|
57
|
-
defaultValue: TransactionStatus.PENDING,
|
|
58
|
-
}),
|
|
59
|
-
__metadata("design:type", String)
|
|
60
|
-
], Transaction.prototype, "status", void 0);
|
|
61
|
-
__decorate([
|
|
62
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
63
|
-
__metadata("design:type", Date)
|
|
64
|
-
], Transaction.prototype, "transactionDate", void 0);
|
|
65
|
-
__decorate([
|
|
66
|
-
sequelize_typescript_1.CreatedAt,
|
|
67
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
68
|
-
__metadata("design:type", Date)
|
|
69
|
-
], Transaction.prototype, "createdAt", void 0);
|
|
70
|
-
__decorate([
|
|
71
|
-
sequelize_typescript_1.UpdatedAt,
|
|
72
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
73
|
-
__metadata("design:type", Date)
|
|
74
|
-
], Transaction.prototype, "updatedAt", void 0);
|
|
75
|
-
__decorate([
|
|
76
|
-
(0, sequelize_typescript_1.BelongsTo)(() => Project_1.Project),
|
|
77
|
-
__metadata("design:type", Project_1.Project)
|
|
78
|
-
], Transaction.prototype, "project", void 0);
|
|
79
|
-
__decorate([
|
|
80
|
-
(0, sequelize_typescript_1.BelongsTo)(() => User_1.User, 'buyerId'),
|
|
81
|
-
__metadata("design:type", User_1.User)
|
|
82
|
-
], Transaction.prototype, "buyer", void 0);
|
|
83
|
-
__decorate([
|
|
84
|
-
(0, sequelize_typescript_1.BelongsTo)(() => User_1.User, 'sellerId'),
|
|
85
|
-
__metadata("design:type", User_1.User)
|
|
86
|
-
], Transaction.prototype, "seller", void 0);
|
|
87
|
-
exports.Transaction = Transaction = __decorate([
|
|
88
|
-
(0, sequelize_typescript_1.Table)({
|
|
89
|
-
tableName: 'transactions',
|
|
90
|
-
timestamps: true,
|
|
91
|
-
})
|
|
92
|
-
], Transaction);
|
package/build/models/User.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Model } from 'sequelize-typescript';
|
|
2
|
-
import { Project } from './Project';
|
|
3
|
-
import { Transaction } from './Transaction';
|
|
4
|
-
import { Asset } from './Asset';
|
|
5
|
-
export declare class User extends Model {
|
|
6
|
-
id: string;
|
|
7
|
-
userName: string;
|
|
8
|
-
email: string;
|
|
9
|
-
password: string;
|
|
10
|
-
createdAt: Date;
|
|
11
|
-
updatedAt: Date;
|
|
12
|
-
projects: Project[];
|
|
13
|
-
purchasedTransactions: Transaction[];
|
|
14
|
-
soldTransactions: Transaction[];
|
|
15
|
-
createdAssets: Asset[];
|
|
16
|
-
ownedAssets: Asset[];
|
|
17
|
-
}
|
package/build/models/User.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.User = void 0;
|
|
13
|
-
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
14
|
-
const Project_1 = require("./Project");
|
|
15
|
-
const Transaction_1 = require("./Transaction");
|
|
16
|
-
const Asset_1 = require("./Asset");
|
|
17
|
-
const UserAsset_1 = require("./UserAsset");
|
|
18
|
-
let User = class User extends sequelize_typescript_1.Model {
|
|
19
|
-
};
|
|
20
|
-
exports.User = User;
|
|
21
|
-
__decorate([
|
|
22
|
-
sequelize_typescript_1.PrimaryKey,
|
|
23
|
-
(0, sequelize_typescript_1.Default)(sequelize_typescript_1.DataType.UUIDV4),
|
|
24
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
25
|
-
__metadata("design:type", String)
|
|
26
|
-
], User.prototype, "id", void 0);
|
|
27
|
-
__decorate([
|
|
28
|
-
sequelize_typescript_1.Unique,
|
|
29
|
-
(0, sequelize_typescript_1.AllowNull)(false),
|
|
30
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(100)),
|
|
31
|
-
__metadata("design:type", String)
|
|
32
|
-
], User.prototype, "userName", void 0);
|
|
33
|
-
__decorate([
|
|
34
|
-
sequelize_typescript_1.Unique,
|
|
35
|
-
(0, sequelize_typescript_1.AllowNull)(false),
|
|
36
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(255)),
|
|
37
|
-
__metadata("design:type", String)
|
|
38
|
-
], User.prototype, "email", void 0);
|
|
39
|
-
__decorate([
|
|
40
|
-
(0, sequelize_typescript_1.AllowNull)(false),
|
|
41
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.STRING(255)),
|
|
42
|
-
__metadata("design:type", String)
|
|
43
|
-
], User.prototype, "password", void 0);
|
|
44
|
-
__decorate([
|
|
45
|
-
sequelize_typescript_1.CreatedAt,
|
|
46
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
47
|
-
__metadata("design:type", Date)
|
|
48
|
-
], User.prototype, "createdAt", void 0);
|
|
49
|
-
__decorate([
|
|
50
|
-
sequelize_typescript_1.UpdatedAt,
|
|
51
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
52
|
-
__metadata("design:type", Date)
|
|
53
|
-
], User.prototype, "updatedAt", void 0);
|
|
54
|
-
__decorate([
|
|
55
|
-
(0, sequelize_typescript_1.HasMany)(() => Project_1.Project),
|
|
56
|
-
__metadata("design:type", Array)
|
|
57
|
-
], User.prototype, "projects", void 0);
|
|
58
|
-
__decorate([
|
|
59
|
-
(0, sequelize_typescript_1.HasMany)(() => Transaction_1.Transaction, 'buyerId'),
|
|
60
|
-
__metadata("design:type", Array)
|
|
61
|
-
], User.prototype, "purchasedTransactions", void 0);
|
|
62
|
-
__decorate([
|
|
63
|
-
(0, sequelize_typescript_1.HasMany)(() => Transaction_1.Transaction, 'sellerId'),
|
|
64
|
-
__metadata("design:type", Array)
|
|
65
|
-
], User.prototype, "soldTransactions", void 0);
|
|
66
|
-
__decorate([
|
|
67
|
-
(0, sequelize_typescript_1.HasMany)(() => Asset_1.Asset, 'creatorId'),
|
|
68
|
-
__metadata("design:type", Array)
|
|
69
|
-
], User.prototype, "createdAssets", void 0);
|
|
70
|
-
__decorate([
|
|
71
|
-
(0, sequelize_typescript_1.BelongsToMany)(() => Asset_1.Asset, () => UserAsset_1.UserAsset),
|
|
72
|
-
__metadata("design:type", Array)
|
|
73
|
-
], User.prototype, "ownedAssets", void 0);
|
|
74
|
-
exports.User = User = __decorate([
|
|
75
|
-
(0, sequelize_typescript_1.Table)({
|
|
76
|
-
tableName: 'users',
|
|
77
|
-
timestamps: true,
|
|
78
|
-
})
|
|
79
|
-
], User);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Model } from 'sequelize-typescript';
|
|
2
|
-
import { User } from './User';
|
|
3
|
-
import { Asset } from './Asset';
|
|
4
|
-
export declare class UserAsset extends Model {
|
|
5
|
-
id: string;
|
|
6
|
-
userId: string;
|
|
7
|
-
assetId: string;
|
|
8
|
-
acquiredAt: Date;
|
|
9
|
-
createdAt: Date;
|
|
10
|
-
updatedAt: Date;
|
|
11
|
-
user: User;
|
|
12
|
-
asset: Asset;
|
|
13
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.UserAsset = void 0;
|
|
13
|
-
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
14
|
-
const User_1 = require("./User");
|
|
15
|
-
const Asset_1 = require("./Asset");
|
|
16
|
-
let UserAsset = class UserAsset extends sequelize_typescript_1.Model {
|
|
17
|
-
};
|
|
18
|
-
exports.UserAsset = UserAsset;
|
|
19
|
-
__decorate([
|
|
20
|
-
sequelize_typescript_1.PrimaryKey,
|
|
21
|
-
(0, sequelize_typescript_1.Default)(sequelize_typescript_1.DataType.UUIDV4),
|
|
22
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
23
|
-
__metadata("design:type", String)
|
|
24
|
-
], UserAsset.prototype, "id", void 0);
|
|
25
|
-
__decorate([
|
|
26
|
-
(0, sequelize_typescript_1.ForeignKey)(() => User_1.User),
|
|
27
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
28
|
-
__metadata("design:type", String)
|
|
29
|
-
], UserAsset.prototype, "userId", void 0);
|
|
30
|
-
__decorate([
|
|
31
|
-
(0, sequelize_typescript_1.ForeignKey)(() => Asset_1.Asset),
|
|
32
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.UUID),
|
|
33
|
-
__metadata("design:type", String)
|
|
34
|
-
], UserAsset.prototype, "assetId", void 0);
|
|
35
|
-
__decorate([
|
|
36
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
37
|
-
__metadata("design:type", Date)
|
|
38
|
-
], UserAsset.prototype, "acquiredAt", void 0);
|
|
39
|
-
__decorate([
|
|
40
|
-
sequelize_typescript_1.CreatedAt,
|
|
41
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
42
|
-
__metadata("design:type", Date)
|
|
43
|
-
], UserAsset.prototype, "createdAt", void 0);
|
|
44
|
-
__decorate([
|
|
45
|
-
sequelize_typescript_1.UpdatedAt,
|
|
46
|
-
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.DATE),
|
|
47
|
-
__metadata("design:type", Date)
|
|
48
|
-
], UserAsset.prototype, "updatedAt", void 0);
|
|
49
|
-
__decorate([
|
|
50
|
-
(0, sequelize_typescript_1.BelongsTo)(() => User_1.User),
|
|
51
|
-
__metadata("design:type", User_1.User)
|
|
52
|
-
], UserAsset.prototype, "user", void 0);
|
|
53
|
-
__decorate([
|
|
54
|
-
(0, sequelize_typescript_1.BelongsTo)(() => Asset_1.Asset),
|
|
55
|
-
__metadata("design:type", Asset_1.Asset)
|
|
56
|
-
], UserAsset.prototype, "asset", void 0);
|
|
57
|
-
exports.UserAsset = UserAsset = __decorate([
|
|
58
|
-
(0, sequelize_typescript_1.Table)({
|
|
59
|
-
tableName: 'user_assets',
|
|
60
|
-
timestamps: true,
|
|
61
|
-
})
|
|
62
|
-
], UserAsset);
|
package/build/models/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import sequelize from '../database';
|
|
3
|
-
import { User } from './User';
|
|
4
|
-
import { Project } from './Project';
|
|
5
|
-
import { ProjectDependency } from './ProjectDependency';
|
|
6
|
-
import { Transaction } from './Transaction';
|
|
7
|
-
import { Asset } from './Asset';
|
|
8
|
-
import { UserAsset } from './UserAsset';
|
|
9
|
-
import { ProjectAsset } from './ProjectAsset';
|
|
10
|
-
export declare const initializeDatabase: (force: boolean) => Promise<void>;
|
|
11
|
-
export { User, Project, ProjectDependency, Transaction, Asset, UserAsset, ProjectAsset };
|
|
12
|
-
export { ProjectStatus } from './Project';
|
|
13
|
-
export { TransactionStatus } from './Transaction';
|
|
14
|
-
export { AssetType, AssetPrivacy } from './Asset';
|
|
15
|
-
export type { AssetPayload } from './Asset';
|
|
16
|
-
export default sequelize;
|
package/build/models/index.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
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.AssetPrivacy = exports.AssetType = exports.TransactionStatus = exports.ProjectStatus = exports.ProjectAsset = exports.UserAsset = exports.Asset = exports.Transaction = exports.ProjectDependency = exports.Project = exports.User = exports.initializeDatabase = void 0;
|
|
16
|
-
require("reflect-metadata");
|
|
17
|
-
const database_1 = __importDefault(require("../database"));
|
|
18
|
-
const User_1 = require("./User");
|
|
19
|
-
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return User_1.User; } });
|
|
20
|
-
const Project_1 = require("./Project");
|
|
21
|
-
Object.defineProperty(exports, "Project", { enumerable: true, get: function () { return Project_1.Project; } });
|
|
22
|
-
const ProjectDependency_1 = require("./ProjectDependency");
|
|
23
|
-
Object.defineProperty(exports, "ProjectDependency", { enumerable: true, get: function () { return ProjectDependency_1.ProjectDependency; } });
|
|
24
|
-
const Transaction_1 = require("./Transaction");
|
|
25
|
-
Object.defineProperty(exports, "Transaction", { enumerable: true, get: function () { return Transaction_1.Transaction; } });
|
|
26
|
-
const Asset_1 = require("./Asset");
|
|
27
|
-
Object.defineProperty(exports, "Asset", { enumerable: true, get: function () { return Asset_1.Asset; } });
|
|
28
|
-
const UserAsset_1 = require("./UserAsset");
|
|
29
|
-
Object.defineProperty(exports, "UserAsset", { enumerable: true, get: function () { return UserAsset_1.UserAsset; } });
|
|
30
|
-
const ProjectAsset_1 = require("./ProjectAsset");
|
|
31
|
-
Object.defineProperty(exports, "ProjectAsset", { enumerable: true, get: function () { return ProjectAsset_1.ProjectAsset; } });
|
|
32
|
-
// Initialize database and sync models
|
|
33
|
-
const initializeDatabase = (force) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
try {
|
|
35
|
-
yield database_1.default.authenticate();
|
|
36
|
-
console.log('Database connection has been established successfully.');
|
|
37
|
-
// Sync all models
|
|
38
|
-
yield database_1.default.sync({ force }); // Set to true to drop and recreate tables
|
|
39
|
-
console.log('All models were synchronized successfully.');
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
console.error('Unable to connect to the database:', error);
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
exports.initializeDatabase = initializeDatabase;
|
|
47
|
-
var Project_2 = require("./Project");
|
|
48
|
-
Object.defineProperty(exports, "ProjectStatus", { enumerable: true, get: function () { return Project_2.ProjectStatus; } });
|
|
49
|
-
var Transaction_2 = require("./Transaction");
|
|
50
|
-
Object.defineProperty(exports, "TransactionStatus", { enumerable: true, get: function () { return Transaction_2.TransactionStatus; } });
|
|
51
|
-
var Asset_2 = require("./Asset");
|
|
52
|
-
Object.defineProperty(exports, "AssetType", { enumerable: true, get: function () { return Asset_2.AssetType; } });
|
|
53
|
-
Object.defineProperty(exports, "AssetPrivacy", { enumerable: true, get: function () { return Asset_2.AssetPrivacy; } });
|
|
54
|
-
exports.default = database_1.default;
|