clhq-dynamodb-module 1.1.0-alpha.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.module.d.ts +2 -0
- package/dist/app.module.js +88 -0
- package/dist/common/enums/index.d.ts +1 -0
- package/dist/common/enums/index.js +17 -0
- package/dist/common/enums/project-enums.d.ts +13 -0
- package/dist/common/enums/project-enums.js +18 -0
- package/dist/common/user.controller.d.ts +12 -0
- package/dist/common/user.controller.js +102 -0
- package/dist/dbservice/dynamodb-base.service.d.ts +23 -0
- package/dist/dbservice/dynamodb-base.service.js +105 -0
- package/dist/dbservice/index.d.ts +4 -0
- package/dist/dbservice/index.js +20 -0
- package/dist/dbservice/projects.service.d.ts +5 -0
- package/dist/dbservice/projects.service.js +25 -0
- package/dist/dbservice/users.service.d.ts +5 -0
- package/dist/dbservice/users.service.js +25 -0
- package/dist/dbservice/workspaces.service.d.ts +5 -0
- package/dist/dbservice/workspaces.service.js +25 -0
- package/dist/entities/ai-usage.entity.d.ts +16 -0
- package/dist/entities/ai-usage.entity.js +71 -0
- package/dist/entities/asset.entity.d.ts +59 -0
- package/dist/entities/asset.entity.js +185 -0
- package/dist/entities/auth.entity.d.ts +10 -0
- package/dist/entities/auth.entity.js +9 -0
- package/dist/entities/clip-effect.entity.d.ts +9 -0
- package/dist/entities/clip-effect.entity.js +53 -0
- package/dist/entities/clip.entity.d.ts +44 -0
- package/dist/entities/clip.entity.js +114 -0
- package/dist/entities/comment.entity.d.ts +18 -0
- package/dist/entities/comment.entity.js +83 -0
- package/dist/entities/common.entity.d.ts +21 -0
- package/dist/entities/common.entity.js +27 -0
- package/dist/entities/credit-transaction.entity.d.ts +15 -0
- package/dist/entities/credit-transaction.entity.js +66 -0
- package/dist/entities/editor-project.entity.d.ts +48 -0
- package/dist/entities/editor-project.entity.js +226 -0
- package/dist/entities/effect.entity.d.ts +22 -0
- package/dist/entities/effect.entity.js +87 -0
- package/dist/entities/index.d.ts +28 -0
- package/dist/entities/index.js +44 -0
- package/dist/entities/invite.entity.d.ts +17 -0
- package/dist/entities/invite.entity.js +73 -0
- package/dist/entities/keyframe.entity.d.ts +18 -0
- package/dist/entities/keyframe.entity.js +73 -0
- package/dist/entities/payment-transaction.entity.d.ts +40 -0
- package/dist/entities/payment-transaction.entity.js +138 -0
- package/dist/entities/payment.entity.d.ts +24 -0
- package/dist/entities/payment.entity.js +89 -0
- package/dist/entities/plan.entity.d.ts +13 -0
- package/dist/entities/plan.entity.js +77 -0
- package/dist/entities/project-version.entity.d.ts +11 -0
- package/dist/entities/project-version.entity.js +66 -0
- package/dist/entities/project.entity.d.ts +48 -0
- package/dist/entities/project.entity.js +175 -0
- package/dist/entities/reward-rule.entity.d.ts +15 -0
- package/dist/entities/reward-rule.entity.js +67 -0
- package/dist/entities/stripe-webhook-event.entity.d.ts +9 -0
- package/dist/entities/stripe-webhook-event.entity.js +54 -0
- package/dist/entities/subscription-plan.entity.d.ts +37 -0
- package/dist/entities/subscription-plan.entity.js +197 -0
- package/dist/entities/subscription-usage.entity.d.ts +15 -0
- package/dist/entities/subscription-usage.entity.js +83 -0
- package/dist/entities/timeline.entity.d.ts +8 -0
- package/dist/entities/timeline.entity.js +48 -0
- package/dist/entities/track.entity.d.ts +20 -0
- package/dist/entities/track.entity.js +81 -0
- package/dist/entities/user-onboarding-response.entity.d.ts +8 -0
- package/dist/entities/user-onboarding-response.entity.js +48 -0
- package/dist/entities/user-profile.entity.d.ts +51 -0
- package/dist/entities/user-profile.entity.js +200 -0
- package/dist/entities/user-subscription.entity.d.ts +44 -0
- package/dist/entities/user-subscription.entity.js +160 -0
- package/dist/entities/user.entity.d.ts +32 -0
- package/dist/entities/user.entity.js +133 -0
- package/dist/entities/workspace-member.entity.d.ts +8 -0
- package/dist/entities/workspace-member.entity.js +49 -0
- package/dist/entities/workspace.entity.d.ts +9 -0
- package/dist/entities/workspace.entity.js +54 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +22 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +10 -0
- package/dist/repositories/asset.repository.d.ts +15 -0
- package/dist/repositories/asset.repository.js +101 -0
- package/dist/repositories/base.repository.d.ts +31 -0
- package/dist/repositories/base.repository.js +172 -0
- package/dist/repositories/clip-effect.repository.d.ts +9 -0
- package/dist/repositories/clip-effect.repository.js +49 -0
- package/dist/repositories/clip.repository.d.ts +13 -0
- package/dist/repositories/clip.repository.js +101 -0
- package/dist/repositories/comment.repository.d.ts +12 -0
- package/dist/repositories/comment.repository.js +92 -0
- package/dist/repositories/editor-project.repository.d.ts +26 -0
- package/dist/repositories/editor-project.repository.js +107 -0
- package/dist/repositories/effect.repository.d.ts +10 -0
- package/dist/repositories/effect.repository.js +59 -0
- package/dist/repositories/index.d.ts +21 -0
- package/dist/repositories/index.js +37 -0
- package/dist/repositories/keyframe.repository.d.ts +9 -0
- package/dist/repositories/keyframe.repository.js +49 -0
- package/dist/repositories/payment-transaction.repository.d.ts +13 -0
- package/dist/repositories/payment-transaction.repository.js +123 -0
- package/dist/repositories/project-version.repository.d.ts +9 -0
- package/dist/repositories/project-version.repository.js +51 -0
- package/dist/repositories/project.repository.d.ts +17 -0
- package/dist/repositories/project.repository.js +132 -0
- package/dist/repositories/reward-rule.repository.d.ts +13 -0
- package/dist/repositories/reward-rule.repository.js +84 -0
- package/dist/repositories/subscription-plan.repository.d.ts +11 -0
- package/dist/repositories/subscription-plan.repository.js +49 -0
- package/dist/repositories/subscription-usage.repository.d.ts +12 -0
- package/dist/repositories/subscription-usage.repository.js +68 -0
- package/dist/repositories/timeline.repository.d.ts +9 -0
- package/dist/repositories/timeline.repository.js +53 -0
- package/dist/repositories/track.repository.d.ts +13 -0
- package/dist/repositories/track.repository.js +61 -0
- package/dist/repositories/user-onboarding-response.repository.d.ts +11 -0
- package/dist/repositories/user-onboarding-response.repository.js +58 -0
- package/dist/repositories/user-profile.repository.d.ts +18 -0
- package/dist/repositories/user-profile.repository.js +62 -0
- package/dist/repositories/user-subscription.repository.d.ts +13 -0
- package/dist/repositories/user-subscription.repository.js +52 -0
- package/dist/repositories/user.repository.d.ts +20 -0
- package/dist/repositories/user.repository.js +94 -0
- package/dist/repositories/workspace-member.repository.d.ts +10 -0
- package/dist/repositories/workspace-member.repository.js +37 -0
- package/dist/repositories/workspace.repository.d.ts +10 -0
- package/dist/repositories/workspace.repository.js +45 -0
- package/package.json +63 -0
- package/readme.entity.implementation.md +1560 -0
|
@@ -0,0 +1,123 @@
|
|
|
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 PaymentTransactionRepository_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.PaymentTransactionRepository = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
16
|
+
const base_repository_1 = require("./base.repository");
|
|
17
|
+
const payment_transaction_entity_1 = require("../entities/payment-transaction.entity");
|
|
18
|
+
let PaymentTransactionRepository = PaymentTransactionRepository_1 = class PaymentTransactionRepository extends base_repository_1.BaseRepository {
|
|
19
|
+
logger = new common_1.Logger(PaymentTransactionRepository_1.name);
|
|
20
|
+
constructor(dynamoDbClient) {
|
|
21
|
+
super(dynamoDbClient, `payment-transaction-${process.env.STAGE}`);
|
|
22
|
+
}
|
|
23
|
+
async findByUserId(userId) {
|
|
24
|
+
const result = await this.dynamoDb.query({
|
|
25
|
+
TableName: this.tableName,
|
|
26
|
+
IndexName: 'userId-createdAt-index',
|
|
27
|
+
KeyConditionExpression: 'userId = :userId',
|
|
28
|
+
ScanIndexForward: false,
|
|
29
|
+
ExpressionAttributeValues: {
|
|
30
|
+
':userId': userId,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
return result.Items || [];
|
|
34
|
+
}
|
|
35
|
+
async findBySubscriptionId(subscriptionId) {
|
|
36
|
+
const result = await this.dynamoDb.query({
|
|
37
|
+
TableName: this.tableName,
|
|
38
|
+
IndexName: 'subscriptionId-index',
|
|
39
|
+
KeyConditionExpression: 'subscriptionId = :subscriptionId',
|
|
40
|
+
ExpressionAttributeValues: {
|
|
41
|
+
':subscriptionId': subscriptionId,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
return result.Items || [];
|
|
45
|
+
}
|
|
46
|
+
async findByStripePaymentIntentId(stripePaymentIntentId) {
|
|
47
|
+
const result = await this.dynamoDb.query({
|
|
48
|
+
TableName: this.tableName,
|
|
49
|
+
IndexName: 'stripePaymentIntentId-index',
|
|
50
|
+
KeyConditionExpression: 'stripePaymentIntentId = :stripePaymentIntentId',
|
|
51
|
+
ExpressionAttributeValues: {
|
|
52
|
+
':stripePaymentIntentId': stripePaymentIntentId,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
return result.Items?.[0];
|
|
56
|
+
}
|
|
57
|
+
async findByStatusAndDateRange(status, startDate, endDate) {
|
|
58
|
+
const result = await this.dynamoDb.query({
|
|
59
|
+
TableName: this.tableName,
|
|
60
|
+
IndexName: 'status-createdAt-index',
|
|
61
|
+
KeyConditionExpression: '#status = :status AND createdAt BETWEEN :startDate AND :endDate',
|
|
62
|
+
ExpressionAttributeNames: {
|
|
63
|
+
'#status': 'status',
|
|
64
|
+
},
|
|
65
|
+
ExpressionAttributeValues: {
|
|
66
|
+
':status': status,
|
|
67
|
+
':startDate': startDate,
|
|
68
|
+
':endDate': endDate,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
return result.Items || [];
|
|
72
|
+
}
|
|
73
|
+
async findFailedTransactions(userId) {
|
|
74
|
+
if (userId) {
|
|
75
|
+
const result = await this.dynamoDb.query({
|
|
76
|
+
TableName: this.tableName,
|
|
77
|
+
IndexName: 'userId-status-index',
|
|
78
|
+
KeyConditionExpression: 'userId = :userId AND #status = :status',
|
|
79
|
+
ExpressionAttributeNames: {
|
|
80
|
+
'#status': 'status',
|
|
81
|
+
},
|
|
82
|
+
ExpressionAttributeValues: {
|
|
83
|
+
':userId': userId,
|
|
84
|
+
':status': payment_transaction_entity_1.TransactionStatus.FAILED,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
return result.Items || [];
|
|
88
|
+
}
|
|
89
|
+
const result = await this.dynamoDb.query({
|
|
90
|
+
TableName: this.tableName,
|
|
91
|
+
IndexName: 'status-index',
|
|
92
|
+
KeyConditionExpression: '#status = :status',
|
|
93
|
+
ExpressionAttributeNames: {
|
|
94
|
+
'#status': 'status',
|
|
95
|
+
},
|
|
96
|
+
ExpressionAttributeValues: {
|
|
97
|
+
':status': payment_transaction_entity_1.TransactionStatus.FAILED,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
return result.Items || [];
|
|
101
|
+
}
|
|
102
|
+
async getTotalRevenueByPeriod(startDate, endDate) {
|
|
103
|
+
const result = await this.dynamoDb.scan({
|
|
104
|
+
TableName: this.tableName,
|
|
105
|
+
FilterExpression: '#status = :completed AND transactionType = :payment AND createdAt BETWEEN :startDate AND :endDate',
|
|
106
|
+
ExpressionAttributeNames: {
|
|
107
|
+
'#status': 'status',
|
|
108
|
+
},
|
|
109
|
+
ExpressionAttributeValues: {
|
|
110
|
+
':completed': payment_transaction_entity_1.TransactionStatus.COMPLETED,
|
|
111
|
+
':payment': payment_transaction_entity_1.PaymentTransactionType.PAYMENT,
|
|
112
|
+
':startDate': startDate,
|
|
113
|
+
':endDate': endDate,
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
return result.Items.reduce((total, transaction) => total + transaction.amount, 0);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
exports.PaymentTransactionRepository = PaymentTransactionRepository;
|
|
120
|
+
exports.PaymentTransactionRepository = PaymentTransactionRepository = PaymentTransactionRepository_1 = __decorate([
|
|
121
|
+
(0, common_1.Injectable)(),
|
|
122
|
+
__metadata("design:paramtypes", [client_dynamodb_1.DynamoDB])
|
|
123
|
+
], PaymentTransactionRepository);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DynamoDB } from '@aws-sdk/client-dynamodb';
|
|
2
|
+
import { BaseRepository } from './base.repository';
|
|
3
|
+
import { ProjectVersion } from '../entities/project-version.entity';
|
|
4
|
+
export declare class ProjectVersionRepository extends BaseRepository<ProjectVersion> {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(dynamoDbClient: DynamoDB);
|
|
7
|
+
findByProjectId(projectId: string): Promise<ProjectVersion[]>;
|
|
8
|
+
findLatestVersion(projectId: string): Promise<ProjectVersion | undefined>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 ProjectVersionRepository_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.ProjectVersionRepository = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
16
|
+
const base_repository_1 = require("./base.repository");
|
|
17
|
+
let ProjectVersionRepository = ProjectVersionRepository_1 = class ProjectVersionRepository extends base_repository_1.BaseRepository {
|
|
18
|
+
logger = new common_1.Logger(ProjectVersionRepository_1.name);
|
|
19
|
+
constructor(dynamoDbClient) {
|
|
20
|
+
super(dynamoDbClient, `project-version-${process.env.STAGE}`);
|
|
21
|
+
}
|
|
22
|
+
async findByProjectId(projectId) {
|
|
23
|
+
const result = await this.dynamoDb.query({
|
|
24
|
+
TableName: this.tableName,
|
|
25
|
+
IndexName: 'projectId-versionNumber-index',
|
|
26
|
+
KeyConditionExpression: 'projectId = :projectId',
|
|
27
|
+
ExpressionAttributeValues: {
|
|
28
|
+
':projectId': projectId,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return result.Items || [];
|
|
32
|
+
}
|
|
33
|
+
async findLatestVersion(projectId) {
|
|
34
|
+
const result = await this.dynamoDb.query({
|
|
35
|
+
TableName: this.tableName,
|
|
36
|
+
IndexName: 'projectId-versionNumber-index',
|
|
37
|
+
KeyConditionExpression: 'projectId = :projectId',
|
|
38
|
+
ScanIndexForward: false,
|
|
39
|
+
Limit: 1,
|
|
40
|
+
ExpressionAttributeValues: {
|
|
41
|
+
':projectId': projectId,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
return result.Items?.[0];
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.ProjectVersionRepository = ProjectVersionRepository;
|
|
48
|
+
exports.ProjectVersionRepository = ProjectVersionRepository = ProjectVersionRepository_1 = __decorate([
|
|
49
|
+
(0, common_1.Injectable)(),
|
|
50
|
+
__metadata("design:paramtypes", [client_dynamodb_1.DynamoDB])
|
|
51
|
+
], ProjectVersionRepository);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DynamoDB } from '@aws-sdk/client-dynamodb';
|
|
2
|
+
import { BaseRepository } from './base.repository';
|
|
3
|
+
import { Project, ProjectStatus } from '../entities/project.entity';
|
|
4
|
+
export declare class ProjectRepository extends BaseRepository<Project> {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(dynamoDbClient: DynamoDB);
|
|
7
|
+
findByWorkspaceId(workspaceId: string): Promise<Project[]>;
|
|
8
|
+
findByOwnerId(ownerId: string): Promise<Project[]>;
|
|
9
|
+
findByStatus(status: ProjectStatus): Promise<Project[]>;
|
|
10
|
+
findTemplates(category?: string, isPremium?: boolean): Promise<Project[]>;
|
|
11
|
+
findRecentProjects(userId: string, limit?: number): Promise<Project[]>;
|
|
12
|
+
findFavoriteProjects(userId: string): Promise<Project[]>;
|
|
13
|
+
findByTags(tags: string[], workspaceId?: string): Promise<Project[]>;
|
|
14
|
+
updateLastOpened(projectId: string, userId: string): Promise<void>;
|
|
15
|
+
incrementTemplateUsage(projectId: string): Promise<void>;
|
|
16
|
+
searchProjects(searchTerm: string, workspaceId?: string, userId?: string): Promise<Project[]>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
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 ProjectRepository_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.ProjectRepository = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
16
|
+
const base_repository_1 = require("./base.repository");
|
|
17
|
+
let ProjectRepository = ProjectRepository_1 = class ProjectRepository extends base_repository_1.BaseRepository {
|
|
18
|
+
logger = new common_1.Logger(ProjectRepository_1.name);
|
|
19
|
+
constructor(dynamoDbClient) {
|
|
20
|
+
super(dynamoDbClient, `projects-${process.env.STAGE}`);
|
|
21
|
+
}
|
|
22
|
+
async findByWorkspaceId(workspaceId) {
|
|
23
|
+
return this.find({ workspaceId });
|
|
24
|
+
}
|
|
25
|
+
async findByOwnerId(ownerId) {
|
|
26
|
+
return this.find({ ownerId });
|
|
27
|
+
}
|
|
28
|
+
async findByStatus(status) {
|
|
29
|
+
return this.find({ status });
|
|
30
|
+
}
|
|
31
|
+
async findTemplates(category, isPremium) {
|
|
32
|
+
let filterExpression = `isTemplate = :isTemplate`;
|
|
33
|
+
const expressionAttributeValues = {
|
|
34
|
+
':isTemplate': true,
|
|
35
|
+
};
|
|
36
|
+
if (category) {
|
|
37
|
+
filterExpression += ` AND templateCategory = :category`;
|
|
38
|
+
expressionAttributeValues[`:category`] = category;
|
|
39
|
+
}
|
|
40
|
+
if (isPremium !== undefined) {
|
|
41
|
+
filterExpression += ` AND isPremiumTemplate = :isPremium`;
|
|
42
|
+
expressionAttributeValues[`:isPremium`] = isPremium;
|
|
43
|
+
}
|
|
44
|
+
const result = await this.dynamoDb.scan({
|
|
45
|
+
TableName: this.tableName,
|
|
46
|
+
FilterExpression: filterExpression,
|
|
47
|
+
ExpressionAttributeValues: expressionAttributeValues,
|
|
48
|
+
});
|
|
49
|
+
return result.Items || [];
|
|
50
|
+
}
|
|
51
|
+
async findRecentProjects(userId, limit = 10) {
|
|
52
|
+
const all = await this.find({ ownerId: userId });
|
|
53
|
+
return all
|
|
54
|
+
.filter((p) => p.lastOpenedAt)
|
|
55
|
+
.sort((a, b) => (b.lastOpenedAt || '').localeCompare(a.lastOpenedAt || ''))
|
|
56
|
+
.slice(0, limit);
|
|
57
|
+
}
|
|
58
|
+
async findFavoriteProjects(userId) {
|
|
59
|
+
const all = await this.find({ ownerId: userId, isFavorite: true });
|
|
60
|
+
return all;
|
|
61
|
+
}
|
|
62
|
+
async findByTags(tags, workspaceId) {
|
|
63
|
+
const tagConditions = tags
|
|
64
|
+
.map((_, index) => `contains(tags, :tag${index})`)
|
|
65
|
+
.join(' OR ');
|
|
66
|
+
let filterExpression = `(${tagConditions})`;
|
|
67
|
+
const expressionAttributeValues = {};
|
|
68
|
+
tags.forEach((tag, index) => {
|
|
69
|
+
expressionAttributeValues[`:tag${index}`] = tag;
|
|
70
|
+
});
|
|
71
|
+
if (workspaceId) {
|
|
72
|
+
filterExpression += ` AND workspaceId = :workspaceId`;
|
|
73
|
+
expressionAttributeValues[`:workspaceId`] = workspaceId;
|
|
74
|
+
}
|
|
75
|
+
const result = await this.dynamoDb.scan({
|
|
76
|
+
TableName: this.tableName,
|
|
77
|
+
FilterExpression: filterExpression,
|
|
78
|
+
ExpressionAttributeValues: expressionAttributeValues,
|
|
79
|
+
});
|
|
80
|
+
return result.Items || [];
|
|
81
|
+
}
|
|
82
|
+
async updateLastOpened(projectId, userId) {
|
|
83
|
+
await this.dynamoDb.update({
|
|
84
|
+
TableName: this.tableName,
|
|
85
|
+
Key: { id: projectId },
|
|
86
|
+
UpdateExpression: 'SET lastOpenedAt = :timestamp, lastEditedBy = :userId',
|
|
87
|
+
ExpressionAttributeValues: {
|
|
88
|
+
':timestamp': new Date().toISOString(),
|
|
89
|
+
':userId': userId,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async incrementTemplateUsage(projectId) {
|
|
94
|
+
await this.dynamoDb.update({
|
|
95
|
+
TableName: this.tableName,
|
|
96
|
+
Key: { id: projectId },
|
|
97
|
+
UpdateExpression: 'ADD templateUsageCount :increment',
|
|
98
|
+
ExpressionAttributeValues: {
|
|
99
|
+
':increment': 1,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
async searchProjects(searchTerm, workspaceId, userId) {
|
|
104
|
+
let filterExpression = `contains(#name, :searchTerm) OR contains(description, :searchTerm)`;
|
|
105
|
+
const expressionAttributeNames = {
|
|
106
|
+
'#name': 'name',
|
|
107
|
+
};
|
|
108
|
+
const expressionAttributeValues = {
|
|
109
|
+
':searchTerm': searchTerm,
|
|
110
|
+
};
|
|
111
|
+
if (workspaceId) {
|
|
112
|
+
filterExpression += ` AND workspaceId = :workspaceId`;
|
|
113
|
+
expressionAttributeValues[`:workspaceId`] = workspaceId;
|
|
114
|
+
}
|
|
115
|
+
if (userId) {
|
|
116
|
+
filterExpression += ` AND ownerId = :userId`;
|
|
117
|
+
expressionAttributeValues[`:userId`] = userId;
|
|
118
|
+
}
|
|
119
|
+
const result = await this.dynamoDb.scan({
|
|
120
|
+
TableName: this.tableName,
|
|
121
|
+
FilterExpression: filterExpression,
|
|
122
|
+
ExpressionAttributeNames: expressionAttributeNames,
|
|
123
|
+
ExpressionAttributeValues: expressionAttributeValues,
|
|
124
|
+
});
|
|
125
|
+
return result.Items || [];
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
exports.ProjectRepository = ProjectRepository;
|
|
129
|
+
exports.ProjectRepository = ProjectRepository = ProjectRepository_1 = __decorate([
|
|
130
|
+
(0, common_1.Injectable)(),
|
|
131
|
+
__metadata("design:paramtypes", [client_dynamodb_1.DynamoDB])
|
|
132
|
+
], ProjectRepository);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DynamoDB } from '@aws-sdk/client-dynamodb';
|
|
2
|
+
import { BaseRepository } from './base.repository';
|
|
3
|
+
import { RewardRule, RewardType } from '../entities/reward-rule.entity';
|
|
4
|
+
export declare class RewardRuleRepository extends BaseRepository<RewardRule> {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(dynamoDbClient: DynamoDB);
|
|
7
|
+
findByType(type: RewardType): Promise<RewardRule[]>;
|
|
8
|
+
findActive(): Promise<RewardRule[]>;
|
|
9
|
+
findById(id: string): Promise<RewardRule | undefined>;
|
|
10
|
+
createRewardRule(rule: RewardRule): Promise<RewardRule>;
|
|
11
|
+
updateRewardRule(id: string, updates: Partial<RewardRule>): Promise<RewardRule | undefined>;
|
|
12
|
+
deleteRewardRule(id: string): Promise<boolean>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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 RewardRuleRepository_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.RewardRuleRepository = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
16
|
+
const base_repository_1 = require("./base.repository");
|
|
17
|
+
let RewardRuleRepository = RewardRuleRepository_1 = class RewardRuleRepository extends base_repository_1.BaseRepository {
|
|
18
|
+
logger = new common_1.Logger(RewardRuleRepository_1.name);
|
|
19
|
+
constructor(dynamoDbClient) {
|
|
20
|
+
super(dynamoDbClient, `reward-rule-${process.env.STAGE}`);
|
|
21
|
+
}
|
|
22
|
+
async findByType(type) {
|
|
23
|
+
const result = await this.dynamoDb.query({
|
|
24
|
+
TableName: this.tableName,
|
|
25
|
+
IndexName: 'type-index',
|
|
26
|
+
KeyConditionExpression: 'type = :type',
|
|
27
|
+
ExpressionAttributeValues: {
|
|
28
|
+
':type': type,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return result.Items || [];
|
|
32
|
+
}
|
|
33
|
+
async findActive() {
|
|
34
|
+
const result = await this.dynamoDb.query({
|
|
35
|
+
TableName: this.tableName,
|
|
36
|
+
IndexName: 'isActive-index',
|
|
37
|
+
KeyConditionExpression: 'isActive = :active',
|
|
38
|
+
ExpressionAttributeValues: {
|
|
39
|
+
':active': true,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
return result.Items || [];
|
|
43
|
+
}
|
|
44
|
+
async findById(id) {
|
|
45
|
+
const result = await this.dynamoDb.query({
|
|
46
|
+
TableName: this.tableName,
|
|
47
|
+
KeyConditionExpression: 'id = :id',
|
|
48
|
+
ExpressionAttributeValues: {
|
|
49
|
+
':id': id,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
return result.Items?.[0];
|
|
53
|
+
}
|
|
54
|
+
async createRewardRule(rule) {
|
|
55
|
+
await this.dynamoDb.put({
|
|
56
|
+
TableName: this.tableName,
|
|
57
|
+
Item: rule,
|
|
58
|
+
});
|
|
59
|
+
return rule;
|
|
60
|
+
}
|
|
61
|
+
async updateRewardRule(id, updates) {
|
|
62
|
+
const rule = await this.findById(id);
|
|
63
|
+
if (!rule)
|
|
64
|
+
return undefined;
|
|
65
|
+
const updatedRule = { ...rule, ...updates };
|
|
66
|
+
await this.dynamoDb.put({
|
|
67
|
+
TableName: this.tableName,
|
|
68
|
+
Item: updatedRule,
|
|
69
|
+
});
|
|
70
|
+
return updatedRule;
|
|
71
|
+
}
|
|
72
|
+
async deleteRewardRule(id) {
|
|
73
|
+
await this.dynamoDb.delete({
|
|
74
|
+
TableName: this.tableName,
|
|
75
|
+
Key: { id },
|
|
76
|
+
});
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
exports.RewardRuleRepository = RewardRuleRepository;
|
|
81
|
+
exports.RewardRuleRepository = RewardRuleRepository = RewardRuleRepository_1 = __decorate([
|
|
82
|
+
(0, common_1.Injectable)(),
|
|
83
|
+
__metadata("design:paramtypes", [client_dynamodb_1.DynamoDB])
|
|
84
|
+
], RewardRuleRepository);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DynamoDB } from '@aws-sdk/client-dynamodb';
|
|
2
|
+
import { BaseRepository } from './base.repository';
|
|
3
|
+
import { SubscriptionPlan } from '../entities/subscription-plan.entity';
|
|
4
|
+
export declare class SubscriptionPlanRepository extends BaseRepository<SubscriptionPlan> {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(dynamoDbClient: DynamoDB);
|
|
7
|
+
findByPlanKey(planKey: string): Promise<SubscriptionPlan | undefined>;
|
|
8
|
+
findActivePlans(): Promise<SubscriptionPlan[]>;
|
|
9
|
+
findFeaturedPlans(): Promise<SubscriptionPlan[]>;
|
|
10
|
+
findByPriceRange(minPrice: number, maxPrice: number): Promise<SubscriptionPlan[]>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 SubscriptionPlanRepository_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.SubscriptionPlanRepository = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
16
|
+
const base_repository_1 = require("./base.repository");
|
|
17
|
+
let SubscriptionPlanRepository = SubscriptionPlanRepository_1 = class SubscriptionPlanRepository extends base_repository_1.BaseRepository {
|
|
18
|
+
logger = new common_1.Logger(SubscriptionPlanRepository_1.name);
|
|
19
|
+
constructor(dynamoDbClient) {
|
|
20
|
+
super(dynamoDbClient, `subscription-plan-${process.env.STAGE}`);
|
|
21
|
+
}
|
|
22
|
+
async findByPlanKey(planKey) {
|
|
23
|
+
const result = await this.find({ planKey });
|
|
24
|
+
return result[0];
|
|
25
|
+
}
|
|
26
|
+
async findActivePlans() {
|
|
27
|
+
const result = await this.find({ isActive: true });
|
|
28
|
+
return result.sort((a, b) => (a.displayOrder || 0) - (b.displayOrder || 0));
|
|
29
|
+
}
|
|
30
|
+
async findFeaturedPlans() {
|
|
31
|
+
return this.find({ isFeatured: true });
|
|
32
|
+
}
|
|
33
|
+
async findByPriceRange(minPrice, maxPrice) {
|
|
34
|
+
const result = await this.dynamoDb.scan({
|
|
35
|
+
TableName: this.tableName,
|
|
36
|
+
FilterExpression: 'priceMonthly BETWEEN :minPrice AND :maxPrice',
|
|
37
|
+
ExpressionAttributeValues: {
|
|
38
|
+
':minPrice': minPrice,
|
|
39
|
+
':maxPrice': maxPrice,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
return result.Items || [];
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
exports.SubscriptionPlanRepository = SubscriptionPlanRepository;
|
|
46
|
+
exports.SubscriptionPlanRepository = SubscriptionPlanRepository = SubscriptionPlanRepository_1 = __decorate([
|
|
47
|
+
(0, common_1.Injectable)(),
|
|
48
|
+
__metadata("design:paramtypes", [client_dynamodb_1.DynamoDB])
|
|
49
|
+
], SubscriptionPlanRepository);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DynamoDB } from '@aws-sdk/client-dynamodb';
|
|
2
|
+
import { BaseRepository } from './base.repository';
|
|
3
|
+
import { SubscriptionUsage } from '../entities/subscription-usage.entity';
|
|
4
|
+
export declare class SubscriptionUsageRepository extends BaseRepository<SubscriptionUsage> {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(dynamoDbClient: DynamoDB);
|
|
7
|
+
findByUserId(userId: string): Promise<SubscriptionUsage[]>;
|
|
8
|
+
findCurrentUsageByUserId(userId: string): Promise<SubscriptionUsage | undefined>;
|
|
9
|
+
findBySubscriptionId(subscriptionId: string): Promise<SubscriptionUsage[]>;
|
|
10
|
+
incrementUsage(userId: string, usageType: keyof Pick<SubscriptionUsage, 'projectsCreated' | 'exportsCompleted' | 'aiFeaturesUsed' | 'renderMinutesUsed'>, amount?: number): Promise<void>;
|
|
11
|
+
updateStorageUsage(userId: string, storageUsedGb: number): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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 SubscriptionUsageRepository_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.SubscriptionUsageRepository = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
16
|
+
const base_repository_1 = require("./base.repository");
|
|
17
|
+
let SubscriptionUsageRepository = SubscriptionUsageRepository_1 = class SubscriptionUsageRepository extends base_repository_1.BaseRepository {
|
|
18
|
+
logger = new common_1.Logger(SubscriptionUsageRepository_1.name);
|
|
19
|
+
constructor(dynamoDbClient) {
|
|
20
|
+
super(dynamoDbClient, `subscription-usage-${process.env.STAGE}`);
|
|
21
|
+
}
|
|
22
|
+
async findByUserId(userId) {
|
|
23
|
+
return this.find({ userId });
|
|
24
|
+
}
|
|
25
|
+
async findCurrentUsageByUserId(userId) {
|
|
26
|
+
const now = new Date().toISOString();
|
|
27
|
+
const results = await this.find({ userId });
|
|
28
|
+
return results.find((usage) => usage.periodStart <= now && usage.periodEnd > now);
|
|
29
|
+
}
|
|
30
|
+
async findBySubscriptionId(subscriptionId) {
|
|
31
|
+
return this.find({ subscriptionId });
|
|
32
|
+
}
|
|
33
|
+
async incrementUsage(userId, usageType, amount = 1) {
|
|
34
|
+
const currentUsage = await this.findCurrentUsageByUserId(userId);
|
|
35
|
+
if (!currentUsage) {
|
|
36
|
+
throw new Error('No current usage record found for user');
|
|
37
|
+
}
|
|
38
|
+
await this.dynamoDb.update({
|
|
39
|
+
TableName: this.tableName,
|
|
40
|
+
Key: { id: currentUsage.id },
|
|
41
|
+
UpdateExpression: `ADD ${usageType} :amount SET updatedAt = :updatedAt`,
|
|
42
|
+
ExpressionAttributeValues: {
|
|
43
|
+
':amount': amount,
|
|
44
|
+
':updatedAt': new Date().toISOString(),
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async updateStorageUsage(userId, storageUsedGb) {
|
|
49
|
+
const currentUsage = await this.findCurrentUsageByUserId(userId);
|
|
50
|
+
if (!currentUsage) {
|
|
51
|
+
throw new Error('No current usage record found for user');
|
|
52
|
+
}
|
|
53
|
+
await this.dynamoDb.update({
|
|
54
|
+
TableName: this.tableName,
|
|
55
|
+
Key: { id: currentUsage.id },
|
|
56
|
+
UpdateExpression: 'SET storageUsedGb = :storageUsed, updatedAt = :updatedAt',
|
|
57
|
+
ExpressionAttributeValues: {
|
|
58
|
+
':storageUsed': storageUsedGb,
|
|
59
|
+
':updatedAt': new Date().toISOString(),
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.SubscriptionUsageRepository = SubscriptionUsageRepository;
|
|
65
|
+
exports.SubscriptionUsageRepository = SubscriptionUsageRepository = SubscriptionUsageRepository_1 = __decorate([
|
|
66
|
+
(0, common_1.Injectable)(),
|
|
67
|
+
__metadata("design:paramtypes", [client_dynamodb_1.DynamoDB])
|
|
68
|
+
], SubscriptionUsageRepository);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DynamoDB } from '@aws-sdk/client-dynamodb';
|
|
2
|
+
import { BaseRepository } from './base.repository';
|
|
3
|
+
import { Timeline } from '../entities/timeline.entity';
|
|
4
|
+
export declare class TimelineRepository extends BaseRepository<Timeline> {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(dynamoDbClient: DynamoDB);
|
|
7
|
+
findByProjectId(projectId: string): Promise<Timeline[]>;
|
|
8
|
+
findMainTimelineByProjectId(projectId: string): Promise<Timeline | undefined>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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 TimelineRepository_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.TimelineRepository = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
16
|
+
const base_repository_1 = require("./base.repository");
|
|
17
|
+
let TimelineRepository = TimelineRepository_1 = class TimelineRepository extends base_repository_1.BaseRepository {
|
|
18
|
+
logger = new common_1.Logger(TimelineRepository_1.name);
|
|
19
|
+
constructor(dynamoDbClient) {
|
|
20
|
+
super(dynamoDbClient, `timeline-${process.env.STAGE}`);
|
|
21
|
+
}
|
|
22
|
+
async findByProjectId(projectId) {
|
|
23
|
+
const result = await this.dynamoDb.query({
|
|
24
|
+
TableName: this.tableName,
|
|
25
|
+
IndexName: 'projectId-index',
|
|
26
|
+
KeyConditionExpression: 'projectId = :projectId',
|
|
27
|
+
ExpressionAttributeValues: {
|
|
28
|
+
':projectId': projectId,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return result.Items || [];
|
|
32
|
+
}
|
|
33
|
+
async findMainTimelineByProjectId(projectId) {
|
|
34
|
+
const result = await this.dynamoDb.query({
|
|
35
|
+
TableName: this.tableName,
|
|
36
|
+
IndexName: 'projectId-name-index',
|
|
37
|
+
KeyConditionExpression: 'projectId = :projectId AND #name = :name',
|
|
38
|
+
ExpressionAttributeNames: {
|
|
39
|
+
'#name': 'name',
|
|
40
|
+
},
|
|
41
|
+
ExpressionAttributeValues: {
|
|
42
|
+
':projectId': projectId,
|
|
43
|
+
':name': 'Main Timeline',
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
return result.Items?.[0];
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.TimelineRepository = TimelineRepository;
|
|
50
|
+
exports.TimelineRepository = TimelineRepository = TimelineRepository_1 = __decorate([
|
|
51
|
+
(0, common_1.Injectable)(),
|
|
52
|
+
__metadata("design:paramtypes", [client_dynamodb_1.DynamoDB])
|
|
53
|
+
], TimelineRepository);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DynamoDB } from '@aws-sdk/client-dynamodb';
|
|
2
|
+
import { BaseRepository } from './base.repository';
|
|
3
|
+
import { Track, TrackType } from '../entities/track.entity';
|
|
4
|
+
export declare class TrackRepository extends BaseRepository<Track> {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(dynamoDbClient: DynamoDB);
|
|
7
|
+
findByTimelineId(timelineId: string): Promise<Track[]>;
|
|
8
|
+
findByTrackType(timelineId: string, trackType: TrackType): Promise<Track[]>;
|
|
9
|
+
reorderTracks(timelineId: string, trackOrders: {
|
|
10
|
+
id: string;
|
|
11
|
+
orderIndex: number;
|
|
12
|
+
}[]): Promise<void>;
|
|
13
|
+
}
|