4
4
* @namespace operation
5
5
*/
6
6
7
- export interface CreateOperation < TEntityType > {
7
+ import type { DefaultEntityTypeMap } from "./types.js" ;
8
+
9
+ export interface CreateOperation < TEntityType = keyof DefaultEntityTypeMap > {
8
10
action : "create" ;
9
11
entity_type : TEntityType ;
10
12
entity_data : any ;
@@ -15,15 +17,17 @@ export interface QueryOperation {
15
17
expression : string ;
16
18
}
17
19
18
- export interface SearchOperationOptions < TEntityType > {
20
+ export interface SearchOperationOptions <
21
+ TEntityType = keyof DefaultEntityTypeMap ,
22
+ > {
19
23
expression ?: string ;
20
24
entityType ?: TEntityType ;
21
25
terms ?: string [ ] ;
22
26
contextId ?: string ;
23
27
objectTypeIds ?: string [ ] ;
24
28
}
25
29
26
- export interface SearchOperation < TEntityType > {
30
+ export interface SearchOperation < TEntityType = keyof DefaultEntityTypeMap > {
27
31
action : "search" ;
28
32
expression ?: string ;
29
33
entity_type ?: TEntityType ;
@@ -32,14 +36,14 @@ export interface SearchOperation<TEntityType> {
32
36
object_type_ids ?: string [ ] ;
33
37
}
34
38
35
- export interface UpdateOperation < TEntityType > {
39
+ export interface UpdateOperation < TEntityType = keyof DefaultEntityTypeMap > {
36
40
action : "update" ;
37
41
entity_type : TEntityType ;
38
42
entity_key : string [ ] | string ;
39
43
entity_data : any ;
40
44
}
41
45
42
- export interface DeleteOperation < TEntityType > {
46
+ export interface DeleteOperation < TEntityType = keyof DefaultEntityTypeMap > {
43
47
action : "delete" ;
44
48
entity_type : TEntityType ;
45
49
entity_key : string [ ] | string ;
@@ -61,7 +65,7 @@ export interface GetUploadMetadataOperation {
61
65
component_id : string ;
62
66
}
63
67
64
- export type Operation < TEntityType > =
68
+ export type Operation < TEntityType = keyof DefaultEntityTypeMap > =
65
69
| CreateOperation < TEntityType >
66
70
| QueryOperation
67
71
| SearchOperation < TEntityType >
@@ -81,7 +85,7 @@ export type Operation<TEntityType> =
81
85
* @param {Object } data Entity data to use for creation
82
86
* @return {Object } API operation
83
87
*/
84
- export function create < TEntityType > (
88
+ export function create < TEntityType = keyof DefaultEntityTypeMap > (
85
89
type : TEntityType ,
86
90
data : any ,
87
91
) : CreateOperation < TEntityType > {
@@ -112,7 +116,7 @@ export function query(expression: string): QueryOperation {
112
116
* @param {string } expression API query expression
113
117
* @return {Object } API operation
114
118
*/
115
- export function search < TEntityType > ( {
119
+ export function search < TEntityType = keyof DefaultEntityTypeMap > ( {
116
120
expression,
117
121
entityType,
118
122
terms,
@@ -139,7 +143,7 @@ export function search<TEntityType>({
139
143
* @param {Object } data values to update
140
144
* @return {Object } API operation
141
145
*/
142
- export function update < TEntityType > (
146
+ export function update < TEntityType = keyof DefaultEntityTypeMap > (
143
147
type : TEntityType ,
144
148
keys : string [ ] | string ,
145
149
data : any ,
@@ -161,7 +165,7 @@ export function update<TEntityType>(
161
165
* @param {Array } keys Identifying keys, typically [<entity id>]
162
166
* @return {Object } API operation
163
167
*/
164
- function deleteOperation < TEntityType > (
168
+ function deleteOperation < TEntityType = keyof DefaultEntityTypeMap > (
165
169
type : TEntityType ,
166
170
keys : string [ ] | string ,
167
171
) : DeleteOperation < TEntityType > {
0 commit comments