@seamlet/astro 1.3.0 → 1.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.0
4
+
5
+ - Documents: `file({ label })` holds a PDF the owner uploads in the CMS, `{ src, name }` (`FileValue`): a price list, a menu, a contract. An empty name of a file asks for its file (`missing-file-src`). A static build copies the uploaded documents its pages link to, as it copies the photos, and the route of uploads serves them on request; `isUploadedFile` names both.
6
+
7
+ A site with a file field needs a CMS that reads 1.4 (cms.seamlet.ru from its release that takes documents). Code with an exhaustive `switch` over `FieldKind` or over the issues of `parseContent` gets the new member to handle.
8
+
3
9
  ## 1.3.0
4
10
 
5
11
  - Requests: `requestForm({ id, title, fields })` with `requestText`, `requestLongText`, `requestPhone`, `requestEmail` and `requestChoice` declares a form visitors send the business requests with; `defineSeamletSite` takes them as `forms`, and the site's description tells the CMS about them. `RequestForm.astro` renders one, with a checkbox of consent of its own; it is posted to the CMS without a script, and sent in place with it.
package/README.md CHANGED
@@ -128,6 +128,7 @@ The site's pages take their published content with `site.loadPublishedContent()`
128
128
  | `time({ label })` | `HH:MM`, 00:00 to 23:59 | `null` |
129
129
  | `slug({ label })` | the address of a record's page, `latte` in `/menu/latte` (below) | `""` |
130
130
  | `image({ label })` | `{ src, alt }` | `null` |
131
+ | `file({ label })` | `{ src, name }`: a PDF uploaded in the CMS, a price list or a menu | `null` |
131
132
  | `link({ label })` | `{ text, href }`: a page of the site, another site, a phone or an email | `null` |
132
133
  | `url({ label })` | a web address without a text: a booking widget, a map | `null` |
133
134
  | `toggle({ label })` | `true` or `false` | `false` |
@@ -138,6 +139,16 @@ The site's pages take their published content with `site.loadPublishedContent()`
138
139
  | `group({ label, fields })` | named fields shown together | each field empty |
139
140
  | `collection({ label, item, itemTitle? })` | a list of records of the same fields | `[]` |
140
141
 
142
+ A file is a document the owner uploads in the CMS as a PDF. The site links to it, and a static build copies it next to its pages as it copies the uploaded photos:
143
+
144
+ ```astro
145
+ {content.priceList && (
146
+ <a href={safeHref(content.priceList.src)} download>
147
+ {content.priceList.name}
148
+ </a>
149
+ )}
150
+ ```
151
+
141
152
  Options are `{ value, label }`: the site reads `value`, the editor shows `label`, so a label can change without touching the site. The content has their exact type:
142
153
 
143
154
  ```ts
package/dist/bridge.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as Fields } from './parse-content-Bnn6Wa-l.js';
2
- import { P as PageMessage, E as EditorMessage } from './messages-C2OjqFmy.js';
1
+ import { F as Fields } from './parse-content-CT2cUVL-.js';
2
+ import { P as PageMessage, E as EditorMessage } from './messages-Dwjthhrk.js';
3
3
 
4
4
  interface BridgeOptions {
5
5
  /** The origin of the CMS whose editor may frame the page, such as `https://cms.example.com`. */
package/dist/bridge.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  shortcutOf,
19
19
  toggleList,
20
20
  toggleMark
21
- } from "./chunk-2GZZHXP5.js";
21
+ } from "./chunk-BCJUH3ZD.js";
22
22
  import {
23
23
  FIELD_PATH_ATTRIBUTE,
24
24
  REVEALED_ATTRIBUTE,
@@ -28,7 +28,7 @@ import {
28
28
  readRichText,
29
29
  resolveFieldPath,
30
30
  safeHref
31
- } from "./chunk-ENMUO442.js";
31
+ } from "./chunk-TMN7KG5M.js";
32
32
 
33
33
  // src/bridge/typed-fields.ts
34
34
  function typedKindAt(schema, path) {
@@ -44,6 +44,7 @@ function typedKindAt(schema, path) {
44
44
  case "time":
45
45
  case "slug":
46
46
  case "image":
47
+ case "file":
47
48
  case "link":
48
49
  case "url":
49
50
  case "toggle":
@@ -6,7 +6,7 @@ import {
6
6
  readRichText,
7
7
  resolveFieldPath,
8
8
  safeHref
9
- } from "./chunk-ENMUO442.js";
9
+ } from "./chunk-TMN7KG5M.js";
10
10
 
11
11
  // src/bridge/editor-shortcuts.ts
12
12
  function shortcutOf(event) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pagePathOf
3
- } from "./chunk-VQKAWFCQ.js";
3
+ } from "./chunk-ULOKDC6D.js";
4
4
  import {
5
5
  FIELD_PATH_SEPARATOR,
6
6
  collectionAt,
@@ -9,7 +9,7 @@ import {
9
9
  newRecord,
10
10
  recordAt,
11
11
  recordPageAt
12
- } from "./chunk-ENMUO442.js";
12
+ } from "./chunk-TMN7KG5M.js";
13
13
 
14
14
  // src/preview-requests.ts
15
15
  var MAX_DRAFT_BYTES = 1024 * 1024;
@@ -17,6 +17,7 @@ var BAD_REQUEST = 400;
17
17
  var PAYLOAD_TOO_LARGE = 413;
18
18
  var UNSUPPORTED_MEDIA_TYPE = 415;
19
19
  var UPLOADED_PHOTO = /^[A-Za-z0-9_-]+\.webp$/u;
20
+ var UPLOADED_FILE = /^[A-Za-z0-9_-]+\.(?:webp|pdf)$/u;
20
21
  function previewHeadersOf(cmsOrigin) {
21
22
  return {
22
23
  "Content-Security-Policy": `frame-ancestors ${cmsOrigin}`,
@@ -57,6 +58,9 @@ function previewContentAt(description, content, rest) {
57
58
  function isUploadedPhoto(fileName) {
58
59
  return fileName !== void 0 && UPLOADED_PHOTO.test(fileName);
59
60
  }
61
+ function isUploadedFile(fileName) {
62
+ return fileName !== void 0 && UPLOADED_FILE.test(fileName);
63
+ }
60
64
  async function readLimited(request) {
61
65
  if (request.body === null) return "";
62
66
  const reader = request.body.getReader();
@@ -100,5 +104,6 @@ export {
100
104
  readDraft,
101
105
  isPageAddress,
102
106
  previewContentAt,
103
- isUploadedPhoto
107
+ isUploadedPhoto,
108
+ isUploadedFile
104
109
  };
@@ -17,6 +17,9 @@ function date(options) {
17
17
  function image(options) {
18
18
  return { kind: "image", ...options };
19
19
  }
20
+ function file(options) {
21
+ return { kind: "file", ...options };
22
+ }
20
23
  function link(options) {
21
24
  return { kind: "link", ...options };
22
25
  }
@@ -66,6 +69,7 @@ function defaultValue(field) {
66
69
  case "number":
67
70
  case "date":
68
71
  case "image":
72
+ case "file":
69
73
  case "link":
70
74
  case "choice":
71
75
  case "url":
@@ -116,6 +120,7 @@ function resolveInsideField(field, segments, path) {
116
120
  case "number":
117
121
  case "date":
118
122
  case "image":
123
+ case "file":
119
124
  case "link":
120
125
  case "toggle":
121
126
  case "choice":
@@ -352,6 +357,7 @@ function collectionIn(fields, content, names) {
352
357
  case "number":
353
358
  case "date":
354
359
  case "image":
360
+ case "file":
355
361
  case "link":
356
362
  case "toggle":
357
363
  case "choice":
@@ -379,6 +385,7 @@ function collectionFieldAt(schema, path) {
379
385
  case "number":
380
386
  case "date":
381
387
  case "image":
388
+ case "file":
382
389
  case "link":
383
390
  case "toggle":
384
391
  case "choice":
@@ -413,6 +420,7 @@ function withIdsIn(field, value, newId) {
413
420
  case "number":
414
421
  case "date":
415
422
  case "image":
423
+ case "file":
416
424
  case "link":
417
425
  case "toggle":
418
426
  case "choice":
@@ -469,6 +477,7 @@ function issuesInField(field, value, path, idsOf) {
469
477
  case "number":
470
478
  case "date":
471
479
  case "image":
480
+ case "file":
472
481
  case "link":
473
482
  case "toggle":
474
483
  case "choice":
@@ -521,6 +530,7 @@ function issuesInField2(field, value, path) {
521
530
  case "number":
522
531
  case "date":
523
532
  case "image":
533
+ case "file":
524
534
  case "link":
525
535
  case "toggle":
526
536
  case "choice":
@@ -685,6 +695,8 @@ function parseField(field, input, path) {
685
695
  return parseDate(field, input, path);
686
696
  case "image":
687
697
  return parseImage(field, input, path);
698
+ case "file":
699
+ return parseFile(field, input, path);
688
700
  case "link":
689
701
  return parseLink(field, input, path);
690
702
  case "toggle":
@@ -798,6 +810,21 @@ function parseImage(field, input, path) {
798
810
  }
799
811
  return valid(image2);
800
812
  }
813
+ function parseFile(field, input, path) {
814
+ if (input === null) {
815
+ return valid(null);
816
+ }
817
+ const src = isJsonObject(input) ? input["src"] : void 0;
818
+ const name = isJsonObject(input) ? input["name"] : void 0;
819
+ if (typeof src !== "string" || typeof name !== "string") {
820
+ return invalidType(defaultValue(field), path);
821
+ }
822
+ const file2 = { src, name };
823
+ if (src.trim() === "") {
824
+ return { value: file2, issues: [{ path, code: "missing-file-src" }] };
825
+ }
826
+ return valid(file2);
827
+ }
801
828
  function parseLink(field, input, path) {
802
829
  if (input === null) {
803
830
  return valid(null);
@@ -1105,6 +1132,7 @@ function readFieldOfKind(field) {
1105
1132
  ]);
1106
1133
  case "date":
1107
1134
  case "image":
1135
+ case "file":
1108
1136
  case "link":
1109
1137
  case "toggle":
1110
1138
  case "url":
@@ -1184,6 +1212,7 @@ function unknownCollectionIn(schema, field, path) {
1184
1212
  case "number":
1185
1213
  case "date":
1186
1214
  case "image":
1215
+ case "file":
1187
1216
  case "link":
1188
1217
  case "toggle":
1189
1218
  case "choice":
@@ -1214,6 +1243,7 @@ function misplacedSlugIn(field, path) {
1214
1243
  case "number":
1215
1244
  case "date":
1216
1245
  case "image":
1246
+ case "file":
1217
1247
  case "link":
1218
1248
  case "toggle":
1219
1249
  case "choice":
@@ -1255,6 +1285,7 @@ var FIELD_KINDS = {
1255
1285
  number: true,
1256
1286
  date: true,
1257
1287
  image: true,
1288
+ file: true,
1258
1289
  link: true,
1259
1290
  toggle: true,
1260
1291
  choice: true,
@@ -1790,6 +1821,7 @@ export {
1790
1821
  number,
1791
1822
  date,
1792
1823
  image,
1824
+ file,
1793
1825
  link,
1794
1826
  toggle,
1795
1827
  choice,
@@ -6,7 +6,7 @@ import {
6
6
  recordAt,
7
7
  recordPageAt,
8
8
  recordPagePath
9
- } from "./chunk-ENMUO442.js";
9
+ } from "./chunk-TMN7KG5M.js";
10
10
 
11
11
  // src/site-pages.ts
12
12
  function pagePathOf(rest) {
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  SITE_CONFIG_FILE,
7
7
  isSiteId,
8
8
  readSiteConfig
9
- } from "./chunk-ENMUO442.js";
9
+ } from "./chunk-TMN7KG5M.js";
10
10
 
11
11
  // src/cli.ts
12
12
  import process from "process";
package/dist/client.js CHANGED
@@ -16,7 +16,7 @@ if (isFramed && isPreview) {
16
16
  });
17
17
  }
18
18
  if (document.querySelector(REQUEST_FORM_SELECTOR) !== null) {
19
- void import("./request-sending-Y6L55IIM.js").then(({ connectRequestForms }) => {
19
+ void import("./request-sending-ZBTK5L7U.js").then(({ connectRequestForms }) => {
20
20
  connectRequestForms(document, { isPreview });
21
21
  });
22
22
  }
package/dist/index.js CHANGED
@@ -7,15 +7,15 @@ import {
7
7
  UPLOADS_PATH
8
8
  } from "./chunk-QCVWHHJC.js";
9
9
  import {
10
- isUploadedPhoto
11
- } from "./chunk-MFD4TJPV.js";
12
- import "./chunk-VQKAWFCQ.js";
10
+ isUploadedFile
11
+ } from "./chunk-JQ4YD7MM.js";
12
+ import "./chunk-ULOKDC6D.js";
13
13
  import {
14
14
  SITE_CONFIG_FILE,
15
15
  SITE_DESCRIPTION_PATH,
16
16
  isJsonObject,
17
17
  readSiteConfig
18
- } from "./chunk-ENMUO442.js";
18
+ } from "./chunk-TMN7KG5M.js";
19
19
 
20
20
  // src/index.ts
21
21
  import process from "process";
@@ -33,7 +33,7 @@ var PHOTOS_COPIED_AT_ONCE = 6;
33
33
  var PHOTO_TIMEOUT_MS = 6e4;
34
34
  function uploadedPhotoAddresses(html, siteId) {
35
35
  const addresses = [...html.matchAll(PHOTO_ADDRESS)].flatMap(
36
- ([address, site, fileName]) => site === siteId && isUploadedPhoto(fileName) ? [address] : []
36
+ ([address, site, fileName]) => site === siteId && isUploadedFile(fileName) ? [address] : []
37
37
  );
38
38
  return [...new Set(addresses)];
39
39
  }
@@ -1,4 +1,4 @@
1
- import { R as RichText, F as Fields, C as Content, a as FieldPath } from './parse-content-Bnn6Wa-l.js';
1
+ import { R as RichText, F as Fields, C as Content, a as FieldPath } from './parse-content-CT2cUVL-.js';
2
2
 
3
3
  interface Box {
4
4
  readonly top: number;
@@ -34,6 +34,14 @@ interface ImageField {
34
34
  readonly kind: "image";
35
35
  readonly label: string;
36
36
  }
37
+ /**
38
+ * A document a visitor opens or downloads: a price list, a menu, a contract, uploaded in the CMS as
39
+ * a PDF. Its value is the file's address and the name the site shows for it.
40
+ */
41
+ interface FileField {
42
+ readonly kind: "file";
43
+ readonly label: string;
44
+ }
37
45
  /**
38
46
  * A link: its text and where it leads (a page of the site, another site, a phone or an email).
39
47
  * The site decides how it looks; a button «Записаться» stays a button.
@@ -117,7 +125,7 @@ interface CollectionField<F extends RecordFields = RecordFields> {
117
125
  /** The field of a record that names it in the editor: a text field, or a link by its text. */
118
126
  readonly itemTitle?: keyof F & string;
119
127
  }
120
- type Field = TextField | RichTextField | NumberField | DateField | ImageField | LinkField | ToggleField | ChoiceField | ChoicesField | UrlField | TimeField | SlugField | ReferenceField | ReferencesField | GroupField | CollectionField;
128
+ type Field = TextField | RichTextField | NumberField | DateField | ImageField | FileField | LinkField | ToggleField | ChoiceField | ChoicesField | UrlField | TimeField | SlugField | ReferenceField | ReferencesField | GroupField | CollectionField;
121
129
  type FieldKind = Field["kind"];
122
130
  /** Field names to fields; the order of the keys is the order of the form. */
123
131
  interface Fields {
@@ -135,6 +143,7 @@ declare function richText(options: FieldOptions<RichTextField>): RichTextField;
135
143
  declare function number(options: FieldOptions<NumberField>): NumberField;
136
144
  declare function date(options: FieldOptions<DateField>): DateField;
137
145
  declare function image(options: FieldOptions<ImageField>): ImageField;
146
+ declare function file(options: FieldOptions<FileField>): FileField;
138
147
  declare function link(options: FieldOptions<LinkField>): LinkField;
139
148
  declare function toggle(options: FieldOptions<ToggleField>): ToggleField;
140
149
  /** `const` keeps the values of the options literal, so the content has their exact type. */
@@ -192,6 +201,13 @@ interface ImageValue {
192
201
  /** Unset: the middle of the photo (see imagePosition). */
193
202
  readonly focus?: ImageFocus;
194
203
  }
204
+ /** A document uploaded in the CMS: where it is and the name the site shows for it. */
205
+ interface FileValue {
206
+ /** `/media/<site>/<file>.pdf`, or an address of the site's own files. */
207
+ readonly src: string;
208
+ /** «Прайс-лист», «Меню банкета»: the words of the link to it. */
209
+ readonly name: string;
210
+ }
195
211
  interface LinkValue {
196
212
  readonly text: string;
197
213
  /** A path of the site (`/menu`), a web address, `tel:` or `mailto:`; see linkTargetOf. */
@@ -201,7 +217,7 @@ interface LinkValue {
201
217
  * The value of each field. A text can be empty (""), the other scalar fields can be unset (null):
202
218
  * content is filled in by people, so a site must be ready for a missing price or date.
203
219
  */
204
- type ValueOf<F extends Field> = F extends TextField ? string : F extends RichTextField ? RichText : F extends NumberField ? number | null : F extends DateField ? string | null : F extends ImageField ? ImageValue | null : F extends LinkField ? LinkValue | null : F extends ToggleField ? boolean : F extends ChoiceField<infer Options> ? OptionValue<Options> | null : F extends ChoicesField<infer Options> ? readonly OptionValue<Options>[] : F extends UrlField ? string | null : F extends TimeField ? string | null : F extends SlugField ? string : F extends ReferenceField ? string | null : F extends ReferencesField ? readonly string[] : F extends GroupField<infer Group> ? ContentOf<Group> : F extends CollectionField<infer Item> ? readonly RecordOf<Item>[] : never;
220
+ type ValueOf<F extends Field> = F extends TextField ? string : F extends RichTextField ? RichText : F extends NumberField ? number | null : F extends DateField ? string | null : F extends ImageField ? ImageValue | null : F extends FileField ? FileValue | null : F extends LinkField ? LinkValue | null : F extends ToggleField ? boolean : F extends ChoiceField<infer Options> ? OptionValue<Options> | null : F extends ChoicesField<infer Options> ? readonly OptionValue<Options>[] : F extends UrlField ? string | null : F extends TimeField ? string | null : F extends SlugField ? string : F extends ReferenceField ? string | null : F extends ReferencesField ? readonly string[] : F extends GroupField<infer Group> ? ContentOf<Group> : F extends CollectionField<infer Item> ? readonly RecordOf<Item>[] : never;
205
221
  /**
206
222
  * A record of a collection: its fields and its id. The id is missing only in content no editor has
207
223
  * saved yet, such as a site's initial content (see withRecordIds).
@@ -219,7 +235,7 @@ type ContentOf<F extends Fields> = {
219
235
  interface Content {
220
236
  readonly [name: string]: FieldValue;
221
237
  }
222
- type FieldValue = string | number | boolean | null | readonly string[] | ImageValue | LinkValue | RichText | Content | readonly Content[];
238
+ type FieldValue = string | number | boolean | null | readonly string[] | ImageValue | FileValue | LinkValue | RichText | Content | readonly Content[];
223
239
  declare function defaultValue(field: Field): FieldValue;
224
240
  declare function defaultContent(fields: Fields): Content;
225
241
 
@@ -249,6 +265,9 @@ type ContentIssue = {
249
265
  } | {
250
266
  readonly path: FieldPath;
251
267
  readonly code: "missing-image-src";
268
+ } | {
269
+ readonly path: FieldPath;
270
+ readonly code: "missing-file-src";
252
271
  } | {
253
272
  readonly path: FieldPath;
254
273
  readonly code: "missing-link-href";
@@ -300,4 +319,4 @@ declare function countCharacters(text: string): number;
300
319
  */
301
320
  declare function parseContent<F extends Fields>(schema: F, input: unknown): ParsedContent<ContentOf<F>>;
302
321
 
303
- export { parseContent as $, collection as A, countCharacters as B, type Content as C, type DateField as D, date as E, type Fields as F, type GroupField as G, defaultContent as H, type ImageField as I, defaultValue as J, defineSchema as K, type LinkValue as L, formatFieldPath as M, type NumberField as N, type OptionValue as O, type ParsedContent as P, group as Q, type RichText as R, type SlugField as S, type TextField as T, type UrlField as U, type ValueOf as V, image as W, linesOf as X, link as Y, normalizedLine as Z, number as _, type FieldPath as a, plainTextOf as a0, readRichText as a1, reference as a2, references as a3, richText as a4, richTextOf as a5, slug as a6, text as a7, time as a8, toggle as a9, url as aa, type ContentOf as b, type Field as c, type CollectionField as d, type RecordFields as e, type RecordOf as f, type ContentIssue as g, type ImageValue as h, type LinkField as i, type ChoicesField as j, type TimeField as k, type RichTextField as l, type ToggleField as m, type ChoiceField as n, type ChoiceOption as o, type FieldKind as p, type FieldValue as q, type ImageFocus as r, type ReferenceField as s, type ReferencesField as t, type RichBlock as u, type RichLine as v, type RichSpan as w, asOneParagraph as x, choice as y, choices as z };
322
+ export { link as $, choice as A, choices as B, type Content as C, type DateField as D, collection as E, type Fields as F, type GroupField as G, countCharacters as H, type ImageField as I, date as J, defaultContent as K, type LinkValue as L, defaultValue as M, type NumberField as N, type OptionValue as O, type ParsedContent as P, defineSchema as Q, type RichText as R, type SlugField as S, type TextField as T, type UrlField as U, type ValueOf as V, file as W, formatFieldPath as X, group as Y, image as Z, linesOf as _, type FieldPath as a, normalizedLine as a0, number as a1, parseContent as a2, plainTextOf as a3, readRichText as a4, reference as a5, references as a6, richText as a7, richTextOf as a8, slug as a9, text as aa, time as ab, toggle as ac, url as ad, type ContentOf as b, type Field as c, type CollectionField as d, type RecordFields as e, type RecordOf as f, type ContentIssue as g, type ImageValue as h, type LinkField as i, type ChoicesField as j, type TimeField as k, type RichTextField as l, type ToggleField as m, type ChoiceField as n, type ChoiceOption as o, type FieldKind as p, type FieldValue as q, type FileField as r, type FileValue as s, type ImageFocus as t, type ReferenceField as u, type ReferencesField as v, type RichBlock as w, type RichLine as x, type RichSpan as y, asOneParagraph as z };
@@ -1,5 +1,5 @@
1
- import { C as Content } from './parse-content-Bnn6Wa-l.js';
2
- import { S as SiteDescription } from './site-description-DSHyBrAL.js';
1
+ import { C as Content } from './parse-content-CT2cUVL-.js';
2
+ import { S as SiteDescription } from './site-description-cKiFtNHW.js';
3
3
 
4
4
  /** Far more than the content of a site ever takes; a bigger body is not a draft. */
5
5
  declare const MAX_DRAFT_BYTES: number;
@@ -33,5 +33,7 @@ declare function isPageAddress(description: SiteDescription, rest: string | unde
33
33
  declare function previewContentAt(description: SiteDescription, content: Content, rest: string | undefined): Content;
34
34
  /** Whether a name can be a photo uploaded to the CMS: the hash of its bytes, as WebP. */
35
35
  declare function isUploadedPhoto(fileName: string | undefined): fileName is string;
36
+ /** Whether a name can be a file uploaded to the CMS: a photo or a document. */
37
+ declare function isUploadedFile(fileName: string | undefined): fileName is string;
36
38
 
37
- export { type DraftReading, MAX_DRAFT_BYTES, isPageAddress, isUploadedPhoto, previewContentAt, previewHeadersOf, readDraft };
39
+ export { type DraftReading, MAX_DRAFT_BYTES, isPageAddress, isUploadedFile, isUploadedPhoto, previewContentAt, previewHeadersOf, readDraft };
@@ -1,16 +1,18 @@
1
1
  import {
2
2
  MAX_DRAFT_BYTES,
3
3
  isPageAddress,
4
+ isUploadedFile,
4
5
  isUploadedPhoto,
5
6
  previewContentAt,
6
7
  previewHeadersOf,
7
8
  readDraft
8
- } from "./chunk-MFD4TJPV.js";
9
- import "./chunk-VQKAWFCQ.js";
10
- import "./chunk-ENMUO442.js";
9
+ } from "./chunk-JQ4YD7MM.js";
10
+ import "./chunk-ULOKDC6D.js";
11
+ import "./chunk-TMN7KG5M.js";
11
12
  export {
12
13
  MAX_DRAFT_BYTES,
13
14
  isPageAddress,
15
+ isUploadedFile,
14
16
  isUploadedPhoto,
15
17
  previewContentAt,
16
18
  previewHeadersOf,
@@ -1,6 +1,6 @@
1
- import { S as Shortcut, T as TextFormats } from './messages-C2OjqFmy.js';
2
- export { B as Box, a as EditorKey, E as EditorMessage, I as InlineEditingOutcome, L as LinkBox, M as MarkerBox, b as PROTOCOL_VERSION, c as PageLayout, P as PageMessage, d as Point, e as TextFormat, f as TypedSelection, V as Viewport, r as readEditorMessage, g as readPageMessage } from './messages-C2OjqFmy.js';
3
- import { F as Fields, a as FieldPath, I as ImageField, R as RichText } from './parse-content-Bnn6Wa-l.js';
1
+ import { S as Shortcut, T as TextFormats } from './messages-Dwjthhrk.js';
2
+ export { B as Box, a as EditorKey, E as EditorMessage, I as InlineEditingOutcome, L as LinkBox, M as MarkerBox, b as PROTOCOL_VERSION, c as PageLayout, P as PageMessage, d as Point, e as TextFormat, f as TypedSelection, V as Viewport, r as readEditorMessage, g as readPageMessage } from './messages-Dwjthhrk.js';
3
+ import { F as Fields, a as FieldPath, I as ImageField, R as RichText } from './parse-content-CT2cUVL-.js';
4
4
 
5
5
  declare function shortcutOf(event: KeyboardEvent): Shortcut | undefined;
6
6
 
package/dist/protocol.js CHANGED
@@ -22,9 +22,9 @@ import {
22
22
  shortcutOf,
23
23
  toggleList,
24
24
  toggleMark
25
- } from "./chunk-2GZZHXP5.js";
25
+ } from "./chunk-BCJUH3ZD.js";
26
26
  import "./chunk-QCVWHHJC.js";
27
- import "./chunk-ENMUO442.js";
27
+ import "./chunk-TMN7KG5M.js";
28
28
  export {
29
29
  OWN_PHOTOS_PATH,
30
30
  PROTOCOL_VERSION,
@@ -12,7 +12,7 @@ import {
12
12
  isJsonObject,
13
13
  readRequestForm,
14
14
  readRequestValues
15
- } from "./chunk-ENMUO442.js";
15
+ } from "./chunk-TMN7KG5M.js";
16
16
 
17
17
  // src/request-sending.ts
18
18
  var STATUS_CREATED = 201;
@@ -2,10 +2,10 @@ import {
2
2
  uploadedPhotoPath
3
3
  } from "../chunk-QCVWHHJC.js";
4
4
  import {
5
- isUploadedPhoto
6
- } from "../chunk-MFD4TJPV.js";
7
- import "../chunk-VQKAWFCQ.js";
8
- import "../chunk-ENMUO442.js";
5
+ isUploadedFile
6
+ } from "../chunk-JQ4YD7MM.js";
7
+ import "../chunk-ULOKDC6D.js";
8
+ import "../chunk-TMN7KG5M.js";
9
9
 
10
10
  // src/routes/media.ts
11
11
  import { cmsOrigin } from "virtual:seamlet/config";
@@ -15,7 +15,7 @@ var BAD_GATEWAY = 502;
15
15
  var PHOTO_TIMEOUT_MS = 1e4;
16
16
  var GET = async ({ params }) => {
17
17
  const fileName = params["file"];
18
- const isOurs = params["site"] === site.id && isUploadedPhoto(fileName);
18
+ const isOurs = params["site"] === site.id && isUploadedFile(fileName);
19
19
  if (!isOurs) {
20
20
  return new Response(null, { status: NOT_FOUND });
21
21
  }
package/dist/schema.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { h as ImageValue, L as LinkValue, d as CollectionField, C as Content, F as Fields, e as RecordFields, b as ContentOf, G as GroupField, i as LinkField, T as TextField, U as UrlField, j as ChoicesField, k as TimeField, S as SlugField, I as ImageField, l as RichTextField, N as NumberField, m as ToggleField } from './parse-content-Bnn6Wa-l.js';
2
- export { n as ChoiceField, o as ChoiceOption, g as ContentIssue, D as DateField, c as Field, p as FieldKind, a as FieldPath, q as FieldValue, r as ImageFocus, O as OptionValue, P as ParsedContent, f as RecordOf, s as ReferenceField, t as ReferencesField, u as RichBlock, v as RichLine, w as RichSpan, R as RichText, V as ValueOf, x as asOneParagraph, y as choice, z as choices, A as collection, B as countCharacters, E as date, H as defaultContent, J as defaultValue, K as defineSchema, M as formatFieldPath, Q as group, W as image, X as linesOf, Y as link, Z as normalizedLine, _ as number, $ as parseContent, a0 as plainTextOf, a1 as readRichText, a2 as reference, a3 as references, a4 as richText, a5 as richTextOf, a6 as slug, a7 as text, a8 as time, a9 as toggle, aa as url } from './parse-content-Bnn6Wa-l.js';
3
- import { R as RequestForm } from './site-description-DSHyBrAL.js';
4
- export { C as CollectionPath, D as DEFAULT_LONG_TEXT_LENGTH, b as DEFAULT_TEXT_LENGTH, F as FIELD_PATH_SEPARATOR, c as FieldTarget, d as FieldsReading, H as HOME_PAGE_PATH, M as MAX_REQUEST_FIELD_LENGTH, P as PAGE_PATH_SEPARATOR, e as PageProblemReason, f as PlacedRecord, g as RECORD_PLACEHOLDER, h as RecordFieldsAt, i as RecordPagePath, j as RecordPageProblemReason, k as RecordPages, l as RequestChoiceField, m as RequestEmailField, n as RequestField, o as RequestFieldKind, p as RequestFields, q as RequestFormProblemReason, r as RequestFormReading, s as RequestLongTextField, t as RequestPhoneField, u as RequestTextField, v as SITE_DESCRIPTION_PATH, w as SchemaProblem, x as SchemaProblemReason, S as SiteDescription, y as SiteDescriptionProblem, z as SiteDescriptionReading, A as SitePageDescription, B as SiteRecordPageDescription, a as SiteRecordPages, E as checkFields, G as checkSiteDescription, I as isFormId, J as isRecordPagePath, K as isSearchTextsGroup, L as maxLengthOf, N as readFields, O as readRequestForm, Q as readSiteDescription, T as recordAddressOf, U as recordAt, V as recordPageAt, W as recordPagePath, X as recordPages, Y as requestChoice, Z as requestEmail, _ as requestForm, $ as requestLongText, a0 as requestPhone, a1 as requestText, a2 as resolveFieldPath } from './site-description-DSHyBrAL.js';
1
+ import { h as ImageValue, L as LinkValue, d as CollectionField, C as Content, F as Fields, e as RecordFields, b as ContentOf, G as GroupField, i as LinkField, T as TextField, U as UrlField, j as ChoicesField, k as TimeField, S as SlugField, I as ImageField, l as RichTextField, N as NumberField, m as ToggleField } from './parse-content-CT2cUVL-.js';
2
+ export { n as ChoiceField, o as ChoiceOption, g as ContentIssue, D as DateField, c as Field, p as FieldKind, a as FieldPath, q as FieldValue, r as FileField, s as FileValue, t as ImageFocus, O as OptionValue, P as ParsedContent, f as RecordOf, u as ReferenceField, v as ReferencesField, w as RichBlock, x as RichLine, y as RichSpan, R as RichText, V as ValueOf, z as asOneParagraph, A as choice, B as choices, E as collection, H as countCharacters, J as date, K as defaultContent, M as defaultValue, Q as defineSchema, W as file, X as formatFieldPath, Y as group, Z as image, _ as linesOf, $ as link, a0 as normalizedLine, a1 as number, a2 as parseContent, a3 as plainTextOf, a4 as readRichText, a5 as reference, a6 as references, a7 as richText, a8 as richTextOf, a9 as slug, aa as text, ab as time, ac as toggle, ad as url } from './parse-content-CT2cUVL-.js';
3
+ import { R as RequestForm } from './site-description-cKiFtNHW.js';
4
+ export { C as CollectionPath, D as DEFAULT_LONG_TEXT_LENGTH, b as DEFAULT_TEXT_LENGTH, F as FIELD_PATH_SEPARATOR, c as FieldTarget, d as FieldsReading, H as HOME_PAGE_PATH, M as MAX_REQUEST_FIELD_LENGTH, P as PAGE_PATH_SEPARATOR, e as PageProblemReason, f as PlacedRecord, g as RECORD_PLACEHOLDER, h as RecordFieldsAt, i as RecordPagePath, j as RecordPageProblemReason, k as RecordPages, l as RequestChoiceField, m as RequestEmailField, n as RequestField, o as RequestFieldKind, p as RequestFields, q as RequestFormProblemReason, r as RequestFormReading, s as RequestLongTextField, t as RequestPhoneField, u as RequestTextField, v as SITE_DESCRIPTION_PATH, w as SchemaProblem, x as SchemaProblemReason, S as SiteDescription, y as SiteDescriptionProblem, z as SiteDescriptionReading, A as SitePageDescription, B as SiteRecordPageDescription, a as SiteRecordPages, E as checkFields, G as checkSiteDescription, I as isFormId, J as isRecordPagePath, K as isSearchTextsGroup, L as maxLengthOf, N as readFields, O as readRequestForm, Q as readSiteDescription, T as recordAddressOf, U as recordAt, V as recordPageAt, W as recordPagePath, X as recordPages, Y as requestChoice, Z as requestEmail, _ as requestForm, $ as requestLongText, a0 as requestPhone, a1 as requestText, a2 as resolveFieldPath } from './site-description-cKiFtNHW.js';
5
5
 
6
6
  declare const FIELD_PATH_ATTRIBUTE = "data-cms-path";
7
7
  interface FieldMarker {
package/dist/schema.js CHANGED
@@ -39,6 +39,7 @@ import {
39
39
  defaultValue,
40
40
  defineSchema,
41
41
  editable,
42
+ file,
42
43
  findRecord,
43
44
  formatFieldPath,
44
45
  group,
@@ -104,7 +105,7 @@ import {
104
105
  toggle,
105
106
  url,
106
107
  withRecordIds
107
- } from "./chunk-ENMUO442.js";
108
+ } from "./chunk-TMN7KG5M.js";
108
109
  export {
109
110
  CONSENT_REQUIRED_TEXT,
110
111
  DEFAULT_LONG_TEXT_LENGTH,
@@ -146,6 +147,7 @@ export {
146
147
  defaultValue,
147
148
  defineSchema,
148
149
  editable,
150
+ file,
149
151
  findRecord,
150
152
  formatFieldPath,
151
153
  group,
@@ -1,4 +1,4 @@
1
- import { a as FieldPath, c as Field, d as CollectionField, F as Fields, G as GroupField, C as Content, e as RecordFields, f as RecordOf, g as ContentIssue } from './parse-content-Bnn6Wa-l.js';
1
+ import { a as FieldPath, c as Field, d as CollectionField, F as Fields, G as GroupField, C as Content, e as RecordFields, f as RecordOf, g as ContentIssue } from './parse-content-CT2cUVL-.js';
2
2
 
3
3
  /** What a path written on a page points at: a field, or a whole record of a collection. */
4
4
  type FieldTarget = {
package/dist/site.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ImageMetadata } from 'astro';
2
2
  import { AstroComponentFactory } from 'astro/runtime/server/index.js';
3
- import { C as Content, F as Fields, b as ContentOf } from './parse-content-Bnn6Wa-l.js';
4
- import { a as SiteRecordPages, S as SiteDescription, R as RequestForm } from './site-description-DSHyBrAL.js';
3
+ import { C as Content, F as Fields, b as ContentOf } from './parse-content-CT2cUVL-.js';
4
+ import { a as SiteRecordPages, S as SiteDescription, R as RequestForm } from './site-description-cKiFtNHW.js';
5
5
 
6
6
  /** A page of the site: how the editor names it, and the component that renders it. */
7
7
  interface SeamletPage {
package/dist/site.js CHANGED
@@ -6,12 +6,12 @@ import {
6
6
  previewedPageAt,
7
7
  renderedPageAt,
8
8
  staticPagesOf
9
- } from "./chunk-VQKAWFCQ.js";
9
+ } from "./chunk-ULOKDC6D.js";
10
10
  import {
11
11
  checkSiteDescription,
12
12
  formatFieldPath,
13
13
  parseContent
14
- } from "./chunk-ENMUO442.js";
14
+ } from "./chunk-TMN7KG5M.js";
15
15
 
16
16
  // src/site.ts
17
17
  import { cmsOrigin, siteId, siteTitle } from "virtual:seamlet/config";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamlet/astro",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Connects an Astro site to the Seamlet CMS: the schema of its content, the preview the editor frames, and its published content.",
5
5
  "license": "MIT",
6
6
  "type": "module",