@toa.io/pointer 0.20.0-dev.31 → 0.20.0-dev.35
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 +15 -8
- package/readme.md +113 -76
- package/schemas/urimap.cos.yaml +2 -0
- package/source/Deployment.ts +90 -0
- package/source/annotation.test.ts +66 -0
- package/source/annotation.ts +46 -0
- package/source/createVariables.test.ts +186 -0
- package/source/createVariables.ts +12 -0
- package/source/index.ts +7 -0
- package/source/naming.ts +11 -0
- package/source/resolve.ts +53 -0
- package/tsconfig.json +12 -0
- package/source/.deployment/.variables/credentials.js +0 -35
- package/source/.deployment/.variables/index.js +0 -7
- package/source/.deployment/.variables/pointer.js +0 -18
- package/source/.deployment/index.js +0 -8
- package/source/.deployment/validate.js +0 -19
- package/source/.deployment/variables.js +0 -22
- package/source/.pointer/env.js +0 -44
- package/source/.pointer/index.js +0 -9
- package/source/.pointer/label.js +0 -15
- package/source/.pointer/local.js +0 -17
- package/source/deployment.js +0 -17
- package/source/index.js +0 -11
- package/source/pointer.js +0 -34
- package/source/uris/construct.js +0 -18
- package/source/uris/index.js +0 -9
- package/source/uris/normalize.js +0 -12
- package/source/uris/resolve.js +0 -18
- package/source/uris/schema.yaml +0 -17
- package/source/uris/validate.js +0 -17
- package/source/variable.js +0 -12
- package/test/deployment.test.js +0 -92
- package/test/pointer.test.js +0 -213
- package/test/uris.fixtures.js +0 -10
- package/test/uris.test.js +0 -146
- package/test/variable.test.js +0 -37
- package/transpiled/Deployment.d.ts +0 -15
- package/transpiled/Deployment.js +0 -42
- package/transpiled/Deployment.js.map +0 -1
- package/transpiled/Variables.d.ts +0 -15
- package/transpiled/Variables.js +0 -42
- package/transpiled/Variables.js.map +0 -1
- package/transpiled/annotation.d.ts +0 -3
- package/transpiled/annotation.js +0 -62
- package/transpiled/annotation.js.map +0 -1
- package/transpiled/createDeployment.d.ts +0 -4
- package/transpiled/createDeployment.js +0 -12
- package/transpiled/createDeployment.js.map +0 -1
- package/transpiled/createVariables.d.ts +0 -4
- package/transpiled/createVariables.js +0 -12
- package/transpiled/createVariables.js.map +0 -1
- package/transpiled/env.d.ts +0 -1
- package/transpiled/env.js +0 -10
- package/transpiled/env.js.map +0 -1
- package/transpiled/index.d.ts +0 -4
- package/transpiled/index.js +0 -8
- package/transpiled/index.js.map +0 -1
- package/transpiled/resolve.d.ts +0 -1
- package/transpiled/resolve.js +0 -25
- package/transpiled/resolve.js.map +0 -1
- package/transpiled/tsconfig.tsbuildinfo +0 -1
- package/types/_uris.d.ts +0 -27
- package/types/deployment.d.ts +0 -21
- package/types/index.d.ts +0 -1
- package/types/pointer.d.ts +0 -19
- package/types/uris.d.ts +0 -19
- package/types/variable.d.ts +0 -8
package/test/pointer.test.js
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { generate } = require('randomstring')
|
|
4
|
-
const { encode, letters: { up } } = require('@toa.io/generic')
|
|
5
|
-
|
|
6
|
-
const mock = { console: { info: jest.fn(), warn: jest.fn() } }
|
|
7
|
-
|
|
8
|
-
jest.mock('@toa.io/console', () => mock)
|
|
9
|
-
|
|
10
|
-
const { Locator } = require('@toa.io/core')
|
|
11
|
-
const { Pointer } = require('../')
|
|
12
|
-
|
|
13
|
-
it('should be', () => {
|
|
14
|
-
expect(Pointer).toBeDefined()
|
|
15
|
-
expect(Pointer).toBeInstanceOf(Function)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
const prefix = 'bindings-amqp'
|
|
19
|
-
|
|
20
|
-
/** @type {toa.core.Locator} */
|
|
21
|
-
let locator
|
|
22
|
-
|
|
23
|
-
/** @type {toa.pointer.Options} */
|
|
24
|
-
const options = { protocol: 'protocol:' }
|
|
25
|
-
|
|
26
|
-
/** @type {toa.pointer.Pointer} */
|
|
27
|
-
let pointer
|
|
28
|
-
|
|
29
|
-
/** @type {URL} */
|
|
30
|
-
let url
|
|
31
|
-
|
|
32
|
-
const uris = (uris) => (process.env[`TOA_${up(prefix)}_POINTER`] = encode(uris))
|
|
33
|
-
|
|
34
|
-
beforeEach(() => {
|
|
35
|
-
jest.clearAllMocks()
|
|
36
|
-
|
|
37
|
-
const name = generate()
|
|
38
|
-
const namespace = generate()
|
|
39
|
-
|
|
40
|
-
locator = new Locator(name, namespace)
|
|
41
|
-
|
|
42
|
-
url = new URL('amqp://whatever:3000')
|
|
43
|
-
|
|
44
|
-
uris({ default: url.href })
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('should throw if env not set', () => {
|
|
48
|
-
const name = `TOA_${up(prefix)}_POINTER`
|
|
49
|
-
delete process.env[name]
|
|
50
|
-
|
|
51
|
-
expect(() => new Pointer(prefix, locator, options)).toThrow(`Environment variable ${name} is not set`)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('should use declared protocol', () => {
|
|
55
|
-
pointer = new Pointer(prefix, locator, options)
|
|
56
|
-
|
|
57
|
-
expect(pointer.protocol).toStrictEqual(url.protocol)
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('should point to host', () => {
|
|
61
|
-
pointer = new Pointer(prefix, locator, options)
|
|
62
|
-
|
|
63
|
-
expect(pointer.hostname).toStrictEqual(url.hostname)
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('should resolve credentials', () => {
|
|
67
|
-
const check = (entry) => {
|
|
68
|
-
const env = `TOA_${up(prefix)}_${up(entry)}_`
|
|
69
|
-
const username = generate()
|
|
70
|
-
const password = generate()
|
|
71
|
-
|
|
72
|
-
process.env[env + 'USERNAME'] = username
|
|
73
|
-
process.env[env + 'PASSWORD'] = password
|
|
74
|
-
|
|
75
|
-
pointer = new Pointer(prefix, locator, options)
|
|
76
|
-
|
|
77
|
-
delete process.env[env + 'USERNAME']
|
|
78
|
-
delete process.env[env + 'PASSWORD']
|
|
79
|
-
|
|
80
|
-
expect(pointer.username).toStrictEqual(username)
|
|
81
|
-
expect(pointer.password).toStrictEqual(password)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// default resolution
|
|
85
|
-
check('default')
|
|
86
|
-
|
|
87
|
-
// namespace resolution
|
|
88
|
-
uris({ [locator.namespace]: 'pg://host0/db' })
|
|
89
|
-
check(locator.namespace)
|
|
90
|
-
|
|
91
|
-
// id resolution
|
|
92
|
-
uris({ [locator.id]: 'pg://host0/db' })
|
|
93
|
-
check(locator.label)
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it('should expose port as number', () => {
|
|
97
|
-
pointer = new Pointer(prefix, locator, options)
|
|
98
|
-
|
|
99
|
-
expect(pointer.port).toStrictEqual(Number(url.port))
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('should expose reference', () => {
|
|
103
|
-
pointer = new Pointer(prefix, locator, options)
|
|
104
|
-
|
|
105
|
-
expect(pointer.reference).toStrictEqual(url.href)
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
it('should use localhost and given protocol on local environment', () => {
|
|
109
|
-
process.env.TOA_DEV = '1'
|
|
110
|
-
|
|
111
|
-
pointer = new Pointer(prefix, locator, options)
|
|
112
|
-
|
|
113
|
-
delete process.env.TOA_DEV
|
|
114
|
-
|
|
115
|
-
expect(pointer.hostname).toStrictEqual('localhost')
|
|
116
|
-
expect(pointer.protocol).toStrictEqual(options.protocol)
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
it('should use default protocol and credentials on local environment', () => {
|
|
120
|
-
process.env.TOA_DEV = '1'
|
|
121
|
-
|
|
122
|
-
pointer = new Pointer(prefix, locator, options)
|
|
123
|
-
|
|
124
|
-
delete process.env.TOA_DEV
|
|
125
|
-
|
|
126
|
-
expect(pointer.reference).toStrictEqual(`${options.protocol}//developer:secret@localhost`)
|
|
127
|
-
expect(pointer.label).toStrictEqual(`${options.protocol}//developer@localhost`)
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
describe('environment variables', () => {
|
|
131
|
-
const username = generate()
|
|
132
|
-
const password = generate()
|
|
133
|
-
|
|
134
|
-
const env = `TOA_${up(prefix)}_DEFAULT`
|
|
135
|
-
|
|
136
|
-
let set
|
|
137
|
-
let unset
|
|
138
|
-
|
|
139
|
-
beforeEach(() => {
|
|
140
|
-
jest.clearAllMocks()
|
|
141
|
-
|
|
142
|
-
set = (name, value, prefix = env) => {
|
|
143
|
-
const key = prefix + '_' + up(name)
|
|
144
|
-
|
|
145
|
-
process.env[key] = value
|
|
146
|
-
url[name] = value
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
unset = (name, prefix = env) => {
|
|
150
|
-
const key = prefix + '_' + up(name)
|
|
151
|
-
|
|
152
|
-
delete process.env[key]
|
|
153
|
-
url[name] = ''
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
set('username', username)
|
|
157
|
-
set('password', password)
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
afterEach(() => {
|
|
161
|
-
unset('username')
|
|
162
|
-
unset('password')
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
it('should use env variables for credentials', () => {
|
|
166
|
-
pointer = new Pointer(prefix, locator, options)
|
|
167
|
-
|
|
168
|
-
expect(pointer.reference).toStrictEqual(url.href)
|
|
169
|
-
|
|
170
|
-
url.password = ''
|
|
171
|
-
|
|
172
|
-
expect(pointer.label).toStrictEqual(url.href)
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
it('should warn if username is not set', () => {
|
|
176
|
-
url.hostname = locator.hostname(prefix)
|
|
177
|
-
|
|
178
|
-
unset('username')
|
|
179
|
-
url.password = ''
|
|
180
|
-
|
|
181
|
-
const pointer = new Pointer(prefix, locator, options)
|
|
182
|
-
|
|
183
|
-
expect(pointer).toBeDefined()
|
|
184
|
-
expect(mock.console.warn).toHaveBeenCalledWith(`Username for ${env} is not set`)
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
it('should warn if password is not set', () => {
|
|
188
|
-
url.hostname = locator.hostname(prefix)
|
|
189
|
-
|
|
190
|
-
unset('password')
|
|
191
|
-
|
|
192
|
-
const pointer = new Pointer(prefix, locator, options)
|
|
193
|
-
|
|
194
|
-
expect(pointer).toBeDefined()
|
|
195
|
-
expect(mock.console.warn).toHaveBeenCalledWith(`Password for ${env} is not set`)
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
it('should not warn it credentials are set', () => {
|
|
199
|
-
uris({ [locator.id]: 'amqp://host0' })
|
|
200
|
-
|
|
201
|
-
const username = generate()
|
|
202
|
-
const password = generate()
|
|
203
|
-
const env = `TOA_${up(prefix)}_${locator.uppercase}`
|
|
204
|
-
|
|
205
|
-
set('username', username, env)
|
|
206
|
-
set('password', password, env)
|
|
207
|
-
|
|
208
|
-
const pointer = new Pointer(prefix, locator, options)
|
|
209
|
-
|
|
210
|
-
expect(pointer).toBeDefined()
|
|
211
|
-
expect(mock.console.warn).not.toHaveBeenCalled()
|
|
212
|
-
})
|
|
213
|
-
})
|
package/test/uris.fixtures.js
DELETED
package/test/uris.test.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const clone = require('clone-deep')
|
|
4
|
-
const { generate } = require('randomstring')
|
|
5
|
-
const { random } = require('@toa.io/generic')
|
|
6
|
-
const { Locator } = require('@toa.io/core')
|
|
7
|
-
|
|
8
|
-
const fixtures = require('./uris.fixtures')
|
|
9
|
-
const { uris } = require('../')
|
|
10
|
-
|
|
11
|
-
const gen = () => 'schema://host-' + generate().toLowerCase() + ':' + (random(1000) + 1000)
|
|
12
|
-
|
|
13
|
-
describe('construct', () => {
|
|
14
|
-
const construct = uris.construct
|
|
15
|
-
|
|
16
|
-
let annotations
|
|
17
|
-
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
annotations = clone(fixtures.annotations)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('should be', () => {
|
|
23
|
-
expect(construct).toBeDefined()
|
|
24
|
-
expect(construct).toBeInstanceOf(Function)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
describe('normalize', () => {
|
|
28
|
-
it('should treat string value as default', () => {
|
|
29
|
-
const declaration = gen()
|
|
30
|
-
const result = construct(declaration)
|
|
31
|
-
|
|
32
|
-
expect(result).toStrictEqual({ default: declaration })
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('should allow dot notation', () => {
|
|
36
|
-
const url = gen()
|
|
37
|
-
|
|
38
|
-
annotations['foo.bar'] = url
|
|
39
|
-
|
|
40
|
-
construct(annotations)
|
|
41
|
-
|
|
42
|
-
expect(annotations['foo.bar']).toStrictEqual(url)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('should allow shards', () => {
|
|
46
|
-
const annotations = 'schema://host{1-2}-' + generate().toLowerCase()
|
|
47
|
-
|
|
48
|
-
construct(annotations)
|
|
49
|
-
|
|
50
|
-
expect(annotations).toStrictEqual(annotations)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it('should allow dot notation with namespace value', () => {
|
|
54
|
-
annotations.foo = gen()
|
|
55
|
-
annotations['foo.bar'] = gen()
|
|
56
|
-
|
|
57
|
-
expect(() => construct(annotations)).not.toThrow()
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
describe('validate', () => {
|
|
62
|
-
it('should throw if declaration is not a string or an object', () => {
|
|
63
|
-
// noinspection JSCheckFunctionSignatures
|
|
64
|
-
expect(() => construct(1)).toThrow(TypeError)
|
|
65
|
-
expect(() => construct(null)).toThrow(TypeError)
|
|
66
|
-
})
|
|
67
|
-
})
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
describe('resolve', () => {
|
|
71
|
-
const resolve = uris.resolve
|
|
72
|
-
|
|
73
|
-
let name
|
|
74
|
-
let namespace
|
|
75
|
-
let uri
|
|
76
|
-
|
|
77
|
-
/** @type {toa.pointer.URIs} */
|
|
78
|
-
let annotation
|
|
79
|
-
|
|
80
|
-
/** @type {toa.core.Locator} */
|
|
81
|
-
let locator
|
|
82
|
-
|
|
83
|
-
beforeEach(() => {
|
|
84
|
-
name = generate()
|
|
85
|
-
namespace = generate()
|
|
86
|
-
uri = gen()
|
|
87
|
-
|
|
88
|
-
annotation = {
|
|
89
|
-
[namespace + '.' + name]: uri
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
locator = new Locator(name, namespace)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('should be', () => {
|
|
96
|
-
expect(uris.resolve).toBeDefined()
|
|
97
|
-
expect(uris.resolve).toBeInstanceOf(Function)
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
it('should resolve by id', () => {
|
|
101
|
-
const { url } = resolve(locator, annotation)
|
|
102
|
-
|
|
103
|
-
expect(url).toBeInstanceOf(URL)
|
|
104
|
-
expect(url.href).toStrictEqual(uri)
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
it('should throw if not found', () => {
|
|
108
|
-
const name = generate()
|
|
109
|
-
const namespace = generate()
|
|
110
|
-
const locator = new Locator(name, namespace)
|
|
111
|
-
|
|
112
|
-
expect(() => resolve(locator, annotation)).toThrow(`URI annotation for '${locator.id}' is not found`)
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
it('should resolve by namespace', () => {
|
|
116
|
-
annotation[namespace] = uri
|
|
117
|
-
|
|
118
|
-
const { url } = resolve(locator, annotation)
|
|
119
|
-
|
|
120
|
-
expect(url.href).toStrictEqual(uri)
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
it('should resolve default', () => {
|
|
124
|
-
annotation = { default: gen() }
|
|
125
|
-
|
|
126
|
-
const { url } = resolve(locator, annotation)
|
|
127
|
-
|
|
128
|
-
expect(url.href).toStrictEqual(annotation.default)
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
it('should resolve global locators', () => {
|
|
132
|
-
const name = generate()
|
|
133
|
-
const locator = new Locator(name)
|
|
134
|
-
const uri = gen()
|
|
135
|
-
|
|
136
|
-
annotation = { [name]: uri }
|
|
137
|
-
|
|
138
|
-
const { url } = resolve(locator, annotation)
|
|
139
|
-
|
|
140
|
-
expect(url.href).toStrictEqual(uri)
|
|
141
|
-
})
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
it('should expose validate function', async () => {
|
|
145
|
-
expect(uris.validate).toBeInstanceOf(Function)
|
|
146
|
-
})
|
package/test/variable.test.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { generate } = require('randomstring')
|
|
4
|
-
const { Locator } = require('@toa.io/core')
|
|
5
|
-
const { random, letters: { up } } = require('@toa.io/generic')
|
|
6
|
-
|
|
7
|
-
const { variable } = require('../')
|
|
8
|
-
|
|
9
|
-
it('should be', () => {
|
|
10
|
-
expect(variable).toBeInstanceOf(Function)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('should create variable', () => {
|
|
14
|
-
const prefix = 'foo-bar'
|
|
15
|
-
const namespace = generate()
|
|
16
|
-
const component = generate()
|
|
17
|
-
const locator = new Locator(component, namespace)
|
|
18
|
-
const name = generate()
|
|
19
|
-
|
|
20
|
-
let value = generate()
|
|
21
|
-
|
|
22
|
-
const string = variable(prefix, locator, name, value)
|
|
23
|
-
|
|
24
|
-
const expected = {
|
|
25
|
-
name: `TOA_${up(prefix)}_${locator.uppercase}_${up(name)}`,
|
|
26
|
-
value
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
expect(string).toStrictEqual(expected)
|
|
30
|
-
|
|
31
|
-
value = random()
|
|
32
|
-
expected.value = value
|
|
33
|
-
|
|
34
|
-
const number = variable(prefix, locator, name, value)
|
|
35
|
-
|
|
36
|
-
expect(number).toStrictEqual(expected)
|
|
37
|
-
})
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Variables } from '@toa.io/operations';
|
|
2
|
-
export declare class Deployment {
|
|
3
|
-
private readonly id;
|
|
4
|
-
private readonly annotation;
|
|
5
|
-
constructor(id: string, annotation: URIMap);
|
|
6
|
-
export(requests: Request[]): Variables;
|
|
7
|
-
private createVariables;
|
|
8
|
-
private createVariable;
|
|
9
|
-
private resolve;
|
|
10
|
-
}
|
|
11
|
-
export interface Request {
|
|
12
|
-
group: string;
|
|
13
|
-
selectors: string[];
|
|
14
|
-
}
|
|
15
|
-
export type URIMap = Record<string, string[]>;
|
package/transpiled/Deployment.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Deployment = void 0;
|
|
4
|
-
const env_1 = require("./env");
|
|
5
|
-
class Deployment {
|
|
6
|
-
id;
|
|
7
|
-
annotation;
|
|
8
|
-
constructor(id, annotation) {
|
|
9
|
-
this.id = id;
|
|
10
|
-
this.annotation = annotation;
|
|
11
|
-
}
|
|
12
|
-
export(requests) {
|
|
13
|
-
const variables = {};
|
|
14
|
-
for (const request of requests)
|
|
15
|
-
variables[request.group] = this.createVariables(request.selectors);
|
|
16
|
-
return variables;
|
|
17
|
-
}
|
|
18
|
-
createVariables(selectors) {
|
|
19
|
-
return selectors.map((selector) => this.createVariable(selector));
|
|
20
|
-
}
|
|
21
|
-
createVariable(selector) {
|
|
22
|
-
const name = (0, env_1.nameVariable)(this.id, selector);
|
|
23
|
-
const values = this.resolve(selector);
|
|
24
|
-
const value = values.join(' ');
|
|
25
|
-
return { name, value };
|
|
26
|
-
}
|
|
27
|
-
resolve(selector) {
|
|
28
|
-
if (selector in this.annotation)
|
|
29
|
-
return this.annotation[selector];
|
|
30
|
-
const segments = selector.split('.');
|
|
31
|
-
while (segments.pop() !== undefined) {
|
|
32
|
-
const current = segments.join('.');
|
|
33
|
-
if (current in this.annotation)
|
|
34
|
-
return this.annotation[current];
|
|
35
|
-
}
|
|
36
|
-
if (this.annotation['.'] === undefined)
|
|
37
|
-
throw new Error(`Selector '${selector}' cannot be resolved.`);
|
|
38
|
-
return this.annotation['.'];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.Deployment =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,CAAC,CAAA;QAEpC,OAAO,QAAQ,CAAC,GAAG,EAAE,KAAK,SAAS,EAAE;YACnC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAElC,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU;gBAAE,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;SAChE;QAED,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,SAAS;YACpC,MAAM,IAAI,KAAK,CAAC,aAAa,QAAQ,uBAAuB,CAAC,CAAA;QAE/D,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IAC7B,CAAC;CACF;AA9CD,gCA8CC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type * as operations from '@toa.io/operations';
|
|
2
|
-
export declare class Variables {
|
|
3
|
-
private readonly id;
|
|
4
|
-
private readonly annotation;
|
|
5
|
-
constructor(id: string, annotation: URIMap);
|
|
6
|
-
export(requests: Request[]): operations.Variables;
|
|
7
|
-
private createVariables;
|
|
8
|
-
private createVariable;
|
|
9
|
-
private resolve;
|
|
10
|
-
}
|
|
11
|
-
export interface Request {
|
|
12
|
-
group: string;
|
|
13
|
-
selectors: string[];
|
|
14
|
-
}
|
|
15
|
-
export type URIMap = Record<string, string[]>;
|
package/transpiled/Variables.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Variables = void 0;
|
|
4
|
-
const env_1 = require("./env");
|
|
5
|
-
class Variables {
|
|
6
|
-
id;
|
|
7
|
-
annotation;
|
|
8
|
-
constructor(id, annotation) {
|
|
9
|
-
this.id = id;
|
|
10
|
-
this.annotation = annotation;
|
|
11
|
-
}
|
|
12
|
-
export(requests) {
|
|
13
|
-
const variables = {};
|
|
14
|
-
for (const request of requests)
|
|
15
|
-
variables[request.group] = this.createVariables(request.selectors);
|
|
16
|
-
return variables;
|
|
17
|
-
}
|
|
18
|
-
createVariables(selectors) {
|
|
19
|
-
return selectors.map((selector) => this.createVariable(selector));
|
|
20
|
-
}
|
|
21
|
-
createVariable(selector) {
|
|
22
|
-
const name = (0, env_1.nameVariable)(this.id, selector);
|
|
23
|
-
const values = this.resolve(selector);
|
|
24
|
-
const value = values.join(' ');
|
|
25
|
-
return { name, value };
|
|
26
|
-
}
|
|
27
|
-
resolve(selector) {
|
|
28
|
-
if (selector in this.annotation)
|
|
29
|
-
return this.annotation[selector];
|
|
30
|
-
const segments = selector.split('.');
|
|
31
|
-
while (segments.pop() !== undefined) {
|
|
32
|
-
const current = segments.join('.');
|
|
33
|
-
if (current in this.annotation)
|
|
34
|
-
return this.annotation[current];
|
|
35
|
-
}
|
|
36
|
-
if (this.annotation['.'] === undefined)
|
|
37
|
-
throw new Error(`Selector '${selector}' cannot be resolved.`);
|
|
38
|
-
return this.annotation['.'];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.Variables = Variables;
|
|
42
|
-
//# sourceMappingURL=Variables.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Variables.js","sourceRoot":"","sources":["../source/Variables.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AAGpC,MAAa,SAAS;IACH,EAAE,CAAQ;IACV,UAAU,CAAQ;IAEnC,YAAoB,EAAU,EAAE,UAAkB;QAChD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAEM,MAAM,CAAE,QAAmB;QAChC,MAAM,SAAS,GAAyB,EAAE,CAAA;QAE1C,KAAK,MAAM,OAAO,IAAI,QAAQ;YAC5B,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAEpE,OAAO,SAAS,CAAA;IAClB,CAAC;IAEO,eA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(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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.normalize = void 0;
|
|
27
|
-
const node_path_1 = require("node:path");
|
|
28
|
-
const schemas = __importStar(require("@toa.io/schemas"));
|
|
29
|
-
const generic_1 = require("@toa.io/generic");
|
|
30
|
-
function normalize(declaration) {
|
|
31
|
-
const map = {};
|
|
32
|
-
if (typeof declaration === 'string' || Array.isArray(declaration))
|
|
33
|
-
declaration = { '.': declaration };
|
|
34
|
-
for (const [key, value] of Object.entries(declaration))
|
|
35
|
-
if (typeof value === 'string')
|
|
36
|
-
map[key] = format([value]);
|
|
37
|
-
else
|
|
38
|
-
map[key] = format(value);
|
|
39
|
-
validate(map);
|
|
40
|
-
return map;
|
|
41
|
-
}
|
|
42
|
-
exports.normalize = normalize;
|
|
43
|
-
function format(values) {
|
|
44
|
-
return values.map(generic_1.shards)
|
|
45
|
-
.flat()
|
|
46
|
-
.map((value) => (0, generic_1.echo)(value));
|
|
47
|
-
}
|
|
48
|
-
function validate(map) {
|
|
49
|
-
schema.validate(map);
|
|
50
|
-
for (const uris of Object.values(map))
|
|
51
|
-
for (const uri of uris)
|
|
52
|
-
checkCredentials(uri);
|
|
53
|
-
}
|
|
54
|
-
function checkCredentials(uri) {
|
|
55
|
-
const url = new URL(uri);
|
|
56
|
-
if (url.username !== '' || url.password !== '')
|
|
57
|
-
throw new Error(`Pointer URI '${uri}' must not contain credentials. ` +
|
|
58
|
-
'Please refer to the "Credentials" section in the documentation for more information.');
|
|
59
|
-
}
|
|
60
|
-
const path = (0, node_path_1.resolve)(__dirname, '../schemas/urimap.cos.yaml');
|
|
61
|
-
const schema = schemas.schema(path);
|
|
62
|
-
//# sourceMappingURL=annotation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"annotation.js","sourceRoot":"","sources":["../source/annotation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAmC;AACnC,yDAA0C;AAC1C,6CAA8C;AAG9C,SAAgB,SAAS,CAAE,WAAwB;IACjD,MAAM,GAAG,GAAW,EAAE,CAAA;IAEtB,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;QAC/D,WAAW,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,CAAA;IAEpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;QACpD,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;;YACpD,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAE/B,QAAQ,CAAC,GAAG,CAAC,CAAA;IAEb,OAAO,GAAG,CAAA;AACZ,CAAC;AAbD,8BAaC;AAED,SAAS,MAAM,CAAE,MAAgB;IAC/B,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAM,CAAC;SACtB,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,cAAI,EAAC,KAAK,CAAC,CAAC,CAAA;AAChC,CAAC;AAED,SAAS,QAAQ,CAAE,GAAW;IAC5B,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IAEpB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;QACnC,KAAK,MAAM,GAAG,IAAI,IAAI;YACpB,gBAAgB,CAAC,GAAG,CAAC,CAAA;AAC3B,CAAC;AAED,SAAS,gBAAgB,CAAE,GAAW;IACpC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAExB,IAAI,GAAG,CAAC,QAAQ,KAAK,EAAE,IAAI,GAAG,CAAC,QAAQ,KAAK,EAAE;QAC5C,MAAM,IAAI,KAAK,CAAC,gBAAgB,GAAG,kCAAkC;YACnE,sFAAsF,CAAC,CAAA;AAC7F,CAAC;AAED,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,4BAA4B,CAAC,CAAA;AAC7D,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createVariables = void 0;
|
|
4
|
-
const Deployment_1 = require("./Deployment");
|
|
5
|
-
const annotation_1 = require("./annotation");
|
|
6
|
-
function createVariables(id, declaration, requests) {
|
|
7
|
-
const annotation = (0, annotation_1.normalize)(declaration);
|
|
8
|
-
const deployment = new Deployment_1.Deployment(id, annotation);
|
|
9
|
-
return deployment.export(requests);
|
|
10
|
-
}
|
|
11
|
-
exports.createVariables = createVariables;
|
|
12
|
-
//# sourceMappingURL=createDeployment.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createDeployment.js","sourceRoot":"","sources":["../source/createDeployment.ts"],"names":[],"mappings":";;;AAAA,6CAAuD;AACvD,6CAAwC;AAIxC,SAAgB,eAAe,CAC9B,EAAU,EAAE,WAAwB,EAAE,QAAmB;IACxD,MAAM,UAAU,GAAG,IAAA,sBAAS,EAAC,WAAW,CAAC,CAAA;IACzC,MAAM,UAAU,GAAG,IAAI,uBAAU,CAAC,EAAE,EAAE,UAAU,CAAC,CAAA;IAEjD,OAAO,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACpC,CAAC;AAND,0CAMC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createVariables = void 0;
|
|
4
|
-
const Deployment_1 = require("./Deployment");
|
|
5
|
-
const annotation_1 = require("./annotation");
|
|
6
|
-
function createVariables(id, declaration, requests) {
|
|
7
|
-
const annotation = (0, annotation_1.normalize)(declaration);
|
|
8
|
-
const deployment = new Deployment_1.Deployment(id, annotation);
|
|
9
|
-
return deployment.export(requests);
|
|
10
|
-
}
|
|
11
|
-
exports.createVariables = createVariables;
|
|
12
|
-
//# sourceMappingURL=createVariables.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createVariables.js","sourceRoot":"","sources":["../source/createVariables.ts"],"names":[],"mappings":";;;AAAA,6CAAuD;AACvD,6CAAwC;AAIxC,SAAgB,eAAe,CAC9B,EAAU,EAAE,WAAwB,EAAE,QAAmB;IACxD,MAAM,UAAU,GAAG,IAAA,sBAAS,EAAC,WAAW,CAAC,CAAA;IACzC,MAAM,UAAU,GAAG,IAAI,uBAAU,CAAC,EAAE,EAAE,UAAU,CAAC,CAAA;IAEjD,OAAO,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACpC,CAAC;AAND,0CAMC"}
|
package/transpiled/env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function nameVariable(...segments: string[]): string;
|
package/transpiled/env.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nameVariable = void 0;
|
|
4
|
-
function nameVariable(...segments) {
|
|
5
|
-
return 'TOA_' + segments.join('_')
|
|
6
|
-
.replaceAll(/[-.]/g, '_')
|
|
7
|
-
.toUpperCase();
|
|
8
|
-
}
|
|
9
|
-
exports.nameVariable = nameVariable;
|
|
10
|
-
//# sourceMappingURL=env.js.map
|
package/transpiled/env.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../source/env.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAE,GAAG,QAAkB;IACjD,OAAO,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;SAC/B,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC;SACxB,WAAW,EAAE,CAAA;AAClB,CAAC;AAJD,oCAIC"}
|
package/transpiled/index.d.ts
DELETED