plugin-data-source-mssql 1.9.48 โ†’ 2.0.0

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/README.md CHANGED
@@ -1,69 +1,75 @@
1
- # @gemvn90/plugin-data-source-mssql
1
+ # plugin-data-source-mssql
2
2
 
3
- External MSSQL (Microsoft SQL Server) data source plugin for NocoBase.
3
+ External MSSQL (Microsoft SQL Server) data source plugin for NocoBase 2.x.
4
4
 
5
5
  ## Features
6
6
 
7
7
  ### ๐Ÿ”Œ External Data Source Integration
8
- - Connect to external Microsoft SQL Server databases
9
- - Automatically introspect and import database schema (tables, columns, types)
10
- - Support for multiple schemas within a single database
11
- - Schema-prefixed collection naming (`schema_tableName`)
8
+ - Connect to external Microsoft SQL Server databases as a NocoBase data source
9
+ - Extends `SequelizeDataSource` โ€” fully integrated with the core persistence pipeline
10
+ - Collections are **persisted** across app restarts via `dataSourcesCollections` metadata table
11
+ - Support for multiple schemas and table prefix filtering
12
12
 
13
13
  ### ๐Ÿ“Š Collection Management
14
- - **Load All Collections**: Automatically load all tables from the database
15
- - **Selective Loading**: Choose specific tables to import
16
- - **Schema Introspection**: Automatic field type detection and mapping to NocoBase field types
17
- - **Primary Key Detection**: Automatically identifies primary keys from table constraints
18
-
19
- ### โšก Performance Optimizations
20
-
21
- #### Cursor-Based Pagination
22
- Optimized for querying large datasets (millions of rows):
23
-
24
- ```typescript
25
- // Using MssqlRepository.chunkWithCursor()
26
- await repository.chunkWithCursor({
27
- chunkSize: 1000,
28
- callback: async (rows) => {
29
- // Process each chunk
30
- }
31
- });
32
- ```
33
-
34
- **Benefits:**
35
- - Avoids `OFFSET/FETCH` performance degradation on deep pages
36
- - Auto-detects best cursor strategy based on table indexes
37
- - Supports composite primary keys and unique indexes
38
- - O(1) complexity regardless of page position
14
+ - **Automatic Introspection**: Discover all tables from the external database via `readTables()`
15
+ - **Selective Loading**: Choose specific tables to import via `loadTables()`
16
+ - **Field Type Mapping**: MSSQL types automatically mapped to NocoBase field types
17
+ - **Primary Key Detection**: Auto-detects PKs via Sequelize + fallback `sys.indexes` query
39
18
 
40
19
  ### ๐Ÿ—„๏ธ Data Type Mapping
41
20
 
42
- | MSSQL Type | NocoBase Type | Interface |
43
- |------------|---------------|-----------|
44
- | `int`, `bigint`, `smallint`, `tinyint` | integer | integer |
45
- | `decimal`, `numeric`, `money` | decimal | |
46
- | `float`, `real` | double | |
47
- | `varchar`, `nvarchar`, `char`, `nchar` | string | input / textarea |
48
- | `text`, `ntext` | text | textarea |
49
- | `bit` | boolean | checkbox |
50
- | `date` | date | date |
51
- | `time` | time | time |
52
- | `datetime`, `datetime2`, `smalldatetime` | datetime | datetime |
53
- | `uniqueidentifier` | uuid | input |
54
- | `varbinary`, `binary`, `image` | json | |
21
+ | MSSQL Type | NocoBase Type | UI Component |
22
+ |------------|---------------|--------------|
23
+ | `int`, `bigint`, `smallint`, `tinyint` | integer / bigInt | InputNumber |
24
+ | `decimal`, `numeric`, `money` | decimal | InputNumber |
25
+ | `float`, `real` | float | InputNumber |
26
+ | `varchar`, `nvarchar`, `char`, `nchar` | string | Input |
27
+ | `text`, `ntext` | text | Input.TextArea |
28
+ | `bit` | boolean | Checkbox |
29
+ | `date` | dateOnly | DatePicker |
30
+ | `time` | time | TimePicker |
31
+ | `datetime`, `datetime2`, `smalldatetime` | datetimeNoTz | DatePicker |
32
+ | `datetimeoffset` | datetimeTz | DatePicker |
33
+ | `uniqueidentifier` | uuid | Input |
34
+
35
+ ### โšก Performance
36
+ - **Cursor-Based Pagination**: `MssqlSmartCursorBuilder` for efficient large dataset queries
37
+ - Avoids `OFFSET/FETCH` degradation on deep pages
38
+ - Auto-detects best cursor strategy based on table indexes
55
39
 
56
40
  ### ๐Ÿ• DateTime Handling
57
41
  - Automatic conversion of JavaScript `Date` objects to MSSQL-compatible format
58
- - Timezone-aware date filtering support
59
- - Fixes "Conversion failed when converting date and/or time from character string" errors
42
+ - `beforeFind`/`beforeCount` hooks transform date values in WHERE clauses
43
+ - Preserves Sequelize operator symbols (`Op.and`, `Op.like`, etc.) using `Reflect.ownKeys()`
60
44
 
61
45
  ### ๐Ÿ”’ Security
62
46
  - Encrypted connection support (`encrypt` option)
63
47
  - Configurable connection pooling
64
48
  - Secure credential handling
65
49
 
66
- ## Configuration Options
50
+ ## Architecture
51
+
52
+ ```
53
+ plugin-data-source-mssql/
54
+ โ”œโ”€โ”€ src/server/
55
+ โ”‚ โ”œโ”€โ”€ plugin.ts # Plugin registration + destroy middleware
56
+ โ”‚ โ”œโ”€โ”€ data-source/
57
+ โ”‚ โ”‚ โ”œโ”€โ”€ MssqlExternalDataSource.ts # Main class (extends SequelizeDataSource)
58
+ โ”‚ โ”‚ โ”œโ”€โ”€ MssqlIntrospector.ts # MSSQL-specific DatabaseIntrospector
59
+ โ”‚ โ”‚ โ”œโ”€โ”€ MssqlCollectionManager.ts # Collection manager with MSSQL repo
60
+ โ”‚ โ”‚ โ”œโ”€โ”€ MssqlRepository.ts # Repository with cursor pagination
61
+ โ”‚ โ”‚ โ””โ”€โ”€ MssqlSmartCursorBuilder.ts # Cursor-based query builder
62
+ โ”‚ โ”œโ”€โ”€ controllers/
63
+ โ”‚ โ”‚ โ””โ”€โ”€ ExternalMssqlController.ts # testConnection API
64
+ โ”‚ โ””โ”€โ”€ dialects/
65
+ โ”‚ โ””โ”€โ”€ mssql-dialect.ts # MSSQL dialect registration
66
+ โ”œโ”€โ”€ src/client/
67
+ โ”‚ โ””โ”€โ”€ ... # Configuration UI components
68
+ โ””โ”€โ”€ scripts/
69
+ โ””โ”€โ”€ copy-tedious.js # Embeds tedious + deps into dist/
70
+ ```
71
+
72
+ ## Configuration
67
73
 
68
74
  ```typescript
69
75
  interface MssqlDataSourceOptions {
@@ -92,28 +98,15 @@ interface MssqlDataSourceOptions {
92
98
 
93
99
  ## API Endpoints
94
100
 
95
- ### Test Connection
96
- ```
97
- POST /api/external-mssql:testConnection
98
- ```
99
-
100
- ### List Available Tables (Preview)
101
- ```
102
- POST /api/dataSources:readTables
103
- Body: { type: 'mssql', options: { host, database, ... } }
104
- ```
105
-
106
- ### Collection Operations
107
- Standard NocoBase data source collection operations are supported:
108
- - `GET /api/:collectionName:list`
109
- - `GET /api/:collectionName:get`
110
- - `POST /api/:collectionName:create`
111
- - `POST /api/:collectionName:update`
112
- - `POST /api/:collectionName:destroy`
101
+ | Endpoint | Description |
102
+ |----------|-------------|
103
+ | `POST /api/external-mssql:testConnection` | Test MSSQL connection |
104
+ | `GET /api/dataSources.collections:list` | List loaded collections |
105
+ | Standard CRUD via data source routing | `list`, `get`, `create`, `update`, `destroy` |
113
106
 
114
107
  ## Requirements
115
108
 
116
- - NocoBase >= 1.0.0
109
+ - NocoBase >= 2.0.0
117
110
  - Microsoft SQL Server 2012 or later
118
111
  - Node.js >= 18
119
112
 
@@ -121,12 +114,12 @@ Standard NocoBase data source collection operations are supported:
121
114
 
122
115
  ```bash
123
116
  # From tgz file
124
- yarn pm add ./path/to/gemvn90-plugin-data-source-mssql-x.x.x.tgz
117
+ yarn pm add ./plugin-data-source-mssql-2.0.0.tgz
125
118
 
126
- # Then enable the plugin
127
- yarn pm enable @gemvn90/plugin-data-source-mssql
119
+ # Enable the plugin
120
+ yarn pm enable plugin-data-source-mssql
128
121
  ```
129
122
 
130
123
  ## License
131
124
 
132
- AGPL-3.0 / NocoBase Commercial License
125
+ MIT
@@ -206,8 +206,8 @@ class MssqlExternalDataSource extends import_data_source_manager.SequelizeDataSo
206
206
  return obj.map((item) => transformDatesInObject(item, Sq));
207
207
  }
208
208
  const result = {};
209
- for (const [key, value] of Object.entries(obj)) {
210
- result[key] = transformDatesInObject(value, Sq);
209
+ for (const key of Reflect.ownKeys(obj)) {
210
+ result[key] = transformDatesInObject(obj[key], Sq);
211
211
  }
212
212
  return result;
213
213
  };
package/package.json CHANGED
@@ -3,9 +3,9 @@
3
3
  "displayName": "Data source: MSSQL",
4
4
  "displayName.ru-RU": "ะ˜ัั‚ะพั‡ะฝะธะบ ะดะฐะฝะฝั‹ั…: MSSQL",
5
5
  "displayName.zh-CN": "ๆ•ฐๆฎๆบ๏ผšMSSQL",
6
- "version": "1.9.48",
6
+ "version": "2.0.0",
7
7
  "description": "External MSSQL data source support for NocoBase.",
8
- "license": "AGPL-3.0",
8
+ "license": "MIT",
9
9
  "main": "./dist/server/index.js",
10
10
  "scripts": {
11
11
  "postbuild": "node ./scripts/copy-tedious.js",