oca_package 1.1.0 → 1.2.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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Extension = exports.Overlay = exports.ExtensionState = void 0;
7
7
  const ordering_js_1 = __importDefault(require("./state/overlays/ordering.js"));
8
8
  const unit_framing_js_1 = __importDefault(require("./state/overlays/framing/unit_framing.js"));
9
+ const range_js_1 = __importDefault(require("./state/overlays/range.js"));
9
10
  const helpers_js_1 = require("../utils/helpers.js");
10
11
  const saidify_1 = require("saidify");
11
12
  const ADC_COMMUNITY = 'adc';
@@ -49,6 +50,11 @@ class Overlay {
49
50
  const unit_framing_ov = unit_framing_instance.GenerateOverlay();
50
51
  overlay['unit_framing'] = JSON.parse(unit_framing_ov);
51
52
  }
53
+ else if (ov_type === 'range_overlay') {
54
+ const range_instance = new range_js_1.default(this._overlay);
55
+ const range_ov = range_instance.GenerateOverlay();
56
+ overlay['range'] = JSON.parse(range_ov);
57
+ }
52
58
  else {
53
59
  throw new Error('Invalid overlay name');
54
60
  }
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  const saidify_1 = require("saidify");
7
+ const canonical_js_1 = __importDefault(require("../../../../utils/canonical.js"));
4
8
  class UnitFraming {
5
9
  constructor(dynOverlay) {
6
10
  if (!dynOverlay) {
@@ -9,7 +13,10 @@ class UnitFraming {
9
13
  this.dynOverlay = dynOverlay;
10
14
  }
11
15
  GetUnits() {
12
- return this.dynOverlay.unit_framing_overlay.units;
16
+ const units = this.dynOverlay.unit_framing_overlay.units;
17
+ const canonicalizedUnits = (0, canonical_js_1.default)(units);
18
+ const sortedUnits = JSON.parse(canonicalizedUnits);
19
+ return sortedUnits;
13
20
  }
14
21
  GetId() {
15
22
  return this.dynOverlay.unit_framing_overlay.properties.id;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const saidify_1 = require("saidify");
7
+ const canonical_js_1 = __importDefault(require("../../../utils/canonical.js"));
8
+ class Range {
9
+ constructor(dynOverlay) {
10
+ if (!dynOverlay) {
11
+ throw new Error('a dynamic extension overlay are required');
12
+ }
13
+ this.dynOverlay = dynOverlay;
14
+ }
15
+ GetAttributes() {
16
+ const range_overlay_attributes = this.dynOverlay.range_overlay.attributes;
17
+ const canonicalized_attributes = (0, canonical_js_1.default)(range_overlay_attributes);
18
+ const sortedAttributes = JSON.parse(canonicalized_attributes);
19
+ return sortedAttributes;
20
+ }
21
+ toJSON() {
22
+ return {
23
+ d: '',
24
+ type: 'community/overlays/adc/range/1.1',
25
+ attributes: this.GetAttributes(),
26
+ };
27
+ }
28
+ Saidifying() {
29
+ const [, sad] = (0, saidify_1.saidify)(this.toJSON());
30
+ return sad;
31
+ }
32
+ GenerateOverlay() {
33
+ return JSON.stringify(this.Saidifying());
34
+ }
35
+ }
36
+ exports.default = Range;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Canonicalizes a JSON object by sorting its properties and maintaining the order of array elements.
5
+ * This function is useful for generating a consistent string representation of JSON data.
6
+ *
7
+ * @param {JsonValue} object - The JSON object to canonicalize.
8
+ * @returns {string} - The canonicalized string representation of the JSON object.
9
+ */
10
+ const canonicalize = (object) => {
11
+ let buffer = '';
12
+ serialize(object);
13
+ return buffer;
14
+ function serialize(object) {
15
+ if (object === null || typeof object !== 'object' || typeof object.toJSON === 'function') {
16
+ // Primitive type or toJSON - Use ES6/JSON
17
+ buffer += JSON.stringify(object);
18
+ }
19
+ else if (Array.isArray(object)) {
20
+ // Array - Maintain element order
21
+ buffer += '[';
22
+ let next = false;
23
+ object.forEach(element => {
24
+ if (next) {
25
+ buffer += ',';
26
+ }
27
+ next = true;
28
+ // Array element - Recursive expansion
29
+ serialize(element);
30
+ });
31
+ buffer += ']';
32
+ }
33
+ else {
34
+ // Object - Sort properties before serializing
35
+ buffer += '{';
36
+ let next = false;
37
+ Object.keys(object)
38
+ .sort()
39
+ .forEach(property => {
40
+ if (next) {
41
+ buffer += ',';
42
+ }
43
+ next = true;
44
+ // Property names are strings - Use ES6/JSON
45
+ buffer += JSON.stringify(property);
46
+ buffer += ':';
47
+ // Property value - Recursive expansion
48
+ serialize(object[property]);
49
+ });
50
+ buffer += '}';
51
+ }
52
+ }
53
+ };
54
+ exports.default = canonicalize;
@@ -1,5 +1,6 @@
1
1
  import Ordering from './state/overlays/ordering.js';
2
2
  import UnitFraming from './state/overlays/framing/unit_framing.js';
3
+ import Range from './state/overlays/range.js';
3
4
  import { ocabundleDigest, getOcaBundleFromDeps, getDigest, isOcaBundleWithDeps } from '../utils/helpers.js';
4
5
  import { saidify } from 'saidify';
5
6
  const ADC_COMMUNITY = 'adc';
@@ -42,6 +43,11 @@ export class Overlay {
42
43
  const unit_framing_ov = unit_framing_instance.GenerateOverlay();
43
44
  overlay['unit_framing'] = JSON.parse(unit_framing_ov);
44
45
  }
46
+ else if (ov_type === 'range_overlay') {
47
+ const range_instance = new Range(this._overlay);
48
+ const range_ov = range_instance.GenerateOverlay();
49
+ overlay['range'] = JSON.parse(range_ov);
50
+ }
45
51
  else {
46
52
  throw new Error('Invalid overlay name');
47
53
  }
@@ -1,4 +1,5 @@
1
1
  import { saidify } from 'saidify';
2
+ import canonicalize from '../../../../utils/canonical.js';
2
3
  class UnitFraming {
3
4
  constructor(dynOverlay) {
4
5
  if (!dynOverlay) {
@@ -7,7 +8,10 @@ class UnitFraming {
7
8
  this.dynOverlay = dynOverlay;
8
9
  }
9
10
  GetUnits() {
10
- return this.dynOverlay.unit_framing_overlay.units;
11
+ const units = this.dynOverlay.unit_framing_overlay.units;
12
+ const canonicalizedUnits = canonicalize(units);
13
+ const sortedUnits = JSON.parse(canonicalizedUnits);
14
+ return sortedUnits;
11
15
  }
12
16
  GetId() {
13
17
  return this.dynOverlay.unit_framing_overlay.properties.id;
@@ -0,0 +1,31 @@
1
+ import { saidify } from 'saidify';
2
+ import canonicalize from '../../../utils/canonical.js';
3
+ class Range {
4
+ constructor(dynOverlay) {
5
+ if (!dynOverlay) {
6
+ throw new Error('a dynamic extension overlay are required');
7
+ }
8
+ this.dynOverlay = dynOverlay;
9
+ }
10
+ GetAttributes() {
11
+ const range_overlay_attributes = this.dynOverlay.range_overlay.attributes;
12
+ const canonicalized_attributes = canonicalize(range_overlay_attributes);
13
+ const sortedAttributes = JSON.parse(canonicalized_attributes);
14
+ return sortedAttributes;
15
+ }
16
+ toJSON() {
17
+ return {
18
+ d: '',
19
+ type: 'community/overlays/adc/range/1.1',
20
+ attributes: this.GetAttributes(),
21
+ };
22
+ }
23
+ Saidifying() {
24
+ const [, sad] = saidify(this.toJSON());
25
+ return sad;
26
+ }
27
+ GenerateOverlay() {
28
+ return JSON.stringify(this.Saidifying());
29
+ }
30
+ }
31
+ export default Range;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Canonicalizes a JSON object by sorting its properties and maintaining the order of array elements.
3
+ * This function is useful for generating a consistent string representation of JSON data.
4
+ *
5
+ * @param {JsonValue} object - The JSON object to canonicalize.
6
+ * @returns {string} - The canonicalized string representation of the JSON object.
7
+ */
8
+ const canonicalize = (object) => {
9
+ let buffer = '';
10
+ serialize(object);
11
+ return buffer;
12
+ function serialize(object) {
13
+ if (object === null || typeof object !== 'object' || typeof object.toJSON === 'function') {
14
+ // Primitive type or toJSON - Use ES6/JSON
15
+ buffer += JSON.stringify(object);
16
+ }
17
+ else if (Array.isArray(object)) {
18
+ // Array - Maintain element order
19
+ buffer += '[';
20
+ let next = false;
21
+ object.forEach(element => {
22
+ if (next) {
23
+ buffer += ',';
24
+ }
25
+ next = true;
26
+ // Array element - Recursive expansion
27
+ serialize(element);
28
+ });
29
+ buffer += ']';
30
+ }
31
+ else {
32
+ // Object - Sort properties before serializing
33
+ buffer += '{';
34
+ let next = false;
35
+ Object.keys(object)
36
+ .sort()
37
+ .forEach(property => {
38
+ if (next) {
39
+ buffer += ',';
40
+ }
41
+ next = true;
42
+ // Property names are strings - Use ES6/JSON
43
+ buffer += JSON.stringify(property);
44
+ buffer += ':';
45
+ // Property value - Recursive expansion
46
+ serialize(object[property]);
47
+ });
48
+ buffer += '}';
49
+ }
50
+ }
51
+ };
52
+ export default canonicalize;
@@ -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;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,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F,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"}
@@ -1 +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"}
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;AAOpD,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;IAMhB,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"}
@@ -0,0 +1,15 @@
1
+ import { DynOverlay } from '../../extensions.js';
2
+ export interface IRange {
3
+ dynOverlay: DynOverlay;
4
+ GenerateOverlay(): string;
5
+ }
6
+ declare class Range implements IRange {
7
+ dynOverlay: DynOverlay;
8
+ constructor(dynOverlay: DynOverlay);
9
+ private GetAttributes;
10
+ private toJSON;
11
+ private Saidifying;
12
+ GenerateOverlay(): string;
13
+ }
14
+ export default Range;
15
+ //# sourceMappingURL=range.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../../../../src/oca_extensions/state/overlays/range.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIjD,MAAM,WAAW,MAAM;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,IAAI,MAAM,CAAC;CAC3B;AAED,cAAM,KAAM,YAAW,MAAM;IACpB,UAAU,EAAE,UAAU,CAAC;gBAElB,UAAU,EAAE,UAAU;IAQlC,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,MAAM;IAOd,OAAO,CAAC,UAAU;IAIX,eAAe,IAAI,MAAM;CAGjC;AACD,eAAe,KAAK,CAAC"}
@@ -0,0 +1,15 @@
1
+ type JsonObject = {
2
+ [key: string]: JsonValue;
3
+ };
4
+ type JsonArray = JsonValue[];
5
+ type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
6
+ /**
7
+ * Canonicalizes a JSON object by sorting its properties and maintaining the order of array elements.
8
+ * This function is useful for generating a consistent string representation of JSON data.
9
+ *
10
+ * @param {JsonValue} object - The JSON object to canonicalize.
11
+ * @returns {string} - The canonicalized string representation of the JSON object.
12
+ */
13
+ declare const canonicalize: (object: JsonValue) => string;
14
+ export default canonicalize;
15
+ //# sourceMappingURL=canonical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../../src/utils/canonical.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAC/C,KAAK,SAAS,GAAG,SAAS,EAAE,CAAC;AAC7B,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU,GAAG,SAAS,CAAC;AAE3E;;;;;;GAMG;AACH,QAAA,MAAM,YAAY,WAAY,SAAS,KAAG,MA0CzC,CAAC;AAEF,eAAe,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oca_package",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "The wrapper of OCA bundle to generate OCA Package at ADC",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",