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
package/dist/cjs/index.js
CHANGED
|
@@ -3,9 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.OcaPackage = void 0;
|
|
7
7
|
var oca_package_js_1 = require("./oca_package.js");
|
|
8
8
|
Object.defineProperty(exports, "OcaPackage", { enumerable: true, get: function () { return __importDefault(oca_package_js_1).default; } });
|
|
9
|
-
var extenstionContainer_js_1 = require("./oca_extensions/state/extenstionContainer.js");
|
|
10
|
-
Object.defineProperty(exports, "ExtensionContainer", { enumerable: true, get: function () { return __importDefault(extenstionContainer_js_1).default; } });
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -3,82 +3,143 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ExtensionState = void 0;
|
|
7
|
-
const helpers_js_1 = require("../utils/helpers.js");
|
|
6
|
+
exports.Extension = exports.Overlay = exports.ExtensionState = void 0;
|
|
8
7
|
const ordering_js_1 = __importDefault(require("./state/overlays/ordering.js"));
|
|
8
|
+
const unit_framing_js_1 = __importDefault(require("./state/overlays/framing/unit_framing.js"));
|
|
9
|
+
const helpers_js_1 = require("../utils/helpers.js");
|
|
9
10
|
const saidify_1 = require("saidify");
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const ADC_COMMUNITY = 'adc';
|
|
12
|
+
const v = '1.0';
|
|
12
13
|
class ExtensionState {
|
|
13
|
-
constructor(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
this._attributes_ordering_arr = this.extractAttributeOrdering(extension_obj);
|
|
18
|
-
this._entry_code_ordering_arr = this.extractEntryCodeOrdering(extension_obj);
|
|
14
|
+
constructor(ExtensionInputJson) {
|
|
15
|
+
this._extension_input_json = ExtensionInputJson;
|
|
16
|
+
this._extensionState = this.BuildExtensionState();
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
BuildExtensionState() {
|
|
19
|
+
let state = {};
|
|
20
|
+
for (const community in this._extension_input_json.extensions) {
|
|
21
|
+
const community_extensions = this._extension_input_json.extensions[community];
|
|
22
|
+
state[community] = {};
|
|
23
|
+
for (const bundle_digest in community_extensions) {
|
|
24
|
+
state[community][bundle_digest] = community_extensions[bundle_digest];
|
|
25
|
+
}
|
|
26
26
|
}
|
|
27
|
+
return state;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
get attribute_ordering_arr() {
|
|
32
|
-
return this._attributes_ordering_arr;
|
|
33
|
-
}
|
|
34
|
-
get entry_code_ordering_arr() {
|
|
35
|
-
return this._entry_code_ordering_arr;
|
|
29
|
+
// TODO: list the overlays
|
|
30
|
+
get communities() {
|
|
31
|
+
return this._extensionState;
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
34
|
exports.ExtensionState = ExtensionState;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this.
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
class Overlay {
|
|
36
|
+
constructor(community_overlay) {
|
|
37
|
+
this._overlay = community_overlay;
|
|
38
|
+
}
|
|
39
|
+
GenerateOverlay() {
|
|
40
|
+
const overlay = {};
|
|
41
|
+
for (const ov_type in this._overlay) {
|
|
42
|
+
if (ov_type === 'ordering_overlay') {
|
|
43
|
+
const ordering_instance = new ordering_js_1.default(this._overlay);
|
|
44
|
+
const ordering_ov = ordering_instance.GenerateOverlay();
|
|
45
|
+
overlay['ordering'] = JSON.parse(ordering_ov);
|
|
46
|
+
}
|
|
47
|
+
else if (ov_type === 'unit_framing_overlay') {
|
|
48
|
+
const unit_framing_instance = new unit_framing_js_1.default(this._overlay);
|
|
49
|
+
const unit_framing_ov = unit_framing_instance.GenerateOverlay();
|
|
50
|
+
overlay['unit_framing'] = JSON.parse(unit_framing_ov);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
throw new Error('Invalid overlay name');
|
|
54
|
+
}
|
|
48
55
|
}
|
|
49
|
-
|
|
50
|
-
this.oca_bundle = oca_bundle;
|
|
51
|
-
this.overlays = this.generateOverlays();
|
|
56
|
+
return overlay;
|
|
52
57
|
}
|
|
53
|
-
|
|
58
|
+
}
|
|
59
|
+
exports.Overlay = Overlay;
|
|
60
|
+
class ADCOverlayStrategy {
|
|
61
|
+
GenerateOverlay(extensions) {
|
|
54
62
|
const overlays = {};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
for (const extKey in extensions) {
|
|
64
|
+
const ext = extensions[extKey];
|
|
65
|
+
const overlay_instance = new Overlay(ext);
|
|
66
|
+
const generated_overlay = overlay_instance.GenerateOverlay();
|
|
67
|
+
for (const overlay_type in generated_overlay) {
|
|
68
|
+
overlays[overlay_type] = generated_overlay[overlay_type];
|
|
59
69
|
}
|
|
60
70
|
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
console.error('Error generating overlays:', error);
|
|
63
|
-
}
|
|
64
71
|
return overlays;
|
|
65
72
|
}
|
|
73
|
+
}
|
|
74
|
+
// To implement overlays for external communities, create a new class that implements the OverlayStrategy interface.
|
|
75
|
+
// For example, if you have a community called "external_community", you can create a class like this:
|
|
76
|
+
class DefaultOverlayStrategy {
|
|
77
|
+
GenerateOverlay(extensions) {
|
|
78
|
+
throw new Error('Unsupported community type');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
class Extension {
|
|
82
|
+
constructor(_extensions_input, community) {
|
|
83
|
+
this.d = '';
|
|
84
|
+
this.overlays = {};
|
|
85
|
+
if (!_extensions_input || !community) {
|
|
86
|
+
throw new Error('extension array is required from extension state and community is required');
|
|
87
|
+
}
|
|
88
|
+
this._community = community;
|
|
89
|
+
this._exensions = _extensions_input;
|
|
90
|
+
this.type = `community/${this._community}/extension/${v}`;
|
|
91
|
+
}
|
|
92
|
+
GenerateOverlays() {
|
|
93
|
+
const strategy = this._community === ADC_COMMUNITY ? new ADCOverlayStrategy() : new DefaultOverlayStrategy();
|
|
94
|
+
return strategy.GenerateOverlay(this._exensions);
|
|
95
|
+
}
|
|
66
96
|
toJSON() {
|
|
67
|
-
const oca_bundle_digest = (0, helpers_js_1.ocabundleDigest)(this.oca_bundle);
|
|
68
97
|
return {
|
|
69
98
|
d: '',
|
|
70
|
-
type:
|
|
71
|
-
|
|
72
|
-
overlays: this.overlays,
|
|
99
|
+
type: `community/${this._community}/extension/1.0`,
|
|
100
|
+
overlays: this.GenerateOverlays(),
|
|
73
101
|
};
|
|
74
102
|
}
|
|
75
|
-
|
|
103
|
+
Saidifying() {
|
|
76
104
|
const [, sad] = (0, saidify_1.saidify)(this.toJSON());
|
|
77
105
|
return sad;
|
|
78
106
|
}
|
|
79
|
-
|
|
80
|
-
return
|
|
107
|
+
GenerateExtension() {
|
|
108
|
+
return this.Saidifying();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.Extension = Extension;
|
|
112
|
+
class ExtensionBox {
|
|
113
|
+
constructor(extension_input_json, oca_bundle) {
|
|
114
|
+
this._extensions_box = {};
|
|
115
|
+
this._oca_bundle = oca_bundle;
|
|
116
|
+
this._extensionState = new ExtensionState(extension_input_json);
|
|
117
|
+
}
|
|
118
|
+
get buildExtensionsBox() {
|
|
119
|
+
const extensionsBox = {};
|
|
120
|
+
const extensionState_communities = this._extensionState.communities;
|
|
121
|
+
for (const community in extensionState_communities) {
|
|
122
|
+
extensionsBox[community] = {};
|
|
123
|
+
const current_community = extensionState_communities[community];
|
|
124
|
+
for (const bundle_digest in current_community) {
|
|
125
|
+
if (bundle_digest === (0, helpers_js_1.ocabundleDigest)(this._oca_bundle)) {
|
|
126
|
+
const capture_base_digest = (0, helpers_js_1.getDigest)(this._oca_bundle);
|
|
127
|
+
const community_extension_input = extensionState_communities[community][bundle_digest];
|
|
128
|
+
const extension = new Extension(community_extension_input, community);
|
|
129
|
+
extensionsBox[community][capture_base_digest] = extension.GenerateExtension();
|
|
130
|
+
}
|
|
131
|
+
else if (bundle_digest !== (0, helpers_js_1.ocabundleDigest)(this._oca_bundle)) {
|
|
132
|
+
if ((0, helpers_js_1.isOcaBundleWithDeps)(this._oca_bundle)) {
|
|
133
|
+
const current_bundle = (0, helpers_js_1.getOcaBundleFromDeps)(this._oca_bundle, bundle_digest);
|
|
134
|
+
const capture_base_digest = (0, helpers_js_1.getDigest)(current_bundle);
|
|
135
|
+
const community_extension_input = extensionState_communities[community][bundle_digest];
|
|
136
|
+
const extension = new Extension(community_extension_input, community);
|
|
137
|
+
extensionsBox[community][capture_base_digest] = extension.GenerateExtension();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return extensionsBox;
|
|
81
143
|
}
|
|
82
144
|
}
|
|
83
|
-
exports.default =
|
|
84
|
-
//# sourceMappingURL=extensions.js.map
|
|
145
|
+
exports.default = ExtensionBox;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const saidify_1 = require("saidify");
|
|
4
|
+
class AttributeFraming {
|
|
5
|
+
constructor(dynOverlay) {
|
|
6
|
+
if (!dynOverlay) {
|
|
7
|
+
throw new Error('a dynamic extension overlay are required');
|
|
8
|
+
}
|
|
9
|
+
this.dynOverlay = dynOverlay;
|
|
10
|
+
}
|
|
11
|
+
GetAttributeFraming() {
|
|
12
|
+
return this.dynOverlay.attribute_framing_overlay.attributes;
|
|
13
|
+
}
|
|
14
|
+
GetId() {
|
|
15
|
+
return this.dynOverlay.attribute_framing_overlay.properties.id;
|
|
16
|
+
}
|
|
17
|
+
GetLabel() {
|
|
18
|
+
return this.dynOverlay.attribute_framing_overlay.properties.label;
|
|
19
|
+
}
|
|
20
|
+
GetLocation() {
|
|
21
|
+
return this.dynOverlay.attribute_framing_overlay.properties.location;
|
|
22
|
+
}
|
|
23
|
+
GetVersion() {
|
|
24
|
+
return this.dynOverlay.attribute_framing_overlay.properties.version;
|
|
25
|
+
}
|
|
26
|
+
toJSON() {
|
|
27
|
+
return {
|
|
28
|
+
d: '',
|
|
29
|
+
type: 'community/overlays/adc/attribute_framing/1.1',
|
|
30
|
+
framing_metadata: {
|
|
31
|
+
id: this.GetId(),
|
|
32
|
+
label: this.GetLabel(),
|
|
33
|
+
location: this.GetLocation(),
|
|
34
|
+
version: this.GetVersion(),
|
|
35
|
+
},
|
|
36
|
+
attribute_framing: this.GetAttributeFraming(),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
Saidifying() {
|
|
40
|
+
const [, sad] = (0, saidify_1.saidify)(this.toJSON());
|
|
41
|
+
return sad;
|
|
42
|
+
}
|
|
43
|
+
GenerateOverlay() {
|
|
44
|
+
return JSON.stringify(this.Saidifying());
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.default = AttributeFraming;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const saidify_1 = require("saidify");
|
|
4
|
+
class UnitFraming {
|
|
5
|
+
constructor(dynOverlay) {
|
|
6
|
+
if (!dynOverlay) {
|
|
7
|
+
throw new Error('a dynamic extension overlay are required');
|
|
8
|
+
}
|
|
9
|
+
this.dynOverlay = dynOverlay;
|
|
10
|
+
}
|
|
11
|
+
GetUnits() {
|
|
12
|
+
return this.dynOverlay.unit_framing_overlay.units;
|
|
13
|
+
}
|
|
14
|
+
GetId() {
|
|
15
|
+
return this.dynOverlay.unit_framing_overlay.properties.id;
|
|
16
|
+
}
|
|
17
|
+
GetLabel() {
|
|
18
|
+
return this.dynOverlay.unit_framing_overlay.properties.label;
|
|
19
|
+
}
|
|
20
|
+
GetLocation() {
|
|
21
|
+
return this.dynOverlay.unit_framing_overlay.properties.location;
|
|
22
|
+
}
|
|
23
|
+
GetVersion() {
|
|
24
|
+
return this.dynOverlay.unit_framing_overlay.properties.version;
|
|
25
|
+
}
|
|
26
|
+
toJSON() {
|
|
27
|
+
return {
|
|
28
|
+
d: '',
|
|
29
|
+
type: 'community/overlays/adc/unit_framing/1.1',
|
|
30
|
+
framing_metadata: {
|
|
31
|
+
id: this.GetId(),
|
|
32
|
+
label: this.GetLabel(),
|
|
33
|
+
location: this.GetLocation(),
|
|
34
|
+
version: this.GetVersion(),
|
|
35
|
+
},
|
|
36
|
+
units: this.GetUnits(),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
Saidifying() {
|
|
40
|
+
const [, sad] = (0, saidify_1.saidify)(this.toJSON());
|
|
41
|
+
return sad;
|
|
42
|
+
}
|
|
43
|
+
GenerateOverlay() {
|
|
44
|
+
return JSON.stringify(this.Saidifying());
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.default = UnitFraming;
|
|
@@ -1,38 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const helpers_js_1 = require("../../../utils/helpers.js");
|
|
4
3
|
const saidify_1 = require("saidify");
|
|
5
4
|
class Ordering {
|
|
6
|
-
constructor(
|
|
7
|
-
if (!
|
|
8
|
-
throw new Error('
|
|
5
|
+
constructor(dynOverlay) {
|
|
6
|
+
if (!dynOverlay) {
|
|
7
|
+
throw new Error('a dynamic extension overlay are required');
|
|
9
8
|
}
|
|
10
|
-
this.
|
|
11
|
-
this.extensionState = extensionState;
|
|
12
|
-
this.ordering_overlay = this.getAttributeOrdering();
|
|
9
|
+
this.dynOverlay = dynOverlay;
|
|
13
10
|
}
|
|
14
|
-
|
|
15
|
-
return this.
|
|
11
|
+
GetAttributeOrdering() {
|
|
12
|
+
return this.dynOverlay.ordering_overlay.attribute_ordering;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
return this.
|
|
14
|
+
GetEntryCodeOrdering() {
|
|
15
|
+
return this.dynOverlay.ordering_overlay.entry_code_ordering;
|
|
19
16
|
}
|
|
20
17
|
toJSON() {
|
|
21
18
|
return {
|
|
22
19
|
d: '',
|
|
23
20
|
type: 'community/overlays/adc/ordering/1.1',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
entry_code_ordering: this.getEntryCodeOrdering(),
|
|
21
|
+
attribute_ordering: this.GetAttributeOrdering(),
|
|
22
|
+
entry_code_ordering: this.GetEntryCodeOrdering(),
|
|
27
23
|
};
|
|
28
24
|
}
|
|
29
|
-
|
|
25
|
+
Saidifying() {
|
|
30
26
|
const [, sad] = (0, saidify_1.saidify)(this.toJSON());
|
|
31
27
|
return sad;
|
|
32
28
|
}
|
|
33
|
-
|
|
34
|
-
return JSON.stringify(this.
|
|
29
|
+
GenerateOverlay() {
|
|
30
|
+
return JSON.stringify(this.Saidifying());
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
33
|
exports.default = Ordering;
|
|
38
|
-
//# sourceMappingURL=ordering.js.map
|
package/dist/cjs/oca_package.js
CHANGED
|
@@ -3,39 +3,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const extensions_js_1 = __importDefault(require("./oca_extensions/extensions.js"));
|
|
7
7
|
const saidify_1 = require("saidify");
|
|
8
8
|
class OcaPackage {
|
|
9
|
-
constructor(
|
|
10
|
-
this.
|
|
11
|
-
this.extension_input = extension_input;
|
|
9
|
+
constructor(extension_input_json, oca_bundle) {
|
|
10
|
+
this.extensions_box = new extensions_js_1.default(extension_input_json, oca_bundle);
|
|
12
11
|
this.oca_bundle = oca_bundle;
|
|
13
12
|
}
|
|
14
|
-
|
|
13
|
+
Saidifying() {
|
|
15
14
|
const [, sad] = (0, saidify_1.saidify)(this.toJSON());
|
|
16
|
-
return
|
|
15
|
+
return sad;
|
|
17
16
|
}
|
|
18
|
-
|
|
17
|
+
Said() {
|
|
19
18
|
const [said] = (0, saidify_1.saidify)(this.toJSON());
|
|
20
19
|
return said;
|
|
21
20
|
}
|
|
22
21
|
toJSON() {
|
|
23
22
|
try {
|
|
24
|
-
const extension_container = this.extensions.generate_extensions(this.extension_input, this.oca_bundle);
|
|
25
23
|
return {
|
|
26
24
|
d: '',
|
|
27
25
|
type: 'oca_package/1.0',
|
|
28
26
|
oca_bundle: this.oca_bundle,
|
|
29
|
-
extensions:
|
|
27
|
+
extensions: this.extensions_box.buildExtensionsBox,
|
|
30
28
|
};
|
|
31
29
|
}
|
|
32
30
|
catch (error) {
|
|
33
31
|
throw new Error(`Failed to parse Extension JSON: ${error}`);
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
|
-
|
|
37
|
-
return this.
|
|
34
|
+
GenerateOcaPackage() {
|
|
35
|
+
return JSON.stringify(this.Saidifying());
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
38
|
exports.default = OcaPackage;
|
|
41
|
-
//# sourceMappingURL=oca_package.js.map
|
package/dist/cjs/types/types.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ocabundleDigest = exports.getDigest = exports.isPresent = exports.getCaptureBase = void 0;
|
|
3
|
+
exports.getOcaBundleFromDeps = exports.isOcaBundleWithDeps = exports.isSaid = exports.ocabundleDigest = exports.getDigest = exports.isPresent = exports.getCaptureBase = void 0;
|
|
4
4
|
// Get capture base from the OCA bundle
|
|
5
5
|
const getCaptureBase = (oca_bundle) => {
|
|
6
6
|
try {
|
|
7
7
|
if (!oca_bundle) {
|
|
8
8
|
throw new Error('OCA bundle is undefined or null.');
|
|
9
9
|
}
|
|
10
|
-
if (!oca_bundle.bundle) {
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
if (!oca_bundle.bundle.capture_base) {
|
|
14
|
-
throw new Error('OCA bundle does not contain a capture_base property.');
|
|
10
|
+
if (!oca_bundle.bundle && oca_bundle.capture_base) {
|
|
11
|
+
return oca_bundle.capture_base;
|
|
15
12
|
}
|
|
16
13
|
return oca_bundle.bundle.capture_base;
|
|
17
14
|
}
|
|
@@ -51,7 +48,7 @@ exports.getDigest = getDigest;
|
|
|
51
48
|
// Get oca bundle digest
|
|
52
49
|
const ocabundleDigest = (oca_bundle) => {
|
|
53
50
|
try {
|
|
54
|
-
const oca_bundle_d = oca_bundle.bundle.d;
|
|
51
|
+
const oca_bundle_d = oca_bundle.bundle?.d !== undefined ? oca_bundle.bundle.d : oca_bundle.d;
|
|
55
52
|
return oca_bundle_d;
|
|
56
53
|
}
|
|
57
54
|
catch (error) {
|
|
@@ -60,4 +57,43 @@ const ocabundleDigest = (oca_bundle) => {
|
|
|
60
57
|
}
|
|
61
58
|
};
|
|
62
59
|
exports.ocabundleDigest = ocabundleDigest;
|
|
63
|
-
|
|
60
|
+
const isSaid = (value) => {
|
|
61
|
+
return typeof value === 'string' && value.length == 44;
|
|
62
|
+
};
|
|
63
|
+
exports.isSaid = isSaid;
|
|
64
|
+
// Handling oca bundle with dependencies
|
|
65
|
+
const isOcaBundleWithDeps = (oca_bundle) => {
|
|
66
|
+
try {
|
|
67
|
+
if (!oca_bundle) {
|
|
68
|
+
throw new Error('OCA bundle is undefined or null.');
|
|
69
|
+
}
|
|
70
|
+
if (!oca_bundle.dependencies || oca_bundle.dependencies.length === 0) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error('Error in checking oca bundle with dependencies:', error);
|
|
77
|
+
throw new Error(`Failed to check if the OCA bundle has dependencies: ${error.message}`);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
exports.isOcaBundleWithDeps = isOcaBundleWithDeps;
|
|
81
|
+
// Get corresponding oca bundle from oca bundle with dependencies
|
|
82
|
+
const getOcaBundleFromDeps = (oca_bundle, digest) => {
|
|
83
|
+
try {
|
|
84
|
+
if (!(0, exports.isOcaBundleWithDeps)(oca_bundle)) {
|
|
85
|
+
throw new Error('OCA bundle does not have dependencies.');
|
|
86
|
+
}
|
|
87
|
+
const dependencies = oca_bundle['dependencies'];
|
|
88
|
+
for (const dep in dependencies) {
|
|
89
|
+
if ((0, exports.isSaid)(digest) && dependencies[dep].d === digest) {
|
|
90
|
+
return dependencies[dep];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
console.error('Error in getting oca bundle from dependencies:', error);
|
|
96
|
+
throw new Error(`Failed to get the OCA bundle from dependencies: ${error.message}`);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
exports.getOcaBundleFromDeps = getOcaBundleFromDeps;
|
package/dist/esm/index.js
CHANGED