@knocklabs/cli 1.1.1 → 1.2.2
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/README.md +297 -170
- package/dist/commands/audience/new.js +2 -2
- package/dist/commands/branch/rebase.js +65 -0
- package/dist/commands/commit/index.js +15 -11
- package/dist/commands/commit/list.js +2 -8
- package/dist/commands/guide/get.js +6 -0
- package/dist/commands/guide/list.js +6 -0
- package/dist/commands/guide/push.js +1 -0
- package/dist/commands/layout/push.js +1 -0
- package/dist/commands/message-type/push.js +1 -0
- package/dist/commands/partial/push.js +1 -0
- package/dist/commands/push.js +4 -0
- package/dist/commands/schema/pull.js +197 -0
- package/dist/commands/schema/push.js +203 -0
- package/dist/commands/source/get.js +180 -0
- package/dist/commands/source/list.js +96 -0
- package/dist/commands/translation/push.js +1 -0
- package/dist/commands/whoami.js +8 -2
- package/dist/commands/workflow/get.js +6 -0
- package/dist/commands/workflow/list.js +6 -0
- package/dist/commands/workflow/push.js +1 -0
- package/dist/commands/workflow/run.js +6 -0
- package/dist/help.js +74 -0
- package/dist/lib/api-v1.js +78 -1
- package/dist/lib/auth.js +3 -2
- package/dist/lib/helpers/flag.js +15 -0
- package/dist/lib/marshal/guide/helpers.js +11 -0
- package/dist/lib/marshal/schema/helpers.js +142 -0
- package/dist/lib/marshal/schema/index.js +21 -0
- package/dist/lib/marshal/schema/reader.js +177 -0
- package/dist/lib/marshal/schema/types.js +15 -0
- package/dist/lib/marshal/schema/writer.js +154 -0
- package/dist/lib/marshal/shared/helpers.js +30 -14
- package/dist/lib/marshal/source/helpers.js +28 -0
- package/dist/lib/marshal/source/index.js +19 -0
- package/dist/lib/marshal/source/types.js +4 -0
- package/dist/lib/marshal/workflow/generator.js +11 -8
- package/dist/lib/marshal/workflow/helpers.js +10 -6
- package/dist/lib/resources.js +11 -0
- package/npm-shrinkwrap.json +10698 -0
- package/oclif.manifest.json +448 -11
- package/package.json +22 -15
|
@@ -157,7 +157,7 @@ const scaffoldInAppFeedChannelStep = (refSuffix, channels)=>{
|
|
|
157
157
|
const scaffoldedStep = {
|
|
158
158
|
ref: stepRef,
|
|
159
159
|
type: _types.StepType.Channel,
|
|
160
|
-
channel_key: firstChannel ? firstChannel.key : "<
|
|
160
|
+
channel_key: firstChannel ? firstChannel.key : "<IN_APP_FEED CHANNEL KEY>",
|
|
161
161
|
template: {
|
|
162
162
|
action_url: "{{ vars.app_url }}",
|
|
163
163
|
["markdown_body" + _constisomorphic.FILEPATH_MARKER]: templateFilePath
|
|
@@ -239,7 +239,7 @@ const STEP_TAGS = [
|
|
|
239
239
|
"batch",
|
|
240
240
|
"fetch",
|
|
241
241
|
"email",
|
|
242
|
-
"
|
|
242
|
+
"in_app_feed",
|
|
243
243
|
"sms",
|
|
244
244
|
"push",
|
|
245
245
|
"chat"
|
|
@@ -249,7 +249,7 @@ const StepTagChoices = {
|
|
|
249
249
|
batch: "Batch step",
|
|
250
250
|
fetch: "HTTP Fetch step",
|
|
251
251
|
email: "Email channel step",
|
|
252
|
-
|
|
252
|
+
in_app_feed: "In-app feed channel step",
|
|
253
253
|
sms: "SMS channel step",
|
|
254
254
|
push: "Push channel step",
|
|
255
255
|
chat: "Chat channel step"
|
|
@@ -261,13 +261,16 @@ const stepScaffoldFuncs = {
|
|
|
261
261
|
fetch: scaffoldHttpFetchStep,
|
|
262
262
|
// Channel steps
|
|
263
263
|
email: scaffoldEmailChannelStep,
|
|
264
|
-
|
|
264
|
+
in_app_feed: scaffoldInAppFeedChannelStep,
|
|
265
265
|
sms: scaffoldSmsChannelStep,
|
|
266
266
|
push: scaffoldPushChannelStep,
|
|
267
267
|
chat: scaffoldChatChannelStep
|
|
268
268
|
};
|
|
269
|
+
// Accept "in-app-feed" for backward compatibility, but normalize to the snake
|
|
270
|
+
// case one as the canonical tag.
|
|
271
|
+
const normalizeStepTag = (tag)=>tag === "in-app-feed" ? "in_app_feed" : tag;
|
|
269
272
|
const parseStepsInput = (input, availableStepTypes)=>{
|
|
270
|
-
const tags = input.split(",").filter((x)=>x);
|
|
273
|
+
const tags = input.split(",").filter((x)=>x).map((tag)=>normalizeStepTag(tag));
|
|
271
274
|
const invalidTags = tags.filter((tag)=>!availableStepTypes.includes(tag));
|
|
272
275
|
if (invalidTags.length > 0) {
|
|
273
276
|
return [
|
|
@@ -286,7 +289,7 @@ const getAvailableStepTypes = (channelTypes)=>{
|
|
|
286
289
|
switch(stepTag){
|
|
287
290
|
case "email":
|
|
288
291
|
return channelTypes.includes("email");
|
|
289
|
-
case "
|
|
292
|
+
case "in_app_feed":
|
|
290
293
|
return channelTypes.includes("in_app_feed");
|
|
291
294
|
case "sms":
|
|
292
295
|
return channelTypes.includes("sms");
|
|
@@ -310,12 +313,11 @@ const scaffoldWorkflowDirBundle = (attrs, channelsByType)=>{
|
|
|
310
313
|
const stepCount = ++stepCountByTag[tag];
|
|
311
314
|
switch(tag){
|
|
312
315
|
case "email":
|
|
316
|
+
case "in_app_feed":
|
|
313
317
|
case "sms":
|
|
314
318
|
case "push":
|
|
315
319
|
case "chat":
|
|
316
320
|
return stepScaffoldFuncs[tag](stepCount, (0, _lodash.get)(channelsByType, tag, []));
|
|
317
|
-
case "in-app-feed":
|
|
318
|
-
return stepScaffoldFuncs[tag](stepCount, (0, _lodash.get)(channelsByType, "in_app_feed", []));
|
|
319
321
|
default:
|
|
320
322
|
return stepScaffoldFuncs[tag](stepCount);
|
|
321
323
|
}
|
|
@@ -348,6 +350,7 @@ function swapChannelReferences(step, channelsByType) {
|
|
|
348
350
|
...step,
|
|
349
351
|
channel_key: (_channelsByType_email_ = channelsByType.email[0]) === null || _channelsByType_email_ === void 0 ? void 0 : _channelsByType_email_.key
|
|
350
352
|
};
|
|
353
|
+
case "in_app_feed":
|
|
351
354
|
case "in-app-feed":
|
|
352
355
|
case "knock-in-app-feed":
|
|
353
356
|
case "knock-feed":
|
|
@@ -24,6 +24,9 @@ _export(exports, {
|
|
|
24
24
|
get formatStepSummary () {
|
|
25
25
|
return formatStepSummary;
|
|
26
26
|
},
|
|
27
|
+
get formatTags () {
|
|
28
|
+
return formatTags;
|
|
29
|
+
},
|
|
27
30
|
get generateWorkflowTypes () {
|
|
28
31
|
return generateWorkflowTypes;
|
|
29
32
|
},
|
|
@@ -106,13 +109,14 @@ const lsWorkflowJson = async (dirPath)=>{
|
|
|
106
109
|
return exists ? workflowJsonPath : undefined;
|
|
107
110
|
};
|
|
108
111
|
const isWorkflowDir = async (dirPath)=>Boolean(await lsWorkflowJson(dirPath));
|
|
109
|
-
const formatCategories = (workflow, opts = {})=>
|
|
110
|
-
|
|
112
|
+
const formatCategories = (workflow, opts = {})=>formatStringList(workflow.categories, opts);
|
|
113
|
+
const formatTags = (workflow, opts = {})=>formatStringList(workflow.tags, opts);
|
|
114
|
+
const formatStringList = (items, opts = {})=>{
|
|
111
115
|
const { truncateAfter: limit, emptyDisplay = "" } = opts;
|
|
112
|
-
if (!
|
|
113
|
-
const count =
|
|
114
|
-
if (!limit || limit >= count) return
|
|
115
|
-
return (0, _lodash.take)(
|
|
116
|
+
if (!items) return emptyDisplay;
|
|
117
|
+
const count = items.length;
|
|
118
|
+
if (!limit || limit >= count) return items.join(", ");
|
|
119
|
+
return (0, _lodash.take)(items, limit).join(", ") + ` (+ ${count - limit} more)`;
|
|
116
120
|
};
|
|
117
121
|
/*
|
|
118
122
|
* Returns a formatted string of workflow steps.
|
package/dist/lib/resources.js
CHANGED
|
@@ -9,6 +9,9 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
get ALLOW_EMPTY_RESOURCE_TYPES () {
|
|
13
|
+
return ALLOW_EMPTY_RESOURCE_TYPES;
|
|
14
|
+
},
|
|
12
15
|
get ALL_RESOURCE_TYPES () {
|
|
13
16
|
return ALL_RESOURCE_TYPES;
|
|
14
17
|
},
|
|
@@ -16,6 +19,14 @@ _export(exports, {
|
|
|
16
19
|
return RESOURCE_SUBDIRS;
|
|
17
20
|
}
|
|
18
21
|
});
|
|
22
|
+
const ALLOW_EMPTY_RESOURCE_TYPES = [
|
|
23
|
+
"partial",
|
|
24
|
+
"email_layout",
|
|
25
|
+
"workflow",
|
|
26
|
+
"message_type",
|
|
27
|
+
"guide",
|
|
28
|
+
"translation"
|
|
29
|
+
];
|
|
19
30
|
const ALL_RESOURCE_TYPES = [
|
|
20
31
|
// Audiences can be referenced by workflows, so push them early
|
|
21
32
|
"audience",
|