computeFanout

tagtree · /core·functionthrows When

Expands a single entity reference into its full set of invalidation tags, from the most-specific leaf tag down to the namespace root, following the hierarchy declared in the schema.

Signature

@nordcom/commerce-tagtree
function computeFanout(schema: CacheSchemaShape<NS, T, Q, E>, input: FanoutInput<T>): string[];

Parameters

NameTypeDescription
schemaCacheSchemaShape<NS, T, Q, E>
inputFanoutInput<T>

Returns

Ordered array of cache tags from leaf to namespace root, suitable for passing to an adapter's invalidate call.

Throws

When
input.entity is not declared in schema.entities.

Example

const tags = computeFanout(productSchema.schema, {
    entity: 'product',
    tenant: shop,
    params: { id: '123' },
});
// ['commerce.acme.product.123', 'commerce.acme.product', 'commerce.acme', 'commerce']

ContractTestOptions runAdapterContract AdapterCtx CacheAdapter CacheInstance CacheKey CacheSchema CacheSchemaShape

Sourcefanout.ts:44Edit the JSDoc directly

On this page