@lovrozagar/oat 0.1.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 (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +401 -0
  3. package/bin/oat.js +2 -0
  4. package/dist/cli.js +386 -0
  5. package/dist/config/define-config.d.ts +165 -0
  6. package/dist/config/define-config.d.ts.map +1 -0
  7. package/dist/config/define-config.js +24 -0
  8. package/dist/config/define-config.js.map +1 -0
  9. package/dist/config/load.d.ts +10 -0
  10. package/dist/config/load.d.ts.map +1 -0
  11. package/dist/config/load.js +61 -0
  12. package/dist/config/load.js.map +1 -0
  13. package/dist/index.d.ts +17 -0
  14. package/dist/index.js +9 -0
  15. package/dist/reference/defects.d.ts +254 -0
  16. package/dist/reference/defects.d.ts.map +1 -0
  17. package/dist/reference/defects.js +265 -0
  18. package/dist/reference/defects.js.map +1 -0
  19. package/dist/reference/dialect.d.ts +104 -0
  20. package/dist/reference/dialect.d.ts.map +1 -0
  21. package/dist/reference/dialect.js +174 -0
  22. package/dist/reference/dialect.js.map +1 -0
  23. package/dist/reference/http.d.ts +79 -0
  24. package/dist/reference/http.d.ts.map +1 -0
  25. package/dist/reference/http.js +889 -0
  26. package/dist/reference/http.js.map +1 -0
  27. package/dist/reference/model.d.ts +56 -0
  28. package/dist/reference/model.d.ts.map +1 -0
  29. package/dist/reference/model.js +156 -0
  30. package/dist/reference/model.js.map +1 -0
  31. package/dist/reference/query.d.ts +45 -0
  32. package/dist/reference/query.d.ts.map +1 -0
  33. package/dist/reference/query.js +353 -0
  34. package/dist/reference/query.js.map +1 -0
  35. package/dist/reference/spec.d.ts +13 -0
  36. package/dist/reference/spec.d.ts.map +1 -0
  37. package/dist/reference/spec.js +547 -0
  38. package/dist/reference/spec.js.map +1 -0
  39. package/dist/reference/store-api.d.ts +59 -0
  40. package/dist/reference/store-api.d.ts.map +1 -0
  41. package/dist/reference/store-api.js +76 -0
  42. package/dist/reference/store-api.js.map +1 -0
  43. package/dist/reference/stores/memory.d.ts +27 -0
  44. package/dist/reference/stores/memory.d.ts.map +1 -0
  45. package/dist/reference/stores/memory.js +97 -0
  46. package/dist/reference/stores/memory.js.map +1 -0
  47. package/dist/reference/stores/postgres.d.ts +61 -0
  48. package/dist/reference/stores/postgres.d.ts.map +1 -0
  49. package/dist/reference/stores/postgres.js +406 -0
  50. package/dist/reference/stores/postgres.js.map +1 -0
  51. package/dist/reference/stores/sqlite-driver.d.ts +54 -0
  52. package/dist/reference/stores/sqlite-driver.d.ts.map +1 -0
  53. package/dist/reference/stores/sqlite-driver.js +99 -0
  54. package/dist/reference/stores/sqlite-driver.js.map +1 -0
  55. package/dist/reference/stores/sqlite.d.ts +68 -0
  56. package/dist/reference/stores/sqlite.d.ts.map +1 -0
  57. package/dist/reference/stores/sqlite.js +464 -0
  58. package/dist/reference/stores/sqlite.js.map +1 -0
  59. package/dist/report/console.d.ts +33 -0
  60. package/dist/report/console.d.ts.map +1 -0
  61. package/dist/report/console.js +237 -0
  62. package/dist/report/console.js.map +1 -0
  63. package/dist/report/matrix.d.ts +131 -0
  64. package/dist/report/matrix.d.ts.map +1 -0
  65. package/dist/report/matrix.js +865 -0
  66. package/dist/report/matrix.js.map +1 -0
  67. package/dist/report/render.d.ts +66 -0
  68. package/dist/report/render.d.ts.map +1 -0
  69. package/dist/report/render.js +423 -0
  70. package/dist/report/render.js.map +1 -0
  71. package/dist/runtime/async.d.ts +34 -0
  72. package/dist/runtime/async.d.ts.map +1 -0
  73. package/dist/runtime/async.js +130 -0
  74. package/dist/runtime/async.js.map +1 -0
  75. package/dist/runtime/auth.d.ts +46 -0
  76. package/dist/runtime/auth.d.ts.map +1 -0
  77. package/dist/runtime/auth.js +236 -0
  78. package/dist/runtime/auth.js.map +1 -0
  79. package/dist/runtime/checks.d.ts +89 -0
  80. package/dist/runtime/checks.d.ts.map +1 -0
  81. package/dist/runtime/checks.js +3400 -0
  82. package/dist/runtime/checks.js.map +1 -0
  83. package/dist/runtime/client.d.ts +65 -0
  84. package/dist/runtime/client.d.ts.map +1 -0
  85. package/dist/runtime/client.js +122 -0
  86. package/dist/runtime/client.js.map +1 -0
  87. package/dist/runtime/finding.d.ts +50 -0
  88. package/dist/runtime/finding.d.ts.map +1 -0
  89. package/dist/runtime/finding.js +50 -0
  90. package/dist/runtime/finding.js.map +1 -0
  91. package/dist/runtime/fixture.d.ts +20 -0
  92. package/dist/runtime/fixture.d.ts.map +1 -0
  93. package/dist/runtime/fixture.js +175 -0
  94. package/dist/runtime/fixture.js.map +1 -0
  95. package/dist/runtime/progress.d.ts +41 -0
  96. package/dist/runtime/progress.d.ts.map +1 -0
  97. package/dist/runtime/progress.js +186 -0
  98. package/dist/runtime/progress.js.map +1 -0
  99. package/dist/runtime/run.d.ts +69 -0
  100. package/dist/runtime/run.d.ts.map +1 -0
  101. package/dist/runtime/run.js +575 -0
  102. package/dist/runtime/run.js.map +1 -0
  103. package/dist/runtime/teardown.d.ts +38 -0
  104. package/dist/runtime/teardown.d.ts.map +1 -0
  105. package/dist/runtime/teardown.js +129 -0
  106. package/dist/runtime/teardown.js.map +1 -0
  107. package/dist/runtime/validate.d.ts +31 -0
  108. package/dist/runtime/validate.d.ts.map +1 -0
  109. package/dist/runtime/validate.js +111 -0
  110. package/dist/runtime/validate.js.map +1 -0
  111. package/dist/runtime/world.d.ts +49 -0
  112. package/dist/runtime/world.d.ts.map +1 -0
  113. package/dist/runtime/world.js +119 -0
  114. package/dist/runtime/world.js.map +1 -0
  115. package/dist/spec/collection.d.ts +31 -0
  116. package/dist/spec/collection.d.ts.map +1 -0
  117. package/dist/spec/collection.js +121 -0
  118. package/dist/spec/collection.js.map +1 -0
  119. package/dist/spec/conventions.d.ts +103 -0
  120. package/dist/spec/conventions.d.ts.map +1 -0
  121. package/dist/spec/conventions.js +275 -0
  122. package/dist/spec/conventions.js.map +1 -0
  123. package/dist/spec/extensions.d.ts +74 -0
  124. package/dist/spec/extensions.d.ts.map +1 -0
  125. package/dist/spec/extensions.js +335 -0
  126. package/dist/spec/extensions.js.map +1 -0
  127. package/dist/spec/graph.d.ts +89 -0
  128. package/dist/spec/graph.d.ts.map +1 -0
  129. package/dist/spec/graph.js +318 -0
  130. package/dist/spec/graph.js.map +1 -0
  131. package/dist/spec/load.d.ts +36 -0
  132. package/dist/spec/load.d.ts.map +1 -0
  133. package/dist/spec/load.js +166 -0
  134. package/dist/spec/load.js.map +1 -0
  135. package/dist/spec/types.d.ts +57 -0
  136. package/dist/spec/types.d.ts.map +1 -0
  137. package/dist/spec/types.js +24 -0
  138. package/dist/spec/types.js.map +1 -0
  139. package/labs/README.md +130 -0
  140. package/labs/annotated-openapi.yaml +311 -0
  141. package/labs/anyrow.config.ts +107 -0
  142. package/labs/demo.mjs +124 -0
  143. package/labs/local.config.ts +41 -0
  144. package/labs/minimal.config.ts +32 -0
  145. package/package.json +80 -0
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Points at the demo API that ships with oat, so this runs end to end with no setup.
3
+ *
4
+ * oat serve # terminal 1 — prints a url
5
+ * oat run --config labs/local.config.ts --base-url <that url>
6
+ *
7
+ * Real configs import from "@lovrozagar/oat"; this one uses a relative path because it lives inside the
8
+ * repository.
9
+ */
10
+
11
+ import { defineConfig } from "../dist/index.js"
12
+
13
+ /* Overridden by --base-url, which is what `oat serve` prints. */
14
+ const API = process.env.OAT_BASE_URL ?? "http://127.0.0.1:8787"
15
+
16
+ export default defineConfig({
17
+ baseUrl: API,
18
+ principals: [
19
+ {
20
+ auth: {
21
+ credentialFrom: "$.access_token",
22
+ steps: [{ body: { key: "key_alpha" }, operationId: "auth.token" }],
23
+ },
24
+ id: "alpha",
25
+ roots: { project_id: "proj_alpha" },
26
+ },
27
+ /* A second principal in a different tenant — this is what makes the isolation checks
28
+ * possible. Without one they are skipped rather than silently passed. */
29
+ {
30
+ auth: {
31
+ credentialFrom: "$.access_token",
32
+ steps: [{ body: { key: "key_beta" }, operationId: "auth.token" }],
33
+ },
34
+ id: "beta",
35
+ roots: { project_id: "proj_beta" },
36
+ },
37
+ ],
38
+ seed: 42,
39
+ /* Relative to baseUrl — oat also accepts an absolute URL or a filesystem path. */
40
+ spec: "/v1/openapi/spec",
41
+ })
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The smallest useful config: a long-lived API key, no login flow.
3
+ *
4
+ * A principal without an `auth` flow authenticates by static header, so nothing needs acquiring.
5
+ * The second principal is optional — but it is what makes the tenant-isolation checks possible;
6
+ * without one they are skipped rather than silently passed.
7
+ *
8
+ * oat run --config labs/minimal.config.ts
9
+ *
10
+ * Written as `from "../dist/index.js"` only because this file lives inside the repository —
11
+ * in your own project it is `from "@lovrozagar/oat"`.
12
+ */
13
+
14
+ import { defineConfig } from "../dist/index.js"
15
+
16
+ export default defineConfig({
17
+ baseUrl: "https://api.example.com",
18
+ principals: [
19
+ {
20
+ headers: { authorization: `Bearer ${process.env.API_TOKEN ?? ""}` },
21
+ id: "alpha",
22
+ /* Path parameters oat cannot create for itself. */
23
+ roots: { project_id: process.env.PROJECT_A ?? "" },
24
+ },
25
+ {
26
+ headers: { authorization: `Bearer ${process.env.API_TOKEN_B ?? ""}` },
27
+ id: "beta",
28
+ roots: { project_id: process.env.PROJECT_B ?? "" },
29
+ },
30
+ ],
31
+ spec: "https://api.example.com/openapi.json",
32
+ })
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@lovrozagar/oat",
3
+ "version": "0.1.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "OpenAPI Tester — behavioural testing of a live backend against its OpenAPI specification",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/lovrozagar/oat.git"
12
+ },
13
+ "homepage": "https://github.com/lovrozagar/oat#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/lovrozagar/oat/issues"
16
+ },
17
+ "author": "lovrozagar",
18
+ "type": "module",
19
+ "engines": {
20
+ "node": ">=20"
21
+ },
22
+ "bin": {
23
+ "oat": "./bin/oat.js"
24
+ },
25
+ "main": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "default": "./dist/index.js"
31
+ }
32
+ },
33
+ "files": [
34
+ "bin/oat.js",
35
+ "dist/cli.js",
36
+ "dist/index.js",
37
+ "dist/index.d.ts",
38
+ "dist/config",
39
+ "dist/reference",
40
+ "dist/report",
41
+ "dist/runtime",
42
+ "dist/spec",
43
+ "README.md",
44
+ "LICENSE",
45
+ "labs/annotated-openapi.yaml",
46
+ "labs/local.config.ts",
47
+ "labs/minimal.config.ts",
48
+ "labs/anyrow.config.ts",
49
+ "labs/demo.mjs",
50
+ "labs/README.md"
51
+ ],
52
+ "scripts": {
53
+ "build": "tsc -p tsconfig.json",
54
+ "dev": "tsc -p tsconfig.json --watch",
55
+ "check": "tsc -p tsconfig.json --noEmit",
56
+ "test": "npm run build && node --experimental-sqlite dist/cli.js conformance",
57
+ "conformance": "node --experimental-sqlite dist/cli.js conformance",
58
+ "demo": "npm run build && node labs/demo.mjs",
59
+ "labs": "node --experimental-strip-types labs/serve.ts",
60
+ "labs:sweep": "bash labs/sweep.sh",
61
+ "prepublishOnly": "npm run build"
62
+ },
63
+ "keywords": [
64
+ "openapi",
65
+ "testing",
66
+ "contract-testing",
67
+ "api",
68
+ "swagger"
69
+ ],
70
+ "dependencies": {
71
+ "ajv": "^8.17.1",
72
+ "ajv-formats": "^3.0.1",
73
+ "yaml": "^2.9.0"
74
+ },
75
+ "devDependencies": {
76
+ "@types/node": "^22.10.0",
77
+ "postgres": "^3.4.9",
78
+ "typescript": "^5.7.2"
79
+ }
80
+ }