freestyle-sandboxes 0.1.40 → 0.1.41

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 (3) hide show
  1. package/index.cjs +84 -2
  2. package/index.mjs +84 -2
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -6695,6 +6695,73 @@ function isVmSpecLike$1(value) {
6695
6695
  function isVmTemplateLike$1(value) {
6696
6696
  return !!value && typeof value === "object" && "raw" in value && "with" in value;
6697
6697
  }
6698
+ function cloneVmSpecTree(spec) {
6699
+ const clonedRaw = cloneVmSpecRaw$1(spec.raw);
6700
+ return new VmSpec({
6701
+ ...clonedRaw,
6702
+ with: { ...spec.builders },
6703
+ __withDiscriminators: spec.getBuilderDiscriminators()
6704
+ });
6705
+ }
6706
+ function isVmSpecInstance(value) {
6707
+ return value instanceof VmSpec;
6708
+ }
6709
+ function isVmTemplateInstance(value) {
6710
+ return value instanceof VmTemplate;
6711
+ }
6712
+ function cloneVmTemplateTree(template) {
6713
+ const clonedRaw = cloneVmTemplateRaw$1(template.raw);
6714
+ return new VmTemplate({
6715
+ ...clonedRaw,
6716
+ with: { ...template.with }
6717
+ });
6718
+ }
6719
+ function cloneVmSpecRaw$1(raw) {
6720
+ const cloned = cloneVmTemplateRaw$1(raw);
6721
+ if (isVmSpecInstance(raw.snapshot)) {
6722
+ cloned.snapshot = cloneVmSpecTree(raw.snapshot);
6723
+ } else if (raw.snapshot !== void 0) {
6724
+ cloned.snapshot = cloneVmValue(raw.snapshot);
6725
+ }
6726
+ return cloned;
6727
+ }
6728
+ function cloneVmTemplateRaw$1(raw) {
6729
+ const cloned = cloneVmPlainObject(raw);
6730
+ if (isVmTemplateInstance(raw.template)) {
6731
+ cloned.template = cloneVmTemplateTree(raw.template);
6732
+ } else if (raw.template !== void 0) {
6733
+ cloned.template = cloneVmValue(raw.template);
6734
+ }
6735
+ return cloned;
6736
+ }
6737
+ function cloneVmPlainObject(value) {
6738
+ if (!value || typeof value !== "object") {
6739
+ return value;
6740
+ }
6741
+ const cloned = {};
6742
+ for (const [key, entry] of Object.entries(value)) {
6743
+ cloned[key] = cloneVmValue(entry);
6744
+ }
6745
+ return cloned;
6746
+ }
6747
+ function cloneVmValue(value) {
6748
+ if (value instanceof VmBaseImage) {
6749
+ return new VmBaseImage(value.toRaw());
6750
+ }
6751
+ if (isVmSpecInstance(value)) {
6752
+ return cloneVmSpecTree(value);
6753
+ }
6754
+ if (isVmTemplateInstance(value)) {
6755
+ return cloneVmTemplateTree(value);
6756
+ }
6757
+ if (Array.isArray(value)) {
6758
+ return value.map((entry) => cloneVmValue(entry));
6759
+ }
6760
+ if (value && typeof value === "object") {
6761
+ return cloneVmPlainObject(value);
6762
+ }
6763
+ return value;
6764
+ }
6698
6765
  async function convertSpecSnapshotsToTemplates(spec, processBuilders = true) {
6699
6766
  if (!isVmSpecLike$1(spec.raw.snapshot)) {
6700
6767
  return void 0;
@@ -6806,7 +6873,17 @@ class VmsNamespace {
6806
6873
  snapshots;
6807
6874
  async create(options = {}) {
6808
6875
  if (isVmSpecLike$1(options)) {
6809
- options = { spec: options };
6876
+ options = { spec: cloneVmSpecTree(options) };
6877
+ } else {
6878
+ if (isVmSpecLike$1(options.spec)) {
6879
+ options.spec = cloneVmSpecTree(options.spec);
6880
+ }
6881
+ if (isVmSpecLike$1(options.snapshot)) {
6882
+ options.snapshot = cloneVmSpecTree(options.snapshot);
6883
+ }
6884
+ if (isVmTemplateLike$1(options.template)) {
6885
+ options.template = cloneVmTemplateTree(options.template);
6886
+ }
6810
6887
  }
6811
6888
  if (isVmSpecLike$1(options.snapshot)) {
6812
6889
  if (isVmSpecLike$1(options.spec)) {
@@ -7083,7 +7160,12 @@ class VmSnapshotsNamespace {
7083
7160
  this.apiClient = apiClient;
7084
7161
  }
7085
7162
  async ensure(options) {
7086
- let requestOptions = options;
7163
+ let requestOptions = {
7164
+ ...options,
7165
+ spec: isVmSpecLike$1(options.spec) ? cloneVmSpecTree(options.spec) : void 0,
7166
+ snapshot: isVmSpecLike$1(options.snapshot) ? cloneVmSpecTree(options.snapshot) : void 0,
7167
+ template: isVmTemplateLike$1(options.template) ? cloneVmTemplateTree(options.template) : options.template
7168
+ };
7087
7169
  if (isVmSpecLike$1(requestOptions.snapshot)) {
7088
7170
  if (isVmSpecLike$1(requestOptions.spec)) {
7089
7171
  if (!requestOptions.spec.raw.snapshot) {
package/index.mjs CHANGED
@@ -6693,6 +6693,73 @@ function isVmSpecLike$1(value) {
6693
6693
  function isVmTemplateLike$1(value) {
6694
6694
  return !!value && typeof value === "object" && "raw" in value && "with" in value;
6695
6695
  }
6696
+ function cloneVmSpecTree(spec) {
6697
+ const clonedRaw = cloneVmSpecRaw$1(spec.raw);
6698
+ return new VmSpec({
6699
+ ...clonedRaw,
6700
+ with: { ...spec.builders },
6701
+ __withDiscriminators: spec.getBuilderDiscriminators()
6702
+ });
6703
+ }
6704
+ function isVmSpecInstance(value) {
6705
+ return value instanceof VmSpec;
6706
+ }
6707
+ function isVmTemplateInstance(value) {
6708
+ return value instanceof VmTemplate;
6709
+ }
6710
+ function cloneVmTemplateTree(template) {
6711
+ const clonedRaw = cloneVmTemplateRaw$1(template.raw);
6712
+ return new VmTemplate({
6713
+ ...clonedRaw,
6714
+ with: { ...template.with }
6715
+ });
6716
+ }
6717
+ function cloneVmSpecRaw$1(raw) {
6718
+ const cloned = cloneVmTemplateRaw$1(raw);
6719
+ if (isVmSpecInstance(raw.snapshot)) {
6720
+ cloned.snapshot = cloneVmSpecTree(raw.snapshot);
6721
+ } else if (raw.snapshot !== void 0) {
6722
+ cloned.snapshot = cloneVmValue(raw.snapshot);
6723
+ }
6724
+ return cloned;
6725
+ }
6726
+ function cloneVmTemplateRaw$1(raw) {
6727
+ const cloned = cloneVmPlainObject(raw);
6728
+ if (isVmTemplateInstance(raw.template)) {
6729
+ cloned.template = cloneVmTemplateTree(raw.template);
6730
+ } else if (raw.template !== void 0) {
6731
+ cloned.template = cloneVmValue(raw.template);
6732
+ }
6733
+ return cloned;
6734
+ }
6735
+ function cloneVmPlainObject(value) {
6736
+ if (!value || typeof value !== "object") {
6737
+ return value;
6738
+ }
6739
+ const cloned = {};
6740
+ for (const [key, entry] of Object.entries(value)) {
6741
+ cloned[key] = cloneVmValue(entry);
6742
+ }
6743
+ return cloned;
6744
+ }
6745
+ function cloneVmValue(value) {
6746
+ if (value instanceof VmBaseImage) {
6747
+ return new VmBaseImage(value.toRaw());
6748
+ }
6749
+ if (isVmSpecInstance(value)) {
6750
+ return cloneVmSpecTree(value);
6751
+ }
6752
+ if (isVmTemplateInstance(value)) {
6753
+ return cloneVmTemplateTree(value);
6754
+ }
6755
+ if (Array.isArray(value)) {
6756
+ return value.map((entry) => cloneVmValue(entry));
6757
+ }
6758
+ if (value && typeof value === "object") {
6759
+ return cloneVmPlainObject(value);
6760
+ }
6761
+ return value;
6762
+ }
6696
6763
  async function convertSpecSnapshotsToTemplates(spec, processBuilders = true) {
6697
6764
  if (!isVmSpecLike$1(spec.raw.snapshot)) {
6698
6765
  return void 0;
@@ -6804,7 +6871,17 @@ class VmsNamespace {
6804
6871
  snapshots;
6805
6872
  async create(options = {}) {
6806
6873
  if (isVmSpecLike$1(options)) {
6807
- options = { spec: options };
6874
+ options = { spec: cloneVmSpecTree(options) };
6875
+ } else {
6876
+ if (isVmSpecLike$1(options.spec)) {
6877
+ options.spec = cloneVmSpecTree(options.spec);
6878
+ }
6879
+ if (isVmSpecLike$1(options.snapshot)) {
6880
+ options.snapshot = cloneVmSpecTree(options.snapshot);
6881
+ }
6882
+ if (isVmTemplateLike$1(options.template)) {
6883
+ options.template = cloneVmTemplateTree(options.template);
6884
+ }
6808
6885
  }
6809
6886
  if (isVmSpecLike$1(options.snapshot)) {
6810
6887
  if (isVmSpecLike$1(options.spec)) {
@@ -7081,7 +7158,12 @@ class VmSnapshotsNamespace {
7081
7158
  this.apiClient = apiClient;
7082
7159
  }
7083
7160
  async ensure(options) {
7084
- let requestOptions = options;
7161
+ let requestOptions = {
7162
+ ...options,
7163
+ spec: isVmSpecLike$1(options.spec) ? cloneVmSpecTree(options.spec) : void 0,
7164
+ snapshot: isVmSpecLike$1(options.snapshot) ? cloneVmSpecTree(options.snapshot) : void 0,
7165
+ template: isVmTemplateLike$1(options.template) ? cloneVmTemplateTree(options.template) : options.template
7166
+ };
7085
7167
  if (isVmSpecLike$1(requestOptions.snapshot)) {
7086
7168
  if (isVmSpecLike$1(requestOptions.spec)) {
7087
7169
  if (!requestOptions.spec.raw.snapshot) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freestyle-sandboxes",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "require": {