@salesforce/lds-runtime-mobile 1.461.0 → 1.463.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/main.js +726 -276
- package/dist/types/drafts/records/actionHandlers/SideEffectHook.d.ts +4 -3
- package/dist/types/drafts/sideEffects/SideEffectHandler.d.ts +5 -1
- package/dist/types/drafts/sideEffects/sideEffects.d.ts +6 -1
- package/dist/types/durableStore/MemoizingRecordReader.d.ts +29 -0
- package/dist/types/sfs/ProductConsumedSideEffects.d.ts +46 -3
- package/dist/types/sfs/ProductItemSideEffects.d.ts +46 -0
- package/dist/types/sfs/ProductTransferSideEffects.d.ts +49 -0
- package/dist/types/sfs/sfsIsProduct2Serialized.d.ts +88 -0
- package/package.json +37 -37
- package/sfdc/main.js +726 -276
- package/sfdc/types/drafts/records/actionHandlers/SideEffectHook.d.ts +4 -3
- package/sfdc/types/drafts/sideEffects/SideEffectHandler.d.ts +5 -1
- package/sfdc/types/drafts/sideEffects/sideEffects.d.ts +6 -1
- package/sfdc/types/durableStore/MemoizingRecordReader.d.ts +29 -0
- package/sfdc/types/sfs/ProductConsumedSideEffects.d.ts +46 -3
- package/sfdc/types/sfs/ProductItemSideEffects.d.ts +46 -0
- package/sfdc/types/sfs/ProductTransferSideEffects.d.ts +49 -0
- package/sfdc/types/sfs/sfsIsProduct2Serialized.d.ts +88 -0
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import type { SideEffect } from '../../sideEffects';
|
|
2
|
+
import type { RecordReader } from '../../../durableStore/MemoizingRecordReader';
|
|
2
3
|
interface BaseSideEffectHook {
|
|
3
4
|
on: 'post' | 'patch' | 'delete';
|
|
4
5
|
apiName: string;
|
|
5
6
|
}
|
|
6
7
|
export interface CreateSideEffectHook extends BaseSideEffectHook {
|
|
7
8
|
on: 'post';
|
|
8
|
-
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string, fields: Record<string, any
|
|
9
|
+
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string, fields: Record<string, any>, reader?: RecordReader): Promise<SideEffect[]>;
|
|
9
10
|
}
|
|
10
11
|
export interface UpdateSideEffectHook extends BaseSideEffectHook {
|
|
11
12
|
on: 'patch';
|
|
12
|
-
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string, fields: Record<string, any
|
|
13
|
+
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string, fields: Record<string, any>, reader?: RecordReader): Promise<SideEffect[]>;
|
|
13
14
|
}
|
|
14
15
|
export interface DeleteSideEffectHook extends BaseSideEffectHook {
|
|
15
16
|
on: 'delete';
|
|
16
|
-
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string): Promise<SideEffect[]>;
|
|
17
|
+
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string, fields?: Record<string, any>, reader?: RecordReader): Promise<SideEffect[]>;
|
|
17
18
|
}
|
|
18
19
|
export type SideEffectHook = CreateSideEffectHook | UpdateSideEffectHook | DeleteSideEffectHook;
|
|
19
20
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DurableRecordRepresentation } from '@salesforce/lds-durable-records';
|
|
2
|
-
import type { CreateRecordSideEffect, DeleteRecordSideEffect, FieldIncrementSideEffect, UpdateRecordSideEffect } from './sideEffects';
|
|
2
|
+
import type { CreateRecordSideEffect, DeleteRecordSideEffect, FieldIncrementSideEffect, FieldSetSideEffect, UpdateRecordSideEffect } from './sideEffects';
|
|
3
3
|
export interface SideEffectHandler<EntryType, EffectType> {
|
|
4
4
|
apply(entry: EntryType | undefined, effect: EffectType): EntryType | undefined;
|
|
5
5
|
}
|
|
@@ -16,3 +16,7 @@ export declare class RecordFieldIncrementHandler implements SideEffectHandler<Du
|
|
|
16
16
|
private logger;
|
|
17
17
|
apply(record: DurableRecordRepresentation | undefined, effect: FieldIncrementSideEffect): DurableRecordRepresentation | undefined;
|
|
18
18
|
}
|
|
19
|
+
export declare class RecordFieldSetHandler implements SideEffectHandler<DurableRecordRepresentation, FieldSetSideEffect> {
|
|
20
|
+
private logger;
|
|
21
|
+
apply(record: DurableRecordRepresentation | undefined, effect: FieldSetSideEffect): DurableRecordRepresentation | undefined;
|
|
22
|
+
}
|
|
@@ -21,7 +21,12 @@ export interface FieldIncrementSideEffect extends BaseRecordSideEffect {
|
|
|
21
21
|
fieldName: string;
|
|
22
22
|
value: number;
|
|
23
23
|
}
|
|
24
|
-
export
|
|
24
|
+
export interface FieldSetSideEffect extends BaseRecordSideEffect {
|
|
25
|
+
type: 'record-field-set';
|
|
26
|
+
fieldName: string;
|
|
27
|
+
value: boolean | number | string | null;
|
|
28
|
+
}
|
|
29
|
+
export type SideEffect = CreateRecordSideEffect | UpdateRecordSideEffect | DeleteRecordSideEffect | FieldIncrementSideEffect | FieldSetSideEffect;
|
|
25
30
|
/**
|
|
26
31
|
* Removes any existing effects on a record and re-applies the given ordered list and returns the record
|
|
27
32
|
* with the updated side effects applied.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DurableRecordRepresentation } from '@salesforce/lds-durable-records';
|
|
2
|
+
import type { DurableRecordStore } from './DurableRecordStore';
|
|
3
|
+
/**
|
|
4
|
+
* The minimal record-read surface the SFS side-effect hooks depend on. Both
|
|
5
|
+
* `DurableRecordStore` and `MemoizingRecordReader` satisfy it, so a hook can be handed either
|
|
6
|
+
* one: the raw store, or a per-action memoizer that dedups reads.
|
|
7
|
+
*/
|
|
8
|
+
export interface RecordReader {
|
|
9
|
+
getRecord(key: string): Promise<DurableRecordRepresentation | undefined>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A read-through cache over `DurableRecordStore.getRecord` scoped to a single draft-action
|
|
13
|
+
* dispatch. Multiple side-effect hooks fire for one action (e.g. the van-stock and
|
|
14
|
+
* IsProduct2Serialized ProductConsumed hooks) and are awaited one at a time, so they otherwise
|
|
15
|
+
* each re-read the same draft record — and the IsProduct2Serialized chain re-reads the same
|
|
16
|
+
* related ProductItem / Product2 — from the durable store. Sharing one reader across the
|
|
17
|
+
* action's hooks collapses those repeated reads to a single durable call per key.
|
|
18
|
+
*
|
|
19
|
+
* The cache stores the in-flight promise (not the resolved value) so concurrent reads of the
|
|
20
|
+
* same key share one durable call, and it caches `undefined` results so a miss is not re-fetched.
|
|
21
|
+
* A reader must not outlive one action dispatch: durable state changes between actions, so a
|
|
22
|
+
* longer-lived cache would return stale records.
|
|
23
|
+
*/
|
|
24
|
+
export declare class MemoizingRecordReader implements RecordReader {
|
|
25
|
+
private readonly durableRecordStore;
|
|
26
|
+
private readonly cache;
|
|
27
|
+
constructor(durableRecordStore: DurableRecordStore);
|
|
28
|
+
getRecord(key: string): Promise<DurableRecordRepresentation | undefined>;
|
|
29
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SideEffect } from '../drafts/sideEffects';
|
|
2
2
|
import type { CreateSideEffectHook, DeleteSideEffectHook, UpdateSideEffectHook } from '../drafts/records/actionHandlers/SideEffectHook';
|
|
3
3
|
import type { DurableRecordStore } from '../durableStore/DurableRecordStore';
|
|
4
|
-
|
|
4
|
+
import type { RecordReader } from '../durableStore/MemoizingRecordReader';
|
|
5
5
|
export declare class ProductConsumedCreatedHook implements CreateSideEffectHook {
|
|
6
6
|
on: 'post';
|
|
7
7
|
apiName: string;
|
|
@@ -14,7 +14,7 @@ export declare class ProductConsumedUpdatedHook implements UpdateSideEffectHook
|
|
|
14
14
|
apiName: string;
|
|
15
15
|
private static COUNTER_NAME;
|
|
16
16
|
constructor(durableRecordStore: DurableRecordStore);
|
|
17
|
-
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string, fields: Record<string, any
|
|
17
|
+
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string, fields: Record<string, any>, reader?: RecordReader): Promise<SideEffect[]>;
|
|
18
18
|
}
|
|
19
19
|
export declare class ProductConsumedDeletedHook implements DeleteSideEffectHook {
|
|
20
20
|
private readonly durableRecordStore;
|
|
@@ -22,5 +22,48 @@ export declare class ProductConsumedDeletedHook implements DeleteSideEffectHook
|
|
|
22
22
|
apiName: string;
|
|
23
23
|
private static COUNTER_NAME;
|
|
24
24
|
constructor(durableRecordStore: DurableRecordStore);
|
|
25
|
-
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string): Promise<SideEffect[]>;
|
|
25
|
+
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string, _fields?: Record<string, any>, reader?: RecordReader): Promise<SideEffect[]>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Replicates the server-derived `IsProduct2Serialized` boolean on a draft-created
|
|
29
|
+
* `ProductConsumed` record.
|
|
30
|
+
*
|
|
31
|
+
* `Product2Id` is not createable on `ProductConsumed`, so the draft only carries the
|
|
32
|
+
* `ProductItemId`. The value is resolved through the related `ProductItem` record (see
|
|
33
|
+
* `resolveIsProduct2SerializedFromProductItem`): the ProductItem's own
|
|
34
|
+
* `IsProduct2Serialized` when cached, otherwise `ProductItem.Product2Id` ->
|
|
35
|
+
* `Product2.IsSerialized`. When the chain cannot be resolved the hook exits without an
|
|
36
|
+
* effect and the field is left as synthesized (null).
|
|
37
|
+
*/
|
|
38
|
+
export declare class ProductConsumedIsSerializedCreatedHook implements CreateSideEffectHook {
|
|
39
|
+
private readonly durableRecordStore;
|
|
40
|
+
on: 'post';
|
|
41
|
+
apiName: string;
|
|
42
|
+
private static COUNTER_NAME;
|
|
43
|
+
constructor(durableRecordStore: DurableRecordStore);
|
|
44
|
+
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string, fields: Record<string, any>, reader?: RecordReader): Promise<SideEffect[]>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Replicates the server-derived `IsProduct2Serialized` boolean on a draft-edited
|
|
48
|
+
* `ProductConsumed` record.
|
|
49
|
+
*
|
|
50
|
+
* A `patch` body only carries changed fields, so the related `ProductItemId` may be absent.
|
|
51
|
+
* The id is resolved by preferring the patch body (the link is being reassigned) and falling
|
|
52
|
+
* back to the original record in the durable store, then the value is resolved through that
|
|
53
|
+
* `ProductItem` exactly as on create (see `resolveIsProduct2SerializedFromProductItem`).
|
|
54
|
+
*
|
|
55
|
+
* When the patch explicitly clears `ProductItemId` (sets it to `null`) the record no longer
|
|
56
|
+
* derives from any `ProductItem`, so `IsProduct2Serialized` is cleared (set to `null`) rather
|
|
57
|
+
* than resolved from the now-stale original link. Likewise, when the patch reassigns
|
|
58
|
+
* `ProductItemId` to a new id whose chain isn't cached, the stored value reflects the old link
|
|
59
|
+
* and is stale, so it is cleared. When the link is unchanged and its chain cannot be resolved,
|
|
60
|
+
* the stored value is still correct so the hook exits without an effect and leaves it unchanged.
|
|
61
|
+
*/
|
|
62
|
+
export declare class ProductConsumedIsSerializedUpdatedHook implements UpdateSideEffectHook {
|
|
63
|
+
private readonly durableRecordStore;
|
|
64
|
+
on: 'patch';
|
|
65
|
+
apiName: string;
|
|
66
|
+
private static COUNTER_NAME;
|
|
67
|
+
constructor(durableRecordStore: DurableRecordStore);
|
|
68
|
+
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string, fields: Record<string, any>, reader?: RecordReader): Promise<SideEffect[]>;
|
|
26
69
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { SideEffect } from '../drafts/sideEffects';
|
|
2
|
+
import type { CreateSideEffectHook, UpdateSideEffectHook } from '../drafts/records/actionHandlers/SideEffectHook';
|
|
3
|
+
import type { DurableRecordStore } from '../durableStore/DurableRecordStore';
|
|
4
|
+
import type { RecordReader } from '../durableStore/MemoizingRecordReader';
|
|
5
|
+
/**
|
|
6
|
+
* Replicates the server-derived `IsProduct2Serialized` boolean on a draft-created
|
|
7
|
+
* `ProductItem` record.
|
|
8
|
+
*
|
|
9
|
+
* Unlike `ProductConsumed`/`ProductTransfer` — which reach the product through a related
|
|
10
|
+
* `ProductItem` — a `ProductItem` carries `Product2Id` directly, so the value is resolved as
|
|
11
|
+
* `Product2Id` -> `Product2.IsSerialized` (see `resolveIsSerializedFromProduct2Id`). When the
|
|
12
|
+
* chain cannot be resolved the hook exits without an effect and the field is left as
|
|
13
|
+
* synthesized (null).
|
|
14
|
+
*/
|
|
15
|
+
export declare class ProductItemIsSerializedCreatedHook implements CreateSideEffectHook {
|
|
16
|
+
private readonly durableRecordStore;
|
|
17
|
+
on: 'post';
|
|
18
|
+
apiName: string;
|
|
19
|
+
private static COUNTER_NAME;
|
|
20
|
+
constructor(durableRecordStore: DurableRecordStore);
|
|
21
|
+
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string, fields: Record<string, any>, reader?: RecordReader): Promise<SideEffect[]>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Replicates the server-derived `IsProduct2Serialized` boolean on a draft-edited
|
|
25
|
+
* `ProductItem` record.
|
|
26
|
+
*
|
|
27
|
+
* A `patch` body only carries changed fields, so `Product2Id` may be absent; it is resolved by
|
|
28
|
+
* preferring the patch body (the product is being reassigned) and falling back to the original
|
|
29
|
+
* record in the durable store, then resolved as `Product2Id` -> `Product2.IsSerialized` (see
|
|
30
|
+
* `resolveIsSerializedFromProduct2Id`).
|
|
31
|
+
*
|
|
32
|
+
* When the patch explicitly clears `Product2Id` (sets it to `null`) the record no longer
|
|
33
|
+
* derives from any `Product2`, so `IsProduct2Serialized` is cleared (set to `null`) rather than
|
|
34
|
+
* resolved from the now-stale original link. Likewise, when the patch reassigns `Product2Id` to
|
|
35
|
+
* a new id whose `Product2` isn't cached, the stored value reflects the old link and is stale,
|
|
36
|
+
* so it is cleared. When the link is unchanged and its `Product2` cannot be resolved, the stored
|
|
37
|
+
* value is still correct so the hook exits without an effect and leaves it unchanged.
|
|
38
|
+
*/
|
|
39
|
+
export declare class ProductItemIsSerializedUpdatedHook implements UpdateSideEffectHook {
|
|
40
|
+
private readonly durableRecordStore;
|
|
41
|
+
on: 'patch';
|
|
42
|
+
apiName: string;
|
|
43
|
+
private static COUNTER_NAME;
|
|
44
|
+
constructor(durableRecordStore: DurableRecordStore);
|
|
45
|
+
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string, fields: Record<string, any>, reader?: RecordReader): Promise<SideEffect[]>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { SideEffect } from '../drafts/sideEffects';
|
|
2
|
+
import type { CreateSideEffectHook, UpdateSideEffectHook } from '../drafts/records/actionHandlers/SideEffectHook';
|
|
3
|
+
import type { DurableRecordStore } from '../durableStore/DurableRecordStore';
|
|
4
|
+
import type { RecordReader } from '../durableStore/MemoizingRecordReader';
|
|
5
|
+
/**
|
|
6
|
+
* Replicates the server-derived `IsProduct2Serialized` boolean on a draft-created
|
|
7
|
+
* `ProductTransfer` record.
|
|
8
|
+
*
|
|
9
|
+
* The value is resolved through the related `SourceProductItem` record (a `ProductItem`),
|
|
10
|
+
* mirroring the `ProductConsumed` hook: the ProductItem's own `IsProduct2Serialized` when
|
|
11
|
+
* cached, otherwise `ProductItem.Product2Id` -> `Product2.IsSerialized` (see
|
|
12
|
+
* `resolveIsProduct2SerializedFromProductItem`). When the chain cannot be resolved the hook
|
|
13
|
+
* exits without an effect and the field is left as synthesized (null).
|
|
14
|
+
*/
|
|
15
|
+
export declare class ProductTransferIsSerializedCreatedHook implements CreateSideEffectHook {
|
|
16
|
+
private readonly durableRecordStore;
|
|
17
|
+
on: 'post';
|
|
18
|
+
apiName: string;
|
|
19
|
+
private static COUNTER_NAME;
|
|
20
|
+
constructor(durableRecordStore: DurableRecordStore);
|
|
21
|
+
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string, fields: Record<string, any>, reader?: RecordReader): Promise<SideEffect[]>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Replicates the server-derived `IsProduct2Serialized` boolean on a draft-edited
|
|
25
|
+
* `ProductTransfer` record.
|
|
26
|
+
*
|
|
27
|
+
* ProductTransfer can only be edited (not created) on mobile, so this is the hook that fires
|
|
28
|
+
* in practice. A `patch` body only carries changed fields, so the related `SourceProductItemId`
|
|
29
|
+
* may be absent; the id is resolved by preferring the patch body (the link is being reassigned)
|
|
30
|
+
* and falling back to the original record in the durable store, then the value is resolved
|
|
31
|
+
* through that `ProductItem` exactly as on create (see
|
|
32
|
+
* `resolveIsProduct2SerializedFromProductItem`).
|
|
33
|
+
*
|
|
34
|
+
* When the patch explicitly clears `SourceProductItemId` (sets it to `null`) the record no
|
|
35
|
+
* longer derives from any `ProductItem`, so `IsProduct2Serialized` is cleared (set to `null`)
|
|
36
|
+
* rather than resolved from the now-stale original link. Likewise, when the patch reassigns
|
|
37
|
+
* `SourceProductItemId` to a new id whose chain isn't cached, the stored value reflects the old
|
|
38
|
+
* link and is stale, so it is cleared. When the link is unchanged and its chain cannot be
|
|
39
|
+
* resolved, the stored value is still correct so the hook exits without an effect and leaves it
|
|
40
|
+
* unchanged.
|
|
41
|
+
*/
|
|
42
|
+
export declare class ProductTransferIsSerializedUpdatedHook implements UpdateSideEffectHook {
|
|
43
|
+
private readonly durableRecordStore;
|
|
44
|
+
on: 'patch';
|
|
45
|
+
apiName: string;
|
|
46
|
+
private static COUNTER_NAME;
|
|
47
|
+
constructor(durableRecordStore: DurableRecordStore);
|
|
48
|
+
then(draftActionId: string, draftActionTimestamp: number, draftRecordId: string, fields: Record<string, any>, reader?: RecordReader): Promise<SideEffect[]>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { RecordReader } from '../durableStore/MemoizingRecordReader';
|
|
2
|
+
import type { DurableRecordRepresentationFields } from '@salesforce/lds-durable-records';
|
|
3
|
+
export declare const instrumentation: any;
|
|
4
|
+
export declare enum CounterResult {
|
|
5
|
+
Created = "Created",
|
|
6
|
+
Exited = "Exited",
|
|
7
|
+
Error = "Error"
|
|
8
|
+
}
|
|
9
|
+
export declare function incrementCounter(name: string, result: CounterResult): void;
|
|
10
|
+
/**
|
|
11
|
+
* Reads a string-valued field off a draft-create `fields` map (the raw create body, where
|
|
12
|
+
* values are the primitives themselves rather than `{ value }` wrappers). Returns `undefined`
|
|
13
|
+
* when the field is absent or not a string.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getStringDraftField(fields: Record<string, any>, fieldName: string): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Reads a string-valued field off a durable record's `fields` map (where each value is a
|
|
18
|
+
* `{ value }` wrapper). Returns `undefined` when the field is absent, null, or not a string.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getStringRecordField(fields: DurableRecordRepresentationFields, fieldName: string): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* The outcome of resolving a related reference id (e.g. `ProductItemId`,
|
|
23
|
+
* `SourceProductItemId`, `Product2Id`) on a draft edit:
|
|
24
|
+
*
|
|
25
|
+
* - `resolved` — a usable id was found. `source` records where it came from, because the two
|
|
26
|
+
* cases differ when the id's chain can't be resolved downstream:
|
|
27
|
+
* - `'patch'` — the link was reassigned to a new id in the patch body. If
|
|
28
|
+
* its chain can't be resolved, the stored `IsProduct2Serialized` reflects
|
|
29
|
+
* the OLD link and is now stale, so the caller must clear it (set null).
|
|
30
|
+
* - `'original'` — the patch left the link untouched and it fell back to the
|
|
31
|
+
* original durable record. If its chain can't be resolved, the stored
|
|
32
|
+
* value is still correct for the unchanged link, so the caller leaves it.
|
|
33
|
+
* - `cleared` — the patch explicitly set the link to `null`; the record no longer derives
|
|
34
|
+
* from any related record, so the caller should clear `IsProduct2Serialized`
|
|
35
|
+
* rather than fall back to the now-stale original id.
|
|
36
|
+
* - `unresolved`— no usable id and no explicit clear (link absent from the patch and missing
|
|
37
|
+
* from the original record); the caller exits without an effect.
|
|
38
|
+
*/
|
|
39
|
+
export type ReferenceIdForUpdate = {
|
|
40
|
+
kind: 'resolved';
|
|
41
|
+
id: string;
|
|
42
|
+
source: 'patch' | 'original';
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'cleared';
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'unresolved';
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Resolves the reference id that points at a related record for a draft edit.
|
|
50
|
+
*
|
|
51
|
+
* On a `patch` the body only carries the fields being changed, so the link field may be
|
|
52
|
+
* absent, present with a new id, or present but explicitly `null` (the link is being cleared).
|
|
53
|
+
* These three cases are distinguished via `hasOwnProperty` because they demand different
|
|
54
|
+
* behavior — falling back to the original durable-store id on an explicit `null` would resolve
|
|
55
|
+
* `IsProduct2Serialized` from a relationship the record no longer has:
|
|
56
|
+
*
|
|
57
|
+
* - present + string -> `resolved` with the reassigned id.
|
|
58
|
+
* - present + null -> `cleared`.
|
|
59
|
+
* - absent -> fall back to the original record; `resolved` when it carries a usable
|
|
60
|
+
* string, otherwise `unresolved`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function resolveReferenceIdForUpdate(patchFields: Record<string, any>, originalFields: DurableRecordRepresentationFields, fieldName: string): ReferenceIdForUpdate;
|
|
63
|
+
/**
|
|
64
|
+
* Resolves the server-derived `IsProduct2Serialized` boolean for a draft-created record by
|
|
65
|
+
* following the related `ProductItem`:
|
|
66
|
+
*
|
|
67
|
+
* 1. If the cached `ProductItem` already carries `IsProduct2Serialized`, use it directly
|
|
68
|
+
* (it mirrors the linked product's serialization, and avoids a second durable read).
|
|
69
|
+
* 2. Otherwise fall back to the linked `Product2`:
|
|
70
|
+
* `ProductItem.Product2Id` -> `Product2.IsSerialized`.
|
|
71
|
+
*
|
|
72
|
+
* All lookups go through the given `RecordReader` (the durable store, or a per-action memoizer
|
|
73
|
+
* that dedups reads). Returns `undefined` when a link in the chain is missing so the caller can
|
|
74
|
+
* exit without an effect and leave the field synthesized (null). Callers pass their own
|
|
75
|
+
* `counterName` so instrumentation is attributed to the owning hook.
|
|
76
|
+
*/
|
|
77
|
+
export declare function resolveIsProduct2SerializedFromProductItem(recordReader: RecordReader, productItemId: string, counterName: string): Promise<boolean | undefined>;
|
|
78
|
+
/**
|
|
79
|
+
* Resolves the `Product2.IsSerialized` boolean for a given `Product2Id` by reading the linked
|
|
80
|
+
* `Product2` record through the given `RecordReader`. Used directly by the `ProductItem` hooks
|
|
81
|
+
* (which carry `Product2Id` themselves) and as the fallback tail of
|
|
82
|
+
* `resolveIsProduct2SerializedFromProductItem`.
|
|
83
|
+
*
|
|
84
|
+
* Returns `undefined` when the `Product2` record is missing so the caller can exit without an
|
|
85
|
+
* effect and leave the field synthesized (null). Callers pass their own `counterName` so
|
|
86
|
+
* instrumentation is attributed to the owning hook.
|
|
87
|
+
*/
|
|
88
|
+
export declare function resolveIsSerializedFromProduct2Id(recordReader: RecordReader, product2Id: string, counterName: string): Promise<boolean | undefined>;
|