@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.
Files changed (120) hide show
  1. package/{LICENSE.md → LICENSE} +1 -1
  2. package/README.md +166 -2
  3. package/build/configure.d.ts +2 -2
  4. package/build/configure.js +10 -0
  5. package/build/index.d.ts +38 -31
  6. package/build/index.js +38 -154
  7. package/build/providers/api_query_provider.d.ts +48 -37
  8. package/build/providers/api_query_provider.js +26 -27
  9. package/build/src/allowed_filter.d.ts +44 -36
  10. package/build/src/allowed_filter.js +135 -0
  11. package/build/src/allowed_include.d.ts +15 -16
  12. package/build/src/allowed_include.js +47 -0
  13. package/build/src/allowed_sort.d.ts +17 -17
  14. package/build/src/allowed_sort.js +49 -0
  15. package/build/src/api_query_builder_request.d.ts +55 -30
  16. package/build/src/api_query_builder_request.js +200 -0
  17. package/build/src/base_filterable.d.ts +45 -0
  18. package/build/src/base_filterable.js +172 -0
  19. package/build/src/bindings/api_query_request.js +13 -0
  20. package/build/src/bindings/filterable_query.js +51 -0
  21. package/build/src/bindings/filters_query.js +38 -0
  22. package/build/src/bindings/includes_query.js +50 -0
  23. package/build/src/bindings/sorts_query.js +42 -0
  24. package/build/src/bindings/validation_query.js +27 -0
  25. package/build/src/decorators/filterable.d.ts +20 -0
  26. package/build/src/decorators/filterable.js +24 -0
  27. package/build/src/define_config.d.ts +3 -3
  28. package/build/src/define_config.js +25 -0
  29. package/build/src/enums/filter_operator.d.ts +8 -9
  30. package/build/src/enums/filter_operator.js +11 -0
  31. package/build/src/enums/sort_direction.d.ts +3 -4
  32. package/build/src/enums/sort_direction.js +6 -0
  33. package/build/src/exceptions/allowed_fields_must_be_called_before_allowed_includes.d.ts +5 -5
  34. package/build/src/exceptions/allowed_fields_must_be_called_before_allowed_includes.js +10 -0
  35. package/build/src/exceptions/filterable_not_configured.d.ts +5 -0
  36. package/build/src/exceptions/filterable_not_configured.js +12 -0
  37. package/build/src/exceptions/invalid_append_query.d.ts +6 -4
  38. package/build/src/exceptions/invalid_append_query.js +17 -0
  39. package/build/src/exceptions/invalid_direction.d.ts +3 -3
  40. package/build/src/exceptions/invalid_direction.js +9 -0
  41. package/build/src/exceptions/invalid_field_query.d.ts +6 -4
  42. package/build/src/exceptions/invalid_field_query.js +17 -0
  43. package/build/src/exceptions/invalid_filter_query.d.ts +6 -6
  44. package/build/src/exceptions/invalid_filter_query.js +17 -0
  45. package/build/src/exceptions/invalid_filter_value.d.ts +3 -3
  46. package/build/src/exceptions/invalid_filter_value.js +8 -0
  47. package/build/src/exceptions/invalid_include_query.d.ts +6 -6
  48. package/build/src/exceptions/invalid_include_query.js +21 -0
  49. package/build/src/exceptions/invalid_query.d.ts +3 -3
  50. package/build/{chunk-XIRHVLVQ.js → src/exceptions/invalid_query.js} +3 -7
  51. package/build/src/exceptions/invalid_sort_query.d.ts +6 -6
  52. package/build/src/exceptions/invalid_sort_query.js +17 -0
  53. package/build/src/exceptions/unknown_included_fields_query.d.ts +4 -4
  54. package/build/src/exceptions/unknown_included_fields_query.js +12 -0
  55. package/build/src/exceptions/vine_not_installed.d.ts +5 -0
  56. package/build/src/exceptions/vine_not_installed.js +12 -0
  57. package/build/src/filters/filters_begin_with_strict.d.ts +6 -6
  58. package/build/src/filters/filters_begin_with_strict.js +8 -0
  59. package/build/src/filters/filters_callback.d.ts +6 -6
  60. package/build/src/filters/filters_callback.js +11 -0
  61. package/build/src/filters/filters_ends_with_strict.d.ts +6 -6
  62. package/build/src/filters/filters_ends_with_strict.js +8 -0
  63. package/build/src/filters/filters_exact.d.ts +11 -11
  64. package/build/src/filters/filters_exact.js +50 -0
  65. package/build/src/filters/filters_operator.d.ts +13 -13
  66. package/build/src/filters/filters_operator.js +52 -0
  67. package/build/src/filters/filters_partial.d.ts +9 -11
  68. package/build/src/filters/filters_partial.js +37 -0
  69. package/build/src/filters/filters_scope.d.ts +12 -0
  70. package/build/src/filters/filters_scope.js +98 -0
  71. package/build/src/filters/filters_trashed.d.ts +5 -5
  72. package/build/src/filters/filters_trashed.js +13 -0
  73. package/build/src/includes/included_callback.d.ts +7 -7
  74. package/build/src/includes/included_callback.js +11 -0
  75. package/build/src/includes/included_count.d.ts +4 -4
  76. package/build/src/includes/included_count.js +11 -0
  77. package/build/src/includes/included_relationship.d.ts +8 -8
  78. package/build/src/includes/included_relationship.js +37 -0
  79. package/build/src/sorts/sorts_callback.d.ts +6 -6
  80. package/build/src/sorts/sorts_callback.js +11 -0
  81. package/build/src/sorts/sorts_field.d.ts +4 -4
  82. package/build/src/sorts/sorts_field.js +7 -0
  83. package/build/src/utils/helpers.js +14 -0
  84. package/build/src/validation/schema_builder.d.ts +3 -0
  85. package/build/src/validation/schema_builder.js +38 -0
  86. package/build/src/validation/vine_resolver.js +13 -0
  87. package/build/stubs/main.d.ts +1 -1
  88. package/build/stubs/main.js +3 -0
  89. package/build/types.d.ts +116 -0
  90. package/build/types.js +1 -0
  91. package/package.json +101 -88
  92. package/build/api_query_request-QXOB4BN6.js +0 -18
  93. package/build/api_query_request-QXOB4BN6.js.map +0 -1
  94. package/build/chunk-3ITWUZL5.js +0 -108
  95. package/build/chunk-3ITWUZL5.js.map +0 -1
  96. package/build/chunk-54HNQTDY.js +0 -348
  97. package/build/chunk-54HNQTDY.js.map +0 -1
  98. package/build/chunk-IV3B5WO7.js +0 -160
  99. package/build/chunk-IV3B5WO7.js.map +0 -1
  100. package/build/chunk-MKQ3HMMA.js +0 -198
  101. package/build/chunk-MKQ3HMMA.js.map +0 -1
  102. package/build/chunk-XIRHVLVQ.js.map +0 -1
  103. package/build/filters_query-LCFH2F2X.js +0 -55
  104. package/build/filters_query-LCFH2F2X.js.map +0 -1
  105. package/build/includes_query-PVONWQMC.js +0 -70
  106. package/build/includes_query-PVONWQMC.js.map +0 -1
  107. package/build/index.js.map +0 -1
  108. package/build/metafile-esm.json +0 -1
  109. package/build/providers/api_query_provider.js.map +0 -1
  110. package/build/sorts_query-NJTC5UXX.js +0 -63
  111. package/build/sorts_query-NJTC5UXX.js.map +0 -1
  112. package/build/src/bindings/api_query_request.d.ts +0 -2
  113. package/build/src/bindings/filters_query.d.ts +0 -3
  114. package/build/src/bindings/includes_query.d.ts +0 -3
  115. package/build/src/bindings/sorts_query.d.ts +0 -3
  116. package/build/src/types.d.ts +0 -90
  117. package/build/src/types.js +0 -1
  118. package/build/src/types.js.map +0 -1
  119. package/build/src/utils/helpers.d.ts +0 -3
  120. /package/build/{config.stub → stubs/config.stub} +0 -0
@@ -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;
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,3 +0,0 @@
1
- export declare const substrReplace: (str: string, replace: string, start: number, length?: number) => string;
2
- export declare const strBeforeLast: (subject: string, search: string) => string;
3
- export declare const strAfterLast: (subject: string, search: string) => string;
File without changes