@teleporthq/teleport-plugin-next-data-source 0.42.5 → 0.42.6
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/dist/cjs/array-mapper-pagination.d.ts +5 -0
- package/dist/cjs/array-mapper-pagination.d.ts.map +1 -1
- package/dist/cjs/array-mapper-pagination.js.map +1 -1
- package/dist/cjs/array-mapper-registry.d.ts +84 -0
- package/dist/cjs/array-mapper-registry.d.ts.map +1 -0
- package/dist/cjs/array-mapper-registry.js +291 -0
- package/dist/cjs/array-mapper-registry.js.map +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +36 -14
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/pagination-plugin.d.ts +1 -3
- package/dist/cjs/pagination-plugin.d.ts.map +1 -1
- package/dist/cjs/pagination-plugin.js +895 -1405
- package/dist/cjs/pagination-plugin.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/array-mapper-pagination.d.ts +5 -0
- package/dist/esm/array-mapper-pagination.d.ts.map +1 -1
- package/dist/esm/array-mapper-pagination.js.map +1 -1
- package/dist/esm/array-mapper-registry.d.ts +84 -0
- package/dist/esm/array-mapper-registry.d.ts.map +1 -0
- package/dist/esm/array-mapper-registry.js +287 -0
- package/dist/esm/array-mapper-registry.js.map +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +36 -14
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pagination-plugin.d.ts +1 -3
- package/dist/esm/pagination-plugin.d.ts.map +1 -1
- package/dist/esm/pagination-plugin.js +896 -1406
- package/dist/esm/pagination-plugin.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/array-mapper-pagination.ts +5 -0
- package/src/array-mapper-registry.ts +408 -0
- package/src/index.ts +24 -1
- package/src/pagination-plugin.ts +1846 -2201
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArrayMapperRegistry - Centralized registry for managing array mappers,
|
|
3
|
+
* their associated states, search inputs, and pagination buttons.
|
|
4
|
+
*
|
|
5
|
+
* This ensures consistent index usage across:
|
|
6
|
+
* - Component state declarations
|
|
7
|
+
* - DataProvider params
|
|
8
|
+
* - getStaticProps fetch calls and prop names
|
|
9
|
+
* - Search input bindings
|
|
10
|
+
* - Pagination button bindings
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export type MapperType = 'paginated' | 'pagination-only' | 'search-only' | 'plain'
|
|
14
|
+
|
|
15
|
+
export interface ArrayMapperRegistryEntry {
|
|
16
|
+
registryIndex: number
|
|
17
|
+
type: MapperType
|
|
18
|
+
dataSourceIdentifier: string
|
|
19
|
+
arrayMapperRenderProp: string
|
|
20
|
+
uidlGlobalIndex: number
|
|
21
|
+
|
|
22
|
+
paginated: boolean
|
|
23
|
+
searchEnabled: boolean
|
|
24
|
+
perPage: number
|
|
25
|
+
searchDebounce: number
|
|
26
|
+
queryColumns: string[]
|
|
27
|
+
|
|
28
|
+
stateVarPrefix: string
|
|
29
|
+
pageStateVar?: string
|
|
30
|
+
setPageStateVar?: string
|
|
31
|
+
maxPagesStateVar?: string
|
|
32
|
+
setMaxPagesStateVar?: string
|
|
33
|
+
combinedStateVar?: string
|
|
34
|
+
setCombinedStateVar?: string
|
|
35
|
+
searchQueryVar?: string
|
|
36
|
+
setSearchQueryVar?: string
|
|
37
|
+
debouncedSearchQueryVar?: string
|
|
38
|
+
setDebouncedSearchQueryVar?: string
|
|
39
|
+
skipDebounceRefVar?: string
|
|
40
|
+
skipCountFetchRefVar?: string
|
|
41
|
+
|
|
42
|
+
getStaticPropsDataVar: string
|
|
43
|
+
getStaticPropsMaxPagesVar: string
|
|
44
|
+
getStaticPropsPropName: string
|
|
45
|
+
getStaticPropsMaxPagesPropName: string
|
|
46
|
+
|
|
47
|
+
searchInputClass?: string
|
|
48
|
+
paginationNodeClass?: string
|
|
49
|
+
prevButtonClass?: string
|
|
50
|
+
nextButtonClass?: string
|
|
51
|
+
|
|
52
|
+
dataProviderJSX?: any
|
|
53
|
+
searchInputJSX?: any
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class ArrayMapperRegistry {
|
|
57
|
+
private entries: ArrayMapperRegistryEntry[] = []
|
|
58
|
+
private paginatedCount = 0
|
|
59
|
+
private paginationOnlyCount = 0
|
|
60
|
+
private searchOnlyCount = 0
|
|
61
|
+
private plainCount = 0
|
|
62
|
+
|
|
63
|
+
registerFromUIDL(config: {
|
|
64
|
+
dataSourceIdentifier: string
|
|
65
|
+
arrayMapperRenderProp: string
|
|
66
|
+
uidlGlobalIndex: number
|
|
67
|
+
paginated: boolean
|
|
68
|
+
searchEnabled: boolean
|
|
69
|
+
perPage?: number
|
|
70
|
+
searchDebounce?: number
|
|
71
|
+
queryColumns?: string[]
|
|
72
|
+
}): ArrayMapperRegistryEntry {
|
|
73
|
+
const type = this.determineType(config.paginated, config.searchEnabled)
|
|
74
|
+
const typeIndex = this.getTypeIndex(type)
|
|
75
|
+
const registryIndex = this.entries.length
|
|
76
|
+
|
|
77
|
+
const stateVarPrefix = this.generateStateVarPrefix(type, typeIndex)
|
|
78
|
+
|
|
79
|
+
const entry: ArrayMapperRegistryEntry = {
|
|
80
|
+
registryIndex,
|
|
81
|
+
type,
|
|
82
|
+
dataSourceIdentifier: config.dataSourceIdentifier,
|
|
83
|
+
arrayMapperRenderProp: config.arrayMapperRenderProp,
|
|
84
|
+
uidlGlobalIndex: config.uidlGlobalIndex,
|
|
85
|
+
|
|
86
|
+
paginated: config.paginated,
|
|
87
|
+
searchEnabled: config.searchEnabled,
|
|
88
|
+
perPage: config.perPage || 10,
|
|
89
|
+
searchDebounce: config.searchDebounce || 300,
|
|
90
|
+
queryColumns: config.queryColumns || [],
|
|
91
|
+
|
|
92
|
+
stateVarPrefix,
|
|
93
|
+
...this.generateStateVarNames(stateVarPrefix, config.paginated, config.searchEnabled),
|
|
94
|
+
...this.generateGetStaticPropsVarNames(config.dataSourceIdentifier, type, typeIndex),
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this.entries.push(entry)
|
|
98
|
+
this.incrementTypeCount(type)
|
|
99
|
+
|
|
100
|
+
return entry
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
getEntry(registryIndex: number): ArrayMapperRegistryEntry | undefined {
|
|
104
|
+
return this.entries[registryIndex]
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
getEntryByUIDLIndex(uidlGlobalIndex: number): ArrayMapperRegistryEntry | undefined {
|
|
108
|
+
return this.entries.find((e) => e.uidlGlobalIndex === uidlGlobalIndex)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
getEntriesByType(type: MapperType): ArrayMapperRegistryEntry[] {
|
|
112
|
+
return this.entries.filter((e) => e.type === type)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
getAllEntries(): ArrayMapperRegistryEntry[] {
|
|
116
|
+
return [...this.entries]
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
getPaginatedEntries(): ArrayMapperRegistryEntry[] {
|
|
120
|
+
return this.getEntriesByType('paginated')
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
getPaginationOnlyEntries(): ArrayMapperRegistryEntry[] {
|
|
124
|
+
return this.getEntriesByType('pagination-only')
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
getSearchOnlyEntries(): ArrayMapperRegistryEntry[] {
|
|
128
|
+
return this.getEntriesByType('search-only')
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
getPlainEntries(): ArrayMapperRegistryEntry[] {
|
|
132
|
+
return this.getEntriesByType('plain')
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
updateJSXReferences(
|
|
136
|
+
registryIndex: number,
|
|
137
|
+
updates: Partial<
|
|
138
|
+
Pick<
|
|
139
|
+
ArrayMapperRegistryEntry,
|
|
140
|
+
| 'dataProviderJSX'
|
|
141
|
+
| 'searchInputJSX'
|
|
142
|
+
| 'searchInputClass'
|
|
143
|
+
| 'paginationNodeClass'
|
|
144
|
+
| 'prevButtonClass'
|
|
145
|
+
| 'nextButtonClass'
|
|
146
|
+
>
|
|
147
|
+
>
|
|
148
|
+
): void {
|
|
149
|
+
const entry = this.entries[registryIndex]
|
|
150
|
+
if (entry) {
|
|
151
|
+
Object.assign(entry, updates)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
getStateInitializationMaxPagesPropName(entry: ArrayMapperRegistryEntry): string {
|
|
156
|
+
return entry.getStaticPropsMaxPagesPropName
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
toDebugSummary(): string {
|
|
160
|
+
return JSON.stringify(
|
|
161
|
+
this.entries.map((e) => ({
|
|
162
|
+
registryIndex: e.registryIndex,
|
|
163
|
+
type: e.type,
|
|
164
|
+
dataSource: e.dataSourceIdentifier,
|
|
165
|
+
renderProp: e.arrayMapperRenderProp,
|
|
166
|
+
uidlIndex: e.uidlGlobalIndex,
|
|
167
|
+
statePrefix: e.stateVarPrefix,
|
|
168
|
+
getStaticPropsProp: e.getStaticPropsPropName,
|
|
169
|
+
})),
|
|
170
|
+
null,
|
|
171
|
+
2
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private determineType(paginated: boolean, searchEnabled: boolean): MapperType {
|
|
176
|
+
if (paginated && searchEnabled) {
|
|
177
|
+
return 'paginated'
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (paginated && !searchEnabled) {
|
|
181
|
+
return 'pagination-only'
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (!paginated && searchEnabled) {
|
|
185
|
+
return 'search-only'
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return 'plain'
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private getTypeIndex(type: MapperType): number {
|
|
192
|
+
switch (type) {
|
|
193
|
+
case 'paginated':
|
|
194
|
+
return this.paginatedCount
|
|
195
|
+
case 'pagination-only':
|
|
196
|
+
return this.paginationOnlyCount
|
|
197
|
+
case 'search-only':
|
|
198
|
+
return this.searchOnlyCount
|
|
199
|
+
case 'plain':
|
|
200
|
+
return this.plainCount
|
|
201
|
+
default:
|
|
202
|
+
return 0
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
private incrementTypeCount(type: MapperType): void {
|
|
207
|
+
switch (type) {
|
|
208
|
+
case 'paginated':
|
|
209
|
+
this.paginatedCount++
|
|
210
|
+
break
|
|
211
|
+
case 'pagination-only':
|
|
212
|
+
this.paginationOnlyCount++
|
|
213
|
+
break
|
|
214
|
+
case 'search-only':
|
|
215
|
+
this.searchOnlyCount++
|
|
216
|
+
break
|
|
217
|
+
case 'plain':
|
|
218
|
+
this.plainCount++
|
|
219
|
+
break
|
|
220
|
+
default:
|
|
221
|
+
break
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private generateStateVarPrefix(type: MapperType, typeIndex: number): string {
|
|
226
|
+
switch (type) {
|
|
227
|
+
case 'paginated':
|
|
228
|
+
return `pg_${typeIndex}`
|
|
229
|
+
case 'pagination-only':
|
|
230
|
+
return `paginationOnly_${typeIndex}`
|
|
231
|
+
case 'search-only':
|
|
232
|
+
return `searchOnly_${typeIndex}`
|
|
233
|
+
case 'plain':
|
|
234
|
+
return `plain_${typeIndex}`
|
|
235
|
+
default:
|
|
236
|
+
return ''
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
private generateStateVarNames(
|
|
241
|
+
prefix: string,
|
|
242
|
+
paginated: boolean,
|
|
243
|
+
searchEnabled: boolean
|
|
244
|
+
): Partial<ArrayMapperRegistryEntry> {
|
|
245
|
+
const result: Partial<ArrayMapperRegistryEntry> = {}
|
|
246
|
+
|
|
247
|
+
if (paginated) {
|
|
248
|
+
if (searchEnabled) {
|
|
249
|
+
result.combinedStateVar = `paginationState_${prefix}`
|
|
250
|
+
result.setCombinedStateVar = `setPaginationState_${prefix}`
|
|
251
|
+
result.pageStateVar = `paginationState_${prefix}.page`
|
|
252
|
+
result.setPageStateVar = `setPaginationState_${prefix}`
|
|
253
|
+
} else {
|
|
254
|
+
result.pageStateVar = `${prefix}_page`
|
|
255
|
+
result.setPageStateVar = `set${this.capitalize(prefix)}_page`
|
|
256
|
+
}
|
|
257
|
+
result.maxPagesStateVar = `pagination_${prefix}_maxPages`
|
|
258
|
+
result.setMaxPagesStateVar = `setPagination_${prefix}_maxPages`
|
|
259
|
+
} else {
|
|
260
|
+
result.pageStateVar = ''
|
|
261
|
+
result.setPageStateVar = ''
|
|
262
|
+
result.maxPagesStateVar = ''
|
|
263
|
+
result.setMaxPagesStateVar = ''
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (searchEnabled) {
|
|
267
|
+
result.searchQueryVar = `search_${prefix}_query`
|
|
268
|
+
result.setSearchQueryVar = `setSearch_${prefix}_query`
|
|
269
|
+
result.debouncedSearchQueryVar = `debouncedSearch_${prefix}_query`
|
|
270
|
+
result.setDebouncedSearchQueryVar = `setDebouncedSearch_${prefix}_query`
|
|
271
|
+
result.skipDebounceRefVar = `skipDebounceOnMount_${prefix}`
|
|
272
|
+
|
|
273
|
+
if (paginated) {
|
|
274
|
+
result.skipCountFetchRefVar = `skipCountFetchOnMount_${prefix}`
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return result
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private generateGetStaticPropsVarNames(
|
|
282
|
+
dataSourceIdentifier: string,
|
|
283
|
+
type: MapperType,
|
|
284
|
+
typeIndex: number
|
|
285
|
+
): Pick<
|
|
286
|
+
ArrayMapperRegistryEntry,
|
|
287
|
+
| 'getStaticPropsDataVar'
|
|
288
|
+
| 'getStaticPropsMaxPagesVar'
|
|
289
|
+
| 'getStaticPropsPropName'
|
|
290
|
+
| 'getStaticPropsMaxPagesPropName'
|
|
291
|
+
> {
|
|
292
|
+
let suffix: string
|
|
293
|
+
switch (type) {
|
|
294
|
+
case 'paginated':
|
|
295
|
+
suffix = `pg_${typeIndex}`
|
|
296
|
+
break
|
|
297
|
+
case 'pagination-only':
|
|
298
|
+
suffix = `paginationOnly_${typeIndex}`
|
|
299
|
+
break
|
|
300
|
+
case 'search-only':
|
|
301
|
+
suffix = `searchOnly_${typeIndex}`
|
|
302
|
+
break
|
|
303
|
+
case 'plain':
|
|
304
|
+
suffix = `plain_${typeIndex}`
|
|
305
|
+
break
|
|
306
|
+
default:
|
|
307
|
+
suffix = `plain_${typeIndex}`
|
|
308
|
+
break
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const dataVar = `${dataSourceIdentifier}_${suffix}`
|
|
312
|
+
const maxPagesVar = `${dataSourceIdentifier}_${suffix}_maxPages`
|
|
313
|
+
|
|
314
|
+
return {
|
|
315
|
+
getStaticPropsDataVar: dataVar,
|
|
316
|
+
getStaticPropsMaxPagesVar: maxPagesVar,
|
|
317
|
+
getStaticPropsPropName: dataVar,
|
|
318
|
+
getStaticPropsMaxPagesPropName: maxPagesVar,
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
private capitalize(str: string): string {
|
|
323
|
+
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export function createRegistryFromUIDL(uidlNode: any, allResources: any): ArrayMapperRegistry {
|
|
328
|
+
const registry = new ArrayMapperRegistry()
|
|
329
|
+
|
|
330
|
+
const visitedRepeaterKeys = new Set<string>()
|
|
331
|
+
let uidlGlobalIndex = 0
|
|
332
|
+
|
|
333
|
+
const findQueryColumns = (
|
|
334
|
+
resourceId: string,
|
|
335
|
+
nodeResource: any,
|
|
336
|
+
registryResources: any
|
|
337
|
+
): string[] | undefined => {
|
|
338
|
+
if (nodeResource?.params?.queryColumns) {
|
|
339
|
+
const val = nodeResource.params.queryColumns
|
|
340
|
+
if (val.type === 'static' && Array.isArray(val.content)) {
|
|
341
|
+
return val.content
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (registryResources?.items?.[resourceId]?.params?.queryColumns) {
|
|
345
|
+
const val = registryResources.items[resourceId].params.queryColumns
|
|
346
|
+
if (val.type === 'static' && Array.isArray(val.content)) {
|
|
347
|
+
return val.content
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return undefined
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const traverse = (node: any, currentDataSourceId?: string): void => {
|
|
354
|
+
if (!node || typeof node !== 'object') {
|
|
355
|
+
return
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (node.type === 'data-source-list' && node.content?.renderPropIdentifier) {
|
|
359
|
+
currentDataSourceId = node.content.renderPropIdentifier
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (node.type === 'cms-list-repeater' && node.content?.renderPropIdentifier) {
|
|
363
|
+
const c = node.content
|
|
364
|
+
const repeaterKey = `${c.renderPropIdentifier}|${c.paginated}|${c.searchEnabled}|${
|
|
365
|
+
c.perPage || 'default'
|
|
366
|
+
}|${c.source || ''}`
|
|
367
|
+
|
|
368
|
+
if (visitedRepeaterKeys.has(repeaterKey)) {
|
|
369
|
+
return
|
|
370
|
+
}
|
|
371
|
+
visitedRepeaterKeys.add(repeaterKey)
|
|
372
|
+
|
|
373
|
+
const resourceId = c.resource?.id
|
|
374
|
+
let queryColumns: string[] | undefined
|
|
375
|
+
if (resourceId) {
|
|
376
|
+
queryColumns = findQueryColumns(resourceId, c.resource, allResources)
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
registry.registerFromUIDL({
|
|
380
|
+
dataSourceIdentifier: currentDataSourceId || 'unknown',
|
|
381
|
+
arrayMapperRenderProp: c.renderPropIdentifier,
|
|
382
|
+
uidlGlobalIndex: uidlGlobalIndex++,
|
|
383
|
+
paginated: !!c.paginated,
|
|
384
|
+
searchEnabled: !!c.searchEnabled,
|
|
385
|
+
perPage: c.perPage,
|
|
386
|
+
searchDebounce: c.searchDebounce,
|
|
387
|
+
queryColumns,
|
|
388
|
+
})
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (node.content?.children && Array.isArray(node.content.children)) {
|
|
392
|
+
node.content.children.forEach((child: any) => traverse(child, currentDataSourceId))
|
|
393
|
+
}
|
|
394
|
+
if (node.content?.node) {
|
|
395
|
+
traverse(node.content.node, currentDataSourceId)
|
|
396
|
+
}
|
|
397
|
+
if (node.content?.nodes) {
|
|
398
|
+
Object.values(node.content.nodes).forEach((n: any) => traverse(n, currentDataSourceId))
|
|
399
|
+
}
|
|
400
|
+
if (Array.isArray(node.children)) {
|
|
401
|
+
node.children.forEach((child: any) => traverse(child, currentDataSourceId))
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
traverse(uidlNode)
|
|
406
|
+
|
|
407
|
+
return registry
|
|
408
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -12,12 +12,14 @@ interface PaginationConfig {
|
|
|
12
12
|
perPageMap: Map<string, number>
|
|
13
13
|
searchConfigMap: Map<string, SearchConfig>
|
|
14
14
|
queryColumnsMap: Map<string, string[]>
|
|
15
|
+
limitMap: Map<string, number>
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
function extractPaginationConfigEarly(uidlNode: any, resources: any): PaginationConfig {
|
|
18
19
|
const perPageMap = new Map<string, number>()
|
|
19
20
|
const searchConfigMap = new Map<string, SearchConfig>()
|
|
20
21
|
const queryColumnsMap = new Map<string, string[]>()
|
|
22
|
+
const limitMap = new Map<string, number>()
|
|
21
23
|
|
|
22
24
|
const dataSourceToRenderProp = new Map<string, string>()
|
|
23
25
|
|
|
@@ -47,6 +49,19 @@ function extractPaginationConfigEarly(uidlNode: any, resources: any): Pagination
|
|
|
47
49
|
queryColumnsMap.set(renderProp, queryColumnsValue.content)
|
|
48
50
|
}
|
|
49
51
|
}
|
|
52
|
+
|
|
53
|
+
// Extract limit parameter from resource.params.limit for plain array mappers
|
|
54
|
+
if (node.content?.resource?.params?.limit) {
|
|
55
|
+
const limitValue = node.content.resource.params.limit
|
|
56
|
+
if (limitValue.type === 'static' && typeof limitValue.content === 'number') {
|
|
57
|
+
limitMap.set(renderProp, limitValue.content)
|
|
58
|
+
}
|
|
59
|
+
} else if (resources?.items?.[resourceId]?.params?.limit) {
|
|
60
|
+
const limitValue = resources.items[resourceId].params.limit
|
|
61
|
+
if (limitValue.type === 'static' && typeof limitValue.content === 'number') {
|
|
62
|
+
limitMap.set(renderProp, limitValue.content)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
50
65
|
}
|
|
51
66
|
|
|
52
67
|
if (node.type === 'cms-list-repeater') {
|
|
@@ -110,7 +125,7 @@ function extractPaginationConfigEarly(uidlNode: any, resources: any): Pagination
|
|
|
110
125
|
|
|
111
126
|
traverse(uidlNode)
|
|
112
127
|
|
|
113
|
-
return { perPageMap, searchConfigMap, queryColumnsMap }
|
|
128
|
+
return { perPageMap, searchConfigMap, queryColumnsMap, limitMap }
|
|
114
129
|
}
|
|
115
130
|
|
|
116
131
|
export const createNextPagesDataSourcePlugin: ComponentPluginFactory<{}> = () => {
|
|
@@ -146,6 +161,7 @@ export const createNextPagesDataSourcePlugin: ComponentPluginFactory<{}> = () =>
|
|
|
146
161
|
perPageMap: new Map<string, number>(),
|
|
147
162
|
searchConfigMap: new Map<string, SearchConfig>(),
|
|
148
163
|
queryColumnsMap: new Map<string, string[]>(),
|
|
164
|
+
limitMap: new Map<string, number>(),
|
|
149
165
|
}
|
|
150
166
|
}
|
|
151
167
|
|
|
@@ -160,6 +176,9 @@ export const createNextPagesDataSourcePlugin: ComponentPluginFactory<{}> = () =>
|
|
|
160
176
|
pageConfig.queryColumnsMap.forEach((queryColumns, dataSourceId) => {
|
|
161
177
|
opts.paginationConfig.queryColumnsMap.set(dataSourceId, queryColumns)
|
|
162
178
|
})
|
|
179
|
+
pageConfig.limitMap.forEach((limit, dataSourceId) => {
|
|
180
|
+
opts.paginationConfig.limitMap.set(dataSourceId, limit)
|
|
181
|
+
})
|
|
163
182
|
|
|
164
183
|
let getStaticPropsChunk = chunks.find((chunk) => chunk.name === 'getStaticProps')
|
|
165
184
|
|
|
@@ -279,6 +298,7 @@ export const createNextComponentDataSourcePlugin: ComponentPluginFactory<{}> = (
|
|
|
279
298
|
perPageMap: new Map<string, number>(),
|
|
280
299
|
searchConfigMap: new Map<string, SearchConfig>(),
|
|
281
300
|
queryColumnsMap: new Map<string, string[]>(),
|
|
301
|
+
limitMap: new Map<string, number>(),
|
|
282
302
|
}
|
|
283
303
|
}
|
|
284
304
|
|
|
@@ -293,6 +313,9 @@ export const createNextComponentDataSourcePlugin: ComponentPluginFactory<{}> = (
|
|
|
293
313
|
componentConfig.queryColumnsMap.forEach((queryColumns, dataSourceId) => {
|
|
294
314
|
opts.paginationConfig.queryColumnsMap.set(dataSourceId, queryColumns)
|
|
295
315
|
})
|
|
316
|
+
componentConfig.limitMap.forEach((limit, dataSourceId) => {
|
|
317
|
+
opts.paginationConfig.limitMap.set(dataSourceId, limit)
|
|
318
|
+
})
|
|
296
319
|
|
|
297
320
|
const componentChunk = chunks.find((chunk) => chunk.name === 'jsx-component')
|
|
298
321
|
if (!componentChunk) {
|