Skip to content

Commit

Permalink
Merge branch 'v2' into v2-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Jul 17, 2024
2 parents 980dd5f + 19db641 commit ac1907d
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
24 changes: 24 additions & 0 deletions lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ModelExportDataOpts,
RequestOptions,
ReadForViewOpts,
ReadAggOpts,
} from "./types";
import {
createSearchPayload,
Expand All @@ -34,6 +35,7 @@ import {
createFieldsGetPayload,
createExportDataPayload,
createReadForViewPayload,
createReadAggPayload,
} from "./payloads";

export class Model {
Expand Down Expand Up @@ -426,4 +428,26 @@ export class Model {
options,
});
}

public async read_agg(
data: ReadAggOpts,
options?: RequestOptions,
): Promise<any> {
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,
});
}
}
14 changes: 14 additions & 0 deletions lib/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
ModelFieldsGetPayload,
ModelExportDataPayload,
ReadForViewPayload,
ReadAggPayload,
} from "./types";

export const makeLoginTokenPayload = (options: LoginTokenPayload): Payload => {
Expand Down Expand Up @@ -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_agg",
domain,
aggregate_fields,
];
};
7 changes: 7 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,10 @@ export type ReadForViewOpts = {
};

export type ReadForViewPayload = Database & Token & Model & ReadForViewOpts;

export type ReadAggOpts = {
domain?: any[];
aggregate_fields: Record<string, string[]>;
};

export type ReadAggPayload = Database & Token & Model & ReadAggOpts;
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gisce/powerp.js",
"version": "2.2.0",
"version": "2.3.1",
"description": "PowERP Javascript Client",
"module": "./dist/powerpjs.es.js",
"files": [
Expand Down Expand Up @@ -108,7 +108,13 @@
"npmPublish": true
}
],
"@semantic-release/github",
[
"@semantic-release/github",
{
"successComment": false,
"failComment": false
}
],
"@semantic-release/git"
]
}
Expand Down

0 comments on commit ac1907d

Please sign in to comment.