{"version":3,"file":"errors-DYyzTYzE-39CV_aMo.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/errors-DYyzTYzE.mjs"],"sourcesContent":["import { structuredError } from \"@internal/utils/structured-error\";\nimport { CliStructuredError } from \"@internal/errors/control\";\n//#region src/core/errors.ts\nfunction postgresError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n/**\n* A `PostgresMigration` operation that needs the materialized control adapter\n* — named by `operation` (e.g. `createTable`, `dropColumn`, `dataTransform`) —\n* was invoked, but the migration was constructed without a `ControlStack`.\n* Concrete authoring usage always goes through the migration CLI entrypoint,\n* which assembles a stack from the loaded `prisma.config.ts`; reaching this\n* error means a test fixture or ad-hoc consumer instantiated `PostgresMigration`\n* with the no-arg form (legal for `operations` / `describe` introspection only).\n*\n* The `operation` argument is required so every throw site names the operation\n* that actually failed; a new operation cannot inherit a misattributed message.\n*\n* Distinct from `MIGRATION.UNFILLED_PLACEHOLDER` (placeholder not filled)\n* and `MIGRATION.DATA_TRANSFORM_CONTRACT_MISMATCH` (data-transform query\n* plan against wrong contract) because the missing input is the stack\n* itself, not the per-operation contract.\n*\n* Lives in `@internal/target-postgres/errors` rather than the shared\n* framework migration errors module because the failure is target-specific:\n* the contract it talks about (`PostgresMigration`, the Postgres control\n* adapter, the Postgres-target stack) only exists in this package.\n*/\nfunction errorPostgresMigrationStackMissing(operation) {\n\treturn new CliStructuredError(\"MIGRATION.POSTGRES_CONTROL_STACK_MISSING\", `PostgresMigration.${operation} requires a control adapter`, {\n\t\twhy: `PostgresMigration.${operation} was invoked on an instance constructed without a ControlStack, so the stored controlAdapter is undefined and the operation cannot lower its plan.`,\n\t\tfix: \"Construct the migration via the migration CLI entrypoint (which assembles a ControlStack from the loaded prisma.config.ts), or pass a ControlStack containing a Postgres adapter to the migration constructor in test fixtures.\",\n\t\tmeta: { operation }\n\t});\n}\nfunction errorTemporalUnavailable(codecId, operation) {\n\treturn postgresError(\"RUNTIME.TEMPORAL_UNAVAILABLE\", `Codec '${codecId}' cannot ${operation} a value because this runtime has no global Temporal implementation.`, {\n\t\twhy: \"Temporal-backed codecs read and write their values through the global Temporal API, which this runtime does not provide.\",\n\t\tfix: \"Run on a runtime with Temporal available, install a Temporal polyfill before creating the client, or author the column with its *String type to read and write PostgreSQL's own text instead.\",\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\toperation\n\t\t}\n\t});\n}\nfunction errorTemporalUnavailableForDefault(generatorId) {\n\treturn postgresError(\"RUNTIME.TEMPORAL_UNAVAILABLE\", `Mutation default generator '${generatorId}' cannot produce a value because this runtime has no global Temporal implementation.`, {\n\t\twhy: \"The generator answers a Temporal-backed column, so the value it produces is a Temporal.Instant, which this runtime cannot construct.\",\n\t\tfix: \"Run on a runtime with Temporal available, install a Temporal polyfill before creating the client, or author the column with `temporal.createdAtString()` / `temporal.updatedAtString()` to store PostgreSQL's own text instead.\",\n\t\tmeta: { generatorId }\n\t});\n}\nfunction errorTemporalUnrepresentable(options) {\n\tconst { codecId, operation, stringType, value, detail } = options;\n\treturn postgresError(operation === \"decode\" ? \"RUNTIME.DECODE_FAILED\" : \"RUNTIME.ENCODE_FAILED\", `Codec '${codecId}' cannot represent the value ${operation === \"decode\" ? \"PostgreSQL returned\" : \"the application supplied\"}: ${JSON.stringify(value)} — ${detail}. Use ${stringType} to carry this column as PostgreSQL's own text.`, {\n\t\twhy: `${detail}. Temporal is the authoritative parser and range check for this codec, so a value it cannot express has no representation on this column.`,\n\t\tfix: `Author the column as ${stringType} to read and write PostgreSQL's own text for it, which preserves every value the database accepts.`,\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\toperation,\n\t\t\tvalue,\n\t\t\tstringType\n\t\t},\n\t\t...options.cause === void 0 ? {} : { cause: options.cause }\n\t});\n}\nfunction errorTemporalWrongType(codecId, temporalTag, stringType, received) {\n\treturn postgresError(\"RUNTIME.ENCODE_FAILED\", `Codec '${codecId}' encodes a ${temporalTag}, but received ${received}.`, {\n\t\twhy: \"The codec serializes through the Temporal value's own toString(). A different type reaches PostgreSQL in a spelling it does not accept, and the resulting error names the column rather than the codec.\",\n\t\tfix: `Pass a ${temporalTag}, or author the column with its ${stringType} type to write PostgreSQL text directly.`,\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\ttemporalTag,\n\t\t\tstringType,\n\t\t\treceived\n\t\t}\n\t});\n}\nfunction errorTemporalNonIsoCalendar(codecId, calendarId) {\n\treturn postgresError(\"RUNTIME.ENCODE_FAILED\", `Codec '${codecId}' accepts only the iso8601 calendar, but the value carries '${calendarId}'.`, {\n\t\twhy: \"PostgreSQL stores no calendar alongside a date, so a non-ISO calendar would be discarded on write and the value would read back as a different date than the one authored.\",\n\t\tfix: \"Convert the value with .withCalendar(\\\"iso8601\\\") before writing if the ISO projection is what you mean to store.\",\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\tcalendarId\n\t\t}\n\t});\n}\n//#endregion\nexport { errorTemporalUnrepresentable as a, errorTemporalUnavailableForDefault as i, errorTemporalNonIsoCalendar as n, errorTemporalWrongType as o, errorTemporalUnavailable as r, postgresError as s, errorPostgresMigrationStackMissing as t };\n\n//# sourceMappingURL=errors-DYyzTYzE.mjs.map"],"mappings":";;;AAGA,SAAS,cAAc,MAAM,SAAS,SAAS;CAC9C,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C;;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAS,mCAAmC,WAAW;CACtD,OAAO,IAAI,mBAAmB,4CAA4C,qBAAqB,UAAU,8BAA8B;EACtI,KAAK,qBAAqB,UAAU;EACpC,KAAK;EACL,MAAM,EAAE,UAAU;CACnB,CAAC;AACF;AACA,SAAS,yBAAyB,SAAS,WAAW;CACrD,OAAO,cAAc,gCAAgC,UAAU,QAAQ,WAAW,UAAU,uEAAuE;EAClK,KAAK;EACL,KAAK;EACL,MAAM;GACL;GACA;EACD;CACD,CAAC;AACF;AACA,SAAS,mCAAmC,aAAa;CACxD,OAAO,cAAc,gCAAgC,+BAA+B,YAA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