@mcp-com-ai/shared-utils 1.0.1-beta.260912 → 1.0.2-beta.260914
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 +46 -0
- package/dist/config.js +126 -126
- package/dist/errors.js +3 -2
- package/dist/home.d.ts +13 -0
- package/dist/home.js +1 -1
- package/dist/index.js +177 -176
- package/dist/logger.js +38 -38
- package/dist/runtime.js +1 -1
- package/dist/secrets.js +1 -1
- package/package.json +56 -56
package/dist/runtime.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
2
|
+
var u={},a=l(),{isBunRuntime:s,isCloudflareRuntime:m,isNodeRuntime:v,hasFileSystemAccess:g,console:h}=a,p=u;f();function O(e,n){let t=typeof process<"u"?process.env:void 0,o=t?t[e]:void 0,i=s?Bun?.env?.[e]:void 0,r=p[e],c=typeof r==="string"?r:void 0,d=m?c??o??i:o??i??c;return d===void 0||d===""?n:d}function _(e,n){if(typeof process<"u")process.env[e]=n;p[e]=n}function F(e){globalThis.__hapiRuntimeOverride="cloudflare",y(),Object.assign(u,e)}function N(){delete globalThis.__hapiRuntimeOverride,y()}async function T(e){if(!s)throw Error(`File system access not available in this runtime: ${e}`);return await Bun.file(e).text()}async function k(e){if(!s)throw Error(`File system access not available in this runtime: ${e}`);return await Bun.file(e).json()}async function S(e){return s?await Bun.file(e).exists():!1}function A(e){if(!s)throw Error(`File system access not available in this runtime: ${e}`);return Bun.file(e)}function y(){let e=l();b(e),f()}function V(){if(g)return;if(R()!==void 0)return;let e=l();b(e),f()}function l(){let e=R(),n=x(e),t=n?!1:C(e),o=w(e,t);return{isBunRuntime:n,isCloudflareRuntime:t,isNodeRuntime:o,hasFileSystemAccess:!t&&(n||o),console:B()}}function x(e){if(e==="bun")return!0;if(e==="cloudflare"||e==="node")return!1;return typeof Bun<"u"}function C(e){if(e==="cloudflare")return!0;if(e==="bun"||e==="node")return!1;let n=typeof globalThis<"u"?globalThis:void 0,t=n?.navigator?.userAgent??"",o=typeof t==="string"&&t.includes("Cloudflare-Workers"),i=typeof n?.__ENVIRONMENT__==="string"&&n.__ENVIRONMENT__.toLowerCase()==="workerd",r=typeof n?.caches?.default<"u";return o||i||r}function w(e,n){if(e==="node")return!0;if(e==="bun"||e==="cloudflare")return!1;if(n)return!1;let t=typeof process<"u"?process.versions?.node:void 0;return typeof t==="string"&&t.length>0}function R(){return typeof globalThis<"u"?globalThis.__hapiRuntimeOverride:void 0}function B(){let e=()=>{},n=typeof console<"u"?console:void 0;if(!n)return{log:e,info:e,warn:e,error:e,debug:e};let t=(i,r)=>typeof i==="function"?i.bind(n):r,o=t(n.log,e);return{log:o,info:t(n.info,o),warn:t(n.warn,o),error:t(n.error,o),debug:t(n.debug,o)}}function b(e){s=e.isBunRuntime,m=e.isCloudflareRuntime,v=e.isNodeRuntime,g=e.hasFileSystemAccess,h=e.console}function f(){let e=E();for(let n of Object.keys(u))delete u[n];Object.assign(u,e)}function E(){if(s)return{...typeof Bun<"u"?Bun.env:{},...typeof process<"u"?process.env:{}};return(typeof process<"u"?process:void 0)?.env??{}}export{V as ensureRuntimeSynchronized,S as fileExists,A as getBunFile,O as getEnvVar,g as hasFileSystemAccess,F as initializeCloudflareRuntime,s as isBunRuntime,m as isCloudflareRuntime,v as isNodeRuntime,k as readJsonFile,T as readTextFile,y as refreshRuntimeEnvironment,N as resetRuntimeForTests,h as runtimeConsole,p as runtimeEnv,_ as setEnvVar};
|
package/dist/secrets.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
2
|
+
var u={},a=f(),{isBunRuntime:o,isCloudflareRuntime:y,isNodeRuntime:C,hasFileSystemAccess:R,console:w}=a,b=u;g();function _(e,n){let t=typeof process<"u"?process.env:void 0,i=t?t[e]:void 0,r=o?Bun?.env?.[e]:void 0,s=b[e],p=typeof s==="string"?s:void 0,d=y?p??i??r:i??r??p;return d===void 0||d===""?n:d}function T(e,n){if(typeof process<"u")process.env[e]=n;b[e]=n}function F(e){globalThis.__hapiRuntimeOverride="cloudflare",v(),Object.assign(u,e)}function N(){delete globalThis.__hapiRuntimeOverride,v()}async function P(e){if(!o)throw Error(`File system access not available in this runtime: ${e}`);return await Bun.file(e).text()}async function k(e){if(!o)throw Error(`File system access not available in this runtime: ${e}`);return await Bun.file(e).json()}async function V(e){return o?await Bun.file(e).exists():!1}function j(e){if(!o)throw Error(`File system access not available in this runtime: ${e}`);return Bun.file(e)}function v(){let e=f();x(e),g()}function L(){if(R)return;if(h()!==void 0)return;let e=f();x(e),g()}function f(){let e=h(),n=B(e),t=n?!1:S(e),i=E(e,t);return{isBunRuntime:n,isCloudflareRuntime:t,isNodeRuntime:i,hasFileSystemAccess:!t&&(n||i),console:O()}}function B(e){if(e==="bun")return!0;if(e==="cloudflare"||e==="node")return!1;return typeof Bun<"u"}function S(e){if(e==="cloudflare")return!0;if(e==="bun"||e==="node")return!1;let n=typeof globalThis<"u"?globalThis:void 0,t=n?.navigator?.userAgent??"",i=typeof t==="string"&&t.includes("Cloudflare-Workers"),r=typeof n?.__ENVIRONMENT__==="string"&&n.__ENVIRONMENT__.toLowerCase()==="workerd",s=typeof n?.caches?.default<"u";return i||r||s}function E(e,n){if(e==="node")return!0;if(e==="bun"||e==="cloudflare")return!1;if(n)return!1;let t=typeof process<"u"?process.versions?.node:void 0;return typeof t==="string"&&t.length>0}function h(){return typeof globalThis<"u"?globalThis.__hapiRuntimeOverride:void 0}function O(){let e=()=>{},n=typeof console<"u"?console:void 0;if(!n)return{log:e,info:e,warn:e,error:e,debug:e};let t=(r,s)=>typeof r==="function"?r.bind(n):s,i=t(n.log,e);return{log:i,info:t(n.info,i),warn:t(n.warn,i),error:t(n.error,i),debug:t(n.debug,i)}}function x(e){o=e.isBunRuntime,y=e.isCloudflareRuntime,C=e.isNodeRuntime,R=e.hasFileSystemAccess,w=e.console}function g(){let e=A();for(let n of Object.keys(u))delete u[n];Object.assign(u,e)}function A(){if(o)return{...typeof Bun<"u"?Bun.env:{},...typeof process<"u"?process.env:{}};return(typeof process<"u"?process:void 0)?.env??{}}var c=new Map;function m(){if(!o)return null;let e=globalThis.Bun?.secrets;if(!e||typeof e.get!=="function")return null;return e}var l=(e,n)=>`${e}::${n}`;async function I(e,n){let t=m();if(t)try{return await t.get({service:e,name:n})}catch{return c.get(l(e,n))??null}return c.get(l(e,n))??null}async function W(e,n,t){let i=m();if(i)try{await i.set({service:e,name:n,value:t});return}catch{}c.set(l(e,n),t)}async function H(e,n){let t=m();if(t)try{await t.delete({service:e,name:n});return}catch{}c.delete(l(e,n))}export{H as deleteSecret,I as getSecret,W as setSecret};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-com-ai/shared-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2-beta.260914",
|
|
4
4
|
"description": "Shared HAPI utilities: HAPI_HOME resolution, logger, config loader, errors, runtime detection, secrets. Consumed by the CLI, the core engine, and all first-party plugins.",
|
|
5
5
|
"license": "LRL-CL",
|
|
6
6
|
"type": "module",
|
|
@@ -15,60 +15,60 @@
|
|
|
15
15
|
"default": "./dist/index.js"
|
|
16
16
|
},
|
|
17
17
|
"./home": {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
"types": "./dist/home.d.ts",
|
|
19
|
+
"hapi-build-source": "./src/home.ts",
|
|
20
|
+
"bun": "./dist/home.js",
|
|
21
|
+
"default": "./dist/home.js"
|
|
22
|
+
},
|
|
23
|
+
"./logger": {
|
|
24
|
+
"types": "./dist/logger.d.ts",
|
|
25
|
+
"hapi-build-source": "./src/logger.ts",
|
|
26
|
+
"bun": "./dist/logger.js",
|
|
27
|
+
"default": "./dist/logger.js"
|
|
28
|
+
},
|
|
29
|
+
"./config": {
|
|
30
|
+
"types": "./dist/config.d.ts",
|
|
31
|
+
"hapi-build-source": "./src/config.ts",
|
|
32
|
+
"bun": "./dist/config.js",
|
|
33
|
+
"default": "./dist/config.js"
|
|
34
|
+
},
|
|
35
|
+
"./errors": {
|
|
36
|
+
"types": "./dist/errors.d.ts",
|
|
37
|
+
"hapi-build-source": "./src/errors.ts",
|
|
38
|
+
"bun": "./dist/errors.js",
|
|
39
|
+
"default": "./dist/errors.js"
|
|
40
|
+
},
|
|
41
|
+
"./runtime": {
|
|
42
|
+
"types": "./dist/runtime.d.ts",
|
|
43
|
+
"hapi-build-source": "./src/runtime.ts",
|
|
44
|
+
"bun": "./dist/runtime.js",
|
|
45
|
+
"default": "./dist/runtime.js"
|
|
46
|
+
},
|
|
47
|
+
"./secrets": {
|
|
48
|
+
"types": "./dist/secrets.d.ts",
|
|
49
|
+
"hapi-build-source": "./src/secrets.ts",
|
|
50
|
+
"bun": "./dist/secrets.js",
|
|
51
|
+
"default": "./dist/secrets.js"
|
|
52
|
+
}
|
|
22
53
|
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
"bun": "
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
"hapi-build-source": "./src/runtime.ts",
|
|
44
|
-
"bun": "./dist/runtime.js",
|
|
45
|
-
"default": "./dist/runtime.js"
|
|
46
|
-
},
|
|
47
|
-
"./secrets": {
|
|
48
|
-
"types": "./dist/secrets.d.ts",
|
|
49
|
-
"hapi-build-source": "./src/secrets.ts",
|
|
50
|
-
"bun": "./dist/secrets.js",
|
|
51
|
-
"default": "./dist/secrets.js"
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
"files": ["dist", "README.md"],
|
|
55
|
-
"scripts": {
|
|
56
|
-
"typecheck": "bunx tsc --noEmit",
|
|
57
|
-
"test": "bun test",
|
|
58
|
-
"build": "bun ../../scripts/build-package.ts ."
|
|
59
|
-
},
|
|
60
|
-
"peerDependencies": {
|
|
61
|
-
"typescript": "^5"
|
|
62
|
-
},
|
|
63
|
-
"dependencies": {
|
|
64
|
-
"winston": "^3.19.0",
|
|
65
|
-
"winston-daily-rotate-file": "^5.0.0",
|
|
66
|
-
"yaml": "^2.8.2"
|
|
67
|
-
},
|
|
68
|
-
"engines": {
|
|
69
|
-
"bun": ">=1.3.0"
|
|
70
|
-
},
|
|
71
|
-
"publishConfig": {
|
|
72
|
-
"access": "public"
|
|
73
|
-
}
|
|
54
|
+
"files": ["dist", "README.md"],
|
|
55
|
+
"scripts": {
|
|
56
|
+
"typecheck": "bunx tsc --noEmit",
|
|
57
|
+
"test": "bun test",
|
|
58
|
+
"build": "bun ../../scripts/build-package.ts ."
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"typescript": "^5"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"winston": "^3.19.0",
|
|
65
|
+
"winston-daily-rotate-file": "^5.0.0",
|
|
66
|
+
"yaml": "^2.8.2"
|
|
67
|
+
},
|
|
68
|
+
"engines": {
|
|
69
|
+
"bun": ">=1.3.0"
|
|
70
|
+
},
|
|
71
|
+
"publishConfig": {
|
|
72
|
+
"access": "public"
|
|
73
|
+
}
|
|
74
74
|
}
|