@salesforce/lds-drafts 1.443.0 → 1.444.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.
package/dist/ldsDrafts.js CHANGED
@@ -259,7 +259,7 @@ function customActionHandler(executor, id, draftQueue) {
259
259
  }, result.error.type === CustomActionErrorType.NETWORK_ERROR);
260
260
  }
261
261
  };
262
- const buildPendingAction = (action, queue) => {
262
+ const buildPendingAction = (action, queue, observabilityContext) => {
263
263
  const { data, tag, targetId, handler } = action;
264
264
  const id = generateUniqueDraftActionId(queue.map((a) => a.id));
265
265
  return Promise.resolve({
@@ -271,6 +271,7 @@ function customActionHandler(executor, id, draftQueue) {
271
271
  timestamp: Date.now(),
272
272
  metadata: data,
273
273
  handler,
274
+ observabilityContext,
274
275
  });
275
276
  };
276
277
  const getQueueOperationsForCompletingDrafts = (_queue, action) => {
@@ -442,12 +443,12 @@ class DurableDraftQueue {
442
443
  return aTime - bTime;
443
444
  });
444
445
  }
445
- async enqueue(handlerId, data) {
446
+ async enqueue(handlerId, data, observabilityContext) {
446
447
  return this.workerPool.push({
447
448
  workFn: async () => {
448
449
  let queue = await this.getQueueActions();
449
450
  const handler = this.getHandler(handlerId);
450
- const pendingAction = (await handler.buildPendingAction(data, queue));
451
+ const pendingAction = (await handler.buildPendingAction(data, queue, observabilityContext));
451
452
  await this.draftStore.writeAction(pendingAction);
452
453
  queue = await this.getQueueActions();
453
454
  await this.notifyChangedListeners({
@@ -1269,7 +1270,7 @@ class DraftManager {
1269
1270
  }
1270
1271
  buildDraftQueueItem(action) {
1271
1272
  const operationType = getOperationTypeFrom(action);
1272
- const { id, status, timestamp, targetId, metadata } = action;
1273
+ const { id, status, timestamp, targetId, metadata, observabilityContext } = action;
1273
1274
  const item = {
1274
1275
  id,
1275
1276
  targetId,
@@ -1277,6 +1278,7 @@ class DraftManager {
1277
1278
  timestamp,
1278
1279
  operationType,
1279
1280
  metadata,
1281
+ observabilityContext,
1280
1282
  };
1281
1283
  if (isDraftError(action)) {
1282
1284
  // We should always return an array, if the body is just a dictionary,
@@ -1,4 +1,5 @@
1
1
  import type { CustomActionResult } from './actionHandlers/CustomActionHandler';
2
+ import type { ObservabilityContext } from '@salesforce/nimbus-plugin-lds';
2
3
  import type { DraftQueue, DraftAction, DraftActionMetadata, PendingDraftAction, DraftQueueState } from './DraftQueue';
3
4
  import { DraftActionStatus } from './DraftQueue';
4
5
  import type { ResourceRequest } from '@luvio/engine';
@@ -37,6 +38,8 @@ export interface DraftQueueItem {
37
38
  error?: undefined | DraftQueueItemError;
38
39
  /** The stored metadata for the draft queue item */
39
40
  metadata: DraftQueueItemMetadata;
41
+ /** o11y context from draft creation time, forwarded at replay */
42
+ observabilityContext?: ObservabilityContext;
40
43
  }
41
44
  /**
42
45
  * An error of a draft action that was submitted and failed
@@ -1,4 +1,5 @@
1
1
  import type { FetchResponse } from '@luvio/engine';
2
+ import type { ObservabilityContext } from '@salesforce/nimbus-plugin-lds';
2
3
  import type { ActionHandler } from './actionHandlers/ActionHandler';
3
4
  import type { CustomActionExecutor } from './actionHandlers/CustomActionHandler';
4
5
  export declare enum DraftActionStatus {
@@ -25,6 +26,8 @@ interface BaseDraftAction<Data> {
25
26
  /** the data being enqueued */
26
27
  data: Data;
27
28
  version: '242.0.0';
29
+ /** o11y context from draft creation time, forwarded verbatim at replay */
30
+ observabilityContext?: ObservabilityContext;
28
31
  }
29
32
  export interface CompletedDraftAction<Data, Response> extends BaseDraftAction<Data> {
30
33
  status: DraftActionStatus.Completed;
@@ -162,10 +165,11 @@ export interface DraftQueue {
162
165
  * Enqueues a draft action into the DraftQueue
163
166
  * @param handlerId the id of the handler associated with the data
164
167
  * @param data the data the handler will use to create the draft action with
168
+ * @param observabilityContext optional o11y context from the enqueuing call site, persisted for replay
165
169
  * @returns A promise including the pending action created for the request and the data associated with the action
166
170
  * @throws {Error} An error when a proper action handler is not found or conditions are not met to enqueue the action
167
171
  */
168
- enqueue<Data>(handlerId: string, data: Data): Promise<PendingDraftAction<Data>>;
172
+ enqueue<Data>(handlerId: string, data: Data, observabilityContext?: ObservabilityContext): Promise<PendingDraftAction<Data>>;
169
173
  /**
170
174
  * add a new handler to the draft queue to process the data in the actions
171
175
  * @param id identifier to the handler
@@ -3,6 +3,7 @@ import { ProcessActionResult, DraftQueueState } from './DraftQueue';
3
3
  import type { CustomActionExecutor } from './actionHandlers/CustomActionHandler';
4
4
  import type { ActionHandler } from './actionHandlers/ActionHandler';
5
5
  import type { DraftStore } from './DraftStore';
6
+ import type { ObservabilityContext } from '@salesforce/nimbus-plugin-lds';
6
7
  export declare const DRAFT_SEGMENT = "DRAFT";
7
8
  export declare class DurableDraftQueue implements DraftQueue {
8
9
  private retryIntervalMilliseconds;
@@ -33,7 +34,7 @@ export declare class DurableDraftQueue implements DraftQueue {
33
34
  */
34
35
  private stopQueueManually;
35
36
  getQueueActions<Data = unknown, Response = unknown>(): Promise<DraftAction<Data, Response>[]>;
36
- enqueue<Data>(handlerId: string, data: unknown): Promise<PendingDraftAction<Data>>;
37
+ enqueue<Data>(handlerId: string, data: unknown, observabilityContext?: ObservabilityContext): Promise<PendingDraftAction<Data>>;
37
38
  registerOnChangedListener(listener: DraftQueueChangeListener): () => Promise<void>;
38
39
  actionCompleted(action: CompletedDraftAction<unknown, unknown>): Promise<void>;
39
40
  actionFailed(action: DraftAction<unknown, unknown>, retry: boolean, retryDelayInMs?: number, actionDataChanged?: boolean): Promise<void>;
@@ -1,3 +1,4 @@
1
+ import type { ObservabilityContext } from '@salesforce/nimbus-plugin-lds';
1
2
  import type { CompletedDraftAction, DraftAction, DraftActionMetadata, PendingDraftAction, ProcessActionResult, QueueOperation } from '../DraftQueue';
2
3
  export interface ReplacingActions<Response, Data> {
3
4
  original: DraftAction<Response, Data>;
@@ -26,10 +27,11 @@ export interface ActionHandler<Data, Type> {
26
27
  * Used to build a PendingDraftAction that is specific to the type of Data and Response.
27
28
  * @param data
28
29
  * @param queue
30
+ * @param observabilityContext optional o11y context to persist on the action for replay
29
31
  *
30
32
  * @throws {Error} if any preconditions to building the draft action are not satisfied
31
33
  */
32
- buildPendingAction(data: unknown, queue: DraftAction<unknown, unknown>[]): Promise<PendingDraftAction<Data>>;
34
+ buildPendingAction(data: unknown, queue: DraftAction<unknown, unknown>[], observabilityContext?: ObservabilityContext): Promise<PendingDraftAction<Data>>;
33
35
  /**
34
36
  * Invoked after an action is enqueued into the draft queue
35
37
  * @param action The action that was just enqueued
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-drafts",
3
- "version": "1.443.0",
3
+ "version": "1.444.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS Drafts",
6
6
  "main": "dist/ldsDrafts.js",
@@ -24,12 +24,12 @@
24
24
  "release:corejar": "yarn build && ../core-build/scripts/core.js --adapter=lds-drafts"
25
25
  },
26
26
  "dependencies": {
27
- "@luvio/engine": "0.160.5",
28
- "@luvio/environments": "0.160.5",
29
- "@salesforce/lds-utils-adapters": "^1.443.0"
27
+ "@luvio/engine": "0.161.0",
28
+ "@luvio/environments": "0.161.0",
29
+ "@salesforce/lds-utils-adapters": "^1.444.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@salesforce/nimbus-plugin-lds": "^1.443.0"
32
+ "@salesforce/nimbus-plugin-lds": "^1.444.0"
33
33
  },
34
34
  "volta": {
35
35
  "extends": "../../package.json"