@teleporthq/teleport-plugin-next-data-source 0.43.66 → 0.43.67

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 (179) hide show
  1. package/__tests__/array-mapper-cache-wiring.test.ts +11 -0
  2. package/__tests__/data-source-request-locale.test.ts +313 -0
  3. package/__tests__/gated-data-provider.test.ts +88 -0
  4. package/__tests__/localized-columns.test.ts +217 -0
  5. package/__tests__/numbered-pagination.test.ts +15 -0
  6. package/__tests__/product-filter-fields.ts +230 -0
  7. package/__tests__/product-filter-sql.fixture.json +7 -0
  8. package/__tests__/refetch-loading-state.test.ts +23 -0
  9. package/__tests__/search-clear-button.test.ts +122 -0
  10. package/dist/cjs/content-localization.d.ts +37 -0
  11. package/dist/cjs/content-localization.d.ts.map +1 -0
  12. package/dist/cjs/content-localization.js +29 -0
  13. package/dist/cjs/content-localization.js.map +1 -0
  14. package/dist/cjs/count-effect.d.ts +11 -1
  15. package/dist/cjs/count-effect.d.ts.map +1 -1
  16. package/dist/cjs/count-effect.js +30 -2
  17. package/dist/cjs/count-effect.js.map +1 -1
  18. package/dist/cjs/fetchers/airtable.d.ts.map +1 -1
  19. package/dist/cjs/fetchers/airtable.js +1 -1
  20. package/dist/cjs/fetchers/airtable.js.map +1 -1
  21. package/dist/cjs/fetchers/clickhouse.d.ts.map +1 -1
  22. package/dist/cjs/fetchers/clickhouse.js +1 -1
  23. package/dist/cjs/fetchers/clickhouse.js.map +1 -1
  24. package/dist/cjs/fetchers/firestore.d.ts.map +1 -1
  25. package/dist/cjs/fetchers/firestore.js +1 -1
  26. package/dist/cjs/fetchers/firestore.js.map +1 -1
  27. package/dist/cjs/fetchers/mariadb.d.ts.map +1 -1
  28. package/dist/cjs/fetchers/mariadb.js +1 -1
  29. package/dist/cjs/fetchers/mariadb.js.map +1 -1
  30. package/dist/cjs/fetchers/mongodb.d.ts.map +1 -1
  31. package/dist/cjs/fetchers/mongodb.js +1 -1
  32. package/dist/cjs/fetchers/mongodb.js.map +1 -1
  33. package/dist/cjs/fetchers/mysql.d.ts.map +1 -1
  34. package/dist/cjs/fetchers/mysql.js +1 -1
  35. package/dist/cjs/fetchers/mysql.js.map +1 -1
  36. package/dist/cjs/fetchers/postgresql.d.ts.map +1 -1
  37. package/dist/cjs/fetchers/postgresql.js +2 -1
  38. package/dist/cjs/fetchers/postgresql.js.map +1 -1
  39. package/dist/cjs/fetchers/redshift.d.ts.map +1 -1
  40. package/dist/cjs/fetchers/redshift.js +1 -1
  41. package/dist/cjs/fetchers/redshift.js.map +1 -1
  42. package/dist/cjs/fetchers/teleport.d.ts.map +1 -1
  43. package/dist/cjs/fetchers/teleport.js +10 -3
  44. package/dist/cjs/fetchers/teleport.js.map +1 -1
  45. package/dist/cjs/fetchers/turso.d.ts.map +1 -1
  46. package/dist/cjs/fetchers/turso.js +1 -1
  47. package/dist/cjs/fetchers/turso.js.map +1 -1
  48. package/dist/cjs/index.d.ts +5 -0
  49. package/dist/cjs/index.d.ts.map +1 -1
  50. package/dist/cjs/index.js +60 -8
  51. package/dist/cjs/index.js.map +1 -1
  52. package/dist/cjs/loading-state.d.ts +16 -1
  53. package/dist/cjs/loading-state.d.ts.map +1 -1
  54. package/dist/cjs/loading-state.js +69 -3
  55. package/dist/cjs/loading-state.js.map +1 -1
  56. package/dist/cjs/localized-columns.d.ts +56 -0
  57. package/dist/cjs/localized-columns.d.ts.map +1 -0
  58. package/dist/cjs/localized-columns.js +124 -0
  59. package/dist/cjs/localized-columns.js.map +1 -0
  60. package/dist/cjs/pagination-plugin.d.ts.map +1 -1
  61. package/dist/cjs/pagination-plugin.js +123 -45
  62. package/dist/cjs/pagination-plugin.js.map +1 -1
  63. package/dist/cjs/product-filter-fields.d.ts +87 -0
  64. package/dist/cjs/product-filter-fields.d.ts.map +1 -0
  65. package/dist/cjs/product-filter-fields.js +161 -0
  66. package/dist/cjs/product-filter-fields.js.map +1 -0
  67. package/dist/cjs/request-locale.d.ts +49 -0
  68. package/dist/cjs/request-locale.d.ts.map +1 -0
  69. package/dist/cjs/request-locale.js +130 -0
  70. package/dist/cjs/request-locale.js.map +1 -0
  71. package/dist/cjs/search-clear.d.ts +31 -0
  72. package/dist/cjs/search-clear.d.ts.map +1 -0
  73. package/dist/cjs/search-clear.js +103 -0
  74. package/dist/cjs/search-clear.js.map +1 -0
  75. package/dist/cjs/transformations/index.d.ts +16 -2
  76. package/dist/cjs/transformations/index.d.ts.map +1 -1
  77. package/dist/cjs/transformations/index.js +14 -2
  78. package/dist/cjs/transformations/index.js.map +1 -1
  79. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  80. package/dist/cjs/utils.d.ts +11 -1
  81. package/dist/cjs/utils.d.ts.map +1 -1
  82. package/dist/cjs/utils.js +59 -15
  83. package/dist/cjs/utils.js.map +1 -1
  84. package/dist/esm/content-localization.d.ts +37 -0
  85. package/dist/esm/content-localization.d.ts.map +1 -0
  86. package/dist/esm/content-localization.js +24 -0
  87. package/dist/esm/content-localization.js.map +1 -0
  88. package/dist/esm/count-effect.d.ts +11 -1
  89. package/dist/esm/count-effect.d.ts.map +1 -1
  90. package/dist/esm/count-effect.js +28 -1
  91. package/dist/esm/count-effect.js.map +1 -1
  92. package/dist/esm/fetchers/airtable.d.ts.map +1 -1
  93. package/dist/esm/fetchers/airtable.js +1 -1
  94. package/dist/esm/fetchers/airtable.js.map +1 -1
  95. package/dist/esm/fetchers/clickhouse.d.ts.map +1 -1
  96. package/dist/esm/fetchers/clickhouse.js +1 -1
  97. package/dist/esm/fetchers/clickhouse.js.map +1 -1
  98. package/dist/esm/fetchers/firestore.d.ts.map +1 -1
  99. package/dist/esm/fetchers/firestore.js +1 -1
  100. package/dist/esm/fetchers/firestore.js.map +1 -1
  101. package/dist/esm/fetchers/mariadb.d.ts.map +1 -1
  102. package/dist/esm/fetchers/mariadb.js +1 -1
  103. package/dist/esm/fetchers/mariadb.js.map +1 -1
  104. package/dist/esm/fetchers/mongodb.d.ts.map +1 -1
  105. package/dist/esm/fetchers/mongodb.js +1 -1
  106. package/dist/esm/fetchers/mongodb.js.map +1 -1
  107. package/dist/esm/fetchers/mysql.d.ts.map +1 -1
  108. package/dist/esm/fetchers/mysql.js +1 -1
  109. package/dist/esm/fetchers/mysql.js.map +1 -1
  110. package/dist/esm/fetchers/postgresql.d.ts.map +1 -1
  111. package/dist/esm/fetchers/postgresql.js +2 -1
  112. package/dist/esm/fetchers/postgresql.js.map +1 -1
  113. package/dist/esm/fetchers/redshift.d.ts.map +1 -1
  114. package/dist/esm/fetchers/redshift.js +1 -1
  115. package/dist/esm/fetchers/redshift.js.map +1 -1
  116. package/dist/esm/fetchers/teleport.d.ts.map +1 -1
  117. package/dist/esm/fetchers/teleport.js +10 -3
  118. package/dist/esm/fetchers/teleport.js.map +1 -1
  119. package/dist/esm/fetchers/turso.d.ts.map +1 -1
  120. package/dist/esm/fetchers/turso.js +1 -1
  121. package/dist/esm/fetchers/turso.js.map +1 -1
  122. package/dist/esm/index.d.ts +5 -0
  123. package/dist/esm/index.d.ts.map +1 -1
  124. package/dist/esm/index.js +55 -7
  125. package/dist/esm/index.js.map +1 -1
  126. package/dist/esm/loading-state.d.ts +16 -1
  127. package/dist/esm/loading-state.d.ts.map +1 -1
  128. package/dist/esm/loading-state.js +69 -3
  129. package/dist/esm/loading-state.js.map +1 -1
  130. package/dist/esm/localized-columns.d.ts +56 -0
  131. package/dist/esm/localized-columns.d.ts.map +1 -0
  132. package/dist/esm/localized-columns.js +119 -0
  133. package/dist/esm/localized-columns.js.map +1 -0
  134. package/dist/esm/pagination-plugin.d.ts.map +1 -1
  135. package/dist/esm/pagination-plugin.js +124 -46
  136. package/dist/esm/pagination-plugin.js.map +1 -1
  137. package/dist/esm/product-filter-fields.d.ts +87 -0
  138. package/dist/esm/product-filter-fields.d.ts.map +1 -0
  139. package/dist/esm/product-filter-fields.js +154 -0
  140. package/dist/esm/product-filter-fields.js.map +1 -0
  141. package/dist/esm/request-locale.d.ts +49 -0
  142. package/dist/esm/request-locale.d.ts.map +1 -0
  143. package/dist/esm/request-locale.js +98 -0
  144. package/dist/esm/request-locale.js.map +1 -0
  145. package/dist/esm/search-clear.d.ts +31 -0
  146. package/dist/esm/search-clear.d.ts.map +1 -0
  147. package/dist/esm/search-clear.js +74 -0
  148. package/dist/esm/search-clear.js.map +1 -0
  149. package/dist/esm/transformations/index.d.ts +16 -2
  150. package/dist/esm/transformations/index.d.ts.map +1 -1
  151. package/dist/esm/transformations/index.js +14 -2
  152. package/dist/esm/transformations/index.js.map +1 -1
  153. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  154. package/dist/esm/utils.d.ts +11 -1
  155. package/dist/esm/utils.d.ts.map +1 -1
  156. package/dist/esm/utils.js +59 -15
  157. package/dist/esm/utils.js.map +1 -1
  158. package/package.json +5 -5
  159. package/src/content-localization.ts +53 -0
  160. package/src/count-effect.ts +53 -2
  161. package/src/fetchers/airtable.ts +4 -2
  162. package/src/fetchers/clickhouse.ts +4 -2
  163. package/src/fetchers/firestore.ts +4 -2
  164. package/src/fetchers/mariadb.ts +4 -2
  165. package/src/fetchers/mongodb.ts +4 -2
  166. package/src/fetchers/mysql.ts +4 -2
  167. package/src/fetchers/postgresql.ts +16 -2
  168. package/src/fetchers/redshift.ts +4 -2
  169. package/src/fetchers/teleport.ts +48 -9
  170. package/src/fetchers/turso.ts +4 -2
  171. package/src/index.ts +79 -11
  172. package/src/loading-state.ts +134 -3
  173. package/src/localized-columns.ts +133 -0
  174. package/src/pagination-plugin.ts +177 -53
  175. package/src/product-filter-fields.ts +173 -0
  176. package/src/request-locale.ts +113 -0
  177. package/src/search-clear.ts +102 -0
  178. package/src/transformations/index.ts +30 -5
  179. package/src/utils.ts +83 -15
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ /**
3
+ * Filtering a products list on things that are not a plain column.
4
+ *
5
+ * The storefront's product filters ask questions the `teleport_products` row
6
+ * cannot answer with a single column comparison: "what does it cost right now"
7
+ * (`price` net of a live markdown), "how many stars" (an aggregate over the
8
+ * reviews table), "is it on sale", and "does it come in size XL" (a value
9
+ * inside the `variant_options` JSON). Like the discount-aware sort in
10
+ * `product-price-sort.ts`, these have to be answered by the DATABASE — the list
11
+ * is paginated, so filtering the fetched page would only filter 20 of N rows.
12
+ *
13
+ * The editor emits such a filter as an ordinary condition whose `source` is
14
+ * one of the VIRTUAL field names below. Every SQL builder that can receive a
15
+ * products filter rewrites them into the expressions here:
16
+ *
17
+ * - this file → the generated store's `teleport_products` API route
18
+ * (`fetchers/teleport.ts`, `fetchers/postgresql.ts`);
19
+ * - `database-provider-worker/src/lib/product-filter-fields.ts` → the editor
20
+ * canvas. ⛔ A byte-for-byte mirror of the SQL below; both repos pin the
21
+ * strings with a test, because a clause the canvas cannot build is an HTTP
22
+ * 500 the canvas draws as an EMPTY grid.
23
+ *
24
+ * ## The expressions cannot raise
25
+ *
26
+ * Same discipline as the sort: the JSON column is cast only when its text
27
+ * already looks like an array, the axis key is validated against a slug pattern
28
+ * before it is bound, and an unknown key filters to no rows instead of erroring
29
+ * — a filter that the database rejects would empty the whole products page.
30
+ */
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.generateProductFilterClauseHelper = exports.buildProductVariantAxisExistsSql = exports.SAFE_VARIANT_OPTIONS_JSONB = exports.buildProductOnSaleSql = exports.buildProductRatingBucketSql = exports.IN_OPERAND = exports.PRODUCT_VARIANT_AXIS_KEY_PATTERN = exports.PRODUCT_VARIANT_AXIS_FILTER_PREFIX = exports.PRODUCT_ON_SALE_FILTER_FIELD = exports.PRODUCT_RATING_FILTER_FIELD = exports.PRODUCT_REVIEWS_TABLE_NAME = void 0;
33
+ var product_price_sort_1 = require("./product-price-sort");
34
+ /** The reviews table the star-rating aggregate reads. Exists once reviews were enabled. */
35
+ exports.PRODUCT_REVIEWS_TABLE_NAME = 'teleport_product_reviews';
36
+ /** Virtual field: the product's star bucket — `ROUND(AVG(approved rating))`, 1..5, NULL when unreviewed. */
37
+ exports.PRODUCT_RATING_FILTER_FIELD = 'rating';
38
+ /** Virtual field: `'true'` while a markdown is live, else `'false'`. */
39
+ exports.PRODUCT_ON_SALE_FILTER_FIELD = 'on_sale';
40
+ /**
41
+ * Virtual field family: `variant_options.<axisKey>` — the product offers the
42
+ * axis (e.g. `size`) in one of the given values (e.g. `xl`).
43
+ */
44
+ exports.PRODUCT_VARIANT_AXIS_FILTER_PREFIX = 'variant_options.';
45
+ /**
46
+ * What an axis key may look like. Keys are produced by the editor's slug
47
+ * helper (`deriveOptionKey`), so this is what every real key matches; anything
48
+ * else is refused before it can reach the database.
49
+ */
50
+ exports.PRODUCT_VARIANT_AXIS_KEY_PATTERN = '^[a-z0-9][a-z0-9_-]{0,63}$';
51
+ /** Generic multi-value operand: the column equals ANY of the destination values. */
52
+ exports.IN_OPERAND = 'in';
53
+ /**
54
+ * `ROUND(AVG(rating))` over the product's APPROVED reviews. Only approved rows
55
+ * count — moderation is the merchant's veto — and the outer row is the
56
+ * unaliased `teleport_products` the fetchers select from.
57
+ */
58
+ var buildProductRatingBucketSql = function () {
59
+ return "(SELECT ROUND(AVG(r.rating)) FROM ".concat(exports.PRODUCT_REVIEWS_TABLE_NAME, " r WHERE r.product_id = ").concat(product_price_sort_1.PRODUCTS_TABLE_NAME, ".id AND r.status = 'approved' AND r.rating IS NOT NULL)");
60
+ };
61
+ exports.buildProductRatingBucketSql = buildProductRatingBucketSql;
62
+ /** `'true'` when the price paid today is below the list price, i.e. a markdown is live. */
63
+ var buildProductOnSaleSql = function () {
64
+ return "(CASE WHEN ".concat((0, product_price_sort_1.buildProductEffectivePriceSql)(), " < \"price\"::numeric THEN 'true' ELSE 'false' END)");
65
+ };
66
+ exports.buildProductOnSaleSql = buildProductOnSaleSql;
67
+ /**
68
+ * Only text that already looks like a JSON array is cast; NULL, empty or a
69
+ * hand-edited scalar reads as "no variant axes".
70
+ */
71
+ exports.SAFE_VARIANT_OPTIONS_JSONB = "CASE\n WHEN \"variant_options\" IS NULL OR btrim(\"variant_options\") NOT LIKE '[%' THEN '[]'::jsonb\n ELSE \"variant_options\"::jsonb\n END";
72
+ /**
73
+ * True when the product declares the axis bound to `keyParam` with at least one
74
+ * of the values bound to `valuesParam` (a `text[]`). Both are PARAMETERS, never
75
+ * interpolated text.
76
+ */
77
+ var buildProductVariantAxisExistsSql = function (keyParam, valuesParam) {
78
+ return "EXISTS (SELECT 1 FROM jsonb_array_elements(".concat(exports.SAFE_VARIANT_OPTIONS_JSONB, ") AS ax, jsonb_array_elements(CASE WHEN jsonb_typeof(ax->'values') = 'array' THEN ax->'values' ELSE '[]'::jsonb END) AS v WHERE ax->>'key' = ").concat(keyParam, " AND v->>'value' = ANY(").concat(valuesParam, "::text[]))");
79
+ };
80
+ exports.buildProductVariantAxisExistsSql = buildProductVariantAxisExistsSql;
81
+ /**
82
+ * The complete `productFilterClause(field, operand, value, pushParam)` helper a
83
+ * SQL fetcher embeds in its generated route.
84
+ *
85
+ * Returns a finished WHERE clause for a virtual (or rewritten) products field,
86
+ * or `null` for anything else so the fetcher's ordinary branches run. `pushParam`
87
+ * binds a value and answers its `$n` placeholder. By the time it is called an
88
+ * `in` filter has been normalised to `=` with an ARRAY value (see
89
+ * `normalizeInOperand` in `utils.ts`), which reads as "any of". A virtual field
90
+ * never answers `null` once matched — an operand it cannot express filters to
91
+ * no rows rather than falling into a branch that would name a column the table
92
+ * does not have.
93
+ *
94
+ * Emitted through `JSON.stringify` and string concatenation only — no backtick
95
+ * and no `${` may appear in the output, which is interpolated into a fetcher's
96
+ * template literal. On a table that is not the products table the helper still
97
+ * exists and always answers `null`, so a fetcher can embed it unconditionally.
98
+ */
99
+ var generateProductFilterClauseHelper = function (tableName) {
100
+ if (!(0, product_price_sort_1.supportsProductPriceSort)(tableName)) {
101
+ return [
102
+ '// Virtual products-table filter fields. This table has none, so every',
103
+ "// condition takes the fetcher's ordinary branches.",
104
+ 'function productFilterClause() {',
105
+ ' return null',
106
+ '}',
107
+ ].join('\n');
108
+ }
109
+ var lines = [
110
+ "// Rewrites the products table's virtual filter fields - the price paid",
111
+ '// today, the star-rating bucket, the on-sale flag and a variant axis - into',
112
+ '// SQL. Answers null for a plain column so the ordinary branches run. An',
113
+ '// "in" filter arrives here already normalised to "=" with an ARRAY value.',
114
+ 'function productFilterClause(field, operand, value, pushParam) {',
115
+ " var scalarOps = ['=', '!=', '>', '<', '>=', '<=']",
116
+ " var equalityOps = ['=', '!=']",
117
+ ' var compare = function (expression, allowedOps, virtual) {',
118
+ ' if (Array.isArray(value)) {',
119
+ " if (operand === '=') {",
120
+ " return expression + '::text = ANY(' + pushParam(value.map(String)) + '::text[])'",
121
+ ' }',
122
+ " if (operand === '!=') {",
123
+ " return expression + '::text <> ALL(' + pushParam(value.map(String)) + '::text[])'",
124
+ ' }',
125
+ " return virtual ? 'FALSE' : null",
126
+ ' }',
127
+ " if (allowedOps.indexOf(operand) === -1) return virtual ? 'FALSE' : null",
128
+ " return expression + ' ' + operand + ' ' + pushParam(value)",
129
+ ' }',
130
+ " if (field === ".concat(JSON.stringify(product_price_sort_1.PRODUCT_PRICE_SORT_FIELD), ") {"),
131
+ " return compare(".concat(JSON.stringify('(' + (0, product_price_sort_1.buildProductEffectivePriceSql)() + ')'), ", scalarOps, false)"),
132
+ ' }',
133
+ " if (field === ".concat(JSON.stringify(exports.PRODUCT_RATING_FILTER_FIELD), ") {"),
134
+ " return compare(".concat(JSON.stringify((0, exports.buildProductRatingBucketSql)()), ", scalarOps, true)"),
135
+ ' }',
136
+ " if (field === ".concat(JSON.stringify(exports.PRODUCT_ON_SALE_FILTER_FIELD), ") {"),
137
+ " return compare(".concat(JSON.stringify((0, exports.buildProductOnSaleSql)()), ", equalityOps, true)"),
138
+ ' }',
139
+ " if (field.indexOf(".concat(JSON.stringify(exports.PRODUCT_VARIANT_AXIS_FILTER_PREFIX), ") === 0) {"),
140
+ " var axisKey = field.slice(".concat(exports.PRODUCT_VARIANT_AXIS_FILTER_PREFIX.length, ")"),
141
+ " if (!new RegExp(".concat(JSON.stringify(exports.PRODUCT_VARIANT_AXIS_KEY_PATTERN), ").test(axisKey)) {"),
142
+ ' // Not a key the editor could have written: no rows, never an error.',
143
+ " return 'FALSE'",
144
+ ' }',
145
+ " if (operand !== '=') return 'FALSE'",
146
+ ' var values = (Array.isArray(value) ? value : [value]).map(String)',
147
+ ' var keyParam = pushParam(axisKey)',
148
+ ' var valuesParam = pushParam(values)',
149
+ " return ".concat(JSON.stringify((0, exports.buildProductVariantAxisExistsSql)('__KEY__', '__VALUES__'))),
150
+ // Function replacements: a "$1" inside a replacement STRING is a special
151
+ // pattern, so the placeholders are swapped by callback.
152
+ " .replace('__KEY__', function () { return keyParam })",
153
+ " .replace('__VALUES__', function () { return valuesParam })",
154
+ ' }',
155
+ ' return null',
156
+ '}',
157
+ ];
158
+ return lines.join('\n');
159
+ };
160
+ exports.generateProductFilterClauseHelper = generateProductFilterClauseHelper;
161
+ //# sourceMappingURL=product-filter-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-filter-fields.js","sourceRoot":"","sources":["../../src/product-filter-fields.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAEH,2DAK6B;AAE7B,2FAA2F;AAC9E,QAAA,0BAA0B,GAAG,0BAA0B,CAAA;AAEpE,4GAA4G;AAC/F,QAAA,2BAA2B,GAAG,QAAQ,CAAA;AAEnD,wEAAwE;AAC3D,QAAA,4BAA4B,GAAG,SAAS,CAAA;AAErD;;;GAGG;AACU,QAAA,kCAAkC,GAAG,kBAAkB,CAAA;AAEpE;;;;GAIG;AACU,QAAA,gCAAgC,GAAG,4BAA4B,CAAA;AAE5E,oFAAoF;AACvE,QAAA,UAAU,GAAG,IAAI,CAAA;AAE9B;;;;GAIG;AACI,IAAM,2BAA2B,GAAG;IACzC,OAAA,4CAAqC,kCAA0B,qCAA2B,wCAAmB,4DAAyD;AAAtK,CAAsK,CAAA;AAD3J,QAAA,2BAA2B,+BACgI;AAExK,2FAA2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AK;QACL,0BAAmB,IAAI,CAAC,SAAS,CAAC,oCAA4B,CAAC,QAAK;QACpE,6BAAsB,IAAI,CAAC,SAAS,CAAC,IAAA,6BAAqB,GAAE,CAAC,yBAAsB;QACnF,KAAK;QACL,8BAAuB,IAAI,CAAC,SAAS,CAAC,0CAAkC,CAAC,eAAY;QACrF,wCAAiC,0CAAkC,CAAC,MAAM,MAAG;QAC7E,8BAAuB,IAAI,CAAC,SAAS,CAAC,wCAAgC,CAAC,uBAAoB;QAC3F,4EAA4E;QAC5E,sBAAsB;QACtB,OAAO;QACP,yCAAyC;QACzC,uEAAuE;QACvE,uCAAuC;QACvC,yCAAyC;QACzC,qBAAc,IAAI,CAAC,SAAS,CAAC,IAAA,wCAAgC,EAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAE;QACzF,yEAAyE;QACzE,wDAAwD;QACxD,4DAA4D;QAC5D,kEAAkE;QAClE,KAAK;QACL,eAAe;QACf,GAAG;KACJ,CAAA;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC,CAAA;AA/DY,QAAA,iCAAiC,qCA+D7C"}
@@ -0,0 +1,49 @@
1
+ import * as types from '@babel/types';
2
+ import type { UIDLDependency } from '@teleporthq/teleport-types';
3
+ /**
4
+ * How a generated data-source fetch says which language it is for.
5
+ *
6
+ * A multi-language project stores a translatable column once per language
7
+ * (`name`, `es_name`, …) and the generated fetcher resolves each row against
8
+ * ONE of them (see `transformations/` and `localized-columns.ts`). Nothing
9
+ * about the API route knows the page it serves — an API route has no locale
10
+ * segment in its URL — so the page tells it, through this query parameter:
11
+ *
12
+ * - a client-side fetch (`DataProvider` `params`) sends `router.locale`;
13
+ * - a build-time fetch inside `getStaticProps` sends `context.locale`.
14
+ *
15
+ * Both are what Next.js resolved from the `/es/...` route, so the rows a page
16
+ * renders are in the language the page is in. The same name the details-page
17
+ * fetch (`teleport-plugin-next-static-props`) has always sent.
18
+ */
19
+ export declare const REQUEST_LOCALE_PARAM = "locale";
20
+ /**
21
+ * `router?.locale` — the client's current locale. Optional-chained like every
22
+ * other generated `router` read: `useRouter()` answers `null` during a static
23
+ * export's first paint.
24
+ */
25
+ export declare const buildClientLocaleExpression: () => types.Expression;
26
+ /** `locale: router?.locale` — the param of a client-side fetch. */
27
+ export declare const buildClientLocaleParam: () => types.ObjectProperty;
28
+ /** `locale: context.locale` — the param of a fetch inside getStaticProps. */
29
+ export declare const buildServerLocaleParam: () => types.ObjectProperty;
30
+ /** Whether an object literal already carries the locale param. */
31
+ export declare const hasLocaleParam: (properties: types.ObjectExpression['properties']) => boolean;
32
+ /**
33
+ * Adds the client locale to a fetch's params, once, and to the `useMemo` deps
34
+ * that must rebuild them: a locale switch is a client-side transition on the
35
+ * SAME page instance, so only a dependency change refetches the rows in the
36
+ * new language.
37
+ */
38
+ export declare const appendClientLocaleParam: (paramsProps: types.ObjectExpression['properties'], memoDeps: types.Expression[]) => void;
39
+ /**
40
+ * Puts `const router = useRouter()` (and its import) in scope, once.
41
+ *
42
+ * Idempotent with every sibling plugin that declares the same hook — the i18n
43
+ * locale mapper, the URL search-params plugin and the base component plugin
44
+ * all guard on the same identifier, so whichever runs first wins and the rest
45
+ * find it in place. Unshifted to the top of the body: nothing reads it before
46
+ * an effect runs, and hooks must not sit below a conditional return.
47
+ */
48
+ export declare const ensureRouterDeclaration: (body: types.Statement[], dependencies: Record<string, UIDLDependency>) => void;
49
+ //# sourceMappingURL=request-locale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-locale.d.ts","sourceRoot":"","sources":["../../src/request-locale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAEhE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAA;AAU5C;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,QAAO,MAAM,UAMlD,CAAA;AAEH,mEAAmE;AACnE,eAAO,MAAM,sBAAsB,QAAO,MAAM,cAC6C,CAAA;AAE7F,6EAA6E;AAC7E,eAAO,MAAM,sBAAsB,QAAO,MAAM,cAI7C,CAAA;AAEH,kEAAkE;AAClE,eAAO,MAAM,cAAc,eAAgB,MAAM,gBAAgB,CAAC,YAAY,CAAC,KAAG,OAM/E,CAAA;AAEH;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,gBACrB,MAAM,gBAAgB,CAAC,YAAY,CAAC,YACvC,MAAM,UAAU,EAAE,KAC3B,IAKF,CAAA;AASD;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,SAC5B,MAAM,SAAS,EAAE,gBACT,OAAO,MAAM,EAAE,cAAc,CAAC,KAC3C,IAeF,CAAA"}
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.ensureRouterDeclaration = exports.appendClientLocaleParam = exports.hasLocaleParam = exports.buildServerLocaleParam = exports.buildClientLocaleParam = exports.buildClientLocaleExpression = exports.REQUEST_LOCALE_PARAM = void 0;
38
+ var types = __importStar(require("@babel/types"));
39
+ /**
40
+ * How a generated data-source fetch says which language it is for.
41
+ *
42
+ * A multi-language project stores a translatable column once per language
43
+ * (`name`, `es_name`, …) and the generated fetcher resolves each row against
44
+ * ONE of them (see `transformations/` and `localized-columns.ts`). Nothing
45
+ * about the API route knows the page it serves — an API route has no locale
46
+ * segment in its URL — so the page tells it, through this query parameter:
47
+ *
48
+ * - a client-side fetch (`DataProvider` `params`) sends `router.locale`;
49
+ * - a build-time fetch inside `getStaticProps` sends `context.locale`.
50
+ *
51
+ * Both are what Next.js resolved from the `/es/...` route, so the rows a page
52
+ * renders are in the language the page is in. The same name the details-page
53
+ * fetch (`teleport-plugin-next-static-props`) has always sent.
54
+ */
55
+ exports.REQUEST_LOCALE_PARAM = 'locale';
56
+ /** The dependency behind the `router` every client-side locale read closes over. */
57
+ var USE_ROUTER_DEPENDENCY = {
58
+ type: 'library',
59
+ path: 'next/router',
60
+ version: '^12.1.10',
61
+ meta: { namedImport: true },
62
+ };
63
+ /**
64
+ * `router?.locale` — the client's current locale. Optional-chained like every
65
+ * other generated `router` read: `useRouter()` answers `null` during a static
66
+ * export's first paint.
67
+ */
68
+ var buildClientLocaleExpression = function () {
69
+ return types.optionalMemberExpression(types.identifier('router'), types.identifier('locale'), false, true);
70
+ };
71
+ exports.buildClientLocaleExpression = buildClientLocaleExpression;
72
+ /** `locale: router?.locale` — the param of a client-side fetch. */
73
+ var buildClientLocaleParam = function () {
74
+ return types.objectProperty(types.identifier(exports.REQUEST_LOCALE_PARAM), (0, exports.buildClientLocaleExpression)());
75
+ };
76
+ exports.buildClientLocaleParam = buildClientLocaleParam;
77
+ /** `locale: context.locale` — the param of a fetch inside getStaticProps. */
78
+ var buildServerLocaleParam = function () {
79
+ return types.objectProperty(types.identifier(exports.REQUEST_LOCALE_PARAM), types.memberExpression(types.identifier('context'), types.identifier('locale')));
80
+ };
81
+ exports.buildServerLocaleParam = buildServerLocaleParam;
82
+ /** Whether an object literal already carries the locale param. */
83
+ var hasLocaleParam = function (properties) {
84
+ return properties.some(function (property) {
85
+ return property.type === 'ObjectProperty' &&
86
+ ((property.key.type === 'Identifier' && property.key.name === exports.REQUEST_LOCALE_PARAM) ||
87
+ (property.key.type === 'StringLiteral' && property.key.value === exports.REQUEST_LOCALE_PARAM));
88
+ });
89
+ };
90
+ exports.hasLocaleParam = hasLocaleParam;
91
+ /**
92
+ * Adds the client locale to a fetch's params, once, and to the `useMemo` deps
93
+ * that must rebuild them: a locale switch is a client-side transition on the
94
+ * SAME page instance, so only a dependency change refetches the rows in the
95
+ * new language.
96
+ */
97
+ var appendClientLocaleParam = function (paramsProps, memoDeps) {
98
+ if (!(0, exports.hasLocaleParam)(paramsProps)) {
99
+ paramsProps.push((0, exports.buildClientLocaleParam)());
100
+ }
101
+ memoDeps.push((0, exports.buildClientLocaleExpression)());
102
+ };
103
+ exports.appendClientLocaleParam = appendClientLocaleParam;
104
+ /** Any declaration of `router` — a second one, however it is initialised, is a syntax error. */
105
+ var declaresRouter = function (statement) {
106
+ return statement.type === 'VariableDeclaration' &&
107
+ statement.declarations.some(function (declaration) { return declaration.id.type === 'Identifier' && declaration.id.name === 'router'; });
108
+ };
109
+ /**
110
+ * Puts `const router = useRouter()` (and its import) in scope, once.
111
+ *
112
+ * Idempotent with every sibling plugin that declares the same hook — the i18n
113
+ * locale mapper, the URL search-params plugin and the base component plugin
114
+ * all guard on the same identifier, so whichever runs first wins and the rest
115
+ * find it in place. Unshifted to the top of the body: nothing reads it before
116
+ * an effect runs, and hooks must not sit below a conditional return.
117
+ */
118
+ var ensureRouterDeclaration = function (body, dependencies) {
119
+ if (!dependencies.useRouter) {
120
+ dependencies.useRouter = __assign({}, USE_ROUTER_DEPENDENCY);
121
+ }
122
+ if (body.some(declaresRouter)) {
123
+ return;
124
+ }
125
+ body.unshift(types.variableDeclaration('const', [
126
+ types.variableDeclarator(types.identifier('router'), types.callExpression(types.identifier('useRouter'), [])),
127
+ ]));
128
+ };
129
+ exports.ensureRouterDeclaration = ensureRouterDeclaration;
130
+ //# sourceMappingURL=request-locale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-locale.js","sourceRoot":"","sources":["../../src/request-locale.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAqC;AAGrC;;;;;;;;;;;;;;;GAeG;AACU,QAAA,oBAAoB,GAAG,QAAQ,CAAA;AAE5C,oFAAoF;AACpF,IAAM,qBAAqB,GAAmB;IAC5C,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;CAC5B,CAAA;AAED;;;;GAIG;AACI,IAAM,2BAA2B,GAAG;IACzC,OAAA,KAAK,CAAC,wBAAwB,CAC5B,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,EAC1B,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,EAC1B,KAAK,EACL,IAAI,CACL;AALD,CAKC,CAAA;AANU,QAAA,2BAA2B,+BAMrC;AAEH,mEAAmE;AAC5D,IAAM,sBAAsB,GAAG;IACpC,OAAA,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,4BAAoB,CAAC,EAAE,IAAA,mCAA2B,GAAE,CAAC;AAA3F,CAA2F,CAAA;AADhF,QAAA,sBAAsB,0BAC0D;AAE7F,6EAA6E;AACtE,IAAM,sBAAsB,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,CAAC,IAAI,KAAK,QAAQ,EAAxE,CAAwE,CAC1F;AAHD,CAGC,CAAA;AAEH;;;;;;;;GAQG;AACI,IAAM,uBAAuB,GAAG,UACrC,IAAuB,EACvB,YAA4C;IAE5C,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE;QAC3B,YAAY,CAAC,SAAS,gBAAQ,qBAAqB,CAAE,CAAA;KACtD;IACD,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE;QAC7B,OAAM;KACP;IACD,IAAI,CAAC,OAAO,CACV,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE;QACjC,KAAK,CAAC,kBAAkB,CACtB,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,EAC1B,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,CACxD;KACF,CAAC,CACH,CAAA;AACH,CAAC,CAAA;AAlBY,QAAA,uBAAuB,2BAkBnC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The "clear search" button a listing's search field carries — marked
3
+ * `data-tq-search-clear` by the editor (`listing-search-field.ts`), the same
4
+ * marker the canvas renderer acts on. The search keyword is the mapper's own
5
+ * React state, which no authored workflow can reach, so the generator wires
6
+ * the button here: a click empties the query, and the button renders only
7
+ * while the query is non-empty.
8
+ *
9
+ * A button belongs to the search input it shares a parent with — the field
10
+ * wrapper — never to "the next search-enabled mapper": a page with two lists
11
+ * and one clear button would otherwise wire it to the wrong list.
12
+ */
13
+ export declare const SEARCH_CLEAR_ATTR = "data-tq-search-clear";
14
+ export interface SearchClearButton {
15
+ node: any;
16
+ parent: any;
17
+ index: number;
18
+ }
19
+ /** Every marked button under `root`, with the JSX parent and child index it sits at. */
20
+ export declare function findAllSearchClearButtonsInJSX(root: any): SearchClearButton[];
21
+ /** The search input the button shares its parent with, or null. */
22
+ export declare function findSiblingSearchInput(button: SearchClearButton, searchInputs: any[]): any | null;
23
+ /**
24
+ * Wires one button: `onClick` empties the query, and the element is replaced
25
+ * in its parent by `{query ? <button…/> : null}`.
26
+ */
27
+ export declare function wireSearchClearButton(button: SearchClearButton, vars: {
28
+ searchQueryVar: string;
29
+ setSearchQueryVar: string;
30
+ }): void;
31
+ //# sourceMappingURL=search-clear.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-clear.d.ts","sourceRoot":"","sources":["../../src/search-clear.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,iBAAiB,yBAAyB,CAAA;AAIvD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,GAAG,CAAA;IACT,MAAM,EAAE,GAAG,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;CACd;AAQD,wFAAwF;AACxF,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,GAAG,GAAG,iBAAiB,EAAE,CAqC7E;AAED,mEAAmE;AACnE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,iBAAiB,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,CAGjG;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,iBAAiB,EACzB,IAAI,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,GAC1D,IAAI,CAgBN"}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.wireSearchClearButton = exports.findSiblingSearchInput = exports.findAllSearchClearButtonsInJSX = exports.SEARCH_CLEAR_ATTR = void 0;
27
+ var types = __importStar(require("@babel/types"));
28
+ var pagination_controls_1 = require("./pagination-controls");
29
+ /**
30
+ * The "clear search" button a listing's search field carries — marked
31
+ * `data-tq-search-clear` by the editor (`listing-search-field.ts`), the same
32
+ * marker the canvas renderer acts on. The search keyword is the mapper's own
33
+ * React state, which no authored workflow can reach, so the generator wires
34
+ * the button here: a click empties the query, and the button renders only
35
+ * while the query is non-empty.
36
+ *
37
+ * A button belongs to the search input it shares a parent with — the field
38
+ * wrapper — never to "the next search-enabled mapper": a page with two lists
39
+ * and one clear button would otherwise wire it to the wrong list.
40
+ */
41
+ exports.SEARCH_CLEAR_ATTR = 'data-tq-search-clear';
42
+ function hasSearchClearMarker(node) {
43
+ var _a, _b;
44
+ return !!((_b = (_a = node === null || node === void 0 ? void 0 : node.openingElement) === null || _a === void 0 ? void 0 : _a.attributes) === null || _b === void 0 ? void 0 : _b.some(function (attr) { var _a; return attr.type === 'JSXAttribute' && ((_a = attr.name) === null || _a === void 0 ? void 0 : _a.name) === exports.SEARCH_CLEAR_ATTR; }));
45
+ }
46
+ /** Every marked button under `root`, with the JSX parent and child index it sits at. */
47
+ function findAllSearchClearButtonsInJSX(root) {
48
+ var results = [];
49
+ var traverse = function (node) {
50
+ if (!node) {
51
+ return;
52
+ }
53
+ if (node.type === 'JSXElement' && Array.isArray(node.children)) {
54
+ node.children.forEach(function (child, index) {
55
+ if ((child === null || child === void 0 ? void 0 : child.type) === 'JSXElement' && hasSearchClearMarker(child)) {
56
+ results.push({ node: child, parent: node, index: index });
57
+ }
58
+ traverse(child);
59
+ });
60
+ return;
61
+ }
62
+ if (node.body) {
63
+ if (Array.isArray(node.body)) {
64
+ node.body.forEach(function (statement) { return traverse(statement); });
65
+ }
66
+ else {
67
+ traverse(node.body);
68
+ }
69
+ }
70
+ if (node.consequent) {
71
+ traverse(node.consequent);
72
+ }
73
+ if (node.alternate) {
74
+ traverse(node.alternate);
75
+ }
76
+ if (node.expression) {
77
+ traverse(node.expression);
78
+ }
79
+ if (node.argument) {
80
+ traverse(node.argument);
81
+ }
82
+ };
83
+ traverse(root);
84
+ return results;
85
+ }
86
+ exports.findAllSearchClearButtonsInJSX = findAllSearchClearButtonsInJSX;
87
+ /** The search input the button shares its parent with, or null. */
88
+ function findSiblingSearchInput(button, searchInputs) {
89
+ var _a, _b;
90
+ var siblings = (_a = button.parent.children) !== null && _a !== void 0 ? _a : [];
91
+ return (_b = siblings.find(function (sibling) { return searchInputs.includes(sibling); })) !== null && _b !== void 0 ? _b : null;
92
+ }
93
+ exports.findSiblingSearchInput = findSiblingSearchInput;
94
+ /**
95
+ * Wires one button: `onClick` empties the query, and the element is replaced
96
+ * in its parent by `{query ? <button…/> : null}`.
97
+ */
98
+ function wireSearchClearButton(button, vars) {
99
+ (0, pagination_controls_1.setJSXExpressionAttribute)(button.node, 'onClick', types.arrowFunctionExpression([], types.callExpression(types.identifier(vars.setSearchQueryVar), [types.stringLiteral('')])));
100
+ button.parent.children[button.index] = types.jsxExpressionContainer(types.conditionalExpression(types.identifier(vars.searchQueryVar), button.node, types.nullLiteral()));
101
+ }
102
+ exports.wireSearchClearButton = wireSearchClearButton;
103
+ //# sourceMappingURL=search-clear.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-clear.js","sourceRoot":"","sources":["../../src/search-clear.ts"],"names":[],"mappings":";;;;;;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1F,CACF,CAAA;IACD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,sBAAsB,CACjE,KAAK,CAAC,qBAAqB,CACzB,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,EACrC,MAAM,CAAC,IAAI,EACX,KAAK,CAAC,WAAW,EAAE,CACpB,CACF,CAAA;AACH,CAAC;AAnBD,sDAmBC"}
@@ -1,5 +1,6 @@
1
1
  import type { GeneratorOptions, UIDLEcommerceCategory } from '@teleporthq/teleport-types';
2
2
  import { type EcommerceProductTransformOptions } from './ecommerce-product';
3
+ import { type ContentLocalization, type LocalizedProjectOptions } from '../content-localization';
3
4
  export type { EcommerceProductTransformOptions };
4
5
  /**
5
6
  * Everything a generated fetcher bakes in, for EITHER entity. One options object
@@ -10,6 +11,13 @@ export type { EcommerceProductTransformOptions };
10
11
  export interface EntityTransformOptions extends EcommerceProductTransformOptions {
11
12
  /** Blog post-category taxonomy — see `blogSettings.categories`. */
12
13
  blogCategories?: UIDLEcommerceCategory[];
14
+ /**
15
+ * The languages the rows are stored in — absent for a single-language
16
+ * project. The transform resolves every translatable field against the
17
+ * request's locale (`?locale=es` → `es_name`, falling back to `name`), and
18
+ * the fetcher matches and sorts translatable columns the same way.
19
+ */
20
+ localization?: ContentLocalization;
13
21
  }
14
22
  /**
15
23
  * Collects everything the product transform bakes in from the generator
@@ -20,7 +28,7 @@ export interface EntityTransformOptions extends EcommerceProductTransformOptions
20
28
  * tax-inclusive or untaxed stores. `allowBackorders` is the effective
21
29
  * "stock never blocks a purchase" flag — see `resolveAllowBackorders`.
22
30
  */
23
- export declare const buildProductTransformOptions: (options: Pick<GeneratorOptions, 'ecommerceSettings' | 'invoiceSettings' | 'blogSettings'>) => EntityTransformOptions;
31
+ export declare const buildProductTransformOptions: (options: Pick<GeneratorOptions, 'ecommerceSettings' | 'invoiceSettings' | 'blogSettings'> & LocalizedProjectOptions) => EntityTransformOptions;
24
32
  export type TransformationType = 'blog-post' | 'ecommerce-product' | 'custom-page' | null;
25
33
  /**
26
34
  * Detects which transformation type to apply based on the table name.
@@ -61,6 +69,12 @@ export declare const REVIEWS_PER_PRODUCT = 5;
61
69
  * Returns the transform wrapper function code that handles asset map loading
62
70
  * and calls the appropriate transformer.
63
71
  * Returns empty string if no transformation is needed.
72
+ *
73
+ * The request's `locale` (see `REQUEST_LOCALE_PARAM`) is what every
74
+ * translatable field resolves against; the MAIN locale it falls back to is a
75
+ * project constant and is baked in from `options.localization` rather than
76
+ * asked of every caller. Without a localization every row reads as before —
77
+ * the base columns.
64
78
  */
65
- export declare const getTransformWrapperCode: (tableName: string) => string;
79
+ export declare const getTransformWrapperCode: (tableName: string, options?: Pick<EntityTransformOptions, 'localization'>) => string;
66
80
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transformations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAKzF,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,qBAAqB,CAAA;AAE5B,YAAY,EAAE,gCAAgC,EAAE,CAAA;AAEhD;;;;;GAKG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gCAAgC;IAC9E,mEAAmE;IACnE,cAAc,CAAC,EAAE,qBAAqB,EAAE,CAAA;CACzC;AAkBD;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,YAC9B,KAAK,gBAAgB,EAAE,mBAAmB,GAAG,iBAAiB,GAAG,cAAc,CAAC,KACxF,sBAKD,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,mBAAmB,GAAG,aAAa,GAAG,IAAI,CAAA;AAezF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,cAAe,MAAM,KAAG,kBAe5D,CAAA;AAED;;;;GAIG;AACH,eAAO,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AAM,KAAG,MAAM,GAAG,IAgBnE,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAA;AAEpC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,cACvB,MAAM,YACR,KAAK,sBAAsB,EAAE,cAAc,CAAC,KACpD,MAkIF,CAAA"}
@@ -6,6 +6,8 @@ var shared_utils_1 = require("./shared-utils");
6
6
  var blog_post_1 = require("./blog-post");
7
7
  var custom_page_1 = require("./custom-page");
8
8
  var ecommerce_product_1 = require("./ecommerce-product");
9
+ var request_locale_1 = require("../request-locale");
10
+ var content_localization_1 = require("../content-localization");
9
11
  /**
10
12
  * Stock never gates purchasability when the merchant disabled stock management
11
13
  * entirely or opted into backorders. Mirrors the GUI rule in
@@ -36,6 +38,7 @@ var buildProductTransformOptions = function (options) {
36
38
  blogCategories: (_b = options.blogSettings) === null || _b === void 0 ? void 0 : _b.categories,
37
39
  storefrontTaxRate: teleport_shared_1.StorefrontTax.resolveStorefrontTaxRate(options.invoiceSettings),
38
40
  allowBackorders: resolveAllowBackorders(options.ecommerceSettings),
41
+ localization: (0, content_localization_1.resolveContentLocalization)(options),
39
42
  });
40
43
  };
41
44
  exports.buildProductTransformOptions = buildProductTransformOptions;
@@ -140,12 +143,21 @@ exports.REVIEWS_PER_PRODUCT = 5;
140
143
  * Returns the transform wrapper function code that handles asset map loading
141
144
  * and calls the appropriate transformer.
142
145
  * Returns empty string if no transformation is needed.
146
+ *
147
+ * The request's `locale` (see `REQUEST_LOCALE_PARAM`) is what every
148
+ * translatable field resolves against; the MAIN locale it falls back to is a
149
+ * project constant and is baked in from `options.localization` rather than
150
+ * asked of every caller. Without a localization every row reads as before —
151
+ * the base columns.
143
152
  */
144
- var getTransformWrapperCode = function (tableName) {
153
+ var getTransformWrapperCode = function (tableName, options) {
154
+ var _a, _b;
155
+ if (options === void 0) { options = {}; }
145
156
  var type = (0, exports.detectTransformationType)(tableName);
146
157
  if (!type) {
147
158
  return '';
148
159
  }
160
+ var mainLanguageLiteral = JSON.stringify((_b = (_a = options.localization) === null || _a === void 0 ? void 0 : _a.mainLocale) !== null && _b !== void 0 ? _b : null);
149
161
  var transformFn = type === 'blog-post'
150
162
  ? 'transformBlogPosts'
151
163
  : type === 'custom-page'
@@ -189,7 +201,7 @@ var getTransformWrapperCode = function (tableName) {
189
201
  ? "\n var ".concat(relatedMapVar, " = null\n if (Array.isArray(records) && records.length === 1) {\n try {\n ").concat(relatedMapVar, " = await ").concat(relatedMapFn, "(getClientFn, records)\n } catch (e) {\n // Best-effort; the related rail stays hidden behind its empty gate.\n }\n }")
190
202
  : '';
191
203
  var relatedOption = hasRelatedItems ? ", ".concat(relatedMapVar, ": ").concat(relatedMapVar) : '';
192
- return "\nasync function transformRecords(records, getClientFn, reqQuery) {\n var assetMap = {}\n try {\n assetMap = await getAssetMap(getClientFn)\n } catch (e) {\n // Asset resolution is best-effort; continue without it\n }".concat(relatedEnrichment).concat(variantEnrichment, "\n var currentLanguage = (reqQuery && reqQuery.lang) || null\n var mainLanguage = (reqQuery && reqQuery.mainLang) || null\n var options = { assetMap: assetMap, currentLanguage: currentLanguage, mainLanguage: mainLanguage").concat(variantOption).concat(relatedOption, " }\n return ").concat(transformFn, "(records, options)\n}\n");
204
+ return "\nasync function transformRecords(records, getClientFn, reqQuery) {\n var assetMap = {}\n try {\n assetMap = await getAssetMap(getClientFn)\n } catch (e) {\n // Asset resolution is best-effort; continue without it\n }".concat(relatedEnrichment).concat(variantEnrichment, "\n var currentLanguage = reqQuery && typeof reqQuery.").concat(request_locale_1.REQUEST_LOCALE_PARAM, " === 'string' && reqQuery.").concat(request_locale_1.REQUEST_LOCALE_PARAM, " ? reqQuery.").concat(request_locale_1.REQUEST_LOCALE_PARAM, " : null\n var options = { assetMap: assetMap, currentLanguage: currentLanguage, mainLanguage: ").concat(mainLanguageLiteral).concat(variantOption).concat(relatedOption, " }\n return ").concat(transformFn, "(records, options)\n}\n");
193
205
  };
194
206
  exports.getTransformWrapperCode = getTransformWrapperCode;
195
207
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transformations/index.ts"],"names":[],"mappings":";;;AACA,+DAA2D;AAC3D,+CAAiE;AACjE,yCAAgE;AAChE,6CAAoE;AACpE,yDAG4B;AAe5B;;;;;;GAMG;AACH,IAAM,sBAAsB,GAAG,UAC7B,QAA2D;;IAE3D,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,KAAK,CAAA;KACb;IACD,OAAO,CAAC,QAAQ,CAAC,eAAe,IAAI,CAAA,MAAA,QAAQ,CAAC,qBAAqB,0CAAE,eAAe,MAAK,IAAI,CAAA;AAC9F,CAAC,CAAA;AAED;;;;;;;;GAQG;AACI,IAAM,4BAA4B,GAAG,UAC1C,OAAyF;;IAC9D,OAAA,CAAC;QAC5B,UAAU,EAAE,MAAA,OAAO,CAAC,iBAAiB,0CAAE,UAAU;QACjD,cAAc,EAAE,MAAA,OAAO,CAAC,YAAY,0CAAE,UAAU;QAChD,iBAAiB,EAAE,+BAAa,CAAC,wBAAwB,CAAC,OAAO,CAAC,eAAe,CAAC;QAClF,eAAe,EAAE,sBAAsB,CAAC,OAAO,CAAC,iBAAiB,CAAC;KACnE,CAAC,CAAA;CAAA,CAAA;AAPW,QAAA,4BAA4B,gCAOvC;AAIF;;;;GAIG;AACH,IAAM,oBAAoB,GAAG,UAAC,SAAiB;IAC7C,IAAM,KAAK,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAA;IAC5C,IAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACtC,IAAM,IAAI,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;IAC5D,kEAAkE;IAClE,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,E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