diff --git a/package-lock.json b/package-lock.json index ffb80aa..72317fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "2.4.65", "license": "ISC", "dependencies": { - "@web-atoms/core": "^v2.4.29", + "@web-atoms/core": "^v2.4.30", "@web-atoms/date-time": "^1.1.0", "@web-atoms/module-loader": "^2.1.2", "@web-atoms/web-controls": "^2.2.1", @@ -29,9 +29,9 @@ } }, "node_modules/@web-atoms/core": { - "version": "2.4.29", - "resolved": "https://registry.npmjs.org/@web-atoms/core/-/core-2.4.29.tgz", - "integrity": "sha512-0yyus8JLw6mxt3lFbZMclr68rmKl8c7enRv9dzAPYn+QVVSEq2LpR1eDdx78RUOw38EPfFOSbYhPOGBA+Yy2EA==", + "version": "2.4.30", + "resolved": "https://registry.npmjs.org/@web-atoms/core/-/core-2.4.30.tgz", + "integrity": "sha512-bMnMBg4WaooTOgt5tZiQcB6cFFQZCGOefDshV+cjU5iy6tiCMm88GzmmfmnWC7fVq72e1vBDRe4BS5UeBUyLTg==", "license": "MIT", "dependencies": { "@web-atoms/date-time": "^1.1.1", @@ -733,9 +733,9 @@ "dev": true }, "@web-atoms/core": { - "version": "2.4.29", - "resolved": "https://registry.npmjs.org/@web-atoms/core/-/core-2.4.29.tgz", - "integrity": "sha512-0yyus8JLw6mxt3lFbZMclr68rmKl8c7enRv9dzAPYn+QVVSEq2LpR1eDdx78RUOw38EPfFOSbYhPOGBA+Yy2EA==", + "version": "2.4.30", + "resolved": "https://registry.npmjs.org/@web-atoms/core/-/core-2.4.30.tgz", + "integrity": "sha512-bMnMBg4WaooTOgt5tZiQcB6cFFQZCGOefDshV+cjU5iy6tiCMm88GzmmfmnWC7fVq72e1vBDRe4BS5UeBUyLTg==", "requires": { "@web-atoms/date-time": "^1.1.1", "reflect-metadata": "^0.1.14" diff --git a/package.json b/package.json index c164cca..f1d0c49 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "author": "", "license": "ISC", "dependencies": { - "@web-atoms/core": "^v2.4.29", + "@web-atoms/core": "^v2.4.30", "@web-atoms/date-time": "^1.1.0", "@web-atoms/module-loader": "^2.1.2", "@web-atoms/web-controls": "^2.2.1", diff --git a/src/services/BaseEntityService.ts b/src/services/BaseEntityService.ts index e57fea0..33d4d25 100644 --- a/src/services/BaseEntityService.ts +++ b/src/services/BaseEntityService.ts @@ -461,7 +461,7 @@ export default abstract class BaseEntityService extends TaskManager { // }) as Promise; } - buildRunUrl(m: IModel, method: keyof TA, argEntity: IClrEntity, { + run(m: IModel, method: keyof TA, argEntity: IClrEntity, { args = void 0 as any[], cacheSeconds = 0, cacheVersion = void 0 as any @@ -482,51 +482,7 @@ export default abstract class BaseEntityService extends TaskManager { if (cacheVersion) { usp.append("cv", cacheVersion); } - return `${this.url}run/${$type}/${method as any}?${usp.toString()}`; - } - - async runAsText(m: IModel, method: keyof TA, argEntity: IClrEntity, { - args = void 0 as any[], - cacheSeconds = 0, - cacheVersion = void 0 as any, - cancelToken = void 0 as CancelToken - } = { - }) { - using busy = this.createBusyIndicator(false); - const url = this.buildRunUrl(m, method, argEntity, { args, cacheSeconds, cacheVersion}); - return await FetchBuilder.get(url) - .cancelToken(cancelToken) - .asText(); - } - - async runAsBlob(m: IModel, method: keyof TA, argEntity: IClrEntity, { - args = void 0 as any[], - cacheSeconds = 0, - cacheVersion = void 0 as any, - cancelToken = void 0 as CancelToken - } = { - }) { - using busy = this.createBusyIndicator(false); - const url = this.buildRunUrl(m, method, argEntity, { args, cacheSeconds, cacheVersion}); - return await FetchBuilder.get(url) - .cancelToken(cancelToken) - .asBlob(); - } - - async run(m: IModel, method: keyof TA, argEntity: IClrEntity, { - args = void 0 as any[], - cacheSeconds = 0, - cacheVersion = void 0 as any, - cancelToken = void 0 as CancelToken - } = { - }) { - using busy = this.createBusyIndicator(false); - const url = this.buildRunUrl(m, method, argEntity, { args, cacheSeconds, cacheVersion}); - let result = await FetchBuilder.get(url) - .cancelToken(cancelToken) - .asJson(); - result = this.resultConverter(result); - return result as any; + return FetchBuilder.get(`${this.url}run/${$type}/${method as any}?${usp.toString()}`).jsonPostProcessor(this.resultConverter); } diff --git a/src/services/Query.ts b/src/services/Query.ts index 6cfbae7..78355ea 100644 --- a/src/services/Query.ts +++ b/src/services/Query.ts @@ -3,6 +3,7 @@ import IPagedList from "../models/IPagedList"; import type BaseEntityService from "./BaseEntityService"; import type { ICollection, IListParams, IModel, IPagedListParams, IQueryMethod } from "./BaseEntityService"; import StringHelper from "./StringHelper"; +import FetchBuilder from "@web-atoms/core/dist/services/FetchBuilder"; export type stepTypes = "Day" | "Month" | "Year" | "Week" | "Hour"; @@ -303,7 +304,7 @@ export default class Query { return r.items; } - public toPagedList( + async toPagedList( { start = 0, size = 100, @@ -326,6 +327,9 @@ export default class Query { args } = this.context; + // @ts-expect-error + using busy = service.createBusyIndicator(hideActivityIndicator); + const trace = traceQuery; const methods = JSON.stringify(this.methods); const fm = new URLSearchParams(); @@ -348,15 +352,15 @@ export default class Query { fm.append("expandable", "1"); } const encodedMethods = fm.toString(); + let result; if (encodedMethods.length > 1824) { if (cacheSeconds > 0) { throw new Error("Generated query too big for caching"); } url = `${service.url}methods/${name}`; - return (service as any).postJson({ - url, - cancelToken, - body: { + result = await FetchBuilder.post(url) + .cancelToken(cancelToken) + .jsonBody({ methods: this.methods, start, size, @@ -366,8 +370,11 @@ export default class Query { expandable: expandable ? 1 : void 0, function: queryFunction || void 0, args: queryFunction ? args : void 0 - } - }); + }) + .asJson(); + // @ts-expect-error + result = service.resultConverter(result); + return result; } if (cacheSeconds > 0) { fm.append("cache", cacheSeconds.toString()); @@ -378,12 +385,19 @@ export default class Query { } else { } url = `${service.url}query/${name}?${fm.toString()}`; + result = await FetchBuilder.get(url) + .cancelToken(cancelToken) + .asJson(); + // @ts-expect-error + return service.resultConverter(result); // @ts-ignore - return service.getJson({ - url, - cancelToken, - hideActivityIndicator - }); + // return service.getJson({ + // url, + // cancelToken, + // hideActivityIndicator + // }); + + } protected thenInclude(a): any {