@decaf-ts/for-http 0.3.1 → 0.3.3
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/README.md +1 -1
- package/dist/for-http.cjs +1 -1
- package/dist/for-http.cjs.map +1 -1
- package/dist/for-http.js +1 -1
- package/dist/for-http.js.map +1 -1
- package/lib/adapter.cjs +30 -0
- package/lib/adapter.d.ts +2 -1
- package/lib/adapter.js.map +1 -1
- package/lib/axios/axios.cjs +1 -15
- package/lib/axios/axios.js.map +1 -1
- package/lib/esm/adapter.d.ts +2 -1
- package/lib/esm/adapter.js +32 -2
- package/lib/esm/adapter.js.map +1 -1
- package/lib/esm/axios/axios.js +1 -15
- package/lib/esm/axios/axios.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ A lightweight HTTP adapter layer for decaf-ts that enables CRUD-style repositori
|
|
|
27
27
|
|
|
28
28
|
Documentation available [here](https://decaf-ts.github.io/for-http/)
|
|
29
29
|
|
|
30
|
-
Minimal size: 1.
|
|
30
|
+
Minimal size: 1.4 KB kb gzipped
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
# decaf-ts/for-http — Detailed Description
|
package/dist/for-http.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e,r;e=this,r=function(e,r,t,s,o){"use strict";class n extends r.Repository{constructor(e,r){super(e,r)}url(e,r){return this.adapter.url(e,r)}async request(e){return this.adapter.request(e)}}class i extends n{constructor(e,r){super(e,r),this._overrides={ignoreValidation:!0,ignoreHandlers:!0}}toString(){return s.Model.tableName(this.class)+" REST service"}}class a extends r.Adapter{constructor(e,r,t){super(e,r,t)}flags(e,r,t){return Object.assign(super.flags(e,r,t),{headers:{}})}repository(){return i}prepare(e,...t){const{log:o}=this.logCtx(t,this.prepare),n=Object.assign({},e);return e[r.PersistenceKeys.METADATA]&&(o.silly("Passing along persistence metadata for "+e[r.PersistenceKeys.METADATA]),Object.defineProperty(n,r.PersistenceKeys.METADATA,{enumerable:!1,writable:!1,configurable:!0,value:e[r.PersistenceKeys.METADATA]})),{record:e,id:e[s.Model.pk(e.constructor)]}}revert(e,o,n,...i){const{log:a}=this.logCtx(i,this.revert),c={},l="string"==typeof o?s.Model.build(c,o):new o(c);a.silly(`Rebuilding model ${l.constructor.name} id ${n}`);const d="string"==typeof o?s.Model.get(o):o;if(!d)throw new t.InternalError("Failed to retrieve model constructor for "+o);const u=new d(e),p=e[r.PersistenceKeys.METADATA];return p&&(a.silly(`Passing along ${this.flavour} persistence metadata for ${l.constructor.name} id ${n}: ${p}`),Object.defineProperty(u,r.PersistenceKeys.METADATA,{enumerable:!1,configurable:!1,writable:!1,value:p})),u}toTableName(e){return"string"==typeof e?e:s.Model.tableName(e)}url(e,r){e=this.toTableName(e);const t=new URL(`${this.config.protocol}://${this.config.host}/${e}`);return r&&Object.entries(r).forEach(([e,r])=>t.searchParams.append(e,r.toString())),encodeURI(t.toString()).replace(/\+/g,"%20")}raw(e,...t){return Promise.reject(new r.UnsupportedError("Api is not natively available for HttpAdapters. If required, please extends this class"))}Sequence(e){return Promise.reject(new r.UnsupportedError("Api is not natively available for HttpAdapters. If required, please extends this class"))}Statement(){throw new r.UnsupportedError("Api is not natively available for HttpAdapters. If required, please extends this class")}parseCondition(e){throw new r.UnsupportedError("Api is not natively available for HttpAdapters. If required, please extends this class")}}const c="axios";class l extends a{constructor(e,r){super(e,c,r)}getClient(){return new o.Axios({baseURL:`${this.config.protocol}://${this.config.host}`})}async request(e){return this.client.request(e)}async create(e,r,t,...s){try{const r=this.url(e);return this.client.post(r,t)}catch(e){throw this.parseError(e)}}async read(e,r,...t){try{const t=this.url(e,{id:r});return this.client.get(t)}catch(e){throw this.parseError(e)}}async update(e,r,t,...s){try{const r=this.url(e);return this.client.put(r,t)}catch(e){throw this.parseError(e)}}async delete(e,r,...t){try{const t=this.url(e,{id:r});return this.client.delete(t)}catch(e){throw this.parseError(e)}}parseError(e,...
|
|
1
|
+
var e,r;e=this,r=function(e,r,t,s,o){"use strict";class n extends r.Repository{constructor(e,r){super(e,r)}url(e,r){return this.adapter.url(e,r)}async request(e){return this.adapter.request(e)}}class i extends n{constructor(e,r){super(e,r),this._overrides={ignoreValidation:!0,ignoreHandlers:!0}}toString(){return s.Model.tableName(this.class)+" REST service"}}class a extends r.Adapter{constructor(e,r,t){super(e,r,t)}flags(e,r,t){return Object.assign(super.flags(e,r,t),{headers:{}})}repository(){return i}prepare(e,...t){const{log:o}=this.logCtx(t,this.prepare),n=Object.assign({},e);return e[r.PersistenceKeys.METADATA]&&(o.silly("Passing along persistence metadata for "+e[r.PersistenceKeys.METADATA]),Object.defineProperty(n,r.PersistenceKeys.METADATA,{enumerable:!1,writable:!1,configurable:!0,value:e[r.PersistenceKeys.METADATA]})),{record:e,id:e[s.Model.pk(e.constructor)]}}revert(e,o,n,...i){const{log:a}=this.logCtx(i,this.revert),c={},l="string"==typeof o?s.Model.build(c,o):new o(c);a.silly(`Rebuilding model ${l.constructor.name} id ${n}`);const d="string"==typeof o?s.Model.get(o):o;if(!d)throw new t.InternalError("Failed to retrieve model constructor for "+o);const u=new d(e),p=e[r.PersistenceKeys.METADATA];return p&&(a.silly(`Passing along ${this.flavour} persistence metadata for ${l.constructor.name} id ${n}: ${p}`),Object.defineProperty(u,r.PersistenceKeys.METADATA,{enumerable:!1,configurable:!1,writable:!1,value:p})),u}toTableName(e){return"string"==typeof e?e:s.Model.tableName(e)}url(e,r){e=this.toTableName(e);const t=new URL(`${this.config.protocol}://${this.config.host}/${e}`);return r&&Object.entries(r).forEach(([e,r])=>t.searchParams.append(e,r.toString())),encodeURI(t.toString()).replace(/\+/g,"%20")}raw(e,...t){return Promise.reject(new r.UnsupportedError("Api is not natively available for HttpAdapters. If required, please extends this class"))}Sequence(e){return Promise.reject(new r.UnsupportedError("Api is not natively available for HttpAdapters. If required, please extends this class"))}Statement(){throw new r.UnsupportedError("Api is not natively available for HttpAdapters. If required, please extends this class")}parseCondition(e){throw new r.UnsupportedError("Api is not natively available for HttpAdapters. If required, please extends this class")}static parseError(e,...s){const o="string"==typeof e?e:e.message;return o.includes(t.NotFoundError.name)?new t.NotFoundError(e):o.includes(t.ConflictError.name)?new t.ConflictError(e):o.includes(t.BadRequestError.name)?new t.BadRequestError(e):o.includes(r.QueryError.name)?new r.QueryError(e):o.includes(r.PagingError.name)?new r.PagingError(e):o.includes(r.UnsupportedError.name)?new r.UnsupportedError(e):o.includes(r.MigrationError.name)?new r.MigrationError(e):o.includes(r.ObserverError.name)?new r.ObserverError(e):o.includes(r.AuthorizationError.name)?new r.AuthorizationError(e):o.includes(r.ForbiddenError.name)?new r.ForbiddenError(e):o.includes(r.ConnectionError.name)?new r.ConnectionError(e):o.includes(t.SerializationError.name)?new t.SerializationError(e):new t.InternalError(e)}}const c="axios";class l extends a{constructor(e,r){super(e,c,r)}getClient(){return new o.Axios({baseURL:`${this.config.protocol}://${this.config.host}`})}async request(e){return this.client.request(e)}async create(e,r,t,...s){try{const r=this.url(e);return this.client.post(r,t)}catch(e){throw this.parseError(e)}}async read(e,r,...t){try{const t=this.url(e,{id:r});return this.client.get(t)}catch(e){throw this.parseError(e)}}async update(e,r,t,...s){try{const r=this.url(e);return this.client.put(r,t)}catch(e){throw this.parseError(e)}}async delete(e,r,...t){try{const t=this.url(e,{id:r});return this.client.delete(t)}catch(e){throw this.parseError(e)}}parseError(e,...r){return a.parseError(e,...r)}}l.decoration(),e.AxiosFlavour=c,e.AxiosHttpAdapter=l,e.HttpAdapter=a,e.RestRepository=n,e.RestService=i,e.VERSION="##VERSION##"},"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@decaf-ts/core"),require("@decaf-ts/db-decorators"),require("@decaf-ts/decorator-validation"),require("axios")):"function"==typeof define&&define.amd?define(["exports","@decaf-ts/core","@decaf-ts/db-decorators","@decaf-ts/decorator-validation","axios"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self)["for-http"]={},e.decafTsCore,e.decafTsDbDecorators,e.decafTsDecoratorValidation,e.axios);
|
|
2
2
|
//# sourceMappingURL=for-http.cjs.map
|
package/dist/for-http.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"for-http.cjs","sources":["../src/RestRepository.ts","../src/RestService.ts","../src/adapter.ts","../src/axios/constants.ts","../src/axios/axios.ts","../src/axios/index.ts","../src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":["RestRepository","Repository","constructor","adapter","clazz","super","url","path","queryParams","this","request","details","RestService","_overrides","ignoreValidation","ignoreHandlers","toString","Model","tableName","class","HttpAdapter","Adapter","config","flavour","alias","flags","operation","model","overrides","Object","assign","headers","repository","prepare","args","log","logCtx","result","PersistenceKeys","METADATA","silly","defineProperty","enumerable","writable","configurable","value","record","id","pk","revert","obj","ob","m","build","name","constr","get","InternalError","metadata","toTableName","t","URL","protocol","host","entries","forEach","key","searchParams","append","encodeURI","replace","raw","rawInput","Promise","reject","UnsupportedError","Sequence","options","Statement","parseCondition","condition","
|
|
1
|
+
{"version":3,"file":"for-http.cjs","sources":["../src/RestRepository.ts","../src/RestService.ts","../src/adapter.ts","../src/axios/constants.ts","../src/axios/axios.ts","../src/axios/index.ts","../src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":["RestRepository","Repository","constructor","adapter","clazz","super","url","path","queryParams","this","request","details","RestService","_overrides","ignoreValidation","ignoreHandlers","toString","Model","tableName","class","HttpAdapter","Adapter","config","flavour","alias","flags","operation","model","overrides","Object","assign","headers","repository","prepare","args","log","logCtx","result","PersistenceKeys","METADATA","silly","defineProperty","enumerable","writable","configurable","value","record","id","pk","revert","obj","ob","m","build","name","constr","get","InternalError","metadata","toTableName","t","URL","protocol","host","entries","forEach","key","searchParams","append","encodeURI","replace","raw","rawInput","Promise","reject","UnsupportedError","Sequence","options","Statement","parseCondition","condition","parseError","err","msg","message","includes","NotFoundError","ConflictError","BadRequestError","QueryError","PagingError","MigrationError","ObserverError","AuthorizationError","ForbiddenError","ConnectionError","SerializationError","AxiosFlavour","AxiosHttpAdapter","getClient","Axios","baseURL","client","create","_args","post","e","read","update","put","delete","decoration"],"mappings":"kDAkCM,MAAOA,UAIHC,EAAAA,WACR,WAAAC,CAAYC,EAAYC,GACtBC,MAAMF,EAASC,EAChB,CAED,GAAAE,CACEC,EACAC,GAEA,OAAOC,KAAKN,QAAQG,IAAIC,EAAMC,EAC/B,CAED,aAAME,CAAWC,GACf,OAAOF,KAAKN,QAAQO,QAAWC,EAChC,ECEG,MAAOC,UAIHZ,EAaR,WAAAE,CAAYC,EAAYC,GACtBC,MAAMF,EAASC,GAbEK,KAAAI,WAAkC,CACnDC,kBAAkB,EAClBC,gBAAgB,EAYjB,CAEQ,QAAAC,GACP,OAAUC,EAAAA,MAAMC,UAAUT,KAAKU,OAAxB,eACR,ECTG,MAAgBC,UAKZC,EAAAA,QACR,WAAAnB,CAAsBoB,EAAcC,EAAiBC,GACnDnB,MAAMiB,EAAQC,EAASC,EACxB,CAaQ,KAAAC,CACPC,EAKAC,EACAC,GAEA,OAAOC,OAAOC,OAAOzB,MAAMoB,MAASC,EAAWC,EAAOC,GAAY,CAChEG,QAAS,CAAE,GAEd,CASQ,UAAAC,GAGP,OAAOpB,CACR,CAYQ,OAAAqB,CACPN,KACGO,GAEH,MAAMC,IAAEA,GAAQ1B,KAAK2B,OAAOF,EAAMzB,KAAKwB,SACjCI,EAASR,OAAOC,OAAO,CAAE,EAAEH,GAajC,OAZKA,EAAcW,kBAAgBC,YACjCJ,EAAIK,MACF,0CAA2Cb,EAAcW,EAAAA,gBAAgBC,WAE3EV,OAAOY,eAAeJ,EAAQC,EAAAA,gBAAgBC,SAAU,CACtDG,YAAY,EACZC,UAAU,EACVC,cAAc,EACdC,MAAQlB,EAAcW,EAAeA,gBAACC,aAInC,CACLO,OAAQnB,EACRoB,GAAI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GACjB,OAAO,IAAIC,EAAAA,MAAM,CACfC,QAAS,GAAG5F,KAAKa,OAAOwC,cAAcrD,KAAKa,OAAOyC,QAErD,CAUQ,aAAMrD,CAAWC,GACxB,OAAOF,KAAK6F,OAAO5F,QAAQC,EAC5B,CAWQ,YAAM4F,CACbrF,EACA6B,EACApB,KAEG6E,GAEH,IACE,MAAMlG,EAAMG,KAAKH,IAAIY,GACrB,OAAOT,KAAK6F,OAAOG,KAAKnG,EAAKqB,EAC9B,CAAC,MAAO+E,GACP,MAAMjG,KAAKwE,WAAWyB,EACvB,CACF,CASQ,UAAMC,CACbzF,EACA6B,KAEGb,GAEH,IACE,MAAM5B,EAAMG,KAAKH,IAAIY,EAAW,CAC9B6B,GAAIA,IAEN,OAAOtC,KAAK6F,OAAO9C,IAAIlD,EACxB,CAAC,MAAOoG,GACP,MAAMjG,KAAKwE,WAAWyB,EACvB,CACF,CAWQ,YAAME,CACb1F,EACA6B,EACApB,KAEG6E,GAEH,IACE,MAAMlG,EAAMG,KAAKH,IAAIY,GACrB,OAAOT,KAAK6F,OAAOO,IAAIvG,EAAKqB,EAC7B,CAAC,MAAO+E,GACP,MAAMjG,KAAKwE,WAAWyB,EACvB,CACF,CAUQ,YAAM,CACbxF,EACA6B,KAEGyD,GAEH,IACE,MAAMlG,EAAMG,KAAKH,IAAIY,EAAW,CAC9B6B,GAAIA,IAEN,OAAOtC,KAAK6F,OAAOQ,OAAOxG,EAC3B,CAAC,MAAOoG,GACP,MAAMjG,KAAKwE,WAAWyB,EACvB,CACF,CAEQ,UAAAzB,CAAgCC,KAAehD,GACtD,OAAOd,EAAY6D,WAAWC,KAAQhD,EACvC,EC1KHgE,EAAiBa,gHCSM"}
|
package/dist/for-http.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Repository as e,Adapter as t,PersistenceKeys as r,UnsupportedError as s,AuthorizationError as
|
|
1
|
+
import{Repository as e,Adapter as t,PersistenceKeys as r,UnsupportedError as s,QueryError as n,PagingError as a,MigrationError as i,ObserverError as o,AuthorizationError as c,ForbiddenError as l,ConnectionError as u}from"@decaf-ts/core";import{InternalError as d,NotFoundError as p,ConflictError as h,BadRequestError as m,SerializationError as f}from"@decaf-ts/db-decorators";import{Model as g}from"@decaf-ts/decorator-validation";import{Axios as w}from"axios";class A extends e{constructor(e,t){super(e,t)}url(e,t){return this.adapter.url(e,t)}async request(e){return this.adapter.request(e)}}class y extends A{constructor(e,t){super(e,t),this._overrides={ignoreValidation:!0,ignoreHandlers:!0}}toString(){return g.tableName(this.class)+" REST service"}}class b extends t{constructor(e,t,r){super(e,t,r)}flags(e,t,r){return Object.assign(super.flags(e,t,r),{headers:{}})}repository(){return y}prepare(e,...t){const{log:s}=this.logCtx(t,this.prepare),n=Object.assign({},e);return e[r.METADATA]&&(s.silly("Passing along persistence metadata for "+e[r.METADATA]),Object.defineProperty(n,r.METADATA,{enumerable:!1,writable:!1,configurable:!0,value:e[r.METADATA]})),{record:e,id:e[g.pk(e.constructor)]}}revert(e,t,s,...n){const{log:a}=this.logCtx(n,this.revert),i={},o="string"==typeof t?g.build(i,t):new t(i);a.silly(`Rebuilding model ${o.constructor.name} id ${s}`);const c="string"==typeof t?g.get(t):t;if(!c)throw new d("Failed to retrieve model constructor for "+t);const l=new c(e),u=e[r.METADATA];return u&&(a.silly(`Passing along ${this.flavour} persistence metadata for ${o.constructor.name} id ${s}: ${u}`),Object.defineProperty(l,r.METADATA,{enumerable:!1,configurable:!1,writable:!1,value:u})),l}toTableName(e){return"string"==typeof e?e:g.tableName(e)}url(e,t){e=this.toTableName(e);const r=new URL(`${this.config.protocol}://${this.config.host}/${e}`);return t&&Object.entries(t).forEach(([e,t])=>r.searchParams.append(e,t.toString())),encodeURI(r.toString()).replace(/\+/g,"%20")}raw(e,...t){return Promise.reject(new s("Api is not natively available for HttpAdapters. If required, please extends this class"))}Sequence(e){return Promise.reject(new s("Api is not natively available for HttpAdapters. If required, please extends this class"))}Statement(){throw new s("Api is not natively available for HttpAdapters. If required, please extends this class")}parseCondition(e){throw new s("Api is not natively available for HttpAdapters. If required, please extends this class")}static parseError(e,...t){const r="string"==typeof e?e:e.message;return r.includes(p.name)?new p(e):r.includes(h.name)?new h(e):r.includes(m.name)?new m(e):r.includes(n.name)?new n(e):r.includes(a.name)?new a(e):r.includes(s.name)?new s(e):r.includes(i.name)?new i(e):r.includes(o.name)?new o(e):r.includes(c.name)?new c(e):r.includes(l.name)?new l(e):r.includes(u.name)?new u(e):r.includes(f.name)?new f(e):new d(e)}}const v="axios";class E extends b{constructor(e,t){super(e,v,t)}getClient(){return new w({baseURL:`${this.config.protocol}://${this.config.host}`})}async request(e){return this.client.request(e)}async create(e,t,r,...s){try{const t=this.url(e);return this.client.post(t,r)}catch(e){throw this.parseError(e)}}async read(e,t,...r){try{const r=this.url(e,{id:t});return this.client.get(r)}catch(e){throw this.parseError(e)}}async update(e,t,r,...s){try{const t=this.url(e);return this.client.put(t,r)}catch(e){throw this.parseError(e)}}async delete(e,t,...r){try{const r=this.url(e,{id:t});return this.client.delete(r)}catch(e){throw this.parseError(e)}}parseError(e,...t){return b.parseError(e,...t)}}E.decoration();const T="##VERSION##";export{v as AxiosFlavour,E as AxiosHttpAdapter,b as HttpAdapter,A as RestRepository,y as RestService,T as VERSION};
|
|
2
2
|
//# sourceMappingURL=for-http.js.map
|
package/dist/for-http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"for-http.js","sources":["../src/RestRepository.ts","../src/RestService.ts","../src/adapter.ts","../src/axios/constants.ts","../src/axios/axios.ts","../src/axios/index.ts","../src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":["RestRepository","Repository","constructor","adapter","clazz","super","url","path","queryParams","this","request","details","RestService","_overrides","ignoreValidation","ignoreHandlers","toString","Model","tableName","class","HttpAdapter","Adapter","config","flavour","alias","flags","operation","model","overrides","Object","assign","headers","repository","prepare","args","log","logCtx","result","PersistenceKeys","METADATA","silly","defineProperty","enumerable","writable","configurable","value","record","id","pk","revert","obj","ob","m","build","name","constr","get","InternalError","metadata","toTableName","t","URL","protocol","host","entries","forEach","key","searchParams","append","encodeURI","replace","raw","rawInput","Promise","reject","UnsupportedError","Sequence","options","Statement","parseCondition","condition","
|
|
1
|
+
{"version":3,"file":"for-http.js","sources":["../src/RestRepository.ts","../src/RestService.ts","../src/adapter.ts","../src/axios/constants.ts","../src/axios/axios.ts","../src/axios/index.ts","../src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":["RestRepository","Repository","constructor","adapter","clazz","super","url","path","queryParams","this","request","details","RestService","_overrides","ignoreValidation","ignoreHandlers","toString","Model","tableName","class","HttpAdapter","Adapter","config","flavour","alias","flags","operation","model","overrides","Object","assign","headers","repository","prepare","args","log","logCtx","result","PersistenceKeys","METADATA","silly","defineProperty","enumerable","writable","configurable","value","record","id","pk","revert","obj","ob","m","build","name","constr","get","InternalError","metadata","toTableName","t","URL","protocol","host","entries","forEach","key","searchParams","append","encodeURI","replace","raw","rawInput","Promise","reject","UnsupportedError","Sequence","options","Statement","parseCondition","condition","parseError","err","msg","message","includes","NotFoundError","ConflictError","BadRequestError","QueryError","PagingError","MigrationError","ObserverError","AuthorizationError","ForbiddenError","ConnectionError","SerializationError","AxiosFlavour","AxiosHttpAdapter","getClient","Axios","baseURL","client","create","_args","post","e","read","update","put","delete","decoration","VERSION"],"mappings":"6cAkCM,MAAOA,UAIHC,EACR,WAAAC,CAAYC,EAAYC,GACtBC,MAAMF,EAASC,EAChB,CAED,GAAAE,CACEC,EACAC,GAEA,OAAOC,KAAKN,QAAQG,IAAIC,EAAMC,EAC/B,CAED,aAAME,CAAWC,GACf,OAAOF,KAAKN,QAAQO,QAAWC,EAChC,ECEG,MAAOC,UAIHZ,EAaR,WAAAE,CAAYC,EAAYC,GACtBC,MAAMF,EAASC,GAbEK,KAAAI,WAAkC,CACnDC,kBAAkB,EAClBC,gBAAgB,EAYjB,CAEQ,QAAAC,GACP,OAAUC,EAAMC,UAA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,OAAOxG,EAC3B,CAAC,MAAOoG,GACP,MAAMjG,KAAKwE,WAAWyB,EACvB,CACF,CAEQ,UAAAzB,CAAgCC,KAAehD,GACtD,OAAOd,EAAY6D,WAAWC,KAAQhD,EACvC,EC1KHgE,EAAiBa,aCSV,MAAMC,EAAU"}
|
package/lib/adapter.cjs
CHANGED
|
@@ -200,6 +200,36 @@ class HttpAdapter extends core_1.Adapter {
|
|
|
200
200
|
parseCondition(condition) {
|
|
201
201
|
throw new core_1.UnsupportedError("Api is not natively available for HttpAdapters. If required, please extends this class");
|
|
202
202
|
}
|
|
203
|
+
static parseError(err,
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
205
|
+
...args) {
|
|
206
|
+
const msg = typeof err === "string" ? err : err.message;
|
|
207
|
+
if (msg.includes(db_decorators_1.NotFoundError.name))
|
|
208
|
+
return new db_decorators_1.NotFoundError(err);
|
|
209
|
+
if (msg.includes(db_decorators_1.ConflictError.name))
|
|
210
|
+
return new db_decorators_1.ConflictError(err);
|
|
211
|
+
if (msg.includes(db_decorators_1.BadRequestError.name))
|
|
212
|
+
return new db_decorators_1.BadRequestError(err);
|
|
213
|
+
if (msg.includes(core_1.QueryError.name))
|
|
214
|
+
return new core_1.QueryError(err);
|
|
215
|
+
if (msg.includes(core_1.PagingError.name))
|
|
216
|
+
return new core_1.PagingError(err);
|
|
217
|
+
if (msg.includes(core_1.UnsupportedError.name))
|
|
218
|
+
return new core_1.UnsupportedError(err);
|
|
219
|
+
if (msg.includes(core_1.MigrationError.name))
|
|
220
|
+
return new core_1.MigrationError(err);
|
|
221
|
+
if (msg.includes(core_1.ObserverError.name))
|
|
222
|
+
return new core_1.ObserverError(err);
|
|
223
|
+
if (msg.includes(core_1.AuthorizationError.name))
|
|
224
|
+
return new core_1.AuthorizationError(err);
|
|
225
|
+
if (msg.includes(core_1.ForbiddenError.name))
|
|
226
|
+
return new core_1.ForbiddenError(err);
|
|
227
|
+
if (msg.includes(core_1.ConnectionError.name))
|
|
228
|
+
return new core_1.ConnectionError(err);
|
|
229
|
+
if (msg.includes(db_decorators_1.SerializationError.name))
|
|
230
|
+
return new db_decorators_1.SerializationError(err);
|
|
231
|
+
return new db_decorators_1.InternalError(err);
|
|
232
|
+
}
|
|
203
233
|
}
|
|
204
234
|
exports.HttpAdapter = HttpAdapter;
|
|
205
235
|
//# sourceMappingURL=adapter.js.map
|
package/lib/adapter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Adapter, Condition, ContextualArgs, PreparedModel, Repository, Sequence, SequenceOptions } from "@decaf-ts/core";
|
|
2
|
-
import { Context, FlagsOf, OperationKeys, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
2
|
+
import { BaseError, Context, FlagsOf, OperationKeys, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
3
3
|
import { HttpConfig, HttpFlags } from "./types";
|
|
4
4
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
5
|
import { Constructor } from "@decaf-ts/decoration";
|
|
@@ -188,4 +188,5 @@ export declare abstract class HttpAdapter<CONF extends HttpConfig, CON, Q, C ext
|
|
|
188
188
|
* @throws {UnsupportedError} Always throws as this method is not supported by default
|
|
189
189
|
*/
|
|
190
190
|
parseCondition(condition: Condition<any>): Q;
|
|
191
|
+
static parseError<E extends BaseError>(err: Error | string, ...args: any[]): E;
|
|
191
192
|
}
|
package/lib/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":";;;AAAA,yCAiBwB;AACxB,2DAWiC;AAEjC,yEAAuD;AAEvD,mDAA4C;AAG5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAsB,WAKpB,SAAQ,cAAwB;IAChC,YAAsB,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,IAAI,yBAAkB,CAAC,GAAG,CAAM,CAAC;QAC1C,IAAI,GAAG,CAAC,QAAQ,CAAC,qBAAc,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,qBAAc,CAAC,GAAG,CAAM,CAAC;QAC3E,IAAI,GAAG,CAAC,QAAQ,CAAC,sBAAe,CAAC,IAAI,CAAC;YACpC,OAAO,IAAI,sBAAe,CAAC,GAAG,CAAM,CAAC;QACvC,IAAI,GAAG,CAAC,QAAQ,CAAC,kCAAkB,CAAC,IAAI,CAAC;YACvC,OAAO,IAAI,kCAAkB,CAAC,GAAG,CAAM,CAAC;QAC1C,OAAO,IAAI,6BAAa,CAAC,GAAG,CAAM,CAAC;IACrC,CAAC;CACF;AA1UD,kCA0UC"}
|
package/lib/axios/axios.cjs
CHANGED
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AxiosHttpAdapter = void 0;
|
|
4
4
|
const adapter_1 = require("./../adapter.cjs");
|
|
5
5
|
const axios_1 = require("axios");
|
|
6
|
-
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
7
|
-
const core_1 = require("@decaf-ts/core");
|
|
8
6
|
const constants_1 = require("./constants.cjs");
|
|
9
7
|
/**
|
|
10
8
|
* @description Axios implementation of the HTTP adapter
|
|
@@ -155,20 +153,8 @@ class AxiosHttpAdapter extends adapter_1.HttpAdapter {
|
|
|
155
153
|
throw this.parseError(e);
|
|
156
154
|
}
|
|
157
155
|
}
|
|
158
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
159
156
|
parseError(err, ...args) {
|
|
160
|
-
|
|
161
|
-
db_decorators_1.InternalError,
|
|
162
|
-
core_1.AuthorizationError,
|
|
163
|
-
db_decorators_1.ConflictError,
|
|
164
|
-
db_decorators_1.NotFoundError,
|
|
165
|
-
core_1.UnsupportedError,
|
|
166
|
-
];
|
|
167
|
-
for (const error of errs) {
|
|
168
|
-
if (err.message.includes(error.name))
|
|
169
|
-
return new error(err.message);
|
|
170
|
-
}
|
|
171
|
-
return new db_decorators_1.InternalError(err.message);
|
|
157
|
+
return adapter_1.HttpAdapter.parseError(err, ...args);
|
|
172
158
|
}
|
|
173
159
|
}
|
|
174
160
|
exports.AxiosHttpAdapter = AxiosHttpAdapter;
|
package/lib/axios/axios.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../src/axios/axios.ts"],"names":[],"mappings":";;;AAAA,8CAAyC;AACzC,iCAAkD;
|
|
1
|
+
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../src/axios/axios.ts"],"names":[],"mappings":";;;AAAA,8CAAyC;AACzC,iCAAkD;AAKlD,+CAA2C;AAI3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAa,gBAAiB,SAAQ,qBAKrC;IACC,YAAY,MAAkB,EAAE,KAAc;QAC5C,KAAK,CAAC,MAAM,EAAE,wBAAY,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAEkB,SAAS;QAC1B,OAAO,IAAI,aAAK,CAAC;YACf,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;SACnC,CAAC,CAAC;IAC3B,CAAC;IAED;;;;;;;OAOG;IACM,KAAK,CAAC,OAAO,CAAI,OAA2B;QACnD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;;;OAQG;IACM,KAAK,CAAC,MAAM,CACnB,SAAkC,EAClC,EAAkB,EAClB,KAA0B;IAC1B,6DAA6D;IAC7D,GAAG,KAA0C;QAE7C,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAChC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EA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AAG,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAEQ,UAAU,CAAsB,GAAU,EAAE,GAAG,IAAW;QACjE,OAAO,qBAAW,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9C,CAAC;CACF;AA9HD,4CA8HC"}
|
package/lib/esm/adapter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Adapter, Condition, ContextualArgs, PreparedModel, Repository, Sequence, SequenceOptions } from "@decaf-ts/core";
|
|
2
|
-
import { Context, FlagsOf, OperationKeys, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
2
|
+
import { BaseError, Context, FlagsOf, OperationKeys, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
3
3
|
import { HttpConfig, HttpFlags } from "./types";
|
|
4
4
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
5
|
import { Constructor } from "@decaf-ts/decoration";
|
|
@@ -188,4 +188,5 @@ export declare abstract class HttpAdapter<CONF extends HttpConfig, CON, Q, C ext
|
|
|
188
188
|
* @throws {UnsupportedError} Always throws as this method is not supported by default
|
|
189
189
|
*/
|
|
190
190
|
parseCondition(condition: Condition<any>): Q;
|
|
191
|
+
static parseError<E extends BaseError>(err: Error | string, ...args: any[]): E;
|
|
191
192
|
}
|
package/lib/esm/adapter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Adapter, PersistenceKeys, UnsupportedError, } from "@decaf-ts/core";
|
|
2
|
-
import { InternalError, } from "@decaf-ts/db-decorators";
|
|
1
|
+
import { Adapter, AuthorizationError, ConnectionError, ForbiddenError, MigrationError, ObserverError, PagingError, PersistenceKeys, QueryError, UnsupportedError, } from "@decaf-ts/core";
|
|
2
|
+
import { BadRequestError, ConflictError, InternalError, NotFoundError, SerializationError, } from "@decaf-ts/db-decorators";
|
|
3
3
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
4
|
import { RestService } from "./RestService.js";
|
|
5
5
|
/**
|
|
@@ -197,5 +197,35 @@ export class HttpAdapter extends Adapter {
|
|
|
197
197
|
parseCondition(condition) {
|
|
198
198
|
throw new UnsupportedError("Api is not natively available for HttpAdapters. If required, please extends this class");
|
|
199
199
|
}
|
|
200
|
+
static parseError(err,
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
202
|
+
...args) {
|
|
203
|
+
const msg = typeof err === "string" ? err : err.message;
|
|
204
|
+
if (msg.includes(NotFoundError.name))
|
|
205
|
+
return new NotFoundError(err);
|
|
206
|
+
if (msg.includes(ConflictError.name))
|
|
207
|
+
return new ConflictError(err);
|
|
208
|
+
if (msg.includes(BadRequestError.name))
|
|
209
|
+
return new BadRequestError(err);
|
|
210
|
+
if (msg.includes(QueryError.name))
|
|
211
|
+
return new QueryError(err);
|
|
212
|
+
if (msg.includes(PagingError.name))
|
|
213
|
+
return new PagingError(err);
|
|
214
|
+
if (msg.includes(UnsupportedError.name))
|
|
215
|
+
return new UnsupportedError(err);
|
|
216
|
+
if (msg.includes(MigrationError.name))
|
|
217
|
+
return new MigrationError(err);
|
|
218
|
+
if (msg.includes(ObserverError.name))
|
|
219
|
+
return new ObserverError(err);
|
|
220
|
+
if (msg.includes(AuthorizationError.name))
|
|
221
|
+
return new AuthorizationError(err);
|
|
222
|
+
if (msg.includes(ForbiddenError.name))
|
|
223
|
+
return new ForbiddenError(err);
|
|
224
|
+
if (msg.includes(ConnectionError.name))
|
|
225
|
+
return new ConnectionError(err);
|
|
226
|
+
if (msg.includes(SerializationError.name))
|
|
227
|
+
return new SerializationError(err);
|
|
228
|
+
return new InternalError(err);
|
|
229
|
+
}
|
|
200
230
|
}
|
|
201
231
|
//# sourceMappingURL=adapter.js.map
|
package/lib/esm/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAElB,eAAe,EAEf,cAAc,EACd,cAAc,EACd,aAAa,EACb,WAAW,EACX,eAAe,EAEf,UAAU,EAIV,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAEf,aAAa,EAGb,aAAa,EACb,aAAa,EAGb,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,yBAAsB;AAG5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,OAAgB,WAKpB,SAAQ,OAAwB;IAChC,YAAsB,MAAY,EAAE,OAAe,EAAE,KAAc;QACjE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;IAED;;;;;;;;;;OAUG;IACM,KAAK,CACZ,SAIwB,EACxB,KAAqB,EACrB,SAA8B;QAE9B,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAI,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE;YAChE,OAAO,EAAE,EAAE;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACM,UAAU;QAGjB,OAAO,WAAwC,CAAC;IAClD,CAAC;IAED;;;;;;;;;OASG;IACM,OAAO,CACd,KAAQ,EACR,GAAG,IAAuB;QAE1B,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAA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AI,CAAC;YAAE,OAAO,IAAI,UAAU,CAAC,GAAG,CAAM,CAAC;QACnE,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,WAAW,CAAC,GAAG,CAAM,CAAC;QACrE,IAAI,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC;YACrC,OAAO,IAAI,gBAAgB,CAAC,GAAG,CAAM,CAAC;QACxC,IAAI,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,cAAc,CAAC,GAAG,CAAM,CAAC;QAC3E,IAAI,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,aAAa,CAAC,GAAG,CAAM,CAAC;QACzE,IAAI,GAAG,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC;YACvC,OAAO,IAAI,kBAAkB,CAAC,GAAG,CAAM,CAAC;QAC1C,IAAI,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,cAAc,CAAC,GAAG,CAAM,CAAC;QAC3E,IAAI,GAAG,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC;YACpC,OAAO,IAAI,eAAe,CAAC,GAAG,CAAM,CAAC;QACvC,IAAI,GAAG,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC;YACvC,OAAO,IAAI,kBAAkB,CAAC,GAAG,CAAM,CAAC;QAC1C,OAAO,IAAI,aAAa,CAAC,GAAG,CAAM,CAAC;IACrC,CAAC;CACF"}
|
package/lib/esm/axios/axios.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { HttpAdapter } from "./../adapter.js";
|
|
2
2
|
import { Axios } from "axios";
|
|
3
|
-
import { ConflictError, InternalError, NotFoundError, } from "@decaf-ts/db-decorators";
|
|
4
|
-
import { AuthorizationError, UnsupportedError, } from "@decaf-ts/core";
|
|
5
3
|
import { AxiosFlavour } from "./constants.js";
|
|
6
4
|
/**
|
|
7
5
|
* @description Axios implementation of the HTTP adapter
|
|
@@ -152,20 +150,8 @@ export class AxiosHttpAdapter extends HttpAdapter {
|
|
|
152
150
|
throw this.parseError(e);
|
|
153
151
|
}
|
|
154
152
|
}
|
|
155
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
156
153
|
parseError(err, ...args) {
|
|
157
|
-
|
|
158
|
-
InternalError,
|
|
159
|
-
AuthorizationError,
|
|
160
|
-
ConflictError,
|
|
161
|
-
NotFoundError,
|
|
162
|
-
UnsupportedError,
|
|
163
|
-
];
|
|
164
|
-
for (const error of errs) {
|
|
165
|
-
if (err.message.includes(error.name))
|
|
166
|
-
return new error(err.message);
|
|
167
|
-
}
|
|
168
|
-
return new InternalError(err.message);
|
|
154
|
+
return HttpAdapter.parseError(err, ...args);
|
|
169
155
|
}
|
|
170
156
|
}
|
|
171
157
|
//# sourceMappingURL=axios.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../../src/axios/axios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,wBAAmB;AACzC,OAAO,EAAE,KAAK,EAAsB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../../src/axios/axios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,wBAAmB;AACzC,OAAO,EAAE,KAAK,EAAsB,MAAM,OAAO,CAAC;AAKlD,OAAO,EAAE,YAAY,EAAE,uBAAoB;AAI3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,OAAO,gBAAiB,SAAQ,WAKrC;IACC,YAAY,MAAkB,EAAE,KAAc;QAC5C,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IACrC,CAA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KAA0C;QAE7C,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAChC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACM,KAAK,CAAC,MAAM,CACnB,SAAkC,EAClC,EAAkB;IAClB,6DAA6D;IAC7D,GAAG,KAA0C;QAE7C,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE;gBAC9B,EAAE,EAAE,EAAqB;aAC1B,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAEQ,UAAU,CAAsB,GAAU,EAAE,GAAG,IAAW;QACjE,OAAO,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
package/lib/esm/index.d.ts
CHANGED
package/lib/esm/index.js
CHANGED
package/lib/index.cjs
CHANGED
package/lib/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decaf-ts/for-http",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "http wrappers for decaf-ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -91,6 +91,6 @@
|
|
|
91
91
|
"@decaf-ts/logging": "latest",
|
|
92
92
|
"@decaf-ts/reflection": "latest",
|
|
93
93
|
"@decaf-ts/transactional-decorators": "latest",
|
|
94
|
-
"axios": "^1.
|
|
94
|
+
"axios": "^1.13.2"
|
|
95
95
|
}
|
|
96
96
|
}
|