oca_package 1.0.7 → 1.1.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/dist/cjs/index.js +1 -4
- package/dist/cjs/oca_extensions/extensions.js +114 -53
- package/dist/cjs/oca_extensions/state/attribute.js +0 -1
- package/dist/cjs/oca_extensions/state/overlays/framing/attribute_framing.js +47 -0
- package/dist/cjs/oca_extensions/state/overlays/framing/entry_code_framing.js +1 -0
- package/dist/cjs/oca_extensions/state/overlays/framing/unit_framing.js +47 -0
- package/dist/cjs/oca_extensions/state/overlays/ordering.js +13 -18
- package/dist/cjs/oca_extensions/state/overlays/separator.js +0 -1
- package/dist/cjs/oca_package.js +9 -12
- package/dist/cjs/types/types.js +0 -1
- package/dist/cjs/utils/helpers.js +44 -8
- package/dist/esm/index.js +0 -2
- package/dist/esm/oca_extensions/extensions.js +111 -52
- package/dist/esm/oca_extensions/state/attribute.js +0 -1
- package/dist/esm/oca_extensions/state/overlays/framing/attribute_framing.js +45 -0
- package/dist/esm/oca_extensions/state/overlays/framing/entry_code_framing.js +1 -0
- package/dist/esm/oca_extensions/state/overlays/framing/unit_framing.js +45 -0
- package/dist/esm/oca_extensions/state/overlays/ordering.js +13 -18
- package/dist/esm/oca_extensions/state/overlays/separator.js +0 -1
- package/dist/esm/oca_package.js +9 -12
- package/dist/esm/types/types.js +0 -1
- package/dist/esm/utils/helpers.js +40 -7
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/oca_extensions/extensions.d.ts +47 -28
- package/dist/types/oca_extensions/extensions.d.ts.map +1 -1
- package/dist/types/oca_extensions/state/overlays/framing/attribute_framing.d.ts +19 -0
- package/dist/types/oca_extensions/state/overlays/framing/attribute_framing.d.ts.map +1 -0
- package/dist/types/oca_extensions/state/overlays/framing/entry_code_framing.d.ts +1 -0
- package/dist/types/oca_extensions/state/overlays/framing/entry_code_framing.d.ts.map +1 -0
- package/dist/types/oca_extensions/state/overlays/framing/unit_framing.d.ts +19 -0
- package/dist/types/oca_extensions/state/overlays/framing/unit_framing.d.ts.map +1 -0
- package/dist/types/oca_extensions/state/overlays/ordering.d.ts +9 -10
- package/dist/types/oca_extensions/state/overlays/ordering.d.ts.map +1 -1
- package/dist/types/oca_package.d.ts +9 -8
- package/dist/types/oca_package.d.ts.map +1 -1
- package/dist/types/utils/helpers.d.ts +3 -0
- package/dist/types/utils/helpers.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/oca_extensions/extensions.js.map +0 -1
- package/dist/cjs/oca_extensions/state/attribute.js.map +0 -1
- package/dist/cjs/oca_extensions/state/extenstionContainer.js +0 -29
- package/dist/cjs/oca_extensions/state/extenstionContainer.js.map +0 -1
- package/dist/cjs/oca_extensions/state/overlays/ordering.js.map +0 -1
- package/dist/cjs/oca_extensions/state/overlays/separator.js.map +0 -1
- package/dist/cjs/oca_package.js.map +0 -1
- package/dist/cjs/types/types.js.map +0 -1
- package/dist/cjs/utils/helpers.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/oca_extensions/extensions.js.map +0 -1
- package/dist/esm/oca_extensions/state/attribute.js.map +0 -1
- package/dist/esm/oca_extensions/state/extenstionContainer.js +0 -24
- package/dist/esm/oca_extensions/state/extenstionContainer.js.map +0 -1
- package/dist/esm/oca_extensions/state/overlays/ordering.js.map +0 -1
- package/dist/esm/oca_extensions/state/overlays/separator.js.map +0 -1
- package/dist/esm/oca_package.js.map +0 -1
- package/dist/esm/types/types.js.map +0 -1
- package/dist/esm/utils/helpers.js.map +0 -1
- package/dist/types/oca_extensions/state/extenstionContainer.d.ts +0 -11
- package/dist/types/oca_extensions/state/extenstionContainer.d.ts.map +0 -1
|
@@ -1,77 +1,136 @@
|
|
|
1
|
-
import { ocabundleDigest } from '../utils/helpers.js';
|
|
2
1
|
import Ordering from './state/overlays/ordering.js';
|
|
2
|
+
import UnitFraming from './state/overlays/framing/unit_framing.js';
|
|
3
|
+
import { ocabundleDigest, getOcaBundleFromDeps, getDigest, isOcaBundleWithDeps } from '../utils/helpers.js';
|
|
3
4
|
import { saidify } from 'saidify';
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
const ADC_COMMUNITY = 'adc';
|
|
6
|
+
const v = '1.0';
|
|
6
7
|
export class ExtensionState {
|
|
7
|
-
constructor(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
this._attributes_ordering_arr = this.extractAttributeOrdering(extension_obj);
|
|
12
|
-
this._entry_code_ordering_arr = this.extractEntryCodeOrdering(extension_obj);
|
|
8
|
+
constructor(ExtensionInputJson) {
|
|
9
|
+
this._extension_input_json = ExtensionInputJson;
|
|
10
|
+
this._extensionState = this.BuildExtensionState();
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
BuildExtensionState() {
|
|
13
|
+
let state = {};
|
|
14
|
+
for (const community in this._extension_input_json.extensions) {
|
|
15
|
+
const community_extensions = this._extension_input_json.extensions[community];
|
|
16
|
+
state[community] = {};
|
|
17
|
+
for (const bundle_digest in community_extensions) {
|
|
18
|
+
state[community][bundle_digest] = community_extensions[bundle_digest];
|
|
19
|
+
}
|
|
20
20
|
}
|
|
21
|
+
return state;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
get attribute_ordering_arr() {
|
|
26
|
-
return this._attributes_ordering_arr;
|
|
27
|
-
}
|
|
28
|
-
get entry_code_ordering_arr() {
|
|
29
|
-
return this._entry_code_ordering_arr;
|
|
23
|
+
// TODO: list the overlays
|
|
24
|
+
get communities() {
|
|
25
|
+
return this._extensionState;
|
|
30
26
|
}
|
|
31
27
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
export class Overlay {
|
|
29
|
+
constructor(community_overlay) {
|
|
30
|
+
this._overlay = community_overlay;
|
|
31
|
+
}
|
|
32
|
+
GenerateOverlay() {
|
|
33
|
+
const overlay = {};
|
|
34
|
+
for (const ov_type in this._overlay) {
|
|
35
|
+
if (ov_type === 'ordering_overlay') {
|
|
36
|
+
const ordering_instance = new Ordering(this._overlay);
|
|
37
|
+
const ordering_ov = ordering_instance.GenerateOverlay();
|
|
38
|
+
overlay['ordering'] = JSON.parse(ordering_ov);
|
|
39
|
+
}
|
|
40
|
+
else if (ov_type === 'unit_framing_overlay') {
|
|
41
|
+
const unit_framing_instance = new UnitFraming(this._overlay);
|
|
42
|
+
const unit_framing_ov = unit_framing_instance.GenerateOverlay();
|
|
43
|
+
overlay['unit_framing'] = JSON.parse(unit_framing_ov);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw new Error('Invalid overlay name');
|
|
47
|
+
}
|
|
41
48
|
}
|
|
42
|
-
|
|
43
|
-
this.oca_bundle = oca_bundle;
|
|
44
|
-
this.overlays = this.generateOverlays();
|
|
49
|
+
return overlay;
|
|
45
50
|
}
|
|
46
|
-
|
|
51
|
+
}
|
|
52
|
+
class ADCOverlayStrategy {
|
|
53
|
+
GenerateOverlay(extensions) {
|
|
47
54
|
const overlays = {};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
for (const extKey in extensions) {
|
|
56
|
+
const ext = extensions[extKey];
|
|
57
|
+
const overlay_instance = new Overlay(ext);
|
|
58
|
+
const generated_overlay = overlay_instance.GenerateOverlay();
|
|
59
|
+
for (const overlay_type in generated_overlay) {
|
|
60
|
+
overlays[overlay_type] = generated_overlay[overlay_type];
|
|
52
61
|
}
|
|
53
62
|
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
console.error('Error generating overlays:', error);
|
|
56
|
-
}
|
|
57
63
|
return overlays;
|
|
58
64
|
}
|
|
65
|
+
}
|
|
66
|
+
// To implement overlays for external communities, create a new class that implements the OverlayStrategy interface.
|
|
67
|
+
// For example, if you have a community called "external_community", you can create a class like this:
|
|
68
|
+
class DefaultOverlayStrategy {
|
|
69
|
+
GenerateOverlay(extensions) {
|
|
70
|
+
throw new Error('Unsupported community type');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export class Extension {
|
|
74
|
+
constructor(_extensions_input, community) {
|
|
75
|
+
this.d = '';
|
|
76
|
+
this.overlays = {};
|
|
77
|
+
if (!_extensions_input || !community) {
|
|
78
|
+
throw new Error('extension array is required from extension state and community is required');
|
|
79
|
+
}
|
|
80
|
+
this._community = community;
|
|
81
|
+
this._exensions = _extensions_input;
|
|
82
|
+
this.type = `community/${this._community}/extension/${v}`;
|
|
83
|
+
}
|
|
84
|
+
GenerateOverlays() {
|
|
85
|
+
const strategy = this._community === ADC_COMMUNITY ? new ADCOverlayStrategy() : new DefaultOverlayStrategy();
|
|
86
|
+
return strategy.GenerateOverlay(this._exensions);
|
|
87
|
+
}
|
|
59
88
|
toJSON() {
|
|
60
|
-
const oca_bundle_digest = ocabundleDigest(this.oca_bundle);
|
|
61
89
|
return {
|
|
62
90
|
d: '',
|
|
63
|
-
type:
|
|
64
|
-
|
|
65
|
-
overlays: this.overlays,
|
|
91
|
+
type: `community/${this._community}/extension/1.0`,
|
|
92
|
+
overlays: this.GenerateOverlays(),
|
|
66
93
|
};
|
|
67
94
|
}
|
|
68
|
-
|
|
95
|
+
Saidifying() {
|
|
69
96
|
const [, sad] = saidify(this.toJSON());
|
|
70
97
|
return sad;
|
|
71
98
|
}
|
|
72
|
-
|
|
73
|
-
return
|
|
99
|
+
GenerateExtension() {
|
|
100
|
+
return this.Saidifying();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
class ExtensionBox {
|
|
104
|
+
constructor(extension_input_json, oca_bundle) {
|
|
105
|
+
this._extensions_box = {};
|
|
106
|
+
this._oca_bundle = oca_bundle;
|
|
107
|
+
this._extensionState = new ExtensionState(extension_input_json);
|
|
108
|
+
}
|
|
109
|
+
get buildExtensionsBox() {
|
|
110
|
+
const extensionsBox = {};
|
|
111
|
+
const extensionState_communities = this._extensionState.communities;
|
|
112
|
+
for (const community in extensionState_communities) {
|
|
113
|
+
extensionsBox[community] = {};
|
|
114
|
+
const current_community = extensionState_communities[community];
|
|
115
|
+
for (const bundle_digest in current_community) {
|
|
116
|
+
if (bundle_digest === ocabundleDigest(this._oca_bundle)) {
|
|
117
|
+
const capture_base_digest = getDigest(this._oca_bundle);
|
|
118
|
+
const community_extension_input = extensionState_communities[community][bundle_digest];
|
|
119
|
+
const extension = new Extension(community_extension_input, community);
|
|
120
|
+
extensionsBox[community][capture_base_digest] = extension.GenerateExtension();
|
|
121
|
+
}
|
|
122
|
+
else if (bundle_digest !== ocabundleDigest(this._oca_bundle)) {
|
|
123
|
+
if (isOcaBundleWithDeps(this._oca_bundle)) {
|
|
124
|
+
const current_bundle = getOcaBundleFromDeps(this._oca_bundle, bundle_digest);
|
|
125
|
+
const capture_base_digest = getDigest(current_bundle);
|
|
126
|
+
const community_extension_input = extensionState_communities[community][bundle_digest];
|
|
127
|
+
const extension = new Extension(community_extension_input, community);
|
|
128
|
+
extensionsBox[community][capture_base_digest] = extension.GenerateExtension();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return extensionsBox;
|
|
74
134
|
}
|
|
75
135
|
}
|
|
76
|
-
export default
|
|
77
|
-
//# sourceMappingURL=extensions.js.map
|
|
136
|
+
export default ExtensionBox;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { saidify } from 'saidify';
|
|
2
|
+
class AttributeFraming {
|
|
3
|
+
constructor(dynOverlay) {
|
|
4
|
+
if (!dynOverlay) {
|
|
5
|
+
throw new Error('a dynamic extension overlay are required');
|
|
6
|
+
}
|
|
7
|
+
this.dynOverlay = dynOverlay;
|
|
8
|
+
}
|
|
9
|
+
GetAttributeFraming() {
|
|
10
|
+
return this.dynOverlay.attribute_framing_overlay.attributes;
|
|
11
|
+
}
|
|
12
|
+
GetId() {
|
|
13
|
+
return this.dynOverlay.attribute_framing_overlay.properties.id;
|
|
14
|
+
}
|
|
15
|
+
GetLabel() {
|
|
16
|
+
return this.dynOverlay.attribute_framing_overlay.properties.label;
|
|
17
|
+
}
|
|
18
|
+
GetLocation() {
|
|
19
|
+
return this.dynOverlay.attribute_framing_overlay.properties.location;
|
|
20
|
+
}
|
|
21
|
+
GetVersion() {
|
|
22
|
+
return this.dynOverlay.attribute_framing_overlay.properties.version;
|
|
23
|
+
}
|
|
24
|
+
toJSON() {
|
|
25
|
+
return {
|
|
26
|
+
d: '',
|
|
27
|
+
type: 'community/overlays/adc/attribute_framing/1.1',
|
|
28
|
+
framing_metadata: {
|
|
29
|
+
id: this.GetId(),
|
|
30
|
+
label: this.GetLabel(),
|
|
31
|
+
location: this.GetLocation(),
|
|
32
|
+
version: this.GetVersion(),
|
|
33
|
+
},
|
|
34
|
+
attribute_framing: this.GetAttributeFraming(),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
Saidifying() {
|
|
38
|
+
const [, sad] = saidify(this.toJSON());
|
|
39
|
+
return sad;
|
|
40
|
+
}
|
|
41
|
+
GenerateOverlay() {
|
|
42
|
+
return JSON.stringify(this.Saidifying());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export default AttributeFraming;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { saidify } from 'saidify';
|
|
2
|
+
class UnitFraming {
|
|
3
|
+
constructor(dynOverlay) {
|
|
4
|
+
if (!dynOverlay) {
|
|
5
|
+
throw new Error('a dynamic extension overlay are required');
|
|
6
|
+
}
|
|
7
|
+
this.dynOverlay = dynOverlay;
|
|
8
|
+
}
|
|
9
|
+
GetUnits() {
|
|
10
|
+
return this.dynOverlay.unit_framing_overlay.units;
|
|
11
|
+
}
|
|
12
|
+
GetId() {
|
|
13
|
+
return this.dynOverlay.unit_framing_overlay.properties.id;
|
|
14
|
+
}
|
|
15
|
+
GetLabel() {
|
|
16
|
+
return this.dynOverlay.unit_framing_overlay.properties.label;
|
|
17
|
+
}
|
|
18
|
+
GetLocation() {
|
|
19
|
+
return this.dynOverlay.unit_framing_overlay.properties.location;
|
|
20
|
+
}
|
|
21
|
+
GetVersion() {
|
|
22
|
+
return this.dynOverlay.unit_framing_overlay.properties.version;
|
|
23
|
+
}
|
|
24
|
+
toJSON() {
|
|
25
|
+
return {
|
|
26
|
+
d: '',
|
|
27
|
+
type: 'community/overlays/adc/unit_framing/1.1',
|
|
28
|
+
framing_metadata: {
|
|
29
|
+
id: this.GetId(),
|
|
30
|
+
label: this.GetLabel(),
|
|
31
|
+
location: this.GetLocation(),
|
|
32
|
+
version: this.GetVersion(),
|
|
33
|
+
},
|
|
34
|
+
units: this.GetUnits(),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
Saidifying() {
|
|
38
|
+
const [, sad] = saidify(this.toJSON());
|
|
39
|
+
return sad;
|
|
40
|
+
}
|
|
41
|
+
GenerateOverlay() {
|
|
42
|
+
return JSON.stringify(this.Saidifying());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export default UnitFraming;
|
|
@@ -1,36 +1,31 @@
|
|
|
1
|
-
import { getDigest } from '../../../utils/helpers.js';
|
|
2
1
|
import { saidify } from 'saidify';
|
|
3
2
|
class Ordering {
|
|
4
|
-
constructor(
|
|
5
|
-
if (!
|
|
6
|
-
throw new Error('
|
|
3
|
+
constructor(dynOverlay) {
|
|
4
|
+
if (!dynOverlay) {
|
|
5
|
+
throw new Error('a dynamic extension overlay are required');
|
|
7
6
|
}
|
|
8
|
-
this.
|
|
9
|
-
this.extensionState = extensionState;
|
|
10
|
-
this.ordering_overlay = this.getAttributeOrdering();
|
|
7
|
+
this.dynOverlay = dynOverlay;
|
|
11
8
|
}
|
|
12
|
-
|
|
13
|
-
return this.
|
|
9
|
+
GetAttributeOrdering() {
|
|
10
|
+
return this.dynOverlay.ordering_overlay.attribute_ordering;
|
|
14
11
|
}
|
|
15
|
-
|
|
16
|
-
return this.
|
|
12
|
+
GetEntryCodeOrdering() {
|
|
13
|
+
return this.dynOverlay.ordering_overlay.entry_code_ordering;
|
|
17
14
|
}
|
|
18
15
|
toJSON() {
|
|
19
16
|
return {
|
|
20
17
|
d: '',
|
|
21
18
|
type: 'community/overlays/adc/ordering/1.1',
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
entry_code_ordering: this.getEntryCodeOrdering(),
|
|
19
|
+
attribute_ordering: this.GetAttributeOrdering(),
|
|
20
|
+
entry_code_ordering: this.GetEntryCodeOrdering(),
|
|
25
21
|
};
|
|
26
22
|
}
|
|
27
|
-
|
|
23
|
+
Saidifying() {
|
|
28
24
|
const [, sad] = saidify(this.toJSON());
|
|
29
25
|
return sad;
|
|
30
26
|
}
|
|
31
|
-
|
|
32
|
-
return JSON.stringify(this.
|
|
27
|
+
GenerateOverlay() {
|
|
28
|
+
return JSON.stringify(this.Saidifying());
|
|
33
29
|
}
|
|
34
30
|
}
|
|
35
31
|
export default Ordering;
|
|
36
|
-
//# sourceMappingURL=ordering.js.map
|
package/dist/esm/oca_package.js
CHANGED
|
@@ -1,36 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ExtensionBox from './oca_extensions/extensions.js';
|
|
2
2
|
import { saidify } from 'saidify';
|
|
3
3
|
class OcaPackage {
|
|
4
|
-
constructor(
|
|
5
|
-
this.
|
|
6
|
-
this.extension_input = extension_input;
|
|
4
|
+
constructor(extension_input_json, oca_bundle) {
|
|
5
|
+
this.extensions_box = new ExtensionBox(extension_input_json, oca_bundle);
|
|
7
6
|
this.oca_bundle = oca_bundle;
|
|
8
7
|
}
|
|
9
|
-
|
|
8
|
+
Saidifying() {
|
|
10
9
|
const [, sad] = saidify(this.toJSON());
|
|
11
|
-
return
|
|
10
|
+
return sad;
|
|
12
11
|
}
|
|
13
|
-
|
|
12
|
+
Said() {
|
|
14
13
|
const [said] = saidify(this.toJSON());
|
|
15
14
|
return said;
|
|
16
15
|
}
|
|
17
16
|
toJSON() {
|
|
18
17
|
try {
|
|
19
|
-
const extension_container = this.extensions.generate_extensions(this.extension_input, this.oca_bundle);
|
|
20
18
|
return {
|
|
21
19
|
d: '',
|
|
22
20
|
type: 'oca_package/1.0',
|
|
23
21
|
oca_bundle: this.oca_bundle,
|
|
24
|
-
extensions:
|
|
22
|
+
extensions: this.extensions_box.buildExtensionsBox,
|
|
25
23
|
};
|
|
26
24
|
}
|
|
27
25
|
catch (error) {
|
|
28
26
|
throw new Error(`Failed to parse Extension JSON: ${error}`);
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
|
-
|
|
32
|
-
return this.
|
|
29
|
+
GenerateOcaPackage() {
|
|
30
|
+
return JSON.stringify(this.Saidifying());
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
export default OcaPackage;
|
|
36
|
-
//# sourceMappingURL=oca_package.js.map
|
package/dist/esm/types/types.js
CHANGED
|
@@ -4,11 +4,8 @@ export const getCaptureBase = (oca_bundle) => {
|
|
|
4
4
|
if (!oca_bundle) {
|
|
5
5
|
throw new Error('OCA bundle is undefined or null.');
|
|
6
6
|
}
|
|
7
|
-
if (!oca_bundle.bundle) {
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
if (!oca_bundle.bundle.capture_base) {
|
|
11
|
-
throw new Error('OCA bundle does not contain a capture_base property.');
|
|
7
|
+
if (!oca_bundle.bundle && oca_bundle.capture_base) {
|
|
8
|
+
return oca_bundle.capture_base;
|
|
12
9
|
}
|
|
13
10
|
return oca_bundle.bundle.capture_base;
|
|
14
11
|
}
|
|
@@ -45,7 +42,7 @@ export const getDigest = (oca_bundle) => {
|
|
|
45
42
|
// Get oca bundle digest
|
|
46
43
|
export const ocabundleDigest = (oca_bundle) => {
|
|
47
44
|
try {
|
|
48
|
-
const oca_bundle_d = oca_bundle.bundle.d;
|
|
45
|
+
const oca_bundle_d = oca_bundle.bundle?.d !== undefined ? oca_bundle.bundle.d : oca_bundle.d;
|
|
49
46
|
return oca_bundle_d;
|
|
50
47
|
}
|
|
51
48
|
catch (error) {
|
|
@@ -53,4 +50,40 @@ export const ocabundleDigest = (oca_bundle) => {
|
|
|
53
50
|
throw new Error(`Failed to get the oca bundle digest: ${error.message}`);
|
|
54
51
|
}
|
|
55
52
|
};
|
|
56
|
-
|
|
53
|
+
export const isSaid = (value) => {
|
|
54
|
+
return typeof value === 'string' && value.length == 44;
|
|
55
|
+
};
|
|
56
|
+
// Handling oca bundle with dependencies
|
|
57
|
+
export const isOcaBundleWithDeps = (oca_bundle) => {
|
|
58
|
+
try {
|
|
59
|
+
if (!oca_bundle) {
|
|
60
|
+
throw new Error('OCA bundle is undefined or null.');
|
|
61
|
+
}
|
|
62
|
+
if (!oca_bundle.dependencies || oca_bundle.dependencies.length === 0) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error('Error in checking oca bundle with dependencies:', error);
|
|
69
|
+
throw new Error(`Failed to check if the OCA bundle has dependencies: ${error.message}`);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
// Get corresponding oca bundle from oca bundle with dependencies
|
|
73
|
+
export const getOcaBundleFromDeps = (oca_bundle, digest) => {
|
|
74
|
+
try {
|
|
75
|
+
if (!isOcaBundleWithDeps(oca_bundle)) {
|
|
76
|
+
throw new Error('OCA bundle does not have dependencies.');
|
|
77
|
+
}
|
|
78
|
+
const dependencies = oca_bundle['dependencies'];
|
|
79
|
+
for (const dep in dependencies) {
|
|
80
|
+
if (isSaid(digest) && dependencies[dep].d === digest) {
|
|
81
|
+
return dependencies[dep];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
console.error('Error in getting oca bundle from dependencies:', error);
|
|
87
|
+
throw new Error(`Failed to get the OCA bundle from dependencies: ${error.message}`);
|
|
88
|
+
}
|
|
89
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,41 +1,60 @@
|
|
|
1
1
|
import { Said } from '../types/types.js';
|
|
2
2
|
export interface ExtensionInputJson {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
entry_code_ordering?: Record<string, any>;
|
|
3
|
+
[community: string]: {
|
|
4
|
+
[bundle_digest: Said]: DynOverlay[];
|
|
6
5
|
};
|
|
7
6
|
}
|
|
8
7
|
export interface IExtensionState {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
get
|
|
19
|
-
|
|
8
|
+
[community: string]: {
|
|
9
|
+
[bundle_digest: Said]: DynOverlay;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare class ExtensionState {
|
|
13
|
+
private _extension_input_json;
|
|
14
|
+
_extensionState: IExtensionState;
|
|
15
|
+
constructor(ExtensionInputJson: ExtensionInputJson);
|
|
16
|
+
private BuildExtensionState;
|
|
17
|
+
get communities(): IExtensionState;
|
|
18
|
+
}
|
|
19
|
+
export interface DynOverlay {
|
|
20
|
+
[ov_name: string]: {
|
|
21
|
+
type?: string;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export declare class Overlay implements DynOverlay {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
constructor(community_overlay: DynOverlay);
|
|
28
|
+
GenerateOverlay(): Required<DynOverlay>;
|
|
20
29
|
}
|
|
21
30
|
export interface IExtension {
|
|
22
31
|
d: Said;
|
|
23
32
|
type: string;
|
|
24
|
-
|
|
25
|
-
overlays: Record<string, any>;
|
|
33
|
+
_community: string;
|
|
26
34
|
}
|
|
27
|
-
declare class Extension implements IExtension {
|
|
28
|
-
d: Said;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
private generateOverlays;
|
|
35
|
+
export declare class Extension implements IExtension {
|
|
36
|
+
readonly d: Said;
|
|
37
|
+
_community: string;
|
|
38
|
+
readonly type: string;
|
|
39
|
+
_exensions: DynOverlay;
|
|
40
|
+
readonly overlays: {};
|
|
41
|
+
constructor(_extensions_input: DynOverlay, community: string);
|
|
42
|
+
private GenerateOverlays;
|
|
36
43
|
private toJSON;
|
|
37
|
-
private
|
|
38
|
-
|
|
44
|
+
private Saidifying;
|
|
45
|
+
GenerateExtension(): any;
|
|
46
|
+
}
|
|
47
|
+
type ExtensionBoxType = {
|
|
48
|
+
[community: string]: {
|
|
49
|
+
[capture_base_digest: string]: Extension;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
declare class ExtensionBox {
|
|
53
|
+
_extensions_box: ExtensionBoxType;
|
|
54
|
+
_oca_bundle: any;
|
|
55
|
+
_extensionState: ExtensionState;
|
|
56
|
+
constructor(extension_input_json: ExtensionInputJson, oca_bundle: any);
|
|
57
|
+
get buildExtensionsBox(): ExtensionBoxType;
|
|
39
58
|
}
|
|
40
|
-
export default
|
|
59
|
+
export default ExtensionBox;
|
|
41
60
|
//# sourceMappingURL=extensions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../../src/oca_extensions/extensions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../../src/oca_extensions/extensions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAQzC,MAAM,WAAW,kBAAkB;IACjC,CAAC,SAAS,EAAE,MAAM,GAAG;QACnB,CAAC,aAAa,EAAE,IAAI,GAAG,UAAU,EAAE,CAAC;KACrC,CAAC;CACH;AAGD,MAAM,WAAW,eAAe;IAC9B,CAAC,SAAS,EAAE,MAAM,GAAG;QACnB,CAAC,aAAa,EAAE,IAAI,GAAG,UAAU,CAAC;KACnC,CAAC;CACH;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,qBAAqB,CAAqB;IAC3C,eAAe,EAAE,eAAe,CAAC;gBAE5B,kBAAkB,EAAE,kBAAkB;IAKlD,OAAO,CAAC,mBAAmB;IAiB3B,IAAW,WAAW,IAAI,eAAe,CAExC;CACF;AAKD,MAAM,WAAW,UAAU;IACzB,CAAC,OAAO,EAAE,MAAM,GAAG;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED,qBAAa,OAAQ,YAAW,UAAU;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;gBAEP,iBAAiB,EAAE,UAAU;IAIlC,eAAe,IAAI,QAAQ,CAAC,UAAU,CAAC;CAkB/C;AAkFD,MAAM,WAAW,UAAU;IACzB,CAAC,EAAE,IAAI,CAAC;IACR,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,SAAU,YAAW,UAAU;IAC1C,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAM;IACf,UAAU,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,QAAQ,KAAM;gBAEX,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM;IAU5D,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,MAAM;IAQd,OAAO,CAAC,UAAU;IAKX,iBAAiB,IAAI,GAAG;CAGhC;AAED,KAAK,gBAAgB,GAAG;IAAE,CAAC,SAAS,EAAE,MAAM,GAAG;QAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAA;CAAE,CAAC;AAE9F,cAAM,YAAY;IACT,eAAe,EAAE,gBAAgB,CAAC;IAClC,WAAW,EAAE,GAAG,CAAC;IACjB,eAAe,EAAE,cAAc,CAAC;gBAE3B,oBAAoB,EAAE,kBAAkB,EAAE,UAAU,EAAE,GAAG;IAMrE,IAAW,kBAAkB,IAAI,gBAAgB,CA4BhD;CACF;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DynOverlay } from '../../../extensions.js';
|
|
2
|
+
export interface IAttributeFraming {
|
|
3
|
+
dynOverlay: DynOverlay;
|
|
4
|
+
GenerateOverlay(): string;
|
|
5
|
+
}
|
|
6
|
+
declare class AttributeFraming implements IAttributeFraming {
|
|
7
|
+
dynOverlay: DynOverlay;
|
|
8
|
+
constructor(dynOverlay: DynOverlay);
|
|
9
|
+
private GetAttributeFraming;
|
|
10
|
+
private GetId;
|
|
11
|
+
private GetLabel;
|
|
12
|
+
private GetLocation;
|
|
13
|
+
private GetVersion;
|
|
14
|
+
private toJSON;
|
|
15
|
+
private Saidifying;
|
|
16
|
+
GenerateOverlay(): string;
|
|
17
|
+
}
|
|
18
|
+
export default AttributeFraming;
|
|
19
|
+
//# sourceMappingURL=attribute_framing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute_framing.d.ts","sourceRoot":"","sources":["../../../../../../src/oca_extensions/state/overlays/framing/attribute_framing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,IAAI,MAAM,CAAC;CAC3B;AAED,cAAM,gBAAiB,YAAW,iBAAiB;IAC1C,UAAU,EAAE,UAAU,CAAC;gBAElB,UAAU,EAAE,UAAU;IAQlC,OAAO,CAAC,mBAAmB;IAG3B,OAAO,CAAC,KAAK;IAGb,OAAO,CAAC,QAAQ;IAGhB,OAAO,CAAC,WAAW;IAGnB,OAAO,CAAC,UAAU;IAGlB,OAAO,CAAC,MAAM;IAad,OAAO,CAAC,UAAU;IAIX,eAAe,IAAI,MAAM;CAGjC;AACD,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=entry_code_framing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry_code_framing.d.ts","sourceRoot":"","sources":["../../../../../../src/oca_extensions/state/overlays/framing/entry_code_framing.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DynOverlay } from '../../../extensions.js';
|
|
2
|
+
export interface IUnitFraming {
|
|
3
|
+
dynOverlay: DynOverlay;
|
|
4
|
+
GenerateOverlay(): string;
|
|
5
|
+
}
|
|
6
|
+
declare class UnitFraming implements IUnitFraming {
|
|
7
|
+
dynOverlay: DynOverlay;
|
|
8
|
+
constructor(dynOverlay: DynOverlay);
|
|
9
|
+
private GetUnits;
|
|
10
|
+
private GetId;
|
|
11
|
+
private GetLabel;
|
|
12
|
+
private GetLocation;
|
|
13
|
+
private GetVersion;
|
|
14
|
+
private toJSON;
|
|
15
|
+
private Saidifying;
|
|
16
|
+
GenerateOverlay(): string;
|
|
17
|
+
}
|
|
18
|
+
export default UnitFraming;
|
|
19
|
+
//# sourceMappingURL=unit_framing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit_framing.d.ts","sourceRoot":"","sources":["../../../../../../src/oca_extensions/state/overlays/framing/unit_framing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAMpD,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,IAAI,MAAM,CAAC;CAC3B;AAED,cAAM,WAAY,YAAW,YAAY;IAChC,UAAU,EAAE,UAAU,CAAC;gBAElB,UAAU,EAAE,UAAU;IAQlC,OAAO,CAAC,QAAQ;IAGhB,OAAO,CAAC,KAAK;IAGb,OAAO,CAAC,QAAQ;IAGhB,OAAO,CAAC,WAAW;IAGnB,OAAO,CAAC,UAAU;IAGlB,OAAO,CAAC,MAAM;IAad,OAAO,CAAC,UAAU;IAIX,eAAe,IAAI,MAAM;CAGjC;AACD,eAAe,WAAW,CAAC"}
|