@toa.io/userland 1.0.0-alpha.7 → 1.0.0-alpha.9

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 (98) hide show
  1. package/package.json +9 -9
  2. package/readme.md +0 -2
  3. package/example/components/echo/samples/get.yaml +0 -12
  4. package/example/components/echo/samples/signal.yaml +0 -4
  5. package/example/components/math.calculations/samples/add.yaml +0 -10
  6. package/example/components/math.calculations/samples/assets/ab.yaml +0 -2
  7. package/example/components/math.calculations/samples/increment.yaml +0 -27
  8. package/example/components/math.proxy/samples/add.yaml +0 -11
  9. package/example/components/tea.pots/samples/same.yaml +0 -8
  10. package/example/components/tea.pots/samples/transit.yaml +0 -43
  11. package/example/components/web/samples/get.yaml +0 -8
  12. package/example/samples/math.proxy.add.yaml +0 -5
  13. package/example/samples/messages/store.orders.created.yaml +0 -8
  14. package/samples/docs/sampling-dark.jpg +0 -0
  15. package/samples/docs/sampling-light.jpg +0 -0
  16. package/samples/notes.md +0 -12
  17. package/samples/package.json +0 -5
  18. package/samples/readme.md +0 -131
  19. package/samples/src/.replay/.suite/component.js +0 -20
  20. package/samples/src/.replay/.suite/index.js +0 -7
  21. package/samples/src/.replay/.suite/messages.js +0 -39
  22. package/samples/src/.replay/.suite/operation.js +0 -28
  23. package/samples/src/.replay/.suite/operations.js +0 -20
  24. package/samples/src/.replay/.suite/translate/.message/index.js +0 -5
  25. package/samples/src/.replay/.suite/translate/.message/request.js +0 -31
  26. package/samples/src/.replay/.suite/translate/.operation/.prepare/cast.js +0 -20
  27. package/samples/src/.replay/.suite/translate/.operation/.prepare/cast.test.js +0 -94
  28. package/samples/src/.replay/.suite/translate/.operation/.prepare/expand.js +0 -14
  29. package/samples/src/.replay/.suite/translate/.operation/.prepare/index.js +0 -7
  30. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/.aspect.js +0 -26
  31. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/configuration.js +0 -5
  32. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/http.js +0 -5
  33. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/index.js +0 -9
  34. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/state.js +0 -5
  35. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/async.js +0 -3
  36. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/cast.js +0 -26
  37. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/index.js +0 -5
  38. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/map.js +0 -3
  39. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/set.js +0 -3
  40. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/sync.js +0 -3
  41. package/samples/src/.replay/.suite/translate/.operation/calls.js +0 -49
  42. package/samples/src/.replay/.suite/translate/.operation/cleanup.js +0 -16
  43. package/samples/src/.replay/.suite/translate/.operation/events.js +0 -16
  44. package/samples/src/.replay/.suite/translate/.operation/index.js +0 -11
  45. package/samples/src/.replay/.suite/translate/.operation/prepare.js +0 -14
  46. package/samples/src/.replay/.suite/translate/index.js +0 -7
  47. package/samples/src/.replay/.suite/translate/message.js +0 -26
  48. package/samples/src/.replay/.suite/translate/operation.js +0 -47
  49. package/samples/src/.replay/.suite/translate/schemas/index.js +0 -7
  50. package/samples/src/.replay/.suite/translate/schemas/message.cos.yaml +0 -10
  51. package/samples/src/.replay/.suite/translate/schemas/operation.cos.yaml +0 -23
  52. package/samples/src/.replay/index.js +0 -7
  53. package/samples/src/.replay/stage.js +0 -60
  54. package/samples/src/.replay/suite.js +0 -23
  55. package/samples/src/.replay/test.js +0 -19
  56. package/samples/src/components.js +0 -13
  57. package/samples/src/context.js +0 -23
  58. package/samples/src/index.js +0 -9
  59. package/samples/src/replay.js +0 -16
  60. package/samples/src/suite/.read/filter.js +0 -15
  61. package/samples/src/suite/.read/index.js +0 -7
  62. package/samples/src/suite/.read/messages.js +0 -40
  63. package/samples/src/suite/.read/operations.js +0 -51
  64. package/samples/src/suite/.read/parse.js +0 -20
  65. package/samples/src/suite/components.js +0 -31
  66. package/samples/src/suite/context.js +0 -20
  67. package/samples/src/suite/index.js +0 -7
  68. package/samples/test/components.test.js +0 -42
  69. package/samples/test/context/components/dummy/manifest.toa.yaml +0 -2
  70. package/samples/test/context/components/dummy/samples/do.yaml +0 -11
  71. package/samples/test/context/components/dummy/samples/dummies.dummy.do.yaml +0 -11
  72. package/samples/test/context/components/dummy/samples/dummies.dummy.undo.yaml +0 -7
  73. package/samples/test/context/components/dummy/samples/messages/somewhere.something.happened.yaml +0 -6
  74. package/samples/test/context/components/pot/manifest.toa.yaml +0 -2
  75. package/samples/test/context/components/pot/samples/do.yaml +0 -11
  76. package/samples/test/context/components/pot/samples/messages/somewhere.something.happened.yaml +0 -6
  77. package/samples/test/context/context.toa.yaml +0 -3
  78. package/samples/test/context/samples/dummies.dummy.observe.yaml +0 -6
  79. package/samples/test/context/samples/dummies.dummy.transit.yaml +0 -10
  80. package/samples/test/context/samples/messages/somewhere.something.happened.yaml +0 -6
  81. package/samples/test/context.fixtures.js +0 -8
  82. package/samples/test/context.test.js +0 -82
  83. package/samples/test/replay.mock.js +0 -7
  84. package/samples/test/replay.test.js +0 -152
  85. package/samples/test/replay.translate.message.fixtures.js +0 -24
  86. package/samples/test/replay.translate.message.test.js +0 -119
  87. package/samples/test/replay.translate.mock.js +0 -17
  88. package/samples/test/replay.translate.operation.fixtures.js +0 -107
  89. package/samples/test/replay.translate.operation.test.js +0 -68
  90. package/samples/test/stage.mock.js +0 -30
  91. package/samples/test/suite.components.test.js +0 -122
  92. package/samples/test/suite.context.test.js +0 -79
  93. package/samples/test/suite.mock.js +0 -10
  94. package/samples/types/index.d.ts +0 -8
  95. package/samples/types/message.d.ts +0 -24
  96. package/samples/types/operation.d.ts +0 -36
  97. package/samples/types/replay.d.ts +0 -13
  98. package/samples/types/suite.d.ts +0 -31
@@ -1,5 +0,0 @@
1
- 'use strict'
2
-
3
- const { aspect } = require('./.aspect')
4
-
5
- exports.configuration = aspect('configuration')
@@ -1,5 +0,0 @@
1
- 'use strict'
2
-
3
- const { aspect } = require('./.aspect')
4
-
5
- exports.http = aspect('http')
@@ -1,9 +0,0 @@
1
- 'use strict'
2
-
3
- const { configuration } = require('./configuration')
4
- const { state } = require('./state')
5
- const { http } = require('./http')
6
-
7
- exports.configuration = configuration
8
- exports.state = state
9
- exports.http = http
@@ -1,5 +0,0 @@
1
- 'use strict'
2
-
3
- const { aspect } = require('./.aspect')
4
-
5
- exports.state = aspect('state')
@@ -1,3 +0,0 @@
1
- 'use strict'
2
-
3
- module.exports = (value) => async () => value
@@ -1,26 +0,0 @@
1
- 'use strict'
2
-
3
- const { map } = require('@toa.io/generic')
4
-
5
- const types = {
6
- Map: require('./map'),
7
- Set: require('./set'),
8
- sync: require('./sync'),
9
- async: require('./async')
10
- }
11
-
12
- function cast (value) {
13
- return map(value, replace)
14
- }
15
-
16
- function replace (key, value) {
17
- const [name, type] = key.split(':')
18
-
19
- if (!(type in types)) return
20
-
21
- const typed = types[type](value)
22
-
23
- return [name, typed]
24
- }
25
-
26
- exports.cast = cast
@@ -1,5 +0,0 @@
1
- 'use strict'
2
-
3
- const { cast } = require('./cast')
4
-
5
- exports.cast = cast
@@ -1,3 +0,0 @@
1
- 'use strict'
2
-
3
- module.exports = (value) => new Map(Object.entries(value))
@@ -1,3 +0,0 @@
1
- 'use strict'
2
-
3
- module.exports = (value) => new Set(value)
@@ -1,3 +0,0 @@
1
- 'use strict'
2
-
3
- module.exports = (value) => () => value
@@ -1,49 +0,0 @@
1
- 'use strict'
2
-
3
- const { defined } = require('@toa.io/generic')
4
-
5
- /**
6
- * @param {toa.samples.operation.Calls} calls
7
- * @returns {toa.sampling.request.context.Calls}
8
- */
9
- const calls = (calls) => {
10
- /** @type {toa.sampling.request.context.Calls} */
11
- const output = {}
12
-
13
- for (let [endpoint, samples] of Object.entries(calls)) {
14
- if (!Array.isArray(samples)) samples = [samples]
15
-
16
- const target = []
17
-
18
- for (const sample of samples) {
19
- const translation = call(sample)
20
-
21
- target.push(translation)
22
- }
23
-
24
- output[endpoint] = target
25
- }
26
-
27
- return output
28
- }
29
-
30
- /**
31
- * @param {toa.samples.operation.Call} call
32
- * @returns {toa.sampling.request.context.Call}
33
- */
34
- const call = (call) => {
35
- let request
36
- let reply
37
-
38
- const sample = {}
39
- const { input, query, output } = call
40
-
41
- if (input !== undefined || query !== undefined) request = defined({ input, query })
42
- if (output !== undefined) reply = { output }
43
- if (request !== undefined) sample.request = request
44
- if (reply !== undefined) sample.reply = reply
45
-
46
- return sample
47
- }
48
-
49
- exports.calls = calls
@@ -1,16 +0,0 @@
1
- 'use strict'
2
-
3
- const { defined, empty } = require('@toa.io/generic')
4
-
5
- /**
6
- * @param {toa.sampling.request.Sample} sample
7
- */
8
- const cleanup = (sample) => {
9
- for (const [key, value] of Object.entries(sample)) {
10
- if (value === undefined || (typeof value === 'object' && empty(defined(value)))) {
11
- delete sample[key]
12
- }
13
- }
14
- }
15
-
16
- exports.cleanup = cleanup
@@ -1,16 +0,0 @@
1
- 'use strict'
2
-
3
- /**
4
- * @param {toa.samples.operations.Events} events
5
- * @returns {toa.sampling.request.Events}
6
- */
7
- const events = (events) => {
8
- /** @type {toa.sampling.request.Events} */
9
- const set = {}
10
-
11
- for (const [label, sample] of Object.entries(events)) set[label] = { payload: sample }
12
-
13
- return set
14
- }
15
-
16
- exports.events = events
@@ -1,11 +0,0 @@
1
- 'use strict'
2
-
3
- const { calls } = require('./calls')
4
- const { events } = require('./events')
5
- const { cleanup } = require('./cleanup')
6
- const { prepare } = require('./prepare')
7
-
8
- exports.calls = calls
9
- exports.events = events
10
- exports.cleanup = cleanup
11
- exports.prepare = prepare
@@ -1,14 +0,0 @@
1
- 'use strict'
2
-
3
- const { cast, expand } = require('./.prepare')
4
-
5
- /**
6
- * @param {toa.samples.Operation & Object} declaration
7
- */
8
- const prepare = (declaration) => {
9
- expand(declaration)
10
-
11
- if ('extensions' in declaration) cast(declaration.extensions)
12
- }
13
-
14
- exports.prepare = prepare
@@ -1,7 +0,0 @@
1
- 'use strict'
2
-
3
- const { operation } = require('./operation')
4
- const { message } = require('./message')
5
-
6
- exports.operation = operation
7
- exports.message = message
@@ -1,26 +0,0 @@
1
- 'use strict'
2
-
3
- const { schemas } = require('./schemas')
4
- const translate = require('./.message')
5
-
6
- const schema = schemas.schema('message')
7
-
8
- /**
9
- * @param {toa.samples.Message} declaration
10
- * @param {boolean} autonomous
11
- * @param {string} component
12
- * @returns {toa.sampling.Message}
13
- */
14
- const message = (declaration, autonomous, component) => {
15
- schema.validate(declaration)
16
-
17
- const payload = declaration.payload
18
- const request = translate.request(declaration, autonomous)
19
-
20
- /** @type {toa.sampling.messages.Sample} */
21
- const sample = { authentic: true, component, request }
22
-
23
- return { payload, sample }
24
- }
25
-
26
- exports.message = message
@@ -1,47 +0,0 @@
1
- 'use strict'
2
-
3
- const transform = require('./.operation')
4
- const { schemas } = require('./schemas')
5
-
6
- const schema = schemas.schema('operation')
7
-
8
- /**
9
- * @param {toa.samples.Operation} declaration
10
- * @param {boolean} autonomous
11
- * @returns {toa.sampling.Request}
12
- */
13
- const operation = (declaration, autonomous) => {
14
- transform.prepare(declaration)
15
- schema.validate(declaration)
16
-
17
- const { title, input, output, local, remote, current, next, extensions } = declaration
18
- const reply = { output }
19
- const storage = { current, next }
20
-
21
- /** @type {toa.sampling.request.Context} */
22
- let context = {}
23
-
24
- /** @type {toa.sampling.request.Events} */
25
- let events
26
-
27
- if (local !== undefined) context.local = transform.calls(local)
28
- if (remote !== undefined) context.remote = transform.calls(remote)
29
- if (declaration.events !== undefined) events = transform.events(declaration.events)
30
-
31
- const sample = /** @type {toa.sampling.request.Sample} */ {
32
- authentic: true,
33
- autonomous,
34
- title,
35
- reply,
36
- context,
37
- storage,
38
- events,
39
- extensions
40
- }
41
-
42
- transform.cleanup(sample)
43
-
44
- return { input, sample }
45
- }
46
-
47
- exports.operation = operation
@@ -1,7 +0,0 @@
1
- 'use strict'
2
-
3
- const { namespace } = require('@toa.io/schemas')
4
-
5
- const schemas = namespace(__dirname)
6
-
7
- exports.schemas = schemas
@@ -1,10 +0,0 @@
1
- autonomous: boolean
2
- component: string
3
- title: string
4
- payload: object
5
- input: ~
6
- query: object
7
- request:
8
- $ref: 'operation'
9
- not:
10
- required: [input]
@@ -1,23 +0,0 @@
1
- autonomous: boolean
2
- title: string
3
- input: ~
4
- output: ~
5
- local: &calls
6
- ~+:
7
- input: ~
8
- query:
9
- id: string
10
- criteria: string
11
- omit: number
12
- limit: number
13
- output: ~
14
- remote: *calls
15
- current+: object
16
- next: object
17
- events:
18
- ~: object
19
- extensions:
20
- ~:
21
- - arguments: [~]
22
- result: ~
23
- permanent: boolean
@@ -1,7 +0,0 @@
1
- 'use strict'
2
-
3
- const { test } = require('./test')
4
- const stage = require('./stage')
5
-
6
- exports.test = test
7
- exports.stage = stage
@@ -1,60 +0,0 @@
1
- 'use strict'
2
-
3
- const stage = require('@toa.io/userland/stage')
4
- const storage = require.resolve('@toa.io/storages.null')
5
-
6
- /**
7
- * @param {string[]} paths
8
- * @param {boolean} autonomous
9
- * @return {Promise<Record<string, toa.core.Component>>}
10
- */
11
- async function setup (paths, autonomous) {
12
- if (!autonomous) return remotes(paths)
13
- else return components(paths)
14
- }
15
-
16
- async function remotes (paths) {
17
- await stage.composition(paths)
18
-
19
- const remotes = {}
20
-
21
- for (const path of paths) {
22
- const id = await getId(path)
23
-
24
- remotes[id] = await stage.remote(id)
25
- }
26
-
27
- return remotes
28
- }
29
-
30
- async function components (paths) {
31
- const components = {}
32
-
33
- process.env.TOA_SAMPLING_AUTONOMOUS = '1'
34
-
35
- for (const path of paths) {
36
- const id = await getId(path)
37
-
38
- components[id] = await stage.component(path, { storage })
39
- }
40
-
41
- delete process.env.TOA_SAMPLING_AUTONOMOUS
42
-
43
- return components
44
- }
45
-
46
- async function getId (path) {
47
- const manifest = await stage.manifest(path)
48
-
49
- return manifest.locator.id
50
- }
51
-
52
- /**
53
- * @return {Promise<void>}
54
- */
55
- async function shutdown () {
56
- await stage.shutdown()
57
- }
58
-
59
- exports.setup = setup
60
- exports.shutdown = shutdown
@@ -1,23 +0,0 @@
1
- 'use strict'
2
-
3
- const replay = require('./.suite')
4
-
5
- /**
6
- * @param {toa.samples.Suite} suite
7
- * @param {Record<string, toa.core.Component>} components
8
- * @returns {Function}
9
- */
10
- const suite = (suite, components) =>
11
- async (test) => {
12
- if ('operations' in suite) {
13
- await test.test('Operations', replay.operations(suite.operations, components, suite.autonomous))
14
- }
15
-
16
- if ('messages' in suite) {
17
- await test.test('Messages', replay.messages(suite.messages, suite.autonomous))
18
- }
19
-
20
- test.end()
21
- }
22
-
23
- exports.suite = suite
@@ -1,19 +0,0 @@
1
- 'use strict'
2
-
3
- const tap = require('tap')
4
-
5
- const replay = require('./suite')
6
-
7
- /**
8
- * @param {toa.samples.Suite} suite
9
- * @param {Record<string, toa.core.Component>} components
10
- * @param {object} options
11
- * @return {Promise<boolean>}
12
- */
13
- const test = async (suite, components, options) => {
14
- const result = await tap.test(suite.title, options, replay.suite(suite, components))
15
-
16
- return result === null ? false : result.ok
17
- }
18
-
19
- exports.test = test
@@ -1,13 +0,0 @@
1
- 'use strict'
2
-
3
- const { components: load } = require('./suite')
4
- const { replay } = require('./replay')
5
-
6
- /** @type {toa.samples.replay.components} */
7
- const components = async (paths, options = {}) => {
8
- const suite = await load(paths, options)
9
-
10
- return await replay(suite, paths, options.runner)
11
- }
12
-
13
- exports.components = components
@@ -1,23 +0,0 @@
1
- 'use strict'
2
-
3
- const norm = require('@toa.io/norm')
4
-
5
- const test = require('./components')
6
- const { context: load } = require('./suite')
7
- const { replay } = require('./replay')
8
-
9
- /** @type {toa.samples.replay.context} */
10
- const context = async (path, options = {}) => {
11
- const context = await norm.context(path)
12
- const suite = await load(path, options)
13
- const paths = context.components.map((component) => component.path)
14
-
15
- let ok = true
16
-
17
- if (options.integration !== true) ok = await test.components(paths, options)
18
- if (ok && options.autonomous !== true) ok = await replay(suite, paths, options.runner)
19
-
20
- return ok
21
- }
22
-
23
- exports.context = context
@@ -1,9 +0,0 @@
1
- 'use strict'
2
-
3
- const { context } = require('./context')
4
- const { components } = require('./components')
5
- const { replay } = require('./replay')
6
-
7
- exports.context = context
8
- exports.components = components
9
- exports.replay = replay
@@ -1,16 +0,0 @@
1
- 'use strict'
2
-
3
- const { test, stage } = require('./.replay')
4
-
5
- /** @type {toa.samples.replay.replay} */
6
- const replay = async (suite, paths, options = undefined) => {
7
- const components = await stage.setup(paths, suite.autonomous)
8
-
9
- const ok = await test(suite, components, options)
10
-
11
- await stage.shutdown()
12
-
13
- return ok
14
- }
15
-
16
- exports.replay = replay
@@ -1,15 +0,0 @@
1
- 'use strict'
2
-
3
- /**
4
- * @template {{ title: string }} T
5
- * @param {T[]} samples
6
- * @param {string} expression
7
- * @returns {T}
8
- */
9
- function filter (samples, expression) {
10
- const rx = new RegExp(expression)
11
-
12
- return samples.filter((sample) => rx.test(sample.title))
13
- }
14
-
15
- exports.filter = filter
@@ -1,7 +0,0 @@
1
- 'use strict'
2
-
3
- const { operations } = require('./operations')
4
- const { messages } = require('./messages')
5
-
6
- exports.operations = operations
7
- exports.messages = messages
@@ -1,40 +0,0 @@
1
- 'use strict'
2
-
3
- const { join, basename } = require('node:path')
4
- const { file: { glob } } = require('@toa.io/filesystem')
5
- const yaml = require('@toa.io/yaml')
6
-
7
- const { filter } = require('./filter')
8
-
9
- /**
10
- * @param {string} path
11
- * @param {toa.samples.suite.Options} options
12
- * @returns {Promise<toa.samples.messages.Set>}
13
- */
14
- const messages = async (path, options) => {
15
- /** @type {toa.samples.messages.Set} */
16
- const messages = {}
17
-
18
- const pattern = join(path, DIRECTORY, PATTERN)
19
- const files = await glob(pattern)
20
-
21
- for (const file of files) {
22
- const label = basename(file, EXTENSION)
23
-
24
- let samples = /** @type {toa.samples.Message[]} */ await yaml.load.all(file)
25
-
26
- if (options.id !== undefined) samples.forEach((sample) => (sample.component = options.id))
27
- if (options.component !== undefined) samples = samples.filter((sample) => sample.component === options.component)
28
- if (options.title !== undefined) samples = filter(samples, options.title)
29
-
30
- messages[label] = samples
31
- }
32
-
33
- return messages
34
- }
35
-
36
- const DIRECTORY = 'samples/messages'
37
- const EXTENSION = '.yaml'
38
- const PATTERN = '*' + EXTENSION
39
-
40
- exports.messages = messages
@@ -1,51 +0,0 @@
1
- 'use strict'
2
-
3
- const { basename, join } = require('node:path')
4
- const { file: { glob } } = require('@toa.io/filesystem')
5
- const { merge } = require('@toa.io/generic')
6
- const yaml = require('@toa.io/yaml')
7
-
8
- const { parse } = require('./parse')
9
- const { filter } = require('./filter')
10
-
11
- /**
12
- * @param {string} path
13
- * @param {toa.samples.suite.Options} options
14
- * @returns {Promise<toa.samples.suite.Operations>}
15
- */
16
- const operations = async (path, options) => {
17
- /** @type {toa.samples.suite.Operations} */
18
- const operations = {}
19
-
20
- const pattern = join(path, DIRECTORY, PATTERN)
21
- const files = await glob(pattern)
22
-
23
- for (const file of files) {
24
- const name = basename(file, EXTENSION)
25
- const [component, operation] = parse(name, options.id)
26
-
27
- if (options.component !== undefined && component !== options.component) continue
28
- if (options.operation !== undefined && operation !== options.operation) continue
29
-
30
- let samples = /** @type {toa.samples.Operation[]} */ await yaml.load.all(file)
31
-
32
- if (options.title !== undefined) samples = filter(samples, options.title)
33
- if (samples.length === 0) continue
34
-
35
- if (operations[component] === undefined) operations[component] = {}
36
-
37
- /** @type {toa.samples.operations.Set} */
38
- const set = operations[component]
39
-
40
- if (set[operation] === undefined) set[operation] = samples
41
- else set[operation] = /** @type {toa.samples.Operation[]} */ merge(set[operation], samples)
42
- }
43
-
44
- return operations
45
- }
46
-
47
- const DIRECTORY = 'samples'
48
- const EXTENSION = '.yaml'
49
- const PATTERN = '*' + EXTENSION
50
-
51
- exports.operations = operations
@@ -1,20 +0,0 @@
1
- 'use strict'
2
-
3
- /**
4
- * @param {string} name
5
- * @param {string} [def]
6
- * @returns {[string, string]}
7
- */
8
- const parse = (name, def) => {
9
- const parts = name.split('.')
10
- const [endpoint, component, namespace] = parts.reverse()
11
- const id = namespace === undefined ? def : namespace + '.' + component
12
-
13
- if (id !== undefined && def !== undefined && id !== def) {
14
- throw new Error(`Component id mismatch: '${id}' expected, '${component}' given`)
15
- }
16
-
17
- return [id, endpoint]
18
- }
19
-
20
- exports.parse = parse