@_linked/s3 1.0.3 → 1.1.1

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,80 +0,0 @@
1
- import { DeleteObjectCommandInput, S3Client } from '@aws-sdk/client-s3';
2
- import { PutObjectCommandInput, PutObjectCommandOutput } from '@aws-sdk/client-s3/dist-types/commands/PutObjectCommand';
3
- import { StreamingBlobPayloadInputTypes } from '@smithy/types';
4
- import { Shape } from '@_linked/core/shapes/Shape';
5
- export interface S3ClientConfigInput {
6
- endpoint?: string;
7
- accessKeyId?: string;
8
- secretAccessKey?: string;
9
- region?: string;
10
- }
11
- export declare const endpoint: string;
12
- /**
13
- * Builds an S3 client from explicit config, falling back to legacy env vars.
14
- * This enables multiple S3 stores in one process with independent credentials/endpoints.
15
- */
16
- export declare const createS3Client: (config?: S3ClientConfigInput) => S3Client;
17
- /**
18
- * Legacy singleton exported for backward compatibility. New code should prefer
19
- * per-instance clients by passing config into S3Bucket/S3FileStore.
20
- */
21
- export declare const s3Client: S3Client;
22
- export declare class S3Bucket extends Shape {
23
- static targetClass: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
24
- protected _client: S3Client;
25
- label: string;
26
- private ensureKeyPromise;
27
- constructor(n?: string | {
28
- id: string;
29
- }, clientConfig?: S3ClientConfigInput);
30
- get endpoint(): string;
31
- /**
32
- * Delete an object from the bucket.
33
- * @param key The key of the object to delete
34
- * @param options Additional options to pass to the DeleteObjectCommand
35
- * @returns The response from the DeleteObjectCommand
36
- * @todo Batch delete, see https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html
37
- */
38
- deleteObject(key: string, options?: Omit<DeleteObjectCommandInput, 'Key' | 'Bucket'>): Promise<import("@aws-sdk/client-s3").DeleteObjectCommandOutput>;
39
- copyObject(sourceKey: string, destinationKey: string, options?: Omit<PutObjectCommandInput, 'Key' | 'Bucket'>): Promise<boolean>;
40
- /**
41
- * Put an object into the bucket.
42
- *
43
- * @param key The key of the object to PUT (i.e. file name)
44
- * @param value The value of the object to PUT (i.e. file contents)
45
- * @param options Additional options to pass to the PutObjectCommand
46
- * @returns The response from the PutObjectCommand
47
- */
48
- putObject(key: string, value: StreamingBlobPayloadInputTypes, options?: Omit<PutObjectCommandInput, 'Body' | 'Key' | 'Bucket'>): Promise<PutObjectCommandOutput>;
49
- /**
50
- * Get a list of all object keys in the bucket.
51
- * Important to note that only a maximum 1000 keys will be returned.
52
- *
53
- * @param prefix The prefix to search for in the bucket. This can be a folder or the beginning of a file name.
54
- * @returns A list of all object keys in the bucket
55
- * @todo Recursive search within directories
56
- * @todo Implement pagination
57
- */
58
- getAllObjectKeys(prefix?: string): Promise<string[]>;
59
- /**
60
- * Get the contents of an object in the bucket.
61
- * @param key The key of the object to get
62
- * @returns The contents of the object as a string
63
- */
64
- getObject(key: string): Promise<string>;
65
- /**
66
- * Ensure that the given key exists in the bucket, the file contents
67
- * will be an empty json object.
68
- *
69
- * @param key The key to insert if it does not exist
70
- * @returns The promise that will resolve when the key exists
71
- */
72
- ensureKeyExists(key: string): Promise<string | void>;
73
- private _ensureKeyExists;
74
- private keyExists;
75
- /**
76
- * Create the bucket if it does not exist.
77
- * @returns The promise that will resolve when the bucket exists
78
- */
79
- createBucket(): Promise<import("@aws-sdk/client-s3").CreateBucketCommandOutput>;
80
- }
@@ -1,59 +0,0 @@
1
- import { IFileStore } from '@_linked/core/interfaces/IFileStore';
2
- import { Shape } from '@_linked/core/shapes/Shape';
3
- import { type S3ClientConfigInput } from './S3Bucket.js';
4
- import type { Readable } from 'stream';
5
- export interface S3FileStoreConfig {
6
- bucketName?: string;
7
- accessURL?: string;
8
- prefix?: string;
9
- clientConfig?: S3ClientConfigInput;
10
- }
11
- export declare class S3FileStore extends Shape implements IFileStore {
12
- static targetClass: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
13
- label: string;
14
- private _bucket;
15
- private readonly config;
16
- readonly accessURL: string;
17
- constructor(n: string | {
18
- id: string;
19
- }, config?: S3FileStoreConfig);
20
- private get bucket();
21
- private resolveBucketName;
22
- private resolveAccessURL;
23
- private get prefix();
24
- private normalizePath;
25
- private applyPrefix;
26
- private stripPrefix;
27
- /**
28
- * List all files in the bucket
29
- * @param recursive Whether to list files recursively or just the top-level files
30
- * @returns A list of file paths, relative to the endpoint
31
- * @todo Think about taking an options parameter instead of positional args
32
- * @todo Take a path parameter to list files in a subdirectory
33
- */
34
- listFiles(prefix?: string): Promise<string[]>;
35
- /**
36
- * Save a file to the bucket
37
- * @param filePath The path to save the file to, relative to the endpoint
38
- * @param fileContent The contents of the file as a buffer
39
- * @returns The public URL of the file
40
- */
41
- saveFile(filePath: string, fileContent: string | Uint8Array | Buffer | Readable, mimeType?: string, preventDuplicate?: boolean): Promise<string>;
42
- /**
43
- * Get a file from the bucket
44
- * @param filePath The path of the file to get, relative to the endpoint
45
- * @returns The contents of the file as a buffer
46
- */
47
- getFile(filePath: string): Promise<Buffer | null>;
48
- /**
49
- * Delete a file from the bucket
50
- * @param filePath The path of the file to delete, relative to the endpoint
51
- */
52
- deleteFile(filePath: string): Promise<void>;
53
- /**
54
- * Check if a file exists in the bucket
55
- * @param filePath The path of the file to check, relative to the endpoint
56
- * @returns Whether the file exists
57
- */
58
- fileExists(filePath: string): Promise<boolean>;
59
- }
@@ -1,12 +0,0 @@
1
- declare module '*.module.css' {
2
- const classes: {
3
- [key: string]: string;
4
- };
5
- export default classes;
6
- }
7
- declare module '*.module.scss' {
8
- const classes: {
9
- [key: string]: string;
10
- };
11
- export default classes;
12
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * Access URL for user-uploaded files. This intentionally prefers upload-specific
3
- * env vars, then falls back to legacy shared env vars.
4
- */
5
- export declare const getAccessURLUploadsStore: () => string;
6
- /**
7
- * Access URL for static web assets (bundles/images/root). This can be independent
8
- * from uploads and is expected to include the release version when configured by
9
- * app storage bootstrap (for example ".../4.1.1").
10
- */
11
- export declare const getAccessURLStaticStore: () => string;
12
- /**
13
- * Backward-compatible alias for existing imports.
14
- */
15
- export declare const getAccessURLS3FileStore: () => string;
@@ -1,63 +0,0 @@
1
- {
2
- "name": "@_linked/s3",
3
- "displayName": "s3",
4
- "description": "A general purpose Simple Storage Service (S3) package to be extended or used as is",
5
- "author": {
6
- "name": "Valentine Wilson",
7
- "email": "valentine@semantu.com",
8
- "url": "https://vw.codes"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": ""
13
- },
14
- "version": "1.0.3",
15
- "linkedPackage": true,
16
- "license": "ISC",
17
- "scripts": {
18
- "start": "npm exec linked dev",
19
- "build": "yarn linked build",
20
- "prepublishOnly": "yarn linked build production",
21
- "postpublish": "npm exec linked register"
22
- },
23
- "keywords": [
24
- "lincd",
25
- "linked data",
26
- "interoperable",
27
- "semantic web",
28
- "web3",
29
- "s3",
30
- "simple storage service",
31
- "cloud storage",
32
- "aws"
33
- ],
34
- "dependencies": {
35
- "@_linked/core": "^2.2.1",
36
- "@_linked/server": "~1.0",
37
- "@_linked/server-utils": "~1.0",
38
- "@aws-sdk/client-s3": "^3.159.0",
39
- "@aws-sdk/credential-providers": "^3.159.0",
40
- "cron": "^3.1.7",
41
- "mime": "2.6.0"
42
- },
43
- "devDependencies": {
44
- "@_linked/cli": "^1.2",
45
- "@changesets/changelog-github": "^0.5.2",
46
- "@changesets/cli": "^2.29.8",
47
- "@types/mime": "^3.0.4",
48
- "tsconfig-to-dual-package": "^1.2.0",
49
- "typescript": "^5.7.3",
50
- "typescript-plugin-css-modules": "^5.1.0"
51
- },
52
- "typesVersions": {
53
- "*": {
54
- "*": [
55
- "lib/esm/*"
56
- ]
57
- }
58
- },
59
- "publishConfig": {
60
- "access": "public"
61
- },
62
- "type": "module"
63
- }