@powerformer/prism-client 0.9.0 → 0.10.0
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/build-info.json +3 -3
- package/dist/{chunk-3GDVHLYY.js → chunk-7NEPBMKR.js} +17 -13
- package/dist/sdk/astro.d.ts +2 -0
- package/dist/sdk/astro.js +8 -3
- package/dist/sdk/visual-lane.d.ts +2 -0
- package/dist/sdk/visual-lane.js +2 -2
- package/dist/sdk/visual-map.d.ts +5 -1
- package/dist/sdk/visual-map.js +1 -1
- package/dist/sdk/visual-middleware.js +1 -1
- package/package.json +1 -1
package/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerformer/prism-client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"gitCommit": "
|
|
5
|
-
"sourceSha256": "
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"gitCommit": "ad1227fead1f643a578d2bc3ca971973a7c16d3c",
|
|
5
|
+
"sourceSha256": "9d3bcf925346949fa2573aa66659c8e8296123d9f54f762bb4a63f7899752366",
|
|
6
6
|
"contentContract": "app/contracts",
|
|
7
7
|
"contentContractSha256": "443ac891fd70f4ff6c59193de4668cb7bd0136d879eead0b0e100e4f480ddd32"
|
|
8
8
|
}
|
|
@@ -403,19 +403,19 @@ function verifyVisualExpectations(input) {
|
|
|
403
403
|
});
|
|
404
404
|
continue;
|
|
405
405
|
}
|
|
406
|
-
let actual = matches[0].text,
|
|
406
|
+
let actual = matches[0].text, ok2 = !1, expectedStr = typeof exp.expectedValue == "string" ? normalizeSpace(exp.expectedValue) : String(exp.expectedValue);
|
|
407
407
|
if (exp.matchType === "exact-text")
|
|
408
|
-
|
|
408
|
+
ok2 = actual === expectedStr;
|
|
409
409
|
else if (exp.matchType === "media-src")
|
|
410
|
-
|
|
410
|
+
ok2 = actual === String(exp.expectedValue) || actual.includes(String(exp.expectedValue));
|
|
411
411
|
else if (exp.matchType === "override-number")
|
|
412
|
-
|
|
412
|
+
ok2 = actual.includes(String(exp.expectedValue)) && !/\b(?:NaN|undefined|null)\b/.test(actual);
|
|
413
413
|
else if (exp.matchType === "template-segments") {
|
|
414
414
|
let plain = normalizeSpace(expectedStr.replace(/\*\*/g, "").replace(/\{[^}]+\}/g, " ")), segments = expectedStr.replace(/\*\*/g, "").split(/\{[^}]+\}/).map(normalizeSpace).filter((s) => s.length >= 3);
|
|
415
|
-
|
|
415
|
+
ok2 = segments.length > 0 ? segments.every((seg) => actual.includes(seg)) : actual.includes(plain);
|
|
416
416
|
} else if (exp.matchType === "richtext-html") {
|
|
417
417
|
let stripped = normalizeSpace(String(exp.expectedValue).replace(/<[^>]+>/g, " ")), head = stripped.slice(0, Math.min(40, stripped.length));
|
|
418
|
-
|
|
418
|
+
ok2 = head.length > 0 && actual.includes(head);
|
|
419
419
|
}
|
|
420
420
|
items.push({
|
|
421
421
|
resourceId: bundle.resourceId,
|
|
@@ -424,14 +424,14 @@ function verifyVisualExpectations(input) {
|
|
|
424
424
|
xpath: exp.xpath,
|
|
425
425
|
pointer: exp.pointer,
|
|
426
426
|
locale: exp.locale,
|
|
427
|
-
status:
|
|
427
|
+
status: ok2 ? "passed" : "value_mismatch",
|
|
428
428
|
expected: exp.expectedValue,
|
|
429
429
|
actual,
|
|
430
|
-
detail:
|
|
430
|
+
detail: ok2 ? "Matched expected rendered output" : `Expected "${expectedStr}" but rendered "${actual}"`
|
|
431
431
|
});
|
|
432
432
|
}
|
|
433
433
|
let passed = items.filter((i) => i.status === "passed").length, failed = items.length - passed;
|
|
434
|
-
return { ok: failed === 0, checkedAt: (/* @__PURE__ */ new Date()).toISOString(), total: items.length, passed, failed, items };
|
|
434
|
+
return { ok: failed === 0 && (!input.requireNonEmpty || items.length > 0), checkedAt: (/* @__PURE__ */ new Date()).toISOString(), total: items.length, passed, failed, items };
|
|
435
435
|
}
|
|
436
436
|
function finalizeVisualArtifacts(options) {
|
|
437
437
|
let prismDir = resolve(options.rootDir, ".prism"), traceDir = join(prismDir, "trace"), cacheDir = join(prismDir, "cache"), cacheFile = join(cacheDir, "trace-state.json");
|
|
@@ -472,11 +472,15 @@ function finalizeVisualArtifacts(options) {
|
|
|
472
472
|
tracedPages: merged.size
|
|
473
473
|
}, null, 2) + `
|
|
474
474
|
`, "utf8"), mkdirSync(options.outDir, { recursive: !0 });
|
|
475
|
-
let
|
|
476
|
-
|
|
477
|
-
|
|
475
|
+
let targetPublicConfigPath = resolve(options.outDir, "prism-visual.json"), publicKeyPem = options.encryptPublicKeyPem?.trim() || "", requireEncryption = options.requireEncryption ?? options.environment === "prod", publicConfigPath = null;
|
|
476
|
+
if (publicKeyPem) {
|
|
477
|
+
let envelope = encryptVisualEnvelope(publicConfig, publicKeyPem, options.encryptKeyId ?? "prism-visual-v1");
|
|
478
|
+
writeFileSync(targetPublicConfigPath, JSON.stringify(envelope) + `
|
|
479
|
+
`, "utf8"), publicConfigPath = targetPublicConfigPath;
|
|
480
|
+
} else requireEncryption ? rmSync(targetPublicConfigPath, { force: !0 }) : (writeFileSync(targetPublicConfigPath, JSON.stringify(publicConfig) + `
|
|
481
|
+
`, "utf8"), publicConfigPath = targetPublicConfigPath);
|
|
478
482
|
let verifyReport;
|
|
479
|
-
return options.verify &&
|
|
483
|
+
return options.verify && (verifyReport = verifyVisualExpectations({ outDir: options.outDir, bundles: expectations, requireNonEmpty: !0 }), writeFileSync(join(prismDir, "visual-verify-report.json"), JSON.stringify(verifyReport, null, 2) + `
|
|
480
484
|
`, "utf8")), { visualMapPath, publicConfigPath, publicConfig, verifyReport };
|
|
481
485
|
}
|
|
482
486
|
|
package/dist/sdk/astro.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface PrismVisualMapOptions {
|
|
|
21
21
|
/** Optional RSA public key PEM for envelope encrypting out/prism-visual.json (plaintext in local dev). */
|
|
22
22
|
encryptPublicKeyPem?: string;
|
|
23
23
|
encryptKeyId?: string;
|
|
24
|
+
/** Require public-key encryption to emit out/prism-visual.json. Defaults to `true` in `prod` (fail-closed: no key => feature disabled). */
|
|
25
|
+
requireEncryption?: boolean;
|
|
24
26
|
/** Dev-only optional resolver so Chrome extension can inspect live 11-locale slices locally on 127.0.0.1. */
|
|
25
27
|
devSliceResolver?: (params: {
|
|
26
28
|
resourceId: string;
|
package/dist/sdk/astro.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
getLivePageReads,
|
|
6
6
|
readOverridesFile,
|
|
7
7
|
resolveBuildRef
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-7NEPBMKR.js";
|
|
9
9
|
import {
|
|
10
10
|
getRuntime,
|
|
11
11
|
releaseRuntime,
|
|
@@ -156,16 +156,21 @@ function prismVisualMap(options = {}) {
|
|
|
156
156
|
},
|
|
157
157
|
"astro:build:done": ({ logger }) => {
|
|
158
158
|
if (isDev) return;
|
|
159
|
-
let verifyEnabled = process.env.PRISM_VISUAL_VERIFY === "1" && !!(process.env.PRISM_VERSION_OVERRIDE || process.env.PRISM_VERSION), publicKeyPem = options.encryptPublicKeyPem ?? process.env.PRISM_VISUAL_PUBLIC_KEY_PEM, result = finalizeVisualArtifacts({
|
|
159
|
+
let verifyEnabled = process.env.PRISM_VISUAL_VERIFY === "1" && !!(process.env.PRISM_VERSION_OVERRIDE || process.env.PRISM_VERSION), publicKeyPem = options.encryptPublicKeyPem ?? process.env.PRISM_VISUAL_PUBLIC_KEY_PEM, requireEncryption = options.requireEncryption ?? activeEnv === "prod", result = finalizeVisualArtifacts({
|
|
160
160
|
rootDir,
|
|
161
161
|
outDir,
|
|
162
162
|
environment: activeEnv,
|
|
163
163
|
overridesFile: options.overridesFile ?? "prism.visual.json",
|
|
164
164
|
encryptPublicKeyPem: publicKeyPem,
|
|
165
165
|
encryptKeyId: options.encryptKeyId ?? process.env.PRISM_VISUAL_KEY_ID ?? "prism-visual-v1",
|
|
166
|
+
requireEncryption,
|
|
166
167
|
verify: verifyEnabled
|
|
167
168
|
});
|
|
168
|
-
if (logger.info(`Wrote ${result.visualMapPath} and ${result.publicConfigPath} (${result.publicConfig.routes.length} routes).`)
|
|
169
|
+
if (result.publicConfigPath ? logger.info(`Wrote ${result.visualMapPath} and ${result.publicConfigPath} (${result.publicConfig.routes.length} routes).`) : logger.warn(
|
|
170
|
+
`PRISM_VISUAL_PUBLIC_KEY_PEM is not configured for ${activeEnv}; skipped writing out/prism-visual.json so visual editing remains disabled (fail-closed).`
|
|
171
|
+
), result.verifyReport && (logger.info(`Visual XPath verification: ${result.verifyReport.passed}/${result.verifyReport.total} passed.`), !result.verifyReport.ok)) {
|
|
172
|
+
if (result.verifyReport.total === 0)
|
|
173
|
+
throw new Error("Prism visual XPath verification failed: 0 assertions executed (refusing empty pass).");
|
|
169
174
|
let summary = result.verifyReport.items.filter((item) => item.status !== "passed").map((item) => ` - [${item.status}] ${item.pagePath} ${item.xpath}: ${item.detail}`).join(`
|
|
170
175
|
`);
|
|
171
176
|
throw new Error(`Prism visual XPath verification failed (${result.verifyReport.failed}/${result.verifyReport.total}):
|
|
@@ -32,6 +32,8 @@ export declare function runVisualVerifyLane(options?: {
|
|
|
32
32
|
expectationsDir?: string;
|
|
33
33
|
reportPath?: string;
|
|
34
34
|
bundles?: readonly VisualLaneExpectationBundle[];
|
|
35
|
+
/** By default (`false`), zero executed assertions (`total === 0`) fails closed (`ok: false`). */
|
|
36
|
+
allowEmpty?: boolean;
|
|
35
37
|
}): VisualLaneReport;
|
|
36
38
|
/**
|
|
37
39
|
* Extract an immutable preview URL from deployment stdout/stderr logs.
|
package/dist/sdk/visual-lane.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
verifyVisualExpectations
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-7NEPBMKR.js";
|
|
4
4
|
import "../chunk-XJWMC7TR.js";
|
|
5
5
|
import "../chunk-3B2PZHLA.js";
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ function runVisualVerifyLane(options = {}) {
|
|
|
22
22
|
expectations: parsed.expectations
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
let rawReport = verifyVisualExpectations({ outDir, bundles }), matchTypeByKey = /* @__PURE__ */ new Map();
|
|
25
|
+
let rawReport = verifyVisualExpectations({ outDir, bundles, requireNonEmpty: options.allowEmpty !== !0 }), matchTypeByKey = /* @__PURE__ */ new Map();
|
|
26
26
|
for (let bundle of bundles)
|
|
27
27
|
for (let exp of bundle.expectations)
|
|
28
28
|
matchTypeByKey.set(`${exp.pagePath}|${exp.xpath}|${exp.pointer}|${exp.locale}`, exp.matchType);
|
package/dist/sdk/visual-map.d.ts
CHANGED
|
@@ -156,6 +156,8 @@ export declare function verifyVisualExpectations(input: {
|
|
|
156
156
|
versionId: string;
|
|
157
157
|
expectations: VisualExpectation[];
|
|
158
158
|
}>;
|
|
159
|
+
/** When true, zero executed assertions (`total === 0`) is treated as failed (`ok: false`). */
|
|
160
|
+
requireNonEmpty?: boolean;
|
|
159
161
|
}): VisualVerifyReport;
|
|
160
162
|
export declare function finalizeVisualArtifacts(options: {
|
|
161
163
|
rootDir: string;
|
|
@@ -164,10 +166,12 @@ export declare function finalizeVisualArtifacts(options: {
|
|
|
164
166
|
overridesFile?: string;
|
|
165
167
|
encryptPublicKeyPem?: string;
|
|
166
168
|
encryptKeyId?: string;
|
|
169
|
+
/** Require public-key encryption to emit `out/prism-visual.json`. Defaults to `true` for `prod` (fail-closed: no key => feature disabled). */
|
|
170
|
+
requireEncryption?: boolean;
|
|
167
171
|
verify?: boolean;
|
|
168
172
|
}): {
|
|
169
173
|
visualMapPath: string;
|
|
170
|
-
publicConfigPath: string;
|
|
174
|
+
publicConfigPath: string | null;
|
|
171
175
|
publicConfig: VisualPublicConfig;
|
|
172
176
|
verifyReport?: VisualVerifyReport;
|
|
173
177
|
};
|
package/dist/sdk/visual-map.js
CHANGED
package/package.json
CHANGED