@memberjunction/global 2.111.0 → 2.112.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/dist/Core.d.ts +29 -0
- package/dist/Core.d.ts.map +1 -0
- package/dist/Core.js +58 -0
- package/dist/Core.js.map +1 -0
- package/dist/generic/QueryCache.d.ts +85 -0
- package/dist/generic/QueryCache.d.ts.map +1 -0
- package/dist/generic/QueryCache.js +198 -0
- package/dist/generic/QueryCache.js.map +1 -0
- package/dist/generic/QueryCacheConfig.d.ts +72 -0
- package/dist/generic/QueryCacheConfig.d.ts.map +1 -0
- package/dist/generic/QueryCacheConfig.js +3 -0
- package/dist/generic/QueryCacheConfig.js.map +1 -0
- package/dist/generic/applicationInfo.d.ts +138 -0
- package/dist/generic/applicationInfo.d.ts.map +1 -0
- package/dist/generic/applicationInfo.js +177 -0
- package/dist/generic/applicationInfo.js.map +1 -0
- package/dist/generic/authEvaluator.d.ts +25 -0
- package/dist/generic/authEvaluator.d.ts.map +1 -0
- package/dist/generic/authEvaluator.js +49 -0
- package/dist/generic/authEvaluator.js.map +1 -0
- package/dist/generic/authTypes.d.ts +193 -0
- package/dist/generic/authTypes.d.ts.map +1 -0
- package/dist/generic/authTypes.js +19 -0
- package/dist/generic/authTypes.js.map +1 -0
- package/dist/generic/baseEngine.d.ts +260 -0
- package/dist/generic/baseEngine.d.ts.map +1 -0
- package/dist/generic/baseEngine.js +510 -0
- package/dist/generic/baseEngine.js.map +1 -0
- package/dist/generic/baseEntity.d.ts +691 -0
- package/dist/generic/baseEntity.d.ts.map +1 -0
- package/dist/generic/baseEntity.js +1688 -0
- package/dist/generic/baseEntity.js.map +1 -0
- package/dist/generic/baseInfo.d.ts +24 -0
- package/dist/generic/baseInfo.d.ts.map +1 -0
- package/dist/generic/baseInfo.js +53 -0
- package/dist/generic/baseInfo.js.map +1 -0
- package/dist/generic/compositeKey.d.ts +206 -0
- package/dist/generic/compositeKey.d.ts.map +1 -0
- package/dist/generic/compositeKey.js +412 -0
- package/dist/generic/compositeKey.js.map +1 -0
- package/dist/generic/databaseProviderBase.d.ts +46 -0
- package/dist/generic/databaseProviderBase.d.ts.map +1 -0
- package/dist/generic/databaseProviderBase.js +14 -0
- package/dist/generic/databaseProviderBase.js.map +1 -0
- package/dist/generic/entityInfo.d.ts +983 -0
- package/dist/generic/entityInfo.d.ts.map +1 -0
- package/dist/generic/entityInfo.js +1401 -0
- package/dist/generic/entityInfo.js.map +1 -0
- package/dist/generic/explorerNavigationItem.d.ts +20 -0
- package/dist/generic/explorerNavigationItem.d.ts.map +1 -0
- package/dist/generic/explorerNavigationItem.js +29 -0
- package/dist/generic/explorerNavigationItem.js.map +1 -0
- package/dist/generic/interfaces.d.ts +610 -0
- package/dist/generic/interfaces.d.ts.map +1 -0
- package/dist/generic/interfaces.js +211 -0
- package/dist/generic/interfaces.js.map +1 -0
- package/dist/generic/libraryInfo.d.ts +40 -0
- package/dist/generic/libraryInfo.d.ts.map +1 -0
- package/dist/generic/libraryInfo.js +56 -0
- package/dist/generic/libraryInfo.js.map +1 -0
- package/dist/generic/logging.d.ts +179 -0
- package/dist/generic/logging.d.ts.map +1 -0
- package/dist/generic/logging.js +382 -0
- package/dist/generic/logging.js.map +1 -0
- package/dist/generic/metadata.d.ts +305 -0
- package/dist/generic/metadata.d.ts.map +1 -0
- package/dist/generic/metadata.js +454 -0
- package/dist/generic/metadata.js.map +1 -0
- package/dist/generic/metadataUtil.d.ts +8 -0
- package/dist/generic/metadataUtil.d.ts.map +1 -0
- package/dist/generic/metadataUtil.js +36 -0
- package/dist/generic/metadataUtil.js.map +1 -0
- package/dist/generic/providerBase.d.ts +546 -0
- package/dist/generic/providerBase.d.ts.map +1 -0
- package/dist/generic/providerBase.js +999 -0
- package/dist/generic/providerBase.js.map +1 -0
- package/dist/generic/queryInfo.d.ts +460 -0
- package/dist/generic/queryInfo.d.ts.map +1 -0
- package/dist/generic/queryInfo.js +633 -0
- package/dist/generic/queryInfo.js.map +1 -0
- package/dist/generic/querySQLFilters.d.ts +54 -0
- package/dist/generic/querySQLFilters.d.ts.map +1 -0
- package/dist/generic/querySQLFilters.js +84 -0
- package/dist/generic/querySQLFilters.js.map +1 -0
- package/dist/generic/runQuery.d.ts +96 -0
- package/dist/generic/runQuery.d.ts.map +1 -0
- package/dist/generic/runQuery.js +66 -0
- package/dist/generic/runQuery.js.map +1 -0
- package/dist/generic/runQuerySQLFilterImplementations.d.ts +51 -0
- package/dist/generic/runQuerySQLFilterImplementations.d.ts.map +1 -0
- package/dist/generic/runQuerySQLFilterImplementations.js +238 -0
- package/dist/generic/runQuerySQLFilterImplementations.js.map +1 -0
- package/dist/generic/runReport.d.ts +25 -0
- package/dist/generic/runReport.d.ts.map +1 -0
- package/dist/generic/runReport.js +42 -0
- package/dist/generic/runReport.js.map +1 -0
- package/dist/generic/securityInfo.d.ts +355 -0
- package/dist/generic/securityInfo.d.ts.map +1 -0
- package/dist/generic/securityInfo.js +425 -0
- package/dist/generic/securityInfo.js.map +1 -0
- package/dist/generic/transactionGroup.d.ts +184 -0
- package/dist/generic/transactionGroup.d.ts.map +1 -0
- package/dist/generic/transactionGroup.js +357 -0
- package/dist/generic/transactionGroup.js.map +1 -0
- package/dist/generic/util.d.ts +81 -0
- package/dist/generic/util.d.ts.map +1 -0
- package/dist/generic/util.js +301 -0
- package/dist/generic/util.js.map +1 -0
- package/dist/views/runView.d.ts +150 -0
- package/dist/views/runView.d.ts.map +1 -0
- package/dist/views/runView.js +100 -0
- package/dist/views/runView.js.map +1 -0
- package/dist/views/viewInfo.d.ts +121 -0
- package/dist/views/viewInfo.d.ts.map +1 -0
- package/dist/views/viewInfo.js +182 -0
- package/dist/views/viewInfo.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array of all available SQL filters for parameterized queries.
|
|
3
|
+
* These filters ensure safe SQL generation and prevent SQL injection attacks.
|
|
4
|
+
* Implementation functions are added separately to keep this definition token-efficient for AI prompts.
|
|
5
|
+
*/
|
|
6
|
+
export declare const RUN_QUERY_SQL_FILTERS: RunQuerySQLFilter[];
|
|
7
|
+
/**
|
|
8
|
+
* Gets a SQL filter definition by name
|
|
9
|
+
* @param filterName The name of the filter to retrieve
|
|
10
|
+
* @returns The filter definition or undefined if not found
|
|
11
|
+
*/
|
|
12
|
+
export declare function getRunQuerySQLFilter(filterName: string): RunQuerySQLFilter | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Gets an array of all SQL filter names
|
|
15
|
+
* @returns Array of filter names
|
|
16
|
+
*/
|
|
17
|
+
export declare function getRunQuerySQLFilterNames(): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Represents a custom SQL filter that can be used in Nunjucks templates
|
|
20
|
+
* for safe SQL query construction in RunQuery operations
|
|
21
|
+
*/
|
|
22
|
+
export interface RunQuerySQLFilter {
|
|
23
|
+
/**
|
|
24
|
+
* The name of the filter as used in templates (e.g., "sqlString")
|
|
25
|
+
*/
|
|
26
|
+
name: string;
|
|
27
|
+
/**
|
|
28
|
+
* Human-readable description of what the filter does
|
|
29
|
+
*/
|
|
30
|
+
description: string;
|
|
31
|
+
/**
|
|
32
|
+
* Example usage showing the filter syntax in a Nunjucks template
|
|
33
|
+
*/
|
|
34
|
+
exampleSyntax: string;
|
|
35
|
+
/**
|
|
36
|
+
* Example input value
|
|
37
|
+
*/
|
|
38
|
+
exampleInput: any;
|
|
39
|
+
/**
|
|
40
|
+
* Example output after filtering
|
|
41
|
+
*/
|
|
42
|
+
exampleOutput: string;
|
|
43
|
+
/**
|
|
44
|
+
* Additional notes or warnings about using this filter
|
|
45
|
+
*/
|
|
46
|
+
notes?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Optional implementation function for the filter.
|
|
49
|
+
* When provided, this function will be called to apply the filter.
|
|
50
|
+
* This is separate from the definition to keep AI prompts token-efficient.
|
|
51
|
+
*/
|
|
52
|
+
implementation?: (value: any) => any;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=querySQLFilters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"querySQLFilters.d.ts","sourceRoot":"","sources":["../../src/generic/querySQLFilters.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,iBAAiB,EAyDpD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAEtF;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,EAAE,CAEpD;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,YAAY,EAAE,GAAG,CAAC;IAElB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;CACxC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRunQuerySQLFilterNames = exports.getRunQuerySQLFilter = exports.RUN_QUERY_SQL_FILTERS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Array of all available SQL filters for parameterized queries.
|
|
6
|
+
* These filters ensure safe SQL generation and prevent SQL injection attacks.
|
|
7
|
+
* Implementation functions are added separately to keep this definition token-efficient for AI prompts.
|
|
8
|
+
*/
|
|
9
|
+
exports.RUN_QUERY_SQL_FILTERS = [
|
|
10
|
+
{
|
|
11
|
+
name: 'sqlString',
|
|
12
|
+
description: 'Safely escapes a string value for SQL queries by doubling single quotes and wrapping in quotes',
|
|
13
|
+
exampleSyntax: "WHERE Name = {{ userName | sqlString }}",
|
|
14
|
+
exampleInput: "O'Brien",
|
|
15
|
+
exampleOutput: "'O''Brien'",
|
|
16
|
+
notes: 'Returns NULL for null/undefined values. Always use this filter for string parameters in WHERE clauses.'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'sqlNumber',
|
|
20
|
+
description: 'Validates and formats a numeric value for SQL queries',
|
|
21
|
+
exampleSyntax: "WHERE Age > {{ minAge | sqlNumber }}",
|
|
22
|
+
exampleInput: "25",
|
|
23
|
+
exampleOutput: "25",
|
|
24
|
+
notes: 'Throws an error if the value cannot be converted to a valid number. Handles both integers and decimals.'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'sqlDate',
|
|
28
|
+
description: 'Formats a date value for SQL queries in ISO 8601 format',
|
|
29
|
+
exampleSyntax: "WHERE CreatedDate >= {{ startDate | sqlDate }}",
|
|
30
|
+
exampleInput: new Date('2024-01-15'),
|
|
31
|
+
exampleOutput: "'2024-01-15T00:00:00.000Z'",
|
|
32
|
+
notes: 'Accepts Date objects or parseable date strings. Returns NULL for null/undefined values.'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'sqlBoolean',
|
|
36
|
+
description: 'Converts a boolean value to SQL bit representation (1 or 0)',
|
|
37
|
+
exampleSyntax: "WHERE IsActive = {{ isActive | sqlBoolean }}",
|
|
38
|
+
exampleInput: true,
|
|
39
|
+
exampleOutput: "1",
|
|
40
|
+
notes: 'Truthy values become 1, falsy values become 0. Useful for SQL Server bit columns.'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'sqlIdentifier',
|
|
44
|
+
description: 'Safely formats a SQL identifier (table/column name) by wrapping in square brackets',
|
|
45
|
+
exampleSyntax: "SELECT * FROM {{ tableName | sqlIdentifier }}",
|
|
46
|
+
exampleInput: "UserAccounts",
|
|
47
|
+
exampleOutput: "[UserAccounts]",
|
|
48
|
+
notes: 'Only allows alphanumeric characters and underscores. Throws error for invalid identifiers to prevent SQL injection.'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'sqlIn',
|
|
52
|
+
description: 'Formats an array of values for use with SQL IN operator',
|
|
53
|
+
exampleSyntax: "WHERE Status IN {{ statusList | sqlIn }}",
|
|
54
|
+
exampleInput: ['Active', 'Pending', 'Review'],
|
|
55
|
+
exampleOutput: "('Active', 'Pending', 'Review')",
|
|
56
|
+
notes: 'Automatically escapes string values. Returns (NULL) for empty arrays which will match no records. Supports mixed types (strings, numbers, nulls).'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'sqlNoKeywordsExpression',
|
|
60
|
+
description: 'Validates and formats a SQL expression by ensuring it contains no dangerous keywords',
|
|
61
|
+
exampleSyntax: "ORDER BY {{ orderClause | sqlNoKeywordsExpression }}",
|
|
62
|
+
exampleInput: "Revenue DESC, CreatedDate ASC",
|
|
63
|
+
exampleOutput: "Revenue DESC, CreatedDate ASC",
|
|
64
|
+
notes: 'Blocks dangerous SQL keywords like DROP, DELETE, INSERT, UPDATE, EXEC, etc. Allows field names, ASC/DESC, basic functions, and arithmetic operators. Throws error if dangerous keywords detected.'
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
/**
|
|
68
|
+
* Gets a SQL filter definition by name
|
|
69
|
+
* @param filterName The name of the filter to retrieve
|
|
70
|
+
* @returns The filter definition or undefined if not found
|
|
71
|
+
*/
|
|
72
|
+
function getRunQuerySQLFilter(filterName) {
|
|
73
|
+
return exports.RUN_QUERY_SQL_FILTERS.find(f => f.name === filterName);
|
|
74
|
+
}
|
|
75
|
+
exports.getRunQuerySQLFilter = getRunQuerySQLFilter;
|
|
76
|
+
/**
|
|
77
|
+
* Gets an array of all SQL filter names
|
|
78
|
+
* @returns Array of filter names
|
|
79
|
+
*/
|
|
80
|
+
function getRunQuerySQLFilterNames() {
|
|
81
|
+
return exports.RUN_QUERY_SQL_FILTERS.map(f => f.name);
|
|
82
|
+
}
|
|
83
|
+
exports.getRunQuerySQLFilterNames = getRunQuerySQLFilterNames;
|
|
84
|
+
//# sourceMappingURL=querySQLFilters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"querySQLFilters.js","sourceRoot":"","sources":["../../src/generic/querySQLFilters.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,qBAAqB,GAAwB;IACtD;QACI,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,gGAAgG;QAC7G,aAAa,EAAE,yCAAyC;QACxD,YAAY,EAAE,SAAS;QACvB,aAAa,EAAE,YAAY;QAC3B,KAAK,EAAE,wGAAwG;KAClH;IACD;QACI,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,uDAAuD;QACpE,aAAa,EAAE,sCAAsC;QACrD,YAAY,EAAE,IAAI;QAClB,aAAa,EAAE,IAAI;QACnB,KAAK,EAAE,yGAAyG;KACnH;IACD;QACI,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,yDAAyD;QACtE,aAAa,EAAE,gDAAgD;QAC/D,YAAY,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC;QACpC,aAAa,EAAE,4BAA4B;QAC3C,KAAK,EAAE,yFAAyF;KACnG;IACD;QACI,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,6DAA6D;QAC1E,aAAa,EAAE,8CAA8C;QAC7D,YAAY,EAAE,IAAI;QAClB,aAAa,EAAE,GAAG;QAClB,KAAK,EAAE,mFAAmF;KAC7F;IACD;QACI,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,oFAAoF;QACjG,aAAa,EAAE,+CAA+C;QAC9D,YAAY,EAAE,cAAc;QAC5B,aAAa,EAAE,gBAAgB;QAC/B,KAAK,EAAE,qHAAqH;KAC/H;IACD;QACI,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,yDAAyD;QACtE,aAAa,EAAE,0CAA0C;QACzD,YAAY,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;QAC7C,aAAa,EAAE,iCAAiC;QAChD,KAAK,EAAE,mJAAmJ;KAC7J;IACD;QACI,IAAI,EAAE,yBAAyB;QAC/B,WAAW,EAAE,sFAAsF;QACnG,aAAa,EAAE,sDAAsD;QACrE,YAAY,EAAE,+BAA+B;QAC7C,aAAa,EAAE,+BAA+B;QAC9C,KAAK,EAAE,mMAAmM;KAC7M;CACJ,CAAC;AAEF;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,UAAkB;IACnD,OAAO,6BAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;AAClE,CAAC;AAFD,oDAEC;AAED;;;GAGG;AACH,SAAgB,yBAAyB;IACrC,OAAO,6BAAqB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC;AAFD,8DAEC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { IRunQueryProvider, RunQueryResult } from './interfaces';
|
|
2
|
+
import { UserInfo } from './securityInfo';
|
|
3
|
+
/**
|
|
4
|
+
* Parameters for running a query, must provide either QueryID or QueryName. If both are provided QueryName is ignored.
|
|
5
|
+
* QueryName and CategoryPath together uniquely identify a Query, just as QueryID does.
|
|
6
|
+
* CategoryPath supports hierarchical paths (e.g., "/MJ/AI/Agents/") for navigation through nested categories.
|
|
7
|
+
*/
|
|
8
|
+
export type RunQueryParams = {
|
|
9
|
+
/**
|
|
10
|
+
* Provide either QueryID or QueryName. If both are provided QueryName is ignored
|
|
11
|
+
*/
|
|
12
|
+
QueryID?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Provide either QueryID or QueryName. If both are provided QueryName is ignored
|
|
15
|
+
*/
|
|
16
|
+
QueryName?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional, if provided, the query to be run will be selected to match the specified Category by hierarchical path
|
|
19
|
+
* (e.g., "/MJ/AI/Agents/") or simple category name for backward compatibility
|
|
20
|
+
*/
|
|
21
|
+
CategoryPath?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional, if provided, the query to be run will be selected to match the specified CategoryID
|
|
24
|
+
*/
|
|
25
|
+
CategoryID?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Optional parameters to pass to parameterized queries that use Nunjucks templates.
|
|
28
|
+
* Key-value pairs where keys match parameter names defined in QueryParameter metadata.
|
|
29
|
+
* Values will be validated and type-converted based on parameter definitions.
|
|
30
|
+
*/
|
|
31
|
+
Parameters?: Record<string, any>;
|
|
32
|
+
/**
|
|
33
|
+
* Optional maximum number of rows to return from the query.
|
|
34
|
+
* If not provided, all rows will be returned.
|
|
35
|
+
*/
|
|
36
|
+
MaxRows?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Optional - if provided, this value will be used to offset the rows returned.
|
|
39
|
+
* Used for pagination in conjunction with MaxRows.
|
|
40
|
+
*/
|
|
41
|
+
StartRow?: number;
|
|
42
|
+
/**
|
|
43
|
+
* optional - if set to true, the query run will ALWAYS be logged to the Audit Log,
|
|
44
|
+
* regardless of the query's property settings for logging query runs.
|
|
45
|
+
*/
|
|
46
|
+
ForceAuditLog?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* optional - if provided and either ForceAuditLog is set, or the query's property
|
|
49
|
+
* settings for logging query runs are set to true, this will be used as the Audit Log Description.
|
|
50
|
+
*/
|
|
51
|
+
AuditLogDescription?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Class used to run a query and return the results.
|
|
55
|
+
* Provides an abstraction layer for executing saved queries with proper security checks.
|
|
56
|
+
* Supports both instance-based and static provider patterns.
|
|
57
|
+
*/
|
|
58
|
+
export declare class RunQuery {
|
|
59
|
+
private _provider;
|
|
60
|
+
/**
|
|
61
|
+
* Optionally, you can pass in a provider to use for running the query. If not provided, the static provider will be used.
|
|
62
|
+
*/
|
|
63
|
+
constructor(provider?: IRunQueryProvider | null);
|
|
64
|
+
/**
|
|
65
|
+
* Gets the query provider to use for execution.
|
|
66
|
+
* Returns the instance provider if set, otherwise falls back to the static provider.
|
|
67
|
+
* @returns The query provider instance
|
|
68
|
+
*/
|
|
69
|
+
get ProviderToUse(): IRunQueryProvider;
|
|
70
|
+
/**
|
|
71
|
+
* Executes a saved query and returns the results.
|
|
72
|
+
* The query must exist in the system and the user must have permission to execute it.
|
|
73
|
+
* Queries can be identified by QueryID or by QueryName + CategoryPath combination.
|
|
74
|
+
* CategoryPath supports hierarchical navigation (e.g., "/MJ/AI/Agents/") and falls back to simple name matching.
|
|
75
|
+
* @param params - Parameters including query ID or name with optional CategoryPath for disambiguation
|
|
76
|
+
* @param contextUser - Optional user context for permissions (mainly used server-side)
|
|
77
|
+
* @returns Query results including data rows and execution metadata
|
|
78
|
+
*/
|
|
79
|
+
RunQuery(params: RunQueryParams, contextUser?: UserInfo): Promise<RunQueryResult>;
|
|
80
|
+
private static _globalProviderKey;
|
|
81
|
+
/**
|
|
82
|
+
* Gets the static query provider instance.
|
|
83
|
+
* Used when no instance-specific provider is configured.
|
|
84
|
+
* @returns The global query provider
|
|
85
|
+
* @throws Error if global object store is not available
|
|
86
|
+
*/
|
|
87
|
+
static get Provider(): IRunQueryProvider;
|
|
88
|
+
/**
|
|
89
|
+
* Sets the static query provider instance.
|
|
90
|
+
* This provider will be used by all RunQuery instances that don't have their own provider.
|
|
91
|
+
* @param value - The query provider to set globally
|
|
92
|
+
* @throws Error if global object store is not available
|
|
93
|
+
*/
|
|
94
|
+
static set Provider(value: IRunQueryProvider);
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=runQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runQuery.d.ts","sourceRoot":"","sources":["../../src/generic/runQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF;;;;GAIG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,SAAS,CAA2B;IAC5C;;OAEG;gBACS,QAAQ,GAAE,iBAAiB,GAAG,IAAW;IAIrD;;;;OAIG;IACH,IAAW,aAAa,IAAI,iBAAiB,CAE5C;IACD;;;;;;;;OAQG;IACU,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC;IAI9F,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAiC;IAClE;;;;;OAKG;IACH,WAAkB,QAAQ,IAAI,iBAAiB,CAI9C;IACD;;;;;OAKG;IACH,WAAkB,QAAQ,CAAC,KAAK,EAAE,iBAAiB,EAIlD;CACF"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RunQuery = void 0;
|
|
4
|
+
const Global_1 = require("../Global");
|
|
5
|
+
/**
|
|
6
|
+
* Class used to run a query and return the results.
|
|
7
|
+
* Provides an abstraction layer for executing saved queries with proper security checks.
|
|
8
|
+
* Supports both instance-based and static provider patterns.
|
|
9
|
+
*/
|
|
10
|
+
class RunQuery {
|
|
11
|
+
/**
|
|
12
|
+
* Optionally, you can pass in a provider to use for running the query. If not provided, the static provider will be used.
|
|
13
|
+
*/
|
|
14
|
+
constructor(provider = null) {
|
|
15
|
+
this._provider = provider;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Gets the query provider to use for execution.
|
|
19
|
+
* Returns the instance provider if set, otherwise falls back to the static provider.
|
|
20
|
+
* @returns The query provider instance
|
|
21
|
+
*/
|
|
22
|
+
get ProviderToUse() {
|
|
23
|
+
return this._provider || RunQuery.Provider;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Executes a saved query and returns the results.
|
|
27
|
+
* The query must exist in the system and the user must have permission to execute it.
|
|
28
|
+
* Queries can be identified by QueryID or by QueryName + CategoryPath combination.
|
|
29
|
+
* CategoryPath supports hierarchical navigation (e.g., "/MJ/AI/Agents/") and falls back to simple name matching.
|
|
30
|
+
* @param params - Parameters including query ID or name with optional CategoryPath for disambiguation
|
|
31
|
+
* @param contextUser - Optional user context for permissions (mainly used server-side)
|
|
32
|
+
* @returns Query results including data rows and execution metadata
|
|
33
|
+
*/
|
|
34
|
+
async RunQuery(params, contextUser) {
|
|
35
|
+
return this.ProviderToUse.RunQuery(params, contextUser);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Gets the static query provider instance.
|
|
39
|
+
* Used when no instance-specific provider is configured.
|
|
40
|
+
* @returns The global query provider
|
|
41
|
+
* @throws Error if global object store is not available
|
|
42
|
+
*/
|
|
43
|
+
static get Provider() {
|
|
44
|
+
const g = Global_1.MJGlobal.Instance.GetGlobalObjectStore();
|
|
45
|
+
if (g)
|
|
46
|
+
return g[RunQuery._globalProviderKey];
|
|
47
|
+
else
|
|
48
|
+
throw new Error('No global object store, so we cant get the static provider');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sets the static query provider instance.
|
|
52
|
+
* This provider will be used by all RunQuery instances that don't have their own provider.
|
|
53
|
+
* @param value - The query provider to set globally
|
|
54
|
+
* @throws Error if global object store is not available
|
|
55
|
+
*/
|
|
56
|
+
static set Provider(value) {
|
|
57
|
+
const g = Global_1.MJGlobal.Instance.GetGlobalObjectStore();
|
|
58
|
+
if (g)
|
|
59
|
+
g[RunQuery._globalProviderKey] = value;
|
|
60
|
+
else
|
|
61
|
+
throw new Error('No global object store, so we cant set the static provider');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.RunQuery = RunQuery;
|
|
65
|
+
RunQuery._globalProviderKey = 'MJ_RunQueryProvider';
|
|
66
|
+
//# sourceMappingURL=runQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runQuery.js","sourceRoot":"","sources":["../../src/generic/runQuery.ts"],"names":[],"mappings":";;;AAAA,sCAAqC;AAuDrC;;;;GAIG;AACH,MAAa,QAAQ;IAEnB;;OAEG;IACH,YAAY,WAAqC,IAAI;QACnD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,SAAS,IAAI,QAAQ,CAAC,QAAQ,CAAC;IAC7C,CAAC;IACD;;;;;;;;OAQG;IACI,KAAK,CAAC,QAAQ,CAAC,MAAsB,EAAE,WAAsB;QAClE,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC1D,CAAC;IAGD;;;;;OAKG;IACI,MAAM,KAAK,QAAQ;QACxB,MAAM,CAAC,GAAG,iBAAQ,CAAC,QAAQ,CAAC,oBAAoB,EAAE,CAAC;QACnD,IAAI,CAAC;YAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;;YACxC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACrF,CAAC;IACD;;;;;OAKG;IACI,MAAM,KAAK,QAAQ,CAAC,KAAwB;QACjD,MAAM,CAAC,GAAG,iBAAQ,CAAC,QAAQ,CAAC,oBAAoB,EAAE,CAAC;QACnD,IAAI,CAAC;YAAE,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,GAAG,KAAK,CAAC;;YACzC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACrF,CAAC;;AApDH,4BAqDC;AAvBgB,2BAAkB,GAAW,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview SQL Filter Implementations for RunQuery
|
|
3
|
+
*
|
|
4
|
+
* This module provides the actual implementation functions for RunQuery SQL filters.
|
|
5
|
+
* This is separate from the filter definitions to keep AI prompts token-efficient.
|
|
6
|
+
*
|
|
7
|
+
* @module @memberjunction/global/runQuerySQLFilterImplementations
|
|
8
|
+
*/
|
|
9
|
+
import { RunQuerySQLFilter } from './querySQLFilters';
|
|
10
|
+
/**
|
|
11
|
+
* Complete SQL filters with implementations attached.
|
|
12
|
+
* This is the array that should be used by the QueryParameterProcessor.
|
|
13
|
+
*/
|
|
14
|
+
export declare const RUN_QUERY_SQL_FILTERS_WITH_IMPLEMENTATIONS: RunQuerySQLFilter[];
|
|
15
|
+
/**
|
|
16
|
+
* Singleton class for managing RunQuery SQL filters with implementations
|
|
17
|
+
*/
|
|
18
|
+
export declare class RunQuerySQLFilterManager {
|
|
19
|
+
private static _instance;
|
|
20
|
+
private _filters;
|
|
21
|
+
private constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Gets the singleton instance
|
|
24
|
+
*/
|
|
25
|
+
static get Instance(): RunQuerySQLFilterManager;
|
|
26
|
+
/**
|
|
27
|
+
* Gets a filter by name
|
|
28
|
+
* @param name The filter name
|
|
29
|
+
* @returns The filter with implementation or undefined if not found
|
|
30
|
+
*/
|
|
31
|
+
getFilter(name: string): RunQuerySQLFilter | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Gets all available filter names
|
|
34
|
+
* @returns Array of filter names
|
|
35
|
+
*/
|
|
36
|
+
getFilterNames(): string[];
|
|
37
|
+
/**
|
|
38
|
+
* Gets all filters with implementations
|
|
39
|
+
* @returns Array of all filters
|
|
40
|
+
*/
|
|
41
|
+
getAllFilters(): RunQuerySQLFilter[];
|
|
42
|
+
/**
|
|
43
|
+
* Executes a filter function by name
|
|
44
|
+
* @param filterName The name of the filter to execute
|
|
45
|
+
* @param value The value to filter
|
|
46
|
+
* @returns The filtered result
|
|
47
|
+
* @throws Error if filter is not found or execution fails
|
|
48
|
+
*/
|
|
49
|
+
executeFilter(filterName: string, value: any): any;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=runQuerySQLFilterImplementations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runQuerySQLFilterImplementations.d.ts","sourceRoot":"","sources":["../../src/generic/runQuerySQLFilterImplementations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAyB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAgM7E;;;GAGG;AACH,eAAO,MAAM,0CAA0C,EAAE,iBAAiB,EAInE,CAAC;AAER;;GAEG;AACH,qBAAa,wBAAwB;IACjC,OAAO,CAAC,MAAM,CAAC,SAAS,CAA2B;IACnD,OAAO,CAAC,QAAQ,CAAiC;IAEjD,OAAO;IAUP;;OAEG;IACH,WAAkB,QAAQ,IAAI,wBAAwB,CAKrD;IAED;;;;OAIG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAI7D;;;OAGG;IACI,cAAc,IAAI,MAAM,EAAE;IAIjC;;;OAGG;IACI,aAAa,IAAI,iBAAiB,EAAE;IAI3C;;;;;;OAMG;IACI,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG;CAO5D"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview SQL Filter Implementations for RunQuery
|
|
4
|
+
*
|
|
5
|
+
* This module provides the actual implementation functions for RunQuery SQL filters.
|
|
6
|
+
* This is separate from the filter definitions to keep AI prompts token-efficient.
|
|
7
|
+
*
|
|
8
|
+
* @module @memberjunction/global/runQuerySQLFilterImplementations
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.RunQuerySQLFilterManager = exports.RUN_QUERY_SQL_FILTERS_WITH_IMPLEMENTATIONS = void 0;
|
|
12
|
+
const querySQLFilters_1 = require("./querySQLFilters");
|
|
13
|
+
/**
|
|
14
|
+
* Dangerous SQL keywords that should be blocked in expressions
|
|
15
|
+
*/
|
|
16
|
+
const DANGEROUS_SQL_KEYWORDS = [
|
|
17
|
+
// DDL (Data Definition Language) - Structure modification
|
|
18
|
+
'DROP', 'CREATE', 'ALTER', 'TRUNCATE', 'RENAME',
|
|
19
|
+
// DML (Data Manipulation Language) - Data modification
|
|
20
|
+
'INSERT', 'UPDATE', 'DELETE', 'MERGE', 'REPLACE',
|
|
21
|
+
// DCL (Data Control Language) - Permissions
|
|
22
|
+
'GRANT', 'REVOKE', 'DENY',
|
|
23
|
+
// Execution and procedures
|
|
24
|
+
'EXEC', 'EXECUTE', 'CALL', 'PROCEDURE', 'FUNCTION',
|
|
25
|
+
// Transaction control
|
|
26
|
+
'BEGIN', 'COMMIT', 'ROLLBACK', 'SAVEPOINT',
|
|
27
|
+
// Database/schema operations
|
|
28
|
+
'USE', 'DATABASE', 'SCHEMA',
|
|
29
|
+
// Conditional execution that could be dangerous
|
|
30
|
+
'IF', 'WHILE', 'LOOP', 'FOR', 'GOTO',
|
|
31
|
+
// System functions and variables
|
|
32
|
+
'SYSTEM', 'ADMIN', 'USER', 'SESSION', 'GLOBAL',
|
|
33
|
+
'SHOW', 'DESCRIBE', 'EXPLAIN',
|
|
34
|
+
// Union and set operations (can be used for injection)
|
|
35
|
+
'UNION', 'INTERSECT', 'EXCEPT',
|
|
36
|
+
// Subquery keywords (when used maliciously)
|
|
37
|
+
'EXISTS', 'ANY', 'ALL', 'SOME',
|
|
38
|
+
// Comment indicators (used in injection)
|
|
39
|
+
'--', '/*', '*/',
|
|
40
|
+
// String manipulation that could escape
|
|
41
|
+
'CHAR', 'ASCII', 'UNICODE',
|
|
42
|
+
// File operations
|
|
43
|
+
'BULK', 'OPENROWSET', 'OPENDATASOURCE', 'OPENQUERY',
|
|
44
|
+
// Dynamic SQL
|
|
45
|
+
'DYNAMIC', 'PREPARE', 'DEALLOCATE',
|
|
46
|
+
// Common injection patterns
|
|
47
|
+
'WAITFOR', 'DELAY', 'SLEEP'
|
|
48
|
+
];
|
|
49
|
+
/**
|
|
50
|
+
* Allowed keywords and functions for ORDER BY and similar expressions
|
|
51
|
+
*/
|
|
52
|
+
const ALLOWED_SQL_KEYWORDS = [
|
|
53
|
+
// Direction keywords
|
|
54
|
+
'ASC', 'ASCENDING', 'DESC', 'DESCENDING',
|
|
55
|
+
// Basic aggregate functions (read-only)
|
|
56
|
+
'COUNT', 'SUM', 'AVG', 'MIN', 'MAX',
|
|
57
|
+
// Math functions
|
|
58
|
+
'ABS', 'CEILING', 'FLOOR', 'ROUND', 'SQRT',
|
|
59
|
+
// String functions (read-only)
|
|
60
|
+
'LEN', 'LENGTH', 'UPPER', 'LOWER', 'LTRIM', 'RTRIM', 'TRIM',
|
|
61
|
+
// Date functions (read-only)
|
|
62
|
+
'YEAR', 'MONTH', 'DAY', 'DATEPART', 'DATEDIFF',
|
|
63
|
+
// Case expressions
|
|
64
|
+
'CASE', 'WHEN', 'THEN', 'ELSE', 'END',
|
|
65
|
+
// Basic logical
|
|
66
|
+
'AND', 'OR', 'NOT', 'IS', 'NULL', 'LIKE',
|
|
67
|
+
// Comparison operators (as words)
|
|
68
|
+
'BETWEEN', 'IN'
|
|
69
|
+
];
|
|
70
|
+
/**
|
|
71
|
+
* SQL Filter implementation functions
|
|
72
|
+
*/
|
|
73
|
+
const FILTER_IMPLEMENTATIONS = {
|
|
74
|
+
sqlString: (value) => {
|
|
75
|
+
if (value === null || value === undefined)
|
|
76
|
+
return 'NULL';
|
|
77
|
+
return `'${String(value).replace(/'/g, "''")}'`;
|
|
78
|
+
},
|
|
79
|
+
sqlNumber: (value) => {
|
|
80
|
+
const num = Number(value);
|
|
81
|
+
if (isNaN(num))
|
|
82
|
+
throw new Error(`Invalid number: ${value}`);
|
|
83
|
+
return num;
|
|
84
|
+
},
|
|
85
|
+
sqlDate: (value) => {
|
|
86
|
+
if (!value)
|
|
87
|
+
return 'NULL';
|
|
88
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
89
|
+
if (isNaN(date.getTime()))
|
|
90
|
+
throw new Error(`Invalid date: ${value}`);
|
|
91
|
+
return `'${date.toISOString()}'`;
|
|
92
|
+
},
|
|
93
|
+
sqlBoolean: (value) => {
|
|
94
|
+
return value ? '1' : '0';
|
|
95
|
+
},
|
|
96
|
+
sqlIdentifier: (value) => {
|
|
97
|
+
if (!value)
|
|
98
|
+
throw new Error('Identifier cannot be empty');
|
|
99
|
+
const identifier = String(value);
|
|
100
|
+
// Basic SQL injection prevention for identifiers
|
|
101
|
+
if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(identifier)) {
|
|
102
|
+
throw new Error(`Invalid SQL identifier: ${identifier}`);
|
|
103
|
+
}
|
|
104
|
+
return `[${identifier}]`;
|
|
105
|
+
},
|
|
106
|
+
sqlIn: (values) => {
|
|
107
|
+
if (!Array.isArray(values) || values.length === 0) {
|
|
108
|
+
return '(NULL)'; // This will match nothing
|
|
109
|
+
}
|
|
110
|
+
const escaped = values.map(v => {
|
|
111
|
+
if (typeof v === 'string') {
|
|
112
|
+
return `'${v.replace(/'/g, "''")}'`;
|
|
113
|
+
}
|
|
114
|
+
else if (typeof v === 'number') {
|
|
115
|
+
return v;
|
|
116
|
+
}
|
|
117
|
+
else if (v === null || v === undefined) {
|
|
118
|
+
return 'NULL';
|
|
119
|
+
}
|
|
120
|
+
return `'${String(v).replace(/'/g, "''")}'`;
|
|
121
|
+
});
|
|
122
|
+
return `(${escaped.join(', ')})`;
|
|
123
|
+
},
|
|
124
|
+
sqlNoKeywordsExpression: (value) => {
|
|
125
|
+
if (!value) {
|
|
126
|
+
throw new Error('SQL expression cannot be empty');
|
|
127
|
+
}
|
|
128
|
+
const expression = String(value).trim();
|
|
129
|
+
if (!expression) {
|
|
130
|
+
throw new Error('SQL expression cannot be empty');
|
|
131
|
+
}
|
|
132
|
+
// Convert to uppercase for keyword checking
|
|
133
|
+
const upperExpression = expression.toUpperCase();
|
|
134
|
+
// Check for dangerous keywords
|
|
135
|
+
for (const keyword of DANGEROUS_SQL_KEYWORDS) {
|
|
136
|
+
// Use word boundaries to avoid false positives (e.g., "Description" containing "DESC")
|
|
137
|
+
const regex = new RegExp(`\\b${keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`, 'i');
|
|
138
|
+
if (regex.test(upperExpression)) {
|
|
139
|
+
throw new Error(`Dangerous SQL keyword detected: ${keyword}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Extract all words/tokens from the expression
|
|
143
|
+
const tokens = expression.match(/\b[A-Za-z_][A-Za-z0-9_]*\b/g) || [];
|
|
144
|
+
// Check that any SQL keywords used are in the allowed list
|
|
145
|
+
for (const token of tokens) {
|
|
146
|
+
const upperToken = token.toUpperCase();
|
|
147
|
+
// If it's a SQL keyword (appears in either list), it must be in the allowed list
|
|
148
|
+
const isKnownKeyword = DANGEROUS_SQL_KEYWORDS.includes(upperToken) || ALLOWED_SQL_KEYWORDS.includes(upperToken);
|
|
149
|
+
const isAllowed = ALLOWED_SQL_KEYWORDS.includes(upperToken);
|
|
150
|
+
// If it's a known SQL keyword and not allowed, block it
|
|
151
|
+
if (isKnownKeyword && !isAllowed) {
|
|
152
|
+
throw new Error(`SQL keyword '${token}' is not allowed in expressions`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Additional safety checks
|
|
156
|
+
if (upperExpression.includes('--') || upperExpression.includes('/*') || upperExpression.includes('*/')) {
|
|
157
|
+
throw new Error('Comments are not allowed in SQL expressions');
|
|
158
|
+
}
|
|
159
|
+
if (upperExpression.includes(';')) {
|
|
160
|
+
throw new Error('Semicolons are not allowed in SQL expressions');
|
|
161
|
+
}
|
|
162
|
+
// Check for suspicious patterns
|
|
163
|
+
if (upperExpression.includes('()') && !upperExpression.match(/\b(COUNT|SUM|AVG|MIN|MAX|ABS|CEILING|FLOOR|ROUND|SQRT|LEN|LENGTH|UPPER|LOWER|TRIM|YEAR|MONTH|DAY)\s*\(/i)) {
|
|
164
|
+
throw new Error('Function calls with empty parentheses are not allowed');
|
|
165
|
+
}
|
|
166
|
+
// Return the original expression (preserving case)
|
|
167
|
+
return expression;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Complete SQL filters with implementations attached.
|
|
172
|
+
* This is the array that should be used by the QueryParameterProcessor.
|
|
173
|
+
*/
|
|
174
|
+
exports.RUN_QUERY_SQL_FILTERS_WITH_IMPLEMENTATIONS = querySQLFilters_1.RUN_QUERY_SQL_FILTERS.map(filter => ({
|
|
175
|
+
...filter,
|
|
176
|
+
implementation: FILTER_IMPLEMENTATIONS[filter.name]
|
|
177
|
+
}));
|
|
178
|
+
/**
|
|
179
|
+
* Singleton class for managing RunQuery SQL filters with implementations
|
|
180
|
+
*/
|
|
181
|
+
class RunQuerySQLFilterManager {
|
|
182
|
+
constructor() {
|
|
183
|
+
this._filters = new Map();
|
|
184
|
+
// Initialize with all filters that have implementations
|
|
185
|
+
exports.RUN_QUERY_SQL_FILTERS_WITH_IMPLEMENTATIONS.forEach(filter => {
|
|
186
|
+
if (filter.implementation) {
|
|
187
|
+
this._filters.set(filter.name, filter);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Gets the singleton instance
|
|
193
|
+
*/
|
|
194
|
+
static get Instance() {
|
|
195
|
+
if (!this._instance) {
|
|
196
|
+
this._instance = new RunQuerySQLFilterManager();
|
|
197
|
+
}
|
|
198
|
+
return this._instance;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Gets a filter by name
|
|
202
|
+
* @param name The filter name
|
|
203
|
+
* @returns The filter with implementation or undefined if not found
|
|
204
|
+
*/
|
|
205
|
+
getFilter(name) {
|
|
206
|
+
return this._filters.get(name);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Gets all available filter names
|
|
210
|
+
* @returns Array of filter names
|
|
211
|
+
*/
|
|
212
|
+
getFilterNames() {
|
|
213
|
+
return Array.from(this._filters.keys());
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Gets all filters with implementations
|
|
217
|
+
* @returns Array of all filters
|
|
218
|
+
*/
|
|
219
|
+
getAllFilters() {
|
|
220
|
+
return Array.from(this._filters.values());
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Executes a filter function by name
|
|
224
|
+
* @param filterName The name of the filter to execute
|
|
225
|
+
* @param value The value to filter
|
|
226
|
+
* @returns The filtered result
|
|
227
|
+
* @throws Error if filter is not found or execution fails
|
|
228
|
+
*/
|
|
229
|
+
executeFilter(filterName, value) {
|
|
230
|
+
const filter = this._filters.get(filterName);
|
|
231
|
+
if (!filter || !filter.implementation) {
|
|
232
|
+
throw new Error(`Filter '${filterName}' not found or has no implementation`);
|
|
233
|
+
}
|
|
234
|
+
return filter.implementation(value);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
exports.RunQuerySQLFilterManager = RunQuerySQLFilterManager;
|
|
238
|
+
//# sourceMappingURL=runQuerySQLFilterImplementations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runQuerySQLFilterImplementations.js","sourceRoot":"","sources":["../../src/generic/runQuerySQLF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securityInfo';
|
|
3
|
+
export type RunReportParams = {
|
|
4
|
+
ReportID: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Class used to run a report and return the results.
|
|
8
|
+
*/
|
|
9
|
+
export declare class RunReport {
|
|
10
|
+
private _provider;
|
|
11
|
+
/**
|
|
12
|
+
* Optionally, you can pass in a provider to use for running the report. If you dont pass in a provider, the static provider will be used.
|
|
13
|
+
* @param provider
|
|
14
|
+
*/
|
|
15
|
+
constructor(provider?: IRunReportProvider | null);
|
|
16
|
+
/**
|
|
17
|
+
* Returns the provider to be used for this instance, if one was passed in. Otherwise, it returns the static provider.
|
|
18
|
+
*/
|
|
19
|
+
get ProviderToUse(): IRunReportProvider;
|
|
20
|
+
RunReport(params: RunReportParams, contextUser?: UserInfo): Promise<RunReportResult>;
|
|
21
|
+
private static _globalProviderKey;
|
|
22
|
+
static get Provider(): IRunReportProvider;
|
|
23
|
+
static set Provider(value: IRunReportProvider);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=runReport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runReport.d.ts","sourceRoot":"","sources":["../../src/generic/runReport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,SAAS,CAAqB;IACtC;;;OAGG;gBACS,QAAQ,GAAE,kBAAkB,GAAG,IAAW;IAItD;;OAEG;IACH,IAAW,aAAa,IAAI,kBAAkB,CAE7C;IAEY,SAAS,CAAC,MAAM,EAAE,eAAe,EAAE,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC;IAIjG,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAkC;IACnE,WAAkB,QAAQ,IAAI,kBAAkB,CAI/C;IACD,WAAkB,QAAQ,CAAC,KAAK,EAAE,kBAAkB,EAInD;CACF"}
|