ng-qubee 3.3.0 → 3.4.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/README.md +40 -883
- package/fesm2022/ng-qubee.mjs +315 -14
- package/fesm2022/ng-qubee.mjs.map +1 -1
- package/package.json +16 -9
- package/types/ng-qubee.d.ts +171 -2
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"name": "Andrea Tantimonaco",
|
|
5
5
|
"url": "https://andreatantimonaco.me"
|
|
6
6
|
},
|
|
7
|
-
"version": "3.
|
|
7
|
+
"version": "3.4.0",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -13,20 +13,27 @@
|
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/AndreaAlhena/ng-qubee/issues"
|
|
15
15
|
},
|
|
16
|
-
"homepage": "https://
|
|
16
|
+
"homepage": "https://ng-qubee.andreatantimonaco.me",
|
|
17
17
|
"keywords": [
|
|
18
18
|
"angular",
|
|
19
|
-
"query-builder",
|
|
20
19
|
"api",
|
|
21
|
-
"
|
|
22
|
-
"rxjs",
|
|
20
|
+
"builder",
|
|
23
21
|
"filter",
|
|
22
|
+
"headless-cms",
|
|
23
|
+
"json-api",
|
|
24
|
+
"laravel",
|
|
25
|
+
"nestjs",
|
|
26
|
+
"nestjs-paginate",
|
|
27
|
+
"pagination",
|
|
28
|
+
"postgrest",
|
|
24
29
|
"query",
|
|
25
|
-
"builder",
|
|
26
|
-
"
|
|
30
|
+
"query-builder",
|
|
31
|
+
"rxjs",
|
|
27
32
|
"signals",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
33
|
+
"spatie",
|
|
34
|
+
"strapi",
|
|
35
|
+
"supabase",
|
|
36
|
+
"typescript"
|
|
30
37
|
],
|
|
31
38
|
"allowedNonPeerDependencies": [
|
|
32
39
|
"qs"
|
package/types/ng-qubee.d.ts
CHANGED
|
@@ -50,7 +50,8 @@ declare enum DriverEnum {
|
|
|
50
50
|
LARAVEL = "laravel",
|
|
51
51
|
NESTJS = "nestjs",
|
|
52
52
|
POSTGREST = "postgrest",
|
|
53
|
-
SPATIE = "spatie"
|
|
53
|
+
SPATIE = "spatie",
|
|
54
|
+
STRAPI = "strapi"
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
/**
|
|
@@ -2110,5 +2111,173 @@ declare class SpatieResponseStrategy implements IResponseStrategy {
|
|
|
2110
2111
|
paginate<T extends IPaginatedObject>(response: Record<string, any>, options: ResponseOptions): PaginatedCollection<T>;
|
|
2111
2112
|
}
|
|
2112
2113
|
|
|
2113
|
-
|
|
2114
|
+
/**
|
|
2115
|
+
* Request strategy for the Strapi driver
|
|
2116
|
+
*
|
|
2117
|
+
* Generates URIs in [Strapi's filter API format](https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication):
|
|
2118
|
+
* - Filters: `filters[field][$eq]=value` (multi-value collapses to `$in`)
|
|
2119
|
+
* - Operator filters: `filters[field][$op]=value` (translated from
|
|
2120
|
+
* `FilterOperatorEnum` — `BTW`→`$between`, `SW`→`$startsWith`,
|
|
2121
|
+
* `ILIKE`→`$containsi`, `NOT`→`$ne`/`$notIn`,
|
|
2122
|
+
* `NULL`→`$null`/`$notNull`)
|
|
2123
|
+
* - Sorts: `sort[0]=field:asc&sort[1]=field:desc`
|
|
2124
|
+
* - Field selection (flat): `fields[0]=col1&fields[1]=col2`
|
|
2125
|
+
* - Population: `populate[0]=relation`
|
|
2126
|
+
* - Pagination (page-based): `pagination[page]=N&pagination[pageSize]=N`
|
|
2127
|
+
*
|
|
2128
|
+
* Strapi-native full-text search (`FTS`, `PHFTS`, `PLFTS`, `WFTS`) is
|
|
2129
|
+
* PostgREST-only and throws `UnsupportedFilterOperatorError` here.
|
|
2130
|
+
*
|
|
2131
|
+
* @see https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication
|
|
2132
|
+
*/
|
|
2133
|
+
declare class StrapiRequestStrategy extends AbstractRequestStrategy {
|
|
2134
|
+
/**
|
|
2135
|
+
* Filters, operator filters, sorts, populate (`includes`), flat field
|
|
2136
|
+
* selection (`select`) — no per-model fields, no global search (use
|
|
2137
|
+
* `$contains` / `$containsi` operator filters instead)
|
|
2138
|
+
*/
|
|
2139
|
+
readonly capabilities: IStrategyCapabilities;
|
|
2140
|
+
/**
|
|
2141
|
+
* Strapi-native names of the four hardcoded query keys
|
|
2142
|
+
*
|
|
2143
|
+
* Strapi's wire format is fixed (the server reads `pagination[page]`,
|
|
2144
|
+
* `populate`, `sort`, `fields`); these keys are intentionally not
|
|
2145
|
+
* configurable through `QueryBuilderOptions` and live as private
|
|
2146
|
+
* statics so they are visible in one place.
|
|
2147
|
+
*/
|
|
2148
|
+
private static readonly _fieldsKey;
|
|
2149
|
+
private static readonly _paginationKey;
|
|
2150
|
+
private static readonly _populateKey;
|
|
2151
|
+
private static readonly _sortKey;
|
|
2152
|
+
/**
|
|
2153
|
+
* Emit Strapi-format query-string segments in canonical order:
|
|
2154
|
+
* populate → fields → filters (merged) → sort → pagination
|
|
2155
|
+
*
|
|
2156
|
+
* Simple filters and operator filters share a single `filters` wrapper
|
|
2157
|
+
* so qs emits one ordered, deeply-nested bracket structure rather than
|
|
2158
|
+
* two duplicate top-level `filters[...]` blocks.
|
|
2159
|
+
*
|
|
2160
|
+
* @param state - The current query builder state
|
|
2161
|
+
* @param _options - The query parameter key name configuration (unused;
|
|
2162
|
+
* Strapi's wire keys are fixed by the server)
|
|
2163
|
+
* @returns Ordered query-string fragments
|
|
2164
|
+
*/
|
|
2165
|
+
protected parts(state: IQueryBuilderState, _options: QueryBuilderOptions): string[];
|
|
2166
|
+
/**
|
|
2167
|
+
* Append `fields[0]=col1&fields[1]=col2` from the flat select array
|
|
2168
|
+
*
|
|
2169
|
+
* Strapi's `fields` parameter is the column-pruner for the main
|
|
2170
|
+
* resource; per-relation field selection is expressed through the
|
|
2171
|
+
* `populate` deep syntax (out of scope for this driver).
|
|
2172
|
+
*
|
|
2173
|
+
* @param state - The current query builder state
|
|
2174
|
+
* @param out - The accumulator the caller joins into the URI
|
|
2175
|
+
*/
|
|
2176
|
+
private _appendFields;
|
|
2177
|
+
/**
|
|
2178
|
+
* Append the unified `filters[...]` wrapper combining simple filters
|
|
2179
|
+
* and operator filters
|
|
2180
|
+
*
|
|
2181
|
+
* Both kinds emit into the same nested object under `filters` so qs
|
|
2182
|
+
* produces a single deeply-bracketed block per request. Simple
|
|
2183
|
+
* single-value filters fold to `$eq`; simple multi-value filters fold
|
|
2184
|
+
* to `$in`. Operator filters then merge into the same per-field map,
|
|
2185
|
+
* potentially co-existing with a simple filter on the same field.
|
|
2186
|
+
*
|
|
2187
|
+
* @param state - The current query builder state
|
|
2188
|
+
* @param out - The accumulator the caller joins into the URI
|
|
2189
|
+
*/
|
|
2190
|
+
private _appendFilters;
|
|
2191
|
+
/**
|
|
2192
|
+
* Append the `pagination[page]` / `pagination[pageSize]` wrapper
|
|
2193
|
+
*
|
|
2194
|
+
* Page-based mode is the Strapi default; offset-based
|
|
2195
|
+
* (`pagination[start]` / `pagination[limit]`) is out of scope for this
|
|
2196
|
+
* driver until cursor/offset pagination lands library-wide.
|
|
2197
|
+
*
|
|
2198
|
+
* @param state - The current query builder state
|
|
2199
|
+
* @param out - The accumulator the caller joins into the URI
|
|
2200
|
+
*/
|
|
2201
|
+
private _appendPagination;
|
|
2202
|
+
/**
|
|
2203
|
+
* Append the `populate` parameter from the includes array
|
|
2204
|
+
*
|
|
2205
|
+
* Emits `populate[0]=relation1&populate[1]=relation2`; deep-populate
|
|
2206
|
+
* syntax (`populate[author][fields][0]=name`) is not exposed through
|
|
2207
|
+
* the current state shape.
|
|
2208
|
+
*
|
|
2209
|
+
* @param state - The current query builder state
|
|
2210
|
+
* @param out - The accumulator the caller joins into the URI
|
|
2211
|
+
*/
|
|
2212
|
+
private _appendPopulate;
|
|
2213
|
+
/**
|
|
2214
|
+
* Append the `sort[N]=field:dir` array
|
|
2215
|
+
*
|
|
2216
|
+
* @param state - The current query builder state
|
|
2217
|
+
* @param out - The accumulator the caller joins into the URI
|
|
2218
|
+
*/
|
|
2219
|
+
private _appendSort;
|
|
2220
|
+
/**
|
|
2221
|
+
* Translate a `FilterOperatorEnum` operator filter into Strapi's
|
|
2222
|
+
* `$operator → value` payload shape
|
|
2223
|
+
*
|
|
2224
|
+
* The mapping is library-canonical → Strapi-native:
|
|
2225
|
+
* - `EQ`/`GT`/`GTE`/`LT`/`LTE`/`CONTAINS` → identity (same key name)
|
|
2226
|
+
* - `ILIKE` → `$containsi` (case-insensitive contains)
|
|
2227
|
+
* - `IN` → `$in` (array)
|
|
2228
|
+
* - `SW` → `$startsWith`
|
|
2229
|
+
* - `BTW` → `$between` with `[min, max]` (arity-checked)
|
|
2230
|
+
* - `NOT` → `$ne` (single value) / `$notIn` (multi-value)
|
|
2231
|
+
* - `NULL` → `$null=true` (when value is `true`) / `$notNull=true`
|
|
2232
|
+
* (when value is `false`); arity- and type-checked
|
|
2233
|
+
*
|
|
2234
|
+
* PostgREST's full-text-search operators (`FTS`, `PHFTS`, `PLFTS`,
|
|
2235
|
+
* `WFTS`) have no Strapi equivalent and throw
|
|
2236
|
+
* `UnsupportedFilterOperatorError`.
|
|
2237
|
+
*
|
|
2238
|
+
* @param filter - The operator filter to translate
|
|
2239
|
+
* @returns A `{ $operator: value }` payload ready to merge under
|
|
2240
|
+
* `filters[field]`
|
|
2241
|
+
* @throws {InvalidFilterOperatorValueError} If `BTW` does not receive
|
|
2242
|
+
* exactly two values, or `NULL` does not receive exactly one boolean
|
|
2243
|
+
* @throws {UnsupportedFilterOperatorError} If the operator is a
|
|
2244
|
+
* PostgREST-only FTS variant
|
|
2245
|
+
*/
|
|
2246
|
+
private _formatOperatorPayload;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
/**
|
|
2250
|
+
* Response strategy for the Strapi driver
|
|
2251
|
+
*
|
|
2252
|
+
* Parses Strapi v4/v5 pagination responses:
|
|
2253
|
+
* ```json
|
|
2254
|
+
* {
|
|
2255
|
+
* "data": [{ "id": 1, "documentId": "abc", "title": "Hello" }],
|
|
2256
|
+
* "meta": {
|
|
2257
|
+
* "pagination": {
|
|
2258
|
+
* "page": 1,
|
|
2259
|
+
* "pageSize": 10,
|
|
2260
|
+
* "pageCount": 5,
|
|
2261
|
+
* "total": 48
|
|
2262
|
+
* }
|
|
2263
|
+
* }
|
|
2264
|
+
* }
|
|
2265
|
+
* ```
|
|
2266
|
+
*
|
|
2267
|
+
* Default key paths are configured in `StrapiResponseOptions`. Strapi
|
|
2268
|
+
* does not include navigation links in the envelope, so `firstPageUrl`,
|
|
2269
|
+
* `prevPageUrl`, `nextPageUrl`, and `lastPageUrl` resolve to `undefined`
|
|
2270
|
+
* unless the consumer overrides their paths via `IPaginationConfig`. The
|
|
2271
|
+
* traversal algorithm (dot-notation resolution + computed `from`/`to`)
|
|
2272
|
+
* is inherited from `AbstractDotPathResponseStrategy`; this class exists
|
|
2273
|
+
* so `DriverEnum.STRAPI` resolves to a distinct identity at the DI
|
|
2274
|
+
* layer even though the parsing logic is shared with JSON:API and
|
|
2275
|
+
* NestJS.
|
|
2276
|
+
*
|
|
2277
|
+
* @see https://docs.strapi.io/dev-docs/api/rest/sort-pagination
|
|
2278
|
+
*/
|
|
2279
|
+
declare class StrapiResponseStrategy extends AbstractDotPathResponseStrategy {
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
export { DriverEnum, FilterOperatorEnum, InvalidFilterOperatorValueError, InvalidLimitError, InvalidPageNumberError, InvalidResourceNameError, JsonApiRequestStrategy, JsonApiResponseStrategy, KeyNotFoundError, LaravelRequestStrategy, LaravelResponseStrategy, NG_QUBEE_DRIVER, NG_QUBEE_REQUEST_OPTIONS, NG_QUBEE_REQUEST_STRATEGY, NG_QUBEE_RESPONSE_OPTIONS, NG_QUBEE_RESPONSE_STRATEGY, NestjsRequestStrategy, NestjsResponseStrategy, NgQubeeModule, NgQubeeService, PaginatedCollection, PaginationModeEnum, PaginationNotSyncedError, PaginationService, PostgrestRequestStrategy, PostgrestResponseStrategy, SortEnum, SpatieRequestStrategy, SpatieResponseStrategy, StrapiRequestStrategy, StrapiResponseStrategy, UnselectableModelError, UnsupportedFieldSelectionError, UnsupportedFilterError, UnsupportedFilterOperatorError, UnsupportedIncludesError, UnsupportedSearchError, UnsupportedSelectError, UnsupportedSortError, buildNgQubeeProviders, provideNgQubee, provideNgQubeeInstance, readHeader };
|
|
2114
2283
|
export type { HeaderBag, IConfig, IFields, IFilters, INestState, IOperatorFilter, IPage, IPaginatedObject, IPaginationConfig, IQueryBuilderConfig, IQueryBuilderState, IRequestStrategy, IResponseStrategy, ISort };
|