@conloca/content-api 0.2.3 → 0.2.4
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/.build-inputs.json +20 -9
- package/dist/asset-constraints.d.ts +9 -1
- package/dist/asset-constraints.d.ts.map +1 -1
- package/dist/asset-constraints.js +10 -2
- package/dist/asset-constraints.js.map +1 -1
- package/dist/asset-metadata-record.d.ts +18 -0
- package/dist/asset-metadata-record.d.ts.map +1 -0
- package/dist/asset-metadata-record.js +59 -0
- package/dist/asset-metadata-record.js.map +1 -0
- package/dist/asset-metadata-store.d.ts.map +1 -1
- package/dist/asset-metadata-store.js +7 -26
- package/dist/asset-metadata-store.js.map +1 -1
- package/dist/asset-naming.d.ts +39 -0
- package/dist/asset-naming.d.ts.map +1 -0
- package/dist/asset-naming.js +123 -0
- package/dist/asset-naming.js.map +1 -0
- package/dist/asset-operations.d.ts +3 -5
- package/dist/asset-operations.d.ts.map +1 -1
- package/dist/asset-operations.js +99 -90
- package/dist/asset-operations.js.map +1 -1
- package/dist/asset-types.d.ts +2 -0
- package/dist/asset-types.d.ts.map +1 -1
- package/dist/asset-usage.d.ts +8 -1
- package/dist/asset-usage.d.ts.map +1 -1
- package/dist/asset-usage.js +4 -1
- package/dist/asset-usage.js.map +1 -1
- package/dist/draft-media-ref.d.ts +9 -0
- package/dist/draft-media-ref.d.ts.map +1 -0
- package/dist/draft-media-ref.js +47 -0
- package/dist/draft-media-ref.js.map +1 -0
- package/dist/editor-host.d.ts +53 -0
- package/dist/editor-host.d.ts.map +1 -1
- package/dist/editor-host.js +92 -0
- package/dist/editor-host.js.map +1 -1
- package/dist/git-operations.d.ts +0 -5
- package/dist/git-operations.d.ts.map +1 -1
- package/dist/git-operations.js +1 -33
- package/dist/git-operations.js.map +1 -1
- package/dist/image-format.d.ts +9 -0
- package/dist/image-format.d.ts.map +1 -0
- package/dist/image-format.js +100 -0
- package/dist/image-format.js.map +1 -0
- package/dist/image-metadata.d.ts +11 -0
- package/dist/image-metadata.d.ts.map +1 -0
- package/dist/image-metadata.js +283 -0
- package/dist/image-metadata.js.map +1 -0
- package/dist/image-shrink.d.ts +15 -0
- package/dist/image-shrink.d.ts.map +1 -0
- package/dist/image-shrink.js +52 -0
- package/dist/image-shrink.js.map +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/lfs-attributes.d.ts +26 -0
- package/dist/lfs-attributes.d.ts.map +1 -0
- package/dist/lfs-attributes.js +285 -0
- package/dist/lfs-attributes.js.map +1 -0
- package/dist/skill-stamp.d.ts +10 -0
- package/dist/skill-stamp.d.ts.map +1 -0
- package/dist/skill-stamp.js +42 -0
- package/dist/skill-stamp.js.map +1 -0
- package/dist/svg-sanitize.d.ts +8 -0
- package/dist/svg-sanitize.d.ts.map +1 -0
- package/dist/svg-sanitize.js +260 -0
- package/dist/svg-sanitize.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/upload-bytes.d.ts +17 -0
- package/dist/upload-bytes.d.ts.map +1 -0
- package/dist/upload-bytes.js +43 -0
- package/dist/upload-bytes.js.map +1 -0
- package/dist/upload-refusals.d.ts +24 -0
- package/dist/upload-refusals.d.ts.map +1 -0
- package/dist/upload-refusals.js +49 -0
- package/dist/upload-refusals.js.map +1 -0
- package/package.json +43 -5
- package/src/asset-constraints.ts +14 -2
- package/src/asset-metadata-record.ts +57 -0
- package/src/asset-metadata-store.ts +12 -21
- package/src/asset-naming.ts +120 -0
- package/src/asset-operations.ts +108 -91
- package/src/asset-types.ts +2 -0
- package/src/asset-usage.ts +16 -2
- package/src/draft-media-ref.ts +46 -0
- package/src/editor-host.ts +117 -1
- package/src/git-operations.ts +1 -38
- package/src/image-format.ts +87 -0
- package/src/image-metadata.ts +266 -0
- package/src/image-shrink.ts +57 -0
- package/src/index.ts +45 -3
- package/src/lfs-attributes.ts +291 -0
- package/src/skill-stamp.ts +45 -0
- package/src/svg-sanitize.ts +260 -0
- package/src/types.ts +7 -0
- package/src/upload-bytes.ts +46 -0
- package/src/upload-refusals.ts +59 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every sentence an upload is refused or warned with, in every editor and on every server. Each names the file and
|
|
3
|
+
* the next step, so no raw server string reaches the person uploading. Pure strings: the browser entry re-exports
|
|
4
|
+
* them.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Megabytes as people count them, rounded up so a file just over the limit never reads as "25 MB". */
|
|
8
|
+
function megabytes(bytes: number): number {
|
|
9
|
+
return Math.ceil(bytes / 2 ** 20);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function overLimit(limit: number): string {
|
|
13
|
+
return `over the ${megabytes(limit)} MB limit for files stored in your site`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** A file over the size limit. */
|
|
17
|
+
export function tooLargeRefusal(name: string, bytes: number, limit: number): string {
|
|
18
|
+
return `${name} is ${megabytes(bytes)} MB, ${overLimit(limit)}. Save a smaller copy and upload that.`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** A video: the site's own embed component is where it belongs. */
|
|
22
|
+
export function videoRefusal(name: string): string {
|
|
23
|
+
return `${name} is a video. Videos are not stored with your site’s images: upload it to a video service and add it to the page with your site’s video embed component.`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A file whose type the site does not store, with the formats it does. */
|
|
27
|
+
export function unsupportedTypeRefusal(name: string, formats: readonly string[]): string {
|
|
28
|
+
return `${name} is not an image the editor can store. Use one of: ${formats.map((f) => f.toUpperCase()).join(', ')}.`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** A file named as an image whose bytes are not one. */
|
|
32
|
+
export function unreadableImageRefusal(name: string): string {
|
|
33
|
+
return `${name} could not be read as an image. Export it again from the program that made it and upload the new file.`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A URL import that failed; `detail` says why in plain words. */
|
|
37
|
+
export function importRefusal(detail: string): string {
|
|
38
|
+
return `The image at that link could not be downloaded: ${detail}. Check the link, or download the image and upload the file.`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** A URL import whose body passed the size limit. */
|
|
42
|
+
export function importTooLargeRefusal(limit: number): string {
|
|
43
|
+
return importRefusal(`it is ${overLimit(limit)}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** An online editor upload a Git LFS rule in the repository would catch. */
|
|
47
|
+
export function lfsRefusal(name: string, attributesPath: string, pattern: string): string {
|
|
48
|
+
return `${name} would be stored in Git LFS by the rule "${pattern}" in ${attributesPath}, and the online editor cannot store files in Git LFS. Remove that rule from the repository, or add the image with Git on your computer.`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** An online editor upload checked before the branch's files are in the editor's copy. */
|
|
52
|
+
export function repoNotReadyRefusal(): string {
|
|
53
|
+
return 'The editor is still reading this branch from your repository. Try again in a minute.';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** A large photo stored unshrunk because the optional `sharp` is not installed. */
|
|
57
|
+
export function shrinkUnavailableWarning(name: string): string {
|
|
58
|
+
return `${name} is larger than 2560 pixels and was stored without shrinking, because the image library sharp is not installed. Run "bun add sharp" in the site to shrink future uploads.`;
|
|
59
|
+
}
|