@gasboost/replica 0.1.0 → 0.1.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.
|
@@ -3,6 +3,12 @@ import type { z } from "zod";
|
|
|
3
3
|
export type ReplicaTableDefinition<N extends string = string, S extends z.ZodObject<any> = z.ZodObject<any>, PK extends Extract<keyof z.infer<S>, string> = Extract<keyof z.infer<S>, string>> = TableDefinition<N, S> & {
|
|
4
4
|
readonly primaryKey: PK;
|
|
5
5
|
};
|
|
6
|
+
export type ValidReplicaTables<T extends readonly ReplicaTableDefinition[]> = {
|
|
7
|
+
readonly [K in keyof T]: T[K] extends {
|
|
8
|
+
readonly schema: infer S extends z.ZodObject<any>;
|
|
9
|
+
readonly primaryKey: infer PK;
|
|
10
|
+
} ? PK extends Extract<keyof z.infer<S>, string> ? T[K] : never : never;
|
|
11
|
+
};
|
|
6
12
|
export type ReplicaTableByName<T extends readonly ReplicaTableDefinition[], N extends T[number]["name"]> = Extract<T[number], {
|
|
7
13
|
name: N;
|
|
8
14
|
}>;
|
package/dist/createReplica.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Replica } from "./Replica";
|
|
2
|
-
import type { ReplicaTableDefinition } from "./ReplicaTableDefinition";
|
|
3
|
-
export declare function createReplica<T extends readonly ReplicaTableDefinition[]>({ name, tables, }: {
|
|
2
|
+
import type { ReplicaTableDefinition, ValidReplicaTables } from "./ReplicaTableDefinition";
|
|
3
|
+
export declare function createReplica<const T extends readonly ReplicaTableDefinition[]>({ name, tables, }: {
|
|
4
4
|
name: string;
|
|
5
|
-
tables: T
|
|
5
|
+
tables: T & ValidReplicaTables<T>;
|
|
6
6
|
}): Replica<T>;
|