pi-lean-host 0.2.1 → 0.3.1

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/core/helpers.ts CHANGED
@@ -170,6 +170,26 @@ function buildQueryParams(
170
170
  }
171
171
  }
172
172
 
173
+ // At-least-one-of constraint: at least one group member must be supplied.
174
+ // Members can't be `required` or carry a `default` (parser-enforced), so
175
+ // this is the only guard the group needs — same fail-closed seam as the
176
+ // per-param `required` check above. Both api-fetch and /api verify route
177
+ // through here (resolveOpForExecution → restGet/paginate), so one guard
178
+ // covers both call sites.
179
+ if (operation.requiresAnyOf && operation.requiresAnyOf.length > 0) {
180
+ const satisfied = operation.requiresAnyOf.some(
181
+ (name) => params[name] !== undefined,
182
+ );
183
+ if (!satisfied) {
184
+ throw new HelperError(
185
+ "params.requiresAnyOf",
186
+ `Missing one of: ${operation.requiresAnyOf.join(", ")}`,
187
+ `at least one of: ${operation.requiresAnyOf.join(", ")}`,
188
+ "none supplied",
189
+ );
190
+ }
191
+ }
192
+
173
193
  // `passthrough`: forward caller-supplied params not declared in the
174
194
  // recipe's `params` map onto the query string as-is. For APIs with an
175
195
  // open param surface (Infogami /query.json flat form, CKAN, OAI-PMH)
@@ -219,7 +239,11 @@ export function normalizeDateParam(
219
239
  /**
220
240
  * Resolve a simple dot-delimited JSON path against an object.
221
241
  * Supports `data.items`, `resultados[0].campo`, `$.items` prefix.
242
+ *
243
+ * Returns `unknown` by design — the value at an arbitrary JSON path has no
244
+ * named domain type until the caller knows the path they asked for.
222
245
  */
246
+ // pi-lens-ignore: ast-grep:no-unknown-returns
223
247
  export function resolveJsonPath(obj: unknown, path: string): unknown {
224
248
  // Normalise: strip leading $ or $., convert bracket notation.
225
249
  const normalised = path
@@ -267,10 +291,14 @@ const xmlParser = new XMLParser({
267
291
  * header charset wins). `parseResponse` itself does no decoding — the
268
292
  * `charset` field is consumed by the transport, not here.
269
293
  *
294
+ * Returns `unknown` by design — an arbitrary API response body has no named
295
+ * domain type; callers resolve JSON paths or run transforms against it.
296
+ *
270
297
  * @param body The response body string (correctly decoded).
271
298
  * @param shape The response shape (format dictates XML vs JSON parsing).
272
299
  * @returns Parsed JSON value or XML-converted object.
273
300
  */
301
+ // pi-lens-ignore: ast-grep:no-unknown-returns
274
302
  export function parseResponse(body: string, shape: ResponseShape): unknown {
275
303
  if (shape.format === "text") {
276
304
  // Raw passthrough — returned as-is, no trim (matches xml/json branches).