@salsita-ai/common 0.50.0-develop.ae9a830ef0 → 0.50.0-develop.aec0f535bf
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 +7 -7
- package/dist/env/index.d.ts +10 -3
- package/dist/env/index.js +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/zod-types.d.ts +0 -6
- package/dist/utils/zod-types.js +1 -1
- package/package.json +3 -13
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
|
|
19
|
-
| `env` | `createEnvReader`, which loads environment variables into an `envalid` specification, and `
|
|
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
|
|
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
|
|
package/dist/env/index.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ import type { CleanOptions, CleanedEnv } from 'envalid';
|
|
|
4
4
|
* `.phoenix/.env.generated` otherwise. The result is `directory` joined with one of the two, whether or not the
|
|
5
5
|
* second one exists.
|
|
6
6
|
*
|
|
7
|
-
* The deployment and environment commands and the deploy pipelines write the first
|
|
8
|
-
* two files that count: the one in `.phoenix` is read
|
|
7
|
+
* The deployment and environment commands and the deploy pipelines write the first, `phoenix dev` writes whichever
|
|
8
|
+
* this returns. A folder therefore never has two files that count: the one in `.phoenix` is read and written only
|
|
9
|
+
* while the folder itself has none.
|
|
9
10
|
*/
|
|
10
11
|
export declare const resolveGeneratedEnvFile: (directory: string) => string;
|
|
11
12
|
/**
|
|
@@ -16,10 +17,16 @@ export declare const resolveGeneratedEnvFile: (directory: string) => string;
|
|
|
16
17
|
* - the generated env file
|
|
17
18
|
* - and `.env` file
|
|
18
19
|
*
|
|
19
|
-
* in this order of precedence.
|
|
20
|
+
* in this order of precedence. Within each file tier, the working directory takes precedence over the pnpm workspace root.
|
|
20
21
|
* In each of the two folders the generated env file is `.env.generated` when the folder has one, and
|
|
21
22
|
* `.phoenix/.env.generated` otherwise (see {@link resolveGeneratedEnvFile}): the two are never merged.
|
|
22
23
|
*
|
|
24
|
+
* Only `.env` values expand variable references; process and generated values remain literal.
|
|
23
25
|
* The function parses the variable based on the provided `envalid` specs and options
|
|
24
26
|
*/
|
|
25
27
|
export declare const createEnvReader: <S>(specs: S, options?: CleanOptions<S>) => () => CleanedEnv<S>;
|
|
28
|
+
/**
|
|
29
|
+
* The `envalid` validators that the env specs Phoenix generates into a project are built from. The generated code
|
|
30
|
+
* imports them through `@salsita-ai/sdk/common/env`, so a project needs no `envalid` of its own.
|
|
31
|
+
*/
|
|
32
|
+
export { bool, num, str, url } from 'envalid';
|
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
|
|
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";
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -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,
|
|
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';
|
package/dist/utils/index.js
CHANGED
|
@@ -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,
|
|
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;
|
package/dist/utils/zod-types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"zod";export function usingType(s){return(r
|
|
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.
|
|
3
|
+
"version": "0.50.0-develop.aec0f535bf",
|
|
4
4
|
"description": "Shared Phoenix utilities, environment loading, and lint and formatting configuration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"salsita",
|
|
@@ -36,28 +36,20 @@
|
|
|
36
36
|
"CHANGELOG.md"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@babel/core": "7.29.7",
|
|
40
|
-
"@babel/plugin-syntax-flow": "7.23.3",
|
|
41
|
-
"@babel/plugin-transform-react-jsx": "7.23.4",
|
|
42
39
|
"@eslint/js": "9.39.4",
|
|
43
40
|
"@trivago/prettier-plugin-sort-imports": "4.3.0",
|
|
44
41
|
"@types/json-schema": "7.0.15",
|
|
45
42
|
"dotenv": "17.4.2",
|
|
46
|
-
"dotenv-expand": "
|
|
47
|
-
"eslint-config-prettier": "10.1.8",
|
|
43
|
+
"dotenv-expand": "12.0.3",
|
|
48
44
|
"eslint-plugin-import": "2.32.0",
|
|
49
|
-
"eslint-plugin-jsx-a11y": "6.10.2",
|
|
50
45
|
"eslint-plugin-lingui": "0.13.1",
|
|
51
46
|
"eslint-plugin-lodash": "8.0.0",
|
|
52
|
-
"eslint-plugin-n": "18.0.1",
|
|
53
|
-
"eslint-plugin-promise": "7.3.0",
|
|
54
47
|
"eslint-plugin-react": "7.37.5",
|
|
55
48
|
"eslint-plugin-react-hooks": "6.0.0",
|
|
56
49
|
"eslint-plugin-storybook": "10.4.1",
|
|
57
50
|
"eslint-plugin-unused-imports": "4.4.1",
|
|
58
51
|
"find-up": "7.0.0",
|
|
59
52
|
"globals": "17.6.0",
|
|
60
|
-
"lodash-es": "4.18.1",
|
|
61
53
|
"typescript-eslint": "8.60.0",
|
|
62
54
|
"zod": "3.25.76"
|
|
63
55
|
},
|
|
@@ -65,9 +57,7 @@
|
|
|
65
57
|
"@lingui/core": "5.9.5",
|
|
66
58
|
"@swc/cli": "0.8.1",
|
|
67
59
|
"@swc/core": "1.15.40",
|
|
68
|
-
"@types/babel__core": "7",
|
|
69
60
|
"@types/eslint": "9.6.1",
|
|
70
|
-
"@types/lodash-es": "4.17.12",
|
|
71
61
|
"@types/prettier": "2.7.1",
|
|
72
62
|
"envalid": "8.1.1",
|
|
73
63
|
"eslint": "9.39.4",
|
|
@@ -76,7 +66,7 @@
|
|
|
76
66
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
77
67
|
"vite": "6.4.3",
|
|
78
68
|
"vitest": "4.1.11",
|
|
79
|
-
"@salsita-ai/common": "0.50.0-develop.
|
|
69
|
+
"@salsita-ai/common": "0.50.0-develop.aec0f535bf"
|
|
80
70
|
},
|
|
81
71
|
"peerDependencies": {
|
|
82
72
|
"envalid": "8.1.1",
|