@salsita-ai/common 0.50.0-develop.55964c9a60 → 0.50.0-develop.5ac9723d62

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 CHANGED
@@ -13,12 +13,12 @@ import { Branded } from '@salsita-ai/sdk/common/utils'
13
13
 
14
14
  There is no package-root export. Import from one of the paths declared in `package.json`.
15
15
 
16
- | Entry point | Contents |
17
- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
18
- | `utils` | General-purpose helpers for browser and Node: branded types, assertions, equality and nullish checks, cache and selector helpers, localization shapes, color parsing, Zod helpers. |
19
- | `env` | `createEnvReader`, which loads environment variables into an `envalid` specification, `resolveGeneratedEnvFile`, and the `envalid` validators `bool`, `num`, `str` and `url`. |
20
- | `eslint` | Shared flat ESLint configurations: `eslintrc`, `eslintrcReactWithStoryBook`, and the optional `devLinguiEslintrcRules`. |
21
- | `prettier` | `prettierrc`, the shared Prettier configuration with its import-order plugin setup. |
16
+ | Entry point | Contents |
17
+ | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
18
+ | `utils` | General-purpose helpers for browser and Node: branded types, assertions, equality and nullish checks, cache and selector helpers, localization shapes, color parsing, and the Zod transforms `usingType` and `usingOptionalType`. |
19
+ | `env` | `createEnvReader`, which loads environment variables into an `envalid` specification, `resolveGeneratedEnvFile`, and the `envalid` validators `bool`, `num`, `str` and `url`. |
20
+ | `eslint` | Shared flat ESLint configurations: `eslintrc`, `eslintrcReactWithStoryBook`, and the optional `devLinguiEslintrcRules`. |
21
+ | `prettier` | `prettierrc`, the shared Prettier configuration with its import-order plugin setup. |
22
22
 
23
23
  ### Environment loading
24
24
 
@@ -28,7 +28,7 @@ There is no package-root export. Import from one of the paths declared in `packa
28
28
  2. The generated env file, written by the CLI with deployment values: `.env.generated` in the folder when it has one, otherwise `.phoenix/.env.generated`. The two are never merged.
29
29
  3. `.env`, the developer's own values and credentials.
30
30
 
31
- `resolveGeneratedEnvFile` names that file for a folder. `createEnvReader` searches the current package and the pnpm workspace root, expands variable references after merging, and validates the result with the supplied `envalid` specs. A value in `.env` therefore never overrides a process or generated deployment value. The consuming project owns its `.env.example`; this package has no environment variables of its own.
31
+ `resolveGeneratedEnvFile` names that file for a folder. `createEnvReader` searches the current package and the pnpm workspace root, prefers the current package within each file tier, expands references in `.env` values against the winning values after merging, keeps process-supplied and generated values literal without modifying `process.env`, and validates the result with the supplied `envalid` specs. A value in `.env` therefore never overrides a process or generated deployment value. Escape a literal dollar sign in `.env` as `\$` (for example, `PASSWORD=cost-\$5`). Generated values need no interpolation escaping. The consuming project owns its `.env.example`; this package has no environment variables of its own.
32
32
 
33
33
  ## Licence
34
34
 
@@ -17,10 +17,11 @@ export declare const resolveGeneratedEnvFile: (directory: string) => string;
17
17
  * - the generated env file
18
18
  * - and `.env` file
19
19
  *
20
- * in this order of precedence. The files are looked up in the pnpm workspace root and in the working directory.
20
+ * in this order of precedence. Within each file tier, the working directory takes precedence over the pnpm workspace root.
21
21
  * In each of the two folders the generated env file is `.env.generated` when the folder has one, and
22
22
  * `.phoenix/.env.generated` otherwise (see {@link resolveGeneratedEnvFile}): the two are never merged.
23
23
  *
24
+ * Only `.env` values expand variable references; process and generated values remain literal.
24
25
  * The function parses the variable based on the provided `envalid` specs and options
25
26
  */
26
27
  export declare const createEnvReader: <S>(specs: S, options?: CleanOptions<S>) => () => CleanedEnv<S>;
package/dist/env/index.js CHANGED
@@ -1 +1 @@
1
- import{config as e}from"dotenv";import{expand as r}from"dotenv-expand";import{cleanEnv as o}from"envalid";import{findUpSync as t,pathExistsSync as n}from"find-up";import{dirname as p,join as s,resolve as d}from"node:path";let a=(r,o)=>{let s=process.cwd(),a=[s],i=t("pnpm-workspace.yaml",{stopAt:"../../.."});if(i){let e=p(i);e!==s&&a.unshift(e)}return a.reduce((t,p)=>{let s=d(o(p));if(!n(s))return t;let a=e({processEnv:r,path:s,quiet:!0});return a.error&&(console.error("DotEnv error:",a.error),t.error=t.error??a.error),Object.assign(t.parsed,a.parsed),t},{error:void 0,parsed:{}})};export const resolveGeneratedEnvFile=e=>{let r=s(e,".env.generated");return n(r)?r:s(e,".phoenix/.env.generated")};export const createEnvReader=(e,t={})=>()=>{let n={...process.env},p=a(n,resolveGeneratedEnvFile),d=a(n,e=>s(e,".env"));return r({...d,parsed:{...d.parsed,...p.parsed},ignoreProcessEnv:!0}),o(n,e,t)};export{bool,num,str,url}from"envalid";
1
+ import{config as e}from"dotenv";import{expand as r}from"dotenv-expand";import{cleanEnv as t}from"envalid";import{findUpSync as o,pathExistsSync as l}from"find-up";import{randomUUID as n}from"node:crypto";import{dirname as p,join as c,resolve as s}from"node:path";let a=(r,t)=>{let n=process.cwd(),c=[n],a=o("pnpm-workspace.yaml",{stopAt:"../../.."});if(a){let e=p(a);e!==n&&c.push(e)}for(let o of c){let n=s(t(o));if(!l(n))continue;let p=e({processEnv:r,path:n,quiet:!0});p.error&&console.error("DotEnv error:",p.error)}};export const resolveGeneratedEnvFile=e=>{let r=c(e,".env.generated");return l(r)?r:c(e,".phoenix/.env.generated")};export const createEnvReader=(e,o={})=>()=>{let l={...process.env},p={},s={};a(p,resolveGeneratedEnvFile),a(s,e=>c(e,".env"));let i=n(),m=n(),v=[...Object.values(s),...Object.values(p),...Object.values(l)];for(;i===m||v.some(e=>void 0!==e&&(e.includes(i)||e.includes(m)));)i=n(),m=n();let d=Object.fromEntries(Object.entries(s).map(([e,r])=>[e,r.replace(/\\\$|\$(?!\{|[A-Za-z_])/g,i).replaceAll("\\",m)])),f={...d};for(let[e,r]of Object.entries({...p,...l}))void 0!==r&&(f[e]=r.replaceAll("\\",m).replaceAll("$",i),delete d[e]);return r({parsed:d,processEnv:f}),t({...Object.fromEntries(Object.entries(d).map(([e,r])=>[e,r.replaceAll(i,"$").replaceAll(m,"\\")])),...p,...l},e,o)};export{bool,num,str,url}from"envalid";
@@ -12,7 +12,7 @@ export { type ValueOf } from './value-of.js';
12
12
  export { Brand, Branded, type WithBrand } from './branded-types.js';
13
13
  export { type Empty } from './empty.js';
14
14
  export { assertExistence, AssertionError } from './assert-existence.js';
15
- export { usingType, usingNullishType, usingOptionalType } from './zod-types.js';
15
+ export { usingType, usingOptionalType } from './zod-types.js';
16
16
  export { type Logger, type LogLevel, isLogLevelEnabled } from './logger.js';
17
17
  export { initConsoleLogger, type ConsoleLoggerOptions } from './console-logger.js';
18
18
  export { isNonEmptyString } from './is-non-empty-string.js';
@@ -1 +1 @@
1
- export{isArray}from"./is-array.js";export{isNonNullish}from"./is-non-nullish.js";export{isShallowEqual}from"./is-shallow-equal.js";export{isEqualArray}from"./is-equal-array.js";export{isEqualNullish}from"./is-equal-nullish.js";export{canonicalStringify}from"./canonical-stringify.js";export{getStickyCache,createCacheToken}from"./sticky-cache.js";export{isColor,isSimpleColor,isHexColor,isRalColor,simpleColorToHex}from"./colors.js";export{Brand,Branded}from"./branded-types.js";export{assertExistence,AssertionError}from"./assert-existence.js";export{usingType,usingNullishType,usingOptionalType}from"./zod-types.js";export{isLogLevelEnabled}from"./logger.js";export{initConsoleLogger}from"./console-logger.js";export{isNonEmptyString}from"./is-non-empty-string.js";export{isMessageDescriptor,isMultilingualString,resolveLocalizable,MessageDescriptorSchema,EnhancedMessageDescriptorSchema,MultilingualStringSchema,LocalizableSchema,EnhancedLocalizableSchema}from"./localizable.js";export{InfoError}from"./info-error.js";export{CompositeKeyMap}from"./composite-key-map.js";export{memoOnce}from"./memo-once.js";export{toObservableWithLastValue}from"./observable-with-last-value.js";export{ObjectWithKeySchema}from"./object-with-key.js";export{tryOrDefault}from"./try-or-default.js";export*from"./create-selector.js";
1
+ export{isArray}from"./is-array.js";export{isNonNullish}from"./is-non-nullish.js";export{isShallowEqual}from"./is-shallow-equal.js";export{isEqualArray}from"./is-equal-array.js";export{isEqualNullish}from"./is-equal-nullish.js";export{canonicalStringify}from"./canonical-stringify.js";export{getStickyCache,createCacheToken}from"./sticky-cache.js";export{isColor,isSimpleColor,isHexColor,isRalColor,simpleColorToHex}from"./colors.js";export{Brand,Branded}from"./branded-types.js";export{assertExistence,AssertionError}from"./assert-existence.js";export{usingType,usingOptionalType}from"./zod-types.js";export{isLogLevelEnabled}from"./logger.js";export{initConsoleLogger}from"./console-logger.js";export{isNonEmptyString}from"./is-non-empty-string.js";export{isMessageDescriptor,isMultilingualString,resolveLocalizable,MessageDescriptorSchema,EnhancedMessageDescriptorSchema,MultilingualStringSchema,LocalizableSchema,EnhancedLocalizableSchema}from"./localizable.js";export{InfoError}from"./info-error.js";export{CompositeKeyMap}from"./composite-key-map.js";export{memoOnce}from"./memo-once.js";export{toObservableWithLastValue}from"./observable-with-last-value.js";export{ObjectWithKeySchema}from"./object-with-key.js";export{tryOrDefault}from"./try-or-default.js";export*from"./create-selector.js";
@@ -10,9 +10,3 @@ export declare function usingType<T, V>(typeFactory: (arg: V) => T): (arg: V, ct
10
10
  * It allows the input to be undefined.
11
11
  */
12
12
  export declare function usingOptionalType<T, V>(typeFactory: (arg: V) => T): (arg: V | undefined, ctx: RefinementCtx) => T | undefined;
13
- /**
14
- * Utility function to run zod validation on custom type factor, use effectType: 'input' in openapi metadata
15
- * to use the input type as a type to generate the openapi schema.
16
- * It allows the input to be undefined.
17
- */
18
- export declare function usingNullishType<T, V>(typeFactory: (arg: V) => T): (arg: V | undefined | null, ctx: RefinementCtx) => T | null | undefined;
@@ -1 +1 @@
1
- import{z as e}from"zod";export function usingType(s){return(r,o)=>{try{return s(r)}catch(s){return s instanceof Error?o.addIssue({code:e.ZodIssueCode.custom,message:s.message}):o.addIssue({code:e.ZodIssueCode.custom,message:"An unknown error occurred."}),e.NEVER}}}export function usingOptionalType(s){return(r,o)=>{if(void 0!==r)try{return s(r)}catch(s){return s instanceof Error?o.addIssue({code:e.ZodIssueCode.custom,message:s.message}):o.addIssue({code:e.ZodIssueCode.custom,message:"An unknown error occurred."}),e.NEVER}}}export function usingNullishType(s){return(r,o)=>{if(void 0!==r){if(null===r)return null;try{return s(r)}catch(s){return s instanceof Error?o.addIssue({code:e.ZodIssueCode.custom,message:s.message}):o.addIssue({code:e.ZodIssueCode.custom,message:"An unknown error occurred."}),e.NEVER}}}}
1
+ import{z as e}from"zod";export function usingType(s){return(o,r)=>{try{return s(o)}catch(s){return s instanceof Error?r.addIssue({code:e.ZodIssueCode.custom,message:s.message}):r.addIssue({code:e.ZodIssueCode.custom,message:"An unknown error occurred."}),e.NEVER}}}export function usingOptionalType(s){return(o,r)=>{if(void 0!==o)try{return s(o)}catch(s){return s instanceof Error?r.addIssue({code:e.ZodIssueCode.custom,message:s.message}):r.addIssue({code:e.ZodIssueCode.custom,message:"An unknown error occurred."}),e.NEVER}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salsita-ai/common",
3
- "version": "0.50.0-develop.55964c9a60",
3
+ "version": "0.50.0-develop.5ac9723d62",
4
4
  "description": "Shared Phoenix utilities, environment loading, and lint and formatting configuration.",
5
5
  "keywords": [
6
6
  "salsita",
@@ -40,7 +40,7 @@
40
40
  "@trivago/prettier-plugin-sort-imports": "4.3.0",
41
41
  "@types/json-schema": "7.0.15",
42
42
  "dotenv": "17.4.2",
43
- "dotenv-expand": "10.0.0",
43
+ "dotenv-expand": "12.0.3",
44
44
  "eslint-plugin-import": "2.32.0",
45
45
  "eslint-plugin-lingui": "0.13.1",
46
46
  "eslint-plugin-lodash": "8.0.0",
@@ -66,7 +66,7 @@
66
66
  "typescript": "npm:@typescript/typescript6@6.0.2",
67
67
  "vite": "6.4.3",
68
68
  "vitest": "4.1.11",
69
- "@salsita-ai/common": "0.50.0-develop.55964c9a60"
69
+ "@salsita-ai/common": "0.50.0-develop.5ac9723d62"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "envalid": "8.1.1",