@plasius/schema 1.1.0 → 1.1.1

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 (58) hide show
  1. package/dist/index.cjs +1934 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +391 -0
  4. package/dist/index.d.ts +391 -0
  5. package/dist/index.js +1883 -0
  6. package/dist/index.js.map +1 -0
  7. package/package.json +18 -6
  8. package/.eslintrc.cjs +0 -7
  9. package/.github/workflows/cd.yml +0 -236
  10. package/.github/workflows/ci.yml +0 -16
  11. package/.nvmrc +0 -1
  12. package/.vscode/launch.json +0 -15
  13. package/CHANGELOG.md +0 -120
  14. package/CODE_OF_CONDUCT.md +0 -79
  15. package/CONTRIBUTING.md +0 -201
  16. package/CONTRIBUTORS.md +0 -27
  17. package/SECURITY.md +0 -17
  18. package/docs/adrs/adr-0001: schema.md +0 -45
  19. package/docs/adrs/adr-template.md +0 -67
  20. package/legal/CLA-REGISTRY.csv +0 -2
  21. package/legal/CLA.md +0 -22
  22. package/legal/CORPORATE_CLA.md +0 -57
  23. package/legal/INDIVIDUAL_CLA.md +0 -91
  24. package/sbom.cdx.json +0 -66
  25. package/src/components.ts +0 -39
  26. package/src/field.builder.ts +0 -239
  27. package/src/field.ts +0 -153
  28. package/src/index.ts +0 -7
  29. package/src/infer.ts +0 -34
  30. package/src/pii.ts +0 -165
  31. package/src/schema.ts +0 -893
  32. package/src/types.ts +0 -156
  33. package/src/validation/countryCode.ISO3166.ts +0 -256
  34. package/src/validation/currencyCode.ISO4217.ts +0 -191
  35. package/src/validation/dateTime.ISO8601.ts +0 -60
  36. package/src/validation/email.RFC5322.ts +0 -9
  37. package/src/validation/generalText.OWASP.ts +0 -39
  38. package/src/validation/index.ts +0 -13
  39. package/src/validation/languageCode.BCP47.ts +0 -299
  40. package/src/validation/name.OWASP.ts +0 -25
  41. package/src/validation/percentage.ISO80000-1.ts +0 -8
  42. package/src/validation/phone.E.164.ts +0 -9
  43. package/src/validation/richtext.OWASP.ts +0 -34
  44. package/src/validation/url.WHATWG.ts +0 -16
  45. package/src/validation/user.MS-GOOGLE-APPLE.ts +0 -31
  46. package/src/validation/uuid.RFC4122.ts +0 -10
  47. package/src/validation/version.SEMVER2.0.0.ts +0 -10
  48. package/tests/field.builder.test.ts +0 -81
  49. package/tests/fields.test.ts +0 -213
  50. package/tests/pii.test.ts +0 -139
  51. package/tests/schema.test.ts +0 -501
  52. package/tests/test-utils.ts +0 -97
  53. package/tests/validate.test.ts +0 -97
  54. package/tests/validation.test.ts +0 -98
  55. package/tsconfig.build.json +0 -19
  56. package/tsconfig.json +0 -7
  57. package/tsup.config.ts +0 -10
  58. 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
- });