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,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UrlValidator = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* URL Validator
|
|
6
|
+
* Validates URLs and extracts filenames
|
|
7
|
+
*/
|
|
8
|
+
class UrlValidator {
|
|
9
|
+
/**
|
|
10
|
+
* Validates if a string is a valid HTTP/HTTPS URL
|
|
11
|
+
* @param url - The URL to validate
|
|
12
|
+
* @returns true if valid, false otherwise
|
|
13
|
+
*/
|
|
14
|
+
isValid(url) {
|
|
15
|
+
if (!url || typeof url !== 'string') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const urlObj = new URL(url);
|
|
20
|
+
return urlObj.protocol === 'http:' || urlObj.protocol === 'https:';
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Extracts filename from URL
|
|
28
|
+
* @param url - The URL to extract filename from
|
|
29
|
+
* @returns The filename or 'download' as default
|
|
30
|
+
*/
|
|
31
|
+
extractFilename(url) {
|
|
32
|
+
try {
|
|
33
|
+
const urlObj = new URL(url);
|
|
34
|
+
const pathname = urlObj.pathname;
|
|
35
|
+
const segments = pathname.split('/');
|
|
36
|
+
const filename = segments[segments.length - 1];
|
|
37
|
+
// Return filename if it exists and is not empty, otherwise return default
|
|
38
|
+
return filename && filename.length > 0 ? filename : 'download';
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return 'download';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.UrlValidator = UrlValidator;
|
|
46
|
+
//# sourceMappingURL=url.validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.validator.js","sourceRoot":"","sources":["../../../src/domain/validators/url.validator.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,MAAa,YAAY;IACvB;;;;OAIG;IACH,OAAO,CAAC,GAAQ;QACd,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;YAC5B,OAAO,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC;QACrE,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,eAAe,CAAC,GAAW;QACzB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;YAC5B,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;YACjC,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACrC,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAE/C,0EAA0E;YAC1E,OAAO,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC;QACjE,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;CACF;AArCD,oCAqCC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Entry Point
|
|
3
|
+
* Exports the CLI for programmatic use
|
|
4
|
+
*/
|
|
5
|
+
export * from './cli/index';
|
|
6
|
+
export * from './application/services/application.service';
|
|
7
|
+
export * from './application/services/download.service';
|
|
8
|
+
export * from './application/services/queue.service';
|
|
9
|
+
export * from './application/config/config.manager';
|
|
10
|
+
export * from './infrastructure/di/container';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,4CAA4C,CAAC;AAC3D,cAAc,yCAAyC,CAAC;AACxD,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AACpD,cAAc,+BAA+B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* Main Entry Point
|
|
19
|
+
* Exports the CLI for programmatic use
|
|
20
|
+
*/
|
|
21
|
+
__exportStar(require("./cli/index"), exports);
|
|
22
|
+
__exportStar(require("./application/services/application.service"), exports);
|
|
23
|
+
__exportStar(require("./application/services/download.service"), exports);
|
|
24
|
+
__exportStar(require("./application/services/queue.service"), exports);
|
|
25
|
+
__exportStar(require("./application/config/config.manager"), exports);
|
|
26
|
+
__exportStar(require("./infrastructure/di/container"), exports);
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,8CAA4B;AAC5B,6EAA2D;AAC3D,0EAAwD;AACxD,uEAAqD;AACrD,sEAAoD;AACpD,gEAA8C"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IFileSystemAdapter } from '../../domain/interfaces/adapters/ifilesystem.adapter';
|
|
2
|
+
/**
|
|
3
|
+
* File System Adapter
|
|
4
|
+
* Handles file system operations
|
|
5
|
+
*/
|
|
6
|
+
export declare class FileSystemAdapter implements IFileSystemAdapter {
|
|
7
|
+
/**
|
|
8
|
+
* Writes a file to the file system
|
|
9
|
+
* @param filePath - Full path where to write the file
|
|
10
|
+
* @param data - Data to write (Buffer or string)
|
|
11
|
+
* @returns Promise that resolves when write is complete
|
|
12
|
+
*/
|
|
13
|
+
writeFile(filePath: string, data: Buffer | string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if a file exists
|
|
16
|
+
* @param filePath - Path to check
|
|
17
|
+
* @returns true if file exists, false otherwise
|
|
18
|
+
*/
|
|
19
|
+
fileExists(filePath: string): Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a directory (and parent directories if needed)
|
|
22
|
+
* @param dirPath - Directory path to create
|
|
23
|
+
* @returns Promise that resolves when directory is created
|
|
24
|
+
*/
|
|
25
|
+
ensureDir(dirPath: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Gets file stats
|
|
28
|
+
* @param filePath - Path to the file
|
|
29
|
+
* @returns File stats including size
|
|
30
|
+
*/
|
|
31
|
+
getFileStats(filePath: string): Promise<{
|
|
32
|
+
size: number;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=filesystem.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.adapter.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/adapters/filesystem.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AAEtF;;;GAGG;AACH,qBACa,iBAAkB,YAAW,kBAAkB;IAC1D;;;;;OAKG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvE;;;;OAIG;IACG,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASpD;;;;OAIG;IACG,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW/C;;;;OAIG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAIhE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.FileSystemAdapter = void 0;
|
|
43
|
+
const tsyringe_1 = require("tsyringe");
|
|
44
|
+
const fs = __importStar(require("fs/promises"));
|
|
45
|
+
/**
|
|
46
|
+
* File System Adapter
|
|
47
|
+
* Handles file system operations
|
|
48
|
+
*/
|
|
49
|
+
let FileSystemAdapter = class FileSystemAdapter {
|
|
50
|
+
/**
|
|
51
|
+
* Writes a file to the file system
|
|
52
|
+
* @param filePath - Full path where to write the file
|
|
53
|
+
* @param data - Data to write (Buffer or string)
|
|
54
|
+
* @returns Promise that resolves when write is complete
|
|
55
|
+
*/
|
|
56
|
+
async writeFile(filePath, data) {
|
|
57
|
+
await fs.writeFile(filePath, data);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Checks if a file exists
|
|
61
|
+
* @param filePath - Path to check
|
|
62
|
+
* @returns true if file exists, false otherwise
|
|
63
|
+
*/
|
|
64
|
+
async fileExists(filePath) {
|
|
65
|
+
try {
|
|
66
|
+
await fs.access(filePath);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Creates a directory (and parent directories if needed)
|
|
75
|
+
* @param dirPath - Directory path to create
|
|
76
|
+
* @returns Promise that resolves when directory is created
|
|
77
|
+
*/
|
|
78
|
+
async ensureDir(dirPath) {
|
|
79
|
+
try {
|
|
80
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
// Ignore error if directory already exists
|
|
84
|
+
if (error.code !== 'EEXIST') {
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Gets file stats
|
|
91
|
+
* @param filePath - Path to the file
|
|
92
|
+
* @returns File stats including size
|
|
93
|
+
*/
|
|
94
|
+
async getFileStats(filePath) {
|
|
95
|
+
const stats = await fs.stat(filePath);
|
|
96
|
+
return { size: stats.size };
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
exports.FileSystemAdapter = FileSystemAdapter;
|
|
100
|
+
exports.FileSystemAdapter = FileSystemAdapter = __decorate([
|
|
101
|
+
(0, tsyringe_1.injectable)()
|
|
102
|
+
], FileSystemAdapter);
|
|
103
|
+
//# sourceMappingURL=filesystem.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.adapter.js","sourceRoot":"","sources":["../../../src/infrastructure/adapters/filesystem.adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAsC;AACtC,gDAAkC;AAGlC;;;GAGG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B;;;;;OAKG;IACH,KAAK,CAAC,SAAS,CAAC,QAAgB,EAAE,IAAqB;QACrD,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,QAAgB;QAC/B,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,SAAS,CAAC,OAAe;QAC7B,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,2CAA2C;YAC3C,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC5B,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY,CAAC,QAAgB;QACjC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;CACF,CAAA;AAlDY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,qBAAU,GAAE;GACA,iBAAiB,CAkD7B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IHttpAdapter, HttpDownloadResult } from '../../domain/interfaces/adapters/ihttp.adapter';
|
|
2
|
+
/**
|
|
3
|
+
* HTTP Adapter
|
|
4
|
+
* Handles HTTP operations for downloading files
|
|
5
|
+
*/
|
|
6
|
+
export declare class HttpAdapter implements IHttpAdapter {
|
|
7
|
+
/**
|
|
8
|
+
* Downloads a file from a URL
|
|
9
|
+
* @param url - URL to download from
|
|
10
|
+
* @param timeoutMs - Timeout in milliseconds (default: 30000)
|
|
11
|
+
* @returns Download result with buffer and metadata
|
|
12
|
+
*/
|
|
13
|
+
download(url: string, timeoutMs?: number): Promise<HttpDownloadResult>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=http.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.adapter.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/adapters/http.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAE9F;;;GAGG;AACH,qBACa,WAAY,YAAW,YAAY;IAC9C;;;;;OAKG;IACG,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,GAAE,MAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAqDpF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.HttpAdapter = void 0;
|
|
13
|
+
const tsyringe_1 = require("tsyringe");
|
|
14
|
+
const axios_1 = __importDefault(require("axios"));
|
|
15
|
+
/**
|
|
16
|
+
* HTTP Adapter
|
|
17
|
+
* Handles HTTP operations for downloading files
|
|
18
|
+
*/
|
|
19
|
+
let HttpAdapter = class HttpAdapter {
|
|
20
|
+
/**
|
|
21
|
+
* Downloads a file from a URL
|
|
22
|
+
* @param url - URL to download from
|
|
23
|
+
* @param timeoutMs - Timeout in milliseconds (default: 30000)
|
|
24
|
+
* @returns Download result with buffer and metadata
|
|
25
|
+
*/
|
|
26
|
+
async download(url, timeoutMs = 30000) {
|
|
27
|
+
try {
|
|
28
|
+
// Derive origin for Referer header (some CDNs require it)
|
|
29
|
+
let refererHeader;
|
|
30
|
+
try {
|
|
31
|
+
refererHeader = new URL(url).origin;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
refererHeader = undefined;
|
|
35
|
+
}
|
|
36
|
+
const response = await axios_1.default.get(url, {
|
|
37
|
+
responseType: 'arraybuffer',
|
|
38
|
+
timeout: timeoutMs,
|
|
39
|
+
maxRedirects: 5,
|
|
40
|
+
headers: {
|
|
41
|
+
'User-Agent': 'Mozilla/5.0 (compatible; ImageDownloader/1.0)',
|
|
42
|
+
'Accept': 'image/*,*/*',
|
|
43
|
+
...(refererHeader ? { Referer: refererHeader } : {}),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const buffer = Buffer.from(response.data);
|
|
47
|
+
// Extract metadata from headers
|
|
48
|
+
const contentType = response.headers['content-type'] || undefined;
|
|
49
|
+
const contentLengthStr = response.headers['content-length'];
|
|
50
|
+
const contentLength = contentLengthStr ? parseInt(contentLengthStr, 10) : undefined;
|
|
51
|
+
return {
|
|
52
|
+
buffer,
|
|
53
|
+
contentType,
|
|
54
|
+
contentLength,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
59
|
+
if (error.code === 'ECONNABORTED') {
|
|
60
|
+
throw new Error(`Download timeout after ${timeoutMs}ms`);
|
|
61
|
+
}
|
|
62
|
+
if (error.response) {
|
|
63
|
+
throw new Error(`HTTP ${error.response.status}: ${error.response.statusText}`);
|
|
64
|
+
}
|
|
65
|
+
if (error.request) {
|
|
66
|
+
throw new Error(`Network error: ${error.message}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (error instanceof Error) {
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
throw new Error('Download failed: Unknown error');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
exports.HttpAdapter = HttpAdapter;
|
|
77
|
+
exports.HttpAdapter = HttpAdapter = __decorate([
|
|
78
|
+
(0, tsyringe_1.injectable)()
|
|
79
|
+
], HttpAdapter);
|
|
80
|
+
//# sourceMappingURL=http.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.adapter.js","sourceRoot":"","sources":["../../../src/infrastructure/adapters/http.adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAsC;AACtC,kDAA0B;AAG1B;;;GAGG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,CAAC,GAAW,EAAE,YAAoB,KAAK;QACnD,IAAI,CAAC;YACH,0DAA0D;YAC1D,IAAI,aAAiC,CAAC;YACtC,IAAI,CAAC;gBACH,aAAa,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;YACtC,CAAC;YAAC,MAAM,CAAC;gBACP,aAAa,GAAG,SAAS,CAAC;YAC5B,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE;gBACpC,YAAY,EAAE,aAAa;gBAC3B,OAAO,EAAE,SAAS;gBAClB,YAAY,EAAE,CAAC;gBACf,OAAO,EAAE;oBACP,YAAY,EAAE,+CAA+C;oBAC7D,QAAQ,EAAE,a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gC,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;CACF,CAAA;AA5DY,kCAAW;sBAAX,WAAW;IADvB,IAAA,qBAAU,GAAE;GACA,WAAW,CA4DvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileSystemAdapter = exports.HttpAdapter = exports.SupabaseAdapter = void 0;
|
|
4
|
+
var supabase_adapter_1 = require("./supabase.adapter");
|
|
5
|
+
Object.defineProperty(exports, "SupabaseAdapter", { enumerable: true, get: function () { return supabase_adapter_1.SupabaseAdapter; } });
|
|
6
|
+
var http_adapter_1 = require("./http.adapter");
|
|
7
|
+
Object.defineProperty(exports, "HttpAdapter", { enumerable: true, get: function () { return http_adapter_1.HttpAdapter; } });
|
|
8
|
+
var filesystem_adapter_1 = require("./filesystem.adapter");
|
|
9
|
+
Object.defineProperty(exports, "FileSystemAdapter", { enumerable: true, get: function () { return filesystem_adapter_1.FileSystemAdapter; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/adapters/index.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAAzD,mHAAA,eAAe,OAAA;AACxB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Direct PostgreSQL adapter for PGMQ operations
|
|
3
|
+
* Bypasses Supabase JS client to avoid schema cache issues
|
|
4
|
+
*/
|
|
5
|
+
export declare class PgmqAdapter {
|
|
6
|
+
private pool;
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Read a message from the queue
|
|
10
|
+
*/
|
|
11
|
+
readMessage(queueName: string, vt: number, qty?: number): Promise<any[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Delete a message from the queue
|
|
14
|
+
*/
|
|
15
|
+
deleteMessage(queueName: string, msgId: number): Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Send a message to the queue
|
|
18
|
+
*/
|
|
19
|
+
sendMessage(queueName: string, message: any): Promise<number>;
|
|
20
|
+
/**
|
|
21
|
+
* Create a queue
|
|
22
|
+
*/
|
|
23
|
+
createQueue(queueName: string): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Close the connection pool
|
|
26
|
+
*/
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=pgmq.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pgmq.adapter.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/adapters/pgmq.adapter.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBACa,WAAW;IACtB,OAAO,CAAC,IAAI,CAAO;;IAoBnB;;OAEG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,GAAE,MAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAejF;;OAEG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQvE;;OAEG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAQnE;;OAEG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PgmqAdapter = void 0;
|
|
13
|
+
const pg_1 = require("pg");
|
|
14
|
+
const tsyringe_1 = require("tsyringe");
|
|
15
|
+
/**
|
|
16
|
+
* Direct PostgreSQL adapter for PGMQ operations
|
|
17
|
+
* Bypasses Supabase JS client to avoid schema cache issues
|
|
18
|
+
*/
|
|
19
|
+
let PgmqAdapter = class PgmqAdapter {
|
|
20
|
+
pool;
|
|
21
|
+
constructor() {
|
|
22
|
+
this.pool = new pg_1.Pool({
|
|
23
|
+
connectionString: process.env.SUPABASE_DB_URL || 'postgresql://postgres:postgres@127.0.0.1:54322/postgres',
|
|
24
|
+
});
|
|
25
|
+
// Handle pool errors to prevent unhandled error events
|
|
26
|
+
this.pool.on('error', (err) => {
|
|
27
|
+
console.error('❌ Unexpected database pool error:', err.message);
|
|
28
|
+
if (err.message.includes('db_termination') || err.message.includes('shutdown')) {
|
|
29
|
+
console.error('⚠️ Database connection terminated. This usually means:');
|
|
30
|
+
console.error(' 1. Supabase project is paused (free tier auto-pauses)');
|
|
31
|
+
console.error(' 2. Connection was idle for too long');
|
|
32
|
+
console.error(' 3. Database credentials changed');
|
|
33
|
+
console.error('💡 Check your Supabase dashboard and restore the project if needed.');
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Read a message from the queue
|
|
39
|
+
*/
|
|
40
|
+
async readMessage(queueName, vt, qty = 1) {
|
|
41
|
+
try {
|
|
42
|
+
const result = await this.pool.query('SELECT * FROM pgmq.read($1, $2, $3)', [queueName, vt, qty]);
|
|
43
|
+
return result.rows;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (error instanceof Error && (error.message.includes('db_termination') || error.message.includes('shutdown'))) {
|
|
47
|
+
throw new Error('Database connection terminated. Please check if your Supabase project is paused.');
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Delete a message from the queue
|
|
54
|
+
*/
|
|
55
|
+
async deleteMessage(queueName, msgId) {
|
|
56
|
+
const result = await this.pool.query('SELECT pgmq.delete($1::text, $2::bigint) as deleted', [queueName, msgId]);
|
|
57
|
+
return result.rows[0]?.deleted === true;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Send a message to the queue
|
|
61
|
+
*/
|
|
62
|
+
async sendMessage(queueName, message) {
|
|
63
|
+
const result = await this.pool.query('SELECT pgmq.send($1, $2) as msg_id', [queueName, JSON.stringify(message)]);
|
|
64
|
+
return result.rows[0]?.msg_id;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create a queue
|
|
68
|
+
*/
|
|
69
|
+
async createQueue(queueName) {
|
|
70
|
+
await this.pool.query('SELECT pgmq.create($1)', [queueName]);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Close the connection pool
|
|
74
|
+
*/
|
|
75
|
+
async close() {
|
|
76
|
+
await this.pool.end();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
exports.PgmqAdapter = PgmqAdapter;
|
|
80
|
+
exports.PgmqAdapter = PgmqAdapter = __decorate([
|
|
81
|
+
(0, tsyringe_1.injectable)(),
|
|
82
|
+
__metadata("design:paramtypes", [])
|
|
83
|
+
], PgmqAdapter);
|
|
84
|
+
//# sourceMappingURL=pgmq.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pgmq.adapter.js","sourceRoot":"","sources":["../../../src/infrastructure/adapters/pgmq.adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAA0B;AAC1B,uCAAsC;AAEtC;;;GAGG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAW;IACd,IAAI,CAAO;IAEnB;QACE,IAAI,CAAC,IAAI,GAAG,IAAI,SAAI,CAAC;YACnB,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yDAAyD;SAC3G,CAAC,CAAC;QAEH,uDAAuD;QACvD,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YAC5B,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;YAChE,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC/E,OAAO,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;gBACzE,OAAO,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAC;gBAC1E,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;gBACxD,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;gBACpD,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CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,SAAiB;QACjC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IACxB,CAAC;CACF,CAAA;AA1EY,kCAAW;sBAAX,WAAW;IADvB,IAAA,qBAAU,GAAE;;GACA,WAAW,CA0EvB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { ISupabaseAdapter } from '../../domain/interfaces/adapters/isupabase.adapter';
|
|
3
|
+
/**
|
|
4
|
+
* Filter for database queries
|
|
5
|
+
*/
|
|
6
|
+
export interface QueryFilter {
|
|
7
|
+
column: string;
|
|
8
|
+
value: any;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Supabase Adapter
|
|
12
|
+
* Wraps Supabase client and provides abstraction for database operations
|
|
13
|
+
*/
|
|
14
|
+
export declare class SupabaseAdapter implements ISupabaseAdapter {
|
|
15
|
+
private client;
|
|
16
|
+
constructor(client: SupabaseClient);
|
|
17
|
+
/**
|
|
18
|
+
* Gets the Supabase client instance
|
|
19
|
+
* @returns SupabaseClient
|
|
20
|
+
*/
|
|
21
|
+
getClient(): SupabaseClient;
|
|
22
|
+
/**
|
|
23
|
+
* Calls a Supabase RPC function
|
|
24
|
+
* @param functionName - Name of the RPC function
|
|
25
|
+
* @param params - Function parameters
|
|
26
|
+
* @returns Function result
|
|
27
|
+
*/
|
|
28
|
+
rpc<T = any>(functionName: string, params?: Record<string, any>): Promise<T>;
|
|
29
|
+
/**
|
|
30
|
+
* Executes a raw SQL query (not implemented - use RPC instead)
|
|
31
|
+
* @param _query - SQL query to execute
|
|
32
|
+
* @param _params - Query parameters
|
|
33
|
+
* @returns Query result
|
|
34
|
+
*/
|
|
35
|
+
executeQuery<T = any>(_query: string, _params?: any[]): Promise<T[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Inserts data into a table
|
|
38
|
+
* @param tableName - Name of the table
|
|
39
|
+
* @param data - Data to insert
|
|
40
|
+
* @returns Insert result
|
|
41
|
+
*/
|
|
42
|
+
insert<T = any>(tableName: string, data: any): Promise<{
|
|
43
|
+
data: T[] | null;
|
|
44
|
+
error: any;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Updates data in a table
|
|
48
|
+
* @param tableName - Name of the table
|
|
49
|
+
* @param data - Data to update
|
|
50
|
+
* @param filter - Filter to apply
|
|
51
|
+
* @returns Update result
|
|
52
|
+
*/
|
|
53
|
+
update<T = any>(tableName: string, data: any, filter: QueryFilter): Promise<{
|
|
54
|
+
data: T[] | null;
|
|
55
|
+
error: any;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Selects data from a table
|
|
59
|
+
* @param tableName - Name of the table
|
|
60
|
+
* @param columns - Columns to select
|
|
61
|
+
* @param filter - Optional filter to apply
|
|
62
|
+
* @returns Select result
|
|
63
|
+
*/
|
|
64
|
+
select<T = any>(tableName: string, columns?: string, filter?: QueryFilter): Promise<{
|
|
65
|
+
data: T[] | null;
|
|
66
|
+
error: any;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* Deletes data from a table
|
|
70
|
+
* @param tableName - Name of the table
|
|
71
|
+
* @param filter - Filter to apply
|
|
72
|
+
* @returns Delete result
|
|
73
|
+
*/
|
|
74
|
+
delete(tableName: string, filter: QueryFilter): Promise<{
|
|
75
|
+
data: any;
|
|
76
|
+
error: any;
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=supabase.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supabase.adapter.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/adapters/supabase.adapter.ts"],"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