@opra/sqb 1.28.3 → 1.28.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Panates
3
+ Copyright (c) 2020-present Panates®
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,19 +1,70 @@
1
+ <div align="center">
2
+
3
+ <a href="https://oprajs.com">
4
+ <img src="https://oprajs.com/img/opra-header-block.webp" width="880" alt="OPRA — Open Platform for Rich APIs" />
5
+ </a>
6
+
1
7
  # @opra/sqb
2
8
 
9
+ SQL data service adapter for the OPRA framework, powered by SQB
10
+
3
11
  [![NPM Version][npm-image]][npm-url]
4
12
  [![NPM Downloads][downloads-image]][downloads-url]
5
13
  [![CI Tests][ci-test-image]][ci-test-url]
6
14
  [![Test Coverage][coveralls-image]][coveralls-url]
7
15
 
16
+ [🌐 Documentation](https://oprajs.com) · [🚀 Getting Started](https://oprajs.com/docs/introduction) · [📦 Packages](https://github.com/panates/opra#packages) · [💬 Issues](https://github.com/panates/opra/issues)
17
+
18
+ </div>
19
+
20
+ ---
21
+
22
+ SQL data service adapter for the [OPRA](https://oprajs.com) framework, powered by [SQB](https://github.com/panates/sqb). Connect your relational database to OPRA's operation model with full transaction support.
23
+
24
+ ## Features
25
+
26
+ - **`SqbServiceBase`** — Base service managing SqbClient or SqbConnection with transaction support
27
+ - **`SqbCollectionService`** — Table-level CRUD service with automatic query generation
28
+ - **`SqbEntityService`** — Row-level service for single entity operations
29
+ - **`SQBAdapter`** — Utility namespace: `prepareFilter()`, `parseRequest()`
30
+ - Automatic translation of OPRA filter DSL to SQL WHERE clauses
31
+ - `withTransaction()` helper for multi-step atomic operations
32
+ - Compatible with PostgreSQL, MySQL, SQLite, and other SQB-supported databases
33
+
34
+ ## Installation
8
35
 
9
- ## Support
10
- You can report bugs and discuss features on the [GitHub issues](https://github.com/panates/opra/issues) page.
36
+ ```bash
37
+ npm install @opra/sqb
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ```typescript
43
+ import { SqbCollectionService } from '@opra/sqb';
44
+ import { SqbClient } from '@sqb/connect';
45
+
46
+ @HttpController({ path: 'orders' })
47
+ export class OrdersController extends SqbCollectionService<Order> {
48
+ constructor(client: SqbClient) {
49
+ super(Order, client, 'orders');
50
+ }
51
+
52
+ @HttpOperation.Entity.FindMany({ type: Order })
53
+ findMany() { return super.findMany(); }
54
+
55
+ @HttpOperation.Entity.Create({ type: Order })
56
+ async create(dto: CreateOrderDto) {
57
+ return this.withTransaction(conn => super.create(dto, { connection: conn }));
58
+ }
59
+ }
60
+ ```
11
61
 
12
62
  ## Node Compatibility
13
- - node >= 20.x
14
63
 
64
+ - node >= 20.x
15
65
 
16
66
  ## License
67
+
17
68
  Available under [MIT](LICENSE) license.
18
69
 
19
70
  [npm-image]: https://img.shields.io/npm/v/@opra/sqb
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@opra/sqb",
3
- "version": "1.28.3",
3
+ "version": "1.28.5",
4
4
  "description": "Opra SQB adapter package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
+ "homepage": "https://www.oprajs.com",
7
8
  "dependencies": {
8
9
  "reflect-metadata": "^0.2.2",
9
10
  "tslib": "^2.8.1",
10
11
  "valgen": "^6.2.0"
11
12
  },
12
13
  "peerDependencies": {
13
- "@opra/core": "^1.28.3",
14
- "@opra/http": "^1.28.3",
14
+ "@opra/core": "^1.28.5",
15
+ "@opra/http": "^1.28.5",
15
16
  "@sqb/builder": ">=5.0.1 <6",
16
17
  "@sqb/connect": ">=5.0.1 <6"
17
18
  },
@@ -135,8 +135,10 @@ export class SqbEntityService extends SqbServiceBase {
135
135
  return vg.oneOf([defaultGenerator(), vg.isInstanceOf(SqlElement)]);
136
136
  },
137
137
  };
138
- if (operation === 'update')
138
+ if (operation === 'update') {
139
139
  options.partial = 'deep';
140
+ options.allowNullOptionals = true;
141
+ }
140
142
  validator = dataType.generateCodec('decode', options);
141
143
  this._inputCodecs[cacheKey] = validator;
142
144
  return validator;