@namzu/sandbox 18.1.1 → 19.0.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.
- package/CHANGELOG.md +85 -0
- package/README.md +35 -5
- package/dist/backends/docker/index.d.ts +46 -1
- package/dist/backends/docker/index.d.ts.map +1 -1
- package/dist/backends/docker/index.js +187 -51
- package/dist/backends/docker/index.js.map +1 -1
- package/dist/egress/index.d.ts +1 -0
- package/dist/egress/index.d.ts.map +1 -1
- package/dist/egress/index.js +1 -0
- package/dist/egress/index.js.map +1 -1
- package/dist/egress/profile-wiring.d.ts +40 -0
- package/dist/egress/profile-wiring.d.ts.map +1 -0
- package/dist/egress/profile-wiring.js +75 -0
- package/dist/egress/profile-wiring.js.map +1 -0
- package/dist/egress/profile.d.ts +153 -0
- package/dist/egress/profile.d.ts.map +1 -0
- package/dist/egress/profile.js +244 -0
- package/dist/egress/profile.js.map +1 -0
- package/dist/egress/proxy.d.ts +16 -0
- package/dist/egress/proxy.d.ts.map +1 -1
- package/dist/egress/proxy.js +37 -3
- package/dist/egress/proxy.js.map +1 -1
- package/dist/index.d.ts +19 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/seed/index.d.ts +165 -0
- package/dist/seed/index.d.ts.map +1 -0
- package/dist/seed/index.js +505 -0
- package/dist/seed/index.js.map +1 -0
- package/dist/testing/sandbox-conformance.d.ts +30 -1
- package/dist/testing/sandbox-conformance.d.ts.map +1 -1
- package/dist/testing/sandbox-conformance.js +18 -0
- package/dist/testing/sandbox-conformance.js.map +1 -1
- package/package.json +3 -3
- package/src/backends/docker/index.ts +246 -51
- package/src/egress/index.ts +1 -0
- package/src/egress/profile-wiring.ts +125 -0
- package/src/egress/profile.ts +380 -0
- package/src/egress/proxy.ts +53 -3
- package/src/index.ts +54 -5
- package/src/seed/index.ts +710 -0
- package/src/testing/sandbox-conformance.ts +52 -6
|
@@ -71,12 +71,29 @@ import type {
|
|
|
71
71
|
TerminalSession,
|
|
72
72
|
} from '@namzu/sdk'
|
|
73
73
|
|
|
74
|
-
import
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
import { ensureSandboxSeed } from '../seed/index.js'
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The runner shapes the suite takes, declared here rather than imported.
|
|
78
|
+
* `@namzu/sdk/testing` exported them beside the checkpoint-store suite, and
|
|
79
|
+
* that suite and these exports went with it; they are structurally the
|
|
80
|
+
* same types, so a runner written against either still fits.
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/** The assertions the suite uses, and nothing more. */
|
|
84
|
+
interface ConformanceAssertion {
|
|
85
|
+
toBe(expected: unknown): void
|
|
86
|
+
toEqual(expected: unknown): void
|
|
87
|
+
toBeGreaterThan(expected: number): void
|
|
88
|
+
toMatch(expected: RegExp): void
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Shape of the `expect` a runner supplies. */
|
|
92
|
+
type ConformanceExpect = (actual: unknown) => ConformanceAssertion
|
|
93
|
+
/** Shape of the `it` a runner supplies. */
|
|
94
|
+
type ConformanceIt = (name: string, body: () => Promise<void>) => unknown
|
|
95
|
+
/** Shape of the `describe` a runner supplies. */
|
|
96
|
+
type ConformanceDescribe = (name: string, body: () => void) => unknown
|
|
80
97
|
|
|
81
98
|
/**
|
|
82
99
|
* The contract revision these assertions express. Carried on the describe
|
|
@@ -172,6 +189,14 @@ export interface SandboxConformanceOptions {
|
|
|
172
189
|
* capability.
|
|
173
190
|
*/
|
|
174
191
|
readonly supportsRangedAndStreamedReads?: boolean
|
|
192
|
+
/**
|
|
193
|
+
* A git repository the guest can clone, and an absolute directory to
|
|
194
|
+
* clone it under, for the `ensureSandboxSeed` case. Absent (the default),
|
|
195
|
+
* the case is a named skip: this suite cannot assume a guest has git or a
|
|
196
|
+
* route to any repository. The URL follows the seed's own rules (`https://`,
|
|
197
|
+
* or `http://` for a proxy-brokered host, no credentials).
|
|
198
|
+
*/
|
|
199
|
+
readonly seed?: { readonly url: string; readonly root: string }
|
|
175
200
|
}
|
|
176
201
|
|
|
177
202
|
/** Assert `call()` rejects. The contract cares that admission was refused, never the message. */
|
|
@@ -1194,6 +1219,27 @@ export function defineSandboxConformance(options: SandboxConformanceOptions): vo
|
|
|
1194
1219
|
)
|
|
1195
1220
|
})
|
|
1196
1221
|
})
|
|
1222
|
+
|
|
1223
|
+
describe(`${label} seed`, () => {
|
|
1224
|
+
const seedOption = options.seed
|
|
1225
|
+
const title = 'prepares a seed once, and a second call finds it present at the same commit'
|
|
1226
|
+
it(
|
|
1227
|
+
seedOption === undefined ? `${title} (skipped: no seed repository was given)` : title,
|
|
1228
|
+
seedOption === undefined
|
|
1229
|
+
? async () => {}
|
|
1230
|
+
: withSandbox(async (sandbox) => {
|
|
1231
|
+
const seed = {
|
|
1232
|
+
name: 'conformance',
|
|
1233
|
+
repositories: [{ name: 'repo', url: seedOption.url }],
|
|
1234
|
+
}
|
|
1235
|
+
const first = await ensureSandboxSeed(sandbox, seed, { root: seedOption.root })
|
|
1236
|
+
expect(first.repositories[0]?.status).toBe('cloned')
|
|
1237
|
+
const second = await ensureSandboxSeed(sandbox, seed, { root: seedOption.root })
|
|
1238
|
+
expect(second.repositories[0]?.status).toBe('present')
|
|
1239
|
+
expect(second.repositories[0]?.commit).toBe(first.repositories[0]?.commit)
|
|
1240
|
+
}),
|
|
1241
|
+
)
|
|
1242
|
+
})
|
|
1197
1243
|
}
|
|
1198
1244
|
|
|
1199
1245
|
// Re-exported so a caller building a recording harness (as this suite's own
|