@octostar/platform-api 0.5.11 → 0.5.12
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/ContextAPI.d.ts.map +1 -1
- package/dist/lib/ContextAPI.js +3 -1
- package/dist/lib/ContextAPI.js.map +1 -1
- package/dist/lib/classInstanceToObject.d.ts +12 -0
- package/dist/lib/classInstanceToObject.d.ts.map +1 -0
- package/dist/lib/classInstanceToObject.js +45 -0
- package/dist/lib/classInstanceToObject.js.map +1 -0
- package/dist/octostar-platform-api.js +83 -7
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextAPI.d.ts","sourceRoot":"","sources":["../../src/lib/ContextAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAqB,oBAAoB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"ContextAPI.d.ts","sourceRoot":"","sources":["../../src/lib/ContextAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAqB,oBAAoB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAIlI,KAAK,0BAA0B,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,oBAAoB,CAAC,WAAW,CAAC,GAAG;IAC7G,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,qBAAa,UAAU,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAE,YAAW,OAAO,CAAC,WAAW,CAAC;IAC9F,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC,WAAW,CAAC,CAAA;IAEvD,OAAO,CAAC,OAAO,CAA+B;IAE9C,OAAO,CAAC,SAAS,CAA+C;IAEhE,OAAO,CAAC,EAAE,CAAS;gBAEP,EAAE,EAAE,EAAE,GAAG,WAAW,EAAE,EAAE,0BAA0B,CAAC,WAAW,CAAC;IAO3E,IAAI,OAAO,IAIU,WAAW,CAF/B;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,WAAW,EAK/B;IAED,IAAI,SAAS,IAIc,MAAM,GAAG,SAAS,CAF5C;IAEC,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAe1C;IAEH,UAAU;IAIV,UAAU,CAAC,OAAO,EAAE,mBAAmB,CAAC,WAAW,CAAC;IAKpD,eAAe;IAIf,oBAAoB;IAapB,kBAAkB,CAAC,eAAe,EAAE,eAAe,CAAC,WAAW,CAAC,GAAG,MAAM;IAEzE,kBAAkB,CAChB,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,eAAe,CAAC,WAAW,CAAC,GAC5C,MAAM;IAqBT,sBAAsB,CAAC,EAAE,EAAE,MAAM;CAGlC"}
|
package/dist/lib/ContextAPI.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import { classInstanceToObject } from './classInstanceToObject';
|
|
2
3
|
export class ContextAPI {
|
|
3
4
|
constructor({ id, ...static_data }) {
|
|
4
5
|
this.static_data = static_data;
|
|
@@ -44,9 +45,10 @@ export class ContextAPI {
|
|
|
44
45
|
if (!this.channel) {
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
48
|
+
const context = classInstanceToObject(this.context);
|
|
47
49
|
this.channel.postMessage({
|
|
48
50
|
from: this.id,
|
|
49
|
-
context
|
|
51
|
+
context,
|
|
50
52
|
});
|
|
51
53
|
}
|
|
52
54
|
subscribeToChanges(idOrContextListener, contextListenerOrNothing) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextAPI.js","sourceRoot":"","sources":["../../src/lib/ContextAPI.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ContextAPI.js","sourceRoot":"","sources":["../../src/lib/ContextAPI.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,MAAM,OAAO,UAAU;IASrB,YAAY,EAAE,EAAE,EAAE,GAAG,WAAW,EAA2C;QACzE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;IACzC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,OAAoB;QAC9B,IAAI,CAAC,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC;QAEnC,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;IACpC,CAAC;IAEC,IAAI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AAC,CAAC;IACL,CAAC;IASD,kBAAkB,CAChB,mBAA0D,EAC1D,wBAAuD;QAEvD,MAAM,EAAE,GACN,OAAO,mBAAmB,KAAK,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC3E,MAAM,eAAe,GACnB,OAAO,mBAAmB,KAAK,UAAU;YACvC,CAAC,CAAC,mBAAmB;YACrB,CAAC,CAAC,wBAAwB,CAAC;QAE/B,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC;QACrC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,sBAAsB,CAAC,EAAU;QAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const classInstanceToObject: <T extends {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}>(instance: T, options?: {
|
|
4
|
+
globals?: {
|
|
5
|
+
canCallAction?: (prams: {
|
|
6
|
+
method: string;
|
|
7
|
+
class: string;
|
|
8
|
+
}) => boolean;
|
|
9
|
+
};
|
|
10
|
+
methodWrappers?: { [K in keyof T]?: (fn: T[K], ...args: T[K] extends (...args: infer P) => any ? P : never) => T[K] extends (...args: any) => infer R ? R : never; };
|
|
11
|
+
}) => T;
|
|
12
|
+
//# sourceMappingURL=classInstanceToObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classInstanceToObject.d.ts","sourceRoot":"","sources":["../../src/lib/classInstanceToObject.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EACpE,UAAU,CAAC,EACX,UAAU;IACR,OAAO,CAAC,EAAE;QACR,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,KAAK,OAAO,CAAC;KACvE,CAAC;IACF,cAAc,CAAC,EAAE,GACd,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CACf,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EACR,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,KAAK,KACxD,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,GACxD,CAAC;CACH,KACA,CAoDF,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export const classInstanceToObject = (instance, options) => {
|
|
2
|
+
const obj = {};
|
|
3
|
+
// const prototype = Object.getPrototypeOf(instance);
|
|
4
|
+
const properties = [
|
|
5
|
+
// ...Object.getOwnPropertyNames(instance),
|
|
6
|
+
// ...Object.getOwnPropertyNames(prototype),
|
|
7
|
+
];
|
|
8
|
+
let currentClass = instance;
|
|
9
|
+
while (currentClass && currentClass !== Object) {
|
|
10
|
+
// console.log('current class', currentClass); // TODO: test if it omits the Object methods
|
|
11
|
+
properties.push(...Object.getOwnPropertyNames(currentClass));
|
|
12
|
+
currentClass = Object.getPrototypeOf(currentClass);
|
|
13
|
+
}
|
|
14
|
+
properties.forEach(property => {
|
|
15
|
+
if (['constructor'].includes(property)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
let method = instance[property];
|
|
19
|
+
method =
|
|
20
|
+
typeof method === 'function' && typeof method.bind === 'function'
|
|
21
|
+
? method.bind(instance)
|
|
22
|
+
: method;
|
|
23
|
+
if (options?.globals?.canCallAction) {
|
|
24
|
+
const originalMethod = method;
|
|
25
|
+
method = (...args) => {
|
|
26
|
+
const canCall = options.globals.canCallAction({
|
|
27
|
+
method: method.name,
|
|
28
|
+
class: instance.constructor.name,
|
|
29
|
+
});
|
|
30
|
+
if (!canCall) {
|
|
31
|
+
throw new Error(`No permissions for call: ${method.name}`); // TODO: consider usage of a specific permissions error
|
|
32
|
+
}
|
|
33
|
+
return originalMethod(...args);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (typeof options?.methodWrappers?.[property] === 'function') {
|
|
37
|
+
obj[property] = (...args) => options.methodWrappers[property](method, ...args);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
obj[property] = (...args) => method(...args);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return obj;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=classInstanceToObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classInstanceToObject.js","sourceRoot":"","sources":["../../src/lib/classInstanceToObject.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,QAAW,EACX,OAUC,EACE,EAAE;IACL,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,qDAAqD;IACrD,MAAM,UAAU,GAAa;IAC3B,2CAA2C;IAC3C,4CAA4C;KAC7C,CAAC;IACF,IAAI,YAAY,GAAG,QAAQ,CAAC;IAC5B,OAAO,YAAY,IAAK,YAAoB,KAAK,MAAM,EAAE,CAAC;QACxD,2FAA2F;QAE3F,UAAU,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC;QAC7D,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IACrD,CAAC;IAED,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC5B,IAAI,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvC,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|
@@ -6684,7 +6684,7 @@ var forwardCallsToFutureObject = exports.forwardCallsToFutureObject = function f
|
|
|
6684
6684
|
});
|
|
6685
6685
|
};
|
|
6686
6686
|
|
|
6687
|
-
},{"./constants":33,"./utils":
|
|
6687
|
+
},{"./constants":33,"./utils":45,"post-robot":5}],35:[function(require,module,exports){
|
|
6688
6688
|
"use strict";
|
|
6689
6689
|
|
|
6690
6690
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -6811,8 +6811,19 @@ Object.keys(_ContextAPI).forEach(function (key) {
|
|
|
6811
6811
|
}
|
|
6812
6812
|
});
|
|
6813
6813
|
});
|
|
6814
|
+
var _classInstanceToObject = require("./lib/classInstanceToObject");
|
|
6815
|
+
Object.keys(_classInstanceToObject).forEach(function (key) {
|
|
6816
|
+
if (key === "default" || key === "__esModule") return;
|
|
6817
|
+
if (key in exports && exports[key] === _classInstanceToObject[key]) return;
|
|
6818
|
+
Object.defineProperty(exports, key, {
|
|
6819
|
+
enumerable: true,
|
|
6820
|
+
get: function get() {
|
|
6821
|
+
return _classInstanceToObject[key];
|
|
6822
|
+
}
|
|
6823
|
+
});
|
|
6824
|
+
});
|
|
6814
6825
|
|
|
6815
|
-
},{"./apis":22,"./components":32,"./constants":33,"./lib/AIClientImpl":36,"./lib/ContextAPI":38,"./lib/JWTProvider":39,"./lib/Proxy":40,"./lib/
|
|
6826
|
+
},{"./apis":22,"./components":32,"./constants":33,"./lib/AIClientImpl":36,"./lib/ContextAPI":38,"./lib/JWTProvider":39,"./lib/Proxy":40,"./lib/classInstanceToObject":41,"./lib/userWorkspace":42,"./permissions":43,"./types":44,"./utils":45}],36:[function(require,module,exports){
|
|
6816
6827
|
"use strict";
|
|
6817
6828
|
|
|
6818
6829
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -7067,6 +7078,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7067
7078
|
});
|
|
7068
7079
|
exports.ContextAPI = void 0;
|
|
7069
7080
|
var _uuid = require("uuid");
|
|
7081
|
+
var _classInstanceToObject = require("./classInstanceToObject");
|
|
7070
7082
|
var _excluded = ["id"];
|
|
7071
7083
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
7072
7084
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
@@ -7139,9 +7151,10 @@ var ContextAPI = exports.ContextAPI = /*#__PURE__*/function () {
|
|
|
7139
7151
|
if (!this.channel) {
|
|
7140
7152
|
return;
|
|
7141
7153
|
}
|
|
7154
|
+
var context = (0, _classInstanceToObject.classInstanceToObject)(this.context);
|
|
7142
7155
|
this.channel.postMessage({
|
|
7143
7156
|
from: this.id,
|
|
7144
|
-
context:
|
|
7157
|
+
context: context
|
|
7145
7158
|
});
|
|
7146
7159
|
}
|
|
7147
7160
|
}, {
|
|
@@ -7163,7 +7176,7 @@ var ContextAPI = exports.ContextAPI = /*#__PURE__*/function () {
|
|
|
7163
7176
|
}]);
|
|
7164
7177
|
}();
|
|
7165
7178
|
|
|
7166
|
-
},{"uuid":6}],39:[function(require,module,exports){
|
|
7179
|
+
},{"./classInstanceToObject":41,"uuid":6}],39:[function(require,module,exports){
|
|
7167
7180
|
"use strict";
|
|
7168
7181
|
|
|
7169
7182
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -7287,6 +7300,69 @@ var makeProxy = exports.makeProxy = function makeProxy(obj) {
|
|
|
7287
7300
|
},{}],41:[function(require,module,exports){
|
|
7288
7301
|
"use strict";
|
|
7289
7302
|
|
|
7303
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7304
|
+
value: true
|
|
7305
|
+
});
|
|
7306
|
+
exports.classInstanceToObject = void 0;
|
|
7307
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
7308
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7309
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
7310
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
7311
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
7312
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
7313
|
+
var classInstanceToObject = exports.classInstanceToObject = function classInstanceToObject(instance, options) {
|
|
7314
|
+
var obj = {};
|
|
7315
|
+
// const prototype = Object.getPrototypeOf(instance);
|
|
7316
|
+
var properties = [
|
|
7317
|
+
// ...Object.getOwnPropertyNames(instance),
|
|
7318
|
+
// ...Object.getOwnPropertyNames(prototype),
|
|
7319
|
+
];
|
|
7320
|
+
var currentClass = instance;
|
|
7321
|
+
while (currentClass && currentClass !== Object) {
|
|
7322
|
+
// console.log('current class', currentClass); // TODO: test if it omits the Object methods
|
|
7323
|
+
properties.push.apply(properties, _toConsumableArray(Object.getOwnPropertyNames(currentClass)));
|
|
7324
|
+
currentClass = Object.getPrototypeOf(currentClass);
|
|
7325
|
+
}
|
|
7326
|
+
properties.forEach(function (property) {
|
|
7327
|
+
var _options$globals, _options$methodWrappe;
|
|
7328
|
+
if (['constructor'].includes(property)) {
|
|
7329
|
+
return;
|
|
7330
|
+
}
|
|
7331
|
+
var _method = instance[property];
|
|
7332
|
+
_method = typeof _method === 'function' && typeof _method.bind === 'function' ? _method.bind(instance) : _method;
|
|
7333
|
+
if (options !== null && options !== void 0 && (_options$globals = options.globals) !== null && _options$globals !== void 0 && _options$globals.canCallAction) {
|
|
7334
|
+
var originalMethod = _method;
|
|
7335
|
+
_method = function method() {
|
|
7336
|
+
var canCall = options.globals.canCallAction({
|
|
7337
|
+
method: _method.name,
|
|
7338
|
+
"class": instance.constructor.name
|
|
7339
|
+
});
|
|
7340
|
+
if (!canCall) {
|
|
7341
|
+
throw new Error("No permissions for call: ".concat(_method.name)); // TODO: consider usage of a specific permissions error
|
|
7342
|
+
}
|
|
7343
|
+
return originalMethod.apply(void 0, arguments);
|
|
7344
|
+
};
|
|
7345
|
+
}
|
|
7346
|
+
if (typeof (options === null || options === void 0 || (_options$methodWrappe = options.methodWrappers) === null || _options$methodWrappe === void 0 ? void 0 : _options$methodWrappe[property]) === 'function') {
|
|
7347
|
+
obj[property] = function () {
|
|
7348
|
+
var _options$methodWrappe2;
|
|
7349
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
7350
|
+
args[_key] = arguments[_key];
|
|
7351
|
+
}
|
|
7352
|
+
return (_options$methodWrappe2 = options.methodWrappers)[property].apply(_options$methodWrappe2, [_method].concat(args));
|
|
7353
|
+
};
|
|
7354
|
+
} else {
|
|
7355
|
+
obj[property] = function () {
|
|
7356
|
+
return _method.apply(void 0, arguments);
|
|
7357
|
+
};
|
|
7358
|
+
}
|
|
7359
|
+
});
|
|
7360
|
+
return obj;
|
|
7361
|
+
};
|
|
7362
|
+
|
|
7363
|
+
},{}],42:[function(require,module,exports){
|
|
7364
|
+
"use strict";
|
|
7365
|
+
|
|
7290
7366
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
7291
7367
|
Object.defineProperty(exports, "__esModule", {
|
|
7292
7368
|
value: true
|
|
@@ -7337,7 +7413,7 @@ var getOrCreateUsersPrivateWorkspaceRecord = exports.getOrCreateUsersPrivateWork
|
|
|
7337
7413
|
};
|
|
7338
7414
|
}();
|
|
7339
7415
|
|
|
7340
|
-
},{"uuid":6}],
|
|
7416
|
+
},{"uuid":6}],43:[function(require,module,exports){
|
|
7341
7417
|
"use strict";
|
|
7342
7418
|
|
|
7343
7419
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -7362,14 +7438,14 @@ var ONTOLOGY_PERMISSION_GROUP = exports.ONTOLOGY_PERMISSION_GROUP = 'octostar:on
|
|
|
7362
7438
|
var ALL_PERMISSIONS = exports.ALL_PERMISSIONS = 'all';
|
|
7363
7439
|
var ALL_PERMISSIONS_ARRAY = exports.ALL_PERMISSIONS_ARRAY = [ALL_PERMISSIONS];
|
|
7364
7440
|
|
|
7365
|
-
},{}],
|
|
7441
|
+
},{}],44:[function(require,module,exports){
|
|
7366
7442
|
"use strict";
|
|
7367
7443
|
|
|
7368
7444
|
Object.defineProperty(exports, "__esModule", {
|
|
7369
7445
|
value: true
|
|
7370
7446
|
});
|
|
7371
7447
|
|
|
7372
|
-
},{}],
|
|
7448
|
+
},{}],45:[function(require,module,exports){
|
|
7373
7449
|
"use strict";
|
|
7374
7450
|
|
|
7375
7451
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octostar/platform-api",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.12",
|
|
4
4
|
"description": "Provides access to the API exposed by Octostar platform to an application run in an iframe",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"octostar",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"rimraf": "^5.0.5",
|
|
39
39
|
"tsup": "^8.4.0",
|
|
40
40
|
"typescript": "^5.8.2",
|
|
41
|
-
"@octostar/platform-types": "0.5.
|
|
41
|
+
"@octostar/platform-types": "0.5.15"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@octostar/platform-types": "^0.5.
|
|
44
|
+
"@octostar/platform-types": "^0.5.15"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|