clhq-dynamodb-module 1.1.0-alpha.90 → 1.1.0-alpha.91

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clhq-dynamodb-module",
3
- "version": "1.1.0-alpha.90",
3
+ "version": "1.1.0-alpha.91",
4
4
  "description": "Reusable DynamoDB service package for the monorepo",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,48 +0,0 @@
1
- export declare enum ProjectStatus {
2
- DRAFT = "draft",
3
- IN_PROGRESS = "in_progress",
4
- RENDERING = "rendering",
5
- COMPLETED = "completed",
6
- FAILED = "failed",
7
- ARCHIVED = "archived"
8
- }
9
- export declare enum ProjectVisibility {
10
- PRIVATE = "private",
11
- WORKSPACE = "workspace",
12
- PUBLIC = "public"
13
- }
14
- export declare class Project {
15
- id: string;
16
- workspaceId: string;
17
- ownerId: string;
18
- name: string;
19
- description?: string;
20
- thumbnailUrl?: string;
21
- durationMs: number;
22
- fps: number;
23
- resolutionWidth: number;
24
- resolutionHeight: number;
25
- backgroundColor: string;
26
- aspectRatio: string;
27
- status: ProjectStatus;
28
- visibility: ProjectVisibility;
29
- version: number;
30
- isTemplate: boolean;
31
- isFavorite: boolean;
32
- collaboratorIds?: string[];
33
- tags?: string[];
34
- templateCategory?: string;
35
- isPremiumTemplate: boolean;
36
- templateUsageCount: number;
37
- lastOpenedAt?: string;
38
- lastEditedBy?: string;
39
- createdAt?: string;
40
- updatedAt?: string;
41
- settings?: {
42
- autoSave?: boolean;
43
- gridSnap?: boolean;
44
- showTimecode?: boolean;
45
- previewQuality?: 'low' | 'medium' | 'high';
46
- audioLevels?: boolean;
47
- };
48
- }
@@ -1,175 +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.ProjectVisibility = exports.ProjectStatus = void 0;
13
- const class_validator_1 = require("class-validator");
14
- var ProjectStatus;
15
- (function (ProjectStatus) {
16
- ProjectStatus["DRAFT"] = "draft";
17
- ProjectStatus["IN_PROGRESS"] = "in_progress";
18
- ProjectStatus["RENDERING"] = "rendering";
19
- ProjectStatus["COMPLETED"] = "completed";
20
- ProjectStatus["FAILED"] = "failed";
21
- ProjectStatus["ARCHIVED"] = "archived";
22
- })(ProjectStatus || (exports.ProjectStatus = ProjectStatus = {}));
23
- var ProjectVisibility;
24
- (function (ProjectVisibility) {
25
- ProjectVisibility["PRIVATE"] = "private";
26
- ProjectVisibility["WORKSPACE"] = "workspace";
27
- ProjectVisibility["PUBLIC"] = "public";
28
- })(ProjectVisibility || (exports.ProjectVisibility = ProjectVisibility = {}));
29
- class Project {
30
- id;
31
- workspaceId;
32
- ownerId;
33
- name;
34
- description;
35
- thumbnailUrl;
36
- durationMs = 0;
37
- fps = 30;
38
- resolutionWidth = 1920;
39
- resolutionHeight = 1080;
40
- backgroundColor = '#000000';
41
- aspectRatio = '16:9';
42
- status = ProjectStatus.DRAFT;
43
- visibility = ProjectVisibility.PRIVATE;
44
- version = 1;
45
- isTemplate = false;
46
- isFavorite = false;
47
- collaboratorIds;
48
- tags;
49
- templateCategory;
50
- isPremiumTemplate = false;
51
- templateUsageCount = 0;
52
- lastOpenedAt;
53
- lastEditedBy;
54
- createdAt;
55
- updatedAt;
56
- settings;
57
- }
58
- exports.Project = Project;
59
- __decorate([
60
- (0, class_validator_1.IsString)(),
61
- __metadata("design:type", String)
62
- ], Project.prototype, "id", void 0);
63
- __decorate([
64
- (0, class_validator_1.IsString)(),
65
- __metadata("design:type", String)
66
- ], Project.prototype, "workspaceId", void 0);
67
- __decorate([
68
- (0, class_validator_1.IsString)(),
69
- __metadata("design:type", String)
70
- ], Project.prototype, "ownerId", void 0);
71
- __decorate([
72
- (0, class_validator_1.IsString)(),
73
- __metadata("design:type", String)
74
- ], Project.prototype, "name", void 0);
75
- __decorate([
76
- (0, class_validator_1.IsString)(),
77
- (0, class_validator_1.IsOptional)(),
78
- __metadata("design:type", String)
79
- ], Project.prototype, "description", void 0);
80
- __decorate([
81
- (0, class_validator_1.IsString)(),
82
- (0, class_validator_1.IsOptional)(),
83
- __metadata("design:type", String)
84
- ], Project.prototype, "thumbnailUrl", void 0);
85
- __decorate([
86
- (0, class_validator_1.IsNumber)(),
87
- __metadata("design:type", Number)
88
- ], Project.prototype, "durationMs", void 0);
89
- __decorate([
90
- (0, class_validator_1.IsNumber)(),
91
- __metadata("design:type", Number)
92
- ], Project.prototype, "fps", void 0);
93
- __decorate([
94
- (0, class_validator_1.IsNumber)(),
95
- __metadata("design:type", Number)
96
- ], Project.prototype, "resolutionWidth", void 0);
97
- __decorate([
98
- (0, class_validator_1.IsNumber)(),
99
- __metadata("design:type", Number)
100
- ], Project.prototype, "resolutionHeight", void 0);
101
- __decorate([
102
- (0, class_validator_1.IsString)(),
103
- __metadata("design:type", String)
104
- ], Project.prototype, "backgroundColor", void 0);
105
- __decorate([
106
- (0, class_validator_1.IsString)(),
107
- __metadata("design:type", String)
108
- ], Project.prototype, "aspectRatio", void 0);
109
- __decorate([
110
- (0, class_validator_1.IsEnum)(ProjectStatus),
111
- __metadata("design:type", String)
112
- ], Project.prototype, "status", void 0);
113
- __decorate([
114
- (0, class_validator_1.IsEnum)(ProjectVisibility),
115
- __metadata("design:type", String)
116
- ], Project.prototype, "visibility", void 0);
117
- __decorate([
118
- (0, class_validator_1.IsNumber)(),
119
- __metadata("design:type", Number)
120
- ], Project.prototype, "version", void 0);
121
- __decorate([
122
- (0, class_validator_1.IsBoolean)(),
123
- __metadata("design:type", Boolean)
124
- ], Project.prototype, "isTemplate", void 0);
125
- __decorate([
126
- (0, class_validator_1.IsBoolean)(),
127
- __metadata("design:type", Boolean)
128
- ], Project.prototype, "isFavorite", void 0);
129
- __decorate([
130
- (0, class_validator_1.IsArray)(),
131
- (0, class_validator_1.IsOptional)(),
132
- __metadata("design:type", Array)
133
- ], Project.prototype, "collaboratorIds", void 0);
134
- __decorate([
135
- (0, class_validator_1.IsArray)(),
136
- (0, class_validator_1.IsOptional)(),
137
- __metadata("design:type", Array)
138
- ], Project.prototype, "tags", void 0);
139
- __decorate([
140
- (0, class_validator_1.IsString)(),
141
- (0, class_validator_1.IsOptional)(),
142
- __metadata("design:type", String)
143
- ], Project.prototype, "templateCategory", void 0);
144
- __decorate([
145
- (0, class_validator_1.IsBoolean)(),
146
- __metadata("design:type", Boolean)
147
- ], Project.prototype, "isPremiumTemplate", void 0);
148
- __decorate([
149
- (0, class_validator_1.IsNumber)(),
150
- __metadata("design:type", Number)
151
- ], Project.prototype, "templateUsageCount", void 0);
152
- __decorate([
153
- (0, class_validator_1.IsString)(),
154
- (0, class_validator_1.IsOptional)(),
155
- __metadata("design:type", String)
156
- ], Project.prototype, "lastOpenedAt", void 0);
157
- __decorate([
158
- (0, class_validator_1.IsString)(),
159
- (0, class_validator_1.IsOptional)(),
160
- __metadata("design:type", String)
161
- ], Project.prototype, "lastEditedBy", void 0);
162
- __decorate([
163
- (0, class_validator_1.IsString)(),
164
- (0, class_validator_1.IsOptional)(),
165
- __metadata("design:type", String)
166
- ], Project.prototype, "createdAt", void 0);
167
- __decorate([
168
- (0, class_validator_1.IsString)(),
169
- (0, class_validator_1.IsOptional)(),
170
- __metadata("design:type", String)
171
- ], Project.prototype, "updatedAt", void 0);
172
- __decorate([
173
- (0, class_validator_1.IsOptional)(),
174
- __metadata("design:type", Object)
175
- ], Project.prototype, "settings", void 0);
@@ -1,17 +0,0 @@
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
- }
@@ -1,132 +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
- 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);