@salesforce/lds-runtime-mobile 1.444.0 → 1.446.0

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.
@@ -26,6 +26,28 @@ export declare abstract class AbstractResourceRequestActionHandler<ResponseType>
26
26
  enqueue(data: ResourceRequest, observabilityContext?: ObservabilityContext): Promise<PendingDraftAction<ResourceRequest>>;
27
27
  buildPendingAction(request: ResourceRequest, queue: DraftAction<unknown, unknown>[], observabilityContext?: ObservabilityContext): Promise<PendingDraftAction<ResourceRequest>>;
28
28
  handleAction(action: DraftAction<ResourceRequest, ResponseType>, actionCompleted: (action: CompletedDraftAction<ResourceRequest, ResponseType>) => Promise<void>, actionErrored: (action: DraftAction<ResourceRequest, ResponseType>, retry: boolean, retryDelayInMs?: number, actionDataChanged?: boolean) => Promise<void>): Promise<ProcessActionResult>;
29
+ /**
30
+ * Reads the persisted upload retry-attempt count from the action's durable metadata
31
+ * bag. The count lives in metadata (rather than in-memory) so it survives app
32
+ * restarts and queue re-creation — the failure modes that let the unbounded retry
33
+ * loop run for days.
34
+ */
35
+ private getUploadRetryCount;
36
+ /**
37
+ * Enforces the upload retry-attempt cap around the queue's `actionErrored` callback.
38
+ * Both retry paths — a retryable HTTP error and a thrown exception — funnel through
39
+ * here.
40
+ *
41
+ * The entire cap behavior is gated behind `lmr.draft-queue-max-retry-attempts`. When
42
+ * the gate is CLOSED this is a transparent passthrough: it issues the same
43
+ * `actionErrored(action, true, ...)` retry the queue made before this change, and
44
+ * writes no extra metadata. When the gate is OPEN it persists an incremented attempt
45
+ * count to the action's durable metadata and, once the action has failed
46
+ * {@link MAX_RETRY_ATTEMPTS} times, transitions it to Error (carrying a
47
+ * FetchResponse-shaped error that names the failure that exhausted the retries)
48
+ * instead of scheduling yet another retry.
49
+ */
50
+ private retryOrCap;
29
51
  handleActionEnqueued(action: PendingDraftAction<ResourceRequest>): Promise<void>;
30
52
  handleActionRemoved(action: DraftAction<ResourceRequest, ResponseType>): Promise<void>;
31
53
  handleActionReplaced(target: DraftAction<ResourceRequest, ResponseType>, source: DraftAction<ResourceRequest, ResponseType>): Promise<void>;
@@ -1,4 +1,33 @@
1
+ import type { FetchResponse } from '@luvio/engine';
1
2
  /**
2
3
  * This function takes an unknown error and normalizes it to an Error object
3
4
  */
4
5
  export declare function normalizeError(error: unknown): Error;
6
+ /**
7
+ * Maximum number of times an action's upload will be retried before the action is
8
+ * transitioned to Error and surfaced to the consumer. Caps the otherwise-unbounded
9
+ * retry loop that can wedge the single-worker draft queue when an upload fails
10
+ * deterministically on every dispatch. Only enforced when the
11
+ * `lmr.draft-queue-max-retry-attempts` gate is open.
12
+ */
13
+ export declare const MAX_RETRY_ATTEMPTS = 5;
14
+ export declare const MAX_RETRY_ERROR_CODE = "MAX_RETRY_ATTEMPTS_EXCEEDED";
15
+ /**
16
+ * The two things that can cause an upload attempt to fail and be retried:
17
+ * - a non-ok `FetchResponse` returned by the network adapter (the HTTP error path), or
18
+ * - an `Error` thrown out of the dispatch and caught by `handleAction` (the catch path;
19
+ * the raw caught value is normalized to an `Error` before it reaches here).
20
+ * Either way the cause is concretely typed — it is never an opaque `unknown`.
21
+ */
22
+ export type UploadFailure = FetchResponse<unknown> | Error;
23
+ /**
24
+ * Builds the FetchResponse-shaped error attached to an action that has exhausted its
25
+ * upload retries. Shaped like a real network error response (status/statusText/ok/
26
+ * headers/body) so downstream consumers (DraftManager, queue instrumentation) that
27
+ * read `action.error.status`/`.body`/etc. behave consistently with a server error.
28
+ *
29
+ * The failure that caused the final attempt — a non-ok response (HTTP path) or a thrown
30
+ * error (catch path) — is folded into the body so the surfaced error says WHAT failed,
31
+ * not merely that the attempt cap was reached.
32
+ */
33
+ export declare function buildMaxRetryError(lastFailure: UploadFailure): FetchResponse<unknown>;
@@ -10,6 +10,20 @@ export declare function reportGraphqlAdapterError(errorCode: string): void;
10
10
  export declare function reportGraphqlQueryInstrumentation(data: QueryInstrumentation): void;
11
11
  export declare function incrementGraphQLRefreshUndfined(): void;
12
12
  export declare function reportDraftActionEvent(state: 'added' | 'uploading' | 'completed' | 'deleted' | 'updated' | 'failed', draftCount: number, message?: string): void;
13
+ /**
14
+ * Reports an exception thrown while uploading a draft action. The thrown error is
15
+ * otherwise swallowed by the upload handler's retry path, leaving the failure
16
+ * invisible in telemetry; this surfaces it to o11y (log + counter) so a deterministic
17
+ * upload failure can be diagnosed instead of silently retried forever.
18
+ *
19
+ * PII: the device log line carries only the handler id, retry attempt, and the error
20
+ * NAME (e.g. "TypeError") — never the free-text error message, which can embed record
21
+ * ids (URL path segments) or server field-validation strings. The full normalized error
22
+ * (message + stack) is handed only to `ldsMobileInstrumentation.error`, the structured
23
+ * o11y error pipeline responsible for scrubbing/handling that detail. Also does NOT log
24
+ * the action's targetId/tag or any request body/field values.
25
+ */
26
+ export declare function reportDraftActionUploadError(error: unknown, handlerId: string, attempt: number): void;
13
27
  export declare function reportDraftQueueState(state: 'started' | 'error' | 'waiting' | 'stopped', draftCount: number): void;
14
28
  export declare function reportDraftAwareContentDocumentVersionSynthesizeError(err: unknown): void;
15
29
  export declare function reportDraftAwareContentVersionSynthesizeCalls(mimeType: string): void;
@@ -0,0 +1,10 @@
1
+ import type { AdapterRequestContext, DmlAdapterRequestContext } from '@luvio/engine';
2
+ import type { ObservabilityContext } from '@salesforce/nimbus-plugin-lds';
3
+ /**
4
+ * lds-worker-api packs the user action's ObservabilityContext into
5
+ * `requestContext.requestCorrelator = { observabilityContext }`. This helper
6
+ * unwraps it for draft-aware adapter wrappers, which forward the context to
7
+ * the action handler so retry network spans can be parented to the
8
+ * originating user action.
9
+ */
10
+ export declare function extractObservabilityContext(requestContext?: AdapterRequestContext | DmlAdapterRequestContext): ObservabilityContext | undefined;