@elaraai/east-node-std 1.0.35 → 1.0.37

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.
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ import { StringType, OptionType } from "@elaraai/east";
6
+ import type { PlatformFunction } from "@elaraai/east/internal";
7
+ /**
8
+ * Reads an environment variable from the process environment.
9
+ *
10
+ * Returns `some(value)` when the variable is set (including when set to the
11
+ * empty string) and `none` when it is not set. Like `Time.now()`, this is an
12
+ * impure platform function: the value comes from the process environment at
13
+ * runtime and is never part of the compiled program.
14
+ *
15
+ * This is the supported way to consume credentials in East programs — the IR
16
+ * carries only the variable *name*, and whatever launched the process supplies
17
+ * the value (a developer's shell locally, a secret store in hosted runtimes).
18
+ * Never write a credential as a string literal: East IR is content-addressed,
19
+ * stored, exported, and replicated, so a literal secret in it is effectively
20
+ * unredactable.
21
+ *
22
+ * This is a platform function for the East language, enabling environment
23
+ * access in East programs running on Node.js.
24
+ *
25
+ * @param name - The environment variable name (e.g. "ERP_DB_PASSWORD")
26
+ * @returns `some(value)` if the variable is set, `none` otherwise
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const readToken = East.function([], OptionType(StringType), $ => {
31
+ * return Env.get("API_TOKEN");
32
+ * // Returns: some("...") when API_TOKEN is set, none otherwise
33
+ * });
34
+ * ```
35
+ */
36
+ export declare const env_get: import("@elaraai/east").PlatformDefinition<[StringType], OptionType<StringType>>;
37
+ /**
38
+ * Node.js implementation of environment platform functions.
39
+ *
40
+ * Pass this array to {@link East.compile} or {@link East.compileAsync} to
41
+ * enable environment access.
42
+ */
43
+ declare const EnvImpl: PlatformFunction[];
44
+ /**
45
+ * Grouped environment platform functions.
46
+ *
47
+ * Provides read access to process environment variables for East programs.
48
+ * Use this for values that must be supplied by the runtime environment rather
49
+ * than compiled into the program — above all credentials, which must never
50
+ * appear as literals in East code (the IR is content-addressed and replicated;
51
+ * a literal secret in it cannot be redacted).
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * import { East, StringType } from "@elaraai/east";
56
+ * import { Env } from "@elaraai/east-node-std";
57
+ *
58
+ * const connectionPassword = East.function([], StringType, $ => {
59
+ * // Name in IR; value from the environment. `.unwrap()` errors at
60
+ * // runtime if the variable is not set.
61
+ * return Env.get("ERP_DB_PASSWORD").unwrap();
62
+ * });
63
+ *
64
+ * const compiled = East.compile(connectionPassword.toIR(), Env.Implementation);
65
+ * compiled();
66
+ * ```
67
+ */
68
+ export declare const Env: {
69
+ /**
70
+ * Reads an environment variable from the process environment.
71
+ *
72
+ * Returns `some(value)` when the variable is set (including when set to
73
+ * the empty string) and `none` when it is not set. Impure by design —
74
+ * the value is read at runtime and never participates in the compiled
75
+ * program or task input hashing, which is the desired semantics for
76
+ * credentials: rotating a secret does not invalidate caches.
77
+ *
78
+ * Use `.unwrap()` on the result for the must-exist case, or
79
+ * `.unwrap("some", $ => ...)` to supply a default.
80
+ *
81
+ * @param name - The environment variable name (e.g. "ERP_DB_PASSWORD")
82
+ * @returns `some(value)` if the variable is set, `none` otherwise
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * const readToken = East.function([], OptionType(StringType), $ => {
87
+ * return Env.get("API_TOKEN");
88
+ * });
89
+ *
90
+ * const compiled = East.compile(readToken.toIR(), Env.Implementation);
91
+ * compiled(); // Returns: some("...") when API_TOKEN is set, none otherwise
92
+ * ```
93
+ */
94
+ readonly get: import("@elaraai/east").PlatformDefinition<[StringType], OptionType<StringType>>;
95
+ /**
96
+ * Node.js implementation of environment platform functions.
97
+ *
98
+ * Pass this to {@link East.compile} or {@link East.compileAsync} to
99
+ * enable environment access.
100
+ */
101
+ readonly Implementation: PlatformFunction[];
102
+ };
103
+ export { EnvImpl };
104
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/env.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAQ,UAAU,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,OAAO,kFAAiE,CAAC;AAEtF;;;;;GAKG;AACH,QAAA,MAAM,OAAO,EAAE,gBAAgB,EAY9B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,GAAG;IACZ;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;;IAGH;;;;;OAKG;;CAEG,CAAC;AAGX,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ import { East, StringType, OptionType, some, none } from "@elaraai/east";
6
+ import { EastError } from "@elaraai/east/internal";
7
+ /**
8
+ * Reads an environment variable from the process environment.
9
+ *
10
+ * Returns `some(value)` when the variable is set (including when set to the
11
+ * empty string) and `none` when it is not set. Like `Time.now()`, this is an
12
+ * impure platform function: the value comes from the process environment at
13
+ * runtime and is never part of the compiled program.
14
+ *
15
+ * This is the supported way to consume credentials in East programs — the IR
16
+ * carries only the variable *name*, and whatever launched the process supplies
17
+ * the value (a developer's shell locally, a secret store in hosted runtimes).
18
+ * Never write a credential as a string literal: East IR is content-addressed,
19
+ * stored, exported, and replicated, so a literal secret in it is effectively
20
+ * unredactable.
21
+ *
22
+ * This is a platform function for the East language, enabling environment
23
+ * access in East programs running on Node.js.
24
+ *
25
+ * @param name - The environment variable name (e.g. "ERP_DB_PASSWORD")
26
+ * @returns `some(value)` if the variable is set, `none` otherwise
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const readToken = East.function([], OptionType(StringType), $ => {
31
+ * return Env.get("API_TOKEN");
32
+ * // Returns: some("...") when API_TOKEN is set, none otherwise
33
+ * });
34
+ * ```
35
+ */
36
+ export const env_get = East.platform("env_get", [StringType], OptionType(StringType));
37
+ /**
38
+ * Node.js implementation of environment platform functions.
39
+ *
40
+ * Pass this array to {@link East.compile} or {@link East.compileAsync} to
41
+ * enable environment access.
42
+ */
43
+ const EnvImpl = [
44
+ env_get.implement((name) => {
45
+ try {
46
+ const value = process.env[name];
47
+ return value === undefined ? none : some(value);
48
+ }
49
+ catch (err) {
50
+ throw new EastError(`Failed to read environment variable "${name}": ${err.message}`, {
51
+ location: [{ filename: "env_get", line: 0n, column: 0n }],
52
+ cause: err,
53
+ });
54
+ }
55
+ }),
56
+ ];
57
+ /**
58
+ * Grouped environment platform functions.
59
+ *
60
+ * Provides read access to process environment variables for East programs.
61
+ * Use this for values that must be supplied by the runtime environment rather
62
+ * than compiled into the program — above all credentials, which must never
63
+ * appear as literals in East code (the IR is content-addressed and replicated;
64
+ * a literal secret in it cannot be redacted).
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * import { East, StringType } from "@elaraai/east";
69
+ * import { Env } from "@elaraai/east-node-std";
70
+ *
71
+ * const connectionPassword = East.function([], StringType, $ => {
72
+ * // Name in IR; value from the environment. `.unwrap()` errors at
73
+ * // runtime if the variable is not set.
74
+ * return Env.get("ERP_DB_PASSWORD").unwrap();
75
+ * });
76
+ *
77
+ * const compiled = East.compile(connectionPassword.toIR(), Env.Implementation);
78
+ * compiled();
79
+ * ```
80
+ */
81
+ export const Env = {
82
+ /**
83
+ * Reads an environment variable from the process environment.
84
+ *
85
+ * Returns `some(value)` when the variable is set (including when set to
86
+ * the empty string) and `none` when it is not set. Impure by design —
87
+ * the value is read at runtime and never participates in the compiled
88
+ * program or task input hashing, which is the desired semantics for
89
+ * credentials: rotating a secret does not invalidate caches.
90
+ *
91
+ * Use `.unwrap()` on the result for the must-exist case, or
92
+ * `.unwrap("some", $ => ...)` to supply a default.
93
+ *
94
+ * @param name - The environment variable name (e.g. "ERP_DB_PASSWORD")
95
+ * @returns `some(value)` if the variable is set, `none` otherwise
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * const readToken = East.function([], OptionType(StringType), $ => {
100
+ * return Env.get("API_TOKEN");
101
+ * });
102
+ *
103
+ * const compiled = East.compile(readToken.toIR(), Env.Implementation);
104
+ * compiled(); // Returns: some("...") when API_TOKEN is set, none otherwise
105
+ * ```
106
+ */
107
+ get: env_get,
108
+ /**
109
+ * Node.js implementation of environment platform functions.
110
+ *
111
+ * Pass this to {@link East.compile} or {@link East.compileAsync} to
112
+ * enable environment access.
113
+ */
114
+ Implementation: EnvImpl,
115
+ };
116
+ // Export for consistency with the other module implementation arrays
117
+ export { EnvImpl };
118
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/env.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;AAEtF;;;;;GAKG;AACH,MAAM,OAAO,GAAuB;IAChC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAY,EAAE,EAAE;QAC/B,IAAI,CAAC;YACD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAChC,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAChB,MAAM,IAAI,SAAS,CAAC,wCAAwC,IAAI,MAAM,GAAG,CAAC,OAAO,EAAE,EAAE;gBACjF,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;gBACzD,KAAK,EAAE,GAAG;aACb,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC;CACL,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG;IACf;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,GAAG,EAAE,OAAO;IAEZ;;;;;OAKG;IACH,cAAc,EAAE,OAAO;CACjB,CAAC;AAEX,qEAAqE;AACrE,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -9,6 +9,7 @@
9
9
  */
10
10
  export * from "./test.js";
11
11
  export * from "./console.js";
12
+ export * from "./env.js";
12
13
  export * from "./fs.js";
13
14
  export * from "./path.js";
14
15
  export * from "./crypto.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAGH,cAAc,WAAW,CAAC;AAG1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAY5B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,qDASxB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,qDAQ5B,CAAC;AAGF,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAGH,cAAc,WAAW,CAAC;AAG1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAa5B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,qDAUxB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,qDAS5B,CAAC;AAGF,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC"}
package/dist/src/index.js CHANGED
@@ -11,6 +11,7 @@
11
11
  export * from "./test.js";
12
12
  // Export platform function definitions and implementations
13
13
  export * from "./console.js";
14
+ export * from "./env.js";
14
15
  export * from "./fs.js";
15
16
  export * from "./path.js";
16
17
  export * from "./crypto.js";
@@ -19,6 +20,7 @@ export * from "./fetch.js";
19
20
  export * from "./random.js";
20
21
  // Import implementations for combined export
21
22
  import { ConsoleImpl } from "./console.js";
23
+ import { EnvImpl } from "./env.js";
22
24
  import { FileSystemImpl } from "./fs.js";
23
25
  import { PathImpl } from "./path.js";
24
26
  import { CryptoImpl } from "./crypto.js";
@@ -48,6 +50,7 @@ import { TestImpl } from "./test.js";
48
50
  */
49
51
  export const NodePlatform = [
50
52
  ...ConsoleImpl,
53
+ ...EnvImpl,
51
54
  ...FileSystemImpl,
52
55
  ...PathImpl,
53
56
  ...CryptoImpl,
@@ -76,6 +79,7 @@ export const NodePlatform = [
76
79
  */
77
80
  export const NodePlatformSync = [
78
81
  ...ConsoleImpl,
82
+ ...EnvImpl,
79
83
  ...FileSystemImpl,
80
84
  ...PathImpl,
81
85
  ...CryptoImpl,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA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json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elaraai/east-node-std",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "description": "East Node - Node.js platform integration for East language",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -50,7 +50,7 @@
50
50
  "typescript": "~5.9.2"
51
51
  },
52
52
  "peerDependencies": {
53
- "@elaraai/east": "1.0.35"
53
+ "@elaraai/east": "1.0.37"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "rm -rf dist && tsc",