-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapiStack.ts
More file actions
27 lines (25 loc) · 870 Bytes
/
apiStack.ts
File metadata and controls
27 lines (25 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { ResponseType } from '@tauri-apps/api/http';
import { iots, taskEither } from '@code-expert/prelude';
import { PfsPath } from '@/domain/FileSystem';
import { ProjectId } from '@/domain/Project';
import { ApiError, apiGetSigned } from '@/utils/api';
export interface ApiStack {
readRemoteProjectFile: (
projectId: ProjectId,
file: PfsPath,
) => taskEither.TaskEither<ApiError, Uint8Array>;
}
/**
* Notes:
* - This instance should not be defined here, but passed as an environment dependency
* - It seems like this could be part of the {@link ProjectRepository}
*/
export const apiStack: ApiStack = {
readRemoteProjectFile: (projectId, file) =>
apiGetSigned({
path: `project/${projectId}/file`,
jwtPayload: { path: file }, // fixme: add version
codec: iots.Uint8ArrayC,
responseType: ResponseType.Binary,
}),
};