@slickgrid-universal/sql 0.0.1 → 10.4.1
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 +11 -39
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/index.d.ts +4 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +4 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/sqlResult.interface.d.ts +6 -0
- package/dist/interfaces/sqlResult.interface.d.ts.map +1 -0
- package/dist/interfaces/sqlResult.interface.js +2 -0
- package/dist/interfaces/sqlResult.interface.js.map +1 -0
- package/dist/interfaces/sqlServiceApi.interface.d.ts +22 -0
- package/dist/interfaces/sqlServiceApi.interface.d.ts.map +1 -0
- package/dist/interfaces/sqlServiceApi.interface.js +2 -0
- package/dist/interfaces/sqlServiceApi.interface.js.map +1 -0
- package/dist/interfaces/sqlServiceOption.interface.d.ts +54 -0
- package/dist/interfaces/sqlServiceOption.interface.d.ts.map +1 -0
- package/dist/interfaces/sqlServiceOption.interface.js +2 -0
- package/dist/interfaces/sqlServiceOption.interface.js.map +1 -0
- package/dist/services/sql.service.d.ts +69 -0
- package/dist/services/sql.service.d.ts.map +1 -0
- package/dist/services/sql.service.js +600 -0
- package/dist/services/sql.service.js.map +1 -0
- package/package.json +44 -7
- package/src/index.ts +2 -0
- package/src/interfaces/index.ts +3 -0
- package/src/interfaces/sqlResult.interface.ts +6 -0
- package/src/interfaces/sqlServiceApi.interface.ts +27 -0
- package/src/interfaces/sqlServiceOption.interface.ts +61 -0
- package/src/services/__tests__/sql.service.spec.ts +1819 -0
- package/src/services/sql.service.ts +691 -0
package/package.json
CHANGED
|
@@ -1,10 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slickgrid-universal/sql",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
3
|
+
"version": "10.4.1",
|
|
4
|
+
"description": "SlickGrid Universal SQL Backend Service (implements BackendService for SQL)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"/dist",
|
|
20
|
+
"/src"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "pnpm run clean && tsc",
|
|
24
|
+
"build:incremental": "tsc --incremental --declaration",
|
|
25
|
+
"clean": "remove dist tsconfig.tsbuildinfo",
|
|
26
|
+
"dev": "pnpm build:incremental"
|
|
27
|
+
},
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"author": "Ghislain B.",
|
|
30
|
+
"homepage": "https://github.com/ghiscoding/slickgrid-universal",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/ghiscoding/slickgrid-universal.git",
|
|
34
|
+
"directory": "packages/sql"
|
|
35
|
+
},
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/ghiscoding/slickgrid-universal/issues"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@slickgrid-universal/common": "10.4.0",
|
|
41
|
+
"@slickgrid-universal/utils": "10.3.0"
|
|
42
|
+
},
|
|
43
|
+
"funding": {
|
|
44
|
+
"type": "ko_fi",
|
|
45
|
+
"url": "https://ko-fi.com/ghiscoding"
|
|
46
|
+
}
|
|
10
47
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BackendServiceApi, Observable } from '@slickgrid-universal/common';
|
|
2
|
+
import type { SqlService } from '../services/sql.service.js';
|
|
3
|
+
import type { SqlResult } from './sqlResult.interface.js';
|
|
4
|
+
import type { SqlServiceOption } from './sqlServiceOption.interface.js';
|
|
5
|
+
|
|
6
|
+
export interface SqlServiceApi<T = any> extends BackendServiceApi {
|
|
7
|
+
/** Backend Service Options */
|
|
8
|
+
options: SqlServiceOption;
|
|
9
|
+
|
|
10
|
+
/** Backend Service instance */
|
|
11
|
+
service: SqlService;
|
|
12
|
+
|
|
13
|
+
/** On init (or on page load), what action to perform? */
|
|
14
|
+
onInit?: (query: string) => Promise<SqlResult<T>> | Observable<SqlResult<T>>;
|
|
15
|
+
|
|
16
|
+
/** On Processing, we get the query back from the service, and we need to provide a Promise/Observable. For example: this.http.get(mySqlUrl) */
|
|
17
|
+
process: (query: string) => Promise<SqlResult<T>> | Observable<SqlResult<T>>;
|
|
18
|
+
|
|
19
|
+
/** After executing the query, what action to perform? For example, stop the spinner */
|
|
20
|
+
postProcess?: (response: SqlResult<T>) => void;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* INTERNAL USAGE ONLY by Slickgrid-Universal
|
|
24
|
+
* This internal process will be run just before postProcess and is meant to refresh the Dataset & Pagination after a SQL call
|
|
25
|
+
*/
|
|
26
|
+
internalPostProcess?: (result: SqlResult<T>) => void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { InfiniteScrollOption, SortDirection } from '@slickgrid-universal/common';
|
|
2
|
+
|
|
3
|
+
export type IdentifierEscapeStyle = 'doubleQuote' | 'backtick' | 'bracket';
|
|
4
|
+
|
|
5
|
+
export interface SqlServiceOption {
|
|
6
|
+
/** Name of the SQL table to query (required) */
|
|
7
|
+
tableName: string;
|
|
8
|
+
/** Optional: dataset/schema/database name for multi-database support */
|
|
9
|
+
datasetName?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Controls how SQL identifiers (table/schema) are escaped in generated queries.
|
|
12
|
+
* - 'doubleQuote': "identifier" (PostgreSQL, ANSI SQL, default)
|
|
13
|
+
* - 'backtick': `identifier` (MySQL)
|
|
14
|
+
* - 'bracket': [identifier] (MSSQL)
|
|
15
|
+
*/
|
|
16
|
+
identifierEscapeStyle?: IdentifierEscapeStyle;
|
|
17
|
+
/** Filtering options for WHERE clause */
|
|
18
|
+
filteringOptions?: SqlFilteringOption[];
|
|
19
|
+
/** Sorting options for ORDER BY clause */
|
|
20
|
+
sortingOptions?: SqlSortingOption[];
|
|
21
|
+
/** Pagination options (pageNumber, pageSize) */
|
|
22
|
+
paginationOptions?: SqlPaginationOption;
|
|
23
|
+
/** Any extra query arguments (for advanced use) */
|
|
24
|
+
extraQueryArguments?: SqlQueryArgument[];
|
|
25
|
+
/** Enable infinite scroll mode (disables LIMIT/OFFSET pagination) */
|
|
26
|
+
infiniteScroll?: boolean | InfiniteScrollOption;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Name of the total count column returned by the SQL query (default: 'totalCount').
|
|
30
|
+
* Use this to avoid conflicts or customize the count field name in the result set.
|
|
31
|
+
*/
|
|
32
|
+
totalCountField?: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* When false, searchTerms may be manipulated to be functional with certain filters eg: string only filters.
|
|
36
|
+
* When true, JSON.stringify is used on the searchTerms and used in the query "as-is". It is then the responsibility of the developer to sanitise the `searchTerms` property if necessary.
|
|
37
|
+
*/
|
|
38
|
+
useVerbatimSearchTerms?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface SqlFilteringOption {
|
|
42
|
+
field: string;
|
|
43
|
+
operator: string;
|
|
44
|
+
value: any;
|
|
45
|
+
type?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface SqlSortingOption {
|
|
49
|
+
field: string;
|
|
50
|
+
direction: SortDirection;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface SqlPaginationOption {
|
|
54
|
+
pageNumber: number;
|
|
55
|
+
pageSize: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface SqlQueryArgument {
|
|
59
|
+
field: string;
|
|
60
|
+
value: any;
|
|
61
|
+
}
|