@zintrust/workers 0.5.2 → 0.5.3
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/README.md +2 -0
- package/dist/telemetry/routes/dashboard.js +2 -0
- package/dist/ui/BrandFavicon.d.ts +4 -0
- package/dist/ui/BrandFavicon.js +33 -0
- package/dist/ui/router/ui.js +6 -3
- package/package.json +2 -2
- package/src/telemetry/routes/dashboard.ts +2 -0
- package/src/ui/BrandFavicon.ts +36 -0
- package/src/ui/router/ui.ts +6 -3
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Enterprise-grade worker management system for ZinTrust framework. Provides comprehensive background job processing, monitoring, resilience, and orchestration capabilities.
|
|
4
4
|
|
|
5
|
+
Docs: https://zintrust.com/package-workers
|
|
6
|
+
|
|
5
7
|
[](https://www.npmjs.com/package/@zintrust/workers)
|
|
6
8
|
[](https://opensource.org/licenses/MIT)
|
|
7
9
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BrandFavicon } from '../../ui/BrandFavicon.js';
|
|
1
2
|
import { renderAlertPanel } from '../components/AlertPanel.js';
|
|
2
3
|
import { renderCostTracking } from '../components/CostTracking.js';
|
|
3
4
|
import { renderResourceUsageChart } from '../components/ResourceUsageChart.js';
|
|
@@ -144,6 +145,7 @@ const getDashboardHead = (appName) => `
|
|
|
144
145
|
<meta charset="UTF-8" />
|
|
145
146
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
146
147
|
<title>ZinTrust ${appName}'s Telemetry Dashboard</title>
|
|
148
|
+
<link rel="icon" type="image/svg+xml" href="${BrandFavicon.forTelemetry()}" />
|
|
147
149
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
148
150
|
${getDashboardStyles()}
|
|
149
151
|
</head>`;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const encodeSvgDataUri = (svg) => {
|
|
2
|
+
return `data:image/svg+xml,${encodeURIComponent(svg.replaceAll(/\s+/g, ' ').trim())}`;
|
|
3
|
+
};
|
|
4
|
+
const buildBrandFavicon = (kind) => {
|
|
5
|
+
if (kind === 'telemetry') {
|
|
6
|
+
return encodeSvgDataUri(`
|
|
7
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="none">
|
|
8
|
+
<rect width="256" height="256" rx="56" fill="#0f172a"/>
|
|
9
|
+
<path d="M48 200 L208 200" stroke="#1e293b" stroke-width="12" stroke-linecap="round"/>
|
|
10
|
+
<path d="M48 180 Q80 120, 128 150 T208 80 L208 200 L48 200 Z" fill="#0ea5e9" opacity="0.4"/>
|
|
11
|
+
<path d="M48 180 Q80 120, 128 150 T208 80" stroke="#0ea5e9" stroke-width="16" stroke-linecap="round"/>
|
|
12
|
+
<circle cx="208" cy="80" r="12" fill="#22c55e"/>
|
|
13
|
+
</svg>
|
|
14
|
+
`);
|
|
15
|
+
}
|
|
16
|
+
return encodeSvgDataUri(`
|
|
17
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="none">
|
|
18
|
+
<rect width="256" height="256" rx="56" fill="#0f172a"/>
|
|
19
|
+
<path d="M128 56 L200 96 L128 136 L56 96 Z" fill="#0ea5e9" opacity="0.2" stroke="#0ea5e9" stroke-width="4" stroke-linejoin="round"/>
|
|
20
|
+
<path d="M128 104 L200 144 L128 184 L56 144 Z" fill="#0ea5e9" opacity="0.4" stroke="#0ea5e9" stroke-width="4" stroke-linejoin="round"/>
|
|
21
|
+
<path d="M128 152 L200 192 L128 232 L56 192 Z" fill="#1e293b" stroke="#22c55e" stroke-width="6" stroke-linejoin="round"/>
|
|
22
|
+
<circle cx="128" cy="192" r="8" fill="#22c55e"/>
|
|
23
|
+
</svg>
|
|
24
|
+
`);
|
|
25
|
+
};
|
|
26
|
+
export const BrandFavicon = Object.freeze({
|
|
27
|
+
forWorkersUi() {
|
|
28
|
+
return buildBrandFavicon('workers');
|
|
29
|
+
},
|
|
30
|
+
forTelemetry() {
|
|
31
|
+
return buildBrandFavicon('telemetry');
|
|
32
|
+
},
|
|
33
|
+
});
|
package/dist/ui/router/ui.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Cloudflare, Env, ErrorFactory, Logger, MIME_TYPES, NodeSingletons, Router, } from '@zintrust/core';
|
|
2
|
+
import { BrandFavicon } from '../BrandFavicon.js';
|
|
2
3
|
import { INDEX_HTML, MAIN_JS, STYLES_CSS, ZINTRUST_SVG } from './EmbeddedAssets.js';
|
|
3
4
|
const isCloudflare = (() => {
|
|
4
5
|
try {
|
|
@@ -34,7 +35,7 @@ const fetchAssetText = async (assetPath) => {
|
|
|
34
35
|
const assets = getAssetsBinding();
|
|
35
36
|
if (!assets)
|
|
36
37
|
return '';
|
|
37
|
-
const url = new URL(assetPath, 'http://assets');
|
|
38
|
+
const url = new URL(assetPath, 'http://assets'); //NOSONAR
|
|
38
39
|
const response = await assets.fetch(url);
|
|
39
40
|
if (!response.ok)
|
|
40
41
|
return '';
|
|
@@ -44,7 +45,7 @@ const fetchAssetBytes = async (assetPath) => {
|
|
|
44
45
|
const assets = getAssetsBinding();
|
|
45
46
|
if (!assets)
|
|
46
47
|
return null;
|
|
47
|
-
const url = new URL(assetPath, 'http://assets');
|
|
48
|
+
const url = new URL(assetPath, 'http://assets'); //NOSONAR
|
|
48
49
|
const response = await assets.fetch(url);
|
|
49
50
|
if (!response.ok)
|
|
50
51
|
return null;
|
|
@@ -61,9 +62,11 @@ const escapeHtml = (value) => {
|
|
|
61
62
|
};
|
|
62
63
|
const injectIndexAppName = (html) => {
|
|
63
64
|
const appName = Env.get('APP_NAME', 'ZinTrust').trim() || 'ZinTrust';
|
|
65
|
+
const faviconLink = `<link rel="icon" type="image/svg+xml" href="${BrandFavicon.forWorkersUi()}" />`;
|
|
64
66
|
return html
|
|
65
67
|
.replaceAll('__ZINTRUST_WORKERS_TITLE__', escapeHtml(`ZinTrust ${appName} Workers Dashboard`))
|
|
66
|
-
.replaceAll('__ZINTRUST_WORKERS_HEADING__', escapeHtml(`ZinTrust ${appName}'s Workers`))
|
|
68
|
+
.replaceAll('__ZINTRUST_WORKERS_HEADING__', escapeHtml(`ZinTrust ${appName}'s Workers`))
|
|
69
|
+
.replace('</head>', ` ${faviconLink}\n </head>`);
|
|
67
70
|
};
|
|
68
71
|
const resolveEmbeddedAssetText = (assetPath) => {
|
|
69
72
|
const normalizedPath = assetPath.replace(/^\//, '');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/workers",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Worker orchestration and background job management for ZinTrust.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -73,4 +73,4 @@
|
|
|
73
73
|
"prom-client": "^15.1.3",
|
|
74
74
|
"simple-statistics": "^7.8.9"
|
|
75
75
|
}
|
|
76
|
-
}
|
|
76
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BrandFavicon } from '../../ui/BrandFavicon';
|
|
1
2
|
import { renderAlertPanel } from '../components/AlertPanel';
|
|
2
3
|
import { renderCostTracking } from '../components/CostTracking';
|
|
3
4
|
import { renderResourceUsageChart } from '../components/ResourceUsageChart';
|
|
@@ -158,6 +159,7 @@ const getDashboardHead = (appName: string): string => `
|
|
|
158
159
|
<meta charset="UTF-8" />
|
|
159
160
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
160
161
|
<title>ZinTrust ${appName}'s Telemetry Dashboard</title>
|
|
162
|
+
<link rel="icon" type="image/svg+xml" href="${BrandFavicon.forTelemetry()}" />
|
|
161
163
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
162
164
|
${getDashboardStyles()}
|
|
163
165
|
</head>`;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const encodeSvgDataUri = (svg: string): string => {
|
|
2
|
+
return `data:image/svg+xml,${encodeURIComponent(svg.replaceAll(/\s+/g, ' ').trim())}`;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
const buildBrandFavicon = (kind: 'workers' | 'telemetry'): string => {
|
|
6
|
+
if (kind === 'telemetry') {
|
|
7
|
+
return encodeSvgDataUri(`
|
|
8
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="none">
|
|
9
|
+
<rect width="256" height="256" rx="56" fill="#0f172a"/>
|
|
10
|
+
<path d="M48 200 L208 200" stroke="#1e293b" stroke-width="12" stroke-linecap="round"/>
|
|
11
|
+
<path d="M48 180 Q80 120, 128 150 T208 80 L208 200 L48 200 Z" fill="#0ea5e9" opacity="0.4"/>
|
|
12
|
+
<path d="M48 180 Q80 120, 128 150 T208 80" stroke="#0ea5e9" stroke-width="16" stroke-linecap="round"/>
|
|
13
|
+
<circle cx="208" cy="80" r="12" fill="#22c55e"/>
|
|
14
|
+
</svg>
|
|
15
|
+
`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return encodeSvgDataUri(`
|
|
19
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="none">
|
|
20
|
+
<rect width="256" height="256" rx="56" fill="#0f172a"/>
|
|
21
|
+
<path d="M128 56 L200 96 L128 136 L56 96 Z" fill="#0ea5e9" opacity="0.2" stroke="#0ea5e9" stroke-width="4" stroke-linejoin="round"/>
|
|
22
|
+
<path d="M128 104 L200 144 L128 184 L56 144 Z" fill="#0ea5e9" opacity="0.4" stroke="#0ea5e9" stroke-width="4" stroke-linejoin="round"/>
|
|
23
|
+
<path d="M128 152 L200 192 L128 232 L56 192 Z" fill="#1e293b" stroke="#22c55e" stroke-width="6" stroke-linejoin="round"/>
|
|
24
|
+
<circle cx="128" cy="192" r="8" fill="#22c55e"/>
|
|
25
|
+
</svg>
|
|
26
|
+
`);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const BrandFavicon = Object.freeze({
|
|
30
|
+
forWorkersUi(): string {
|
|
31
|
+
return buildBrandFavicon('workers');
|
|
32
|
+
},
|
|
33
|
+
forTelemetry(): string {
|
|
34
|
+
return buildBrandFavicon('telemetry');
|
|
35
|
+
},
|
|
36
|
+
});
|
package/src/ui/router/ui.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
NodeSingletons,
|
|
9
9
|
Router,
|
|
10
10
|
} from '@zintrust/core';
|
|
11
|
+
import { BrandFavicon } from '../BrandFavicon';
|
|
11
12
|
import { INDEX_HTML, MAIN_JS, STYLES_CSS, ZINTRUST_SVG } from './EmbeddedAssets';
|
|
12
13
|
|
|
13
14
|
const isCloudflare = ((): boolean => {
|
|
@@ -42,7 +43,7 @@ const getAssetsBinding = (): AssetsBinding | null => Cloudflare.getAssetsBinding
|
|
|
42
43
|
const fetchAssetText = async (assetPath: string): Promise<string> => {
|
|
43
44
|
const assets = getAssetsBinding();
|
|
44
45
|
if (!assets) return '';
|
|
45
|
-
const url = new URL(assetPath, 'http://assets');
|
|
46
|
+
const url = new URL(assetPath, 'http://assets'); //NOSONAR
|
|
46
47
|
const response = await assets.fetch(url);
|
|
47
48
|
if (!response.ok) return '';
|
|
48
49
|
return response.text();
|
|
@@ -51,7 +52,7 @@ const fetchAssetText = async (assetPath: string): Promise<string> => {
|
|
|
51
52
|
const fetchAssetBytes = async (assetPath: string): Promise<Uint8Array | null> => {
|
|
52
53
|
const assets = getAssetsBinding();
|
|
53
54
|
if (!assets) return null;
|
|
54
|
-
const url = new URL(assetPath, 'http://assets');
|
|
55
|
+
const url = new URL(assetPath, 'http://assets'); //NOSONAR
|
|
55
56
|
const response = await assets.fetch(url);
|
|
56
57
|
if (!response.ok) return null;
|
|
57
58
|
const buffer = await response.arrayBuffer();
|
|
@@ -69,10 +70,12 @@ const escapeHtml = (value: string): string => {
|
|
|
69
70
|
|
|
70
71
|
const injectIndexAppName = (html: string): string => {
|
|
71
72
|
const appName = Env.get('APP_NAME', 'ZinTrust').trim() || 'ZinTrust';
|
|
73
|
+
const faviconLink = `<link rel="icon" type="image/svg+xml" href="${BrandFavicon.forWorkersUi()}" />`;
|
|
72
74
|
|
|
73
75
|
return html
|
|
74
76
|
.replaceAll('__ZINTRUST_WORKERS_TITLE__', escapeHtml(`ZinTrust ${appName} Workers Dashboard`))
|
|
75
|
-
.replaceAll('__ZINTRUST_WORKERS_HEADING__', escapeHtml(`ZinTrust ${appName}'s Workers`))
|
|
77
|
+
.replaceAll('__ZINTRUST_WORKERS_HEADING__', escapeHtml(`ZinTrust ${appName}'s Workers`))
|
|
78
|
+
.replace('</head>', ` ${faviconLink}\n </head>`);
|
|
76
79
|
};
|
|
77
80
|
|
|
78
81
|
const resolveEmbeddedAssetText = (assetPath: string): string | null => {
|