(packageName, schema, options = {})
| 315 | Object.hasOwn(schema, "additionalProperties")); |
| 316 | |
| 317 | export const validateOptions = (packageName, schema, options = {}) => { |
| 318 | const fail = (message) => { |
| 319 | throw new TypeError(message, { cause: { package: packageName } }); |
| 320 | }; |
| 321 | try { |
| 322 | if (isJsonSchemaForm(schema)) { |
| 323 | checkRule(schema, options, "", fail); |
| 324 | } else { |
| 325 | checkSchemaObject(schema, options, "", fail); |
| 326 | } |
| 327 | } catch (e) { |
| 328 | // Re-wrap an internal malformed-schema `SchemaError` so callers still see |
| 329 | // the documented `TypeError` + `cause.package`; mismatch errors already |
| 330 | // carry that shape and pass through untouched. |
| 331 | // Stryker disable next-line ConditionalExpression: forcing this true is equivalent; the only non-SchemaError reaching here is a `fail()` TypeError that already carries cause.package, so re-wrapping it via `fail(e.message)` produces an identical message + cause. |
| 332 | if (e instanceof SchemaError) { |
| 333 | fail(e.message); |
| 334 | } |
| 335 | throw e; |
| 336 | } |
| 337 | return options; |
| 338 | }; |
| 339 | |
| 340 | export const createPrefetchClient = (options) => { |
| 341 | const { awsClientOptions } = options; |
no test coverage detected