@toa.io/extensions.storages 0.24.0-alpha.9 → 1.0.0-alpha.2

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 (79) hide show
  1. package/package.json +11 -11
  2. package/readme.md +63 -19
  3. package/schemas/annotation.cos.yaml +10 -0
  4. package/schemas/fs.cos.yaml +9 -0
  5. package/schemas/mem.cos.yaml +6 -0
  6. package/schemas/s3.cos.yaml +16 -0
  7. package/schemas/test.cos.yaml +8 -0
  8. package/schemas/tmp.cos.yaml +9 -0
  9. package/source/Annotation.ts +39 -0
  10. package/source/Aspect.ts +6 -4
  11. package/source/Factory.ts +31 -28
  12. package/source/Provider.ts +30 -5
  13. package/source/Scanner.ts +3 -3
  14. package/source/Storage.test.ts +110 -105
  15. package/source/Storage.ts +13 -6
  16. package/source/deployment.ts +21 -29
  17. package/source/providers/Declaration.ts +10 -0
  18. package/source/providers/FileSystem.test.ts +1 -9
  19. package/source/providers/FileSystem.ts +20 -15
  20. package/source/providers/Memory.ts +41 -0
  21. package/source/providers/S3.test.ts +133 -0
  22. package/source/providers/S3.ts +114 -39
  23. package/source/providers/Temporary.ts +8 -6
  24. package/source/providers/Test.ts +8 -8
  25. package/source/providers/index.test.ts +24 -19
  26. package/source/providers/index.ts +10 -9
  27. package/source/providers/readme.md +1 -1
  28. package/source/schemas.test.ts +58 -0
  29. package/source/schemas.ts +15 -0
  30. package/source/test/util.ts +25 -54
  31. package/transpiled/Annotation.d.ts +3 -0
  32. package/transpiled/Annotation.js +57 -0
  33. package/transpiled/Annotation.js.map +1 -0
  34. package/transpiled/Aspect.d.ts +1 -1
  35. package/transpiled/Aspect.js +7 -3
  36. package/transpiled/Aspect.js.map +1 -1
  37. package/transpiled/Factory.d.ts +2 -3
  38. package/transpiled/Factory.js +24 -21
  39. package/transpiled/Factory.js.map +1 -1
  40. package/transpiled/Provider.d.ts +17 -5
  41. package/transpiled/Provider.js +33 -0
  42. package/transpiled/Provider.js.map +1 -1
  43. package/transpiled/Scanner.d.ts +2 -2
  44. package/transpiled/Scanner.js +2 -2
  45. package/transpiled/Scanner.js.map +1 -1
  46. package/transpiled/Storage.d.ts +6 -2
  47. package/transpiled/Storage.js +5 -5
  48. package/transpiled/Storage.js.map +1 -1
  49. package/transpiled/deployment.d.ts +2 -3
  50. package/transpiled/deployment.js +39 -23
  51. package/transpiled/deployment.js.map +1 -1
  52. package/transpiled/providers/Declaration.d.ts +14 -0
  53. package/transpiled/providers/Declaration.js +3 -0
  54. package/transpiled/providers/Declaration.js.map +1 -0
  55. package/transpiled/providers/FileSystem.d.ts +7 -3
  56. package/transpiled/providers/FileSystem.js +17 -14
  57. package/transpiled/providers/FileSystem.js.map +1 -1
  58. package/transpiled/providers/Memory.d.ts +13 -0
  59. package/transpiled/providers/Memory.js +60 -0
  60. package/transpiled/providers/Memory.js.map +1 -0
  61. package/transpiled/providers/S3.d.ts +20 -6
  62. package/transpiled/providers/S3.js +111 -32
  63. package/transpiled/providers/S3.js.map +1 -1
  64. package/transpiled/providers/Temporary.d.ts +5 -2
  65. package/transpiled/providers/Temporary.js +3 -4
  66. package/transpiled/providers/Temporary.js.map +1 -1
  67. package/transpiled/providers/Test.d.ts +4 -3
  68. package/transpiled/providers/Test.js +6 -9
  69. package/transpiled/providers/Test.js.map +1 -1
  70. package/transpiled/providers/index.d.ts +12 -4
  71. package/transpiled/providers/index.js +6 -4
  72. package/transpiled/providers/index.js.map +1 -1
  73. package/transpiled/schemas.d.ts +9 -0
  74. package/transpiled/schemas.js +14 -0
  75. package/transpiled/schemas.js.map +1 -0
  76. package/transpiled/test/util.d.ts +29 -10
  77. package/transpiled/test/util.js +17 -40
  78. package/transpiled/test/util.js.map +1 -1
  79. package/transpiled/tsconfig.tsbuildinfo +1 -1
@@ -5,10 +5,12 @@ const FileSystem_1 = require("./FileSystem");
5
5
  const S3_1 = require("./S3");
6
6
  const Temporary_1 = require("./Temporary");
7
7
  const Test_1 = require("./Test");
8
+ const Memory_1 = require("./Memory");
8
9
  exports.providers = {
9
- 'file:': FileSystem_1.FileSystem,
10
- 'tmp:': Temporary_1.Temporary,
11
- 'test:': Test_1.Test,
12
- 's3:': S3_1.S3
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
13
15
  };
14
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/providers/index.ts"],"names":[],"mappings":";;;AACA,6CAAyC;AACzC,6BAAyB;AACzB,2CAAuC;AACvC,iCAA6B;AAEhB,QAAA,SAAS,GAAkC;IACtD,OAAO,EAAE,uBAAU;IACnB,MAAM,EAAE,qBAAS;IACjB,OAAO,EAAE,WAAI;IACb,KAAK,EAAE,OAAE;CACV,CAAA"}
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"}
@@ -0,0 +1,9 @@
1
+ import type { Declaration } from './providers';
2
+ import type { Schema } from '@toa.io/schemas';
3
+ import type { Annotation } from './Annotation';
4
+ export declare const annotation: Schema<Annotation>;
5
+ export declare const s3: Schema<Declaration>;
6
+ export declare const fs: Schema<Declaration>;
7
+ export declare const mem: Schema<Declaration>;
8
+ export declare const tmp: Schema<Declaration>;
9
+ export declare const test: Schema<Declaration>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.test = exports.tmp = exports.mem = exports.fs = exports.s3 = exports.annotation = void 0;
4
+ const node_path_1 = require("node:path");
5
+ const schemas_1 = require("@toa.io/schemas");
6
+ const path = (0, node_path_1.resolve)(__dirname, '../schemas');
7
+ const ns = (0, schemas_1.namespace)(path);
8
+ exports.annotation = ns.schema('annotation');
9
+ exports.s3 = ns.schema('s3');
10
+ exports.fs = ns.schema('fs');
11
+ exports.mem = ns.schema('mem');
12
+ exports.tmp = ns.schema('tmp');
13
+ exports.test = ns.schema('test');
14
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../source/schemas.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;AACnC,6CAA2C;AAK3C,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,YAAY,CAAC,CAAA;AAC7C,MAAM,EAAE,GAAG,IAAA,mBAAS,EAAC,IAAI,CAAC,CAAA;AAEb,QAAA,UAAU,GAAuB,EAAE,CAAC,MAAM,CAAa,YAAY,CAAC,CAAA;AACpE,QAAA,EAAE,GAAwB,EAAE,CAAC,MAAM,CAAc,IAAI,CAAC,CAAA;AACtD,QAAA,EAAE,GAAwB,EAAE,CAAC,MAAM,CAAc,IAAI,CAAC,CAAA;AACtD,QAAA,GAAG,GAAwB,EAAE,CAAC,MAAM,CAAc,KAAK,CAAC,CAAA;AACxD,QAAA,GAAG,GAAwB,EAAE,CAAC,MAAM,CAAc,KAAK,CAAC,CAAA;AACxD,QAAA,IAAI,GAAwB,EAAE,CAAC,MAAM,CAAc,MAAM,CAAC,CAAA"}
@@ -1,10 +1,29 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { type ReadStream } from 'node:fs';
4
- export declare const cases: Case[];
5
- export declare function rnd(): string;
6
- export declare function open(rel: string): ReadStream;
7
- export declare function read(rel: string): Promise<Buffer>;
8
- type SuiteInit = (url: URL, secrets: Record<string, string>) => Promise<void> | void;
9
- type Case = [string, URL, Record<string, string>, SuiteInit?];
10
- export {};
1
+ export declare const suites: ({
2
+ run: true;
3
+ provider: "tmp";
4
+ options: {
5
+ directory: string;
6
+ endpoint?: undefined;
7
+ region?: undefined;
8
+ bucket?: undefined;
9
+ };
10
+ secrets?: undefined;
11
+ } | {
12
+ run: true;
13
+ provider: "mem";
14
+ options?: undefined;
15
+ secrets?: undefined;
16
+ } | {
17
+ run: boolean;
18
+ provider: "s3";
19
+ options: {
20
+ endpoint: string;
21
+ region: string;
22
+ bucket: string;
23
+ directory?: undefined;
24
+ };
25
+ secrets: {
26
+ ACCESS_KEY_ID: string;
27
+ SECRET_ACCESS_KEY: string;
28
+ };
29
+ })[];
@@ -3,59 +3,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.read = exports.open = exports.rnd = exports.cases = void 0;
6
+ exports.suites = void 0;
7
7
  const node_path_1 = require("node:path");
8
- const promises_1 = __importDefault(require("node:fs/promises"));
9
- const node_fs_1 = require("node:fs");
10
- const client_s3_1 = require("@aws-sdk/client-s3");
11
8
  const dotenv_1 = __importDefault(require("dotenv"));
12
9
  dotenv_1.default.config({ path: (0, node_path_1.join)(__dirname, '.env') });
13
- const suites = [
10
+ exports.suites = [
14
11
  {
15
12
  run: true,
16
- ref: 'tmp:///toa-storages-temp'
13
+ provider: 'tmp',
14
+ options: {
15
+ directory: 'toa-storages-temp'
16
+ }
17
+ },
18
+ {
19
+ run: true,
20
+ provider: 'mem'
17
21
  },
18
22
  {
19
23
  run: process.env.RUN_S3 === '1',
20
- ref: 's3://us-west-1/test-bucket?endpoint=http://s3.localhost.localstack.cloud:4566',
24
+ provider: 's3',
25
+ options: {
26
+ endpoint: 'http://localhost:4566',
27
+ region: 'us-west-1',
28
+ bucket: 'test-bucket'
29
+ },
21
30
  secrets: {
22
31
  ACCESS_KEY_ID: 'developer',
23
32
  SECRET_ACCESS_KEY: 'secret'
24
- },
25
- init: initS3
33
+ }
26
34
  }
27
35
  // add more providers here, use `run` as a condition to run the test
28
36
  // e.g.: `run: process.env.ACCESS_KEY_ID !== undefined`
29
37
  ];
30
- function map(suite) {
31
- const url = new URL(suite.ref);
32
- return [url.protocol, url, suite.secrets ?? {}, suite.init];
33
- }
34
- exports.cases = suites.filter(({ run }) => run).map(map);
35
- function rnd() {
36
- return Math.random().toString(36).slice(2);
37
- }
38
- exports.rnd = rnd;
39
- function open(rel) {
40
- const path = (0, node_path_1.join)(__dirname, rel);
41
- return (0, node_fs_1.createReadStream)(path);
42
- }
43
- exports.open = open;
44
- async function read(rel) {
45
- const path = (0, node_path_1.join)(__dirname, rel);
46
- return await promises_1.default.readFile(path);
47
- }
48
- exports.read = read;
49
- async function initS3(url, secrets) {
50
- const client = new client_s3_1.S3Client({
51
- credentials: {
52
- accessKeyId: secrets.ACCESS_KEY_ID,
53
- secretAccessKey: secrets.SECRET_ACCESS_KEY
54
- },
55
- region: url.host,
56
- endpoint: url.searchParams.get('endpoint') ?? undefined
57
- });
58
- const command = new client_s3_1.CreateBucketCommand({ Bucket: url.pathname.substring(1) });
59
- await client.send(command).catch(() => undefined);
60
- }
61
38
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../source/test/util.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAgC;AAChC,gEAAiC;AACjC,qCAA2D;AAC3D,kDAAkE;AAClE,oDAA2B;AAE3B,gBAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAA,gBAAI,EAAC,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,CAAA;AAEhD,MAAM,MAAM,GAAY;IACtB;QACE,GAAG,EAAE,IAAI;QACT,GAAG,EAAE,0BAA0B;KAChC;IACD;QACE,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,KAAK,GAAG;QAC/B,GAAG,EAAE,+EAA+E;QACpF,OAAO,EAAE;YACP,aAAa,EAAE,WAAW;YAC1B,iBAA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