@owlmeans/image-resource 0.1.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 +21 -0
- package/README.md +257 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +2 -0
- package/build/index.js.map +1 -0
- package/build/model.d.ts +6 -0
- package/build/model.d.ts.map +1 -0
- package/build/model.js +26 -0
- package/build/model.js.map +1 -0
- package/build/types.d.ts +8 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/package.json +37 -0
- package/src/index.ts +3 -0
- package/src/model.ts +30 -0
- package/src/types.ts +11 -0
- package/tsconfig.json +15 -0
- package/tsconfig.tsbuildinfo +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 OwlMeans Common — Fullstack typescript framework
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# @owlmeans/image-resource
|
|
2
|
+
|
|
3
|
+
The **@owlmeans/image-resource** package provides specialized image management functionality for OwlMeans Common Libraries, extending the core storage functionality with image-specific operations and validation schemas for handling images in object storage systems like S3.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
This package serves as an image-specific extension to the storage system, designed for:
|
|
8
|
+
|
|
9
|
+
- **Image Storage Management**: Specialized handling of image files in object storage
|
|
10
|
+
- **Image Metadata**: Enhanced metadata management specific to image files
|
|
11
|
+
- **Validation Schemas**: AJV schemas for image data validation
|
|
12
|
+
- **Type Safety**: TypeScript interfaces for image-related data structures
|
|
13
|
+
- **Storage Integration**: Seamless integration with OwlMeans storage infrastructure
|
|
14
|
+
|
|
15
|
+
## Key Concepts
|
|
16
|
+
|
|
17
|
+
### Image-specific Storage
|
|
18
|
+
Extends the basic file storage functionality with image-specific operations and metadata handling.
|
|
19
|
+
|
|
20
|
+
### Type Extensions
|
|
21
|
+
Provides specialized TypeScript interfaces that extend the base storage types for image-specific use cases.
|
|
22
|
+
|
|
23
|
+
### Schema Validation
|
|
24
|
+
Includes AJV schemas for validating image metadata and data structures.
|
|
25
|
+
|
|
26
|
+
### Storage Abstraction
|
|
27
|
+
Builds upon the storage-common package to provide higher-level image management capabilities.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install @owlmeans/image-resource
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API Reference
|
|
36
|
+
|
|
37
|
+
### Types
|
|
38
|
+
|
|
39
|
+
#### `ImageMeta`
|
|
40
|
+
Metadata interface for stored images.
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
interface ImageMeta extends StoredFileMeta {
|
|
44
|
+
// Extends base file metadata with image-specific properties
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### `StoredImage`
|
|
49
|
+
Interface for stored image files.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
interface StoredImage extends StoredFile {
|
|
53
|
+
// Extends base stored file interface for images
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### `ImageData`
|
|
58
|
+
Interface for image data with content.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
interface ImageData extends StoredFileWithData {
|
|
62
|
+
// Extends base file data interface for images
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Validation Schemas
|
|
67
|
+
|
|
68
|
+
#### `ImageMetaSchema`
|
|
69
|
+
AJV schema for validating image metadata.
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const ImageMetaSchema: JSONSchemaType<ImageMeta>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### `StoredImageSchema`
|
|
76
|
+
AJV schema for validating stored image objects.
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const StoredImageSchema: JSONSchemaType<StoredImage>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### `ImageDataSchema`
|
|
83
|
+
AJV schema for validating image data with content.
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const ImageDataSchema: JSONSchemaType<ImageData>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Usage Examples
|
|
90
|
+
|
|
91
|
+
### Basic Image Validation
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { ImageMetaSchema, StoredImageSchema, ImageDataSchema } from '@owlmeans/image-resource'
|
|
95
|
+
import Ajv from 'ajv'
|
|
96
|
+
|
|
97
|
+
const ajv = new Ajv()
|
|
98
|
+
|
|
99
|
+
// Validate image metadata
|
|
100
|
+
const validateImageMeta = ajv.compile(ImageMetaSchema)
|
|
101
|
+
const isValidMeta = validateImageMeta(imageMetadata)
|
|
102
|
+
|
|
103
|
+
// Validate stored image
|
|
104
|
+
const validateStoredImage = ajv.compile(StoredImageSchema)
|
|
105
|
+
const isValidImage = validateStoredImage(imageObject)
|
|
106
|
+
|
|
107
|
+
// Validate image data
|
|
108
|
+
const validateImageData = ajv.compile(ImageDataSchema)
|
|
109
|
+
const isValidData = validateImageData(imageDataObject)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Integration with Storage Systems
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
import type { ImageMeta, StoredImage, ImageData } from '@owlmeans/image-resource'
|
|
116
|
+
import { ImageMetaSchema } from '@owlmeans/image-resource'
|
|
117
|
+
|
|
118
|
+
class ImageStorageService {
|
|
119
|
+
async storeImage(file: File, metadata: Partial<ImageMeta>): Promise<StoredImage> {
|
|
120
|
+
// Validate metadata
|
|
121
|
+
const validateMeta = ajv.compile(ImageMetaSchema)
|
|
122
|
+
if (!validateMeta(metadata)) {
|
|
123
|
+
throw new Error('Invalid image metadata')
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Process and store image
|
|
127
|
+
const storedImage: StoredImage = {
|
|
128
|
+
id: generateId(),
|
|
129
|
+
filename: file.name,
|
|
130
|
+
contentType: file.type,
|
|
131
|
+
size: file.size,
|
|
132
|
+
...metadata
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return storedImage
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async getImageData(imageId: string): Promise<ImageData> {
|
|
139
|
+
// Retrieve image with data
|
|
140
|
+
const imageData = await this.storage.getWithData(imageId)
|
|
141
|
+
|
|
142
|
+
// Validate returned data
|
|
143
|
+
const validateData = ajv.compile(ImageDataSchema)
|
|
144
|
+
if (!validateData(imageData)) {
|
|
145
|
+
throw new Error('Invalid image data format')
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return imageData as ImageData
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Type-safe Image Operations
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import type { ImageMeta, StoredImage } from '@owlmeans/image-resource'
|
|
157
|
+
|
|
158
|
+
interface ImageProcessor {
|
|
159
|
+
processImage(image: StoredImage): Promise<StoredImage>
|
|
160
|
+
getImageMetadata(imageId: string): Promise<ImageMeta>
|
|
161
|
+
updateImageMetadata(imageId: string, metadata: Partial<ImageMeta>): Promise<void>
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
class BasicImageProcessor implements ImageProcessor {
|
|
165
|
+
async processImage(image: StoredImage): Promise<StoredImage> {
|
|
166
|
+
// Process the image (resize, compress, etc.)
|
|
167
|
+
return {
|
|
168
|
+
...image,
|
|
169
|
+
// Updated properties after processing
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async getImageMetadata(imageId: string): Promise<ImageMeta> {
|
|
174
|
+
const metadata = await this.storage.getMetadata(imageId)
|
|
175
|
+
return metadata as ImageMeta
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async updateImageMetadata(imageId: string, metadata: Partial<ImageMeta>): Promise<void> {
|
|
179
|
+
await this.storage.updateMetadata(imageId, metadata)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Integration Patterns
|
|
185
|
+
|
|
186
|
+
### Web Upload Handler
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
import type { ImageData } from '@owlmeans/image-resource'
|
|
190
|
+
import { ImageDataSchema } from '@owlmeans/image-resource'
|
|
191
|
+
|
|
192
|
+
async function handleImageUpload(file: File): Promise<ImageData> {
|
|
193
|
+
// Create image data object
|
|
194
|
+
const imageData: ImageData = {
|
|
195
|
+
id: generateId(),
|
|
196
|
+
filename: file.name,
|
|
197
|
+
contentType: file.type,
|
|
198
|
+
size: file.size,
|
|
199
|
+
data: await file.arrayBuffer(),
|
|
200
|
+
uploadedAt: new Date(),
|
|
201
|
+
// Additional image-specific metadata
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Validate before processing
|
|
205
|
+
const validate = ajv.compile(ImageDataSchema)
|
|
206
|
+
if (!validate(imageData)) {
|
|
207
|
+
throw new Error('Invalid image data')
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return imageData
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Storage Resource Integration
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
import { StorageResource } from '@owlmeans/storage-resource'
|
|
218
|
+
import type { StoredImage } from '@owlmeans/image-resource'
|
|
219
|
+
|
|
220
|
+
class ImageResource extends StorageResource<StoredImage> {
|
|
221
|
+
constructor() {
|
|
222
|
+
super({
|
|
223
|
+
schema: StoredImageSchema,
|
|
224
|
+
bucket: 'images',
|
|
225
|
+
// Image-specific configuration
|
|
226
|
+
})
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async uploadImage(file: File, metadata?: Partial<ImageMeta>): Promise<StoredImage> {
|
|
230
|
+
const imageData = await this.processFile(file)
|
|
231
|
+
return await this.store({
|
|
232
|
+
...imageData,
|
|
233
|
+
...metadata
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Best Practices
|
|
240
|
+
|
|
241
|
+
1. **Validation**: Always validate image data using provided schemas
|
|
242
|
+
2. **Type Safety**: Use TypeScript interfaces for compile-time safety
|
|
243
|
+
3. **Metadata Management**: Properly manage image-specific metadata
|
|
244
|
+
4. **Integration**: Leverage with storage-common and storage-resource packages
|
|
245
|
+
5. **Error Handling**: Implement proper error handling for validation failures
|
|
246
|
+
|
|
247
|
+
## Dependencies
|
|
248
|
+
|
|
249
|
+
This package depends on:
|
|
250
|
+
- `@owlmeans/storage-common` - Core storage types and schemas
|
|
251
|
+
- `ajv` - JSON schema validation
|
|
252
|
+
|
|
253
|
+
## Related Packages
|
|
254
|
+
|
|
255
|
+
- [`@owlmeans/storage-common`](../storage-common) - Core storage functionality
|
|
256
|
+
- [`@owlmeans/storage-resource`](../storage-resource) - Storage resource management
|
|
257
|
+
- [`@owlmeans/resource`](../resource) - Base resource management
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,YAAY,CAAA"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAA"}
|
package/build/model.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { JSONSchemaType } from 'ajv';
|
|
2
|
+
import type { ImageMeta, StoredImage, ImageData } from './types.js';
|
|
3
|
+
export declare const ImageMetaSchema: JSONSchemaType<ImageMeta>;
|
|
4
|
+
export declare const StoredImageSchema: JSONSchemaType<StoredImage>;
|
|
5
|
+
export declare const ImageDataSchema: JSONSchemaType<ImageData>;
|
|
6
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,KAAK,CAAA;AAEvC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEnE,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,SAAS,CAOrD,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,WAAW,CAOzD,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,SAAS,CAOrD,CAAA"}
|
package/build/model.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { StoredFileMetaSchema, StoredFileSchema, StoredFileWithDataSchema } from '@owlmeans/storage-common';
|
|
2
|
+
export const ImageMetaSchema = {
|
|
3
|
+
type: 'object',
|
|
4
|
+
properties: {
|
|
5
|
+
...StoredFileMetaSchema.properties,
|
|
6
|
+
},
|
|
7
|
+
required: [...StoredFileMetaSchema.required],
|
|
8
|
+
additionalProperties: false,
|
|
9
|
+
};
|
|
10
|
+
export const StoredImageSchema = {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
...StoredFileSchema.properties,
|
|
14
|
+
},
|
|
15
|
+
required: [...StoredFileSchema.required],
|
|
16
|
+
additionalProperties: false,
|
|
17
|
+
};
|
|
18
|
+
export const ImageDataSchema = {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
...StoredFileWithDataSchema.properties,
|
|
22
|
+
},
|
|
23
|
+
required: [...StoredFileWithDataSchema.required],
|
|
24
|
+
additionalProperties: false,
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAG3G,MAAM,CAAC,MAAM,eAAe,GAA8B;IACxD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,GAAG,oBAAoB,CAAC,UAAU;KACnC;IACD,QAAQ,EAAE,CAAC,GAAG,oBAAoB,CAAC,QAAQ,CAAC;IAC5C,oBAAoB,EAAE,KAAK;CAC5B,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAgC;IAC5D,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,GAAG,gBAAgB,CAAC,UAAU;KAC/B;IACD,QAAQ,EAAE,CAAC,GAAG,gBAAgB,CAAC,QAAQ,CAAC;IACxC,oBAAoB,EAAE,KAAK;CAC5B,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAA8B;IACxD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,GAAG,wBAAwB,CAAC,UAAU;KACvC;IACD,QAAQ,EAAE,CAAC,GAAG,wBAAwB,CAAC,QAAQ,CAAC;IAChD,oBAAoB,EAAE,KAAK;CAC5B,CAAA"}
|
package/build/types.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StoredFile, StoredFileMeta, StoredFileWithData } from '@owlmeans/storage-common';
|
|
2
|
+
export interface ImageMeta extends StoredFileMeta {
|
|
3
|
+
}
|
|
4
|
+
export interface StoredImage extends StoredFile {
|
|
5
|
+
}
|
|
6
|
+
export interface ImageData extends StoredFileWithData {
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAE9F,MAAM,WAAW,SAAU,SAAQ,cAAc;CAChD;AAED,MAAM,WAAW,WAAY,SAAQ,UAAU;CAC9C;AAED,MAAM,WAAW,SAAU,SAAQ,kBAAkB;CACpD"}
|
package/build/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@owlmeans/image-resource",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "tsc -b",
|
|
7
|
+
"dev": "sleep 390 && nodemon -e ts,tsx,json --watch src --exec \"tsc -p ./tsconfig.json\"",
|
|
8
|
+
"watch": "tsc -b -w --preserveWatchOutput --pretty"
|
|
9
|
+
},
|
|
10
|
+
"main": "build/index.js",
|
|
11
|
+
"module": "build/index.js",
|
|
12
|
+
"types": "build/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./build/index.js",
|
|
16
|
+
"require": "./build/index.js",
|
|
17
|
+
"default": "./build/index.js",
|
|
18
|
+
"module": "./build/index.js",
|
|
19
|
+
"types": "./build/index.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"ajv": "*"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@owlmeans/storage-resource": "^0.1.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^22.7.8",
|
|
30
|
+
"nodemon": "^3.1.7",
|
|
31
|
+
"typescript": "^5.6.3"
|
|
32
|
+
},
|
|
33
|
+
"private": false,
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/index.ts
ADDED
package/src/model.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type {JSONSchemaType} from 'ajv'
|
|
2
|
+
import { StoredFileMetaSchema, StoredFileSchema, StoredFileWithDataSchema } from '@owlmeans/storage-common'
|
|
3
|
+
import type { ImageMeta, StoredImage, ImageData } from './types.js'
|
|
4
|
+
|
|
5
|
+
export const ImageMetaSchema: JSONSchemaType<ImageMeta> = {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
...StoredFileMetaSchema.properties,
|
|
9
|
+
},
|
|
10
|
+
required: [...StoredFileMetaSchema.required],
|
|
11
|
+
additionalProperties: false,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const StoredImageSchema: JSONSchemaType<StoredImage> = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
...StoredFileSchema.properties,
|
|
18
|
+
},
|
|
19
|
+
required: [...StoredFileSchema.required],
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const ImageDataSchema: JSONSchemaType<ImageData> = {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
...StoredFileWithDataSchema.properties,
|
|
27
|
+
},
|
|
28
|
+
required: [...StoredFileWithDataSchema.required],
|
|
29
|
+
additionalProperties: false,
|
|
30
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
import type { StoredFile, StoredFileMeta, StoredFileWithData } from '@owlmeans/storage-common'
|
|
3
|
+
|
|
4
|
+
export interface ImageMeta extends StoredFileMeta {
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface StoredImage extends StoredFile {
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ImageData extends StoredFileWithData {
|
|
11
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"../tsconfig.default.json",
|
|
4
|
+
],
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"rootDir": "./src/", /* Specify the root folder within your source files. */
|
|
7
|
+
"outDir": "./build/", /* Specify an output folder for all emitted files. */
|
|
8
|
+
"moduleResolution": "Bundler",
|
|
9
|
+
},
|
|
10
|
+
"exclude": [
|
|
11
|
+
"./dist/**/*",
|
|
12
|
+
"./build/**/*",
|
|
13
|
+
"./*.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["./src/index.ts","./src/model.ts","./src/types.ts"],"version":"5.6.3"}
|