electrodb 1.10.1 → 1.10.2
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/index.d.ts +1691 -3
- package/package.json +1 -1
- package/src/entity.d.ts +0 -94
- package/src/entity.test-d.ts +0 -110
- package/src/service.d.ts +0 -17
- package/src/types/client.ts +0 -15
- package/src/types/collections.ts +0 -243
- package/src/types/events.ts +0 -47
- package/src/types/index.ts +0 -72
- package/src/types/model.ts +0 -132
- package/src/types/options.ts +0 -81
- package/src/types/schema.test-d.ts +0 -2507
- package/src/types/schema.ts +0 -1016
- package/src/types/tests.test-d.ts +0 -3
- package/src/types/types.test-d.ts +0 -142
- package/src/types/where.test-d.ts +0 -1939
- package/src/types/where.ts +0 -94
package/src/types/model.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GoRecord,
|
|
3
|
-
ParamRecord,
|
|
4
|
-
QueryOptions,
|
|
5
|
-
PageRecord,
|
|
6
|
-
PutQueryOptions,
|
|
7
|
-
UpdateQueryOptions,
|
|
8
|
-
UpdateQueryParams,
|
|
9
|
-
DeleteQueryOptions,
|
|
10
|
-
BulkOptions,
|
|
11
|
-
BatchGoRecord
|
|
12
|
-
} from './options';
|
|
13
|
-
import {
|
|
14
|
-
WhereClause,
|
|
15
|
-
DataUpdateMethod,
|
|
16
|
-
} from './where';
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
AllTableIndexCompositeAttributes,
|
|
20
|
-
IndexCompositeAttributes,
|
|
21
|
-
ResponseItem,
|
|
22
|
-
IndexWithSortKey,
|
|
23
|
-
IndexSKAttributes,
|
|
24
|
-
Item,
|
|
25
|
-
Schema,
|
|
26
|
-
SetItem,
|
|
27
|
-
UpdateData,
|
|
28
|
-
AddItem,
|
|
29
|
-
SubtractItem,
|
|
30
|
-
AppendItem,
|
|
31
|
-
DeleteItem,
|
|
32
|
-
} from './schema';
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export interface RecordsActionOptions<A extends string,
|
|
36
|
-
F extends string, C extends string, S extends Schema<A,F,C>, Items, IndexCompositeAttributes> {
|
|
37
|
-
go: GoRecord<Items>;
|
|
38
|
-
params: ParamRecord;
|
|
39
|
-
page: PageRecord<Items,IndexCompositeAttributes>;
|
|
40
|
-
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,RecordsActionOptions<A,F,C,S,Items,IndexCompositeAttributes>>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface SingleRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
|
|
44
|
-
go: GoRecord<ResponseType, QueryOptions>;
|
|
45
|
-
params: ParamRecord<QueryOptions>;
|
|
46
|
-
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,SingleRecordOperationOptions<A,F,C,S,ResponseType>>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface PutRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
|
|
50
|
-
go: GoRecord<ResponseType, PutQueryOptions>;
|
|
51
|
-
params: ParamRecord<PutQueryOptions>;
|
|
52
|
-
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,PutRecordOperationOptions<A,F,C,S,ResponseType>>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface UpdateRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
|
|
56
|
-
go: GoRecord<ResponseType, UpdateQueryOptions>;
|
|
57
|
-
params: ParamRecord<UpdateQueryParams>;
|
|
58
|
-
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,PutRecordOperationOptions<A,F,C,S,ResponseType>>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface DeleteRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
|
|
62
|
-
go: GoRecord<ResponseType, DeleteQueryOptions>;
|
|
63
|
-
params: ParamRecord<DeleteQueryOptions>;
|
|
64
|
-
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,DeleteRecordOperationOptions<A,F,C,S,ResponseType>>;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface BulkRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType, AlternateResponseType> {
|
|
68
|
-
go: BatchGoRecord<ResponseType, AlternateResponseType>;
|
|
69
|
-
params: ParamRecord<BulkOptions>;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface SetRecordActionOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, SetAttr,IndexCompositeAttributes,TableItem> {
|
|
73
|
-
go: GoRecord<Partial<TableItem>, UpdateQueryOptions>;
|
|
74
|
-
params: ParamRecord<UpdateQueryParams>;
|
|
75
|
-
set: SetRecord<A,F,C,S, SetItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
|
|
76
|
-
remove: SetRecord<A,F,C,S, Array<keyof SetItem<A,F,C,S>>,IndexCompositeAttributes,TableItem>;
|
|
77
|
-
add: SetRecord<A,F,C,S, AddItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
|
|
78
|
-
subtract: SetRecord<A,F,C,S, SubtractItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
|
|
79
|
-
append: SetRecord<A,F,C,S, AppendItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
|
|
80
|
-
delete: SetRecord<A,F,C,S, DeleteItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
|
|
81
|
-
data: DataUpdateMethodRecord<A,F,C,S, Item<A,F,C,S,S["attributes"]>,IndexCompositeAttributes,TableItem>;
|
|
82
|
-
where: WhereClause<A,F,C,S, Item<A,F,C,S,S["attributes"]>,SetRecordActionOptions<A,F,C,S,SetAttr,IndexCompositeAttributes,TableItem>>;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export type SetRecord<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, SetAttr, IndexCompositeAttributes, TableItem> = (properties: SetAttr) => SetRecordActionOptions<A,F,C,S, SetAttr, IndexCompositeAttributes, TableItem>;
|
|
86
|
-
export type RemoveRecord<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, RemoveAttr, IndexCompositeAttributes, TableItem> = (properties: RemoveAttr) => SetRecordActionOptions<A,F,C,S, RemoveAttr, IndexCompositeAttributes, TableItem>;
|
|
87
|
-
|
|
88
|
-
export type DataUpdateMethodRecord<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, SetAttr, IndexCompositeAttributes, TableItem> =
|
|
89
|
-
DataUpdateMethod<A,F,C,S, UpdateData<A,F,C,S>, SetRecordActionOptions<A,F,C,S, SetAttr, IndexCompositeAttributes, TableItem>>
|
|
90
|
-
|
|
91
|
-
interface QueryOperations<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, CompositeAttributes, TableItem, IndexCompositeAttributes> {
|
|
92
|
-
between: (skCompositeAttributesStart: CompositeAttributes, skCompositeAttributesEnd: CompositeAttributes) => RecordsActionOptions<A,F,C,S, Array<TableItem>,IndexCompositeAttributes>;
|
|
93
|
-
gt: (skCompositeAttributes: CompositeAttributes) => RecordsActionOptions<A,F,C,S, Array<TableItem>,IndexCompositeAttributes>;
|
|
94
|
-
gte: (skCompositeAttributes: CompositeAttributes) => RecordsActionOptions<A,F,C,S, Array<TableItem>,IndexCompositeAttributes>;
|
|
95
|
-
lt: (skCompositeAttributes: CompositeAttributes) => RecordsActionOptions<A,F,C,S, Array<TableItem>,IndexCompositeAttributes>;
|
|
96
|
-
lte: (skCompositeAttributes: CompositeAttributes) => RecordsActionOptions<A,F,C,S, Array<TableItem>,IndexCompositeAttributes>;
|
|
97
|
-
begins: (skCompositeAttributes: CompositeAttributes) => RecordsActionOptions<A,F,C,S, Array<TableItem>,IndexCompositeAttributes>;
|
|
98
|
-
go: GoRecord<Array<TableItem>>;
|
|
99
|
-
params: ParamRecord;
|
|
100
|
-
page: PageRecord<Array<TableItem>,IndexCompositeAttributes>;
|
|
101
|
-
where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,RecordsActionOptions<A,F,C,S,Array<TableItem>,IndexCompositeAttributes>>
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export type Queries<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
|
|
105
|
-
[I in keyof S["indexes"]]: <CompositeAttributes extends IndexCompositeAttributes<A,F,C,S,I>>(composite: CompositeAttributes) =>
|
|
106
|
-
IndexSKAttributes<A,F,C,S,I> extends infer SK
|
|
107
|
-
// If there is no SK, dont show query operations (when an empty array is provided)
|
|
108
|
-
? [keyof SK] extends [never]
|
|
109
|
-
? RecordsActionOptions<A,F,C,S, ResponseItem<A,F,C,S>[], AllTableIndexCompositeAttributes<A,F,C,S> & Required<CompositeAttributes>>
|
|
110
|
-
// If there is no SK, dont show query operations (When no PK is specified)
|
|
111
|
-
: S["indexes"][I] extends IndexWithSortKey
|
|
112
|
-
? QueryOperations<
|
|
113
|
-
A,F,C,S,
|
|
114
|
-
// Omit the composite attributes already provided
|
|
115
|
-
Omit<Partial<IndexSKAttributes<A,F,C,S,I>>, keyof CompositeAttributes>,
|
|
116
|
-
ResponseItem<A,F,C,S>,
|
|
117
|
-
AllTableIndexCompositeAttributes<A,F,C,S> & Required<CompositeAttributes> & SK
|
|
118
|
-
>
|
|
119
|
-
: RecordsActionOptions<A,F,C,S, ResponseItem<A,F,C,S>[], AllTableIndexCompositeAttributes<A,F,C,S> & Required<CompositeAttributes> & SK>
|
|
120
|
-
: never
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export type ParseSingleInput = {
|
|
124
|
-
Item?: {[key: string]: any}
|
|
125
|
-
} | {
|
|
126
|
-
Attributes?: {[key: string]: any}
|
|
127
|
-
} | null;
|
|
128
|
-
|
|
129
|
-
export type ParseMultiInput = {
|
|
130
|
-
Items?: {[key: string]: any}[]
|
|
131
|
-
}
|
|
132
|
-
|
package/src/types/options.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { ElectroEventListener } from './events';
|
|
2
|
-
|
|
3
|
-
export type ReturnValues = "default" | "none" | 'all_old' | 'updated_old' | 'all_new' | 'updated_new';
|
|
4
|
-
|
|
5
|
-
export interface QueryOptions {
|
|
6
|
-
raw?: boolean;
|
|
7
|
-
table?: string;
|
|
8
|
-
limit?: number;
|
|
9
|
-
params?: object;
|
|
10
|
-
includeKeys?: boolean;
|
|
11
|
-
originalErr?: boolean;
|
|
12
|
-
ignoreOwnership?: boolean;
|
|
13
|
-
pages?: number;
|
|
14
|
-
listeners?: Array<ElectroEventListener>;
|
|
15
|
-
logger?: ElectroEventListener;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// subset of QueryOptions
|
|
19
|
-
export interface ParseOptions {
|
|
20
|
-
ignoreOwnership?: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface UpdateQueryOptions extends QueryOptions {
|
|
24
|
-
response?: "default" | "none" | 'all_old' | 'updated_old' | 'all_new' | 'updated_new';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface UpdateQueryParams {
|
|
28
|
-
response?: "default" | "none" | 'all_old' | 'updated_old' | 'all_new' | 'updated_new';
|
|
29
|
-
table?: string;
|
|
30
|
-
params?: object;
|
|
31
|
-
originalErr?: boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface DeleteQueryOptions extends QueryOptions {
|
|
35
|
-
response?: "default" | "none" | 'all_old';
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface PutQueryOptions extends QueryOptions {
|
|
39
|
-
response?: "default" | "none" | 'all_old';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface ParamOptions {
|
|
43
|
-
params?: object;
|
|
44
|
-
table?: string;
|
|
45
|
-
limit?: number;
|
|
46
|
-
response?: "default" | "none" | 'all_old' | 'updated_old' | 'all_new' | 'updated_new';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface PaginationOptions extends QueryOptions {
|
|
50
|
-
pager?: "raw" | "item" | "named";
|
|
51
|
-
limit?: number;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface BulkOptions extends QueryOptions {
|
|
55
|
-
unprocessed?: "raw" | "item";
|
|
56
|
-
concurrency?: number;
|
|
57
|
-
preserveBatchOrder?: boolean;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export type OptionalDefaultEntityIdentifiers = {
|
|
61
|
-
__edb_e__?: string;
|
|
62
|
-
__edb_v__?: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export type GoRecord<ResponseType, Options = QueryOptions> = <T = ResponseType>(options?: Options) => Promise<T>;
|
|
66
|
-
|
|
67
|
-
export type BatchGoRecord<ResponseType, AlternateResponseType> = <O extends BulkOptions>(options?: O) =>
|
|
68
|
-
O extends infer Options
|
|
69
|
-
? 'preserveBatchOrder' extends keyof Options
|
|
70
|
-
? Options['preserveBatchOrder'] extends true
|
|
71
|
-
? Promise<AlternateResponseType>
|
|
72
|
-
: Promise<ResponseType>
|
|
73
|
-
: Promise<ResponseType>
|
|
74
|
-
: never
|
|
75
|
-
|
|
76
|
-
export type PageRecord<ResponseType, CompositeAttributes> = (page?: (CompositeAttributes & OptionalDefaultEntityIdentifiers) | null, options?: PaginationOptions) => Promise<[
|
|
77
|
-
(CompositeAttributes & OptionalDefaultEntityIdentifiers) | null,
|
|
78
|
-
ResponseType
|
|
79
|
-
]>;
|
|
80
|
-
|
|
81
|
-
export type ParamRecord<Options = ParamOptions> = <P>(options?: Options) => P;
|