@vouchington/utils 0.7.0 → 0.7.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.
package/README.md CHANGED
@@ -21,6 +21,8 @@ import { createScopeCatalog } from '@vouchington/utils/scopes'
21
21
  - `cache-tags`: canonical printable-ASCII wire encoding, one-segment URL decoding, validation,
22
22
  and escape-boundary truncation. Applications own family names, route recognition, and purge policy.
23
23
  Single-tag validation rejects spaces and comma separators; raw commas are percent-encoded.
24
+ - `schema-growth`: `buildUnboundedUnpartitionedTables()` and `classifyTableGrowth()` map tables to
25
+ caller-supplied growth reasons. Applications own every table name and reason.
24
26
  - `sentry-envelope`: bounded UTF-8 envelope record scanning and safe item-type diagnostics.
25
27
  Callers choose the byte and type-list limits; DSN, tunnel, request, and logging policy stay local.
26
28
  - `scopes`: caller-owned scope catalog validation, prerequisite expansion, audience and surface
@@ -0,0 +1,20 @@
1
+ type GrowthPolicyGroup = {
2
+ /** Why these tables may grow without a time or size bound. */
3
+ reason: string;
4
+ tables: readonly string[];
5
+ /** Skip tables that are partitioned (they are bounded by partition retention instead). */
6
+ excludePartitioned?: boolean;
7
+ };
8
+ export interface BuildUnboundedTablesOptions {
9
+ partitionedTables: ReadonlySet<string>;
10
+ /** Applied in order; a later group or entry overrides an earlier reason for the same table. */
11
+ groups?: readonly GrowthPolicyGroup[];
12
+ /** Per-table `[table, reason]` entries, applied after `groups`. */
13
+ entries?: Iterable<readonly [table: string, reason: string]>;
14
+ }
15
+ export type TableGrowthClass = 'partitioned' | 'unbounded' | 'unclassified';
16
+ /** Maps every deliberately unbounded, unpartitioned table to its documented reason. */
17
+ export declare function buildUnboundedUnpartitionedTables(options: BuildUnboundedTablesOptions): Map<string, string>;
18
+ /** Partitioned wins over unbounded; anything else needs an explicit growth decision. */
19
+ export declare function classifyTableGrowth(table: string, partitionedTables: ReadonlySet<string>, unboundedTables: ReadonlyMap<string, string>): TableGrowthClass;
20
+ export {};
@@ -0,0 +1,20 @@
1
+ /** Maps every deliberately unbounded, unpartitioned table to its documented reason. */
2
+ export function buildUnboundedUnpartitionedTables(options) {
3
+ const result = new Map();
4
+ for (const group of options.groups ?? []) {
5
+ for (const table of group.tables) {
6
+ if (group.excludePartitioned && options.partitionedTables.has(table))
7
+ continue;
8
+ result.set(table, group.reason);
9
+ }
10
+ }
11
+ for (const [table, reason] of options.entries ?? [])
12
+ result.set(table, reason);
13
+ return result;
14
+ }
15
+ /** Partitioned wins over unbounded; anything else needs an explicit growth decision. */
16
+ export function classifyTableGrowth(table, partitionedTables, unboundedTables) {
17
+ if (partitionedTables.has(table))
18
+ return 'partitioned';
19
+ return unboundedTables.has(table) ? 'unbounded' : 'unclassified';
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vouchington/utils",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Dependency-free runtime utilities for Vouchington-style applications.",
5
5
  "homepage": "https://github.com/vouchington/vouchington-platform/tree/main/packages/utils#readme",
6
6
  "bugs": {
@@ -30,6 +30,11 @@
30
30
  "import": "./dist/api-response-contract.mjs",
31
31
  "default": "./dist/api-response-contract.mjs"
32
32
  },
33
+ "./schema-growth": {
34
+ "types": "./dist/schema-growth.d.mts",
35
+ "import": "./dist/schema-growth.mjs",
36
+ "default": "./dist/schema-growth.mjs"
37
+ },
33
38
  "./cache-tags": {
34
39
  "types": "./dist/cache-tags.d.mts",
35
40
  "import": "./dist/cache-tags.mjs",