eprel-client
Advanced tools
@@ -1,1 +0,1 @@ | ||
| "use strict";var f=require("@blgc/utils"),e=require("feature-fetch"),E=require("./helper/get-label-url.js"),y=require("./helper/get-language-set.js"),m=require("./helper/get-sheet-url.js"),k=Object.defineProperty,v=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,P=(l,i,r)=>i in l?k(l,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):l[i]=r,b=(l,i)=>{for(var r in i||(i={}))S.call(i,r)&&P(l,r,i[r]);if(v)for(var r of v(i))w.call(i,r)&&P(l,r,i[r]);return l},c=(l,i,r)=>new Promise((t,a)=>{var u=s=>{try{n(r.next(s))}catch(p){a(p)}},o=s=>{try{n(r.throw(s))}catch(p){a(p)}},n=s=>s.done?t(s.value):Promise.resolve(s.value).then(u,o);n((r=r.apply(l,i)).next())});function R(l){if(!e.isFetchClientWithFeatures(l,["openapi"]))throw Error('FetchClient must have "openapi" feature to use withEPREL');const i=Object.assign(l,{getProductGroups(){return c(this,null,function*(){const r=yield this.get("/product-groups");return f.mapOk(r,t=>t.data)})},getModelsInProductGroup(r){return c(this,arguments,function*(t,a={}){const{page:u,limit:o,sort:n=[],includeOldProducts:s,filter:p={}}=a,d={};if(n.length>3)throw new e.FetchError("#ERR_MAX_3_SORT");n.forEach((g,h)=>{d[`sort${h.toString()}`]=g.field,d[`order${h.toString()}`]=g.order});const O=yield this.get("/products/{productGroup}",{pathParams:{productGroup:t},queryParams:b(b({_page:u,_limit:o,includeOldProducts:s},d),p)});return f.mapOk(O,g=>g.data)})},getProductByRegistrationNumber(r){return c(this,null,function*(){const t=yield this.get("/product/{registrationNumber}",{pathParams:{registrationNumber:r}});return t.isErr()?e.isStatusCode(t.error,404)?e.Ok(null):e.Err(t.error):e.Ok(t.value.data)})},getProductSheets(r){return c(this,arguments,function*(t,a={}){const{noRedirect:u=!1,language:o}=a,n=yield this.get("/product/{registrationNumber}/fiches",{pathParams:{registrationNumber:t},queryParams:{noRedirect:u,language:o},parseAs:u?"json":"arrayBuffer"});return n.isErr()?e.Err(n.error):e.Ok(n.value.data instanceof ArrayBuffer?new Uint8Array(n.value.data):n.value.data)})},getProductSheetUrls(r){return c(this,null,function*(){var t;const a=yield this.getProductByRegistrationNumber(r);if(a.isErr())return e.isStatusCode(a.error,404)?e.Ok([]):e.Err(a.error);const{productGroup:u,placementCountries:o}=(t=a.value)!=null?t:{};if(u==null||o==null)return e.Ok([]);const n=y.getLanguageSet(o);return e.Ok(Array.from(n).map(s=>({language:s,url:m.getSheetUrl(u,r,s)})))})},getProductSheetUrl(r,t){return c(this,null,function*(){var a;const u=yield this.getProductByRegistrationNumber(r);if(u.isErr())return e.isStatusCode(u.error,404)?e.Ok(null):e.Err(u.error);const{productGroup:o,placementCountries:n}=(a=u.value)!=null?a:{};return o==null||n==null?e.Ok(null):y.getLanguageSet(n).has(t)?e.Ok(m.getSheetUrl(o,r,t)):e.Ok(null)})},getProductLabels(r){return c(this,arguments,function*(t,a={}){const{noRedirect:u=!1,format:o,instance:n,supplierLabel:s,type:p}=a,d=yield this.get("/product/{registrationNumber}/labels",{pathParams:{registrationNumber:t},queryParams:{noRedirect:u,format:o,instance:n,supplier_label:s,type:p},parseAs:u?"json":"arrayBuffer"});return d.isErr()?e.Err(d.error):e.Ok(d.value.data instanceof ArrayBuffer?new Uint8Array(d.value.data):d.value.data)})},getProductLabelUrl(r,t){return c(this,null,function*(){var a;const u=yield this.getProductByRegistrationNumber(r);if(u.isErr())return e.isStatusCode(u.error,404)?e.Ok(null):e.Err(u.error);const{productGroup:o}=(a=u.value)!=null?a:{};return o==null?e.Ok(null):e.Ok(E.getLabelUrl(o,r,t))})},getNestedLabel(r){return c(this,null,function*(){const t=yield this.get("/product/{registrationNumber}/nested-label",{pathParams:{registrationNumber:r},parseAs:"arrayBuffer"});return t.isErr()?e.isStatusCode(t.error,404)?e.Ok(null):e.Err(t.error):e.Ok(new Uint8Array(t.value.data))})},exportProductGroupModels(r){return c(this,null,function*(){const t=yield this.get("/exportProducts/{productGroup}",{pathParams:{productGroup:r},parseAs:"arrayBuffer"});return t.isErr()?e.isStatusCode(t.error,404)?e.Ok(null):e.Err(t.error):e.Ok(new Uint8Array(t.value.data))})}});return i._features.push("eprel"),i}exports.withEPREL=R; | ||
| "use strict";var r=require("feature-fetch"),O=require("./helper/get-label-url.js"),f=require("./helper/get-language-set.js"),y=require("./helper/get-sheet-url.js"),E=Object.defineProperty,m=Object.getOwnPropertySymbols,k=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,v=(l,i,e)=>i in l?E(l,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[i]=e,P=(l,i)=>{for(var e in i||(i={}))k.call(i,e)&&v(l,e,i[e]);if(m)for(var e of m(i))S.call(i,e)&&v(l,e,i[e]);return l},c=(l,i,e)=>new Promise((t,a)=>{var u=s=>{try{n(e.next(s))}catch(p){a(p)}},o=s=>{try{n(e.throw(s))}catch(p){a(p)}},n=s=>s.done?t(s.value):Promise.resolve(s.value).then(u,o);n((e=e.apply(l,i)).next())});function w(l){if(!r.isFetchClientWithFeatures(l,["openapi"]))throw Error('FetchClient must have "openapi" feature to use withEPREL');const i=Object.assign(l,{getProductGroups(){return c(this,null,function*(){const e=yield this.get("/product-groups");return r.mapOk(e,t=>t.data)})},getModelsInProductGroup(e){return c(this,arguments,function*(t,a={}){const{page:u,limit:o,sort:n=[],includeOldProducts:s,filter:p={}}=a,d={};if(n.length>3)throw new r.FetchError("#ERR_MAX_3_SORT");n.forEach((g,h)=>{d[`sort${h.toString()}`]=g.field,d[`order${h.toString()}`]=g.order});const b=yield this.get("/products/{productGroup}",{pathParams:{productGroup:t},queryParams:P(P({_page:u,_limit:o,includeOldProducts:s},d),p)});return r.mapOk(b,g=>g.data)})},getProductByRegistrationNumber(e){return c(this,null,function*(){const t=yield this.get("/product/{registrationNumber}",{pathParams:{registrationNumber:e}});return t.isErr()?r.isStatusCode(t.error,404)?r.Ok(null):r.Err(t.error):r.Ok(t.value.data)})},getProductSheets(e){return c(this,arguments,function*(t,a={}){const{noRedirect:u=!1,language:o}=a,n=yield this.get("/product/{registrationNumber}/fiches",{pathParams:{registrationNumber:t},queryParams:{noRedirect:u,language:o},parseAs:u?"json":"arrayBuffer"});return n.isErr()?r.Err(n.error):r.Ok(n.value.data instanceof ArrayBuffer?new Uint8Array(n.value.data):n.value.data)})},getProductSheetUrls(e){return c(this,null,function*(){var t;const a=yield this.getProductByRegistrationNumber(e);if(a.isErr())return r.isStatusCode(a.error,404)?r.Ok([]):r.Err(a.error);const{productGroup:u,placementCountries:o}=(t=a.value)!=null?t:{};if(u==null||o==null)return r.Ok([]);const n=f.getLanguageSet(o);return r.Ok(Array.from(n).map(s=>({language:s,url:y.getSheetUrl(u,e,s)})))})},getProductSheetUrl(e,t){return c(this,null,function*(){var a;const u=yield this.getProductByRegistrationNumber(e);if(u.isErr())return r.isStatusCode(u.error,404)?r.Ok(null):r.Err(u.error);const{productGroup:o,placementCountries:n}=(a=u.value)!=null?a:{};return o==null||n==null?r.Ok(null):f.getLanguageSet(n).has(t)?r.Ok(y.getSheetUrl(o,e,t)):r.Ok(null)})},getProductLabels(e){return c(this,arguments,function*(t,a={}){const{noRedirect:u=!1,format:o,instance:n,supplierLabel:s,type:p}=a,d=yield this.get("/product/{registrationNumber}/labels",{pathParams:{registrationNumber:t},queryParams:{noRedirect:u,format:o,instance:n,supplier_label:s,type:p},parseAs:u?"json":"arrayBuffer"});return d.isErr()?r.Err(d.error):r.Ok(d.value.data instanceof ArrayBuffer?new Uint8Array(d.value.data):d.value.data)})},getProductLabelUrl(e,t){return c(this,null,function*(){var a;const u=yield this.getProductByRegistrationNumber(e);if(u.isErr())return r.isStatusCode(u.error,404)?r.Ok(null):r.Err(u.error);const{productGroup:o}=(a=u.value)!=null?a:{};return o==null?r.Ok(null):r.Ok(O.getLabelUrl(o,e,t))})},getNestedLabel(e){return c(this,null,function*(){const t=yield this.get("/product/{registrationNumber}/nested-label",{pathParams:{registrationNumber:e},parseAs:"arrayBuffer"});return t.isErr()?r.isStatusCode(t.error,404)?r.Ok(null):r.Err(t.error):r.Ok(new Uint8Array(t.value.data))})},exportProductGroupModels(e){return c(this,null,function*(){const t=yield this.get("/exportProducts/{productGroup}",{pathParams:{productGroup:e},parseAs:"arrayBuffer"});return t.isErr()?r.isStatusCode(t.error,404)?r.Ok(null):r.Err(t.error):r.Ok(new Uint8Array(t.value.data))})}});return i._features.push("eprel"),i}exports.withEPREL=w; |
@@ -1,1 +0,1 @@ | ||
| import{mapOk as y}from"@blgc/utils";import{isFetchClientWithFeatures as N,Ok as n,Err as d,isStatusCode as g,FetchError as O}from"feature-fetch";import{getLabelUrl as R}from"./helper/get-label-url.js";import{getLanguageSet as P}from"./helper/get-language-set.js";import{getSheetUrl as b}from"./helper/get-sheet-url.js";var B=Object.defineProperty,v=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,E=(l,o,r)=>o in l?B(l,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):l[o]=r,w=(l,o)=>{for(var r in o||(o={}))G.call(o,r)&&E(l,r,o[r]);if(v)for(var r of v(o))S.call(o,r)&&E(l,r,o[r]);return l},c=(l,o,r)=>new Promise((t,u)=>{var e=s=>{try{a(r.next(s))}catch(f){u(f)}},i=s=>{try{a(r.throw(s))}catch(f){u(f)}},a=s=>s.done?t(s.value):Promise.resolve(s.value).then(e,i);a((r=r.apply(l,o)).next())});function U(l){if(!N(l,["openapi"]))throw Error('FetchClient must have "openapi" feature to use withEPREL');const o=Object.assign(l,{getProductGroups(){return c(this,null,function*(){const r=yield this.get("/product-groups");return y(r,t=>t.data)})},getModelsInProductGroup(r){return c(this,arguments,function*(t,u={}){const{page:e,limit:i,sort:a=[],includeOldProducts:s,filter:f={}}=u,p={};if(a.length>3)throw new O("#ERR_MAX_3_SORT");a.forEach((h,m)=>{p[`sort${m.toString()}`]=h.field,p[`order${m.toString()}`]=h.order});const A=yield this.get("/products/{productGroup}",{pathParams:{productGroup:t},queryParams:w(w({_page:e,_limit:i,includeOldProducts:s},p),f)});return y(A,h=>h.data)})},getProductByRegistrationNumber(r){return c(this,null,function*(){const t=yield this.get("/product/{registrationNumber}",{pathParams:{registrationNumber:r}});return t.isErr()?g(t.error,404)?n(null):d(t.error):n(t.value.data)})},getProductSheets(r){return c(this,arguments,function*(t,u={}){const{noRedirect:e=!1,language:i}=u,a=yield this.get("/product/{registrationNumber}/fiches",{pathParams:{registrationNumber:t},queryParams:{noRedirect:e,language:i},parseAs:e?"json":"arrayBuffer"});return a.isErr()?d(a.error):n(a.value.data instanceof ArrayBuffer?new Uint8Array(a.value.data):a.value.data)})},getProductSheetUrls(r){return c(this,null,function*(){var t;const u=yield this.getProductByRegistrationNumber(r);if(u.isErr())return g(u.error,404)?n([]):d(u.error);const{productGroup:e,placementCountries:i}=(t=u.value)!=null?t:{};if(e==null||i==null)return n([]);const a=P(i);return n(Array.from(a).map(s=>({language:s,url:b(e,r,s)})))})},getProductSheetUrl(r,t){return c(this,null,function*(){var u;const e=yield this.getProductByRegistrationNumber(r);if(e.isErr())return g(e.error,404)?n(null):d(e.error);const{productGroup:i,placementCountries:a}=(u=e.value)!=null?u:{};return i==null||a==null?n(null):P(a).has(t)?n(b(i,r,t)):n(null)})},getProductLabels(r){return c(this,arguments,function*(t,u={}){const{noRedirect:e=!1,format:i,instance:a,supplierLabel:s,type:f}=u,p=yield this.get("/product/{registrationNumber}/labels",{pathParams:{registrationNumber:t},queryParams:{noRedirect:e,format:i,instance:a,supplier_label:s,type:f},parseAs:e?"json":"arrayBuffer"});return p.isErr()?d(p.error):n(p.value.data instanceof ArrayBuffer?new Uint8Array(p.value.data):p.value.data)})},getProductLabelUrl(r,t){return c(this,null,function*(){var u;const e=yield this.getProductByRegistrationNumber(r);if(e.isErr())return g(e.error,404)?n(null):d(e.error);const{productGroup:i}=(u=e.value)!=null?u:{};return i==null?n(null):n(R(i,r,t))})},getNestedLabel(r){return c(this,null,function*(){const t=yield this.get("/product/{registrationNumber}/nested-label",{pathParams:{registrationNumber:r},parseAs:"arrayBuffer"});return t.isErr()?g(t.error,404)?n(null):d(t.error):n(new Uint8Array(t.value.data))})},exportProductGroupModels(r){return c(this,null,function*(){const t=yield this.get("/exportProducts/{productGroup}",{pathParams:{productGroup:r},parseAs:"arrayBuffer"});return t.isErr()?g(t.error,404)?n(null):d(t.error):n(new Uint8Array(t.value.data))})}});return o._features.push("eprel"),o}export{U as withEPREL}; | ||
| import{isFetchClientWithFeatures as N,Ok as n,Err as d,isStatusCode as f,FetchError as O,mapOk as y}from"feature-fetch";import{getLabelUrl as R}from"./helper/get-label-url.js";import{getLanguageSet as P}from"./helper/get-language-set.js";import{getSheetUrl as b}from"./helper/get-sheet-url.js";var B=Object.defineProperty,v=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,E=(l,o,r)=>o in l?B(l,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):l[o]=r,w=(l,o)=>{for(var r in o||(o={}))G.call(o,r)&&E(l,r,o[r]);if(v)for(var r of v(o))S.call(o,r)&&E(l,r,o[r]);return l},c=(l,o,r)=>new Promise((e,u)=>{var t=s=>{try{a(r.next(s))}catch(g){u(g)}},i=s=>{try{a(r.throw(s))}catch(g){u(g)}},a=s=>s.done?e(s.value):Promise.resolve(s.value).then(t,i);a((r=r.apply(l,o)).next())});function U(l){if(!N(l,["openapi"]))throw Error('FetchClient must have "openapi" feature to use withEPREL');const o=Object.assign(l,{getProductGroups(){return c(this,null,function*(){const r=yield this.get("/product-groups");return y(r,e=>e.data)})},getModelsInProductGroup(r){return c(this,arguments,function*(e,u={}){const{page:t,limit:i,sort:a=[],includeOldProducts:s,filter:g={}}=u,p={};if(a.length>3)throw new O("#ERR_MAX_3_SORT");a.forEach((h,m)=>{p[`sort${m.toString()}`]=h.field,p[`order${m.toString()}`]=h.order});const A=yield this.get("/products/{productGroup}",{pathParams:{productGroup:e},queryParams:w(w({_page:t,_limit:i,includeOldProducts:s},p),g)});return y(A,h=>h.data)})},getProductByRegistrationNumber(r){return c(this,null,function*(){const e=yield this.get("/product/{registrationNumber}",{pathParams:{registrationNumber:r}});return e.isErr()?f(e.error,404)?n(null):d(e.error):n(e.value.data)})},getProductSheets(r){return c(this,arguments,function*(e,u={}){const{noRedirect:t=!1,language:i}=u,a=yield this.get("/product/{registrationNumber}/fiches",{pathParams:{registrationNumber:e},queryParams:{noRedirect:t,language:i},parseAs:t?"json":"arrayBuffer"});return a.isErr()?d(a.error):n(a.value.data instanceof ArrayBuffer?new Uint8Array(a.value.data):a.value.data)})},getProductSheetUrls(r){return c(this,null,function*(){var e;const u=yield this.getProductByRegistrationNumber(r);if(u.isErr())return f(u.error,404)?n([]):d(u.error);const{productGroup:t,placementCountries:i}=(e=u.value)!=null?e:{};if(t==null||i==null)return n([]);const a=P(i);return n(Array.from(a).map(s=>({language:s,url:b(t,r,s)})))})},getProductSheetUrl(r,e){return c(this,null,function*(){var u;const t=yield this.getProductByRegistrationNumber(r);if(t.isErr())return f(t.error,404)?n(null):d(t.error);const{productGroup:i,placementCountries:a}=(u=t.value)!=null?u:{};return i==null||a==null?n(null):P(a).has(e)?n(b(i,r,e)):n(null)})},getProductLabels(r){return c(this,arguments,function*(e,u={}){const{noRedirect:t=!1,format:i,instance:a,supplierLabel:s,type:g}=u,p=yield this.get("/product/{registrationNumber}/labels",{pathParams:{registrationNumber:e},queryParams:{noRedirect:t,format:i,instance:a,supplier_label:s,type:g},parseAs:t?"json":"arrayBuffer"});return p.isErr()?d(p.error):n(p.value.data instanceof ArrayBuffer?new Uint8Array(p.value.data):p.value.data)})},getProductLabelUrl(r,e){return c(this,null,function*(){var u;const t=yield this.getProductByRegistrationNumber(r);if(t.isErr())return f(t.error,404)?n(null):d(t.error);const{productGroup:i}=(u=t.value)!=null?u:{};return i==null?n(null):n(R(i,r,e))})},getNestedLabel(r){return c(this,null,function*(){const e=yield this.get("/product/{registrationNumber}/nested-label",{pathParams:{registrationNumber:r},parseAs:"arrayBuffer"});return e.isErr()?f(e.error,404)?n(null):d(e.error):n(new Uint8Array(e.value.data))})},exportProductGroupModels(r){return c(this,null,function*(){const e=yield this.get("/exportProducts/{productGroup}",{pathParams:{productGroup:r},parseAs:"arrayBuffer"});return e.isErr()?f(e.error,404)?n(null):d(e.error):n(new Uint8Array(e.value.data))})}});return o._features.push("eprel"),o}export{U as withEPREL}; |
+7
-8
| { | ||
| "name": "eprel-client", | ||
| "version": "0.0.31", | ||
| "version": "0.0.32", | ||
| "private": false, | ||
@@ -26,12 +26,11 @@ "description": "Typesafe and straightforward fetch client for interacting with the European Product Registry for Energy Labelling (EPREL) API using feature-fetch", | ||
| "dependencies": { | ||
| "@blgc/utils": "0.0.58", | ||
| "feature-fetch": "0.0.50", | ||
| "@blgc/types": "0.0.18" | ||
| "@blgc/types": "0.0.19", | ||
| "feature-fetch": "0.0.51" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/node": "^24.1.0", | ||
| "@types/node": "^24.3.0", | ||
| "dotenv": "^17.2.1", | ||
| "openapi-typescript": "^7.8.0", | ||
| "@blgc/config": "0.0.36", | ||
| "rollup-presets": "0.0.22" | ||
| "openapi-typescript": "^7.9.1", | ||
| "@blgc/config": "0.0.37", | ||
| "rollup-presets": "0.0.23" | ||
| }, | ||
@@ -38,0 +37,0 @@ "size-limit": [ |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
2
-33.33%51203
-0.15%827
-0.12%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
Updated
Updated