@venizia/ignis-filter 0.4.7-6 → 0.4.7

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.
@@ -76,8 +76,8 @@ export type TWhereOperators<V> = {
76
76
  * bare - the column's own `toDriver` already converts one.
77
77
  */
78
78
  export type TWhereValue<V> = TWidenIsoTimestamp<V> | null | TWhereOperators<TWidenIsoTimestamp<V>>;
79
- /** `true` when a column value can hold JSON: `unknown`, `any` or an object other than a `Date` or a `TIsoTimestamp`. */
80
- type TIsJsonValue<V> = unknown extends V ? true : V extends Date | TIsoTimestamp ? false : V extends object ? true : false;
79
+ /** `true` when a column value can hold JSON: `unknown`, `any`, or a union with an object other than a `Date` or a `TIsoTimestamp` (a `TJsonValue` is one). */
80
+ type TIsJsonValue<V> = unknown extends V ? true : [Exclude<Extract<V, object>, Date | TIsoTimestamp>] extends [never] ? false : true;
81
81
  /** The columns of `T` whose value can hold JSON - the only columns a JSON-path key may start with. */
82
82
  export type TJsonColumnKey<T> = {
83
83
  [K in keyof T & string]: TIsJsonValue<NonNullable<T[K]>> extends true ? K : never;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":"AAAA,gTAAgT","sourcesContent":["/** The filter shape, free of any runtime import. The zod schemas that validate this shape over HTTP stay in `@venizia/ignis-core` - they parse query strings and pull in the OpenAPI layer, which is a server concern. Do not import a value here; the purity guard fails if this file resolves to anything. */\n\nimport type { TConstValue } from '@venizia/ignis-inversion';\nimport type { Sorts } from './operators';\n\n/** Fields selection - an array of field names to include, or an object keyed by field name; only a `true` entry selects (a `false` is ignored by the query layer). `any` for an untyped model. */\nexport type TFields<T = any> = 0 extends 1 & T\n ? any\n : Partial<{ [K in keyof T]: boolean }> | ReadonlyArray<keyof T>;\n\n/**\n * The keys a `fields` selection keeps, which is what the query layer reads: an array names them, an\n * object keeps its `true` entries. An empty selection, an object with no `true`, or a value the type\n * cannot read (`boolean`, a non-literal array) keeps the whole row - the same as the runtime.\n */\ntype TSelectedKeys<T, F> =\n F extends ReadonlyArray<infer K>\n ? K & keyof T\n : F extends object\n ? {\n [K in keyof F]: boolean extends F[K] ? 0 : F[K] extends true ? K : never;\n }[keyof F] extends infer U\n ? 0 extends U\n ? keyof T\n : U & keyof T\n : keyof T\n : keyof T;\n\n/** The keys a model declares optional (`items?: ...`): relations, which an `include` adds beside the selected columns. */\ntype TOptionalKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? K : never }[keyof T];\n\n/** The row `fields` leaves: `Pick` of the selected keys, the whole row when nothing narrows it. A model with no known keys (`any`, `object`) stays `any`: there is nothing to pick from. */\nexport type TSelectedRow<T, F> = [keyof T] extends [never]\n ? any\n : [TSelectedKeys<T, F>] extends [never]\n ? T\n : [keyof T] extends [TSelectedKeys<T, F>]\n ? T\n : Pick<T, TSelectedKeys<T, F> | TOptionalKeys<T>>;\n\n/** The row of a read: `R` when the caller named it (`find<MyType>`), else the row `fields` leaves. `unknown` is the \"not named\" marker. */\nexport type TRow<T, R, F> = unknown extends R ? TSelectedRow<T, F> : R;\n\n/**\n * Branded read-shape for a timestamp column normalized to ISO 8601 (`isoTimestamp` in\n * `@venizia/ignis-connectors`), whose `toDriver` accepts a `Date` even though the column reads\n * back as `string`. A plain `text` column stays bare `string` and is untouched by this brand -\n * only a column built with it is eligible for the `Date` widening below.\n */\nexport type TIsoTimestamp = string & { readonly isoTimestampBrand: unique symbol };\n\n/** Adds `Date` to a branded `TIsoTimestamp` value type; every other type passes through unchanged. */\ntype TWidenIsoTimestamp<V> = V extends TIsoTimestamp ? V | Date : V;\n\n/**\n * A SQL fragment built in code - a Drizzle `SQL` or `SQLWrapper` - named structurally so this\n * package stays free of Drizzle. JSON from a request can never satisfy it.\n */\nexport type TSqlFragment = { getSQL(): unknown };\n\n/** Field-level comparison operators, mirrored 1:1 from `QueryOperators` in `common/operators.ts`. */\nexport type TWhereOperators<V> = {\n eq?: V;\n ne?: V;\n neq?: V;\n gt?: V;\n gte?: V;\n lt?: V;\n lte?: V;\n like?: V;\n nlike?: V;\n ilike?: V;\n nilike?: V;\n is?: V | null;\n isn?: V | null;\n regexp?: V;\n iregexp?: V;\n in?: V[];\n inq?: V[];\n nin?: V[];\n exists?: boolean;\n notExists?: boolean;\n between?: [V, V];\n notBetween?: [V, V];\n inSql?: TSqlFragment;\n ninSql?: TSqlFragment;\n contains?: V | V[];\n containedBy?: V | V[];\n overlaps?: V | V[];\n not?: V | TWhereOperators<V>;\n};\n\n/**\n * A field's condition - a bare scalar (implicit `eq`), `null` (implicit `is`), or an operator\n * object. A `TIsoTimestamp` column also accepts a `Date`, inside the operator object as well as\n * bare - the column's own `toDriver` already converts one.\n */\nexport type TWhereValue<V> = TWidenIsoTimestamp<V> | null | TWhereOperators<TWidenIsoTimestamp<V>>;\n\n/** `true` when a column value can hold JSON: `unknown`, `any` or an object other than a `Date` or a `TIsoTimestamp`. */\ntype TIsJsonValue<V> = unknown extends V\n ? true\n : V extends Date | TIsoTimestamp\n ? false\n : V extends object\n ? true\n : false;\n\n/** The columns of `T` whose value can hold JSON - the only columns a JSON-path key may start with. */\nexport type TJsonColumnKey<T> = {\n [K in keyof T & string]: TIsJsonValue<NonNullable<T[K]>> extends true ? K : never;\n}[keyof T & string];\n\n/** A JSON-path key on a JSON column of `T`: `metadata.a.b` or `metadata[0]`. */\nexport type TJsonPathKey<T> = `${TJsonColumnKey<T>}.${string}` | `${TJsonColumnKey<T>}[${string}`;\n\n/**\n * Query conditions for selecting data - column keys, JSON-path keys on JSON columns, and nested\n * `and` / `or`. A JSON-path value is `unknown` so a `Record<string, unknown>` still assigns.\n */\nexport type TWhere<T = any> = { [key in keyof T]?: TWhereValue<T[key]> } & {\n [key in TJsonPathKey<T>]?: unknown;\n} & {\n and?: TWhere<T>[];\n or?: TWhere<T>[];\n};\n\n/** Single relation inclusion configuration. */\nexport type TInclusion = {\n relation: string;\n scope?: TFilter;\n shouldSkipDefaultFilter?: boolean;\n};\n\n/** A sort direction, exactly the `Sorts` values. */\nexport type TSortDirection = TConstValue<typeof Sorts>;\n\n/** One order entry read by `Sorts.parseEntry`: the field as written, the direction lower-cased. */\nexport type TParsedOrderEntry = { field: string; direction: TSortDirection };\n\n/** An order direction in either case. */\ntype TOrderDirection = TSortDirection | Uppercase<TSortDirection>;\n\n/** A column of `T` or a JSON-path key on one of its JSON columns. */\ntype TOrderKey<T> = (keyof T & string) | TJsonPathKey<T>;\n\n/** One typed order entry, opt-in through `satisfies TOrderEntry<T>[]` - `TFilter.order` stays `string[]`. */\nexport type TOrderEntry<T> = TOrderKey<T> | `${TOrderKey<T>} ${TOrderDirection}`;\n\n/** Comprehensive filter configuration used across all repository query methods. */\nexport type TFilter<T = any, F extends TFields<T> = TFields<T>> = {\n where?: TWhere<T>;\n fields?: F;\n include?: TInclusion[];\n order?: string[];\n limit?: number;\n offset?: number;\n skip?: number;\n};\n\n/** The filter of a read by id: no `where` (the id is the `where`), `fields` typed like `TFilter`. */\nexport type TByIdFilter<T = any, F extends TFields<T> = TFields<T>> = Omit<\n TFilter<T>,\n 'where' | 'fields'\n> & {\n fields?: F;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":"AAAA,gTAAgT","sourcesContent":["/** The filter shape, free of any runtime import. The zod schemas that validate this shape over HTTP stay in `@venizia/ignis-core` - they parse query strings and pull in the OpenAPI layer, which is a server concern. Do not import a value here; the purity guard fails if this file resolves to anything. */\n\nimport type { TConstValue } from '@venizia/ignis-inversion';\nimport type { Sorts } from './operators';\n\n/** Fields selection - an array of field names to include, or an object keyed by field name; only a `true` entry selects (a `false` is ignored by the query layer). `any` for an untyped model. */\nexport type TFields<T = any> = 0 extends 1 & T\n ? any\n : Partial<{ [K in keyof T]: boolean }> | ReadonlyArray<keyof T>;\n\n/**\n * The keys a `fields` selection keeps, which is what the query layer reads: an array names them, an\n * object keeps its `true` entries. An empty selection, an object with no `true`, or a value the type\n * cannot read (`boolean`, a non-literal array) keeps the whole row - the same as the runtime.\n */\ntype TSelectedKeys<T, F> =\n F extends ReadonlyArray<infer K>\n ? K & keyof T\n : F extends object\n ? {\n [K in keyof F]: boolean extends F[K] ? 0 : F[K] extends true ? K : never;\n }[keyof F] extends infer U\n ? 0 extends U\n ? keyof T\n : U & keyof T\n : keyof T\n : keyof T;\n\n/** The keys a model declares optional (`items?: ...`): relations, which an `include` adds beside the selected columns. */\ntype TOptionalKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? K : never }[keyof T];\n\n/** The row `fields` leaves: `Pick` of the selected keys, the whole row when nothing narrows it. A model with no known keys (`any`, `object`) stays `any`: there is nothing to pick from. */\nexport type TSelectedRow<T, F> = [keyof T] extends [never]\n ? any\n : [TSelectedKeys<T, F>] extends [never]\n ? T\n : [keyof T] extends [TSelectedKeys<T, F>]\n ? T\n : Pick<T, TSelectedKeys<T, F> | TOptionalKeys<T>>;\n\n/** The row of a read: `R` when the caller named it (`find<MyType>`), else the row `fields` leaves. `unknown` is the \"not named\" marker. */\nexport type TRow<T, R, F> = unknown extends R ? TSelectedRow<T, F> : R;\n\n/**\n * Branded read-shape for a timestamp column normalized to ISO 8601 (`isoTimestamp` in\n * `@venizia/ignis-connectors`), whose `toDriver` accepts a `Date` even though the column reads\n * back as `string`. A plain `text` column stays bare `string` and is untouched by this brand -\n * only a column built with it is eligible for the `Date` widening below.\n */\nexport type TIsoTimestamp = string & { readonly isoTimestampBrand: unique symbol };\n\n/** Adds `Date` to a branded `TIsoTimestamp` value type; every other type passes through unchanged. */\ntype TWidenIsoTimestamp<V> = V extends TIsoTimestamp ? V | Date : V;\n\n/**\n * A SQL fragment built in code - a Drizzle `SQL` or `SQLWrapper` - named structurally so this\n * package stays free of Drizzle. JSON from a request can never satisfy it.\n */\nexport type TSqlFragment = { getSQL(): unknown };\n\n/** Field-level comparison operators, mirrored 1:1 from `QueryOperators` in `common/operators.ts`. */\nexport type TWhereOperators<V> = {\n eq?: V;\n ne?: V;\n neq?: V;\n gt?: V;\n gte?: V;\n lt?: V;\n lte?: V;\n like?: V;\n nlike?: V;\n ilike?: V;\n nilike?: V;\n is?: V | null;\n isn?: V | null;\n regexp?: V;\n iregexp?: V;\n in?: V[];\n inq?: V[];\n nin?: V[];\n exists?: boolean;\n notExists?: boolean;\n between?: [V, V];\n notBetween?: [V, V];\n inSql?: TSqlFragment;\n ninSql?: TSqlFragment;\n contains?: V | V[];\n containedBy?: V | V[];\n overlaps?: V | V[];\n not?: V | TWhereOperators<V>;\n};\n\n/**\n * A field's condition - a bare scalar (implicit `eq`), `null` (implicit `is`), or an operator\n * object. A `TIsoTimestamp` column also accepts a `Date`, inside the operator object as well as\n * bare - the column's own `toDriver` already converts one.\n */\nexport type TWhereValue<V> = TWidenIsoTimestamp<V> | null | TWhereOperators<TWidenIsoTimestamp<V>>;\n\n/** `true` when a column value can hold JSON: `unknown`, `any`, or a union with an object other than a `Date` or a `TIsoTimestamp` (a `TJsonValue` is one). */\ntype TIsJsonValue<V> = unknown extends V\n ? true\n : [Exclude<Extract<V, object>, Date | TIsoTimestamp>] extends [never]\n ? false\n : true;\n\n/** The columns of `T` whose value can hold JSON - the only columns a JSON-path key may start with. */\nexport type TJsonColumnKey<T> = {\n [K in keyof T & string]: TIsJsonValue<NonNullable<T[K]>> extends true ? K : never;\n}[keyof T & string];\n\n/** A JSON-path key on a JSON column of `T`: `metadata.a.b` or `metadata[0]`. */\nexport type TJsonPathKey<T> = `${TJsonColumnKey<T>}.${string}` | `${TJsonColumnKey<T>}[${string}`;\n\n/**\n * Query conditions for selecting data - column keys, JSON-path keys on JSON columns, and nested\n * `and` / `or`. A JSON-path value is `unknown` so a `Record<string, unknown>` still assigns.\n */\nexport type TWhere<T = any> = { [key in keyof T]?: TWhereValue<T[key]> } & {\n [key in TJsonPathKey<T>]?: unknown;\n} & {\n and?: TWhere<T>[];\n or?: TWhere<T>[];\n};\n\n/** Single relation inclusion configuration. */\nexport type TInclusion = {\n relation: string;\n scope?: TFilter;\n shouldSkipDefaultFilter?: boolean;\n};\n\n/** A sort direction, exactly the `Sorts` values. */\nexport type TSortDirection = TConstValue<typeof Sorts>;\n\n/** One order entry read by `Sorts.parseEntry`: the field as written, the direction lower-cased. */\nexport type TParsedOrderEntry = { field: string; direction: TSortDirection };\n\n/** An order direction in either case. */\ntype TOrderDirection = TSortDirection | Uppercase<TSortDirection>;\n\n/** A column of `T` or a JSON-path key on one of its JSON columns. */\ntype TOrderKey<T> = (keyof T & string) | TJsonPathKey<T>;\n\n/** One typed order entry, opt-in through `satisfies TOrderEntry<T>[]` - `TFilter.order` stays `string[]`. */\nexport type TOrderEntry<T> = TOrderKey<T> | `${TOrderKey<T>} ${TOrderDirection}`;\n\n/** Comprehensive filter configuration used across all repository query methods. */\nexport type TFilter<T = any, F extends TFields<T> = TFields<T>> = {\n where?: TWhere<T>;\n fields?: F;\n include?: TInclusion[];\n order?: string[];\n limit?: number;\n offset?: number;\n skip?: number;\n};\n\n/** The filter of a read by id: no `where` (the id is the `where`), `fields` typed like `TFilter`. */\nexport type TByIdFilter<T = any, F extends TFields<T> = TFields<T>> = Omit<\n TFilter<T>,\n 'where' | 'fields'\n> & {\n fields?: F;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@venizia/ignis-filter",
3
- "version": "0.4.7-6",
3
+ "version": "0.4.7",
4
4
  "description": "Engine-neutral query filter vocabulary for TypeScript: the `{ where, order, limit, offset, skip, fields, include }` shape, comparison/pattern/null/array/logical operators, and sort direction constants. Isomorphic by construction - no node builtins and no server-only peer, so the same filter language serves a server repository and a browser data layer.",
5
5
  "keywords": [
6
6
  "browser",
@@ -61,12 +61,12 @@
61
61
  "force-update": "sh ../../scripts/build/force-update.sh"
62
62
  },
63
63
  "dependencies": {
64
- "@venizia/ignis-inversion": "0.4.7-5",
64
+ "@venizia/ignis-inversion": "0.4.7",
65
65
  "zod": "^4.6.7"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/bun": "^1.4.3",
69
- "@venizia/dev-configs": "0.4.8-10",
69
+ "@venizia/dev-configs": "0.4.8",
70
70
  "eslint": "^10.13.0",
71
71
  "oxlint": "1.89.0",
72
72
  "oxlint-tsgolint": "7.0.2004",