json-fs-query 1.0.4 → 1.0.6

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 (139) hide show
  1. package/browser/jsonFsQuery.js +10158 -27750
  2. package/browser/jsonFsQuery.min.js +1 -1
  3. package/dist/data/introspect/create.d.ts +10 -10
  4. package/dist/data/introspect/create.js +47 -47
  5. package/dist/data/introspect/definitions/field.d.ts +27 -27
  6. package/dist/data/introspect/definitions/field.js +36 -36
  7. package/dist/data/introspect/definitions/key.d.ts +25 -25
  8. package/dist/data/introspect/definitions/key.js +53 -53
  9. package/dist/data/introspect/definitions/keyReference.d.ts +17 -17
  10. package/dist/data/introspect/definitions/keyReference.js +20 -20
  11. package/dist/data/introspect/definitions/record.d.ts +25 -25
  12. package/dist/data/introspect/definitions/record.js +32 -32
  13. package/dist/data/introspect/describe.js +15 -15
  14. package/dist/data/introspect/drop.js +37 -37
  15. package/dist/data/introspect/index.d.ts +7 -7
  16. package/dist/data/introspect/index.js +30 -30
  17. package/dist/data/introspect/policies/foreignKeyExists.d.ts +8 -8
  18. package/dist/data/introspect/policies/foreignKeyExists.js +25 -25
  19. package/dist/data/introspect/policies/hasDependents.d.ts +12 -12
  20. package/dist/data/introspect/policies/hasDependents.js +52 -52
  21. package/dist/data/introspect/policies/keyGenerate.d.ts +1 -1
  22. package/dist/data/introspect/policies/keyGenerate.js +17 -17
  23. package/dist/data/introspect/policies/keyUnique.d.ts +9 -9
  24. package/dist/data/introspect/policies/keyUnique.js +31 -31
  25. package/dist/data/introspect/policies/typeCheck.d.ts +11 -11
  26. package/dist/data/introspect/policies/typeCheck.js +57 -57
  27. package/dist/data/introspect/policies/typeEnum.d.ts +1 -1
  28. package/dist/data/introspect/policies/typeEnum.js +9 -9
  29. package/dist/data/introspect/policies/useDefault.d.ts +1 -1
  30. package/dist/data/introspect/policies/useDefault.js +8 -8
  31. package/dist/data/queries/deleteEntity.d.ts +1 -1
  32. package/dist/data/queries/deleteEntity.js +100 -100
  33. package/dist/data/queries/groupBy.d.ts +1 -1
  34. package/dist/data/queries/groupBy.js +22 -22
  35. package/dist/data/queries/insertEntity.d.ts +1 -1
  36. package/dist/data/queries/insertEntity.js +117 -117
  37. package/dist/data/queries/joinEntity.d.ts +1 -1
  38. package/dist/data/queries/joinEntity.js +32 -32
  39. package/dist/data/queries/joinEntity.min.js +1 -1
  40. package/dist/data/queries/limitOffset.d.ts +7 -7
  41. package/dist/data/queries/limitOffset.js +21 -21
  42. package/dist/data/queries/mergeJoins.d.ts +1 -1
  43. package/dist/data/queries/mergeJoins.js +19 -19
  44. package/dist/data/queries/mergeJoins.min.js +1 -1
  45. package/dist/data/queries/parser.d.ts +1 -1
  46. package/dist/data/queries/parser.js +19 -19
  47. package/dist/data/queries/parser.min.js +1 -1
  48. package/dist/data/queries/query.d.ts +1 -1
  49. package/dist/data/queries/query.js +18 -18
  50. package/dist/data/queries/query.min.js +1 -1
  51. package/dist/data/queries/readEntity.js +14 -14
  52. package/dist/data/queries/selectFields.d.ts +9 -9
  53. package/dist/data/queries/selectFields.js +36 -36
  54. package/dist/data/queries/sortBy.d.ts +1 -1
  55. package/dist/data/queries/sortBy.js +15 -15
  56. package/dist/data/queries/sortBy.min.js +1 -1
  57. package/dist/data/queries/updateEntity.d.ts +1 -1
  58. package/dist/data/queries/updateEntity.js +190 -190
  59. package/dist/data/queries/where.d.ts +6 -6
  60. package/dist/data/queries/where.js +56 -56
  61. package/dist/data/utilities/computeKeyValue.d.ts +12 -12
  62. package/dist/data/utilities/computeKeyValue.js +26 -26
  63. package/dist/data/utilities/config.d.ts +27 -27
  64. package/dist/data/utilities/config.js +45 -45
  65. package/dist/data/utilities/deregisterRecord.d.ts +7 -7
  66. package/dist/data/utilities/deregisterRecord.js +34 -34
  67. package/dist/data/utilities/getConditionIndexedList.js +47 -47
  68. package/dist/data/utilities/getConditionIndexedList.min.js +1 -1
  69. package/dist/data/utilities/getJoinIndexedList.js +76 -76
  70. package/dist/data/utilities/getJoinIndexedList.min.js +1 -1
  71. package/dist/data/utilities/getMatchingIndexes.js +28 -28
  72. package/dist/data/utilities/getMatchingIndexes.min.js +1 -1
  73. package/dist/data/utilities/matchIndexedJoins.js +61 -61
  74. package/dist/data/utilities/matchIndexedJoins.min.js +1 -1
  75. package/dist/data/utilities/mergeJoin.js +44 -44
  76. package/dist/data/utilities/mergeJoin.min.js +1 -1
  77. package/dist/data/utilities/parsers/findCommand.d.ts +9 -9
  78. package/dist/data/utilities/parsers/findCommand.js +25 -25
  79. package/dist/data/utilities/parsers/findConditions.d.ts +14 -14
  80. package/dist/data/utilities/parsers/findConditions.js +28 -28
  81. package/dist/data/utilities/parsers/findConditions.min.js +1 -1
  82. package/dist/data/utilities/parsers/findGroupBy.d.ts +8 -8
  83. package/dist/data/utilities/parsers/findGroupBy.js +22 -22
  84. package/dist/data/utilities/parsers/findInsertValues.d.ts +12 -12
  85. package/dist/data/utilities/parsers/findInsertValues.js +34 -34
  86. package/dist/data/utilities/parsers/findJoinClauses.d.ts +12 -12
  87. package/dist/data/utilities/parsers/findJoinClauses.js +27 -27
  88. package/dist/data/utilities/parsers/findJoinClauses.min.js +1 -1
  89. package/dist/data/utilities/parsers/findJoinEntity.d.ts +8 -8
  90. package/dist/data/utilities/parsers/findJoinEntity.js +22 -22
  91. package/dist/data/utilities/parsers/findLimit.d.ts +8 -8
  92. package/dist/data/utilities/parsers/findLimit.js +22 -22
  93. package/dist/data/utilities/parsers/findMergeJoins.d.ts +11 -11
  94. package/dist/data/utilities/parsers/findMergeJoins.js +26 -26
  95. package/dist/data/utilities/parsers/findMergeJoins.min.js +1 -1
  96. package/dist/data/utilities/parsers/findOffset.d.ts +8 -8
  97. package/dist/data/utilities/parsers/findOffset.js +22 -22
  98. package/dist/data/utilities/parsers/findSelects.d.ts +11 -11
  99. package/dist/data/utilities/parsers/findSelects.js +30 -30
  100. package/dist/data/utilities/parsers/findSelects.min.js +1 -1
  101. package/dist/data/utilities/parsers/findSortClauses.d.ts +11 -11
  102. package/dist/data/utilities/parsers/findSortClauses.js +30 -30
  103. package/dist/data/utilities/parsers/findSortClauses.min.js +1 -1
  104. package/dist/data/utilities/parsers/findUpdateValues.d.ts +14 -14
  105. package/dist/data/utilities/parsers/findUpdateValues.js +34 -34
  106. package/dist/data/utilities/parsers/isEntityProperty.js +6 -6
  107. package/dist/data/utilities/parsers/parseLiteralValue.d.ts +11 -11
  108. package/dist/data/utilities/parsers/parseLiteralValue.js +34 -34
  109. package/dist/data/utilities/parsers/parseQuery.d.ts +32 -32
  110. package/dist/data/utilities/parsers/parseQuery.js +51 -51
  111. package/dist/data/utilities/parsers/parseQuery.min.js +1 -1
  112. package/dist/data/utilities/parsers/removeFromQuery.js +6 -6
  113. package/dist/data/utilities/parsers/splitEntityProperty.js +13 -13
  114. package/dist/data/utilities/parsers/splitQueries.js +9 -9
  115. package/dist/data/utilities/reconcileJoin.js +26 -26
  116. package/dist/data/utilities/reconcileJoins.js +26 -26
  117. package/dist/data/utilities/reconcileJoins.min.js +1 -1
  118. package/dist/data/utilities/registerRecord.d.ts +7 -7
  119. package/dist/data/utilities/registerRecord.js +67 -67
  120. package/dist/data/utilities/removeFromIndex.d.ts +13 -13
  121. package/dist/data/utilities/removeFromIndex.js +44 -46
  122. package/dist/data/utilities/restrictIndexedList.js +45 -45
  123. package/dist/data/utilities/retrieveFile.js +28 -28
  124. package/dist/data/utilities/retrieveFile.min.js +1 -1
  125. package/dist/data/utilities/retrieveIndexes.d.ts +1 -1
  126. package/dist/data/utilities/retrieveIndexes.js +24 -24
  127. package/dist/data/utilities/retrieveIndexes.min.js +1 -1
  128. package/dist/data/utilities/retrieveRecord.js +9 -9
  129. package/dist/data/utilities/retrieveRecords.js +21 -21
  130. package/dist/data/utilities/retrieveRecords.min.js +1 -1
  131. package/dist/data/utilities/runQuery.d.ts +1 -1
  132. package/dist/data/utilities/runQuery.js +87 -87
  133. package/dist/data/utilities/updateIndex.d.ts +16 -16
  134. package/dist/data/utilities/updateIndex.js +56 -56
  135. package/dist/data/utilities/useJoinClause.d.ts +5 -5
  136. package/dist/data/utilities/useJoinClause.js +51 -51
  137. package/dist/index.d.ts +4 -4
  138. package/dist/index.js +42 -42
  139. package/package.json +9 -5
@@ -1,22 +1,22 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.findLimit = void 0
7
- const _removeFromQuery = require('./removeFromQuery')
8
- const limitMatch = /limit\s*(\d+)/i
9
- /**
10
- * Extract the limit clauses from the query.
11
- * @param parsed
12
- * @param query
13
- */
14
- const findLimit = (parsed, query) => {
15
- const limitFound = query.match(limitMatch)
16
- if (limitFound) {
17
- parsed.limit = limitFound ? parseInt(limitFound[1]) : undefined
18
- return (0, _removeFromQuery.removeFromQuery)(limitFound[0], query)
19
- }
20
- return query
21
- }
22
- exports.findLimit = findLimit
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findLimit = void 0;
7
+ var _removeFromQuery = require("./removeFromQuery");
8
+ const limitMatch = /limit\s*(\d+)/i;
9
+ /**
10
+ * Extract the limit clauses from the query.
11
+ * @param parsed
12
+ * @param query
13
+ */
14
+ const findLimit = (parsed, query) => {
15
+ const limitFound = query.match(limitMatch);
16
+ if (limitFound) {
17
+ parsed['limit'] = limitFound ? parseInt(limitFound[1]) : undefined;
18
+ return (0, _removeFromQuery.removeFromQuery)(limitFound[0], query);
19
+ }
20
+ return query;
21
+ };
22
+ exports.findLimit = findLimit;
@@ -1,12 +1,12 @@
1
- import { ParsedQuery } from './parseQuery';
2
- export type ParsedMergeJoin = {
3
- propertyA: string;
4
- propertyB: string;
5
- };
6
- /**
7
- * Extract merge-join clauses from the query.
8
- * @param parsed
9
- * @param query
10
- */
11
- export declare const findMergeJoins: (parsed: ParsedQuery, query: string) => string;
1
+ import { ParsedQuery } from './parseQuery';
2
+ export type ParsedMergeJoin = {
3
+ propertyA: string;
4
+ propertyB: string;
5
+ };
6
+ /**
7
+ * Extract merge-join clauses from the query.
8
+ * @param parsed
9
+ * @param query
10
+ */
11
+ export declare const findMergeJoins: (parsed: ParsedQuery, query: string) => string;
12
12
  //# sourceMappingURL=findMergeJoins.d.ts.map
@@ -1,26 +1,26 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.findMergeJoins = void 0
7
- const _removeFromQuery = require('./removeFromQuery')
8
- const mergeJoinMatch = /(and)?\s*merge\s+([a-z0-9_-]+\.[a-z0-9_-]+)\s+with\s+([a-z0-9_-]+\.[a-z0-9_-]+)/ig
9
- /**
10
- * Extract merge-join clauses from the query.
11
- * @param parsed
12
- * @param query
13
- */
14
- const findMergeJoins = (parsed, query) => {
15
- const mergeJoinsFound = query.matchAll(mergeJoinMatch)
16
- // @ts-ignore
17
- for (const mergeJoin of mergeJoinsFound) {
18
- parsed.mergeJoins.push({
19
- propertyA: mergeJoin[2],
20
- propertyB: mergeJoin[3]
21
- })
22
- query = (0, _removeFromQuery.removeFromQuery)(mergeJoin[0].trim(), query)
23
- }
24
- return query
25
- }
26
- exports.findMergeJoins = findMergeJoins
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findMergeJoins = void 0;
7
+ var _removeFromQuery = require("./removeFromQuery");
8
+ const mergeJoinMatch = /(and)?\s*merge\s+([a-z0-9_-]+\.[a-z0-9_-]+)\s+with\s+([a-z0-9_-]+\.[a-z0-9_-]+)/ig;
9
+ /**
10
+ * Extract merge-join clauses from the query.
11
+ * @param parsed
12
+ * @param query
13
+ */
14
+ const findMergeJoins = (parsed, query) => {
15
+ const mergeJoinsFound = query.matchAll(mergeJoinMatch);
16
+ // @ts-ignore
17
+ for (const mergeJoin of mergeJoinsFound) {
18
+ parsed['mergeJoins'].push({
19
+ propertyA: mergeJoin[2],
20
+ propertyB: mergeJoin[3]
21
+ });
22
+ query = (0, _removeFromQuery.removeFromQuery)(mergeJoin[0].trim(), query);
23
+ }
24
+ return query;
25
+ };
26
+ exports.findMergeJoins = findMergeJoins;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findMergeJoins=void 0;var _removeFromQuery=require("./removeFromQuery");const mergeJoinMatch=/(and)?\s*merge\s+([a-z0-9_-]+\.[a-z0-9_-]+)\s+with\s+([a-z0-9_-]+\.[a-z0-9_-]+)/gi,findMergeJoins=(e,r)=>{const o=r.matchAll(mergeJoinMatch);for(let i of o)e.mergeJoins.push({propertyA:i[2],propertyB:i[3]}),r=(0,_removeFromQuery.removeFromQuery)(i[0].trim(),r);return r};exports.findMergeJoins=findMergeJoins;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findMergeJoins=void 0;var _removeFromQuery=require("./removeFromQuery");const mergeJoinMatch=/(and)?\s*merge\s+([a-z0-9_-]+\.[a-z0-9_-]+)\s+with\s+([a-z0-9_-]+\.[a-z0-9_-]+)/gi,findMergeJoins=(e,r)=>{const o=r.matchAll(mergeJoinMatch);for(const s of o)e.mergeJoins.push({propertyA:s[2],propertyB:s[3]}),r=(0,_removeFromQuery.removeFromQuery)(s[0].trim(),r);return r};exports.findMergeJoins=findMergeJoins;
@@ -1,9 +1,9 @@
1
- import { ParsedQuery } from './parseQuery';
2
- export type ParsedOffset = number;
3
- /**
4
- * Extract the offset clauses from the query.
5
- * @param parsed
6
- * @param query
7
- */
8
- export declare const findOffset: (parsed: ParsedQuery, query: string) => string;
1
+ import { ParsedQuery } from './parseQuery';
2
+ export type ParsedOffset = number;
3
+ /**
4
+ * Extract the offset clauses from the query.
5
+ * @param parsed
6
+ * @param query
7
+ */
8
+ export declare const findOffset: (parsed: ParsedQuery, query: string) => string;
9
9
  //# sourceMappingURL=findOffset.d.ts.map
@@ -1,22 +1,22 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.findOffset = void 0
7
- const _removeFromQuery = require('./removeFromQuery')
8
- const offsetMatch = /offset\s*(\d+)/i
9
- /**
10
- * Extract the offset clauses from the query.
11
- * @param parsed
12
- * @param query
13
- */
14
- const findOffset = (parsed, query) => {
15
- const offsetFound = query.match(offsetMatch)
16
- if (offsetFound) {
17
- parsed.offset = offsetFound ? parseInt(offsetFound[1]) : undefined
18
- return (0, _removeFromQuery.removeFromQuery)(offsetFound[0], query)
19
- }
20
- return query
21
- }
22
- exports.findOffset = findOffset
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findOffset = void 0;
7
+ var _removeFromQuery = require("./removeFromQuery");
8
+ const offsetMatch = /offset\s*(\d+)/i;
9
+ /**
10
+ * Extract the offset clauses from the query.
11
+ * @param parsed
12
+ * @param query
13
+ */
14
+ const findOffset = (parsed, query) => {
15
+ const offsetFound = query.match(offsetMatch);
16
+ if (offsetFound) {
17
+ parsed['offset'] = offsetFound ? parseInt(offsetFound[1]) : undefined;
18
+ return (0, _removeFromQuery.removeFromQuery)(offsetFound[0], query);
19
+ }
20
+ return query;
21
+ };
22
+ exports.findOffset = findOffset;
@@ -1,12 +1,12 @@
1
- import { ParsedQuery } from './parseQuery';
2
- export type ParsedSelect = {
3
- property: string;
4
- alias: string | undefined;
5
- };
6
- /**
7
- * Extract select clauses from the query.
8
- * @param parsed
9
- * @param query
10
- */
11
- export declare const findSelects: (parsed: ParsedQuery, query: string) => string;
1
+ import { ParsedQuery } from './parseQuery';
2
+ export type ParsedSelect = {
3
+ property: string;
4
+ alias: string | undefined;
5
+ };
6
+ /**
7
+ * Extract select clauses from the query.
8
+ * @param parsed
9
+ * @param query
10
+ */
11
+ export declare const findSelects: (parsed: ParsedQuery, query: string) => string;
12
12
  //# sourceMappingURL=findSelects.d.ts.map
@@ -1,30 +1,30 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.findSelects = void 0
7
- const _removeFromQuery = require('./removeFromQuery')
8
- const selectClausesMatch = /select\s+([a-z0-9=._-]+\s*(as\s+)?([a-z0-9_-]+)?)+\s*(,\s*[a-z0-9=._-]+\s*(as\s*[a-z0-9_-]+)?)*/i
9
- const selectClauseMatch = /(select)?\s*,?\s*([a-z0-9=._-]+)\s*(as\s+)?([a-z0-9_-]+)?/ig
10
- /**
11
- * Extract select clauses from the query.
12
- * @param parsed
13
- * @param query
14
- */
15
- const findSelects = (parsed, query) => {
16
- const selectsFound = query.match(selectClausesMatch)
17
- if (selectsFound) {
18
- const selectClausesFound = selectsFound[0].matchAll(selectClauseMatch)
19
- // @ts-ignore
20
- for (const selectClause of selectClausesFound) {
21
- parsed.selectClauses.push({
22
- property: selectClause[2],
23
- alias: selectClause[4]
24
- })
25
- }
26
- return (0, _removeFromQuery.removeFromQuery)(selectsFound[0], query)
27
- }
28
- return query
29
- }
30
- exports.findSelects = findSelects
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findSelects = void 0;
7
+ var _removeFromQuery = require("./removeFromQuery");
8
+ const selectClausesMatch = /select\s+([a-z0-9=._-]+\s*(as\s+)?([a-z0-9_-]+)?)+\s*(,\s*[a-z0-9=._-]+\s*(as\s*[a-z0-9_-]+)?)*/i;
9
+ const selectClauseMatch = /(select)?\s*,?\s*([a-z0-9=._-]+)\s*(as\s+)?([a-z0-9_-]+)?/ig;
10
+ /**
11
+ * Extract select clauses from the query.
12
+ * @param parsed
13
+ * @param query
14
+ */
15
+ const findSelects = (parsed, query) => {
16
+ const selectsFound = query.match(selectClausesMatch);
17
+ if (selectsFound) {
18
+ const selectClausesFound = selectsFound[0].matchAll(selectClauseMatch);
19
+ // @ts-ignore
20
+ for (const selectClause of selectClausesFound) {
21
+ parsed['selectClauses'].push({
22
+ property: selectClause[2],
23
+ alias: selectClause[4]
24
+ });
25
+ }
26
+ return (0, _removeFromQuery.removeFromQuery)(selectsFound[0], query);
27
+ }
28
+ return query;
29
+ };
30
+ exports.findSelects = findSelects;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findSelects=void 0;var _removeFromQuery=require("./removeFromQuery");const selectClausesMatch=/select\s+([a-z0-9=._-]+\s*(as\s+)?([a-z0-9_-]+)?)+\s*(,\s*[a-z0-9=._-]+\s*(as\s*[a-z0-9_-]+)?)*/i,selectClauseMatch=/(select)?\s*,?\s*([a-z0-9=._-]+)\s*(as\s+)?([a-z0-9_-]+)?/gi,findSelects=(e,s)=>{const t=s.match(selectClausesMatch);if(t){const r=t[0].matchAll(selectClauseMatch);for(let s of r)e.selectClauses.push({property:s[2],alias:s[4]});return(0,_removeFromQuery.removeFromQuery)(t[0],s)}return s};exports.findSelects=findSelects;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findSelects=void 0;var _removeFromQuery=require("./removeFromQuery");const selectClausesMatch=/select\s+([a-z0-9=._-]+\s*(as\s+)?([a-z0-9_-]+)?)+\s*(,\s*[a-z0-9=._-]+\s*(as\s*[a-z0-9_-]+)?)*/i,selectClauseMatch=/(select)?\s*,?\s*([a-z0-9=._-]+)\s*(as\s+)?([a-z0-9_-]+)?/gi,findSelects=(e,s)=>{const t=s.match(selectClausesMatch);if(t){const r=t[0].matchAll(selectClauseMatch);for(const s of r)e.selectClauses.push({property:s[2],alias:s[4]});return(0,_removeFromQuery.removeFromQuery)(t[0],s)}return s};exports.findSelects=findSelects;
@@ -1,12 +1,12 @@
1
- import { ParsedQuery } from './parseQuery';
2
- export type ParsedSortClause = {
3
- property: string;
4
- direction: string | 'asc' | 'desc';
5
- };
6
- /**
7
- * Extract sort clauses from the query.
8
- * @param parsed
9
- * @param query
10
- */
11
- export declare const findSortClauses: (parsed: ParsedQuery, query: string) => string;
1
+ import { ParsedQuery } from './parseQuery';
2
+ export type ParsedSortClause = {
3
+ property: string;
4
+ direction: string | 'asc' | 'desc';
5
+ };
6
+ /**
7
+ * Extract sort clauses from the query.
8
+ * @param parsed
9
+ * @param query
10
+ */
11
+ export declare const findSortClauses: (parsed: ParsedQuery, query: string) => string;
12
12
  //# sourceMappingURL=findSortClauses.d.ts.map
@@ -1,30 +1,30 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.findSortClauses = void 0
7
- const _removeFromQuery = require('./removeFromQuery')
8
- const sortMatch = /sort\s+([a-z0-9._-]+\s*(asc|desc)?)+\s*(,\s*[a-z0-9._-]+\s*(asc|desc)?)*/i
9
- const sortRuleMatch = /(sort)?\s*,?\s*([a-z0-9._-]+)\s*(asc|desc)?/ig
10
- /**
11
- * Extract sort clauses from the query.
12
- * @param parsed
13
- * @param query
14
- */
15
- const findSortClauses = (parsed, query) => {
16
- const sortFound = query.match(sortMatch)
17
- if (sortFound) {
18
- const sortRulesFound = sortFound[0].matchAll(sortRuleMatch)
19
- // @ts-ignore
20
- for (const sortClause of sortRulesFound) {
21
- parsed.sortClauses.push({
22
- property: sortClause[2],
23
- direction: sortClause[3] || 'asc'
24
- })
25
- }
26
- return (0, _removeFromQuery.removeFromQuery)(sortFound[0], query)
27
- }
28
- return query
29
- }
30
- exports.findSortClauses = findSortClauses
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findSortClauses = void 0;
7
+ var _removeFromQuery = require("./removeFromQuery");
8
+ const sortMatch = /sort\s+([a-z0-9._-]+\s*(asc|desc)?)+\s*(,\s*[a-z0-9._-]+\s*(asc|desc)?)*/i;
9
+ const sortRuleMatch = /(sort)?\s*,?\s*([a-z0-9._-]+)\s*(asc|desc)?/ig;
10
+ /**
11
+ * Extract sort clauses from the query.
12
+ * @param parsed
13
+ * @param query
14
+ */
15
+ const findSortClauses = (parsed, query) => {
16
+ const sortFound = query.match(sortMatch);
17
+ if (sortFound) {
18
+ const sortRulesFound = sortFound[0].matchAll(sortRuleMatch);
19
+ // @ts-ignore
20
+ for (const sortClause of sortRulesFound) {
21
+ parsed['sortClauses'].push({
22
+ property: sortClause[2],
23
+ direction: sortClause[3] || 'asc'
24
+ });
25
+ }
26
+ return (0, _removeFromQuery.removeFromQuery)(sortFound[0], query);
27
+ }
28
+ return query;
29
+ };
30
+ exports.findSortClauses = findSortClauses;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findSortClauses=void 0;var _removeFromQuery=require("./removeFromQuery");const sortMatch=/sort\s+([a-z0-9._-]+\s*(asc|desc)?)+\s*(,\s*[a-z0-9._-]+\s*(asc|desc)?)*/i,sortRuleMatch=/(sort)?\s*,?\s*([a-z0-9._-]+)\s*(asc|desc)?/gi,findSortClauses=(s,e)=>{const r=e.match(sortMatch);if(r){const o=r[0].matchAll(sortRuleMatch);for(let e of o)s.sortClauses.push({property:e[2],direction:e[3]||"asc"});return(0,_removeFromQuery.removeFromQuery)(r[0],e)}return e};exports.findSortClauses=findSortClauses;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findSortClauses=void 0;var _removeFromQuery=require("./removeFromQuery");const sortMatch=/sort\s+([a-z0-9._-]+\s*(asc|desc)?)+\s*(,\s*[a-z0-9._-]+\s*(asc|desc)?)*/i,sortRuleMatch=/(sort)?\s*,?\s*([a-z0-9._-]+)\s*(asc|desc)?/gi,findSortClauses=(s,r)=>{const e=r.match(sortMatch);if(e){const o=e[0].matchAll(sortRuleMatch);for(const r of o)s.sortClauses.push({property:r[2],direction:r[3]||"asc"});return(0,_removeFromQuery.removeFromQuery)(e[0],r)}return r};exports.findSortClauses=findSortClauses;
@@ -1,15 +1,15 @@
1
- import { ParsedQuery } from './parseQuery';
2
- export type ParsedUpdateValues = {
3
- [field: string]: any;
4
- };
5
- /**
6
- * Extract an update's "set field = value, field2 = value2" clause from the query. Uses a two-pass
7
- * match, unlike the other parsers here: the set clause's own boundary is found first (so it can
8
- * be removed from the query as a whole, and so the comma-separated list doesn't get confused with
9
- * anything that follows, like a where clause), then each individual assignment is parsed out of
10
- * that captured substring.
11
- * @param parsed
12
- * @param query
13
- */
14
- export declare const findUpdateValues: (parsed: ParsedQuery, query: string) => string;
1
+ import { ParsedQuery } from './parseQuery';
2
+ export type ParsedUpdateValues = {
3
+ [field: string]: any;
4
+ };
5
+ /**
6
+ * Extract an update's "set field = value, field2 = value2" clause from the query. Uses a two-pass
7
+ * match, unlike the other parsers here: the set clause's own boundary is found first (so it can
8
+ * be removed from the query as a whole, and so the comma-separated list doesn't get confused with
9
+ * anything that follows, like a where clause), then each individual assignment is parsed out of
10
+ * that captured substring.
11
+ * @param parsed
12
+ * @param query
13
+ */
14
+ export declare const findUpdateValues: (parsed: ParsedQuery, query: string) => string;
15
15
  //# sourceMappingURL=findUpdateValues.d.ts.map
@@ -1,34 +1,34 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.findUpdateValues = void 0
7
- const _removeFromQuery = require('./removeFromQuery')
8
- const _parseLiteralValue = require('./parseLiteralValue')
9
- const literal = '(?:["\'][^"\']*[\'"]|[0-9]+|\\[.*?]|null|true|false)'
10
- const setClauseMatch = new RegExp(`(set)\\s+([a-z0-9_-]+\\s*=\\s*${literal}(?:\\s*,\\s*[a-z0-9_-]+\\s*=\\s*${literal})*)`, 'i')
11
- const assignmentMatch = /([a-z0-9_-]+)\s*=\s*(["'](.*?)['"]|([0-9]+)|(\[.*?])|(null)|(true)|(false))/ig
12
- /**
13
- * Extract an update's "set field = value, field2 = value2" clause from the query. Uses a two-pass
14
- * match, unlike the other parsers here: the set clause's own boundary is found first (so it can
15
- * be removed from the query as a whole, and so the comma-separated list doesn't get confused with
16
- * anything that follows, like a where clause), then each individual assignment is parsed out of
17
- * that captured substring.
18
- * @param parsed
19
- * @param query
20
- */
21
- const findUpdateValues = (parsed, query) => {
22
- const clauseFound = query.match(setClauseMatch)
23
- parsed.updateValues = {}
24
- if (!clauseFound) {
25
- return query
26
- }
27
- const assignmentsFound = clauseFound[2].matchAll(assignmentMatch)
28
- // @ts-ignore
29
- for (const assignment of assignmentsFound) {
30
- parsed.updateValues[assignment[1]] = (0, _parseLiteralValue.parseLiteralValue)(assignment, 3)
31
- }
32
- return (0, _removeFromQuery.removeFromQuery)(clauseFound[0], query)
33
- }
34
- exports.findUpdateValues = findUpdateValues
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findUpdateValues = void 0;
7
+ var _removeFromQuery = require("./removeFromQuery");
8
+ var _parseLiteralValue = require("./parseLiteralValue");
9
+ const literal = '(?:["\'][^"\']*[\'"]|[0-9]+|\\[.*?]|null|true|false)';
10
+ const setClauseMatch = new RegExp(`(set)\\s+([a-z0-9_-]+\\s*=\\s*${literal}(?:\\s*,\\s*[a-z0-9_-]+\\s*=\\s*${literal})*)`, 'i');
11
+ const assignmentMatch = /([a-z0-9_-]+)\s*=\s*(["'](.*?)['"]|([0-9]+)|(\[.*?])|(null)|(true)|(false))/ig;
12
+ /**
13
+ * Extract an update's "set field = value, field2 = value2" clause from the query. Uses a two-pass
14
+ * match, unlike the other parsers here: the set clause's own boundary is found first (so it can
15
+ * be removed from the query as a whole, and so the comma-separated list doesn't get confused with
16
+ * anything that follows, like a where clause), then each individual assignment is parsed out of
17
+ * that captured substring.
18
+ * @param parsed
19
+ * @param query
20
+ */
21
+ const findUpdateValues = (parsed, query) => {
22
+ const clauseFound = query.match(setClauseMatch);
23
+ parsed['updateValues'] = {};
24
+ if (!clauseFound) {
25
+ return query;
26
+ }
27
+ const assignmentsFound = clauseFound[2].matchAll(assignmentMatch);
28
+ // @ts-ignore
29
+ for (const assignment of assignmentsFound) {
30
+ parsed['updateValues'][assignment[1]] = (0, _parseLiteralValue.parseLiteralValue)(assignment, 3);
31
+ }
32
+ return (0, _removeFromQuery.removeFromQuery)(clauseFound[0], query);
33
+ };
34
+ exports.findUpdateValues = findUpdateValues;
@@ -1,8 +1,8 @@
1
- 'use strict'
1
+ "use strict";
2
2
 
3
- Object.defineProperty(exports, '__esModule', {
3
+ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- })
6
- exports.isEntityProperty = void 0
7
- const isEntityProperty = property => /^[a-z0-9_-]+\.([a-z0-9_-]+)$/i.test(property)
8
- exports.isEntityProperty = isEntityProperty
5
+ });
6
+ exports.isEntityProperty = void 0;
7
+ const isEntityProperty = property => /^[a-z0-9_-]+\.([a-z0-9_-]+)$/i.test(property);
8
+ exports.isEntityProperty = isEntityProperty;
@@ -1,12 +1,12 @@
1
- export type LiteralValue = string | number | boolean | null | any[];
2
- /**
3
- * Several parsers (findConditions, findInsertValues, findUpdateValues) capture a query-string
4
- * literal into one of six consecutive alternation groups depending on its shape - quoted string,
5
- * number, array, null, true, false - since a single regex can't otherwise tell them apart. Given
6
- * the match and the index of the first of those six groups (which shifts depending on how many
7
- * groups come before it in the parent regex), return the literal with its real JS type.
8
- * @param match
9
- * @param baseIndex
10
- */
11
- export declare const parseLiteralValue: (match: RegExpMatchArray, baseIndex: number) => LiteralValue;
1
+ export type LiteralValue = string | number | boolean | null | any[];
2
+ /**
3
+ * Several parsers (findConditions, findInsertValues, findUpdateValues) capture a query-string
4
+ * literal into one of six consecutive alternation groups depending on its shape - quoted string,
5
+ * number, array, null, true, false - since a single regex can't otherwise tell them apart. Given
6
+ * the match and the index of the first of those six groups (which shifts depending on how many
7
+ * groups come before it in the parent regex), return the literal with its real JS type.
8
+ * @param match
9
+ * @param baseIndex
10
+ */
11
+ export declare const parseLiteralValue: (match: RegExpMatchArray, baseIndex: number) => LiteralValue;
12
12
  //# sourceMappingURL=parseLiteralValue.d.ts.map
@@ -1,34 +1,34 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.parseLiteralValue = void 0
7
- /**
8
- * Several parsers (findConditions, findInsertValues, findUpdateValues) capture a query-string
9
- * literal into one of six consecutive alternation groups depending on its shape - quoted string,
10
- * number, array, null, true, false - since a single regex can't otherwise tell them apart. Given
11
- * the match and the index of the first of those six groups (which shifts depending on how many
12
- * groups come before it in the parent regex), return the literal with its real JS type.
13
- * @param match
14
- * @param baseIndex
15
- */
16
- const parseLiteralValue = (match, baseIndex) => {
17
- if (typeof match[baseIndex] !== 'undefined') {
18
- return match[baseIndex]
19
- }
20
- if (typeof match[baseIndex + 1] !== 'undefined') {
21
- return Number(match[baseIndex + 1])
22
- }
23
- if (typeof match[baseIndex + 2] !== 'undefined') {
24
- return JSON.parse(match[baseIndex + 2])
25
- }
26
- if (typeof match[baseIndex + 3] !== 'undefined') {
27
- return null
28
- }
29
- if (typeof match[baseIndex + 4] !== 'undefined') {
30
- return true
31
- }
32
- return false
33
- }
34
- exports.parseLiteralValue = parseLiteralValue
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseLiteralValue = void 0;
7
+ /**
8
+ * Several parsers (findConditions, findInsertValues, findUpdateValues) capture a query-string
9
+ * literal into one of six consecutive alternation groups depending on its shape - quoted string,
10
+ * number, array, null, true, false - since a single regex can't otherwise tell them apart. Given
11
+ * the match and the index of the first of those six groups (which shifts depending on how many
12
+ * groups come before it in the parent regex), return the literal with its real JS type.
13
+ * @param match
14
+ * @param baseIndex
15
+ */
16
+ const parseLiteralValue = (match, baseIndex) => {
17
+ if (typeof match[baseIndex] !== 'undefined') {
18
+ return match[baseIndex];
19
+ }
20
+ if (typeof match[baseIndex + 1] !== 'undefined') {
21
+ return Number(match[baseIndex + 1]);
22
+ }
23
+ if (typeof match[baseIndex + 2] !== 'undefined') {
24
+ return JSON.parse(match[baseIndex + 2]);
25
+ }
26
+ if (typeof match[baseIndex + 3] !== 'undefined') {
27
+ return null;
28
+ }
29
+ if (typeof match[baseIndex + 4] !== 'undefined') {
30
+ return true;
31
+ }
32
+ return false;
33
+ };
34
+ exports.parseLiteralValue = parseLiteralValue;