@toa.io/extensions.origins 0.7.2-dev.0 → 0.8.0-dev.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.
Files changed (46) hide show
  1. package/package.json +9 -8
  2. package/readme.md +57 -0
  3. package/source/.deployment/index.js +5 -0
  4. package/source/.deployment/uris.js +35 -0
  5. package/source/.test/constants.js +3 -0
  6. package/source/.test/deployment.fixtures.js +20 -0
  7. package/source/.test/factory.fixtures.js +13 -0
  8. package/source/constants.js +3 -0
  9. package/source/deployment.js +28 -0
  10. package/source/deployment.test.js +159 -0
  11. package/source/env.js +50 -0
  12. package/source/factory.js +34 -0
  13. package/source/factory.test.js +122 -0
  14. package/{src → source}/index.js +2 -0
  15. package/source/manifest.js +23 -0
  16. package/source/manifest.test.js +51 -0
  17. package/source/protocols/amqp/.test/aspect.fixtures.js +15 -0
  18. package/source/protocols/amqp/.test/mock.comq.js +13 -0
  19. package/source/protocols/amqp/aspect.js +75 -0
  20. package/source/protocols/amqp/aspect.test.js +119 -0
  21. package/source/protocols/amqp/deployment.js +57 -0
  22. package/source/protocols/amqp/index.js +9 -0
  23. package/source/protocols/amqp/protocols.js +3 -0
  24. package/{test → source/protocols/http/.test}/aspect.fixtures.js +6 -6
  25. package/{src → source/protocols/http}/aspect.js +13 -20
  26. package/{test → source/protocols/http}/aspect.test.js +11 -11
  27. package/source/protocols/http/index.js +7 -0
  28. package/source/protocols/http/protocols.js +3 -0
  29. package/source/protocols/index.js +6 -0
  30. package/source/schemas/annotations.cos.yaml +1 -0
  31. package/source/schemas/index.js +8 -0
  32. package/source/schemas/manifest.cos.yaml +1 -0
  33. package/types/amqp.ts +9 -0
  34. package/types/deployment.d.ts +7 -0
  35. package/types/{aspect.ts → http.ts} +1 -2
  36. package/src/.manifest/index.js +0 -7
  37. package/src/.manifest/normalize.js +0 -17
  38. package/src/.manifest/schema.yaml +0 -13
  39. package/src/.manifest/validate.js +0 -13
  40. package/src/factory.js +0 -14
  41. package/src/manifest.js +0 -13
  42. package/test/factory.fixtures.js +0 -5
  43. package/test/factory.test.js +0 -22
  44. package/test/manifest.fixtures.js +0 -11
  45. package/test/manifest.test.js +0 -58
  46. package/types/declaration.d.ts +0 -11
@@ -1,58 +0,0 @@
1
- 'use strict'
2
-
3
- const clone = require('clone-deep')
4
- const { generate } = require('randomstring')
5
-
6
- const fixtures = require('./manifest.fixtures')
7
- const { manifest } = require('../src')
8
-
9
- let declaration
10
-
11
- beforeEach(() => {
12
- declaration = clone(fixtures.declaration)
13
- })
14
-
15
- const exec = () => manifest(declaration)
16
- const gen = () => 'https://host-' + generate().toLowerCase() + '.com'
17
-
18
- it('should expand origins', () => {
19
- const origins = {
20
- [generate()]: gen(),
21
- [generate()]: gen()
22
- }
23
-
24
- const value = clone(origins)
25
- const result = manifest(value)
26
-
27
- expect(result).toStrictEqual({ origins })
28
- })
29
-
30
- it('should not throw if valid', () => {
31
- expect(exec).not.toThrow()
32
- })
33
-
34
- it('should require origins', () => {
35
- delete declaration.origins
36
-
37
- expect(exec).toThrow(/fewer than 1/)
38
- })
39
-
40
- it('should require at least one origin', () => {
41
- declaration.origins = {}
42
-
43
- expect(exec).toThrow(/fewer than 1/)
44
- })
45
-
46
- it('should require origin values as strings', () => {
47
- declaration.origins.foo = ['bar', 'baz']
48
-
49
- expect(exec).toThrow(/must be string/)
50
- })
51
-
52
- describe('origin', () => {
53
- it('should require origin values as web origins', () => {
54
- declaration.origins.foo = 'http://origin/with/path'
55
-
56
- expect(exec).toThrow(/must match pattern/)
57
- })
58
- })
@@ -1,11 +0,0 @@
1
- declare namespace toa.extensions.origins {
2
-
3
- type Origins = {
4
- [name: string]: string
5
- }
6
-
7
- type Declaration = {
8
- origins: Origins
9
- }
10
-
11
- }