@company-semantics/contracts 0.101.0 → 0.102.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/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ResourceResponse } from '../../../resource-response';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wrap resource data with version for cache invalidation.
|
|
5
|
+
* @param data - The resource data
|
|
6
|
+
* @param version - MUST be entity.updatedAt or DB row version. NEVER Date.now().
|
|
7
|
+
* Using request time defeats invalidation — race conditions reappear.
|
|
8
|
+
*/
|
|
9
|
+
export function resourceResponse<T>(data: T, version: number): ResourceResponse<T> {
|
|
10
|
+
return { data, version };
|
|
11
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -536,3 +536,6 @@ export { ENVELOPE_TRANSITIONS } from './ci-envelope/index'
|
|
|
536
536
|
// @see PRD-00321 for design rationale
|
|
537
537
|
export type { ResourceKey, Action } from './resource-keys'
|
|
538
538
|
export { resolveScope, toQueryKey, fromQueryKey, resourceRelationships, matchesResourceKey } from './resource-keys'
|
|
539
|
+
|
|
540
|
+
// Resource response wrapper (typed versioning for cache invalidation)
|
|
541
|
+
export type { ResourceResponse } from './resource-response'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard response wrapper for resource endpoints.
|
|
3
|
+
* version MUST come from data source (entity.updatedAt), NEVER from request time (Date.now()).
|
|
4
|
+
* Using request time defeats invalidation — race conditions reappear.
|
|
5
|
+
*/
|
|
6
|
+
export type ResourceResponse<T> = {
|
|
7
|
+
data: T;
|
|
8
|
+
version: number;
|
|
9
|
+
};
|