@endora-commerce/contracts 0.105.0 → 0.107.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin-contributions.d.ts +37 -6
- package/dist/admin-contributions.d.ts.map +1 -1
- package/dist/admin-contributions.js +37 -6
- package/dist/admin-contributions.js.map +1 -1
- package/dist/admin-roles.d.ts +32 -2
- package/dist/admin-roles.d.ts.map +1 -1
- package/dist/admin-roles.js +21 -1
- package/dist/admin-roles.js.map +1 -1
- package/dist/admin-search.d.ts +655 -0
- package/dist/admin-search.d.ts.map +1 -0
- package/dist/admin-search.js +179 -0
- package/dist/admin-search.js.map +1 -0
- package/dist/analytics.d.ts +5 -0
- package/dist/analytics.d.ts.map +1 -1
- package/dist/analytics.js +8 -0
- package/dist/analytics.js.map +1 -1
- package/dist/api-keys.d.ts +6 -0
- package/dist/api-keys.d.ts.map +1 -1
- package/dist/api-keys.js +5 -0
- package/dist/api-keys.js.map +1 -1
- package/dist/assets-library.d.ts +102 -0
- package/dist/assets-library.d.ts.map +1 -1
- package/dist/assets-library.js +89 -0
- package/dist/assets-library.js.map +1 -1
- package/dist/auth.d.ts +20 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +20 -0
- package/dist/auth.js.map +1 -1
- package/dist/blog.d.ts +1 -1
- package/dist/carts.d.ts +21 -6
- package/dist/carts.d.ts.map +1 -1
- package/dist/catalog.d.ts +58 -6
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +31 -0
- package/dist/catalog.js.map +1 -1
- package/dist/cms.d.ts +183 -3
- package/dist/cms.d.ts.map +1 -1
- package/dist/cms.js +132 -1
- package/dist/cms.js.map +1 -1
- package/dist/comparisons.d.ts +73 -0
- package/dist/comparisons.d.ts.map +1 -1
- package/dist/comparisons.js +22 -0
- package/dist/comparisons.js.map +1 -1
- package/dist/credentials.d.ts +23 -0
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +24 -0
- package/dist/credentials.js.map +1 -1
- package/dist/crm.d.ts +1 -1
- package/dist/custom-fields.d.ts +3 -3
- package/dist/customer-accounts.d.ts +92 -2
- package/dist/customer-accounts.d.ts.map +1 -1
- package/dist/document-templates.d.ts +1192 -0
- package/dist/document-templates.d.ts.map +1 -0
- package/dist/document-templates.js +472 -0
- package/dist/document-templates.js.map +1 -0
- package/dist/document-values.d.ts +156 -0
- package/dist/document-values.d.ts.map +1 -0
- package/dist/document-values.js +208 -0
- package/dist/document-values.js.map +1 -0
- package/dist/errors.d.ts +98 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +121 -0
- package/dist/errors.js.map +1 -1
- package/dist/import-export.d.ts +11 -0
- package/dist/import-export.d.ts.map +1 -1
- package/dist/import-export.js +9 -0
- package/dist/import-export.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/invoice-ledger.d.ts +6 -6
- package/dist/invoices.d.ts +88 -0
- package/dist/invoices.d.ts.map +1 -1
- package/dist/invoices.js +12 -0
- package/dist/invoices.js.map +1 -1
- package/dist/mfa.d.ts +20 -0
- package/dist/mfa.d.ts.map +1 -1
- package/dist/modules.d.ts +21 -10
- package/dist/modules.d.ts.map +1 -1
- package/dist/newsletter.d.ts +2 -0
- package/dist/newsletter.d.ts.map +1 -1
- package/dist/newsletter.js +4 -0
- package/dist/newsletter.js.map +1 -1
- package/dist/orders.d.ts +32 -1
- package/dist/orders.d.ts.map +1 -1
- package/dist/orders.js +33 -17
- package/dist/orders.js.map +1 -1
- package/dist/organizations.d.ts +78 -0
- package/dist/organizations.d.ts.map +1 -1
- package/dist/organizations.js +54 -0
- package/dist/organizations.js.map +1 -1
- package/dist/payment-methods.d.ts +2 -2
- package/dist/price-lists.d.ts +491 -2
- package/dist/price-lists.d.ts.map +1 -1
- package/dist/price-lists.js +255 -0
- package/dist/price-lists.js.map +1 -1
- package/dist/product-feeds.d.ts +13 -13
- package/dist/prompt-actions.d.ts +25 -6
- package/dist/prompt-actions.d.ts.map +1 -1
- package/dist/prompt-actions.js +17 -1
- package/dist/prompt-actions.js.map +1 -1
- package/dist/pwa.d.ts +25 -0
- package/dist/pwa.d.ts.map +1 -1
- package/dist/pwa.js +38 -0
- package/dist/pwa.js.map +1 -1
- package/dist/quote-requests.d.ts +633 -8
- package/dist/quote-requests.d.ts.map +1 -1
- package/dist/quote-requests.js +365 -2
- package/dist/quote-requests.js.map +1 -1
- package/dist/sales-channels.d.ts +46 -0
- package/dist/sales-channels.d.ts.map +1 -1
- package/dist/sales-channels.js +40 -0
- package/dist/sales-channels.js.map +1 -1
- package/dist/saved-list-views.d.ts +140 -0
- package/dist/saved-list-views.d.ts.map +1 -0
- package/dist/saved-list-views.js +108 -0
- package/dist/saved-list-views.js.map +1 -0
- package/dist/search.d.ts +6 -0
- package/dist/search.d.ts.map +1 -1
- package/dist/seo.d.ts +324 -0
- package/dist/seo.d.ts.map +1 -1
- package/dist/seo.js +303 -0
- package/dist/seo.js.map +1 -1
- package/dist/settings.d.ts +19 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +18 -0
- package/dist/settings.js.map +1 -1
- package/dist/shipping-methods.d.ts +2 -2
- package/package.json +1 -1
package/dist/seo.d.ts
CHANGED
|
@@ -94,6 +94,330 @@ export declare const sitemapChannelListResponseSchema: z.ZodObject<{
|
|
|
94
94
|
}, z.core.$strip>>;
|
|
95
95
|
}, z.core.$strip>;
|
|
96
96
|
export type SitemapChannelListResponse = z.infer<typeof sitemapChannelListResponseSchema>;
|
|
97
|
+
/**
|
|
98
|
+
* A sales channel's default robots policy, as the storefront reads it from
|
|
99
|
+
* `GET /api/v1/storefront/seo/robots-policy`.
|
|
100
|
+
*
|
|
101
|
+
* Two booleans and nothing else. The operator's choice is stored by `seo` as a
|
|
102
|
+
* token (`NOINDEX, FOLLOW` …); that spelling is the module's own and never
|
|
103
|
+
* crosses the wire, so a consumer branches on `index` and `follow` and the
|
|
104
|
+
* stored vocabulary can change without a storefront noticing.
|
|
105
|
+
*
|
|
106
|
+
* **Strict about what it reads, tolerant of what it does not know.** `index`
|
|
107
|
+
* and `follow` must both be present and must both be booleans: a storefront
|
|
108
|
+
* validates the answer against this schema and treats a body that fails it as
|
|
109
|
+
* unreadable, and a policy with half of it missing is not one to guess at.
|
|
110
|
+
*
|
|
111
|
+
* A member this schema does not name is **dropped, not refused**. A storefront
|
|
112
|
+
* is deployed separately from its backend and is usually the older of the two;
|
|
113
|
+
* were an unknown member a failure, the first backend release to add a field
|
|
114
|
+
* here would make every storefront already in the field read the answer as
|
|
115
|
+
* unreadable — and a freshly started one would then serve a `noindex` channel
|
|
116
|
+
* with no directive at all, with nothing to say why. Additive changes to this
|
|
117
|
+
* response are therefore safe by construction, and a consumer never sees a
|
|
118
|
+
* member it was not written for.
|
|
119
|
+
*/
|
|
120
|
+
export declare const storefrontRobotsPolicySchema: z.ZodObject<{
|
|
121
|
+
index: z.ZodBoolean;
|
|
122
|
+
follow: z.ZodBoolean;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
export type StorefrontRobotsPolicy = z.infer<typeof storefrontRobotsPolicySchema>;
|
|
125
|
+
export declare const storefrontRobotsPolicyResponseSchema: z.ZodObject<{
|
|
126
|
+
data: z.ZodObject<{
|
|
127
|
+
index: z.ZodBoolean;
|
|
128
|
+
follow: z.ZodBoolean;
|
|
129
|
+
}, z.core.$strip>;
|
|
130
|
+
}, z.core.$strip>;
|
|
131
|
+
export type StorefrontRobotsPolicyResponse = z.infer<typeof storefrontRobotsPolicyResponseSchema>;
|
|
132
|
+
/**
|
|
133
|
+
* The most an operator may save as custom `robots.txt` instructions or as
|
|
134
|
+
* additional `llms.txt` content, per sales channel: 64 KiB of UTF-8.
|
|
135
|
+
*
|
|
136
|
+
* **Bytes, not characters** — it bounds the file a crawler downloads, and one
|
|
137
|
+
* character is up to four bytes. The `seo` module refuses a larger text when
|
|
138
|
+
* it is saved. Search engines read the first 500 KiB of a `robots.txt`; the
|
|
139
|
+
* system-generated rules are under 1 KiB, so the whole file stays well inside
|
|
140
|
+
* that.
|
|
141
|
+
*/
|
|
142
|
+
export declare const CRAWLER_TEXT_MAX_BYTES = 65536;
|
|
143
|
+
/** In `unreadable`: the channel's default robots — `index` and `follow` — is not known. */
|
|
144
|
+
export declare const CRAWLER_FILES_UNREADABLE_POLICY = "policy";
|
|
145
|
+
/** In `unreadable`: the channel's additional `llms.txt` content is not known. */
|
|
146
|
+
export declare const CRAWLER_FILES_UNREADABLE_LLMS_TXT = "llmsTxtAdditional";
|
|
147
|
+
/**
|
|
148
|
+
* What a sales channel's crawler files are built from, as the storefront reads
|
|
149
|
+
* it from `GET /api/v1/storefront/seo/crawler-files`.
|
|
150
|
+
*
|
|
151
|
+
* The two texts are the values resolved for the channel — its own, else the
|
|
152
|
+
* all-channels value, else empty — **exactly as stored**: the backend changes
|
|
153
|
+
* no character of them, line breaks included. What a served file does with
|
|
154
|
+
* them is {@link composeCrawlerFile}'s to say.
|
|
155
|
+
*
|
|
156
|
+
* `index` and `follow` repeat the robots policy so that a file whose existence
|
|
157
|
+
* depends on it needs one read rather than two.
|
|
158
|
+
*
|
|
159
|
+
* ## `unreadable` — the parts of the answer fail apart
|
|
160
|
+
*
|
|
161
|
+
* `robots.txt` reads the texts and never the policy; `llms.txt` reads all of
|
|
162
|
+
* it. Were one unreadable stored value to fail the whole answer, a channel
|
|
163
|
+
* whose *Default robots* row holds a value nobody can interpret would lose its
|
|
164
|
+
* `robots.txt` — a file that row has no say in. So the backend answers `200`
|
|
165
|
+
* and **names** what it could not read:
|
|
166
|
+
*
|
|
167
|
+
* * {@link CRAWLER_FILES_UNREADABLE_POLICY} — `index` and `follow` are then
|
|
168
|
+
* both `false`, the restrictive reading, and mean "not known";
|
|
169
|
+
* * {@link CRAWLER_FILES_UNREADABLE_LLMS_TXT} — `llmsTxtAdditional` is then
|
|
170
|
+
* `''` and means "not known".
|
|
171
|
+
*
|
|
172
|
+
* A file that needs a named member treats it as unknown and is not served; a
|
|
173
|
+
* file that does not is unaffected. The member is optional and additive: a
|
|
174
|
+
* backend older than it never sends it (it failed the whole answer instead),
|
|
175
|
+
* and a storefront older than it ignores it — and reads neither of the two
|
|
176
|
+
* members it can name, which is why those two, and only those, may be answered
|
|
177
|
+
* this way. `robotsTxtCustom` is read by every storefront that has this
|
|
178
|
+
* endpoint, so an unreadable one still fails the whole answer: a `200` with an
|
|
179
|
+
* empty text would be a `robots.txt` that silently omits an operator's rules.
|
|
180
|
+
*
|
|
181
|
+
* It is a list of names, not a closed enum, so that a later backend can name
|
|
182
|
+
* something else without an earlier storefront finding the answer unreadable.
|
|
183
|
+
*
|
|
184
|
+
* Strict about the members it names and tolerant of any it does not, for the
|
|
185
|
+
* reason given at {@link storefrontRobotsPolicySchema}. The `max` on the texts
|
|
186
|
+
* is in characters and is deliberately the looser test: a text within the byte
|
|
187
|
+
* limit never has more characters than that, so a longer one did not come
|
|
188
|
+
* through the door that enforces the limit, and a storefront treats the answer
|
|
189
|
+
* as unreadable rather than serve it.
|
|
190
|
+
*/
|
|
191
|
+
export declare const storefrontCrawlerFilesSchema: z.ZodObject<{
|
|
192
|
+
index: z.ZodBoolean;
|
|
193
|
+
follow: z.ZodBoolean;
|
|
194
|
+
robotsTxtCustom: z.ZodString;
|
|
195
|
+
llmsTxtAdditional: z.ZodString;
|
|
196
|
+
shop: z.ZodObject<{
|
|
197
|
+
name: z.ZodString;
|
|
198
|
+
}, z.core.$strip>;
|
|
199
|
+
unreadable: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
200
|
+
anonymousAccess: z.ZodOptional<z.ZodBoolean>;
|
|
201
|
+
}, z.core.$strip>;
|
|
202
|
+
export type StorefrontCrawlerFiles = z.infer<typeof storefrontCrawlerFilesSchema>;
|
|
203
|
+
export declare const storefrontCrawlerFilesResponseSchema: z.ZodObject<{
|
|
204
|
+
data: z.ZodObject<{
|
|
205
|
+
index: z.ZodBoolean;
|
|
206
|
+
follow: z.ZodBoolean;
|
|
207
|
+
robotsTxtCustom: z.ZodString;
|
|
208
|
+
llmsTxtAdditional: z.ZodString;
|
|
209
|
+
shop: z.ZodObject<{
|
|
210
|
+
name: z.ZodString;
|
|
211
|
+
}, z.core.$strip>;
|
|
212
|
+
unreadable: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
213
|
+
anonymousAccess: z.ZodOptional<z.ZodBoolean>;
|
|
214
|
+
}, z.core.$strip>;
|
|
215
|
+
}, z.core.$strip>;
|
|
216
|
+
export type StorefrontCrawlerFilesResponse = z.infer<typeof storefrontCrawlerFilesResponseSchema>;
|
|
217
|
+
/**
|
|
218
|
+
* A crawler file: the part the storefront generates, then the part an operator
|
|
219
|
+
* wrote.
|
|
220
|
+
*
|
|
221
|
+
* One function, shared by the storefront that serves the file and by the Admin
|
|
222
|
+
* UI that previews it, so the two cannot come to disagree about the join.
|
|
223
|
+
*
|
|
224
|
+
* * `extra` empty or made only of whitespace → `base`, **byte for byte**. An
|
|
225
|
+
* instance nobody configured serves exactly what it generated.
|
|
226
|
+
* * otherwise → `base` ending in one line break, one blank line, `extra`, one
|
|
227
|
+
* line break.
|
|
228
|
+
*
|
|
229
|
+
* ## What happens to `extra` — the definition of "verbatim"
|
|
230
|
+
*
|
|
231
|
+
* Every character of it is kept, unchanged and in order — indentation,
|
|
232
|
+
* trailing spaces, blank lines, comments, anything that is not a line break at
|
|
233
|
+
* all. Two things are normalised, and both are about line breaks:
|
|
234
|
+
*
|
|
235
|
+
* * **every line break is served as a line feed**, whether it was stored as
|
|
236
|
+
* `LF`, `CRLF` or a lone `CR`. A browser's text field sends `LF`; the
|
|
237
|
+
* settings API stores what it is sent, so a client that sends `CRLF` stores
|
|
238
|
+
* `CRLF`. Without this, one file would carry two conventions — the
|
|
239
|
+
* generated part's and the operator's — and the same text would be served
|
|
240
|
+
* as different bytes depending on which client saved it;
|
|
241
|
+
* * **line breaks at the end of the text become exactly one**, so the file
|
|
242
|
+
* always ends with a single line break.
|
|
243
|
+
*
|
|
244
|
+
* And one thing is removed that is not a line break: **a single byte order
|
|
245
|
+
* mark (`U+FEFF`) at the very start of the text.** Editors put one there
|
|
246
|
+
* unseen. Served, it is glued to the first line, and a crawler does not
|
|
247
|
+
* recognise `\uFEFFUser-agent: …` as the start of a group — so the rules
|
|
248
|
+
* under it attach to the group above, which is the generated one for every
|
|
249
|
+
* crawler, and a `Disallow: /` written for one crawler would close the site
|
|
250
|
+
* to all of them. Exactly one, and only there: a second one, or one anywhere
|
|
251
|
+
* else in the text, is the operator's character like any other.
|
|
252
|
+
*
|
|
253
|
+
* `base` is never altered apart from the line breaks it ends with.
|
|
254
|
+
*
|
|
255
|
+
* ## Its cost is proportional to the text
|
|
256
|
+
*
|
|
257
|
+
* It runs for every request of a public file, on text an operator saved, so
|
|
258
|
+
* it must not be possible to write a text that makes it slow. The trailing
|
|
259
|
+
* line breaks are therefore counted from the end rather than matched with
|
|
260
|
+
* `/\n+$/`: that pattern re-scans a run of line breaks from each of its
|
|
261
|
+
* positions when the run is not at the end, and took four and a half seconds
|
|
262
|
+
* on 64 KiB of them — during which a single-threaded server answers nobody.
|
|
263
|
+
* `seo.test.ts` holds the function to a time bound on such texts.
|
|
264
|
+
*/
|
|
265
|
+
export declare function composeCrawlerFile(base: string, extra: string): string;
|
|
266
|
+
/**
|
|
267
|
+
* The response header by which a storefront says it serves crawler files the
|
|
268
|
+
* way `specs/144-seo-search-engine-robots/` describes — it joins the
|
|
269
|
+
* operator's text to its own rules and answers `?part=system` with its own
|
|
270
|
+
* rules alone.
|
|
271
|
+
*
|
|
272
|
+
* A storefront is deployed separately from its backend and is often the older
|
|
273
|
+
* of the two. One that predates the feature ignores `?part=system` and answers
|
|
274
|
+
* its whole file, which looks exactly like an answer; the header is how the
|
|
275
|
+
* preview tells the two apart instead of showing a file that storefront will
|
|
276
|
+
* never serve.
|
|
277
|
+
*/
|
|
278
|
+
export declare const CRAWLER_FILES_CAPABILITY_HEADER = "X-Endora-Crawler-Files";
|
|
279
|
+
/** The crawler file a preview is asked for. */
|
|
280
|
+
export declare const adminCrawlerFileSchema: z.ZodEnum<{
|
|
281
|
+
robots: "robots";
|
|
282
|
+
llms: "llms";
|
|
283
|
+
}>;
|
|
284
|
+
export type AdminCrawlerFile = z.infer<typeof adminCrawlerFileSchema>;
|
|
285
|
+
/**
|
|
286
|
+
* What `GET /api/v1/admin/seo/crawler-files/preview` is asked
|
|
287
|
+
* (`specs/144-seo-search-engine-robots/contracts/admin-surfaces.md` §3).
|
|
288
|
+
*
|
|
289
|
+
* **Two members, both closed, and neither is an address.** The backend makes a
|
|
290
|
+
* request to a storefront on the caller's behalf, so what the caller may say
|
|
291
|
+
* is which of two files and which sales channel — a code, in the shape every
|
|
292
|
+
* channel code has. Where the request goes is the channel's configured
|
|
293
|
+
* storefront address and nothing a caller sends; the object is strict so that
|
|
294
|
+
* a member nobody declared is refused rather than ignored, and adding one is a
|
|
295
|
+
* visible change to this schema.
|
|
296
|
+
*/
|
|
297
|
+
export declare const adminCrawlerFilePreviewQuerySchema: z.ZodObject<{
|
|
298
|
+
file: z.ZodEnum<{
|
|
299
|
+
robots: "robots";
|
|
300
|
+
llms: "llms";
|
|
301
|
+
}>;
|
|
302
|
+
/**
|
|
303
|
+
* The sales channel to preview. Absent means the **system default channel**,
|
|
304
|
+
* which always exists — it is what an administrator who may read settings
|
|
305
|
+
* but may not list sales channels asks for (FR-045). There is still no
|
|
306
|
+
* cross-channel file: the answer names the one channel it is about.
|
|
307
|
+
*/
|
|
308
|
+
salesChannelCode: z.ZodOptional<z.ZodString>;
|
|
309
|
+
}, z.core.$strict>;
|
|
310
|
+
export type AdminCrawlerFilePreviewQuery = z.infer<typeof adminCrawlerFilePreviewQuerySchema>;
|
|
311
|
+
/**
|
|
312
|
+
* What became of asking the channel's storefront for the part it generates.
|
|
313
|
+
*
|
|
314
|
+
* * `ok` — it answered, and said it serves crawler files the current way;
|
|
315
|
+
* * `storefront-outdated` — it answered without
|
|
316
|
+
* {@link CRAWLER_FILES_CAPABILITY_HEADER}: it predates the feature, serves
|
|
317
|
+
* its own rules alone and applies none of the `seo` crawler settings;
|
|
318
|
+
* * `not-served` — `llms` only: the storefront serves no such file for the
|
|
319
|
+
* channel;
|
|
320
|
+
* * `storefront-unreachable` — no usable answer. Deliberately one state for a
|
|
321
|
+
* refusal, a timeout, a redirect, an error status, an answer that is not
|
|
322
|
+
* plain text and one that is too large: the endpoint tells an administrator
|
|
323
|
+
* whether the preview can be shown, not what is listening at an address;
|
|
324
|
+
* * `address-unknown` — no storefront address is configured for the channel,
|
|
325
|
+
* and no request was made.
|
|
326
|
+
*/
|
|
327
|
+
export declare const adminCrawlerFilePreviewStateSchema: z.ZodEnum<{
|
|
328
|
+
ok: "ok";
|
|
329
|
+
"storefront-outdated": "storefront-outdated";
|
|
330
|
+
"not-served": "not-served";
|
|
331
|
+
"storefront-unreachable": "storefront-unreachable";
|
|
332
|
+
"address-unknown": "address-unknown";
|
|
333
|
+
}>;
|
|
334
|
+
export type AdminCrawlerFilePreviewState = z.infer<typeof adminCrawlerFilePreviewStateSchema>;
|
|
335
|
+
/**
|
|
336
|
+
* The preview of one sales channel's crawler file.
|
|
337
|
+
*
|
|
338
|
+
* `base` is the part the storefront generates, as that storefront answered it
|
|
339
|
+
* a moment ago — never a copy the backend keeps (FR-041). It is `null`
|
|
340
|
+
* whenever it was not obtained, so a consumer cannot show remembered or
|
|
341
|
+
* invented rules as current (FR-042); the schema holds the two to each other.
|
|
342
|
+
*
|
|
343
|
+
* `savedExtra` is the operator's stored text as it resolves for the channel,
|
|
344
|
+
* character for character. The Admin UI joins the two with
|
|
345
|
+
* {@link composeCrawlerFile}, the function the storefront serves with.
|
|
346
|
+
*
|
|
347
|
+
* `base` is text a remote server sent. A consumer renders it as text.
|
|
348
|
+
*/
|
|
349
|
+
export declare const adminCrawlerFilePreviewSchema: z.ZodObject<{
|
|
350
|
+
file: z.ZodEnum<{
|
|
351
|
+
robots: "robots";
|
|
352
|
+
llms: "llms";
|
|
353
|
+
}>;
|
|
354
|
+
salesChannelCode: z.ZodString;
|
|
355
|
+
state: z.ZodEnum<{
|
|
356
|
+
ok: "ok";
|
|
357
|
+
"storefront-outdated": "storefront-outdated";
|
|
358
|
+
"not-served": "not-served";
|
|
359
|
+
"storefront-unreachable": "storefront-unreachable";
|
|
360
|
+
"address-unknown": "address-unknown";
|
|
361
|
+
}>;
|
|
362
|
+
base: z.ZodNullable<z.ZodString>;
|
|
363
|
+
savedExtra: z.ZodString;
|
|
364
|
+
savedExtraSource: z.ZodEnum<{
|
|
365
|
+
default: "default";
|
|
366
|
+
channel: "channel";
|
|
367
|
+
global: "global";
|
|
368
|
+
}>;
|
|
369
|
+
channelsWithOwnValue: z.ZodArray<z.ZodString>;
|
|
370
|
+
policy: z.ZodObject<{
|
|
371
|
+
index: z.ZodBoolean;
|
|
372
|
+
follow: z.ZodBoolean;
|
|
373
|
+
}, z.core.$strip>;
|
|
374
|
+
storefront: z.ZodObject<{
|
|
375
|
+
url: z.ZodString;
|
|
376
|
+
source: z.ZodEnum<{
|
|
377
|
+
env: "env";
|
|
378
|
+
setting: "setting";
|
|
379
|
+
fallback: "fallback";
|
|
380
|
+
}>;
|
|
381
|
+
}, z.core.$strip>;
|
|
382
|
+
}, z.core.$strip>;
|
|
383
|
+
export type AdminCrawlerFilePreview = z.infer<typeof adminCrawlerFilePreviewSchema>;
|
|
384
|
+
export declare const adminCrawlerFilePreviewResponseSchema: z.ZodObject<{
|
|
385
|
+
data: z.ZodObject<{
|
|
386
|
+
file: z.ZodEnum<{
|
|
387
|
+
robots: "robots";
|
|
388
|
+
llms: "llms";
|
|
389
|
+
}>;
|
|
390
|
+
salesChannelCode: z.ZodString;
|
|
391
|
+
state: z.ZodEnum<{
|
|
392
|
+
ok: "ok";
|
|
393
|
+
"storefront-outdated": "storefront-outdated";
|
|
394
|
+
"not-served": "not-served";
|
|
395
|
+
"storefront-unreachable": "storefront-unreachable";
|
|
396
|
+
"address-unknown": "address-unknown";
|
|
397
|
+
}>;
|
|
398
|
+
base: z.ZodNullable<z.ZodString>;
|
|
399
|
+
savedExtra: z.ZodString;
|
|
400
|
+
savedExtraSource: z.ZodEnum<{
|
|
401
|
+
default: "default";
|
|
402
|
+
channel: "channel";
|
|
403
|
+
global: "global";
|
|
404
|
+
}>;
|
|
405
|
+
channelsWithOwnValue: z.ZodArray<z.ZodString>;
|
|
406
|
+
policy: z.ZodObject<{
|
|
407
|
+
index: z.ZodBoolean;
|
|
408
|
+
follow: z.ZodBoolean;
|
|
409
|
+
}, z.core.$strip>;
|
|
410
|
+
storefront: z.ZodObject<{
|
|
411
|
+
url: z.ZodString;
|
|
412
|
+
source: z.ZodEnum<{
|
|
413
|
+
env: "env";
|
|
414
|
+
setting: "setting";
|
|
415
|
+
fallback: "fallback";
|
|
416
|
+
}>;
|
|
417
|
+
}, z.core.$strip>;
|
|
418
|
+
}, z.core.$strip>;
|
|
419
|
+
}, z.core.$strip>;
|
|
420
|
+
export type AdminCrawlerFilePreviewResponse = z.infer<typeof adminCrawlerFilePreviewResponseSchema>;
|
|
97
421
|
/**
|
|
98
422
|
* Container name: `seoMetaWritePort`. Owner: `seo`.
|
|
99
423
|
*
|
package/dist/seo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seo.d.ts","sourceRoot":"","sources":["../src/seo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"seo.d.ts","sourceRoot":"","sources":["../src/seo.ts"],"names":[],"mappings":"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"}
|
package/dist/seo.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { isoDateTimeSchema, uuidSchema } from './common.js';
|
|
3
|
+
import { SalesChannelCodeSchema } from './sales-channels.js';
|
|
3
4
|
/**
|
|
4
5
|
* SEO meta + sitemap contracts (T235 / FR-101, FR-102).
|
|
5
6
|
*
|
|
@@ -60,4 +61,306 @@ export const sitemapChannelStatusSchema = sitemapStatusSchema.extend({
|
|
|
60
61
|
export const sitemapChannelListResponseSchema = z.object({
|
|
61
62
|
data: z.array(sitemapChannelStatusSchema),
|
|
62
63
|
});
|
|
64
|
+
/**
|
|
65
|
+
* A sales channel's default robots policy, as the storefront reads it from
|
|
66
|
+
* `GET /api/v1/storefront/seo/robots-policy`.
|
|
67
|
+
*
|
|
68
|
+
* Two booleans and nothing else. The operator's choice is stored by `seo` as a
|
|
69
|
+
* token (`NOINDEX, FOLLOW` …); that spelling is the module's own and never
|
|
70
|
+
* crosses the wire, so a consumer branches on `index` and `follow` and the
|
|
71
|
+
* stored vocabulary can change without a storefront noticing.
|
|
72
|
+
*
|
|
73
|
+
* **Strict about what it reads, tolerant of what it does not know.** `index`
|
|
74
|
+
* and `follow` must both be present and must both be booleans: a storefront
|
|
75
|
+
* validates the answer against this schema and treats a body that fails it as
|
|
76
|
+
* unreadable, and a policy with half of it missing is not one to guess at.
|
|
77
|
+
*
|
|
78
|
+
* A member this schema does not name is **dropped, not refused**. A storefront
|
|
79
|
+
* is deployed separately from its backend and is usually the older of the two;
|
|
80
|
+
* were an unknown member a failure, the first backend release to add a field
|
|
81
|
+
* here would make every storefront already in the field read the answer as
|
|
82
|
+
* unreadable — and a freshly started one would then serve a `noindex` channel
|
|
83
|
+
* with no directive at all, with nothing to say why. Additive changes to this
|
|
84
|
+
* response are therefore safe by construction, and a consumer never sees a
|
|
85
|
+
* member it was not written for.
|
|
86
|
+
*/
|
|
87
|
+
export const storefrontRobotsPolicySchema = z.object({
|
|
88
|
+
/** `false` asks search engines not to index the channel's storefront. */
|
|
89
|
+
index: z.boolean(),
|
|
90
|
+
/** `false` asks search engines not to follow the links on its pages. */
|
|
91
|
+
follow: z.boolean(),
|
|
92
|
+
});
|
|
93
|
+
export const storefrontRobotsPolicyResponseSchema = z.object({
|
|
94
|
+
data: storefrontRobotsPolicySchema,
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* The most an operator may save as custom `robots.txt` instructions or as
|
|
98
|
+
* additional `llms.txt` content, per sales channel: 64 KiB of UTF-8.
|
|
99
|
+
*
|
|
100
|
+
* **Bytes, not characters** — it bounds the file a crawler downloads, and one
|
|
101
|
+
* character is up to four bytes. The `seo` module refuses a larger text when
|
|
102
|
+
* it is saved. Search engines read the first 500 KiB of a `robots.txt`; the
|
|
103
|
+
* system-generated rules are under 1 KiB, so the whole file stays well inside
|
|
104
|
+
* that.
|
|
105
|
+
*/
|
|
106
|
+
export const CRAWLER_TEXT_MAX_BYTES = 65_536;
|
|
107
|
+
/** In `unreadable`: the channel's default robots — `index` and `follow` — is not known. */
|
|
108
|
+
export const CRAWLER_FILES_UNREADABLE_POLICY = 'policy';
|
|
109
|
+
/** In `unreadable`: the channel's additional `llms.txt` content is not known. */
|
|
110
|
+
export const CRAWLER_FILES_UNREADABLE_LLMS_TXT = 'llmsTxtAdditional';
|
|
111
|
+
/**
|
|
112
|
+
* What a sales channel's crawler files are built from, as the storefront reads
|
|
113
|
+
* it from `GET /api/v1/storefront/seo/crawler-files`.
|
|
114
|
+
*
|
|
115
|
+
* The two texts are the values resolved for the channel — its own, else the
|
|
116
|
+
* all-channels value, else empty — **exactly as stored**: the backend changes
|
|
117
|
+
* no character of them, line breaks included. What a served file does with
|
|
118
|
+
* them is {@link composeCrawlerFile}'s to say.
|
|
119
|
+
*
|
|
120
|
+
* `index` and `follow` repeat the robots policy so that a file whose existence
|
|
121
|
+
* depends on it needs one read rather than two.
|
|
122
|
+
*
|
|
123
|
+
* ## `unreadable` — the parts of the answer fail apart
|
|
124
|
+
*
|
|
125
|
+
* `robots.txt` reads the texts and never the policy; `llms.txt` reads all of
|
|
126
|
+
* it. Were one unreadable stored value to fail the whole answer, a channel
|
|
127
|
+
* whose *Default robots* row holds a value nobody can interpret would lose its
|
|
128
|
+
* `robots.txt` — a file that row has no say in. So the backend answers `200`
|
|
129
|
+
* and **names** what it could not read:
|
|
130
|
+
*
|
|
131
|
+
* * {@link CRAWLER_FILES_UNREADABLE_POLICY} — `index` and `follow` are then
|
|
132
|
+
* both `false`, the restrictive reading, and mean "not known";
|
|
133
|
+
* * {@link CRAWLER_FILES_UNREADABLE_LLMS_TXT} — `llmsTxtAdditional` is then
|
|
134
|
+
* `''` and means "not known".
|
|
135
|
+
*
|
|
136
|
+
* A file that needs a named member treats it as unknown and is not served; a
|
|
137
|
+
* file that does not is unaffected. The member is optional and additive: a
|
|
138
|
+
* backend older than it never sends it (it failed the whole answer instead),
|
|
139
|
+
* and a storefront older than it ignores it — and reads neither of the two
|
|
140
|
+
* members it can name, which is why those two, and only those, may be answered
|
|
141
|
+
* this way. `robotsTxtCustom` is read by every storefront that has this
|
|
142
|
+
* endpoint, so an unreadable one still fails the whole answer: a `200` with an
|
|
143
|
+
* empty text would be a `robots.txt` that silently omits an operator's rules.
|
|
144
|
+
*
|
|
145
|
+
* It is a list of names, not a closed enum, so that a later backend can name
|
|
146
|
+
* something else without an earlier storefront finding the answer unreadable.
|
|
147
|
+
*
|
|
148
|
+
* Strict about the members it names and tolerant of any it does not, for the
|
|
149
|
+
* reason given at {@link storefrontRobotsPolicySchema}. The `max` on the texts
|
|
150
|
+
* is in characters and is deliberately the looser test: a text within the byte
|
|
151
|
+
* limit never has more characters than that, so a longer one did not come
|
|
152
|
+
* through the door that enforces the limit, and a storefront treats the answer
|
|
153
|
+
* as unreadable rather than serve it.
|
|
154
|
+
*/
|
|
155
|
+
export const storefrontCrawlerFilesSchema = storefrontRobotsPolicySchema.extend({
|
|
156
|
+
/** The operator's `robots.txt` instructions, or `''`. */
|
|
157
|
+
robotsTxtCustom: z.string().max(CRAWLER_TEXT_MAX_BYTES),
|
|
158
|
+
/** The operator's additional `llms.txt` content, or `''`. */
|
|
159
|
+
llmsTxtAdditional: z.string().max(CRAWLER_TEXT_MAX_BYTES),
|
|
160
|
+
shop: z.object({
|
|
161
|
+
/** The channel's configured shop name, or `''` when none is set. */
|
|
162
|
+
name: z.string(),
|
|
163
|
+
}),
|
|
164
|
+
/** The members above that could not be read. Absent means none. */
|
|
165
|
+
unreadable: z.array(z.string()).optional(),
|
|
166
|
+
/**
|
|
167
|
+
* Whether the channel is open to anonymous visitors
|
|
168
|
+
* (`specs/154-sales-channel-access/`). `false` is a store with nothing
|
|
169
|
+
* public: its `robots.txt` disallows everything and names no sitemap, and
|
|
170
|
+
* its `llms.txt` names the store and lists nothing — whatever the texts and
|
|
171
|
+
* the policy above say. The texts are still answered as stored.
|
|
172
|
+
*
|
|
173
|
+
* Optional and additive: a backend older than it never sends it, and its
|
|
174
|
+
* channels are all open; a consumer reads its absence as `true`.
|
|
175
|
+
*/
|
|
176
|
+
anonymousAccess: z.boolean().optional(),
|
|
177
|
+
});
|
|
178
|
+
export const storefrontCrawlerFilesResponseSchema = z.object({
|
|
179
|
+
data: storefrontCrawlerFilesSchema,
|
|
180
|
+
});
|
|
181
|
+
/**
|
|
182
|
+
* A crawler file: the part the storefront generates, then the part an operator
|
|
183
|
+
* wrote.
|
|
184
|
+
*
|
|
185
|
+
* One function, shared by the storefront that serves the file and by the Admin
|
|
186
|
+
* UI that previews it, so the two cannot come to disagree about the join.
|
|
187
|
+
*
|
|
188
|
+
* * `extra` empty or made only of whitespace → `base`, **byte for byte**. An
|
|
189
|
+
* instance nobody configured serves exactly what it generated.
|
|
190
|
+
* * otherwise → `base` ending in one line break, one blank line, `extra`, one
|
|
191
|
+
* line break.
|
|
192
|
+
*
|
|
193
|
+
* ## What happens to `extra` — the definition of "verbatim"
|
|
194
|
+
*
|
|
195
|
+
* Every character of it is kept, unchanged and in order — indentation,
|
|
196
|
+
* trailing spaces, blank lines, comments, anything that is not a line break at
|
|
197
|
+
* all. Two things are normalised, and both are about line breaks:
|
|
198
|
+
*
|
|
199
|
+
* * **every line break is served as a line feed**, whether it was stored as
|
|
200
|
+
* `LF`, `CRLF` or a lone `CR`. A browser's text field sends `LF`; the
|
|
201
|
+
* settings API stores what it is sent, so a client that sends `CRLF` stores
|
|
202
|
+
* `CRLF`. Without this, one file would carry two conventions — the
|
|
203
|
+
* generated part's and the operator's — and the same text would be served
|
|
204
|
+
* as different bytes depending on which client saved it;
|
|
205
|
+
* * **line breaks at the end of the text become exactly one**, so the file
|
|
206
|
+
* always ends with a single line break.
|
|
207
|
+
*
|
|
208
|
+
* And one thing is removed that is not a line break: **a single byte order
|
|
209
|
+
* mark (`U+FEFF`) at the very start of the text.** Editors put one there
|
|
210
|
+
* unseen. Served, it is glued to the first line, and a crawler does not
|
|
211
|
+
* recognise `\uFEFFUser-agent: …` as the start of a group — so the rules
|
|
212
|
+
* under it attach to the group above, which is the generated one for every
|
|
213
|
+
* crawler, and a `Disallow: /` written for one crawler would close the site
|
|
214
|
+
* to all of them. Exactly one, and only there: a second one, or one anywhere
|
|
215
|
+
* else in the text, is the operator's character like any other.
|
|
216
|
+
*
|
|
217
|
+
* `base` is never altered apart from the line breaks it ends with.
|
|
218
|
+
*
|
|
219
|
+
* ## Its cost is proportional to the text
|
|
220
|
+
*
|
|
221
|
+
* It runs for every request of a public file, on text an operator saved, so
|
|
222
|
+
* it must not be possible to write a text that makes it slow. The trailing
|
|
223
|
+
* line breaks are therefore counted from the end rather than matched with
|
|
224
|
+
* `/\n+$/`: that pattern re-scans a run of line breaks from each of its
|
|
225
|
+
* positions when the run is not at the end, and took four and a half seconds
|
|
226
|
+
* on 64 KiB of them — during which a single-threaded server answers nobody.
|
|
227
|
+
* `seo.test.ts` holds the function to a time bound on such texts.
|
|
228
|
+
*/
|
|
229
|
+
export function composeCrawlerFile(base, extra) {
|
|
230
|
+
const written = extra.charCodeAt(0) === BYTE_ORDER_MARK ? extra.slice(1) : extra;
|
|
231
|
+
if (written.trim().length === 0)
|
|
232
|
+
return base;
|
|
233
|
+
// One pass, no backtracking: a `\r` is consumed with the `\n` after it, if any.
|
|
234
|
+
const text = withoutTrailingLineFeeds(written.replace(/\r\n?/g, '\n'));
|
|
235
|
+
return `${withoutTrailingLineFeeds(base)}\n\n${text}\n`;
|
|
236
|
+
}
|
|
237
|
+
const BYTE_ORDER_MARK = 0xfeff;
|
|
238
|
+
const LINE_FEED = 0x0a;
|
|
239
|
+
/** `text` without the line feeds it ends with. Linear in their number. */
|
|
240
|
+
function withoutTrailingLineFeeds(text) {
|
|
241
|
+
let end = text.length;
|
|
242
|
+
while (end > 0 && text.charCodeAt(end - 1) === LINE_FEED)
|
|
243
|
+
end -= 1;
|
|
244
|
+
return end === text.length ? text : text.slice(0, end);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The response header by which a storefront says it serves crawler files the
|
|
248
|
+
* way `specs/144-seo-search-engine-robots/` describes — it joins the
|
|
249
|
+
* operator's text to its own rules and answers `?part=system` with its own
|
|
250
|
+
* rules alone.
|
|
251
|
+
*
|
|
252
|
+
* A storefront is deployed separately from its backend and is often the older
|
|
253
|
+
* of the two. One that predates the feature ignores `?part=system` and answers
|
|
254
|
+
* its whole file, which looks exactly like an answer; the header is how the
|
|
255
|
+
* preview tells the two apart instead of showing a file that storefront will
|
|
256
|
+
* never serve.
|
|
257
|
+
*/
|
|
258
|
+
export const CRAWLER_FILES_CAPABILITY_HEADER = 'X-Endora-Crawler-Files';
|
|
259
|
+
/** The crawler file a preview is asked for. */
|
|
260
|
+
export const adminCrawlerFileSchema = z.enum(['robots', 'llms']);
|
|
261
|
+
/**
|
|
262
|
+
* What `GET /api/v1/admin/seo/crawler-files/preview` is asked
|
|
263
|
+
* (`specs/144-seo-search-engine-robots/contracts/admin-surfaces.md` §3).
|
|
264
|
+
*
|
|
265
|
+
* **Two members, both closed, and neither is an address.** The backend makes a
|
|
266
|
+
* request to a storefront on the caller's behalf, so what the caller may say
|
|
267
|
+
* is which of two files and which sales channel — a code, in the shape every
|
|
268
|
+
* channel code has. Where the request goes is the channel's configured
|
|
269
|
+
* storefront address and nothing a caller sends; the object is strict so that
|
|
270
|
+
* a member nobody declared is refused rather than ignored, and adding one is a
|
|
271
|
+
* visible change to this schema.
|
|
272
|
+
*/
|
|
273
|
+
export const adminCrawlerFilePreviewQuerySchema = z.strictObject({
|
|
274
|
+
file: adminCrawlerFileSchema,
|
|
275
|
+
/**
|
|
276
|
+
* The sales channel to preview. Absent means the **system default channel**,
|
|
277
|
+
* which always exists — it is what an administrator who may read settings
|
|
278
|
+
* but may not list sales channels asks for (FR-045). There is still no
|
|
279
|
+
* cross-channel file: the answer names the one channel it is about.
|
|
280
|
+
*/
|
|
281
|
+
salesChannelCode: SalesChannelCodeSchema.optional(),
|
|
282
|
+
});
|
|
283
|
+
/**
|
|
284
|
+
* What became of asking the channel's storefront for the part it generates.
|
|
285
|
+
*
|
|
286
|
+
* * `ok` — it answered, and said it serves crawler files the current way;
|
|
287
|
+
* * `storefront-outdated` — it answered without
|
|
288
|
+
* {@link CRAWLER_FILES_CAPABILITY_HEADER}: it predates the feature, serves
|
|
289
|
+
* its own rules alone and applies none of the `seo` crawler settings;
|
|
290
|
+
* * `not-served` — `llms` only: the storefront serves no such file for the
|
|
291
|
+
* channel;
|
|
292
|
+
* * `storefront-unreachable` — no usable answer. Deliberately one state for a
|
|
293
|
+
* refusal, a timeout, a redirect, an error status, an answer that is not
|
|
294
|
+
* plain text and one that is too large: the endpoint tells an administrator
|
|
295
|
+
* whether the preview can be shown, not what is listening at an address;
|
|
296
|
+
* * `address-unknown` — no storefront address is configured for the channel,
|
|
297
|
+
* and no request was made.
|
|
298
|
+
*/
|
|
299
|
+
export const adminCrawlerFilePreviewStateSchema = z.enum([
|
|
300
|
+
'ok',
|
|
301
|
+
'storefront-outdated',
|
|
302
|
+
'not-served',
|
|
303
|
+
'storefront-unreachable',
|
|
304
|
+
'address-unknown',
|
|
305
|
+
]);
|
|
306
|
+
/** States whose answer carries no storefront-generated part at all. */
|
|
307
|
+
const STATES_WITHOUT_BASE = [
|
|
308
|
+
'not-served',
|
|
309
|
+
'storefront-unreachable',
|
|
310
|
+
'address-unknown',
|
|
311
|
+
];
|
|
312
|
+
/**
|
|
313
|
+
* The preview of one sales channel's crawler file.
|
|
314
|
+
*
|
|
315
|
+
* `base` is the part the storefront generates, as that storefront answered it
|
|
316
|
+
* a moment ago — never a copy the backend keeps (FR-041). It is `null`
|
|
317
|
+
* whenever it was not obtained, so a consumer cannot show remembered or
|
|
318
|
+
* invented rules as current (FR-042); the schema holds the two to each other.
|
|
319
|
+
*
|
|
320
|
+
* `savedExtra` is the operator's stored text as it resolves for the channel,
|
|
321
|
+
* character for character. The Admin UI joins the two with
|
|
322
|
+
* {@link composeCrawlerFile}, the function the storefront serves with.
|
|
323
|
+
*
|
|
324
|
+
* `base` is text a remote server sent. A consumer renders it as text.
|
|
325
|
+
*/
|
|
326
|
+
export const adminCrawlerFilePreviewSchema = z
|
|
327
|
+
.object({
|
|
328
|
+
file: adminCrawlerFileSchema,
|
|
329
|
+
salesChannelCode: SalesChannelCodeSchema,
|
|
330
|
+
state: adminCrawlerFilePreviewStateSchema,
|
|
331
|
+
base: z.string().nullable(),
|
|
332
|
+
/** The stored text that resolves for the channel, or `''`. */
|
|
333
|
+
savedExtra: z.string(),
|
|
334
|
+
/** Where that text comes from: the channel's own value, the all-channels value, or neither. */
|
|
335
|
+
savedExtraSource: z.enum(['channel', 'global', 'default']),
|
|
336
|
+
/** The codes of the channels holding a value of their own for the setting. */
|
|
337
|
+
channelsWithOwnValue: z.array(SalesChannelCodeSchema),
|
|
338
|
+
/** The channel's saved *Default robots*, as the storefront reads it. */
|
|
339
|
+
policy: storefrontRobotsPolicySchema,
|
|
340
|
+
storefront: z.object({
|
|
341
|
+
/** The address the channel's storefront is taken to be at. */
|
|
342
|
+
url: z.string(),
|
|
343
|
+
/**
|
|
344
|
+
* `setting` — the channel's own configured address; `env` — the
|
|
345
|
+
* deployment-wide one, shared by every channel; `fallback` — neither is
|
|
346
|
+
* configured.
|
|
347
|
+
*/
|
|
348
|
+
source: z.enum(['setting', 'env', 'fallback']),
|
|
349
|
+
}),
|
|
350
|
+
})
|
|
351
|
+
.superRefine((preview, ctx) => {
|
|
352
|
+
if (preview.state === 'ok' && preview.base === null) {
|
|
353
|
+
ctx.addIssue({ code: 'custom', path: ['base'], message: 'state "ok" carries the base' });
|
|
354
|
+
}
|
|
355
|
+
if (STATES_WITHOUT_BASE.includes(preview.state) && preview.base !== null) {
|
|
356
|
+
ctx.addIssue({
|
|
357
|
+
code: 'custom',
|
|
358
|
+
path: ['base'],
|
|
359
|
+
message: `state "${preview.state}" obtained no base and must not carry one`,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
export const adminCrawlerFilePreviewResponseSchema = z.object({
|
|
364
|
+
data: adminCrawlerFilePreviewSchema,
|
|
365
|
+
});
|
|
63
366
|
//# sourceMappingURL=seo.js.map
|