@telia-ace/alliance-internal-node-utilities 4.0.0-next.11 → 4.0.0-next.12
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.
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { createRequire as c__createRequire } from 'node:module';
|
|
3
3
|
const require = c__createRequire(import.meta.url);
|
|
4
4
|
import{a as h,b as p,c as x,d as y,e as S,g as j,i as I}from"./chunk-FUASCPVV.js";import"./chunk-COPUUGH4.js";import{existsSync as ce,mkdirSync as le,readFileSync as L,writeFileSync as P}from"fs";import{relative as ue,resolve as w}from"path";var B=h.enum(["necessary","functional","analytics","marketing"]),G=h.object({purpose:h.string().describe("Purpose of the storing the value."),category:B.describe("Category of the storage value - necessary, functional, analytics or marketing."),lifespan:h.string().describe("Basic description of how long the value will be stored.")}),$=h.record(G.describe("Key used when writing to the storage.")),F=h.object({value:h.string().describe("The localization token default value."),description:h.string().describe("The localization token description.")}),V=h.object({localization:h.record(F.describe("Key used when getting the localized text.")).default({}).describe("Translateable texts used in the app")}),_=h.object({common:h.object({order:h.number().optional().describe("Order of the capability in the common capabilities list."),variant:h.enum(["primary","secondary","expressive","destructive","text","primary-white","secondary-white","expressive-white","tertiary-purple"]).default("secondary").describe("Variant of the capability button.")}).optional().describe("Common capability configuration."),label:h.string().optional().describe("Label for the capability.")}),Y=h.object({name:h.string().describe("URL friendly name of the app."),endpoints:h.string().array().default([]).describe("Endpoints that should be communicated with using the API gateway."),permissions:h.string().array().default([]).describe("Permissions that can be added to user roles."),resources:V.default({}).describe("Resources used by the app."),storage:$.default({}).describe("Cookies, session storage, and local storage values that are used by the app."),capabilities:h.record(_.describe("Capability key.")).default({}).describe("Capabilities that the app has.")}).passthrough();function D(e,o){let t=Y.safeParse(e);return t.success?t.data:O(t.error.format(),o?[o]:[]).join(`
|
|
5
|
-
`)}function O(e,o=[],t=""){e._errors?.length&&o.push(`${t} - ${e._errors.join(" + ")}`);for(let[
|
|
6
|
-
`)}function m(e){return typeof e=="function"?e():e}var b=class extends Error{constructor(o,t){super(o),this.code=t,this.name="CLIError"}},J=/\d/,Z=["-","_","/","."];function X(e=""){if(!J.test(e))return e!==e.toLowerCase()}function N(e,o){let t=o??Z,
|
|
7
|
-
`)}catch(t){y.error(t)}}async function se(e,o){let t=await m(e.meta||{}),
|
|
8
|
-
`)}async function q(e,o={}){let t=o.rawArgs||process.argv.slice(2),
|
|
9
|
-
`),n&&await
|
|
5
|
+
`)}function O(e,o=[],t=""){e._errors?.length&&o.push(`${t} - ${e._errors.join(" + ")}`);for(let[a,i]of Object.entries(e))a==="_errors"||!i||typeof i!="object"||Array.isArray(i)||O(i,o,t?`${t}.${a}`:a);return o}import"tty";function K(e){return Array.isArray(e)?e:e===void 0?[]:[e]}function T(e,o=""){let t=[];for(let a of e)for(let[i,n]of a.entries())t[i]=Math.max(t[i]||0,n.length);return e.map(a=>a.map((i,n)=>o+i[n===0?"padStart":"padEnd"](t[n])).join(" ")).join(`
|
|
6
|
+
`)}function m(e){return typeof e=="function"?e():e}var b=class extends Error{constructor(o,t){super(o),this.code=t,this.name="CLIError"}},J=/\d/,Z=["-","_","/","."];function X(e=""){if(!J.test(e))return e!==e.toLowerCase()}function N(e,o){let t=o??Z,a=[];if(!e||typeof e!="string")return a;let i="",n,u;for(let r of e){let s=t.includes(r);if(s===!0){a.push(i),i="",n=void 0;continue}let c=X(r);if(u===!1){if(n===!1&&c===!0){a.push(i),i=r,n=c;continue}if(n===!0&&c===!1&&i.length>1){let f=i.at(-1);a.push(i.slice(0,Math.max(0,i.length-1))),i=f+r,n=c;continue}}i+=r,n=c,u=s}return a.push(i),a}function W(e){return e?e[0].toUpperCase()+e.slice(1):""}function Q(e){return e?e[0].toLowerCase()+e.slice(1):""}function ee(e,o){return e?(Array.isArray(e)?e:N(e)).map(t=>W(o?.normalize?t.toLowerCase():t)).join(""):""}function oe(e,o){return Q(ee(e||"",o))}function te(e,o){return e?(Array.isArray(e)?e:N(e)).map(t=>t.toLowerCase()).join(o??"-"):""}function E(e){return e==null?[]:Array.isArray(e)?e:[e]}function ie(e,o,t,a){let i,n=e[o],u=~a.string.indexOf(o)?t==null||t===!0?"":String(t):typeof t=="boolean"?t:~a.boolean.indexOf(o)?t==="false"?!1:t==="true"||(e._.push((i=+t,i*0===0?i:t)),!!t):(i=+t,i*0===0?i:t);e[o]=n==null?u:Array.isArray(n)?n.concat(u):[n,u]}function ae(e=[],o={}){let t,a,i,n,u,r={_:[]},s=0,c=0,f=0,A=e.length,C=o.alias!==void 0,l=o.unknown!==void 0,d=o.default!==void 0;if(o.alias=o.alias||{},o.string=E(o.string),o.boolean=E(o.boolean),C)for(t in o.alias)for(a=o.alias[t]=E(o.alias[t]),s=0;s<a.length;s++)(o.alias[a[s]]=a.concat(t)).splice(s,1);for(s=o.boolean.length;s-- >0;)for(a=o.alias[o.boolean[s]]||[],c=a.length;c-- >0;)o.boolean.push(a[c]);for(s=o.string.length;s-- >0;)for(a=o.alias[o.string[s]]||[],c=a.length;c-- >0;)o.string.push(a[c]);if(d){for(t in o.default)if(n=typeof o.default[t],a=o.alias[t]=o.alias[t]||[],o[n]!==void 0)for(o[n].push(t),s=0;s<a.length;s++)o[n].push(a[s])}let g=l?Object.keys(o.alias):[];for(s=0;s<A;s++){if(i=e[s],i==="--"){r._=r._.concat(e.slice(++s));break}for(c=0;c<i.length&&i.charCodeAt(c)===45;c++);if(c===0)r._.push(i);else if(i.substring(c,c+3)==="no-"){if(n=i.slice(Math.max(0,c+3)),l&&!~g.indexOf(n))return o.unknown(i);r[n]=!1}else{for(f=c+1;f<i.length&&i.charCodeAt(f)!==61;f++);for(n=i.substring(c,f),u=i.slice(Math.max(0,++f))||s+1===A||(""+e[s+1]).charCodeAt(0)===45||e[++s],a=c===2?[n]:n,f=0;f<a.length;f++){if(n=a[f],l&&!~g.indexOf(n))return o.unknown("-".repeat(c)+n);ie(r,n,f+1<a.length||u,o)}}}if(d)for(t in o.default)r[t]===void 0&&(r[t]=o.default[t]);if(C)for(t in r)for(a=o.alias[t]||[];a.length>0;)r[a.shift()]=r[t];return r}function re(e,o){let t={boolean:[],string:[],mixed:[],alias:{},default:{}},a=U(o);for(let r of a)r.type!=="positional"&&(r.type==="string"?t.string.push(r.name):r.type==="boolean"&&t.boolean.push(r.name),r.default!==void 0&&(t.default[r.name]=r.default),r.alias&&(t.alias[r.name]=r.alias));let i=ae(e,t),[...n]=i._,u=new Proxy(i,{get(r,s){return r[s]??r[oe(s)]??r[te(s)]}});for(let[,r]of a.entries())if(r.type==="positional"){let s=n.shift();if(s!==void 0)u[r.name]=s;else{if(r.default===void 0&&r.required!==!1)throw new b(`Missing required positional argument: ${r.name.toUpperCase()}`,"EARG");u[r.name]=r.default}}else if(r.required&&u[r.name]===void 0)throw new b(`Missing required argument: --${r.name}`,"EARG");return u}function U(e){let o=[];for(let[t,a]of Object.entries(e||{}))o.push({...a,name:t,alias:K(a.alias)});return o}async function R(e,o){let t=await m(e.args||{}),a=re(o.rawArgs,t),i={rawArgs:o.rawArgs,args:a,data:o.data,cmd:e};typeof e.setup=="function"&&await e.setup(i);let n;try{let u=await m(e.subCommands);if(u&&Object.keys(u).length>0){let r=o.rawArgs.findIndex(c=>!c.startsWith("-")),s=o.rawArgs[r];if(s){if(!u[s])throw new b(`Unknown command \`${s}\``,"E_UNKNOWN_COMMAND");let c=await m(u[s]);c&&await R(c,{rawArgs:o.rawArgs.slice(r+1)})}else if(!e.run)throw new b("No command specified.","E_NO_COMMAND")}typeof e.run=="function"&&(n=await e.run(i))}finally{typeof e.cleanup=="function"&&await e.cleanup(i)}return{result:n}}async function M(e,o,t){let a=await m(e.subCommands);if(a&&Object.keys(a).length>0){let i=o.findIndex(r=>!r.startsWith("-")),n=o[i],u=await m(a[n]);if(u)return M(u,o.slice(i+1),e)}return[e,t]}async function ne(e,o){try{y.log(await se(e,o)+`
|
|
7
|
+
`)}catch(t){y.error(t)}}async function se(e,o){let t=await m(e.meta||{}),a=U(await m(e.args||{})),i=await m(o?.meta||{}),n=`${i.name?`${i.name} `:""}`+(t.name||process.argv[1]),u=[],r=[],s=[],c=[];for(let l of a)if(l.type==="positional"){let d=l.name.toUpperCase(),g=l.required!==!1&&l.default===void 0,k=l.default?`="${l.default}"`:"";r.push(["`"+d+k+"`",l.description||"",l.valueHint?`<${l.valueHint}>`:""]),c.push(g?`<${d}>`:`[${d}]`)}else{let d=l.required===!0&&l.default===void 0,g=(l.type==="boolean"&&l.default===!0?[...(l.alias||[]).map(k=>`--no-${k}`),`--no-${l.name}`].join(", "):[...(l.alias||[]).map(k=>`-${k}`),`--${l.name}`].join(", "))+(l.type==="string"&&(l.valueHint||l.default)?`=${l.valueHint?`<${l.valueHint}>`:`"${l.default||""}"`}`:"");u.push(["`"+g+(d?" (required)":"")+"`",l.description||""]),d&&c.push(g)}if(e.subCommands){let l=[],d=await m(e.subCommands);for(let[g,k]of Object.entries(d)){let z=await m(k),H=await m(z?.meta);s.push([`\`${g}\``,H?.description||""]),l.push(g)}c.push(l.join("|"))}let f=[],A=t.version||i.version;f.push(p.gray(`${t.description} (${n+(A?` v${A}`:"")})`),"");let C=u.length>0||r.length>0;return f.push(`${p.underline(p.bold("USAGE"))} \`${n}${C?" [OPTIONS]":""} ${c.join(" ")}\``,""),r.length>0&&(f.push(p.underline(p.bold("ARGUMENTS")),""),f.push(T(r," ")),f.push("")),u.length>0&&(f.push(p.underline(p.bold("OPTIONS")),""),f.push(T(u," ")),f.push("")),s.length>0&&(f.push(p.underline(p.bold("COMMANDS")),""),f.push(T(s," ")),f.push("",`Use \`${n} <command> --help\` for more information about a command.`)),f.filter(l=>typeof l=="string").join(`
|
|
8
|
+
`)}async function q(e,o={}){let t=o.rawArgs||process.argv.slice(2),a=o.showUsage||ne;try{if(t.includes("--help")||t.includes("-h"))await a(...await M(e,t)),process.exit(0);else if(t.length===1&&t[0]==="--version"){let i=typeof e.meta=="function"?await e.meta():await e.meta;if(!i?.version)throw new b("No version specified","E_NO_VERSION");y.log(i.version)}else await R(e,{rawArgs:t})}catch(i){let n=i instanceof b;n||y.error(i,`
|
|
9
|
+
`),n&&await a(...await M(e,t)),y.error(i.message),process.exit(1)}}var fe="public",he="manifests.json",de="cookie-policy.html",pe="config.schema.json",me="manifest.schema.json";function v(e){console.log(x("yellowBright","DIST ")+x("bold",ue(process.cwd(),e)))}await q({meta:{name:"compile-distribution",description:"Creates files used when building an Alliance distribution by reading alliance.apps in the CWD package.json."},async run(){let e=await S(),o=e?.alliance?.apps||[];if(!o.length)throw new Error("No alliance.apps in package.json.");let t=await I(e.alliance.apps);for(let c of t){let f=D(c,`App '${c.name}' has an invalid manifest`);typeof f=="string"&&(y.error(f),process.exit(1))}let a=j(o.map(c=>({packageName:c,appImportPath:`${c}/app`,manifestImportPath:`${c}/manifest`})));v(a);let i=w(process.cwd(),fe);ce(i)||(le(i),v(i));let n=w(i,he);P(n,JSON.stringify(t)),v(n);let u=w(i,de);P(u,ye(t)),v(u);let[r,s]=ge(i);v(r),v(s)}});function ge(e){let o=w(process.cwd(),"node_modules","@telia-ace/alliance-framework","dist"),t=w(e,pe);P(t,L(w(o,"config.schema.json")));let a=w(e,me);return P(a,L(w(o,"manifest.schema.json"))),[t,a]}function ye(e){let o=[];for(let t of e)if(t.storage)for(let[a,i]of Object.entries(t.storage)){let n=be(a,i);o.push(n)}return we().replace("{APP_COOKIES}",o.join("")).trim()}function be(e,o){let t=["<tr>"],{category:a,purpose:i,lifespan:n}=o;return t.push(`<td>${e}</td>`),t.push(`<td>${a}</td>`),t.push(`<td>${i}</td>`),t.push(`<td>${n}</td>`),t.push("</tr>"),t.join("")}function we(){return`
|
|
10
10
|
<!DOCTYPE html>
|
|
11
11
|
<html lang="en">
|
|
12
12
|
<head>
|
|
@@ -272,9 +272,9 @@ import{a as h,b as p,c as x,d as y,e as S,g as j,i as I}from"./chunk-FUASCPVV.js
|
|
|
272
272
|
</thead>
|
|
273
273
|
<tbody>
|
|
274
274
|
<tr>
|
|
275
|
-
<td>alliance-
|
|
275
|
+
<td>alliance-auth</td>
|
|
276
276
|
<td>necessary</td>
|
|
277
|
-
<td>Contains the authenticated
|
|
277
|
+
<td>Contains the authenticated users session ID.</td>
|
|
278
278
|
<td>1 day</td>
|
|
279
279
|
</tr>
|
|
280
280
|
{APP_COOKIES}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/alliance-internal-node-utilities",
|
|
3
|
-
"version": "4.0.0-next.
|
|
3
|
+
"version": "4.0.0-next.12",
|
|
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",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"import-from-esm": "^2.0.0",
|
|
28
28
|
"pino-pretty": "^13.0.0",
|
|
29
29
|
"pkg-types": "^2.1.0",
|
|
30
|
-
"@telia-ace/alliance-framework": "^4.0.0-next.
|
|
30
|
+
"@telia-ace/alliance-framework": "^4.0.0-next.12"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|