ztechno_core 0.0.111 → 0.0.113

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.
Files changed (40) hide show
  1. package/lib/mollie/services/invoice_service.js +29 -12
  2. package/package.json +1 -1
  3. package/lib/crypto_service.d.ts +0 -23
  4. package/lib/crypto_service.js +0 -100
  5. package/lib/engine_base.d.ts +0 -11
  6. package/lib/engine_base.js +0 -9
  7. package/lib/express.d.ts +0 -1
  8. package/lib/express.js +0 -18
  9. package/lib/mail_service.d.ts +0 -85
  10. package/lib/mail_service.js +0 -156
  11. package/lib/orm/mail_blacklist_orm.d.ts +0 -22
  12. package/lib/orm/mail_blacklist_orm.js +0 -79
  13. package/lib/orm/orm.d.ts +0 -8
  14. package/lib/orm/orm.js +0 -26
  15. package/lib/scripts/docker-build.d.ts +0 -14
  16. package/lib/scripts/docker-build.js +0 -91
  17. package/lib/scripts/docker-publish.d.ts +0 -19
  18. package/lib/scripts/docker-publish.js +0 -114
  19. package/lib/scripts/docker-push.d.ts +0 -8
  20. package/lib/scripts/docker-push.js +0 -87
  21. package/lib/scripts/docker-update.d.ts +0 -27
  22. package/lib/scripts/docker-update.js +0 -207
  23. package/lib/scripts/encrypt.d.ts +0 -1
  24. package/lib/scripts/encrypt.js +0 -4
  25. package/lib/sql_service.d.ts +0 -123
  26. package/lib/sql_service.js +0 -234
  27. package/lib/translate_service.d.ts +0 -48
  28. package/lib/translate_service.js +0 -908
  29. package/lib/typings/crypto_types.d.ts +0 -4
  30. package/lib/typings/crypto_types.js +0 -2
  31. package/lib/typings/index.d.ts +0 -4
  32. package/lib/typings/index.js +0 -36
  33. package/lib/typings/mail_types.d.ts +0 -95
  34. package/lib/typings/mail_types.js +0 -2
  35. package/lib/typings/translate_types.d.ts +0 -69
  36. package/lib/typings/translate_types.js +0 -46
  37. package/lib/typings/user_types.d.ts +0 -41
  38. package/lib/typings/user_types.js +0 -2
  39. package/lib/user_service.d.ts +0 -80
  40. package/lib/user_service.js +0 -216
@@ -1,91 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- var __importDefault =
4
- (this && this.__importDefault) ||
5
- function (mod) {
6
- return mod && mod.__esModule ? mod : { default: mod };
7
- };
8
- Object.defineProperty(exports, '__esModule', { value: true });
9
- exports.dockerBuild = void 0;
10
- const child_process_1 = require('child_process');
11
- const path_1 = __importDefault(require('path'));
12
- const fs_1 = __importDefault(require('fs'));
13
- // ANSI color helpers
14
- const red = (msg) => `\x1b[31m${msg}\x1b[0m`;
15
- const green = (msg) => `\x1b[32m${msg}\x1b[0m`;
16
- const cyan = (msg) => `\x1b[36m${msg}\x1b[0m`;
17
- function loadPackageJson() {
18
- const pkgPath = path_1.default.join(process.cwd(), 'package.json');
19
- if (!fs_1.default.existsSync(pkgPath)) {
20
- throw new Error(`No package.json found in ${process.cwd()}`);
21
- }
22
- return JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf-8'));
23
- }
24
- /**
25
- * Build a Docker image tagged as <awsAccountId>/<packagename>:latest
26
- * @param opt.packagename - Override the image name (defaults to package.json name)
27
- * @param opt.awsAccountId - Override the AWS Account ID (defaults to package.json config.awsAccountId)
28
- * @param opt.tag - Override the tag (defaults to "latest")
29
- * @param opt.context - Docker build context path (defaults to ".")
30
- */
31
- function dockerBuild(opt) {
32
- const pkg = loadPackageJson();
33
- const packagename = opt?.packagename || pkg.name;
34
- const awsAccountId = opt?.awsAccountId || pkg.config?.awsAccountId || process.env.AWS_ACCOUNT_ID;
35
- const tag = opt?.tag || 'latest';
36
- const context = opt?.context || '.';
37
- if (!packagename) {
38
- throw new Error('Missing package name. Set "name" in package.json or pass --name.');
39
- }
40
- if (!awsAccountId) {
41
- throw new Error('Missing AWS Account ID. Set "config.awsAccountId" in package.json or AWS_ACCOUNT_ID env var.');
42
- }
43
- const image = `${awsAccountId}/${packagename}:${tag}`;
44
- const cmd = `docker build -t ${image} ${context}`;
45
- console.log(green(`[Docker Build]`));
46
- console.log(cyan(`> ${cmd}`));
47
- (0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
48
- console.log(green(`✓ Built ${image}`));
49
- }
50
- exports.dockerBuild = dockerBuild;
51
- const USAGE = `
52
- Usage:
53
- ztechno-docker-build [options]
54
-
55
- Options:
56
- --name <name> Override image name (default: package.json "name")
57
- --account <id> Override AWS Account ID (default: package.json "config.awsAccountId")
58
- --tag <tag> Override tag (default: "latest")
59
- --context <path> Docker build context (default: ".")
60
- -h, --help Show this help
61
-
62
- package.json format:
63
- {
64
- "name": "my-image",
65
- "config": {
66
- "awsAccountId": "00028463827"
67
- }
68
- }
69
- `.trim();
70
- if (require.main === module) {
71
- try {
72
- const args = process.argv.slice(2);
73
- if (args.includes('--help') || args.includes('-h')) {
74
- console.log(USAGE);
75
- process.exit(0);
76
- }
77
- const getArg = (flag) => {
78
- const idx = args.indexOf(flag);
79
- return idx !== -1 && idx + 1 < args.length ? args[idx + 1] : undefined;
80
- };
81
- dockerBuild({
82
- packagename: getArg('--name'),
83
- awsAccountId: getArg('--account'),
84
- tag: getArg('--tag'),
85
- context: getArg('--context'),
86
- });
87
- } catch (err) {
88
- console.error(red(`✗ Error: ${err.message}`));
89
- process.exit(1);
90
- }
91
- }
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Run the full Docker publish pipeline: build → push → update
4
- * All options are auto-detected from package.json and .env
5
- * @param opt.packagename - Override the image name
6
- * @param opt.awsAccountId - Override the AWS Account ID
7
- * @param opt.tag - Override the tag (defaults to "latest")
8
- * @param opt.context - Docker build context path (defaults to ".")
9
- * @param opt.port - Override the port for remote update
10
- * @param opt.volumes - Override volumes for remote update
11
- */
12
- export declare function dockerPublish(opt?: {
13
- packagename?: string;
14
- awsAccountId?: string;
15
- tag?: string;
16
- context?: string;
17
- port?: string | number;
18
- volumes?: string[];
19
- }): Promise<void>;
@@ -1,114 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- var __importDefault =
4
- (this && this.__importDefault) ||
5
- function (mod) {
6
- return mod && mod.__esModule ? mod : { default: mod };
7
- };
8
- Object.defineProperty(exports, '__esModule', { value: true });
9
- exports.dockerPublish = void 0;
10
- const path_1 = __importDefault(require('path'));
11
- const fs_1 = __importDefault(require('fs'));
12
- const dotenv_1 = require('dotenv');
13
- const docker_build_1 = require('./docker-build');
14
- const docker_push_1 = require('./docker-push');
15
- const docker_update_1 = require('./docker-update');
16
- // ANSI color helpers
17
- const red = (msg) => `\x1b[31m${msg}\x1b[0m`;
18
- const green = (msg) => `\x1b[32m${msg}\x1b[0m`;
19
- const cyan = (msg) => `\x1b[36m${msg}\x1b[0m`;
20
- function loadPackageJson() {
21
- const pkgPath = path_1.default.join(process.cwd(), 'package.json');
22
- if (!fs_1.default.existsSync(pkgPath)) {
23
- throw new Error(`No package.json found in ${process.cwd()}`);
24
- }
25
- return JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf-8'));
26
- }
27
- /**
28
- * Run the full Docker publish pipeline: build → push → update
29
- * All options are auto-detected from package.json and .env
30
- * @param opt.packagename - Override the image name
31
- * @param opt.awsAccountId - Override the AWS Account ID
32
- * @param opt.tag - Override the tag (defaults to "latest")
33
- * @param opt.context - Docker build context path (defaults to ".")
34
- * @param opt.port - Override the port for remote update
35
- * @param opt.volumes - Override volumes for remote update
36
- */
37
- async function dockerPublish(opt) {
38
- // Load .env so ZTECHNO_API_SECRET (and other vars) are available
39
- (0, dotenv_1.config)({ path: path_1.default.join(process.cwd(), '.env') });
40
- const pkg = loadPackageJson();
41
- const packagename = opt?.packagename || pkg.name;
42
- const awsAccountId = opt?.awsAccountId || pkg.config?.awsAccountId || process.env.AWS_ACCOUNT_ID;
43
- const tag = opt?.tag || 'latest';
44
- console.log(cyan(`\n[Docker Publish Pipeline]`));
45
- console.log(cyan(` Image: ${awsAccountId}/${packagename}:${tag}\n`));
46
- // Step 1: Build
47
- console.log(cyan(`── Step 1/3: Build ──`));
48
- (0, docker_build_1.dockerBuild)({ packagename, awsAccountId, tag, context: opt?.context });
49
- // Step 2: Push
50
- console.log(cyan(`\n── Step 2/3: Push ──`));
51
- (0, docker_push_1.dockerPush)({ packagename, awsAccountId, tag });
52
- // Step 3: Update remote
53
- console.log(cyan(`\n── Step 3/3: Update Remote ──`));
54
- const port = opt?.port || pkg.config?.port;
55
- let volumes = opt?.volumes;
56
- if (!volumes && pkg.config?.volumes) {
57
- volumes = Array.isArray(pkg.config.volumes) ? pkg.config.volumes : pkg.config.volumes.split(',').filter(Boolean);
58
- }
59
- if (!port) {
60
- console.log(green(`✓ Build & push complete. Skipping remote update (no port configured).`));
61
- return;
62
- }
63
- await (0, docker_update_1.updateDocker)({
64
- packagename: packagename,
65
- port,
66
- volumes,
67
- c: console,
68
- });
69
- console.log(green(`\n✓ Publish pipeline complete!`));
70
- }
71
- exports.dockerPublish = dockerPublish;
72
- const USAGE = `
73
- Usage:
74
- ztechno-docker-publish [options]
75
-
76
- Runs: docker build → docker push → remote update
77
-
78
- Options:
79
- --name <name> Override image name (default: package.json "name")
80
- --account <id> Override AWS Account ID (default: package.json "config.awsAccountId")
81
- --tag <tag> Override tag (default: "latest")
82
- --context <path> Docker build context (default: ".")
83
- -h, --help Show this help
84
-
85
- package.json format:
86
- {
87
- "name": "my-image",
88
- "config": {
89
- "awsAccountId": "00028463827",
90
- "port": 3000,
91
- "volumes": ["/data:/app/data"]
92
- }
93
- }
94
- `.trim();
95
- if (require.main === module) {
96
- const args = process.argv.slice(2);
97
- if (args.includes('--help') || args.includes('-h')) {
98
- console.log(USAGE);
99
- process.exit(0);
100
- }
101
- const getArg = (flag) => {
102
- const idx = args.indexOf(flag);
103
- return idx !== -1 && idx + 1 < args.length ? args[idx + 1] : undefined;
104
- };
105
- dockerPublish({
106
- packagename: getArg('--name'),
107
- awsAccountId: getArg('--account'),
108
- tag: getArg('--tag'),
109
- context: getArg('--context'),
110
- }).catch((err) => {
111
- console.error(red(`✗ Error: ${err.message}`));
112
- process.exit(1);
113
- });
114
- }
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Push a Docker image tagged as <awsAccountId>/<packagename>:latest
4
- * @param opt.packagename - Override the image name (defaults to package.json name)
5
- * @param opt.awsAccountId - Override the AWS Account ID (defaults to package.json config.awsAccountId)
6
- * @param opt.tag - Override the tag (defaults to "latest")
7
- */
8
- export declare function dockerPush(opt?: { packagename?: string; awsAccountId?: string; tag?: string }): void;
@@ -1,87 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- var __importDefault =
4
- (this && this.__importDefault) ||
5
- function (mod) {
6
- return mod && mod.__esModule ? mod : { default: mod };
7
- };
8
- Object.defineProperty(exports, '__esModule', { value: true });
9
- exports.dockerPush = void 0;
10
- const child_process_1 = require('child_process');
11
- const path_1 = __importDefault(require('path'));
12
- const fs_1 = __importDefault(require('fs'));
13
- // ANSI color helpers
14
- const red = (msg) => `\x1b[31m${msg}\x1b[0m`;
15
- const green = (msg) => `\x1b[32m${msg}\x1b[0m`;
16
- const cyan = (msg) => `\x1b[36m${msg}\x1b[0m`;
17
- function loadPackageJson() {
18
- const pkgPath = path_1.default.join(process.cwd(), 'package.json');
19
- if (!fs_1.default.existsSync(pkgPath)) {
20
- throw new Error(`No package.json found in ${process.cwd()}`);
21
- }
22
- return JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf-8'));
23
- }
24
- /**
25
- * Push a Docker image tagged as <awsAccountId>/<packagename>:latest
26
- * @param opt.packagename - Override the image name (defaults to package.json name)
27
- * @param opt.awsAccountId - Override the AWS Account ID (defaults to package.json config.awsAccountId)
28
- * @param opt.tag - Override the tag (defaults to "latest")
29
- */
30
- function dockerPush(opt) {
31
- const pkg = loadPackageJson();
32
- const packagename = opt?.packagename || pkg.name;
33
- const awsAccountId = opt?.awsAccountId || pkg.config?.awsAccountId || process.env.AWS_ACCOUNT_ID;
34
- const tag = opt?.tag || 'latest';
35
- if (!packagename) {
36
- throw new Error('Missing package name. Set "name" in package.json or pass --name.');
37
- }
38
- if (!awsAccountId) {
39
- throw new Error('Missing AWS Account ID. Set "config.awsAccountId" in package.json or AWS_ACCOUNT_ID env var.');
40
- }
41
- const image = `${awsAccountId}/${packagename}:${tag}`;
42
- const cmd = `docker push ${image}`;
43
- console.log(green(`[Docker Push]`));
44
- console.log(cyan(`> ${cmd}`));
45
- (0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
46
- console.log(green(`✓ Pushed ${image}`));
47
- }
48
- exports.dockerPush = dockerPush;
49
- const USAGE = `
50
- Usage:
51
- ztechno-docker-push [options]
52
-
53
- Options:
54
- --name <name> Override image name (default: package.json "name")
55
- --account <id> Override AWS Account ID (default: package.json "config.awsAccountId")
56
- --tag <tag> Override tag (default: "latest")
57
- -h, --help Show this help
58
-
59
- package.json format:
60
- {
61
- "name": "my-image",
62
- "config": {
63
- "awsAccountId": "00028463827"
64
- }
65
- }
66
- `.trim();
67
- if (require.main === module) {
68
- try {
69
- const args = process.argv.slice(2);
70
- if (args.includes('--help') || args.includes('-h')) {
71
- console.log(USAGE);
72
- process.exit(0);
73
- }
74
- const getArg = (flag) => {
75
- const idx = args.indexOf(flag);
76
- return idx !== -1 && idx + 1 < args.length ? args[idx + 1] : undefined;
77
- };
78
- dockerPush({
79
- packagename: getArg('--name'),
80
- awsAccountId: getArg('--account'),
81
- tag: getArg('--tag'),
82
- });
83
- } catch (err) {
84
- console.error(red(`✗ Error: ${err.message}`));
85
- process.exit(1);
86
- }
87
- }
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
- export interface DockerUpdateOptions {
3
- /** The package/image name */
4
- packagename: string;
5
- /** The port number */
6
- port: string | number;
7
- /** Optional array of volume mappings */
8
- volumes?: string[];
9
- /** Optional logger (defaults to silent) */
10
- c?: {
11
- log: (...args: any[]) => void;
12
- error: (...args: any[]) => void;
13
- };
14
- /** Request timeout in ms (default: 30000) */
15
- timeout?: number;
16
- }
17
- export interface DockerUpdateResult {
18
- success: boolean;
19
- message?: string;
20
- err?: string;
21
- }
22
- /**
23
- * Update a remote Docker container via the V2 Secure API
24
- * @param opt - Update options
25
- * @returns Promise resolving to success status and message
26
- */
27
- export declare function updateDocker(opt: DockerUpdateOptions): Promise<DockerUpdateResult>;
@@ -1,207 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- var __importDefault =
4
- (this && this.__importDefault) ||
5
- function (mod) {
6
- return mod && mod.__esModule ? mod : { default: mod };
7
- };
8
- Object.defineProperty(exports, '__esModule', { value: true });
9
- exports.updateDocker = void 0;
10
- const http_1 = __importDefault(require('http'));
11
- const crypto_1 = __importDefault(require('crypto'));
12
- const path_1 = __importDefault(require('path'));
13
- const fs_1 = __importDefault(require('fs'));
14
- const dotenv_1 = require('dotenv');
15
- const crypto_service_1 = require('../crypto_service');
16
- // ANSI color helpers
17
- const red = (msg) => `\x1b[31m${msg}\x1b[0m`;
18
- const green = (msg) => `\x1b[32m${msg}\x1b[0m`;
19
- const cyan = (msg) => `\x1b[36m${msg}\x1b[0m`;
20
- const blue = (msg) => `\x1b[34m${msg}\x1b[0m`;
21
- /** Default request timeout in milliseconds (30 seconds) */
22
- const REQUEST_TIMEOUT_MS = 30000;
23
- /**
24
- * Update a remote Docker container via the V2 Secure API
25
- * @param opt - Update options
26
- * @returns Promise resolving to success status and message
27
- */
28
- function updateDocker(opt) {
29
- return new Promise((resolve, reject) => {
30
- const { packagename, port, volumes, c, timeout = REQUEST_TIMEOUT_MS } = opt;
31
- const secretKey = process.env.ZTECHNO_API_SECRET;
32
- if (!secretKey) {
33
- c?.log(red('✗ Error: ZTECHNO_API_SECRET environment variable not set'));
34
- return reject(new Error('ZTECHNO_API_SECRET environment variable not set'));
35
- }
36
- // Generate timestamp and HMAC signature
37
- const timestamp = Date.now().toString();
38
- const volumesString = volumes && volumes.length > 0 ? volumes.join(',') : '';
39
- const payload = timestamp + packagename + port + volumesString;
40
- const signature = crypto_1.default.createHmac('sha256', secretKey).update(payload).digest('hex');
41
- c?.log(green(`[Updating Remote Docker via V2 Secure API]`));
42
- // Build query parameters with proper encoding
43
- const query = new URLSearchParams({ port: String(port) });
44
- if (volumesString) {
45
- query.set('volumes', volumesString);
46
- }
47
- const options = {
48
- hostname: crypto_service_1.ZCryptoService.decrypt({
49
- iv: '00d1df14932d0e6b5d064cceb037f586',
50
- encryptedData: '05b9d826539fe2cbdf7d7ecccfe57635',
51
- }),
52
- port: 7998,
53
- path: `/v2/images/${encodeURIComponent(packagename)}/update?${query}`,
54
- method: 'GET',
55
- timeout,
56
- headers: {
57
- 'x-timestamp': timestamp,
58
- 'x-signature': signature,
59
- },
60
- };
61
- const req = http_1.default.request(options, (res) => {
62
- let data = '';
63
- res.on('data', (chunk) => {
64
- data += chunk;
65
- });
66
- res.on('end', () => {
67
- try {
68
- const response = JSON.parse(data);
69
- c?.log(cyan(`Status Code: ${res.statusCode}`));
70
- c?.log(blue(`Response: ${JSON.stringify(response, null, 2)}`));
71
- if (response.success) {
72
- c?.log(green(`✓ ${response.message}`));
73
- } else {
74
- c?.log(red(`✗ Error: ${response.err}`));
75
- }
76
- resolve(response);
77
- } catch (err) {
78
- c?.log(red(`Failed to parse response: ${data}`));
79
- c?.error(err);
80
- reject(err);
81
- }
82
- });
83
- });
84
- req.on('timeout', () => {
85
- req.destroy();
86
- const err = new Error(`Request timed out after ${timeout}ms`);
87
- c?.log(red(`✗ ${err.message}`));
88
- reject(err);
89
- });
90
- req.on('error', (err) => {
91
- c?.log(red(`✗ Request failed: ${err.message}`));
92
- reject(err);
93
- });
94
- req.end();
95
- });
96
- }
97
- exports.updateDocker = updateDocker;
98
- /**
99
- * Read the consumer's package.json from the current working directory.
100
- * Returns null if not found or unreadable.
101
- */
102
- function loadPackageJson() {
103
- try {
104
- const pkgPath = path_1.default.join(process.cwd(), 'package.json');
105
- if (!fs_1.default.existsSync(pkgPath)) return null;
106
- return JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf-8'));
107
- } catch {
108
- return null;
109
- }
110
- }
111
- /**
112
- * Auto-detect options from .env and/or package.json in the current working directory.
113
- *
114
- * Resolution order for each field:
115
- * 1. .env / environment variable
116
- * 2. package.json (name → packagename, config.port → port, config.volumes → volumes)
117
- *
118
- * Required: packagename, port, ZTECHNO_API_SECRET (env only)
119
- * Optional: volumes (comma-separated)
120
- */
121
- function loadOptionsFromEnv() {
122
- // Load .env file
123
- const envPath = path_1.default.join(process.cwd(), '.env');
124
- const cfg = (0, dotenv_1.config)({ path: envPath });
125
- if (cfg.error && cfg.error.message && !cfg.error.message.includes('ENOENT')) {
126
- throw cfg.error;
127
- }
128
- // Load package.json as fallback
129
- const pkg = loadPackageJson();
130
- const packagename = cfg.parsed?.packagename || process.env.packagename || pkg?.name;
131
- const port =
132
- cfg.parsed?.port || process.env.port || (pkg?.config?.port != null ? String(pkg.config.port) : undefined);
133
- const volumesRaw = cfg.parsed?.volumes || process.env.volumes || pkg?.config?.volumes;
134
- if (pkg) {
135
- console.log(`Detected package.json: ${pkg.name || '(unnamed)'}`);
136
- }
137
- if (!packagename) {
138
- throw new Error('Missing packagename. Set it in .env, environment, or package.json "name".');
139
- }
140
- if (!port) {
141
- throw new Error('Missing port. Set it in .env, environment, or package.json "config.port".');
142
- }
143
- // Normalize volumes: accept string[] from package.json or comma-separated string from .env
144
- let volumes;
145
- if (Array.isArray(volumesRaw)) {
146
- volumes = volumesRaw.filter(Boolean);
147
- } else if (typeof volumesRaw === 'string') {
148
- volumes = volumesRaw.split(',').filter(Boolean);
149
- }
150
- return { packagename, port, volumes };
151
- }
152
- const USAGE = `
153
- Usage:
154
- ztechno-docker-update <packagename>:<port>
155
- ztechno-docker-update (auto-detect from .env / package.json)
156
-
157
- Auto-detection priority:
158
- 1. .env file → packagename, port, volumes, ZTECHNO_API_SECRET
159
- 2. package.json → "name" as packagename, "config.port", "config.volumes"
160
-
161
- .env file format:
162
- ZTECHNO_API_SECRET=your_secret
163
- packagename=my-image
164
- port=3000
165
- volumes=/host/path:/container/path (optional, comma-separated)
166
-
167
- package.json format:
168
- {
169
- "name": "my-image",
170
- "config": {
171
- "port": 3000,
172
- "volumes": ["/host/path:/container/path", "/logs:/app/logs"]
173
- }
174
- }
175
- `.trim();
176
- // Run if executed directly (node docker-update.js or npx ztechno-docker-update)
177
- if (require.main === module) {
178
- const main = async () => {
179
- const arg = process.argv[2];
180
- if (arg === '--help' || arg === '-h') {
181
- console.log(USAGE);
182
- return;
183
- }
184
- // No argument: load from .env
185
- if (arg === undefined) {
186
- const { packagename, port, volumes } = loadOptionsFromEnv();
187
- await updateDocker({ packagename, port, volumes, c: console });
188
- return;
189
- }
190
- // Argument with colon: packagename:port
191
- if (arg.includes(':')) {
192
- const [packagename, port] = arg.split(':');
193
- if (!packagename || !port) {
194
- throw new Error(`Invalid argument "${arg}". Expected format: <packagename>:<port>`);
195
- }
196
- await updateDocker({ packagename, port, c: console });
197
- return;
198
- }
199
- console.error(red(`✗ Invalid argument: "${arg}"`));
200
- console.log(USAGE);
201
- process.exit(1);
202
- };
203
- main().catch((err) => {
204
- console.error(red(`✗ Error: ${err.message}`));
205
- process.exit(1);
206
- });
207
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- const crypto_service_1 = require('../crypto_service');
4
- console.log(crypto_service_1.ZCryptoService.encrypt('...'));
@@ -1,123 +0,0 @@
1
- import * as mysql from 'mysql';
2
- type ZOnErrorCallback = (err: mysql.MysqlError) => any;
3
- type ZOnLogCallback = (log: string) => any;
4
- export type ZSQLOptions = mysql.PoolConfig & {
5
- dateStringTimezone?: string;
6
- parseBooleans?: boolean;
7
- };
8
- export declare class ZSQLService {
9
- private options;
10
- private pool;
11
- private defaultPoolconfig;
12
- private listeners;
13
- private databaseName;
14
- get database(): string;
15
- /**
16
- * Creates a new ZSQLService instance with a MySQL connection pool.
17
- * @param options - MySQL pool configuration options including custom dateStringTimezone and parseBooleans settings
18
- */
19
- constructor(options: ZSQLOptions);
20
- /**
21
- * Registers an event listener for database errors or logs.
22
- * @param eventName - The event type to listen for ('err' or 'log')
23
- * @param listener - The callback function to execute when the event occurs
24
- * @throws Error if the event name is not supported
25
- */
26
- on(eventName: 'err', listener: ZOnErrorCallback): void;
27
- on(eventName: 'log', listener: ZOnLogCallback): void;
28
- private triggerEvent;
29
- private getPoolConnection;
30
- /**
31
- * Executes a SQL query with automatic type conversion for dates and booleans.
32
- * Converts TINYINT(1) columns to booleans if parseBooleans option is enabled.
33
- * Converts date strings to Date objects if dateStringTimezone option is set.
34
- * @template T - The expected result type
35
- * @param opt - Query options containing the SQL query string and optional parameters
36
- * @param opt.query - The SQL query string to execute
37
- * @param opt.params - Optional query parameters (array for positional, object for named parameters)
38
- * @returns Promise resolving to query results with type conversions applied
39
- */
40
- exec(opt: {
41
- query: string;
42
- params?:
43
- | any[]
44
- | {
45
- [key: string]: any;
46
- };
47
- }): Promise<{
48
- insertId: number;
49
- affectedRows: number;
50
- }>;
51
- exec<T = any>(opt: {
52
- query: string;
53
- params?:
54
- | any[]
55
- | {
56
- [key: string]: any;
57
- };
58
- }): Promise<T[]>;
59
- /**
60
- * Legacy method to execute a SQL query. Uses uppercase property names for backwards compatibility.
61
- * Applies date and boolean conversions if configured. Consider using exec() directly for new code.
62
- * @template T - The expected result type
63
- * @param opt - Query options
64
- * @param opt.Query - The SQL query string to execute
65
- * @param opt.Params - Named parameters for the query
66
- * @returns Promise resolving to query results
67
- */
68
- fetch<T = any>(opt: {
69
- Query: string;
70
- Params:
71
- | {
72
- [key: string]: any;
73
- }
74
- | any[];
75
- }): Promise<T[]>;
76
- fetch<T = any>(
77
- query: string,
78
- params:
79
- | {
80
- [key: string]: any;
81
- }
82
- | any[],
83
- ): Promise<T[]>;
84
- /**
85
- * Executes a SQL query without type conversions.
86
- * Supports both positional (array) and named (object) parameters.
87
- * @template T - The expected result type
88
- * @param sql - The SQL query string to execute
89
- * @param params - Optional query parameters (array for positional with ?, object for named with :key)
90
- * @returns Promise resolving to query results or insert/update metadata
91
- */
92
- query(
93
- sql: string,
94
- params?:
95
- | any[]
96
- | {
97
- [key: string]: any;
98
- },
99
- ): Promise<{
100
- insertId: number;
101
- affectedRows: number;
102
- }>;
103
- query<T = any>(
104
- sql: string,
105
- params?:
106
- | any[]
107
- | {
108
- [key: string]: any;
109
- },
110
- ): Promise<T[]>;
111
- private queryWithFields;
112
- private formatQueryParams;
113
- private isSqlDate;
114
- /**
115
- * Changes the active database by closing the current connection pool and creating a new one.
116
- * All active connections will be gracefully closed before switching.
117
- * @param newDatabase - The name of the database to switch to
118
- * @returns Promise that resolves when the database has been changed successfully
119
- * @throws Error if the pool cannot be closed or new pool cannot be created
120
- */
121
- changeDatabase(newDatabase: string): Promise<void>;
122
- }
123
- export {};