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
|
-
#
|
|
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
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
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
|
-
- **
|
|
15
|
-
- **Selective Loading**: Choose specific tables to import
|
|
16
|
-
- **
|
|
17
|
-
- **Primary Key Detection**:
|
|
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 |
|
|
43
|
-
|
|
44
|
-
| `int`, `bigint`, `smallint`, `tinyint` | integer |
|
|
45
|
-
| `decimal`, `numeric`, `money` | decimal | |
|
|
46
|
-
| `float`, `real` |
|
|
47
|
-
| `varchar`, `nvarchar`, `char`, `nchar` | string |
|
|
48
|
-
| `text`, `ntext` | text |
|
|
49
|
-
| `bit` | boolean |
|
|
50
|
-
| `date` |
|
|
51
|
-
| `time` | time |
|
|
52
|
-
| `datetime`, `datetime2`, `smalldatetime` |
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
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
|
-
-
|
|
59
|
-
-
|
|
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
|
-
##
|
|
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
|
-
|
|
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 >=
|
|
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 ./
|
|
117
|
+
yarn pm add ./plugin-data-source-mssql-2.0.0.tgz
|
|
125
118
|
|
|
126
|
-
#
|
|
127
|
-
yarn pm enable
|
|
119
|
+
# Enable the plugin
|
|
120
|
+
yarn pm enable plugin-data-source-mssql
|
|
128
121
|
```
|
|
129
122
|
|
|
130
123
|
## License
|
|
131
124
|
|
|
132
|
-
|
|
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
|
|
210
|
-
result[key] = transformDatesInObject(
|
|
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": "
|
|
6
|
+
"version": "2.0.0",
|
|
7
7
|
"description": "External MSSQL data source support for NocoBase.",
|
|
8
|
-
"license": "
|
|
8
|
+
"license": "MIT",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"postbuild": "node ./scripts/copy-tedious.js",
|