ampless 1.0.0-beta.52 → 1.0.0-beta.54

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/index.d.ts CHANGED
@@ -17,12 +17,20 @@ type SiteSettingsEventType = 'site.settings.updated';
17
17
  */
18
18
  type PostIndexEventType = 'post.index.refresh';
19
19
  type EventType = ContentEventType | MediaEventType | SiteSettingsEventType | PostIndexEventType;
20
- /** Minimal projection of a Post item carried in events (no body, to keep payloads small). */
20
+ /**
21
+ * Minimal projection of a Post item carried in events (no body, to keep
22
+ * payloads small). `format` / `excerpt` are included so the denormalized
23
+ * PostTag index can render tag-page summaries faithfully — without them the
24
+ * `listPostsByTag` resolver can't know a post's real format and would
25
+ * mislabel non-markdown posts.
26
+ */
21
27
  interface ContentEventPayload {
22
28
  postId: string;
23
29
  slug: string;
24
30
  title: string;
25
31
  status: 'draft' | 'published';
32
+ format?: ContentFormat;
33
+ excerpt?: string;
26
34
  publishedAt?: string;
27
35
  tags?: string[];
28
36
  }
@@ -1829,17 +1837,31 @@ declare function escapeXml(s: string): string;
1829
1837
  *
1830
1838
  * Variable 'body' has an invalid value.
1831
1839
  *
1832
- * On the read side two wire shapes coexist:
1833
- *
1834
- * - JSON-encoded string — what the auto-generated CRUD resolver and
1835
- * custom resolvers usually return.
1836
- * - Native object / Map DynamoDBDocumentClient unmarshals
1837
- * AWSJSON-stored maps straight into JS objects when read directly
1838
- * from DynamoDB (the path used by the trusted processor and the
1839
- * MCP Lambda).
1840
- *
1841
- * `decodeAwsJson` handles both: pass strings through `JSON.parse`,
1842
- * everything else as-is.
1840
+ * On the read side there are two FUNDAMENTALLY DIFFERENT paths, and they
1841
+ * must be handled differently — the value's runtime shape is NOT enough
1842
+ * to disambiguate them:
1843
+ *
1844
+ * 1. GraphQL wire read (auto-generated CRUD resolver, custom resolvers,
1845
+ * raw GraphQL fetch) the value arrives as a JSON-encoded string,
1846
+ * regardless of the underlying type. Use `decodeAwsJson` to parse it
1847
+ * back into the native JS value.
1848
+ *
1849
+ * 2. Direct DynamoDBDocumentClient read (the trusted processor and the
1850
+ * MCP Lambda read straight from DynamoDB) — DocumentClient already
1851
+ * unmarshals AWSJSON-backed attributes into native JS types
1852
+ * (S→string, N→number, BOOL→boolean, M→object). The value is ALREADY
1853
+ * the correct JS type and must be used AS-IS. Do NOT run
1854
+ * `decodeAwsJson` / `JSON.parse` on it.
1855
+ *
1856
+ * Why the distinction is load-bearing: a native scalar STRING from path 2
1857
+ * is indistinguishable, by type alone, from a wire string on path 1. But
1858
+ * `decodeAwsJson("1470")` === `JSON.parse("1470")` === the number `1470`,
1859
+ * so running the decoder on a DocumentClient scalar string silently
1860
+ * double-decodes numeric-looking settings/bodies (this caused a
1861
+ * site-wide 500). The "non-strings pass through unchanged" tolerance of
1862
+ * `decodeAwsJson` does NOT make it safe on DocumentClient reads — scalar
1863
+ * strings are exactly the case it corrupts. Pick the decoder by read PATH,
1864
+ * never by the value's runtime shape.
1843
1865
  */
1844
1866
  /**
1845
1867
  * Serialise a value for an AWSJSON variable. `undefined` / `null` both
@@ -1848,9 +1870,14 @@ declare function escapeXml(s: string): string;
1848
1870
  */
1849
1871
  declare function encodeAwsJson(value: unknown): string;
1850
1872
  /**
1851
- * Deserialise an AWSJSON value from a GraphQL / DynamoDB read.
1852
- * Tolerates both the wire-string shape and the auto-unmarshalled
1853
- * native value. Throws if the string is not valid JSON.
1873
+ * Deserialise an AWSJSON value from a GraphQL wire read (path 1 above).
1874
+ * Non-string inputs pass through unchanged; strings go through
1875
+ * `JSON.parse` and throw if not valid JSON.
1876
+ *
1877
+ * Only call this on values read over the GraphQL wire. Do NOT call it on
1878
+ * values read directly via DynamoDBDocumentClient — those are already
1879
+ * native JS types, and a native scalar string (e.g. "1470") would be
1880
+ * double-decoded into a number. See the module doc block above.
1854
1881
  */
1855
1882
  declare function decodeAwsJson(value: unknown): unknown;
1856
1883
 
package/dist/index.js CHANGED
@@ -529,6 +529,11 @@ function compareRows(a, b, sort) {
529
529
  return b.title.localeCompare(a.title);
530
530
  case "title-asc":
531
531
  return a.title.localeCompare(b.title);
532
+ default: {
533
+ const _exhaustive = sort;
534
+ void _exhaustive;
535
+ return 0;
536
+ }
532
537
  }
533
538
  }
534
539
  function compareOptionalIso(a, b, direction) {
@@ -766,6 +771,11 @@ function validateThemeValue(field, raw) {
766
771
  const sanitized = v.replace(/[\x00-\x1f<>]/g, "");
767
772
  return sanitized.length <= max ? sanitized : sanitized.slice(0, max);
768
773
  }
774
+ default: {
775
+ const _exhaustive = field;
776
+ void _exhaustive;
777
+ return null;
778
+ }
769
779
  }
770
780
  }
771
781
  var DANGEROUS_URL_RE = /^\s*(javascript|data|vbscript):/i;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ampless",
3
- "version": "1.0.0-beta.52",
3
+ "version": "1.0.0-beta.54",
4
4
  "description": "Serverless CMS for AWS Amplify",
5
5
  "license": "MIT",
6
6
  "type": "module",