@nuasite/cms-core 0.59.0 → 0.60.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.
@@ -1,6 +1,7 @@
1
1
  export { type ContemberStorageOptions, createContemberStorageAdapter } from './contember'
2
2
  export { MEDIA_INVALID_FOLDER, MEDIA_INVALID_ID, MEDIA_NOT_FOUND, mediaErrorStatus } from './errors'
3
- export { createLocalStorageAdapter, getFileExtension, type LocalStorageOptions, MIME_BY_EXT, mimeFromExt } from './local'
3
+ export { createFileSystemStorageAdapter, type FileSystemStorageOptions } from './file-system'
4
+ export { getFileExtension, MIME_BY_EXT, mimeFromExt } from './mime'
4
5
  export { isUnsafeFolder } from './names'
5
6
  export { listProjectImages, type ListProjectImagesOptions, uploadsDirRelativeToRoot } from './project-images'
6
7
  export { createS3StorageAdapter, type S3StorageOptions } from './s3'
@@ -3,6 +3,7 @@ import { randomUUID } from 'node:crypto'
3
3
  import fs from 'node:fs/promises'
4
4
  import path from 'node:path'
5
5
  import { MEDIA_INVALID_FOLDER, MEDIA_INVALID_ID, MEDIA_NOT_FOUND } from './errors'
6
+ import { getFileExtension, mimeFromExt } from './mime'
6
7
  import { isUnsafeFolder } from './names'
7
8
 
8
9
  export interface LocalStorageOptions {
@@ -227,27 +228,3 @@ export function createLocalStorageAdapter(options: LocalStorageOptions = {}): Me
227
228
  },
228
229
  }
229
230
  }
230
-
231
- export function getFileExtension(filename: string): string {
232
- const parts = filename.split('.')
233
- const ext = parts.length > 1 ? (parts.pop()?.toLowerCase() ?? '') : ''
234
- return /^[a-z0-9]+$/.test(ext) ? ext : ''
235
- }
236
-
237
- export const MIME_BY_EXT: Record<string, string> = {
238
- '.jpg': 'image/jpeg',
239
- '.jpeg': 'image/jpeg',
240
- '.png': 'image/png',
241
- '.gif': 'image/gif',
242
- '.webp': 'image/webp',
243
- '.avif': 'image/avif',
244
- '.svg': 'image/svg+xml',
245
- '.ico': 'image/x-icon',
246
- '.mp4': 'video/mp4',
247
- '.webm': 'video/webm',
248
- '.pdf': 'application/pdf',
249
- }
250
-
251
- export function mimeFromExt(ext: string): string {
252
- return MIME_BY_EXT[ext] ?? 'application/octet-stream'
253
- }
@@ -0,0 +1,23 @@
1
+ export function getFileExtension(filename: string): string {
2
+ const parts = filename.split('.')
3
+ const ext = parts.length > 1 ? (parts.pop()?.toLowerCase() ?? '') : ''
4
+ return /^[a-z0-9]+$/.test(ext) ? ext : ''
5
+ }
6
+
7
+ export const MIME_BY_EXT: Record<string, string> = {
8
+ '.jpg': 'image/jpeg',
9
+ '.jpeg': 'image/jpeg',
10
+ '.png': 'image/png',
11
+ '.gif': 'image/gif',
12
+ '.webp': 'image/webp',
13
+ '.avif': 'image/avif',
14
+ '.svg': 'image/svg+xml',
15
+ '.ico': 'image/x-icon',
16
+ '.mp4': 'video/mp4',
17
+ '.webm': 'video/webm',
18
+ '.pdf': 'application/pdf',
19
+ }
20
+
21
+ export function mimeFromExt(ext: string): string {
22
+ return MIME_BY_EXT[ext] ?? 'application/octet-stream'
23
+ }
@@ -1,6 +1,6 @@
1
1
  import type { MediaItem } from '@nuasite/cms-types'
2
2
  import type { CmsFileSystem } from '../fs/types'
3
- import { MIME_BY_EXT, mimeFromExt } from './local'
3
+ import { MIME_BY_EXT, mimeFromExt } from './mime'
4
4
 
5
5
  const IMAGE_EXTENSIONS = new Set(Object.entries(MIME_BY_EXT).filter(([, mime]) => mime.startsWith('image/')).map(([ext]) => ext))
6
6
 
package/src/media/s3.ts CHANGED
@@ -2,7 +2,7 @@ import type { MediaFolderItem, MediaListResult, MediaStorageAdapter, MediaUpload
2
2
  import { randomUUID } from 'node:crypto'
3
3
  import path from 'node:path'
4
4
  import { MEDIA_INVALID_FOLDER, MEDIA_INVALID_ID } from './errors'
5
- import { getFileExtension, mimeFromExt } from './local'
5
+ import { getFileExtension, mimeFromExt } from './mime'
6
6
  import { hasDotSegment, isUnsafeFolder } from './names'
7
7
 
8
8
  /*
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Everything cms-core offers that runs without `node:fs`. The package root resolves here under the
3
+ * `workerd` condition; the default root adds the Node filesystem and the local media adapter.
4
+ */
5
+ export { resolveAssetCandidates } from './asset-paths'
6
+ export {
7
+ analyzeAstroScript,
8
+ analyzeAstroSource,
9
+ type AstroCollectionBinding,
10
+ type AstroContentAccessor,
11
+ type AstroContentCall,
12
+ type AstroSourceAnalysis,
13
+ type AstroSourceImport,
14
+ } from './astro-source-analysis'
15
+ export { checkContent, type CheckContentOptions, type CheckFinding, type CheckReport, type CheckSeverity, formatCheckReport } from './check'
16
+ export {
17
+ collectionKind,
18
+ entryStem,
19
+ loadCollections,
20
+ type LoadedCollection,
21
+ type LoadedCollections,
22
+ type LoadedEntry,
23
+ normalizeBase,
24
+ parseEntry,
25
+ } from './check-entries'
26
+ export { checkAgainstSchemas, type LiveCheckInput } from './check-live'
27
+ export { checkFieldShapes, type ShapeCheckInput } from './check-shape'
28
+ export { checkEditorWrites, type WriteCheckInput } from './check-write'
29
+ export { collectionScanReport, scanCollections } from './collection-scanner'
30
+ export { scanComponentDefinitions } from './component-registry'
31
+ export {
32
+ classifyEmptyContentConfig,
33
+ CONTENT_CONFIG_PATHS,
34
+ type ContentConfigRead,
35
+ type DeclaredCollection,
36
+ type EmptyContentConfigReason,
37
+ type ParseCache,
38
+ parseConfigSource,
39
+ parseContentConfig,
40
+ type ParsedCollection,
41
+ type ParsedConfig,
42
+ type ParsedField,
43
+ type ParsedReference,
44
+ readContentConfig,
45
+ UNREAD_CONTENT_CONFIG_PATHS,
46
+ } from './content-config-ast'
47
+ export { createCmsCore } from './core'
48
+ export type { CmsCore, CmsCoreOptions } from './core'
49
+ export {
50
+ applyCreateRouteFields,
51
+ blankFieldValue,
52
+ blankRequiredFields,
53
+ type CollectionKind,
54
+ type CreateWriteField,
55
+ isBlankFieldValue,
56
+ newEntryFrontmatter,
57
+ newRepeaterItem,
58
+ normalizeCreateWrite,
59
+ omitEmptyOnCreate,
60
+ type RepeaterItemField,
61
+ type RequiredGuardField,
62
+ seedValueForRequiredField,
63
+ withoutBlankArrayItems,
64
+ type WriteModelField,
65
+ } from './editor-write-model'
66
+ export { globMayMatchUnder, globToRegExp, UnreadableDirectoryError } from './fs/glob'
67
+ export {
68
+ type CmsChangeset,
69
+ type CmsCommit,
70
+ CmsCommitConflictError,
71
+ type CmsFileVersion,
72
+ type CmsStagedChange,
73
+ commitChangeset,
74
+ createStagedFileSystem,
75
+ digestBytes,
76
+ type StagedFileSystem,
77
+ versionMatches,
78
+ versionOf,
79
+ } from './fs/staged'
80
+ export type { CmsFileSystem, GlobOptions } from './fs/types'
81
+ export {
82
+ type AddArrayItemInput,
83
+ type CreateEntryInput,
84
+ ensureMdxImports,
85
+ type EntryAsset,
86
+ type EntryOpsDeps,
87
+ type GetEntryResult,
88
+ parseFrontmatter,
89
+ type RemoveArrayItemInput,
90
+ serializeFrontmatter,
91
+ type UpdateEntryInput,
92
+ } from './handlers/entry-ops'
93
+ export {
94
+ type ContemberStorageOptions,
95
+ createContemberStorageAdapter,
96
+ createFileSystemStorageAdapter,
97
+ createS3StorageAdapter,
98
+ decodeFilteredMediaCursor,
99
+ type FileSystemStorageOptions,
100
+ getFileExtension,
101
+ isUnsafeFolder,
102
+ listFilteredMedia,
103
+ listProjectImages,
104
+ type ListProjectImagesOptions,
105
+ MEDIA_CURSOR_TYPE_MISMATCH,
106
+ MEDIA_INVALID_CURSOR,
107
+ MEDIA_INVALID_FOLDER,
108
+ MEDIA_INVALID_ID,
109
+ MEDIA_NOT_FOUND,
110
+ MediaCursorError,
111
+ mediaErrorStatus,
112
+ MIME_BY_EXT,
113
+ mimeFromExt,
114
+ parseMediaTypeFilter,
115
+ type S3StorageOptions,
116
+ uploadsDirRelativeToRoot,
117
+ } from './media/index'
118
+ export { parseProjectCmsConfig, parseProjectCmsConfigSource } from './project-config-ast'
119
+ export {
120
+ CLOUDFLARE_REDIRECT_LIMITS,
121
+ CMS_REDIRECTS_FILE,
122
+ type MergedRedirects,
123
+ mergeRedirects,
124
+ parseRedirectRule,
125
+ type RedirectLayer,
126
+ type RedirectLine,
127
+ type RedirectRuleLine,
128
+ } from './redirects'
129
+ export { type RouteCollectionScan, scanRouteCollections } from './route-scan'
130
+ export { describeIssue, type LiveIssue, type LiveParseResult, type LiveSchema, type LiveSchemas, schemaFor } from './schema-port'
131
+ export { acceptsMissing, firstAcceptedEntry, governsPath, pointAt, type ProbePoint, rejectsValueAt } from './schema-probe'
132
+ export {
133
+ applyDerivedTransform,
134
+ computeDerivedFieldUpdates,
135
+ computePathnameFromSpec,
136
+ type DerivedFieldSpec,
137
+ escapeHtml,
138
+ relativeImportPath,
139
+ resolvePathnameFromSpec,
140
+ slugify,
141
+ slugifyHref,
142
+ } from './shared'