@longzai-intelligence-npm-registry/config 0.0.7 → 0.0.9

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 CHANGED
@@ -1,7 +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
- //#region src/env.constants.d.ts
5
4
  /**
6
5
  * env 键名单一真源与缺省常量(agent-tools 范式:env 名一律 `LZI_<TOOL>_` 前缀)。
7
6
  *
@@ -40,8 +39,6 @@ declare const DEFAULT_PORT = 4874;
40
39
  * 集中数据目录名(位于产品群统一数据区下,纯项目完整名称不带后缀,ADR 0113 命名铁律)
41
40
  */
42
41
  declare const CENTRAL_DATA_DIR_NAME = "longzai-intelligence-npm-registry";
43
- //#endregion
44
- //#region src/env.config.d.ts
45
42
  /**
46
43
  * env 契约(HOST / PORT 必填有缺省;DATA_HOME 可空——显式性校验由 resolveDataRoot 严格链承载)
47
44
  */
@@ -76,8 +73,6 @@ declare function loadEffectiveEnv(repoRoot: string | null): Record<string, strin
76
73
  * @throws {@link Error} 任一键取值不合法时(启动期响亮失败)
77
74
  */
78
75
  declare function parseNpmRegistryEnv(source: Record<string, string | undefined>): NpmRegistryEnv;
79
- //#endregion
80
- //#region src/data-root.utils.d.ts
81
76
  /**
82
77
  * 数据根解析结果
83
78
  */
@@ -99,8 +94,6 @@ type ResolvedDataRoot = {
99
94
  * @throws {@link DataHomeResolveError} 项目级键未设置或显式路径未命中时抛出
100
95
  */
101
96
  declare function resolveDataRoot(env: Record<string, string | undefined>): ResolvedDataRoot;
102
- //#endregion
103
- //#region src/npm-registry.config.d.ts
104
97
  /**
105
98
  * 上游直通模式集合:off = 纯本地孤仓;passthrough = 本地 miss 透传上游 packument
106
99
  */
@@ -116,7 +109,7 @@ declare const UpstreamModeSchema: z.ZodEnum<{
116
109
  * 闲置自退段(ADR 0082 §4:registry 为按需拉起的临时服务,静默达阈值即优雅停机)
117
110
  */
118
111
  declare const ShutdownSchema: z.ZodObject<{
119
- idleMs: z.ZodNumber;
112
+ idleMs: z.ZodInt;
120
113
  }, z.core.$strict>;
121
114
  /**
122
115
  * lzi-npm-registry 根配置 zod 契约(strict:多余键即报错,防止拼写漂移静默失效)
@@ -133,7 +126,7 @@ declare const NpmRegistryConfigSchema: z.ZodObject<{
133
126
  allowPattern: z.ZodString;
134
127
  }, z.core.$strict>;
135
128
  shutdown: z.ZodDefault<z.ZodObject<{
136
- idleMs: z.ZodNumber;
129
+ idleMs: z.ZodInt;
137
130
  }, z.core.$strict>>;
138
131
  }, z.core.$strict>;
139
132
  /**
@@ -159,8 +152,6 @@ declare function parseNpmRegistryConfig(source: unknown): NpmRegistryConfig;
159
152
  * @returns 原样返回的配置对象(运行时校验由加载方执行)
160
153
  */
161
154
  declare function defineConfig(config: NpmRegistryConfig): NpmRegistryConfig;
162
- //#endregion
163
- //#region src/config.loader.d.ts
164
155
  /**
165
156
  * standalone 配置文件名(单一约定,供本装载器与文档引用)
166
157
  */
@@ -194,5 +185,4 @@ type LoadedNpmRegistryConfig = {
194
185
  * @throws {@link Error} 找到配置文件但内容不合法时(交由 parseNpmRegistryConfig 响亮失败)
195
186
  */
196
187
  declare function loadNpmRegistryConfig(cwd?: string): Promise<LoadedNpmRegistryConfig>;
197
- //#endregion
198
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
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.number().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};
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-npm-registry/config",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Longzai Intelligence 本地 npm registry 配置",
5
5
  "keywords": [
6
6
  "config",