import { PartitionKey } from "./keys" import { Model } from "./Model" import { ExtractFields } from "./types" export class Partition, U extends Model> { private modelTags: string[] constructor(private models: [T, ...U[]]) { this.modelTags = models.map((_) => _.modelTag) } /** Since we assume that all this.models[] live under the same partition * we can generate a valid partition key by calling models[0].partitionKey * (or any models[i].key - but models[0] is convenient) */ key(params: Parameters[0]): PartitionKey> { const { partitionKeyName, partitionKey } = this.models[0].partitionKey(params) return new PartitionKey>(partitionKeyName, partitionKey, this.modelTags) } }