@salsita-ai/common 0.50.0-develop.016963b09e → 0.50.0-develop.0842f1af93

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
@@ -16,7 +16,7 @@ There is no package-root export. Import from one of the paths declared in `packa
16
16
  | Entry point | Contents |
17
17
  | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
18
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. |
19
+ | `env` | `createEnvReader`, which loads environment variables into an `envalid` specification, `resolveGeneratedEnvFile`, and the `envalid` validators `bool`, `num`, `str` and `url`. |
20
20
  | `eslint` | Shared flat ESLint configurations: `eslintrc`, `eslintrcReactWithStoryBook`, and the optional `devLinguiEslintrcRules`. |
21
21
  | `prettier` | `prettierrc`, the shared Prettier configuration with its import-order plugin setup. |
22
22
 
@@ -25,10 +25,10 @@ There is no package-root export. Import from one of the paths declared in `packa
25
25
  `createEnvReader` reads variables with this precedence, highest first:
26
26
 
27
27
  1. Variables already present in `process.env`.
28
- 2. `.env.generated`, written by the CLI with deployment values.
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
- It 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, 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.
32
32
 
33
33
  ## Licence
34
34
 
@@ -1,14 +1,31 @@
1
1
  import type { CleanOptions, CleanedEnv } from 'envalid';
2
+ /**
3
+ * The one generated env file of a folder: `.env.generated` in the folder when it exists there, and
4
+ * `.phoenix/.env.generated` otherwise. The result is `directory` joined with one of the two, whether or not the
5
+ * second one exists.
6
+ *
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.
10
+ */
11
+ export declare const resolveGeneratedEnvFile: (directory: string) => string;
2
12
  /**
3
13
  * Create a function that reads and parses the environment variables.
4
14
  *
5
15
  * The variables are read from
6
16
  * - the process environment,
7
- * - `.env.generated` file
17
+ * - the generated env file
8
18
  * - and `.env` file
9
19
  *
10
- * in this order of precedence.
20
+ * in this order of precedence. The files are looked up in the pnpm workspace root and in the working directory.
21
+ * In each of the two folders the generated env file is `.env.generated` when the folder has one, and
22
+ * `.phoenix/.env.generated` otherwise (see {@link resolveGeneratedEnvFile}): the two are never merged.
11
23
  *
12
24
  * The function parses the variable based on the provided `envalid` specs and options
13
25
  */
14
26
  export declare const createEnvReader: <S>(specs: S, options?: CleanOptions<S>) => () => CleanedEnv<S>;
27
+ /**
28
+ * The `envalid` validators that the env specs Phoenix generates into a project are built from. The generated code
29
+ * imports them through `@salsita-ai/sdk/common/env`, so a project needs no `envalid` of its own.
30
+ */
31
+ export { bool, num, str, url } from 'envalid';
package/dist/env/index.js CHANGED
@@ -1 +1 @@
1
- import{config as r}from"dotenv";import{expand as e}from"dotenv-expand";import{cleanEnv as o}from"envalid";import{findUpSync as t,pathExistsSync as n}from"find-up";import{dirname as p,resolve as s}from"node:path";let d=(e,o)=>{let d=process.cwd(),a=[d],i=t("pnpm-workspace.yaml",{stopAt:"../../.."});if(i){let r=p(i);r!==d&&a.unshift(r)}return a.reduce((t,p)=>{let d=s(p,o);if(!n(d))return t;let a=r({processEnv:e,path:d,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 createEnvReader=(r,t={})=>()=>{let n={...process.env},p=d(n,".env.generated"),s=d(n,".env");return e({...s,parsed:{...s.parsed,...p.parsed},ignoreProcessEnv:!0}),o(n,r,t)};
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";
@@ -18,7 +18,7 @@ export { initConsoleLogger, type ConsoleLoggerOptions } from './console-logger.j
18
18
  export { isNonEmptyString } from './is-non-empty-string.js';
19
19
  export type { WithOptional } from './with-optional.js';
20
20
  export type { WithRequired } from './with-required.js';
21
- export { type Localizable, isMessageDescriptor, isMultilingualString, resolveLocalizable, type MultilingualString, MessageDescriptorSchema, EnhancedMessageDescriptorSchema, MultilingualStringSchema, LocalizableSchema, EnhancedLocalizableSchema, } from './localizable.js';
21
+ export { type Localizable, type EnhancedLocalizable, isMessageDescriptor, isMultilingualString, resolveLocalizable, type MultilingualString, MessageDescriptorSchema, EnhancedMessageDescriptorSchema, MultilingualStringSchema, LocalizableSchema, EnhancedLocalizableSchema, } from './localizable.js';
22
22
  export { type DeepPartial } from './deep-partial.js';
23
23
  export { InfoError } from './info-error.js';
24
24
  export { CompositeKeyMap } from './composite-key-map.js';
@@ -46,6 +46,12 @@ export declare const EnhancedMessageDescriptorSchema: {
46
46
  readonly tsType: 'EnhancedMessageDescriptor';
47
47
  };
48
48
  export type Localizable = string | MessageDescriptor | MultilingualString;
49
+ /**
50
+ * The type of a value that `EnhancedLocalizableSchema` validates, once it reaches code. In a spec the value
51
+ * may also be a `$msg` object; code generation compiles it into a `MessageDescriptor`, so generated code and
52
+ * component states hold a `Localizable`. The schema names this type as its `tsType`.
53
+ */
54
+ export type EnhancedLocalizable = Localizable;
49
55
  export declare const isMessageDescriptor: <T>(message: T | MessageDescriptor) => message is MessageDescriptor;
50
56
  export declare const isMultilingualString: <T>(message: T | MultilingualString) => message is MultilingualString;
51
57
  export declare function resolveLocalizable(message: MessageDescriptor | MultilingualString, i18n: I18n, textLanguages?: readonly string[]): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salsita-ai/common",
3
- "version": "0.50.0-develop.016963b09e",
3
+ "version": "0.50.0-develop.0842f1af93",
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
43
  "dotenv-expand": "10.0.0",
47
- "eslint-config-prettier": "10.1.8",
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.016963b09e"
69
+ "@salsita-ai/common": "0.50.0-develop.0842f1af93"
80
70
  },
81
71
  "peerDependencies": {
82
72
  "envalid": "8.1.1",