@teleporthq/teleport-plugin-next-data-source 0.43.66 → 0.43.68
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/__tests__/array-mapper-cache-wiring.test.ts +11 -0
- package/__tests__/array-overlap-sql.test.ts +53 -0
- package/__tests__/blog-post-page-enrichment.test.ts +214 -0
- package/__tests__/browser-row-policy.test.ts +503 -0
- package/__tests__/data-source-cache-wrapping.test.ts +18 -2
- package/__tests__/data-source-request-locale.test.ts +313 -0
- package/__tests__/ecommerce-product-options.test.ts +206 -0
- package/__tests__/ecommerce-product-pages.test.ts +82 -0
- package/__tests__/ecommerce-product-pre-options.golden.json +505 -0
- package/__tests__/ecommerce-product-storefront-contract.test.ts +293 -0
- package/__tests__/ecommerce-product-subscriptions.test.ts +121 -0
- package/__tests__/fetchers.test.ts +2 -2
- package/__tests__/gated-data-provider.test.ts +88 -0
- package/__tests__/items-path.test.ts +150 -0
- package/__tests__/localized-columns.test.ts +217 -0
- package/__tests__/numbered-pagination.test.ts +15 -0
- package/__tests__/product-filter-fields.ts +230 -0
- package/__tests__/product-filter-sql.fixture.json +7 -0
- package/__tests__/product-options-storefront.fixture.json +2510 -0
- package/__tests__/product-page-url-fixtures.json +25 -0
- package/__tests__/product-price-sort.ts +4 -2
- package/__tests__/raw-rows-mode.test.ts +111 -0
- package/__tests__/refetch-loading-state.test.ts +23 -0
- package/__tests__/rest-api-response-cache.test.ts +434 -0
- package/__tests__/search-clear-button.test.ts +122 -0
- package/__tests__/table-read-route-protected-tables.test.ts +493 -0
- package/dist/cjs/array-overlap-sql.d.ts +21 -0
- package/dist/cjs/array-overlap-sql.d.ts.map +1 -0
- package/dist/cjs/array-overlap-sql.js +25 -0
- package/dist/cjs/array-overlap-sql.js.map +1 -0
- package/dist/cjs/content-localization.d.ts +37 -0
- package/dist/cjs/content-localization.d.ts.map +1 -0
- package/dist/cjs/content-localization.js +29 -0
- package/dist/cjs/content-localization.js.map +1 -0
- package/dist/cjs/count-effect.d.ts +11 -1
- package/dist/cjs/count-effect.d.ts.map +1 -1
- package/dist/cjs/count-effect.js +30 -2
- package/dist/cjs/count-effect.js.map +1 -1
- package/dist/cjs/data-source-fetchers.d.ts.map +1 -1
- package/dist/cjs/data-source-fetchers.js +10 -4
- package/dist/cjs/data-source-fetchers.js.map +1 -1
- package/dist/cjs/fetchers/airtable.d.ts.map +1 -1
- package/dist/cjs/fetchers/airtable.js +1 -1
- package/dist/cjs/fetchers/airtable.js.map +1 -1
- package/dist/cjs/fetchers/clickhouse.d.ts.map +1 -1
- package/dist/cjs/fetchers/clickhouse.js +1 -1
- package/dist/cjs/fetchers/clickhouse.js.map +1 -1
- package/dist/cjs/fetchers/firestore.d.ts.map +1 -1
- package/dist/cjs/fetchers/firestore.js +1 -1
- package/dist/cjs/fetchers/firestore.js.map +1 -1
- package/dist/cjs/fetchers/javascript.d.ts.map +1 -1
- package/dist/cjs/fetchers/javascript.js +1 -1
- package/dist/cjs/fetchers/javascript.js.map +1 -1
- package/dist/cjs/fetchers/mariadb.d.ts.map +1 -1
- package/dist/cjs/fetchers/mariadb.js +1 -1
- package/dist/cjs/fetchers/mariadb.js.map +1 -1
- package/dist/cjs/fetchers/mongodb.d.ts.map +1 -1
- package/dist/cjs/fetchers/mongodb.js +1 -1
- package/dist/cjs/fetchers/mongodb.js.map +1 -1
- package/dist/cjs/fetchers/mysql.d.ts.map +1 -1
- package/dist/cjs/fetchers/mysql.js +1 -1
- package/dist/cjs/fetchers/mysql.js.map +1 -1
- package/dist/cjs/fetchers/postgresql.d.ts +1 -1
- package/dist/cjs/fetchers/postgresql.d.ts.map +1 -1
- package/dist/cjs/fetchers/postgresql.js +9 -4
- package/dist/cjs/fetchers/postgresql.js.map +1 -1
- package/dist/cjs/fetchers/raw-query.d.ts +8 -1
- package/dist/cjs/fetchers/raw-query.d.ts.map +1 -1
- package/dist/cjs/fetchers/raw-query.js +42 -4
- package/dist/cjs/fetchers/raw-query.js.map +1 -1
- package/dist/cjs/fetchers/redshift.d.ts.map +1 -1
- package/dist/cjs/fetchers/redshift.js +1 -1
- package/dist/cjs/fetchers/redshift.js.map +1 -1
- package/dist/cjs/fetchers/rest-api.d.ts.map +1 -1
- package/dist/cjs/fetchers/rest-api.js +7 -2
- package/dist/cjs/fetchers/rest-api.js.map +1 -1
- package/dist/cjs/fetchers/teleport.d.ts.map +1 -1
- package/dist/cjs/fetchers/teleport.js +16 -6
- package/dist/cjs/fetchers/teleport.js.map +1 -1
- package/dist/cjs/fetchers/turso.d.ts.map +1 -1
- package/dist/cjs/fetchers/turso.js +1 -1
- package/dist/cjs/fetchers/turso.js.map +1 -1
- package/dist/cjs/fetchers/utils/browser-row-policy.d.ts +43 -0
- package/dist/cjs/fetchers/utils/browser-row-policy.d.ts.map +1 -0
- package/dist/cjs/fetchers/utils/browser-row-policy.js +66 -0
- package/dist/cjs/fetchers/utils/browser-row-policy.js.map +1 -0
- package/dist/cjs/fetchers/utils/request-sql-guards.d.ts +8 -0
- package/dist/cjs/fetchers/utils/request-sql-guards.d.ts.map +1 -0
- package/dist/cjs/fetchers/utils/request-sql-guards.js +12 -0
- package/dist/cjs/fetchers/utils/request-sql-guards.js.map +1 -0
- package/dist/cjs/fetchers/utils/rest-api-response-cache.d.ts +40 -0
- package/dist/cjs/fetchers/utils/rest-api-response-cache.d.ts.map +1 -0
- package/dist/cjs/fetchers/utils/rest-api-response-cache.js +64 -0
- package/dist/cjs/fetchers/utils/rest-api-response-cache.js.map +1 -0
- package/dist/cjs/fetchers/utils/table-access-guard.d.ts +23 -0
- package/dist/cjs/fetchers/utils/table-access-guard.d.ts.map +1 -0
- package/dist/cjs/fetchers/utils/table-access-guard.js +34 -0
- package/dist/cjs/fetchers/utils/table-access-guard.js.map +1 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +60 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/items-path.d.ts +10 -0
- package/dist/cjs/items-path.d.ts.map +1 -0
- package/dist/cjs/items-path.js +86 -0
- package/dist/cjs/items-path.js.map +1 -0
- package/dist/cjs/loading-state.d.ts +16 -1
- package/dist/cjs/loading-state.d.ts.map +1 -1
- package/dist/cjs/loading-state.js +69 -3
- package/dist/cjs/loading-state.js.map +1 -1
- package/dist/cjs/localized-columns.d.ts +56 -0
- package/dist/cjs/localized-columns.d.ts.map +1 -0
- package/dist/cjs/localized-columns.js +137 -0
- package/dist/cjs/localized-columns.js.map +1 -0
- package/dist/cjs/pagination-plugin.d.ts.map +1 -1
- package/dist/cjs/pagination-plugin.js +140 -50
- package/dist/cjs/pagination-plugin.js.map +1 -1
- package/dist/cjs/product-filter-fields.d.ts +87 -0
- package/dist/cjs/product-filter-fields.d.ts.map +1 -0
- package/dist/cjs/product-filter-fields.js +161 -0
- package/dist/cjs/product-filter-fields.js.map +1 -0
- package/dist/cjs/request-locale.d.ts +49 -0
- package/dist/cjs/request-locale.d.ts.map +1 -0
- package/dist/cjs/request-locale.js +130 -0
- package/dist/cjs/request-locale.js.map +1 -0
- package/dist/cjs/search-clear.d.ts +31 -0
- package/dist/cjs/search-clear.d.ts.map +1 -0
- package/dist/cjs/search-clear.js +103 -0
- package/dist/cjs/search-clear.js.map +1 -0
- package/dist/cjs/transformations/blog-adjacent-posts.d.ts +16 -0
- package/dist/cjs/transformations/blog-adjacent-posts.d.ts.map +1 -0
- package/dist/cjs/transformations/blog-adjacent-posts.js +25 -0
- package/dist/cjs/transformations/blog-adjacent-posts.js.map +1 -0
- package/dist/cjs/transformations/blog-comments.d.ts +30 -0
- package/dist/cjs/transformations/blog-comments.d.ts.map +1 -0
- package/dist/cjs/transformations/blog-comments.js +34 -0
- package/dist/cjs/transformations/blog-comments.js.map +1 -0
- package/dist/cjs/transformations/blog-post.d.ts +2 -0
- package/dist/cjs/transformations/blog-post.d.ts.map +1 -1
- package/dist/cjs/transformations/blog-post.js +4 -1
- package/dist/cjs/transformations/blog-post.js.map +1 -1
- package/dist/cjs/transformations/ecommerce-product.d.ts +9 -1
- package/dist/cjs/transformations/ecommerce-product.d.ts.map +1 -1
- package/dist/cjs/transformations/ecommerce-product.js +28 -1
- package/dist/cjs/transformations/ecommerce-product.js.map +1 -1
- package/dist/cjs/transformations/heading-anchors.d.ts +25 -0
- package/dist/cjs/transformations/heading-anchors.d.ts.map +1 -0
- package/dist/cjs/transformations/heading-anchors.js +29 -0
- package/dist/cjs/transformations/heading-anchors.js.map +1 -0
- package/dist/cjs/transformations/index.d.ts +61 -4
- package/dist/cjs/transformations/index.d.ts.map +1 -1
- package/dist/cjs/transformations/index.js +69 -19
- package/dist/cjs/transformations/index.js.map +1 -1
- package/dist/cjs/transformations/shared-utils.d.ts.map +1 -1
- package/dist/cjs/transformations/shared-utils.js +1 -1
- package/dist/cjs/transformations/shared-utils.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/utils.d.ts +11 -1
- package/dist/cjs/utils.d.ts.map +1 -1
- package/dist/cjs/utils.js +60 -16
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/array-overlap-sql.d.ts +21 -0
- package/dist/esm/array-overlap-sql.d.ts.map +1 -0
- package/dist/esm/array-overlap-sql.js +21 -0
- package/dist/esm/array-overlap-sql.js.map +1 -0
- package/dist/esm/content-localization.d.ts +37 -0
- package/dist/esm/content-localization.d.ts.map +1 -0
- package/dist/esm/content-localization.js +24 -0
- package/dist/esm/content-localization.js.map +1 -0
- package/dist/esm/count-effect.d.ts +11 -1
- package/dist/esm/count-effect.d.ts.map +1 -1
- package/dist/esm/count-effect.js +28 -1
- package/dist/esm/count-effect.js.map +1 -1
- package/dist/esm/data-source-fetchers.d.ts.map +1 -1
- package/dist/esm/data-source-fetchers.js +11 -5
- package/dist/esm/data-source-fetchers.js.map +1 -1
- package/dist/esm/fetchers/airtable.d.ts.map +1 -1
- package/dist/esm/fetchers/airtable.js +1 -1
- package/dist/esm/fetchers/airtable.js.map +1 -1
- package/dist/esm/fetchers/clickhouse.d.ts.map +1 -1
- package/dist/esm/fetchers/clickhouse.js +1 -1
- package/dist/esm/fetchers/clickhouse.js.map +1 -1
- package/dist/esm/fetchers/firestore.d.ts.map +1 -1
- package/dist/esm/fetchers/firestore.js +1 -1
- package/dist/esm/fetchers/firestore.js.map +1 -1
- package/dist/esm/fetchers/javascript.d.ts.map +1 -1
- package/dist/esm/fetchers/javascript.js +1 -1
- package/dist/esm/fetchers/javascript.js.map +1 -1
- package/dist/esm/fetchers/mariadb.d.ts.map +1 -1
- package/dist/esm/fetchers/mariadb.js +1 -1
- package/dist/esm/fetchers/mariadb.js.map +1 -1
- package/dist/esm/fetchers/mongodb.d.ts.map +1 -1
- package/dist/esm/fetchers/mongodb.js +1 -1
- package/dist/esm/fetchers/mongodb.js.map +1 -1
- package/dist/esm/fetchers/mysql.d.ts.map +1 -1
- package/dist/esm/fetchers/mysql.js +1 -1
- package/dist/esm/fetchers/mysql.js.map +1 -1
- package/dist/esm/fetchers/postgresql.d.ts +1 -1
- package/dist/esm/fetchers/postgresql.d.ts.map +1 -1
- package/dist/esm/fetchers/postgresql.js +9 -4
- package/dist/esm/fetchers/postgresql.js.map +1 -1
- package/dist/esm/fetchers/raw-query.d.ts +8 -1
- package/dist/esm/fetchers/raw-query.d.ts.map +1 -1
- package/dist/esm/fetchers/raw-query.js +42 -4
- package/dist/esm/fetchers/raw-query.js.map +1 -1
- package/dist/esm/fetchers/redshift.d.ts.map +1 -1
- package/dist/esm/fetchers/redshift.js +1 -1
- package/dist/esm/fetchers/redshift.js.map +1 -1
- package/dist/esm/fetchers/rest-api.d.ts.map +1 -1
- package/dist/esm/fetchers/rest-api.js +7 -2
- package/dist/esm/fetchers/rest-api.js.map +1 -1
- package/dist/esm/fetchers/teleport.d.ts.map +1 -1
- package/dist/esm/fetchers/teleport.js +16 -6
- package/dist/esm/fetchers/teleport.js.map +1 -1
- package/dist/esm/fetchers/turso.d.ts.map +1 -1
- package/dist/esm/fetchers/turso.js +1 -1
- package/dist/esm/fetchers/turso.js.map +1 -1
- package/dist/esm/fetchers/utils/browser-row-policy.d.ts +43 -0
- package/dist/esm/fetchers/utils/browser-row-policy.d.ts.map +1 -0
- package/dist/esm/fetchers/utils/browser-row-policy.js +60 -0
- package/dist/esm/fetchers/utils/browser-row-policy.js.map +1 -0
- package/dist/esm/fetchers/utils/request-sql-guards.d.ts +8 -0
- package/dist/esm/fetchers/utils/request-sql-guards.d.ts.map +1 -0
- package/dist/esm/fetchers/utils/request-sql-guards.js +8 -0
- package/dist/esm/fetchers/utils/request-sql-guards.js.map +1 -0
- package/dist/esm/fetchers/utils/rest-api-response-cache.d.ts +40 -0
- package/dist/esm/fetchers/utils/rest-api-response-cache.d.ts.map +1 -0
- package/dist/esm/fetchers/utils/rest-api-response-cache.js +59 -0
- package/dist/esm/fetchers/utils/rest-api-response-cache.js.map +1 -0
- package/dist/esm/fetchers/utils/table-access-guard.d.ts +23 -0
- package/dist/esm/fetchers/utils/table-access-guard.d.ts.map +1 -0
- package/dist/esm/fetchers/utils/table-access-guard.js +29 -0
- package/dist/esm/fetchers/utils/table-access-guard.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +55 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/items-path.d.ts +10 -0
- package/dist/esm/items-path.d.ts.map +1 -0
- package/dist/esm/items-path.js +58 -0
- package/dist/esm/items-path.js.map +1 -0
- package/dist/esm/loading-state.d.ts +16 -1
- package/dist/esm/loading-state.d.ts.map +1 -1
- package/dist/esm/loading-state.js +69 -3
- package/dist/esm/loading-state.js.map +1 -1
- package/dist/esm/localized-columns.d.ts +56 -0
- package/dist/esm/localized-columns.d.ts.map +1 -0
- package/dist/esm/localized-columns.js +132 -0
- package/dist/esm/localized-columns.js.map +1 -0
- package/dist/esm/pagination-plugin.d.ts.map +1 -1
- package/dist/esm/pagination-plugin.js +141 -51
- package/dist/esm/pagination-plugin.js.map +1 -1
- package/dist/esm/product-filter-fields.d.ts +87 -0
- package/dist/esm/product-filter-fields.d.ts.map +1 -0
- package/dist/esm/product-filter-fields.js +154 -0
- package/dist/esm/product-filter-fields.js.map +1 -0
- package/dist/esm/request-locale.d.ts +49 -0
- package/dist/esm/request-locale.d.ts.map +1 -0
- package/dist/esm/request-locale.js +98 -0
- package/dist/esm/request-locale.js.map +1 -0
- package/dist/esm/search-clear.d.ts +31 -0
- package/dist/esm/search-clear.d.ts.map +1 -0
- package/dist/esm/search-clear.js +74 -0
- package/dist/esm/search-clear.js.map +1 -0
- package/dist/esm/transformations/blog-adjacent-posts.d.ts +16 -0
- package/dist/esm/transformations/blog-adjacent-posts.d.ts.map +1 -0
- package/dist/esm/transformations/blog-adjacent-posts.js +21 -0
- package/dist/esm/transformations/blog-adjacent-posts.js.map +1 -0
- package/dist/esm/transformations/blog-comments.d.ts +30 -0
- package/dist/esm/transformations/blog-comments.d.ts.map +1 -0
- package/dist/esm/transformations/blog-comments.js +30 -0
- package/dist/esm/transformations/blog-comments.js.map +1 -0
- package/dist/esm/transformations/blog-post.d.ts +2 -0
- package/dist/esm/transformations/blog-post.d.ts.map +1 -1
- package/dist/esm/transformations/blog-post.js +4 -1
- package/dist/esm/transformations/blog-post.js.map +1 -1
- package/dist/esm/transformations/ecommerce-product.d.ts +9 -1
- package/dist/esm/transformations/ecommerce-product.d.ts.map +1 -1
- package/dist/esm/transformations/ecommerce-product.js +29 -2
- package/dist/esm/transformations/ecommerce-product.js.map +1 -1
- package/dist/esm/transformations/heading-anchors.d.ts +25 -0
- package/dist/esm/transformations/heading-anchors.d.ts.map +1 -0
- package/dist/esm/transformations/heading-anchors.js +25 -0
- package/dist/esm/transformations/heading-anchors.js.map +1 -0
- package/dist/esm/transformations/index.d.ts +61 -4
- package/dist/esm/transformations/index.d.ts.map +1 -1
- package/dist/esm/transformations/index.js +69 -19
- package/dist/esm/transformations/index.js.map +1 -1
- package/dist/esm/transformations/shared-utils.d.ts.map +1 -1
- package/dist/esm/transformations/shared-utils.js +1 -1
- package/dist/esm/transformations/shared-utils.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/utils.d.ts +11 -1
- package/dist/esm/utils.d.ts.map +1 -1
- package/dist/esm/utils.js +60 -16
- package/dist/esm/utils.js.map +1 -1
- package/package.json +5 -5
- package/src/array-overlap-sql.ts +41 -0
- package/src/content-localization.ts +53 -0
- package/src/count-effect.ts +53 -2
- package/src/data-source-fetchers.ts +41 -5
- package/src/fetchers/airtable.ts +4 -2
- package/src/fetchers/clickhouse.ts +4 -2
- package/src/fetchers/firestore.ts +4 -2
- package/src/fetchers/javascript.ts +9 -1
- package/src/fetchers/mariadb.ts +4 -2
- package/src/fetchers/mongodb.ts +4 -2
- package/src/fetchers/mysql.ts +4 -2
- package/src/fetchers/postgresql.ts +53 -12
- package/src/fetchers/raw-query.ts +60 -5
- package/src/fetchers/redshift.ts +4 -2
- package/src/fetchers/rest-api.ts +27 -5
- package/src/fetchers/teleport.ts +85 -22
- package/src/fetchers/turso.ts +4 -2
- package/src/fetchers/utils/browser-row-policy.ts +212 -0
- package/src/fetchers/utils/request-sql-guards.ts +25 -0
- package/src/fetchers/utils/rest-api-response-cache.ts +188 -0
- package/src/fetchers/utils/table-access-guard.ts +39 -0
- package/src/index.ts +79 -11
- package/src/items-path.ts +74 -0
- package/src/loading-state.ts +134 -3
- package/src/localized-columns.ts +146 -0
- package/src/pagination-plugin.ts +206 -60
- package/src/product-filter-fields.ts +173 -0
- package/src/request-locale.ts +113 -0
- package/src/search-clear.ts +102 -0
- package/src/transformations/blog-adjacent-posts.ts +74 -0
- package/src/transformations/blog-comments.ts +132 -0
- package/src/transformations/blog-post.ts +38 -5
- package/src/transformations/ecommerce-product.ts +568 -5
- package/src/transformations/heading-anchors.ts +85 -0
- package/src/transformations/index.ts +191 -23
- package/src/transformations/shared-utils.ts +6 -0
- package/src/utils.ts +109 -19
|
@@ -79,15 +79,19 @@ var data_source_fetchers_1 = require("./data-source-fetchers");
|
|
|
79
79
|
var transformations_1 = require("./transformations");
|
|
80
80
|
var sort_utils_1 = require("./sort-utils");
|
|
81
81
|
var filter_utils_1 = require("./filter-utils");
|
|
82
|
+
var items_path_1 = require("./items-path");
|
|
82
83
|
var loading_state_1 = require("./loading-state");
|
|
83
84
|
var config_1 = require("./cache/config");
|
|
84
85
|
var ast_1 = require("./cache/ast");
|
|
85
86
|
var pagination_controls_1 = require("./pagination-controls");
|
|
86
87
|
var count_effect_1 = require("./count-effect");
|
|
88
|
+
var search_clear_1 = require("./search-clear");
|
|
87
89
|
var numbered_pagination_1 = require("./numbered-pagination");
|
|
88
90
|
var infinite_scroll_1 = require("./infinite-scroll");
|
|
89
91
|
var page_reset_1 = require("./page-reset");
|
|
90
92
|
var page_url_sync_1 = require("./page-url-sync");
|
|
93
|
+
var content_localization_1 = require("./content-localization");
|
|
94
|
+
var request_locale_1 = require("./request-locale");
|
|
91
95
|
// tslint:disable-next-line:no-any
|
|
92
96
|
function parseSearchDefaultValue(raw) {
|
|
93
97
|
if (!raw || typeof raw !== 'object') {
|
|
@@ -479,6 +483,7 @@ function buildStateRegistry(uidlNode) {
|
|
|
479
483
|
infiniteScroll: infiniteScroll,
|
|
480
484
|
infiniteScrollLoadMore: infiniteScroll && !!content.infiniteScrollLoadMore,
|
|
481
485
|
pageUrlParamKey: pageUrlParamKey,
|
|
486
|
+
itemsPath: (0, items_path_1.extractItemsPath)(content.source, parentDataSource.identifier, parentDataSource.resourceDef.dataSourceType || ''),
|
|
482
487
|
category: 'plain',
|
|
483
488
|
};
|
|
484
489
|
// Determine category
|
|
@@ -557,6 +562,7 @@ function getStateVarsForUsage(usage) {
|
|
|
557
562
|
combinedStateVar: "ds_".concat(idx, "_state"),
|
|
558
563
|
setCombinedStateVar: "setDs_".concat(idx, "_state"),
|
|
559
564
|
skipDebounceRefVar: "ds_".concat(idx, "_skipDebounce"),
|
|
565
|
+
countSeqRefVar: "ds_".concat(idx, "_countSeq"),
|
|
560
566
|
propsPrefix: "".concat(usage.dataSourceIdentifier, "_ds_").concat(idx),
|
|
561
567
|
};
|
|
562
568
|
}
|
|
@@ -769,7 +775,7 @@ function pushFilterSortPageResetEffect(stateDeclarations, effectStatements, usag
|
|
|
769
775
|
// ==================== MAIN PLUGIN ====================
|
|
770
776
|
var createNextArrayMapperPaginationPlugin = function () {
|
|
771
777
|
var paginationPlugin = function (structure) { return __awaiter(void 0, void 0, void 0, function () {
|
|
772
|
-
var uidl, chunks, dependencies, options, componentChunk, variableDeclaration, declarator, arrowFunction, blockStatement, registry, getStaticPropsChunk, isPage, stateDeclarations, effectStatements, needsUseRouter,
|
|
778
|
+
var uidl, chunks, dependencies, options, componentChunk, variableDeclaration, declarator, arrowFunction, blockStatement, registry, getStaticPropsChunk, isPage, localized, stateDeclarations, effectStatements, needsUseRouter, returnIndex, insertIndex, dataProviders, dataProvidersWithRepeaters, usageIndexByDataSourceId, loadingStateDeclarations, usagesWithLoadingState, usageByProviderNode, cacheDeclarations, sharedOptions, cachedScopes, dataProvidersWithoutRepeaters, searchInputs, searchEnabledUsages, usageBySearchInput;
|
|
773
779
|
var _a, _b;
|
|
774
780
|
return __generator(this, function (_c) {
|
|
775
781
|
uidl = structure.uidl, chunks = structure.chunks, dependencies = structure.dependencies, options = structure.options;
|
|
@@ -799,6 +805,7 @@ var createNextArrayMapperPaginationPlugin = function () {
|
|
|
799
805
|
}
|
|
800
806
|
getStaticPropsChunk = chunks.find(function (chunk) { return chunk.name === 'getStaticProps'; });
|
|
801
807
|
isPage = !!getStaticPropsChunk;
|
|
808
|
+
localized = (0, content_localization_1.isLocalizedProject)(options);
|
|
802
809
|
// Add React dependencies
|
|
803
810
|
if (!dependencies.useState) {
|
|
804
811
|
dependencies.useState = {
|
|
@@ -946,6 +953,7 @@ var createNextArrayMapperPaginationPlugin = function () {
|
|
|
946
953
|
}
|
|
947
954
|
// Add filters to count fetch params if present
|
|
948
955
|
(0, filter_utils_1.appendFiltersParam)(urlParams, usage.filters, buildFilterDestinationExpression);
|
|
956
|
+
(0, items_path_1.appendItemsPathParam)(urlParams, usage.itemsPath, 'collectionPath');
|
|
949
957
|
var countEffectDeps = [
|
|
950
958
|
types.memberExpression(types.identifier(vars.combinedStateVar), types.identifier('debouncedQuery')),
|
|
951
959
|
];
|
|
@@ -960,12 +968,14 @@ var createNextArrayMapperPaginationPlugin = function () {
|
|
|
960
968
|
(0, filter_utils_1.pushPropIdsAsDeps)(countEffectDeps, countEffectSeen, usage.filterPropIds);
|
|
961
969
|
// Same goes for URL-driven filters (already documented above).
|
|
962
970
|
pushUrlSearchParamMemoDeps(countEffectDeps, usage);
|
|
971
|
+
stateDeclarations.push((0, count_effect_1.buildCountSeqDeclaration)(vars.countSeqRefVar));
|
|
963
972
|
effectStatements.push((0, count_effect_1.buildCountFetchEffect)({
|
|
964
973
|
fileName: fileName,
|
|
965
974
|
perPage: usage.perPage,
|
|
966
975
|
setMaxPagesVar: vars.setMaxPagesStateVar,
|
|
967
976
|
urlParams: urlParams,
|
|
968
977
|
deps: countEffectDeps,
|
|
978
|
+
countSeqRefVar: vars.countSeqRefVar,
|
|
969
979
|
}));
|
|
970
980
|
// Two-way URL sync for the search input when bound to a URL param.
|
|
971
981
|
pushSearchUrlSyncEffects(effectStatements, usage, vars);
|
|
@@ -1016,6 +1026,7 @@ var createNextArrayMapperPaginationPlugin = function () {
|
|
|
1016
1026
|
countUrlParams.push(types.objectProperty(types.identifier('queryColumns'), types.callExpression(types.memberExpression(types.identifier('JSON'), types.identifier('stringify')), [types.arrayExpression(usage.queryColumns.map(function (c) { return types.stringLiteral(c); }))])));
|
|
1017
1027
|
}
|
|
1018
1028
|
(0, filter_utils_1.appendFiltersParam)(countUrlParams, usage.filters, buildFilterDestinationExpression);
|
|
1029
|
+
(0, items_path_1.appendItemsPathParam)(countUrlParams, usage.itemsPath, 'collectionPath');
|
|
1019
1030
|
// Default to mount-only; refresh when ANY filter destination
|
|
1020
1031
|
// changes — state-bound (e.g. `selectedCategory`) and URL-driven —
|
|
1021
1032
|
// so the pagination control reflects the current filtered count
|
|
@@ -1025,12 +1036,14 @@ var createNextArrayMapperPaginationPlugin = function () {
|
|
|
1025
1036
|
(0, filter_utils_1.pushStateIdsAsDeps)(countDeps, countDepsSeen, usage.filterStateIds);
|
|
1026
1037
|
(0, filter_utils_1.pushPropIdsAsDeps)(countDeps, countDepsSeen, usage.filterPropIds);
|
|
1027
1038
|
pushUrlSearchParamMemoDeps(countDeps, usage);
|
|
1039
|
+
stateDeclarations.push((0, count_effect_1.buildCountSeqDeclaration)(vars.countSeqRefVar));
|
|
1028
1040
|
effectStatements.push((0, count_effect_1.buildCountFetchEffect)({
|
|
1029
1041
|
fileName: fileName,
|
|
1030
1042
|
perPage: usage.perPage,
|
|
1031
1043
|
setMaxPagesVar: vars.setMaxPagesStateVar,
|
|
1032
1044
|
urlParams: countUrlParams,
|
|
1033
1045
|
deps: countDeps,
|
|
1046
|
+
countSeqRefVar: vars.countSeqRefVar,
|
|
1034
1047
|
}));
|
|
1035
1048
|
}
|
|
1036
1049
|
// Visible page numbers, when this mapper draws a numbered strip.
|
|
@@ -1087,35 +1100,10 @@ var createNextArrayMapperPaginationPlugin = function () {
|
|
|
1087
1100
|
});
|
|
1088
1101
|
// Insert state declarations at the beginning
|
|
1089
1102
|
stateDeclarations.reverse().forEach(function (s) { return blockStatement.body.unshift(s); });
|
|
1090
|
-
needsUseRouter =
|
|
1103
|
+
needsUseRouter = localized ||
|
|
1104
|
+
registry.usages.some(function (u) { return hasUrlSearchParamFilters(u) || usageHasSearchUrlSync(u) || usageHasPageUrlSync(u); });
|
|
1091
1105
|
if (needsUseRouter) {
|
|
1092
|
-
|
|
1093
|
-
// Match the shape the sibling Next.js plugins use (i18n locale mapper,
|
|
1094
|
-
// search-params plugin) so the deduped import line is identical and
|
|
1095
|
-
// the dependency-resolver merges instead of emitting a second one.
|
|
1096
|
-
dependencies.useRouter = {
|
|
1097
|
-
type: 'library',
|
|
1098
|
-
path: 'next/router',
|
|
1099
|
-
version: '^12.1.10',
|
|
1100
|
-
meta: { namedImport: true },
|
|
1101
|
-
};
|
|
1102
|
-
}
|
|
1103
|
-
hasRouterDecl = blockStatement.body.some(function (statement) {
|
|
1104
|
-
return statement.type === 'VariableDeclaration' &&
|
|
1105
|
-
statement.declarations.some(function (decl) {
|
|
1106
|
-
var _a;
|
|
1107
|
-
return decl.id.type === 'Identifier' &&
|
|
1108
|
-
decl.id.name === 'router' &&
|
|
1109
|
-
((_a = decl.init) === null || _a === void 0 ? void 0 : _a.type) === 'CallExpression' &&
|
|
1110
|
-
decl.init.callee.type === 'Identifier' &&
|
|
1111
|
-
decl.init.callee.name === 'useRouter';
|
|
1112
|
-
});
|
|
1113
|
-
});
|
|
1114
|
-
if (!hasRouterDecl) {
|
|
1115
|
-
blockStatement.body.unshift(types.variableDeclaration('const', [
|
|
1116
|
-
types.variableDeclarator(types.identifier('router'), types.callExpression(types.identifier('useRouter'), [])),
|
|
1117
|
-
]));
|
|
1118
|
-
}
|
|
1106
|
+
(0, request_locale_1.ensureRouterDeclaration)(blockStatement.body, dependencies);
|
|
1119
1107
|
}
|
|
1120
1108
|
// Both the search write-back and the page ⇄ URL effect write the URL through
|
|
1121
1109
|
// the shared `URLQueryWriter`, so the ref + helper they close over must be in
|
|
@@ -1157,16 +1145,16 @@ var createNextArrayMapperPaginationPlugin = function () {
|
|
|
1157
1145
|
var fileName = (0, utils_1.generateSafeFileName)(usage.resourceDefinition.dataSourceType, usage.resourceDefinition.tableName, usage.resourceDefinition.dataSourceId);
|
|
1158
1146
|
// Update DataProvider based on category
|
|
1159
1147
|
if (usage.category === 'paginated+search') {
|
|
1160
|
-
updateDataProviderForPaginatedSearch(dp, usage, vars, fileName, cacheDeclarations);
|
|
1148
|
+
updateDataProviderForPaginatedSearch(dp, usage, vars, fileName, cacheDeclarations, localized);
|
|
1161
1149
|
}
|
|
1162
1150
|
else if (usage.category === 'paginated-only') {
|
|
1163
|
-
updateDataProviderForPaginationOnly(dp, usage, vars, fileName, cacheDeclarations);
|
|
1151
|
+
updateDataProviderForPaginationOnly(dp, usage, vars, fileName, cacheDeclarations, localized);
|
|
1164
1152
|
}
|
|
1165
1153
|
else if (usage.category === 'search-only') {
|
|
1166
|
-
updateDataProviderForSearchOnly(dp, usage, vars, fileName, cacheDeclarations);
|
|
1154
|
+
updateDataProviderForSearchOnly(dp, usage, vars, fileName, cacheDeclarations, localized);
|
|
1167
1155
|
}
|
|
1168
1156
|
else if (usage.category === 'plain') {
|
|
1169
|
-
updateDataProviderForPlain(dp, fileName, usage);
|
|
1157
|
+
updateDataProviderForPlain(dp, fileName, usage, localized);
|
|
1170
1158
|
}
|
|
1171
1159
|
// Show the array mapper's loading state while a category/sort/search
|
|
1172
1160
|
// change refetches, instead of leaving the previous rows on screen with
|
|
@@ -1226,7 +1214,7 @@ var createNextArrayMapperPaginationPlugin = function () {
|
|
|
1226
1214
|
});
|
|
1227
1215
|
searchInputs = findAllSearchInputsInJSX(blockStatement);
|
|
1228
1216
|
searchEnabledUsages = registry.usages.filter(function (u) { return u.searchEnabled; });
|
|
1229
|
-
|
|
1217
|
+
usageBySearchInput = new Map();
|
|
1230
1218
|
searchInputs.forEach(function (input, idx) {
|
|
1231
1219
|
if (idx >= searchEnabledUsages.length) {
|
|
1232
1220
|
return;
|
|
@@ -1234,6 +1222,15 @@ var createNextArrayMapperPaginationPlugin = function () {
|
|
|
1234
1222
|
var usage = searchEnabledUsages[idx];
|
|
1235
1223
|
var vars = getStateVarsForUsage(usage);
|
|
1236
1224
|
wireSearchInput(input.node, vars);
|
|
1225
|
+
usageBySearchInput.set(input.node, usage);
|
|
1226
|
+
});
|
|
1227
|
+
// STEP 4.5: Wire the clear buttons, each to the input it shares a parent with.
|
|
1228
|
+
(0, search_clear_1.findAllSearchClearButtonsInJSX)(blockStatement).forEach(function (button) {
|
|
1229
|
+
var input = (0, search_clear_1.findSiblingSearchInput)(button, searchInputs.map(function (entry) { return entry.node; }));
|
|
1230
|
+
var usage = input ? usageBySearchInput.get(input) : undefined;
|
|
1231
|
+
if (usage) {
|
|
1232
|
+
(0, search_clear_1.wireSearchClearButton)(button, getStateVarsForUsage(usage));
|
|
1233
|
+
}
|
|
1237
1234
|
});
|
|
1238
1235
|
// STEP 5: Wire pagination widgets
|
|
1239
1236
|
//
|
|
@@ -1255,7 +1252,7 @@ var createNextArrayMapperPaginationPlugin = function () {
|
|
|
1255
1252
|
});
|
|
1256
1253
|
// STEP 6: Update getStaticProps if this is a page
|
|
1257
1254
|
if (isPage) {
|
|
1258
|
-
updateGetStaticProps(chunks, registry, dependencies, (_b = uidl.outputOptions) === null || _b === void 0 ? void 0 : _b.folderPath);
|
|
1255
|
+
updateGetStaticProps(chunks, registry, dependencies, (_b = uidl.outputOptions) === null || _b === void 0 ? void 0 : _b.folderPath, localized);
|
|
1259
1256
|
}
|
|
1260
1257
|
return [2 /*return*/, structure];
|
|
1261
1258
|
});
|
|
@@ -1305,6 +1302,20 @@ function insertSentinelAfterProvider(blockStatement, provider, sentinel) {
|
|
|
1305
1302
|
if (node.alternate) {
|
|
1306
1303
|
traverse(node.alternate);
|
|
1307
1304
|
}
|
|
1305
|
+
// `{activeTabIndex === 0 && (<div>…<DataProvider/>…</div>)}` — a tab
|
|
1306
|
+
// panel, a gated section: the provider sits on the RIGHT of a logical
|
|
1307
|
+
// expression (or in a ternary's `test`), which is not a child, a body or
|
|
1308
|
+
// an argument. Left unvisited, the products list under the first tab of
|
|
1309
|
+
// a shop was never paginated or seeded, and rendered nothing.
|
|
1310
|
+
if (node.left) {
|
|
1311
|
+
traverse(node.left);
|
|
1312
|
+
}
|
|
1313
|
+
if (node.right) {
|
|
1314
|
+
traverse(node.right);
|
|
1315
|
+
}
|
|
1316
|
+
if (node.test) {
|
|
1317
|
+
traverse(node.test);
|
|
1318
|
+
}
|
|
1308
1319
|
if (node.expression) {
|
|
1309
1320
|
traverse(node.expression);
|
|
1310
1321
|
}
|
|
@@ -1342,6 +1353,20 @@ function findAllDataProvidersInJSX(blockStatement) {
|
|
|
1342
1353
|
if (node.alternate) {
|
|
1343
1354
|
traverse(node.alternate);
|
|
1344
1355
|
}
|
|
1356
|
+
// `{activeTabIndex === 0 && (<div>…<DataProvider/>…</div>)}` — a tab
|
|
1357
|
+
// panel, a gated section: the provider sits on the RIGHT of a logical
|
|
1358
|
+
// expression (or in a ternary's `test`), which is not a child, a body or
|
|
1359
|
+
// an argument. Left unvisited, the products list under the first tab of
|
|
1360
|
+
// a shop was never paginated or seeded, and rendered nothing.
|
|
1361
|
+
if (node.left) {
|
|
1362
|
+
traverse(node.left);
|
|
1363
|
+
}
|
|
1364
|
+
if (node.right) {
|
|
1365
|
+
traverse(node.right);
|
|
1366
|
+
}
|
|
1367
|
+
if (node.test) {
|
|
1368
|
+
traverse(node.test);
|
|
1369
|
+
}
|
|
1345
1370
|
if (node.expression) {
|
|
1346
1371
|
traverse(node.expression);
|
|
1347
1372
|
}
|
|
@@ -1424,6 +1449,20 @@ function findAllSearchInputsInJSX(blockStatement) {
|
|
|
1424
1449
|
if (node.alternate) {
|
|
1425
1450
|
traverse(node.alternate);
|
|
1426
1451
|
}
|
|
1452
|
+
// `{activeTabIndex === 0 && (<div>…<DataProvider/>…</div>)}` — a tab
|
|
1453
|
+
// panel, a gated section: the provider sits on the RIGHT of a logical
|
|
1454
|
+
// expression (or in a ternary's `test`), which is not a child, a body or
|
|
1455
|
+
// an argument. Left unvisited, the products list under the first tab of
|
|
1456
|
+
// a shop was never paginated or seeded, and rendered nothing.
|
|
1457
|
+
if (node.left) {
|
|
1458
|
+
traverse(node.left);
|
|
1459
|
+
}
|
|
1460
|
+
if (node.right) {
|
|
1461
|
+
traverse(node.right);
|
|
1462
|
+
}
|
|
1463
|
+
if (node.test) {
|
|
1464
|
+
traverse(node.test);
|
|
1465
|
+
}
|
|
1427
1466
|
if (node.expression) {
|
|
1428
1467
|
traverse(node.expression);
|
|
1429
1468
|
}
|
|
@@ -1479,6 +1518,20 @@ function findPaginationNodesWithOwners(blockStatement, usageByProviderNode) {
|
|
|
1479
1518
|
if (node.alternate) {
|
|
1480
1519
|
traverse(node.alternate);
|
|
1481
1520
|
}
|
|
1521
|
+
// `{activeTabIndex === 0 && (<div>…<DataProvider/>…</div>)}` — a tab
|
|
1522
|
+
// panel, a gated section: the provider sits on the RIGHT of a logical
|
|
1523
|
+
// expression (or in a ternary's `test`), which is not a child, a body or
|
|
1524
|
+
// an argument. Left unvisited, the products list under the first tab of
|
|
1525
|
+
// a shop was never paginated or seeded, and rendered nothing.
|
|
1526
|
+
if (node.left) {
|
|
1527
|
+
traverse(node.left);
|
|
1528
|
+
}
|
|
1529
|
+
if (node.right) {
|
|
1530
|
+
traverse(node.right);
|
|
1531
|
+
}
|
|
1532
|
+
if (node.test) {
|
|
1533
|
+
traverse(node.test);
|
|
1534
|
+
}
|
|
1482
1535
|
if (node.expression) {
|
|
1483
1536
|
traverse(node.expression);
|
|
1484
1537
|
}
|
|
@@ -1521,7 +1574,7 @@ dp, usage, paramsProps, memoDeps, cacheDeclarations) {
|
|
|
1521
1574
|
dp.openingElement.attributes.push(types.jsxAttribute(types.jsxIdentifier('params'), types.jsxExpressionContainer(types.identifier(hoisted.paramsIdentifier))));
|
|
1522
1575
|
return hoisted.cachedIdentifier;
|
|
1523
1576
|
}
|
|
1524
|
-
function updateDataProviderForPaginatedSearch(dp, usage, vars, fileName, cacheDeclarations) {
|
|
1577
|
+
function updateDataProviderForPaginatedSearch(dp, usage, vars, fileName, cacheDeclarations, localized) {
|
|
1525
1578
|
var attrs = dp.openingElement.attributes;
|
|
1526
1579
|
// Remove existing params, key, initialData, fetchData, persistDataDuringLoading
|
|
1527
1580
|
dp.openingElement.attributes = attrs.filter(function (attr) {
|
|
@@ -1541,6 +1594,7 @@ function updateDataProviderForPaginatedSearch(dp, usage, vars, fileName, cacheDe
|
|
|
1541
1594
|
(0, sort_utils_1.appendSortsParam)(paramsProps, usage.sorts, usage.dynamicSort);
|
|
1542
1595
|
// Add filters if present
|
|
1543
1596
|
(0, filter_utils_1.appendFiltersParam)(paramsProps, usage.filters, buildFilterDestinationExpression);
|
|
1597
|
+
(0, items_path_1.appendItemsPathParam)(paramsProps, usage.itemsPath, 'itemsPath');
|
|
1544
1598
|
// Build useMemo dependencies including filter state IDs and dynamic sort state IDs
|
|
1545
1599
|
var memoDeps = [types.identifier(vars.combinedStateVar)];
|
|
1546
1600
|
var seenDeps = new Set([vars.combinedStateVar]);
|
|
@@ -1550,6 +1604,9 @@ function updateDataProviderForPaginatedSearch(dp, usage, vars, fileName, cacheDe
|
|
|
1550
1604
|
(0, filter_utils_1.pushStateIdsAsDeps)(memoDeps, seenDeps, usage.dynamicSort.depStateIds);
|
|
1551
1605
|
}
|
|
1552
1606
|
pushUrlSearchParamMemoDeps(memoDeps, usage);
|
|
1607
|
+
if (localized) {
|
|
1608
|
+
(0, request_locale_1.appendClientLocaleParam)(paramsProps, memoDeps);
|
|
1609
|
+
}
|
|
1553
1610
|
var cachedInitialData = pushParamsAttribute(dp, usage, paramsProps, memoDeps, cacheDeclarations);
|
|
1554
1611
|
// Add initialData. Skip the server-prefetched data entirely when a dynamic
|
|
1555
1612
|
// state-bound sort is active — the prefetch ran without sort parameters, so
|
|
@@ -1601,7 +1658,7 @@ function updateDataProviderForPaginatedSearch(dp, usage, vars, fileName, cacheDe
|
|
|
1601
1658
|
// Add persistDataDuringLoading
|
|
1602
1659
|
dp.openingElement.attributes.push(types.jsxAttribute(types.jsxIdentifier('persistDataDuringLoading'), types.jsxExpressionContainer(types.booleanLiteral(true))));
|
|
1603
1660
|
}
|
|
1604
|
-
function updateDataProviderForPaginationOnly(dp, usage, vars, fileName, cacheDeclarations) {
|
|
1661
|
+
function updateDataProviderForPaginationOnly(dp, usage, vars, fileName, cacheDeclarations, localized) {
|
|
1605
1662
|
var attrs = dp.openingElement.attributes;
|
|
1606
1663
|
dp.openingElement.attributes = attrs.filter(function (attr) {
|
|
1607
1664
|
var _a;
|
|
@@ -1616,6 +1673,7 @@ function updateDataProviderForPaginationOnly(dp, usage, vars, fileName, cacheDec
|
|
|
1616
1673
|
(0, sort_utils_1.appendSortsParam)(paramsProps, usage.sorts, usage.dynamicSort);
|
|
1617
1674
|
// Add filters if present
|
|
1618
1675
|
(0, filter_utils_1.appendFiltersParam)(paramsProps, usage.filters, buildFilterDestinationExpression);
|
|
1676
|
+
(0, items_path_1.appendItemsPathParam)(paramsProps, usage.itemsPath, 'itemsPath');
|
|
1619
1677
|
// Build useMemo dependencies including filter state IDs and dynamic sort state IDs
|
|
1620
1678
|
var memoDeps = [types.identifier(vars.pageStateVar)];
|
|
1621
1679
|
var seenDeps = new Set([vars.pageStateVar]);
|
|
@@ -1625,6 +1683,9 @@ function updateDataProviderForPaginationOnly(dp, usage, vars, fileName, cacheDec
|
|
|
1625
1683
|
(0, filter_utils_1.pushStateIdsAsDeps)(memoDeps, seenDeps, usage.dynamicSort.depStateIds);
|
|
1626
1684
|
}
|
|
1627
1685
|
pushUrlSearchParamMemoDeps(memoDeps, usage);
|
|
1686
|
+
if (localized) {
|
|
1687
|
+
(0, request_locale_1.appendClientLocaleParam)(paramsProps, memoDeps);
|
|
1688
|
+
}
|
|
1628
1689
|
// Add params
|
|
1629
1690
|
var cachedInitialData = pushParamsAttribute(dp, usage, paramsProps, memoDeps, cacheDeclarations);
|
|
1630
1691
|
// Add initialData. See paginated+search updater for why we skip prefetch
|
|
@@ -1650,7 +1711,7 @@ function updateDataProviderForPaginationOnly(dp, usage, vars, fileName, cacheDec
|
|
|
1650
1711
|
dp.openingElement.attributes.push(buildFetchDataForUsage(fileName, usage));
|
|
1651
1712
|
dp.openingElement.attributes.push(types.jsxAttribute(types.jsxIdentifier('persistDataDuringLoading'), types.jsxExpressionContainer(types.booleanLiteral(true))));
|
|
1652
1713
|
}
|
|
1653
|
-
function updateDataProviderForSearchOnly(dp, usage, vars, fileName, cacheDeclarations) {
|
|
1714
|
+
function updateDataProviderForSearchOnly(dp, usage, vars, fileName, cacheDeclarations, localized) {
|
|
1654
1715
|
var _a;
|
|
1655
1716
|
var attrs = dp.openingElement.attributes;
|
|
1656
1717
|
dp.openingElement.attributes = attrs.filter(function (attr) {
|
|
@@ -1668,6 +1729,7 @@ function updateDataProviderForSearchOnly(dp, usage, vars, fileName, cacheDeclara
|
|
|
1668
1729
|
(0, sort_utils_1.appendSortsParam)(paramsProps, usage.sorts, usage.dynamicSort);
|
|
1669
1730
|
// Add filters if present
|
|
1670
1731
|
(0, filter_utils_1.appendFiltersParam)(paramsProps, usage.filters, buildFilterDestinationExpression);
|
|
1732
|
+
(0, items_path_1.appendItemsPathParam)(paramsProps, usage.itemsPath, 'itemsPath');
|
|
1671
1733
|
// Build useMemo dependencies including filter state IDs and dynamic sort state IDs
|
|
1672
1734
|
var memoDeps = [types.identifier(vars.debouncedSearchQueryVar)];
|
|
1673
1735
|
var seenDeps = new Set([vars.debouncedSearchQueryVar]);
|
|
@@ -1677,6 +1739,9 @@ function updateDataProviderForSearchOnly(dp, usage, vars, fileName, cacheDeclara
|
|
|
1677
1739
|
(0, filter_utils_1.pushStateIdsAsDeps)(memoDeps, seenDeps, usage.dynamicSort.depStateIds);
|
|
1678
1740
|
}
|
|
1679
1741
|
pushUrlSearchParamMemoDeps(memoDeps, usage);
|
|
1742
|
+
if (localized) {
|
|
1743
|
+
(0, request_locale_1.appendClientLocaleParam)(paramsProps, memoDeps);
|
|
1744
|
+
}
|
|
1680
1745
|
var cachedInitialData = pushParamsAttribute(dp, usage, paramsProps, memoDeps, cacheDeclarations);
|
|
1681
1746
|
// Add initialData. See paginated+search updater for why we skip prefetch
|
|
1682
1747
|
// reuse when a dynamic state-bound sort is active.
|
|
@@ -1692,7 +1757,7 @@ function updateDataProviderForSearchOnly(dp, usage, vars, fileName, cacheDeclara
|
|
|
1692
1757
|
dp.openingElement.attributes.push(createFetchDataAttribute(fileName, ((_a = usage.cache) === null || _a === void 0 ? void 0 : _a.client) ? usage.cache : undefined));
|
|
1693
1758
|
dp.openingElement.attributes.push(types.jsxAttribute(types.jsxIdentifier('persistDataDuringLoading'), types.jsxExpressionContainer(types.booleanLiteral(true))));
|
|
1694
1759
|
}
|
|
1695
|
-
function updateDataProviderForPlain(dp, fileName, usage) {
|
|
1760
|
+
function updateDataProviderForPlain(dp, fileName, usage, localized) {
|
|
1696
1761
|
var _a, _b, _c, _d;
|
|
1697
1762
|
var attrs = dp.openingElement.attributes;
|
|
1698
1763
|
var clientCache = ((_a = usage.cache) === null || _a === void 0 ? void 0 : _a.client) ? usage.cache : undefined;
|
|
@@ -1714,10 +1779,16 @@ function updateDataProviderForPlain(dp, fileName, usage) {
|
|
|
1714
1779
|
if (!hasPersistData) {
|
|
1715
1780
|
attrs.push(types.jsxAttribute(types.jsxIdentifier('persistDataDuringLoading'), types.jsxExpressionContainer(types.booleanLiteral(true))));
|
|
1716
1781
|
}
|
|
1717
|
-
// Find the params attribute
|
|
1782
|
+
// Find the params attribute. A plain list may have none at all — but the
|
|
1783
|
+
// fetch it was just given sends `params` regardless, and in a localized
|
|
1784
|
+
// project those have to carry the locale, so the attribute is created.
|
|
1718
1785
|
var paramsAttrIndex = attrs.findIndex(function (attr) { return attr.type === 'JSXAttribute' && attr.name.name === 'params'; });
|
|
1719
1786
|
if (paramsAttrIndex === -1) {
|
|
1720
|
-
|
|
1787
|
+
if (!localized) {
|
|
1788
|
+
return;
|
|
1789
|
+
}
|
|
1790
|
+
attrs.push(types.jsxAttribute(types.jsxIdentifier('params'), types.jsxExpressionContainer(types.objectExpression([]))));
|
|
1791
|
+
paramsAttrIndex = attrs.length - 1;
|
|
1721
1792
|
}
|
|
1722
1793
|
var paramsAttr = attrs[paramsAttrIndex];
|
|
1723
1794
|
// Check if params is already wrapped in useMemo
|
|
@@ -1740,6 +1811,9 @@ function updateDataProviderForPlain(dp, fileName, usage) {
|
|
|
1740
1811
|
(0, filter_utils_1.pushStateIdsAsDeps)(memoDeps, memoSeen, usage.filterStateIds);
|
|
1741
1812
|
(0, filter_utils_1.pushPropIdsAsDeps)(memoDeps, memoSeen, usage.filterPropIds);
|
|
1742
1813
|
pushUrlSearchParamMemoDeps(memoDeps, usage);
|
|
1814
|
+
if (localized && paramsExpression.type === 'ObjectExpression') {
|
|
1815
|
+
(0, request_locale_1.appendClientLocaleParam)(paramsExpression.properties, memoDeps);
|
|
1816
|
+
}
|
|
1743
1817
|
// Wrap params in useMemo with filter state dependencies
|
|
1744
1818
|
var memoizedParams = types.callExpression(types.identifier('useMemo'), [
|
|
1745
1819
|
types.arrowFunctionExpression([], paramsExpression),
|
|
@@ -1771,11 +1845,18 @@ function stabilizeDataProviderWithoutRepeater(dp) {
|
|
|
1771
1845
|
if (!paramsExpression) {
|
|
1772
1846
|
return;
|
|
1773
1847
|
}
|
|
1774
|
-
// Wrap params in useMemo with empty dependencies array
|
|
1775
|
-
//
|
|
1848
|
+
// Wrap params in useMemo with an empty dependencies array so the object
|
|
1849
|
+
// reference stays stable across re-renders. The one thing that may vary is
|
|
1850
|
+
// the locale a client-fetched item carries (put there by the data-source
|
|
1851
|
+
// plugin): a locale switch must rebuild the params, or the item would keep
|
|
1852
|
+
// its previous language.
|
|
1853
|
+
var memoDeps = [];
|
|
1854
|
+
if (paramsExpression.type === 'ObjectExpression' && (0, request_locale_1.hasLocaleParam)(paramsExpression.properties)) {
|
|
1855
|
+
memoDeps.push((0, request_locale_1.buildClientLocaleExpression)());
|
|
1856
|
+
}
|
|
1776
1857
|
var memoizedParams = types.callExpression(types.identifier('useMemo'), [
|
|
1777
1858
|
types.arrowFunctionExpression([], paramsExpression),
|
|
1778
|
-
types.arrayExpression(
|
|
1859
|
+
types.arrayExpression(memoDeps),
|
|
1779
1860
|
]);
|
|
1780
1861
|
// Replace the params attribute
|
|
1781
1862
|
attrs[paramsAttrIndex] = types.jsxAttribute(types.jsxIdentifier('params'), types.jsxExpressionContainer(memoizedParams));
|
|
@@ -2087,7 +2168,7 @@ function ensureAPIRouteExists(extractedResources, usage, dataSources, transformO
|
|
|
2087
2168
|
};
|
|
2088
2169
|
}
|
|
2089
2170
|
}
|
|
2090
|
-
function updateGetStaticProps(chunks, registry, dependencies, folderPath) {
|
|
2171
|
+
function updateGetStaticProps(chunks, registry, dependencies, folderPath, localized) {
|
|
2091
2172
|
var _a;
|
|
2092
2173
|
var getStaticPropsChunk = chunks.find(function (c) { return c.name === 'getStaticProps'; });
|
|
2093
2174
|
if (!getStaticPropsChunk || getStaticPropsChunk.type !== teleport_types_1.ChunkType.AST) {
|
|
@@ -2182,6 +2263,11 @@ function updateGetStaticProps(chunks, registry, dependencies, folderPath) {
|
|
|
2182
2263
|
})),
|
|
2183
2264
|
])));
|
|
2184
2265
|
}
|
|
2266
|
+
(0, items_path_1.appendItemsPathParam)(fetchParams, usage.itemsPath, 'itemsPath');
|
|
2267
|
+
// The prefetch is per locale — getStaticProps runs once per language.
|
|
2268
|
+
if (localized) {
|
|
2269
|
+
fetchParams.push((0, request_locale_1.buildServerLocaleParam)());
|
|
2270
|
+
}
|
|
2185
2271
|
// Check if this fetch already exists
|
|
2186
2272
|
var existingFetchIndex = arrayPattern.elements.findIndex(function (el) { return (el === null || el === void 0 ? void 0 : el.type) === 'Identifier' && el.name === vars.propsPrefix; });
|
|
2187
2273
|
if (existingFetchIndex === -1) {
|
|
@@ -2216,8 +2302,10 @@ function updateGetStaticProps(chunks, registry, dependencies, folderPath) {
|
|
|
2216
2302
|
// Use filter-specific count variable if usage has static filters
|
|
2217
2303
|
// (dynamic filters can't be resolved at build time)
|
|
2218
2304
|
var staticFiltersForCount = (usage.filters || []).filter(function (f) { return !teleport_plugin_common_1.ASTUtils.isUIDLDynamicReference(f.destination); });
|
|
2219
|
-
|
|
2220
|
-
|
|
2305
|
+
// A count scoped to an inner array is a different number from the
|
|
2306
|
+
// whole-payload one, so it gets its own variable just like a filtered one.
|
|
2307
|
+
var hasScopedCount = staticFiltersForCount.length > 0 || !!usage.itemsPath;
|
|
2308
|
+
var countVarName = hasScopedCount
|
|
2221
2309
|
? "".concat(usage.dataSourceIdentifier, "_ds_").concat(usage.index, "_count")
|
|
2222
2310
|
: "".concat(usage.dataSourceIdentifier, "_count");
|
|
2223
2311
|
// Check if maxPages calculation already exists
|
|
@@ -2255,7 +2343,7 @@ function updateGetStaticProps(chunks, registry, dependencies, folderPath) {
|
|
|
2255
2343
|
var usagesByFilters = new Map();
|
|
2256
2344
|
for (var _i = 0, usagesForDataSource_1 = usagesForDataSource; _i < usagesForDataSource_1.length; _i++) {
|
|
2257
2345
|
var usage = usagesForDataSource_1[_i];
|
|
2258
|
-
var filtersKey = JSON.stringify(usage.filters || []);
|
|
2346
|
+
var filtersKey = JSON.stringify([usage.filters || [], usage.itemsPath || []]);
|
|
2259
2347
|
var existing = usagesByFilters.get(filtersKey) || [];
|
|
2260
2348
|
existing.push(usage);
|
|
2261
2349
|
usagesByFilters.set(filtersKey, existing);
|
|
@@ -2266,8 +2354,9 @@ function updateGetStaticProps(chunks, registry, dependencies, folderPath) {
|
|
|
2266
2354
|
// Filter out dynamic destinations for getStaticProps (they can't be resolved at build time)
|
|
2267
2355
|
var staticFiltersForCount = (firstUsage.filters || []).filter(function (f) { return !teleport_plugin_common_1.ASTUtils.isUIDLDynamicReference(f.destination); });
|
|
2268
2356
|
var hasStaticFilters = staticFiltersForCount.length > 0;
|
|
2269
|
-
// Create unique count variable name based on filters
|
|
2270
|
-
|
|
2357
|
+
// Create unique count variable name based on filters (and inner-array
|
|
2358
|
+
// scope — must match the naming at the maxPages site above)
|
|
2359
|
+
var countVarName = hasStaticFilters || firstUsage.itemsPath
|
|
2271
2360
|
? "".concat(firstUsage.dataSourceIdentifier, "_ds_").concat(firstUsage.index, "_count")
|
|
2272
2361
|
: "".concat(firstUsage.dataSourceIdentifier, "_count");
|
|
2273
2362
|
// Check if this count was already processed
|
|
@@ -2293,6 +2382,7 @@ function updateGetStaticProps(chunks, registry, dependencies, folderPath) {
|
|
|
2293
2382
|
})),
|
|
2294
2383
|
])));
|
|
2295
2384
|
}
|
|
2385
|
+
(0, items_path_1.appendItemsPathParam)(countParams, firstUsage.itemsPath, 'collectionPath');
|
|
2296
2386
|
fetchesArray.elements.push(types.callExpression(types.memberExpression(types.callExpression(types.memberExpression(types.identifier(fetcherImportName), types.identifier('fetchCount')), countParams.length > 0 ? [types.objectExpression(countParams)] : []), types.identifier('catch')), [
|
|
2297
2387
|
types.arrowFunctionExpression([types.identifier('error')], types.blockStatement([
|
|
2298
2388
|
types.expressionStatement(types.callExpression(types.memberExpression(types.identifier('console'), types.identifier('error')), [
|