@jini-ai/devops 0.4.0 → 0.5.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/README.md +62 -2
  3. package/dist/agent-jobs/entry.d.ts +4 -0
  4. package/dist/agent-jobs/entry.js +4 -0
  5. package/dist/agent-jobs/jobs.d.ts +25 -0
  6. package/dist/agent-jobs/jobs.js +115 -0
  7. package/dist/agent-jobs/node.d.ts +12 -0
  8. package/dist/agent-jobs/node.js +53 -0
  9. package/dist/agent-jobs/ports.d.ts +69 -0
  10. package/dist/agent-jobs/ports.js +2 -0
  11. package/dist/checks/coverage/diff.d.ts +57 -0
  12. package/dist/checks/coverage/diff.js +48 -0
  13. package/dist/checks/coverage/disk.d.ts +65 -0
  14. package/dist/checks/coverage/disk.js +136 -0
  15. package/dist/checks/coverage/floors.d.ts +31 -0
  16. package/dist/checks/coverage/floors.js +24 -0
  17. package/dist/checks/coverage/index.d.ts +7 -0
  18. package/dist/checks/coverage/index.js +6 -0
  19. package/dist/checks/coverage/integrity.d.ts +79 -0
  20. package/dist/checks/coverage/integrity.js +140 -0
  21. package/dist/checks/coverage/lcov.d.ts +65 -0
  22. package/dist/checks/coverage/lcov.js +64 -0
  23. package/dist/checks/node.d.ts +19 -0
  24. package/dist/checks/node.js +40 -0
  25. package/dist/checks/ports.d.ts +67 -0
  26. package/dist/checks/ports.js +2 -0
  27. package/dist/checks/published-types/index.d.ts +77 -0
  28. package/dist/checks/published-types/index.js +186 -0
  29. package/dist/deploy/host-kit.d.ts +27 -10
  30. package/dist/deploy/naming.d.ts +8 -4
  31. package/dist/deploy/naming.js +4 -5
  32. package/dist/deploy/node.d.ts +18 -0
  33. package/dist/deploy/node.js +57 -0
  34. package/dist/deploy/reachability.d.ts +42 -12
  35. package/dist/deploy/reachability.js +75 -69
  36. package/dist/deploy/redirect-guard.d.ts +7 -2
  37. package/dist/deploy/redirect-guard.js +3 -3
  38. package/dist/deploy/tokens.d.ts +14 -11
  39. package/dist/deploy/tokens.js +13 -13
  40. package/dist/deploy/tool.d.ts +9 -5
  41. package/dist/deploy/tool.js +5 -6
  42. package/dist/deploy/types.d.ts +22 -10
  43. package/dist/deploy/types.js +2 -2
  44. package/dist/index.d.ts +2 -1
  45. package/dist/index.js +2 -1
  46. package/dist/local-dev/index.d.ts +34 -0
  47. package/dist/local-dev/index.js +37 -0
  48. package/dist/packaging/electron/archive.d.ts +41 -0
  49. package/dist/packaging/electron/archive.js +77 -0
  50. package/dist/packaging/electron/asar-adapter.d.ts +13 -0
  51. package/dist/packaging/electron/asar-adapter.js +5 -0
  52. package/dist/packaging/electron/entry.d.ts +9 -0
  53. package/dist/packaging/electron/entry.js +9 -0
  54. package/dist/packaging/electron/imports.d.ts +13 -0
  55. package/dist/packaging/electron/imports.js +44 -0
  56. package/dist/packaging/electron/node.d.ts +8 -0
  57. package/dist/packaging/electron/node.js +51 -0
  58. package/dist/packaging/electron/policies.d.ts +64 -0
  59. package/dist/packaging/electron/policies.js +63 -0
  60. package/dist/packaging/electron/ports.d.ts +113 -0
  61. package/dist/packaging/electron/ports.js +2 -0
  62. package/dist/packaging/electron/stability.d.ts +9 -0
  63. package/dist/packaging/electron/stability.js +12 -0
  64. package/dist/packaging/electron/staging.d.ts +108 -0
  65. package/dist/packaging/electron/staging.js +249 -0
  66. package/dist/packaging/electron/typescript.d.ts +7 -0
  67. package/dist/packaging/electron/typescript.js +18 -0
  68. package/dist/source-control/commit.d.ts +11 -0
  69. package/dist/source-control/commit.js +71 -0
  70. package/dist/source-control/contracts.d.ts +327 -0
  71. package/dist/source-control/contracts.js +2 -0
  72. package/dist/source-control/entry.d.ts +6 -0
  73. package/dist/source-control/entry.js +6 -0
  74. package/dist/source-control/kit.d.ts +15 -0
  75. package/dist/source-control/kit.js +17 -0
  76. package/dist/source-control/registry.d.ts +100 -0
  77. package/dist/source-control/registry.js +174 -0
  78. package/dist/source-control/repository-target.d.ts +13 -0
  79. package/dist/source-control/repository-target.js +28 -0
  80. package/dist/static-export/contracts.d.ts +138 -0
  81. package/dist/static-export/contracts.js +5 -0
  82. package/dist/static-export/entry.d.ts +6 -0
  83. package/dist/static-export/entry.js +6 -0
  84. package/dist/static-export/failure-summary.d.ts +12 -0
  85. package/dist/static-export/failure-summary.js +12 -0
  86. package/dist/static-export/fetch-adapter.d.ts +6 -0
  87. package/dist/static-export/fetch-adapter.js +5 -0
  88. package/dist/static-export/node-adapters.d.ts +11 -0
  89. package/dist/static-export/node-adapters.js +111 -0
  90. package/dist/static-export/runner.d.ts +6 -0
  91. package/dist/static-export/runner.js +135 -0
  92. package/dist/static-export/transforms.d.ts +53 -0
  93. package/dist/static-export/transforms.js +154 -0
  94. package/package.json +82 -5
@@ -0,0 +1,154 @@
1
+ import { ExportPathError } from './contracts.js';
2
+ function escapeHtml(value) { return value.replace(/[&<>"']/g, char => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[char]); }
3
+ function safeHref(value) {
4
+ const href = value.trim();
5
+ if (href.startsWith('#') || /^https?:\/\//i.test(href) || /^mailto:/i.test(href))
6
+ return href;
7
+ if (href.startsWith('/')) {
8
+ try {
9
+ if (new URL(href, 'http://export-safehref.invalid/').origin === 'http://export-safehref.invalid')
10
+ return href;
11
+ }
12
+ catch {
13
+ return '#';
14
+ }
15
+ }
16
+ return '#';
17
+ }
18
+ /** Normalize the optional output URL prefix; no product layout is implied. */
19
+ export function normalizeBasePath(required) {
20
+ const trimmed = required.raw.trim().replace(/\/+$/, '');
21
+ if (trimmed === '' || trimmed === '/')
22
+ return '';
23
+ if (/[\\\x00-\x20\x7f?#"'<>]/.test(trimmed) || trimmed.startsWith('//'))
24
+ throw new ExportPathError('Invalid export base path.');
25
+ const normalized = trimmed.startsWith('/') ? trimmed : '/' + trimmed;
26
+ if (normalized.split('/').slice(1).some(segment => !segment || segment === '.' || segment === '..'))
27
+ throw new ExportPathError('Invalid export base path.');
28
+ return normalized;
29
+ }
30
+ function prefix(value, basePath) {
31
+ if (!basePath || !value.startsWith('/') || value.startsWith('//'))
32
+ return value;
33
+ if (value === basePath || value.startsWith(basePath + '/'))
34
+ return value;
35
+ return basePath + value;
36
+ }
37
+ function srcsetRanges(value) {
38
+ const ranges = [];
39
+ let index = 0;
40
+ while (index < value.length) {
41
+ while (index < value.length && /[\s,]/.test(value[index]))
42
+ index++;
43
+ const start = index;
44
+ while (index < value.length && !/\s/.test(value[index]))
45
+ index++;
46
+ let end = index;
47
+ while (end > start && value[end - 1] === ',')
48
+ end--;
49
+ if (end > start)
50
+ ranges.push({ start, end });
51
+ if (end < index)
52
+ continue;
53
+ while (index < value.length && value[index] !== ',')
54
+ index++;
55
+ }
56
+ return ranges;
57
+ }
58
+ function rewriteHtml(html, basePath) {
59
+ if (!basePath)
60
+ return html;
61
+ return html.replace(/\b(href|src|srcset)=(["'])([^"']*)\2/g, (_match, attr, quote, value) => {
62
+ if (attr !== 'srcset')
63
+ return `${attr}=${quote}${prefix(value, basePath)}${quote}`;
64
+ for (const { start, end } of srcsetRanges(value).reverse())
65
+ value = value.slice(0, start) + prefix(value.slice(start, end), basePath) + value.slice(end);
66
+ return `${attr}=${quote}${value}${quote}`;
67
+ });
68
+ }
69
+ /** Same bounded text transforms as the exporter origin; crawl the raw body before applying these. */
70
+ export function rewriteRouteBodyForBasePath(required) {
71
+ const { path, body, basePath } = required;
72
+ if (!basePath || path === '/feed.xml')
73
+ return body;
74
+ if (path === '/sitemap.xml')
75
+ return body.replace(/<loc>([^<]*)<\/loc>/g, (_match, value) => `<loc>${prefix(value, basePath)}</loc>`);
76
+ if (path === '/robots.txt')
77
+ return body.replace(/^Sitemap: (.*)$/gm, (_match, value) => `Sitemap: ${prefix(value.trim(), basePath)}`);
78
+ return rewriteHtml(body, basePath);
79
+ }
80
+ /** Live Location wins; a manifest target is a fallback only for a genuine 3xx. */
81
+ export function redirectOutcomeFor(required, optional = {}) {
82
+ if (required.status < 300 || required.status >= 400)
83
+ return { kind: 'failed', reason: `expected a 3xx redirect response, got ${required.status}` };
84
+ const location = required.locationHeader ?? optional.manifestTarget;
85
+ if (!location)
86
+ return { kind: 'failed', reason: 'redirect response carried no Location header' };
87
+ return { kind: 'redirect-to', location };
88
+ }
89
+ /** Scheme-check before escaping all three URL sinks. Unsafe destinations degrade to '#'. */
90
+ export function renderRedirectStub(required, optional = {}) {
91
+ const location = prefix(required.location, optional.basePath ?? '');
92
+ const safeTarget = escapeHtml(safeHref(location));
93
+ return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="refresh" content="0; url=${safeTarget}"><link rel="canonical" href="${safeTarget}"><title>Redirecting…</title></head><body>Redirecting to <a href="${safeTarget}">${escapeHtml(location)}</a>.</body></html>\n`;
94
+ }
95
+ /** Quoted href/src/srcset scan, preserving data-URL commas and ignoring external references. */
96
+ export function extractAssetUrls(required) {
97
+ const found = new Set();
98
+ for (const match of required.html.matchAll(/\b(href|src|srcset)=(["'])([^"']+)\2/g)) {
99
+ const value = match[3];
100
+ const values = match[1] === 'srcset' ? srcsetRanges(value).map(({ start, end }) => value.slice(start, end)) : [value];
101
+ for (const url of values)
102
+ if (!url.startsWith('//') && required.prefixes.some(prefix => url.startsWith(prefix)))
103
+ found.add(url.split('#')[0]);
104
+ }
105
+ return [...found];
106
+ }
107
+ /** A single CSS hop, resolved against the stylesheet URL and restricted to the same synthetic origin. */
108
+ export function extractCssUrls(required) {
109
+ const found = new Set();
110
+ for (const match of required.css.matchAll(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g)) {
111
+ const ref = match[2].trim();
112
+ if (!ref || ref.startsWith('data:'))
113
+ continue;
114
+ let resolved;
115
+ try {
116
+ resolved = new URL(ref, 'http://export-local.invalid' + required.cssUrl);
117
+ }
118
+ catch {
119
+ continue;
120
+ }
121
+ if (resolved.origin !== 'http://export-local.invalid')
122
+ continue;
123
+ if (required.prefixes.some(prefix => resolved.pathname.startsWith(prefix)))
124
+ found.add(resolved.pathname);
125
+ }
126
+ return [...found];
127
+ }
128
+ /** Reject path escapes and separators before HTTP or writing; returns forward-slash relative output. */
129
+ export function safeRelativeOutputFile(required) {
130
+ const { value } = required;
131
+ if (!value || /[\\\x00-\x1f\x7f:]/.test(value) || value.startsWith('/'))
132
+ throw new ExportPathError('Output path resolved outside the output directory — refused');
133
+ if (value.split('/').some(segment => !segment || segment === '.' || segment === '..'))
134
+ throw new ExportPathError('Output path resolved outside the output directory — refused');
135
+ return value;
136
+ }
137
+ /** URL request path to portable artifact path, with decoded traversal refusal. */
138
+ export function outputFileForUrl(required, optional = {}) {
139
+ if (!required.url.startsWith('/') || required.url.startsWith('//') || /[\\\x00-\x1f\x7f]/.test(required.url))
140
+ throw new ExportPathError('URL resolved outside the output directory — refused');
141
+ let decoded;
142
+ try {
143
+ decoded = decodeURIComponent(required.url.split(/[?#]/)[0]);
144
+ }
145
+ catch {
146
+ throw new ExportPathError('Invalid URL encoding — refused');
147
+ }
148
+ const relative = decoded.replace(/^\//, '').replace(/\/+$/, '');
149
+ if (relative)
150
+ safeRelativeOutputFile({ value: relative });
151
+ const output = optional.contentRoute ? (relative ? relative + '/index.html' : 'index.html') : relative;
152
+ return safeRelativeOutputFile({ value: output });
153
+ }
154
+ //# sourceMappingURL=transforms.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/devops",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "DevOps capabilities for deployment, source control, and CI/CD, exposed through independent subpaths.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,7 +14,18 @@
14
14
  "runtime": "node",
15
15
  "entries": {
16
16
  ".": "node",
17
- "./deploy": "node"
17
+ "./source-control": "node",
18
+ "./static-export": "node",
19
+ "./static-export/node": "node",
20
+ "./packaging/electron": "node",
21
+ "./packaging/electron/typescript": "node",
22
+ "./agent-jobs": "node",
23
+ "./deploy": "node",
24
+ "./checks/published-types": "node",
25
+ "./checks/coverage": "node",
26
+ "./checks/node": "node",
27
+ "./local-dev": "node",
28
+ "./deploy/node": "node"
18
29
  }
19
30
  },
20
31
  "type": "module",
@@ -22,6 +33,36 @@
22
33
  "main": "./dist/index.js",
23
34
  "types": "./dist/index.d.ts",
24
35
  "exports": {
36
+ "./source-control": {
37
+ "types": "./dist/source-control/entry.d.ts",
38
+ "import": "./dist/source-control/entry.js",
39
+ "default": "./dist/source-control/entry.js"
40
+ },
41
+ "./static-export": {
42
+ "types": "./dist/static-export/entry.d.ts",
43
+ "import": "./dist/static-export/entry.js",
44
+ "default": "./dist/static-export/entry.js"
45
+ },
46
+ "./static-export/node": {
47
+ "types": "./dist/static-export/node-adapters.d.ts",
48
+ "import": "./dist/static-export/node-adapters.js",
49
+ "default": "./dist/static-export/node-adapters.js"
50
+ },
51
+ "./packaging/electron": {
52
+ "types": "./dist/packaging/electron/entry.d.ts",
53
+ "import": "./dist/packaging/electron/entry.js",
54
+ "default": "./dist/packaging/electron/entry.js"
55
+ },
56
+ "./packaging/electron/typescript": {
57
+ "types": "./dist/packaging/electron/typescript.d.ts",
58
+ "import": "./dist/packaging/electron/typescript.js",
59
+ "default": "./dist/packaging/electron/typescript.js"
60
+ },
61
+ "./agent-jobs": {
62
+ "types": "./dist/agent-jobs/entry.d.ts",
63
+ "import": "./dist/agent-jobs/entry.js",
64
+ "default": "./dist/agent-jobs/entry.js"
65
+ },
25
66
  ".": {
26
67
  "types": "./dist/index.d.ts",
27
68
  "import": "./dist/index.js",
@@ -31,10 +72,38 @@
31
72
  "types": "./dist/deploy/index.d.ts",
32
73
  "import": "./dist/deploy/index.js",
33
74
  "default": "./dist/deploy/index.js"
75
+ },
76
+ "./checks/published-types": {
77
+ "types": "./dist/checks/published-types/index.d.ts",
78
+ "import": "./dist/checks/published-types/index.js",
79
+ "default": "./dist/checks/published-types/index.js"
80
+ },
81
+ "./checks/coverage": {
82
+ "types": "./dist/checks/coverage/index.d.ts",
83
+ "import": "./dist/checks/coverage/index.js",
84
+ "default": "./dist/checks/coverage/index.js"
85
+ },
86
+ "./checks/node": {
87
+ "types": "./dist/checks/node.d.ts",
88
+ "import": "./dist/checks/node.js",
89
+ "default": "./dist/checks/node.js"
90
+ },
91
+ "./local-dev": {
92
+ "types": "./dist/local-dev/index.d.ts",
93
+ "import": "./dist/local-dev/index.js",
94
+ "default": "./dist/local-dev/index.js"
95
+ },
96
+ "./deploy/node": {
97
+ "types": "./dist/deploy/node.d.ts",
98
+ "import": "./dist/deploy/node.js",
99
+ "default": "./dist/deploy/node.js"
34
100
  }
35
101
  },
36
102
  "files": [
37
103
  "dist",
104
+ "README.md",
105
+ "CHANGELOG.md",
106
+ "LICENSE",
38
107
  "!dist/**/*.test.js",
39
108
  "!dist/**/*.test.d.ts",
40
109
  "!dist/**/*.test.js.map",
@@ -48,12 +117,20 @@
48
117
  },
49
118
  "dependencies": {
50
119
  "undici": "^7.25.0",
51
- "@jini-ai/core": "0.3.1",
52
- "@jini-ai/platform": "0.3.0"
120
+ "@jini-ai/core": "0.4.0",
121
+ "@jini-ai/platform": "0.5.0"
53
122
  },
54
123
  "devDependencies": {
55
124
  "@vitest/coverage-v8": "^2.1.9",
56
- "@jini-ai/daemon": "0.3.8"
125
+ "@jini-ai/daemon": "0.5.0"
126
+ },
127
+ "peerDependencies": {
128
+ "typescript": "^5.6.0"
129
+ },
130
+ "peerDependenciesMeta": {
131
+ "typescript": {
132
+ "optional": true
133
+ }
57
134
  },
58
135
  "scripts": {
59
136
  "build": "tsc -p tsconfig.json",