@knocklabs/cli 1.0.0-rc.1 → 1.0.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.
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return GuideOpen;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _browser = require("../../lib/helpers/browser");
14
+ const _error = require("../../lib/helpers/error");
15
+ const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
16
+ const _request = require("../../lib/helpers/request");
17
+ const _urls = require("../../lib/urls");
18
+ function _define_property(obj, key, value) {
19
+ if (key in obj) {
20
+ Object.defineProperty(obj, key, {
21
+ value: value,
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true
25
+ });
26
+ } else {
27
+ obj[key] = value;
28
+ }
29
+ return obj;
30
+ }
31
+ function _interop_require_default(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
36
+ function _getRequireWildcardCache(nodeInterop) {
37
+ if (typeof WeakMap !== "function") return null;
38
+ var cacheBabelInterop = new WeakMap();
39
+ var cacheNodeInterop = new WeakMap();
40
+ return (_getRequireWildcardCache = function(nodeInterop) {
41
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
+ })(nodeInterop);
43
+ }
44
+ function _interop_require_wildcard(obj, nodeInterop) {
45
+ if (!nodeInterop && obj && obj.__esModule) {
46
+ return obj;
47
+ }
48
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
49
+ return {
50
+ default: obj
51
+ };
52
+ }
53
+ var cache = _getRequireWildcardCache(nodeInterop);
54
+ if (cache && cache.has(obj)) {
55
+ return cache.get(obj);
56
+ }
57
+ var newObj = {
58
+ __proto__: null
59
+ };
60
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
61
+ for(var key in obj){
62
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
63
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
64
+ if (desc && (desc.get || desc.set)) {
65
+ Object.defineProperty(newObj, key, desc);
66
+ } else {
67
+ newObj[key] = obj[key];
68
+ }
69
+ }
70
+ }
71
+ newObj.default = obj;
72
+ if (cache) {
73
+ cache.set(obj, newObj);
74
+ }
75
+ return newObj;
76
+ }
77
+ class GuideOpen extends _basecommand.default {
78
+ async run() {
79
+ const whoamiResp = await this.apiV1.whoami();
80
+ if (!(0, _request.isSuccessResp)(whoamiResp)) {
81
+ const message = (0, _request.formatErrorRespMessage)(whoamiResp);
82
+ _core.ux.error(new _error.ApiError(message));
83
+ }
84
+ const { account_slug } = whoamiResp.data;
85
+ const { guideKey } = this.props.args;
86
+ const { environment, branch } = this.props.flags;
87
+ const envOrBranch = branch !== null && branch !== void 0 ? branch : environment;
88
+ const url = (0, _urls.viewGuideUrl)(this.sessionContext.dashboardOrigin, account_slug, envOrBranch, guideKey);
89
+ this.log(`‣ Opening guide \`${guideKey}\` in the Knock dashboard...`);
90
+ this.log(` ${url}`);
91
+ await _browser.browser.openUrl(url);
92
+ }
93
+ }
94
+ _define_property(GuideOpen, "summary", "Open a guide in the Knock dashboard.");
95
+ _define_property(GuideOpen, "flags", {
96
+ environment: _core.Flags.string({
97
+ default: "development",
98
+ summary: "The environment to use."
99
+ }),
100
+ branch: _flag.branch
101
+ });
102
+ _define_property(GuideOpen, "args", {
103
+ guideKey: _core.Args.string({
104
+ required: true
105
+ })
106
+ });
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return LayoutOpen;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _browser = require("../../lib/helpers/browser");
14
+ const _error = require("../../lib/helpers/error");
15
+ const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
16
+ const _request = require("../../lib/helpers/request");
17
+ const _urls = require("../../lib/urls");
18
+ function _define_property(obj, key, value) {
19
+ if (key in obj) {
20
+ Object.defineProperty(obj, key, {
21
+ value: value,
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true
25
+ });
26
+ } else {
27
+ obj[key] = value;
28
+ }
29
+ return obj;
30
+ }
31
+ function _interop_require_default(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
36
+ function _getRequireWildcardCache(nodeInterop) {
37
+ if (typeof WeakMap !== "function") return null;
38
+ var cacheBabelInterop = new WeakMap();
39
+ var cacheNodeInterop = new WeakMap();
40
+ return (_getRequireWildcardCache = function(nodeInterop) {
41
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
+ })(nodeInterop);
43
+ }
44
+ function _interop_require_wildcard(obj, nodeInterop) {
45
+ if (!nodeInterop && obj && obj.__esModule) {
46
+ return obj;
47
+ }
48
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
49
+ return {
50
+ default: obj
51
+ };
52
+ }
53
+ var cache = _getRequireWildcardCache(nodeInterop);
54
+ if (cache && cache.has(obj)) {
55
+ return cache.get(obj);
56
+ }
57
+ var newObj = {
58
+ __proto__: null
59
+ };
60
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
61
+ for(var key in obj){
62
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
63
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
64
+ if (desc && (desc.get || desc.set)) {
65
+ Object.defineProperty(newObj, key, desc);
66
+ } else {
67
+ newObj[key] = obj[key];
68
+ }
69
+ }
70
+ }
71
+ newObj.default = obj;
72
+ if (cache) {
73
+ cache.set(obj, newObj);
74
+ }
75
+ return newObj;
76
+ }
77
+ class LayoutOpen extends _basecommand.default {
78
+ async run() {
79
+ const whoamiResp = await this.apiV1.whoami();
80
+ if (!(0, _request.isSuccessResp)(whoamiResp)) {
81
+ const message = (0, _request.formatErrorRespMessage)(whoamiResp);
82
+ _core.ux.error(new _error.ApiError(message));
83
+ }
84
+ const { account_slug } = whoamiResp.data;
85
+ const { layoutKey } = this.props.args;
86
+ const { environment, branch } = this.props.flags;
87
+ const envOrBranch = branch !== null && branch !== void 0 ? branch : environment;
88
+ const url = (0, _urls.viewLayoutUrl)(this.sessionContext.dashboardOrigin, account_slug, envOrBranch, layoutKey);
89
+ this.log(`‣ Opening layout \`${layoutKey}\` in the Knock dashboard...`);
90
+ this.log(` ${url}`);
91
+ await _browser.browser.openUrl(url);
92
+ }
93
+ }
94
+ _define_property(LayoutOpen, "summary", "Open a layout in the Knock dashboard.");
95
+ _define_property(LayoutOpen, "flags", {
96
+ environment: _core.Flags.string({
97
+ default: "development",
98
+ summary: "The environment to use."
99
+ }),
100
+ branch: _flag.branch
101
+ });
102
+ _define_property(LayoutOpen, "args", {
103
+ layoutKey: _core.Args.string({
104
+ required: true
105
+ })
106
+ });
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return MessageTypeOpen;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _browser = require("../../lib/helpers/browser");
14
+ const _error = require("../../lib/helpers/error");
15
+ const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
16
+ const _request = require("../../lib/helpers/request");
17
+ const _urls = require("../../lib/urls");
18
+ function _define_property(obj, key, value) {
19
+ if (key in obj) {
20
+ Object.defineProperty(obj, key, {
21
+ value: value,
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true
25
+ });
26
+ } else {
27
+ obj[key] = value;
28
+ }
29
+ return obj;
30
+ }
31
+ function _interop_require_default(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
36
+ function _getRequireWildcardCache(nodeInterop) {
37
+ if (typeof WeakMap !== "function") return null;
38
+ var cacheBabelInterop = new WeakMap();
39
+ var cacheNodeInterop = new WeakMap();
40
+ return (_getRequireWildcardCache = function(nodeInterop) {
41
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
+ })(nodeInterop);
43
+ }
44
+ function _interop_require_wildcard(obj, nodeInterop) {
45
+ if (!nodeInterop && obj && obj.__esModule) {
46
+ return obj;
47
+ }
48
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
49
+ return {
50
+ default: obj
51
+ };
52
+ }
53
+ var cache = _getRequireWildcardCache(nodeInterop);
54
+ if (cache && cache.has(obj)) {
55
+ return cache.get(obj);
56
+ }
57
+ var newObj = {
58
+ __proto__: null
59
+ };
60
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
61
+ for(var key in obj){
62
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
63
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
64
+ if (desc && (desc.get || desc.set)) {
65
+ Object.defineProperty(newObj, key, desc);
66
+ } else {
67
+ newObj[key] = obj[key];
68
+ }
69
+ }
70
+ }
71
+ newObj.default = obj;
72
+ if (cache) {
73
+ cache.set(obj, newObj);
74
+ }
75
+ return newObj;
76
+ }
77
+ class MessageTypeOpen extends _basecommand.default {
78
+ async run() {
79
+ const whoamiResp = await this.apiV1.whoami();
80
+ if (!(0, _request.isSuccessResp)(whoamiResp)) {
81
+ const message = (0, _request.formatErrorRespMessage)(whoamiResp);
82
+ _core.ux.error(new _error.ApiError(message));
83
+ }
84
+ const { account_slug } = whoamiResp.data;
85
+ const { messageTypeKey } = this.props.args;
86
+ const { environment, branch } = this.props.flags;
87
+ const envOrBranch = branch !== null && branch !== void 0 ? branch : environment;
88
+ const url = (0, _urls.viewMessageTypeUrl)(this.sessionContext.dashboardOrigin, account_slug, envOrBranch, messageTypeKey);
89
+ this.log(`‣ Opening message type \`${messageTypeKey}\` in the Knock dashboard...`);
90
+ this.log(` ${url}`);
91
+ await _browser.browser.openUrl(url);
92
+ }
93
+ }
94
+ _define_property(MessageTypeOpen, "summary", "Open a message type in the Knock dashboard.");
95
+ _define_property(MessageTypeOpen, "flags", {
96
+ environment: _core.Flags.string({
97
+ default: "development",
98
+ summary: "The environment to use."
99
+ }),
100
+ branch: _flag.branch
101
+ });
102
+ _define_property(MessageTypeOpen, "args", {
103
+ messageTypeKey: _core.Args.string({
104
+ required: true
105
+ })
106
+ });
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return PartialOpen;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _browser = require("../../lib/helpers/browser");
14
+ const _error = require("../../lib/helpers/error");
15
+ const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
16
+ const _request = require("../../lib/helpers/request");
17
+ const _urls = require("../../lib/urls");
18
+ function _define_property(obj, key, value) {
19
+ if (key in obj) {
20
+ Object.defineProperty(obj, key, {
21
+ value: value,
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true
25
+ });
26
+ } else {
27
+ obj[key] = value;
28
+ }
29
+ return obj;
30
+ }
31
+ function _interop_require_default(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
36
+ function _getRequireWildcardCache(nodeInterop) {
37
+ if (typeof WeakMap !== "function") return null;
38
+ var cacheBabelInterop = new WeakMap();
39
+ var cacheNodeInterop = new WeakMap();
40
+ return (_getRequireWildcardCache = function(nodeInterop) {
41
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
+ })(nodeInterop);
43
+ }
44
+ function _interop_require_wildcard(obj, nodeInterop) {
45
+ if (!nodeInterop && obj && obj.__esModule) {
46
+ return obj;
47
+ }
48
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
49
+ return {
50
+ default: obj
51
+ };
52
+ }
53
+ var cache = _getRequireWildcardCache(nodeInterop);
54
+ if (cache && cache.has(obj)) {
55
+ return cache.get(obj);
56
+ }
57
+ var newObj = {
58
+ __proto__: null
59
+ };
60
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
61
+ for(var key in obj){
62
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
63
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
64
+ if (desc && (desc.get || desc.set)) {
65
+ Object.defineProperty(newObj, key, desc);
66
+ } else {
67
+ newObj[key] = obj[key];
68
+ }
69
+ }
70
+ }
71
+ newObj.default = obj;
72
+ if (cache) {
73
+ cache.set(obj, newObj);
74
+ }
75
+ return newObj;
76
+ }
77
+ class PartialOpen extends _basecommand.default {
78
+ async run() {
79
+ const whoamiResp = await this.apiV1.whoami();
80
+ if (!(0, _request.isSuccessResp)(whoamiResp)) {
81
+ const message = (0, _request.formatErrorRespMessage)(whoamiResp);
82
+ _core.ux.error(new _error.ApiError(message));
83
+ }
84
+ const { account_slug } = whoamiResp.data;
85
+ const { partialKey } = this.props.args;
86
+ const { environment, branch } = this.props.flags;
87
+ const envOrBranch = branch !== null && branch !== void 0 ? branch : environment;
88
+ const url = (0, _urls.viewPartialUrl)(this.sessionContext.dashboardOrigin, account_slug, envOrBranch, partialKey);
89
+ this.log(`‣ Opening partial \`${partialKey}\` in the Knock dashboard...`);
90
+ this.log(` ${url}`);
91
+ await _browser.browser.openUrl(url);
92
+ }
93
+ }
94
+ _define_property(PartialOpen, "summary", "Open a partial in the Knock dashboard.");
95
+ _define_property(PartialOpen, "flags", {
96
+ environment: _core.Flags.string({
97
+ default: "development",
98
+ summary: "The environment to use."
99
+ }),
100
+ branch: _flag.branch
101
+ });
102
+ _define_property(PartialOpen, "args", {
103
+ partialKey: _core.Args.string({
104
+ required: true
105
+ })
106
+ });
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return WorkflowOpen;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _browser = require("../../lib/helpers/browser");
14
+ const _error = require("../../lib/helpers/error");
15
+ const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
16
+ const _request = require("../../lib/helpers/request");
17
+ const _urls = require("../../lib/urls");
18
+ function _define_property(obj, key, value) {
19
+ if (key in obj) {
20
+ Object.defineProperty(obj, key, {
21
+ value: value,
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true
25
+ });
26
+ } else {
27
+ obj[key] = value;
28
+ }
29
+ return obj;
30
+ }
31
+ function _interop_require_default(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
36
+ function _getRequireWildcardCache(nodeInterop) {
37
+ if (typeof WeakMap !== "function") return null;
38
+ var cacheBabelInterop = new WeakMap();
39
+ var cacheNodeInterop = new WeakMap();
40
+ return (_getRequireWildcardCache = function(nodeInterop) {
41
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
+ })(nodeInterop);
43
+ }
44
+ function _interop_require_wildcard(obj, nodeInterop) {
45
+ if (!nodeInterop && obj && obj.__esModule) {
46
+ return obj;
47
+ }
48
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
49
+ return {
50
+ default: obj
51
+ };
52
+ }
53
+ var cache = _getRequireWildcardCache(nodeInterop);
54
+ if (cache && cache.has(obj)) {
55
+ return cache.get(obj);
56
+ }
57
+ var newObj = {
58
+ __proto__: null
59
+ };
60
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
61
+ for(var key in obj){
62
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
63
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
64
+ if (desc && (desc.get || desc.set)) {
65
+ Object.defineProperty(newObj, key, desc);
66
+ } else {
67
+ newObj[key] = obj[key];
68
+ }
69
+ }
70
+ }
71
+ newObj.default = obj;
72
+ if (cache) {
73
+ cache.set(obj, newObj);
74
+ }
75
+ return newObj;
76
+ }
77
+ class WorkflowOpen extends _basecommand.default {
78
+ async run() {
79
+ const whoamiResp = await this.apiV1.whoami();
80
+ if (!(0, _request.isSuccessResp)(whoamiResp)) {
81
+ const message = (0, _request.formatErrorRespMessage)(whoamiResp);
82
+ _core.ux.error(new _error.ApiError(message));
83
+ }
84
+ const { account_slug } = whoamiResp.data;
85
+ const { workflowKey } = this.props.args;
86
+ const { environment, branch } = this.props.flags;
87
+ const envOrBranch = branch !== null && branch !== void 0 ? branch : environment;
88
+ const url = (0, _urls.viewWorkflowUrl)(this.sessionContext.dashboardOrigin, account_slug, envOrBranch, workflowKey);
89
+ this.log(`‣ Opening workflow \`${workflowKey}\` in the Knock dashboard...`);
90
+ this.log(` ${url}`);
91
+ await _browser.browser.openUrl(url);
92
+ }
93
+ }
94
+ _define_property(WorkflowOpen, "summary", "Open a workflow in the Knock dashboard.");
95
+ _define_property(WorkflowOpen, "flags", {
96
+ environment: _core.Flags.string({
97
+ default: "development",
98
+ summary: "The environment to use."
99
+ }),
100
+ branch: _flag.branch
101
+ });
102
+ _define_property(WorkflowOpen, "args", {
103
+ workflowKey: _core.Args.string({
104
+ required: true
105
+ })
106
+ });
package/dist/lib/urls.js CHANGED
@@ -24,6 +24,18 @@ _export(exports, {
24
24
  get authSuccessUrl () {
25
25
  return authSuccessUrl;
26
26
  },
27
+ get viewGuideUrl () {
28
+ return viewGuideUrl;
29
+ },
30
+ get viewLayoutUrl () {
31
+ return viewLayoutUrl;
32
+ },
33
+ get viewMessageTypeUrl () {
34
+ return viewMessageTypeUrl;
35
+ },
36
+ get viewPartialUrl () {
37
+ return viewPartialUrl;
38
+ },
27
39
  get viewWorkflowUrl () {
28
40
  return viewWorkflowUrl;
29
41
  }
@@ -34,3 +46,7 @@ const DEFAULT_API_URL = "https://control.knock.app";
34
46
  const authSuccessUrl = (dashboardUrl)=>`${dashboardUrl}/auth/oauth/cli`;
35
47
  const authErrorUrl = (dashboardUrl, error)=>`${dashboardUrl}/auth/oauth/cli?error=${error}`;
36
48
  const viewWorkflowUrl = (dashboardUrl, accountSlug, envOrBranchSlug, workflowKey)=>`${dashboardUrl}/${accountSlug}/${envOrBranchSlug.toLowerCase()}/workflows/${workflowKey}`;
49
+ const viewGuideUrl = (dashboardUrl, accountSlug, envOrBranchSlug, guideKey)=>`${dashboardUrl}/${accountSlug}/${envOrBranchSlug.toLowerCase()}/guides/${guideKey}`;
50
+ const viewLayoutUrl = (dashboardUrl, accountSlug, envOrBranchSlug, layoutKey)=>`${dashboardUrl}/${accountSlug}/${envOrBranchSlug.toLowerCase()}/layouts/${layoutKey}`;
51
+ const viewMessageTypeUrl = (dashboardUrl, accountSlug, envOrBranchSlug, messageTypeKey)=>`${dashboardUrl}/${accountSlug}/${envOrBranchSlug.toLowerCase()}/message-types/${messageTypeKey}`;
52
+ const viewPartialUrl = (dashboardUrl, accountSlug, envOrBranchSlug, partialKey)=>`${dashboardUrl}/${accountSlug}/${envOrBranchSlug.toLowerCase()}/partials/${partialKey}`;