@iexec/dataprotector
Version:
This product enables users to confidentially store data–such as mail address, documents, personal information ...
41 lines (37 loc) • 1.23 kB
text/typescript
import { WorkflowError } from '../../utils/errors.js';
import {
addressSchema,
booleanSchema,
throwIfMissing,
} from '../../utils/validators.js';
import {
GetCollectionsByOwnerResponse,
GetCollectionsByOwnerParams,
} from '../types/index.js';
import { SubgraphConsumer } from '../types/internalTypes.js';
import { getCollectionsByOwnerQuery } from './subgraph/getCollectionsByOwnerQuery.js';
export async function getCollectionsByOwner({
graphQLClient = throwIfMissing(),
owner,
includeHiddenProtectedDatas = false,
}: SubgraphConsumer &
GetCollectionsByOwnerParams): Promise<GetCollectionsByOwnerResponse> {
const vOwner = addressSchema().required().label('owner').validateSync(owner);
const vIncludeHiddenProtectedDatas = booleanSchema()
.required()
.label('includeHiddenProtectedDatas')
.validateSync(includeHiddenProtectedDatas);
try {
return await getCollectionsByOwnerQuery({
graphQLClient,
owner: vOwner,
includeHiddenProtectedDatas: vIncludeHiddenProtectedDatas,
});
} catch (e) {
console.log('[getCollectionsByOwner] ERROR', e);
throw new WorkflowError({
message: 'Failed to get collections by owner',
errorCause: e,
});
}
}