@eienjs/adonisjs-api-query 1.1.1 → 3.0.0
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 → LICENSE} +1 -1
- package/README.md +166 -2
- package/build/configure.d.ts +2 -2
- package/build/configure.js +10 -0
- package/build/index.d.ts +38 -31
- package/build/index.js +38 -154
- package/build/providers/api_query_provider.d.ts +48 -37
- package/build/providers/api_query_provider.js +26 -27
- package/build/src/allowed_filter.d.ts +44 -36
- package/build/src/allowed_filter.js +135 -0
- package/build/src/allowed_include.d.ts +15 -16
- package/build/src/allowed_include.js +47 -0
- package/build/src/allowed_sort.d.ts +17 -17
- package/build/src/allowed_sort.js +49 -0
- package/build/src/api_query_builder_request.d.ts +55 -30
- package/build/src/api_query_builder_request.js +200 -0
- package/build/src/base_filterable.d.ts +45 -0
- package/build/src/base_filterable.js +172 -0
- package/build/src/bindings/api_query_request.js +13 -0
- package/build/src/bindings/filterable_query.js +51 -0
- package/build/src/bindings/filters_query.js +38 -0
- package/build/src/bindings/includes_query.js +50 -0
- package/build/src/bindings/sorts_query.js +42 -0
- package/build/src/bindings/validation_query.js +27 -0
- package/build/src/decorators/filterable.d.ts +20 -0
- package/build/src/decorators/filterable.js +24 -0
- package/build/src/define_config.d.ts +3 -3
- package/build/src/define_config.js +25 -0
- package/build/src/enums/filter_operator.d.ts +8 -9
- package/build/src/enums/filter_operator.js +11 -0
- package/build/src/enums/sort_direction.d.ts +3 -4
- package/build/src/enums/sort_direction.js +6 -0
- package/build/src/exceptions/allowed_fields_must_be_called_before_allowed_includes.d.ts +5 -5
- package/build/src/exceptions/allowed_fields_must_be_called_before_allowed_includes.js +10 -0
- package/build/src/exceptions/filterable_not_configured.d.ts +5 -0
- package/build/src/exceptions/filterable_not_configured.js +12 -0
- package/build/src/exceptions/invalid_append_query.d.ts +6 -4
- package/build/src/exceptions/invalid_append_query.js +17 -0
- package/build/src/exceptions/invalid_direction.d.ts +3 -3
- package/build/src/exceptions/invalid_direction.js +9 -0
- package/build/src/exceptions/invalid_field_query.d.ts +6 -4
- package/build/src/exceptions/invalid_field_query.js +17 -0
- package/build/src/exceptions/invalid_filter_query.d.ts +6 -6
- package/build/src/exceptions/invalid_filter_query.js +17 -0
- package/build/src/exceptions/invalid_filter_value.d.ts +3 -3
- package/build/src/exceptions/invalid_filter_value.js +8 -0
- package/build/src/exceptions/invalid_include_query.d.ts +6 -6
- package/build/src/exceptions/invalid_include_query.js +21 -0
- package/build/src/exceptions/invalid_query.d.ts +3 -3
- package/build/{chunk-XIRHVLVQ.js → src/exceptions/invalid_query.js} +3 -7
- package/build/src/exceptions/invalid_sort_query.d.ts +6 -6
- package/build/src/exceptions/invalid_sort_query.js +17 -0
- package/build/src/exceptions/unknown_included_fields_query.d.ts +4 -4
- package/build/src/exceptions/unknown_included_fields_query.js +12 -0
- package/build/src/exceptions/vine_not_installed.d.ts +5 -0
- package/build/src/exceptions/vine_not_installed.js +12 -0
- package/build/src/filters/filters_begin_with_strict.d.ts +6 -6
- package/build/src/filters/filters_begin_with_strict.js +8 -0
- package/build/src/filters/filters_callback.d.ts +6 -6
- package/build/src/filters/filters_callback.js +11 -0
- package/build/src/filters/filters_ends_with_strict.d.ts +6 -6
- package/build/src/filters/filters_ends_with_strict.js +8 -0
- package/build/src/filters/filters_exact.d.ts +11 -11
- package/build/src/filters/filters_exact.js +50 -0
- package/build/src/filters/filters_operator.d.ts +13 -13
- package/build/src/filters/filters_operator.js +52 -0
- package/build/src/filters/filters_partial.d.ts +9 -11
- package/build/src/filters/filters_partial.js +37 -0
- package/build/src/filters/filters_scope.d.ts +12 -0
- package/build/src/filters/filters_scope.js +98 -0
- package/build/src/filters/filters_trashed.d.ts +5 -5
- package/build/src/filters/filters_trashed.js +13 -0
- package/build/src/includes/included_callback.d.ts +7 -7
- package/build/src/includes/included_callback.js +11 -0
- package/build/src/includes/included_count.d.ts +4 -4
- package/build/src/includes/included_count.js +11 -0
- package/build/src/includes/included_relationship.d.ts +8 -8
- package/build/src/includes/included_relationship.js +37 -0
- package/build/src/sorts/sorts_callback.d.ts +6 -6
- package/build/src/sorts/sorts_callback.js +11 -0
- package/build/src/sorts/sorts_field.d.ts +4 -4
- package/build/src/sorts/sorts_field.js +7 -0
- package/build/src/utils/helpers.js +14 -0
- package/build/src/validation/schema_builder.d.ts +3 -0
- package/build/src/validation/schema_builder.js +38 -0
- package/build/src/validation/vine_resolver.js +13 -0
- package/build/stubs/main.d.ts +1 -1
- package/build/stubs/main.js +3 -0
- package/build/types.d.ts +116 -0
- package/build/types.js +1 -0
- package/package.json +101 -88
- package/build/api_query_request-QXOB4BN6.js +0 -18
- package/build/api_query_request-QXOB4BN6.js.map +0 -1
- package/build/chunk-3ITWUZL5.js +0 -108
- package/build/chunk-3ITWUZL5.js.map +0 -1
- package/build/chunk-54HNQTDY.js +0 -348
- package/build/chunk-54HNQTDY.js.map +0 -1
- package/build/chunk-IV3B5WO7.js +0 -160
- package/build/chunk-IV3B5WO7.js.map +0 -1
- package/build/chunk-MKQ3HMMA.js +0 -198
- package/build/chunk-MKQ3HMMA.js.map +0 -1
- package/build/chunk-XIRHVLVQ.js.map +0 -1
- package/build/filters_query-LCFH2F2X.js +0 -55
- package/build/filters_query-LCFH2F2X.js.map +0 -1
- package/build/includes_query-PVONWQMC.js +0 -70
- package/build/includes_query-PVONWQMC.js.map +0 -1
- package/build/index.js.map +0 -1
- package/build/metafile-esm.json +0 -1
- package/build/providers/api_query_provider.js.map +0 -1
- package/build/sorts_query-NJTC5UXX.js +0 -63
- package/build/sorts_query-NJTC5UXX.js.map +0 -1
- package/build/src/bindings/api_query_request.d.ts +0 -2
- package/build/src/bindings/filters_query.d.ts +0 -3
- package/build/src/bindings/includes_query.d.ts +0 -3
- package/build/src/bindings/sorts_query.d.ts +0 -3
- package/build/src/types.d.ts +0 -90
- package/build/src/types.js +0 -1
- package/build/src/types.js.map +0 -1
- package/build/src/utils/helpers.d.ts +0 -3
- /package/build/{config.stub → stubs/config.stub} +0 -0
package/build/src/types.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { type LucidModel, type ModelAttributes, type ModelQueryBuilderContract } from '@adonisjs/lucid/types/model';
|
|
2
|
-
import { type StrictValuesWithoutRaw } from '@adonisjs/lucid/types/querybuilder';
|
|
3
|
-
export interface ApiQueryConfigParameters {
|
|
4
|
-
include?: string;
|
|
5
|
-
filter?: string;
|
|
6
|
-
sort?: string;
|
|
7
|
-
fields?: string;
|
|
8
|
-
append?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface ApiQueryConfig {
|
|
11
|
-
/**
|
|
12
|
-
* By default the package will use the `include`, `filter`, `sort`
|
|
13
|
-
* and `fields` query parameters as described in the readme.
|
|
14
|
-
*
|
|
15
|
-
* You can customize these query string parameters here.
|
|
16
|
-
*/
|
|
17
|
-
parameters?: ApiQueryConfigParameters;
|
|
18
|
-
/**
|
|
19
|
-
* Related model counts are included using the relationship name suffixed with this string.
|
|
20
|
-
* For example: GET /users?include=postsCount
|
|
21
|
-
*/
|
|
22
|
-
countSuffix?: string;
|
|
23
|
-
/**
|
|
24
|
-
* Related model exists are included using the relationship name suffixed with this string.
|
|
25
|
-
* For example: GET /users?include=postsExists
|
|
26
|
-
*/
|
|
27
|
-
existsSuffix?: string;
|
|
28
|
-
/**
|
|
29
|
-
* By default the package will throw an `InvalidFilterQuery` exception when a filter in the
|
|
30
|
-
* URL is not allowed in the `allowedFilters()` method.
|
|
31
|
-
*/
|
|
32
|
-
disableInvalidFilterQueryException?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* By default the package will throw an `InvalidSortQuery` exception when a sort in the
|
|
35
|
-
* URL is not allowed in the `allowedSorts()` method.
|
|
36
|
-
*/
|
|
37
|
-
disableInvalidSortQueryException?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* By default the package will throw an `InvalidIncludeQuery` exception when an include in the
|
|
40
|
-
* URL is not allowed in the `allowedIncludes()` method.
|
|
41
|
-
*/
|
|
42
|
-
disableInvalidIncludesQueryException?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* By default, the package expects relationship names to be camel case plural when using fields[relationship].
|
|
45
|
-
* For example, fetching the id and name for a userOwner relation would look like this:
|
|
46
|
-
* GET /users?fields[userOwner]=id,name
|
|
47
|
-
*
|
|
48
|
-
* Set this to `true` if you don't want that and keep the requested relationship names as-is and allows you to
|
|
49
|
-
* request the fields using a snake case relationship name:
|
|
50
|
-
* GET /users?fields[user_owner]=id,name
|
|
51
|
-
*/
|
|
52
|
-
convertRelationNamesToSnakeCasePlural?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* By default, the package expects relationship names to be camel case plural when using fields[relationship].
|
|
55
|
-
* For example, fetching the id and name for a userOwner relation would look like this:
|
|
56
|
-
* GET /users?fields[userOwner]=id,name
|
|
57
|
-
*
|
|
58
|
-
* Set this to one of `snake_case`, `camelCase` or `none` if you want to enable table name resolution in addition to the relation name resolution
|
|
59
|
-
* GET /users?include=top_orders&fields[orders]=id,name
|
|
60
|
-
*/
|
|
61
|
-
convertRelationTableNameStrategy?: 'snake_case' | 'camelCase' | 'none' | false;
|
|
62
|
-
/**
|
|
63
|
-
* By default, the package expects the field names to match the database names
|
|
64
|
-
* For example, fetching the field named firstName would look like this:
|
|
65
|
-
* GET /users?fields=firstName
|
|
66
|
-
*
|
|
67
|
-
* Set this to `true` if you want to convert the firstName into first_name for the underlying query
|
|
68
|
-
*/
|
|
69
|
-
convertFieldNamesToSnakeCase?: boolean;
|
|
70
|
-
}
|
|
71
|
-
export type ResolvedApiQueryConfig = Required<ApiQueryConfig> & {
|
|
72
|
-
parameters: Required<ApiQueryConfigParameters>;
|
|
73
|
-
};
|
|
74
|
-
export interface Sort<Model extends LucidModel> {
|
|
75
|
-
handle(query: ModelQueryBuilderContract<Model, InstanceType<Model>>, descending: boolean, property: string): void;
|
|
76
|
-
}
|
|
77
|
-
export interface Filter<Model extends LucidModel> {
|
|
78
|
-
handle(query: ModelQueryBuilderContract<Model, InstanceType<Model>>, value: StrictValuesWithoutRaw | null, property: string): void;
|
|
79
|
-
}
|
|
80
|
-
export interface Include<ParentModel extends LucidModel> {
|
|
81
|
-
handle(query: ModelQueryBuilderContract<ParentModel, InstanceType<ParentModel>>, include: string): void;
|
|
82
|
-
}
|
|
83
|
-
export type ExtractKeys<T> = T extends object ? {
|
|
84
|
-
[K in keyof T & string]: K;
|
|
85
|
-
}[keyof T & string] : never;
|
|
86
|
-
export type ExtractKeysWithSort<T> = T extends object ? {
|
|
87
|
-
[K in keyof T & string]: `-${K}`;
|
|
88
|
-
}[keyof T & string] : never;
|
|
89
|
-
export type SortUnionKeyParams<Model extends LucidModel> = ExtractKeys<ModelAttributes<InstanceType<Model>>> | ExtractKeysWithSort<ModelAttributes<InstanceType<Model>>>;
|
|
90
|
-
export type HintedString<KnownValues> = KnownValues extends string ? (string & {}) | KnownValues : never;
|
package/build/src/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=types.js.map
|
package/build/src/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
File without changes
|