tyfigo 0.0.0 → 0.1.0-next.4294ee4.0

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
@@ -1,21 +1,21 @@
1
1
  <div align="center">
2
2
 
3
- # tyfig
3
+ # tyfigo
4
4
 
5
5
  **Import YAML, TOML, JSON5, INI and .env files into TypeScript with full type inference.**
6
6
 
7
- [![GitHub](https://img.shields.io/github/license/imranbarbhuiya/tyfig)](https://github.com/imranbarbhuiya/tyfig/blob/main/LICENSE)
8
- [![npm](https://img.shields.io/npm/v/tyfig?color=crimson&logo=npm&style=flat-square)](https://www.npmjs.com/package/tyfig)
7
+ [![GitHub](https://img.shields.io/github/license/imranbarbhuiya/tyfigo)](https://github.com/imranbarbhuiya/tyfigo/blob/main/LICENSE)
8
+ [![npm](https://img.shields.io/npm/v/tyfigo?color=crimson&logo=npm&style=flat-square)](https://www.npmjs.com/package/tyfigo)
9
9
 
10
10
  </div>
11
11
 
12
12
  > [!WARNING]
13
- > tyfig is in early development and not usable yet.
13
+ > tyfigo is in early development and not usable yet.
14
14
 
15
15
  ## Install
16
16
 
17
17
  ```bash
18
- npm i tyfig
18
+ npm i tyfigo
19
19
  ```
20
20
 
21
21
  ## Buy me some doughnuts
@@ -30,6 +30,6 @@ If you want to support me by donating, you can do so by using any of the followi
30
30
 
31
31
  Thanks goes to these wonderful people:
32
32
 
33
- <a href="https://github.com/imranbarbhuiya/tyfig/graphs/contributors">
34
- <img src="https://contrib.rocks/image?repo=imranbarbhuiya/tyfig" />
33
+ <a href="https://github.com/imranbarbhuiya/tyfigo/graphs/contributors">
34
+ <img src="https://contrib.rocks/image?repo=imranbarbhuiya/tyfigo" />
35
35
  </a>
package/dist/effect.d.mts CHANGED
@@ -1,13 +1,2 @@
1
- import { Effect } from "effect";
2
- declare const EmptyNameError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
3
- readonly _tag: "EmptyNameError";
4
- } & Readonly<A>;
5
- export declare class EmptyNameError extends EmptyNameError_base {}
6
- /**
7
- * Greets someone by name.
8
- *
9
- * Fails with {@link EmptyNameError} when the name is blank
10
- */
11
- export declare const greet: (name: string) => Effect.Effect<string, EmptyNameError, never>;
12
- export {};
13
- //# sourceMappingURL=effect.d.mts.map
1
+ import { a as Problem, c as Span, i as LocatedSpan, n as ResolvedConfig, o as ProblemCode, r as ResolvedLayer, s as Path, t as ResolveOptions } from "./index-DqgkSYnb.mjs";
2
+ export type { LocatedSpan, Path, Problem, ProblemCode, ResolveOptions, ResolvedConfig, ResolvedLayer, Span };
package/dist/effect.mjs CHANGED
@@ -1,16 +1 @@
1
- import { Data, Effect } from "effect";
2
- // src/effect.ts
3
- var EmptyNameError = class extends Data.TaggedError("EmptyNameError") {};
4
- /**
5
- * Greets someone by name.
6
- *
7
- * Fails with {@link EmptyNameError} when the name is blank
8
- */
9
- const greet = Effect.fn("greet")(function* (name) {
10
- const trimmed = name.trim();
11
- if (trimmed === "") return yield* new EmptyNameError();
12
- return `Hello, ${trimmed}!`;
13
- });
14
- export { EmptyNameError, greet };
15
-
16
- //# sourceMappingURL=effect.mjs.map
1
+ export {};
@@ -0,0 +1,102 @@
1
+ import "effect";
2
+ /**
3
+ * A key path into a config value. Strings are object keys and numbers are array indices.
4
+ */
5
+ type Path = readonly (string | number)[];
6
+ /**
7
+ * Where a key and its value sit in the source, in UTF-8 byte offsets.
8
+ *
9
+ * Array elements have no key, so their key span is the same as their value span. The root (`[]`) spans the whole document value.
10
+ */
11
+ interface Span {
12
+ readonly path: Path;
13
+ readonly keyStart: number;
14
+ readonly keyLength: number;
15
+ readonly valueStart: number;
16
+ readonly valueLength: number;
17
+ }
18
+ /**
19
+ * Spans keyed by {@link pathKey}.
20
+ */
21
+ type PositionMap = ReadonlyMap<string, Span>;
22
+ type ProblemCode = 'parse-error' | 'duplicate-key' | 'file-not-found' | 'read-error' | 'unsupported-file' | 'missing-variable' | 'invalid-placeholder' | 'unknown-key' | 'type-mismatch';
23
+ /**
24
+ * Something wrong with a config file. `start` and `length` are UTF-8 byte offsets, `line` and `column` are 1-based and
25
+ * `column` counts UTF-16 code units.
26
+ */
27
+ interface Problem {
28
+ readonly file: string;
29
+ readonly start: number;
30
+ readonly length: number;
31
+ readonly line: number;
32
+ readonly column: number;
33
+ readonly message: string;
34
+ readonly code: ProblemCode;
35
+ }
36
+ type EnvVariables = Readonly<Record<string, string | undefined>>;
37
+ type FormatName = 'yaml' | 'toml' | 'jsonc' | 'json5';
38
+ /**
39
+ * A parsed config file. `value` is `undefined` when the file could not be parsed at all. An empty file is `{}`.
40
+ */
41
+ interface ParseResult {
42
+ readonly value: unknown;
43
+ readonly positions: PositionMap;
44
+ readonly problems: readonly Problem[];
45
+ }
46
+ interface Format {
47
+ readonly name: FormatName;
48
+ readonly parse: (text: string, file?: string) => ParseResult;
49
+ /**
50
+ * Reads the text a whole-value placeholder resolved to with the format's scalar rules. Returns the text itself when it is not a
51
+ * number, boolean or null.
52
+ */
53
+ readonly parseScalar: (text: string) => unknown;
54
+ }
55
+ type LayerKind = 'base' | 'environment' | 'local' | 'environment-local';
56
+ /**
57
+ * A {@link Span} together with the file it is in.
58
+ */
59
+ interface LocatedSpan extends Span {
60
+ readonly file: string;
61
+ }
62
+ interface ResolveOptions {
63
+ /**
64
+ * The real environment variables, which win over every `.env` file. Defaults to a copy of the current ones.
65
+ */
66
+ readonly env?: EnvVariables | undefined;
67
+ /**
68
+ * The environment name that picks `app.<environment>.config.yaml` and `.env.<environment>`. Defaults to `env.NODE_ENV`.
69
+ */
70
+ readonly environment?: string | undefined;
71
+ }
72
+ interface ResolvedLayer {
73
+ readonly file: string;
74
+ readonly kind: LayerKind;
75
+ readonly text: string;
76
+ /**
77
+ * The parsed value with placeholders resolved, or `undefined` when the file could not be parsed.
78
+ */
79
+ readonly value: unknown;
80
+ readonly positions: PositionMap;
81
+ }
82
+ interface ResolvedConfig {
83
+ /**
84
+ * The base file, resolved to an absolute path.
85
+ */
86
+ readonly file: string;
87
+ readonly format: Format | undefined;
88
+ readonly environment: string | undefined;
89
+ /**
90
+ * The merged value, or `undefined` when the base file is missing or could not be parsed.
91
+ */
92
+ readonly value: unknown;
93
+ readonly layers: readonly ResolvedLayer[];
94
+ readonly envFiles: readonly string[];
95
+ /**
96
+ * Where each key path of `value` came from, keyed by `pathKey`.
97
+ */
98
+ readonly positions: ReadonlyMap<string, LocatedSpan>;
99
+ readonly problems: readonly Problem[];
100
+ }
101
+ export { Problem as a, Span as c, LocatedSpan as i, ResolvedConfig as n, ProblemCode as o, ResolvedLayer as r, Path as s, ResolveOptions as t };
102
+ //# sourceMappingURL=index-DqgkSYnb.d.mts.map
package/dist/index.d.mts CHANGED
@@ -1,10 +1,2 @@
1
- import { EmptyNameError } from "./effect.mjs";
2
- /**
3
- * Greets someone by name.
4
- *
5
- * @param name - The name to greet
6
- * @returns The greeting, or rejects with {@link EmptyNameError} when the name is blank
7
- */
8
- export declare const greet: (name: string) => Promise<string>;
9
- export { EmptyNameError };
10
- //# sourceMappingURL=index.d.mts.map
1
+ import { a as Problem, c as Span, i as LocatedSpan, n as ResolvedConfig, o as ProblemCode, r as ResolvedLayer, s as Path, t as ResolveOptions } from "./index-DqgkSYnb.mjs";
2
+ export type { LocatedSpan, Path, Problem, ProblemCode, ResolveOptions, ResolvedConfig, ResolvedLayer, Span };
package/dist/index.mjs CHANGED
@@ -1,13 +1 @@
1
- import { EmptyNameError, greet as greet$1 } from "./effect.mjs";
2
- import { Effect } from "effect";
3
- // src/index.ts
4
- /**
5
- * Greets someone by name.
6
- *
7
- * @param name - The name to greet
8
- * @returns The greeting, or rejects with {@link EmptyNameError} when the name is blank
9
- */
10
- const greet = (name) => Effect.runPromise(greet$1(name));
11
- export { EmptyNameError, greet };
12
-
13
- //# sourceMappingURL=index.mjs.map
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tyfigo",
3
- "version": "0.0.0",
3
+ "version": "0.1.0-next.4294ee4.0",
4
4
  "description": "Import YAML, TOML, JSON5, INI and .env files into TypeScript with full type inference",
5
5
  "keywords": [
6
6
  "config",
@@ -13,15 +13,15 @@
13
13
  "typescript",
14
14
  "yaml"
15
15
  ],
16
- "homepage": "https://github.com/imranbarbhuiya/tyfig#readme",
16
+ "homepage": "https://github.com/imranbarbhuiya/tyfigo#readme",
17
17
  "bugs": {
18
- "url": "https://github.com/imranbarbhuiya/tyfig/issues"
18
+ "url": "https://github.com/imranbarbhuiya/tyfigo/issues"
19
19
  },
20
20
  "license": "MIT",
21
21
  "author": "Parbez <imranbarbhuiya.fsd@gmail.com>",
22
22
  "repository": {
23
23
  "type": "git",
24
- "url": "git+https://github.com/imranbarbhuiya/tyfig.git"
24
+ "url": "git+https://github.com/imranbarbhuiya/tyfigo.git"
25
25
  },
26
26
  "files": [
27
27
  "dist"
@@ -57,7 +57,11 @@
57
57
  "prepare": "husky .github/husky && effect-tsgo patch --typescript --oxlint"
58
58
  },
59
59
  "dependencies": {
60
- "effect": "^4.0.6"
60
+ "effect": "^4.0.6",
61
+ "jsonc-eslint-parser": "^3.3.0",
62
+ "jsonc-parser": "^3.3.1",
63
+ "toml-eslint-parser": "^1.0.3",
64
+ "yaml": "^2.9.1"
61
65
  },
62
66
  "devDependencies": {
63
67
  "@commitlint/cli": "^21.2.4",
@@ -1 +0,0 @@
1
- {"version":3,"file":"effect.mjs","names":[],"sources":["../src/effect.ts"],"sourcesContent":["import { Data, Effect } from 'effect';\n\nexport class EmptyNameError extends Data.TaggedError('EmptyNameError') {}\n\n/**\n * Greets someone by name.\n *\n * Fails with {@link EmptyNameError} when the name is blank\n */\nexport const greet = Effect.fn('greet')(function* (name: string) {\n\tconst trimmed = name.trim();\n\tif (trimmed === '') return yield* new EmptyNameError();\n\treturn `Hello, ${trimmed}!`;\n});\n"],"mappings":";;AAEA,IAAa,iBAAb,cAAoC,KAAK,YAAY,gBAAgB,CAAC,CAAC,CAAC;;;;;;AAOxE,MAAa,QAAQ,OAAO,GAAG,OAAO,CAAC,CAAC,WAAW,MAAc;CAChE,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,YAAY,IAAI,OAAO,OAAO,IAAI,eAAe;CACrD,OAAO,UAAU,QAAQ;AAC1B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":["Greeter.greet"],"sources":["../src/index.ts"],"sourcesContent":["import { Effect } from 'effect';\n\nimport * as Greeter from './effect.ts';\n\nexport { EmptyNameError } from './effect.ts';\n\n/**\n * Greets someone by name.\n *\n * @param name - The name to greet\n * @returns The greeting, or rejects with {@link EmptyNameError} when the name is blank\n */\nexport const greet = (name: string): Promise<string> => Effect.runPromise(Greeter.greet(name));\n"],"mappings":";;;;;;;;;AAYA,MAAa,SAAS,SAAkC,OAAO,WAAWA,QAAc,IAAI,CAAC"}