-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
14,731 additions
and
480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ERP_HOST=https://url_erp:8068 | ||
ERP_DB=database | ||
ERP_USER=user | ||
ERP_PASSWORD=password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 12, | ||
"sourceType": "module" | ||
}, | ||
"plugins": ["@typescript-eslint"], | ||
"rules": { | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-empty-function": "off", | ||
"@typescript-eslint/no-non-null-assertion": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: ALPHA - Create PR on WebClient | ||
|
||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
create-pr: | ||
if: github.event.release.prerelease == true && contains(github.event.release.tag_name, '-alpha.') | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout webclient repository | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: 'gisce/webclient' | ||
ref: alpha | ||
token: ${{ secrets.GH_PAT }} | ||
|
||
- name: Update library version in package.json | ||
run: | | ||
NEW_VERSION=${{ github.event.release.tag_name }} | ||
NEW_VERSION=${NEW_VERSION#v} # Remove the leading 'v' | ||
sed -i 's|"@gisce/powerp.js": "[^"]*"|"@gisce/powerp.js": "'"$NEW_VERSION"'"|' package.json | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '20.5.0' | ||
|
||
- name: Install npm dependencies and generate package-lock.json | ||
run: | | ||
npm install | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
token: ${{ secrets.GH_PAT }} | ||
commit-message: "fix: Update @gisce/powerp.js to ${{ github.event.release.tag_name }}" | ||
title: "Update @gisce/powerp.js to ${{ github.event.release.tag_name }}" | ||
branch: "update-powerpjs-${{ github.event.release.tag_name }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: Build and publish | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the "master" branch | ||
push: | ||
branches: ["master", "develop"] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/[email protected] | ||
with: | ||
node-version: "16.13.1" | ||
registry-url: "https://registry.npmjs.org" | ||
|
||
- name: Installing dependencies | ||
run: npm ci | ||
|
||
- name: Build and publish | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
# - main | ||
# - develop | ||
- alpha | ||
workflow_dispatch: | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '20.5.0' | ||
|
||
- name: Install Dependencies | ||
run: npm ci | ||
|
||
- name: Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_PAT }} | ||
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} | ||
run: npx semantic-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,3 +58,5 @@ typings/ | |
# dotenv environment variables file | ||
.env | ||
.idea | ||
.vscode | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
lib | ||
coverage | ||
spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"tabWidth": 2, | ||
"useTabs": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,74 @@ | ||
# PowERP.js | ||
|
||
Javascript client for PowERP and MessagePack protocol. | ||
A TypeScript implementation for a PowERP client. | ||
|
||
## Install | ||
|
||
## Example | ||
For the moment you can install this library adding the specific git repository in your `package.json` dependencies, like this: | ||
|
||
_package.json_ | ||
|
||
```json | ||
{ | ||
// ... | ||
"dependencies": { | ||
// ... | ||
"powerp.js": "git://github.com/gisce/powerp.js.git#feature/typescript" | ||
} | ||
} | ||
``` | ||
|
||
## Usage | ||
|
||
```javascript | ||
import Client from 'powerp'; | ||
|
||
|
||
const c = new Client('http://localhost:8068', 'test', 'admin', 'admin'); | ||
c.login().then(() => { | ||
const model = c.model('res.partner'); | ||
model.search([['name', 'ilike', 'asus']]).then((ids) => { | ||
model.read(ids, ['name', 'vat']).then((results) => { | ||
results.map((result) => { | ||
console.log(`Partner ${result.name} vat: ${result.vat}`); | ||
}); | ||
}); | ||
}); | ||
import { Client } from "powerp.js"; | ||
|
||
// ... | ||
|
||
const c = new Client({ | ||
host: process.env.ERP_HOST!, | ||
database: process.env.ERP_DB!, | ||
}); | ||
|
||
const token = await c.loginAndGetToken({ | ||
user: process.env.ERP_USER!, | ||
password: process.env.ERP_PASSWORD!, | ||
}); | ||
``` | ||
|
||
## Running tests | ||
|
||
First adjust your `.env` file in order to fulfill the proper host, database and auth details. You can get an example copy from `.env.sample`. | ||
|
||
Then install the dependencies with: | ||
|
||
```shell | ||
$ npm install | ||
``` | ||
|
||
And therefore you can run the tests using: | ||
|
||
```shell | ||
$ npm test | ||
``` | ||
|
||
## Publishing new versions of the library | ||
|
||
If you make any changes in this library and want to use them in your project, you must build it in order to get the updated version: | ||
|
||
```shell | ||
$ npm run build | ||
``` | ||
|
||
This will erase your `dist/` folder and rebuild the library in it. You must push these updated `dist/` files into git. | ||
|
||
Then in your project you can simply: | ||
|
||
```shell | ||
$ npm update powerp.js | ||
``` | ||
|
||
## TODO | ||
|
||
[ ] Implement pending methods from the old version | ||
[ ] Improve the way to publish this library. NPM public registry? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
roots: ["<rootDir>/spec"], | ||
transform: { | ||
"^.+\\.tsx?$": "ts-jest", | ||
}, | ||
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$", | ||
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], | ||
collectCoverage: true, | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.