@open-mercato/shared 0.4.11-develop.1537.8724d715df → 0.4.11-develop.1557.23456abf54
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/dist/lib/version.js
CHANGED
package/dist/lib/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/version.ts"],
|
|
4
|
-
"sourcesContent": ["// Build-time generated version\nexport const APP_VERSION = '0.4.11-develop.
|
|
4
|
+
"sourcesContent": ["// Build-time generated version\nexport const APP_VERSION = '0.4.11-develop.1557.23456abf54'\nexport const appVersion = APP_VERSION\n"],
|
|
5
5
|
"mappings": "AACO,MAAM,cAAc;AACpB,MAAM,aAAa;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractFeatureStrings,
|
|
3
|
+
featureScope,
|
|
4
|
+
featureString,
|
|
5
|
+
hasAllFeatures,
|
|
6
|
+
matchFeature,
|
|
7
|
+
} from '../featureMatch'
|
|
8
|
+
|
|
9
|
+
describe('featureString', () => {
|
|
10
|
+
it('returns raw string entries unchanged', () => {
|
|
11
|
+
expect(featureString('catalog.view')).toBe('catalog.view')
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('reads the id from structured feature entries', () => {
|
|
15
|
+
expect(featureString({ id: 'catalog.edit', title: 'Edit catalog' })).toBe('catalog.edit')
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
describe('featureScope', () => {
|
|
20
|
+
it('returns the whole feature id when there is no nested segment', () => {
|
|
21
|
+
expect(featureScope('catalog')).toBe('catalog')
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('returns the top-level scope for nested feature ids', () => {
|
|
25
|
+
expect(featureScope('catalog.products.edit')).toBe('catalog')
|
|
26
|
+
expect(featureScope('catalog.*')).toBe('catalog')
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
describe('extractFeatureStrings', () => {
|
|
31
|
+
it('normalizes mixed feature entry arrays into string ids', () => {
|
|
32
|
+
expect(
|
|
33
|
+
extractFeatureStrings([
|
|
34
|
+
'catalog.view',
|
|
35
|
+
{ id: 'sales.edit', module: 'sales', title: 'Edit sales' },
|
|
36
|
+
]),
|
|
37
|
+
).toEqual(['catalog.view', 'sales.edit'])
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
describe('matchFeature', () => {
|
|
42
|
+
it('matches exact feature ids', () => {
|
|
43
|
+
expect(matchFeature('catalog.view', 'catalog.view')).toBe(true)
|
|
44
|
+
expect(matchFeature('catalog.view', 'catalog.edit')).toBe(false)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('accepts the global wildcard grant', () => {
|
|
48
|
+
expect(matchFeature('catalog.view', '*')).toBe(true)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('matches module wildcards against nested features and the bare prefix', () => {
|
|
52
|
+
expect(matchFeature('catalog.products.edit', 'catalog.*')).toBe(true)
|
|
53
|
+
expect(matchFeature('catalog', 'catalog.*')).toBe(true)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('does not treat partial prefixes as module matches', () => {
|
|
57
|
+
expect(matchFeature('cataloging.view', 'catalog.*')).toBe(false)
|
|
58
|
+
expect(matchFeature('sales.view', 'catalog.*')).toBe(false)
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
describe('hasAllFeatures', () => {
|
|
63
|
+
it('returns true when no features are required', () => {
|
|
64
|
+
expect(hasAllFeatures([], ['catalog.*'])).toBe(true)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('returns false when features are required but none are granted', () => {
|
|
68
|
+
expect(hasAllFeatures(['catalog.view'], [])).toBe(false)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('returns true when every required feature is satisfied', () => {
|
|
72
|
+
expect(hasAllFeatures(['catalog.view', 'sales.edit'], ['catalog.*', 'sales.edit'])).toBe(true)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('returns false when any required feature is missing', () => {
|
|
76
|
+
expect(hasAllFeatures(['catalog.view', 'sales.edit'], ['catalog.*'])).toBe(false)
|
|
77
|
+
})
|
|
78
|
+
})
|