@ailo/file-service-client

Ailo TypeScript starter

Usage no npm install needed!

<script type="module">
  import ailoFileServiceClient from 'https://cdn.skypack.dev/@ailo/file-service-client';
</script>

README

@ailo/file-service-client

GraphQL Client to be used in Ailo services to access Internal API of file-service.

Example usage

// fileServiceClient.ts
import { FileServiceClient } from "@ailo/file-service-client";
import { AccessToken } from "@ailo/events";
import { config, Logger } from "local/app/utils";

const serviceAccessToken = new AccessToken(
  config.auth0.domain,
  config.auth0.clientId,
  config.auth0.clientSecret,
  config.auth0.audience
);

export const fileServiceClient = new FileServiceClient({
  baseUrl: config.fileService.url,
  logger: Logger.logAs("fileServiceClient"),
  getAccessToken: () => serviceAccessToken.getAccessToken(),
});

// ChatService.ts
await fileServiceClient.claimFiles({
  filesIds,
  ownerId: (await securityContext.authorizeUser())
    .getActualUserAilorn()
    .toString(),
  claimerId: chatMessageId,
  permittedReadEntitiesIds: getChatReadAccessEntitiesIds(chat),
});

Development

yarn
yarn start

Testing

yarn lint # prettier and eslint
yarn test # unit tests
yarn test --watch # unit tests in watch mode

Releasing

yarn release # will automatically ask you about version bump, run tests and build, and push new version to git & npm