Skip to content

Commit 4ac212b

Browse files
committed
feat: allow raw queries for where filter
Adapted types and functions Added tests Updated dependencies safely Adapted github workflow
1 parent adc14c7 commit 4ac212b

8 files changed

Lines changed: 246 additions & 86 deletions

File tree

.github/workflows/main.yml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ jobs:
3434
name: build
3535
path: dist
3636

37-
test:
38-
name: Test
37+
generate:
38+
name: Generate SDK
3939
runs-on: ubuntu-latest
40+
needs: build
41+
strategy:
42+
matrix:
43+
target: [node, node.rx, browser, browser.rx]
4044
steps:
4145
- name: Checkout repository
4246
uses: actions/checkout@v4
@@ -49,16 +53,23 @@ jobs:
4953
- name: Install dependencies
5054
run: npm ci
5155

52-
- name: Run tests
53-
run: npm run test
56+
- name: Download dist files
57+
uses: actions/download-artifact@v4
58+
with:
59+
name: build
60+
path: dist
5461

55-
generate:
56-
name: Generate SDK
62+
- name: Generate SDK
63+
run: |
64+
chmod +x ./bin/cli.js
65+
./bin/cli.js test/openapi.json --target ${{ matrix.target }}
66+
./bin/cli.js test/openapi_v2.json --target ${{ matrix.target }}
67+
./bin/cli.js test/openapi_v3.json --target ${{ matrix.target }}
68+
69+
test:
70+
name: Test
5771
runs-on: ubuntu-latest
5872
needs: build
59-
strategy:
60-
matrix:
61-
target: [node, node.rx, browser, browser.rx]
6273
steps:
6374
- name: Checkout repository
6475
uses: actions/checkout@v4
@@ -77,11 +88,16 @@ jobs:
7788
name: build
7889
path: dist
7990

80-
- name: Generate SDK
91+
- name: Generate SDK for tests
8192
run: |
8293
chmod +x ./bin/cli.js
83-
./bin/cli.js test/openapi.json --target ${{ matrix.target }}
84-
./bin/cli.js test/openapi_v2.json --target ${{ matrix.target }}
94+
./bin/cli.js test/openapi_v3.json --target browser --use-query-language
95+
96+
- name: Run type-check
97+
run: npm run type-check
98+
99+
- name: Run tests
100+
run: npm run test
85101

86102
publish:
87103
name: Publish release version

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,22 @@ wServices['article'].some({
349349
where: {
350350
AND: [
351351
{
352-
OR: [{ name: { LIKE: '%test%', lower: true } }, { articleNumber: { LIKE: '%345%' } }]
352+
OR: [{ name: { LIKE: '%test%', LOWER: true } }, { articleNumber: { LIKE: '%345%' } }]
353353
},
354354
{ batchNumberRequired: { EQ: true } }
355355
]
356356
}
357357
});
358358
```
359359

360+
Some API operations like the arithmetic ones are not supported as type, due to their complexity. In this case a raw filter expression can be passed as string to `where`
361+
362+
```ts
363+
wServices['article'].some({
364+
where: '(articleLength * articleWidth * articleHeight) <= 3000'
365+
});
366+
```
367+
360368
"where" parameters are ANDed with other filter parameters.
361369

362370
It is also possible to set an empty list within an IN-query:

package-lock.json

Lines changed: 67 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"cli:browser:v2": "./bin/cli.js test/openapi_v2.json --target browser",
4545
"cli:browser.rx:v2": "./bin/cli.js test/openapi_v2.json --target browser.rx",
4646
"cli:browser:v3": "./bin/cli.js test/openapi_v3.json --target browser",
47+
"cli:browser:v3:ql": "./bin/cli.js test/openapi_v3.json --target browser --use-query-language",
4748
"cli:browser:v3:cache": "./bin/cli.js test/openapi_v3.json --target browser --cache",
4849
"cli:browser.rx:v3": "./bin/cli.js test/openapi_v3.json --target browser.rx",
4950
"cli:browser.rx:v3:cache": "./bin/cli.js test/openapi_v3.json --target browser.rx --cache",
@@ -55,9 +56,10 @@
5556
"prettier:fix": "prettier . --write",
5657
"test": "vitest run",
5758
"test:coverage": "vitest run --coverage",
59+
"type-check": "tsc -p tsconfig.sdk.json --noEmit --skipLibCheck",
5860
"lint": "eslint ./src --cache",
5961
"lint:fix": "npm run lint -- --fix",
60-
"ci": "npm run prettier && npm run lint && npm run test && npm run build && npm run cli:browser:v1 && npm run cli:browser:v2 && npm run cli:browser:v3",
62+
"ci": "npm run prettier && npm run lint && npm run build && npm run cli:browser:v1 && npm run cli:browser:v2 && npm run cli:browser:v3 && npm run cli:browser:v3:ql && npm run type-check && npm run test",
6163
"release": "standard-version"
6264
},
6365
"devDependencies": {

0 commit comments

Comments
 (0)