Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4323d4df1 | ||
|
|
da26677639 | ||
|
|
7921ae235b | ||
|
|
3937731706 | ||
|
|
0c907a75c2 | ||
|
|
710893c236 | ||
|
|
9fa7e61ec7 | ||
|
|
36f1e144e1 | ||
|
|
53aa38c736 |
@ -2,7 +2,7 @@ name: 'Publish Immutable Action Version'
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
types: [released]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
|
||||
BIN
.licenses/npm/@actions/cache.dep.yml
generated
BIN
.licenses/npm/@actions/cache.dep.yml
generated
Binary file not shown.
@ -1,5 +1,13 @@
|
||||
# Releases
|
||||
|
||||
### 4.2.2
|
||||
|
||||
- Bump `@actions/cache` to v4.0.2
|
||||
|
||||
### 4.2.1
|
||||
|
||||
- Bump `@actions/cache` to v4.0.1
|
||||
|
||||
### 4.2.0
|
||||
|
||||
TLDR; The cache backend service has been rewritten from the ground up for improved performance and reliability. [actions/cache](https://github.com/actions/cache) now integrates with the new cache service (v2) APIs.
|
||||
|
||||
@ -102,7 +102,7 @@ The [GitHub Context](https://docs.github.com/en/actions/learn-github-actions/con
|
||||
|
||||
While setting paths for caching dependencies it is important to give correct path depending on the hosted runner you are using or whether the action is running in a container job. Assigning different `path` for save and restore will result in cache miss.
|
||||
|
||||
Below are GiHub hosted runner specific paths one should take care of when writing a workflow which saves/restores caches across OS.
|
||||
Below are GitHub hosted runner specific paths one should take care of when writing a workflow which saves/restores caches across OS.
|
||||
|
||||
#### Ubuntu Paths
|
||||
|
||||
|
||||
2913
dist/restore-only/index.js
vendored
2913
dist/restore-only/index.js
vendored
@ -220,7 +220,7 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
||||
};
|
||||
const response = yield twirpClient.GetCacheEntryDownloadURL(request);
|
||||
if (!response.ok) {
|
||||
core.warning(`Cache not found for keys: ${keys.join(', ')}`);
|
||||
core.debug(`Cache not found for keys: ${keys.join(', ')}`);
|
||||
return undefined;
|
||||
}
|
||||
core.info(`Cache hit for: ${request.key}`);
|
||||
@ -412,12 +412,20 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
key,
|
||||
version
|
||||
};
|
||||
const response = yield twirpClient.CreateCacheEntry(request);
|
||||
if (!response.ok) {
|
||||
let signedUploadUrl;
|
||||
try {
|
||||
const response = yield twirpClient.CreateCacheEntry(request);
|
||||
if (!response.ok) {
|
||||
throw new Error('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, response.signedUploadUrl, options);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options);
|
||||
const finalizeRequest = {
|
||||
key,
|
||||
version,
|
||||
@ -458,156 +466,13 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8200:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Timestamp = void 0;
|
||||
const runtime_1 = __nccwpck_require__(8886);
|
||||
const runtime_2 = __nccwpck_require__(8886);
|
||||
const runtime_3 = __nccwpck_require__(8886);
|
||||
const runtime_4 = __nccwpck_require__(8886);
|
||||
const runtime_5 = __nccwpck_require__(8886);
|
||||
const runtime_6 = __nccwpck_require__(8886);
|
||||
const runtime_7 = __nccwpck_require__(8886);
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class Timestamp$Type extends runtime_7.MessageType {
|
||||
constructor() {
|
||||
super("google.protobuf.Timestamp", [
|
||||
{ no: 1, name: "seconds", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
|
||||
{ no: 2, name: "nanos", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* Creates a new `Timestamp` for the current time.
|
||||
*/
|
||||
now() {
|
||||
const msg = this.create();
|
||||
const ms = Date.now();
|
||||
msg.seconds = runtime_6.PbLong.from(Math.floor(ms / 1000)).toString();
|
||||
msg.nanos = (ms % 1000) * 1000000;
|
||||
return msg;
|
||||
}
|
||||
/**
|
||||
* Converts a `Timestamp` to a JavaScript Date.
|
||||
*/
|
||||
toDate(message) {
|
||||
return new Date(runtime_6.PbLong.from(message.seconds).toNumber() * 1000 + Math.ceil(message.nanos / 1000000));
|
||||
}
|
||||
/**
|
||||
* Converts a JavaScript Date to a `Timestamp`.
|
||||
*/
|
||||
fromDate(date) {
|
||||
const msg = this.create();
|
||||
const ms = date.getTime();
|
||||
msg.seconds = runtime_6.PbLong.from(Math.floor(ms / 1000)).toString();
|
||||
msg.nanos = (ms % 1000) * 1000000;
|
||||
return msg;
|
||||
}
|
||||
/**
|
||||
* In JSON format, the `Timestamp` type is encoded as a string
|
||||
* in the RFC 3339 format.
|
||||
*/
|
||||
internalJsonWrite(message, options) {
|
||||
let ms = runtime_6.PbLong.from(message.seconds).toNumber() * 1000;
|
||||
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z"))
|
||||
throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");
|
||||
if (message.nanos < 0)
|
||||
throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");
|
||||
let z = "Z";
|
||||
if (message.nanos > 0) {
|
||||
let nanosStr = (message.nanos + 1000000000).toString().substring(1);
|
||||
if (nanosStr.substring(3) === "000000")
|
||||
z = "." + nanosStr.substring(0, 3) + "Z";
|
||||
else if (nanosStr.substring(6) === "000")
|
||||
z = "." + nanosStr.substring(0, 6) + "Z";
|
||||
else
|
||||
z = "." + nanosStr + "Z";
|
||||
}
|
||||
return new Date(ms).toISOString().replace(".000Z", z);
|
||||
}
|
||||
/**
|
||||
* In JSON format, the `Timestamp` type is encoded as a string
|
||||
* in the RFC 3339 format.
|
||||
*/
|
||||
internalJsonRead(json, options, target) {
|
||||
if (typeof json !== "string")
|
||||
throw new Error("Unable to parse Timestamp from JSON " + (0, runtime_5.typeofJsonValue)(json) + ".");
|
||||
let matches = json.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);
|
||||
if (!matches)
|
||||
throw new Error("Unable to parse Timestamp from JSON. Invalid format.");
|
||||
let ms = Date.parse(matches[1] + "-" + matches[2] + "-" + matches[3] + "T" + matches[4] + ":" + matches[5] + ":" + matches[6] + (matches[8] ? matches[8] : "Z"));
|
||||
if (Number.isNaN(ms))
|
||||
throw new Error("Unable to parse Timestamp from JSON. Invalid value.");
|
||||
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z"))
|
||||
throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");
|
||||
if (!target)
|
||||
target = this.create();
|
||||
target.seconds = runtime_6.PbLong.from(ms / 1000).toString();
|
||||
target.nanos = 0;
|
||||
if (matches[7])
|
||||
target.nanos = (parseInt("1" + matches[7] + "0".repeat(9 - matches[7].length)) - 1000000000);
|
||||
return target;
|
||||
}
|
||||
create(value) {
|
||||
const message = { seconds: "0", nanos: 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 /* int64 seconds */ 1:
|
||||
message.seconds = reader.int64().toString();
|
||||
break;
|
||||
case /* int32 nanos */ 2:
|
||||
message.nanos = reader.int32();
|
||||
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 seconds = 1; */
|
||||
if (message.seconds !== "0")
|
||||
writer.tag(1, runtime_1.WireType.Varint).int64(message.seconds);
|
||||
/* int32 nanos = 2; */
|
||||
if (message.nanos !== 0)
|
||||
writer.tag(2, runtime_1.WireType.Varint).int32(message.nanos);
|
||||
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 google.protobuf.Timestamp
|
||||
*/
|
||||
exports.Timestamp = new Timestamp$Type();
|
||||
//# sourceMappingURL=timestamp.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3156:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.CacheService = exports.LookupCacheEntryResponse = exports.LookupCacheEntryRequest = exports.ListCacheEntriesResponse = exports.ListCacheEntriesRequest = exports.DeleteCacheEntryResponse = exports.DeleteCacheEntryRequest = exports.GetCacheEntryDownloadURLResponse = exports.GetCacheEntryDownloadURLRequest = exports.FinalizeCacheEntryUploadResponse = exports.FinalizeCacheEntryUploadRequest = exports.CreateCacheEntryResponse = exports.CreateCacheEntryRequest = void 0;
|
||||
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
|
||||
@ -617,7 +482,6 @@ const runtime_2 = __nccwpck_require__(8886);
|
||||
const runtime_3 = __nccwpck_require__(8886);
|
||||
const runtime_4 = __nccwpck_require__(8886);
|
||||
const runtime_5 = __nccwpck_require__(8886);
|
||||
const cacheentry_1 = __nccwpck_require__(5893);
|
||||
const cachemetadata_1 = __nccwpck_require__(9444);
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class CreateCacheEntryRequest$Type extends runtime_5.MessageType {
|
||||
@ -985,376 +849,25 @@ class GetCacheEntryDownloadURLResponse$Type extends runtime_5.MessageType {
|
||||
* @generated MessageType for protobuf message github.actions.results.api.v1.GetCacheEntryDownloadURLResponse
|
||||
*/
|
||||
exports.GetCacheEntryDownloadURLResponse = new GetCacheEntryDownloadURLResponse$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class DeleteCacheEntryRequest$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.DeleteCacheEntryRequest", [
|
||||
{ no: 1, name: "metadata", kind: "message", T: () => cachemetadata_1.CacheMetadata },
|
||||
{ no: 2, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { key: "" };
|
||||
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;
|
||||
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);
|
||||
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.DeleteCacheEntryRequest
|
||||
*/
|
||||
exports.DeleteCacheEntryRequest = new DeleteCacheEntryRequest$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class DeleteCacheEntryResponse$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.DeleteCacheEntryResponse", [
|
||||
{ no: 1, name: "ok", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
|
||||
{ no: 2, name: "entry_id", kind: "scalar", T: 3 /*ScalarType.INT64*/ }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { ok: false, entryId: "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 /* bool ok */ 1:
|
||||
message.ok = reader.bool();
|
||||
break;
|
||||
case /* int64 entry_id */ 2:
|
||||
message.entryId = 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) {
|
||||
/* 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);
|
||||
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.DeleteCacheEntryResponse
|
||||
*/
|
||||
exports.DeleteCacheEntryResponse = new DeleteCacheEntryResponse$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class ListCacheEntriesRequest$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.ListCacheEntriesRequest", [
|
||||
{ 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*/ }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { key: "", restoreKeys: [] };
|
||||
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;
|
||||
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]);
|
||||
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.ListCacheEntriesRequest
|
||||
*/
|
||||
exports.ListCacheEntriesRequest = new ListCacheEntriesRequest$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class ListCacheEntriesResponse$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.ListCacheEntriesResponse", [
|
||||
{ no: 1, name: "entries", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => cacheentry_1.CacheEntry }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { entries: [] };
|
||||
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 /* repeated github.actions.results.entities.v1.CacheEntry entries */ 1:
|
||||
message.entries.push(cacheentry_1.CacheEntry.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) {
|
||||
/* repeated github.actions.results.entities.v1.CacheEntry entries = 1; */
|
||||
for (let i = 0; i < message.entries.length; i++)
|
||||
cacheentry_1.CacheEntry.internalBinaryWrite(message.entries[i], writer.tag(1, 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.api.v1.ListCacheEntriesResponse
|
||||
*/
|
||||
exports.ListCacheEntriesResponse = new ListCacheEntriesResponse$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class LookupCacheEntryRequest$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.LookupCacheEntryRequest", [
|
||||
{ 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.LookupCacheEntryRequest
|
||||
*/
|
||||
exports.LookupCacheEntryRequest = new LookupCacheEntryRequest$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class LookupCacheEntryResponse$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.LookupCacheEntryResponse", [
|
||||
{ no: 1, name: "exists", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
|
||||
{ no: 2, name: "entry", kind: "message", T: () => cacheentry_1.CacheEntry }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { exists: false };
|
||||
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 exists */ 1:
|
||||
message.exists = reader.bool();
|
||||
break;
|
||||
case /* github.actions.results.entities.v1.CacheEntry entry */ 2:
|
||||
message.entry = cacheentry_1.CacheEntry.internalBinaryRead(reader, reader.uint32(), options, message.entry);
|
||||
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 exists = 1; */
|
||||
if (message.exists !== false)
|
||||
writer.tag(1, runtime_1.WireType.Varint).bool(message.exists);
|
||||
/* github.actions.results.entities.v1.CacheEntry entry = 2; */
|
||||
if (message.entry)
|
||||
cacheentry_1.CacheEntry.internalBinaryWrite(message.entry, 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.api.v1.LookupCacheEntryResponse
|
||||
*/
|
||||
exports.LookupCacheEntryResponse = new LookupCacheEntryResponse$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 },
|
||||
{ name: "DeleteCacheEntry", options: {}, I: exports.DeleteCacheEntryRequest, O: exports.DeleteCacheEntryResponse },
|
||||
{ name: "ListCacheEntries", options: {}, I: exports.ListCacheEntriesRequest, O: exports.ListCacheEntriesResponse },
|
||||
{ name: "LookupCacheEntry", options: {}, I: exports.LookupCacheEntryRequest, O: exports.LookupCacheEntryResponse }
|
||||
{ name: "GetCacheEntryDownloadURL", options: {}, I: exports.GetCacheEntryDownloadURLRequest, O: exports.GetCacheEntryDownloadURLResponse }
|
||||
]);
|
||||
//# sourceMappingURL=cache.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 564:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
/***/ 1486:
|
||||
/***/ ((__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.createCacheServiceServer = exports.CacheServiceMethodList = exports.CacheServiceMethod = exports.CacheServiceClientProtobuf = exports.CacheServiceClientJSON = void 0;
|
||||
const twirp_ts_1 = __nccwpck_require__(430);
|
||||
exports.CacheServiceClientProtobuf = exports.CacheServiceClientJSON = void 0;
|
||||
const cache_1 = __nccwpck_require__(3156);
|
||||
class CacheServiceClientJSON {
|
||||
constructor(rpc) {
|
||||
@ -1362,9 +875,6 @@ class CacheServiceClientJSON {
|
||||
this.CreateCacheEntry.bind(this);
|
||||
this.FinalizeCacheEntryUpload.bind(this);
|
||||
this.GetCacheEntryDownloadURL.bind(this);
|
||||
this.DeleteCacheEntry.bind(this);
|
||||
this.ListCacheEntries.bind(this);
|
||||
this.LookupCacheEntry.bind(this);
|
||||
}
|
||||
CreateCacheEntry(request) {
|
||||
const data = cache_1.CreateCacheEntryRequest.toJson(request, {
|
||||
@ -1396,36 +906,6 @@ class CacheServiceClientJSON {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
DeleteCacheEntry(request) {
|
||||
const data = cache_1.DeleteCacheEntryRequest.toJson(request, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
});
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "DeleteCacheEntry", "application/json", data);
|
||||
return promise.then((data) => cache_1.DeleteCacheEntryResponse.fromJson(data, {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
ListCacheEntries(request) {
|
||||
const data = cache_1.ListCacheEntriesRequest.toJson(request, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
});
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "ListCacheEntries", "application/json", data);
|
||||
return promise.then((data) => cache_1.ListCacheEntriesResponse.fromJson(data, {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
LookupCacheEntry(request) {
|
||||
const data = cache_1.LookupCacheEntryRequest.toJson(request, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
});
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "LookupCacheEntry", "application/json", data);
|
||||
return promise.then((data) => cache_1.LookupCacheEntryResponse.fromJson(data, {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
}
|
||||
exports.CacheServiceClientJSON = CacheServiceClientJSON;
|
||||
class CacheServiceClientProtobuf {
|
||||
@ -1434,9 +914,6 @@ class CacheServiceClientProtobuf {
|
||||
this.CreateCacheEntry.bind(this);
|
||||
this.FinalizeCacheEntryUpload.bind(this);
|
||||
this.GetCacheEntryDownloadURL.bind(this);
|
||||
this.DeleteCacheEntry.bind(this);
|
||||
this.ListCacheEntries.bind(this);
|
||||
this.LookupCacheEntry.bind(this);
|
||||
}
|
||||
CreateCacheEntry(request) {
|
||||
const data = cache_1.CreateCacheEntryRequest.toBinary(request);
|
||||
@ -1453,610 +930,9 @@ class CacheServiceClientProtobuf {
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "GetCacheEntryDownloadURL", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.GetCacheEntryDownloadURLResponse.fromBinary(data));
|
||||
}
|
||||
DeleteCacheEntry(request) {
|
||||
const data = cache_1.DeleteCacheEntryRequest.toBinary(request);
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "DeleteCacheEntry", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.DeleteCacheEntryResponse.fromBinary(data));
|
||||
}
|
||||
ListCacheEntries(request) {
|
||||
const data = cache_1.ListCacheEntriesRequest.toBinary(request);
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "ListCacheEntries", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.ListCacheEntriesResponse.fromBinary(data));
|
||||
}
|
||||
LookupCacheEntry(request) {
|
||||
const data = cache_1.LookupCacheEntryRequest.toBinary(request);
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "LookupCacheEntry", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.LookupCacheEntryResponse.fromBinary(data));
|
||||
}
|
||||
}
|
||||
exports.CacheServiceClientProtobuf = CacheServiceClientProtobuf;
|
||||
var CacheServiceMethod;
|
||||
(function (CacheServiceMethod) {
|
||||
CacheServiceMethod["CreateCacheEntry"] = "CreateCacheEntry";
|
||||
CacheServiceMethod["FinalizeCacheEntryUpload"] = "FinalizeCacheEntryUpload";
|
||||
CacheServiceMethod["GetCacheEntryDownloadURL"] = "GetCacheEntryDownloadURL";
|
||||
CacheServiceMethod["DeleteCacheEntry"] = "DeleteCacheEntry";
|
||||
CacheServiceMethod["ListCacheEntries"] = "ListCacheEntries";
|
||||
CacheServiceMethod["LookupCacheEntry"] = "LookupCacheEntry";
|
||||
})(CacheServiceMethod || (exports.CacheServiceMethod = CacheServiceMethod = {}));
|
||||
exports.CacheServiceMethodList = [
|
||||
CacheServiceMethod.CreateCacheEntry,
|
||||
CacheServiceMethod.FinalizeCacheEntryUpload,
|
||||
CacheServiceMethod.GetCacheEntryDownloadURL,
|
||||
CacheServiceMethod.DeleteCacheEntry,
|
||||
CacheServiceMethod.ListCacheEntries,
|
||||
CacheServiceMethod.LookupCacheEntry,
|
||||
];
|
||||
function createCacheServiceServer(service) {
|
||||
return new twirp_ts_1.TwirpServer({
|
||||
service,
|
||||
packageName: "github.actions.results.api.v1",
|
||||
serviceName: "CacheService",
|
||||
methodList: exports.CacheServiceMethodList,
|
||||
matchRoute: matchCacheServiceRoute,
|
||||
});
|
||||
}
|
||||
exports.createCacheServiceServer = createCacheServiceServer;
|
||||
function matchCacheServiceRoute(method, events) {
|
||||
switch (method) {
|
||||
case "CreateCacheEntry":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "CreateCacheEntry" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceCreateCacheEntryRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "FinalizeCacheEntryUpload":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "FinalizeCacheEntryUpload" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceFinalizeCacheEntryUploadRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "GetCacheEntryDownloadURL":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "GetCacheEntryDownloadURL" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceGetCacheEntryDownloadURLRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "DeleteCacheEntry":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "DeleteCacheEntry" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceDeleteCacheEntryRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "ListCacheEntries":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "ListCacheEntries" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceListCacheEntriesRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "LookupCacheEntry":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "LookupCacheEntry" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceLookupCacheEntryRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
default:
|
||||
events.onNotFound();
|
||||
const msg = `no handler found`;
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceCreateCacheEntryRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceCreateCacheEntryJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceCreateCacheEntryProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceFinalizeCacheEntryUploadRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceFinalizeCacheEntryUploadJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceFinalizeCacheEntryUploadProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceGetCacheEntryDownloadURLRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceGetCacheEntryDownloadURLJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceGetCacheEntryDownloadURLProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceDeleteCacheEntryRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceDeleteCacheEntryJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceDeleteCacheEntryProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceListCacheEntriesRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceListCacheEntriesJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceListCacheEntriesProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceLookupCacheEntryRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceLookupCacheEntryJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceLookupCacheEntryProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceCreateCacheEntryJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.CreateCacheEntryRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.CreateCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.CreateCacheEntry(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.CreateCacheEntryResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceFinalizeCacheEntryUploadJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.FinalizeCacheEntryUploadRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.FinalizeCacheEntryUpload(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.FinalizeCacheEntryUpload(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.FinalizeCacheEntryUploadResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceGetCacheEntryDownloadURLJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.GetCacheEntryDownloadURLRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.GetCacheEntryDownloadURL(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.GetCacheEntryDownloadURL(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.GetCacheEntryDownloadURLResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceDeleteCacheEntryJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.DeleteCacheEntryRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.DeleteCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.DeleteCacheEntry(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.DeleteCacheEntryResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceListCacheEntriesJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.ListCacheEntriesRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.ListCacheEntries(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.ListCacheEntries(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.ListCacheEntriesResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceLookupCacheEntryJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.LookupCacheEntryRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.LookupCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.LookupCacheEntry(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.LookupCacheEntryResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceCreateCacheEntryProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.CreateCacheEntryRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.CreateCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.CreateCacheEntry(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.CreateCacheEntryResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceFinalizeCacheEntryUploadProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.FinalizeCacheEntryUploadRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.FinalizeCacheEntryUpload(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.FinalizeCacheEntryUpload(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.FinalizeCacheEntryUploadResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceGetCacheEntryDownloadURLProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.GetCacheEntryDownloadURLRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.GetCacheEntryDownloadURL(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.GetCacheEntryDownloadURL(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.GetCacheEntryDownloadURLResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceDeleteCacheEntryProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.DeleteCacheEntryRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.DeleteCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.DeleteCacheEntry(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.DeleteCacheEntryResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceListCacheEntriesProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.ListCacheEntriesRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.ListCacheEntries(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.ListCacheEntries(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.ListCacheEntriesResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceLookupCacheEntryProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.LookupCacheEntryRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.LookupCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.LookupCacheEntry(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.LookupCacheEntryResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=cache.twirp.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5893:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.CacheEntry = void 0;
|
||||
const runtime_1 = __nccwpck_require__(8886);
|
||||
const runtime_2 = __nccwpck_require__(8886);
|
||||
const runtime_3 = __nccwpck_require__(8886);
|
||||
const runtime_4 = __nccwpck_require__(8886);
|
||||
const runtime_5 = __nccwpck_require__(8886);
|
||||
const timestamp_1 = __nccwpck_require__(8200);
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class CacheEntry$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.entities.v1.CacheEntry", [
|
||||
{ no: 1, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 2, name: "hash", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 3, name: "size_bytes", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
|
||||
{ no: 4, name: "scope", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 5, name: "version", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 6, name: "created_at", kind: "message", T: () => timestamp_1.Timestamp },
|
||||
{ no: 7, name: "last_accessed_at", kind: "message", T: () => timestamp_1.Timestamp },
|
||||
{ no: 8, name: "expires_at", kind: "message", T: () => timestamp_1.Timestamp }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { key: "", hash: "", sizeBytes: "0", scope: "", 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 /* string key */ 1:
|
||||
message.key = reader.string();
|
||||
break;
|
||||
case /* string hash */ 2:
|
||||
message.hash = reader.string();
|
||||
break;
|
||||
case /* int64 size_bytes */ 3:
|
||||
message.sizeBytes = reader.int64().toString();
|
||||
break;
|
||||
case /* string scope */ 4:
|
||||
message.scope = reader.string();
|
||||
break;
|
||||
case /* string version */ 5:
|
||||
message.version = reader.string();
|
||||
break;
|
||||
case /* google.protobuf.Timestamp created_at */ 6:
|
||||
message.createdAt = timestamp_1.Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.createdAt);
|
||||
break;
|
||||
case /* google.protobuf.Timestamp last_accessed_at */ 7:
|
||||
message.lastAccessedAt = timestamp_1.Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.lastAccessedAt);
|
||||
break;
|
||||
case /* google.protobuf.Timestamp expires_at */ 8:
|
||||
message.expiresAt = timestamp_1.Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.expiresAt);
|
||||
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 key = 1; */
|
||||
if (message.key !== "")
|
||||
writer.tag(1, runtime_1.WireType.LengthDelimited).string(message.key);
|
||||
/* string hash = 2; */
|
||||
if (message.hash !== "")
|
||||
writer.tag(2, runtime_1.WireType.LengthDelimited).string(message.hash);
|
||||
/* int64 size_bytes = 3; */
|
||||
if (message.sizeBytes !== "0")
|
||||
writer.tag(3, runtime_1.WireType.Varint).int64(message.sizeBytes);
|
||||
/* string scope = 4; */
|
||||
if (message.scope !== "")
|
||||
writer.tag(4, runtime_1.WireType.LengthDelimited).string(message.scope);
|
||||
/* string version = 5; */
|
||||
if (message.version !== "")
|
||||
writer.tag(5, runtime_1.WireType.LengthDelimited).string(message.version);
|
||||
/* google.protobuf.Timestamp created_at = 6; */
|
||||
if (message.createdAt)
|
||||
timestamp_1.Timestamp.internalBinaryWrite(message.createdAt, writer.tag(6, runtime_1.WireType.LengthDelimited).fork(), options).join();
|
||||
/* google.protobuf.Timestamp last_accessed_at = 7; */
|
||||
if (message.lastAccessedAt)
|
||||
timestamp_1.Timestamp.internalBinaryWrite(message.lastAccessedAt, writer.tag(7, runtime_1.WireType.LengthDelimited).fork(), options).join();
|
||||
/* google.protobuf.Timestamp expires_at = 8; */
|
||||
if (message.expiresAt)
|
||||
timestamp_1.Timestamp.internalBinaryWrite(message.expiresAt, writer.tag(8, 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.CacheEntry
|
||||
*/
|
||||
exports.CacheEntry = new CacheEntry$Type();
|
||||
//# sourceMappingURL=cacheentry.js.map
|
||||
//# sourceMappingURL=cache.twirp-client.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
@ -3327,7 +2203,7 @@ const config_1 = __nccwpck_require__(7606);
|
||||
const cacheUtils_1 = __nccwpck_require__(8299);
|
||||
const auth_1 = __nccwpck_require__(4552);
|
||||
const http_client_1 = __nccwpck_require__(4844);
|
||||
const cache_twirp_1 = __nccwpck_require__(564);
|
||||
const cache_twirp_client_1 = __nccwpck_require__(1486);
|
||||
/**
|
||||
* This class is a wrapper around the CacheServiceClientJSON class generated by Twirp.
|
||||
*
|
||||
@ -3464,7 +2340,7 @@ class CacheServiceClient {
|
||||
}
|
||||
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_1.CacheServiceClientJSON(client);
|
||||
return new cache_twirp_client_1.CacheServiceClientJSON(client);
|
||||
}
|
||||
exports.internalCacheTwirpClient = internalCacheTwirpClient;
|
||||
//# sourceMappingURL=cacheTwirpClient.js.map
|
||||
@ -52391,599 +51267,6 @@ DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
|
||||
};
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5129:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
function _process (v, mod) {
|
||||
var i
|
||||
var r
|
||||
|
||||
if (typeof mod === 'function') {
|
||||
r = mod(v)
|
||||
if (r !== undefined) {
|
||||
v = r
|
||||
}
|
||||
} else if (Array.isArray(mod)) {
|
||||
for (i = 0; i < mod.length; i++) {
|
||||
r = mod[i](v)
|
||||
if (r !== undefined) {
|
||||
v = r
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
function parseKey (key, val) {
|
||||
// detect negative index notation
|
||||
if (key[0] === '-' && Array.isArray(val) && /^-\d+$/.test(key)) {
|
||||
return val.length + parseInt(key, 10)
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
function isIndex (k) {
|
||||
return /^\d+$/.test(k)
|
||||
}
|
||||
|
||||
function isObject (val) {
|
||||
return Object.prototype.toString.call(val) === '[object Object]'
|
||||
}
|
||||
|
||||
function isArrayOrObject (val) {
|
||||
return Object(val) === val
|
||||
}
|
||||
|
||||
function isEmptyObject (val) {
|
||||
return Object.keys(val).length === 0
|
||||
}
|
||||
|
||||
var blacklist = ['__proto__', 'prototype', 'constructor']
|
||||
var blacklistFilter = function (part) { return blacklist.indexOf(part) === -1 }
|
||||
|
||||
function parsePath (path, sep) {
|
||||
if (path.indexOf('[') >= 0) {
|
||||
path = path.replace(/\[/g, sep).replace(/]/g, '')
|
||||
}
|
||||
|
||||
var parts = path.split(sep)
|
||||
|
||||
var check = parts.filter(blacklistFilter)
|
||||
|
||||
if (check.length !== parts.length) {
|
||||
throw Error('Refusing to update blacklisted property ' + path)
|
||||
}
|
||||
|
||||
return parts
|
||||
}
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
|
||||
function DotObject (separator, override, useArray, useBrackets) {
|
||||
if (!(this instanceof DotObject)) {
|
||||
return new DotObject(separator, override, useArray, useBrackets)
|
||||
}
|
||||
|
||||
if (typeof override === 'undefined') override = false
|
||||
if (typeof useArray === 'undefined') useArray = true
|
||||
if (typeof useBrackets === 'undefined') useBrackets = true
|
||||
this.separator = separator || '.'
|
||||
this.override = override
|
||||
this.useArray = useArray
|
||||
this.useBrackets = useBrackets
|
||||
this.keepArray = false
|
||||
|
||||
// contains touched arrays
|
||||
this.cleanup = []
|
||||
}
|
||||
|
||||
var dotDefault = new DotObject('.', false, true, true)
|
||||
function wrap (method) {
|
||||
return function () {
|
||||
return dotDefault[method].apply(dotDefault, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
DotObject.prototype._fill = function (a, obj, v, mod) {
|
||||
var k = a.shift()
|
||||
|
||||
if (a.length > 0) {
|
||||
obj[k] = obj[k] || (this.useArray && isIndex(a[0]) ? [] : {})
|
||||
|
||||
if (!isArrayOrObject(obj[k])) {
|
||||
if (this.override) {
|
||||
obj[k] = {}
|
||||
} else {
|
||||
if (!(isArrayOrObject(v) && isEmptyObject(v))) {
|
||||
throw new Error(
|
||||
'Trying to redefine `' + k + '` which is a ' + typeof obj[k]
|
||||
)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this._fill(a, obj[k], v, mod)
|
||||
} else {
|
||||
if (!this.override && isArrayOrObject(obj[k]) && !isEmptyObject(obj[k])) {
|
||||
if (!(isArrayOrObject(v) && isEmptyObject(v))) {
|
||||
throw new Error("Trying to redefine non-empty obj['" + k + "']")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
obj[k] = _process(v, mod)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts an object with dotted-key/value pairs to it's expanded version
|
||||
*
|
||||
* Optionally transformed by a set of modifiers.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* var row = {
|
||||
* 'nr': 200,
|
||||
* 'doc.name': ' My Document '
|
||||
* }
|
||||
*
|
||||
* var mods = {
|
||||
* 'doc.name': [_s.trim, _s.underscored]
|
||||
* }
|
||||
*
|
||||
* dot.object(row, mods)
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {Object} mods
|
||||
*/
|
||||
DotObject.prototype.object = function (obj, mods) {
|
||||
var self = this
|
||||
|
||||
Object.keys(obj).forEach(function (k) {
|
||||
var mod = mods === undefined ? null : mods[k]
|
||||
// normalize array notation.
|
||||
var ok = parsePath(k, self.separator).join(self.separator)
|
||||
|
||||
if (ok.indexOf(self.separator) !== -1) {
|
||||
self._fill(ok.split(self.separator), obj, obj[k], mod)
|
||||
delete obj[k]
|
||||
} else {
|
||||
obj[k] = _process(obj[k], mod)
|
||||
}
|
||||
})
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} path dotted path
|
||||
* @param {String} v value to be set
|
||||
* @param {Object} obj object to be modified
|
||||
* @param {Function|Array} mod optional modifier
|
||||
*/
|
||||
DotObject.prototype.str = function (path, v, obj, mod) {
|
||||
var ok = parsePath(path, this.separator).join(this.separator)
|
||||
|
||||
if (path.indexOf(this.separator) !== -1) {
|
||||
this._fill(ok.split(this.separator), obj, v, mod)
|
||||
} else {
|
||||
obj[path] = _process(v, mod)
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Pick a value from an object using dot notation.
|
||||
*
|
||||
* Optionally remove the value
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} remove
|
||||
*/
|
||||
DotObject.prototype.pick = function (path, obj, remove, reindexArray) {
|
||||
var i
|
||||
var keys
|
||||
var val
|
||||
var key
|
||||
var cp
|
||||
|
||||
keys = parsePath(path, this.separator)
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
key = parseKey(keys[i], obj)
|
||||
if (obj && typeof obj === 'object' && key in obj) {
|
||||
if (i === keys.length - 1) {
|
||||
if (remove) {
|
||||
val = obj[key]
|
||||
if (reindexArray && Array.isArray(obj)) {
|
||||
obj.splice(key, 1)
|
||||
} else {
|
||||
delete obj[key]
|
||||
}
|
||||
if (Array.isArray(obj)) {
|
||||
cp = keys.slice(0, -1).join('.')
|
||||
if (this.cleanup.indexOf(cp) === -1) {
|
||||
this.cleanup.push(cp)
|
||||
}
|
||||
}
|
||||
return val
|
||||
} else {
|
||||
return obj[key]
|
||||
}
|
||||
} else {
|
||||
obj = obj[key]
|
||||
}
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
if (remove && Array.isArray(obj)) {
|
||||
obj = obj.filter(function (n) {
|
||||
return n !== undefined
|
||||
})
|
||||
}
|
||||
return obj
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Delete value from an object using dot notation.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Object} obj
|
||||
* @return {any} The removed value
|
||||
*/
|
||||
DotObject.prototype.delete = function (path, obj) {
|
||||
return this.remove(path, obj, true)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Remove value from an object using dot notation.
|
||||
*
|
||||
* Will remove multiple items if path is an array.
|
||||
* In this case array indexes will be retained until all
|
||||
* removals have been processed.
|
||||
*
|
||||
* Use dot.delete() to automatically re-index arrays.
|
||||
*
|
||||
* @param {String|Array<String>} path
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} reindexArray
|
||||
* @return {any} The removed value
|
||||
*/
|
||||
DotObject.prototype.remove = function (path, obj, reindexArray) {
|
||||
var i
|
||||
|
||||
this.cleanup = []
|
||||
if (Array.isArray(path)) {
|
||||
for (i = 0; i < path.length; i++) {
|
||||
this.pick(path[i], obj, true, reindexArray)
|
||||
}
|
||||
if (!reindexArray) {
|
||||
this._cleanup(obj)
|
||||
}
|
||||
return obj
|
||||
} else {
|
||||
return this.pick(path, obj, true, reindexArray)
|
||||
}
|
||||
}
|
||||
|
||||
DotObject.prototype._cleanup = function (obj) {
|
||||
var ret
|
||||
var i
|
||||
var keys
|
||||
var root
|
||||
if (this.cleanup.length) {
|
||||
for (i = 0; i < this.cleanup.length; i++) {
|
||||
keys = this.cleanup[i].split('.')
|
||||
root = keys.splice(0, -1).join('.')
|
||||
ret = root ? this.pick(root, obj) : obj
|
||||
ret = ret[keys[0]].filter(function (v) {
|
||||
return v !== undefined
|
||||
})
|
||||
this.set(this.cleanup[i], ret, obj)
|
||||
}
|
||||
this.cleanup = []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias method for `dot.remove`
|
||||
*
|
||||
* Note: this is not an alias for dot.delete()
|
||||
*
|
||||
* @param {String|Array<String>} path
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} reindexArray
|
||||
* @return {any} The removed value
|
||||
*/
|
||||
DotObject.prototype.del = DotObject.prototype.remove
|
||||
|
||||
/**
|
||||
*
|
||||
* Move a property from one place to the other.
|
||||
*
|
||||
* If the source path does not exist (undefined)
|
||||
* the target property will not be set.
|
||||
*
|
||||
* @param {String} source
|
||||
* @param {String} target
|
||||
* @param {Object} obj
|
||||
* @param {Function|Array} mods
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.move = function (source, target, obj, mods, merge) {
|
||||
if (typeof mods === 'function' || Array.isArray(mods)) {
|
||||
this.set(target, _process(this.pick(source, obj, true), mods), obj, merge)
|
||||
} else {
|
||||
merge = mods
|
||||
this.set(target, this.pick(source, obj, true), obj, merge)
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Transfer a property from one object to another object.
|
||||
*
|
||||
* If the source path does not exist (undefined)
|
||||
* the property on the other object will not be set.
|
||||
*
|
||||
* @param {String} source
|
||||
* @param {String} target
|
||||
* @param {Object} obj1
|
||||
* @param {Object} obj2
|
||||
* @param {Function|Array} mods
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.transfer = function (
|
||||
source,
|
||||
target,
|
||||
obj1,
|
||||
obj2,
|
||||
mods,
|
||||
merge
|
||||
) {
|
||||
if (typeof mods === 'function' || Array.isArray(mods)) {
|
||||
this.set(
|
||||
target,
|
||||
_process(this.pick(source, obj1, true), mods),
|
||||
obj2,
|
||||
merge
|
||||
)
|
||||
} else {
|
||||
merge = mods
|
||||
this.set(target, this.pick(source, obj1, true), obj2, merge)
|
||||
}
|
||||
|
||||
return obj2
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Copy a property from one object to another object.
|
||||
*
|
||||
* If the source path does not exist (undefined)
|
||||
* the property on the other object will not be set.
|
||||
*
|
||||
* @param {String} source
|
||||
* @param {String} target
|
||||
* @param {Object} obj1
|
||||
* @param {Object} obj2
|
||||
* @param {Function|Array} mods
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.copy = function (source, target, obj1, obj2, mods, merge) {
|
||||
if (typeof mods === 'function' || Array.isArray(mods)) {
|
||||
this.set(
|
||||
target,
|
||||
_process(
|
||||
// clone what is picked
|
||||
JSON.parse(JSON.stringify(this.pick(source, obj1, false))),
|
||||
mods
|
||||
),
|
||||
obj2,
|
||||
merge
|
||||
)
|
||||
} else {
|
||||
merge = mods
|
||||
this.set(target, this.pick(source, obj1, false), obj2, merge)
|
||||
}
|
||||
|
||||
return obj2
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Set a property on an object using dot notation.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {any} val
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.set = function (path, val, obj, merge) {
|
||||
var i
|
||||
var k
|
||||
var keys
|
||||
var key
|
||||
|
||||
// Do not operate if the value is undefined.
|
||||
if (typeof val === 'undefined') {
|
||||
return obj
|
||||
}
|
||||
keys = parsePath(path, this.separator)
|
||||
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
key = keys[i]
|
||||
if (i === keys.length - 1) {
|
||||
if (merge && isObject(val) && isObject(obj[key])) {
|
||||
for (k in val) {
|
||||
if (hasOwnProperty.call(val, k)) {
|
||||
obj[key][k] = val[k]
|
||||
}
|
||||
}
|
||||
} else if (merge && Array.isArray(obj[key]) && Array.isArray(val)) {
|
||||
for (var j = 0; j < val.length; j++) {
|
||||
obj[keys[i]].push(val[j])
|
||||
}
|
||||
} else {
|
||||
obj[key] = val
|
||||
}
|
||||
} else if (
|
||||
// force the value to be an object
|
||||
!hasOwnProperty.call(obj, key) ||
|
||||
(!isObject(obj[key]) && !Array.isArray(obj[key]))
|
||||
) {
|
||||
// initialize as array if next key is numeric
|
||||
if (/^\d+$/.test(keys[i + 1])) {
|
||||
obj[key] = []
|
||||
} else {
|
||||
obj[key] = {}
|
||||
}
|
||||
}
|
||||
obj = obj[key]
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Transform an object
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* var obj = {
|
||||
* "id": 1,
|
||||
* "some": {
|
||||
* "thing": "else"
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* var transform = {
|
||||
* "id": "nr",
|
||||
* "some.thing": "name"
|
||||
* }
|
||||
*
|
||||
* var tgt = dot.transform(transform, obj)
|
||||
*
|
||||
* @param {Object} recipe Transform recipe
|
||||
* @param {Object} obj Object to be transformed
|
||||
* @param {Array} mods modifiers for the target
|
||||
*/
|
||||
DotObject.prototype.transform = function (recipe, obj, tgt) {
|
||||
obj = obj || {}
|
||||
tgt = tgt || {}
|
||||
Object.keys(recipe).forEach(
|
||||
function (key) {
|
||||
this.set(recipe[key], this.pick(key, obj), tgt)
|
||||
}.bind(this)
|
||||
)
|
||||
return tgt
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convert object to dotted-key/value pair
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* var tgt = dot.dot(obj)
|
||||
*
|
||||
* or
|
||||
*
|
||||
* var tgt = {}
|
||||
* dot.dot(obj, tgt)
|
||||
*
|
||||
* @param {Object} obj source object
|
||||
* @param {Object} tgt target object
|
||||
* @param {Array} path path array (internal)
|
||||
*/
|
||||
DotObject.prototype.dot = function (obj, tgt, path) {
|
||||
tgt = tgt || {}
|
||||
path = path || []
|
||||
var isArray = Array.isArray(obj)
|
||||
|
||||
Object.keys(obj).forEach(
|
||||
function (key) {
|
||||
var index = isArray && this.useBrackets ? '[' + key + ']' : key
|
||||
if (
|
||||
isArrayOrObject(obj[key]) &&
|
||||
((isObject(obj[key]) && !isEmptyObject(obj[key])) ||
|
||||
(Array.isArray(obj[key]) && !this.keepArray && obj[key].length !== 0))
|
||||
) {
|
||||
if (isArray && this.useBrackets) {
|
||||
var previousKey = path[path.length - 1] || ''
|
||||
return this.dot(
|
||||
obj[key],
|
||||
tgt,
|
||||
path.slice(0, -1).concat(previousKey + index)
|
||||
)
|
||||
} else {
|
||||
return this.dot(obj[key], tgt, path.concat(index))
|
||||
}
|
||||
} else {
|
||||
if (isArray && this.useBrackets) {
|
||||
tgt[path.join(this.separator).concat('[' + key + ']')] = obj[key]
|
||||
} else {
|
||||
tgt[path.concat(index).join(this.separator)] = obj[key]
|
||||
}
|
||||
}
|
||||
}.bind(this)
|
||||
)
|
||||
return tgt
|
||||
}
|
||||
|
||||
DotObject.pick = wrap('pick')
|
||||
DotObject.move = wrap('move')
|
||||
DotObject.transfer = wrap('transfer')
|
||||
DotObject.transform = wrap('transform')
|
||||
DotObject.copy = wrap('copy')
|
||||
DotObject.object = wrap('object')
|
||||
DotObject.str = wrap('str')
|
||||
DotObject.set = wrap('set')
|
||||
DotObject.delete = wrap('delete')
|
||||
DotObject.del = DotObject.remove = wrap('remove')
|
||||
DotObject.dot = wrap('dot');
|
||||
['override', 'overwrite'].forEach(function (prop) {
|
||||
Object.defineProperty(DotObject, prop, {
|
||||
get: function () {
|
||||
return dotDefault.override
|
||||
},
|
||||
set: function (val) {
|
||||
dotDefault.override = !!val
|
||||
}
|
||||
})
|
||||
});
|
||||
['useArray', 'keepArray', 'useBrackets'].forEach(function (prop) {
|
||||
Object.defineProperty(DotObject, prop, {
|
||||
get: function () {
|
||||
return dotDefault[prop]
|
||||
},
|
||||
set: function (val) {
|
||||
dotDefault[prop] = val
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
DotObject._process = _process
|
||||
|
||||
module.exports = DotObject
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9829:
|
||||
@ -61521,1152 +59804,6 @@ if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) {
|
||||
exports.debug = debug; // for test
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5497:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3315:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.isValidErrorCode = exports.httpStatusFromErrorCode = exports.TwirpErrorCode = exports.BadRouteError = exports.InternalServerErrorWith = exports.InternalServerError = exports.RequiredArgumentError = exports.InvalidArgumentError = exports.NotFoundError = exports.TwirpError = void 0;
|
||||
/**
|
||||
* Represents a twirp error
|
||||
*/
|
||||
class TwirpError extends Error {
|
||||
constructor(code, msg) {
|
||||
super(msg);
|
||||
this.code = TwirpErrorCode.Internal;
|
||||
this.meta = {};
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
Object.setPrototypeOf(this, TwirpError.prototype);
|
||||
}
|
||||
/**
|
||||
* Adds a metadata kv to the error
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
withMeta(key, value) {
|
||||
this.meta[key] = value;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Returns a single metadata value
|
||||
* return "" if not found
|
||||
* @param key
|
||||
*/
|
||||
getMeta(key) {
|
||||
return this.meta[key] || "";
|
||||
}
|
||||
/**
|
||||
* Add the original error cause
|
||||
* @param err
|
||||
* @param addMeta
|
||||
*/
|
||||
withCause(err, addMeta = false) {
|
||||
this._originalCause = err;
|
||||
if (addMeta) {
|
||||
this.withMeta("cause", err.message);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
cause() {
|
||||
return this._originalCause;
|
||||
}
|
||||
/**
|
||||
* Returns the error representation to JSON
|
||||
*/
|
||||
toJSON() {
|
||||
try {
|
||||
return JSON.stringify({
|
||||
code: this.code,
|
||||
msg: this.msg,
|
||||
meta: this.meta,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
return `{"code": "internal", "msg": "There was an error but it could not be serialized into JSON"}`;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create a twirp error from an object
|
||||
* @param obj
|
||||
*/
|
||||
static fromObject(obj) {
|
||||
const code = obj["code"] || TwirpErrorCode.Unknown;
|
||||
const msg = obj["msg"] || "unknown";
|
||||
const error = new TwirpError(code, msg);
|
||||
if (obj["meta"]) {
|
||||
Object.keys(obj["meta"]).forEach((key) => {
|
||||
error.withMeta(key, obj["meta"][key]);
|
||||
});
|
||||
}
|
||||
return error;
|
||||
}
|
||||
}
|
||||
exports.TwirpError = TwirpError;
|
||||
/**
|
||||
* NotFoundError constructor for the common NotFound error.
|
||||
*/
|
||||
class NotFoundError extends TwirpError {
|
||||
constructor(msg) {
|
||||
super(TwirpErrorCode.NotFound, msg);
|
||||
}
|
||||
}
|
||||
exports.NotFoundError = NotFoundError;
|
||||
/**
|
||||
* InvalidArgumentError constructor for the common InvalidArgument error. Can be
|
||||
* used when an argument has invalid format, is a number out of range, is a bad
|
||||
* option, etc).
|
||||
*/
|
||||
class InvalidArgumentError extends TwirpError {
|
||||
constructor(argument, validationMsg) {
|
||||
super(TwirpErrorCode.InvalidArgument, argument + " " + validationMsg);
|
||||
this.withMeta("argument", argument);
|
||||
}
|
||||
}
|
||||
exports.InvalidArgumentError = InvalidArgumentError;
|
||||
/**
|
||||
* RequiredArgumentError is a more specific constructor for InvalidArgument
|
||||
* error. Should be used when the argument is required (expected to have a
|
||||
* non-zero value).
|
||||
*/
|
||||
class RequiredArgumentError extends InvalidArgumentError {
|
||||
constructor(argument) {
|
||||
super(argument, "is required");
|
||||
}
|
||||
}
|
||||
exports.RequiredArgumentError = RequiredArgumentError;
|
||||
/**
|
||||
* InternalError constructor for the common Internal error. Should be used to
|
||||
* specify that something bad or unexpected happened.
|
||||
*/
|
||||
class InternalServerError extends TwirpError {
|
||||
constructor(msg) {
|
||||
super(TwirpErrorCode.Internal, msg);
|
||||
}
|
||||
}
|
||||
exports.InternalServerError = InternalServerError;
|
||||
/**
|
||||
* InternalErrorWith makes an internal error, wrapping the original error and using it
|
||||
* for the error message, and with metadata "cause" with the original error type.
|
||||
* This function is used by Twirp services to wrap non-Twirp errors as internal errors.
|
||||
* The wrapped error can be extracted later with err.cause()
|
||||
*/
|
||||
class InternalServerErrorWith extends InternalServerError {
|
||||
constructor(err) {
|
||||
super(err.message);
|
||||
this.withMeta("cause", err.name);
|
||||
this.withCause(err);
|
||||
}
|
||||
}
|
||||
exports.InternalServerErrorWith = InternalServerErrorWith;
|
||||
/**
|
||||
* A standard BadRoute Error
|
||||
*/
|
||||
class BadRouteError extends TwirpError {
|
||||
constructor(msg, method, url) {
|
||||
super(TwirpErrorCode.BadRoute, msg);
|
||||
this.withMeta("twirp_invalid_route", method + " " + url);
|
||||
}
|
||||
}
|
||||
exports.BadRouteError = BadRouteError;
|
||||
var TwirpErrorCode;
|
||||
(function (TwirpErrorCode) {
|
||||
// Canceled indicates the operation was cancelled (typically by the caller).
|
||||
TwirpErrorCode["Canceled"] = "canceled";
|
||||
// Unknown error. For example when handling errors raised by APIs that do not
|
||||
// return enough error information.
|
||||
TwirpErrorCode["Unknown"] = "unknown";
|
||||
// InvalidArgument indicates client specified an invalid argument. It
|
||||
// indicates arguments that are problematic regardless of the state of the
|
||||
// system (i.e. a malformed file name, required argument, number out of range,
|
||||
// etc.).
|
||||
TwirpErrorCode["InvalidArgument"] = "invalid_argument";
|
||||
// Malformed indicates an error occurred while decoding the client's request.
|
||||
// This may mean that the message was encoded improperly, or that there is a
|
||||
// disagreement in message format between the client and server.
|
||||
TwirpErrorCode["Malformed"] = "malformed";
|
||||
// DeadlineExceeded means operation expired before completion. For operations
|
||||
// that change the state of the system, this error may be returned even if the
|
||||
// operation has completed successfully (timeout).
|
||||
TwirpErrorCode["DeadlineExceeded"] = "deadline_exceeded";
|
||||
// NotFound means some requested entity was not found.
|
||||
TwirpErrorCode["NotFound"] = "not_found";
|
||||
// BadRoute means that the requested URL path wasn't routable to a Twirp
|
||||
// service and method. This is returned by the generated server, and usually
|
||||
// shouldn't be returned by applications. Instead, applications should use
|
||||
// NotFound or Unimplemented.
|
||||
TwirpErrorCode["BadRoute"] = "bad_route";
|
||||
// AlreadyExists means an attempt to create an entity failed because one
|
||||
// already exists.
|
||||
TwirpErrorCode["AlreadyExists"] = "already_exists";
|
||||
// PermissionDenied indicates the caller does not have permission to execute
|
||||
// the specified operation. It must not be used if the caller cannot be
|
||||
// identified (Unauthenticated).
|
||||
TwirpErrorCode["PermissionDenied"] = "permission_denied";
|
||||
// Unauthenticated indicates the request does not have valid authentication
|
||||
// credentials for the operation.
|
||||
TwirpErrorCode["Unauthenticated"] = "unauthenticated";
|
||||
// ResourceExhausted indicates some resource has been exhausted, perhaps a
|
||||
// per-user quota, or perhaps the entire file system is out of space.
|
||||
TwirpErrorCode["ResourceExhausted"] = "resource_exhausted";
|
||||
// FailedPrecondition indicates operation was rejected because the system is
|
||||
// not in a state required for the operation's execution. For example, doing
|
||||
// an rmdir operation on a directory that is non-empty, or on a non-directory
|
||||
// object, or when having conflicting read-modify-write on the same resource.
|
||||
TwirpErrorCode["FailedPrecondition"] = "failed_precondition";
|
||||
// Aborted indicates the operation was aborted, typically due to a concurrency
|
||||
// issue like sequencer check failures, transaction aborts, etc.
|
||||
TwirpErrorCode["Aborted"] = "aborted";
|
||||
// OutOfRange means operation was attempted past the valid range. For example,
|
||||
// seeking or reading past end of a paginated collection.
|
||||
//
|
||||
// Unlike InvalidArgument, this error indicates a problem that may be fixed if
|
||||
// the system state changes (i.e. adding more items to the collection).
|
||||
//
|
||||
// There is a fair bit of overlap between FailedPrecondition and OutOfRange.
|
||||
// We recommend using OutOfRange (the more specific error) when it applies so
|
||||
// that callers who are iterating through a space can easily look for an
|
||||
// OutOfRange error to detect when they are done.
|
||||
TwirpErrorCode["OutOfRange"] = "out_of_range";
|
||||
// Unimplemented indicates operation is not implemented or not
|
||||
// supported/enabled in this service.
|
||||
TwirpErrorCode["Unimplemented"] = "unimplemented";
|
||||
// Internal errors. When some invariants expected by the underlying system
|
||||
// have been broken. In other words, something bad happened in the library or
|
||||
// backend service. Do not confuse with HTTP Internal Server Error; an
|
||||
// Internal error could also happen on the client code, i.e. when parsing a
|
||||
// server response.
|
||||
TwirpErrorCode["Internal"] = "internal";
|
||||
// Unavailable indicates the service is currently unavailable. This is a most
|
||||
// likely a transient condition and may be corrected by retrying with a
|
||||
// backoff.
|
||||
TwirpErrorCode["Unavailable"] = "unavailable";
|
||||
// DataLoss indicates unrecoverable data loss or corruption.
|
||||
TwirpErrorCode["DataLoss"] = "data_loss";
|
||||
})(TwirpErrorCode = exports.TwirpErrorCode || (exports.TwirpErrorCode = {}));
|
||||
// ServerHTTPStatusFromErrorCode maps a Twirp error type into a similar HTTP
|
||||
// response status. It is used by the Twirp server handler to set the HTTP
|
||||
// response status code. Returns 0 if the ErrorCode is invalid.
|
||||
function httpStatusFromErrorCode(code) {
|
||||
switch (code) {
|
||||
case TwirpErrorCode.Canceled:
|
||||
return 408; // RequestTimeout
|
||||
case TwirpErrorCode.Unknown:
|
||||
return 500; // Internal Server Error
|
||||
case TwirpErrorCode.InvalidArgument:
|
||||
return 400; // BadRequest
|
||||
case TwirpErrorCode.Malformed:
|
||||
return 400; // BadRequest
|
||||
case TwirpErrorCode.DeadlineExceeded:
|
||||
return 408; // RequestTimeout
|
||||
case TwirpErrorCode.NotFound:
|
||||
return 404; // Not Found
|
||||
case TwirpErrorCode.BadRoute:
|
||||
return 404; // Not Found
|
||||
case TwirpErrorCode.AlreadyExists:
|
||||
return 409; // Conflict
|
||||
case TwirpErrorCode.PermissionDenied:
|
||||
return 403; // Forbidden
|
||||
case TwirpErrorCode.Unauthenticated:
|
||||
return 401; // Unauthorized
|
||||
case TwirpErrorCode.ResourceExhausted:
|
||||
return 429; // Too Many Requests
|
||||
case TwirpErrorCode.FailedPrecondition:
|
||||
return 412; // Precondition Failed
|
||||
case TwirpErrorCode.Aborted:
|
||||
return 409; // Conflict
|
||||
case TwirpErrorCode.OutOfRange:
|
||||
return 400; // Bad Request
|
||||
case TwirpErrorCode.Unimplemented:
|
||||
return 501; // Not Implemented
|
||||
case TwirpErrorCode.Internal:
|
||||
return 500; // Internal Server Error
|
||||
case TwirpErrorCode.Unavailable:
|
||||
return 503; // Service Unavailable
|
||||
case TwirpErrorCode.DataLoss:
|
||||
return 500; // Internal Server Error
|
||||
default:
|
||||
return 0; // Invalid!
|
||||
}
|
||||
}
|
||||
exports.httpStatusFromErrorCode = httpStatusFromErrorCode;
|
||||
// IsValidErrorCode returns true if is one of the valid predefined constants.
|
||||
function isValidErrorCode(code) {
|
||||
return httpStatusFromErrorCode(code) != 0;
|
||||
}
|
||||
exports.isValidErrorCode = isValidErrorCode;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9636:
|
||||
/***/ (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;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (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 (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__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 __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Gateway = exports.Pattern = void 0;
|
||||
const querystring_1 = __nccwpck_require__(3480);
|
||||
const dotObject = __importStar(__nccwpck_require__(5129));
|
||||
const request_1 = __nccwpck_require__(9647);
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
const http_client_1 = __nccwpck_require__(5683);
|
||||
const server_1 = __nccwpck_require__(1035);
|
||||
var Pattern;
|
||||
(function (Pattern) {
|
||||
Pattern["POST"] = "post";
|
||||
Pattern["GET"] = "get";
|
||||
Pattern["PATCH"] = "patch";
|
||||
Pattern["PUT"] = "put";
|
||||
Pattern["DELETE"] = "delete";
|
||||
})(Pattern = exports.Pattern || (exports.Pattern = {}));
|
||||
/**
|
||||
* The Gateway proxies http requests to Twirp Compliant
|
||||
* handlers
|
||||
*/
|
||||
class Gateway {
|
||||
constructor(routes) {
|
||||
this.routes = routes;
|
||||
}
|
||||
/**
|
||||
* Middleware that rewrite the current request
|
||||
* to a Twirp compliant request
|
||||
*/
|
||||
twirpRewrite(prefix = "/twirp") {
|
||||
return (req, resp, next) => {
|
||||
this.rewrite(req, resp, prefix)
|
||||
.then(() => next())
|
||||
.catch((e) => {
|
||||
if (e instanceof errors_1.TwirpError) {
|
||||
if (e.code !== errors_1.TwirpErrorCode.NotFound) {
|
||||
server_1.writeError(resp, e);
|
||||
}
|
||||
else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Rewrite an incoming request to a Twirp compliant request
|
||||
* @param req
|
||||
* @param resp
|
||||
* @param prefix
|
||||
*/
|
||||
rewrite(req, resp, prefix = "/twirp") {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const [match, route] = this.matchRoute(req);
|
||||
const body = yield this.prepareTwirpBody(req, match, route);
|
||||
const twirpUrl = `${prefix}/${route.packageName}.${route.serviceName}/${route.methodName}`;
|
||||
req.url = twirpUrl;
|
||||
req.originalUrl = twirpUrl;
|
||||
req.method = "POST";
|
||||
req.headers["content-type"] = "application/json";
|
||||
req.rawBody = Buffer.from(JSON.stringify(body));
|
||||
if (route.responseBodyKey) {
|
||||
const endFn = resp.end.bind(resp);
|
||||
resp.end = function (chunk) {
|
||||
if (resp.statusCode === 200) {
|
||||
endFn(`{ "${route.responseBodyKey}": ${chunk} }`);
|
||||
}
|
||||
else {
|
||||
endFn(chunk);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Create a reverse proxy handler to
|
||||
* proxy http requests to Twirp Compliant handlers
|
||||
* @param httpClientOption
|
||||
*/
|
||||
reverseProxy(httpClientOption) {
|
||||
const client = http_client_1.NodeHttpRPC(httpClientOption);
|
||||
return (req, res) => __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const [match, route] = this.matchRoute(req);
|
||||
const body = yield this.prepareTwirpBody(req, match, route);
|
||||
const response = yield client.request(`${route.packageName}.${route.serviceName}`, route.methodName, "application/json", body);
|
||||
res.statusCode = 200;
|
||||
res.setHeader("content-type", "application/json");
|
||||
let jsonResponse;
|
||||
if (route.responseBodyKey) {
|
||||
jsonResponse = JSON.stringify({ [route.responseBodyKey]: response });
|
||||
}
|
||||
else {
|
||||
jsonResponse = JSON.stringify(response);
|
||||
}
|
||||
res.end(jsonResponse);
|
||||
}
|
||||
catch (e) {
|
||||
server_1.writeError(res, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Prepares twirp body requests using http.google.annotions
|
||||
* compliant spec
|
||||
*
|
||||
* @param req
|
||||
* @param match
|
||||
* @param route
|
||||
* @protected
|
||||
*/
|
||||
prepareTwirpBody(req, match, route) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const _a = match.params, { query_string } = _a, params = __rest(_a, ["query_string"]);
|
||||
let requestBody = Object.assign({}, params);
|
||||
if (query_string && route.bodyKey !== "*") {
|
||||
const queryParams = this.parseQueryString(query_string);
|
||||
requestBody = Object.assign(Object.assign({}, queryParams), requestBody);
|
||||
}
|
||||
let body = {};
|
||||
if (route.bodyKey) {
|
||||
const data = yield request_1.getRequestData(req);
|
||||
try {
|
||||
const jsonBody = JSON.parse(data.toString() || "{}");
|
||||
if (route.bodyKey === "*") {
|
||||
body = jsonBody;
|
||||
}
|
||||
else {
|
||||
body[route.bodyKey] = jsonBody;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new errors_1.TwirpError(errors_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
return Object.assign(Object.assign({}, body), requestBody);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Matches a route
|
||||
* @param req
|
||||
*/
|
||||
matchRoute(req) {
|
||||
var _a;
|
||||
const httpMethod = (_a = req.method) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
||||
if (!httpMethod) {
|
||||
throw new errors_1.BadRouteError(`method not allowed`, req.method || "", req.url || "");
|
||||
}
|
||||
const routes = this.routes[httpMethod];
|
||||
for (const route of routes) {
|
||||
const match = route.matcher(req.url || "/");
|
||||
if (match) {
|
||||
return [match, route];
|
||||
}
|
||||
}
|
||||
throw new errors_1.NotFoundError(`url ${req.url} not found`);
|
||||
}
|
||||
/**
|
||||
* Parse query string
|
||||
* @param queryString
|
||||
*/
|
||||
parseQueryString(queryString) {
|
||||
const queryParams = querystring_1.parse(queryString.replace("?", ""));
|
||||
return dotObject.object(queryParams);
|
||||
}
|
||||
}
|
||||
exports.Gateway = Gateway;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3898:
|
||||
/***/ (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.isHook = exports.chainHooks = void 0;
|
||||
// ChainHooks creates a new ServerHook which chains the callbacks in
|
||||
// each of the constituent hooks passed in. Each hook function will be
|
||||
// called in the order of the ServerHooks values passed in.
|
||||
//
|
||||
// For the erroring hooks, RequestReceived and RequestRouted, any returned
|
||||
// errors prevent processing by later hooks.
|
||||
function chainHooks(...hooks) {
|
||||
if (hooks.length === 0) {
|
||||
return null;
|
||||
}
|
||||
if (hooks.length === 1) {
|
||||
return hooks[0];
|
||||
}
|
||||
const serverHook = {
|
||||
requestReceived(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestReceived) {
|
||||
continue;
|
||||
}
|
||||
yield hook.requestReceived(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
requestPrepared(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestPrepared) {
|
||||
continue;
|
||||
}
|
||||
console.warn("hook requestPrepared is deprecated and will be removed in the next release. " +
|
||||
"Please use responsePrepared instead.");
|
||||
yield hook.requestPrepared(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
responsePrepared(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.responsePrepared) {
|
||||
continue;
|
||||
}
|
||||
yield hook.responsePrepared(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
requestSent(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestSent) {
|
||||
continue;
|
||||
}
|
||||
console.warn("hook requestSent is deprecated and will be removed in the next release. " +
|
||||
"Please use responseSent instead.");
|
||||
yield hook.requestSent(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
responseSent(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.responseSent) {
|
||||
continue;
|
||||
}
|
||||
yield hook.responseSent(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
requestRouted(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestRouted) {
|
||||
continue;
|
||||
}
|
||||
yield hook.requestRouted(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
error(ctx, err) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.error) {
|
||||
continue;
|
||||
}
|
||||
yield hook.error(ctx, err);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
return serverHook;
|
||||
}
|
||||
exports.chainHooks = chainHooks;
|
||||
function isHook(object) {
|
||||
return ("requestReceived" in object ||
|
||||
"requestPrepared" in object ||
|
||||
"requestSent" in object ||
|
||||
"requestRouted" in object ||
|
||||
"responsePrepared" in object ||
|
||||
"responseSent" in object ||
|
||||
"error" in object);
|
||||
}
|
||||
exports.isHook = isHook;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5683:
|
||||
/***/ (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;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (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 (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__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.FetchRPC = exports.wrapErrorResponseToTwirpError = exports.NodeHttpRPC = void 0;
|
||||
const http = __importStar(__nccwpck_require__(8611));
|
||||
const https = __importStar(__nccwpck_require__(5692));
|
||||
const url_1 = __nccwpck_require__(7016);
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
/**
|
||||
* a node HTTP RPC implementation
|
||||
* @param options
|
||||
* @constructor
|
||||
*/
|
||||
const NodeHttpRPC = (options) => ({
|
||||
request(service, method, contentType, data) {
|
||||
let client;
|
||||
return new Promise((resolve, rejected) => {
|
||||
const responseChunks = [];
|
||||
const requestData = contentType === "application/protobuf"
|
||||
? Buffer.from(data)
|
||||
: JSON.stringify(data);
|
||||
const url = new url_1.URL(options.baseUrl);
|
||||
const isHttps = url.protocol === "https:";
|
||||
if (isHttps) {
|
||||
client = https;
|
||||
}
|
||||
else {
|
||||
client = http;
|
||||
}
|
||||
const prefix = url.pathname !== "/" ? url.pathname : "";
|
||||
const req = client
|
||||
.request(Object.assign(Object.assign({}, (options ? options : {})), { method: "POST", protocol: url.protocol, host: url.hostname, port: url.port ? url.port : isHttps ? 443 : 80, path: `${prefix}/${service}/${method}`, headers: Object.assign(Object.assign({}, (options.headers ? options.headers : {})), { "Content-Type": contentType, "Content-Length": contentType === "application/protobuf"
|
||||
? Buffer.byteLength(requestData)
|
||||
: Buffer.from(requestData).byteLength }) }), (res) => {
|
||||
res.on("data", (chunk) => responseChunks.push(chunk));
|
||||
res.on("end", () => {
|
||||
const data = Buffer.concat(responseChunks);
|
||||
if (res.statusCode != 200) {
|
||||
rejected(wrapErrorResponseToTwirpError(data.toString()));
|
||||
}
|
||||
else {
|
||||
if (contentType === "application/json") {
|
||||
resolve(JSON.parse(data.toString()));
|
||||
}
|
||||
else {
|
||||
resolve(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
res.on("error", (err) => {
|
||||
rejected(err);
|
||||
});
|
||||
})
|
||||
.on("error", (err) => {
|
||||
rejected(err);
|
||||
});
|
||||
req.end(requestData);
|
||||
});
|
||||
},
|
||||
});
|
||||
exports.NodeHttpRPC = NodeHttpRPC;
|
||||
function wrapErrorResponseToTwirpError(errorResponse) {
|
||||
return errors_1.TwirpError.fromObject(JSON.parse(errorResponse));
|
||||
}
|
||||
exports.wrapErrorResponseToTwirpError = wrapErrorResponseToTwirpError;
|
||||
/**
|
||||
* a browser fetch RPC implementation
|
||||
*/
|
||||
const FetchRPC = (options) => ({
|
||||
request(service, method, contentType, data) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const headers = new Headers(options.headers);
|
||||
headers.set("content-type", contentType);
|
||||
const response = yield fetch(`${options.baseUrl}/${service}/${method}`, Object.assign(Object.assign({}, options), { method: "POST", headers, body: data instanceof Uint8Array ? data : JSON.stringify(data) }));
|
||||
if (response.status === 200) {
|
||||
if (contentType === "application/json") {
|
||||
return yield response.json();
|
||||
}
|
||||
return new Uint8Array(yield response.arrayBuffer());
|
||||
}
|
||||
throw errors_1.TwirpError.fromObject(yield response.json());
|
||||
});
|
||||
},
|
||||
});
|
||||
exports.FetchRPC = FetchRPC;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 430:
|
||||
/***/ (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;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.TwirpContentType = void 0;
|
||||
__exportStar(__nccwpck_require__(5497), exports);
|
||||
__exportStar(__nccwpck_require__(1035), exports);
|
||||
__exportStar(__nccwpck_require__(4036), exports);
|
||||
__exportStar(__nccwpck_require__(3898), exports);
|
||||
__exportStar(__nccwpck_require__(3315), exports);
|
||||
__exportStar(__nccwpck_require__(9636), exports);
|
||||
__exportStar(__nccwpck_require__(5683), exports);
|
||||
var request_1 = __nccwpck_require__(9647);
|
||||
Object.defineProperty(exports, "TwirpContentType", ({ enumerable: true, get: function () { return request_1.TwirpContentType; } }));
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4036:
|
||||
/***/ (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.chainInterceptors = void 0;
|
||||
// chains multiple Interceptors into a single Interceptor.
|
||||
// The first interceptor wraps the second one, and so on.
|
||||
// Returns null if interceptors is empty.
|
||||
function chainInterceptors(...interceptors) {
|
||||
if (interceptors.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (interceptors.length === 1) {
|
||||
return interceptors[0];
|
||||
}
|
||||
const first = interceptors[0];
|
||||
return (ctx, request, handler) => __awaiter(this, void 0, void 0, function* () {
|
||||
let next = handler;
|
||||
for (let i = interceptors.length - 1; i > 0; i--) {
|
||||
next = ((next) => (ctx, typedRequest) => {
|
||||
return interceptors[i](ctx, typedRequest, next);
|
||||
})(next);
|
||||
}
|
||||
return first(ctx, request, next);
|
||||
});
|
||||
}
|
||||
exports.chainInterceptors = chainInterceptors;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9647:
|
||||
/***/ (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.parseTwirpPath = exports.getRequestData = exports.validateRequest = exports.getContentType = exports.TwirpContentType = void 0;
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
/**
|
||||
* Supported Twirp Content-Type
|
||||
*/
|
||||
var TwirpContentType;
|
||||
(function (TwirpContentType) {
|
||||
TwirpContentType[TwirpContentType["Protobuf"] = 0] = "Protobuf";
|
||||
TwirpContentType[TwirpContentType["JSON"] = 1] = "JSON";
|
||||
TwirpContentType[TwirpContentType["Unknown"] = 2] = "Unknown";
|
||||
})(TwirpContentType = exports.TwirpContentType || (exports.TwirpContentType = {}));
|
||||
/**
|
||||
* Get supported content-type
|
||||
* @param mimeType
|
||||
*/
|
||||
function getContentType(mimeType) {
|
||||
switch (mimeType) {
|
||||
case "application/protobuf":
|
||||
return TwirpContentType.Protobuf;
|
||||
case "application/json":
|
||||
return TwirpContentType.JSON;
|
||||
default:
|
||||
return TwirpContentType.Unknown;
|
||||
}
|
||||
}
|
||||
exports.getContentType = getContentType;
|
||||
/**
|
||||
* Validate a twirp request
|
||||
* @param ctx
|
||||
* @param request
|
||||
* @param pathPrefix
|
||||
*/
|
||||
function validateRequest(ctx, request, pathPrefix) {
|
||||
if (request.method !== "POST") {
|
||||
const msg = `unsupported method ${request.method} (only POST is allowed)`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
const path = parseTwirpPath(request.url || "");
|
||||
if (path.pkgService !==
|
||||
(ctx.packageName ? ctx.packageName + "." : "") + ctx.serviceName) {
|
||||
const msg = `no handler for path ${request.url}`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
if (path.prefix !== pathPrefix) {
|
||||
const msg = `invalid path prefix ${path.prefix}, expected ${pathPrefix}, on path ${request.url}`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
const mimeContentType = request.headers["content-type"] || "";
|
||||
if (ctx.contentType === TwirpContentType.Unknown) {
|
||||
const msg = `unexpected Content-Type: ${request.headers["content-type"]}`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
return Object.assign(Object.assign({}, path), { mimeContentType, contentType: ctx.contentType });
|
||||
}
|
||||
exports.validateRequest = validateRequest;
|
||||
/**
|
||||
* Get request data from the body
|
||||
* @param req
|
||||
*/
|
||||
function getRequestData(req) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reqWithRawBody = req;
|
||||
if (reqWithRawBody.rawBody instanceof Buffer) {
|
||||
resolve(reqWithRawBody.rawBody);
|
||||
return;
|
||||
}
|
||||
const chunks = [];
|
||||
req.on("data", (chunk) => chunks.push(chunk));
|
||||
req.on("end", () => __awaiter(this, void 0, void 0, function* () {
|
||||
const data = Buffer.concat(chunks);
|
||||
resolve(data);
|
||||
}));
|
||||
req.on("error", (err) => {
|
||||
if (req.aborted) {
|
||||
reject(new errors_1.TwirpError(errors_1.TwirpErrorCode.DeadlineExceeded, "failed to read request: deadline exceeded"));
|
||||
}
|
||||
else {
|
||||
reject(new errors_1.TwirpError(errors_1.TwirpErrorCode.Malformed, err.message).withCause(err));
|
||||
}
|
||||
});
|
||||
req.on("close", () => {
|
||||
reject(new errors_1.TwirpError(errors_1.TwirpErrorCode.Canceled, "failed to read request: context canceled"));
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.getRequestData = getRequestData;
|
||||
/**
|
||||
* Parses twirp url path
|
||||
* @param path
|
||||
*/
|
||||
function parseTwirpPath(path) {
|
||||
const parts = path.split("/");
|
||||
if (parts.length < 2) {
|
||||
return {
|
||||
pkgService: "",
|
||||
method: "",
|
||||
prefix: "",
|
||||
};
|
||||
}
|
||||
return {
|
||||
method: parts[parts.length - 1],
|
||||
pkgService: parts[parts.length - 2],
|
||||
prefix: parts.slice(0, parts.length - 2).join("/"),
|
||||
};
|
||||
}
|
||||
exports.parseTwirpPath = parseTwirpPath;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 1035:
|
||||
/***/ (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.writeError = exports.TwirpServer = void 0;
|
||||
const hooks_1 = __nccwpck_require__(3898);
|
||||
const request_1 = __nccwpck_require__(9647);
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
/**
|
||||
* Runtime server implementation of a TwirpServer
|
||||
*/
|
||||
class TwirpServer {
|
||||
constructor(options) {
|
||||
this.pathPrefix = "/twirp";
|
||||
this.hooks = [];
|
||||
this.interceptors = [];
|
||||
this.packageName = options.packageName;
|
||||
this.serviceName = options.serviceName;
|
||||
this.methodList = options.methodList;
|
||||
this.matchRoute = options.matchRoute;
|
||||
this.service = options.service;
|
||||
}
|
||||
/**
|
||||
* Returns the prefix for this server
|
||||
*/
|
||||
get prefix() {
|
||||
return this.pathPrefix;
|
||||
}
|
||||
/**
|
||||
* The http handler for twirp complaint endpoints
|
||||
* @param options
|
||||
*/
|
||||
httpHandler(options) {
|
||||
return (req, resp) => {
|
||||
// setup prefix
|
||||
if ((options === null || options === void 0 ? void 0 : options.prefix) !== undefined) {
|
||||
this.withPrefix(options.prefix);
|
||||
}
|
||||
return this._httpHandler(req, resp);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Adds interceptors or hooks to the request stack
|
||||
* @param middlewares
|
||||
*/
|
||||
use(...middlewares) {
|
||||
middlewares.forEach((middleware) => {
|
||||
if (hooks_1.isHook(middleware)) {
|
||||
this.hooks.push(middleware);
|
||||
return this;
|
||||
}
|
||||
this.interceptors.push(middleware);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Adds a prefix to the service url path
|
||||
* @param prefix
|
||||
*/
|
||||
withPrefix(prefix) {
|
||||
if (prefix === false) {
|
||||
this.pathPrefix = "";
|
||||
}
|
||||
else {
|
||||
this.pathPrefix = prefix;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Returns the regex matching path for this twirp server
|
||||
*/
|
||||
matchingPath() {
|
||||
const baseRegex = this.baseURI().replace(/\./g, "\\.");
|
||||
return new RegExp(`${baseRegex}\/(${this.methodList.join("|")})`);
|
||||
}
|
||||
/**
|
||||
* Returns the base URI for this twirp server
|
||||
*/
|
||||
baseURI() {
|
||||
return `${this.pathPrefix}/${this.packageName ? this.packageName + "." : ""}${this.serviceName}`;
|
||||
}
|
||||
/**
|
||||
* Create a twirp context
|
||||
* @param req
|
||||
* @param res
|
||||
* @private
|
||||
*/
|
||||
createContext(req, res) {
|
||||
return {
|
||||
packageName: this.packageName,
|
||||
serviceName: this.serviceName,
|
||||
methodName: "",
|
||||
contentType: request_1.getContentType(req.headers["content-type"]),
|
||||
req: req,
|
||||
res: res,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Twrip server http handler implementation
|
||||
* @param req
|
||||
* @param resp
|
||||
* @private
|
||||
*/
|
||||
_httpHandler(req, resp) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const ctx = this.createContext(req, resp);
|
||||
try {
|
||||
yield this.invokeHook("requestReceived", ctx);
|
||||
const { method, mimeContentType } = request_1.validateRequest(ctx, req, this.pathPrefix || "");
|
||||
const handler = this.matchRoute(method, {
|
||||
onMatch: (ctx) => {
|
||||
return this.invokeHook("requestRouted", ctx);
|
||||
},
|
||||
onNotFound: () => {
|
||||
const msg = `no handler for path ${req.url}`;
|
||||
throw new errors_1.BadRouteError(msg, req.method || "", req.url || "");
|
||||
},
|
||||
});
|
||||
const body = yield request_1.getRequestData(req);
|
||||
const response = yield handler(ctx, this.service, body, this.interceptors);
|
||||
yield Promise.all([
|
||||
this.invokeHook("responsePrepared", ctx),
|
||||
// keep backwards compatibility till next release
|
||||
this.invokeHook("requestPrepared", ctx),
|
||||
]);
|
||||
resp.statusCode = 200;
|
||||
resp.setHeader("Content-Type", mimeContentType);
|
||||
resp.end(response);
|
||||
}
|
||||
catch (e) {
|
||||
yield this.invokeHook("error", ctx, mustBeTwirpError(e));
|
||||
if (!resp.headersSent) {
|
||||
writeError(resp, e);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
yield Promise.all([
|
||||
this.invokeHook("responseSent", ctx),
|
||||
// keep backwards compatibility till next release
|
||||
this.invokeHook("requestSent", ctx),
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Invoke a hook
|
||||
* @param hookName
|
||||
* @param ctx
|
||||
* @param err
|
||||
* @protected
|
||||
*/
|
||||
invokeHook(hookName, ctx, err) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (this.hooks.length === 0) {
|
||||
return;
|
||||
}
|
||||
const chainedHooks = hooks_1.chainHooks(...this.hooks);
|
||||
const hook = chainedHooks === null || chainedHooks === void 0 ? void 0 : chainedHooks[hookName];
|
||||
if (hook) {
|
||||
yield hook(ctx, err || new errors_1.InternalServerError("internal server error"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.TwirpServer = TwirpServer;
|
||||
/**
|
||||
* Write http error response
|
||||
* @param res
|
||||
* @param error
|
||||
*/
|
||||
function writeError(res, error) {
|
||||
const twirpError = mustBeTwirpError(error);
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
res.statusCode = errors_1.httpStatusFromErrorCode(twirpError.code);
|
||||
res.end(twirpError.toJSON());
|
||||
}
|
||||
exports.writeError = writeError;
|
||||
/**
|
||||
* Make sure that the error passed is a TwirpError
|
||||
* otherwise it will wrap it into an InternalError
|
||||
* @param err
|
||||
*/
|
||||
function mustBeTwirpError(err) {
|
||||
if (err instanceof errors_1.TwirpError) {
|
||||
return err;
|
||||
}
|
||||
return new errors_1.InternalServerErrorWith(err);
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8736:
|
||||
@ -68120,14 +65257,6 @@ module.exports = require("punycode");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3480:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("querystring");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2203:
|
||||
/***/ ((module) => {
|
||||
|
||||
@ -68188,7 +65317,7 @@ module.exports = require("zlib");
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.0.0","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1","twirp-ts":"^2.5.0"},"devDependencies":{"@types/semver":"^6.0.0","typescript":"^5.2.2"}}');
|
||||
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.0.2","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1"},"devDependencies":{"@types/semver":"^6.0.0","typescript":"^5.2.2"}}');
|
||||
|
||||
/***/ }),
|
||||
|
||||
|
||||
2913
dist/restore/index.js
vendored
2913
dist/restore/index.js
vendored
@ -220,7 +220,7 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
||||
};
|
||||
const response = yield twirpClient.GetCacheEntryDownloadURL(request);
|
||||
if (!response.ok) {
|
||||
core.warning(`Cache not found for keys: ${keys.join(', ')}`);
|
||||
core.debug(`Cache not found for keys: ${keys.join(', ')}`);
|
||||
return undefined;
|
||||
}
|
||||
core.info(`Cache hit for: ${request.key}`);
|
||||
@ -412,12 +412,20 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
key,
|
||||
version
|
||||
};
|
||||
const response = yield twirpClient.CreateCacheEntry(request);
|
||||
if (!response.ok) {
|
||||
let signedUploadUrl;
|
||||
try {
|
||||
const response = yield twirpClient.CreateCacheEntry(request);
|
||||
if (!response.ok) {
|
||||
throw new Error('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, response.signedUploadUrl, options);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options);
|
||||
const finalizeRequest = {
|
||||
key,
|
||||
version,
|
||||
@ -458,156 +466,13 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8200:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Timestamp = void 0;
|
||||
const runtime_1 = __nccwpck_require__(8886);
|
||||
const runtime_2 = __nccwpck_require__(8886);
|
||||
const runtime_3 = __nccwpck_require__(8886);
|
||||
const runtime_4 = __nccwpck_require__(8886);
|
||||
const runtime_5 = __nccwpck_require__(8886);
|
||||
const runtime_6 = __nccwpck_require__(8886);
|
||||
const runtime_7 = __nccwpck_require__(8886);
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class Timestamp$Type extends runtime_7.MessageType {
|
||||
constructor() {
|
||||
super("google.protobuf.Timestamp", [
|
||||
{ no: 1, name: "seconds", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
|
||||
{ no: 2, name: "nanos", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* Creates a new `Timestamp` for the current time.
|
||||
*/
|
||||
now() {
|
||||
const msg = this.create();
|
||||
const ms = Date.now();
|
||||
msg.seconds = runtime_6.PbLong.from(Math.floor(ms / 1000)).toString();
|
||||
msg.nanos = (ms % 1000) * 1000000;
|
||||
return msg;
|
||||
}
|
||||
/**
|
||||
* Converts a `Timestamp` to a JavaScript Date.
|
||||
*/
|
||||
toDate(message) {
|
||||
return new Date(runtime_6.PbLong.from(message.seconds).toNumber() * 1000 + Math.ceil(message.nanos / 1000000));
|
||||
}
|
||||
/**
|
||||
* Converts a JavaScript Date to a `Timestamp`.
|
||||
*/
|
||||
fromDate(date) {
|
||||
const msg = this.create();
|
||||
const ms = date.getTime();
|
||||
msg.seconds = runtime_6.PbLong.from(Math.floor(ms / 1000)).toString();
|
||||
msg.nanos = (ms % 1000) * 1000000;
|
||||
return msg;
|
||||
}
|
||||
/**
|
||||
* In JSON format, the `Timestamp` type is encoded as a string
|
||||
* in the RFC 3339 format.
|
||||
*/
|
||||
internalJsonWrite(message, options) {
|
||||
let ms = runtime_6.PbLong.from(message.seconds).toNumber() * 1000;
|
||||
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z"))
|
||||
throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");
|
||||
if (message.nanos < 0)
|
||||
throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");
|
||||
let z = "Z";
|
||||
if (message.nanos > 0) {
|
||||
let nanosStr = (message.nanos + 1000000000).toString().substring(1);
|
||||
if (nanosStr.substring(3) === "000000")
|
||||
z = "." + nanosStr.substring(0, 3) + "Z";
|
||||
else if (nanosStr.substring(6) === "000")
|
||||
z = "." + nanosStr.substring(0, 6) + "Z";
|
||||
else
|
||||
z = "." + nanosStr + "Z";
|
||||
}
|
||||
return new Date(ms).toISOString().replace(".000Z", z);
|
||||
}
|
||||
/**
|
||||
* In JSON format, the `Timestamp` type is encoded as a string
|
||||
* in the RFC 3339 format.
|
||||
*/
|
||||
internalJsonRead(json, options, target) {
|
||||
if (typeof json !== "string")
|
||||
throw new Error("Unable to parse Timestamp from JSON " + (0, runtime_5.typeofJsonValue)(json) + ".");
|
||||
let matches = json.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);
|
||||
if (!matches)
|
||||
throw new Error("Unable to parse Timestamp from JSON. Invalid format.");
|
||||
let ms = Date.parse(matches[1] + "-" + matches[2] + "-" + matches[3] + "T" + matches[4] + ":" + matches[5] + ":" + matches[6] + (matches[8] ? matches[8] : "Z"));
|
||||
if (Number.isNaN(ms))
|
||||
throw new Error("Unable to parse Timestamp from JSON. Invalid value.");
|
||||
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z"))
|
||||
throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");
|
||||
if (!target)
|
||||
target = this.create();
|
||||
target.seconds = runtime_6.PbLong.from(ms / 1000).toString();
|
||||
target.nanos = 0;
|
||||
if (matches[7])
|
||||
target.nanos = (parseInt("1" + matches[7] + "0".repeat(9 - matches[7].length)) - 1000000000);
|
||||
return target;
|
||||
}
|
||||
create(value) {
|
||||
const message = { seconds: "0", nanos: 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 /* int64 seconds */ 1:
|
||||
message.seconds = reader.int64().toString();
|
||||
break;
|
||||
case /* int32 nanos */ 2:
|
||||
message.nanos = reader.int32();
|
||||
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 seconds = 1; */
|
||||
if (message.seconds !== "0")
|
||||
writer.tag(1, runtime_1.WireType.Varint).int64(message.seconds);
|
||||
/* int32 nanos = 2; */
|
||||
if (message.nanos !== 0)
|
||||
writer.tag(2, runtime_1.WireType.Varint).int32(message.nanos);
|
||||
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 google.protobuf.Timestamp
|
||||
*/
|
||||
exports.Timestamp = new Timestamp$Type();
|
||||
//# sourceMappingURL=timestamp.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3156:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.CacheService = exports.LookupCacheEntryResponse = exports.LookupCacheEntryRequest = exports.ListCacheEntriesResponse = exports.ListCacheEntriesRequest = exports.DeleteCacheEntryResponse = exports.DeleteCacheEntryRequest = exports.GetCacheEntryDownloadURLResponse = exports.GetCacheEntryDownloadURLRequest = exports.FinalizeCacheEntryUploadResponse = exports.FinalizeCacheEntryUploadRequest = exports.CreateCacheEntryResponse = exports.CreateCacheEntryRequest = void 0;
|
||||
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
|
||||
@ -617,7 +482,6 @@ const runtime_2 = __nccwpck_require__(8886);
|
||||
const runtime_3 = __nccwpck_require__(8886);
|
||||
const runtime_4 = __nccwpck_require__(8886);
|
||||
const runtime_5 = __nccwpck_require__(8886);
|
||||
const cacheentry_1 = __nccwpck_require__(5893);
|
||||
const cachemetadata_1 = __nccwpck_require__(9444);
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class CreateCacheEntryRequest$Type extends runtime_5.MessageType {
|
||||
@ -985,376 +849,25 @@ class GetCacheEntryDownloadURLResponse$Type extends runtime_5.MessageType {
|
||||
* @generated MessageType for protobuf message github.actions.results.api.v1.GetCacheEntryDownloadURLResponse
|
||||
*/
|
||||
exports.GetCacheEntryDownloadURLResponse = new GetCacheEntryDownloadURLResponse$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class DeleteCacheEntryRequest$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.DeleteCacheEntryRequest", [
|
||||
{ no: 1, name: "metadata", kind: "message", T: () => cachemetadata_1.CacheMetadata },
|
||||
{ no: 2, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { key: "" };
|
||||
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;
|
||||
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);
|
||||
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.DeleteCacheEntryRequest
|
||||
*/
|
||||
exports.DeleteCacheEntryRequest = new DeleteCacheEntryRequest$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class DeleteCacheEntryResponse$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.DeleteCacheEntryResponse", [
|
||||
{ no: 1, name: "ok", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
|
||||
{ no: 2, name: "entry_id", kind: "scalar", T: 3 /*ScalarType.INT64*/ }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { ok: false, entryId: "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 /* bool ok */ 1:
|
||||
message.ok = reader.bool();
|
||||
break;
|
||||
case /* int64 entry_id */ 2:
|
||||
message.entryId = 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) {
|
||||
/* 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);
|
||||
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.DeleteCacheEntryResponse
|
||||
*/
|
||||
exports.DeleteCacheEntryResponse = new DeleteCacheEntryResponse$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class ListCacheEntriesRequest$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.ListCacheEntriesRequest", [
|
||||
{ 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*/ }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { key: "", restoreKeys: [] };
|
||||
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;
|
||||
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]);
|
||||
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.ListCacheEntriesRequest
|
||||
*/
|
||||
exports.ListCacheEntriesRequest = new ListCacheEntriesRequest$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class ListCacheEntriesResponse$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.ListCacheEntriesResponse", [
|
||||
{ no: 1, name: "entries", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => cacheentry_1.CacheEntry }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { entries: [] };
|
||||
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 /* repeated github.actions.results.entities.v1.CacheEntry entries */ 1:
|
||||
message.entries.push(cacheentry_1.CacheEntry.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) {
|
||||
/* repeated github.actions.results.entities.v1.CacheEntry entries = 1; */
|
||||
for (let i = 0; i < message.entries.length; i++)
|
||||
cacheentry_1.CacheEntry.internalBinaryWrite(message.entries[i], writer.tag(1, 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.api.v1.ListCacheEntriesResponse
|
||||
*/
|
||||
exports.ListCacheEntriesResponse = new ListCacheEntriesResponse$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class LookupCacheEntryRequest$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.LookupCacheEntryRequest", [
|
||||
{ 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.LookupCacheEntryRequest
|
||||
*/
|
||||
exports.LookupCacheEntryRequest = new LookupCacheEntryRequest$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class LookupCacheEntryResponse$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.LookupCacheEntryResponse", [
|
||||
{ no: 1, name: "exists", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
|
||||
{ no: 2, name: "entry", kind: "message", T: () => cacheentry_1.CacheEntry }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { exists: false };
|
||||
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 exists */ 1:
|
||||
message.exists = reader.bool();
|
||||
break;
|
||||
case /* github.actions.results.entities.v1.CacheEntry entry */ 2:
|
||||
message.entry = cacheentry_1.CacheEntry.internalBinaryRead(reader, reader.uint32(), options, message.entry);
|
||||
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 exists = 1; */
|
||||
if (message.exists !== false)
|
||||
writer.tag(1, runtime_1.WireType.Varint).bool(message.exists);
|
||||
/* github.actions.results.entities.v1.CacheEntry entry = 2; */
|
||||
if (message.entry)
|
||||
cacheentry_1.CacheEntry.internalBinaryWrite(message.entry, 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.api.v1.LookupCacheEntryResponse
|
||||
*/
|
||||
exports.LookupCacheEntryResponse = new LookupCacheEntryResponse$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 },
|
||||
{ name: "DeleteCacheEntry", options: {}, I: exports.DeleteCacheEntryRequest, O: exports.DeleteCacheEntryResponse },
|
||||
{ name: "ListCacheEntries", options: {}, I: exports.ListCacheEntriesRequest, O: exports.ListCacheEntriesResponse },
|
||||
{ name: "LookupCacheEntry", options: {}, I: exports.LookupCacheEntryRequest, O: exports.LookupCacheEntryResponse }
|
||||
{ name: "GetCacheEntryDownloadURL", options: {}, I: exports.GetCacheEntryDownloadURLRequest, O: exports.GetCacheEntryDownloadURLResponse }
|
||||
]);
|
||||
//# sourceMappingURL=cache.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 564:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
/***/ 1486:
|
||||
/***/ ((__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.createCacheServiceServer = exports.CacheServiceMethodList = exports.CacheServiceMethod = exports.CacheServiceClientProtobuf = exports.CacheServiceClientJSON = void 0;
|
||||
const twirp_ts_1 = __nccwpck_require__(430);
|
||||
exports.CacheServiceClientProtobuf = exports.CacheServiceClientJSON = void 0;
|
||||
const cache_1 = __nccwpck_require__(3156);
|
||||
class CacheServiceClientJSON {
|
||||
constructor(rpc) {
|
||||
@ -1362,9 +875,6 @@ class CacheServiceClientJSON {
|
||||
this.CreateCacheEntry.bind(this);
|
||||
this.FinalizeCacheEntryUpload.bind(this);
|
||||
this.GetCacheEntryDownloadURL.bind(this);
|
||||
this.DeleteCacheEntry.bind(this);
|
||||
this.ListCacheEntries.bind(this);
|
||||
this.LookupCacheEntry.bind(this);
|
||||
}
|
||||
CreateCacheEntry(request) {
|
||||
const data = cache_1.CreateCacheEntryRequest.toJson(request, {
|
||||
@ -1396,36 +906,6 @@ class CacheServiceClientJSON {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
DeleteCacheEntry(request) {
|
||||
const data = cache_1.DeleteCacheEntryRequest.toJson(request, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
});
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "DeleteCacheEntry", "application/json", data);
|
||||
return promise.then((data) => cache_1.DeleteCacheEntryResponse.fromJson(data, {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
ListCacheEntries(request) {
|
||||
const data = cache_1.ListCacheEntriesRequest.toJson(request, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
});
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "ListCacheEntries", "application/json", data);
|
||||
return promise.then((data) => cache_1.ListCacheEntriesResponse.fromJson(data, {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
LookupCacheEntry(request) {
|
||||
const data = cache_1.LookupCacheEntryRequest.toJson(request, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
});
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "LookupCacheEntry", "application/json", data);
|
||||
return promise.then((data) => cache_1.LookupCacheEntryResponse.fromJson(data, {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
}
|
||||
exports.CacheServiceClientJSON = CacheServiceClientJSON;
|
||||
class CacheServiceClientProtobuf {
|
||||
@ -1434,9 +914,6 @@ class CacheServiceClientProtobuf {
|
||||
this.CreateCacheEntry.bind(this);
|
||||
this.FinalizeCacheEntryUpload.bind(this);
|
||||
this.GetCacheEntryDownloadURL.bind(this);
|
||||
this.DeleteCacheEntry.bind(this);
|
||||
this.ListCacheEntries.bind(this);
|
||||
this.LookupCacheEntry.bind(this);
|
||||
}
|
||||
CreateCacheEntry(request) {
|
||||
const data = cache_1.CreateCacheEntryRequest.toBinary(request);
|
||||
@ -1453,610 +930,9 @@ class CacheServiceClientProtobuf {
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "GetCacheEntryDownloadURL", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.GetCacheEntryDownloadURLResponse.fromBinary(data));
|
||||
}
|
||||
DeleteCacheEntry(request) {
|
||||
const data = cache_1.DeleteCacheEntryRequest.toBinary(request);
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "DeleteCacheEntry", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.DeleteCacheEntryResponse.fromBinary(data));
|
||||
}
|
||||
ListCacheEntries(request) {
|
||||
const data = cache_1.ListCacheEntriesRequest.toBinary(request);
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "ListCacheEntries", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.ListCacheEntriesResponse.fromBinary(data));
|
||||
}
|
||||
LookupCacheEntry(request) {
|
||||
const data = cache_1.LookupCacheEntryRequest.toBinary(request);
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "LookupCacheEntry", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.LookupCacheEntryResponse.fromBinary(data));
|
||||
}
|
||||
}
|
||||
exports.CacheServiceClientProtobuf = CacheServiceClientProtobuf;
|
||||
var CacheServiceMethod;
|
||||
(function (CacheServiceMethod) {
|
||||
CacheServiceMethod["CreateCacheEntry"] = "CreateCacheEntry";
|
||||
CacheServiceMethod["FinalizeCacheEntryUpload"] = "FinalizeCacheEntryUpload";
|
||||
CacheServiceMethod["GetCacheEntryDownloadURL"] = "GetCacheEntryDownloadURL";
|
||||
CacheServiceMethod["DeleteCacheEntry"] = "DeleteCacheEntry";
|
||||
CacheServiceMethod["ListCacheEntries"] = "ListCacheEntries";
|
||||
CacheServiceMethod["LookupCacheEntry"] = "LookupCacheEntry";
|
||||
})(CacheServiceMethod || (exports.CacheServiceMethod = CacheServiceMethod = {}));
|
||||
exports.CacheServiceMethodList = [
|
||||
CacheServiceMethod.CreateCacheEntry,
|
||||
CacheServiceMethod.FinalizeCacheEntryUpload,
|
||||
CacheServiceMethod.GetCacheEntryDownloadURL,
|
||||
CacheServiceMethod.DeleteCacheEntry,
|
||||
CacheServiceMethod.ListCacheEntries,
|
||||
CacheServiceMethod.LookupCacheEntry,
|
||||
];
|
||||
function createCacheServiceServer(service) {
|
||||
return new twirp_ts_1.TwirpServer({
|
||||
service,
|
||||
packageName: "github.actions.results.api.v1",
|
||||
serviceName: "CacheService",
|
||||
methodList: exports.CacheServiceMethodList,
|
||||
matchRoute: matchCacheServiceRoute,
|
||||
});
|
||||
}
|
||||
exports.createCacheServiceServer = createCacheServiceServer;
|
||||
function matchCacheServiceRoute(method, events) {
|
||||
switch (method) {
|
||||
case "CreateCacheEntry":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "CreateCacheEntry" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceCreateCacheEntryRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "FinalizeCacheEntryUpload":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "FinalizeCacheEntryUpload" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceFinalizeCacheEntryUploadRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "GetCacheEntryDownloadURL":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "GetCacheEntryDownloadURL" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceGetCacheEntryDownloadURLRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "DeleteCacheEntry":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "DeleteCacheEntry" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceDeleteCacheEntryRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "ListCacheEntries":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "ListCacheEntries" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceListCacheEntriesRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "LookupCacheEntry":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "LookupCacheEntry" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceLookupCacheEntryRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
default:
|
||||
events.onNotFound();
|
||||
const msg = `no handler found`;
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceCreateCacheEntryRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceCreateCacheEntryJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceCreateCacheEntryProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceFinalizeCacheEntryUploadRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceFinalizeCacheEntryUploadJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceFinalizeCacheEntryUploadProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceGetCacheEntryDownloadURLRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceGetCacheEntryDownloadURLJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceGetCacheEntryDownloadURLProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceDeleteCacheEntryRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceDeleteCacheEntryJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceDeleteCacheEntryProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceListCacheEntriesRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceListCacheEntriesJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceListCacheEntriesProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceLookupCacheEntryRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceLookupCacheEntryJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceLookupCacheEntryProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceCreateCacheEntryJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.CreateCacheEntryRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.CreateCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.CreateCacheEntry(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.CreateCacheEntryResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceFinalizeCacheEntryUploadJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.FinalizeCacheEntryUploadRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.FinalizeCacheEntryUpload(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.FinalizeCacheEntryUpload(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.FinalizeCacheEntryUploadResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceGetCacheEntryDownloadURLJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.GetCacheEntryDownloadURLRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.GetCacheEntryDownloadURL(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.GetCacheEntryDownloadURL(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.GetCacheEntryDownloadURLResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceDeleteCacheEntryJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.DeleteCacheEntryRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.DeleteCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.DeleteCacheEntry(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.DeleteCacheEntryResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceListCacheEntriesJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.ListCacheEntriesRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.ListCacheEntries(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.ListCacheEntries(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.ListCacheEntriesResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceLookupCacheEntryJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.LookupCacheEntryRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.LookupCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.LookupCacheEntry(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.LookupCacheEntryResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceCreateCacheEntryProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.CreateCacheEntryRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.CreateCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.CreateCacheEntry(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.CreateCacheEntryResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceFinalizeCacheEntryUploadProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.FinalizeCacheEntryUploadRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.FinalizeCacheEntryUpload(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.FinalizeCacheEntryUpload(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.FinalizeCacheEntryUploadResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceGetCacheEntryDownloadURLProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.GetCacheEntryDownloadURLRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.GetCacheEntryDownloadURL(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.GetCacheEntryDownloadURL(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.GetCacheEntryDownloadURLResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceDeleteCacheEntryProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.DeleteCacheEntryRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.DeleteCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.DeleteCacheEntry(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.DeleteCacheEntryResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceListCacheEntriesProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.ListCacheEntriesRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.ListCacheEntries(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.ListCacheEntries(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.ListCacheEntriesResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceLookupCacheEntryProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.LookupCacheEntryRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.LookupCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.LookupCacheEntry(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.LookupCacheEntryResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=cache.twirp.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5893:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.CacheEntry = void 0;
|
||||
const runtime_1 = __nccwpck_require__(8886);
|
||||
const runtime_2 = __nccwpck_require__(8886);
|
||||
const runtime_3 = __nccwpck_require__(8886);
|
||||
const runtime_4 = __nccwpck_require__(8886);
|
||||
const runtime_5 = __nccwpck_require__(8886);
|
||||
const timestamp_1 = __nccwpck_require__(8200);
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class CacheEntry$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.entities.v1.CacheEntry", [
|
||||
{ no: 1, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 2, name: "hash", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 3, name: "size_bytes", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
|
||||
{ no: 4, name: "scope", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 5, name: "version", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 6, name: "created_at", kind: "message", T: () => timestamp_1.Timestamp },
|
||||
{ no: 7, name: "last_accessed_at", kind: "message", T: () => timestamp_1.Timestamp },
|
||||
{ no: 8, name: "expires_at", kind: "message", T: () => timestamp_1.Timestamp }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { key: "", hash: "", sizeBytes: "0", scope: "", 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 /* string key */ 1:
|
||||
message.key = reader.string();
|
||||
break;
|
||||
case /* string hash */ 2:
|
||||
message.hash = reader.string();
|
||||
break;
|
||||
case /* int64 size_bytes */ 3:
|
||||
message.sizeBytes = reader.int64().toString();
|
||||
break;
|
||||
case /* string scope */ 4:
|
||||
message.scope = reader.string();
|
||||
break;
|
||||
case /* string version */ 5:
|
||||
message.version = reader.string();
|
||||
break;
|
||||
case /* google.protobuf.Timestamp created_at */ 6:
|
||||
message.createdAt = timestamp_1.Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.createdAt);
|
||||
break;
|
||||
case /* google.protobuf.Timestamp last_accessed_at */ 7:
|
||||
message.lastAccessedAt = timestamp_1.Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.lastAccessedAt);
|
||||
break;
|
||||
case /* google.protobuf.Timestamp expires_at */ 8:
|
||||
message.expiresAt = timestamp_1.Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.expiresAt);
|
||||
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 key = 1; */
|
||||
if (message.key !== "")
|
||||
writer.tag(1, runtime_1.WireType.LengthDelimited).string(message.key);
|
||||
/* string hash = 2; */
|
||||
if (message.hash !== "")
|
||||
writer.tag(2, runtime_1.WireType.LengthDelimited).string(message.hash);
|
||||
/* int64 size_bytes = 3; */
|
||||
if (message.sizeBytes !== "0")
|
||||
writer.tag(3, runtime_1.WireType.Varint).int64(message.sizeBytes);
|
||||
/* string scope = 4; */
|
||||
if (message.scope !== "")
|
||||
writer.tag(4, runtime_1.WireType.LengthDelimited).string(message.scope);
|
||||
/* string version = 5; */
|
||||
if (message.version !== "")
|
||||
writer.tag(5, runtime_1.WireType.LengthDelimited).string(message.version);
|
||||
/* google.protobuf.Timestamp created_at = 6; */
|
||||
if (message.createdAt)
|
||||
timestamp_1.Timestamp.internalBinaryWrite(message.createdAt, writer.tag(6, runtime_1.WireType.LengthDelimited).fork(), options).join();
|
||||
/* google.protobuf.Timestamp last_accessed_at = 7; */
|
||||
if (message.lastAccessedAt)
|
||||
timestamp_1.Timestamp.internalBinaryWrite(message.lastAccessedAt, writer.tag(7, runtime_1.WireType.LengthDelimited).fork(), options).join();
|
||||
/* google.protobuf.Timestamp expires_at = 8; */
|
||||
if (message.expiresAt)
|
||||
timestamp_1.Timestamp.internalBinaryWrite(message.expiresAt, writer.tag(8, 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.CacheEntry
|
||||
*/
|
||||
exports.CacheEntry = new CacheEntry$Type();
|
||||
//# sourceMappingURL=cacheentry.js.map
|
||||
//# sourceMappingURL=cache.twirp-client.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
@ -3327,7 +2203,7 @@ const config_1 = __nccwpck_require__(7606);
|
||||
const cacheUtils_1 = __nccwpck_require__(8299);
|
||||
const auth_1 = __nccwpck_require__(4552);
|
||||
const http_client_1 = __nccwpck_require__(4844);
|
||||
const cache_twirp_1 = __nccwpck_require__(564);
|
||||
const cache_twirp_client_1 = __nccwpck_require__(1486);
|
||||
/**
|
||||
* This class is a wrapper around the CacheServiceClientJSON class generated by Twirp.
|
||||
*
|
||||
@ -3464,7 +2340,7 @@ class CacheServiceClient {
|
||||
}
|
||||
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_1.CacheServiceClientJSON(client);
|
||||
return new cache_twirp_client_1.CacheServiceClientJSON(client);
|
||||
}
|
||||
exports.internalCacheTwirpClient = internalCacheTwirpClient;
|
||||
//# sourceMappingURL=cacheTwirpClient.js.map
|
||||
@ -52391,599 +51267,6 @@ DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
|
||||
};
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5129:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
function _process (v, mod) {
|
||||
var i
|
||||
var r
|
||||
|
||||
if (typeof mod === 'function') {
|
||||
r = mod(v)
|
||||
if (r !== undefined) {
|
||||
v = r
|
||||
}
|
||||
} else if (Array.isArray(mod)) {
|
||||
for (i = 0; i < mod.length; i++) {
|
||||
r = mod[i](v)
|
||||
if (r !== undefined) {
|
||||
v = r
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
function parseKey (key, val) {
|
||||
// detect negative index notation
|
||||
if (key[0] === '-' && Array.isArray(val) && /^-\d+$/.test(key)) {
|
||||
return val.length + parseInt(key, 10)
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
function isIndex (k) {
|
||||
return /^\d+$/.test(k)
|
||||
}
|
||||
|
||||
function isObject (val) {
|
||||
return Object.prototype.toString.call(val) === '[object Object]'
|
||||
}
|
||||
|
||||
function isArrayOrObject (val) {
|
||||
return Object(val) === val
|
||||
}
|
||||
|
||||
function isEmptyObject (val) {
|
||||
return Object.keys(val).length === 0
|
||||
}
|
||||
|
||||
var blacklist = ['__proto__', 'prototype', 'constructor']
|
||||
var blacklistFilter = function (part) { return blacklist.indexOf(part) === -1 }
|
||||
|
||||
function parsePath (path, sep) {
|
||||
if (path.indexOf('[') >= 0) {
|
||||
path = path.replace(/\[/g, sep).replace(/]/g, '')
|
||||
}
|
||||
|
||||
var parts = path.split(sep)
|
||||
|
||||
var check = parts.filter(blacklistFilter)
|
||||
|
||||
if (check.length !== parts.length) {
|
||||
throw Error('Refusing to update blacklisted property ' + path)
|
||||
}
|
||||
|
||||
return parts
|
||||
}
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
|
||||
function DotObject (separator, override, useArray, useBrackets) {
|
||||
if (!(this instanceof DotObject)) {
|
||||
return new DotObject(separator, override, useArray, useBrackets)
|
||||
}
|
||||
|
||||
if (typeof override === 'undefined') override = false
|
||||
if (typeof useArray === 'undefined') useArray = true
|
||||
if (typeof useBrackets === 'undefined') useBrackets = true
|
||||
this.separator = separator || '.'
|
||||
this.override = override
|
||||
this.useArray = useArray
|
||||
this.useBrackets = useBrackets
|
||||
this.keepArray = false
|
||||
|
||||
// contains touched arrays
|
||||
this.cleanup = []
|
||||
}
|
||||
|
||||
var dotDefault = new DotObject('.', false, true, true)
|
||||
function wrap (method) {
|
||||
return function () {
|
||||
return dotDefault[method].apply(dotDefault, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
DotObject.prototype._fill = function (a, obj, v, mod) {
|
||||
var k = a.shift()
|
||||
|
||||
if (a.length > 0) {
|
||||
obj[k] = obj[k] || (this.useArray && isIndex(a[0]) ? [] : {})
|
||||
|
||||
if (!isArrayOrObject(obj[k])) {
|
||||
if (this.override) {
|
||||
obj[k] = {}
|
||||
} else {
|
||||
if (!(isArrayOrObject(v) && isEmptyObject(v))) {
|
||||
throw new Error(
|
||||
'Trying to redefine `' + k + '` which is a ' + typeof obj[k]
|
||||
)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this._fill(a, obj[k], v, mod)
|
||||
} else {
|
||||
if (!this.override && isArrayOrObject(obj[k]) && !isEmptyObject(obj[k])) {
|
||||
if (!(isArrayOrObject(v) && isEmptyObject(v))) {
|
||||
throw new Error("Trying to redefine non-empty obj['" + k + "']")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
obj[k] = _process(v, mod)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts an object with dotted-key/value pairs to it's expanded version
|
||||
*
|
||||
* Optionally transformed by a set of modifiers.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* var row = {
|
||||
* 'nr': 200,
|
||||
* 'doc.name': ' My Document '
|
||||
* }
|
||||
*
|
||||
* var mods = {
|
||||
* 'doc.name': [_s.trim, _s.underscored]
|
||||
* }
|
||||
*
|
||||
* dot.object(row, mods)
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {Object} mods
|
||||
*/
|
||||
DotObject.prototype.object = function (obj, mods) {
|
||||
var self = this
|
||||
|
||||
Object.keys(obj).forEach(function (k) {
|
||||
var mod = mods === undefined ? null : mods[k]
|
||||
// normalize array notation.
|
||||
var ok = parsePath(k, self.separator).join(self.separator)
|
||||
|
||||
if (ok.indexOf(self.separator) !== -1) {
|
||||
self._fill(ok.split(self.separator), obj, obj[k], mod)
|
||||
delete obj[k]
|
||||
} else {
|
||||
obj[k] = _process(obj[k], mod)
|
||||
}
|
||||
})
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} path dotted path
|
||||
* @param {String} v value to be set
|
||||
* @param {Object} obj object to be modified
|
||||
* @param {Function|Array} mod optional modifier
|
||||
*/
|
||||
DotObject.prototype.str = function (path, v, obj, mod) {
|
||||
var ok = parsePath(path, this.separator).join(this.separator)
|
||||
|
||||
if (path.indexOf(this.separator) !== -1) {
|
||||
this._fill(ok.split(this.separator), obj, v, mod)
|
||||
} else {
|
||||
obj[path] = _process(v, mod)
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Pick a value from an object using dot notation.
|
||||
*
|
||||
* Optionally remove the value
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} remove
|
||||
*/
|
||||
DotObject.prototype.pick = function (path, obj, remove, reindexArray) {
|
||||
var i
|
||||
var keys
|
||||
var val
|
||||
var key
|
||||
var cp
|
||||
|
||||
keys = parsePath(path, this.separator)
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
key = parseKey(keys[i], obj)
|
||||
if (obj && typeof obj === 'object' && key in obj) {
|
||||
if (i === keys.length - 1) {
|
||||
if (remove) {
|
||||
val = obj[key]
|
||||
if (reindexArray && Array.isArray(obj)) {
|
||||
obj.splice(key, 1)
|
||||
} else {
|
||||
delete obj[key]
|
||||
}
|
||||
if (Array.isArray(obj)) {
|
||||
cp = keys.slice(0, -1).join('.')
|
||||
if (this.cleanup.indexOf(cp) === -1) {
|
||||
this.cleanup.push(cp)
|
||||
}
|
||||
}
|
||||
return val
|
||||
} else {
|
||||
return obj[key]
|
||||
}
|
||||
} else {
|
||||
obj = obj[key]
|
||||
}
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
if (remove && Array.isArray(obj)) {
|
||||
obj = obj.filter(function (n) {
|
||||
return n !== undefined
|
||||
})
|
||||
}
|
||||
return obj
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Delete value from an object using dot notation.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Object} obj
|
||||
* @return {any} The removed value
|
||||
*/
|
||||
DotObject.prototype.delete = function (path, obj) {
|
||||
return this.remove(path, obj, true)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Remove value from an object using dot notation.
|
||||
*
|
||||
* Will remove multiple items if path is an array.
|
||||
* In this case array indexes will be retained until all
|
||||
* removals have been processed.
|
||||
*
|
||||
* Use dot.delete() to automatically re-index arrays.
|
||||
*
|
||||
* @param {String|Array<String>} path
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} reindexArray
|
||||
* @return {any} The removed value
|
||||
*/
|
||||
DotObject.prototype.remove = function (path, obj, reindexArray) {
|
||||
var i
|
||||
|
||||
this.cleanup = []
|
||||
if (Array.isArray(path)) {
|
||||
for (i = 0; i < path.length; i++) {
|
||||
this.pick(path[i], obj, true, reindexArray)
|
||||
}
|
||||
if (!reindexArray) {
|
||||
this._cleanup(obj)
|
||||
}
|
||||
return obj
|
||||
} else {
|
||||
return this.pick(path, obj, true, reindexArray)
|
||||
}
|
||||
}
|
||||
|
||||
DotObject.prototype._cleanup = function (obj) {
|
||||
var ret
|
||||
var i
|
||||
var keys
|
||||
var root
|
||||
if (this.cleanup.length) {
|
||||
for (i = 0; i < this.cleanup.length; i++) {
|
||||
keys = this.cleanup[i].split('.')
|
||||
root = keys.splice(0, -1).join('.')
|
||||
ret = root ? this.pick(root, obj) : obj
|
||||
ret = ret[keys[0]].filter(function (v) {
|
||||
return v !== undefined
|
||||
})
|
||||
this.set(this.cleanup[i], ret, obj)
|
||||
}
|
||||
this.cleanup = []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias method for `dot.remove`
|
||||
*
|
||||
* Note: this is not an alias for dot.delete()
|
||||
*
|
||||
* @param {String|Array<String>} path
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} reindexArray
|
||||
* @return {any} The removed value
|
||||
*/
|
||||
DotObject.prototype.del = DotObject.prototype.remove
|
||||
|
||||
/**
|
||||
*
|
||||
* Move a property from one place to the other.
|
||||
*
|
||||
* If the source path does not exist (undefined)
|
||||
* the target property will not be set.
|
||||
*
|
||||
* @param {String} source
|
||||
* @param {String} target
|
||||
* @param {Object} obj
|
||||
* @param {Function|Array} mods
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.move = function (source, target, obj, mods, merge) {
|
||||
if (typeof mods === 'function' || Array.isArray(mods)) {
|
||||
this.set(target, _process(this.pick(source, obj, true), mods), obj, merge)
|
||||
} else {
|
||||
merge = mods
|
||||
this.set(target, this.pick(source, obj, true), obj, merge)
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Transfer a property from one object to another object.
|
||||
*
|
||||
* If the source path does not exist (undefined)
|
||||
* the property on the other object will not be set.
|
||||
*
|
||||
* @param {String} source
|
||||
* @param {String} target
|
||||
* @param {Object} obj1
|
||||
* @param {Object} obj2
|
||||
* @param {Function|Array} mods
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.transfer = function (
|
||||
source,
|
||||
target,
|
||||
obj1,
|
||||
obj2,
|
||||
mods,
|
||||
merge
|
||||
) {
|
||||
if (typeof mods === 'function' || Array.isArray(mods)) {
|
||||
this.set(
|
||||
target,
|
||||
_process(this.pick(source, obj1, true), mods),
|
||||
obj2,
|
||||
merge
|
||||
)
|
||||
} else {
|
||||
merge = mods
|
||||
this.set(target, this.pick(source, obj1, true), obj2, merge)
|
||||
}
|
||||
|
||||
return obj2
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Copy a property from one object to another object.
|
||||
*
|
||||
* If the source path does not exist (undefined)
|
||||
* the property on the other object will not be set.
|
||||
*
|
||||
* @param {String} source
|
||||
* @param {String} target
|
||||
* @param {Object} obj1
|
||||
* @param {Object} obj2
|
||||
* @param {Function|Array} mods
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.copy = function (source, target, obj1, obj2, mods, merge) {
|
||||
if (typeof mods === 'function' || Array.isArray(mods)) {
|
||||
this.set(
|
||||
target,
|
||||
_process(
|
||||
// clone what is picked
|
||||
JSON.parse(JSON.stringify(this.pick(source, obj1, false))),
|
||||
mods
|
||||
),
|
||||
obj2,
|
||||
merge
|
||||
)
|
||||
} else {
|
||||
merge = mods
|
||||
this.set(target, this.pick(source, obj1, false), obj2, merge)
|
||||
}
|
||||
|
||||
return obj2
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Set a property on an object using dot notation.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {any} val
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.set = function (path, val, obj, merge) {
|
||||
var i
|
||||
var k
|
||||
var keys
|
||||
var key
|
||||
|
||||
// Do not operate if the value is undefined.
|
||||
if (typeof val === 'undefined') {
|
||||
return obj
|
||||
}
|
||||
keys = parsePath(path, this.separator)
|
||||
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
key = keys[i]
|
||||
if (i === keys.length - 1) {
|
||||
if (merge && isObject(val) && isObject(obj[key])) {
|
||||
for (k in val) {
|
||||
if (hasOwnProperty.call(val, k)) {
|
||||
obj[key][k] = val[k]
|
||||
}
|
||||
}
|
||||
} else if (merge && Array.isArray(obj[key]) && Array.isArray(val)) {
|
||||
for (var j = 0; j < val.length; j++) {
|
||||
obj[keys[i]].push(val[j])
|
||||
}
|
||||
} else {
|
||||
obj[key] = val
|
||||
}
|
||||
} else if (
|
||||
// force the value to be an object
|
||||
!hasOwnProperty.call(obj, key) ||
|
||||
(!isObject(obj[key]) && !Array.isArray(obj[key]))
|
||||
) {
|
||||
// initialize as array if next key is numeric
|
||||
if (/^\d+$/.test(keys[i + 1])) {
|
||||
obj[key] = []
|
||||
} else {
|
||||
obj[key] = {}
|
||||
}
|
||||
}
|
||||
obj = obj[key]
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Transform an object
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* var obj = {
|
||||
* "id": 1,
|
||||
* "some": {
|
||||
* "thing": "else"
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* var transform = {
|
||||
* "id": "nr",
|
||||
* "some.thing": "name"
|
||||
* }
|
||||
*
|
||||
* var tgt = dot.transform(transform, obj)
|
||||
*
|
||||
* @param {Object} recipe Transform recipe
|
||||
* @param {Object} obj Object to be transformed
|
||||
* @param {Array} mods modifiers for the target
|
||||
*/
|
||||
DotObject.prototype.transform = function (recipe, obj, tgt) {
|
||||
obj = obj || {}
|
||||
tgt = tgt || {}
|
||||
Object.keys(recipe).forEach(
|
||||
function (key) {
|
||||
this.set(recipe[key], this.pick(key, obj), tgt)
|
||||
}.bind(this)
|
||||
)
|
||||
return tgt
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convert object to dotted-key/value pair
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* var tgt = dot.dot(obj)
|
||||
*
|
||||
* or
|
||||
*
|
||||
* var tgt = {}
|
||||
* dot.dot(obj, tgt)
|
||||
*
|
||||
* @param {Object} obj source object
|
||||
* @param {Object} tgt target object
|
||||
* @param {Array} path path array (internal)
|
||||
*/
|
||||
DotObject.prototype.dot = function (obj, tgt, path) {
|
||||
tgt = tgt || {}
|
||||
path = path || []
|
||||
var isArray = Array.isArray(obj)
|
||||
|
||||
Object.keys(obj).forEach(
|
||||
function (key) {
|
||||
var index = isArray && this.useBrackets ? '[' + key + ']' : key
|
||||
if (
|
||||
isArrayOrObject(obj[key]) &&
|
||||
((isObject(obj[key]) && !isEmptyObject(obj[key])) ||
|
||||
(Array.isArray(obj[key]) && !this.keepArray && obj[key].length !== 0))
|
||||
) {
|
||||
if (isArray && this.useBrackets) {
|
||||
var previousKey = path[path.length - 1] || ''
|
||||
return this.dot(
|
||||
obj[key],
|
||||
tgt,
|
||||
path.slice(0, -1).concat(previousKey + index)
|
||||
)
|
||||
} else {
|
||||
return this.dot(obj[key], tgt, path.concat(index))
|
||||
}
|
||||
} else {
|
||||
if (isArray && this.useBrackets) {
|
||||
tgt[path.join(this.separator).concat('[' + key + ']')] = obj[key]
|
||||
} else {
|
||||
tgt[path.concat(index).join(this.separator)] = obj[key]
|
||||
}
|
||||
}
|
||||
}.bind(this)
|
||||
)
|
||||
return tgt
|
||||
}
|
||||
|
||||
DotObject.pick = wrap('pick')
|
||||
DotObject.move = wrap('move')
|
||||
DotObject.transfer = wrap('transfer')
|
||||
DotObject.transform = wrap('transform')
|
||||
DotObject.copy = wrap('copy')
|
||||
DotObject.object = wrap('object')
|
||||
DotObject.str = wrap('str')
|
||||
DotObject.set = wrap('set')
|
||||
DotObject.delete = wrap('delete')
|
||||
DotObject.del = DotObject.remove = wrap('remove')
|
||||
DotObject.dot = wrap('dot');
|
||||
['override', 'overwrite'].forEach(function (prop) {
|
||||
Object.defineProperty(DotObject, prop, {
|
||||
get: function () {
|
||||
return dotDefault.override
|
||||
},
|
||||
set: function (val) {
|
||||
dotDefault.override = !!val
|
||||
}
|
||||
})
|
||||
});
|
||||
['useArray', 'keepArray', 'useBrackets'].forEach(function (prop) {
|
||||
Object.defineProperty(DotObject, prop, {
|
||||
get: function () {
|
||||
return dotDefault[prop]
|
||||
},
|
||||
set: function (val) {
|
||||
dotDefault[prop] = val
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
DotObject._process = _process
|
||||
|
||||
module.exports = DotObject
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9829:
|
||||
@ -61521,1152 +59804,6 @@ if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) {
|
||||
exports.debug = debug; // for test
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5497:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3315:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.isValidErrorCode = exports.httpStatusFromErrorCode = exports.TwirpErrorCode = exports.BadRouteError = exports.InternalServerErrorWith = exports.InternalServerError = exports.RequiredArgumentError = exports.InvalidArgumentError = exports.NotFoundError = exports.TwirpError = void 0;
|
||||
/**
|
||||
* Represents a twirp error
|
||||
*/
|
||||
class TwirpError extends Error {
|
||||
constructor(code, msg) {
|
||||
super(msg);
|
||||
this.code = TwirpErrorCode.Internal;
|
||||
this.meta = {};
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
Object.setPrototypeOf(this, TwirpError.prototype);
|
||||
}
|
||||
/**
|
||||
* Adds a metadata kv to the error
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
withMeta(key, value) {
|
||||
this.meta[key] = value;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Returns a single metadata value
|
||||
* return "" if not found
|
||||
* @param key
|
||||
*/
|
||||
getMeta(key) {
|
||||
return this.meta[key] || "";
|
||||
}
|
||||
/**
|
||||
* Add the original error cause
|
||||
* @param err
|
||||
* @param addMeta
|
||||
*/
|
||||
withCause(err, addMeta = false) {
|
||||
this._originalCause = err;
|
||||
if (addMeta) {
|
||||
this.withMeta("cause", err.message);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
cause() {
|
||||
return this._originalCause;
|
||||
}
|
||||
/**
|
||||
* Returns the error representation to JSON
|
||||
*/
|
||||
toJSON() {
|
||||
try {
|
||||
return JSON.stringify({
|
||||
code: this.code,
|
||||
msg: this.msg,
|
||||
meta: this.meta,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
return `{"code": "internal", "msg": "There was an error but it could not be serialized into JSON"}`;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create a twirp error from an object
|
||||
* @param obj
|
||||
*/
|
||||
static fromObject(obj) {
|
||||
const code = obj["code"] || TwirpErrorCode.Unknown;
|
||||
const msg = obj["msg"] || "unknown";
|
||||
const error = new TwirpError(code, msg);
|
||||
if (obj["meta"]) {
|
||||
Object.keys(obj["meta"]).forEach((key) => {
|
||||
error.withMeta(key, obj["meta"][key]);
|
||||
});
|
||||
}
|
||||
return error;
|
||||
}
|
||||
}
|
||||
exports.TwirpError = TwirpError;
|
||||
/**
|
||||
* NotFoundError constructor for the common NotFound error.
|
||||
*/
|
||||
class NotFoundError extends TwirpError {
|
||||
constructor(msg) {
|
||||
super(TwirpErrorCode.NotFound, msg);
|
||||
}
|
||||
}
|
||||
exports.NotFoundError = NotFoundError;
|
||||
/**
|
||||
* InvalidArgumentError constructor for the common InvalidArgument error. Can be
|
||||
* used when an argument has invalid format, is a number out of range, is a bad
|
||||
* option, etc).
|
||||
*/
|
||||
class InvalidArgumentError extends TwirpError {
|
||||
constructor(argument, validationMsg) {
|
||||
super(TwirpErrorCode.InvalidArgument, argument + " " + validationMsg);
|
||||
this.withMeta("argument", argument);
|
||||
}
|
||||
}
|
||||
exports.InvalidArgumentError = InvalidArgumentError;
|
||||
/**
|
||||
* RequiredArgumentError is a more specific constructor for InvalidArgument
|
||||
* error. Should be used when the argument is required (expected to have a
|
||||
* non-zero value).
|
||||
*/
|
||||
class RequiredArgumentError extends InvalidArgumentError {
|
||||
constructor(argument) {
|
||||
super(argument, "is required");
|
||||
}
|
||||
}
|
||||
exports.RequiredArgumentError = RequiredArgumentError;
|
||||
/**
|
||||
* InternalError constructor for the common Internal error. Should be used to
|
||||
* specify that something bad or unexpected happened.
|
||||
*/
|
||||
class InternalServerError extends TwirpError {
|
||||
constructor(msg) {
|
||||
super(TwirpErrorCode.Internal, msg);
|
||||
}
|
||||
}
|
||||
exports.InternalServerError = InternalServerError;
|
||||
/**
|
||||
* InternalErrorWith makes an internal error, wrapping the original error and using it
|
||||
* for the error message, and with metadata "cause" with the original error type.
|
||||
* This function is used by Twirp services to wrap non-Twirp errors as internal errors.
|
||||
* The wrapped error can be extracted later with err.cause()
|
||||
*/
|
||||
class InternalServerErrorWith extends InternalServerError {
|
||||
constructor(err) {
|
||||
super(err.message);
|
||||
this.withMeta("cause", err.name);
|
||||
this.withCause(err);
|
||||
}
|
||||
}
|
||||
exports.InternalServerErrorWith = InternalServerErrorWith;
|
||||
/**
|
||||
* A standard BadRoute Error
|
||||
*/
|
||||
class BadRouteError extends TwirpError {
|
||||
constructor(msg, method, url) {
|
||||
super(TwirpErrorCode.BadRoute, msg);
|
||||
this.withMeta("twirp_invalid_route", method + " " + url);
|
||||
}
|
||||
}
|
||||
exports.BadRouteError = BadRouteError;
|
||||
var TwirpErrorCode;
|
||||
(function (TwirpErrorCode) {
|
||||
// Canceled indicates the operation was cancelled (typically by the caller).
|
||||
TwirpErrorCode["Canceled"] = "canceled";
|
||||
// Unknown error. For example when handling errors raised by APIs that do not
|
||||
// return enough error information.
|
||||
TwirpErrorCode["Unknown"] = "unknown";
|
||||
// InvalidArgument indicates client specified an invalid argument. It
|
||||
// indicates arguments that are problematic regardless of the state of the
|
||||
// system (i.e. a malformed file name, required argument, number out of range,
|
||||
// etc.).
|
||||
TwirpErrorCode["InvalidArgument"] = "invalid_argument";
|
||||
// Malformed indicates an error occurred while decoding the client's request.
|
||||
// This may mean that the message was encoded improperly, or that there is a
|
||||
// disagreement in message format between the client and server.
|
||||
TwirpErrorCode["Malformed"] = "malformed";
|
||||
// DeadlineExceeded means operation expired before completion. For operations
|
||||
// that change the state of the system, this error may be returned even if the
|
||||
// operation has completed successfully (timeout).
|
||||
TwirpErrorCode["DeadlineExceeded"] = "deadline_exceeded";
|
||||
// NotFound means some requested entity was not found.
|
||||
TwirpErrorCode["NotFound"] = "not_found";
|
||||
// BadRoute means that the requested URL path wasn't routable to a Twirp
|
||||
// service and method. This is returned by the generated server, and usually
|
||||
// shouldn't be returned by applications. Instead, applications should use
|
||||
// NotFound or Unimplemented.
|
||||
TwirpErrorCode["BadRoute"] = "bad_route";
|
||||
// AlreadyExists means an attempt to create an entity failed because one
|
||||
// already exists.
|
||||
TwirpErrorCode["AlreadyExists"] = "already_exists";
|
||||
// PermissionDenied indicates the caller does not have permission to execute
|
||||
// the specified operation. It must not be used if the caller cannot be
|
||||
// identified (Unauthenticated).
|
||||
TwirpErrorCode["PermissionDenied"] = "permission_denied";
|
||||
// Unauthenticated indicates the request does not have valid authentication
|
||||
// credentials for the operation.
|
||||
TwirpErrorCode["Unauthenticated"] = "unauthenticated";
|
||||
// ResourceExhausted indicates some resource has been exhausted, perhaps a
|
||||
// per-user quota, or perhaps the entire file system is out of space.
|
||||
TwirpErrorCode["ResourceExhausted"] = "resource_exhausted";
|
||||
// FailedPrecondition indicates operation was rejected because the system is
|
||||
// not in a state required for the operation's execution. For example, doing
|
||||
// an rmdir operation on a directory that is non-empty, or on a non-directory
|
||||
// object, or when having conflicting read-modify-write on the same resource.
|
||||
TwirpErrorCode["FailedPrecondition"] = "failed_precondition";
|
||||
// Aborted indicates the operation was aborted, typically due to a concurrency
|
||||
// issue like sequencer check failures, transaction aborts, etc.
|
||||
TwirpErrorCode["Aborted"] = "aborted";
|
||||
// OutOfRange means operation was attempted past the valid range. For example,
|
||||
// seeking or reading past end of a paginated collection.
|
||||
//
|
||||
// Unlike InvalidArgument, this error indicates a problem that may be fixed if
|
||||
// the system state changes (i.e. adding more items to the collection).
|
||||
//
|
||||
// There is a fair bit of overlap between FailedPrecondition and OutOfRange.
|
||||
// We recommend using OutOfRange (the more specific error) when it applies so
|
||||
// that callers who are iterating through a space can easily look for an
|
||||
// OutOfRange error to detect when they are done.
|
||||
TwirpErrorCode["OutOfRange"] = "out_of_range";
|
||||
// Unimplemented indicates operation is not implemented or not
|
||||
// supported/enabled in this service.
|
||||
TwirpErrorCode["Unimplemented"] = "unimplemented";
|
||||
// Internal errors. When some invariants expected by the underlying system
|
||||
// have been broken. In other words, something bad happened in the library or
|
||||
// backend service. Do not confuse with HTTP Internal Server Error; an
|
||||
// Internal error could also happen on the client code, i.e. when parsing a
|
||||
// server response.
|
||||
TwirpErrorCode["Internal"] = "internal";
|
||||
// Unavailable indicates the service is currently unavailable. This is a most
|
||||
// likely a transient condition and may be corrected by retrying with a
|
||||
// backoff.
|
||||
TwirpErrorCode["Unavailable"] = "unavailable";
|
||||
// DataLoss indicates unrecoverable data loss or corruption.
|
||||
TwirpErrorCode["DataLoss"] = "data_loss";
|
||||
})(TwirpErrorCode = exports.TwirpErrorCode || (exports.TwirpErrorCode = {}));
|
||||
// ServerHTTPStatusFromErrorCode maps a Twirp error type into a similar HTTP
|
||||
// response status. It is used by the Twirp server handler to set the HTTP
|
||||
// response status code. Returns 0 if the ErrorCode is invalid.
|
||||
function httpStatusFromErrorCode(code) {
|
||||
switch (code) {
|
||||
case TwirpErrorCode.Canceled:
|
||||
return 408; // RequestTimeout
|
||||
case TwirpErrorCode.Unknown:
|
||||
return 500; // Internal Server Error
|
||||
case TwirpErrorCode.InvalidArgument:
|
||||
return 400; // BadRequest
|
||||
case TwirpErrorCode.Malformed:
|
||||
return 400; // BadRequest
|
||||
case TwirpErrorCode.DeadlineExceeded:
|
||||
return 408; // RequestTimeout
|
||||
case TwirpErrorCode.NotFound:
|
||||
return 404; // Not Found
|
||||
case TwirpErrorCode.BadRoute:
|
||||
return 404; // Not Found
|
||||
case TwirpErrorCode.AlreadyExists:
|
||||
return 409; // Conflict
|
||||
case TwirpErrorCode.PermissionDenied:
|
||||
return 403; // Forbidden
|
||||
case TwirpErrorCode.Unauthenticated:
|
||||
return 401; // Unauthorized
|
||||
case TwirpErrorCode.ResourceExhausted:
|
||||
return 429; // Too Many Requests
|
||||
case TwirpErrorCode.FailedPrecondition:
|
||||
return 412; // Precondition Failed
|
||||
case TwirpErrorCode.Aborted:
|
||||
return 409; // Conflict
|
||||
case TwirpErrorCode.OutOfRange:
|
||||
return 400; // Bad Request
|
||||
case TwirpErrorCode.Unimplemented:
|
||||
return 501; // Not Implemented
|
||||
case TwirpErrorCode.Internal:
|
||||
return 500; // Internal Server Error
|
||||
case TwirpErrorCode.Unavailable:
|
||||
return 503; // Service Unavailable
|
||||
case TwirpErrorCode.DataLoss:
|
||||
return 500; // Internal Server Error
|
||||
default:
|
||||
return 0; // Invalid!
|
||||
}
|
||||
}
|
||||
exports.httpStatusFromErrorCode = httpStatusFromErrorCode;
|
||||
// IsValidErrorCode returns true if is one of the valid predefined constants.
|
||||
function isValidErrorCode(code) {
|
||||
return httpStatusFromErrorCode(code) != 0;
|
||||
}
|
||||
exports.isValidErrorCode = isValidErrorCode;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9636:
|
||||
/***/ (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;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (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 (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__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 __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Gateway = exports.Pattern = void 0;
|
||||
const querystring_1 = __nccwpck_require__(3480);
|
||||
const dotObject = __importStar(__nccwpck_require__(5129));
|
||||
const request_1 = __nccwpck_require__(9647);
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
const http_client_1 = __nccwpck_require__(5683);
|
||||
const server_1 = __nccwpck_require__(1035);
|
||||
var Pattern;
|
||||
(function (Pattern) {
|
||||
Pattern["POST"] = "post";
|
||||
Pattern["GET"] = "get";
|
||||
Pattern["PATCH"] = "patch";
|
||||
Pattern["PUT"] = "put";
|
||||
Pattern["DELETE"] = "delete";
|
||||
})(Pattern = exports.Pattern || (exports.Pattern = {}));
|
||||
/**
|
||||
* The Gateway proxies http requests to Twirp Compliant
|
||||
* handlers
|
||||
*/
|
||||
class Gateway {
|
||||
constructor(routes) {
|
||||
this.routes = routes;
|
||||
}
|
||||
/**
|
||||
* Middleware that rewrite the current request
|
||||
* to a Twirp compliant request
|
||||
*/
|
||||
twirpRewrite(prefix = "/twirp") {
|
||||
return (req, resp, next) => {
|
||||
this.rewrite(req, resp, prefix)
|
||||
.then(() => next())
|
||||
.catch((e) => {
|
||||
if (e instanceof errors_1.TwirpError) {
|
||||
if (e.code !== errors_1.TwirpErrorCode.NotFound) {
|
||||
server_1.writeError(resp, e);
|
||||
}
|
||||
else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Rewrite an incoming request to a Twirp compliant request
|
||||
* @param req
|
||||
* @param resp
|
||||
* @param prefix
|
||||
*/
|
||||
rewrite(req, resp, prefix = "/twirp") {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const [match, route] = this.matchRoute(req);
|
||||
const body = yield this.prepareTwirpBody(req, match, route);
|
||||
const twirpUrl = `${prefix}/${route.packageName}.${route.serviceName}/${route.methodName}`;
|
||||
req.url = twirpUrl;
|
||||
req.originalUrl = twirpUrl;
|
||||
req.method = "POST";
|
||||
req.headers["content-type"] = "application/json";
|
||||
req.rawBody = Buffer.from(JSON.stringify(body));
|
||||
if (route.responseBodyKey) {
|
||||
const endFn = resp.end.bind(resp);
|
||||
resp.end = function (chunk) {
|
||||
if (resp.statusCode === 200) {
|
||||
endFn(`{ "${route.responseBodyKey}": ${chunk} }`);
|
||||
}
|
||||
else {
|
||||
endFn(chunk);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Create a reverse proxy handler to
|
||||
* proxy http requests to Twirp Compliant handlers
|
||||
* @param httpClientOption
|
||||
*/
|
||||
reverseProxy(httpClientOption) {
|
||||
const client = http_client_1.NodeHttpRPC(httpClientOption);
|
||||
return (req, res) => __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const [match, route] = this.matchRoute(req);
|
||||
const body = yield this.prepareTwirpBody(req, match, route);
|
||||
const response = yield client.request(`${route.packageName}.${route.serviceName}`, route.methodName, "application/json", body);
|
||||
res.statusCode = 200;
|
||||
res.setHeader("content-type", "application/json");
|
||||
let jsonResponse;
|
||||
if (route.responseBodyKey) {
|
||||
jsonResponse = JSON.stringify({ [route.responseBodyKey]: response });
|
||||
}
|
||||
else {
|
||||
jsonResponse = JSON.stringify(response);
|
||||
}
|
||||
res.end(jsonResponse);
|
||||
}
|
||||
catch (e) {
|
||||
server_1.writeError(res, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Prepares twirp body requests using http.google.annotions
|
||||
* compliant spec
|
||||
*
|
||||
* @param req
|
||||
* @param match
|
||||
* @param route
|
||||
* @protected
|
||||
*/
|
||||
prepareTwirpBody(req, match, route) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const _a = match.params, { query_string } = _a, params = __rest(_a, ["query_string"]);
|
||||
let requestBody = Object.assign({}, params);
|
||||
if (query_string && route.bodyKey !== "*") {
|
||||
const queryParams = this.parseQueryString(query_string);
|
||||
requestBody = Object.assign(Object.assign({}, queryParams), requestBody);
|
||||
}
|
||||
let body = {};
|
||||
if (route.bodyKey) {
|
||||
const data = yield request_1.getRequestData(req);
|
||||
try {
|
||||
const jsonBody = JSON.parse(data.toString() || "{}");
|
||||
if (route.bodyKey === "*") {
|
||||
body = jsonBody;
|
||||
}
|
||||
else {
|
||||
body[route.bodyKey] = jsonBody;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new errors_1.TwirpError(errors_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
return Object.assign(Object.assign({}, body), requestBody);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Matches a route
|
||||
* @param req
|
||||
*/
|
||||
matchRoute(req) {
|
||||
var _a;
|
||||
const httpMethod = (_a = req.method) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
||||
if (!httpMethod) {
|
||||
throw new errors_1.BadRouteError(`method not allowed`, req.method || "", req.url || "");
|
||||
}
|
||||
const routes = this.routes[httpMethod];
|
||||
for (const route of routes) {
|
||||
const match = route.matcher(req.url || "/");
|
||||
if (match) {
|
||||
return [match, route];
|
||||
}
|
||||
}
|
||||
throw new errors_1.NotFoundError(`url ${req.url} not found`);
|
||||
}
|
||||
/**
|
||||
* Parse query string
|
||||
* @param queryString
|
||||
*/
|
||||
parseQueryString(queryString) {
|
||||
const queryParams = querystring_1.parse(queryString.replace("?", ""));
|
||||
return dotObject.object(queryParams);
|
||||
}
|
||||
}
|
||||
exports.Gateway = Gateway;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3898:
|
||||
/***/ (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.isHook = exports.chainHooks = void 0;
|
||||
// ChainHooks creates a new ServerHook which chains the callbacks in
|
||||
// each of the constituent hooks passed in. Each hook function will be
|
||||
// called in the order of the ServerHooks values passed in.
|
||||
//
|
||||
// For the erroring hooks, RequestReceived and RequestRouted, any returned
|
||||
// errors prevent processing by later hooks.
|
||||
function chainHooks(...hooks) {
|
||||
if (hooks.length === 0) {
|
||||
return null;
|
||||
}
|
||||
if (hooks.length === 1) {
|
||||
return hooks[0];
|
||||
}
|
||||
const serverHook = {
|
||||
requestReceived(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestReceived) {
|
||||
continue;
|
||||
}
|
||||
yield hook.requestReceived(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
requestPrepared(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestPrepared) {
|
||||
continue;
|
||||
}
|
||||
console.warn("hook requestPrepared is deprecated and will be removed in the next release. " +
|
||||
"Please use responsePrepared instead.");
|
||||
yield hook.requestPrepared(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
responsePrepared(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.responsePrepared) {
|
||||
continue;
|
||||
}
|
||||
yield hook.responsePrepared(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
requestSent(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestSent) {
|
||||
continue;
|
||||
}
|
||||
console.warn("hook requestSent is deprecated and will be removed in the next release. " +
|
||||
"Please use responseSent instead.");
|
||||
yield hook.requestSent(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
responseSent(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.responseSent) {
|
||||
continue;
|
||||
}
|
||||
yield hook.responseSent(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
requestRouted(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestRouted) {
|
||||
continue;
|
||||
}
|
||||
yield hook.requestRouted(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
error(ctx, err) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.error) {
|
||||
continue;
|
||||
}
|
||||
yield hook.error(ctx, err);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
return serverHook;
|
||||
}
|
||||
exports.chainHooks = chainHooks;
|
||||
function isHook(object) {
|
||||
return ("requestReceived" in object ||
|
||||
"requestPrepared" in object ||
|
||||
"requestSent" in object ||
|
||||
"requestRouted" in object ||
|
||||
"responsePrepared" in object ||
|
||||
"responseSent" in object ||
|
||||
"error" in object);
|
||||
}
|
||||
exports.isHook = isHook;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5683:
|
||||
/***/ (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;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (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 (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__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.FetchRPC = exports.wrapErrorResponseToTwirpError = exports.NodeHttpRPC = void 0;
|
||||
const http = __importStar(__nccwpck_require__(8611));
|
||||
const https = __importStar(__nccwpck_require__(5692));
|
||||
const url_1 = __nccwpck_require__(7016);
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
/**
|
||||
* a node HTTP RPC implementation
|
||||
* @param options
|
||||
* @constructor
|
||||
*/
|
||||
const NodeHttpRPC = (options) => ({
|
||||
request(service, method, contentType, data) {
|
||||
let client;
|
||||
return new Promise((resolve, rejected) => {
|
||||
const responseChunks = [];
|
||||
const requestData = contentType === "application/protobuf"
|
||||
? Buffer.from(data)
|
||||
: JSON.stringify(data);
|
||||
const url = new url_1.URL(options.baseUrl);
|
||||
const isHttps = url.protocol === "https:";
|
||||
if (isHttps) {
|
||||
client = https;
|
||||
}
|
||||
else {
|
||||
client = http;
|
||||
}
|
||||
const prefix = url.pathname !== "/" ? url.pathname : "";
|
||||
const req = client
|
||||
.request(Object.assign(Object.assign({}, (options ? options : {})), { method: "POST", protocol: url.protocol, host: url.hostname, port: url.port ? url.port : isHttps ? 443 : 80, path: `${prefix}/${service}/${method}`, headers: Object.assign(Object.assign({}, (options.headers ? options.headers : {})), { "Content-Type": contentType, "Content-Length": contentType === "application/protobuf"
|
||||
? Buffer.byteLength(requestData)
|
||||
: Buffer.from(requestData).byteLength }) }), (res) => {
|
||||
res.on("data", (chunk) => responseChunks.push(chunk));
|
||||
res.on("end", () => {
|
||||
const data = Buffer.concat(responseChunks);
|
||||
if (res.statusCode != 200) {
|
||||
rejected(wrapErrorResponseToTwirpError(data.toString()));
|
||||
}
|
||||
else {
|
||||
if (contentType === "application/json") {
|
||||
resolve(JSON.parse(data.toString()));
|
||||
}
|
||||
else {
|
||||
resolve(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
res.on("error", (err) => {
|
||||
rejected(err);
|
||||
});
|
||||
})
|
||||
.on("error", (err) => {
|
||||
rejected(err);
|
||||
});
|
||||
req.end(requestData);
|
||||
});
|
||||
},
|
||||
});
|
||||
exports.NodeHttpRPC = NodeHttpRPC;
|
||||
function wrapErrorResponseToTwirpError(errorResponse) {
|
||||
return errors_1.TwirpError.fromObject(JSON.parse(errorResponse));
|
||||
}
|
||||
exports.wrapErrorResponseToTwirpError = wrapErrorResponseToTwirpError;
|
||||
/**
|
||||
* a browser fetch RPC implementation
|
||||
*/
|
||||
const FetchRPC = (options) => ({
|
||||
request(service, method, contentType, data) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const headers = new Headers(options.headers);
|
||||
headers.set("content-type", contentType);
|
||||
const response = yield fetch(`${options.baseUrl}/${service}/${method}`, Object.assign(Object.assign({}, options), { method: "POST", headers, body: data instanceof Uint8Array ? data : JSON.stringify(data) }));
|
||||
if (response.status === 200) {
|
||||
if (contentType === "application/json") {
|
||||
return yield response.json();
|
||||
}
|
||||
return new Uint8Array(yield response.arrayBuffer());
|
||||
}
|
||||
throw errors_1.TwirpError.fromObject(yield response.json());
|
||||
});
|
||||
},
|
||||
});
|
||||
exports.FetchRPC = FetchRPC;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 430:
|
||||
/***/ (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;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.TwirpContentType = void 0;
|
||||
__exportStar(__nccwpck_require__(5497), exports);
|
||||
__exportStar(__nccwpck_require__(1035), exports);
|
||||
__exportStar(__nccwpck_require__(4036), exports);
|
||||
__exportStar(__nccwpck_require__(3898), exports);
|
||||
__exportStar(__nccwpck_require__(3315), exports);
|
||||
__exportStar(__nccwpck_require__(9636), exports);
|
||||
__exportStar(__nccwpck_require__(5683), exports);
|
||||
var request_1 = __nccwpck_require__(9647);
|
||||
Object.defineProperty(exports, "TwirpContentType", ({ enumerable: true, get: function () { return request_1.TwirpContentType; } }));
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4036:
|
||||
/***/ (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.chainInterceptors = void 0;
|
||||
// chains multiple Interceptors into a single Interceptor.
|
||||
// The first interceptor wraps the second one, and so on.
|
||||
// Returns null if interceptors is empty.
|
||||
function chainInterceptors(...interceptors) {
|
||||
if (interceptors.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (interceptors.length === 1) {
|
||||
return interceptors[0];
|
||||
}
|
||||
const first = interceptors[0];
|
||||
return (ctx, request, handler) => __awaiter(this, void 0, void 0, function* () {
|
||||
let next = handler;
|
||||
for (let i = interceptors.length - 1; i > 0; i--) {
|
||||
next = ((next) => (ctx, typedRequest) => {
|
||||
return interceptors[i](ctx, typedRequest, next);
|
||||
})(next);
|
||||
}
|
||||
return first(ctx, request, next);
|
||||
});
|
||||
}
|
||||
exports.chainInterceptors = chainInterceptors;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9647:
|
||||
/***/ (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.parseTwirpPath = exports.getRequestData = exports.validateRequest = exports.getContentType = exports.TwirpContentType = void 0;
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
/**
|
||||
* Supported Twirp Content-Type
|
||||
*/
|
||||
var TwirpContentType;
|
||||
(function (TwirpContentType) {
|
||||
TwirpContentType[TwirpContentType["Protobuf"] = 0] = "Protobuf";
|
||||
TwirpContentType[TwirpContentType["JSON"] = 1] = "JSON";
|
||||
TwirpContentType[TwirpContentType["Unknown"] = 2] = "Unknown";
|
||||
})(TwirpContentType = exports.TwirpContentType || (exports.TwirpContentType = {}));
|
||||
/**
|
||||
* Get supported content-type
|
||||
* @param mimeType
|
||||
*/
|
||||
function getContentType(mimeType) {
|
||||
switch (mimeType) {
|
||||
case "application/protobuf":
|
||||
return TwirpContentType.Protobuf;
|
||||
case "application/json":
|
||||
return TwirpContentType.JSON;
|
||||
default:
|
||||
return TwirpContentType.Unknown;
|
||||
}
|
||||
}
|
||||
exports.getContentType = getContentType;
|
||||
/**
|
||||
* Validate a twirp request
|
||||
* @param ctx
|
||||
* @param request
|
||||
* @param pathPrefix
|
||||
*/
|
||||
function validateRequest(ctx, request, pathPrefix) {
|
||||
if (request.method !== "POST") {
|
||||
const msg = `unsupported method ${request.method} (only POST is allowed)`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
const path = parseTwirpPath(request.url || "");
|
||||
if (path.pkgService !==
|
||||
(ctx.packageName ? ctx.packageName + "." : "") + ctx.serviceName) {
|
||||
const msg = `no handler for path ${request.url}`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
if (path.prefix !== pathPrefix) {
|
||||
const msg = `invalid path prefix ${path.prefix}, expected ${pathPrefix}, on path ${request.url}`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
const mimeContentType = request.headers["content-type"] || "";
|
||||
if (ctx.contentType === TwirpContentType.Unknown) {
|
||||
const msg = `unexpected Content-Type: ${request.headers["content-type"]}`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
return Object.assign(Object.assign({}, path), { mimeContentType, contentType: ctx.contentType });
|
||||
}
|
||||
exports.validateRequest = validateRequest;
|
||||
/**
|
||||
* Get request data from the body
|
||||
* @param req
|
||||
*/
|
||||
function getRequestData(req) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reqWithRawBody = req;
|
||||
if (reqWithRawBody.rawBody instanceof Buffer) {
|
||||
resolve(reqWithRawBody.rawBody);
|
||||
return;
|
||||
}
|
||||
const chunks = [];
|
||||
req.on("data", (chunk) => chunks.push(chunk));
|
||||
req.on("end", () => __awaiter(this, void 0, void 0, function* () {
|
||||
const data = Buffer.concat(chunks);
|
||||
resolve(data);
|
||||
}));
|
||||
req.on("error", (err) => {
|
||||
if (req.aborted) {
|
||||
reject(new errors_1.TwirpError(errors_1.TwirpErrorCode.DeadlineExceeded, "failed to read request: deadline exceeded"));
|
||||
}
|
||||
else {
|
||||
reject(new errors_1.TwirpError(errors_1.TwirpErrorCode.Malformed, err.message).withCause(err));
|
||||
}
|
||||
});
|
||||
req.on("close", () => {
|
||||
reject(new errors_1.TwirpError(errors_1.TwirpErrorCode.Canceled, "failed to read request: context canceled"));
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.getRequestData = getRequestData;
|
||||
/**
|
||||
* Parses twirp url path
|
||||
* @param path
|
||||
*/
|
||||
function parseTwirpPath(path) {
|
||||
const parts = path.split("/");
|
||||
if (parts.length < 2) {
|
||||
return {
|
||||
pkgService: "",
|
||||
method: "",
|
||||
prefix: "",
|
||||
};
|
||||
}
|
||||
return {
|
||||
method: parts[parts.length - 1],
|
||||
pkgService: parts[parts.length - 2],
|
||||
prefix: parts.slice(0, parts.length - 2).join("/"),
|
||||
};
|
||||
}
|
||||
exports.parseTwirpPath = parseTwirpPath;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 1035:
|
||||
/***/ (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.writeError = exports.TwirpServer = void 0;
|
||||
const hooks_1 = __nccwpck_require__(3898);
|
||||
const request_1 = __nccwpck_require__(9647);
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
/**
|
||||
* Runtime server implementation of a TwirpServer
|
||||
*/
|
||||
class TwirpServer {
|
||||
constructor(options) {
|
||||
this.pathPrefix = "/twirp";
|
||||
this.hooks = [];
|
||||
this.interceptors = [];
|
||||
this.packageName = options.packageName;
|
||||
this.serviceName = options.serviceName;
|
||||
this.methodList = options.methodList;
|
||||
this.matchRoute = options.matchRoute;
|
||||
this.service = options.service;
|
||||
}
|
||||
/**
|
||||
* Returns the prefix for this server
|
||||
*/
|
||||
get prefix() {
|
||||
return this.pathPrefix;
|
||||
}
|
||||
/**
|
||||
* The http handler for twirp complaint endpoints
|
||||
* @param options
|
||||
*/
|
||||
httpHandler(options) {
|
||||
return (req, resp) => {
|
||||
// setup prefix
|
||||
if ((options === null || options === void 0 ? void 0 : options.prefix) !== undefined) {
|
||||
this.withPrefix(options.prefix);
|
||||
}
|
||||
return this._httpHandler(req, resp);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Adds interceptors or hooks to the request stack
|
||||
* @param middlewares
|
||||
*/
|
||||
use(...middlewares) {
|
||||
middlewares.forEach((middleware) => {
|
||||
if (hooks_1.isHook(middleware)) {
|
||||
this.hooks.push(middleware);
|
||||
return this;
|
||||
}
|
||||
this.interceptors.push(middleware);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Adds a prefix to the service url path
|
||||
* @param prefix
|
||||
*/
|
||||
withPrefix(prefix) {
|
||||
if (prefix === false) {
|
||||
this.pathPrefix = "";
|
||||
}
|
||||
else {
|
||||
this.pathPrefix = prefix;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Returns the regex matching path for this twirp server
|
||||
*/
|
||||
matchingPath() {
|
||||
const baseRegex = this.baseURI().replace(/\./g, "\\.");
|
||||
return new RegExp(`${baseRegex}\/(${this.methodList.join("|")})`);
|
||||
}
|
||||
/**
|
||||
* Returns the base URI for this twirp server
|
||||
*/
|
||||
baseURI() {
|
||||
return `${this.pathPrefix}/${this.packageName ? this.packageName + "." : ""}${this.serviceName}`;
|
||||
}
|
||||
/**
|
||||
* Create a twirp context
|
||||
* @param req
|
||||
* @param res
|
||||
* @private
|
||||
*/
|
||||
createContext(req, res) {
|
||||
return {
|
||||
packageName: this.packageName,
|
||||
serviceName: this.serviceName,
|
||||
methodName: "",
|
||||
contentType: request_1.getContentType(req.headers["content-type"]),
|
||||
req: req,
|
||||
res: res,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Twrip server http handler implementation
|
||||
* @param req
|
||||
* @param resp
|
||||
* @private
|
||||
*/
|
||||
_httpHandler(req, resp) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const ctx = this.createContext(req, resp);
|
||||
try {
|
||||
yield this.invokeHook("requestReceived", ctx);
|
||||
const { method, mimeContentType } = request_1.validateRequest(ctx, req, this.pathPrefix || "");
|
||||
const handler = this.matchRoute(method, {
|
||||
onMatch: (ctx) => {
|
||||
return this.invokeHook("requestRouted", ctx);
|
||||
},
|
||||
onNotFound: () => {
|
||||
const msg = `no handler for path ${req.url}`;
|
||||
throw new errors_1.BadRouteError(msg, req.method || "", req.url || "");
|
||||
},
|
||||
});
|
||||
const body = yield request_1.getRequestData(req);
|
||||
const response = yield handler(ctx, this.service, body, this.interceptors);
|
||||
yield Promise.all([
|
||||
this.invokeHook("responsePrepared", ctx),
|
||||
// keep backwards compatibility till next release
|
||||
this.invokeHook("requestPrepared", ctx),
|
||||
]);
|
||||
resp.statusCode = 200;
|
||||
resp.setHeader("Content-Type", mimeContentType);
|
||||
resp.end(response);
|
||||
}
|
||||
catch (e) {
|
||||
yield this.invokeHook("error", ctx, mustBeTwirpError(e));
|
||||
if (!resp.headersSent) {
|
||||
writeError(resp, e);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
yield Promise.all([
|
||||
this.invokeHook("responseSent", ctx),
|
||||
// keep backwards compatibility till next release
|
||||
this.invokeHook("requestSent", ctx),
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Invoke a hook
|
||||
* @param hookName
|
||||
* @param ctx
|
||||
* @param err
|
||||
* @protected
|
||||
*/
|
||||
invokeHook(hookName, ctx, err) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (this.hooks.length === 0) {
|
||||
return;
|
||||
}
|
||||
const chainedHooks = hooks_1.chainHooks(...this.hooks);
|
||||
const hook = chainedHooks === null || chainedHooks === void 0 ? void 0 : chainedHooks[hookName];
|
||||
if (hook) {
|
||||
yield hook(ctx, err || new errors_1.InternalServerError("internal server error"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.TwirpServer = TwirpServer;
|
||||
/**
|
||||
* Write http error response
|
||||
* @param res
|
||||
* @param error
|
||||
*/
|
||||
function writeError(res, error) {
|
||||
const twirpError = mustBeTwirpError(error);
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
res.statusCode = errors_1.httpStatusFromErrorCode(twirpError.code);
|
||||
res.end(twirpError.toJSON());
|
||||
}
|
||||
exports.writeError = writeError;
|
||||
/**
|
||||
* Make sure that the error passed is a TwirpError
|
||||
* otherwise it will wrap it into an InternalError
|
||||
* @param err
|
||||
*/
|
||||
function mustBeTwirpError(err) {
|
||||
if (err instanceof errors_1.TwirpError) {
|
||||
return err;
|
||||
}
|
||||
return new errors_1.InternalServerErrorWith(err);
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8736:
|
||||
@ -68120,14 +65257,6 @@ module.exports = require("punycode");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3480:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("querystring");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2203:
|
||||
/***/ ((module) => {
|
||||
|
||||
@ -68188,7 +65317,7 @@ module.exports = require("zlib");
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.0.0","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1","twirp-ts":"^2.5.0"},"devDependencies":{"@types/semver":"^6.0.0","typescript":"^5.2.2"}}');
|
||||
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.0.2","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1"},"devDependencies":{"@types/semver":"^6.0.0","typescript":"^5.2.2"}}');
|
||||
|
||||
/***/ }),
|
||||
|
||||
|
||||
2913
dist/save-only/index.js
vendored
2913
dist/save-only/index.js
vendored
@ -220,7 +220,7 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
||||
};
|
||||
const response = yield twirpClient.GetCacheEntryDownloadURL(request);
|
||||
if (!response.ok) {
|
||||
core.warning(`Cache not found for keys: ${keys.join(', ')}`);
|
||||
core.debug(`Cache not found for keys: ${keys.join(', ')}`);
|
||||
return undefined;
|
||||
}
|
||||
core.info(`Cache hit for: ${request.key}`);
|
||||
@ -412,12 +412,20 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
key,
|
||||
version
|
||||
};
|
||||
const response = yield twirpClient.CreateCacheEntry(request);
|
||||
if (!response.ok) {
|
||||
let signedUploadUrl;
|
||||
try {
|
||||
const response = yield twirpClient.CreateCacheEntry(request);
|
||||
if (!response.ok) {
|
||||
throw new Error('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, response.signedUploadUrl, options);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options);
|
||||
const finalizeRequest = {
|
||||
key,
|
||||
version,
|
||||
@ -458,156 +466,13 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8200:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Timestamp = void 0;
|
||||
const runtime_1 = __nccwpck_require__(8886);
|
||||
const runtime_2 = __nccwpck_require__(8886);
|
||||
const runtime_3 = __nccwpck_require__(8886);
|
||||
const runtime_4 = __nccwpck_require__(8886);
|
||||
const runtime_5 = __nccwpck_require__(8886);
|
||||
const runtime_6 = __nccwpck_require__(8886);
|
||||
const runtime_7 = __nccwpck_require__(8886);
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class Timestamp$Type extends runtime_7.MessageType {
|
||||
constructor() {
|
||||
super("google.protobuf.Timestamp", [
|
||||
{ no: 1, name: "seconds", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
|
||||
{ no: 2, name: "nanos", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* Creates a new `Timestamp` for the current time.
|
||||
*/
|
||||
now() {
|
||||
const msg = this.create();
|
||||
const ms = Date.now();
|
||||
msg.seconds = runtime_6.PbLong.from(Math.floor(ms / 1000)).toString();
|
||||
msg.nanos = (ms % 1000) * 1000000;
|
||||
return msg;
|
||||
}
|
||||
/**
|
||||
* Converts a `Timestamp` to a JavaScript Date.
|
||||
*/
|
||||
toDate(message) {
|
||||
return new Date(runtime_6.PbLong.from(message.seconds).toNumber() * 1000 + Math.ceil(message.nanos / 1000000));
|
||||
}
|
||||
/**
|
||||
* Converts a JavaScript Date to a `Timestamp`.
|
||||
*/
|
||||
fromDate(date) {
|
||||
const msg = this.create();
|
||||
const ms = date.getTime();
|
||||
msg.seconds = runtime_6.PbLong.from(Math.floor(ms / 1000)).toString();
|
||||
msg.nanos = (ms % 1000) * 1000000;
|
||||
return msg;
|
||||
}
|
||||
/**
|
||||
* In JSON format, the `Timestamp` type is encoded as a string
|
||||
* in the RFC 3339 format.
|
||||
*/
|
||||
internalJsonWrite(message, options) {
|
||||
let ms = runtime_6.PbLong.from(message.seconds).toNumber() * 1000;
|
||||
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z"))
|
||||
throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");
|
||||
if (message.nanos < 0)
|
||||
throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");
|
||||
let z = "Z";
|
||||
if (message.nanos > 0) {
|
||||
let nanosStr = (message.nanos + 1000000000).toString().substring(1);
|
||||
if (nanosStr.substring(3) === "000000")
|
||||
z = "." + nanosStr.substring(0, 3) + "Z";
|
||||
else if (nanosStr.substring(6) === "000")
|
||||
z = "." + nanosStr.substring(0, 6) + "Z";
|
||||
else
|
||||
z = "." + nanosStr + "Z";
|
||||
}
|
||||
return new Date(ms).toISOString().replace(".000Z", z);
|
||||
}
|
||||
/**
|
||||
* In JSON format, the `Timestamp` type is encoded as a string
|
||||
* in the RFC 3339 format.
|
||||
*/
|
||||
internalJsonRead(json, options, target) {
|
||||
if (typeof json !== "string")
|
||||
throw new Error("Unable to parse Timestamp from JSON " + (0, runtime_5.typeofJsonValue)(json) + ".");
|
||||
let matches = json.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);
|
||||
if (!matches)
|
||||
throw new Error("Unable to parse Timestamp from JSON. Invalid format.");
|
||||
let ms = Date.parse(matches[1] + "-" + matches[2] + "-" + matches[3] + "T" + matches[4] + ":" + matches[5] + ":" + matches[6] + (matches[8] ? matches[8] : "Z"));
|
||||
if (Number.isNaN(ms))
|
||||
throw new Error("Unable to parse Timestamp from JSON. Invalid value.");
|
||||
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z"))
|
||||
throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");
|
||||
if (!target)
|
||||
target = this.create();
|
||||
target.seconds = runtime_6.PbLong.from(ms / 1000).toString();
|
||||
target.nanos = 0;
|
||||
if (matches[7])
|
||||
target.nanos = (parseInt("1" + matches[7] + "0".repeat(9 - matches[7].length)) - 1000000000);
|
||||
return target;
|
||||
}
|
||||
create(value) {
|
||||
const message = { seconds: "0", nanos: 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 /* int64 seconds */ 1:
|
||||
message.seconds = reader.int64().toString();
|
||||
break;
|
||||
case /* int32 nanos */ 2:
|
||||
message.nanos = reader.int32();
|
||||
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 seconds = 1; */
|
||||
if (message.seconds !== "0")
|
||||
writer.tag(1, runtime_1.WireType.Varint).int64(message.seconds);
|
||||
/* int32 nanos = 2; */
|
||||
if (message.nanos !== 0)
|
||||
writer.tag(2, runtime_1.WireType.Varint).int32(message.nanos);
|
||||
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 google.protobuf.Timestamp
|
||||
*/
|
||||
exports.Timestamp = new Timestamp$Type();
|
||||
//# sourceMappingURL=timestamp.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3156:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.CacheService = exports.LookupCacheEntryResponse = exports.LookupCacheEntryRequest = exports.ListCacheEntriesResponse = exports.ListCacheEntriesRequest = exports.DeleteCacheEntryResponse = exports.DeleteCacheEntryRequest = exports.GetCacheEntryDownloadURLResponse = exports.GetCacheEntryDownloadURLRequest = exports.FinalizeCacheEntryUploadResponse = exports.FinalizeCacheEntryUploadRequest = exports.CreateCacheEntryResponse = exports.CreateCacheEntryRequest = void 0;
|
||||
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
|
||||
@ -617,7 +482,6 @@ const runtime_2 = __nccwpck_require__(8886);
|
||||
const runtime_3 = __nccwpck_require__(8886);
|
||||
const runtime_4 = __nccwpck_require__(8886);
|
||||
const runtime_5 = __nccwpck_require__(8886);
|
||||
const cacheentry_1 = __nccwpck_require__(5893);
|
||||
const cachemetadata_1 = __nccwpck_require__(9444);
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class CreateCacheEntryRequest$Type extends runtime_5.MessageType {
|
||||
@ -985,376 +849,25 @@ class GetCacheEntryDownloadURLResponse$Type extends runtime_5.MessageType {
|
||||
* @generated MessageType for protobuf message github.actions.results.api.v1.GetCacheEntryDownloadURLResponse
|
||||
*/
|
||||
exports.GetCacheEntryDownloadURLResponse = new GetCacheEntryDownloadURLResponse$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class DeleteCacheEntryRequest$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.DeleteCacheEntryRequest", [
|
||||
{ no: 1, name: "metadata", kind: "message", T: () => cachemetadata_1.CacheMetadata },
|
||||
{ no: 2, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { key: "" };
|
||||
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;
|
||||
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);
|
||||
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.DeleteCacheEntryRequest
|
||||
*/
|
||||
exports.DeleteCacheEntryRequest = new DeleteCacheEntryRequest$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class DeleteCacheEntryResponse$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.DeleteCacheEntryResponse", [
|
||||
{ no: 1, name: "ok", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
|
||||
{ no: 2, name: "entry_id", kind: "scalar", T: 3 /*ScalarType.INT64*/ }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { ok: false, entryId: "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 /* bool ok */ 1:
|
||||
message.ok = reader.bool();
|
||||
break;
|
||||
case /* int64 entry_id */ 2:
|
||||
message.entryId = 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) {
|
||||
/* 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);
|
||||
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.DeleteCacheEntryResponse
|
||||
*/
|
||||
exports.DeleteCacheEntryResponse = new DeleteCacheEntryResponse$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class ListCacheEntriesRequest$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.ListCacheEntriesRequest", [
|
||||
{ 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*/ }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { key: "", restoreKeys: [] };
|
||||
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;
|
||||
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]);
|
||||
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.ListCacheEntriesRequest
|
||||
*/
|
||||
exports.ListCacheEntriesRequest = new ListCacheEntriesRequest$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class ListCacheEntriesResponse$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.ListCacheEntriesResponse", [
|
||||
{ no: 1, name: "entries", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => cacheentry_1.CacheEntry }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { entries: [] };
|
||||
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 /* repeated github.actions.results.entities.v1.CacheEntry entries */ 1:
|
||||
message.entries.push(cacheentry_1.CacheEntry.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) {
|
||||
/* repeated github.actions.results.entities.v1.CacheEntry entries = 1; */
|
||||
for (let i = 0; i < message.entries.length; i++)
|
||||
cacheentry_1.CacheEntry.internalBinaryWrite(message.entries[i], writer.tag(1, 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.api.v1.ListCacheEntriesResponse
|
||||
*/
|
||||
exports.ListCacheEntriesResponse = new ListCacheEntriesResponse$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class LookupCacheEntryRequest$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.LookupCacheEntryRequest", [
|
||||
{ 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.LookupCacheEntryRequest
|
||||
*/
|
||||
exports.LookupCacheEntryRequest = new LookupCacheEntryRequest$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class LookupCacheEntryResponse$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.LookupCacheEntryResponse", [
|
||||
{ no: 1, name: "exists", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
|
||||
{ no: 2, name: "entry", kind: "message", T: () => cacheentry_1.CacheEntry }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { exists: false };
|
||||
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 exists */ 1:
|
||||
message.exists = reader.bool();
|
||||
break;
|
||||
case /* github.actions.results.entities.v1.CacheEntry entry */ 2:
|
||||
message.entry = cacheentry_1.CacheEntry.internalBinaryRead(reader, reader.uint32(), options, message.entry);
|
||||
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 exists = 1; */
|
||||
if (message.exists !== false)
|
||||
writer.tag(1, runtime_1.WireType.Varint).bool(message.exists);
|
||||
/* github.actions.results.entities.v1.CacheEntry entry = 2; */
|
||||
if (message.entry)
|
||||
cacheentry_1.CacheEntry.internalBinaryWrite(message.entry, 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.api.v1.LookupCacheEntryResponse
|
||||
*/
|
||||
exports.LookupCacheEntryResponse = new LookupCacheEntryResponse$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 },
|
||||
{ name: "DeleteCacheEntry", options: {}, I: exports.DeleteCacheEntryRequest, O: exports.DeleteCacheEntryResponse },
|
||||
{ name: "ListCacheEntries", options: {}, I: exports.ListCacheEntriesRequest, O: exports.ListCacheEntriesResponse },
|
||||
{ name: "LookupCacheEntry", options: {}, I: exports.LookupCacheEntryRequest, O: exports.LookupCacheEntryResponse }
|
||||
{ name: "GetCacheEntryDownloadURL", options: {}, I: exports.GetCacheEntryDownloadURLRequest, O: exports.GetCacheEntryDownloadURLResponse }
|
||||
]);
|
||||
//# sourceMappingURL=cache.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 564:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
/***/ 1486:
|
||||
/***/ ((__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.createCacheServiceServer = exports.CacheServiceMethodList = exports.CacheServiceMethod = exports.CacheServiceClientProtobuf = exports.CacheServiceClientJSON = void 0;
|
||||
const twirp_ts_1 = __nccwpck_require__(430);
|
||||
exports.CacheServiceClientProtobuf = exports.CacheServiceClientJSON = void 0;
|
||||
const cache_1 = __nccwpck_require__(3156);
|
||||
class CacheServiceClientJSON {
|
||||
constructor(rpc) {
|
||||
@ -1362,9 +875,6 @@ class CacheServiceClientJSON {
|
||||
this.CreateCacheEntry.bind(this);
|
||||
this.FinalizeCacheEntryUpload.bind(this);
|
||||
this.GetCacheEntryDownloadURL.bind(this);
|
||||
this.DeleteCacheEntry.bind(this);
|
||||
this.ListCacheEntries.bind(this);
|
||||
this.LookupCacheEntry.bind(this);
|
||||
}
|
||||
CreateCacheEntry(request) {
|
||||
const data = cache_1.CreateCacheEntryRequest.toJson(request, {
|
||||
@ -1396,36 +906,6 @@ class CacheServiceClientJSON {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
DeleteCacheEntry(request) {
|
||||
const data = cache_1.DeleteCacheEntryRequest.toJson(request, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
});
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "DeleteCacheEntry", "application/json", data);
|
||||
return promise.then((data) => cache_1.DeleteCacheEntryResponse.fromJson(data, {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
ListCacheEntries(request) {
|
||||
const data = cache_1.ListCacheEntriesRequest.toJson(request, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
});
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "ListCacheEntries", "application/json", data);
|
||||
return promise.then((data) => cache_1.ListCacheEntriesResponse.fromJson(data, {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
LookupCacheEntry(request) {
|
||||
const data = cache_1.LookupCacheEntryRequest.toJson(request, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
});
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "LookupCacheEntry", "application/json", data);
|
||||
return promise.then((data) => cache_1.LookupCacheEntryResponse.fromJson(data, {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
}
|
||||
exports.CacheServiceClientJSON = CacheServiceClientJSON;
|
||||
class CacheServiceClientProtobuf {
|
||||
@ -1434,9 +914,6 @@ class CacheServiceClientProtobuf {
|
||||
this.CreateCacheEntry.bind(this);
|
||||
this.FinalizeCacheEntryUpload.bind(this);
|
||||
this.GetCacheEntryDownloadURL.bind(this);
|
||||
this.DeleteCacheEntry.bind(this);
|
||||
this.ListCacheEntries.bind(this);
|
||||
this.LookupCacheEntry.bind(this);
|
||||
}
|
||||
CreateCacheEntry(request) {
|
||||
const data = cache_1.CreateCacheEntryRequest.toBinary(request);
|
||||
@ -1453,610 +930,9 @@ class CacheServiceClientProtobuf {
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "GetCacheEntryDownloadURL", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.GetCacheEntryDownloadURLResponse.fromBinary(data));
|
||||
}
|
||||
DeleteCacheEntry(request) {
|
||||
const data = cache_1.DeleteCacheEntryRequest.toBinary(request);
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "DeleteCacheEntry", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.DeleteCacheEntryResponse.fromBinary(data));
|
||||
}
|
||||
ListCacheEntries(request) {
|
||||
const data = cache_1.ListCacheEntriesRequest.toBinary(request);
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "ListCacheEntries", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.ListCacheEntriesResponse.fromBinary(data));
|
||||
}
|
||||
LookupCacheEntry(request) {
|
||||
const data = cache_1.LookupCacheEntryRequest.toBinary(request);
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "LookupCacheEntry", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.LookupCacheEntryResponse.fromBinary(data));
|
||||
}
|
||||
}
|
||||
exports.CacheServiceClientProtobuf = CacheServiceClientProtobuf;
|
||||
var CacheServiceMethod;
|
||||
(function (CacheServiceMethod) {
|
||||
CacheServiceMethod["CreateCacheEntry"] = "CreateCacheEntry";
|
||||
CacheServiceMethod["FinalizeCacheEntryUpload"] = "FinalizeCacheEntryUpload";
|
||||
CacheServiceMethod["GetCacheEntryDownloadURL"] = "GetCacheEntryDownloadURL";
|
||||
CacheServiceMethod["DeleteCacheEntry"] = "DeleteCacheEntry";
|
||||
CacheServiceMethod["ListCacheEntries"] = "ListCacheEntries";
|
||||
CacheServiceMethod["LookupCacheEntry"] = "LookupCacheEntry";
|
||||
})(CacheServiceMethod || (exports.CacheServiceMethod = CacheServiceMethod = {}));
|
||||
exports.CacheServiceMethodList = [
|
||||
CacheServiceMethod.CreateCacheEntry,
|
||||
CacheServiceMethod.FinalizeCacheEntryUpload,
|
||||
CacheServiceMethod.GetCacheEntryDownloadURL,
|
||||
CacheServiceMethod.DeleteCacheEntry,
|
||||
CacheServiceMethod.ListCacheEntries,
|
||||
CacheServiceMethod.LookupCacheEntry,
|
||||
];
|
||||
function createCacheServiceServer(service) {
|
||||
return new twirp_ts_1.TwirpServer({
|
||||
service,
|
||||
packageName: "github.actions.results.api.v1",
|
||||
serviceName: "CacheService",
|
||||
methodList: exports.CacheServiceMethodList,
|
||||
matchRoute: matchCacheServiceRoute,
|
||||
});
|
||||
}
|
||||
exports.createCacheServiceServer = createCacheServiceServer;
|
||||
function matchCacheServiceRoute(method, events) {
|
||||
switch (method) {
|
||||
case "CreateCacheEntry":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "CreateCacheEntry" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceCreateCacheEntryRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "FinalizeCacheEntryUpload":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "FinalizeCacheEntryUpload" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceFinalizeCacheEntryUploadRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "GetCacheEntryDownloadURL":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "GetCacheEntryDownloadURL" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceGetCacheEntryDownloadURLRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "DeleteCacheEntry":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "DeleteCacheEntry" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceDeleteCacheEntryRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "ListCacheEntries":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "ListCacheEntries" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceListCacheEntriesRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "LookupCacheEntry":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "LookupCacheEntry" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceLookupCacheEntryRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
default:
|
||||
events.onNotFound();
|
||||
const msg = `no handler found`;
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceCreateCacheEntryRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceCreateCacheEntryJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceCreateCacheEntryProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceFinalizeCacheEntryUploadRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceFinalizeCacheEntryUploadJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceFinalizeCacheEntryUploadProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceGetCacheEntryDownloadURLRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceGetCacheEntryDownloadURLJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceGetCacheEntryDownloadURLProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceDeleteCacheEntryRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceDeleteCacheEntryJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceDeleteCacheEntryProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceListCacheEntriesRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceListCacheEntriesJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceListCacheEntriesProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceLookupCacheEntryRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceLookupCacheEntryJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceLookupCacheEntryProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceCreateCacheEntryJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.CreateCacheEntryRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.CreateCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.CreateCacheEntry(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.CreateCacheEntryResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceFinalizeCacheEntryUploadJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.FinalizeCacheEntryUploadRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.FinalizeCacheEntryUpload(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.FinalizeCacheEntryUpload(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.FinalizeCacheEntryUploadResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceGetCacheEntryDownloadURLJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.GetCacheEntryDownloadURLRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.GetCacheEntryDownloadURL(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.GetCacheEntryDownloadURL(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.GetCacheEntryDownloadURLResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceDeleteCacheEntryJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.DeleteCacheEntryRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.DeleteCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.DeleteCacheEntry(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.DeleteCacheEntryResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceListCacheEntriesJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.ListCacheEntriesRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.ListCacheEntries(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.ListCacheEntries(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.ListCacheEntriesResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceLookupCacheEntryJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.LookupCacheEntryRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.LookupCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.LookupCacheEntry(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.LookupCacheEntryResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceCreateCacheEntryProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.CreateCacheEntryRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.CreateCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.CreateCacheEntry(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.CreateCacheEntryResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceFinalizeCacheEntryUploadProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.FinalizeCacheEntryUploadRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.FinalizeCacheEntryUpload(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.FinalizeCacheEntryUpload(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.FinalizeCacheEntryUploadResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceGetCacheEntryDownloadURLProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.GetCacheEntryDownloadURLRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.GetCacheEntryDownloadURL(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.GetCacheEntryDownloadURL(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.GetCacheEntryDownloadURLResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceDeleteCacheEntryProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.DeleteCacheEntryRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.DeleteCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.DeleteCacheEntry(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.DeleteCacheEntryResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceListCacheEntriesProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.ListCacheEntriesRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.ListCacheEntries(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.ListCacheEntries(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.ListCacheEntriesResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceLookupCacheEntryProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.LookupCacheEntryRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.LookupCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.LookupCacheEntry(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.LookupCacheEntryResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=cache.twirp.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5893:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.CacheEntry = void 0;
|
||||
const runtime_1 = __nccwpck_require__(8886);
|
||||
const runtime_2 = __nccwpck_require__(8886);
|
||||
const runtime_3 = __nccwpck_require__(8886);
|
||||
const runtime_4 = __nccwpck_require__(8886);
|
||||
const runtime_5 = __nccwpck_require__(8886);
|
||||
const timestamp_1 = __nccwpck_require__(8200);
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class CacheEntry$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.entities.v1.CacheEntry", [
|
||||
{ no: 1, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 2, name: "hash", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 3, name: "size_bytes", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
|
||||
{ no: 4, name: "scope", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 5, name: "version", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 6, name: "created_at", kind: "message", T: () => timestamp_1.Timestamp },
|
||||
{ no: 7, name: "last_accessed_at", kind: "message", T: () => timestamp_1.Timestamp },
|
||||
{ no: 8, name: "expires_at", kind: "message", T: () => timestamp_1.Timestamp }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { key: "", hash: "", sizeBytes: "0", scope: "", 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 /* string key */ 1:
|
||||
message.key = reader.string();
|
||||
break;
|
||||
case /* string hash */ 2:
|
||||
message.hash = reader.string();
|
||||
break;
|
||||
case /* int64 size_bytes */ 3:
|
||||
message.sizeBytes = reader.int64().toString();
|
||||
break;
|
||||
case /* string scope */ 4:
|
||||
message.scope = reader.string();
|
||||
break;
|
||||
case /* string version */ 5:
|
||||
message.version = reader.string();
|
||||
break;
|
||||
case /* google.protobuf.Timestamp created_at */ 6:
|
||||
message.createdAt = timestamp_1.Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.createdAt);
|
||||
break;
|
||||
case /* google.protobuf.Timestamp last_accessed_at */ 7:
|
||||
message.lastAccessedAt = timestamp_1.Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.lastAccessedAt);
|
||||
break;
|
||||
case /* google.protobuf.Timestamp expires_at */ 8:
|
||||
message.expiresAt = timestamp_1.Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.expiresAt);
|
||||
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 key = 1; */
|
||||
if (message.key !== "")
|
||||
writer.tag(1, runtime_1.WireType.LengthDelimited).string(message.key);
|
||||
/* string hash = 2; */
|
||||
if (message.hash !== "")
|
||||
writer.tag(2, runtime_1.WireType.LengthDelimited).string(message.hash);
|
||||
/* int64 size_bytes = 3; */
|
||||
if (message.sizeBytes !== "0")
|
||||
writer.tag(3, runtime_1.WireType.Varint).int64(message.sizeBytes);
|
||||
/* string scope = 4; */
|
||||
if (message.scope !== "")
|
||||
writer.tag(4, runtime_1.WireType.LengthDelimited).string(message.scope);
|
||||
/* string version = 5; */
|
||||
if (message.version !== "")
|
||||
writer.tag(5, runtime_1.WireType.LengthDelimited).string(message.version);
|
||||
/* google.protobuf.Timestamp created_at = 6; */
|
||||
if (message.createdAt)
|
||||
timestamp_1.Timestamp.internalBinaryWrite(message.createdAt, writer.tag(6, runtime_1.WireType.LengthDelimited).fork(), options).join();
|
||||
/* google.protobuf.Timestamp last_accessed_at = 7; */
|
||||
if (message.lastAccessedAt)
|
||||
timestamp_1.Timestamp.internalBinaryWrite(message.lastAccessedAt, writer.tag(7, runtime_1.WireType.LengthDelimited).fork(), options).join();
|
||||
/* google.protobuf.Timestamp expires_at = 8; */
|
||||
if (message.expiresAt)
|
||||
timestamp_1.Timestamp.internalBinaryWrite(message.expiresAt, writer.tag(8, 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.CacheEntry
|
||||
*/
|
||||
exports.CacheEntry = new CacheEntry$Type();
|
||||
//# sourceMappingURL=cacheentry.js.map
|
||||
//# sourceMappingURL=cache.twirp-client.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
@ -3327,7 +2203,7 @@ const config_1 = __nccwpck_require__(7606);
|
||||
const cacheUtils_1 = __nccwpck_require__(8299);
|
||||
const auth_1 = __nccwpck_require__(4552);
|
||||
const http_client_1 = __nccwpck_require__(4844);
|
||||
const cache_twirp_1 = __nccwpck_require__(564);
|
||||
const cache_twirp_client_1 = __nccwpck_require__(1486);
|
||||
/**
|
||||
* This class is a wrapper around the CacheServiceClientJSON class generated by Twirp.
|
||||
*
|
||||
@ -3464,7 +2340,7 @@ class CacheServiceClient {
|
||||
}
|
||||
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_1.CacheServiceClientJSON(client);
|
||||
return new cache_twirp_client_1.CacheServiceClientJSON(client);
|
||||
}
|
||||
exports.internalCacheTwirpClient = internalCacheTwirpClient;
|
||||
//# sourceMappingURL=cacheTwirpClient.js.map
|
||||
@ -52391,599 +51267,6 @@ DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
|
||||
};
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5129:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
function _process (v, mod) {
|
||||
var i
|
||||
var r
|
||||
|
||||
if (typeof mod === 'function') {
|
||||
r = mod(v)
|
||||
if (r !== undefined) {
|
||||
v = r
|
||||
}
|
||||
} else if (Array.isArray(mod)) {
|
||||
for (i = 0; i < mod.length; i++) {
|
||||
r = mod[i](v)
|
||||
if (r !== undefined) {
|
||||
v = r
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
function parseKey (key, val) {
|
||||
// detect negative index notation
|
||||
if (key[0] === '-' && Array.isArray(val) && /^-\d+$/.test(key)) {
|
||||
return val.length + parseInt(key, 10)
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
function isIndex (k) {
|
||||
return /^\d+$/.test(k)
|
||||
}
|
||||
|
||||
function isObject (val) {
|
||||
return Object.prototype.toString.call(val) === '[object Object]'
|
||||
}
|
||||
|
||||
function isArrayOrObject (val) {
|
||||
return Object(val) === val
|
||||
}
|
||||
|
||||
function isEmptyObject (val) {
|
||||
return Object.keys(val).length === 0
|
||||
}
|
||||
|
||||
var blacklist = ['__proto__', 'prototype', 'constructor']
|
||||
var blacklistFilter = function (part) { return blacklist.indexOf(part) === -1 }
|
||||
|
||||
function parsePath (path, sep) {
|
||||
if (path.indexOf('[') >= 0) {
|
||||
path = path.replace(/\[/g, sep).replace(/]/g, '')
|
||||
}
|
||||
|
||||
var parts = path.split(sep)
|
||||
|
||||
var check = parts.filter(blacklistFilter)
|
||||
|
||||
if (check.length !== parts.length) {
|
||||
throw Error('Refusing to update blacklisted property ' + path)
|
||||
}
|
||||
|
||||
return parts
|
||||
}
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
|
||||
function DotObject (separator, override, useArray, useBrackets) {
|
||||
if (!(this instanceof DotObject)) {
|
||||
return new DotObject(separator, override, useArray, useBrackets)
|
||||
}
|
||||
|
||||
if (typeof override === 'undefined') override = false
|
||||
if (typeof useArray === 'undefined') useArray = true
|
||||
if (typeof useBrackets === 'undefined') useBrackets = true
|
||||
this.separator = separator || '.'
|
||||
this.override = override
|
||||
this.useArray = useArray
|
||||
this.useBrackets = useBrackets
|
||||
this.keepArray = false
|
||||
|
||||
// contains touched arrays
|
||||
this.cleanup = []
|
||||
}
|
||||
|
||||
var dotDefault = new DotObject('.', false, true, true)
|
||||
function wrap (method) {
|
||||
return function () {
|
||||
return dotDefault[method].apply(dotDefault, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
DotObject.prototype._fill = function (a, obj, v, mod) {
|
||||
var k = a.shift()
|
||||
|
||||
if (a.length > 0) {
|
||||
obj[k] = obj[k] || (this.useArray && isIndex(a[0]) ? [] : {})
|
||||
|
||||
if (!isArrayOrObject(obj[k])) {
|
||||
if (this.override) {
|
||||
obj[k] = {}
|
||||
} else {
|
||||
if (!(isArrayOrObject(v) && isEmptyObject(v))) {
|
||||
throw new Error(
|
||||
'Trying to redefine `' + k + '` which is a ' + typeof obj[k]
|
||||
)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this._fill(a, obj[k], v, mod)
|
||||
} else {
|
||||
if (!this.override && isArrayOrObject(obj[k]) && !isEmptyObject(obj[k])) {
|
||||
if (!(isArrayOrObject(v) && isEmptyObject(v))) {
|
||||
throw new Error("Trying to redefine non-empty obj['" + k + "']")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
obj[k] = _process(v, mod)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts an object with dotted-key/value pairs to it's expanded version
|
||||
*
|
||||
* Optionally transformed by a set of modifiers.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* var row = {
|
||||
* 'nr': 200,
|
||||
* 'doc.name': ' My Document '
|
||||
* }
|
||||
*
|
||||
* var mods = {
|
||||
* 'doc.name': [_s.trim, _s.underscored]
|
||||
* }
|
||||
*
|
||||
* dot.object(row, mods)
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {Object} mods
|
||||
*/
|
||||
DotObject.prototype.object = function (obj, mods) {
|
||||
var self = this
|
||||
|
||||
Object.keys(obj).forEach(function (k) {
|
||||
var mod = mods === undefined ? null : mods[k]
|
||||
// normalize array notation.
|
||||
var ok = parsePath(k, self.separator).join(self.separator)
|
||||
|
||||
if (ok.indexOf(self.separator) !== -1) {
|
||||
self._fill(ok.split(self.separator), obj, obj[k], mod)
|
||||
delete obj[k]
|
||||
} else {
|
||||
obj[k] = _process(obj[k], mod)
|
||||
}
|
||||
})
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} path dotted path
|
||||
* @param {String} v value to be set
|
||||
* @param {Object} obj object to be modified
|
||||
* @param {Function|Array} mod optional modifier
|
||||
*/
|
||||
DotObject.prototype.str = function (path, v, obj, mod) {
|
||||
var ok = parsePath(path, this.separator).join(this.separator)
|
||||
|
||||
if (path.indexOf(this.separator) !== -1) {
|
||||
this._fill(ok.split(this.separator), obj, v, mod)
|
||||
} else {
|
||||
obj[path] = _process(v, mod)
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Pick a value from an object using dot notation.
|
||||
*
|
||||
* Optionally remove the value
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} remove
|
||||
*/
|
||||
DotObject.prototype.pick = function (path, obj, remove, reindexArray) {
|
||||
var i
|
||||
var keys
|
||||
var val
|
||||
var key
|
||||
var cp
|
||||
|
||||
keys = parsePath(path, this.separator)
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
key = parseKey(keys[i], obj)
|
||||
if (obj && typeof obj === 'object' && key in obj) {
|
||||
if (i === keys.length - 1) {
|
||||
if (remove) {
|
||||
val = obj[key]
|
||||
if (reindexArray && Array.isArray(obj)) {
|
||||
obj.splice(key, 1)
|
||||
} else {
|
||||
delete obj[key]
|
||||
}
|
||||
if (Array.isArray(obj)) {
|
||||
cp = keys.slice(0, -1).join('.')
|
||||
if (this.cleanup.indexOf(cp) === -1) {
|
||||
this.cleanup.push(cp)
|
||||
}
|
||||
}
|
||||
return val
|
||||
} else {
|
||||
return obj[key]
|
||||
}
|
||||
} else {
|
||||
obj = obj[key]
|
||||
}
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
if (remove && Array.isArray(obj)) {
|
||||
obj = obj.filter(function (n) {
|
||||
return n !== undefined
|
||||
})
|
||||
}
|
||||
return obj
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Delete value from an object using dot notation.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Object} obj
|
||||
* @return {any} The removed value
|
||||
*/
|
||||
DotObject.prototype.delete = function (path, obj) {
|
||||
return this.remove(path, obj, true)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Remove value from an object using dot notation.
|
||||
*
|
||||
* Will remove multiple items if path is an array.
|
||||
* In this case array indexes will be retained until all
|
||||
* removals have been processed.
|
||||
*
|
||||
* Use dot.delete() to automatically re-index arrays.
|
||||
*
|
||||
* @param {String|Array<String>} path
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} reindexArray
|
||||
* @return {any} The removed value
|
||||
*/
|
||||
DotObject.prototype.remove = function (path, obj, reindexArray) {
|
||||
var i
|
||||
|
||||
this.cleanup = []
|
||||
if (Array.isArray(path)) {
|
||||
for (i = 0; i < path.length; i++) {
|
||||
this.pick(path[i], obj, true, reindexArray)
|
||||
}
|
||||
if (!reindexArray) {
|
||||
this._cleanup(obj)
|
||||
}
|
||||
return obj
|
||||
} else {
|
||||
return this.pick(path, obj, true, reindexArray)
|
||||
}
|
||||
}
|
||||
|
||||
DotObject.prototype._cleanup = function (obj) {
|
||||
var ret
|
||||
var i
|
||||
var keys
|
||||
var root
|
||||
if (this.cleanup.length) {
|
||||
for (i = 0; i < this.cleanup.length; i++) {
|
||||
keys = this.cleanup[i].split('.')
|
||||
root = keys.splice(0, -1).join('.')
|
||||
ret = root ? this.pick(root, obj) : obj
|
||||
ret = ret[keys[0]].filter(function (v) {
|
||||
return v !== undefined
|
||||
})
|
||||
this.set(this.cleanup[i], ret, obj)
|
||||
}
|
||||
this.cleanup = []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias method for `dot.remove`
|
||||
*
|
||||
* Note: this is not an alias for dot.delete()
|
||||
*
|
||||
* @param {String|Array<String>} path
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} reindexArray
|
||||
* @return {any} The removed value
|
||||
*/
|
||||
DotObject.prototype.del = DotObject.prototype.remove
|
||||
|
||||
/**
|
||||
*
|
||||
* Move a property from one place to the other.
|
||||
*
|
||||
* If the source path does not exist (undefined)
|
||||
* the target property will not be set.
|
||||
*
|
||||
* @param {String} source
|
||||
* @param {String} target
|
||||
* @param {Object} obj
|
||||
* @param {Function|Array} mods
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.move = function (source, target, obj, mods, merge) {
|
||||
if (typeof mods === 'function' || Array.isArray(mods)) {
|
||||
this.set(target, _process(this.pick(source, obj, true), mods), obj, merge)
|
||||
} else {
|
||||
merge = mods
|
||||
this.set(target, this.pick(source, obj, true), obj, merge)
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Transfer a property from one object to another object.
|
||||
*
|
||||
* If the source path does not exist (undefined)
|
||||
* the property on the other object will not be set.
|
||||
*
|
||||
* @param {String} source
|
||||
* @param {String} target
|
||||
* @param {Object} obj1
|
||||
* @param {Object} obj2
|
||||
* @param {Function|Array} mods
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.transfer = function (
|
||||
source,
|
||||
target,
|
||||
obj1,
|
||||
obj2,
|
||||
mods,
|
||||
merge
|
||||
) {
|
||||
if (typeof mods === 'function' || Array.isArray(mods)) {
|
||||
this.set(
|
||||
target,
|
||||
_process(this.pick(source, obj1, true), mods),
|
||||
obj2,
|
||||
merge
|
||||
)
|
||||
} else {
|
||||
merge = mods
|
||||
this.set(target, this.pick(source, obj1, true), obj2, merge)
|
||||
}
|
||||
|
||||
return obj2
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Copy a property from one object to another object.
|
||||
*
|
||||
* If the source path does not exist (undefined)
|
||||
* the property on the other object will not be set.
|
||||
*
|
||||
* @param {String} source
|
||||
* @param {String} target
|
||||
* @param {Object} obj1
|
||||
* @param {Object} obj2
|
||||
* @param {Function|Array} mods
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.copy = function (source, target, obj1, obj2, mods, merge) {
|
||||
if (typeof mods === 'function' || Array.isArray(mods)) {
|
||||
this.set(
|
||||
target,
|
||||
_process(
|
||||
// clone what is picked
|
||||
JSON.parse(JSON.stringify(this.pick(source, obj1, false))),
|
||||
mods
|
||||
),
|
||||
obj2,
|
||||
merge
|
||||
)
|
||||
} else {
|
||||
merge = mods
|
||||
this.set(target, this.pick(source, obj1, false), obj2, merge)
|
||||
}
|
||||
|
||||
return obj2
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Set a property on an object using dot notation.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {any} val
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.set = function (path, val, obj, merge) {
|
||||
var i
|
||||
var k
|
||||
var keys
|
||||
var key
|
||||
|
||||
// Do not operate if the value is undefined.
|
||||
if (typeof val === 'undefined') {
|
||||
return obj
|
||||
}
|
||||
keys = parsePath(path, this.separator)
|
||||
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
key = keys[i]
|
||||
if (i === keys.length - 1) {
|
||||
if (merge && isObject(val) && isObject(obj[key])) {
|
||||
for (k in val) {
|
||||
if (hasOwnProperty.call(val, k)) {
|
||||
obj[key][k] = val[k]
|
||||
}
|
||||
}
|
||||
} else if (merge && Array.isArray(obj[key]) && Array.isArray(val)) {
|
||||
for (var j = 0; j < val.length; j++) {
|
||||
obj[keys[i]].push(val[j])
|
||||
}
|
||||
} else {
|
||||
obj[key] = val
|
||||
}
|
||||
} else if (
|
||||
// force the value to be an object
|
||||
!hasOwnProperty.call(obj, key) ||
|
||||
(!isObject(obj[key]) && !Array.isArray(obj[key]))
|
||||
) {
|
||||
// initialize as array if next key is numeric
|
||||
if (/^\d+$/.test(keys[i + 1])) {
|
||||
obj[key] = []
|
||||
} else {
|
||||
obj[key] = {}
|
||||
}
|
||||
}
|
||||
obj = obj[key]
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Transform an object
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* var obj = {
|
||||
* "id": 1,
|
||||
* "some": {
|
||||
* "thing": "else"
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* var transform = {
|
||||
* "id": "nr",
|
||||
* "some.thing": "name"
|
||||
* }
|
||||
*
|
||||
* var tgt = dot.transform(transform, obj)
|
||||
*
|
||||
* @param {Object} recipe Transform recipe
|
||||
* @param {Object} obj Object to be transformed
|
||||
* @param {Array} mods modifiers for the target
|
||||
*/
|
||||
DotObject.prototype.transform = function (recipe, obj, tgt) {
|
||||
obj = obj || {}
|
||||
tgt = tgt || {}
|
||||
Object.keys(recipe).forEach(
|
||||
function (key) {
|
||||
this.set(recipe[key], this.pick(key, obj), tgt)
|
||||
}.bind(this)
|
||||
)
|
||||
return tgt
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convert object to dotted-key/value pair
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* var tgt = dot.dot(obj)
|
||||
*
|
||||
* or
|
||||
*
|
||||
* var tgt = {}
|
||||
* dot.dot(obj, tgt)
|
||||
*
|
||||
* @param {Object} obj source object
|
||||
* @param {Object} tgt target object
|
||||
* @param {Array} path path array (internal)
|
||||
*/
|
||||
DotObject.prototype.dot = function (obj, tgt, path) {
|
||||
tgt = tgt || {}
|
||||
path = path || []
|
||||
var isArray = Array.isArray(obj)
|
||||
|
||||
Object.keys(obj).forEach(
|
||||
function (key) {
|
||||
var index = isArray && this.useBrackets ? '[' + key + ']' : key
|
||||
if (
|
||||
isArrayOrObject(obj[key]) &&
|
||||
((isObject(obj[key]) && !isEmptyObject(obj[key])) ||
|
||||
(Array.isArray(obj[key]) && !this.keepArray && obj[key].length !== 0))
|
||||
) {
|
||||
if (isArray && this.useBrackets) {
|
||||
var previousKey = path[path.length - 1] || ''
|
||||
return this.dot(
|
||||
obj[key],
|
||||
tgt,
|
||||
path.slice(0, -1).concat(previousKey + index)
|
||||
)
|
||||
} else {
|
||||
return this.dot(obj[key], tgt, path.concat(index))
|
||||
}
|
||||
} else {
|
||||
if (isArray && this.useBrackets) {
|
||||
tgt[path.join(this.separator).concat('[' + key + ']')] = obj[key]
|
||||
} else {
|
||||
tgt[path.concat(index).join(this.separator)] = obj[key]
|
||||
}
|
||||
}
|
||||
}.bind(this)
|
||||
)
|
||||
return tgt
|
||||
}
|
||||
|
||||
DotObject.pick = wrap('pick')
|
||||
DotObject.move = wrap('move')
|
||||
DotObject.transfer = wrap('transfer')
|
||||
DotObject.transform = wrap('transform')
|
||||
DotObject.copy = wrap('copy')
|
||||
DotObject.object = wrap('object')
|
||||
DotObject.str = wrap('str')
|
||||
DotObject.set = wrap('set')
|
||||
DotObject.delete = wrap('delete')
|
||||
DotObject.del = DotObject.remove = wrap('remove')
|
||||
DotObject.dot = wrap('dot');
|
||||
['override', 'overwrite'].forEach(function (prop) {
|
||||
Object.defineProperty(DotObject, prop, {
|
||||
get: function () {
|
||||
return dotDefault.override
|
||||
},
|
||||
set: function (val) {
|
||||
dotDefault.override = !!val
|
||||
}
|
||||
})
|
||||
});
|
||||
['useArray', 'keepArray', 'useBrackets'].forEach(function (prop) {
|
||||
Object.defineProperty(DotObject, prop, {
|
||||
get: function () {
|
||||
return dotDefault[prop]
|
||||
},
|
||||
set: function (val) {
|
||||
dotDefault[prop] = val
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
DotObject._process = _process
|
||||
|
||||
module.exports = DotObject
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9829:
|
||||
@ -61521,1152 +59804,6 @@ if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) {
|
||||
exports.debug = debug; // for test
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5497:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3315:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.isValidErrorCode = exports.httpStatusFromErrorCode = exports.TwirpErrorCode = exports.BadRouteError = exports.InternalServerErrorWith = exports.InternalServerError = exports.RequiredArgumentError = exports.InvalidArgumentError = exports.NotFoundError = exports.TwirpError = void 0;
|
||||
/**
|
||||
* Represents a twirp error
|
||||
*/
|
||||
class TwirpError extends Error {
|
||||
constructor(code, msg) {
|
||||
super(msg);
|
||||
this.code = TwirpErrorCode.Internal;
|
||||
this.meta = {};
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
Object.setPrototypeOf(this, TwirpError.prototype);
|
||||
}
|
||||
/**
|
||||
* Adds a metadata kv to the error
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
withMeta(key, value) {
|
||||
this.meta[key] = value;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Returns a single metadata value
|
||||
* return "" if not found
|
||||
* @param key
|
||||
*/
|
||||
getMeta(key) {
|
||||
return this.meta[key] || "";
|
||||
}
|
||||
/**
|
||||
* Add the original error cause
|
||||
* @param err
|
||||
* @param addMeta
|
||||
*/
|
||||
withCause(err, addMeta = false) {
|
||||
this._originalCause = err;
|
||||
if (addMeta) {
|
||||
this.withMeta("cause", err.message);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
cause() {
|
||||
return this._originalCause;
|
||||
}
|
||||
/**
|
||||
* Returns the error representation to JSON
|
||||
*/
|
||||
toJSON() {
|
||||
try {
|
||||
return JSON.stringify({
|
||||
code: this.code,
|
||||
msg: this.msg,
|
||||
meta: this.meta,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
return `{"code": "internal", "msg": "There was an error but it could not be serialized into JSON"}`;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create a twirp error from an object
|
||||
* @param obj
|
||||
*/
|
||||
static fromObject(obj) {
|
||||
const code = obj["code"] || TwirpErrorCode.Unknown;
|
||||
const msg = obj["msg"] || "unknown";
|
||||
const error = new TwirpError(code, msg);
|
||||
if (obj["meta"]) {
|
||||
Object.keys(obj["meta"]).forEach((key) => {
|
||||
error.withMeta(key, obj["meta"][key]);
|
||||
});
|
||||
}
|
||||
return error;
|
||||
}
|
||||
}
|
||||
exports.TwirpError = TwirpError;
|
||||
/**
|
||||
* NotFoundError constructor for the common NotFound error.
|
||||
*/
|
||||
class NotFoundError extends TwirpError {
|
||||
constructor(msg) {
|
||||
super(TwirpErrorCode.NotFound, msg);
|
||||
}
|
||||
}
|
||||
exports.NotFoundError = NotFoundError;
|
||||
/**
|
||||
* InvalidArgumentError constructor for the common InvalidArgument error. Can be
|
||||
* used when an argument has invalid format, is a number out of range, is a bad
|
||||
* option, etc).
|
||||
*/
|
||||
class InvalidArgumentError extends TwirpError {
|
||||
constructor(argument, validationMsg) {
|
||||
super(TwirpErrorCode.InvalidArgument, argument + " " + validationMsg);
|
||||
this.withMeta("argument", argument);
|
||||
}
|
||||
}
|
||||
exports.InvalidArgumentError = InvalidArgumentError;
|
||||
/**
|
||||
* RequiredArgumentError is a more specific constructor for InvalidArgument
|
||||
* error. Should be used when the argument is required (expected to have a
|
||||
* non-zero value).
|
||||
*/
|
||||
class RequiredArgumentError extends InvalidArgumentError {
|
||||
constructor(argument) {
|
||||
super(argument, "is required");
|
||||
}
|
||||
}
|
||||
exports.RequiredArgumentError = RequiredArgumentError;
|
||||
/**
|
||||
* InternalError constructor for the common Internal error. Should be used to
|
||||
* specify that something bad or unexpected happened.
|
||||
*/
|
||||
class InternalServerError extends TwirpError {
|
||||
constructor(msg) {
|
||||
super(TwirpErrorCode.Internal, msg);
|
||||
}
|
||||
}
|
||||
exports.InternalServerError = InternalServerError;
|
||||
/**
|
||||
* InternalErrorWith makes an internal error, wrapping the original error and using it
|
||||
* for the error message, and with metadata "cause" with the original error type.
|
||||
* This function is used by Twirp services to wrap non-Twirp errors as internal errors.
|
||||
* The wrapped error can be extracted later with err.cause()
|
||||
*/
|
||||
class InternalServerErrorWith extends InternalServerError {
|
||||
constructor(err) {
|
||||
super(err.message);
|
||||
this.withMeta("cause", err.name);
|
||||
this.withCause(err);
|
||||
}
|
||||
}
|
||||
exports.InternalServerErrorWith = InternalServerErrorWith;
|
||||
/**
|
||||
* A standard BadRoute Error
|
||||
*/
|
||||
class BadRouteError extends TwirpError {
|
||||
constructor(msg, method, url) {
|
||||
super(TwirpErrorCode.BadRoute, msg);
|
||||
this.withMeta("twirp_invalid_route", method + " " + url);
|
||||
}
|
||||
}
|
||||
exports.BadRouteError = BadRouteError;
|
||||
var TwirpErrorCode;
|
||||
(function (TwirpErrorCode) {
|
||||
// Canceled indicates the operation was cancelled (typically by the caller).
|
||||
TwirpErrorCode["Canceled"] = "canceled";
|
||||
// Unknown error. For example when handling errors raised by APIs that do not
|
||||
// return enough error information.
|
||||
TwirpErrorCode["Unknown"] = "unknown";
|
||||
// InvalidArgument indicates client specified an invalid argument. It
|
||||
// indicates arguments that are problematic regardless of the state of the
|
||||
// system (i.e. a malformed file name, required argument, number out of range,
|
||||
// etc.).
|
||||
TwirpErrorCode["InvalidArgument"] = "invalid_argument";
|
||||
// Malformed indicates an error occurred while decoding the client's request.
|
||||
// This may mean that the message was encoded improperly, or that there is a
|
||||
// disagreement in message format between the client and server.
|
||||
TwirpErrorCode["Malformed"] = "malformed";
|
||||
// DeadlineExceeded means operation expired before completion. For operations
|
||||
// that change the state of the system, this error may be returned even if the
|
||||
// operation has completed successfully (timeout).
|
||||
TwirpErrorCode["DeadlineExceeded"] = "deadline_exceeded";
|
||||
// NotFound means some requested entity was not found.
|
||||
TwirpErrorCode["NotFound"] = "not_found";
|
||||
// BadRoute means that the requested URL path wasn't routable to a Twirp
|
||||
// service and method. This is returned by the generated server, and usually
|
||||
// shouldn't be returned by applications. Instead, applications should use
|
||||
// NotFound or Unimplemented.
|
||||
TwirpErrorCode["BadRoute"] = "bad_route";
|
||||
// AlreadyExists means an attempt to create an entity failed because one
|
||||
// already exists.
|
||||
TwirpErrorCode["AlreadyExists"] = "already_exists";
|
||||
// PermissionDenied indicates the caller does not have permission to execute
|
||||
// the specified operation. It must not be used if the caller cannot be
|
||||
// identified (Unauthenticated).
|
||||
TwirpErrorCode["PermissionDenied"] = "permission_denied";
|
||||
// Unauthenticated indicates the request does not have valid authentication
|
||||
// credentials for the operation.
|
||||
TwirpErrorCode["Unauthenticated"] = "unauthenticated";
|
||||
// ResourceExhausted indicates some resource has been exhausted, perhaps a
|
||||
// per-user quota, or perhaps the entire file system is out of space.
|
||||
TwirpErrorCode["ResourceExhausted"] = "resource_exhausted";
|
||||
// FailedPrecondition indicates operation was rejected because the system is
|
||||
// not in a state required for the operation's execution. For example, doing
|
||||
// an rmdir operation on a directory that is non-empty, or on a non-directory
|
||||
// object, or when having conflicting read-modify-write on the same resource.
|
||||
TwirpErrorCode["FailedPrecondition"] = "failed_precondition";
|
||||
// Aborted indicates the operation was aborted, typically due to a concurrency
|
||||
// issue like sequencer check failures, transaction aborts, etc.
|
||||
TwirpErrorCode["Aborted"] = "aborted";
|
||||
// OutOfRange means operation was attempted past the valid range. For example,
|
||||
// seeking or reading past end of a paginated collection.
|
||||
//
|
||||
// Unlike InvalidArgument, this error indicates a problem that may be fixed if
|
||||
// the system state changes (i.e. adding more items to the collection).
|
||||
//
|
||||
// There is a fair bit of overlap between FailedPrecondition and OutOfRange.
|
||||
// We recommend using OutOfRange (the more specific error) when it applies so
|
||||
// that callers who are iterating through a space can easily look for an
|
||||
// OutOfRange error to detect when they are done.
|
||||
TwirpErrorCode["OutOfRange"] = "out_of_range";
|
||||
// Unimplemented indicates operation is not implemented or not
|
||||
// supported/enabled in this service.
|
||||
TwirpErrorCode["Unimplemented"] = "unimplemented";
|
||||
// Internal errors. When some invariants expected by the underlying system
|
||||
// have been broken. In other words, something bad happened in the library or
|
||||
// backend service. Do not confuse with HTTP Internal Server Error; an
|
||||
// Internal error could also happen on the client code, i.e. when parsing a
|
||||
// server response.
|
||||
TwirpErrorCode["Internal"] = "internal";
|
||||
// Unavailable indicates the service is currently unavailable. This is a most
|
||||
// likely a transient condition and may be corrected by retrying with a
|
||||
// backoff.
|
||||
TwirpErrorCode["Unavailable"] = "unavailable";
|
||||
// DataLoss indicates unrecoverable data loss or corruption.
|
||||
TwirpErrorCode["DataLoss"] = "data_loss";
|
||||
})(TwirpErrorCode = exports.TwirpErrorCode || (exports.TwirpErrorCode = {}));
|
||||
// ServerHTTPStatusFromErrorCode maps a Twirp error type into a similar HTTP
|
||||
// response status. It is used by the Twirp server handler to set the HTTP
|
||||
// response status code. Returns 0 if the ErrorCode is invalid.
|
||||
function httpStatusFromErrorCode(code) {
|
||||
switch (code) {
|
||||
case TwirpErrorCode.Canceled:
|
||||
return 408; // RequestTimeout
|
||||
case TwirpErrorCode.Unknown:
|
||||
return 500; // Internal Server Error
|
||||
case TwirpErrorCode.InvalidArgument:
|
||||
return 400; // BadRequest
|
||||
case TwirpErrorCode.Malformed:
|
||||
return 400; // BadRequest
|
||||
case TwirpErrorCode.DeadlineExceeded:
|
||||
return 408; // RequestTimeout
|
||||
case TwirpErrorCode.NotFound:
|
||||
return 404; // Not Found
|
||||
case TwirpErrorCode.BadRoute:
|
||||
return 404; // Not Found
|
||||
case TwirpErrorCode.AlreadyExists:
|
||||
return 409; // Conflict
|
||||
case TwirpErrorCode.PermissionDenied:
|
||||
return 403; // Forbidden
|
||||
case TwirpErrorCode.Unauthenticated:
|
||||
return 401; // Unauthorized
|
||||
case TwirpErrorCode.ResourceExhausted:
|
||||
return 429; // Too Many Requests
|
||||
case TwirpErrorCode.FailedPrecondition:
|
||||
return 412; // Precondition Failed
|
||||
case TwirpErrorCode.Aborted:
|
||||
return 409; // Conflict
|
||||
case TwirpErrorCode.OutOfRange:
|
||||
return 400; // Bad Request
|
||||
case TwirpErrorCode.Unimplemented:
|
||||
return 501; // Not Implemented
|
||||
case TwirpErrorCode.Internal:
|
||||
return 500; // Internal Server Error
|
||||
case TwirpErrorCode.Unavailable:
|
||||
return 503; // Service Unavailable
|
||||
case TwirpErrorCode.DataLoss:
|
||||
return 500; // Internal Server Error
|
||||
default:
|
||||
return 0; // Invalid!
|
||||
}
|
||||
}
|
||||
exports.httpStatusFromErrorCode = httpStatusFromErrorCode;
|
||||
// IsValidErrorCode returns true if is one of the valid predefined constants.
|
||||
function isValidErrorCode(code) {
|
||||
return httpStatusFromErrorCode(code) != 0;
|
||||
}
|
||||
exports.isValidErrorCode = isValidErrorCode;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9636:
|
||||
/***/ (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;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (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 (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__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 __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Gateway = exports.Pattern = void 0;
|
||||
const querystring_1 = __nccwpck_require__(3480);
|
||||
const dotObject = __importStar(__nccwpck_require__(5129));
|
||||
const request_1 = __nccwpck_require__(9647);
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
const http_client_1 = __nccwpck_require__(5683);
|
||||
const server_1 = __nccwpck_require__(1035);
|
||||
var Pattern;
|
||||
(function (Pattern) {
|
||||
Pattern["POST"] = "post";
|
||||
Pattern["GET"] = "get";
|
||||
Pattern["PATCH"] = "patch";
|
||||
Pattern["PUT"] = "put";
|
||||
Pattern["DELETE"] = "delete";
|
||||
})(Pattern = exports.Pattern || (exports.Pattern = {}));
|
||||
/**
|
||||
* The Gateway proxies http requests to Twirp Compliant
|
||||
* handlers
|
||||
*/
|
||||
class Gateway {
|
||||
constructor(routes) {
|
||||
this.routes = routes;
|
||||
}
|
||||
/**
|
||||
* Middleware that rewrite the current request
|
||||
* to a Twirp compliant request
|
||||
*/
|
||||
twirpRewrite(prefix = "/twirp") {
|
||||
return (req, resp, next) => {
|
||||
this.rewrite(req, resp, prefix)
|
||||
.then(() => next())
|
||||
.catch((e) => {
|
||||
if (e instanceof errors_1.TwirpError) {
|
||||
if (e.code !== errors_1.TwirpErrorCode.NotFound) {
|
||||
server_1.writeError(resp, e);
|
||||
}
|
||||
else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Rewrite an incoming request to a Twirp compliant request
|
||||
* @param req
|
||||
* @param resp
|
||||
* @param prefix
|
||||
*/
|
||||
rewrite(req, resp, prefix = "/twirp") {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const [match, route] = this.matchRoute(req);
|
||||
const body = yield this.prepareTwirpBody(req, match, route);
|
||||
const twirpUrl = `${prefix}/${route.packageName}.${route.serviceName}/${route.methodName}`;
|
||||
req.url = twirpUrl;
|
||||
req.originalUrl = twirpUrl;
|
||||
req.method = "POST";
|
||||
req.headers["content-type"] = "application/json";
|
||||
req.rawBody = Buffer.from(JSON.stringify(body));
|
||||
if (route.responseBodyKey) {
|
||||
const endFn = resp.end.bind(resp);
|
||||
resp.end = function (chunk) {
|
||||
if (resp.statusCode === 200) {
|
||||
endFn(`{ "${route.responseBodyKey}": ${chunk} }`);
|
||||
}
|
||||
else {
|
||||
endFn(chunk);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Create a reverse proxy handler to
|
||||
* proxy http requests to Twirp Compliant handlers
|
||||
* @param httpClientOption
|
||||
*/
|
||||
reverseProxy(httpClientOption) {
|
||||
const client = http_client_1.NodeHttpRPC(httpClientOption);
|
||||
return (req, res) => __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const [match, route] = this.matchRoute(req);
|
||||
const body = yield this.prepareTwirpBody(req, match, route);
|
||||
const response = yield client.request(`${route.packageName}.${route.serviceName}`, route.methodName, "application/json", body);
|
||||
res.statusCode = 200;
|
||||
res.setHeader("content-type", "application/json");
|
||||
let jsonResponse;
|
||||
if (route.responseBodyKey) {
|
||||
jsonResponse = JSON.stringify({ [route.responseBodyKey]: response });
|
||||
}
|
||||
else {
|
||||
jsonResponse = JSON.stringify(response);
|
||||
}
|
||||
res.end(jsonResponse);
|
||||
}
|
||||
catch (e) {
|
||||
server_1.writeError(res, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Prepares twirp body requests using http.google.annotions
|
||||
* compliant spec
|
||||
*
|
||||
* @param req
|
||||
* @param match
|
||||
* @param route
|
||||
* @protected
|
||||
*/
|
||||
prepareTwirpBody(req, match, route) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const _a = match.params, { query_string } = _a, params = __rest(_a, ["query_string"]);
|
||||
let requestBody = Object.assign({}, params);
|
||||
if (query_string && route.bodyKey !== "*") {
|
||||
const queryParams = this.parseQueryString(query_string);
|
||||
requestBody = Object.assign(Object.assign({}, queryParams), requestBody);
|
||||
}
|
||||
let body = {};
|
||||
if (route.bodyKey) {
|
||||
const data = yield request_1.getRequestData(req);
|
||||
try {
|
||||
const jsonBody = JSON.parse(data.toString() || "{}");
|
||||
if (route.bodyKey === "*") {
|
||||
body = jsonBody;
|
||||
}
|
||||
else {
|
||||
body[route.bodyKey] = jsonBody;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new errors_1.TwirpError(errors_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
return Object.assign(Object.assign({}, body), requestBody);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Matches a route
|
||||
* @param req
|
||||
*/
|
||||
matchRoute(req) {
|
||||
var _a;
|
||||
const httpMethod = (_a = req.method) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
||||
if (!httpMethod) {
|
||||
throw new errors_1.BadRouteError(`method not allowed`, req.method || "", req.url || "");
|
||||
}
|
||||
const routes = this.routes[httpMethod];
|
||||
for (const route of routes) {
|
||||
const match = route.matcher(req.url || "/");
|
||||
if (match) {
|
||||
return [match, route];
|
||||
}
|
||||
}
|
||||
throw new errors_1.NotFoundError(`url ${req.url} not found`);
|
||||
}
|
||||
/**
|
||||
* Parse query string
|
||||
* @param queryString
|
||||
*/
|
||||
parseQueryString(queryString) {
|
||||
const queryParams = querystring_1.parse(queryString.replace("?", ""));
|
||||
return dotObject.object(queryParams);
|
||||
}
|
||||
}
|
||||
exports.Gateway = Gateway;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3898:
|
||||
/***/ (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.isHook = exports.chainHooks = void 0;
|
||||
// ChainHooks creates a new ServerHook which chains the callbacks in
|
||||
// each of the constituent hooks passed in. Each hook function will be
|
||||
// called in the order of the ServerHooks values passed in.
|
||||
//
|
||||
// For the erroring hooks, RequestReceived and RequestRouted, any returned
|
||||
// errors prevent processing by later hooks.
|
||||
function chainHooks(...hooks) {
|
||||
if (hooks.length === 0) {
|
||||
return null;
|
||||
}
|
||||
if (hooks.length === 1) {
|
||||
return hooks[0];
|
||||
}
|
||||
const serverHook = {
|
||||
requestReceived(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestReceived) {
|
||||
continue;
|
||||
}
|
||||
yield hook.requestReceived(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
requestPrepared(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestPrepared) {
|
||||
continue;
|
||||
}
|
||||
console.warn("hook requestPrepared is deprecated and will be removed in the next release. " +
|
||||
"Please use responsePrepared instead.");
|
||||
yield hook.requestPrepared(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
responsePrepared(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.responsePrepared) {
|
||||
continue;
|
||||
}
|
||||
yield hook.responsePrepared(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
requestSent(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestSent) {
|
||||
continue;
|
||||
}
|
||||
console.warn("hook requestSent is deprecated and will be removed in the next release. " +
|
||||
"Please use responseSent instead.");
|
||||
yield hook.requestSent(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
responseSent(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.responseSent) {
|
||||
continue;
|
||||
}
|
||||
yield hook.responseSent(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
requestRouted(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestRouted) {
|
||||
continue;
|
||||
}
|
||||
yield hook.requestRouted(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
error(ctx, err) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.error) {
|
||||
continue;
|
||||
}
|
||||
yield hook.error(ctx, err);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
return serverHook;
|
||||
}
|
||||
exports.chainHooks = chainHooks;
|
||||
function isHook(object) {
|
||||
return ("requestReceived" in object ||
|
||||
"requestPrepared" in object ||
|
||||
"requestSent" in object ||
|
||||
"requestRouted" in object ||
|
||||
"responsePrepared" in object ||
|
||||
"responseSent" in object ||
|
||||
"error" in object);
|
||||
}
|
||||
exports.isHook = isHook;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5683:
|
||||
/***/ (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;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (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 (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__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.FetchRPC = exports.wrapErrorResponseToTwirpError = exports.NodeHttpRPC = void 0;
|
||||
const http = __importStar(__nccwpck_require__(8611));
|
||||
const https = __importStar(__nccwpck_require__(5692));
|
||||
const url_1 = __nccwpck_require__(7016);
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
/**
|
||||
* a node HTTP RPC implementation
|
||||
* @param options
|
||||
* @constructor
|
||||
*/
|
||||
const NodeHttpRPC = (options) => ({
|
||||
request(service, method, contentType, data) {
|
||||
let client;
|
||||
return new Promise((resolve, rejected) => {
|
||||
const responseChunks = [];
|
||||
const requestData = contentType === "application/protobuf"
|
||||
? Buffer.from(data)
|
||||
: JSON.stringify(data);
|
||||
const url = new url_1.URL(options.baseUrl);
|
||||
const isHttps = url.protocol === "https:";
|
||||
if (isHttps) {
|
||||
client = https;
|
||||
}
|
||||
else {
|
||||
client = http;
|
||||
}
|
||||
const prefix = url.pathname !== "/" ? url.pathname : "";
|
||||
const req = client
|
||||
.request(Object.assign(Object.assign({}, (options ? options : {})), { method: "POST", protocol: url.protocol, host: url.hostname, port: url.port ? url.port : isHttps ? 443 : 80, path: `${prefix}/${service}/${method}`, headers: Object.assign(Object.assign({}, (options.headers ? options.headers : {})), { "Content-Type": contentType, "Content-Length": contentType === "application/protobuf"
|
||||
? Buffer.byteLength(requestData)
|
||||
: Buffer.from(requestData).byteLength }) }), (res) => {
|
||||
res.on("data", (chunk) => responseChunks.push(chunk));
|
||||
res.on("end", () => {
|
||||
const data = Buffer.concat(responseChunks);
|
||||
if (res.statusCode != 200) {
|
||||
rejected(wrapErrorResponseToTwirpError(data.toString()));
|
||||
}
|
||||
else {
|
||||
if (contentType === "application/json") {
|
||||
resolve(JSON.parse(data.toString()));
|
||||
}
|
||||
else {
|
||||
resolve(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
res.on("error", (err) => {
|
||||
rejected(err);
|
||||
});
|
||||
})
|
||||
.on("error", (err) => {
|
||||
rejected(err);
|
||||
});
|
||||
req.end(requestData);
|
||||
});
|
||||
},
|
||||
});
|
||||
exports.NodeHttpRPC = NodeHttpRPC;
|
||||
function wrapErrorResponseToTwirpError(errorResponse) {
|
||||
return errors_1.TwirpError.fromObject(JSON.parse(errorResponse));
|
||||
}
|
||||
exports.wrapErrorResponseToTwirpError = wrapErrorResponseToTwirpError;
|
||||
/**
|
||||
* a browser fetch RPC implementation
|
||||
*/
|
||||
const FetchRPC = (options) => ({
|
||||
request(service, method, contentType, data) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const headers = new Headers(options.headers);
|
||||
headers.set("content-type", contentType);
|
||||
const response = yield fetch(`${options.baseUrl}/${service}/${method}`, Object.assign(Object.assign({}, options), { method: "POST", headers, body: data instanceof Uint8Array ? data : JSON.stringify(data) }));
|
||||
if (response.status === 200) {
|
||||
if (contentType === "application/json") {
|
||||
return yield response.json();
|
||||
}
|
||||
return new Uint8Array(yield response.arrayBuffer());
|
||||
}
|
||||
throw errors_1.TwirpError.fromObject(yield response.json());
|
||||
});
|
||||
},
|
||||
});
|
||||
exports.FetchRPC = FetchRPC;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 430:
|
||||
/***/ (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;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.TwirpContentType = void 0;
|
||||
__exportStar(__nccwpck_require__(5497), exports);
|
||||
__exportStar(__nccwpck_require__(1035), exports);
|
||||
__exportStar(__nccwpck_require__(4036), exports);
|
||||
__exportStar(__nccwpck_require__(3898), exports);
|
||||
__exportStar(__nccwpck_require__(3315), exports);
|
||||
__exportStar(__nccwpck_require__(9636), exports);
|
||||
__exportStar(__nccwpck_require__(5683), exports);
|
||||
var request_1 = __nccwpck_require__(9647);
|
||||
Object.defineProperty(exports, "TwirpContentType", ({ enumerable: true, get: function () { return request_1.TwirpContentType; } }));
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4036:
|
||||
/***/ (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.chainInterceptors = void 0;
|
||||
// chains multiple Interceptors into a single Interceptor.
|
||||
// The first interceptor wraps the second one, and so on.
|
||||
// Returns null if interceptors is empty.
|
||||
function chainInterceptors(...interceptors) {
|
||||
if (interceptors.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (interceptors.length === 1) {
|
||||
return interceptors[0];
|
||||
}
|
||||
const first = interceptors[0];
|
||||
return (ctx, request, handler) => __awaiter(this, void 0, void 0, function* () {
|
||||
let next = handler;
|
||||
for (let i = interceptors.length - 1; i > 0; i--) {
|
||||
next = ((next) => (ctx, typedRequest) => {
|
||||
return interceptors[i](ctx, typedRequest, next);
|
||||
})(next);
|
||||
}
|
||||
return first(ctx, request, next);
|
||||
});
|
||||
}
|
||||
exports.chainInterceptors = chainInterceptors;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9647:
|
||||
/***/ (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.parseTwirpPath = exports.getRequestData = exports.validateRequest = exports.getContentType = exports.TwirpContentType = void 0;
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
/**
|
||||
* Supported Twirp Content-Type
|
||||
*/
|
||||
var TwirpContentType;
|
||||
(function (TwirpContentType) {
|
||||
TwirpContentType[TwirpContentType["Protobuf"] = 0] = "Protobuf";
|
||||
TwirpContentType[TwirpContentType["JSON"] = 1] = "JSON";
|
||||
TwirpContentType[TwirpContentType["Unknown"] = 2] = "Unknown";
|
||||
})(TwirpContentType = exports.TwirpContentType || (exports.TwirpContentType = {}));
|
||||
/**
|
||||
* Get supported content-type
|
||||
* @param mimeType
|
||||
*/
|
||||
function getContentType(mimeType) {
|
||||
switch (mimeType) {
|
||||
case "application/protobuf":
|
||||
return TwirpContentType.Protobuf;
|
||||
case "application/json":
|
||||
return TwirpContentType.JSON;
|
||||
default:
|
||||
return TwirpContentType.Unknown;
|
||||
}
|
||||
}
|
||||
exports.getContentType = getContentType;
|
||||
/**
|
||||
* Validate a twirp request
|
||||
* @param ctx
|
||||
* @param request
|
||||
* @param pathPrefix
|
||||
*/
|
||||
function validateRequest(ctx, request, pathPrefix) {
|
||||
if (request.method !== "POST") {
|
||||
const msg = `unsupported method ${request.method} (only POST is allowed)`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
const path = parseTwirpPath(request.url || "");
|
||||
if (path.pkgService !==
|
||||
(ctx.packageName ? ctx.packageName + "." : "") + ctx.serviceName) {
|
||||
const msg = `no handler for path ${request.url}`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
if (path.prefix !== pathPrefix) {
|
||||
const msg = `invalid path prefix ${path.prefix}, expected ${pathPrefix}, on path ${request.url}`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
const mimeContentType = request.headers["content-type"] || "";
|
||||
if (ctx.contentType === TwirpContentType.Unknown) {
|
||||
const msg = `unexpected Content-Type: ${request.headers["content-type"]}`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
return Object.assign(Object.assign({}, path), { mimeContentType, contentType: ctx.contentType });
|
||||
}
|
||||
exports.validateRequest = validateRequest;
|
||||
/**
|
||||
* Get request data from the body
|
||||
* @param req
|
||||
*/
|
||||
function getRequestData(req) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reqWithRawBody = req;
|
||||
if (reqWithRawBody.rawBody instanceof Buffer) {
|
||||
resolve(reqWithRawBody.rawBody);
|
||||
return;
|
||||
}
|
||||
const chunks = [];
|
||||
req.on("data", (chunk) => chunks.push(chunk));
|
||||
req.on("end", () => __awaiter(this, void 0, void 0, function* () {
|
||||
const data = Buffer.concat(chunks);
|
||||
resolve(data);
|
||||
}));
|
||||
req.on("error", (err) => {
|
||||
if (req.aborted) {
|
||||
reject(new errors_1.TwirpError(errors_1.TwirpErrorCode.DeadlineExceeded, "failed to read request: deadline exceeded"));
|
||||
}
|
||||
else {
|
||||
reject(new errors_1.TwirpError(errors_1.TwirpErrorCode.Malformed, err.message).withCause(err));
|
||||
}
|
||||
});
|
||||
req.on("close", () => {
|
||||
reject(new errors_1.TwirpError(errors_1.TwirpErrorCode.Canceled, "failed to read request: context canceled"));
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.getRequestData = getRequestData;
|
||||
/**
|
||||
* Parses twirp url path
|
||||
* @param path
|
||||
*/
|
||||
function parseTwirpPath(path) {
|
||||
const parts = path.split("/");
|
||||
if (parts.length < 2) {
|
||||
return {
|
||||
pkgService: "",
|
||||
method: "",
|
||||
prefix: "",
|
||||
};
|
||||
}
|
||||
return {
|
||||
method: parts[parts.length - 1],
|
||||
pkgService: parts[parts.length - 2],
|
||||
prefix: parts.slice(0, parts.length - 2).join("/"),
|
||||
};
|
||||
}
|
||||
exports.parseTwirpPath = parseTwirpPath;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 1035:
|
||||
/***/ (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.writeError = exports.TwirpServer = void 0;
|
||||
const hooks_1 = __nccwpck_require__(3898);
|
||||
const request_1 = __nccwpck_require__(9647);
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
/**
|
||||
* Runtime server implementation of a TwirpServer
|
||||
*/
|
||||
class TwirpServer {
|
||||
constructor(options) {
|
||||
this.pathPrefix = "/twirp";
|
||||
this.hooks = [];
|
||||
this.interceptors = [];
|
||||
this.packageName = options.packageName;
|
||||
this.serviceName = options.serviceName;
|
||||
this.methodList = options.methodList;
|
||||
this.matchRoute = options.matchRoute;
|
||||
this.service = options.service;
|
||||
}
|
||||
/**
|
||||
* Returns the prefix for this server
|
||||
*/
|
||||
get prefix() {
|
||||
return this.pathPrefix;
|
||||
}
|
||||
/**
|
||||
* The http handler for twirp complaint endpoints
|
||||
* @param options
|
||||
*/
|
||||
httpHandler(options) {
|
||||
return (req, resp) => {
|
||||
// setup prefix
|
||||
if ((options === null || options === void 0 ? void 0 : options.prefix) !== undefined) {
|
||||
this.withPrefix(options.prefix);
|
||||
}
|
||||
return this._httpHandler(req, resp);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Adds interceptors or hooks to the request stack
|
||||
* @param middlewares
|
||||
*/
|
||||
use(...middlewares) {
|
||||
middlewares.forEach((middleware) => {
|
||||
if (hooks_1.isHook(middleware)) {
|
||||
this.hooks.push(middleware);
|
||||
return this;
|
||||
}
|
||||
this.interceptors.push(middleware);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Adds a prefix to the service url path
|
||||
* @param prefix
|
||||
*/
|
||||
withPrefix(prefix) {
|
||||
if (prefix === false) {
|
||||
this.pathPrefix = "";
|
||||
}
|
||||
else {
|
||||
this.pathPrefix = prefix;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Returns the regex matching path for this twirp server
|
||||
*/
|
||||
matchingPath() {
|
||||
const baseRegex = this.baseURI().replace(/\./g, "\\.");
|
||||
return new RegExp(`${baseRegex}\/(${this.methodList.join("|")})`);
|
||||
}
|
||||
/**
|
||||
* Returns the base URI for this twirp server
|
||||
*/
|
||||
baseURI() {
|
||||
return `${this.pathPrefix}/${this.packageName ? this.packageName + "." : ""}${this.serviceName}`;
|
||||
}
|
||||
/**
|
||||
* Create a twirp context
|
||||
* @param req
|
||||
* @param res
|
||||
* @private
|
||||
*/
|
||||
createContext(req, res) {
|
||||
return {
|
||||
packageName: this.packageName,
|
||||
serviceName: this.serviceName,
|
||||
methodName: "",
|
||||
contentType: request_1.getContentType(req.headers["content-type"]),
|
||||
req: req,
|
||||
res: res,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Twrip server http handler implementation
|
||||
* @param req
|
||||
* @param resp
|
||||
* @private
|
||||
*/
|
||||
_httpHandler(req, resp) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const ctx = this.createContext(req, resp);
|
||||
try {
|
||||
yield this.invokeHook("requestReceived", ctx);
|
||||
const { method, mimeContentType } = request_1.validateRequest(ctx, req, this.pathPrefix || "");
|
||||
const handler = this.matchRoute(method, {
|
||||
onMatch: (ctx) => {
|
||||
return this.invokeHook("requestRouted", ctx);
|
||||
},
|
||||
onNotFound: () => {
|
||||
const msg = `no handler for path ${req.url}`;
|
||||
throw new errors_1.BadRouteError(msg, req.method || "", req.url || "");
|
||||
},
|
||||
});
|
||||
const body = yield request_1.getRequestData(req);
|
||||
const response = yield handler(ctx, this.service, body, this.interceptors);
|
||||
yield Promise.all([
|
||||
this.invokeHook("responsePrepared", ctx),
|
||||
// keep backwards compatibility till next release
|
||||
this.invokeHook("requestPrepared", ctx),
|
||||
]);
|
||||
resp.statusCode = 200;
|
||||
resp.setHeader("Content-Type", mimeContentType);
|
||||
resp.end(response);
|
||||
}
|
||||
catch (e) {
|
||||
yield this.invokeHook("error", ctx, mustBeTwirpError(e));
|
||||
if (!resp.headersSent) {
|
||||
writeError(resp, e);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
yield Promise.all([
|
||||
this.invokeHook("responseSent", ctx),
|
||||
// keep backwards compatibility till next release
|
||||
this.invokeHook("requestSent", ctx),
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Invoke a hook
|
||||
* @param hookName
|
||||
* @param ctx
|
||||
* @param err
|
||||
* @protected
|
||||
*/
|
||||
invokeHook(hookName, ctx, err) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (this.hooks.length === 0) {
|
||||
return;
|
||||
}
|
||||
const chainedHooks = hooks_1.chainHooks(...this.hooks);
|
||||
const hook = chainedHooks === null || chainedHooks === void 0 ? void 0 : chainedHooks[hookName];
|
||||
if (hook) {
|
||||
yield hook(ctx, err || new errors_1.InternalServerError("internal server error"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.TwirpServer = TwirpServer;
|
||||
/**
|
||||
* Write http error response
|
||||
* @param res
|
||||
* @param error
|
||||
*/
|
||||
function writeError(res, error) {
|
||||
const twirpError = mustBeTwirpError(error);
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
res.statusCode = errors_1.httpStatusFromErrorCode(twirpError.code);
|
||||
res.end(twirpError.toJSON());
|
||||
}
|
||||
exports.writeError = writeError;
|
||||
/**
|
||||
* Make sure that the error passed is a TwirpError
|
||||
* otherwise it will wrap it into an InternalError
|
||||
* @param err
|
||||
*/
|
||||
function mustBeTwirpError(err) {
|
||||
if (err instanceof errors_1.TwirpError) {
|
||||
return err;
|
||||
}
|
||||
return new errors_1.InternalServerErrorWith(err);
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8736:
|
||||
@ -68133,14 +65270,6 @@ module.exports = require("punycode");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3480:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("querystring");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2203:
|
||||
/***/ ((module) => {
|
||||
|
||||
@ -68201,7 +65330,7 @@ module.exports = require("zlib");
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.0.0","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1","twirp-ts":"^2.5.0"},"devDependencies":{"@types/semver":"^6.0.0","typescript":"^5.2.2"}}');
|
||||
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.0.2","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1"},"devDependencies":{"@types/semver":"^6.0.0","typescript":"^5.2.2"}}');
|
||||
|
||||
/***/ }),
|
||||
|
||||
|
||||
2913
dist/save/index.js
vendored
2913
dist/save/index.js
vendored
@ -220,7 +220,7 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
||||
};
|
||||
const response = yield twirpClient.GetCacheEntryDownloadURL(request);
|
||||
if (!response.ok) {
|
||||
core.warning(`Cache not found for keys: ${keys.join(', ')}`);
|
||||
core.debug(`Cache not found for keys: ${keys.join(', ')}`);
|
||||
return undefined;
|
||||
}
|
||||
core.info(`Cache hit for: ${request.key}`);
|
||||
@ -412,12 +412,20 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
key,
|
||||
version
|
||||
};
|
||||
const response = yield twirpClient.CreateCacheEntry(request);
|
||||
if (!response.ok) {
|
||||
let signedUploadUrl;
|
||||
try {
|
||||
const response = yield twirpClient.CreateCacheEntry(request);
|
||||
if (!response.ok) {
|
||||
throw new Error('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, response.signedUploadUrl, options);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options);
|
||||
const finalizeRequest = {
|
||||
key,
|
||||
version,
|
||||
@ -458,156 +466,13 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8200:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Timestamp = void 0;
|
||||
const runtime_1 = __nccwpck_require__(8886);
|
||||
const runtime_2 = __nccwpck_require__(8886);
|
||||
const runtime_3 = __nccwpck_require__(8886);
|
||||
const runtime_4 = __nccwpck_require__(8886);
|
||||
const runtime_5 = __nccwpck_require__(8886);
|
||||
const runtime_6 = __nccwpck_require__(8886);
|
||||
const runtime_7 = __nccwpck_require__(8886);
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class Timestamp$Type extends runtime_7.MessageType {
|
||||
constructor() {
|
||||
super("google.protobuf.Timestamp", [
|
||||
{ no: 1, name: "seconds", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
|
||||
{ no: 2, name: "nanos", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* Creates a new `Timestamp` for the current time.
|
||||
*/
|
||||
now() {
|
||||
const msg = this.create();
|
||||
const ms = Date.now();
|
||||
msg.seconds = runtime_6.PbLong.from(Math.floor(ms / 1000)).toString();
|
||||
msg.nanos = (ms % 1000) * 1000000;
|
||||
return msg;
|
||||
}
|
||||
/**
|
||||
* Converts a `Timestamp` to a JavaScript Date.
|
||||
*/
|
||||
toDate(message) {
|
||||
return new Date(runtime_6.PbLong.from(message.seconds).toNumber() * 1000 + Math.ceil(message.nanos / 1000000));
|
||||
}
|
||||
/**
|
||||
* Converts a JavaScript Date to a `Timestamp`.
|
||||
*/
|
||||
fromDate(date) {
|
||||
const msg = this.create();
|
||||
const ms = date.getTime();
|
||||
msg.seconds = runtime_6.PbLong.from(Math.floor(ms / 1000)).toString();
|
||||
msg.nanos = (ms % 1000) * 1000000;
|
||||
return msg;
|
||||
}
|
||||
/**
|
||||
* In JSON format, the `Timestamp` type is encoded as a string
|
||||
* in the RFC 3339 format.
|
||||
*/
|
||||
internalJsonWrite(message, options) {
|
||||
let ms = runtime_6.PbLong.from(message.seconds).toNumber() * 1000;
|
||||
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z"))
|
||||
throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");
|
||||
if (message.nanos < 0)
|
||||
throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");
|
||||
let z = "Z";
|
||||
if (message.nanos > 0) {
|
||||
let nanosStr = (message.nanos + 1000000000).toString().substring(1);
|
||||
if (nanosStr.substring(3) === "000000")
|
||||
z = "." + nanosStr.substring(0, 3) + "Z";
|
||||
else if (nanosStr.substring(6) === "000")
|
||||
z = "." + nanosStr.substring(0, 6) + "Z";
|
||||
else
|
||||
z = "." + nanosStr + "Z";
|
||||
}
|
||||
return new Date(ms).toISOString().replace(".000Z", z);
|
||||
}
|
||||
/**
|
||||
* In JSON format, the `Timestamp` type is encoded as a string
|
||||
* in the RFC 3339 format.
|
||||
*/
|
||||
internalJsonRead(json, options, target) {
|
||||
if (typeof json !== "string")
|
||||
throw new Error("Unable to parse Timestamp from JSON " + (0, runtime_5.typeofJsonValue)(json) + ".");
|
||||
let matches = json.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);
|
||||
if (!matches)
|
||||
throw new Error("Unable to parse Timestamp from JSON. Invalid format.");
|
||||
let ms = Date.parse(matches[1] + "-" + matches[2] + "-" + matches[3] + "T" + matches[4] + ":" + matches[5] + ":" + matches[6] + (matches[8] ? matches[8] : "Z"));
|
||||
if (Number.isNaN(ms))
|
||||
throw new Error("Unable to parse Timestamp from JSON. Invalid value.");
|
||||
if (ms < Date.parse("0001-01-01T00:00:00Z") || ms > Date.parse("9999-12-31T23:59:59Z"))
|
||||
throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");
|
||||
if (!target)
|
||||
target = this.create();
|
||||
target.seconds = runtime_6.PbLong.from(ms / 1000).toString();
|
||||
target.nanos = 0;
|
||||
if (matches[7])
|
||||
target.nanos = (parseInt("1" + matches[7] + "0".repeat(9 - matches[7].length)) - 1000000000);
|
||||
return target;
|
||||
}
|
||||
create(value) {
|
||||
const message = { seconds: "0", nanos: 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 /* int64 seconds */ 1:
|
||||
message.seconds = reader.int64().toString();
|
||||
break;
|
||||
case /* int32 nanos */ 2:
|
||||
message.nanos = reader.int32();
|
||||
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 seconds = 1; */
|
||||
if (message.seconds !== "0")
|
||||
writer.tag(1, runtime_1.WireType.Varint).int64(message.seconds);
|
||||
/* int32 nanos = 2; */
|
||||
if (message.nanos !== 0)
|
||||
writer.tag(2, runtime_1.WireType.Varint).int32(message.nanos);
|
||||
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 google.protobuf.Timestamp
|
||||
*/
|
||||
exports.Timestamp = new Timestamp$Type();
|
||||
//# sourceMappingURL=timestamp.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3156:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.CacheService = exports.LookupCacheEntryResponse = exports.LookupCacheEntryRequest = exports.ListCacheEntriesResponse = exports.ListCacheEntriesRequest = exports.DeleteCacheEntryResponse = exports.DeleteCacheEntryRequest = exports.GetCacheEntryDownloadURLResponse = exports.GetCacheEntryDownloadURLRequest = exports.FinalizeCacheEntryUploadResponse = exports.FinalizeCacheEntryUploadRequest = exports.CreateCacheEntryResponse = exports.CreateCacheEntryRequest = void 0;
|
||||
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
|
||||
@ -617,7 +482,6 @@ const runtime_2 = __nccwpck_require__(8886);
|
||||
const runtime_3 = __nccwpck_require__(8886);
|
||||
const runtime_4 = __nccwpck_require__(8886);
|
||||
const runtime_5 = __nccwpck_require__(8886);
|
||||
const cacheentry_1 = __nccwpck_require__(5893);
|
||||
const cachemetadata_1 = __nccwpck_require__(9444);
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class CreateCacheEntryRequest$Type extends runtime_5.MessageType {
|
||||
@ -985,376 +849,25 @@ class GetCacheEntryDownloadURLResponse$Type extends runtime_5.MessageType {
|
||||
* @generated MessageType for protobuf message github.actions.results.api.v1.GetCacheEntryDownloadURLResponse
|
||||
*/
|
||||
exports.GetCacheEntryDownloadURLResponse = new GetCacheEntryDownloadURLResponse$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class DeleteCacheEntryRequest$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.DeleteCacheEntryRequest", [
|
||||
{ no: 1, name: "metadata", kind: "message", T: () => cachemetadata_1.CacheMetadata },
|
||||
{ no: 2, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { key: "" };
|
||||
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;
|
||||
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);
|
||||
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.DeleteCacheEntryRequest
|
||||
*/
|
||||
exports.DeleteCacheEntryRequest = new DeleteCacheEntryRequest$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class DeleteCacheEntryResponse$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.DeleteCacheEntryResponse", [
|
||||
{ no: 1, name: "ok", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
|
||||
{ no: 2, name: "entry_id", kind: "scalar", T: 3 /*ScalarType.INT64*/ }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { ok: false, entryId: "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 /* bool ok */ 1:
|
||||
message.ok = reader.bool();
|
||||
break;
|
||||
case /* int64 entry_id */ 2:
|
||||
message.entryId = 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) {
|
||||
/* 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);
|
||||
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.DeleteCacheEntryResponse
|
||||
*/
|
||||
exports.DeleteCacheEntryResponse = new DeleteCacheEntryResponse$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class ListCacheEntriesRequest$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.ListCacheEntriesRequest", [
|
||||
{ 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*/ }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { key: "", restoreKeys: [] };
|
||||
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;
|
||||
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]);
|
||||
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.ListCacheEntriesRequest
|
||||
*/
|
||||
exports.ListCacheEntriesRequest = new ListCacheEntriesRequest$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class ListCacheEntriesResponse$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.ListCacheEntriesResponse", [
|
||||
{ no: 1, name: "entries", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => cacheentry_1.CacheEntry }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { entries: [] };
|
||||
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 /* repeated github.actions.results.entities.v1.CacheEntry entries */ 1:
|
||||
message.entries.push(cacheentry_1.CacheEntry.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) {
|
||||
/* repeated github.actions.results.entities.v1.CacheEntry entries = 1; */
|
||||
for (let i = 0; i < message.entries.length; i++)
|
||||
cacheentry_1.CacheEntry.internalBinaryWrite(message.entries[i], writer.tag(1, 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.api.v1.ListCacheEntriesResponse
|
||||
*/
|
||||
exports.ListCacheEntriesResponse = new ListCacheEntriesResponse$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class LookupCacheEntryRequest$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.LookupCacheEntryRequest", [
|
||||
{ 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.LookupCacheEntryRequest
|
||||
*/
|
||||
exports.LookupCacheEntryRequest = new LookupCacheEntryRequest$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class LookupCacheEntryResponse$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.api.v1.LookupCacheEntryResponse", [
|
||||
{ no: 1, name: "exists", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
|
||||
{ no: 2, name: "entry", kind: "message", T: () => cacheentry_1.CacheEntry }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { exists: false };
|
||||
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 exists */ 1:
|
||||
message.exists = reader.bool();
|
||||
break;
|
||||
case /* github.actions.results.entities.v1.CacheEntry entry */ 2:
|
||||
message.entry = cacheentry_1.CacheEntry.internalBinaryRead(reader, reader.uint32(), options, message.entry);
|
||||
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 exists = 1; */
|
||||
if (message.exists !== false)
|
||||
writer.tag(1, runtime_1.WireType.Varint).bool(message.exists);
|
||||
/* github.actions.results.entities.v1.CacheEntry entry = 2; */
|
||||
if (message.entry)
|
||||
cacheentry_1.CacheEntry.internalBinaryWrite(message.entry, 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.api.v1.LookupCacheEntryResponse
|
||||
*/
|
||||
exports.LookupCacheEntryResponse = new LookupCacheEntryResponse$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 },
|
||||
{ name: "DeleteCacheEntry", options: {}, I: exports.DeleteCacheEntryRequest, O: exports.DeleteCacheEntryResponse },
|
||||
{ name: "ListCacheEntries", options: {}, I: exports.ListCacheEntriesRequest, O: exports.ListCacheEntriesResponse },
|
||||
{ name: "LookupCacheEntry", options: {}, I: exports.LookupCacheEntryRequest, O: exports.LookupCacheEntryResponse }
|
||||
{ name: "GetCacheEntryDownloadURL", options: {}, I: exports.GetCacheEntryDownloadURLRequest, O: exports.GetCacheEntryDownloadURLResponse }
|
||||
]);
|
||||
//# sourceMappingURL=cache.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 564:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
/***/ 1486:
|
||||
/***/ ((__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.createCacheServiceServer = exports.CacheServiceMethodList = exports.CacheServiceMethod = exports.CacheServiceClientProtobuf = exports.CacheServiceClientJSON = void 0;
|
||||
const twirp_ts_1 = __nccwpck_require__(430);
|
||||
exports.CacheServiceClientProtobuf = exports.CacheServiceClientJSON = void 0;
|
||||
const cache_1 = __nccwpck_require__(3156);
|
||||
class CacheServiceClientJSON {
|
||||
constructor(rpc) {
|
||||
@ -1362,9 +875,6 @@ class CacheServiceClientJSON {
|
||||
this.CreateCacheEntry.bind(this);
|
||||
this.FinalizeCacheEntryUpload.bind(this);
|
||||
this.GetCacheEntryDownloadURL.bind(this);
|
||||
this.DeleteCacheEntry.bind(this);
|
||||
this.ListCacheEntries.bind(this);
|
||||
this.LookupCacheEntry.bind(this);
|
||||
}
|
||||
CreateCacheEntry(request) {
|
||||
const data = cache_1.CreateCacheEntryRequest.toJson(request, {
|
||||
@ -1396,36 +906,6 @@ class CacheServiceClientJSON {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
DeleteCacheEntry(request) {
|
||||
const data = cache_1.DeleteCacheEntryRequest.toJson(request, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
});
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "DeleteCacheEntry", "application/json", data);
|
||||
return promise.then((data) => cache_1.DeleteCacheEntryResponse.fromJson(data, {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
ListCacheEntries(request) {
|
||||
const data = cache_1.ListCacheEntriesRequest.toJson(request, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
});
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "ListCacheEntries", "application/json", data);
|
||||
return promise.then((data) => cache_1.ListCacheEntriesResponse.fromJson(data, {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
LookupCacheEntry(request) {
|
||||
const data = cache_1.LookupCacheEntryRequest.toJson(request, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
});
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "LookupCacheEntry", "application/json", data);
|
||||
return promise.then((data) => cache_1.LookupCacheEntryResponse.fromJson(data, {
|
||||
ignoreUnknownFields: true,
|
||||
}));
|
||||
}
|
||||
}
|
||||
exports.CacheServiceClientJSON = CacheServiceClientJSON;
|
||||
class CacheServiceClientProtobuf {
|
||||
@ -1434,9 +914,6 @@ class CacheServiceClientProtobuf {
|
||||
this.CreateCacheEntry.bind(this);
|
||||
this.FinalizeCacheEntryUpload.bind(this);
|
||||
this.GetCacheEntryDownloadURL.bind(this);
|
||||
this.DeleteCacheEntry.bind(this);
|
||||
this.ListCacheEntries.bind(this);
|
||||
this.LookupCacheEntry.bind(this);
|
||||
}
|
||||
CreateCacheEntry(request) {
|
||||
const data = cache_1.CreateCacheEntryRequest.toBinary(request);
|
||||
@ -1453,610 +930,9 @@ class CacheServiceClientProtobuf {
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "GetCacheEntryDownloadURL", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.GetCacheEntryDownloadURLResponse.fromBinary(data));
|
||||
}
|
||||
DeleteCacheEntry(request) {
|
||||
const data = cache_1.DeleteCacheEntryRequest.toBinary(request);
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "DeleteCacheEntry", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.DeleteCacheEntryResponse.fromBinary(data));
|
||||
}
|
||||
ListCacheEntries(request) {
|
||||
const data = cache_1.ListCacheEntriesRequest.toBinary(request);
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "ListCacheEntries", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.ListCacheEntriesResponse.fromBinary(data));
|
||||
}
|
||||
LookupCacheEntry(request) {
|
||||
const data = cache_1.LookupCacheEntryRequest.toBinary(request);
|
||||
const promise = this.rpc.request("github.actions.results.api.v1.CacheService", "LookupCacheEntry", "application/protobuf", data);
|
||||
return promise.then((data) => cache_1.LookupCacheEntryResponse.fromBinary(data));
|
||||
}
|
||||
}
|
||||
exports.CacheServiceClientProtobuf = CacheServiceClientProtobuf;
|
||||
var CacheServiceMethod;
|
||||
(function (CacheServiceMethod) {
|
||||
CacheServiceMethod["CreateCacheEntry"] = "CreateCacheEntry";
|
||||
CacheServiceMethod["FinalizeCacheEntryUpload"] = "FinalizeCacheEntryUpload";
|
||||
CacheServiceMethod["GetCacheEntryDownloadURL"] = "GetCacheEntryDownloadURL";
|
||||
CacheServiceMethod["DeleteCacheEntry"] = "DeleteCacheEntry";
|
||||
CacheServiceMethod["ListCacheEntries"] = "ListCacheEntries";
|
||||
CacheServiceMethod["LookupCacheEntry"] = "LookupCacheEntry";
|
||||
})(CacheServiceMethod || (exports.CacheServiceMethod = CacheServiceMethod = {}));
|
||||
exports.CacheServiceMethodList = [
|
||||
CacheServiceMethod.CreateCacheEntry,
|
||||
CacheServiceMethod.FinalizeCacheEntryUpload,
|
||||
CacheServiceMethod.GetCacheEntryDownloadURL,
|
||||
CacheServiceMethod.DeleteCacheEntry,
|
||||
CacheServiceMethod.ListCacheEntries,
|
||||
CacheServiceMethod.LookupCacheEntry,
|
||||
];
|
||||
function createCacheServiceServer(service) {
|
||||
return new twirp_ts_1.TwirpServer({
|
||||
service,
|
||||
packageName: "github.actions.results.api.v1",
|
||||
serviceName: "CacheService",
|
||||
methodList: exports.CacheServiceMethodList,
|
||||
matchRoute: matchCacheServiceRoute,
|
||||
});
|
||||
}
|
||||
exports.createCacheServiceServer = createCacheServiceServer;
|
||||
function matchCacheServiceRoute(method, events) {
|
||||
switch (method) {
|
||||
case "CreateCacheEntry":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "CreateCacheEntry" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceCreateCacheEntryRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "FinalizeCacheEntryUpload":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "FinalizeCacheEntryUpload" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceFinalizeCacheEntryUploadRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "GetCacheEntryDownloadURL":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "GetCacheEntryDownloadURL" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceGetCacheEntryDownloadURLRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "DeleteCacheEntry":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "DeleteCacheEntry" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceDeleteCacheEntryRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "ListCacheEntries":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "ListCacheEntries" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceListCacheEntriesRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
case "LookupCacheEntry":
|
||||
return (ctx, service, data, interceptors) => __awaiter(this, void 0, void 0, function* () {
|
||||
ctx = Object.assign(Object.assign({}, ctx), { methodName: "LookupCacheEntry" });
|
||||
yield events.onMatch(ctx);
|
||||
return handleCacheServiceLookupCacheEntryRequest(ctx, service, data, interceptors);
|
||||
});
|
||||
default:
|
||||
events.onNotFound();
|
||||
const msg = `no handler found`;
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceCreateCacheEntryRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceCreateCacheEntryJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceCreateCacheEntryProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceFinalizeCacheEntryUploadRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceFinalizeCacheEntryUploadJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceFinalizeCacheEntryUploadProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceGetCacheEntryDownloadURLRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceGetCacheEntryDownloadURLJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceGetCacheEntryDownloadURLProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceDeleteCacheEntryRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceDeleteCacheEntryJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceDeleteCacheEntryProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceListCacheEntriesRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceListCacheEntriesJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceListCacheEntriesProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceLookupCacheEntryRequest(ctx, service, data, interceptors) {
|
||||
switch (ctx.contentType) {
|
||||
case twirp_ts_1.TwirpContentType.JSON:
|
||||
return handleCacheServiceLookupCacheEntryJSON(ctx, service, data, interceptors);
|
||||
case twirp_ts_1.TwirpContentType.Protobuf:
|
||||
return handleCacheServiceLookupCacheEntryProtobuf(ctx, service, data, interceptors);
|
||||
default:
|
||||
const msg = "unexpected Content-Type";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.BadRoute, msg);
|
||||
}
|
||||
}
|
||||
function handleCacheServiceCreateCacheEntryJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.CreateCacheEntryRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.CreateCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.CreateCacheEntry(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.CreateCacheEntryResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceFinalizeCacheEntryUploadJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.FinalizeCacheEntryUploadRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.FinalizeCacheEntryUpload(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.FinalizeCacheEntryUpload(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.FinalizeCacheEntryUploadResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceGetCacheEntryDownloadURLJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.GetCacheEntryDownloadURLRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.GetCacheEntryDownloadURL(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.GetCacheEntryDownloadURL(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.GetCacheEntryDownloadURLResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceDeleteCacheEntryJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.DeleteCacheEntryRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.DeleteCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.DeleteCacheEntry(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.DeleteCacheEntryResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceListCacheEntriesJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.ListCacheEntriesRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.ListCacheEntries(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.ListCacheEntries(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.ListCacheEntriesResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceLookupCacheEntryJSON(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
const body = JSON.parse(data.toString() || "{}");
|
||||
request = cache_1.LookupCacheEntryRequest.fromJson(body, {
|
||||
ignoreUnknownFields: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.LookupCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.LookupCacheEntry(ctx, request);
|
||||
}
|
||||
return JSON.stringify(cache_1.LookupCacheEntryResponse.toJson(response, {
|
||||
useProtoFieldName: true,
|
||||
emitDefaultValues: false,
|
||||
}));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceCreateCacheEntryProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.CreateCacheEntryRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.CreateCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.CreateCacheEntry(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.CreateCacheEntryResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceFinalizeCacheEntryUploadProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.FinalizeCacheEntryUploadRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.FinalizeCacheEntryUpload(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.FinalizeCacheEntryUpload(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.FinalizeCacheEntryUploadResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceGetCacheEntryDownloadURLProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.GetCacheEntryDownloadURLRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.GetCacheEntryDownloadURL(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.GetCacheEntryDownloadURL(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.GetCacheEntryDownloadURLResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceDeleteCacheEntryProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.DeleteCacheEntryRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.DeleteCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.DeleteCacheEntry(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.DeleteCacheEntryResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceListCacheEntriesProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.ListCacheEntriesRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.ListCacheEntries(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.ListCacheEntries(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.ListCacheEntriesResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
function handleCacheServiceLookupCacheEntryProtobuf(ctx, service, data, interceptors) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let request;
|
||||
let response;
|
||||
try {
|
||||
request = cache_1.LookupCacheEntryRequest.fromBinary(data);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error) {
|
||||
const msg = "the protobuf request could not be decoded";
|
||||
throw new twirp_ts_1.TwirpError(twirp_ts_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
if (interceptors && interceptors.length > 0) {
|
||||
const interceptor = (0, twirp_ts_1.chainInterceptors)(...interceptors);
|
||||
response = yield interceptor(ctx, request, (ctx, inputReq) => {
|
||||
return service.LookupCacheEntry(ctx, inputReq);
|
||||
});
|
||||
}
|
||||
else {
|
||||
response = yield service.LookupCacheEntry(ctx, request);
|
||||
}
|
||||
return Buffer.from(cache_1.LookupCacheEntryResponse.toBinary(response));
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=cache.twirp.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5893:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.CacheEntry = void 0;
|
||||
const runtime_1 = __nccwpck_require__(8886);
|
||||
const runtime_2 = __nccwpck_require__(8886);
|
||||
const runtime_3 = __nccwpck_require__(8886);
|
||||
const runtime_4 = __nccwpck_require__(8886);
|
||||
const runtime_5 = __nccwpck_require__(8886);
|
||||
const timestamp_1 = __nccwpck_require__(8200);
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class CacheEntry$Type extends runtime_5.MessageType {
|
||||
constructor() {
|
||||
super("github.actions.results.entities.v1.CacheEntry", [
|
||||
{ no: 1, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 2, name: "hash", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 3, name: "size_bytes", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
|
||||
{ no: 4, name: "scope", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 5, name: "version", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 6, name: "created_at", kind: "message", T: () => timestamp_1.Timestamp },
|
||||
{ no: 7, name: "last_accessed_at", kind: "message", T: () => timestamp_1.Timestamp },
|
||||
{ no: 8, name: "expires_at", kind: "message", T: () => timestamp_1.Timestamp }
|
||||
]);
|
||||
}
|
||||
create(value) {
|
||||
const message = { key: "", hash: "", sizeBytes: "0", scope: "", 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 /* string key */ 1:
|
||||
message.key = reader.string();
|
||||
break;
|
||||
case /* string hash */ 2:
|
||||
message.hash = reader.string();
|
||||
break;
|
||||
case /* int64 size_bytes */ 3:
|
||||
message.sizeBytes = reader.int64().toString();
|
||||
break;
|
||||
case /* string scope */ 4:
|
||||
message.scope = reader.string();
|
||||
break;
|
||||
case /* string version */ 5:
|
||||
message.version = reader.string();
|
||||
break;
|
||||
case /* google.protobuf.Timestamp created_at */ 6:
|
||||
message.createdAt = timestamp_1.Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.createdAt);
|
||||
break;
|
||||
case /* google.protobuf.Timestamp last_accessed_at */ 7:
|
||||
message.lastAccessedAt = timestamp_1.Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.lastAccessedAt);
|
||||
break;
|
||||
case /* google.protobuf.Timestamp expires_at */ 8:
|
||||
message.expiresAt = timestamp_1.Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.expiresAt);
|
||||
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 key = 1; */
|
||||
if (message.key !== "")
|
||||
writer.tag(1, runtime_1.WireType.LengthDelimited).string(message.key);
|
||||
/* string hash = 2; */
|
||||
if (message.hash !== "")
|
||||
writer.tag(2, runtime_1.WireType.LengthDelimited).string(message.hash);
|
||||
/* int64 size_bytes = 3; */
|
||||
if (message.sizeBytes !== "0")
|
||||
writer.tag(3, runtime_1.WireType.Varint).int64(message.sizeBytes);
|
||||
/* string scope = 4; */
|
||||
if (message.scope !== "")
|
||||
writer.tag(4, runtime_1.WireType.LengthDelimited).string(message.scope);
|
||||
/* string version = 5; */
|
||||
if (message.version !== "")
|
||||
writer.tag(5, runtime_1.WireType.LengthDelimited).string(message.version);
|
||||
/* google.protobuf.Timestamp created_at = 6; */
|
||||
if (message.createdAt)
|
||||
timestamp_1.Timestamp.internalBinaryWrite(message.createdAt, writer.tag(6, runtime_1.WireType.LengthDelimited).fork(), options).join();
|
||||
/* google.protobuf.Timestamp last_accessed_at = 7; */
|
||||
if (message.lastAccessedAt)
|
||||
timestamp_1.Timestamp.internalBinaryWrite(message.lastAccessedAt, writer.tag(7, runtime_1.WireType.LengthDelimited).fork(), options).join();
|
||||
/* google.protobuf.Timestamp expires_at = 8; */
|
||||
if (message.expiresAt)
|
||||
timestamp_1.Timestamp.internalBinaryWrite(message.expiresAt, writer.tag(8, 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.CacheEntry
|
||||
*/
|
||||
exports.CacheEntry = new CacheEntry$Type();
|
||||
//# sourceMappingURL=cacheentry.js.map
|
||||
//# sourceMappingURL=cache.twirp-client.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
@ -3327,7 +2203,7 @@ const config_1 = __nccwpck_require__(7606);
|
||||
const cacheUtils_1 = __nccwpck_require__(8299);
|
||||
const auth_1 = __nccwpck_require__(4552);
|
||||
const http_client_1 = __nccwpck_require__(4844);
|
||||
const cache_twirp_1 = __nccwpck_require__(564);
|
||||
const cache_twirp_client_1 = __nccwpck_require__(1486);
|
||||
/**
|
||||
* This class is a wrapper around the CacheServiceClientJSON class generated by Twirp.
|
||||
*
|
||||
@ -3464,7 +2340,7 @@ class CacheServiceClient {
|
||||
}
|
||||
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_1.CacheServiceClientJSON(client);
|
||||
return new cache_twirp_client_1.CacheServiceClientJSON(client);
|
||||
}
|
||||
exports.internalCacheTwirpClient = internalCacheTwirpClient;
|
||||
//# sourceMappingURL=cacheTwirpClient.js.map
|
||||
@ -52391,599 +51267,6 @@ DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
|
||||
};
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5129:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
function _process (v, mod) {
|
||||
var i
|
||||
var r
|
||||
|
||||
if (typeof mod === 'function') {
|
||||
r = mod(v)
|
||||
if (r !== undefined) {
|
||||
v = r
|
||||
}
|
||||
} else if (Array.isArray(mod)) {
|
||||
for (i = 0; i < mod.length; i++) {
|
||||
r = mod[i](v)
|
||||
if (r !== undefined) {
|
||||
v = r
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
function parseKey (key, val) {
|
||||
// detect negative index notation
|
||||
if (key[0] === '-' && Array.isArray(val) && /^-\d+$/.test(key)) {
|
||||
return val.length + parseInt(key, 10)
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
function isIndex (k) {
|
||||
return /^\d+$/.test(k)
|
||||
}
|
||||
|
||||
function isObject (val) {
|
||||
return Object.prototype.toString.call(val) === '[object Object]'
|
||||
}
|
||||
|
||||
function isArrayOrObject (val) {
|
||||
return Object(val) === val
|
||||
}
|
||||
|
||||
function isEmptyObject (val) {
|
||||
return Object.keys(val).length === 0
|
||||
}
|
||||
|
||||
var blacklist = ['__proto__', 'prototype', 'constructor']
|
||||
var blacklistFilter = function (part) { return blacklist.indexOf(part) === -1 }
|
||||
|
||||
function parsePath (path, sep) {
|
||||
if (path.indexOf('[') >= 0) {
|
||||
path = path.replace(/\[/g, sep).replace(/]/g, '')
|
||||
}
|
||||
|
||||
var parts = path.split(sep)
|
||||
|
||||
var check = parts.filter(blacklistFilter)
|
||||
|
||||
if (check.length !== parts.length) {
|
||||
throw Error('Refusing to update blacklisted property ' + path)
|
||||
}
|
||||
|
||||
return parts
|
||||
}
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
|
||||
function DotObject (separator, override, useArray, useBrackets) {
|
||||
if (!(this instanceof DotObject)) {
|
||||
return new DotObject(separator, override, useArray, useBrackets)
|
||||
}
|
||||
|
||||
if (typeof override === 'undefined') override = false
|
||||
if (typeof useArray === 'undefined') useArray = true
|
||||
if (typeof useBrackets === 'undefined') useBrackets = true
|
||||
this.separator = separator || '.'
|
||||
this.override = override
|
||||
this.useArray = useArray
|
||||
this.useBrackets = useBrackets
|
||||
this.keepArray = false
|
||||
|
||||
// contains touched arrays
|
||||
this.cleanup = []
|
||||
}
|
||||
|
||||
var dotDefault = new DotObject('.', false, true, true)
|
||||
function wrap (method) {
|
||||
return function () {
|
||||
return dotDefault[method].apply(dotDefault, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
DotObject.prototype._fill = function (a, obj, v, mod) {
|
||||
var k = a.shift()
|
||||
|
||||
if (a.length > 0) {
|
||||
obj[k] = obj[k] || (this.useArray && isIndex(a[0]) ? [] : {})
|
||||
|
||||
if (!isArrayOrObject(obj[k])) {
|
||||
if (this.override) {
|
||||
obj[k] = {}
|
||||
} else {
|
||||
if (!(isArrayOrObject(v) && isEmptyObject(v))) {
|
||||
throw new Error(
|
||||
'Trying to redefine `' + k + '` which is a ' + typeof obj[k]
|
||||
)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this._fill(a, obj[k], v, mod)
|
||||
} else {
|
||||
if (!this.override && isArrayOrObject(obj[k]) && !isEmptyObject(obj[k])) {
|
||||
if (!(isArrayOrObject(v) && isEmptyObject(v))) {
|
||||
throw new Error("Trying to redefine non-empty obj['" + k + "']")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
obj[k] = _process(v, mod)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts an object with dotted-key/value pairs to it's expanded version
|
||||
*
|
||||
* Optionally transformed by a set of modifiers.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* var row = {
|
||||
* 'nr': 200,
|
||||
* 'doc.name': ' My Document '
|
||||
* }
|
||||
*
|
||||
* var mods = {
|
||||
* 'doc.name': [_s.trim, _s.underscored]
|
||||
* }
|
||||
*
|
||||
* dot.object(row, mods)
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {Object} mods
|
||||
*/
|
||||
DotObject.prototype.object = function (obj, mods) {
|
||||
var self = this
|
||||
|
||||
Object.keys(obj).forEach(function (k) {
|
||||
var mod = mods === undefined ? null : mods[k]
|
||||
// normalize array notation.
|
||||
var ok = parsePath(k, self.separator).join(self.separator)
|
||||
|
||||
if (ok.indexOf(self.separator) !== -1) {
|
||||
self._fill(ok.split(self.separator), obj, obj[k], mod)
|
||||
delete obj[k]
|
||||
} else {
|
||||
obj[k] = _process(obj[k], mod)
|
||||
}
|
||||
})
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} path dotted path
|
||||
* @param {String} v value to be set
|
||||
* @param {Object} obj object to be modified
|
||||
* @param {Function|Array} mod optional modifier
|
||||
*/
|
||||
DotObject.prototype.str = function (path, v, obj, mod) {
|
||||
var ok = parsePath(path, this.separator).join(this.separator)
|
||||
|
||||
if (path.indexOf(this.separator) !== -1) {
|
||||
this._fill(ok.split(this.separator), obj, v, mod)
|
||||
} else {
|
||||
obj[path] = _process(v, mod)
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Pick a value from an object using dot notation.
|
||||
*
|
||||
* Optionally remove the value
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} remove
|
||||
*/
|
||||
DotObject.prototype.pick = function (path, obj, remove, reindexArray) {
|
||||
var i
|
||||
var keys
|
||||
var val
|
||||
var key
|
||||
var cp
|
||||
|
||||
keys = parsePath(path, this.separator)
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
key = parseKey(keys[i], obj)
|
||||
if (obj && typeof obj === 'object' && key in obj) {
|
||||
if (i === keys.length - 1) {
|
||||
if (remove) {
|
||||
val = obj[key]
|
||||
if (reindexArray && Array.isArray(obj)) {
|
||||
obj.splice(key, 1)
|
||||
} else {
|
||||
delete obj[key]
|
||||
}
|
||||
if (Array.isArray(obj)) {
|
||||
cp = keys.slice(0, -1).join('.')
|
||||
if (this.cleanup.indexOf(cp) === -1) {
|
||||
this.cleanup.push(cp)
|
||||
}
|
||||
}
|
||||
return val
|
||||
} else {
|
||||
return obj[key]
|
||||
}
|
||||
} else {
|
||||
obj = obj[key]
|
||||
}
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
if (remove && Array.isArray(obj)) {
|
||||
obj = obj.filter(function (n) {
|
||||
return n !== undefined
|
||||
})
|
||||
}
|
||||
return obj
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Delete value from an object using dot notation.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Object} obj
|
||||
* @return {any} The removed value
|
||||
*/
|
||||
DotObject.prototype.delete = function (path, obj) {
|
||||
return this.remove(path, obj, true)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Remove value from an object using dot notation.
|
||||
*
|
||||
* Will remove multiple items if path is an array.
|
||||
* In this case array indexes will be retained until all
|
||||
* removals have been processed.
|
||||
*
|
||||
* Use dot.delete() to automatically re-index arrays.
|
||||
*
|
||||
* @param {String|Array<String>} path
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} reindexArray
|
||||
* @return {any} The removed value
|
||||
*/
|
||||
DotObject.prototype.remove = function (path, obj, reindexArray) {
|
||||
var i
|
||||
|
||||
this.cleanup = []
|
||||
if (Array.isArray(path)) {
|
||||
for (i = 0; i < path.length; i++) {
|
||||
this.pick(path[i], obj, true, reindexArray)
|
||||
}
|
||||
if (!reindexArray) {
|
||||
this._cleanup(obj)
|
||||
}
|
||||
return obj
|
||||
} else {
|
||||
return this.pick(path, obj, true, reindexArray)
|
||||
}
|
||||
}
|
||||
|
||||
DotObject.prototype._cleanup = function (obj) {
|
||||
var ret
|
||||
var i
|
||||
var keys
|
||||
var root
|
||||
if (this.cleanup.length) {
|
||||
for (i = 0; i < this.cleanup.length; i++) {
|
||||
keys = this.cleanup[i].split('.')
|
||||
root = keys.splice(0, -1).join('.')
|
||||
ret = root ? this.pick(root, obj) : obj
|
||||
ret = ret[keys[0]].filter(function (v) {
|
||||
return v !== undefined
|
||||
})
|
||||
this.set(this.cleanup[i], ret, obj)
|
||||
}
|
||||
this.cleanup = []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias method for `dot.remove`
|
||||
*
|
||||
* Note: this is not an alias for dot.delete()
|
||||
*
|
||||
* @param {String|Array<String>} path
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} reindexArray
|
||||
* @return {any} The removed value
|
||||
*/
|
||||
DotObject.prototype.del = DotObject.prototype.remove
|
||||
|
||||
/**
|
||||
*
|
||||
* Move a property from one place to the other.
|
||||
*
|
||||
* If the source path does not exist (undefined)
|
||||
* the target property will not be set.
|
||||
*
|
||||
* @param {String} source
|
||||
* @param {String} target
|
||||
* @param {Object} obj
|
||||
* @param {Function|Array} mods
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.move = function (source, target, obj, mods, merge) {
|
||||
if (typeof mods === 'function' || Array.isArray(mods)) {
|
||||
this.set(target, _process(this.pick(source, obj, true), mods), obj, merge)
|
||||
} else {
|
||||
merge = mods
|
||||
this.set(target, this.pick(source, obj, true), obj, merge)
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Transfer a property from one object to another object.
|
||||
*
|
||||
* If the source path does not exist (undefined)
|
||||
* the property on the other object will not be set.
|
||||
*
|
||||
* @param {String} source
|
||||
* @param {String} target
|
||||
* @param {Object} obj1
|
||||
* @param {Object} obj2
|
||||
* @param {Function|Array} mods
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.transfer = function (
|
||||
source,
|
||||
target,
|
||||
obj1,
|
||||
obj2,
|
||||
mods,
|
||||
merge
|
||||
) {
|
||||
if (typeof mods === 'function' || Array.isArray(mods)) {
|
||||
this.set(
|
||||
target,
|
||||
_process(this.pick(source, obj1, true), mods),
|
||||
obj2,
|
||||
merge
|
||||
)
|
||||
} else {
|
||||
merge = mods
|
||||
this.set(target, this.pick(source, obj1, true), obj2, merge)
|
||||
}
|
||||
|
||||
return obj2
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Copy a property from one object to another object.
|
||||
*
|
||||
* If the source path does not exist (undefined)
|
||||
* the property on the other object will not be set.
|
||||
*
|
||||
* @param {String} source
|
||||
* @param {String} target
|
||||
* @param {Object} obj1
|
||||
* @param {Object} obj2
|
||||
* @param {Function|Array} mods
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.copy = function (source, target, obj1, obj2, mods, merge) {
|
||||
if (typeof mods === 'function' || Array.isArray(mods)) {
|
||||
this.set(
|
||||
target,
|
||||
_process(
|
||||
// clone what is picked
|
||||
JSON.parse(JSON.stringify(this.pick(source, obj1, false))),
|
||||
mods
|
||||
),
|
||||
obj2,
|
||||
merge
|
||||
)
|
||||
} else {
|
||||
merge = mods
|
||||
this.set(target, this.pick(source, obj1, false), obj2, merge)
|
||||
}
|
||||
|
||||
return obj2
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Set a property on an object using dot notation.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {any} val
|
||||
* @param {Object} obj
|
||||
* @param {Boolean} merge
|
||||
*/
|
||||
DotObject.prototype.set = function (path, val, obj, merge) {
|
||||
var i
|
||||
var k
|
||||
var keys
|
||||
var key
|
||||
|
||||
// Do not operate if the value is undefined.
|
||||
if (typeof val === 'undefined') {
|
||||
return obj
|
||||
}
|
||||
keys = parsePath(path, this.separator)
|
||||
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
key = keys[i]
|
||||
if (i === keys.length - 1) {
|
||||
if (merge && isObject(val) && isObject(obj[key])) {
|
||||
for (k in val) {
|
||||
if (hasOwnProperty.call(val, k)) {
|
||||
obj[key][k] = val[k]
|
||||
}
|
||||
}
|
||||
} else if (merge && Array.isArray(obj[key]) && Array.isArray(val)) {
|
||||
for (var j = 0; j < val.length; j++) {
|
||||
obj[keys[i]].push(val[j])
|
||||
}
|
||||
} else {
|
||||
obj[key] = val
|
||||
}
|
||||
} else if (
|
||||
// force the value to be an object
|
||||
!hasOwnProperty.call(obj, key) ||
|
||||
(!isObject(obj[key]) && !Array.isArray(obj[key]))
|
||||
) {
|
||||
// initialize as array if next key is numeric
|
||||
if (/^\d+$/.test(keys[i + 1])) {
|
||||
obj[key] = []
|
||||
} else {
|
||||
obj[key] = {}
|
||||
}
|
||||
}
|
||||
obj = obj[key]
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Transform an object
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* var obj = {
|
||||
* "id": 1,
|
||||
* "some": {
|
||||
* "thing": "else"
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* var transform = {
|
||||
* "id": "nr",
|
||||
* "some.thing": "name"
|
||||
* }
|
||||
*
|
||||
* var tgt = dot.transform(transform, obj)
|
||||
*
|
||||
* @param {Object} recipe Transform recipe
|
||||
* @param {Object} obj Object to be transformed
|
||||
* @param {Array} mods modifiers for the target
|
||||
*/
|
||||
DotObject.prototype.transform = function (recipe, obj, tgt) {
|
||||
obj = obj || {}
|
||||
tgt = tgt || {}
|
||||
Object.keys(recipe).forEach(
|
||||
function (key) {
|
||||
this.set(recipe[key], this.pick(key, obj), tgt)
|
||||
}.bind(this)
|
||||
)
|
||||
return tgt
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convert object to dotted-key/value pair
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* var tgt = dot.dot(obj)
|
||||
*
|
||||
* or
|
||||
*
|
||||
* var tgt = {}
|
||||
* dot.dot(obj, tgt)
|
||||
*
|
||||
* @param {Object} obj source object
|
||||
* @param {Object} tgt target object
|
||||
* @param {Array} path path array (internal)
|
||||
*/
|
||||
DotObject.prototype.dot = function (obj, tgt, path) {
|
||||
tgt = tgt || {}
|
||||
path = path || []
|
||||
var isArray = Array.isArray(obj)
|
||||
|
||||
Object.keys(obj).forEach(
|
||||
function (key) {
|
||||
var index = isArray && this.useBrackets ? '[' + key + ']' : key
|
||||
if (
|
||||
isArrayOrObject(obj[key]) &&
|
||||
((isObject(obj[key]) && !isEmptyObject(obj[key])) ||
|
||||
(Array.isArray(obj[key]) && !this.keepArray && obj[key].length !== 0))
|
||||
) {
|
||||
if (isArray && this.useBrackets) {
|
||||
var previousKey = path[path.length - 1] || ''
|
||||
return this.dot(
|
||||
obj[key],
|
||||
tgt,
|
||||
path.slice(0, -1).concat(previousKey + index)
|
||||
)
|
||||
} else {
|
||||
return this.dot(obj[key], tgt, path.concat(index))
|
||||
}
|
||||
} else {
|
||||
if (isArray && this.useBrackets) {
|
||||
tgt[path.join(this.separator).concat('[' + key + ']')] = obj[key]
|
||||
} else {
|
||||
tgt[path.concat(index).join(this.separator)] = obj[key]
|
||||
}
|
||||
}
|
||||
}.bind(this)
|
||||
)
|
||||
return tgt
|
||||
}
|
||||
|
||||
DotObject.pick = wrap('pick')
|
||||
DotObject.move = wrap('move')
|
||||
DotObject.transfer = wrap('transfer')
|
||||
DotObject.transform = wrap('transform')
|
||||
DotObject.copy = wrap('copy')
|
||||
DotObject.object = wrap('object')
|
||||
DotObject.str = wrap('str')
|
||||
DotObject.set = wrap('set')
|
||||
DotObject.delete = wrap('delete')
|
||||
DotObject.del = DotObject.remove = wrap('remove')
|
||||
DotObject.dot = wrap('dot');
|
||||
['override', 'overwrite'].forEach(function (prop) {
|
||||
Object.defineProperty(DotObject, prop, {
|
||||
get: function () {
|
||||
return dotDefault.override
|
||||
},
|
||||
set: function (val) {
|
||||
dotDefault.override = !!val
|
||||
}
|
||||
})
|
||||
});
|
||||
['useArray', 'keepArray', 'useBrackets'].forEach(function (prop) {
|
||||
Object.defineProperty(DotObject, prop, {
|
||||
get: function () {
|
||||
return dotDefault[prop]
|
||||
},
|
||||
set: function (val) {
|
||||
dotDefault[prop] = val
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
DotObject._process = _process
|
||||
|
||||
module.exports = DotObject
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9829:
|
||||
@ -61521,1152 +59804,6 @@ if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) {
|
||||
exports.debug = debug; // for test
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5497:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3315:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.isValidErrorCode = exports.httpStatusFromErrorCode = exports.TwirpErrorCode = exports.BadRouteError = exports.InternalServerErrorWith = exports.InternalServerError = exports.RequiredArgumentError = exports.InvalidArgumentError = exports.NotFoundError = exports.TwirpError = void 0;
|
||||
/**
|
||||
* Represents a twirp error
|
||||
*/
|
||||
class TwirpError extends Error {
|
||||
constructor(code, msg) {
|
||||
super(msg);
|
||||
this.code = TwirpErrorCode.Internal;
|
||||
this.meta = {};
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
Object.setPrototypeOf(this, TwirpError.prototype);
|
||||
}
|
||||
/**
|
||||
* Adds a metadata kv to the error
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
withMeta(key, value) {
|
||||
this.meta[key] = value;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Returns a single metadata value
|
||||
* return "" if not found
|
||||
* @param key
|
||||
*/
|
||||
getMeta(key) {
|
||||
return this.meta[key] || "";
|
||||
}
|
||||
/**
|
||||
* Add the original error cause
|
||||
* @param err
|
||||
* @param addMeta
|
||||
*/
|
||||
withCause(err, addMeta = false) {
|
||||
this._originalCause = err;
|
||||
if (addMeta) {
|
||||
this.withMeta("cause", err.message);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
cause() {
|
||||
return this._originalCause;
|
||||
}
|
||||
/**
|
||||
* Returns the error representation to JSON
|
||||
*/
|
||||
toJSON() {
|
||||
try {
|
||||
return JSON.stringify({
|
||||
code: this.code,
|
||||
msg: this.msg,
|
||||
meta: this.meta,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
return `{"code": "internal", "msg": "There was an error but it could not be serialized into JSON"}`;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create a twirp error from an object
|
||||
* @param obj
|
||||
*/
|
||||
static fromObject(obj) {
|
||||
const code = obj["code"] || TwirpErrorCode.Unknown;
|
||||
const msg = obj["msg"] || "unknown";
|
||||
const error = new TwirpError(code, msg);
|
||||
if (obj["meta"]) {
|
||||
Object.keys(obj["meta"]).forEach((key) => {
|
||||
error.withMeta(key, obj["meta"][key]);
|
||||
});
|
||||
}
|
||||
return error;
|
||||
}
|
||||
}
|
||||
exports.TwirpError = TwirpError;
|
||||
/**
|
||||
* NotFoundError constructor for the common NotFound error.
|
||||
*/
|
||||
class NotFoundError extends TwirpError {
|
||||
constructor(msg) {
|
||||
super(TwirpErrorCode.NotFound, msg);
|
||||
}
|
||||
}
|
||||
exports.NotFoundError = NotFoundError;
|
||||
/**
|
||||
* InvalidArgumentError constructor for the common InvalidArgument error. Can be
|
||||
* used when an argument has invalid format, is a number out of range, is a bad
|
||||
* option, etc).
|
||||
*/
|
||||
class InvalidArgumentError extends TwirpError {
|
||||
constructor(argument, validationMsg) {
|
||||
super(TwirpErrorCode.InvalidArgument, argument + " " + validationMsg);
|
||||
this.withMeta("argument", argument);
|
||||
}
|
||||
}
|
||||
exports.InvalidArgumentError = InvalidArgumentError;
|
||||
/**
|
||||
* RequiredArgumentError is a more specific constructor for InvalidArgument
|
||||
* error. Should be used when the argument is required (expected to have a
|
||||
* non-zero value).
|
||||
*/
|
||||
class RequiredArgumentError extends InvalidArgumentError {
|
||||
constructor(argument) {
|
||||
super(argument, "is required");
|
||||
}
|
||||
}
|
||||
exports.RequiredArgumentError = RequiredArgumentError;
|
||||
/**
|
||||
* InternalError constructor for the common Internal error. Should be used to
|
||||
* specify that something bad or unexpected happened.
|
||||
*/
|
||||
class InternalServerError extends TwirpError {
|
||||
constructor(msg) {
|
||||
super(TwirpErrorCode.Internal, msg);
|
||||
}
|
||||
}
|
||||
exports.InternalServerError = InternalServerError;
|
||||
/**
|
||||
* InternalErrorWith makes an internal error, wrapping the original error and using it
|
||||
* for the error message, and with metadata "cause" with the original error type.
|
||||
* This function is used by Twirp services to wrap non-Twirp errors as internal errors.
|
||||
* The wrapped error can be extracted later with err.cause()
|
||||
*/
|
||||
class InternalServerErrorWith extends InternalServerError {
|
||||
constructor(err) {
|
||||
super(err.message);
|
||||
this.withMeta("cause", err.name);
|
||||
this.withCause(err);
|
||||
}
|
||||
}
|
||||
exports.InternalServerErrorWith = InternalServerErrorWith;
|
||||
/**
|
||||
* A standard BadRoute Error
|
||||
*/
|
||||
class BadRouteError extends TwirpError {
|
||||
constructor(msg, method, url) {
|
||||
super(TwirpErrorCode.BadRoute, msg);
|
||||
this.withMeta("twirp_invalid_route", method + " " + url);
|
||||
}
|
||||
}
|
||||
exports.BadRouteError = BadRouteError;
|
||||
var TwirpErrorCode;
|
||||
(function (TwirpErrorCode) {
|
||||
// Canceled indicates the operation was cancelled (typically by the caller).
|
||||
TwirpErrorCode["Canceled"] = "canceled";
|
||||
// Unknown error. For example when handling errors raised by APIs that do not
|
||||
// return enough error information.
|
||||
TwirpErrorCode["Unknown"] = "unknown";
|
||||
// InvalidArgument indicates client specified an invalid argument. It
|
||||
// indicates arguments that are problematic regardless of the state of the
|
||||
// system (i.e. a malformed file name, required argument, number out of range,
|
||||
// etc.).
|
||||
TwirpErrorCode["InvalidArgument"] = "invalid_argument";
|
||||
// Malformed indicates an error occurred while decoding the client's request.
|
||||
// This may mean that the message was encoded improperly, or that there is a
|
||||
// disagreement in message format between the client and server.
|
||||
TwirpErrorCode["Malformed"] = "malformed";
|
||||
// DeadlineExceeded means operation expired before completion. For operations
|
||||
// that change the state of the system, this error may be returned even if the
|
||||
// operation has completed successfully (timeout).
|
||||
TwirpErrorCode["DeadlineExceeded"] = "deadline_exceeded";
|
||||
// NotFound means some requested entity was not found.
|
||||
TwirpErrorCode["NotFound"] = "not_found";
|
||||
// BadRoute means that the requested URL path wasn't routable to a Twirp
|
||||
// service and method. This is returned by the generated server, and usually
|
||||
// shouldn't be returned by applications. Instead, applications should use
|
||||
// NotFound or Unimplemented.
|
||||
TwirpErrorCode["BadRoute"] = "bad_route";
|
||||
// AlreadyExists means an attempt to create an entity failed because one
|
||||
// already exists.
|
||||
TwirpErrorCode["AlreadyExists"] = "already_exists";
|
||||
// PermissionDenied indicates the caller does not have permission to execute
|
||||
// the specified operation. It must not be used if the caller cannot be
|
||||
// identified (Unauthenticated).
|
||||
TwirpErrorCode["PermissionDenied"] = "permission_denied";
|
||||
// Unauthenticated indicates the request does not have valid authentication
|
||||
// credentials for the operation.
|
||||
TwirpErrorCode["Unauthenticated"] = "unauthenticated";
|
||||
// ResourceExhausted indicates some resource has been exhausted, perhaps a
|
||||
// per-user quota, or perhaps the entire file system is out of space.
|
||||
TwirpErrorCode["ResourceExhausted"] = "resource_exhausted";
|
||||
// FailedPrecondition indicates operation was rejected because the system is
|
||||
// not in a state required for the operation's execution. For example, doing
|
||||
// an rmdir operation on a directory that is non-empty, or on a non-directory
|
||||
// object, or when having conflicting read-modify-write on the same resource.
|
||||
TwirpErrorCode["FailedPrecondition"] = "failed_precondition";
|
||||
// Aborted indicates the operation was aborted, typically due to a concurrency
|
||||
// issue like sequencer check failures, transaction aborts, etc.
|
||||
TwirpErrorCode["Aborted"] = "aborted";
|
||||
// OutOfRange means operation was attempted past the valid range. For example,
|
||||
// seeking or reading past end of a paginated collection.
|
||||
//
|
||||
// Unlike InvalidArgument, this error indicates a problem that may be fixed if
|
||||
// the system state changes (i.e. adding more items to the collection).
|
||||
//
|
||||
// There is a fair bit of overlap between FailedPrecondition and OutOfRange.
|
||||
// We recommend using OutOfRange (the more specific error) when it applies so
|
||||
// that callers who are iterating through a space can easily look for an
|
||||
// OutOfRange error to detect when they are done.
|
||||
TwirpErrorCode["OutOfRange"] = "out_of_range";
|
||||
// Unimplemented indicates operation is not implemented or not
|
||||
// supported/enabled in this service.
|
||||
TwirpErrorCode["Unimplemented"] = "unimplemented";
|
||||
// Internal errors. When some invariants expected by the underlying system
|
||||
// have been broken. In other words, something bad happened in the library or
|
||||
// backend service. Do not confuse with HTTP Internal Server Error; an
|
||||
// Internal error could also happen on the client code, i.e. when parsing a
|
||||
// server response.
|
||||
TwirpErrorCode["Internal"] = "internal";
|
||||
// Unavailable indicates the service is currently unavailable. This is a most
|
||||
// likely a transient condition and may be corrected by retrying with a
|
||||
// backoff.
|
||||
TwirpErrorCode["Unavailable"] = "unavailable";
|
||||
// DataLoss indicates unrecoverable data loss or corruption.
|
||||
TwirpErrorCode["DataLoss"] = "data_loss";
|
||||
})(TwirpErrorCode = exports.TwirpErrorCode || (exports.TwirpErrorCode = {}));
|
||||
// ServerHTTPStatusFromErrorCode maps a Twirp error type into a similar HTTP
|
||||
// response status. It is used by the Twirp server handler to set the HTTP
|
||||
// response status code. Returns 0 if the ErrorCode is invalid.
|
||||
function httpStatusFromErrorCode(code) {
|
||||
switch (code) {
|
||||
case TwirpErrorCode.Canceled:
|
||||
return 408; // RequestTimeout
|
||||
case TwirpErrorCode.Unknown:
|
||||
return 500; // Internal Server Error
|
||||
case TwirpErrorCode.InvalidArgument:
|
||||
return 400; // BadRequest
|
||||
case TwirpErrorCode.Malformed:
|
||||
return 400; // BadRequest
|
||||
case TwirpErrorCode.DeadlineExceeded:
|
||||
return 408; // RequestTimeout
|
||||
case TwirpErrorCode.NotFound:
|
||||
return 404; // Not Found
|
||||
case TwirpErrorCode.BadRoute:
|
||||
return 404; // Not Found
|
||||
case TwirpErrorCode.AlreadyExists:
|
||||
return 409; // Conflict
|
||||
case TwirpErrorCode.PermissionDenied:
|
||||
return 403; // Forbidden
|
||||
case TwirpErrorCode.Unauthenticated:
|
||||
return 401; // Unauthorized
|
||||
case TwirpErrorCode.ResourceExhausted:
|
||||
return 429; // Too Many Requests
|
||||
case TwirpErrorCode.FailedPrecondition:
|
||||
return 412; // Precondition Failed
|
||||
case TwirpErrorCode.Aborted:
|
||||
return 409; // Conflict
|
||||
case TwirpErrorCode.OutOfRange:
|
||||
return 400; // Bad Request
|
||||
case TwirpErrorCode.Unimplemented:
|
||||
return 501; // Not Implemented
|
||||
case TwirpErrorCode.Internal:
|
||||
return 500; // Internal Server Error
|
||||
case TwirpErrorCode.Unavailable:
|
||||
return 503; // Service Unavailable
|
||||
case TwirpErrorCode.DataLoss:
|
||||
return 500; // Internal Server Error
|
||||
default:
|
||||
return 0; // Invalid!
|
||||
}
|
||||
}
|
||||
exports.httpStatusFromErrorCode = httpStatusFromErrorCode;
|
||||
// IsValidErrorCode returns true if is one of the valid predefined constants.
|
||||
function isValidErrorCode(code) {
|
||||
return httpStatusFromErrorCode(code) != 0;
|
||||
}
|
||||
exports.isValidErrorCode = isValidErrorCode;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9636:
|
||||
/***/ (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;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (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 (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__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 __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Gateway = exports.Pattern = void 0;
|
||||
const querystring_1 = __nccwpck_require__(3480);
|
||||
const dotObject = __importStar(__nccwpck_require__(5129));
|
||||
const request_1 = __nccwpck_require__(9647);
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
const http_client_1 = __nccwpck_require__(5683);
|
||||
const server_1 = __nccwpck_require__(1035);
|
||||
var Pattern;
|
||||
(function (Pattern) {
|
||||
Pattern["POST"] = "post";
|
||||
Pattern["GET"] = "get";
|
||||
Pattern["PATCH"] = "patch";
|
||||
Pattern["PUT"] = "put";
|
||||
Pattern["DELETE"] = "delete";
|
||||
})(Pattern = exports.Pattern || (exports.Pattern = {}));
|
||||
/**
|
||||
* The Gateway proxies http requests to Twirp Compliant
|
||||
* handlers
|
||||
*/
|
||||
class Gateway {
|
||||
constructor(routes) {
|
||||
this.routes = routes;
|
||||
}
|
||||
/**
|
||||
* Middleware that rewrite the current request
|
||||
* to a Twirp compliant request
|
||||
*/
|
||||
twirpRewrite(prefix = "/twirp") {
|
||||
return (req, resp, next) => {
|
||||
this.rewrite(req, resp, prefix)
|
||||
.then(() => next())
|
||||
.catch((e) => {
|
||||
if (e instanceof errors_1.TwirpError) {
|
||||
if (e.code !== errors_1.TwirpErrorCode.NotFound) {
|
||||
server_1.writeError(resp, e);
|
||||
}
|
||||
else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Rewrite an incoming request to a Twirp compliant request
|
||||
* @param req
|
||||
* @param resp
|
||||
* @param prefix
|
||||
*/
|
||||
rewrite(req, resp, prefix = "/twirp") {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const [match, route] = this.matchRoute(req);
|
||||
const body = yield this.prepareTwirpBody(req, match, route);
|
||||
const twirpUrl = `${prefix}/${route.packageName}.${route.serviceName}/${route.methodName}`;
|
||||
req.url = twirpUrl;
|
||||
req.originalUrl = twirpUrl;
|
||||
req.method = "POST";
|
||||
req.headers["content-type"] = "application/json";
|
||||
req.rawBody = Buffer.from(JSON.stringify(body));
|
||||
if (route.responseBodyKey) {
|
||||
const endFn = resp.end.bind(resp);
|
||||
resp.end = function (chunk) {
|
||||
if (resp.statusCode === 200) {
|
||||
endFn(`{ "${route.responseBodyKey}": ${chunk} }`);
|
||||
}
|
||||
else {
|
||||
endFn(chunk);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Create a reverse proxy handler to
|
||||
* proxy http requests to Twirp Compliant handlers
|
||||
* @param httpClientOption
|
||||
*/
|
||||
reverseProxy(httpClientOption) {
|
||||
const client = http_client_1.NodeHttpRPC(httpClientOption);
|
||||
return (req, res) => __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const [match, route] = this.matchRoute(req);
|
||||
const body = yield this.prepareTwirpBody(req, match, route);
|
||||
const response = yield client.request(`${route.packageName}.${route.serviceName}`, route.methodName, "application/json", body);
|
||||
res.statusCode = 200;
|
||||
res.setHeader("content-type", "application/json");
|
||||
let jsonResponse;
|
||||
if (route.responseBodyKey) {
|
||||
jsonResponse = JSON.stringify({ [route.responseBodyKey]: response });
|
||||
}
|
||||
else {
|
||||
jsonResponse = JSON.stringify(response);
|
||||
}
|
||||
res.end(jsonResponse);
|
||||
}
|
||||
catch (e) {
|
||||
server_1.writeError(res, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Prepares twirp body requests using http.google.annotions
|
||||
* compliant spec
|
||||
*
|
||||
* @param req
|
||||
* @param match
|
||||
* @param route
|
||||
* @protected
|
||||
*/
|
||||
prepareTwirpBody(req, match, route) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const _a = match.params, { query_string } = _a, params = __rest(_a, ["query_string"]);
|
||||
let requestBody = Object.assign({}, params);
|
||||
if (query_string && route.bodyKey !== "*") {
|
||||
const queryParams = this.parseQueryString(query_string);
|
||||
requestBody = Object.assign(Object.assign({}, queryParams), requestBody);
|
||||
}
|
||||
let body = {};
|
||||
if (route.bodyKey) {
|
||||
const data = yield request_1.getRequestData(req);
|
||||
try {
|
||||
const jsonBody = JSON.parse(data.toString() || "{}");
|
||||
if (route.bodyKey === "*") {
|
||||
body = jsonBody;
|
||||
}
|
||||
else {
|
||||
body[route.bodyKey] = jsonBody;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
const msg = "the json request could not be decoded";
|
||||
throw new errors_1.TwirpError(errors_1.TwirpErrorCode.Malformed, msg).withCause(e, true);
|
||||
}
|
||||
}
|
||||
return Object.assign(Object.assign({}, body), requestBody);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Matches a route
|
||||
* @param req
|
||||
*/
|
||||
matchRoute(req) {
|
||||
var _a;
|
||||
const httpMethod = (_a = req.method) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
||||
if (!httpMethod) {
|
||||
throw new errors_1.BadRouteError(`method not allowed`, req.method || "", req.url || "");
|
||||
}
|
||||
const routes = this.routes[httpMethod];
|
||||
for (const route of routes) {
|
||||
const match = route.matcher(req.url || "/");
|
||||
if (match) {
|
||||
return [match, route];
|
||||
}
|
||||
}
|
||||
throw new errors_1.NotFoundError(`url ${req.url} not found`);
|
||||
}
|
||||
/**
|
||||
* Parse query string
|
||||
* @param queryString
|
||||
*/
|
||||
parseQueryString(queryString) {
|
||||
const queryParams = querystring_1.parse(queryString.replace("?", ""));
|
||||
return dotObject.object(queryParams);
|
||||
}
|
||||
}
|
||||
exports.Gateway = Gateway;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3898:
|
||||
/***/ (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.isHook = exports.chainHooks = void 0;
|
||||
// ChainHooks creates a new ServerHook which chains the callbacks in
|
||||
// each of the constituent hooks passed in. Each hook function will be
|
||||
// called in the order of the ServerHooks values passed in.
|
||||
//
|
||||
// For the erroring hooks, RequestReceived and RequestRouted, any returned
|
||||
// errors prevent processing by later hooks.
|
||||
function chainHooks(...hooks) {
|
||||
if (hooks.length === 0) {
|
||||
return null;
|
||||
}
|
||||
if (hooks.length === 1) {
|
||||
return hooks[0];
|
||||
}
|
||||
const serverHook = {
|
||||
requestReceived(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestReceived) {
|
||||
continue;
|
||||
}
|
||||
yield hook.requestReceived(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
requestPrepared(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestPrepared) {
|
||||
continue;
|
||||
}
|
||||
console.warn("hook requestPrepared is deprecated and will be removed in the next release. " +
|
||||
"Please use responsePrepared instead.");
|
||||
yield hook.requestPrepared(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
responsePrepared(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.responsePrepared) {
|
||||
continue;
|
||||
}
|
||||
yield hook.responsePrepared(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
requestSent(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestSent) {
|
||||
continue;
|
||||
}
|
||||
console.warn("hook requestSent is deprecated and will be removed in the next release. " +
|
||||
"Please use responseSent instead.");
|
||||
yield hook.requestSent(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
responseSent(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.responseSent) {
|
||||
continue;
|
||||
}
|
||||
yield hook.responseSent(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
requestRouted(ctx) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.requestRouted) {
|
||||
continue;
|
||||
}
|
||||
yield hook.requestRouted(ctx);
|
||||
}
|
||||
});
|
||||
},
|
||||
error(ctx, err) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
for (const hook of hooks) {
|
||||
if (!hook.error) {
|
||||
continue;
|
||||
}
|
||||
yield hook.error(ctx, err);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
return serverHook;
|
||||
}
|
||||
exports.chainHooks = chainHooks;
|
||||
function isHook(object) {
|
||||
return ("requestReceived" in object ||
|
||||
"requestPrepared" in object ||
|
||||
"requestSent" in object ||
|
||||
"requestRouted" in object ||
|
||||
"responsePrepared" in object ||
|
||||
"responseSent" in object ||
|
||||
"error" in object);
|
||||
}
|
||||
exports.isHook = isHook;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5683:
|
||||
/***/ (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;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (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 (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__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.FetchRPC = exports.wrapErrorResponseToTwirpError = exports.NodeHttpRPC = void 0;
|
||||
const http = __importStar(__nccwpck_require__(8611));
|
||||
const https = __importStar(__nccwpck_require__(5692));
|
||||
const url_1 = __nccwpck_require__(7016);
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
/**
|
||||
* a node HTTP RPC implementation
|
||||
* @param options
|
||||
* @constructor
|
||||
*/
|
||||
const NodeHttpRPC = (options) => ({
|
||||
request(service, method, contentType, data) {
|
||||
let client;
|
||||
return new Promise((resolve, rejected) => {
|
||||
const responseChunks = [];
|
||||
const requestData = contentType === "application/protobuf"
|
||||
? Buffer.from(data)
|
||||
: JSON.stringify(data);
|
||||
const url = new url_1.URL(options.baseUrl);
|
||||
const isHttps = url.protocol === "https:";
|
||||
if (isHttps) {
|
||||
client = https;
|
||||
}
|
||||
else {
|
||||
client = http;
|
||||
}
|
||||
const prefix = url.pathname !== "/" ? url.pathname : "";
|
||||
const req = client
|
||||
.request(Object.assign(Object.assign({}, (options ? options : {})), { method: "POST", protocol: url.protocol, host: url.hostname, port: url.port ? url.port : isHttps ? 443 : 80, path: `${prefix}/${service}/${method}`, headers: Object.assign(Object.assign({}, (options.headers ? options.headers : {})), { "Content-Type": contentType, "Content-Length": contentType === "application/protobuf"
|
||||
? Buffer.byteLength(requestData)
|
||||
: Buffer.from(requestData).byteLength }) }), (res) => {
|
||||
res.on("data", (chunk) => responseChunks.push(chunk));
|
||||
res.on("end", () => {
|
||||
const data = Buffer.concat(responseChunks);
|
||||
if (res.statusCode != 200) {
|
||||
rejected(wrapErrorResponseToTwirpError(data.toString()));
|
||||
}
|
||||
else {
|
||||
if (contentType === "application/json") {
|
||||
resolve(JSON.parse(data.toString()));
|
||||
}
|
||||
else {
|
||||
resolve(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
res.on("error", (err) => {
|
||||
rejected(err);
|
||||
});
|
||||
})
|
||||
.on("error", (err) => {
|
||||
rejected(err);
|
||||
});
|
||||
req.end(requestData);
|
||||
});
|
||||
},
|
||||
});
|
||||
exports.NodeHttpRPC = NodeHttpRPC;
|
||||
function wrapErrorResponseToTwirpError(errorResponse) {
|
||||
return errors_1.TwirpError.fromObject(JSON.parse(errorResponse));
|
||||
}
|
||||
exports.wrapErrorResponseToTwirpError = wrapErrorResponseToTwirpError;
|
||||
/**
|
||||
* a browser fetch RPC implementation
|
||||
*/
|
||||
const FetchRPC = (options) => ({
|
||||
request(service, method, contentType, data) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const headers = new Headers(options.headers);
|
||||
headers.set("content-type", contentType);
|
||||
const response = yield fetch(`${options.baseUrl}/${service}/${method}`, Object.assign(Object.assign({}, options), { method: "POST", headers, body: data instanceof Uint8Array ? data : JSON.stringify(data) }));
|
||||
if (response.status === 200) {
|
||||
if (contentType === "application/json") {
|
||||
return yield response.json();
|
||||
}
|
||||
return new Uint8Array(yield response.arrayBuffer());
|
||||
}
|
||||
throw errors_1.TwirpError.fromObject(yield response.json());
|
||||
});
|
||||
},
|
||||
});
|
||||
exports.FetchRPC = FetchRPC;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 430:
|
||||
/***/ (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;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.TwirpContentType = void 0;
|
||||
__exportStar(__nccwpck_require__(5497), exports);
|
||||
__exportStar(__nccwpck_require__(1035), exports);
|
||||
__exportStar(__nccwpck_require__(4036), exports);
|
||||
__exportStar(__nccwpck_require__(3898), exports);
|
||||
__exportStar(__nccwpck_require__(3315), exports);
|
||||
__exportStar(__nccwpck_require__(9636), exports);
|
||||
__exportStar(__nccwpck_require__(5683), exports);
|
||||
var request_1 = __nccwpck_require__(9647);
|
||||
Object.defineProperty(exports, "TwirpContentType", ({ enumerable: true, get: function () { return request_1.TwirpContentType; } }));
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4036:
|
||||
/***/ (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.chainInterceptors = void 0;
|
||||
// chains multiple Interceptors into a single Interceptor.
|
||||
// The first interceptor wraps the second one, and so on.
|
||||
// Returns null if interceptors is empty.
|
||||
function chainInterceptors(...interceptors) {
|
||||
if (interceptors.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (interceptors.length === 1) {
|
||||
return interceptors[0];
|
||||
}
|
||||
const first = interceptors[0];
|
||||
return (ctx, request, handler) => __awaiter(this, void 0, void 0, function* () {
|
||||
let next = handler;
|
||||
for (let i = interceptors.length - 1; i > 0; i--) {
|
||||
next = ((next) => (ctx, typedRequest) => {
|
||||
return interceptors[i](ctx, typedRequest, next);
|
||||
})(next);
|
||||
}
|
||||
return first(ctx, request, next);
|
||||
});
|
||||
}
|
||||
exports.chainInterceptors = chainInterceptors;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9647:
|
||||
/***/ (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.parseTwirpPath = exports.getRequestData = exports.validateRequest = exports.getContentType = exports.TwirpContentType = void 0;
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
/**
|
||||
* Supported Twirp Content-Type
|
||||
*/
|
||||
var TwirpContentType;
|
||||
(function (TwirpContentType) {
|
||||
TwirpContentType[TwirpContentType["Protobuf"] = 0] = "Protobuf";
|
||||
TwirpContentType[TwirpContentType["JSON"] = 1] = "JSON";
|
||||
TwirpContentType[TwirpContentType["Unknown"] = 2] = "Unknown";
|
||||
})(TwirpContentType = exports.TwirpContentType || (exports.TwirpContentType = {}));
|
||||
/**
|
||||
* Get supported content-type
|
||||
* @param mimeType
|
||||
*/
|
||||
function getContentType(mimeType) {
|
||||
switch (mimeType) {
|
||||
case "application/protobuf":
|
||||
return TwirpContentType.Protobuf;
|
||||
case "application/json":
|
||||
return TwirpContentType.JSON;
|
||||
default:
|
||||
return TwirpContentType.Unknown;
|
||||
}
|
||||
}
|
||||
exports.getContentType = getContentType;
|
||||
/**
|
||||
* Validate a twirp request
|
||||
* @param ctx
|
||||
* @param request
|
||||
* @param pathPrefix
|
||||
*/
|
||||
function validateRequest(ctx, request, pathPrefix) {
|
||||
if (request.method !== "POST") {
|
||||
const msg = `unsupported method ${request.method} (only POST is allowed)`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
const path = parseTwirpPath(request.url || "");
|
||||
if (path.pkgService !==
|
||||
(ctx.packageName ? ctx.packageName + "." : "") + ctx.serviceName) {
|
||||
const msg = `no handler for path ${request.url}`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
if (path.prefix !== pathPrefix) {
|
||||
const msg = `invalid path prefix ${path.prefix}, expected ${pathPrefix}, on path ${request.url}`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
const mimeContentType = request.headers["content-type"] || "";
|
||||
if (ctx.contentType === TwirpContentType.Unknown) {
|
||||
const msg = `unexpected Content-Type: ${request.headers["content-type"]}`;
|
||||
throw new errors_1.BadRouteError(msg, request.method || "", request.url || "");
|
||||
}
|
||||
return Object.assign(Object.assign({}, path), { mimeContentType, contentType: ctx.contentType });
|
||||
}
|
||||
exports.validateRequest = validateRequest;
|
||||
/**
|
||||
* Get request data from the body
|
||||
* @param req
|
||||
*/
|
||||
function getRequestData(req) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reqWithRawBody = req;
|
||||
if (reqWithRawBody.rawBody instanceof Buffer) {
|
||||
resolve(reqWithRawBody.rawBody);
|
||||
return;
|
||||
}
|
||||
const chunks = [];
|
||||
req.on("data", (chunk) => chunks.push(chunk));
|
||||
req.on("end", () => __awaiter(this, void 0, void 0, function* () {
|
||||
const data = Buffer.concat(chunks);
|
||||
resolve(data);
|
||||
}));
|
||||
req.on("error", (err) => {
|
||||
if (req.aborted) {
|
||||
reject(new errors_1.TwirpError(errors_1.TwirpErrorCode.DeadlineExceeded, "failed to read request: deadline exceeded"));
|
||||
}
|
||||
else {
|
||||
reject(new errors_1.TwirpError(errors_1.TwirpErrorCode.Malformed, err.message).withCause(err));
|
||||
}
|
||||
});
|
||||
req.on("close", () => {
|
||||
reject(new errors_1.TwirpError(errors_1.TwirpErrorCode.Canceled, "failed to read request: context canceled"));
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.getRequestData = getRequestData;
|
||||
/**
|
||||
* Parses twirp url path
|
||||
* @param path
|
||||
*/
|
||||
function parseTwirpPath(path) {
|
||||
const parts = path.split("/");
|
||||
if (parts.length < 2) {
|
||||
return {
|
||||
pkgService: "",
|
||||
method: "",
|
||||
prefix: "",
|
||||
};
|
||||
}
|
||||
return {
|
||||
method: parts[parts.length - 1],
|
||||
pkgService: parts[parts.length - 2],
|
||||
prefix: parts.slice(0, parts.length - 2).join("/"),
|
||||
};
|
||||
}
|
||||
exports.parseTwirpPath = parseTwirpPath;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 1035:
|
||||
/***/ (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.writeError = exports.TwirpServer = void 0;
|
||||
const hooks_1 = __nccwpck_require__(3898);
|
||||
const request_1 = __nccwpck_require__(9647);
|
||||
const errors_1 = __nccwpck_require__(3315);
|
||||
/**
|
||||
* Runtime server implementation of a TwirpServer
|
||||
*/
|
||||
class TwirpServer {
|
||||
constructor(options) {
|
||||
this.pathPrefix = "/twirp";
|
||||
this.hooks = [];
|
||||
this.interceptors = [];
|
||||
this.packageName = options.packageName;
|
||||
this.serviceName = options.serviceName;
|
||||
this.methodList = options.methodList;
|
||||
this.matchRoute = options.matchRoute;
|
||||
this.service = options.service;
|
||||
}
|
||||
/**
|
||||
* Returns the prefix for this server
|
||||
*/
|
||||
get prefix() {
|
||||
return this.pathPrefix;
|
||||
}
|
||||
/**
|
||||
* The http handler for twirp complaint endpoints
|
||||
* @param options
|
||||
*/
|
||||
httpHandler(options) {
|
||||
return (req, resp) => {
|
||||
// setup prefix
|
||||
if ((options === null || options === void 0 ? void 0 : options.prefix) !== undefined) {
|
||||
this.withPrefix(options.prefix);
|
||||
}
|
||||
return this._httpHandler(req, resp);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Adds interceptors or hooks to the request stack
|
||||
* @param middlewares
|
||||
*/
|
||||
use(...middlewares) {
|
||||
middlewares.forEach((middleware) => {
|
||||
if (hooks_1.isHook(middleware)) {
|
||||
this.hooks.push(middleware);
|
||||
return this;
|
||||
}
|
||||
this.interceptors.push(middleware);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Adds a prefix to the service url path
|
||||
* @param prefix
|
||||
*/
|
||||
withPrefix(prefix) {
|
||||
if (prefix === false) {
|
||||
this.pathPrefix = "";
|
||||
}
|
||||
else {
|
||||
this.pathPrefix = prefix;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Returns the regex matching path for this twirp server
|
||||
*/
|
||||
matchingPath() {
|
||||
const baseRegex = this.baseURI().replace(/\./g, "\\.");
|
||||
return new RegExp(`${baseRegex}\/(${this.methodList.join("|")})`);
|
||||
}
|
||||
/**
|
||||
* Returns the base URI for this twirp server
|
||||
*/
|
||||
baseURI() {
|
||||
return `${this.pathPrefix}/${this.packageName ? this.packageName + "." : ""}${this.serviceName}`;
|
||||
}
|
||||
/**
|
||||
* Create a twirp context
|
||||
* @param req
|
||||
* @param res
|
||||
* @private
|
||||
*/
|
||||
createContext(req, res) {
|
||||
return {
|
||||
packageName: this.packageName,
|
||||
serviceName: this.serviceName,
|
||||
methodName: "",
|
||||
contentType: request_1.getContentType(req.headers["content-type"]),
|
||||
req: req,
|
||||
res: res,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Twrip server http handler implementation
|
||||
* @param req
|
||||
* @param resp
|
||||
* @private
|
||||
*/
|
||||
_httpHandler(req, resp) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const ctx = this.createContext(req, resp);
|
||||
try {
|
||||
yield this.invokeHook("requestReceived", ctx);
|
||||
const { method, mimeContentType } = request_1.validateRequest(ctx, req, this.pathPrefix || "");
|
||||
const handler = this.matchRoute(method, {
|
||||
onMatch: (ctx) => {
|
||||
return this.invokeHook("requestRouted", ctx);
|
||||
},
|
||||
onNotFound: () => {
|
||||
const msg = `no handler for path ${req.url}`;
|
||||
throw new errors_1.BadRouteError(msg, req.method || "", req.url || "");
|
||||
},
|
||||
});
|
||||
const body = yield request_1.getRequestData(req);
|
||||
const response = yield handler(ctx, this.service, body, this.interceptors);
|
||||
yield Promise.all([
|
||||
this.invokeHook("responsePrepared", ctx),
|
||||
// keep backwards compatibility till next release
|
||||
this.invokeHook("requestPrepared", ctx),
|
||||
]);
|
||||
resp.statusCode = 200;
|
||||
resp.setHeader("Content-Type", mimeContentType);
|
||||
resp.end(response);
|
||||
}
|
||||
catch (e) {
|
||||
yield this.invokeHook("error", ctx, mustBeTwirpError(e));
|
||||
if (!resp.headersSent) {
|
||||
writeError(resp, e);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
yield Promise.all([
|
||||
this.invokeHook("responseSent", ctx),
|
||||
// keep backwards compatibility till next release
|
||||
this.invokeHook("requestSent", ctx),
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Invoke a hook
|
||||
* @param hookName
|
||||
* @param ctx
|
||||
* @param err
|
||||
* @protected
|
||||
*/
|
||||
invokeHook(hookName, ctx, err) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (this.hooks.length === 0) {
|
||||
return;
|
||||
}
|
||||
const chainedHooks = hooks_1.chainHooks(...this.hooks);
|
||||
const hook = chainedHooks === null || chainedHooks === void 0 ? void 0 : chainedHooks[hookName];
|
||||
if (hook) {
|
||||
yield hook(ctx, err || new errors_1.InternalServerError("internal server error"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.TwirpServer = TwirpServer;
|
||||
/**
|
||||
* Write http error response
|
||||
* @param res
|
||||
* @param error
|
||||
*/
|
||||
function writeError(res, error) {
|
||||
const twirpError = mustBeTwirpError(error);
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
res.statusCode = errors_1.httpStatusFromErrorCode(twirpError.code);
|
||||
res.end(twirpError.toJSON());
|
||||
}
|
||||
exports.writeError = writeError;
|
||||
/**
|
||||
* Make sure that the error passed is a TwirpError
|
||||
* otherwise it will wrap it into an InternalError
|
||||
* @param err
|
||||
*/
|
||||
function mustBeTwirpError(err) {
|
||||
if (err instanceof errors_1.TwirpError) {
|
||||
return err;
|
||||
}
|
||||
return new errors_1.InternalServerErrorWith(err);
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8736:
|
||||
@ -68133,14 +65270,6 @@ module.exports = require("punycode");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3480:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("querystring");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2203:
|
||||
/***/ ((module) => {
|
||||
|
||||
@ -68201,7 +65330,7 @@ module.exports = require("zlib");
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.0.0","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1","twirp-ts":"^2.5.0"},"devDependencies":{"@types/semver":"^6.0.0","typescript":"^5.2.2"}}');
|
||||
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.0.2","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1"},"devDependencies":{"@types/semver":"^6.0.0","typescript":"^5.2.2"}}');
|
||||
|
||||
/***/ }),
|
||||
|
||||
|
||||
310
package-lock.json
generated
310
package-lock.json
generated
@ -1,15 +1,15 @@
|
||||
{
|
||||
"name": "cache",
|
||||
"version": "4.2.0",
|
||||
"version": "4.2.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "cache",
|
||||
"version": "4.2.0",
|
||||
"version": "4.2.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^4.0.0",
|
||||
"@actions/cache": "^4.0.2",
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/io": "^1.1.3"
|
||||
@ -36,9 +36,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/cache": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-4.0.0.tgz",
|
||||
"integrity": "sha512-WIuxjnZ44lNYtIS4fqSaYvF00hORdy3cSin+jx8xNgBVGWnNIAiCBHjlwusVQlcgExoQC9pHXGrDsZyZr7rCDQ==",
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-4.0.2.tgz",
|
||||
"integrity": "sha512-cBr7JL1q+JKjbBd3w3SZN5OQ1Xg+/D8QLMcE7MpgpghZlL4biBO0ZEeraoTxCZyfN0YY0dxXlLgsgGv/sT5BTg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.11.1",
|
||||
@ -50,8 +50,7 @@
|
||||
"@azure/ms-rest-js": "^2.6.0",
|
||||
"@azure/storage-blob": "^12.13.0",
|
||||
"@protobuf-ts/plugin": "^2.9.4",
|
||||
"semver": "^6.3.1",
|
||||
"twirp-ts": "^2.5.0"
|
||||
"semver": "^6.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/core": {
|
||||
@ -3678,22 +3677,6 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/camel-case": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz",
|
||||
"integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pascal-case": "^3.1.2",
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/camel-case/node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/camelcase": {
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
|
||||
@ -3809,15 +3792,6 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/commander": {
|
||||
"version": "6.2.1",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz",
|
||||
"integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
@ -3951,19 +3925,6 @@
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dot-object": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/dot-object/-/dot-object-2.1.5.tgz",
|
||||
"integrity": "sha512-xHF8EP4XH/Ba9fvAF2LDd5O3IITVolerVV6xvkxoM8zlGEiCUrggpAnHyOoKJKCrhvPcGATFAUwIujj7bRG5UA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"commander": "^6.1.0",
|
||||
"glob": "^7.1.6"
|
||||
},
|
||||
"bin": {
|
||||
"dot-object": "bin/dot-object"
|
||||
}
|
||||
},
|
||||
"node_modules/electron-to-chromium": {
|
||||
"version": "1.4.71",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.71.tgz",
|
||||
@ -4793,7 +4754,8 @@
|
||||
"node_modules/fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.2",
|
||||
@ -4888,6 +4850,7 @@
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
|
||||
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
@ -5103,6 +5066,7 @@
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
@ -5111,7 +5075,8 @@
|
||||
"node_modules/inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/internal-slot": {
|
||||
"version": "1.0.3",
|
||||
@ -8155,7 +8120,8 @@
|
||||
"node_modules/lodash": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/lodash.memoize": {
|
||||
"version": "4.1.2",
|
||||
@ -8169,21 +8135,6 @@
|
||||
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/lower-case": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz",
|
||||
"integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/lower-case/node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||
@ -8312,22 +8263,6 @@
|
||||
"integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/no-case": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz",
|
||||
"integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"lower-case": "^2.0.2",
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/no-case/node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/nock": {
|
||||
"version": "13.2.9",
|
||||
"resolved": "https://registry.npmjs.org/nock/-/nock-13.2.9.tgz",
|
||||
@ -8471,6 +8406,7 @@
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@ -8570,22 +8506,6 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/pascal-case": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz",
|
||||
"integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"no-case": "^3.0.4",
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/pascal-case/node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/path-exists": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
|
||||
@ -8599,6 +8519,7 @@
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
@ -8618,12 +8539,6 @@
|
||||
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/path-to-regexp": {
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz",
|
||||
"integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/path-type": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
|
||||
@ -8756,6 +8671,7 @@
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.0.tgz",
|
||||
"integrity": "sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
},
|
||||
@ -9372,16 +9288,6 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/ts-poet": {
|
||||
"version": "4.15.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-poet/-/ts-poet-4.15.0.tgz",
|
||||
"integrity": "sha512-sLLR8yQBvHzi9d4R1F4pd+AzQxBfzOSSjfxiJxQhkUoH5bL7RsAC6wgvtVUQdGqiCsyS9rT6/8X2FI7ipdir5g==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.15",
|
||||
"prettier": "^2.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/tsconfig-paths": {
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
|
||||
@ -9440,35 +9346,6 @@
|
||||
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
|
||||
}
|
||||
},
|
||||
"node_modules/twirp-ts": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/twirp-ts/-/twirp-ts-2.5.0.tgz",
|
||||
"integrity": "sha512-JTKIK5Pf/+3qCrmYDFlqcPPUx+ohEWKBaZy8GL8TmvV2VvC0SXVyNYILO39+GCRbqnuP6hBIF+BVr8ZxRz+6fw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@protobuf-ts/plugin-framework": "^2.0.7",
|
||||
"camel-case": "^4.1.2",
|
||||
"dot-object": "^2.1.4",
|
||||
"path-to-regexp": "^6.2.0",
|
||||
"ts-poet": "^4.5.0",
|
||||
"yaml": "^1.10.2"
|
||||
},
|
||||
"bin": {
|
||||
"protoc-gen-twirp_ts": "protoc-gen-twirp_ts"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@protobuf-ts/plugin": "^2.5.0",
|
||||
"ts-proto": "^1.81.3"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@protobuf-ts/plugin": {
|
||||
"optional": true
|
||||
},
|
||||
"ts-proto": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/type-check": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
|
||||
@ -9631,7 +9508,8 @@
|
||||
"node_modules/wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/write-file-atomic": {
|
||||
"version": "3.0.3",
|
||||
@ -9680,15 +9558,6 @@
|
||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/yaml": {
|
||||
"version": "1.10.2",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz",
|
||||
"integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/yargs": {
|
||||
"version": "17.6.2",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.2.tgz",
|
||||
@ -9731,9 +9600,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/cache": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-4.0.0.tgz",
|
||||
"integrity": "sha512-WIuxjnZ44lNYtIS4fqSaYvF00hORdy3cSin+jx8xNgBVGWnNIAiCBHjlwusVQlcgExoQC9pHXGrDsZyZr7rCDQ==",
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-4.0.2.tgz",
|
||||
"integrity": "sha512-cBr7JL1q+JKjbBd3w3SZN5OQ1Xg+/D8QLMcE7MpgpghZlL4biBO0ZEeraoTxCZyfN0YY0dxXlLgsgGv/sT5BTg==",
|
||||
"requires": {
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/exec": "^1.0.1",
|
||||
@ -9744,8 +9613,7 @@
|
||||
"@azure/ms-rest-js": "^2.6.0",
|
||||
"@azure/storage-blob": "^12.13.0",
|
||||
"@protobuf-ts/plugin": "^2.9.4",
|
||||
"semver": "^6.3.1",
|
||||
"twirp-ts": "^2.5.0"
|
||||
"semver": "^6.3.1"
|
||||
}
|
||||
},
|
||||
"@actions/core": {
|
||||
@ -12608,22 +12476,6 @@
|
||||
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
|
||||
"dev": true
|
||||
},
|
||||
"camel-case": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz",
|
||||
"integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==",
|
||||
"requires": {
|
||||
"pascal-case": "^3.1.2",
|
||||
"tslib": "^2.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"camelcase": {
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
|
||||
@ -12710,11 +12562,6 @@
|
||||
"delayed-stream": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"commander": {
|
||||
"version": "6.2.1",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz",
|
||||
"integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA=="
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
@ -12812,15 +12659,6 @@
|
||||
"esutils": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"dot-object": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/dot-object/-/dot-object-2.1.5.tgz",
|
||||
"integrity": "sha512-xHF8EP4XH/Ba9fvAF2LDd5O3IITVolerVV6xvkxoM8zlGEiCUrggpAnHyOoKJKCrhvPcGATFAUwIujj7bRG5UA==",
|
||||
"requires": {
|
||||
"commander": "^6.1.0",
|
||||
"glob": "^7.1.6"
|
||||
}
|
||||
},
|
||||
"electron-to-chromium": {
|
||||
"version": "1.4.71",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.71.tgz",
|
||||
@ -13448,7 +13286,8 @@
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
|
||||
"dev": true
|
||||
},
|
||||
"fsevents": {
|
||||
"version": "2.3.2",
|
||||
@ -13512,6 +13351,7 @@
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
|
||||
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
@ -13658,6 +13498,7 @@
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
@ -13666,7 +13507,8 @@
|
||||
"inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"dev": true
|
||||
},
|
||||
"internal-slot": {
|
||||
"version": "1.0.3",
|
||||
@ -16067,7 +15909,8 @@
|
||||
"lodash": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
||||
"dev": true
|
||||
},
|
||||
"lodash.memoize": {
|
||||
"version": "4.1.2",
|
||||
@ -16081,21 +15924,6 @@
|
||||
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
|
||||
"dev": true
|
||||
},
|
||||
"lower-case": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz",
|
||||
"integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==",
|
||||
"requires": {
|
||||
"tslib": "^2.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||
@ -16196,22 +16024,6 @@
|
||||
"integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==",
|
||||
"dev": true
|
||||
},
|
||||
"no-case": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz",
|
||||
"integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==",
|
||||
"requires": {
|
||||
"lower-case": "^2.0.2",
|
||||
"tslib": "^2.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"nock": {
|
||||
"version": "13.2.9",
|
||||
"resolved": "https://registry.npmjs.org/nock/-/nock-13.2.9.tgz",
|
||||
@ -16319,6 +16131,7 @@
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@ -16391,22 +16204,6 @@
|
||||
"lines-and-columns": "^1.1.6"
|
||||
}
|
||||
},
|
||||
"pascal-case": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz",
|
||||
"integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==",
|
||||
"requires": {
|
||||
"no-case": "^3.0.4",
|
||||
"tslib": "^2.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"path-exists": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
|
||||
@ -16416,7 +16213,8 @@
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
|
||||
"dev": true
|
||||
},
|
||||
"path-key": {
|
||||
"version": "3.1.1",
|
||||
@ -16430,11 +16228,6 @@
|
||||
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
|
||||
"dev": true
|
||||
},
|
||||
"path-to-regexp": {
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz",
|
||||
"integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ=="
|
||||
},
|
||||
"path-type": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
|
||||
@ -16528,7 +16321,8 @@
|
||||
"prettier": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.0.tgz",
|
||||
"integrity": "sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA=="
|
||||
"integrity": "sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA==",
|
||||
"dev": true
|
||||
},
|
||||
"prettier-linter-helpers": {
|
||||
"version": "1.0.0",
|
||||
@ -16947,15 +16741,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"ts-poet": {
|
||||
"version": "4.15.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-poet/-/ts-poet-4.15.0.tgz",
|
||||
"integrity": "sha512-sLLR8yQBvHzi9d4R1F4pd+AzQxBfzOSSjfxiJxQhkUoH5bL7RsAC6wgvtVUQdGqiCsyS9rT6/8X2FI7ipdir5g==",
|
||||
"requires": {
|
||||
"lodash": "^4.17.15",
|
||||
"prettier": "^2.5.1"
|
||||
}
|
||||
},
|
||||
"tsconfig-paths": {
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
|
||||
@ -17004,19 +16789,6 @@
|
||||
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg=="
|
||||
},
|
||||
"twirp-ts": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/twirp-ts/-/twirp-ts-2.5.0.tgz",
|
||||
"integrity": "sha512-JTKIK5Pf/+3qCrmYDFlqcPPUx+ohEWKBaZy8GL8TmvV2VvC0SXVyNYILO39+GCRbqnuP6hBIF+BVr8ZxRz+6fw==",
|
||||
"requires": {
|
||||
"@protobuf-ts/plugin-framework": "^2.0.7",
|
||||
"camel-case": "^4.1.2",
|
||||
"dot-object": "^2.1.4",
|
||||
"path-to-regexp": "^6.2.0",
|
||||
"ts-poet": "^4.5.0",
|
||||
"yaml": "^1.10.2"
|
||||
}
|
||||
},
|
||||
"type-check": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
|
||||
@ -17136,7 +16908,8 @@
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
|
||||
"dev": true
|
||||
},
|
||||
"write-file-atomic": {
|
||||
"version": "3.0.3",
|
||||
@ -17176,11 +16949,6 @@
|
||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||
"dev": true
|
||||
},
|
||||
"yaml": {
|
||||
"version": "1.10.2",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz",
|
||||
"integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg=="
|
||||
},
|
||||
"yargs": {
|
||||
"version": "17.6.2",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.2.tgz",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cache",
|
||||
"version": "4.2.0",
|
||||
"version": "4.2.2",
|
||||
"private": true,
|
||||
"description": "Cache dependencies and build outputs",
|
||||
"main": "dist/restore/index.js",
|
||||
@ -23,7 +23,7 @@
|
||||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^4.0.0",
|
||||
"@actions/cache": "^4.0.2",
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/io": "^1.1.3"
|
||||
@ -48,4 +48,4 @@
|
||||
"ts-jest": "^28.0.8",
|
||||
"typescript": "^4.9.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,8 +79,10 @@ To avoid saving a cache that already exists, the `cache-hit` output from a resto
|
||||
The `cache-primary-key` output from the restore step should also be used to ensure
|
||||
the cache key does not change during the build if it's calculated based on file contents.
|
||||
|
||||
Here's an example where we imagine we're calculating a lot of prime numbers and want to cache them:
|
||||
|
||||
```yaml
|
||||
name: Always Caching Primes
|
||||
name: Always Caching Prime Numbers
|
||||
|
||||
on: push
|
||||
|
||||
@ -91,23 +93,23 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Restore cached Primes
|
||||
id: cache-primes-restore
|
||||
- name: Restore cached Prime Numbers
|
||||
id: cache-prime-numbers-restore
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
key: ${{ runner.os }}-primes
|
||||
key: ${{ runner.os }}-prime-numbers
|
||||
path: |
|
||||
path/to/dependencies
|
||||
some/other/dependencies
|
||||
|
||||
# Intermediate workflow steps
|
||||
|
||||
- name: Always Save Primes
|
||||
id: cache-primes-save
|
||||
if: always() && steps.cache-primes-restore.outputs.cache-hit != 'true'
|
||||
- name: Always Save Prime Numbers
|
||||
id: cache-prime-numbers-save
|
||||
if: always() && steps.cache-prime-numbers-restore.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
key: ${{ steps.cache-primes-restore.outputs.cache-primary-key }}
|
||||
key: ${{ steps.cache-prime-numbers-restore.outputs.cache-primary-key }}
|
||||
path: |
|
||||
path/to/dependencies
|
||||
some/other/dependencies
|
||||
|
||||
@ -37,9 +37,8 @@ From `v3.2.3` cache is cross-os compatible when `enableCrossOsArchive` input is
|
||||
|
||||
## Force deletion of caches overriding default cache eviction policy
|
||||
|
||||
Caches have [branch scope restriction](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache) in place. This means that if caches for a specific branch are using a lot of storage quota, it may result into more frequently used caches from `default` branch getting thrashed. For example, if there are many pull requests happening on a repo and are creating caches, these cannot be used in default branch scope but will still occupy a lot of space till they get cleaned up by [eviction policy](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy). But sometime we want to clean them up on a faster cadence so as to ensure default branch is not thrashing. In order to achieve this, [gh-actions-cache cli](https://github.com/actions/gh-actions-cache/) can be used to delete caches for specific branches.
|
||||
Caches have [branch scope restriction](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache) in place. This means that if caches for a specific branch are using a lot of storage quota, it may result into more frequently used caches from `default` branch getting thrashed. For example, if there are many pull requests happening on a repo and are creating caches, these cannot be used in default branch scope but will still occupy a lot of space till they get cleaned up by [eviction policy](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy). But sometime we want to clean them up on a faster cadence so as to ensure default branch is not thrashing.
|
||||
|
||||
This workflow uses `gh-actions-cache` to delete all the caches created by a branch.
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
||||
@ -60,29 +59,23 @@ jobs:
|
||||
actions: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cleanup
|
||||
run: |
|
||||
gh extension install actions/gh-actions-cache
|
||||
|
||||
REPO=${{ github.repository }}
|
||||
BRANCH=refs/pull/${{ github.event.pull_request.number }}/merge
|
||||
|
||||
echo "Fetching list of cache key"
|
||||
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
|
||||
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
|
||||
|
||||
## Setting this to not fail the workflow while deleting cache keys.
|
||||
## Setting this to not fail the workflow while deleting cache keys.
|
||||
set +e
|
||||
echo "Deleting caches..."
|
||||
for cacheKey in $cacheKeysForPR
|
||||
do
|
||||
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
|
||||
gh cache delete $cacheKey
|
||||
done
|
||||
echo "Done"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user