@toa.io/extensions.origins 0.7.2-dev.0 → 0.8.0-dev.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.
Files changed (52) hide show
  1. package/package.json +9 -8
  2. package/readme.md +113 -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 +158 -0
  11. package/source/env.js +50 -0
  12. package/source/factory.js +46 -0
  13. package/source/factory.test.js +140 -0
  14. package/{src → source}/index.js +2 -0
  15. package/source/manifest.js +25 -0
  16. package/source/manifest.test.js +57 -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 +77 -0
  20. package/source/protocols/amqp/aspect.test.js +119 -0
  21. package/source/protocols/amqp/deployment.js +63 -0
  22. package/source/protocols/amqp/id.js +3 -0
  23. package/source/protocols/amqp/index.js +11 -0
  24. package/source/protocols/amqp/protocols.js +3 -0
  25. package/source/protocols/http/.aspect/permissions.js +65 -0
  26. package/{test → source/protocols/http/.test}/aspect.fixtures.js +6 -6
  27. package/source/protocols/http/aspect.js +129 -0
  28. package/source/protocols/http/aspect.test.js +239 -0
  29. package/source/protocols/http/id.js +3 -0
  30. package/source/protocols/http/index.js +9 -0
  31. package/source/protocols/http/protocols.js +3 -0
  32. package/source/protocols/index.js +6 -0
  33. package/source/schemas/annotations.cos.yaml +1 -0
  34. package/source/schemas/index.js +8 -0
  35. package/source/schemas/manifest.cos.yaml +1 -0
  36. package/types/amqp.d.ts +9 -0
  37. package/types/deployment.d.ts +7 -0
  38. package/types/http.d.ts +28 -0
  39. package/src/.manifest/index.js +0 -7
  40. package/src/.manifest/normalize.js +0 -17
  41. package/src/.manifest/schema.yaml +0 -13
  42. package/src/.manifest/validate.js +0 -13
  43. package/src/aspect.js +0 -95
  44. package/src/factory.js +0 -14
  45. package/src/manifest.js +0 -13
  46. package/test/aspect.test.js +0 -144
  47. package/test/factory.fixtures.js +0 -5
  48. package/test/factory.test.js +0 -22
  49. package/test/manifest.fixtures.js +0 -11
  50. package/test/manifest.test.js +0 -58
  51. package/types/aspect.ts +0 -19
  52. package/types/declaration.d.ts +0 -11
@@ -1,11 +0,0 @@
1
- 'use strict'
2
-
3
- const { generate } = require('randomstring')
4
-
5
- const declaration = {
6
- origins: {
7
- [generate()]: 'https://toa.io'
8
- }
9
- }
10
-
11
- exports.declaration = declaration
@@ -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
- })
package/types/aspect.ts DELETED
@@ -1,19 +0,0 @@
1
- import * as fetch from 'node-fetch'
2
-
3
- import * as _extensions from '@toa.io/core/types/extensions'
4
- import * as _retry from '@toa.io/generic/types/retry'
5
-
6
- declare namespace toa.extensions.origins {
7
-
8
- namespace invocation {
9
- type Options = {
10
- substitutions?: string[]
11
- retry?: _retry.Options
12
- }
13
- }
14
-
15
- interface Aspect extends _extensions.Aspect {
16
- invoke(name: string, path: string, request: fetch.RequestInit, options?: invocation.Options): Promise<fetch.Response>
17
- }
18
-
19
- }
@@ -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
- }