@krak-stack/registry 0.1.56 → 0.1.57

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.
@@ -28,6 +28,80 @@ export declare const SortParams: Schema.declare<readonly {
28
28
  readonly id: string;
29
29
  readonly direction: "asc" | "desc";
30
30
  }[]>;
31
+ export declare const TextFilterOperator: Schema.Literals<readonly ["contains", "equals", "startsWith", "endsWith"]>;
32
+ export declare const ColumnFilter: Schema.Union<readonly [Schema.Struct<{
33
+ readonly id: Schema.NonEmptyString;
34
+ readonly kind: Schema.Literal<"text">;
35
+ readonly operator: Schema.Literals<readonly ["contains", "equals", "startsWith", "endsWith"]>;
36
+ readonly value: Schema.NonEmptyString;
37
+ }>, Schema.Struct<{
38
+ readonly id: Schema.NonEmptyString;
39
+ readonly kind: Schema.Literal<"number">;
40
+ readonly min: Schema.optional<Schema.Finite>;
41
+ readonly max: Schema.optional<Schema.Finite>;
42
+ }>, Schema.Struct<{
43
+ readonly id: Schema.NonEmptyString;
44
+ readonly kind: Schema.Literal<"date">;
45
+ readonly from: Schema.optional<Schema.String>;
46
+ readonly to: Schema.optional<Schema.String>;
47
+ }>, Schema.Struct<{
48
+ readonly id: Schema.NonEmptyString;
49
+ readonly kind: Schema.Literal<"boolean">;
50
+ readonly value: Schema.Boolean;
51
+ }>, Schema.Struct<{
52
+ readonly id: Schema.NonEmptyString;
53
+ readonly kind: Schema.Literal<"values">;
54
+ readonly values: Schema.NonEmptyArray<Schema.String>;
55
+ }>]>;
56
+ export type ColumnFilter = typeof ColumnFilter.Type;
57
+ /** Structured in router/JSON state; schema-validated JSON in HTTP query strings. */
58
+ export declare const ColumnFilters: Schema.declare<readonly ({
59
+ readonly id: string;
60
+ readonly kind: "number";
61
+ readonly min?: number | undefined;
62
+ readonly max?: number | undefined;
63
+ } | {
64
+ readonly id: string;
65
+ readonly kind: "date";
66
+ readonly from?: string | undefined;
67
+ readonly to?: string | undefined;
68
+ } | {
69
+ readonly id: string;
70
+ readonly kind: "text";
71
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
72
+ readonly value: string;
73
+ } | {
74
+ readonly id: string;
75
+ readonly kind: "boolean";
76
+ readonly value: boolean;
77
+ } | {
78
+ readonly id: string;
79
+ readonly kind: "values";
80
+ readonly values: readonly [string, ...string[]];
81
+ })[], readonly ({
82
+ readonly id: string;
83
+ readonly kind: "number";
84
+ readonly min?: number | undefined;
85
+ readonly max?: number | undefined;
86
+ } | {
87
+ readonly id: string;
88
+ readonly kind: "date";
89
+ readonly from?: string | undefined;
90
+ readonly to?: string | undefined;
91
+ } | {
92
+ readonly id: string;
93
+ readonly kind: "text";
94
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
95
+ readonly value: string;
96
+ } | {
97
+ readonly id: string;
98
+ readonly kind: "boolean";
99
+ readonly value: boolean;
100
+ } | {
101
+ readonly id: string;
102
+ readonly kind: "values";
103
+ readonly values: readonly [string, ...string[]];
104
+ })[]>;
31
105
  export declare const Query: Schema.Struct<{
32
106
  readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
33
107
  readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
@@ -39,6 +113,53 @@ export declare const Query: Schema.Struct<{
39
113
  readonly id: string;
40
114
  readonly direction: "asc" | "desc";
41
115
  }[]>>;
116
+ readonly filters: Schema.optional<Schema.declare<readonly ({
117
+ readonly id: string;
118
+ readonly kind: "number";
119
+ readonly min?: number | undefined;
120
+ readonly max?: number | undefined;
121
+ } | {
122
+ readonly id: string;
123
+ readonly kind: "date";
124
+ readonly from?: string | undefined;
125
+ readonly to?: string | undefined;
126
+ } | {
127
+ readonly id: string;
128
+ readonly kind: "text";
129
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
130
+ readonly value: string;
131
+ } | {
132
+ readonly id: string;
133
+ readonly kind: "boolean";
134
+ readonly value: boolean;
135
+ } | {
136
+ readonly id: string;
137
+ readonly kind: "values";
138
+ readonly values: readonly [string, ...string[]];
139
+ })[], readonly ({
140
+ readonly id: string;
141
+ readonly kind: "number";
142
+ readonly min?: number | undefined;
143
+ readonly max?: number | undefined;
144
+ } | {
145
+ readonly id: string;
146
+ readonly kind: "date";
147
+ readonly from?: string | undefined;
148
+ readonly to?: string | undefined;
149
+ } | {
150
+ readonly id: string;
151
+ readonly kind: "text";
152
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
153
+ readonly value: string;
154
+ } | {
155
+ readonly id: string;
156
+ readonly kind: "boolean";
157
+ readonly value: boolean;
158
+ } | {
159
+ readonly id: string;
160
+ readonly kind: "values";
161
+ readonly values: readonly [string, ...string[]];
162
+ })[]>>;
42
163
  }>;
43
164
  export type QueryType = typeof Query.Type;
44
165
  export type QueryEncoded = typeof Query.Encoded;
@@ -50,6 +171,30 @@ export declare const QueryStandard: import("effect/StandardSchema").StandardSche
50
171
  readonly id: string;
51
172
  readonly direction: "asc" | "desc";
52
173
  }[] | undefined;
174
+ readonly filters?: readonly ({
175
+ readonly id: string;
176
+ readonly kind: "number";
177
+ readonly min?: number | undefined;
178
+ readonly max?: number | undefined;
179
+ } | {
180
+ readonly id: string;
181
+ readonly kind: "date";
182
+ readonly from?: string | undefined;
183
+ readonly to?: string | undefined;
184
+ } | {
185
+ readonly id: string;
186
+ readonly kind: "text";
187
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
188
+ readonly value: string;
189
+ } | {
190
+ readonly id: string;
191
+ readonly kind: "boolean";
192
+ readonly value: boolean;
193
+ } | {
194
+ readonly id: string;
195
+ readonly kind: "values";
196
+ readonly values: readonly [string, ...string[]];
197
+ })[] | undefined;
53
198
  }, {
54
199
  readonly page: number;
55
200
  readonly pageSize: number;
@@ -58,6 +203,30 @@ export declare const QueryStandard: import("effect/StandardSchema").StandardSche
58
203
  readonly id: string;
59
204
  readonly direction: "asc" | "desc";
60
205
  }[] | undefined;
206
+ readonly filters?: readonly ({
207
+ readonly id: string;
208
+ readonly kind: "number";
209
+ readonly min?: number | undefined;
210
+ readonly max?: number | undefined;
211
+ } | {
212
+ readonly id: string;
213
+ readonly kind: "date";
214
+ readonly from?: string | undefined;
215
+ readonly to?: string | undefined;
216
+ } | {
217
+ readonly id: string;
218
+ readonly kind: "text";
219
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
220
+ readonly value: string;
221
+ } | {
222
+ readonly id: string;
223
+ readonly kind: "boolean";
224
+ readonly value: boolean;
225
+ } | {
226
+ readonly id: string;
227
+ readonly kind: "values";
228
+ readonly values: readonly [string, ...string[]];
229
+ })[] | undefined;
61
230
  }> & Schema.Struct<{
62
231
  readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
63
232
  readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
@@ -69,6 +238,53 @@ export declare const QueryStandard: import("effect/StandardSchema").StandardSche
69
238
  readonly id: string;
70
239
  readonly direction: "asc" | "desc";
71
240
  }[]>>;
241
+ readonly filters: Schema.optional<Schema.declare<readonly ({
242
+ readonly id: string;
243
+ readonly kind: "number";
244
+ readonly min?: number | undefined;
245
+ readonly max?: number | undefined;
246
+ } | {
247
+ readonly id: string;
248
+ readonly kind: "date";
249
+ readonly from?: string | undefined;
250
+ readonly to?: string | undefined;
251
+ } | {
252
+ readonly id: string;
253
+ readonly kind: "text";
254
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
255
+ readonly value: string;
256
+ } | {
257
+ readonly id: string;
258
+ readonly kind: "boolean";
259
+ readonly value: boolean;
260
+ } | {
261
+ readonly id: string;
262
+ readonly kind: "values";
263
+ readonly values: readonly [string, ...string[]];
264
+ })[], readonly ({
265
+ readonly id: string;
266
+ readonly kind: "number";
267
+ readonly min?: number | undefined;
268
+ readonly max?: number | undefined;
269
+ } | {
270
+ readonly id: string;
271
+ readonly kind: "date";
272
+ readonly from?: string | undefined;
273
+ readonly to?: string | undefined;
274
+ } | {
275
+ readonly id: string;
276
+ readonly kind: "text";
277
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
278
+ readonly value: string;
279
+ } | {
280
+ readonly id: string;
281
+ readonly kind: "boolean";
282
+ readonly value: boolean;
283
+ } | {
284
+ readonly id: string;
285
+ readonly kind: "values";
286
+ readonly values: readonly [string, ...string[]];
287
+ })[]>>;
72
288
  }>;
73
289
  export declare const PaginationMeta: Schema.Struct<{
74
290
  readonly page: Schema.Int;
package/dist/lib/query.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // ../../src/lib/query.ts
2
2
  import {
3
+ DateTime,
3
4
  Effect,
4
5
  Option,
5
6
  Schema,
@@ -80,6 +81,49 @@ var SortParams = Schema.declare(Schema.is(SortParamsArray), {
80
81
  toCodec: () => Schema.link()(SortParamsArray, SchemaTransformation.passthrough()),
81
82
  toCodecStringTree: () => Schema.link()(SortParamsFromString, SchemaTransformation.passthrough())
82
83
  });
84
+ var TextFilterOperator = Schema.Literals([
85
+ "contains",
86
+ "equals",
87
+ "startsWith",
88
+ "endsWith"
89
+ ]).annotate({ identifier: "TextFilterOperator" });
90
+ var FilterCalendarDate = Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}$/), Schema.makeFilter((value) => Option.exists(DateTime.make(value), (date) => DateTime.formatIsoDateUtc(date) === value))).annotate({ identifier: "FilterCalendarDate" });
91
+ var ColumnFilter = Schema.Union([
92
+ Schema.Struct({
93
+ id: Schema.NonEmptyString,
94
+ kind: Schema.Literal("text"),
95
+ operator: TextFilterOperator,
96
+ value: Schema.NonEmptyString
97
+ }),
98
+ Schema.Struct({
99
+ id: Schema.NonEmptyString,
100
+ kind: Schema.Literal("number"),
101
+ min: Schema.optional(Schema.Finite),
102
+ max: Schema.optional(Schema.Finite)
103
+ }).check(Schema.makeFilter((range) => (range.min !== undefined || range.max !== undefined) && (range.min === undefined || range.max === undefined || range.min <= range.max))),
104
+ Schema.Struct({
105
+ id: Schema.NonEmptyString,
106
+ kind: Schema.Literal("date"),
107
+ from: Schema.optional(FilterCalendarDate),
108
+ to: Schema.optional(FilterCalendarDate)
109
+ }).check(Schema.makeFilter((range) => (range.from !== undefined || range.to !== undefined) && (range.from === undefined || range.to === undefined || range.from <= range.to))),
110
+ Schema.Struct({
111
+ id: Schema.NonEmptyString,
112
+ kind: Schema.Literal("boolean"),
113
+ value: Schema.Boolean
114
+ }),
115
+ Schema.Struct({
116
+ id: Schema.NonEmptyString,
117
+ kind: Schema.Literal("values"),
118
+ values: Schema.NonEmptyArray(Schema.String)
119
+ })
120
+ ]).annotate({ identifier: "ColumnFilter" });
121
+ var ColumnFiltersArray = Schema.Array(ColumnFilter);
122
+ var ColumnFilters = Schema.declare(Schema.is(ColumnFiltersArray), {
123
+ identifier: "ColumnFilters",
124
+ toCodec: () => Schema.link()(ColumnFiltersArray, SchemaTransformation.passthrough()),
125
+ toCodecStringTree: () => Schema.link()(Schema.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
126
+ });
83
127
  var Query = Schema.Struct({
84
128
  page: Schema.optional(Schema.Union([Schema.Number, Schema.NumberFromString]).check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0))).pipe(Schema.decodeTo(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)), {
85
129
  decode: SchemaGetter.withDefault(Effect.succeed(0)),
@@ -90,7 +134,8 @@ var Query = Schema.Struct({
90
134
  encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== 20))
91
135
  })),
92
136
  globalFilter: Schema.optional(Schema.String),
93
- sort: Schema.optional(SortParams)
137
+ sort: Schema.optional(SortParams),
138
+ filters: Schema.optional(ColumnFilters)
94
139
  }).annotate({
95
140
  identifier: "Query",
96
141
  title: "Query",
@@ -124,6 +169,8 @@ var PaginatedResponse = (items) => Schema.Struct({
124
169
  meta: PaginationMeta
125
170
  });
126
171
  export {
172
+ ColumnFilter,
173
+ ColumnFilters,
127
174
  PaginatedResponse,
128
175
  PaginationMeta,
129
176
  Query,
@@ -132,5 +179,6 @@ export {
132
179
  SortParam,
133
180
  SortParamFromString,
134
181
  SortParams,
135
- SortParamsFromString
182
+ SortParamsFromString,
183
+ TextFilterOperator
136
184
  };
@@ -235,6 +235,7 @@ import { Effect as Effect4, Option as Option4, Schema as Schema5 } from "effect"
235
235
 
236
236
  // ../../src/lib/query.ts
237
237
  import {
238
+ DateTime as DateTime2,
238
239
  Effect as Effect3,
239
240
  Option as Option3,
240
241
  Schema as Schema4,
@@ -315,6 +316,49 @@ var SortParams = Schema4.declare(Schema4.is(SortParamsArray), {
315
316
  toCodec: () => Schema4.link()(SortParamsArray, SchemaTransformation.passthrough()),
316
317
  toCodecStringTree: () => Schema4.link()(SortParamsFromString, SchemaTransformation.passthrough())
317
318
  });
319
+ var TextFilterOperator = Schema4.Literals([
320
+ "contains",
321
+ "equals",
322
+ "startsWith",
323
+ "endsWith"
324
+ ]).annotate({ identifier: "TextFilterOperator" });
325
+ var FilterCalendarDate = Schema4.String.check(Schema4.isPattern(/^\d{4}-\d{2}-\d{2}$/), Schema4.makeFilter((value) => Option3.exists(DateTime2.make(value), (date) => DateTime2.formatIsoDateUtc(date) === value))).annotate({ identifier: "FilterCalendarDate" });
326
+ var ColumnFilter = Schema4.Union([
327
+ Schema4.Struct({
328
+ id: Schema4.NonEmptyString,
329
+ kind: Schema4.Literal("text"),
330
+ operator: TextFilterOperator,
331
+ value: Schema4.NonEmptyString
332
+ }),
333
+ Schema4.Struct({
334
+ id: Schema4.NonEmptyString,
335
+ kind: Schema4.Literal("number"),
336
+ min: Schema4.optional(Schema4.Finite),
337
+ max: Schema4.optional(Schema4.Finite)
338
+ }).check(Schema4.makeFilter((range) => (range.min !== undefined || range.max !== undefined) && (range.min === undefined || range.max === undefined || range.min <= range.max))),
339
+ Schema4.Struct({
340
+ id: Schema4.NonEmptyString,
341
+ kind: Schema4.Literal("date"),
342
+ from: Schema4.optional(FilterCalendarDate),
343
+ to: Schema4.optional(FilterCalendarDate)
344
+ }).check(Schema4.makeFilter((range) => (range.from !== undefined || range.to !== undefined) && (range.from === undefined || range.to === undefined || range.from <= range.to))),
345
+ Schema4.Struct({
346
+ id: Schema4.NonEmptyString,
347
+ kind: Schema4.Literal("boolean"),
348
+ value: Schema4.Boolean
349
+ }),
350
+ Schema4.Struct({
351
+ id: Schema4.NonEmptyString,
352
+ kind: Schema4.Literal("values"),
353
+ values: Schema4.NonEmptyArray(Schema4.String)
354
+ })
355
+ ]).annotate({ identifier: "ColumnFilter" });
356
+ var ColumnFiltersArray = Schema4.Array(ColumnFilter);
357
+ var ColumnFilters = Schema4.declare(Schema4.is(ColumnFiltersArray), {
358
+ identifier: "ColumnFilters",
359
+ toCodec: () => Schema4.link()(ColumnFiltersArray, SchemaTransformation.passthrough()),
360
+ toCodecStringTree: () => Schema4.link()(Schema4.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
361
+ });
318
362
  var Query = Schema4.Struct({
319
363
  page: Schema4.optional(Schema4.Union([Schema4.Number, Schema4.NumberFromString]).check(Schema4.isInt(), Schema4.isGreaterThanOrEqualTo(0))).pipe(Schema4.decodeTo(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)), {
320
364
  decode: SchemaGetter.withDefault(Effect3.succeed(0)),
@@ -325,7 +369,8 @@ var Query = Schema4.Struct({
325
369
  encode: SchemaGetter.transformOptional(Option3.filter((pageSize) => pageSize !== 20))
326
370
  })),
327
371
  globalFilter: Schema4.optional(Schema4.String),
328
- sort: Schema4.optional(SortParams)
372
+ sort: Schema4.optional(SortParams),
373
+ filters: Schema4.optional(ColumnFilters)
329
374
  }).annotate({
330
375
  identifier: "Query",
331
376
  title: "Query",