@knocklabs/cli 0.1.19 → 0.1.20

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.
@@ -76,7 +76,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
76
76
  /*
77
77
  * For the given list of partial directory contexts, read each partial dir and
78
78
  * return partial directory data.
79
- */ const readPartialsDirs = async (partialDirCtxs, opts = {})=>{
79
+ */ const readPartialDirs = async (partialDirCtxs, opts = {})=>{
80
80
  const partials = [];
81
81
  const errors = [];
82
82
  for (const partialDirCtx of partialDirCtxs){
@@ -170,7 +170,7 @@ const readAllForCommandTarget = async (target, opts = {})=>{
170
170
  switch(targetType){
171
171
  case "partialDir":
172
172
  {
173
- return readPartialsDirs([
173
+ return readPartialDirs([
174
174
  targetCtx
175
175
  ], opts);
176
176
  }
@@ -190,7 +190,7 @@ const readAllForCommandTarget = async (target, opts = {})=>{
190
190
  return partialDirCtx;
191
191
  });
192
192
  const partialDirCtxs = (await Promise.all(promises)).filter((partialDirCtx)=>partialDirCtx.exists);
193
- return readPartialsDirs(partialDirCtxs, opts);
193
+ return readPartialDirs(partialDirCtxs, opts);
194
194
  }
195
195
  default:
196
196
  throw new Error(`Invalid partial command target: ${target}`);
@@ -8,10 +8,10 @@ Object.defineProperty(exports, "PartialType", {
8
8
  return PartialType;
9
9
  }
10
10
  });
11
- var PartialType;
12
- (function(PartialType) {
11
+ var PartialType = /*#__PURE__*/ function(PartialType) {
13
12
  PartialType["Html"] = "html";
14
13
  PartialType["Json"] = "json";
15
14
  PartialType["Markdown"] = "markdown";
16
15
  PartialType["Text"] = "text";
17
- })(PartialType || (PartialType = {}));
16
+ return PartialType;
17
+ }({});
@@ -8,12 +8,12 @@ Object.defineProperty(exports, "StepType", {
8
8
  return StepType;
9
9
  }
10
10
  });
11
- var StepType;
12
- (function(StepType) {
11
+ var StepType = /*#__PURE__*/ function(StepType) {
13
12
  StepType["Channel"] = "channel";
14
13
  StepType["Batch"] = "batch";
15
14
  StepType["Delay"] = "delay";
16
15
  StepType["HttpFetch"] = "http_fetch";
17
16
  StepType["Branch"] = "branch";
18
17
  StepType["Throttle"] = "throttle";
19
- })(StepType || (StepType = {}));
18
+ return StepType;
19
+ }({});
@@ -14,6 +14,8 @@ Object.defineProperty(exports, "load", {
14
14
  });
15
15
  const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
16
16
  const _emaillayout = /*#__PURE__*/ _interop_require_wildcard(require("../marshal/email-layout"));
17
+ const _messagetype = /*#__PURE__*/ _interop_require_wildcard(require("../marshal/message-type"));
18
+ const _partial = /*#__PURE__*/ _interop_require_wildcard(require("../marshal/partial"));
17
19
  const _translation = /*#__PURE__*/ _interop_require_wildcard(require("../marshal/translation"));
18
20
  const _workflow = /*#__PURE__*/ _interop_require_wildcard(require("../marshal/workflow"));
19
21
  function _getRequireWildcardCache(nodeInterop) {
@@ -57,38 +59,40 @@ function _interop_require_wildcard(obj, nodeInterop) {
57
59
  }
58
60
  return newObj;
59
61
  }
62
+ const buildResourceDirContext = (type, currDir)=>{
63
+ return {
64
+ type,
65
+ key: _nodepath.basename(currDir),
66
+ abspath: currDir,
67
+ exists: true
68
+ };
69
+ };
60
70
  const evaluateRecursively = async (ctx, currDir)=>{
61
- // Check if we are inside a workflow directory, and if so update the context.
62
- const isWorkflowDir = await _workflow.isWorkflowDir(currDir);
63
- if (!ctx.resourceDir && isWorkflowDir) {
64
- ctx.resourceDir = {
65
- type: "workflow",
66
- key: _nodepath.basename(currDir),
67
- abspath: currDir,
68
- exists: true
69
- };
70
- }
71
- // Check if we are inside a layout directory, and if so update the context.
72
- const isEmailLayoutDir = await _emaillayout.isEmailLayoutDir(currDir);
73
- if (!ctx.resourceDir && isEmailLayoutDir) {
74
- ctx.resourceDir = {
75
- type: "email_layout",
76
- key: _nodepath.basename(currDir),
77
- abspath: currDir,
78
- exists: true
79
- };
80
- }
81
- // NOTE: Must keep this check as last in the order of directory-type checks
82
- // since the `isTranslationDir` only checks that the directory name is a
83
- // valid locale name.
84
- const isTranslationDir = _translation.isTranslationDir(currDir);
85
- if (!ctx.resourceDir && isTranslationDir) {
86
- ctx.resourceDir = {
87
- type: "translation",
88
- key: _nodepath.basename(currDir),
89
- abspath: currDir,
90
- exists: true
91
- };
71
+ // Check if we are inside a resource directory and if so update the context.
72
+ if (!ctx.resourceDir) {
73
+ const isWorkflowDir = await _workflow.isWorkflowDir(currDir);
74
+ if (isWorkflowDir) {
75
+ ctx.resourceDir = buildResourceDirContext("workflow", currDir);
76
+ }
77
+ const isEmailLayoutDir = await _emaillayout.isEmailLayoutDir(currDir);
78
+ if (isEmailLayoutDir) {
79
+ ctx.resourceDir = buildResourceDirContext("email_layout", currDir);
80
+ }
81
+ const isPartialDir = await _partial.isPartialDir(currDir);
82
+ if (isPartialDir) {
83
+ ctx.resourceDir = buildResourceDirContext("partial", currDir);
84
+ }
85
+ const isMessageTypeDir = await _messagetype.isMessageTypeDir(currDir);
86
+ if (isMessageTypeDir) {
87
+ ctx.resourceDir = buildResourceDirContext("message_type", currDir);
88
+ }
89
+ // NOTE: Must keep this check as last in the order of directory-type checks
90
+ // since the `isTranslationDir` only checks that the directory name is a
91
+ // valid locale name.
92
+ const isTranslationDir = _translation.isTranslationDir(currDir);
93
+ if (isTranslationDir) {
94
+ ctx.resourceDir = buildResourceDirContext("translation", currDir);
95
+ }
92
96
  }
93
97
  // If we've identified the resource context, no need to go further.
94
98
  // TODO: In the future, consider supporting a knock project config file which
@@ -770,6 +770,396 @@
770
770
  "validate.js"
771
771
  ]
772
772
  },
773
+ "message-type:get": {
774
+ "aliases": [],
775
+ "args": {
776
+ "messageTypeKey": {
777
+ "name": "messageTypeKey",
778
+ "required": true
779
+ }
780
+ },
781
+ "flags": {
782
+ "json": {
783
+ "description": "Format output as json.",
784
+ "helpGroup": "GLOBAL",
785
+ "name": "json",
786
+ "allowNo": false,
787
+ "type": "boolean"
788
+ },
789
+ "service-token": {
790
+ "env": "KNOCK_SERVICE_TOKEN",
791
+ "name": "service-token",
792
+ "required": true,
793
+ "summary": "The service token to authenticate with.",
794
+ "hasDynamicHelp": false,
795
+ "multiple": false,
796
+ "type": "option"
797
+ },
798
+ "api-origin": {
799
+ "hidden": true,
800
+ "name": "api-origin",
801
+ "required": false,
802
+ "hasDynamicHelp": false,
803
+ "multiple": false,
804
+ "type": "option"
805
+ },
806
+ "environment": {
807
+ "name": "environment",
808
+ "summary": "The environment to use.",
809
+ "default": "development",
810
+ "hasDynamicHelp": false,
811
+ "multiple": false,
812
+ "type": "option"
813
+ },
814
+ "hide-uncommitted-changes": {
815
+ "name": "hide-uncommitted-changes",
816
+ "summary": "Hide any uncommitted changes.",
817
+ "allowNo": false,
818
+ "type": "boolean"
819
+ }
820
+ },
821
+ "hasDynamicHelp": false,
822
+ "hidden": true,
823
+ "hiddenAliases": [],
824
+ "id": "message-type:get",
825
+ "pluginAlias": "@knocklabs/cli",
826
+ "pluginName": "@knocklabs/cli",
827
+ "pluginType": "core",
828
+ "strict": true,
829
+ "summary": "Display a single in-app message type from an environment.",
830
+ "enableJsonFlag": true,
831
+ "isESM": false,
832
+ "relativePath": [
833
+ "dist",
834
+ "commands",
835
+ "message-type",
836
+ "get.js"
837
+ ]
838
+ },
839
+ "message-type:list": {
840
+ "aliases": [],
841
+ "args": {},
842
+ "flags": {
843
+ "json": {
844
+ "description": "Format output as json.",
845
+ "helpGroup": "GLOBAL",
846
+ "name": "json",
847
+ "allowNo": false,
848
+ "type": "boolean"
849
+ },
850
+ "service-token": {
851
+ "env": "KNOCK_SERVICE_TOKEN",
852
+ "name": "service-token",
853
+ "required": true,
854
+ "summary": "The service token to authenticate with.",
855
+ "hasDynamicHelp": false,
856
+ "multiple": false,
857
+ "type": "option"
858
+ },
859
+ "api-origin": {
860
+ "hidden": true,
861
+ "name": "api-origin",
862
+ "required": false,
863
+ "hasDynamicHelp": false,
864
+ "multiple": false,
865
+ "type": "option"
866
+ },
867
+ "environment": {
868
+ "name": "environment",
869
+ "summary": "The environment to use.",
870
+ "default": "development",
871
+ "hasDynamicHelp": false,
872
+ "multiple": false,
873
+ "type": "option"
874
+ },
875
+ "hide-uncommitted-changes": {
876
+ "name": "hide-uncommitted-changes",
877
+ "summary": "Hide any uncommitted changes.",
878
+ "allowNo": false,
879
+ "type": "boolean"
880
+ },
881
+ "after": {
882
+ "name": "after",
883
+ "summary": "The cursor after which to fetch the next page.",
884
+ "hasDynamicHelp": false,
885
+ "multiple": false,
886
+ "type": "option"
887
+ },
888
+ "before": {
889
+ "name": "before",
890
+ "summary": "The cursor before which to fetch the previous page.",
891
+ "hasDynamicHelp": false,
892
+ "multiple": false,
893
+ "type": "option"
894
+ },
895
+ "limit": {
896
+ "name": "limit",
897
+ "summary": "The total number of entries to fetch per page.",
898
+ "hasDynamicHelp": false,
899
+ "multiple": false,
900
+ "type": "option"
901
+ }
902
+ },
903
+ "hasDynamicHelp": false,
904
+ "hidden": true,
905
+ "hiddenAliases": [],
906
+ "id": "message-type:list",
907
+ "pluginAlias": "@knocklabs/cli",
908
+ "pluginName": "@knocklabs/cli",
909
+ "pluginType": "core",
910
+ "strict": true,
911
+ "summary": "Display all in-app message types for an environment.",
912
+ "enableJsonFlag": true,
913
+ "isESM": false,
914
+ "relativePath": [
915
+ "dist",
916
+ "commands",
917
+ "message-type",
918
+ "list.js"
919
+ ]
920
+ },
921
+ "message-type:pull": {
922
+ "aliases": [],
923
+ "args": {
924
+ "messageTypeKey": {
925
+ "name": "messageTypeKey",
926
+ "required": false
927
+ }
928
+ },
929
+ "flags": {
930
+ "service-token": {
931
+ "env": "KNOCK_SERVICE_TOKEN",
932
+ "name": "service-token",
933
+ "required": true,
934
+ "summary": "The service token to authenticate with.",
935
+ "hasDynamicHelp": false,
936
+ "multiple": false,
937
+ "type": "option"
938
+ },
939
+ "api-origin": {
940
+ "hidden": true,
941
+ "name": "api-origin",
942
+ "required": false,
943
+ "hasDynamicHelp": false,
944
+ "multiple": false,
945
+ "type": "option"
946
+ },
947
+ "environment": {
948
+ "name": "environment",
949
+ "summary": "The environment to use.",
950
+ "default": "development",
951
+ "hasDynamicHelp": false,
952
+ "multiple": false,
953
+ "type": "option"
954
+ },
955
+ "all": {
956
+ "name": "all",
957
+ "summary": "Whether to pull all in-app message types from the specified environment.",
958
+ "allowNo": false,
959
+ "type": "boolean"
960
+ },
961
+ "message-types-dir": {
962
+ "dependsOn": [
963
+ "all"
964
+ ],
965
+ "name": "message-types-dir",
966
+ "summary": "The target directory path to pull all in-app message types into.",
967
+ "hasDynamicHelp": false,
968
+ "multiple": false,
969
+ "type": "option"
970
+ },
971
+ "hide-uncommitted-changes": {
972
+ "name": "hide-uncommitted-changes",
973
+ "summary": "Hide any uncommitted changes.",
974
+ "allowNo": false,
975
+ "type": "boolean"
976
+ },
977
+ "force": {
978
+ "name": "force",
979
+ "summary": "Remove the confirmation prompt.",
980
+ "allowNo": false,
981
+ "type": "boolean"
982
+ }
983
+ },
984
+ "hasDynamicHelp": false,
985
+ "hidden": true,
986
+ "hiddenAliases": [],
987
+ "id": "message-type:pull",
988
+ "pluginAlias": "@knocklabs/cli",
989
+ "pluginName": "@knocklabs/cli",
990
+ "pluginType": "core",
991
+ "strict": true,
992
+ "summary": "Pull one or more in-app message types from an environment into a local file system.",
993
+ "enableJsonFlag": false,
994
+ "isESM": false,
995
+ "relativePath": [
996
+ "dist",
997
+ "commands",
998
+ "message-type",
999
+ "pull.js"
1000
+ ]
1001
+ },
1002
+ "message-type:push": {
1003
+ "aliases": [],
1004
+ "args": {
1005
+ "messageTypeKey": {
1006
+ "name": "messageTypeKey",
1007
+ "required": false
1008
+ }
1009
+ },
1010
+ "flags": {
1011
+ "service-token": {
1012
+ "env": "KNOCK_SERVICE_TOKEN",
1013
+ "name": "service-token",
1014
+ "required": true,
1015
+ "summary": "The service token to authenticate with.",
1016
+ "hasDynamicHelp": false,
1017
+ "multiple": false,
1018
+ "type": "option"
1019
+ },
1020
+ "api-origin": {
1021
+ "hidden": true,
1022
+ "name": "api-origin",
1023
+ "required": false,
1024
+ "hasDynamicHelp": false,
1025
+ "multiple": false,
1026
+ "type": "option"
1027
+ },
1028
+ "environment": {
1029
+ "name": "environment",
1030
+ "summary": "Pushing a message type is only allowed in the development environment",
1031
+ "default": "development",
1032
+ "hasDynamicHelp": false,
1033
+ "multiple": false,
1034
+ "options": [
1035
+ "development"
1036
+ ],
1037
+ "type": "option"
1038
+ },
1039
+ "all": {
1040
+ "name": "all",
1041
+ "summary": "Whether to push all message types from the target directory.",
1042
+ "allowNo": false,
1043
+ "type": "boolean"
1044
+ },
1045
+ "message-types-dir": {
1046
+ "dependsOn": [
1047
+ "all"
1048
+ ],
1049
+ "name": "message-types-dir",
1050
+ "summary": "The target directory path to find all message types to push.",
1051
+ "hasDynamicHelp": false,
1052
+ "multiple": false,
1053
+ "type": "option"
1054
+ },
1055
+ "commit": {
1056
+ "name": "commit",
1057
+ "summary": "Push and commit the message type(s) at the same time",
1058
+ "allowNo": false,
1059
+ "type": "boolean"
1060
+ },
1061
+ "commit-message": {
1062
+ "char": "m",
1063
+ "dependsOn": [
1064
+ "commit"
1065
+ ],
1066
+ "name": "commit-message",
1067
+ "summary": "Use the given value as the commit message",
1068
+ "hasDynamicHelp": false,
1069
+ "multiple": false,
1070
+ "type": "option"
1071
+ }
1072
+ },
1073
+ "hasDynamicHelp": false,
1074
+ "hidden": true,
1075
+ "hiddenAliases": [],
1076
+ "id": "message-type:push",
1077
+ "pluginAlias": "@knocklabs/cli",
1078
+ "pluginName": "@knocklabs/cli",
1079
+ "pluginType": "core",
1080
+ "strict": true,
1081
+ "summary": "Push one or more message types from a local file system to Knock.",
1082
+ "enableJsonFlag": false,
1083
+ "isESM": false,
1084
+ "relativePath": [
1085
+ "dist",
1086
+ "commands",
1087
+ "message-type",
1088
+ "push.js"
1089
+ ]
1090
+ },
1091
+ "message-type:validate": {
1092
+ "aliases": [],
1093
+ "args": {
1094
+ "messageTypeKey": {
1095
+ "name": "messageTypeKey",
1096
+ "required": false
1097
+ }
1098
+ },
1099
+ "flags": {
1100
+ "service-token": {
1101
+ "env": "KNOCK_SERVICE_TOKEN",
1102
+ "name": "service-token",
1103
+ "required": true,
1104
+ "summary": "The service token to authenticate with.",
1105
+ "hasDynamicHelp": false,
1106
+ "multiple": false,
1107
+ "type": "option"
1108
+ },
1109
+ "api-origin": {
1110
+ "hidden": true,
1111
+ "name": "api-origin",
1112
+ "required": false,
1113
+ "hasDynamicHelp": false,
1114
+ "multiple": false,
1115
+ "type": "option"
1116
+ },
1117
+ "environment": {
1118
+ "name": "environment",
1119
+ "summary": "Validating a message type is only done in the development environment",
1120
+ "default": "development",
1121
+ "hasDynamicHelp": false,
1122
+ "multiple": false,
1123
+ "options": [
1124
+ "development"
1125
+ ],
1126
+ "type": "option"
1127
+ },
1128
+ "all": {
1129
+ "name": "all",
1130
+ "summary": "Whether to validate all message types from the target directory.",
1131
+ "allowNo": false,
1132
+ "type": "boolean"
1133
+ },
1134
+ "message-types-dir": {
1135
+ "dependsOn": [
1136
+ "all"
1137
+ ],
1138
+ "name": "message-types-dir",
1139
+ "summary": "The target directory path to find all message types to validate.",
1140
+ "hasDynamicHelp": false,
1141
+ "multiple": false,
1142
+ "type": "option"
1143
+ }
1144
+ },
1145
+ "hasDynamicHelp": false,
1146
+ "hidden": true,
1147
+ "hiddenAliases": [],
1148
+ "id": "message-type:validate",
1149
+ "pluginAlias": "@knocklabs/cli",
1150
+ "pluginName": "@knocklabs/cli",
1151
+ "pluginType": "core",
1152
+ "strict": true,
1153
+ "summary": "Validate one or more message types from a local file system.",
1154
+ "enableJsonFlag": false,
1155
+ "isESM": false,
1156
+ "relativePath": [
1157
+ "dist",
1158
+ "commands",
1159
+ "message-type",
1160
+ "validate.js"
1161
+ ]
1162
+ },
773
1163
  "partial:get": {
774
1164
  "aliases": [],
775
1165
  "args": {
@@ -2167,5 +2557,5 @@
2167
2557
  ]
2168
2558
  }
2169
2559
  },
2170
- "version": "0.1.19"
2560
+ "version": "0.1.20"
2171
2561
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/cli",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Knock CLI",
5
5
  "author": "@knocklabs",
6
6
  "bin": {
@@ -19,12 +19,12 @@
19
19
  "dependencies": {
20
20
  "@oclif/core": "^3",
21
21
  "@oclif/plugin-help": "^6",
22
- "@prantlf/jsonlint": "^14.0.3",
23
- "axios": "^1.7.3",
22
+ "@prantlf/jsonlint": "^14.1.0",
23
+ "axios": "^1.7.9",
24
24
  "date-fns": "^2.30.0",
25
25
  "enquirer": "^2.4.1",
26
- "fs-extra": "^11.2.0",
27
- "liquidjs": "^10.16.1",
26
+ "fs-extra": "^11.3.0",
27
+ "liquidjs": "^10.21.0",
28
28
  "locale-codes": "^1.3.1",
29
29
  "lodash": "^4.17.21",
30
30
  "yup": "^1.4.0"
@@ -32,12 +32,12 @@
32
32
  "devDependencies": {
33
33
  "@oclif/test": "^3",
34
34
  "@swc/cli": "^0.4.0",
35
- "@swc/core": "^1.5.7",
36
- "@swc/helpers": "^0.5.12",
35
+ "@swc/core": "^1.10.6",
36
+ "@swc/helpers": "^0.5.15",
37
37
  "@types/chai": "^4",
38
38
  "@types/fs-extra": "^11.0.4",
39
- "@types/mocha": "^10.0.6",
40
- "@types/node": "^20.14.14",
39
+ "@types/mocha": "^10.0.10",
40
+ "@types/node": "^20.17.24",
41
41
  "chai": "^4",
42
42
  "eslint": "^7.32.0",
43
43
  "eslint-config-oclif": "^4",
@@ -46,14 +46,14 @@
46
46
  "eslint-plugin-prettier": "^4.2.1",
47
47
  "eslint-plugin-simple-import-sort": "^10.0.0",
48
48
  "mocha": "^10",
49
- "nock": "^13.5.4",
49
+ "nock": "^13.5.6",
50
50
  "oclif": "^4",
51
51
  "prettier": "2.8.8",
52
52
  "shx": "^0.3.4",
53
53
  "sinon": "^16.1.3",
54
54
  "ts-node": "^10.9.1",
55
55
  "tsconfig-paths": "^4.2.0",
56
- "tslib": "^2.6.3",
56
+ "tslib": "^2.8.1",
57
57
  "typescript": "^5.5.4"
58
58
  },
59
59
  "oclif": {