@memberjunction/core 2.72.0 → 2.74.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.
Files changed (46) hide show
  1. package/dist/generic/applicationInfo.d.ts +92 -1
  2. package/dist/generic/applicationInfo.d.ts.map +1 -1
  3. package/dist/generic/applicationInfo.js +92 -1
  4. package/dist/generic/applicationInfo.js.map +1 -1
  5. package/dist/generic/baseInfo.d.ts +15 -0
  6. package/dist/generic/baseInfo.d.ts.map +1 -1
  7. package/dist/generic/baseInfo.js +15 -0
  8. package/dist/generic/baseInfo.js.map +1 -1
  9. package/dist/generic/entityInfo.d.ts +184 -3
  10. package/dist/generic/entityInfo.d.ts.map +1 -1
  11. package/dist/generic/entityInfo.js +184 -3
  12. package/dist/generic/entityInfo.js.map +1 -1
  13. package/dist/generic/interfaces.d.ts +119 -4
  14. package/dist/generic/interfaces.d.ts.map +1 -1
  15. package/dist/generic/interfaces.js +44 -3
  16. package/dist/generic/interfaces.js.map +1 -1
  17. package/dist/generic/providerBase.d.ts +248 -8
  18. package/dist/generic/providerBase.d.ts.map +1 -1
  19. package/dist/generic/providerBase.js +185 -2
  20. package/dist/generic/providerBase.js.map +1 -1
  21. package/dist/generic/queryInfo.d.ts +312 -1
  22. package/dist/generic/queryInfo.d.ts.map +1 -1
  23. package/dist/generic/queryInfo.js +371 -2
  24. package/dist/generic/queryInfo.js.map +1 -1
  25. package/dist/generic/querySQLFilters.d.ts +54 -0
  26. package/dist/generic/querySQLFilters.d.ts.map +1 -0
  27. package/dist/generic/querySQLFilters.js +84 -0
  28. package/dist/generic/querySQLFilters.js.map +1 -0
  29. package/dist/generic/runQuery.d.ts +42 -0
  30. package/dist/generic/runQuery.d.ts.map +1 -1
  31. package/dist/generic/runQuery.js +26 -0
  32. package/dist/generic/runQuery.js.map +1 -1
  33. package/dist/generic/runQuerySQLFilterImplementations.d.ts +51 -0
  34. package/dist/generic/runQuerySQLFilterImplementations.d.ts.map +1 -0
  35. package/dist/generic/runQuerySQLFilterImplementations.js +238 -0
  36. package/dist/generic/runQuerySQLFilterImplementations.js.map +1 -0
  37. package/dist/generic/securityInfo.d.ts +212 -13
  38. package/dist/generic/securityInfo.d.ts.map +1 -1
  39. package/dist/generic/securityInfo.js +200 -14
  40. package/dist/generic/securityInfo.js.map +1 -1
  41. package/dist/index.d.ts +4 -0
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +4 -0
  44. package/dist/index.js.map +1 -1
  45. package/package.json +2 -2
  46. package/readme.md +550 -1
@@ -1,37 +1,110 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueryPermissionInfo = exports.QueryFieldInfo = exports.QueryCategoryInfo = exports.QueryInfo = void 0;
3
+ exports.QueryParameterInfo = exports.QueryEntityInfo = exports.QueryPermissionInfo = exports.QueryFieldInfo = exports.QueryCategoryInfo = exports.QueryInfo = void 0;
4
4
  const baseInfo_1 = require("./baseInfo");
5
5
  const metadata_1 = require("./metadata");
6
6
  /**
7
- * Metadata about a single stored query in the database.
7
+ * Catalog of stored queries. This is useful for any arbitrary query that is known to be performant and correct and can be reused.
8
+ * Queries can be viewed/run by a user, used programatically via RunQuery, and also used by AI systems for improved reliability
9
+ * instead of dynamically generated SQL. Queries can also improve security since they store the SQL instead of using dynamic SQL.
8
10
  */
9
11
  class QueryInfo extends baseInfo_1.BaseInfo {
12
+ /**
13
+ * Gets the field metadata for this query, including display names, data types, and formatting rules.
14
+ * @returns {QueryFieldInfo[]} Array of field metadata for the query
15
+ */
10
16
  get Fields() {
11
17
  if (this._fields === null) {
12
18
  this._fields = metadata_1.Metadata.Provider.QueryFields.filter(f => f.QueryID === this.ID);
13
19
  }
14
20
  return this._fields;
15
21
  }
22
+ /**
23
+ * Gets the permissions that control access to this query, defining which users and roles can run it.
24
+ * @returns {QueryPermissionInfo[]} Array of permission settings for the query
25
+ */
16
26
  get Permissions() {
17
27
  return metadata_1.Metadata.Provider.QueryPermissions.filter(p => p.QueryID === this.ID);
18
28
  }
29
+ /**
30
+ * Gets the parameter definitions for this parameterized query if it uses Nunjucks templates.
31
+ * Parameters include validation filters and metadata for type-safe query execution.
32
+ * @returns {QueryParameterInfo[]} Array of parameter definitions for the query
33
+ */
34
+ get Parameters() {
35
+ if (this._parameters === null) {
36
+ this._parameters = metadata_1.Metadata.Provider.QueryParameters.filter(p => p.QueryID === this.ID);
37
+ }
38
+ return this._parameters;
39
+ }
40
+ /**
41
+ * Gets the entities that are involved in this query, tracking which MemberJunction entities are referenced.
42
+ * @returns {QueryEntityInfo[]} Array of entities used by the query
43
+ */
44
+ get Entities() {
45
+ if (this._entities === null) {
46
+ this._entities = metadata_1.Metadata.Provider.QueryEntities.filter(e => e.QueryID === this.ID);
47
+ }
48
+ return this._entities;
49
+ }
19
50
  constructor(initData = null) {
20
51
  super();
52
+ /**
53
+ * Unique identifier for the query record
54
+ */
21
55
  this.ID = null;
56
+ /**
57
+ * Name of the query for display and reference
58
+ */
22
59
  this.Name = null;
60
+ /**
61
+ * Detailed description of what the query does and what data it returns
62
+ */
23
63
  this.Description = null;
64
+ /**
65
+ * Foreign key reference to the Query Categories entity
66
+ */
24
67
  this.CategoryID = null;
68
+ /**
69
+ * The actual SQL query text to execute, may include Nunjucks template parameters
70
+ */
25
71
  this.SQL = null;
72
+ /**
73
+ * The original SQL before any optimization or modification, kept for reference and comparison
74
+ */
26
75
  this.OriginalSQL = null;
76
+ /**
77
+ * User feedback on query accuracy, performance, or suggested improvements
78
+ */
27
79
  this.Feedback = null;
80
+ /**
81
+ * Current status of the query in the approval workflow
82
+ */
28
83
  this.Status = null;
84
+ /**
85
+ * Value indicating the quality of the query, higher values mean better quality
86
+ */
29
87
  this.QualityRank = null;
88
+ /**
89
+ * Automatically set to true when the SQL column contains Nunjucks template markers like {{paramName}}
90
+ */
91
+ this.UsesTemplate = false;
92
+ /**
93
+ * Date and time when this query record was created
94
+ */
30
95
  this.__mj_CreatedAt = null;
96
+ /**
97
+ * Date and time when this query record was last updated
98
+ */
31
99
  this.__mj_UpdatedAt = null;
32
100
  // virtual fields - returned by the database VIEW
101
+ /**
102
+ * Category name from the related Query Categories entity
103
+ */
33
104
  this.Category = null;
34
105
  this._fields = null;
106
+ this._parameters = null;
107
+ this._entities = null;
35
108
  if (initData) {
36
109
  this.copyInitData(initData);
37
110
  // do some special handling to create class instances instead of just data objects
@@ -45,40 +118,133 @@ class QueryInfo extends baseInfo_1.BaseInfo {
45
118
  }
46
119
  }
47
120
  }
121
+ /**
122
+ * Gets the category information for this query, supporting hierarchical organization.
123
+ * @returns {QueryCategoryInfo} The category this query belongs to, or undefined if not categorized
124
+ */
48
125
  get CategoryInfo() {
49
126
  return metadata_1.Metadata.Provider.QueryCategories.find(c => c.ID === this.CategoryID);
50
127
  }
128
+ /**
129
+ * Checks if a user has permission to run this query based on their roles.
130
+ * A user can run a query if:
131
+ * 1. The query has no permissions defined (open to all)
132
+ * 2. The user has at least one role that is granted permission
133
+ *
134
+ * @param user The user to check permissions for
135
+ * @returns true if the user has permission to run the query
136
+ */
137
+ UserHasRunPermissions(user) {
138
+ const permissions = this.Permissions;
139
+ // If no permissions are defined, the query is open to all
140
+ if (!permissions || permissions.length === 0) {
141
+ return true;
142
+ }
143
+ // Check if user has any of the required roles
144
+ if (user && user.UserRoles) {
145
+ for (const userRole of user.UserRoles) {
146
+ if (permissions.some(p => p.RoleName === userRole.Role)) {
147
+ return true;
148
+ }
149
+ }
150
+ }
151
+ return false;
152
+ }
153
+ /**
154
+ * Checks if a user can run this query, considering both permissions and query status.
155
+ * A query can be run if:
156
+ * 1. The user has permission to run it (via UserHasRunPermissions)
157
+ * 2. The query status is 'Approved'
158
+ *
159
+ * @param user The user to check
160
+ * @returns true if the user can run the query right now
161
+ */
162
+ UserCanRun(user) {
163
+ // First check permissions
164
+ if (!this.UserHasRunPermissions(user)) {
165
+ return false;
166
+ }
167
+ // Then check status - only approved queries can be run
168
+ return this.Status === 'Approved';
169
+ }
51
170
  }
52
171
  exports.QueryInfo = QueryInfo;
172
+ /**
173
+ * Organizes saved queries into categories for discovery and management, supporting folder-like organization of queries.
174
+ */
53
175
  class QueryCategoryInfo extends baseInfo_1.BaseInfo {
54
176
  constructor(initData = null) {
55
177
  super();
178
+ /**
179
+ * Unique identifier for the query category
180
+ */
56
181
  this.ID = null;
182
+ /**
183
+ * Name of the category for organizing queries
184
+ */
57
185
  this.Name = null;
186
+ /**
187
+ * Foreign key to parent category for hierarchical organization
188
+ */
58
189
  this.ParentID = null;
190
+ /**
191
+ * Description of what types of queries belong in this category
192
+ */
59
193
  this.Description = null;
194
+ /**
195
+ * Date and time when this category was created
196
+ */
60
197
  this.__mj_CreatedAt = null;
198
+ /**
199
+ * Date and time when this category was last updated
200
+ */
61
201
  this.__mj_UpdatedAt = null;
62
202
  // virtual fields - returned by the database VIEW
203
+ /**
204
+ * Parent category name from the related category
205
+ */
63
206
  this.Parent = null;
64
207
  if (initData) {
65
208
  this.copyInitData(initData);
66
209
  }
67
210
  }
211
+ /**
212
+ * Gets the parent category information for hierarchical category organization.
213
+ * @returns {QueryCategoryInfo} The parent category, or undefined if this is a top-level category
214
+ */
68
215
  get ParentCategoryInfo() {
69
216
  return metadata_1.Metadata.Provider.QueryCategories.find(c => c.ID === this.ParentID);
70
217
  }
218
+ /**
219
+ * Gets all queries that belong to this category.
220
+ * @returns {QueryInfo[]} Array of queries in this category
221
+ */
71
222
  get Queries() {
72
223
  return metadata_1.Metadata.Provider.Queries.filter(q => q.CategoryID === this.ID);
73
224
  }
74
225
  }
75
226
  exports.QueryCategoryInfo = QueryCategoryInfo;
227
+ /**
228
+ * Stores field-level metadata for queries including display names, data types, and formatting rules for result presentation.
229
+ */
76
230
  class QueryFieldInfo extends baseInfo_1.BaseInfo {
77
231
  constructor(initData = null) {
78
232
  super();
233
+ /**
234
+ * Name of the field as it appears in query results
235
+ */
79
236
  this.Name = null;
237
+ /**
238
+ * Foreign key to the parent query
239
+ */
80
240
  this.QueryID = null;
241
+ /**
242
+ * Description of what this field represents
243
+ */
81
244
  this.Description = null;
245
+ /**
246
+ * Display order of this field in query results
247
+ */
82
248
  this.Sequence = null;
83
249
  /**
84
250
  * The base type, not including parameters, in SQL. For example this field would be nvarchar or decimal, and wouldn't include type parameters. The SQLFullType field provides that information.
@@ -88,42 +254,245 @@ class QueryFieldInfo extends baseInfo_1.BaseInfo {
88
254
  * The full SQL type for the field, for example datetime or nvarchar(10) etc.
89
255
  */
90
256
  this.SQLFullType = null;
257
+ /**
258
+ * Foreign key to the source entity this field comes from
259
+ */
91
260
  this.SourceEntityID = null;
261
+ /**
262
+ * Name of the field in the source entity
263
+ */
92
264
  this.SourceFieldName = null;
265
+ /**
266
+ * Whether this field is computed rather than directly selected from a table
267
+ */
93
268
  this.IsComputed = null;
269
+ /**
270
+ * Explanation of how this computed field is calculated
271
+ */
94
272
  this.ComputationDescription = null;
273
+ /**
274
+ * Whether this field represents a summary/aggregate value
275
+ */
95
276
  this.IsSummary = null;
277
+ /**
278
+ * Description of the summary calculation
279
+ */
96
280
  this.SummaryDescription = null;
281
+ /**
282
+ * Date and time when this field was created
283
+ */
97
284
  this.__mj_CreatedAt = null;
285
+ /**
286
+ * Date and time when this field was last updated
287
+ */
98
288
  this.__mj_UpdatedAt = null;
99
289
  // virtual fields - returned by the database VIEW
290
+ /**
291
+ * Source entity name if field is from an entity
292
+ */
100
293
  this.SourceEntity = null;
101
294
  if (initData) {
102
295
  this.copyInitData(initData);
103
296
  }
104
297
  }
298
+ /**
299
+ * Gets the entity information for the source entity this field comes from.
300
+ * @returns {EntityInfo} The source entity metadata, or undefined if not linked to an entity
301
+ */
105
302
  get SourceEntityInfo() {
106
303
  return metadata_1.Metadata.Provider.Entities.find(e => e.ID === this.SourceEntityID);
107
304
  }
305
+ /**
306
+ * Gets the query information this field belongs to.
307
+ * @returns {QueryInfo} The parent query metadata
308
+ */
108
309
  get QueryInfo() {
109
310
  return metadata_1.Metadata.Provider.Queries.find(q => q.ID === this.ID);
110
311
  }
111
312
  }
112
313
  exports.QueryFieldInfo = QueryFieldInfo;
314
+ /**
315
+ * Controls access to queries by defining which users and roles can run specific queries.
316
+ */
113
317
  class QueryPermissionInfo extends baseInfo_1.BaseInfo {
114
318
  constructor(initData = null) {
115
319
  super();
320
+ /**
321
+ * Foreign key to the query this permission applies to
322
+ */
116
323
  this.QueryID = null;
324
+ /**
325
+ * Name of the role that has permission to run this query
326
+ */
117
327
  this.RoleName = null;
118
328
  // virtual fields - returned by the database VIEW
329
+ /**
330
+ * Query name from the related query
331
+ */
119
332
  this.Query = null;
120
333
  if (initData) {
121
334
  this.copyInitData(initData);
122
335
  }
123
336
  }
337
+ /**
338
+ * Gets the query information this permission applies to.
339
+ * @returns {QueryInfo} The query metadata this permission controls
340
+ */
124
341
  get QueryInfo() {
125
342
  return metadata_1.Metadata.Provider.Queries.find(q => q.ID === this.QueryID);
126
343
  }
127
344
  }
128
345
  exports.QueryPermissionInfo = QueryPermissionInfo;
346
+ /**
347
+ * Tracks which entities are involved in a given query. The Queries table stores SQL and descriptions for stored queries
348
+ * that can be executed and serve as examples for AI.
349
+ */
350
+ class QueryEntityInfo extends baseInfo_1.BaseInfo {
351
+ constructor(initData = null) {
352
+ super();
353
+ /**
354
+ * References the ID of the query in the Queries table
355
+ */
356
+ this.QueryID = null;
357
+ /**
358
+ * References the ID of the entity in the Entities table
359
+ */
360
+ this.EntityID = null;
361
+ /**
362
+ * Order sequence for multiple entities in a query
363
+ */
364
+ this.Sequence = null;
365
+ /**
366
+ * How this entity association was detected: AI (automatic) or Manual (user-specified)
367
+ */
368
+ this.DetectionMethod = 'Manual';
369
+ /**
370
+ * Confidence score (0.00-1.00) when AI detection was used
371
+ */
372
+ this.AutoDetectConfidenceScore = null;
373
+ /**
374
+ * Date and time when this association was created
375
+ */
376
+ this.__mj_CreatedAt = null;
377
+ /**
378
+ * Date and time when this association was last updated
379
+ */
380
+ this.__mj_UpdatedAt = null;
381
+ // virtual fields - returned by the database VIEW
382
+ /**
383
+ * Query name from the related query
384
+ */
385
+ this.Query = null;
386
+ /**
387
+ * Entity name from the related entity
388
+ */
389
+ this.Entity = null;
390
+ if (initData) {
391
+ this.copyInitData(initData);
392
+ }
393
+ }
394
+ /**
395
+ * Gets the query information this entity relationship belongs to.
396
+ * @returns {QueryInfo} The parent query metadata
397
+ */
398
+ get QueryInfo() {
399
+ return metadata_1.Metadata.Provider.Queries.find(q => q.ID === this.QueryID);
400
+ }
401
+ /**
402
+ * Gets the entity information for the entity involved in this query.
403
+ * @returns {EntityInfo} The entity metadata
404
+ */
405
+ get EntityInfo() {
406
+ return metadata_1.Metadata.Provider.Entities.find(e => e.ID === this.EntityID);
407
+ }
408
+ }
409
+ exports.QueryEntityInfo = QueryEntityInfo;
410
+ /**
411
+ * Stores parameter definitions for parameterized queries that use Nunjucks templates. Each parameter represents a dynamic value
412
+ * that can be passed when executing the query. Parameters are automatically extracted from the query template by the QueryEntityServer
413
+ * using LLM analysis, or can be manually defined. The combination of parameter metadata and validation filters creates a
414
+ * self-documenting, type-safe query execution system.
415
+ */
416
+ class QueryParameterInfo extends baseInfo_1.BaseInfo {
417
+ constructor(initData = null) {
418
+ super();
419
+ /**
420
+ * Foreign key to the query this parameter belongs to
421
+ */
422
+ this.QueryID = null;
423
+ /**
424
+ * The name of the parameter as it appears in the Nunjucks template (e.g., {{parameterName}})
425
+ */
426
+ this.Name = null;
427
+ /**
428
+ * Data type of the parameter for validation and type casting
429
+ */
430
+ this.Type = null;
431
+ /**
432
+ * Whether this parameter must be provided when executing the query
433
+ */
434
+ this.IsRequired = false;
435
+ /**
436
+ * Default value to use when parameter is not provided
437
+ */
438
+ this.DefaultValue = null;
439
+ /**
440
+ * Human-readable description of what this parameter is for
441
+ */
442
+ this.Description = null;
443
+ /**
444
+ * Example value demonstrating the proper format for this parameter
445
+ */
446
+ this.SampleValue = null;
447
+ /**
448
+ * JSON array of Nunjucks filter definitions for value transformation
449
+ */
450
+ this.ValidationFilters = null;
451
+ /**
452
+ * How this parameter was detected: AI (automatic) or Manual (user-specified)
453
+ */
454
+ this.DetectionMethod = 'Manual';
455
+ /**
456
+ * Confidence score (0.00-1.00) when AI detection was used
457
+ */
458
+ this.AutoDetectConfidenceScore = null;
459
+ /**
460
+ * Date and time when this parameter was created
461
+ */
462
+ this.__mj_CreatedAt = null;
463
+ /**
464
+ * Date and time when this parameter was last updated
465
+ */
466
+ this.__mj_UpdatedAt = null;
467
+ // virtual field from view
468
+ /**
469
+ * Query name from the related query
470
+ */
471
+ this.Query = null;
472
+ if (initData) {
473
+ this.copyInitData(initData);
474
+ }
475
+ }
476
+ /**
477
+ * Gets the query information this parameter belongs to.
478
+ * @returns {QueryInfo} The parent query metadata
479
+ */
480
+ get QueryInfo() {
481
+ return metadata_1.Metadata.Provider.Queries.find(q => q.ID === this.QueryID);
482
+ }
483
+ /**
484
+ * Gets the parsed validation filters for this parameter.
485
+ * Parses the JSON string of filter definitions into an array of filter objects.
486
+ * @returns {any[]} Array of parsed filter definitions, or empty array if parsing fails
487
+ */
488
+ get ParsedFilters() {
489
+ try {
490
+ return this.ValidationFilters ? JSON.parse(this.ValidationFilters) : [];
491
+ }
492
+ catch {
493
+ return [];
494
+ }
495
+ }
496
+ }
497
+ exports.QueryParameterInfo = QueryParameterInfo;
129
498
  //# sourceMappingURL=queryInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"queryInfo.js","sourceRoot":"","sources":["../../src/generic/queryInfo.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AAEtC,yCAAsC;AAEtC;;GAEG;AACH,MAAa,SAAU,SAAQ,mBAAQ;IAiBnC,IAAW,MAAM;QACb,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YACxB,IAAI,CAAC,OAAO,GAAG,mBAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC;QACp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L 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,W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