ampless 1.0.0-alpha.49 → 1.0.0-alpha.50

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
@@ -1933,6 +1933,17 @@ declare function resolvePluginSettings(manifest: PluginSettingsManifest | undefi
1933
1933
  */
1934
1934
  declare function extractFirstImageUrl(post: Post): string | null;
1935
1935
 
1936
+ type PostListStatusFilter = 'all' | 'draft' | 'published';
1937
+ type PostListSort = 'updated-desc' | 'updated-asc' | 'published-desc' | 'published-asc' | 'title-asc' | 'title-desc';
1938
+ interface PostListFilterOptions {
1939
+ query?: string;
1940
+ status?: PostListStatusFilter;
1941
+ tag?: string;
1942
+ sort?: PostListSort;
1943
+ }
1944
+ declare function filterSortPostSummaries<T extends PostSummary>(rows: readonly T[], options?: PostListFilterOptions): T[];
1945
+ declare function collectTags(rows: readonly PostSummary[]): Map<string, number>;
1946
+
1936
1947
  /**
1937
1948
  * Pure helpers for `format: 'static'` post bundles. Kept platform-free
1938
1949
  * (no `File`, no Amplify Storage, no AWS SDK) so both the browser admin
@@ -2023,4 +2034,4 @@ declare function pickDefaultEntrypoint(files: readonly {
2023
2034
 
2024
2035
  declare const VERSION = "0.0.1";
2025
2036
 
2026
- export { type AmplessEvent, type AmplessPlugin, type AuthContext, type BundleExtractResult, type CacheConfig, type CacheStrategy, type Config, type ContentEventPayload, type ContentEventType, type ContentFieldRenderer, type ContentFormat, type ContentTypeDefinition, type CreatePostInput, DEFAULT_ENTRYPOINT, type DateFormat, type EventPayloadOf, type EventType, type ExtractedFile, type FieldDefinition, type FieldType, type HistoryConfig, type ImageDisplay, type KvItem, type KvStore, type LinkListItem, type ListOptions, type ListPostHistoryOptions, type LocalizedString, MAX_BUNDLE_BYTES, type MarkdownEmbedMatch, type Media, type MediaEventPayload, type MediaEventType, type MediaMetadata, type MediaProcessingDefaults, type OgImageConfig, type OgImageFont, type OgImageRenderContext, PLUGIN_KEY_PATTERN, type Page, type PluginBooleanField, type PluginCapability, type PluginCodeField, type PluginEventHandler, type PluginHookResult, type PluginJsonField, type PluginMetadata, type PluginNumberField, type PluginPackageManifest, type PluginPublicRenderContext, type PluginRepeatableField, type PluginRepeatableSubField, type PluginRuntimeContext, type PluginSecretField, type PluginSelectField, type PluginSettingField, type PluginSettingsManifest, type PluginTextField, type PluginTextareaField, type PluginUninstallContext, type PluginUrlField, type Post, type PostIndexEventPayload, type PostIndexEventType, type PostMetadata, type PostRevision, type PostRevisionConnection, type PostStatus, type PostSummary, type PostsProvider, type PublicBodyDescriptor, type PublicHeadDescriptor, type PublicPostBodyDescriptor, type PublicPostHtmlDescriptor, type PublicPostHtmlPosition, type PublicPostScriptDescriptor, type Role, SITE_CONFIG_PK, type ScriptStrategy, type SiteSettingsEventPayload, type SiteSettingsEventType, type StaticPostBody, type StaticPostFileMeta, type StreamEventName, type SummaryListOptions, TEXT_EXTENSIONS, type ThemeColorField, type ThemeField, type ThemeFieldType, type ThemeFontFamilyField, type ThemeImageField, type ThemeLengthField, type ThemeLinkListField, type ThemeManifest, type ThemeModule, type ThemeRouteContext, type ThemeSelectField, type ThemeTextField, type TiptapNodeHtmlAdapters, type TiptapNodeMarkdownAdapters, type TiptapNodeToHtml, type TiptapNodeToMarkdown, type TiptapRenderNode, type TrustLevel, type TrustedPluginRuntimeContext, VERSION, type ValidationIssue, bundlePrefix, createPost, decodeAwsJson, defineConfig, definePlugin, defineSchema, defineTheme, defineThemeModule, deletePost, deleteSiteSetting, detectContentEvents, encodeAwsJson, escapeXml, extractFirstImageUrl, findAbsolutePathRefs, flattenSettings, formatColorPair, formatDate, formatPublicAssetUrl, getKvStore, getPost, getPostById, getSiteSetting, hasKvStore, hasPostsProvider, isTagListUrl, isValidPluginKey, listPostHistory, listPostSummaries, listPosts, listSiteSettings, mimeTypeFor, parseColorPair, parseLinkList, pickDefaultEntrypoint, resolveLocalized, resolvePluginSettings, resolveThemeValues, setKvStore, setPostsProvider, setSiteSetting, stringifyLinkList, stripCommonPrefix, themeSettingKey, unflattenSettings, updatePost, validateBundle, validateBundlePath, validatePluginSettingValue, validatePublicAssetKey, validateThemeValue };
2037
+ export { type AmplessEvent, type AmplessPlugin, type AuthContext, type BundleExtractResult, type CacheConfig, type CacheStrategy, type Config, type ContentEventPayload, type ContentEventType, type ContentFieldRenderer, type ContentFormat, type ContentTypeDefinition, type CreatePostInput, DEFAULT_ENTRYPOINT, type DateFormat, type EventPayloadOf, type EventType, type ExtractedFile, type FieldDefinition, type FieldType, type HistoryConfig, type ImageDisplay, type KvItem, type KvStore, type LinkListItem, type ListOptions, type ListPostHistoryOptions, type LocalizedString, MAX_BUNDLE_BYTES, type MarkdownEmbedMatch, type Media, type MediaEventPayload, type MediaEventType, type MediaMetadata, type MediaProcessingDefaults, type OgImageConfig, type OgImageFont, type OgImageRenderContext, PLUGIN_KEY_PATTERN, type Page, type PluginBooleanField, type PluginCapability, type PluginCodeField, type PluginEventHandler, type PluginHookResult, type PluginJsonField, type PluginMetadata, type PluginNumberField, type PluginPackageManifest, type PluginPublicRenderContext, type PluginRepeatableField, type PluginRepeatableSubField, type PluginRuntimeContext, type PluginSecretField, type PluginSelectField, type PluginSettingField, type PluginSettingsManifest, type PluginTextField, type PluginTextareaField, type PluginUninstallContext, type PluginUrlField, type Post, type PostIndexEventPayload, type PostIndexEventType, type PostListFilterOptions, type PostListSort, type PostListStatusFilter, type PostMetadata, type PostRevision, type PostRevisionConnection, type PostStatus, type PostSummary, type PostsProvider, type PublicBodyDescriptor, type PublicHeadDescriptor, type PublicPostBodyDescriptor, type PublicPostHtmlDescriptor, type PublicPostHtmlPosition, type PublicPostScriptDescriptor, type Role, SITE_CONFIG_PK, type ScriptStrategy, type SiteSettingsEventPayload, type SiteSettingsEventType, type StaticPostBody, type StaticPostFileMeta, type StreamEventName, type SummaryListOptions, TEXT_EXTENSIONS, type ThemeColorField, type ThemeField, type ThemeFieldType, type ThemeFontFamilyField, type ThemeImageField, type ThemeLengthField, type ThemeLinkListField, type ThemeManifest, type ThemeModule, type ThemeRouteContext, type ThemeSelectField, type ThemeTextField, type TiptapNodeHtmlAdapters, type TiptapNodeMarkdownAdapters, type TiptapNodeToHtml, type TiptapNodeToMarkdown, type TiptapRenderNode, type TrustLevel, type TrustedPluginRuntimeContext, VERSION, type ValidationIssue, bundlePrefix, collectTags, createPost, decodeAwsJson, defineConfig, definePlugin, defineSchema, defineTheme, defineThemeModule, deletePost, deleteSiteSetting, detectContentEvents, encodeAwsJson, escapeXml, extractFirstImageUrl, filterSortPostSummaries, findAbsolutePathRefs, flattenSettings, formatColorPair, formatDate, formatPublicAssetUrl, getKvStore, getPost, getPostById, getSiteSetting, hasKvStore, hasPostsProvider, isTagListUrl, isValidPluginKey, listPostHistory, listPostSummaries, listPosts, listSiteSettings, mimeTypeFor, parseColorPair, parseLinkList, pickDefaultEntrypoint, resolveLocalized, resolvePluginSettings, resolveThemeValues, setKvStore, setPostsProvider, setSiteSetting, stringifyLinkList, stripCommonPrefix, themeSettingKey, unflattenSettings, updatePost, validateBundle, validateBundlePath, validatePluginSettingValue, validatePublicAssetKey, validateThemeValue };
package/dist/index.js CHANGED
@@ -491,6 +491,53 @@ function findHtmlImage(body) {
491
491
  return m ? m[1] : null;
492
492
  }
493
493
 
494
+ // src/post-list-filter.ts
495
+ function filterSortPostSummaries(rows, options = {}) {
496
+ const query = options.query?.trim().toLowerCase() ?? "";
497
+ const status = options.status ?? "all";
498
+ const tag = options.tag ?? "";
499
+ const sort = options.sort ?? "updated-desc";
500
+ return rows.filter((row) => {
501
+ if (status !== "all" && row.status !== status) return false;
502
+ if (tag && !row.tags.includes(tag)) return false;
503
+ if (!query) return true;
504
+ return row.title.toLowerCase().includes(query) || row.slug.toLowerCase().includes(query) || row.tags.some((t) => t.toLowerCase().includes(query));
505
+ }).sort((a, b) => compareRows(a, b, sort));
506
+ }
507
+ function collectTags(rows) {
508
+ const counts = /* @__PURE__ */ new Map();
509
+ for (const row of rows) {
510
+ for (const tag of row.tags) {
511
+ const trimmed = tag.trim();
512
+ if (!trimmed) continue;
513
+ counts.set(trimmed, (counts.get(trimmed) ?? 0) + 1);
514
+ }
515
+ }
516
+ return new Map([...counts.entries()].sort(([a], [b]) => a.localeCompare(b)));
517
+ }
518
+ function compareRows(a, b, sort) {
519
+ switch (sort) {
520
+ case "updated-asc":
521
+ return compareOptionalIso(a.updatedAt, b.updatedAt, "asc");
522
+ case "updated-desc":
523
+ return compareOptionalIso(a.updatedAt, b.updatedAt, "desc");
524
+ case "published-asc":
525
+ return compareOptionalIso(a.publishedAt, b.publishedAt, "asc");
526
+ case "published-desc":
527
+ return compareOptionalIso(a.publishedAt, b.publishedAt, "desc");
528
+ case "title-desc":
529
+ return b.title.localeCompare(a.title);
530
+ case "title-asc":
531
+ return a.title.localeCompare(b.title);
532
+ }
533
+ }
534
+ function compareOptionalIso(a, b, direction) {
535
+ if (!a && !b) return 0;
536
+ if (!a) return 1;
537
+ if (!b) return -1;
538
+ return direction === "asc" ? a.localeCompare(b) : b.localeCompare(a);
539
+ }
540
+
494
541
  // src/static-bundle.ts
495
542
  var DEFAULT_ENTRYPOINT = "index.html";
496
543
  var MAX_BUNDLE_BYTES = 50 * 1024 * 1024;
@@ -802,6 +849,7 @@ export {
802
849
  TEXT_EXTENSIONS,
803
850
  VERSION,
804
851
  bundlePrefix,
852
+ collectTags,
805
853
  createPost,
806
854
  decodeAwsJson,
807
855
  defineConfig,
@@ -815,6 +863,7 @@ export {
815
863
  encodeAwsJson,
816
864
  escapeXml,
817
865
  extractFirstImageUrl,
866
+ filterSortPostSummaries,
818
867
  findAbsolutePathRefs,
819
868
  flattenSettings,
820
869
  formatColorPair,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ampless",
3
- "version": "1.0.0-alpha.49",
3
+ "version": "1.0.0-alpha.50",
4
4
  "description": "Serverless CMS for AWS Amplify",
5
5
  "license": "MIT",
6
6
  "type": "module",