@toa.io/extensions.storages 1.0.0-alpha.31 → 1.0.0-alpha.310

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.
Files changed (122) hide show
  1. package/package.json +38 -18
  2. package/readme.md +115 -47
  3. package/transpiled/Aspect.d.ts +8 -4
  4. package/transpiled/Aspect.js +12 -14
  5. package/transpiled/Aspect.js.map +1 -1
  6. package/transpiled/Entry.d.ts +14 -11
  7. package/transpiled/Entry.js +1 -2
  8. package/transpiled/Factory.d.ts +1 -1
  9. package/transpiled/Factory.js +29 -30
  10. package/transpiled/Factory.js.map +1 -1
  11. package/transpiled/Provider.d.ts +17 -19
  12. package/transpiled/Provider.js +10 -33
  13. package/transpiled/Provider.js.map +1 -1
  14. package/transpiled/Scanner.d.ts +5 -4
  15. package/transpiled/Scanner.js +33 -26
  16. package/transpiled/Scanner.js.map +1 -1
  17. package/transpiled/Secrets.d.ts +5 -0
  18. package/transpiled/Secrets.js +2 -0
  19. package/transpiled/Secrets.js.map +1 -0
  20. package/transpiled/Storage.d.ts +23 -22
  21. package/transpiled/Storage.js +79 -142
  22. package/transpiled/Storage.js.map +1 -1
  23. package/transpiled/errors.d.ts +7 -0
  24. package/transpiled/errors.js +4 -0
  25. package/transpiled/errors.js.map +1 -0
  26. package/transpiled/index.d.ts +4 -4
  27. package/transpiled/index.js +1 -9
  28. package/transpiled/index.js.map +1 -1
  29. package/transpiled/measurements.d.ts +3 -0
  30. package/transpiled/measurements.js +23 -0
  31. package/transpiled/measurements.js.map +1 -0
  32. package/transpiled/providers/Cloudinary.d.ts +50 -0
  33. package/transpiled/providers/Cloudinary.js +223 -0
  34. package/transpiled/providers/Cloudinary.js.map +1 -0
  35. package/transpiled/providers/Declaration.d.ts +9 -5
  36. package/transpiled/providers/Declaration.js +1 -2
  37. package/transpiled/providers/FileSystem.d.ts +16 -11
  38. package/transpiled/providers/FileSystem.js +64 -43
  39. package/transpiled/providers/FileSystem.js.map +1 -1
  40. package/transpiled/providers/S3.d.ts +14 -19
  41. package/transpiled/providers/S3.js +72 -123
  42. package/transpiled/providers/S3.js.map +1 -1
  43. package/transpiled/providers/Spaces.d.ts +12 -0
  44. package/transpiled/providers/Spaces.js +13 -0
  45. package/transpiled/providers/Spaces.js.map +1 -0
  46. package/transpiled/providers/Temporary.d.ts +2 -3
  47. package/transpiled/providers/Temporary.js +7 -11
  48. package/transpiled/providers/Temporary.js.map +1 -1
  49. package/transpiled/providers/Test.d.ts +4 -4
  50. package/transpiled/providers/Test.js +6 -12
  51. package/transpiled/providers/Test.js.map +1 -1
  52. package/transpiled/providers/index.d.ts +23 -11
  53. package/transpiled/providers/index.js +30 -14
  54. package/transpiled/providers/index.js.map +1 -1
  55. package/transpiled/providers/index.types.d.ts +5 -0
  56. package/transpiled/providers/index.types.js +2 -0
  57. package/transpiled/providers/index.types.js.map +1 -0
  58. package/transpiled/test/util.d.ts +113 -6
  59. package/transpiled/test/util.js +68 -15
  60. package/transpiled/test/util.js.map +1 -1
  61. package/schemas/annotation.cos.yaml +0 -10
  62. package/schemas/fs.cos.yaml +0 -9
  63. package/schemas/mem.cos.yaml +0 -6
  64. package/schemas/s3.cos.yaml +0 -16
  65. package/schemas/test.cos.yaml +0 -8
  66. package/schemas/tmp.cos.yaml +0 -9
  67. package/source/Annotation.ts +0 -39
  68. package/source/Aspect.ts +0 -25
  69. package/source/Entry.ts +0 -14
  70. package/source/Factory.ts +0 -68
  71. package/source/Provider.ts +0 -37
  72. package/source/Scanner.ts +0 -153
  73. package/source/Storage.test.ts +0 -472
  74. package/source/Storage.ts +0 -235
  75. package/source/deployment.ts +0 -57
  76. package/source/index.ts +0 -5
  77. package/source/manifest.ts +0 -8
  78. package/source/providers/Declaration.ts +0 -10
  79. package/source/providers/FileSystem.test.ts +0 -5
  80. package/source/providers/FileSystem.ts +0 -63
  81. package/source/providers/Memory.ts +0 -55
  82. package/source/providers/S3.test.ts +0 -134
  83. package/source/providers/S3.ts +0 -196
  84. package/source/providers/Temporary.ts +0 -16
  85. package/source/providers/Test.ts +0 -13
  86. package/source/providers/index.test.ts +0 -136
  87. package/source/providers/index.ts +0 -16
  88. package/source/providers/readme.md +0 -25
  89. package/source/schemas.test.ts +0 -58
  90. package/source/schemas.ts +0 -15
  91. package/source/test/.env.example +0 -1
  92. package/source/test/albert.jpg +0 -0
  93. package/source/test/empty.txt +0 -0
  94. package/source/test/lenna.ascii +0 -64
  95. package/source/test/lenna.png +0 -0
  96. package/source/test/sample.avi +0 -0
  97. package/source/test/sample.avif +0 -0
  98. package/source/test/sample.gif +0 -0
  99. package/source/test/sample.heic +0 -0
  100. package/source/test/sample.jpeg +0 -0
  101. package/source/test/sample.jxl +0 -0
  102. package/source/test/sample.svg +0 -4
  103. package/source/test/sample.wav +0 -0
  104. package/source/test/sample.webp +0 -0
  105. package/source/test/util.ts +0 -45
  106. package/transpiled/Annotation.d.ts +0 -3
  107. package/transpiled/Annotation.js +0 -57
  108. package/transpiled/Annotation.js.map +0 -1
  109. package/transpiled/deployment.d.ts +0 -5
  110. package/transpiled/deployment.js +0 -68
  111. package/transpiled/deployment.js.map +0 -1
  112. package/transpiled/manifest.d.ts +0 -1
  113. package/transpiled/manifest.js +0 -9
  114. package/transpiled/manifest.js.map +0 -1
  115. package/transpiled/providers/Memory.d.ts +0 -15
  116. package/transpiled/providers/Memory.js +0 -72
  117. package/transpiled/providers/Memory.js.map +0 -1
  118. package/transpiled/schemas.d.ts +0 -9
  119. package/transpiled/schemas.js +0 -14
  120. package/transpiled/schemas.js.map +0 -1
  121. package/transpiled/tsconfig.tsbuildinfo +0 -1
  122. package/tsconfig.json +0 -12
@@ -1,54 +1,21 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.S3 = void 0;
30
- const node_stream_1 = require("node:stream");
31
- const node_buffer_1 = require("node:buffer");
32
- const posix_1 = require("node:path/posix");
33
- const node_assert_1 = __importDefault(require("node:assert"));
34
- const node_path_1 = require("node:path");
35
- const lib_storage_1 = require("@aws-sdk/lib-storage");
36
- const client_s3_1 = require("@aws-sdk/client-s3");
37
- const nodeNativeFetch = __importStar(require("smithy-node-native-fetch"));
38
- const Provider_1 = require("../Provider");
39
- class S3 extends Provider_1.Provider {
40
- static SECRETS = [
41
- { name: 'ACCESS_KEY_ID', optional: true },
42
- { name: 'SECRET_ACCESS_KEY', optional: true }
43
- ];
1
+ import { Readable } from 'node:stream';
2
+ import { Blob } from 'node:buffer';
3
+ import { join } from 'node:path/posix';
4
+ import { Upload } from '@aws-sdk/lib-storage';
5
+ import * as s3 from '@aws-sdk/client-s3';
6
+ import { console } from 'openspan';
7
+ import { Provider } from '../Provider.js';
8
+ import { secrets } from '@toa.io/definitions/extensions.storages';
9
+ import { ERR_NOT_FOUND } from '../errors.js';
10
+ export class S3 extends Provider {
11
+ static SECRETS = secrets.s3;
44
12
  bucket;
45
13
  client;
46
14
  constructor(options, secrets) {
47
- super(options);
15
+ super(options, secrets);
48
16
  this.bucket = options.bucket;
49
17
  const s3Config = {
50
- retryMode: 'adaptive',
51
- ...nodeNativeFetch
18
+ retryMode: 'adaptive'
52
19
  };
53
20
  if (options.endpoint !== undefined) {
54
21
  s3Config.forcePathStyle = options.endpoint.startsWith('http://');
@@ -57,19 +24,20 @@ class S3 extends Provider_1.Provider {
57
24
  if (options.region !== undefined)
58
25
  s3Config.region = options.region;
59
26
  if (typeof secrets?.ACCESS_KEY_ID === 'string') {
60
- node_assert_1.default.ok(secrets.SECRET_ACCESS_KEY !== undefined, 'SECRET_ACCESS_KEY is required if ACCESS_KEY_ID is provided');
27
+ if (secrets.SECRET_ACCESS_KEY === undefined)
28
+ throw new Error('SECRET_ACCESS_KEY is required if ACCESS_KEY_ID is provided');
61
29
  s3Config.credentials = {
62
30
  accessKeyId: secrets.ACCESS_KEY_ID,
63
31
  secretAccessKey: secrets.SECRET_ACCESS_KEY
64
32
  };
65
33
  }
66
- this.client = new client_s3_1.S3Client(s3Config);
34
+ this.client = new s3.S3Client(s3Config);
67
35
  this.client.middlewareStack.add((next, _context) => async (args) => {
36
+ // removes leading slash
68
37
  if ('Key' in args.input && typeof args.input.Key === 'string')
69
- // removes leading slash
70
38
  args.input.Key = args.input.Key.replace(/^\//, '');
39
+ // removes leading slash and ensures finishing slash
71
40
  if ('Prefix' in args.input && typeof args.input.Prefix === 'string')
72
- // removes leading slash and ensures finishing slash
73
41
  args.input.Prefix = args.input.Prefix.replace(/^\/|\/$/g, '') + '/';
74
42
  return next(args);
75
43
  }, {
@@ -79,95 +47,76 @@ class S3 extends Provider_1.Provider {
79
47
  });
80
48
  }
81
49
  async get(Key) {
82
- try {
83
- const fileResponse = await this.client.send(new client_s3_1.GetObjectCommand({
50
+ return await this.try(async () => {
51
+ const entry = await this.client.send(new s3.GetObjectCommand({
84
52
  Bucket: this.bucket,
85
53
  Key
86
54
  }));
87
- if (fileResponse.Body === undefined)
88
- return null; // should never happen
89
- if (fileResponse.Body instanceof node_stream_1.Readable)
90
- return fileResponse.Body;
91
- return node_stream_1.Readable.fromWeb((fileResponse.Body instanceof node_buffer_1.Blob
92
- ? fileResponse.Body.stream()
93
- : fileResponse.Body)); // types mismatch between Node 20 and aws-sdk
94
- }
95
- catch (err) {
96
- if (err instanceof client_s3_1.NotFound || err instanceof client_s3_1.NoSuchKey)
97
- return null;
98
- else
99
- throw err;
100
- }
55
+ const stream = entry.Body instanceof Readable
56
+ ? entry.Body
57
+ : Readable.fromWeb((entry.Body instanceof Blob
58
+ ? entry.Body.stream()
59
+ : entry.Body));
60
+ if (entry.Metadata?.value === undefined)
61
+ return ERR_NOT_FOUND;
62
+ const metadata = JSON.parse(entry.Metadata.value);
63
+ return { stream, ...metadata };
64
+ });
101
65
  }
102
- async list(prefix) {
103
- return (await this.listObjects(prefix))
104
- .map(({ Key }) => node_path_1.posix.basename(Key));
66
+ async head(Key) {
67
+ return await this.try(async () => {
68
+ const entry = await this.client.send(new s3.HeadObjectCommand({
69
+ Bucket: this.bucket,
70
+ Key
71
+ }));
72
+ if (entry.Metadata?.value === undefined)
73
+ return ERR_NOT_FOUND;
74
+ return JSON.parse(entry.Metadata.value);
75
+ });
105
76
  }
106
- async put(path, filename, stream) {
107
- await new lib_storage_1.Upload({
77
+ async put(Key, stream) {
78
+ await new Upload({
108
79
  client: this.client,
109
80
  params: {
110
81
  Bucket: this.bucket,
111
- Key: (0, posix_1.join)(path, filename),
82
+ Key,
112
83
  Body: stream
113
84
  }
114
85
  }).done();
115
86
  }
116
- /**
117
- * Deletes either a single object or "directory" - all objects
118
- * with given prefix (prefix will be enforced to finish with `/`)
119
- * @param Key - key name or path prefix
120
- */
121
- async delete(Key) {
122
- const { client, bucket: Bucket } = this;
123
- // checking if given key is a single file
124
- if (!Key.endsWith('/'))
125
- try {
126
- // DeleteObject on S3 returns no error if object does not exist
127
- await client.send(new client_s3_1.HeadObjectCommand({ Bucket, Key }));
128
- await client.send(new client_s3_1.DeleteObjectCommand({ Bucket, Key }));
129
- return;
130
- }
131
- catch (err) {
132
- node_assert_1.default.ok(err instanceof client_s3_1.NotFound || err instanceof client_s3_1.NoSuchKey, err);
133
- }
134
- const objectsToRemove = await this.listObjects(Key);
135
- // Removing all objects in parallel in batches
136
- await Promise.all((function* () {
137
- while (objectsToRemove.length > 0)
138
- yield client.send(new client_s3_1.DeleteObjectsCommand({
139
- Bucket,
140
- Delete: {
141
- Objects: objectsToRemove.splice(0, 1000 /* max batch size for DeleteObjects */)
142
- }
143
- }));
144
- })());
145
- }
146
- async move(from, keyTo) {
147
- await this.client.send(new client_s3_1.CopyObjectCommand({
87
+ async commit(Key, metadata) {
88
+ await this.client.send(new s3.CopyObjectCommand({
148
89
  Bucket: this.bucket,
149
- Key: keyTo,
150
- CopySource: (0, posix_1.join)(this.bucket, from)
90
+ Key,
91
+ CopySource: join(this.bucket, Key),
92
+ Metadata: { value: JSON.stringify(metadata) },
93
+ MetadataDirective: 'REPLACE'
151
94
  }));
152
- await this.client.send(new client_s3_1.DeleteObjectCommand({ Bucket: this.bucket, Key: from }));
95
+ console.debug('Uploaded to S3', { bucket: this.bucket, path: Key, metadata });
153
96
  }
154
- async moveDir(from, to) {
155
- const objects = await this.listObjects(from);
156
- await Promise.all(objects.map(async ({ Key }) => {
157
- const ent = node_path_1.posix.basename(Key);
158
- const source = node_path_1.posix.join(from, ent);
159
- const target = node_path_1.posix.join(to, ent);
160
- return this.move(source, target);
161
- }));
97
+ async delete(Key) {
98
+ await this.client.send(new s3.DeleteObjectCommand({ Bucket: this.bucket, Key }));
162
99
  }
163
- async listObjects(Prefix) {
164
- const { client, bucket: Bucket } = this;
165
- const objects = [];
166
- for await (const page of (0, client_s3_1.paginateListObjectsV2)({ client }, { Bucket, Prefix }))
167
- for (const { Key } of page.Contents ?? [])
168
- objects.push({ Key });
169
- return objects;
100
+ async move(from, keyTo) {
101
+ return await this.try(async () => {
102
+ await this.client.send(new s3.CopyObjectCommand({
103
+ Bucket: this.bucket,
104
+ Key: keyTo,
105
+ CopySource: join(this.bucket, from)
106
+ }));
107
+ await this.client.send(new s3.DeleteObjectCommand({ Bucket: this.bucket, Key: from }));
108
+ });
109
+ }
110
+ async try(action) {
111
+ try {
112
+ return await action();
113
+ }
114
+ catch (err) {
115
+ if (err?.name === 'NotFound' || err?.name === 'NoSuchKey')
116
+ return ERR_NOT_FOUND;
117
+ else
118
+ throw err;
119
+ }
170
120
  }
171
121
  }
172
- exports.S3 = S3;
173
122
  //# sourceMappingURL=S3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"S3.js","sourceRoot":"","sources":["../../source/providers/S3.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAsC;AACtC,6CAAkC;AAClC,2CAAsC;AACtC,8DAAgC;AAChC,yCAAiC;AACjC,sDAA6C;AAC7C,kDAY2B;AAC3B,0EAA2D;AAC3D,0CAAiF;AAYjF,MAAa,EAAG,SAAQ,mBAAmB;IAClC,MAAM,CAAmB,OAAO,GAA8B;QACnE,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,IAAI,EAAE;QACzC,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC9C,CAAA;IAEkB,MAAM,CAAQ;IACd,MAAM,CAAU;IAEnC,YAAoB,OAAkB,EAAE,OAAmB;QACzD,KAAK,CAAC,OAAO,CAAC,CAAA;QAEd,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAE5B,MAAM,QAAQ,GAAuB;YACnC,SAAS,EAAE,UAAU;YACrB,GAAG,eAAe;SACnB,CAAA;QAED,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACnC,QAAQ,CAAC,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;YAChE,QAAQ,CAAC,QAAQ,GAAG,OAAO,CAAC,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,CAAC,MAAM;gBACnB,GAAG,EAAE,KAAK;gBACV,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;aACpC,CAAC,CACH,CAAA;YAED,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACpB,IAAI,EAAE,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAC/D,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,KAAK,CAAC,GAAG,CAAW,MAAwB;QAClD,IAAI,CAAC;YACH,OAAO,MAAM,MAAM,EAAE,CAAA;QACvB,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,GAAG,EAAE,IAAI,KAAK,UAAU,IAAI,GAAG,EAAE,IAAI,KAAK,WAAW;gBAAE,OAAO,aAAa,CAAA;;gBAC1E,MAAM,GAAG,CAAA;QAChB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import { S3 } from './S3.ts';
2
+ import type { Secret, Secrets } from '../Secrets.ts';
3
+ export interface SpacesOptions {
4
+ space: string;
5
+ region: string;
6
+ }
7
+ type SpacesSecrets = Secrets<'ACCESS_KEY_ID' | 'SECRET_ACCESS_KEY'>;
8
+ export declare class Spaces extends S3 {
9
+ static readonly SECRETS: readonly Secret[];
10
+ constructor(options: SpacesOptions, secrets?: SpacesSecrets);
11
+ }
12
+ export {};
@@ -0,0 +1,13 @@
1
+ import { S3 } from './S3.js';
2
+ import { secrets } from '@toa.io/definitions/extensions.storages';
3
+ export class Spaces extends S3 {
4
+ static SECRETS = secrets.spaces;
5
+ constructor(options, secrets) {
6
+ super({
7
+ bucket: options.space,
8
+ region: options.region,
9
+ endpoint: `https://${options.region}.digitaloceanspaces.com`
10
+ }, secrets);
11
+ }
12
+ }
13
+ //# sourceMappingURL=Spaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Spaces.js","sourceRoot":"","sources":["../../source/providers/Spaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAA;AAUjE,MAAM,OAAO,MAAO,SAAQ,EAAE;IACrB,MAAM,CAAmB,OAAO,GAAsB,OAAO,CAAC,MAAM,CAAA;IAE3E,YAAmB,OAAsB,EAAE,OAAuB;QAChE,KAAK,CACH;YACE,MAAM,EAAE,OAAO,CAAC,KAAK;YACrB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,QAAQ,EAAE,WAAW,OAAO,CAAC,MAAM,yBAAyB;SAC7D,EACD,OAAO,CACR,CAAA;IACH,CAAC;CACF"}
@@ -1,8 +1,7 @@
1
- import { FileSystem } from './FileSystem';
2
- import type { ProviderSecrets } from '../Provider';
1
+ import { FileSystem } from './FileSystem.ts';
3
2
  export interface TemporaryOptions {
4
3
  directory: string;
5
4
  }
6
5
  export declare class Temporary extends FileSystem {
7
- constructor(options: TemporaryOptions, secrets?: ProviderSecrets);
6
+ constructor(options: TemporaryOptions);
8
7
  }
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Temporary = void 0;
4
- const node_os_1 = require("node:os");
5
- const node_path_1 = require("node:path");
6
- const FileSystem_1 = require("./FileSystem");
7
- class Temporary extends FileSystem_1.FileSystem {
8
- constructor(options, secrets) {
9
- const path = (0, node_path_1.join)((0, node_os_1.tmpdir)(), options.directory);
10
- super({ path }, secrets);
1
+ import { tmpdir } from 'node:os';
2
+ import { join } from 'node:path';
3
+ import { FileSystem } from './FileSystem.js';
4
+ export class Temporary extends FileSystem {
5
+ constructor(options) {
6
+ const path = join(tmpdir(), options.directory);
7
+ super({ path });
11
8
  }
12
9
  }
13
- exports.Temporary = Temporary;
14
10
  //# sourceMappingURL=Temporary.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Temporary.js","sourceRoot":"","sources":["../../source/providers/Temporary.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAChC,yCAAgC;AAChC,6CAAyC;AAOzC,MAAa,SAAU,SAAQ,uBAAU;IACvC,YAAoB,OAAyB,EAAE,OAAyB;QACtE,MAAM,IAAI,GAAG,IAAA,gBAAI,EAAC,IAAA,gBAAM,GAAE,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;QAE9C,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAA;IAC1B,CAAC;CACF;AAND,8BAMC"}
1
+ {"version":3,"file":"Temporary.js","sourceRoot":"","sources":["../../source/providers/Temporary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAM5C,MAAM,OAAO,SAAU,SAAQ,UAAU;IACvC,YAAmB,OAAyB;QAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;QAE9C,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;IACjB,CAAC;CACF"}
@@ -1,6 +1,6 @@
1
- import { Temporary, type TemporaryOptions } from './Temporary';
2
- import type { ProviderSecret, ProviderSecrets } from '../Provider';
1
+ import { Temporary, type TemporaryOptions } from './Temporary.ts';
2
+ import type { Secret } from '../Secrets.ts';
3
3
  export declare class Test extends Temporary {
4
- static readonly SECRETS: readonly ProviderSecret[];
5
- constructor(options: TemporaryOptions, secrets?: ProviderSecrets);
4
+ static readonly SECRETS: readonly Secret[];
5
+ constructor(options: TemporaryOptions);
6
6
  }
@@ -1,15 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Test = void 0;
4
- const Temporary_1 = require("./Temporary");
5
- class Test extends Temporary_1.Temporary {
6
- static SECRETS = [
7
- { name: 'USERNAME' },
8
- { name: 'PASSWORD' }
9
- ];
10
- constructor(options, secrets) {
11
- super(options, secrets);
1
+ import { Temporary } from './Temporary.js';
2
+ import { secrets } from '@toa.io/definitions/extensions.storages';
3
+ export class Test extends Temporary {
4
+ static SECRETS = secrets.test;
5
+ constructor(options) {
6
+ super(options);
12
7
  }
13
8
  }
14
- exports.Test = Test;
15
9
  //# sourceMappingURL=Test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Test.js","sourceRoot":"","sources":["../../source/providers/Test.ts"],"names":[],"mappings":";;;AAAA,2CAA8D;AAG9D,MAAa,IAAK,SAAQ,qBAAS;IAC1B,MAAM,CAAmB,OAAO,GAA8B;QACnE,EAAE,IAAI,EAAE,UAAU,EAAE;QACpB,EAAE,IAAI,EAAE,UAAU,EAAE;KACrB,CAAA;IAED,YAAoB,OAAyB,EAAE,OAAyB;QACtE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACzB,CAAC;;AARH,oBASC"}
1
+ {"version":3,"file":"Test.js","sourceRoot":"","sources":["../../source/providers/Test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAyB,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAA;AAGjE,MAAM,OAAO,IAAK,SAAQ,SAAS;IAC1B,MAAM,CAAmB,OAAO,GAAsB,OAAO,CAAC,IAAI,CAAA;IAEzE,YAAmB,OAAyB;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;CACF"}
@@ -1,13 +1,25 @@
1
- import { FileSystem } from './FileSystem';
2
- import { S3 } from './S3';
3
- import { Temporary } from './Temporary';
4
- import { Test } from './Test';
5
- import { InMemory } from './Memory';
1
+ import type { Constructor } from '../Provider.ts';
2
+ /**
3
+ * A provider is loaded when a storage names it: the SDK one is written against is not paid
4
+ * for by a process that declares another, and is not installed by one either — it is an
5
+ * optional peer of this package, which a deploy installs for the storages a component
6
+ * declares. See `provider` below for what a workspace that has not gets told.
7
+ */
6
8
  export declare const providers: {
7
- readonly s3: typeof S3;
8
- readonly fs: typeof FileSystem;
9
- readonly tmp: typeof Temporary;
10
- readonly mem: typeof InMemory;
11
- readonly test: typeof Test;
9
+ readonly s3: () => Promise<typeof import("./S3.ts").S3>;
10
+ readonly spaces: () => Promise<typeof import("./Spaces.ts").Spaces>;
11
+ readonly cloudinary: () => Promise<typeof import("./Cloudinary.ts").Cloudinary>;
12
+ readonly fs: () => Promise<typeof import("./FileSystem.ts").FileSystem>;
13
+ readonly tmp: () => Promise<typeof import("./Temporary.ts").Temporary>;
14
+ readonly test: () => Promise<typeof import("./Test.ts").Test>;
12
15
  };
13
- export type { Declaration } from './Declaration';
16
+ export type Id = keyof typeof providers;
17
+ /** The provider a declaration names, or what to install to have it. */
18
+ export declare function provider(id: Id): Promise<Constructor>;
19
+ export type { Declaration } from './Declaration.ts';
20
+ export type { S3Options } from './S3.ts';
21
+ export type { SpacesOptions } from './Spaces.ts';
22
+ export type { CloudinaryOptions } from './Cloudinary.ts';
23
+ export type { FileSystemOptions } from './FileSystem.ts';
24
+ export type { TemporaryOptions } from './Temporary.ts';
25
+ export type { FileSystem, S3, Spaces, Cloudinary, Temporary } from './index.types.ts';
@@ -1,16 +1,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.providers = void 0;
4
- const FileSystem_1 = require("./FileSystem");
5
- const S3_1 = require("./S3");
6
- const Temporary_1 = require("./Temporary");
7
- const Test_1 = require("./Test");
8
- const Memory_1 = require("./Memory");
9
- exports.providers = {
10
- s3: S3_1.S3,
11
- fs: FileSystem_1.FileSystem,
12
- tmp: Temporary_1.Temporary,
13
- mem: Memory_1.InMemory,
14
- test: Test_1.Test
1
+ import { packages } from '@toa.io/definitions/extensions.storages';
2
+ /**
3
+ * A provider is loaded when a storage names it: the SDK one is written against is not paid
4
+ * for by a process that declares another, and is not installed by one either — it is an
5
+ * optional peer of this package, which a deploy installs for the storages a component
6
+ * declares. See `provider` below for what a workspace that has not gets told.
7
+ */
8
+ export const providers = {
9
+ s3: async () => (await import('./S3.js')).S3,
10
+ spaces: async () => (await import('./Spaces.js')).Spaces,
11
+ cloudinary: async () => (await import('./Cloudinary.js')).Cloudinary,
12
+ fs: async () => (await import('./FileSystem.js')).FileSystem,
13
+ tmp: async () => (await import('./Temporary.js')).Temporary,
14
+ test: async () => (await import('./Test.js')).Test
15
15
  };
16
+ /** The provider a declaration names, or what to install to have it. */
17
+ export async function provider(id) {
18
+ try {
19
+ return await providers[id]();
20
+ }
21
+ catch (error) {
22
+ const missing = Object.entries(packages[id]).map(([name, version]) => `${name}@${version}`);
23
+ if (missing.length === 0 || !isMissingModule(error))
24
+ throw error;
25
+ throw new Error(`Storage provider '${id}' needs ${missing.join(' ')}, which is not installed. ` +
26
+ `\`toa npm\` installs what this context's components declare.`, { cause: error });
27
+ }
28
+ }
29
+ function isMissingModule(error) {
30
+ return error?.code === 'ERR_MODULE_NOT_FOUND';
31
+ }
16
32
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/providers/index.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,6BAAyB;AACzB,2CAAuC;AACvC,iCAA6B;AAC7B,qCAAmC;AAGtB,QAAA,SAAS,GAAG;IACvB,EAAE,EAAE,OAAE;IACN,EAAE,EAAE,uBAAU;IACd,GAAG,EAAE,qBAAS;IACd,GAAG,EAAE,iBAAQ;IACb,IAAI,EAAE,WAAI;CAC4C,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAA;AAGlE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,EAAE,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC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,IAAI,KAAK,sBAAsB,CAAA;AACtE,CAAC"}
@@ -0,0 +1,5 @@
1
+ export type { FileSystem } from './FileSystem.ts';
2
+ export type { S3 } from './S3.ts';
3
+ export type { Spaces } from './Spaces.ts';
4
+ export type { Cloudinary } from './Cloudinary.ts';
5
+ export type { Temporary } from './Temporary.ts';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.types.js","sourceRoot":"","sources":["../../source/providers/index.types.ts"],"names":[],"mappings":""}