@squonk/data-manager-client 1.2.3 → 1.2.4-rc.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/accounting/accounting.cjs +31 -13
- package/accounting/accounting.cjs.map +1 -1
- package/accounting/accounting.d.cts +77 -0
- package/accounting/accounting.d.ts +10 -1
- package/accounting/accounting.js +29 -11
- package/accounting/accounting.js.map +1 -1
- package/admin/admin.cjs +67 -27
- package/admin/admin.cjs.map +1 -1
- package/admin/admin.d.cts +324 -0
- package/admin/admin.d.ts +55 -22
- package/admin/admin.js +57 -17
- package/admin/admin.js.map +1 -1
- package/application/application.cjs +23 -13
- package/application/application.cjs.map +1 -1
- package/application/application.d.cts +57 -0
- package/application/application.d.ts +7 -1
- package/application/application.js +22 -12
- package/application/application.js.map +1 -1
- package/{chunk-UZTHSGDT.cjs → chunk-J22A7LHX.cjs} +1 -1
- package/chunk-J22A7LHX.cjs.map +1 -0
- package/{chunk-3RNIDX7T.js → chunk-UKA7G3OB.js} +1 -1
- package/{chunk-3RNIDX7T.js.map → chunk-UKA7G3OB.js.map} +1 -1
- package/configuration/configuration.cjs +13 -7
- package/configuration/configuration.cjs.map +1 -1
- package/configuration/configuration.d.cts +29 -0
- package/configuration/configuration.d.ts +4 -1
- package/configuration/configuration.js +13 -7
- package/configuration/configuration.js.map +1 -1
- package/{custom-instance-50c9dd5d.d.ts → custom-instance-3d66fe97.d.ts} +826 -826
- package/dataset/dataset.cjs +71 -72
- package/dataset/dataset.cjs.map +1 -1
- package/dataset/dataset.d.cts +315 -0
- package/dataset/dataset.d.ts +46 -16
- package/dataset/dataset.js +62 -63
- package/dataset/dataset.js.map +1 -1
- package/exchange-rate/exchange-rate.cjs +43 -32
- package/exchange-rate/exchange-rate.cjs.map +1 -1
- package/exchange-rate/exchange-rate.d.cts +180 -0
- package/exchange-rate/exchange-rate.d.ts +25 -7
- package/exchange-rate/exchange-rate.js +38 -27
- package/exchange-rate/exchange-rate.js.map +1 -1
- package/file/file.cjs +38 -22
- package/file/file.cjs.map +1 -1
- package/file/file.d.cts +154 -0
- package/file/file.d.ts +25 -10
- package/file/file.js +34 -18
- package/file/file.js.map +1 -1
- package/index.cjs +10 -10
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -0
- package/index.d.ts +1 -1
- package/index.js +9 -9
- package/index.js.map +1 -1
- package/instance/instance.cjs +47 -37
- package/instance/instance.cjs.map +1 -1
- package/instance/instance.d.cts +215 -0
- package/instance/instance.d.ts +33 -12
- package/instance/instance.js +41 -31
- package/instance/instance.js.map +1 -1
- package/job/job.cjs +36 -19
- package/job/job.cjs.map +1 -1
- package/job/job.d.cts +85 -0
- package/job/job.d.ts +10 -1
- package/job/job.js +34 -17
- package/job/job.js.map +1 -1
- package/metadata/metadata.cjs +23 -26
- package/metadata/metadata.cjs.map +1 -1
- package/metadata/metadata.d.cts +132 -0
- package/metadata/metadata.d.ts +19 -7
- package/metadata/metadata.js +20 -23
- package/metadata/metadata.js.map +1 -1
- package/package.json +12 -12
- package/project/project.cjs +70 -48
- package/project/project.cjs.map +1 -1
- package/project/project.d.cts +377 -0
- package/project/project.d.ts +61 -25
- package/project/project.js +59 -37
- package/project/project.js.map +1 -1
- package/src/accounting/accounting.ts +179 -194
- package/src/admin/admin.ts +590 -735
- package/src/application/application.ts +125 -141
- package/src/configuration/configuration.ts +72 -60
- package/src/data-manager-api.schemas.ts +941 -942
- package/src/dataset/dataset.ts +591 -770
- package/src/exchange-rate/exchange-rate.ts +362 -478
- package/src/file/file.ts +292 -357
- package/src/instance/instance.ts +427 -533
- package/src/job/job.ts +187 -198
- package/src/metadata/metadata.ts +247 -339
- package/src/project/project.ts +669 -860
- package/src/task/task.ts +181 -202
- package/src/type/type.ts +72 -68
- package/src/user/user.ts +248 -286
- package/task/task.cjs +31 -15
- package/task/task.cjs.map +1 -1
- package/task/task.d.cts +103 -0
- package/task/task.d.ts +10 -1
- package/task/task.js +29 -13
- package/task/task.js.map +1 -1
- package/type/type.cjs +13 -7
- package/type/type.cjs.map +1 -1
- package/type/type.d.cts +31 -0
- package/type/type.d.ts +4 -1
- package/type/type.js +13 -7
- package/type/type.js.map +1 -1
- package/user/user.cjs +39 -28
- package/user/user.cjs.map +1 -1
- package/user/user.d.cts +104 -0
- package/user/user.d.ts +16 -4
- package/user/user.js +36 -25
- package/user/user.js.map +1 -1
- package/chunk-UZTHSGDT.cjs.map +0 -1
package/src/file/file.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generated by orval v6.
|
|
2
|
+
* Generated by orval v6.20.0 🍺
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Dataset Manager API
|
|
5
5
|
* The Dataset Manager API service.
|
|
@@ -8,109 +8,103 @@ A service that allows *registered* users to make **Datasets** and associated **M
|
|
|
8
8
|
|
|
9
9
|
* OpenAPI spec version: 1.2
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
useMutation,
|
|
13
|
+
useQuery
|
|
14
|
+
} from '@tanstack/react-query'
|
|
12
15
|
import type {
|
|
13
|
-
UseQueryOptions,
|
|
14
|
-
UseMutationOptions,
|
|
15
|
-
QueryFunction,
|
|
16
16
|
MutationFunction,
|
|
17
|
-
|
|
17
|
+
QueryFunction,
|
|
18
18
|
QueryKey,
|
|
19
|
-
|
|
19
|
+
UseMutationOptions,
|
|
20
|
+
UseQueryOptions,
|
|
21
|
+
UseQueryResult
|
|
22
|
+
} from '@tanstack/react-query'
|
|
20
23
|
import type {
|
|
21
|
-
|
|
24
|
+
DeleteUnmanagedFileParams,
|
|
22
25
|
DmError,
|
|
23
|
-
GetFilesParams,
|
|
24
|
-
FilePostResponse,
|
|
25
26
|
FilePostBodyBody,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
FilePostResponse,
|
|
28
|
+
FilesGetResponse,
|
|
29
|
+
GetFilesParams
|
|
30
|
+
} from '../data-manager-api.schemas'
|
|
31
|
+
import { customInstance } from '.././custom-instance';
|
|
32
|
+
import type { ErrorType } from '.././custom-instance';
|
|
33
|
+
|
|
30
34
|
|
|
31
35
|
// eslint-disable-next-line
|
|
32
|
-
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
36
|
+
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
33
37
|
config: any,
|
|
34
|
-
args: infer P
|
|
38
|
+
args: infer P,
|
|
35
39
|
) => any
|
|
36
40
|
? P
|
|
37
41
|
: never;
|
|
38
42
|
|
|
43
|
+
|
|
39
44
|
/**
|
|
40
45
|
* Given a Project and Path the files available to you on that path will be returned along with any additional paths (sub-directories).
|
|
41
46
|
|
|
42
47
|
* @summary Gets the Files on a Project Path
|
|
43
48
|
*/
|
|
44
49
|
export const getFiles = (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
signal?: AbortSignal
|
|
50
|
+
params: GetFilesParams,
|
|
51
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
48
52
|
) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
TError
|
|
93
|
-
|
|
94
|
-
params
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
TData
|
|
100
|
-
>;
|
|
101
|
-
request?: SecondParameter<typeof customInstance>;
|
|
102
|
-
}
|
|
103
|
-
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
104
|
-
const queryOptions = getGetFilesQueryOptions(params, options);
|
|
105
|
-
|
|
106
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
107
|
-
queryKey: QueryKey;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
query.queryKey = queryOptions.queryKey;
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
return customInstance<FilesGetResponse>(
|
|
56
|
+
{url: `/file`, method: 'get',
|
|
57
|
+
params, signal
|
|
58
|
+
},
|
|
59
|
+
options);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
export const getGetFilesQueryKey = (params: GetFilesParams,) => {
|
|
64
|
+
|
|
65
|
+
return ["data-manager-api", `/file`, ...(params ? [params]: [])] as const;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
export const getGetFilesQueryOptions = <TData = Awaited<ReturnType<typeof getFiles>>, TError = ErrorType<void | DmError>>(params: GetFilesParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getFiles>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
70
|
+
) => {
|
|
71
|
+
|
|
72
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
73
|
+
|
|
74
|
+
const queryKey = queryOptions?.queryKey ?? getGetFilesQueryKey(params);
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getFiles>>> = ({ signal }) => getFiles(params, requestOptions, signal);
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getFiles>>, TError, TData> & { queryKey: QueryKey }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type GetFilesQueryResult = NonNullable<Awaited<ReturnType<typeof getFiles>>>
|
|
88
|
+
export type GetFilesQueryError = ErrorType<void | DmError>
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @summary Gets the Files on a Project Path
|
|
92
|
+
*/
|
|
93
|
+
export const useGetFiles = <TData = Awaited<ReturnType<typeof getFiles>>, TError = ErrorType<void | DmError>>(
|
|
94
|
+
params: GetFilesParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getFiles>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
95
|
+
|
|
96
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
97
|
+
|
|
98
|
+
const queryOptions = getGetFilesQueryOptions(params,options)
|
|
99
|
+
|
|
100
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
101
|
+
|
|
102
|
+
query.queryKey = queryOptions.queryKey ;
|
|
111
103
|
|
|
112
104
|
return query;
|
|
113
|
-
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
114
108
|
|
|
115
109
|
/**
|
|
116
110
|
* Given a Project and a Dataset the Dataset will be attached (added) to the project as a File using the format provided. When attached the Dataset is referred to as a Project **File**. As format conversion may take some time the file may not be immediately available. You should use the `task_id` you're presented with on the `/task` endpoint to determine when the file is available to the project.
|
|
@@ -126,92 +120,71 @@ You cannot add a Dataset to a Project until its upload is complete.
|
|
|
126
120
|
* @summary Attach a Dataset, as a File, to a Project
|
|
127
121
|
*/
|
|
128
122
|
export const attachFile = (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
{
|
|
152
|
-
url: `/file`,
|
|
153
|
-
method: "post",
|
|
154
|
-
headers: { "Content-Type": "multipart/form-data" },
|
|
155
|
-
data: formData,
|
|
123
|
+
filePostBodyBody: FilePostBodyBody,
|
|
124
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
125
|
+
|
|
126
|
+
const formData = new FormData();
|
|
127
|
+
formData.append('dataset_id', filePostBodyBody.dataset_id)
|
|
128
|
+
formData.append('dataset_version', filePostBodyBody.dataset_version.toString())
|
|
129
|
+
formData.append('project_id', filePostBodyBody.project_id)
|
|
130
|
+
formData.append('as_type', filePostBodyBody.as_type)
|
|
131
|
+
if(filePostBodyBody.path !== undefined) {
|
|
132
|
+
formData.append('path', filePostBodyBody.path)
|
|
133
|
+
}
|
|
134
|
+
if(filePostBodyBody.compress !== undefined) {
|
|
135
|
+
formData.append('compress', filePostBodyBody.compress.toString())
|
|
136
|
+
}
|
|
137
|
+
if(filePostBodyBody.immutable !== undefined) {
|
|
138
|
+
formData.append('immutable', filePostBodyBody.immutable.toString())
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return customInstance<FilePostResponse>(
|
|
142
|
+
{url: `/file`, method: 'post',
|
|
143
|
+
headers: {'Content-Type': 'multipart/form-data', },
|
|
144
|
+
data: formData
|
|
156
145
|
},
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
>(options?: {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
TError = ErrorType<void | DmError>,
|
|
200
|
-
TContext = unknown
|
|
201
|
-
>(options?: {
|
|
202
|
-
mutation?: UseMutationOptions<
|
|
203
|
-
Awaited<ReturnType<typeof attachFile>>,
|
|
204
|
-
TError,
|
|
205
|
-
{ data: FilePostBodyBody },
|
|
206
|
-
TContext
|
|
207
|
-
>;
|
|
208
|
-
request?: SecondParameter<typeof customInstance>;
|
|
209
|
-
}) => {
|
|
210
|
-
const mutationOptions = getAttachFileMutationOptions(options);
|
|
211
|
-
|
|
212
|
-
return useMutation(mutationOptions);
|
|
213
|
-
};
|
|
214
|
-
/**
|
|
146
|
+
options);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
export const getAttachFileMutationOptions = <TError = ErrorType<void | DmError>,
|
|
152
|
+
|
|
153
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof attachFile>>, TError,{data: FilePostBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
154
|
+
): UseMutationOptions<Awaited<ReturnType<typeof attachFile>>, TError,{data: FilePostBodyBody}, TContext> => {
|
|
155
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof attachFile>>, {data: FilePostBodyBody}> = (props) => {
|
|
161
|
+
const {data} = props ?? {};
|
|
162
|
+
|
|
163
|
+
return attachFile(data,requestOptions)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
return { mutationFn, ...mutationOptions }}
|
|
170
|
+
|
|
171
|
+
export type AttachFileMutationResult = NonNullable<Awaited<ReturnType<typeof attachFile>>>
|
|
172
|
+
export type AttachFileMutationBody = FilePostBodyBody
|
|
173
|
+
export type AttachFileMutationError = ErrorType<void | DmError>
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @summary Attach a Dataset, as a File, to a Project
|
|
177
|
+
*/
|
|
178
|
+
export const useAttachFile = <TError = ErrorType<void | DmError>,
|
|
179
|
+
|
|
180
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof attachFile>>, TError,{data: FilePostBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
181
|
+
) => {
|
|
182
|
+
|
|
183
|
+
const mutationOptions = getAttachFileMutationOptions(options);
|
|
184
|
+
|
|
185
|
+
return useMutation(mutationOptions);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
215
188
|
* Removes an unmanaged file from a Project. You cannot use this endpoint to delete managed project files.
|
|
216
189
|
|
|
217
190
|
You must be an `editor` or the `owner` of the project to delete a file from a project.
|
|
@@ -219,69 +192,56 @@ You must be an `editor` or the `owner` of the project to delete a file from a pr
|
|
|
219
192
|
* @summary Delete an unmanaged Project File
|
|
220
193
|
*/
|
|
221
194
|
export const deleteUnmanagedFile = (
|
|
222
|
-
|
|
223
|
-
|
|
195
|
+
params: DeleteUnmanagedFileParams,
|
|
196
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
return customInstance<void>(
|
|
200
|
+
{url: `/file`, method: 'delete',
|
|
201
|
+
params
|
|
202
|
+
},
|
|
203
|
+
options);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
export const getDeleteUnmanagedFileMutationOptions = <TError = ErrorType<DmError>,
|
|
209
|
+
|
|
210
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteUnmanagedFile>>, TError,{params: DeleteUnmanagedFileParams}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
211
|
+
): UseMutationOptions<Awaited<ReturnType<typeof deleteUnmanagedFile>>, TError,{params: DeleteUnmanagedFileParams}, TContext> => {
|
|
212
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteUnmanagedFile>>, {params: DeleteUnmanagedFileParams}> = (props) => {
|
|
218
|
+
const {params} = props ?? {};
|
|
219
|
+
|
|
220
|
+
return deleteUnmanagedFile(params,requestOptions)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
return { mutationFn, ...mutationOptions }}
|
|
227
|
+
|
|
228
|
+
export type DeleteUnmanagedFileMutationResult = NonNullable<Awaited<ReturnType<typeof deleteUnmanagedFile>>>
|
|
229
|
+
|
|
230
|
+
export type DeleteUnmanagedFileMutationError = ErrorType<DmError>
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* @summary Delete an unmanaged Project File
|
|
234
|
+
*/
|
|
235
|
+
export const useDeleteUnmanagedFile = <TError = ErrorType<DmError>,
|
|
236
|
+
|
|
237
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteUnmanagedFile>>, TError,{params: DeleteUnmanagedFileParams}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
224
238
|
) => {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export const getDeleteUnmanagedFileMutationOptions = <
|
|
232
|
-
TError = ErrorType<DmError>,
|
|
233
|
-
TContext = unknown
|
|
234
|
-
>(options?: {
|
|
235
|
-
mutation?: UseMutationOptions<
|
|
236
|
-
Awaited<ReturnType<typeof deleteUnmanagedFile>>,
|
|
237
|
-
TError,
|
|
238
|
-
{ params: DeleteUnmanagedFileParams },
|
|
239
|
-
TContext
|
|
240
|
-
>;
|
|
241
|
-
request?: SecondParameter<typeof customInstance>;
|
|
242
|
-
}): UseMutationOptions<
|
|
243
|
-
Awaited<ReturnType<typeof deleteUnmanagedFile>>,
|
|
244
|
-
TError,
|
|
245
|
-
{ params: DeleteUnmanagedFileParams },
|
|
246
|
-
TContext
|
|
247
|
-
> => {
|
|
248
|
-
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
249
|
-
|
|
250
|
-
const mutationFn: MutationFunction<
|
|
251
|
-
Awaited<ReturnType<typeof deleteUnmanagedFile>>,
|
|
252
|
-
{ params: DeleteUnmanagedFileParams }
|
|
253
|
-
> = (props) => {
|
|
254
|
-
const { params } = props ?? {};
|
|
255
|
-
|
|
256
|
-
return deleteUnmanagedFile(params, requestOptions);
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
return { mutationFn, ...mutationOptions };
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
export type DeleteUnmanagedFileMutationResult = NonNullable<
|
|
263
|
-
Awaited<ReturnType<typeof deleteUnmanagedFile>>
|
|
264
|
-
>;
|
|
265
|
-
|
|
266
|
-
export type DeleteUnmanagedFileMutationError = ErrorType<DmError>;
|
|
267
|
-
|
|
268
|
-
export const useDeleteUnmanagedFile = <
|
|
269
|
-
TError = ErrorType<DmError>,
|
|
270
|
-
TContext = unknown
|
|
271
|
-
>(options?: {
|
|
272
|
-
mutation?: UseMutationOptions<
|
|
273
|
-
Awaited<ReturnType<typeof deleteUnmanagedFile>>,
|
|
274
|
-
TError,
|
|
275
|
-
{ params: DeleteUnmanagedFileParams },
|
|
276
|
-
TContext
|
|
277
|
-
>;
|
|
278
|
-
request?: SecondParameter<typeof customInstance>;
|
|
279
|
-
}) => {
|
|
280
|
-
const mutationOptions = getDeleteUnmanagedFileMutationOptions(options);
|
|
281
|
-
|
|
282
|
-
return useMutation(mutationOptions);
|
|
283
|
-
};
|
|
284
|
-
/**
|
|
239
|
+
|
|
240
|
+
const mutationOptions = getDeleteUnmanagedFileMutationOptions(options);
|
|
241
|
+
|
|
242
|
+
return useMutation(mutationOptions);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
285
245
|
* Given a `file_id` the file will be removed from the Project it's attached to.
|
|
286
246
|
|
|
287
247
|
You must be an `editor` or the `owner` of the project to delete a file from a Project. Being an `editor` of the original Dataset does not give you the ability to detach it from the Project.
|
|
@@ -291,69 +251,55 @@ You cannot delete a Project File until the attach is complete.
|
|
|
291
251
|
* @summary Delete/detach a File (from a Project)
|
|
292
252
|
*/
|
|
293
253
|
export const deleteFile = (
|
|
294
|
-
|
|
295
|
-
|
|
254
|
+
fileId: string,
|
|
255
|
+
options?: SecondParameter<typeof customInstance>,) => {
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
return customInstance<void>(
|
|
259
|
+
{url: `/file/${fileId}`, method: 'delete'
|
|
260
|
+
},
|
|
261
|
+
options);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
export const getDeleteFileMutationOptions = <TError = ErrorType<DmError>,
|
|
267
|
+
|
|
268
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteFile>>, TError,{fileId: string}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
269
|
+
): UseMutationOptions<Awaited<ReturnType<typeof deleteFile>>, TError,{fileId: string}, TContext> => {
|
|
270
|
+
const {mutation: mutationOptions, request: requestOptions} = options ?? {};
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteFile>>, {fileId: string}> = (props) => {
|
|
276
|
+
const {fileId} = props ?? {};
|
|
277
|
+
|
|
278
|
+
return deleteFile(fileId,requestOptions)
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
return { mutationFn, ...mutationOptions }}
|
|
285
|
+
|
|
286
|
+
export type DeleteFileMutationResult = NonNullable<Awaited<ReturnType<typeof deleteFile>>>
|
|
287
|
+
|
|
288
|
+
export type DeleteFileMutationError = ErrorType<DmError>
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* @summary Delete/detach a File (from a Project)
|
|
292
|
+
*/
|
|
293
|
+
export const useDeleteFile = <TError = ErrorType<DmError>,
|
|
294
|
+
|
|
295
|
+
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteFile>>, TError,{fileId: string}, TContext>, request?: SecondParameter<typeof customInstance>}
|
|
296
296
|
) => {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
export const getDeleteFileMutationOptions = <
|
|
304
|
-
TError = ErrorType<DmError>,
|
|
305
|
-
TContext = unknown
|
|
306
|
-
>(options?: {
|
|
307
|
-
mutation?: UseMutationOptions<
|
|
308
|
-
Awaited<ReturnType<typeof deleteFile>>,
|
|
309
|
-
TError,
|
|
310
|
-
{ fileId: string },
|
|
311
|
-
TContext
|
|
312
|
-
>;
|
|
313
|
-
request?: SecondParameter<typeof customInstance>;
|
|
314
|
-
}): UseMutationOptions<
|
|
315
|
-
Awaited<ReturnType<typeof deleteFile>>,
|
|
316
|
-
TError,
|
|
317
|
-
{ fileId: string },
|
|
318
|
-
TContext
|
|
319
|
-
> => {
|
|
320
|
-
const { mutation: mutationOptions, request: requestOptions } = options ?? {};
|
|
321
|
-
|
|
322
|
-
const mutationFn: MutationFunction<
|
|
323
|
-
Awaited<ReturnType<typeof deleteFile>>,
|
|
324
|
-
{ fileId: string }
|
|
325
|
-
> = (props) => {
|
|
326
|
-
const { fileId } = props ?? {};
|
|
327
|
-
|
|
328
|
-
return deleteFile(fileId, requestOptions);
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
return { mutationFn, ...mutationOptions };
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
export type DeleteFileMutationResult = NonNullable<
|
|
335
|
-
Awaited<ReturnType<typeof deleteFile>>
|
|
336
|
-
>;
|
|
337
|
-
|
|
338
|
-
export type DeleteFileMutationError = ErrorType<DmError>;
|
|
339
|
-
|
|
340
|
-
export const useDeleteFile = <
|
|
341
|
-
TError = ErrorType<DmError>,
|
|
342
|
-
TContext = unknown
|
|
343
|
-
>(options?: {
|
|
344
|
-
mutation?: UseMutationOptions<
|
|
345
|
-
Awaited<ReturnType<typeof deleteFile>>,
|
|
346
|
-
TError,
|
|
347
|
-
{ fileId: string },
|
|
348
|
-
TContext
|
|
349
|
-
>;
|
|
350
|
-
request?: SecondParameter<typeof customInstance>;
|
|
351
|
-
}) => {
|
|
352
|
-
const mutationOptions = getDeleteFileMutationOptions(options);
|
|
353
|
-
|
|
354
|
-
return useMutation(mutationOptions);
|
|
355
|
-
};
|
|
356
|
-
/**
|
|
297
|
+
|
|
298
|
+
const mutationOptions = getDeleteFileMutationOptions(options);
|
|
299
|
+
|
|
300
|
+
return useMutation(mutationOptions);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
357
303
|
* Given a `file_id` the file will be returned if available.
|
|
358
304
|
|
|
359
305
|
You cannot get a Project File until the attach is complete.
|
|
@@ -361,72 +307,61 @@ You cannot get a Project File until the attach is complete.
|
|
|
361
307
|
* @summary Download a File (from a project)
|
|
362
308
|
*/
|
|
363
309
|
export const downloadFile = (
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
310
|
+
fileId: string,
|
|
311
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
312
|
+
) => {
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
return customInstance<void>(
|
|
316
|
+
{url: `/file/${fileId}`, method: 'get', signal
|
|
317
|
+
},
|
|
318
|
+
options);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
export const getDownloadFileQueryKey = (fileId: string,) => {
|
|
323
|
+
|
|
324
|
+
return ["data-manager-api", `/file/${fileId}`] as const;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
export const getDownloadFileQueryOptions = <TData = Awaited<ReturnType<typeof downloadFile>>, TError = ErrorType<DmError>>(fileId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof downloadFile>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
367
329
|
) => {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
);
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
fileId:
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
return { queryKey, queryFn, enabled: !!fileId, ...queryOptions };
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
export type DownloadFileQueryResult = NonNullable<
|
|
405
|
-
Awaited<ReturnType<typeof downloadFile>>
|
|
406
|
-
>;
|
|
407
|
-
export type DownloadFileQueryError = ErrorType<DmError>;
|
|
408
|
-
|
|
409
|
-
export const useDownloadFile = <
|
|
410
|
-
TData = Awaited<ReturnType<typeof downloadFile>>,
|
|
411
|
-
TError = ErrorType<DmError>
|
|
412
|
-
>(
|
|
413
|
-
fileId: string,
|
|
414
|
-
options?: {
|
|
415
|
-
query?: UseQueryOptions<
|
|
416
|
-
Awaited<ReturnType<typeof downloadFile>>,
|
|
417
|
-
TError,
|
|
418
|
-
TData
|
|
419
|
-
>;
|
|
420
|
-
request?: SecondParameter<typeof customInstance>;
|
|
421
|
-
}
|
|
422
|
-
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
423
|
-
const queryOptions = getDownloadFileQueryOptions(fileId, options);
|
|
424
|
-
|
|
425
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
|
426
|
-
queryKey: QueryKey;
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
query.queryKey = queryOptions.queryKey;
|
|
330
|
+
|
|
331
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
332
|
+
|
|
333
|
+
const queryKey = queryOptions?.queryKey ?? getDownloadFileQueryKey(fileId);
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof downloadFile>>> = ({ signal }) => downloadFile(fileId, requestOptions, signal);
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
return { queryKey, queryFn, enabled: !!(fileId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof downloadFile>>, TError, TData> & { queryKey: QueryKey }
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export type DownloadFileQueryResult = NonNullable<Awaited<ReturnType<typeof downloadFile>>>
|
|
347
|
+
export type DownloadFileQueryError = ErrorType<DmError>
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* @summary Download a File (from a project)
|
|
351
|
+
*/
|
|
352
|
+
export const useDownloadFile = <TData = Awaited<ReturnType<typeof downloadFile>>, TError = ErrorType<DmError>>(
|
|
353
|
+
fileId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof downloadFile>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
|
|
354
|
+
|
|
355
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
356
|
+
|
|
357
|
+
const queryOptions = getDownloadFileQueryOptions(fileId,options)
|
|
358
|
+
|
|
359
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
360
|
+
|
|
361
|
+
query.queryKey = queryOptions.queryKey ;
|
|
430
362
|
|
|
431
363
|
return query;
|
|
432
|
-
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|