@intentius/chant-lexicon-sql 0.121.1 → 0.122.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 (150) hide show
  1. package/dist/clickhouse/catalog-types.d.ts +8 -0
  2. package/dist/clickhouse/catalog-types.d.ts.map +1 -1
  3. package/dist/clickhouse/overlays/codecs.d.ts.map +1 -1
  4. package/dist/clickhouse/overlays/kinds.d.ts +1 -1
  5. package/dist/clickhouse/overlays/kinds.d.ts.map +1 -1
  6. package/dist/clickhouse/overlays/types.d.ts.map +1 -1
  7. package/dist/clickhouse/type-syntax.d.ts +33 -0
  8. package/dist/clickhouse/type-syntax.d.ts.map +1 -0
  9. package/dist/codegen/clickhouse-module.d.ts.map +1 -1
  10. package/dist/codegen/postgres-module.d.ts.map +1 -1
  11. package/dist/generated/clickhouse.d.ts +7 -1
  12. package/dist/generated/clickhouse.d.ts.map +1 -1
  13. package/dist/generated/postgres.d.ts +6 -0
  14. package/dist/generated/postgres.d.ts.map +1 -1
  15. package/dist/integrity.json +23 -5
  16. package/dist/lint/audit-catalog.d.ts.map +1 -1
  17. package/dist/lint/post-synth/audit-entries.d.ts.map +1 -1
  18. package/dist/lint/post-synth/clickhouse-type-check.d.ts +37 -0
  19. package/dist/lint/post-synth/clickhouse-type-check.d.ts.map +1 -0
  20. package/dist/lint/post-synth/index.d.ts.map +1 -1
  21. package/dist/lint/post-synth/postgres-audit-entries.d.ts.map +1 -1
  22. package/dist/lint/post-synth/postgres-names.d.ts +149 -0
  23. package/dist/lint/post-synth/postgres-names.d.ts.map +1 -0
  24. package/dist/lint/post-synth/sql101.d.ts +9 -0
  25. package/dist/lint/post-synth/sql101.d.ts.map +1 -0
  26. package/dist/lint/post-synth/sqlch121.d.ts +10 -0
  27. package/dist/lint/post-synth/sqlch121.d.ts.map +1 -0
  28. package/dist/lint/post-synth/sqlch122.d.ts +10 -0
  29. package/dist/lint/post-synth/sqlch122.d.ts.map +1 -0
  30. package/dist/lint/post-synth/sqlch123.d.ts +9 -0
  31. package/dist/lint/post-synth/sqlch123.d.ts.map +1 -0
  32. package/dist/lint/post-synth/sqlch124.d.ts +6 -0
  33. package/dist/lint/post-synth/sqlch124.d.ts.map +1 -0
  34. package/dist/lint/post-synth/sqlch125.d.ts +11 -0
  35. package/dist/lint/post-synth/sqlch125.d.ts.map +1 -0
  36. package/dist/lint/post-synth/sqlch126.d.ts +12 -0
  37. package/dist/lint/post-synth/sqlch126.d.ts.map +1 -0
  38. package/dist/lint/post-synth/sqlch127.d.ts +22 -0
  39. package/dist/lint/post-synth/sqlch127.d.ts.map +1 -0
  40. package/dist/lint/post-synth/sqlpg119.d.ts +18 -0
  41. package/dist/lint/post-synth/sqlpg119.d.ts.map +1 -0
  42. package/dist/lint/post-synth/sqlpg120.d.ts +17 -0
  43. package/dist/lint/post-synth/sqlpg120.d.ts.map +1 -0
  44. package/dist/lint/post-synth/sqlpg121.d.ts +12 -0
  45. package/dist/lint/post-synth/sqlpg121.d.ts.map +1 -0
  46. package/dist/lint/post-synth/sqlpg122.d.ts +12 -0
  47. package/dist/lint/post-synth/sqlpg122.d.ts.map +1 -0
  48. package/dist/lint/post-synth/sqlpg123.d.ts +17 -0
  49. package/dist/lint/post-synth/sqlpg123.d.ts.map +1 -0
  50. package/dist/lint/post-synth/sqlpg124.d.ts +16 -0
  51. package/dist/lint/post-synth/sqlpg124.d.ts.map +1 -0
  52. package/dist/lint/post-synth/sqlpg125.d.ts +17 -0
  53. package/dist/lint/post-synth/sqlpg125.d.ts.map +1 -0
  54. package/dist/lint/post-synth/sqlpg126.d.ts +19 -0
  55. package/dist/lint/post-synth/sqlpg126.d.ts.map +1 -0
  56. package/dist/manifest.json +1 -1
  57. package/dist/okf/index.md +16 -0
  58. package/dist/okf/rules/SQL101.md +23 -0
  59. package/dist/okf/rules/SQLCH121.md +11 -0
  60. package/dist/okf/rules/SQLCH122.md +11 -0
  61. package/dist/okf/rules/SQLCH123.md +11 -0
  62. package/dist/okf/rules/SQLCH124.md +18 -0
  63. package/dist/okf/rules/SQLCH125.md +11 -0
  64. package/dist/okf/rules/SQLCH126.md +15 -0
  65. package/dist/okf/rules/SQLCH127.md +15 -0
  66. package/dist/okf/rules/SQLPG119.md +16 -0
  67. package/dist/okf/rules/SQLPG120.md +16 -0
  68. package/dist/okf/rules/SQLPG121.md +11 -0
  69. package/dist/okf/rules/SQLPG122.md +15 -0
  70. package/dist/okf/rules/SQLPG123.md +16 -0
  71. package/dist/okf/rules/SQLPG124.md +11 -0
  72. package/dist/okf/rules/SQLPG125.md +11 -0
  73. package/dist/okf/rules/SQLPG126.md +11 -0
  74. package/dist/okf/types/Dictionary.md +4 -0
  75. package/dist/okf/types/Function.md +5 -0
  76. package/dist/okf/types/Grant.md +6 -0
  77. package/dist/okf/types/MaterializedView.md +1 -0
  78. package/dist/okf/types/PostgresDefaultPrivileges.md +4 -0
  79. package/dist/okf/types/PostgresDomain.md +2 -0
  80. package/dist/okf/types/PostgresEnum.md +1 -0
  81. package/dist/okf/types/PostgresFunction.md +4 -0
  82. package/dist/okf/types/PostgresGrant.md +5 -0
  83. package/dist/okf/types/PostgresPolicy.md +4 -0
  84. package/dist/okf/types/PostgresProcedure.md +4 -0
  85. package/dist/okf/types/PostgresSequence.md +2 -0
  86. package/dist/okf/types/PostgresTrigger.md +4 -0
  87. package/dist/okf/types/RowPolicy.md +4 -0
  88. package/dist/okf/types/Table.md +1 -0
  89. package/dist/okf/types/View.md +1 -0
  90. package/dist/postgres/overlays/extension-objects.d.ts +28 -0
  91. package/dist/postgres/overlays/extension-objects.d.ts.map +1 -0
  92. package/dist/postgres/overlays/types.d.ts +10 -0
  93. package/dist/postgres/overlays/types.d.ts.map +1 -1
  94. package/dist/rules/audit-entries.ts +7 -0
  95. package/dist/rules/clickhouse-type-check.ts +173 -0
  96. package/dist/rules/postgres-audit-entries.ts +8 -0
  97. package/dist/rules/postgres-names.ts +506 -0
  98. package/dist/rules/sql101.ts +62 -0
  99. package/dist/rules/sqlch121.ts +12 -0
  100. package/dist/rules/sqlch122.ts +12 -0
  101. package/dist/rules/sqlch123.ts +11 -0
  102. package/dist/rules/sqlch124.ts +21 -0
  103. package/dist/rules/sqlch125.ts +56 -0
  104. package/dist/rules/sqlch126.ts +57 -0
  105. package/dist/rules/sqlch127.ts +128 -0
  106. package/dist/rules/sqlpg119.ts +37 -0
  107. package/dist/rules/sqlpg120.ts +70 -0
  108. package/dist/rules/sqlpg121.ts +32 -0
  109. package/dist/rules/sqlpg122.ts +28 -0
  110. package/dist/rules/sqlpg123.ts +63 -0
  111. package/dist/rules/sqlpg124.ts +47 -0
  112. package/dist/rules/sqlpg125.ts +40 -0
  113. package/dist/rules/sqlpg126.ts +37 -0
  114. package/package.json +2 -2
  115. package/src/clickhouse/catalog-types.ts +9 -0
  116. package/src/clickhouse/overlays/codecs.ts +6 -2
  117. package/src/clickhouse/overlays/kinds.ts +1 -1
  118. package/src/clickhouse/overlays/types.ts +20 -3
  119. package/src/clickhouse/type-syntax.ts +82 -0
  120. package/src/codegen/clickhouse-module.ts +15 -1
  121. package/src/codegen/postgres-module.ts +43 -0
  122. package/src/composites/composites.test.ts +7 -6
  123. package/src/generated/clickhouse.ts +1905 -6
  124. package/src/generated/postgres.ts +2639 -0
  125. package/src/lint/audit-catalog.ts +8 -0
  126. package/src/lint/post-synth/audit-entries.ts +7 -0
  127. package/src/lint/post-synth/clickhouse-catalog-checks.test.ts +315 -0
  128. package/src/lint/post-synth/clickhouse-type-check.ts +173 -0
  129. package/src/lint/post-synth/index.ts +32 -0
  130. package/src/lint/post-synth/postgres-audit-entries.ts +8 -0
  131. package/src/lint/post-synth/postgres-checks.test.ts +214 -1
  132. package/src/lint/post-synth/postgres-names.ts +506 -0
  133. package/src/lint/post-synth/sql101.ts +62 -0
  134. package/src/lint/post-synth/sqlch121.ts +12 -0
  135. package/src/lint/post-synth/sqlch122.ts +12 -0
  136. package/src/lint/post-synth/sqlch123.ts +11 -0
  137. package/src/lint/post-synth/sqlch124.ts +21 -0
  138. package/src/lint/post-synth/sqlch125.ts +56 -0
  139. package/src/lint/post-synth/sqlch126.ts +57 -0
  140. package/src/lint/post-synth/sqlch127.ts +128 -0
  141. package/src/lint/post-synth/sqlpg119.ts +37 -0
  142. package/src/lint/post-synth/sqlpg120.ts +70 -0
  143. package/src/lint/post-synth/sqlpg121.ts +32 -0
  144. package/src/lint/post-synth/sqlpg122.ts +28 -0
  145. package/src/lint/post-synth/sqlpg123.ts +63 -0
  146. package/src/lint/post-synth/sqlpg124.ts +47 -0
  147. package/src/lint/post-synth/sqlpg125.ts +40 -0
  148. package/src/lint/post-synth/sqlpg126.ts +37 -0
  149. package/src/postgres/overlays/extension-objects.ts +100 -0
  150. package/src/postgres/overlays/types.ts +25 -0
@@ -0,0 +1,100 @@
1
+ /**
2
+ * What the common extensions add, for lint: the types, functions, index
3
+ * access methods and operator classes a declaration may name once the project
4
+ * declares the extension. The pinned catalogs are read from a server with no
5
+ * extension installed, so none of these are in them.
6
+ *
7
+ * The list is not exhaustive. A name the core catalog does not have and no
8
+ * entry here covers is reported as a warning when the project declares any
9
+ * extension (it may come from one), and as an error when it declares none.
10
+ * A name an entry here covers, used without that extension declared, is an
11
+ * error that names the extension.
12
+ *
13
+ * Sources: the reference page of each contrib module
14
+ * (https://www.postgresql.org/docs/18/contrib.html), PostGIS
15
+ * (https://postgis.net/docs/reference.html) and pgvector
16
+ * (https://github.com/pgvector/pgvector#reference).
17
+ */
18
+
19
+ export interface ExtensionObjects {
20
+ types?: readonly string[];
21
+ functions?: readonly string[];
22
+ /** Function name prefixes the extension owns (`st_` for PostGIS). */
23
+ functionPrefixes?: readonly string[];
24
+ accessMethods?: readonly string[];
25
+ /** Operator classes by access method. */
26
+ opclasses?: Readonly<Record<string, readonly string[]>>;
27
+ }
28
+
29
+ const BTREE_GIN = [
30
+ "int2_ops", "int4_ops", "int8_ops", "float4_ops", "float8_ops", "money_ops", "oid_ops", "timestamp_ops", "timestamptz_ops",
31
+ "time_ops", "timetz_ops", "date_ops", "interval_ops", "macaddr_ops", "macaddr8_ops", "inet_ops", "cidr_ops", "text_ops",
32
+ "varchar_ops", "char_ops", "bytea_ops", "bit_ops", "varbit_ops", "numeric_ops", "enum_ops", "uuid_ops", "name_ops",
33
+ "bool_ops", "bpchar_ops",
34
+ ];
35
+ const BTREE_GIST = [
36
+ "gist_int2_ops", "gist_int4_ops", "gist_int8_ops", "gist_float4_ops", "gist_float8_ops", "gist_numeric_ops", "gist_oid_ops",
37
+ "gist_timestamp_ops", "gist_timestamptz_ops", "gist_time_ops", "gist_timetz_ops", "gist_date_ops", "gist_interval_ops",
38
+ "gist_cash_ops", "gist_macaddr_ops", "gist_macaddr8_ops", "gist_text_ops", "gist_bpchar_ops", "gist_bytea_ops", "gist_bit_ops",
39
+ "gist_vbit_ops", "gist_inet_ops", "gist_cidr_ops", "gist_uuid_ops", "gist_enum_ops", "gist_bool_ops",
40
+ ];
41
+ const VECTOR_OPS = ["vector_l2_ops", "vector_ip_ops", "vector_cosine_ops", "vector_l1_ops", "halfvec_l2_ops", "halfvec_ip_ops", "halfvec_cosine_ops", "halfvec_l1_ops", "sparsevec_l2_ops", "sparsevec_ip_ops", "sparsevec_cosine_ops", "sparsevec_l1_ops", "bit_hamming_ops", "bit_jaccard_ops"];
42
+
43
+ export const EXTENSION_OBJECTS: Readonly<Record<string, ExtensionObjects>> = {
44
+ bloom: { accessMethods: ["bloom"], opclasses: { bloom: ["int4_ops", "text_ops"] } },
45
+ btree_gin: { opclasses: { gin: BTREE_GIN } },
46
+ btree_gist: { opclasses: { gist: BTREE_GIST } },
47
+ citext: { types: ["citext"], opclasses: { btree: ["citext_ops", "citext_pattern_ops"], hash: ["citext_ops"] } },
48
+ cube: { types: ["cube"], functions: ["cube", "cube_dim", "cube_ll_coord", "cube_ur_coord", "cube_is_point", "cube_enlarge", "cube_subset", "cube_union", "cube_inter", "cube_size", "cube_distance"], opclasses: { gist: ["gist_cube_ops"] } },
49
+ earthdistance: { types: ["earth"], functions: ["earth", "earth_distance", "earth_box", "ll_to_earth", "latitude", "longitude", "sec_to_gc", "gc_to_sec"] },
50
+ fuzzystrmatch: { functions: ["soundex", "difference", "levenshtein", "levenshtein_less_equal", "metaphone", "dmetaphone", "dmetaphone_alt", "daitch_mokotoff"] },
51
+ hstore: {
52
+ types: ["hstore"],
53
+ functions: ["hstore", "akeys", "avals", "skeys", "svals", "hstore_to_array", "hstore_to_matrix", "hstore_to_json", "hstore_to_jsonb", "hstore_to_json_loose", "hstore_to_jsonb_loose", "slice", "exist", "defined", "delete", "each", "populate_record"],
54
+ opclasses: { gist: ["gist_hstore_ops"], gin: ["gin_hstore_ops"], btree: ["btree_hstore_ops"], hash: ["hash_hstore_ops"] },
55
+ },
56
+ intarray: {
57
+ functions: ["icount", "sort", "sort_asc", "sort_desc", "uniq", "idx", "subarray", "intset"],
58
+ opclasses: { gist: ["gist__int_ops", "gist__intbig_ops"], gin: ["gin__int_ops"] },
59
+ },
60
+ isn: { types: ["ean13", "isbn", "isbn13", "ismn", "ismn13", "issn", "issn13", "upc"], functions: ["isn_weak", "make_valid", "is_valid"] },
61
+ ltree: {
62
+ types: ["ltree", "lquery", "ltxtquery"],
63
+ functions: ["subltree", "subpath", "nlevel", "index", "text2ltree", "ltree2text", "lca"],
64
+ opclasses: { gist: ["gist_ltree_ops", "gist__ltree_ops"], btree: ["ltree_ops"], hash: ["hash_ltree_ops"] },
65
+ },
66
+ pg_trgm: {
67
+ functions: ["similarity", "word_similarity", "strict_word_similarity", "show_trgm", "show_limit", "set_limit"],
68
+ opclasses: { gin: ["gin_trgm_ops"], gist: ["gist_trgm_ops"] },
69
+ },
70
+ pgcrypto: {
71
+ functions: [
72
+ "digest", "hmac", "crypt", "gen_salt", "gen_random_bytes", "gen_random_uuid", "encrypt", "decrypt", "encrypt_iv", "decrypt_iv",
73
+ "pgp_sym_encrypt", "pgp_sym_encrypt_bytea", "pgp_sym_decrypt", "pgp_sym_decrypt_bytea", "pgp_pub_encrypt", "pgp_pub_encrypt_bytea",
74
+ "pgp_pub_decrypt", "pgp_pub_decrypt_bytea", "pgp_key_id", "armor", "dearmor", "pgp_armor_headers",
75
+ ],
76
+ },
77
+ postgis: {
78
+ types: ["geometry", "geography", "box2d", "box3d"],
79
+ functionPrefixes: ["st_", "postgis_"],
80
+ opclasses: {
81
+ gist: ["gist_geometry_ops_2d", "gist_geometry_ops_nd", "gist_geography_ops"],
82
+ brin: ["brin_geometry_inclusion_ops_2d", "brin_geometry_inclusion_ops_3d", "brin_geometry_inclusion_ops_4d", "brin_geography_inclusion_ops"],
83
+ spgist: ["spgist_geometry_ops_2d", "spgist_geometry_ops_3d", "spgist_geometry_ops_nd", "spgist_geography_ops_nd"],
84
+ btree: ["btree_geometry_ops", "btree_geography_ops"],
85
+ hash: ["hash_geometry_ops"],
86
+ },
87
+ },
88
+ seg: { types: ["seg"], opclasses: { gist: ["gist_seg_ops"] } },
89
+ tablefunc: { functions: ["crosstab", "normal_rand", "connectby"] },
90
+ unaccent: { functions: ["unaccent"] },
91
+ "uuid-ossp": {
92
+ functions: ["uuid_generate_v1", "uuid_generate_v1mc", "uuid_generate_v3", "uuid_generate_v4", "uuid_generate_v5", "uuid_nil", "uuid_ns_dns", "uuid_ns_url", "uuid_ns_oid", "uuid_ns_x500"],
93
+ },
94
+ vector: {
95
+ types: ["vector", "halfvec", "sparsevec"],
96
+ functions: ["l2_distance", "inner_product", "cosine_distance", "l1_distance", "vector_dims", "vector_norm", "l2_norm", "l2_normalize", "binary_quantize", "subvector", "hamming_distance", "jaccard_distance"],
97
+ accessMethods: ["hnsw", "ivfflat"],
98
+ opclasses: { hnsw: VECTOR_OPS, ivfflat: VECTOR_OPS.filter((o) => !o.startsWith("sparsevec") && !o.endsWith("l1_ops") && o !== "bit_jaccard_ops") },
99
+ },
100
+ };
@@ -54,3 +54,28 @@ export const SERIAL_TYPES: Record<string, string> = {
54
54
 
55
55
  /** An array suffix: `integer[]`, `text[3]`, `ARRAY`. Dimensions are documentation only to the server. */
56
56
  export const ARRAY_SUFFIX = { brackets: "[]", dimensioned: "[n]", keyword: "ARRAY" } as const;
57
+
58
+ /**
59
+ * Spellings the grammar accepts that neither `pg_type` nor {@link TYPE_SPELLINGS}
60
+ * lists, and the canonical name each stands for (gram.y, `Numeric`,
61
+ * `Character`, `ConstDatetime`). Lint reads them beside the catalog so every
62
+ * spelling Postgres accepts resolves. `float(p)` is `real` for p up to 24 and
63
+ * `double precision` above; lint reads the precision.
64
+ */
65
+ export const GRAMMAR_TYPE_SPELLINGS: Record<string, string> = {
66
+ dec: "numeric",
67
+ "char varying": "character varying",
68
+ "national character": "character",
69
+ "national char": "character",
70
+ nchar: "character",
71
+ "national character varying": "character varying",
72
+ "national char varying": "character varying",
73
+ "nchar varying": "character varying",
74
+ };
75
+
76
+ /** The serial spellings with a width suffix, beside {@link SERIAL_TYPES}. */
77
+ export const SERIAL_WIDTH_SPELLINGS: Record<string, string> = {
78
+ serial2: "smallint",
79
+ serial4: "integer",
80
+ serial8: "bigint",
81
+ };