@_linked/s3 1.0.2 → 1.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.
@@ -0,0 +1,173 @@
1
+ import { Shape } from '@_linked/core/shapes/Shape';
2
+ import mime from 'mime';
3
+ import path from 'path';
4
+ import { s3 } from '../ontologies/s3.js';
5
+ import { S3Bucket } from './S3Bucket.js';
6
+ const trimSlashes = (value = '') => value.replace(/^\/+|\/+$/g, '');
7
+ const trimTrailingSlash = (value = '') => value.replace(/\/+$/g, '');
8
+ export class S3FileStore extends Shape {
9
+ constructor(n, config = {}) {
10
+ if (typeof n === 'string') {
11
+ //set a fixed URI. This is important because the URI needs to match on the frontend and backend
12
+ super(`${process.env.DATA_ROOT}/s3-filestore/${n}`);
13
+ this.label = n;
14
+ }
15
+ else {
16
+ super(n);
17
+ }
18
+ this.config = config;
19
+ this.accessURL = this.resolveAccessURL();
20
+ }
21
+ get bucket() {
22
+ const bucketName = this.resolveBucketName();
23
+ if (!bucketName) {
24
+ throw new Error('S3_FILES_BUCKET_NAME environment variable must be set to use S3FileStore (or pass bucketName in config)');
25
+ }
26
+ if (!this._bucket) {
27
+ this._bucket = new S3Bucket(bucketName, this.config.clientConfig);
28
+ }
29
+ return this._bucket;
30
+ }
31
+ resolveBucketName() {
32
+ var _a, _b, _c;
33
+ // Scoped store config wins. Legacy shared env vars stay as fallback to keep
34
+ // existing apps working while allowing upload/static separation.
35
+ return ((_c = (_b = (_a = this.config.bucketName) !== null && _a !== void 0 ? _a : process.env.S3_FILES_BUCKET_NAME) !== null && _b !== void 0 ? _b : process.env.UPLOADS_S3_FILES_BUCKET_NAME) !== null && _c !== void 0 ? _c : process.env.STATIC_S3_FILES_BUCKET_NAME);
36
+ }
37
+ resolveAccessURL() {
38
+ var _a, _b, _c, _d, _e, _f, _g;
39
+ const explicitAccessURL = (_c = (_b = (_a = this.config.accessURL) !== null && _a !== void 0 ? _a : process.env.S3_CDN_URL) !== null && _b !== void 0 ? _b : process.env.UPLOADS_ACCESS_URL) !== null && _c !== void 0 ? _c : process.env.STATIC_ACCESS_URL;
40
+ if (explicitAccessURL) {
41
+ return trimTrailingSlash(explicitAccessURL);
42
+ }
43
+ const endpoint = (_g = (_f = (_e = (_d = this.config.clientConfig) === null || _d === void 0 ? void 0 : _d.endpoint) !== null && _e !== void 0 ? _e : process.env.S3_BUCKET_ENDPOINT) !== null && _f !== void 0 ? _f : process.env.UPLOADS_S3_BUCKET_ENDPOINT) !== null && _g !== void 0 ? _g : process.env.STATIC_S3_BUCKET_ENDPOINT;
44
+ const bucketName = this.resolveBucketName();
45
+ if (endpoint && bucketName) {
46
+ return `${trimTrailingSlash(endpoint)}/${bucketName}`;
47
+ }
48
+ return trimTrailingSlash(endpoint);
49
+ }
50
+ get prefix() {
51
+ var _a;
52
+ // Optional per-store key prefix, used for versioned static publishing.
53
+ return trimSlashes((_a = this.config.prefix) !== null && _a !== void 0 ? _a : '');
54
+ }
55
+ normalizePath(filePath) {
56
+ return filePath.replace(/^\/+/, '');
57
+ }
58
+ applyPrefix(filePath) {
59
+ const normalizedPath = this.normalizePath(filePath);
60
+ if (!this.prefix) {
61
+ return normalizedPath;
62
+ }
63
+ // Guard against accidental double prefixing when callers pass already-prefixed keys.
64
+ if (normalizedPath.startsWith(`${this.prefix}/`)) {
65
+ return normalizedPath;
66
+ }
67
+ return `${this.prefix}/${normalizedPath}`;
68
+ }
69
+ stripPrefix(filePath) {
70
+ if (!this.prefix) {
71
+ return filePath;
72
+ }
73
+ const normalizedPath = this.normalizePath(filePath);
74
+ const prefixedPath = `${this.prefix}/`;
75
+ if (normalizedPath.startsWith(prefixedPath)) {
76
+ return normalizedPath.substring(prefixedPath.length);
77
+ }
78
+ return normalizedPath;
79
+ }
80
+ /**
81
+ * List all files in the bucket
82
+ * @param recursive Whether to list files recursively or just the top-level files
83
+ * @returns A list of file paths, relative to the endpoint
84
+ * @todo Think about taking an options parameter instead of positional args
85
+ * @todo Take a path parameter to list files in a subdirectory
86
+ */
87
+ async listFiles(prefix) {
88
+ let bucket = this.bucket;
89
+ const keyPrefix = this.prefix
90
+ ? prefix
91
+ ? this.applyPrefix(prefix)
92
+ : `${this.prefix}/`
93
+ : prefix;
94
+ return bucket
95
+ .getAllObjectKeys(keyPrefix)
96
+ .then((keys) => keys.map((key) => this.stripPrefix(key)))
97
+ .catch((err) => {
98
+ console.error('Error listing files:', err);
99
+ return [];
100
+ });
101
+ }
102
+ /**
103
+ * Save a file to the bucket
104
+ * @param filePath The path to save the file to, relative to the endpoint
105
+ * @param fileContent The contents of the file as a buffer
106
+ * @returns The public URL of the file
107
+ */
108
+ async saveFile(filePath, fileContent, mimeType, preventDuplicate = false) {
109
+ let bucket = this.bucket;
110
+ filePath = this.normalizePath(filePath);
111
+ if (!mimeType) {
112
+ mimeType = mime.getType(filePath);
113
+ }
114
+ // console.log(`mimeType of ${filePath} is ${mimeType}`);
115
+ //first check if the object already exists
116
+ if (preventDuplicate && (await this.fileExists(filePath))) {
117
+ //if yes, use a more unique name based on the current unix timestamp
118
+ filePath = `${path.dirname(filePath)}/${Date.now()}-${path.basename(filePath)}`;
119
+ console.log('File already exists, renaming to avoid overwrite: ' + filePath);
120
+ }
121
+ const key = this.applyPrefix(filePath);
122
+ let res = await bucket
123
+ .putObject(key, fileContent, {
124
+ ContentType: mimeType,
125
+ })
126
+ .catch((err) => {
127
+ console.error('Error saving file to S3:', err);
128
+ return false;
129
+ });
130
+ if (!res) {
131
+ return null;
132
+ }
133
+ return this.accessURL + '/' + filePath;
134
+ }
135
+ /**
136
+ * Get a file from the bucket
137
+ * @param filePath The path of the file to get, relative to the endpoint
138
+ * @returns The contents of the file as a buffer
139
+ */
140
+ async getFile(filePath) {
141
+ let bucket = this.bucket;
142
+ const key = this.applyPrefix(filePath);
143
+ const bufferString = await bucket.getObject(key);
144
+ return Buffer.from(bufferString, 'base64');
145
+ }
146
+ /**
147
+ * Delete a file from the bucket
148
+ * @param filePath The path of the file to delete, relative to the endpoint
149
+ */
150
+ async deleteFile(filePath) {
151
+ let bucket = this.bucket;
152
+ await bucket.deleteObject(this.applyPrefix(filePath));
153
+ }
154
+ /**
155
+ * Check if a file exists in the bucket
156
+ * @param filePath The path of the file to check, relative to the endpoint
157
+ * @returns Whether the file exists
158
+ */
159
+ async fileExists(filePath) {
160
+ try {
161
+ const bucket = await this.bucket.getObject(this.applyPrefix(filePath));
162
+ if (!bucket) {
163
+ return false;
164
+ }
165
+ return true;
166
+ }
167
+ catch (e) {
168
+ return false;
169
+ }
170
+ }
171
+ }
172
+ S3FileStore.targetClass = s3.FileStore;
173
+ //# sourceMappingURL=S3FileStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"S3FileStore.js","sourceRoot":"","sources":["../../../src/shapes/S3FileStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAA4B,MAAM,eAAe,CAAC;AAUnE,MAAM,WAAW,GAAG,CAAC,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AACpE,MAAM,iBAAiB,GAAG,CAAC,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAErE,MAAM,OAAO,WAAY,SAAQ,KAAK;IASpC,YAAY,CAA0B,EAAE,SAA4B,EAAE;QACpE,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1B,+FAA+F;YAC/F,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,iBAAiB,CAAC,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,KAAK,GAAG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CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,QAAgB;QAC/B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;YACvE,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,KAAK,CAAC;YACf,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;;AAxNM,uBAAW,GAAG,EAAE,CAAC,SAAS,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,93 @@
1
+ const trimTrailingSlash = (value = '') => value.replace(/\/+$/g, '');
2
+ const trimSlashes = (value = '') => value.replace(/^\/+|\/+$/g, '');
3
+ /**
4
+ * Read env vars in a browser-safe way while still allowing webpack EnvironmentPlugin
5
+ * to inline direct `process.env.X` references at build time.
6
+ */
7
+ const readEnv = (getter) => {
8
+ try {
9
+ return getter();
10
+ }
11
+ catch (_error) {
12
+ return undefined;
13
+ }
14
+ };
15
+ // Shared legacy env set used when scoped STATIC_/UPLOADS_ vars are absent.
16
+ const getSharedS3Env = () => ({
17
+ accessURL: readEnv(() => process.env.S3_CDN_URL),
18
+ endpoint: readEnv(() => process.env.S3_BUCKET_ENDPOINT),
19
+ bucketName: readEnv(() => process.env.S3_FILES_BUCKET_NAME),
20
+ });
21
+ // Returns the first defined, non-empty value from a fallback chain.
22
+ const firstNonEmpty = (...values) => {
23
+ for (const value of values) {
24
+ if (value !== undefined && value !== null && value !== '') {
25
+ return value;
26
+ }
27
+ }
28
+ return undefined;
29
+ };
30
+ // Builds versioned/static URL segments without duplicate or broken slashes.
31
+ const appendPathSegment = (base, segment) => {
32
+ const cleanBase = trimTrailingSlash(base || '');
33
+ const cleanSegment = trimSlashes(segment || '');
34
+ if (!cleanBase) {
35
+ return undefined;
36
+ }
37
+ if (!cleanSegment || cleanBase.endsWith(`/${cleanSegment}`)) {
38
+ return cleanBase;
39
+ }
40
+ return `${cleanBase}/${cleanSegment}`;
41
+ };
42
+ // Normalizes the final public access URL from either direct accessURL or endpoint+bucket.
43
+ const getAccessURL = ({ accessURL, endpoint, bucketName, }) => {
44
+ if (accessURL) {
45
+ return trimTrailingSlash(accessURL);
46
+ }
47
+ if (endpoint && bucketName) {
48
+ return `${trimTrailingSlash(endpoint)}/${bucketName}`;
49
+ }
50
+ return trimTrailingSlash(endpoint);
51
+ };
52
+ /**
53
+ * Access URL for user-uploaded files. This intentionally prefers upload-specific
54
+ * env vars, then falls back to legacy shared env vars.
55
+ */
56
+ export const getAccessURLUploadsStore = () => {
57
+ const shared = getSharedS3Env();
58
+ const uploadsAccessURL = readEnv(() => process.env.UPLOADS_ACCESS_URL);
59
+ const uploadsEndpoint = readEnv(() => process.env.UPLOADS_S3_BUCKET_ENDPOINT);
60
+ const uploadsBucketName = readEnv(() => process.env.UPLOADS_S3_FILES_BUCKET_NAME);
61
+ return getAccessURL({
62
+ accessURL: firstNonEmpty(uploadsAccessURL, shared.accessURL),
63
+ endpoint: firstNonEmpty(uploadsEndpoint, shared.endpoint),
64
+ bucketName: firstNonEmpty(uploadsBucketName, shared.bucketName),
65
+ });
66
+ };
67
+ /**
68
+ * Access URL for static web assets (bundles/images/root). This can be independent
69
+ * from uploads and is expected to include the release version when configured by
70
+ * app storage bootstrap (for example ".../4.1.1").
71
+ */
72
+ export const getAccessURLStaticStore = () => {
73
+ const shared = getSharedS3Env();
74
+ const uploadsEndpoint = readEnv(() => process.env.UPLOADS_S3_BUCKET_ENDPOINT);
75
+ const uploadsBucketName = readEnv(() => process.env.UPLOADS_S3_FILES_BUCKET_NAME);
76
+ const staticAccessURL = readEnv(() => process.env.STATIC_ACCESS_URL);
77
+ const version = readEnv(() => process.env.VERSION);
78
+ const staticEndpoint = readEnv(() => process.env.STATIC_S3_BUCKET_ENDPOINT);
79
+ const staticBucketName = readEnv(() => process.env.STATIC_S3_FILES_BUCKET_NAME);
80
+ // If STATIC_ACCESS_URL is not set, derive it from shared CDN + VERSION.
81
+ // This keeps static assets versioned even with legacy env-only configs.
82
+ const fallbackStaticAccessURL = appendPathSegment(shared.accessURL, version);
83
+ return getAccessURL({
84
+ accessURL: firstNonEmpty(staticAccessURL, fallbackStaticAccessURL),
85
+ endpoint: firstNonEmpty(staticEndpoint, uploadsEndpoint, shared.endpoint),
86
+ bucketName: firstNonEmpty(staticBucketName, uploadsBucketName, shared.bucketName),
87
+ });
88
+ };
89
+ /**
90
+ * Backward-compatible alias for existing imports.
91
+ */
92
+ export const getAccessURLS3FileStore = () => getAccessURLUploadsStore();
93
+ //# sourceMappingURL=accessUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessUrl.js","sourceRoot":"","sources":["../../../src/utils/accessUrl.ts"],"names":[],"mappings":"AAAA,MAAM,iBAAiB,GAAG,CAAC,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACrE,MAAM,WAAW,GAAG,CAAC,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAEpE;;;GAGG;AACH,MAAM,OAAO,GAAG,CAAC,MAAgC,EAAE,EAAE;IACnD,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAC;IAClB,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC;AAEF,2EAA2E;AAC3E,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,CAAC;I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AC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACrE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IAC5E,MAAM,gBAAgB,GAAG,OAAO,CAC9B,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAC9C,CAAC;IACF,wEAAwE;IACxE,wEAAwE;IACxE,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAE7E,OAAO,YAAY,CAAC;QAClB,SAAS,EAAE,aAAa,CAAC,eAAe,EAAE,uBAAuB,CAAC;QAClE,QAAQ,EAAE,aAAa,CAAC,cAAc,EAAE,eAAe,EAAE,MAAM,CAAC,QAAQ,CAAC;QACzE,UAAU,EAAE,aAAa,CACvB,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,CAAC,UAAU,CAClB;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE,CAAC,wBAAwB,EAAE,CAAC"}
package/package.json CHANGED
@@ -11,16 +11,17 @@
11
11
  "type": "git",
12
12
  "url": ""
13
13
  },
14
- "version": "1.0.2",
14
+ "version": "1.1.0",
15
15
  "linkedPackage": true,
16
- "main": "lib/cjs/index.js",
17
- "types": "dist/s3.d.ts",
16
+ "type": "module",
17
+ "main": "lib/esm/index.js",
18
+ "types": "./lib/esm/index.d.ts",
18
19
  "license": "ISC",
19
20
  "scripts": {
20
21
  "start": "npm exec linked dev",
21
- "build": "yarn linked build",
22
- "prepublishOnly": "yarn linked build production",
23
- "postpublish": "npm exec linked register"
22
+ "build": "rimraf ./lib && yarn build-esm && yarn copy-to-lib",
23
+ "build-esm": "echo \"compiling ESM\" && rimraf ./lib/esm && (yarn tsc -p tsconfig-esm.json || echo 'tsc returned non-zero; .js still emitted via noEmitOnError default')",
24
+ "copy-to-lib": "echo 'copying JSON assets to lib folder' && yarn copyfiles -u 1 'src/**/*.json' lib/esm"
24
25
  },
25
26
  "keywords": [
26
27
  "lincd",
@@ -35,8 +36,8 @@
35
36
  ],
36
37
  "dependencies": {
37
38
  "@_linked/core": "^2.2.1",
38
- "@_linked/server": "~1.0",
39
- "@_linked/server-utils": "~1.0",
39
+ "@_linked/server": "^2.0.0",
40
+ "@_linked/server-utils": "^1.0",
40
41
  "@aws-sdk/client-s3": "^3.159.0",
41
42
  "@aws-sdk/credential-providers": "^3.159.0",
42
43
  "cron": "^3.1.7",
@@ -44,29 +45,28 @@
44
45
  },
45
46
  "devDependencies": {
46
47
  "@_linked/cli": "^1.2",
48
+ "@changesets/changelog-github": "^0.5.2",
49
+ "@changesets/cli": "^2.29.8",
47
50
  "@types/mime": "^3.0.4",
51
+ "copyfiles": "^2.4.1",
52
+ "rimraf": "^5.0.7",
48
53
  "tsconfig-to-dual-package": "^1.2.0",
49
54
  "typescript": "^5.7.3",
50
- "typescript-plugin-css-modules": "^5.1.0",
51
- "@changesets/cli": "^2.29.8",
52
- "@changesets/changelog-github": "^0.5.2"
55
+ "typescript-plugin-css-modules": "^5.1.0"
53
56
  },
54
57
  "module": "lib/esm/index.js",
55
58
  "exports": {
56
59
  ".": {
57
60
  "types": "./lib/esm/index.d.ts",
58
- "import": "./lib/esm/index.js",
59
- "require": "./lib/cjs/index.js"
61
+ "import": "./lib/esm/index.js"
60
62
  },
61
63
  "./*.js": {
62
64
  "types": "./lib/esm/*.d.ts",
63
- "import": "./lib/esm/*.js",
64
- "require": "./lib/cjs/*.js"
65
+ "import": "./lib/esm/*.js"
65
66
  },
66
67
  "./*": {
67
68
  "types": "./lib/esm/*.d.ts",
68
- "import": "./lib/esm/*.js",
69
- "require": "./lib/cjs/*.js"
69
+ "import": "./lib/esm/*.js"
70
70
  }
71
71
  },
72
72
  "typesVersions": {
package/tsconfig-esm.json CHANGED
@@ -4,6 +4,6 @@
4
4
  "module": "esnext",
5
5
  "target": "es2018",
6
6
  "outDir": "lib/esm",
7
- "moduleResolution": "node"
7
+ "moduleResolution": "bundler"
8
8
  }
9
9
  }
File without changes
@@ -1,20 +0,0 @@
1
- {
2
- "@context": {
3
- "dc": "http://purl.org/dc/elements/1.1/",
4
- "owl": "http://www.w3.org/2002/07/owl#",
5
- "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
6
- "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
7
- "s3": "http://lincd.org/ont/s3/"
8
- },
9
- "@graph": [
10
- {
11
- "@id": "s3:ExampleClass",
12
- "@type": "rdfs:Class",
13
- "rdfs:comment": "This is an example class. You can remove or rename it",
14
- "rdfs:isDefinedBy": {
15
- "@id": "s3:"
16
- },
17
- "rdfs:label": "Example Class"
18
- }
19
- ]
20
- }
@@ -1,5 +0,0 @@
1
- import './types.js';
2
- import './ontologies/s3.js';
3
- import './shapes/S3Bucket.js';
4
- import './shapes/S3FileStore.js';
5
- import './utils/accessUrl.js';
@@ -1,38 +0,0 @@
1
- export declare var loadData: () => Promise<{
2
- "@context": {
3
- dc: string;
4
- owl: string;
5
- rdf: string;
6
- rdfs: string;
7
- s3: string;
8
- };
9
- "@graph": {
10
- "@id": string;
11
- "@type": string;
12
- "rdfs:comment": string;
13
- "rdfs:isDefinedBy": {
14
- "@id": string;
15
- };
16
- "rdfs:label": string;
17
- }[];
18
- }>;
19
- export declare var ns: (term: string) => import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
20
- export declare var _self: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
21
- export declare var Bucket: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
22
- export declare var FileStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
23
- export declare var FrontendStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
24
- export declare var QuadStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
25
- export declare var bucket: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
26
- export declare var endpoint: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
27
- export declare var key: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
28
- export declare var secret: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
29
- export declare const s3: {
30
- Bucket: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
31
- FileStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
32
- FrontendStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
33
- QuadStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
34
- bucket: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
35
- endpoint: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
36
- key: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
37
- secret: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
38
- };
@@ -1,4 +0,0 @@
1
- export declare const linkedShape: {
2
- <T extends typeof import("@_linked/core/shapes/Shape").Shape>(constructor: T): void;
3
- <T extends typeof import("@_linked/core/shapes/Shape").Shape>(config?: import("@_linked/core/utils/Package").ShapeConfig): (constructor: T) => void;
4
- }, linkedUtil: (constructor: any) => any, linkedOntology: (allFileExports: any, nameSpace: (term: string) => import("@_linked/core/utils/NodeReference").NodeReferenceValue, suggestedPrefixAndFileName: string, loadDataFunction?: () => Promise<any>, dataSource?: string | string[]) => void, registerPackageExport: (exportedObject: any) => void, packageExports: any, packageName: 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.2",
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
- "@types/mime": "^3.0.4",
46
- "tsconfig-to-dual-package": "^1.2.0",
47
- "typescript": "^5.7.3",
48
- "typescript-plugin-css-modules": "^5.1.0",
49
- "@changesets/cli": "^2.29.8",
50
- "@changesets/changelog-github": "^0.5.2"
51
- },
52
- "typesVersions": {
53
- "*": {
54
- "*": [
55
- "lib/esm/*"
56
- ]
57
- }
58
- },
59
- "publishConfig": {
60
- "access": "public"
61
- },
62
- "type": "commonjs"
63
- }
@@ -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
- }