@sprucelabs/spruce-cli 17.1.0 → 17.1.3
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 +24 -0
- package/build/__tests__/behavioral/AddingADependency.test.js +2 -1
- package/build/__tests__/behavioral/AddingADependency.test.js.map +1 -1
- package/build/__tests__/behavioral/permissions/CreatingPermissions.test.d.ts +7 -0
- package/build/__tests__/behavioral/permissions/CreatingPermissions.test.js +137 -0
- package/build/__tests__/behavioral/permissions/CreatingPermissions.test.js.map +1 -0
- package/build/__tests__/testDirsAndFiles/related_schemas/v2020_10_06/skillWithExtraField.builder.d.ts +10 -2
- package/build/features/FeatureInstaller.d.ts +1 -1
- package/build/features/FeatureInstallerFactory.js +4 -2
- package/build/features/FeatureInstallerFactory.js.map +1 -1
- package/build/features/event/actions/CreateAction.d.ts +24 -16
- package/build/features/event/actions/CreateAction.js +3 -5
- package/build/features/event/actions/CreateAction.js.map +1 -1
- package/build/features/node/actions/UpdateDependenciesAction.js +25 -32
- package/build/features/node/actions/UpdateDependenciesAction.js.map +1 -1
- package/build/features/organization/OrganizationFeature.d.ts +5 -5
- package/build/features/organization/OrganizationFeature.js.map +1 -1
- package/build/features/permission/PermissionFeature.d.ts +15 -0
- package/build/features/permission/PermissionFeature.js +66 -0
- package/build/features/permission/PermissionFeature.js.map +1 -0
- package/build/features/permission/actions/CreateAction.d.ts +46 -0
- package/build/features/permission/actions/CreateAction.js +96 -0
- package/build/features/permission/actions/CreateAction.js.map +1 -0
- package/build/features/skill/actions/RegisterAction.d.ts +2 -0
- package/build/features/skill/actions/RegisterAction.js +4 -2
- package/build/features/skill/actions/RegisterAction.js.map +1 -1
- package/build/features/skill/stores/SkillStore.d.ts +9 -8
- package/build/features/skill/stores/SkillStore.js +4 -3
- package/build/features/skill/stores/SkillStore.js.map +1 -1
- package/build/tests/fixtures/SkillFixture.d.ts +3 -8
- package/build/tests/fixtures/SkillFixture.js.map +1 -1
- package/build/widgets/terminalKit/TkBaseWidget.js +9 -18
- package/build/widgets/terminalKit/TkBaseWidget.js.map +1 -1
- package/package.json +18 -3
- package/src/__tests__/behavioral/AddingADependency.test.ts +1 -0
- package/src/__tests__/behavioral/permissions/CreatingPermissions.test.ts +25 -0
- package/src/features/FeatureInstallerFactory.ts +3 -0
- package/src/features/event/actions/CreateAction.ts +5 -6
- package/src/features/organization/OrganizationFeature.ts +6 -6
- package/src/features/permission/PermissionFeature.ts +28 -0
- package/src/features/permission/actions/CreateAction.ts +29 -0
- package/src/features/skill/actions/RegisterAction.ts +2 -0
- package/src/features/skill/stores/SkillStore.ts +13 -11
- package/src/tests/fixtures/SkillFixture.ts +6 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrganizationFeature.js","names":["OrganizationFeature","code","isRequired","diskUtil","resolvePath","__dirname","AbstractFeature"],"sources":["../../../src/features/organization/OrganizationFeature.ts"],"sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport AbstractFeature, { FeatureDependency } from '../AbstractFeature'\nimport { FeatureCode } from '../features.types'\n\
|
|
1
|
+
{"version":3,"file":"OrganizationFeature.js","names":["OrganizationFeature","code","isRequired","diskUtil","resolvePath","__dirname","AbstractFeature"],"sources":["../../../src/features/organization/OrganizationFeature.ts"],"sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport AbstractFeature, { FeatureDependency } from '../AbstractFeature'\nimport { FeatureCode } from '../features.types'\n\nexport default class OrganizationFeature extends AbstractFeature {\n\tpublic code: FeatureCode = 'organization'\n\tpublic nameReadable = 'Organization'\n\tpublic description = 'Manage the organizations you are part of'\n\tpublic dependencies: FeatureDependency[] = [\n\t\t{\n\t\t\tcode: 'skill',\n\t\t\tisRequired: true,\n\t\t},\n\t\t{\n\t\t\tcode: 'event',\n\t\t\tisRequired: true,\n\t\t},\n\t]\n\tpublic packageDependencies = []\n\n\tpublic actionsDir = diskUtil.resolvePath(__dirname, 'actions')\n}\n\ndeclare module '../../features/features.types' {\n\tinterface FeatureMap {\n\t\torganization: OrganizationFeature\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;IAGqBA,mB;;;;;;;;;;;;;;;6FACO,c;qGACL,c;oGACD,0C;qGACsB,CAC1C;MACCC,IAAI,EAAE,OADP;MAECC,UAAU,EAAE;IAFb,CAD0C,EAK1C;MACCD,IAAI,EAAE,OADP;MAECC,UAAU,EAAE;IAFb,CAL0C,C;4GAUd,E;mGAETC,0BAAA,CAASC,WAAT,CAAqBC,SAArB,EAAgC,SAAhC,C;;;;;EAhB4BC,4B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import AbstractFeature, { FeatureDependency } from '../AbstractFeature';
|
|
2
|
+
import { FeatureCode } from '../features.types';
|
|
3
|
+
export default class PermissionFeature extends AbstractFeature {
|
|
4
|
+
code: FeatureCode;
|
|
5
|
+
nameReadable: string;
|
|
6
|
+
description: string;
|
|
7
|
+
dependencies: FeatureDependency[];
|
|
8
|
+
packageDependencies: never[];
|
|
9
|
+
actionsDir: string;
|
|
10
|
+
}
|
|
11
|
+
declare module '../../features/features.types' {
|
|
12
|
+
interface FeatureMap {
|
|
13
|
+
permission: PermissionFeature;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
+
|
|
24
|
+
var _spruceSkillUtils = require("@sprucelabs/spruce-skill-utils");
|
|
25
|
+
|
|
26
|
+
var _AbstractFeature2 = _interopRequireDefault(require("../AbstractFeature"));
|
|
27
|
+
|
|
28
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
29
|
+
|
|
30
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
31
|
+
|
|
32
|
+
var PermissionFeature = /*#__PURE__*/function (_AbstractFeature) {
|
|
33
|
+
(0, _inherits2["default"])(PermissionFeature, _AbstractFeature);
|
|
34
|
+
|
|
35
|
+
var _super = _createSuper(PermissionFeature);
|
|
36
|
+
|
|
37
|
+
function PermissionFeature() {
|
|
38
|
+
var _this;
|
|
39
|
+
|
|
40
|
+
(0, _classCallCheck2["default"])(this, PermissionFeature);
|
|
41
|
+
|
|
42
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
43
|
+
args[_key] = arguments[_key];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
47
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "code", 'permission');
|
|
48
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "nameReadable", 'permission');
|
|
49
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "description", 'Manage permissions for your skill');
|
|
50
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "dependencies", [{
|
|
51
|
+
code: 'skill',
|
|
52
|
+
isRequired: true
|
|
53
|
+
}, {
|
|
54
|
+
code: 'event',
|
|
55
|
+
isRequired: true
|
|
56
|
+
}]);
|
|
57
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "packageDependencies", []);
|
|
58
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "actionsDir", _spruceSkillUtils.diskUtil.resolvePath(__dirname, 'actions'));
|
|
59
|
+
return _this;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return (0, _createClass2["default"])(PermissionFeature);
|
|
63
|
+
}(_AbstractFeature2["default"]);
|
|
64
|
+
|
|
65
|
+
exports["default"] = PermissionFeature;
|
|
66
|
+
//# sourceMappingURL=PermissionFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PermissionFeature.js","names":["PermissionFeature","code","isRequired","diskUtil","resolvePath","__dirname","AbstractFeature"],"sources":["../../../src/features/permission/PermissionFeature.ts"],"sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport AbstractFeature, { FeatureDependency } from '../AbstractFeature'\nimport { FeatureCode } from '../features.types'\n\nexport default class PermissionFeature extends AbstractFeature {\n\tpublic code: FeatureCode = 'permission'\n\tpublic nameReadable = 'permission'\n\tpublic description = 'Manage permissions for your skill'\n\tpublic dependencies: FeatureDependency[] = [\n\t\t{\n\t\t\tcode: 'skill',\n\t\t\tisRequired: true,\n\t\t},\n\t\t{\n\t\t\tcode: 'event',\n\t\t\tisRequired: true,\n\t\t},\n\t]\n\tpublic packageDependencies = []\n\n\tpublic actionsDir = diskUtil.resolvePath(__dirname, 'actions')\n}\n\ndeclare module '../../features/features.types' {\n\tinterface FeatureMap {\n\t\tpermission: PermissionFeature\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;IAGqBA,iB;;;;;;;;;;;;;;;6FACO,Y;qGACL,Y;oGACD,mC;qGACsB,CAC1C;MACCC,IAAI,EAAE,OADP;MAECC,UAAU,EAAE;IAFb,CAD0C,EAK1C;MACCD,IAAI,EAAE,OADP;MAECC,UAAU,EAAE;IAFb,CAL0C,C;4GAUd,E;mGAETC,0BAAA,CAASC,WAAT,CAAqBC,SAArB,EAAgC,SAAhC,C;;;;;EAhB0BC,4B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { SchemaValues } from '@sprucelabs/schema';
|
|
2
|
+
import AbstractAction from '../../AbstractAction';
|
|
3
|
+
import { FeatureActionResponse } from '../../features.types';
|
|
4
|
+
declare const schema: {
|
|
5
|
+
id: string;
|
|
6
|
+
fields: {
|
|
7
|
+
nameReadable: {
|
|
8
|
+
label: "Readable name";
|
|
9
|
+
type: "text";
|
|
10
|
+
isRequired: true;
|
|
11
|
+
hint: "The name people will read";
|
|
12
|
+
options: undefined;
|
|
13
|
+
};
|
|
14
|
+
nameKebab: {
|
|
15
|
+
label: "Kebab case name";
|
|
16
|
+
type: "text";
|
|
17
|
+
hint: "kebab-case of the name";
|
|
18
|
+
options: undefined;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
declare type OptionsSchema = typeof schema;
|
|
23
|
+
declare type Options = SchemaValues<OptionsSchema>;
|
|
24
|
+
export default class CreateAction extends AbstractAction<OptionsSchema> {
|
|
25
|
+
optionsSchema: {
|
|
26
|
+
id: string;
|
|
27
|
+
fields: {
|
|
28
|
+
nameReadable: {
|
|
29
|
+
label: "Readable name";
|
|
30
|
+
type: "text";
|
|
31
|
+
isRequired: true;
|
|
32
|
+
hint: "The name people will read";
|
|
33
|
+
options: undefined;
|
|
34
|
+
};
|
|
35
|
+
nameKebab: {
|
|
36
|
+
label: "Kebab case name";
|
|
37
|
+
type: "text";
|
|
38
|
+
hint: "kebab-case of the name";
|
|
39
|
+
options: undefined;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
invocationMessage: string;
|
|
44
|
+
execute(_options: Options): Promise<FeatureActionResponse>;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
19
|
+
|
|
20
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
+
|
|
22
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
+
|
|
24
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
+
|
|
26
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
+
|
|
28
|
+
var _schema = require("@sprucelabs/schema");
|
|
29
|
+
|
|
30
|
+
var _namedTemplateItem = _interopRequireDefault(require("../../../.spruce/schemas/spruceCli/v2020_07_22/namedTemplateItem.schema"));
|
|
31
|
+
|
|
32
|
+
var _AbstractAction2 = _interopRequireDefault(require("../../AbstractAction"));
|
|
33
|
+
|
|
34
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
35
|
+
|
|
36
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
|
+
|
|
38
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
39
|
+
|
|
40
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
41
|
+
|
|
42
|
+
var schema = (0, _schema.buildSchema)({
|
|
43
|
+
id: 'createPermission',
|
|
44
|
+
fields: _objectSpread({}, (0, _schema.pickFields)(_namedTemplateItem["default"].fields, ['nameReadable', 'nameKebab']))
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
var CreateAction = /*#__PURE__*/function (_AbstractAction) {
|
|
48
|
+
(0, _inherits2["default"])(CreateAction, _AbstractAction);
|
|
49
|
+
|
|
50
|
+
var _super = _createSuper(CreateAction);
|
|
51
|
+
|
|
52
|
+
function CreateAction() {
|
|
53
|
+
var _this;
|
|
54
|
+
|
|
55
|
+
(0, _classCallCheck2["default"])(this, CreateAction);
|
|
56
|
+
|
|
57
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
58
|
+
args[_key] = arguments[_key];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
62
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "optionsSchema", schema);
|
|
63
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "invocationMessage", 'Creating a permission contract... 🛡');
|
|
64
|
+
return _this;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
(0, _createClass2["default"])(CreateAction, [{
|
|
68
|
+
key: "execute",
|
|
69
|
+
value: function () {
|
|
70
|
+
var _execute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_options) {
|
|
71
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
72
|
+
while (1) {
|
|
73
|
+
switch (_context.prev = _context.next) {
|
|
74
|
+
case 0:
|
|
75
|
+
return _context.abrupt("return", {});
|
|
76
|
+
|
|
77
|
+
case 1:
|
|
78
|
+
case "end":
|
|
79
|
+
return _context.stop();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}, _callee);
|
|
83
|
+
}));
|
|
84
|
+
|
|
85
|
+
function execute(_x) {
|
|
86
|
+
return _execute.apply(this, arguments);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return execute;
|
|
90
|
+
}()
|
|
91
|
+
}]);
|
|
92
|
+
return CreateAction;
|
|
93
|
+
}(_AbstractAction2["default"]);
|
|
94
|
+
|
|
95
|
+
exports["default"] = CreateAction;
|
|
96
|
+
//# sourceMappingURL=CreateAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateAction.js","names":["schema","buildSchema","id","fields","pickFields","namedTemplateItemSchema","CreateAction","_options","AbstractAction"],"sources":["../../../../src/features/permission/actions/CreateAction.ts"],"sourcesContent":["import { buildSchema, pickFields, SchemaValues } from '@sprucelabs/schema'\nimport namedTemplateItemSchema from '#spruce/schemas/spruceCli/v2020_07_22/namedTemplateItem.schema'\nimport AbstractAction from '../../AbstractAction'\nimport { FeatureActionResponse } from '../../features.types'\n\nconst schema = buildSchema({\n\tid: 'createPermission',\n\tfields: {\n\t\t...pickFields(namedTemplateItemSchema.fields, [\n\t\t\t'nameReadable',\n\t\t\t'nameKebab',\n\t\t]),\n\t},\n})\n\ntype OptionsSchema = typeof schema\ntype Options = SchemaValues<OptionsSchema>\n\nexport default class CreateAction extends AbstractAction<OptionsSchema> {\n\tpublic optionsSchema = schema\n\tpublic invocationMessage = 'Creating a permission contract... 🛡'\n\n\tpublic async execute(_options: Options): Promise<FeatureActionResponse> {\n\t\t// const { nameKebab, nameReadable } =\n\t\t// \tthis.validateAndNormalizeOptions(options)\n\n\t\treturn {}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;AAGA,IAAMA,MAAM,GAAG,IAAAC,mBAAA,EAAY;EAC1BC,EAAE,EAAE,kBADsB;EAE1BC,MAAM,oBACF,IAAAC,kBAAA,EAAWC,6BAAA,CAAwBF,MAAnC,EAA2C,CAC7C,cAD6C,EAE7C,WAF6C,CAA3C,CADE;AAFoB,CAAZ,CAAf;;IAaqBG,Y;;;;;;;;;;;;;;;sGACGN,M;0GACI,sC;;;;;;;mGAE3B,iBAAqBO,QAArB;QAAA;UAAA;YAAA;cAAA;gBAAA,iCAIQ,EAJR;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;EAJyCC,2B"}
|
|
@@ -43,12 +43,14 @@ var optionsSchema = (0, _schema.buildSchema)({
|
|
|
43
43
|
nameReadable: {
|
|
44
44
|
type: 'text',
|
|
45
45
|
label: "What is your skill's name?",
|
|
46
|
-
isRequired: true
|
|
46
|
+
isRequired: true,
|
|
47
|
+
hint: 'The name people will see with their special eyes!'
|
|
47
48
|
},
|
|
48
49
|
nameKebab: {
|
|
49
50
|
type: 'text',
|
|
50
51
|
label: 'Namespace',
|
|
51
|
-
isRequired: true
|
|
52
|
+
isRequired: true,
|
|
53
|
+
hint: 'The namespace of your skill in-kebab-case'
|
|
52
54
|
},
|
|
53
55
|
description: {
|
|
54
56
|
type: 'text',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisterAction.js","names":["optionsSchema","buildSchema","id","description","fields","nameReadable","type","label","isRequired","nameKebab","RegisterAction","options","validateAndNormalizeOptions","connectToApi","client","emit","payload","name","slug","results","eventResponseUtil","getFirstResponseOrThrow","skill","summaryLines","generateSkillSummaryLines","Service","updateCurrentSkill","hints","meta","errors","AbstractAction","apiKey"],"sources":["../../../../src/features/skill/actions/RegisterAction.ts"],"sourcesContent":["import { buildSchema, SchemaValues } from '@sprucelabs/schema'\nimport { eventResponseUtil } from '@sprucelabs/spruce-event-utils'\nimport { RegisteredSkill } from '../../../types/cli.types'\nimport AbstractAction from '../../AbstractAction'\nimport { FeatureActionResponse } from '../../features.types'\n\nconst optionsSchema = buildSchema({\n\tid: 'registerSkillAction',\n\tdescription:\n\t\t'Register your skill with Mercury so you can start communicating with other skills.',\n\tfields: {\n\t\tnameReadable: {\n\t\t\ttype: 'text',\n\t\t\tlabel: `What is your skill's name?`,\n\t\t\tisRequired: true,\n\t\t},\n\t\tnameKebab: {\n\t\t\ttype: 'text',\n\t\t\tlabel: 'Namespace',\n\t\t\tisRequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: 'text',\n\t\t\tlabel: 'Describe your skill',\n\t\t},\n\t},\n})\n\ntype OptionsSchema = typeof optionsSchema\ntype Options = SchemaValues<OptionsSchema>\n\nexport default class RegisterAction extends AbstractAction<OptionsSchema> {\n\tpublic optionsSchema: OptionsSchema = optionsSchema\n\tpublic commandAliases = ['register.skill', 'register']\n\tpublic invocationMessage = 'Registering your skill... ⚡️'\n\n\tpublic async execute(options: Options): Promise<FeatureActionResponse> {\n\t\tconst { nameReadable, nameKebab, description } =\n\t\t\tthis.validateAndNormalizeOptions(options)\n\n\t\tconst client = await this.connectToApi()\n\t\tconst results = await client.emit('register-skill::v2020_12_25', {\n\t\t\tpayload: {\n\t\t\t\tname: nameReadable,\n\t\t\t\tslug: nameKebab,\n\t\t\t\tdescription,\n\t\t\t},\n\t\t})\n\n\t\ttry {\n\t\t\tconst { skill } = eventResponseUtil.getFirstResponseOrThrow(results)\n\n\t\t\tconst summaryLines = generateSkillSummaryLines(skill)\n\n\t\t\tthis.Service('auth').updateCurrentSkill(skill)\n\n\t\t\treturn {\n\t\t\t\tsummaryLines,\n\t\t\t\thints: [\n\t\t\t\t\t'Your skill is registered.',\n\t\t\t\t\t'You can check your .env for more details.',\n\t\t\t\t\t\"If you're ready to deploy, try `spruce deploy`. 🚀\",\n\t\t\t\t],\n\t\t\t\tmeta: {\n\t\t\t\t\tskill,\n\t\t\t\t},\n\t\t\t}\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\thints: [\n\t\t\t\t\t`If you've already registered your skill, try 'spruce login.skill'!`,\n\t\t\t\t],\n\t\t\t\terrors: [err],\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function generateSkillSummaryLines(skill: RegisteredSkill) {\n\treturn [\n\t\t`Name: ${skill.name}`,\n\t\t`Slug: ${skill.slug}`,\n\t\t`ID: ${skill.id}`,\n\t\t`API Key: ${skill.apiKey}`,\n\t]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;;;;;AAGA,IAAMA,aAAa,GAAG,IAAAC,mBAAA,EAAY;EACjCC,EAAE,EAAE,qBAD6B;EAEjCC,WAAW,EACV,oFAHgC;EAIjCC,MAAM,EAAE;IACPC,YAAY,EAAE;MACbC,IAAI,EAAE,MADO;MAEbC,KAAK,8BAFQ;MAGbC,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"RegisterAction.js","names":["optionsSchema","buildSchema","id","description","fields","nameReadable","type","label","isRequired","hint","nameKebab","RegisterAction","options","validateAndNormalizeOptions","connectToApi","client","emit","payload","name","slug","results","eventResponseUtil","getFirstResponseOrThrow","skill","summaryLines","generateSkillSummaryLines","Service","updateCurrentSkill","hints","meta","errors","AbstractAction","apiKey"],"sources":["../../../../src/features/skill/actions/RegisterAction.ts"],"sourcesContent":["import { buildSchema, SchemaValues } from '@sprucelabs/schema'\nimport { eventResponseUtil } from '@sprucelabs/spruce-event-utils'\nimport { RegisteredSkill } from '../../../types/cli.types'\nimport AbstractAction from '../../AbstractAction'\nimport { FeatureActionResponse } from '../../features.types'\n\nconst optionsSchema = buildSchema({\n\tid: 'registerSkillAction',\n\tdescription:\n\t\t'Register your skill with Mercury so you can start communicating with other skills.',\n\tfields: {\n\t\tnameReadable: {\n\t\t\ttype: 'text',\n\t\t\tlabel: `What is your skill's name?`,\n\t\t\tisRequired: true,\n\t\t\thint: 'The name people will see with their special eyes!',\n\t\t},\n\t\tnameKebab: {\n\t\t\ttype: 'text',\n\t\t\tlabel: 'Namespace',\n\t\t\tisRequired: true,\n\t\t\thint: 'The namespace of your skill in-kebab-case',\n\t\t},\n\t\tdescription: {\n\t\t\ttype: 'text',\n\t\t\tlabel: 'Describe your skill',\n\t\t},\n\t},\n})\n\ntype OptionsSchema = typeof optionsSchema\ntype Options = SchemaValues<OptionsSchema>\n\nexport default class RegisterAction extends AbstractAction<OptionsSchema> {\n\tpublic optionsSchema: OptionsSchema = optionsSchema\n\tpublic commandAliases = ['register.skill', 'register']\n\tpublic invocationMessage = 'Registering your skill... ⚡️'\n\n\tpublic async execute(options: Options): Promise<FeatureActionResponse> {\n\t\tconst { nameReadable, nameKebab, description } =\n\t\t\tthis.validateAndNormalizeOptions(options)\n\n\t\tconst client = await this.connectToApi()\n\t\tconst results = await client.emit('register-skill::v2020_12_25', {\n\t\t\tpayload: {\n\t\t\t\tname: nameReadable,\n\t\t\t\tslug: nameKebab,\n\t\t\t\tdescription,\n\t\t\t},\n\t\t})\n\n\t\ttry {\n\t\t\tconst { skill } = eventResponseUtil.getFirstResponseOrThrow(results)\n\n\t\t\tconst summaryLines = generateSkillSummaryLines(skill)\n\n\t\t\tthis.Service('auth').updateCurrentSkill(skill)\n\n\t\t\treturn {\n\t\t\t\tsummaryLines,\n\t\t\t\thints: [\n\t\t\t\t\t'Your skill is registered.',\n\t\t\t\t\t'You can check your .env for more details.',\n\t\t\t\t\t\"If you're ready to deploy, try `spruce deploy`. 🚀\",\n\t\t\t\t],\n\t\t\t\tmeta: {\n\t\t\t\t\tskill,\n\t\t\t\t},\n\t\t\t}\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\thints: [\n\t\t\t\t\t`If you've already registered your skill, try 'spruce login.skill'!`,\n\t\t\t\t],\n\t\t\t\terrors: [err],\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function generateSkillSummaryLines(skill: RegisteredSkill) {\n\treturn [\n\t\t`Name: ${skill.name}`,\n\t\t`Slug: ${skill.slug}`,\n\t\t`ID: ${skill.id}`,\n\t\t`API Key: ${skill.apiKey}`,\n\t]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;;;;;AA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F,iCAoBS;kBACNC,YAAY,EAAZA,YADM;kBAENI,KAAK,EAAE,CACN,2BADM,EAEN,2CAFM,EAGN,oDAHM,CAFD;kBAONC,IAAI,EAAE;oBACLN,KAAK,EAALA;kBADK;gBAPA,CApBT;;cAAA;gBAAA;gBAAA;gBAAA,iCAgCS;kBACNK,KAAK,EAAE,sEADD;kBAINE,MAAM,EAAE;gBAJF,CAhCT;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;EAL2CC,2B;;;;AA+CrC,SAASN,yBAAT,CAAmCF,KAAnC,EAA2D;EACjE,OAAO,iBACGA,KAAK,CAACL,IADT,mBAEGK,KAAK,CAACJ,IAFT,iBAGCI,KAAK,CAACrB,EAHP,sBAIMqB,KAAK,CAACS,MAJZ,EAAP;AAMA"}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import AbstractStore from '../../../stores/AbstractStore';
|
|
2
2
|
import { CurrentSkill, RegisteredSkill } from '../../../types/cli.types';
|
|
3
|
-
export interface CreateSkill {
|
|
4
|
-
name: string;
|
|
5
|
-
slug: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface RegisterSkillOptions {
|
|
9
|
-
isRegisteringCurrentSkill?: boolean;
|
|
10
|
-
}
|
|
11
3
|
export default class SkillStore extends AbstractStore {
|
|
12
4
|
readonly name = "skill";
|
|
13
5
|
private static currentSkill?;
|
|
@@ -28,3 +20,12 @@ export default class SkillStore extends AbstractStore {
|
|
|
28
20
|
namespaces?: string[];
|
|
29
21
|
}): Promise<import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/mercury-types").SpruceSchemas.Mercury.v2020_12_25.ListSkillsSkillsResponsePayloadSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<import("@sprucelabs/mercury-types").SpruceSchemas.Mercury.v2020_12_25.ListSkillsSkillsResponsePayloadSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/mercury-types").SpruceSchemas.Mercury.v2020_12_25.ListSkillsSkillsResponsePayloadSchema, false>>[]>;
|
|
30
22
|
}
|
|
23
|
+
export interface CreateSkill {
|
|
24
|
+
name: string;
|
|
25
|
+
slug?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
isPublished?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface RegisterSkillOptions {
|
|
30
|
+
isRegisteringCurrentSkill?: boolean;
|
|
31
|
+
}
|
|
@@ -64,7 +64,7 @@ var SkillStore = /*#__PURE__*/function (_AbstractStore) {
|
|
|
64
64
|
key: "register",
|
|
65
65
|
value: function () {
|
|
66
66
|
var _register = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(values, options) {
|
|
67
|
-
var isRegisteringCurrentSkill, name, slug, description, client, results, _eventResponseUtil$ge, skill;
|
|
67
|
+
var isRegisteringCurrentSkill, name, slug, description, isPublished, client, results, _eventResponseUtil$ge, skill;
|
|
68
68
|
|
|
69
69
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
70
70
|
while (1) {
|
|
@@ -72,7 +72,7 @@ var SkillStore = /*#__PURE__*/function (_AbstractStore) {
|
|
|
72
72
|
case 0:
|
|
73
73
|
isRegisteringCurrentSkill = (options === null || options === void 0 ? void 0 : options.isRegisteringCurrentSkill) !== false;
|
|
74
74
|
isRegisteringCurrentSkill && this.assertInSkill();
|
|
75
|
-
name = values.name, slug = values.slug, description = values.description;
|
|
75
|
+
name = values.name, slug = values.slug, description = values.description, isPublished = values.isPublished;
|
|
76
76
|
_context.next = 5;
|
|
77
77
|
return this.connectToApi();
|
|
78
78
|
|
|
@@ -83,7 +83,8 @@ var SkillStore = /*#__PURE__*/function (_AbstractStore) {
|
|
|
83
83
|
payload: {
|
|
84
84
|
name: name,
|
|
85
85
|
slug: slug,
|
|
86
|
-
description: description
|
|
86
|
+
description: description,
|
|
87
|
+
isPublished: isPublished
|
|
87
88
|
}
|
|
88
89
|
});
|
|
89
90
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkillStore.js","names":["SkillStore","values","options","isRegisteringCurrentSkill","assertInSkill","name","slug","description","connectToApi","client","emit","payload","results","eventResponseUtil","getFirstResponseOrThrow","skill","setCurrentSkillsNamespace","Service","updateCurrentSkill","isInstalled","isMarkedAsInstalled","SpruceError","code","currentSkill","getCurrentSkill","shouldAuthAsCurrentSkill","target","skillId","id","response","namespacePascal","namesUtil","toPascal","isRegistered","apiKey","getNamespaceFromPkg","getEventNamespaceForNotRegistered","getSkillDescriptionFromPkg","loadCurrentSkill","pkg","nameFromPackage","get","Error","fallback","current","namespace","isCurrentSkillRegistered","friendlyMessage","updateCurrentSkillNamespace","undefined","logoutCurrentSkill","fetchAllSkills","shouldOnlyShowMine","query","skills","AbstractStore"],"sources":["../../../../src/features/skill/stores/SkillStore.ts"],"sourcesContent":["import { eventResponseUtil } from '@sprucelabs/spruce-event-utils'\nimport { namesUtil } from '@sprucelabs/spruce-skill-utils'\nimport SpruceError from '../../../errors/SpruceError'\nimport AbstractStore from '../../../stores/AbstractStore'\nimport { CurrentSkill, RegisteredSkill } from '../../../types/cli.types'\n\nexport interface CreateSkill {\n\tname: string\n\tslug: string\n\tdescription?: string\n}\n\nexport interface RegisterSkillOptions {\n\tisRegisteringCurrentSkill?: boolean\n}\n\nexport default class SkillStore extends AbstractStore {\n\tpublic readonly name = 'skill'\n\tprivate static currentSkill?: CurrentSkill\n\n\tpublic static clearCurrentSkill() {\n\t\tthis.currentSkill = undefined\n\t}\n\n\tpublic async register(\n\t\tvalues: CreateSkill,\n\t\toptions?: RegisterSkillOptions\n\t): Promise<RegisteredSkill> {\n\t\tconst isRegisteringCurrentSkill =\n\t\t\toptions?.isRegisteringCurrentSkill !== false\n\n\t\tisRegisteringCurrentSkill && this.assertInSkill()\n\n\t\tconst { name, slug, description } = values\n\t\tconst client = await this.connectToApi()\n\n\t\tconst results = await client.emit('register-skill::v2020_12_25', {\n\t\t\tpayload: {\n\t\t\t\tname,\n\t\t\t\tslug,\n\t\t\t\tdescription,\n\t\t\t},\n\t\t})\n\n\t\tconst { skill } = eventResponseUtil.getFirstResponseOrThrow(results)\n\n\t\tif (isRegisteringCurrentSkill) {\n\t\t\tawait this.setCurrentSkillsNamespace(skill.slug)\n\t\t\tthis.Service('auth').updateCurrentSkill(skill)\n\t\t}\n\n\t\treturn skill\n\t}\n\n\tprivate assertInSkill() {\n\t\tconst isInstalled = this.Service('settings').isMarkedAsInstalled('skill')\n\n\t\tif (!isInstalled) {\n\t\t\tthrow new SpruceError({ code: 'DIRECTORY_NOT_SKILL' })\n\t\t}\n\t}\n\n\tpublic async loadCurrentSkill(): Promise<CurrentSkill> {\n\t\tif (SkillStore.currentSkill) {\n\t\t\treturn SkillStore.currentSkill\n\t\t}\n\n\t\tthis.assertInSkill()\n\n\t\tconst currentSkill = this.Service('auth').getCurrentSkill()\n\n\t\tif (currentSkill) {\n\t\t\tconst client = await this.connectToApi({ shouldAuthAsCurrentSkill: true })\n\n\t\t\tconst response = await client.emit('get-skill::v2020_12_25', {\n\t\t\t\ttarget: {\n\t\t\t\t\tskillId: currentSkill.id,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tconst { skill } = eventResponseUtil.getFirstResponseOrThrow(response)\n\n\t\t\tSkillStore.currentSkill = {\n\t\t\t\t...skill,\n\t\t\t\tnamespacePascal: namesUtil.toPascal(skill.slug),\n\t\t\t\tisRegistered: true,\n\t\t\t\tapiKey: currentSkill.apiKey,\n\t\t\t}\n\n\t\t\treturn SkillStore.currentSkill as CurrentSkill\n\t\t}\n\n\t\treturn {\n\t\t\tname: this.getNamespaceFromPkg(),\n\t\t\tnamespacePascal: this.getEventNamespaceForNotRegistered(),\n\t\t\tdescription: this.getSkillDescriptionFromPkg(),\n\t\t\tisRegistered: false,\n\t\t}\n\t}\n\n\tpublic async isCurrentSkillRegistered() {\n\t\tconst skill = await this.loadCurrentSkill()\n\t\treturn skill.isRegistered\n\t}\n\n\tprivate getNamespaceFromPkg() {\n\t\tconst pkg = this.Service('pkg')\n\t\tconst nameFromPackage = pkg.get('skill.namespace')\n\t\tif (!nameFromPackage) {\n\t\t\tthrow new Error(\n\t\t\t\t'You need need to set skill.namespace in the package.json'\n\t\t\t)\n\t\t}\n\t\treturn nameFromPackage\n\t}\n\n\tpublic async loadCurrentSkillsNamespace() {\n\t\tconst fallback = namesUtil.toPascal(this.getNamespaceFromPkg())\n\n\t\tif (this.Service('auth').getCurrentSkill()) {\n\t\t\tconst current = await this.loadCurrentSkill()\n\t\t\treturn namesUtil.toPascal(current.slug ?? fallback)\n\t\t}\n\n\t\treturn fallback\n\t}\n\n\tpublic async setCurrentSkillsNamespace(namespace: string) {\n\t\tlet isRegistered = false\n\t\ttry {\n\t\t\tisRegistered = await this.isCurrentSkillRegistered()\n\t\t\t// eslint-disable-next-line no-empty\n\t\t} catch {}\n\n\t\tif (isRegistered) {\n\t\t\tthrow new SpruceError({\n\t\t\t\tcode: 'GENERIC',\n\t\t\t\tfriendlyMessage: `You can't set the namespace of a skill that is registered.`,\n\t\t\t})\n\t\t}\n\n\t\tthis.Service('auth').updateCurrentSkillNamespace(namespace)\n\t}\n\n\tprivate getEventNamespaceForNotRegistered() {\n\t\treturn namesUtil.toPascal(this.getNamespaceFromPkg())\n\t}\n\n\tprivate getSkillDescriptionFromPkg() {\n\t\tconst pkg = this.Service('pkg')\n\t\treturn pkg.get('description')\n\t}\n\n\tpublic async unregisterSkill(skillId: string) {\n\t\tconst client = await this.connectToApi()\n\n\t\tconst response = await client.emit('unregister-skill::v2020_12_25', {\n\t\t\ttarget: {\n\t\t\t\tskillId,\n\t\t\t},\n\t\t})\n\n\t\teventResponseUtil.getFirstResponseOrThrow(response)\n\n\t\tif (SkillStore.currentSkill?.id === skillId) {\n\t\t\tSkillStore.currentSkill = undefined\n\t\t\tthis.Service('auth').logoutCurrentSkill()\n\t\t}\n\t}\n\n\tpublic async fetchMySkills() {\n\t\treturn this.fetchAllSkills({ shouldOnlyShowMine: true })\n\t}\n\n\tpublic async fetchAllSkills(query?: {\n\t\tshouldOnlyShowMine?: boolean\n\t\tnamespaces?: string[]\n\t}) {\n\t\tconst client = await this.connectToApi()\n\n\t\tconst response = await client.emit('list-skills::v2020_12_25', {\n\t\t\tpayload: {\n\t\t\t\t...query,\n\t\t\t},\n\t\t})\n\n\t\tconst { skills } = eventResponseUtil.getFirstResponseOrThrow(response)\n\n\t\treturn skills\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;IAaqBA,U;;;;;;;;;;;;;;;6FACG,O;;;;;;;oGAOvB,iBACCC,MADD,EAECC,OAFD;QAAA;;QAAA;UAAA;YAAA;cAAA;gBAIOC,yBAJP,GAKE,CAAAD,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEC,yBAAT,MAAuC,KALzC;gBAOCA,yBAAyB,IAAI,KAAKC,aAAL,EAA7B;gBAEQC,IATT,GASqCJ,MATrC,CASSI,IATT,EASeC,IATf,GASqCL,MATrC,CASeK,IATf,EASqBC,WATrB,GASqCN,MATrC,CASqBM,WATrB;gBAAA;gBAAA,OAUsB,KAAKC,YAAL,EAVtB;;cAAA;gBAUOC,MAVP;gBAAA;gBAAA,OAYuBA,MAAM,CAACC,IAAP,CAAY,6BAAZ,EAA2C;kBAChEC,OAAO,EAAE;oBACRN,IAAI,EAAJA,IADQ;oBAERC,IAAI,EAAJA,IAFQ;oBAGRC,WAAW,EAAXA;kBAHQ;gBADuD,CAA3C,CAZvB;;cAAA;gBAYOK,OAZP;gBAAA,wBAoBmBC,mCAAA,CAAkBC,uBAAlB,CAA0CF,OAA1C,CApBnB,EAoBSG,KApBT,yBAoBSA,KApBT;;gBAAA,KAsBKZ,yBAtBL;kBAAA;kBAAA;gBAAA;;gBAAA;gBAAA,OAuBQ,KAAKa,yBAAL,CAA+BD,KAAK,CAACT,IAArC,CAvBR;;cAAA;gBAwBE,KAAKW,OAAL,CA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AkB,EAAE;gBAAtB,CAApB,CADR;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;;0GAIA,kBAA4BC,KAA5B;QAAA;;QAAA;UAAA;YAAA;cAAA;gBAAA;gBAAA,OAIsB,KAAK7C,YAAL,EAJtB;;cAAA;gBAIOC,MAJP;gBAAA;gBAAA,OAMwBA,MAAM,CAACC,IAAP,CAAY,0BAAZ,EAAwC;kBAC9DC,OAAO,oBACH0C,KADG;gBADuD,CAAxC,CANxB;;cAAA;gBAMOxB,QANP;gBAAA,yBAYoBhB,mCAAA,CAAkBC,uBAAlB,CAA0Ce,QAA1C,CAZpB,EAYSyB,MAZT,0BAYSA,MAZT;gBAAA,kCAcQA,MAdR;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;WA1JA,6BAAkC;MACjC,KAAK/B,YAAL,GAAoB0B,SAApB;IACA;;;EANsCM,0B;;;iCAAnBvD,U"}
|
|
1
|
+
{"version":3,"file":"SkillStore.js","names":["SkillStore","values","options","isRegisteringCurrentSkill","assertInSkill","name","slug","description","isPublished","connectToApi","client","emit","payload","results","eventResponseUtil","getFirstResponseOrThrow","skill","setCurrentSkillsNamespace","Service","updateCurrentSkill","isInstalled","isMarkedAsInstalled","SpruceError","code","currentSkill","getCurrentSkill","shouldAuthAsCurrentSkill","target","skillId","id","response","namespacePascal","namesUtil","toPascal","isRegistered","apiKey","getNamespaceFromPkg","getEventNamespaceForNotRegistered","getSkillDescriptionFromPkg","loadCurrentSkill","pkg","nameFromPackage","get","Error","fallback","current","namespace","isCurrentSkillRegistered","friendlyMessage","updateCurrentSkillNamespace","undefined","logoutCurrentSkill","fetchAllSkills","shouldOnlyShowMine","query","skills","AbstractStore"],"sources":["../../../../src/features/skill/stores/SkillStore.ts"],"sourcesContent":["import { eventResponseUtil } from '@sprucelabs/spruce-event-utils'\nimport { namesUtil } from '@sprucelabs/spruce-skill-utils'\nimport SpruceError from '../../../errors/SpruceError'\nimport AbstractStore from '../../../stores/AbstractStore'\nimport { CurrentSkill, RegisteredSkill } from '../../../types/cli.types'\n\nexport default class SkillStore extends AbstractStore {\n\tpublic readonly name = 'skill'\n\tprivate static currentSkill?: CurrentSkill\n\n\tpublic static clearCurrentSkill() {\n\t\tthis.currentSkill = undefined\n\t}\n\n\tpublic async register(\n\t\tvalues: CreateSkill,\n\t\toptions?: RegisterSkillOptions\n\t): Promise<RegisteredSkill> {\n\t\tconst isRegisteringCurrentSkill =\n\t\t\toptions?.isRegisteringCurrentSkill !== false\n\n\t\tisRegisteringCurrentSkill && this.assertInSkill()\n\n\t\tconst { name, slug, description, isPublished } = values\n\t\tconst client = await this.connectToApi()\n\n\t\tconst results = await client.emit('register-skill::v2020_12_25', {\n\t\t\tpayload: {\n\t\t\t\tname,\n\t\t\t\tslug,\n\t\t\t\tdescription,\n\t\t\t\tisPublished,\n\t\t\t},\n\t\t})\n\n\t\tconst { skill } = eventResponseUtil.getFirstResponseOrThrow(results)\n\n\t\tif (isRegisteringCurrentSkill) {\n\t\t\tawait this.setCurrentSkillsNamespace(skill.slug)\n\t\t\tthis.Service('auth').updateCurrentSkill(skill)\n\t\t}\n\n\t\treturn skill\n\t}\n\n\tprivate assertInSkill() {\n\t\tconst isInstalled = this.Service('settings').isMarkedAsInstalled('skill')\n\n\t\tif (!isInstalled) {\n\t\t\tthrow new SpruceError({ code: 'DIRECTORY_NOT_SKILL' })\n\t\t}\n\t}\n\n\tpublic async loadCurrentSkill(): Promise<CurrentSkill> {\n\t\tif (SkillStore.currentSkill) {\n\t\t\treturn SkillStore.currentSkill\n\t\t}\n\n\t\tthis.assertInSkill()\n\n\t\tconst currentSkill = this.Service('auth').getCurrentSkill()\n\n\t\tif (currentSkill) {\n\t\t\tconst client = await this.connectToApi({ shouldAuthAsCurrentSkill: true })\n\n\t\t\tconst response = await client.emit('get-skill::v2020_12_25', {\n\t\t\t\ttarget: {\n\t\t\t\t\tskillId: currentSkill.id,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tconst { skill } = eventResponseUtil.getFirstResponseOrThrow(response)\n\n\t\t\tSkillStore.currentSkill = {\n\t\t\t\t...skill,\n\t\t\t\tnamespacePascal: namesUtil.toPascal(skill.slug),\n\t\t\t\tisRegistered: true,\n\t\t\t\tapiKey: currentSkill.apiKey,\n\t\t\t}\n\n\t\t\treturn SkillStore.currentSkill as CurrentSkill\n\t\t}\n\n\t\treturn {\n\t\t\tname: this.getNamespaceFromPkg(),\n\t\t\tnamespacePascal: this.getEventNamespaceForNotRegistered(),\n\t\t\tdescription: this.getSkillDescriptionFromPkg(),\n\t\t\tisRegistered: false,\n\t\t}\n\t}\n\n\tpublic async isCurrentSkillRegistered() {\n\t\tconst skill = await this.loadCurrentSkill()\n\t\treturn skill.isRegistered\n\t}\n\n\tprivate getNamespaceFromPkg() {\n\t\tconst pkg = this.Service('pkg')\n\t\tconst nameFromPackage = pkg.get('skill.namespace')\n\t\tif (!nameFromPackage) {\n\t\t\tthrow new Error(\n\t\t\t\t'You need need to set skill.namespace in the package.json'\n\t\t\t)\n\t\t}\n\t\treturn nameFromPackage\n\t}\n\n\tpublic async loadCurrentSkillsNamespace() {\n\t\tconst fallback = namesUtil.toPascal(this.getNamespaceFromPkg())\n\n\t\tif (this.Service('auth').getCurrentSkill()) {\n\t\t\tconst current = await this.loadCurrentSkill()\n\t\t\treturn namesUtil.toPascal(current.slug ?? fallback)\n\t\t}\n\n\t\treturn fallback\n\t}\n\n\tpublic async setCurrentSkillsNamespace(namespace: string) {\n\t\tlet isRegistered = false\n\t\ttry {\n\t\t\tisRegistered = await this.isCurrentSkillRegistered()\n\t\t\t// eslint-disable-next-line no-empty\n\t\t} catch {}\n\n\t\tif (isRegistered) {\n\t\t\tthrow new SpruceError({\n\t\t\t\tcode: 'GENERIC',\n\t\t\t\tfriendlyMessage: `You can't set the namespace of a skill that is registered.`,\n\t\t\t})\n\t\t}\n\n\t\tthis.Service('auth').updateCurrentSkillNamespace(namespace)\n\t}\n\n\tprivate getEventNamespaceForNotRegistered() {\n\t\treturn namesUtil.toPascal(this.getNamespaceFromPkg())\n\t}\n\n\tprivate getSkillDescriptionFromPkg() {\n\t\tconst pkg = this.Service('pkg')\n\t\treturn pkg.get('description')\n\t}\n\n\tpublic async unregisterSkill(skillId: string) {\n\t\tconst client = await this.connectToApi()\n\n\t\tconst response = await client.emit('unregister-skill::v2020_12_25', {\n\t\t\ttarget: {\n\t\t\t\tskillId,\n\t\t\t},\n\t\t})\n\n\t\teventResponseUtil.getFirstResponseOrThrow(response)\n\n\t\tif (SkillStore.currentSkill?.id === skillId) {\n\t\t\tSkillStore.currentSkill = undefined\n\t\t\tthis.Service('auth').logoutCurrentSkill()\n\t\t}\n\t}\n\n\tpublic async fetchMySkills() {\n\t\treturn this.fetchAllSkills({ shouldOnlyShowMine: true })\n\t}\n\n\tpublic async fetchAllSkills(query?: {\n\t\tshouldOnlyShowMine?: boolean\n\t\tnamespaces?: string[]\n\t}) {\n\t\tconst client = await this.connectToApi()\n\n\t\tconst response = await client.emit('list-skills::v2020_12_25', {\n\t\t\tpayload: {\n\t\t\t\t...query,\n\t\t\t},\n\t\t})\n\n\t\tconst { skills } = eventResponseUtil.getFirstResponseOrThrow(response)\n\n\t\treturn skills\n\t}\n}\n\nexport interface CreateSkill {\n\tname: string\n\tslug?: string\n\tdescription?: string\n\tisPublished?: boolean\n}\n\nexport interface RegisterSkillOptions {\n\tisRegisteringCurrentSkill?: boolean\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;IAGqBA,U;;;;;;;;;;;;;;;6FACG,O;;;;;;;oGAOvB,iBACCC,MADD,EAECC,OAFD;QAAA;;QAAA;UAAA;YAAA;cAAA;gBAIOC,yBAJP,GAKE,CAAAD,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEC,yBAAT,MAAuC,KALzC;gBAOCA,yBAAyB,IAAI,KAAKC,aAAL,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A,6BAAkC;MACjC,KAAK/B,YAAL,GAAoB0B,SAApB;IACA;;;EANsCM,0B;;;iCAAnBxD,U"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventContract, SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
2
|
-
import { RegisterSkillOptions } from '../../features/skill/stores/SkillStore';
|
|
2
|
+
import { CreateSkill, RegisterSkillOptions } from '../../features/skill/stores/SkillStore';
|
|
3
3
|
import StoreFactory from '../../stores/StoreFactory';
|
|
4
4
|
import { ApiClientFactory, ApiClientFactoryOptions } from '../../types/apiClient.types';
|
|
5
5
|
import PersonFixture from './PersonFixture';
|
|
@@ -9,15 +9,10 @@ export default class SkillFixture {
|
|
|
9
9
|
private personFixture;
|
|
10
10
|
private static skillCount;
|
|
11
11
|
constructor(personFixture: PersonFixture, storeFactory: StoreFactory, apiClientFactory: ApiClientFactory);
|
|
12
|
-
seedDemoSkill(values: {
|
|
13
|
-
name: string;
|
|
14
|
-
}, options?: {
|
|
12
|
+
seedDemoSkill(values: CreateSkill, options?: {
|
|
15
13
|
phone?: string;
|
|
16
14
|
}): Promise<import("../../types/cli.types").RegisteredSkill>;
|
|
17
|
-
registerCurrentSkill(values: {
|
|
18
|
-
name: string;
|
|
19
|
-
slug?: string;
|
|
20
|
-
}, options?: RegisterSkillOptions & {
|
|
15
|
+
registerCurrentSkill(values: CreateSkill, options?: RegisterSkillOptions & {
|
|
21
16
|
phone?: string;
|
|
22
17
|
}): Promise<import("../../types/cli.types").RegisteredSkill>;
|
|
23
18
|
private generateSkillSlug;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkillFixture.js","names":["SkillFixture","personFixture","storeFactory","apiClientFactory","values","options","registerCurrentSkill","isRegisteringCurrentSkill","loginAsDemoPerson","phone","Store","register","slug","generateSkillSlug","name","skillCount","namesUtil","toKebab","Date","getTime","auth","contract","skillAuth","apiClientUtil","skillOrAuthToAuth","client","eventStore","registerEventContract","eventContract","unRegisterEvents","skillStore","fetchMySkills","skills","skill","unregisterSkill","id","length","Math","round","random"],"sources":["../../../src/tests/fixtures/SkillFixture.ts"],"sourcesContent":["import { EventContract, SpruceSchemas } from '@sprucelabs/mercury-types'\nimport { namesUtil } from '@sprucelabs/spruce-skill-utils'\nimport {
|
|
1
|
+
{"version":3,"file":"SkillFixture.js","names":["SkillFixture","personFixture","storeFactory","apiClientFactory","values","options","registerCurrentSkill","isRegisteringCurrentSkill","loginAsDemoPerson","phone","Store","register","slug","generateSkillSlug","name","skillCount","namesUtil","toKebab","Date","getTime","auth","contract","skillAuth","apiClientUtil","skillOrAuthToAuth","client","eventStore","registerEventContract","eventContract","unRegisterEvents","skillStore","fetchMySkills","skills","skill","unregisterSkill","id","length","Math","round","random"],"sources":["../../../src/tests/fixtures/SkillFixture.ts"],"sourcesContent":["import { EventContract, SpruceSchemas } from '@sprucelabs/mercury-types'\nimport { namesUtil } from '@sprucelabs/spruce-skill-utils'\nimport {\n\tCreateSkill,\n\tRegisterSkillOptions,\n} from '../../features/skill/stores/SkillStore'\nimport StoreFactory from '../../stores/StoreFactory'\nimport {\n\tApiClientFactory,\n\tApiClientFactoryOptions,\n} from '../../types/apiClient.types'\nimport apiClientUtil from '../../utilities/apiClient.utility'\nimport PersonFixture from './PersonFixture'\n\nexport default class SkillFixture {\n\tprivate storeFactory: StoreFactory\n\tprivate apiClientFactory: ApiClientFactory\n\tprivate personFixture: PersonFixture\n\n\tprivate static skillCount = Math.round(Math.random() * 100)\n\n\tpublic constructor(\n\t\tpersonFixture: PersonFixture,\n\t\tstoreFactory: StoreFactory,\n\t\tapiClientFactory: ApiClientFactory\n\t) {\n\t\tthis.personFixture = personFixture\n\t\tthis.storeFactory = storeFactory\n\t\tthis.apiClientFactory = apiClientFactory\n\t}\n\n\tpublic async seedDemoSkill(\n\t\tvalues: CreateSkill,\n\t\toptions?: { phone?: string }\n\t) {\n\t\treturn this.registerCurrentSkill(values, {\n\t\t\tisRegisteringCurrentSkill: false,\n\t\t\t...options,\n\t\t})\n\t}\n\n\tpublic async registerCurrentSkill(\n\t\tvalues: CreateSkill,\n\t\toptions?: RegisterSkillOptions & { phone?: string }\n\t) {\n\t\tawait this.personFixture.loginAsDemoPerson(options?.phone)\n\n\t\treturn this.storeFactory.Store('skill').register(\n\t\t\t{\n\t\t\t\tslug: values.slug ?? this.generateSkillSlug(values.name),\n\t\t\t\t...values,\n\t\t\t},\n\t\t\toptions\n\t\t)\n\t}\n\n\tprivate generateSkillSlug(name: string): string {\n\t\tSkillFixture.skillCount++\n\t\treturn `${namesUtil.toKebab(name)}-${new Date().getTime()}-count-${\n\t\t\tSkillFixture.skillCount\n\t\t}-cli-test`\n\t}\n\n\tpublic async registerEventContract(\n\t\tauth: ApiClientFactoryOptions | SpruceSchemas.Spruce.v2020_07_22.Skill,\n\t\tcontract: EventContract\n\t) {\n\t\tconst skillAuth = apiClientUtil.skillOrAuthToAuth(auth)\n\t\tconst client = await this.apiClientFactory(skillAuth)\n\n\t\tconst eventStore = this.storeFactory.Store('event', {\n\t\t\tapiClientFactory: async () => {\n\t\t\t\treturn client\n\t\t\t},\n\t\t})\n\n\t\tawait eventStore.registerEventContract({\n\t\t\teventContract: contract,\n\t\t})\n\t}\n\n\tpublic async unRegisterEvents(\n\t\tauth: ApiClientFactoryOptions | SpruceSchemas.Spruce.v2020_07_22.Skill,\n\t\toptions: SpruceSchemas.Mercury.v2020_12_25.UnregisterEventsEmitPayload\n\t) {\n\t\tconst skillAuth = apiClientUtil.skillOrAuthToAuth(auth)\n\t\tconst client = await this.apiClientFactory(skillAuth)\n\n\t\tconst eventStore = this.storeFactory.Store('event', {\n\t\t\tapiClientFactory: async () => {\n\t\t\t\treturn client\n\t\t\t},\n\t\t})\n\n\t\tawait eventStore.unRegisterEvents(options)\n\t}\n\n\tpublic async clearAllSkills() {\n\t\tawait this.personFixture.loginAsDemoPerson()\n\n\t\tconst skillStore = this.storeFactory.Store('skill')\n\t\tconst skills = await skillStore.fetchMySkills()\n\n\t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BAAA;gBAAA,OACO,KAAKJ,aAAL,CAAmBO,iBAAnB,EADP;;cAAA;gBAGOsB,UAHP,GAGoB,KAAK5B,YAAL,CAAkBQ,KAAlB,CAAwB,OAAxB,CAHpB;gBAAA;gBAAA,OAIsBoB,UAAU,CAACC,aAAX,EAJtB;;cAAA;gBAIOC,MAJP;gBAAA,uCAMqBA,MANrB;gBAAA;;gBAAA;;cAAA;gBAAA;kBAAA;kBAAA;gBAAA;;gBAMYC,KANZ;gBAAA;gBAAA,OAOQH,UAAU,CAACI,eAAX,CAA2BD,KAAK,CAACE,EAAjC,CAPR;;cAAA;gBAAA;gBAAA;;cAAA;gBAAA;gBAAA;;cAAA;gBAAA;gBAAA;;gBAAA;;cAAA;gBAAA;;gBAAA;;gBAAA;;cAAA;gBAAA,kCAUQH,MAAM,CAACI,MAVf;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;;;;iCAnFoBpC,Y,gBAKQqC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,MAAL,KAAgB,GAA3B,C"}
|
|
@@ -164,38 +164,29 @@ var TkBaseWidget = /*#__PURE__*/function (_ref) {
|
|
|
164
164
|
value: function sizeLockedChildren() {
|
|
165
165
|
var newFrame = this.getFrame();
|
|
166
166
|
|
|
167
|
-
var
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
try {
|
|
171
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
172
|
-
var child = _step.value;
|
|
173
|
-
child.handleParentResize(newFrame);
|
|
174
|
-
}
|
|
175
|
-
} catch (err) {
|
|
176
|
-
_iterator.e(err);
|
|
177
|
-
} finally {
|
|
178
|
-
_iterator.f();
|
|
167
|
+
for (var _i = 0, _arr = this.children; _i < _arr.length; _i++) {
|
|
168
|
+
var child = _arr[_i];
|
|
169
|
+
child.handleParentResize(newFrame);
|
|
179
170
|
}
|
|
180
171
|
}
|
|
181
172
|
}, {
|
|
182
173
|
key: "getChildById",
|
|
183
174
|
value: function getChildById(id) {
|
|
184
|
-
var
|
|
185
|
-
|
|
175
|
+
var _iterator = _createForOfIteratorHelper(this.getChildren()),
|
|
176
|
+
_step;
|
|
186
177
|
|
|
187
178
|
try {
|
|
188
|
-
for (
|
|
189
|
-
var child =
|
|
179
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
180
|
+
var child = _step.value;
|
|
190
181
|
|
|
191
182
|
if (child.getId() === id) {
|
|
192
183
|
return child;
|
|
193
184
|
}
|
|
194
185
|
}
|
|
195
186
|
} catch (err) {
|
|
196
|
-
|
|
187
|
+
_iterator.e(err);
|
|
197
188
|
} finally {
|
|
198
|
-
|
|
189
|
+
_iterator.f();
|
|
199
190
|
}
|
|
200
191
|
|
|
201
192
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TkBaseWidget.js","names":["TkBaseWidget","options","eventContract","eventSignatures","leftDelta","widthDelta","topDelta","heightDelta","rightDelta","bottomDelta","parent","term","id","shouldLockHeightWithParent","shouldLockWidthWithParent","shouldLockRightWithParent","shouldLockBottomWithParent","padding","left","top","right","bottom","addChild","children","child","push","element","getTermKitElement","outputX","outputY","width","outputWidth","height","outputHeight","Error","type","frame","resize","x","y","sizeLockedChildren","draw","newFrame","getFrame","handleParentResize","getChildren","getId","filter","c","parentFrame","updatedFrame","shouldSetFrame","frameLockDeltas","setFrame","destroy","getParent","removeChild","AbstractEventEmitter"],"sources":["../../../src/widgets/terminalKit/TkBaseWidget.ts"],"sourcesContent":["import { AbstractEventEmitter } from '@sprucelabs/mercury-event-emitter'\nimport { EventContract } from '@sprucelabs/mercury-types'\nimport { Terminal } from 'terminal-kit'\nimport {\n\tBaseWidget,\n\tUniversalWidgetOptions,\n\tWidgetFrame,\n\tWidgetFrameCalculated,\n\tWidgetPadding,\n} from '../types/widgets.types'\n\nexport type BaseWidgetWithTermKitAddons = BaseWidget & {\n\tgetTermKitElement: () => any | null\n}\n\nexport type TkWidgetOptions = UniversalWidgetOptions & {\n\tterm: Terminal\n\tparent: BaseWidgetWithTermKitAddons\n}\n\nexport default abstract class TkBaseWidget<Contract extends EventContract = any>\n\textends AbstractEventEmitter<Contract>\n\timplements BaseWidget<Contract>\n{\n\tpublic type = 'abstract'\n\tprotected parent: BaseWidgetWithTermKitAddons | null\n\tprotected term: Terminal\n\tprivate id: string | null\n\tprivate children: BaseWidget[] = []\n\tprotected shouldLockWidthWithParent = false\n\tprotected shouldLockHeightWithParent = false\n\tprotected shouldLockRightWithParent = false\n\tprotected shouldLockBottomWithParent = false\n\tprotected padding: WidgetPadding = {}\n\tprivate frameLockDeltas: {\n\t\tleftDelta: number\n\t\twidthDelta: number\n\t\ttopDelta: number\n\t\theightDelta: number\n\t\trightDelta: number\n\t\tbottomDelta: number\n\t} = {\n\t\tleftDelta: 0,\n\t\twidthDelta: 0,\n\t\ttopDelta: 0,\n\t\theightDelta: 0,\n\t\trightDelta: 0,\n\t\tbottomDelta: 0,\n\t}\n\n\tpublic constructor(options: TkWidgetOptions) {\n\t\tsuper(options.eventContract ?? { eventSignatures: {} })\n\n\t\tthis.parent = options.parent ?? null\n\t\tthis.term = options.term\n\t\tthis.id = options.id ?? null\n\t\tthis.shouldLockHeightWithParent =\n\t\t\toptions.shouldLockHeightWithParent ?? false\n\t\tthis.shouldLockWidthWithParent = options.shouldLockWidthWithParent ?? false\n\t\tthis.shouldLockRightWithParent = options.shouldLockRightWithParent ?? false\n\t\tthis.shouldLockBottomWithParent =\n\t\t\toptions.shouldLockBottomWithParent ?? false\n\n\t\tthis.padding = {\n\t\t\tleft: 0,\n\t\t\ttop: 0,\n\t\t\tright: 0,\n\t\t\tbottom: 0,\n\t\t\t...options.padding,\n\t\t}\n\n\t\tif (this.parent) {\n\t\t\tthis.parent.addChild(this as TkBaseWidget)\n\t\t}\n\t}\n\n\tpublic getChildren(): BaseWidget[] {\n\t\treturn this.children\n\t}\n\n\tpublic addChild(child: BaseWidget): void {\n\t\tthis.children.push(child)\n\t}\n\n\tpublic getId(): string | null {\n\t\treturn this.id\n\t}\n\n\tpublic getParent(): BaseWidget | null {\n\t\treturn this.parent\n\t}\n\n\tpublic getFrame(): WidgetFrameCalculated {\n\t\tconst element = this.getTermKitElement()\n\t\tif (element) {\n\t\t\treturn {\n\t\t\t\tleft: element.outputX,\n\t\t\t\ttop: element.outputY,\n\t\t\t\twidth: element.outputWidth,\n\t\t\t\theight: element.outputHeight,\n\t\t\t}\n\t\t}\n\t\tthrow new Error(\n\t\t\telement\n\t\t\t\t? `${this.type} does not implement getFrame()`\n\t\t\t\t: `${this.type} does not implement getTermKitElement()`\n\t\t)\n\t}\n\n\tpublic setFrame(frame: Partial<WidgetFrame>): void {\n\t\tconst element = this.getTermKitElement()\n\n\t\tif (element) {\n\t\t\tif (element.resize) {\n\t\t\t\telement.resize({\n\t\t\t\t\tx: frame.left,\n\t\t\t\t\ty: frame.top,\n\t\t\t\t\twidth: frame.width,\n\t\t\t\t\theight: frame.height,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\telement.outputX = frame.left ?? element.outputX\n\t\t\t\telement.outputY = frame.top ?? element.outputY\n\t\t\t\telement.outputWidth = frame.width ?? element.outputWidth\n\t\t\t\telement.outputHeight = frame.height ?? element.outputHeight\n\t\t\t}\n\n\t\t\tthis.sizeLockedChildren()\n\n\t\t\telement.draw()\n\n\t\t\treturn\n\t\t}\n\n\t\tthrow new Error(`${this.type} does not implement getTermKitElement()`)\n\t}\n\n\tprotected sizeLockedChildren() {\n\t\tconst newFrame = this.getFrame()\n\t\tfor (const child of this.children as TkBaseWidget[]) {\n\t\t\tchild.handleParentResize(newFrame)\n\t\t}\n\t}\n\n\tpublic getChildById(id?: string): BaseWidget | null {\n\t\tfor (const child of this.getChildren()) {\n\t\t\tif (child.getId() === id) {\n\t\t\t\treturn child\n\t\t\t}\n\t\t}\n\n\t\treturn null\n\t}\n\n\tpublic removeChild(child: BaseWidget) {\n\t\tthis.children = this.children.filter((c) => c !== child)\n\t}\n\n\tprotected handleParentResize(parentFrame: WidgetFrameCalculated): void {\n\t\tconst updatedFrame = this.getFrame()\n\t\tlet shouldSetFrame = false\n\n\t\tif (this.shouldLockHeightWithParent) {\n\t\t\tshouldSetFrame = true\n\t\t\tupdatedFrame.height =\n\t\t\t\tparentFrame.height - this.frameLockDeltas.heightDelta\n\t\t}\n\n\t\tif (this.shouldLockWidthWithParent) {\n\t\t\tshouldSetFrame = true\n\t\t\tupdatedFrame.width = parentFrame.width - this.frameLockDeltas.widthDelta\n\t\t}\n\n\t\tif (this.shouldLockRightWithParent) {\n\t\t\tshouldSetFrame = true\n\t\t\tupdatedFrame.left =\n\t\t\t\tparentFrame.width - this.frameLockDeltas.rightDelta - updatedFrame.width\n\t\t}\n\n\t\tif (this.shouldLockBottomWithParent) {\n\t\t\tshouldSetFrame = true\n\t\t\tupdatedFrame.top =\n\t\t\t\tparentFrame.height -\n\t\t\t\tupdatedFrame.height -\n\t\t\t\tthis.frameLockDeltas.bottomDelta\n\t\t}\n\n\t\tif (shouldSetFrame) {\n\t\t\tthis.setFrame(updatedFrame)\n\t\t}\n\t}\n\n\tpublic async destroy() {\n\t\tthis.getTermKitElement()?.destroy()\n\t\tthis.getParent()?.removeChild(this as BaseWidget)\n\t}\n\n\tpublic getTermKitElement(): any | null {\n\t\treturn null\n\t}\n\n\tprotected calculateSizeLockDeltas() {\n\t\tconst frame = this.getFrame()\n\t\tconst parentFrame = this.getParent()?.getFrame()\n\n\t\tif (!parentFrame) {\n\t\t\treturn\n\t\t}\n\n\t\tlet leftDelta = 0\n\t\tlet widthDelta = 0\n\t\tlet topDelta = 0\n\t\tlet heightDelta = 0\n\t\tlet rightDelta = 0\n\t\tlet bottomDelta = 0\n\n\t\tif (this.shouldLockWidthWithParent) {\n\t\t\tleftDelta = frame.left\n\t\t\twidthDelta = parentFrame.width - frame.width\n\t\t}\n\n\t\tif (this.shouldLockHeightWithParent) {\n\t\t\ttopDelta = frame.top\n\t\t\theightDelta = parentFrame.height - frame.height\n\t\t}\n\n\t\tif (this.shouldLockRightWithParent) {\n\t\t\trightDelta = frame.left + frame.width - parentFrame.width\n\t\t}\n\n\t\tif (this.shouldLockBottomWithParent) {\n\t\t\tbottomDelta = parentFrame.height - (frame.top + frame.height)\n\t\t}\n\n\t\tthis.frameLockDeltas = {\n\t\t\tleftDelta,\n\t\t\twidthDelta,\n\t\t\ttopDelta,\n\t\t\theightDelta,\n\t\t\trightDelta,\n\t\t\tbottomDelta,\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;IAoB8BA,Y;;;;;EA8B7B,sBAAmBC,OAAnB,EAA6C;IAAA;;IAAA;;IAAA;IAC5C,mDAAMA,OAAO,CAACC,aAAd,yEAA+B;MAAEC,eAAe,EAAE;IAAnB,CAA/B;IAD4C,yFA1B/B,UA0B+B;IAAA;IAAA;IAAA;IAAA,6FAtBZ,EAsBY;IAAA,8GArBP,KAqBO;IAAA,+GApBN,KAoBM;IAAA,8GAnBP,KAmBO;IAAA,+GAlBN,KAkBM;IAAA,4FAjBV,EAiBU;IAAA,oGATzC;MACHC,SAAS,EAAE,CADR;MAEHC,UAAU,EAAE,CAFT;MAGHC,QAAQ,EAAE,CAHP;MAIHC,WAAW,EAAE,CAJV;MAKHC,UAAU,EAAE,CALT;MAMHC,WAAW,EAAE;IANV,CASyC;IAG5C,MAAKC,MAAL,sBAAcT,OAAO,CAACS,MAAtB,6DAAgC,IAAhC;IACA,MAAKC,IAAL,GAAYV,OAAO,CAACU,IAApB;IACA,MAAKC,EAAL,kBAAUX,OAAO,CAACW,EAAlB,qDAAwB,IAAxB;IACA,MAAKC,0BAAL,4BACCZ,OAAO,CAACY,0BADT,yEACuC,KADvC;IAEA,MAAKC,yBAAL,4BAAiCb,OAAO,CAACa,yBAAzC,yEAAsE,KAAtE;IACA,MAAKC,yBAAL,4BAAiCd,OAAO,CAACc,yBAAzC,yEAAsE,KAAtE;IACA,MAAKC,0BAAL,4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,QAAQ,GAAG,CAAf;MACA,IAAIC,WAAW,GAAG,CAAlB;MACA,IAAIC,UAAU,GAAG,CAAjB;MACA,IAAIC,WAAW,GAAG,CAAlB;;MAEA,IAAI,KAAKK,yBAAT,EAAoC;QACnCV,SAAS,GAAGgC,KAAK,CAAClB,IAAlB;QACAb,UAAU,GAAG4C,WAAW,CAACnB,KAAZ,GAAoBM,KAAK,CAACN,KAAvC;MACA;;MAED,IAAI,KAAKjB,0BAAT,EAAqC;QACpCP,QAAQ,GAAG8B,KAAK,CAACjB,GAAjB;QACAZ,WAAW,GAAG0C,WAAW,CAACjB,MAAZ,GAAqBI,KAAK,CAACJ,MAAzC;MACA;;MAED,IAAI,KAAKjB,yBAAT,EAAoC;QACnCP,UAAU,GAAG4B,KAAK,CAAClB,IAAN,GAAakB,KAAK,CAACN,KAAnB,GAA2BmB,WAAW,CAACnB,KAApD;MACA;;MAED,IAAI,KAAKd,0BAAT,EAAqC;QACpCP,WAAW,GAAGwC,WAAW,CAACjB,MAAZ,IAAsBI,KAAK,CAACjB,GAAN,GAAYiB,KAAK,CAACJ,MAAxC,CAAd;MACA;;MAED,KAAKoB,eAAL,GAAuB;QACtBhD,SAAS,EAATA,SADsB;QAEtBC,UAAU,EAAVA,UAFsB;QAGtBC,QAAQ,EAARA,QAHsB;QAItBC,WAAW,EAAXA,WAJsB;QAKtBC,UAAU,EAAVA,UALsB;QAMtBC,WAAW,EAAXA;MANsB,CAAvB;IAQA;;;EA7NOgD,yC"}
|
|
1
|
+
{"version":3,"file":"TkBaseWidget.js","names":["TkBaseWidget","options","eventContract","eventSignatures","leftDelta","widthDelta","topDelta","heightDelta","rightDelta","bottomDelta","parent","term","id","shouldLockHeightWithParent","shouldLockWidthWithParent","shouldLockRightWithParent","shouldLockBottomWithParent","padding","left","top","right","bottom","addChild","children","child","push","element","getTermKitElement","outputX","outputY","width","outputWidth","height","outputHeight","Error","type","frame","resize","x","y","sizeLockedChildren","draw","newFrame","getFrame","handleParentResize","getChildren","getId","filter","c","parentFrame","updatedFrame","shouldSetFrame","frameLockDeltas","setFrame","destroy","getParent","removeChild","AbstractEventEmitter"],"sources":["../../../src/widgets/terminalKit/TkBaseWidget.ts"],"sourcesContent":["import { AbstractEventEmitter } from '@sprucelabs/mercury-event-emitter'\nimport { EventContract } from '@sprucelabs/mercury-types'\nimport { Terminal } from 'terminal-kit'\nimport {\n\tBaseWidget,\n\tUniversalWidgetOptions,\n\tWidgetFrame,\n\tWidgetFrameCalculated,\n\tWidgetPadding,\n} from '../types/widgets.types'\n\nexport type BaseWidgetWithTermKitAddons = BaseWidget & {\n\tgetTermKitElement: () => any | null\n}\n\nexport type TkWidgetOptions = UniversalWidgetOptions & {\n\tterm: Terminal\n\tparent: BaseWidgetWithTermKitAddons\n}\n\nexport default abstract class TkBaseWidget<Contract extends EventContract = any>\n\textends AbstractEventEmitter<Contract>\n\timplements BaseWidget<Contract>\n{\n\tpublic type = 'abstract'\n\tprotected parent: BaseWidgetWithTermKitAddons | null\n\tprotected term: Terminal\n\tprivate id: string | null\n\tprivate children: BaseWidget[] = []\n\tprotected shouldLockWidthWithParent = false\n\tprotected shouldLockHeightWithParent = false\n\tprotected shouldLockRightWithParent = false\n\tprotected shouldLockBottomWithParent = false\n\tprotected padding: WidgetPadding = {}\n\tprivate frameLockDeltas: {\n\t\tleftDelta: number\n\t\twidthDelta: number\n\t\ttopDelta: number\n\t\theightDelta: number\n\t\trightDelta: number\n\t\tbottomDelta: number\n\t} = {\n\t\tleftDelta: 0,\n\t\twidthDelta: 0,\n\t\ttopDelta: 0,\n\t\theightDelta: 0,\n\t\trightDelta: 0,\n\t\tbottomDelta: 0,\n\t}\n\n\tpublic constructor(options: TkWidgetOptions) {\n\t\tsuper(options.eventContract ?? { eventSignatures: {} })\n\n\t\tthis.parent = options.parent ?? null\n\t\tthis.term = options.term\n\t\tthis.id = options.id ?? null\n\t\tthis.shouldLockHeightWithParent =\n\t\t\toptions.shouldLockHeightWithParent ?? false\n\t\tthis.shouldLockWidthWithParent = options.shouldLockWidthWithParent ?? false\n\t\tthis.shouldLockRightWithParent = options.shouldLockRightWithParent ?? false\n\t\tthis.shouldLockBottomWithParent =\n\t\t\toptions.shouldLockBottomWithParent ?? false\n\n\t\tthis.padding = {\n\t\t\tleft: 0,\n\t\t\ttop: 0,\n\t\t\tright: 0,\n\t\t\tbottom: 0,\n\t\t\t...options.padding,\n\t\t}\n\n\t\tif (this.parent) {\n\t\t\tthis.parent.addChild(this as TkBaseWidget)\n\t\t}\n\t}\n\n\tpublic getChildren(): BaseWidget[] {\n\t\treturn this.children\n\t}\n\n\tpublic addChild(child: BaseWidget): void {\n\t\tthis.children.push(child)\n\t}\n\n\tpublic getId(): string | null {\n\t\treturn this.id\n\t}\n\n\tpublic getParent(): BaseWidget | null {\n\t\treturn this.parent\n\t}\n\n\tpublic getFrame(): WidgetFrameCalculated {\n\t\tconst element = this.getTermKitElement()\n\t\tif (element) {\n\t\t\treturn {\n\t\t\t\tleft: element.outputX,\n\t\t\t\ttop: element.outputY,\n\t\t\t\twidth: element.outputWidth,\n\t\t\t\theight: element.outputHeight,\n\t\t\t}\n\t\t}\n\t\tthrow new Error(\n\t\t\telement\n\t\t\t\t? `${this.type} does not implement getFrame()`\n\t\t\t\t: `${this.type} does not implement getTermKitElement()`\n\t\t)\n\t}\n\n\tpublic setFrame(frame: Partial<WidgetFrame>): void {\n\t\tconst element = this.getTermKitElement()\n\n\t\tif (element) {\n\t\t\tif (element.resize) {\n\t\t\t\telement.resize({\n\t\t\t\t\tx: frame.left,\n\t\t\t\t\ty: frame.top,\n\t\t\t\t\twidth: frame.width,\n\t\t\t\t\theight: frame.height,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\telement.outputX = frame.left ?? element.outputX\n\t\t\t\telement.outputY = frame.top ?? element.outputY\n\t\t\t\telement.outputWidth = frame.width ?? element.outputWidth\n\t\t\t\telement.outputHeight = frame.height ?? element.outputHeight\n\t\t\t}\n\n\t\t\tthis.sizeLockedChildren()\n\n\t\t\telement.draw()\n\n\t\t\treturn\n\t\t}\n\n\t\tthrow new Error(`${this.type} does not implement getTermKitElement()`)\n\t}\n\n\tprotected sizeLockedChildren() {\n\t\tconst newFrame = this.getFrame()\n\t\tfor (const child of this.children as TkBaseWidget[]) {\n\t\t\tchild.handleParentResize(newFrame)\n\t\t}\n\t}\n\n\tpublic getChildById(id?: string): BaseWidget | null {\n\t\tfor (const child of this.getChildren()) {\n\t\t\tif (child.getId() === id) {\n\t\t\t\treturn child\n\t\t\t}\n\t\t}\n\n\t\treturn null\n\t}\n\n\tpublic removeChild(child: BaseWidget) {\n\t\tthis.children = this.children.filter((c) => c !== child)\n\t}\n\n\tprotected handleParentResize(parentFrame: WidgetFrameCalculated): void {\n\t\tconst updatedFrame = this.getFrame()\n\t\tlet shouldSetFrame = false\n\n\t\tif (this.shouldLockHeightWithParent) {\n\t\t\tshouldSetFrame = true\n\t\t\tupdatedFrame.height =\n\t\t\t\tparentFrame.height - this.frameLockDeltas.heightDelta\n\t\t}\n\n\t\tif (this.shouldLockWidthWithParent) {\n\t\t\tshouldSetFrame = true\n\t\t\tupdatedFrame.width = parentFrame.width - this.frameLockDeltas.widthDelta\n\t\t}\n\n\t\tif (this.shouldLockRightWithParent) {\n\t\t\tshouldSetFrame = true\n\t\t\tupdatedFrame.left =\n\t\t\t\tparentFrame.width - this.frameLockDeltas.rightDelta - updatedFrame.width\n\t\t}\n\n\t\tif (this.shouldLockBottomWithParent) {\n\t\t\tshouldSetFrame = true\n\t\t\tupdatedFrame.top =\n\t\t\t\tparentFrame.height -\n\t\t\t\tupdatedFrame.height -\n\t\t\t\tthis.frameLockDeltas.bottomDelta\n\t\t}\n\n\t\tif (shouldSetFrame) {\n\t\t\tthis.setFrame(updatedFrame)\n\t\t}\n\t}\n\n\tpublic async destroy() {\n\t\tthis.getTermKitElement()?.destroy()\n\t\tthis.getParent()?.removeChild(this as BaseWidget)\n\t}\n\n\tpublic getTermKitElement(): any | null {\n\t\treturn null\n\t}\n\n\tprotected calculateSizeLockDeltas() {\n\t\tconst frame = this.getFrame()\n\t\tconst parentFrame = this.getParent()?.getFrame()\n\n\t\tif (!parentFrame) {\n\t\t\treturn\n\t\t}\n\n\t\tlet leftDelta = 0\n\t\tlet widthDelta = 0\n\t\tlet topDelta = 0\n\t\tlet heightDelta = 0\n\t\tlet rightDelta = 0\n\t\tlet bottomDelta = 0\n\n\t\tif (this.shouldLockWidthWithParent) {\n\t\t\tleftDelta = frame.left\n\t\t\twidthDelta = parentFrame.width - frame.width\n\t\t}\n\n\t\tif (this.shouldLockHeightWithParent) {\n\t\t\ttopDelta = frame.top\n\t\t\theightDelta = parentFrame.height - frame.height\n\t\t}\n\n\t\tif (this.shouldLockRightWithParent) {\n\t\t\trightDelta = frame.left + frame.width - parentFrame.width\n\t\t}\n\n\t\tif (this.shouldLockBottomWithParent) {\n\t\t\tbottomDelta = parentFrame.height - (frame.top + frame.height)\n\t\t}\n\n\t\tthis.frameLockDeltas = {\n\t\t\tleftDelta,\n\t\t\twidthDelta,\n\t\t\ttopDelta,\n\t\t\theightDelta,\n\t\t\trightDelta,\n\t\t\tbottomDelta,\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;IAoB8BA,Y;;;;;EA8B7B,sBAAmBC,OAAnB,EAA6C;IAAA;;IAAA;;IAAA;IAC5C,mDAAMA,OAAO,CAACC,aAAd,yEAA+B;MAAEC,eAAe,EAAE;IAAnB,CAA/B;IAD4C,yFA1B/B,UA0B+B;IAAA;IAAA;IAAA;IAAA,6FAtBZ,EAsBY;IAAA,8GArBP,KAqBO;IAAA,+GApBN,KAoBM;IAAA,8GAnBP,KAmBO;IAAA,+GAlBN,KAkBM;IAAA,4FAjBV,EAiBU;IAAA,oGATzC;MACHC,SAAS,EAAE,CADR;MAEHC,UAAU,EAAE,CAFT;MAGHC,QAAQ,EAAE,CAHP;MAIHC,WAAW,EAAE,CAJV;MAKH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