@specific.dev/spectest 0.26.0 → 0.28.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 +172 -0
  12. package/dist/components/k3s.js +1124 -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 +4611 -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 +1328 -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 +527 -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,172 @@
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
+ * Two values are **rejected** rather than silently ignored, because the
12
+ * component owns those decisions and passing them here has no effect:
13
+ * `--disable=traefik` (use `traefik: false`) and `--disable=servicelb`
14
+ * (use `loadBalancer: false`).
15
+ */
16
+ extraArgs?: string[];
17
+ /**
18
+ * Install the component's own Traefik ingress controller (hostNetwork,
19
+ * default IngressClass, wired to the in-VM CA when `ingressDomains` is
20
+ * set). Default `true`.
21
+ *
22
+ * Set `false` to run a cluster with no ingress controller at all — for
23
+ * a project that installs its own (via Helm, an operator, or a raw
24
+ * manifest) and wants the port to itself. The bundled k3s Traefik is
25
+ * disabled either way, so `false` really does mean none.
26
+ */
27
+ traefik?: boolean;
28
+ /**
29
+ * Run k3s's ServiceLB (klipper-lb) so `type: LoadBalancer` Services are
30
+ * assigned an address instead of sitting at `<pending>` forever.
31
+ * Default `true`.
32
+ *
33
+ * The assigned address is the **node IP** — the k3s container's own IP
34
+ * on `spectest-net` — so a LoadBalancer on port 8080 is reachable from
35
+ * a test or a peer service at `<cluster-key>.internal:8080`. Because
36
+ * klipper-lb binds the port on the node, a LoadBalancer that asks for
37
+ * port 80 or 443 collides with the component's hostNetwork Traefik;
38
+ * either pick another port or pass `traefik: false`.
39
+ */
40
+ loadBalancer?: boolean;
41
+ /**
42
+ * Readiness probe timeout in seconds. k3s on a warm image is ready in
43
+ * a few seconds; the first cold start of an env (image pull + cluster
44
+ * bootstrap) can take 30–60s. Default `120`.
45
+ */
46
+ readyTimeoutSecs?: number;
47
+ /**
48
+ * Run an in-cluster OCI registry (CNCF `distribution` / `registry:2`)
49
+ * that the cluster's own containerd trusts. This is the hermetic
50
+ * stand-in for a cloud registry (ECR/GCR/GHCR): a peer service builds
51
+ * an image, pushes it here over plain HTTP, references
52
+ * `<cluster-key>.internal:5000/...` from a Deployment, and the kubelet
53
+ * pulls it straight back. Lets you test a real
54
+ * `build → push → deploy → pull` pipeline with no external registry
55
+ * and no image pre-baking.
56
+ *
57
+ * **The registry's push/pull address is `<cluster-key>.internal:5000`**,
58
+ * where `<cluster-key>` is the key you give this service in the
59
+ * `services` map (e.g. a cluster at `services.cluster` is reachable at
60
+ * `cluster.internal:5000`). That's the cluster service's own
61
+ * unconditional `.internal` alias — peer-reachable and never clobbered
62
+ * by any `hostnames` you set — so it resolves identically from peer
63
+ * containers (push) and the cluster's own containerd (pull). Wire it
64
+ * into your platform, e.g. `env: { REGISTRY_URL: "cluster.internal:5000" }`.
65
+ * Plain HTTP, so configure your push client for an insecure registry.
66
+ *
67
+ * On by default. Set `false` for clusters that only ever run public
68
+ * images — that skips the extra pod.
69
+ */
70
+ registry?: boolean;
71
+ /**
72
+ * Domains to route into this cluster's ingress via **wildcard DNS**. For
73
+ * each `"example.com"`, spectest-resolver answers any `*.example.com`
74
+ * query with the cluster container's IP, where Traefik dispatches by Host
75
+ * to the matching Ingress. This lets a test `kubectl apply` an Ingress for
76
+ * any host under the domain and reach it immediately — no need to
77
+ * pre-declare each hostname in `hostnames`.
78
+ *
79
+ * ```ts
80
+ * services: { k8s: k3s({ ingressDomains: ["example.com"] }) }
81
+ * // a test then applies an Ingress for foo.example.com and fetches it.
82
+ * ```
83
+ *
84
+ * For one-off hosts not under a declared domain, a test can also register
85
+ * dynamically with `ctx.dnsName(host, { service: "k8s" })`.
86
+ *
87
+ * **TLS.** Setting `ingressDomains` also makes those domains reachable
88
+ * over **HTTPS**: Traefik gains a `:443` entrypoint and serves a default
89
+ * certificate minted from the in-VM root CA with SANs `*.<domain>` for
90
+ * each declared domain. The CA is already trusted by the test framework
91
+ * (Node `fetch`, `ctx.browser()`, Python, the system store), so
92
+ * `ctx.fetch("https://foo.example.com")` gets a clean handshake — no
93
+ * per-Ingress `spec.tls` and no `--insecure` needed. Only hosts **under**
94
+ * a declared domain are covered by the cert; static `hostnames` not under
95
+ * one (and one-off `ctx.dnsName` hosts) remain HTTP-only.
96
+ */
97
+ ingressDomains?: string[];
98
+ }
99
+ /**
100
+ * Rewrites a `@kubernetes/client-node` API class so each method's resolved
101
+ * value comes back **inspect-wrapped** ({@link Wrapped}) — exactly what
102
+ * `withTagging` does at runtime. The method *signatures* (argument types) are
103
+ * untouched; only the `Promise<R>` result becomes `Promise<Wrapped<R>>`, so
104
+ * `expect(pod.status.phase)` links to the API call with no cast and you
105
+ * `.unwrap()` before using a value as raw data. Non-method
106
+ * members pass through unchanged. Mirrors {@link RecordingSqlClient} on the
107
+ * postgres side.
108
+ */
109
+ type Tagged<T> = {
110
+ [K in keyof T]: T[K] extends (...args: infer A) => Promise<infer R> ? (...args: A) => Promise<Wrapped<R>> : T[K];
111
+ };
112
+ /**
113
+ * Pre-instantiated `@kubernetes/client-node` API clients sharing the
114
+ * same recording HTTP transport. Every method call lands on the test
115
+ * event log as an HTTP event alongside `fetch` calls, and its result is
116
+ * inspect-wrapped (see {@link Tagged}) so assertions on it stay linked.
117
+ */
118
+ export interface K3sClient {
119
+ core: Tagged<CoreV1Api>;
120
+ apps: Tagged<AppsV1Api>;
121
+ /** Generic object API — `create()`, `read()`, `patch()`, `delete()`
122
+ * against any Kubernetes resource (custom resources included). */
123
+ objects: Tagged<KubernetesObjectApi>;
124
+ }
125
+ /** Helpers a `k3s(...)` service exposes on `ctx.svc.<name>`. */
126
+ export interface K3sHelpers {
127
+ /**
128
+ * Fully-loaded `KubeConfig`. The cluster server URL is rewritten to
129
+ * `https://<service-name>.internal:6443`, the auto-assigned DNS name
130
+ * for this service on `spectest-net`. TLS verification is off because
131
+ * Bun's fetch doesn't honor an https.Agent's CA option (the client
132
+ * cert from the kubeconfig still flows through for auth), so the
133
+ * server's cert SAN list doesn't need to include the .internal name.
134
+ */
135
+ kubeconfig: KubeConfig;
136
+ /** Pre-built API clients. */
137
+ client: K3sClient;
138
+ /**
139
+ * Apply a (multi-document) YAML manifest. Each parsed document is
140
+ * created via `KubernetesObjectApi.create`. Returns the API server's
141
+ * response objects in input order — each element inspect-wrapped (the
142
+ * array container itself is plain), so `expect(created[0]!.metadata.uid)`
143
+ * links to its create call.
144
+ */
145
+ apply: (manifest: string) => Promise<Wrapped<KubernetesObject>[]>;
146
+ }
147
+ export declare function k3s(opts?: K3sOptions): {
148
+ readyCheck: {
149
+ type: "exec";
150
+ command: string;
151
+ timeoutSecs: number;
152
+ };
153
+ setup: ({ name, helpers }: {
154
+ name: string;
155
+ helpers: K3sHelpers;
156
+ }) => Promise<void>;
157
+ helpers: ({ name, exec }: ServiceHelpersContext) => Promise<K3sHelpers>;
158
+ files?: {
159
+ path: string;
160
+ content: string;
161
+ }[] | undefined;
162
+ image: {
163
+ type: "registry";
164
+ reference: string;
165
+ };
166
+ command: string;
167
+ privileged: true;
168
+ tmpfs: string[];
169
+ cgroupns: string;
170
+ ports: number[];
171
+ };
172
+ export {};