cadenlane-cli-2 1.0.0
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/CHANGELOG.md +6 -0
- package/LICENSE +21 -0
- package/README.md +333 -0
- package/bin.js +2 -0
- package/dist/application/config/config.manager.d.ts +62 -0
- package/dist/application/config/config.manager.d.ts.map +1 -0
- package/dist/application/config/config.manager.js +146 -0
- package/dist/application/config/config.manager.js.map +1 -0
- package/dist/application/services/application.service.d.ts +35 -0
- package/dist/application/services/application.service.d.ts.map +1 -0
- package/dist/application/services/application.service.js +174 -0
- package/dist/application/services/application.service.js.map +1 -0
- package/dist/application/services/download.service.d.ts +27 -0
- package/dist/application/services/download.service.d.ts.map +1 -0
- package/dist/application/services/download.service.js +197 -0
- package/dist/application/services/download.service.js.map +1 -0
- package/dist/application/services/file-naming.service.d.ts +34 -0
- package/dist/application/services/file-naming.service.d.ts.map +1 -0
- package/dist/application/services/file-naming.service.js +142 -0
- package/dist/application/services/file-naming.service.js.map +1 -0
- package/dist/application/services/queue.service.d.ts +53 -0
- package/dist/application/services/queue.service.d.ts.map +1 -0
- package/dist/application/services/queue.service.js +82 -0
- package/dist/application/services/queue.service.js.map +1 -0
- package/dist/cli/commands/start.command.d.ts +39 -0
- package/dist/cli/commands/start.command.d.ts.map +1 -0
- package/dist/cli/commands/start.command.js +196 -0
- package/dist/cli/commands/start.command.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +86 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/domain/constants/config.constants.d.ts +54 -0
- package/dist/domain/constants/config.constants.d.ts.map +1 -0
- package/dist/domain/constants/config.constants.js +142 -0
- package/dist/domain/constants/config.constants.js.map +1 -0
- package/dist/domain/dtos/index.d.ts +4 -0
- package/dist/domain/dtos/index.d.ts.map +1 -0
- package/dist/domain/dtos/index.js +10 -0
- package/dist/domain/dtos/index.js.map +1 -0
- package/dist/domain/dtos/log-entry.dto.d.ts +15 -0
- package/dist/domain/dtos/log-entry.dto.d.ts.map +1 -0
- package/dist/domain/dtos/log-entry.dto.js +64 -0
- package/dist/domain/dtos/log-entry.dto.js.map +1 -0
- package/dist/domain/dtos/message.dto.d.ts +27 -0
- package/dist/domain/dtos/message.dto.d.ts.map +1 -0
- package/dist/domain/dtos/message.dto.js +140 -0
- package/dist/domain/dtos/message.dto.js.map +1 -0
- package/dist/domain/dtos/queue-message.dto.d.ts +10 -0
- package/dist/domain/dtos/queue-message.dto.d.ts.map +1 -0
- package/dist/domain/dtos/queue-message.dto.js +39 -0
- package/dist/domain/dtos/queue-message.dto.js.map +1 -0
- package/dist/domain/entities/cli-instance.entity.d.ts +55 -0
- package/dist/domain/entities/cli-instance.entity.d.ts.map +1 -0
- package/dist/domain/entities/cli-instance.entity.js +132 -0
- package/dist/domain/entities/cli-instance.entity.js.map +1 -0
- package/dist/domain/entities/index.d.ts +3 -0
- package/dist/domain/entities/index.d.ts.map +1 -0
- package/dist/domain/entities/index.js +8 -0
- package/dist/domain/entities/index.js.map +1 -0
- package/dist/domain/entities/log-entry.entity.d.ts +60 -0
- package/dist/domain/entities/log-entry.entity.d.ts.map +1 -0
- package/dist/domain/entities/log-entry.entity.js +101 -0
- package/dist/domain/entities/log-entry.entity.js.map +1 -0
- package/dist/domain/entities/message.entity.d.ts +64 -0
- package/dist/domain/entities/message.entity.d.ts.map +1 -0
- package/dist/domain/entities/message.entity.js +110 -0
- package/dist/domain/entities/message.entity.js.map +1 -0
- package/dist/domain/enums/error-category.enum.d.ts +11 -0
- package/dist/domain/enums/error-category.enum.d.ts.map +1 -0
- package/dist/domain/enums/error-category.enum.js +15 -0
- package/dist/domain/enums/error-category.enum.js.map +1 -0
- package/dist/domain/enums/index.d.ts +4 -0
- package/dist/domain/enums/index.d.ts.map +1 -0
- package/dist/domain/enums/index.js +10 -0
- package/dist/domain/enums/index.js.map +1 -0
- package/dist/domain/enums/log-level.enum.d.ts +11 -0
- package/dist/domain/enums/log-level.enum.d.ts.map +1 -0
- package/dist/domain/enums/log-level.enum.js +15 -0
- package/dist/domain/enums/log-level.enum.js.map +1 -0
- package/dist/domain/enums/message-status.enum.d.ts +11 -0
- package/dist/domain/enums/message-status.enum.d.ts.map +1 -0
- package/dist/domain/enums/message-status.enum.js +15 -0
- package/dist/domain/enums/message-status.enum.js.map +1 -0
- package/dist/domain/interfaces/adapters/ifilesystem.adapter.d.ts +34 -0
- package/dist/domain/interfaces/adapters/ifilesystem.adapter.d.ts.map +1 -0
- package/dist/domain/interfaces/adapters/ifilesystem.adapter.js +3 -0
- package/dist/domain/interfaces/adapters/ifilesystem.adapter.js.map +1 -0
- package/dist/domain/interfaces/adapters/ihttp.adapter.d.ts +22 -0
- package/dist/domain/interfaces/adapters/ihttp.adapter.d.ts.map +1 -0
- package/dist/domain/interfaces/adapters/ihttp.adapter.js +3 -0
- package/dist/domain/interfaces/adapters/ihttp.adapter.js.map +1 -0
- package/dist/domain/interfaces/adapters/index.d.ts +4 -0
- package/dist/domain/interfaces/adapters/index.d.ts.map +1 -0
- package/dist/domain/interfaces/adapters/index.js +3 -0
- package/dist/domain/interfaces/adapters/index.js.map +1 -0
- package/dist/domain/interfaces/adapters/isupabase.adapter.d.ts +27 -0
- package/dist/domain/interfaces/adapters/isupabase.adapter.d.ts.map +1 -0
- package/dist/domain/interfaces/adapters/isupabase.adapter.js +3 -0
- package/dist/domain/interfaces/adapters/isupabase.adapter.js.map +1 -0
- package/dist/domain/interfaces/repositories/ilog.repository.d.ts +32 -0
- package/dist/domain/interfaces/repositories/ilog.repository.d.ts.map +1 -0
- package/dist/domain/interfaces/repositories/ilog.repository.js +3 -0
- package/dist/domain/interfaces/repositories/ilog.repository.js.map +1 -0
- package/dist/domain/interfaces/repositories/imessage.repository.d.ts +39 -0
- package/dist/domain/interfaces/repositories/imessage.repository.d.ts.map +1 -0
- package/dist/domain/interfaces/repositories/imessage.repository.js +3 -0
- package/dist/domain/interfaces/repositories/imessage.repository.js.map +1 -0
- package/dist/domain/interfaces/repositories/index.d.ts +4 -0
- package/dist/domain/interfaces/repositories/index.d.ts.map +1 -0
- package/dist/domain/interfaces/repositories/index.js +3 -0
- package/dist/domain/interfaces/repositories/index.js.map +1 -0
- package/dist/domain/interfaces/repositories/iqueue.repository.d.ts +75 -0
- package/dist/domain/interfaces/repositories/iqueue.repository.d.ts.map +1 -0
- package/dist/domain/interfaces/repositories/iqueue.repository.js +3 -0
- package/dist/domain/interfaces/repositories/iqueue.repository.js.map +1 -0
- package/dist/domain/interfaces/services/idownload.service.d.ts +28 -0
- package/dist/domain/interfaces/services/idownload.service.d.ts.map +1 -0
- package/dist/domain/interfaces/services/idownload.service.js +3 -0
- package/dist/domain/interfaces/services/idownload.service.js.map +1 -0
- package/dist/domain/interfaces/services/iqueue.service.d.ts +35 -0
- package/dist/domain/interfaces/services/iqueue.service.d.ts.map +1 -0
- package/dist/domain/interfaces/services/iqueue.service.js +3 -0
- package/dist/domain/interfaces/services/iqueue.service.js.map +1 -0
- package/dist/domain/services/path-resolver.service.d.ts +94 -0
- package/dist/domain/services/path-resolver.service.d.ts.map +1 -0
- package/dist/domain/services/path-resolver.service.js +332 -0
- package/dist/domain/services/path-resolver.service.js.map +1 -0
- package/dist/domain/validators/index.d.ts +4 -0
- package/dist/domain/validators/index.d.ts.map +1 -0
- package/dist/domain/validators/index.js +10 -0
- package/dist/domain/validators/index.js.map +1 -0
- package/dist/domain/validators/message.validator.d.ts +20 -0
- package/dist/domain/validators/message.validator.d.ts.map +1 -0
- package/dist/domain/validators/message.validator.js +31 -0
- package/dist/domain/validators/message.validator.js.map +1 -0
- package/dist/domain/validators/path.validator.d.ts +44 -0
- package/dist/domain/validators/path.validator.d.ts.map +1 -0
- package/dist/domain/validators/path.validator.js +156 -0
- package/dist/domain/validators/path.validator.js.map +1 -0
- package/dist/domain/validators/url.validator.d.ts +19 -0
- package/dist/domain/validators/url.validator.d.ts.map +1 -0
- package/dist/domain/validators/url.validator.js +46 -0
- package/dist/domain/validators/url.validator.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/adapters/filesystem.adapter.d.ts +35 -0
- package/dist/infrastructure/adapters/filesystem.adapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/filesystem.adapter.js +103 -0
- package/dist/infrastructure/adapters/filesystem.adapter.js.map +1 -0
- package/dist/infrastructure/adapters/http.adapter.d.ts +15 -0
- package/dist/infrastructure/adapters/http.adapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/http.adapter.js +80 -0
- package/dist/infrastructure/adapters/http.adapter.js.map +1 -0
- package/dist/infrastructure/adapters/index.d.ts +4 -0
- package/dist/infrastructure/adapters/index.d.ts.map +1 -0
- package/dist/infrastructure/adapters/index.js +10 -0
- package/dist/infrastructure/adapters/index.js.map +1 -0
- package/dist/infrastructure/adapters/pgmq.adapter.d.ts +29 -0
- package/dist/infrastructure/adapters/pgmq.adapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/pgmq.adapter.js +84 -0
- package/dist/infrastructure/adapters/pgmq.adapter.js.map +1 -0
- package/dist/infrastructure/adapters/supabase.adapter.d.ts +79 -0
- package/dist/infrastructure/adapters/supabase.adapter.d.ts.map +1 -0
- package/dist/infrastructure/adapters/supabase.adapter.js +97 -0
- package/dist/infrastructure/adapters/supabase.adapter.js.map +1 -0
- package/dist/infrastructure/database/supabase.client.d.ts +20 -0
- package/dist/infrastructure/database/supabase.client.d.ts.map +1 -0
- package/dist/infrastructure/database/supabase.client.js +36 -0
- package/dist/infrastructure/database/supabase.client.js.map +1 -0
- package/dist/infrastructure/di/container.d.ts +18 -0
- package/dist/infrastructure/di/container.d.ts.map +1 -0
- package/dist/infrastructure/di/container.js +103 -0
- package/dist/infrastructure/di/container.js.map +1 -0
- package/dist/infrastructure/repositories/cli-instance.repository.d.ts +64 -0
- package/dist/infrastructure/repositories/cli-instance.repository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/cli-instance.repository.js +154 -0
- package/dist/infrastructure/repositories/cli-instance.repository.js.map +1 -0
- package/dist/infrastructure/repositories/config.repository.d.ts +52 -0
- package/dist/infrastructure/repositories/config.repository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/config.repository.js +130 -0
- package/dist/infrastructure/repositories/config.repository.js.map +1 -0
- package/dist/infrastructure/repositories/index.d.ts +4 -0
- package/dist/infrastructure/repositories/index.d.ts.map +1 -0
- package/dist/infrastructure/repositories/index.js +10 -0
- package/dist/infrastructure/repositories/index.js.map +1 -0
- package/dist/infrastructure/repositories/log.repository.d.ts +44 -0
- package/dist/infrastructure/repositories/log.repository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/log.repository.js +108 -0
- package/dist/infrastructure/repositories/log.repository.js.map +1 -0
- package/dist/infrastructure/repositories/message.repository.d.ts +51 -0
- package/dist/infrastructure/repositories/message.repository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/message.repository.js +161 -0
- package/dist/infrastructure/repositories/message.repository.js.map +1 -0
- package/dist/infrastructure/repositories/queue.repository.d.ts +69 -0
- package/dist/infrastructure/repositories/queue.repository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/queue.repository.js +130 -0
- package/dist/infrastructure/repositories/queue.repository.js.map +1 -0
- package/dist/infrastructure/utils/connection-health.util.d.ts +23 -0
- package/dist/infrastructure/utils/connection-health.util.d.ts.map +1 -0
- package/dist/infrastructure/utils/connection-health.util.js +64 -0
- package/dist/infrastructure/utils/connection-health.util.js.map +1 -0
- package/package.json +105 -0
- package/pm2.config.js +104 -0
|
@@ -0,0 +1,130 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ConfigRepository = void 0;
|
|
16
|
+
const tsyringe_1 = require("tsyringe");
|
|
17
|
+
const supabase_adapter_1 = require("../../infrastructure/adapters/supabase.adapter");
|
|
18
|
+
/**
|
|
19
|
+
* Configuration Repository
|
|
20
|
+
* Manages application configuration stored in the database
|
|
21
|
+
*/
|
|
22
|
+
let ConfigRepository = class ConfigRepository {
|
|
23
|
+
adapter;
|
|
24
|
+
TABLE_NAME = 'app_config';
|
|
25
|
+
constructor(adapter) {
|
|
26
|
+
this.adapter = adapter;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get a single configuration value by key
|
|
30
|
+
*/
|
|
31
|
+
async get(key) {
|
|
32
|
+
const { data, error } = await this.adapter.select(this.TABLE_NAME, '*', { column: 'config_key', value: key });
|
|
33
|
+
if (error || !data || data.length === 0) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return this.parseValue(data[0]);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get all configuration entries
|
|
40
|
+
*/
|
|
41
|
+
async getAll() {
|
|
42
|
+
try {
|
|
43
|
+
const { data, error } = await this.adapter.select(this.TABLE_NAME, '*');
|
|
44
|
+
if (error) {
|
|
45
|
+
console.warn(`[ConfigRepository] Failed to load config from database: ${error.message}`);
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
if (!data) {
|
|
49
|
+
return {};
|
|
50
|
+
}
|
|
51
|
+
const config = {};
|
|
52
|
+
for (const entry of data) {
|
|
53
|
+
config[entry.config_key] = this.parseValue(entry);
|
|
54
|
+
}
|
|
55
|
+
return config;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
59
|
+
console.warn(`[ConfigRepository] Error loading config: ${message}`);
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get configuration entries by prefix (e.g., 'queue.' returns all queue configs)
|
|
65
|
+
*/
|
|
66
|
+
async getByPrefix(prefix) {
|
|
67
|
+
const { data, error } = await this.adapter.select(this.TABLE_NAME, '*');
|
|
68
|
+
if (error || !data) {
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
const config = {};
|
|
72
|
+
for (const entry of data) {
|
|
73
|
+
if (entry.config_key.startsWith(prefix)) {
|
|
74
|
+
// Remove prefix from key for easier access
|
|
75
|
+
const shortKey = entry.config_key.substring(prefix.length);
|
|
76
|
+
config[shortKey] = this.parseValue(entry);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return config;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Set a configuration value
|
|
83
|
+
*/
|
|
84
|
+
async set(key, value) {
|
|
85
|
+
const configType = typeof value;
|
|
86
|
+
const configValue = String(value);
|
|
87
|
+
// Try to update first
|
|
88
|
+
const { data: existing } = await this.adapter.select(this.TABLE_NAME, 'id', { column: 'config_key', value: key });
|
|
89
|
+
if (existing && existing.length > 0) {
|
|
90
|
+
// Update existing
|
|
91
|
+
await this.adapter.update(this.TABLE_NAME, { config_value: configValue, config_type: configType }, { column: 'config_key', value: key });
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
// Insert new
|
|
95
|
+
await this.adapter.insert(this.TABLE_NAME, {
|
|
96
|
+
config_key: key,
|
|
97
|
+
config_value: configValue,
|
|
98
|
+
config_type: configType,
|
|
99
|
+
is_sensitive: false,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Delete a configuration entry
|
|
105
|
+
*/
|
|
106
|
+
async delete(key) {
|
|
107
|
+
await this.adapter.delete(this.TABLE_NAME, { column: 'config_key', value: key });
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Parse configuration value based on its type
|
|
111
|
+
*/
|
|
112
|
+
parseValue(entry) {
|
|
113
|
+
switch (entry.config_type) {
|
|
114
|
+
case 'number':
|
|
115
|
+
return parseInt(entry.config_value, 10);
|
|
116
|
+
case 'boolean':
|
|
117
|
+
return entry.config_value.toLowerCase() === 'true';
|
|
118
|
+
case 'string':
|
|
119
|
+
default:
|
|
120
|
+
return entry.config_value;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
exports.ConfigRepository = ConfigRepository;
|
|
125
|
+
exports.ConfigRepository = ConfigRepository = __decorate([
|
|
126
|
+
(0, tsyringe_1.injectable)(),
|
|
127
|
+
__param(0, (0, tsyringe_1.inject)(supabase_adapter_1.SupabaseAdapter)),
|
|
128
|
+
__metadata("design:paramtypes", [supabase_adapter_1.SupabaseAdapter])
|
|
129
|
+
], ConfigRepository);
|
|
130
|
+
//# sourceMappingURL=config.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.repository.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/config.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAA8C;AAC9C,iFAA6E;AAqB7E;;;GAGG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAGkB;IAF5B,UAAU,GAAG,YAAY,CAAC;IAE3C,YAA6C,OAAwB;QAAxB,YAA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ories/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueueRepository = exports.LogRepository = exports.MessageRepository = void 0;
|
|
4
|
+
var message_repository_1 = require("./message.repository");
|
|
5
|
+
Object.defineProperty(exports, "MessageRepository", { enumerable: true, get: function () { return message_repository_1.MessageRepository; } });
|
|
6
|
+
var log_repository_1 = require("./log.repository");
|
|
7
|
+
Object.defineProperty(exports, "LogRepository", { enumerable: true, get: function () { return log_repository_1.LogRepository; } });
|
|
8
|
+
var queue_repository_1 = require("./queue.repository");
|
|
9
|
+
Object.defineProperty(exports, "QueueRepository", { enumerable: true, get: function () { return queue_repository_1.QueueRepository; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/index.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA;AAC1B,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,uDAAqD;AAA5C,mHAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ILogRepository } from '../../domain/interfaces/repositories';
|
|
2
|
+
import { LogEntryEntity } from '../../domain/entities';
|
|
3
|
+
import { SupabaseAdapter } from '../adapters/supabase.adapter';
|
|
4
|
+
/**
|
|
5
|
+
* Log Repository
|
|
6
|
+
* Handles persistence operations for log entries
|
|
7
|
+
*/
|
|
8
|
+
export declare class LogRepository implements ILogRepository {
|
|
9
|
+
private adapter;
|
|
10
|
+
constructor(adapter: SupabaseAdapter);
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new log entry
|
|
13
|
+
* @param logEntry - Log entry entity to create
|
|
14
|
+
* @returns Created log entry entity
|
|
15
|
+
*/
|
|
16
|
+
create(logEntry: LogEntryEntity): Promise<LogEntryEntity>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates multiple log entries in batch
|
|
19
|
+
* @param logEntries - Array of log entry entities
|
|
20
|
+
* @returns Array of created log entry entities
|
|
21
|
+
*/
|
|
22
|
+
createBatch(logEntries: LogEntryEntity[]): Promise<LogEntryEntity[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Finds all logs for a specific message
|
|
25
|
+
* @param messageId - Message ID
|
|
26
|
+
* @returns Array of log entry entities
|
|
27
|
+
*/
|
|
28
|
+
findByMessageId(messageId: string): Promise<LogEntryEntity[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Finds error logs for a specific message
|
|
31
|
+
* @param messageId - Message ID
|
|
32
|
+
* @returns Array of error log entry entities
|
|
33
|
+
*/
|
|
34
|
+
findErrorsByMessageId(messageId: string): Promise<LogEntryEntity[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Converts entity to database row
|
|
37
|
+
*/
|
|
38
|
+
private entityToDb;
|
|
39
|
+
/**
|
|
40
|
+
* Converts database row to entity
|
|
41
|
+
*/
|
|
42
|
+
private dbToEntity;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=log.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.repository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/repositories/log.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D;;;GAGG;AACH,qBACa,aAAc,YAAW,cAAc;IAEvB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,eAAe;IAG3D;;;;OAIG;IACG,MAAM,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAY/D;;;;OAIG;IACG,WAAW,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAY1E;;;;OAIG;IACG,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAcnE;;;;OAIG;IACG,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAKzE;;OAEG;IACH,OAAO,CAAC,UAAU;IAYlB;;OAEG;IACH,OAAO,CAAC,UAAU;CAcnB"}
|
|
@@ -0,0 +1,108 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.LogRepository = void 0;
|
|
16
|
+
const tsyringe_1 = require("tsyringe");
|
|
17
|
+
const entities_1 = require("../../domain/entities");
|
|
18
|
+
const enums_1 = require("../../domain/enums");
|
|
19
|
+
const supabase_adapter_1 = require("../adapters/supabase.adapter");
|
|
20
|
+
/**
|
|
21
|
+
* Log Repository
|
|
22
|
+
* Handles persistence operations for log entries
|
|
23
|
+
*/
|
|
24
|
+
let LogRepository = class LogRepository {
|
|
25
|
+
adapter;
|
|
26
|
+
constructor(adapter) {
|
|
27
|
+
this.adapter = adapter;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new log entry
|
|
31
|
+
* @param logEntry - Log entry entity to create
|
|
32
|
+
* @returns Created log entry entity
|
|
33
|
+
*/
|
|
34
|
+
async create(logEntry) {
|
|
35
|
+
const data = this.entityToDb(logEntry);
|
|
36
|
+
const { data: result, error } = await this.adapter.insert('job_logs', data);
|
|
37
|
+
if (error || !result || result.length === 0) {
|
|
38
|
+
throw new Error('Failed to create log entry: ' + (error?.message || 'No data returned'));
|
|
39
|
+
}
|
|
40
|
+
return this.dbToEntity(result[0]);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates multiple log entries in batch
|
|
44
|
+
* @param logEntries - Array of log entry entities
|
|
45
|
+
* @returns Array of created log entry entities
|
|
46
|
+
*/
|
|
47
|
+
async createBatch(logEntries) {
|
|
48
|
+
const data = logEntries.map(entry => this.entityToDb(entry));
|
|
49
|
+
const { data: result, error } = await this.adapter.insert('job_logs', data);
|
|
50
|
+
if (error || !result) {
|
|
51
|
+
throw new Error('Failed to create log entries: ' + (error?.message || 'No data returned'));
|
|
52
|
+
}
|
|
53
|
+
return result.map(row => this.dbToEntity(row));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Finds all logs for a specific message
|
|
57
|
+
* @param messageId - Message ID
|
|
58
|
+
* @returns Array of log entry entities
|
|
59
|
+
*/
|
|
60
|
+
async findByMessageId(messageId) {
|
|
61
|
+
const { data, error } = await this.adapter.select('job_logs', '*', { column: 'message_id', value: messageId });
|
|
62
|
+
if (error || !data) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
return data.map(row => this.dbToEntity(row));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Finds error logs for a specific message
|
|
69
|
+
* @param messageId - Message ID
|
|
70
|
+
* @returns Array of error log entry entities
|
|
71
|
+
*/
|
|
72
|
+
async findErrorsByMessageId(messageId) {
|
|
73
|
+
const allLogs = await this.findByMessageId(messageId);
|
|
74
|
+
return allLogs.filter(log => log.log_level === enums_1.LogLevel.ERROR);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Converts entity to database row
|
|
78
|
+
*/
|
|
79
|
+
entityToDb(entity) {
|
|
80
|
+
return {
|
|
81
|
+
id: entity.id,
|
|
82
|
+
message_id: entity.message_id,
|
|
83
|
+
log_level: entity.log_level,
|
|
84
|
+
log_message: entity.log_message,
|
|
85
|
+
log_data: entity.log_data,
|
|
86
|
+
stack_trace: entity.stack_trace,
|
|
87
|
+
created_at: entity.created_at.toISOString(),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Converts database row to entity
|
|
92
|
+
*/
|
|
93
|
+
dbToEntity(row) {
|
|
94
|
+
const entity = new entities_1.LogEntryEntity(row.id, row.message_id, row.log_level, row.log_message, new Date(row.created_at));
|
|
95
|
+
if (row.log_data)
|
|
96
|
+
entity.log_data = row.log_data;
|
|
97
|
+
if (row.stack_trace)
|
|
98
|
+
entity.stack_trace = row.stack_trace;
|
|
99
|
+
return entity;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
exports.LogRepository = LogRepository;
|
|
103
|
+
exports.LogRepository = LogRepository = __decorate([
|
|
104
|
+
(0, tsyringe_1.injectable)(),
|
|
105
|
+
__param(0, (0, tsyringe_1.inject)(supabase_adapter_1.SupabaseAdapter)),
|
|
106
|
+
__metadata("design:paramtypes", [supabase_adapter_1.SupabaseAdapter])
|
|
107
|
+
], LogRepository);
|
|
108
|
+
//# sourceMappingURL=log.repository.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C,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,UAAU,CAAC,GAAQ;QACzB,MAAM,MAAM,GAAG,IAAI,yBAAc,CAC/B,GAAG,CAAC,EAAE,EACN,GAAG,CAAC,UAAU,EACd,GAAG,CAAC,SAAqB,EACzB,GAAG,CAAC,WAAW,EACf,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CACzB,CAAC;QAEF,IAAI,GAAG,CAAC,QAAQ;YAAE,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QACjD,IAAI,GAAG,CAAC,WAAW;YAAE,MAAM,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;QAE1D,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AApGY,sCAAa;wBAAb,aAAa;IADzB,IAAA,qBAAU,GAAE;IAGR,WAAA,IAAA,iBAAM,EAAC,kCAAe,CAAC,CAAA;qCAAkB,kCAAe;GAFhD,aAAa,CAoGzB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { IMessageRepository } from '../../domain/interfaces/repositories';
|
|
2
|
+
import { MessageEntity } from '../../domain/entities';
|
|
3
|
+
import { SupabaseAdapter } from '../adapters/supabase.adapter';
|
|
4
|
+
/**
|
|
5
|
+
* Message Repository
|
|
6
|
+
* Handles persistence operations for messages
|
|
7
|
+
*/
|
|
8
|
+
export declare class MessageRepository implements IMessageRepository {
|
|
9
|
+
private adapter;
|
|
10
|
+
constructor(adapter: SupabaseAdapter);
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new message record
|
|
13
|
+
* @param message - Message entity to create
|
|
14
|
+
* @returns Created message entity
|
|
15
|
+
*/
|
|
16
|
+
create(message: MessageEntity): Promise<MessageEntity>;
|
|
17
|
+
/**
|
|
18
|
+
* Updates an existing message
|
|
19
|
+
* @param message - Message entity with updated data
|
|
20
|
+
* @returns Updated message entity
|
|
21
|
+
*/
|
|
22
|
+
update(message: MessageEntity): Promise<MessageEntity>;
|
|
23
|
+
/**
|
|
24
|
+
* Finds a message by ID
|
|
25
|
+
* @param id - Message ID
|
|
26
|
+
* @returns Message entity or null if not found
|
|
27
|
+
*/
|
|
28
|
+
findById(id: string): Promise<MessageEntity | null>;
|
|
29
|
+
/**
|
|
30
|
+
* Finds a message by PGMQ message ID
|
|
31
|
+
* @param pgmqMessageId - PGMQ message ID
|
|
32
|
+
* @returns Message entity or null if not found
|
|
33
|
+
*/
|
|
34
|
+
findByPgmqMessageId(pgmqMessageId: number): Promise<MessageEntity | null>;
|
|
35
|
+
/**
|
|
36
|
+
* Finds messages by status
|
|
37
|
+
* @param status - Message status
|
|
38
|
+
* @param limit - Maximum number of results
|
|
39
|
+
* @returns Array of message entities
|
|
40
|
+
*/
|
|
41
|
+
findByStatus(status: string, limit?: number): Promise<MessageEntity[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Converts entity to database row
|
|
44
|
+
*/
|
|
45
|
+
private entityToDb;
|
|
46
|
+
/**
|
|
47
|
+
* Converts database row to entity
|
|
48
|
+
*/
|
|
49
|
+
private dbToEntity;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=message.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.repository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/repositories/message.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D;;;GAGG;AACH,qBACa,iBAAkB,YAAW,kBAAkB;IAE/B,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,eAAe;IAG3D;;;;OAIG;IACG,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAY5D;;;;OAIG;IACG,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAgB5D;;;;OAIG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAczD;;;;OAIG;IACG,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAc/E;;;;;OAKG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAgB5E;;OAEG;IACH,OAAO,CAAC,UAAU;IA0BlB;;OAEG;IACH,OAAO,CAAC,UAAU;CA+BnB"}
|
|
@@ -0,0 +1,161 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MessageRepository = void 0;
|
|
16
|
+
const tsyringe_1 = require("tsyringe");
|
|
17
|
+
const entities_1 = require("../../domain/entities");
|
|
18
|
+
const supabase_adapter_1 = require("../adapters/supabase.adapter");
|
|
19
|
+
/**
|
|
20
|
+
* Message Repository
|
|
21
|
+
* Handles persistence operations for messages
|
|
22
|
+
*/
|
|
23
|
+
let MessageRepository = class MessageRepository {
|
|
24
|
+
adapter;
|
|
25
|
+
constructor(adapter) {
|
|
26
|
+
this.adapter = adapter;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new message record
|
|
30
|
+
* @param message - Message entity to create
|
|
31
|
+
* @returns Created message entity
|
|
32
|
+
*/
|
|
33
|
+
async create(message) {
|
|
34
|
+
const data = this.entityToDb(message);
|
|
35
|
+
const { data: result, error } = await this.adapter.insert('messages', data);
|
|
36
|
+
if (error || !result || result.length === 0) {
|
|
37
|
+
throw new Error('Failed to create message: ' + (error?.message || 'No data returned'));
|
|
38
|
+
}
|
|
39
|
+
return this.dbToEntity(result[0]);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Updates an existing message
|
|
43
|
+
* @param message - Message entity with updated data
|
|
44
|
+
* @returns Updated message entity
|
|
45
|
+
*/
|
|
46
|
+
async update(message) {
|
|
47
|
+
const data = this.entityToDb(message);
|
|
48
|
+
const { data: result, error } = await this.adapter.update('messages', data, { column: 'id', value: message.id });
|
|
49
|
+
if (error || !result || result.length === 0) {
|
|
50
|
+
throw new Error('Failed to update message: ' + (error?.message || 'No data returned'));
|
|
51
|
+
}
|
|
52
|
+
return this.dbToEntity(result[0]);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Finds a message by ID
|
|
56
|
+
* @param id - Message ID
|
|
57
|
+
* @returns Message entity or null if not found
|
|
58
|
+
*/
|
|
59
|
+
async findById(id) {
|
|
60
|
+
const { data, error } = await this.adapter.select('messages', '*', { column: 'id', value: id });
|
|
61
|
+
if (error || !data || data.length === 0) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return this.dbToEntity(data[0]);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Finds a message by PGMQ message ID
|
|
68
|
+
* @param pgmqMessageId - PGMQ message ID
|
|
69
|
+
* @returns Message entity or null if not found
|
|
70
|
+
*/
|
|
71
|
+
async findByPgmqMessageId(pgmqMessageId) {
|
|
72
|
+
const { data, error } = await this.adapter.select('messages', '*', { column: 'pgmq_message_id', value: pgmqMessageId });
|
|
73
|
+
if (error || !data || data.length === 0) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
return this.dbToEntity(data[0]);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Finds messages by status
|
|
80
|
+
* @param status - Message status
|
|
81
|
+
* @param limit - Maximum number of results
|
|
82
|
+
* @returns Array of message entities
|
|
83
|
+
*/
|
|
84
|
+
async findByStatus(status, limit) {
|
|
85
|
+
const { data, error } = await this.adapter.select('messages', '*', { column: 'status', value: status });
|
|
86
|
+
if (error || !data) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
const entities = data.map(row => this.dbToEntity(row));
|
|
90
|
+
return limit ? entities.slice(0, limit) : entities;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Converts entity to database row
|
|
94
|
+
*/
|
|
95
|
+
entityToDb(entity) {
|
|
96
|
+
return {
|
|
97
|
+
id: entity.id,
|
|
98
|
+
pgmq_message_id: entity.pgmq_message_id,
|
|
99
|
+
file_url: entity.file_url,
|
|
100
|
+
target_folder: entity.target_folder,
|
|
101
|
+
status: entity.status,
|
|
102
|
+
received_at: entity.received_at.toISOString(),
|
|
103
|
+
processing_started_at: entity.processing_started_at?.toISOString(),
|
|
104
|
+
processing_completed_at: entity.processing_completed_at?.toISOString(),
|
|
105
|
+
file_name: entity.file_name,
|
|
106
|
+
file_path: entity.file_path,
|
|
107
|
+
file_size_bytes: entity.file_size_bytes,
|
|
108
|
+
download_duration_ms: entity.download_duration_ms,
|
|
109
|
+
total_duration_ms: entity.total_duration_ms,
|
|
110
|
+
error_message: entity.error_message,
|
|
111
|
+
error_category: entity.error_category,
|
|
112
|
+
retry_count: entity.retry_count || 0,
|
|
113
|
+
deleted_from_queue_at: entity.deleted_from_queue_at?.toISOString(),
|
|
114
|
+
processed_by_instance_id: entity.processed_by_instance_id,
|
|
115
|
+
processed_by_instance_name: entity.processed_by_instance_name,
|
|
116
|
+
processed_by_hostname: entity.processed_by_hostname,
|
|
117
|
+
processed_by_platform: entity.processed_by_platform,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Converts database row to entity
|
|
122
|
+
*/
|
|
123
|
+
dbToEntity(row) {
|
|
124
|
+
const entity = new entities_1.MessageEntity(row.id, row.pgmq_message_id, row.file_url, row.target_folder, row.status, new Date(row.received_at), row.processed_by_instance_id, row.processed_by_instance_name, row.processed_by_hostname, row.processed_by_platform);
|
|
125
|
+
// Map optional fields
|
|
126
|
+
if (row.processing_started_at)
|
|
127
|
+
entity.processing_started_at = new Date(row.processing_started_at);
|
|
128
|
+
if (row.processing_completed_at)
|
|
129
|
+
entity.processing_completed_at = new Date(row.processing_completed_at);
|
|
130
|
+
if (row.file_name)
|
|
131
|
+
entity.file_name = row.file_name;
|
|
132
|
+
if (row.file_path)
|
|
133
|
+
entity.file_path = row.file_path;
|
|
134
|
+
if (row.file_size_bytes)
|
|
135
|
+
entity.file_size_bytes = row.file_size_bytes;
|
|
136
|
+
if (row.download_duration_ms)
|
|
137
|
+
entity.download_duration_ms = row.download_duration_ms;
|
|
138
|
+
if (row.total_duration_ms)
|
|
139
|
+
entity.total_duration_ms = row.total_duration_ms;
|
|
140
|
+
if (row.error_message)
|
|
141
|
+
entity.error_message = row.error_message;
|
|
142
|
+
if (row.error_category)
|
|
143
|
+
entity.error_category = row.error_category;
|
|
144
|
+
if (row.retry_count)
|
|
145
|
+
entity.retry_count = row.retry_count;
|
|
146
|
+
if (row.created_at)
|
|
147
|
+
entity.created_at = new Date(row.created_at);
|
|
148
|
+
if (row.updated_at)
|
|
149
|
+
entity.updated_at = new Date(row.updated_at);
|
|
150
|
+
if (row.deleted_from_queue_at)
|
|
151
|
+
entity.deleted_from_queue_at = new Date(row.deleted_from_queue_at);
|
|
152
|
+
return entity;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
exports.MessageRepository = MessageRepository;
|
|
156
|
+
exports.MessageRepository = MessageRepository = __decorate([
|
|
157
|
+
(0, tsyringe_1.injectable)(),
|
|
158
|
+
__param(0, (0, tsyringe_1.inject)(supabase_adapter_1.SupabaseAdapter)),
|
|
159
|
+
__metadata("design:paramtypes", [supabase_adapter_1.SupabaseAdapter])
|
|
160
|
+
], MessageRepository);
|
|
161
|
+
//# sourceMappingURL=message.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.repository.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/message.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAA8C;AAE9C,gDAAkD;AAElD,mEAA+D;AAE/D;;;GAGG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAEO;IADnC,YACmC,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;IACxD,CAAC;IAEJ;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAAsB;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAEtC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAE5E,IAAI,KAAK,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,CAAC,KAAK,EAAE,OAAO,IAAI,kBAAkB,CAAC,CAAC,CAAC;QACzF,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,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ces/repositories';
|
|
2
|
+
import { QueueMessageDto } from '../../domain/dtos';
|
|
3
|
+
import { PgmqAdapter } from '../adapters/pgmq.adapter';
|
|
4
|
+
/**
|
|
5
|
+
* Queue Repository
|
|
6
|
+
* Handles PGMQ queue operations using direct PostgreSQL connection
|
|
7
|
+
*/
|
|
8
|
+
export declare class QueueRepository implements IQueueRepository {
|
|
9
|
+
private adapter;
|
|
10
|
+
constructor(adapter: PgmqAdapter);
|
|
11
|
+
/**
|
|
12
|
+
* Reads a message from the queue (non-blocking)
|
|
13
|
+
* @param queueName - Name of the queue
|
|
14
|
+
* @param visibilityTimeoutSeconds - Visibility timeout in seconds
|
|
15
|
+
* @returns PGMQ message or null if queue is empty
|
|
16
|
+
*/
|
|
17
|
+
readMessage(queueName: string, visibilityTimeoutSeconds: number): Promise<PgmqMessage | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Reads a message from the queue with blocking poll (event-driven)
|
|
20
|
+
* Note: Not implemented with direct PG adapter - use readMessage instead
|
|
21
|
+
* @param queueName - Name of the queue
|
|
22
|
+
* @param visibilityTimeoutSeconds - Visibility timeout in seconds
|
|
23
|
+
* @param pollTimeoutSeconds - How long to wait for a message (default: 5s)
|
|
24
|
+
* @param pollIntervalMs - Internal polling interval (default: 250ms)
|
|
25
|
+
* @returns PGMQ message or null if timeout reached
|
|
26
|
+
*/
|
|
27
|
+
readMessageWithPoll(queueName: string, visibilityTimeoutSeconds: number, _pollTimeoutSeconds?: number, _pollIntervalMs?: number): Promise<PgmqMessage | null>;
|
|
28
|
+
/**
|
|
29
|
+
* Deletes a message from the queue
|
|
30
|
+
* @param queueName - Name of the queue
|
|
31
|
+
* @param messageId - PGMQ message ID
|
|
32
|
+
* @returns true if deleted, false otherwise
|
|
33
|
+
*/
|
|
34
|
+
deleteMessage(queueName: string, messageId: number): Promise<boolean>;
|
|
35
|
+
/**
|
|
36
|
+
* Sends a message to the queue
|
|
37
|
+
* @param queueName - Name of the queue
|
|
38
|
+
* @param message - Message to send
|
|
39
|
+
* @returns PGMQ message ID
|
|
40
|
+
*/
|
|
41
|
+
sendMessage(queueName: string, message: QueueMessageDto): Promise<number>;
|
|
42
|
+
/**
|
|
43
|
+
* Gets queue metrics
|
|
44
|
+
* @param queueName - Name of the queue
|
|
45
|
+
* @returns Queue metrics
|
|
46
|
+
*/
|
|
47
|
+
getMetrics(_queueName: string): Promise<{
|
|
48
|
+
queue_name: string;
|
|
49
|
+
queue_length: number;
|
|
50
|
+
newest_msg_age_sec: number | null;
|
|
51
|
+
oldest_msg_age_sec: number | null;
|
|
52
|
+
total_messages: number;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new queue (idempotent - safe to call if queue exists)
|
|
56
|
+
* @param queueName - Name of the queue to create
|
|
57
|
+
* @returns true if created or already exists
|
|
58
|
+
*/
|
|
59
|
+
createQueue(queueName: string): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Sends a message to a specific CLI instance queue
|
|
62
|
+
* @param baseQueueName - Base queue name (e.g., 'image_downloads')
|
|
63
|
+
* @param targetInstanceId - Target CLI instance ID
|
|
64
|
+
* @param message - Message to send
|
|
65
|
+
* @returns PGMQ message ID
|
|
66
|
+
*/
|
|
67
|
+
sendMessageToInstance(baseQueueName: string, targetInstanceId: string, message: QueueMessageDto): Promise<number>;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=queue.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.repository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/repositories/queue.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD;;;GAGG;AACH,qBACa,eAAgB,YAAW,gBAAgB;IAE/B,OAAO,CAAC,OA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