@telia-ace/alliance-internal-node-utilities 1.1.0-next.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-UNKGNXJ3.js +32 -0
- package/dist/compile-distribution.js +13 -13
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -4
- package/package.json +2 -2
- package/dist/chunk-RKK7CWA6.js +0 -32
package/dist/index.d.ts
CHANGED
|
@@ -195,7 +195,8 @@ declare enum GatewayErrorCode {
|
|
|
195
195
|
NoUserPermissionsInRequestContext = 10012,
|
|
196
196
|
WorkspacePermissionDenied = 10013,
|
|
197
197
|
NoTargetUrlHeader = 10014,
|
|
198
|
-
NoSessionInRedisCache = 10015
|
|
198
|
+
NoSessionInRedisCache = 10015,
|
|
199
|
+
ProhibitedTargetDomain = 10016
|
|
199
200
|
}
|
|
200
201
|
declare enum DataErrorCode {
|
|
201
202
|
NoPublicKey = 11000,
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as It,b as Et,c as Ct}from"./chunk-RKK7CWA6.js";import"./chunk-26VIM55J.js";import"./chunk-JG7V63GM.js";import Cr from"jsonwebtoken";import{createPublicKey as Sr}from"node:crypto";var k;(function(t){t.assertEqual=s=>s;function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let a={};for(let o of s)a[o]=o;return a},t.getValidEnumValues=s=>{let a=t.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),o={};for(let c of a)o[c]=s[c];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(a){return s[a]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&a.push(o);return a},t.find=(s,a)=>{for(let o of s)if(a(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(k||(k={}));var je;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(je||(je={}));var p=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),z=t=>{switch(typeof t){case"undefined":return p.undefined;case"string":return p.string;case"number":return isNaN(t)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(t)?p.array:t===null?p.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?p.promise:typeof Map<"u"&&t instanceof Map?p.map:typeof Set<"u"&&t instanceof Set?p.set:typeof Date<"u"&&t instanceof Date?p.date:p.object;default:return p.unknown}},d=k.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),St=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),N=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let r=e||function(a){return a.message},n={_errors:[]},s=a=>{for(let o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let c=n,h=0;for(;h<o.path.length;){let i=o.path[h];h===o.path.length-1?(c[i]=c[i]||{_errors:[]},c[i]._errors.push(r(o))):c[i]=c[i]||{_errors:[]},c=c[i],h++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,k.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};N.create=t=>new N(t);var ge=(t,e)=>{let r;switch(t.code){case d.invalid_type:t.received===p.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,k.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:r=`Unrecognized key(s) in object: ${k.joinValues(t.keys,", ")}`;break;case d.invalid_union:r="Invalid input";break;case d.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${k.joinValues(t.options)}`;break;case d.invalid_enum_value:r=`Invalid enum value. Expected ${k.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:r="Invalid function arguments";break;case d.invalid_return_type:r="Invalid function return type";break;case d.invalid_date:r="Invalid date";break;case d.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:k.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case d.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case d.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case d.custom:r="Invalid input";break;case d.invalid_intersection_types:r="Intersection results could not be merged";break;case d.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:r="Number must be finite";break;default:r=e.defaultError,k.assertNever(t)}return{message:r}},Qe=ge;function Nt(t){Qe=t}function ke(){return Qe}var Te=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,a=[...r,...s.path||[]],o={...s,path:a},c="",h=n.filter(i=>!!i).slice().reverse();for(let i of h)c=i(o,{data:e,defaultError:c}).message;return{...s,path:a,message:s.message||c}},Rt=[];function m(t,e){let r=Te({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ke(),ge].filter(n=>!!n)});t.common.issues.push(r)}var I=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r)n.push({key:await s.key,value:await s.value});return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:a,value:o}=s;if(a.status==="aborted"||o.status==="aborted")return v;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[a.value]=o.value)}return{status:e.value,value:n}}},v=Object.freeze({status:"aborted"}),Xe=t=>({status:"dirty",value:t}),E=t=>({status:"valid",value:t}),Pe=t=>t.status==="aborted",Ze=t=>t.status==="dirty",ye=t=>t.status==="valid",Ie=t=>typeof Promise<"u"&&t instanceof Promise,g;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(g||(g={}));var O=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},He=(t,e)=>{if(ye(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new N(t.common.issues);return this._error=r,this._error}}};function _(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,c)=>o.code!=="invalid_type"?{message:c.defaultError}:typeof c.data>"u"?{message:n??c.defaultError}:{message:r??c.defaultError},description:s}}var x=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),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)}get description(){return this._def.description}_getType(e){return z(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new I,ctx:{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Ie(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;let s={common:{issues:[],async:(n=r?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},a=this._parseSync({data:e,path:s.path,parent:s});return He(s,a)}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Ie(s)?s:Promise.resolve(s));return He(n,a)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,a)=>{let o=e(s),c=()=>a.addIssue({code:d.custom,...n(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(h=>h?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new R({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return j.create(this,this._def)}nullable(){return V.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return M.create(this,this._def)}promise(){return U.create(this,this._def)}or(e){return G.create([this,e],this._def)}and(e){return Q.create(this,e,this._def)}transform(e){return new R({..._(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new ne({..._(this._def),innerType:this,defaultValue:r,typeName:y.ZodDefault})}brand(){return new Ne({typeName:y.ZodBranded,type:this,..._(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new le({..._(this._def),innerType:this,catchValue:r,typeName:y.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return ve.create(this,e)}readonly(){return pe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Ot=/^c[^\s-]{8,}$/i,At=/^[a-z][a-z0-9]*$/,jt=/^[0-9A-HJKMNP-TV-Z]{26}$/,Pt=/^[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,Zt=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Lt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ae,Mt=/^(((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}))$/,Vt=/^(([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})))$/,zt=t=>t.precision?t.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`):t.precision===0?t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Bt(t,e){return!!((e==="v4"||!e)&&Mt.test(t)||(e==="v6"||!e)&&Vt.test(t))}var B=class t extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){let a=this._getOrReturnCtx(e);return m(a,{code:d.invalid_type,expected:p.string,received:a.parsedType}),v}let n=new I,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let o=e.data.length>a.value,c=e.data.length<a.value;(o||c)&&(s=this._getOrReturnCtx(e,s),o?m(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):c&&m(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Zt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"email",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Ae||(Ae=new RegExp(Lt,"u")),Ae.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"emoji",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Pt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"uuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Ot.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")At.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid2",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")jt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ulid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),m(s,{validation:"url",code:d.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"regex",code:d.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?zt(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="ip"?Bt(e.data,a.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ip",code:d.invalid_string,message:a.message}),n.dirty()):k.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:d.invalid_string,...g.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...g.errToObj(e)})}url(e){return this._addCheck({kind:"url",...g.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...g.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...g.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...g.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...g.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...g.errToObj(e)})}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!==null&&r!==void 0?r:!1,...g.errToObj(e?.message)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...g.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...g.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...g.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...g.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...g.errToObj(r)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};B.create=t=>{var e;return new B({checks:[],typeName:y.ZodString,coerce:(e=t?.coerce)!==null&&e!==void 0?e:!1,..._(t)})};function Kt(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,a=parseInt(t.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return a%o/Math.pow(10,s)}var $=class t extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==p.number){let a=this._getOrReturnCtx(e);return m(a,{code:d.invalid_type,expected:p.number,received:a.parsedType}),v}let n,s=new I;for(let a of this._def.checks)a.kind==="int"?k.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Kt(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_finite,message:a.message}),s.dirty()):k.assertNever(a);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,g.toString(r))}gt(e,r){return this.setLimit("min",e,!1,g.toString(r))}lte(e,r){return this.setLimit("max",e,!0,g.toString(r))}lt(e,r){return this.setLimit("max",e,!1,g.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:g.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};$.create=t=>new $({checks:[],typeName:y.ZodNumber,coerce:t?.coerce||!1,..._(t)});var W=class t extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==p.bigint){let a=this._getOrReturnCtx(e);return m(a,{code:d.invalid_type,expected:p.bigint,received:a.parsedType}),v}let n,s=new I;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):k.assertNever(a);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,g.toString(r))}gt(e,r){return this.setLimit("min",e,!1,g.toString(r))}lte(e,r){return this.setLimit("max",e,!0,g.toString(r))}lt(e,r){return this.setLimit("max",e,!1,g.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};W.create=t=>{var e;return new W({checks:[],typeName:y.ZodBigInt,coerce:(e=t?.coerce)!==null&&e!==void 0?e:!1,..._(t)})};var F=class extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:p.boolean,received:n.parsedType}),v}return E(e.data)}};F.create=t=>new F({typeName:y.ZodBoolean,coerce:t?.coerce||!1,..._(t)});var Y=class t extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){let a=this._getOrReturnCtx(e);return m(a,{code:d.invalid_type,expected:p.date,received:a.parsedType}),v}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return m(a,{code:d.invalid_date}),v}let n=new I,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):k.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:g.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};Y.create=t=>new Y({checks:[],coerce:t?.coerce||!1,typeName:y.ZodDate,..._(t)});var oe=class extends x{_parse(e){if(this._getType(e)!==p.symbol){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:p.symbol,received:n.parsedType}),v}return E(e.data)}};oe.create=t=>new oe({typeName:y.ZodSymbol,..._(t)});var J=class extends x{_parse(e){if(this._getType(e)!==p.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:p.undefined,received:n.parsedType}),v}return E(e.data)}};J.create=t=>new J({typeName:y.ZodUndefined,..._(t)});var H=class extends x{_parse(e){if(this._getType(e)!==p.null){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:p.null,received:n.parsedType}),v}return E(e.data)}};H.create=t=>new H({typeName:y.ZodNull,..._(t)});var K=class extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return E(e.data)}};K.create=t=>new K({typeName:y.ZodAny,..._(t)});var L=class extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return E(e.data)}};L.create=t=>new L({typeName:y.ZodUnknown,..._(t)});var P=class extends x{_parse(e){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:p.never,received:r.parsedType}),v}};P.create=t=>new P({typeName:y.ZodNever,..._(t)});var ce=class extends x{_parse(e){if(this._getType(e)!==p.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:p.void,received:n.parsedType}),v}return E(e.data)}};ce.create=t=>new ce({typeName:y.ZodVoid,..._(t)});var M=class t extends x{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==p.array)return m(r,{code:d.invalid_type,expected:p.array,received:r.parsedType}),v;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,c=r.data.length<s.exactLength.value;(o||c)&&(m(r,{code:o?d.too_big:d.too_small,minimum:c?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(m(r,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(m(r,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,c)=>s.type._parseAsync(new O(r,o,r.path,c)))).then(o=>I.mergeArray(n,o));let a=[...r.data].map((o,c)=>s.type._parseSync(new O(r,o,r.path,c)));return I.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:g.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:g.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:g.toString(r)}})}nonempty(e){return this.min(1,e)}};M.create=(t,e)=>new M({type:t,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,..._(e)});function ie(t){if(t instanceof S){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=j.create(ie(n))}return new S({...t._def,shape:()=>e})}else return t instanceof M?new M({...t._def,type:ie(t.element)}):t instanceof j?j.create(ie(t.unwrap())):t instanceof V?V.create(ie(t.unwrap())):t instanceof Z?Z.create(t.items.map(e=>ie(e))):t}var S=class t extends x{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=k.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==p.object){let i=this._getOrReturnCtx(e);return m(i,{code:d.invalid_type,expected:p.object,received:i.parsedType}),v}let{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof P&&this._def.unknownKeys==="strip"))for(let i in s.data)o.includes(i)||c.push(i);let h=[];for(let i of o){let u=a[i],f=s.data[i];h.push({key:{status:"valid",value:i},value:u._parse(new O(s,f,s.path,i)),alwaysSet:i in s.data})}if(this._def.catchall instanceof P){let i=this._def.unknownKeys;if(i==="passthrough")for(let u of c)h.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(i==="strict")c.length>0&&(m(s,{code:d.unrecognized_keys,keys:c}),n.dirty());else if(i!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let i=this._def.catchall;for(let u of c){let f=s.data[u];h.push({key:{status:"valid",value:u},value:i._parse(new O(s,f,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let i=[];for(let u of h){let f=await u.key;i.push({key:f,value:await u.value,alwaysSet:u.alwaysSet})}return i}).then(i=>I.mergeObjectSync(n,i)):I.mergeObjectSync(n,h)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var s,a,o,c;let h=(o=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,r,n).message)!==null&&o!==void 0?o:n.defaultError;return r.code==="unrecognized_keys"?{message:(c=g.errToObj(e).message)!==null&&c!==void 0?c:h}:{message:h}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};return k.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new t({...this._def,shape:()=>r})}omit(e){let r={};return k.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new t({...this._def,shape:()=>r})}deepPartial(){return ie(this)}partial(e){let r={};return k.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}),new t({...this._def,shape:()=>r})}required(e){let r={};return k.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof j;)a=a._def.innerType;r[n]=a}}),new t({...this._def,shape:()=>r})}keyof(){return et(k.objectKeys(this.shape))}};S.create=(t,e)=>new S({shape:()=>t,unknownKeys:"strip",catchall:P.create(),typeName:y.ZodObject,..._(e)});S.strictCreate=(t,e)=>new S({shape:()=>t,unknownKeys:"strict",catchall:P.create(),typeName:y.ZodObject,..._(e)});S.lazycreate=(t,e)=>new S({shape:t,unknownKeys:"strip",catchall:P.create(),typeName:y.ZodObject,..._(e)});var G=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(a){for(let c of a)if(c.result.status==="valid")return c.result;for(let c of a)if(c.result.status==="dirty")return r.common.issues.push(...c.ctx.common.issues),c.result;let o=a.map(c=>new N(c.ctx.common.issues));return m(r,{code:d.invalid_union,unionErrors:o}),v}if(r.common.async)return Promise.all(n.map(async a=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let a,o=[];for(let h of n){let i={...r,common:{...r.common,issues:[]},parent:null},u=h._parseSync({data:r.data,path:r.path,parent:i});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,ctx:i}),i.common.issues.length&&o.push(i.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let c=o.map(h=>new N(h));return m(r,{code:d.invalid_union,unionErrors:c}),v}}get options(){return this._def.options}};G.create=(t,e)=>new G({options:t,typeName:y.ZodUnion,..._(e)});var be=t=>t instanceof X?be(t.schema):t instanceof R?be(t.innerType()):t instanceof ee?[t.value]:t instanceof te?t.options:t instanceof re?Object.keys(t.enum):t instanceof ne?be(t._def.innerType):t instanceof J?[void 0]:t instanceof H?[null]:null,Ee=class t extends x{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.object)return m(r,{code:d.invalid_type,expected:p.object,received:r.parsedType}),v;let n=this.discriminator,s=r.data[n],a=this.optionsMap.get(s);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(m(r,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let a of r){let o=be(a.shape[e]);if(!o)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let c of o){if(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,a)}}return new t({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,..._(n)})}};function Le(t,e){let r=z(t),n=z(e);if(t===e)return{valid:!0,data:t};if(r===p.object&&n===p.object){let s=k.objectKeys(e),a=k.objectKeys(t).filter(c=>s.indexOf(c)!==-1),o={...t,...e};for(let c of a){let h=Le(t[c],e[c]);if(!h.valid)return{valid:!1};o[c]=h.data}return{valid:!0,data:o}}else if(r===p.array&&n===p.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<t.length;a++){let o=t[a],c=e[a],h=Le(o,c);if(!h.valid)return{valid:!1};s.push(h.data)}return{valid:!0,data:s}}else return r===p.date&&n===p.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Q=class extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(a,o)=>{if(Pe(a)||Pe(o))return v;let c=Le(a.value,o.value);return c.valid?((Ze(a)||Ze(o))&&r.dirty(),{status:r.value,value:c.data}):(m(n,{code:d.invalid_intersection_types}),v)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,o])=>s(a,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Q.create=(t,e,r)=>new Q({left:t,right:e,typeName:y.ZodIntersection,..._(r)});var Z=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.array)return m(n,{code:d.invalid_type,expected:p.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return m(n,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&n.data.length>this._def.items.length&&(m(n,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((o,c)=>{let h=this._def.items[c]||this._def.rest;return h?h._parse(new O(n,o,n.path,c)):null}).filter(o=>!!o);return n.common.async?Promise.all(a).then(o=>I.mergeArray(r,o)):I.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Z.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Z({items:t,typeName:y.ZodTuple,rest:null,..._(e)})};var Ce=class t extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.object)return m(n,{code:d.invalid_type,expected:p.object,received:n.parsedType}),v;let s=[],a=this._def.keyType,o=this._def.valueType;for(let c in n.data)s.push({key:a._parse(new O(n,c,n.path,c)),value:o._parse(new O(n,n.data[c],n.path,c))});return n.common.async?I.mergeObjectAsync(r,s):I.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof x?new t({keyType:e,valueType:r,typeName:y.ZodRecord,..._(n)}):new t({keyType:B.create(),valueType:e,typeName:y.ZodRecord,..._(r)})}},ue=class extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.map)return m(n,{code:d.invalid_type,expected:p.map,received:n.parsedType}),v;let s=this._def.keyType,a=this._def.valueType,o=[...n.data.entries()].map(([c,h],i)=>({key:s._parse(new O(n,c,n.path,[i,"key"])),value:a._parse(new O(n,h,n.path,[i,"value"]))}));if(n.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let h of o){let i=await h.key,u=await h.value;if(i.status==="aborted"||u.status==="aborted")return v;(i.status==="dirty"||u.status==="dirty")&&r.dirty(),c.set(i.value,u.value)}return{status:r.value,value:c}})}else{let c=new Map;for(let h of o){let i=h.key,u=h.value;if(i.status==="aborted"||u.status==="aborted")return v;(i.status==="dirty"||u.status==="dirty")&&r.dirty(),c.set(i.value,u.value)}return{status:r.value,value:c}}}};ue.create=(t,e,r)=>new ue({valueType:e,keyType:t,typeName:y.ZodMap,..._(r)});var de=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.set)return m(n,{code:d.invalid_type,expected:p.set,received:n.parsedType}),v;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(m(n,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(m(n,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let a=this._def.valueType;function o(h){let i=new Set;for(let u of h){if(u.status==="aborted")return v;u.status==="dirty"&&r.dirty(),i.add(u.value)}return{status:r.value,value:i}}let c=[...n.data.values()].map((h,i)=>a._parse(new O(n,h,n.path,i)));return n.common.async?Promise.all(c).then(h=>o(h)):o(c)}min(e,r){return new t({...this._def,minSize:{value:e,message:g.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:g.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};de.create=(t,e)=>new de({valueType:t,minSize:null,maxSize:null,typeName:y.ZodSet,..._(e)});var Se=class t extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.function)return m(r,{code:d.invalid_type,expected:p.function,received:r.parsedType}),v;function n(c,h){return Te({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ke(),ge].filter(i=>!!i),issueData:{code:d.invalid_arguments,argumentsError:h}})}function s(c,h){return Te({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ke(),ge].filter(i=>!!i),issueData:{code:d.invalid_return_type,returnTypeError:h}})}let a={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof U){let c=this;return E(async function(...h){let i=new N([]),u=await c._def.args.parseAsync(h,a).catch(b=>{throw i.addIssue(n(h,b)),i}),f=await Reflect.apply(o,this,u);return await c._def.returns._def.type.parseAsync(f,a).catch(b=>{throw i.addIssue(s(f,b)),i})})}else{let c=this;return E(function(...h){let i=c._def.args.safeParse(h,a);if(!i.success)throw new N([n(h,i.error)]);let u=Reflect.apply(o,this,i.data),f=c._def.returns.safeParse(u,a);if(!f.success)throw new N([s(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Z.create(e).rest(L.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||Z.create([]).rest(L.create()),returns:r||L.create(),typeName:y.ZodFunction,..._(n)})}},X=class extends x{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};X.create=(t,e)=>new X({getter:t,typeName:y.ZodLazy,..._(e)});var ee=class extends x{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return m(r,{received:r.data,code:d.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}};ee.create=(t,e)=>new ee({value:t,typeName:y.ZodLiteral,..._(e)});function et(t,e){return new te({values:t,typeName:y.ZodEnum,..._(e)})}var te=class t extends x{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{expected:k.joinValues(n),received:r.parsedType,code:d.invalid_type}),v}if(this._def.values.indexOf(e.data)===-1){let r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{received:r.data,code:d.invalid_enum_value,options:n}),v}return E(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e){return t.create(e)}exclude(e){return t.create(this.options.filter(r=>!e.includes(r)))}};te.create=et;var re=class extends x{_parse(e){let r=k.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==p.string&&n.parsedType!==p.number){let s=k.objectValues(r);return m(n,{expected:k.joinValues(s),received:n.parsedType,code:d.invalid_type}),v}if(r.indexOf(e.data)===-1){let s=k.objectValues(r);return m(n,{received:n.data,code:d.invalid_enum_value,options:s}),v}return E(e.data)}get enum(){return this._def.values}};re.create=(t,e)=>new re({values:t,typeName:y.ZodNativeEnum,..._(e)});var U=class extends x{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.promise&&r.common.async===!1)return m(r,{code:d.invalid_type,expected:p.promise,received:r.parsedType}),v;let n=r.parsedType===p.promise?r.data:Promise.resolve(r.data);return E(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};U.create=(t,e)=>new U({type:t,typeName:y.ZodPromise,..._(e)});var R=class extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:o=>{m(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){let o=s.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(o).then(c=>this._def.schema._parseAsync({data:c,path:n.path,parent:n})):this._def.schema._parseSync({data:o,path:n.path,parent:n})}if(s.type==="refinement"){let o=c=>{let h=s.refinement(c,a);if(n.common.async)return Promise.resolve(h);if(h instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===!1){let c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?v:(c.status==="dirty"&&r.dirty(),o(c.value),{status:r.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?v:(c.status==="dirty"&&r.dirty(),o(c.value).then(()=>({status:r.value,value:c.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ye(o))return o;let c=s.transform(o.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>ye(o)?Promise.resolve(s.transform(o.value,a)).then(c=>({status:r.value,value:c})):o);k.assertNever(s)}};R.create=(t,e,r)=>new R({schema:t,typeName:y.ZodEffects,effect:e,..._(r)});R.createWithPreprocess=(t,e,r)=>new R({schema:e,effect:{type:"preprocess",transform:t},typeName:y.ZodEffects,..._(r)});var j=class extends x{_parse(e){return this._getType(e)===p.undefined?E(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};j.create=(t,e)=>new j({innerType:t,typeName:y.ZodOptional,..._(e)});var V=class extends x{_parse(e){return this._getType(e)===p.null?E(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};V.create=(t,e)=>new V({innerType:t,typeName:y.ZodNullable,..._(e)});var ne=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===p.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ne.create=(t,e)=>new ne({innerType:t,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});var le=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ie(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new N(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new N(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};le.create=(t,e)=>new le({innerType:t,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});var fe=class extends x{_parse(e){if(this._getType(e)!==p.nan){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:p.nan,received:n.parsedType}),v}return{status:"valid",value:e.data}}};fe.create=t=>new fe({typeName:y.ZodNaN,..._(t)});var Ut=Symbol("zod_brand"),Ne=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},ve=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?v:a.status==="dirty"?(r.dirty(),Xe(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?v:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:y.ZodPipeline})}},pe=class extends x{_parse(e){let r=this._def.innerType._parse(e);return ye(r)&&(r.value=Object.freeze(r.value)),r}};pe.create=(t,e)=>new pe({innerType:t,typeName:y.ZodReadonly,..._(e)});var tt=(t,e={},r)=>t?K.create().superRefine((n,s)=>{var a,o;if(!t(n)){let c=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,h=(o=(a=c.fatal)!==null&&a!==void 0?a:r)!==null&&o!==void 0?o:!0,i=typeof c=="string"?{message:c}:c;s.addIssue({code:"custom",...i,fatal:h})}}):K.create(),Dt={object:S.lazycreate},y;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(y||(y={}));var qt=(t,e={message:`Input not instance of ${t.name}`})=>tt(r=>r instanceof t,e),rt=B.create,nt=$.create,$t=fe.create,Wt=W.create,st=F.create,Ft=Y.create,Yt=oe.create,Jt=J.create,Ht=H.create,Gt=K.create,Qt=L.create,Xt=P.create,er=ce.create,tr=M.create,rr=S.create,nr=S.strictCreate,sr=G.create,ar=Ee.create,ir=Q.create,or=Z.create,cr=Ce.create,ur=ue.create,dr=de.create,lr=Se.create,fr=X.create,pr=ee.create,mr=te.create,hr=re.create,gr=U.create,Ge=R.create,yr=j.create,vr=V.create,_r=R.createWithPreprocess,xr=ve.create,wr=()=>rt().optional(),br=()=>nt().optional(),kr=()=>st().optional(),Tr={string:t=>B.create({...t,coerce:!0}),number:t=>$.create({...t,coerce:!0}),boolean:t=>F.create({...t,coerce:!0}),bigint:t=>W.create({...t,coerce:!0}),date:t=>Y.create({...t,coerce:!0})},Ir=v,me=Object.freeze({__proto__:null,defaultErrorMap:ge,setErrorMap:Nt,getErrorMap:ke,makeIssue:Te,EMPTY_PATH:Rt,addIssueToContext:m,ParseStatus:I,INVALID:v,DIRTY:Xe,OK:E,isAborted:Pe,isDirty:Ze,isValid:ye,isAsync:Ie,get util(){return k},get objectUtil(){return je},ZodParsedType:p,getParsedType:z,ZodType:x,ZodString:B,ZodNumber:$,ZodBigInt:W,ZodBoolean:F,ZodDate:Y,ZodSymbol:oe,ZodUndefined:J,ZodNull:H,ZodAny:K,ZodUnknown:L,ZodNever:P,ZodVoid:ce,ZodArray:M,ZodObject:S,ZodUnion:G,ZodDiscriminatedUnion:Ee,ZodIntersection:Q,ZodTuple:Z,ZodRecord:Ce,ZodMap:ue,ZodSet:de,ZodFunction:Se,ZodLazy:X,ZodLiteral:ee,ZodEnum:te,ZodNativeEnum:re,ZodPromise:U,ZodEffects:R,ZodTransformer:R,ZodOptional:j,ZodNullable:V,ZodDefault:ne,ZodCatch:le,ZodNaN:fe,BRAND:Ut,ZodBranded:Ne,ZodPipeline:ve,ZodReadonly:pe,custom:tt,Schema:x,ZodSchema:x,late:Dt,get ZodFirstPartyTypeKind(){return y},coerce:Tr,any:Gt,array:tr,bigint:Wt,boolean:st,date:Ft,discriminatedUnion:ar,effect:Ge,enum:mr,function:lr,instanceof:qt,intersection:ir,lazy:fr,literal:pr,map:ur,nan:$t,nativeEnum:hr,never:Xt,null:Ht,nullable:vr,number:nt,object:rr,oboolean:kr,onumber:br,optional:yr,ostring:wr,pipeline:xr,preprocess:_r,promise:gr,record:cr,set:dr,strictObject:nr,string:rt,symbol:Yt,transformer:Ge,tuple:or,undefined:Jt,union:sr,unknown:Qt,void:er,NEVER:Ir,ZodIssueCode:d,quotelessJson:St,ZodError:N});var Er=me.enum(["true","false"]).transform(t=>t==="true"),D=me.string().min(1),Me=me.object({AUTH_COOKIE_NAME:D.default("alliance-auth"),AUTH_COOKIE_SECRET:D.default("zlLZBlk7wt8lypP5lA4D"),DB_ENDPOINT:D,JWT_PRIVATE_KEY:D.default("MIIEogIBAAKCAQEAsGqOzjnfQtCYlDqhgGAnKuJOCiPt2WpCmL1Cs+SLBQlyoNn6LT8BJ6ZRj8t/vK8Sw0p51Uq/3k0tazh7bLGkWNMBLY3BqFiNRMMnCqHJfvGIUi/itNXNe2kbP7H3rbyQTu4O7yH/ZAMitdpF2KLucVRlFxrQ/ggZjxwEGso4JUnCwmAnoKct/uupKz9Y2PMTr00WWN79aPfD4LcKi570VJqBT3ISSucdwFLYNqnOkQnEa8O8xbthQhiI0k1GGJT+GCQcATUPeEbaCFXonOrJm+CyuMmQWYLFF3NbE5NllU1jz9PYHzp2hAgAx8WGeretTvpEA1dE2gvXNESGbQ8FxQIDAQABAoIBAAjTJmud1348eGAfLV8CRaij2MAxxenJ9/ozVXfcPIa2+fCelsuBSv8pwbYODvNoVT7xpcs2nwccGI6JgnBl09EhqlMWCT7w7GLT2aBy3A/T6JF76xJICQGzDfWPYygMtlyhv0YqZDUjjFlJHun+/ysqIUMY81AR0FLUAEc6yw41ChcdSvTgIqBM9f5PsBRK7zOgdW1vcVQiZbf2Vqr+7wTJ+6b9A4rWnnAqesGDXqYupx3UJEu3x0wRNQB8FeiG9iJrw4cyD9SmM95doTyKosQ2PWWnUO1NMgmWCR/mWcKZAUcfZUpnQ8rz75WAWept8ZIOOdha8UZ1B/kw3EsVdEECgYEA3iN0BRUqMN0J69bazvlNOWtI+Chc1lYMt/tZ4p78pIJpAZvc3rQ9lAp6JvOEno2IglULA4I+ZLUmpz+lfu7XxKMNOI3cnG7WdiGbiIlwOSwuxzeO1FJqhtnc0U6mNkIjptV8b2etj8U2/SXAC3CC8XgsawAj9A/I7awlCL3NXdECgYEAy07gun3rcd3Y0ISmd3+SbAn/MbGf8uRLcfSc2ls9B6m3pXj25prXJWIrB6DyGuL/HQmHzffQkOeXmwFGHFXyiIFOIITX4z8b9lMnavgUZoPDY+ZFsxp6I7vMn75AetB8wYXpOFFeCG/Ck/VSIYP7oAN8kLw8EHdOuNbZYbu34bUCgYBYd14ZOBiZZS4yUlrJ2tc6atOgoNJ4OcTO8LcXXaHYEmenUF9iAf4UGygSoyDJ1CvtW9kLCK+4g7xlFx/dsVkU4qq9PyIA2tNmMHQ0qCedXU8z35huTnRGSDV81gmzyhtQsezgoTWp8Cy6HHKjG6fKasWlx2SKKk8m+Eu3c396QQKBgBMY2asq4M7VU+RiUXCwHwTe+4Wjda7PGvcdTw6Du3vYyVNVxXtr2AG+8uPIjnVQFT6ZApSqToEOAAOjXv6SZDHGU5xiXhUOfIXq0a0OmHv4rIXZv3pPZmGs5k+rA0uGAfH7riiIHBkWxmQ3ivty9lPVgAHobIvvaQmbxNeVVnRxAoGAUzUmcBiUAiODfjulrpYvWG0tCn5B//yk7g1Tm3Chrh9huA1qGEN3jDoqSsTd5k4Yi5foyAZt5ORgoiUVm4IsfS56aoxIco1CtFG3zeMQRy4uKzTsvUTOdsJ4RlQdjNwpngXR44VL0WelgCDqTqJwn5ubzPvuIHuTj3cBpmJCjOo="),JWT_PUBLIC_CSP_KEY:me.string().min(1).default("BgIAAACkAABSU0ExAAgAAAEAAQDFBQ9thkQ01wvaRFcDRPpOrbd6hsXHAAiEdjof2NPPY02VZZMTW3MXxYJZkMm4suCbyeqc6FUI2kZ4DzUBHCQY/pQYRk3SiBhCYbvFvMNrxAmRzqk22FLAHedKEnJPgZpU9J6LCrfgw/do/d5YFk2vE/PYWD8rqev+LaegJ2DCwkklOMoaBByPGQj+0BoXZVRx7qLYRdq1IgNk/yHvDu5OkLyt97E/G2l7zdW04i9SiPF+yaEKJ8NEjViowY0tAdNYpLFsezhrLU3ev0rVeUrDEq+8f8uPUaYnAT8t+tmgcgkFi+SzQr2YQmrZ7SMKTuIqJ2CAoTqUmNBC3znOjmqw"),SERVICE_LOG_LEVEL:me.enum(["silent","fatal","error","warn","info","debug","trace"]).default("trace"),SERVICE_PORT:D.transform(Number).default("3000"),REDIS_HOST:D,REDIS_PASSWORD:D.optional()});var Ve=(n=>(n.TargetUrl="alliance-target-url",n.TargetApp="alliance-target-app",n.TargetWorkspace="alliance-target-workspace",n))(Ve||{});var hn=Me.pick({JWT_PRIVATE_KEY:!0,JWT_PUBLIC_CSP_KEY:!0});function at({privateKey:t,aud:e,sub:r,name:n,user:s,workspace:a,expiration:o="1h"}){return`Bearer ${Cr.sign({iss:"Alliance",aud:e,sub:r,name:n,"https://alliance.teliacompany.net/user_type":s.type,"https://alliance.teliacompany.net/user_email":s.email,"https://alliance.teliacompany.net/user_privileges":s.permissions,"https://alliance.teliacompany.net/workspace":a.slug,"https://alliance.teliacompany.net/workspace_name":a.name,"https://alliance.teliacompany.net/tenant":a.slug,"https://alliance.teliacompany.net/tenant_name":a.name},t,{expiresIn:o,algorithm:"RS256"})}`}function ze(t){return`-----BEGIN RSA PRIVATE KEY-----
|
|
2
|
-
`+
|
|
3
|
-
-----END RSA PRIVATE KEY-----`}function
|
|
4
|
-
`,"")}import{homedir as Jr,tmpdir as Hr}from"node:os";import{resolve as Gr}from"node:path";var Ar=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,jr=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,Pr=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function Zr(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){Lr(t);return}return e}function Lr(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function _e(t,e={}){if(typeof t!="string")return t;let r=t.trim();if(t[0]==='"'&&t.at(-1)==='"'&&!t.includes("\\"))return r.slice(1,-1);if(r.length<=9){let n=r.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;if(n==="undefined")return;if(n==="null")return null;if(n==="nan")return Number.NaN;if(n==="infinity")return Number.POSITIVE_INFINITY;if(n==="-infinity")return Number.NEGATIVE_INFINITY}if(!Pr.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(Ar.test(t)||jr.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,Zr)}return JSON.parse(t)}catch(n){if(e.strict)throw n;return t}}function Mr(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function T(t,...e){try{return Mr(t(...e))}catch(r){return Promise.reject(r)}}function Vr(t){let e=typeof t;return t===null||e!=="object"&&e!=="function"}function zr(t){let e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function xe(t){if(Vr(t))return String(t);if(zr(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return xe(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function it(){if(typeof Buffer===void 0)throw new TypeError("[unstorage] Buffer is not supported!")}var Be="base64:";function ot(t){if(typeof t=="string")return t;it();let e=Buffer.from(t).toString("base64");return Be+e}function ct(t){return typeof t!="string"||!t.startsWith(Be)?t:(it(),Buffer.from(t.slice(Be.length),"base64"))}var Br=["hasItem","getItem","getItemRaw","setItem","setItemRaw","removeItem","getMeta","setMeta","removeMeta","getKeys","clear","mount","unmount"];function Ke(t,e){if(e=he(e),!e)return t;let r={...t};for(let n of Br)r[n]=(s="",...a)=>t[n](e+s,...a);return r.getKeys=(n="",...s)=>t.getKeys(e+n,...s).then(a=>a.map(o=>o.slice(e.length))),r}function C(t){return t?t.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function ut(...t){return C(t.join(":"))}function he(t){return t=C(t),t?t+":":""}var Kr="memory",Ur=()=>{let t=new Map;return{name:Kr,options:{},hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,r){t.set(e,r)},setItemRaw(e,r){t.set(e,r)},removeItem(e){t.delete(e)},getKeys(){return Array.from(t.keys())},clear(){t.clear()},dispose(){t.clear()}}};function ft(t={}){let e={mounts:{"":t.driver||Ur()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=i=>{for(let u of e.mountpoints)if(i.startsWith(u))return{base:u,relativeKey:i.slice(u.length),driver:e.mounts[u]};return{base:"",relativeKey:i,driver:e.mounts[""]}},n=(i,u)=>e.mountpoints.filter(f=>f.startsWith(i)||u&&i.startsWith(f)).map(f=>({relativeBase:i.length>f.length?i.slice(f.length):void 0,mountpoint:f,driver:e.mounts[f]})),s=(i,u)=>{if(e.watching){u=C(u);for(let f of e.watchListeners)f(i,u)}},a=async()=>{if(!e.watching){e.watching=!0;for(let i in e.mounts)e.unwatch[i]=await dt(e.mounts[i],s,i)}},o=async()=>{if(e.watching){for(let i in e.unwatch)await e.unwatch[i]();e.unwatch={},e.watching=!1}},c=(i,u,f)=>{let l=new Map,b=w=>{let A=l.get(w.base);return A||(A={driver:w.driver,base:w.base,items:[]},l.set(w.base,A)),A};for(let w of i){let A=typeof w=="string",we=C(A?w:w.key),q=A?void 0:w.value,Oe=A||!w.options?u:{...u,...w.options},Je=r(we);b(Je).items.push({key:we,value:q,relativeKey:Je.relativeKey,options:Oe})}return Promise.all([...l.values()].map(w=>f(w))).then(w=>w.flat())},h={hasItem(i,u={}){i=C(i);let{relativeKey:f,driver:l}=r(i);return T(l.hasItem,f,u)},getItem(i,u={}){i=C(i);let{relativeKey:f,driver:l}=r(i);return T(l.getItem,f,u).then(b=>_e(b))},getItems(i,u){return c(i,u,f=>f.driver.getItems?T(f.driver.getItems,f.items.map(l=>({key:l.relativeKey,options:l.options})),u).then(l=>l.map(b=>({key:ut(f.base,b.key),value:_e(b.value)}))):Promise.all(f.items.map(l=>T(f.driver.getItem,l.relativeKey,l.options).then(b=>({key:l.key,value:_e(b)})))))},getItemRaw(i,u={}){i=C(i);let{relativeKey:f,driver:l}=r(i);return l.getItemRaw?T(l.getItemRaw,f,u):T(l.getItem,f,u).then(b=>ct(b))},async setItem(i,u,f={}){if(u===void 0)return h.removeItem(i);i=C(i);let{relativeKey:l,driver:b}=r(i);b.setItem&&(await T(b.setItem,l,xe(u),f),b.watch||s("update",i))},async setItems(i,u){await c(i,u,async f=>{f.driver.setItems&&await T(f.driver.setItems,f.items.map(l=>({key:l.relativeKey,value:xe(l.value),options:l.options})),u),f.driver.setItem&&await Promise.all(f.items.map(l=>T(f.driver.setItem,l.relativeKey,xe(l.value),l.options)))})},async setItemRaw(i,u,f={}){if(u===void 0)return h.removeItem(i,f);i=C(i);let{relativeKey:l,driver:b}=r(i);if(b.setItemRaw)await T(b.setItemRaw,l,u,f);else if(b.setItem)await T(b.setItem,l,ot(u),f);else return;b.watch||s("update",i)},async removeItem(i,u={}){typeof u=="boolean"&&(u={removeMeta:u}),i=C(i);let{relativeKey:f,driver:l}=r(i);l.removeItem&&(await T(l.removeItem,f,u),(u.removeMeta||u.removeMata)&&await T(l.removeItem,f+"$",u),l.watch||s("remove",i))},async getMeta(i,u={}){typeof u=="boolean"&&(u={nativeOnly:u}),i=C(i);let{relativeKey:f,driver:l}=r(i),b=Object.create(null);if(l.getMeta&&Object.assign(b,await T(l.getMeta,f,u)),!u.nativeOnly){let w=await T(l.getItem,f+"$",u).then(A=>_e(A));w&&typeof w=="object"&&(typeof w.atime=="string"&&(w.atime=new Date(w.atime)),typeof w.mtime=="string"&&(w.mtime=new Date(w.mtime)),Object.assign(b,w))}return b},setMeta(i,u,f={}){return this.setItem(i+"$",u,f)},removeMeta(i,u={}){return this.removeItem(i+"$",u)},async getKeys(i,u={}){i=he(i);let f=n(i,!0),l=[],b=[];for(let w of f){let we=(await T(w.driver.getKeys,w.relativeBase,u)).map(q=>w.mountpoint+C(q)).filter(q=>!l.some(Oe=>q.startsWith(Oe)));b.push(...we),l=[w.mountpoint,...l.filter(q=>!q.startsWith(w.mountpoint))]}return i?b.filter(w=>w.startsWith(i)&&!w.endsWith("$")):b.filter(w=>!w.endsWith("$"))},async clear(i,u={}){i=he(i),await Promise.all(n(i,!1).map(async f=>{if(f.driver.clear)return T(f.driver.clear,f.relativeBase,u);if(f.driver.removeItem){let l=await f.driver.getKeys(f.relativeBase||"",u);return Promise.all(l.map(b=>f.driver.removeItem(b,u)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(i=>lt(i)))},async watch(i){return await a(),e.watchListeners.push(i),async()=>{e.watchListeners=e.watchListeners.filter(u=>u!==i),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(i,u){if(i=he(i),i&&e.mounts[i])throw new Error(`already mounted at ${i}`);return i&&(e.mountpoints.push(i),e.mountpoints.sort((f,l)=>l.length-f.length)),e.mounts[i]=u,e.watching&&Promise.resolve(dt(u,s,i)).then(f=>{e.unwatch[i]=f}).catch(console.error),h},async unmount(i,u=!0){i=he(i),!(!i||!e.mounts[i])&&(e.watching&&i in e.unwatch&&(e.unwatch[i](),delete e.unwatch[i]),u&&await lt(e.mounts[i]),e.mountpoints=e.mountpoints.filter(f=>f!==i),delete e.mounts[i])},getMount(i=""){i=C(i)+":";let u=r(i);return{driver:u.driver,base:u.base}},getMounts(i="",u={}){return i=C(i),n(i,u.parents).map(l=>({driver:l.driver,base:l.mountpoint}))}};return h}function dt(t,e,r){return t.watch?t.watch((n,s)=>e(n,r+s)):()=>{}}async function lt(t){typeof t.dispose=="function"&&await T(t.dispose)}import{existsSync as qr,promises as $r}from"fs";import{resolve as Wr,join as Fr}from"path";function Re(t,e,r){return new Error(`[unstorage] [${t}] ${e}`,r)}function pt(t,e){return Array.isArray(e)?Re(t,`Missing some of the required options ${e.map(r=>"`"+r+"`").join(", ")}`):Re(t,`Missing required option \`${e}\`.`)}import{existsSync as Dr,promises as se}from"fs";import{resolve as ht,dirname as gt}from"path";function Ue(t){return t.code==="ENOENT"||t.code==="EISDIR"?null:t}function mt(t){return t.code==="EEXIST"?null:t}async function De(t,e,r){return await _t(gt(t)),se.writeFile(t,e,r)}function qe(t,e){return se.readFile(t,e).catch(Ue)}function yt(t){return se.unlink(t).catch(Ue)}function vt(t){return se.readdir(t,{withFileTypes:!0}).catch(Ue).then(e=>e||[])}async function _t(t){Dr(t)||(await _t(gt(t)).catch(mt),await se.mkdir(t).catch(mt))}async function $e(t,e){if(e&&e(t))return[];let r=await vt(t),n=[];return await Promise.all(r.map(async s=>{let a=ht(t,s.name);if(s.isDirectory()){let o=await $e(a,e);n.push(...o.map(c=>s.name+"/"+c))}else e&&e(s.name)||n.push(s.name)})),n}async function We(t){let e=await vt(t);await Promise.all(e.map(r=>{let n=ht(t,r.name);return r.isDirectory()?We(n).then(()=>se.rmdir(n)):se.unlink(n)}))}var Yr=/\.\.\:|\.\.$/,Fe="fs-lite",xt=(t={})=>{if(!t.base)throw pt(Fe,"base");t.base=Wr(t.base);let e=r=>{if(Yr.test(r))throw Re(Fe,`Invalid key: ${JSON.stringify(r)}. It should not contain .. segments`);return Fr(t.base,r.replace(/:/g,"/"))};return{name:Fe,options:t,hasItem(r){return qr(e(r))},getItem(r){return qe(e(r),"utf8")},getItemRaw(r){return qe(e(r))},async getMeta(r){let{atime:n,mtime:s,size:a,birthtime:o,ctime:c}=await $r.stat(e(r)).catch(()=>({}));return{atime:n,mtime:s,size:a,birthtime:o,ctime:c}},setItem(r,n){if(!t.readOnly)return De(e(r),n,"utf8")},setItemRaw(r,n){if(!t.readOnly)return De(e(r),n)},removeItem(r){if(!t.readOnly)return yt(e(r))},getKeys(){return $e(e("."),t.ignore)},async clear(){t.readOnly||t.noClear||await We(e("."))}}};function Qr({prefix:t,logger:e}){return Ke(ft({driver:xt({base:Xr({logger:e})})}),t)}function Xr({logger:t}){let e="";try{e=Jr()}catch(r){t.error("could not use homedir, trying tmpdir",{error:r?.message})}if(!e)try{e=Hr()}catch(r){t.error("could not use tmpdir, trying process.cwd",{error:r?.message})}if(!e)try{e=process.cwd()}catch(r){t.error("could not use process.cwd, exiting",{error:r?.message}),process.exit(1)}return Gr(e,".alliance")}import en from"pino";function ae(t){return e=>(r,n)=>t[e]({...n,msg:r})}function wt(t){let e=en({level:t.SERVICE_LOG_LEVEL,redact:["authorization","headers.authorization","req.headers.authorization","res.headers.authorization","req.headers.cookie",'res.headers["set-cookie"]']});return{fatal:ae(e)("fatal"),error:ae(e)("error"),warn:ae(e)("warn"),info:ae(e)("info"),debug:ae(e)("debug"),trace:ae(e)("trace"),silent:ae(e)("silent"),child:()=>wt(t),level:t.SERVICE_LOG_LEVEL}}function tn(t){return(e,r,n)=>(t.trace("received request",{url:e.url,params:e.params,query:e.query,body:e.body}),n())}var bt=(l=>(l[l.NoObjectId=10001]="NoObjectId",l[l.NoTargetAppHeader=10002]="NoTargetAppHeader",l[l.NoTargetWorkspaceHeader=10003]="NoTargetWorkspaceHeader",l[l.NoManifest=10006]="NoManifest",l[l.NoRequestContext=10007]="NoRequestContext",l[l.NoUserInRequestContext=10008]="NoUserInRequestContext",l[l.NoAppInRequestContext=10009]="NoAppInRequestContext",l[l.NoWorkspaceInRequestContext=10010]="NoWorkspaceInRequestContext",l[l.NoUserPermissionsInRequestContext=10012]="NoUserPermissionsInRequestContext",l[l.WorkspacePermissionDenied=10013]="WorkspacePermissionDenied",l[l.NoTargetUrlHeader=10014]="NoTargetUrlHeader",l[l.NoSessionInRedisCache=10015]="NoSessionInRedisCache",l))(bt||{}),kt=(s=>(s[s.NoPublicKey=11e3]="NoPublicKey",s[s.NoAuthHeader=11001]="NoAuthHeader",s[s.FailedFileUpload=11002]="FailedFileUpload",s[s.FailedFileDownload=11003]="FailedFileDownload",s))(kt||{});var Tt={10001:{statusCode:401,msg:"No object id available on authenticated user."},10002:{statusCode:400,msg:"Request missing header 'alliance-target-app'."},10003:{statusCode:400,msg:"Request missing header 'alliance-target-workspace'."},10014:{statusCode:400,msg:"Request missing header 'alliance-target-url'."},10015:{statusCode:401,msg:"Could not find user session in Redis server."},10006:{statusCode:500,msg:"Could not find manifest for app '{{appSlug}}'."},10007:{statusCode:500,msg:"No request context."},10008:{statusCode:500,msg:"No user in request context."},10009:{statusCode:500,msg:"No app in request context."},10010:{statusCode:500,msg:"No workspace in request context."},10012:{statusCode:500,msg:"No user permissions in request context."},10013:{statusCode:403,msg:"User does not have access to the current workspace."},11e3:{statusCode:401,msg:"No public key available to decode JWT."},11001:{statusCode:401,msg:"No authorization header found."},11002:{statusCode:500,msg:"Something went wrong when trying to upload a file to the S3 storage."},11003:{statusCode:500,msg:"Something went wrong when trying to download a file to the S3 storage."},12e3:{statusCode:401,msg:"No object id found in user claims."}};var Ye=class extends Error{constructor(r,n={}){let{msg:s,statusCode:a}=Tt[r],o=rn(s,n);super(o);this.errorCode=r;this.message=o,this.statusCode=a,this.info=`https://github.com/telia-company/ace-alliance-sdk/wiki/error-codes#${this.errorCode}`}info;statusCode};function rn(t,e){return Object.entries(e).reduce((r,[n,s])=>r.replaceAll(`{{${n}}}`,s),t)}function nn(t){return(e,r,n,s)=>{let a={cause:e.cause,message:e.message,status:e.status||e.statusCode||e.code,info:e.info};return t.error("error when processing request",{url:r.url,body:r.body,error:a}),n.status(a.status).json(a)}}export{Ye as AllianceError,Ve as AllianceHeaders,kt as DataErrorCode,bt as GatewayErrorCode,at as createBearerToken,Qr as createFileStorage,Et as createIndexHtml,wt as createLogger,Rr as createPublicKeys,Nr as createSystemUserToken,Ct as getAppManifests,Or as getCleanPublicKey,ze as getPrivateKey,nn as requestErrorHandler,tn as requestLoggerHandler,It as slugify,Er as zBooleanEnum,D as zNonEmptyString,Me as zSharedConfig};
|
|
1
|
+
import{a as E,b as ue,c as ce,d as le}from"./chunk-UNKGNXJ3.js";import"./chunk-26VIM55J.js";import"./chunk-JG7V63GM.js";import pe from"jsonwebtoken";import{createPublicKey as fe}from"node:crypto";var me=E.enum(["true","false"]).transform(e=>e==="true"),y=E.string().min(1),T=E.object({AUTH_COOKIE_NAME:y.default("alliance-auth"),AUTH_COOKIE_SECRET:y.default("zlLZBlk7wt8lypP5lA4D"),DB_ENDPOINT:y,JWT_PRIVATE_KEY:y.default("MIIEogIBAAKCAQEAsGqOzjnfQtCYlDqhgGAnKuJOCiPt2WpCmL1Cs+SLBQlyoNn6LT8BJ6ZRj8t/vK8Sw0p51Uq/3k0tazh7bLGkWNMBLY3BqFiNRMMnCqHJfvGIUi/itNXNe2kbP7H3rbyQTu4O7yH/ZAMitdpF2KLucVRlFxrQ/ggZjxwEGso4JUnCwmAnoKct/uupKz9Y2PMTr00WWN79aPfD4LcKi570VJqBT3ISSucdwFLYNqnOkQnEa8O8xbthQhiI0k1GGJT+GCQcATUPeEbaCFXonOrJm+CyuMmQWYLFF3NbE5NllU1jz9PYHzp2hAgAx8WGeretTvpEA1dE2gvXNESGbQ8FxQIDAQABAoIBAAjTJmud1348eGAfLV8CRaij2MAxxenJ9/ozVXfcPIa2+fCelsuBSv8pwbYODvNoVT7xpcs2nwccGI6JgnBl09EhqlMWCT7w7GLT2aBy3A/T6JF76xJICQGzDfWPYygMtlyhv0YqZDUjjFlJHun+/ysqIUMY81AR0FLUAEc6yw41ChcdSvTgIqBM9f5PsBRK7zOgdW1vcVQiZbf2Vqr+7wTJ+6b9A4rWnnAqesGDXqYupx3UJEu3x0wRNQB8FeiG9iJrw4cyD9SmM95doTyKosQ2PWWnUO1NMgmWCR/mWcKZAUcfZUpnQ8rz75WAWept8ZIOOdha8UZ1B/kw3EsVdEECgYEA3iN0BRUqMN0J69bazvlNOWtI+Chc1lYMt/tZ4p78pIJpAZvc3rQ9lAp6JvOEno2IglULA4I+ZLUmpz+lfu7XxKMNOI3cnG7WdiGbiIlwOSwuxzeO1FJqhtnc0U6mNkIjptV8b2etj8U2/SXAC3CC8XgsawAj9A/I7awlCL3NXdECgYEAy07gun3rcd3Y0ISmd3+SbAn/MbGf8uRLcfSc2ls9B6m3pXj25prXJWIrB6DyGuL/HQmHzffQkOeXmwFGHFXyiIFOIITX4z8b9lMnavgUZoPDY+ZFsxp6I7vMn75AetB8wYXpOFFeCG/Ck/VSIYP7oAN8kLw8EHdOuNbZYbu34bUCgYBYd14ZOBiZZS4yUlrJ2tc6atOgoNJ4OcTO8LcXXaHYEmenUF9iAf4UGygSoyDJ1CvtW9kLCK+4g7xlFx/dsVkU4qq9PyIA2tNmMHQ0qCedXU8z35huTnRGSDV81gmzyhtQsezgoTWp8Cy6HHKjG6fKasWlx2SKKk8m+Eu3c396QQKBgBMY2asq4M7VU+RiUXCwHwTe+4Wjda7PGvcdTw6Du3vYyVNVxXtr2AG+8uPIjnVQFT6ZApSqToEOAAOjXv6SZDHGU5xiXhUOfIXq0a0OmHv4rIXZv3pPZmGs5k+rA0uGAfH7riiIHBkWxmQ3ivty9lPVgAHobIvvaQmbxNeVVnRxAoGAUzUmcBiUAiODfjulrpYvWG0tCn5B//yk7g1Tm3Chrh9huA1qGEN3jDoqSsTd5k4Yi5foyAZt5ORgoiUVm4IsfS56aoxIco1CtFG3zeMQRy4uKzTsvUTOdsJ4RlQdjNwpngXR44VL0WelgCDqTqJwn5ubzPvuIHuTj3cBpmJCjOo="),JWT_PUBLIC_CSP_KEY:E.string().min(1).default("BgIAAACkAABSU0ExAAgAAAEAAQDFBQ9thkQ01wvaRFcDRPpOrbd6hsXHAAiEdjof2NPPY02VZZMTW3MXxYJZkMm4suCbyeqc6FUI2kZ4DzUBHCQY/pQYRk3SiBhCYbvFvMNrxAmRzqk22FLAHedKEnJPgZpU9J6LCrfgw/do/d5YFk2vE/PYWD8rqev+LaegJ2DCwkklOMoaBByPGQj+0BoXZVRx7qLYRdq1IgNk/yHvDu5OkLyt97E/G2l7zdW04i9SiPF+yaEKJ8NEjViowY0tAdNYpLFsezhrLU3ev0rVeUrDEq+8f8uPUaYnAT8t+tmgcgkFi+SzQr2YQmrZ7SMKTuIqJ2CAoTqUmNBC3znOjmqw"),SERVICE_LOG_LEVEL:E.enum(["silent","fatal","error","warn","info","debug","trace"]).default("trace"),SERVICE_PORT:y.transform(Number).default("3000"),REDIS_HOST:y,REDIS_PASSWORD:y.optional()});var K=(u=>(u.TargetUrl="alliance-target-url",u.TargetApp="alliance-target-app",u.TargetWorkspace="alliance-target-workspace",u))(K||{});var Xe=T.pick({JWT_PRIVATE_KEY:!0,JWT_PUBLIC_CSP_KEY:!0});function j({privateKey:e,aud:t,sub:n,name:u,user:c,workspace:m,expiration:g="1h"}){return`Bearer ${pe.sign({iss:"Alliance",aud:t,sub:n,name:u,"https://alliance.teliacompany.net/user_type":c.type,"https://alliance.teliacompany.net/user_email":c.email,"https://alliance.teliacompany.net/user_privileges":c.permissions,"https://alliance.teliacompany.net/workspace":m.slug,"https://alliance.teliacompany.net/workspace_name":m.name,"https://alliance.teliacompany.net/tenant":m.slug,"https://alliance.teliacompany.net/tenant_name":m.name},e,{expiresIn:g,algorithm:"RS256"})}`}function L(e){return`-----BEGIN RSA PRIVATE KEY-----
|
|
2
|
+
`+e.JWT_PRIVATE_KEY+`
|
|
3
|
+
-----END RSA PRIVATE KEY-----`}function ge(e){return j({aud:"system",sub:"system",name:"system",workspace:{slug:"system",name:"system"},user:{type:"system",permissions:[],email:"system"},privateKey:L(e)})}function de(e){let t=L(e),n=fe(t);return{pkcs:n.export({type:"pkcs1",format:"pem"}).toString().trim(),spki:n.export({type:"spki",format:"pem"}).toString().trim(),csp:e.JWT_PUBLIC_CSP_KEY}}function ye(e,t){return t[e].replace("-----BEGIN RSA PUBLIC KEY-----","").replace("-----END RSA PUBLIC KEY-----","").replace("-----BEGIN PUBLIC KEY-----","").replace("-----END PUBLIC KEY-----","").trim().replaceAll(`
|
|
4
|
+
`,"")}import{homedir as Oe,tmpdir as ze}from"node:os";import{resolve as Fe}from"node:path";var he=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,Ie=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,ve=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function we(e,t){if(e==="__proto__"||e==="constructor"&&t&&typeof t=="object"&&"prototype"in t){Ee(e);return}return t}function Ee(e){console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`)}function C(e,t={}){if(typeof e!="string")return e;let n=e.trim();if(e[0]==='"'&&e.at(-1)==='"'&&!e.includes("\\"))return n.slice(1,-1);if(n.length<=9){let u=n.toLowerCase();if(u==="true")return!0;if(u==="false")return!1;if(u==="undefined")return;if(u==="null")return null;if(u==="nan")return Number.NaN;if(u==="infinity")return Number.POSITIVE_INFINITY;if(u==="-infinity")return Number.NEGATIVE_INFINITY}if(!ve.test(e)){if(t.strict)throw new SyntaxError("[destr] Invalid JSON");return e}try{if(he.test(e)||Ie.test(e)){if(t.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(e,we)}return JSON.parse(e)}catch(u){if(t.strict)throw u;return e}}function xe(e){return!e||typeof e.then!="function"?Promise.resolve(e):e}function p(e,...t){try{return xe(e(...t))}catch(n){return Promise.reject(n)}}function Ce(e){let t=typeof e;return e===null||t!=="object"&&t!=="function"}function Ae(e){let t=Object.getPrototypeOf(e);return!t||t.isPrototypeOf(Object)}function A(e){if(Ce(e))return String(e);if(Ae(e)||Array.isArray(e))return JSON.stringify(e);if(typeof e.toJSON=="function")return A(e.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function M(){if(typeof Buffer===void 0)throw new TypeError("[unstorage] Buffer is not supported!")}var b="base64:";function V(e){if(typeof e=="string")return e;M();let t=Buffer.from(e).toString("base64");return b+t}function Y(e){return typeof e!="string"||!e.startsWith(b)?e:(M(),Buffer.from(e.slice(b.length),"base64"))}var Se=["hasItem","getItem","getItemRaw","setItem","setItemRaw","removeItem","getMeta","setMeta","removeMeta","getKeys","clear","mount","unmount"];function B(e,t){if(t=x(t),!t)return e;let n={...e};for(let u of Se)n[u]=(c="",...m)=>e[u](t+c,...m);return n.getKeys=(u="",...c)=>e.getKeys(t+u,...c).then(m=>m.map(g=>g.slice(t.length))),n}function f(e){return e?e.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function D(...e){return f(e.join(":"))}function x(e){return e=f(e),e?e+":":""}var Re="memory",Ne=()=>{let e=new Map;return{name:Re,options:{},hasItem(t){return e.has(t)},getItem(t){return e.get(t)??null},getItemRaw(t){return e.get(t)??null},setItem(t,n){e.set(t,n)},setItemRaw(t,n){e.set(t,n)},removeItem(t){e.delete(t)},getKeys(){return Array.from(e.keys())},clear(){e.clear()},dispose(){e.clear()}}};function Q(e={}){let t={mounts:{"":e.driver||Ne()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},n=r=>{for(let o of t.mountpoints)if(r.startsWith(o))return{base:o,relativeKey:r.slice(o.length),driver:t.mounts[o]};return{base:"",relativeKey:r,driver:t.mounts[""]}},u=(r,o)=>t.mountpoints.filter(s=>s.startsWith(r)||o&&r.startsWith(s)).map(s=>({relativeBase:r.length>s.length?r.slice(s.length):void 0,mountpoint:s,driver:t.mounts[s]})),c=(r,o)=>{if(t.watching){o=f(o);for(let s of t.watchListeners)s(r,o)}},m=async()=>{if(!t.watching){t.watching=!0;for(let r in t.mounts)t.unwatch[r]=await J(t.mounts[r],c,r)}},g=async()=>{if(t.watching){for(let r in t.unwatch)await t.unwatch[r]();t.unwatch={},t.watching=!1}},h=(r,o,s)=>{let a=new Map,i=l=>{let d=a.get(l.base);return d||(d={driver:l.driver,base:l.base,items:[]},a.set(l.base,d)),d};for(let l of r){let d=typeof l=="string",R=f(d?l:l.key),I=d?void 0:l.value,P=d||!l.options?o:{...o,...l.options},W=n(R);i(W).items.push({key:R,value:I,relativeKey:W.relativeKey,options:P})}return Promise.all([...a.values()].map(l=>s(l))).then(l=>l.flat())},S={hasItem(r,o={}){r=f(r);let{relativeKey:s,driver:a}=n(r);return p(a.hasItem,s,o)},getItem(r,o={}){r=f(r);let{relativeKey:s,driver:a}=n(r);return p(a.getItem,s,o).then(i=>C(i))},getItems(r,o){return h(r,o,s=>s.driver.getItems?p(s.driver.getItems,s.items.map(a=>({key:a.relativeKey,options:a.options})),o).then(a=>a.map(i=>({key:D(s.base,i.key),value:C(i.value)}))):Promise.all(s.items.map(a=>p(s.driver.getItem,a.relativeKey,a.options).then(i=>({key:a.key,value:C(i)})))))},getItemRaw(r,o={}){r=f(r);let{relativeKey:s,driver:a}=n(r);return a.getItemRaw?p(a.getItemRaw,s,o):p(a.getItem,s,o).then(i=>Y(i))},async setItem(r,o,s={}){if(o===void 0)return S.removeItem(r);r=f(r);let{relativeKey:a,driver:i}=n(r);i.setItem&&(await p(i.setItem,a,A(o),s),i.watch||c("update",r))},async setItems(r,o){await h(r,o,async s=>{s.driver.setItems&&await p(s.driver.setItems,s.items.map(a=>({key:a.relativeKey,value:A(a.value),options:a.options})),o),s.driver.setItem&&await Promise.all(s.items.map(a=>p(s.driver.setItem,a.relativeKey,A(a.value),a.options)))})},async setItemRaw(r,o,s={}){if(o===void 0)return S.removeItem(r,s);r=f(r);let{relativeKey:a,driver:i}=n(r);if(i.setItemRaw)await p(i.setItemRaw,a,o,s);else if(i.setItem)await p(i.setItem,a,V(o),s);else return;i.watch||c("update",r)},async removeItem(r,o={}){typeof o=="boolean"&&(o={removeMeta:o}),r=f(r);let{relativeKey:s,driver:a}=n(r);a.removeItem&&(await p(a.removeItem,s,o),(o.removeMeta||o.removeMata)&&await p(a.removeItem,s+"$",o),a.watch||c("remove",r))},async getMeta(r,o={}){typeof o=="boolean"&&(o={nativeOnly:o}),r=f(r);let{relativeKey:s,driver:a}=n(r),i=Object.create(null);if(a.getMeta&&Object.assign(i,await p(a.getMeta,s,o)),!o.nativeOnly){let l=await p(a.getItem,s+"$",o).then(d=>C(d));l&&typeof l=="object"&&(typeof l.atime=="string"&&(l.atime=new Date(l.atime)),typeof l.mtime=="string"&&(l.mtime=new Date(l.mtime)),Object.assign(i,l))}return i},setMeta(r,o,s={}){return this.setItem(r+"$",o,s)},removeMeta(r,o={}){return this.removeItem(r+"$",o)},async getKeys(r,o={}){r=x(r);let s=u(r,!0),a=[],i=[];for(let l of s){let R=(await p(l.driver.getKeys,l.relativeBase,o)).map(I=>l.mountpoint+f(I)).filter(I=>!a.some(P=>I.startsWith(P)));i.push(...R),a=[l.mountpoint,...a.filter(I=>!I.startsWith(l.mountpoint))]}return r?i.filter(l=>l.startsWith(r)&&!l.endsWith("$")):i.filter(l=>!l.endsWith("$"))},async clear(r,o={}){r=x(r),await Promise.all(u(r,!1).map(async s=>{if(s.driver.clear)return p(s.driver.clear,s.relativeBase,o);if(s.driver.removeItem){let a=await s.driver.getKeys(s.relativeBase||"",o);return Promise.all(a.map(i=>s.driver.removeItem(i,o)))}}))},async dispose(){await Promise.all(Object.values(t.mounts).map(r=>H(r)))},async watch(r){return await m(),t.watchListeners.push(r),async()=>{t.watchListeners=t.watchListeners.filter(o=>o!==r),t.watchListeners.length===0&&await g()}},async unwatch(){t.watchListeners=[],await g()},mount(r,o){if(r=x(r),r&&t.mounts[r])throw new Error(`already mounted at ${r}`);return r&&(t.mountpoints.push(r),t.mountpoints.sort((s,a)=>a.length-s.length)),t.mounts[r]=o,t.watching&&Promise.resolve(J(o,c,r)).then(s=>{t.unwatch[r]=s}).catch(console.error),S},async unmount(r,o=!0){r=x(r),!(!r||!t.mounts[r])&&(t.watching&&r in t.unwatch&&(t.unwatch[r](),delete t.unwatch[r]),o&&await H(t.mounts[r]),t.mountpoints=t.mountpoints.filter(s=>s!==r),delete t.mounts[r])},getMount(r=""){r=f(r)+":";let o=n(r);return{driver:o.driver,base:o.base}},getMounts(r="",o={}){return r=f(r),u(r,o.parents).map(a=>({driver:a.driver,base:a.mountpoint}))}};return S}function J(e,t,n){return e.watch?e.watch((u,c)=>t(u,n+c)):()=>{}}async function H(e){typeof e.dispose=="function"&&await p(e.dispose)}import{existsSync as Te,promises as Ke}from"fs";import{resolve as Le,join as be}from"path";function N(e,t,n){return new Error(`[unstorage] [${e}] ${t}`,n)}function G(e,t){return Array.isArray(t)?N(e,`Missing some of the required options ${t.map(n=>"`"+n+"`").join(", ")}`):N(e,`Missing required option \`${t}\`.`)}import{existsSync as Pe,promises as v}from"fs";import{resolve as X,dirname as $}from"path";function O(e){return e.code==="ENOENT"||e.code==="EISDIR"?null:e}function Z(e){return e.code==="EEXIST"?null:e}async function z(e,t,n){return await re($(e)),v.writeFile(e,t,n)}function F(e,t){return v.readFile(e,t).catch(O)}function ee(e){return v.unlink(e).catch(O)}function te(e){return v.readdir(e,{withFileTypes:!0}).catch(O).then(t=>t||[])}async function re(e){Pe(e)||(await re($(e)).catch(Z),await v.mkdir(e).catch(Z))}async function q(e,t){if(t&&t(e))return[];let n=await te(e),u=[];return await Promise.all(n.map(async c=>{let m=X(e,c.name);if(c.isDirectory()){let g=await q(m,t);u.push(...g.map(h=>c.name+"/"+h))}else t&&t(c.name)||u.push(c.name)})),u}async function _(e){let t=await te(e);await Promise.all(t.map(n=>{let u=X(e,n.name);return n.isDirectory()?_(u).then(()=>v.rmdir(u)):v.unlink(u)}))}var Be=/\.\.\:|\.\.$/,k="fs-lite",ne=(e={})=>{if(!e.base)throw G(k,"base");e.base=Le(e.base);let t=n=>{if(Be.test(n))throw N(k,`Invalid key: ${JSON.stringify(n)}. It should not contain .. segments`);return be(e.base,n.replace(/:/g,"/"))};return{name:k,options:e,hasItem(n){return Te(t(n))},getItem(n){return F(t(n),"utf8")},getItemRaw(n){return F(t(n))},async getMeta(n){let{atime:u,mtime:c,size:m,birthtime:g,ctime:h}=await Ke.stat(t(n)).catch(()=>({}));return{atime:u,mtime:c,size:m,birthtime:g,ctime:h}},setItem(n,u){if(!e.readOnly)return z(t(n),u,"utf8")},setItemRaw(n,u){if(!e.readOnly)return z(t(n),u)},removeItem(n){if(!e.readOnly)return ee(t(n))},getKeys(){return q(t("."),e.ignore)},async clear(){e.readOnly||e.noClear||await _(t("."))}}};function qe({prefix:e,logger:t}){return B(Q({driver:ne({base:_e({logger:t})})}),e)}function _e({logger:e}){let t="";try{t=Oe()}catch(n){e.error("could not use homedir, trying tmpdir",{error:n?.message})}if(!t)try{t=ze()}catch(n){e.error("could not use tmpdir, trying process.cwd",{error:n?.message})}if(!t)try{t=process.cwd()}catch(n){e.error("could not use process.cwd, exiting",{error:n?.message}),process.exit(1)}return Fe(t,".alliance")}import ke from"pino";function w(e){return t=>(n,u)=>e[t]({...u,msg:n})}function oe(e){let t=ke({level:e.SERVICE_LOG_LEVEL,redact:["authorization","headers.authorization","req.headers.authorization","res.headers.authorization","req.headers.cookie",'res.headers["set-cookie"]']});return{fatal:w(t)("fatal"),error:w(t)("error"),warn:w(t)("warn"),info:w(t)("info"),debug:w(t)("debug"),trace:w(t)("trace"),silent:w(t)("silent"),child:()=>oe(e),level:e.SERVICE_LOG_LEVEL}}function Ue(e){return(t,n,u)=>(e.trace("received request",{url:t.url,params:t.params,query:t.query,body:t.body}),u())}var se=(i=>(i[i.NoObjectId=10001]="NoObjectId",i[i.NoTargetAppHeader=10002]="NoTargetAppHeader",i[i.NoTargetWorkspaceHeader=10003]="NoTargetWorkspaceHeader",i[i.NoManifest=10006]="NoManifest",i[i.NoRequestContext=10007]="NoRequestContext",i[i.NoUserInRequestContext=10008]="NoUserInRequestContext",i[i.NoAppInRequestContext=10009]="NoAppInRequestContext",i[i.NoWorkspaceInRequestContext=10010]="NoWorkspaceInRequestContext",i[i.NoUserPermissionsInRequestContext=10012]="NoUserPermissionsInRequestContext",i[i.WorkspacePermissionDenied=10013]="WorkspacePermissionDenied",i[i.NoTargetUrlHeader=10014]="NoTargetUrlHeader",i[i.NoSessionInRedisCache=10015]="NoSessionInRedisCache",i[i.ProhibitedTargetDomain=10016]="ProhibitedTargetDomain",i))(se||{}),ie=(c=>(c[c.NoPublicKey=11e3]="NoPublicKey",c[c.NoAuthHeader=11001]="NoAuthHeader",c[c.FailedFileUpload=11002]="FailedFileUpload",c[c.FailedFileDownload=11003]="FailedFileDownload",c))(ie||{});var ae={10001:{statusCode:401,msg:"No object id available on authenticated user."},10002:{statusCode:400,msg:"Request missing header 'alliance-target-app'."},10003:{statusCode:400,msg:"Request missing header 'alliance-target-workspace'."},10014:{statusCode:400,msg:"Request missing header 'alliance-target-url'."},10015:{statusCode:401,msg:"Could not find user session in Redis server."},10006:{statusCode:500,msg:"Could not find manifest for app '{{appSlug}}'."},10007:{statusCode:500,msg:"No request context."},10008:{statusCode:500,msg:"No user in request context."},10009:{statusCode:500,msg:"No app in request context."},10010:{statusCode:500,msg:"No workspace in request context."},10012:{statusCode:500,msg:"No user permissions in request context."},10013:{statusCode:403,msg:"User does not have access to the current workspace."},10016:{statusCode:403,msg:"Request prohibited - REQUEST_DOMAIN_WHITE_LIST does not contain '{{domain}}'."},11e3:{statusCode:401,msg:"No public key available to decode JWT."},11001:{statusCode:401,msg:"No authorization header found."},11002:{statusCode:500,msg:"Something went wrong when trying to upload a file to the S3 storage."},11003:{statusCode:500,msg:"Something went wrong when trying to download a file to the S3 storage."},12e3:{statusCode:401,msg:"No object id found in user claims."}};var U=class extends Error{constructor(n,u={}){let{msg:c,statusCode:m}=ae[n],g=We(c,u);super(g);this.errorCode=n;this.message=g,this.statusCode=m,this.info=`https://github.com/telia-company/ace-alliance-sdk/wiki/error-codes#${this.errorCode}`}info;statusCode};function We(e,t){return Object.entries(t).reduce((n,[u,c])=>n.replaceAll(`{{${u}}}`,c),e)}function je(e){return(t,n,u,c)=>{let m={cause:t.cause,message:t.message,status:t.status||t.statusCode||t.code,info:t.info};return e.error("error when processing request",{url:n.url,body:n.body,error:m}),u.status(m.status).json(m)}}export{U as AllianceError,K as AllianceHeaders,ie as DataErrorCode,se as GatewayErrorCode,j as createBearerToken,qe as createFileStorage,ce as createIndexHtml,oe as createLogger,de as createPublicKeys,ge as createSystemUserToken,le as getAppManifests,ye as getCleanPublicKey,L as getPrivateKey,je as requestErrorHandler,Ue as requestLoggerHandler,ue as slugify,me as zBooleanEnum,y as zNonEmptyString,T as zSharedConfig};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/alliance-internal-node-utilities",
|
|
3
|
-
"version": "1.1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Utilities used internally by packages developed by team Alliance.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Telia Company AB",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"pino": "^8.16.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@telia-ace/alliance-framework": "^1.1.0
|
|
27
|
+
"@telia-ace/alliance-framework": "^1.1.0"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
package/dist/chunk-RKK7CWA6.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import{e as p}from"./chunk-26VIM55J.js";import{a as I,b as O}from"./chunk-JG7V63GM.js";var h=I((f,d)=>{"use strict";(function(a,r,e){typeof f=="object"?(d.exports=e(),d.exports.default=e()):typeof define=="function"&&define.amd?define(e):r[a]=e()})("slugify",f,function(){var a=JSON.parse(`{"$":"dollar","%":"percent","&":"and","<":"less",">":"greater","|":"or","\xA2":"cent","\xA3":"pound","\xA4":"currency","\xA5":"yen","\xA9":"(c)","\xAA":"a","\xAE":"(r)","\xBA":"o","\xC0":"A","\xC1":"A","\xC2":"A","\xC3":"A","\xC4":"A","\xC5":"A","\xC6":"AE","\xC7":"C","\xC8":"E","\xC9":"E","\xCA":"E","\xCB":"E","\xCC":"I","\xCD":"I","\xCE":"I","\xCF":"I","\xD0":"D","\xD1":"N","\xD2":"O","\xD3":"O","\xD4":"O","\xD5":"O","\xD6":"O","\xD8":"O","\xD9":"U","\xDA":"U","\xDB":"U","\xDC":"U","\xDD":"Y","\xDE":"TH","\xDF":"ss","\xE0":"a","\xE1":"a","\xE2":"a","\xE3":"a","\xE4":"a","\xE5":"a","\xE6":"ae","\xE7":"c","\xE8":"e","\xE9":"e","\xEA":"e","\xEB":"e","\xEC":"i","\xED":"i","\xEE":"i","\xEF":"i","\xF0":"d","\xF1":"n","\xF2":"o","\xF3":"o","\xF4":"o","\xF5":"o","\xF6":"o","\xF8":"o","\xF9":"u","\xFA":"u","\xFB":"u","\xFC":"u","\xFD":"y","\xFE":"th","\xFF":"y","\u0100":"A","\u0101":"a","\u0102":"A","\u0103":"a","\u0104":"A","\u0105":"a","\u0106":"C","\u0107":"c","\u010C":"C","\u010D":"c","\u010E":"D","\u010F":"d","\u0110":"DJ","\u0111":"dj","\u0112":"E","\u0113":"e","\u0116":"E","\u0117":"e","\u0118":"e","\u0119":"e","\u011A":"E","\u011B":"e","\u011E":"G","\u011F":"g","\u0122":"G","\u0123":"g","\u0128":"I","\u0129":"i","\u012A":"i","\u012B":"i","\u012E":"I","\u012F":"i","\u0130":"I","\u0131":"i","\u0136":"k","\u0137":"k","\u013B":"L","\u013C":"l","\u013D":"L","\u013E":"l","\u0141":"L","\u0142":"l","\u0143":"N","\u0144":"n","\u0145":"N","\u0146":"n","\u0147":"N","\u0148":"n","\u014C":"O","\u014D":"o","\u0150":"O","\u0151":"o","\u0152":"OE","\u0153":"oe","\u0154":"R","\u0155":"r","\u0158":"R","\u0159":"r","\u015A":"S","\u015B":"s","\u015E":"S","\u015F":"s","\u0160":"S","\u0161":"s","\u0162":"T","\u0163":"t","\u0164":"T","\u0165":"t","\u0168":"U","\u0169":"u","\u016A":"u","\u016B":"u","\u016E":"U","\u016F":"u","\u0170":"U","\u0171":"u","\u0172":"U","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017A":"z","\u017B":"Z","\u017C":"z","\u017D":"Z","\u017E":"z","\u018F":"E","\u0192":"f","\u01A0":"O","\u01A1":"o","\u01AF":"U","\u01B0":"u","\u01C8":"LJ","\u01C9":"lj","\u01CB":"NJ","\u01CC":"nj","\u0218":"S","\u0219":"s","\u021A":"T","\u021B":"t","\u0259":"e","\u02DA":"o","\u0386":"A","\u0388":"E","\u0389":"H","\u038A":"I","\u038C":"O","\u038E":"Y","\u038F":"W","\u0390":"i","\u0391":"A","\u0392":"B","\u0393":"G","\u0394":"D","\u0395":"E","\u0396":"Z","\u0397":"H","\u0398":"8","\u0399":"I","\u039A":"K","\u039B":"L","\u039C":"M","\u039D":"N","\u039E":"3","\u039F":"O","\u03A0":"P","\u03A1":"R","\u03A3":"S","\u03A4":"T","\u03A5":"Y","\u03A6":"F","\u03A7":"X","\u03A8":"PS","\u03A9":"W","\u03AA":"I","\u03AB":"Y","\u03AC":"a","\u03AD":"e","\u03AE":"h","\u03AF":"i","\u03B0":"y","\u03B1":"a","\u03B2":"b","\u03B3":"g","\u03B4":"d","\u03B5":"e","\u03B6":"z","\u03B7":"h","\u03B8":"8","\u03B9":"i","\u03BA":"k","\u03BB":"l","\u03BC":"m","\u03BD":"n","\u03BE":"3","\u03BF":"o","\u03C0":"p","\u03C1":"r","\u03C2":"s","\u03C3":"s","\u03C4":"t","\u03C5":"y","\u03C6":"f","\u03C7":"x","\u03C8":"ps","\u03C9":"w","\u03CA":"i","\u03CB":"y","\u03CC":"o","\u03CD":"y","\u03CE":"w","\u0401":"Yo","\u0402":"DJ","\u0404":"Ye","\u0406":"I","\u0407":"Yi","\u0408":"J","\u0409":"LJ","\u040A":"NJ","\u040B":"C","\u040F":"DZ","\u0410":"A","\u0411":"B","\u0412":"V","\u0413":"G","\u0414":"D","\u0415":"E","\u0416":"Zh","\u0417":"Z","\u0418":"I","\u0419":"J","\u041A":"K","\u041B":"L","\u041C":"M","\u041D":"N","\u041E":"O","\u041F":"P","\u0420":"R","\u0421":"S","\u0422":"T","\u0423":"U","\u0424":"F","\u0425":"H","\u0426":"C","\u0427":"Ch","\u0428":"Sh","\u0429":"Sh","\u042A":"U","\u042B":"Y","\u042C":"","\u042D":"E","\u042E":"Yu","\u042F":"Ya","\u0430":"a","\u0431":"b","\u0432":"v","\u0433":"g","\u0434":"d","\u0435":"e","\u0436":"zh","\u0437":"z","\u0438":"i","\u0439":"j","\u043A":"k","\u043B":"l","\u043C":"m","\u043D":"n","\u043E":"o","\u043F":"p","\u0440":"r","\u0441":"s","\u0442":"t","\u0443":"u","\u0444":"f","\u0445":"h","\u0446":"c","\u0447":"ch","\u0448":"sh","\u0449":"sh","\u044A":"u","\u044B":"y","\u044C":"","\u044D":"e","\u044E":"yu","\u044F":"ya","\u0451":"yo","\u0452":"dj","\u0454":"ye","\u0456":"i","\u0457":"yi","\u0458":"j","\u0459":"lj","\u045A":"nj","\u045B":"c","\u045D":"u","\u045F":"dz","\u0490":"G","\u0491":"g","\u0492":"GH","\u0493":"gh","\u049A":"KH","\u049B":"kh","\u04A2":"NG","\u04A3":"ng","\u04AE":"UE","\u04AF":"ue","\u04B0":"U","\u04B1":"u","\u04BA":"H","\u04BB":"h","\u04D8":"AE","\u04D9":"ae","\u04E8":"OE","\u04E9":"oe","\u0531":"A","\u0532":"B","\u0533":"G","\u0534":"D","\u0535":"E","\u0536":"Z","\u0537":"E'","\u0538":"Y'","\u0539":"T'","\u053A":"JH","\u053B":"I","\u053C":"L","\u053D":"X","\u053E":"C'","\u053F":"K","\u0540":"H","\u0541":"D'","\u0542":"GH","\u0543":"TW","\u0544":"M","\u0545":"Y","\u0546":"N","\u0547":"SH","\u0549":"CH","\u054A":"P","\u054B":"J","\u054C":"R'","\u054D":"S","\u054E":"V","\u054F":"T","\u0550":"R","\u0551":"C","\u0553":"P'","\u0554":"Q'","\u0555":"O''","\u0556":"F","\u0587":"EV","\u0621":"a","\u0622":"aa","\u0623":"a","\u0624":"u","\u0625":"i","\u0626":"e","\u0627":"a","\u0628":"b","\u0629":"h","\u062A":"t","\u062B":"th","\u062C":"j","\u062D":"h","\u062E":"kh","\u062F":"d","\u0630":"th","\u0631":"r","\u0632":"z","\u0633":"s","\u0634":"sh","\u0635":"s","\u0636":"dh","\u0637":"t","\u0638":"z","\u0639":"a","\u063A":"gh","\u0641":"f","\u0642":"q","\u0643":"k","\u0644":"l","\u0645":"m","\u0646":"n","\u0647":"h","\u0648":"w","\u0649":"a","\u064A":"y","\u064B":"an","\u064C":"on","\u064D":"en","\u064E":"a","\u064F":"u","\u0650":"e","\u0652":"","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u067E":"p","\u0686":"ch","\u0698":"zh","\u06A9":"k","\u06AF":"g","\u06CC":"y","\u06F0":"0","\u06F1":"1","\u06F2":"2","\u06F3":"3","\u06F4":"4","\u06F5":"5","\u06F6":"6","\u06F7":"7","\u06F8":"8","\u06F9":"9","\u0E3F":"baht","\u10D0":"a","\u10D1":"b","\u10D2":"g","\u10D3":"d","\u10D4":"e","\u10D5":"v","\u10D6":"z","\u10D7":"t","\u10D8":"i","\u10D9":"k","\u10DA":"l","\u10DB":"m","\u10DC":"n","\u10DD":"o","\u10DE":"p","\u10DF":"zh","\u10E0":"r","\u10E1":"s","\u10E2":"t","\u10E3":"u","\u10E4":"f","\u10E5":"k","\u10E6":"gh","\u10E7":"q","\u10E8":"sh","\u10E9":"ch","\u10EA":"ts","\u10EB":"dz","\u10EC":"ts","\u10ED":"ch","\u10EE":"kh","\u10EF":"j","\u10F0":"h","\u1E62":"S","\u1E63":"s","\u1E80":"W","\u1E81":"w","\u1E82":"W","\u1E83":"w","\u1E84":"W","\u1E85":"w","\u1E9E":"SS","\u1EA0":"A","\u1EA1":"a","\u1EA2":"A","\u1EA3":"a","\u1EA4":"A","\u1EA5":"a","\u1EA6":"A","\u1EA7":"a","\u1EA8":"A","\u1EA9":"a","\u1EAA":"A","\u1EAB":"a","\u1EAC":"A","\u1EAD":"a","\u1EAE":"A","\u1EAF":"a","\u1EB0":"A","\u1EB1":"a","\u1EB2":"A","\u1EB3":"a","\u1EB4":"A","\u1EB5":"a","\u1EB6":"A","\u1EB7":"a","\u1EB8":"E","\u1EB9":"e","\u1EBA":"E","\u1EBB":"e","\u1EBC":"E","\u1EBD":"e","\u1EBE":"E","\u1EBF":"e","\u1EC0":"E","\u1EC1":"e","\u1EC2":"E","\u1EC3":"e","\u1EC4":"E","\u1EC5":"e","\u1EC6":"E","\u1EC7":"e","\u1EC8":"I","\u1EC9":"i","\u1ECA":"I","\u1ECB":"i","\u1ECC":"O","\u1ECD":"o","\u1ECE":"O","\u1ECF":"o","\u1ED0":"O","\u1ED1":"o","\u1ED2":"O","\u1ED3":"o","\u1ED4":"O","\u1ED5":"o","\u1ED6":"O","\u1ED7":"o","\u1ED8":"O","\u1ED9":"o","\u1EDA":"O","\u1EDB":"o","\u1EDC":"O","\u1EDD":"o","\u1EDE":"O","\u1EDF":"o","\u1EE0":"O","\u1EE1":"o","\u1EE2":"O","\u1EE3":"o","\u1EE4":"U","\u1EE5":"u","\u1EE6":"U","\u1EE7":"u","\u1EE8":"U","\u1EE9":"u","\u1EEA":"U","\u1EEB":"u","\u1EEC":"U","\u1EED":"u","\u1EEE":"U","\u1EEF":"u","\u1EF0":"U","\u1EF1":"u","\u1EF2":"Y","\u1EF3":"y","\u1EF4":"Y","\u1EF5":"y","\u1EF6":"Y","\u1EF7":"y","\u1EF8":"Y","\u1EF9":"y","\u2013":"-","\u2018":"'","\u2019":"'","\u201C":"\\"","\u201D":"\\"","\u201E":"\\"","\u2020":"+","\u2022":"*","\u2026":"...","\u20A0":"ecu","\u20A2":"cruzeiro","\u20A3":"french franc","\u20A4":"lira","\u20A5":"mill","\u20A6":"naira","\u20A7":"peseta","\u20A8":"rupee","\u20A9":"won","\u20AA":"new shequel","\u20AB":"dong","\u20AC":"euro","\u20AD":"kip","\u20AE":"tugrik","\u20AF":"drachma","\u20B0":"penny","\u20B1":"peso","\u20B2":"guarani","\u20B3":"austral","\u20B4":"hryvnia","\u20B5":"cedi","\u20B8":"kazakhstani tenge","\u20B9":"indian rupee","\u20BA":"turkish lira","\u20BD":"russian ruble","\u20BF":"bitcoin","\u2120":"sm","\u2122":"tm","\u2202":"d","\u2206":"delta","\u2211":"sum","\u221E":"infinity","\u2665":"love","\u5143":"yuan","\u5186":"yen","\uFDFC":"rial","\uFEF5":"laa","\uFEF7":"laa","\uFEF9":"lai","\uFEFB":"la"}`),r=JSON.parse('{"bg":{"\u0419":"Y","\u0426":"Ts","\u0429":"Sht","\u042A":"A","\u042C":"Y","\u0439":"y","\u0446":"ts","\u0449":"sht","\u044A":"a","\u044C":"y"},"de":{"\xC4":"AE","\xE4":"ae","\xD6":"OE","\xF6":"oe","\xDC":"UE","\xFC":"ue","\xDF":"ss","%":"prozent","&":"und","|":"oder","\u2211":"summe","\u221E":"unendlich","\u2665":"liebe"},"es":{"%":"por ciento","&":"y","<":"menor que",">":"mayor que","|":"o","\xA2":"centavos","\xA3":"libras","\xA4":"moneda","\u20A3":"francos","\u2211":"suma","\u221E":"infinito","\u2665":"amor"},"fr":{"%":"pourcent","&":"et","<":"plus petit",">":"plus grand","|":"ou","\xA2":"centime","\xA3":"livre","\xA4":"devise","\u20A3":"franc","\u2211":"somme","\u221E":"infini","\u2665":"amour"},"pt":{"%":"porcento","&":"e","<":"menor",">":"maior","|":"ou","\xA2":"centavo","\u2211":"soma","\xA3":"libra","\u221E":"infinito","\u2665":"amor"},"uk":{"\u0418":"Y","\u0438":"y","\u0419":"Y","\u0439":"y","\u0426":"Ts","\u0446":"ts","\u0425":"Kh","\u0445":"kh","\u0429":"Shch","\u0449":"shch","\u0413":"H","\u0433":"h"},"vi":{"\u0110":"D","\u0111":"d"},"da":{"\xD8":"OE","\xF8":"oe","\xC5":"AA","\xE5":"aa","%":"procent","&":"og","|":"eller","$":"dollar","<":"mindre end",">":"st\xF8rre end"},"nb":{"&":"og","\xC5":"AA","\xC6":"AE","\xD8":"OE","\xE5":"aa","\xE6":"ae","\xF8":"oe"},"it":{"&":"e"},"nl":{"&":"en"},"sv":{"&":"och","\xC5":"AA","\xC4":"AE","\xD6":"OE","\xE5":"aa","\xE4":"ae","\xF6":"oe"}}');function e(n,t){if(typeof n!="string")throw new Error("slugify: string argument expected");t=typeof t=="string"?{replacement:t}:t||{};var o=r[t.locale]||{},m=t.replacement===void 0?"-":t.replacement,l=t.trim===void 0?!0:t.trim,i=n.normalize().split("").reduce(function(c,u){var s=o[u];return s===void 0&&(s=a[u]),s===void 0&&(s=u),s===m&&(s=" "),c+s.replace(t.remove||/[^\w\s$*_+~.()'"!\-:@]+/g,"")},"");return t.strict&&(i=i.replace(/[^A-Za-z0-9\s]/g,"")),l&&(i=i.trim()),i=i.replace(/\s+/g,m),t.lower&&(i=i.toLowerCase()),i}return e.extend=function(n){Object.assign(a,n)},e})});var g=O(h(),1);function y(a,r="-"){return(0,g.default)(a,{strict:!0,replacement:r,lower:!0})}import{existsSync as w,rmSync as v,writeFileSync as k}from"node:fs";import{resolve as S}from"node:path";function P(a){let r=S(process.cwd(),"index.html");w(r)&&v(r,{force:!0});let e=Y(a);return k(r,e),r}function b(a){return a.reduce((r,{appImport:e,manifestImport:n},t)=>{let o=e+`
|
|
2
|
-
`+n;return t===0?o:r+`
|
|
3
|
-
`+o},"")}function U(a){return"const apps = ["+a.reduce((e,{appVariableName:n,manifestVariableName:t})=>{let o=`{ app: ${n}, manifest: ${t} },`;return e+`
|
|
4
|
-
`+o},"")+`
|
|
5
|
-
];`}function Y(a){let r=a.map(({packageName:t,appImportPath:o,manifestImportPath:m})=>{let l=y(t,""),i=`${l}App`,c=`${l}Manifest`;return{packageName:t,appVariableName:i,manifestVariableName:c,appImport:`import ${i} from '${A(o)}';`,manifestImport:`import ${c} from '${A(m)}';`}}),e=b(r),n=U(r);return $.replaceAll("$imports;",e).replaceAll("$apps;",n)}var $=`
|
|
6
|
-
<!doctype html>
|
|
7
|
-
<html lang="en">
|
|
8
|
-
<head>
|
|
9
|
-
<meta charset="UTF-8" />
|
|
10
|
-
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
|
|
11
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
12
|
-
<title>Alliance Portal</title>
|
|
13
|
-
</head>
|
|
14
|
-
|
|
15
|
-
<body>
|
|
16
|
-
<script type="module">
|
|
17
|
-
import createFramework from '@telia-ace/alliance-framework/create-framework';
|
|
18
|
-
import '@telia-ace/alliance-ui/components';
|
|
19
|
-
import { addCssVariables } from '@telia-ace/alliance-ui/voca/foundations';
|
|
20
|
-
|
|
21
|
-
$imports;
|
|
22
|
-
|
|
23
|
-
addCssVariables();
|
|
24
|
-
|
|
25
|
-
$apps;
|
|
26
|
-
|
|
27
|
-
createFramework(apps);
|
|
28
|
-
</script>
|
|
29
|
-
</body>
|
|
30
|
-
</html>
|
|
31
|
-
`.trim();function A(a){return a.replaceAll("\\","\\\\")}import{rmSync as E,writeFileSync as N}from"node:fs";import{resolve as z}from"node:path";async function x(a,r){let e=z(process.cwd(),`${r}.mjs`);try{N(e,a);let n=await import(`file:///${e}`);return E(e,{force:!0}),n}catch(n){try{E(e,{force:!0})}catch{}p.error("something went wrong when creating temp module for app manifest import"),p.error(n),process.exit(1)}}async function X(a){let r=[],e=[];for(let n of a){let t=`app${a.indexOf(n)}`;e.push(t),r.push(`import ${t} from '${n}/manifest';`)}return r.push(`export default [${e.join(", ")}];`),x(r.join(`
|
|
32
|
-
`),"app-manifests").then(n=>n.default)}export{y as a,P as b,X as c};
|