@blaxel/core 0.2.0-dev17 → 0.2.0-dev19

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.
@@ -0,0 +1,35 @@
1
+ import { Preview, PreviewToken, Sandbox } from "../client/index.js";
2
+ export declare class SandboxPreviewToken {
3
+ private previewToken;
4
+ constructor(previewToken: PreviewToken);
5
+ get value(): string;
6
+ get expiresAt(): string | Date;
7
+ }
8
+ export declare class SandboxPreviewTokens {
9
+ private preview;
10
+ constructor(preview: Preview);
11
+ get previewName(): string;
12
+ get resourceName(): string;
13
+ create(expiresAt: Date): Promise<SandboxPreviewToken>;
14
+ list(): Promise<SandboxPreviewToken[]>;
15
+ delete(tokenName: string): Promise<{
16
+ message?: string;
17
+ }>;
18
+ }
19
+ export declare class SandboxPreview {
20
+ private preview;
21
+ tokens: SandboxPreviewTokens;
22
+ constructor(preview: Preview);
23
+ get name(): string;
24
+ get metadata(): import("../client/types.gen.js").PreviewMetadata | undefined;
25
+ get spec(): import("../client/types.gen.js").PreviewSpec | undefined;
26
+ }
27
+ export declare class SandboxPreviews {
28
+ private sandbox;
29
+ constructor(sandbox: Sandbox);
30
+ get sandboxName(): string;
31
+ list(): Promise<SandboxPreview[]>;
32
+ create(preview: Preview): Promise<SandboxPreview>;
33
+ get(previewName: string): Promise<SandboxPreview>;
34
+ delete(previewName: string): Promise<Preview>;
35
+ }
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SandboxPreviews = exports.SandboxPreview = exports.SandboxPreviewTokens = exports.SandboxPreviewToken = void 0;
4
+ const index_js_1 = require("../client/index.js");
5
+ class SandboxPreviewToken {
6
+ previewToken;
7
+ constructor(previewToken) {
8
+ this.previewToken = previewToken;
9
+ }
10
+ get value() {
11
+ return this.previewToken.spec?.token ?? "";
12
+ }
13
+ get expiresAt() {
14
+ return this.previewToken.spec?.expiresAt ?? new Date();
15
+ }
16
+ }
17
+ exports.SandboxPreviewToken = SandboxPreviewToken;
18
+ class SandboxPreviewTokens {
19
+ preview;
20
+ constructor(preview) {
21
+ this.preview = preview;
22
+ }
23
+ get previewName() {
24
+ return this.preview.metadata?.name ?? "";
25
+ }
26
+ get resourceName() {
27
+ return this.preview.metadata?.resourceName ?? "";
28
+ }
29
+ async create(expiresAt) {
30
+ const { data } = await (0, index_js_1.createSandboxPreviewToken)({
31
+ path: {
32
+ sandboxName: this.resourceName,
33
+ previewName: this.previewName,
34
+ },
35
+ body: {
36
+ spec: {
37
+ expiresAt: expiresAt.toISOString(),
38
+ },
39
+ },
40
+ throwOnError: true,
41
+ });
42
+ return new SandboxPreviewToken(data);
43
+ }
44
+ async list() {
45
+ const { data } = await (0, index_js_1.listSandboxPreviewTokens)({
46
+ path: {
47
+ sandboxName: this.resourceName,
48
+ previewName: this.previewName,
49
+ },
50
+ throwOnError: true,
51
+ });
52
+ return data.map((token) => new SandboxPreviewToken(token));
53
+ }
54
+ async delete(tokenName) {
55
+ const { data } = await (0, index_js_1.deleteSandboxPreviewToken)({
56
+ path: {
57
+ sandboxName: this.resourceName,
58
+ previewName: this.previewName,
59
+ tokenName,
60
+ },
61
+ throwOnError: true,
62
+ });
63
+ return data;
64
+ }
65
+ }
66
+ exports.SandboxPreviewTokens = SandboxPreviewTokens;
67
+ class SandboxPreview {
68
+ preview;
69
+ tokens;
70
+ constructor(preview) {
71
+ this.preview = preview;
72
+ this.tokens = new SandboxPreviewTokens(this);
73
+ }
74
+ get name() {
75
+ return this.preview.metadata?.name ?? "";
76
+ }
77
+ get metadata() {
78
+ return this.preview.metadata;
79
+ }
80
+ get spec() {
81
+ return this.preview.spec;
82
+ }
83
+ }
84
+ exports.SandboxPreview = SandboxPreview;
85
+ class SandboxPreviews {
86
+ sandbox;
87
+ constructor(sandbox) {
88
+ this.sandbox = sandbox;
89
+ }
90
+ get sandboxName() {
91
+ return this.sandbox.metadata?.name ?? "";
92
+ }
93
+ async list() {
94
+ const { data } = await (0, index_js_1.listSandboxPreviews)({
95
+ path: {
96
+ sandboxName: this.sandboxName,
97
+ },
98
+ throwOnError: true,
99
+ });
100
+ return data.map((preview) => new SandboxPreview(preview));
101
+ }
102
+ async create(preview) {
103
+ const { data } = await (0, index_js_1.createSandboxPreview)({
104
+ path: {
105
+ sandboxName: this.sandboxName,
106
+ },
107
+ body: preview,
108
+ throwOnError: true,
109
+ });
110
+ return new SandboxPreview(data);
111
+ }
112
+ async get(previewName) {
113
+ const { data } = await (0, index_js_1.getSandboxPreview)({
114
+ path: {
115
+ sandboxName: this.sandboxName,
116
+ previewName,
117
+ },
118
+ throwOnError: true,
119
+ });
120
+ return new SandboxPreview(data);
121
+ }
122
+ async delete(previewName) {
123
+ const { data } = await (0, index_js_1.deleteSandboxPreview)({
124
+ path: {
125
+ sandboxName: this.sandboxName,
126
+ previewName,
127
+ },
128
+ throwOnError: true,
129
+ });
130
+ return data;
131
+ }
132
+ }
133
+ exports.SandboxPreviews = SandboxPreviews;
@@ -1,12 +1,14 @@
1
1
  import { Sandbox as SandboxModel } from "../client/index.js";
2
2
  import { SandboxFileSystem } from "./filesystem.js";
3
3
  import { SandboxNetwork } from "./network.js";
4
+ import { SandboxPreviews } from "./preview.js";
4
5
  import { SandboxProcess } from "./process.js";
5
6
  export declare class SandboxInstance {
6
7
  private sandbox;
7
8
  fs: SandboxFileSystem;
8
9
  network: SandboxNetwork;
9
10
  process: SandboxProcess;
11
+ previews: SandboxPreviews;
10
12
  constructor(sandbox: SandboxModel);
11
13
  get metadata(): import("../client/types.gen.js").Metadata | undefined;
12
14
  get status(): string | undefined;
@@ -5,17 +5,20 @@ const index_js_1 = require("../client/index.js");
5
5
  const logger_js_1 = require("../common/logger.js");
6
6
  const filesystem_js_1 = require("./filesystem.js");
7
7
  const network_js_1 = require("./network.js");
8
+ const preview_js_1 = require("./preview.js");
8
9
  const process_js_1 = require("./process.js");
9
10
  class SandboxInstance {
10
11
  sandbox;
11
12
  fs;
12
13
  network;
13
14
  process;
15
+ previews;
14
16
  constructor(sandbox) {
15
17
  this.sandbox = sandbox;
16
18
  this.fs = new filesystem_js_1.SandboxFileSystem(sandbox);
17
19
  this.network = new network_js_1.SandboxNetwork(sandbox);
18
20
  this.process = new process_js_1.SandboxProcess(sandbox);
21
+ this.previews = new preview_js_1.SandboxPreviews(sandbox);
19
22
  }
20
23
  get metadata() {
21
24
  return this.sandbox.metadata;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaxel/core",
3
- "version": "0.2.0-dev17",
3
+ "version": "0.2.0-dev19",
4
4
  "description": "Blaxel Core SDK for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Blaxel, INC (https://blaxel.ai)",