@blaxel/core 0.3.7-preview.230 → 0.3.8-preview.232

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,145 @@
1
+ import { v4 as uuidv4 } from "uuid";
2
+ import { createApplication, deleteApplication, getApplication, listApplications, updateApplication, listApplicationRevisions, } from "../client/index.js";
3
+ import { settings } from "../common/settings.js";
4
+ export class ApplicationInstance {
5
+ application;
6
+ constructor(application) {
7
+ this.application = application;
8
+ }
9
+ get metadata() {
10
+ return this.application.metadata;
11
+ }
12
+ get status() {
13
+ return this.application.status;
14
+ }
15
+ get spec() {
16
+ return this.application.spec;
17
+ }
18
+ get events() {
19
+ return this.application.events;
20
+ }
21
+ get name() {
22
+ return this.application.metadata.name;
23
+ }
24
+ static async create(config) {
25
+ const defaultName = `app-${uuidv4().replace(/-/g, "").substring(0, 8)}`;
26
+ let body;
27
+ if ("spec" in config && "metadata" in config) {
28
+ body = config;
29
+ }
30
+ else {
31
+ const cfg = config;
32
+ body = {
33
+ metadata: {
34
+ name: cfg.name || defaultName,
35
+ displayName: cfg.displayName || cfg.name || defaultName,
36
+ labels: cfg.labels,
37
+ },
38
+ spec: {
39
+ enabled: cfg.enabled ?? true,
40
+ region: cfg.region || settings.region,
41
+ image: cfg.image,
42
+ memory: cfg.memory,
43
+ port: cfg.port,
44
+ envs: cfg.envs,
45
+ },
46
+ };
47
+ }
48
+ if (!body.metadata) {
49
+ body.metadata = { name: defaultName };
50
+ }
51
+ if (!body.metadata.name) {
52
+ body.metadata.name = defaultName;
53
+ }
54
+ const { data } = await createApplication({
55
+ body,
56
+ throwOnError: true,
57
+ });
58
+ return new ApplicationInstance(data);
59
+ }
60
+ static async get(applicationName) {
61
+ const { data } = await getApplication({
62
+ path: { applicationName },
63
+ throwOnError: true,
64
+ });
65
+ return new ApplicationInstance(data);
66
+ }
67
+ static async list() {
68
+ const { data } = await listApplications({ throwOnError: true });
69
+ const items = Array.isArray(data) ? data : (data.data ?? []);
70
+ return items.map((app) => new ApplicationInstance(app));
71
+ }
72
+ static async delete(applicationName) {
73
+ const { data } = await deleteApplication({
74
+ path: { applicationName },
75
+ throwOnError: true,
76
+ });
77
+ return data;
78
+ }
79
+ async delete() {
80
+ return await ApplicationInstance.delete(this.metadata.name);
81
+ }
82
+ static async update(applicationName, updates) {
83
+ const existing = await ApplicationInstance.get(applicationName);
84
+ let body;
85
+ if ("spec" in updates && "metadata" in updates) {
86
+ body = {
87
+ metadata: {
88
+ ...existing.metadata,
89
+ ...updates.metadata,
90
+ },
91
+ spec: {
92
+ ...existing.spec,
93
+ ...updates.spec,
94
+ },
95
+ };
96
+ }
97
+ else {
98
+ const cfg = updates;
99
+ const metadataUpdates = {};
100
+ const specUpdates = {};
101
+ if (cfg.displayName !== undefined)
102
+ metadataUpdates.displayName = cfg.displayName;
103
+ if (cfg.labels !== undefined)
104
+ metadataUpdates.labels = cfg.labels;
105
+ if (cfg.enabled !== undefined)
106
+ specUpdates.enabled = cfg.enabled;
107
+ if (cfg.region !== undefined)
108
+ specUpdates.region = cfg.region;
109
+ if (cfg.image !== undefined)
110
+ specUpdates.image = cfg.image;
111
+ if (cfg.memory !== undefined)
112
+ specUpdates.memory = cfg.memory;
113
+ if (cfg.port !== undefined)
114
+ specUpdates.port = cfg.port;
115
+ if (cfg.envs !== undefined)
116
+ specUpdates.envs = cfg.envs;
117
+ body = {
118
+ metadata: {
119
+ ...existing.metadata,
120
+ ...metadataUpdates,
121
+ },
122
+ spec: {
123
+ ...existing.spec,
124
+ ...specUpdates,
125
+ },
126
+ };
127
+ }
128
+ const { data } = await updateApplication({
129
+ path: { applicationName },
130
+ body,
131
+ throwOnError: true,
132
+ });
133
+ return new ApplicationInstance(data);
134
+ }
135
+ async update(updates) {
136
+ return await ApplicationInstance.update(this.metadata.name, updates);
137
+ }
138
+ async listRevisions() {
139
+ const { data } = await listApplicationRevisions({
140
+ path: { applicationName: this.metadata.name },
141
+ throwOnError: true,
142
+ });
143
+ return data;
144
+ }
145
+ }
@@ -0,0 +1 @@
1
+ export { ApplicationInstance } from "./application.js";
@@ -24,8 +24,8 @@ function missingCredentialsMessage() {
24
24
  return "No Blaxel credentials found. Set the BL_API_KEY and BL_WORKSPACE environment variables, or run `bl login`.";
25
25
  }
26
26
  // Build info - these placeholders are replaced at build time by build:replace-imports
27
- const BUILD_VERSION = "0.3.7-preview.230";
28
- const BUILD_COMMIT = "110dd5983dfa658153d44e36dc9b02ffe6a90d77";
27
+ const BUILD_VERSION = "0.3.8-preview.232";
28
+ const BUILD_COMMIT = "984d0f21ad10014285117ebbbff73e62efd5cf98";
29
29
  const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
30
30
  const BLAXEL_API_VERSION = "2026-04-28";
31
31
  // Bun < 1.3.11 never sends connection-level WINDOW_UPDATE: the pooled h2
@@ -1,5 +1,6 @@
1
1
  import "./common/autoload.js";
2
2
  export * from "./agents/index.js";
3
+ export * from "./application/index.js";
3
4
  export * from "./client/client.js";
4
5
  export * from "./common/autoload.js";
5
6
  export * from "./common/env.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaxel/core",
3
- "version": "0.3.7-preview.230",
3
+ "version": "0.3.8-preview.232",
4
4
  "description": "Blaxel Core SDK for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Blaxel, INC (https://blaxel.ai)",