@tpmjs/tools-sprites-checkpoint-create 0.1.3 → 0.1.4

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 (2) hide show
  1. package/dist/index.js +21 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -83,33 +83,39 @@ var spritesCheckpointCreateTool = tool({
83
83
  throw new Error("Failed to read response from Sprites API");
84
84
  }
85
85
  const lines = text.trim().split("\n").filter((line) => line.trim());
86
- let checkpointData = null;
86
+ let checkpointId = "";
87
+ let createdAt = "";
87
88
  for (const line of lines) {
88
89
  try {
89
90
  const parsed = JSON.parse(line);
90
- if (parsed.id || parsed.checkpoint_id) {
91
- checkpointData = parsed;
91
+ if (parsed.type === "error") {
92
+ throw new Error(`Checkpoint creation failed: ${parsed.data || "Unknown error"}`);
92
93
  }
93
- if (parsed.error) {
94
- throw new Error(`Checkpoint creation failed: ${parsed.error}`);
94
+ if (parsed.type === "info" && parsed.data?.trim().startsWith("ID:")) {
95
+ checkpointId = parsed.data.trim().replace("ID:", "").trim();
96
+ }
97
+ if (parsed.type === "info" && parsed.data?.trim().startsWith("Created:")) {
98
+ createdAt = parsed.data.trim().replace("Created:", "").trim();
99
+ }
100
+ if (parsed.type === "complete" && parsed.data && !checkpointId) {
101
+ const match = parsed.data.match(/Checkpoint\s+(\S+)\s+created/);
102
+ if (match && match[1]) {
103
+ checkpointId = match[1];
104
+ }
95
105
  }
96
106
  } catch (parseError) {
97
107
  if (parseError instanceof SyntaxError) continue;
98
108
  throw parseError;
99
109
  }
100
110
  }
101
- if (!checkpointData) {
102
- try {
103
- checkpointData = JSON.parse(text);
104
- } catch {
105
- throw new Error(`Failed to parse checkpoint response. Raw response: ${text.slice(0, 200)}`);
106
- }
111
+ if (!checkpointId) {
112
+ throw new Error(`Failed to extract checkpoint ID from response. Raw response: ${text.slice(0, 300)}`);
107
113
  }
108
114
  return {
109
- id: checkpointData.id || checkpointData.checkpoint_id || "",
110
- name: checkpointData.name || checkpointName,
111
- createdAt: checkpointData.createdAt || checkpointData.created_at || (/* @__PURE__ */ new Date()).toISOString(),
112
- size: checkpointData.size
115
+ id: checkpointId,
116
+ name: checkpointName || checkpointId,
117
+ createdAt: createdAt || (/* @__PURE__ */ new Date()).toISOString(),
118
+ size: void 0
113
119
  };
114
120
  }
115
121
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpmjs/tools-sprites-checkpoint-create",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Create a point-in-time snapshot of a sprite's filesystem state for later restoration",
5
5
  "type": "module",
6
6
  "keywords": [