@zthun/webigail-rest 5.0.1 → 5.0.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/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/service/restful-create.d.mts +17 -0
- package/dist/service/restful-delete.d.mts +11 -0
- package/dist/service/restful-get.d.mts +17 -0
- package/dist/service/restful-service.d.mts +40 -0
- package/dist/service/restful-update.d.mts +19 -0
- package/dist/service/restful-upsert.d.mts +21 -0
- package/dist/url/restful-url.d.mts +31 -0
- package/package.json +11 -9
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/url/restful-url.mts","../src/service/restful-service.mts"],"sourcesContent":["import type { IZDataRequest } from \"@zthun/helpful-query\";\nimport { ZFilterSerialize, ZSortSerialize } from \"@zthun/helpful-query\";\nimport { ZUrlBuilder } from \"@zthun/webigail-url\";\n\n/**\n * Represents a decorator that can build a url for a restful endpoint\n * given an existing base url.\n */\nexport class ZRestfulUrlBuilder {\n private _url: ZUrlBuilder;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor(baseUrl: string) {\n this._url = new ZUrlBuilder().parse(baseUrl);\n }\n\n /**\n * Adds the request parameters to the url.\n *\n * This will add the page, size, search, filter, and sort parameters to the url if they are defined.\n *\n * @param request -\n * The request to add to the url.\n * @returns\n * This object.\n */\n public from(request: IZDataRequest): this {\n this._url = this._url\n .page(request.page)\n .size(request.size)\n .search(request.search)\n .filter(new ZFilterSerialize().serialize(request.filter))\n .sort(new ZSortSerialize().serialize(request.sort));\n return this;\n }\n\n /**\n * Updates the url to optimize to retrieve a count.\n *\n * This will add the size and page parameters to the url and remove the sort parameter.\n *\n * @returns\n * This object.\n */\n public count(): this {\n this._url = this._url.size(1).page(1).sort(null);\n return this;\n }\n\n /**\n * Returns the built url.\n *\n * @returns\n * The built url.\n */\n public build(): string {\n return this._url.build();\n }\n}\n","import type { IZDataRequest, IZDataSource } from \"@zthun/helpful-query\";\nimport type { IZHttpService } from \"@zthun/webigail-http\";\nimport { ZHttpRequestBuilder } from \"@zthun/webigail-http\";\nimport { ZUrlBuilder } from \"@zthun/webigail-url\";\nimport { ZRestfulUrlBuilder } from \"../url/restful-url.mjs\";\nimport type { IZRestfulCreate } from \"./restful-create.mjs\";\nimport type { IZRestfulDelete } from \"./restful-delete.mjs\";\nimport type { IZRestfulGet } from \"./restful-get.mjs\";\nimport type { IZRestfulUpdate } from \"./restful-update.mjs\";\nimport type { 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 r = new ZHttpRequestBuilder()\n .copy(this._request)\n .get()\n .url(\n new ZRestfulUrlBuilder(this.endpoint().build())\n .from(req)\n .count()\n .build(),\n )\n .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 r = new ZHttpRequestBuilder()\n .copy(this._request)\n .get()\n .url(new ZRestfulUrlBuilder(this.endpoint().build()).from(req).build())\n .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()\n .copy(this._request)\n .get()\n .url(url)\n .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>()\n .copy(this._request)\n .post(body)\n .url(url)\n .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>()\n .copy(this._request)\n .put(body)\n .url(url)\n .build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async update(\n identification: number | string,\n fields: Partial<T>,\n ): Promise<T> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder<Partial<T>>()\n .copy(this._request)\n .patch(fields)\n .url(url)\n .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>()\n .copy(this._request)\n .delete()\n .url(url)\n .build();\n await this._http.request(r);\n }\n}\n"],"names":["ZRestfulUrlBuilder","from","request","_url","page","size","search","filter","ZFilterSerialize","serialize","sort","ZSortSerialize","count","build","baseUrl","_define_property","ZUrlBuilder","parse","ZRestfulService","endpoint","identification","url","_endpointUrl","append","req","r","ZHttpRequestBuilder","copy","_request","get","data","_http","retrieve","result","create","body","post","upsert","put","update","fields","patch","delete"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAIA;;;AAGC,IACM,MAAMA,kBAAAA,CAAAA;AAUX;;;;;;;;;MAUOC,IAAAA,CAAKC,OAAsB,EAAQ;AACxC,QAAA,IAAI,CAACC,IAAI,GAAG,IAAI,CAACA,IAAI,CAClBC,IAAI,CAACF,OAAAA,CAAQE,IAAI,CAAA,CACjBC,IAAI,CAACH,OAAAA,CAAQG,IAAI,EACjBC,MAAM,CAACJ,OAAAA,CAAQI,MAAM,EACrBC,MAAM,CAAC,IAAIC,6BAAAA,EAAAA,CAAmBC,SAAS,CAACP,OAAAA,CAAQK,MAAM,CAAA,CAAA,CACtDG,IAAI,CAAC,IAAIC,8BAAiBF,SAAS,CAACP,QAAQQ,IAAI,CAAA,CAAA;AACnD,QAAA,OAAO,IAAI;AACb,IAAA;AAEA;;;;;;;AAOC,MACD,KAAOE,GAAc;AACnB,QAAA,IAAI,CAACT,IAAI,GAAG,IAAI,CAACA,IAAI,CAACE,IAAI,CAAC,CAAA,CAAA,CAAGD,IAAI,CAAC,CAAA,CAAA,CAAGM,IAAI,CAAC,IAAA,CAAA;AAC3C,QAAA,OAAO,IAAI;AACb,IAAA;AAEA;;;;;AAKC,MACD,KAAOG,GAAgB;AACrB,QAAA,OAAO,IAAI,CAACV,IAAI,CAACU,KAAK,EAAA;AACxB,IAAA;AAhDA;;MAGA,WAAA,CAAmBC,OAAe,CAAE;AALpC,QAAAC,kBAAA,CAAA,IAAA,EAAQZ,QAAR,MAAA,CAAA;AAME,QAAA,IAAI,CAACA,IAAI,GAAG,IAAIa,uBAAAA,EAAAA,CAAcC,KAAK,CAACH,OAAAA,CAAAA;AACtC,IAAA;AA4CF;;;;;;;;;;;;;;;AClCA;;;;;;;;;AASC,IACM,MAAMI,eAAAA,CAAAA;AAqBX;;;;;;;;;MAUOC,QAAAA,CAASC,cAAgC,EAAE;AA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A;AAEA,IAAA,MAAaS,MAAAA,CACXnB,cAA+B,EAC/BoB,MAAkB,EACN;AACZ,QAAA,MAAMnB,MAAM,IAAI,CAACF,QAAQ,CAACC,gBAAgBP,KAAK,EAAA;AAC/C,QAAA,MAAMY,CAAAA,GAAI,IAAIC,gCAAAA,EAAAA,CACXC,IAAI,CAAC,IAAI,CAACC,QAAQ,CAAA,CAClBa,KAAK,CAACD,MAAAA,CAAAA,CACNnB,GAAG,CAACA,KACJR,KAAK,EAAA;QACR,MAAM,EAAEiB,IAAI,EAAE,GAAG,MAAM,IAAI,CAACC,KAAK,CAAC7B,OAAO,CAAIuB,CAAAA,CAAAA;QAC7C,OAAOK,IAAAA;AACT,IAAA;IAEA,MAAaY,MAAAA,CAAOtB,cAA+B,EAAiB;AAClE,QAAA,MAAMC,MAAM,IAAI,CAACF,QAAQ,CAACC,gBAAgBP,KAAK,EAAA;AAC/C,QAAA,MAAMY,CAAAA,GAAI,IAAIC,gCAAAA,EAAAA,CACXC,IAAI,CAAC,IAAI,CAACC,QAAQ,CAAA,CAClBc,MAAM,EAAA,CACNrB,GAAG,CAACA,KACJR,KAAK,EAAA;AACR,QAAA,MAAM,IAAI,CAACkB,KAAK,CAAC7B,OAAO,CAACuB,CAAAA,CAAAA;AAC3B,IAAA;AAnHA;;;;;;;;;;;;;AAaC,MACD,WAAA,CACmBM,KAAoB,EACrC,YAAqC,EACpBH,QAAAA,GAAW,IAAIF,gCAAAA,EAAAA,CAAyBb,KAAK,EAAE,CAChE;;;;aAHiBkB,KAAAA,GAAAA,KAAAA;aACAT,YAAAA,GAAAA,YAAAA;aACAM,QAAAA,GAAAA,QAAAA;AAChB,IAAA;AAkGL;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/url/restful-url.mts","../src/service/restful-service.mts"],"sourcesContent":["import type { IZDataRequest } from \"@zthun/helpful-query\";\nimport { ZFilterSerialize, ZSortSerialize } from \"@zthun/helpful-query\";\nimport { ZUrlBuilder } from \"@zthun/webigail-url\";\n\n/**\n * Represents a decorator that can build a url for a restful endpoint\n * given an existing base url.\n */\nexport class ZRestfulUrlBuilder {\n private _url: ZUrlBuilder;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor(baseUrl: string) {\n this._url = new ZUrlBuilder().parse(baseUrl);\n }\n\n /**\n * Adds the request parameters to the url.\n *\n * This will add the page, size, search, filter, and sort parameters to the url if they are defined.\n *\n * @param request -\n * The request to add to the url.\n * @returns\n * This object.\n */\n public from(request: IZDataRequest): this {\n this._url = this._url\n .page(request.page)\n .size(request.size)\n .search(request.search)\n .filter(new ZFilterSerialize().serialize(request.filter))\n .sort(new ZSortSerialize().serialize(request.sort));\n return this;\n }\n\n /**\n * Updates the url to optimize to retrieve a count.\n *\n * This will add the size and page parameters to the url and remove the sort parameter.\n *\n * @returns\n * This object.\n */\n public count(): this {\n this._url = this._url.size(1).page(1).sort(null);\n return this;\n }\n\n /**\n * Returns the built url.\n *\n * @returns\n * The built url.\n */\n public build(): string {\n return this._url.build();\n }\n}\n","import type { IZDataRequest, IZDataSource } from \"@zthun/helpful-query\";\nimport type { IZHttpService } from \"@zthun/webigail-http\";\nimport { ZHttpRequestBuilder } from \"@zthun/webigail-http\";\nimport { ZUrlBuilder } from \"@zthun/webigail-url\";\nimport { ZRestfulUrlBuilder } from \"../url/restful-url.mjs\";\nimport type { IZRestfulCreate } from \"./restful-create.mjs\";\nimport type { IZRestfulDelete } from \"./restful-delete.mjs\";\nimport type { IZRestfulGet } from \"./restful-get.mjs\";\nimport type { IZRestfulUpdate } from \"./restful-update.mjs\";\nimport type { 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\n 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 r = new ZHttpRequestBuilder()\n .copy(this._request)\n .get()\n .url(\n new ZRestfulUrlBuilder(this.endpoint().build())\n .from(req)\n .count()\n .build(),\n )\n .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 r = new ZHttpRequestBuilder()\n .copy(this._request)\n .get()\n .url(new ZRestfulUrlBuilder(this.endpoint().build()).from(req).build())\n .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()\n .copy(this._request)\n .get()\n .url(url)\n .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>()\n .copy(this._request)\n .post(body)\n .url(url)\n .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>()\n .copy(this._request)\n .put(body)\n .url(url)\n .build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async update(\n identification: number | string,\n fields: Partial<T>,\n ): Promise<T> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder<Partial<T>>()\n .copy(this._request)\n .patch(fields)\n .url(url)\n .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>()\n .copy(this._request)\n .delete()\n .url(url)\n .build();\n await this._http.request(r);\n }\n}\n"],"names":["ZRestfulUrlBuilder","from","request","_url","page","size","search","filter","ZFilterSerialize","serialize","sort","ZSortSerialize","count","build","baseUrl","_define_property","ZUrlBuilder","parse","ZRestfulService","endpoint","identification","url","_endpointUrl","append","req","r","ZHttpRequestBuilder","copy","_request","get","data","_http","retrieve","result","create","body","post","upsert","put","update","fields","patch","delete"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAIA;;;AAGC,IACM,MAAMA,kBAAAA,CAAAA;AAUX;;;;;;;;;MAUOC,IAAAA,CAAKC,OAAsB,EAAQ;AACxC,QAAA,IAAI,CAACC,IAAI,GAAG,IAAI,CAACA,IAAI,CAClBC,IAAI,CAACF,OAAAA,CAAQE,IAAI,CAAA,CACjBC,IAAI,CAACH,OAAAA,CAAQG,IAAI,EACjBC,MAAM,CAACJ,OAAAA,CAAQI,MAAM,EACrBC,MAAM,CAAC,IAAIC,6BAAAA,EAAAA,CAAmBC,SAAS,CAACP,OAAAA,CAAQK,MAAM,CAAA,CAAA,CACtDG,IAAI,CAAC,IAAIC,8BAAiBF,SAAS,CAACP,QAAQQ,IAAI,CAAA,CAAA;AACnD,QAAA,OAAO,IAAI;AACb,IAAA;AAEA;;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,IAAIC,gCAAAA,EAAAA,CACXC,IAAI,CAAC,IAAI,CAACC,QAAQ,CAAA,CAClBc,MAAM,EAAA,CACNrB,GAAG,CAACA,KACJR,KAAK,EAAA;AACR,QAAA,MAAM,IAAI,CAACkB,KAAK,CAAC7B,OAAO,CAACuB,CAAAA,CAAAA;AAC3B,IAAA;AAnHA;;;;;;;;;;;;;AAaC,MACD,WAAA,CACmBM,KAAoB,EACrC,YAAqC,EACpBH,QAAAA,GAAW,IAAIF,gCAAAA,EAAAA,CAAyBb,KAAK,EAAE,CAChE;;;;aAHiBkB,KAAAA,GAAAA,KAAAA;aACAT,YAAAA,GAAAA,YAAAA;aACAM,QAAAA,GAAAA,QAAAA;AAChB,IAAA;AAkGL;;;;;"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/url/restful-url.mts","../src/service/restful-service.mts"],"sourcesContent":["import type { IZDataRequest } from \"@zthun/helpful-query\";\nimport { ZFilterSerialize, ZSortSerialize } from \"@zthun/helpful-query\";\nimport { ZUrlBuilder } from \"@zthun/webigail-url\";\n\n/**\n * Represents a decorator that can build a url for a restful endpoint\n * given an existing base url.\n */\nexport class ZRestfulUrlBuilder {\n private _url: ZUrlBuilder;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor(baseUrl: string) {\n this._url = new ZUrlBuilder().parse(baseUrl);\n }\n\n /**\n * Adds the request parameters to the url.\n *\n * This will add the page, size, search, filter, and sort parameters to the url if they are defined.\n *\n * @param request -\n * The request to add to the url.\n * @returns\n * This object.\n */\n public from(request: IZDataRequest): this {\n this._url = this._url\n .page(request.page)\n .size(request.size)\n .search(request.search)\n .filter(new ZFilterSerialize().serialize(request.filter))\n .sort(new ZSortSerialize().serialize(request.sort));\n return this;\n }\n\n /**\n * Updates the url to optimize to retrieve a count.\n *\n * This will add the size and page parameters to the url and remove the sort parameter.\n *\n * @returns\n * This object.\n */\n public count(): this {\n this._url = this._url.size(1).page(1).sort(null);\n return this;\n }\n\n /**\n * Returns the built url.\n *\n * @returns\n * The built url.\n */\n public build(): string {\n return this._url.build();\n }\n}\n","import type { IZDataRequest, IZDataSource } from \"@zthun/helpful-query\";\nimport type { IZHttpService } from \"@zthun/webigail-http\";\nimport { ZHttpRequestBuilder } from \"@zthun/webigail-http\";\nimport { ZUrlBuilder } from \"@zthun/webigail-url\";\nimport { ZRestfulUrlBuilder } from \"../url/restful-url.mjs\";\nimport type { IZRestfulCreate } from \"./restful-create.mjs\";\nimport type { IZRestfulDelete } from \"./restful-delete.mjs\";\nimport type { IZRestfulGet } from \"./restful-get.mjs\";\nimport type { IZRestfulUpdate } from \"./restful-update.mjs\";\nimport type { 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 r = new ZHttpRequestBuilder()\n .copy(this._request)\n .get()\n .url(\n new ZRestfulUrlBuilder(this.endpoint().build())\n .from(req)\n .count()\n .build(),\n )\n .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 r = new ZHttpRequestBuilder()\n .copy(this._request)\n .get()\n .url(new ZRestfulUrlBuilder(this.endpoint().build()).from(req).build())\n .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()\n .copy(this._request)\n .get()\n .url(url)\n .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>()\n .copy(this._request)\n .post(body)\n .url(url)\n .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>()\n .copy(this._request)\n .put(body)\n .url(url)\n .build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async update(\n identification: number | string,\n fields: Partial<T>,\n ): Promise<T> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder<Partial<T>>()\n .copy(this._request)\n .patch(fields)\n .url(url)\n .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>()\n .copy(this._request)\n .delete()\n .url(url)\n .build();\n await this._http.request(r);\n }\n}\n"],"names":["ZRestfulUrlBuilder","from","request","_url","page","size","search","filter","ZFilterSerialize","serialize","sort","ZSortSerialize","count","build","baseUrl","_define_property","ZUrlBuilder","parse","ZRestfulService","endpoint","identification","url","_endpointUrl","append","req","r","ZHttpRequestBuilder","copy","_request","get","data","_http","retrieve","result","create","body","post","upsert","put","update","fields","patch","delete"],"mappings":";;;;;;;;;;;;;;;;;AAIA;;;AAGC,IACM,MAAMA,kBAAAA,CAAAA;AAUX;;;;;;;;;MAUOC,IAAAA,CAAKC,OAAsB,EAAQ;AACxC,QAAA,IAAI,CAACC,IAAI,GAAG,IAAI,CAACA,IAAI,CAClBC,IAAI,CAACF,OAAAA,CAAQE,IAAI,CAAA,CACjBC,IAAI,CAACH,OAAAA,CAAQG,IAAI,EACjBC,MAAM,CAACJ,OAAAA,CAAQI,MAAM,EACrBC,MAAM,CAAC,IAAIC,gBAAAA,EAAAA,CAAmBC,SAAS,CAACP,OAAAA,CAAQK,MAAM,CAAA,CAAA,CACtDG,IAAI,CAAC,IAAIC,iBAAiBF,SAAS,CAACP,QAAQQ,IAAI,CAAA,CAAA;AACnD,QAAA,OAAO,IAAI;AACb,IAAA;AAEA;;;;;;;AAOC,MACD,KAAOE,GAAc;AACnB,QAAA,IAAI,CAACT,IAAI,GAAG,IAAI,CAACA,IAAI,CAACE,IAAI,CAAC,CAAA,CAAA,CAAGD,IAAI,CAAC,CAAA,CAAA,CAAGM,IAAI,CAAC,IAAA,CAAA;AAC3C,QAAA,OAAO,IAAI;AACb,IAAA;AAEA;;;;;AAKC,MACD,KAAOG,GAAgB;AACrB,QAAA,OAAO,IAAI,CAACV,IAAI,CAACU,KAAK,EAAA;AACxB,IAAA;AAhDA;;MAGA,WAAA,CAAmBC,OAAe,CAAE;AALpC,QAAAC,kBAAA,CAAA,IAAA,EAAQZ,QAAR,MAAA,CAAA;AAME,QAAA,IAAI,CAACA,IAAI,GAAG,IAAIa,WAAAA,EAAAA,CAAcC,KAAK,CAACH,OAAAA,CAAAA;AACtC,IAAA;AA4CF;;;;;;;;;;;;;;;AClCA;;;;;;;;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AAI,CAACC,KAAK,CAAC7B,OAAO,CAAIuB,CAAAA,CAAAA;QAC7C,OAAOK,IAAAA;AACT,IAAA;AAEA,IAAA,MAAaS,MAAAA,CACXnB,cAA+B,EAC/BoB,MAAkB,EACN;AACZ,QAAA,MAAMnB,MAAM,IAAI,CAACF,QAAQ,CAACC,gBAAgBP,KAAK,EAAA;AAC/C,QAAA,MAAMY,CAAAA,GAAI,IAAIC,mBAAAA,EAAAA,CACXC,IAAI,CAAC,IAAI,CAACC,QAAQ,CAAA,CAClBa,KAAK,CAACD,MAAAA,CAAAA,CACNnB,GAAG,CAACA,KACJR,KAAK,EAAA;QACR,MAAM,EAAEiB,IAAI,EAAE,GAAG,MAAM,IAAI,CAACC,KAAK,CAAC7B,OAAO,CAAIuB,CAAAA,CAAAA;QAC7C,OAAOK,IAAAA;AACT,IAAA;IAEA,MAAaY,MAAAA,CAAOtB,cAA+B,EAAiB;AAClE,QAAA,MAAMC,MAAM,IAAI,CAACF,QAAQ,CAACC,gBAAgBP,KAAK,EAAA;AAC/C,QAAA,MAAMY,CAAAA,GAAI,IAAIC,mBAAAA,EAAAA,CACXC,IAAI,CAAC,IAAI,CAACC,QAAQ,CAAA,CAClBc,MAAM,EAAA,CACNrB,GAAG,CAACA,KACJR,KAAK,EAAA;AACR,QAAA,MAAM,IAAI,CAACkB,KAAK,CAAC7B,OAAO,CAACuB,CAAAA,CAAAA;AAC3B,IAAA;AAnHA;;;;;;;;;;;;;AAaC,MACD,WAAA,CACmBM,KAAoB,EACrC,YAAqC,EACpBH,QAAAA,GAAW,IAAIF,mBAAAA,EAAAA,CAAyBb,KAAK,EAAE,CAChE;;;;aAHiBkB,KAAAA,GAAAA,KAAAA;aACAT,YAAAA,GAAAA,YAAAA;aACAM,QAAAA,GAAAA,QAAAA;AAChB,IAAA;AAkGL;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/url/restful-url.mts","../src/service/restful-service.mts"],"sourcesContent":["import type { IZDataRequest } from \"@zthun/helpful-query\";\nimport { ZFilterSerialize, ZSortSerialize } from \"@zthun/helpful-query\";\nimport { ZUrlBuilder } from \"@zthun/webigail-url\";\n\n/**\n * Represents a decorator that can build a url for a restful endpoint\n * given an existing base url.\n */\nexport class ZRestfulUrlBuilder {\n private _url: ZUrlBuilder;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor(baseUrl: string) {\n this._url = new ZUrlBuilder().parse(baseUrl);\n }\n\n /**\n * Adds the request parameters to the url.\n *\n * This will add the page, size, search, filter, and sort parameters to the url if they are defined.\n *\n * @param request -\n * The request to add to the url.\n * @returns\n * This object.\n */\n public from(request: IZDataRequest): this {\n this._url = this._url\n .page(request.page)\n .size(request.size)\n .search(request.search)\n .filter(new ZFilterSerialize().serialize(request.filter))\n .sort(new ZSortSerialize().serialize(request.sort));\n return this;\n }\n\n /**\n * Updates the url to optimize to retrieve a count.\n *\n * This will add the size and page parameters to the url and remove the sort parameter.\n *\n * @returns\n * This object.\n */\n public count(): this {\n this._url = this._url.size(1).page(1).sort(null);\n return this;\n }\n\n /**\n * Returns the built url.\n *\n * @returns\n * The built url.\n */\n public build(): string {\n return this._url.build();\n }\n}\n","import type { IZDataRequest, IZDataSource } from \"@zthun/helpful-query\";\nimport type { IZHttpService } from \"@zthun/webigail-http\";\nimport { ZHttpRequestBuilder } from \"@zthun/webigail-http\";\nimport { ZUrlBuilder } from \"@zthun/webigail-url\";\nimport { ZRestfulUrlBuilder } from \"../url/restful-url.mjs\";\nimport type { IZRestfulCreate } from \"./restful-create.mjs\";\nimport type { IZRestfulDelete } from \"./restful-delete.mjs\";\nimport type { IZRestfulGet } from \"./restful-get.mjs\";\nimport type { IZRestfulUpdate } from \"./restful-update.mjs\";\nimport type { 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\n 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 r = new ZHttpRequestBuilder()\n .copy(this._request)\n .get()\n .url(\n new ZRestfulUrlBuilder(this.endpoint().build())\n .from(req)\n .count()\n .build(),\n )\n .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 r = new ZHttpRequestBuilder()\n .copy(this._request)\n .get()\n .url(new ZRestfulUrlBuilder(this.endpoint().build()).from(req).build())\n .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()\n .copy(this._request)\n .get()\n .url(url)\n .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>()\n .copy(this._request)\n .post(body)\n .url(url)\n .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>()\n .copy(this._request)\n .put(body)\n .url(url)\n .build();\n const { data } = await this._http.request<T>(r);\n return data;\n }\n\n public async update(\n identification: number | string,\n fields: Partial<T>,\n ): Promise<T> {\n const url = this.endpoint(identification).build();\n const r = new ZHttpRequestBuilder<Partial<T>>()\n .copy(this._request)\n .patch(fields)\n .url(url)\n .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>()\n .copy(this._request)\n .delete()\n .url(url)\n .build();\n await this._http.request(r);\n }\n}\n"],"names":["ZRestfulUrlBuilder","from","request","_url","page","size","search","filter","ZFilterSerialize","serialize","sort","ZSortSerialize","count","build","baseUrl","_define_property","ZUrlBuilder","parse","ZRestfulService","endpoint","identification","url","_endpointUrl","append","req","r","ZHttpRequestBuilder","copy","_request","get","data","_http","retrieve","result","create","body","post","upsert","put","update","fields","patch","delete"],"mappings":";;;;;;;;;;;;;;;;;AAIA;;;AAGC,IACM,MAAMA,kBAAAA,CAAAA;AAUX;;;;;;;;;MAUOC,IAAAA,CAAKC,OAAsB,EAAQ;AACxC,QAAA,IAAI,CAACC,IAAI,GAAG,IAAI,CAACA,IAAI,CAClBC,IAAI,CAACF,OAAAA,CAAQE,IAAI,CAAA,CACjBC,IAAI,CAACH,OAAAA,CAAQG,IAAI,EACjBC,MAAM,CAACJ,OAAAA,CAAQI,MAAM,EACrBC,MAAM,CAAC,IAAIC,gBAAAA,EAAAA,CAAmBC,SAAS,CAACP,OAAAA,CAAQK,MAAM,CAAA,CAAA,CACtDG,IAAI,CAAC,IAAIC,iBAAiBF,SAAS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CAACF,QAAQ,CAACC,gBAAgBP,KAAK,EAAA;AAC/C,QAAA,MAAMY,CAAAA,GAAI,IAAIC,mBAAAA,EAAAA,CACXC,IAAI,CAAC,IAAI,CAACC,QAAQ,CAAA,CAClBc,MAAM,EAAA,CACNrB,GAAG,CAACA,KACJR,KAAK,EAAA;AACR,QAAA,MAAM,IAAI,CAACkB,KAAK,CAAC7B,OAAO,CAACuB,CAAAA,CAAAA;AAC3B,IAAA;AAnHA;;;;;;;;;;;;;AAaC,MACD,WAAA,CACmBM,KAAoB,EACrC,YAAqC,EACpBH,QAAAA,GAAW,IAAIF,mBAAAA,EAAAA,CAAyBb,KAAK,EAAE,CAChE;;;;aAHiBkB,KAAAA,GAAAA,KAAAA;aACAT,YAAAA,GAAAA,YAAAA;aACAM,QAAAA,GAAAA,QAAAA;AAChB,IAAA;AAkGL;;;;"}
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A service that can be used to create resources.
|
|
3
|
+
*
|
|
4
|
+
* @param T -
|
|
5
|
+
* The type of resource being created.
|
|
6
|
+
*/
|
|
1
7
|
export interface IZRestfulCreate<T> {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new entity.
|
|
10
|
+
*
|
|
11
|
+
* This uses a POST verb.
|
|
12
|
+
*
|
|
13
|
+
* @param body -
|
|
14
|
+
* The post body that represents the resource to create.
|
|
15
|
+
*
|
|
16
|
+
* @returns
|
|
17
|
+
* The resource that was created.
|
|
18
|
+
*/
|
|
2
19
|
create(body: T): Promise<T>;
|
|
3
20
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A service that can be used to delete resources.
|
|
3
|
+
*/
|
|
1
4
|
export interface IZRestfulDelete {
|
|
5
|
+
/**
|
|
6
|
+
* Deletes a resource entity.
|
|
7
|
+
*
|
|
8
|
+
* This uses the DELETE verb.
|
|
9
|
+
*
|
|
10
|
+
* @param identification -
|
|
11
|
+
* The identification of the resource to delete.
|
|
12
|
+
*/
|
|
2
13
|
delete(identification: string): Promise<void>;
|
|
3
14
|
}
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A service that can be used to get resources.
|
|
3
|
+
*
|
|
4
|
+
* @param T -
|
|
5
|
+
* The type of resource being retrieved.
|
|
6
|
+
*/
|
|
1
7
|
export interface IZRestfulGet<T> {
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves a single item by it's identification.
|
|
10
|
+
*
|
|
11
|
+
* This uses a GET verb.
|
|
12
|
+
*
|
|
13
|
+
* @param identification -
|
|
14
|
+
* The identification of the resource to retrieve.
|
|
15
|
+
*
|
|
16
|
+
* @returns
|
|
17
|
+
* The json representation of the entity.
|
|
18
|
+
*/
|
|
2
19
|
get(identification: number | string): Promise<T>;
|
|
3
20
|
}
|
|
@@ -6,13 +6,53 @@ import { IZRestfulDelete } from './restful-delete.mjs';
|
|
|
6
6
|
import { IZRestfulGet } from './restful-get.mjs';
|
|
7
7
|
import { IZRestfulUpdate } from './restful-update.mjs';
|
|
8
8
|
import { IZRestfulUpsert } from './restful-upsert.mjs';
|
|
9
|
+
/**
|
|
10
|
+
* A service that conforms to all known restful standards.
|
|
11
|
+
*
|
|
12
|
+
* @param T -
|
|
13
|
+
* The type of resource being retrieved or mutated.
|
|
14
|
+
*/
|
|
9
15
|
export interface IZRestfulService<T> extends IZRestfulCreate<T>, IZRestfulDelete, IZRestfulGet<T>, IZRestfulUpdate<T>, IZRestfulUpdate<T>, IZRestfulUpsert<T>, IZDataSource<T> {
|
|
10
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* A generic implementation of a restful service that assumes all verbs are implemented.
|
|
19
|
+
*
|
|
20
|
+
* This can be used to invoke a service that is only partially implemented. If your service,
|
|
21
|
+
* for example, is read only, then create, upsert, update, and delete should all return
|
|
22
|
+
* not found or forbidden errors.
|
|
23
|
+
*
|
|
24
|
+
* @param T -
|
|
25
|
+
* The type of resource being retrieved or mutated.
|
|
26
|
+
*/
|
|
11
27
|
export declare class ZRestfulService<T> implements IZRestfulService<T> {
|
|
12
28
|
private readonly _http;
|
|
13
29
|
private readonly _endpointUrl;
|
|
14
30
|
private readonly _request;
|
|
31
|
+
/**
|
|
32
|
+
* Initializes a new instance of this object.
|
|
33
|
+
*
|
|
34
|
+
* @param _http -
|
|
35
|
+
* The http service to use when invoking the RESTful service.
|
|
36
|
+
* @param _endpointUrl -
|
|
37
|
+
* The root url of the endpoint to hit. This can include params
|
|
38
|
+
* to send them with every request, but standard params of page,
|
|
39
|
+
* size, search, filter, and sort will be overridden depending on
|
|
40
|
+
* which method is being invoked.
|
|
41
|
+
* @param _request -
|
|
42
|
+
* The base request to use when constructing requests in the http
|
|
43
|
+
* service.
|
|
44
|
+
*/
|
|
15
45
|
constructor(_http: IZHttpService, _endpointUrl: string, _request?: import('@zthun/webigail-http').IZHttpRequest<any>);
|
|
46
|
+
/**
|
|
47
|
+
* Gets the final endpoint for a resource.
|
|
48
|
+
*
|
|
49
|
+
* @param identification -
|
|
50
|
+
* The identification of a single resource. If this is falsy, then
|
|
51
|
+
* the entire data scope is used.
|
|
52
|
+
*
|
|
53
|
+
* @returns
|
|
54
|
+
* A url builder that points to the target resource endpoint.
|
|
55
|
+
*/
|
|
16
56
|
endpoint(identification?: number | string): ZUrlBuilder;
|
|
17
57
|
count(req: IZDataRequest): Promise<number>;
|
|
18
58
|
retrieve(req: IZDataRequest): Promise<T[]>;
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A restful service that can update resources.
|
|
3
|
+
*
|
|
4
|
+
* @param T -
|
|
5
|
+
* The type of resource being updated.
|
|
6
|
+
*/
|
|
1
7
|
export interface IZRestfulUpdate<T> {
|
|
8
|
+
/**
|
|
9
|
+
* Partially updates an existing resource entity.
|
|
10
|
+
*
|
|
11
|
+
* This uses the PATCH verb.
|
|
12
|
+
*
|
|
13
|
+
* @param identification -
|
|
14
|
+
* The identification of the resource to update.
|
|
15
|
+
* @param fields -
|
|
16
|
+
* The partial fields to update.
|
|
17
|
+
*
|
|
18
|
+
* @returns
|
|
19
|
+
* The resource that was updated.
|
|
20
|
+
*/
|
|
2
21
|
update(identification: string, fields: Partial<T>): Promise<T>;
|
|
3
22
|
}
|
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A restful service that can upsert resources.
|
|
3
|
+
*
|
|
4
|
+
* @param T -
|
|
5
|
+
* The type of resource being created/updated.
|
|
6
|
+
*/
|
|
1
7
|
export interface IZRestfulUpsert<T> {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new entity or updates an existing entity.
|
|
10
|
+
*
|
|
11
|
+
* This is determined by the body parameters on whether
|
|
12
|
+
* or not an entity already exists.
|
|
13
|
+
*
|
|
14
|
+
* This uses the PUT verb.
|
|
15
|
+
*
|
|
16
|
+
* @param body -
|
|
17
|
+
* The post body that represents the resource to create
|
|
18
|
+
* or update.
|
|
19
|
+
*
|
|
20
|
+
* @returns
|
|
21
|
+
* The resource that was created or updated.
|
|
22
|
+
*/
|
|
2
23
|
upsert(body: T): Promise<T>;
|
|
3
24
|
}
|
|
@@ -1,8 +1,39 @@
|
|
|
1
1
|
import { IZDataRequest } from '@zthun/helpful-query';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a decorator that can build a url for a restful endpoint
|
|
4
|
+
* given an existing base url.
|
|
5
|
+
*/
|
|
2
6
|
export declare class ZRestfulUrlBuilder {
|
|
3
7
|
private _url;
|
|
8
|
+
/**
|
|
9
|
+
* Initializes a new instance of this object.
|
|
10
|
+
*/
|
|
4
11
|
constructor(baseUrl: string);
|
|
12
|
+
/**
|
|
13
|
+
* Adds the request parameters to the url.
|
|
14
|
+
*
|
|
15
|
+
* This will add the page, size, search, filter, and sort parameters to the url if they are defined.
|
|
16
|
+
*
|
|
17
|
+
* @param request -
|
|
18
|
+
* The request to add to the url.
|
|
19
|
+
* @returns
|
|
20
|
+
* This object.
|
|
21
|
+
*/
|
|
5
22
|
from(request: IZDataRequest): this;
|
|
23
|
+
/**
|
|
24
|
+
* Updates the url to optimize to retrieve a count.
|
|
25
|
+
*
|
|
26
|
+
* This will add the size and page parameters to the url and remove the sort parameter.
|
|
27
|
+
*
|
|
28
|
+
* @returns
|
|
29
|
+
* This object.
|
|
30
|
+
*/
|
|
6
31
|
count(): this;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the built url.
|
|
34
|
+
*
|
|
35
|
+
* @returns
|
|
36
|
+
* The built url.
|
|
37
|
+
*/
|
|
7
38
|
build(): string;
|
|
8
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zthun/webigail-rest",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "Helpful services for querying rest services based on specific standards.",
|
|
5
5
|
"author": "Anthony Bonta",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,19 +25,21 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@zthun/helpful-fn": "^9.
|
|
29
|
-
"@zthun/helpful-query": "^9.
|
|
30
|
-
"@zthun/webigail-http": "^5.0.
|
|
31
|
-
"@zthun/webigail-url": "^5.0.
|
|
28
|
+
"@zthun/helpful-fn": "^9.11.2",
|
|
29
|
+
"@zthun/helpful-query": "^9.11.2",
|
|
30
|
+
"@zthun/webigail-http": "^5.0.3",
|
|
31
|
+
"@zthun/webigail-url": "^5.0.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@zthun/janitor-build-config": "^19.4
|
|
35
|
-
"
|
|
36
|
-
"
|
|
34
|
+
"@zthun/janitor-build-config": "^19.5.4",
|
|
35
|
+
"@zthun/janitor-ts-config": "^19.5.3",
|
|
36
|
+
"typescript": "~5.9.3",
|
|
37
|
+
"vite": "^7.3.0",
|
|
38
|
+
"vitest": "^4.0.16"
|
|
37
39
|
},
|
|
38
40
|
"files": [
|
|
39
41
|
"dist"
|
|
40
42
|
],
|
|
41
43
|
"sideEffects": false,
|
|
42
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "72e9e39897db1a5105194b6b40d5060e537a0a55"
|
|
43
45
|
}
|