@longzai-intelligence-npm-registry/config 0.0.6 → 0.0.8
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/dist/index.d.ts +17 -33
- package/dist/index.js +2 -2
- package/package.json +11 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
|
|
3
|
+
import { DataHomeSource } from "@longzai-intelligence-runtime/core";
|
|
4
4
|
/**
|
|
5
5
|
* env 键名单一真源与缺省常量(agent-tools 范式:env 名一律 `LZI_<TOOL>_` 前缀)。
|
|
6
6
|
*
|
|
@@ -8,9 +8,9 @@ import * as z from "zod";
|
|
|
8
8
|
* 跨机器稳定的项目事实在 lzi-npm-registry.config.ts(见 config.loader.ts)。
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
* 集中数据根 env
|
|
11
|
+
* 集中数据根 env 键(绝对路径;须显式设置且路径命中,严格链正本见 architecture 仓 ADR 0113)
|
|
12
12
|
*/
|
|
13
|
-
declare const
|
|
13
|
+
declare const ENV_KEY_DATA_HOME = "LZI_NPM_REGISTRY_DATA_HOME";
|
|
14
14
|
/**
|
|
15
15
|
* 监听地址 env 键(缺省仅本机回环——local-first 安全缺省)
|
|
16
16
|
*/
|
|
@@ -23,7 +23,7 @@ declare const ENV_KEY_PORT = "LZI_NPM_REGISTRY_PORT";
|
|
|
23
23
|
* env 键名单一真源(供校验/文档/CLI 提示统一引用)
|
|
24
24
|
*/
|
|
25
25
|
declare const ENV_KEYS: {
|
|
26
|
-
readonly
|
|
26
|
+
readonly dataHome: "LZI_NPM_REGISTRY_DATA_HOME";
|
|
27
27
|
readonly host: "LZI_NPM_REGISTRY_HOST";
|
|
28
28
|
readonly port: "LZI_NPM_REGISTRY_PORT";
|
|
29
29
|
};
|
|
@@ -36,18 +36,16 @@ declare const DEFAULT_HOST = "127.0.0.1";
|
|
|
36
36
|
*/
|
|
37
37
|
declare const DEFAULT_PORT = 4874;
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* 集中数据目录名(位于产品群统一数据区下,纯项目完整名称不带后缀,ADR 0113 命名铁律)
|
|
40
40
|
*/
|
|
41
|
-
declare const CENTRAL_DATA_DIR_NAME = "longzai-intelligence-npm-registry
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/env.config.d.ts
|
|
41
|
+
declare const CENTRAL_DATA_DIR_NAME = "longzai-intelligence-npm-registry";
|
|
44
42
|
/**
|
|
45
|
-
* env 契约(HOST / PORT 必填有缺省;
|
|
43
|
+
* env 契约(HOST / PORT 必填有缺省;DATA_HOME 可空——显式性校验由 resolveDataRoot 严格链承载)
|
|
46
44
|
*/
|
|
47
45
|
declare const NpmRegistryEnvSchema: z.ZodObject<{
|
|
48
46
|
host: z.ZodDefault<z.ZodString>;
|
|
49
47
|
port: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
50
|
-
|
|
48
|
+
dataHome: z.ZodOptional<z.ZodString>;
|
|
51
49
|
}, z.core.$strip>;
|
|
52
50
|
/**
|
|
53
51
|
* env 形态
|
|
@@ -75,38 +73,27 @@ declare function loadEffectiveEnv(repoRoot: string | null): Record<string, strin
|
|
|
75
73
|
* @throws {@link Error} 任一键取值不合法时(启动期响亮失败)
|
|
76
74
|
*/
|
|
77
75
|
declare function parseNpmRegistryEnv(source: Record<string, string | undefined>): NpmRegistryEnv;
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region src/data-root.utils.d.ts
|
|
80
|
-
/**
|
|
81
|
-
* 集中数据根解析链(agent-tools hub-resolution 同款范式:显式 env > 惯例回退 > 响亮报错)。
|
|
82
|
-
*
|
|
83
|
-
* 惯例回退:`<repoRoot>/../../data/longzai-intelligence-npm-registry-data`
|
|
84
|
-
* (仓库群平铺于 m5-edition 下,../.. 即产品群根,data/ 为集中数据目录)。
|
|
85
|
-
*/
|
|
86
76
|
/**
|
|
87
77
|
* 数据根解析结果
|
|
88
78
|
*/
|
|
89
79
|
type ResolvedDataRoot = {
|
|
90
80
|
/**
|
|
91
|
-
* 集中数据根绝对路径(调用方负责建目录,见 core
|
|
81
|
+
* 集中数据根绝对路径(调用方负责建目录,见 core 的 ensureLayout)
|
|
92
82
|
*/
|
|
93
83
|
dataRoot: string;
|
|
94
84
|
/**
|
|
95
|
-
* 命中来源:env
|
|
85
|
+
* 命中来源:env 为项目级显式键命中,machine 与 xdg-fallback 仅在声明 allowFallback 时出现
|
|
96
86
|
*/
|
|
97
|
-
source:
|
|
87
|
+
source: DataHomeSource;
|
|
98
88
|
};
|
|
99
89
|
/**
|
|
100
90
|
* 解析集中数据根
|
|
101
91
|
*
|
|
102
|
-
* @param
|
|
103
|
-
* @param repoRoot - 仓库根(convention 回退的前提;可为 null)
|
|
92
|
+
* @param env - 原始环境变量键值集合,.env 与 `process.env` 合并形态
|
|
104
93
|
* @returns 数据根与命中来源
|
|
105
|
-
* @throws {@link
|
|
94
|
+
* @throws {@link DataHomeResolveError} 项目级键未设置或显式路径未命中时抛出
|
|
106
95
|
*/
|
|
107
|
-
declare function resolveDataRoot(
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/npm-registry.config.d.ts
|
|
96
|
+
declare function resolveDataRoot(env: Record<string, string | undefined>): ResolvedDataRoot;
|
|
110
97
|
/**
|
|
111
98
|
* 上游直通模式集合:off = 纯本地孤仓;passthrough = 本地 miss 透传上游 packument
|
|
112
99
|
*/
|
|
@@ -122,7 +109,7 @@ declare const UpstreamModeSchema: z.ZodEnum<{
|
|
|
122
109
|
* 闲置自退段(ADR 0082 §4:registry 为按需拉起的临时服务,静默达阈值即优雅停机)
|
|
123
110
|
*/
|
|
124
111
|
declare const ShutdownSchema: z.ZodObject<{
|
|
125
|
-
idleMs: z.
|
|
112
|
+
idleMs: z.ZodInt;
|
|
126
113
|
}, z.core.$strict>;
|
|
127
114
|
/**
|
|
128
115
|
* lzi-npm-registry 根配置 zod 契约(strict:多余键即报错,防止拼写漂移静默失效)
|
|
@@ -139,7 +126,7 @@ declare const NpmRegistryConfigSchema: z.ZodObject<{
|
|
|
139
126
|
allowPattern: z.ZodString;
|
|
140
127
|
}, z.core.$strict>;
|
|
141
128
|
shutdown: z.ZodDefault<z.ZodObject<{
|
|
142
|
-
idleMs: z.
|
|
129
|
+
idleMs: z.ZodInt;
|
|
143
130
|
}, z.core.$strict>>;
|
|
144
131
|
}, z.core.$strict>;
|
|
145
132
|
/**
|
|
@@ -165,8 +152,6 @@ declare function parseNpmRegistryConfig(source: unknown): NpmRegistryConfig;
|
|
|
165
152
|
* @returns 原样返回的配置对象(运行时校验由加载方执行)
|
|
166
153
|
*/
|
|
167
154
|
declare function defineConfig(config: NpmRegistryConfig): NpmRegistryConfig;
|
|
168
|
-
//#endregion
|
|
169
|
-
//#region src/config.loader.d.ts
|
|
170
155
|
/**
|
|
171
156
|
* standalone 配置文件名(单一约定,供本装载器与文档引用)
|
|
172
157
|
*/
|
|
@@ -200,5 +185,4 @@ type LoadedNpmRegistryConfig = {
|
|
|
200
185
|
* @throws {@link Error} 找到配置文件但内容不合法时(交由 parseNpmRegistryConfig 响亮失败)
|
|
201
186
|
*/
|
|
202
187
|
declare function loadNpmRegistryConfig(cwd?: string): Promise<LoadedNpmRegistryConfig>;
|
|
203
|
-
|
|
204
|
-
export { CENTRAL_DATA_DIR_NAME, DEFAULT_HOST, DEFAULT_NPM_REGISTRY_CONFIG, DEFAULT_PORT, ENV_KEYS, ENV_KEY_DATA_ROOT, ENV_KEY_HOST, ENV_KEY_PORT, type LoadedNpmRegistryConfig, type NpmRegistryConfig, NpmRegistryConfigSchema, type NpmRegistryEnv, NpmRegistryEnvSchema, type ResolvedDataRoot, STANDALONE_CONFIG_FILE, ShutdownSchema, UNIFIED_CONFIG_FIELD, UPSTREAM_MODES, UpstreamModeSchema, defineConfig, loadEffectiveEnv, loadNpmRegistryConfig, parseEnvFileContent, parseNpmRegistryConfig, parseNpmRegistryEnv, resolveDataRoot };
|
|
188
|
+
export { CENTRAL_DATA_DIR_NAME, DEFAULT_HOST, DEFAULT_NPM_REGISTRY_CONFIG, DEFAULT_PORT, ENV_KEYS, ENV_KEY_DATA_HOME, ENV_KEY_HOST, ENV_KEY_PORT, type LoadedNpmRegistryConfig, type NpmRegistryConfig, NpmRegistryConfigSchema, type NpmRegistryEnv, NpmRegistryEnvSchema, type ResolvedDataRoot, STANDALONE_CONFIG_FILE, ShutdownSchema, UNIFIED_CONFIG_FIELD, UPSTREAM_MODES, UpstreamModeSchema, defineConfig, loadEffectiveEnv, loadNpmRegistryConfig, parseEnvFileContent, parseNpmRegistryConfig, parseNpmRegistryEnv, resolveDataRoot };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./rolldown-runtime-BqT_7tdF.js";import{existsSync as e,readFileSync as t}from"node:fs";import{dirname as n,
|
|
2
|
-
`)){let e=n.trim();if(e===``||e.startsWith(`#`))continue;let r=e.indexOf(`=`);if(r<=0)continue;let i=e.slice(0,r).trim(),a=e.slice(r+1).trim();(a.startsWith(`"`)&&a.endsWith(`"`)&&a.length>=2||a.startsWith(`'`)&&a.endsWith(`'`)&&a.length>=2)&&(a=a.slice(1,-1)),t[i]=a}return t}function _(n){let
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{existsSync as e,readFileSync as t}from"node:fs";import{dirname as n,join as r,resolve as i}from"node:path";import*as a from"zod";import{resolveDataHome as o}from"@longzai-intelligence-runtime/core";import{loadUnifiedConfig as s}from"@longzai-intelligence-shared-config/core";const c=`LZI_NPM_REGISTRY_DATA_HOME`,l=`LZI_NPM_REGISTRY_HOST`,u=`LZI_NPM_REGISTRY_PORT`,d={dataHome:c,host:l,port:u},f=`127.0.0.1`,p=4874,m=`longzai-intelligence-npm-registry`,h=a.object({host:a.string().min(1).default(f),port:a.coerce.number().int().min(0).max(65535).default(p),dataHome:a.string().min(1).optional()});function g(e){let t={};for(let n of e.split(`
|
|
2
|
+
`)){let e=n.trim();if(e===``||e.startsWith(`#`))continue;let r=e.indexOf(`=`);if(r<=0)continue;let i=e.slice(0,r).trim(),a=e.slice(r+1).trim();(a.startsWith(`"`)&&a.endsWith(`"`)&&a.length>=2||a.startsWith(`'`)&&a.endsWith(`'`)&&a.length>=2)&&(a=a.slice(1,-1)),t[i]=a}return t}function _(n){let i={};if(n!==null){let a=r(n,`.env`);e(a)&&(i=g(t(a,`utf8`)))}return{...i,...process.env}}function v(e){let t=h.safeParse({host:e[d.host],port:e[d.port],dataHome:e[d.dataHome]});if(!t.success)throw Error(`[config] lzi-npm-registry env 不合法:${t.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `)}`);return t.data}const y={domain:`npm-registry`,centralDataDirName:m};function b(e){let t=o({config:y,env:e});return{dataRoot:t.dataHome,source:t.source}}const x=[`off`,`passthrough`],S=a.enum(x),C=a.strictObject({idleMs:a.int().nonnegative()}),w=a.strictObject({upstream:a.strictObject({registry:a.url(),mode:S}),publish:a.strictObject({allowPattern:a.string().min(1).refine(e=>{try{return new RegExp(e),!0}catch{return!1}},{error:`allowPattern 必须是合法正则源文本`})}),shutdown:C.default({idleMs:6e5})}),T={upstream:{registry:`https://mirrors.cloud.tencent.com/npm/`,mode:`passthrough`},publish:{allowPattern:`^@longzai-intelligence(-[a-z0-9-]+)?/`},shutdown:{idleMs:6e5}};function E(e){let t=w.safeParse(e);if(!t.success)throw Error(`[config] lzi-npm-registry.config.ts 不合法:${t.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `)}`);return t.data}function D(e){return e}const O=`lzi-npm-registry.config.ts`,k=`npmRegistry`;async function A(e=process.cwd()){let t=await s({cwd:e,standaloneFile:O,unifiedField:k});return t.success?{config:E(t.config),source:t.source,repoRoot:i(n(t.configFilePath))}:{config:T,source:`builtin`,repoRoot:null}}export{m as CENTRAL_DATA_DIR_NAME,f as DEFAULT_HOST,T as DEFAULT_NPM_REGISTRY_CONFIG,p as DEFAULT_PORT,d as ENV_KEYS,c as ENV_KEY_DATA_HOME,l as ENV_KEY_HOST,u as ENV_KEY_PORT,w as NpmRegistryConfigSchema,h as NpmRegistryEnvSchema,O as STANDALONE_CONFIG_FILE,C as ShutdownSchema,k as UNIFIED_CONFIG_FIELD,x as UPSTREAM_MODES,S as UpstreamModeSchema,D as defineConfig,_ as loadEffectiveEnv,A as loadNpmRegistryConfig,g as parseEnvFileContent,E as parseNpmRegistryConfig,v as parseNpmRegistryEnv,b as resolveDataRoot};
|
package/package.json
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longzai-intelligence-npm-registry/config",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Longzai Intelligence 本地 npm registry
|
|
3
|
+
"version": "0.0.8",
|
|
4
|
+
"description": "Longzai Intelligence 本地 npm registry 配置",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"config",
|
|
7
|
+
"longzai-intelligence",
|
|
8
|
+
"npm-registry",
|
|
9
|
+
"schema",
|
|
10
|
+
"zod"
|
|
11
|
+
],
|
|
5
12
|
"license": "UNLICENSED",
|
|
6
13
|
"files": [
|
|
7
14
|
"dist"
|
|
@@ -31,6 +38,8 @@
|
|
|
31
38
|
"clean": "lzi-dev-cli clean"
|
|
32
39
|
},
|
|
33
40
|
"dependencies": {
|
|
41
|
+
"@longzai-intelligence-runtime/config": "^0.0.3",
|
|
42
|
+
"@longzai-intelligence-runtime/core": "^0.0.3",
|
|
34
43
|
"@longzai-intelligence-shared-config/core": "^0.0.7",
|
|
35
44
|
"zod": "^4.4.3"
|
|
36
45
|
}
|