@specific.dev/spectest 0.26.0 → 0.27.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 (74) hide show
  1. package/dist/aws-sigv4.d.ts +42 -0
  2. package/dist/aws-sigv4.js +166 -0
  3. package/dist/browser.d.ts +314 -0
  4. package/dist/browser.js +1320 -0
  5. package/dist/components/email.d.ts +135 -0
  6. package/dist/components/email.js +271 -0
  7. package/dist/components/expo.d.ts +69 -0
  8. package/dist/components/expo.js +125 -0
  9. package/dist/components/index.d.ts +8 -0
  10. package/dist/components/index.js +18 -0
  11. package/dist/components/k3s.d.ts +143 -0
  12. package/dist/components/k3s.js +1067 -0
  13. package/dist/components/postgres.d.ts +93 -0
  14. package/dist/components/postgres.js +58 -0
  15. package/dist/components/replayFake.d.ts +169 -0
  16. package/dist/components/replayFake.js +738 -0
  17. package/dist/components/s3.d.ts +99 -0
  18. package/dist/components/s3.js +81 -0
  19. package/dist/components/supabase.d.ts +197 -0
  20. package/dist/components/supabase.js +1003 -0
  21. package/dist/daemon.d.ts +1 -0
  22. package/dist/daemon.js +4223 -0
  23. package/dist/ids.d.ts +2 -0
  24. package/{src/ids.ts → dist/ids.js} +46 -50
  25. package/dist/index.d.ts +1183 -0
  26. package/dist/index.js +769 -0
  27. package/dist/ingress.d.ts +114 -0
  28. package/dist/ingress.js +210 -0
  29. package/dist/inspect.d.ts +228 -0
  30. package/dist/inspect.js +429 -0
  31. package/dist/locator.d.ts +260 -0
  32. package/dist/locator.js +293 -0
  33. package/dist/mobile.d.ts +71 -0
  34. package/dist/mobile.js +65 -0
  35. package/dist/record-secrets.d.ts +9 -0
  36. package/{src/record-secrets.ts → dist/record-secrets.js} +13 -15
  37. package/dist/recorder.d.ts +516 -0
  38. package/dist/recorder.js +219 -0
  39. package/dist/redis.d.ts +54 -0
  40. package/dist/redis.js +126 -0
  41. package/dist/replay-bundle.d.ts +38 -0
  42. package/{src/replay-bundle.ts → dist/replay-bundle.js} +29 -47
  43. package/dist/resolver.d.ts +1 -0
  44. package/dist/resolver.js +309 -0
  45. package/dist/s3.d.ts +89 -0
  46. package/dist/s3.js +198 -0
  47. package/dist/sql.d.ts +74 -0
  48. package/dist/sql.js +151 -0
  49. package/dist/terminal.d.ts +161 -0
  50. package/dist/terminal.js +538 -0
  51. package/package.json +24 -9
  52. package/src/browser.ts +0 -1819
  53. package/src/components/email.ts +0 -398
  54. package/src/components/expo.ts +0 -167
  55. package/src/components/index.ts +0 -63
  56. package/src/components/k3s.ts +0 -1312
  57. package/src/components/postgres.ts +0 -105
  58. package/src/components/replayFake.ts +0 -848
  59. package/src/components/s3.ts +0 -132
  60. package/src/components/supabase.ts +0 -1299
  61. package/src/daemon.ts +0 -4969
  62. package/src/index.ts +0 -2350
  63. package/src/ingress.ts +0 -288
  64. package/src/inspect.ts +0 -673
  65. package/src/locator.ts +0 -594
  66. package/src/mobile.ts +0 -133
  67. package/src/recorder.ts +0 -817
  68. package/src/redis.ts +0 -202
  69. package/src/resolver.ts +0 -351
  70. package/src/s3.ts +0 -333
  71. package/src/sql.ts +0 -243
  72. package/src/terminal.ts +0 -740
  73. package/src/vendor/rrweb-plugin-console-record.umd.js +0 -521
  74. package/src/vendor/rrweb-record.min.js +0 -5061
@@ -0,0 +1,143 @@
1
+ import { AppsV1Api, CoreV1Api, KubeConfig, KubernetesObjectApi, type KubernetesObject } from "@kubernetes/client-node";
2
+ import type { ServiceHelpersContext } from "../index.js";
3
+ import type { Wrapped } from "../inspect.js";
4
+ export interface K3sOptions {
5
+ /** Image tag for the official `rancher/k3s` image. Default `"v1.30.6-k3s1"`. */
6
+ version?: string;
7
+ /**
8
+ * Extra arguments appended to `k3s server`. Useful for `--tls-san=...`,
9
+ * additional `--disable=<addon>`, custom CIDRs, etc.
10
+ */
11
+ extraArgs?: string[];
12
+ /**
13
+ * Readiness probe timeout in seconds. k3s on a warm image is ready in
14
+ * a few seconds; the first cold start of an env (image pull + cluster
15
+ * bootstrap) can take 30–60s. Default `120`.
16
+ */
17
+ readyTimeoutSecs?: number;
18
+ /**
19
+ * Run an in-cluster OCI registry (CNCF `distribution` / `registry:2`)
20
+ * that the cluster's own containerd trusts. This is the hermetic
21
+ * stand-in for a cloud registry (ECR/GCR/GHCR): a peer service builds
22
+ * an image, pushes it here over plain HTTP, references
23
+ * `<cluster-key>.internal:5000/...` from a Deployment, and the kubelet
24
+ * pulls it straight back. Lets you test a real
25
+ * `build → push → deploy → pull` pipeline with no external registry
26
+ * and no image pre-baking.
27
+ *
28
+ * **The registry's push/pull address is `<cluster-key>.internal:5000`**,
29
+ * where `<cluster-key>` is the key you give this service in the
30
+ * `services` map (e.g. a cluster at `services.cluster` is reachable at
31
+ * `cluster.internal:5000`). That's the cluster service's own
32
+ * unconditional `.internal` alias — peer-reachable and never clobbered
33
+ * by any `hostnames` you set — so it resolves identically from peer
34
+ * containers (push) and the cluster's own containerd (pull). Wire it
35
+ * into your platform, e.g. `env: { REGISTRY_URL: "cluster.internal:5000" }`.
36
+ * Plain HTTP, so configure your push client for an insecure registry.
37
+ *
38
+ * On by default. Set `false` for clusters that only ever run public
39
+ * images — that skips the extra pod.
40
+ */
41
+ registry?: boolean;
42
+ /**
43
+ * Domains to route into this cluster's ingress via **wildcard DNS**. For
44
+ * each `"example.com"`, spectest-resolver answers any `*.example.com`
45
+ * query with the cluster container's IP, where Traefik dispatches by Host
46
+ * to the matching Ingress. This lets a test `kubectl apply` an Ingress for
47
+ * any host under the domain and reach it immediately — no need to
48
+ * pre-declare each hostname in `hostnames`.
49
+ *
50
+ * ```ts
51
+ * services: { k8s: k3s({ ingressDomains: ["example.com"] }) }
52
+ * // a test then applies an Ingress for foo.example.com and fetches it.
53
+ * ```
54
+ *
55
+ * For one-off hosts not under a declared domain, a test can also register
56
+ * dynamically with `ctx.dnsName(host, { service: "k8s" })`.
57
+ *
58
+ * **TLS.** Setting `ingressDomains` also makes those domains reachable
59
+ * over **HTTPS**: Traefik gains a `:443` entrypoint and serves a default
60
+ * certificate minted from the in-VM root CA with SANs `*.<domain>` for
61
+ * each declared domain. The CA is already trusted by the test framework
62
+ * (Node `fetch`, `ctx.browser()`, Python, the system store), so
63
+ * `ctx.fetch("https://foo.example.com")` gets a clean handshake — no
64
+ * per-Ingress `spec.tls` and no `--insecure` needed. Only hosts **under**
65
+ * a declared domain are covered by the cert; static `hostnames` not under
66
+ * one (and one-off `ctx.dnsName` hosts) remain HTTP-only.
67
+ */
68
+ ingressDomains?: string[];
69
+ }
70
+ /**
71
+ * Rewrites a `@kubernetes/client-node` API class so each method's resolved
72
+ * value comes back **inspect-wrapped** ({@link Wrapped}) — exactly what
73
+ * `withTagging` does at runtime. The method *signatures* (argument types) are
74
+ * untouched; only the `Promise<R>` result becomes `Promise<Wrapped<R>>`, so
75
+ * `expect(pod.status.phase)` links to the API call with no cast and you
76
+ * `.unwrap()` before using a value as raw data. Non-method
77
+ * members pass through unchanged. Mirrors {@link RecordingSqlClient} on the
78
+ * postgres side.
79
+ */
80
+ type Tagged<T> = {
81
+ [K in keyof T]: T[K] extends (...args: infer A) => Promise<infer R> ? (...args: A) => Promise<Wrapped<R>> : T[K];
82
+ };
83
+ /**
84
+ * Pre-instantiated `@kubernetes/client-node` API clients sharing the
85
+ * same recording HTTP transport. Every method call lands on the test
86
+ * event log as an HTTP event alongside `fetch` calls, and its result is
87
+ * inspect-wrapped (see {@link Tagged}) so assertions on it stay linked.
88
+ */
89
+ export interface K3sClient {
90
+ core: Tagged<CoreV1Api>;
91
+ apps: Tagged<AppsV1Api>;
92
+ /** Generic object API — `create()`, `read()`, `patch()`, `delete()`
93
+ * against any Kubernetes resource (custom resources included). */
94
+ objects: Tagged<KubernetesObjectApi>;
95
+ }
96
+ /** Helpers a `k3s(...)` service exposes on `ctx.svc.<name>`. */
97
+ export interface K3sHelpers {
98
+ /**
99
+ * Fully-loaded `KubeConfig`. The cluster server URL is rewritten to
100
+ * `https://<service-name>.internal:6443`, the auto-assigned DNS name
101
+ * for this service on `spectest-net`. TLS verification is off because
102
+ * Bun's fetch doesn't honor an https.Agent's CA option (the client
103
+ * cert from the kubeconfig still flows through for auth), so the
104
+ * server's cert SAN list doesn't need to include the .internal name.
105
+ */
106
+ kubeconfig: KubeConfig;
107
+ /** Pre-built API clients. */
108
+ client: K3sClient;
109
+ /**
110
+ * Apply a (multi-document) YAML manifest. Each parsed document is
111
+ * created via `KubernetesObjectApi.create`. Returns the API server's
112
+ * response objects in input order — each element inspect-wrapped (the
113
+ * array container itself is plain), so `expect(created[0]!.metadata.uid)`
114
+ * links to its create call.
115
+ */
116
+ apply: (manifest: string) => Promise<Wrapped<KubernetesObject>[]>;
117
+ }
118
+ export declare function k3s(opts?: K3sOptions): {
119
+ readyCheck: {
120
+ type: "exec";
121
+ command: string;
122
+ timeoutSecs: number;
123
+ };
124
+ setup: ({ name, helpers }: {
125
+ name: string;
126
+ helpers: K3sHelpers;
127
+ }) => Promise<void>;
128
+ helpers: ({ name, exec }: ServiceHelpersContext) => Promise<K3sHelpers>;
129
+ files?: {
130
+ path: string;
131
+ content: string;
132
+ }[] | undefined;
133
+ image: {
134
+ type: "registry";
135
+ reference: string;
136
+ };
137
+ command: string;
138
+ privileged: true;
139
+ tmpfs: string[];
140
+ cgroupns: string;
141
+ ports: number[];
142
+ };
143
+ export {};