@zthun/webigail-rest 2.2.0 → 2.4.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/index.cjs +6 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const helpfulQuery = require("@zthun/helpful-query");
|
|
3
4
|
const webigailHttp = require("@zthun/webigail-http");
|
|
4
5
|
const webigailUrl = require("@zthun/webigail-url");
|
|
5
6
|
class ZRestfulService {
|
|
@@ -37,13 +38,16 @@ class ZRestfulService {
|
|
|
37
38
|
return identification ? url.append(`${identification}`) : url;
|
|
38
39
|
}
|
|
39
40
|
async count(req) {
|
|
40
|
-
const
|
|
41
|
+
const filter = new helpfulQuery.ZFilterSerialize().serialize(req.filter);
|
|
42
|
+
const url = this.endpoint().page(1).size(1).search(req.search).filter(filter).build();
|
|
41
43
|
const r = new webigailHttp.ZHttpRequestBuilder().copy(this._request).get().url(url).build();
|
|
42
44
|
const { data: page } = await this._http.request(r);
|
|
43
45
|
return page.count;
|
|
44
46
|
}
|
|
45
47
|
async retrieve(req) {
|
|
46
|
-
const
|
|
48
|
+
const filter = new helpfulQuery.ZFilterSerialize().serialize(req.filter);
|
|
49
|
+
const sort = new helpfulQuery.ZSortSerialize().serialize(req.sort);
|
|
50
|
+
const url = this.endpoint().page(req.page).size(req.size).search(req.search).filter(filter).sort(sort).build();
|
|
47
51
|
const r = new webigailHttp.ZHttpRequestBuilder().copy(this._request).get().url(url).build();
|
|
48
52
|
const { data: page } = await this._http.request(r);
|
|
49
53
|
return page.data ?? page.result;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/service/restful-service.mts"],"sourcesContent":["import { IZDataRequest, IZDataSource } from '@zthun/helpful-query';\nimport { IZHttpService, ZHttpRequestBuilder } from '@zthun/webigail-http';\nimport { ZUrlBuilder } from '@zthun/webigail-url';\nimport { IZRestfulCreate } from './restful-create.mjs';\nimport { IZRestfulDelete } from './restful-delete.mjs';\nimport { IZRestfulGet } from './restful-get.mjs';\nimport { IZRestfulUpdate } from './restful-update.mjs';\nimport { IZRestfulUpsert } from './restful-upsert.mjs';\n\n/**\n * A service that conforms to all known restful standards.\n *\n * @param T -\n * The type of resource being retrieved or mutated.\n */\nexport interface IZRestfulService<T>\n extends IZRestfulCreate<T>,\n IZRestfulDelete,\n IZRestfulGet<T>,\n IZRestfulUpdate<T>,\n IZRestfulUpdate<T>,\n IZRestfulUpsert<T>,\n IZDataSource<T> {}\n\n/**\n * A generic implementation of a restful service that assumes all verbs are implemented.\n *\n * This can be used to invoke a service that is only partially implemented. If your service,\n * for example, is read only, then create, upsert, update, and delete should all return\n * not found or forbidden errors.\n *\n * @param T -\n * The type of resource being retrieved or mutated.\n */\nexport class ZRestfulService<T> implements IZRestfulService<T> {\n /**\n * Initializes a new instance of this object.\n *\n * @param _http -\n * The http service to use when invoking the RESTful service.\n * @param _endpointUrl -\n * The root url of the endpoint to hit. This can include params\n * to send them with every request, but standard params of page,\n * size, search, filter, and sort will be overridden depending on\n * which method is being invoked.\n * @param _request -\n * The base request to use when constructing requests in the http\n * service.\n */\n public constructor(\n private readonly _http: IZHttpService,\n private readonly _endpointUrl: string,\n private readonly _request = new ZHttpRequestBuilder<T>().build()\n ) {}\n\n /**\n * Gets the final endpoint for a resource.\n *\n * @param identification -\n * The identification of a single resource. If this is falsy, then\n * the entire data scope is used.\n *\n * @returns\n * A url builder that points to the target resource endpoint.\n */\n public endpoint(identification?: number | string) {\n const url = new ZUrlBuilder().parse(this._endpointUrl);\n return identification ? url.append(`${identification}`) : url;\n }\n\n public async count(req: IZDataRequest): Promise<number> {\n const url = this.endpoint().page(1).size(1).search(req.search).build();\n const r = new ZHttpRequestBuilder().copy(this._request).get().url(url).build();\n const { data: page } = await this._http.request<any>(r);\n return page.count;\n }\n\n public async retrieve(req: IZDataRequest): Promise<T[]> {\n const url = this.endpoint().page(req.page).size(req.size).search(req.search).build();\n const r = new ZHttpRequestBuilder().copy(this._request).get().url(url).build();\n const { data: page } = await this._http.request<any>(r);\n return page.data ?? page.result;\n }\n\n public async get(identification: number | string): Promise<T> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder().copy(this._request).get().url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async create(body: T): Promise<T> {\n const url = this.endpoint().build();\n const r = new ZHttpRequestBuilder<T>().copy(this._request).post(body).url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async upsert(body: T): Promise<T> {\n const url = this.endpoint().build();\n const r = new ZHttpRequestBuilder<T>().copy(this._request).put(body).url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async update(identification: number | string, fields: Partial<T>): Promise<T> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder<Partial<T>>().copy(this._request).patch(fields).url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async delete(identification: number | string): Promise<void> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder<undefined>().copy(this._request).delete().url(url).build();\n await this._http.request(r);\n }\n}\n"],"names":["ZHttpRequestBuilder","ZUrlBuilder"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/service/restful-service.mts"],"sourcesContent":["import { IZDataRequest, IZDataSource, ZFilterSerialize, ZSortSerialize } from '@zthun/helpful-query';\nimport { IZHttpService, ZHttpRequestBuilder } from '@zthun/webigail-http';\nimport { ZUrlBuilder } from '@zthun/webigail-url';\nimport { IZRestfulCreate } from './restful-create.mjs';\nimport { IZRestfulDelete } from './restful-delete.mjs';\nimport { IZRestfulGet } from './restful-get.mjs';\nimport { IZRestfulUpdate } from './restful-update.mjs';\nimport { IZRestfulUpsert } from './restful-upsert.mjs';\n\n/**\n * A service that conforms to all known restful standards.\n *\n * @param T -\n * The type of resource being retrieved or mutated.\n */\nexport interface IZRestfulService<T>\n extends IZRestfulCreate<T>,\n IZRestfulDelete,\n IZRestfulGet<T>,\n IZRestfulUpdate<T>,\n IZRestfulUpdate<T>,\n IZRestfulUpsert<T>,\n IZDataSource<T> {}\n\n/**\n * A generic implementation of a restful service that assumes all verbs are implemented.\n *\n * This can be used to invoke a service that is only partially implemented. If your service,\n * for example, is read only, then create, upsert, update, and delete should all return\n * not found or forbidden errors.\n *\n * @param T -\n * The type of resource being retrieved or mutated.\n */\nexport class ZRestfulService<T> implements IZRestfulService<T> {\n /**\n * Initializes a new instance of this object.\n *\n * @param _http -\n * The http service to use when invoking the RESTful service.\n * @param _endpointUrl -\n * The root url of the endpoint to hit. This can include params\n * to send them with every request, but standard params of page,\n * size, search, filter, and sort will be overridden depending on\n * which method is being invoked.\n * @param _request -\n * The base request to use when constructing requests in the http\n * service.\n */\n public constructor(\n private readonly _http: IZHttpService,\n private readonly _endpointUrl: string,\n private readonly _request = new ZHttpRequestBuilder<T>().build()\n ) {}\n\n /**\n * Gets the final endpoint for a resource.\n *\n * @param identification -\n * The identification of a single resource. If this is falsy, then\n * the entire data scope is used.\n *\n * @returns\n * A url builder that points to the target resource endpoint.\n */\n public endpoint(identification?: number | string) {\n const url = new ZUrlBuilder().parse(this._endpointUrl);\n return identification ? url.append(`${identification}`) : url;\n }\n\n public async count(req: IZDataRequest): Promise<number> {\n const filter = new ZFilterSerialize().serialize(req.filter);\n const url = this.endpoint().page(1).size(1).search(req.search).filter(filter).build();\n const r = new ZHttpRequestBuilder().copy(this._request).get().url(url).build();\n const { data: page } = await this._http.request<any>(r);\n return page.count;\n }\n\n public async retrieve(req: IZDataRequest): Promise<T[]> {\n const filter = new ZFilterSerialize().serialize(req.filter);\n const sort = new ZSortSerialize().serialize(req.sort);\n const url = this.endpoint().page(req.page).size(req.size).search(req.search).filter(filter).sort(sort).build();\n const r = new ZHttpRequestBuilder().copy(this._request).get().url(url).build();\n const { data: page } = await this._http.request<any>(r);\n return page.data ?? page.result;\n }\n\n public async get(identification: number | string): Promise<T> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder().copy(this._request).get().url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async create(body: T): Promise<T> {\n const url = this.endpoint().build();\n const r = new ZHttpRequestBuilder<T>().copy(this._request).post(body).url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async upsert(body: T): Promise<T> {\n const url = this.endpoint().build();\n const r = new ZHttpRequestBuilder<T>().copy(this._request).put(body).url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async update(identification: number | string, fields: Partial<T>): Promise<T> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder<Partial<T>>().copy(this._request).patch(fields).url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async delete(identification: number | string): Promise<void> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder<undefined>().copy(this._request).delete().url(url).build();\n await this._http.request(r);\n }\n}\n"],"names":["ZHttpRequestBuilder","ZUrlBuilder","ZFilterSerialize","ZSortSerialize"],"mappings":";;;;;AAkCO,MAAM,gBAAkD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAetD,YACY,OACA,cACA,WAAW,IAAIA,aAAuB,oBAAA,EAAE,SACzD;AAHiB,SAAA,QAAA;AACA,SAAA,eAAA;AACA,SAAA,WAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYI,SAAS,gBAAkC;AAChD,UAAM,MAAM,IAAIC,YAAA,YAAA,EAAc,MAAM,KAAK,YAAY;AACrD,WAAO,iBAAiB,IAAI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A,MAAa,OAAO,MAAqB;AACvC,UAAM,MAAM,KAAK,SAAS,EAAE,MAAM;AAClC,UAAM,IAAI,IAAIA,aAAAA,oBAAuB,EAAE,KAAK,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,IAAI,GAAG,EAAE,MAAM;AACrF,UAAM,EAAE,KAAK,IAAI,MAAM,KAAK,MAAM,QAAW,CAAC;AACvC,WAAA;AAAA,EACT;AAAA,EAEA,MAAa,OAAO,MAAqB;AACvC,UAAM,MAAM,KAAK,SAAS,EAAE,MAAM;AAClC,UAAM,IAAI,IAAIA,aAAAA,oBAAuB,EAAE,KAAK,KAAK,QAAQ,EAAE,IAAI,IAAI,EAAE,IAAI,GAAG,EAAE,MAAM;AACpF,UAAM,EAAE,KAAK,IAAI,MAAM,KAAK,MAAM,QAAW,CAAC;AACvC,WAAA;AAAA,EACT;AAAA,EAEA,MAAa,OAAO,gBAAiC,QAAgC;AACnF,UAAM,MAAM,KAAK,SAAS,cAAc,EAAE,MAAM;AAChD,UAAM,IAAI,IAAIA,aAAAA,oBAAgC,EAAE,KAAK,KAAK,QAAQ,EAAE,MAAM,MAAM,EAAE,IAAI,GAAG,EAAE,MAAM;AACjG,UAAM,EAAE,KAAK,IAAI,MAAM,KAAK,MAAM,QAAW,CAAC;AACvC,WAAA;AAAA,EACT;AAAA,EAEA,MAAa,OAAO,gBAAgD;AAClE,UAAM,MAAM,KAAK,SAAS,cAAc,EAAE,MAAM;AAChD,UAAM,IAAI,IAAIA,aAAAA,sBAAiC,KAAK,KAAK,QAAQ,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,MAAM;AACrF,UAAA,KAAK,MAAM,QAAQ,CAAC;AAAA,EAC5B;AACF;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ZFilterSerialize, ZSortSerialize } from "@zthun/helpful-query";
|
|
1
2
|
import { ZHttpRequestBuilder } from "@zthun/webigail-http";
|
|
2
3
|
import { ZUrlBuilder } from "@zthun/webigail-url";
|
|
3
4
|
class ZRestfulService {
|
|
@@ -35,13 +36,16 @@ class ZRestfulService {
|
|
|
35
36
|
return identification ? url.append(`${identification}`) : url;
|
|
36
37
|
}
|
|
37
38
|
async count(req) {
|
|
38
|
-
const
|
|
39
|
+
const filter = new ZFilterSerialize().serialize(req.filter);
|
|
40
|
+
const url = this.endpoint().page(1).size(1).search(req.search).filter(filter).build();
|
|
39
41
|
const r = new ZHttpRequestBuilder().copy(this._request).get().url(url).build();
|
|
40
42
|
const { data: page } = await this._http.request(r);
|
|
41
43
|
return page.count;
|
|
42
44
|
}
|
|
43
45
|
async retrieve(req) {
|
|
44
|
-
const
|
|
46
|
+
const filter = new ZFilterSerialize().serialize(req.filter);
|
|
47
|
+
const sort = new ZSortSerialize().serialize(req.sort);
|
|
48
|
+
const url = this.endpoint().page(req.page).size(req.size).search(req.search).filter(filter).sort(sort).build();
|
|
45
49
|
const r = new ZHttpRequestBuilder().copy(this._request).get().url(url).build();
|
|
46
50
|
const { data: page } = await this._http.request(r);
|
|
47
51
|
return page.data ?? page.result;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/service/restful-service.mts"],"sourcesContent":["import { IZDataRequest, IZDataSource } from '@zthun/helpful-query';\nimport { IZHttpService, ZHttpRequestBuilder } from '@zthun/webigail-http';\nimport { ZUrlBuilder } from '@zthun/webigail-url';\nimport { IZRestfulCreate } from './restful-create.mjs';\nimport { IZRestfulDelete } from './restful-delete.mjs';\nimport { IZRestfulGet } from './restful-get.mjs';\nimport { IZRestfulUpdate } from './restful-update.mjs';\nimport { IZRestfulUpsert } from './restful-upsert.mjs';\n\n/**\n * A service that conforms to all known restful standards.\n *\n * @param T -\n * The type of resource being retrieved or mutated.\n */\nexport interface IZRestfulService<T>\n extends IZRestfulCreate<T>,\n IZRestfulDelete,\n IZRestfulGet<T>,\n IZRestfulUpdate<T>,\n IZRestfulUpdate<T>,\n IZRestfulUpsert<T>,\n IZDataSource<T> {}\n\n/**\n * A generic implementation of a restful service that assumes all verbs are implemented.\n *\n * This can be used to invoke a service that is only partially implemented. If your service,\n * for example, is read only, then create, upsert, update, and delete should all return\n * not found or forbidden errors.\n *\n * @param T -\n * The type of resource being retrieved or mutated.\n */\nexport class ZRestfulService<T> implements IZRestfulService<T> {\n /**\n * Initializes a new instance of this object.\n *\n * @param _http -\n * The http service to use when invoking the RESTful service.\n * @param _endpointUrl -\n * The root url of the endpoint to hit. This can include params\n * to send them with every request, but standard params of page,\n * size, search, filter, and sort will be overridden depending on\n * which method is being invoked.\n * @param _request -\n * The base request to use when constructing requests in the http\n * service.\n */\n public constructor(\n private readonly _http: IZHttpService,\n private readonly _endpointUrl: string,\n private readonly _request = new ZHttpRequestBuilder<T>().build()\n ) {}\n\n /**\n * Gets the final endpoint for a resource.\n *\n * @param identification -\n * The identification of a single resource. If this is falsy, then\n * the entire data scope is used.\n *\n * @returns\n * A url builder that points to the target resource endpoint.\n */\n public endpoint(identification?: number | string) {\n const url = new ZUrlBuilder().parse(this._endpointUrl);\n return identification ? url.append(`${identification}`) : url;\n }\n\n public async count(req: IZDataRequest): Promise<number> {\n const url = this.endpoint().page(1).size(1).search(req.search).build();\n const r = new ZHttpRequestBuilder().copy(this._request).get().url(url).build();\n const { data: page } = await this._http.request<any>(r);\n return page.count;\n }\n\n public async retrieve(req: IZDataRequest): Promise<T[]> {\n const url = this.endpoint().page(req.page).size(req.size).search(req.search).build();\n const r = new ZHttpRequestBuilder().copy(this._request).get().url(url).build();\n const { data: page } = await this._http.request<any>(r);\n return page.data ?? page.result;\n }\n\n public async get(identification: number | string): Promise<T> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder().copy(this._request).get().url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async create(body: T): Promise<T> {\n const url = this.endpoint().build();\n const r = new ZHttpRequestBuilder<T>().copy(this._request).post(body).url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async upsert(body: T): Promise<T> {\n const url = this.endpoint().build();\n const r = new ZHttpRequestBuilder<T>().copy(this._request).put(body).url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async update(identification: number | string, fields: Partial<T>): Promise<T> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder<Partial<T>>().copy(this._request).patch(fields).url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async delete(identification: number | string): Promise<void> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder<undefined>().copy(this._request).delete().url(url).build();\n await this._http.request(r);\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/service/restful-service.mts"],"sourcesContent":["import { IZDataRequest, IZDataSource, ZFilterSerialize, ZSortSerialize } from '@zthun/helpful-query';\nimport { IZHttpService, ZHttpRequestBuilder } from '@zthun/webigail-http';\nimport { ZUrlBuilder } from '@zthun/webigail-url';\nimport { IZRestfulCreate } from './restful-create.mjs';\nimport { IZRestfulDelete } from './restful-delete.mjs';\nimport { IZRestfulGet } from './restful-get.mjs';\nimport { IZRestfulUpdate } from './restful-update.mjs';\nimport { IZRestfulUpsert } from './restful-upsert.mjs';\n\n/**\n * A service that conforms to all known restful standards.\n *\n * @param T -\n * The type of resource being retrieved or mutated.\n */\nexport interface IZRestfulService<T>\n extends IZRestfulCreate<T>,\n IZRestfulDelete,\n IZRestfulGet<T>,\n IZRestfulUpdate<T>,\n IZRestfulUpdate<T>,\n IZRestfulUpsert<T>,\n IZDataSource<T> {}\n\n/**\n * A generic implementation of a restful service that assumes all verbs are implemented.\n *\n * This can be used to invoke a service that is only partially implemented. If your service,\n * for example, is read only, then create, upsert, update, and delete should all return\n * not found or forbidden errors.\n *\n * @param T -\n * The type of resource being retrieved or mutated.\n */\nexport class ZRestfulService<T> implements IZRestfulService<T> {\n /**\n * Initializes a new instance of this object.\n *\n * @param _http -\n * The http service to use when invoking the RESTful service.\n * @param _endpointUrl -\n * The root url of the endpoint to hit. This can include params\n * to send them with every request, but standard params of page,\n * size, search, filter, and sort will be overridden depending on\n * which method is being invoked.\n * @param _request -\n * The base request to use when constructing requests in the http\n * service.\n */\n public constructor(\n private readonly _http: IZHttpService,\n private readonly _endpointUrl: string,\n private readonly _request = new ZHttpRequestBuilder<T>().build()\n ) {}\n\n /**\n * Gets the final endpoint for a resource.\n *\n * @param identification -\n * The identification of a single resource. If this is falsy, then\n * the entire data scope is used.\n *\n * @returns\n * A url builder that points to the target resource endpoint.\n */\n public endpoint(identification?: number | string) {\n const url = new ZUrlBuilder().parse(this._endpointUrl);\n return identification ? url.append(`${identification}`) : url;\n }\n\n public async count(req: IZDataRequest): Promise<number> {\n const filter = new ZFilterSerialize().serialize(req.filter);\n const url = this.endpoint().page(1).size(1).search(req.search).filter(filter).build();\n const r = new ZHttpRequestBuilder().copy(this._request).get().url(url).build();\n const { data: page } = await this._http.request<any>(r);\n return page.count;\n }\n\n public async retrieve(req: IZDataRequest): Promise<T[]> {\n const filter = new ZFilterSerialize().serialize(req.filter);\n const sort = new ZSortSerialize().serialize(req.sort);\n const url = this.endpoint().page(req.page).size(req.size).search(req.search).filter(filter).sort(sort).build();\n const r = new ZHttpRequestBuilder().copy(this._request).get().url(url).build();\n const { data: page } = await this._http.request<any>(r);\n return page.data ?? page.result;\n }\n\n public async get(identification: number | string): Promise<T> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder().copy(this._request).get().url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async create(body: T): Promise<T> {\n const url = this.endpoint().build();\n const r = new ZHttpRequestBuilder<T>().copy(this._request).post(body).url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async upsert(body: T): Promise<T> {\n const url = this.endpoint().build();\n const r = new ZHttpRequestBuilder<T>().copy(this._request).put(body).url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async update(identification: number | string, fields: Partial<T>): Promise<T> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder<Partial<T>>().copy(this._request).patch(fields).url(url).build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async delete(identification: number | string): Promise<void> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder<undefined>().copy(this._request).delete().url(url).build();\n await this._http.request(r);\n }\n}\n"],"names":[],"mappings":";;;AAkCO,MAAM,gBAAkD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAetD,YACY,OACA,cACA,WAAW,IAAI,oBAAuB,EAAE,SACzD;AAHiB,SAAA,QAAA;AACA,SAAA,eAAA;AACA,SAAA,WAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYI,SAAS,gBAAkC;AAChD,UAAM,MAAM,IAAI,YAAA,EAAc,MAAM,KAAK,YAAY;AACrD,WAAO,iBAAiB,IAAI,OAAO,GAAG,cAAc,EAAE,IAAI;AAAA,EAC5D;AAAA,EAEA,MAAa,MAAM,KAAqC;AACtD,UAAM,SAAS,IAAI,iBAAA,EAAmB,UAAU,IAAI,MAAM;AAC1D,UAAM,MAAM,KAAK,SAAA,EAAW,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,IAAI,MAAM,EAAE,OAAO,MAAM,EAAE;AAC9E,UAAM,IAAI,IAAI,sBAAsB,KAAK,KAAK,QAAQ,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,MAAM;AACvE,UAAA,EAAE,MAAM,SAAS,MAAM,KAAK,MAAM,QAAa,CAAC;AACtD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,SAAS,KAAkC;AACtD,UAAM,SAAS,IAAI,iBAAA,EAAmB,UAAU,IAAI,MAAM;AAC1D,UAAM,OAAO,IAAI,eAAA,EAAiB,UAAU,IAAI,IA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,IAAI,oBAAgC,EAAE,KAAK,KAAK,QAAQ,EAAE,MAAM,MAAM,EAAE,IAAI,GAAG,EAAE,MAAM;AACjG,UAAM,EAAE,KAAK,IAAI,MAAM,KAAK,MAAM,QAAW,CAAC;AACvC,WAAA;AAAA,EACT;AAAA,EAEA,MAAa,OAAO,gBAAgD;AAClE,UAAM,MAAM,KAAK,SAAS,cAAc,EAAE,MAAM;AAChD,UAAM,IAAI,IAAI,sBAAiC,KAAK,KAAK,QAAQ,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,MAAM;AACrF,UAAA,KAAK,MAAM,QAAQ,CAAC;AAAA,EAC5B;AACF;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zthun/webigail-rest",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Helpful services for querying rest services based on specific standards.",
|
|
5
5
|
"author": "Anthony Bonta",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"vite": "^5.
|
|
28
|
+
"vite": "^5.1.1",
|
|
29
29
|
"vitest": "^1.2.2"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@zthun/helpful-fn": "^3.
|
|
36
|
-
"@zthun/helpful-query": "^3.
|
|
37
|
-
"@zthun/webigail-http": "^2.
|
|
38
|
-
"@zthun/webigail-url": "^2.
|
|
35
|
+
"@zthun/helpful-fn": "^3.3.0",
|
|
36
|
+
"@zthun/helpful-query": "^3.3.1",
|
|
37
|
+
"@zthun/webigail-http": "^2.4.0",
|
|
38
|
+
"@zthun/webigail-url": "^2.4.0"
|
|
39
39
|
},
|
|
40
40
|
"sideEffects": false,
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "024fcb71bea75232c1ed8f2ae5cd78a5c8ff20fd"
|
|
42
42
|
}
|