@bonginkan/maria 4.3.9 → 4.3.12

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.
@@ -8529,6 +8529,7 @@ var IMSFacade = class {
8529
8529
  var IMSFacade_default = IMSFacade;
8530
8530
 
8531
8531
  // src/server/express-server.ts
8532
+ var jobIndex = /* @__PURE__ */ new Map();
8532
8533
  var app = express__default.default();
8533
8534
  var port = process.env.PORT || 8080;
8534
8535
  app.use(helmet__default.default());
@@ -8723,9 +8724,17 @@ app.post("/api/v1/image", rateLimitMiddleware, async (req, res) => {
8723
8724
  trace: Math.random().toString(36).slice(2, 8).toUpperCase()
8724
8725
  };
8725
8726
  const saved = await saveArtifacts({ root: process.cwd(), kind: "image" }, buffers.map((b) => ({ bytes: b, ext: `.${format}` })), manifest);
8727
+ jobIndex.set(String(manifest.trace), {
8728
+ id: String(manifest.trace),
8729
+ status: "completed",
8730
+ kind: "image",
8731
+ manifestPath: saved.manifestPath,
8732
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
8733
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
8734
+ });
8726
8735
  const idemKey = req.headers["idempotency-key"] || void 0;
8727
8736
  await recordConsumption("current", { requests: 1, image: Math.max(1, buffers.length) }, idemKey);
8728
- return res.json({ success: true, data: { url: saved.manifestPath } });
8737
+ return res.json({ success: true, data: { url: saved.manifestPath, jobId: manifest.trace } });
8729
8738
  } catch (error) {
8730
8739
  console.error("[Image API] Error:", error);
8731
8740
  return res.status(500).json({
@@ -8771,7 +8780,15 @@ app.post("/api/v1/video", rateLimitMiddleware, async (req, res) => {
8771
8780
  }
8772
8781
  const idemKey = req.headers["idempotency-key"] || void 0;
8773
8782
  await recordConsumption("current", { requests: 1, video: 1 }, idemKey);
8774
- return res.json({ success: true, data: { url: saved.manifestPath } });
8783
+ jobIndex.set(String(manifest.trace), {
8784
+ id: String(manifest.trace),
8785
+ status: "completed",
8786
+ kind: "video",
8787
+ manifestPath: saved.manifestPath,
8788
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
8789
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
8790
+ });
8791
+ return res.json({ success: true, data: { url: saved.manifestPath, jobId: manifest.trace } });
8775
8792
  } catch (error) {
8776
8793
  console.error("[Video API] Error:", error);
8777
8794
  return res.status(500).json({
@@ -8780,6 +8797,35 @@ app.post("/api/v1/video", rateLimitMiddleware, async (req, res) => {
8780
8797
  });
8781
8798
  }
8782
8799
  });
8800
+ app.get("/api/v1/jobs/:id", async (req, res) => {
8801
+ try {
8802
+ const id = String(req.params.id || "").trim();
8803
+ if (!id) return res.status(400).json({ error: "bad_request", message: "id required" });
8804
+ const info = jobIndex.get(id);
8805
+ if (!info) return res.status(404).json({ error: "not_found", message: "job not found" });
8806
+ let manifest;
8807
+ if (info.manifestPath) {
8808
+ try {
8809
+ const full = path__namespace.default.resolve(process.cwd(), info.manifestPath);
8810
+ const txt = await fsp__namespace.default.readFile(full, "utf8");
8811
+ manifest = JSON.parse(txt);
8812
+ } catch {
8813
+ }
8814
+ }
8815
+ return res.json({
8816
+ id: info.id,
8817
+ status: info.status,
8818
+ kind: info.kind,
8819
+ manifestPath: info.manifestPath,
8820
+ manifest,
8821
+ createdAt: info.createdAt,
8822
+ updatedAt: info.updatedAt
8823
+ });
8824
+ } catch (error) {
8825
+ console.error("[Jobs API] Error:", error);
8826
+ return res.status(500).json({ error: "internal_error", message: "failed to fetch job" });
8827
+ }
8828
+ });
8783
8829
  app.post("/api/v1/code", rateLimitMiddleware, async (req, res) => {
8784
8830
  try {
8785
8831
  const { prompt, language = "typescript", model = "gpt-4" } = req.body;
@@ -8529,6 +8529,7 @@ var IMSFacade = class {
8529
8529
  var IMSFacade_default = IMSFacade;
8530
8530
 
8531
8531
  // src/server/express-server.ts
8532
+ var jobIndex = /* @__PURE__ */ new Map();
8532
8533
  var app = express__default.default();
8533
8534
  var port = process.env.PORT || 8080;
8534
8535
  app.use(helmet__default.default());
@@ -8723,9 +8724,17 @@ app.post("/api/v1/image", rateLimitMiddleware, async (req, res) => {
8723
8724
  trace: Math.random().toString(36).slice(2, 8).toUpperCase()
8724
8725
  };
8725
8726
  const saved = await saveArtifacts({ root: process.cwd(), kind: "image" }, buffers.map((b) => ({ bytes: b, ext: `.${format}` })), manifest);
8727
+ jobIndex.set(String(manifest.trace), {
8728
+ id: String(manifest.trace),
8729
+ status: "completed",
8730
+ kind: "image",
8731
+ manifestPath: saved.manifestPath,
8732
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
8733
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
8734
+ });
8726
8735
  const idemKey = req.headers["idempotency-key"] || void 0;
8727
8736
  await recordConsumption("current", { requests: 1, image: Math.max(1, buffers.length) }, idemKey);
8728
- return res.json({ success: true, data: { url: saved.manifestPath } });
8737
+ return res.json({ success: true, data: { url: saved.manifestPath, jobId: manifest.trace } });
8729
8738
  } catch (error) {
8730
8739
  console.error("[Image API] Error:", error);
8731
8740
  return res.status(500).json({
@@ -8771,7 +8780,15 @@ app.post("/api/v1/video", rateLimitMiddleware, async (req, res) => {
8771
8780
  }
8772
8781
  const idemKey = req.headers["idempotency-key"] || void 0;
8773
8782
  await recordConsumption("current", { requests: 1, video: 1 }, idemKey);
8774
- return res.json({ success: true, data: { url: saved.manifestPath } });
8783
+ jobIndex.set(String(manifest.trace), {
8784
+ id: String(manifest.trace),
8785
+ status: "completed",
8786
+ kind: "video",
8787
+ manifestPath: saved.manifestPath,
8788
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
8789
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
8790
+ });
8791
+ return res.json({ success: true, data: { url: saved.manifestPath, jobId: manifest.trace } });
8775
8792
  } catch (error) {
8776
8793
  console.error("[Video API] Error:", error);
8777
8794
  return res.status(500).json({
@@ -8780,6 +8797,35 @@ app.post("/api/v1/video", rateLimitMiddleware, async (req, res) => {
8780
8797
  });
8781
8798
  }
8782
8799
  });
8800
+ app.get("/api/v1/jobs/:id", async (req, res) => {
8801
+ try {
8802
+ const id = String(req.params.id || "").trim();
8803
+ if (!id) return res.status(400).json({ error: "bad_request", message: "id required" });
8804
+ const info = jobIndex.get(id);
8805
+ if (!info) return res.status(404).json({ error: "not_found", message: "job not found" });
8806
+ let manifest;
8807
+ if (info.manifestPath) {
8808
+ try {
8809
+ const full = path__namespace.default.resolve(process.cwd(), info.manifestPath);
8810
+ const txt = await fsp__namespace.default.readFile(full, "utf8");
8811
+ manifest = JSON.parse(txt);
8812
+ } catch {
8813
+ }
8814
+ }
8815
+ return res.json({
8816
+ id: info.id,
8817
+ status: info.status,
8818
+ kind: info.kind,
8819
+ manifestPath: info.manifestPath,
8820
+ manifest,
8821
+ createdAt: info.createdAt,
8822
+ updatedAt: info.updatedAt
8823
+ });
8824
+ } catch (error) {
8825
+ console.error("[Jobs API] Error:", error);
8826
+ return res.status(500).json({ error: "internal_error", message: "failed to fetch job" });
8827
+ }
8828
+ });
8783
8829
  app.post("/api/v1/code", rateLimitMiddleware, async (req, res) => {
8784
8830
  try {
8785
8831
  const { prompt, language = "typescript", model = "gpt-4" } = req.body;
@@ -8529,6 +8529,7 @@ var IMSFacade = class {
8529
8529
  var IMSFacade_default = IMSFacade;
8530
8530
 
8531
8531
  // src/server/express-server.ts
8532
+ var jobIndex = /* @__PURE__ */ new Map();
8532
8533
  var app = express__default.default();
8533
8534
  var port = process.env.PORT || 8080;
8534
8535
  app.use(helmet__default.default());
@@ -8723,9 +8724,17 @@ app.post("/api/v1/image", rateLimitMiddleware, async (req, res) => {
8723
8724
  trace: Math.random().toString(36).slice(2, 8).toUpperCase()
8724
8725
  };
8725
8726
  const saved = await saveArtifacts({ root: process.cwd(), kind: "image" }, buffers.map((b) => ({ bytes: b, ext: `.${format}` })), manifest);
8727
+ jobIndex.set(String(manifest.trace), {
8728
+ id: String(manifest.trace),
8729
+ status: "completed",
8730
+ kind: "image",
8731
+ manifestPath: saved.manifestPath,
8732
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
8733
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
8734
+ });
8726
8735
  const idemKey = req.headers["idempotency-key"] || void 0;
8727
8736
  await recordConsumption("current", { requests: 1, image: Math.max(1, buffers.length) }, idemKey);
8728
- return res.json({ success: true, data: { url: saved.manifestPath } });
8737
+ return res.json({ success: true, data: { url: saved.manifestPath, jobId: manifest.trace } });
8729
8738
  } catch (error) {
8730
8739
  console.error("[Image API] Error:", error);
8731
8740
  return res.status(500).json({
@@ -8771,7 +8780,15 @@ app.post("/api/v1/video", rateLimitMiddleware, async (req, res) => {
8771
8780
  }
8772
8781
  const idemKey = req.headers["idempotency-key"] || void 0;
8773
8782
  await recordConsumption("current", { requests: 1, video: 1 }, idemKey);
8774
- return res.json({ success: true, data: { url: saved.manifestPath } });
8783
+ jobIndex.set(String(manifest.trace), {
8784
+ id: String(manifest.trace),
8785
+ status: "completed",
8786
+ kind: "video",
8787
+ manifestPath: saved.manifestPath,
8788
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
8789
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
8790
+ });
8791
+ return res.json({ success: true, data: { url: saved.manifestPath, jobId: manifest.trace } });
8775
8792
  } catch (error) {
8776
8793
  console.error("[Video API] Error:", error);
8777
8794
  return res.status(500).json({
@@ -8780,6 +8797,35 @@ app.post("/api/v1/video", rateLimitMiddleware, async (req, res) => {
8780
8797
  });
8781
8798
  }
8782
8799
  });
8800
+ app.get("/api/v1/jobs/:id", async (req, res) => {
8801
+ try {
8802
+ const id = String(req.params.id || "").trim();
8803
+ if (!id) return res.status(400).json({ error: "bad_request", message: "id required" });
8804
+ const info = jobIndex.get(id);
8805
+ if (!info) return res.status(404).json({ error: "not_found", message: "job not found" });
8806
+ let manifest;
8807
+ if (info.manifestPath) {
8808
+ try {
8809
+ const full = path__namespace.default.resolve(process.cwd(), info.manifestPath);
8810
+ const txt = await fsp__namespace.default.readFile(full, "utf8");
8811
+ manifest = JSON.parse(txt);
8812
+ } catch {
8813
+ }
8814
+ }
8815
+ return res.json({
8816
+ id: info.id,
8817
+ status: info.status,
8818
+ kind: info.kind,
8819
+ manifestPath: info.manifestPath,
8820
+ manifest,
8821
+ createdAt: info.createdAt,
8822
+ updatedAt: info.updatedAt
8823
+ });
8824
+ } catch (error) {
8825
+ console.error("[Jobs API] Error:", error);
8826
+ return res.status(500).json({ error: "internal_error", message: "failed to fetch job" });
8827
+ }
8828
+ });
8783
8829
  app.post("/api/v1/code", rateLimitMiddleware, async (req, res) => {
8784
8830
  try {
8785
8831
  const { prompt, language = "typescript", model = "gpt-4" } = req.body;