@kasoa/env 0.0.9 → 0.0.10

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
@@ -18,10 +18,7 @@ const env = defineEnv(
18
18
  v.object({
19
19
  DATABASE_URL: v.pipe(v.string(), v.url()),
20
20
  PORT: v.pipe(v.string(), v.transform(Number)),
21
- NODE_ENV: v.optional(
22
- v.picklist(["development", "production"]),
23
- "development",
24
- ),
21
+ NODE_ENV: v.optional(v.picklist(["development", "production"]), "development"),
25
22
  }),
26
23
  );
27
24
 
@@ -0,0 +1,2 @@
1
+ export { node as default } from "@kasoa/oxlint-config/node";
2
+ //# sourceMappingURL=oxlint.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oxlint.config.d.ts","sourceRoot":"","sources":["../oxlint.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1 @@
1
+ export { node as default } from "@kasoa/oxlint-config/node";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,gBAAgB,IAC7C,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AAElC,wBAAgB,SAAS,CAAC,CAAC,SAAS,gBAAgB,EAClD,MAAM,EAAE,CAAC,EACT,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,QAAQ,CAAC,CAAC,CAAC,CAab"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,gBAAgB,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AAEnF,wBAAgB,SAAS,CAAC,CAAC,SAAS,gBAAgB,EAClD,MAAM,EAAE,CAAC,EACT,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,QAAQ,CAAC,CAAC,CAAC,CAab"}
package/dist/src/index.js CHANGED
@@ -25,7 +25,5 @@ function formatIssues(issues) {
25
25
  return `Environment validation failed:\n\n${lines.join("\n")}`;
26
26
  }
27
27
  function getPathString(path) {
28
- return path
29
- .map((segment) => (typeof segment === "object" ? segment.key : segment))
30
- .join(".");
28
+ return path.map((segment) => (typeof segment === "object" ? segment.key : segment)).join(".");
31
29
  }
package/package.json CHANGED
@@ -1,33 +1,33 @@
1
1
  {
2
2
  "name": "@kasoa/env",
3
- "version": "0.0.9",
4
- "type": "module",
5
- "license": "MIT",
3
+ "version": "0.0.10",
6
4
  "description": "Type-safe environment variable validation using Standard Schema",
7
5
  "keywords": [
8
6
  "env",
9
7
  "environment",
10
- "validation",
8
+ "kasoa",
11
9
  "standard-schema",
12
- "kasoa"
10
+ "validation"
13
11
  ],
12
+ "homepage": "https://github.com/emmanuelchucks/kasoa/tree/main/packages/env",
13
+ "bugs": {
14
+ "url": "https://github.com/emmanuelchucks/kasoa/issues"
15
+ },
16
+ "license": "MIT",
14
17
  "author": {
15
18
  "name": "Emmanuel Chucks",
16
19
  "email": "hi@emmanuelchucks.com",
17
20
  "url": "https://emmanuelchucks.com"
18
21
  },
19
- "homepage": "https://github.com/emmanuelchucks/kasoa/tree/main/packages/env",
20
22
  "repository": {
21
23
  "type": "git",
22
24
  "url": "git+https://github.com/emmanuelchucks/kasoa.git",
23
25
  "directory": "packages/env"
24
26
  },
25
- "bugs": {
26
- "url": "https://github.com/emmanuelchucks/kasoa/issues"
27
- },
28
27
  "files": [
29
28
  "dist"
30
29
  ],
30
+ "type": "module",
31
31
  "exports": {
32
32
  ".": "./dist/src/index.js"
33
33
  },
@@ -38,15 +38,15 @@
38
38
  "@standard-schema/spec": "^1.1.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@types/node": "^25.2.3",
42
- "@typescript/native-preview": "^7.0.0-dev.20260211.1",
43
- "eslint": "^9.39.2",
44
- "prettier": "^3.8.1",
41
+ "@types/node": "^25.3.0",
42
+ "@typescript/native-preview": "^7.0.0-dev.20260223.1",
43
+ "oxfmt": "^0.35.0",
44
+ "oxlint": "^1.50.0",
45
+ "oxlint-tsgolint": "^0.14.2",
45
46
  "valibot": "^1.2.0",
46
47
  "vitest": "^4.0.18",
47
- "@kasoa/eslint-config": "0.0.26",
48
- "@kasoa/prettier-config": "0.0.11",
49
- "@kasoa/tsconfig": "0.0.0"
48
+ "@kasoa/oxfmt-config": "0.0.3",
49
+ "@kasoa/oxlint-config": "0.0.3"
50
50
  },
51
51
  "engines": {
52
52
  "node": ">=24"
@@ -54,8 +54,8 @@
54
54
  "scripts": {
55
55
  "dev": "tsgo --watch",
56
56
  "build": "tsgo",
57
- "lint": "eslint --fix --cache .",
58
- "format": "prettier --write --cache --experimental-cli .",
57
+ "lint": "oxlint --type-aware --fix .",
58
+ "format": "oxfmt -c ./node_modules/@kasoa/oxfmt-config/configs/base.json .",
59
59
  "typecheck": "tsgo --noEmit",
60
60
  "test": "vitest run"
61
61
  }
@@ -1,2 +0,0 @@
1
- export { node as default } from "@kasoa/eslint-config/node";
2
- //# sourceMappingURL=eslint.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"eslint.config.d.ts","sourceRoot":"","sources":["../eslint.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,2BAA2B,CAAC"}
@@ -1 +0,0 @@
1
- export { node as default } from "@kasoa/eslint-config/node";
@@ -1,2 +0,0 @@
1
- export { base as default } from "@kasoa/prettier-config/base";
2
- //# sourceMappingURL=prettier.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prettier.config.d.ts","sourceRoot":"","sources":["../prettier.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,6BAA6B,CAAC"}
@@ -1 +0,0 @@
1
- export { base as default } from "@kasoa/prettier-config/base";
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=define-env.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"define-env.test.d.ts","sourceRoot":"","sources":["../../src/define-env.test.ts"],"names":[],"mappings":""}
@@ -1,82 +0,0 @@
1
- import * as v from "valibot";
2
- import { describe, expect, it } from "vitest";
3
- import { defineEnv } from "./index.js";
4
- describe("defineEnv()", () => {
5
- it("returns validated env object", () => {
6
- expect.assertions(1);
7
- const schema = v.object({
8
- DATABASE_URL: v.string(),
9
- PORT: v.pipe(v.string(), v.toNumber()),
10
- });
11
- const env = defineEnv(schema, {
12
- DATABASE_URL: "postgres://localhost",
13
- PORT: "3000",
14
- });
15
- expect(env).toStrictEqual({
16
- DATABASE_URL: "postgres://localhost",
17
- PORT: 3000,
18
- });
19
- });
20
- it("throws on missing required variable", () => {
21
- expect.assertions(2);
22
- const schema = v.object({
23
- DATABASE_URL: v.string(),
24
- });
25
- expect(() => defineEnv(schema, {})).toThrowError("Environment validation failed");
26
- expect(() => defineEnv(schema, {})).toThrowError("DATABASE_URL");
27
- });
28
- it("treats empty string as undefined", () => {
29
- expect.assertions(1);
30
- const schema = v.object({
31
- API_KEY: v.string(),
32
- });
33
- expect(() => defineEnv(schema, { API_KEY: "" })).toThrowError("Environment validation failed");
34
- });
35
- it("supports optional variables with defaults", () => {
36
- expect.assertions(1);
37
- const schema = v.object({
38
- PORT: v.optional(v.string(), "3000"),
39
- });
40
- const env = defineEnv(schema, {});
41
- expect(env.PORT).toBe("3000");
42
- });
43
- it("validates nested paths correctly", () => {
44
- expect.assertions(1);
45
- const schema = v.object({
46
- DATABASE_URL: v.pipe(v.string(), v.url()),
47
- });
48
- expect(() => defineEnv(schema, { DATABASE_URL: "not-a-url" })).toThrowError("DATABASE_URL");
49
- });
50
- it("throws TypeError for async schemas", () => {
51
- expect.assertions(2);
52
- const asyncSchema = {
53
- "~standard": {
54
- vendor: "test",
55
- version: 1,
56
- validate: () => Promise.resolve({ value: {} }),
57
- },
58
- };
59
- expect(() => defineEnv(asyncSchema, {})).toThrowError(TypeError);
60
- expect(() => defineEnv(asyncSchema, {})).toThrowError("Async schema validation is not supported");
61
- });
62
- it("uses process.env by default", () => {
63
- expect.assertions(1);
64
- const originalEnv = process.env.TEST_VAR;
65
- process.env.TEST_VAR = "test-value";
66
- try {
67
- const schema = v.object({
68
- TEST_VAR: v.string(),
69
- });
70
- const env = defineEnv(schema);
71
- expect(env.TEST_VAR).toBe("test-value");
72
- }
73
- finally {
74
- if (originalEnv === undefined) {
75
- delete process.env.TEST_VAR;
76
- }
77
- else {
78
- process.env.TEST_VAR = originalEnv;
79
- }
80
- }
81
- });
82
- });