@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.
- package/package.json +9 -8
- package/readme.md +113 -0
- package/source/.deployment/index.js +5 -0
- package/source/.deployment/uris.js +35 -0
- package/source/.test/constants.js +3 -0
- package/source/.test/deployment.fixtures.js +20 -0
- package/source/.test/factory.fixtures.js +13 -0
- package/source/constants.js +3 -0
- package/source/deployment.js +28 -0
- package/source/deployment.test.js +158 -0
- package/source/env.js +50 -0
- package/source/factory.js +46 -0
- package/source/factory.test.js +140 -0
- package/{src → source}/index.js +2 -0
- package/source/manifest.js +25 -0
- package/source/manifest.test.js +57 -0
- package/source/protocols/amqp/.test/aspect.fixtures.js +15 -0
- package/source/protocols/amqp/.test/mock.comq.js +13 -0
- package/source/protocols/amqp/aspect.js +77 -0
- package/source/protocols/amqp/aspect.test.js +119 -0
- package/source/protocols/amqp/deployment.js +63 -0
- package/source/protocols/amqp/id.js +3 -0
- package/source/protocols/amqp/index.js +11 -0
- package/source/protocols/amqp/protocols.js +3 -0
- package/source/protocols/http/.aspect/permissions.js +65 -0
- package/{test → source/protocols/http/.test}/aspect.fixtures.js +6 -6
- package/source/protocols/http/aspect.js +129 -0
- package/source/protocols/http/aspect.test.js +239 -0
- package/source/protocols/http/id.js +3 -0
- package/source/protocols/http/index.js +9 -0
- package/source/protocols/http/protocols.js +3 -0
- package/source/protocols/index.js +6 -0
- package/source/schemas/annotations.cos.yaml +1 -0
- package/source/schemas/index.js +8 -0
- package/source/schemas/manifest.cos.yaml +1 -0
- package/types/amqp.d.ts +9 -0
- package/types/deployment.d.ts +7 -0
- package/types/http.d.ts +28 -0
- package/src/.manifest/index.js +0 -7
- package/src/.manifest/normalize.js +0 -17
- package/src/.manifest/schema.yaml +0 -13
- package/src/.manifest/validate.js +0 -13
- package/src/aspect.js +0 -95
- package/src/factory.js +0 -14
- package/src/manifest.js +0 -13
- package/test/aspect.test.js +0 -144
- package/test/factory.fixtures.js +0 -5
- package/test/factory.test.js +0 -22
- package/test/manifest.fixtures.js +0 -11
- package/test/manifest.test.js +0 -58
- package/types/aspect.ts +0 -19
- package/types/declaration.d.ts +0 -11
package/test/manifest.test.js
DELETED
|
@@ -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
|
-
}
|