Conversation
🦋 Changeset detectedLatest commit: 62e5936 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. WalkthroughAdds a new public export Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant ArkEnv as "arkenv (package)"
participant Scope as "scope (internal)"
participant EnvType as "envType (schema)"
participant Runtime as "runtime (process.env)"
Dev->>ArkEnv: import { type } from "arkenv"
ArkEnv->>Scope: forward export ($.type)
Dev->>EnvType: const envType = type(schema)
Dev->>Runtime: provide env object (e.g., process.env)
Dev->>EnvType: envType.assert(runtime)
EnvType-->>Dev: validated & coerced config OR throws error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/www/content/docs/index.mdx (1)
38-39: Fix port range comment (0 is invalid per our validator and tests).- PORT: "number.port", // Ensures valid port number (0-65535) + PORT: "number.port", // Ensures valid port number (1-65535)
🧹 Nitpick comments (6)
.changeset/large-taxis-check.md (1)
25-25: Link the new guide from the changeset for discoverability.-This extends ArkType's `type` function with ArkEnv-specific validations for common environment variable patterns. +This extends ArkType's `type` function with ArkEnv-specific validations for common environment variable patterns. See the docs: [Type Function guide](/docs/guides/type-function).apps/www/content/docs/index.mdx (1)
15-15: Nice addition. Consider linking to the guide inline.-- 🛠️ **Type function**: Use `type()` to separate schema definition from validation +- 🛠️ **Type function**: Use `type()` to separate schema definition from validation ([learn more](/docs/guides/type-function))packages/arkenv/src/index.ts (1)
4-4: Re-export looks good; add a smoke test to ensuretypeis exposed from the top-level.Add this small test to
packages/arkenv/src/index.test.tsto guard the public API:it("should export `type` from the package entrypoint", () => { // Import from the index (package entry) // eslint-disable-next-line @typescript-eslint/no-var-requires const { type: arkenvType } = require("."); const schema = arkenvType({ PORT: "number.port" }); const result = schema.assert({ PORT: "3000" }); expect(result.PORT).toBe(3000); });packages/arkenv/src/type.ts (1)
1-3: Add TSDoc to clarify that this is ArkEnv-scoped ArkType.import { $ } from "./scope"; +/** + * ArkEnv-scoped ArkType `type` function. + * Provides `string.host`, `number.port`, and other ArkEnv-specific validators. + */ export const type = $.type;apps/www/content/docs/guides/type-function.mdx (1)
125-146: Add a small “Defaults” subsection to mirror Quickstart and show= 'default'usage.## Advanced Usage ### Optional Fields @@ const env = type({ REQUIRED: "string", OPTIONAL: "string?", PORT: "number.port?", }); @@ }); + +### Defaults + +You can provide defaults for optional fields: + +```ts +const env = type({ + LOG_LEVEL: "'debug' | 'info' | 'warn' | 'error' = 'info'", +}); + +const result = env.assert({}); +// result.LOG_LEVEL === "info" +```packages/arkenv/src/type.test.ts (1)
1-3: IncludeexpectTypeOfand add a couple of lightweight type and failure tests.-import { describe, expect, it } from "vitest"; +import { describe, expect, it, expectTypeOf } from "vitest";Additional tests (append near the end):
it("should infer precise types from schema", () => { const envType = type({ HOST: "string.host", PORT: "number.port", OPTIONAL: "string?", }); const res = envType.assert({ HOST: "localhost", PORT: "3000" }); expectTypeOf(res.HOST).toEqualTypeOf<string>(); expectTypeOf(res.PORT).toEqualTypeOf<number>(); expectTypeOf(res.OPTIONAL).toEqualTypeOf<string | undefined>(); }); it("should fail invalid array members", () => { const envType = type({ ALLOWED_ORIGINS: "string[]" }); expect(() => envType.assert({ ALLOWED_ORIGINS: ["ok.com", 123 as unknown as string] }) ).toThrow(); });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
.changeset/large-taxis-check.md(1 hunks)apps/www/content/docs/guides/type-function.mdx(1 hunks)apps/www/content/docs/index.mdx(1 hunks)apps/www/content/docs/meta.json(1 hunks)apps/www/content/docs/quickstart.mdx(1 hunks)packages/arkenv/src/index.ts(1 hunks)packages/arkenv/src/type.test.ts(1 hunks)packages/arkenv/src/type.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Use built-in validators (host, port, url, email, etc.) when available in environment schemas
Provide default values for optional environment variables in schemas
Files:
packages/arkenv/src/type.tspackages/arkenv/src/type.test.tspackages/arkenv/src/index.ts
**/*.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.test.ts: Place tests alongside source files using the .test.ts suffix
Use Vitest's describe/it structure in tests
Test both success and failure cases for each feature
Mock process.env in tests and restore it after each test to isolate scenarios
Verify both runtime behavior and TypeScript types in tests
Files:
packages/arkenv/src/type.test.ts
🧠 Learnings (4)
📚 Learning: 2025-09-10T19:39:49.841Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-10T19:39:49.841Z
Learning: Applies to **/*.{ts,tsx} : Use built-in validators (host, port, url, email, etc.) when available in environment schemas
Applied to files:
apps/www/content/docs/index.mdxpackages/arkenv/src/type.test.ts
📚 Learning: 2025-09-10T19:39:49.841Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-10T19:39:49.841Z
Learning: Applies to **/*.test.ts : Verify both runtime behavior and TypeScript types in tests
Applied to files:
packages/arkenv/src/type.test.ts
📚 Learning: 2025-09-10T19:39:49.841Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-10T19:39:49.841Z
Learning: Applies to **/*.test.ts : Use Vitest's describe/it structure in tests
Applied to files:
packages/arkenv/src/type.test.ts
📚 Learning: 2025-09-10T19:39:49.841Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-10T19:39:49.841Z
Learning: Applies to **/*.{ts,tsx} : Provide default values for optional environment variables in schemas
Applied to files:
packages/arkenv/src/index.ts
🧬 Code graph analysis (6)
.changeset/large-taxis-check.md (3)
packages/arkenv/src/scope.test.ts (6)
envType(33-44)stringType(46-50)hostType(5-9)hostType(11-15)it(4-51)hostType(17-20)packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/index.test.ts (2)
expectTypeOf(32-39)process(53-63)
packages/arkenv/src/type.ts (2)
packages/arkenv/src/scope.ts (1)
$(9-18)packages/arkenv/src/scope.test.ts (6)
stringType(46-50)hostType(11-15)hostType(5-9)envType(33-44)it(4-51)portType(22-26)
apps/www/content/docs/quickstart.mdx (1)
apps/www/components/ui/card.tsx (1)
Card(6-8)
packages/arkenv/src/type.test.ts (3)
packages/arkenv/src/type.ts (1)
type(3-3)packages/arkenv/src/scope.test.ts (4)
envType(33-44)stringType(46-50)it(4-51)hostType(5-9)packages/arkenv/src/types.test.ts (2)
it(23-37)it(4-21)
apps/www/content/docs/guides/type-function.mdx (3)
packages/arkenv/src/scope.test.ts (5)
stringType(46-50)envType(33-44)hostType(5-9)it(4-51)hostType(11-15)packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/index.test.ts (2)
expectTypeOf(32-39)beforeEach(15-98)
packages/arkenv/src/index.ts (1)
packages/arkenv/src/index.test.ts (8)
process(81-97)process(53-63)expect(27-30)process(41-51)vi(21-25)process(16-19)arkenv(66-69)createEnv(74-77)
🔇 Additional comments (3)
.changeset/large-taxis-check.md (1)
5-23: Changelog entry is clear and actionable.Example matches the new API surface and reads well.
apps/www/content/docs/meta.json (1)
9-10: Nav entry added in the right section. LGTM.apps/www/content/docs/quickstart.mdx (1)
121-125: Card addition is spot-on.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## arkenv@0.6.0 ### Minor Changes - #### Expose `type` function _[`#139`](#139) [`721c014`](721c014) [@yamcodes](https://github.com/yamcodes)_ ArkEnv now exposes a `type` function with built-in ArkEnv scope, providing access to environment-specific types like `string.host` and `number.port`. ```ts import { type } from "arkenv"; const env = type({ NODE_ENV: "string", HOST: "string.host", PORT: "number.port", }); const result = env.assert({ NODE_ENV: "development", HOST: "localhost", PORT: "3000", }); ``` This extends ArkType's `type` function with ArkEnv-specific validations for common environment variable patterns. ## @arkenv/vite-plugin@0.0.9 ### Patch Changes <details><summary>Updated 1 dependency</summary> <small> [`721c014`](721c014) </small> - `arkenv@0.6.0` </details> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary by CodeRabbit
New Features
Documentation
Tests
Chores