freestyle-sandboxes 0.1.37 → 0.1.38
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/index.cjs +14 -6
- package/index.d.cts +29 -16
- package/index.d.mts +29 -16
- package/index.mjs +14 -6
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -5947,8 +5947,9 @@ function composeVmTemplates(templates) {
|
|
|
5947
5947
|
);
|
|
5948
5948
|
const mergedWith = {};
|
|
5949
5949
|
for (const template of templates) {
|
|
5950
|
-
|
|
5951
|
-
|
|
5950
|
+
const builders = template.with ?? {};
|
|
5951
|
+
for (const key in builders) {
|
|
5952
|
+
const builder = builders[key];
|
|
5952
5953
|
if (builder) {
|
|
5953
5954
|
mergedWith[key] = builder;
|
|
5954
5955
|
}
|
|
@@ -5984,8 +5985,9 @@ function composeVmSpecs(specs) {
|
|
|
5984
5985
|
const mergedWithDiscriminators = {};
|
|
5985
5986
|
for (const spec of specs) {
|
|
5986
5987
|
const builderDiscriminators = spec.getBuilderDiscriminators();
|
|
5987
|
-
|
|
5988
|
-
|
|
5988
|
+
const builders = spec.builders ?? {};
|
|
5989
|
+
for (const key in builders) {
|
|
5990
|
+
const builder = builders[key];
|
|
5989
5991
|
if (builder) {
|
|
5990
5992
|
mergedWith[key] = builder;
|
|
5991
5993
|
mergedWithDiscriminators[key] = builderDiscriminators[key];
|
|
@@ -6402,7 +6404,9 @@ class VmSpec {
|
|
|
6402
6404
|
}
|
|
6403
6405
|
snapshot() {
|
|
6404
6406
|
const { snapshot: existingSnapshot, ...currentLayer } = this.raw;
|
|
6405
|
-
const currentBuilders = {
|
|
6407
|
+
const currentBuilders = {
|
|
6408
|
+
...this.builders
|
|
6409
|
+
};
|
|
6406
6410
|
const currentWithDiscriminators = this.getBuilderDiscriminators();
|
|
6407
6411
|
const innerSnapshot = new VmSpec({
|
|
6408
6412
|
...currentLayer,
|
|
@@ -6756,7 +6760,11 @@ class VmsNamespace {
|
|
|
6756
6760
|
...rawTemplate ?? {},
|
|
6757
6761
|
baseImage: serializedBaseImage
|
|
6758
6762
|
} : rawTemplate;
|
|
6759
|
-
const {
|
|
6763
|
+
const {
|
|
6764
|
+
baseImage: _baseImage,
|
|
6765
|
+
template: _template,
|
|
6766
|
+
...requestConfig
|
|
6767
|
+
} = config;
|
|
6760
6768
|
const response = await this.freestyle._apiClient.post("/v1/vms", {
|
|
6761
6769
|
body: {
|
|
6762
6770
|
...requestConfig,
|
package/index.d.cts
CHANGED
|
@@ -12125,12 +12125,25 @@ declare class Systemd {
|
|
|
12125
12125
|
* This is the instance attached to the VM after creation.
|
|
12126
12126
|
*/
|
|
12127
12127
|
declare class VmWithInstance {
|
|
12128
|
-
|
|
12128
|
+
vm: Vm;
|
|
12129
12129
|
private _init;
|
|
12130
12130
|
}
|
|
12131
|
-
|
|
12132
|
-
|
|
12133
|
-
|
|
12131
|
+
interface VmWithLike<TInstance = unknown, TAddedFields extends Record<string, VmWithLike<any, any, any>> = {}, TDefaultField extends string = string> {
|
|
12132
|
+
instance: TInstance;
|
|
12133
|
+
readonly defaultField?: TDefaultField;
|
|
12134
|
+
configure?(existingConfig: any): any;
|
|
12135
|
+
configureSpec?(spec: any): any;
|
|
12136
|
+
configureSnapshotSpec?(spec: any): any;
|
|
12137
|
+
configureBaseImage?(image: any): any;
|
|
12138
|
+
configureTemplate?(template: any): any;
|
|
12139
|
+
configureNestedTemplate?(template: any): any;
|
|
12140
|
+
createInstance(): TInstance;
|
|
12141
|
+
}
|
|
12142
|
+
type VmWithDefaultField<B extends VmWithLike> = B extends {
|
|
12143
|
+
defaultField?: infer TDefaultField;
|
|
12144
|
+
} ? Extract<TDefaultField, string> extends never ? string : Extract<TDefaultField, string> : string;
|
|
12145
|
+
type VmWithDefaultFieldRecord<B extends VmWithLike> = Record<VmWithDefaultField<B>, B>;
|
|
12146
|
+
type VmWithAddedFields<B extends VmWithLike> = B extends VmWith<any, infer TAddedFields, any> ? TAddedFields : {};
|
|
12134
12147
|
/**
|
|
12135
12148
|
* Base class for VM configuration builders that act as middleware.
|
|
12136
12149
|
* Extend this class to create reusable VM components like DevServer, Database, etc.
|
|
@@ -12140,7 +12153,7 @@ type VmWithAddedFields<B extends VmWith> = B extends VmWith<any, infer TAddedFie
|
|
|
12140
12153
|
* 2. Applies its own configuration
|
|
12141
12154
|
* 3. Returns merged configuration
|
|
12142
12155
|
*/
|
|
12143
|
-
declare abstract class VmWith<TInstance
|
|
12156
|
+
declare abstract class VmWith<TInstance = VmWithInstance, TAddedFields extends Record<string, VmWithLike<any, any, any>> = {}, TDefaultField extends string = string> {
|
|
12144
12157
|
instance: TInstance;
|
|
12145
12158
|
readonly defaultField?: TDefaultField;
|
|
12146
12159
|
protected readonly _addedFields?: TAddedFields;
|
|
@@ -12406,7 +12419,7 @@ type GitOptions = Omit<NonNullable<CreateSnapshotRequest["template"]["git"]>, "c
|
|
|
12406
12419
|
* Template options with SystemdServiceInput support and optional git.config
|
|
12407
12420
|
*/
|
|
12408
12421
|
type TemplateOptions = Omit<CreateSnapshotRequest["template"], "systemd" | "git"> & {
|
|
12409
|
-
template?: VmTemplate<Record<string,
|
|
12422
|
+
template?: VmTemplate<Record<string, VmWithLike>>;
|
|
12410
12423
|
baseImage?: VmBaseImage | RawBaseImage | null;
|
|
12411
12424
|
systemd?: null | {
|
|
12412
12425
|
services?: SystemdServiceInput[] | null;
|
|
@@ -12423,7 +12436,7 @@ declare class VmBaseImage {
|
|
|
12423
12436
|
hasFromInstruction(): boolean;
|
|
12424
12437
|
toRaw(): RawBaseImage;
|
|
12425
12438
|
}
|
|
12426
|
-
declare class VmTemplate<T extends Record<string,
|
|
12439
|
+
declare class VmTemplate<T extends Record<string, VmWithLike> = {}> {
|
|
12427
12440
|
raw: TemplateOptions;
|
|
12428
12441
|
readonly with: Partial<T>;
|
|
12429
12442
|
constructor(template: TemplateOptions & {
|
|
@@ -12433,11 +12446,11 @@ declare class VmTemplate<T extends Record<string, VmWith> = {}> {
|
|
|
12433
12446
|
type VmSpecOptions = TemplateOptions & {
|
|
12434
12447
|
snapshot?: VmSpec;
|
|
12435
12448
|
};
|
|
12436
|
-
type VmSpecWithFn<T extends Record<string,
|
|
12437
|
-
<K extends string, B extends
|
|
12438
|
-
<B extends
|
|
12449
|
+
type VmSpecWithFn<T extends Record<string, VmWithLike>> = {
|
|
12450
|
+
<K extends string, B extends VmWithLike>(name: K, builder: B): VmSpec<T & Record<K, B> & VmWithAddedFields<B>>;
|
|
12451
|
+
<B extends VmWithLike>(builder: B): VmSpec<T & Record<VmWithDefaultField<B>, B> & VmWithAddedFields<B>>;
|
|
12439
12452
|
} & Partial<T>;
|
|
12440
|
-
declare class VmSpec<T extends Record<string,
|
|
12453
|
+
declare class VmSpec<T extends Record<string, VmWithLike> = {}> {
|
|
12441
12454
|
raw: VmSpecOptions;
|
|
12442
12455
|
readonly with: VmSpecWithFn<T>;
|
|
12443
12456
|
private withDiscriminators;
|
|
@@ -12476,14 +12489,14 @@ declare class VmsNamespace {
|
|
|
12476
12489
|
* @param options Optional VM configuration
|
|
12477
12490
|
* @returns A VM instance representing the created VM
|
|
12478
12491
|
*/
|
|
12479
|
-
create<T extends Record<string,
|
|
12492
|
+
create<T extends Record<string, VmWithLike>>(spec: VmSpec<T>): Promise<Omit<ResponsePostV1Vms200, "consoleUrl"> & {
|
|
12480
12493
|
vmId: string;
|
|
12481
12494
|
vm: Vm & {
|
|
12482
12495
|
[K in keyof T]: ReturnType<T[K]["createInstance"]>;
|
|
12483
12496
|
};
|
|
12484
12497
|
domains: string[];
|
|
12485
12498
|
}>;
|
|
12486
|
-
create<T extends Record<string,
|
|
12499
|
+
create<T extends Record<string, VmWithLike>>(options: CreateVmOptions & {
|
|
12487
12500
|
with?: T;
|
|
12488
12501
|
template?: VmTemplate<T>;
|
|
12489
12502
|
spec?: VmSpec<T>;
|
|
@@ -12506,7 +12519,7 @@ declare class VmsNamespace {
|
|
|
12506
12519
|
* @param spec Optional spec to attach builders to the returned VM
|
|
12507
12520
|
* @returns The VM instance configured with builders from the spec
|
|
12508
12521
|
*/
|
|
12509
|
-
get<T extends Record<string,
|
|
12522
|
+
get<T extends Record<string, VmWithLike>>({ vmId, spec, }: {
|
|
12510
12523
|
vmId: string;
|
|
12511
12524
|
spec?: VmSpec<T>;
|
|
12512
12525
|
}): Promise<{
|
|
@@ -12518,7 +12531,7 @@ declare class VmsNamespace {
|
|
|
12518
12531
|
/**
|
|
12519
12532
|
* Create a VM instance by ID without making an api call.
|
|
12520
12533
|
*/
|
|
12521
|
-
ref<T extends Record<string,
|
|
12534
|
+
ref<T extends Record<string, VmWithLike>>({ vmId, spec, }: {
|
|
12522
12535
|
vmId: string;
|
|
12523
12536
|
spec?: VmSpec<T>;
|
|
12524
12537
|
}): Vm & {
|
|
@@ -12531,7 +12544,7 @@ declare class VmsNamespace {
|
|
|
12531
12544
|
declare class VmSnapshotsNamespace {
|
|
12532
12545
|
private apiClient;
|
|
12533
12546
|
constructor(apiClient: ApiClient);
|
|
12534
|
-
ensure<T extends Record<string,
|
|
12547
|
+
ensure<T extends Record<string, VmWithLike>>(options: Omit<PostV1VmsSnapshotsRequestBody, "template"> & {
|
|
12535
12548
|
template?: VmTemplate<T> | PostV1VmsSnapshotsRequestBody["template"];
|
|
12536
12549
|
spec?: VmSpec<T>;
|
|
12537
12550
|
snapshot?: VmSpec<T>;
|
package/index.d.mts
CHANGED
|
@@ -12125,12 +12125,25 @@ declare class Systemd {
|
|
|
12125
12125
|
* This is the instance attached to the VM after creation.
|
|
12126
12126
|
*/
|
|
12127
12127
|
declare class VmWithInstance {
|
|
12128
|
-
|
|
12128
|
+
vm: Vm;
|
|
12129
12129
|
private _init;
|
|
12130
12130
|
}
|
|
12131
|
-
|
|
12132
|
-
|
|
12133
|
-
|
|
12131
|
+
interface VmWithLike<TInstance = unknown, TAddedFields extends Record<string, VmWithLike<any, any, any>> = {}, TDefaultField extends string = string> {
|
|
12132
|
+
instance: TInstance;
|
|
12133
|
+
readonly defaultField?: TDefaultField;
|
|
12134
|
+
configure?(existingConfig: any): any;
|
|
12135
|
+
configureSpec?(spec: any): any;
|
|
12136
|
+
configureSnapshotSpec?(spec: any): any;
|
|
12137
|
+
configureBaseImage?(image: any): any;
|
|
12138
|
+
configureTemplate?(template: any): any;
|
|
12139
|
+
configureNestedTemplate?(template: any): any;
|
|
12140
|
+
createInstance(): TInstance;
|
|
12141
|
+
}
|
|
12142
|
+
type VmWithDefaultField<B extends VmWithLike> = B extends {
|
|
12143
|
+
defaultField?: infer TDefaultField;
|
|
12144
|
+
} ? Extract<TDefaultField, string> extends never ? string : Extract<TDefaultField, string> : string;
|
|
12145
|
+
type VmWithDefaultFieldRecord<B extends VmWithLike> = Record<VmWithDefaultField<B>, B>;
|
|
12146
|
+
type VmWithAddedFields<B extends VmWithLike> = B extends VmWith<any, infer TAddedFields, any> ? TAddedFields : {};
|
|
12134
12147
|
/**
|
|
12135
12148
|
* Base class for VM configuration builders that act as middleware.
|
|
12136
12149
|
* Extend this class to create reusable VM components like DevServer, Database, etc.
|
|
@@ -12140,7 +12153,7 @@ type VmWithAddedFields<B extends VmWith> = B extends VmWith<any, infer TAddedFie
|
|
|
12140
12153
|
* 2. Applies its own configuration
|
|
12141
12154
|
* 3. Returns merged configuration
|
|
12142
12155
|
*/
|
|
12143
|
-
declare abstract class VmWith<TInstance
|
|
12156
|
+
declare abstract class VmWith<TInstance = VmWithInstance, TAddedFields extends Record<string, VmWithLike<any, any, any>> = {}, TDefaultField extends string = string> {
|
|
12144
12157
|
instance: TInstance;
|
|
12145
12158
|
readonly defaultField?: TDefaultField;
|
|
12146
12159
|
protected readonly _addedFields?: TAddedFields;
|
|
@@ -12406,7 +12419,7 @@ type GitOptions = Omit<NonNullable<CreateSnapshotRequest["template"]["git"]>, "c
|
|
|
12406
12419
|
* Template options with SystemdServiceInput support and optional git.config
|
|
12407
12420
|
*/
|
|
12408
12421
|
type TemplateOptions = Omit<CreateSnapshotRequest["template"], "systemd" | "git"> & {
|
|
12409
|
-
template?: VmTemplate<Record<string,
|
|
12422
|
+
template?: VmTemplate<Record<string, VmWithLike>>;
|
|
12410
12423
|
baseImage?: VmBaseImage | RawBaseImage | null;
|
|
12411
12424
|
systemd?: null | {
|
|
12412
12425
|
services?: SystemdServiceInput[] | null;
|
|
@@ -12423,7 +12436,7 @@ declare class VmBaseImage {
|
|
|
12423
12436
|
hasFromInstruction(): boolean;
|
|
12424
12437
|
toRaw(): RawBaseImage;
|
|
12425
12438
|
}
|
|
12426
|
-
declare class VmTemplate<T extends Record<string,
|
|
12439
|
+
declare class VmTemplate<T extends Record<string, VmWithLike> = {}> {
|
|
12427
12440
|
raw: TemplateOptions;
|
|
12428
12441
|
readonly with: Partial<T>;
|
|
12429
12442
|
constructor(template: TemplateOptions & {
|
|
@@ -12433,11 +12446,11 @@ declare class VmTemplate<T extends Record<string, VmWith> = {}> {
|
|
|
12433
12446
|
type VmSpecOptions = TemplateOptions & {
|
|
12434
12447
|
snapshot?: VmSpec;
|
|
12435
12448
|
};
|
|
12436
|
-
type VmSpecWithFn<T extends Record<string,
|
|
12437
|
-
<K extends string, B extends
|
|
12438
|
-
<B extends
|
|
12449
|
+
type VmSpecWithFn<T extends Record<string, VmWithLike>> = {
|
|
12450
|
+
<K extends string, B extends VmWithLike>(name: K, builder: B): VmSpec<T & Record<K, B> & VmWithAddedFields<B>>;
|
|
12451
|
+
<B extends VmWithLike>(builder: B): VmSpec<T & Record<VmWithDefaultField<B>, B> & VmWithAddedFields<B>>;
|
|
12439
12452
|
} & Partial<T>;
|
|
12440
|
-
declare class VmSpec<T extends Record<string,
|
|
12453
|
+
declare class VmSpec<T extends Record<string, VmWithLike> = {}> {
|
|
12441
12454
|
raw: VmSpecOptions;
|
|
12442
12455
|
readonly with: VmSpecWithFn<T>;
|
|
12443
12456
|
private withDiscriminators;
|
|
@@ -12476,14 +12489,14 @@ declare class VmsNamespace {
|
|
|
12476
12489
|
* @param options Optional VM configuration
|
|
12477
12490
|
* @returns A VM instance representing the created VM
|
|
12478
12491
|
*/
|
|
12479
|
-
create<T extends Record<string,
|
|
12492
|
+
create<T extends Record<string, VmWithLike>>(spec: VmSpec<T>): Promise<Omit<ResponsePostV1Vms200, "consoleUrl"> & {
|
|
12480
12493
|
vmId: string;
|
|
12481
12494
|
vm: Vm & {
|
|
12482
12495
|
[K in keyof T]: ReturnType<T[K]["createInstance"]>;
|
|
12483
12496
|
};
|
|
12484
12497
|
domains: string[];
|
|
12485
12498
|
}>;
|
|
12486
|
-
create<T extends Record<string,
|
|
12499
|
+
create<T extends Record<string, VmWithLike>>(options: CreateVmOptions & {
|
|
12487
12500
|
with?: T;
|
|
12488
12501
|
template?: VmTemplate<T>;
|
|
12489
12502
|
spec?: VmSpec<T>;
|
|
@@ -12506,7 +12519,7 @@ declare class VmsNamespace {
|
|
|
12506
12519
|
* @param spec Optional spec to attach builders to the returned VM
|
|
12507
12520
|
* @returns The VM instance configured with builders from the spec
|
|
12508
12521
|
*/
|
|
12509
|
-
get<T extends Record<string,
|
|
12522
|
+
get<T extends Record<string, VmWithLike>>({ vmId, spec, }: {
|
|
12510
12523
|
vmId: string;
|
|
12511
12524
|
spec?: VmSpec<T>;
|
|
12512
12525
|
}): Promise<{
|
|
@@ -12518,7 +12531,7 @@ declare class VmsNamespace {
|
|
|
12518
12531
|
/**
|
|
12519
12532
|
* Create a VM instance by ID without making an api call.
|
|
12520
12533
|
*/
|
|
12521
|
-
ref<T extends Record<string,
|
|
12534
|
+
ref<T extends Record<string, VmWithLike>>({ vmId, spec, }: {
|
|
12522
12535
|
vmId: string;
|
|
12523
12536
|
spec?: VmSpec<T>;
|
|
12524
12537
|
}): Vm & {
|
|
@@ -12531,7 +12544,7 @@ declare class VmsNamespace {
|
|
|
12531
12544
|
declare class VmSnapshotsNamespace {
|
|
12532
12545
|
private apiClient;
|
|
12533
12546
|
constructor(apiClient: ApiClient);
|
|
12534
|
-
ensure<T extends Record<string,
|
|
12547
|
+
ensure<T extends Record<string, VmWithLike>>(options: Omit<PostV1VmsSnapshotsRequestBody, "template"> & {
|
|
12535
12548
|
template?: VmTemplate<T> | PostV1VmsSnapshotsRequestBody["template"];
|
|
12536
12549
|
spec?: VmSpec<T>;
|
|
12537
12550
|
snapshot?: VmSpec<T>;
|
package/index.mjs
CHANGED
|
@@ -5945,8 +5945,9 @@ function composeVmTemplates(templates) {
|
|
|
5945
5945
|
);
|
|
5946
5946
|
const mergedWith = {};
|
|
5947
5947
|
for (const template of templates) {
|
|
5948
|
-
|
|
5949
|
-
|
|
5948
|
+
const builders = template.with ?? {};
|
|
5949
|
+
for (const key in builders) {
|
|
5950
|
+
const builder = builders[key];
|
|
5950
5951
|
if (builder) {
|
|
5951
5952
|
mergedWith[key] = builder;
|
|
5952
5953
|
}
|
|
@@ -5982,8 +5983,9 @@ function composeVmSpecs(specs) {
|
|
|
5982
5983
|
const mergedWithDiscriminators = {};
|
|
5983
5984
|
for (const spec of specs) {
|
|
5984
5985
|
const builderDiscriminators = spec.getBuilderDiscriminators();
|
|
5985
|
-
|
|
5986
|
-
|
|
5986
|
+
const builders = spec.builders ?? {};
|
|
5987
|
+
for (const key in builders) {
|
|
5988
|
+
const builder = builders[key];
|
|
5987
5989
|
if (builder) {
|
|
5988
5990
|
mergedWith[key] = builder;
|
|
5989
5991
|
mergedWithDiscriminators[key] = builderDiscriminators[key];
|
|
@@ -6400,7 +6402,9 @@ class VmSpec {
|
|
|
6400
6402
|
}
|
|
6401
6403
|
snapshot() {
|
|
6402
6404
|
const { snapshot: existingSnapshot, ...currentLayer } = this.raw;
|
|
6403
|
-
const currentBuilders = {
|
|
6405
|
+
const currentBuilders = {
|
|
6406
|
+
...this.builders
|
|
6407
|
+
};
|
|
6404
6408
|
const currentWithDiscriminators = this.getBuilderDiscriminators();
|
|
6405
6409
|
const innerSnapshot = new VmSpec({
|
|
6406
6410
|
...currentLayer,
|
|
@@ -6754,7 +6758,11 @@ class VmsNamespace {
|
|
|
6754
6758
|
...rawTemplate ?? {},
|
|
6755
6759
|
baseImage: serializedBaseImage
|
|
6756
6760
|
} : rawTemplate;
|
|
6757
|
-
const {
|
|
6761
|
+
const {
|
|
6762
|
+
baseImage: _baseImage,
|
|
6763
|
+
template: _template,
|
|
6764
|
+
...requestConfig
|
|
6765
|
+
} = config;
|
|
6758
6766
|
const response = await this.freestyle._apiClient.post("/v1/vms", {
|
|
6759
6767
|
body: {
|
|
6760
6768
|
...requestConfig,
|