typed-settings 0.1.4 → 0.2.1
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 +14 -7
- package/bin/typed-settings.mjs +5 -0
- package/dist/adapters/joi.cjs +1 -26
- package/dist/adapters/joi.d.cts +2 -1
- package/dist/adapters/joi.d.ts +2 -1
- package/dist/adapters/joi.js +1 -1
- package/dist/adapters/superstruct.cjs +1 -26
- package/dist/adapters/superstruct.js +1 -1
- package/dist/adapters/yup.cjs +1 -25
- package/dist/adapters/yup.js +1 -1
- package/dist/adapters/zod.cjs +3 -36
- package/dist/adapters/zod.js +1 -33
- package/dist/check-XVFZEVNV.js +1 -0
- package/dist/chunk-4EAMKDNK.js +3 -0
- package/dist/chunk-5D2AQWDG.js +1 -0
- package/dist/chunk-C6CG2D4B.js +2 -0
- package/dist/chunk-FQYD5ZKE.js +1 -0
- package/dist/chunk-NQDE3WLR.js +3 -0
- package/dist/chunk-RURPDXIJ.js +1 -0
- package/dist/cli/main.cjs +36 -2225
- package/dist/cli/main.js +32 -806
- package/dist/errors-JkkOM0u-.d.cts +25 -0
- package/dist/errors-JkkOM0u-.d.ts +25 -0
- package/dist/framework/next.cjs +5 -1158
- package/dist/framework/next.d.cts +3 -3
- package/dist/framework/next.d.ts +3 -3
- package/dist/framework/next.js +1 -15
- package/dist/framework/vite.cjs +5 -1156
- package/dist/framework/vite.d.cts +8 -3
- package/dist/framework/vite.d.ts +8 -3
- package/dist/framework/vite.js +1 -14
- package/dist/index.cjs +5 -1181
- package/dist/index.d.cts +38 -7
- package/dist/index.d.ts +38 -7
- package/dist/index.js +1 -6
- package/dist/node.cjs +6 -1241
- package/dist/node.d.cts +23 -9
- package/dist/node.d.ts +23 -9
- package/dist/node.js +1 -7
- package/dist/{types-B_Dc2L4T.d.cts → types-CcsYDAdO.d.cts} +23 -1
- package/dist/{types-B_Dc2L4T.d.ts → types-CcsYDAdO.d.ts} +23 -1
- package/dist/vault/aws.cjs +4 -217
- package/dist/vault/aws.d.cts +1 -1
- package/dist/vault/aws.d.ts +1 -1
- package/dist/vault/aws.js +2 -167
- package/dist/vault/hashicorp.cjs +4 -183
- package/dist/vault/hashicorp.d.cts +1 -1
- package/dist/vault/hashicorp.d.ts +1 -1
- package/dist/vault/hashicorp.js +2 -77
- package/dist/vault/http.cjs +4 -185
- package/dist/vault/http.d.cts +1 -1
- package/dist/vault/http.d.ts +1 -1
- package/dist/vault/http.js +2 -79
- package/package.json +2 -3
- package/dist/chunk-33M5GIKQ.js +0 -13
- package/dist/chunk-A5TCQJ7L.js +0 -65
- package/dist/chunk-DEP5SD4J.js +0 -233
- package/dist/chunk-EE6LXNJV.js +0 -34
- package/dist/chunk-F6DX3HXZ.js +0 -101
- package/dist/chunk-OVFMKC2O.js +0 -15
- package/dist/chunk-RQC6OMVV.js +0 -86
- package/dist/chunk-UFUHHR2J.js +0 -38
- package/dist/chunk-YVJEZPPZ.js +0 -989
- package/dist/errors-itGaU4Q8.d.cts +0 -17
- package/dist/errors-itGaU4Q8.d.ts +0 -17
- package/dist/formats/env.cjs +0 -103
- package/dist/formats/env.d.cts +0 -8
- package/dist/formats/env.d.ts +0 -8
- package/dist/formats/env.js +0 -1
- package/dist/formats/json.cjs +0 -15
- package/dist/formats/json.d.cts +0 -7
- package/dist/formats/json.d.ts +0 -7
- package/dist/formats/json.js +0 -1
- package/dist/formats/toml.cjs +0 -17
- package/dist/formats/toml.d.cts +0 -7
- package/dist/formats/toml.d.ts +0 -7
- package/dist/formats/toml.js +0 -1
- package/dist/formats/yaml.cjs +0 -40
- package/dist/formats/yaml.d.cts +0 -8
- package/dist/formats/yaml.d.ts +0 -8
- package/dist/formats/yaml.js +0 -1
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** One validation failure: the key path, the winning source, and what went wrong. */
|
|
2
|
-
interface ConfigIssue {
|
|
3
|
-
path: string;
|
|
4
|
-
from: string;
|
|
5
|
-
message: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Every settings failure. Carries machine-readable `issues` plus a `code`
|
|
9
|
-
* (`E_INVALID_CONFIG` by default, e.g. `E_UNKNOWN_KEY`, `E_TIMEOUT`).
|
|
10
|
-
*/
|
|
11
|
-
declare class ConfigError extends Error {
|
|
12
|
-
code: string;
|
|
13
|
-
issues: ConfigIssue[];
|
|
14
|
-
constructor(issues: ConfigIssue[], code?: string);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { ConfigError as C };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** One validation failure: the key path, the winning source, and what went wrong. */
|
|
2
|
-
interface ConfigIssue {
|
|
3
|
-
path: string;
|
|
4
|
-
from: string;
|
|
5
|
-
message: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Every settings failure. Carries machine-readable `issues` plus a `code`
|
|
9
|
-
* (`E_INVALID_CONFIG` by default, e.g. `E_UNKNOWN_KEY`, `E_TIMEOUT`).
|
|
10
|
-
*/
|
|
11
|
-
declare class ConfigError extends Error {
|
|
12
|
-
code: string;
|
|
13
|
-
issues: ConfigIssue[];
|
|
14
|
-
constructor(issues: ConfigIssue[], code?: string);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { ConfigError as C };
|
package/dist/formats/env.cjs
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// src/formats/env.ts
|
|
4
|
-
function parseEnvText(text) {
|
|
5
|
-
const out = {};
|
|
6
|
-
if (text.charCodeAt(0) === 65279) text = text.slice(1);
|
|
7
|
-
const lines = splitLogicalLines(text);
|
|
8
|
-
for (const rawLine of lines) {
|
|
9
|
-
let line = rawLine.trim();
|
|
10
|
-
if (!line || line.startsWith("#")) continue;
|
|
11
|
-
if (line.startsWith("export ")) line = line.slice(7).trimStart();
|
|
12
|
-
const eq = line.indexOf("=");
|
|
13
|
-
if (eq === -1) {
|
|
14
|
-
throw new Error(`ParseError: bare key without '=': ${JSON.stringify(line)}`);
|
|
15
|
-
}
|
|
16
|
-
const key = line.slice(0, eq).trim();
|
|
17
|
-
let rest = line.slice(eq + 1).trimStart();
|
|
18
|
-
if (!key) throw new Error("ParseError: empty key");
|
|
19
|
-
out[key] = parseValue(rest);
|
|
20
|
-
}
|
|
21
|
-
return out;
|
|
22
|
-
}
|
|
23
|
-
function splitLogicalLines(text) {
|
|
24
|
-
const physical = text.split(/\r?\n/);
|
|
25
|
-
const out = [];
|
|
26
|
-
let buf = "";
|
|
27
|
-
let inDouble = false;
|
|
28
|
-
for (const pl of physical) {
|
|
29
|
-
if (!inDouble) {
|
|
30
|
-
const opens = countUnescapedQuotes(pl);
|
|
31
|
-
if (opens % 2 === 1 && isValueStartDoubleQuoted(pl)) {
|
|
32
|
-
buf = pl;
|
|
33
|
-
inDouble = true;
|
|
34
|
-
} else {
|
|
35
|
-
out.push(pl);
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
buf += "\n" + pl;
|
|
39
|
-
const opens = countUnescapedQuotes(buf.split("=").slice(1).join("="));
|
|
40
|
-
if (opens % 2 === 0) {
|
|
41
|
-
inDouble = false;
|
|
42
|
-
out.push(buf);
|
|
43
|
-
buf = "";
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (inDouble) throw new Error("ParseError: unterminated double-quoted value");
|
|
48
|
-
return out;
|
|
49
|
-
}
|
|
50
|
-
function isValueStartDoubleQuoted(line) {
|
|
51
|
-
const eq = line.indexOf("=");
|
|
52
|
-
if (eq === -1) return false;
|
|
53
|
-
const rest = line.slice(eq + 1).trimStart();
|
|
54
|
-
return rest.startsWith('"') && !rest.endsWith('"');
|
|
55
|
-
}
|
|
56
|
-
function countUnescapedQuotes(s) {
|
|
57
|
-
let n = 0;
|
|
58
|
-
for (let i = 0; i < s.length; i++) {
|
|
59
|
-
if (s[i] === '"' && s[i - 1] !== "\\") n++;
|
|
60
|
-
}
|
|
61
|
-
return n;
|
|
62
|
-
}
|
|
63
|
-
function parseValue(rest) {
|
|
64
|
-
if (!rest) return "";
|
|
65
|
-
if (rest.startsWith("'")) {
|
|
66
|
-
const end = rest.indexOf("'", 1);
|
|
67
|
-
if (end === -1) throw new Error("ParseError: unterminated single-quoted value");
|
|
68
|
-
return rest.slice(1, end);
|
|
69
|
-
}
|
|
70
|
-
if (rest.startsWith('"')) {
|
|
71
|
-
let i = 1;
|
|
72
|
-
let val = "";
|
|
73
|
-
while (i < rest.length) {
|
|
74
|
-
const c = rest[i];
|
|
75
|
-
if (c === "\\" && i + 1 < rest.length) {
|
|
76
|
-
const n = rest[i + 1];
|
|
77
|
-
if (n === "n") val += "\n";
|
|
78
|
-
else if (n === "r") val += "\r";
|
|
79
|
-
else if (n === "t") val += " ";
|
|
80
|
-
else val += n;
|
|
81
|
-
i += 2;
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
if (c === '"') break;
|
|
85
|
-
val += c;
|
|
86
|
-
i++;
|
|
87
|
-
}
|
|
88
|
-
if (rest[i] !== '"') throw new Error("ParseError: unterminated double-quoted value");
|
|
89
|
-
return val;
|
|
90
|
-
}
|
|
91
|
-
if (rest.startsWith("`")) throw new Error("ParseError: backtick values not supported");
|
|
92
|
-
const hash = findCommentStart(rest);
|
|
93
|
-
const v = (hash === -1 ? rest : rest.slice(0, hash)).trim();
|
|
94
|
-
return v;
|
|
95
|
-
}
|
|
96
|
-
function findCommentStart(s) {
|
|
97
|
-
for (let i = 0; i < s.length; i++) {
|
|
98
|
-
if (s[i] === "#" && (i === 0 || /\s/.test(s[i - 1]))) return i;
|
|
99
|
-
}
|
|
100
|
-
return -1;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
exports.parseEnvText = parseEnvText;
|
package/dist/formats/env.d.cts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses dotenv text into a flat map. Strips one BOM, joins multiline
|
|
3
|
-
* double-quoted values, lets the last duplicate win. Throws `ParseError` on
|
|
4
|
-
* backticks, unterminated quotes, bare keys, and empty keys.
|
|
5
|
-
*/
|
|
6
|
-
declare function parseEnvText(text: string): Record<string, string>;
|
|
7
|
-
|
|
8
|
-
export { parseEnvText };
|
package/dist/formats/env.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses dotenv text into a flat map. Strips one BOM, joins multiline
|
|
3
|
-
* double-quoted values, lets the last duplicate win. Throws `ParseError` on
|
|
4
|
-
* backticks, unterminated quotes, bare keys, and empty keys.
|
|
5
|
-
*/
|
|
6
|
-
declare function parseEnvText(text: string): Record<string, string>;
|
|
7
|
-
|
|
8
|
-
export { parseEnvText };
|
package/dist/formats/env.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { parseEnvText } from '../chunk-F6DX3HXZ.js';
|
package/dist/formats/json.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// src/formats/json.ts
|
|
4
|
-
function parseJsonText(text, from = "json") {
|
|
5
|
-
const stripped = text.charCodeAt(0) === 65279 ? text.slice(1) : text;
|
|
6
|
-
if (!stripped.trim()) return {};
|
|
7
|
-
try {
|
|
8
|
-
return JSON.parse(stripped);
|
|
9
|
-
} catch (e) {
|
|
10
|
-
const err = e;
|
|
11
|
-
throw new Error(`ParseError (${from}): ${err.message}`);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
exports.parseJsonText = parseJsonText;
|
package/dist/formats/json.d.cts
DELETED
package/dist/formats/json.d.ts
DELETED
package/dist/formats/json.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { parseJsonText } from '../chunk-33M5GIKQ.js';
|
package/dist/formats/toml.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var smolToml = require('smol-toml');
|
|
4
|
-
|
|
5
|
-
// src/formats/toml.ts
|
|
6
|
-
function parseTomlText(text, from = "toml") {
|
|
7
|
-
const stripped = text.charCodeAt(0) === 65279 ? text.slice(1) : text;
|
|
8
|
-
if (!stripped.trim()) return {};
|
|
9
|
-
try {
|
|
10
|
-
return smolToml.parse(stripped);
|
|
11
|
-
} catch (e) {
|
|
12
|
-
const err = e;
|
|
13
|
-
throw new Error(`ParseError (${from}): ${err.message}`);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
exports.parseTomlText = parseTomlText;
|
package/dist/formats/toml.d.cts
DELETED
package/dist/formats/toml.d.ts
DELETED
package/dist/formats/toml.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { parseTomlText } from '../chunk-OVFMKC2O.js';
|
package/dist/formats/yaml.cjs
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var yaml = require('yaml');
|
|
4
|
-
|
|
5
|
-
// src/formats/yaml.ts
|
|
6
|
-
function parseYamlText(text, from = "yaml") {
|
|
7
|
-
const stripped = text.charCodeAt(0) === 65279 ? text.slice(1) : text;
|
|
8
|
-
if (!stripped.trim()) return {};
|
|
9
|
-
const docs = yaml.parseAllDocuments(stripped, {
|
|
10
|
-
version: "1.2",
|
|
11
|
-
uniqueKeys: true
|
|
12
|
-
}).filter((d) => {
|
|
13
|
-
if (d.errors.length > 0) return true;
|
|
14
|
-
try {
|
|
15
|
-
const v = d.toJS();
|
|
16
|
-
return v !== null && v !== void 0;
|
|
17
|
-
} catch {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
if (docs.length === 0) return {};
|
|
22
|
-
if (docs.length > 1) {
|
|
23
|
-
throw new Error(`ParseError (${from}): multi-doc YAML not supported (got ${docs.length} documents)`);
|
|
24
|
-
}
|
|
25
|
-
const doc = docs[0];
|
|
26
|
-
if (doc.errors.length > 0) {
|
|
27
|
-
const first = doc.errors[0];
|
|
28
|
-
const line = first.linePos?.[0]?.line ?? "?";
|
|
29
|
-
throw new Error(`ParseError (${from}:${line}): ${first.message}`);
|
|
30
|
-
}
|
|
31
|
-
let value;
|
|
32
|
-
try {
|
|
33
|
-
value = doc.toJS();
|
|
34
|
-
} catch (e) {
|
|
35
|
-
throw new Error(`ParseError (${from}): ${e.message}`);
|
|
36
|
-
}
|
|
37
|
-
return value;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
exports.parseYamlText = parseYamlText;
|
package/dist/formats/yaml.d.cts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Single-doc YAML parse (1.2, duplicate keys rejected). A trailing lone `---`
|
|
3
|
-
* still parses; multi-doc payloads, bad indentation, and unresolvable aliases
|
|
4
|
-
* throw `ParseError` naming the source. Explicit `null` reads as `{}`.
|
|
5
|
-
*/
|
|
6
|
-
declare function parseYamlText(text: string, from?: string): unknown;
|
|
7
|
-
|
|
8
|
-
export { parseYamlText };
|
package/dist/formats/yaml.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Single-doc YAML parse (1.2, duplicate keys rejected). A trailing lone `---`
|
|
3
|
-
* still parses; multi-doc payloads, bad indentation, and unresolvable aliases
|
|
4
|
-
* throw `ParseError` naming the source. Explicit `null` reads as `{}`.
|
|
5
|
-
*/
|
|
6
|
-
declare function parseYamlText(text: string, from?: string): unknown;
|
|
7
|
-
|
|
8
|
-
export { parseYamlText };
|
package/dist/formats/yaml.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { parseYamlText } from '../chunk-UFUHHR2J.js';
|