mirror of
https://github.com/actions/cache.git
synced 2026-06-05 19:53:30 +00:00
86795 lines
No EOL
3 MiB
86795 lines
No EOL
3 MiB
/******/ (() => { // webpackBootstrap
|
||
/******/ var __webpack_modules__ = ({
|
||
|
||
/***/ 5116:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.FinalizeCacheError = exports.ReserveCacheError = exports.ValidationError = void 0;
|
||
exports.isFeatureAvailable = isFeatureAvailable;
|
||
exports.restoreCache = restoreCache;
|
||
exports.saveCache = saveCache;
|
||
const core = __importStar(__nccwpck_require__(37484));
|
||
const path = __importStar(__nccwpck_require__(16928));
|
||
const utils = __importStar(__nccwpck_require__(98299));
|
||
const cacheHttpClient = __importStar(__nccwpck_require__(73171));
|
||
const cacheTwirpClient = __importStar(__nccwpck_require__(96819));
|
||
const config_1 = __nccwpck_require__(17606);
|
||
const tar_1 = __nccwpck_require__(95321);
|
||
const http_client_1 = __nccwpck_require__(54844);
|
||
class ValidationError extends Error {
|
||
constructor(message) {
|
||
super(message);
|
||
this.name = 'ValidationError';
|
||
Object.setPrototypeOf(this, ValidationError.prototype);
|
||
}
|
||
}
|
||
exports.ValidationError = ValidationError;
|
||
class ReserveCacheError extends Error {
|
||
constructor(message) {
|
||
super(message);
|
||
this.name = 'ReserveCacheError';
|
||
Object.setPrototypeOf(this, ReserveCacheError.prototype);
|
||
}
|
||
}
|
||
exports.ReserveCacheError = ReserveCacheError;
|
||
class FinalizeCacheError extends Error {
|
||
constructor(message) {
|
||
super(message);
|
||
this.name = 'FinalizeCacheError';
|
||
Object.setPrototypeOf(this, FinalizeCacheError.prototype);
|
||
}
|
||
}
|
||
exports.FinalizeCacheError = FinalizeCacheError;
|
||
function checkPaths(paths) {
|
||
if (!paths || paths.length === 0) {
|
||
throw new ValidationError(`Path Validation Error: At least one directory or file path is required`);
|
||
}
|
||
}
|
||
function checkKey(key) {
|
||
if (key.length > 512) {
|
||
throw new ValidationError(`Key Validation Error: ${key} cannot be larger than 512 characters.`);
|
||
}
|
||
const regex = /^[^,]*$/;
|
||
if (!regex.test(key)) {
|
||
throw new ValidationError(`Key Validation Error: ${key} cannot contain commas.`);
|
||
}
|
||
}
|
||
/**
|
||
* isFeatureAvailable to check the presence of Actions cache service
|
||
*
|
||
* @returns boolean return true if Actions cache service feature is available, otherwise false
|
||
*/
|
||
function isFeatureAvailable() {
|
||
const cacheServiceVersion = (0, config_1.getCacheServiceVersion)();
|
||
// Check availability based on cache service version
|
||
switch (cacheServiceVersion) {
|
||
case 'v2':
|
||
// For v2, we need ACTIONS_RESULTS_URL
|
||
return !!process.env['ACTIONS_RESULTS_URL'];
|
||
case 'v1':
|
||
default:
|
||
// For v1, we only need ACTIONS_CACHE_URL
|
||
return !!process.env['ACTIONS_CACHE_URL'];
|
||
}
|
||
}
|
||
/**
|
||
* Restores cache from keys
|
||
*
|
||
* @param paths a list of file paths to restore from the cache
|
||
* @param primaryKey an explicit key for restoring the cache. Lookup is done with prefix matching.
|
||
* @param restoreKeys an optional ordered list of keys to use for restoring the cache if no cache hit occurred for primaryKey
|
||
* @param downloadOptions cache download options
|
||
* @param enableCrossOsArchive an optional boolean enabled to restore on windows any cache created on any platform
|
||
* @returns string returns the key for the cache hit, otherwise returns undefined
|
||
*/
|
||
function restoreCache(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
||
return __awaiter(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
|
||
const cacheServiceVersion = (0, config_1.getCacheServiceVersion)();
|
||
core.debug(`Cache service version: ${cacheServiceVersion}`);
|
||
checkPaths(paths);
|
||
switch (cacheServiceVersion) {
|
||
case 'v2':
|
||
return yield restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsArchive);
|
||
case 'v1':
|
||
default:
|
||
return yield restoreCacheV1(paths, primaryKey, restoreKeys, options, enableCrossOsArchive);
|
||
}
|
||
});
|
||
}
|
||
/**
|
||
* Restores cache using the legacy Cache Service
|
||
*
|
||
* @param paths a list of file paths to restore from the cache
|
||
* @param primaryKey an explicit key for restoring the cache. Lookup is done with prefix matching.
|
||
* @param restoreKeys an optional ordered list of keys to use for restoring the cache if no cache hit occurred for primaryKey
|
||
* @param options cache download options
|
||
* @param enableCrossOsArchive an optional boolean enabled to restore on Windows any cache created on any platform
|
||
* @returns string returns the key for the cache hit, otherwise returns undefined
|
||
*/
|
||
function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
||
return __awaiter(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
|
||
restoreKeys = restoreKeys || [];
|
||
const keys = [primaryKey, ...restoreKeys];
|
||
core.debug('Resolved Keys:');
|
||
core.debug(JSON.stringify(keys));
|
||
if (keys.length > 10) {
|
||
throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`);
|
||
}
|
||
for (const key of keys) {
|
||
checkKey(key);
|
||
}
|
||
const compressionMethod = yield utils.getCompressionMethod();
|
||
let archivePath = '';
|
||
try {
|
||
// path are needed to compute version
|
||
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
||
compressionMethod,
|
||
enableCrossOsArchive
|
||
});
|
||
if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
|
||
// Cache not found
|
||
return undefined;
|
||
}
|
||
if (options === null || options === void 0 ? void 0 : options.lookupOnly) {
|
||
core.info('Lookup only - skipping download');
|
||
return cacheEntry.cacheKey;
|
||
}
|
||
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
||
core.debug(`Archive Path: ${archivePath}`);
|
||
// Download the cache from the cache entry
|
||
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
|
||
if (core.isDebug()) {
|
||
yield (0, tar_1.listTar)(archivePath, compressionMethod);
|
||
}
|
||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||
yield (0, tar_1.extractTar)(archivePath, compressionMethod);
|
||
core.info('Cache restored successfully');
|
||
return cacheEntry.cacheKey;
|
||
}
|
||
catch (error) {
|
||
const typedError = error;
|
||
if (typedError.name === ValidationError.name) {
|
||
throw error;
|
||
}
|
||
else {
|
||
// warn on cache restore failure and continue build
|
||
// Log server errors (5xx) as errors, all other errors as warnings
|
||
if (typedError instanceof http_client_1.HttpClientError &&
|
||
typeof typedError.statusCode === 'number' &&
|
||
typedError.statusCode >= 500) {
|
||
core.error(`Failed to restore: ${error.message}`);
|
||
}
|
||
else {
|
||
core.warning(`Failed to restore: ${error.message}`);
|
||
}
|
||
}
|
||
}
|
||
finally {
|
||
// Try to delete the archive to save space
|
||
try {
|
||
yield utils.unlinkFile(archivePath);
|
||
}
|
||
catch (error) {
|
||
core.debug(`Failed to delete archive: ${error}`);
|
||
}
|
||
}
|
||
return undefined;
|
||
});
|
||
}
|
||
/**
|
||
* Restores cache using Cache Service v2
|
||
*
|
||
* @param paths a list of file paths to restore from the cache
|
||
* @param primaryKey an explicit key for restoring the cache. Lookup is done with prefix matching
|
||
* @param restoreKeys an optional ordered list of keys to use for restoring the cache if no cache hit occurred for primaryKey
|
||
* @param downloadOptions cache download options
|
||
* @param enableCrossOsArchive an optional boolean enabled to restore on windows any cache created on any platform
|
||
* @returns string returns the key for the cache hit, otherwise returns undefined
|
||
*/
|
||
function restoreCacheV2(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
||
return __awaiter(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
|
||
// Override UploadOptions to force the use of Azure
|
||
options = Object.assign(Object.assign({}, options), { useAzureSdk: true });
|
||
restoreKeys = restoreKeys || [];
|
||
const keys = [primaryKey, ...restoreKeys];
|
||
core.debug('Resolved Keys:');
|
||
core.debug(JSON.stringify(keys));
|
||
if (keys.length > 10) {
|
||
throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`);
|
||
}
|
||
for (const key of keys) {
|
||
checkKey(key);
|
||
}
|
||
let archivePath = '';
|
||
try {
|
||
const twirpClient = cacheTwirpClient.internalCacheTwirpClient();
|
||
const compressionMethod = yield utils.getCompressionMethod();
|
||
const request = {
|
||
key: primaryKey,
|
||
restoreKeys,
|
||
version: utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive)
|
||
};
|
||
const response = yield twirpClient.GetCacheEntryDownloadURL(request);
|
||
if (!response.ok) {
|
||
core.debug(`Cache not found for version ${request.version} of keys: ${keys.join(', ')}`);
|
||
return undefined;
|
||
}
|
||
const isRestoreKeyMatch = request.key !== response.matchedKey;
|
||
if (isRestoreKeyMatch) {
|
||
core.info(`Cache hit for restore-key: ${response.matchedKey}`);
|
||
}
|
||
else {
|
||
core.info(`Cache hit for: ${response.matchedKey}`);
|
||
}
|
||
if (options === null || options === void 0 ? void 0 : options.lookupOnly) {
|
||
core.info('Lookup only - skipping download');
|
||
return response.matchedKey;
|
||
}
|
||
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
||
core.debug(`Archive path: ${archivePath}`);
|
||
core.debug(`Starting download of archive to: ${archivePath}`);
|
||
yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options);
|
||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||
if (core.isDebug()) {
|
||
yield (0, tar_1.listTar)(archivePath, compressionMethod);
|
||
}
|
||
yield (0, tar_1.extractTar)(archivePath, compressionMethod);
|
||
core.info('Cache restored successfully');
|
||
return response.matchedKey;
|
||
}
|
||
catch (error) {
|
||
const typedError = error;
|
||
if (typedError.name === ValidationError.name) {
|
||
throw error;
|
||
}
|
||
else {
|
||
// Supress all non-validation cache related errors because caching should be optional
|
||
// Log server errors (5xx) as errors, all other errors as warnings
|
||
if (typedError instanceof http_client_1.HttpClientError &&
|
||
typeof typedError.statusCode === 'number' &&
|
||
typedError.statusCode >= 500) {
|
||
core.error(`Failed to restore: ${error.message}`);
|
||
}
|
||
else {
|
||
core.warning(`Failed to restore: ${error.message}`);
|
||
}
|
||
}
|
||
}
|
||
finally {
|
||
try {
|
||
if (archivePath) {
|
||
yield utils.unlinkFile(archivePath);
|
||
}
|
||
}
|
||
catch (error) {
|
||
core.debug(`Failed to delete archive: ${error}`);
|
||
}
|
||
}
|
||
return undefined;
|
||
});
|
||
}
|
||
/**
|
||
* Saves a list of files with the specified key
|
||
*
|
||
* @param paths a list of file paths to be cached
|
||
* @param key an explicit key for restoring the cache
|
||
* @param enableCrossOsArchive an optional boolean enabled to save cache on windows which could be restored on any platform
|
||
* @param options cache upload options
|
||
* @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
|
||
*/
|
||
function saveCache(paths_1, key_1, options_1) {
|
||
return __awaiter(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) {
|
||
const cacheServiceVersion = (0, config_1.getCacheServiceVersion)();
|
||
core.debug(`Cache service version: ${cacheServiceVersion}`);
|
||
checkPaths(paths);
|
||
checkKey(key);
|
||
switch (cacheServiceVersion) {
|
||
case 'v2':
|
||
return yield saveCacheV2(paths, key, options, enableCrossOsArchive);
|
||
case 'v1':
|
||
default:
|
||
return yield saveCacheV1(paths, key, options, enableCrossOsArchive);
|
||
}
|
||
});
|
||
}
|
||
/**
|
||
* Save cache using the legacy Cache Service
|
||
*
|
||
* @param paths
|
||
* @param key
|
||
* @param options
|
||
* @param enableCrossOsArchive
|
||
* @returns
|
||
*/
|
||
function saveCacheV1(paths_1, key_1, options_1) {
|
||
return __awaiter(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) {
|
||
var _a, _b, _c, _d, _e;
|
||
const compressionMethod = yield utils.getCompressionMethod();
|
||
let cacheId = -1;
|
||
const cachePaths = yield utils.resolvePaths(paths);
|
||
core.debug('Cache Paths:');
|
||
core.debug(`${JSON.stringify(cachePaths)}`);
|
||
if (cachePaths.length === 0) {
|
||
throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`);
|
||
}
|
||
const archiveFolder = yield utils.createTempDirectory();
|
||
const archivePath = path.join(archiveFolder, utils.getCacheFileName(compressionMethod));
|
||
core.debug(`Archive Path: ${archivePath}`);
|
||
try {
|
||
yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod);
|
||
if (core.isDebug()) {
|
||
yield (0, tar_1.listTar)(archivePath, compressionMethod);
|
||
}
|
||
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB 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 && !(0, config_1.isGhes)()) {
|
||
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
|
||
}
|
||
core.debug('Reserving Cache');
|
||
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
|
||
compressionMethod,
|
||
enableCrossOsArchive,
|
||
cacheSize: archiveFileSize
|
||
});
|
||
if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) {
|
||
cacheId = (_b = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _b === void 0 ? void 0 : _b.cacheId;
|
||
}
|
||
else if ((reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.statusCode) === 400) {
|
||
throw new Error((_d = (_c = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : `Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`);
|
||
}
|
||
else {
|
||
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`);
|
||
}
|
||
core.debug(`Saving Cache (ID: ${cacheId})`);
|
||
yield cacheHttpClient.saveCache(cacheId, archivePath, '', options);
|
||
}
|
||
catch (error) {
|
||
const typedError = error;
|
||
if (typedError.name === ValidationError.name) {
|
||
throw error;
|
||
}
|
||
else if (typedError.name === ReserveCacheError.name) {
|
||
core.info(`Failed to save: ${typedError.message}`);
|
||
}
|
||
else {
|
||
// Log server errors (5xx) as errors, all other errors as warnings
|
||
if (typedError instanceof http_client_1.HttpClientError &&
|
||
typeof typedError.statusCode === 'number' &&
|
||
typedError.statusCode >= 500) {
|
||
core.error(`Failed to save: ${typedError.message}`);
|
||
}
|
||
else {
|
||
core.warning(`Failed to save: ${typedError.message}`);
|
||
}
|
||
}
|
||
}
|
||
finally {
|
||
// Try to delete the archive to save space
|
||
try {
|
||
yield utils.unlinkFile(archivePath);
|
||
}
|
||
catch (error) {
|
||
core.debug(`Failed to delete archive: ${error}`);
|
||
}
|
||
}
|
||
return cacheId;
|
||
});
|
||
}
|
||
/**
|
||
* Save cache using Cache Service v2
|
||
*
|
||
* @param paths a list of file paths to restore from the cache
|
||
* @param key an explicit key for restoring the cache
|
||
* @param options cache upload options
|
||
* @param enableCrossOsArchive an optional boolean enabled to save cache on windows which could be restored on any platform
|
||
* @returns
|
||
*/
|
||
function saveCacheV2(paths_1, key_1, options_1) {
|
||
return __awaiter(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) {
|
||
// Override UploadOptions to force the use of Azure
|
||
// ...options goes first because we want to override the default values
|
||
// set in UploadOptions with these specific figures
|
||
options = Object.assign(Object.assign({}, options), { uploadChunkSize: 64 * 1024 * 1024, uploadConcurrency: 8, useAzureSdk: true });
|
||
const compressionMethod = yield utils.getCompressionMethod();
|
||
const twirpClient = cacheTwirpClient.internalCacheTwirpClient();
|
||
let cacheId = -1;
|
||
const cachePaths = yield utils.resolvePaths(paths);
|
||
core.debug('Cache Paths:');
|
||
core.debug(`${JSON.stringify(cachePaths)}`);
|
||
if (cachePaths.length === 0) {
|
||
throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`);
|
||
}
|
||
const archiveFolder = yield utils.createTempDirectory();
|
||
const archivePath = path.join(archiveFolder, utils.getCacheFileName(compressionMethod));
|
||
core.debug(`Archive Path: ${archivePath}`);
|
||
try {
|
||
yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod);
|
||
if (core.isDebug()) {
|
||
yield (0, tar_1.listTar)(archivePath, compressionMethod);
|
||
}
|
||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||
core.debug(`File Size: ${archiveFileSize}`);
|
||
// Set the archive size in the options, will be used to display the upload progress
|
||
options.archiveSizeBytes = archiveFileSize;
|
||
core.debug('Reserving Cache');
|
||
const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive);
|
||
const request = {
|
||
key,
|
||
version
|
||
};
|
||
let signedUploadUrl;
|
||
try {
|
||
const response = yield twirpClient.CreateCacheEntry(request);
|
||
if (!response.ok) {
|
||
if (response.message) {
|
||
core.warning(`Cache reservation failed: ${response.message}`);
|
||
}
|
||
throw new Error(response.message || 'Response was not ok');
|
||
}
|
||
signedUploadUrl = response.signedUploadUrl;
|
||
}
|
||
catch (error) {
|
||
core.debug(`Failed to reserve cache: ${error}`);
|
||
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`);
|
||
}
|
||
core.debug(`Attempting to upload cache located at: ${archivePath}`);
|
||
yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options);
|
||
const finalizeRequest = {
|
||
key,
|
||
version,
|
||
sizeBytes: `${archiveFileSize}`
|
||
};
|
||
const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest);
|
||
core.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`);
|
||
if (!finalizeResponse.ok) {
|
||
if (finalizeResponse.message) {
|
||
throw new FinalizeCacheError(finalizeResponse.message);
|
||
}
|
||
throw new Error(`Unable to finalize cache with key ${key}, another job may be finalizing this cache.`);
|
||
}
|
||
cacheId = parseInt(finalizeResponse.entryId);
|
||
}
|
||
catch (error) {
|
||
const typedError = error;
|
||
if (typedError.name === ValidationError.name) {
|
||
throw error;
|
||
}
|
||
else if (typedError.name === ReserveCacheError.name) {
|
||
core.info(`Failed to save: ${typedError.message}`);
|
||
}
|
||
else if (typedError.name === FinalizeCacheError.name) {
|
||
core.warning(typedError.message);
|
||
}
|
||
else {
|
||
// Log server errors (5xx) as errors, all other errors as warnings
|
||
if (typedError instanceof http_client_1.HttpClientError &&
|
||
typeof typedError.statusCode === 'number' &&
|
||
typedError.statusCode >= 500) {
|
||
core.error(`Failed to save: ${typedError.message}`);
|
||
}
|
||
else {
|
||
core.warning(`Failed to save: ${typedError.message}`);
|
||
}
|
||
}
|
||
}
|
||
finally {
|
||
// Try to delete the archive to save space
|
||
try {
|
||
yield utils.unlinkFile(archivePath);
|
||
}
|
||
catch (error) {
|
||
core.debug(`Failed to delete archive: ${error}`);
|
||
}
|
||
}
|
||
return cacheId;
|
||
});
|
||
}
|
||
//# sourceMappingURL=cache.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 93156:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.CacheService = exports.GetCacheEntryDownloadURLResponse = exports.GetCacheEntryDownloadURLRequest = exports.FinalizeCacheEntryUploadResponse = exports.FinalizeCacheEntryUploadRequest = exports.CreateCacheEntryResponse = exports.CreateCacheEntryRequest = void 0;
|
||
// @generated by protobuf-ts 2.9.1 with parameter long_type_string,client_none,generate_dependencies
|
||
// @generated from protobuf file "results/api/v1/cache.proto" (package "github.actions.results.api.v1", syntax proto3)
|
||
// tslint:disable
|
||
const runtime_rpc_1 = __nccwpck_require__(44420);
|
||
const runtime_1 = __nccwpck_require__(68886);
|
||
const runtime_2 = __nccwpck_require__(68886);
|
||
const runtime_3 = __nccwpck_require__(68886);
|
||
const runtime_4 = __nccwpck_require__(68886);
|
||
const runtime_5 = __nccwpck_require__(68886);
|
||
const cachemetadata_1 = __nccwpck_require__(89444);
|
||
// @generated message type with reflection information, may provide speed optimized methods
|
||
class CreateCacheEntryRequest$Type extends runtime_5.MessageType {
|
||
constructor() {
|
||
super("github.actions.results.api.v1.CreateCacheEntryRequest", [
|
||
{ no: 1, name: "metadata", kind: "message", T: () => cachemetadata_1.CacheMetadata },
|
||
{ no: 2, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||
{ no: 3, name: "version", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
||
]);
|
||
}
|
||
create(value) {
|
||
const message = { key: "", version: "" };
|
||
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
|
||
if (value !== undefined)
|
||
(0, runtime_3.reflectionMergePartial)(this, message, value);
|
||
return message;
|
||
}
|
||
internalBinaryRead(reader, length, options, target) {
|
||
let message = target !== null && target !== void 0 ? target : this.create(), end = reader.pos + length;
|
||
while (reader.pos < end) {
|
||
let [fieldNo, wireType] = reader.tag();
|
||
switch (fieldNo) {
|
||
case /* github.actions.results.entities.v1.CacheMetadata metadata */ 1:
|
||
message.metadata = cachemetadata_1.CacheMetadata.internalBinaryRead(reader, reader.uint32(), options, message.metadata);
|
||
break;
|
||
case /* string key */ 2:
|
||
message.key = reader.string();
|
||
break;
|
||
case /* string version */ 3:
|
||
message.version = reader.string();
|
||
break;
|
||
default:
|
||
let u = options.readUnknownField;
|
||
if (u === "throw")
|
||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||
let d = reader.skip(wireType);
|
||
if (u !== false)
|
||
(u === true ? runtime_2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||
}
|
||
}
|
||
return message;
|
||
}
|
||
internalBinaryWrite(message, writer, options) {
|
||
/* github.actions.results.entities.v1.CacheMetadata metadata = 1; */
|
||
if (message.metadata)
|
||
cachemetadata_1.CacheMetadata.internalBinaryWrite(message.metadata, writer.tag(1, runtime_1.WireType.LengthDelimited).fork(), options).join();
|
||
/* string key = 2; */
|
||
if (message.key !== "")
|
||
writer.tag(2, runtime_1.WireType.LengthDelimited).string(message.key);
|
||
/* string version = 3; */
|
||
if (message.version !== "")
|
||
writer.tag(3, runtime_1.WireType.LengthDelimited).string(message.version);
|
||
let u = options.writeUnknownFields;
|
||
if (u !== false)
|
||
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||
return writer;
|
||
}
|
||
}
|
||
/**
|
||
* @generated MessageType for protobuf message github.actions.results.api.v1.CreateCacheEntryRequest
|
||
*/
|
||
exports.CreateCacheEntryRequest = new CreateCacheEntryRequest$Type();
|
||
// @generated message type with reflection information, may provide speed optimized methods
|
||
class CreateCacheEntryResponse$Type extends runtime_5.MessageType {
|
||
constructor() {
|
||
super("github.actions.results.api.v1.CreateCacheEntryResponse", [
|
||
{ no: 1, name: "ok", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
|
||
{ no: 2, name: "signed_upload_url", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||
{ no: 3, name: "message", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
||
]);
|
||
}
|
||
create(value) {
|
||
const message = { ok: false, signedUploadUrl: "", message: "" };
|
||
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
|
||
if (value !== undefined)
|
||
(0, runtime_3.reflectionMergePartial)(this, message, value);
|
||
return message;
|
||
}
|
||
internalBinaryRead(reader, length, options, target) {
|
||
let message = target !== null && target !== void 0 ? target : this.create(), end = reader.pos + length;
|
||
while (reader.pos < end) {
|
||
let [fieldNo, wireType] = reader.tag();
|
||
switch (fieldNo) {
|
||
case /* bool ok */ 1:
|
||
message.ok = reader.bool();
|
||
break;
|
||
case /* string signed_upload_url */ 2:
|
||
message.signedUploadUrl = reader.string();
|
||
break;
|
||
case /* string message */ 3:
|
||
message.message = reader.string();
|
||
break;
|
||
default:
|
||
let u = options.readUnknownField;
|
||
if (u === "throw")
|
||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||
let d = reader.skip(wireType);
|
||
if (u !== false)
|
||
(u === true ? runtime_2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||
}
|
||
}
|
||
return message;
|
||
}
|
||
internalBinaryWrite(message, writer, options) {
|
||
/* bool ok = 1; */
|
||
if (message.ok !== false)
|
||
writer.tag(1, runtime_1.WireType.Varint).bool(message.ok);
|
||
/* string signed_upload_url = 2; */
|
||
if (message.signedUploadUrl !== "")
|
||
writer.tag(2, runtime_1.WireType.LengthDelimited).string(message.signedUploadUrl);
|
||
/* string message = 3; */
|
||
if (message.message !== "")
|
||
writer.tag(3, runtime_1.WireType.LengthDelimited).string(message.message);
|
||
let u = options.writeUnknownFields;
|
||
if (u !== false)
|
||
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||
return writer;
|
||
}
|
||
}
|
||
/**
|
||
* @generated MessageType for protobuf message github.actions.results.api.v1.CreateCacheEntryResponse
|
||
*/
|
||
exports.CreateCacheEntryResponse = new CreateCacheEntryResponse$Type();
|
||
// @generated message type with reflection information, may provide speed optimized methods
|
||
class FinalizeCacheEntryUploadRequest$Type extends runtime_5.MessageType {
|
||
constructor() {
|
||
super("github.actions.results.api.v1.FinalizeCacheEntryUploadRequest", [
|
||
{ no: 1, name: "metadata", kind: "message", T: () => cachemetadata_1.CacheMetadata },
|
||
{ no: 2, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||
{ no: 3, name: "size_bytes", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
|
||
{ no: 4, name: "version", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
||
]);
|
||
}
|
||
create(value) {
|
||
const message = { key: "", sizeBytes: "0", version: "" };
|
||
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
|
||
if (value !== undefined)
|
||
(0, runtime_3.reflectionMergePartial)(this, message, value);
|
||
return message;
|
||
}
|
||
internalBinaryRead(reader, length, options, target) {
|
||
let message = target !== null && target !== void 0 ? target : this.create(), end = reader.pos + length;
|
||
while (reader.pos < end) {
|
||
let [fieldNo, wireType] = reader.tag();
|
||
switch (fieldNo) {
|
||
case /* github.actions.results.entities.v1.CacheMetadata metadata */ 1:
|
||
message.metadata = cachemetadata_1.CacheMetadata.internalBinaryRead(reader, reader.uint32(), options, message.metadata);
|
||
break;
|
||
case /* string key */ 2:
|
||
message.key = reader.string();
|
||
break;
|
||
case /* int64 size_bytes */ 3:
|
||
message.sizeBytes = reader.int64().toString();
|
||
break;
|
||
case /* string version */ 4:
|
||
message.version = reader.string();
|
||
break;
|
||
default:
|
||
let u = options.readUnknownField;
|
||
if (u === "throw")
|
||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||
let d = reader.skip(wireType);
|
||
if (u !== false)
|
||
(u === true ? runtime_2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||
}
|
||
}
|
||
return message;
|
||
}
|
||
internalBinaryWrite(message, writer, options) {
|
||
/* github.actions.results.entities.v1.CacheMetadata metadata = 1; */
|
||
if (message.metadata)
|
||
cachemetadata_1.CacheMetadata.internalBinaryWrite(message.metadata, writer.tag(1, runtime_1.WireType.LengthDelimited).fork(), options).join();
|
||
/* string key = 2; */
|
||
if (message.key !== "")
|
||
writer.tag(2, runtime_1.WireType.LengthDelimited).string(message.key);
|
||
/* int64 size_bytes = 3; */
|
||
if (message.sizeBytes !== "0")
|
||
writer.tag(3, runtime_1.WireType.Varint).int64(message.sizeBytes);
|
||
/* string version = 4; */
|
||
if (message.version !== "")
|
||
writer.tag(4, runtime_1.WireType.LengthDelimited).string(message.version);
|
||
let u = options.writeUnknownFields;
|
||
if (u !== false)
|
||
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||
return writer;
|
||
}
|
||
}
|
||
/**
|
||
* @generated MessageType for protobuf message github.actions.results.api.v1.FinalizeCacheEntryUploadRequest
|
||
*/
|
||
exports.FinalizeCacheEntryUploadRequest = new FinalizeCacheEntryUploadRequest$Type();
|
||
// @generated message type with reflection information, may provide speed optimized methods
|
||
class FinalizeCacheEntryUploadResponse$Type extends runtime_5.MessageType {
|
||
constructor() {
|
||
super("github.actions.results.api.v1.FinalizeCacheEntryUploadResponse", [
|
||
{ no: 1, name: "ok", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
|
||
{ no: 2, name: "entry_id", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
|
||
{ no: 3, name: "message", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
||
]);
|
||
}
|
||
create(value) {
|
||
const message = { ok: false, entryId: "0", message: "" };
|
||
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
|
||
if (value !== undefined)
|
||
(0, runtime_3.reflectionMergePartial)(this, message, value);
|
||
return message;
|
||
}
|
||
internalBinaryRead(reader, length, options, target) {
|
||
let message = target !== null && target !== void 0 ? target : this.create(), end = reader.pos + length;
|
||
while (reader.pos < end) {
|
||
let [fieldNo, wireType] = reader.tag();
|
||
switch (fieldNo) {
|
||
case /* bool ok */ 1:
|
||
message.ok = reader.bool();
|
||
break;
|
||
case /* int64 entry_id */ 2:
|
||
message.entryId = reader.int64().toString();
|
||
break;
|
||
case /* string message */ 3:
|
||
message.message = reader.string();
|
||
break;
|
||
default:
|
||
let u = options.readUnknownField;
|
||
if (u === "throw")
|
||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||
let d = reader.skip(wireType);
|
||
if (u !== false)
|
||
(u === true ? runtime_2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||
}
|
||
}
|
||
return message;
|
||
}
|
||
internalBinaryWrite(message, writer, options) {
|
||
/* bool ok = 1; */
|
||
if (message.ok !== false)
|
||
writer.tag(1, runtime_1.WireType.Varint).bool(message.ok);
|
||
/* int64 entry_id = 2; */
|
||
if (message.entryId !== "0")
|
||
writer.tag(2, runtime_1.WireType.Varint).int64(message.entryId);
|
||
/* string message = 3; */
|
||
if (message.message !== "")
|
||
writer.tag(3, runtime_1.WireType.LengthDelimited).string(message.message);
|
||
let u = options.writeUnknownFields;
|
||
if (u !== false)
|
||
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||
return writer;
|
||
}
|
||
}
|
||
/**
|
||
* @generated MessageType for protobuf message github.actions.results.api.v1.FinalizeCacheEntryUploadResponse
|
||
*/
|
||
exports.FinalizeCacheEntryUploadResponse = new FinalizeCacheEntryUploadResponse$Type();
|
||
// @generated message type with reflection information, may provide speed optimized methods
|
||
class GetCacheEntryDownloadURLRequest$Type extends runtime_5.MessageType {
|
||
constructor() {
|
||
super("github.actions.results.api.v1.GetCacheEntryDownloadURLRequest", [
|
||
{ no: 1, name: "metadata", kind: "message", T: () => cachemetadata_1.CacheMetadata },
|
||
{ no: 2, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||
{ no: 3, name: "restore_keys", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 9 /*ScalarType.STRING*/ },
|
||
{ no: 4, name: "version", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
||
]);
|
||
}
|
||
create(value) {
|
||
const message = { key: "", restoreKeys: [], version: "" };
|
||
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
|
||
if (value !== undefined)
|
||
(0, runtime_3.reflectionMergePartial)(this, message, value);
|
||
return message;
|
||
}
|
||
internalBinaryRead(reader, length, options, target) {
|
||
let message = target !== null && target !== void 0 ? target : this.create(), end = reader.pos + length;
|
||
while (reader.pos < end) {
|
||
let [fieldNo, wireType] = reader.tag();
|
||
switch (fieldNo) {
|
||
case /* github.actions.results.entities.v1.CacheMetadata metadata */ 1:
|
||
message.metadata = cachemetadata_1.CacheMetadata.internalBinaryRead(reader, reader.uint32(), options, message.metadata);
|
||
break;
|
||
case /* string key */ 2:
|
||
message.key = reader.string();
|
||
break;
|
||
case /* repeated string restore_keys */ 3:
|
||
message.restoreKeys.push(reader.string());
|
||
break;
|
||
case /* string version */ 4:
|
||
message.version = reader.string();
|
||
break;
|
||
default:
|
||
let u = options.readUnknownField;
|
||
if (u === "throw")
|
||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||
let d = reader.skip(wireType);
|
||
if (u !== false)
|
||
(u === true ? runtime_2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||
}
|
||
}
|
||
return message;
|
||
}
|
||
internalBinaryWrite(message, writer, options) {
|
||
/* github.actions.results.entities.v1.CacheMetadata metadata = 1; */
|
||
if (message.metadata)
|
||
cachemetadata_1.CacheMetadata.internalBinaryWrite(message.metadata, writer.tag(1, runtime_1.WireType.LengthDelimited).fork(), options).join();
|
||
/* string key = 2; */
|
||
if (message.key !== "")
|
||
writer.tag(2, runtime_1.WireType.LengthDelimited).string(message.key);
|
||
/* repeated string restore_keys = 3; */
|
||
for (let i = 0; i < message.restoreKeys.length; i++)
|
||
writer.tag(3, runtime_1.WireType.LengthDelimited).string(message.restoreKeys[i]);
|
||
/* string version = 4; */
|
||
if (message.version !== "")
|
||
writer.tag(4, runtime_1.WireType.LengthDelimited).string(message.version);
|
||
let u = options.writeUnknownFields;
|
||
if (u !== false)
|
||
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||
return writer;
|
||
}
|
||
}
|
||
/**
|
||
* @generated MessageType for protobuf message github.actions.results.api.v1.GetCacheEntryDownloadURLRequest
|
||
*/
|
||
exports.GetCacheEntryDownloadURLRequest = new GetCacheEntryDownloadURLRequest$Type();
|
||
// @generated message type with reflection information, may provide speed optimized methods
|
||
class GetCacheEntryDownloadURLResponse$Type extends runtime_5.MessageType {
|
||
constructor() {
|
||
super("github.actions.results.api.v1.GetCacheEntryDownloadURLResponse", [
|
||
{ no: 1, name: "ok", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
|
||
{ no: 2, name: "signed_download_url", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||
{ no: 3, name: "matched_key", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
||
]);
|
||
}
|
||
create(value) {
|
||
const message = { ok: false, signedDownloadUrl: "", matchedKey: "" };
|
||
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
|
||
if (value !== undefined)
|
||
(0, runtime_3.reflectionMergePartial)(this, message, value);
|
||
return message;
|
||
}
|
||
internalBinaryRead(reader, length, options, target) {
|
||
let message = target !== null && target !== void 0 ? target : this.create(), end = reader.pos + length;
|
||
while (reader.pos < end) {
|
||
let [fieldNo, wireType] = reader.tag();
|
||
switch (fieldNo) {
|
||
case /* bool ok */ 1:
|
||
message.ok = reader.bool();
|
||
break;
|
||
case /* string signed_download_url */ 2:
|
||
message.signedDownloadUrl = reader.string();
|
||
break;
|
||
case /* string matched_key */ 3:
|
||
message.matchedKey = reader.string();
|
||
break;
|
||
default:
|
||
let u = options.readUnknownField;
|
||
if (u === "throw")
|
||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||
let d = reader.skip(wireType);
|
||
if (u !== false)
|
||
(u === true ? runtime_2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||
}
|
||
}
|
||
return message;
|
||
}
|
||
internalBinaryWrite(message, writer, options) {
|
||
/* bool ok = 1; */
|
||
if (message.ok !== false)
|
||
writer.tag(1, runtime_1.WireType.Varint).bool(message.ok);
|
||
/* string signed_download_url = 2; */
|
||
if (message.signedDownloadUrl !== "")
|
||
writer.tag(2, runtime_1.WireType.LengthDelimited).string(message.signedDownloadUrl);
|
||
/* string matched_key = 3; */
|
||
if (message.matchedKey !== "")
|
||
writer.tag(3, runtime_1.WireType.LengthDelimited).string(message.matchedKey);
|
||
let u = options.writeUnknownFields;
|
||
if (u !== false)
|
||
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||
return writer;
|
||
}
|
||
}
|
||
/**
|
||
* @generated MessageType for protobuf message github.actions.results.api.v1.GetCacheEntryDownloadURLResponse
|
||
*/
|
||
exports.GetCacheEntryDownloadURLResponse = new GetCacheEntryDownloadURLResponse$Type();
|
||
/**
|
||
* @generated ServiceType for protobuf service github.actions.results.api.v1.CacheService
|
||
*/
|
||
exports.CacheService = new runtime_rpc_1.ServiceType("github.actions.results.api.v1.CacheService", [
|
||
{ name: "CreateCacheEntry", options: {}, I: exports.CreateCacheEntryRequest, O: exports.CreateCacheEntryResponse },
|
||
{ name: "FinalizeCacheEntryUpload", options: {}, I: exports.FinalizeCacheEntryUploadRequest, O: exports.FinalizeCacheEntryUploadResponse },
|
||
{ name: "GetCacheEntryDownloadURL", options: {}, I: exports.GetCacheEntryDownloadURLRequest, O: exports.GetCacheEntryDownloadURLResponse }
|
||
]);
|
||
//# sourceMappingURL=cache.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 11486:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.CacheServiceClientProtobuf = exports.CacheServiceClientJSON = void 0;
|
||
const cache_1 = __nccwpck_require__(93156);
|
||
class CacheServiceClientJSON {
|
||
constructor(rpc) {
|
||
this.rpc = rpc;
|
||
this.CreateCacheEntry.bind(this);
|
||
this.FinalizeCacheEntryUpload.bind(this);
|
||
this.GetCacheEntryDownloadURL.bind(this);
|
||
}
|
||
CreateCacheEntry(request) {
|
||
const data = cache_1.CreateCacheEntryRequest.toJson(request, {
|
||
useProtoFieldName: true,
|
||
emitDefaultValues: false,
|
||
});
|
||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "CreateCacheEntry", "application/json", data);
|
||
return promise.then((data) => cache_1.CreateCacheEntryResponse.fromJson(data, {
|
||
ignoreUnknownFields: true,
|
||
}));
|
||
}
|
||
FinalizeCacheEntryUpload(request) {
|
||
const data = cache_1.FinalizeCacheEntryUploadRequest.toJson(request, {
|
||
useProtoFieldName: true,
|
||
emitDefaultValues: false,
|
||
});
|
||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "FinalizeCacheEntryUpload", "application/json", data);
|
||
return promise.then((data) => cache_1.FinalizeCacheEntryUploadResponse.fromJson(data, {
|
||
ignoreUnknownFields: true,
|
||
}));
|
||
}
|
||
GetCacheEntryDownloadURL(request) {
|
||
const data = cache_1.GetCacheEntryDownloadURLRequest.toJson(request, {
|
||
useProtoFieldName: true,
|
||
emitDefaultValues: false,
|
||
});
|
||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "GetCacheEntryDownloadURL", "application/json", data);
|
||
return promise.then((data) => cache_1.GetCacheEntryDownloadURLResponse.fromJson(data, {
|
||
ignoreUnknownFields: true,
|
||
}));
|
||
}
|
||
}
|
||
exports.CacheServiceClientJSON = CacheServiceClientJSON;
|
||
class CacheServiceClientProtobuf {
|
||
constructor(rpc) {
|
||
this.rpc = rpc;
|
||
this.CreateCacheEntry.bind(this);
|
||
this.FinalizeCacheEntryUpload.bind(this);
|
||
this.GetCacheEntryDownloadURL.bind(this);
|
||
}
|
||
CreateCacheEntry(request) {
|
||
const data = cache_1.CreateCacheEntryRequest.toBinary(request);
|
||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "CreateCacheEntry", "application/protobuf", data);
|
||
return promise.then((data) => cache_1.CreateCacheEntryResponse.fromBinary(data));
|
||
}
|
||
FinalizeCacheEntryUpload(request) {
|
||
const data = cache_1.FinalizeCacheEntryUploadRequest.toBinary(request);
|
||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "FinalizeCacheEntryUpload", "application/protobuf", data);
|
||
return promise.then((data) => cache_1.FinalizeCacheEntryUploadResponse.fromBinary(data));
|
||
}
|
||
GetCacheEntryDownloadURL(request) {
|
||
const data = cache_1.GetCacheEntryDownloadURLRequest.toBinary(request);
|
||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "GetCacheEntryDownloadURL", "application/protobuf", data);
|
||
return promise.then((data) => cache_1.GetCacheEntryDownloadURLResponse.fromBinary(data));
|
||
}
|
||
}
|
||
exports.CacheServiceClientProtobuf = CacheServiceClientProtobuf;
|
||
//# sourceMappingURL=cache.twirp-client.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 89444:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.CacheMetadata = void 0;
|
||
const runtime_1 = __nccwpck_require__(68886);
|
||
const runtime_2 = __nccwpck_require__(68886);
|
||
const runtime_3 = __nccwpck_require__(68886);
|
||
const runtime_4 = __nccwpck_require__(68886);
|
||
const runtime_5 = __nccwpck_require__(68886);
|
||
const cachescope_1 = __nccwpck_require__(29425);
|
||
// @generated message type with reflection information, may provide speed optimized methods
|
||
class CacheMetadata$Type extends runtime_5.MessageType {
|
||
constructor() {
|
||
super("github.actions.results.entities.v1.CacheMetadata", [
|
||
{ no: 1, name: "repository_id", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
|
||
{ no: 2, name: "scope", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => cachescope_1.CacheScope }
|
||
]);
|
||
}
|
||
create(value) {
|
||
const message = { repositoryId: "0", scope: [] };
|
||
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
|
||
if (value !== undefined)
|
||
(0, runtime_3.reflectionMergePartial)(this, message, value);
|
||
return message;
|
||
}
|
||
internalBinaryRead(reader, length, options, target) {
|
||
let message = target !== null && target !== void 0 ? target : this.create(), end = reader.pos + length;
|
||
while (reader.pos < end) {
|
||
let [fieldNo, wireType] = reader.tag();
|
||
switch (fieldNo) {
|
||
case /* int64 repository_id */ 1:
|
||
message.repositoryId = reader.int64().toString();
|
||
break;
|
||
case /* repeated github.actions.results.entities.v1.CacheScope scope */ 2:
|
||
message.scope.push(cachescope_1.CacheScope.internalBinaryRead(reader, reader.uint32(), options));
|
||
break;
|
||
default:
|
||
let u = options.readUnknownField;
|
||
if (u === "throw")
|
||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||
let d = reader.skip(wireType);
|
||
if (u !== false)
|
||
(u === true ? runtime_2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||
}
|
||
}
|
||
return message;
|
||
}
|
||
internalBinaryWrite(message, writer, options) {
|
||
/* int64 repository_id = 1; */
|
||
if (message.repositoryId !== "0")
|
||
writer.tag(1, runtime_1.WireType.Varint).int64(message.repositoryId);
|
||
/* repeated github.actions.results.entities.v1.CacheScope scope = 2; */
|
||
for (let i = 0; i < message.scope.length; i++)
|
||
cachescope_1.CacheScope.internalBinaryWrite(message.scope[i], writer.tag(2, runtime_1.WireType.LengthDelimited).fork(), options).join();
|
||
let u = options.writeUnknownFields;
|
||
if (u !== false)
|
||
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||
return writer;
|
||
}
|
||
}
|
||
/**
|
||
* @generated MessageType for protobuf message github.actions.results.entities.v1.CacheMetadata
|
||
*/
|
||
exports.CacheMetadata = new CacheMetadata$Type();
|
||
//# sourceMappingURL=cachemetadata.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 29425:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.CacheScope = void 0;
|
||
const runtime_1 = __nccwpck_require__(68886);
|
||
const runtime_2 = __nccwpck_require__(68886);
|
||
const runtime_3 = __nccwpck_require__(68886);
|
||
const runtime_4 = __nccwpck_require__(68886);
|
||
const runtime_5 = __nccwpck_require__(68886);
|
||
// @generated message type with reflection information, may provide speed optimized methods
|
||
class CacheScope$Type extends runtime_5.MessageType {
|
||
constructor() {
|
||
super("github.actions.results.entities.v1.CacheScope", [
|
||
{ no: 1, name: "scope", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||
{ no: 2, name: "permission", kind: "scalar", T: 3 /*ScalarType.INT64*/ }
|
||
]);
|
||
}
|
||
create(value) {
|
||
const message = { scope: "", permission: "0" };
|
||
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
|
||
if (value !== undefined)
|
||
(0, runtime_3.reflectionMergePartial)(this, message, value);
|
||
return message;
|
||
}
|
||
internalBinaryRead(reader, length, options, target) {
|
||
let message = target !== null && target !== void 0 ? target : this.create(), end = reader.pos + length;
|
||
while (reader.pos < end) {
|
||
let [fieldNo, wireType] = reader.tag();
|
||
switch (fieldNo) {
|
||
case /* string scope */ 1:
|
||
message.scope = reader.string();
|
||
break;
|
||
case /* int64 permission */ 2:
|
||
message.permission = reader.int64().toString();
|
||
break;
|
||
default:
|
||
let u = options.readUnknownField;
|
||
if (u === "throw")
|
||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||
let d = reader.skip(wireType);
|
||
if (u !== false)
|
||
(u === true ? runtime_2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||
}
|
||
}
|
||
return message;
|
||
}
|
||
internalBinaryWrite(message, writer, options) {
|
||
/* string scope = 1; */
|
||
if (message.scope !== "")
|
||
writer.tag(1, runtime_1.WireType.LengthDelimited).string(message.scope);
|
||
/* int64 permission = 2; */
|
||
if (message.permission !== "0")
|
||
writer.tag(2, runtime_1.WireType.Varint).int64(message.permission);
|
||
let u = options.writeUnknownFields;
|
||
if (u !== false)
|
||
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||
return writer;
|
||
}
|
||
}
|
||
/**
|
||
* @generated MessageType for protobuf message github.actions.results.entities.v1.CacheScope
|
||
*/
|
||
exports.CacheScope = new CacheScope$Type();
|
||
//# sourceMappingURL=cachescope.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 73171:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.getCacheEntry = getCacheEntry;
|
||
exports.downloadCache = downloadCache;
|
||
exports.reserveCache = reserveCache;
|
||
exports.saveCache = saveCache;
|
||
const core = __importStar(__nccwpck_require__(37484));
|
||
const http_client_1 = __nccwpck_require__(54844);
|
||
const auth_1 = __nccwpck_require__(44552);
|
||
const fs = __importStar(__nccwpck_require__(79896));
|
||
const url_1 = __nccwpck_require__(87016);
|
||
const utils = __importStar(__nccwpck_require__(98299));
|
||
const uploadUtils_1 = __nccwpck_require__(35268);
|
||
const downloadUtils_1 = __nccwpck_require__(75067);
|
||
const options_1 = __nccwpck_require__(98356);
|
||
const requestUtils_1 = __nccwpck_require__(32846);
|
||
const config_1 = __nccwpck_require__(17606);
|
||
const user_agent_1 = __nccwpck_require__(41899);
|
||
function getCacheApiUrl(resource) {
|
||
const baseUrl = (0, config_1.getCacheServiceURL)();
|
||
if (!baseUrl) {
|
||
throw new Error('Cache Service Url not found, unable to restore cache.');
|
||
}
|
||
const url = `${baseUrl}_apis/artifactcache/${resource}`;
|
||
core.debug(`Resource Url: ${url}`);
|
||
return url;
|
||
}
|
||
function createAcceptHeader(type, apiVersion) {
|
||
return `${type};api-version=${apiVersion}`;
|
||
}
|
||
function getRequestOptions() {
|
||
const requestOptions = {
|
||
headers: {
|
||
Accept: createAcceptHeader('application/json', '6.0-preview.1')
|
||
}
|
||
};
|
||
return requestOptions;
|
||
}
|
||
function createHttpClient() {
|
||
const token = process.env['ACTIONS_RUNTIME_TOKEN'] || '';
|
||
const bearerCredentialHandler = new auth_1.BearerCredentialHandler(token);
|
||
return new http_client_1.HttpClient((0, user_agent_1.getUserAgentString)(), [bearerCredentialHandler], getRequestOptions());
|
||
}
|
||
function getCacheEntry(keys, paths, options) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const httpClient = createHttpClient();
|
||
const version = utils.getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive);
|
||
const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`;
|
||
const response = yield (0, requestUtils_1.retryTypedResponse)('getCacheEntry', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); }));
|
||
// Cache not found
|
||
if (response.statusCode === 204) {
|
||
// List cache for primary key only if cache miss occurs
|
||
if (core.isDebug()) {
|
||
yield printCachesListForDiagnostics(keys[0], httpClient, version);
|
||
}
|
||
return null;
|
||
}
|
||
if (!(0, requestUtils_1.isSuccessStatusCode)(response.statusCode)) {
|
||
throw new Error(`Cache service responded with ${response.statusCode}`);
|
||
}
|
||
const cacheResult = response.result;
|
||
const cacheDownloadUrl = cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.archiveLocation;
|
||
if (!cacheDownloadUrl) {
|
||
// Cache achiveLocation 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;
|
||
});
|
||
}
|
||
function printCachesListForDiagnostics(key, httpClient, version) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const resource = `caches?key=${encodeURIComponent(key)}`;
|
||
const response = yield (0, requestUtils_1.retryTypedResponse)('listCache', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); }));
|
||
if (response.statusCode === 200) {
|
||
const cacheListResult = response.result;
|
||
const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount;
|
||
if (totalCount && totalCount > 0) {
|
||
core.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env['GITHUB_REF']}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key \nOther caches with similar key:`);
|
||
for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) {
|
||
core.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
function downloadCache(archiveLocation, archivePath, options) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const archiveUrl = new url_1.URL(archiveLocation);
|
||
const downloadOptions = (0, options_1.getDownloadOptions)(options);
|
||
if (archiveUrl.hostname.endsWith('.blob.core.windows.net')) {
|
||
if (downloadOptions.useAzureSdk) {
|
||
// Use Azure storage SDK to download caches hosted on Azure to improve speed and reliability.
|
||
yield (0, downloadUtils_1.downloadCacheStorageSDK)(archiveLocation, archivePath, downloadOptions);
|
||
}
|
||
else if (downloadOptions.concurrentBlobDownloads) {
|
||
// Use concurrent implementation with HttpClient to work around blob SDK issue
|
||
yield (0, downloadUtils_1.downloadCacheHttpClientConcurrent)(archiveLocation, archivePath, downloadOptions);
|
||
}
|
||
else {
|
||
// Otherwise, download using the Actions http-client.
|
||
yield (0, downloadUtils_1.downloadCacheHttpClient)(archiveLocation, archivePath);
|
||
}
|
||
}
|
||
else {
|
||
yield (0, downloadUtils_1.downloadCacheHttpClient)(archiveLocation, archivePath);
|
||
}
|
||
});
|
||
}
|
||
// Reserve Cache
|
||
function reserveCache(key, paths, options) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const httpClient = createHttpClient();
|
||
const version = utils.getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive);
|
||
const reserveCacheRequest = {
|
||
key,
|
||
version,
|
||
cacheSize: options === null || options === void 0 ? void 0 : options.cacheSize
|
||
};
|
||
const response = yield (0, requestUtils_1.retryTypedResponse)('reserveCache', () => __awaiter(this, void 0, void 0, function* () {
|
||
return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest);
|
||
}));
|
||
return response;
|
||
});
|
||
}
|
||
function getContentRange(start, end) {
|
||
// 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}/*`;
|
||
}
|
||
function uploadChunk(httpClient, resourceUrl, openStream, start, end) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
core.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`);
|
||
const additionalHeaders = {
|
||
'Content-Type': 'application/octet-stream',
|
||
'Content-Range': getContentRange(start, end)
|
||
};
|
||
const uploadChunkResponse = yield (0, requestUtils_1.retryHttpClientResponse)(`uploadChunk (start: ${start}, end: ${end})`, () => __awaiter(this, void 0, void 0, function* () {
|
||
return httpClient.sendStream('PATCH', resourceUrl, openStream(), additionalHeaders);
|
||
}));
|
||
if (!(0, requestUtils_1.isSuccessStatusCode)(uploadChunkResponse.message.statusCode)) {
|
||
throw new Error(`Cache service responded with ${uploadChunkResponse.message.statusCode} during upload chunk.`);
|
||
}
|
||
});
|
||
}
|
||
function uploadFile(httpClient, cacheId, archivePath, options) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
// Upload Chunks
|
||
const fileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||
const resourceUrl = getCacheApiUrl(`caches/${cacheId.toString()}`);
|
||
const fd = fs.openSync(archivePath, 'r');
|
||
const uploadOptions = (0, options_1.getUploadOptions)(options);
|
||
const concurrency = utils.assertDefined('uploadConcurrency', uploadOptions.uploadConcurrency);
|
||
const maxChunkSize = utils.assertDefined('uploadChunkSize', uploadOptions.uploadChunkSize);
|
||
const parallelUploads = [...new Array(concurrency).keys()];
|
||
core.debug('Awaiting all uploads');
|
||
let offset = 0;
|
||
try {
|
||
yield Promise.all(parallelUploads.map(() => __awaiter(this, void 0, void 0, function* () {
|
||
while (offset < fileSize) {
|
||
const chunkSize = Math.min(fileSize - offset, maxChunkSize);
|
||
const start = offset;
|
||
const end = offset + chunkSize - 1;
|
||
offset += maxChunkSize;
|
||
yield uploadChunk(httpClient, resourceUrl, () => fs
|
||
.createReadStream(archivePath, {
|
||
fd,
|
||
start,
|
||
end,
|
||
autoClose: false
|
||
})
|
||
.on('error', error => {
|
||
throw new Error(`Cache upload failed because file read failed with ${error.message}`);
|
||
}), start, end);
|
||
}
|
||
})));
|
||
}
|
||
finally {
|
||
fs.closeSync(fd);
|
||
}
|
||
return;
|
||
});
|
||
}
|
||
function commitCache(httpClient, cacheId, filesize) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const commitCacheRequest = { size: filesize };
|
||
return yield (0, requestUtils_1.retryTypedResponse)('commitCache', () => __awaiter(this, void 0, void 0, function* () {
|
||
return httpClient.postJson(getCacheApiUrl(`caches/${cacheId.toString()}`), commitCacheRequest);
|
||
}));
|
||
});
|
||
}
|
||
function saveCache(cacheId, archivePath, signedUploadURL, options) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const uploadOptions = (0, options_1.getUploadOptions)(options);
|
||
if (uploadOptions.useAzureSdk) {
|
||
// Use Azure storage SDK to upload caches directly to Azure
|
||
if (!signedUploadURL) {
|
||
throw new Error('Azure Storage SDK can only be used when a signed URL is provided.');
|
||
}
|
||
yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options);
|
||
}
|
||
else {
|
||
const httpClient = createHttpClient();
|
||
core.debug('Upload cache');
|
||
yield uploadFile(httpClient, cacheId, archivePath, options);
|
||
// Commit Cache
|
||
core.debug('Commiting cache');
|
||
const cacheSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||
core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
|
||
const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
|
||
if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) {
|
||
throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`);
|
||
}
|
||
core.info('Cache saved successfully');
|
||
}
|
||
});
|
||
}
|
||
//# sourceMappingURL=cacheHttpClient.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 98299:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||
var m = o[Symbol.asyncIterator], i;
|
||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.createTempDirectory = createTempDirectory;
|
||
exports.getArchiveFileSizeInBytes = getArchiveFileSizeInBytes;
|
||
exports.resolvePaths = resolvePaths;
|
||
exports.unlinkFile = unlinkFile;
|
||
exports.getCompressionMethod = getCompressionMethod;
|
||
exports.getCacheFileName = getCacheFileName;
|
||
exports.getGnuTarPathOnWindows = getGnuTarPathOnWindows;
|
||
exports.assertDefined = assertDefined;
|
||
exports.getCacheVersion = getCacheVersion;
|
||
exports.getRuntimeToken = getRuntimeToken;
|
||
const core = __importStar(__nccwpck_require__(37484));
|
||
const exec = __importStar(__nccwpck_require__(95236));
|
||
const glob = __importStar(__nccwpck_require__(47206));
|
||
const io = __importStar(__nccwpck_require__(94994));
|
||
const crypto = __importStar(__nccwpck_require__(76982));
|
||
const fs = __importStar(__nccwpck_require__(79896));
|
||
const path = __importStar(__nccwpck_require__(16928));
|
||
const semver = __importStar(__nccwpck_require__(39318));
|
||
const util = __importStar(__nccwpck_require__(39023));
|
||
const constants_1 = __nccwpck_require__(58287);
|
||
const versionSalt = '1.0';
|
||
// From https://github.com/actions/toolkit/blob/main/packages/tool-cache/src/tool-cache.ts#L23
|
||
function createTempDirectory() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const IS_WINDOWS = process.platform === 'win32';
|
||
let tempDirectory = process.env['RUNNER_TEMP'] || '';
|
||
if (!tempDirectory) {
|
||
let baseLocation;
|
||
if (IS_WINDOWS) {
|
||
// On Windows use the USERPROFILE env variable
|
||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
||
}
|
||
else {
|
||
if (process.platform === 'darwin') {
|
||
baseLocation = '/Users';
|
||
}
|
||
else {
|
||
baseLocation = '/home';
|
||
}
|
||
}
|
||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||
}
|
||
const dest = path.join(tempDirectory, crypto.randomUUID());
|
||
yield io.mkdirP(dest);
|
||
return dest;
|
||
});
|
||
}
|
||
function getArchiveFileSizeInBytes(filePath) {
|
||
return fs.statSync(filePath).size;
|
||
}
|
||
function resolvePaths(patterns) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
var _a, e_1, _b, _c;
|
||
var _d;
|
||
const paths = [];
|
||
const workspace = (_d = process.env['GITHUB_WORKSPACE']) !== null && _d !== void 0 ? _d : process.cwd();
|
||
const globber = yield glob.create(patterns.join('\n'), {
|
||
implicitDescendants: false
|
||
});
|
||
try {
|
||
for (var _e = true, _f = __asyncValues(globber.globGenerator()), _g; _g = yield _f.next(), _a = _g.done, !_a; _e = true) {
|
||
_c = _g.value;
|
||
_e = false;
|
||
const file = _c;
|
||
const relativeFile = path
|
||
.relative(workspace, file)
|
||
.replace(new RegExp(`\\${path.sep}`, 'g'), '/');
|
||
core.debug(`Matched: ${relativeFile}`);
|
||
// Paths are made relative so the tar entries are all relative to the root of the workspace.
|
||
if (relativeFile === '') {
|
||
// path.relative returns empty string if workspace and file are equal
|
||
paths.push('.');
|
||
}
|
||
else {
|
||
paths.push(`${relativeFile}`);
|
||
}
|
||
}
|
||
}
|
||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||
finally {
|
||
try {
|
||
if (!_e && !_a && (_b = _f.return)) yield _b.call(_f);
|
||
}
|
||
finally { if (e_1) throw e_1.error; }
|
||
}
|
||
return paths;
|
||
});
|
||
}
|
||
function unlinkFile(filePath) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return util.promisify(fs.unlink)(filePath);
|
||
});
|
||
}
|
||
function getVersion(app_1) {
|
||
return __awaiter(this, arguments, void 0, function* (app, additionalArgs = []) {
|
||
let versionOutput = '';
|
||
additionalArgs.push('--version');
|
||
core.debug(`Checking ${app} ${additionalArgs.join(' ')}`);
|
||
try {
|
||
yield exec.exec(`${app}`, additionalArgs, {
|
||
ignoreReturnCode: true,
|
||
silent: true,
|
||
listeners: {
|
||
stdout: (data) => (versionOutput += data.toString()),
|
||
stderr: (data) => (versionOutput += data.toString())
|
||
}
|
||
});
|
||
}
|
||
catch (err) {
|
||
core.debug(err.message);
|
||
}
|
||
versionOutput = versionOutput.trim();
|
||
core.debug(versionOutput);
|
||
return versionOutput;
|
||
});
|
||
}
|
||
// Use zstandard if possible to maximize cache performance
|
||
function getCompressionMethod() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const versionOutput = yield getVersion('zstd', ['--quiet']);
|
||
const version = semver.clean(versionOutput);
|
||
core.debug(`zstd version: ${version}`);
|
||
if (versionOutput === '') {
|
||
return constants_1.CompressionMethod.Gzip;
|
||
}
|
||
else {
|
||
return constants_1.CompressionMethod.ZstdWithoutLong;
|
||
}
|
||
});
|
||
}
|
||
function getCacheFileName(compressionMethod) {
|
||
return compressionMethod === constants_1.CompressionMethod.Gzip
|
||
? constants_1.CacheFilename.Gzip
|
||
: constants_1.CacheFilename.Zstd;
|
||
}
|
||
function getGnuTarPathOnWindows() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
if (fs.existsSync(constants_1.GnuTarPathOnWindows)) {
|
||
return constants_1.GnuTarPathOnWindows;
|
||
}
|
||
const versionOutput = yield getVersion('tar');
|
||
return versionOutput.toLowerCase().includes('gnu tar') ? io.which('tar') : '';
|
||
});
|
||
}
|
||
function assertDefined(name, value) {
|
||
if (value === undefined) {
|
||
throw Error(`Expected ${name} but value was undefiend`);
|
||
}
|
||
return value;
|
||
}
|
||
function getCacheVersion(paths, compressionMethod, enableCrossOsArchive = false) {
|
||
// don't pass changes upstream
|
||
const components = paths.slice();
|
||
// Add compression method to cache version to restore
|
||
// compressed cache as per compression method
|
||
if (compressionMethod) {
|
||
components.push(compressionMethod);
|
||
}
|
||
// Only check for windows platforms if enableCrossOsArchive is false
|
||
if (process.platform === 'win32' && !enableCrossOsArchive) {
|
||
components.push('windows-only');
|
||
}
|
||
// Add salt to cache version to support breaking changes in cache entry
|
||
components.push(versionSalt);
|
||
return crypto.createHash('sha256').update(components.join('|')).digest('hex');
|
||
}
|
||
function getRuntimeToken() {
|
||
const token = process.env['ACTIONS_RUNTIME_TOKEN'];
|
||
if (!token) {
|
||
throw new Error('Unable to get the ACTIONS_RUNTIME_TOKEN env variable');
|
||
}
|
||
return token;
|
||
}
|
||
//# sourceMappingURL=cacheUtils.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 17606:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.isGhes = isGhes;
|
||
exports.getCacheServiceVersion = getCacheServiceVersion;
|
||
exports.getCacheServiceURL = getCacheServiceURL;
|
||
function isGhes() {
|
||
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
||
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
||
const isGitHubHost = hostname === 'GITHUB.COM';
|
||
const isGheHost = hostname.endsWith('.GHE.COM');
|
||
const isLocalHost = hostname.endsWith('.LOCALHOST');
|
||
return !isGitHubHost && !isGheHost && !isLocalHost;
|
||
}
|
||
function getCacheServiceVersion() {
|
||
// Cache service v2 is not supported on GHES. We will default to
|
||
// cache service v1 even if the feature flag was enabled by user.
|
||
if (isGhes())
|
||
return 'v1';
|
||
return process.env['ACTIONS_CACHE_SERVICE_V2'] ? 'v2' : 'v1';
|
||
}
|
||
function getCacheServiceURL() {
|
||
const version = getCacheServiceVersion();
|
||
// Based on the version of the cache service, we will determine which
|
||
// URL to use.
|
||
switch (version) {
|
||
case 'v1':
|
||
return (process.env['ACTIONS_CACHE_URL'] ||
|
||
process.env['ACTIONS_RESULTS_URL'] ||
|
||
'');
|
||
case 'v2':
|
||
return process.env['ACTIONS_RESULTS_URL'] || '';
|
||
default:
|
||
throw new Error(`Unsupported cache service version: ${version}`);
|
||
}
|
||
}
|
||
//# sourceMappingURL=config.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 58287:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.CacheFileSizeLimit = exports.ManifestFilename = exports.TarFilename = exports.SystemTarPathOnWindows = exports.GnuTarPathOnWindows = exports.SocketTimeout = exports.DefaultRetryDelay = exports.DefaultRetryAttempts = exports.ArchiveToolType = exports.CompressionMethod = exports.CacheFilename = void 0;
|
||
var CacheFilename;
|
||
(function (CacheFilename) {
|
||
CacheFilename["Gzip"] = "cache.tgz";
|
||
CacheFilename["Zstd"] = "cache.tzst";
|
||
})(CacheFilename || (exports.CacheFilename = CacheFilename = {}));
|
||
var CompressionMethod;
|
||
(function (CompressionMethod) {
|
||
CompressionMethod["Gzip"] = "gzip";
|
||
// Long range mode was added to zstd in v1.3.2.
|
||
// This enum is for earlier version of zstd that does not have --long support
|
||
CompressionMethod["ZstdWithoutLong"] = "zstd-without-long";
|
||
CompressionMethod["Zstd"] = "zstd";
|
||
})(CompressionMethod || (exports.CompressionMethod = CompressionMethod = {}));
|
||
var ArchiveToolType;
|
||
(function (ArchiveToolType) {
|
||
ArchiveToolType["GNU"] = "gnu";
|
||
ArchiveToolType["BSD"] = "bsd";
|
||
})(ArchiveToolType || (exports.ArchiveToolType = ArchiveToolType = {}));
|
||
// The default number of retry attempts.
|
||
exports.DefaultRetryAttempts = 2;
|
||
// The default delay in milliseconds between retry attempts.
|
||
exports.DefaultRetryDelay = 5000;
|
||
// Socket timeout in milliseconds during download. If no traffic is received
|
||
// over the socket during this period, the socket is destroyed and the download
|
||
// is aborted.
|
||
exports.SocketTimeout = 5000;
|
||
// The default path of GNUtar on hosted Windows runners
|
||
exports.GnuTarPathOnWindows = `${process.env['PROGRAMFILES']}\\Git\\usr\\bin\\tar.exe`;
|
||
// The default path of BSDtar on hosted Windows runners
|
||
exports.SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System32\\tar.exe`;
|
||
exports.TarFilename = 'cache.tar';
|
||
exports.ManifestFilename = 'manifest.txt';
|
||
exports.CacheFileSizeLimit = 10 * Math.pow(1024, 3); // 10GiB per repository
|
||
//# sourceMappingURL=constants.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 75067:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.DownloadProgress = void 0;
|
||
exports.downloadCacheHttpClient = downloadCacheHttpClient;
|
||
exports.downloadCacheHttpClientConcurrent = downloadCacheHttpClientConcurrent;
|
||
exports.downloadCacheStorageSDK = downloadCacheStorageSDK;
|
||
const core = __importStar(__nccwpck_require__(37484));
|
||
const http_client_1 = __nccwpck_require__(54844);
|
||
const storage_blob_1 = __nccwpck_require__(71400);
|
||
const buffer = __importStar(__nccwpck_require__(20181));
|
||
const fs = __importStar(__nccwpck_require__(79896));
|
||
const stream = __importStar(__nccwpck_require__(2203));
|
||
const util = __importStar(__nccwpck_require__(39023));
|
||
const utils = __importStar(__nccwpck_require__(98299));
|
||
const constants_1 = __nccwpck_require__(58287);
|
||
const requestUtils_1 = __nccwpck_require__(32846);
|
||
const abort_controller_1 = __nccwpck_require__(68110);
|
||
/**
|
||
* Pipes the body of a HTTP response to a stream
|
||
*
|
||
* @param response the HTTP response
|
||
* @param output the writable stream
|
||
*/
|
||
function pipeResponseToStream(response, output) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const pipeline = util.promisify(stream.pipeline);
|
||
yield pipeline(response.message, output);
|
||
});
|
||
}
|
||
/**
|
||
* Class for tracking the download state and displaying stats.
|
||
*/
|
||
class DownloadProgress {
|
||
constructor(contentLength) {
|
||
this.contentLength = contentLength;
|
||
this.segmentIndex = 0;
|
||
this.segmentSize = 0;
|
||
this.segmentOffset = 0;
|
||
this.receivedBytes = 0;
|
||
this.displayedComplete = false;
|
||
this.startTime = Date.now();
|
||
}
|
||
/**
|
||
* Progress to the next segment. Only call this method when the previous segment
|
||
* is complete.
|
||
*
|
||
* @param segmentSize the length of the next segment
|
||
*/
|
||
nextSegment(segmentSize) {
|
||
this.segmentOffset = this.segmentOffset + this.segmentSize;
|
||
this.segmentIndex = this.segmentIndex + 1;
|
||
this.segmentSize = segmentSize;
|
||
this.receivedBytes = 0;
|
||
core.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`);
|
||
}
|
||
/**
|
||
* Sets the number of bytes received for the current segment.
|
||
*
|
||
* @param receivedBytes the number of bytes received
|
||
*/
|
||
setReceivedBytes(receivedBytes) {
|
||
this.receivedBytes = receivedBytes;
|
||
}
|
||
/**
|
||
* Returns the total number of bytes transferred.
|
||
*/
|
||
getTransferredBytes() {
|
||
return this.segmentOffset + this.receivedBytes;
|
||
}
|
||
/**
|
||
* Returns true if the download is complete.
|
||
*/
|
||
isDone() {
|
||
return this.getTransferredBytes() === this.contentLength;
|
||
}
|
||
/**
|
||
* Prints the current download stats. Once the download completes, this will print one
|
||
* last line and then stop.
|
||
*/
|
||
display() {
|
||
if (this.displayedComplete) {
|
||
return;
|
||
}
|
||
const transferredBytes = this.segmentOffset + this.receivedBytes;
|
||
const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1);
|
||
const elapsedTime = Date.now() - this.startTime;
|
||
const downloadSpeed = (transferredBytes /
|
||
(1024 * 1024) /
|
||
(elapsedTime / 1000)).toFixed(1);
|
||
core.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`);
|
||
if (this.isDone()) {
|
||
this.displayedComplete = true;
|
||
}
|
||
}
|
||
/**
|
||
* Returns a function used to handle TransferProgressEvents.
|
||
*/
|
||
onProgress() {
|
||
return (progress) => {
|
||
this.setReceivedBytes(progress.loadedBytes);
|
||
};
|
||
}
|
||
/**
|
||
* Starts the timer that displays the stats.
|
||
*
|
||
* @param delayInMs the delay between each write
|
||
*/
|
||
startDisplayTimer(delayInMs = 1000) {
|
||
const displayCallback = () => {
|
||
this.display();
|
||
if (!this.isDone()) {
|
||
this.timeoutHandle = setTimeout(displayCallback, delayInMs);
|
||
}
|
||
};
|
||
this.timeoutHandle = setTimeout(displayCallback, delayInMs);
|
||
}
|
||
/**
|
||
* Stops the timer that displays the stats. As this typically indicates the download
|
||
* is complete, this will display one last line, unless the last line has already
|
||
* been written.
|
||
*/
|
||
stopDisplayTimer() {
|
||
if (this.timeoutHandle) {
|
||
clearTimeout(this.timeoutHandle);
|
||
this.timeoutHandle = undefined;
|
||
}
|
||
this.display();
|
||
}
|
||
}
|
||
exports.DownloadProgress = DownloadProgress;
|
||
/**
|
||
* Download the cache using the Actions toolkit http-client
|
||
*
|
||
* @param archiveLocation the URL for the cache
|
||
* @param archivePath the local path where the cache is saved
|
||
*/
|
||
function downloadCacheHttpClient(archiveLocation, archivePath) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const writeStream = fs.createWriteStream(archivePath);
|
||
const httpClient = new http_client_1.HttpClient('actions/cache');
|
||
const downloadResponse = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCache', () => __awaiter(this, void 0, void 0, function* () { return httpClient.get(archiveLocation); }));
|
||
// Abort download if no traffic received over the socket.
|
||
downloadResponse.message.socket.setTimeout(constants_1.SocketTimeout, () => {
|
||
downloadResponse.message.destroy();
|
||
core.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`);
|
||
});
|
||
yield pipeResponseToStream(downloadResponse, writeStream);
|
||
// Validate download size.
|
||
const contentLengthHeader = downloadResponse.message.headers['content-length'];
|
||
if (contentLengthHeader) {
|
||
const expectedLength = parseInt(contentLengthHeader);
|
||
const actualLength = utils.getArchiveFileSizeInBytes(archivePath);
|
||
if (actualLength !== expectedLength) {
|
||
throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`);
|
||
}
|
||
}
|
||
else {
|
||
core.debug('Unable to validate download, no Content-Length header');
|
||
}
|
||
});
|
||
}
|
||
/**
|
||
* Download the cache using the Actions toolkit http-client concurrently
|
||
*
|
||
* @param archiveLocation the URL for the cache
|
||
* @param archivePath the local path where the cache is saved
|
||
*/
|
||
function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
var _a;
|
||
const archiveDescriptor = yield fs.promises.open(archivePath, 'w');
|
||
const httpClient = new http_client_1.HttpClient('actions/cache', undefined, {
|
||
socketTimeout: options.timeoutInMs,
|
||
keepAlive: true
|
||
});
|
||
try {
|
||
const res = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCacheMetadata', () => __awaiter(this, void 0, void 0, function* () { return yield httpClient.request('HEAD', archiveLocation, null, {}); }));
|
||
const lengthHeader = res.message.headers['content-length'];
|
||
if (lengthHeader === undefined || lengthHeader === null) {
|
||
throw new Error('Content-Length not found on blob response');
|
||
}
|
||
const length = parseInt(lengthHeader);
|
||
if (Number.isNaN(length)) {
|
||
throw new Error(`Could not interpret Content-Length: ${length}`);
|
||
}
|
||
const downloads = [];
|
||
const blockSize = 4 * 1024 * 1024;
|
||
for (let offset = 0; offset < length; offset += blockSize) {
|
||
const count = Math.min(blockSize, length - offset);
|
||
downloads.push({
|
||
offset,
|
||
promiseGetter: () => __awaiter(this, void 0, void 0, function* () {
|
||
return yield downloadSegmentRetry(httpClient, archiveLocation, offset, count);
|
||
})
|
||
});
|
||
}
|
||
// reverse to use .pop instead of .shift
|
||
downloads.reverse();
|
||
let actives = 0;
|
||
let bytesDownloaded = 0;
|
||
const progress = new DownloadProgress(length);
|
||
progress.startDisplayTimer();
|
||
const progressFn = progress.onProgress();
|
||
const activeDownloads = [];
|
||
let nextDownload;
|
||
const waitAndWrite = () => __awaiter(this, void 0, void 0, function* () {
|
||
const segment = yield Promise.race(Object.values(activeDownloads));
|
||
yield archiveDescriptor.write(segment.buffer, 0, segment.count, segment.offset);
|
||
actives--;
|
||
delete activeDownloads[segment.offset];
|
||
bytesDownloaded += segment.count;
|
||
progressFn({ loadedBytes: bytesDownloaded });
|
||
});
|
||
while ((nextDownload = downloads.pop())) {
|
||
activeDownloads[nextDownload.offset] = nextDownload.promiseGetter();
|
||
actives++;
|
||
if (actives >= ((_a = options.downloadConcurrency) !== null && _a !== void 0 ? _a : 10)) {
|
||
yield waitAndWrite();
|
||
}
|
||
}
|
||
while (actives > 0) {
|
||
yield waitAndWrite();
|
||
}
|
||
}
|
||
finally {
|
||
httpClient.dispose();
|
||
yield archiveDescriptor.close();
|
||
}
|
||
});
|
||
}
|
||
function downloadSegmentRetry(httpClient, archiveLocation, offset, count) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const retries = 5;
|
||
let failures = 0;
|
||
while (true) {
|
||
try {
|
||
const timeout = 30000;
|
||
const result = yield promiseWithTimeout(timeout, downloadSegment(httpClient, archiveLocation, offset, count));
|
||
if (typeof result === 'string') {
|
||
throw new Error('downloadSegmentRetry failed due to timeout');
|
||
}
|
||
return result;
|
||
}
|
||
catch (err) {
|
||
if (failures >= retries) {
|
||
throw err;
|
||
}
|
||
failures++;
|
||
}
|
||
}
|
||
});
|
||
}
|
||
function downloadSegment(httpClient, archiveLocation, offset, count) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const partRes = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCachePart', () => __awaiter(this, void 0, void 0, function* () {
|
||
return yield httpClient.get(archiveLocation, {
|
||
Range: `bytes=${offset}-${offset + count - 1}`
|
||
});
|
||
}));
|
||
if (!partRes.readBodyBuffer) {
|
||
throw new Error('Expected HttpClientResponse to implement readBodyBuffer');
|
||
}
|
||
return {
|
||
offset,
|
||
count,
|
||
buffer: yield partRes.readBodyBuffer()
|
||
};
|
||
});
|
||
}
|
||
/**
|
||
* Download the cache using the Azure Storage SDK. Only call this method if the
|
||
* URL points to an Azure Storage endpoint.
|
||
*
|
||
* @param archiveLocation the URL for the cache
|
||
* @param archivePath the local path where the cache is saved
|
||
* @param options the download options with the defaults set
|
||
*/
|
||
function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
var _a;
|
||
const client = new storage_blob_1.BlockBlobClient(archiveLocation, undefined, {
|
||
retryOptions: {
|
||
// Override the timeout used when downloading each 4 MB chunk
|
||
// The default is 2 min / MB, which is way too slow
|
||
tryTimeoutInMs: options.timeoutInMs
|
||
}
|
||
});
|
||
const properties = yield client.getProperties();
|
||
const contentLength = (_a = properties.contentLength) !== null && _a !== void 0 ? _a : -1;
|
||
if (contentLength < 0) {
|
||
// We should never hit this condition, but just in case fall back to downloading the
|
||
// file as one large stream
|
||
core.debug('Unable to determine content length, downloading file with http-client...');
|
||
yield downloadCacheHttpClient(archiveLocation, archivePath);
|
||
}
|
||
else {
|
||
// Use downloadToBuffer for faster downloads, since internally it splits the
|
||
// file into 4 MB chunks which can then be parallelized and retried independently
|
||
//
|
||
// If the file exceeds the buffer maximum length (~1 GB on 32-bit systems and ~2 GB
|
||
// on 64-bit systems), split the download into multiple segments
|
||
// ~2 GB = 2147483647, beyond this, we start getting out of range error. So, capping it accordingly.
|
||
// Updated segment size to 128MB = 134217728 bytes, to complete a segment faster and fail fast
|
||
const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH);
|
||
const downloadProgress = new DownloadProgress(contentLength);
|
||
const fd = fs.openSync(archivePath, 'w');
|
||
try {
|
||
downloadProgress.startDisplayTimer();
|
||
const controller = new abort_controller_1.AbortController();
|
||
const abortSignal = controller.signal;
|
||
while (!downloadProgress.isDone()) {
|
||
const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize;
|
||
const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart);
|
||
downloadProgress.nextSegment(segmentSize);
|
||
const result = yield promiseWithTimeout(options.segmentTimeoutInMs || 3600000, client.downloadToBuffer(segmentStart, segmentSize, {
|
||
abortSignal,
|
||
concurrency: options.downloadConcurrency,
|
||
onProgress: downloadProgress.onProgress()
|
||
}));
|
||
if (result === 'timeout') {
|
||
controller.abort();
|
||
throw new Error('Aborting cache download as the download time exceeded the timeout.');
|
||
}
|
||
else if (Buffer.isBuffer(result)) {
|
||
fs.writeFileSync(fd, result);
|
||
}
|
||
}
|
||
}
|
||
finally {
|
||
downloadProgress.stopDisplayTimer();
|
||
fs.closeSync(fd);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
const promiseWithTimeout = (timeoutMs, promise) => __awaiter(void 0, void 0, void 0, function* () {
|
||
let timeoutHandle;
|
||
const timeoutPromise = new Promise(resolve => {
|
||
timeoutHandle = setTimeout(() => resolve('timeout'), timeoutMs);
|
||
});
|
||
return Promise.race([promise, timeoutPromise]).then(result => {
|
||
clearTimeout(timeoutHandle);
|
||
return result;
|
||
});
|
||
});
|
||
//# sourceMappingURL=downloadUtils.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 32846:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.isSuccessStatusCode = isSuccessStatusCode;
|
||
exports.isServerErrorStatusCode = isServerErrorStatusCode;
|
||
exports.isRetryableStatusCode = isRetryableStatusCode;
|
||
exports.retry = retry;
|
||
exports.retryTypedResponse = retryTypedResponse;
|
||
exports.retryHttpClientResponse = retryHttpClientResponse;
|
||
const core = __importStar(__nccwpck_require__(37484));
|
||
const http_client_1 = __nccwpck_require__(54844);
|
||
const constants_1 = __nccwpck_require__(58287);
|
||
function isSuccessStatusCode(statusCode) {
|
||
if (!statusCode) {
|
||
return false;
|
||
}
|
||
return statusCode >= 200 && statusCode < 300;
|
||
}
|
||
function isServerErrorStatusCode(statusCode) {
|
||
if (!statusCode) {
|
||
return true;
|
||
}
|
||
return statusCode >= 500;
|
||
}
|
||
function isRetryableStatusCode(statusCode) {
|
||
if (!statusCode) {
|
||
return false;
|
||
}
|
||
const retryableStatusCodes = [
|
||
http_client_1.HttpCodes.BadGateway,
|
||
http_client_1.HttpCodes.ServiceUnavailable,
|
||
http_client_1.HttpCodes.GatewayTimeout
|
||
];
|
||
return retryableStatusCodes.includes(statusCode);
|
||
}
|
||
function sleep(milliseconds) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return new Promise(resolve => setTimeout(resolve, milliseconds));
|
||
});
|
||
}
|
||
function retry(name_1, method_1, getStatusCode_1) {
|
||
return __awaiter(this, arguments, void 0, function* (name, method, getStatusCode, maxAttempts = constants_1.DefaultRetryAttempts, delay = constants_1.DefaultRetryDelay, onError = undefined) {
|
||
let errorMessage = '';
|
||
let attempt = 1;
|
||
while (attempt <= maxAttempts) {
|
||
let response = undefined;
|
||
let statusCode = undefined;
|
||
let isRetryable = false;
|
||
try {
|
||
response = yield method();
|
||
}
|
||
catch (error) {
|
||
if (onError) {
|
||
response = onError(error);
|
||
}
|
||
isRetryable = true;
|
||
errorMessage = error.message;
|
||
}
|
||
if (response) {
|
||
statusCode = getStatusCode(response);
|
||
if (!isServerErrorStatusCode(statusCode)) {
|
||
return response;
|
||
}
|
||
}
|
||
if (statusCode) {
|
||
isRetryable = isRetryableStatusCode(statusCode);
|
||
errorMessage = `Cache service responded with ${statusCode}`;
|
||
}
|
||
core.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`);
|
||
if (!isRetryable) {
|
||
core.debug(`${name} - Error is not retryable`);
|
||
break;
|
||
}
|
||
yield sleep(delay);
|
||
attempt++;
|
||
}
|
||
throw Error(`${name} failed: ${errorMessage}`);
|
||
});
|
||
}
|
||
function retryTypedResponse(name_1, method_1) {
|
||
return __awaiter(this, arguments, void 0, function* (name, method, maxAttempts = constants_1.DefaultRetryAttempts, delay = constants_1.DefaultRetryDelay) {
|
||
return yield retry(name, method, (response) => response.statusCode, maxAttempts, delay,
|
||
// If the error object contains the statusCode property, extract it and return
|
||
// an TypedResponse<T> so it can be processed by the retry logic.
|
||
(error) => {
|
||
if (error instanceof http_client_1.HttpClientError) {
|
||
return {
|
||
statusCode: error.statusCode,
|
||
result: null,
|
||
headers: {},
|
||
error
|
||
};
|
||
}
|
||
else {
|
||
return undefined;
|
||
}
|
||
});
|
||
});
|
||
}
|
||
function retryHttpClientResponse(name_1, method_1) {
|
||
return __awaiter(this, arguments, void 0, function* (name, method, maxAttempts = constants_1.DefaultRetryAttempts, delay = constants_1.DefaultRetryDelay) {
|
||
return yield retry(name, method, (response) => response.message.statusCode, maxAttempts, delay);
|
||
});
|
||
}
|
||
//# sourceMappingURL=requestUtils.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 96819:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.internalCacheTwirpClient = internalCacheTwirpClient;
|
||
const core_1 = __nccwpck_require__(37484);
|
||
const user_agent_1 = __nccwpck_require__(41899);
|
||
const errors_1 = __nccwpck_require__(50263);
|
||
const config_1 = __nccwpck_require__(17606);
|
||
const cacheUtils_1 = __nccwpck_require__(98299);
|
||
const auth_1 = __nccwpck_require__(44552);
|
||
const http_client_1 = __nccwpck_require__(54844);
|
||
const cache_twirp_client_1 = __nccwpck_require__(11486);
|
||
const util_1 = __nccwpck_require__(27564);
|
||
/**
|
||
* This class is a wrapper around the CacheServiceClientJSON class generated by Twirp.
|
||
*
|
||
* It adds retry logic to the request method, which is not present in the generated client.
|
||
*
|
||
* This class is used to interact with cache service v2.
|
||
*/
|
||
class CacheServiceClient {
|
||
constructor(userAgent, maxAttempts, baseRetryIntervalMilliseconds, retryMultiplier) {
|
||
this.maxAttempts = 5;
|
||
this.baseRetryIntervalMilliseconds = 3000;
|
||
this.retryMultiplier = 1.5;
|
||
const token = (0, cacheUtils_1.getRuntimeToken)();
|
||
this.baseUrl = (0, config_1.getCacheServiceURL)();
|
||
if (maxAttempts) {
|
||
this.maxAttempts = maxAttempts;
|
||
}
|
||
if (baseRetryIntervalMilliseconds) {
|
||
this.baseRetryIntervalMilliseconds = baseRetryIntervalMilliseconds;
|
||
}
|
||
if (retryMultiplier) {
|
||
this.retryMultiplier = retryMultiplier;
|
||
}
|
||
this.httpClient = new http_client_1.HttpClient(userAgent, [
|
||
new auth_1.BearerCredentialHandler(token)
|
||
]);
|
||
}
|
||
// This function satisfies the Rpc interface. It is compatible with the JSON
|
||
// JSON generated client.
|
||
request(service, method, contentType, data) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const url = new URL(`/twirp/${service}/${method}`, this.baseUrl).href;
|
||
(0, core_1.debug)(`[Request] ${method} ${url}`);
|
||
const headers = {
|
||
'Content-Type': contentType
|
||
};
|
||
try {
|
||
const { body } = yield this.retryableRequest(() => __awaiter(this, void 0, void 0, function* () { return this.httpClient.post(url, JSON.stringify(data), headers); }));
|
||
return body;
|
||
}
|
||
catch (error) {
|
||
throw new Error(`Failed to ${method}: ${error.message}`);
|
||
}
|
||
});
|
||
}
|
||
retryableRequest(operation) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
let attempt = 0;
|
||
let errorMessage = '';
|
||
let rawBody = '';
|
||
while (attempt < this.maxAttempts) {
|
||
let isRetryable = false;
|
||
try {
|
||
const response = yield operation();
|
||
const statusCode = response.message.statusCode;
|
||
rawBody = yield response.readBody();
|
||
(0, core_1.debug)(`[Response] - ${response.message.statusCode}`);
|
||
(0, core_1.debug)(`Headers: ${JSON.stringify(response.message.headers, null, 2)}`);
|
||
const body = JSON.parse(rawBody);
|
||
(0, util_1.maskSecretUrls)(body);
|
||
(0, core_1.debug)(`Body: ${JSON.stringify(body, null, 2)}`);
|
||
if (this.isSuccessStatusCode(statusCode)) {
|
||
return { response, body };
|
||
}
|
||
isRetryable = this.isRetryableHttpStatusCode(statusCode);
|
||
errorMessage = `Failed request: (${statusCode}) ${response.message.statusMessage}`;
|
||
if (body.msg) {
|
||
if (errors_1.UsageError.isUsageErrorMessage(body.msg)) {
|
||
throw new errors_1.UsageError();
|
||
}
|
||
errorMessage = `${errorMessage}: ${body.msg}`;
|
||
}
|
||
// Handle rate limiting - don't retry, just warn and exit
|
||
// For more info, see https://docs.github.com/en/actions/reference/limits
|
||
if (statusCode === http_client_1.HttpCodes.TooManyRequests) {
|
||
const retryAfterHeader = response.message.headers['retry-after'];
|
||
if (retryAfterHeader) {
|
||
const parsedSeconds = parseInt(retryAfterHeader, 10);
|
||
if (!isNaN(parsedSeconds) && parsedSeconds > 0) {
|
||
(0, core_1.warning)(`You've hit a rate limit, your rate limit will reset in ${parsedSeconds} seconds`);
|
||
}
|
||
}
|
||
throw new errors_1.RateLimitError(`Rate limited: ${errorMessage}`);
|
||
}
|
||
}
|
||
catch (error) {
|
||
if (error instanceof SyntaxError) {
|
||
(0, core_1.debug)(`Raw Body: ${rawBody}`);
|
||
}
|
||
if (error instanceof errors_1.UsageError) {
|
||
throw error;
|
||
}
|
||
if (error instanceof errors_1.RateLimitError) {
|
||
throw error;
|
||
}
|
||
if (errors_1.NetworkError.isNetworkErrorCode(error === null || error === void 0 ? void 0 : error.code)) {
|
||
throw new errors_1.NetworkError(error === null || error === void 0 ? void 0 : error.code);
|
||
}
|
||
isRetryable = true;
|
||
errorMessage = error.message;
|
||
}
|
||
if (!isRetryable) {
|
||
throw new Error(`Received non-retryable error: ${errorMessage}`);
|
||
}
|
||
if (attempt + 1 === this.maxAttempts) {
|
||
throw new Error(`Failed to make request after ${this.maxAttempts} attempts: ${errorMessage}`);
|
||
}
|
||
const retryTimeMilliseconds = this.getExponentialRetryTimeMilliseconds(attempt);
|
||
(0, core_1.info)(`Attempt ${attempt + 1} of ${this.maxAttempts} failed with error: ${errorMessage}. Retrying request in ${retryTimeMilliseconds} ms...`);
|
||
yield this.sleep(retryTimeMilliseconds);
|
||
attempt++;
|
||
}
|
||
throw new Error(`Request failed`);
|
||
});
|
||
}
|
||
isSuccessStatusCode(statusCode) {
|
||
if (!statusCode)
|
||
return false;
|
||
return statusCode >= 200 && statusCode < 300;
|
||
}
|
||
isRetryableHttpStatusCode(statusCode) {
|
||
if (!statusCode)
|
||
return false;
|
||
const retryableStatusCodes = [
|
||
http_client_1.HttpCodes.BadGateway,
|
||
http_client_1.HttpCodes.GatewayTimeout,
|
||
http_client_1.HttpCodes.InternalServerError,
|
||
http_client_1.HttpCodes.ServiceUnavailable
|
||
];
|
||
return retryableStatusCodes.includes(statusCode);
|
||
}
|
||
sleep(milliseconds) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return new Promise(resolve => setTimeout(resolve, milliseconds));
|
||
});
|
||
}
|
||
getExponentialRetryTimeMilliseconds(attempt) {
|
||
if (attempt < 0) {
|
||
throw new Error('attempt should be a positive integer');
|
||
}
|
||
if (attempt === 0) {
|
||
return this.baseRetryIntervalMilliseconds;
|
||
}
|
||
const minTime = this.baseRetryIntervalMilliseconds * Math.pow(this.retryMultiplier, attempt);
|
||
const maxTime = minTime * this.retryMultiplier;
|
||
// returns a random number between minTime and maxTime (exclusive)
|
||
return Math.trunc(Math.random() * (maxTime - minTime) + minTime);
|
||
}
|
||
}
|
||
function internalCacheTwirpClient(options) {
|
||
const client = new CacheServiceClient((0, user_agent_1.getUserAgentString)(), options === null || options === void 0 ? void 0 : options.maxAttempts, options === null || options === void 0 ? void 0 : options.retryIntervalMs, options === null || options === void 0 ? void 0 : options.retryMultiplier);
|
||
return new cache_twirp_client_1.CacheServiceClientJSON(client);
|
||
}
|
||
//# sourceMappingURL=cacheTwirpClient.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 50263:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.RateLimitError = exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0;
|
||
class FilesNotFoundError extends Error {
|
||
constructor(files = []) {
|
||
let message = 'No files were found to upload';
|
||
if (files.length > 0) {
|
||
message += `: ${files.join(', ')}`;
|
||
}
|
||
super(message);
|
||
this.files = files;
|
||
this.name = 'FilesNotFoundError';
|
||
}
|
||
}
|
||
exports.FilesNotFoundError = FilesNotFoundError;
|
||
class InvalidResponseError extends Error {
|
||
constructor(message) {
|
||
super(message);
|
||
this.name = 'InvalidResponseError';
|
||
}
|
||
}
|
||
exports.InvalidResponseError = InvalidResponseError;
|
||
class CacheNotFoundError extends Error {
|
||
constructor(message = 'Cache not found') {
|
||
super(message);
|
||
this.name = 'CacheNotFoundError';
|
||
}
|
||
}
|
||
exports.CacheNotFoundError = CacheNotFoundError;
|
||
class GHESNotSupportedError extends Error {
|
||
constructor(message = '@actions/cache v4.1.4+, actions/cache/save@v4+ and actions/cache/restore@v4+ are not currently supported on GHES.') {
|
||
super(message);
|
||
this.name = 'GHESNotSupportedError';
|
||
}
|
||
}
|
||
exports.GHESNotSupportedError = GHESNotSupportedError;
|
||
class NetworkError extends Error {
|
||
constructor(code) {
|
||
const message = `Unable to make request: ${code}\nIf you are using self-hosted runners, please make sure your runner has access to all GitHub endpoints: https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners#communication-between-self-hosted-runners-and-github`;
|
||
super(message);
|
||
this.code = code;
|
||
this.name = 'NetworkError';
|
||
}
|
||
}
|
||
exports.NetworkError = NetworkError;
|
||
NetworkError.isNetworkErrorCode = (code) => {
|
||
if (!code)
|
||
return false;
|
||
return [
|
||
'ECONNRESET',
|
||
'ENOTFOUND',
|
||
'ETIMEDOUT',
|
||
'ECONNREFUSED',
|
||
'EHOSTUNREACH'
|
||
].includes(code);
|
||
};
|
||
class UsageError extends Error {
|
||
constructor() {
|
||
const message = `Cache storage quota has been hit. Unable to upload any new cache entries. Usage is recalculated every 6-12 hours.\nMore info on storage limits: https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#calculating-minute-and-storage-spending`;
|
||
super(message);
|
||
this.name = 'UsageError';
|
||
}
|
||
}
|
||
exports.UsageError = UsageError;
|
||
UsageError.isUsageErrorMessage = (msg) => {
|
||
if (!msg)
|
||
return false;
|
||
return msg.includes('insufficient usage');
|
||
};
|
||
class RateLimitError extends Error {
|
||
constructor(message) {
|
||
super(message);
|
||
this.name = 'RateLimitError';
|
||
}
|
||
}
|
||
exports.RateLimitError = RateLimitError;
|
||
//# sourceMappingURL=errors.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 41899:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.getUserAgentString = getUserAgentString;
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
||
const packageJson = __nccwpck_require__(64012);
|
||
/**
|
||
* Ensure that this User Agent String is used in all HTTP calls so that we can monitor telemetry between different versions of this package
|
||
*/
|
||
function getUserAgentString() {
|
||
return `@actions/cache-${packageJson.version}`;
|
||
}
|
||
//# sourceMappingURL=user-agent.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 27564:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.maskSigUrl = maskSigUrl;
|
||
exports.maskSecretUrls = maskSecretUrls;
|
||
const core_1 = __nccwpck_require__(37484);
|
||
/**
|
||
* Masks the `sig` parameter in a URL and sets it as a secret.
|
||
*
|
||
* @param url - The URL containing the signature parameter to mask
|
||
* @remarks
|
||
* This function attempts to parse the provided URL and identify the 'sig' query parameter.
|
||
* If found, it registers both the raw and URL-encoded signature values as secrets using
|
||
* the Actions `setSecret` API, which prevents them from being displayed in logs.
|
||
*
|
||
* The function handles errors gracefully if URL parsing fails, logging them as debug messages.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* // Mask a signature in an Azure SAS token URL
|
||
* maskSigUrl('https://example.blob.core.windows.net/container/file.txt?sig=abc123&se=2023-01-01');
|
||
* ```
|
||
*/
|
||
function maskSigUrl(url) {
|
||
if (!url)
|
||
return;
|
||
try {
|
||
const parsedUrl = new URL(url);
|
||
const signature = parsedUrl.searchParams.get('sig');
|
||
if (signature) {
|
||
(0, core_1.setSecret)(signature);
|
||
(0, core_1.setSecret)(encodeURIComponent(signature));
|
||
}
|
||
}
|
||
catch (error) {
|
||
(0, core_1.debug)(`Failed to parse URL: ${url} ${error instanceof Error ? error.message : String(error)}`);
|
||
}
|
||
}
|
||
/**
|
||
* Masks sensitive information in URLs containing signature parameters.
|
||
* Currently supports masking 'sig' parameters in the 'signed_upload_url'
|
||
* and 'signed_download_url' properties of the provided object.
|
||
*
|
||
* @param body - The object should contain a signature
|
||
* @remarks
|
||
* This function extracts URLs from the object properties and calls maskSigUrl
|
||
* on each one to redact sensitive signature information. The function doesn't
|
||
* modify the original object; it only marks the signatures as secrets for
|
||
* logging purposes.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* const responseBody = {
|
||
* signed_upload_url: 'https://blob.core.windows.net/?sig=abc123',
|
||
* signed_download_url: 'https://blob.core/windows.net/?sig=def456'
|
||
* };
|
||
* maskSecretUrls(responseBody);
|
||
* ```
|
||
*/
|
||
function maskSecretUrls(body) {
|
||
if (typeof body !== 'object' || body === null) {
|
||
(0, core_1.debug)('body is not an object or is null');
|
||
return;
|
||
}
|
||
if ('signed_upload_url' in body &&
|
||
typeof body.signed_upload_url === 'string') {
|
||
maskSigUrl(body.signed_upload_url);
|
||
}
|
||
if ('signed_download_url' in body &&
|
||
typeof body.signed_download_url === 'string') {
|
||
maskSigUrl(body.signed_download_url);
|
||
}
|
||
}
|
||
//# sourceMappingURL=util.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 95321:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.listTar = listTar;
|
||
exports.extractTar = extractTar;
|
||
exports.createTar = createTar;
|
||
const exec_1 = __nccwpck_require__(95236);
|
||
const io = __importStar(__nccwpck_require__(94994));
|
||
const fs_1 = __nccwpck_require__(79896);
|
||
const path = __importStar(__nccwpck_require__(16928));
|
||
const utils = __importStar(__nccwpck_require__(98299));
|
||
const constants_1 = __nccwpck_require__(58287);
|
||
const IS_WINDOWS = process.platform === 'win32';
|
||
// Returns tar path and type: BSD or GNU
|
||
function getTarPath() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
switch (process.platform) {
|
||
case 'win32': {
|
||
const gnuTar = yield utils.getGnuTarPathOnWindows();
|
||
const systemTar = constants_1.SystemTarPathOnWindows;
|
||
if (gnuTar) {
|
||
// Use GNUtar as default on windows
|
||
return { path: gnuTar, type: constants_1.ArchiveToolType.GNU };
|
||
}
|
||
else if ((0, fs_1.existsSync)(systemTar)) {
|
||
return { path: systemTar, type: constants_1.ArchiveToolType.BSD };
|
||
}
|
||
break;
|
||
}
|
||
case 'darwin': {
|
||
const gnuTar = yield io.which('gtar', false);
|
||
if (gnuTar) {
|
||
// fix permission denied errors when extracting BSD tar archive with GNU tar - https://github.com/actions/cache/issues/527
|
||
return { path: gnuTar, type: constants_1.ArchiveToolType.GNU };
|
||
}
|
||
else {
|
||
return {
|
||
path: yield io.which('tar', true),
|
||
type: constants_1.ArchiveToolType.BSD
|
||
};
|
||
}
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
// Default assumption is GNU tar is present in path
|
||
return {
|
||
path: yield io.which('tar', true),
|
||
type: constants_1.ArchiveToolType.GNU
|
||
};
|
||
});
|
||
}
|
||
// Return arguments for tar as per tarPath, compressionMethod, method type and os
|
||
function getTarArgs(tarPath_1, compressionMethod_1, type_1) {
|
||
return __awaiter(this, arguments, void 0, function* (tarPath, compressionMethod, type, archivePath = '') {
|
||
const args = [`"${tarPath.path}"`];
|
||
const cacheFileName = utils.getCacheFileName(compressionMethod);
|
||
const tarFile = 'cache.tar';
|
||
const workingDirectory = getWorkingDirectory();
|
||
// Speficic args for BSD tar on windows for workaround
|
||
const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
|
||
compressionMethod !== constants_1.CompressionMethod.Gzip &&
|
||
IS_WINDOWS;
|
||
// Method specific args
|
||
switch (type) {
|
||
case 'create':
|
||
args.push('--posix', '-cf', BSD_TAR_ZSTD
|
||
? tarFile
|
||
: cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--exclude', BSD_TAR_ZSTD
|
||
? tarFile
|
||
: cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '--files-from', constants_1.ManifestFilename);
|
||
break;
|
||
case 'extract':
|
||
args.push('-xf', BSD_TAR_ZSTD
|
||
? tarFile
|
||
: archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', '-C', workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'));
|
||
break;
|
||
case 'list':
|
||
args.push('-tf', BSD_TAR_ZSTD
|
||
? tarFile
|
||
: archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P');
|
||
break;
|
||
}
|
||
// Platform specific args
|
||
if (tarPath.type === constants_1.ArchiveToolType.GNU) {
|
||
switch (process.platform) {
|
||
case 'win32':
|
||
args.push('--force-local');
|
||
break;
|
||
case 'darwin':
|
||
args.push('--delay-directory-restore');
|
||
break;
|
||
}
|
||
}
|
||
return args;
|
||
});
|
||
}
|
||
// Returns commands to run tar and compression program
|
||
function getCommands(compressionMethod_1, type_1) {
|
||
return __awaiter(this, arguments, void 0, function* (compressionMethod, type, archivePath = '') {
|
||
let args;
|
||
const tarPath = yield getTarPath();
|
||
const tarArgs = yield getTarArgs(tarPath, compressionMethod, type, archivePath);
|
||
const compressionArgs = type !== 'create'
|
||
? yield getDecompressionProgram(tarPath, compressionMethod, archivePath)
|
||
: yield getCompressionProgram(tarPath, compressionMethod);
|
||
const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
|
||
compressionMethod !== constants_1.CompressionMethod.Gzip &&
|
||
IS_WINDOWS;
|
||
if (BSD_TAR_ZSTD && type !== 'create') {
|
||
args = [[...compressionArgs].join(' '), [...tarArgs].join(' ')];
|
||
}
|
||
else {
|
||
args = [[...tarArgs].join(' '), [...compressionArgs].join(' ')];
|
||
}
|
||
if (BSD_TAR_ZSTD) {
|
||
return args;
|
||
}
|
||
return [args.join(' ')];
|
||
});
|
||
}
|
||
function getWorkingDirectory() {
|
||
var _a;
|
||
return (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : process.cwd();
|
||
}
|
||
// Common function for extractTar and listTar to get the compression method
|
||
function getDecompressionProgram(tarPath, compressionMethod, archivePath) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
// -d: Decompress.
|
||
// unzstd is equivalent to 'zstd -d'
|
||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
||
// Using 30 here because we also support 32-bit self-hosted runners.
|
||
const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
|
||
compressionMethod !== constants_1.CompressionMethod.Gzip &&
|
||
IS_WINDOWS;
|
||
switch (compressionMethod) {
|
||
case constants_1.CompressionMethod.Zstd:
|
||
return BSD_TAR_ZSTD
|
||
? [
|
||
'zstd -d --long=30 --force -o',
|
||
constants_1.TarFilename,
|
||
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
|
||
]
|
||
: [
|
||
'--use-compress-program',
|
||
IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30'
|
||
];
|
||
case constants_1.CompressionMethod.ZstdWithoutLong:
|
||
return BSD_TAR_ZSTD
|
||
? [
|
||
'zstd -d --force -o',
|
||
constants_1.TarFilename,
|
||
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
|
||
]
|
||
: ['--use-compress-program', IS_WINDOWS ? '"zstd -d"' : 'unzstd'];
|
||
default:
|
||
return ['-z'];
|
||
}
|
||
});
|
||
}
|
||
// Used for creating the archive
|
||
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
|
||
// zstdmt is equivalent to 'zstd -T0'
|
||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
||
// Using 30 here because we also support 32-bit self-hosted runners.
|
||
// Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
|
||
function getCompressionProgram(tarPath, compressionMethod) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const cacheFileName = utils.getCacheFileName(compressionMethod);
|
||
const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD &&
|
||
compressionMethod !== constants_1.CompressionMethod.Gzip &&
|
||
IS_WINDOWS;
|
||
switch (compressionMethod) {
|
||
case constants_1.CompressionMethod.Zstd:
|
||
return BSD_TAR_ZSTD
|
||
? [
|
||
'zstd -T0 --long=30 --force -o',
|
||
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||
constants_1.TarFilename
|
||
]
|
||
: [
|
||
'--use-compress-program',
|
||
IS_WINDOWS ? '"zstd -T0 --long=30"' : 'zstdmt --long=30'
|
||
];
|
||
case constants_1.CompressionMethod.ZstdWithoutLong:
|
||
return BSD_TAR_ZSTD
|
||
? [
|
||
'zstd -T0 --force -o',
|
||
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||
constants_1.TarFilename
|
||
]
|
||
: ['--use-compress-program', IS_WINDOWS ? '"zstd -T0"' : 'zstdmt'];
|
||
default:
|
||
return ['-z'];
|
||
}
|
||
});
|
||
}
|
||
// Executes all commands as separate processes
|
||
function execCommands(commands, cwd) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
for (const command of commands) {
|
||
try {
|
||
yield (0, exec_1.exec)(command, undefined, {
|
||
cwd,
|
||
env: Object.assign(Object.assign({}, process.env), { MSYS: 'winsymlinks:nativestrict' })
|
||
});
|
||
}
|
||
catch (error) {
|
||
throw new Error(`${command.split(' ')[0]} failed with error: ${error === null || error === void 0 ? void 0 : error.message}`);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
// List the contents of a tar
|
||
function listTar(archivePath, compressionMethod) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const commands = yield getCommands(compressionMethod, 'list', archivePath);
|
||
yield execCommands(commands);
|
||
});
|
||
}
|
||
// Extract a tar
|
||
function extractTar(archivePath, compressionMethod) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
// Create directory to extract tar into
|
||
const workingDirectory = getWorkingDirectory();
|
||
yield io.mkdirP(workingDirectory);
|
||
const commands = yield getCommands(compressionMethod, 'extract', archivePath);
|
||
yield execCommands(commands);
|
||
});
|
||
}
|
||
// Create a tar
|
||
function createTar(archiveFolder, sourceDirectories, compressionMethod) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
// Write source directories to manifest.txt to avoid command length limits
|
||
(0, fs_1.writeFileSync)(path.join(archiveFolder, constants_1.ManifestFilename), sourceDirectories.join('\n'));
|
||
const commands = yield getCommands(compressionMethod, 'create');
|
||
yield execCommands(commands, archiveFolder);
|
||
});
|
||
}
|
||
//# sourceMappingURL=tar.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 35268:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.UploadProgress = void 0;
|
||
exports.uploadCacheArchiveSDK = uploadCacheArchiveSDK;
|
||
const core = __importStar(__nccwpck_require__(37484));
|
||
const storage_blob_1 = __nccwpck_require__(71400);
|
||
const errors_1 = __nccwpck_require__(50263);
|
||
/**
|
||
* Class for tracking the upload state and displaying stats.
|
||
*/
|
||
class UploadProgress {
|
||
constructor(contentLength) {
|
||
this.contentLength = contentLength;
|
||
this.sentBytes = 0;
|
||
this.displayedComplete = false;
|
||
this.startTime = Date.now();
|
||
}
|
||
/**
|
||
* Sets the number of bytes sent
|
||
*
|
||
* @param sentBytes the number of bytes sent
|
||
*/
|
||
setSentBytes(sentBytes) {
|
||
this.sentBytes = sentBytes;
|
||
}
|
||
/**
|
||
* Returns the total number of bytes transferred.
|
||
*/
|
||
getTransferredBytes() {
|
||
return this.sentBytes;
|
||
}
|
||
/**
|
||
* Returns true if the upload is complete.
|
||
*/
|
||
isDone() {
|
||
return this.getTransferredBytes() === this.contentLength;
|
||
}
|
||
/**
|
||
* Prints the current upload stats. Once the upload completes, this will print one
|
||
* last line and then stop.
|
||
*/
|
||
display() {
|
||
if (this.displayedComplete) {
|
||
return;
|
||
}
|
||
const transferredBytes = this.sentBytes;
|
||
const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1);
|
||
const elapsedTime = Date.now() - this.startTime;
|
||
const uploadSpeed = (transferredBytes /
|
||
(1024 * 1024) /
|
||
(elapsedTime / 1000)).toFixed(1);
|
||
core.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`);
|
||
if (this.isDone()) {
|
||
this.displayedComplete = true;
|
||
}
|
||
}
|
||
/**
|
||
* Returns a function used to handle TransferProgressEvents.
|
||
*/
|
||
onProgress() {
|
||
return (progress) => {
|
||
this.setSentBytes(progress.loadedBytes);
|
||
};
|
||
}
|
||
/**
|
||
* Starts the timer that displays the stats.
|
||
*
|
||
* @param delayInMs the delay between each write
|
||
*/
|
||
startDisplayTimer(delayInMs = 1000) {
|
||
const displayCallback = () => {
|
||
this.display();
|
||
if (!this.isDone()) {
|
||
this.timeoutHandle = setTimeout(displayCallback, delayInMs);
|
||
}
|
||
};
|
||
this.timeoutHandle = setTimeout(displayCallback, delayInMs);
|
||
}
|
||
/**
|
||
* Stops the timer that displays the stats. As this typically indicates the upload
|
||
* is complete, this will display one last line, unless the last line has already
|
||
* been written.
|
||
*/
|
||
stopDisplayTimer() {
|
||
if (this.timeoutHandle) {
|
||
clearTimeout(this.timeoutHandle);
|
||
this.timeoutHandle = undefined;
|
||
}
|
||
this.display();
|
||
}
|
||
}
|
||
exports.UploadProgress = UploadProgress;
|
||
/**
|
||
* Uploads a cache archive directly to Azure Blob Storage using the Azure SDK.
|
||
* This function will display progress information to the console. Concurrency of the
|
||
* upload is determined by the calling functions.
|
||
*
|
||
* @param signedUploadURL
|
||
* @param archivePath
|
||
* @param options
|
||
* @returns
|
||
*/
|
||
function uploadCacheArchiveSDK(signedUploadURL, archivePath, options) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
var _a;
|
||
const blobClient = new storage_blob_1.BlobClient(signedUploadURL);
|
||
const blockBlobClient = blobClient.getBlockBlobClient();
|
||
const uploadProgress = new UploadProgress((_a = options === null || options === void 0 ? void 0 : options.archiveSizeBytes) !== null && _a !== void 0 ? _a : 0);
|
||
// Specify data transfer options
|
||
const uploadOptions = {
|
||
blockSize: options === null || options === void 0 ? void 0 : options.uploadChunkSize,
|
||
concurrency: options === null || options === void 0 ? void 0 : options.uploadConcurrency, // maximum number of parallel transfer workers
|
||
maxSingleShotSize: 128 * 1024 * 1024, // 128 MiB initial transfer size
|
||
onProgress: uploadProgress.onProgress()
|
||
};
|
||
try {
|
||
uploadProgress.startDisplayTimer();
|
||
core.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`);
|
||
const response = yield blockBlobClient.uploadFile(archivePath, uploadOptions);
|
||
// TODO: better management of non-retryable errors
|
||
if (response._response.status >= 400) {
|
||
throw new errors_1.InvalidResponseError(`uploadCacheArchiveSDK: upload failed with status code ${response._response.status}`);
|
||
}
|
||
return response;
|
||
}
|
||
catch (error) {
|
||
core.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error.message}`);
|
||
throw error;
|
||
}
|
||
finally {
|
||
uploadProgress.stopDisplayTimer();
|
||
}
|
||
});
|
||
}
|
||
//# sourceMappingURL=uploadUtils.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 98356:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.getUploadOptions = getUploadOptions;
|
||
exports.getDownloadOptions = getDownloadOptions;
|
||
const core = __importStar(__nccwpck_require__(37484));
|
||
/**
|
||
* Returns a copy of the upload options with defaults filled in.
|
||
*
|
||
* @param copy the original upload options
|
||
*/
|
||
function getUploadOptions(copy) {
|
||
// Defaults if not overriden
|
||
const result = {
|
||
useAzureSdk: false,
|
||
uploadConcurrency: 4,
|
||
uploadChunkSize: 32 * 1024 * 1024
|
||
};
|
||
if (copy) {
|
||
if (typeof copy.useAzureSdk === 'boolean') {
|
||
result.useAzureSdk = copy.useAzureSdk;
|
||
}
|
||
if (typeof copy.uploadConcurrency === 'number') {
|
||
result.uploadConcurrency = copy.uploadConcurrency;
|
||
}
|
||
if (typeof copy.uploadChunkSize === 'number') {
|
||
result.uploadChunkSize = copy.uploadChunkSize;
|
||
}
|
||
}
|
||
/**
|
||
* Add env var overrides
|
||
*/
|
||
// Cap the uploadConcurrency at 32
|
||
result.uploadConcurrency = !isNaN(Number(process.env['CACHE_UPLOAD_CONCURRENCY']))
|
||
? Math.min(32, Number(process.env['CACHE_UPLOAD_CONCURRENCY']))
|
||
: result.uploadConcurrency;
|
||
// Cap the uploadChunkSize at 128MiB
|
||
result.uploadChunkSize = !isNaN(Number(process.env['CACHE_UPLOAD_CHUNK_SIZE']))
|
||
? Math.min(128 * 1024 * 1024, Number(process.env['CACHE_UPLOAD_CHUNK_SIZE']) * 1024 * 1024)
|
||
: result.uploadChunkSize;
|
||
core.debug(`Use Azure SDK: ${result.useAzureSdk}`);
|
||
core.debug(`Upload concurrency: ${result.uploadConcurrency}`);
|
||
core.debug(`Upload chunk size: ${result.uploadChunkSize}`);
|
||
return result;
|
||
}
|
||
/**
|
||
* Returns a copy of the download options with defaults filled in.
|
||
*
|
||
* @param copy the original download options
|
||
*/
|
||
function getDownloadOptions(copy) {
|
||
const result = {
|
||
useAzureSdk: false,
|
||
concurrentBlobDownloads: true,
|
||
downloadConcurrency: 8,
|
||
timeoutInMs: 30000,
|
||
segmentTimeoutInMs: 600000,
|
||
lookupOnly: false
|
||
};
|
||
if (copy) {
|
||
if (typeof copy.useAzureSdk === 'boolean') {
|
||
result.useAzureSdk = copy.useAzureSdk;
|
||
}
|
||
if (typeof copy.concurrentBlobDownloads === 'boolean') {
|
||
result.concurrentBlobDownloads = copy.concurrentBlobDownloads;
|
||
}
|
||
if (typeof copy.downloadConcurrency === 'number') {
|
||
result.downloadConcurrency = copy.downloadConcurrency;
|
||
}
|
||
if (typeof copy.timeoutInMs === 'number') {
|
||
result.timeoutInMs = copy.timeoutInMs;
|
||
}
|
||
if (typeof copy.segmentTimeoutInMs === 'number') {
|
||
result.segmentTimeoutInMs = copy.segmentTimeoutInMs;
|
||
}
|
||
if (typeof copy.lookupOnly === 'boolean') {
|
||
result.lookupOnly = copy.lookupOnly;
|
||
}
|
||
}
|
||
const segmentDownloadTimeoutMins = process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS'];
|
||
if (segmentDownloadTimeoutMins &&
|
||
!isNaN(Number(segmentDownloadTimeoutMins)) &&
|
||
isFinite(Number(segmentDownloadTimeoutMins))) {
|
||
result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1000;
|
||
}
|
||
core.debug(`Use Azure SDK: ${result.useAzureSdk}`);
|
||
core.debug(`Download concurrency: ${result.downloadConcurrency}`);
|
||
core.debug(`Request timeout (ms): ${result.timeoutInMs}`);
|
||
core.debug(`Cache segment download timeout mins env var: ${process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS']}`);
|
||
core.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`);
|
||
core.debug(`Lookup only: ${result.lookupOnly}`);
|
||
return result;
|
||
}
|
||
//# sourceMappingURL=options.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 44914:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.issueCommand = issueCommand;
|
||
exports.issue = issue;
|
||
const os = __importStar(__nccwpck_require__(70857));
|
||
const utils_1 = __nccwpck_require__(30302);
|
||
/**
|
||
* Issues a command to the GitHub Actions runner
|
||
*
|
||
* @param command - The command name to issue
|
||
* @param properties - Additional properties for the command (key-value pairs)
|
||
* @param message - The message to include with the command
|
||
* @remarks
|
||
* This function outputs a specially formatted string to stdout that the Actions
|
||
* runner interprets as a command. These commands can control workflow behavior,
|
||
* set outputs, create annotations, mask values, and more.
|
||
*
|
||
* Command Format:
|
||
* ::name key=value,key=value::message
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* // Issue a warning annotation
|
||
* issueCommand('warning', {}, 'This is a warning message');
|
||
* // Output: ::warning::This is a warning message
|
||
*
|
||
* // Set an environment variable
|
||
* issueCommand('set-env', { name: 'MY_VAR' }, 'some value');
|
||
* // Output: ::set-env name=MY_VAR::some value
|
||
*
|
||
* // Add a secret mask
|
||
* issueCommand('add-mask', {}, 'secretValue123');
|
||
* // Output: ::add-mask::secretValue123
|
||
* ```
|
||
*
|
||
* @internal
|
||
* This is an internal utility function that powers the public API functions
|
||
* such as setSecret, warning, error, and exportVariable.
|
||
*/
|
||
function issueCommand(command, properties, message) {
|
||
const cmd = new Command(command, properties, message);
|
||
process.stdout.write(cmd.toString() + os.EOL);
|
||
}
|
||
function issue(name, message = '') {
|
||
issueCommand(name, {}, message);
|
||
}
|
||
const CMD_STRING = '::';
|
||
class Command {
|
||
constructor(command, properties, message) {
|
||
if (!command) {
|
||
command = 'missing.command';
|
||
}
|
||
this.command = command;
|
||
this.properties = properties;
|
||
this.message = message;
|
||
}
|
||
toString() {
|
||
let cmdStr = CMD_STRING + this.command;
|
||
if (this.properties && Object.keys(this.properties).length > 0) {
|
||
cmdStr += ' ';
|
||
let first = true;
|
||
for (const key in this.properties) {
|
||
if (this.properties.hasOwnProperty(key)) {
|
||
const val = this.properties[key];
|
||
if (val) {
|
||
if (first) {
|
||
first = false;
|
||
}
|
||
else {
|
||
cmdStr += ',';
|
||
}
|
||
cmdStr += `${key}=${escapeProperty(val)}`;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
|
||
return cmdStr;
|
||
}
|
||
}
|
||
function escapeData(s) {
|
||
return (0, utils_1.toCommandValue)(s)
|
||
.replace(/%/g, '%25')
|
||
.replace(/\r/g, '%0D')
|
||
.replace(/\n/g, '%0A');
|
||
}
|
||
function escapeProperty(s) {
|
||
return (0, utils_1.toCommandValue)(s)
|
||
.replace(/%/g, '%25')
|
||
.replace(/\r/g, '%0D')
|
||
.replace(/\n/g, '%0A')
|
||
.replace(/:/g, '%3A')
|
||
.replace(/,/g, '%2C');
|
||
}
|
||
//# sourceMappingURL=command.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 37484:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.platform = exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = exports.markdownSummary = exports.summary = exports.ExitCode = void 0;
|
||
exports.exportVariable = exportVariable;
|
||
exports.setSecret = setSecret;
|
||
exports.addPath = addPath;
|
||
exports.getInput = getInput;
|
||
exports.getMultilineInput = getMultilineInput;
|
||
exports.getBooleanInput = getBooleanInput;
|
||
exports.setOutput = setOutput;
|
||
exports.setCommandEcho = setCommandEcho;
|
||
exports.setFailed = setFailed;
|
||
exports.isDebug = isDebug;
|
||
exports.debug = debug;
|
||
exports.error = error;
|
||
exports.warning = warning;
|
||
exports.notice = notice;
|
||
exports.info = info;
|
||
exports.startGroup = startGroup;
|
||
exports.endGroup = endGroup;
|
||
exports.group = group;
|
||
exports.saveState = saveState;
|
||
exports.getState = getState;
|
||
exports.getIDToken = getIDToken;
|
||
const command_1 = __nccwpck_require__(44914);
|
||
const file_command_1 = __nccwpck_require__(24753);
|
||
const utils_1 = __nccwpck_require__(30302);
|
||
const os = __importStar(__nccwpck_require__(70857));
|
||
const path = __importStar(__nccwpck_require__(16928));
|
||
const oidc_utils_1 = __nccwpck_require__(35306);
|
||
/**
|
||
* The code to exit an action
|
||
*/
|
||
var ExitCode;
|
||
(function (ExitCode) {
|
||
/**
|
||
* A code indicating that the action was successful
|
||
*/
|
||
ExitCode[ExitCode["Success"] = 0] = "Success";
|
||
/**
|
||
* A code indicating that the action was a failure
|
||
*/
|
||
ExitCode[ExitCode["Failure"] = 1] = "Failure";
|
||
})(ExitCode || (exports.ExitCode = ExitCode = {}));
|
||
//-----------------------------------------------------------------------
|
||
// Variables
|
||
//-----------------------------------------------------------------------
|
||
/**
|
||
* Sets env variable for this action and future actions in the job
|
||
* @param name the name of the variable to set
|
||
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
|
||
*/
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||
function exportVariable(name, val) {
|
||
const convertedVal = (0, utils_1.toCommandValue)(val);
|
||
process.env[name] = convertedVal;
|
||
const filePath = process.env['GITHUB_ENV'] || '';
|
||
if (filePath) {
|
||
return (0, file_command_1.issueFileCommand)('ENV', (0, file_command_1.prepareKeyValueMessage)(name, val));
|
||
}
|
||
(0, command_1.issueCommand)('set-env', { name }, convertedVal);
|
||
}
|
||
/**
|
||
* Registers a secret which will get masked from logs
|
||
*
|
||
* @param secret - Value of the secret to be masked
|
||
* @remarks
|
||
* This function instructs the Actions runner to mask the specified value in any
|
||
* logs produced during the workflow run. Once registered, the secret value will
|
||
* be replaced with asterisks (***) whenever it appears in console output, logs,
|
||
* or error messages.
|
||
*
|
||
* This is useful for protecting sensitive information such as:
|
||
* - API keys
|
||
* - Access tokens
|
||
* - Authentication credentials
|
||
* - URL parameters containing signatures (SAS tokens)
|
||
*
|
||
* Note that masking only affects future logs; any previous appearances of the
|
||
* secret in logs before calling this function will remain unmasked.
|
||
*
|
||
* @example
|
||
* ```typescript
|
||
* // Register an API token as a secret
|
||
* const apiToken = "abc123xyz456";
|
||
* setSecret(apiToken);
|
||
*
|
||
* // Now any logs containing this value will show *** instead
|
||
* console.log(`Using token: ${apiToken}`); // Outputs: "Using token: ***"
|
||
* ```
|
||
*/
|
||
function setSecret(secret) {
|
||
(0, command_1.issueCommand)('add-mask', {}, secret);
|
||
}
|
||
/**
|
||
* Prepends inputPath to the PATH (for this action and future actions)
|
||
* @param inputPath
|
||
*/
|
||
function addPath(inputPath) {
|
||
const filePath = process.env['GITHUB_PATH'] || '';
|
||
if (filePath) {
|
||
(0, file_command_1.issueFileCommand)('PATH', inputPath);
|
||
}
|
||
else {
|
||
(0, command_1.issueCommand)('add-path', {}, inputPath);
|
||
}
|
||
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
||
}
|
||
/**
|
||
* Gets the value of an input.
|
||
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
|
||
* Returns an empty string if the value is not defined.
|
||
*
|
||
* @param name name of the input to get
|
||
* @param options optional. See InputOptions.
|
||
* @returns string
|
||
*/
|
||
function getInput(name, options) {
|
||
const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
|
||
if (options && options.required && !val) {
|
||
throw new Error(`Input required and not supplied: ${name}`);
|
||
}
|
||
if (options && options.trimWhitespace === false) {
|
||
return val;
|
||
}
|
||
return val.trim();
|
||
}
|
||
/**
|
||
* Gets the values of an multiline input. Each value is also trimmed.
|
||
*
|
||
* @param name name of the input to get
|
||
* @param options optional. See InputOptions.
|
||
* @returns string[]
|
||
*
|
||
*/
|
||
function getMultilineInput(name, options) {
|
||
const inputs = getInput(name, options)
|
||
.split('\n')
|
||
.filter(x => x !== '');
|
||
if (options && options.trimWhitespace === false) {
|
||
return inputs;
|
||
}
|
||
return inputs.map(input => input.trim());
|
||
}
|
||
/**
|
||
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
|
||
* Support boolean input list: `true | True | TRUE | false | False | FALSE` .
|
||
* The return value is also in boolean type.
|
||
* ref: https://yaml.org/spec/1.2/spec.html#id2804923
|
||
*
|
||
* @param name name of the input to get
|
||
* @param options optional. See InputOptions.
|
||
* @returns boolean
|
||
*/
|
||
function getBooleanInput(name, options) {
|
||
const trueValue = ['true', 'True', 'TRUE'];
|
||
const falseValue = ['false', 'False', 'FALSE'];
|
||
const val = getInput(name, options);
|
||
if (trueValue.includes(val))
|
||
return true;
|
||
if (falseValue.includes(val))
|
||
return false;
|
||
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
|
||
`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
|
||
}
|
||
/**
|
||
* Sets the value of an output.
|
||
*
|
||
* @param name name of the output to set
|
||
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
||
*/
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||
function setOutput(name, value) {
|
||
const filePath = process.env['GITHUB_OUTPUT'] || '';
|
||
if (filePath) {
|
||
return (0, file_command_1.issueFileCommand)('OUTPUT', (0, file_command_1.prepareKeyValueMessage)(name, value));
|
||
}
|
||
process.stdout.write(os.EOL);
|
||
(0, command_1.issueCommand)('set-output', { name }, (0, utils_1.toCommandValue)(value));
|
||
}
|
||
/**
|
||
* Enables or disables the echoing of commands into stdout for the rest of the step.
|
||
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
|
||
*
|
||
*/
|
||
function setCommandEcho(enabled) {
|
||
(0, command_1.issue)('echo', enabled ? 'on' : 'off');
|
||
}
|
||
//-----------------------------------------------------------------------
|
||
// Results
|
||
//-----------------------------------------------------------------------
|
||
/**
|
||
* Sets the action status to failed.
|
||
* When the action exits it will be with an exit code of 1
|
||
* @param message add error issue message
|
||
*/
|
||
function setFailed(message) {
|
||
process.exitCode = ExitCode.Failure;
|
||
error(message);
|
||
}
|
||
//-----------------------------------------------------------------------
|
||
// Logging Commands
|
||
//-----------------------------------------------------------------------
|
||
/**
|
||
* Gets whether Actions Step Debug is on or not
|
||
*/
|
||
function isDebug() {
|
||
return process.env['RUNNER_DEBUG'] === '1';
|
||
}
|
||
/**
|
||
* Writes debug message to user log
|
||
* @param message debug message
|
||
*/
|
||
function debug(message) {
|
||
(0, command_1.issueCommand)('debug', {}, message);
|
||
}
|
||
/**
|
||
* Adds an error issue
|
||
* @param message error issue message. Errors will be converted to string via toString()
|
||
* @param properties optional properties to add to the annotation.
|
||
*/
|
||
function error(message, properties = {}) {
|
||
(0, command_1.issueCommand)('error', (0, utils_1.toCommandProperties)(properties), message instanceof Error ? message.toString() : message);
|
||
}
|
||
/**
|
||
* Adds a warning issue
|
||
* @param message warning issue message. Errors will be converted to string via toString()
|
||
* @param properties optional properties to add to the annotation.
|
||
*/
|
||
function warning(message, properties = {}) {
|
||
(0, command_1.issueCommand)('warning', (0, utils_1.toCommandProperties)(properties), message instanceof Error ? message.toString() : message);
|
||
}
|
||
/**
|
||
* Adds a notice issue
|
||
* @param message notice issue message. Errors will be converted to string via toString()
|
||
* @param properties optional properties to add to the annotation.
|
||
*/
|
||
function notice(message, properties = {}) {
|
||
(0, command_1.issueCommand)('notice', (0, utils_1.toCommandProperties)(properties), message instanceof Error ? message.toString() : message);
|
||
}
|
||
/**
|
||
* Writes info to log with console.log.
|
||
* @param message info message
|
||
*/
|
||
function info(message) {
|
||
process.stdout.write(message + os.EOL);
|
||
}
|
||
/**
|
||
* Begin an output group.
|
||
*
|
||
* Output until the next `groupEnd` will be foldable in this group
|
||
*
|
||
* @param name The name of the output group
|
||
*/
|
||
function startGroup(name) {
|
||
(0, command_1.issue)('group', name);
|
||
}
|
||
/**
|
||
* End an output group.
|
||
*/
|
||
function endGroup() {
|
||
(0, command_1.issue)('endgroup');
|
||
}
|
||
/**
|
||
* Wrap an asynchronous function call in a group.
|
||
*
|
||
* Returns the same type as the function itself.
|
||
*
|
||
* @param name The name of the group
|
||
* @param fn The function to wrap in the group
|
||
*/
|
||
function group(name, fn) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
startGroup(name);
|
||
let result;
|
||
try {
|
||
result = yield fn();
|
||
}
|
||
finally {
|
||
endGroup();
|
||
}
|
||
return result;
|
||
});
|
||
}
|
||
//-----------------------------------------------------------------------
|
||
// Wrapper action state
|
||
//-----------------------------------------------------------------------
|
||
/**
|
||
* Saves state for current action, the state can only be retrieved by this action's post job execution.
|
||
*
|
||
* @param name name of the state to store
|
||
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
||
*/
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||
function saveState(name, value) {
|
||
const filePath = process.env['GITHUB_STATE'] || '';
|
||
if (filePath) {
|
||
return (0, file_command_1.issueFileCommand)('STATE', (0, file_command_1.prepareKeyValueMessage)(name, value));
|
||
}
|
||
(0, command_1.issueCommand)('save-state', { name }, (0, utils_1.toCommandValue)(value));
|
||
}
|
||
/**
|
||
* Gets the value of an state set by this action's main execution.
|
||
*
|
||
* @param name name of the state to get
|
||
* @returns string
|
||
*/
|
||
function getState(name) {
|
||
return process.env[`STATE_${name}`] || '';
|
||
}
|
||
function getIDToken(aud) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return yield oidc_utils_1.OidcClient.getIDToken(aud);
|
||
});
|
||
}
|
||
/**
|
||
* Summary exports
|
||
*/
|
||
var summary_1 = __nccwpck_require__(71847);
|
||
Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } }));
|
||
/**
|
||
* @deprecated use core.summary
|
||
*/
|
||
var summary_2 = __nccwpck_require__(71847);
|
||
Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } }));
|
||
/**
|
||
* Path exports
|
||
*/
|
||
var path_utils_1 = __nccwpck_require__(31976);
|
||
Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } }));
|
||
Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } }));
|
||
Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } }));
|
||
/**
|
||
* Platform utilities exports
|
||
*/
|
||
exports.platform = __importStar(__nccwpck_require__(18968));
|
||
//# sourceMappingURL=core.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 24753:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
// For internal use, subject to change.
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.issueFileCommand = issueFileCommand;
|
||
exports.prepareKeyValueMessage = prepareKeyValueMessage;
|
||
// We use any as a valid input type
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||
const crypto = __importStar(__nccwpck_require__(76982));
|
||
const fs = __importStar(__nccwpck_require__(79896));
|
||
const os = __importStar(__nccwpck_require__(70857));
|
||
const utils_1 = __nccwpck_require__(30302);
|
||
function issueFileCommand(command, message) {
|
||
const filePath = process.env[`GITHUB_${command}`];
|
||
if (!filePath) {
|
||
throw new Error(`Unable to find environment variable for file command ${command}`);
|
||
}
|
||
if (!fs.existsSync(filePath)) {
|
||
throw new Error(`Missing file at path: ${filePath}`);
|
||
}
|
||
fs.appendFileSync(filePath, `${(0, utils_1.toCommandValue)(message)}${os.EOL}`, {
|
||
encoding: 'utf8'
|
||
});
|
||
}
|
||
function prepareKeyValueMessage(key, value) {
|
||
const delimiter = `ghadelimiter_${crypto.randomUUID()}`;
|
||
const convertedValue = (0, utils_1.toCommandValue)(value);
|
||
// These should realistically never happen, but just in case someone finds a
|
||
// way to exploit uuid generation let's not allow keys or values that contain
|
||
// the delimiter.
|
||
if (key.includes(delimiter)) {
|
||
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
|
||
}
|
||
if (convertedValue.includes(delimiter)) {
|
||
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
|
||
}
|
||
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
|
||
}
|
||
//# sourceMappingURL=file-command.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 35306:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.OidcClient = void 0;
|
||
const http_client_1 = __nccwpck_require__(54844);
|
||
const auth_1 = __nccwpck_require__(44552);
|
||
const core_1 = __nccwpck_require__(37484);
|
||
class OidcClient {
|
||
static createHttpClient(allowRetry = true, maxRetry = 10) {
|
||
const requestOptions = {
|
||
allowRetries: allowRetry,
|
||
maxRetries: maxRetry
|
||
};
|
||
return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions);
|
||
}
|
||
static getRequestToken() {
|
||
const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'];
|
||
if (!token) {
|
||
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable');
|
||
}
|
||
return token;
|
||
}
|
||
static getIDTokenUrl() {
|
||
const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL'];
|
||
if (!runtimeUrl) {
|
||
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable');
|
||
}
|
||
return runtimeUrl;
|
||
}
|
||
static getCall(id_token_url) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
var _a;
|
||
const httpclient = OidcClient.createHttpClient();
|
||
const res = yield httpclient
|
||
.getJson(id_token_url)
|
||
.catch(error => {
|
||
throw new Error(`Failed to get ID Token. \n
|
||
Error Code : ${error.statusCode}\n
|
||
Error Message: ${error.message}`);
|
||
});
|
||
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
|
||
if (!id_token) {
|
||
throw new Error('Response json body do not have ID Token field');
|
||
}
|
||
return id_token;
|
||
});
|
||
}
|
||
static getIDToken(audience) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
try {
|
||
// New ID Token is requested from action service
|
||
let id_token_url = OidcClient.getIDTokenUrl();
|
||
if (audience) {
|
||
const encodedAudience = encodeURIComponent(audience);
|
||
id_token_url = `${id_token_url}&audience=${encodedAudience}`;
|
||
}
|
||
(0, core_1.debug)(`ID token url is ${id_token_url}`);
|
||
const id_token = yield OidcClient.getCall(id_token_url);
|
||
(0, core_1.setSecret)(id_token);
|
||
return id_token;
|
||
}
|
||
catch (error) {
|
||
throw new Error(`Error message: ${error.message}`);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
exports.OidcClient = OidcClient;
|
||
//# sourceMappingURL=oidc-utils.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 31976:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.toPosixPath = toPosixPath;
|
||
exports.toWin32Path = toWin32Path;
|
||
exports.toPlatformPath = toPlatformPath;
|
||
const path = __importStar(__nccwpck_require__(16928));
|
||
/**
|
||
* toPosixPath converts the given path to the posix form. On Windows, \\ will be
|
||
* replaced with /.
|
||
*
|
||
* @param pth. Path to transform.
|
||
* @return string Posix path.
|
||
*/
|
||
function toPosixPath(pth) {
|
||
return pth.replace(/[\\]/g, '/');
|
||
}
|
||
/**
|
||
* toWin32Path converts the given path to the win32 form. On Linux, / will be
|
||
* replaced with \\.
|
||
*
|
||
* @param pth. Path to transform.
|
||
* @return string Win32 path.
|
||
*/
|
||
function toWin32Path(pth) {
|
||
return pth.replace(/[/]/g, '\\');
|
||
}
|
||
/**
|
||
* toPlatformPath converts the given path to a platform-specific path. It does
|
||
* this by replacing instances of / and \ with the platform-specific path
|
||
* separator.
|
||
*
|
||
* @param pth The path to platformize.
|
||
* @return string The platform-specific path.
|
||
*/
|
||
function toPlatformPath(pth) {
|
||
return pth.replace(/[/\\]/g, path.sep);
|
||
}
|
||
//# sourceMappingURL=path-utils.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 18968:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.isLinux = exports.isMacOS = exports.isWindows = exports.arch = exports.platform = void 0;
|
||
exports.getDetails = getDetails;
|
||
const os_1 = __importDefault(__nccwpck_require__(70857));
|
||
const exec = __importStar(__nccwpck_require__(95236));
|
||
const getWindowsInfo = () => __awaiter(void 0, void 0, void 0, function* () {
|
||
const { stdout: version } = yield exec.getExecOutput('powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Version"', undefined, {
|
||
silent: true
|
||
});
|
||
const { stdout: name } = yield exec.getExecOutput('powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Caption"', undefined, {
|
||
silent: true
|
||
});
|
||
return {
|
||
name: name.trim(),
|
||
version: version.trim()
|
||
};
|
||
});
|
||
const getMacOsInfo = () => __awaiter(void 0, void 0, void 0, function* () {
|
||
var _a, _b, _c, _d;
|
||
const { stdout } = yield exec.getExecOutput('sw_vers', undefined, {
|
||
silent: true
|
||
});
|
||
const version = (_b = (_a = stdout.match(/ProductVersion:\s*(.+)/)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : '';
|
||
const name = (_d = (_c = stdout.match(/ProductName:\s*(.+)/)) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : '';
|
||
return {
|
||
name,
|
||
version
|
||
};
|
||
});
|
||
const getLinuxInfo = () => __awaiter(void 0, void 0, void 0, function* () {
|
||
const { stdout } = yield exec.getExecOutput('lsb_release', ['-i', '-r', '-s'], {
|
||
silent: true
|
||
});
|
||
const [name, version] = stdout.trim().split('\n');
|
||
return {
|
||
name,
|
||
version
|
||
};
|
||
});
|
||
exports.platform = os_1.default.platform();
|
||
exports.arch = os_1.default.arch();
|
||
exports.isWindows = exports.platform === 'win32';
|
||
exports.isMacOS = exports.platform === 'darwin';
|
||
exports.isLinux = exports.platform === 'linux';
|
||
function getDetails() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return Object.assign(Object.assign({}, (yield (exports.isWindows
|
||
? getWindowsInfo()
|
||
: exports.isMacOS
|
||
? getMacOsInfo()
|
||
: getLinuxInfo()))), { platform: exports.platform,
|
||
arch: exports.arch,
|
||
isWindows: exports.isWindows,
|
||
isMacOS: exports.isMacOS,
|
||
isLinux: exports.isLinux });
|
||
});
|
||
}
|
||
//# sourceMappingURL=platform.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 71847:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0;
|
||
const os_1 = __nccwpck_require__(70857);
|
||
const fs_1 = __nccwpck_require__(79896);
|
||
const { access, appendFile, writeFile } = fs_1.promises;
|
||
exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY';
|
||
exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary';
|
||
class Summary {
|
||
constructor() {
|
||
this._buffer = '';
|
||
}
|
||
/**
|
||
* Finds the summary file path from the environment, rejects if env var is not found or file does not exist
|
||
* Also checks r/w permissions.
|
||
*
|
||
* @returns step summary file path
|
||
*/
|
||
filePath() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
if (this._filePath) {
|
||
return this._filePath;
|
||
}
|
||
const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR];
|
||
if (!pathFromEnv) {
|
||
throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`);
|
||
}
|
||
try {
|
||
yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK);
|
||
}
|
||
catch (_a) {
|
||
throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`);
|
||
}
|
||
this._filePath = pathFromEnv;
|
||
return this._filePath;
|
||
});
|
||
}
|
||
/**
|
||
* Wraps content in an HTML tag, adding any HTML attributes
|
||
*
|
||
* @param {string} tag HTML tag to wrap
|
||
* @param {string | null} content content within the tag
|
||
* @param {[attribute: string]: string} attrs key-value list of HTML attributes to add
|
||
*
|
||
* @returns {string} content wrapped in HTML element
|
||
*/
|
||
wrap(tag, content, attrs = {}) {
|
||
const htmlAttrs = Object.entries(attrs)
|
||
.map(([key, value]) => ` ${key}="${value}"`)
|
||
.join('');
|
||
if (!content) {
|
||
return `<${tag}${htmlAttrs}>`;
|
||
}
|
||
return `<${tag}${htmlAttrs}>${content}</${tag}>`;
|
||
}
|
||
/**
|
||
* Writes text in the buffer to the summary buffer file and empties buffer. Will append by default.
|
||
*
|
||
* @param {SummaryWriteOptions} [options] (optional) options for write operation
|
||
*
|
||
* @returns {Promise<Summary>} summary instance
|
||
*/
|
||
write(options) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
|
||
const filePath = yield this.filePath();
|
||
const writeFunc = overwrite ? writeFile : appendFile;
|
||
yield writeFunc(filePath, this._buffer, { encoding: 'utf8' });
|
||
return this.emptyBuffer();
|
||
});
|
||
}
|
||
/**
|
||
* Clears the summary buffer and wipes the summary file
|
||
*
|
||
* @returns {Summary} summary instance
|
||
*/
|
||
clear() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return this.emptyBuffer().write({ overwrite: true });
|
||
});
|
||
}
|
||
/**
|
||
* Returns the current summary buffer as a string
|
||
*
|
||
* @returns {string} string of summary buffer
|
||
*/
|
||
stringify() {
|
||
return this._buffer;
|
||
}
|
||
/**
|
||
* If the summary buffer is empty
|
||
*
|
||
* @returns {boolen} true if the buffer is empty
|
||
*/
|
||
isEmptyBuffer() {
|
||
return this._buffer.length === 0;
|
||
}
|
||
/**
|
||
* Resets the summary buffer without writing to summary file
|
||
*
|
||
* @returns {Summary} summary instance
|
||
*/
|
||
emptyBuffer() {
|
||
this._buffer = '';
|
||
return this;
|
||
}
|
||
/**
|
||
* Adds raw text to the summary buffer
|
||
*
|
||
* @param {string} text content to add
|
||
* @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false)
|
||
*
|
||
* @returns {Summary} summary instance
|
||
*/
|
||
addRaw(text, addEOL = false) {
|
||
this._buffer += text;
|
||
return addEOL ? this.addEOL() : this;
|
||
}
|
||
/**
|
||
* Adds the operating system-specific end-of-line marker to the buffer
|
||
*
|
||
* @returns {Summary} summary instance
|
||
*/
|
||
addEOL() {
|
||
return this.addRaw(os_1.EOL);
|
||
}
|
||
/**
|
||
* Adds an HTML codeblock to the summary buffer
|
||
*
|
||
* @param {string} code content to render within fenced code block
|
||
* @param {string} lang (optional) language to syntax highlight code
|
||
*
|
||
* @returns {Summary} summary instance
|
||
*/
|
||
addCodeBlock(code, lang) {
|
||
const attrs = Object.assign({}, (lang && { lang }));
|
||
const element = this.wrap('pre', this.wrap('code', code), attrs);
|
||
return this.addRaw(element).addEOL();
|
||
}
|
||
/**
|
||
* Adds an HTML list to the summary buffer
|
||
*
|
||
* @param {string[]} items list of items to render
|
||
* @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false)
|
||
*
|
||
* @returns {Summary} summary instance
|
||
*/
|
||
addList(items, ordered = false) {
|
||
const tag = ordered ? 'ol' : 'ul';
|
||
const listItems = items.map(item => this.wrap('li', item)).join('');
|
||
const element = this.wrap(tag, listItems);
|
||
return this.addRaw(element).addEOL();
|
||
}
|
||
/**
|
||
* Adds an HTML table to the summary buffer
|
||
*
|
||
* @param {SummaryTableCell[]} rows table rows
|
||
*
|
||
* @returns {Summary} summary instance
|
||
*/
|
||
addTable(rows) {
|
||
const tableBody = rows
|
||
.map(row => {
|
||
const cells = row
|
||
.map(cell => {
|
||
if (typeof cell === 'string') {
|
||
return this.wrap('td', cell);
|
||
}
|
||
const { header, data, colspan, rowspan } = cell;
|
||
const tag = header ? 'th' : 'td';
|
||
const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan }));
|
||
return this.wrap(tag, data, attrs);
|
||
})
|
||
.join('');
|
||
return this.wrap('tr', cells);
|
||
})
|
||
.join('');
|
||
const element = this.wrap('table', tableBody);
|
||
return this.addRaw(element).addEOL();
|
||
}
|
||
/**
|
||
* Adds a collapsable HTML details element to the summary buffer
|
||
*
|
||
* @param {string} label text for the closed state
|
||
* @param {string} content collapsable content
|
||
*
|
||
* @returns {Summary} summary instance
|
||
*/
|
||
addDetails(label, content) {
|
||
const element = this.wrap('details', this.wrap('summary', label) + content);
|
||
return this.addRaw(element).addEOL();
|
||
}
|
||
/**
|
||
* Adds an HTML image tag to the summary buffer
|
||
*
|
||
* @param {string} src path to the image you to embed
|
||
* @param {string} alt text description of the image
|
||
* @param {SummaryImageOptions} options (optional) addition image attributes
|
||
*
|
||
* @returns {Summary} summary instance
|
||
*/
|
||
addImage(src, alt, options) {
|
||
const { width, height } = options || {};
|
||
const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height }));
|
||
const element = this.wrap('img', null, Object.assign({ src, alt }, attrs));
|
||
return this.addRaw(element).addEOL();
|
||
}
|
||
/**
|
||
* Adds an HTML section heading element
|
||
*
|
||
* @param {string} text heading text
|
||
* @param {number | string} [level=1] (optional) the heading level, default: 1
|
||
*
|
||
* @returns {Summary} summary instance
|
||
*/
|
||
addHeading(text, level) {
|
||
const tag = `h${level}`;
|
||
const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag)
|
||
? tag
|
||
: 'h1';
|
||
const element = this.wrap(allowedTag, text);
|
||
return this.addRaw(element).addEOL();
|
||
}
|
||
/**
|
||
* Adds an HTML thematic break (<hr>) to the summary buffer
|
||
*
|
||
* @returns {Summary} summary instance
|
||
*/
|
||
addSeparator() {
|
||
const element = this.wrap('hr', null);
|
||
return this.addRaw(element).addEOL();
|
||
}
|
||
/**
|
||
* Adds an HTML line break (<br>) to the summary buffer
|
||
*
|
||
* @returns {Summary} summary instance
|
||
*/
|
||
addBreak() {
|
||
const element = this.wrap('br', null);
|
||
return this.addRaw(element).addEOL();
|
||
}
|
||
/**
|
||
* Adds an HTML blockquote to the summary buffer
|
||
*
|
||
* @param {string} text quote text
|
||
* @param {string} cite (optional) citation url
|
||
*
|
||
* @returns {Summary} summary instance
|
||
*/
|
||
addQuote(text, cite) {
|
||
const attrs = Object.assign({}, (cite && { cite }));
|
||
const element = this.wrap('blockquote', text, attrs);
|
||
return this.addRaw(element).addEOL();
|
||
}
|
||
/**
|
||
* Adds an HTML anchor tag to the summary buffer
|
||
*
|
||
* @param {string} text link text/content
|
||
* @param {string} href hyperlink
|
||
*
|
||
* @returns {Summary} summary instance
|
||
*/
|
||
addLink(text, href) {
|
||
const element = this.wrap('a', text, { href });
|
||
return this.addRaw(element).addEOL();
|
||
}
|
||
}
|
||
const _summary = new Summary();
|
||
/**
|
||
* @deprecated use `core.summary`
|
||
*/
|
||
exports.markdownSummary = _summary;
|
||
exports.summary = _summary;
|
||
//# sourceMappingURL=summary.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 30302:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
// We use any as a valid input type
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.toCommandValue = toCommandValue;
|
||
exports.toCommandProperties = toCommandProperties;
|
||
/**
|
||
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||
* @param input input to sanitize into a string
|
||
*/
|
||
function toCommandValue(input) {
|
||
if (input === null || input === undefined) {
|
||
return '';
|
||
}
|
||
else if (typeof input === 'string' || input instanceof String) {
|
||
return input;
|
||
}
|
||
return JSON.stringify(input);
|
||
}
|
||
/**
|
||
*
|
||
* @param annotationProperties
|
||
* @returns The command properties to send with the actual annotation command
|
||
* See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
|
||
*/
|
||
function toCommandProperties(annotationProperties) {
|
||
if (!Object.keys(annotationProperties).length) {
|
||
return {};
|
||
}
|
||
return {
|
||
title: annotationProperties.title,
|
||
file: annotationProperties.file,
|
||
line: annotationProperties.startLine,
|
||
endLine: annotationProperties.endLine,
|
||
col: annotationProperties.startColumn,
|
||
endColumn: annotationProperties.endColumn
|
||
};
|
||
}
|
||
//# sourceMappingURL=utils.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 95236:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.exec = exec;
|
||
exports.getExecOutput = getExecOutput;
|
||
const string_decoder_1 = __nccwpck_require__(13193);
|
||
const tr = __importStar(__nccwpck_require__(6665));
|
||
/**
|
||
* Exec a command.
|
||
* Output will be streamed to the live console.
|
||
* Returns promise with return code
|
||
*
|
||
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
||
* @param args optional arguments for tool. Escaping is handled by the lib.
|
||
* @param options optional exec options. See ExecOptions
|
||
* @returns Promise<number> exit code
|
||
*/
|
||
function exec(commandLine, args, options) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const commandArgs = tr.argStringToArray(commandLine);
|
||
if (commandArgs.length === 0) {
|
||
throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
|
||
}
|
||
// Path to tool to execute should be first arg
|
||
const toolPath = commandArgs[0];
|
||
args = commandArgs.slice(1).concat(args || []);
|
||
const runner = new tr.ToolRunner(toolPath, args, options);
|
||
return runner.exec();
|
||
});
|
||
}
|
||
/**
|
||
* Exec a command and get the output.
|
||
* Output will be streamed to the live console.
|
||
* Returns promise with the exit code and collected stdout and stderr
|
||
*
|
||
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
||
* @param args optional arguments for tool. Escaping is handled by the lib.
|
||
* @param options optional exec options. See ExecOptions
|
||
* @returns Promise<ExecOutput> exit code, stdout, and stderr
|
||
*/
|
||
function getExecOutput(commandLine, args, options) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
var _a, _b;
|
||
let stdout = '';
|
||
let stderr = '';
|
||
//Using string decoder covers the case where a mult-byte character is split
|
||
const stdoutDecoder = new string_decoder_1.StringDecoder('utf8');
|
||
const stderrDecoder = new string_decoder_1.StringDecoder('utf8');
|
||
const originalStdoutListener = (_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout;
|
||
const originalStdErrListener = (_b = options === null || options === void 0 ? void 0 : options.listeners) === null || _b === void 0 ? void 0 : _b.stderr;
|
||
const stdErrListener = (data) => {
|
||
stderr += stderrDecoder.write(data);
|
||
if (originalStdErrListener) {
|
||
originalStdErrListener(data);
|
||
}
|
||
};
|
||
const stdOutListener = (data) => {
|
||
stdout += stdoutDecoder.write(data);
|
||
if (originalStdoutListener) {
|
||
originalStdoutListener(data);
|
||
}
|
||
};
|
||
const listeners = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.listeners), { stdout: stdOutListener, stderr: stdErrListener });
|
||
const exitCode = yield exec(commandLine, args, Object.assign(Object.assign({}, options), { listeners }));
|
||
//flush any remaining characters
|
||
stdout += stdoutDecoder.end();
|
||
stderr += stderrDecoder.end();
|
||
return {
|
||
exitCode,
|
||
stdout,
|
||
stderr
|
||
};
|
||
});
|
||
}
|
||
//# sourceMappingURL=exec.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 6665:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.ToolRunner = void 0;
|
||
exports.argStringToArray = argStringToArray;
|
||
const os = __importStar(__nccwpck_require__(70857));
|
||
const events = __importStar(__nccwpck_require__(24434));
|
||
const child = __importStar(__nccwpck_require__(35317));
|
||
const path = __importStar(__nccwpck_require__(16928));
|
||
const io = __importStar(__nccwpck_require__(94994));
|
||
const ioUtil = __importStar(__nccwpck_require__(75207));
|
||
const timers_1 = __nccwpck_require__(53557);
|
||
/* eslint-disable @typescript-eslint/unbound-method */
|
||
const IS_WINDOWS = process.platform === 'win32';
|
||
/*
|
||
* Class for running command line tools. Handles quoting and arg parsing in a platform agnostic way.
|
||
*/
|
||
class ToolRunner extends events.EventEmitter {
|
||
constructor(toolPath, args, options) {
|
||
super();
|
||
if (!toolPath) {
|
||
throw new Error("Parameter 'toolPath' cannot be null or empty.");
|
||
}
|
||
this.toolPath = toolPath;
|
||
this.args = args || [];
|
||
this.options = options || {};
|
||
}
|
||
_debug(message) {
|
||
if (this.options.listeners && this.options.listeners.debug) {
|
||
this.options.listeners.debug(message);
|
||
}
|
||
}
|
||
_getCommandString(options, noPrefix) {
|
||
const toolPath = this._getSpawnFileName();
|
||
const args = this._getSpawnArgs(options);
|
||
let cmd = noPrefix ? '' : '[command]'; // omit prefix when piped to a second tool
|
||
if (IS_WINDOWS) {
|
||
// Windows + cmd file
|
||
if (this._isCmdFile()) {
|
||
cmd += toolPath;
|
||
for (const a of args) {
|
||
cmd += ` ${a}`;
|
||
}
|
||
}
|
||
// Windows + verbatim
|
||
else if (options.windowsVerbatimArguments) {
|
||
cmd += `"${toolPath}"`;
|
||
for (const a of args) {
|
||
cmd += ` ${a}`;
|
||
}
|
||
}
|
||
// Windows (regular)
|
||
else {
|
||
cmd += this._windowsQuoteCmdArg(toolPath);
|
||
for (const a of args) {
|
||
cmd += ` ${this._windowsQuoteCmdArg(a)}`;
|
||
}
|
||
}
|
||
}
|
||
else {
|
||
// OSX/Linux - this can likely be improved with some form of quoting.
|
||
// creating processes on Unix is fundamentally different than Windows.
|
||
// on Unix, execvp() takes an arg array.
|
||
cmd += toolPath;
|
||
for (const a of args) {
|
||
cmd += ` ${a}`;
|
||
}
|
||
}
|
||
return cmd;
|
||
}
|
||
_processLineBuffer(data, strBuffer, onLine) {
|
||
try {
|
||
let s = strBuffer + data.toString();
|
||
let n = s.indexOf(os.EOL);
|
||
while (n > -1) {
|
||
const line = s.substring(0, n);
|
||
onLine(line);
|
||
// the rest of the string ...
|
||
s = s.substring(n + os.EOL.length);
|
||
n = s.indexOf(os.EOL);
|
||
}
|
||
return s;
|
||
}
|
||
catch (err) {
|
||
// streaming lines to console is best effort. Don't fail a build.
|
||
this._debug(`error processing line. Failed with error ${err}`);
|
||
return '';
|
||
}
|
||
}
|
||
_getSpawnFileName() {
|
||
if (IS_WINDOWS) {
|
||
if (this._isCmdFile()) {
|
||
return process.env['COMSPEC'] || 'cmd.exe';
|
||
}
|
||
}
|
||
return this.toolPath;
|
||
}
|
||
_getSpawnArgs(options) {
|
||
if (IS_WINDOWS) {
|
||
if (this._isCmdFile()) {
|
||
let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;
|
||
for (const a of this.args) {
|
||
argline += ' ';
|
||
argline += options.windowsVerbatimArguments
|
||
? a
|
||
: this._windowsQuoteCmdArg(a);
|
||
}
|
||
argline += '"';
|
||
return [argline];
|
||
}
|
||
}
|
||
return this.args;
|
||
}
|
||
_endsWith(str, end) {
|
||
return str.endsWith(end);
|
||
}
|
||
_isCmdFile() {
|
||
const upperToolPath = this.toolPath.toUpperCase();
|
||
return (this._endsWith(upperToolPath, '.CMD') ||
|
||
this._endsWith(upperToolPath, '.BAT'));
|
||
}
|
||
_windowsQuoteCmdArg(arg) {
|
||
// for .exe, apply the normal quoting rules that libuv applies
|
||
if (!this._isCmdFile()) {
|
||
return this._uvQuoteCmdArg(arg);
|
||
}
|
||
// otherwise apply quoting rules specific to the cmd.exe command line parser.
|
||
// the libuv rules are generic and are not designed specifically for cmd.exe
|
||
// command line parser.
|
||
//
|
||
// for a detailed description of the cmd.exe command line parser, refer to
|
||
// http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/7970912#7970912
|
||
// need quotes for empty arg
|
||
if (!arg) {
|
||
return '""';
|
||
}
|
||
// determine whether the arg needs to be quoted
|
||
const cmdSpecialChars = [
|
||
' ',
|
||
'\t',
|
||
'&',
|
||
'(',
|
||
')',
|
||
'[',
|
||
']',
|
||
'{',
|
||
'}',
|
||
'^',
|
||
'=',
|
||
';',
|
||
'!',
|
||
"'",
|
||
'+',
|
||
',',
|
||
'`',
|
||
'~',
|
||
'|',
|
||
'<',
|
||
'>',
|
||
'"'
|
||
];
|
||
let needsQuotes = false;
|
||
for (const char of arg) {
|
||
if (cmdSpecialChars.some(x => x === char)) {
|
||
needsQuotes = true;
|
||
break;
|
||
}
|
||
}
|
||
// short-circuit if quotes not needed
|
||
if (!needsQuotes) {
|
||
return arg;
|
||
}
|
||
// the following quoting rules are very similar to the rules that by libuv applies.
|
||
//
|
||
// 1) wrap the string in quotes
|
||
//
|
||
// 2) double-up quotes - i.e. " => ""
|
||
//
|
||
// this is different from the libuv quoting rules. libuv replaces " with \", which unfortunately
|
||
// doesn't work well with a cmd.exe command line.
|
||
//
|
||
// note, replacing " with "" also works well if the arg is passed to a downstream .NET console app.
|
||
// for example, the command line:
|
||
// foo.exe "myarg:""my val"""
|
||
// is parsed by a .NET console app into an arg array:
|
||
// [ "myarg:\"my val\"" ]
|
||
// which is the same end result when applying libuv quoting rules. although the actual
|
||
// command line from libuv quoting rules would look like:
|
||
// foo.exe "myarg:\"my val\""
|
||
//
|
||
// 3) double-up slashes that precede a quote,
|
||
// e.g. hello \world => "hello \world"
|
||
// hello\"world => "hello\\""world"
|
||
// hello\\"world => "hello\\\\""world"
|
||
// hello world\ => "hello world\\"
|
||
//
|
||
// technically this is not required for a cmd.exe command line, or the batch argument parser.
|
||
// the reasons for including this as a .cmd quoting rule are:
|
||
//
|
||
// a) this is optimized for the scenario where the argument is passed from the .cmd file to an
|
||
// external program. many programs (e.g. .NET console apps) rely on the slash-doubling rule.
|
||
//
|
||
// b) it's what we've been doing previously (by deferring to node default behavior) and we
|
||
// haven't heard any complaints about that aspect.
|
||
//
|
||
// note, a weakness of the quoting rules chosen here, is that % is not escaped. in fact, % cannot be
|
||
// escaped when used on the command line directly - even though within a .cmd file % can be escaped
|
||
// by using %%.
|
||
//
|
||
// the saving grace is, on the command line, %var% is left as-is if var is not defined. this contrasts
|
||
// the line parsing rules within a .cmd file, where if var is not defined it is replaced with nothing.
|
||
//
|
||
// one option that was explored was replacing % with ^% - i.e. %var% => ^%var^%. this hack would
|
||
// often work, since it is unlikely that var^ would exist, and the ^ character is removed when the
|
||
// variable is used. the problem, however, is that ^ is not removed when %* is used to pass the args
|
||
// to an external program.
|
||
//
|
||
// an unexplored potential solution for the % escaping problem, is to create a wrapper .cmd file.
|
||
// % can be escaped within a .cmd file.
|
||
let reverse = '"';
|
||
let quoteHit = true;
|
||
for (let i = arg.length; i > 0; i--) {
|
||
// walk the string in reverse
|
||
reverse += arg[i - 1];
|
||
if (quoteHit && arg[i - 1] === '\\') {
|
||
reverse += '\\'; // double the slash
|
||
}
|
||
else if (arg[i - 1] === '"') {
|
||
quoteHit = true;
|
||
reverse += '"'; // double the quote
|
||
}
|
||
else {
|
||
quoteHit = false;
|
||
}
|
||
}
|
||
reverse += '"';
|
||
return reverse.split('').reverse().join('');
|
||
}
|
||
_uvQuoteCmdArg(arg) {
|
||
// Tool runner wraps child_process.spawn() and needs to apply the same quoting as
|
||
// Node in certain cases where the undocumented spawn option windowsVerbatimArguments
|
||
// is used.
|
||
//
|
||
// Since this function is a port of quote_cmd_arg from Node 4.x (technically, lib UV,
|
||
// see https://github.com/nodejs/node/blob/v4.x/deps/uv/src/win/process.c for details),
|
||
// pasting copyright notice from Node within this function:
|
||
//
|
||
// Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||
//
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||
// of this software and associated documentation files (the "Software"), to
|
||
// deal in the Software without restriction, including without limitation the
|
||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||
// sell copies of the Software, and to permit persons to whom the Software is
|
||
// furnished to do so, subject to the following conditions:
|
||
//
|
||
// The above copyright notice and this permission notice shall be included in
|
||
// all copies or substantial portions of the Software.
|
||
//
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||
// IN THE SOFTWARE.
|
||
if (!arg) {
|
||
// Need double quotation for empty argument
|
||
return '""';
|
||
}
|
||
if (!arg.includes(' ') && !arg.includes('\t') && !arg.includes('"')) {
|
||
// No quotation needed
|
||
return arg;
|
||
}
|
||
if (!arg.includes('"') && !arg.includes('\\')) {
|
||
// No embedded double quotes or backslashes, so I can just wrap
|
||
// quote marks around the whole thing.
|
||
return `"${arg}"`;
|
||
}
|
||
// Expected input/output:
|
||
// input : hello"world
|
||
// output: "hello\"world"
|
||
// input : hello""world
|
||
// output: "hello\"\"world"
|
||
// input : hello\world
|
||
// output: hello\world
|
||
// input : hello\\world
|
||
// output: hello\\world
|
||
// input : hello\"world
|
||
// output: "hello\\\"world"
|
||
// input : hello\\"world
|
||
// output: "hello\\\\\"world"
|
||
// input : hello world\
|
||
// output: "hello world\\" - note the comment in libuv actually reads "hello world\"
|
||
// but it appears the comment is wrong, it should be "hello world\\"
|
||
let reverse = '"';
|
||
let quoteHit = true;
|
||
for (let i = arg.length; i > 0; i--) {
|
||
// walk the string in reverse
|
||
reverse += arg[i - 1];
|
||
if (quoteHit && arg[i - 1] === '\\') {
|
||
reverse += '\\';
|
||
}
|
||
else if (arg[i - 1] === '"') {
|
||
quoteHit = true;
|
||
reverse += '\\';
|
||
}
|
||
else {
|
||
quoteHit = false;
|
||
}
|
||
}
|
||
reverse += '"';
|
||
return reverse.split('').reverse().join('');
|
||
}
|
||
_cloneExecOptions(options) {
|
||
options = options || {};
|
||
const result = {
|
||
cwd: options.cwd || process.cwd(),
|
||
env: options.env || process.env,
|
||
silent: options.silent || false,
|
||
windowsVerbatimArguments: options.windowsVerbatimArguments || false,
|
||
failOnStdErr: options.failOnStdErr || false,
|
||
ignoreReturnCode: options.ignoreReturnCode || false,
|
||
delay: options.delay || 10000
|
||
};
|
||
result.outStream = options.outStream || process.stdout;
|
||
result.errStream = options.errStream || process.stderr;
|
||
return result;
|
||
}
|
||
_getSpawnOptions(options, toolPath) {
|
||
options = options || {};
|
||
const result = {};
|
||
result.cwd = options.cwd;
|
||
result.env = options.env;
|
||
result['windowsVerbatimArguments'] =
|
||
options.windowsVerbatimArguments || this._isCmdFile();
|
||
if (options.windowsVerbatimArguments) {
|
||
result.argv0 = `"${toolPath}"`;
|
||
}
|
||
return result;
|
||
}
|
||
/**
|
||
* Exec a tool.
|
||
* Output will be streamed to the live console.
|
||
* Returns promise with return code
|
||
*
|
||
* @param tool path to tool to exec
|
||
* @param options optional exec options. See ExecOptions
|
||
* @returns number
|
||
*/
|
||
exec() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
// root the tool path if it is unrooted and contains relative pathing
|
||
if (!ioUtil.isRooted(this.toolPath) &&
|
||
(this.toolPath.includes('/') ||
|
||
(IS_WINDOWS && this.toolPath.includes('\\')))) {
|
||
// prefer options.cwd if it is specified, however options.cwd may also need to be rooted
|
||
this.toolPath = path.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath);
|
||
}
|
||
// if the tool is only a file name, then resolve it from the PATH
|
||
// otherwise verify it exists (add extension on Windows if necessary)
|
||
this.toolPath = yield io.which(this.toolPath, true);
|
||
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
||
this._debug(`exec tool: ${this.toolPath}`);
|
||
this._debug('arguments:');
|
||
for (const arg of this.args) {
|
||
this._debug(` ${arg}`);
|
||
}
|
||
const optionsNonNull = this._cloneExecOptions(this.options);
|
||
if (!optionsNonNull.silent && optionsNonNull.outStream) {
|
||
optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL);
|
||
}
|
||
const state = new ExecState(optionsNonNull, this.toolPath);
|
||
state.on('debug', (message) => {
|
||
this._debug(message);
|
||
});
|
||
if (this.options.cwd && !(yield ioUtil.exists(this.options.cwd))) {
|
||
return reject(new Error(`The cwd: ${this.options.cwd} does not exist!`));
|
||
}
|
||
const fileName = this._getSpawnFileName();
|
||
const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
|
||
let stdbuffer = '';
|
||
if (cp.stdout) {
|
||
cp.stdout.on('data', (data) => {
|
||
if (this.options.listeners && this.options.listeners.stdout) {
|
||
this.options.listeners.stdout(data);
|
||
}
|
||
if (!optionsNonNull.silent && optionsNonNull.outStream) {
|
||
optionsNonNull.outStream.write(data);
|
||
}
|
||
stdbuffer = this._processLineBuffer(data, stdbuffer, (line) => {
|
||
if (this.options.listeners && this.options.listeners.stdline) {
|
||
this.options.listeners.stdline(line);
|
||
}
|
||
});
|
||
});
|
||
}
|
||
let errbuffer = '';
|
||
if (cp.stderr) {
|
||
cp.stderr.on('data', (data) => {
|
||
state.processStderr = true;
|
||
if (this.options.listeners && this.options.listeners.stderr) {
|
||
this.options.listeners.stderr(data);
|
||
}
|
||
if (!optionsNonNull.silent &&
|
||
optionsNonNull.errStream &&
|
||
optionsNonNull.outStream) {
|
||
const s = optionsNonNull.failOnStdErr
|
||
? optionsNonNull.errStream
|
||
: optionsNonNull.outStream;
|
||
s.write(data);
|
||
}
|
||
errbuffer = this._processLineBuffer(data, errbuffer, (line) => {
|
||
if (this.options.listeners && this.options.listeners.errline) {
|
||
this.options.listeners.errline(line);
|
||
}
|
||
});
|
||
});
|
||
}
|
||
cp.on('error', (err) => {
|
||
state.processError = err.message;
|
||
state.processExited = true;
|
||
state.processClosed = true;
|
||
state.CheckComplete();
|
||
});
|
||
cp.on('exit', (code) => {
|
||
state.processExitCode = code;
|
||
state.processExited = true;
|
||
this._debug(`Exit code ${code} received from tool '${this.toolPath}'`);
|
||
state.CheckComplete();
|
||
});
|
||
cp.on('close', (code) => {
|
||
state.processExitCode = code;
|
||
state.processExited = true;
|
||
state.processClosed = true;
|
||
this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);
|
||
state.CheckComplete();
|
||
});
|
||
state.on('done', (error, exitCode) => {
|
||
if (stdbuffer.length > 0) {
|
||
this.emit('stdline', stdbuffer);
|
||
}
|
||
if (errbuffer.length > 0) {
|
||
this.emit('errline', errbuffer);
|
||
}
|
||
cp.removeAllListeners();
|
||
if (error) {
|
||
reject(error);
|
||
}
|
||
else {
|
||
resolve(exitCode);
|
||
}
|
||
});
|
||
if (this.options.input) {
|
||
if (!cp.stdin) {
|
||
throw new Error('child process missing stdin');
|
||
}
|
||
cp.stdin.end(this.options.input);
|
||
}
|
||
}));
|
||
});
|
||
}
|
||
}
|
||
exports.ToolRunner = ToolRunner;
|
||
/**
|
||
* Convert an arg string to an array of args. Handles escaping
|
||
*
|
||
* @param argString string of arguments
|
||
* @returns string[] array of arguments
|
||
*/
|
||
function argStringToArray(argString) {
|
||
const args = [];
|
||
let inQuotes = false;
|
||
let escaped = false;
|
||
let arg = '';
|
||
function append(c) {
|
||
// we only escape double quotes.
|
||
if (escaped && c !== '"') {
|
||
arg += '\\';
|
||
}
|
||
arg += c;
|
||
escaped = false;
|
||
}
|
||
for (let i = 0; i < argString.length; i++) {
|
||
const c = argString.charAt(i);
|
||
if (c === '"') {
|
||
if (!escaped) {
|
||
inQuotes = !inQuotes;
|
||
}
|
||
else {
|
||
append(c);
|
||
}
|
||
continue;
|
||
}
|
||
if (c === '\\' && escaped) {
|
||
append(c);
|
||
continue;
|
||
}
|
||
if (c === '\\' && inQuotes) {
|
||
escaped = true;
|
||
continue;
|
||
}
|
||
if (c === ' ' && !inQuotes) {
|
||
if (arg.length > 0) {
|
||
args.push(arg);
|
||
arg = '';
|
||
}
|
||
continue;
|
||
}
|
||
append(c);
|
||
}
|
||
if (arg.length > 0) {
|
||
args.push(arg.trim());
|
||
}
|
||
return args;
|
||
}
|
||
class ExecState extends events.EventEmitter {
|
||
constructor(options, toolPath) {
|
||
super();
|
||
this.processClosed = false; // tracks whether the process has exited and stdio is closed
|
||
this.processError = '';
|
||
this.processExitCode = 0;
|
||
this.processExited = false; // tracks whether the process has exited
|
||
this.processStderr = false; // tracks whether stderr was written to
|
||
this.delay = 10000; // 10 seconds
|
||
this.done = false;
|
||
this.timeout = null;
|
||
if (!toolPath) {
|
||
throw new Error('toolPath must not be empty');
|
||
}
|
||
this.options = options;
|
||
this.toolPath = toolPath;
|
||
if (options.delay) {
|
||
this.delay = options.delay;
|
||
}
|
||
}
|
||
CheckComplete() {
|
||
if (this.done) {
|
||
return;
|
||
}
|
||
if (this.processClosed) {
|
||
this._setResult();
|
||
}
|
||
else if (this.processExited) {
|
||
this.timeout = (0, timers_1.setTimeout)(ExecState.HandleTimeout, this.delay, this);
|
||
}
|
||
}
|
||
_debug(message) {
|
||
this.emit('debug', message);
|
||
}
|
||
_setResult() {
|
||
// determine whether there is an error
|
||
let error;
|
||
if (this.processExited) {
|
||
if (this.processError) {
|
||
error = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`);
|
||
}
|
||
else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) {
|
||
error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`);
|
||
}
|
||
else if (this.processStderr && this.options.failOnStdErr) {
|
||
error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`);
|
||
}
|
||
}
|
||
// clear the timeout
|
||
if (this.timeout) {
|
||
clearTimeout(this.timeout);
|
||
this.timeout = null;
|
||
}
|
||
this.done = true;
|
||
this.emit('done', error, this.processExitCode);
|
||
}
|
||
static HandleTimeout(state) {
|
||
if (state.done) {
|
||
return;
|
||
}
|
||
if (!state.processClosed && state.processExited) {
|
||
const message = `The STDIO streams did not close within ${state.delay / 1000} seconds of the exit event from process '${state.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;
|
||
state._debug(message);
|
||
}
|
||
state._setResult();
|
||
}
|
||
}
|
||
//# sourceMappingURL=toolrunner.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 47206:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.create = create;
|
||
exports.hashFiles = hashFiles;
|
||
const internal_globber_1 = __nccwpck_require__(10103);
|
||
const internal_hash_files_1 = __nccwpck_require__(73608);
|
||
/**
|
||
* Constructs a globber
|
||
*
|
||
* @param patterns Patterns separated by newlines
|
||
* @param options Glob options
|
||
*/
|
||
function create(patterns, options) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return yield internal_globber_1.DefaultGlobber.create(patterns, options);
|
||
});
|
||
}
|
||
/**
|
||
* Computes the sha256 hash of a glob
|
||
*
|
||
* @param patterns Patterns separated by newlines
|
||
* @param currentWorkspace Workspace used when matching files
|
||
* @param options Glob options
|
||
* @param verbose Enables verbose logging
|
||
*/
|
||
function hashFiles(patterns_1) {
|
||
return __awaiter(this, arguments, void 0, function* (patterns, currentWorkspace = '', options, verbose = false) {
|
||
let followSymbolicLinks = true;
|
||
if (options && typeof options.followSymbolicLinks === 'boolean') {
|
||
followSymbolicLinks = options.followSymbolicLinks;
|
||
}
|
||
const globber = yield create(patterns, { followSymbolicLinks });
|
||
return (0, internal_hash_files_1.hashFiles)(globber, currentWorkspace, verbose);
|
||
});
|
||
}
|
||
//# sourceMappingURL=glob.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 18164:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.getOptions = getOptions;
|
||
const core = __importStar(__nccwpck_require__(37484));
|
||
/**
|
||
* Returns a copy with defaults filled in.
|
||
*/
|
||
function getOptions(copy) {
|
||
const result = {
|
||
followSymbolicLinks: true,
|
||
implicitDescendants: true,
|
||
matchDirectories: true,
|
||
omitBrokenSymbolicLinks: true,
|
||
excludeHiddenFiles: false
|
||
};
|
||
if (copy) {
|
||
if (typeof copy.followSymbolicLinks === 'boolean') {
|
||
result.followSymbolicLinks = copy.followSymbolicLinks;
|
||
core.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`);
|
||
}
|
||
if (typeof copy.implicitDescendants === 'boolean') {
|
||
result.implicitDescendants = copy.implicitDescendants;
|
||
core.debug(`implicitDescendants '${result.implicitDescendants}'`);
|
||
}
|
||
if (typeof copy.matchDirectories === 'boolean') {
|
||
result.matchDirectories = copy.matchDirectories;
|
||
core.debug(`matchDirectories '${result.matchDirectories}'`);
|
||
}
|
||
if (typeof copy.omitBrokenSymbolicLinks === 'boolean') {
|
||
result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks;
|
||
core.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`);
|
||
}
|
||
if (typeof copy.excludeHiddenFiles === 'boolean') {
|
||
result.excludeHiddenFiles = copy.excludeHiddenFiles;
|
||
core.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
//# sourceMappingURL=internal-glob-options-helper.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 10103:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||
var m = o[Symbol.asyncIterator], i;
|
||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||
};
|
||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
||
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
||
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
||
function fulfill(value) { resume("next", value); }
|
||
function reject(value) { resume("throw", value); }
|
||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.DefaultGlobber = void 0;
|
||
const core = __importStar(__nccwpck_require__(37484));
|
||
const fs = __importStar(__nccwpck_require__(79896));
|
||
const globOptionsHelper = __importStar(__nccwpck_require__(18164));
|
||
const path = __importStar(__nccwpck_require__(16928));
|
||
const patternHelper = __importStar(__nccwpck_require__(98891));
|
||
const internal_match_kind_1 = __nccwpck_require__(62644);
|
||
const internal_pattern_1 = __nccwpck_require__(25370);
|
||
const internal_search_state_1 = __nccwpck_require__(79890);
|
||
const IS_WINDOWS = process.platform === 'win32';
|
||
class DefaultGlobber {
|
||
constructor(options) {
|
||
this.patterns = [];
|
||
this.searchPaths = [];
|
||
this.options = globOptionsHelper.getOptions(options);
|
||
}
|
||
getSearchPaths() {
|
||
// Return a copy
|
||
return this.searchPaths.slice();
|
||
}
|
||
glob() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
var _a, e_1, _b, _c;
|
||
const result = [];
|
||
try {
|
||
for (var _d = true, _e = __asyncValues(this.globGenerator()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
||
_c = _f.value;
|
||
_d = false;
|
||
const itemPath = _c;
|
||
result.push(itemPath);
|
||
}
|
||
}
|
||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||
finally {
|
||
try {
|
||
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
||
}
|
||
finally { if (e_1) throw e_1.error; }
|
||
}
|
||
return result;
|
||
});
|
||
}
|
||
globGenerator() {
|
||
return __asyncGenerator(this, arguments, function* globGenerator_1() {
|
||
// Fill in defaults options
|
||
const options = globOptionsHelper.getOptions(this.options);
|
||
// Implicit descendants?
|
||
const patterns = [];
|
||
for (const pattern of this.patterns) {
|
||
patterns.push(pattern);
|
||
if (options.implicitDescendants &&
|
||
(pattern.trailingSeparator ||
|
||
pattern.segments[pattern.segments.length - 1] !== '**')) {
|
||
patterns.push(new internal_pattern_1.Pattern(pattern.negate, true, pattern.segments.concat('**')));
|
||
}
|
||
}
|
||
// Push the search paths
|
||
const stack = [];
|
||
for (const searchPath of patternHelper.getSearchPaths(patterns)) {
|
||
core.debug(`Search path '${searchPath}'`);
|
||
// Exists?
|
||
try {
|
||
// Intentionally using lstat. Detection for broken symlink
|
||
// will be performed later (if following symlinks).
|
||
yield __await(fs.promises.lstat(searchPath));
|
||
}
|
||
catch (err) {
|
||
if (err.code === 'ENOENT') {
|
||
continue;
|
||
}
|
||
throw err;
|
||
}
|
||
stack.unshift(new internal_search_state_1.SearchState(searchPath, 1));
|
||
}
|
||
// Search
|
||
const traversalChain = []; // used to detect cycles
|
||
while (stack.length) {
|
||
// Pop
|
||
const item = stack.pop();
|
||
// Match?
|
||
const match = patternHelper.match(patterns, item.path);
|
||
const partialMatch = !!match || patternHelper.partialMatch(patterns, item.path);
|
||
if (!match && !partialMatch) {
|
||
continue;
|
||
}
|
||
// Stat
|
||
const stats = yield __await(DefaultGlobber.stat(item, options, traversalChain)
|
||
// Broken symlink, or symlink cycle detected, or no longer exists
|
||
);
|
||
// Broken symlink, or symlink cycle detected, or no longer exists
|
||
if (!stats) {
|
||
continue;
|
||
}
|
||
// Hidden file or directory?
|
||
if (options.excludeHiddenFiles && path.basename(item.path).match(/^\./)) {
|
||
continue;
|
||
}
|
||
// Directory
|
||
if (stats.isDirectory()) {
|
||
// Matched
|
||
if (match & internal_match_kind_1.MatchKind.Directory && options.matchDirectories) {
|
||
yield yield __await(item.path);
|
||
}
|
||
// Descend?
|
||
else if (!partialMatch) {
|
||
continue;
|
||
}
|
||
// Push the child items in reverse
|
||
const childLevel = item.level + 1;
|
||
const childItems = (yield __await(fs.promises.readdir(item.path))).map(x => new internal_search_state_1.SearchState(path.join(item.path, x), childLevel));
|
||
stack.push(...childItems.reverse());
|
||
}
|
||
// File
|
||
else if (match & internal_match_kind_1.MatchKind.File) {
|
||
yield yield __await(item.path);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
/**
|
||
* Constructs a DefaultGlobber
|
||
*/
|
||
static create(patterns, options) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const result = new DefaultGlobber(options);
|
||
if (IS_WINDOWS) {
|
||
patterns = patterns.replace(/\r\n/g, '\n');
|
||
patterns = patterns.replace(/\r/g, '\n');
|
||
}
|
||
const lines = patterns.split('\n').map(x => x.trim());
|
||
for (const line of lines) {
|
||
// Empty or comment
|
||
if (!line || line.startsWith('#')) {
|
||
continue;
|
||
}
|
||
// Pattern
|
||
else {
|
||
result.patterns.push(new internal_pattern_1.Pattern(line));
|
||
}
|
||
}
|
||
result.searchPaths.push(...patternHelper.getSearchPaths(result.patterns));
|
||
return result;
|
||
});
|
||
}
|
||
static stat(item, options, traversalChain) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
// Note:
|
||
// `stat` returns info about the target of a symlink (or symlink chain)
|
||
// `lstat` returns info about a symlink itself
|
||
let stats;
|
||
if (options.followSymbolicLinks) {
|
||
try {
|
||
// Use `stat` (following symlinks)
|
||
stats = yield fs.promises.stat(item.path);
|
||
}
|
||
catch (err) {
|
||
if (err.code === 'ENOENT') {
|
||
if (options.omitBrokenSymbolicLinks) {
|
||
core.debug(`Broken symlink '${item.path}'`);
|
||
return undefined;
|
||
}
|
||
throw new Error(`No information found for the path '${item.path}'. This may indicate a broken symbolic link.`);
|
||
}
|
||
throw err;
|
||
}
|
||
}
|
||
else {
|
||
// Use `lstat` (not following symlinks)
|
||
stats = yield fs.promises.lstat(item.path);
|
||
}
|
||
// Note, isDirectory() returns false for the lstat of a symlink
|
||
if (stats.isDirectory() && options.followSymbolicLinks) {
|
||
// Get the realpath
|
||
const realPath = yield fs.promises.realpath(item.path);
|
||
// Fixup the traversal chain to match the item level
|
||
while (traversalChain.length >= item.level) {
|
||
traversalChain.pop();
|
||
}
|
||
// Test for a cycle
|
||
if (traversalChain.some((x) => x === realPath)) {
|
||
core.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`);
|
||
return undefined;
|
||
}
|
||
// Update the traversal chain
|
||
traversalChain.push(realPath);
|
||
}
|
||
return stats;
|
||
});
|
||
}
|
||
}
|
||
exports.DefaultGlobber = DefaultGlobber;
|
||
//# sourceMappingURL=internal-globber.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 73608:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||
var m = o[Symbol.asyncIterator], i;
|
||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.hashFiles = hashFiles;
|
||
const crypto = __importStar(__nccwpck_require__(76982));
|
||
const core = __importStar(__nccwpck_require__(37484));
|
||
const fs = __importStar(__nccwpck_require__(79896));
|
||
const stream = __importStar(__nccwpck_require__(2203));
|
||
const util = __importStar(__nccwpck_require__(39023));
|
||
const path = __importStar(__nccwpck_require__(16928));
|
||
function hashFiles(globber_1, currentWorkspace_1) {
|
||
return __awaiter(this, arguments, void 0, function* (globber, currentWorkspace, verbose = false) {
|
||
var _a, e_1, _b, _c;
|
||
var _d;
|
||
const writeDelegate = verbose ? core.info : core.debug;
|
||
let hasMatch = false;
|
||
const githubWorkspace = currentWorkspace
|
||
? currentWorkspace
|
||
: ((_d = process.env['GITHUB_WORKSPACE']) !== null && _d !== void 0 ? _d : process.cwd());
|
||
const result = crypto.createHash('sha256');
|
||
let count = 0;
|
||
try {
|
||
for (var _e = true, _f = __asyncValues(globber.globGenerator()), _g; _g = yield _f.next(), _a = _g.done, !_a; _e = true) {
|
||
_c = _g.value;
|
||
_e = false;
|
||
const file = _c;
|
||
writeDelegate(file);
|
||
if (!file.startsWith(`${githubWorkspace}${path.sep}`)) {
|
||
writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`);
|
||
continue;
|
||
}
|
||
if (fs.statSync(file).isDirectory()) {
|
||
writeDelegate(`Skip directory '${file}'.`);
|
||
continue;
|
||
}
|
||
const hash = crypto.createHash('sha256');
|
||
const pipeline = util.promisify(stream.pipeline);
|
||
yield pipeline(fs.createReadStream(file), hash);
|
||
result.write(hash.digest());
|
||
count++;
|
||
if (!hasMatch) {
|
||
hasMatch = true;
|
||
}
|
||
}
|
||
}
|
||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||
finally {
|
||
try {
|
||
if (!_e && !_a && (_b = _f.return)) yield _b.call(_f);
|
||
}
|
||
finally { if (e_1) throw e_1.error; }
|
||
}
|
||
result.end();
|
||
if (hasMatch) {
|
||
writeDelegate(`Found ${count} files to hash.`);
|
||
return result.digest('hex');
|
||
}
|
||
else {
|
||
writeDelegate(`No matches found for glob`);
|
||
return '';
|
||
}
|
||
});
|
||
}
|
||
//# sourceMappingURL=internal-hash-files.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 62644:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.MatchKind = void 0;
|
||
/**
|
||
* Indicates whether a pattern matches a path
|
||
*/
|
||
var MatchKind;
|
||
(function (MatchKind) {
|
||
/** Not matched */
|
||
MatchKind[MatchKind["None"] = 0] = "None";
|
||
/** Matched if the path is a directory */
|
||
MatchKind[MatchKind["Directory"] = 1] = "Directory";
|
||
/** Matched if the path is a regular file */
|
||
MatchKind[MatchKind["File"] = 2] = "File";
|
||
/** Matched */
|
||
MatchKind[MatchKind["All"] = 3] = "All";
|
||
})(MatchKind || (exports.MatchKind = MatchKind = {}));
|
||
//# sourceMappingURL=internal-match-kind.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 84138:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.dirname = dirname;
|
||
exports.ensureAbsoluteRoot = ensureAbsoluteRoot;
|
||
exports.hasAbsoluteRoot = hasAbsoluteRoot;
|
||
exports.hasRoot = hasRoot;
|
||
exports.normalizeSeparators = normalizeSeparators;
|
||
exports.safeTrimTrailingSeparator = safeTrimTrailingSeparator;
|
||
const path = __importStar(__nccwpck_require__(16928));
|
||
const assert_1 = __importDefault(__nccwpck_require__(42613));
|
||
const IS_WINDOWS = process.platform === 'win32';
|
||
/**
|
||
* Similar to path.dirname except normalizes the path separators and slightly better handling for Windows UNC paths.
|
||
*
|
||
* For example, on Linux/macOS:
|
||
* - `/ => /`
|
||
* - `/hello => /`
|
||
*
|
||
* For example, on Windows:
|
||
* - `C:\ => C:\`
|
||
* - `C:\hello => C:\`
|
||
* - `C: => C:`
|
||
* - `C:hello => C:`
|
||
* - `\ => \`
|
||
* - `\hello => \`
|
||
* - `\\hello => \\hello`
|
||
* - `\\hello\world => \\hello\world`
|
||
*/
|
||
function dirname(p) {
|
||
// Normalize slashes and trim unnecessary trailing slash
|
||
p = safeTrimTrailingSeparator(p);
|
||
// Windows UNC root, e.g. \\hello or \\hello\world
|
||
if (IS_WINDOWS && /^\\\\[^\\]+(\\[^\\]+)?$/.test(p)) {
|
||
return p;
|
||
}
|
||
// Get dirname
|
||
let result = path.dirname(p);
|
||
// Trim trailing slash for Windows UNC root, e.g. \\hello\world\
|
||
if (IS_WINDOWS && /^\\\\[^\\]+\\[^\\]+\\$/.test(result)) {
|
||
result = safeTrimTrailingSeparator(result);
|
||
}
|
||
return result;
|
||
}
|
||
/**
|
||
* Roots the path if not already rooted. On Windows, relative roots like `\`
|
||
* or `C:` are expanded based on the current working directory.
|
||
*/
|
||
function ensureAbsoluteRoot(root, itemPath) {
|
||
(0, assert_1.default)(root, `ensureAbsoluteRoot parameter 'root' must not be empty`);
|
||
(0, assert_1.default)(itemPath, `ensureAbsoluteRoot parameter 'itemPath' must not be empty`);
|
||
// Already rooted
|
||
if (hasAbsoluteRoot(itemPath)) {
|
||
return itemPath;
|
||
}
|
||
// Windows
|
||
if (IS_WINDOWS) {
|
||
// Check for itemPath like C: or C:foo
|
||
if (itemPath.match(/^[A-Z]:[^\\/]|^[A-Z]:$/i)) {
|
||
let cwd = process.cwd();
|
||
(0, assert_1.default)(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`);
|
||
// Drive letter matches cwd? Expand to cwd
|
||
if (itemPath[0].toUpperCase() === cwd[0].toUpperCase()) {
|
||
// Drive only, e.g. C:
|
||
if (itemPath.length === 2) {
|
||
// Preserve specified drive letter case (upper or lower)
|
||
return `${itemPath[0]}:\\${cwd.substr(3)}`;
|
||
}
|
||
// Drive + path, e.g. C:foo
|
||
else {
|
||
if (!cwd.endsWith('\\')) {
|
||
cwd += '\\';
|
||
}
|
||
// Preserve specified drive letter case (upper or lower)
|
||
return `${itemPath[0]}:\\${cwd.substr(3)}${itemPath.substr(2)}`;
|
||
}
|
||
}
|
||
// Different drive
|
||
else {
|
||
return `${itemPath[0]}:\\${itemPath.substr(2)}`;
|
||
}
|
||
}
|
||
// Check for itemPath like \ or \foo
|
||
else if (normalizeSeparators(itemPath).match(/^\\$|^\\[^\\]/)) {
|
||
const cwd = process.cwd();
|
||
(0, assert_1.default)(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`);
|
||
return `${cwd[0]}:\\${itemPath.substr(1)}`;
|
||
}
|
||
}
|
||
(0, assert_1.default)(hasAbsoluteRoot(root), `ensureAbsoluteRoot parameter 'root' must have an absolute root`);
|
||
// Otherwise ensure root ends with a separator
|
||
if (root.endsWith('/') || (IS_WINDOWS && root.endsWith('\\'))) {
|
||
// Intentionally empty
|
||
}
|
||
else {
|
||
// Append separator
|
||
root += path.sep;
|
||
}
|
||
return root + itemPath;
|
||
}
|
||
/**
|
||
* On Linux/macOS, true if path starts with `/`. On Windows, true for paths like:
|
||
* `\\hello\share` and `C:\hello` (and using alternate separator).
|
||
*/
|
||
function hasAbsoluteRoot(itemPath) {
|
||
(0, assert_1.default)(itemPath, `hasAbsoluteRoot parameter 'itemPath' must not be empty`);
|
||
// Normalize separators
|
||
itemPath = normalizeSeparators(itemPath);
|
||
// Windows
|
||
if (IS_WINDOWS) {
|
||
// E.g. \\hello\share or C:\hello
|
||
return itemPath.startsWith('\\\\') || /^[A-Z]:\\/i.test(itemPath);
|
||
}
|
||
// E.g. /hello
|
||
return itemPath.startsWith('/');
|
||
}
|
||
/**
|
||
* On Linux/macOS, true if path starts with `/`. On Windows, true for paths like:
|
||
* `\`, `\hello`, `\\hello\share`, `C:`, and `C:\hello` (and using alternate separator).
|
||
*/
|
||
function hasRoot(itemPath) {
|
||
(0, assert_1.default)(itemPath, `isRooted parameter 'itemPath' must not be empty`);
|
||
// Normalize separators
|
||
itemPath = normalizeSeparators(itemPath);
|
||
// Windows
|
||
if (IS_WINDOWS) {
|
||
// E.g. \ or \hello or \\hello
|
||
// E.g. C: or C:\hello
|
||
return itemPath.startsWith('\\') || /^[A-Z]:/i.test(itemPath);
|
||
}
|
||
// E.g. /hello
|
||
return itemPath.startsWith('/');
|
||
}
|
||
/**
|
||
* Removes redundant slashes and converts `/` to `\` on Windows
|
||
*/
|
||
function normalizeSeparators(p) {
|
||
p = p || '';
|
||
// Windows
|
||
if (IS_WINDOWS) {
|
||
// Convert slashes on Windows
|
||
p = p.replace(/\//g, '\\');
|
||
// Remove redundant slashes
|
||
const isUnc = /^\\\\+[^\\]/.test(p); // e.g. \\hello
|
||
return (isUnc ? '\\' : '') + p.replace(/\\\\+/g, '\\'); // preserve leading \\ for UNC
|
||
}
|
||
// Remove redundant slashes
|
||
return p.replace(/\/\/+/g, '/');
|
||
}
|
||
/**
|
||
* Normalizes the path separators and trims the trailing separator (when safe).
|
||
* For example, `/foo/ => /foo` but `/ => /`
|
||
*/
|
||
function safeTrimTrailingSeparator(p) {
|
||
// Short-circuit if empty
|
||
if (!p) {
|
||
return '';
|
||
}
|
||
// Normalize separators
|
||
p = normalizeSeparators(p);
|
||
// No trailing slash
|
||
if (!p.endsWith(path.sep)) {
|
||
return p;
|
||
}
|
||
// Check '/' on Linux/macOS and '\' on Windows
|
||
if (p === path.sep) {
|
||
return p;
|
||
}
|
||
// On Windows check if drive root. E.g. C:\
|
||
if (IS_WINDOWS && /^[A-Z]:\\$/i.test(p)) {
|
||
return p;
|
||
}
|
||
// Otherwise trim trailing slash
|
||
return p.substr(0, p.length - 1);
|
||
}
|
||
//# sourceMappingURL=internal-path-helper.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 76617:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.Path = void 0;
|
||
const path = __importStar(__nccwpck_require__(16928));
|
||
const pathHelper = __importStar(__nccwpck_require__(84138));
|
||
const assert_1 = __importDefault(__nccwpck_require__(42613));
|
||
const IS_WINDOWS = process.platform === 'win32';
|
||
/**
|
||
* Helper class for parsing paths into segments
|
||
*/
|
||
class Path {
|
||
/**
|
||
* Constructs a Path
|
||
* @param itemPath Path or array of segments
|
||
*/
|
||
constructor(itemPath) {
|
||
this.segments = [];
|
||
// String
|
||
if (typeof itemPath === 'string') {
|
||
(0, assert_1.default)(itemPath, `Parameter 'itemPath' must not be empty`);
|
||
// Normalize slashes and trim unnecessary trailing slash
|
||
itemPath = pathHelper.safeTrimTrailingSeparator(itemPath);
|
||
// Not rooted
|
||
if (!pathHelper.hasRoot(itemPath)) {
|
||
this.segments = itemPath.split(path.sep);
|
||
}
|
||
// Rooted
|
||
else {
|
||
// Add all segments, while not at the root
|
||
let remaining = itemPath;
|
||
let dir = pathHelper.dirname(remaining);
|
||
while (dir !== remaining) {
|
||
// Add the segment
|
||
const basename = path.basename(remaining);
|
||
this.segments.unshift(basename);
|
||
// Truncate the last segment
|
||
remaining = dir;
|
||
dir = pathHelper.dirname(remaining);
|
||
}
|
||
// Remainder is the root
|
||
this.segments.unshift(remaining);
|
||
}
|
||
}
|
||
// Array
|
||
else {
|
||
// Must not be empty
|
||
(0, assert_1.default)(itemPath.length > 0, `Parameter 'itemPath' must not be an empty array`);
|
||
// Each segment
|
||
for (let i = 0; i < itemPath.length; i++) {
|
||
let segment = itemPath[i];
|
||
// Must not be empty
|
||
(0, assert_1.default)(segment, `Parameter 'itemPath' must not contain any empty segments`);
|
||
// Normalize slashes
|
||
segment = pathHelper.normalizeSeparators(itemPath[i]);
|
||
// Root segment
|
||
if (i === 0 && pathHelper.hasRoot(segment)) {
|
||
segment = pathHelper.safeTrimTrailingSeparator(segment);
|
||
(0, assert_1.default)(segment === pathHelper.dirname(segment), `Parameter 'itemPath' root segment contains information for multiple segments`);
|
||
this.segments.push(segment);
|
||
}
|
||
// All other segments
|
||
else {
|
||
// Must not contain slash
|
||
(0, assert_1.default)(!segment.includes(path.sep), `Parameter 'itemPath' contains unexpected path separators`);
|
||
this.segments.push(segment);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Converts the path to it's string representation
|
||
*/
|
||
toString() {
|
||
// First segment
|
||
let result = this.segments[0];
|
||
// All others
|
||
let skipSlash = result.endsWith(path.sep) || (IS_WINDOWS && /^[A-Z]:$/i.test(result));
|
||
for (let i = 1; i < this.segments.length; i++) {
|
||
if (skipSlash) {
|
||
skipSlash = false;
|
||
}
|
||
else {
|
||
result += path.sep;
|
||
}
|
||
result += this.segments[i];
|
||
}
|
||
return result;
|
||
}
|
||
}
|
||
exports.Path = Path;
|
||
//# sourceMappingURL=internal-path.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 98891:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.getSearchPaths = getSearchPaths;
|
||
exports.match = match;
|
||
exports.partialMatch = partialMatch;
|
||
const pathHelper = __importStar(__nccwpck_require__(84138));
|
||
const internal_match_kind_1 = __nccwpck_require__(62644);
|
||
const IS_WINDOWS = process.platform === 'win32';
|
||
/**
|
||
* Given an array of patterns, returns an array of paths to search.
|
||
* Duplicates and paths under other included paths are filtered out.
|
||
*/
|
||
function getSearchPaths(patterns) {
|
||
// Ignore negate patterns
|
||
patterns = patterns.filter(x => !x.negate);
|
||
// Create a map of all search paths
|
||
const searchPathMap = {};
|
||
for (const pattern of patterns) {
|
||
const key = IS_WINDOWS
|
||
? pattern.searchPath.toUpperCase()
|
||
: pattern.searchPath;
|
||
searchPathMap[key] = 'candidate';
|
||
}
|
||
const result = [];
|
||
for (const pattern of patterns) {
|
||
// Check if already included
|
||
const key = IS_WINDOWS
|
||
? pattern.searchPath.toUpperCase()
|
||
: pattern.searchPath;
|
||
if (searchPathMap[key] === 'included') {
|
||
continue;
|
||
}
|
||
// Check for an ancestor search path
|
||
let foundAncestor = false;
|
||
let tempKey = key;
|
||
let parent = pathHelper.dirname(tempKey);
|
||
while (parent !== tempKey) {
|
||
if (searchPathMap[parent]) {
|
||
foundAncestor = true;
|
||
break;
|
||
}
|
||
tempKey = parent;
|
||
parent = pathHelper.dirname(tempKey);
|
||
}
|
||
// Include the search pattern in the result
|
||
if (!foundAncestor) {
|
||
result.push(pattern.searchPath);
|
||
searchPathMap[key] = 'included';
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
/**
|
||
* Matches the patterns against the path
|
||
*/
|
||
function match(patterns, itemPath) {
|
||
let result = internal_match_kind_1.MatchKind.None;
|
||
for (const pattern of patterns) {
|
||
if (pattern.negate) {
|
||
result &= ~pattern.match(itemPath);
|
||
}
|
||
else {
|
||
result |= pattern.match(itemPath);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
/**
|
||
* Checks whether to descend further into the directory
|
||
*/
|
||
function partialMatch(patterns, itemPath) {
|
||
return patterns.some(x => !x.negate && x.partialMatch(itemPath));
|
||
}
|
||
//# sourceMappingURL=internal-pattern-helper.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 25370:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.Pattern = void 0;
|
||
const os = __importStar(__nccwpck_require__(70857));
|
||
const path = __importStar(__nccwpck_require__(16928));
|
||
const pathHelper = __importStar(__nccwpck_require__(84138));
|
||
const assert_1 = __importDefault(__nccwpck_require__(42613));
|
||
const minimatch_1 = __nccwpck_require__(43772);
|
||
const internal_match_kind_1 = __nccwpck_require__(62644);
|
||
const internal_path_1 = __nccwpck_require__(76617);
|
||
const IS_WINDOWS = process.platform === 'win32';
|
||
class Pattern {
|
||
constructor(patternOrNegate, isImplicitPattern = false, segments, homedir) {
|
||
/**
|
||
* Indicates whether matches should be excluded from the result set
|
||
*/
|
||
this.negate = false;
|
||
// Pattern overload
|
||
let pattern;
|
||
if (typeof patternOrNegate === 'string') {
|
||
pattern = patternOrNegate.trim();
|
||
}
|
||
// Segments overload
|
||
else {
|
||
// Convert to pattern
|
||
segments = segments || [];
|
||
(0, assert_1.default)(segments.length, `Parameter 'segments' must not empty`);
|
||
const root = Pattern.getLiteral(segments[0]);
|
||
(0, assert_1.default)(root && pathHelper.hasAbsoluteRoot(root), `Parameter 'segments' first element must be a root path`);
|
||
pattern = new internal_path_1.Path(segments).toString().trim();
|
||
if (patternOrNegate) {
|
||
pattern = `!${pattern}`;
|
||
}
|
||
}
|
||
// Negate
|
||
while (pattern.startsWith('!')) {
|
||
this.negate = !this.negate;
|
||
pattern = pattern.substr(1).trim();
|
||
}
|
||
// Normalize slashes and ensures absolute root
|
||
pattern = Pattern.fixupPattern(pattern, homedir);
|
||
// Segments
|
||
this.segments = new internal_path_1.Path(pattern).segments;
|
||
// Trailing slash indicates the pattern should only match directories, not regular files
|
||
this.trailingSeparator = pathHelper
|
||
.normalizeSeparators(pattern)
|
||
.endsWith(path.sep);
|
||
pattern = pathHelper.safeTrimTrailingSeparator(pattern);
|
||
// Search path (literal path prior to the first glob segment)
|
||
let foundGlob = false;
|
||
const searchSegments = this.segments
|
||
.map(x => Pattern.getLiteral(x))
|
||
.filter(x => !foundGlob && !(foundGlob = x === ''));
|
||
this.searchPath = new internal_path_1.Path(searchSegments).toString();
|
||
// Root RegExp (required when determining partial match)
|
||
this.rootRegExp = new RegExp(Pattern.regExpEscape(searchSegments[0]), IS_WINDOWS ? 'i' : '');
|
||
this.isImplicitPattern = isImplicitPattern;
|
||
// Create minimatch
|
||
const minimatchOptions = {
|
||
dot: true,
|
||
nobrace: true,
|
||
nocase: IS_WINDOWS,
|
||
nocomment: true,
|
||
noext: true,
|
||
nonegate: true
|
||
};
|
||
pattern = IS_WINDOWS ? pattern.replace(/\\/g, '/') : pattern;
|
||
this.minimatch = new minimatch_1.Minimatch(pattern, minimatchOptions);
|
||
}
|
||
/**
|
||
* Matches the pattern against the specified path
|
||
*/
|
||
match(itemPath) {
|
||
// Last segment is globstar?
|
||
if (this.segments[this.segments.length - 1] === '**') {
|
||
// Normalize slashes
|
||
itemPath = pathHelper.normalizeSeparators(itemPath);
|
||
// Append a trailing slash. Otherwise Minimatch will not match the directory immediately
|
||
// preceding the globstar. For example, given the pattern `/foo/**`, Minimatch returns
|
||
// false for `/foo` but returns true for `/foo/`. Append a trailing slash to handle that quirk.
|
||
if (!itemPath.endsWith(path.sep) && this.isImplicitPattern === false) {
|
||
// Note, this is safe because the constructor ensures the pattern has an absolute root.
|
||
// For example, formats like C: and C:foo on Windows are resolved to an absolute root.
|
||
itemPath = `${itemPath}${path.sep}`;
|
||
}
|
||
}
|
||
else {
|
||
// Normalize slashes and trim unnecessary trailing slash
|
||
itemPath = pathHelper.safeTrimTrailingSeparator(itemPath);
|
||
}
|
||
// Match
|
||
if (this.minimatch.match(itemPath)) {
|
||
return this.trailingSeparator ? internal_match_kind_1.MatchKind.Directory : internal_match_kind_1.MatchKind.All;
|
||
}
|
||
return internal_match_kind_1.MatchKind.None;
|
||
}
|
||
/**
|
||
* Indicates whether the pattern may match descendants of the specified path
|
||
*/
|
||
partialMatch(itemPath) {
|
||
// Normalize slashes and trim unnecessary trailing slash
|
||
itemPath = pathHelper.safeTrimTrailingSeparator(itemPath);
|
||
// matchOne does not handle root path correctly
|
||
if (pathHelper.dirname(itemPath) === itemPath) {
|
||
return this.rootRegExp.test(itemPath);
|
||
}
|
||
return this.minimatch.matchOne(itemPath.split(IS_WINDOWS ? /\\+/ : /\/+/), this.minimatch.set[0], true);
|
||
}
|
||
/**
|
||
* Escapes glob patterns within a path
|
||
*/
|
||
static globEscape(s) {
|
||
return (IS_WINDOWS ? s : s.replace(/\\/g, '\\\\')) // escape '\' on Linux/macOS
|
||
.replace(/(\[)(?=[^/]+\])/g, '[[]') // escape '[' when ']' follows within the path segment
|
||
.replace(/\?/g, '[?]') // escape '?'
|
||
.replace(/\*/g, '[*]'); // escape '*'
|
||
}
|
||
/**
|
||
* Normalizes slashes and ensures absolute root
|
||
*/
|
||
static fixupPattern(pattern, homedir) {
|
||
// Empty
|
||
(0, assert_1.default)(pattern, 'pattern cannot be empty');
|
||
// Must not contain `.` segment, unless first segment
|
||
// Must not contain `..` segment
|
||
const literalSegments = new internal_path_1.Path(pattern).segments.map(x => Pattern.getLiteral(x));
|
||
(0, assert_1.default)(literalSegments.every((x, i) => (x !== '.' || i === 0) && x !== '..'), `Invalid pattern '${pattern}'. Relative pathing '.' and '..' is not allowed.`);
|
||
// Must not contain globs in root, e.g. Windows UNC path \\foo\b*r
|
||
(0, assert_1.default)(!pathHelper.hasRoot(pattern) || literalSegments[0], `Invalid pattern '${pattern}'. Root segment must not contain globs.`);
|
||
// Normalize slashes
|
||
pattern = pathHelper.normalizeSeparators(pattern);
|
||
// Replace leading `.` segment
|
||
if (pattern === '.' || pattern.startsWith(`.${path.sep}`)) {
|
||
pattern = Pattern.globEscape(process.cwd()) + pattern.substr(1);
|
||
}
|
||
// Replace leading `~` segment
|
||
else if (pattern === '~' || pattern.startsWith(`~${path.sep}`)) {
|
||
homedir = homedir || os.homedir();
|
||
(0, assert_1.default)(homedir, 'Unable to determine HOME directory');
|
||
(0, assert_1.default)(pathHelper.hasAbsoluteRoot(homedir), `Expected HOME directory to be a rooted path. Actual '${homedir}'`);
|
||
pattern = Pattern.globEscape(homedir) + pattern.substr(1);
|
||
}
|
||
// Replace relative drive root, e.g. pattern is C: or C:foo
|
||
else if (IS_WINDOWS &&
|
||
(pattern.match(/^[A-Z]:$/i) || pattern.match(/^[A-Z]:[^\\]/i))) {
|
||
let root = pathHelper.ensureAbsoluteRoot('C:\\dummy-root', pattern.substr(0, 2));
|
||
if (pattern.length > 2 && !root.endsWith('\\')) {
|
||
root += '\\';
|
||
}
|
||
pattern = Pattern.globEscape(root) + pattern.substr(2);
|
||
}
|
||
// Replace relative root, e.g. pattern is \ or \foo
|
||
else if (IS_WINDOWS && (pattern === '\\' || pattern.match(/^\\[^\\]/))) {
|
||
let root = pathHelper.ensureAbsoluteRoot('C:\\dummy-root', '\\');
|
||
if (!root.endsWith('\\')) {
|
||
root += '\\';
|
||
}
|
||
pattern = Pattern.globEscape(root) + pattern.substr(1);
|
||
}
|
||
// Otherwise ensure absolute root
|
||
else {
|
||
pattern = pathHelper.ensureAbsoluteRoot(Pattern.globEscape(process.cwd()), pattern);
|
||
}
|
||
return pathHelper.normalizeSeparators(pattern);
|
||
}
|
||
/**
|
||
* Attempts to unescape a pattern segment to create a literal path segment.
|
||
* Otherwise returns empty string.
|
||
*/
|
||
static getLiteral(segment) {
|
||
let literal = '';
|
||
for (let i = 0; i < segment.length; i++) {
|
||
const c = segment[i];
|
||
// Escape
|
||
if (c === '\\' && !IS_WINDOWS && i + 1 < segment.length) {
|
||
literal += segment[++i];
|
||
continue;
|
||
}
|
||
// Wildcard
|
||
else if (c === '*' || c === '?') {
|
||
return '';
|
||
}
|
||
// Character set
|
||
else if (c === '[' && i + 1 < segment.length) {
|
||
let set = '';
|
||
let closed = -1;
|
||
for (let i2 = i + 1; i2 < segment.length; i2++) {
|
||
const c2 = segment[i2];
|
||
// Escape
|
||
if (c2 === '\\' && !IS_WINDOWS && i2 + 1 < segment.length) {
|
||
set += segment[++i2];
|
||
continue;
|
||
}
|
||
// Closed
|
||
else if (c2 === ']') {
|
||
closed = i2;
|
||
break;
|
||
}
|
||
// Otherwise
|
||
else {
|
||
set += c2;
|
||
}
|
||
}
|
||
// Closed?
|
||
if (closed >= 0) {
|
||
// Cannot convert
|
||
if (set.length > 1) {
|
||
return '';
|
||
}
|
||
// Convert to literal
|
||
if (set) {
|
||
literal += set;
|
||
i = closed;
|
||
continue;
|
||
}
|
||
}
|
||
// Otherwise fall thru
|
||
}
|
||
// Append
|
||
literal += c;
|
||
}
|
||
return literal;
|
||
}
|
||
/**
|
||
* Escapes regexp special characters
|
||
* https://javascript.info/regexp-escaping
|
||
*/
|
||
static regExpEscape(s) {
|
||
return s.replace(/[[\\^$.|?*+()]/g, '\\$&');
|
||
}
|
||
}
|
||
exports.Pattern = Pattern;
|
||
//# sourceMappingURL=internal-pattern.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 79890:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.SearchState = void 0;
|
||
class SearchState {
|
||
constructor(path, level) {
|
||
this.path = path;
|
||
this.level = level;
|
||
}
|
||
}
|
||
exports.SearchState = SearchState;
|
||
//# sourceMappingURL=internal-search-state.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 44552:
|
||
/***/ (function(__unused_webpack_module, exports) {
|
||
|
||
"use strict";
|
||
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0;
|
||
class BasicCredentialHandler {
|
||
constructor(username, password) {
|
||
this.username = username;
|
||
this.password = password;
|
||
}
|
||
prepareRequest(options) {
|
||
if (!options.headers) {
|
||
throw Error('The request has no headers');
|
||
}
|
||
options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`;
|
||
}
|
||
// This handler cannot handle 401
|
||
canHandleAuthentication() {
|
||
return false;
|
||
}
|
||
handleAuthentication() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
throw new Error('not implemented');
|
||
});
|
||
}
|
||
}
|
||
exports.BasicCredentialHandler = BasicCredentialHandler;
|
||
class BearerCredentialHandler {
|
||
constructor(token) {
|
||
this.token = token;
|
||
}
|
||
// currently implements pre-authorization
|
||
// TODO: support preAuth = false where it hooks on 401
|
||
prepareRequest(options) {
|
||
if (!options.headers) {
|
||
throw Error('The request has no headers');
|
||
}
|
||
options.headers['Authorization'] = `Bearer ${this.token}`;
|
||
}
|
||
// This handler cannot handle 401
|
||
canHandleAuthentication() {
|
||
return false;
|
||
}
|
||
handleAuthentication() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
throw new Error('not implemented');
|
||
});
|
||
}
|
||
}
|
||
exports.BearerCredentialHandler = BearerCredentialHandler;
|
||
class PersonalAccessTokenCredentialHandler {
|
||
constructor(token) {
|
||
this.token = token;
|
||
}
|
||
// currently implements pre-authorization
|
||
// TODO: support preAuth = false where it hooks on 401
|
||
prepareRequest(options) {
|
||
if (!options.headers) {
|
||
throw Error('The request has no headers');
|
||
}
|
||
options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`;
|
||
}
|
||
// This handler cannot handle 401
|
||
canHandleAuthentication() {
|
||
return false;
|
||
}
|
||
handleAuthentication() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
throw new Error('not implemented');
|
||
});
|
||
}
|
||
}
|
||
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
||
//# sourceMappingURL=auth.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 54844:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.HttpClient = exports.HttpClientResponse = exports.HttpClientError = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0;
|
||
exports.getProxyUrl = getProxyUrl;
|
||
exports.isHttps = isHttps;
|
||
const http = __importStar(__nccwpck_require__(58611));
|
||
const https = __importStar(__nccwpck_require__(65692));
|
||
const pm = __importStar(__nccwpck_require__(54988));
|
||
const tunnel = __importStar(__nccwpck_require__(20770));
|
||
const undici_1 = __nccwpck_require__(46752);
|
||
var HttpCodes;
|
||
(function (HttpCodes) {
|
||
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
||
HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
|
||
HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
|
||
HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
|
||
HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
|
||
HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
|
||
HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
|
||
HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
|
||
HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
||
HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
|
||
HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
|
||
HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
|
||
HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
|
||
HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
|
||
HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
|
||
HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
||
HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
|
||
HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
||
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
||
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
||
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
||
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
|
||
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
||
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
||
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
||
HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
||
HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
|
||
})(HttpCodes || (exports.HttpCodes = HttpCodes = {}));
|
||
var Headers;
|
||
(function (Headers) {
|
||
Headers["Accept"] = "accept";
|
||
Headers["ContentType"] = "content-type";
|
||
})(Headers || (exports.Headers = Headers = {}));
|
||
var MediaTypes;
|
||
(function (MediaTypes) {
|
||
MediaTypes["ApplicationJson"] = "application/json";
|
||
})(MediaTypes || (exports.MediaTypes = MediaTypes = {}));
|
||
/**
|
||
* Returns the proxy URL, depending upon the supplied url and proxy environment variables.
|
||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||
*/
|
||
function getProxyUrl(serverUrl) {
|
||
const proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
||
return proxyUrl ? proxyUrl.href : '';
|
||
}
|
||
const HttpRedirectCodes = [
|
||
HttpCodes.MovedPermanently,
|
||
HttpCodes.ResourceMoved,
|
||
HttpCodes.SeeOther,
|
||
HttpCodes.TemporaryRedirect,
|
||
HttpCodes.PermanentRedirect
|
||
];
|
||
const HttpResponseRetryCodes = [
|
||
HttpCodes.BadGateway,
|
||
HttpCodes.ServiceUnavailable,
|
||
HttpCodes.GatewayTimeout
|
||
];
|
||
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
||
const ExponentialBackoffCeiling = 10;
|
||
const ExponentialBackoffTimeSlice = 5;
|
||
class HttpClientError extends Error {
|
||
constructor(message, statusCode) {
|
||
super(message);
|
||
this.name = 'HttpClientError';
|
||
this.statusCode = statusCode;
|
||
Object.setPrototypeOf(this, HttpClientError.prototype);
|
||
}
|
||
}
|
||
exports.HttpClientError = HttpClientError;
|
||
class HttpClientResponse {
|
||
constructor(message) {
|
||
this.message = message;
|
||
}
|
||
readBody() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
||
let output = Buffer.alloc(0);
|
||
this.message.on('data', (chunk) => {
|
||
output = Buffer.concat([output, chunk]);
|
||
});
|
||
this.message.on('end', () => {
|
||
resolve(output.toString());
|
||
});
|
||
}));
|
||
});
|
||
}
|
||
readBodyBuffer() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
||
const chunks = [];
|
||
this.message.on('data', (chunk) => {
|
||
chunks.push(chunk);
|
||
});
|
||
this.message.on('end', () => {
|
||
resolve(Buffer.concat(chunks));
|
||
});
|
||
}));
|
||
});
|
||
}
|
||
}
|
||
exports.HttpClientResponse = HttpClientResponse;
|
||
function isHttps(requestUrl) {
|
||
const parsedUrl = new URL(requestUrl);
|
||
return parsedUrl.protocol === 'https:';
|
||
}
|
||
class HttpClient {
|
||
constructor(userAgent, handlers, requestOptions) {
|
||
this._ignoreSslError = false;
|
||
this._allowRedirects = true;
|
||
this._allowRedirectDowngrade = false;
|
||
this._maxRedirects = 50;
|
||
this._allowRetries = false;
|
||
this._maxRetries = 1;
|
||
this._keepAlive = false;
|
||
this._disposed = false;
|
||
this.userAgent = this._getUserAgentWithOrchestrationId(userAgent);
|
||
this.handlers = handlers || [];
|
||
this.requestOptions = requestOptions;
|
||
if (requestOptions) {
|
||
if (requestOptions.ignoreSslError != null) {
|
||
this._ignoreSslError = requestOptions.ignoreSslError;
|
||
}
|
||
this._socketTimeout = requestOptions.socketTimeout;
|
||
if (requestOptions.allowRedirects != null) {
|
||
this._allowRedirects = requestOptions.allowRedirects;
|
||
}
|
||
if (requestOptions.allowRedirectDowngrade != null) {
|
||
this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
|
||
}
|
||
if (requestOptions.maxRedirects != null) {
|
||
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
|
||
}
|
||
if (requestOptions.keepAlive != null) {
|
||
this._keepAlive = requestOptions.keepAlive;
|
||
}
|
||
if (requestOptions.allowRetries != null) {
|
||
this._allowRetries = requestOptions.allowRetries;
|
||
}
|
||
if (requestOptions.maxRetries != null) {
|
||
this._maxRetries = requestOptions.maxRetries;
|
||
}
|
||
}
|
||
}
|
||
options(requestUrl, additionalHeaders) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
||
});
|
||
}
|
||
get(requestUrl, additionalHeaders) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
||
});
|
||
}
|
||
del(requestUrl, additionalHeaders) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
||
});
|
||
}
|
||
post(requestUrl, data, additionalHeaders) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
||
});
|
||
}
|
||
patch(requestUrl, data, additionalHeaders) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
||
});
|
||
}
|
||
put(requestUrl, data, additionalHeaders) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
||
});
|
||
}
|
||
head(requestUrl, additionalHeaders) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
||
});
|
||
}
|
||
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return this.request(verb, requestUrl, stream, additionalHeaders);
|
||
});
|
||
}
|
||
/**
|
||
* Gets a typed object from an endpoint
|
||
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
||
*/
|
||
getJson(requestUrl_1) {
|
||
return __awaiter(this, arguments, void 0, function* (requestUrl, additionalHeaders = {}) {
|
||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||
const res = yield this.get(requestUrl, additionalHeaders);
|
||
return this._processResponse(res, this.requestOptions);
|
||
});
|
||
}
|
||
postJson(requestUrl_1, obj_1) {
|
||
return __awaiter(this, arguments, void 0, function* (requestUrl, obj, additionalHeaders = {}) {
|
||
const data = JSON.stringify(obj, null, 2);
|
||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||
additionalHeaders[Headers.ContentType] =
|
||
this._getExistingOrDefaultContentTypeHeader(additionalHeaders, MediaTypes.ApplicationJson);
|
||
const res = yield this.post(requestUrl, data, additionalHeaders);
|
||
return this._processResponse(res, this.requestOptions);
|
||
});
|
||
}
|
||
putJson(requestUrl_1, obj_1) {
|
||
return __awaiter(this, arguments, void 0, function* (requestUrl, obj, additionalHeaders = {}) {
|
||
const data = JSON.stringify(obj, null, 2);
|
||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||
additionalHeaders[Headers.ContentType] =
|
||
this._getExistingOrDefaultContentTypeHeader(additionalHeaders, MediaTypes.ApplicationJson);
|
||
const res = yield this.put(requestUrl, data, additionalHeaders);
|
||
return this._processResponse(res, this.requestOptions);
|
||
});
|
||
}
|
||
patchJson(requestUrl_1, obj_1) {
|
||
return __awaiter(this, arguments, void 0, function* (requestUrl, obj, additionalHeaders = {}) {
|
||
const data = JSON.stringify(obj, null, 2);
|
||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||
additionalHeaders[Headers.ContentType] =
|
||
this._getExistingOrDefaultContentTypeHeader(additionalHeaders, MediaTypes.ApplicationJson);
|
||
const res = yield this.patch(requestUrl, data, additionalHeaders);
|
||
return this._processResponse(res, this.requestOptions);
|
||
});
|
||
}
|
||
/**
|
||
* Makes a raw http request.
|
||
* All other methods such as get, post, patch, and request ultimately call this.
|
||
* Prefer get, del, post and patch
|
||
*/
|
||
request(verb, requestUrl, data, headers) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
if (this._disposed) {
|
||
throw new Error('Client has already been disposed.');
|
||
}
|
||
const parsedUrl = new URL(requestUrl);
|
||
let info = this._prepareRequest(verb, parsedUrl, headers);
|
||
// Only perform retries on reads since writes may not be idempotent.
|
||
const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb)
|
||
? this._maxRetries + 1
|
||
: 1;
|
||
let numTries = 0;
|
||
let response;
|
||
do {
|
||
response = yield this.requestRaw(info, data);
|
||
// Check if it's an authentication challenge
|
||
if (response &&
|
||
response.message &&
|
||
response.message.statusCode === HttpCodes.Unauthorized) {
|
||
let authenticationHandler;
|
||
for (const handler of this.handlers) {
|
||
if (handler.canHandleAuthentication(response)) {
|
||
authenticationHandler = handler;
|
||
break;
|
||
}
|
||
}
|
||
if (authenticationHandler) {
|
||
return authenticationHandler.handleAuthentication(this, info, data);
|
||
}
|
||
else {
|
||
// We have received an unauthorized response but have no handlers to handle it.
|
||
// Let the response return to the caller.
|
||
return response;
|
||
}
|
||
}
|
||
let redirectsRemaining = this._maxRedirects;
|
||
while (response.message.statusCode &&
|
||
HttpRedirectCodes.includes(response.message.statusCode) &&
|
||
this._allowRedirects &&
|
||
redirectsRemaining > 0) {
|
||
const redirectUrl = response.message.headers['location'];
|
||
if (!redirectUrl) {
|
||
// if there's no location to redirect to, we won't
|
||
break;
|
||
}
|
||
const parsedRedirectUrl = new URL(redirectUrl);
|
||
if (parsedUrl.protocol === 'https:' &&
|
||
parsedUrl.protocol !== parsedRedirectUrl.protocol &&
|
||
!this._allowRedirectDowngrade) {
|
||
throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.');
|
||
}
|
||
// we need to finish reading the response before reassigning response
|
||
// which will leak the open socket.
|
||
yield response.readBody();
|
||
// strip authorization header if redirected to a different hostname
|
||
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
||
for (const header in headers) {
|
||
// header names are case insensitive
|
||
if (header.toLowerCase() === 'authorization') {
|
||
delete headers[header];
|
||
}
|
||
}
|
||
}
|
||
// let's make the request with the new redirectUrl
|
||
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
||
response = yield this.requestRaw(info, data);
|
||
redirectsRemaining--;
|
||
}
|
||
if (!response.message.statusCode ||
|
||
!HttpResponseRetryCodes.includes(response.message.statusCode)) {
|
||
// If not a retry code, return immediately instead of retrying
|
||
return response;
|
||
}
|
||
numTries += 1;
|
||
if (numTries < maxTries) {
|
||
yield response.readBody();
|
||
yield this._performExponentialBackoff(numTries);
|
||
}
|
||
} while (numTries < maxTries);
|
||
return response;
|
||
});
|
||
}
|
||
/**
|
||
* Needs to be called if keepAlive is set to true in request options.
|
||
*/
|
||
dispose() {
|
||
if (this._agent) {
|
||
this._agent.destroy();
|
||
}
|
||
this._disposed = true;
|
||
}
|
||
/**
|
||
* Raw request.
|
||
* @param info
|
||
* @param data
|
||
*/
|
||
requestRaw(info, data) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return new Promise((resolve, reject) => {
|
||
function callbackForResult(err, res) {
|
||
if (err) {
|
||
reject(err);
|
||
}
|
||
else if (!res) {
|
||
// If `err` is not passed, then `res` must be passed.
|
||
reject(new Error('Unknown error'));
|
||
}
|
||
else {
|
||
resolve(res);
|
||
}
|
||
}
|
||
this.requestRawWithCallback(info, data, callbackForResult);
|
||
});
|
||
});
|
||
}
|
||
/**
|
||
* Raw request with callback.
|
||
* @param info
|
||
* @param data
|
||
* @param onResult
|
||
*/
|
||
requestRawWithCallback(info, data, onResult) {
|
||
if (typeof data === 'string') {
|
||
if (!info.options.headers) {
|
||
info.options.headers = {};
|
||
}
|
||
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
||
}
|
||
let callbackCalled = false;
|
||
function handleResult(err, res) {
|
||
if (!callbackCalled) {
|
||
callbackCalled = true;
|
||
onResult(err, res);
|
||
}
|
||
}
|
||
const req = info.httpModule.request(info.options, (msg) => {
|
||
const res = new HttpClientResponse(msg);
|
||
handleResult(undefined, res);
|
||
});
|
||
let socket;
|
||
req.on('socket', sock => {
|
||
socket = sock;
|
||
});
|
||
// If we ever get disconnected, we want the socket to timeout eventually
|
||
req.setTimeout(this._socketTimeout || 3 * 60000, () => {
|
||
if (socket) {
|
||
socket.end();
|
||
}
|
||
handleResult(new Error(`Request timeout: ${info.options.path}`));
|
||
});
|
||
req.on('error', function (err) {
|
||
// err has statusCode property
|
||
// res should have headers
|
||
handleResult(err);
|
||
});
|
||
if (data && typeof data === 'string') {
|
||
req.write(data, 'utf8');
|
||
}
|
||
if (data && typeof data !== 'string') {
|
||
data.on('close', function () {
|
||
req.end();
|
||
});
|
||
data.pipe(req);
|
||
}
|
||
else {
|
||
req.end();
|
||
}
|
||
}
|
||
/**
|
||
* Gets an http agent. This function is useful when you need an http agent that handles
|
||
* routing through a proxy server - depending upon the url and proxy environment variables.
|
||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||
*/
|
||
getAgent(serverUrl) {
|
||
const parsedUrl = new URL(serverUrl);
|
||
return this._getAgent(parsedUrl);
|
||
}
|
||
getAgentDispatcher(serverUrl) {
|
||
const parsedUrl = new URL(serverUrl);
|
||
const proxyUrl = pm.getProxyUrl(parsedUrl);
|
||
const useProxy = proxyUrl && proxyUrl.hostname;
|
||
if (!useProxy) {
|
||
return;
|
||
}
|
||
return this._getProxyAgentDispatcher(parsedUrl, proxyUrl);
|
||
}
|
||
_prepareRequest(method, requestUrl, headers) {
|
||
const info = {};
|
||
info.parsedUrl = requestUrl;
|
||
const usingSsl = info.parsedUrl.protocol === 'https:';
|
||
info.httpModule = usingSsl ? https : http;
|
||
const defaultPort = usingSsl ? 443 : 80;
|
||
info.options = {};
|
||
info.options.host = info.parsedUrl.hostname;
|
||
info.options.port = info.parsedUrl.port
|
||
? parseInt(info.parsedUrl.port)
|
||
: defaultPort;
|
||
info.options.path =
|
||
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
||
info.options.method = method;
|
||
info.options.headers = this._mergeHeaders(headers);
|
||
if (this.userAgent != null) {
|
||
info.options.headers['user-agent'] = this.userAgent;
|
||
}
|
||
info.options.agent = this._getAgent(info.parsedUrl);
|
||
// gives handlers an opportunity to participate
|
||
if (this.handlers) {
|
||
for (const handler of this.handlers) {
|
||
handler.prepareRequest(info.options);
|
||
}
|
||
}
|
||
return info;
|
||
}
|
||
_mergeHeaders(headers) {
|
||
if (this.requestOptions && this.requestOptions.headers) {
|
||
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {}));
|
||
}
|
||
return lowercaseKeys(headers || {});
|
||
}
|
||
/**
|
||
* Gets an existing header value or returns a default.
|
||
* Handles converting number header values to strings since HTTP headers must be strings.
|
||
* Note: This returns string | string[] since some headers can have multiple values.
|
||
* For headers that must always be a single string (like Content-Type), use the
|
||
* specialized _getExistingOrDefaultContentTypeHeader method instead.
|
||
*/
|
||
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
||
let clientHeader;
|
||
if (this.requestOptions && this.requestOptions.headers) {
|
||
const headerValue = lowercaseKeys(this.requestOptions.headers)[header];
|
||
if (headerValue) {
|
||
clientHeader =
|
||
typeof headerValue === 'number' ? headerValue.toString() : headerValue;
|
||
}
|
||
}
|
||
const additionalValue = additionalHeaders[header];
|
||
if (additionalValue !== undefined) {
|
||
return typeof additionalValue === 'number'
|
||
? additionalValue.toString()
|
||
: additionalValue;
|
||
}
|
||
if (clientHeader !== undefined) {
|
||
return clientHeader;
|
||
}
|
||
return _default;
|
||
}
|
||
/**
|
||
* Specialized version of _getExistingOrDefaultHeader for Content-Type header.
|
||
* Always returns a single string (not an array) since Content-Type should be a single value.
|
||
* Converts arrays to comma-separated strings and numbers to strings to ensure type safety.
|
||
* This was split from _getExistingOrDefaultHeader to provide stricter typing for callers
|
||
* that assign the result to places expecting a string (e.g., additionalHeaders[Headers.ContentType]).
|
||
*/
|
||
_getExistingOrDefaultContentTypeHeader(additionalHeaders, _default) {
|
||
let clientHeader;
|
||
if (this.requestOptions && this.requestOptions.headers) {
|
||
const headerValue = lowercaseKeys(this.requestOptions.headers)[Headers.ContentType];
|
||
if (headerValue) {
|
||
if (typeof headerValue === 'number') {
|
||
clientHeader = String(headerValue);
|
||
}
|
||
else if (Array.isArray(headerValue)) {
|
||
clientHeader = headerValue.join(', ');
|
||
}
|
||
else {
|
||
clientHeader = headerValue;
|
||
}
|
||
}
|
||
}
|
||
const additionalValue = additionalHeaders[Headers.ContentType];
|
||
// Return the first non-undefined value, converting numbers or arrays to strings if necessary
|
||
if (additionalValue !== undefined) {
|
||
if (typeof additionalValue === 'number') {
|
||
return String(additionalValue);
|
||
}
|
||
else if (Array.isArray(additionalValue)) {
|
||
return additionalValue.join(', ');
|
||
}
|
||
else {
|
||
return additionalValue;
|
||
}
|
||
}
|
||
if (clientHeader !== undefined) {
|
||
return clientHeader;
|
||
}
|
||
return _default;
|
||
}
|
||
_getAgent(parsedUrl) {
|
||
let agent;
|
||
const proxyUrl = pm.getProxyUrl(parsedUrl);
|
||
const useProxy = proxyUrl && proxyUrl.hostname;
|
||
if (this._keepAlive && useProxy) {
|
||
agent = this._proxyAgent;
|
||
}
|
||
if (!useProxy) {
|
||
agent = this._agent;
|
||
}
|
||
// if agent is already assigned use that agent.
|
||
if (agent) {
|
||
return agent;
|
||
}
|
||
const usingSsl = parsedUrl.protocol === 'https:';
|
||
let maxSockets = 100;
|
||
if (this.requestOptions) {
|
||
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
||
}
|
||
// This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis.
|
||
if (proxyUrl && proxyUrl.hostname) {
|
||
const agentOptions = {
|
||
maxSockets,
|
||
keepAlive: this._keepAlive,
|
||
proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && {
|
||
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
||
})), { host: proxyUrl.hostname, port: proxyUrl.port })
|
||
};
|
||
let tunnelAgent;
|
||
const overHttps = proxyUrl.protocol === 'https:';
|
||
if (usingSsl) {
|
||
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
|
||
}
|
||
else {
|
||
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
|
||
}
|
||
agent = tunnelAgent(agentOptions);
|
||
this._proxyAgent = agent;
|
||
}
|
||
// if tunneling agent isn't assigned create a new agent
|
||
if (!agent) {
|
||
const options = { keepAlive: this._keepAlive, maxSockets };
|
||
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
||
this._agent = agent;
|
||
}
|
||
if (usingSsl && this._ignoreSslError) {
|
||
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
||
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
||
// we have to cast it to any and change it directly
|
||
agent.options = Object.assign(agent.options || {}, {
|
||
rejectUnauthorized: false
|
||
});
|
||
}
|
||
return agent;
|
||
}
|
||
_getProxyAgentDispatcher(parsedUrl, proxyUrl) {
|
||
let proxyAgent;
|
||
if (this._keepAlive) {
|
||
proxyAgent = this._proxyAgentDispatcher;
|
||
}
|
||
// if agent is already assigned use that agent.
|
||
if (proxyAgent) {
|
||
return proxyAgent;
|
||
}
|
||
const usingSsl = parsedUrl.protocol === 'https:';
|
||
proxyAgent = new undici_1.ProxyAgent(Object.assign({ uri: proxyUrl.href, pipelining: !this._keepAlive ? 0 : 1 }, ((proxyUrl.username || proxyUrl.password) && {
|
||
token: `Basic ${Buffer.from(`${proxyUrl.username}:${proxyUrl.password}`).toString('base64')}`
|
||
})));
|
||
this._proxyAgentDispatcher = proxyAgent;
|
||
if (usingSsl && this._ignoreSslError) {
|
||
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
||
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
||
// we have to cast it to any and change it directly
|
||
proxyAgent.options = Object.assign(proxyAgent.options.requestTls || {}, {
|
||
rejectUnauthorized: false
|
||
});
|
||
}
|
||
return proxyAgent;
|
||
}
|
||
_getUserAgentWithOrchestrationId(userAgent) {
|
||
const baseUserAgent = userAgent || 'actions/http-client';
|
||
const orchId = process.env['ACTIONS_ORCHESTRATION_ID'];
|
||
if (orchId) {
|
||
// Sanitize the orchestration ID to ensure it contains only valid characters
|
||
// Valid characters: 0-9, a-z, _, -, .
|
||
const sanitizedId = orchId.replace(/[^a-z0-9_.-]/gi, '_');
|
||
return `${baseUserAgent} actions_orchestration_id/${sanitizedId}`;
|
||
}
|
||
return baseUserAgent;
|
||
}
|
||
_performExponentialBackoff(retryNumber) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
||
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
||
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
||
});
|
||
}
|
||
_processResponse(res, options) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
||
const statusCode = res.message.statusCode || 0;
|
||
const response = {
|
||
statusCode,
|
||
result: null,
|
||
headers: {}
|
||
};
|
||
// not found leads to null obj returned
|
||
if (statusCode === HttpCodes.NotFound) {
|
||
resolve(response);
|
||
}
|
||
// get the result from the body
|
||
function dateTimeDeserializer(key, value) {
|
||
if (typeof value === 'string') {
|
||
const a = new Date(value);
|
||
if (!isNaN(a.valueOf())) {
|
||
return a;
|
||
}
|
||
}
|
||
return value;
|
||
}
|
||
let obj;
|
||
let contents;
|
||
try {
|
||
contents = yield res.readBody();
|
||
if (contents && contents.length > 0) {
|
||
if (options && options.deserializeDates) {
|
||
obj = JSON.parse(contents, dateTimeDeserializer);
|
||
}
|
||
else {
|
||
obj = JSON.parse(contents);
|
||
}
|
||
response.result = obj;
|
||
}
|
||
response.headers = res.message.headers;
|
||
}
|
||
catch (err) {
|
||
// Invalid resource (contents not json); leaving result obj null
|
||
}
|
||
// note that 3xx redirects are handled by the http layer.
|
||
if (statusCode > 299) {
|
||
let msg;
|
||
// if exception/error in body, attempt to get better error
|
||
if (obj && obj.message) {
|
||
msg = obj.message;
|
||
}
|
||
else if (contents && contents.length > 0) {
|
||
// it may be the case that the exception is in the body message as string
|
||
msg = contents;
|
||
}
|
||
else {
|
||
msg = `Failed request: (${statusCode})`;
|
||
}
|
||
const err = new HttpClientError(msg, statusCode);
|
||
err.result = response.result;
|
||
reject(err);
|
||
}
|
||
else {
|
||
resolve(response);
|
||
}
|
||
}));
|
||
});
|
||
}
|
||
}
|
||
exports.HttpClient = HttpClient;
|
||
const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
||
//# sourceMappingURL=index.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 54988:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.getProxyUrl = getProxyUrl;
|
||
exports.checkBypass = checkBypass;
|
||
function getProxyUrl(reqUrl) {
|
||
const usingSsl = reqUrl.protocol === 'https:';
|
||
if (checkBypass(reqUrl)) {
|
||
return undefined;
|
||
}
|
||
const proxyVar = (() => {
|
||
if (usingSsl) {
|
||
return process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
||
}
|
||
else {
|
||
return process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
||
}
|
||
})();
|
||
if (proxyVar) {
|
||
try {
|
||
return new DecodedURL(proxyVar);
|
||
}
|
||
catch (_a) {
|
||
if (!proxyVar.startsWith('http://') && !proxyVar.startsWith('https://'))
|
||
return new DecodedURL(`http://${proxyVar}`);
|
||
}
|
||
}
|
||
else {
|
||
return undefined;
|
||
}
|
||
}
|
||
function checkBypass(reqUrl) {
|
||
if (!reqUrl.hostname) {
|
||
return false;
|
||
}
|
||
const reqHost = reqUrl.hostname;
|
||
if (isLoopbackAddress(reqHost)) {
|
||
return true;
|
||
}
|
||
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
||
if (!noProxy) {
|
||
return false;
|
||
}
|
||
// Determine the request port
|
||
let reqPort;
|
||
if (reqUrl.port) {
|
||
reqPort = Number(reqUrl.port);
|
||
}
|
||
else if (reqUrl.protocol === 'http:') {
|
||
reqPort = 80;
|
||
}
|
||
else if (reqUrl.protocol === 'https:') {
|
||
reqPort = 443;
|
||
}
|
||
// Format the request hostname and hostname with port
|
||
const upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
||
if (typeof reqPort === 'number') {
|
||
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
||
}
|
||
// Compare request host against noproxy
|
||
for (const upperNoProxyItem of noProxy
|
||
.split(',')
|
||
.map(x => x.trim().toUpperCase())
|
||
.filter(x => x)) {
|
||
if (upperNoProxyItem === '*' ||
|
||
upperReqHosts.some(x => x === upperNoProxyItem ||
|
||
x.endsWith(`.${upperNoProxyItem}`) ||
|
||
(upperNoProxyItem.startsWith('.') &&
|
||
x.endsWith(`${upperNoProxyItem}`)))) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
function isLoopbackAddress(host) {
|
||
const hostLower = host.toLowerCase();
|
||
return (hostLower === 'localhost' ||
|
||
hostLower.startsWith('127.') ||
|
||
hostLower.startsWith('[::1]') ||
|
||
hostLower.startsWith('[0:0:0:0:0:0:0:1]'));
|
||
}
|
||
class DecodedURL extends URL {
|
||
constructor(url, base) {
|
||
super(url, base);
|
||
this._decodedUsername = decodeURIComponent(super.username);
|
||
this._decodedPassword = decodeURIComponent(super.password);
|
||
}
|
||
get username() {
|
||
return this._decodedUsername;
|
||
}
|
||
get password() {
|
||
return this._decodedPassword;
|
||
}
|
||
}
|
||
//# sourceMappingURL=proxy.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 75207:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
var _a;
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.READONLY = exports.UV_FS_O_EXLOCK = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rm = exports.rename = exports.readdir = exports.open = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0;
|
||
exports.readlink = readlink;
|
||
exports.exists = exists;
|
||
exports.isDirectory = isDirectory;
|
||
exports.isRooted = isRooted;
|
||
exports.tryGetExecutablePath = tryGetExecutablePath;
|
||
exports.getCmdPath = getCmdPath;
|
||
const fs = __importStar(__nccwpck_require__(79896));
|
||
const path = __importStar(__nccwpck_require__(16928));
|
||
_a = fs.promises
|
||
// export const {open} = 'fs'
|
||
, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.open = _a.open, exports.readdir = _a.readdir, exports.rename = _a.rename, exports.rm = _a.rm, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
|
||
// export const {open} = 'fs'
|
||
exports.IS_WINDOWS = process.platform === 'win32';
|
||
/**
|
||
* Custom implementation of readlink to ensure Windows junctions
|
||
* maintain trailing backslash for backward compatibility with Node.js < 24
|
||
*
|
||
* In Node.js 20, Windows junctions (directory symlinks) always returned paths
|
||
* with trailing backslashes. Node.js 24 removed this behavior, which breaks
|
||
* code that relied on this format for path operations.
|
||
*
|
||
* This implementation restores the Node 20 behavior by adding a trailing
|
||
* backslash to all junction results on Windows.
|
||
*/
|
||
function readlink(fsPath) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
const result = yield fs.promises.readlink(fsPath);
|
||
// On Windows, restore Node 20 behavior: add trailing backslash to all results
|
||
// since junctions on Windows are always directory links
|
||
if (exports.IS_WINDOWS && !result.endsWith('\\')) {
|
||
return `${result}\\`;
|
||
}
|
||
return result;
|
||
});
|
||
}
|
||
// See https://github.com/nodejs/node/blob/d0153aee367422d0858105abec186da4dff0a0c5/deps/uv/include/uv/win.h#L691
|
||
exports.UV_FS_O_EXLOCK = 0x10000000;
|
||
exports.READONLY = fs.constants.O_RDONLY;
|
||
function exists(fsPath) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
try {
|
||
yield (0, exports.stat)(fsPath);
|
||
}
|
||
catch (err) {
|
||
if (err.code === 'ENOENT') {
|
||
return false;
|
||
}
|
||
throw err;
|
||
}
|
||
return true;
|
||
});
|
||
}
|
||
function isDirectory(fsPath_1) {
|
||
return __awaiter(this, arguments, void 0, function* (fsPath, useStat = false) {
|
||
const stats = useStat ? yield (0, exports.stat)(fsPath) : yield (0, exports.lstat)(fsPath);
|
||
return stats.isDirectory();
|
||
});
|
||
}
|
||
/**
|
||
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
|
||
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
|
||
*/
|
||
function isRooted(p) {
|
||
p = normalizeSeparators(p);
|
||
if (!p) {
|
||
throw new Error('isRooted() parameter "p" cannot be empty');
|
||
}
|
||
if (exports.IS_WINDOWS) {
|
||
return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello
|
||
); // e.g. C: or C:\hello
|
||
}
|
||
return p.startsWith('/');
|
||
}
|
||
/**
|
||
* Best effort attempt to determine whether a file exists and is executable.
|
||
* @param filePath file path to check
|
||
* @param extensions additional file extensions to try
|
||
* @return if file exists and is executable, returns the file path. otherwise empty string.
|
||
*/
|
||
function tryGetExecutablePath(filePath, extensions) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
let stats = undefined;
|
||
try {
|
||
// test file exists
|
||
stats = yield (0, exports.stat)(filePath);
|
||
}
|
||
catch (err) {
|
||
if (err.code !== 'ENOENT') {
|
||
// eslint-disable-next-line no-console
|
||
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
|
||
}
|
||
}
|
||
if (stats && stats.isFile()) {
|
||
if (exports.IS_WINDOWS) {
|
||
// on Windows, test for valid extension
|
||
const upperExt = path.extname(filePath).toUpperCase();
|
||
if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) {
|
||
return filePath;
|
||
}
|
||
}
|
||
else {
|
||
if (isUnixExecutable(stats)) {
|
||
return filePath;
|
||
}
|
||
}
|
||
}
|
||
// try each extension
|
||
const originalFilePath = filePath;
|
||
for (const extension of extensions) {
|
||
filePath = originalFilePath + extension;
|
||
stats = undefined;
|
||
try {
|
||
stats = yield (0, exports.stat)(filePath);
|
||
}
|
||
catch (err) {
|
||
if (err.code !== 'ENOENT') {
|
||
// eslint-disable-next-line no-console
|
||
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
|
||
}
|
||
}
|
||
if (stats && stats.isFile()) {
|
||
if (exports.IS_WINDOWS) {
|
||
// preserve the case of the actual file (since an extension was appended)
|
||
try {
|
||
const directory = path.dirname(filePath);
|
||
const upperName = path.basename(filePath).toUpperCase();
|
||
for (const actualName of yield (0, exports.readdir)(directory)) {
|
||
if (upperName === actualName.toUpperCase()) {
|
||
filePath = path.join(directory, actualName);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
catch (err) {
|
||
// eslint-disable-next-line no-console
|
||
console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
|
||
}
|
||
return filePath;
|
||
}
|
||
else {
|
||
if (isUnixExecutable(stats)) {
|
||
return filePath;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return '';
|
||
});
|
||
}
|
||
function normalizeSeparators(p) {
|
||
p = p || '';
|
||
if (exports.IS_WINDOWS) {
|
||
// convert slashes on Windows
|
||
p = p.replace(/\//g, '\\');
|
||
// remove redundant slashes
|
||
return p.replace(/\\\\+/g, '\\');
|
||
}
|
||
// remove redundant slashes
|
||
return p.replace(/\/\/+/g, '/');
|
||
}
|
||
// on Mac/Linux, test the execute bit
|
||
// R W X R W X R W X
|
||
// 256 128 64 32 16 8 4 2 1
|
||
function isUnixExecutable(stats) {
|
||
return ((stats.mode & 1) > 0 ||
|
||
((stats.mode & 8) > 0 &&
|
||
process.getgid !== undefined &&
|
||
stats.gid === process.getgid()) ||
|
||
((stats.mode & 64) > 0 &&
|
||
process.getuid !== undefined &&
|
||
stats.uid === process.getuid()));
|
||
}
|
||
// Get the path of cmd.exe in windows
|
||
function getCmdPath() {
|
||
var _a;
|
||
return (_a = process.env['COMSPEC']) !== null && _a !== void 0 ? _a : `cmd.exe`;
|
||
}
|
||
//# sourceMappingURL=io-util.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 94994:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||
}
|
||
Object.defineProperty(o, k2, desc);
|
||
}) : (function(o, m, k, k2) {
|
||
if (k2 === undefined) k2 = k;
|
||
o[k2] = m[k];
|
||
}));
|
||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||
}) : function(o, v) {
|
||
o["default"] = v;
|
||
});
|
||
var __importStar = (this && this.__importStar) || (function () {
|
||
var ownKeys = function(o) {
|
||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||
var ar = [];
|
||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||
return ar;
|
||
};
|
||
return ownKeys(o);
|
||
};
|
||
return function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||
__setModuleDefault(result, mod);
|
||
return result;
|
||
};
|
||
})();
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.cp = cp;
|
||
exports.mv = mv;
|
||
exports.rmRF = rmRF;
|
||
exports.mkdirP = mkdirP;
|
||
exports.which = which;
|
||
exports.findInPath = findInPath;
|
||
const assert_1 = __nccwpck_require__(42613);
|
||
const path = __importStar(__nccwpck_require__(16928));
|
||
const ioUtil = __importStar(__nccwpck_require__(75207));
|
||
/**
|
||
* Copies a file or folder.
|
||
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
|
||
*
|
||
* @param source source path
|
||
* @param dest destination path
|
||
* @param options optional. See CopyOptions.
|
||
*/
|
||
function cp(source_1, dest_1) {
|
||
return __awaiter(this, arguments, void 0, function* (source, dest, options = {}) {
|
||
const { force, recursive, copySourceDirectory } = readCopyOptions(options);
|
||
const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
|
||
// Dest is an existing file, but not forcing
|
||
if (destStat && destStat.isFile() && !force) {
|
||
return;
|
||
}
|
||
// If dest is an existing directory, should copy inside.
|
||
const newDest = destStat && destStat.isDirectory() && copySourceDirectory
|
||
? path.join(dest, path.basename(source))
|
||
: dest;
|
||
if (!(yield ioUtil.exists(source))) {
|
||
throw new Error(`no such file or directory: ${source}`);
|
||
}
|
||
const sourceStat = yield ioUtil.stat(source);
|
||
if (sourceStat.isDirectory()) {
|
||
if (!recursive) {
|
||
throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`);
|
||
}
|
||
else {
|
||
yield cpDirRecursive(source, newDest, 0, force);
|
||
}
|
||
}
|
||
else {
|
||
if (path.relative(source, newDest) === '') {
|
||
// a file cannot be copied to itself
|
||
throw new Error(`'${newDest}' and '${source}' are the same file`);
|
||
}
|
||
yield copyFile(source, newDest, force);
|
||
}
|
||
});
|
||
}
|
||
/**
|
||
* Moves a path.
|
||
*
|
||
* @param source source path
|
||
* @param dest destination path
|
||
* @param options optional. See MoveOptions.
|
||
*/
|
||
function mv(source_1, dest_1) {
|
||
return __awaiter(this, arguments, void 0, function* (source, dest, options = {}) {
|
||
if (yield ioUtil.exists(dest)) {
|
||
let destExists = true;
|
||
if (yield ioUtil.isDirectory(dest)) {
|
||
// If dest is directory copy src into dest
|
||
dest = path.join(dest, path.basename(source));
|
||
destExists = yield ioUtil.exists(dest);
|
||
}
|
||
if (destExists) {
|
||
if (options.force == null || options.force) {
|
||
yield rmRF(dest);
|
||
}
|
||
else {
|
||
throw new Error('Destination already exists');
|
||
}
|
||
}
|
||
}
|
||
yield mkdirP(path.dirname(dest));
|
||
yield ioUtil.rename(source, dest);
|
||
});
|
||
}
|
||
/**
|
||
* Remove a path recursively with force
|
||
*
|
||
* @param inputPath path to remove
|
||
*/
|
||
function rmRF(inputPath) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
if (ioUtil.IS_WINDOWS) {
|
||
// Check for invalid characters
|
||
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
|
||
if (/[*"<>|]/.test(inputPath)) {
|
||
throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
|
||
}
|
||
}
|
||
try {
|
||
// note if path does not exist, error is silent
|
||
yield ioUtil.rm(inputPath, {
|
||
force: true,
|
||
maxRetries: 3,
|
||
recursive: true,
|
||
retryDelay: 300
|
||
});
|
||
}
|
||
catch (err) {
|
||
throw new Error(`File was unable to be removed ${err}`);
|
||
}
|
||
});
|
||
}
|
||
/**
|
||
* Make a directory. Creates the full path with folders in between
|
||
* Will throw if it fails
|
||
*
|
||
* @param fsPath path to create
|
||
* @returns Promise<void>
|
||
*/
|
||
function mkdirP(fsPath) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
(0, assert_1.ok)(fsPath, 'a path argument must be provided');
|
||
yield ioUtil.mkdir(fsPath, { recursive: true });
|
||
});
|
||
}
|
||
/**
|
||
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
|
||
* If you check and the tool does not exist, it will throw.
|
||
*
|
||
* @param tool name of the tool
|
||
* @param check whether to check if tool exists
|
||
* @returns Promise<string> path to tool
|
||
*/
|
||
function which(tool, check) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
if (!tool) {
|
||
throw new Error("parameter 'tool' is required");
|
||
}
|
||
// recursive when check=true
|
||
if (check) {
|
||
const result = yield which(tool, false);
|
||
if (!result) {
|
||
if (ioUtil.IS_WINDOWS) {
|
||
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`);
|
||
}
|
||
else {
|
||
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
const matches = yield findInPath(tool);
|
||
if (matches && matches.length > 0) {
|
||
return matches[0];
|
||
}
|
||
return '';
|
||
});
|
||
}
|
||
/**
|
||
* Returns a list of all occurrences of the given tool on the system path.
|
||
*
|
||
* @returns Promise<string[]> the paths of the tool
|
||
*/
|
||
function findInPath(tool) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
if (!tool) {
|
||
throw new Error("parameter 'tool' is required");
|
||
}
|
||
// build the list of extensions to try
|
||
const extensions = [];
|
||
if (ioUtil.IS_WINDOWS && process.env['PATHEXT']) {
|
||
for (const extension of process.env['PATHEXT'].split(path.delimiter)) {
|
||
if (extension) {
|
||
extensions.push(extension);
|
||
}
|
||
}
|
||
}
|
||
// if it's rooted, return it if exists. otherwise return empty.
|
||
if (ioUtil.isRooted(tool)) {
|
||
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
|
||
if (filePath) {
|
||
return [filePath];
|
||
}
|
||
return [];
|
||
}
|
||
// if any path separators, return empty
|
||
if (tool.includes(path.sep)) {
|
||
return [];
|
||
}
|
||
// build the list of directories
|
||
//
|
||
// Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
|
||
// it feels like we should not do this. Checking the current directory seems like more of a use
|
||
// case of a shell, and the which() function exposed by the toolkit should strive for consistency
|
||
// across platforms.
|
||
const directories = [];
|
||
if (process.env.PATH) {
|
||
for (const p of process.env.PATH.split(path.delimiter)) {
|
||
if (p) {
|
||
directories.push(p);
|
||
}
|
||
}
|
||
}
|
||
// find all matches
|
||
const matches = [];
|
||
for (const directory of directories) {
|
||
const filePath = yield ioUtil.tryGetExecutablePath(path.join(directory, tool), extensions);
|
||
if (filePath) {
|
||
matches.push(filePath);
|
||
}
|
||
}
|
||
return matches;
|
||
});
|
||
}
|
||
function readCopyOptions(options) {
|
||
const force = options.force == null ? true : options.force;
|
||
const recursive = Boolean(options.recursive);
|
||
const copySourceDirectory = options.copySourceDirectory == null
|
||
? true
|
||
: Boolean(options.copySourceDirectory);
|
||
return { force, recursive, copySourceDirectory };
|
||
}
|
||
function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
// Ensure there is not a run away recursive copy
|
||
if (currentDepth >= 255)
|
||
return;
|
||
currentDepth++;
|
||
yield mkdirP(destDir);
|
||
const files = yield ioUtil.readdir(sourceDir);
|
||
for (const fileName of files) {
|
||
const srcFile = `${sourceDir}/${fileName}`;
|
||
const destFile = `${destDir}/${fileName}`;
|
||
const srcFileStat = yield ioUtil.lstat(srcFile);
|
||
if (srcFileStat.isDirectory()) {
|
||
// Recurse
|
||
yield cpDirRecursive(srcFile, destFile, currentDepth, force);
|
||
}
|
||
else {
|
||
yield copyFile(srcFile, destFile, force);
|
||
}
|
||
}
|
||
// Change the mode for the newly created directory
|
||
yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode);
|
||
});
|
||
}
|
||
// Buffered file copy
|
||
function copyFile(srcFile, destFile, force) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) {
|
||
// unlink/re-link it
|
||
try {
|
||
yield ioUtil.lstat(destFile);
|
||
yield ioUtil.unlink(destFile);
|
||
}
|
||
catch (e) {
|
||
// Try to override file permission
|
||
if (e.code === 'EPERM') {
|
||
yield ioUtil.chmod(destFile, '0666');
|
||
yield ioUtil.unlink(destFile);
|
||
}
|
||
// other errors = it doesn't exist, no work to do
|
||
}
|
||
// Copy over symlink
|
||
const symlinkFull = yield ioUtil.readlink(srcFile);
|
||
yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? 'junction' : null);
|
||
}
|
||
else if (!(yield ioUtil.exists(destFile)) || force) {
|
||
yield ioUtil.copyFile(srcFile, destFile);
|
||
}
|
||
});
|
||
}
|
||
//# sourceMappingURL=io.js.map
|
||
|
||
/***/ }),
|
||
|
||
/***/ 68110:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
|
||
// Copyright (c) Microsoft Corporation.
|
||
// Licensed under the MIT license.
|
||
/// <reference path="../shims-public.d.ts" />
|
||
const listenersMap = new WeakMap();
|
||
const abortedMap = new WeakMap();
|
||
/**
|
||
* An aborter instance implements AbortSignal interface, can abort HTTP requests.
|
||
*
|
||
* - Call AbortSignal.none to create a new AbortSignal instance that cannot be cancelled.
|
||
* Use `AbortSignal.none` when you are required to pass a cancellation token but the operation
|
||
* cannot or will not ever be cancelled.
|
||
*
|
||
* @example
|
||
* Abort without timeout
|
||
* ```ts
|
||
* await doAsyncWork(AbortSignal.none);
|
||
* ```
|
||
*/
|
||
class AbortSignal {
|
||
constructor() {
|
||
/**
|
||
* onabort event listener.
|
||
*/
|
||
this.onabort = null;
|
||
listenersMap.set(this, []);
|
||
abortedMap.set(this, false);
|
||
}
|
||
/**
|
||
* Status of whether aborted or not.
|
||
*
|
||
* @readonly
|
||
*/
|
||
get aborted() {
|
||
if (!abortedMap.has(this)) {
|
||
throw new TypeError("Expected `this` to be an instance of AbortSignal.");
|
||
}
|
||
return abortedMap.get(this);
|
||
}
|
||
/**
|
||
* Creates a new AbortSignal instance that will never be aborted.
|
||
*
|
||
* @readonly
|
||
*/
|
||
static get none() {
|
||
return new AbortSignal();
|
||
}
|
||
/**
|
||
* Added new "abort" event listener, only support "abort" event.
|
||
*
|
||
* @param _type - Only support "abort" event
|
||
* @param listener - The listener to be added
|
||
*/
|
||
addEventListener(
|
||
// tslint:disable-next-line:variable-name
|
||
_type, listener) {
|
||
if (!listenersMap.has(this)) {
|
||
throw new TypeError("Expected `this` to be an instance of AbortSignal.");
|
||
}
|
||
const listeners = listenersMap.get(this);
|
||
listeners.push(listener);
|
||
}
|
||
/**
|
||
* Remove "abort" event listener, only support "abort" event.
|
||
*
|
||
* @param _type - Only support "abort" event
|
||
* @param listener - The listener to be removed
|
||
*/
|
||
removeEventListener(
|
||
// tslint:disable-next-line:variable-name
|
||
_type, listener) {
|
||
if (!listenersMap.has(this)) {
|
||
throw new TypeError("Expected `this` to be an instance of AbortSignal.");
|
||
}
|
||
const listeners = listenersMap.get(this);
|
||
const index = listeners.indexOf(listener);
|
||
if (index > -1) {
|
||
listeners.splice(index, 1);
|
||
}
|
||
}
|
||
/**
|
||
* Dispatches a synthetic event to the AbortSignal.
|
||
*/
|
||
dispatchEvent(_event) {
|
||
throw new Error("This is a stub dispatchEvent implementation that should not be used. It only exists for type-checking purposes.");
|
||
}
|
||
}
|
||
/**
|
||
* Helper to trigger an abort event immediately, the onabort and all abort event listeners will be triggered.
|
||
* Will try to trigger abort event for all linked AbortSignal nodes.
|
||
*
|
||
* - If there is a timeout, the timer will be cancelled.
|
||
* - If aborted is true, nothing will happen.
|
||
*
|
||
* @internal
|
||
*/
|
||
// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
|
||
function abortSignal(signal) {
|
||
if (signal.aborted) {
|
||
return;
|
||
}
|
||
if (signal.onabort) {
|
||
signal.onabort.call(signal);
|
||
}
|
||
const listeners = listenersMap.get(signal);
|
||
if (listeners) {
|
||
// Create a copy of listeners so mutations to the array
|
||
// (e.g. via removeListener calls) don't affect the listeners
|
||
// we invoke.
|
||
listeners.slice().forEach((listener) => {
|
||
listener.call(signal, { type: "abort" });
|
||
});
|
||
}
|
||
abortedMap.set(signal, true);
|
||
}
|
||
|
||
// Copyright (c) Microsoft Corporation.
|
||
/**
|
||
* This error is thrown when an asynchronous operation has been aborted.
|
||
* Check for this error by testing the `name` that the name property of the
|
||
* error matches `"AbortError"`.
|
||
*
|
||
* @example
|
||
* ```ts
|
||
* const controller = new AbortController();
|
||
* controller.abort();
|
||
* try {
|
||
* doAsyncWork(controller.signal)
|
||
* } catch (e) {
|
||
* if (e.name === 'AbortError') {
|
||
* // handle abort error here.
|
||
* }
|
||
* }
|
||
* ```
|
||
*/
|
||
class AbortError extends Error {
|
||
constructor(message) {
|
||
super(message);
|
||
this.name = "AbortError";
|
||
}
|
||
}
|
||
/**
|
||
* An AbortController provides an AbortSignal and the associated controls to signal
|
||
* that an asynchronous operation should be aborted.
|
||
*
|
||
* @example
|
||
* Abort an operation when another event fires
|
||
* ```ts
|
||
* const controller = new AbortController();
|
||
* const signal = controller.signal;
|
||
* doAsyncWork(signal);
|
||
* button.addEventListener('click', () => controller.abort());
|
||
* ```
|
||
*
|
||
* @example
|
||
* Share aborter cross multiple operations in 30s
|
||
* ```ts
|
||
* // Upload the same data to 2 different data centers at the same time,
|
||
* // abort another when any of them is finished
|
||
* const controller = AbortController.withTimeout(30 * 1000);
|
||
* doAsyncWork(controller.signal).then(controller.abort);
|
||
* doAsyncWork(controller.signal).then(controller.abort);
|
||
*```
|
||
*
|
||
* @example
|
||
* Cascaded aborting
|
||
* ```ts
|
||
* // All operations can't take more than 30 seconds
|
||
* const aborter = Aborter.timeout(30 * 1000);
|
||
*
|
||
* // Following 2 operations can't take more than 25 seconds
|
||
* await doAsyncWork(aborter.withTimeout(25 * 1000));
|
||
* await doAsyncWork(aborter.withTimeout(25 * 1000));
|
||
* ```
|
||
*/
|
||
class AbortController {
|
||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||
constructor(parentSignals) {
|
||
this._signal = new AbortSignal();
|
||
if (!parentSignals) {
|
||
return;
|
||
}
|
||
// coerce parentSignals into an array
|
||
if (!Array.isArray(parentSignals)) {
|
||
// eslint-disable-next-line prefer-rest-params
|
||
parentSignals = arguments;
|
||
}
|
||
for (const parentSignal of parentSignals) {
|
||
// if the parent signal has already had abort() called,
|
||
// then call abort on this signal as well.
|
||
if (parentSignal.aborted) {
|
||
this.abort();
|
||
}
|
||
else {
|
||
// when the parent signal aborts, this signal should as well.
|
||
parentSignal.addEventListener("abort", () => {
|
||
this.abort();
|
||
});
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* The AbortSignal associated with this controller that will signal aborted
|
||
* when the abort method is called on this controller.
|
||
*
|
||
* @readonly
|
||
*/
|
||
get signal() {
|
||
return this._signal;
|
||
}
|
||
/**
|
||
* Signal that any operations passed this controller's associated abort signal
|
||
* to cancel any remaining work and throw an `AbortError`.
|
||
*/
|
||
abort() {
|
||
abortSignal(this._signal);
|
||
}
|
||
/**
|
||
* Creates a new AbortSignal instance that will abort after the provided ms.
|
||
* @param ms - Elapsed time in milliseconds to trigger an abort.
|
||
*/
|
||
static timeout(ms) {
|
||
const signal = new AbortSignal();
|
||
const timer = setTimeout(abortSignal, ms, signal);
|
||
// Prevent the active Timer from keeping the Node.js event loop active.
|
||
if (typeof timer.unref === "function") {
|
||
timer.unref();
|
||
}
|
||
return signal;
|
||
}
|
||
}
|
||
|
||
exports.AbortController = AbortController;
|
||
exports.AbortError = AbortError;
|
||
exports.AbortSignal = AbortSignal;
|
||
//# sourceMappingURL=index.js.map
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 37889:
|
||
/***/ (function(__unused_webpack_module, exports) {
|
||
|
||
"use strict";
|
||
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.ClientStreamingCall = void 0;
|
||
/**
|
||
* A client streaming RPC call. This means that the clients sends 0, 1, or
|
||
* more messages to the server, and the server replies with exactly one
|
||
* message.
|
||
*/
|
||
class ClientStreamingCall {
|
||
constructor(method, requestHeaders, request, headers, response, status, trailers) {
|
||
this.method = method;
|
||
this.requestHeaders = requestHeaders;
|
||
this.requests = request;
|
||
this.headers = headers;
|
||
this.response = response;
|
||
this.status = status;
|
||
this.trailers = trailers;
|
||
}
|
||
/**
|
||
* Instead of awaiting the response status and trailers, you can
|
||
* just as well await this call itself to receive the server outcome.
|
||
* Note that it may still be valid to send more request messages.
|
||
*/
|
||
then(onfulfilled, onrejected) {
|
||
return this.promiseFinished().then(value => onfulfilled ? Promise.resolve(onfulfilled(value)) : value, reason => onrejected ? Promise.resolve(onrejected(reason)) : Promise.reject(reason));
|
||
}
|
||
promiseFinished() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
let [headers, response, status, trailers] = yield Promise.all([this.headers, this.response, this.status, this.trailers]);
|
||
return {
|
||
method: this.method,
|
||
requestHeaders: this.requestHeaders,
|
||
headers,
|
||
response,
|
||
status,
|
||
trailers
|
||
};
|
||
});
|
||
}
|
||
}
|
||
exports.ClientStreamingCall = ClientStreamingCall;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 71409:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.Deferred = exports.DeferredState = void 0;
|
||
var DeferredState;
|
||
(function (DeferredState) {
|
||
DeferredState[DeferredState["PENDING"] = 0] = "PENDING";
|
||
DeferredState[DeferredState["REJECTED"] = 1] = "REJECTED";
|
||
DeferredState[DeferredState["RESOLVED"] = 2] = "RESOLVED";
|
||
})(DeferredState = exports.DeferredState || (exports.DeferredState = {}));
|
||
/**
|
||
* A deferred promise. This is a "controller" for a promise, which lets you
|
||
* pass a promise around and reject or resolve it from the outside.
|
||
*
|
||
* Warning: This class is to be used with care. Using it can make code very
|
||
* difficult to read. It is intended for use in library code that exposes
|
||
* promises, not for regular business logic.
|
||
*/
|
||
class Deferred {
|
||
/**
|
||
* @param preventUnhandledRejectionWarning - prevents the warning
|
||
* "Unhandled Promise rejection" by adding a noop rejection handler.
|
||
* Working with calls returned from the runtime-rpc package in an
|
||
* async function usually means awaiting one call property after
|
||
* the other. This means that the "status" is not being awaited when
|
||
* an earlier await for the "headers" is rejected. This causes the
|
||
* "unhandled promise reject" warning. A more correct behaviour for
|
||
* calls might be to become aware whether at least one of the
|
||
* promises is handled and swallow the rejection warning for the
|
||
* others.
|
||
*/
|
||
constructor(preventUnhandledRejectionWarning = true) {
|
||
this._state = DeferredState.PENDING;
|
||
this._promise = new Promise((resolve, reject) => {
|
||
this._resolve = resolve;
|
||
this._reject = reject;
|
||
});
|
||
if (preventUnhandledRejectionWarning) {
|
||
this._promise.catch(_ => { });
|
||
}
|
||
}
|
||
/**
|
||
* Get the current state of the promise.
|
||
*/
|
||
get state() {
|
||
return this._state;
|
||
}
|
||
/**
|
||
* Get the deferred promise.
|
||
*/
|
||
get promise() {
|
||
return this._promise;
|
||
}
|
||
/**
|
||
* Resolve the promise. Throws if the promise is already resolved or rejected.
|
||
*/
|
||
resolve(value) {
|
||
if (this.state !== DeferredState.PENDING)
|
||
throw new Error(`cannot resolve ${DeferredState[this.state].toLowerCase()}`);
|
||
this._resolve(value);
|
||
this._state = DeferredState.RESOLVED;
|
||
}
|
||
/**
|
||
* Reject the promise. Throws if the promise is already resolved or rejected.
|
||
*/
|
||
reject(reason) {
|
||
if (this.state !== DeferredState.PENDING)
|
||
throw new Error(`cannot reject ${DeferredState[this.state].toLowerCase()}`);
|
||
this._reject(reason);
|
||
this._state = DeferredState.REJECTED;
|
||
}
|
||
/**
|
||
* Resolve the promise. Ignore if not pending.
|
||
*/
|
||
resolvePending(val) {
|
||
if (this._state === DeferredState.PENDING)
|
||
this.resolve(val);
|
||
}
|
||
/**
|
||
* Reject the promise. Ignore if not pending.
|
||
*/
|
||
rejectPending(reason) {
|
||
if (this._state === DeferredState.PENDING)
|
||
this.reject(reason);
|
||
}
|
||
}
|
||
exports.Deferred = Deferred;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 36826:
|
||
/***/ (function(__unused_webpack_module, exports) {
|
||
|
||
"use strict";
|
||
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.DuplexStreamingCall = void 0;
|
||
/**
|
||
* A duplex streaming RPC call. This means that the clients sends an
|
||
* arbitrary amount of messages to the server, while at the same time,
|
||
* the server sends an arbitrary amount of messages to the client.
|
||
*/
|
||
class DuplexStreamingCall {
|
||
constructor(method, requestHeaders, request, headers, response, status, trailers) {
|
||
this.method = method;
|
||
this.requestHeaders = requestHeaders;
|
||
this.requests = request;
|
||
this.headers = headers;
|
||
this.responses = response;
|
||
this.status = status;
|
||
this.trailers = trailers;
|
||
}
|
||
/**
|
||
* Instead of awaiting the response status and trailers, you can
|
||
* just as well await this call itself to receive the server outcome.
|
||
* Note that it may still be valid to send more request messages.
|
||
*/
|
||
then(onfulfilled, onrejected) {
|
||
return this.promiseFinished().then(value => onfulfilled ? Promise.resolve(onfulfilled(value)) : value, reason => onrejected ? Promise.resolve(onrejected(reason)) : Promise.reject(reason));
|
||
}
|
||
promiseFinished() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
let [headers, status, trailers] = yield Promise.all([this.headers, this.status, this.trailers]);
|
||
return {
|
||
method: this.method,
|
||
requestHeaders: this.requestHeaders,
|
||
headers,
|
||
status,
|
||
trailers,
|
||
};
|
||
});
|
||
}
|
||
}
|
||
exports.DuplexStreamingCall = DuplexStreamingCall;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 44420:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
// Public API of the rpc runtime.
|
||
// Note: we do not use `export * from ...` to help tree shakers,
|
||
// webpack verbose output hints that this should be useful
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
var service_type_1 = __nccwpck_require__(56892);
|
||
Object.defineProperty(exports, "ServiceType", ({ enumerable: true, get: function () { return service_type_1.ServiceType; } }));
|
||
var reflection_info_1 = __nccwpck_require__(62496);
|
||
Object.defineProperty(exports, "readMethodOptions", ({ enumerable: true, get: function () { return reflection_info_1.readMethodOptions; } }));
|
||
Object.defineProperty(exports, "readMethodOption", ({ enumerable: true, get: function () { return reflection_info_1.readMethodOption; } }));
|
||
Object.defineProperty(exports, "readServiceOption", ({ enumerable: true, get: function () { return reflection_info_1.readServiceOption; } }));
|
||
var rpc_error_1 = __nccwpck_require__(78636);
|
||
Object.defineProperty(exports, "RpcError", ({ enumerable: true, get: function () { return rpc_error_1.RpcError; } }));
|
||
var rpc_options_1 = __nccwpck_require__(28576);
|
||
Object.defineProperty(exports, "mergeRpcOptions", ({ enumerable: true, get: function () { return rpc_options_1.mergeRpcOptions; } }));
|
||
var rpc_output_stream_1 = __nccwpck_require__(72726);
|
||
Object.defineProperty(exports, "RpcOutputStreamController", ({ enumerable: true, get: function () { return rpc_output_stream_1.RpcOutputStreamController; } }));
|
||
var test_transport_1 = __nccwpck_require__(79122);
|
||
Object.defineProperty(exports, "TestTransport", ({ enumerable: true, get: function () { return test_transport_1.TestTransport; } }));
|
||
var deferred_1 = __nccwpck_require__(71409);
|
||
Object.defineProperty(exports, "Deferred", ({ enumerable: true, get: function () { return deferred_1.Deferred; } }));
|
||
Object.defineProperty(exports, "DeferredState", ({ enumerable: true, get: function () { return deferred_1.DeferredState; } }));
|
||
var duplex_streaming_call_1 = __nccwpck_require__(36826);
|
||
Object.defineProperty(exports, "DuplexStreamingCall", ({ enumerable: true, get: function () { return duplex_streaming_call_1.DuplexStreamingCall; } }));
|
||
var client_streaming_call_1 = __nccwpck_require__(37889);
|
||
Object.defineProperty(exports, "ClientStreamingCall", ({ enumerable: true, get: function () { return client_streaming_call_1.ClientStreamingCall; } }));
|
||
var server_streaming_call_1 = __nccwpck_require__(46173);
|
||
Object.defineProperty(exports, "ServerStreamingCall", ({ enumerable: true, get: function () { return server_streaming_call_1.ServerStreamingCall; } }));
|
||
var unary_call_1 = __nccwpck_require__(29288);
|
||
Object.defineProperty(exports, "UnaryCall", ({ enumerable: true, get: function () { return unary_call_1.UnaryCall; } }));
|
||
var rpc_interceptor_1 = __nccwpck_require__(52849);
|
||
Object.defineProperty(exports, "stackIntercept", ({ enumerable: true, get: function () { return rpc_interceptor_1.stackIntercept; } }));
|
||
Object.defineProperty(exports, "stackDuplexStreamingInterceptors", ({ enumerable: true, get: function () { return rpc_interceptor_1.stackDuplexStreamingInterceptors; } }));
|
||
Object.defineProperty(exports, "stackClientStreamingInterceptors", ({ enumerable: true, get: function () { return rpc_interceptor_1.stackClientStreamingInterceptors; } }));
|
||
Object.defineProperty(exports, "stackServerStreamingInterceptors", ({ enumerable: true, get: function () { return rpc_interceptor_1.stackServerStreamingInterceptors; } }));
|
||
Object.defineProperty(exports, "stackUnaryInterceptors", ({ enumerable: true, get: function () { return rpc_interceptor_1.stackUnaryInterceptors; } }));
|
||
var server_call_context_1 = __nccwpck_require__(43352);
|
||
Object.defineProperty(exports, "ServerCallContextController", ({ enumerable: true, get: function () { return server_call_context_1.ServerCallContextController; } }));
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 62496:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.readServiceOption = exports.readMethodOption = exports.readMethodOptions = exports.normalizeMethodInfo = void 0;
|
||
const runtime_1 = __nccwpck_require__(68886);
|
||
/**
|
||
* Turns PartialMethodInfo into MethodInfo.
|
||
*/
|
||
function normalizeMethodInfo(method, service) {
|
||
var _a, _b, _c;
|
||
let m = method;
|
||
m.service = service;
|
||
m.localName = (_a = m.localName) !== null && _a !== void 0 ? _a : runtime_1.lowerCamelCase(m.name);
|
||
// noinspection PointlessBooleanExpressionJS
|
||
m.serverStreaming = !!m.serverStreaming;
|
||
// noinspection PointlessBooleanExpressionJS
|
||
m.clientStreaming = !!m.clientStreaming;
|
||
m.options = (_b = m.options) !== null && _b !== void 0 ? _b : {};
|
||
m.idempotency = (_c = m.idempotency) !== null && _c !== void 0 ? _c : undefined;
|
||
return m;
|
||
}
|
||
exports.normalizeMethodInfo = normalizeMethodInfo;
|
||
/**
|
||
* Read custom method options from a generated service client.
|
||
*
|
||
* @deprecated use readMethodOption()
|
||
*/
|
||
function readMethodOptions(service, methodName, extensionName, extensionType) {
|
||
var _a;
|
||
const options = (_a = service.methods.find((m, i) => m.localName === methodName || i === methodName)) === null || _a === void 0 ? void 0 : _a.options;
|
||
return options && options[extensionName] ? extensionType.fromJson(options[extensionName]) : undefined;
|
||
}
|
||
exports.readMethodOptions = readMethodOptions;
|
||
function readMethodOption(service, methodName, extensionName, extensionType) {
|
||
var _a;
|
||
const options = (_a = service.methods.find((m, i) => m.localName === methodName || i === methodName)) === null || _a === void 0 ? void 0 : _a.options;
|
||
if (!options) {
|
||
return undefined;
|
||
}
|
||
const optionVal = options[extensionName];
|
||
if (optionVal === undefined) {
|
||
return optionVal;
|
||
}
|
||
return extensionType ? extensionType.fromJson(optionVal) : optionVal;
|
||
}
|
||
exports.readMethodOption = readMethodOption;
|
||
function readServiceOption(service, extensionName, extensionType) {
|
||
const options = service.options;
|
||
if (!options) {
|
||
return undefined;
|
||
}
|
||
const optionVal = options[extensionName];
|
||
if (optionVal === undefined) {
|
||
return optionVal;
|
||
}
|
||
return extensionType ? extensionType.fromJson(optionVal) : optionVal;
|
||
}
|
||
exports.readServiceOption = readServiceOption;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 78636:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.RpcError = void 0;
|
||
/**
|
||
* An error that occurred while calling a RPC method.
|
||
*/
|
||
class RpcError extends Error {
|
||
constructor(message, code = 'UNKNOWN', meta) {
|
||
super(message);
|
||
this.name = 'RpcError';
|
||
// see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#example
|
||
Object.setPrototypeOf(this, new.target.prototype);
|
||
this.code = code;
|
||
this.meta = meta !== null && meta !== void 0 ? meta : {};
|
||
}
|
||
toString() {
|
||
const l = [this.name + ': ' + this.message];
|
||
if (this.code) {
|
||
l.push('');
|
||
l.push('Code: ' + this.code);
|
||
}
|
||
if (this.serviceName && this.methodName) {
|
||
l.push('Method: ' + this.serviceName + '/' + this.methodName);
|
||
}
|
||
let m = Object.entries(this.meta);
|
||
if (m.length) {
|
||
l.push('');
|
||
l.push('Meta:');
|
||
for (let [k, v] of m) {
|
||
l.push(` ${k}: ${v}`);
|
||
}
|
||
}
|
||
return l.join('\n');
|
||
}
|
||
}
|
||
exports.RpcError = RpcError;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 52849:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.stackDuplexStreamingInterceptors = exports.stackClientStreamingInterceptors = exports.stackServerStreamingInterceptors = exports.stackUnaryInterceptors = exports.stackIntercept = void 0;
|
||
const runtime_1 = __nccwpck_require__(68886);
|
||
/**
|
||
* Creates a "stack" of of all interceptors specified in the given `RpcOptions`.
|
||
* Used by generated client implementations.
|
||
* @internal
|
||
*/
|
||
function stackIntercept(kind, transport, method, options, input) {
|
||
var _a, _b, _c, _d;
|
||
if (kind == "unary") {
|
||
let tail = (mtd, inp, opt) => transport.unary(mtd, inp, opt);
|
||
for (const curr of ((_a = options.interceptors) !== null && _a !== void 0 ? _a : []).filter(i => i.interceptUnary).reverse()) {
|
||
const next = tail;
|
||
tail = (mtd, inp, opt) => curr.interceptUnary(next, mtd, inp, opt);
|
||
}
|
||
return tail(method, input, options);
|
||
}
|
||
if (kind == "serverStreaming") {
|
||
let tail = (mtd, inp, opt) => transport.serverStreaming(mtd, inp, opt);
|
||
for (const curr of ((_b = options.interceptors) !== null && _b !== void 0 ? _b : []).filter(i => i.interceptServerStreaming).reverse()) {
|
||
const next = tail;
|
||
tail = (mtd, inp, opt) => curr.interceptServerStreaming(next, mtd, inp, opt);
|
||
}
|
||
return tail(method, input, options);
|
||
}
|
||
if (kind == "clientStreaming") {
|
||
let tail = (mtd, opt) => transport.clientStreaming(mtd, opt);
|
||
for (const curr of ((_c = options.interceptors) !== null && _c !== void 0 ? _c : []).filter(i => i.interceptClientStreaming).reverse()) {
|
||
const next = tail;
|
||
tail = (mtd, opt) => curr.interceptClientStreaming(next, mtd, opt);
|
||
}
|
||
return tail(method, options);
|
||
}
|
||
if (kind == "duplex") {
|
||
let tail = (mtd, opt) => transport.duplex(mtd, opt);
|
||
for (const curr of ((_d = options.interceptors) !== null && _d !== void 0 ? _d : []).filter(i => i.interceptDuplex).reverse()) {
|
||
const next = tail;
|
||
tail = (mtd, opt) => curr.interceptDuplex(next, mtd, opt);
|
||
}
|
||
return tail(method, options);
|
||
}
|
||
runtime_1.assertNever(kind);
|
||
}
|
||
exports.stackIntercept = stackIntercept;
|
||
/**
|
||
* @deprecated replaced by `stackIntercept()`, still here to support older generated code
|
||
*/
|
||
function stackUnaryInterceptors(transport, method, input, options) {
|
||
return stackIntercept("unary", transport, method, options, input);
|
||
}
|
||
exports.stackUnaryInterceptors = stackUnaryInterceptors;
|
||
/**
|
||
* @deprecated replaced by `stackIntercept()`, still here to support older generated code
|
||
*/
|
||
function stackServerStreamingInterceptors(transport, method, input, options) {
|
||
return stackIntercept("serverStreaming", transport, method, options, input);
|
||
}
|
||
exports.stackServerStreamingInterceptors = stackServerStreamingInterceptors;
|
||
/**
|
||
* @deprecated replaced by `stackIntercept()`, still here to support older generated code
|
||
*/
|
||
function stackClientStreamingInterceptors(transport, method, options) {
|
||
return stackIntercept("clientStreaming", transport, method, options);
|
||
}
|
||
exports.stackClientStreamingInterceptors = stackClientStreamingInterceptors;
|
||
/**
|
||
* @deprecated replaced by `stackIntercept()`, still here to support older generated code
|
||
*/
|
||
function stackDuplexStreamingInterceptors(transport, method, options) {
|
||
return stackIntercept("duplex", transport, method, options);
|
||
}
|
||
exports.stackDuplexStreamingInterceptors = stackDuplexStreamingInterceptors;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 28576:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.mergeRpcOptions = void 0;
|
||
const runtime_1 = __nccwpck_require__(68886);
|
||
/**
|
||
* Merges custom RPC options with defaults. Returns a new instance and keeps
|
||
* the "defaults" and the "options" unmodified.
|
||
*
|
||
* Merges `RpcMetadata` "meta", overwriting values from "defaults" with
|
||
* values from "options". Does not append values to existing entries.
|
||
*
|
||
* Merges "jsonOptions", including "jsonOptions.typeRegistry", by creating
|
||
* a new array that contains types from "options.jsonOptions.typeRegistry"
|
||
* first, then types from "defaults.jsonOptions.typeRegistry".
|
||
*
|
||
* Merges "binaryOptions".
|
||
*
|
||
* Merges "interceptors" by creating a new array that contains interceptors
|
||
* from "defaults" first, then interceptors from "options".
|
||
*
|
||
* Works with objects that extend `RpcOptions`, but only if the added
|
||
* properties are of type Date, primitive like string, boolean, or Array
|
||
* of primitives. If you have other property types, you have to merge them
|
||
* yourself.
|
||
*/
|
||
function mergeRpcOptions(defaults, options) {
|
||
if (!options)
|
||
return defaults;
|
||
let o = {};
|
||
copy(defaults, o);
|
||
copy(options, o);
|
||
for (let key of Object.keys(options)) {
|
||
let val = options[key];
|
||
switch (key) {
|
||
case "jsonOptions":
|
||
o.jsonOptions = runtime_1.mergeJsonOptions(defaults.jsonOptions, o.jsonOptions);
|
||
break;
|
||
case "binaryOptions":
|
||
o.binaryOptions = runtime_1.mergeBinaryOptions(defaults.binaryOptions, o.binaryOptions);
|
||
break;
|
||
case "meta":
|
||
o.meta = {};
|
||
copy(defaults.meta, o.meta);
|
||
copy(options.meta, o.meta);
|
||
break;
|
||
case "interceptors":
|
||
o.interceptors = defaults.interceptors ? defaults.interceptors.concat(val) : val.concat();
|
||
break;
|
||
}
|
||
}
|
||
return o;
|
||
}
|
||
exports.mergeRpcOptions = mergeRpcOptions;
|
||
function copy(a, into) {
|
||
if (!a)
|
||
return;
|
||
let c = into;
|
||
for (let [k, v] of Object.entries(a)) {
|
||
if (v instanceof Date)
|
||
c[k] = new Date(v.getTime());
|
||
else if (Array.isArray(v))
|
||
c[k] = v.concat();
|
||
else
|
||
c[k] = v;
|
||
}
|
||
}
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 72726:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.RpcOutputStreamController = void 0;
|
||
const deferred_1 = __nccwpck_require__(71409);
|
||
const runtime_1 = __nccwpck_require__(68886);
|
||
/**
|
||
* A `RpcOutputStream` that you control.
|
||
*/
|
||
class RpcOutputStreamController {
|
||
constructor() {
|
||
this._lis = {
|
||
nxt: [],
|
||
msg: [],
|
||
err: [],
|
||
cmp: [],
|
||
};
|
||
this._closed = false;
|
||
// --- RpcOutputStream async iterator API
|
||
// iterator state.
|
||
// is undefined when no iterator has been acquired yet.
|
||
this._itState = { q: [] };
|
||
}
|
||
// --- RpcOutputStream callback API
|
||
onNext(callback) {
|
||
return this.addLis(callback, this._lis.nxt);
|
||
}
|
||
onMessage(callback) {
|
||
return this.addLis(callback, this._lis.msg);
|
||
}
|
||
onError(callback) {
|
||
return this.addLis(callback, this._lis.err);
|
||
}
|
||
onComplete(callback) {
|
||
return this.addLis(callback, this._lis.cmp);
|
||
}
|
||
addLis(callback, list) {
|
||
list.push(callback);
|
||
return () => {
|
||
let i = list.indexOf(callback);
|
||
if (i >= 0)
|
||
list.splice(i, 1);
|
||
};
|
||
}
|
||
// remove all listeners
|
||
clearLis() {
|
||
for (let l of Object.values(this._lis))
|
||
l.splice(0, l.length);
|
||
}
|
||
// --- Controller API
|
||
/**
|
||
* Is this stream already closed by a completion or error?
|
||
*/
|
||
get closed() {
|
||
return this._closed !== false;
|
||
}
|
||
/**
|
||
* Emit message, close with error, or close successfully, but only one
|
||
* at a time.
|
||
* Can be used to wrap a stream by using the other stream's `onNext`.
|
||
*/
|
||
notifyNext(message, error, complete) {
|
||
runtime_1.assert((message ? 1 : 0) + (error ? 1 : 0) + (complete ? 1 : 0) <= 1, 'only one emission at a time');
|
||
if (message)
|
||
this.notifyMessage(message);
|
||
if (error)
|
||
this.notifyError(error);
|
||
if (complete)
|
||
this.notifyComplete();
|
||
}
|
||
/**
|
||
* Emits a new message. Throws if stream is closed.
|
||
*
|
||
* Triggers onNext and onMessage callbacks.
|
||
*/
|
||
notifyMessage(message) {
|
||
runtime_1.assert(!this.closed, 'stream is closed');
|
||
this.pushIt({ value: message, done: false });
|
||
this._lis.msg.forEach(l => l(message));
|
||
this._lis.nxt.forEach(l => l(message, undefined, false));
|
||
}
|
||
/**
|
||
* Closes the stream with an error. Throws if stream is closed.
|
||
*
|
||
* Triggers onNext and onError callbacks.
|
||
*/
|
||
notifyError(error) {
|
||
runtime_1.assert(!this.closed, 'stream is closed');
|
||
this._closed = error;
|
||
this.pushIt(error);
|
||
this._lis.err.forEach(l => l(error));
|
||
this._lis.nxt.forEach(l => l(undefined, error, false));
|
||
this.clearLis();
|
||
}
|
||
/**
|
||
* Closes the stream successfully. Throws if stream is closed.
|
||
*
|
||
* Triggers onNext and onComplete callbacks.
|
||
*/
|
||
notifyComplete() {
|
||
runtime_1.assert(!this.closed, 'stream is closed');
|
||
this._closed = true;
|
||
this.pushIt({ value: null, done: true });
|
||
this._lis.cmp.forEach(l => l());
|
||
this._lis.nxt.forEach(l => l(undefined, undefined, true));
|
||
this.clearLis();
|
||
}
|
||
/**
|
||
* Creates an async iterator (that can be used with `for await {...}`)
|
||
* to consume the stream.
|
||
*
|
||
* Some things to note:
|
||
* - If an error occurs, the `for await` will throw it.
|
||
* - If an error occurred before the `for await` was started, `for await`
|
||
* will re-throw it.
|
||
* - If the stream is already complete, the `for await` will be empty.
|
||
* - If your `for await` consumes slower than the stream produces,
|
||
* for example because you are relaying messages in a slow operation,
|
||
* messages are queued.
|
||
*/
|
||
[Symbol.asyncIterator]() {
|
||
// if we are closed, we are definitely not receiving any more messages.
|
||
// but we can't let the iterator get stuck. we want to either:
|
||
// a) finish the new iterator immediately, because we are completed
|
||
// b) reject the new iterator, because we errored
|
||
if (this._closed === true)
|
||
this.pushIt({ value: null, done: true });
|
||
else if (this._closed !== false)
|
||
this.pushIt(this._closed);
|
||
// the async iterator
|
||
return {
|
||
next: () => {
|
||
let state = this._itState;
|
||
runtime_1.assert(state, "bad state"); // if we don't have a state here, code is broken
|
||
// there should be no pending result.
|
||
// did the consumer call next() before we resolved our previous result promise?
|
||
runtime_1.assert(!state.p, "iterator contract broken");
|
||
// did we produce faster than the iterator consumed?
|
||
// return the oldest result from the queue.
|
||
let first = state.q.shift();
|
||
if (first)
|
||
return ("value" in first) ? Promise.resolve(first) : Promise.reject(first);
|
||
// we have no result ATM, but we promise one.
|
||
// as soon as we have a result, we must resolve promise.
|
||
state.p = new deferred_1.Deferred();
|
||
return state.p.promise;
|
||
},
|
||
};
|
||
}
|
||
// "push" a new iterator result.
|
||
// this either resolves a pending promise, or enqueues the result.
|
||
pushIt(result) {
|
||
let state = this._itState;
|
||
// is the consumer waiting for us?
|
||
if (state.p) {
|
||
// yes, consumer is waiting for this promise.
|
||
const p = state.p;
|
||
runtime_1.assert(p.state == deferred_1.DeferredState.PENDING, "iterator contract broken");
|
||
// resolve the promise
|
||
("value" in result) ? p.resolve(result) : p.reject(result);
|
||
// must cleanup, otherwise iterator.next() would pick it up again.
|
||
delete state.p;
|
||
}
|
||
else {
|
||
// we are producing faster than the iterator consumes.
|
||
// push result onto queue.
|
||
state.q.push(result);
|
||
}
|
||
}
|
||
}
|
||
exports.RpcOutputStreamController = RpcOutputStreamController;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 43352:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.ServerCallContextController = void 0;
|
||
class ServerCallContextController {
|
||
constructor(method, headers, deadline, sendResponseHeadersFn, defaultStatus = { code: 'OK', detail: '' }) {
|
||
this._cancelled = false;
|
||
this._listeners = [];
|
||
this.method = method;
|
||
this.headers = headers;
|
||
this.deadline = deadline;
|
||
this.trailers = {};
|
||
this._sendRH = sendResponseHeadersFn;
|
||
this.status = defaultStatus;
|
||
}
|
||
/**
|
||
* Set the call cancelled.
|
||
*
|
||
* Invokes all callbacks registered with onCancel() and
|
||
* sets `cancelled = true`.
|
||
*/
|
||
notifyCancelled() {
|
||
if (!this._cancelled) {
|
||
this._cancelled = true;
|
||
for (let l of this._listeners) {
|
||
l();
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Send response headers.
|
||
*/
|
||
sendResponseHeaders(data) {
|
||
this._sendRH(data);
|
||
}
|
||
/**
|
||
* Is the call cancelled?
|
||
*
|
||
* When the client closes the connection before the server
|
||
* is done, the call is cancelled.
|
||
*
|
||
* If you want to cancel a request on the server, throw a
|
||
* RpcError with the CANCELLED status code.
|
||
*/
|
||
get cancelled() {
|
||
return this._cancelled;
|
||
}
|
||
/**
|
||
* Add a callback for cancellation.
|
||
*/
|
||
onCancel(callback) {
|
||
const l = this._listeners;
|
||
l.push(callback);
|
||
return () => {
|
||
let i = l.indexOf(callback);
|
||
if (i >= 0)
|
||
l.splice(i, 1);
|
||
};
|
||
}
|
||
}
|
||
exports.ServerCallContextController = ServerCallContextController;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 46173:
|
||
/***/ (function(__unused_webpack_module, exports) {
|
||
|
||
"use strict";
|
||
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.ServerStreamingCall = void 0;
|
||
/**
|
||
* A server streaming RPC call. The client provides exactly one input message
|
||
* but the server may respond with 0, 1, or more messages.
|
||
*/
|
||
class ServerStreamingCall {
|
||
constructor(method, requestHeaders, request, headers, response, status, trailers) {
|
||
this.method = method;
|
||
this.requestHeaders = requestHeaders;
|
||
this.request = request;
|
||
this.headers = headers;
|
||
this.responses = response;
|
||
this.status = status;
|
||
this.trailers = trailers;
|
||
}
|
||
/**
|
||
* Instead of awaiting the response status and trailers, you can
|
||
* just as well await this call itself to receive the server outcome.
|
||
* You should first setup some listeners to the `request` to
|
||
* see the actual messages the server replied with.
|
||
*/
|
||
then(onfulfilled, onrejected) {
|
||
return this.promiseFinished().then(value => onfulfilled ? Promise.resolve(onfulfilled(value)) : value, reason => onrejected ? Promise.resolve(onrejected(reason)) : Promise.reject(reason));
|
||
}
|
||
promiseFinished() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
let [headers, status, trailers] = yield Promise.all([this.headers, this.status, this.trailers]);
|
||
return {
|
||
method: this.method,
|
||
requestHeaders: this.requestHeaders,
|
||
request: this.request,
|
||
headers,
|
||
status,
|
||
trailers,
|
||
};
|
||
});
|
||
}
|
||
}
|
||
exports.ServerStreamingCall = ServerStreamingCall;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 56892:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.ServiceType = void 0;
|
||
const reflection_info_1 = __nccwpck_require__(62496);
|
||
class ServiceType {
|
||
constructor(typeName, methods, options) {
|
||
this.typeName = typeName;
|
||
this.methods = methods.map(i => reflection_info_1.normalizeMethodInfo(i, this));
|
||
this.options = options !== null && options !== void 0 ? options : {};
|
||
}
|
||
}
|
||
exports.ServiceType = ServiceType;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 79122:
|
||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||
|
||
"use strict";
|
||
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.TestTransport = void 0;
|
||
const rpc_error_1 = __nccwpck_require__(78636);
|
||
const runtime_1 = __nccwpck_require__(68886);
|
||
const rpc_output_stream_1 = __nccwpck_require__(72726);
|
||
const rpc_options_1 = __nccwpck_require__(28576);
|
||
const unary_call_1 = __nccwpck_require__(29288);
|
||
const server_streaming_call_1 = __nccwpck_require__(46173);
|
||
const client_streaming_call_1 = __nccwpck_require__(37889);
|
||
const duplex_streaming_call_1 = __nccwpck_require__(36826);
|
||
/**
|
||
* Transport for testing.
|
||
*/
|
||
class TestTransport {
|
||
/**
|
||
* Initialize with mock data. Omitted fields have default value.
|
||
*/
|
||
constructor(data) {
|
||
/**
|
||
* Suppress warning / error about uncaught rejections of
|
||
* "status" and "trailers".
|
||
*/
|
||
this.suppressUncaughtRejections = true;
|
||
this.headerDelay = 10;
|
||
this.responseDelay = 50;
|
||
this.betweenResponseDelay = 10;
|
||
this.afterResponseDelay = 10;
|
||
this.data = data !== null && data !== void 0 ? data : {};
|
||
}
|
||
/**
|
||
* Sent message(s) during the last operation.
|
||
*/
|
||
get sentMessages() {
|
||
if (this.lastInput instanceof TestInputStream) {
|
||
return this.lastInput.sent;
|
||
}
|
||
else if (typeof this.lastInput == "object") {
|
||
return [this.lastInput.single];
|
||
}
|
||
return [];
|
||
}
|
||
/**
|
||
* Sending message(s) completed?
|
||
*/
|
||
get sendComplete() {
|
||
if (this.lastInput instanceof TestInputStream) {
|
||
return this.lastInput.completed;
|
||
}
|
||
else if (typeof this.lastInput == "object") {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
// Creates a promise for response headers from the mock data.
|
||
promiseHeaders() {
|
||
var _a;
|
||
const headers = (_a = this.data.headers) !== null && _a !== void 0 ? _a : TestTransport.defaultHeaders;
|
||
return headers instanceof rpc_error_1.RpcError
|
||
? Promise.reject(headers)
|
||
: Promise.resolve(headers);
|
||
}
|
||
// Creates a promise for a single, valid, message from the mock data.
|
||
promiseSingleResponse(method) {
|
||
if (this.data.response instanceof rpc_error_1.RpcError) {
|
||
return Promise.reject(this.data.response);
|
||
}
|
||
let r;
|
||
if (Array.isArray(this.data.response)) {
|
||
runtime_1.assert(this.data.response.length > 0);
|
||
r = this.data.response[0];
|
||
}
|
||
else if (this.data.response !== undefined) {
|
||
r = this.data.response;
|
||
}
|
||
else {
|
||
r = method.O.create();
|
||
}
|
||
runtime_1.assert(method.O.is(r));
|
||
return Promise.resolve(r);
|
||
}
|
||
/**
|
||
* Pushes response messages from the mock data to the output stream.
|
||
* If an error response, status or trailers are mocked, the stream is
|
||
* closed with the respective error.
|
||
* Otherwise, stream is completed successfully.
|
||
*
|
||
* The returned promise resolves when the stream is closed. It should
|
||
* not reject. If it does, code is broken.
|
||
*/
|
||
streamResponses(method, stream, abort) {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
// normalize "data.response" into an array of valid output messages
|
||
const messages = [];
|
||
if (this.data.response === undefined) {
|
||
messages.push(method.O.create());
|
||
}
|
||
else if (Array.isArray(this.data.response)) {
|
||
for (let msg of this.data.response) {
|
||
runtime_1.assert(method.O.is(msg));
|
||
messages.push(msg);
|
||
}
|
||
}
|
||
else if (!(this.data.response instanceof rpc_error_1.RpcError)) {
|
||
runtime_1.assert(method.O.is(this.data.response));
|
||
messages.push(this.data.response);
|
||
}
|
||
// start the stream with an initial delay.
|
||
// if the request is cancelled, notify() error and exit.
|
||
try {
|
||
yield delay(this.responseDelay, abort)(undefined);
|
||
}
|
||
catch (error) {
|
||
stream.notifyError(error);
|
||
return;
|
||
}
|
||
// if error response was mocked, notify() error (stream is now closed with error) and exit.
|
||
if (this.data.response instanceof rpc_error_1.RpcError) {
|
||
stream.notifyError(this.data.response);
|
||
return;
|
||
}
|
||
// regular response messages were mocked. notify() them.
|
||
for (let msg of messages) {
|
||
stream.notifyMessage(msg);
|
||
// add a short delay between responses
|
||
// if the request is cancelled, notify() error and exit.
|
||
try {
|
||
yield delay(this.betweenResponseDelay, abort)(undefined);
|
||
}
|
||
catch (error) {
|
||
stream.notifyError(error);
|
||
return;
|
||
}
|
||
}
|
||
// error status was mocked, notify() error (stream is now closed with error) and exit.
|
||
if (this.data.status instanceof rpc_error_1.RpcError) {
|
||
stream.notifyError(this.data.status);
|
||
return;
|
||
}
|
||
// error trailers were mocked, notify() error (stream is now closed with error) and exit.
|
||
if (this.data.trailers instanceof rpc_error_1.RpcError) {
|
||
stream.notifyError(this.data.trailers);
|
||
return;
|
||
}
|
||
// stream completed successfully
|
||
stream.notifyComplete();
|
||
});
|
||
}
|
||
// Creates a promise for response status from the mock data.
|
||
promiseStatus() {
|
||
var _a;
|
||
const status = (_a = this.data.status) !== null && _a !== void 0 ? _a : TestTransport.defaultStatus;
|
||
return status instanceof rpc_error_1.RpcError
|
||
? Promise.reject(status)
|
||
: Promise.resolve(status);
|
||
}
|
||
// Creates a promise for response trailers from the mock data.
|
||
promiseTrailers() {
|
||
var _a;
|
||
const trailers = (_a = this.data.trailers) !== null && _a !== void 0 ? _a : TestTransport.defaultTrailers;
|
||
return trailers instanceof rpc_error_1.RpcError
|
||
? Promise.reject(trailers)
|
||
: Promise.resolve(trailers);
|
||
}
|
||
maybeSuppressUncaught(...promise) {
|
||
if (this.suppressUncaughtRejections) {
|
||
for (let p of promise) {
|
||
p.catch(() => {
|
||
});
|
||
}
|
||
}
|
||
}
|
||
mergeOptions(options) {
|
||
return rpc_options_1.mergeRpcOptions({}, options);
|
||
}
|
||
unary(method, input, options) {
|
||
var _a;
|
||
const requestHeaders = (_a = options.meta) !== null && _a !== void 0 ? _a : {}, headersPromise = this.promiseHeaders()
|
||
.then(delay(this.headerDelay, options.abort)), responsePromise = headersPromise
|
||
.catch(_ => {
|
||
})
|
||
.then(delay(this.responseDelay, options.abort))
|
||
.then(_ => this.promiseSingleResponse(method)), statusPromise = responsePromise
|
||
.catch(_ => {
|
||
})
|
||
.then(delay(this.afterResponseDelay, options.abort))
|
||
.then(_ => this.promiseStatus()), trailersPromise = responsePromise
|
||
.catch(_ => {
|
||
})
|
||
.then(delay(this.afterResponseDelay, options.abort))
|
||
.then(_ => this.promiseTrailers());
|
||
this.maybeSuppressUncaught(statusPromise, trailersPromise);
|
||
this.lastInput = { single: input };
|
||
return new unary_call_1.UnaryCall(method, requestHeaders, input, headersPromise, responsePromise, statusPromise, trailersPromise);
|
||
}
|
||
serverStreaming(method, input, options) {
|
||
var _a;
|
||
const requestHeaders = (_a = options.meta) !== null && _a !== void 0 ? _a : {}, headersPromise = this.promiseHeaders()
|
||
.then(delay(this.headerDelay, options.abort)), outputStream = new rpc_output_stream_1.RpcOutputStreamController(), responseStreamClosedPromise = headersPromise
|
||
.then(delay(this.responseDelay, options.abort))
|
||
.catch(() => {
|
||
})
|
||
.then(() => this.streamResponses(method, outputStream, options.abort))
|
||
.then(delay(this.afterResponseDelay, options.abort)), statusPromise = responseStreamClosedPromise
|
||
.then(() => this.promiseStatus()), trailersPromise = responseStreamClosedPromise
|
||
.then(() => this.promiseTrailers());
|
||
this.maybeSuppressUncaught(statusPromise, trailersPromise);
|
||
this.lastInput = { single: input };
|
||
return new server_streaming_call_1.ServerStreamingCall(method, requestHeaders, input, headersPromise, outputStream, statusPromise, trailersPromise);
|
||
}
|
||
clientStreaming(method, options) {
|
||
var _a;
|
||
const requestHeaders = (_a = options.meta) !== null && _a !== void 0 ? _a : {}, headersPromise = this.promiseHeaders()
|
||
.then(delay(this.headerDelay, options.abort)), responsePromise = headersPromise
|
||
.catch(_ => {
|
||
})
|
||
.then(delay(this.responseDelay, options.abort))
|
||
.then(_ => this.promiseSingleResponse(method)), statusPromise = responsePromise
|
||
.catch(_ => {
|
||
})
|
||
.then(delay(this.afterResponseDelay, options.abort))
|
||
.then(_ => this.promiseStatus()), trailersPromise = responsePromise
|
||
.catch(_ => {
|
||
})
|
||
.then(delay(this.afterResponseDelay, options.abort))
|
||
.then(_ => this.promiseTrailers());
|
||
this.maybeSuppressUncaught(statusPromise, trailersPromise);
|
||
this.lastInput = new TestInputStream(this.data, options.abort);
|
||
return new client_streaming_call_1.ClientStreamingCall(method, requestHeaders, this.lastInput, headersPromise, responsePromise, statusPromise, trailersPromise);
|
||
}
|
||
duplex(method, options) {
|
||
var _a;
|
||
const requestHeaders = (_a = options.meta) !== null && _a !== void 0 ? _a : {}, headersPromise = this.promiseHeaders()
|
||
.then(delay(this.headerDelay, options.abort)), outputStream = new rpc_output_stream_1.RpcOutputStreamController(), responseStreamClosedPromise = headersPromise
|
||
.then(delay(this.responseDelay, options.abort))
|
||
.catch(() => {
|
||
})
|
||
.then(() => this.streamResponses(method, outputStream, options.abort))
|
||
.then(delay(this.afterResponseDelay, options.abort)), statusPromise = responseStreamClosedPromise
|
||
.then(() => this.promiseStatus()), trailersPromise = responseStreamClosedPromise
|
||
.then(() => this.promiseTrailers());
|
||
this.maybeSuppressUncaught(statusPromise, trailersPromise);
|
||
this.lastInput = new TestInputStream(this.data, options.abort);
|
||
return new duplex_streaming_call_1.DuplexStreamingCall(method, requestHeaders, this.lastInput, headersPromise, outputStream, statusPromise, trailersPromise);
|
||
}
|
||
}
|
||
exports.TestTransport = TestTransport;
|
||
TestTransport.defaultHeaders = {
|
||
responseHeader: "test"
|
||
};
|
||
TestTransport.defaultStatus = {
|
||
code: "OK", detail: "all good"
|
||
};
|
||
TestTransport.defaultTrailers = {
|
||
responseTrailer: "test"
|
||
};
|
||
function delay(ms, abort) {
|
||
return (v) => new Promise((resolve, reject) => {
|
||
if (abort === null || abort === void 0 ? void 0 : abort.aborted) {
|
||
reject(new rpc_error_1.RpcError("user cancel", "CANCELLED"));
|
||
}
|
||
else {
|
||
const id = setTimeout(() => resolve(v), ms);
|
||
if (abort) {
|
||
abort.addEventListener("abort", ev => {
|
||
clearTimeout(id);
|
||
reject(new rpc_error_1.RpcError("user cancel", "CANCELLED"));
|
||
});
|
||
}
|
||
}
|
||
});
|
||
}
|
||
class TestInputStream {
|
||
constructor(data, abort) {
|
||
this._completed = false;
|
||
this._sent = [];
|
||
this.data = data;
|
||
this.abort = abort;
|
||
}
|
||
get sent() {
|
||
return this._sent;
|
||
}
|
||
get completed() {
|
||
return this._completed;
|
||
}
|
||
send(message) {
|
||
if (this.data.inputMessage instanceof rpc_error_1.RpcError) {
|
||
return Promise.reject(this.data.inputMessage);
|
||
}
|
||
const delayMs = this.data.inputMessage === undefined
|
||
? 10
|
||
: this.data.inputMessage;
|
||
return Promise.resolve(undefined)
|
||
.then(() => {
|
||
this._sent.push(message);
|
||
})
|
||
.then(delay(delayMs, this.abort));
|
||
}
|
||
complete() {
|
||
if (this.data.inputComplete instanceof rpc_error_1.RpcError) {
|
||
return Promise.reject(this.data.inputComplete);
|
||
}
|
||
const delayMs = this.data.inputComplete === undefined
|
||
? 10
|
||
: this.data.inputComplete;
|
||
return Promise.resolve(undefined)
|
||
.then(() => {
|
||
this._completed = true;
|
||
})
|
||
.then(delay(delayMs, this.abort));
|
||
}
|
||
}
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 29288:
|
||
/***/ (function(__unused_webpack_module, exports) {
|
||
|
||
"use strict";
|
||
|
||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
return new (P || (P = Promise))(function (resolve, reject) {
|
||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
};
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.UnaryCall = void 0;
|
||
/**
|
||
* A unary RPC call. Unary means there is exactly one input message and
|
||
* exactly one output message unless an error occurred.
|
||
*/
|
||
class UnaryCall {
|
||
constructor(method, requestHeaders, request, headers, response, status, trailers) {
|
||
this.method = method;
|
||
this.requestHeaders = requestHeaders;
|
||
this.request = request;
|
||
this.headers = headers;
|
||
this.response = response;
|
||
this.status = status;
|
||
this.trailers = trailers;
|
||
}
|
||
/**
|
||
* If you are only interested in the final outcome of this call,
|
||
* you can await it to receive a `FinishedUnaryCall`.
|
||
*/
|
||
then(onfulfilled, onrejected) {
|
||
return this.promiseFinished().then(value => onfulfilled ? Promise.resolve(onfulfilled(value)) : value, reason => onrejected ? Promise.resolve(onrejected(reason)) : Promise.reject(reason));
|
||
}
|
||
promiseFinished() {
|
||
return __awaiter(this, void 0, void 0, function* () {
|
||
let [headers, response, status, trailers] = yield Promise.all([this.headers, this.response, this.status, this.trailers]);
|
||
return {
|
||
method: this.method,
|
||
requestHeaders: this.requestHeaders,
|
||
request: this.request,
|
||
headers,
|
||
response,
|
||
status,
|
||
trailers
|
||
};
|
||
});
|
||
}
|
||
}
|
||
exports.UnaryCall = UnaryCall;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 8602:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.assertFloat32 = exports.assertUInt32 = exports.assertInt32 = exports.assertNever = exports.assert = void 0;
|
||
/**
|
||
* assert that condition is true or throw error (with message)
|
||
*/
|
||
function assert(condition, msg) {
|
||
if (!condition) {
|
||
throw new Error(msg);
|
||
}
|
||
}
|
||
exports.assert = assert;
|
||
/**
|
||
* assert that value cannot exist = type `never`. throw runtime error if it does.
|
||
*/
|
||
function assertNever(value, msg) {
|
||
throw new Error(msg !== null && msg !== void 0 ? msg : 'Unexpected object: ' + value);
|
||
}
|
||
exports.assertNever = assertNever;
|
||
const FLOAT32_MAX = 3.4028234663852886e+38, FLOAT32_MIN = -3.4028234663852886e+38, UINT32_MAX = 0xFFFFFFFF, INT32_MAX = 0X7FFFFFFF, INT32_MIN = -0X80000000;
|
||
function assertInt32(arg) {
|
||
if (typeof arg !== "number")
|
||
throw new Error('invalid int 32: ' + typeof arg);
|
||
if (!Number.isInteger(arg) || arg > INT32_MAX || arg < INT32_MIN)
|
||
throw new Error('invalid int 32: ' + arg);
|
||
}
|
||
exports.assertInt32 = assertInt32;
|
||
function assertUInt32(arg) {
|
||
if (typeof arg !== "number")
|
||
throw new Error('invalid uint 32: ' + typeof arg);
|
||
if (!Number.isInteger(arg) || arg > UINT32_MAX || arg < 0)
|
||
throw new Error('invalid uint 32: ' + arg);
|
||
}
|
||
exports.assertUInt32 = assertUInt32;
|
||
function assertFloat32(arg) {
|
||
if (typeof arg !== "number")
|
||
throw new Error('invalid float 32: ' + typeof arg);
|
||
if (!Number.isFinite(arg))
|
||
return;
|
||
if (arg > FLOAT32_MAX || arg < FLOAT32_MIN)
|
||
throw new Error('invalid float 32: ' + arg);
|
||
}
|
||
exports.assertFloat32 = assertFloat32;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 26335:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.base64encode = exports.base64decode = void 0;
|
||
// lookup table from base64 character to byte
|
||
let encTable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
|
||
// lookup table from base64 character *code* to byte because lookup by number is fast
|
||
let decTable = [];
|
||
for (let i = 0; i < encTable.length; i++)
|
||
decTable[encTable[i].charCodeAt(0)] = i;
|
||
// support base64url variants
|
||
decTable["-".charCodeAt(0)] = encTable.indexOf("+");
|
||
decTable["_".charCodeAt(0)] = encTable.indexOf("/");
|
||
/**
|
||
* Decodes a base64 string to a byte array.
|
||
*
|
||
* - ignores white-space, including line breaks and tabs
|
||
* - allows inner padding (can decode concatenated base64 strings)
|
||
* - does not require padding
|
||
* - understands base64url encoding:
|
||
* "-" instead of "+",
|
||
* "_" instead of "/",
|
||
* no padding
|
||
*/
|
||
function base64decode(base64Str) {
|
||
// estimate byte size, not accounting for inner padding and whitespace
|
||
let es = base64Str.length * 3 / 4;
|
||
// if (es % 3 !== 0)
|
||
// throw new Error('invalid base64 string');
|
||
if (base64Str[base64Str.length - 2] == '=')
|
||
es -= 2;
|
||
else if (base64Str[base64Str.length - 1] == '=')
|
||
es -= 1;
|
||
let bytes = new Uint8Array(es), bytePos = 0, // position in byte array
|
||
groupPos = 0, // position in base64 group
|
||
b, // current byte
|
||
p = 0 // previous byte
|
||
;
|
||
for (let i = 0; i < base64Str.length; i++) {
|
||
b = decTable[base64Str.charCodeAt(i)];
|
||
if (b === undefined) {
|
||
// noinspection FallThroughInSwitchStatementJS
|
||
switch (base64Str[i]) {
|
||
case '=':
|
||
groupPos = 0; // reset state when padding found
|
||
case '\n':
|
||
case '\r':
|
||
case '\t':
|
||
case ' ':
|
||
continue; // skip white-space, and padding
|
||
default:
|
||
throw Error(`invalid base64 string.`);
|
||
}
|
||
}
|
||
switch (groupPos) {
|
||
case 0:
|
||
p = b;
|
||
groupPos = 1;
|
||
break;
|
||
case 1:
|
||
bytes[bytePos++] = p << 2 | (b & 48) >> 4;
|
||
p = b;
|
||
groupPos = 2;
|
||
break;
|
||
case 2:
|
||
bytes[bytePos++] = (p & 15) << 4 | (b & 60) >> 2;
|
||
p = b;
|
||
groupPos = 3;
|
||
break;
|
||
case 3:
|
||
bytes[bytePos++] = (p & 3) << 6 | b;
|
||
groupPos = 0;
|
||
break;
|
||
}
|
||
}
|
||
if (groupPos == 1)
|
||
throw Error(`invalid base64 string.`);
|
||
return bytes.subarray(0, bytePos);
|
||
}
|
||
exports.base64decode = base64decode;
|
||
/**
|
||
* Encodes a byte array to a base64 string.
|
||
* Adds padding at the end.
|
||
* Does not insert newlines.
|
||
*/
|
||
function base64encode(bytes) {
|
||
let base64 = '', groupPos = 0, // position in base64 group
|
||
b, // current byte
|
||
p = 0; // carry over from previous byte
|
||
for (let i = 0; i < bytes.length; i++) {
|
||
b = bytes[i];
|
||
switch (groupPos) {
|
||
case 0:
|
||
base64 += encTable[b >> 2];
|
||
p = (b & 3) << 4;
|
||
groupPos = 1;
|
||
break;
|
||
case 1:
|
||
base64 += encTable[p | b >> 4];
|
||
p = (b & 15) << 2;
|
||
groupPos = 2;
|
||
break;
|
||
case 2:
|
||
base64 += encTable[p | b >> 6];
|
||
base64 += encTable[b & 63];
|
||
groupPos = 0;
|
||
break;
|
||
}
|
||
}
|
||
// padding required?
|
||
if (groupPos) {
|
||
base64 += encTable[p];
|
||
base64 += '=';
|
||
if (groupPos == 1)
|
||
base64 += '=';
|
||
}
|
||
return base64;
|
||
}
|
||
exports.base64encode = base64encode;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 54816:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.WireType = exports.mergeBinaryOptions = exports.UnknownFieldHandler = void 0;
|
||
/**
|
||
* This handler implements the default behaviour for unknown fields.
|
||
* When reading data, unknown fields are stored on the message, in a
|
||
* symbol property.
|
||
* When writing data, the symbol property is queried and unknown fields
|
||
* are serialized into the output again.
|
||
*/
|
||
var UnknownFieldHandler;
|
||
(function (UnknownFieldHandler) {
|
||
/**
|
||
* The symbol used to store unknown fields for a message.
|
||
* The property must conform to `UnknownFieldContainer`.
|
||
*/
|
||
UnknownFieldHandler.symbol = Symbol.for("protobuf-ts/unknown");
|
||
/**
|
||
* Store an unknown field during binary read directly on the message.
|
||
* This method is compatible with `BinaryReadOptions.readUnknownField`.
|
||
*/
|
||
UnknownFieldHandler.onRead = (typeName, message, fieldNo, wireType, data) => {
|
||
let container = is(message) ? message[UnknownFieldHandler.symbol] : message[UnknownFieldHandler.symbol] = [];
|
||
container.push({ no: fieldNo, wireType, data });
|
||
};
|
||
/**
|
||
* Write unknown fields stored for the message to the writer.
|
||
* This method is compatible with `BinaryWriteOptions.writeUnknownFields`.
|
||
*/
|
||
UnknownFieldHandler.onWrite = (typeName, message, writer) => {
|
||
for (let { no, wireType, data } of UnknownFieldHandler.list(message))
|
||
writer.tag(no, wireType).raw(data);
|
||
};
|
||
/**
|
||
* List unknown fields stored for the message.
|
||
* Note that there may be multiples fields with the same number.
|
||
*/
|
||
UnknownFieldHandler.list = (message, fieldNo) => {
|
||
if (is(message)) {
|
||
let all = message[UnknownFieldHandler.symbol];
|
||
return fieldNo ? all.filter(uf => uf.no == fieldNo) : all;
|
||
}
|
||
return [];
|
||
};
|
||
/**
|
||
* Returns the last unknown field by field number.
|
||
*/
|
||
UnknownFieldHandler.last = (message, fieldNo) => UnknownFieldHandler.list(message, fieldNo).slice(-1)[0];
|
||
const is = (message) => message && Array.isArray(message[UnknownFieldHandler.symbol]);
|
||
})(UnknownFieldHandler = exports.UnknownFieldHandler || (exports.UnknownFieldHandler = {}));
|
||
/**
|
||
* Merges binary write or read options. Later values override earlier values.
|
||
*/
|
||
function mergeBinaryOptions(a, b) {
|
||
return Object.assign(Object.assign({}, a), b);
|
||
}
|
||
exports.mergeBinaryOptions = mergeBinaryOptions;
|
||
/**
|
||
* Protobuf binary format wire types.
|
||
*
|
||
* A wire type provides just enough information to find the length of the
|
||
* following value.
|
||
*
|
||
* See https://developers.google.com/protocol-buffers/docs/encoding#structure
|
||
*/
|
||
var WireType;
|
||
(function (WireType) {
|
||
/**
|
||
* Used for int32, int64, uint32, uint64, sint32, sint64, bool, enum
|
||
*/
|
||
WireType[WireType["Varint"] = 0] = "Varint";
|
||
/**
|
||
* Used for fixed64, sfixed64, double.
|
||
* Always 8 bytes with little-endian byte order.
|
||
*/
|
||
WireType[WireType["Bit64"] = 1] = "Bit64";
|
||
/**
|
||
* Used for string, bytes, embedded messages, packed repeated fields
|
||
*
|
||
* Only repeated numeric types (types which use the varint, 32-bit,
|
||
* or 64-bit wire types) can be packed. In proto3, such fields are
|
||
* packed by default.
|
||
*/
|
||
WireType[WireType["LengthDelimited"] = 2] = "LengthDelimited";
|
||
/**
|
||
* Used for groups
|
||
* @deprecated
|
||
*/
|
||
WireType[WireType["StartGroup"] = 3] = "StartGroup";
|
||
/**
|
||
* Used for groups
|
||
* @deprecated
|
||
*/
|
||
WireType[WireType["EndGroup"] = 4] = "EndGroup";
|
||
/**
|
||
* Used for fixed32, sfixed32, float.
|
||
* Always 4 bytes with little-endian byte order.
|
||
*/
|
||
WireType[WireType["Bit32"] = 5] = "Bit32";
|
||
})(WireType = exports.WireType || (exports.WireType = {}));
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 92889:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.BinaryReader = exports.binaryReadOptions = void 0;
|
||
const binary_format_contract_1 = __nccwpck_require__(54816);
|
||
const pb_long_1 = __nccwpck_require__(61753);
|
||
const goog_varint_1 = __nccwpck_require__(93223);
|
||
const defaultsRead = {
|
||
readUnknownField: true,
|
||
readerFactory: bytes => new BinaryReader(bytes),
|
||
};
|
||
/**
|
||
* Make options for reading binary data form partial options.
|
||
*/
|
||
function binaryReadOptions(options) {
|
||
return options ? Object.assign(Object.assign({}, defaultsRead), options) : defaultsRead;
|
||
}
|
||
exports.binaryReadOptions = binaryReadOptions;
|
||
class BinaryReader {
|
||
constructor(buf, textDecoder) {
|
||
this.varint64 = goog_varint_1.varint64read; // dirty cast for `this`
|
||
/**
|
||
* Read a `uint32` field, an unsigned 32 bit varint.
|
||
*/
|
||
this.uint32 = goog_varint_1.varint32read; // dirty cast for `this` and access to protected `buf`
|
||
this.buf = buf;
|
||
this.len = buf.length;
|
||
this.pos = 0;
|
||
this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
||
this.textDecoder = textDecoder !== null && textDecoder !== void 0 ? textDecoder : new TextDecoder("utf-8", {
|
||
fatal: true,
|
||
ignoreBOM: true,
|
||
});
|
||
}
|
||
/**
|
||
* Reads a tag - field number and wire type.
|
||
*/
|
||
tag() {
|
||
let tag = this.uint32(), fieldNo = tag >>> 3, wireType = tag & 7;
|
||
if (fieldNo <= 0 || wireType < 0 || wireType > 5)
|
||
throw new Error("illegal tag: field no " + fieldNo + " wire type " + wireType);
|
||
return [fieldNo, wireType];
|
||
}
|
||
/**
|
||
* Skip one element on the wire and return the skipped data.
|
||
* Supports WireType.StartGroup since v2.0.0-alpha.23.
|
||
*/
|
||
skip(wireType) {
|
||
let start = this.pos;
|
||
// noinspection FallThroughInSwitchStatementJS
|
||
switch (wireType) {
|
||
case binary_format_contract_1.WireType.Varint:
|
||
while (this.buf[this.pos++] & 0x80) {
|
||
// ignore
|
||
}
|
||
break;
|
||
case binary_format_contract_1.WireType.Bit64:
|
||
this.pos += 4;
|
||
case binary_format_contract_1.WireType.Bit32:
|
||
this.pos += 4;
|
||
break;
|
||
case binary_format_contract_1.WireType.LengthDelimited:
|
||
let len = this.uint32();
|
||
this.pos += len;
|
||
break;
|
||
case binary_format_contract_1.WireType.StartGroup:
|
||
// From descriptor.proto: Group type is deprecated, not supported in proto3.
|
||
// But we must still be able to parse and treat as unknown.
|
||
let t;
|
||
while ((t = this.tag()[1]) !== binary_format_contract_1.WireType.EndGroup) {
|
||
this.skip(t);
|
||
}
|
||
break;
|
||
default:
|
||
throw new Error("cant skip wire type " + wireType);
|
||
}
|
||
this.assertBounds();
|
||
return this.buf.subarray(start, this.pos);
|
||
}
|
||
/**
|
||
* Throws error if position in byte array is out of range.
|
||
*/
|
||
assertBounds() {
|
||
if (this.pos > this.len)
|
||
throw new RangeError("premature EOF");
|
||
}
|
||
/**
|
||
* Read a `int32` field, a signed 32 bit varint.
|
||
*/
|
||
int32() {
|
||
return this.uint32() | 0;
|
||
}
|
||
/**
|
||
* Read a `sint32` field, a signed, zigzag-encoded 32-bit varint.
|
||
*/
|
||
sint32() {
|
||
let zze = this.uint32();
|
||
// decode zigzag
|
||
return (zze >>> 1) ^ -(zze & 1);
|
||
}
|
||
/**
|
||
* Read a `int64` field, a signed 64-bit varint.
|
||
*/
|
||
int64() {
|
||
return new pb_long_1.PbLong(...this.varint64());
|
||
}
|
||
/**
|
||
* Read a `uint64` field, an unsigned 64-bit varint.
|
||
*/
|
||
uint64() {
|
||
return new pb_long_1.PbULong(...this.varint64());
|
||
}
|
||
/**
|
||
* Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
|
||
*/
|
||
sint64() {
|
||
let [lo, hi] = this.varint64();
|
||
// decode zig zag
|
||
let s = -(lo & 1);
|
||
lo = ((lo >>> 1 | (hi & 1) << 31) ^ s);
|
||
hi = (hi >>> 1 ^ s);
|
||
return new pb_long_1.PbLong(lo, hi);
|
||
}
|
||
/**
|
||
* Read a `bool` field, a variant.
|
||
*/
|
||
bool() {
|
||
let [lo, hi] = this.varint64();
|
||
return lo !== 0 || hi !== 0;
|
||
}
|
||
/**
|
||
* Read a `fixed32` field, an unsigned, fixed-length 32-bit integer.
|
||
*/
|
||
fixed32() {
|
||
return this.view.getUint32((this.pos += 4) - 4, true);
|
||
}
|
||
/**
|
||
* Read a `sfixed32` field, a signed, fixed-length 32-bit integer.
|
||
*/
|
||
sfixed32() {
|
||
return this.view.getInt32((this.pos += 4) - 4, true);
|
||
}
|
||
/**
|
||
* Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
|
||
*/
|
||
fixed64() {
|
||
return new pb_long_1.PbULong(this.sfixed32(), this.sfixed32());
|
||
}
|
||
/**
|
||
* Read a `fixed64` field, a signed, fixed-length 64-bit integer.
|
||
*/
|
||
sfixed64() {
|
||
return new pb_long_1.PbLong(this.sfixed32(), this.sfixed32());
|
||
}
|
||
/**
|
||
* Read a `float` field, 32-bit floating point number.
|
||
*/
|
||
float() {
|
||
return this.view.getFloat32((this.pos += 4) - 4, true);
|
||
}
|
||
/**
|
||
* Read a `double` field, a 64-bit floating point number.
|
||
*/
|
||
double() {
|
||
return this.view.getFloat64((this.pos += 8) - 8, true);
|
||
}
|
||
/**
|
||
* Read a `bytes` field, length-delimited arbitrary data.
|
||
*/
|
||
bytes() {
|
||
let len = this.uint32();
|
||
let start = this.pos;
|
||
this.pos += len;
|
||
this.assertBounds();
|
||
return this.buf.subarray(start, start + len);
|
||
}
|
||
/**
|
||
* Read a `string` field, length-delimited data converted to UTF-8 text.
|
||
*/
|
||
string() {
|
||
return this.textDecoder.decode(this.bytes());
|
||
}
|
||
}
|
||
exports.BinaryReader = BinaryReader;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 23957:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.BinaryWriter = exports.binaryWriteOptions = void 0;
|
||
const pb_long_1 = __nccwpck_require__(61753);
|
||
const goog_varint_1 = __nccwpck_require__(93223);
|
||
const assert_1 = __nccwpck_require__(8602);
|
||
const defaultsWrite = {
|
||
writeUnknownFields: true,
|
||
writerFactory: () => new BinaryWriter(),
|
||
};
|
||
/**
|
||
* Make options for writing binary data form partial options.
|
||
*/
|
||
function binaryWriteOptions(options) {
|
||
return options ? Object.assign(Object.assign({}, defaultsWrite), options) : defaultsWrite;
|
||
}
|
||
exports.binaryWriteOptions = binaryWriteOptions;
|
||
class BinaryWriter {
|
||
constructor(textEncoder) {
|
||
/**
|
||
* Previous fork states.
|
||
*/
|
||
this.stack = [];
|
||
this.textEncoder = textEncoder !== null && textEncoder !== void 0 ? textEncoder : new TextEncoder();
|
||
this.chunks = [];
|
||
this.buf = [];
|
||
}
|
||
/**
|
||
* Return all bytes written and reset this writer.
|
||
*/
|
||
finish() {
|
||
this.chunks.push(new Uint8Array(this.buf)); // flush the buffer
|
||
let len = 0;
|
||
for (let i = 0; i < this.chunks.length; i++)
|
||
len += this.chunks[i].length;
|
||
let bytes = new Uint8Array(len);
|
||
let offset = 0;
|
||
for (let i = 0; i < this.chunks.length; i++) {
|
||
bytes.set(this.chunks[i], offset);
|
||
offset += this.chunks[i].length;
|
||
}
|
||
this.chunks = [];
|
||
return bytes;
|
||
}
|
||
/**
|
||
* Start a new fork for length-delimited data like a message
|
||
* or a packed repeated field.
|
||
*
|
||
* Must be joined later with `join()`.
|
||
*/
|
||
fork() {
|
||
this.stack.push({ chunks: this.chunks, buf: this.buf });
|
||
this.chunks = [];
|
||
this.buf = [];
|
||
return this;
|
||
}
|
||
/**
|
||
* Join the last fork. Write its length and bytes, then
|
||
* return to the previous state.
|
||
*/
|
||
join() {
|
||
// get chunk of fork
|
||
let chunk = this.finish();
|
||
// restore previous state
|
||
let prev = this.stack.pop();
|
||
if (!prev)
|
||
throw new Error('invalid state, fork stack empty');
|
||
this.chunks = prev.chunks;
|
||
this.buf = prev.buf;
|
||
// write length of chunk as varint
|
||
this.uint32(chunk.byteLength);
|
||
return this.raw(chunk);
|
||
}
|
||
/**
|
||
* Writes a tag (field number and wire type).
|
||
*
|
||
* Equivalent to `uint32( (fieldNo << 3 | type) >>> 0 )`.
|
||
*
|
||
* Generated code should compute the tag ahead of time and call `uint32()`.
|
||
*/
|
||
tag(fieldNo, type) {
|
||
return this.uint32((fieldNo << 3 | type) >>> 0);
|
||
}
|
||
/**
|
||
* Write a chunk of raw bytes.
|
||
*/
|
||
raw(chunk) {
|
||
if (this.buf.length) {
|
||
this.chunks.push(new Uint8Array(this.buf));
|
||
this.buf = [];
|
||
}
|
||
this.chunks.push(chunk);
|
||
return this;
|
||
}
|
||
/**
|
||
* Write a `uint32` value, an unsigned 32 bit varint.
|
||
*/
|
||
uint32(value) {
|
||
assert_1.assertUInt32(value);
|
||
// write value as varint 32, inlined for speed
|
||
while (value > 0x7f) {
|
||
this.buf.push((value & 0x7f) | 0x80);
|
||
value = value >>> 7;
|
||
}
|
||
this.buf.push(value);
|
||
return this;
|
||
}
|
||
/**
|
||
* Write a `int32` value, a signed 32 bit varint.
|
||
*/
|
||
int32(value) {
|
||
assert_1.assertInt32(value);
|
||
goog_varint_1.varint32write(value, this.buf);
|
||
return this;
|
||
}
|
||
/**
|
||
* Write a `bool` value, a variant.
|
||
*/
|
||
bool(value) {
|
||
this.buf.push(value ? 1 : 0);
|
||
return this;
|
||
}
|
||
/**
|
||
* Write a `bytes` value, length-delimited arbitrary data.
|
||
*/
|
||
bytes(value) {
|
||
this.uint32(value.byteLength); // write length of chunk as varint
|
||
return this.raw(value);
|
||
}
|
||
/**
|
||
* Write a `string` value, length-delimited data converted to UTF-8 text.
|
||
*/
|
||
string(value) {
|
||
let chunk = this.textEncoder.encode(value);
|
||
this.uint32(chunk.byteLength); // write length of chunk as varint
|
||
return this.raw(chunk);
|
||
}
|
||
/**
|
||
* Write a `float` value, 32-bit floating point number.
|
||
*/
|
||
float(value) {
|
||
assert_1.assertFloat32(value);
|
||
let chunk = new Uint8Array(4);
|
||
new DataView(chunk.buffer).setFloat32(0, value, true);
|
||
return this.raw(chunk);
|
||
}
|
||
/**
|
||
* Write a `double` value, a 64-bit floating point number.
|
||
*/
|
||
double(value) {
|
||
let chunk = new Uint8Array(8);
|
||
new DataView(chunk.buffer).setFloat64(0, value, true);
|
||
return this.raw(chunk);
|
||
}
|
||
/**
|
||
* Write a `fixed32` value, an unsigned, fixed-length 32-bit integer.
|
||
*/
|
||
fixed32(value) {
|
||
assert_1.assertUInt32(value);
|
||
let chunk = new Uint8Array(4);
|
||
new DataView(chunk.buffer).setUint32(0, value, true);
|
||
return this.raw(chunk);
|
||
}
|
||
/**
|
||
* Write a `sfixed32` value, a signed, fixed-length 32-bit integer.
|
||
*/
|
||
sfixed32(value) {
|
||
assert_1.assertInt32(value);
|
||
let chunk = new Uint8Array(4);
|
||
new DataView(chunk.buffer).setInt32(0, value, true);
|
||
return this.raw(chunk);
|
||
}
|
||
/**
|
||
* Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
|
||
*/
|
||
sint32(value) {
|
||
assert_1.assertInt32(value);
|
||
// zigzag encode
|
||
value = ((value << 1) ^ (value >> 31)) >>> 0;
|
||
goog_varint_1.varint32write(value, this.buf);
|
||
return this;
|
||
}
|
||
/**
|
||
* Write a `fixed64` value, a signed, fixed-length 64-bit integer.
|
||
*/
|
||
sfixed64(value) {
|
||
let chunk = new Uint8Array(8);
|
||
let view = new DataView(chunk.buffer);
|
||
let long = pb_long_1.PbLong.from(value);
|
||
view.setInt32(0, long.lo, true);
|
||
view.setInt32(4, long.hi, true);
|
||
return this.raw(chunk);
|
||
}
|
||
/**
|
||
* Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
|
||
*/
|
||
fixed64(value) {
|
||
let chunk = new Uint8Array(8);
|
||
let view = new DataView(chunk.buffer);
|
||
let long = pb_long_1.PbULong.from(value);
|
||
view.setInt32(0, long.lo, true);
|
||
view.setInt32(4, long.hi, true);
|
||
return this.raw(chunk);
|
||
}
|
||
/**
|
||
* Write a `int64` value, a signed 64-bit varint.
|
||
*/
|
||
int64(value) {
|
||
let long = pb_long_1.PbLong.from(value);
|
||
goog_varint_1.varint64write(long.lo, long.hi, this.buf);
|
||
return this;
|
||
}
|
||
/**
|
||
* Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
|
||
*/
|
||
sint64(value) {
|
||
let long = pb_long_1.PbLong.from(value),
|
||
// zigzag encode
|
||
sign = long.hi >> 31, lo = (long.lo << 1) ^ sign, hi = ((long.hi << 1) | (long.lo >>> 31)) ^ sign;
|
||
goog_varint_1.varint64write(lo, hi, this.buf);
|
||
return this;
|
||
}
|
||
/**
|
||
* Write a `uint64` value, an unsigned 64-bit varint.
|
||
*/
|
||
uint64(value) {
|
||
let long = pb_long_1.PbULong.from(value);
|
||
goog_varint_1.varint64write(long.lo, long.hi, this.buf);
|
||
return this;
|
||
}
|
||
}
|
||
exports.BinaryWriter = BinaryWriter;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 70257:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.listEnumNumbers = exports.listEnumNames = exports.listEnumValues = exports.isEnumObject = void 0;
|
||
/**
|
||
* Is this a lookup object generated by Typescript, for a Typescript enum
|
||
* generated by protobuf-ts?
|
||
*
|
||
* - No `const enum` (enum must not be inlined, we need reverse mapping).
|
||
* - No string enum (we need int32 for protobuf).
|
||
* - Must have a value for 0 (otherwise, we would need to support custom default values).
|
||
*/
|
||
function isEnumObject(arg) {
|
||
if (typeof arg != 'object' || arg === null) {
|
||
return false;
|
||
}
|
||
if (!arg.hasOwnProperty(0)) {
|
||
return false;
|
||
}
|
||
for (let k of Object.keys(arg)) {
|
||
let num = parseInt(k);
|
||
if (!Number.isNaN(num)) {
|
||
// is there a name for the number?
|
||
let nam = arg[num];
|
||
if (nam === undefined)
|
||
return false;
|
||
// does the name resolve back to the number?
|
||
if (arg[nam] !== num)
|
||
return false;
|
||
}
|
||
else {
|
||
// is there a number for the name?
|
||
let num = arg[k];
|
||
if (num === undefined)
|
||
return false;
|
||
// is it a string enum?
|
||
if (typeof num !== 'number')
|
||
return false;
|
||
// do we know the number?
|
||
if (arg[num] === undefined)
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
exports.isEnumObject = isEnumObject;
|
||
/**
|
||
* Lists all values of a Typescript enum, as an array of objects with a "name"
|
||
* property and a "number" property.
|
||
*
|
||
* Note that it is possible that a number appears more than once, because it is
|
||
* possible to have aliases in an enum.
|
||
*
|
||
* Throws if the enum does not adhere to the rules of enums generated by
|
||
* protobuf-ts. See `isEnumObject()`.
|
||
*/
|
||
function listEnumValues(enumObject) {
|
||
if (!isEnumObject(enumObject))
|
||
throw new Error("not a typescript enum object");
|
||
let values = [];
|
||
for (let [name, number] of Object.entries(enumObject))
|
||
if (typeof number == "number")
|
||
values.push({ name, number });
|
||
return values;
|
||
}
|
||
exports.listEnumValues = listEnumValues;
|
||
/**
|
||
* Lists the names of a Typescript enum.
|
||
*
|
||
* Throws if the enum does not adhere to the rules of enums generated by
|
||
* protobuf-ts. See `isEnumObject()`.
|
||
*/
|
||
function listEnumNames(enumObject) {
|
||
return listEnumValues(enumObject).map(val => val.name);
|
||
}
|
||
exports.listEnumNames = listEnumNames;
|
||
/**
|
||
* Lists the numbers of a Typescript enum.
|
||
*
|
||
* Throws if the enum does not adhere to the rules of enums generated by
|
||
* protobuf-ts. See `isEnumObject()`.
|
||
*/
|
||
function listEnumNumbers(enumObject) {
|
||
return listEnumValues(enumObject)
|
||
.map(val => val.number)
|
||
.filter((num, index, arr) => arr.indexOf(num) == index);
|
||
}
|
||
exports.listEnumNumbers = listEnumNumbers;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 93223:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
// Copyright 2008 Google Inc. All rights reserved.
|
||
//
|
||
// Redistribution and use in source and binary forms, with or without
|
||
// modification, are permitted provided that the following conditions are
|
||
// met:
|
||
//
|
||
// * Redistributions of source code must retain the above copyright
|
||
// notice, this list of conditions and the following disclaimer.
|
||
// * Redistributions in binary form must reproduce the above
|
||
// copyright notice, this list of conditions and the following disclaimer
|
||
// in the documentation and/or other materials provided with the
|
||
// distribution.
|
||
// * Neither the name of Google Inc. nor the names of its
|
||
// contributors may be used to endorse or promote products derived from
|
||
// this software without specific prior written permission.
|
||
//
|
||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
//
|
||
// Code generated by the Protocol Buffer compiler is owned by the owner
|
||
// of the input file used when generating it. This code is not
|
||
// standalone and requires a support library to be linked with it. This
|
||
// support library is itself covered by the above license.
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.varint32read = exports.varint32write = exports.int64toString = exports.int64fromString = exports.varint64write = exports.varint64read = void 0;
|
||
/**
|
||
* Read a 64 bit varint as two JS numbers.
|
||
*
|
||
* Returns tuple:
|
||
* [0]: low bits
|
||
* [0]: high bits
|
||
*
|
||
* Copyright 2008 Google Inc. All rights reserved.
|
||
*
|
||
* See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L175
|
||
*/
|
||
function varint64read() {
|
||
let lowBits = 0;
|
||
let highBits = 0;
|
||
for (let shift = 0; shift < 28; shift += 7) {
|
||
let b = this.buf[this.pos++];
|
||
lowBits |= (b & 0x7F) << shift;
|
||
if ((b & 0x80) == 0) {
|
||
this.assertBounds();
|
||
return [lowBits, highBits];
|
||
}
|
||
}
|
||
let middleByte = this.buf[this.pos++];
|
||
// last four bits of the first 32 bit number
|
||
lowBits |= (middleByte & 0x0F) << 28;
|
||
// 3 upper bits are part of the next 32 bit number
|
||
highBits = (middleByte & 0x70) >> 4;
|
||
if ((middleByte & 0x80) == 0) {
|
||
this.assertBounds();
|
||
return [lowBits, highBits];
|
||
}
|
||
for (let shift = 3; shift <= 31; shift += 7) {
|
||
let b = this.buf[this.pos++];
|
||
highBits |= (b & 0x7F) << shift;
|
||
if ((b & 0x80) == 0) {
|
||
this.assertBounds();
|
||
return [lowBits, highBits];
|
||
}
|
||
}
|
||
throw new Error('invalid varint');
|
||
}
|
||
exports.varint64read = varint64read;
|
||
/**
|
||
* Write a 64 bit varint, given as two JS numbers, to the given bytes array.
|
||
*
|
||
* Copyright 2008 Google Inc. All rights reserved.
|
||
*
|
||
* See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/writer.js#L344
|
||
*/
|
||
function varint64write(lo, hi, bytes) {
|
||
for (let i = 0; i < 28; i = i + 7) {
|
||
const shift = lo >>> i;
|
||
const hasNext = !((shift >>> 7) == 0 && hi == 0);
|
||
const byte = (hasNext ? shift | 0x80 : shift) & 0xFF;
|
||
bytes.push(byte);
|
||
if (!hasNext) {
|
||
return;
|
||
}
|
||
}
|
||
const splitBits = ((lo >>> 28) & 0x0F) | ((hi & 0x07) << 4);
|
||
const hasMoreBits = !((hi >> 3) == 0);
|
||
bytes.push((hasMoreBits ? splitBits | 0x80 : splitBits) & 0xFF);
|
||
if (!hasMoreBits) {
|
||
return;
|
||
}
|
||
for (let i = 3; i < 31; i = i + 7) {
|
||
const shift = hi >>> i;
|
||
const hasNext = !((shift >>> 7) == 0);
|
||
const byte = (hasNext ? shift | 0x80 : shift) & 0xFF;
|
||
bytes.push(byte);
|
||
if (!hasNext) {
|
||
return;
|
||
}
|
||
}
|
||
bytes.push((hi >>> 31) & 0x01);
|
||
}
|
||
exports.varint64write = varint64write;
|
||
// constants for binary math
|
||
const TWO_PWR_32_DBL = (1 << 16) * (1 << 16);
|
||
/**
|
||
* Parse decimal string of 64 bit integer value as two JS numbers.
|
||
*
|
||
* Returns tuple:
|
||
* [0]: minus sign?
|
||
* [1]: low bits
|
||
* [2]: high bits
|
||
*
|
||
* Copyright 2008 Google Inc.
|
||
*/
|
||
function int64fromString(dec) {
|
||
// Check for minus sign.
|
||
let minus = dec[0] == '-';
|
||
if (minus)
|
||
dec = dec.slice(1);
|
||
// Work 6 decimal digits at a time, acting like we're converting base 1e6
|
||
// digits to binary. This is safe to do with floating point math because
|
||
// Number.isSafeInteger(ALL_32_BITS * 1e6) == true.
|
||
const base = 1e6;
|
||
let lowBits = 0;
|
||
let highBits = 0;
|
||
function add1e6digit(begin, end) {
|
||
// Note: Number('') is 0.
|
||
const digit1e6 = Number(dec.slice(begin, end));
|
||
highBits *= base;
|
||
lowBits = lowBits * base + digit1e6;
|
||
// Carry bits from lowBits to highBits
|
||
if (lowBits >= TWO_PWR_32_DBL) {
|
||
highBits = highBits + ((lowBits / TWO_PWR_32_DBL) | 0);
|
||
lowBits = lowBits % TWO_PWR_32_DBL;
|
||
}
|
||
}
|
||
add1e6digit(-24, -18);
|
||
add1e6digit(-18, -12);
|
||
add1e6digit(-12, -6);
|
||
add1e6digit(-6);
|
||
return [minus, lowBits, highBits];
|
||
}
|
||
exports.int64fromString = int64fromString;
|
||
/**
|
||
* Format 64 bit integer value (as two JS numbers) to decimal string.
|
||
*
|
||
* Copyright 2008 Google Inc.
|
||
*/
|
||
function int64toString(bitsLow, bitsHigh) {
|
||
// Skip the expensive conversion if the number is small enough to use the
|
||
// built-in conversions.
|
||
if ((bitsHigh >>> 0) <= 0x1FFFFF) {
|
||
return '' + (TWO_PWR_32_DBL * bitsHigh + (bitsLow >>> 0));
|
||
}
|
||
// What this code is doing is essentially converting the input number from
|
||
// base-2 to base-1e7, which allows us to represent the 64-bit range with
|
||
// only 3 (very large) digits. Those digits are then trivial to convert to
|
||
// a base-10 string.
|
||
// The magic numbers used here are -
|
||
// 2^24 = 16777216 = (1,6777216) in base-1e7.
|
||
// 2^48 = 281474976710656 = (2,8147497,6710656) in base-1e7.
|
||
// Split 32:32 representation into 16:24:24 representation so our
|
||
// intermediate digits don't overflow.
|
||
let low = bitsLow & 0xFFFFFF;
|
||
let mid = (((bitsLow >>> 24) | (bitsHigh << 8)) >>> 0) & 0xFFFFFF;
|
||
let high = (bitsHigh >> 16) & 0xFFFF;
|
||
// Assemble our three base-1e7 digits, ignoring carries. The maximum
|
||
// value in a digit at this step is representable as a 48-bit integer, which
|
||
// can be stored in a 64-bit floating point number.
|
||
let digitA = low + (mid * 6777216) + (high * 6710656);
|
||
let digitB = mid + (high * 8147497);
|
||
let digitC = (high * 2);
|
||
// Apply carries from A to B and from B to C.
|
||
let base = 10000000;
|
||
if (digitA >= base) {
|
||
digitB += Math.floor(digitA / base);
|
||
digitA %= base;
|
||
}
|
||
if (digitB >= base) {
|
||
digitC += Math.floor(digitB / base);
|
||
digitB %= base;
|
||
}
|
||
// Convert base-1e7 digits to base-10, with optional leading zeroes.
|
||
function decimalFrom1e7(digit1e7, needLeadingZeros) {
|
||
let partial = digit1e7 ? String(digit1e7) : '';
|
||
if (needLeadingZeros) {
|
||
return '0000000'.slice(partial.length) + partial;
|
||
}
|
||
return partial;
|
||
}
|
||
return decimalFrom1e7(digitC, /*needLeadingZeros=*/ 0) +
|
||
decimalFrom1e7(digitB, /*needLeadingZeros=*/ digitC) +
|
||
// If the final 1e7 digit didn't need leading zeros, we would have
|
||
// returned via the trivial code path at the top.
|
||
decimalFrom1e7(digitA, /*needLeadingZeros=*/ 1);
|
||
}
|
||
exports.int64toString = int64toString;
|
||
/**
|
||
* Write a 32 bit varint, signed or unsigned. Same as `varint64write(0, value, bytes)`
|
||
*
|
||
* Copyright 2008 Google Inc. All rights reserved.
|
||
*
|
||
* See https://github.com/protocolbuffers/protobuf/blob/1b18833f4f2a2f681f4e4a25cdf3b0a43115ec26/js/binary/encoder.js#L144
|
||
*/
|
||
function varint32write(value, bytes) {
|
||
if (value >= 0) {
|
||
// write value as varint 32
|
||
while (value > 0x7f) {
|
||
bytes.push((value & 0x7f) | 0x80);
|
||
value = value >>> 7;
|
||
}
|
||
bytes.push(value);
|
||
}
|
||
else {
|
||
for (let i = 0; i < 9; i++) {
|
||
bytes.push(value & 127 | 128);
|
||
value = value >> 7;
|
||
}
|
||
bytes.push(1);
|
||
}
|
||
}
|
||
exports.varint32write = varint32write;
|
||
/**
|
||
* Read an unsigned 32 bit varint.
|
||
*
|
||
* See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L220
|
||
*/
|
||
function varint32read() {
|
||
let b = this.buf[this.pos++];
|
||
let result = b & 0x7F;
|
||
if ((b & 0x80) == 0) {
|
||
this.assertBounds();
|
||
return result;
|
||
}
|
||
b = this.buf[this.pos++];
|
||
result |= (b & 0x7F) << 7;
|
||
if ((b & 0x80) == 0) {
|
||
this.assertBounds();
|
||
return result;
|
||
}
|
||
b = this.buf[this.pos++];
|
||
result |= (b & 0x7F) << 14;
|
||
if ((b & 0x80) == 0) {
|
||
this.assertBounds();
|
||
return result;
|
||
}
|
||
b = this.buf[this.pos++];
|
||
result |= (b & 0x7F) << 21;
|
||
if ((b & 0x80) == 0) {
|
||
this.assertBounds();
|
||
return result;
|
||
}
|
||
// Extract only last 4 bits
|
||
b = this.buf[this.pos++];
|
||
result |= (b & 0x0F) << 28;
|
||
for (let readBytes = 5; ((b & 0x80) !== 0) && readBytes < 10; readBytes++)
|
||
b = this.buf[this.pos++];
|
||
if ((b & 0x80) != 0)
|
||
throw new Error('invalid varint');
|
||
this.assertBounds();
|
||
// Result can have 32 bits, convert it to unsigned
|
||
return result >>> 0;
|
||
}
|
||
exports.varint32read = varint32read;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 68886:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
// Public API of the protobuf-ts runtime.
|
||
// Note: we do not use `export * from ...` to help tree shakers,
|
||
// webpack verbose output hints that this should be useful
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
// Convenience JSON typings and corresponding type guards
|
||
var json_typings_1 = __nccwpck_require__(49999);
|
||
Object.defineProperty(exports, "typeofJsonValue", ({ enumerable: true, get: function () { return json_typings_1.typeofJsonValue; } }));
|
||
Object.defineProperty(exports, "isJsonObject", ({ enumerable: true, get: function () { return json_typings_1.isJsonObject; } }));
|
||
// Base 64 encoding
|
||
var base64_1 = __nccwpck_require__(26335);
|
||
Object.defineProperty(exports, "base64decode", ({ enumerable: true, get: function () { return base64_1.base64decode; } }));
|
||
Object.defineProperty(exports, "base64encode", ({ enumerable: true, get: function () { return base64_1.base64encode; } }));
|
||
// UTF8 encoding
|
||
var protobufjs_utf8_1 = __nccwpck_require__(58950);
|
||
Object.defineProperty(exports, "utf8read", ({ enumerable: true, get: function () { return protobufjs_utf8_1.utf8read; } }));
|
||
// Binary format contracts, options for reading and writing, for example
|
||
var binary_format_contract_1 = __nccwpck_require__(54816);
|
||
Object.defineProperty(exports, "WireType", ({ enumerable: true, get: function () { return binary_format_contract_1.WireType; } }));
|
||
Object.defineProperty(exports, "mergeBinaryOptions", ({ enumerable: true, get: function () { return binary_format_contract_1.mergeBinaryOptions; } }));
|
||
Object.defineProperty(exports, "UnknownFieldHandler", ({ enumerable: true, get: function () { return binary_format_contract_1.UnknownFieldHandler; } }));
|
||
// Standard IBinaryReader implementation
|
||
var binary_reader_1 = __nccwpck_require__(92889);
|
||
Object.defineProperty(exports, "BinaryReader", ({ enumerable: true, get: function () { return binary_reader_1.BinaryReader; } }));
|
||
Object.defineProperty(exports, "binaryReadOptions", ({ enumerable: true, get: function () { return binary_reader_1.binaryReadOptions; } }));
|
||
// Standard IBinaryWriter implementation
|
||
var binary_writer_1 = __nccwpck_require__(23957);
|
||
Object.defineProperty(exports, "BinaryWriter", ({ enumerable: true, get: function () { return binary_writer_1.BinaryWriter; } }));
|
||
Object.defineProperty(exports, "binaryWriteOptions", ({ enumerable: true, get: function () { return binary_writer_1.binaryWriteOptions; } }));
|
||
// Int64 and UInt64 implementations required for the binary format
|
||
var pb_long_1 = __nccwpck_require__(61753);
|
||
Object.defineProperty(exports, "PbLong", ({ enumerable: true, get: function () { return pb_long_1.PbLong; } }));
|
||
Object.defineProperty(exports, "PbULong", ({ enumerable: true, get: function () { return pb_long_1.PbULong; } }));
|
||
// JSON format contracts, options for reading and writing, for example
|
||
var json_format_contract_1 = __nccwpck_require__(29367);
|
||
Object.defineProperty(exports, "jsonReadOptions", ({ enumerable: true, get: function () { return json_format_contract_1.jsonReadOptions; } }));
|
||
Object.defineProperty(exports, "jsonWriteOptions", ({ enumerable: true, get: function () { return json_format_contract_1.jsonWriteOptions; } }));
|
||
Object.defineProperty(exports, "mergeJsonOptions", ({ enumerable: true, get: function () { return json_format_contract_1.mergeJsonOptions; } }));
|
||
// Message type contract
|
||
var message_type_contract_1 = __nccwpck_require__(43785);
|
||
Object.defineProperty(exports, "MESSAGE_TYPE", ({ enumerable: true, get: function () { return message_type_contract_1.MESSAGE_TYPE; } }));
|
||
// Message type implementation via reflection
|
||
var message_type_1 = __nccwpck_require__(15106);
|
||
Object.defineProperty(exports, "MessageType", ({ enumerable: true, get: function () { return message_type_1.MessageType; } }));
|
||
// Reflection info, generated by the plugin, exposed to the user, used by reflection ops
|
||
var reflection_info_1 = __nccwpck_require__(67910);
|
||
Object.defineProperty(exports, "ScalarType", ({ enumerable: true, get: function () { return reflection_info_1.ScalarType; } }));
|
||
Object.defineProperty(exports, "LongType", ({ enumerable: true, get: function () { return reflection_info_1.LongType; } }));
|
||
Object.defineProperty(exports, "RepeatType", ({ enumerable: true, get: function () { return reflection_info_1.RepeatType; } }));
|
||
Object.defineProperty(exports, "normalizeFieldInfo", ({ enumerable: true, get: function () { return reflection_info_1.normalizeFieldInfo; } }));
|
||
Object.defineProperty(exports, "readFieldOptions", ({ enumerable: true, get: function () { return reflection_info_1.readFieldOptions; } }));
|
||
Object.defineProperty(exports, "readFieldOption", ({ enumerable: true, get: function () { return reflection_info_1.readFieldOption; } }));
|
||
Object.defineProperty(exports, "readMessageOption", ({ enumerable: true, get: function () { return reflection_info_1.readMessageOption; } }));
|
||
// Message operations via reflection
|
||
var reflection_type_check_1 = __nccwpck_require__(25167);
|
||
Object.defineProperty(exports, "ReflectionTypeCheck", ({ enumerable: true, get: function () { return reflection_type_check_1.ReflectionTypeCheck; } }));
|
||
var reflection_create_1 = __nccwpck_require__(75726);
|
||
Object.defineProperty(exports, "reflectionCreate", ({ enumerable: true, get: function () { return reflection_create_1.reflectionCreate; } }));
|
||
var reflection_scalar_default_1 = __nccwpck_require__(19526);
|
||
Object.defineProperty(exports, "reflectionScalarDefault", ({ enumerable: true, get: function () { return reflection_scalar_default_1.reflectionScalarDefault; } }));
|
||
var reflection_merge_partial_1 = __nccwpck_require__(98044);
|
||
Object.defineProperty(exports, "reflectionMergePartial", ({ enumerable: true, get: function () { return reflection_merge_partial_1.reflectionMergePartial; } }));
|
||
var reflection_equals_1 = __nccwpck_require__(4827);
|
||
Object.defineProperty(exports, "reflectionEquals", ({ enumerable: true, get: function () { return reflection_equals_1.reflectionEquals; } }));
|
||
var reflection_binary_reader_1 = __nccwpck_require__(89611);
|
||
Object.defineProperty(exports, "ReflectionBinaryReader", ({ enumerable: true, get: function () { return reflection_binary_reader_1.ReflectionBinaryReader; } }));
|
||
var reflection_binary_writer_1 = __nccwpck_require__(66907);
|
||
Object.defineProperty(exports, "ReflectionBinaryWriter", ({ enumerable: true, get: function () { return reflection_binary_writer_1.ReflectionBinaryWriter; } }));
|
||
var reflection_json_reader_1 = __nccwpck_require__(46790);
|
||
Object.defineProperty(exports, "ReflectionJsonReader", ({ enumerable: true, get: function () { return reflection_json_reader_1.ReflectionJsonReader; } }));
|
||
var reflection_json_writer_1 = __nccwpck_require__(11094);
|
||
Object.defineProperty(exports, "ReflectionJsonWriter", ({ enumerable: true, get: function () { return reflection_json_writer_1.ReflectionJsonWriter; } }));
|
||
var reflection_contains_message_type_1 = __nccwpck_require__(59946);
|
||
Object.defineProperty(exports, "containsMessageType", ({ enumerable: true, get: function () { return reflection_contains_message_type_1.containsMessageType; } }));
|
||
// Oneof helpers
|
||
var oneof_1 = __nccwpck_require__(18063);
|
||
Object.defineProperty(exports, "isOneofGroup", ({ enumerable: true, get: function () { return oneof_1.isOneofGroup; } }));
|
||
Object.defineProperty(exports, "setOneofValue", ({ enumerable: true, get: function () { return oneof_1.setOneofValue; } }));
|
||
Object.defineProperty(exports, "getOneofValue", ({ enumerable: true, get: function () { return oneof_1.getOneofValue; } }));
|
||
Object.defineProperty(exports, "clearOneofValue", ({ enumerable: true, get: function () { return oneof_1.clearOneofValue; } }));
|
||
Object.defineProperty(exports, "getSelectedOneofValue", ({ enumerable: true, get: function () { return oneof_1.getSelectedOneofValue; } }));
|
||
// Enum object type guard and reflection util, may be interesting to the user.
|
||
var enum_object_1 = __nccwpck_require__(70257);
|
||
Object.defineProperty(exports, "listEnumValues", ({ enumerable: true, get: function () { return enum_object_1.listEnumValues; } }));
|
||
Object.defineProperty(exports, "listEnumNames", ({ enumerable: true, get: function () { return enum_object_1.listEnumNames; } }));
|
||
Object.defineProperty(exports, "listEnumNumbers", ({ enumerable: true, get: function () { return enum_object_1.listEnumNumbers; } }));
|
||
Object.defineProperty(exports, "isEnumObject", ({ enumerable: true, get: function () { return enum_object_1.isEnumObject; } }));
|
||
// lowerCamelCase() is exported for plugin, rpc-runtime and other rpc packages
|
||
var lower_camel_case_1 = __nccwpck_require__(4073);
|
||
Object.defineProperty(exports, "lowerCamelCase", ({ enumerable: true, get: function () { return lower_camel_case_1.lowerCamelCase; } }));
|
||
// assertion functions are exported for plugin, may also be useful to user
|
||
var assert_1 = __nccwpck_require__(8602);
|
||
Object.defineProperty(exports, "assert", ({ enumerable: true, get: function () { return assert_1.assert; } }));
|
||
Object.defineProperty(exports, "assertNever", ({ enumerable: true, get: function () { return assert_1.assertNever; } }));
|
||
Object.defineProperty(exports, "assertInt32", ({ enumerable: true, get: function () { return assert_1.assertInt32; } }));
|
||
Object.defineProperty(exports, "assertUInt32", ({ enumerable: true, get: function () { return assert_1.assertUInt32; } }));
|
||
Object.defineProperty(exports, "assertFloat32", ({ enumerable: true, get: function () { return assert_1.assertFloat32; } }));
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 29367:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.mergeJsonOptions = exports.jsonWriteOptions = exports.jsonReadOptions = void 0;
|
||
const defaultsWrite = {
|
||
emitDefaultValues: false,
|
||
enumAsInteger: false,
|
||
useProtoFieldName: false,
|
||
prettySpaces: 0,
|
||
}, defaultsRead = {
|
||
ignoreUnknownFields: false,
|
||
};
|
||
/**
|
||
* Make options for reading JSON data from partial options.
|
||
*/
|
||
function jsonReadOptions(options) {
|
||
return options ? Object.assign(Object.assign({}, defaultsRead), options) : defaultsRead;
|
||
}
|
||
exports.jsonReadOptions = jsonReadOptions;
|
||
/**
|
||
* Make options for writing JSON data from partial options.
|
||
*/
|
||
function jsonWriteOptions(options) {
|
||
return options ? Object.assign(Object.assign({}, defaultsWrite), options) : defaultsWrite;
|
||
}
|
||
exports.jsonWriteOptions = jsonWriteOptions;
|
||
/**
|
||
* Merges JSON write or read options. Later values override earlier values. Type registries are merged.
|
||
*/
|
||
function mergeJsonOptions(a, b) {
|
||
var _a, _b;
|
||
let c = Object.assign(Object.assign({}, a), b);
|
||
c.typeRegistry = [...((_a = a === null || a === void 0 ? void 0 : a.typeRegistry) !== null && _a !== void 0 ? _a : []), ...((_b = b === null || b === void 0 ? void 0 : b.typeRegistry) !== null && _b !== void 0 ? _b : [])];
|
||
return c;
|
||
}
|
||
exports.mergeJsonOptions = mergeJsonOptions;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 49999:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.isJsonObject = exports.typeofJsonValue = void 0;
|
||
/**
|
||
* Get the type of a JSON value.
|
||
* Distinguishes between array, null and object.
|
||
*/
|
||
function typeofJsonValue(value) {
|
||
let t = typeof value;
|
||
if (t == "object") {
|
||
if (Array.isArray(value))
|
||
return "array";
|
||
if (value === null)
|
||
return "null";
|
||
}
|
||
return t;
|
||
}
|
||
exports.typeofJsonValue = typeofJsonValue;
|
||
/**
|
||
* Is this a JSON object (instead of an array or null)?
|
||
*/
|
||
function isJsonObject(value) {
|
||
return value !== null && typeof value == "object" && !Array.isArray(value);
|
||
}
|
||
exports.isJsonObject = isJsonObject;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 4073:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.lowerCamelCase = void 0;
|
||
/**
|
||
* Converts snake_case to lowerCamelCase.
|
||
*
|
||
* Should behave like protoc:
|
||
* https://github.com/protocolbuffers/protobuf/blob/e8ae137c96444ea313485ed1118c5e43b2099cf1/src/google/protobuf/compiler/java/java_helpers.cc#L118
|
||
*/
|
||
function lowerCamelCase(snakeCase) {
|
||
let capNext = false;
|
||
const sb = [];
|
||
for (let i = 0; i < snakeCase.length; i++) {
|
||
let next = snakeCase.charAt(i);
|
||
if (next == '_') {
|
||
capNext = true;
|
||
}
|
||
else if (/\d/.test(next)) {
|
||
sb.push(next);
|
||
capNext = true;
|
||
}
|
||
else if (capNext) {
|
||
sb.push(next.toUpperCase());
|
||
capNext = false;
|
||
}
|
||
else if (i == 0) {
|
||
sb.push(next.toLowerCase());
|
||
}
|
||
else {
|
||
sb.push(next);
|
||
}
|
||
}
|
||
return sb.join('');
|
||
}
|
||
exports.lowerCamelCase = lowerCamelCase;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 43785:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.MESSAGE_TYPE = void 0;
|
||
/**
|
||
* The symbol used as a key on message objects to store the message type.
|
||
*
|
||
* Note that this is an experimental feature - it is here to stay, but
|
||
* implementation details may change without notice.
|
||
*/
|
||
exports.MESSAGE_TYPE = Symbol.for("protobuf-ts/message-type");
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 15106:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.MessageType = void 0;
|
||
const message_type_contract_1 = __nccwpck_require__(43785);
|
||
const reflection_info_1 = __nccwpck_require__(67910);
|
||
const reflection_type_check_1 = __nccwpck_require__(25167);
|
||
const reflection_json_reader_1 = __nccwpck_require__(46790);
|
||
const reflection_json_writer_1 = __nccwpck_require__(11094);
|
||
const reflection_binary_reader_1 = __nccwpck_require__(89611);
|
||
const reflection_binary_writer_1 = __nccwpck_require__(66907);
|
||
const reflection_create_1 = __nccwpck_require__(75726);
|
||
const reflection_merge_partial_1 = __nccwpck_require__(98044);
|
||
const json_typings_1 = __nccwpck_require__(49999);
|
||
const json_format_contract_1 = __nccwpck_require__(29367);
|
||
const reflection_equals_1 = __nccwpck_require__(4827);
|
||
const binary_writer_1 = __nccwpck_require__(23957);
|
||
const binary_reader_1 = __nccwpck_require__(92889);
|
||
const baseDescriptors = Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));
|
||
const messageTypeDescriptor = baseDescriptors[message_type_contract_1.MESSAGE_TYPE] = {};
|
||
/**
|
||
* This standard message type provides reflection-based
|
||
* operations to work with a message.
|
||
*/
|
||
class MessageType {
|
||
constructor(name, fields, options) {
|
||
this.defaultCheckDepth = 16;
|
||
this.typeName = name;
|
||
this.fields = fields.map(reflection_info_1.normalizeFieldInfo);
|
||
this.options = options !== null && options !== void 0 ? options : {};
|
||
messageTypeDescriptor.value = this;
|
||
this.messagePrototype = Object.create(null, baseDescriptors);
|
||
this.refTypeCheck = new reflection_type_check_1.ReflectionTypeCheck(this);
|
||
this.refJsonReader = new reflection_json_reader_1.ReflectionJsonReader(this);
|
||
this.refJsonWriter = new reflection_json_writer_1.ReflectionJsonWriter(this);
|
||
this.refBinReader = new reflection_binary_reader_1.ReflectionBinaryReader(this);
|
||
this.refBinWriter = new reflection_binary_writer_1.ReflectionBinaryWriter(this);
|
||
}
|
||
create(value) {
|
||
let message = reflection_create_1.reflectionCreate(this);
|
||
if (value !== undefined) {
|
||
reflection_merge_partial_1.reflectionMergePartial(this, message, value);
|
||
}
|
||
return message;
|
||
}
|
||
/**
|
||
* Clone the message.
|
||
*
|
||
* Unknown fields are discarded.
|
||
*/
|
||
clone(message) {
|
||
let copy = this.create();
|
||
reflection_merge_partial_1.reflectionMergePartial(this, copy, message);
|
||
return copy;
|
||
}
|
||
/**
|
||
* Determines whether two message of the same type have the same field values.
|
||
* Checks for deep equality, traversing repeated fields, oneof groups, maps
|
||
* and messages recursively.
|
||
* Will also return true if both messages are `undefined`.
|
||
*/
|
||
equals(a, b) {
|
||
return reflection_equals_1.reflectionEquals(this, a, b);
|
||
}
|
||
/**
|
||
* Is the given value assignable to our message type
|
||
* and contains no [excess properties](https://www.typescriptlang.org/docs/handbook/interfaces.html#excess-property-checks)?
|
||
*/
|
||
is(arg, depth = this.defaultCheckDepth) {
|
||
return this.refTypeCheck.is(arg, depth, false);
|
||
}
|
||
/**
|
||
* Is the given value assignable to our message type,
|
||
* regardless of [excess properties](https://www.typescriptlang.org/docs/handbook/interfaces.html#excess-property-checks)?
|
||
*/
|
||
isAssignable(arg, depth = this.defaultCheckDepth) {
|
||
return this.refTypeCheck.is(arg, depth, true);
|
||
}
|
||
/**
|
||
* Copy partial data into the target message.
|
||
*/
|
||
mergePartial(target, source) {
|
||
reflection_merge_partial_1.reflectionMergePartial(this, target, source);
|
||
}
|
||
/**
|
||
* Create a new message from binary format.
|
||
*/
|
||
fromBinary(data, options) {
|
||
let opt = binary_reader_1.binaryReadOptions(options);
|
||
return this.internalBinaryRead(opt.readerFactory(data), data.byteLength, opt);
|
||
}
|
||
/**
|
||
* Read a new message from a JSON value.
|
||
*/
|
||
fromJson(json, options) {
|
||
return this.internalJsonRead(json, json_format_contract_1.jsonReadOptions(options));
|
||
}
|
||
/**
|
||
* Read a new message from a JSON string.
|
||
* This is equivalent to `T.fromJson(JSON.parse(json))`.
|
||
*/
|
||
fromJsonString(json, options) {
|
||
let value = JSON.parse(json);
|
||
return this.fromJson(value, options);
|
||
}
|
||
/**
|
||
* Write the message to canonical JSON value.
|
||
*/
|
||
toJson(message, options) {
|
||
return this.internalJsonWrite(message, json_format_contract_1.jsonWriteOptions(options));
|
||
}
|
||
/**
|
||
* Convert the message to canonical JSON string.
|
||
* This is equivalent to `JSON.stringify(T.toJson(t))`
|
||
*/
|
||
toJsonString(message, options) {
|
||
var _a;
|
||
let value = this.toJson(message, options);
|
||
return JSON.stringify(value, null, (_a = options === null || options === void 0 ? void 0 : options.prettySpaces) !== null && _a !== void 0 ? _a : 0);
|
||
}
|
||
/**
|
||
* Write the message to binary format.
|
||
*/
|
||
toBinary(message, options) {
|
||
let opt = binary_writer_1.binaryWriteOptions(options);
|
||
return this.internalBinaryWrite(message, opt.writerFactory(), opt).finish();
|
||
}
|
||
/**
|
||
* This is an internal method. If you just want to read a message from
|
||
* JSON, use `fromJson()` or `fromJsonString()`.
|
||
*
|
||
* Reads JSON value and merges the fields into the target
|
||
* according to protobuf rules. If the target is omitted,
|
||
* a new instance is created first.
|
||
*/
|
||
internalJsonRead(json, options, target) {
|
||
if (json !== null && typeof json == "object" && !Array.isArray(json)) {
|
||
let message = target !== null && target !== void 0 ? target : this.create();
|
||
this.refJsonReader.read(json, message, options);
|
||
return message;
|
||
}
|
||
throw new Error(`Unable to parse message ${this.typeName} from JSON ${json_typings_1.typeofJsonValue(json)}.`);
|
||
}
|
||
/**
|
||
* This is an internal method. If you just want to write a message
|
||
* to JSON, use `toJson()` or `toJsonString().
|
||
*
|
||
* Writes JSON value and returns it.
|
||
*/
|
||
internalJsonWrite(message, options) {
|
||
return this.refJsonWriter.write(message, options);
|
||
}
|
||
/**
|
||
* This is an internal method. If you just want to write a message
|
||
* in binary format, use `toBinary()`.
|
||
*
|
||
* Serializes the message in binary format and appends it to the given
|
||
* writer. Returns passed writer.
|
||
*/
|
||
internalBinaryWrite(message, writer, options) {
|
||
this.refBinWriter.write(message, writer, options);
|
||
return writer;
|
||
}
|
||
/**
|
||
* This is an internal method. If you just want to read a message from
|
||
* binary data, use `fromBinary()`.
|
||
*
|
||
* Reads data from binary format and merges the fields into
|
||
* the target according to protobuf rules. If the target is
|
||
* omitted, a new instance is created first.
|
||
*/
|
||
internalBinaryRead(reader, length, options, target) {
|
||
let message = target !== null && target !== void 0 ? target : this.create();
|
||
this.refBinReader.read(reader, message, options, length);
|
||
return message;
|
||
}
|
||
}
|
||
exports.MessageType = MessageType;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 18063:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.getSelectedOneofValue = exports.clearOneofValue = exports.setUnknownOneofValue = exports.setOneofValue = exports.getOneofValue = exports.isOneofGroup = void 0;
|
||
/**
|
||
* Is the given value a valid oneof group?
|
||
*
|
||
* We represent protobuf `oneof` as algebraic data types (ADT) in generated
|
||
* code. But when working with messages of unknown type, the ADT does not
|
||
* help us.
|
||
*
|
||
* This type guard checks if the given object adheres to the ADT rules, which
|
||
* are as follows:
|
||
*
|
||
* 1) Must be an object.
|
||
*
|
||
* 2) Must have a "oneofKind" discriminator property.
|
||
*
|
||
* 3) If "oneofKind" is `undefined`, no member field is selected. The object
|
||
* must not have any other properties.
|
||
*
|
||
* 4) If "oneofKind" is a `string`, the member field with this name is
|
||
* selected.
|
||
*
|
||
* 5) If a member field is selected, the object must have a second property
|
||
* with this name. The property must not be `undefined`.
|
||
*
|
||
* 6) No extra properties are allowed. The object has either one property
|
||
* (no selection) or two properties (selection).
|
||
*
|
||
*/
|
||
function isOneofGroup(any) {
|
||
if (typeof any != 'object' || any === null || !any.hasOwnProperty('oneofKind')) {
|
||
return false;
|
||
}
|
||
switch (typeof any.oneofKind) {
|
||
case "string":
|
||
if (any[any.oneofKind] === undefined)
|
||
return false;
|
||
return Object.keys(any).length == 2;
|
||
case "undefined":
|
||
return Object.keys(any).length == 1;
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
exports.isOneofGroup = isOneofGroup;
|
||
/**
|
||
* Returns the value of the given field in a oneof group.
|
||
*/
|
||
function getOneofValue(oneof, kind) {
|
||
return oneof[kind];
|
||
}
|
||
exports.getOneofValue = getOneofValue;
|
||
function setOneofValue(oneof, kind, value) {
|
||
if (oneof.oneofKind !== undefined) {
|
||
delete oneof[oneof.oneofKind];
|
||
}
|
||
oneof.oneofKind = kind;
|
||
if (value !== undefined) {
|
||
oneof[kind] = value;
|
||
}
|
||
}
|
||
exports.setOneofValue = setOneofValue;
|
||
function setUnknownOneofValue(oneof, kind, value) {
|
||
if (oneof.oneofKind !== undefined) {
|
||
delete oneof[oneof.oneofKind];
|
||
}
|
||
oneof.oneofKind = kind;
|
||
if (value !== undefined && kind !== undefined) {
|
||
oneof[kind] = value;
|
||
}
|
||
}
|
||
exports.setUnknownOneofValue = setUnknownOneofValue;
|
||
/**
|
||
* Removes the selected field in a oneof group.
|
||
*
|
||
* Note that the recommended way to modify a oneof group is to set
|
||
* a new object:
|
||
*
|
||
* ```ts
|
||
* message.result = { oneofKind: undefined };
|
||
* ```
|
||
*/
|
||
function clearOneofValue(oneof) {
|
||
if (oneof.oneofKind !== undefined) {
|
||
delete oneof[oneof.oneofKind];
|
||
}
|
||
oneof.oneofKind = undefined;
|
||
}
|
||
exports.clearOneofValue = clearOneofValue;
|
||
/**
|
||
* Returns the selected value of the given oneof group.
|
||
*
|
||
* Not that the recommended way to access a oneof group is to check
|
||
* the "oneofKind" property and let TypeScript narrow down the union
|
||
* type for you:
|
||
*
|
||
* ```ts
|
||
* if (message.result.oneofKind === "error") {
|
||
* message.result.error; // string
|
||
* }
|
||
* ```
|
||
*
|
||
* In the rare case you just need the value, and do not care about
|
||
* which protobuf field is selected, you can use this function
|
||
* for convenience.
|
||
*/
|
||
function getSelectedOneofValue(oneof) {
|
||
if (oneof.oneofKind === undefined) {
|
||
return undefined;
|
||
}
|
||
return oneof[oneof.oneofKind];
|
||
}
|
||
exports.getSelectedOneofValue = getSelectedOneofValue;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 61753:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.PbLong = exports.PbULong = exports.detectBi = void 0;
|
||
const goog_varint_1 = __nccwpck_require__(93223);
|
||
let BI;
|
||
function detectBi() {
|
||
const dv = new DataView(new ArrayBuffer(8));
|
||
const ok = globalThis.BigInt !== undefined
|
||
&& typeof dv.getBigInt64 === "function"
|
||
&& typeof dv.getBigUint64 === "function"
|
||
&& typeof dv.setBigInt64 === "function"
|
||
&& typeof dv.setBigUint64 === "function";
|
||
BI = ok ? {
|
||
MIN: BigInt("-9223372036854775808"),
|
||
MAX: BigInt("9223372036854775807"),
|
||
UMIN: BigInt("0"),
|
||
UMAX: BigInt("18446744073709551615"),
|
||
C: BigInt,
|
||
V: dv,
|
||
} : undefined;
|
||
}
|
||
exports.detectBi = detectBi;
|
||
detectBi();
|
||
function assertBi(bi) {
|
||
if (!bi)
|
||
throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support");
|
||
}
|
||
// used to validate from(string) input (when bigint is unavailable)
|
||
const RE_DECIMAL_STR = /^-?[0-9]+$/;
|
||
// constants for binary math
|
||
const TWO_PWR_32_DBL = 0x100000000;
|
||
const HALF_2_PWR_32 = 0x080000000;
|
||
// base class for PbLong and PbULong provides shared code
|
||
class SharedPbLong {
|
||
/**
|
||
* Create a new instance with the given bits.
|
||
*/
|
||
constructor(lo, hi) {
|
||
this.lo = lo | 0;
|
||
this.hi = hi | 0;
|
||
}
|
||
/**
|
||
* Is this instance equal to 0?
|
||
*/
|
||
isZero() {
|
||
return this.lo == 0 && this.hi == 0;
|
||
}
|
||
/**
|
||
* Convert to a native number.
|
||
*/
|
||
toNumber() {
|
||
let result = this.hi * TWO_PWR_32_DBL + (this.lo >>> 0);
|
||
if (!Number.isSafeInteger(result))
|
||
throw new Error("cannot convert to safe number");
|
||
return result;
|
||
}
|
||
}
|
||
/**
|
||
* 64-bit unsigned integer as two 32-bit values.
|
||
* Converts between `string`, `number` and `bigint` representations.
|
||
*/
|
||
class PbULong extends SharedPbLong {
|
||
/**
|
||
* Create instance from a `string`, `number` or `bigint`.
|
||
*/
|
||
static from(value) {
|
||
if (BI)
|
||
// noinspection FallThroughInSwitchStatementJS
|
||
switch (typeof value) {
|
||
case "string":
|
||
if (value == "0")
|
||
return this.ZERO;
|
||
if (value == "")
|
||
throw new Error('string is no integer');
|
||
value = BI.C(value);
|
||
case "number":
|
||
if (value === 0)
|
||
return this.ZERO;
|
||
value = BI.C(value);
|
||
case "bigint":
|
||
if (!value)
|
||
return this.ZERO;
|
||
if (value < BI.UMIN)
|
||
throw new Error('signed value for ulong');
|
||
if (value > BI.UMAX)
|
||
throw new Error('ulong too large');
|
||
BI.V.setBigUint64(0, value, true);
|
||
return new PbULong(BI.V.getInt32(0, true), BI.V.getInt32(4, true));
|
||
}
|
||
else
|
||
switch (typeof value) {
|
||
case "string":
|
||
if (value == "0")
|
||
return this.ZERO;
|
||
value = value.trim();
|
||
if (!RE_DECIMAL_STR.test(value))
|
||
throw new Error('string is no integer');
|
||
let [minus, lo, hi] = goog_varint_1.int64fromString(value);
|
||
if (minus)
|
||
throw new Error('signed value for ulong');
|
||
return new PbULong(lo, hi);
|
||
case "number":
|
||
if (value == 0)
|
||
return this.ZERO;
|
||
if (!Number.isSafeInteger(value))
|
||
throw new Error('number is no integer');
|
||
if (value < 0)
|
||
throw new Error('signed value for ulong');
|
||
return new PbULong(value, value / TWO_PWR_32_DBL);
|
||
}
|
||
throw new Error('unknown value ' + typeof value);
|
||
}
|
||
/**
|
||
* Convert to decimal string.
|
||
*/
|
||
toString() {
|
||
return BI ? this.toBigInt().toString() : goog_varint_1.int64toString(this.lo, this.hi);
|
||
}
|
||
/**
|
||
* Convert to native bigint.
|
||
*/
|
||
toBigInt() {
|
||
assertBi(BI);
|
||
BI.V.setInt32(0, this.lo, true);
|
||
BI.V.setInt32(4, this.hi, true);
|
||
return BI.V.getBigUint64(0, true);
|
||
}
|
||
}
|
||
exports.PbULong = PbULong;
|
||
/**
|
||
* ulong 0 singleton.
|
||
*/
|
||
PbULong.ZERO = new PbULong(0, 0);
|
||
/**
|
||
* 64-bit signed integer as two 32-bit values.
|
||
* Converts between `string`, `number` and `bigint` representations.
|
||
*/
|
||
class PbLong extends SharedPbLong {
|
||
/**
|
||
* Create instance from a `string`, `number` or `bigint`.
|
||
*/
|
||
static from(value) {
|
||
if (BI)
|
||
// noinspection FallThroughInSwitchStatementJS
|
||
switch (typeof value) {
|
||
case "string":
|
||
if (value == "0")
|
||
return this.ZERO;
|
||
if (value == "")
|
||
throw new Error('string is no integer');
|
||
value = BI.C(value);
|
||
case "number":
|
||
if (value === 0)
|
||
return this.ZERO;
|
||
value = BI.C(value);
|
||
case "bigint":
|
||
if (!value)
|
||
return this.ZERO;
|
||
if (value < BI.MIN)
|
||
throw new Error('signed long too small');
|
||
if (value > BI.MAX)
|
||
throw new Error('signed long too large');
|
||
BI.V.setBigInt64(0, value, true);
|
||
return new PbLong(BI.V.getInt32(0, true), BI.V.getInt32(4, true));
|
||
}
|
||
else
|
||
switch (typeof value) {
|
||
case "string":
|
||
if (value == "0")
|
||
return this.ZERO;
|
||
value = value.trim();
|
||
if (!RE_DECIMAL_STR.test(value))
|
||
throw new Error('string is no integer');
|
||
let [minus, lo, hi] = goog_varint_1.int64fromString(value);
|
||
if (minus) {
|
||
if (hi > HALF_2_PWR_32 || (hi == HALF_2_PWR_32 && lo != 0))
|
||
throw new Error('signed long too small');
|
||
}
|
||
else if (hi >= HALF_2_PWR_32)
|
||
throw new Error('signed long too large');
|
||
let pbl = new PbLong(lo, hi);
|
||
return minus ? pbl.negate() : pbl;
|
||
case "number":
|
||
if (value == 0)
|
||
return this.ZERO;
|
||
if (!Number.isSafeInteger(value))
|
||
throw new Error('number is no integer');
|
||
return value > 0
|
||
? new PbLong(value, value / TWO_PWR_32_DBL)
|
||
: new PbLong(-value, -value / TWO_PWR_32_DBL).negate();
|
||
}
|
||
throw new Error('unknown value ' + typeof value);
|
||
}
|
||
/**
|
||
* Do we have a minus sign?
|
||
*/
|
||
isNegative() {
|
||
return (this.hi & HALF_2_PWR_32) !== 0;
|
||
}
|
||
/**
|
||
* Negate two's complement.
|
||
* Invert all the bits and add one to the result.
|
||
*/
|
||
negate() {
|
||
let hi = ~this.hi, lo = this.lo;
|
||
if (lo)
|
||
lo = ~lo + 1;
|
||
else
|
||
hi += 1;
|
||
return new PbLong(lo, hi);
|
||
}
|
||
/**
|
||
* Convert to decimal string.
|
||
*/
|
||
toString() {
|
||
if (BI)
|
||
return this.toBigInt().toString();
|
||
if (this.isNegative()) {
|
||
let n = this.negate();
|
||
return '-' + goog_varint_1.int64toString(n.lo, n.hi);
|
||
}
|
||
return goog_varint_1.int64toString(this.lo, this.hi);
|
||
}
|
||
/**
|
||
* Convert to native bigint.
|
||
*/
|
||
toBigInt() {
|
||
assertBi(BI);
|
||
BI.V.setInt32(0, this.lo, true);
|
||
BI.V.setInt32(4, this.hi, true);
|
||
return BI.V.getBigInt64(0, true);
|
||
}
|
||
}
|
||
exports.PbLong = PbLong;
|
||
/**
|
||
* long 0 singleton.
|
||
*/
|
||
PbLong.ZERO = new PbLong(0, 0);
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 58950:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
// Copyright (c) 2016, Daniel Wirtz All rights reserved.
|
||
//
|
||
// Redistribution and use in source and binary forms, with or without
|
||
// modification, are permitted provided that the following conditions are
|
||
// met:
|
||
//
|
||
// * Redistributions of source code must retain the above copyright
|
||
// notice, this list of conditions and the following disclaimer.
|
||
// * Redistributions in binary form must reproduce the above copyright
|
||
// notice, this list of conditions and the following disclaimer in the
|
||
// documentation and/or other materials provided with the distribution.
|
||
// * Neither the name of its author, nor the names of its contributors
|
||
// may be used to endorse or promote products derived from this software
|
||
// without specific prior written permission.
|
||
//
|
||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.utf8read = void 0;
|
||
const fromCharCodes = (chunk) => String.fromCharCode.apply(String, chunk);
|
||
/**
|
||
* @deprecated This function will no longer be exported with the next major
|
||
* release, since protobuf-ts has switch to TextDecoder API. If you need this
|
||
* function, please migrate to @protobufjs/utf8. For context, see
|
||
* https://github.com/timostamm/protobuf-ts/issues/184
|
||
*
|
||
* Reads UTF8 bytes as a string.
|
||
*
|
||
* See [protobufjs / utf8](https://github.com/protobufjs/protobuf.js/blob/9893e35b854621cce64af4bf6be2cff4fb892796/lib/utf8/index.js#L40)
|
||
*
|
||
* Copyright (c) 2016, Daniel Wirtz
|
||
*/
|
||
function utf8read(bytes) {
|
||
if (bytes.length < 1)
|
||
return "";
|
||
let pos = 0, // position in bytes
|
||
parts = [], chunk = [], i = 0, // char offset
|
||
t; // temporary
|
||
let len = bytes.length;
|
||
while (pos < len) {
|
||
t = bytes[pos++];
|
||
if (t < 128)
|
||
chunk[i++] = t;
|
||
else if (t > 191 && t < 224)
|
||
chunk[i++] = (t & 31) << 6 | bytes[pos++] & 63;
|
||
else if (t > 239 && t < 365) {
|
||
t = ((t & 7) << 18 | (bytes[pos++] & 63) << 12 | (bytes[pos++] & 63) << 6 | bytes[pos++] & 63) - 0x10000;
|
||
chunk[i++] = 0xD800 + (t >> 10);
|
||
chunk[i++] = 0xDC00 + (t & 1023);
|
||
}
|
||
else
|
||
chunk[i++] = (t & 15) << 12 | (bytes[pos++] & 63) << 6 | bytes[pos++] & 63;
|
||
if (i > 8191) {
|
||
parts.push(fromCharCodes(chunk));
|
||
i = 0;
|
||
}
|
||
}
|
||
if (parts.length) {
|
||
if (i)
|
||
parts.push(fromCharCodes(chunk.slice(0, i)));
|
||
return parts.join("");
|
||
}
|
||
return fromCharCodes(chunk.slice(0, i));
|
||
}
|
||
exports.utf8read = utf8read;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 89611:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.ReflectionBinaryReader = void 0;
|
||
const binary_format_contract_1 = __nccwpck_require__(54816);
|
||
const reflection_info_1 = __nccwpck_require__(67910);
|
||
const reflection_long_convert_1 = __nccwpck_require__(63402);
|
||
const reflection_scalar_default_1 = __nccwpck_require__(19526);
|
||
/**
|
||
* Reads proto3 messages in binary format using reflection information.
|
||
*
|
||
* https://developers.google.com/protocol-buffers/docs/encoding
|
||
*/
|
||
class ReflectionBinaryReader {
|
||
constructor(info) {
|
||
this.info = info;
|
||
}
|
||
prepare() {
|
||
var _a;
|
||
if (!this.fieldNoToField) {
|
||
const fieldsInput = (_a = this.info.fields) !== null && _a !== void 0 ? _a : [];
|
||
this.fieldNoToField = new Map(fieldsInput.map(field => [field.no, field]));
|
||
}
|
||
}
|
||
/**
|
||
* Reads a message from binary format into the target message.
|
||
*
|
||
* Repeated fields are appended. Map entries are added, overwriting
|
||
* existing keys.
|
||
*
|
||
* If a message field is already present, it will be merged with the
|
||
* new data.
|
||
*/
|
||
read(reader, message, options, length) {
|
||
this.prepare();
|
||
const end = length === undefined ? reader.len : reader.pos + length;
|
||
while (reader.pos < end) {
|
||
// read the tag and find the field
|
||
const [fieldNo, wireType] = reader.tag(), field = this.fieldNoToField.get(fieldNo);
|
||
if (!field) {
|
||
let u = options.readUnknownField;
|
||
if (u == "throw")
|
||
throw new Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.info.typeName}`);
|
||
let d = reader.skip(wireType);
|
||
if (u !== false)
|
||
(u === true ? binary_format_contract_1.UnknownFieldHandler.onRead : u)(this.info.typeName, message, fieldNo, wireType, d);
|
||
continue;
|
||
}
|
||
// target object for the field we are reading
|
||
let target = message, repeated = field.repeat, localName = field.localName;
|
||
// if field is member of oneof ADT, use ADT as target
|
||
if (field.oneof) {
|
||
target = target[field.oneof];
|
||
// if other oneof member selected, set new ADT
|
||
if (target.oneofKind !== localName)
|
||
target = message[field.oneof] = {
|
||
oneofKind: localName
|
||
};
|
||
}
|
||
// we have handled oneof above, we just have read the value into `target[localName]`
|
||
switch (field.kind) {
|
||
case "scalar":
|
||
case "enum":
|
||
let T = field.kind == "enum" ? reflection_info_1.ScalarType.INT32 : field.T;
|
||
let L = field.kind == "scalar" ? field.L : undefined;
|
||
if (repeated) {
|
||
let arr = target[localName]; // safe to assume presence of array, oneof cannot contain repeated values
|
||
if (wireType == binary_format_contract_1.WireType.LengthDelimited && T != reflection_info_1.ScalarType.STRING && T != reflection_info_1.ScalarType.BYTES) {
|
||
let e = reader.uint32() + reader.pos;
|
||
while (reader.pos < e)
|
||
arr.push(this.scalar(reader, T, L));
|
||
}
|
||
else
|
||
arr.push(this.scalar(reader, T, L));
|
||
}
|
||
else
|
||
target[localName] = this.scalar(reader, T, L);
|
||
break;
|
||
case "message":
|
||
if (repeated) {
|
||
let arr = target[localName]; // safe to assume presence of array, oneof cannot contain repeated values
|
||
let msg = field.T().internalBinaryRead(reader, reader.uint32(), options);
|
||
arr.push(msg);
|
||
}
|
||
else
|
||
target[localName] = field.T().internalBinaryRead(reader, reader.uint32(), options, target[localName]);
|
||
break;
|
||
case "map":
|
||
let [mapKey, mapVal] = this.mapEntry(field, reader, options);
|
||
// safe to assume presence of map object, oneof cannot contain repeated values
|
||
target[localName][mapKey] = mapVal;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Read a map field, expecting key field = 1, value field = 2
|
||
*/
|
||
mapEntry(field, reader, options) {
|
||
let length = reader.uint32();
|
||
let end = reader.pos + length;
|
||
let key = undefined; // javascript only allows number or string for object properties
|
||
let val = undefined;
|
||
while (reader.pos < end) {
|
||
let [fieldNo, wireType] = reader.tag();
|
||
switch (fieldNo) {
|
||
case 1:
|
||
if (field.K == reflection_info_1.ScalarType.BOOL)
|
||
key = reader.bool().toString();
|
||
else
|
||
// long types are read as string, number types are okay as number
|
||
key = this.scalar(reader, field.K, reflection_info_1.LongType.STRING);
|
||
break;
|
||
case 2:
|
||
switch (field.V.kind) {
|
||
case "scalar":
|
||
val = this.scalar(reader, field.V.T, field.V.L);
|
||
break;
|
||
case "enum":
|
||
val = reader.int32();
|
||
break;
|
||
case "message":
|
||
val = field.V.T().internalBinaryRead(reader, reader.uint32(), options);
|
||
break;
|
||
}
|
||
break;
|
||
default:
|
||
throw new Error(`Unknown field ${fieldNo} (wire type ${wireType}) in map entry for ${this.info.typeName}#${field.name}`);
|
||
}
|
||
}
|
||
if (key === undefined) {
|
||
let keyRaw = reflection_scalar_default_1.reflectionScalarDefault(field.K);
|
||
key = field.K == reflection_info_1.ScalarType.BOOL ? keyRaw.toString() : keyRaw;
|
||
}
|
||
if (val === undefined)
|
||
switch (field.V.kind) {
|
||
case "scalar":
|
||
val = reflection_scalar_default_1.reflectionScalarDefault(field.V.T, field.V.L);
|
||
break;
|
||
case "enum":
|
||
val = 0;
|
||
break;
|
||
case "message":
|
||
val = field.V.T().create();
|
||
break;
|
||
}
|
||
return [key, val];
|
||
}
|
||
scalar(reader, type, longType) {
|
||
switch (type) {
|
||
case reflection_info_1.ScalarType.INT32:
|
||
return reader.int32();
|
||
case reflection_info_1.ScalarType.STRING:
|
||
return reader.string();
|
||
case reflection_info_1.ScalarType.BOOL:
|
||
return reader.bool();
|
||
case reflection_info_1.ScalarType.DOUBLE:
|
||
return reader.double();
|
||
case reflection_info_1.ScalarType.FLOAT:
|
||
return reader.float();
|
||
case reflection_info_1.ScalarType.INT64:
|
||
return reflection_long_convert_1.reflectionLongConvert(reader.int64(), longType);
|
||
case reflection_info_1.ScalarType.UINT64:
|
||
return reflection_long_convert_1.reflectionLongConvert(reader.uint64(), longType);
|
||
case reflection_info_1.ScalarType.FIXED64:
|
||
return reflection_long_convert_1.reflectionLongConvert(reader.fixed64(), longType);
|
||
case reflection_info_1.ScalarType.FIXED32:
|
||
return reader.fixed32();
|
||
case reflection_info_1.ScalarType.BYTES:
|
||
return reader.bytes();
|
||
case reflection_info_1.ScalarType.UINT32:
|
||
return reader.uint32();
|
||
case reflection_info_1.ScalarType.SFIXED32:
|
||
return reader.sfixed32();
|
||
case reflection_info_1.ScalarType.SFIXED64:
|
||
return reflection_long_convert_1.reflectionLongConvert(reader.sfixed64(), longType);
|
||
case reflection_info_1.ScalarType.SINT32:
|
||
return reader.sint32();
|
||
case reflection_info_1.ScalarType.SINT64:
|
||
return reflection_long_convert_1.reflectionLongConvert(reader.sint64(), longType);
|
||
}
|
||
}
|
||
}
|
||
exports.ReflectionBinaryReader = ReflectionBinaryReader;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 66907:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.ReflectionBinaryWriter = void 0;
|
||
const binary_format_contract_1 = __nccwpck_require__(54816);
|
||
const reflection_info_1 = __nccwpck_require__(67910);
|
||
const assert_1 = __nccwpck_require__(8602);
|
||
const pb_long_1 = __nccwpck_require__(61753);
|
||
/**
|
||
* Writes proto3 messages in binary format using reflection information.
|
||
*
|
||
* https://developers.google.com/protocol-buffers/docs/encoding
|
||
*/
|
||
class ReflectionBinaryWriter {
|
||
constructor(info) {
|
||
this.info = info;
|
||
}
|
||
prepare() {
|
||
if (!this.fields) {
|
||
const fieldsInput = this.info.fields ? this.info.fields.concat() : [];
|
||
this.fields = fieldsInput.sort((a, b) => a.no - b.no);
|
||
}
|
||
}
|
||
/**
|
||
* Writes the message to binary format.
|
||
*/
|
||
write(message, writer, options) {
|
||
this.prepare();
|
||
for (const field of this.fields) {
|
||
let value, // this will be our field value, whether it is member of a oneof or not
|
||
emitDefault, // whether we emit the default value (only true for oneof members)
|
||
repeated = field.repeat, localName = field.localName;
|
||
// handle oneof ADT
|
||
if (field.oneof) {
|
||
const group = message[field.oneof];
|
||
if (group.oneofKind !== localName)
|
||
continue; // if field is not selected, skip
|
||
value = group[localName];
|
||
emitDefault = true;
|
||
}
|
||
else {
|
||
value = message[localName];
|
||
emitDefault = false;
|
||
}
|
||
// we have handled oneof above. we just have to honor `emitDefault`.
|
||
switch (field.kind) {
|
||
case "scalar":
|
||
case "enum":
|
||
let T = field.kind == "enum" ? reflection_info_1.ScalarType.INT32 : field.T;
|
||
if (repeated) {
|
||
assert_1.assert(Array.isArray(value));
|
||
if (repeated == reflection_info_1.RepeatType.PACKED)
|
||
this.packed(writer, T, field.no, value);
|
||
else
|
||
for (const item of value)
|
||
this.scalar(writer, T, field.no, item, true);
|
||
}
|
||
else if (value === undefined)
|
||
assert_1.assert(field.opt);
|
||
else
|
||
this.scalar(writer, T, field.no, value, emitDefault || field.opt);
|
||
break;
|
||
case "message":
|
||
if (repeated) {
|
||
assert_1.assert(Array.isArray(value));
|
||
for (const item of value)
|
||
this.message(writer, options, field.T(), field.no, item);
|
||
}
|
||
else {
|
||
this.message(writer, options, field.T(), field.no, value);
|
||
}
|
||
break;
|
||
case "map":
|
||
assert_1.assert(typeof value == 'object' && value !== null);
|
||
for (const [key, val] of Object.entries(value))
|
||
this.mapEntry(writer, options, field, key, val);
|
||
break;
|
||
}
|
||
}
|
||
let u = options.writeUnknownFields;
|
||
if (u !== false)
|
||
(u === true ? binary_format_contract_1.UnknownFieldHandler.onWrite : u)(this.info.typeName, message, writer);
|
||
}
|
||
mapEntry(writer, options, field, key, value) {
|
||
writer.tag(field.no, binary_format_contract_1.WireType.LengthDelimited);
|
||
writer.fork();
|
||
// javascript only allows number or string for object properties
|
||
// we convert from our representation to the protobuf type
|
||
let keyValue = key;
|
||
switch (field.K) {
|
||
case reflection_info_1.ScalarType.INT32:
|
||
case reflection_info_1.ScalarType.FIXED32:
|
||
case reflection_info_1.ScalarType.UINT32:
|
||
case reflection_info_1.ScalarType.SFIXED32:
|
||
case reflection_info_1.ScalarType.SINT32:
|
||
keyValue = Number.parseInt(key);
|
||
break;
|
||
case reflection_info_1.ScalarType.BOOL:
|
||
assert_1.assert(key == 'true' || key == 'false');
|
||
keyValue = key == 'true';
|
||
break;
|
||
}
|
||
// write key, expecting key field number = 1
|
||
this.scalar(writer, field.K, 1, keyValue, true);
|
||
// write value, expecting value field number = 2
|
||
switch (field.V.kind) {
|
||
case 'scalar':
|
||
this.scalar(writer, field.V.T, 2, value, true);
|
||
break;
|
||
case 'enum':
|
||
this.scalar(writer, reflection_info_1.ScalarType.INT32, 2, value, true);
|
||
break;
|
||
case 'message':
|
||
this.message(writer, options, field.V.T(), 2, value);
|
||
break;
|
||
}
|
||
writer.join();
|
||
}
|
||
message(writer, options, handler, fieldNo, value) {
|
||
if (value === undefined)
|
||
return;
|
||
handler.internalBinaryWrite(value, writer.tag(fieldNo, binary_format_contract_1.WireType.LengthDelimited).fork(), options);
|
||
writer.join();
|
||
}
|
||
/**
|
||
* Write a single scalar value.
|
||
*/
|
||
scalar(writer, type, fieldNo, value, emitDefault) {
|
||
let [wireType, method, isDefault] = this.scalarInfo(type, value);
|
||
if (!isDefault || emitDefault) {
|
||
writer.tag(fieldNo, wireType);
|
||
writer[method](value);
|
||
}
|
||
}
|
||
/**
|
||
* Write an array of scalar values in packed format.
|
||
*/
|
||
packed(writer, type, fieldNo, value) {
|
||
if (!value.length)
|
||
return;
|
||
assert_1.assert(type !== reflection_info_1.ScalarType.BYTES && type !== reflection_info_1.ScalarType.STRING);
|
||
// write tag
|
||
writer.tag(fieldNo, binary_format_contract_1.WireType.LengthDelimited);
|
||
// begin length-delimited
|
||
writer.fork();
|
||
// write values without tags
|
||
let [, method,] = this.scalarInfo(type);
|
||
for (let i = 0; i < value.length; i++)
|
||
writer[method](value[i]);
|
||
// end length delimited
|
||
writer.join();
|
||
}
|
||
/**
|
||
* Get information for writing a scalar value.
|
||
*
|
||
* Returns tuple:
|
||
* [0]: appropriate WireType
|
||
* [1]: name of the appropriate method of IBinaryWriter
|
||
* [2]: whether the given value is a default value
|
||
*
|
||
* If argument `value` is omitted, [2] is always false.
|
||
*/
|
||
scalarInfo(type, value) {
|
||
let t = binary_format_contract_1.WireType.Varint;
|
||
let m;
|
||
let i = value === undefined;
|
||
let d = value === 0;
|
||
switch (type) {
|
||
case reflection_info_1.ScalarType.INT32:
|
||
m = "int32";
|
||
break;
|
||
case reflection_info_1.ScalarType.STRING:
|
||
d = i || !value.length;
|
||
t = binary_format_contract_1.WireType.LengthDelimited;
|
||
m = "string";
|
||
break;
|
||
case reflection_info_1.ScalarType.BOOL:
|
||
d = value === false;
|
||
m = "bool";
|
||
break;
|
||
case reflection_info_1.ScalarType.UINT32:
|
||
m = "uint32";
|
||
break;
|
||
case reflection_info_1.ScalarType.DOUBLE:
|
||
t = binary_format_contract_1.WireType.Bit64;
|
||
m = "double";
|
||
break;
|
||
case reflection_info_1.ScalarType.FLOAT:
|
||
t = binary_format_contract_1.WireType.Bit32;
|
||
m = "float";
|
||
break;
|
||
case reflection_info_1.ScalarType.INT64:
|
||
d = i || pb_long_1.PbLong.from(value).isZero();
|
||
m = "int64";
|
||
break;
|
||
case reflection_info_1.ScalarType.UINT64:
|
||
d = i || pb_long_1.PbULong.from(value).isZero();
|
||
m = "uint64";
|
||
break;
|
||
case reflection_info_1.ScalarType.FIXED64:
|
||
d = i || pb_long_1.PbULong.from(value).isZero();
|
||
t = binary_format_contract_1.WireType.Bit64;
|
||
m = "fixed64";
|
||
break;
|
||
case reflection_info_1.ScalarType.BYTES:
|
||
d = i || !value.byteLength;
|
||
t = binary_format_contract_1.WireType.LengthDelimited;
|
||
m = "bytes";
|
||
break;
|
||
case reflection_info_1.ScalarType.FIXED32:
|
||
t = binary_format_contract_1.WireType.Bit32;
|
||
m = "fixed32";
|
||
break;
|
||
case reflection_info_1.ScalarType.SFIXED32:
|
||
t = binary_format_contract_1.WireType.Bit32;
|
||
m = "sfixed32";
|
||
break;
|
||
case reflection_info_1.ScalarType.SFIXED64:
|
||
d = i || pb_long_1.PbLong.from(value).isZero();
|
||
t = binary_format_contract_1.WireType.Bit64;
|
||
m = "sfixed64";
|
||
break;
|
||
case reflection_info_1.ScalarType.SINT32:
|
||
m = "sint32";
|
||
break;
|
||
case reflection_info_1.ScalarType.SINT64:
|
||
d = i || pb_long_1.PbLong.from(value).isZero();
|
||
m = "sint64";
|
||
break;
|
||
}
|
||
return [t, m, i || d];
|
||
}
|
||
}
|
||
exports.ReflectionBinaryWriter = ReflectionBinaryWriter;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 59946:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.containsMessageType = void 0;
|
||
const message_type_contract_1 = __nccwpck_require__(43785);
|
||
/**
|
||
* Check if the provided object is a proto message.
|
||
*
|
||
* Note that this is an experimental feature - it is here to stay, but
|
||
* implementation details may change without notice.
|
||
*/
|
||
function containsMessageType(msg) {
|
||
return msg[message_type_contract_1.MESSAGE_TYPE] != null;
|
||
}
|
||
exports.containsMessageType = containsMessageType;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 75726:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.reflectionCreate = void 0;
|
||
const reflection_scalar_default_1 = __nccwpck_require__(19526);
|
||
const message_type_contract_1 = __nccwpck_require__(43785);
|
||
/**
|
||
* Creates an instance of the generic message, using the field
|
||
* information.
|
||
*/
|
||
function reflectionCreate(type) {
|
||
/**
|
||
* This ternary can be removed in the next major version.
|
||
* The `Object.create()` code path utilizes a new `messagePrototype`
|
||
* property on the `IMessageType` which has this same `MESSAGE_TYPE`
|
||
* non-enumerable property on it. Doing it this way means that we only
|
||
* pay the cost of `Object.defineProperty()` once per `IMessageType`
|
||
* class of once per "instance". The falsy code path is only provided
|
||
* for backwards compatibility in cases where the runtime library is
|
||
* updated without also updating the generated code.
|
||
*/
|
||
const msg = type.messagePrototype
|
||
? Object.create(type.messagePrototype)
|
||
: Object.defineProperty({}, message_type_contract_1.MESSAGE_TYPE, { value: type });
|
||
for (let field of type.fields) {
|
||
let name = field.localName;
|
||
if (field.opt)
|
||
continue;
|
||
if (field.oneof)
|
||
msg[field.oneof] = { oneofKind: undefined };
|
||
else if (field.repeat)
|
||
msg[name] = [];
|
||
else
|
||
switch (field.kind) {
|
||
case "scalar":
|
||
msg[name] = reflection_scalar_default_1.reflectionScalarDefault(field.T, field.L);
|
||
break;
|
||
case "enum":
|
||
// we require 0 to be default value for all enums
|
||
msg[name] = 0;
|
||
break;
|
||
case "map":
|
||
msg[name] = {};
|
||
break;
|
||
}
|
||
}
|
||
return msg;
|
||
}
|
||
exports.reflectionCreate = reflectionCreate;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 4827:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.reflectionEquals = void 0;
|
||
const reflection_info_1 = __nccwpck_require__(67910);
|
||
/**
|
||
* Determines whether two message of the same type have the same field values.
|
||
* Checks for deep equality, traversing repeated fields, oneof groups, maps
|
||
* and messages recursively.
|
||
* Will also return true if both messages are `undefined`.
|
||
*/
|
||
function reflectionEquals(info, a, b) {
|
||
if (a === b)
|
||
return true;
|
||
if (!a || !b)
|
||
return false;
|
||
for (let field of info.fields) {
|
||
let localName = field.localName;
|
||
let val_a = field.oneof ? a[field.oneof][localName] : a[localName];
|
||
let val_b = field.oneof ? b[field.oneof][localName] : b[localName];
|
||
switch (field.kind) {
|
||
case "enum":
|
||
case "scalar":
|
||
let t = field.kind == "enum" ? reflection_info_1.ScalarType.INT32 : field.T;
|
||
if (!(field.repeat
|
||
? repeatedPrimitiveEq(t, val_a, val_b)
|
||
: primitiveEq(t, val_a, val_b)))
|
||
return false;
|
||
break;
|
||
case "map":
|
||
if (!(field.V.kind == "message"
|
||
? repeatedMsgEq(field.V.T(), objectValues(val_a), objectValues(val_b))
|
||
: repeatedPrimitiveEq(field.V.kind == "enum" ? reflection_info_1.ScalarType.INT32 : field.V.T, objectValues(val_a), objectValues(val_b))))
|
||
return false;
|
||
break;
|
||
case "message":
|
||
let T = field.T();
|
||
if (!(field.repeat
|
||
? repeatedMsgEq(T, val_a, val_b)
|
||
: T.equals(val_a, val_b)))
|
||
return false;
|
||
break;
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
exports.reflectionEquals = reflectionEquals;
|
||
const objectValues = Object.values;
|
||
function primitiveEq(type, a, b) {
|
||
if (a === b)
|
||
return true;
|
||
if (type !== reflection_info_1.ScalarType.BYTES)
|
||
return false;
|
||
let ba = a;
|
||
let bb = b;
|
||
if (ba.length !== bb.length)
|
||
return false;
|
||
for (let i = 0; i < ba.length; i++)
|
||
if (ba[i] != bb[i])
|
||
return false;
|
||
return true;
|
||
}
|
||
function repeatedPrimitiveEq(type, a, b) {
|
||
if (a.length !== b.length)
|
||
return false;
|
||
for (let i = 0; i < a.length; i++)
|
||
if (!primitiveEq(type, a[i], b[i]))
|
||
return false;
|
||
return true;
|
||
}
|
||
function repeatedMsgEq(type, a, b) {
|
||
if (a.length !== b.length)
|
||
return false;
|
||
for (let i = 0; i < a.length; i++)
|
||
if (!type.equals(a[i], b[i]))
|
||
return false;
|
||
return true;
|
||
}
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 67910:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.readMessageOption = exports.readFieldOption = exports.readFieldOptions = exports.normalizeFieldInfo = exports.RepeatType = exports.LongType = exports.ScalarType = void 0;
|
||
const lower_camel_case_1 = __nccwpck_require__(4073);
|
||
/**
|
||
* Scalar value types. This is a subset of field types declared by protobuf
|
||
* enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE
|
||
* are omitted, but the numerical values are identical.
|
||
*/
|
||
var ScalarType;
|
||
(function (ScalarType) {
|
||
// 0 is reserved for errors.
|
||
// Order is weird for historical reasons.
|
||
ScalarType[ScalarType["DOUBLE"] = 1] = "DOUBLE";
|
||
ScalarType[ScalarType["FLOAT"] = 2] = "FLOAT";
|
||
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
|
||
// negative values are likely.
|
||
ScalarType[ScalarType["INT64"] = 3] = "INT64";
|
||
ScalarType[ScalarType["UINT64"] = 4] = "UINT64";
|
||
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
|
||
// negative values are likely.
|
||
ScalarType[ScalarType["INT32"] = 5] = "INT32";
|
||
ScalarType[ScalarType["FIXED64"] = 6] = "FIXED64";
|
||
ScalarType[ScalarType["FIXED32"] = 7] = "FIXED32";
|
||
ScalarType[ScalarType["BOOL"] = 8] = "BOOL";
|
||
ScalarType[ScalarType["STRING"] = 9] = "STRING";
|
||
// Tag-delimited aggregate.
|
||
// Group type is deprecated and not supported in proto3. However, Proto3
|
||
// implementations should still be able to parse the group wire format and
|
||
// treat group fields as unknown fields.
|
||
// TYPE_GROUP = 10,
|
||
// TYPE_MESSAGE = 11, // Length-delimited aggregate.
|
||
// New in version 2.
|
||
ScalarType[ScalarType["BYTES"] = 12] = "BYTES";
|
||
ScalarType[ScalarType["UINT32"] = 13] = "UINT32";
|
||
// TYPE_ENUM = 14,
|
||
ScalarType[ScalarType["SFIXED32"] = 15] = "SFIXED32";
|
||
ScalarType[ScalarType["SFIXED64"] = 16] = "SFIXED64";
|
||
ScalarType[ScalarType["SINT32"] = 17] = "SINT32";
|
||
ScalarType[ScalarType["SINT64"] = 18] = "SINT64";
|
||
})(ScalarType = exports.ScalarType || (exports.ScalarType = {}));
|
||
/**
|
||
* JavaScript representation of 64 bit integral types. Equivalent to the
|
||
* field option "jstype".
|
||
*
|
||
* By default, protobuf-ts represents 64 bit types as `bigint`.
|
||
*
|
||
* You can change the default behaviour by enabling the plugin parameter
|
||
* `long_type_string`, which will represent 64 bit types as `string`.
|
||
*
|
||
* Alternatively, you can change the behaviour for individual fields
|
||
* with the field option "jstype":
|
||
*
|
||
* ```protobuf
|
||
* uint64 my_field = 1 [jstype = JS_STRING];
|
||
* uint64 other_field = 2 [jstype = JS_NUMBER];
|
||
* ```
|
||
*/
|
||
var LongType;
|
||
(function (LongType) {
|
||
/**
|
||
* Use JavaScript `bigint`.
|
||
*
|
||
* Field option `[jstype = JS_NORMAL]`.
|
||
*/
|
||
LongType[LongType["BIGINT"] = 0] = "BIGINT";
|
||
/**
|
||
* Use JavaScript `string`.
|
||
*
|
||
* Field option `[jstype = JS_STRING]`.
|
||
*/
|
||
LongType[LongType["STRING"] = 1] = "STRING";
|
||
/**
|
||
* Use JavaScript `number`.
|
||
*
|
||
* Large values will loose precision.
|
||
*
|
||
* Field option `[jstype = JS_NUMBER]`.
|
||
*/
|
||
LongType[LongType["NUMBER"] = 2] = "NUMBER";
|
||
})(LongType = exports.LongType || (exports.LongType = {}));
|
||
/**
|
||
* Protobuf 2.1.0 introduced packed repeated fields.
|
||
* Setting the field option `[packed = true]` enables packing.
|
||
*
|
||
* In proto3, all repeated fields are packed by default.
|
||
* Setting the field option `[packed = false]` disables packing.
|
||
*
|
||
* Packed repeated fields are encoded with a single tag,
|
||
* then a length-delimiter, then the element values.
|
||
*
|
||
* Unpacked repeated fields are encoded with a tag and
|
||
* value for each element.
|
||
*
|
||
* `bytes` and `string` cannot be packed.
|
||
*/
|
||
var RepeatType;
|
||
(function (RepeatType) {
|
||
/**
|
||
* The field is not repeated.
|
||
*/
|
||
RepeatType[RepeatType["NO"] = 0] = "NO";
|
||
/**
|
||
* The field is repeated and should be packed.
|
||
* Invalid for `bytes` and `string`, they cannot be packed.
|
||
*/
|
||
RepeatType[RepeatType["PACKED"] = 1] = "PACKED";
|
||
/**
|
||
* The field is repeated but should not be packed.
|
||
* The only valid repeat type for repeated `bytes` and `string`.
|
||
*/
|
||
RepeatType[RepeatType["UNPACKED"] = 2] = "UNPACKED";
|
||
})(RepeatType = exports.RepeatType || (exports.RepeatType = {}));
|
||
/**
|
||
* Turns PartialFieldInfo into FieldInfo.
|
||
*/
|
||
function normalizeFieldInfo(field) {
|
||
var _a, _b, _c, _d;
|
||
field.localName = (_a = field.localName) !== null && _a !== void 0 ? _a : lower_camel_case_1.lowerCamelCase(field.name);
|
||
field.jsonName = (_b = field.jsonName) !== null && _b !== void 0 ? _b : lower_camel_case_1.lowerCamelCase(field.name);
|
||
field.repeat = (_c = field.repeat) !== null && _c !== void 0 ? _c : RepeatType.NO;
|
||
field.opt = (_d = field.opt) !== null && _d !== void 0 ? _d : (field.repeat ? false : field.oneof ? false : field.kind == "message");
|
||
return field;
|
||
}
|
||
exports.normalizeFieldInfo = normalizeFieldInfo;
|
||
/**
|
||
* Read custom field options from a generated message type.
|
||
*
|
||
* @deprecated use readFieldOption()
|
||
*/
|
||
function readFieldOptions(messageType, fieldName, extensionName, extensionType) {
|
||
var _a;
|
||
const options = (_a = messageType.fields.find((m, i) => m.localName == fieldName || i == fieldName)) === null || _a === void 0 ? void 0 : _a.options;
|
||
return options && options[extensionName] ? extensionType.fromJson(options[extensionName]) : undefined;
|
||
}
|
||
exports.readFieldOptions = readFieldOptions;
|
||
function readFieldOption(messageType, fieldName, extensionName, extensionType) {
|
||
var _a;
|
||
const options = (_a = messageType.fields.find((m, i) => m.localName == fieldName || i == fieldName)) === null || _a === void 0 ? void 0 : _a.options;
|
||
if (!options) {
|
||
return undefined;
|
||
}
|
||
const optionVal = options[extensionName];
|
||
if (optionVal === undefined) {
|
||
return optionVal;
|
||
}
|
||
return extensionType ? extensionType.fromJson(optionVal) : optionVal;
|
||
}
|
||
exports.readFieldOption = readFieldOption;
|
||
function readMessageOption(messageType, extensionName, extensionType) {
|
||
const options = messageType.options;
|
||
const optionVal = options[extensionName];
|
||
if (optionVal === undefined) {
|
||
return optionVal;
|
||
}
|
||
return extensionType ? extensionType.fromJson(optionVal) : optionVal;
|
||
}
|
||
exports.readMessageOption = readMessageOption;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 46790:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.ReflectionJsonReader = void 0;
|
||
const json_typings_1 = __nccwpck_require__(49999);
|
||
const base64_1 = __nccwpck_require__(26335);
|
||
const reflection_info_1 = __nccwpck_require__(67910);
|
||
const pb_long_1 = __nccwpck_require__(61753);
|
||
const assert_1 = __nccwpck_require__(8602);
|
||
const reflection_long_convert_1 = __nccwpck_require__(63402);
|
||
/**
|
||
* Reads proto3 messages in canonical JSON format using reflection information.
|
||
*
|
||
* https://developers.google.com/protocol-buffers/docs/proto3#json
|
||
*/
|
||
class ReflectionJsonReader {
|
||
constructor(info) {
|
||
this.info = info;
|
||
}
|
||
prepare() {
|
||
var _a;
|
||
if (this.fMap === undefined) {
|
||
this.fMap = {};
|
||
const fieldsInput = (_a = this.info.fields) !== null && _a !== void 0 ? _a : [];
|
||
for (const field of fieldsInput) {
|
||
this.fMap[field.name] = field;
|
||
this.fMap[field.jsonName] = field;
|
||
this.fMap[field.localName] = field;
|
||
}
|
||
}
|
||
}
|
||
// Cannot parse JSON <type of jsonValue> for <type name>#<fieldName>.
|
||
assert(condition, fieldName, jsonValue) {
|
||
if (!condition) {
|
||
let what = json_typings_1.typeofJsonValue(jsonValue);
|
||
if (what == "number" || what == "boolean")
|
||
what = jsonValue.toString();
|
||
throw new Error(`Cannot parse JSON ${what} for ${this.info.typeName}#${fieldName}`);
|
||
}
|
||
}
|
||
/**
|
||
* Reads a message from canonical JSON format into the target message.
|
||
*
|
||
* Repeated fields are appended. Map entries are added, overwriting
|
||
* existing keys.
|
||
*
|
||
* If a message field is already present, it will be merged with the
|
||
* new data.
|
||
*/
|
||
read(input, message, options) {
|
||
this.prepare();
|
||
const oneofsHandled = [];
|
||
for (const [jsonKey, jsonValue] of Object.entries(input)) {
|
||
const field = this.fMap[jsonKey];
|
||
if (!field) {
|
||
if (!options.ignoreUnknownFields)
|
||
throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${jsonKey}`);
|
||
continue;
|
||
}
|
||
const localName = field.localName;
|
||
// handle oneof ADT
|
||
let target; // this will be the target for the field value, whether it is member of a oneof or not
|
||
if (field.oneof) {
|
||
if (jsonValue === null && (field.kind !== 'enum' || field.T()[0] !== 'google.protobuf.NullValue')) {
|
||
continue;
|
||
}
|
||
// since json objects are unordered by specification, it is not possible to take the last of multiple oneofs
|
||
if (oneofsHandled.includes(field.oneof))
|
||
throw new Error(`Multiple members of the oneof group "${field.oneof}" of ${this.info.typeName} are present in JSON.`);
|
||
oneofsHandled.push(field.oneof);
|
||
target = message[field.oneof] = {
|
||
oneofKind: localName
|
||
};
|
||
}
|
||
else {
|
||
target = message;
|
||
}
|
||
// we have handled oneof above. we just have read the value into `target`.
|
||
if (field.kind == 'map') {
|
||
if (jsonValue === null) {
|
||
continue;
|
||
}
|
||
// check input
|
||
this.assert(json_typings_1.isJsonObject(jsonValue), field.name, jsonValue);
|
||
// our target to put map entries into
|
||
const fieldObj = target[localName];
|
||
// read entries
|
||
for (const [jsonObjKey, jsonObjValue] of Object.entries(jsonValue)) {
|
||
this.assert(jsonObjValue !== null, field.name + " map value", null);
|
||
// read value
|
||
let val;
|
||
switch (field.V.kind) {
|
||
case "message":
|
||
val = field.V.T().internalJsonRead(jsonObjValue, options);
|
||
break;
|
||
case "enum":
|
||
val = this.enum(field.V.T(), jsonObjValue, field.name, options.ignoreUnknownFields);
|
||
if (val === false)
|
||
continue;
|
||
break;
|
||
case "scalar":
|
||
val = this.scalar(jsonObjValue, field.V.T, field.V.L, field.name);
|
||
break;
|
||
}
|
||
this.assert(val !== undefined, field.name + " map value", jsonObjValue);
|
||
// read key
|
||
let key = jsonObjKey;
|
||
if (field.K == reflection_info_1.ScalarType.BOOL)
|
||
key = key == "true" ? true : key == "false" ? false : key;
|
||
key = this.scalar(key, field.K, reflection_info_1.LongType.STRING, field.name).toString();
|
||
fieldObj[key] = val;
|
||
}
|
||
}
|
||
else if (field.repeat) {
|
||
if (jsonValue === null)
|
||
continue;
|
||
// check input
|
||
this.assert(Array.isArray(jsonValue), field.name, jsonValue);
|
||
// our target to put array entries into
|
||
const fieldArr = target[localName];
|
||
// read array entries
|
||
for (const jsonItem of jsonValue) {
|
||
this.assert(jsonItem !== null, field.name, null);
|
||
let val;
|
||
switch (field.kind) {
|
||
case "message":
|
||
val = field.T().internalJsonRead(jsonItem, options);
|
||
break;
|
||
case "enum":
|
||
val = this.enum(field.T(), jsonItem, field.name, options.ignoreUnknownFields);
|
||
if (val === false)
|
||
continue;
|
||
break;
|
||
case "scalar":
|
||
val = this.scalar(jsonItem, field.T, field.L, field.name);
|
||
break;
|
||
}
|
||
this.assert(val !== undefined, field.name, jsonValue);
|
||
fieldArr.push(val);
|
||
}
|
||
}
|
||
else {
|
||
switch (field.kind) {
|
||
case "message":
|
||
if (jsonValue === null && field.T().typeName != 'google.protobuf.Value') {
|
||
this.assert(field.oneof === undefined, field.name + " (oneof member)", null);
|
||
continue;
|
||
}
|
||
target[localName] = field.T().internalJsonRead(jsonValue, options, target[localName]);
|
||
break;
|
||
case "enum":
|
||
if (jsonValue === null)
|
||
continue;
|
||
let val = this.enum(field.T(), jsonValue, field.name, options.ignoreUnknownFields);
|
||
if (val === false)
|
||
continue;
|
||
target[localName] = val;
|
||
break;
|
||
case "scalar":
|
||
if (jsonValue === null)
|
||
continue;
|
||
target[localName] = this.scalar(jsonValue, field.T, field.L, field.name);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Returns `false` for unrecognized string representations.
|
||
*
|
||
* google.protobuf.NullValue accepts only JSON `null` (or the old `"NULL_VALUE"`).
|
||
*/
|
||
enum(type, json, fieldName, ignoreUnknownFields) {
|
||
if (type[0] == 'google.protobuf.NullValue')
|
||
assert_1.assert(json === null || json === "NULL_VALUE", `Unable to parse field ${this.info.typeName}#${fieldName}, enum ${type[0]} only accepts null.`);
|
||
if (json === null)
|
||
// we require 0 to be default value for all enums
|
||
return 0;
|
||
switch (typeof json) {
|
||
case "number":
|
||
assert_1.assert(Number.isInteger(json), `Unable to parse field ${this.info.typeName}#${fieldName}, enum can only be integral number, got ${json}.`);
|
||
return json;
|
||
case "string":
|
||
let localEnumName = json;
|
||
if (type[2] && json.substring(0, type[2].length) === type[2])
|
||
// lookup without the shared prefix
|
||
localEnumName = json.substring(type[2].length);
|
||
let enumNumber = type[1][localEnumName];
|
||
if (typeof enumNumber === 'undefined' && ignoreUnknownFields) {
|
||
return false;
|
||
}
|
||
assert_1.assert(typeof enumNumber == "number", `Unable to parse field ${this.info.typeName}#${fieldName}, enum ${type[0]} has no value for "${json}".`);
|
||
return enumNumber;
|
||
}
|
||
assert_1.assert(false, `Unable to parse field ${this.info.typeName}#${fieldName}, cannot parse enum value from ${typeof json}".`);
|
||
}
|
||
scalar(json, type, longType, fieldName) {
|
||
let e;
|
||
try {
|
||
switch (type) {
|
||
// float, double: JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity".
|
||
// Either numbers or strings are accepted. Exponent notation is also accepted.
|
||
case reflection_info_1.ScalarType.DOUBLE:
|
||
case reflection_info_1.ScalarType.FLOAT:
|
||
if (json === null)
|
||
return .0;
|
||
if (json === "NaN")
|
||
return Number.NaN;
|
||
if (json === "Infinity")
|
||
return Number.POSITIVE_INFINITY;
|
||
if (json === "-Infinity")
|
||
return Number.NEGATIVE_INFINITY;
|
||
if (json === "") {
|
||
e = "empty string";
|
||
break;
|
||
}
|
||
if (typeof json == "string" && json.trim().length !== json.length) {
|
||
e = "extra whitespace";
|
||
break;
|
||
}
|
||
if (typeof json != "string" && typeof json != "number") {
|
||
break;
|
||
}
|
||
let float = Number(json);
|
||
if (Number.isNaN(float)) {
|
||
e = "not a number";
|
||
break;
|
||
}
|
||
if (!Number.isFinite(float)) {
|
||
// infinity and -infinity are handled by string representation above, so this is an error
|
||
e = "too large or small";
|
||
break;
|
||
}
|
||
if (type == reflection_info_1.ScalarType.FLOAT)
|
||
assert_1.assertFloat32(float);
|
||
return float;
|
||
// int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted.
|
||
case reflection_info_1.ScalarType.INT32:
|
||
case reflection_info_1.ScalarType.FIXED32:
|
||
case reflection_info_1.ScalarType.SFIXED32:
|
||
case reflection_info_1.ScalarType.SINT32:
|
||
case reflection_info_1.ScalarType.UINT32:
|
||
if (json === null)
|
||
return 0;
|
||
let int32;
|
||
if (typeof json == "number")
|
||
int32 = json;
|
||
else if (json === "")
|
||
e = "empty string";
|
||
else if (typeof json == "string") {
|
||
if (json.trim().length !== json.length)
|
||
e = "extra whitespace";
|
||
else
|
||
int32 = Number(json);
|
||
}
|
||
if (int32 === undefined)
|
||
break;
|
||
if (type == reflection_info_1.ScalarType.UINT32)
|
||
assert_1.assertUInt32(int32);
|
||
else
|
||
assert_1.assertInt32(int32);
|
||
return int32;
|
||
// int64, fixed64, uint64: JSON value will be a decimal string. Either numbers or strings are accepted.
|
||
case reflection_info_1.ScalarType.INT64:
|
||
case reflection_info_1.ScalarType.SFIXED64:
|
||
case reflection_info_1.ScalarType.SINT64:
|
||
if (json === null)
|
||
return reflection_long_convert_1.reflectionLongConvert(pb_long_1.PbLong.ZERO, longType);
|
||
if (typeof json != "number" && typeof json != "string")
|
||
break;
|
||
return reflection_long_convert_1.reflectionLongConvert(pb_long_1.PbLong.from(json), longType);
|
||
case reflection_info_1.ScalarType.FIXED64:
|
||
case reflection_info_1.ScalarType.UINT64:
|
||
if (json === null)
|
||
return reflection_long_convert_1.reflectionLongConvert(pb_long_1.PbULong.ZERO, longType);
|
||
if (typeof json != "number" && typeof json != "string")
|
||
break;
|
||
return reflection_long_convert_1.reflectionLongConvert(pb_long_1.PbULong.from(json), longType);
|
||
// bool:
|
||
case reflection_info_1.ScalarType.BOOL:
|
||
if (json === null)
|
||
return false;
|
||
if (typeof json !== "boolean")
|
||
break;
|
||
return json;
|
||
// string:
|
||
case reflection_info_1.ScalarType.STRING:
|
||
if (json === null)
|
||
return "";
|
||
if (typeof json !== "string") {
|
||
e = "extra whitespace";
|
||
break;
|
||
}
|
||
try {
|
||
encodeURIComponent(json);
|
||
}
|
||
catch (e) {
|
||
e = "invalid UTF8";
|
||
break;
|
||
}
|
||
return json;
|
||
// bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings.
|
||
// Either standard or URL-safe base64 encoding with/without paddings are accepted.
|
||
case reflection_info_1.ScalarType.BYTES:
|
||
if (json === null || json === "")
|
||
return new Uint8Array(0);
|
||
if (typeof json !== 'string')
|
||
break;
|
||
return base64_1.base64decode(json);
|
||
}
|
||
}
|
||
catch (error) {
|
||
e = error.message;
|
||
}
|
||
this.assert(false, fieldName + (e ? " - " + e : ""), json);
|
||
}
|
||
}
|
||
exports.ReflectionJsonReader = ReflectionJsonReader;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 11094:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.ReflectionJsonWriter = void 0;
|
||
const base64_1 = __nccwpck_require__(26335);
|
||
const pb_long_1 = __nccwpck_require__(61753);
|
||
const reflection_info_1 = __nccwpck_require__(67910);
|
||
const assert_1 = __nccwpck_require__(8602);
|
||
/**
|
||
* Writes proto3 messages in canonical JSON format using reflection
|
||
* information.
|
||
*
|
||
* https://developers.google.com/protocol-buffers/docs/proto3#json
|
||
*/
|
||
class ReflectionJsonWriter {
|
||
constructor(info) {
|
||
var _a;
|
||
this.fields = (_a = info.fields) !== null && _a !== void 0 ? _a : [];
|
||
}
|
||
/**
|
||
* Converts the message to a JSON object, based on the field descriptors.
|
||
*/
|
||
write(message, options) {
|
||
const json = {}, source = message;
|
||
for (const field of this.fields) {
|
||
// field is not part of a oneof, simply write as is
|
||
if (!field.oneof) {
|
||
let jsonValue = this.field(field, source[field.localName], options);
|
||
if (jsonValue !== undefined)
|
||
json[options.useProtoFieldName ? field.name : field.jsonName] = jsonValue;
|
||
continue;
|
||
}
|
||
// field is part of a oneof
|
||
const group = source[field.oneof];
|
||
if (group.oneofKind !== field.localName)
|
||
continue; // not selected, skip
|
||
const opt = field.kind == 'scalar' || field.kind == 'enum'
|
||
? Object.assign(Object.assign({}, options), { emitDefaultValues: true }) : options;
|
||
let jsonValue = this.field(field, group[field.localName], opt);
|
||
assert_1.assert(jsonValue !== undefined);
|
||
json[options.useProtoFieldName ? field.name : field.jsonName] = jsonValue;
|
||
}
|
||
return json;
|
||
}
|
||
field(field, value, options) {
|
||
let jsonValue = undefined;
|
||
if (field.kind == 'map') {
|
||
assert_1.assert(typeof value == "object" && value !== null);
|
||
const jsonObj = {};
|
||
switch (field.V.kind) {
|
||
case "scalar":
|
||
for (const [entryKey, entryValue] of Object.entries(value)) {
|
||
const val = this.scalar(field.V.T, entryValue, field.name, false, true);
|
||
assert_1.assert(val !== undefined);
|
||
jsonObj[entryKey.toString()] = val; // JSON standard allows only (double quoted) string as property key
|
||
}
|
||
break;
|
||
case "message":
|
||
const messageType = field.V.T();
|
||
for (const [entryKey, entryValue] of Object.entries(value)) {
|
||
const val = this.message(messageType, entryValue, field.name, options);
|
||
assert_1.assert(val !== undefined);
|
||
jsonObj[entryKey.toString()] = val; // JSON standard allows only (double quoted) string as property key
|
||
}
|
||
break;
|
||
case "enum":
|
||
const enumInfo = field.V.T();
|
||
for (const [entryKey, entryValue] of Object.entries(value)) {
|
||
assert_1.assert(entryValue === undefined || typeof entryValue == 'number');
|
||
const val = this.enum(enumInfo, entryValue, field.name, false, true, options.enumAsInteger);
|
||
assert_1.assert(val !== undefined);
|
||
jsonObj[entryKey.toString()] = val; // JSON standard allows only (double quoted) string as property key
|
||
}
|
||
break;
|
||
}
|
||
if (options.emitDefaultValues || Object.keys(jsonObj).length > 0)
|
||
jsonValue = jsonObj;
|
||
}
|
||
else if (field.repeat) {
|
||
assert_1.assert(Array.isArray(value));
|
||
const jsonArr = [];
|
||
switch (field.kind) {
|
||
case "scalar":
|
||
for (let i = 0; i < value.length; i++) {
|
||
const val = this.scalar(field.T, value[i], field.name, field.opt, true);
|
||
assert_1.assert(val !== undefined);
|
||
jsonArr.push(val);
|
||
}
|
||
break;
|
||
case "enum":
|
||
const enumInfo = field.T();
|
||
for (let i = 0; i < value.length; i++) {
|
||
assert_1.assert(value[i] === undefined || typeof value[i] == 'number');
|
||
const val = this.enum(enumInfo, value[i], field.name, field.opt, true, options.enumAsInteger);
|
||
assert_1.assert(val !== undefined);
|
||
jsonArr.push(val);
|
||
}
|
||
break;
|
||
case "message":
|
||
const messageType = field.T();
|
||
for (let i = 0; i < value.length; i++) {
|
||
const val = this.message(messageType, value[i], field.name, options);
|
||
assert_1.assert(val !== undefined);
|
||
jsonArr.push(val);
|
||
}
|
||
break;
|
||
}
|
||
// add converted array to json output
|
||
if (options.emitDefaultValues || jsonArr.length > 0 || options.emitDefaultValues)
|
||
jsonValue = jsonArr;
|
||
}
|
||
else {
|
||
switch (field.kind) {
|
||
case "scalar":
|
||
jsonValue = this.scalar(field.T, value, field.name, field.opt, options.emitDefaultValues);
|
||
break;
|
||
case "enum":
|
||
jsonValue = this.enum(field.T(), value, field.name, field.opt, options.emitDefaultValues, options.enumAsInteger);
|
||
break;
|
||
case "message":
|
||
jsonValue = this.message(field.T(), value, field.name, options);
|
||
break;
|
||
}
|
||
}
|
||
return jsonValue;
|
||
}
|
||
/**
|
||
* Returns `null` as the default for google.protobuf.NullValue.
|
||
*/
|
||
enum(type, value, fieldName, optional, emitDefaultValues, enumAsInteger) {
|
||
if (type[0] == 'google.protobuf.NullValue')
|
||
return !emitDefaultValues && !optional ? undefined : null;
|
||
if (value === undefined) {
|
||
assert_1.assert(optional);
|
||
return undefined;
|
||
}
|
||
if (value === 0 && !emitDefaultValues && !optional)
|
||
// we require 0 to be default value for all enums
|
||
return undefined;
|
||
assert_1.assert(typeof value == 'number');
|
||
assert_1.assert(Number.isInteger(value));
|
||
if (enumAsInteger || !type[1].hasOwnProperty(value))
|
||
// if we don't now the enum value, just return the number
|
||
return value;
|
||
if (type[2])
|
||
// restore the dropped prefix
|
||
return type[2] + type[1][value];
|
||
return type[1][value];
|
||
}
|
||
message(type, value, fieldName, options) {
|
||
if (value === undefined)
|
||
return options.emitDefaultValues ? null : undefined;
|
||
return type.internalJsonWrite(value, options);
|
||
}
|
||
scalar(type, value, fieldName, optional, emitDefaultValues) {
|
||
if (value === undefined) {
|
||
assert_1.assert(optional);
|
||
return undefined;
|
||
}
|
||
const ed = emitDefaultValues || optional;
|
||
// noinspection FallThroughInSwitchStatementJS
|
||
switch (type) {
|
||
// int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted.
|
||
case reflection_info_1.ScalarType.INT32:
|
||
case reflection_info_1.ScalarType.SFIXED32:
|
||
case reflection_info_1.ScalarType.SINT32:
|
||
if (value === 0)
|
||
return ed ? 0 : undefined;
|
||
assert_1.assertInt32(value);
|
||
return value;
|
||
case reflection_info_1.ScalarType.FIXED32:
|
||
case reflection_info_1.ScalarType.UINT32:
|
||
if (value === 0)
|
||
return ed ? 0 : undefined;
|
||
assert_1.assertUInt32(value);
|
||
return value;
|
||
// float, double: JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity".
|
||
// Either numbers or strings are accepted. Exponent notation is also accepted.
|
||
case reflection_info_1.ScalarType.FLOAT:
|
||
assert_1.assertFloat32(value);
|
||
case reflection_info_1.ScalarType.DOUBLE:
|
||
if (value === 0)
|
||
return ed ? 0 : undefined;
|
||
assert_1.assert(typeof value == 'number');
|
||
if (Number.isNaN(value))
|
||
return 'NaN';
|
||
if (value === Number.POSITIVE_INFINITY)
|
||
return 'Infinity';
|
||
if (value === Number.NEGATIVE_INFINITY)
|
||
return '-Infinity';
|
||
return value;
|
||
// string:
|
||
case reflection_info_1.ScalarType.STRING:
|
||
if (value === "")
|
||
return ed ? '' : undefined;
|
||
assert_1.assert(typeof value == 'string');
|
||
return value;
|
||
// bool:
|
||
case reflection_info_1.ScalarType.BOOL:
|
||
if (value === false)
|
||
return ed ? false : undefined;
|
||
assert_1.assert(typeof value == 'boolean');
|
||
return value;
|
||
// JSON value will be a decimal string. Either numbers or strings are accepted.
|
||
case reflection_info_1.ScalarType.UINT64:
|
||
case reflection_info_1.ScalarType.FIXED64:
|
||
assert_1.assert(typeof value == 'number' || typeof value == 'string' || typeof value == 'bigint');
|
||
let ulong = pb_long_1.PbULong.from(value);
|
||
if (ulong.isZero() && !ed)
|
||
return undefined;
|
||
return ulong.toString();
|
||
// JSON value will be a decimal string. Either numbers or strings are accepted.
|
||
case reflection_info_1.ScalarType.INT64:
|
||
case reflection_info_1.ScalarType.SFIXED64:
|
||
case reflection_info_1.ScalarType.SINT64:
|
||
assert_1.assert(typeof value == 'number' || typeof value == 'string' || typeof value == 'bigint');
|
||
let long = pb_long_1.PbLong.from(value);
|
||
if (long.isZero() && !ed)
|
||
return undefined;
|
||
return long.toString();
|
||
// bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings.
|
||
// Either standard or URL-safe base64 encoding with/without paddings are accepted.
|
||
case reflection_info_1.ScalarType.BYTES:
|
||
assert_1.assert(value instanceof Uint8Array);
|
||
if (!value.byteLength)
|
||
return ed ? "" : undefined;
|
||
return base64_1.base64encode(value);
|
||
}
|
||
}
|
||
}
|
||
exports.ReflectionJsonWriter = ReflectionJsonWriter;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 63402:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.reflectionLongConvert = void 0;
|
||
const reflection_info_1 = __nccwpck_require__(67910);
|
||
/**
|
||
* Utility method to convert a PbLong or PbUlong to a JavaScript
|
||
* representation during runtime.
|
||
*
|
||
* Works with generated field information, `undefined` is equivalent
|
||
* to `STRING`.
|
||
*/
|
||
function reflectionLongConvert(long, type) {
|
||
switch (type) {
|
||
case reflection_info_1.LongType.BIGINT:
|
||
return long.toBigInt();
|
||
case reflection_info_1.LongType.NUMBER:
|
||
return long.toNumber();
|
||
default:
|
||
// case undefined:
|
||
// case LongType.STRING:
|
||
return long.toString();
|
||
}
|
||
}
|
||
exports.reflectionLongConvert = reflectionLongConvert;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 98044:
|
||
/***/ ((__unused_webpack_module, exports) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.reflectionMergePartial = void 0;
|
||
/**
|
||
* Copy partial data into the target message.
|
||
*
|
||
* If a singular scalar or enum field is present in the source, it
|
||
* replaces the field in the target.
|
||
*
|
||
* If a singular message field is present in the source, it is merged
|
||
* with the target field by calling mergePartial() of the responsible
|
||
* message type.
|
||
*
|
||
* If a repeated field is present in the source, its values replace
|
||
* all values in the target array, removing extraneous values.
|
||
* Repeated message fields are copied, not merged.
|
||
*
|
||
* If a map field is present in the source, entries are added to the
|
||
* target map, replacing entries with the same key. Entries that only
|
||
* exist in the target remain. Entries with message values are copied,
|
||
* not merged.
|
||
*
|
||
* Note that this function differs from protobuf merge semantics,
|
||
* which appends repeated fields.
|
||
*/
|
||
function reflectionMergePartial(info, target, source) {
|
||
let fieldValue, // the field value we are working with
|
||
input = source, output; // where we want our field value to go
|
||
for (let field of info.fields) {
|
||
let name = field.localName;
|
||
if (field.oneof) {
|
||
const group = input[field.oneof]; // this is the oneof`s group in the source
|
||
if ((group === null || group === void 0 ? void 0 : group.oneofKind) == undefined) { // the user is free to omit
|
||
continue; // we skip this field, and all other members too
|
||
}
|
||
fieldValue = group[name]; // our value comes from the the oneof group of the source
|
||
output = target[field.oneof]; // and our output is the oneof group of the target
|
||
output.oneofKind = group.oneofKind; // always update discriminator
|
||
if (fieldValue == undefined) {
|
||
delete output[name]; // remove any existing value
|
||
continue; // skip further work on field
|
||
}
|
||
}
|
||
else {
|
||
fieldValue = input[name]; // we are using the source directly
|
||
output = target; // we want our field value to go directly into the target
|
||
if (fieldValue == undefined) {
|
||
continue; // skip further work on field, existing value is used as is
|
||
}
|
||
}
|
||
if (field.repeat)
|
||
output[name].length = fieldValue.length; // resize target array to match source array
|
||
// now we just work with `fieldValue` and `output` to merge the value
|
||
switch (field.kind) {
|
||
case "scalar":
|
||
case "enum":
|
||
if (field.repeat)
|
||
for (let i = 0; i < fieldValue.length; i++)
|
||
output[name][i] = fieldValue[i]; // not a reference type
|
||
else
|
||
output[name] = fieldValue; // not a reference type
|
||
break;
|
||
case "message":
|
||
let T = field.T();
|
||
if (field.repeat)
|
||
for (let i = 0; i < fieldValue.length; i++)
|
||
output[name][i] = T.create(fieldValue[i]);
|
||
else if (output[name] === undefined)
|
||
output[name] = T.create(fieldValue); // nothing to merge with
|
||
else
|
||
T.mergePartial(output[name], fieldValue);
|
||
break;
|
||
case "map":
|
||
// Map and repeated fields are simply overwritten, not appended or merged
|
||
switch (field.V.kind) {
|
||
case "scalar":
|
||
case "enum":
|
||
Object.assign(output[name], fieldValue); // elements are not reference types
|
||
break;
|
||
case "message":
|
||
let T = field.V.T();
|
||
for (let k of Object.keys(fieldValue))
|
||
output[name][k] = T.create(fieldValue[k]);
|
||
break;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
exports.reflectionMergePartial = reflectionMergePartial;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 19526:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.reflectionScalarDefault = void 0;
|
||
const reflection_info_1 = __nccwpck_require__(67910);
|
||
const reflection_long_convert_1 = __nccwpck_require__(63402);
|
||
const pb_long_1 = __nccwpck_require__(61753);
|
||
/**
|
||
* Creates the default value for a scalar type.
|
||
*/
|
||
function reflectionScalarDefault(type, longType = reflection_info_1.LongType.STRING) {
|
||
switch (type) {
|
||
case reflection_info_1.ScalarType.BOOL:
|
||
return false;
|
||
case reflection_info_1.ScalarType.UINT64:
|
||
case reflection_info_1.ScalarType.FIXED64:
|
||
return reflection_long_convert_1.reflectionLongConvert(pb_long_1.PbULong.ZERO, longType);
|
||
case reflection_info_1.ScalarType.INT64:
|
||
case reflection_info_1.ScalarType.SFIXED64:
|
||
case reflection_info_1.ScalarType.SINT64:
|
||
return reflection_long_convert_1.reflectionLongConvert(pb_long_1.PbLong.ZERO, longType);
|
||
case reflection_info_1.ScalarType.DOUBLE:
|
||
case reflection_info_1.ScalarType.FLOAT:
|
||
return 0.0;
|
||
case reflection_info_1.ScalarType.BYTES:
|
||
return new Uint8Array(0);
|
||
case reflection_info_1.ScalarType.STRING:
|
||
return "";
|
||
default:
|
||
// case ScalarType.INT32:
|
||
// case ScalarType.UINT32:
|
||
// case ScalarType.SINT32:
|
||
// case ScalarType.FIXED32:
|
||
// case ScalarType.SFIXED32:
|
||
return 0;
|
||
}
|
||
}
|
||
exports.reflectionScalarDefault = reflectionScalarDefault;
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 25167:
|
||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||
exports.ReflectionTypeCheck = void 0;
|
||
const reflection_info_1 = __nccwpck_require__(67910);
|
||
const oneof_1 = __nccwpck_require__(18063);
|
||
// noinspection JSMethodCanBeStatic
|
||
class ReflectionTypeCheck {
|
||
constructor(info) {
|
||
var _a;
|
||
this.fields = (_a = info.fields) !== null && _a !== void 0 ? _a : [];
|
||
}
|
||
prepare() {
|
||
if (this.data)
|
||
return;
|
||
const req = [], known = [], oneofs = [];
|
||
for (let field of this.fields) {
|
||
if (field.oneof) {
|
||
if (!oneofs.includes(field.oneof)) {
|
||
oneofs.push(field.oneof);
|
||
req.push(field.oneof);
|
||
known.push(field.oneof);
|
||
}
|
||
}
|
||
else {
|
||
known.push(field.localName);
|
||
switch (field.kind) {
|
||
case "scalar":
|
||
case "enum":
|
||
if (!field.opt || field.repeat)
|
||
req.push(field.localName);
|
||
break;
|
||
case "message":
|
||
if (field.repeat)
|
||
req.push(field.localName);
|
||
break;
|
||
case "map":
|
||
req.push(field.localName);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
this.data = { req, known, oneofs: Object.values(oneofs) };
|
||
}
|
||
/**
|
||
* Is the argument a valid message as specified by the
|
||
* reflection information?
|
||
*
|
||
* Checks all field types recursively. The `depth`
|
||
* specifies how deep into the structure the check will be.
|
||
*
|
||
* With a depth of 0, only the presence of fields
|
||
* is checked.
|
||
*
|
||
* With a depth of 1 or more, the field types are checked.
|
||
*
|
||
* With a depth of 2 or more, the members of map, repeated
|
||
* and message fields are checked.
|
||
*
|
||
* Message fields will be checked recursively with depth - 1.
|
||
*
|
||
* The number of map entries / repeated values being checked
|
||
* is < depth.
|
||
*/
|
||
is(message, depth, allowExcessProperties = false) {
|
||
if (depth < 0)
|
||
return true;
|
||
if (message === null || message === undefined || typeof message != 'object')
|
||
return false;
|
||
this.prepare();
|
||
let keys = Object.keys(message), data = this.data;
|
||
// if a required field is missing in arg, this cannot be a T
|
||
if (keys.length < data.req.length || data.req.some(n => !keys.includes(n)))
|
||
return false;
|
||
if (!allowExcessProperties) {
|
||
// if the arg contains a key we dont know, this is not a literal T
|
||
if (keys.some(k => !data.known.includes(k)))
|
||
return false;
|
||
}
|
||
// "With a depth of 0, only the presence and absence of fields is checked."
|
||
// "With a depth of 1 or more, the field types are checked."
|
||
if (depth < 1) {
|
||
return true;
|
||
}
|
||
// check oneof group
|
||
for (const name of data.oneofs) {
|
||
const group = message[name];
|
||
if (!oneof_1.isOneofGroup(group))
|
||
return false;
|
||
if (group.oneofKind === undefined)
|
||
continue;
|
||
const field = this.fields.find(f => f.localName === group.oneofKind);
|
||
if (!field)
|
||
return false; // we found no field, but have a kind, something is wrong
|
||
if (!this.field(group[group.oneofKind], field, allowExcessProperties, depth))
|
||
return false;
|
||
}
|
||
// check types
|
||
for (const field of this.fields) {
|
||
if (field.oneof !== undefined)
|
||
continue;
|
||
if (!this.field(message[field.localName], field, allowExcessProperties, depth))
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
field(arg, field, allowExcessProperties, depth) {
|
||
let repeated = field.repeat;
|
||
switch (field.kind) {
|
||
case "scalar":
|
||
if (arg === undefined)
|
||
return field.opt;
|
||
if (repeated)
|
||
return this.scalars(arg, field.T, depth, field.L);
|
||
return this.scalar(arg, field.T, field.L);
|
||
case "enum":
|
||
if (arg === undefined)
|
||
return field.opt;
|
||
if (repeated)
|
||
return this.scalars(arg, reflection_info_1.ScalarType.INT32, depth);
|
||
return this.scalar(arg, reflection_info_1.ScalarType.INT32);
|
||
case "message":
|
||
if (arg === undefined)
|
||
return true;
|
||
if (repeated)
|
||
return this.messages(arg, field.T(), allowExcessProperties, depth);
|
||
return this.message(arg, field.T(), allowExcessProperties, depth);
|
||
case "map":
|
||
if (typeof arg != 'object' || arg === null)
|
||
return false;
|
||
if (depth < 2)
|
||
return true;
|
||
if (!this.mapKeys(arg, field.K, depth))
|
||
return false;
|
||
switch (field.V.kind) {
|
||
case "scalar":
|
||
return this.scalars(Object.values(arg), field.V.T, depth, field.V.L);
|
||
case "enum":
|
||
return this.scalars(Object.values(arg), reflection_info_1.ScalarType.INT32, depth);
|
||
case "message":
|
||
return this.messages(Object.values(arg), field.V.T(), allowExcessProperties, depth);
|
||
}
|
||
break;
|
||
}
|
||
return true;
|
||
}
|
||
message(arg, type, allowExcessProperties, depth) {
|
||
if (allowExcessProperties) {
|
||
return type.isAssignable(arg, depth);
|
||
}
|
||
return type.is(arg, depth);
|
||
}
|
||
messages(arg, type, allowExcessProperties, depth) {
|
||
if (!Array.isArray(arg))
|
||
return false;
|
||
if (depth < 2)
|
||
return true;
|
||
if (allowExcessProperties) {
|
||
for (let i = 0; i < arg.length && i < depth; i++)
|
||
if (!type.isAssignable(arg[i], depth - 1))
|
||
return false;
|
||
}
|
||
else {
|
||
for (let i = 0; i < arg.length && i < depth; i++)
|
||
if (!type.is(arg[i], depth - 1))
|
||
return false;
|
||
}
|
||