nucleus-core-ts 0.10.113 → 0.10.114

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.
@@ -0,0 +1,16 @@
1
+ import { type SQL } from 'drizzle-orm';
2
+ export declare const COLLATABLE_COLUMN_TYPES: Set<string>;
3
+ /**
4
+ * A collation name is an IDENTIFIER, so it is interpolated into the SQL text
5
+ * and cannot be sent as a bound parameter. It comes from config rather than
6
+ * from a request, but "not attacker-controlled today" is not the same as safe:
7
+ * accept a bare identifier and nothing else.
8
+ */
9
+ export declare function normalizeSortCollation(raw: unknown): string;
10
+ /** True when `raw` was given but is not usable — the caller should log it. */
11
+ export declare function isRejectedSortCollation(raw: unknown): boolean;
12
+ /**
13
+ * Wraps a sort column in the configured collation when — and only when — the
14
+ * column is a character type.
15
+ */
16
+ export declare function collateColumn(col: unknown, collation: string): SQL;
@@ -30,6 +30,8 @@ export interface EntityRouteConfig {
30
30
  entities: NucleusTable[];
31
31
  logger: Logger;
32
32
  databaseUrl?: string;
33
+ /** ICU collation for text-column sorts (see `database.sortCollation`). */
34
+ sortCollation?: string;
33
35
  dbPool?: import('pg').Pool | null;
34
36
  storage?: {
35
37
  enabled?: boolean;
@@ -210,6 +210,24 @@ export interface NucleusConfigOptions {
210
210
  maxUses?: number;
211
211
  };
212
212
  isMultiTenant?: boolean;
213
+ /**
214
+ * Collation applied to text-column sorts, e.g. `tr-TR-x-icu`.
215
+ *
216
+ * Postgres' default collation on a `C`/`POSIX` database orders by BYTE, so
217
+ * an "A-Z" list is not alphabetical in any language with letters outside
218
+ * ASCII. Measured on a Turkish catalogue: `ALBITROL` sorted before
219
+ * `Airtide` (uppercase letters sort before lowercase), and every name
220
+ * starting with ç/ğ/ı/ö/ş/ü landed after `z`. The list looked sorted and
221
+ * was not — the worst kind of wrong, because nothing about it invites a
222
+ * second look.
223
+ *
224
+ * Set the ICU collation for the install's language (`tr-TR-x-icu`,
225
+ * `de-DE-x-icu`, ...) and every entity sort on a text column uses it.
226
+ * Unset (default) keeps the database's own collation, so existing installs
227
+ * do not change order under them. An unknown collation is refused at boot
228
+ * rather than applied — see the entity route.
229
+ */
230
+ sortCollation?: string;
213
231
  schemas?: string[];
214
232
  /**
215
233
  * Deadline for the startup schema push (default 120000 ms).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleus-core-ts",
3
- "version": "0.10.113",
3
+ "version": "0.10.114",
4
4
  "description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
5
5
  "author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
6
6
  "license": "SEE LICENSE IN LICENSE",