@north-light/plugin 0.3.463 → 0.3.464

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.
Files changed (2) hide show
  1. package/dist/compare.js +1 -1
  2. package/package.json +3 -3
package/dist/compare.js CHANGED
@@ -1 +1 @@
1
- var j=Object.defineProperty;var a=(e,u)=>j(e,"name",{value:u,configurable:!0});function g(e,u){const r=f(e),n=f(u),t=[];for(const[s,i]of r){const o=n.get(s);if(!o){t.push({leaf:s,rule:"tool removed or renamed; bump the major"});continue}i.group!==o.group&&t.push({leaf:s,rule:"tool group changed; bump the major"});const p=new Map(o.params.map(m=>[m.name,m]));for(const m of i.params){const c=p.get(m.name);c?d(m)!==d(c)?t.push({leaf:s,rule:`parameter ${m.name} type changed; bump the major`}):!m.required&&c.required&&t.push({leaf:s,rule:`parameter ${m.name} became required; bump the major`}):t.push({leaf:s,rule:`parameter ${m.name} removed; bump the major`})}const l=new Set(i.params.map(m=>m.name));for(const m of o.params)!l.has(m.name)&&m.required&&t.push({leaf:s,rule:`required parameter ${m.name} added; bump the major`});h(i.output,o.output,s,t)}return t}a(g,"compareManifests");function f(e){const u=new Map;function r(n,t){const s=[...t,n.name];if(n.kind==="leaf")u.set(s.join(" "),n);else for(const i of n.children)r(i,s)}a(r,"visit");for(const n of e.mounts)r(n.node,n.parent);return u}a(f,"leaves");function d(e){return e.kind==="flag"?`${e.kind}:${e.type}:${!!e.repeatable}:${e.type==="enum"?JSON.stringify(e.choices):""}`:e.kind==="positional"?`${e.kind}:${e.type??"string"}:${!!e.repeatable}`:e.kind}a(d,"parameterType");function h(e,u,r,n,t=""){const s=new Map(u.map(o=>[o.name,o])),i=new Set(e.map(o=>o.name));for(const o of u)if(!i.has(o.name)&&b(o.type)==="file"){const p=t?`${t}.${o.name}`:o.name;n.push({leaf:r,rule:`file output field ${p} added; bump the major`})}for(const o of e){const p=t?`${t}.${o.name}`:o.name,l=s.get(o.name);if(!l){n.push({leaf:r,rule:`output field ${p} removed; bump the major`});continue}o.required&&!l.required&&n.push({leaf:r,rule:`output field ${p} became optional; bump the major`}),$(o,l,p,r,n)}}a(h,"compareFields");function b(e){return e.endsWith(" | null")?e.slice(0,-7):e}a(b,"baseType");function $(e,u,r,n,t){if(e.type!==u.type){t.push({leaf:n,rule:`output field ${r} type changed; bump the major`});return}e.values?.some(s=>!u.values?.includes(s))&&t.push({leaf:n,rule:`output field ${r} enum value removed; bump the major`}),e.children&&h(e.children,u.children??[],n,t,r),e.items&&u.items?$(e.items,u.items,`${r}[]`,n,t):!!e.items!=!!u.items&&t.push({leaf:n,rule:`output field ${r} type changed; bump the major`})}a($,"compareShape");export{g as compareManifests};
1
+ var S=Object.defineProperty;var p=(e,n)=>S(e,"name",{value:n,configurable:!0});function E(e,n){const i=j(e),s=j(n),o=[];for(const[u,m]of i){const r=s.get(u);if(!r){o.push({leaf:u,rule:"tool removed or renamed; bump the major"});continue}m.group!==r.group&&o.push({leaf:u,rule:"tool group changed; bump the major"}),q(m,r,u,o),R(m,r,u,o),k(m,r,u,o),y(m.output,r.output,u,o)}return o}p(E,"compareManifests");function q(e,n,i,s){const o=new Map(n.params.map(t=>[t.name,t]));for(const t of e.params){const c=o.get(t.name);if(!c){s.push({leaf:i,rule:`parameter ${t.name} removed; bump the major`});continue}if(v(t)!==v(c)){s.push({leaf:i,rule:`parameter ${t.name} type changed; bump the major`});continue}if(!t.required&&c.required&&s.push({leaf:i,rule:`parameter ${t.name} became required; bump the major`}),t.kind==="flag"&&c.kind==="flag"){for(const g of t.choices??[])c.choices?.includes(g)||s.push({leaf:i,rule:`parameter ${t.name} enum value ${g} removed; bump the major`});const d=l(t),a=l(c);d!==void 0&&a!==void 0&&a!==d&&s.push({leaf:i,rule:`parameter ${t.name} default changed (${d} -> ${a}), so a caller that omits it gets a different page; bump the major`})}(t.kind==="flag"||t.kind==="positional")&&(c.kind==="flag"||c.kind==="positional")&&t.defaultFromEnv!==c.defaultFromEnv&&s.push({leaf:i,rule:`parameter ${t.name} environment default changed (${t.defaultFromEnv??"none"} -> ${c.defaultFromEnv??"none"}); bump the major`})}const u=new Set(e.params.map(t=>t.name));for(const t of n.params)!u.has(t.name)&&t.required&&s.push({leaf:i,rule:`required parameter ${t.name} added; bump the major`});const m=e.params.filter(t=>t.kind==="positional").map(t=>t.name),r=n.params.filter(t=>t.kind==="positional").map(t=>t.name),f=m.findIndex((t,c)=>o.has(t)&&r[c]!==t);f>=0&&s.push({leaf:i,rule:`positional parameter ${m[f]} moved from position ${f+1}; bump the major`})}p(q,"compareParams");const h=p(e=>e.toLowerCase().replace(/[^a-z0-9]/g,""),"normalize"),M=new Set(["limit","pagesize","perpage","maxresults","take"]),O=new Set(["cursor","page","pagetoken","offset"]),$=new Set(["nextcursor","nextpage","nextpagetoken","hasmore","truncated"]);function l(e){if(e.type!=="int"||!M.has(h(e.name)))return;const n=/\bdefaults?(?: of| to| is)?\s+(\d+)/i.exec(e.constraint);return n?Number(n[1]):void 0}p(l,"statedLimit");function R(e,n,i,s){const o=p(a=>a.kind==="flag"&&l(a)!==void 0,"limited"),u=p(a=>a.kind==="flag"&&O.has(h(a.name)),"cursored");if(e.params.some(o)||e.params.some(u)&&e.output.some(a=>$.has(h(a.name))))return;const m=new Set(e.params.map(a=>a.name)),r=new Set(e.output.map(a=>a.name)),f=n.params.filter(a=>!m.has(a.name)&&o(a)).map(a=>`--${a.name} defaulting to ${l(a)}`),t=n.params.filter(a=>!m.has(a.name)&&u(a)).map(a=>`--${a.name}`),c=n.output.filter(a=>!r.has(a.name)&&$.has(h(a.name))).map(a=>`output ${a.name}`),d=t.length>0&&c.length>0;(f.length||d)&&s.push({leaf:i,rule:`gained paging (${[...f,...d?[...t,...c]:[]].join(", ")}) where it returned everything, so callers that do not page now get a partial answer; bump the major`})}p(R,"comparePaging");function k(e,n,i,s){const o=[],u=p(m=>m.replace(/\/v\d+(?=\/|$)/g,"/v*"),"route");e.rest.method!==n.rest.method&&o.push("method"),u(e.rest.path)!==u(n.rest.path)&&o.push("path"),!!e.rest.streaming!=!!n.rest.streaming&&o.push("streaming"),e.rest.bodyRoot!==n.rest.bodyRoot&&o.push("body root"),JSON.stringify(b(e.rest.body))!==JSON.stringify(b(n.rest.body))&&o.push("constant body fields");for(const[m,r]of Object.entries(e.rest.params)){const f=n.rest.params[m];f&&(r.in!==f.in||(r.as??m)!==(f.as??m))&&o.push(`parameter ${m} placement`)}o.length&&s.push({leaf:i,rule:`request mapping changed (${o.join(", ")}); bump the major`})}p(k,"compareRequest");function b(e){return Object.entries(e??{}).sort(([n],[i])=>n<i?-1:1)}p(b,"sorted");function j(e){const n=new Map;function i(s,o){const u=[...o,s.name];if(s.kind==="leaf")n.set(u.join(" "),s);else for(const m of s.children)i(m,u)}p(i,"visit");for(const s of e.mounts)i(s.node,s.parent);return n}p(j,"leaves");function v(e){return e.kind==="flag"?`${e.kind}:${e.type}:${!!e.repeatable}:${e.type==="path"?e.encoding:""}`:e.kind==="positional"?`${e.kind}:${e.type??"string"}:${!!e.repeatable}:${e.type==="path"?e.encoding:""}`:e.kind}p(v,"parameterType");function y(e,n,i,s,o=""){const u=new Map(n.map(r=>[r.name,r])),m=new Set(e.map(r=>r.name));for(const r of n)if(!m.has(r.name)&&B(r.type)==="file"){const f=o?`${o}.${r.name}`:r.name;s.push({leaf:i,rule:`file output field ${f} added; bump the major`})}for(const r of e){const f=o?`${o}.${r.name}`:r.name,t=u.get(r.name);if(!t){s.push({leaf:i,rule:`output field ${f} removed; bump the major`});continue}r.required&&!t.required&&s.push({leaf:i,rule:`output field ${f} became optional; bump the major`}),w(r,t,f,i,s)}}p(y,"compareFields");function B(e){return e.endsWith(" | null")?e.slice(0,-7):e}p(B,"baseType");function w(e,n,i,s,o){if(e.type!==n.type){o.push({leaf:s,rule:`output field ${i} type changed; bump the major`});return}e.values?.some(u=>!n.values?.includes(u))&&o.push({leaf:s,rule:`output field ${i} enum value removed; bump the major`}),e.children&&y(e.children,n.children??[],s,o,i),e.items&&n.items?w(e.items,n.items,`${i}[]`,s,o):!!e.items!=!!n.items&&o.push({leaf:s,rule:`output field ${i} type changed; bump the major`})}p(w,"compareShape");export{E as compareManifests};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/plugin",
3
- "version": "0.3.463",
3
+ "version": "0.3.464",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -23,8 +23,8 @@
23
23
  "postpack": "node ../../scripts/pack-minify.mjs postpack packages/crouter-plugin"
24
24
  },
25
25
  "dependencies": {
26
- "@north-light/api": "0.3.463",
27
- "@north-light/identity": "0.3.463"
26
+ "@north-light/api": "0.3.464",
27
+ "@north-light/identity": "0.3.464"
28
28
  },
29
29
  "license": "UNLICENSED",
30
30
  "publishConfig": {