From 12ab86edde58a2c49de301dc8e0a6ea17bf6ea82 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 5 Oct 2023 20:38:08 +0900 Subject: [PATCH] `npm run package` --- dist/index.js | 112 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 80 insertions(+), 32 deletions(-) diff --git a/dist/index.js b/dist/index.js index 52bde4a2..877d6695 100644 --- a/dist/index.js +++ b/dist/index.js @@ -558,7 +558,7 @@ class OidcClient { .catch(error => { throw new Error(`Failed to get ID Token. \n Error Code : ${error.statusCode}\n - Error Message: ${error.result.message}`); + Error Message: ${error.message}`); }); const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; if (!id_token) { @@ -17050,7 +17050,18 @@ class PackageURL { let version = null; if (path.includes('@')) { let index = path.indexOf('@'); - version = decodeURIComponent(path.substring(index + 1)); + let rawVersion= path.substring(index + 1); + version = decodeURIComponent(rawVersion); + + // Convert percent-encoded colons (:) back, to stay in line with the `toString` + // implementation of this library. + // https://github.com/package-url/packageurl-js/blob/58026c86978c6e356e5e07f29ecfdccbf8829918/src/package-url.js#L98C10-L98C10 + let versionEncoded = encodeURIComponent(version).replace(/%3A/g, ':'); + + if (rawVersion !== versionEncoded) { + throw new Error('Invalid purl: version must be percent-encoded'); + } + remainder = path.substring(0, index); } else { remainder = path; @@ -20531,7 +20542,8 @@ class ParseStatus { status.dirty(); if (value.status === "dirty") status.dirty(); - if (typeof value.value !== "undefined" || pair.alwaysSet) { + if (key.value !== "__proto__" && + (typeof value.value !== "undefined" || pair.alwaysSet)) { finalObject[key.value] = value.value; } } @@ -20898,8 +20910,8 @@ exports["default"] = errorMap; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.discriminatedUnion = exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0; -exports.NEVER = exports["void"] = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports["null"] = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports["instanceof"] = exports["function"] = exports["enum"] = exports.effect = void 0; +exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0; +exports.NEVER = exports["void"] = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports["null"] = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports["instanceof"] = exports["function"] = exports["enum"] = exports.effect = exports.discriminatedUnion = void 0; const errors_1 = __nccwpck_require__(9566); const errorUtil_1 = __nccwpck_require__(2513); const parseUtil_1 = __nccwpck_require__(888); @@ -20989,6 +21001,7 @@ class ZodType { this.catch = this.catch.bind(this); this.describe = this.describe.bind(this); this.pipe = this.pipe.bind(this); + this.readonly = this.readonly.bind(this); this.isNullable = this.isNullable.bind(this); this.isOptional = this.isOptional.bind(this); } @@ -21205,6 +21218,9 @@ class ZodType { pipe(target) { return ZodPipeline.create(this, target); } + readonly() { + return ZodReadonly.create(this); + } isOptional() { return this.safeParse(undefined).success; } @@ -21218,8 +21234,8 @@ exports.ZodSchema = ZodType; const cuidRegex = /^c[^\s-]{8,}$/i; const cuid2Regex = /^[a-z][a-z0-9]*$/; const ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/; -const uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i; -const emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/; +const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i; +const emailRegex = /^([A-Z0-9_+-]+\.?)*[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i; const emojiRegex = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u; const ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/; const ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/; @@ -23195,6 +23211,12 @@ class ZodRecord extends ZodType { } exports.ZodRecord = ZodRecord; class ZodMap extends ZodType { + get keySchema() { + return this._def.keyType; + } + get valueSchema() { + return this._def.valueType; + } _parse(input) { const { status, ctx } = this._processInputParams(input); if (ctx.parsedType !== util_1.ZodParsedType.map) { @@ -23393,16 +23415,17 @@ class ZodFunction extends ZodType { const params = { errorMap: ctx.common.contextualErrorMap }; const fn = ctx.data; if (this._def.returns instanceof ZodPromise) { - return (0, parseUtil_1.OK)(async (...args) => { + const me = this; + return (0, parseUtil_1.OK)(async function (...args) { const error = new ZodError_1.ZodError([]); - const parsedArgs = await this._def.args + const parsedArgs = await me._def.args .parseAsync(args, params) .catch((e) => { error.addIssue(makeArgsIssue(args, e)); throw error; }); - const result = await fn(...parsedArgs); - const parsedReturns = await this._def.returns._def.type + const result = await Reflect.apply(fn, this, parsedArgs); + const parsedReturns = await me._def.returns._def.type .parseAsync(result, params) .catch((e) => { error.addIssue(makeReturnsIssue(result, e)); @@ -23412,13 +23435,14 @@ class ZodFunction extends ZodType { }); } else { - return (0, parseUtil_1.OK)((...args) => { - const parsedArgs = this._def.args.safeParse(args, params); + const me = this; + return (0, parseUtil_1.OK)(function (...args) { + const parsedArgs = me._def.args.safeParse(args, params); if (!parsedArgs.success) { throw new ZodError_1.ZodError([makeArgsIssue(args, parsedArgs.error)]); } - const result = fn(...parsedArgs.data); - const parsedReturns = this._def.returns.safeParse(result, params); + const result = Reflect.apply(fn, this, parsedArgs.data); + const parsedReturns = me._def.returns.safeParse(result, params); if (!parsedReturns.success) { throw new ZodError_1.ZodError([makeReturnsIssue(result, parsedReturns.error)]); } @@ -23509,7 +23533,7 @@ ZodLiteral.create = (value, params) => { }; function createZodEnum(values, params) { return new ZodEnum({ - values: values, + values, typeName: ZodFirstPartyTypeKind.ZodEnum, ...processCreateParams(params), }); @@ -23654,8 +23678,29 @@ class ZodEffects extends ZodType { _parse(input) { const { status, ctx } = this._processInputParams(input); const effect = this._def.effect || null; + const checkCtx = { + addIssue: (arg) => { + (0, parseUtil_1.addIssueToContext)(ctx, arg); + if (arg.fatal) { + status.abort(); + } + else { + status.dirty(); + } + }, + get path() { + return ctx.path; + }, + }; + checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); if (effect.type === "preprocess") { - const processed = effect.transform(ctx.data); + const processed = effect.transform(ctx.data, checkCtx); + if (ctx.common.issues.length) { + return { + status: "dirty", + value: ctx.data, + }; + } if (ctx.common.async) { return Promise.resolve(processed).then((processed) => { return this._def.schema._parseAsync({ @@ -23673,21 +23718,6 @@ class ZodEffects extends ZodType { }); } } - const checkCtx = { - addIssue: (arg) => { - (0, parseUtil_1.addIssueToContext)(ctx, arg); - if (arg.fatal) { - status.abort(); - } - else { - status.dirty(); - } - }, - get path() { - return ctx.path; - }, - }; - checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); if (effect.type === "refinement") { const executeRefinement = (acc) => { const result = effect.refinement(acc, checkCtx); @@ -23996,6 +24026,23 @@ class ZodPipeline extends ZodType { } } exports.ZodPipeline = ZodPipeline; +class ZodReadonly extends ZodType { + _parse(input) { + const result = this._def.innerType._parse(input); + if ((0, parseUtil_1.isValid)(result)) { + result.value = Object.freeze(result.value); + } + return result; + } +} +exports.ZodReadonly = ZodReadonly; +ZodReadonly.create = (type, params) => { + return new ZodReadonly({ + innerType: type, + typeName: ZodFirstPartyTypeKind.ZodReadonly, + ...processCreateParams(params), + }); +}; const custom = (check, params = {}, fatal) => { if (check) return ZodAny.create().superRefine((data, ctx) => { @@ -24054,6 +24101,7 @@ var ZodFirstPartyTypeKind; ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise"; ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded"; ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline"; + ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly"; })(ZodFirstPartyTypeKind = exports.ZodFirstPartyTypeKind || (exports.ZodFirstPartyTypeKind = {})); class Class { constructor(..._) { }