@teleporthq/teleport-shared 0.43.67 → 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.
Files changed (87) hide show
  1. package/__tests__/utils/discount-engine.ts +1548 -0
  2. package/__tests__/utils/product-options.ts +2458 -0
  3. package/__tests__/utils/subscription-access.ts +37 -0
  4. package/dist/cjs/index.d.ts +9 -1
  5. package/dist/cjs/index.d.ts.map +1 -1
  6. package/dist/cjs/index.js +17 -1
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  9. package/dist/cjs/utils/cart-currency.d.ts +27 -0
  10. package/dist/cjs/utils/cart-currency.d.ts.map +1 -0
  11. package/dist/cjs/utils/cart-currency.js +31 -0
  12. package/dist/cjs/utils/cart-currency.js.map +1 -0
  13. package/dist/cjs/utils/cart-line-pricing.d.ts +25 -0
  14. package/dist/cjs/utils/cart-line-pricing.d.ts.map +1 -0
  15. package/dist/cjs/utils/cart-line-pricing.js +29 -0
  16. package/dist/cjs/utils/cart-line-pricing.js.map +1 -0
  17. package/dist/cjs/utils/discount-engine.d.ts +74 -0
  18. package/dist/cjs/utils/discount-engine.d.ts.map +1 -0
  19. package/dist/cjs/utils/discount-engine.js +435 -0
  20. package/dist/cjs/utils/discount-engine.js.map +1 -0
  21. package/dist/cjs/utils/product-options.d.ts +25 -0
  22. package/dist/cjs/utils/product-options.d.ts.map +1 -0
  23. package/dist/cjs/utils/product-options.js +1155 -0
  24. package/dist/cjs/utils/product-options.js.map +1 -0
  25. package/dist/cjs/utils/session-cookie-resolver.d.ts +85 -0
  26. package/dist/cjs/utils/session-cookie-resolver.d.ts.map +1 -0
  27. package/dist/cjs/utils/session-cookie-resolver.js +108 -0
  28. package/dist/cjs/utils/session-cookie-resolver.js.map +1 -0
  29. package/dist/cjs/utils/subscription-access.d.ts +36 -0
  30. package/dist/cjs/utils/subscription-access.d.ts.map +1 -0
  31. package/dist/cjs/utils/subscription-access.js +61 -0
  32. package/dist/cjs/utils/subscription-access.js.map +1 -0
  33. package/dist/cjs/utils/table-access.d.ts +114 -0
  34. package/dist/cjs/utils/table-access.d.ts.map +1 -0
  35. package/dist/cjs/utils/table-access.js +238 -0
  36. package/dist/cjs/utils/table-access.js.map +1 -0
  37. package/dist/cjs/utils/web-push.d.ts +43 -0
  38. package/dist/cjs/utils/web-push.d.ts.map +1 -0
  39. package/dist/cjs/utils/web-push.js +62 -0
  40. package/dist/cjs/utils/web-push.js.map +1 -0
  41. package/dist/esm/index.d.ts +9 -1
  42. package/dist/esm/index.d.ts.map +1 -1
  43. package/dist/esm/index.js +9 -1
  44. package/dist/esm/index.js.map +1 -1
  45. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  46. package/dist/esm/utils/cart-currency.d.ts +27 -0
  47. package/dist/esm/utils/cart-currency.d.ts.map +1 -0
  48. package/dist/esm/utils/cart-currency.js +27 -0
  49. package/dist/esm/utils/cart-currency.js.map +1 -0
  50. package/dist/esm/utils/cart-line-pricing.d.ts +25 -0
  51. package/dist/esm/utils/cart-line-pricing.d.ts.map +1 -0
  52. package/dist/esm/utils/cart-line-pricing.js +25 -0
  53. package/dist/esm/utils/cart-line-pricing.js.map +1 -0
  54. package/dist/esm/utils/discount-engine.d.ts +74 -0
  55. package/dist/esm/utils/discount-engine.d.ts.map +1 -0
  56. package/dist/esm/utils/discount-engine.js +431 -0
  57. package/dist/esm/utils/discount-engine.js.map +1 -0
  58. package/dist/esm/utils/product-options.d.ts +25 -0
  59. package/dist/esm/utils/product-options.d.ts.map +1 -0
  60. package/dist/esm/utils/product-options.js +1151 -0
  61. package/dist/esm/utils/product-options.js.map +1 -0
  62. package/dist/esm/utils/session-cookie-resolver.d.ts +85 -0
  63. package/dist/esm/utils/session-cookie-resolver.d.ts.map +1 -0
  64. package/dist/esm/utils/session-cookie-resolver.js +103 -0
  65. package/dist/esm/utils/session-cookie-resolver.js.map +1 -0
  66. package/dist/esm/utils/subscription-access.d.ts +36 -0
  67. package/dist/esm/utils/subscription-access.d.ts.map +1 -0
  68. package/dist/esm/utils/subscription-access.js +57 -0
  69. package/dist/esm/utils/subscription-access.js.map +1 -0
  70. package/dist/esm/utils/table-access.d.ts +114 -0
  71. package/dist/esm/utils/table-access.d.ts.map +1 -0
  72. package/dist/esm/utils/table-access.js +233 -0
  73. package/dist/esm/utils/table-access.js.map +1 -0
  74. package/dist/esm/utils/web-push.d.ts +43 -0
  75. package/dist/esm/utils/web-push.d.ts.map +1 -0
  76. package/dist/esm/utils/web-push.js +59 -0
  77. package/dist/esm/utils/web-push.js.map +1 -0
  78. package/package.json +3 -3
  79. package/src/index.ts +16 -0
  80. package/src/utils/cart-currency.ts +76 -0
  81. package/src/utils/cart-line-pricing.ts +151 -0
  82. package/src/utils/discount-engine.ts +437 -0
  83. package/src/utils/product-options.ts +1150 -0
  84. package/src/utils/session-cookie-resolver.ts +305 -0
  85. package/src/utils/subscription-access.ts +59 -0
  86. package/src/utils/table-access.ts +516 -0
  87. package/src/utils/web-push.ts +61 -0
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.generateTableAccessHelperCode = exports.resolveTrustedReaderRoles = exports.PUBLIC_FEED_TABLES = exports.AUTH_CREDENTIAL_TABLES = exports.AUTH_CREDENTIAL_COLUMNS = exports.WRITE_PROTECTED_TABLES = exports.PROTECTED_TABLES = exports.CUSTOMER_RECORD_TABLES = exports.MONEY_TABLES = void 0;
13
+ /**
14
+ * Which store tables a browser may touch through the generated data routes.
15
+ *
16
+ * Every generated Next store exposes two families of data routes: the
17
+ * workflow data API (`/api/data/<source>/<op>`, called by workflow data nodes)
18
+ * and one read route per bound table (`/api/teleport-<table>-<source>`, called
19
+ * by the pages' data providers, with a `rawQuery` escape hatch). Both accept
20
+ * a browser's request. For most tables that is the product: a catalogue is
21
+ * public. For the tables below it is theft.
22
+ *
23
+ * `MONEY_TABLES` are money and the keys to it: a gift card's code and
24
+ * balance, its ledger, every voucher code (a generated batch is a list of
25
+ * single-use coupons) and the redemption ledger. A browser reads or writes
26
+ * them only as a signed-in member of a trusted role (the generated admin) —
27
+ * the server-side workflow segments that look a card up, debit it or redeem a
28
+ * code identify themselves with the app secret instead.
29
+ *
30
+ * `CUSTOMER_RECORD_TABLES` are the customers' own records: who ordered what
31
+ * and where it ships, their invoices, parcels, returns, carts and reviews,
32
+ * and the accounts themselves. A buyer is served their own order through the
33
+ * page-load workflow (a server segment), the merchant every order through
34
+ * the admin's session — nothing in a generated storefront lists them from
35
+ * the browser, so a browser that asks for the list is not the store.
36
+ *
37
+ * `PROTECTED_TABLES` is both, spliced into both route families and the
38
+ * restricted-caller SQL check, so no reader can disagree about what is
39
+ * private.
40
+ *
41
+ * `WRITE_PROTECTED_TABLES` decide how much is given away but must stay readable:
42
+ * the storefront provider loads the active automatic rules to price the order
43
+ * summary. A browser that could update `usage_count` or `discount_value` could
44
+ * discount forever, so writes need the same trust.
45
+ */
46
+ exports.MONEY_TABLES = [
47
+ 'teleport_gift_cards',
48
+ 'teleport_gift_card_transactions',
49
+ 'teleport_vouchers',
50
+ 'teleport_voucher_redemptions',
51
+ // The sent-email log keeps the RENDERED message, and a gift-card email
52
+ // carries the full code — protecting the card table while serving its
53
+ // codes from the email log would be no protection at all.
54
+ 'teleport_sent_emails',
55
+ // A live reset token IS the account: whoever reads one sets the password.
56
+ // Only the server-side reset workflows ever read or write the table.
57
+ 'password_reset_tokens',
58
+ // A digital product's files and license keys ARE the product: the order
59
+ // page's server segment mints a download link per paid line, and the
60
+ // download route assigns a key; nothing else reads them.
61
+ 'teleport_product_files',
62
+ 'teleport_license_keys',
63
+ ];
64
+ exports.CUSTOMER_RECORD_TABLES = [
65
+ 'users',
66
+ 'teleport_orders',
67
+ 'teleport_order_items',
68
+ 'teleport_invoices',
69
+ 'teleport_invoice_items',
70
+ 'teleport_events',
71
+ 'teleport_shipments',
72
+ 'teleport_shipment_items',
73
+ 'teleport_withdrawal_requests',
74
+ 'teleport_withdrawal_request_items',
75
+ 'teleport_abandoned_carts',
76
+ 'teleport_cart',
77
+ 'teleport_cart_items',
78
+ 'teleport_favourites',
79
+ // Who subscribed to what and what they downloaded: the buyer's own page reads
80
+ // them through a server segment, the admin through its session.
81
+ 'teleport_subscriptions',
82
+ 'teleport_downloads',
83
+ // A review is public once approved, but the row carries the reviewer's
84
+ // email and the ones still in moderation; the product page reads the
85
+ // approved ones server-side.
86
+ 'teleport_product_reviews',
87
+ // A push subscription is a capability: whoever holds the endpoint and its
88
+ // keys can notify that device. Only the app's push routes read the table.
89
+ 'teleport_push_subscriptions',
90
+ // A comment is public once approved, but the row carries the commenter's
91
+ // email and the comments still waiting for approval; the post page reads
92
+ // the approved ones server-side, public columns only.
93
+ 'teleport_blog_comments',
94
+ // What visitors told the AI assistant, and the merchant's private knowledge
95
+ // base it answers from: the assistant reads them in its own server
96
+ // segments, the admin lists them with its session.
97
+ 'teleport_ai_chat_knowledge_sources',
98
+ 'teleport_ai_chat_documents',
99
+ 'teleport_ai_chat_conversations',
100
+ 'teleport_ai_chat_messages',
101
+ ];
102
+ exports.PROTECTED_TABLES = __spreadArray(__spreadArray([], exports.MONEY_TABLES, true), exports.CUSTOMER_RECORD_TABLES, true);
103
+ exports.WRITE_PROTECTED_TABLES = ['teleport_discounts'];
104
+ /**
105
+ * The auth users table's CREDENTIALS — the password hash and the OAuth
106
+ * provider's tokens (an access or refresh token IS the user's account at the
107
+ * provider). Profile columns stay readable; these never leave the server in a
108
+ * row, whoever asks: the generated admin's users list shows no password either.
109
+ */
110
+ exports.AUTH_CREDENTIAL_COLUMNS = [
111
+ 'password',
112
+ 'access_token',
113
+ 'refresh_token',
114
+ 'id_token',
115
+ 'session_state',
116
+ 'token_type',
117
+ 'scope',
118
+ 'expires_at',
119
+ ];
120
+ /** The table the generated auth reads and writes those credentials in. */
121
+ exports.AUTH_CREDENTIAL_TABLES = ['users'];
122
+ /**
123
+ * The credential names no other table has a reason to use: dropped from the
124
+ * rows of a raw statement too, where a column cannot be traced to its table
125
+ * (`scope` and `expires_at` are ordinary columns elsewhere — a gift card
126
+ * expires).
127
+ */
128
+ var UNAMBIGUOUS_CREDENTIAL_COLUMNS = exports.AUTH_CREDENTIAL_COLUMNS.filter(function (column) { return column !== 'scope' && column !== 'expires_at'; });
129
+ /**
130
+ * A table a browser may read ONLY as a fixed projection of the rows the
131
+ * DATABASE considers live — never whole, never through raw SQL, and never
132
+ * filtered or sorted by a column outside the projection (a filter is an
133
+ * oracle: `usage_count > 100` answers for a column that is never returned).
134
+ *
135
+ * `teleport_discounts` is the merchant's campaign plan: drafts, paused rules,
136
+ * launches scheduled for next month, how often each has been used. The
137
+ * storefront needs none of that; it prices the order summary from the rules
138
+ * that apply right now. Serving exactly those rows is what keeps an
139
+ * unannounced campaign unannounced, and it makes the WINDOW the database's
140
+ * judgement, the same clock that re-prices the order at submit: the storefront
141
+ * prices every row it is served and re-derives nothing from the browser clock,
142
+ * so a disagreement with the server's re-pricing is resolved by re-reading the
143
+ * feed.
144
+ */
145
+ exports.PUBLIC_FEED_TABLES = {
146
+ teleport_discounts: {
147
+ // Exactly what the shared engine normalises a rule from (`__deNormalizeRule`),
148
+ // plus `status`, which the storefront still checks. The window bounds,
149
+ // `description` and `usage_count` are the merchant's, and stay with the
150
+ // merchant.
151
+ columns: [
152
+ 'id',
153
+ 'name',
154
+ 'status',
155
+ 'priority',
156
+ 'discount_type',
157
+ 'discount_value',
158
+ 'applies_to_all_products',
159
+ 'product_ids',
160
+ 'category_ids',
161
+ 'min_order_value',
162
+ 'min_quantity',
163
+ 'first_order_only',
164
+ 'buy_quantity',
165
+ 'get_quantity',
166
+ 'stackable',
167
+ ],
168
+ predicate: "status = 'active' AND (starts_at IS NULL OR starts_at <= NOW()) AND (ends_at IS NULL OR ends_at > NOW())",
169
+ },
170
+ };
171
+ /** The generated back office: its folder in the pages tree and its route prefix. */
172
+ var ADMIN_FOLDER_NAME = 'admin-panel';
173
+ var ADMIN_ROUTE_PREFIX = '/admin';
174
+ /**
175
+ * The roles allowed to read a protected table from a browser: whoever may open
176
+ * the generated admin panel, read off the protection the UIDL records for its
177
+ * folder and pages. A project without an admin panel has no page that binds a
178
+ * money table, so the empty list (server-side callers only) is the right answer.
179
+ */
180
+ var resolveTrustedReaderRoles = function (auth) {
181
+ var roles = new Set();
182
+ if (!auth) {
183
+ return [];
184
+ }
185
+ Object.values(auth.folderProtection || {}).forEach(function (folder) {
186
+ if (folder && folder.folderName === ADMIN_FOLDER_NAME) {
187
+ ;
188
+ (folder.allowedRoles || []).forEach(function (role) { return roles.add(role); });
189
+ }
190
+ });
191
+ Object.values(auth.pageProtection || {}).forEach(function (page) {
192
+ var route = page && typeof page.route === 'string' ? page.route : '';
193
+ if (route === ADMIN_ROUTE_PREFIX || route.startsWith("".concat(ADMIN_ROUTE_PREFIX, "/"))) {
194
+ ;
195
+ (page.allowedRoles || []).forEach(function (role) { return roles.add(role); });
196
+ }
197
+ });
198
+ return Array.from(roles).sort();
199
+ };
200
+ exports.resolveTrustedReaderRoles = resolveTrustedReaderRoles;
201
+ /**
202
+ * ES5 source of the guard, inlined into a generated route. Declares:
203
+ * - `__taIsInternalRequest(req)` — the caller presented the app secret, or
204
+ * is the module's own server-side `fetchData` (`req.__tqServerCall`).
205
+ * - `__taIsRestrictedRequest(req)` — a server-side node that presents the app
206
+ * secret but runs SQL it did not write (the AI data-query node): trusted to
207
+ * run raw SQL, never trusted with the protected tables.
208
+ * - `__taBrowserIsReadOnly(req)` — true for a browser in an app that has an
209
+ * app secret: every server-side caller identifies itself there, so a browser
210
+ * reads through the structured routes only — no raw SQL, no writes.
211
+ * - `__taNormalizeTable(name)` — the bare table a spelling names.
212
+ * - `__taSqlMentionsTable(sql, table)` — the statement names the table as an
213
+ * identifier (bare, double-quoted or schema-qualified; comments and string
214
+ * literals cannot hide or fake a mention).
215
+ * - `__taAssertSqlTextAllowed(sql)` — throws a 403 error when an untrusted
216
+ * caller's raw statement touches a protected table or a feed table, or
217
+ * writes a write-protected one.
218
+ * - `__taPublicFeed(req, tableName)` — the projection an untrusted caller is
219
+ * served of a feed table (`{ columns, predicate }`), or `null` when the
220
+ * caller may read the table as asked (a server-side one) or the table has
221
+ * no feed.
222
+ * - `__taAssertFeedFields(tableName, feed, fields)` — throws a 403 error when
223
+ * a filter or sort field is not one of the feed's columns.
224
+ * - `__taWithoutCredentials(rows, tableName)` — the rows with the auth users
225
+ * table's credential columns removed: all of them for that table's rows,
226
+ * the unambiguous ones for a raw statement's (`tableName` null).
227
+ * - `__taIsCredentialTable(tableName)` — the table holds those credentials.
228
+ * - `__taGuardRead(req, tableName, rawQuery)` — for the per-table read routes:
229
+ * resolves to `null` when the request may proceed, else `{status, message}`.
230
+ * A protected table is readable by an internal caller or by a session whose
231
+ * role is in `trustedReaderRoles`; the session is decoded by the
232
+ * `__tqSessionToken` resolver, which the host route must inline as well.
233
+ */
234
+ var generateTableAccessHelperCode = function (params) {
235
+ return "// GENERATED \u2014 see generateTableAccessHelperCode in\n// @teleporthq/teleport-shared/src/utils/table-access.ts.\n//\n// Tables that ARE money, and tables that decide how much of it is given away.\n// A browser reads the first group only as a trusted role (the generated admin)\n// and writes the second group never; server-side workflow segments present the\n// app secret instead. One list for both data-route families.\nvar __TA_PROTECTED_TABLES = ".concat(JSON.stringify(exports.PROTECTED_TABLES), ";\nvar __TA_WRITE_PROTECTED_TABLES = ").concat(JSON.stringify(exports.WRITE_PROTECTED_TABLES), ";\n// Readable from a browser only as this projection of the rows the database\n// calls live \u2014 see PUBLIC_FEED_TABLES. The per-table routes serve a whole\n// table (and raw SQL), which cannot express a feed, so there they are refused\n// like a protected table.\nvar __TA_PUBLIC_FEED_TABLES = ").concat(JSON.stringify(exports.PUBLIC_FEED_TABLES), ";\nvar __TA_FEED_TABLES = Object.keys(__TA_PUBLIC_FEED_TABLES);\nvar __TA_TRUSTED_READER_ROLES = ").concat(JSON.stringify(params.trustedReaderRoles), ";\nvar __TA_CREDENTIAL_COLUMNS = ").concat(JSON.stringify(exports.AUTH_CREDENTIAL_COLUMNS), ";\nvar __TA_UNAMBIGUOUS_CREDENTIAL_COLUMNS = ").concat(JSON.stringify(UNAMBIGUOUS_CREDENTIAL_COLUMNS), ";\nvar __TA_CREDENTIAL_TABLES = ").concat(JSON.stringify(exports.AUTH_CREDENTIAL_TABLES), ";\nvar __TA_SQL_WRITE_RE = /\\b(?:insert|update|delete|merge|truncate)\\b/i;\n// What a statement can reach without spelling a table's name where this scan\n// can see it: a Unicode-escaped identifier (U&\"\\0075sers\" is `users`), the\n// functions that run SQL text or dump whole tables, schemas or the database\n// (the table name then sits in a string, or is not named at all), and the\n// planner statistics, which hold sampled column values of every table.\nvar __TA_OPAQUE_SQL_RE = /u&\"|\\b(?:query|table|cursor|schema|database)_to_xml\\w*\\s*\\(|\\bts_(?:stat|rewrite)\\s*\\(|\\bdblink\\w*\\s*\\(|\\bpg_read_(?:binary_)?file\\s*\\(|\\blo_(?:import|export|get)\\s*\\(|\\bpg_stat(?:s|istic)\\w*/i;\n\n// Only server code can read NEXTAUTH_SECRET, so a browser cannot forge the\n// header a server segment sends. An in-process call (getStaticProps and the\n// page-load workflows call the handler directly with a synthetic request)\n// marks its request object instead \u2014 a property, never a header, so nothing\n// on the wire can claim it.\nfunction __taPresentsAppSecret(req) {\n var secret = req && req.headers && req.headers['x-internal-data-secret'];\n return !!(secret && process.env.NEXTAUTH_SECRET && secret === process.env.NEXTAUTH_SECRET);\n}\n\nfunction __taIsRestrictedRequest(req) {\n return __taPresentsAppSecret(req) && !!(req.headers && req.headers['x-tq-restricted-sql'] === '1');\n}\n\nfunction __taIsInternalRequest(req) {\n if (req && req.__tqServerCall === true) return true;\n return __taPresentsAppSecret(req) && !__taIsRestrictedRequest(req);\n}\n\n// Generated browser code reads through the structured routes and never sends\n// SQL or a write of its own \u2014 every data node runs server-side and presents\n// the secret. So where a secret exists to tell the two apart, anything else a\n// browser sends is refused whole: no statement scan has to be right about it.\n// An app without one (no authentication, hence no store) keeps the scan.\nfunction __taBrowserIsReadOnly(req) {\n return !!process.env.NEXTAUTH_SECRET && !__taIsInternalRequest(req) && !__taIsRestrictedRequest(req);\n}\n\n// Comments and string literals out, so a table name inside a string neither\n// hides a reference nor fakes one. Quoted identifiers stay, whole: in Postgres\n// they name tables, which is exactly what is being looked for.\n//\n// \u26D4 This is a lexer, not a search: a quote or comment marker inside a quoted\n// identifier (\"x'\", \"--\") is part of the name, a `$` or an `E` inside an\n// identifier (a$b$, ELSE'\u2026') starts neither a dollar quote nor an escape\n// string, and a dollar-quoted body is consumed by its own tag. An UNTERMINATED\n// literal, identifier, comment or dollar quote makes the whole scan fail closed\n// (ok:false): a statement this cleaner cannot read is one it cannot vouch for.\nfunction __taCleanSql(sql) {\n var text = String(sql || '');\n var out = '';\n var i = 0;\n function inIdentifier(at) { return at > 0 && /[A-Za-z0-9_$]/.test(text[at - 1]); }\n while (i < text.length) {\n var ch = text[i];\n var next = text[i + 1];\n if (ch === '-' && next === '-') {\n while (i < text.length && text[i] !== '\\n') i++;\n continue;\n }\n if (ch === '/' && next === '*') {\n i += 2;\n var depth = 1;\n while (i < text.length && depth > 0) {\n if (text[i] === '/' && text[i + 1] === '*') { depth++; i += 2; continue; }\n if (text[i] === '*' && text[i + 1] === '/') { depth--; i += 2; continue; }\n i++;\n }\n if (depth > 0) return { ok: false, text: out };\n out += ' ';\n continue;\n }\n // \"\u2026\" is one identifier token; \"\" inside it is an escaped quote.\n if (ch === '\"') {\n var end = i + 1;\n var closedIdentifier = false;\n while (end < text.length) {\n if (text[end] === '\"' && text[end + 1] === '\"') { end += 2; continue; }\n if (text[end] === '\"') { closedIdentifier = true; break; }\n end++;\n }\n if (!closedIdentifier) return { ok: false, text: out };\n out += text.slice(i, end + 1);\n i = end + 1;\n continue;\n }\n // $tag$ \u2026 $tag$ \u2014 the body is data whatever it holds.\n if (ch === '$' && !inIdentifier(i)) {\n var tagMatch = /^\\$[A-Za-z_][A-Za-z0-9_]*\\$|^\\$\\$/.exec(text.slice(i));\n if (tagMatch) {\n var tag = tagMatch[0];\n var close = text.indexOf(tag, i + tag.length);\n if (close === -1) return { ok: false, text: out };\n i = close + tag.length;\n out += ' ';\n continue;\n }\n }\n // E'\u2026' understands backslash escapes; a plain '\u2026' doubles the quote.\n if (ch === \"'\" || ((ch === 'E' || ch === 'e') && next === \"'\" && !inIdentifier(i))) {\n var escapes = ch !== \"'\";\n if (escapes) i++;\n i++;\n var closed = false;\n while (i < text.length) {\n if (escapes && text[i] === '\\\\') { i += 2; continue; }\n if (text[i] === \"'\" && text[i + 1] === \"'\") { i += 2; continue; }\n if (text[i] === \"'\") { i++; closed = true; break; }\n i++;\n }\n if (!closed) return { ok: false, text: out };\n out += ' ';\n continue;\n }\n out += ch;\n i++;\n }\n return { ok: true, text: out };\n}\n\nfunction __taNormalizeTable(tableName) {\n var name = String(tableName || '').trim().toLowerCase();\n var parts = name.split('.');\n return parts[parts.length - 1].replace(/\"/g, '');\n}\n\n// An unreadable statement, or one that can reach a table without naming it,\n// counts as mentioning EVERY protected table: fail closed rather than let a\n// spelling this scan cannot see decide it is harmless.\nfunction __taSqlMentionsTable(sql, table) {\n var cleaned = __taCleanSql(sql);\n if (!cleaned.ok || __TA_OPAQUE_SQL_RE.test(cleaned.text)) return true;\n var pattern = new RegExp('(?:^|[^A-Za-z0-9_])\"?' + table + '\"?(?![A-Za-z0-9_])', 'i');\n return pattern.test(cleaned.text);\n}\n\nfunction __taIsCredentialTable(tableName) {\n return __TA_CREDENTIAL_TABLES.indexOf(__taNormalizeTable(tableName)) !== -1;\n}\n\n// Credentials never travel in a row: a column is dropped by name, however the\n// caller spelled it in its projection.\nfunction __taWithoutCredentials(rows, tableName) {\n if (!Array.isArray(rows)) return rows;\n var dropped = tableName && __taIsCredentialTable(tableName)\n ? __TA_CREDENTIAL_COLUMNS\n : tableName ? [] : __TA_UNAMBIGUOUS_CREDENTIAL_COLUMNS;\n if (dropped.length === 0) return rows;\n return rows.map(function(row) {\n if (!row || typeof row !== 'object') return row;\n var copy = {};\n Object.keys(row).forEach(function(key) {\n if (dropped.indexOf(String(key).toLowerCase()) === -1) copy[key] = row[key];\n });\n return copy;\n });\n}\n\nfunction __taForbid(table) {\n var err = new Error('Forbidden: ' + table + ' is only accessible to server-side workflow nodes');\n err.status = 403;\n throw err;\n}\n\nfunction __taAssertSqlTextAllowed(sql) {\n var text = String(sql || '');\n // A statement can hand back a whole row (`SELECT u FROM users u`,\n // `row_to_json(u)`) without naming a credential column, so the table itself\n // is out of reach of anything but the server's own calls.\n for (var ci = 0; ci < __TA_CREDENTIAL_TABLES.length; ci++) {\n if (__taSqlMentionsTable(text, __TA_CREDENTIAL_TABLES[ci])) __taForbid(__TA_CREDENTIAL_TABLES[ci]);\n }\n for (var pi = 0; pi < __TA_PROTECTED_TABLES.length; pi++) {\n if (__taSqlMentionsTable(text, __TA_PROTECTED_TABLES[pi])) __taForbid(__TA_PROTECTED_TABLES[pi]);\n }\n // A feed table has exactly one browser-readable shape, and a statement the\n // caller wrote is not it.\n for (var fi = 0; fi < __TA_FEED_TABLES.length; fi++) {\n if (__taSqlMentionsTable(text, __TA_FEED_TABLES[fi])) __taForbid(__TA_FEED_TABLES[fi]);\n }\n var cleaned = __taCleanSql(text);\n // Unreadable, or a write: either way the write-protected tables are refused.\n if (cleaned.ok && !__TA_SQL_WRITE_RE.test(cleaned.text)) return;\n for (var wi = 0; wi < __TA_WRITE_PROTECTED_TABLES.length; wi++) {\n if (__taSqlMentionsTable(text, __TA_WRITE_PROTECTED_TABLES[wi])) __taForbid(__TA_WRITE_PROTECTED_TABLES[wi]);\n }\n}\n\nfunction __taRoleOf(token) {\n if (!token || typeof token !== 'object') return null;\n if (typeof token.role === 'string') return token.role;\n if (typeof token.roleName === 'string') return token.roleName;\n if (Array.isArray(token.roles) && typeof token.roles[0] === 'string') return token.roles[0];\n return null;\n}\n\n// The tables a read of `tableName` (or the raw statement) touches that this\n// route family may not serve to a browser: the protected ones, and the feed\n// tables, whose one browser-readable projection lives on the data API instead.\nvar __TA_ROUTE_PROTECTED_TABLES = __TA_PROTECTED_TABLES.concat(__TA_FEED_TABLES);\n\nfunction __taProtectedTablesRead(tableName, rawQuery) {\n var touched = [];\n var bare = __taNormalizeTable(tableName);\n if (__TA_ROUTE_PROTECTED_TABLES.indexOf(bare) !== -1) touched.push(bare);\n if (typeof rawQuery === 'string' && rawQuery.length > 0) {\n for (var i = 0; i < __TA_ROUTE_PROTECTED_TABLES.length; i++) {\n if (touched.indexOf(__TA_ROUTE_PROTECTED_TABLES[i]) === -1 && __taSqlMentionsTable(rawQuery, __TA_ROUTE_PROTECTED_TABLES[i])) {\n touched.push(__TA_ROUTE_PROTECTED_TABLES[i]);\n }\n }\n }\n return touched;\n}\n\n// The projection an untrusted caller gets of a feed table, or null when the\n// table has no feed or the caller is a server-side one reading it whole.\nfunction __taPublicFeed(req, tableName) {\n if (__taIsInternalRequest(req)) return null;\n var feed = __TA_PUBLIC_FEED_TABLES[__taNormalizeTable(tableName)];\n return feed || null;\n}\n\n// A feed is filtered and sorted only by the columns it serves: a condition on\n// any other column (or an expression over one) would answer for it.\nfunction __taAssertFeedFields(tableName, feed, fields) {\n for (var i = 0; i < fields.length; i++) {\n if (!fields[i]) continue;\n var column = String(fields[i]).trim().replace(/\"/g, '').toLowerCase();\n if (feed.columns.indexOf(column) === -1) __taForbid(__taNormalizeTable(tableName) + '.' + fields[i]);\n }\n}\n\n// null when the read may proceed, else { status, message }.\nasync function __taGuardRead(req, tableName, rawQuery) {\n if (typeof rawQuery === 'string' && rawQuery.length > 0 && __taBrowserIsReadOnly(req)) {\n return { status: 403, message: 'Forbidden: raw queries are only available to server-side calls' };\n }\n var touched = __taProtectedTablesRead(tableName, rawQuery);\n if (touched.length === 0) return null;\n if (__taIsInternalRequest(req)) return null;\n var token = null;\n try {\n token = await __tqSessionToken(req);\n } catch (e) {\n token = null;\n }\n if (!token) return { status: 401, message: 'Unauthenticated' };\n var role = __taRoleOf(token);\n if (!role || __TA_TRUSTED_READER_ROLES.indexOf(role) === -1) {\n return { status: 403, message: 'Forbidden: ' + touched[0] + ' is only readable by the store administrators' };\n }\n return null;\n}\n");
236
+ };
237
+ exports.generateTableAccessHelperCode = generateTableAccessHelperCode;
238
+ //# sourceMappingURL=table-access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-access.js","sourceRoot":"","sources":["../../../src/utils/table-access.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACU,QAAA,YAAY,GAA0B;IACjD,qBAAqB;IACrB,iCAAiC;IACjC,mBAAmB;IACnB,8BAA8B;IAC9B,uEAAuE;IACvE,sEAAsE;IACtE,0DAA0D;IAC1D,sBAAsB;IACtB,0EAA0E;IAC1E,qEAAqE;IACrE,uBAAuB;IACvB,wEAAwE;IACxE,qEAAqE;IACrE,yDAAyD;IACzD,wBAAwB;IACxB,uBAAuB;CACxB,CAAA;AAEY,QAAA,sBAAsB,GAA0B;IAC3D,OAAO;IACP,iBAAiB;IACjB,sBAAsB;IACtB,mBAAmB;IACnB,wBAAwB;IACxB,iBAAiB;IACjB,oBAAoB;IACpB,yBAAyB;IACzB,8BAA8B;IAC9B,mCAAmC;IACnC,0BAA0B;IAC1B,eAAe;IACf,qBAAqB;IACrB,qBAAqB;IACrB,8EAA8E;IAC9E,gEAAgE;IAChE,wBAAwB;IACxB,oBAAoB;IACpB,uEAAuE;IACvE,qEAAqE;IACrE,6BAA6B;IAC7B,0BAA0B;IAC1B,0EAA0E;IAC1E,0EAA0E;IAC1E,6BAA6B;IAC7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8BAAsB,CAAC,wTAK1C,IAAI,CAAC,SAAS,CAAC,0BAAkB,CAAC,8GAEhC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,kBAAkB,CAAC,8CAC3C,IAAI,CAAC,SAAS,CAAC,+BAAuB,CAAC,0DAC3B,IAAI,CAAC,SAAS,CAAC,8BAA8B,CAAC,6CAC3D,IAAI,CAAC,SAAS,CAAC,8BAAsB,CAAC,29VA6PpE,CAAA;AACD,CAAC,CAAA;AAnRY,QAAA,6BAA6B,iCAmRzC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The names the published app's service worker, its push routes and the
3
+ * workflow nodes that use them have to agree on. The node handlers are
4
+ * serialized into the generated app as source text, so they interpolate these
5
+ * values at generation time rather than importing them.
6
+ */
7
+ /** The browsers that agreed to receive the app's push notifications, in the project database. */
8
+ export declare const SUBSCRIPTIONS_TABLE = "teleport_push_subscriptions";
9
+ /** Public: a browser saves (POST) or forgets (DELETE) its own subscription here. */
10
+ export declare const SUBSCRIPTIONS_ROUTE = "/api/push/subscriptions";
11
+ /** Internal: only the app's own server code may send a notification through it. */
12
+ export declare const SEND_ROUTE = "/api/push/send";
13
+ /** What a visitor-facing push step reports when the project has no push keys or no worker. */
14
+ export declare const NOT_CONFIGURED_MESSAGE = "Push notifications are not set up for this site.";
15
+ export declare const PUBLIC_KEY_ENV = "WEB_PUSH_VAPID_PUBLIC_KEY";
16
+ /** Filled at deploy from the project secret of the same name. */
17
+ export declare const PRIVATE_KEY_ENV = "WEB_PUSH_VAPID_PRIVATE_KEY";
18
+ /**
19
+ * The send route accepts a request only when this header carries an HMAC of
20
+ * `SEND_TOKEN_PURPOSE` keyed with the VAPID private key — a value only the
21
+ * app's own server holds, so no extra secret has to be provisioned.
22
+ */
23
+ export declare const SEND_TOKEN_HEADER = "x-teleport-push-token";
24
+ export declare const SEND_TOKEN_PURPOSE = "teleport-web-push-send";
25
+ /**
26
+ * The page-side API the generated service-worker module publishes on `window`.
27
+ * A workflow node handler has no module scope, so a global is the only way it
28
+ * can reach the worker registration.
29
+ */
30
+ export declare const SERVICE_WORKER_GLOBAL = "__teleportServiceWorker";
31
+ export declare const SUBSCRIBE_NODE_TYPE = "browser-subscribe-to-push";
32
+ export declare const UNSUBSCRIBE_NODE_TYPE = "browser-unsubscribe-from-push";
33
+ export declare const GET_SUBSCRIPTION_NODE_TYPE = "browser-get-push-subscription";
34
+ export declare const SHOW_NOTIFICATION_NODE_TYPE = "browser-show-notification";
35
+ export declare const SEND_NODE_TYPE = "push-send-notification";
36
+ /** Nodes that manage the visitor's push subscription and therefore need the push routes. */
37
+ export declare const PUSH_NODE_TYPES: ReadonlyArray<string>;
38
+ /**
39
+ * Nodes that need a service worker on the page: push itself, and on-page
40
+ * notifications, which Chrome on Android only shows through a worker.
41
+ */
42
+ export declare const SERVICE_WORKER_NODE_TYPES: ReadonlyArray<string>;
43
+ //# sourceMappingURL=web-push.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-push.d.ts","sourceRoot":"","sources":["../../../src/utils/web-push.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,iGAAiG;AACjG,eAAO,MAAM,mBAAmB,gCAAgC,CAAA;AAEhE,oFAAoF;AACpF,eAAO,MAAM,mBAAmB,4BAA4B,CAAA;AAE5D,mFAAmF;AACnF,eAAO,MAAM,UAAU,mBAAmB,CAAA;AAE1C,8FAA8F;AAC9F,eAAO,MAAM,sBAAsB,qDAAqD,CAAA;AAExF,eAAO,MAAM,cAAc,8BAA8B,CAAA;AAEzD,iEAAiE;AACjE,eAAO,MAAM,eAAe,+BAA+B,CAAA;AAE3D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,0BAA0B,CAAA;AACxD,eAAO,MAAM,kBAAkB,2BAA2B,CAAA;AAE1D;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,4BAA4B,CAAA;AAE9D,eAAO,MAAM,mBAAmB,8BAA8B,CAAA;AAC9D,eAAO,MAAM,qBAAqB,kCAAkC,CAAA;AACpE,eAAO,MAAM,0BAA0B,kCAAkC,CAAA;AACzE,eAAO,MAAM,2BAA2B,8BAA8B,CAAA;AACtE,eAAO,MAAM,cAAc,2BAA2B,CAAA;AAEtD,4FAA4F;AAC5F,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,MAAM,CAKjD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,aAAa,CAAC,MAAM,CAG3D,CAAA"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ /**
3
+ * The names the published app's service worker, its push routes and the
4
+ * workflow nodes that use them have to agree on. The node handlers are
5
+ * serialized into the generated app as source text, so they interpolate these
6
+ * values at generation time rather than importing them.
7
+ */
8
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
9
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
10
+ if (ar || !(i in from)) {
11
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
12
+ ar[i] = from[i];
13
+ }
14
+ }
15
+ return to.concat(ar || Array.prototype.slice.call(from));
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.SERVICE_WORKER_NODE_TYPES = exports.PUSH_NODE_TYPES = exports.SEND_NODE_TYPE = exports.SHOW_NOTIFICATION_NODE_TYPE = exports.GET_SUBSCRIPTION_NODE_TYPE = exports.UNSUBSCRIBE_NODE_TYPE = exports.SUBSCRIBE_NODE_TYPE = exports.SERVICE_WORKER_GLOBAL = exports.SEND_TOKEN_PURPOSE = exports.SEND_TOKEN_HEADER = exports.PRIVATE_KEY_ENV = exports.PUBLIC_KEY_ENV = exports.NOT_CONFIGURED_MESSAGE = exports.SEND_ROUTE = exports.SUBSCRIPTIONS_ROUTE = exports.SUBSCRIPTIONS_TABLE = void 0;
19
+ /** The browsers that agreed to receive the app's push notifications, in the project database. */
20
+ exports.SUBSCRIPTIONS_TABLE = 'teleport_push_subscriptions';
21
+ /** Public: a browser saves (POST) or forgets (DELETE) its own subscription here. */
22
+ exports.SUBSCRIPTIONS_ROUTE = '/api/push/subscriptions';
23
+ /** Internal: only the app's own server code may send a notification through it. */
24
+ exports.SEND_ROUTE = '/api/push/send';
25
+ /** What a visitor-facing push step reports when the project has no push keys or no worker. */
26
+ exports.NOT_CONFIGURED_MESSAGE = 'Push notifications are not set up for this site.';
27
+ exports.PUBLIC_KEY_ENV = 'WEB_PUSH_VAPID_PUBLIC_KEY';
28
+ /** Filled at deploy from the project secret of the same name. */
29
+ exports.PRIVATE_KEY_ENV = 'WEB_PUSH_VAPID_PRIVATE_KEY';
30
+ /**
31
+ * The send route accepts a request only when this header carries an HMAC of
32
+ * `SEND_TOKEN_PURPOSE` keyed with the VAPID private key — a value only the
33
+ * app's own server holds, so no extra secret has to be provisioned.
34
+ */
35
+ exports.SEND_TOKEN_HEADER = 'x-teleport-push-token';
36
+ exports.SEND_TOKEN_PURPOSE = 'teleport-web-push-send';
37
+ /**
38
+ * The page-side API the generated service-worker module publishes on `window`.
39
+ * A workflow node handler has no module scope, so a global is the only way it
40
+ * can reach the worker registration.
41
+ */
42
+ exports.SERVICE_WORKER_GLOBAL = '__teleportServiceWorker';
43
+ exports.SUBSCRIBE_NODE_TYPE = 'browser-subscribe-to-push';
44
+ exports.UNSUBSCRIBE_NODE_TYPE = 'browser-unsubscribe-from-push';
45
+ exports.GET_SUBSCRIPTION_NODE_TYPE = 'browser-get-push-subscription';
46
+ exports.SHOW_NOTIFICATION_NODE_TYPE = 'browser-show-notification';
47
+ exports.SEND_NODE_TYPE = 'push-send-notification';
48
+ /** Nodes that manage the visitor's push subscription and therefore need the push routes. */
49
+ exports.PUSH_NODE_TYPES = [
50
+ exports.SUBSCRIBE_NODE_TYPE,
51
+ exports.UNSUBSCRIBE_NODE_TYPE,
52
+ exports.GET_SUBSCRIPTION_NODE_TYPE,
53
+ exports.SEND_NODE_TYPE,
54
+ ];
55
+ /**
56
+ * Nodes that need a service worker on the page: push itself, and on-page
57
+ * notifications, which Chrome on Android only shows through a worker.
58
+ */
59
+ exports.SERVICE_WORKER_NODE_TYPES = __spreadArray(__spreadArray([], exports.PUSH_NODE_TYPES, true), [
60
+ exports.SHOW_NOTIFICATION_NODE_TYPE,
61
+ ], false);
62
+ //# sourceMappingURL=web-push.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-push.js","sourceRoot":"","sources":["../../../src/utils/web-push.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;AAEH,iGAAiG;AACpF,QAAA,mBAAmB,GAAG,6BAA6B,CAAA;AAEhE,oFAAoF;AACvE,QAAA,mBAAmB,GAAG,yBAAyB,CAAA;AAE5D,mFAAmF;AACtE,QAAA,UAAU,GAAG,gBAAgB,CAAA;AAE1C,8FAA8F;AACjF,QAAA,sBAAsB,GAAG,kDAAkD,CAAA;AAE3E,QAAA,cAAc,GAAG,2BAA2B,CAAA;AAEzD,iEAAiE;AACpD,QAAA,eAAe,GAAG,4BAA4B,CAAA;AAE3D;;;;GAIG;AACU,QAAA,iBAAiB,GAAG,uBAAuB,CAAA;AAC3C,QAAA,kBAAkB,GAAG,wBAAwB,CAAA;AAE1D;;;;GAIG;AACU,QAAA,qBAAqB,GAAG,yBAAyB,CAAA;AAEjD,QAAA,mBAAmB,GAAG,2BAA2B,CAAA;AACjD,QAAA,qBAAqB,GAAG,+BAA+B,CAAA;AACvD,QAAA,0BAA0B,GAAG,+BAA+B,CAAA;AAC5D,QAAA,2BAA2B,GAAG,2BAA2B,CAAA;AACzD,QAAA,cAAc,GAAG,wBAAwB,CAAA;AAEtD,4FAA4F;AAC/E,QAAA,eAAe,GAA0B;IACpD,2BAAmB;IACnB,6BAAqB;IACrB,kCAA0B;IAC1B,sBAAc;CACf,CAAA;AAED;;;GAGG;AACU,QAAA,yBAAyB,mCACjC,uBAAe;IAClB,mCAA2B;UAC5B"}
@@ -15,11 +15,19 @@ import * as StorefrontTax from './utils/storefront-tax';
15
15
  import * as ProductDiscounts from './utils/product-discounts';
16
16
  import * as ProductRatings from './utils/product-ratings';
17
17
  import * as RegionalPricing from './utils/regional-pricing';
18
+ import * as DiscountEngine from './utils/discount-engine';
19
+ import * as ProductOptions from './utils/product-options';
20
+ import * as CartLinePricing from './utils/cart-line-pricing';
21
+ import * as CartCurrency from './utils/cart-currency';
22
+ import * as TableAccess from './utils/table-access';
23
+ import * as SessionCookieResolver from './utils/session-cookie-resolver';
24
+ import * as SubscriptionAccess from './utils/subscription-access';
18
25
  import * as FontPreconnect from './utils/font-preconnect';
19
26
  import * as EmailDate from './utils/email-date';
20
27
  import * as RichTextEmbeds from './utils/rich-text-embeds';
21
28
  import * as RichTextEmbedsCodegen from './utils/rich-text-embeds-codegen';
22
29
  import * as DataCache from './cache';
23
30
  import * as PageRevalidate from './page-revalidate';
24
- export { Constants, StringUtils, UIDLUtils, GenericUtils, LocalImports, JSIdentifiers, ASTScope, ASTStatementOrder, ASTEffectCleanup, RoutePaths, LayoutTopology, HtmlContentModel, StyleDeclarations, StorefrontTax, ProductDiscounts, ProductRatings, RegionalPricing, FontPreconnect, EmailDate, RichTextEmbeds, RichTextEmbedsCodegen, DataCache, PageRevalidate, };
31
+ import * as WebPush from './utils/web-push';
32
+ export { Constants, StringUtils, UIDLUtils, GenericUtils, LocalImports, JSIdentifiers, ASTScope, ASTStatementOrder, ASTEffectCleanup, RoutePaths, LayoutTopology, HtmlContentModel, StyleDeclarations, StorefrontTax, ProductDiscounts, ProductRatings, RegionalPricing, DiscountEngine, ProductOptions, CartLinePricing, CartCurrency, TableAccess, SessionCookieResolver, SubscriptionAccess, FontPreconnect, EmailDate, RichTextEmbeds, RichTextEmbedsCodegen, DataCache, PageRevalidate, WebPush, };
25
33
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA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AA;AACzD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,cAAc,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,qBAAqB,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,SAAS,MAAM,SAAS,CAAA;AACpC,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAA;AACnD,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAE3C,OAAO,EACL,SAAS,EACT,WAAW,EACX,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,OAAO,GACR,CAAA"}
package/dist/esm/index.js CHANGED
@@ -15,11 +15,19 @@ import * as StorefrontTax from './utils/storefront-tax';
15
15
  import * as ProductDiscounts from './utils/product-discounts';
16
16
  import * as ProductRatings from './utils/product-ratings';
17
17
  import * as RegionalPricing from './utils/regional-pricing';
18
+ import * as DiscountEngine from './utils/discount-engine';
19
+ import * as ProductOptions from './utils/product-options';
20
+ import * as CartLinePricing from './utils/cart-line-pricing';
21
+ import * as CartCurrency from './utils/cart-currency';
22
+ import * as TableAccess from './utils/table-access';
23
+ import * as SessionCookieResolver from './utils/session-cookie-resolver';
24
+ import * as SubscriptionAccess from './utils/subscription-access';
18
25
  import * as FontPreconnect from './utils/font-preconnect';
19
26
  import * as EmailDate from './utils/email-date';
20
27
  import * as RichTextEmbeds from './utils/rich-text-embeds';
21
28
  import * as RichTextEmbedsCodegen from './utils/rich-text-embeds-codegen';
22
29
  import * as DataCache from './cache';
23
30
  import * as PageRevalidate from './page-revalidate';
24
- export { Constants, StringUtils, UIDLUtils, GenericUtils, LocalImports, JSIdentifiers, ASTScope, ASTStatementOrder, ASTEffectCleanup, RoutePaths, LayoutTopology, HtmlContentModel, StyleDeclarations, StorefrontTax, ProductDiscounts, ProductRatings, RegionalPricing, FontPreconnect, EmailDate, RichTextEmbeds, RichTextEmbedsCodegen, DataCache, PageRevalidate, };
31
+ import * as WebPush from './utils/web-push';
32
+ export { Constants, StringUtils, UIDLUtils, GenericUtils, LocalImports, JSIdentifiers, ASTScope, ASTStatementOrder, ASTEffectCleanup, RoutePaths, LayoutTopology, HtmlContentModel, StyleDeclarations, StorefrontTax, ProductDiscounts, ProductRatings, RegionalPricing, DiscountEngine, ProductOptions, CartLinePricing, CartCurrency, TableAccess, SessionCookieResolver, SubscriptionAccess, FontPreconnect, EmailDate, RichTextEmbeds, RichTextEmbedsCodegen, DataCache, PageRevalidate, WebPush, };
25
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,iBAAiB,MAAM,6BAA6B,CAAA;AAChE,OAAO,KAAK,gBAAgB,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,gBAAgB,MAAM,4BAA4B,CAAA;AA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