@swagger-api/apidom-core 0.99.1 → 1.0.0-alpha.0
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/CHANGELOG.md +14 -0
- package/cjs/identity/index.cjs +35 -44
- package/cjs/refractor/plugins/element-identity.cjs +1 -1
- package/cjs/refractor/plugins/semantic-element-identity.cjs +1 -1
- package/dist/apidom-core.browser.js +3005 -3453
- package/dist/apidom-core.browser.min.js +1 -1
- package/es/identity/index.mjs +34 -44
- package/es/refractor/plugins/element-identity.mjs +1 -1
- package/es/refractor/plugins/semantic-element-identity.mjs +1 -1
- package/package.json +7 -7
- package/types/dist.d.ts +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.0.0-alpha.0](https://github.com/swagger-api/apidom/compare/v0.99.2...v1.0.0-alpha.0) (2024-05-14)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **core:** change from stamps to TypeScript classes ([#4095](https://github.com/swagger-api/apidom/issues/4095)) ([3bb7131](https://github.com/swagger-api/apidom/commit/3bb71317420583b0b5e56ca9a6e55bbca9596bfc)), closes [#3481](https://github.com/swagger-api/apidom/issues/3481)
|
|
11
|
+
|
|
12
|
+
### BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
- **core:** IdentityManager from apidom-core package became a class and requires to be instantiated with new operator.
|
|
15
|
+
|
|
16
|
+
## [0.99.2](https://github.com/swagger-api/apidom/compare/v0.99.1...v0.99.2) (2024-04-30)
|
|
17
|
+
|
|
18
|
+
**Note:** Version bump only for package @swagger-api/apidom-core
|
|
19
|
+
|
|
6
20
|
## [0.99.1](https://github.com/swagger-api/apidom/compare/v0.99.0...v0.99.1) (2024-04-05)
|
|
7
21
|
|
|
8
22
|
**Note:** Version bump only for package @swagger-api/apidom-core
|
package/cjs/identity/index.cjs
CHANGED
|
@@ -4,61 +4,52 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.defaultIdentityManager = exports.IdentityManager = void 0;
|
|
6
6
|
var _minim = require("minim");
|
|
7
|
-
var _stampit = _interopRequireDefault(require("stampit"));
|
|
8
7
|
var _shortUniqueId = _interopRequireDefault(require("short-unique-id"));
|
|
9
8
|
var _ElementIdentityError = _interopRequireDefault(require("./errors/ElementIdentityError.cjs"));
|
|
10
9
|
var _index = require("../predicates/index.cjs");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
length: null,
|
|
16
|
-
identityMap: null
|
|
17
|
-
},
|
|
18
|
-
init({
|
|
10
|
+
class IdentityManager {
|
|
11
|
+
uuid;
|
|
12
|
+
identityMap;
|
|
13
|
+
constructor({
|
|
19
14
|
length = 6
|
|
20
15
|
} = {}) {
|
|
21
|
-
this.length = 6;
|
|
22
16
|
this.uuid = new _shortUniqueId.default({
|
|
23
17
|
length
|
|
24
18
|
});
|
|
25
19
|
this.identityMap = new WeakMap();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
20
|
+
}
|
|
21
|
+
identify(element) {
|
|
22
|
+
if (!(0, _index.isElement)(element)) {
|
|
23
|
+
throw new _ElementIdentityError.default('Cannot not identify the element. `element` is neither structurally compatible nor a subclass of an Element class.', {
|
|
24
|
+
value: element
|
|
25
|
+
});
|
|
26
|
+
}
|
|
34
27
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
// use already assigned identity
|
|
29
|
+
if (element.meta.hasKey('id') && (0, _index.isStringElement)(element.meta.get('id')) && !element.meta.get('id').equals('')) {
|
|
30
|
+
return element.id;
|
|
31
|
+
}
|
|
39
32
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
// assign identity in immutable way
|
|
34
|
+
if (this.identityMap.has(element)) {
|
|
35
|
+
return this.identityMap.get(element);
|
|
36
|
+
}
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
},
|
|
57
|
-
generateId() {
|
|
58
|
-
return this.uuid.randomUUID();
|
|
38
|
+
// return element identity
|
|
39
|
+
const id = new _minim.StringElement(this.generateId());
|
|
40
|
+
this.identityMap.set(element, id);
|
|
41
|
+
return id;
|
|
42
|
+
}
|
|
43
|
+
forget(element) {
|
|
44
|
+
if (this.identityMap.has(element)) {
|
|
45
|
+
this.identityMap.delete(element);
|
|
46
|
+
return true;
|
|
59
47
|
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
generateId() {
|
|
51
|
+
return this.uuid.randomUUID();
|
|
60
52
|
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
53
|
+
}
|
|
54
|
+
exports.IdentityManager = IdentityManager;
|
|
55
|
+
const defaultIdentityManager = exports.defaultIdentityManager = new IdentityManager();
|