@plasius/schema 1.1.0 → 1.2.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.
Files changed (59) hide show
  1. package/README.md +31 -18
  2. package/dist/index.cjs +2370 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +627 -0
  5. package/dist/index.d.ts +627 -0
  6. package/dist/index.js +2308 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +18 -6
  9. package/.eslintrc.cjs +0 -7
  10. package/.github/workflows/cd.yml +0 -236
  11. package/.github/workflows/ci.yml +0 -16
  12. package/.nvmrc +0 -1
  13. package/.vscode/launch.json +0 -15
  14. package/CHANGELOG.md +0 -120
  15. package/CODE_OF_CONDUCT.md +0 -79
  16. package/CONTRIBUTING.md +0 -201
  17. package/CONTRIBUTORS.md +0 -27
  18. package/SECURITY.md +0 -17
  19. package/docs/adrs/adr-0001: schema.md +0 -45
  20. package/docs/adrs/adr-template.md +0 -67
  21. package/legal/CLA-REGISTRY.csv +0 -2
  22. package/legal/CLA.md +0 -22
  23. package/legal/CORPORATE_CLA.md +0 -57
  24. package/legal/INDIVIDUAL_CLA.md +0 -91
  25. package/sbom.cdx.json +0 -66
  26. package/src/components.ts +0 -39
  27. package/src/field.builder.ts +0 -239
  28. package/src/field.ts +0 -153
  29. package/src/index.ts +0 -7
  30. package/src/infer.ts +0 -34
  31. package/src/pii.ts +0 -165
  32. package/src/schema.ts +0 -893
  33. package/src/types.ts +0 -156
  34. package/src/validation/countryCode.ISO3166.ts +0 -256
  35. package/src/validation/currencyCode.ISO4217.ts +0 -191
  36. package/src/validation/dateTime.ISO8601.ts +0 -60
  37. package/src/validation/email.RFC5322.ts +0 -9
  38. package/src/validation/generalText.OWASP.ts +0 -39
  39. package/src/validation/index.ts +0 -13
  40. package/src/validation/languageCode.BCP47.ts +0 -299
  41. package/src/validation/name.OWASP.ts +0 -25
  42. package/src/validation/percentage.ISO80000-1.ts +0 -8
  43. package/src/validation/phone.E.164.ts +0 -9
  44. package/src/validation/richtext.OWASP.ts +0 -34
  45. package/src/validation/url.WHATWG.ts +0 -16
  46. package/src/validation/user.MS-GOOGLE-APPLE.ts +0 -31
  47. package/src/validation/uuid.RFC4122.ts +0 -10
  48. package/src/validation/version.SEMVER2.0.0.ts +0 -10
  49. package/tests/field.builder.test.ts +0 -81
  50. package/tests/fields.test.ts +0 -213
  51. package/tests/pii.test.ts +0 -139
  52. package/tests/schema.test.ts +0 -501
  53. package/tests/test-utils.ts +0 -97
  54. package/tests/validate.test.ts +0 -97
  55. package/tests/validation.test.ts +0 -98
  56. package/tsconfig.build.json +0 -19
  57. package/tsconfig.json +0 -7
  58. package/tsup.config.ts +0 -10
  59. package/vitest.config.js +0 -20
@@ -1,98 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import {
3
- validateEmail,
4
- validatePhone,
5
- validateUrl,
6
- validateUUID,
7
- validateDateTimeISO,
8
- validateCountryCode,
9
- validateCurrencyCode,
10
- } from "../src/validation";
11
-
12
- describe("validateEmail", () => {
13
- it("accepts valid emails", () => {
14
- expect(validateEmail("test@example.com")).toBe(true);
15
- expect(validateEmail("user.name+tag+sorting@example.co.uk")).toBe(true);
16
- });
17
-
18
- it("rejects invalid emails", () => {
19
- expect(validateEmail("not-an-email")).toBe(false);
20
- expect(validateEmail("user@com")).toBe(false);
21
- });
22
- });
23
-
24
- describe("validatePhone", () => {
25
- it("accepts valid E.164 phones", () => {
26
- expect(validatePhone("+14155552671")).toBe(true);
27
- expect(validatePhone("+447911123456")).toBe(true);
28
- });
29
-
30
- it("rejects invalid phones", () => {
31
- expect(validatePhone("123456")).toBe(false);
32
- expect(validatePhone("0044123456789")).toBe(false);
33
- });
34
- });
35
-
36
- describe("validateUrl", () => {
37
- it("accepts valid URLs", () => {
38
- expect(validateUrl("https://example.com")).toBe(true);
39
- expect(validateUrl("http://www.example.co.uk/path")).toBe(true);
40
- });
41
-
42
- it("rejects invalid URLs", () => {
43
- expect(validateUrl("ftp://example.com")).toBe(false);
44
- expect(validateUrl("www.example.com")).toBe(false);
45
- expect(validateUrl("not-a-url")).toBe(false);
46
- });
47
- });
48
-
49
- describe("validateUUID", () => {
50
- it("accepts valid UUIDs", () => {
51
- expect(validateUUID("123e4567-e89b-12d3-a456-426614174000")).toBe(true);
52
- });
53
-
54
- it("rejects invalid UUIDs", () => {
55
- expect(validateUUID("not-a-uuid")).toBe(false);
56
- expect(validateUUID("123456")).toBe(false);
57
- });
58
- });
59
-
60
- describe("validateDateTimeISO", () => {
61
- it("accepts valid ISO dates", () => {
62
- const now = new Date().toISOString();
63
- expect(validateDateTimeISO(now)).toBe(true);
64
- });
65
-
66
- it("rejects invalid dates", () => {
67
- expect(validateDateTimeISO("not-a-date")).toBe(false);
68
- expect(validateDateTimeISO("2023-13-01T00:00:00Z")).toBe(false); // invalid month
69
- });
70
- });
71
-
72
- describe("validateCountryCode", () => {
73
- it("accepts valid country codes", () => {
74
- expect(validateCountryCode("GB")).toBe(true);
75
- expect(validateCountryCode("US")).toBe(true);
76
- expect(validateCountryCode("FR")).toBe(true);
77
- });
78
-
79
- it("rejects invalid country codes", () => {
80
- expect(validateCountryCode("XX")).toBe(false);
81
- expect(validateCountryCode("")).toBe(false);
82
- expect(validateCountryCode("gb")).toBe(true); // case insensitive
83
- });
84
- });
85
-
86
- describe("validateCurrencyCode", () => {
87
- it("accepts valid currency codes", () => {
88
- expect(validateCurrencyCode("USD")).toBe(true);
89
- expect(validateCurrencyCode("EUR")).toBe(true);
90
- expect(validateCurrencyCode("GBP")).toBe(true);
91
- });
92
-
93
- it("rejects invalid currency codes", () => {
94
- expect(validateCurrencyCode("XXX")).toBe(true); // XXX is a valid ISO placeholder currency!
95
- expect(validateCurrencyCode("ABC")).toBe(false);
96
- expect(validateCurrencyCode("usd")).toBe(true); // case insensitive
97
- });
98
- });
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "esnext",
4
- "module": "NodeNext",
5
- "lib": ["ESNext", "DOM"],
6
- "moduleResolution": "NodeNext",
7
- "types": ["node", "vitest"],
8
- "declaration": true,
9
- "sourceMap": true,
10
- "strict": true,
11
- "noUncheckedIndexedAccess": true,
12
- "noImplicitOverride": true,
13
- "noFallthroughCasesInSwitch": true,
14
- "resolveJsonModule": true,
15
- "outDir": "dist",
16
- "forceConsistentCasingInFileNames": true
17
- },
18
- "include": ["src"]
19
- }
package/tsconfig.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "./tsconfig.build.json",
3
- "compilerOptions": {
4
- "noEmit": true
5
- },
6
- "include": ["src", "test"]
7
- }
package/tsup.config.ts DELETED
@@ -1,10 +0,0 @@
1
- import { defineConfig } from "tsup";
2
-
3
- export default defineConfig({
4
- entry: ["src/index.ts"],
5
- dts: true,
6
- sourcemap: true,
7
- clean: true,
8
- format: ["esm", "cjs"],
9
- target: "es2022",
10
- });
package/vitest.config.js DELETED
@@ -1,20 +0,0 @@
1
- import { defineConfig } from "vitest/config";
2
-
3
- export default defineConfig({
4
- test: {
5
- environment: "node",
6
- globals: true,
7
- include: ["tests/**/*.test.{ts,tsx}"],
8
- coverage: {
9
- provider: "v8",
10
- reporter: ["text", "lcov"],
11
- reportsDirectory: "./coverage",
12
- exclude: [
13
- "tests/**",
14
- "dist/**",
15
- "**/*.config.{js,ts}",
16
- "**/.eslintrc.{js,cjs}",
17
- ],
18
- },
19
- },
20
- });