@toa.io/norm 1.0.0-alpha.28 → 1.0.0-alpha.282

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 (72) hide show
  1. package/CHANGELOG.md +184 -0
  2. package/package.json +8 -7
  3. package/src/.component/.expand/bridge.js +2 -6
  4. package/src/.component/.expand/entity.js +2 -9
  5. package/src/.component/.expand/events.js +2 -6
  6. package/src/.component/.expand/extensions.js +4 -8
  7. package/src/.component/.expand/index.js +8 -19
  8. package/src/.component/.expand/operations.js +2 -9
  9. package/src/.component/.expand/properties.js +2 -6
  10. package/src/.component/.expand/receivers.js +2 -6
  11. package/src/.component/.expand/version.js +39 -27
  12. package/src/.component/.normalize/events.js +12 -5
  13. package/src/.component/.normalize/index.js +3 -9
  14. package/src/.component/.normalize/operations.js +2 -6
  15. package/src/.component/.normalize/receivers.js +1 -5
  16. package/src/.component/collapse.js +7 -6
  17. package/src/.component/defaults.js +14 -7
  18. package/src/.component/dependencies.js +7 -6
  19. package/src/.component/dereference.js +8 -7
  20. package/src/.component/expand.js +2 -15
  21. package/src/.component/extensions.js +13 -7
  22. package/src/.component/index.js +9 -21
  23. package/src/.component/merge.js +22 -9
  24. package/src/.component/normalize.js +3 -7
  25. package/src/.component/schema.yaml +81 -41
  26. package/src/.component/validate.js +15 -16
  27. package/src/.context/.dependencies/connectors.js +2 -6
  28. package/src/.context/.dependencies/describe.js +1 -5
  29. package/src/.context/.dependencies/extensions.js +11 -10
  30. package/src/.context/.dependencies/index.js +3 -9
  31. package/src/.context/.dependencies/load.js +14 -13
  32. package/src/.context/.dependencies/resolve.js +23 -6
  33. package/src/.context/complete.js +1 -5
  34. package/src/.context/dependencies.js +2 -6
  35. package/src/.context/dereference.js +1 -5
  36. package/src/.context/expand.js +2 -6
  37. package/src/.context/index.js +6 -15
  38. package/src/.context/normalize.js +2 -6
  39. package/src/.context/schema.yaml +115 -7
  40. package/src/.context/validate.js +8 -14
  41. package/src/component.js +31 -28
  42. package/src/context.js +28 -20
  43. package/src/index.js +3 -9
  44. package/src/shortcuts.js +7 -12
  45. package/test/component/collapse.fixtures.js +2 -5
  46. package/test/component/collapse.test.js +17 -10
  47. package/test/component/dependencies.test.js +12 -10
  48. package/test/component/dereference.fixtures.js +2 -7
  49. package/test/component/dereference.test.js +9 -8
  50. package/test/component/dummies/extension/index.js +1 -5
  51. package/test/component/expand.fixtures.js +13 -13
  52. package/test/component/expand.test.js +25 -10
  53. package/test/component/normalize.fixtures.js +3 -7
  54. package/test/component/normalize.test.js +27 -17
  55. package/test/component/validate.fixtures.js +1 -5
  56. package/test/component/validate.test.js +89 -90
  57. package/test/context/complete.fixtures.js +2 -8
  58. package/test/context/complete.test.js +10 -8
  59. package/test/context/dependencies.load.test.js +13 -12
  60. package/test/context/dereference.fixtures.js +3 -9
  61. package/test/context/dereference.test.js +8 -7
  62. package/test/context/expand.fixtures.js +1 -5
  63. package/test/context/expand.test.js +9 -8
  64. package/test/context/normalize.fixtures.js +2 -7
  65. package/test/context/normalize.test.js +10 -8
  66. package/test/context/validate.fixtures.js +1 -6
  67. package/test/context/validate.test.js +31 -30
  68. package/test/shortcuts.fixtures.js +4 -9
  69. package/test/shortcuts.test.js +16 -15
  70. package/types/context/declaration.d.ts +23 -2
  71. package/types/context.d.ts +2 -2
  72. package/types/index.d.ts +3 -3
@@ -1,12 +1,10 @@
1
- 'use strict'
1
+ import { load } from './load.js'
2
2
 
3
- const { load } = require('./load')
4
-
5
- const resolve = (references, annotations) => {
3
+ export const resolve = async (references, annotations) => {
6
4
  const dependencies = {}
7
5
 
8
6
  for (const [dependency, components] of Object.entries(references)) {
9
- const { metadata, module } = load(dependency)
7
+ const { metadata, module } = await load(dependency)
10
8
  const id = metadata.name
11
9
 
12
10
  const instances = components.map((component) => ({
@@ -24,7 +22,26 @@ const resolve = (references, annotations) => {
24
22
  }
25
23
  }
26
24
 
25
+ for (const dependency of Object.keys(annotations)) {
26
+ if (dependency in dependencies) continue
27
+
28
+ // an annotation may be keyed by a dependency id rather than by a module reference
29
+ const module = await optional(dependency)
30
+
31
+ if (module?.standalone === true) dependencies[dependency] = []
32
+ }
33
+
27
34
  return dependencies
28
35
  }
29
36
 
30
- exports.resolve = resolve
37
+ /**
38
+ * @param {string} reference
39
+ * @returns {object | null}
40
+ */
41
+ async function optional (reference) {
42
+ try {
43
+ return (await load(reference)).module
44
+ } catch {
45
+ return null
46
+ }
47
+ }
@@ -1,11 +1,9 @@
1
- 'use strict'
2
-
3
1
  /**
4
2
  * Completes missing compositions with unused components
5
3
  * @param {toa.norm.Context} context
6
4
  * @returns {void}
7
5
  */
8
- const complete = (context) => {
6
+ export const complete = (context) => {
9
7
  /** @type {Set<string>} */
10
8
  const composed = new Set()
11
9
 
@@ -29,5 +27,3 @@ const complete = (context) => {
29
27
  context.compositions.push({ name, components: [component] })
30
28
  }
31
29
  }
32
-
33
- exports.complete = complete
@@ -1,13 +1,9 @@
1
- 'use strict'
1
+ import { connectors, extensions, resolve } from './.dependencies/index.js'
2
2
 
3
- const { connectors, extensions, resolve } = require('./.dependencies')
4
-
5
- const dependencies = async (context) => {
3
+ export const dependencies = async (context) => {
6
4
  const { extensions: e, components } = await extensions(context)
7
5
  const c = connectors(context, components)
8
6
  const references = { ...c, ...e }
9
7
 
10
8
  return resolve(references, context.annotations)
11
9
  }
12
-
13
- exports.dependencies = dependencies
@@ -1,11 +1,9 @@
1
- 'use strict'
2
-
3
1
  /**
4
2
  * Resolves component IDs within compositions with Component objects
5
3
  * @param {toa.norm.Context} context
6
4
  * @returns {void}
7
5
  */
8
- const dereference = (context) => {
6
+ export const dereference = (context) => {
9
7
  const components = map(context.components)
10
8
 
11
9
  if (context.compositions !== undefined) {
@@ -27,5 +25,3 @@ const map = (components) => {
27
25
 
28
26
  return map
29
27
  }
30
-
31
- exports.dereference = dereference
@@ -1,13 +1,9 @@
1
- 'use strict'
2
-
3
- const shortcuts = require('../shortcuts')
1
+ import * as shortcuts from '../shortcuts.js'
4
2
 
5
3
  /**
6
4
  * @param {toa.norm.context.Declaration | object} context
7
5
  */
8
- const expand = (context) => {
6
+ export const expand = (context) => {
9
7
  shortcuts.recognize(shortcuts.SHORTCUTS, context, 'annotations')
10
8
  shortcuts.recognize(shortcuts.SHORTCUTS, context.annotations)
11
9
  }
12
-
13
- exports.expand = expand
@@ -1,15 +1,6 @@
1
- 'use strict'
2
-
3
- const { complete } = require('./complete')
4
- const { dependencies } = require('./dependencies')
5
- const { dereference } = require('./dereference')
6
- const { expand } = require('./expand')
7
- const { normalize } = require('./normalize')
8
- const { validate } = require('./validate')
9
-
10
- exports.complete = complete
11
- exports.dependencies = dependencies
12
- exports.dereference = dereference
13
- exports.expand = expand
14
- exports.normalize = normalize
15
- exports.validate = validate
1
+ export { complete } from './complete.js'
2
+ export { dependencies } from './dependencies.js'
3
+ export { dereference } from './dereference.js'
4
+ export { expand } from './expand.js'
5
+ export { normalize } from './normalize.js'
6
+ export { validate } from './validate.js'
@@ -1,11 +1,9 @@
1
- 'use strict'
1
+ import * as runtime from '@toa.io/runtime'
2
2
 
3
3
  /**
4
4
  * @param {toa.norm.context.Declaration | Object} context
5
5
  */
6
- const normalize = (context) => {
7
- const runtime = require('@toa.io/runtime')
8
-
6
+ export const normalize = (context) => {
9
7
  if (context.runtime === undefined) context.runtime = { version: runtime.version }
10
8
  if (typeof context.runtime === 'string') context.runtime = { version: context.runtime }
11
9
 
@@ -15,5 +13,3 @@ const normalize = (context) => {
15
13
 
16
14
  if (typeof context.registry === 'string') context.registry = { base: context.registry }
17
15
  }
18
-
19
- exports.normalize = normalize
@@ -6,12 +6,10 @@ properties:
6
6
  version:
7
7
  type: string
8
8
  name:
9
- $ref: 'definitions#/definitions/label'
10
- description:
11
9
  type: string
12
- packages:
10
+ pattern: ^([a-zA-Z]+([_a-zA-Z0-9]*[a-zA-Z0-9]+)?)(-([a-zA-Z]+([_a-zA-Z0-9]*[a-zA-Z0-9]+)?))*$
11
+ description:
13
12
  type: string
14
- default: components/*
15
13
  build:
16
14
  type: object
17
15
  properties:
@@ -46,7 +44,7 @@ properties:
46
44
  - linux/amd64
47
45
  - linux/arm/v7
48
46
  - linux/arm64
49
- required: [base, platforms]
47
+ # required: [base]
50
48
  compositions:
51
49
  type: array
52
50
  minItems: 1
@@ -54,16 +52,126 @@ properties:
54
52
  type: object
55
53
  properties:
56
54
  name:
57
- $ref: 'definitions#/definitions/token'
55
+ type: string
56
+ pattern: ^[a-zA-Z]([a-zA-Z0-9]{1,31})?$
58
57
  image:
59
58
  type: string
60
59
  components:
61
60
  type: array
62
61
  minItems: 1
63
62
  items:
64
- $ref: 'definitions#/definitions/locator'
63
+ type: string
64
+ pattern: ^([a-zA-Z]+([_a-zA-Z0-9]*[a-zA-Z0-9]+)?)(\.([a-zA-Z]+([_a-zA-Z0-9]*[a-zA-Z0-9]+)?))$
65
+ resources:
66
+ $ref: '#/definitions/resources'
65
67
  required: [name, components]
68
+ atomicity:
69
+ description: >
70
+ Where the replicas of a component decide together: who owns what, what they have spent
71
+ between them, and which of them holds a name while it works. Absent or unreachable,
72
+ nothing is owned and whoever asked stands down; metering and locking are refused.
73
+ type: object
74
+ additionalProperties: false
75
+ properties:
76
+ redis:
77
+ description: >
78
+ One address, or an odd number of them — independent servers, not the nodes of a
79
+ cluster. A lock is taken on a quorum of them; the registry and the meter use the
80
+ first, because each of them counts on a single key.
81
+ oneOf:
82
+ - type: string
83
+ - type: array
84
+ minItems: 1
85
+ items:
86
+ type: string
87
+ interval:
88
+ description: >
89
+ How often a replica registers, in milliseconds. It has to comfortably exceed a round
90
+ trip to Redis and the jitter around it, and nothing is owned until two consecutive
91
+ intervals have agreed — so this is also how long a replica owns nothing after it
92
+ joins, restarts or stalls.
93
+ type: integer
94
+ minimum: 100
95
+ required: [redis]
96
+ outbox:
97
+ type: object
98
+ additionalProperties: false
99
+ properties:
100
+ interval:
101
+ description: >
102
+ The pump's cycle, in milliseconds. One cycle reads what is unpublished, publishes it
103
+ and marks it. In steady state it reads nothing, so this is budgeted for how fast a rare
104
+ failure heals rather than for how fast events flow.
105
+ type: integer
106
+ minimum: 100
107
+ batch:
108
+ description: >
109
+ How many rows one read brings back. A page that comes back full is read on from,
110
+ so this bounds a read rather than a cycle.
111
+ type: integer
112
+ minimum: 1
113
+ retention:
114
+ description: >
115
+ Seconds a published row is kept as a change log before it expires. A row that never
116
+ made it out has no expiry and is never reaped.
117
+ type: integer
118
+ minimum: 0
119
+ events:
120
+ description: >
121
+ Events of this context that are consumed outside it. An event is otherwise published only
122
+ where something in the context receives it.
123
+ type: array
124
+ items:
125
+ type: string
126
+ pattern: ^[a-zA-Z][a-zA-Z0-9]*\.[a-zA-Z][a-zA-Z0-9]*\.[a-zA-Z][a-zA-Z0-9]*$
127
+ mono:
128
+ type: object
129
+ additionalProperties: false
130
+ properties:
131
+ replicas:
132
+ type: integer
133
+ minimum: 1
134
+ resources:
135
+ $ref: '#/definitions/resources'
136
+ ingress:
137
+ type: object
138
+ additionalProperties: false
139
+ properties:
140
+ hosts:
141
+ type: array
142
+ minItems: 1
143
+ items:
144
+ type: string
145
+ class:
146
+ type: string
147
+ annotations:
148
+ type: object
149
+ default:
150
+ type: boolean
66
151
  annotations:
67
152
  type: object
153
+ resources:
154
+ $ref: '#/definitions/resources'
68
155
  required: [runtime, name, registry]
69
156
  additionalProperties: false
157
+
158
+ definitions:
159
+ # What a deployment may take. `null` deploys it without any, which is a decision
160
+ # rather than an omission — every deployment has to make one.
161
+ resources:
162
+ type: object
163
+ nullable: true
164
+ additionalProperties: false
165
+ properties:
166
+ cpu:
167
+ type: array
168
+ items:
169
+ type: string
170
+ minItems: 2
171
+ maxItems: 2
172
+ memory:
173
+ type: array
174
+ items:
175
+ type: string
176
+ minItems: 2
177
+ maxItems: 2
@@ -1,19 +1,13 @@
1
- 'use strict'
1
+ import { resolve } from 'node:path'
2
2
 
3
- const { resolve } = require('node:path')
3
+ import { readFileSync } from 'node:fs'
4
+ import { yaml } from '@toa.io/generic'
5
+ import * as schemas from '@toa.io/schemas'
4
6
 
5
- const { load } = require('@toa.io/yaml')
6
- const { Schema } = require('@toa.io/schema')
7
+ const path = resolve(import.meta.dirname, 'schema.yaml')
8
+ const object = yaml.load(readFileSync(path, 'utf8'))
9
+ const schema = schemas.schema(object)
7
10
 
8
- const path = resolve(__dirname, 'schema.yaml')
9
- const object = load.sync(path)
10
- const schema = new Schema(object)
11
-
12
- /**
13
- * @param {toa.norm.context.Declaration} context
14
- */
15
- const validate = (context) => {
11
+ export const validate = (context) => {
16
12
  schema.validate(context)
17
13
  }
18
-
19
- exports.validate = validate
package/src/component.js CHANGED
@@ -1,49 +1,39 @@
1
- 'use strict'
2
-
3
- const { join } = require('node:path')
4
-
5
- const { load: yaml } = require('@toa.io/yaml')
6
- const { directory: { find } } = require('@toa.io/filesystem')
7
- const { Locator } = require('@toa.io/core')
8
-
9
- const {
10
- expand,
11
- merge,
12
- validate,
13
- collapse,
14
- dereference,
15
- defaults,
16
- normalize,
17
- extensions
18
- } = require('./.component')
19
-
20
- const component = async (path) => {
1
+ import { join } from 'node:path'
2
+
3
+ import { readFile } from 'node:fs/promises'
4
+ import { yaml as jsyaml } from '@toa.io/generic'
5
+ import { find } from '@toa.io/generic'
6
+ import { Locator } from '@toa.io/core'
7
+
8
+ import { expand, merge, validate, collapse, dereference, defaults, normalize, extensions } from './.component/index.js'
9
+
10
+ export const component = async (path) => {
21
11
  const manifest = await load(path)
22
12
 
23
- normalize(manifest)
24
- validate(manifest)
25
- extensions(manifest)
13
+ await normalize(manifest, path)
14
+ await validate(manifest)
15
+ await extensions(manifest)
26
16
 
27
17
  manifest.locator = new Locator(manifest.name, manifest.namespace)
28
18
 
29
19
  return manifest
30
20
  }
31
21
 
32
- const load = async (path, base) => {
22
+ const load = async (path, base, proto = false) => {
33
23
  if (base !== undefined) path = find(path, base, MANIFEST)
34
24
 
35
25
  const file = join(path, MANIFEST)
36
- const manifest = /** @type {toa.norm.Component} */ await yaml(file) ?? {}
26
+ const manifest = await read(file) ?? {}
37
27
 
38
28
  manifest.path = path
39
29
 
40
- defaults(manifest)
30
+ defaults(manifest, proto)
41
31
  await expand(manifest)
42
32
 
43
33
  await merge(path, manifest)
44
34
 
45
35
  if (manifest.prototype !== null) {
46
- const prototype = await load(manifest.prototype, path)
36
+ const prototype = await load(manifest.prototype, path, true)
47
37
 
48
38
  collapse(manifest, prototype)
49
39
  }
@@ -56,4 +46,17 @@ const load = async (path, base) => {
56
46
 
57
47
  const MANIFEST = 'manifest.toa.yaml'
58
48
 
59
- exports.component = component
49
+
50
+
51
+ /**
52
+ * Reads a YAML file, resolving anchors into distinct objects so that
53
+ * mutating one node cannot reach another.
54
+ *
55
+ * @param {string} path
56
+ * @return {Promise<object>}
57
+ */
58
+ async function read (path) {
59
+ const object = jsyaml.load(await readFile(path, 'utf8'))
60
+
61
+ return jsyaml.load(jsyaml.dump(object, { noRefs: true, lineWidth: -1 }))
62
+ }
package/src/context.js CHANGED
@@ -1,25 +1,16 @@
1
- 'use strict'
1
+ import { resolve } from 'node:path'
2
+ import { convolve } from '@toa.io/generic'
3
+ import glob from 'fast-glob'
4
+ import { readFile } from 'node:fs/promises'
5
+ import { yaml as jsyaml } from '@toa.io/generic'
2
6
 
3
- const { resolve } = require('node:path')
4
- const { convolve } = require('@toa.io/generic')
5
- const { directory: { glob } } = require('@toa.io/filesystem')
6
- const { load } = require('@toa.io/yaml')
7
+ import { component } from './component.js'
7
8
 
8
- const { component } = require('./component')
9
+ import { dependencies, normalize, complete, dereference, expand, validate } from './.context/index.js'
9
10
 
10
- const {
11
- dependencies,
12
- normalize,
13
- complete,
14
- dereference,
15
- expand,
16
- validate
17
- } = require('./.context')
18
-
19
- const context = async (root, environment = process.env.TOA_ENV) => {
11
+ export const context = async (root, environment = process.env.TOA_ENV) => {
20
12
  const path = resolve(root, CONTEXT)
21
- const context = /** @type {toa.norm.Context} */ await load(path)
22
- const pattern = resolve(root, context.packages)
13
+ const context = /** @type {toa.norm.Context} */ await read(path)
23
14
 
24
15
  context.environment = environment
25
16
 
@@ -29,7 +20,7 @@ const context = async (root, environment = process.env.TOA_ENV) => {
29
20
 
30
21
  validate(context)
31
22
 
32
- const paths = await glob(pattern)
23
+ const paths = await glob(resolve(root, COMPONENTS), GLOB)
33
24
 
34
25
  context.components = await Promise.all(paths.map(component))
35
26
  context.dependencies = await dependencies(context)
@@ -41,5 +32,22 @@ const context = async (root, environment = process.env.TOA_ENV) => {
41
32
  }
42
33
 
43
34
  const CONTEXT = 'context.toa.yaml'
35
+ const COMPONENTS = 'components/*'
36
+
37
+
38
+ const GLOB = { onlyDirectories: true, absolute: true }
39
+
44
40
 
45
- exports.context = context
41
+
42
+ /**
43
+ * Reads a YAML file, resolving anchors into distinct objects so that
44
+ * mutating one node cannot reach another.
45
+ *
46
+ * @param {string} path
47
+ * @return {Promise<object>}
48
+ */
49
+ async function read (path) {
50
+ const object = jsyaml.load(await readFile(path, 'utf8'))
51
+
52
+ return jsyaml.load(jsyaml.dump(object, { noRefs: true, lineWidth: -1 }))
53
+ }
package/src/index.js CHANGED
@@ -1,9 +1,3 @@
1
- 'use strict'
2
-
3
- const { context } = require('./context')
4
- const { component } = require('./component')
5
-
6
- exports.shortcuts = require('./shortcuts')
7
-
8
- exports.context = context
9
- exports.component = component
1
+ export { context } from './context.js'
2
+ export { component } from './component.js'
3
+ export * as shortcuts from './shortcuts.js'
package/src/shortcuts.js CHANGED
@@ -1,6 +1,4 @@
1
- 'use strict'
2
-
3
- const { empty, merge } = require('@toa.io/generic')
1
+ import { empty, merge } from '@toa.io/generic'
4
2
 
5
3
  /**
6
4
  * Resolves shortcuts
@@ -8,7 +6,7 @@ const { empty, merge } = require('@toa.io/generic')
8
6
  * @param {string} token
9
7
  * @returns {string}
10
8
  */
11
- const resolve = (token) => {
9
+ export const resolve = (token) => {
12
10
  if (token in SHORTCUTS) return SHORTCUTS[token]
13
11
  else return token
14
12
  }
@@ -20,7 +18,7 @@ const resolve = (token) => {
20
18
  * @param {Object} object
21
19
  * @param {string} [group]
22
20
  */
23
- const recognize = (shortcuts, object, group) => {
21
+ export const recognize = (shortcuts, object, group) => {
24
22
  if (object === undefined) return
25
23
 
26
24
  const target = group === undefined ? object : {}
@@ -38,7 +36,7 @@ const recognize = (shortcuts, object, group) => {
38
36
  if (group !== undefined && !empty(target)) object[group] = merge(object[group], target)
39
37
  }
40
38
 
41
- const SHORTCUTS = {
39
+ export const SHORTCUTS = {
42
40
  amqp: '@toa.io/bindings.amqp',
43
41
  node: '@toa.io/bridges.node',
44
42
  bash: '@toa.io/bridges.bash',
@@ -48,11 +46,8 @@ const SHORTCUTS = {
48
46
  exposition: '@toa.io/extensions.exposition',
49
47
  realtime: '@toa.io/extensions.realtime',
50
48
  configuration: '@toa.io/extensions.configuration',
51
- origins: '@toa.io/extensions.origins',
52
49
  stash: '@toa.io/extensions.stash',
53
- storages: '@toa.io/extensions.storages'
50
+ storages: '@toa.io/extensions.storages',
51
+ telemetry: '@toa.io/extensions.telemetry',
52
+ introspection: '@toa.io/extensions.introspection'
54
53
  }
55
-
56
- exports.recognize = recognize
57
- exports.resolve = resolve
58
- exports.SHORTCUTS = SHORTCUTS
@@ -1,6 +1,4 @@
1
- 'use strict'
2
-
3
- const { generate } = require('randomstring')
1
+ import { generate } from 'randomstring'
4
2
 
5
3
  const entity = {
6
4
  manifest: {
@@ -88,7 +86,6 @@ const operations = {
88
86
  result: {
89
87
  prototype: {
90
88
  prototype: null,
91
- path: expect.any(String),
92
89
  operations: {
93
90
  add: {
94
91
  bridge: 'a'
@@ -131,4 +128,4 @@ const remotes = {
131
128
  }
132
129
  }
133
130
 
134
- exports.samples = { entity, operations, remotes }
131
+ export const samples = { entity, operations, remotes }
@@ -1,9 +1,10 @@
1
- 'use strict'
1
+ import { describe, it, beforeEach } from 'node:test'
2
+ import assert from 'node:assert/strict'
2
3
 
3
- const clone = require('clone-deep')
4
+ import clone from 'clone-deep'
4
5
 
5
- const fixtures = require('./collapse.fixtures')
6
- const { collapse } = require('../../src/.component')
6
+ import * as fixtures from './collapse.fixtures.js'
7
+ import { collapse } from '../../src/.component/index.js'
7
8
 
8
9
  let samples
9
10
 
@@ -18,7 +19,7 @@ it('should ignore locator', () => {
18
19
 
19
20
  collapse(manifest, prototype)
20
21
 
21
- expect(manifest).toStrictEqual(source)
22
+ assert.deepStrictEqual(manifest, source)
22
23
  })
23
24
 
24
25
  it('should remove prototype property', () => {
@@ -26,7 +27,7 @@ it('should remove prototype property', () => {
26
27
 
27
28
  collapse(manifest, {})
28
29
 
29
- expect(manifest).toStrictEqual({})
30
+ assert.deepStrictEqual(manifest, {})
30
31
  })
31
32
 
32
33
  describe('entity', () => {
@@ -34,7 +35,7 @@ describe('entity', () => {
34
35
  const manifest = clone(samples.entity.manifest)
35
36
 
36
37
  collapse(manifest, samples.entity.prototype)
37
- expect(manifest).toStrictEqual(samples.entity.result)
38
+ assert.deepStrictEqual(manifest, samples.entity.result)
38
39
  })
39
40
  })
40
41
 
@@ -44,12 +45,12 @@ it('should ignore bindings', () => {
44
45
  const manifest = clone(source)
45
46
 
46
47
  collapse(manifest, prototype)
47
- expect(manifest).toStrictEqual(source)
48
+ assert.deepStrictEqual(manifest, source)
48
49
 
49
50
  delete manifest.bindings
50
51
 
51
52
  collapse(manifest, prototype)
52
- expect(manifest).toStrictEqual({})
53
+ assert.deepStrictEqual(manifest, {})
53
54
  })
54
55
 
55
56
  it('should merge operations', () => {
@@ -57,5 +58,11 @@ it('should merge operations', () => {
57
58
  const prototype = clone(samples.operations.prototype)
58
59
 
59
60
  collapse(manifest, prototype, '/somewhere')
60
- expect(manifest).toStrictEqual(samples.operations.result)
61
+
62
+ // the prototype's path is generated, so it is checked apart from the shape
63
+ assert.strictEqual(typeof manifest.prototype.path, 'string')
64
+
65
+ const { path, ...rest } = manifest.prototype
66
+
67
+ assert.deepStrictEqual({ ...manifest, prototype: rest }, samples.operations.result)
61
68
  })