dineway 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +89 -0
  3. package/dist/adapters-BlzWJG82.d.mts +106 -0
  4. package/dist/apply-CAPvMfoU.mjs +1339 -0
  5. package/dist/astro/index.d.mts +50 -0
  6. package/dist/astro/index.mjs +1326 -0
  7. package/dist/astro/middleware/auth.d.mts +30 -0
  8. package/dist/astro/middleware/auth.mjs +708 -0
  9. package/dist/astro/middleware/redirect.d.mts +21 -0
  10. package/dist/astro/middleware/redirect.mjs +62 -0
  11. package/dist/astro/middleware/request-context.d.mts +17 -0
  12. package/dist/astro/middleware/request-context.mjs +1371 -0
  13. package/dist/astro/middleware/setup.d.mts +19 -0
  14. package/dist/astro/middleware/setup.mjs +46 -0
  15. package/dist/astro/middleware.d.mts +12 -0
  16. package/dist/astro/middleware.mjs +1716 -0
  17. package/dist/astro/types.d.mts +269 -0
  18. package/dist/astro/types.mjs +1 -0
  19. package/dist/base64-F8-DUraK.mjs +58 -0
  20. package/dist/byline-DeWCMU_i.mjs +234 -0
  21. package/dist/bylines-DyqBV9EQ.mjs +137 -0
  22. package/dist/chunk-ClPoSABd.mjs +21 -0
  23. package/dist/cli/index.d.mts +1 -0
  24. package/dist/cli/index.mjs +3987 -0
  25. package/dist/client/external-auth-headers.d.mts +38 -0
  26. package/dist/client/external-auth-headers.mjs +101 -0
  27. package/dist/client/index.d.mts +397 -0
  28. package/dist/client/index.mjs +345 -0
  29. package/dist/config-Cq8H0SfX.mjs +46 -0
  30. package/dist/connection-C9pxzuag.mjs +52 -0
  31. package/dist/content-zSgdNmnt.mjs +836 -0
  32. package/dist/db/index.d.mts +4 -0
  33. package/dist/db/index.mjs +62 -0
  34. package/dist/db/libsql.d.mts +10 -0
  35. package/dist/db/libsql.mjs +21 -0
  36. package/dist/db/postgres.d.mts +10 -0
  37. package/dist/db/postgres.mjs +29 -0
  38. package/dist/db/sqlite.d.mts +10 -0
  39. package/dist/db/sqlite.mjs +15 -0
  40. package/dist/default-WYlzADZL.mjs +80 -0
  41. package/dist/dialect-helpers-B9uSp2GJ.mjs +89 -0
  42. package/dist/error-DrxtnGPg.mjs +26 -0
  43. package/dist/index-C-jx21qs.d.mts +4771 -0
  44. package/dist/index.d.mts +16 -0
  45. package/dist/index.mjs +30 -0
  46. package/dist/load-C6FCD1FU.mjs +27 -0
  47. package/dist/loader-qKmo0wAY.mjs +446 -0
  48. package/dist/manifest-schema-CTSEyIJ3.mjs +186 -0
  49. package/dist/media/index.d.mts +25 -0
  50. package/dist/media/index.mjs +54 -0
  51. package/dist/media/local-runtime.d.mts +38 -0
  52. package/dist/media/local-runtime.mjs +132 -0
  53. package/dist/media-DMTr80Gv.mjs +199 -0
  54. package/dist/mode-BlyYtIFO.mjs +22 -0
  55. package/dist/page/index.d.mts +148 -0
  56. package/dist/page/index.mjs +419 -0
  57. package/dist/placeholder-B3knXwNc.mjs +267 -0
  58. package/dist/placeholder-bOx1xCTY.d.mts +283 -0
  59. package/dist/plugin-utils.d.mts +57 -0
  60. package/dist/plugin-utils.mjs +77 -0
  61. package/dist/plugins/adapt-sandbox-entry.d.mts +21 -0
  62. package/dist/plugins/adapt-sandbox-entry.mjs +112 -0
  63. package/dist/query-BiaPl_g2.mjs +459 -0
  64. package/dist/redirect-JPqLAbxa.mjs +328 -0
  65. package/dist/registry-DSd1GWB8.mjs +851 -0
  66. package/dist/request-context.d.mts +49 -0
  67. package/dist/request-context.mjs +42 -0
  68. package/dist/runner-B5l1JfOj.d.mts +26 -0
  69. package/dist/runner-BGUGywgG.mjs +1529 -0
  70. package/dist/runtime.d.mts +25 -0
  71. package/dist/runtime.mjs +41 -0
  72. package/dist/search-BNruJHDL.mjs +11054 -0
  73. package/dist/seed/index.d.mts +3 -0
  74. package/dist/seed/index.mjs +15 -0
  75. package/dist/seo/index.d.mts +69 -0
  76. package/dist/seo/index.mjs +69 -0
  77. package/dist/storage/local.d.mts +38 -0
  78. package/dist/storage/local.mjs +165 -0
  79. package/dist/storage/s3.d.mts +31 -0
  80. package/dist/storage/s3.mjs +174 -0
  81. package/dist/tokens-4vgYuXsZ.mjs +170 -0
  82. package/dist/transport-C5FYnid7.mjs +417 -0
  83. package/dist/transport-gIL-e43D.d.mts +41 -0
  84. package/dist/types-BawVha09.mjs +30 -0
  85. package/dist/types-BgQeVaPj.d.mts +192 -0
  86. package/dist/types-CLLdsG3g.d.mts +103 -0
  87. package/dist/types-D38djUXv.d.mts +1196 -0
  88. package/dist/types-DShnjzb6.mjs +15 -0
  89. package/dist/types-DkvMXalq.d.mts +425 -0
  90. package/dist/types-DuNbGKjF.mjs +74 -0
  91. package/dist/types-ju-_ORz7.d.mts +182 -0
  92. package/dist/validate-CXnRKfJK.mjs +327 -0
  93. package/dist/validate-CqRJb_xU.mjs +96 -0
  94. package/dist/validate-DVKJJ-M_.d.mts +377 -0
  95. package/locals.d.ts +47 -0
  96. package/package.json +313 -0
@@ -0,0 +1,16 @@
1
+ import { _ as MediaValue, n as generatePlaceholder, r as normalizeMediaValue, t as PlaceholderData } from "./placeholder-bOx1xCTY.mjs";
2
+ import { n as MediaTable, r as UserTable, t as Database } from "./types-DkvMXalq.mjs";
3
+ import { $ as GetCommentsOptions, $i as ManifestResponse, $n as SessionDatabaseFactory, $r as SandboxEmailMessage, $t as OAuthInput, A as getEntryTerms, Ai as handleContentCountScheduled, An as AuthProviderModule, Ar as getTranslations, At as wordpressRestSource, B as UpdateTermInput, Bi as handleContentPermanentDelete, Bn as WxrTag, Br as hashString, Bt as importReusableBlocksAsSections, C as ReorderWidgetsInput, Ci as RevisionListResponse, Cr as InferCollectionData, Ct as GeneratePreviewTokenOptions, D as WidgetComponentDef, Di as handleRevisionRestore, Dr as getDinewayCollection, Dt as generatePreviewToken, E as WidgetArea, Ei as handleRevisionList, Er as TranslationsResult, Et as VerifyPreviewTokenResult, F as getTermsForEntries, Fi as handleContentDuplicate, Fn as WxrAuthor, Fr as createEditable, Ft as getFileSources, G as CreateMenuInput, Gi as handleContentUnpublish, Gn as EntryFilter, Gr as PortableTextLinkMark, Gt as FileInput, H as getBylineBySlug, Hi as handleContentRestore, Hn as parseWxrString, Hr as prosemirrorToPortableText, Ht as CollectionSchemaStatus, I as CreateTermInput, Ii as handleContentGet, In as WxrCategory, Ir as createNoop, It as getSource, J as MenuItem, Ji as ApiContext, Jn as FilePreviewMiddlewareConfig, Jr as PortableTextTextBlock, Jt as ImportContext, K as CreateMenuItemInput, Ki as handleContentUnschedule, Kr as PortableTextMarkDef, Kt as ImportAnalysis, L as TaxonomyDef, Li as handleContentGetIncludingTrashed, Ln as WxrData, Lr as isSafeHref, Lt as getUrlSources, M as getTaxonomyDefs, Mi as handleContentCreate, Mn as ExternalAuthConfig, Mr as CMSAnnotation, Mt as wxrSource, N as getTaxonomyTerms, Ni as handleContentDelete, Nn as definePlugin, Nr as EditProxy, Nt as clearSources, O as WidgetType, Oi as generateManifest, Or as getDinewayEntry, Ot as parseContentId, P as getTerm, Pi as handleContentDiscardDraft, Pn as WxrAttachment, Pr as FieldAnnotation, Pt as getAllSources, Q as UpdateMenuItemInput, Qi as ListResponse, Qn as SessionCleanupResult, Qr as ProseMirrorNode, Qt as NormalizedItem, R as TaxonomyTerm, Ri as handleContentList, Rn as WxrPost, Rr as sanitizeHref, Rt as probeUrl, S as PropDef, Si as handleMediaUpdate, Sn as pluginManifestSchema, Sr as EntryResult, St as getPreviewUrl, T as Widget, Ti as handleRevisionGet, Tr as TranslationSummary, Tt as VerifyPreviewTokenOptions, U as getMenu, Ui as handleContentSchedule, Un as CollectionFilter$1, Ur as PortableTextCodeBlock, Ut as FetchOptions, V as getByline, Vi as handleContentPublish, Vn as parseWxr, Vr as portableTextToProsemirror, Vt as AttachmentInfo, W as getMenus, Wi as handleContentTranslations, Wn as EntryData, Wr as PortableTextImageBlock, Wt as FieldCompatibility, X as ReorderMenuItemsInput, Xi as ContentResponse, Xn as FileSessionDatabaseFactory, Xr as ProseMirrorDocument, Xt as ImportResult, Y as MenuItemType, Yi as ContentListResponse, Yn as createFilePreviewMiddleware, Yr as PortableTextUnknownBlock, Yt as ImportFieldDef, Z as UpdateMenuInput, Zi as FieldDescriptor, Zn as FileSessionDatabaseFactoryOptions, Zr as ProseMirrorMark, Zt as ImportSource, _ as getWidgetArea, _i as MediaResponse, _r as CollectionFilter, _t as isBlockedInPreview, a as search, aa as FileValue, ai as SerializedRequest, an as SourceInput, ar as PreviewSidecarClient, at as getSiteSetting, b as CreateWidgetAreaInput, bi as handleMediaGet, bn as createHookPipeline, br as DinewayCollections, bt as GetPreviewUrlOptions, c as FTSManager, ca as CreateMediaInput, ci as CreateSectionInput, cn as UrlInput, cr as defaultPreviewSidecarClient, ct as PreviewToolbarConfig, d as SearchOptions, da as ContentRepository, di as SectionSource, dn as NoopSandboxRunner, dr as verifyPreviewSignature, dt as ApplySnapshotToDatabaseOptions, ea as portableText, ei as SandboxEmailSendCallback, en as PostTypeAnalysis, er as SessionDatabaseHandle, et as GetCommentsResult, f as SearchResponse, fa as DatabaseConfig, fi as UpdateSectionInput, fn as SandboxNotAvailableError, fr as I18nConfig, ft as applySnapshotToDatabase, g as Suggestion, gi as MediaListResponse, gn as PluginRouteError, gr as CacheHint, gt as renderPreviewLoadingPage, h as SuggestOptions, hi as SchemaRegistry, hn as createPluginManager, hr as isI18nEnabled, ht as Snapshot, i as getSuggestions, ia as FieldUIHints, ii as SandboxedPlugin, in as SourceCapabilities, ir as SessionOpenOrCreateOptions, it as getPluginSettings, j as getTaxonomyDef, ji as handleContentCountTrashed, jn as AuthResult, jr as resolveDinewayPath, jt as parseWxrDate, k as getEntriesByTerm, ki as handleContentCompare, kn as AuthDescriptor, kr as getEditMeta, kt as verifyPreviewToken, l as CollectionSearchOptions, la as MediaItem, li as GetSectionsOptions, ln as NodeSandboxRunner, lr as parsePreviewSignatureHeader, lt as renderPreviewToolbar, m as SearchStats, mi as SchemaError, mn as PluginManager, mr as getI18nConfig, mt as getAppliedSnapshotMeta, n as extractSearchableFields, na as image, ni as SandboxRunner, nn as ProbeResult, nr as SessionDatabaseLimitError, nt as getComments, o as searchCollection, oa as ImageValue, oi as getSection, on as SourceProbeResult, or as PreviewSidecarSignature, ot as getSiteSettings, p as SearchResult, pa as DinewayDatabaseError, pi as getCollectionInfo, pn as createNoopSandboxRunner, pr as getFallbackChain, pt as dropSessionDatabaseTables, q as Menu, qi as handleContentUpdate, qr as PortableTextSpan, qt as ImportConfig, r as getSearchStats, ra as FieldDefinition, ri as SandboxRunnerFactory, rn as SourceAuth, rr as SessionOpenOptions, rt as getPluginSetting, s as searchWithDb, sa as PortableTextBlock, si as getSections, sn as SuggestedAction, sr as buildPreviewSignatureHeader, st as setSiteSettings, t as extractPlainText, ta as reference, ti as SandboxOptions, tn as PostTypeMapping, tr as SessionDatabaseInfo, tt as getCommentCount, u as SearchConfig, ua as MediaRepository, ui as Section, un as createNodeSandboxRunner, ur as signPreviewUrl, ut as AppliedSnapshotMeta, v as getWidgetAreas, vi as handleMediaCreate, vn as HookPipeline, vr as CollectionResult, vt as getPreviewToken, w as UpdateWidgetInput, wi as RevisionResponse, wn as PluginDescriptor, wr as ResolvePathResult, wt as PreviewTokenPayload, x as CreateWidgetInput, xi as handleMediaList, xn as ValidatedPluginManifest, xr as EditFieldMeta, xt as buildPreviewUrl, y as getWidgetComponents, yi as handleMediaDelete, yn as HookResult, yr as ContentEntry, yt as isPreviewRequest, z as TaxonomyTermRow, zi as handleContentListTrashed, zn as WxrSite, zr as computeContentHash, zt as registerSource } from "./index-C-jx21qs.mjs";
4
+ import { n as getMigrationStatus, t as MigrationStatus } from "./runner-B5l1JfOj.mjs";
5
+ import { a as ContentSeoInput, c as FindManyOptions, i as ContentSeo, l as FindManyResult, n as ContentBylineCredit, o as CreateContentInput, r as ContentItem, s as DinewayValidationError, t as BylineSummary, u as UpdateContentInput } from "./types-CLLdsG3g.mjs";
6
+ import { $ as StandardPluginDefinition, A as PageMetadataHandler, B as PluginManifest, C as MediaUploadEvent, D as PageFragmentHandler, E as PageFragmentEvent, F as PluginAdminPage, G as PublicPageContext, H as PluginStorageConfig, I as PluginCapability, J as ResolvedPlugin, L as PluginContext, M as PagePlacement, N as PluginAdminConfig, O as PageMetadataContribution, P as PluginAdminExports, Q as StandardHookHandler, R as PluginDefinition, T as PageFragmentContribution, U as PortableTextBlockConfig, V as PluginRoute, W as PortableTextBlockField, X as RouteContext, Y as ResolvedPluginHooks, Z as StandardHookEntry, _ as HookName, a as CommentAfterModerateEvent, b as LogAccess, c as CommentBeforeCreateHandler, d as ContentAccess, et as StandardRouteEntry, f as ContentHookEvent, g as HookConfig, h as FieldWidgetConfig, i as CommentAfterCreateHandler, it as isStandardPluginDefinition, k as PageMetadataEvent, l as CommentModerateEvent, n as CollectionCommentSettings, nt as StorageCollection, o as CommentAfterModerateHandler, q as ResolvedHook, r as CommentAfterCreateEvent, rt as StoredComment, s as CommentBeforeCreateEvent, t as BreadcrumbItem, tt as StandardRouteHandler, u as CommentModerateHandler, v as HttpAccess, w as ModerationDecision, x as MediaAccess, y as KVAccess, z as PluginHooks } from "./types-D38djUXv.mjs";
7
+ import { a as ColumnType, c as FIELD_TYPE_TO_COLUMN, d as FieldValidation, f as FieldWidgetOptions, g as UpdateFieldInput, h as UpdateCollectionInput, i as CollectionWithFields, l as Field, m as RESERVED_FIELD_SLUGS, n as CollectionSource, o as CreateCollectionInput, p as RESERVED_COLLECTION_SLUGS, r as CollectionSupport, s as CreateFieldInput, t as Collection, u as FieldType } from "./types-BgQeVaPj.mjs";
8
+ import { C as SiteSettingKey, S as SeoSettings, _ as SeedTaxonomyTerm, a as applySeed, b as ValidationResult, c as SeedCollection, d as SeedFile, f as SeedMenu, g as SeedTaxonomy, l as SeedContentEntry, o as SeedApplyOptions, p as SeedMenuItem, s as SeedApplyResult, t as validateSeed, u as SeedField, v as SeedWidget, w as SiteSettings, x as MediaReference, y as SeedWidgetArea } from "./validate-DVKJJ-M_.mjs";
9
+ import { a as ListOptions, c as S3StorageConfig, d as Storage, f as StorageDescriptor, i as FileInfo, l as SignedUploadOptions, n as DinewayStorageError, o as ListResult, p as UploadResult, r as DownloadResult, s as LocalStorageConfig, t as CreateStorageFn, u as SignedUploadUrl } from "./types-ju-_ORz7.mjs";
10
+ import { DinewayRequestContext, getRequestContext, runWithContext } from "./request-context.mjs";
11
+ import { a as SqliteConfig, i as PostgresConfig, n as DatabaseDialectType, r as LibsqlConfig, t as DatabaseDescriptor } from "./adapters-BlzWJG82.mjs";
12
+ import { adaptSandboxEntry } from "./plugins/adapt-sandbox-entry.mjs";
13
+ import { SeoMeta, SeoMetaOptions, getContentSeo, getSeoMeta } from "./seo/index.mjs";
14
+ import "./seed/index.mjs";
15
+ import { ulid } from "ulidx";
16
+ export { type ApiContext, type AppliedSnapshotMeta, type ApplySnapshotToDatabaseOptions, type AttachmentInfo, type AuthDescriptor, type AuthProviderModule, type AuthResult, type BreadcrumbItem, type BylineSummary, type CMSAnnotation, type CacheHint, type Collection, type CollectionCommentSettings, type CollectionFilter, type CollectionResult, type CollectionSchemaStatus, type CollectionSearchOptions, type CollectionSource, type CollectionSupport, type CollectionWithFields, type ColumnType, type CommentAfterCreateEvent, type CommentAfterCreateHandler, type CommentAfterModerateEvent, type CommentAfterModerateHandler, type CommentBeforeCreateEvent, type CommentBeforeCreateHandler, type CommentModerateEvent, type CommentModerateHandler, type ContentAccess, type ContentBylineCredit, type ContentEntry, type ContentHookEvent, type ContentItem, type ContentListResponse, ContentRepository, type ContentResponse, type ContentSeo, type ContentSeoInput, type CreateCollectionInput, type CreateContentInput, type CreateFieldInput, type CreateMediaInput, type CreateMenuInput, type CreateMenuItemInput, type CreateSectionInput, type CreateStorageFn, type CreateTermInput, type CreateWidgetAreaInput, type CreateWidgetInput, type Database, type DatabaseConfig, type DatabaseDescriptor, type DatabaseDialectType, type DinewayCollections, DinewayDatabaseError, type DinewayRequestContext, DinewayStorageError, DinewayValidationError, type DownloadResult, type EditFieldMeta, type EditProxy, type EntryData, type EntryFilter, type EntryResult, type ExternalAuthConfig, FIELD_TYPE_TO_COLUMN, FTSManager, type FetchOptions, type Field, type FieldAnnotation, type FieldCompatibility, type FieldDefinition, type FieldDescriptor, type FieldType, type FieldUIHints, type FieldValidation, type FieldWidgetConfig, type FieldWidgetOptions, type FileInfo, type FileInput, type FilePreviewMiddlewareConfig, FileSessionDatabaseFactory, type FileSessionDatabaseFactoryOptions, type FileValue, type FindManyOptions, type FindManyResult, type GeneratePreviewTokenOptions, type GetCommentsOptions, type GetCommentsResult, type GetPreviewUrlOptions, type GetSectionsOptions, type HookConfig, type HookName, HookPipeline, type HookResult, type HttpAccess, type I18nConfig, type ImageValue, type ImportAnalysis, type ImportConfig, type ImportContext, type ImportFieldDef, type ImportResult, type ImportSource, type InferCollectionData, type KVAccess, type LibsqlConfig, type ListOptions, type ListResponse, type ListResult, type CollectionFilter$1 as LoaderCollectionFilter, type LocalStorageConfig, type LogAccess, type ManifestResponse, type MediaAccess, type MediaItem, type MediaListResponse, type MediaReference, MediaRepository, type MediaResponse, type MediaTable, type MediaUploadEvent, type MediaValue, type Menu, type MenuItem, type MenuItemType, type MigrationStatus, type ModerationDecision, NodeSandboxRunner, NoopSandboxRunner, type NormalizedItem, type OAuthInput, type PageFragmentContribution, type PageFragmentEvent, type PageFragmentHandler, type PageMetadataContribution, type PageMetadataEvent, type PageMetadataHandler, type PagePlacement, type PlaceholderData, type PluginAdminConfig, type PluginAdminExports, type PluginAdminPage, type PluginCapability, type PluginContext, type PluginDefinition, type PluginDescriptor, type PluginHooks, PluginManager, type PluginManifest, type PluginRoute, PluginRouteError, type PluginStorageConfig, type PortableTextBlock, type PortableTextBlockConfig, type PortableTextBlockField, type PortableTextCodeBlock, type PortableTextImageBlock, type PortableTextLinkMark, type PortableTextMarkDef, type PortableTextSpan, type PortableTextTextBlock, type PortableTextUnknownBlock, type PostTypeAnalysis, type PostTypeMapping, type PostgresConfig, type PreviewSidecarClient, type PreviewSidecarSignature, type PreviewTokenPayload, type PreviewToolbarConfig, type ProbeResult, type PropDef, type ProseMirrorDocument, type ProseMirrorMark, type ProseMirrorNode, type PublicPageContext, RESERVED_COLLECTION_SLUGS, RESERVED_FIELD_SLUGS, type ReorderMenuItemsInput, type ReorderWidgetsInput, type ResolvePathResult, type ResolvedHook, type ResolvedPlugin, type ResolvedPluginHooks, type RevisionListResponse, type RevisionResponse, type RouteContext, type S3StorageConfig, type SandboxEmailMessage, type SandboxEmailSendCallback, SandboxNotAvailableError, type SandboxOptions, type SandboxRunner, type SandboxRunnerFactory, type SandboxedPlugin, SchemaError, SchemaRegistry, type SearchConfig, type SearchOptions, type SearchResponse, type SearchResult, type SearchStats, type Section, type SectionSource, type SeedApplyOptions, type SeedApplyResult, type SeedCollection, type SeedContentEntry, type SeedField, type SeedFile, type SeedMenu, type SeedMenuItem, type SeedTaxonomy, type SeedTaxonomyTerm, type SeedWidget, type SeedWidgetArea, type SeoMeta, type SeoMetaOptions, type SeoSettings, type SerializedRequest, type SessionCleanupResult, type SessionDatabaseFactory, type SessionDatabaseHandle, type SessionDatabaseInfo, SessionDatabaseLimitError, type SessionOpenOptions, type SessionOpenOrCreateOptions, type SignedUploadOptions, type SignedUploadUrl, type SiteSettingKey, type SiteSettings, type Snapshot, type SourceAuth, type SourceCapabilities, type SourceInput, type SourceProbeResult, type SqliteConfig, type StandardHookEntry, type StandardHookHandler, type StandardPluginDefinition, type StandardRouteEntry, type StandardRouteHandler, type Storage, type StorageCollection, type StorageDescriptor, type StoredComment, type SuggestOptions, type SuggestedAction, type Suggestion, type TaxonomyDef, type TaxonomyTerm, type TaxonomyTermRow, type TranslationSummary, type TranslationsResult, type UpdateCollectionInput, type UpdateContentInput, type UpdateFieldInput, type UpdateMenuInput, type UpdateMenuItemInput, type UpdateSectionInput, type UpdateTermInput, type UpdateWidgetInput, type UploadResult, type UrlInput, type UserTable, type ValidatedPluginManifest, type ValidationResult, type VerifyPreviewTokenOptions, type VerifyPreviewTokenResult, type Widget, type WidgetArea, type WidgetComponentDef, type WidgetType, type WxrAttachment, type WxrAuthor, type WxrCategory, type WxrData, type WxrPost, type WxrSite, type WxrTag, adaptSandboxEntry, applySeed, applySnapshotToDatabase, buildPreviewSignatureHeader, buildPreviewUrl, clearSources, computeContentHash, createEditable, createFilePreviewMiddleware, createHookPipeline, createNodeSandboxRunner, createNoop, createNoopSandboxRunner, createPluginManager, defaultPreviewSidecarClient, definePlugin, dropSessionDatabaseTables, extractPlainText, extractSearchableFields, generateManifest, generatePlaceholder, generatePreviewToken, getAllSources, getAppliedSnapshotMeta, getByline, getBylineBySlug, getCollectionInfo, getCommentCount, getComments, getContentSeo, getDinewayCollection, getDinewayEntry, getEditMeta, getEntriesByTerm, getEntryTerms, getFallbackChain, getFileSources, getI18nConfig, getMenu, getMenus, getMigrationStatus, getPluginSetting, getPluginSettings, getPreviewToken, getPreviewUrl, getRequestContext, getSearchStats, getSection, getSections, getSeoMeta, getSiteSetting, getSiteSettings, getSource, getSuggestions, getTaxonomyDef, getTaxonomyDefs, getTaxonomyTerms, getTerm, getTermsForEntries, getTranslations, getUrlSources, getWidgetArea, getWidgetAreas, getWidgetComponents, handleContentCompare, handleContentCountScheduled, handleContentCountTrashed, handleContentCreate, handleContentDelete, handleContentDiscardDraft, handleContentDuplicate, handleContentGet, handleContentGetIncludingTrashed, handleContentList, handleContentListTrashed, handleContentPermanentDelete, handleContentPublish, handleContentRestore, handleContentSchedule, handleContentTranslations, handleContentUnpublish, handleContentUnschedule, handleContentUpdate, handleMediaCreate, handleMediaDelete, handleMediaGet, handleMediaList, handleMediaUpdate, handleRevisionGet, handleRevisionList, handleRevisionRestore, hashString, image, importReusableBlocksAsSections, isBlockedInPreview, isI18nEnabled, isPreviewRequest, isSafeHref, isStandardPluginDefinition, normalizeMediaValue, parseContentId, parsePreviewSignatureHeader, parseWxr, parseWxrDate, parseWxrString, pluginManifestSchema, portableText, portableTextToProsemirror, probeUrl, prosemirrorToPortableText, reference, registerSource, renderPreviewLoadingPage, renderPreviewToolbar, resolveDinewayPath, runWithContext, sanitizeHref, search, searchCollection, searchWithDb, setSiteSettings, signPreviewUrl, ulid, validateSeed, verifyPreviewSignature, verifyPreviewToken, wordpressRestSource, wxrSource };
package/dist/index.mjs ADDED
@@ -0,0 +1,30 @@
1
+ import { t as DinewayDatabaseError } from "./connection-C9pxzuag.mjs";
2
+ import "./dialect-helpers-B9uSp2GJ.mjs";
3
+ import { t as getMigrationStatus } from "./runner-BGUGywgG.mjs";
4
+ import { $t as handleContentSchedule, A as getAllSources, At as handleMediaGet, B as NoopSandboxRunner, Bt as handleContentCountScheduled, C as isPreviewRequest, D as parseWxrDate, Dt as getCollectionInfo, E as wordpressRestSource, F as registerSource, Ft as handleRevisionRestore, G as PluginRouteError, Gt as handleContentDuplicate, H as createNoopSandboxRunner, Ht as handleContentCreate, I as importReusableBlocksAsSections, It as generateManifest, Jt as handleContentList, Kt as handleContentGet, L as isStandardPluginDefinition, Lt as computeContentHash, M as getSource, Mt as handleMediaUpdate, N as getUrlSources, Nt as handleRevisionGet, O as wxrSource, Ot as handleMediaCreate, P as probeUrl, Pt as handleRevisionList, Qt as handleContentRestore, R as NodeSandboxRunner, Rt as hashString, S as getPreviewToken, St as sanitizeHref, T as getPreviewUrl, Tt as getSections, U as PluginManager, Ut as handleContentDelete, V as SandboxNotAvailableError, Vt as handleContentCountTrashed, W as createPluginManager, Wt as handleContentDiscardDraft, X as HookPipeline, Xt as handleContentPermanentDelete, Yt as handleContentListTrashed, Z as createHookPipeline, Zt as handleContentPublish, _ as getTermsForEntries, _t as signPreviewUrl, a as search, an as portableText, at as createFilePreviewMiddleware, b as getCommentCount, bt as prosemirrorToPortableText, c as getWidgetArea, ct as dropSessionDatabaseTables, d as getEntriesByTerm, dt as SessionDatabaseLimitError, en as handleContentTranslations, f as getEntryTerms, ft as isBlockedInPreview, g as getTerm, gt as parsePreviewSignatureHeader, h as getTaxonomyTerms, ht as defaultPreviewSidecarClient, i as getSuggestions, it as parseWxrString, j as getFileSources, jt as handleMediaList, k as clearSources, kt as handleMediaDelete, l as getWidgetAreas, lt as getAppliedSnapshotMeta, m as getTaxonomyDefs, mt as buildPreviewSignatureHeader, n as extractSearchableFields, nn as handleContentUnschedule, nt as definePlugin, o as searchCollection, on as reference, ot as renderPreviewToolbar, p as getTaxonomyDef, pt as renderPreviewLoadingPage, qt as handleContentGetIncludingTrashed, r as getSearchStats, rn as handleContentUpdate, rt as parseWxr, s as searchWithDb, sn as image, st as applySnapshotToDatabase, t as extractPlainText, tn as handleContentUnpublish, u as getWidgetComponents, ut as FileSessionDatabaseFactory, v as getMenu, vt as verifyPreviewSignature, w as buildPreviewUrl, wt as getSection, x as getComments, xt as isSafeHref, y as getMenus, yt as portableTextToProsemirror, z as createNodeSandboxRunner, zt as handleContentCompare } from "./search-BNruJHDL.mjs";
5
+ import { t as ContentRepository } from "./content-zSgdNmnt.mjs";
6
+ import "./base64-F8-DUraK.mjs";
7
+ import { t as DinewayValidationError } from "./types-BawVha09.mjs";
8
+ import { t as MediaRepository } from "./media-DMTr80Gv.mjs";
9
+ import { c as getPluginSettings, d as setSiteSettings, l as getSiteSetting, s as getPluginSetting, t as applySeed, u as getSiteSettings } from "./apply-CAPvMfoU.mjs";
10
+ import { i as FTSManager, n as SchemaRegistry, t as SchemaError } from "./registry-DSd1GWB8.mjs";
11
+ import "./redirect-JPqLAbxa.mjs";
12
+ import "./byline-DeWCMU_i.mjs";
13
+ import { n as normalizeMediaValue, t as generatePlaceholder } from "./placeholder-B3knXwNc.mjs";
14
+ import { n as getI18nConfig, r as isI18nEnabled, t as getFallbackChain } from "./config-Cq8H0SfX.mjs";
15
+ import { i as RESERVED_FIELD_SLUGS, n as FIELD_TYPE_TO_COLUMN, r as RESERVED_COLLECTION_SLUGS } from "./types-DuNbGKjF.mjs";
16
+ import { getRequestContext, runWithContext } from "./request-context.mjs";
17
+ import "./loader-qKmo0wAY.mjs";
18
+ import { i as pluginManifestSchema } from "./manifest-schema-CTSEyIJ3.mjs";
19
+ import { t as DinewayStorageError } from "./types-DShnjzb6.mjs";
20
+ import { c as createNoop, i as getTranslations, n as getDinewayEntry, o as resolveDinewayPath, r as getEditMeta, s as createEditable, t as getDinewayCollection } from "./query-BiaPl_g2.mjs";
21
+ import { adaptSandboxEntry } from "./plugins/adapt-sandbox-entry.mjs";
22
+ import { n as parseContentId, r as verifyPreviewToken, t as generatePreviewToken } from "./tokens-4vgYuXsZ.mjs";
23
+ import { getContentSeo, getSeoMeta } from "./seo/index.mjs";
24
+ import { n as getByline, r as getBylineBySlug } from "./bylines-DyqBV9EQ.mjs";
25
+ import { t as validateSeed } from "./validate-CXnRKfJK.mjs";
26
+ import "./load-C6FCD1FU.mjs";
27
+ import "./seed/index.mjs";
28
+ import { ulid } from "ulidx";
29
+
30
+ export { ContentRepository, DinewayDatabaseError, DinewayStorageError, DinewayValidationError, FIELD_TYPE_TO_COLUMN, FTSManager, FileSessionDatabaseFactory, HookPipeline, MediaRepository, NodeSandboxRunner, NoopSandboxRunner, PluginManager, PluginRouteError, RESERVED_COLLECTION_SLUGS, RESERVED_FIELD_SLUGS, SandboxNotAvailableError, SchemaError, SchemaRegistry, SessionDatabaseLimitError, adaptSandboxEntry, applySeed, applySnapshotToDatabase, buildPreviewSignatureHeader, buildPreviewUrl, clearSources, computeContentHash, createEditable, createFilePreviewMiddleware, createHookPipeline, createNodeSandboxRunner, createNoop, createNoopSandboxRunner, createPluginManager, defaultPreviewSidecarClient, definePlugin, dropSessionDatabaseTables, extractPlainText, extractSearchableFields, generateManifest, generatePlaceholder, generatePreviewToken, getAllSources, getAppliedSnapshotMeta, getByline, getBylineBySlug, getCollectionInfo, getCommentCount, getComments, getContentSeo, getDinewayCollection, getDinewayEntry, getEditMeta, getEntriesByTerm, getEntryTerms, getFallbackChain, getFileSources, getI18nConfig, getMenu, getMenus, getMigrationStatus, getPluginSetting, getPluginSettings, getPreviewToken, getPreviewUrl, getRequestContext, getSearchStats, getSection, getSections, getSeoMeta, getSiteSetting, getSiteSettings, getSource, getSuggestions, getTaxonomyDef, getTaxonomyDefs, getTaxonomyTerms, getTerm, getTermsForEntries, getTranslations, getUrlSources, getWidgetArea, getWidgetAreas, getWidgetComponents, handleContentCompare, handleContentCountScheduled, handleContentCountTrashed, handleContentCreate, handleContentDelete, handleContentDiscardDraft, handleContentDuplicate, handleContentGet, handleContentGetIncludingTrashed, handleContentList, handleContentListTrashed, handleContentPermanentDelete, handleContentPublish, handleContentRestore, handleContentSchedule, handleContentTranslations, handleContentUnpublish, handleContentUnschedule, handleContentUpdate, handleMediaCreate, handleMediaDelete, handleMediaGet, handleMediaList, handleMediaUpdate, handleRevisionGet, handleRevisionList, handleRevisionRestore, hashString, image, importReusableBlocksAsSections, isBlockedInPreview, isI18nEnabled, isPreviewRequest, isSafeHref, isStandardPluginDefinition, normalizeMediaValue, parseContentId, parsePreviewSignatureHeader, parseWxr, parseWxrDate, parseWxrString, pluginManifestSchema, portableText, portableTextToProsemirror, probeUrl, prosemirrorToPortableText, reference, registerSource, renderPreviewLoadingPage, renderPreviewToolbar, resolveDinewayPath, runWithContext, sanitizeHref, search, searchCollection, searchWithDb, setSiteSettings, signPreviewUrl, ulid, validateSeed, verifyPreviewSignature, verifyPreviewToken, wordpressRestSource, wxrSource };
@@ -0,0 +1,27 @@
1
+ import { t as __exportAll } from "./chunk-ClPoSABd.mjs";
2
+
3
+ //#region src/seed/load.ts
4
+ var load_exports = /* @__PURE__ */ __exportAll({
5
+ loadSeed: () => loadSeed,
6
+ loadUserSeed: () => loadUserSeed
7
+ });
8
+ async function getSeedModule() {
9
+ return import("virtual:dineway/seed");
10
+ }
11
+ /**
12
+ * Load the seed file (user seed or default).
13
+ */
14
+ async function loadSeed() {
15
+ const { seed } = await getSeedModule();
16
+ return seed;
17
+ }
18
+ /**
19
+ * Load the user's seed file, or null if none exists.
20
+ */
21
+ async function loadUserSeed() {
22
+ const { userSeed } = await getSeedModule();
23
+ return userSeed ?? null;
24
+ }
25
+
26
+ //#endregion
27
+ export { loadUserSeed as n, load_exports as r, loadSeed as t };
@@ -0,0 +1,446 @@
1
+ import { t as __exportAll } from "./chunk-ClPoSABd.mjs";
2
+ import { i as isPostgres, r as currentTimestampValue } from "./dialect-helpers-B9uSp2GJ.mjs";
3
+ import { n as decodeCursor, r as encodeCursor } from "./types-BawVha09.mjs";
4
+ import { getRequestContext } from "./request-context.mjs";
5
+ import { Kysely, sql } from "kysely";
6
+
7
+ //#region src/loader.ts
8
+ var loader_exports = /* @__PURE__ */ __exportAll({
9
+ dinewayLoader: () => dinewayLoader,
10
+ getDb: () => getDb
11
+ });
12
+ const FIELD_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
13
+ /**
14
+ * System columns that are not part of the content data
15
+ */
16
+ /**
17
+ * System columns excluded from entry.data
18
+ * Note: slug is intentionally NOT excluded - it's useful as data.slug in templates
19
+ */
20
+ const SYSTEM_COLUMNS = new Set([
21
+ "id",
22
+ "status",
23
+ "author_id",
24
+ "primary_byline_id",
25
+ "created_at",
26
+ "updated_at",
27
+ "published_at",
28
+ "scheduled_at",
29
+ "deleted_at",
30
+ "version",
31
+ "live_revision_id",
32
+ "draft_revision_id",
33
+ "locale",
34
+ "translation_group"
35
+ ]);
36
+ /**
37
+ * Get the table name for a collection type
38
+ */
39
+ function getTableName(type) {
40
+ return `ec_${type}`;
41
+ }
42
+ /**
43
+ * Cache for taxonomy names (only used for the primary database).
44
+ * Skipped when a per-request DB override is active (e.g. preview mode)
45
+ * because the override DB may have different taxonomies.
46
+ */
47
+ let taxonomyNames = null;
48
+ /**
49
+ * Get all taxonomy names (cached for primary DB, fresh for overrides)
50
+ */
51
+ async function getTaxonomyNames(db) {
52
+ const hasDbOverride = !!getRequestContext()?.db;
53
+ if (!hasDbOverride && taxonomyNames) return taxonomyNames;
54
+ try {
55
+ const defs = await db.selectFrom("_dineway_taxonomy_defs").select("name").execute();
56
+ const names = new Set(defs.map((d) => d.name));
57
+ if (!hasDbOverride) taxonomyNames = names;
58
+ return names;
59
+ } catch {
60
+ const empty = /* @__PURE__ */ new Set();
61
+ if (!hasDbOverride) taxonomyNames = empty;
62
+ return empty;
63
+ }
64
+ }
65
+ /**
66
+ * System columns to include in data (mapped to camelCase where needed)
67
+ */
68
+ const INCLUDE_IN_DATA = {
69
+ id: "id",
70
+ status: "status",
71
+ author_id: "authorId",
72
+ primary_byline_id: "primaryBylineId",
73
+ created_at: "createdAt",
74
+ updated_at: "updatedAt",
75
+ published_at: "publishedAt",
76
+ scheduled_at: "scheduledAt",
77
+ draft_revision_id: "draftRevisionId",
78
+ live_revision_id: "liveRevisionId",
79
+ locale: "locale",
80
+ translation_group: "translationGroup"
81
+ };
82
+ /** System date columns that should be converted to Date objects */
83
+ const DATE_COLUMNS = new Set([
84
+ "created_at",
85
+ "updated_at",
86
+ "published_at",
87
+ "scheduled_at"
88
+ ]);
89
+ /** Safely extract a string value from a record, returning fallback if not a string */
90
+ function rowStr(row, key, fallback = "") {
91
+ const val = row[key];
92
+ return typeof val === "string" ? val : fallback;
93
+ }
94
+ /**
95
+ * Map a database row to entry data
96
+ * Extracts content fields (non-system columns) and parses JSON where needed.
97
+ * System columns needed for templates (id, status, dates) are included with camelCase names.
98
+ */
99
+ function mapRowToData(row) {
100
+ const data = {};
101
+ for (const [key, value] of Object.entries(row)) {
102
+ if (key in INCLUDE_IN_DATA) {
103
+ if (DATE_COLUMNS.has(key)) data[INCLUDE_IN_DATA[key]] = typeof value === "string" ? new Date(value) : null;
104
+ else data[INCLUDE_IN_DATA[key]] = value;
105
+ continue;
106
+ }
107
+ if (SYSTEM_COLUMNS.has(key)) continue;
108
+ if (typeof value === "string") try {
109
+ if (value.startsWith("{") || value.startsWith("[")) data[key] = JSON.parse(value);
110
+ else data[key] = value;
111
+ } catch {
112
+ data[key] = value;
113
+ }
114
+ else data[key] = value;
115
+ }
116
+ return data;
117
+ }
118
+ /**
119
+ * Map revision data (already-parsed JSON object) to entry data.
120
+ * Strips _-prefixed metadata keys (e.g. _slug) used internally by revisions.
121
+ */
122
+ function mapRevisionData(data) {
123
+ const result = {};
124
+ for (const [key, value] of Object.entries(data)) {
125
+ if (key.startsWith("_")) continue;
126
+ result[key] = value;
127
+ }
128
+ return result;
129
+ }
130
+ let virtualConfig;
131
+ let virtualCreateDialect;
132
+ async function loadVirtualModules() {
133
+ if (virtualConfig === void 0) virtualConfig = (await import("virtual:dineway/config")).default;
134
+ if (virtualCreateDialect === void 0) virtualCreateDialect = (await import("virtual:dineway/dialect")).createDialect;
135
+ }
136
+ /**
137
+ * Build WHERE clause for status filtering.
138
+ * When filtering for 'published' status, also include scheduled content
139
+ * whose scheduled_at time has passed (treating it as effectively published).
140
+ */
141
+ function buildStatusCondition(db, status, tablePrefix) {
142
+ const statusField = tablePrefix ? `${tablePrefix}.status` : "status";
143
+ const scheduledAtField = tablePrefix ? `${tablePrefix}.scheduled_at` : "scheduled_at";
144
+ if (status === "published") {
145
+ const scheduledAtExpr = isPostgres(db) ? sql`${sql.ref(scheduledAtField)}::timestamptz` : sql.ref(scheduledAtField);
146
+ return sql`(${sql.ref(statusField)} = 'published' OR (${sql.ref(statusField)} = 'scheduled' AND ${scheduledAtExpr} <= ${currentTimestampValue(db)}))`;
147
+ }
148
+ return sql`${sql.ref(statusField)} = ${status}`;
149
+ }
150
+ /**
151
+ * Get the primary sort field from an orderBy spec (first valid field, or default).
152
+ */
153
+ function getPrimarySort(orderBy, tablePrefix) {
154
+ if (orderBy) {
155
+ for (const [field, direction] of Object.entries(orderBy)) if (FIELD_NAME_PATTERN.test(field)) return {
156
+ field: tablePrefix ? `${tablePrefix}.${field}` : field,
157
+ direction
158
+ };
159
+ }
160
+ return {
161
+ field: tablePrefix ? `${tablePrefix}.created_at` : "created_at",
162
+ direction: "desc"
163
+ };
164
+ }
165
+ /**
166
+ * Build ORDER BY clause from orderBy spec
167
+ * Validates field names to prevent SQL injection (alphanumeric + underscore only)
168
+ * Supports multiple sort fields in object key order
169
+ */
170
+ function buildOrderByClause(orderBy, tablePrefix) {
171
+ if (!orderBy || Object.keys(orderBy).length === 0) {
172
+ const field = tablePrefix ? `${tablePrefix}.created_at` : "created_at";
173
+ return sql`ORDER BY ${sql.ref(field)} DESC, ${sql.ref(tablePrefix ? `${tablePrefix}.id` : "id")} DESC`;
174
+ }
175
+ const sortParts = [];
176
+ for (const [field, direction] of Object.entries(orderBy)) {
177
+ if (!FIELD_NAME_PATTERN.test(field)) continue;
178
+ const fullField = tablePrefix ? `${tablePrefix}.${field}` : field;
179
+ const dir = direction === "asc" ? sql`ASC` : sql`DESC`;
180
+ sortParts.push(sql`${sql.ref(fullField)} ${dir}`);
181
+ }
182
+ if (sortParts.length === 0) {
183
+ const defaultField = tablePrefix ? `${tablePrefix}.created_at` : "created_at";
184
+ return sql`ORDER BY ${sql.ref(defaultField)} DESC, ${sql.ref(tablePrefix ? `${tablePrefix}.id` : "id")} DESC`;
185
+ }
186
+ const primary = getPrimarySort(orderBy, tablePrefix);
187
+ const idField = tablePrefix ? `${tablePrefix}.id` : "id";
188
+ const idDir = primary.direction === "asc" ? sql`ASC` : sql`DESC`;
189
+ sortParts.push(sql`${sql.ref(idField)} ${idDir}`);
190
+ return sql`ORDER BY ${sql.join(sortParts, sql`, `)}`;
191
+ }
192
+ /**
193
+ * Build a cursor WHERE condition for keyset pagination.
194
+ * Uses the primary sort field + id as tiebreaker for stable ordering.
195
+ */
196
+ function buildCursorCondition(cursor, orderBy, tablePrefix) {
197
+ const decoded = decodeCursor(cursor);
198
+ if (!decoded) return null;
199
+ const { orderValue, id: cursorId } = decoded;
200
+ const primary = getPrimarySort(orderBy, tablePrefix);
201
+ const idField = tablePrefix ? `${tablePrefix}.id` : "id";
202
+ if (primary.direction === "desc") return sql`(${sql.ref(primary.field)} < ${orderValue} OR (${sql.ref(primary.field)} = ${orderValue} AND ${sql.ref(idField)} < ${cursorId}))`;
203
+ return sql`(${sql.ref(primary.field)} > ${orderValue} OR (${sql.ref(primary.field)} = ${orderValue} AND ${sql.ref(idField)} > ${cursorId}))`;
204
+ }
205
+ let dbInstance = null;
206
+ /**
207
+ * Get the database instance. Used by query wrapper functions and middleware.
208
+ *
209
+ * Checks the ALS request context first — if a per-request DB override is set
210
+ * (e.g. by preview or playground middleware), it takes precedence over the
211
+ * module-level cached instance. This allows preview flows to route queries
212
+ * to an isolated session database without modifying any calling code.
213
+ *
214
+ * Initializes the default database on first call using config from virtual module.
215
+ */
216
+ async function getDb() {
217
+ const ctx = getRequestContext();
218
+ if (ctx?.db) return ctx.db;
219
+ if (!dbInstance) {
220
+ await loadVirtualModules();
221
+ if (!virtualConfig?.database || typeof virtualCreateDialect !== "function") throw new Error("Dineway database not configured. Add database config to dineway() in astro.config.mjs");
222
+ dbInstance = new Kysely({ dialect: virtualCreateDialect(virtualConfig.database.config) });
223
+ }
224
+ return dbInstance;
225
+ }
226
+ /**
227
+ * Create a Dineway Live Collections loader
228
+ *
229
+ * This loader handles ALL content types in a single Astro collection.
230
+ * Use `getDinewayCollection()` and `getDinewayEntry()` to query
231
+ * specific content types.
232
+ *
233
+ * Database is configured in astro.config.mjs via the dineway() integration.
234
+ *
235
+ * @example
236
+ * ```ts
237
+ * // src/live.config.ts
238
+ * import { defineLiveCollection } from "astro:content";
239
+ * import { dinewayLoader } from "dineway";
240
+ *
241
+ * export const collections = {
242
+ * dineway: defineLiveCollection({
243
+ * loader: dinewayLoader(),
244
+ * }),
245
+ * };
246
+ * ```
247
+ */
248
+ function dinewayLoader() {
249
+ return {
250
+ name: "dineway",
251
+ async loadCollection({ filter }) {
252
+ try {
253
+ const db = await getDb();
254
+ const type = filter?.type;
255
+ if (!type) return { error: /* @__PURE__ */ new Error("type filter is required. Use getDinewayCollection() instead of getLiveCollection() directly.") };
256
+ const tableName = getTableName(type);
257
+ const status = filter?.status || "published";
258
+ const limit = filter?.limit;
259
+ const cursor = filter?.cursor;
260
+ const where = filter?.where;
261
+ const orderBy = filter?.orderBy;
262
+ const locale = filter?.locale;
263
+ const fetchLimit = limit ? limit + 1 : void 0;
264
+ const cursorCondition = cursor ? buildCursorCondition(cursor, orderBy) : null;
265
+ const cursorConditionPrefixed = cursor ? buildCursorCondition(cursor, orderBy, tableName) : null;
266
+ let result;
267
+ if (where && Object.keys(where).length > 0) {
268
+ const taxNames = await getTaxonomyNames(db);
269
+ const taxonomyFilters = {};
270
+ for (const [key, value] of Object.entries(where)) if (taxNames.has(key)) taxonomyFilters[key] = value;
271
+ if (Object.keys(taxonomyFilters).length > 0) {
272
+ const [taxName, termSlugs] = Object.entries(taxonomyFilters)[0];
273
+ const slugs = Array.isArray(termSlugs) ? termSlugs : [termSlugs];
274
+ const orderByClause = buildOrderByClause(orderBy, tableName);
275
+ const statusCondition = buildStatusCondition(db, status, tableName);
276
+ const localeCondition = locale ? sql`AND ${sql.ref(tableName)}.locale = ${locale}` : sql``;
277
+ const cursorCond = cursorConditionPrefixed ? sql`AND ${cursorConditionPrefixed}` : sql``;
278
+ result = await sql`
279
+ SELECT DISTINCT ${sql.ref(tableName)}.* FROM ${sql.ref(tableName)}
280
+ INNER JOIN content_taxonomies ct
281
+ ON ct.collection = ${type}
282
+ AND ct.entry_id = ${sql.ref(tableName)}.id
283
+ INNER JOIN taxonomies t
284
+ ON t.id = ct.taxonomy_id
285
+ WHERE ${sql.ref(tableName)}.deleted_at IS NULL
286
+ AND ${statusCondition}
287
+ ${localeCondition}
288
+ ${cursorCond}
289
+ AND t.name = ${taxName}
290
+ AND t.slug IN (${sql.join(slugs.map((s) => sql`${s}`))})
291
+ ${orderByClause}
292
+ ${fetchLimit ? sql`LIMIT ${fetchLimit}` : sql``}
293
+ `.execute(db);
294
+ } else {
295
+ const orderByClause = buildOrderByClause(orderBy);
296
+ const statusCondition = buildStatusCondition(db, status);
297
+ const localeFilter = locale ? sql`AND locale = ${locale}` : sql``;
298
+ const cursorCond = cursorCondition ? sql`AND ${cursorCondition}` : sql``;
299
+ result = await sql`
300
+ SELECT * FROM ${sql.ref(tableName)}
301
+ WHERE deleted_at IS NULL
302
+ AND ${statusCondition}
303
+ ${localeFilter}
304
+ ${cursorCond}
305
+ ${orderByClause}
306
+ ${fetchLimit ? sql`LIMIT ${fetchLimit}` : sql``}
307
+ `.execute(db);
308
+ }
309
+ } else {
310
+ const orderByClause = buildOrderByClause(orderBy);
311
+ const statusCondition = buildStatusCondition(db, status);
312
+ const localeFilter = locale ? sql`AND locale = ${locale}` : sql``;
313
+ const cursorCond = cursorCondition ? sql`AND ${cursorCondition}` : sql``;
314
+ result = await sql`
315
+ SELECT * FROM ${sql.ref(tableName)}
316
+ WHERE deleted_at IS NULL
317
+ AND ${statusCondition}
318
+ ${localeFilter}
319
+ ${cursorCond}
320
+ ${orderByClause}
321
+ ${fetchLimit ? sql`LIMIT ${fetchLimit}` : sql``}
322
+ `.execute(db);
323
+ }
324
+ const hasMore = limit ? result.rows.length > limit : false;
325
+ const rows = hasMore ? result.rows.slice(0, limit) : result.rows;
326
+ const i18nConfig = virtualConfig?.i18n;
327
+ const i18nEnabled = i18nConfig && i18nConfig.locales.length > 1;
328
+ const entries = rows.map((row) => {
329
+ const slug = rowStr(row, "slug") || rowStr(row, "id");
330
+ const rowLocale = rowStr(row, "locale");
331
+ return {
332
+ id: i18nEnabled && rowLocale !== "" && (rowLocale !== i18nConfig.defaultLocale || i18nConfig.prefixDefaultLocale) ? `${rowLocale}/${slug}` : slug,
333
+ slug: rowStr(row, "slug"),
334
+ status: rowStr(row, "status", "draft"),
335
+ data: mapRowToData(row),
336
+ cacheHint: {
337
+ tags: [rowStr(row, "id")],
338
+ lastModified: row.updated_at ? new Date(rowStr(row, "updated_at")) : void 0
339
+ }
340
+ };
341
+ });
342
+ let nextCursor;
343
+ if (hasMore && rows.length > 0) {
344
+ const lastRow = rows.at(-1);
345
+ const primary = getPrimarySort(orderBy);
346
+ const lastOrderValue = lastRow[primary.field.includes(".") ? primary.field.split(".").pop() : primary.field];
347
+ nextCursor = encodeCursor(typeof lastOrderValue === "string" || typeof lastOrderValue === "number" ? String(lastOrderValue) : "", String(lastRow.id));
348
+ }
349
+ let collectionLastModified;
350
+ for (const row of rows) if (row.updated_at) {
351
+ const d = new Date(rowStr(row, "updated_at"));
352
+ if (!collectionLastModified || d > collectionLastModified) collectionLastModified = d;
353
+ }
354
+ return {
355
+ entries,
356
+ nextCursor,
357
+ cacheHint: {
358
+ tags: [type],
359
+ lastModified: collectionLastModified
360
+ }
361
+ };
362
+ } catch (error) {
363
+ const message = error instanceof Error ? error.message : String(error);
364
+ const lowerMessage = message.toLowerCase();
365
+ if (lowerMessage.includes("no such table") || lowerMessage.includes("table") && lowerMessage.includes("does not exist") || lowerMessage.includes("relation") && lowerMessage.includes("does not exist")) return { entries: [] };
366
+ return { error: /* @__PURE__ */ new Error(`Failed to load collection: ${message}`) };
367
+ }
368
+ },
369
+ async loadEntry({ filter }) {
370
+ try {
371
+ const db = await getDb();
372
+ const type = filter?.type;
373
+ const id = filter?.id;
374
+ if (!type || !id) return { error: /* @__PURE__ */ new Error("type and id filters are required. Use getDinewayEntry() instead of getLiveEntry() directly.") };
375
+ const tableName = getTableName(type);
376
+ const locale = filter?.locale;
377
+ const row = (locale ? await sql`
378
+ SELECT * FROM ${sql.ref(tableName)}
379
+ WHERE deleted_at IS NULL
380
+ AND ((slug = ${id} AND locale = ${locale}) OR id = ${id})
381
+ LIMIT 1
382
+ `.execute(db) : await sql`
383
+ SELECT * FROM ${sql.ref(tableName)}
384
+ WHERE deleted_at IS NULL
385
+ AND (slug = ${id} OR id = ${id})
386
+ LIMIT 1
387
+ `.execute(db)).rows[0];
388
+ if (!row) return;
389
+ const i18nConfig = virtualConfig?.i18n;
390
+ const i18nEnabled = i18nConfig && i18nConfig.locales.length > 1;
391
+ const entrySlug = rowStr(row, "slug") || rowStr(row, "id");
392
+ const entryLocale = rowStr(row, "locale");
393
+ const entryId = i18nEnabled && entryLocale !== "" && (entryLocale !== i18nConfig.defaultLocale || i18nConfig.prefixDefaultLocale) ? `${entryLocale}/${entrySlug}` : entrySlug;
394
+ const revisionId = filter?.revisionId;
395
+ if (revisionId) {
396
+ const revData = (await sql`
397
+ SELECT data FROM revisions
398
+ WHERE id = ${revisionId}
399
+ LIMIT 1
400
+ `.execute(db)).rows[0];
401
+ if (revData) {
402
+ const parsed = JSON.parse(revData.data);
403
+ const systemData = {};
404
+ for (const [key, mappedKey] of Object.entries(INCLUDE_IN_DATA)) if (key in row) if (DATE_COLUMNS.has(key)) systemData[mappedKey] = typeof row[key] === "string" ? new Date(row[key]) : null;
405
+ else systemData[mappedKey] = row[key];
406
+ const slug = typeof parsed._slug === "string" ? parsed._slug : rowStr(row, "slug");
407
+ const revSlug = slug || rowStr(row, "id");
408
+ const revLocale = rowStr(row, "locale");
409
+ return {
410
+ id: i18nEnabled && revLocale !== "" && (revLocale !== i18nConfig.defaultLocale || i18nConfig.prefixDefaultLocale) ? `${revLocale}/${revSlug}` : revSlug,
411
+ slug,
412
+ status: rowStr(row, "status", "draft"),
413
+ data: {
414
+ ...systemData,
415
+ slug,
416
+ ...mapRevisionData(parsed)
417
+ },
418
+ cacheHint: {
419
+ tags: [rowStr(row, "id")],
420
+ lastModified: row.updated_at ? new Date(rowStr(row, "updated_at")) : void 0
421
+ }
422
+ };
423
+ }
424
+ }
425
+ return {
426
+ id: entryId,
427
+ slug: rowStr(row, "slug"),
428
+ status: rowStr(row, "status", "draft"),
429
+ data: mapRowToData(row),
430
+ cacheHint: {
431
+ tags: [rowStr(row, "id")],
432
+ lastModified: row.updated_at ? new Date(rowStr(row, "updated_at")) : void 0
433
+ }
434
+ };
435
+ } catch (error) {
436
+ const message = error instanceof Error ? error.message : String(error);
437
+ const lowerMessage = message.toLowerCase();
438
+ if (lowerMessage.includes("no such table") || lowerMessage.includes("table") && lowerMessage.includes("does not exist") || lowerMessage.includes("relation") && lowerMessage.includes("does not exist")) return;
439
+ return { error: /* @__PURE__ */ new Error(`Failed to load entry: ${message}`) };
440
+ }
441
+ }
442
+ };
443
+ }
444
+
445
+ //#endregion
446
+ export { getDb as n, loader_exports as r, dinewayLoader as t };