@query-doctor/core 0.8.1 → 0.8.2-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.cjs +13 -0
  2. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.mjs +13 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.cjs +15 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.mjs +15 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.cjs +10 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.mjs +10 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.cjs +17 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.mjs +12 -0
  9. package/dist/_virtual/_rolldown/runtime.cjs +24 -0
  10. package/dist/index.cjs +33 -2568
  11. package/dist/index.d.cts +11 -781
  12. package/dist/index.d.mts +11 -781
  13. package/dist/index.mjs +10 -2522
  14. package/dist/optimizer/genalgo.cjs +365 -0
  15. package/dist/optimizer/genalgo.cjs.map +1 -0
  16. package/dist/optimizer/genalgo.d.cts +111 -0
  17. package/dist/optimizer/genalgo.d.cts.map +1 -0
  18. package/dist/optimizer/genalgo.d.mts +111 -0
  19. package/dist/optimizer/genalgo.d.mts.map +1 -0
  20. package/dist/optimizer/genalgo.mjs +362 -0
  21. package/dist/optimizer/genalgo.mjs.map +1 -0
  22. package/dist/optimizer/pss-rewriter.cjs +31 -0
  23. package/dist/optimizer/pss-rewriter.cjs.map +1 -0
  24. package/dist/optimizer/pss-rewriter.d.cts +16 -0
  25. package/dist/optimizer/pss-rewriter.d.cts.map +1 -0
  26. package/dist/optimizer/pss-rewriter.d.mts +16 -0
  27. package/dist/optimizer/pss-rewriter.d.mts.map +1 -0
  28. package/dist/optimizer/pss-rewriter.mjs +31 -0
  29. package/dist/optimizer/pss-rewriter.mjs.map +1 -0
  30. package/dist/optimizer/statistics.cjs +738 -0
  31. package/dist/optimizer/statistics.cjs.map +1 -0
  32. package/dist/optimizer/statistics.d.cts +389 -0
  33. package/dist/optimizer/statistics.d.cts.map +1 -0
  34. package/dist/optimizer/statistics.d.mts +389 -0
  35. package/dist/optimizer/statistics.d.mts.map +1 -0
  36. package/dist/optimizer/statistics.mjs +729 -0
  37. package/dist/optimizer/statistics.mjs.map +1 -0
  38. package/dist/sentry.cjs +13 -0
  39. package/dist/sentry.cjs.map +1 -0
  40. package/dist/sentry.d.cts +7 -0
  41. package/dist/sentry.d.cts.map +1 -0
  42. package/dist/sentry.d.mts +7 -0
  43. package/dist/sentry.d.mts.map +1 -0
  44. package/dist/sentry.mjs +13 -0
  45. package/dist/sentry.mjs.map +1 -0
  46. package/dist/sql/analyzer.cjs +242 -0
  47. package/dist/sql/analyzer.cjs.map +1 -0
  48. package/dist/sql/analyzer.d.cts +112 -0
  49. package/dist/sql/analyzer.d.cts.map +1 -0
  50. package/dist/sql/analyzer.d.mts +112 -0
  51. package/dist/sql/analyzer.d.mts.map +1 -0
  52. package/dist/sql/analyzer.mjs +240 -0
  53. package/dist/sql/analyzer.mjs.map +1 -0
  54. package/dist/sql/ast-utils.cjs +19 -0
  55. package/dist/sql/ast-utils.cjs.map +1 -0
  56. package/dist/sql/ast-utils.d.cts +9 -0
  57. package/dist/sql/ast-utils.d.cts.map +1 -0
  58. package/dist/sql/ast-utils.d.mts +9 -0
  59. package/dist/sql/ast-utils.d.mts.map +1 -0
  60. package/dist/sql/ast-utils.mjs +17 -0
  61. package/dist/sql/ast-utils.mjs.map +1 -0
  62. package/dist/sql/builder.cjs +94 -0
  63. package/dist/sql/builder.cjs.map +1 -0
  64. package/dist/sql/builder.d.cts +37 -0
  65. package/dist/sql/builder.d.cts.map +1 -0
  66. package/dist/sql/builder.d.mts +37 -0
  67. package/dist/sql/builder.d.mts.map +1 -0
  68. package/dist/sql/builder.mjs +94 -0
  69. package/dist/sql/builder.mjs.map +1 -0
  70. package/dist/sql/database.cjs +35 -0
  71. package/dist/sql/database.cjs.map +1 -0
  72. package/dist/sql/database.d.cts +91 -0
  73. package/dist/sql/database.d.cts.map +1 -0
  74. package/dist/sql/database.d.mts +91 -0
  75. package/dist/sql/database.d.mts.map +1 -0
  76. package/dist/sql/database.mjs +32 -0
  77. package/dist/sql/database.mjs.map +1 -0
  78. package/dist/sql/indexes.cjs +17 -0
  79. package/dist/sql/indexes.cjs.map +1 -0
  80. package/dist/sql/indexes.d.cts +14 -0
  81. package/dist/sql/indexes.d.cts.map +1 -0
  82. package/dist/sql/indexes.d.mts +14 -0
  83. package/dist/sql/indexes.d.mts.map +1 -0
  84. package/dist/sql/indexes.mjs +16 -0
  85. package/dist/sql/indexes.mjs.map +1 -0
  86. package/dist/sql/nudges.cjs +484 -0
  87. package/dist/sql/nudges.cjs.map +1 -0
  88. package/dist/sql/nudges.d.cts +21 -0
  89. package/dist/sql/nudges.d.cts.map +1 -0
  90. package/dist/sql/nudges.d.mts +21 -0
  91. package/dist/sql/nudges.d.mts.map +1 -0
  92. package/dist/sql/nudges.mjs +484 -0
  93. package/dist/sql/nudges.mjs.map +1 -0
  94. package/dist/sql/permutations.cjs +28 -0
  95. package/dist/sql/permutations.cjs.map +1 -0
  96. package/dist/sql/permutations.mjs +28 -0
  97. package/dist/sql/permutations.mjs.map +1 -0
  98. package/dist/sql/pg-identifier.cjs +216 -0
  99. package/dist/sql/pg-identifier.cjs.map +1 -0
  100. package/dist/sql/pg-identifier.d.cts +31 -0
  101. package/dist/sql/pg-identifier.d.cts.map +1 -0
  102. package/dist/sql/pg-identifier.d.mts +31 -0
  103. package/dist/sql/pg-identifier.d.mts.map +1 -0
  104. package/dist/sql/pg-identifier.mjs +216 -0
  105. package/dist/sql/pg-identifier.mjs.map +1 -0
  106. package/dist/sql/walker.cjs +314 -0
  107. package/dist/sql/walker.cjs.map +1 -0
  108. package/dist/sql/walker.d.cts +15 -0
  109. package/dist/sql/walker.d.cts.map +1 -0
  110. package/dist/sql/walker.d.mts +15 -0
  111. package/dist/sql/walker.d.mts.map +1 -0
  112. package/dist/sql/walker.mjs +313 -0
  113. package/dist/sql/walker.mjs.map +1 -0
  114. package/package.json +2 -1
  115. package/dist/index.cjs.map +0 -1
  116. package/dist/index.d.cts.map +0 -1
  117. package/dist/index.d.mts.map +0 -1
  118. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,216 @@
1
+ "use client";
2
+ const require_defineProperty = require("../_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.cjs");
3
+ //#region src/sql/pg-identifier.ts
4
+ /**
5
+ * Represents an identifier in postgres that is subject
6
+ * to quoting rules. The {@link toString} rule behaves
7
+ * exactly like calling `select quote_ident($1)` in postgres
8
+ */
9
+ var PgIdentifier = class PgIdentifier {
10
+ constructor(value, quoted) {
11
+ this.value = value;
12
+ this.quoted = quoted;
13
+ }
14
+ /**
15
+ * Constructs an identifier from a single part (column or table name).
16
+ * When quoting identifiers like `select table.col` use {@link fromParts} instead
17
+ */
18
+ static fromString(identifier) {
19
+ const identifierRegex = /^[a-z_][a-z0-9_]*$/;
20
+ const match = identifier.match(/^"(.+)"$/);
21
+ if (match) {
22
+ const value = match[1];
23
+ return new PgIdentifier(value, !identifierRegex.test(value) || this.reservedKeywords.has(value.toLowerCase()));
24
+ }
25
+ return new PgIdentifier(identifier, !identifierRegex.test(identifier) || this.reservedKeywords.has(identifier.toLowerCase()));
26
+ }
27
+ /**
28
+ * Quotes parts of an identifier like `select schema.table.col`.
29
+ * A separate function is necessary because postgres will treat
30
+ * `select "HELLO.WORLD"` as a column name. It has to be like
31
+ * `select "HELLO"."WORLD"` instead.
32
+ */
33
+ static fromParts(...identifiers) {
34
+ return new PgIdentifier(identifiers.map((identifier) => {
35
+ if (typeof identifier === "string") return PgIdentifier.fromString(identifier);
36
+ else return identifier;
37
+ }).join("."), false);
38
+ }
39
+ toString() {
40
+ if (this.quoted) return `"${this.value.replace(/"/g, "\"\"")}"`;
41
+ return this.value;
42
+ }
43
+ toJSON() {
44
+ return this.toString();
45
+ }
46
+ };
47
+ require_defineProperty._defineProperty(PgIdentifier, "reservedKeywords", new Set([
48
+ "all",
49
+ "analyse",
50
+ "analyze",
51
+ "and",
52
+ "any",
53
+ "array",
54
+ "as",
55
+ "asc",
56
+ "asymmetric",
57
+ "authorization",
58
+ "between",
59
+ "bigint",
60
+ "binary",
61
+ "bit",
62
+ "boolean",
63
+ "both",
64
+ "case",
65
+ "cast",
66
+ "char",
67
+ "character",
68
+ "check",
69
+ "coalesce",
70
+ "collate",
71
+ "collation",
72
+ "column",
73
+ "concurrently",
74
+ "constraint",
75
+ "create",
76
+ "cross",
77
+ "current_catalog",
78
+ "current_date",
79
+ "current_role",
80
+ "current_schema",
81
+ "current_time",
82
+ "current_timestamp",
83
+ "current_user",
84
+ "dec",
85
+ "decimal",
86
+ "default",
87
+ "deferrable",
88
+ "desc",
89
+ "distinct",
90
+ "do",
91
+ "else",
92
+ "end",
93
+ "except",
94
+ "exists",
95
+ "extract",
96
+ "false",
97
+ "fetch",
98
+ "float",
99
+ "for",
100
+ "foreign",
101
+ "freeze",
102
+ "from",
103
+ "full",
104
+ "grant",
105
+ "greatest",
106
+ "group",
107
+ "grouping",
108
+ "having",
109
+ "ilike",
110
+ "in",
111
+ "initially",
112
+ "inner",
113
+ "inout",
114
+ "int",
115
+ "integer",
116
+ "intersect",
117
+ "interval",
118
+ "into",
119
+ "is",
120
+ "isnull",
121
+ "join",
122
+ "json",
123
+ "json_array",
124
+ "json_arrayagg",
125
+ "json_exists",
126
+ "json_object",
127
+ "json_objectagg",
128
+ "json_query",
129
+ "json_scalar",
130
+ "json_serialize",
131
+ "json_table",
132
+ "json_value",
133
+ "lateral",
134
+ "leading",
135
+ "least",
136
+ "left",
137
+ "like",
138
+ "limit",
139
+ "localtime",
140
+ "localtimestamp",
141
+ "merge_action",
142
+ "national",
143
+ "natural",
144
+ "nchar",
145
+ "none",
146
+ "normalize",
147
+ "not",
148
+ "notnull",
149
+ "null",
150
+ "nullif",
151
+ "numeric",
152
+ "offset",
153
+ "on",
154
+ "only",
155
+ "or",
156
+ "order",
157
+ "out",
158
+ "outer",
159
+ "overlaps",
160
+ "overlay",
161
+ "placing",
162
+ "position",
163
+ "precision",
164
+ "primary",
165
+ "real",
166
+ "references",
167
+ "returning",
168
+ "right",
169
+ "row",
170
+ "select",
171
+ "session_user",
172
+ "setof",
173
+ "similar",
174
+ "smallint",
175
+ "some",
176
+ "substring",
177
+ "symmetric",
178
+ "system_user",
179
+ "table",
180
+ "tablesample",
181
+ "then",
182
+ "time",
183
+ "timestamp",
184
+ "to",
185
+ "trailing",
186
+ "treat",
187
+ "trim",
188
+ "true",
189
+ "union",
190
+ "unique",
191
+ "user",
192
+ "using",
193
+ "values",
194
+ "varchar",
195
+ "variadic",
196
+ "verbose",
197
+ "when",
198
+ "where",
199
+ "window",
200
+ "with",
201
+ "xmlattributes",
202
+ "xmlconcat",
203
+ "xmlelement",
204
+ "xmlexists",
205
+ "xmlforest",
206
+ "xmlnamespaces",
207
+ "xmlparse",
208
+ "xmlpi",
209
+ "xmlroot",
210
+ "xmlserialize",
211
+ "xmltable"
212
+ ]));
213
+ //#endregion
214
+ exports.PgIdentifier = PgIdentifier;
215
+
216
+ //# sourceMappingURL=pg-identifier.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pg-identifier.cjs","names":[],"sources":["../../src/sql/pg-identifier.ts"],"sourcesContent":["/**\n * Represents an identifier in postgres that is subject\n * to quoting rules. The {@link toString} rule behaves\n * exactly like calling `select quote_ident($1)` in postgres\n */\nexport class PgIdentifier {\n private constructor(\n private readonly value: string,\n private readonly quoted: boolean,\n ) {}\n\n /**\n * Constructs an identifier from a single part (column or table name).\n * When quoting identifiers like `select table.col` use {@link fromParts} instead\n */\n static fromString(identifier: string): PgIdentifier {\n const identifierRegex = /^[a-z_][a-z0-9_]*$/;\n const match = identifier.match(/^\"(.+)\"$/);\n if (match) {\n const value = match[1];\n const quoted =\n !identifierRegex.test(value) ||\n this.reservedKeywords.has(value.toLowerCase());\n return new PgIdentifier(value, quoted);\n }\n const quoted =\n !identifierRegex.test(identifier) ||\n this.reservedKeywords.has(identifier.toLowerCase());\n return new PgIdentifier(identifier, quoted);\n }\n\n /**\n * Quotes parts of an identifier like `select schema.table.col`.\n * A separate function is necessary because postgres will treat\n * `select \"HELLO.WORLD\"` as a column name. It has to be like\n * `select \"HELLO\".\"WORLD\"` instead.\n */\n static fromParts(...identifiers: (string | PgIdentifier)[]): PgIdentifier {\n return new PgIdentifier(\n identifiers\n .map((identifier) => {\n if (typeof identifier === \"string\") {\n return PgIdentifier.fromString(identifier);\n } else {\n return identifier;\n }\n })\n .join(\".\"),\n false,\n );\n }\n\n toString(): string {\n if (this.quoted) {\n return `\"${this.value.replace(/\"/g, '\"\"')}\"`;\n }\n return this.value;\n }\n\n toJSON(): string {\n return this.toString();\n }\n\n // Every keyword that's not explicitly marked as\n // unreserved in src/include/parser/kwlist.h\n private static readonly reservedKeywords = new Set([\n \"all\",\n \"analyse\",\n \"analyze\",\n \"and\",\n \"any\",\n \"array\",\n \"as\",\n \"asc\",\n \"asymmetric\",\n \"authorization\",\n \"between\",\n \"bigint\",\n \"binary\",\n \"bit\",\n \"boolean\",\n \"both\",\n \"case\",\n \"cast\",\n \"char\",\n \"character\",\n \"check\",\n \"coalesce\",\n \"collate\",\n \"collation\",\n \"column\",\n \"concurrently\",\n \"constraint\",\n \"create\",\n \"cross\",\n \"current_catalog\",\n \"current_date\",\n \"current_role\",\n \"current_schema\",\n \"current_time\",\n \"current_timestamp\",\n \"current_user\",\n \"dec\",\n \"decimal\",\n \"default\",\n \"deferrable\",\n \"desc\",\n \"distinct\",\n \"do\",\n \"else\",\n \"end\",\n \"except\",\n \"exists\",\n \"extract\",\n \"false\",\n \"fetch\",\n \"float\",\n \"for\",\n \"foreign\",\n \"freeze\",\n \"from\",\n \"full\",\n \"grant\",\n \"greatest\",\n \"group\",\n \"grouping\",\n \"having\",\n \"ilike\",\n \"in\",\n \"initially\",\n \"inner\",\n \"inout\",\n \"int\",\n \"integer\",\n \"intersect\",\n \"interval\",\n \"into\",\n \"is\",\n \"isnull\",\n \"join\",\n \"json\",\n \"json_array\",\n \"json_arrayagg\",\n \"json_exists\",\n \"json_object\",\n \"json_objectagg\",\n \"json_query\",\n \"json_scalar\",\n \"json_serialize\",\n \"json_table\",\n \"json_value\",\n \"lateral\",\n \"leading\",\n \"least\",\n \"left\",\n \"like\",\n \"limit\",\n \"localtime\",\n \"localtimestamp\",\n \"merge_action\",\n \"national\",\n \"natural\",\n \"nchar\",\n \"none\",\n \"normalize\",\n \"not\",\n \"notnull\",\n \"null\",\n \"nullif\",\n \"numeric\",\n \"offset\",\n \"on\",\n \"only\",\n \"or\",\n \"order\",\n \"out\",\n \"outer\",\n \"overlaps\",\n \"overlay\",\n \"placing\",\n \"position\",\n \"precision\",\n \"primary\",\n \"real\",\n \"references\",\n \"returning\",\n \"right\",\n \"row\",\n \"select\",\n \"session_user\",\n \"setof\",\n \"similar\",\n \"smallint\",\n \"some\",\n \"substring\",\n \"symmetric\",\n \"system_user\",\n \"table\",\n \"tablesample\",\n \"then\",\n \"time\",\n \"timestamp\",\n \"to\",\n \"trailing\",\n \"treat\",\n \"trim\",\n \"true\",\n \"union\",\n \"unique\",\n \"user\",\n \"using\",\n \"values\",\n \"varchar\",\n \"variadic\",\n \"verbose\",\n \"when\",\n \"where\",\n \"window\",\n \"with\",\n \"xmlattributes\",\n \"xmlconcat\",\n \"xmlelement\",\n \"xmlexists\",\n \"xmlforest\",\n \"xmlnamespaces\",\n \"xmlparse\",\n \"xmlpi\",\n \"xmlroot\",\n \"xmlserialize\",\n \"xmltable\",\n ]);\n}\n"],"mappings":";;;;;;;;AAKA,IAAa,eAAb,MAAa,aAAa;CACxB,YACE,OACA,QACA;AAFiB,OAAA,QAAA;AACA,OAAA,SAAA;;;;;;CAOnB,OAAO,WAAW,YAAkC;EAClD,MAAM,kBAAkB;EACxB,MAAM,QAAQ,WAAW,MAAM,WAAW;AAC1C,MAAI,OAAO;GACT,MAAM,QAAQ,MAAM;AAIpB,UAAO,IAAI,aAAa,OAFtB,CAAC,gBAAgB,KAAK,MAAM,IAC5B,KAAK,iBAAiB,IAAI,MAAM,aAAa,CAAC,CACV;;AAKxC,SAAO,IAAI,aAAa,YAFtB,CAAC,gBAAgB,KAAK,WAAW,IACjC,KAAK,iBAAiB,IAAI,WAAW,aAAa,CAAC,CACV;;;;;;;;CAS7C,OAAO,UAAU,GAAG,aAAsD;AACxE,SAAO,IAAI,aACT,YACG,KAAK,eAAe;AACnB,OAAI,OAAO,eAAe,SACxB,QAAO,aAAa,WAAW,WAAW;OAE1C,QAAO;IAET,CACD,KAAK,IAAI,EACZ,MACD;;CAGH,WAAmB;AACjB,MAAI,KAAK,OACP,QAAO,IAAI,KAAK,MAAM,QAAQ,MAAM,OAAK,CAAC;AAE5C,SAAO,KAAK;;CAGd,SAAiB;AACf,SAAO,KAAK,UAAU;;;qDAKA,oBAAmB,IAAI,IAAI;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+
3
+ //#region src/sql/pg-identifier.d.ts
4
+ /**
5
+ * Represents an identifier in postgres that is subject
6
+ * to quoting rules. The {@link toString} rule behaves
7
+ * exactly like calling `select quote_ident($1)` in postgres
8
+ */
9
+ declare class PgIdentifier {
10
+ private readonly value;
11
+ private readonly quoted;
12
+ private constructor();
13
+ /**
14
+ * Constructs an identifier from a single part (column or table name).
15
+ * When quoting identifiers like `select table.col` use {@link fromParts} instead
16
+ */
17
+ static fromString(identifier: string): PgIdentifier;
18
+ /**
19
+ * Quotes parts of an identifier like `select schema.table.col`.
20
+ * A separate function is necessary because postgres will treat
21
+ * `select "HELLO.WORLD"` as a column name. It has to be like
22
+ * `select "HELLO"."WORLD"` instead.
23
+ */
24
+ static fromParts(...identifiers: (string | PgIdentifier)[]): PgIdentifier;
25
+ toString(): string;
26
+ toJSON(): string;
27
+ private static readonly reservedKeywords;
28
+ }
29
+ //#endregion
30
+ export { PgIdentifier };
31
+ //# sourceMappingURL=pg-identifier.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pg-identifier.d.cts","names":[],"sources":["../../src/sql/pg-identifier.ts"],"mappings":";;;;;AAKA;;;cAAa,YAAA;EAAA,iBAEQ,KAAA;EAAA,iBACA,MAAA;EAAA,QAFZ,WAAA,CAAA;EA+BkE;;;;EAAA,OAtBlE,UAAA,CAAW,UAAA,WAAqB,YAAA;EAArB;;;;;;EAAA,OAsBX,SAAA,CAAA,GAAa,WAAA,YAAuB,YAAA,MAAkB,YAAA;EAe7D,QAAA,CAAA;EAOA,MAAA,CAAA;EAAA,wBAMwB,gBAAA;AAAA"}
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+
3
+ //#region src/sql/pg-identifier.d.ts
4
+ /**
5
+ * Represents an identifier in postgres that is subject
6
+ * to quoting rules. The {@link toString} rule behaves
7
+ * exactly like calling `select quote_ident($1)` in postgres
8
+ */
9
+ declare class PgIdentifier {
10
+ private readonly value;
11
+ private readonly quoted;
12
+ private constructor();
13
+ /**
14
+ * Constructs an identifier from a single part (column or table name).
15
+ * When quoting identifiers like `select table.col` use {@link fromParts} instead
16
+ */
17
+ static fromString(identifier: string): PgIdentifier;
18
+ /**
19
+ * Quotes parts of an identifier like `select schema.table.col`.
20
+ * A separate function is necessary because postgres will treat
21
+ * `select "HELLO.WORLD"` as a column name. It has to be like
22
+ * `select "HELLO"."WORLD"` instead.
23
+ */
24
+ static fromParts(...identifiers: (string | PgIdentifier)[]): PgIdentifier;
25
+ toString(): string;
26
+ toJSON(): string;
27
+ private static readonly reservedKeywords;
28
+ }
29
+ //#endregion
30
+ export { PgIdentifier };
31
+ //# sourceMappingURL=pg-identifier.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pg-identifier.d.mts","names":[],"sources":["../../src/sql/pg-identifier.ts"],"mappings":";;;;;AAKA;;;cAAa,YAAA;EAAA,iBAEQ,KAAA;EAAA,iBACA,MAAA;EAAA,QAFZ,WAAA,CAAA;EA+BkE;;;;EAAA,OAtBlE,UAAA,CAAW,UAAA,WAAqB,YAAA;EAArB;;;;;;EAAA,OAsBX,SAAA,CAAA,GAAa,WAAA,YAAuB,YAAA,MAAkB,YAAA;EAe7D,QAAA,CAAA;EAOA,MAAA,CAAA;EAAA,wBAMwB,gBAAA;AAAA"}
@@ -0,0 +1,216 @@
1
+ "use client";
2
+ import { _defineProperty } from "../_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.mjs";
3
+ //#region src/sql/pg-identifier.ts
4
+ /**
5
+ * Represents an identifier in postgres that is subject
6
+ * to quoting rules. The {@link toString} rule behaves
7
+ * exactly like calling `select quote_ident($1)` in postgres
8
+ */
9
+ var PgIdentifier = class PgIdentifier {
10
+ constructor(value, quoted) {
11
+ this.value = value;
12
+ this.quoted = quoted;
13
+ }
14
+ /**
15
+ * Constructs an identifier from a single part (column or table name).
16
+ * When quoting identifiers like `select table.col` use {@link fromParts} instead
17
+ */
18
+ static fromString(identifier) {
19
+ const identifierRegex = /^[a-z_][a-z0-9_]*$/;
20
+ const match = identifier.match(/^"(.+)"$/);
21
+ if (match) {
22
+ const value = match[1];
23
+ return new PgIdentifier(value, !identifierRegex.test(value) || this.reservedKeywords.has(value.toLowerCase()));
24
+ }
25
+ return new PgIdentifier(identifier, !identifierRegex.test(identifier) || this.reservedKeywords.has(identifier.toLowerCase()));
26
+ }
27
+ /**
28
+ * Quotes parts of an identifier like `select schema.table.col`.
29
+ * A separate function is necessary because postgres will treat
30
+ * `select "HELLO.WORLD"` as a column name. It has to be like
31
+ * `select "HELLO"."WORLD"` instead.
32
+ */
33
+ static fromParts(...identifiers) {
34
+ return new PgIdentifier(identifiers.map((identifier) => {
35
+ if (typeof identifier === "string") return PgIdentifier.fromString(identifier);
36
+ else return identifier;
37
+ }).join("."), false);
38
+ }
39
+ toString() {
40
+ if (this.quoted) return `"${this.value.replace(/"/g, "\"\"")}"`;
41
+ return this.value;
42
+ }
43
+ toJSON() {
44
+ return this.toString();
45
+ }
46
+ };
47
+ _defineProperty(PgIdentifier, "reservedKeywords", new Set([
48
+ "all",
49
+ "analyse",
50
+ "analyze",
51
+ "and",
52
+ "any",
53
+ "array",
54
+ "as",
55
+ "asc",
56
+ "asymmetric",
57
+ "authorization",
58
+ "between",
59
+ "bigint",
60
+ "binary",
61
+ "bit",
62
+ "boolean",
63
+ "both",
64
+ "case",
65
+ "cast",
66
+ "char",
67
+ "character",
68
+ "check",
69
+ "coalesce",
70
+ "collate",
71
+ "collation",
72
+ "column",
73
+ "concurrently",
74
+ "constraint",
75
+ "create",
76
+ "cross",
77
+ "current_catalog",
78
+ "current_date",
79
+ "current_role",
80
+ "current_schema",
81
+ "current_time",
82
+ "current_timestamp",
83
+ "current_user",
84
+ "dec",
85
+ "decimal",
86
+ "default",
87
+ "deferrable",
88
+ "desc",
89
+ "distinct",
90
+ "do",
91
+ "else",
92
+ "end",
93
+ "except",
94
+ "exists",
95
+ "extract",
96
+ "false",
97
+ "fetch",
98
+ "float",
99
+ "for",
100
+ "foreign",
101
+ "freeze",
102
+ "from",
103
+ "full",
104
+ "grant",
105
+ "greatest",
106
+ "group",
107
+ "grouping",
108
+ "having",
109
+ "ilike",
110
+ "in",
111
+ "initially",
112
+ "inner",
113
+ "inout",
114
+ "int",
115
+ "integer",
116
+ "intersect",
117
+ "interval",
118
+ "into",
119
+ "is",
120
+ "isnull",
121
+ "join",
122
+ "json",
123
+ "json_array",
124
+ "json_arrayagg",
125
+ "json_exists",
126
+ "json_object",
127
+ "json_objectagg",
128
+ "json_query",
129
+ "json_scalar",
130
+ "json_serialize",
131
+ "json_table",
132
+ "json_value",
133
+ "lateral",
134
+ "leading",
135
+ "least",
136
+ "left",
137
+ "like",
138
+ "limit",
139
+ "localtime",
140
+ "localtimestamp",
141
+ "merge_action",
142
+ "national",
143
+ "natural",
144
+ "nchar",
145
+ "none",
146
+ "normalize",
147
+ "not",
148
+ "notnull",
149
+ "null",
150
+ "nullif",
151
+ "numeric",
152
+ "offset",
153
+ "on",
154
+ "only",
155
+ "or",
156
+ "order",
157
+ "out",
158
+ "outer",
159
+ "overlaps",
160
+ "overlay",
161
+ "placing",
162
+ "position",
163
+ "precision",
164
+ "primary",
165
+ "real",
166
+ "references",
167
+ "returning",
168
+ "right",
169
+ "row",
170
+ "select",
171
+ "session_user",
172
+ "setof",
173
+ "similar",
174
+ "smallint",
175
+ "some",
176
+ "substring",
177
+ "symmetric",
178
+ "system_user",
179
+ "table",
180
+ "tablesample",
181
+ "then",
182
+ "time",
183
+ "timestamp",
184
+ "to",
185
+ "trailing",
186
+ "treat",
187
+ "trim",
188
+ "true",
189
+ "union",
190
+ "unique",
191
+ "user",
192
+ "using",
193
+ "values",
194
+ "varchar",
195
+ "variadic",
196
+ "verbose",
197
+ "when",
198
+ "where",
199
+ "window",
200
+ "with",
201
+ "xmlattributes",
202
+ "xmlconcat",
203
+ "xmlelement",
204
+ "xmlexists",
205
+ "xmlforest",
206
+ "xmlnamespaces",
207
+ "xmlparse",
208
+ "xmlpi",
209
+ "xmlroot",
210
+ "xmlserialize",
211
+ "xmltable"
212
+ ]));
213
+ //#endregion
214
+ export { PgIdentifier };
215
+
216
+ //# sourceMappingURL=pg-identifier.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pg-identifier.mjs","names":[],"sources":["../../src/sql/pg-identifier.ts"],"sourcesContent":["/**\n * Represents an identifier in postgres that is subject\n * to quoting rules. The {@link toString} rule behaves\n * exactly like calling `select quote_ident($1)` in postgres\n */\nexport class PgIdentifier {\n private constructor(\n private readonly value: string,\n private readonly quoted: boolean,\n ) {}\n\n /**\n * Constructs an identifier from a single part (column or table name).\n * When quoting identifiers like `select table.col` use {@link fromParts} instead\n */\n static fromString(identifier: string): PgIdentifier {\n const identifierRegex = /^[a-z_][a-z0-9_]*$/;\n const match = identifier.match(/^\"(.+)\"$/);\n if (match) {\n const value = match[1];\n const quoted =\n !identifierRegex.test(value) ||\n this.reservedKeywords.has(value.toLowerCase());\n return new PgIdentifier(value, quoted);\n }\n const quoted =\n !identifierRegex.test(identifier) ||\n this.reservedKeywords.has(identifier.toLowerCase());\n return new PgIdentifier(identifier, quoted);\n }\n\n /**\n * Quotes parts of an identifier like `select schema.table.col`.\n * A separate function is necessary because postgres will treat\n * `select \"HELLO.WORLD\"` as a column name. It has to be like\n * `select \"HELLO\".\"WORLD\"` instead.\n */\n static fromParts(...identifiers: (string | PgIdentifier)[]): PgIdentifier {\n return new PgIdentifier(\n identifiers\n .map((identifier) => {\n if (typeof identifier === \"string\") {\n return PgIdentifier.fromString(identifier);\n } else {\n return identifier;\n }\n })\n .join(\".\"),\n false,\n );\n }\n\n toString(): string {\n if (this.quoted) {\n return `\"${this.value.replace(/\"/g, '\"\"')}\"`;\n }\n return this.value;\n }\n\n toJSON(): string {\n return this.toString();\n }\n\n // Every keyword that's not explicitly marked as\n // unreserved in src/include/parser/kwlist.h\n private static readonly reservedKeywords = new Set([\n \"all\",\n \"analyse\",\n \"analyze\",\n \"and\",\n \"any\",\n \"array\",\n \"as\",\n \"asc\",\n \"asymmetric\",\n \"authorization\",\n \"between\",\n \"bigint\",\n \"binary\",\n \"bit\",\n \"boolean\",\n \"both\",\n \"case\",\n \"cast\",\n \"char\",\n \"character\",\n \"check\",\n \"coalesce\",\n \"collate\",\n \"collation\",\n \"column\",\n \"concurrently\",\n \"constraint\",\n \"create\",\n \"cross\",\n \"current_catalog\",\n \"current_date\",\n \"current_role\",\n \"current_schema\",\n \"current_time\",\n \"current_timestamp\",\n \"current_user\",\n \"dec\",\n \"decimal\",\n \"default\",\n \"deferrable\",\n \"desc\",\n \"distinct\",\n \"do\",\n \"else\",\n \"end\",\n \"except\",\n \"exists\",\n \"extract\",\n \"false\",\n \"fetch\",\n \"float\",\n \"for\",\n \"foreign\",\n \"freeze\",\n \"from\",\n \"full\",\n \"grant\",\n \"greatest\",\n \"group\",\n \"grouping\",\n \"having\",\n \"ilike\",\n \"in\",\n \"initially\",\n \"inner\",\n \"inout\",\n \"int\",\n \"integer\",\n \"intersect\",\n \"interval\",\n \"into\",\n \"is\",\n \"isnull\",\n \"join\",\n \"json\",\n \"json_array\",\n \"json_arrayagg\",\n \"json_exists\",\n \"json_object\",\n \"json_objectagg\",\n \"json_query\",\n \"json_scalar\",\n \"json_serialize\",\n \"json_table\",\n \"json_value\",\n \"lateral\",\n \"leading\",\n \"least\",\n \"left\",\n \"like\",\n \"limit\",\n \"localtime\",\n \"localtimestamp\",\n \"merge_action\",\n \"national\",\n \"natural\",\n \"nchar\",\n \"none\",\n \"normalize\",\n \"not\",\n \"notnull\",\n \"null\",\n \"nullif\",\n \"numeric\",\n \"offset\",\n \"on\",\n \"only\",\n \"or\",\n \"order\",\n \"out\",\n \"outer\",\n \"overlaps\",\n \"overlay\",\n \"placing\",\n \"position\",\n \"precision\",\n \"primary\",\n \"real\",\n \"references\",\n \"returning\",\n \"right\",\n \"row\",\n \"select\",\n \"session_user\",\n \"setof\",\n \"similar\",\n \"smallint\",\n \"some\",\n \"substring\",\n \"symmetric\",\n \"system_user\",\n \"table\",\n \"tablesample\",\n \"then\",\n \"time\",\n \"timestamp\",\n \"to\",\n \"trailing\",\n \"treat\",\n \"trim\",\n \"true\",\n \"union\",\n \"unique\",\n \"user\",\n \"using\",\n \"values\",\n \"varchar\",\n \"variadic\",\n \"verbose\",\n \"when\",\n \"where\",\n \"window\",\n \"with\",\n \"xmlattributes\",\n \"xmlconcat\",\n \"xmlelement\",\n \"xmlexists\",\n \"xmlforest\",\n \"xmlnamespaces\",\n \"xmlparse\",\n \"xmlpi\",\n \"xmlroot\",\n \"xmlserialize\",\n \"xmltable\",\n ]);\n}\n"],"mappings":";;;;;;;;AAKA,IAAa,eAAb,MAAa,aAAa;CACxB,YACE,OACA,QACA;AAFiB,OAAA,QAAA;AACA,OAAA,SAAA;;;;;;CAOnB,OAAO,WAAW,YAAkC;EAClD,MAAM,kBAAkB;EACxB,MAAM,QAAQ,WAAW,MAAM,WAAW;AAC1C,MAAI,OAAO;GACT,MAAM,QAAQ,MAAM;AAIpB,UAAO,IAAI,aAAa,OAFtB,CAAC,gBAAgB,KAAK,MAAM,IAC5B,KAAK,iBAAiB,IAAI,MAAM,aAAa,CAAC,CACV;;AAKxC,SAAO,IAAI,aAAa,YAFtB,CAAC,gBAAgB,KAAK,WAAW,IACjC,KAAK,iBAAiB,IAAI,WAAW,aAAa,CAAC,CACV;;;;;;;;CAS7C,OAAO,UAAU,GAAG,aAAsD;AACxE,SAAO,IAAI,aACT,YACG,KAAK,eAAe;AACnB,OAAI,OAAO,eAAe,SACxB,QAAO,aAAa,WAAW,WAAW;OAE1C,QAAO;IAET,CACD,KAAK,IAAI,EACZ,MACD;;CAGH,WAAmB;AACjB,MAAI,KAAK,OACP,QAAO,IAAI,KAAK,MAAM,QAAQ,MAAM,OAAK,CAAC;AAE5C,SAAO,KAAK;;CAGd,SAAiB;AACf,SAAO,KAAK,UAAU;;;8BAKA,oBAAmB,IAAI,IAAI;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC,CAAC"}