UNPKG

biketag

Version:

The Javascript client API for BikeTag Games

56 lines (55 loc) 3.6 kB
import { S3Client, ObjectCannedACL, _Object, ListObjectsV2CommandInput } from '@aws-sdk/client-s3'; import { Tag } from '../common/schema'; import { Readable } from 'form-data'; import { S3ImageMeta, CommonPayloadData } from '../common/types'; import { default as TinyCache } from 'tinycache'; /** Returns the S3 key prefix for a given tag */ export declare const getTagPrefix: (folder: string, game: string, tagnumber: number) => string; export declare const getBikeTagImageKey: (type: any, player: any, tagnumber: any, game: any, contentType?: string, folder?: string) => Promise<string>; export declare const listAllS3Objects: (client: S3Client, params: Omit<ListObjectsV2CommandInput, "ContinuationToken">) => Promise<_Object[]>; export declare const streamToString: (stream: any) => Promise<string>; export declare const loadIndex: (client: S3Client, bucket: string, folder: string, region: string, cached?: boolean, reindex?: boolean) => Promise<Tag[]>; /** Writes the given tag array to index.json or deletes it if empty */ export declare const saveIndex: (client: S3Client, bucket: string, folder: string, tags: Tag[], acl?: ObjectCannedACL) => Promise<void>; /** * Confirms if a given upload payload has the necessary properties for upload. */ export declare const isValidUploadTagImagePayload: (payload?: Partial<S3UploadPayload>) => payload is S3UploadPayload; export declare const resizeAndSaveVariants: ({ client, tag, imageType, resizeHost, maxRetries, folder, }: { client: S3Client; tag: Tag; imageType: "mystery" | "found"; resizeHost?: string; maxRetries?: number; folder?: string; }) => Promise<string>; export declare const encodeMetadataValue: (value: string) => string; export declare const decodeMetadataValue: (value: string) => string; export declare const normalizeUploadBody: (stream: string | Blob | ReadableStream | Uint8Array | Buffer | Readable | File) => Promise<Uint8Array | Buffer>; export declare const getGroupedTagsByPlayer: (groupedImages?: S3ImageMeta[][], appendToTagData?: {}, cache?: typeof TinyCache) => any[]; export declare const getGroupedImagesByTagnumber: (ungroupedImages?: S3ImageMeta[], cache?: typeof TinyCache) => S3ImageMeta[][]; export declare const getKeyFromUrl: (urlStr: string) => string; export declare const moveImage: (client: S3Client, bucket: string, sourceKey: string, destinationKey: string, moveVariants?: boolean) => Promise<{ success: boolean; error?: string; }>; export declare const getHashedPlayerSuffix: (playerId: string) => Promise<string>; export declare const getMysteryMetadata: (tag: Tag, metadataOverrides?: Record<string, any>) => string; export declare const getFoundMetadata: (tag: Tag, metadataOverrides?: Record<string, any>) => string; export declare const getTagMetadata: (metadata: string | undefined, metadataOverrides?: Record<string, any>) => Tag; export declare const isMysteryImage: (image: S3ImageMeta) => boolean; export declare const isFoundImage: (image: S3ImageMeta) => boolean; export interface S3UploadPayload { region: string; game: string; folder: string; tagnumber: number; image: Buffer | Uint8Array | Blob | string | File; filenameSuffix?: string; contentType?: string; resize?: boolean; } export type uploadTagImagePayload = Partial<Tag> & Partial<S3UploadPayload> & CommonPayloadData; export type queueTagPayload = Partial<Tag> & Partial<S3UploadPayload> & CommonPayloadData; export type updateTagPayload = Partial<Tag> & Partial<S3UploadPayload> & CommonPayloadData; export declare const supportedImageExtensions: string[];