@hautechai/sdk 1.0.3 → 1.0.4
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/.github/workflows/release.yaml +3 -0
- package/CHANGELOG.md +1 -1
- package/dist/autogenerated/api.d.ts +11397 -0
- package/dist/autogenerated/api.js +11002 -0
- package/dist/autogenerated/base.d.ts +66 -0
- package/dist/autogenerated/base.js +59 -0
- package/dist/autogenerated/common.d.ts +65 -0
- package/dist/autogenerated/common.js +133 -0
- package/dist/autogenerated/configuration.d.ts +91 -0
- package/dist/autogenerated/configuration.js +39 -0
- package/dist/autogenerated/index.d.ts +13 -0
- package/dist/autogenerated/index.js +15 -0
- package/dist/autogenerated/permissions.d.ts +94 -0
- package/dist/autogenerated/permissions.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/sdk/access/index.d.ts +20 -0
- package/dist/sdk/access/index.js +23 -0
- package/dist/sdk/accounts/index.d.ts +16 -0
- package/dist/sdk/accounts/index.js +25 -0
- package/dist/sdk/api.d.ts +20 -0
- package/dist/sdk/api.js +33 -0
- package/dist/sdk/balances/index.d.ts +12 -0
- package/dist/sdk/balances/index.js +19 -0
- package/dist/sdk/collections/index.d.ts +33 -0
- package/dist/sdk/collections/index.js +34 -0
- package/dist/sdk/errors/index.d.ts +3 -0
- package/dist/sdk/errors/index.js +6 -0
- package/dist/sdk/groups/index.d.ts +24 -0
- package/dist/sdk/groups/index.js +31 -0
- package/dist/sdk/images/index.d.ts +17 -0
- package/dist/sdk/images/index.js +35 -0
- package/dist/sdk/index.d.ts +1585 -0
- package/dist/sdk/index.js +69 -0
- package/dist/sdk/listeners/index.d.ts +28 -0
- package/dist/sdk/listeners/index.js +104 -0
- package/dist/sdk/operations/index.d.ts +199 -0
- package/dist/sdk/operations/index.js +133 -0
- package/dist/sdk/pipelines/index.d.ts +1189 -0
- package/dist/sdk/pipelines/index.js +208 -0
- package/dist/sdk/pipelines/pipelines.d.ts +0 -0
- package/dist/sdk/pipelines/pipelines.js +1 -0
- package/dist/sdk/poses/index.d.ts +20 -0
- package/dist/sdk/poses/index.js +24 -0
- package/dist/sdk/stacks/index.d.ts +29 -0
- package/dist/sdk/stacks/index.js +32 -0
- package/dist/sdk/storage/index.d.ts +18 -0
- package/dist/sdk/storage/index.js +27 -0
- package/dist/sdk/transformers.d.ts +7 -0
- package/dist/sdk/transformers.js +6 -0
- package/dist/sdk/utils/index.d.ts +10 -0
- package/dist/sdk/utils/index.js +6 -0
- package/dist/sdk/videos/index.d.ts +11 -0
- package/dist/sdk/videos/index.js +15 -0
- package/dist/token/index.d.ts +15 -0
- package/dist/token/index.js +65 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AxiosPromise } from 'axios';
|
|
2
|
+
import { BaseAPI } from '../autogenerated/base';
|
|
3
|
+
import { SDKOptions } from '../types';
|
|
4
|
+
import { Configuration } from '../autogenerated';
|
|
5
|
+
export declare const getBaseUrl: (options: SDKOptions) => string;
|
|
6
|
+
export declare const getAPI: <T>(API: new (configuration?: Configuration, basePath?: string, axios?: any) => T, options: SDKOptions) => Promise<T>;
|
|
7
|
+
export declare const useAutogeneratedAPI: <T extends BaseAPI>(baseProps: {
|
|
8
|
+
API: new (configuration?: Configuration, basePath?: string, axios?: any) => T;
|
|
9
|
+
options: SDKOptions;
|
|
10
|
+
}) => {
|
|
11
|
+
call: <ResponseEntity, ReturnType = ResponseEntity>(props: {
|
|
12
|
+
returnUndefinedOn404?: boolean;
|
|
13
|
+
run: (api: T) => AxiosPromise<ResponseEntity>;
|
|
14
|
+
transform?: (response: ResponseEntity) => ReturnType;
|
|
15
|
+
}) => Promise<ReturnType>;
|
|
16
|
+
callWithReturningUndefinedOn404: <ResponseEntity, ReturnType_1 = ResponseEntity>(props: {
|
|
17
|
+
run: (api: T) => AxiosPromise<ResponseEntity>;
|
|
18
|
+
transform?: (response: ResponseEntity) => ReturnType_1;
|
|
19
|
+
}) => Promise<ReturnType_1 | undefined>;
|
|
20
|
+
};
|
package/dist/sdk/api.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { HautechError } from './errors';
|
|
2
|
+
export const getBaseUrl = (options) => options.endpoint ?? 'https://api.hautech.ai';
|
|
3
|
+
export const getAPI = async (API, options) => {
|
|
4
|
+
const config = {
|
|
5
|
+
accessToken: await options.authToken(),
|
|
6
|
+
basePath: getBaseUrl(options),
|
|
7
|
+
isJsonMime: (mime) => true,
|
|
8
|
+
};
|
|
9
|
+
return new API(config);
|
|
10
|
+
};
|
|
11
|
+
export const useAutogeneratedAPI = (baseProps) => {
|
|
12
|
+
const call = async (props) => {
|
|
13
|
+
const api = await getAPI(baseProps.API, baseProps.options);
|
|
14
|
+
try {
|
|
15
|
+
const response = await props.run(api);
|
|
16
|
+
if (props.returnUndefinedOn404 && response.status === 404)
|
|
17
|
+
return undefined;
|
|
18
|
+
if (response.status < 200 || response.status >= 300)
|
|
19
|
+
throw new HautechError(`API call failed with status code ${response.status}`);
|
|
20
|
+
return props.transform ? props.transform(response.data) : response.data;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (props.returnUndefinedOn404 && error?.response?.status === 404)
|
|
24
|
+
return undefined;
|
|
25
|
+
throw new HautechError(error.message, { cause: error });
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const callWithReturningUndefinedOn404 = async (props) => call({ ...props, returnUndefinedOn404: true });
|
|
29
|
+
return {
|
|
30
|
+
call,
|
|
31
|
+
callWithReturningUndefinedOn404,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SDKOptions } from '../../types';
|
|
2
|
+
declare const balances: (options: SDKOptions) => {
|
|
3
|
+
add: (props: {
|
|
4
|
+
accountId: string;
|
|
5
|
+
amount: string;
|
|
6
|
+
}) => Promise<void>;
|
|
7
|
+
get: () => Promise<string>;
|
|
8
|
+
getByAccountId: (props: {
|
|
9
|
+
accountId: string;
|
|
10
|
+
}) => Promise<string>;
|
|
11
|
+
};
|
|
12
|
+
export default balances;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BalancesApi } from '../../autogenerated';
|
|
2
|
+
import { useAutogeneratedAPI } from '../api';
|
|
3
|
+
const balances = (options) => {
|
|
4
|
+
const api = useAutogeneratedAPI({ API: BalancesApi, options });
|
|
5
|
+
return {
|
|
6
|
+
add: async (props) => api.call({
|
|
7
|
+
run: (methods) => methods.balancesControllerAddBalanceV1(props.accountId, { amount: props.amount }),
|
|
8
|
+
}),
|
|
9
|
+
get: async () => api.call({
|
|
10
|
+
run: (methods) => methods.balancesControllerGetBalanceForSelfV1(),
|
|
11
|
+
transform: (data) => data.balance,
|
|
12
|
+
}),
|
|
13
|
+
getByAccountId: async (props) => api.call({
|
|
14
|
+
run: (methods) => methods.balancesControllerGetBalanceV1(props.accountId),
|
|
15
|
+
transform: (data) => data.balance,
|
|
16
|
+
}),
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export default balances;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SDKOptions, ListProps, ListResponse } from '../../types';
|
|
2
|
+
import { CollectionEntity, CollectionsControllerListItemsV1KindEnum, ResourceEntity } from '../../autogenerated';
|
|
3
|
+
import { CollectionMetadata } from '../index';
|
|
4
|
+
import { AddMetadata } from '../utils';
|
|
5
|
+
type CollectionEntityWithMetadata = AddMetadata<CollectionEntity, CollectionMetadata>;
|
|
6
|
+
declare const collections: (options: SDKOptions) => {
|
|
7
|
+
create: (props?: {
|
|
8
|
+
metadata?: CollectionMetadata;
|
|
9
|
+
}) => Promise<CollectionEntityWithMetadata>;
|
|
10
|
+
get: (props: {
|
|
11
|
+
id: string;
|
|
12
|
+
}) => Promise<CollectionEntityWithMetadata | undefined>;
|
|
13
|
+
items: {
|
|
14
|
+
add: (props: {
|
|
15
|
+
collectionId: string;
|
|
16
|
+
itemIds: string[];
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
list: (props: {
|
|
19
|
+
collectionId: string;
|
|
20
|
+
kind?: CollectionsControllerListItemsV1KindEnum;
|
|
21
|
+
} & ListProps) => Promise<ListResponse<ResourceEntity>>;
|
|
22
|
+
remove: (props: {
|
|
23
|
+
collectionId: string;
|
|
24
|
+
itemIds: string[];
|
|
25
|
+
}) => Promise<void>;
|
|
26
|
+
};
|
|
27
|
+
list: (props?: ListProps) => Promise<ListResponse<CollectionEntityWithMetadata>>;
|
|
28
|
+
updateMetadata: (props: {
|
|
29
|
+
id: string;
|
|
30
|
+
metadata?: Partial<CollectionMetadata>;
|
|
31
|
+
}) => Promise<void>;
|
|
32
|
+
};
|
|
33
|
+
export default collections;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CollectionsApi, } from '../../autogenerated';
|
|
2
|
+
import { useAutogeneratedAPI } from '../api';
|
|
3
|
+
import { transformToListResponse } from '../transformers';
|
|
4
|
+
const collections = (options) => {
|
|
5
|
+
const api = useAutogeneratedAPI({ API: CollectionsApi, options });
|
|
6
|
+
return {
|
|
7
|
+
create: async (props = {}) => api.call({
|
|
8
|
+
run: (methods) => methods.collectionsControllerCreateCollectionV1({ metadata: props.metadata }),
|
|
9
|
+
}),
|
|
10
|
+
get: async (props) => api.callWithReturningUndefinedOn404({
|
|
11
|
+
run: (methods) => methods.collectionsControllerGetCollectionV1(props.id),
|
|
12
|
+
}),
|
|
13
|
+
items: {
|
|
14
|
+
add: async (props) => api.call({
|
|
15
|
+
run: (methods) => methods.collectionsControllerAddItemsV1(props.collectionId, { itemIds: props.itemIds }),
|
|
16
|
+
}),
|
|
17
|
+
list: async (props) => api.call({
|
|
18
|
+
run: (methods) => methods.collectionsControllerListItemsV1(props.collectionId, props.cursor, props.orderBy, props.limit, props.kind),
|
|
19
|
+
transform: transformToListResponse,
|
|
20
|
+
}),
|
|
21
|
+
remove: async (props) => api.call({
|
|
22
|
+
run: (methods) => methods.collectionsControllerRemoveItemsV1(props.collectionId, { itemIds: props.itemIds }),
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
list: (props = {}) => api.call({
|
|
26
|
+
run: (methods) => methods.collectionsControllerListCollectionsV1(props.orderBy, props.limit, props.cursor),
|
|
27
|
+
transform: transformToListResponse,
|
|
28
|
+
}),
|
|
29
|
+
updateMetadata: async (props) => api.call({
|
|
30
|
+
run: (methods) => methods.collectionsControllerUpdateMetadataV1(props.id, { overwrite: props.metadata ?? {} }),
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export default collections;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SDKOptions } from '../../types';
|
|
2
|
+
import { AddAccountToGroupControllerParamsDtoRoleEnum, GroupEntity, RemoveAccountFromGroupControllerParamsDtoRoleEnum } from '../../autogenerated';
|
|
3
|
+
declare const groups: (options: SDKOptions) => {
|
|
4
|
+
accounts: {
|
|
5
|
+
add: (props: {
|
|
6
|
+
accountId: string;
|
|
7
|
+
groupId: string;
|
|
8
|
+
role: AddAccountToGroupControllerParamsDtoRoleEnum;
|
|
9
|
+
}) => Promise<void>;
|
|
10
|
+
remove: (props: {
|
|
11
|
+
accountId: string;
|
|
12
|
+
groupId: string;
|
|
13
|
+
role: RemoveAccountFromGroupControllerParamsDtoRoleEnum;
|
|
14
|
+
}) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
create: () => Promise<GroupEntity>;
|
|
17
|
+
delete: (props: {
|
|
18
|
+
id: string;
|
|
19
|
+
}) => Promise<void>;
|
|
20
|
+
get: (props: {
|
|
21
|
+
id: string;
|
|
22
|
+
}) => Promise<GroupEntity | undefined>;
|
|
23
|
+
};
|
|
24
|
+
export default groups;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { GroupsApi, } from '../../autogenerated';
|
|
2
|
+
import { useAutogeneratedAPI } from '../api';
|
|
3
|
+
const groups = (options) => {
|
|
4
|
+
const api = useAutogeneratedAPI({ API: GroupsApi, options });
|
|
5
|
+
return {
|
|
6
|
+
accounts: {
|
|
7
|
+
add: async (props) => api.call({
|
|
8
|
+
run: (methods) => methods.groupsControllerAddAccountV1(props.groupId, {
|
|
9
|
+
accountId: props.accountId,
|
|
10
|
+
role: props.role,
|
|
11
|
+
}),
|
|
12
|
+
}),
|
|
13
|
+
remove: async (props) => api.call({
|
|
14
|
+
run: (methods) => methods.groupsControllerRemoveAccountV1(props.groupId, {
|
|
15
|
+
accountId: props.accountId,
|
|
16
|
+
role: props.role,
|
|
17
|
+
}),
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
create: async () => api.call({
|
|
21
|
+
run: (methods) => methods.groupsControllerCreateGroupV1(),
|
|
22
|
+
}),
|
|
23
|
+
delete: async (props) => api.call({
|
|
24
|
+
run: (methods) => methods.groupsControllerDeleteGroupV1(props.id),
|
|
25
|
+
}),
|
|
26
|
+
get: (props) => api.callWithReturningUndefinedOn404({
|
|
27
|
+
run: (methods) => methods.groupsControllerGetGroupV1(props.id),
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export default groups;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SDKOptions } from '../../types';
|
|
2
|
+
import { ImageEntity } from '../../autogenerated';
|
|
3
|
+
declare const images: (options: SDKOptions) => {
|
|
4
|
+
createFromFile: (props: {
|
|
5
|
+
file: Blob;
|
|
6
|
+
}) => Promise<ImageEntity>;
|
|
7
|
+
createFromUrl: (props: {
|
|
8
|
+
url: string;
|
|
9
|
+
}) => Promise<ImageEntity>;
|
|
10
|
+
get: (props: {
|
|
11
|
+
id: string;
|
|
12
|
+
}) => Promise<ImageEntity | undefined>;
|
|
13
|
+
getUrls: (props: {
|
|
14
|
+
ids: string[];
|
|
15
|
+
}) => Promise<Record<string, string>>;
|
|
16
|
+
};
|
|
17
|
+
export default images;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { ImagesApi } from '../../autogenerated';
|
|
3
|
+
import { useAutogeneratedAPI } from '../api';
|
|
4
|
+
const images = (options) => {
|
|
5
|
+
const api = useAutogeneratedAPI({ API: ImagesApi, options });
|
|
6
|
+
const createFromFile = async (props) => {
|
|
7
|
+
const uploadUrl = await api.call({
|
|
8
|
+
run: (methods) => methods.imagesControllerStartUploadV1(),
|
|
9
|
+
transform: (data) => data.uploadUrl,
|
|
10
|
+
});
|
|
11
|
+
const formData = new FormData();
|
|
12
|
+
formData.append('file', props.file);
|
|
13
|
+
const response = await axios.put(uploadUrl, formData, {
|
|
14
|
+
headers: { 'Content-Type': 'multipart/form-data' },
|
|
15
|
+
});
|
|
16
|
+
const fileToken = response.data.fileToken;
|
|
17
|
+
return await api.call({ run: (methods) => methods.imagesControllerFinalizeUploadV1({ fileToken }) });
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
createFromFile,
|
|
21
|
+
createFromUrl: async (props) => {
|
|
22
|
+
const response = await axios.get(props.url, { responseType: 'arraybuffer' });
|
|
23
|
+
const file = new Blob([response.data], { type: response.headers['content-type'] });
|
|
24
|
+
return createFromFile({ file });
|
|
25
|
+
},
|
|
26
|
+
get: async (props) => api.callWithReturningUndefinedOn404({
|
|
27
|
+
run: (methods) => methods.imagesControllerGetImageV1(props.id),
|
|
28
|
+
}),
|
|
29
|
+
getUrls: async (props) => api.call({
|
|
30
|
+
run: (methods) => methods.imagesControllerGetUrlsV1({ ids: props.ids }),
|
|
31
|
+
transform: (data) => data.reduce((acc, { id, url }) => ({ ...acc, [id]: url }), {}),
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export default images;
|