@nuasite/cms-core 0.58.2 → 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.
- package/dist/types/core.d.ts +8 -0
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/fs/node-fs.d.ts.map +1 -1
- package/dist/types/fs/staged.d.ts +65 -0
- package/dist/types/fs/staged.d.ts.map +1 -0
- package/dist/types/fs/types.d.ts +2 -0
- package/dist/types/fs/types.d.ts.map +1 -1
- package/dist/types/handlers/redirect-ops.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -22
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/media/file-system.d.ts +15 -0
- package/dist/types/media/file-system.d.ts.map +1 -0
- package/dist/types/media/index.d.ts +2 -1
- package/dist/types/media/index.d.ts.map +1 -1
- package/dist/types/media/local.d.ts +0 -3
- package/dist/types/media/local.d.ts.map +1 -1
- package/dist/types/media/mime.d.ts +4 -0
- package/dist/types/media/mime.d.ts.map +1 -0
- package/dist/types/portable.d.ts +29 -0
- package/dist/types/portable.d.ts.map +1 -0
- package/dist/types/redirects.d.ts +99 -0
- package/dist/types/redirects.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/core.ts +43 -21
- package/src/fs/node-fs.ts +18 -12
- package/src/fs/staged.ts +230 -0
- package/src/fs/types.ts +2 -0
- package/src/handlers/entry-ops.ts +1 -1
- package/src/handlers/redirect-ops.ts +31 -27
- package/src/index.ts +2 -115
- package/src/media/file-system.ts +133 -0
- package/src/media/index.ts +2 -1
- package/src/media/local.ts +1 -24
- package/src/media/mime.ts +23 -0
- package/src/media/project-images.ts +1 -1
- package/src/media/s3.ts +1 -1
- package/src/portable.ts +142 -0
- package/src/redirects.ts +246 -0
package/dist/types/core.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AddRedirectRequest, CollectionDefinition, CollectionScanReport, ComponentDefinition, CreatePageRequest, DeletePageRequest, DeleteRedirectRequest, DuplicatePageRequest, GetRedirectsResponse, LayoutInfo, MediaStorageAdapter, MutationResult, PageOperationResponse, RedirectOperationResponse, UpdateRedirectRequest } from '@nuasite/cms-types';
|
|
2
|
+
import { type CmsCommit } from './fs/staged';
|
|
2
3
|
import type { CmsFileSystem } from './fs/types';
|
|
3
4
|
import { type AddArrayItemInput, type CreateEntryInput, type EntryAsset, type GetEntryResult, type RemoveArrayItemInput, type UpdateEntryInput } from './handlers/entry-ops';
|
|
4
5
|
export interface CmsCoreOptions {
|
|
@@ -8,6 +9,13 @@ export interface CmsCoreOptions {
|
|
|
8
9
|
media?: MediaStorageAdapter;
|
|
9
10
|
/** Directories to scan for Astro components (used for MDX import resolution). Defaults to `['src/components']`. */
|
|
10
11
|
componentDirs?: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Runs each mutation over a staged view of the filesystem and hands its changes to this
|
|
14
|
+
* function instead of writing them directly. See {@link CmsCommit}: it rejects with
|
|
15
|
+
* `CmsCommitConflictError` when a file the mutation read has changed meanwhile, and the
|
|
16
|
+
* mutation then rejects with it. Without it, mutations write as they go.
|
|
17
|
+
*/
|
|
18
|
+
commit?: CmsCommit;
|
|
11
19
|
}
|
|
12
20
|
/**
|
|
13
21
|
* The framework-agnostic CMS brain over a `CmsFileSystem` port.
|
package/dist/types/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,UAAU,EACV,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,KAAK,EAAE,aAAa,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AAA;IAC/D,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;IAGrE,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;IACpE,aAAa,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;IAC1E,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;IACpE,UAAU,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;IACnC,aAAa,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAA;IAC9C,WAAW,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAA;IAC1E,cAAc,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAA;IAChF,cAAc,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAA;IAGhF,KAAK,CAAC,EAAE,mBAAmB,CAAA;CAC3B;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,aAAa,EAAE,IAAI,GAAE,cAAmB,GAAG,OAAO,CAyFnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-fs.d.ts","sourceRoot":"","sources":["../../../src/fs/node-fs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"node-fs.d.ts","sourceRoot":"","sources":["../../../src/fs/node-fs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AA0I5C;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CA6ExD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { CmsFileSystem } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Compare-and-commit for CMS mutations.
|
|
4
|
+
*
|
|
5
|
+
* A mutation runs over a staged view of the filesystem: reads go to the real filesystem and
|
|
6
|
+
* record what they saw, writes and removals stay in memory. When the mutation is done, its
|
|
7
|
+
* changeset goes to a commit function that applies the changes only if every file the mutation
|
|
8
|
+
* looked at is still as it saw it. A host whose files can also change by other means (an agent
|
|
9
|
+
* editing the same checkout) implements that commit atomically, so a CMS write never overwrites
|
|
10
|
+
* a change it did not see.
|
|
11
|
+
*/
|
|
12
|
+
/** What a mutation saw of a path. */
|
|
13
|
+
export type CmsFileVersion = {
|
|
14
|
+
kind: 'absent';
|
|
15
|
+
}
|
|
16
|
+
/** It existed. Recorded by `exists`/`stat`, which do not read the content. */
|
|
17
|
+
| {
|
|
18
|
+
kind: 'present';
|
|
19
|
+
}
|
|
20
|
+
/** Its bytes, as {@link digestBytes} gives them. */
|
|
21
|
+
| {
|
|
22
|
+
kind: 'content';
|
|
23
|
+
digest: string;
|
|
24
|
+
};
|
|
25
|
+
export type CmsStagedChange = {
|
|
26
|
+
kind: 'write';
|
|
27
|
+
path: string;
|
|
28
|
+
content: Uint8Array;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'remove';
|
|
31
|
+
path: string;
|
|
32
|
+
};
|
|
33
|
+
export interface CmsChangeset {
|
|
34
|
+
/** Each path the mutation read, tested or changed, with the version it first saw. Paths are root-relative, without a leading slash. */
|
|
35
|
+
readonly reads: ReadonlyMap<string, CmsFileVersion>;
|
|
36
|
+
/** The final state of each changed path, in the order the paths were first changed. A rename is a removal plus a write. */
|
|
37
|
+
readonly changes: readonly CmsStagedChange[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Applies a changeset when every path in `reads` still has the recorded version, and applies
|
|
41
|
+
* nothing otherwise, rejecting with {@link CmsCommitConflictError}. The check and the writes must
|
|
42
|
+
* not interleave with other writes to the same files.
|
|
43
|
+
*/
|
|
44
|
+
export type CmsCommit = (changeset: CmsChangeset) => Promise<void>;
|
|
45
|
+
export declare class CmsCommitConflictError extends Error {
|
|
46
|
+
readonly paths: readonly string[];
|
|
47
|
+
constructor(paths: readonly string[]);
|
|
48
|
+
}
|
|
49
|
+
/** `sha256:<hex>` of the bytes; for UTF-8 text, the same value the sidecar reports as a source hash. */
|
|
50
|
+
export declare function digestBytes(content: Uint8Array): string;
|
|
51
|
+
export interface StagedFileSystem extends CmsFileSystem {
|
|
52
|
+
changeset(): CmsChangeset;
|
|
53
|
+
}
|
|
54
|
+
export declare function createStagedFileSystem(base: CmsFileSystem): StagedFileSystem;
|
|
55
|
+
/** The version of `path` now, in the terms {@link CmsFileVersion} records. */
|
|
56
|
+
export declare function versionOf(fs: CmsFileSystem, path: string): Promise<CmsFileVersion>;
|
|
57
|
+
/** Whether a path whose version was `recorded` may be overwritten now that it is `current`. */
|
|
58
|
+
export declare function versionMatches(recorded: CmsFileVersion, current: CmsFileVersion): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* A commit over `fs` that checks the recorded versions and then applies the changes. It is atomic
|
|
61
|
+
* only when nothing else writes to `fs` between its awaits; a host with concurrent writers does
|
|
62
|
+
* both steps inside its own critical section instead.
|
|
63
|
+
*/
|
|
64
|
+
export declare function commitChangeset(fs: CmsFileSystem): CmsCommit;
|
|
65
|
+
//# sourceMappingURL=staged.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staged.d.ts","sourceRoot":"","sources":["../../../src/fs/staged.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C;;;;;;;;;GASG;AAEH,qCAAqC;AACrC,MAAM,MAAM,cAAc,GACvB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE;AACpB,8EAA8E;GAC5E;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE;AACrB,oDAAoD;GAClD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAA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@@ export interface CmsFileSystem {
|
|
|
37
37
|
readBytes(path: string): Promise<Uint8Array>;
|
|
38
38
|
/** Write a UTF-8 text file atomically (write temp + rename). Creates parent dirs. */
|
|
39
39
|
writeFile(path: string, content: string): Promise<void>;
|
|
40
|
+
/** Write raw bytes (images and other binary assets) atomically, like `writeFile`. Creates parent dirs. */
|
|
41
|
+
writeBytes(path: string, content: Uint8Array): Promise<void>;
|
|
40
42
|
/** Rename/move a file. Creates the destination's parent dir. */
|
|
41
43
|
rename(from: string, to: string): Promise<void>;
|
|
42
44
|
/** Remove a file. No-op when it does not exist. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fs/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC3B;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;IACxC;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,aAAa;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACvC,qGAAqG;IACrG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAC5C,qFAAqF;IACrF,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACvD,gEAAgE;IAChE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/C,mDAAmD;IACnD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACnC,0CAA0C;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AI,CAAC,CAAA;IAC5D,gEAAgE;IAChE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/C,mDAAmD;IACnD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACnC,0CAA0C;IAC1C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACtC,qFAAqF;IACrF,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC,CAAA;IACpE;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAC/D,2DAA2D;IAC3D,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirect-ops.d.ts","sourceRoot":"","sources":["../../../src/handlers/redirect-ops.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EAEzB,qBAAqB,EACrB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"redirect-ops.d.ts","sourceRoot":"","sources":["../../../src/handlers/redirect-ops.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EAEzB,qBAAqB,EACrB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAMhD,MAAM,WAAW,eAAe;IAC/B,EAAE,EAAE,aAAa,CAAA;CACjB;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAGxF;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAgBxH;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAyB9H;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAiB9H"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,24 +1,4 @@
|
|
|
1
|
-
export { resolveAssetCandidates } from './asset-paths';
|
|
2
|
-
export { analyzeAstroScript, analyzeAstroSource, type AstroCollectionBinding, type AstroContentAccessor, type AstroContentCall, type AstroSourceAnalysis, type AstroSourceImport, } from './astro-source-analysis';
|
|
3
|
-
export { checkContent, type CheckContentOptions, type CheckFinding, type CheckReport, type CheckSeverity, formatCheckReport } from './check';
|
|
4
|
-
export { collectionKind, entryStem, loadCollections, type LoadedCollection, type LoadedCollections, type LoadedEntry, normalizeBase, parseEntry, } from './check-entries';
|
|
5
|
-
export { checkAgainstSchemas, type LiveCheckInput } from './check-live';
|
|
6
|
-
export { checkFieldShapes, type ShapeCheckInput } from './check-shape';
|
|
7
|
-
export { checkEditorWrites, type WriteCheckInput } from './check-write';
|
|
8
|
-
export { collectionScanReport, scanCollections } from './collection-scanner';
|
|
9
|
-
export { scanComponentDefinitions } from './component-registry';
|
|
10
|
-
export { classifyEmptyContentConfig, CONTENT_CONFIG_PATHS, type ContentConfigRead, type DeclaredCollection, type EmptyContentConfigReason, type ParseCache, parseConfigSource, parseContentConfig, type ParsedCollection, type ParsedConfig, type ParsedField, type ParsedReference, readContentConfig, UNREAD_CONTENT_CONFIG_PATHS, } from './content-config-ast';
|
|
11
|
-
export { createCmsCore } from './core';
|
|
12
|
-
export type { CmsCore, CmsCoreOptions } from './core';
|
|
13
|
-
export { applyCreateRouteFields, blankFieldValue, blankRequiredFields, type CollectionKind, type CreateWriteField, isBlankFieldValue, newEntryFrontmatter, newRepeaterItem, normalizeCreateWrite, omitEmptyOnCreate, type RepeaterItemField, type RequiredGuardField, seedValueForRequiredField, withoutBlankArrayItems, type WriteModelField, } from './editor-write-model';
|
|
14
|
-
export { globMayMatchUnder, globToRegExp, UnreadableDirectoryError } from './fs/glob';
|
|
15
1
|
export { createNodeFs } from './fs/node-fs';
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export { type ContemberStorageOptions, createContemberStorageAdapter, createLocalStorageAdapter, createS3StorageAdapter, decodeFilteredMediaCursor, getFileExtension, isUnsafeFolder, listFilteredMedia, listProjectImages, type ListProjectImagesOptions, type LocalStorageOptions, MEDIA_CURSOR_TYPE_MISMATCH, MEDIA_INVALID_CURSOR, MEDIA_INVALID_FOLDER, MEDIA_INVALID_ID, MEDIA_NOT_FOUND, MediaCursorError, mediaErrorStatus, MIME_BY_EXT, mimeFromExt, parseMediaTypeFilter, type S3StorageOptions, uploadsDirRelativeToRoot, } from './media/index';
|
|
19
|
-
export { parseProjectCmsConfig, parseProjectCmsConfigSource } from './project-config-ast';
|
|
20
|
-
export { type RouteCollectionScan, scanRouteCollections } from './route-scan';
|
|
21
|
-
export { describeIssue, type LiveIssue, type LiveParseResult, type LiveSchema, type LiveSchemas, schemaFor } from './schema-port';
|
|
22
|
-
export { acceptsMissing, firstAcceptedEntry, governsPath, pointAt, type ProbePoint, rejectsValueAt } from './schema-probe';
|
|
23
|
-
export { applyDerivedTransform, computeDerivedFieldUpdates, computePathnameFromSpec, type DerivedFieldSpec, escapeHtml, relativeImportPath, resolvePathnameFromSpec, slugify, slugifyHref, } from './shared';
|
|
2
|
+
export { createLocalStorageAdapter, type LocalStorageOptions } from './media/local';
|
|
3
|
+
export * from './portable';
|
|
24
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,yBAAyB,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnF,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MediaStorageAdapter } from '@nuasite/cms-types';
|
|
2
|
+
import type { CmsFileSystem } from '../fs/types';
|
|
3
|
+
export interface FileSystemStorageOptions {
|
|
4
|
+
/** Directory to store media files in, relative to the filesystem's root. Default: `public/uploads`. */
|
|
5
|
+
dir?: string;
|
|
6
|
+
/** URL prefix the files are served under. Default: `/uploads`. */
|
|
7
|
+
urlPrefix?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Media stored in the project itself, through the same `CmsFileSystem` the core edits it with: the
|
|
11
|
+
* counterpart of the local adapter for a host without `node:fs`. Uploads land at
|
|
12
|
+
* `<dir>/<folder>/<uuid>.<ext>` and are listed newest first.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createFileSystemStorageAdapter(fs: CmsFileSystem, options?: FileSystemStorageOptions): MediaStorageAdapter;
|
|
15
|
+
//# sourceMappingURL=file-system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-system.d.ts","sourceRoot":"","sources":["../../../src/media/file-system.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA+C,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC1G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAKhD,MAAM,WAAW,wBAAwB;IACxC,uGAAuG;IACvG,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB;AAoBD;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,aAAa,EAAE,OAAO,GAAE,wBAA6B,GAAG,mBAAmB,CAgG7H"}
|
|
@@ -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 {
|
|
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';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/media/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AACzF,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AACpG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/media/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AACzF,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AACpG,OAAO,EAAE,8BAA8B,EAAE,KAAK,wBAAwB,EAAE,MAAM,eAAe,CAAA;AAC7F,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAC7G,OAAO,EAAE,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,MAAM,MAAM,CAAA;AACpE,OAAO,EACN,yBAAyB,EACzB,iBAAiB,EACjB,0BAA0B,EAC1B,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,GACpB,MAAM,eAAe,CAAA"}
|
|
@@ -14,7 +14,4 @@ export interface LocalStorageOptions {
|
|
|
14
14
|
urlPrefix?: string;
|
|
15
15
|
}
|
|
16
16
|
export declare function createLocalStorageAdapter(options?: LocalStorageOptions): MediaStorageAdapter;
|
|
17
|
-
export declare function getFileExtension(filename: string): string;
|
|
18
|
-
export declare const MIME_BY_EXT: Record<string, string>;
|
|
19
|
-
export declare function mimeFromExt(ext: string): string;
|
|
20
17
|
//# sourceMappingURL=local.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../../src/media/local.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoC,mBAAmB,EAAqB,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../../src/media/local.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoC,mBAAmB,EAAqB,MAAM,oBAAoB,CAAA;AAQlH,MAAM,WAAW,mBAAmB;IACnC;;;;;;;;OAQG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB;AAsCD,wBAAgB,yBAAyB,CAAC,OAAO,GAAE,mBAAwB,GAAG,mBAAmB,CA0KhG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mime.d.ts","sourceRoot":"","sources":["../../../src/media/mime.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAY9C,CAAA;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { analyzeAstroScript, analyzeAstroSource, type AstroCollectionBinding, type AstroContentAccessor, type AstroContentCall, type AstroSourceAnalysis, type AstroSourceImport, } from './astro-source-analysis';
|
|
7
|
+
export { checkContent, type CheckContentOptions, type CheckFinding, type CheckReport, type CheckSeverity, formatCheckReport } from './check';
|
|
8
|
+
export { collectionKind, entryStem, loadCollections, type LoadedCollection, type LoadedCollections, type LoadedEntry, normalizeBase, parseEntry, } from './check-entries';
|
|
9
|
+
export { checkAgainstSchemas, type LiveCheckInput } from './check-live';
|
|
10
|
+
export { checkFieldShapes, type ShapeCheckInput } from './check-shape';
|
|
11
|
+
export { checkEditorWrites, type WriteCheckInput } from './check-write';
|
|
12
|
+
export { collectionScanReport, scanCollections } from './collection-scanner';
|
|
13
|
+
export { scanComponentDefinitions } from './component-registry';
|
|
14
|
+
export { classifyEmptyContentConfig, CONTENT_CONFIG_PATHS, type ContentConfigRead, type DeclaredCollection, type EmptyContentConfigReason, type ParseCache, parseConfigSource, parseContentConfig, type ParsedCollection, type ParsedConfig, type ParsedField, type ParsedReference, readContentConfig, UNREAD_CONTENT_CONFIG_PATHS, } from './content-config-ast';
|
|
15
|
+
export { createCmsCore } from './core';
|
|
16
|
+
export type { CmsCore, CmsCoreOptions } from './core';
|
|
17
|
+
export { applyCreateRouteFields, blankFieldValue, blankRequiredFields, type CollectionKind, type CreateWriteField, isBlankFieldValue, newEntryFrontmatter, newRepeaterItem, normalizeCreateWrite, omitEmptyOnCreate, type RepeaterItemField, type RequiredGuardField, seedValueForRequiredField, withoutBlankArrayItems, type WriteModelField, } from './editor-write-model';
|
|
18
|
+
export { globMayMatchUnder, globToRegExp, UnreadableDirectoryError } from './fs/glob';
|
|
19
|
+
export { type CmsChangeset, type CmsCommit, CmsCommitConflictError, type CmsFileVersion, type CmsStagedChange, commitChangeset, createStagedFileSystem, digestBytes, type StagedFileSystem, versionMatches, versionOf, } from './fs/staged';
|
|
20
|
+
export type { CmsFileSystem, GlobOptions } from './fs/types';
|
|
21
|
+
export { type AddArrayItemInput, type CreateEntryInput, ensureMdxImports, type EntryAsset, type EntryOpsDeps, type GetEntryResult, parseFrontmatter, type RemoveArrayItemInput, serializeFrontmatter, type UpdateEntryInput, } from './handlers/entry-ops';
|
|
22
|
+
export { type ContemberStorageOptions, createContemberStorageAdapter, createFileSystemStorageAdapter, createS3StorageAdapter, decodeFilteredMediaCursor, type FileSystemStorageOptions, getFileExtension, isUnsafeFolder, listFilteredMedia, listProjectImages, type ListProjectImagesOptions, MEDIA_CURSOR_TYPE_MISMATCH, MEDIA_INVALID_CURSOR, MEDIA_INVALID_FOLDER, MEDIA_INVALID_ID, MEDIA_NOT_FOUND, MediaCursorError, mediaErrorStatus, MIME_BY_EXT, mimeFromExt, parseMediaTypeFilter, type S3StorageOptions, uploadsDirRelativeToRoot, } from './media/index';
|
|
23
|
+
export { parseProjectCmsConfig, parseProjectCmsConfigSource } from './project-config-ast';
|
|
24
|
+
export { CLOUDFLARE_REDIRECT_LIMITS, CMS_REDIRECTS_FILE, type MergedRedirects, mergeRedirects, parseRedirectRule, type RedirectLayer, type RedirectLine, type RedirectRuleLine, } from './redirects';
|
|
25
|
+
export { type RouteCollectionScan, scanRouteCollections } from './route-scan';
|
|
26
|
+
export { describeIssue, type LiveIssue, type LiveParseResult, type LiveSchema, type LiveSchemas, schemaFor } from './schema-port';
|
|
27
|
+
export { acceptsMissing, firstAcceptedEntry, governsPath, pointAt, type ProbePoint, rejectsValueAt } from './schema-probe';
|
|
28
|
+
export { applyDerivedTransform, computeDerivedFieldUpdates, computePathnameFromSpec, type DerivedFieldSpec, escapeHtml, relativeImportPath, resolvePathnameFromSpec, slugify, slugifyHref, } from './shared';
|
|
29
|
+
//# sourceMappingURL=portable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portable.d.ts","sourceRoot":"","sources":["../../src/portable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EACN,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,GACtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC5I,OAAO,EACN,cAAc,EACd,SAAS,EACT,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,aAAa,EACb,UAAU,GACV,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,mBAAmB,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAA;AACvE,OAAO,EAAE,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AACtE,OAAO,EAAE,iBA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,GACX,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merge the `_redirects` rules a site gets from several places into the one file a host reads.
|
|
3
|
+
*
|
|
4
|
+
* A nua site has three: `src/_redirects`, which editors maintain through the CMS, the hand-written
|
|
5
|
+
* `public/_redirects`, and the `redirects` map in the Astro config. Each used to be written into
|
|
6
|
+
* `dist/_redirects` on its own, so a path redirected in two of them was listed twice. Cloudflare
|
|
7
|
+
* Pages rejects a file with a repeated source, and with it the whole deploy.
|
|
8
|
+
*
|
|
9
|
+
* Only what is understood is changed: a line this reader cannot take apart (a Netlify role gate with
|
|
10
|
+
* no destination, a trailing comment) is kept as written, where it was. Merging is idempotent, so it
|
|
11
|
+
* does not matter which build step merges last, or how often.
|
|
12
|
+
*/
|
|
13
|
+
/** Where the CMS keeps the redirects editors manage, relative to the project root. */
|
|
14
|
+
export declare const CMS_REDIRECTS_FILE = "src/_redirects";
|
|
15
|
+
/** One source of rules, in the order of precedence the caller passes them (first wins). */
|
|
16
|
+
export interface RedirectLayer {
|
|
17
|
+
/** Where the rules come from, for messages: `src/_redirects`, `public/_redirects`. */
|
|
18
|
+
name: string;
|
|
19
|
+
text: string;
|
|
20
|
+
/**
|
|
21
|
+
* Rules written by people with less say over the site than its code, such as CMS editors. Such a
|
|
22
|
+
* layer may only redirect (a 3xx status, no conditions, so no proxying), and none of its rules may
|
|
23
|
+
* touch a path a guard from an unrestricted layer covers: a role gate, a 4xx, or any line not read
|
|
24
|
+
* as a rule. Otherwise an editor's rule, listed first, could take access control off a path.
|
|
25
|
+
*/
|
|
26
|
+
restricted?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface RedirectLine {
|
|
29
|
+
layer: string;
|
|
30
|
+
/** 1-based line number within its layer's text. */
|
|
31
|
+
lineNumber: number;
|
|
32
|
+
line: string;
|
|
33
|
+
}
|
|
34
|
+
export interface MergedRedirects {
|
|
35
|
+
/** The merged file, or `''` when no layer holds a rule. */
|
|
36
|
+
text: string;
|
|
37
|
+
/** The lines written, in order: rules with their fields joined by single spaces, other lines as written. */
|
|
38
|
+
lines: string[];
|
|
39
|
+
/** Rules dropped for a rule with the same source (and conditions) earlier in precedence. */
|
|
40
|
+
overridden: Array<{
|
|
41
|
+
kept: RedirectLine;
|
|
42
|
+
dropped: RedirectLine;
|
|
43
|
+
}>;
|
|
44
|
+
/** Rules kept but never reached: a pattern from a layer of higher precedence matches their source first. */
|
|
45
|
+
shadowed: Array<{
|
|
46
|
+
by: RedirectLine;
|
|
47
|
+
rule: RedirectLine;
|
|
48
|
+
}>;
|
|
49
|
+
/** Lines not read as a rule, kept as written. */
|
|
50
|
+
unrecognised: RedirectLine[];
|
|
51
|
+
/** Rules of a restricted layer left out: not a plain redirect, or touching a path a guard from code covers. */
|
|
52
|
+
refused: Array<{
|
|
53
|
+
rule: RedirectLine;
|
|
54
|
+
reason: string;
|
|
55
|
+
}>;
|
|
56
|
+
/** Rules with a literal source, and rules with a `*` or `:placeholder` in it. */
|
|
57
|
+
counts: {
|
|
58
|
+
exact: number;
|
|
59
|
+
pattern: number;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Cloudflare Pages' limits on a `_redirects` file. Netlify has none, so going over them is worth a
|
|
64
|
+
* warning, not a failed build.
|
|
65
|
+
*/
|
|
66
|
+
export declare const CLOUDFLARE_REDIRECT_LIMITS: {
|
|
67
|
+
readonly exact: 2000;
|
|
68
|
+
readonly pattern: 100;
|
|
69
|
+
};
|
|
70
|
+
/** One `_redirects` line, read the way a host reads it. */
|
|
71
|
+
export interface RedirectRuleLine {
|
|
72
|
+
source: string;
|
|
73
|
+
destination: string;
|
|
74
|
+
/** The status as written (`301`, `302!`), or `undefined` for the host's default. */
|
|
75
|
+
status: string | undefined;
|
|
76
|
+
/** Netlify query matches (`id=:id`) and conditions (`Language=cs`). */
|
|
77
|
+
conditions: string[];
|
|
78
|
+
/** Source plus conditions: two rules with the same key are the same rule. */
|
|
79
|
+
key: string;
|
|
80
|
+
/** A `*` or `:placeholder` in the source's path. */
|
|
81
|
+
pattern: boolean;
|
|
82
|
+
/** The fields joined by single spaces. */
|
|
83
|
+
text: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Read one `_redirects` line: `source [query matches] destination [status] [conditions]`. `undefined`
|
|
87
|
+
* for a line that does not have that shape, such as one with no destination, a source or destination
|
|
88
|
+
* that is not a path or URL, a status that is not a three-digit code, or a stray field.
|
|
89
|
+
*/
|
|
90
|
+
export declare function parseRedirectRule(line: string): RedirectRuleLine | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Merge `layers`, earlier layers taking precedence. Each layer's lines are written as a block, in their
|
|
93
|
+
* own order, ahead of every layer they take precedence over: a host applies the first rule that
|
|
94
|
+
* matches, so a higher layer wins for every path it covers, by an exact rule or by a pattern, and the
|
|
95
|
+
* order an author chose within a file is kept. Two rules are the same rule when they share a source
|
|
96
|
+
* and, for Netlify, the same conditions (`Language=cs`) and query matches (`id=:id`); the first wins.
|
|
97
|
+
*/
|
|
98
|
+
export declare function mergeRedirects(layers: RedirectLayer[]): MergedRedirects;
|
|
99
|
+
//# sourceMappingURL=redirects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirects.d.ts","sourceRoot":"","sources":["../../src/redirects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,mBAAmB,CAAA;AAElD,2FAA2F;AAC3F,MAAM,WAAW,aAAa;IAC7B,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,YAAY;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,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