1
0
Fork 0

feat: adds streaming download and upload for gcs provider

pull/1716/head
Prajjwal 2024-04-11 11:12:08 +05:30
parent 1fc87f92d9
commit 917853e23b
54 changed files with 2457 additions and 295 deletions

View File

@ -12,7 +12,7 @@ import {
import * as tar from '../src/internal/tar'
import * as utils from '../src/internal/cacheUtils'
// eslint-disable-next-line @typescript-eslint/no-require-imports
import fs = require('fs')
import fs from 'fs'
jest.mock('@actions/exec')
jest.mock('@actions/io')

View File

@ -106,26 +106,29 @@ export async function restoreCache(
return undefined
}
if (options?.lookupOnly) {
core.info('Lookup only - skipping download')
return cacheEntry?.cache_key
}
archivePath = path.join(
await utils.createTempDirectory(),
utils.getCacheFileName(compressionMethod)
)
core.debug(`Archive Path: ${archivePath}`)
let cacheKey: string = ''
switch (cacheEntry.provider) {
case 's3': {
if (!cacheEntry.pre_signed_url) {
// Cache not found
if (!cacheEntry.s3?.pre_signed_url) {
return undefined
}
cacheKey = cacheEntry.s3.pre_signed_url
if (options?.lookupOnly) {
core.info('Lookup only - skipping download')
return cacheKey
}
await cacheHttpClient.downloadCache(
cacheEntry.pre_signed_url,
cacheEntry.s3?.pre_signed_url,
archivePath
)
@ -146,12 +149,23 @@ export async function restoreCache(
}
case 'gcs': {
if (!cacheEntry.gcs?.cache_key) {
return undefined
}
cacheKey = cacheEntry.gcs?.cache_key
if (options?.lookupOnly) {
core.info('Lookup only - skipping download')
return cacheKey
}
// For GCS, we do a streaming download which means that we extract the archive while we are downloading it.
const archiveLocation = cacheEntry.archive_location ?? ''
const archiveLocation = `gs://${cacheEntry.gcs?.bucket_name}/${cacheEntry.gcs?.cache_key}`
const readStream = cacheHttpClient.downloadCacheStreaming(
'gcs',
archiveLocation
archiveLocation,
cacheEntry?.gcs?.short_lived_token?.access_token ?? ''
)
if (!readStream) {
@ -164,7 +178,7 @@ export async function restoreCache(
}
}
return cacheEntry.cache_key
return cacheKey
} catch (error) {
const typedError = error as Error
if (typedError.name === ValidationError.name) {
@ -228,21 +242,20 @@ export async function saveCache(
if (core.isDebug()) {
await listTar(archivePath, compressionMethod)
}
const fileSizeLimit = 20 * 1024 * 1024 * 1024 // 20GB per repo limit
const fileSizeLimit = 1000 * 1024 * 1024 * 1024 // 1000GB per repo limit
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath)
core.debug(`File Size: ${archiveFileSize}`)
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
if (archiveFileSize > fileSizeLimit) {
throw new Error(
`Cache size of ~${Math.round(
archiveFileSize / (1024 * 1024)
)} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`
)} MB (${archiveFileSize} B) is over the 1000GB limit, not saving cache.`
)
}
core.debug('Reserving Cache')
// Calculate number of chunks required
// Calculate number of chunks required. This is only required if backend is S3 as Google Cloud SDK will do it for us
const uploadOptions = getUploadOptions()
const maxChunkSize = uploadOptions?.uploadChunkSize ?? 32 * 1024 * 1024 // Default 32MB
const numberOfChunks = Math.floor(archiveFileSize / maxChunkSize)
@ -265,20 +278,46 @@ export async function saveCache(
)
}
core.debug(`Saving Cache`)
cacheKey = await cacheHttpClient.saveCache(
key,
cacheHttpClient.getCacheVersion(
paths,
compressionMethod,
enableCrossOsArchive
),
reserveCacheResponse?.result?.upload_id ?? '',
reserveCacheResponse?.result?.upload_key ?? '',
numberOfChunks,
reserveCacheResponse?.result?.pre_signed_urls ?? [],
archivePath
const cacheVersion = cacheHttpClient.getCacheVersion(
paths,
compressionMethod,
enableCrossOsArchive
)
switch (reserveCacheResponse.result?.provider) {
case 's3':
core.debug(`Saving Cache to S3`)
cacheKey = await cacheHttpClient.saveCache(
's3',
key,
cacheVersion,
archivePath,
reserveCacheResponse?.result?.s3?.upload_id ?? '',
reserveCacheResponse?.result?.s3?.upload_key ?? '',
numberOfChunks,
reserveCacheResponse?.result?.s3?.pre_signed_urls ?? []
)
break
case 'gcs':
core.debug(`Saving Cache to GCS`)
cacheKey = await cacheHttpClient.saveCache(
'gcs',
key,
cacheVersion,
archivePath,
// S3 Params are undefined for GCS
undefined,
undefined,
undefined,
undefined,
reserveCacheResponse?.result?.gcs?.short_lived_token?.access_token ??
'',
reserveCacheResponse?.result?.gcs?.bucket_name ?? '',
reserveCacheResponse?.result?.gcs?.cache_key ?? ''
)
break
}
} catch (error) {
const typedError = error as Error
if (typedError.name === ValidationError.name) {

View File

@ -6,27 +6,28 @@ import {
TypedResponse
} from '@actions/http-client/lib/interfaces'
import * as crypto from 'crypto'
import * as fs from 'fs'
import * as utils from './cacheUtils'
import {CompressionMethod} from './constants'
import {
ArtifactCacheEntry,
InternalCacheOptions,
CommitCacheRequest,
ReserveCacheRequest,
ReserveCacheResponse,
ITypedResponseWithError,
ArtifactCacheList,
InternalS3CompletedPart,
CommitCacheResponse
InternalS3CompletedPart
} from './contracts'
import {
downloadCacheMultiConnection,
downloadCacheStreamingGCP
} from './downloadUtils'
import {isSuccessStatusCode, retryTypedResponse} from './requestUtils'
import axios, {AxiosError} from 'axios'
import {Storage} from '@google-cloud/storage'
import {
CommonsCommitCacheRequest,
CommonsCommitCacheResponse,
CommonsGetCacheResponse,
CommonsReserveCacheRequest,
CommonsReserveCacheResponse
} from './warpcache-ts-sdk'
import {multiPartUploadToGCS, uploadFileToS3} from './uploadUtils'
const versionSalt = '1.0'
@ -37,9 +38,7 @@ function getCacheApiUrl(resource: string): string {
throw new Error('Cache Service Url not found, unable to restore cache.')
}
const provider: string = process.env['STORAGE_PROVIDER'] ?? 'gcs'
const url = `${baseUrl}/v1/${resource}/${provider}`
const url = `${baseUrl}/v1/${resource}`
core.debug(`Resource Url: ${url}`)
return url
}
@ -97,7 +96,7 @@ export async function getCacheEntry(
keys: string[],
paths: string[],
options?: InternalCacheOptions
): Promise<ArtifactCacheEntry | null> {
): Promise<CommonsGetCacheResponse | null> {
const httpClient = createHttpClient()
const version = getCacheVersion(
paths,
@ -109,14 +108,14 @@ export async function getCacheEntry(
)}&version=${version}`
const response = await retryTypedResponse('getCacheEntry', async () =>
httpClient.getJson<ArtifactCacheEntry>(getCacheApiUrl(resource))
httpClient.getJson<CommonsGetCacheResponse>(getCacheApiUrl(resource))
)
if (response.statusCode === 204) {
// List cache for primary key only if cache miss occurs
if (core.isDebug()) {
await printCachesListForDiagnostics(keys[0], httpClient, version)
}
// TODO: List cache for primary key only if cache miss occurs
// if (core.isDebug()) {
// await printCachesListForDiagnostics(keys[0], httpClient, version)
// }
return null
}
if (!isSuccessStatusCode(response.statusCode)) {
@ -124,18 +123,13 @@ export async function getCacheEntry(
}
const cacheResult = response.result
const cacheDownloadUrl = cacheResult?.archive_location
if (!cacheDownloadUrl) {
// Cache archiveLocation not found. This should never happen, and hence bail out.
throw new Error('Cache not found.')
}
core.setSecret(cacheDownloadUrl)
core.debug(`Cache Result:`)
core.debug(JSON.stringify(cacheResult))
return cacheResult
}
/*
async function printCachesListForDiagnostics(
key: string,
httpClient: HttpClient,
@ -160,6 +154,7 @@ async function printCachesListForDiagnostics(
}
}
}
*/
export async function downloadCache(
archiveLocation: string,
@ -170,13 +165,23 @@ export async function downloadCache(
export function downloadCacheStreaming(
provider: string,
archiveLocation: string
archiveLocation: string,
gcsToken?: string
): NodeJS.ReadableStream | undefined {
switch (provider) {
case 's3':
return undefined
case 'gcs':
return downloadCacheStreamingGCP(archiveLocation)
case 'gcs': {
if (!gcsToken) {
throw new Error(
'Unable to download cache from GCS. GCP token is not provided.'
)
}
const storage = new Storage({
token: gcsToken
})
return downloadCacheStreamingGCP(storage, archiveLocation)
}
default:
return undefined
}
@ -186,16 +191,16 @@ export async function reserveCache(
cacheKey: string,
numberOfChunks: number,
options?: InternalCacheOptions
): Promise<ITypedResponseWithError<ReserveCacheResponse>> {
): Promise<ITypedResponseWithError<CommonsReserveCacheResponse>> {
const httpClient = createHttpClient()
const reserveCacheRequest: ReserveCacheRequest = {
const reserveCacheRequest: CommonsReserveCacheRequest = {
cache_key: cacheKey,
number_of_chunks: numberOfChunks,
content_type: 'application/zstd'
}
const response = await retryTypedResponse('reserveCache', async () =>
httpClient.postJson<ReserveCacheResponse>(
httpClient.postJson<CommonsReserveCacheResponse>(
getCacheApiUrl('cache/reserve'),
reserveCacheRequest
)
@ -203,114 +208,20 @@ export async function reserveCache(
return response
}
function getContentRange(start: number, end: number): string {
// Format: `bytes start-end/filesize
// start and end are inclusive
// filesize can be *
// For a 200 byte chunk starting at byte 0:
// Content-Range: bytes 0-199/*
return `bytes ${start}-${end}/*`
}
async function uploadChunk(
resourceUrl: string,
openStream: () => NodeJS.ReadableStream,
partNumber: number,
start: number,
end: number
): Promise<InternalS3CompletedPart> {
core.debug(
`Uploading chunk of size ${
end - start + 1
} bytes at offset ${start} with content range: ${getContentRange(
start,
end
)}`
)
// Manually convert the readable stream to a buffer. S3 doesn't allow stream as input
const chunks = await utils.streamToBuffer(openStream())
try {
// HACK: Using axios here as S3 API doesn't allow readable stream as input and Github's HTTP client is not able to send buffer as body
const response = await axios.request({
method: 'PUT',
url: resourceUrl,
headers: {
'Content-Type': 'application/octet-stream'
},
data: chunks
})
return {
ETag: response.headers.etag ?? '',
PartNumber: partNumber
}
} catch (error) {
throw new Error(
`Cache service responded with ${
(error as AxiosError).status
} during upload chunk.`
)
}
}
async function uploadFileToS3(
preSignedURLs: string[],
archivePath: string
): Promise<InternalS3CompletedPart[]> {
const fileSize = utils.getArchiveFileSizeInBytes(archivePath)
const numberOfChunks = preSignedURLs.length
const fd = fs.openSync(archivePath, 'r')
core.debug('Awaiting all uploads')
let offset = 0
try {
const completedParts = await Promise.all(
preSignedURLs.map(async (presignedURL, index) => {
const chunkSize = Math.ceil(fileSize / numberOfChunks)
const start = offset
const end = offset + chunkSize - 1
offset += chunkSize
return await uploadChunk(
presignedURL,
() =>
fs
.createReadStream(archivePath, {
fd,
start,
end,
autoClose: false
})
.on('error', error => {
throw new Error(
`Cache upload failed because file read failed with ${error.message}`
)
}),
index + 1,
start,
end
)
})
)
return completedParts
} finally {
fs.closeSync(fd)
}
}
async function commitCache(
httpClient: HttpClient,
cacheKey: string,
cacheVersion: string,
uploadKey: string,
uploadID: string,
parts: InternalS3CompletedPart[]
): Promise<TypedResponse<CommitCacheResponse>> {
const commitCacheRequest: CommitCacheRequest = {
uploadKey?: string,
uploadID?: string,
parts?: InternalS3CompletedPart[]
): Promise<TypedResponse<CommonsCommitCacheResponse>> {
const httpClient = createHttpClient()
if (!parts) {
parts = []
}
const commitCacheRequest: CommonsCommitCacheRequest = {
cache_key: cacheKey,
cache_version: cacheVersion,
upload_key: uploadKey,
@ -320,7 +231,7 @@ async function commitCache(
vcs_type: 'github'
}
return await retryTypedResponse('commitCache', async () =>
httpClient.postJson<CommitCacheResponse>(
httpClient.postJson<CommonsCommitCacheResponse>(
getCacheApiUrl(`cache/commit`),
commitCacheRequest
)
@ -328,43 +239,97 @@ async function commitCache(
}
export async function saveCache(
provider: string,
cacheKey: string,
cacheVersion: string,
uploadId: string,
uploadKey: string,
numberOfChunks: number,
preSignedURLs: string[],
archivePath: string
archivePath: string,
S3UploadId?: string,
S3UploadKey?: string,
S3NumberOfChunks?: number,
S3PreSignedURLs?: string[],
GCSAuthToken?: string,
GCSBucketName?: string,
GCSObjectName?: string
): Promise<string> {
// Number of chunks should match the number of pre-signed URLs
if (numberOfChunks !== preSignedURLs.length) {
throw new Error(
`Number of chunks (${numberOfChunks}) should match the number of pre-signed URLs (${preSignedURLs.length}).`
)
}
const httpClient = createHttpClient()
core.debug('Upload cache')
const completedParts = await uploadFileToS3(preSignedURLs, archivePath)
// Sort parts in ascending order by partNumber
completedParts.sort((a, b) => a.PartNumber - b.PartNumber)
core.debug('Committing cache')
const cacheSize = utils.getArchiveFileSizeInBytes(archivePath)
core.info(
`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`
)
const commitCacheResponse = await commitCache(
httpClient,
cacheKey,
cacheVersion,
uploadKey,
uploadId,
completedParts
)
let commitCacheResponse: TypedResponse<CommonsCommitCacheResponse> = {
headers: {},
statusCode: 0,
result: null
}
let cacheKeyResponse = ''
switch (provider) {
case 's3': {
if (
!S3NumberOfChunks ||
!S3PreSignedURLs ||
!S3UploadId ||
!S3UploadKey
) {
throw new Error(
'Unable to upload cache to S3. One of the following required parameters is missing: numberOfChunks, preSignedURLs, uploadId, uploadKey.'
)
}
// Number of chunks should match the number of pre-signed URLs
if (S3NumberOfChunks !== S3PreSignedURLs.length) {
throw new Error(
`Number of chunks (${S3NumberOfChunks}) should match the number of pre-signed URLs (${S3PreSignedURLs.length}).`
)
}
core.debug('Uploading cache')
const completedParts = await uploadFileToS3(S3PreSignedURLs, archivePath)
// Sort parts in ascending order by partNumber
completedParts.sort((a, b) => a.PartNumber - b.PartNumber)
core.debug('Committing cache')
commitCacheResponse = await commitCache(
cacheKey,
cacheVersion,
S3UploadKey,
S3UploadId,
completedParts
)
cacheKeyResponse = commitCacheResponse.result?.s3?.cache_key ?? ''
break
}
case 'gcs': {
if (!GCSBucketName || !GCSObjectName || !GCSAuthToken) {
throw new Error(
'Unable to upload cache to GCS. One of the following required parameters is missing: GCSBucketName, GCSObjectName, GCSAuthToken.'
)
}
core.debug('Uploading cache')
const storage = new Storage({
token: GCSAuthToken
})
await multiPartUploadToGCS(
storage,
archivePath,
GCSBucketName,
GCSObjectName
)
core.debug('Committing cache')
commitCacheResponse = await commitCache(cacheKey, cacheVersion)
cacheKeyResponse = commitCacheResponse.result?.gcs?.cache_key ?? ''
break
}
}
if (!isSuccessStatusCode(commitCacheResponse.statusCode)) {
throw new Error(
`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`
@ -372,7 +337,7 @@ export async function saveCache(
}
core.info('Cache saved successfully')
return commitCacheResponse.result?.cache_key ?? ''
return cacheKeyResponse
}
export async function deleteCache(keys: string[]) {

View File

@ -146,3 +146,28 @@ export function streamToBuffer(stream: NodeJS.ReadableStream): Promise<Buffer> {
stream.on('end', () => resolve(Buffer.concat(buffer)))
})
}
/*
* Retrieve the bucket name and object name from the GCS URL
* @param gcsURL - The URL for the cache in the format gs://<bucket-name>/<object-name>
*/
export function retrieveGCSBucketAndObjectName(gcsURL: string): {
bucketName: string
objectName: string
} {
const bucketName = gcsURL.split('/')[2]
if (!bucketName || bucketName.length < 2) {
throw new Error(
`Invalid GCS URL: ${gcsURL}. Should be in the format gs://<bucket-name>/<object-name>`
)
}
const objectName = gcsURL.split('/').slice(3).join('/')
if (!objectName || objectName.length < 1) {
throw new Error(
`Invalid GCS URL: ${gcsURL}. Should be in the format gs://<bucket-name>/<object-name>`
)
}
return {bucketName, objectName}
}

View File

@ -6,47 +6,6 @@ export interface ITypedResponseWithError<T> extends TypedResponse<T> {
error?: HttpClientError
}
export interface ArtifactCacheEntry {
provider: string
auth_method: string
cache_key?: string
archive_location?: string
pre_signed_url?: string
cache_version?: string
}
export interface ArtifactCacheList {
totalCount: number
artifactCaches?: ArtifactCacheEntry[]
}
export interface CommitCacheRequest {
cache_key: string
cache_version: string
upload_key: string
upload_id: string
parts: InternalS3CompletedPart[]
os: string
vcs_type: string
}
export interface CommitCacheResponse {
cache_key: string
cache_version: string
}
export interface ReserveCacheRequest {
cache_key: string
content_type: string
number_of_chunks: number
}
export interface ReserveCacheResponse {
pre_signed_urls: string[]
upload_key: string
upload_id: string
}
export interface InternalCacheOptions {
compressionMethod?: CompressionMethod
enableCrossOsArchive?: boolean

View File

@ -300,37 +300,23 @@ export async function downloadCacheMultiConnection(
* @param archiveLocation the URL for the cache
*/
export function downloadCacheStreamingGCP(
storage: Storage,
archiveLocation: string
): NodeJS.ReadableStream | undefined {
try {
const storage = new Storage({
token: process.env['GCP_ACCESS_TOKEN']
})
// The archiveLocation for GCP will be in the format of gs://<bucket-name>/<object-name>
const bucketName = archiveLocation.split('/')[2]
if (!bucketName || bucketName.length < 2) {
throw new Error(
`Invalid GCS URL: ${archiveLocation}. Should be in the format gs://<bucket-name>/<object-name>`
)
}
const fileName = archiveLocation.split('/').slice(3).join('/')
if (!fileName || fileName.length < 1) {
throw new Error(
`Invalid GCS URL: ${archiveLocation}. Should be in the format gs://<bucket-name>/<object-name>`
)
}
const {bucketName, objectName} =
utils.retrieveGCSBucketAndObjectName(archiveLocation)
storage
.bucket(bucketName)
.file(fileName)
.file(objectName)
.getMetadata()
.then(data => {
core.info(`File size: ${data[0]?.size} bytes`)
})
return storage.bucket(bucketName).file(fileName).createReadStream()
return storage.bucket(bucketName).file(objectName).createReadStream()
} catch (error) {
core.debug(`Failed to download cache: ${error}`)
core.error(`Failed to download cache.`)

View File

@ -413,7 +413,9 @@ export async function extractTar(
await execCommands(commands)
}
// Supports only archives created using tar and zstd
/*
* NOTE: Currently tested only on archives created using tar and zstd
*/
export async function extractStreamingTar(
stream: NodeJS.ReadableStream,
archivePath: string,
@ -466,7 +468,6 @@ export async function extractStreamingTar(
})
}
// Create a tar
export async function createTar(
archiveFolder: string,
sourceDirectories: string[],

View File

@ -0,0 +1,131 @@
import * as core from '@actions/core'
import * as utils from './cacheUtils'
import fs from 'fs'
import axios, {AxiosError} from 'axios'
import {InternalS3CompletedPart} from './contracts'
import {Storage, TransferManager} from '@google-cloud/storage'
function getContentRange(start: number, end: number): string {
// Format: `bytes start-end/filesize
// start and end are inclusive
// filesize can be *
// For a 200 byte chunk starting at byte 0:
// Content-Range: bytes 0-199/*
return `bytes ${start}-${end}/*`
}
async function uploadChunk(
resourceUrl: string,
openStream: () => NodeJS.ReadableStream,
partNumber: number,
start: number,
end: number
): Promise<InternalS3CompletedPart> {
core.debug(
`Uploading chunk of size ${
end - start + 1
} bytes at offset ${start} with content range: ${getContentRange(
start,
end
)}`
)
// Manually convert the readable stream to a buffer. S3 doesn't allow stream as input
const chunks = await utils.streamToBuffer(openStream())
try {
// HACK: Using axios here as S3 API doesn't allow readable stream as input and Github's HTTP client is not able to send buffer as body
const response = await axios.request({
method: 'PUT',
url: resourceUrl,
headers: {
'Content-Type': 'application/octet-stream'
},
data: chunks
})
return {
ETag: response.headers.etag ?? '',
PartNumber: partNumber
}
} catch (error) {
throw new Error(
`Cache service responded with ${
(error as AxiosError).status
} during upload chunk.`
)
}
}
export async function uploadFileToS3(
preSignedURLs: string[],
archivePath: string
): Promise<InternalS3CompletedPart[]> {
const fileSize = utils.getArchiveFileSizeInBytes(archivePath)
const numberOfChunks = preSignedURLs.length
const fd = fs.openSync(archivePath, 'r')
core.debug('Awaiting all uploads')
let offset = 0
try {
const completedParts = await Promise.all(
preSignedURLs.map(async (presignedURL, index) => {
const chunkSize = Math.ceil(fileSize / numberOfChunks)
const start = offset
const end = offset + chunkSize - 1
offset += chunkSize
return await uploadChunk(
presignedURL,
() =>
fs
.createReadStream(archivePath, {
fd,
start,
end,
autoClose: false
})
.on('error', error => {
throw new Error(
`Cache upload failed because file read failed with ${error.message}`
)
}),
index + 1,
start,
end
)
})
)
return completedParts
} finally {
fs.closeSync(fd)
}
}
/*
* Uploads the cache to GCS
* @param localArchivePath - The path to the cache archive
* @param bucketName - The name of the bucket in GCS
* @param objectName - The name of the object in GCS
*/
export async function multiPartUploadToGCS(
storage: Storage,
localArchivePath: string,
bucketName: string,
objectName: string
) {
try {
const transferManager = new TransferManager(storage.bucket(bucketName))
await transferManager.uploadFileInChunks(localArchivePath, {
uploadName: objectName
})
} catch (error) {
throw new Error(`Failed to upload to GCS: ${error}`)
}
}

View File

@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -0,0 +1,31 @@
.gitignore
.npmignore
.openapi-generator-ignore
README.md
api.ts
api/default-api.ts
base.ts
common.ts
configuration.ts
git_push.sh
index.ts
models/commons-commit-cache-request.ts
models/commons-commit-cache-response.ts
models/commons-delete-cache-response.ts
models/commons-gcscommit-cache-response.ts
models/commons-gcsget-cache-reponse.ts
models/commons-gcsreserve-cache-response.ts
models/commons-get-cache-response.ts
models/commons-reserve-cache-request.ts
models/commons-reserve-cache-response.ts
models/commons-s3-commit-cache-response.ts
models/commons-s3-delete-cache-response.ts
models/commons-s3-get-cache-response.ts
models/commons-s3-reserve-cache-response.ts
models/commons-short-lived-token.ts
models/index.ts
models/types-completed-part.ts
models/warp-build-apierror.ts
package.json
tsconfig.esm.json
tsconfig.json

View File

@ -0,0 +1,18 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export * from './api/default-api';

View File

@ -0,0 +1,493 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import { CommonsCommitCacheRequest } from '../models';
// @ts-ignore
import { CommonsCommitCacheResponse } from '../models';
// @ts-ignore
import { CommonsDeleteCacheResponse } from '../models';
// @ts-ignore
import { CommonsGetCacheResponse } from '../models';
// @ts-ignore
import { CommonsReserveCacheRequest } from '../models';
// @ts-ignore
import { CommonsReserveCacheResponse } from '../models';
// @ts-ignore
import { WarpBuildAPIError } from '../models';
/**
* DefaultApi - axios parameter creator
* @export
*/
export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
* do ping
* @summary pings the api
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
pingGet: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/ping`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* commit cache
* @summary commit cache
* @param {CommonsCommitCacheRequest} body Commit Cache Request Body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
v1CacheCommitPost: async (body: CommonsCommitCacheRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'body' is not null or undefined
assertParamExists('v1CacheCommitPost', 'body', body)
const localVarPath = `/v1/cache/commit`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* delete cache
* @summary delete cache
* @param {string} keys cache keys
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
v1CacheDeleteDelete: async (keys: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'keys' is not null or undefined
assertParamExists('v1CacheDeleteDelete', 'keys', keys)
const localVarPath = `/v1/cache/delete`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
if (keys !== undefined) {
localVarQueryParameter['keys'] = keys;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* get cache
* @summary get cache
* @param {string} keys cache keys
* @param {string} version cache version
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
v1CacheGet: async (keys: string, version: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'keys' is not null or undefined
assertParamExists('v1CacheGet', 'keys', keys)
// verify required parameter 'version' is not null or undefined
assertParamExists('v1CacheGet', 'version', version)
const localVarPath = `/v1/cache`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
if (keys !== undefined) {
localVarQueryParameter['keys'] = keys;
}
if (version !== undefined) {
localVarQueryParameter['version'] = version;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* reserve cache
* @summary reserve cache
* @param {CommonsReserveCacheRequest} body Reserve Cache Request Body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
v1CacheReservePost: async (body: CommonsReserveCacheRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'body' is not null or undefined
assertParamExists('v1CacheReservePost', 'body', body)
const localVarPath = `/v1/cache/reserve`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
}
};
/**
* DefaultApi - functional programming interface
* @export
*/
export const DefaultApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = DefaultApiAxiosParamCreator(configuration)
return {
/**
* do ping
* @summary pings the api
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async pingGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<string>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.pingGet(options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['DefaultApi.pingGet']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* commit cache
* @summary commit cache
* @param {CommonsCommitCacheRequest} body Commit Cache Request Body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async v1CacheCommitPost(body: CommonsCommitCacheRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CommonsCommitCacheResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.v1CacheCommitPost(body, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['DefaultApi.v1CacheCommitPost']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* delete cache
* @summary delete cache
* @param {string} keys cache keys
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async v1CacheDeleteDelete(keys: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CommonsDeleteCacheResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.v1CacheDeleteDelete(keys, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['DefaultApi.v1CacheDeleteDelete']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* get cache
* @summary get cache
* @param {string} keys cache keys
* @param {string} version cache version
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async v1CacheGet(keys: string, version: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CommonsGetCacheResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.v1CacheGet(keys, version, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['DefaultApi.v1CacheGet']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* reserve cache
* @summary reserve cache
* @param {CommonsReserveCacheRequest} body Reserve Cache Request Body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async v1CacheReservePost(body: CommonsReserveCacheRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CommonsReserveCacheResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.v1CacheReservePost(body, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['DefaultApi.v1CacheReservePost']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};
/**
* DefaultApi - factory interface
* @export
*/
export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = DefaultApiFp(configuration)
return {
/**
* do ping
* @summary pings the api
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
pingGet(options?: RawAxiosRequestConfig): AxiosPromise<string> {
return localVarFp.pingGet(options).then((request) => request(axios, basePath));
},
/**
* commit cache
* @summary commit cache
* @param {DefaultApiV1CacheCommitPostRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
v1CacheCommitPost(requestParameters: DefaultApiV1CacheCommitPostRequest, options?: RawAxiosRequestConfig): AxiosPromise<CommonsCommitCacheResponse> {
return localVarFp.v1CacheCommitPost(requestParameters.body, options).then((request) => request(axios, basePath));
},
/**
* delete cache
* @summary delete cache
* @param {DefaultApiV1CacheDeleteDeleteRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
v1CacheDeleteDelete(requestParameters: DefaultApiV1CacheDeleteDeleteRequest, options?: RawAxiosRequestConfig): AxiosPromise<CommonsDeleteCacheResponse> {
return localVarFp.v1CacheDeleteDelete(requestParameters.keys, options).then((request) => request(axios, basePath));
},
/**
* get cache
* @summary get cache
* @param {DefaultApiV1CacheGetRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
v1CacheGet(requestParameters: DefaultApiV1CacheGetRequest, options?: RawAxiosRequestConfig): AxiosPromise<CommonsGetCacheResponse> {
return localVarFp.v1CacheGet(requestParameters.keys, requestParameters.version, options).then((request) => request(axios, basePath));
},
/**
* reserve cache
* @summary reserve cache
* @param {DefaultApiV1CacheReservePostRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
v1CacheReservePost(requestParameters: DefaultApiV1CacheReservePostRequest, options?: RawAxiosRequestConfig): AxiosPromise<CommonsReserveCacheResponse> {
return localVarFp.v1CacheReservePost(requestParameters.body, options).then((request) => request(axios, basePath));
},
};
};
/**
* Request parameters for v1CacheCommitPost operation in DefaultApi.
* @export
* @interface DefaultApiV1CacheCommitPostRequest
*/
export interface DefaultApiV1CacheCommitPostRequest {
/**
* Commit Cache Request Body
* @type {CommonsCommitCacheRequest}
* @memberof DefaultApiV1CacheCommitPost
*/
readonly body: CommonsCommitCacheRequest
}
/**
* Request parameters for v1CacheDeleteDelete operation in DefaultApi.
* @export
* @interface DefaultApiV1CacheDeleteDeleteRequest
*/
export interface DefaultApiV1CacheDeleteDeleteRequest {
/**
* cache keys
* @type {string}
* @memberof DefaultApiV1CacheDeleteDelete
*/
readonly keys: string
}
/**
* Request parameters for v1CacheGet operation in DefaultApi.
* @export
* @interface DefaultApiV1CacheGetRequest
*/
export interface DefaultApiV1CacheGetRequest {
/**
* cache keys
* @type {string}
* @memberof DefaultApiV1CacheGet
*/
readonly keys: string
/**
* cache version
* @type {string}
* @memberof DefaultApiV1CacheGet
*/
readonly version: string
}
/**
* Request parameters for v1CacheReservePost operation in DefaultApi.
* @export
* @interface DefaultApiV1CacheReservePostRequest
*/
export interface DefaultApiV1CacheReservePostRequest {
/**
* Reserve Cache Request Body
* @type {CommonsReserveCacheRequest}
* @memberof DefaultApiV1CacheReservePost
*/
readonly body: CommonsReserveCacheRequest
}
/**
* DefaultApi - object-oriented interface
* @export
* @class DefaultApi
* @extends {BaseAPI}
*/
export class DefaultApi extends BaseAPI {
/**
* do ping
* @summary pings the api
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public pingGet(options?: RawAxiosRequestConfig) {
return DefaultApiFp(this.configuration).pingGet(options).then((request) => request(this.axios, this.basePath));
}
/**
* commit cache
* @summary commit cache
* @param {DefaultApiV1CacheCommitPostRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public v1CacheCommitPost(requestParameters: DefaultApiV1CacheCommitPostRequest, options?: RawAxiosRequestConfig) {
return DefaultApiFp(this.configuration).v1CacheCommitPost(requestParameters.body, options).then((request) => request(this.axios, this.basePath));
}
/**
* delete cache
* @summary delete cache
* @param {DefaultApiV1CacheDeleteDeleteRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public v1CacheDeleteDelete(requestParameters: DefaultApiV1CacheDeleteDeleteRequest, options?: RawAxiosRequestConfig) {
return DefaultApiFp(this.configuration).v1CacheDeleteDelete(requestParameters.keys, options).then((request) => request(this.axios, this.basePath));
}
/**
* get cache
* @summary get cache
* @param {DefaultApiV1CacheGetRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public v1CacheGet(requestParameters: DefaultApiV1CacheGetRequest, options?: RawAxiosRequestConfig) {
return DefaultApiFp(this.configuration).v1CacheGet(requestParameters.keys, requestParameters.version, options).then((request) => request(this.axios, this.basePath));
}
/**
* reserve cache
* @summary reserve cache
* @param {DefaultApiV1CacheReservePostRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public v1CacheReservePost(requestParameters: DefaultApiV1CacheReservePostRequest, options?: RawAxiosRequestConfig) {
return DefaultApiFp(this.configuration).v1CacheReservePost(requestParameters.body, options).then((request) => request(this.axios, this.basePath));
}
}

View File

@ -0,0 +1,86 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import type { Configuration } from './configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
/**
*
* @export
*/
export const COLLECTION_FORMATS = {
csv: ",",
ssv: " ",
tsv: "\t",
pipes: "|",
};
/**
*
* @export
* @interface RequestArgs
*/
export interface RequestArgs {
url: string;
options: RawAxiosRequestConfig;
}
/**
*
* @export
* @class BaseAPI
*/
export class BaseAPI {
protected configuration: Configuration | undefined;
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
if (configuration) {
this.configuration = configuration;
this.basePath = configuration.basePath ?? basePath;
}
}
};
/**
*
* @export
* @class RequiredError
* @extends {Error}
*/
export class RequiredError extends Error {
constructor(public field: string, msg?: string) {
super(msg);
this.name = "RequiredError"
}
}
interface ServerMap {
[key: string]: {
url: string,
description: string,
}[];
}
/**
*
* @export
*/
export const operationServerMap: ServerMap = {
}

View File

@ -0,0 +1,150 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import type { Configuration } from "./configuration";
import type { RequestArgs } from "./base";
import type { AxiosInstance, AxiosResponse } from 'axios';
import { RequiredError } from "./base";
/**
*
* @export
*/
export const DUMMY_BASE_URL = 'https://example.com'
/**
*
* @throws {RequiredError}
* @export
*/
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
if (paramValue === null || paramValue === undefined) {
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
}
}
/**
*
* @export
*/
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
if (configuration && configuration.apiKey) {
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
? await configuration.apiKey(keyParamName)
: await configuration.apiKey;
object[keyParamName] = localVarApiKeyValue;
}
}
/**
*
* @export
*/
export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
if (configuration && (configuration.username || configuration.password)) {
object["auth"] = { username: configuration.username, password: configuration.password };
}
}
/**
*
* @export
*/
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? await configuration.accessToken()
: await configuration.accessToken;
object["Authorization"] = "Bearer " + accessToken;
}
}
/**
*
* @export
*/
export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? await configuration.accessToken(name, scopes)
: await configuration.accessToken;
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
}
}
function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
if (parameter == null) return;
if (typeof parameter === "object") {
if (Array.isArray(parameter)) {
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
}
else {
Object.keys(parameter).forEach(currentKey =>
setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
);
}
}
else {
if (urlSearchParams.has(key)) {
urlSearchParams.append(key, parameter);
}
else {
urlSearchParams.set(key, parameter);
}
}
}
/**
*
* @export
*/
export const setSearchParams = function (url: URL, ...objects: any[]) {
const searchParams = new URLSearchParams(url.search);
setFlattenedQueryParams(searchParams, objects);
url.search = searchParams.toString();
}
/**
*
* @export
*/
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
const nonString = typeof value !== 'string';
const needsSerialization = nonString && configuration && configuration.isJsonMime
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
: nonString;
return needsSerialization
? JSON.stringify(value !== undefined ? value : {})
: (value || "");
}
/**
*
* @export
*/
export const toPathString = function (url: URL) {
return url.pathname + url.search + url.hash
}
/**
*
* @export
*/
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
return axios.request<T, R>(axiosRequestArgs);
};
}

View File

@ -0,0 +1,110 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
username?: string;
password?: string;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string;
serverIndex?: number;
baseOptions?: any;
formDataCtor?: new () => any;
}
export class Configuration {
/**
* parameter for apiKey security
* @param name security name
* @memberof Configuration
*/
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
username?: string;
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
password?: string;
/**
* parameter for oauth2 security
* @param name security name
* @param scopes oauth2 scope
* @memberof Configuration
*/
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
/**
* override base path
*
* @type {string}
* @memberof Configuration
*/
basePath?: string;
/**
* override server index
*
* @type {number}
* @memberof Configuration
*/
serverIndex?: number;
/**
* base options for axios calls
*
* @type {any}
* @memberof Configuration
*/
baseOptions?: any;
/**
* The FormData constructor that will be used to create multipart form data
* requests. You can inject this here so that execution environments that
* do not support the FormData class can still run the generated client.
*
* @type {new () => FormData}
*/
formDataCtor?: new () => any;
constructor(param: ConfigurationParameters = {}) {
this.apiKey = param.apiKey;
this.username = param.username;
this.password = param.password;
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.formDataCtor = param.formDataCtor;
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
}
}

View File

@ -0,0 +1,21 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export * from "./api";
export * from "./configuration";
export * from "./models";
import * as Schema from "./schema";
export {Schema};

View File

@ -0,0 +1,69 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
// May contain unused imports in some cases
// @ts-ignore
import { TypesCompletedPart } from './types-completed-part';
/**
*
* @export
* @interface CommonsCommitCacheRequest
*/
export interface CommonsCommitCacheRequest {
/**
*
* @type {string}
* @memberof CommonsCommitCacheRequest
*/
'cache_key': string;
/**
*
* @type {string}
* @memberof CommonsCommitCacheRequest
*/
'cache_version': string;
/**
*
* @type {string}
* @memberof CommonsCommitCacheRequest
*/
'os': string;
/**
*
* @type {Array<TypesCompletedPart>}
* @memberof CommonsCommitCacheRequest
*/
'parts': Array<TypesCompletedPart>;
/**
* UploadID * This is not supported for GCS cache. When passed this will be ignored. *
* @type {string}
* @memberof CommonsCommitCacheRequest
*/
'upload_id'?: string;
/**
* UploadKey * This is not supported for GCS cache. When passed this will be ignored. *
* @type {string}
* @memberof CommonsCommitCacheRequest
*/
'upload_key'?: string;
/**
*
* @type {string}
* @memberof CommonsCommitCacheRequest
*/
'vcs_type': string;
}

View File

@ -0,0 +1,48 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
// May contain unused imports in some cases
// @ts-ignore
import { CommonsGCSCommitCacheResponse } from './commons-gcscommit-cache-response';
// May contain unused imports in some cases
// @ts-ignore
import { CommonsS3CommitCacheResponse } from './commons-s3-commit-cache-response';
/**
*
* @export
* @interface CommonsCommitCacheResponse
*/
export interface CommonsCommitCacheResponse {
/**
*
* @type {CommonsGCSCommitCacheResponse}
* @memberof CommonsCommitCacheResponse
*/
'gcs'?: CommonsGCSCommitCacheResponse;
/**
*
* @type {string}
* @memberof CommonsCommitCacheResponse
*/
'provider'?: string;
/**
*
* @type {CommonsS3CommitCacheResponse}
* @memberof CommonsCommitCacheResponse
*/
's3'?: CommonsS3CommitCacheResponse;
}

View File

@ -0,0 +1,45 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
// May contain unused imports in some cases
// @ts-ignore
import { CommonsS3DeleteCacheResponse } from './commons-s3-delete-cache-response';
/**
*
* @export
* @interface CommonsDeleteCacheResponse
*/
export interface CommonsDeleteCacheResponse {
/**
*
* @type {object}
* @memberof CommonsDeleteCacheResponse
*/
'gcs'?: object;
/**
*
* @type {string}
* @memberof CommonsDeleteCacheResponse
*/
'provider'?: string;
/**
*
* @type {CommonsS3DeleteCacheResponse}
* @memberof CommonsDeleteCacheResponse
*/
's3'?: CommonsS3DeleteCacheResponse;
}

View File

@ -0,0 +1,57 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
// May contain unused imports in some cases
// @ts-ignore
import { CommonsShortLivedToken } from './commons-short-lived-token';
/**
*
* @export
* @interface CommonsGCSCommitCacheResponse
*/
export interface CommonsGCSCommitCacheResponse {
/**
*
* @type {string}
* @memberof CommonsGCSCommitCacheResponse
*/
'bucket_name'?: string;
/**
* CacheKey is the resolved cache key which might contain some prefix or suffix in addition to the cache key provided by the user. This is the actual storage location in gcs.
* @type {string}
* @memberof CommonsGCSCommitCacheResponse
*/
'cache_key': string;
/**
* Method contains the auth method to be used to connect to the GCP storage backend
* @type {string}
* @memberof CommonsGCSCommitCacheResponse
*/
'method'?: string;
/**
*
* @type {string}
* @memberof CommonsGCSCommitCacheResponse
*/
'project_id'?: string;
/**
*
* @type {CommonsShortLivedToken}
* @memberof CommonsGCSCommitCacheResponse
*/
'short_lived_token'?: CommonsShortLivedToken;
}

View File

@ -0,0 +1,63 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
// May contain unused imports in some cases
// @ts-ignore
import { CommonsShortLivedToken } from './commons-short-lived-token';
/**
*
* @export
* @interface CommonsGCSGetCacheReponse
*/
export interface CommonsGCSGetCacheReponse {
/**
*
* @type {string}
* @memberof CommonsGCSGetCacheReponse
*/
'bucket_name'?: string;
/**
*
* @type {string}
* @memberof CommonsGCSGetCacheReponse
*/
'cache_key'?: string;
/**
*
* @type {string}
* @memberof CommonsGCSGetCacheReponse
*/
'cache_version'?: string;
/**
* Method contains the auth method to be used to connect to the GCP storage backend
* @type {string}
* @memberof CommonsGCSGetCacheReponse
*/
'method'?: string;
/**
*
* @type {string}
* @memberof CommonsGCSGetCacheReponse
*/
'project_id'?: string;
/**
*
* @type {CommonsShortLivedToken}
* @memberof CommonsGCSGetCacheReponse
*/
'short_lived_token'?: CommonsShortLivedToken;
}

View File

@ -0,0 +1,57 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
// May contain unused imports in some cases
// @ts-ignore
import { CommonsShortLivedToken } from './commons-short-lived-token';
/**
*
* @export
* @interface CommonsGCSReserveCacheResponse
*/
export interface CommonsGCSReserveCacheResponse {
/**
*
* @type {string}
* @memberof CommonsGCSReserveCacheResponse
*/
'bucket_name'?: string;
/**
* CacheKey is the resolved cache key which might contain some prefix or suffix in addition to the cache key provided by the user. This is the actual storage location in gcs.
* @type {string}
* @memberof CommonsGCSReserveCacheResponse
*/
'cache_key': string;
/**
* Method contains the auth method to be used to connect to the GCP storage backend
* @type {string}
* @memberof CommonsGCSReserveCacheResponse
*/
'method'?: string;
/**
*
* @type {string}
* @memberof CommonsGCSReserveCacheResponse
*/
'project_id'?: string;
/**
*
* @type {CommonsShortLivedToken}
* @memberof CommonsGCSReserveCacheResponse
*/
'short_lived_token'?: CommonsShortLivedToken;
}

View File

@ -0,0 +1,48 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
// May contain unused imports in some cases
// @ts-ignore
import { CommonsGCSGetCacheReponse } from './commons-gcsget-cache-reponse';
// May contain unused imports in some cases
// @ts-ignore
import { CommonsS3GetCacheResponse } from './commons-s3-get-cache-response';
/**
*
* @export
* @interface CommonsGetCacheResponse
*/
export interface CommonsGetCacheResponse {
/**
*
* @type {CommonsGCSGetCacheReponse}
* @memberof CommonsGetCacheResponse
*/
'gcs'?: CommonsGCSGetCacheReponse;
/**
*
* @type {string}
* @memberof CommonsGetCacheResponse
*/
'provider'?: string;
/**
*
* @type {CommonsS3GetCacheResponse}
* @memberof CommonsGetCacheResponse
*/
's3'?: CommonsS3GetCacheResponse;
}

View File

@ -0,0 +1,42 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CommonsReserveCacheRequest
*/
export interface CommonsReserveCacheRequest {
/**
*
* @type {string}
* @memberof CommonsReserveCacheRequest
*/
'cache_key': string;
/**
* ContentType contains the content type of the cache. * This is not supported for GCS cache. When passed this will be ignored. *
* @type {string}
* @memberof CommonsReserveCacheRequest
*/
'content_type'?: string;
/**
* NumberOfChunks contains the number of chunks the cache will be split into. Minimum value: 1. Maximum value: 10000. * This is not supported for GCS cache. When passed this will be ignored. *
* @type {number}
* @memberof CommonsReserveCacheRequest
*/
'number_of_chunks'?: number;
}

View File

@ -0,0 +1,48 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
// May contain unused imports in some cases
// @ts-ignore
import { CommonsGCSReserveCacheResponse } from './commons-gcsreserve-cache-response';
// May contain unused imports in some cases
// @ts-ignore
import { CommonsS3ReserveCacheResponse } from './commons-s3-reserve-cache-response';
/**
*
* @export
* @interface CommonsReserveCacheResponse
*/
export interface CommonsReserveCacheResponse {
/**
*
* @type {CommonsGCSReserveCacheResponse}
* @memberof CommonsReserveCacheResponse
*/
'gcs'?: CommonsGCSReserveCacheResponse;
/**
*
* @type {string}
* @memberof CommonsReserveCacheResponse
*/
'provider'?: string;
/**
*
* @type {CommonsS3ReserveCacheResponse}
* @memberof CommonsReserveCacheResponse
*/
's3'?: CommonsS3ReserveCacheResponse;
}

View File

@ -0,0 +1,36 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CommonsS3CommitCacheResponse
*/
export interface CommonsS3CommitCacheResponse {
/**
*
* @type {string}
* @memberof CommonsS3CommitCacheResponse
*/
'cache_key': string;
/**
*
* @type {string}
* @memberof CommonsS3CommitCacheResponse
*/
'cache_version': string;
}

View File

@ -0,0 +1,36 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CommonsS3DeleteCacheResponse
*/
export interface CommonsS3DeleteCacheResponse {
/**
*
* @type {string}
* @memberof CommonsS3DeleteCacheResponse
*/
'cache_key': string;
/**
*
* @type {string}
* @memberof CommonsS3DeleteCacheResponse
*/
'cache_version': string;
}

View File

@ -0,0 +1,42 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CommonsS3GetCacheResponse
*/
export interface CommonsS3GetCacheResponse {
/**
*
* @type {string}
* @memberof CommonsS3GetCacheResponse
*/
'cache_key'?: string;
/**
*
* @type {string}
* @memberof CommonsS3GetCacheResponse
*/
'cache_version'?: string;
/**
*
* @type {string}
* @memberof CommonsS3GetCacheResponse
*/
'pre_signed_url'?: string;
}

View File

@ -0,0 +1,42 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CommonsS3ReserveCacheResponse
*/
export interface CommonsS3ReserveCacheResponse {
/**
*
* @type {Array<string>}
* @memberof CommonsS3ReserveCacheResponse
*/
'pre_signed_urls'?: Array<string>;
/**
*
* @type {string}
* @memberof CommonsS3ReserveCacheResponse
*/
'upload_id'?: string;
/**
*
* @type {string}
* @memberof CommonsS3ReserveCacheResponse
*/
'upload_key'?: string;
}

View File

@ -0,0 +1,36 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CommonsShortLivedToken
*/
export interface CommonsShortLivedToken {
/**
* AccessToken contains the short lived access token to be used to connect to the GCP storage backend
* @type {string}
* @memberof CommonsShortLivedToken
*/
'access_token'?: string;
/**
* ExpiresAt contains the expiry time of the short lived access token format: date-time
* @type {string}
* @memberof CommonsShortLivedToken
*/
'expires_at'?: string;
}

View File

@ -0,0 +1,16 @@
export * from './commons-commit-cache-request';
export * from './commons-commit-cache-response';
export * from './commons-delete-cache-response';
export * from './commons-gcscommit-cache-response';
export * from './commons-gcsget-cache-reponse';
export * from './commons-gcsreserve-cache-response';
export * from './commons-get-cache-response';
export * from './commons-reserve-cache-request';
export * from './commons-reserve-cache-response';
export * from './commons-s3-commit-cache-response';
export * from './commons-s3-delete-cache-response';
export * from './commons-s3-get-cache-response';
export * from './commons-s3-reserve-cache-response';
export * from './commons-short-lived-token';
export * from './types-completed-part';
export * from './warp-build-apierror';

View File

@ -0,0 +1,60 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface TypesCompletedPart
*/
export interface TypesCompletedPart {
/**
* The base64-encoded, 32-bit CRC32 checksum of the object. This will only be present if it was uploaded with the object. With multipart uploads, this may not be a checksum value of the object. For more information about how checksums are calculated with multipart uploads, see Checking object integrity (https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#large-object-checksums) in the Amazon S3 User Guide.
* @type {string}
* @memberof TypesCompletedPart
*/
'ChecksumCRC32'?: string;
/**
* The base64-encoded, 32-bit CRC32C checksum of the object. This will only be present if it was uploaded with the object. With multipart uploads, this may not be a checksum value of the object. For more information about how checksums are calculated with multipart uploads, see Checking object integrity (https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#large-object-checksums) in the Amazon S3 User Guide.
* @type {string}
* @memberof TypesCompletedPart
*/
'ChecksumCRC32C'?: string;
/**
* The base64-encoded, 160-bit SHA-1 digest of the object. This will only be present if it was uploaded with the object. With multipart uploads, this may not be a checksum value of the object. For more information about how checksums are calculated with multipart uploads, see Checking object integrity (https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#large-object-checksums) in the Amazon S3 User Guide.
* @type {string}
* @memberof TypesCompletedPart
*/
'ChecksumSHA1'?: string;
/**
* The base64-encoded, 256-bit SHA-256 digest of the object. This will only be present if it was uploaded with the object. With multipart uploads, this may not be a checksum value of the object. For more information about how checksums are calculated with multipart uploads, see Checking object integrity (https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#large-object-checksums) in the Amazon S3 User Guide.
* @type {string}
* @memberof TypesCompletedPart
*/
'ChecksumSHA256'?: string;
/**
* Entity tag returned when the part was uploaded.
* @type {string}
* @memberof TypesCompletedPart
*/
'ETag'?: string;
/**
* Part number that identifies the part. This is a positive integer between 1 and 10,000.
* @type {number}
* @memberof TypesCompletedPart
*/
'PartNumber'?: number;
}

View File

@ -0,0 +1,54 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface WarpBuildAPIError
*/
export interface WarpBuildAPIError {
/**
*
* @type {string}
* @memberof WarpBuildAPIError
*/
'code'?: string;
/**
*
* @type {string}
* @memberof WarpBuildAPIError
*/
'description'?: string;
/**
*
* @type {string}
* @memberof WarpBuildAPIError
*/
'message'?: string;
/**
*
* @type {string}
* @memberof WarpBuildAPIError
*/
'sub_code'?: string;
/**
*
* @type {string}
* @memberof WarpBuildAPIError
*/
'sub_message'?: string;
}

View File

@ -0,0 +1,20 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export { $commons_CommitCacheRequest } from './schemas/$commons_CommitCacheRequest';
export { $commons_CommitCacheResponse } from './schemas/$commons_CommitCacheResponse';
export { $commons_DeleteCacheResponse } from './schemas/$commons_DeleteCacheResponse';
export { $commons_GCSCommitCacheResponse } from './schemas/$commons_GCSCommitCacheResponse';
export { $commons_GCSDeleteCacheResponse } from './schemas/$commons_GCSDeleteCacheResponse';
export { $commons_GCSGetCacheReponse } from './schemas/$commons_GCSGetCacheReponse';
export { $commons_GCSReserveCacheResponse } from './schemas/$commons_GCSReserveCacheResponse';
export { $commons_GetCacheResponse } from './schemas/$commons_GetCacheResponse';
export { $commons_ReserveCacheRequest } from './schemas/$commons_ReserveCacheRequest';
export { $commons_ReserveCacheResponse } from './schemas/$commons_ReserveCacheResponse';
export { $commons_S3CommitCacheResponse } from './schemas/$commons_S3CommitCacheResponse';
export { $commons_S3DeleteCacheResponse } from './schemas/$commons_S3DeleteCacheResponse';
export { $commons_S3GetCacheResponse } from './schemas/$commons_S3GetCacheResponse';
export { $commons_S3ReserveCacheResponse } from './schemas/$commons_S3ReserveCacheResponse';
export { $commons_ShortLivedToken } from './schemas/$commons_ShortLivedToken';
export { $types_CompletedPart } from './schemas/$types_CompletedPart';
export { $WarpBuildAPIError } from './schemas/$WarpBuildAPIError';

View File

@ -0,0 +1,22 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $WarpBuildAPIError = {
properties: {
code: {
type: 'string',
},
description: {
type: 'string',
},
message: {
type: 'string',
},
sub_code: {
type: 'string',
},
sub_message: {
type: 'string',
},
},
} as const;

View File

@ -0,0 +1,36 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_CommitCacheRequest = {
properties: {
cache_key: {
type: 'string',
isRequired: true,
},
cache_version: {
type: 'string',
isRequired: true,
},
os: {
type: 'string',
isRequired: true,
},
parts: {
type: 'array',
contains: {
type: 'types_CompletedPart',
},
isRequired: true,
},
upload_id: {
type: 'string',
},
upload_key: {
type: 'string',
},
vcs_type: {
type: 'string',
isRequired: true,
},
},
} as const;

View File

@ -0,0 +1,16 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_CommitCacheResponse = {
properties: {
gcs: {
type: 'commons_GCSCommitCacheResponse',
},
provider: {
type: 'string',
},
s3: {
type: 'commons_S3CommitCacheResponse',
},
},
} as const;

View File

@ -0,0 +1,16 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_DeleteCacheResponse = {
properties: {
gcs: {
type: 'commons_GCSDeleteCacheResponse',
},
provider: {
type: 'string',
},
s3: {
type: 'commons_S3DeleteCacheResponse',
},
},
} as const;

View File

@ -0,0 +1,23 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_GCSCommitCacheResponse = {
properties: {
bucket_name: {
type: 'string',
},
cache_key: {
type: 'string',
isRequired: true,
},
method: {
type: 'string',
},
project_id: {
type: 'string',
},
short_lived_token: {
type: 'commons_ShortLivedToken',
},
},
} as const;

View File

@ -0,0 +1,7 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_GCSDeleteCacheResponse = {
properties: {
},
} as const;

View File

@ -0,0 +1,25 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_GCSGetCacheReponse = {
properties: {
bucket_name: {
type: 'string',
},
cache_key: {
type: 'string',
},
cache_version: {
type: 'string',
},
method: {
type: 'string',
},
project_id: {
type: 'string',
},
short_lived_token: {
type: 'commons_ShortLivedToken',
},
},
} as const;

View File

@ -0,0 +1,23 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_GCSReserveCacheResponse = {
properties: {
bucket_name: {
type: 'string',
},
cache_key: {
type: 'string',
isRequired: true,
},
method: {
type: 'string',
},
project_id: {
type: 'string',
},
short_lived_token: {
type: 'commons_ShortLivedToken',
},
},
} as const;

View File

@ -0,0 +1,16 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_GetCacheResponse = {
properties: {
gcs: {
type: 'commons_GCSGetCacheReponse',
},
provider: {
type: 'string',
},
s3: {
type: 'commons_S3GetCacheResponse',
},
},
} as const;

View File

@ -0,0 +1,17 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_ReserveCacheRequest = {
properties: {
cache_key: {
type: 'string',
isRequired: true,
},
content_type: {
type: 'string',
},
number_of_chunks: {
type: 'number',
},
},
} as const;

View File

@ -0,0 +1,16 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_ReserveCacheResponse = {
properties: {
gcs: {
type: 'commons_GCSReserveCacheResponse',
},
provider: {
type: 'string',
},
s3: {
type: 'commons_S3ReserveCacheResponse',
},
},
} as const;

View File

@ -0,0 +1,15 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_S3CommitCacheResponse = {
properties: {
cache_key: {
type: 'string',
isRequired: true,
},
cache_version: {
type: 'string',
isRequired: true,
},
},
} as const;

View File

@ -0,0 +1,15 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_S3DeleteCacheResponse = {
properties: {
cache_key: {
type: 'string',
isRequired: true,
},
cache_version: {
type: 'string',
isRequired: true,
},
},
} as const;

View File

@ -0,0 +1,16 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_S3GetCacheResponse = {
properties: {
cache_key: {
type: 'string',
},
cache_version: {
type: 'string',
},
pre_signed_url: {
type: 'string',
},
},
} as const;

View File

@ -0,0 +1,19 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_S3ReserveCacheResponse = {
properties: {
pre_signed_urls: {
type: 'array',
contains: {
type: 'string',
},
},
upload_id: {
type: 'string',
},
upload_key: {
type: 'string',
},
},
} as const;

View File

@ -0,0 +1,13 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_ShortLivedToken = {
properties: {
access_token: {
type: 'string',
},
expires_at: {
type: 'string',
},
},
} as const;

View File

@ -0,0 +1,25 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $types_CompletedPart = {
properties: {
ChecksumCRC32: {
type: 'string',
},
ChecksumCRC32C: {
type: 'string',
},
ChecksumSHA1: {
type: 'string',
},
ChecksumSHA256: {
type: 'string',
},
ETag: {
type: 'string',
},
PartNumber: {
type: 'number',
},
},
} as const;

View File

@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "esnext",
"outDir": "dist/esm"
}
}

View File

@ -1,46 +1,23 @@
import {exec, spawn} from 'child_process'
import {deleteCache, restoreCache, saveCache} from './cache'
import {downloadCacheStreamingGCP} from './internal/downloadUtils'
import fs, {write} from 'fs'
import {extractStreamingTar} from './internal/tar'
import {CompressionMethod} from './internal/constants'
process.env['WARPBUILD_CACHE_URL'] = 'http://localhost:8002'
process.env['RUNNER_TEMP'] = '/Users/prajjwal/Repos/warpbuild/playground/tmp_fs'
process.env['NODE_DEBUG'] = 'http'
process.env['WARPBUILD_RUNNER_VERIFICATION_TOKEN'] =
'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTMwNzE5ODgsInJlcG8iOiJiZW5jaG1hcmtzIiwicmVwb093bmVyIjoiV2FycEJ1aWxkcyIsIngtd2FycGJ1aWxkLW9yZ2FuaXphdGlvbi1pZCI6IndmbW4wODBlaWY4cm5pd3EifQ.Wat-RATKl_KB39SF6egch3nF3_dD8hDE3lbl9wm7AyBUs9pUNEDejJtgHO0xQfGvSN-qRTPbJ_glHKPUIRHE3w'
// saveCache(
// ['/Users/prajjwal/Repos/warpbuild/playground/test_fs'],
// 'test-fs-local-key',
// true
// )
// restoreCache(
// ['/Users/prajjwal/Repos/warpbuild/playground/test_fs'],
// 'test-fs-local-key',
// [],
// {},
// true
// )
// deleteCache(['test-fs-local-key'])
process.env['GCP_ACCESS_TOKEN'] =
'ya29.c.c0AY_VpZgcQopWxkSf9wIIo9NED0YFh3VIgZ1wx1ulvSCrq5iTiZWbrRGPej2vA835U2HkNdrLwaVKFLeL57v1s-guzSvihNnHMMJ4wUPJHZPQd-CJ90i6F0NYcjQuv7SC2EBkaKciM-Act0IDygPwzwwixCe-4iCxcUv3YUysZcee9Qknxq5UBPfGjqQArVKifC2fScJ7HnBmbbSc8t1mDp9mLiIpax9V31anOQ-4QK1kqSgi4gh0m-Cd7v24S7Kfc5IEcQLrVyI62W4Y4HywRJ2V_qBx3ZKFMmO1lV5Tl3wHX40XyD1J2Cc6kXbF4LHHPcMnRf85ylaXaUGMwDNlkDPFHRJmOkWnZF8-v_Y4868-Mmektdl8khWvCQwGSLHo_jCKehCJZl1qK1gzNfie7Rgm9qbooMAEg1KkPPiDBmMY_WUsBo1-a0vuHrE90IhtvKI_TNTeH-pUDjSFMsbgrhnbGu5oN6DXk--WyjHy9slW6r8TDjB8UjPE2uiaGbYrQZsRPoaKVAxVylc9tFONyPwJ10MUerPq3ESq49QUASdasuYCef0CZ_R3kJyIMQe7p6WBfOZ0L11ZTz_tnFn1Oa8JGHvYl1xvx79EbHjo4mvyr5WTAXa42g-gCnPnJFLaN649DRZbdRzbbc3-bQbqFuictuoSQmOjhrqW6_0_44wVhlga9Ok9kZ4_lx6Oqvq9SiI6IxIJSBVnXet3MgzoRdJur8Ws766sinJ_iFkZdsQdj2IQ_hj74vh61v1i84xIZY-bp-IrvQQf_vZm6bbBZXxaXhiVphpij7nY5Rz3qS2d0e3byc1iUW63jXlY1iIhlvsd1i2Zd4YVyQrfgSy_zpuXJOqhS1MwBrkddb4F-r3wQtRJ1ttmbpSJOpeYzewzSeVopk8pmOaUSd0rS4qQkY1UdhQoavyn54VMj5U8BiOkjo-wV2MUXl0FlVF7u3-c3vUhlZ1JrMj6xiWFXys_QBMtU55jMe31UV-saSFxM7f1-xk1_2xoou8'
const readStream = downloadCacheStreamingGCP(
'gs://cache-bench-test/custom_modules.tar.zst'
saveCache(
['/Users/prajjwal/Repos/warpbuild/playground/test_fs'],
'test-fs-local-key',
true
)
extractStreamingTar(
readStream!,
'/tmp/custom_modules',
CompressionMethod.ZstdWithoutLong
restoreCache(
['/Users/prajjwal/Repos/warpbuild/playground/test_fs'],
'test-fs-local-key',
[],
{},
true
)
.then(() => {
console.log('done')
})
.catch(err => {
console.log(err)
})
deleteCache(['test-fs-local-key'])