@dxos/plugin-file 0.0.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/LICENSE +105 -0
- package/PLUGIN.mdl +372 -0
- package/dist/lib/neutral/FileArticle-YU6NN3KN.mjs +80 -0
- package/dist/lib/neutral/FileArticle-YU6NN3KN.mjs.map +7 -0
- package/dist/lib/neutral/FilePlugin.mjs +58 -0
- package/dist/lib/neutral/FilePlugin.mjs.map +7 -0
- package/dist/lib/neutral/FilePlugin.node.mjs +23 -0
- package/dist/lib/neutral/FilePlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +23 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-DKGTSUUH.mjs +8 -0
- package/dist/lib/neutral/chunk-DKGTSUUH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GMYSEHV4.mjs +40 -0
- package/dist/lib/neutral/chunk-GMYSEHV4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-LBZ4MCLI.mjs +45 -0
- package/dist/lib/neutral/chunk-LBZ4MCLI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YODPX62X.mjs +136 -0
- package/dist/lib/neutral/chunk-YODPX62X.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZUXUTRAJ.mjs +80 -0
- package/dist/lib/neutral/chunk-ZUXUTRAJ.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +74 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +59 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-IUUG7RI6.mjs +17 -0
- package/dist/lib/neutral/create-IUUG7RI6.mjs.map +7 -0
- package/dist/lib/neutral/create-object-V667G4ZL.mjs +30 -0
- package/dist/lib/neutral/create-object-V667G4ZL.mjs.map +7 -0
- package/dist/lib/neutral/file-uploader-BCJH6TUL.mjs +41 -0
- package/dist/lib/neutral/file-uploader-BCJH6TUL.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +32 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/inline-backend-FGGGDYRB.mjs +37 -0
- package/dist/lib/neutral/inline-backend-FGGGDYRB.mjs.map +7 -0
- package/dist/lib/neutral/markdown-extension-RA5YNMTW.mjs +230 -0
- package/dist/lib/neutral/markdown-extension-RA5YNMTW.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-CPDANWGH.mjs +13 -0
- package/dist/lib/neutral/operation-handler-CPDANWGH.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-5BXKSHD2.mjs +60 -0
- package/dist/lib/neutral/react-surface-5BXKSHD2.mjs.map +7 -0
- package/dist/lib/neutral/read-HG6CSWKR.mjs +28 -0
- package/dist/lib/neutral/read-HG6CSWKR.mjs.map +7 -0
- package/dist/lib/neutral/settings-RR3RESL2.mjs +28 -0
- package/dist/lib/neutral/settings-RR3RESL2.mjs.map +7 -0
- package/dist/lib/neutral/skill-definition-YHBGWBUS.mjs +15 -0
- package/dist/lib/neutral/skill-definition-YHBGWBUS.mjs.map +7 -0
- package/dist/lib/neutral/skills/index.mjs +11 -0
- package/dist/lib/neutral/skills/index.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +36 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +22 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/dx.config.d.ts +28 -0
- package/dist/types/dx.config.d.ts.map +1 -0
- package/dist/types/src/FilePlugin.d.ts +4 -0
- package/dist/types/src/FilePlugin.d.ts.map +1 -0
- package/dist/types/src/FilePlugin.node.d.ts +4 -0
- package/dist/types/src/FilePlugin.node.d.ts.map +1 -0
- package/dist/types/src/FilePlugin.test.d.ts +2 -0
- package/dist/types/src/FilePlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +5 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/file-uploader.d.ts +5 -0
- package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +11 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/inline-backend.d.ts +11 -0
- package/dist/types/src/capabilities/inline-backend.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown-extension.d.ts +5 -0
- package/dist/types/src/capabilities/markdown-extension.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +5 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/capabilities/skill-definition.d.ts +5 -0
- package/dist/types/src/capabilities/skill-definition.d.ts.map +1 -0
- package/dist/types/src/components/FileInput/FileInput.d.ts +8 -0
- package/dist/types/src/components/FileInput/FileInput.d.ts.map +1 -0
- package/dist/types/src/components/FileInput/index.d.ts +2 -0
- package/dist/types/src/components/FileInput/index.d.ts.map +1 -0
- package/dist/types/src/components/FilePreview/FilePreview.d.ts +12 -0
- package/dist/types/src/components/FilePreview/FilePreview.d.ts.map +1 -0
- package/dist/types/src/components/FilePreview/index.d.ts +2 -0
- package/dist/types/src/components/FilePreview/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +3 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/containers/FileArticle/FileArticle.d.ts +7 -0
- package/dist/types/src/containers/FileArticle/FileArticle.d.ts.map +1 -0
- package/dist/types/src/containers/FileArticle/index.d.ts +2 -0
- package/dist/types/src/containers/FileArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/FileSettings/FileSettings.d.ts +6 -0
- package/dist/types/src/containers/FileSettings/FileSettings.d.ts.map +1 -0
- package/dist/types/src/containers/FileSettings/index.d.ts +2 -0
- package/dist/types/src/containers/FileSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/extensions/image.d.ts +12 -0
- package/dist/types/src/extensions/image.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +33 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/operations/create.d.ts +25 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/create.test.d.ts +2 -0
- package/dist/types/src/operations/create.test.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/read.d.ts +5 -0
- package/dist/types/src/operations/read.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/skills/file-skill.d.ts +5 -0
- package/dist/types/src/skills/file-skill.d.ts.map +1 -0
- package/dist/types/src/skills/index.d.ts +2 -0
- package/dist/types/src/skills/index.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +40 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types/FileCapabilities.d.ts +41 -0
- package/dist/types/src/types/FileCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/FileOperation.d.ts +42 -0
- package/dist/types/src/types/FileOperation.d.ts.map +1 -0
- package/dist/types/src/types/Settings.d.ts +8 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +7 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/limits.d.ts +4 -0
- package/dist/types/src/types/limits.d.ts.map +1 -0
- package/dist/types/src/types/types.d.ts +9 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/dx.config.ts +35 -0
- package/package.json +139 -0
- package/src/FilePlugin.node.ts +19 -0
- package/src/FilePlugin.test.ts +26 -0
- package/src/FilePlugin.tsx +56 -0
- package/src/capabilities/create-object.ts +30 -0
- package/src/capabilities/file-uploader.ts +35 -0
- package/src/capabilities/index.ts +18 -0
- package/src/capabilities/inline-backend.ts +41 -0
- package/src/capabilities/markdown-extension.ts +38 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +61 -0
- package/src/capabilities/settings.ts +31 -0
- package/src/capabilities/skill-definition.ts +14 -0
- package/src/components/FileInput/FileInput.tsx +48 -0
- package/src/components/FileInput/index.ts +5 -0
- package/src/components/FilePreview/FilePreview.tsx +55 -0
- package/src/components/FilePreview/index.ts +5 -0
- package/src/components/index.ts +6 -0
- package/src/containers/FileArticle/FileArticle.tsx +84 -0
- package/src/containers/FileArticle/index.ts +5 -0
- package/src/containers/FileSettings/FileSettings.tsx +67 -0
- package/src/containers/FileSettings/index.ts +5 -0
- package/src/containers/index.ts +9 -0
- package/src/extensions/image.tsx +232 -0
- package/src/extensions/index.ts +5 -0
- package/src/index.ts +7 -0
- package/src/meta.ts +9 -0
- package/src/operations/create.test.ts +53 -0
- package/src/operations/create.ts +87 -0
- package/src/operations/index.ts +10 -0
- package/src/operations/read.ts +35 -0
- package/src/plugin.ts +11 -0
- package/src/skills/file-skill.ts +38 -0
- package/src/skills/index.ts +5 -0
- package/src/translations.ts +37 -0
- package/src/types/FileCapabilities.ts +58 -0
- package/src/types/FileOperation.ts +44 -0
- package/src/types/Settings.ts +23 -0
- package/src/types/index.ts +12 -0
- package/src/types/limits.ts +21 -0
- package/src/types/types.ts +21 -0
- package/src/vite-env.d.ts +10 -0
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Skill, Template } from '@dxos/compute';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
7
|
+
|
|
8
|
+
import { FileOperation } from '../types';
|
|
9
|
+
|
|
10
|
+
export const SKILL_KEY = 'org.dxos.skill.file';
|
|
11
|
+
|
|
12
|
+
const make = () =>
|
|
13
|
+
Skill.make({
|
|
14
|
+
key: SKILL_KEY,
|
|
15
|
+
name: 'File',
|
|
16
|
+
description: 'Read the contents of files (images, videos, PDFs) as File content blocks.',
|
|
17
|
+
tools: Skill.toolDefinitions({
|
|
18
|
+
operations: [FileOperation.Read],
|
|
19
|
+
}),
|
|
20
|
+
instructions: Template.make({
|
|
21
|
+
source: trim`
|
|
22
|
+
{{! File }}
|
|
23
|
+
|
|
24
|
+
You can read the contents of files.
|
|
25
|
+
Calling the read tool returns the file contents as a File content block (a data URL for
|
|
26
|
+
inline files, the original URL for external files). The model receives the file natively
|
|
27
|
+
and can describe, transcribe, or otherwise reason over its contents.
|
|
28
|
+
`,
|
|
29
|
+
}),
|
|
30
|
+
agentCanEnable: true,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const skill: Skill.Definition = {
|
|
34
|
+
key: SKILL_KEY,
|
|
35
|
+
make,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default skill;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Type } from '@dxos/echo';
|
|
6
|
+
import { type Resource } from '@dxos/react-ui';
|
|
7
|
+
|
|
8
|
+
import { meta } from '#meta';
|
|
9
|
+
import { File } from '#types';
|
|
10
|
+
|
|
11
|
+
export const translations = [
|
|
12
|
+
{
|
|
13
|
+
'en-US': {
|
|
14
|
+
[Type.getTypename(File.File)]: {
|
|
15
|
+
'typename.label': 'File',
|
|
16
|
+
'typename.label_zero': 'Files',
|
|
17
|
+
'typename.label_one': 'File',
|
|
18
|
+
'typename.label_other': 'Files',
|
|
19
|
+
'object-name.placeholder': 'New file',
|
|
20
|
+
'add-object.label': 'Add file',
|
|
21
|
+
'rename-object.label': 'Rename file',
|
|
22
|
+
'delete-object.label': 'Delete file',
|
|
23
|
+
'object-deleted.label': 'File deleted',
|
|
24
|
+
},
|
|
25
|
+
[meta.profile.key]: {
|
|
26
|
+
'plugin.name': 'File',
|
|
27
|
+
'file-input.placeholder': 'Drop a file here, or click to select a file',
|
|
28
|
+
'too-large-error.message': 'File is too large. Maximum size is 4MB.',
|
|
29
|
+
'unsupported-type-error.message': 'Unsupported file type. Only images, videos, and PDFs are allowed.',
|
|
30
|
+
'settings.backend.label': 'Storage backend',
|
|
31
|
+
'settings.backend.description':
|
|
32
|
+
'Where uploaded files are stored. Install additional plugins (e.g. WNFS) to add backends.',
|
|
33
|
+
'settings.backend.placeholder': 'Select backend',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
] as const satisfies Resource[];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
7
|
+
import { type Atom } from '@effect-atom/atom-react';
|
|
8
|
+
|
|
9
|
+
import { Capability } from '@dxos/app-framework';
|
|
10
|
+
import { type Database } from '@dxos/echo';
|
|
11
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
12
|
+
import { File } from '@dxos/types';
|
|
13
|
+
|
|
14
|
+
import { meta } from '#meta';
|
|
15
|
+
|
|
16
|
+
import * as Settings from './Settings';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A file storage backend. Each backend ingests a File from the user and
|
|
20
|
+
* returns the metadata + the {@link File.FileData} to attach to a
|
|
21
|
+
* {@link File.File} object.
|
|
22
|
+
*/
|
|
23
|
+
export type Backend = {
|
|
24
|
+
/** Stable backend id (e.g. 'inline', 'wnfs'). Used as the settings key. */
|
|
25
|
+
readonly id: string;
|
|
26
|
+
/** Display label shown in the settings UI. */
|
|
27
|
+
readonly name: string;
|
|
28
|
+
/** Description shown next to the backend in settings. */
|
|
29
|
+
readonly description?: string;
|
|
30
|
+
/** Upload a file. Throws on validation errors (size cap, unsupported MIME). */
|
|
31
|
+
readonly upload: (file: globalThis.File, db: Database.Database) => Promise<UploadResult>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type UploadResult = {
|
|
35
|
+
readonly name: string;
|
|
36
|
+
readonly type: string;
|
|
37
|
+
readonly size: number;
|
|
38
|
+
readonly data: File.FileData;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Backend = Capability.make<Backend>(`${meta.profile.key}.capability.backend`);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Resolves an external URL (e.g. `wnfs://…`) into a renderable URL (a
|
|
45
|
+
* `blob:`, `data:`, or `http(s):` URL). Consumers iterate registered
|
|
46
|
+
* resolvers and pick the first that returns true from {@link UrlResolver#test}.
|
|
47
|
+
*/
|
|
48
|
+
export type UrlResolver = {
|
|
49
|
+
readonly id: string;
|
|
50
|
+
readonly test: (url: string) => boolean;
|
|
51
|
+
readonly resolve: (url: string, file: File.File, space?: Space) => Promise<string | undefined>;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const UrlResolver = Capability.make<UrlResolver>(`${meta.profile.key}.capability.url-resolver`);
|
|
55
|
+
|
|
56
|
+
export const SettingsAtom = Capability.make<Atom.Writable<Settings.Settings>>(
|
|
57
|
+
`${meta.profile.key}.capability.settings`,
|
|
58
|
+
);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
8
|
+
|
|
9
|
+
import { Capability } from '@dxos/app-framework';
|
|
10
|
+
import { Operation } from '@dxos/compute';
|
|
11
|
+
import { Database, DXN, Ref, Type } from '@dxos/echo';
|
|
12
|
+
import { ContentBlock, File } from '@dxos/types';
|
|
13
|
+
|
|
14
|
+
import { meta } from '#meta';
|
|
15
|
+
|
|
16
|
+
import { FileAction } from './types';
|
|
17
|
+
|
|
18
|
+
const makeKey = (name: string) => DXN.make(`${meta.profile.key}.operation.${name}`);
|
|
19
|
+
|
|
20
|
+
export const Create = Operation.make({
|
|
21
|
+
meta: { key: makeKey('create'), name: 'Create File', icon: 'ph--file--regular' },
|
|
22
|
+
services: [Capability.Service],
|
|
23
|
+
input: Schema.extend(FileAction.CreateFileSchema, Schema.Struct({ db: Database.Database })),
|
|
24
|
+
output: Schema.Struct({
|
|
25
|
+
object: Type.getSchema(File.File),
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const Read = Operation.make({
|
|
30
|
+
meta: {
|
|
31
|
+
key: makeKey('read'),
|
|
32
|
+
name: 'Read File',
|
|
33
|
+
description:
|
|
34
|
+
'Reads the contents of a file and returns them as a File content block (data URL for inline files, original URL for external files).',
|
|
35
|
+
icon: 'ph--file-arrow-down--regular',
|
|
36
|
+
},
|
|
37
|
+
input: Schema.Struct({
|
|
38
|
+
file: Ref.Ref(File.File).annotations({
|
|
39
|
+
description: 'The file to read.',
|
|
40
|
+
}),
|
|
41
|
+
}),
|
|
42
|
+
output: ContentBlock.ContentBlockResult,
|
|
43
|
+
services: [Database.Service],
|
|
44
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
8
|
+
|
|
9
|
+
export const DEFAULT_BACKEND_ID = 'inline';
|
|
10
|
+
|
|
11
|
+
export const Settings = Schema.mutable(
|
|
12
|
+
Schema.Struct({
|
|
13
|
+
backend: Schema.optional(
|
|
14
|
+
Schema.String.annotations({
|
|
15
|
+
title: 'File storage backend',
|
|
16
|
+
description:
|
|
17
|
+
'Where uploaded files are stored. Defaults to inline (bytes saved on the ECHO object). Install additional plugins (e.g. WNFS) to add external backends.',
|
|
18
|
+
}),
|
|
19
|
+
),
|
|
20
|
+
}),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export interface Settings extends Schema.Schema.Type<typeof Settings> {}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
export { File } from '@dxos/types';
|
|
6
|
+
|
|
7
|
+
export * from './limits';
|
|
8
|
+
export * from './types';
|
|
9
|
+
|
|
10
|
+
export * as FileCapabilities from './FileCapabilities';
|
|
11
|
+
export * as FileOperation from './FileOperation';
|
|
12
|
+
export * as Settings from './Settings';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
export const MAX_FILE_SIZE = 4 * 1024 * 1024;
|
|
6
|
+
|
|
7
|
+
export const ACCEPTED_MIME: Record<string, string[]> = {
|
|
8
|
+
'image/*': ['.jpg', '.jpeg', '.png', '.gif', '.webp', '.svg'],
|
|
9
|
+
'video/*': ['.mp4', '.webm', '.mov'],
|
|
10
|
+
'application/pdf': ['.pdf'],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const isAcceptedMimeType = (type: string): boolean => {
|
|
14
|
+
if (type === 'application/pdf') {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
if (type.startsWith('image/') || type.startsWith('video/')) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { meta } from '#meta';
|
|
8
|
+
|
|
9
|
+
import { ACCEPTED_MIME } from './limits';
|
|
10
|
+
|
|
11
|
+
export namespace FileAction {
|
|
12
|
+
export const UploadAnnotationId = Symbol.for(`${meta.profile.key}.annotation.upload`);
|
|
13
|
+
|
|
14
|
+
export const CreateFileSchema = Schema.Struct({
|
|
15
|
+
file: Schema.instanceOf(File).annotations({
|
|
16
|
+
[UploadAnnotationId]: ACCEPTED_MIME,
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export type CreateFileForm = Schema.Schema.Type<typeof CreateFileSchema>;
|
|
21
|
+
}
|