@venizia/ignis-filter 0.1.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/LICENSE.md +103 -0
- package/README.md +86 -0
- package/dist/cjs/common/index.d.ts +3 -0
- package/dist/cjs/common/index.d.ts.map +1 -0
- package/dist/cjs/common/index.js +19 -0
- package/dist/cjs/common/index.js.map +1 -0
- package/dist/cjs/common/operators.d.ts +49 -0
- package/dist/cjs/common/operators.d.ts.map +1 -0
- package/dist/cjs/common/operators.js +121 -0
- package/dist/cjs/common/operators.js.map +1 -0
- package/dist/cjs/common/types.d.ts +37 -0
- package/dist/cjs/common/types.d.ts.map +1 -0
- package/dist/cjs/common/types.js +4 -0
- package/dist/cjs/common/types.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/schemas/builder.d.ts +16 -0
- package/dist/cjs/schemas/builder.d.ts.map +1 -0
- package/dist/cjs/schemas/builder.js +131 -0
- package/dist/cjs/schemas/builder.js.map +1 -0
- package/dist/cjs/schemas/common/types.d.ts +9 -0
- package/dist/cjs/schemas/common/types.d.ts.map +1 -0
- package/dist/cjs/schemas/common/types.js +3 -0
- package/dist/cjs/schemas/common/types.js.map +1 -0
- package/dist/cjs/schemas/index.d.ts +5 -0
- package/dist/cjs/schemas/index.d.ts.map +1 -0
- package/dist/cjs/schemas/index.js +24 -0
- package/dist/cjs/schemas/index.js.map +1 -0
- package/dist/esm/common/index.d.ts +3 -0
- package/dist/esm/common/index.d.ts.map +1 -0
- package/dist/esm/common/index.js +3 -0
- package/dist/esm/common/index.js.map +1 -0
- package/dist/esm/common/operators.d.ts +49 -0
- package/dist/esm/common/operators.d.ts.map +1 -0
- package/dist/esm/common/operators.js +116 -0
- package/dist/esm/common/operators.js.map +1 -0
- package/dist/esm/common/types.d.ts +37 -0
- package/dist/esm/common/types.d.ts.map +1 -0
- package/dist/esm/common/types.js +3 -0
- package/dist/esm/common/types.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/schemas/builder.d.ts +16 -0
- package/dist/esm/schemas/builder.d.ts.map +1 -0
- package/dist/esm/schemas/builder.js +127 -0
- package/dist/esm/schemas/builder.js.map +1 -0
- package/dist/esm/schemas/common/types.d.ts +9 -0
- package/dist/esm/schemas/common/types.d.ts.map +1 -0
- package/dist/esm/schemas/common/types.js +2 -0
- package/dist/esm/schemas/common/types.js.map +1 -0
- package/dist/esm/schemas/index.d.ts +5 -0
- package/dist/esm/schemas/index.d.ts.map +1 -0
- package/dist/esm/schemas/index.js +6 -0
- package/dist/esm/schemas/index.js.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The metadata a schema carries for documentation. Structural on purpose - naming the OpenAPI library's type here would pull it into a browser bundle, which is the whole thing this package avoids. */
|
|
2
|
+
export type TSchemaMetadata = {
|
|
3
|
+
description?: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
examples?: Array<unknown>;
|
|
6
|
+
};
|
|
7
|
+
/** Applies documentation metadata to a schema and returns it. A server passes an OpenAPI decorator; a browser passes nothing and gets the identity. */
|
|
8
|
+
export type TSchemaDecorator = <TSchema>(schema: TSchema, metadata: TSchemaMetadata) => TSchema;
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/schemas/common/types.ts"],"names":[],"mappings":"AAAA,yMAAyM;AACzM,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CAC3B,CAAC;AAEF,uJAAuJ;AACvJ,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/schemas/common/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './builder';
|
|
2
|
+
export * from './common/types';
|
|
3
|
+
/** Ready-to-use schemas with no documentation metadata attached - the browser case, and the reason most consumers never touch `buildQuerySchemas` directly. */
|
|
4
|
+
export declare const FieldsSchema: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodBoolean>, import("zod").ZodArray<import("zod").ZodString>]>>, FilterSchema: import("zod").ZodOptional<import("zod").ZodUnion<readonly [any, import("zod").ZodPipe<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<any, string>>, any>]>>, InclusionSchema: any, LimitSchema: import("zod").ZodOptional<import("zod").ZodNumber>, OffsetSchema: import("zod").ZodOptional<import("zod").ZodNumber>, OrderBySchema: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>, SkipSchema: import("zod").ZodOptional<import("zod").ZodNumber>, WhereSchema: import("zod").ZodUnion<readonly [import("zod").ZodType<any, unknown, import("zod/v4/core").$ZodTypeInternals<any, unknown>>, import("zod").ZodPipe<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<any, string>>, import("zod").ZodType<any, unknown, import("zod/v4/core").$ZodTypeInternals<any, unknown>>>]>;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schemas/index.ts"],"names":[],"mappings":"AAEA,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAE/B,+JAA+J;AAC/J,eAAO,MACL,YAAY,oLACZ,YAAY,0LACZ,eAAe,OACf,WAAW,sDACX,YAAY,sDACZ,aAAa,8EACb,UAAU,sDACV,WAAW,2UACU,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var _a;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.WhereSchema = exports.SkipSchema = exports.OrderBySchema = exports.OffsetSchema = exports.LimitSchema = exports.InclusionSchema = exports.FilterSchema = exports.FieldsSchema = void 0;
|
|
19
|
+
const builder_1 = require("./builder");
|
|
20
|
+
__exportStar(require("./builder"), exports);
|
|
21
|
+
__exportStar(require("./common/types"), exports);
|
|
22
|
+
/** Ready-to-use schemas with no documentation metadata attached - the browser case, and the reason most consumers never touch `buildQuerySchemas` directly. */
|
|
23
|
+
_a = (0, builder_1.buildQuerySchemas)(), exports.FieldsSchema = _a.FieldsSchema, exports.FilterSchema = _a.FilterSchema, exports.InclusionSchema = _a.InclusionSchema, exports.LimitSchema = _a.LimitSchema, exports.OffsetSchema = _a.OffsetSchema, exports.OrderBySchema = _a.OrderBySchema, exports.SkipSchema = _a.SkipSchema, exports.WhereSchema = _a.WhereSchema;
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schemas/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAA8C;AAE9C,4CAA0B;AAC1B,iDAA+B;AAE/B,+JAA+J;AAClJ,KAST,IAAA,2BAAiB,GAAE,EARrB,oBAAY,oBACZ,oBAAY,oBACZ,uBAAe,uBACf,mBAAW,mBACX,oBAAY,oBACZ,qBAAa,qBACb,kBAAU,kBACV,mBAAW,kBACW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type TConstValue } from '@venizia/ignis-inversion';
|
|
2
|
+
/** Sort direction constants for order by clauses. */
|
|
3
|
+
export declare class Sorts {
|
|
4
|
+
static readonly DESC = "desc";
|
|
5
|
+
static readonly ASC = "asc";
|
|
6
|
+
static readonly SCHEMA_SET: Set<string>;
|
|
7
|
+
static isValid(value: string): boolean;
|
|
8
|
+
}
|
|
9
|
+
/** Query operators for building where conditions (comparison, pattern, null, array, logical). */
|
|
10
|
+
export declare class QueryOperators {
|
|
11
|
+
static readonly EQ = "eq";
|
|
12
|
+
static readonly NE = "ne";
|
|
13
|
+
static readonly NEQ = "neq";
|
|
14
|
+
static readonly GT = "gt";
|
|
15
|
+
static readonly GTE = "gte";
|
|
16
|
+
static readonly LT = "lt";
|
|
17
|
+
static readonly LTE = "lte";
|
|
18
|
+
static readonly LIKE = "like";
|
|
19
|
+
static readonly NOT_LIKE = "nlike";
|
|
20
|
+
static readonly ILIKE = "ilike";
|
|
21
|
+
static readonly NOT_ILIKE = "nilike";
|
|
22
|
+
static readonly IS = "is";
|
|
23
|
+
static readonly IS_NOT = "isn";
|
|
24
|
+
static readonly REGEXP = "regexp";
|
|
25
|
+
static readonly IREGEXP = "iregexp";
|
|
26
|
+
static readonly IN = "in";
|
|
27
|
+
static readonly INQ = "inq";
|
|
28
|
+
static readonly NIN = "nin";
|
|
29
|
+
static readonly EXISTS = "exists";
|
|
30
|
+
static readonly NOT_EXISTS = "notExists";
|
|
31
|
+
static readonly BETWEEN = "between";
|
|
32
|
+
static readonly NOT_BETWEEN = "notBetween";
|
|
33
|
+
static readonly CONTAINS = "contains";
|
|
34
|
+
static readonly CONTAINED_BY = "containedBy";
|
|
35
|
+
static readonly OVERLAPS = "overlaps";
|
|
36
|
+
static readonly NOT = "not";
|
|
37
|
+
static readonly AND = "and";
|
|
38
|
+
static readonly OR = "or";
|
|
39
|
+
static readonly SCHEME_SET: Set<string>;
|
|
40
|
+
static readonly LOGICAL_GROUP_OPERATORS: Set<string>;
|
|
41
|
+
static readonly NUMERIC_COMPARISON_OPERATORS: Set<string>;
|
|
42
|
+
/** Checks if operators contain numeric comparisons (used for JSON path numeric casting). */
|
|
43
|
+
static hasNumericComparison(opts: {
|
|
44
|
+
operators: Record<string, any>;
|
|
45
|
+
}): boolean;
|
|
46
|
+
static isValid(orgType: string): boolean;
|
|
47
|
+
}
|
|
48
|
+
export type TQueryOperator = TConstValue<typeof QueryOperators>;
|
|
49
|
+
//# sourceMappingURL=operators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../../../src/common/operators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAItE,qD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W,gBAAgB;IAG3C,MAAM,CAAC,QAAQ,CAAC,QAAQ,cAAc;IACtC,MAAM,CAAC,QAAQ,CAAC,YAAY,iBAAiB;IAC7C,MAAM,CAAC,QAAQ,CAAC,QAAQ,cAAc;IAEtC,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS;IAC5B,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS;IAC5B,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ;IAE1B,MAAM,CAAC,QAAQ,CAAC,UAAU,cA6BvB;IAEH,MAAM,CAAC,QAAQ,CAAC,uBAAuB,cAAgC;IAEvE,MAAM,CAAC,QAAQ,CAAC,4BAA4B,cAOzC;IAEH,4FAA4F;IAC5F,MAAM,CAAC,oBAAoB,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO;IAyB9E,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;CAGzC;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { getError } from '@venizia/ignis-inversion';
|
|
2
|
+
// Neutral filter vocabulary shared by every connector. Support differs per engine - unsupported operators throw at translation time rather than being removed from this list.
|
|
3
|
+
/** Sort direction constants for order by clauses. */
|
|
4
|
+
export class Sorts {
|
|
5
|
+
static { this.DESC = 'desc'; }
|
|
6
|
+
static { this.ASC = 'asc'; }
|
|
7
|
+
static { this.SCHEMA_SET = new Set([Sorts.ASC, Sorts.DESC]); }
|
|
8
|
+
static isValid(value) {
|
|
9
|
+
return Sorts.SCHEMA_SET.has(value.toLowerCase());
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** Asserts a between-style operand is a two-element tuple and reports whether both bounds are numbers. */
|
|
13
|
+
const validateNumericRange = (opts) => {
|
|
14
|
+
const { op, value } = opts;
|
|
15
|
+
if (!Array.isArray(value) || value.length !== 2) {
|
|
16
|
+
throw getError({
|
|
17
|
+
message: `[QueryOperators][hasNumericComparison] Invalid '${op}' value | Expected: [min, max] | Got: ${JSON.stringify(value)}`,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return value.every(v => typeof v === 'number');
|
|
21
|
+
};
|
|
22
|
+
/** Query operators for building where conditions (comparison, pattern, null, array, logical). */
|
|
23
|
+
export class QueryOperators {
|
|
24
|
+
static { this.EQ = 'eq'; }
|
|
25
|
+
static { this.NE = 'ne'; }
|
|
26
|
+
static { this.NEQ = 'neq'; }
|
|
27
|
+
static { this.GT = 'gt'; }
|
|
28
|
+
static { this.GTE = 'gte'; }
|
|
29
|
+
static { this.LT = 'lt'; }
|
|
30
|
+
static { this.LTE = 'lte'; }
|
|
31
|
+
static { this.LIKE = 'like'; }
|
|
32
|
+
static { this.NOT_LIKE = 'nlike'; }
|
|
33
|
+
static { this.ILIKE = 'ilike'; }
|
|
34
|
+
static { this.NOT_ILIKE = 'nilike'; }
|
|
35
|
+
static { this.IS = 'is'; }
|
|
36
|
+
static { this.IS_NOT = 'isn'; }
|
|
37
|
+
static { this.REGEXP = 'regexp'; }
|
|
38
|
+
static { this.IREGEXP = 'iregexp'; }
|
|
39
|
+
static { this.IN = 'in'; }
|
|
40
|
+
static { this.INQ = 'inq'; }
|
|
41
|
+
static { this.NIN = 'nin'; }
|
|
42
|
+
static { this.EXISTS = 'exists'; }
|
|
43
|
+
static { this.NOT_EXISTS = 'notExists'; }
|
|
44
|
+
static { this.BETWEEN = 'between'; }
|
|
45
|
+
static { this.NOT_BETWEEN = 'notBetween'; }
|
|
46
|
+
// Array Column Operators (PostgreSQL specific)
|
|
47
|
+
static { this.CONTAINS = 'contains'; } // @> array contains
|
|
48
|
+
static { this.CONTAINED_BY = 'containedBy'; } // <@ array is contained by
|
|
49
|
+
static { this.OVERLAPS = 'overlaps'; } // && array overlaps
|
|
50
|
+
static { this.NOT = 'not'; }
|
|
51
|
+
static { this.AND = 'and'; }
|
|
52
|
+
static { this.OR = 'or'; }
|
|
53
|
+
static { this.SCHEME_SET = new Set([
|
|
54
|
+
this.EQ,
|
|
55
|
+
this.NE,
|
|
56
|
+
this.NEQ,
|
|
57
|
+
this.GT,
|
|
58
|
+
this.GTE,
|
|
59
|
+
this.LT,
|
|
60
|
+
this.LTE,
|
|
61
|
+
this.LIKE,
|
|
62
|
+
this.NOT_LIKE,
|
|
63
|
+
this.ILIKE,
|
|
64
|
+
this.NOT_ILIKE,
|
|
65
|
+
this.IS,
|
|
66
|
+
this.IS_NOT,
|
|
67
|
+
this.REGEXP,
|
|
68
|
+
this.IREGEXP,
|
|
69
|
+
this.IN,
|
|
70
|
+
this.INQ,
|
|
71
|
+
this.NIN,
|
|
72
|
+
this.EXISTS,
|
|
73
|
+
this.NOT_EXISTS,
|
|
74
|
+
this.BETWEEN,
|
|
75
|
+
this.NOT_BETWEEN,
|
|
76
|
+
this.CONTAINS,
|
|
77
|
+
this.CONTAINED_BY,
|
|
78
|
+
this.OVERLAPS,
|
|
79
|
+
this.NOT,
|
|
80
|
+
this.AND,
|
|
81
|
+
this.OR,
|
|
82
|
+
]); }
|
|
83
|
+
static { this.LOGICAL_GROUP_OPERATORS = new Set([this.AND, this.OR]); }
|
|
84
|
+
static { this.NUMERIC_COMPARISON_OPERATORS = new Set([
|
|
85
|
+
this.GT,
|
|
86
|
+
this.GTE,
|
|
87
|
+
this.LT,
|
|
88
|
+
this.LTE,
|
|
89
|
+
this.BETWEEN,
|
|
90
|
+
this.NOT_BETWEEN,
|
|
91
|
+
]); }
|
|
92
|
+
/** Checks if operators contain numeric comparisons (used for JSON path numeric casting). */
|
|
93
|
+
static hasNumericComparison(opts) {
|
|
94
|
+
const { operators } = opts;
|
|
95
|
+
let hasNumeric = false;
|
|
96
|
+
for (const op in operators) {
|
|
97
|
+
if (!this.NUMERIC_COMPARISON_OPERATORS.has(op)) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const value = operators[op];
|
|
101
|
+
if (op === this.BETWEEN || op === this.NOT_BETWEEN) {
|
|
102
|
+
const isNumericRange = validateNumericRange({ op, value });
|
|
103
|
+
hasNumeric = hasNumeric || isNumericRange;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (typeof value === 'number') {
|
|
107
|
+
hasNumeric = true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return hasNumeric;
|
|
111
|
+
}
|
|
112
|
+
static isValid(orgType) {
|
|
113
|
+
return this.SCHEME_SET.has(orgType);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=operators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.js","sourceRoot":"","sources":["../../../src/common/operators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAoB,MAAM,0BAA0B,CAAC;AAEtE,8KAA8K;AAE9K,qDAAqD;AACrD,MAAM,OAAO,KAAK;aACA,SAAI,GAAG,MAAM,CAAC;aACd,QAAG,GAAG,KAAK,CAAC;aACZ,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAE9D,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;IACnD,CAAC;;AAGH,0GAA0G;AAC1G,MAAM,oBAAoB,GAAG,CAAC,IAAoC,EAAW,EAAE;IAC7E,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAE3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,mDAAmD,EAAE,yCAAyC,IAAI,CAAC,SAAS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AC,CAAC;YAE5B,IAAI,EAAE,KAAK,IAAI,CAAC,OAAO,IAAI,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC;gBACnD,MAAM,cAAc,GAAG,oBAAoB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;gBAC3D,UAAU,GAAG,UAAU,IAAI,cAAc,CAAC;gBAC1C,SAAS;YACX,CAAC;YAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,UAAU,GAAG,IAAI,CAAC;YACpB,CAAC;QACH,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,OAAe;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** 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. */
|
|
2
|
+
/** Fields selection - an array of field names to include, or an object keyed by field name (`true` includes, `false` excludes). */
|
|
3
|
+
export type TFields<T = any> = Partial<{
|
|
4
|
+
[K in keyof T]: boolean;
|
|
5
|
+
}> | Array<keyof T>;
|
|
6
|
+
/** Query conditions for selecting data, with nested `and` / `or`. */
|
|
7
|
+
export type TWhere<T = any> = {
|
|
8
|
+
[key in keyof T]?: any;
|
|
9
|
+
} & {
|
|
10
|
+
and?: TWhere<T>[];
|
|
11
|
+
or?: TWhere<T>[];
|
|
12
|
+
};
|
|
13
|
+
/** Single relation inclusion configuration. */
|
|
14
|
+
export type TInclusion = {
|
|
15
|
+
relation: string;
|
|
16
|
+
scope?: TFilter;
|
|
17
|
+
shouldSkipDefaultFilter?: boolean;
|
|
18
|
+
};
|
|
19
|
+
/** Maximum number of items to return. Defaults to 10 for top-level list queries. */
|
|
20
|
+
export type TLimit = number | undefined;
|
|
21
|
+
/** Number of items to offset for pagination. */
|
|
22
|
+
export type TOffset = number | undefined;
|
|
23
|
+
/** Number of items to skip for pagination. */
|
|
24
|
+
export type TSkip = number | undefined;
|
|
25
|
+
/** Sorting order for results - regular columns (`fieldName ASC`) and JSON/JSONB paths (`metadata.field DESC`). */
|
|
26
|
+
export type TOrderBy = string[] | undefined;
|
|
27
|
+
/** Comprehensive filter configuration used across all repository query methods. */
|
|
28
|
+
export type TFilter<T = any> = {
|
|
29
|
+
where?: TWhere<T>;
|
|
30
|
+
fields?: TFields;
|
|
31
|
+
include?: TInclusion[];
|
|
32
|
+
order?: string[];
|
|
33
|
+
limit?: number;
|
|
34
|
+
offset?: number;
|
|
35
|
+
skip?: number;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":"AAAA,gTAAgT;AAEhT,mIAAmI;AACnI,MAAM,MAAM,OAAO,CAAC,CAAC,GAAG,GAAG,IAAI,OAAO,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO;CAAE,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AAErF,qEAAqE;AACrE,MAAM,MAAM,MAAM,CAAC,CAAC,GAAG,GAAG,IAAI;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG;CAAE,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;CAAE,CAAC;AAEnG,+CAA+C;AAC/C,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,oFAAoF;AACpF,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAExC,gDAAgD;AAChD,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEzC,8CAA8C;AAC9C,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAEvC,kHAAkH;AAClH,MAAM,MAAM,QAAQ,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;AAE5C,mFAAmF;AACnF,MAAM,MAAM,OAAO,CAAC,CAAC,GAAG,GAAG,IAAI;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** 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. */
|
|
2
|
+
export {};
|
|
3
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":"AAAA,gTAAgT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { TSchemaDecorator } from './common/types';
|
|
3
|
+
export declare const buildQuerySchemas: (opts?: {
|
|
4
|
+
decorate?: TSchemaDecorator;
|
|
5
|
+
}) => {
|
|
6
|
+
FieldsSchema: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodBoolean>, z.ZodArray<z.ZodString>]>>;
|
|
7
|
+
FilterSchema: any;
|
|
8
|
+
InclusionSchema: any;
|
|
9
|
+
LimitSchema: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
OffsetSchema: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
OrderBySchema: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
12
|
+
SkipSchema: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
WhereSchema: z.ZodUnion<readonly [z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>, z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<any, string>>, z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>>]>;
|
|
14
|
+
};
|
|
15
|
+
export type TQuerySchemas = ReturnType<typeof buildQuerySchemas>;
|
|
16
|
+
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../src/schemas/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOvD,eAAO,MAAM,iBAAiB,GAAI,OAAO;IAAE,QAAQ,CAAC,EAAE,gBAAgB,CAAA;CAAE;;;;;;;;;CA8JvE,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** The schemas are built by a factory rather than declared at module scope because documentation metadata has to be injected. `.openapi()` returns a NEW schema instead of mutating, and three of these decorations sit on inner nodes of a nested tree, so a consumer cannot annotate them after the tree is composed - the outer node would still hold the undecorated children. */
|
|
3
|
+
/** Built with plain `zod`, never `@hono/zod-openapi`: the OpenAPI layer pulls in Hono, and these schemas must stay usable in a browser. `@hono/zod-openapi` declares `zod` as a peer, so it patches the same prototype - a server that imports it can decorate these schemas even though they were built without it. */
|
|
4
|
+
const identityDecorator = schema => schema;
|
|
5
|
+
export const buildQuerySchemas = (opts) => {
|
|
6
|
+
const decorate = opts?.decorate ?? identityDecorator;
|
|
7
|
+
const LimitSchema = decorate(z.number().optional(), {
|
|
8
|
+
description: 'Maximum number of items to return. Defaults to 10 for top-level list queries.',
|
|
9
|
+
examples: [1, 2, 3],
|
|
10
|
+
});
|
|
11
|
+
const OffsetSchema = decorate(z.number().optional(), {
|
|
12
|
+
description: 'Number of items to offset for pagination.',
|
|
13
|
+
examples: [1, 2, 3],
|
|
14
|
+
});
|
|
15
|
+
const SkipSchema = decorate(z.number().optional(), {
|
|
16
|
+
description: 'Number of items to skip for pagination.',
|
|
17
|
+
examples: [1, 2, 3],
|
|
18
|
+
});
|
|
19
|
+
const OrderBySchema = decorate(z.array(z.string()).optional(), {
|
|
20
|
+
description: "Sorting order for results. Supports regular columns ('fieldName ASC') and JSON/JSONB paths ('metadata.field DESC', 'data.nested[0].value ASC').",
|
|
21
|
+
examples: [
|
|
22
|
+
'id DESC',
|
|
23
|
+
'createdAt ASC',
|
|
24
|
+
'metadata.priority DESC',
|
|
25
|
+
'data.nested.value ASC',
|
|
26
|
+
'items[0].score DESC',
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
const FieldsSchema = decorate(z.record(z.string(), z.boolean()).or(z.array(z.string())).optional(), {
|
|
30
|
+
description: 'Fields selection - either an array of field names to include, or an object with field names as keys and boolean values (true to include, false to exclude)',
|
|
31
|
+
examples: [
|
|
32
|
+
JSON.stringify(['id', 'name', 'email']),
|
|
33
|
+
JSON.stringify({ id: true, name: true }),
|
|
34
|
+
JSON.stringify({ id: true, name: true, email: true, fullName: false }),
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
/** @internal Recursive schema for where clause validation with nested AND/OR. */
|
|
38
|
+
const RecursiveWhereSchema = z.lazy(() => z.record(z.string(), z.any()).and(z.object({
|
|
39
|
+
and: z.array(RecursiveWhereSchema).optional(),
|
|
40
|
+
or: z.array(RecursiveWhereSchema).optional(),
|
|
41
|
+
})));
|
|
42
|
+
const WhereSchema = decorate(z.union([
|
|
43
|
+
RecursiveWhereSchema,
|
|
44
|
+
z
|
|
45
|
+
.string()
|
|
46
|
+
.transform(val => {
|
|
47
|
+
if (val) {
|
|
48
|
+
return JSON.parse(val);
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
})
|
|
52
|
+
.pipe(RecursiveWhereSchema),
|
|
53
|
+
]), { type: 'object', description: 'Query conditions for selecting data.' });
|
|
54
|
+
/** Zod schema for including related entities in queries with optional nested filtering. */
|
|
55
|
+
const InclusionSchema = decorate(z
|
|
56
|
+
.array(z.object({
|
|
57
|
+
relation: decorate(z.string(), { description: 'Model relation name' }),
|
|
58
|
+
scope: decorate(z
|
|
59
|
+
.lazy(() => FilterSchema) // eslint-disable-line @typescript-eslint/no-use-before-define
|
|
60
|
+
.optional(), { description: 'Model relation filter' }),
|
|
61
|
+
shouldSkipDefaultFilter: decorate(z.boolean().optional(), {
|
|
62
|
+
description: 'Skip the default filter for this relation',
|
|
63
|
+
}),
|
|
64
|
+
}))
|
|
65
|
+
.optional(), {
|
|
66
|
+
description: 'Define related models to include in the response.',
|
|
67
|
+
examples: [
|
|
68
|
+
JSON.stringify({ include: [{ relation: 'posts' }] }),
|
|
69
|
+
JSON.stringify({ include: [{ relation: 'posts', scope: { limit: 5 } }] }),
|
|
70
|
+
],
|
|
71
|
+
});
|
|
72
|
+
/** @internal Filter schema object definition. */
|
|
73
|
+
const InternalFilterSchema = z.object({
|
|
74
|
+
where: WhereSchema.optional(),
|
|
75
|
+
fields: FieldsSchema,
|
|
76
|
+
include: InclusionSchema,
|
|
77
|
+
order: OrderBySchema,
|
|
78
|
+
limit: LimitSchema,
|
|
79
|
+
offset: OffsetSchema,
|
|
80
|
+
skip: SkipSchema,
|
|
81
|
+
});
|
|
82
|
+
/** Comprehensive Zod schema for repository query filtering. Supports object and JSON string formats. */
|
|
83
|
+
const FilterSchema = decorate(z
|
|
84
|
+
.union([
|
|
85
|
+
InternalFilterSchema,
|
|
86
|
+
z
|
|
87
|
+
.string()
|
|
88
|
+
.transform(val => {
|
|
89
|
+
if (val) {
|
|
90
|
+
return JSON.parse(val);
|
|
91
|
+
}
|
|
92
|
+
return {};
|
|
93
|
+
})
|
|
94
|
+
.pipe(InternalFilterSchema),
|
|
95
|
+
])
|
|
96
|
+
.optional(), {
|
|
97
|
+
type: 'object',
|
|
98
|
+
description: 'A comprehensive filter object for querying data, including conditions, field selection, relations, pagination, and sorting.',
|
|
99
|
+
examples: [
|
|
100
|
+
JSON.stringify({ where: { name: 'John Doe' }, limit: 10 }),
|
|
101
|
+
JSON.stringify({
|
|
102
|
+
fields: { id: true, name: true, email: true },
|
|
103
|
+
order: ['createdAt DESC'],
|
|
104
|
+
}),
|
|
105
|
+
JSON.stringify({ include: [{ relation: 'posts', scope: { limit: 5 } }] }),
|
|
106
|
+
JSON.stringify({
|
|
107
|
+
where: { or: [{ status: 'active' }, { isPublished: true }] },
|
|
108
|
+
skip: 20,
|
|
109
|
+
limit: 10,
|
|
110
|
+
}),
|
|
111
|
+
JSON.stringify({
|
|
112
|
+
where: { and: [{ role: 'admin' }, { createdAt: { gte: 'YYYY-MM-DD' } }] },
|
|
113
|
+
}),
|
|
114
|
+
],
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
FieldsSchema,
|
|
118
|
+
FilterSchema,
|
|
119
|
+
InclusionSchema,
|
|
120
|
+
LimitSchema,
|
|
121
|
+
OffsetSchema,
|
|
122
|
+
OrderBySchema,
|
|
123
|
+
SkipSchema,
|
|
124
|
+
WhereSchema,
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../../src/schemas/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,sXAAsX;AACtX,wTAAwT;AAExT,MAAM,iBAAiB,GAAqB,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC;AAE7D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAsC,EAAE,EAAE;IAC1E,MAAM,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,iBAAiB,CAAC;IAErD,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE;QAClD,WAAW,EAAE,+EAA+E;QAC5F,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE;QACnD,WAAW,EAAE,2CAA2C;QACxD,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE;QACjD,WAAW,EAAE,yCAAyC;QACtD,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC7D,WAAW,EACT,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C;YACF,IAAI,CAAC,SAAS,CAAC;gBACb,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,EAAE,CAAC,EAAE;aAC1E,CAAC;SACH;KACF,CACF,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,YAAY;QACZ,eAAe;QACf,WAAW;QACX,YAAY;QACZ,aAAa;QACb,UAAU;QACV,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The metadata a schema carries for documentation. Structural on purpose - naming the OpenAPI library's type here would pull it into a browser bundle, which is the whole thing this package avoids. */
|
|
2
|
+
export type TSchemaMetadata = {
|
|
3
|
+
description?: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
examples?: Array<unknown>;
|
|
6
|
+
};
|
|
7
|
+
/** Applies documentation metadata to a schema and returns it. A server passes an OpenAPI decorator; a browser passes nothing and gets the identity. */
|
|
8
|
+
export type TSchemaDecorator = <TSchema>(schema: TSchema, metadata: TSchemaMetadata) => TSchema;
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/schemas/common/types.ts"],"names":[],"mappings":"AAAA,yMAAyM;AACzM,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CAC3B,CAAC;AAEF,uJAAuJ;AACvJ,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/schemas/common/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './builder';
|
|
2
|
+
export * from './common/types';
|
|
3
|
+
/** Ready-to-use schemas with no documentation metadata attached - the browser case, and the reason most consumers never touch `buildQuerySchemas` directly. */
|
|
4
|
+
export declare const FieldsSchema: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodBoolean>, import("zod").ZodArray<import("zod").ZodString>]>>, FilterSchema: import("zod").ZodOptional<import("zod").ZodUnion<readonly [any, import("zod").ZodPipe<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<any, string>>, any>]>>, InclusionSchema: any, LimitSchema: import("zod").ZodOptional<import("zod").ZodNumber>, OffsetSchema: import("zod").ZodOptional<import("zod").ZodNumber>, OrderBySchema: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>, SkipSchema: import("zod").ZodOptional<import("zod").ZodNumber>, WhereSchema: import("zod").ZodUnion<readonly [import("zod").ZodType<any, unknown, import("zod/v4/core").$ZodTypeInternals<any, unknown>>, import("zod").ZodPipe<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<any, string>>, import("zod").ZodType<any, unknown, import("zod/v4/core").$ZodTypeInternals<any, unknown>>>]>;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schemas/index.ts"],"names":[],"mappings":"AAEA,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAE/B,+JAA+J;AAC/J,eAAO,MACL,YAAY,oLACZ,YAAY,0LACZ,eAAe,OACf,WAAW,sDACX,YAAY,sDACZ,aAAa,8EACb,UAAU,sDACV,WAAW,2UACU,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { buildQuerySchemas } from './builder';
|
|
2
|
+
export * from './builder';
|
|
3
|
+
export * from './common/types';
|
|
4
|
+
/** Ready-to-use schemas with no documentation metadata attached - the browser case, and the reason most consumers never touch `buildQuerySchemas` directly. */
|
|
5
|
+
export const { FieldsSchema, FilterSchema, InclusionSchema, LimitSchema, OffsetSchema, OrderBySchema, SkipSchema, WhereSchema, } = buildQuerySchemas();
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAE/B,+JAA+J;AAC/J,MAAM,CAAC,MAAM,EACX,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,WAAW,EACX,YAAY,EACZ,aAAa,EACb,UAAU,EACV,WAAW,GACZ,GAAG,iBAAiB,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@venizia/ignis-filter",
|
|
3
|
+
"version": "0.1.1",
|
|
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
|
+
"keywords": [
|
|
6
|
+
"browser",
|
|
7
|
+
"filter",
|
|
8
|
+
"ignis",
|
|
9
|
+
"isomorphic",
|
|
10
|
+
"operators",
|
|
11
|
+
"pagination",
|
|
12
|
+
"query",
|
|
13
|
+
"query-builder",
|
|
14
|
+
"query-filter",
|
|
15
|
+
"repository",
|
|
16
|
+
"sorting",
|
|
17
|
+
"typescript",
|
|
18
|
+
"venizia",
|
|
19
|
+
"where-clause"
|
|
20
|
+
],
|
|
21
|
+
"homepage": "https://ignis.venizia.ai",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/VENIZIA-AI/ignis.git",
|
|
25
|
+
"directory": "packages/filter"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/VENIZIA-AI/ignis/issues"
|
|
29
|
+
},
|
|
30
|
+
"author": {
|
|
31
|
+
"name": "VENIZIA AI Developer",
|
|
32
|
+
"email": "developer@venizia.ai",
|
|
33
|
+
"url": "https://venizia.ai"
|
|
34
|
+
},
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"engines": {
|
|
37
|
+
"bun": ">=1.3"
|
|
38
|
+
},
|
|
39
|
+
"main": "./dist/cjs/index.js",
|
|
40
|
+
"exports": {
|
|
41
|
+
".": {
|
|
42
|
+
"types": "./dist/cjs/index.d.ts",
|
|
43
|
+
"import": "./dist/esm/index.js",
|
|
44
|
+
"require": "./dist/cjs/index.js",
|
|
45
|
+
"default": "./dist/cjs/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./schemas": {
|
|
48
|
+
"types": "./dist/cjs/schemas/index.d.ts",
|
|
49
|
+
"import": "./dist/esm/schemas/index.js",
|
|
50
|
+
"require": "./dist/cjs/schemas/index.js",
|
|
51
|
+
"default": "./dist/cjs/schemas/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./package.json": "./package.json"
|
|
54
|
+
},
|
|
55
|
+
"files": [
|
|
56
|
+
"README.md",
|
|
57
|
+
"LICENSE.md",
|
|
58
|
+
"dist",
|
|
59
|
+
"!/**/tests",
|
|
60
|
+
"!/**/dist/tests",
|
|
61
|
+
"!/**/__tests__",
|
|
62
|
+
"!**/*.tsbuildinfo"
|
|
63
|
+
],
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public"
|
|
66
|
+
},
|
|
67
|
+
"sideEffects": false,
|
|
68
|
+
"scripts": {
|
|
69
|
+
"force-update": "sh ./scripts/force-update.sh",
|
|
70
|
+
"build": "sh ./scripts/build.sh",
|
|
71
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
72
|
+
"clean": "sh ./scripts/clean.sh",
|
|
73
|
+
"eslint": "eslint --report-unused-disable-directives .",
|
|
74
|
+
"lint": "bun run eslint && bun run prettier:cli",
|
|
75
|
+
"lint:fix": "bun run eslint --fix && bun run prettier:fix",
|
|
76
|
+
"prettier:cli": "prettier \"**/*.{js,ts}\" -l",
|
|
77
|
+
"prettier:fix": "bun run prettier:cli --write",
|
|
78
|
+
"rebuild": "sh ./scripts/rebuild.sh no-version",
|
|
79
|
+
"prepublishOnly": "bun run rebuild"
|
|
80
|
+
},
|
|
81
|
+
"dependencies": {
|
|
82
|
+
"@venizia/ignis-inversion": "^0.1.1-5",
|
|
83
|
+
"zod": "^4.4.3"
|
|
84
|
+
},
|
|
85
|
+
"devDependencies": {
|
|
86
|
+
"@types/bun": "^1.3.14",
|
|
87
|
+
"@venizia/dev-configs": "^0.1.0",
|
|
88
|
+
"eslint": "^10.7.0",
|
|
89
|
+
"prettier": "^3.9.5",
|
|
90
|
+
"tsc-alias": "^1.9.1",
|
|
91
|
+
"typescript": "^6.0.3"
|
|
92
|
+
}
|
|
93
|
+
}
|