@kici-dev/shared 0.0.0 → 0.1.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 (105) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +1 -6
  3. package/dist/chunk-gOLHoazu.js +4 -0
  4. package/dist/cold-store/bucket.d.ts +26 -0
  5. package/dist/cold-store/bucket.js +40 -0
  6. package/dist/cold-store/bucket.test.d.ts +2 -0
  7. package/dist/cold-store/chunk-encoder.d.ts +63 -0
  8. package/dist/cold-store/chunk-encoder.js +94 -0
  9. package/dist/cold-store/chunk-encoder.test.d.ts +2 -0
  10. package/dist/cold-store/chunk-id.d.ts +10 -0
  11. package/dist/cold-store/chunk-id.js +29 -0
  12. package/dist/cold-store/chunk-id.test.d.ts +2 -0
  13. package/dist/cold-store/cold-store.d.ts +345 -0
  14. package/dist/cold-store/cold-store.js +1078 -0
  15. package/dist/cold-store/cold-store.test.d.ts +2 -0
  16. package/dist/cold-store/config.d.ts +62 -0
  17. package/dist/cold-store/config.js +28 -0
  18. package/dist/cold-store/index.d.ts +20 -0
  19. package/dist/cold-store/index.js +11 -0
  20. package/dist/cold-store/key.d.ts +89 -0
  21. package/dist/cold-store/key.js +88 -0
  22. package/dist/cold-store/key.test.d.ts +2 -0
  23. package/dist/cold-store/lru.d.ts +33 -0
  24. package/dist/cold-store/lru.js +59 -0
  25. package/dist/cold-store/lru.test.d.ts +2 -0
  26. package/dist/cold-store/manifest.d.ts +11 -0
  27. package/dist/cold-store/manifest.js +57 -0
  28. package/dist/cold-store/manifest.test.d.ts +2 -0
  29. package/dist/cold-store/metrics.d.ts +103 -0
  30. package/dist/cold-store/metrics.js +179 -0
  31. package/dist/cold-store/table-adapter.d.ts +229 -0
  32. package/dist/cold-store/table-adapter.js +2 -0
  33. package/dist/cold-store/types.d.ts +111 -0
  34. package/dist/cold-store/types.js +2 -0
  35. package/dist/crypto.d.ts +33 -0
  36. package/dist/crypto.js +67 -0
  37. package/dist/db-admin.d.ts +1422 -0
  38. package/dist/db-admin.js +2525 -0
  39. package/dist/db-admin.test.d.ts +2 -0
  40. package/dist/db.d.ts +14 -0
  41. package/dist/db.js +23 -0
  42. package/dist/env/allowlist.d.ts +79 -0
  43. package/dist/env/allowlist.js +86 -0
  44. package/dist/env/define-env.d.ts +172 -0
  45. package/dist/env/define-env.js +295 -0
  46. package/dist/env/define-env.test.d.ts +2 -0
  47. package/dist/env/env-rule-allowlist.test.d.ts +2 -0
  48. package/dist/env/index.d.ts +11 -0
  49. package/dist/env/index.js +4 -0
  50. package/dist/env/logger-env.d.ts +30 -0
  51. package/dist/env/logger-env.js +95 -0
  52. package/dist/error.d.ts +16 -0
  53. package/dist/error.js +58 -0
  54. package/dist/error.test.d.ts +2 -0
  55. package/dist/format-bytes.d.ts +5 -0
  56. package/dist/format-bytes.js +15 -0
  57. package/dist/format-bytes.test.d.ts +2 -0
  58. package/dist/format-duration.d.ts +11 -0
  59. package/dist/format-duration.js +32 -0
  60. package/dist/format-duration.test.d.ts +2 -0
  61. package/dist/graceful-shutdown.d.ts +58 -0
  62. package/dist/graceful-shutdown.js +71 -0
  63. package/dist/graceful-shutdown.test.d.ts +2 -0
  64. package/dist/idempotency-files.d.ts +113 -0
  65. package/dist/idempotency-files.js +190 -0
  66. package/dist/idempotency-files.test.d.ts +2 -0
  67. package/dist/idempotency.d.ts +46 -0
  68. package/dist/idempotency.js +45 -0
  69. package/dist/idempotency.test.d.ts +2 -0
  70. package/dist/index.d.ts +19 -0
  71. package/dist/index.js +31 -0
  72. package/dist/logger.d.ts +57 -0
  73. package/dist/logger.js +175 -0
  74. package/dist/logger.test.d.ts +2 -0
  75. package/dist/reconnect-delay.d.ts +11 -0
  76. package/dist/reconnect-delay.js +22 -0
  77. package/dist/request-context.d.ts +42 -0
  78. package/dist/request-context.js +37 -0
  79. package/dist/ring-buffer.d.ts +35 -0
  80. package/dist/ring-buffer.js +62 -0
  81. package/dist/ring-buffer.test.d.ts +2 -0
  82. package/dist/routes/health.d.ts +26 -0
  83. package/dist/routes/health.js +45 -0
  84. package/dist/routes/health.test.d.ts +2 -0
  85. package/dist/routes/metrics.d.ts +20 -0
  86. package/dist/routes/metrics.js +38 -0
  87. package/dist/s3-client.d.ts +42 -0
  88. package/dist/s3-client.js +25 -0
  89. package/dist/telemetry/index.d.ts +3 -0
  90. package/dist/telemetry/index.js +4 -0
  91. package/dist/telemetry/init.d.ts +20 -0
  92. package/dist/telemetry/init.js +42 -0
  93. package/dist/telemetry/init.test.d.ts +2 -0
  94. package/dist/telemetry/metrics.d.ts +8 -0
  95. package/dist/telemetry/metrics.js +16 -0
  96. package/dist/tool-check.d.ts +33 -0
  97. package/dist/tool-check.js +60 -0
  98. package/dist/tool-check.test.d.ts +2 -0
  99. package/dist/ts-loader-hook.d.ts +26 -0
  100. package/dist/ts-loader-hook.js +48 -0
  101. package/dist/zx.d.ts +8 -0
  102. package/dist/zx.js +78 -0
  103. package/package.json +69 -5
  104. package/sbom.spdx.json +8775 -0
  105. package/index.js +0 -3
package/dist/zx.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Initialize zx for cross-platform execution.
3
+ * Sets the quote function required by zx 8+ on all platforms.
4
+ * On Windows, also configures pwsh as shell.
5
+ * Call this at the start of any script/binary entry point using zx.
6
+ */
7
+ export declare function initZx(): void;
8
+ //# sourceMappingURL=zx.d.ts.map
package/dist/zx.js ADDED
@@ -0,0 +1,78 @@
1
+ import "./chunk-gOLHoazu.js";
2
+ import { execSync } from "node:child_process";
3
+ import { $, quote, quotePowerShell, usePwsh } from "zx";
4
+ //#region src/zx.ts
5
+ const PWSH_INSTALL_DOCS = "https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell-on-windows";
6
+ /**
7
+ * Initialize zx for cross-platform execution.
8
+ * Sets the quote function required by zx 8+ on all platforms.
9
+ * On Windows, also configures pwsh as shell.
10
+ * Call this at the start of any script/binary entry point using zx.
11
+ */
12
+ function initZx() {
13
+ if (process.platform === "win32") {
14
+ try {
15
+ usePwsh();
16
+ } catch {
17
+ ensurePwshWindows();
18
+ usePwsh();
19
+ }
20
+ $.quote = quotePowerShell;
21
+ } else $.quote = quote;
22
+ }
23
+ /**
24
+ * Ensure PowerShell Core (pwsh) is installed on Windows.
25
+ * Attempts automatic installation via winget using the built-in powershell.exe.
26
+ * If winget is unavailable, prints installation instructions and exits.
27
+ */
28
+ function ensurePwshWindows() {
29
+ console.error("PowerShell Core (pwsh) is required but not found in PATH.\nKiCI uses pwsh for cross-platform command execution.\n");
30
+ let hasWinget = false;
31
+ try {
32
+ execSync("powershell.exe -NoProfile -Command \"Get-Command winget -ErrorAction Stop\"", {
33
+ stdio: "ignore",
34
+ timeout: 1e4
35
+ });
36
+ hasWinget = true;
37
+ } catch {}
38
+ if (!hasWinget) {
39
+ console.error(`Automatic installation is not possible (winget not found).
40
+ Please install PowerShell Core manually:
41
+ ${PWSH_INSTALL_DOCS}\n`);
42
+ process.exit(1);
43
+ }
44
+ console.error("Attempting to install PowerShell Core via winget...\n");
45
+ try {
46
+ execSync("powershell.exe -NoProfile -Command \"winget install --id Microsoft.PowerShell --accept-source-agreements --accept-package-agreements -e --silent\"", {
47
+ stdio: "inherit",
48
+ timeout: 3e5
49
+ });
50
+ } catch {
51
+ console.error(`
52
+ Automatic installation failed.
53
+ Please install PowerShell Core manually:
54
+ ${PWSH_INSTALL_DOCS}\n`);
55
+ process.exit(1);
56
+ }
57
+ try {
58
+ const pwshPath = execSync("powershell.exe -NoProfile -Command \"(Get-Command pwsh -ErrorAction Stop).Source\"", {
59
+ encoding: "utf-8",
60
+ timeout: 1e4
61
+ }).trim();
62
+ if (pwshPath) {
63
+ const pwshDir = pwshPath.replace(/\\pwsh\.exe$/i, "");
64
+ process.env.PATH = `${pwshDir};${process.env.PATH}`;
65
+ }
66
+ } catch {
67
+ console.error(`
68
+ PowerShell Core was installed but cannot be found in PATH.
69
+ Please restart your terminal or add pwsh to PATH manually.
70
+ See: ${PWSH_INSTALL_DOCS}\n`);
71
+ process.exit(1);
72
+ }
73
+ console.error("PowerShell Core installed successfully.\n");
74
+ }
75
+ //#endregion
76
+ export { initZx };
77
+
78
+ //# sourceMappingURL=zx.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kici-dev/shared",
3
- "version": "0.0.0",
3
+ "version": "0.1.0",
4
4
  "description": "Shared utilities for the KiCI CI/CD stack — logging, zx setup, crypto, telemetry, health and metrics routes. No business logic.",
5
5
  "keywords": [
6
6
  "kici",
@@ -9,7 +9,8 @@
9
9
  "ci-cd",
10
10
  "typescript",
11
11
  "workflows",
12
- "devops"
12
+ "devops",
13
+ "utilities"
13
14
  ],
14
15
  "homepage": "https://kici.dev",
15
16
  "author": {
@@ -17,9 +18,72 @@
17
18
  "email": "hello@kici.dev"
18
19
  },
19
20
  "license": "Apache-2.0",
20
- "main": "index.js",
21
+ "engines": {
22
+ "node": ">=24"
23
+ },
24
+ "type": "module",
25
+ "files": [
26
+ "dist",
27
+ "!dist/**/*.map",
28
+ "sbom.spdx.json"
29
+ ],
21
30
  "publishConfig": {
22
- "access": "public",
23
- "registry": "https://registry.npmjs.org/"
31
+ "registry": "https://registry.npmjs.org/",
32
+ "access": "public"
33
+ },
34
+ "main": "dist/index.js",
35
+ "types": "dist/index.d.ts",
36
+ "exports": {
37
+ ".": {
38
+ "import": "./dist/index.js",
39
+ "types": "./dist/index.d.ts"
40
+ },
41
+ "./env": {
42
+ "import": "./dist/env/index.js",
43
+ "types": "./dist/env/index.d.ts"
44
+ },
45
+ "./ts-loader-hook": {
46
+ "import": "./dist/ts-loader-hook.js",
47
+ "types": "./dist/ts-loader-hook.d.ts"
48
+ },
49
+ "./idempotency": {
50
+ "import": "./dist/idempotency.js",
51
+ "types": "./dist/idempotency.d.ts"
52
+ },
53
+ "./idempotency-files": {
54
+ "import": "./dist/idempotency-files.js",
55
+ "types": "./dist/idempotency-files.d.ts"
56
+ }
57
+ },
58
+ "scripts": {
59
+ "build": "node ../../scripts/build-ts.mjs && tsc --emitDeclarationOnly",
60
+ "test": "vitest run",
61
+ "typecheck": "tsc --noEmit",
62
+ "prepublishOnly": "npx tsx ../../hack/generate-sbom.ts --package packages/shared --name @kici-dev/shared"
63
+ },
64
+ "dependencies": {
65
+ "@aws-sdk/client-s3": "^3.1038.0",
66
+ "@opentelemetry/api": "^1.9.1",
67
+ "@opentelemetry/exporter-metrics-otlp-http": "^0.217.0",
68
+ "@opentelemetry/exporter-prometheus": "^0.217.0",
69
+ "@opentelemetry/exporter-trace-otlp-http": "^0.217.0",
70
+ "@opentelemetry/instrumentation-runtime-node": "^0.28.0",
71
+ "@opentelemetry/resources": "^2.7.0",
72
+ "@opentelemetry/sdk-node": "^0.217.0",
73
+ "@opentelemetry/semantic-conventions": "^1.40.0",
74
+ "diff": "^7.0.0",
75
+ "hono": "^4.12.18",
76
+ "kysely": "^0.29.0",
77
+ "oxc-transform": "0.128.0",
78
+ "pg": "^8.20.0",
79
+ "picocolors": "^1.1.1",
80
+ "winston": "^3.19.0",
81
+ "winston-daily-rotate-file": "^5.0.0",
82
+ "zod": "^4.3.6",
83
+ "zx": "^8.8.5"
84
+ },
85
+ "devDependencies": {
86
+ "@opentelemetry/sdk-trace-base": "^2.7.0",
87
+ "@types/diff": "^7.0.0"
24
88
  }
25
89
  }