diff --git a/.changeset/b7580ab9.md b/.changeset/b7580ab9.md deleted file mode 100644 index 56f43c8..0000000 --- a/.changeset/b7580ab9.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -"@filter-def/core": major -"@filter-def/in-memory": major -"@filter-def/drizzle": major -"@filter-def/bigquery": major ---- - -Enforce non-null filter inputs for all filter types. - -**Breaking change**: Filter inputs can no longer accept `null` or `undefined` values. The `CoreFilterInput` type now excludes these values, requiring explicit filter values. When a value can be nullable, prefer the `isNull` filter kind instead. - -Refactored `CoreFilterInputMap` type to use a new `FieldTypeForFilter` helper, reducing type repetition and improving maintainability. - -Added type tests for `CoreFilterInput` behavior via vitest. diff --git a/packages/bigquery/CHANGELOG.md b/packages/bigquery/CHANGELOG.md index 746d131..05f1da7 100644 --- a/packages/bigquery/CHANGELOG.md +++ b/packages/bigquery/CHANGELOG.md @@ -1,53 +1,71 @@ # @filter-def/bigquery +## 1.0.0 + +### Major Changes + +- 7f24812: Enforce non-null filter inputs for all filter types. + + **Breaking change**: Filter inputs can no longer accept `null` or `undefined` values. The `CoreFilterInput` type now excludes these values, requiring explicit filter values. When a value can be nullable, prefer the `isNull` filter kind instead. + + Refactored `CoreFilterInputMap` type to use a new `FieldTypeForFilter` helper, reducing type repetition and improving maintainability. + + Added type tests for `CoreFilterInput` behavior via vitest. + +### Patch Changes + +- Updated dependencies [7f24812] + - @filter-def/core@1.0.0 + ## 0.1.0 ### Minor Changes - 64c1efc: Add new BigQuery adapter package for filter-def. - This package generates parameterized SQL queries compatible with `@google-cloud/bigquery`. - - ## Features - - All primitive filters: `eq`, `neq`, `contains`, `inArray`, `gt`, `gte`, `lt`, `lte`, `isNull`, `isNotNull` - - Boolean filters: `and`, `or` for combining conditions - - Custom filters for complex SQL expressions - - Type-safe filter inputs inferred from your entity type - - Parameterized queries with `@paramName` placeholders - - Always returns valid SQL - empty filters return `{ sql: "true", params: {} }` for seamless query composition - - ## Basic Usage - - ```typescript - import { bigqueryFilter } from "@filter-def/bigquery"; - import { BigQuery } from "@google-cloud/bigquery"; - - // This is used to define the shape of the data you expect to be returned from BigQuery. - // It also helps define the input types or your filters. - interface User { - id: number; - name: string; - email: string; - age: number; - } - - const userFilter = bigqueryFilter().def({ - name: { kind: "eq" }, - emailContains: { kind: "contains", field: "email" }, - minAge: { kind: "gte", field: "age" }, - }); - - const where = userFilter({ name: "John", minAge: 18 }); - // where = { - // sql: "name = @name AND age >= @minAge", - // params: { name: "John", minAge: 18 } - // } - - // Use with @google-cloud/bigquery - // Filter always returns valid SQL (empty filters return 'WHERE true') - const bigquery = new BigQuery(); - const [rows] = await bigquery.query({ - query: `SELECT * FROM \`myproject.dataset.users\` WHERE ${where.sql}`, - params: where.params, - }); - ``` + This package generates parameterized SQL queries compatible with `@google-cloud/bigquery`. + + ## Features + + - All primitive filters: `eq`, `neq`, `contains`, `inArray`, `gt`, `gte`, `lt`, `lte`, `isNull`, `isNotNull` + - Boolean filters: `and`, `or` for combining conditions + - Custom filters for complex SQL expressions + - Type-safe filter inputs inferred from your entity type + - Parameterized queries with `@paramName` placeholders + - Always returns valid SQL - empty filters return `{ sql: "true", params: {} }` for seamless query composition + + ## Basic Usage + + ```typescript + import { bigqueryFilter } from "@filter-def/bigquery"; + import { BigQuery } from "@google-cloud/bigquery"; + + // This is used to define the shape of the data you expect to be returned from BigQuery. + // It also helps define the input types or your filters. + interface User { + id: number; + name: string; + email: string; + age: number; + } + + const userFilter = bigqueryFilter().def({ + name: { kind: "eq" }, + emailContains: { kind: "contains", field: "email" }, + minAge: { kind: "gte", field: "age" }, + }); + + const where = userFilter({ name: "John", minAge: 18 }); + // where = { + // sql: "name = @name AND age >= @minAge", + // params: { name: "John", minAge: 18 } + // } + + // Use with @google-cloud/bigquery + // Filter always returns valid SQL (empty filters return 'WHERE true') + const bigquery = new BigQuery(); + const [rows] = await bigquery.query({ + query: `SELECT * FROM \`myproject.dataset.users\` WHERE ${where.sql}`, + params: where.params, + }); + ``` diff --git a/packages/bigquery/package.json b/packages/bigquery/package.json index 65c8257..8fc8826 100644 --- a/packages/bigquery/package.json +++ b/packages/bigquery/package.json @@ -1,6 +1,6 @@ { "name": "@filter-def/bigquery", - "version": "0.1.0", + "version": "1.0.0", "description": "BigQuery adapter for filter-def", "homepage": "https://github.com/rmarganti/filter-def#readme", "bugs": { diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 3d91153..7a14410 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,17 @@ # @filter-def/core +## 1.0.0 + +### Major Changes + +- 7f24812: Enforce non-null filter inputs for all filter types. + + **Breaking change**: Filter inputs can no longer accept `null` or `undefined` values. The `CoreFilterInput` type now excludes these values, requiring explicit filter values. When a value can be nullable, prefer the `isNull` filter kind instead. + + Refactored `CoreFilterInputMap` type to use a new `FieldTypeForFilter` helper, reducing type repetition and improving maintainability. + + Added type tests for `CoreFilterInput` behavior via vitest. + ## 0.2.0 ### Minor Changes @@ -12,33 +24,37 @@ - 8445c2f: ### Monorepo Restructure - Restructured filter-def as a pnpm monorepo with three packages: - - `@filter-def/core` - Core types and utilities (types-only) - - `@filter-def/in-memory` - In-memory filtering with native array methods - - `@filter-def/drizzle` - Drizzle ORM adapter for SQL databases + Restructured filter-def as a pnpm monorepo with three packages: + + - `@filter-def/core` - Core types and utilities (types-only) + - `@filter-def/in-memory` - In-memory filtering with native array methods + - `@filter-def/drizzle` - Drizzle ORM adapter for SQL databases + + ### @filter-def/core + + New types-only package containing shared filter definition types: + + - `FilterDef` and all primitive filter types (`eq`, `neq`, `contains`, `inArray`, `gt`, `gte`, `lt`, `lte`, `isNull`, `isNotNull`) + - Boolean filter types (`and`, `or`) + - `CustomFilter` for adapter-specific implementations + - Type utilities for adapter authors (`ExtractFilterKind`, `GetFieldForFilter`, etc.) - ### @filter-def/core + ### @filter-def/in-memory - New types-only package containing shared filter definition types: - - `FilterDef` and all primitive filter types (`eq`, `neq`, `contains`, `inArray`, `gt`, `gte`, `lt`, `lte`, `isNull`, `isNotNull`) - - Boolean filter types (`and`, `or`) - - `CustomFilter` for adapter-specific implementations - - Type utilities for adapter authors (`ExtractFilterKind`, `GetFieldForFilter`, etc.) + Existing in-memory filtering implementation, now as a standalone package: - ### @filter-def/in-memory + - `inMemoryFilter().def()` API for defining filters + - `makeFilterHelpers()` for convenient array filtering + - Full custom filter support + - Re-exports core types for convenience - Existing in-memory filtering implementation, now as a standalone package: - - `inMemoryFilter().def()` API for defining filters - - `makeFilterHelpers()` for convenient array filtering - - Full custom filter support - - Re-exports core types for convenience + ### @filter-def/drizzle - ### @filter-def/drizzle + New Drizzle ORM adapter for SQL database filtering: - New Drizzle ORM adapter for SQL database filtering: - - `drizzleFilter(table).def()` API matching the memory package pattern - - Compiles filter definitions to Drizzle `SQL` expressions - - Maps all primitive filters to Drizzle operators (`eq`, `ne`, `like`, `inArray`, `gt`, `gte`, `lt`, `lte`, `isNull`, `isNotNull`) - - Boolean filter composition with `and()`/`or()` - - Custom filters return `SQL | undefined` for EXISTS subqueries and complex conditions - - `contains` filter uses case-insensitive `ilike` with `%value%` pattern + - `drizzleFilter(table).def()` API matching the memory package pattern + - Compiles filter definitions to Drizzle `SQL` expressions + - Maps all primitive filters to Drizzle operators (`eq`, `ne`, `like`, `inArray`, `gt`, `gte`, `lt`, `lte`, `isNull`, `isNotNull`) + - Boolean filter composition with `and()`/`or()` + - Custom filters return `SQL | undefined` for EXISTS subqueries and complex conditions + - `contains` filter uses case-insensitive `ilike` with `%value%` pattern diff --git a/packages/core/package.json b/packages/core/package.json index 8a75c69..a80a1d2 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@filter-def/core", - "version": "0.2.0", + "version": "1.0.0", "description": "Core types and utilities for filter-def", "homepage": "https://github.com/rmarganti/filter-def#readme", "bugs": { diff --git a/packages/drizzle/CHANGELOG.md b/packages/drizzle/CHANGELOG.md index 663b4e0..f105398 100644 --- a/packages/drizzle/CHANGELOG.md +++ b/packages/drizzle/CHANGELOG.md @@ -1,5 +1,22 @@ # @filter-def/drizzle +## 1.0.0 + +### Major Changes + +- 7f24812: Enforce non-null filter inputs for all filter types. + + **Breaking change**: Filter inputs can no longer accept `null` or `undefined` values. The `CoreFilterInput` type now excludes these values, requiring explicit filter values. When a value can be nullable, prefer the `isNull` filter kind instead. + + Refactored `CoreFilterInputMap` type to use a new `FieldTypeForFilter` helper, reducing type repetition and improving maintainability. + + Added type tests for `CoreFilterInput` behavior via vitest. + +### Patch Changes + +- Updated dependencies [7f24812] + - @filter-def/core@1.0.0 + ## 0.2.0 ### Minor Changes @@ -9,7 +26,7 @@ ### Patch Changes - Updated dependencies [f41a01b] - - @filter-def/core@0.2.0 + - @filter-def/core@0.2.0 ## 0.1.0 @@ -17,38 +34,42 @@ - 8445c2f: ### Monorepo Restructure - Restructured filter-def as a pnpm monorepo with three packages: - - `@filter-def/core` - Core types and utilities (types-only) - - `@filter-def/in-memory` - In-memory filtering with native array methods - - `@filter-def/drizzle` - Drizzle ORM adapter for SQL databases + Restructured filter-def as a pnpm monorepo with three packages: + + - `@filter-def/core` - Core types and utilities (types-only) + - `@filter-def/in-memory` - In-memory filtering with native array methods + - `@filter-def/drizzle` - Drizzle ORM adapter for SQL databases + + ### @filter-def/core + + New types-only package containing shared filter definition types: + + - `FilterDef` and all primitive filter types (`eq`, `neq`, `contains`, `inArray`, `gt`, `gte`, `lt`, `lte`, `isNull`, `isNotNull`) + - Boolean filter types (`and`, `or`) + - `CustomFilter` for adapter-specific implementations + - Type utilities for adapter authors (`ExtractFilterKind`, `GetFieldForFilter`, etc.) - ### @filter-def/core + ### @filter-def/in-memory - New types-only package containing shared filter definition types: - - `FilterDef` and all primitive filter types (`eq`, `neq`, `contains`, `inArray`, `gt`, `gte`, `lt`, `lte`, `isNull`, `isNotNull`) - - Boolean filter types (`and`, `or`) - - `CustomFilter` for adapter-specific implementations - - Type utilities for adapter authors (`ExtractFilterKind`, `GetFieldForFilter`, etc.) + Existing in-memory filtering implementation, now as a standalone package: - ### @filter-def/in-memory + - `inMemoryFilter().def()` API for defining filters + - `makeFilterHelpers()` for convenient array filtering + - Full custom filter support + - Re-exports core types for convenience - Existing in-memory filtering implementation, now as a standalone package: - - `inMemoryFilter().def()` API for defining filters - - `makeFilterHelpers()` for convenient array filtering - - Full custom filter support - - Re-exports core types for convenience + ### @filter-def/drizzle - ### @filter-def/drizzle + New Drizzle ORM adapter for SQL database filtering: - New Drizzle ORM adapter for SQL database filtering: - - `drizzleFilter(table).def()` API matching the memory package pattern - - Compiles filter definitions to Drizzle `SQL` expressions - - Maps all primitive filters to Drizzle operators (`eq`, `ne`, `like`, `inArray`, `gt`, `gte`, `lt`, `lte`, `isNull`, `isNotNull`) - - Boolean filter composition with `and()`/`or()` - - Custom filters return `SQL | undefined` for EXISTS subqueries and complex conditions - - `contains` filter uses case-insensitive `ilike` with `%value%` pattern + - `drizzleFilter(table).def()` API matching the memory package pattern + - Compiles filter definitions to Drizzle `SQL` expressions + - Maps all primitive filters to Drizzle operators (`eq`, `ne`, `like`, `inArray`, `gt`, `gte`, `lt`, `lte`, `isNull`, `isNotNull`) + - Boolean filter composition with `and()`/`or()` + - Custom filters return `SQL | undefined` for EXISTS subqueries and complex conditions + - `contains` filter uses case-insensitive `ilike` with `%value%` pattern ### Patch Changes - Updated dependencies [8445c2f] - - @filter-def/core@0.1.0 + - @filter-def/core@0.1.0 diff --git a/packages/drizzle/package.json b/packages/drizzle/package.json index 87c057e..4b81fd4 100644 --- a/packages/drizzle/package.json +++ b/packages/drizzle/package.json @@ -1,6 +1,6 @@ { "name": "@filter-def/drizzle", - "version": "0.2.0", + "version": "1.0.0", "description": "Drizzle ORM adapter for filter-def", "homepage": "https://github.com/rmarganti/filter-def#readme", "bugs": { diff --git a/packages/in-memory/CHANGELOG.md b/packages/in-memory/CHANGELOG.md index 05d2163..9e4ebe0 100644 --- a/packages/in-memory/CHANGELOG.md +++ b/packages/in-memory/CHANGELOG.md @@ -1,5 +1,22 @@ # @filter-def/in-memory +## 1.0.0 + +### Major Changes + +- 7f24812: Enforce non-null filter inputs for all filter types. + + **Breaking change**: Filter inputs can no longer accept `null` or `undefined` values. The `CoreFilterInput` type now excludes these values, requiring explicit filter values. When a value can be nullable, prefer the `isNull` filter kind instead. + + Refactored `CoreFilterInputMap` type to use a new `FieldTypeForFilter` helper, reducing type repetition and improving maintainability. + + Added type tests for `CoreFilterInput` behavior via vitest. + +### Patch Changes + +- Updated dependencies [7f24812] + - @filter-def/core@1.0.0 + ## 0.2.0 ### Minor Changes @@ -9,7 +26,7 @@ ### Patch Changes - Updated dependencies [f41a01b] - - @filter-def/core@0.2.0 + - @filter-def/core@0.2.0 ## 0.1.0 @@ -17,38 +34,42 @@ - 8445c2f: ### Monorepo Restructure - Restructured filter-def as a pnpm monorepo with three packages: - - `@filter-def/core` - Core types and utilities (types-only) - - `@filter-def/in-memory` - In-memory filtering with native array methods - - `@filter-def/drizzle` - Drizzle ORM adapter for SQL databases + Restructured filter-def as a pnpm monorepo with three packages: + + - `@filter-def/core` - Core types and utilities (types-only) + - `@filter-def/in-memory` - In-memory filtering with native array methods + - `@filter-def/drizzle` - Drizzle ORM adapter for SQL databases + + ### @filter-def/core + + New types-only package containing shared filter definition types: + + - `FilterDef` and all primitive filter types (`eq`, `neq`, `contains`, `inArray`, `gt`, `gte`, `lt`, `lte`, `isNull`, `isNotNull`) + - Boolean filter types (`and`, `or`) + - `CustomFilter` for adapter-specific implementations + - Type utilities for adapter authors (`ExtractFilterKind`, `GetFieldForFilter`, etc.) - ### @filter-def/core + ### @filter-def/in-memory - New types-only package containing shared filter definition types: - - `FilterDef` and all primitive filter types (`eq`, `neq`, `contains`, `inArray`, `gt`, `gte`, `lt`, `lte`, `isNull`, `isNotNull`) - - Boolean filter types (`and`, `or`) - - `CustomFilter` for adapter-specific implementations - - Type utilities for adapter authors (`ExtractFilterKind`, `GetFieldForFilter`, etc.) + Existing in-memory filtering implementation, now as a standalone package: - ### @filter-def/in-memory + - `inMemoryFilter().def()` API for defining filters + - `makeFilterHelpers()` for convenient array filtering + - Full custom filter support + - Re-exports core types for convenience - Existing in-memory filtering implementation, now as a standalone package: - - `inMemoryFilter().def()` API for defining filters - - `makeFilterHelpers()` for convenient array filtering - - Full custom filter support - - Re-exports core types for convenience + ### @filter-def/drizzle - ### @filter-def/drizzle + New Drizzle ORM adapter for SQL database filtering: - New Drizzle ORM adapter for SQL database filtering: - - `drizzleFilter(table).def()` API matching the memory package pattern - - Compiles filter definitions to Drizzle `SQL` expressions - - Maps all primitive filters to Drizzle operators (`eq`, `ne`, `like`, `inArray`, `gt`, `gte`, `lt`, `lte`, `isNull`, `isNotNull`) - - Boolean filter composition with `and()`/`or()` - - Custom filters return `SQL | undefined` for EXISTS subqueries and complex conditions - - `contains` filter uses case-insensitive `ilike` with `%value%` pattern + - `drizzleFilter(table).def()` API matching the memory package pattern + - Compiles filter definitions to Drizzle `SQL` expressions + - Maps all primitive filters to Drizzle operators (`eq`, `ne`, `like`, `inArray`, `gt`, `gte`, `lt`, `lte`, `isNull`, `isNotNull`) + - Boolean filter composition with `and()`/`or()` + - Custom filters return `SQL | undefined` for EXISTS subqueries and complex conditions + - `contains` filter uses case-insensitive `ilike` with `%value%` pattern ### Patch Changes - Updated dependencies [8445c2f] - - @filter-def/core@0.1.0 + - @filter-def/core@0.1.0 diff --git a/packages/in-memory/package.json b/packages/in-memory/package.json index cf38ef9..eb4f419 100644 --- a/packages/in-memory/package.json +++ b/packages/in-memory/package.json @@ -1,6 +1,6 @@ { "name": "@filter-def/in-memory", - "version": "0.2.0", + "version": "1.0.0", "description": "In-memory filtering for filter-def", "homepage": "https://github.com/rmarganti/filter-def#readme", "bugs": {