@apifuse/provider-sdk 2.2.0-beta.63 → 2.2.0-beta.65

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/src/provider.ts CHANGED
@@ -166,6 +166,8 @@ export {
166
166
  APIFUSE_HANDLE_META_KEY,
167
167
  HANDLE_KIND_NAME_PATTERN,
168
168
  handleFieldDescription,
169
+ handleFieldNameFor,
170
+ handleHasDirectionalFieldNames,
169
171
  isHandleFieldMeta,
170
172
  } from "./handle-meta.js";
171
173
  export {
@@ -27,7 +27,7 @@ import {
27
27
  isDraftKind,
28
28
  type ResultOf,
29
29
  } from "../handle.js";
30
- import { formatHandleIssuers } from "../handle-meta.js";
30
+ import { formatHandleIssuers, handleHasDirectionalFieldNames } from "../handle-meta.js";
31
31
  import type {
32
32
  ProviderRequestContext,
33
33
  ProviderRuntimeState,
@@ -248,6 +248,14 @@ export function formatNormalizationClasses(classes: readonly string[]): string {
248
248
  // ---------------------------------------------------------------------------
249
249
 
250
250
  function publicCollapsedMessage(kind: HandleKind): string {
251
+ // "a new one" is unambiguous only while the kind has one name. When it is
252
+ // issued under `next_cursor` and accepted under `cursor`, the caller has to
253
+ // be told which field to read, so use the full recovery sentence — it names
254
+ // both keys and is identical for invalid / expired / not-found, which is
255
+ // what keeps the public collapse indistinguishable.
256
+ if (handleHasDirectionalFieldNames(kind)) {
257
+ return `\`${kind.fieldName}\` is not valid or has expired. ${handleRecoverySentence(kind)}`;
258
+ }
251
259
  const issuers = formatHandleIssuers(kind.issuedBy);
252
260
  const again = issuers ? `Call ${issuers} again to get a new one.` : "Request a new one.";
253
261
  return `\`${kind.fieldName}\` is not valid or has expired. ${again}`;
@@ -86,6 +86,10 @@ function createErrorOcrClient(options: ErrorOcrClientOptions): OcrContext {
86
86
  };
87
87
  return tagCapability(
88
88
  {
89
+ // Own data property: `bindOcrTelemetry` re-spreads the context, so a
90
+ // getter or prototype member would silently vanish before reaching
91
+ // provider code.
92
+ available: false,
89
93
  async recognize() {
90
94
  return unavailable();
91
95
  },
@@ -355,6 +359,7 @@ function createOcrClient(
355
359
  recognize: (request: OcrRecognizeRequest) => Promise<OcrResult>,
356
360
  ): OcrContext {
357
361
  return {
362
+ available: true,
358
363
  recognize,
359
364
  async extractCaptchaText(image, options = {}): Promise<OcrCaptchaResult> {
360
365
  const result = await recognize({ image, hint: "captcha" });