@riddledc/riddle-proof 0.8.35 → 0.8.37
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.
- package/dist/{chunk-TWTEUS7R.js → chunk-DI2XNGEZ.js} +126 -1
- package/dist/{chunk-UGHN77PS.js → chunk-F4HKK2YH.js} +35 -4
- package/dist/{chunk-PEWAIEER.js → chunk-Z2LCVROU.js} +126 -0
- package/dist/cli/index.js +3 -3
- package/dist/cli.cjs +285 -3
- package/dist/cli.js +3 -3
- package/dist/index.cjs +252 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/profile/index.cjs +126 -0
- package/dist/profile/index.js +1 -1
- package/dist/profile.cjs +126 -0
- package/dist/profile.d.cts +2 -0
- package/dist/profile.d.ts +2 -0
- package/dist/profile.js +1 -1
- package/dist/riddle-client.cjs +126 -1
- package/dist/riddle-client.d.cts +21 -1
- package/dist/riddle-client.d.ts +21 -1
- package/dist/riddle-client.js +1 -1
- package/dist/runtime/index.cjs +126 -1
- package/dist/runtime/index.d.cts +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/riddle-client.cjs +126 -1
- package/dist/runtime/riddle-client.d.cts +1 -1
- package/dist/runtime/riddle-client.d.ts +1 -1
- package/dist/runtime/riddle-client.js +1 -1
- package/examples/regression-packs/oc-flow-regression.json +16 -2
- package/package.json +1 -1
|
@@ -132,10 +132,68 @@ function previewDeployResultFromRecord(input) {
|
|
|
132
132
|
function canRecoverPreviewPublish(error) {
|
|
133
133
|
return error instanceof RiddleApiError && PREVIEW_PUBLISH_RECOVERY_STATUSES.has(error.status);
|
|
134
134
|
}
|
|
135
|
+
function summarizePreviewDirectory(directory) {
|
|
136
|
+
const stack = [directory];
|
|
137
|
+
let fileCount = 0;
|
|
138
|
+
let totalBytes = 0;
|
|
139
|
+
while (stack.length) {
|
|
140
|
+
const current = stack.pop();
|
|
141
|
+
for (const entry of (0, import_node_fs.readdirSync)(current, { withFileTypes: true })) {
|
|
142
|
+
const fullPath = import_node_path.default.join(current, entry.name);
|
|
143
|
+
if (entry.isDirectory()) {
|
|
144
|
+
stack.push(fullPath);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (!entry.isFile()) continue;
|
|
148
|
+
const stat = (0, import_node_fs.statSync)(fullPath);
|
|
149
|
+
fileCount += 1;
|
|
150
|
+
totalBytes += stat.size;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return { file_count: fileCount, total_bytes: totalBytes };
|
|
154
|
+
}
|
|
155
|
+
function previewProgressEmitter(config, base) {
|
|
156
|
+
return async (snapshot) => {
|
|
157
|
+
if (!config.onPreviewProgress) return;
|
|
158
|
+
await config.onPreviewProgress({
|
|
159
|
+
label: base.label,
|
|
160
|
+
framework: base.framework,
|
|
161
|
+
directory: base.directory,
|
|
162
|
+
elapsed_ms: Math.max(0, Date.now() - base.startedAt),
|
|
163
|
+
warnings: base.warnings?.length ? base.warnings : void 0,
|
|
164
|
+
...snapshot
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
}
|
|
135
168
|
async function waitForPublishedPreview(config, input) {
|
|
169
|
+
await input.emitProgress?.({
|
|
170
|
+
stage: "publish_recovering",
|
|
171
|
+
id: input.id,
|
|
172
|
+
file_count: input.localSummary?.file_count,
|
|
173
|
+
total_bytes: input.localSummary?.total_bytes,
|
|
174
|
+
publish_error: input.publishError.message,
|
|
175
|
+
message: `publish returned ${input.publishError.status}; polling preview status`
|
|
176
|
+
});
|
|
136
177
|
for (let attempt = 1; attempt <= PREVIEW_PUBLISH_RECOVERY_ATTEMPTS; attempt += 1) {
|
|
137
178
|
const status = await riddleRequestJson(config, `/v1/preview/${input.id}`);
|
|
179
|
+
await input.emitProgress?.({
|
|
180
|
+
stage: "checking_status",
|
|
181
|
+
id: input.id,
|
|
182
|
+
attempt,
|
|
183
|
+
attempts: PREVIEW_PUBLISH_RECOVERY_ATTEMPTS,
|
|
184
|
+
status: typeof status.status === "string" ? status.status : null,
|
|
185
|
+
preview_url: typeof status.preview_url === "string" ? status.preview_url : void 0,
|
|
186
|
+
file_count: typeof status.file_count === "number" ? status.file_count : input.localSummary?.file_count,
|
|
187
|
+
total_bytes: typeof status.total_bytes === "number" ? status.total_bytes : input.localSummary?.total_bytes
|
|
188
|
+
});
|
|
138
189
|
if (String(status.status || "") === "ready" && String(status.preview_url || "").trim()) {
|
|
190
|
+
await input.emitProgress?.({
|
|
191
|
+
stage: "ready",
|
|
192
|
+
id: input.id,
|
|
193
|
+
preview_url: String(status.preview_url),
|
|
194
|
+
file_count: typeof status.file_count === "number" ? status.file_count : input.localSummary?.file_count,
|
|
195
|
+
total_bytes: typeof status.total_bytes === "number" ? status.total_bytes : input.localSummary?.total_bytes
|
|
196
|
+
});
|
|
139
197
|
return previewDeployResultFromRecord({
|
|
140
198
|
record: status,
|
|
141
199
|
id: input.id,
|
|
@@ -157,7 +215,17 @@ async function deployRiddlePreview(config, directory, label, framework = "static
|
|
|
157
215
|
if (!directory?.trim()) throw new Error("directory is required");
|
|
158
216
|
if (!label?.trim()) throw new Error("label is required");
|
|
159
217
|
if (framework !== "spa" && framework !== "static") throw new Error("framework must be spa or static");
|
|
218
|
+
const startedAt = Date.now();
|
|
160
219
|
const warnings = collectRiddlePreviewDeployWarnings(directory, framework);
|
|
220
|
+
const emitProgress = previewProgressEmitter(config, { label, framework, directory, startedAt, warnings });
|
|
221
|
+
await emitProgress({ stage: "validating", message: "checking preview input directory" });
|
|
222
|
+
const localSummary = summarizePreviewDirectory(directory);
|
|
223
|
+
await emitProgress({
|
|
224
|
+
stage: "creating",
|
|
225
|
+
file_count: localSummary.file_count,
|
|
226
|
+
total_bytes: localSummary.total_bytes,
|
|
227
|
+
message: "creating preview upload target"
|
|
228
|
+
});
|
|
161
229
|
const created = await riddleRequestJson(config, "/v1/preview", {
|
|
162
230
|
method: "POST",
|
|
163
231
|
body: JSON.stringify({ framework, label })
|
|
@@ -165,10 +233,42 @@ async function deployRiddlePreview(config, directory, label, framework = "static
|
|
|
165
233
|
const id = String(created.id || "");
|
|
166
234
|
const uploadUrl = String(created.upload_url || "");
|
|
167
235
|
if (!id || !uploadUrl) throw new Error("Riddle preview create response was missing id or upload_url.");
|
|
236
|
+
await emitProgress({
|
|
237
|
+
stage: "created",
|
|
238
|
+
id,
|
|
239
|
+
file_count: localSummary.file_count,
|
|
240
|
+
total_bytes: localSummary.total_bytes,
|
|
241
|
+
message: "preview upload target created"
|
|
242
|
+
});
|
|
168
243
|
const scratch = (0, import_node_fs.mkdtempSync)(import_node_path.default.join((0, import_node_os.tmpdir)(), "riddle-preview-upload-"));
|
|
169
244
|
const tarball = import_node_path.default.join(scratch, `${id}.tar.gz`);
|
|
245
|
+
let tarballBytes = 0;
|
|
170
246
|
try {
|
|
247
|
+
await emitProgress({
|
|
248
|
+
stage: "archiving",
|
|
249
|
+
id,
|
|
250
|
+
file_count: localSummary.file_count,
|
|
251
|
+
total_bytes: localSummary.total_bytes,
|
|
252
|
+
message: "creating preview archive"
|
|
253
|
+
});
|
|
171
254
|
(0, import_node_child_process.execFileSync)("tar", ["czf", tarball, "-C", directory, "."], { stdio: "pipe" });
|
|
255
|
+
tarballBytes = (0, import_node_fs.statSync)(tarball).size;
|
|
256
|
+
await emitProgress({
|
|
257
|
+
stage: "archived",
|
|
258
|
+
id,
|
|
259
|
+
file_count: localSummary.file_count,
|
|
260
|
+
total_bytes: localSummary.total_bytes,
|
|
261
|
+
tarball_bytes: tarballBytes,
|
|
262
|
+
message: "preview archive created"
|
|
263
|
+
});
|
|
264
|
+
await emitProgress({
|
|
265
|
+
stage: "uploading",
|
|
266
|
+
id,
|
|
267
|
+
file_count: localSummary.file_count,
|
|
268
|
+
total_bytes: localSummary.total_bytes,
|
|
269
|
+
tarball_bytes: tarballBytes,
|
|
270
|
+
message: "uploading preview archive"
|
|
271
|
+
});
|
|
172
272
|
const upload = await fetchFor(config)(uploadUrl, {
|
|
173
273
|
method: "PUT",
|
|
174
274
|
headers: { "Content-Type": "application/gzip" },
|
|
@@ -177,14 +277,37 @@ async function deployRiddlePreview(config, directory, label, framework = "static
|
|
|
177
277
|
if (!upload.ok) {
|
|
178
278
|
throw new RiddleApiError(uploadUrl, upload.status, await upload.text());
|
|
179
279
|
}
|
|
280
|
+
await emitProgress({
|
|
281
|
+
stage: "uploaded",
|
|
282
|
+
id,
|
|
283
|
+
file_count: localSummary.file_count,
|
|
284
|
+
total_bytes: localSummary.total_bytes,
|
|
285
|
+
tarball_bytes: tarballBytes,
|
|
286
|
+
message: "preview archive uploaded"
|
|
287
|
+
});
|
|
180
288
|
} finally {
|
|
181
289
|
(0, import_node_fs.rmSync)(scratch, { recursive: true, force: true });
|
|
182
290
|
}
|
|
183
291
|
const expiresAt = typeof created.expires_at === "string" ? created.expires_at : void 0;
|
|
184
292
|
try {
|
|
293
|
+
await emitProgress({
|
|
294
|
+
stage: "publishing",
|
|
295
|
+
id,
|
|
296
|
+
file_count: localSummary.file_count,
|
|
297
|
+
total_bytes: localSummary.total_bytes,
|
|
298
|
+
tarball_bytes: tarballBytes || void 0,
|
|
299
|
+
message: "publishing preview"
|
|
300
|
+
});
|
|
185
301
|
const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
|
|
186
302
|
method: "POST"
|
|
187
303
|
});
|
|
304
|
+
await emitProgress({
|
|
305
|
+
stage: "ready",
|
|
306
|
+
id,
|
|
307
|
+
preview_url: String(published.preview_url || ""),
|
|
308
|
+
file_count: typeof published.file_count === "number" ? published.file_count : localSummary.file_count,
|
|
309
|
+
total_bytes: typeof published.total_bytes === "number" ? published.total_bytes : localSummary.total_bytes
|
|
310
|
+
});
|
|
188
311
|
return previewDeployResultFromRecord({ record: published, id, label, framework, expiresAt, warnings });
|
|
189
312
|
} catch (error) {
|
|
190
313
|
if (!canRecoverPreviewPublish(error)) throw error;
|
|
@@ -194,7 +317,9 @@ async function deployRiddlePreview(config, directory, label, framework = "static
|
|
|
194
317
|
framework,
|
|
195
318
|
expiresAt,
|
|
196
319
|
publishError: error,
|
|
197
|
-
warnings
|
|
320
|
+
warnings,
|
|
321
|
+
localSummary,
|
|
322
|
+
emitProgress
|
|
198
323
|
});
|
|
199
324
|
}
|
|
200
325
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, RiddleApiKeySource, RiddleBalanceResult, RiddleClientConfig, RiddleFetch, RiddlePollJobOptions, RiddlePollJobResult, RiddlePollProgressSnapshot, RiddlePollSummary, RiddlePreviewDeployResult, RiddlePreviewFramework, RiddleRunScriptInput, RiddleServerPreviewInput, RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview } from '../riddle-client.cjs';
|
|
1
|
+
export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, RiddleApiKeySource, RiddleBalanceResult, RiddleClientConfig, RiddleFetch, RiddlePollJobOptions, RiddlePollJobResult, RiddlePollProgressSnapshot, RiddlePollSummary, RiddlePreviewDeployProgressSnapshot, RiddlePreviewDeployResult, RiddlePreviewDeployStage, RiddlePreviewFramework, RiddleRunScriptInput, RiddleServerPreviewInput, RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview } from '../riddle-client.cjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, RiddleApiKeySource, RiddleBalanceResult, RiddleClientConfig, RiddleFetch, RiddlePollJobOptions, RiddlePollJobResult, RiddlePollProgressSnapshot, RiddlePollSummary, RiddlePreviewDeployResult, RiddlePreviewFramework, RiddleRunScriptInput, RiddleServerPreviewInput, RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview } from '../riddle-client.js';
|
|
1
|
+
export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, RiddleApiKeySource, RiddleBalanceResult, RiddleClientConfig, RiddleFetch, RiddlePollJobOptions, RiddlePollJobResult, RiddlePollProgressSnapshot, RiddlePollSummary, RiddlePreviewDeployProgressSnapshot, RiddlePreviewDeployResult, RiddlePreviewDeployStage, RiddlePreviewFramework, RiddleRunScriptInput, RiddleServerPreviewInput, RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview } from '../riddle-client.js';
|
|
@@ -67,7 +67,14 @@
|
|
|
67
67
|
"wait_for_selector": "main#main-content",
|
|
68
68
|
"viewports": [{ "name": "desktop", "width": 1280, "height": 900 }],
|
|
69
69
|
"setup_actions": [
|
|
70
|
-
{
|
|
70
|
+
{
|
|
71
|
+
"type": "click",
|
|
72
|
+
"selector": "a[href*='/proof']",
|
|
73
|
+
"text": "Proof",
|
|
74
|
+
"expected_path": "/proof/",
|
|
75
|
+
"timeout_ms": 10000,
|
|
76
|
+
"after_ms": 750
|
|
77
|
+
}
|
|
71
78
|
]
|
|
72
79
|
},
|
|
73
80
|
"checks": [
|
|
@@ -93,7 +100,14 @@
|
|
|
93
100
|
"wait_for_selector": "main#main-content",
|
|
94
101
|
"viewports": [{ "name": "desktop", "width": 1280, "height": 900 }],
|
|
95
102
|
"setup_actions": [
|
|
96
|
-
{
|
|
103
|
+
{
|
|
104
|
+
"type": "click",
|
|
105
|
+
"selector": "a[href='/'], a[href='https://riddledc.com/']",
|
|
106
|
+
"text": "Riddle",
|
|
107
|
+
"expected_path": "/",
|
|
108
|
+
"timeout_ms": 10000,
|
|
109
|
+
"after_ms": 750
|
|
110
|
+
}
|
|
97
111
|
]
|
|
98
112
|
},
|
|
99
113
|
"checks": [
|