dinah 0.5.0 → 0.7.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/dist/cdk.d.cts +1 -1
- package/dist/cdk.d.mts +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +398 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +398 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/table-C1kr1mV7.d.mts +145 -0
- package/dist/table-C1kr1mV7.d.mts.map +1 -0
- package/dist/table-DBPBsigX.d.cts +145 -0
- package/dist/table-DBPBsigX.d.cts.map +1 -0
- package/package.json +1 -1
- package/dist/table-BqqpOAwS.d.cts +0 -513
- package/dist/table-BqqpOAwS.d.cts.map +0 -1
- package/dist/table-DYFm4ZYg.d.mts +0 -513
- package/dist/table-DYFm4ZYg.d.mts.map +0 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Static, TSchema } from "typebox";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
type Obj<T = any> = Record<string, T>;
|
|
5
|
+
type AllKeys<T> = Extract<T extends any ? keyof T : never, string>;
|
|
6
|
+
type PartialSome<T, K extends string | number | symbol> = Omit<T, K> & Partial<Pick<T, Extract<K, keyof T>>>;
|
|
7
|
+
type DistPartialSome<T, K extends string | number | symbol> = T extends unknown ? PartialSome<T, K> : never;
|
|
8
|
+
type ExtractTableDef<T> = T extends Table<any, infer Def> ? Def : never;
|
|
9
|
+
type ExtractTableSchema<T> = T extends Table<infer Schema, any> ? unknown extends Static<Schema> ? any : Static<Schema> : never;
|
|
10
|
+
type ExtractKey<S, D> = D extends {
|
|
11
|
+
partitionKey: infer PK;
|
|
12
|
+
sortKey?: infer SK;
|
|
13
|
+
} ? PK extends keyof S ? SK extends keyof S ? Pick<S, PK | SK> : Pick<S, PK> : never : never;
|
|
14
|
+
type Func = (...args: any[]) => any;
|
|
15
|
+
type ExtractKeys<T, O> = { [K in AllKeys<T>]: PickTypeOf<T, K, O> extends never ? never : {
|
|
16
|
+
k: K;
|
|
17
|
+
v: PickTypeOf<T, K, O>;
|
|
18
|
+
} }[AllKeys<T>]["k"];
|
|
19
|
+
type PickTypeOf<T, K extends AllKeys<T>, O> = T extends { [k in K]?: O } ? T[K] : never;
|
|
20
|
+
type ToUnion<T> = T extends readonly (infer U)[] ? U : T;
|
|
21
|
+
/** Operators valid in a KeyConditionExpression (sort key). */
|
|
22
|
+
type SortKeyOps<V> = {
|
|
23
|
+
$eq?: V;
|
|
24
|
+
$gt?: V;
|
|
25
|
+
$gte?: V;
|
|
26
|
+
$lt?: V;
|
|
27
|
+
$lte?: V;
|
|
28
|
+
} & ([V] extends [string] ? {
|
|
29
|
+
$between?: [string, string];
|
|
30
|
+
$prefix?: string;
|
|
31
|
+
} : [V] extends [number] ? {
|
|
32
|
+
$between?: [number, number];
|
|
33
|
+
} : {});
|
|
34
|
+
type SortKeyFieldCondition<V> = V | SortKeyOps<V>;
|
|
35
|
+
type SortKeyPick<Schema, Keys extends keyof Schema> = { [K in Keys]: SortKeyFieldCondition<Schema[K]> };
|
|
36
|
+
type SortKeyQuery<Schema, SK> = SK extends readonly [infer A extends string & keyof Schema, infer B extends string & keyof Schema, infer C extends string & keyof Schema, infer D extends string & keyof Schema] ? {} | SortKeyPick<Schema, A> | SortKeyPick<Schema, A | B> | SortKeyPick<Schema, A | B | C> | SortKeyPick<Schema, A | B | C | D> : SK extends readonly [infer A extends string & keyof Schema, infer B extends string & keyof Schema, infer C extends string & keyof Schema] ? {} | SortKeyPick<Schema, A> | SortKeyPick<Schema, A | B> | SortKeyPick<Schema, A | B | C> : SK extends readonly [infer A extends string & keyof Schema, infer B extends string & keyof Schema] ? {} | SortKeyPick<Schema, A> | SortKeyPick<Schema, A | B> : SK extends readonly [infer A extends string & keyof Schema] ? {} | SortKeyPick<Schema, A> : SK extends string & keyof Schema ? { [K in SK]?: SortKeyFieldCondition<Schema[K]> } : {};
|
|
37
|
+
type ValidPrimaryKeys<T> = { [K in keyof T]: T[K] extends string | number ? K : never }[keyof T];
|
|
38
|
+
type ValidTtlKeys<T> = ExtractKeys<T, number>;
|
|
39
|
+
type ValidGsiKeys<T> = ExtractKeys<T, string | number>;
|
|
40
|
+
/** Extract the type of field K across all members of union T */
|
|
41
|
+
type ValueOfUnion<T, K extends string> = T extends unknown ? K extends keyof T ? T[K] : never : never;
|
|
42
|
+
/** Comparison operators valid for ordered types (string, number) */
|
|
43
|
+
interface ComparatorOps<V> {
|
|
44
|
+
$eq?: V;
|
|
45
|
+
$ne?: V;
|
|
46
|
+
$gt?: V;
|
|
47
|
+
$gte?: V;
|
|
48
|
+
$lt?: V;
|
|
49
|
+
$lte?: V;
|
|
50
|
+
}
|
|
51
|
+
/** String-specific operators */
|
|
52
|
+
interface StringOps {
|
|
53
|
+
$prefix?: string;
|
|
54
|
+
$includes?: string;
|
|
55
|
+
$between?: [string, string];
|
|
56
|
+
}
|
|
57
|
+
/** Number-specific operators */
|
|
58
|
+
interface NumberOps {
|
|
59
|
+
$between?: [number, number];
|
|
60
|
+
}
|
|
61
|
+
/** Operators valid for any attribute type */
|
|
62
|
+
interface CommonOps<V> {
|
|
63
|
+
$eq?: V;
|
|
64
|
+
$ne?: V;
|
|
65
|
+
$exists?: boolean;
|
|
66
|
+
$type?: "S" | "SS" | "N" | "NS" | "B" | "BS" | "BOOL" | "NULL" | "L" | "M";
|
|
67
|
+
$in?: V[];
|
|
68
|
+
$nin?: V[];
|
|
69
|
+
}
|
|
70
|
+
/** Size operator — accepts a number or a comparator on number */
|
|
71
|
+
interface SizeOps {
|
|
72
|
+
$size?: number | ComparatorOps<number>;
|
|
73
|
+
}
|
|
74
|
+
/** Path reference for cross-attribute comparisons */
|
|
75
|
+
interface PathRef {
|
|
76
|
+
$path: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Map a field's value type to the set of valid operators.
|
|
80
|
+
* Uses `[V] extends [X]` (wrapped) to prevent distribution over unions.
|
|
81
|
+
*/
|
|
82
|
+
type FieldOps<V> = [V] extends [string] ? CommonOps<V | PathRef> & ComparatorOps<V | PathRef> & StringOps & SizeOps : [V] extends [number] ? CommonOps<V | PathRef> & ComparatorOps<V | PathRef> & NumberOps & SizeOps : [V] extends [boolean] ? CommonOps<V | PathRef> : [V] extends [any[]] ? CommonOps<V | PathRef> & {
|
|
83
|
+
$includes?: V[number];
|
|
84
|
+
} & SizeOps : CommonOps<V | PathRef> & SizeOps;
|
|
85
|
+
/**
|
|
86
|
+
* A single field condition: either a direct value (shorthand for $eq)
|
|
87
|
+
* or an operator object.
|
|
88
|
+
*/
|
|
89
|
+
type FieldCondition<T> = { [K in AllKeys<T>]?: ValueOfUnion<T, K> | FieldOps<ValueOfUnion<T, K>> };
|
|
90
|
+
/**
|
|
91
|
+
* Full condition expression with compound operators.
|
|
92
|
+
*/
|
|
93
|
+
type Condition<T> = FieldCondition<T> & {
|
|
94
|
+
$and?: Condition<T>[];
|
|
95
|
+
$or?: Condition<T>[];
|
|
96
|
+
$not?: Condition<T>;
|
|
97
|
+
};
|
|
98
|
+
/** Key condition expression — only KeyConditionExpression-valid operators, no compound operators. */
|
|
99
|
+
type KeyCondition<T> = { [K in AllKeys<T>]?: ValueOfUnion<T, K> | SortKeyOps<ValueOfUnion<T, K>> };
|
|
100
|
+
interface Gsi<T> {
|
|
101
|
+
readonly partitionKey: ValidGsiKeys<T> | readonly ValidGsiKeys<T>[];
|
|
102
|
+
readonly sortKey?: ValidGsiKeys<T> | readonly ValidGsiKeys<T>[];
|
|
103
|
+
readonly projection?: "ALL" | "KEYS_ONLY" | readonly AllKeys<T>[];
|
|
104
|
+
}
|
|
105
|
+
interface TableDef<T = any> {
|
|
106
|
+
readonly name: string;
|
|
107
|
+
readonly partitionKey: ValidPrimaryKeys<T>;
|
|
108
|
+
readonly sortKey?: ValidPrimaryKeys<T>;
|
|
109
|
+
readonly gsis?: Readonly<Record<string, Gsi<T>>>;
|
|
110
|
+
readonly ttlAttribute?: ValidTtlKeys<T>;
|
|
111
|
+
readonly billingMode?: "PAY_PER_REQUEST" | "PROVISIONED";
|
|
112
|
+
readonly stream?: "KEYS_ONLY" | "NEW_IMAGE" | "OLD_IMAGE" | "NEW_AND_OLD_IMAGES";
|
|
113
|
+
}
|
|
114
|
+
interface TableKey {
|
|
115
|
+
name: string;
|
|
116
|
+
type: "S" | "N";
|
|
117
|
+
}
|
|
118
|
+
interface TableGsi {
|
|
119
|
+
indexName: string;
|
|
120
|
+
projectionType: "KEYS_ONLY" | "ALL" | "INCLUDE";
|
|
121
|
+
partitionKey: TableKey;
|
|
122
|
+
sortKey?: TableKey;
|
|
123
|
+
nonKeyAttributes?: string[];
|
|
124
|
+
}
|
|
125
|
+
interface TableDesc {
|
|
126
|
+
tableName: string;
|
|
127
|
+
billingMode: "PAY_PER_REQUEST" | "PROVISIONED";
|
|
128
|
+
partitionKey: TableKey;
|
|
129
|
+
sortKey?: TableKey;
|
|
130
|
+
ttlAttribute?: string;
|
|
131
|
+
gsis?: TableGsi[];
|
|
132
|
+
stream?: "KEYS_ONLY" | "NEW_IMAGE" | "OLD_IMAGE" | "NEW_AND_OLD_IMAGES";
|
|
133
|
+
}
|
|
134
|
+
type ResolvedAttrType = ("S" | "N" | undefined)[];
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/table.d.ts
|
|
137
|
+
type SchemaStatic<Schema extends TSchema> = unknown extends Static<Schema> ? any : Static<Schema>;
|
|
138
|
+
declare class Table<Schema extends TSchema = TSchema, const Def extends TableDef<SchemaStatic<Schema>> = TableDef<SchemaStatic<Schema>>> {
|
|
139
|
+
readonly schema: Schema;
|
|
140
|
+
readonly def: Def;
|
|
141
|
+
constructor(schema: Schema, def: Def);
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { ValidGsiKeys as C, ToUnion as S, ValidTtlKeys as T, SortKeyQuery as _, ExtractKey as a, TableGsi as b, ExtractTableSchema as c, KeyCondition as d, Obj as f, SortKeyOps as g, ResolvedAttrType as h, DistPartialSome as i, Func as l, PickTypeOf as m, AllKeys as n, ExtractKeys as o, PartialSome as p, Condition as r, ExtractTableDef as s, Table as t, Gsi as u, TableDef as v, ValidPrimaryKeys as w, TableKey as x, TableDesc as y };
|
|
145
|
+
//# sourceMappingURL=table-DBPBsigX.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-DBPBsigX.d.cts","names":[],"sources":["../src/types.ts","../src/table.ts"],"mappings":";;;KAGY,GAAA,YAAe,MAAA,SAAe,CAAA;AAAA,KAM9B,OAAA,MAAa,OAAA,CAAQ,CAAA,qBAAsB,CAAA;AAAA,KAE3C,WAAA,0CAAqD,IAAA,CAAK,CAAA,EAAG,CAAA,IACvE,OAAA,CAAQ,IAAA,CAAK,CAAA,EAAG,OAAA,CAAQ,CAAA,QAAS,CAAA;AAAA,KAEvB,eAAA,0CAAyD,CAAA,mBACjE,WAAA,CAAY,CAAA,EAAG,CAAA;AAAA,KAGP,eAAA,MAAqB,CAAA,SAAU,KAAA,mBAAwB,GAAA;AAAA,KACvD,kBAAA,MACV,CAAA,SAAU,KAAA,sCACU,MAAA,CAAO,MAAA,UAErB,MAAA,CAAO,MAAA;AAAA,KAGH,UAAA,SAAmB,CAAA;EAAY,YAAA;EAAwB,OAAA;AAAA,IAC/D,EAAA,eAAiB,CAAA,GACf,EAAA,eAAiB,CAAA,GACf,IAAA,CAAK,CAAA,EAAG,EAAA,GAAK,EAAA,IACb,IAAA,CAAK,CAAA,EAAG,EAAA;AAAA,KAIJ,IAAA,OAAW,IAAA;AAAA,KAIX,WAAA,iBACJ,OAAA,CAAQ,CAAA,IAAK,UAAA,CAAW,CAAA,EAAG,CAAA,EAAG,CAAA;EAA6B,CAAA,EAAG,CAAA;EAAG,CAAA,EAAG,UAAA,CAAW,CAAA,EAAG,CAAA,EAAG,CAAA;AAAA,IAC3F,OAAA,CAAQ,CAAA;AAAA,K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