UNPKG

@prisma/cli

Version:

Command-line interface for the Prisma Developer Platform.

35 lines (34 loc) 1.6 kB
//#region ../cli-telemetry/dist/payload-B88Qvzxk.js function isNonEmptyString(value) { return typeof value === "string" && value.length > 0; } function isStringArray(value) { return Array.isArray(value) && value.every((entry) => typeof entry === "string"); } /** * Runtime validation for {@link ParentToSenderPayload}. The child sender * uses this before `postEvent` so a payload missing a required field * cannot silently produce a degraded telemetry event downstream. * * Same semantics as the ORM CLI's arktype schema (this repo carries no * arktype dependency, so the checks are spelled out): required scalars * must be non-empty strings; the optional `databaseTarget` override is * a `string` when present (no `null` — see the type's doc-block); the * string array is validated element-by-element. Size caps are enforced * by the backend, not here — IPC is structured-cloned and the * parent/child agree on the schema by version-coupling. */ function isParentToSenderPayload(value) { if (value === null || typeof value !== "object" || Array.isArray(value)) return false; const record = value; if (!isNonEmptyString(record.installationId)) return false; if (!isNonEmptyString(record.version)) return false; if (!isNonEmptyString(record.command)) return false; if (!isStringArray(record.flags)) return false; if (!isNonEmptyString(record.projectRoot)) return false; if (!isNonEmptyString(record.endpoint)) return false; if ("databaseTarget" in record && typeof record.databaseTarget !== "string") return false; return true; } //#endregion export { isParentToSenderPayload as t };