From 76db3c14ea4c2ea00bbfca1a2b400590cbf8ee4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gu=CC=88ell=20Segarra?= Date: Wed, 17 Jul 2024 10:35:26 +0200 Subject: [PATCH 1/5] feat: add read_agg --- lib/model.ts | 24 ++++++++++++++++++++++++ lib/payloads.ts | 14 ++++++++++++++ lib/types.ts | 7 +++++++ 3 files changed, 45 insertions(+) diff --git a/lib/model.ts b/lib/model.ts index 3f4782c..16b40ba 100644 --- a/lib/model.ts +++ b/lib/model.ts @@ -16,6 +16,7 @@ import { ModelExportDataOpts, RequestOptions, ReadForViewOpts, + ReadAggOpts, } from "./types"; import { createSearchPayload, @@ -34,6 +35,7 @@ import { createFieldsGetPayload, createExportDataPayload, createReadForViewPayload, + createReadAggPayload, } from "./payloads"; export class Model { @@ -426,4 +428,26 @@ export class Model { options, }); } + + public async read_agg( + data: ReadAggOpts, + options?: RequestOptions, + ): Promise { + const { domain = [], aggregate_fields } = data; + const { model } = this; + const { database, token } = this.client; + + const payload = createReadAggPayload({ + database: database!, + token: token!, + model, + domain, + aggregate_fields, + }); + + return await this.client._fetch({ + payload, + options, + }); + } } diff --git a/lib/payloads.ts b/lib/payloads.ts index d731cf1..906c4b0 100644 --- a/lib/payloads.ts +++ b/lib/payloads.ts @@ -23,6 +23,7 @@ import { ModelFieldsGetPayload, ModelExportDataPayload, ReadForViewPayload, + ReadAggPayload, } from "./types"; export const makeLoginTokenPayload = (options: LoginTokenPayload): Payload => { @@ -423,3 +424,16 @@ export const createReadForViewPayload = ( context, ]; }; +export const createReadAggPayload = (options: ReadAggPayload): Payload => { + const { database, token, model, domain, aggregate_fields } = options; + return [ + "execute", + database, + "token", + token, + model, + "read_for_view", + domain, + aggregate_fields, + ]; +}; diff --git a/lib/types.ts b/lib/types.ts index 5976038..5c3eb92 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -240,3 +240,10 @@ export type ReadForViewOpts = { }; export type ReadForViewPayload = Database & Token & Model & ReadForViewOpts; + +export type ReadAggOpts = { + domain?: any[]; + aggregate_fields: Record; +}; + +export type ReadAggPayload = Database & Token & Model & ReadAggOpts; From 1f3efcd9b57363741b62028e7a45fafa18ac6962 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 17 Jul 2024 08:37:57 +0000 Subject: [PATCH 2/5] chore(release): 2.3.0 [skip ci] # [2.3.0](https://github.com/gisce/powerp.js/compare/v2.2.0...v2.3.0) (2024-07-17) ### Features * add read_agg ([76db3c1](https://github.com/gisce/powerp.js/commit/76db3c14ea4c2ea00bbfca1a2b400590cbf8ee4e)) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 118b130..c92d940 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gisce/powerp.js", - "version": "2.2.0", + "version": "2.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@gisce/powerp.js", - "version": "2.2.0", + "version": "2.3.0", "license": "MIT", "devDependencies": { "@commitlint/cli": "^18.4.3", diff --git a/package.json b/package.json index 7d5bb9b..3e5352f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gisce/powerp.js", - "version": "2.2.0", + "version": "2.3.0", "description": "PowERP Javascript Client", "module": "./dist/powerpjs.es.js", "files": [ From 3dfd609d981e64383b9db7e1d0b888fa68429e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gu=CC=88ell=20Segarra?= Date: Wed, 17 Jul 2024 12:28:10 +0200 Subject: [PATCH 3/5] fix: typo --- lib/payloads.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/payloads.ts b/lib/payloads.ts index 906c4b0..e557e15 100644 --- a/lib/payloads.ts +++ b/lib/payloads.ts @@ -432,7 +432,7 @@ export const createReadAggPayload = (options: ReadAggPayload): Payload => { "token", token, model, - "read_for_view", + "read_agg", domain, aggregate_fields, ]; From ac58322ed73e5fe280a3cddd26777eb05802baa5 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 17 Jul 2024 10:28:58 +0000 Subject: [PATCH 4/5] chore(release): 2.3.1 [skip ci] ## [2.3.1](https://github.com/gisce/powerp.js/compare/v2.3.0...v2.3.1) (2024-07-17) ### Bug Fixes * typo ([3dfd609](https://github.com/gisce/powerp.js/commit/3dfd609d981e64383b9db7e1d0b888fa68429e4f)) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c92d940..3a83b88 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gisce/powerp.js", - "version": "2.3.0", + "version": "2.3.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@gisce/powerp.js", - "version": "2.3.0", + "version": "2.3.1", "license": "MIT", "devDependencies": { "@commitlint/cli": "^18.4.3", diff --git a/package.json b/package.json index 3e5352f..d4b461a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gisce/powerp.js", - "version": "2.3.0", + "version": "2.3.1", "description": "PowERP Javascript Client", "module": "./dist/powerpjs.es.js", "files": [ From 19db6414071f6989f01d03b997726caa64b63165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gu=CC=88ell=20Segarra?= Date: Wed, 17 Jul 2024 12:55:32 +0200 Subject: [PATCH 5/5] chore: remove gh comments in semantic release --- package.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d4b461a..90d0339 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,13 @@ "npmPublish": true } ], - "@semantic-release/github", + [ + "@semantic-release/github", + { + "successComment": false, + "failComment": false + } + ], "@semantic-release/git" ] }