@conduit-client/type-normalization 3.23.2 → 3.24.1

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.
@@ -98,44 +98,44 @@ export type ReadInputOf<T extends TypeRepository<any, any, any, any>> = T extend
98
98
  export type WriteResponseOf<T extends TypeRepository<any, any, any, any>> = T extends TypeRepository<any, any, infer WriteResponse, any> ? WriteResponse : never;
99
99
  export type WriteResultOf<T extends TypeRepository<any, any, any, any>> = WriteResult<WriteResponseOf<T>>;
100
100
  export type WriteInputOf<T extends TypeRepository<any, any, any, any>> = T extends TypeRepository<any, any, any, infer WriteInput> ? WriteInput : never;
101
- export type InvalidateInputOf<T extends TypeRepository<any, any, any, any>> = T extends Invalidatable<any, infer InvalidateInput> ? InvalidateInput : never;
101
+ export type InvalidateInputOf<T extends TypeRepository<any, any, any, any>> = T extends Invalidatable<TypeRepository<any, any, any, any>, infer InvalidateInput> ? InvalidateInput : never;
102
102
  /**
103
103
  * A utility method for ensuring that a given entry in the cache matches a type based on namespace and name information
104
104
  * @param cacheEntry the cache entry to validate against
105
105
  * @param type the type to validate the cache entry against
106
106
  * @returns
107
107
  */
108
- export declare function isCacheEntryForType(cacheEntry: CacheEntry<unknown>, type: TypeRepository<unknown, unknown, unknown, unknown>): boolean;
109
- export type KeyParamsOf<T> = T extends IdentifiableTypeRepository<any, any, infer KeyParams, any, any> ? KeyParams : never;
108
+ export declare function isCacheEntryForType(cacheEntry: CacheEntry<unknown>, type: TypeRepository<any, any, any, any>): boolean;
109
+ export type KeyParamsOf<T> = T extends IdentifiableTypeRepository<any, any, infer KeyParams, Record<string, unknown>, Record<string, unknown>> ? KeyParams : never;
110
110
  export type WriteInput<Data, Extension = Record<string, unknown>> = {
111
111
  data: Data;
112
112
  } & Extension;
113
- export type NormalizeDataInput<Data, NormalizedData, Extension extends Record<string, any> = Record<string, unknown>> = WriteInput<Data, Extension & {
113
+ export type NormalizeDataInput<Data, NormalizedData, Extension extends Record<string, unknown> = Record<string, unknown>> = WriteInput<Data, Extension & {
114
114
  existingNormalizedData?: NormalizedData;
115
115
  }>;
116
- export type ReadInput<Extension extends Record<string, any> = Record<string, unknown>> = {
116
+ export type ReadInput<Extension extends Record<string, unknown> = Record<string, unknown>> = {
117
117
  normalizedData: NormalizedLink;
118
118
  } & Extension;
119
119
  export type ReadByKeyParamsInput<KeyParams> = {
120
120
  keyParams: KeyParams;
121
121
  };
122
- export type DenormalizeInput<Extension extends Record<string, any> = Record<string, unknown>> = Extension & {
122
+ export type DenormalizeInput<Extension extends Record<string, unknown> = Record<string, unknown>> = Extension & {
123
123
  key: Key;
124
124
  };
125
- export type DenormalizeDataInput<NormalizedData, Extension extends Record<string, any> = Record<string, unknown>> = Extension & {
125
+ export type DenormalizeDataInput<NormalizedData, Extension extends Record<string, unknown> = Record<string, unknown>> = Extension & {
126
126
  normalizedData: NormalizedData;
127
127
  };
128
128
  export type KeyParamQuery<KeyParams, ReadInputExtension> = {
129
129
  type: 'keyParams';
130
130
  keyParams: KeyParams;
131
131
  } & ReadInputExtension;
132
- export type QueryFor<T> = T extends Queryable<any, infer Query> ? Query : never;
132
+ export type QueryFor<T> = T extends Queryable<TypeRepository<any, any, any, any>, infer Query> ? Query : never;
133
133
  /**
134
134
  * An abstract base class that implements Type, defining additional abstract properties and methods
135
135
  * for building a key for a given set of parameters, and defining the canonical cache control metadata
136
136
  * for any data written
137
137
  */
138
- export declare abstract class IdentifiableTypeRepository<Data, NormalizedData, KeyParams, ReadInputExtension extends Record<string, any> = Record<string, unknown>, WriteInputExtension extends Record<string, any> = Record<string, unknown>, Query extends KeyParamQuery<KeyParams, ReadInputExtension> = KeyParamQuery<KeyParams, ReadInputExtension>> implements Queryable<TypeRepository<Data, ReadInput<ReadInputExtension>, NormalizedLink, WriteInput<Data, WriteInputExtension>>, Query> {
138
+ export declare abstract class IdentifiableTypeRepository<Data, NormalizedData, KeyParams, ReadInputExtension extends Record<string, unknown> = Record<string, unknown>, WriteInputExtension extends Record<string, unknown> = Record<string, unknown>, Query extends KeyParamQuery<KeyParams, ReadInputExtension> = KeyParamQuery<KeyParams, ReadInputExtension>> implements Queryable<TypeRepository<Data, ReadInput<ReadInputExtension>, NormalizedLink, WriteInput<Data, WriteInputExtension>>, Query> {
139
139
  protected services: {};
140
140
  constructor(services: {});
141
141
  abstract readonly cacheControl: CanonicalCacheControlMetadata;
@@ -178,14 +178,16 @@ export declare abstract class IdentifiableTypeRepository<Data, NormalizedData, K
178
178
  * only data required to write to the cache is an instance of the data itself, i.e. the identity of
179
179
  * the data lives inside the data
180
180
  */
181
- export declare abstract class SelfIdentifiableTypeRepository<Data, NormalizedData, KeyParams, ReadInputExtension extends Record<string, any> = Record<string, unknown>, WriteInputExtension extends Record<string, any> = Record<string, unknown>> extends IdentifiableTypeRepository<Data, NormalizedData, KeyParams, ReadInputExtension, WriteInputExtension> {
181
+ export declare abstract class SelfIdentifiableTypeRepository<Data, NormalizedData, KeyParams, ReadInputExtension extends Record<string, unknown> = Record<string, unknown>, WriteInputExtension extends Record<string, unknown> = Record<string, unknown>> extends IdentifiableTypeRepository<Data, NormalizedData, KeyParams, ReadInputExtension, WriteInputExtension> {
182
182
  }
183
183
  /**
184
- * An abstract base class that extends SelfIdentifiableType. Adds the constraint that the structure of
185
- * the key parameters must be a flat object, with no objects nested. This class provides invalidation and keybuilding 'for free'.
186
- * Should be preferred over IdentifiableType and SelfIdentifiableType
184
+ * Adds flat positional keying (keySchema), keySchema-based buildKey, and invalidate/evict
185
+ * to IdentifiableTypeRepository. Key params are supplied externally (e.g. from request
186
+ * config) — this class makes NO claim that identity lives in the data. KeyParams must be a
187
+ * flat object (scalars, scalar arrays, or stable-stringifiable objects). Provides
188
+ * invalidation + key building 'for free'.
187
189
  */
188
- export declare abstract class FlattenedKeySelfIdentifiableTypeRepository<Data, NormalizedData, KeyParams extends FlattenedKeyParams, ReadInputExtension extends Record<string, any> = Record<string, unknown>, WriteInputExtension extends Record<string, any> = Record<string, unknown>> extends SelfIdentifiableTypeRepository<Data, NormalizedData, KeyParams, ReadInputExtension, WriteInputExtension> implements Invalidatable<SelfIdentifiableTypeRepository<Data, NormalizedData, KeyParams, ReadInputExtension, WriteInputExtension>, Partial<KeyParams>> {
190
+ export declare abstract class FlattenedKeyIdentifiableTypeRepository<Data, NormalizedData, KeyParams extends FlattenedKeyParams, ReadInputExtension extends Record<string, unknown> = Record<string, unknown>, WriteInputExtension extends Record<string, unknown> = Record<string, unknown>> extends IdentifiableTypeRepository<Data, NormalizedData, KeyParams, ReadInputExtension, WriteInputExtension> implements Invalidatable<IdentifiableTypeRepository<Data, NormalizedData, KeyParams, ReadInputExtension, WriteInputExtension>, Partial<KeyParams>> {
189
191
  protected services: NamedCacheControllerService & NamedPubSubService & Partial<NamedInstrumentationService>;
190
192
  instrumentationAttributes: InstrumentationAttributes | undefined;
191
193
  constructor(services: NamedCacheControllerService & NamedPubSubService & Partial<NamedInstrumentationService>);
@@ -203,11 +205,18 @@ export declare abstract class FlattenedKeySelfIdentifiableTypeRepository<Data, N
203
205
  private runCacheOperation;
204
206
  buildKey(config: KeyParams): Key;
205
207
  }
208
+ /**
209
+ * Flat-keyed identifiable type whose identity lives inside the data itself
210
+ * (self-identifiable). Behaviorally identical to FlattenedKeyIdentifiableTypeRepository;
211
+ * the distinction is a semantic marker for generators that derive keyParams from data.
212
+ */
213
+ export declare abstract class FlattenedKeySelfIdentifiableTypeRepository<Data, NormalizedData, KeyParams extends FlattenedKeyParams, ReadInputExtension extends Record<string, unknown> = Record<string, unknown>, WriteInputExtension extends Record<string, unknown> = Record<string, unknown>> extends FlattenedKeyIdentifiableTypeRepository<Data, NormalizedData, KeyParams, ReadInputExtension, WriteInputExtension> {
214
+ }
206
215
  type ScalarKeyValue = string | number | boolean | null | undefined;
207
- type FlattenedKeyParams = Record<string, ScalarKeyValue | ScalarKeyValue[]>;
216
+ type FlattenedKeyParams = Record<string, ScalarKeyValue | ScalarKeyValue[] | object>;
208
217
  export declare function buildNamespacedTypeKey(namespace: string, typeName: string, keyConfig: FlattenedKeyParams, keySchema: string[]): string;
209
218
  export declare function buildRegexForNamespacedKeys(namespace: string, typeName: string, partialKeyConfigs: Array<FlattenedKeyParams>, keySchema: string[]): RegExp;
210
- export declare function extractReadWriteData<Data>(result: ReadResult<Data> | WriteResult<Data>, errorCollector: any[]): Data | undefined;
219
+ export declare function extractReadWriteData<Data, Error>(result: Result<Data, Error[]>, errorCollector: Error[]): Data | undefined;
211
220
  export declare function buildReadWriteResult<Data, Errors extends WriteErrors | ReadErrors>(data: unknown, errors: Errors): Result<Data, Errors>;
212
221
  export type UnionRepresentation<Discriminator extends string, Data> = {
213
222
  discriminator: Discriminator;
@@ -219,15 +228,15 @@ export type DiscriminatorMap<Discriminator extends string, Data, Normalized> = {
219
228
  normalized: Normalized;
220
229
  };
221
230
  };
222
- export type NormalizedRepresentationOf<M extends DiscriminatorMap<any, any, any>> = M extends DiscriminatorMap<infer D, any, any> ? {
231
+ export type NormalizedRepresentationOf<M extends DiscriminatorMap<string, unknown, unknown>> = M extends DiscriminatorMap<infer D, unknown, unknown> ? {
223
232
  [k in D]: UnionRepresentation<k, M[k]['normalized']>;
224
233
  }[D] : never;
225
- export type DenormalizeMapOf<M extends DiscriminatorMap<any, any, any>> = M extends DiscriminatorMap<infer D, any, any> ? {
234
+ export type DenormalizeMapOf<M extends DiscriminatorMap<string, unknown, unknown>> = M extends DiscriminatorMap<infer D, unknown, unknown> ? {
226
235
  [k in D]: (normalized: M[k]['normalized']) => M[k]['data'];
227
236
  } : never;
228
- export type UnionDataOf<M extends DiscriminatorMap<any, any, any>> = M extends DiscriminatorMap<any, infer D, any> ? D : never;
229
- export type DiscriminatorOf<M extends DiscriminatorMap<any, any, any>> = M extends DiscriminatorMap<infer D, any, any> ? D : never;
230
- export type DiscriminatorNormalizeFunctionsMap<M extends DiscriminatorMap<any, any, any>> = M extends DiscriminatorMap<infer D, any, any> ? {
237
+ export type UnionDataOf<M extends DiscriminatorMap<string, unknown, unknown>> = M extends DiscriminatorMap<string, infer D, unknown> ? D : never;
238
+ export type DiscriminatorOf<M extends DiscriminatorMap<string, unknown, unknown>> = M extends DiscriminatorMap<infer D, unknown, unknown> ? D : never;
239
+ export type DiscriminatorNormalizeFunctionsMap<M extends DiscriminatorMap<string, unknown, unknown>> = M extends DiscriminatorMap<infer D, unknown, unknown> ? {
231
240
  [k in D]: {
232
241
  test: (data: M[D]['data']) => boolean;
233
242
  normalize: (data: M[k]['data']) => M[k]['normalized'];
package/dist/v1/index.js CHANGED
@@ -80,7 +80,7 @@ class IdentifiableTypeRepository {
80
80
  }
81
81
  class SelfIdentifiableTypeRepository extends IdentifiableTypeRepository {
82
82
  }
83
- class FlattenedKeySelfIdentifiableTypeRepository extends SelfIdentifiableTypeRepository {
83
+ class FlattenedKeyIdentifiableTypeRepository extends IdentifiableTypeRepository {
84
84
  constructor(services) {
85
85
  super(services);
86
86
  this.services = services;
@@ -144,13 +144,27 @@ class FlattenedKeySelfIdentifiableTypeRepository extends SelfIdentifiableTypeRep
144
144
  return buildNamespacedTypeKey(this.namespace, this.typeName, config, this.keySchema);
145
145
  }
146
146
  }
147
+ class FlattenedKeySelfIdentifiableTypeRepository extends FlattenedKeyIdentifiableTypeRepository {
148
+ }
147
149
  function buildNamespacedTypeKey(namespace, typeName, keyConfig, keySchema) {
148
- const keyParts = keySchema.map((key) => {
149
- const value = keyConfig[key];
150
- return `${ArrayIsArray(value) ? value.join() : value}`;
151
- }).join("|");
150
+ const keyParts = keySchema.map((key) => serializeKeyValue(keyConfig[key])).join("|");
152
151
  return `${namespace}::${typeName}(${keyParts})`;
153
152
  }
153
+ function serializeKeyValue(value) {
154
+ if (ArrayIsArray(value)) {
155
+ const allScalar = value.every(
156
+ (v) => v === null || v === void 0 || typeof v !== "object"
157
+ );
158
+ return encodeKeySlot(allScalar ? value.join() : stableJSONStringify(value) ?? "");
159
+ }
160
+ if (value !== null && value !== void 0 && typeof value === "object") {
161
+ return encodeKeySlot(stableJSONStringify(value) ?? "");
162
+ }
163
+ return encodeKeySlot(`${value}`);
164
+ }
165
+ function encodeKeySlot(serialized) {
166
+ return serialized.replace(/%/g, "%25").replace(/\|/g, "%7C");
167
+ }
154
168
  function buildRegexForNamespacedKeys(namespace, typeName, partialKeyConfigs, keySchema) {
155
169
  const patterns = partialKeyConfigs.map((partial) => {
156
170
  const requiredParts = keySchema.map((key) => {
@@ -158,7 +172,8 @@ function buildRegexForNamespacedKeys(namespace, typeName, partialKeyConfigs, key
158
172
  return `[^|]*?`;
159
173
  }
160
174
  const value = partial[key];
161
- return `(?:${(ArrayIsArray(value) ? value.join() : String(value)).replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`;
175
+ const serialized = serializeKeyValue(value);
176
+ return `(?:${serialized.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`;
162
177
  }).join("\\|");
163
178
  return `^${namespace}::${typeName}\\((?:${requiredParts})\\)$`;
164
179
  });
@@ -194,6 +209,7 @@ function normalizeUnionRepresentation(data, normalizeTestMap) {
194
209
  throw new Error("No matching union member found");
195
210
  }
196
211
  export {
212
+ FlattenedKeyIdentifiableTypeRepository,
197
213
  FlattenedKeySelfIdentifiableTypeRepository,
198
214
  IdentifiableTypeRepository,
199
215
  SelfIdentifiableTypeRepository,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/v1/index.ts"],"sourcesContent":["import { type Result, ok, err, deepEquals, stableJSONStringify } from '@conduit-client/utils';\n\nimport { ArrayIsArray } from '@conduit-client/utils';\nimport type { NamedPubSubService } from '@conduit-client/service-pubsub/v1';\nimport type {\n InstrumentationAttributes,\n NamedInstrumentationService,\n} from '@conduit-client/service-instrumentation/v1';\nimport type { NamedCacheControllerService } from '@conduit-client/service-cache-control/v1';\nimport type {\n Key,\n CanonicalCacheControlMetadata,\n ReadonlyCache,\n CacheEntry,\n Cache,\n} from '@conduit-client/service-cache/v1';\n\nexport interface NormalizedLink {\n type: 'link';\n linkedKey: Key;\n}\n\ntype UnknownError = {\n type: 'unknown';\n error: Error;\n};\n\n/**\n * An error that occurs when a type tries to read from the cache, and the cache metadata does\n * not match the current type\n */\ntype IncorrectTypeError = {\n type: 'incorrectType';\n expectedType: string;\n actualType: string;\n};\n\n/**\n * An error that occurs when a type tries to read from the cache and data is missing\n */\ntype MissingDataError = {\n type: 'missingData';\n namespace: string;\n typeName: string;\n data: unknown;\n};\n\n/**\n * A union of errors that can be returned during the write process\n */\nexport type WriteErrors = Array<UnknownError>;\n\n/**\n * A union of errors that can be returned during the read process\n */\nexport type ReadErrors = Array<UnknownError | IncorrectTypeError | MissingDataError>;\n\nexport type ReadResult<Data> = Result<Data, ReadErrors>;\nexport type WriteResult<Data> = Result<Data, WriteErrors>;\n\n/**\n * A Type defines a collection of functions associated with a particular\n * data type. Types are not normalized but may contain normalized data.\n *\n * @typeParam Data TypeScript type that corresponds to the data\n * @typeParam NormalizedData TypeScript type that corresponds to the normalized data\n * @typeParam NormalizeInputData TypeScript type that corresponds to the data that the normalize method expects as input. Defaults to the same as Data\n */\nexport type TypeRepository<Data, ReadInput, WriteResponse, WriteInput> = {\n readonly namespace: string;\n readonly typeName: string;\n\n equals(x: Data, y: Data): boolean;\n\n /**\n * Normalizes data for storage.\n */\n write(cache: Cache, input: WriteInput): WriteResult<WriteResponse>;\n\n /**\n * De-normalizes a Type's data. A type could normalize into a Link, or return Data to the caller.\n * A caller must not be relying on the referenced type being normalized or not.\n * If denormalization fails, it will return undefined.\n */\n read(cache: ReadonlyCache, input: ReadInput): ReadResult<Data>;\n};\n\n/**\n * An InvalidatableType defines an invalidate function that takes a generic input,\n * and returns a promise that resolves when the invalidation is complete\n *\n * @typeParam T is another type to extend\n * @typeParam InvalidateInput is the input to run an invalidation\n */\nexport type Invalidatable<T extends TypeRepository<any, any, any, any>, InvalidateInput> = T & {\n /**\n *\n * @param configs Partial KeyConfigs for this Type (partial KeyConfig treats missing parts as wildcard)\n */\n invalidate(configs: InvalidateInput[]): Promise<void>;\n};\n\n/**\n * A QueryableType defines a collection of functions associated with a particular\n * data type that gets its own cache entry.\n *\n * @typeParam Data TypeScript type that corresponds to the data\n * @typeParam KeyConfig TypeScript type for the inputs needed to construct\n * a Key for the data\n * @typeParam NormalizeInputData TypeScript type that corresponds to the data that the normalize method expects as input. Defaults to the same as Data\n */\nexport type Queryable<T extends TypeRepository<any, any, any, any>, QueryInput> = T & {\n /**\n *\n * @param cache The cache to run the query against\n * @param query The query to run\n */\n query(cache: Cache, query: QueryInput): ReadResult<DataOf<T>>;\n};\n\nexport type DataOf<T extends TypeRepository<any, any, any, any>> =\n T extends TypeRepository<infer Data, any, any, any> ? Data : never;\nexport type ReadInputOf<T extends TypeRepository<any, any, any, any>> =\n T extends TypeRepository<any, infer ReadInput, any, any> ? ReadInput : never;\nexport type WriteResponseOf<T extends TypeRepository<any, any, any, any>> =\n T extends TypeRepository<any, any, infer WriteResponse, any> ? WriteResponse : never;\nexport type WriteResultOf<T extends TypeRepository<any, any, any, any>> = WriteResult<\n WriteResponseOf<T>\n>;\nexport type WriteInputOf<T extends TypeRepository<any, any, any, any>> =\n T extends TypeRepository<any, any, any, infer WriteInput> ? WriteInput : never;\nexport type InvalidateInputOf<T extends TypeRepository<any, any, any, any>> =\n T extends Invalidatable<any, infer InvalidateInput> ? InvalidateInput : never;\n\n/**\n * A utility method for ensuring that a given entry in the cache matches a type based on namespace and name information\n * @param cacheEntry the cache entry to validate against\n * @param type the type to validate the cache entry against\n * @returns\n */\nexport function isCacheEntryForType(\n cacheEntry: CacheEntry<unknown>,\n type: TypeRepository<unknown, unknown, unknown, unknown>\n): boolean {\n return (\n cacheEntry.metadata.type.namespace === type.namespace &&\n cacheEntry.metadata.type.name === type.typeName\n );\n}\n\nexport type KeyParamsOf<T> =\n T extends IdentifiableTypeRepository<any, any, infer KeyParams, any, any> ? KeyParams : never;\n\nexport type WriteInput<Data, Extension = Record<string, unknown>> = { data: Data } & Extension;\nexport type NormalizeDataInput<\n Data,\n NormalizedData,\n Extension extends Record<string, any> = Record<string, unknown>,\n> = WriteInput<Data, Extension & { existingNormalizedData?: NormalizedData }>;\n\nexport type ReadInput<Extension extends Record<string, any> = Record<string, unknown>> = {\n normalizedData: NormalizedLink;\n} & Extension;\nexport type ReadByKeyParamsInput<KeyParams> = {\n keyParams: KeyParams;\n};\nexport type DenormalizeInput<Extension extends Record<string, any> = Record<string, unknown>> =\n Extension & {\n key: Key;\n };\nexport type DenormalizeDataInput<\n NormalizedData,\n Extension extends Record<string, any> = Record<string, unknown>,\n> = Extension & { normalizedData: NormalizedData };\n\nexport type KeyParamQuery<KeyParams, ReadInputExtension> = {\n type: 'keyParams';\n keyParams: KeyParams;\n} & ReadInputExtension;\nexport type QueryFor<T> = T extends Queryable<any, infer Query> ? Query : never;\n\n/**\n * An abstract base class that implements Type, defining additional abstract properties and methods\n * for building a key for a given set of parameters, and defining the canonical cache control metadata\n * for any data written\n */\nexport abstract class IdentifiableTypeRepository<\n Data,\n NormalizedData,\n KeyParams,\n ReadInputExtension extends Record<string, any> = Record<string, unknown>,\n WriteInputExtension extends Record<string, any> = Record<string, unknown>,\n Query extends KeyParamQuery<KeyParams, ReadInputExtension> = KeyParamQuery<\n KeyParams,\n ReadInputExtension\n >,\n> implements\n Queryable<\n TypeRepository<\n Data,\n ReadInput<ReadInputExtension>,\n NormalizedLink,\n WriteInput<Data, WriteInputExtension>\n >,\n Query\n >\n{\n constructor(protected services: {}) {}\n abstract readonly cacheControl: CanonicalCacheControlMetadata;\n abstract readonly namespace: string;\n abstract readonly typeName: string;\n protected abstract denormalizeData(\n cache: ReadonlyCache,\n input: DenormalizeDataInput<NormalizedData, ReadInput<ReadInputExtension>>\n ): Result<Data, ReadErrors>;\n protected abstract normalizeData(\n cache: Cache,\n input: NormalizeDataInput<\n Data,\n NormalizedData,\n WriteInputExtension & { existingNormalizedData?: NormalizedData }\n >\n ): Result<NormalizedData, WriteErrors>;\n get cacheMetadata() {\n return {\n cacheControl: { ...this.cacheControl },\n type: { namespace: this.namespace, name: this.typeName },\n };\n }\n\n buildKey(params: KeyParams): Key {\n return `${this.namespace}::${this.typeName}(${stableJSONStringify(params)})`;\n }\n abstract buildKeyParams(input: WriteInput<Data, WriteInputExtension>): KeyParams;\n\n write(cache: Cache, input: WriteInput<Data, WriteInputExtension>): WriteResult<NormalizedLink> {\n // Identifiable types can have a key that is not the same as the input normalized data\n // so we need to build the key from the input, and then get the existing normalized data from the cache\n // and pass it to the normalizeData method. This should ALWAYS be done for identifiable types.\n const key = this.buildKey(this.buildKeyParams(input));\n const existingNormalizedData: NormalizedData | undefined = cache.get<NormalizedData>(key)\n ?.value as any;\n const normalized = this.normalizeData(cache, { ...input, existingNormalizedData });\n if (normalized.isErr()) {\n return err(normalized.error);\n }\n\n cache.set<NormalizedData>(key, {\n value: normalized.value,\n metadata: this.cacheMetadata,\n });\n\n return ok({\n type: 'link',\n linkedKey: key,\n } as const);\n }\n\n protected validateEntry(entry: CacheEntry<unknown>): Result<undefined, ReadErrors> {\n if (!isCacheEntryForType(entry, this)) {\n return err([\n {\n type: 'incorrectType',\n expectedType: this.typeName,\n actualType: entry.metadata.type.name,\n },\n ]);\n }\n return ok(undefined);\n }\n\n query(cache: Cache, query: Query): ReadResult<Data> {\n return this.read(cache, {\n ...query,\n normalizedData: { type: 'link', linkedKey: this.buildKey(query.keyParams) },\n });\n }\n\n read(cache: ReadonlyCache, input: ReadInput<ReadInputExtension>): Result<Data, ReadErrors> {\n return this.denormalize(cache, { ...input, key: input.normalizedData.linkedKey });\n }\n\n denormalize(cache: ReadonlyCache, input: DenormalizeInput<ReadInput<ReadInputExtension>>) {\n const cacheEntry = cache.get<NormalizedData>(input.key, {\n copy: false,\n }) as CacheEntry<NormalizedData>;\n\n if (cacheEntry) {\n const validationResult = this.validateEntry(cacheEntry);\n if (validationResult.isErr()) {\n return err([...validationResult.error]);\n }\n const normalizedData = cacheEntry.value;\n return this.denormalizeData(cache, { ...input, normalizedData });\n }\n\n return err([this.buildMissingDataError()]);\n }\n\n equals(x: Data, y: Data) {\n return deepEquals(x, y);\n }\n\n buildMissingDataError(): MissingDataError {\n return {\n type: 'missingData',\n typeName: this.typeName,\n namespace: this.namespace,\n data: undefined,\n };\n }\n}\n\n/**\n * An abstract base class that extends IdentifiableType, adding the additional constraint that the\n * only data required to write to the cache is an instance of the data itself, i.e. the identity of\n * the data lives inside the data\n */\nexport abstract class SelfIdentifiableTypeRepository<\n Data,\n NormalizedData,\n KeyParams,\n ReadInputExtension extends Record<string, any> = Record<string, unknown>,\n WriteInputExtension extends Record<string, any> = Record<string, unknown>,\n> extends IdentifiableTypeRepository<\n Data,\n NormalizedData,\n KeyParams,\n ReadInputExtension,\n WriteInputExtension\n> {}\n\n/**\n * An abstract base class that extends SelfIdentifiableType. Adds the constraint that the structure of\n * the key parameters must be a flat object, with no objects nested. This class provides invalidation and keybuilding 'for free'.\n * Should be preferred over IdentifiableType and SelfIdentifiableType\n */\nexport abstract class FlattenedKeySelfIdentifiableTypeRepository<\n Data,\n NormalizedData,\n KeyParams extends FlattenedKeyParams,\n ReadInputExtension extends Record<string, any> = Record<string, unknown>,\n WriteInputExtension extends Record<string, any> = Record<string, unknown>,\n >\n extends SelfIdentifiableTypeRepository<\n Data,\n NormalizedData,\n KeyParams,\n ReadInputExtension,\n WriteInputExtension\n >\n implements\n Invalidatable<\n SelfIdentifiableTypeRepository<\n Data,\n NormalizedData,\n KeyParams,\n ReadInputExtension,\n WriteInputExtension\n >,\n Partial<KeyParams>\n >\n{\n instrumentationAttributes: InstrumentationAttributes | undefined;\n constructor(\n protected services: NamedCacheControllerService &\n NamedPubSubService &\n Partial<NamedInstrumentationService>\n ) {\n super(services);\n }\n\n abstract readonly keySchema: string[];\n\n async invalidate(configs: Partial<KeyParams>[]): Promise<void> {\n return this.setupCacheOperation(configs, 'invalidate', 'cacheInvalidation');\n }\n\n protected collectInstrumentation(duration: number, type: 'invalidate' | 'evict') {\n if (this.services.instrumentation) {\n const meter = this.services.instrumentation.metrics.getMeter('onestore');\n const attributes = {\n ...this.instrumentationAttributes,\n namespace: this.namespace,\n typeName: this.typeName,\n };\n meter.createCounter<InstrumentationAttributes>(`type.${type}.count`).add(1, attributes);\n meter\n .createHistogram<InstrumentationAttributes>(`type.${type}.duration`)\n .record(duration, attributes);\n }\n }\n\n async evict(configs: Partial<KeyParams>[]): Promise<void> {\n return this.setupCacheOperation(configs, 'evict', 'cacheEviction');\n }\n\n private async setupCacheOperation(\n configs: Partial<KeyParams>[],\n cacheUpdateType: 'invalidate' | 'evict',\n eventType: 'cacheInvalidation' | 'cacheEviction'\n ) {\n const startTime = this.services.instrumentation\n ? this.services.instrumentation.currentTimeMs()\n : 0;\n const result = this.runCacheOperation(configs, cacheUpdateType, eventType).then(() => {\n if (this.services.instrumentation) {\n const duration = this.services.instrumentation.currentTimeMs() - startTime;\n this.collectInstrumentation(duration, cacheUpdateType);\n }\n });\n return result;\n }\n\n /**\n * Shared implementation for cache operations (invalidate/evict)\n * @param configs - Key configurations to match\n * @param cacheUpdateType - Type of cache update to perform\n * @param eventType - Type of event to publish\n */\n private async runCacheOperation(\n configs: Partial<KeyParams>[],\n cacheUpdateType: 'invalidate' | 'evict',\n eventType: 'cacheInvalidation' | 'cacheEviction'\n ): Promise<void> {\n const regex = buildRegexForNamespacedKeys(\n this.namespace,\n this.typeName,\n configs,\n this.keySchema\n );\n\n const results: Set<Key> = new Set();\n for await (const entry of this.services.cacheController.findAndModify(\n { key: { $regex: regex } },\n { type: cacheUpdateType }\n )) {\n results.add(entry);\n }\n if (results.size > 0) {\n await this.services.pubSub.publish({\n type: eventType,\n data: results,\n });\n }\n }\n\n buildKey(config: KeyParams): Key {\n return buildNamespacedTypeKey(this.namespace, this.typeName, config, this.keySchema);\n }\n}\ntype ScalarKeyValue = string | number | boolean | null | undefined;\ntype FlattenedKeyParams = Record<string, ScalarKeyValue | ScalarKeyValue[]>;\nexport function buildNamespacedTypeKey(\n namespace: string,\n typeName: string,\n keyConfig: FlattenedKeyParams,\n keySchema: string[]\n): string {\n const keyParts = keySchema\n .map((key) => {\n const value = keyConfig[key];\n return `${ArrayIsArray(value) ? value.join() : value}`;\n })\n .join('|');\n return `${namespace}::${typeName}(${keyParts})`;\n}\n\nexport function buildRegexForNamespacedKeys(\n namespace: string,\n typeName: string,\n partialKeyConfigs: Array<FlattenedKeyParams>,\n keySchema: string[]\n): RegExp {\n const patterns = partialKeyConfigs.map((partial) => {\n // Build a regex pattern for a single KeyConfig\n const requiredParts = keySchema\n .map((key) => {\n if (!(key in partial)) {\n return `[^|]*?`; // Allow any value or absence of value (optional match)\n }\n const value = partial[key];\n return `(?:${(ArrayIsArray(value) ? value.join() : String(value)).replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')})`;\n })\n .join('\\\\|'); // Ensure properties are matched in order with literal separator\n\n return `^${namespace}::${typeName}\\\\((?:${requiredParts})\\\\)$`;\n });\n\n return new RegExp(`^(?:${patterns.join('|')})$`); // Apply OR logic across separate partial configs\n}\n\nexport function extractReadWriteData<Data>(\n result: ReadResult<Data> | WriteResult<Data>,\n errorCollector: any[]\n): Data | undefined {\n if (result.isOk()) {\n return result.value;\n }\n\n errorCollector.push(...result.error);\n return undefined;\n}\n\nexport function buildReadWriteResult<Data, Errors extends WriteErrors | ReadErrors>(\n data: unknown,\n errors: Errors\n): Result<Data, Errors> {\n if (errors.length > 0) {\n return err(errors);\n }\n\n return ok(data as Data);\n}\n\n// This type is the normalized representation of union data (either a pure union, or a discriminated union)\n// This data shape will live in the cache, and contains the discriminator (i.e. an identity of what type of data this entry represents)\n// and the normalized data for that entry\nexport type UnionRepresentation<Discriminator extends string, Data> = {\n discriminator: Discriminator;\n data: Data;\n};\n\n// A utility type that represents all the information required for normalizing and\n// denormalizing types into a cache, including the discriminator value, the\n// canonical representation (Data) and the normalized representation (Normalized)\nexport type DiscriminatorMap<Discriminator extends string, Data, Normalized> = {\n [k in Discriminator]: {\n data: Data;\n normalized: Normalized;\n };\n};\n\n// A utility type for inferring the union of normalized representations\n// possible based on a given DiscriminatorType\nexport type NormalizedRepresentationOf<M extends DiscriminatorMap<any, any, any>> =\n M extends DiscriminatorMap<infer D, any, any>\n ? { [k in D]: UnionRepresentation<k, M[k]['normalized']> }[D]\n : never;\n\n// A utility type for inferring the discriminator -> denormalize function map\n// required by the `denormalizeUnionRepresentation` function\nexport type DenormalizeMapOf<M extends DiscriminatorMap<any, any, any>> =\n M extends DiscriminatorMap<infer D, any, any>\n ? { [k in D]: (normalized: M[k]['normalized']) => M[k]['data'] }\n : never;\n\n// A utility type for inferring the canonical data type union based on\n// a DiscriminatorMap type\nexport type UnionDataOf<M extends DiscriminatorMap<any, any, any>> =\n M extends DiscriminatorMap<any, infer D, any> ? D : never;\n\n// A utility type for inferring the discriminator string union from a\n// given discriminator map type\nexport type DiscriminatorOf<M extends DiscriminatorMap<any, any, any>> =\n M extends DiscriminatorMap<infer D, any, any> ? D : never;\n\n// A utilty type for inferring the test/normalize map type from a\n// discriminator map type to be used in the `normalizeUnionRepresentation` function\nexport type DiscriminatorNormalizeFunctionsMap<M extends DiscriminatorMap<any, any, any>> =\n M extends DiscriminatorMap<infer D, any, any>\n ? {\n [k in D]: {\n test: (data: M[D]['data']) => boolean;\n normalize: (data: M[k]['data']) => M[k]['normalized'];\n };\n }\n : never;\n\n/**\n *\n * @param normalized The normalized data representation, including the discriminator value\n * @param denormalizeMap A map of discriminator -> denormalize functions to be used based on the datas discriminator\n * @returns\n */\nexport function denormalizeUnionRepresentation<\n M extends DiscriminatorMap<string, unknown, unknown>,\n>(normalized: NormalizedRepresentationOf<M>, denormalizeMap: DenormalizeMapOf<M>): UnionDataOf<M> {\n const discriminator = normalized.discriminator as DiscriminatorOf<M>;\n return denormalizeMap[discriminator](normalized.data) as UnionDataOf<M>;\n}\n\n/**\n *\n * @param data The canonical/denormalized data representation\n * @param normalizeTestMap A map of discriminator to test method which return a boolean indicating if the data adheres to this \"discriminator\"\n * and a normalize function to call if the data matches this discriminator\n * @returns\n */\nexport function normalizeUnionRepresentation<M extends DiscriminatorMap<string, unknown, unknown>>(\n data: UnionDataOf<M>,\n normalizeTestMap: DiscriminatorNormalizeFunctionsMap<M>\n): NormalizedRepresentationOf<M> {\n for (const discriminator of Object.keys(normalizeTestMap) as DiscriminatorOf<M>[]) {\n const discriminatorLogic = normalizeTestMap[discriminator];\n if (discriminatorLogic.test(data)) {\n return {\n discriminator,\n data: discriminatorLogic.normalize(data),\n } as unknown as NormalizedRepresentationOf<M>;\n }\n }\n\n throw new Error('No matching union member found');\n}\n"],"names":[],"mappings":";AA4IO,SAAS,oBACZ,YACA,MACO;AACP,SACI,WAAW,SAAS,KAAK,cAAc,KAAK,aAC5C,WAAW,SAAS,KAAK,SAAS,KAAK;AAE/C;AAsCO,MAAe,2BAoBtB;AAAA,EACI,YAAsB,UAAc;AAAd,SAAA,WAAA;AAAA,EAAe;AAAA,EAgBrC,IAAI,gBAAgB;AAChB,WAAO;AAAA,MACH,cAAc,EAAE,GAAG,KAAK,aAAA;AAAA,MACxB,MAAM,EAAE,WAAW,KAAK,WAAW,MAAM,KAAK,SAAA;AAAA,IAAS;AAAA,EAE/D;AAAA,EAEA,SAAS,QAAwB;AAC7B,WAAO,GAAG,KAAK,SAAS,KAAK,KAAK,QAAQ,IAAI,oBAAoB,MAAM,CAAC;AAAA,EAC7E;AAAA,EAGA,MAAM,OAAc,OAA2E;AAI3F,UAAM,MAAM,KAAK,SAAS,KAAK,eAAe,KAAK,CAAC;AACpD,UAAM,yBAAqD,MAAM,IAAoB,GAAG,GAClF;AACN,UAAM,aAAa,KAAK,cAAc,OAAO,EAAE,GAAG,OAAO,wBAAwB;AACjF,QAAI,WAAW,SAAS;AACpB,aAAO,IAAI,WAAW,KAAK;AAAA,IAC/B;AAEA,UAAM,IAAoB,KAAK;AAAA,MAC3B,OAAO,WAAW;AAAA,MAClB,UAAU,KAAK;AAAA,IAAA,CAClB;AAED,WAAO,GAAG;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,IAAA,CACL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AAK,GAAG,OAAO,KAAK;AACnC,SAAO;AACX;AAEO,SAAS,qBACZ,MACA,QACoB;AACpB,MAAI,OAAO,SAAS,GAAG;AACnB,WAAO,IAAI,MAAM;AAAA,EACrB;AAEA,SAAO,GAAG,IAAY;AAC1B;AA8DO,SAAS,+BAEd,YAA2C,gBAAqD;AAC9F,QAAM,gBAAgB,WAAW;AACjC,SAAO,eAAe,aAAa,EAAE,WAAW,IAAI;AACxD;AASO,SAAS,6BACZ,MACA,kBAC6B;AAC7B,aAAW,iBAAiB,OAAO,KAAK,gBAAgB,GAA2B;AAC/E,UAAM,qBAAqB,iBAAiB,aAAa;AACzD,QAAI,mBAAmB,KAAK,IAAI,GAAG;AAC/B,aAAO;AAAA,QACH;AAAA,QACA,MAAM,mBAAmB,UAAU,IAAI;AAAA,MAAA;AAAA,IAE/C;AAAA,EACJ;AAEA,QAAM,IAAI,MAAM,gCAAgC;AACpD;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/v1/index.ts"],"sourcesContent":["import { type Result, ok, err, deepEquals, stableJSONStringify } from '@conduit-client/utils';\n\nimport { ArrayIsArray } from '@conduit-client/utils';\nimport type { NamedPubSubService } from '@conduit-client/service-pubsub/v1';\nimport type {\n InstrumentationAttributes,\n NamedInstrumentationService,\n} from '@conduit-client/service-instrumentation/v1';\nimport type { NamedCacheControllerService } from '@conduit-client/service-cache-control/v1';\nimport type {\n Key,\n CanonicalCacheControlMetadata,\n ReadonlyCache,\n CacheEntry,\n Cache,\n} from '@conduit-client/service-cache/v1';\n\nexport interface NormalizedLink {\n type: 'link';\n linkedKey: Key;\n}\n\ntype UnknownError = {\n type: 'unknown';\n error: Error;\n};\n\n/**\n * An error that occurs when a type tries to read from the cache, and the cache metadata does\n * not match the current type\n */\ntype IncorrectTypeError = {\n type: 'incorrectType';\n expectedType: string;\n actualType: string;\n};\n\n/**\n * An error that occurs when a type tries to read from the cache and data is missing\n */\ntype MissingDataError = {\n type: 'missingData';\n namespace: string;\n typeName: string;\n data: unknown;\n};\n\n/**\n * A union of errors that can be returned during the write process\n */\nexport type WriteErrors = Array<UnknownError>;\n\n/**\n * A union of errors that can be returned during the read process\n */\nexport type ReadErrors = Array<UnknownError | IncorrectTypeError | MissingDataError>;\n\nexport type ReadResult<Data> = Result<Data, ReadErrors>;\nexport type WriteResult<Data> = Result<Data, WriteErrors>;\n\n/**\n * A Type defines a collection of functions associated with a particular\n * data type. Types are not normalized but may contain normalized data.\n *\n * @typeParam Data TypeScript type that corresponds to the data\n * @typeParam NormalizedData TypeScript type that corresponds to the normalized data\n * @typeParam NormalizeInputData TypeScript type that corresponds to the data that the normalize method expects as input. Defaults to the same as Data\n */\nexport type TypeRepository<Data, ReadInput, WriteResponse, WriteInput> = {\n readonly namespace: string;\n readonly typeName: string;\n\n equals(x: Data, y: Data): boolean;\n\n /**\n * Normalizes data for storage.\n */\n write(cache: Cache, input: WriteInput): WriteResult<WriteResponse>;\n\n /**\n * De-normalizes a Type's data. A type could normalize into a Link, or return Data to the caller.\n * A caller must not be relying on the referenced type being normalized or not.\n * If denormalization fails, it will return undefined.\n */\n read(cache: ReadonlyCache, input: ReadInput): ReadResult<Data>;\n};\n\n/**\n * An InvalidatableType defines an invalidate function that takes a generic input,\n * and returns a promise that resolves when the invalidation is complete\n *\n * @typeParam T is another type to extend\n * @typeParam InvalidateInput is the input to run an invalidation\n */\nexport type Invalidatable<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- constraint generic positions must be `any`; `unknown` breaks conditional type matching for concrete TypeRepository instantiations\n T extends TypeRepository<any, any, any, any>,\n InvalidateInput,\n> = T & {\n /**\n *\n * @param configs Partial KeyConfigs for this Type (partial KeyConfig treats missing parts as wildcard)\n */\n invalidate(configs: InvalidateInput[]): Promise<void>;\n};\n\n/**\n * A QueryableType defines a collection of functions associated with a particular\n * data type that gets its own cache entry.\n *\n * @typeParam Data TypeScript type that corresponds to the data\n * @typeParam KeyConfig TypeScript type for the inputs needed to construct\n * a Key for the data\n * @typeParam NormalizeInputData TypeScript type that corresponds to the data that the normalize method expects as input. Defaults to the same as Data\n */\nexport type Queryable<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- constraint generic positions must be `any`; `unknown` breaks conditional type matching for concrete TypeRepository instantiations\n T extends TypeRepository<any, any, any, any>,\n QueryInput,\n> = T & {\n /**\n *\n * @param cache The cache to run the query against\n * @param query The query to run\n */\n query(cache: Cache, query: QueryInput): ReadResult<DataOf<T>>;\n};\n\n/* eslint-disable @typescript-eslint/no-explicit-any -- extractor type non-inferred generic positions must be `any`; `unknown` breaks conditional match so concrete repositories collapse to never */\nexport type DataOf<T extends TypeRepository<any, any, any, any>> =\n T extends TypeRepository<infer Data, any, any, any> ? Data : never;\nexport type ReadInputOf<T extends TypeRepository<any, any, any, any>> =\n T extends TypeRepository<any, infer ReadInput, any, any> ? ReadInput : never;\nexport type WriteResponseOf<T extends TypeRepository<any, any, any, any>> =\n T extends TypeRepository<any, any, infer WriteResponse, any> ? WriteResponse : never;\nexport type WriteResultOf<T extends TypeRepository<any, any, any, any>> = WriteResult<\n WriteResponseOf<T>\n>;\nexport type WriteInputOf<T extends TypeRepository<any, any, any, any>> =\n T extends TypeRepository<any, any, any, infer WriteInput> ? WriteInput : never;\nexport type InvalidateInputOf<T extends TypeRepository<any, any, any, any>> =\n T extends Invalidatable<TypeRepository<any, any, any, any>, infer InvalidateInput>\n ? InvalidateInput\n : never;\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n/**\n * A utility method for ensuring that a given entry in the cache matches a type based on namespace and name information\n * @param cacheEntry the cache entry to validate against\n * @param type the type to validate the cache entry against\n * @returns\n */\nexport function isCacheEntryForType(\n cacheEntry: CacheEntry<unknown>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- function parameter constraint must be `any` to accept any concrete TypeRepository; `unknown` is too restrictive\n type: TypeRepository<any, any, any, any>\n): boolean {\n return (\n cacheEntry.metadata.type.namespace === type.namespace &&\n cacheEntry.metadata.type.name === type.typeName\n );\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any -- extractor type non-inferred generic positions must be `any`; `unknown` breaks conditional match so concrete repositories collapse to never */\nexport type KeyParamsOf<T> =\n T extends IdentifiableTypeRepository<\n any,\n any,\n infer KeyParams,\n Record<string, unknown>,\n Record<string, unknown>\n >\n ? KeyParams\n : never;\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\nexport type WriteInput<Data, Extension = Record<string, unknown>> = { data: Data } & Extension;\nexport type NormalizeDataInput<\n Data,\n NormalizedData,\n Extension extends Record<string, unknown> = Record<string, unknown>,\n> = WriteInput<Data, Extension & { existingNormalizedData?: NormalizedData }>;\n\nexport type ReadInput<Extension extends Record<string, unknown> = Record<string, unknown>> = {\n normalizedData: NormalizedLink;\n} & Extension;\nexport type ReadByKeyParamsInput<KeyParams> = {\n keyParams: KeyParams;\n};\nexport type DenormalizeInput<Extension extends Record<string, unknown> = Record<string, unknown>> =\n Extension & {\n key: Key;\n };\nexport type DenormalizeDataInput<\n NormalizedData,\n Extension extends Record<string, unknown> = Record<string, unknown>,\n> = Extension & { normalizedData: NormalizedData };\n\nexport type KeyParamQuery<KeyParams, ReadInputExtension> = {\n type: 'keyParams';\n keyParams: KeyParams;\n} & ReadInputExtension;\n/* eslint-disable @typescript-eslint/no-explicit-any -- extractor type non-inferred generic positions must be `any`; `unknown` breaks conditional match so concrete repositories collapse to never */\nexport type QueryFor<T> =\n T extends Queryable<TypeRepository<any, any, any, any>, infer Query> ? Query : never;\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n/**\n * An abstract base class that implements Type, defining additional abstract properties and methods\n * for building a key for a given set of parameters, and defining the canonical cache control metadata\n * for any data written\n */\nexport abstract class IdentifiableTypeRepository<\n Data,\n NormalizedData,\n KeyParams,\n ReadInputExtension extends Record<string, unknown> = Record<string, unknown>,\n WriteInputExtension extends Record<string, unknown> = Record<string, unknown>,\n Query extends KeyParamQuery<KeyParams, ReadInputExtension> = KeyParamQuery<\n KeyParams,\n ReadInputExtension\n >,\n> implements\n Queryable<\n TypeRepository<\n Data,\n ReadInput<ReadInputExtension>,\n NormalizedLink,\n WriteInput<Data, WriteInputExtension>\n >,\n Query\n >\n{\n constructor(protected services: {}) {}\n abstract readonly cacheControl: CanonicalCacheControlMetadata;\n abstract readonly namespace: string;\n abstract readonly typeName: string;\n protected abstract denormalizeData(\n cache: ReadonlyCache,\n input: DenormalizeDataInput<NormalizedData, ReadInput<ReadInputExtension>>\n ): Result<Data, ReadErrors>;\n protected abstract normalizeData(\n cache: Cache,\n input: NormalizeDataInput<\n Data,\n NormalizedData,\n WriteInputExtension & { existingNormalizedData?: NormalizedData }\n >\n ): Result<NormalizedData, WriteErrors>;\n get cacheMetadata() {\n return {\n cacheControl: { ...this.cacheControl },\n type: { namespace: this.namespace, name: this.typeName },\n };\n }\n\n buildKey(params: KeyParams): Key {\n return `${this.namespace}::${this.typeName}(${stableJSONStringify(params)})`;\n }\n abstract buildKeyParams(input: WriteInput<Data, WriteInputExtension>): KeyParams;\n\n write(cache: Cache, input: WriteInput<Data, WriteInputExtension>): WriteResult<NormalizedLink> {\n // Identifiable types can have a key that is not the same as the input normalized data\n // so we need to build the key from the input, and then get the existing normalized data from the cache\n // and pass it to the normalizeData method. This should ALWAYS be done for identifiable types.\n const key = this.buildKey(this.buildKeyParams(input));\n const existingNormalizedData: NormalizedData | undefined = cache.get<NormalizedData>(key)\n ?.value as NormalizedData | undefined;\n const normalized = this.normalizeData(cache, { ...input, existingNormalizedData });\n if (normalized.isErr()) {\n return err(normalized.error);\n }\n\n cache.set<NormalizedData>(key, {\n value: normalized.value,\n metadata: this.cacheMetadata,\n });\n\n return ok({\n type: 'link',\n linkedKey: key,\n } as const);\n }\n\n protected validateEntry(entry: CacheEntry<unknown>): Result<undefined, ReadErrors> {\n if (!isCacheEntryForType(entry, this)) {\n return err([\n {\n type: 'incorrectType',\n expectedType: this.typeName,\n actualType: entry.metadata.type.name,\n },\n ]);\n }\n return ok(undefined);\n }\n\n query(cache: Cache, query: Query): ReadResult<Data> {\n return this.read(cache, {\n ...query,\n normalizedData: { type: 'link', linkedKey: this.buildKey(query.keyParams) },\n });\n }\n\n read(cache: ReadonlyCache, input: ReadInput<ReadInputExtension>): Result<Data, ReadErrors> {\n return this.denormalize(cache, { ...input, key: input.normalizedData.linkedKey });\n }\n\n denormalize(cache: ReadonlyCache, input: DenormalizeInput<ReadInput<ReadInputExtension>>) {\n const cacheEntry = cache.get<NormalizedData>(input.key, {\n copy: false,\n }) as CacheEntry<NormalizedData>;\n\n if (cacheEntry) {\n const validationResult = this.validateEntry(cacheEntry);\n if (validationResult.isErr()) {\n return err([...validationResult.error]);\n }\n const normalizedData = cacheEntry.value;\n return this.denormalizeData(cache, { ...input, normalizedData });\n }\n\n return err([this.buildMissingDataError()]);\n }\n\n equals(x: Data, y: Data) {\n return deepEquals(x, y);\n }\n\n buildMissingDataError(): MissingDataError {\n return {\n type: 'missingData',\n typeName: this.typeName,\n namespace: this.namespace,\n data: undefined,\n };\n }\n}\n\n/**\n * An abstract base class that extends IdentifiableType, adding the additional constraint that the\n * only data required to write to the cache is an instance of the data itself, i.e. the identity of\n * the data lives inside the data\n */\nexport abstract class SelfIdentifiableTypeRepository<\n Data,\n NormalizedData,\n KeyParams,\n ReadInputExtension extends Record<string, unknown> = Record<string, unknown>,\n WriteInputExtension extends Record<string, unknown> = Record<string, unknown>,\n> extends IdentifiableTypeRepository<\n Data,\n NormalizedData,\n KeyParams,\n ReadInputExtension,\n WriteInputExtension\n> {}\n\n/**\n * Adds flat positional keying (keySchema), keySchema-based buildKey, and invalidate/evict\n * to IdentifiableTypeRepository. Key params are supplied externally (e.g. from request\n * config) — this class makes NO claim that identity lives in the data. KeyParams must be a\n * flat object (scalars, scalar arrays, or stable-stringifiable objects). Provides\n * invalidation + key building 'for free'.\n */\nexport abstract class FlattenedKeyIdentifiableTypeRepository<\n Data,\n NormalizedData,\n KeyParams extends FlattenedKeyParams,\n ReadInputExtension extends Record<string, unknown> = Record<string, unknown>,\n WriteInputExtension extends Record<string, unknown> = Record<string, unknown>,\n >\n extends IdentifiableTypeRepository<\n Data,\n NormalizedData,\n KeyParams,\n ReadInputExtension,\n WriteInputExtension\n >\n implements\n Invalidatable<\n IdentifiableTypeRepository<\n Data,\n NormalizedData,\n KeyParams,\n ReadInputExtension,\n WriteInputExtension\n >,\n Partial<KeyParams>\n >\n{\n instrumentationAttributes: InstrumentationAttributes | undefined;\n constructor(\n protected services: NamedCacheControllerService &\n NamedPubSubService &\n Partial<NamedInstrumentationService>\n ) {\n super(services);\n }\n\n abstract readonly keySchema: string[];\n\n async invalidate(configs: Partial<KeyParams>[]): Promise<void> {\n return this.setupCacheOperation(configs, 'invalidate', 'cacheInvalidation');\n }\n\n protected collectInstrumentation(duration: number, type: 'invalidate' | 'evict') {\n if (this.services.instrumentation) {\n const meter = this.services.instrumentation.metrics.getMeter('onestore');\n const attributes = {\n ...this.instrumentationAttributes,\n namespace: this.namespace,\n typeName: this.typeName,\n };\n meter.createCounter<InstrumentationAttributes>(`type.${type}.count`).add(1, attributes);\n meter\n .createHistogram<InstrumentationAttributes>(`type.${type}.duration`)\n .record(duration, attributes);\n }\n }\n\n async evict(configs: Partial<KeyParams>[]): Promise<void> {\n return this.setupCacheOperation(configs, 'evict', 'cacheEviction');\n }\n\n private async setupCacheOperation(\n configs: Partial<KeyParams>[],\n cacheUpdateType: 'invalidate' | 'evict',\n eventType: 'cacheInvalidation' | 'cacheEviction'\n ) {\n const startTime = this.services.instrumentation\n ? this.services.instrumentation.currentTimeMs()\n : 0;\n const result = this.runCacheOperation(configs, cacheUpdateType, eventType).then(() => {\n if (this.services.instrumentation) {\n const duration = this.services.instrumentation.currentTimeMs() - startTime;\n this.collectInstrumentation(duration, cacheUpdateType);\n }\n });\n return result;\n }\n\n /**\n * Shared implementation for cache operations (invalidate/evict)\n * @param configs - Key configurations to match\n * @param cacheUpdateType - Type of cache update to perform\n * @param eventType - Type of event to publish\n */\n private async runCacheOperation(\n configs: Partial<KeyParams>[],\n cacheUpdateType: 'invalidate' | 'evict',\n eventType: 'cacheInvalidation' | 'cacheEviction'\n ): Promise<void> {\n const regex = buildRegexForNamespacedKeys(\n this.namespace,\n this.typeName,\n configs,\n this.keySchema\n );\n\n const results: Set<Key> = new Set();\n for await (const entry of this.services.cacheController.findAndModify(\n { key: { $regex: regex } },\n { type: cacheUpdateType }\n )) {\n results.add(entry);\n }\n if (results.size > 0) {\n await this.services.pubSub.publish({\n type: eventType,\n data: results,\n });\n }\n }\n\n buildKey(config: KeyParams): Key {\n return buildNamespacedTypeKey(this.namespace, this.typeName, config, this.keySchema);\n }\n}\n\n/**\n * Flat-keyed identifiable type whose identity lives inside the data itself\n * (self-identifiable). Behaviorally identical to FlattenedKeyIdentifiableTypeRepository;\n * the distinction is a semantic marker for generators that derive keyParams from data.\n */\nexport abstract class FlattenedKeySelfIdentifiableTypeRepository<\n Data,\n NormalizedData,\n KeyParams extends FlattenedKeyParams,\n ReadInputExtension extends Record<string, unknown> = Record<string, unknown>,\n WriteInputExtension extends Record<string, unknown> = Record<string, unknown>,\n> extends FlattenedKeyIdentifiableTypeRepository<\n Data,\n NormalizedData,\n KeyParams,\n ReadInputExtension,\n WriteInputExtension\n> {}\ntype ScalarKeyValue = string | number | boolean | null | undefined;\ntype FlattenedKeyParams = Record<string, ScalarKeyValue | ScalarKeyValue[] | object>;\nexport function buildNamespacedTypeKey(\n namespace: string,\n typeName: string,\n keyConfig: FlattenedKeyParams,\n keySchema: string[]\n): string {\n const keyParts = keySchema.map((key) => serializeKeyValue(keyConfig[key])).join('|');\n return `${namespace}::${typeName}(${keyParts})`;\n}\n\n// A scalar (or array of scalars) is serialized inline; any other value (object,\n// array-of-objects) is stable-stringified into a single opaque key slot so that\n// resource/wrapper keys built from arbitrary request config remain deterministic\n// and regex-matchable. Sub-object wildcarding is intentionally unsupported.\nfunction serializeKeyValue(value: unknown): string {\n if (ArrayIsArray(value)) {\n const allScalar = value.every(\n (v) => v === null || v === undefined || typeof v !== 'object'\n );\n return encodeKeySlot(allScalar ? value.join() : (stableJSONStringify(value) ?? ''));\n }\n if (value !== null && value !== undefined && typeof value === 'object') {\n return encodeKeySlot(stableJSONStringify(value) ?? '');\n }\n return encodeKeySlot(`${value}`);\n}\n\n// Slots are joined with a literal `|`, and the wildcard regex treats `|` as a slot\n// boundary (`[^|]*?` / `\\|`). A raw `|` inside a serialized value would shift those\n// boundaries, so wildcard invalidation would silently miss the entry. Percent-encode\n// `%` and `|` so a slot value can never contain a raw delimiter. The encoding is\n// injective and applied identically on the key-build and regex-build paths (both go\n// through serializeKeyValue), so equivalent configs still produce identical keys.\nfunction encodeKeySlot(serialized: string): string {\n return serialized.replace(/%/g, '%25').replace(/\\|/g, '%7C');\n}\n\nexport function buildRegexForNamespacedKeys(\n namespace: string,\n typeName: string,\n partialKeyConfigs: Array<FlattenedKeyParams>,\n keySchema: string[]\n): RegExp {\n const patterns = partialKeyConfigs.map((partial) => {\n // Build a regex pattern for a single KeyConfig\n const requiredParts = keySchema\n .map((key) => {\n if (!(key in partial)) {\n return `[^|]*?`; // Allow any value or absence of value (optional match)\n }\n const value = partial[key];\n const serialized = serializeKeyValue(value);\n return `(?:${serialized.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')})`;\n })\n .join('\\\\|'); // Ensure properties are matched in order with literal separator\n\n return `^${namespace}::${typeName}\\\\((?:${requiredParts})\\\\)$`;\n });\n\n return new RegExp(`^(?:${patterns.join('|')})$`); // Apply OR logic across separate partial configs\n}\n\nexport function extractReadWriteData<Data, Error>(\n result: Result<Data, Error[]>,\n errorCollector: Error[]\n): Data | undefined {\n if (result.isOk()) {\n return result.value;\n }\n\n errorCollector.push(...result.error);\n return undefined;\n}\n\nexport function buildReadWriteResult<Data, Errors extends WriteErrors | ReadErrors>(\n data: unknown,\n errors: Errors\n): Result<Data, Errors> {\n if (errors.length > 0) {\n return err(errors);\n }\n\n return ok(data as Data);\n}\n\n// This type is the normalized representation of union data (either a pure union, or a discriminated union)\n// This data shape will live in the cache, and contains the discriminator (i.e. an identity of what type of data this entry represents)\n// and the normalized data for that entry\nexport type UnionRepresentation<Discriminator extends string, Data> = {\n discriminator: Discriminator;\n data: Data;\n};\n\n// A utility type that represents all the information required for normalizing and\n// denormalizing types into a cache, including the discriminator value, the\n// canonical representation (Data) and the normalized representation (Normalized)\nexport type DiscriminatorMap<Discriminator extends string, Data, Normalized> = {\n [k in Discriminator]: {\n data: Data;\n normalized: Normalized;\n };\n};\n\n// A utility type for inferring the union of normalized representations\n// possible based on a given DiscriminatorType\nexport type NormalizedRepresentationOf<M extends DiscriminatorMap<string, unknown, unknown>> =\n M extends DiscriminatorMap<infer D, unknown, unknown>\n ? { [k in D]: UnionRepresentation<k, M[k]['normalized']> }[D]\n : never;\n\n// A utility type for inferring the discriminator -> denormalize function map\n// required by the `denormalizeUnionRepresentation` function\nexport type DenormalizeMapOf<M extends DiscriminatorMap<string, unknown, unknown>> =\n M extends DiscriminatorMap<infer D, unknown, unknown>\n ? { [k in D]: (normalized: M[k]['normalized']) => M[k]['data'] }\n : never;\n\n// A utility type for inferring the canonical data type union based on\n// a DiscriminatorMap type\nexport type UnionDataOf<M extends DiscriminatorMap<string, unknown, unknown>> =\n M extends DiscriminatorMap<string, infer D, unknown> ? D : never;\n\n// A utility type for inferring the discriminator string union from a\n// given discriminator map type\nexport type DiscriminatorOf<M extends DiscriminatorMap<string, unknown, unknown>> =\n M extends DiscriminatorMap<infer D, unknown, unknown> ? D : never;\n\n// A utilty type for inferring the test/normalize map type from a\n// discriminator map type to be used in the `normalizeUnionRepresentation` function\nexport type DiscriminatorNormalizeFunctionsMap<\n M extends DiscriminatorMap<string, unknown, unknown>,\n> =\n M extends DiscriminatorMap<infer D, unknown, unknown>\n ? {\n [k in D]: {\n test: (data: M[D]['data']) => boolean;\n normalize: (data: M[k]['data']) => M[k]['normalized'];\n };\n }\n : never;\n\n/**\n *\n * @param normalized The normalized data representation, including the discriminator value\n * @param denormalizeMap A map of discriminator -> denormalize functions to be used based on the datas discriminator\n * @returns\n */\nexport function denormalizeUnionRepresentation<\n M extends DiscriminatorMap<string, unknown, unknown>,\n>(normalized: NormalizedRepresentationOf<M>, denormalizeMap: DenormalizeMapOf<M>): UnionDataOf<M> {\n const discriminator = normalized.discriminator as DiscriminatorOf<M>;\n return denormalizeMap[discriminator](normalized.data) as UnionDataOf<M>;\n}\n\n/**\n *\n * @param data The canonical/denormalized data representation\n * @param normalizeTestMap A map of discriminator to test method which return a boolean indicating if the data adheres to this \"discriminator\"\n * and a normalize function to call if the data matches this discriminator\n * @returns\n */\nexport function normalizeUnionRepresentation<M extends DiscriminatorMap<string, unknown, unknown>>(\n data: UnionDataOf<M>,\n normalizeTestMap: DiscriminatorNormalizeFunctionsMap<M>\n): NormalizedRepresentationOf<M> {\n for (const discriminator of Object.keys(normalizeTestMap) as DiscriminatorOf<M>[]) {\n const discriminatorLogic = normalizeTestMap[discriminator];\n if (discriminatorLogic.test(data)) {\n return {\n discriminator,\n data: discriminatorLogic.normalize(data),\n } as unknown as NormalizedRepresentationOf<M>;\n }\n }\n\n throw new Error('No matching union member found');\n}\n"],"names":[],"mappings":";AAwJO,SAAS,oBACZ,YAEA,MACO;AACP,SACI,WAAW,SAAS,KAAK,cAAc,KAAK,aAC5C,WAAW,SAAS,KAAK,SAAS,KAAK;AAE/C;AAmDO,MAAe,2BAoBtB;AAAA,EACI,YAAsB,UAAc;AAAd,SAAA,WAAA;AAAA,EAAe;AAAA,EAgBrC,IAAI,gBAAgB;AAChB,WAAO;AAAA,MACH,cAAc,EAAE,GAAG,KAAK,aAAA;AAAA,MACxB,MAAM,EAAE,WAAW,KAAK,WAAW,MAAM,KAAK,SAAA;AAAA,IAAS;AAAA,EAE/D;AAAA,EAEA,SAAS,QAAwB;AAC7B,WAAO,GAAG,KAAK,SAAS,KAAK,KAAK,QAAQ,IAAI,oBAAoB,MAAM,CAAC;AAAA,EAC7E;AAAA,EAGA,MAAM,OAAc,OAA2E;AAI3F,UAAM,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GAAG;AAC/B,aAAO;AAAA,QACH;AAAA,QACA,MAAM,mBAAmB,UAAU,IAAI;AAAA,MAAA;AAAA,IAE/C;AAAA,EACJ;AAEA,QAAM,IAAI,MAAM,gCAAgC;AACpD;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conduit-client/type-normalization",
3
- "version": "3.23.2",
3
+ "version": "3.24.1",
4
4
  "private": false,
5
5
  "description": "Luvio Normalized Cache Control Command",
6
6
  "type": "module",
@@ -32,9 +32,9 @@
32
32
  "watch": "npm run build --watch"
33
33
  },
34
34
  "dependencies": {
35
- "@conduit-client/service-cache": "3.23.2",
36
- "@conduit-client/service-cache-control": "3.23.2",
37
- "@conduit-client/utils": "3.23.2"
35
+ "@conduit-client/service-cache": "3.24.1",
36
+ "@conduit-client/service-cache-control": "3.24.1",
37
+ "@conduit-client/utils": "3.24.1"
38
38
  },
39
39
  "volta": {
40
40
  "extends": "../../../package.json"