Skip to content

Commit

Permalink
Split exports for wider runtime support
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Nov 5, 2024
1 parent 91ad426 commit 1275835
Show file tree
Hide file tree
Showing 33 changed files with 76 additions and 58 deletions.
12 changes: 12 additions & 0 deletions src/declare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export { bigInteger } from "./declaration/big-integer.js";
export { binary } from "./declaration/binary.js";
export { boolean } from "./declaration/boolean.js";
export { duration } from "./declaration/duration.js";
export { enumeration } from "./declaration/enumeration.js";
export { integer } from "./declaration/integer.js";
export { kubernetesAddress } from "./declaration/kubernetes-address.js";
export type { KubernetesAddress } from "./declaration/kubernetes-address.js";
export { networkPortNumber } from "./declaration/network-port-number.js";
export { number } from "./declaration/number.js";
export { string } from "./declaration/string.js";
export { url } from "./declaration/url.js";
12 changes: 0 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
export { bigInteger } from "./declaration/big-integer.js";
export { binary } from "./declaration/binary.js";
export { boolean } from "./declaration/boolean.js";
export { duration } from "./declaration/duration.js";
export { enumeration } from "./declaration/enumeration.js";
export { integer } from "./declaration/integer.js";
export { kubernetesAddress } from "./declaration/kubernetes-address.js";
export type { KubernetesAddress } from "./declaration/kubernetes-address.js";
export { networkPortNumber } from "./declaration/network-port-number.js";
export { number } from "./declaration/number.js";
export { string } from "./declaration/string.js";
export { url } from "./declaration/url.js";
export { initialize } from "./environment.js";
export type { OnInvalid } from "./environment.js";
2 changes: 1 addition & 1 deletion test/fixture/example/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
number,
string,
url,
} from "../../../src/index.js";
} from "../../../src/declare.js";

export const cdnUrl = url("CDN_URL", "CDN to use when serving static assets", {
protocols: ["http:", "https:"],
Expand Down
3 changes: 2 additions & 1 deletion test/suite/constraint/length.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { beforeEach, describe, expect, it } from "vitest";
import type { LengthConstraintSpec } from "../../../src/constraint/length.js";
import type { Declaration, Options } from "../../../src/declaration.js";
import { binary, string } from "../../../src/declare.js";
import type {
DeclarationExampleOptions,
Example,
} from "../../../src/example.js";
import { binary, initialize, string } from "../../../src/index.js";
import { initialize } from "../../../src/index.js";
import { toString } from "../../../src/schema.js";
import { noop } from "../../helpers.js";

Expand Down
12 changes: 6 additions & 6 deletions test/suite/constraint/range.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import {
type RangeConstraintSpec,
} from "../../../src/constraint/range.js";
import { Declaration, type Options } from "../../../src/declaration.js";
import type {
DeclarationExampleOptions,
Example,
} from "../../../src/example.js";
import {
bigInteger,
duration,
initialize,
integer,
networkPortNumber,
number,
} from "../../../src/index.js";
} from "../../../src/declare.js";
import type {
DeclarationExampleOptions,
Example,
} from "../../../src/example.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

const { Duration } = Temporal;
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/big-integer.spec-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expectTypeOf, it } from "vitest";
import { bigInteger, initialize } from "../../../src/index.js";
import { bigInteger } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

describe("Big integer declarations", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/big-integer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { beforeEach, describe, expect, it } from "vitest";
import { Declaration } from "../../../src/declaration.js";
import { Options } from "../../../src/declaration/big-integer.js";
import { bigInteger, initialize } from "../../../src/index.js";
import { bigInteger } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

const validValueTable = [
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/binary.spec-d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Buffer } from "buffer";
import { describe, expectTypeOf, it } from "vitest";
import { binary, initialize } from "../../../src/index.js";
import { binary } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

describe("Binary declarations", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/binary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Buffer } from "buffer";
import { beforeEach, describe, expect, it } from "vitest";
import { Declaration } from "../../../src/declaration.js";
import { Options } from "../../../src/declaration/binary.js";
import { binary, initialize } from "../../../src/index.js";
import { binary } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

const validValueTable = [
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/boolean.spec-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expectTypeOf, it } from "vitest";
import { boolean, initialize } from "../../../src/index.js";
import { boolean } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

describe("Boolean declarations", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/boolean.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { Declaration } from "../../../src/declaration.js";
import { Options } from "../../../src/declaration/boolean.js";
import { boolean, initialize } from "../../../src/index.js";
import { boolean } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

describe("Boolean declarations", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/duration.spec-d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Temporal } from "@js-temporal/polyfill";
import { describe, expectTypeOf, it } from "vitest";
import { duration, initialize } from "../../../src/index.js";
import { duration } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

const { Duration } = Temporal;
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/duration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Temporal } from "@js-temporal/polyfill";
import { beforeEach, describe, expect, it } from "vitest";
import { Declaration } from "../../../src/declaration.js";
import { Options } from "../../../src/declaration/duration.js";
import { duration, initialize } from "../../../src/index.js";
import { duration } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

const { Duration } = Temporal;
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/enumeration.spec-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expectTypeOf, it } from "vitest";
import { enumeration, initialize } from "../../../src/index.js";
import { enumeration } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

describe("Enumeration declarations", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/enumeration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { Declaration } from "../../../src/declaration.js";
import { Options } from "../../../src/declaration/enumeration.js";
import { enumeration, initialize } from "../../../src/index.js";
import { enumeration } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

describe("Enumeration declarations", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/integer.spec-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expectTypeOf, it } from "vitest";
import { initialize, integer } from "../../../src/index.js";
import { integer } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

describe("Integer declarations", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/integer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { beforeEach, describe, expect, it } from "vitest";
import { Declaration } from "../../../src/declaration.js";
import { Options } from "../../../src/declaration/integer.js";
import { initialize, integer } from "../../../src/index.js";
import { integer } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

const validValueTable = [
Expand Down
7 changes: 2 additions & 5 deletions test/suite/declaration/kubernetes-address.spec-d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { describe, expectTypeOf, it } from "vitest";
import {
KubernetesAddress,
initialize,
kubernetesAddress,
} from "../../../src/index.js";
import { KubernetesAddress, kubernetesAddress } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

describe("Kubernetes address declarations", () => {
Expand Down
7 changes: 2 additions & 5 deletions test/suite/declaration/kubernetes-address.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { beforeEach, describe, expect, it } from "vitest";
import { Declaration } from "../../../src/declaration.js";
import { Options } from "../../../src/declaration/kubernetes-address.js";
import {
KubernetesAddress,
initialize,
kubernetesAddress,
} from "../../../src/index.js";
import { KubernetesAddress, kubernetesAddress } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { quote } from "../../../src/shell.js";
import { noop } from "../../helpers.js";

Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/network-port-number.spec-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expectTypeOf, it } from "vitest";
import { initialize, networkPortNumber } from "../../../src/index.js";
import { networkPortNumber } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

describe("Network port number declarations", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/network-port-number.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { beforeEach, describe, expect, it } from "vitest";
import { Declaration } from "../../../src/declaration.js";
import { Options } from "../../../src/declaration/network-port-number.js";
import { initialize, networkPortNumber } from "../../../src/index.js";
import { networkPortNumber } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

const validValueTable = [
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/number.spec-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expectTypeOf, it } from "vitest";
import { initialize, number } from "../../../src/index.js";
import { number } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

describe("Number declarations", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/number.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { beforeEach, describe, expect, it } from "vitest";
import { Declaration } from "../../../src/declaration.js";
import { Options } from "../../../src/declaration/number.js";
import { initialize, number } from "../../../src/index.js";
import { number } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

const validValueTable = [
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/string.spec-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expectTypeOf, it } from "vitest";
import { initialize, string } from "../../../src/index.js";
import { string } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

describe("String declarations", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/string.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { beforeEach, describe, expect, it } from "vitest";
import { Declaration } from "../../../src/declaration.js";
import { Options } from "../../../src/declaration/string.js";
import { initialize, string } from "../../../src/index.js";
import { string } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

describe("String declarations", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/url.spec-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expectTypeOf, it } from "vitest";
import { initialize, url } from "../../../src/index.js";
import { url } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

describe("URL declarations", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/suite/declaration/url.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { beforeEach, describe, expect, it } from "vitest";
import { Declaration } from "../../../src/declaration.js";
import { Options } from "../../../src/declaration/url.js";
import { initialize, url } from "../../../src/index.js";
import { url } from "../../../src/declare.js";
import { initialize } from "../../../src/index.js";
import { noop } from "../../helpers.js";

const validValueTable = [
Expand Down
2 changes: 1 addition & 1 deletion test/suite/examples.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { integer } from "../../src/index.js";
import { integer } from "../../src/declare.js";

describe("Examples", () => {
describe("when a declaration example violates an intrinsic constraint", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/suite/initialize.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { beforeEach, describe, expect, it, vi, type Mock } from "vitest";
import { Declaration, Options } from "../../src/declaration.js";
import { boolean, string } from "../../src/declare.js";
import { NotSetError } from "../../src/error.js";
import { OnInvalid, boolean, initialize, string } from "../../src/index.js";
import { OnInvalid, initialize } from "../../src/index.js";
import { Results } from "../../src/validation.js";
import { MockConsole, createMockConsole } from "../helpers.js";

Expand Down
3 changes: 2 additions & 1 deletion test/suite/sensitive.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { beforeEach, describe, expect, it } from "vitest";
import { Declaration } from "../../src/declaration.js";
import { Options } from "../../src/declaration/binary.js";
import { binary, initialize } from "../../src/index.js";
import { binary } from "../../src/declare.js";
import { initialize } from "../../src/index.js";
import { noop } from "../helpers.js";

describe("Sensitive declarations", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/suite/specification-prettier.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
it,
vi,
} from "vitest";
import { initialize, url } from "../../src/index.js";
import { url } from "../../src/declare.js";
import { initialize } from "../../src/index.js";
import { MockConsole, createMockConsole } from "../helpers.js";

const fixturesPath = fileURLToPath(
Expand Down
4 changes: 2 additions & 2 deletions test/suite/specification.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
boolean,
duration,
enumeration,
initialize,
integer,
kubernetesAddress,
networkPortNumber,
number,
string,
url,
} from "../../src/index.js";
} from "../../src/declare.js";
import { initialize } from "../../src/index.js";
import { MockConsole, createMockConsole } from "../helpers.js";

const fixturesPath = fileURLToPath(
Expand Down
4 changes: 2 additions & 2 deletions test/suite/summary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
boolean,
duration,
enumeration,
initialize,
integer,
kubernetesAddress,
networkPortNumber,
number,
string,
url,
} from "../../src/index.js";
} from "../../src/declare.js";
import { initialize } from "../../src/index.js";
import { MockConsole, createMockConsole } from "../helpers.js";

const fixturesPath = fileURLToPath(
Expand Down

0 comments on commit 1275835

Please sign in to comment.