@blaxel/core 0.2.96-preview.203 → 0.2.96-preview.205

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 (90) hide show
  1. package/README.md +37 -2
  2. package/dist/cjs/.tsbuildinfo +1 -1
  3. package/dist/cjs/client/sdk.gen.js +113 -2
  4. package/dist/cjs/common/pagination.js +92 -0
  5. package/dist/cjs/common/pagination.test.js +81 -0
  6. package/dist/cjs/common/settings.js +3 -3
  7. package/dist/cjs/common/settings.test.js +3 -3
  8. package/dist/cjs/drive/index.js +39 -4
  9. package/dist/cjs/index.js +1 -0
  10. package/dist/cjs/jobs/jobs.js +42 -10
  11. package/dist/cjs/sandbox/client/sdk.gen.js +2 -2
  12. package/dist/cjs/sandbox/index.js +1 -0
  13. package/dist/cjs/sandbox/preview.js +8 -3
  14. package/dist/cjs/sandbox/sandbox.js +43 -33
  15. package/dist/cjs/sandbox/schedule.js +91 -0
  16. package/dist/cjs/types/client/sdk.gen.d.ts +31 -1
  17. package/dist/cjs/types/client/types.gen.d.ts +347 -0
  18. package/dist/cjs/types/common/pagination.d.ts +35 -0
  19. package/dist/cjs/types/common/pagination.test.d.ts +1 -0
  20. package/dist/cjs/types/drive/index.d.ts +35 -5
  21. package/dist/cjs/types/index.d.ts +1 -0
  22. package/dist/cjs/types/jobs/jobs.d.ts +33 -3
  23. package/dist/cjs/types/sandbox/client/sdk.gen.d.ts +2 -2
  24. package/dist/cjs/types/sandbox/client/types.gen.d.ts +28 -1
  25. package/dist/cjs/types/sandbox/index.d.ts +1 -0
  26. package/dist/cjs/types/sandbox/preview.d.ts +2 -2
  27. package/dist/cjs/types/sandbox/sandbox.d.ts +38 -3
  28. package/dist/cjs/types/sandbox/schedule.d.ts +16 -0
  29. package/dist/cjs/types/volume/index.d.ts +37 -4
  30. package/dist/cjs/volume/index.js +41 -4
  31. package/dist/cjs-browser/.tsbuildinfo +1 -1
  32. package/dist/cjs-browser/client/sdk.gen.js +113 -2
  33. package/dist/cjs-browser/common/pagination.js +92 -0
  34. package/dist/cjs-browser/common/pagination.test.js +81 -0
  35. package/dist/cjs-browser/common/settings.js +3 -3
  36. package/dist/cjs-browser/common/settings.test.js +3 -3
  37. package/dist/cjs-browser/drive/index.js +39 -4
  38. package/dist/cjs-browser/index.js +1 -0
  39. package/dist/cjs-browser/jobs/jobs.js +42 -10
  40. package/dist/cjs-browser/sandbox/client/sdk.gen.js +2 -2
  41. package/dist/cjs-browser/sandbox/index.js +1 -0
  42. package/dist/cjs-browser/sandbox/preview.js +8 -3
  43. package/dist/cjs-browser/sandbox/sandbox.js +43 -33
  44. package/dist/cjs-browser/sandbox/schedule.js +91 -0
  45. package/dist/cjs-browser/types/client/sdk.gen.d.ts +31 -1
  46. package/dist/cjs-browser/types/client/types.gen.d.ts +347 -0
  47. package/dist/cjs-browser/types/common/pagination.d.ts +35 -0
  48. package/dist/cjs-browser/types/common/pagination.test.d.ts +1 -0
  49. package/dist/cjs-browser/types/drive/index.d.ts +35 -5
  50. package/dist/cjs-browser/types/index.d.ts +1 -0
  51. package/dist/cjs-browser/types/jobs/jobs.d.ts +33 -3
  52. package/dist/cjs-browser/types/sandbox/client/sdk.gen.d.ts +2 -2
  53. package/dist/cjs-browser/types/sandbox/client/types.gen.d.ts +28 -1
  54. package/dist/cjs-browser/types/sandbox/index.d.ts +1 -0
  55. package/dist/cjs-browser/types/sandbox/preview.d.ts +2 -2
  56. package/dist/cjs-browser/types/sandbox/sandbox.d.ts +38 -3
  57. package/dist/cjs-browser/types/sandbox/schedule.d.ts +16 -0
  58. package/dist/cjs-browser/types/volume/index.d.ts +37 -4
  59. package/dist/cjs-browser/volume/index.js +41 -4
  60. package/dist/esm/.tsbuildinfo +1 -1
  61. package/dist/esm/client/sdk.gen.js +104 -0
  62. package/dist/esm/common/pagination.js +88 -0
  63. package/dist/esm/common/pagination.test.js +79 -0
  64. package/dist/esm/common/settings.js +3 -3
  65. package/dist/esm/common/settings.test.js +3 -3
  66. package/dist/esm/drive/index.js +39 -4
  67. package/dist/esm/index.js +1 -0
  68. package/dist/esm/jobs/jobs.js +42 -10
  69. package/dist/esm/sandbox/client/sdk.gen.js +2 -2
  70. package/dist/esm/sandbox/index.js +1 -0
  71. package/dist/esm/sandbox/preview.js +8 -3
  72. package/dist/esm/sandbox/sandbox.js +43 -33
  73. package/dist/esm/sandbox/schedule.js +87 -0
  74. package/dist/esm/volume/index.js +41 -4
  75. package/dist/esm-browser/.tsbuildinfo +1 -1
  76. package/dist/esm-browser/client/sdk.gen.js +104 -0
  77. package/dist/esm-browser/common/pagination.js +88 -0
  78. package/dist/esm-browser/common/pagination.test.js +79 -0
  79. package/dist/esm-browser/common/settings.js +3 -3
  80. package/dist/esm-browser/common/settings.test.js +3 -3
  81. package/dist/esm-browser/drive/index.js +39 -4
  82. package/dist/esm-browser/index.js +1 -0
  83. package/dist/esm-browser/jobs/jobs.js +42 -10
  84. package/dist/esm-browser/sandbox/client/sdk.gen.js +2 -2
  85. package/dist/esm-browser/sandbox/index.js +1 -0
  86. package/dist/esm-browser/sandbox/preview.js +8 -3
  87. package/dist/esm-browser/sandbox/sandbox.js +43 -33
  88. package/dist/esm-browser/sandbox/schedule.js +87 -0
  89. package/dist/esm-browser/volume/index.js +41 -4
  90. package/package.json +1 -1
@@ -0,0 +1,87 @@
1
+ import { createSandboxSchedule, deleteSandboxSchedule, getSandboxSchedule, listSandboxScheduleExecutions, listSandboxSchedules, updateSandboxSchedule } from "../client/index.js";
2
+ // Schedule list endpoints return a bare array on older API versions and a
3
+ // cursor-paginated `{ data, meta }` envelope starting on Blaxel-Version
4
+ // 2026-04-28. Handle both so the wrapper works regardless of the SDK's default
5
+ // version.
6
+ function unwrapPage(data) {
7
+ if (Array.isArray(data))
8
+ return data;
9
+ return data?.data ?? [];
10
+ }
11
+ // SandboxSchedules manages a sandbox's schedules. A schedule entry is a flat
12
+ // record (id/type/value/input) with no sub-resource of its own, so methods
13
+ // return the raw SandboxScheduleEntry rather than a wrapper class (the generated
14
+ // `SandboxSchedule` type is the array form `SandboxScheduleEntry[]`).
15
+ export class SandboxSchedules {
16
+ sandbox;
17
+ constructor(sandbox) {
18
+ this.sandbox = sandbox;
19
+ }
20
+ get sandboxName() {
21
+ return this.sandbox.metadata.name;
22
+ }
23
+ async list(options = {}) {
24
+ const { data } = await listSandboxSchedules({
25
+ path: {
26
+ sandboxName: this.sandboxName,
27
+ },
28
+ query: options,
29
+ throwOnError: true,
30
+ });
31
+ return unwrapPage(data);
32
+ }
33
+ async create(schedule) {
34
+ const { data } = await createSandboxSchedule({
35
+ path: {
36
+ sandboxName: this.sandboxName,
37
+ },
38
+ body: schedule,
39
+ throwOnError: true,
40
+ });
41
+ return data;
42
+ }
43
+ async get(scheduleId) {
44
+ const { data } = await getSandboxSchedule({
45
+ path: {
46
+ sandboxName: this.sandboxName,
47
+ scheduleId,
48
+ },
49
+ throwOnError: true,
50
+ });
51
+ return data;
52
+ }
53
+ async update(scheduleId, schedule) {
54
+ const { data } = await updateSandboxSchedule({
55
+ path: {
56
+ sandboxName: this.sandboxName,
57
+ scheduleId,
58
+ },
59
+ body: schedule,
60
+ throwOnError: true,
61
+ });
62
+ return data;
63
+ }
64
+ async delete(scheduleId) {
65
+ const { data } = await deleteSandboxSchedule({
66
+ path: {
67
+ sandboxName: this.sandboxName,
68
+ scheduleId,
69
+ },
70
+ throwOnError: true,
71
+ });
72
+ return data;
73
+ }
74
+ // List the execution history of every schedule on the sandbox, newest first.
75
+ // Executions are sandbox-scoped, not per-schedule; filter by `scheduleId` on
76
+ // the returned records to isolate a single schedule's runs.
77
+ async executions(options = {}) {
78
+ const { data } = await listSandboxScheduleExecutions({
79
+ path: {
80
+ sandboxName: this.sandboxName,
81
+ },
82
+ query: options,
83
+ throwOnError: true,
84
+ });
85
+ return unwrapPage(data);
86
+ }
87
+ }
@@ -1,5 +1,6 @@
1
1
  import { v4 as uuidv4 } from "uuid";
2
2
  import { createVolume, deleteVolume, getVolume, listVolumes, updateVolume } from "../client/index.js";
3
+ import { createPaginatedList } from "../common/pagination.js";
3
4
  import { settings } from "../common/settings.js";
4
5
  export class VolumeInstance {
5
6
  volume;
@@ -85,10 +86,46 @@ export class VolumeInstance {
85
86
  });
86
87
  return new VolumeInstance(data);
87
88
  }
88
- static async list() {
89
- const { data } = await listVolumes({ throwOnError: true });
90
- const items = Array.isArray(data) ? data : (data?.data ?? []);
91
- return items.map((volume) => new VolumeInstance(volume));
89
+ /**
90
+ * List one page of volumes.
91
+ *
92
+ * The returned page exposes `data` for the current page, `meta` for cursor
93
+ * metadata, and helpers to fetch more pages only when you need them.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * const page = await VolumeInstance.list({ limit: 50 });
98
+ *
99
+ * for (const volume of page.data) {
100
+ * console.log(volume.name);
101
+ * }
102
+ *
103
+ * const nextPage = await page.nextPage();
104
+ * ```
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * const page = await VolumeInstance.list({ limit: 100 });
109
+ *
110
+ * for await (const volume of page) {
111
+ * console.log(volume.name);
112
+ * }
113
+ * ```
114
+ */
115
+ static async list(query) {
116
+ const fetchPage = async (pageQuery) => {
117
+ const { data } = await listVolumes({
118
+ query: pageQuery,
119
+ throwOnError: true,
120
+ });
121
+ return data;
122
+ };
123
+ return createPaginatedList({
124
+ response: await fetchPage(query),
125
+ fetchPage,
126
+ mapItem: (volume) => new VolumeInstance(volume),
127
+ query,
128
+ });
92
129
  }
93
130
  static async delete(volumeName) {
94
131
  const { data } = await deleteVolume({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaxel/core",
3
- "version": "0.2.96-preview.203",
3
+ "version": "0.2.96-preview.205",
4
4
  "description": "Blaxel Core SDK for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Blaxel, INC (https://blaxel.ai)",