@knocklabs/cli 0.1.16 → 0.1.18
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 +24 -24
- package/dist/lib/marshal/email-layout/processor.isomorphic.js +2 -22
- package/dist/lib/marshal/index.isomorphic.js +12 -4
- package/dist/lib/marshal/message-type/index.js +19 -0
- package/dist/lib/marshal/message-type/processor.isomorphic.js +78 -0
- package/dist/lib/marshal/message-type/types.js +4 -0
- package/dist/lib/marshal/partial/processor.isomorphic.js +3 -24
- package/dist/lib/marshal/partial/types.js +4 -4
- package/dist/lib/marshal/shared/helpers.isomorphic.js +25 -0
- package/dist/lib/marshal/workflow/processor.isomorphic.js +2 -22
- package/oclif.manifest.json +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ $ npm install -g @knocklabs/cli
|
|
|
16
16
|
$ knock COMMAND
|
|
17
17
|
running command...
|
|
18
18
|
$ knock (--version)
|
|
19
|
-
@knocklabs/cli/0.1.
|
|
19
|
+
@knocklabs/cli/0.1.18 linux-x64 node-v18.20.4
|
|
20
20
|
$ knock --help [COMMAND]
|
|
21
21
|
USAGE
|
|
22
22
|
$ knock COMMAND
|
|
@@ -68,7 +68,7 @@ FLAGS
|
|
|
68
68
|
--service-token=<value> (required) The service token to authenticate with.
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
_See code: [src/commands/commit/index.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
71
|
+
_See code: [src/commands/commit/index.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/commit/index.ts)_
|
|
72
72
|
|
|
73
73
|
## `knock commit get ID`
|
|
74
74
|
|
|
@@ -85,7 +85,7 @@ GLOBAL FLAGS
|
|
|
85
85
|
--json Format output as json.
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
_See code: [src/commands/commit/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
88
|
+
_See code: [src/commands/commit/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/commit/get.ts)_
|
|
89
89
|
|
|
90
90
|
## `knock commit list`
|
|
91
91
|
|
|
@@ -109,7 +109,7 @@ GLOBAL FLAGS
|
|
|
109
109
|
--json Format output as json.
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
_See code: [src/commands/commit/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
112
|
+
_See code: [src/commands/commit/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/commit/list.ts)_
|
|
113
113
|
|
|
114
114
|
## `knock commit promote`
|
|
115
115
|
|
|
@@ -126,7 +126,7 @@ FLAGS
|
|
|
126
126
|
--to=<value> The destination environment to promote all changes from the preceding environment.
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
-
_See code: [src/commands/commit/promote.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
129
|
+
_See code: [src/commands/commit/promote.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/commit/promote.ts)_
|
|
130
130
|
|
|
131
131
|
## `knock help [COMMAND]`
|
|
132
132
|
|
|
@@ -146,7 +146,7 @@ DESCRIPTION
|
|
|
146
146
|
Display help for knock.
|
|
147
147
|
```
|
|
148
148
|
|
|
149
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.
|
|
149
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.6/src/commands/help.ts)_
|
|
150
150
|
|
|
151
151
|
## `knock layout get EMAILLAYOUTKEY`
|
|
152
152
|
|
|
@@ -166,7 +166,7 @@ GLOBAL FLAGS
|
|
|
166
166
|
--json Format output as json.
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
-
_See code: [src/commands/layout/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
169
|
+
_See code: [src/commands/layout/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/layout/get.ts)_
|
|
170
170
|
|
|
171
171
|
## `knock layout list`
|
|
172
172
|
|
|
@@ -189,7 +189,7 @@ GLOBAL FLAGS
|
|
|
189
189
|
--json Format output as json.
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
_See code: [src/commands/layout/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
192
|
+
_See code: [src/commands/layout/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/layout/list.ts)_
|
|
193
193
|
|
|
194
194
|
## `knock layout pull [EMAILLAYOUTKEY]`
|
|
195
195
|
|
|
@@ -209,7 +209,7 @@ FLAGS
|
|
|
209
209
|
--service-token=<value> (required) The service token to authenticate with.
|
|
210
210
|
```
|
|
211
211
|
|
|
212
|
-
_See code: [src/commands/layout/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
212
|
+
_See code: [src/commands/layout/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/layout/pull.ts)_
|
|
213
213
|
|
|
214
214
|
## `knock layout push [EMAILLAYOUTKEY]`
|
|
215
215
|
|
|
@@ -231,7 +231,7 @@ FLAGS
|
|
|
231
231
|
--service-token=<value> (required) The service token to authenticate with.
|
|
232
232
|
```
|
|
233
233
|
|
|
234
|
-
_See code: [src/commands/layout/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
234
|
+
_See code: [src/commands/layout/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/layout/push.ts)_
|
|
235
235
|
|
|
236
236
|
## `knock layout validate [EMAILLAYOUTKEY]`
|
|
237
237
|
|
|
@@ -250,7 +250,7 @@ FLAGS
|
|
|
250
250
|
--service-token=<value> (required) The service token to authenticate with.
|
|
251
251
|
```
|
|
252
252
|
|
|
253
|
-
_See code: [src/commands/layout/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
253
|
+
_See code: [src/commands/layout/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/layout/validate.ts)_
|
|
254
254
|
|
|
255
255
|
## `knock translation get TRANSLATIONREF`
|
|
256
256
|
|
|
@@ -277,7 +277,7 @@ GLOBAL FLAGS
|
|
|
277
277
|
--json Format output as json.
|
|
278
278
|
```
|
|
279
279
|
|
|
280
|
-
_See code: [src/commands/translation/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
280
|
+
_See code: [src/commands/translation/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/translation/get.ts)_
|
|
281
281
|
|
|
282
282
|
## `knock translation list`
|
|
283
283
|
|
|
@@ -300,7 +300,7 @@ GLOBAL FLAGS
|
|
|
300
300
|
--json Format output as json.
|
|
301
301
|
```
|
|
302
302
|
|
|
303
|
-
_See code: [src/commands/translation/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
303
|
+
_See code: [src/commands/translation/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/translation/list.ts)_
|
|
304
304
|
|
|
305
305
|
## `knock translation pull [TRANSLATIONREF]`
|
|
306
306
|
|
|
@@ -327,7 +327,7 @@ FLAGS
|
|
|
327
327
|
--translations-dir=<value> The target directory path to pull all translations into.
|
|
328
328
|
```
|
|
329
329
|
|
|
330
|
-
_See code: [src/commands/translation/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
330
|
+
_See code: [src/commands/translation/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/translation/pull.ts)_
|
|
331
331
|
|
|
332
332
|
## `knock translation push [TRANSLATIONREF]`
|
|
333
333
|
|
|
@@ -354,7 +354,7 @@ FLAGS
|
|
|
354
354
|
--translations-dir=<value> The target directory path to find all translations to push.
|
|
355
355
|
```
|
|
356
356
|
|
|
357
|
-
_See code: [src/commands/translation/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
357
|
+
_See code: [src/commands/translation/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/translation/push.ts)_
|
|
358
358
|
|
|
359
359
|
## `knock translation validate [TRANSLATIONREF]`
|
|
360
360
|
|
|
@@ -379,7 +379,7 @@ FLAGS
|
|
|
379
379
|
--translations-dir=<value> The target directory path to find all translations to validate.
|
|
380
380
|
```
|
|
381
381
|
|
|
382
|
-
_See code: [src/commands/translation/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
382
|
+
_See code: [src/commands/translation/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/translation/validate.ts)_
|
|
383
383
|
|
|
384
384
|
## `knock whoami`
|
|
385
385
|
|
|
@@ -396,7 +396,7 @@ GLOBAL FLAGS
|
|
|
396
396
|
--json Format output as json.
|
|
397
397
|
```
|
|
398
398
|
|
|
399
|
-
_See code: [src/commands/whoami.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
399
|
+
_See code: [src/commands/whoami.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/whoami.ts)_
|
|
400
400
|
|
|
401
401
|
## `knock workflow activate WORKFLOWKEY`
|
|
402
402
|
|
|
@@ -423,7 +423,7 @@ DESCRIPTION
|
|
|
423
423
|
with `false` in order to deactivate it.
|
|
424
424
|
```
|
|
425
425
|
|
|
426
|
-
_See code: [src/commands/workflow/activate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
426
|
+
_See code: [src/commands/workflow/activate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/workflow/activate.ts)_
|
|
427
427
|
|
|
428
428
|
## `knock workflow get WORKFLOWKEY`
|
|
429
429
|
|
|
@@ -443,7 +443,7 @@ GLOBAL FLAGS
|
|
|
443
443
|
--json Format output as json.
|
|
444
444
|
```
|
|
445
445
|
|
|
446
|
-
_See code: [src/commands/workflow/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
446
|
+
_See code: [src/commands/workflow/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/workflow/get.ts)_
|
|
447
447
|
|
|
448
448
|
## `knock workflow list`
|
|
449
449
|
|
|
@@ -466,7 +466,7 @@ GLOBAL FLAGS
|
|
|
466
466
|
--json Format output as json.
|
|
467
467
|
```
|
|
468
468
|
|
|
469
|
-
_See code: [src/commands/workflow/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
469
|
+
_See code: [src/commands/workflow/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/workflow/list.ts)_
|
|
470
470
|
|
|
471
471
|
## `knock workflow pull [WORKFLOWKEY]`
|
|
472
472
|
|
|
@@ -486,7 +486,7 @@ FLAGS
|
|
|
486
486
|
--workflows-dir=<value> The target directory path to pull all workflows into.
|
|
487
487
|
```
|
|
488
488
|
|
|
489
|
-
_See code: [src/commands/workflow/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
489
|
+
_See code: [src/commands/workflow/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/workflow/pull.ts)_
|
|
490
490
|
|
|
491
491
|
## `knock workflow push [WORKFLOWKEY]`
|
|
492
492
|
|
|
@@ -507,7 +507,7 @@ FLAGS
|
|
|
507
507
|
--workflows-dir=<value> The target directory path to find all workflows to push.
|
|
508
508
|
```
|
|
509
509
|
|
|
510
|
-
_See code: [src/commands/workflow/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
510
|
+
_See code: [src/commands/workflow/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/workflow/push.ts)_
|
|
511
511
|
|
|
512
512
|
## `knock workflow run WORKFLOWKEY`
|
|
513
513
|
|
|
@@ -528,7 +528,7 @@ FLAGS
|
|
|
528
528
|
--tenant=<value> A tenant id for the workflow run.
|
|
529
529
|
```
|
|
530
530
|
|
|
531
|
-
_See code: [src/commands/workflow/run.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
531
|
+
_See code: [src/commands/workflow/run.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/workflow/run.ts)_
|
|
532
532
|
|
|
533
533
|
## `knock workflow validate [WORKFLOWKEY]`
|
|
534
534
|
|
|
@@ -547,5 +547,5 @@ FLAGS
|
|
|
547
547
|
--workflows-dir=<value> The target directory path to find all workflows to validate.
|
|
548
548
|
```
|
|
549
549
|
|
|
550
|
-
_See code: [src/commands/workflow/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.
|
|
550
|
+
_See code: [src/commands/workflow/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.18/src/commands/workflow/validate.ts)_
|
|
551
551
|
<!-- commandsstop -->
|
|
@@ -14,33 +14,13 @@ _export(exports, {
|
|
|
14
14
|
},
|
|
15
15
|
buildEmailLayoutDirBundle: function() {
|
|
16
16
|
return buildEmailLayoutDirBundle;
|
|
17
|
-
},
|
|
18
|
-
toEmailLayoutJson: function() {
|
|
19
|
-
return toEmailLayoutJson;
|
|
20
17
|
}
|
|
21
18
|
});
|
|
22
19
|
const _lodash = require("lodash");
|
|
23
20
|
const _objectisomorphic = require("../../helpers/object.isomorphic");
|
|
24
21
|
const _constisomorphic = require("../shared/const.isomorphic");
|
|
22
|
+
const _helpersisomorphic = require("../shared/helpers.isomorphic");
|
|
25
23
|
const LAYOUT_JSON = "layout.json";
|
|
26
|
-
/*
|
|
27
|
-
* Sanitize the email layout content into a format that's appropriate for reading
|
|
28
|
-
* and writing, by stripping out any annotation fields and handling readonly
|
|
29
|
-
* fields.
|
|
30
|
-
*/ const toEmailLayoutJson = (emailLayout)=>{
|
|
31
|
-
var _emailLayout___annotation;
|
|
32
|
-
// Move read only field under the dedicated field "__readonly".
|
|
33
|
-
const readonlyFields = ((_emailLayout___annotation = emailLayout.__annotation) === null || _emailLayout___annotation === void 0 ? void 0 : _emailLayout___annotation.readonly_fields) || [];
|
|
34
|
-
const [readonly, remainder] = (0, _objectisomorphic.split)(emailLayout, readonlyFields);
|
|
35
|
-
const emailLayoutjson = {
|
|
36
|
-
...remainder,
|
|
37
|
-
__readonly: readonly
|
|
38
|
-
};
|
|
39
|
-
// Strip out all schema annotations, so not to expose them to end users.
|
|
40
|
-
return (0, _objectisomorphic.omitDeep)(emailLayoutjson, [
|
|
41
|
-
"__annotation"
|
|
42
|
-
]);
|
|
43
|
-
};
|
|
44
24
|
const compileExtractionSettings = (emailLayout)=>{
|
|
45
25
|
const extractableFields = (0, _lodash.get)(emailLayout, [
|
|
46
26
|
"__annotation",
|
|
@@ -95,5 +75,5 @@ const buildEmailLayoutDirBundle = (remoteEmailLayout, localEmailLayout = {})=>{
|
|
|
95
75
|
// the layout JSON realtive path + the file content.
|
|
96
76
|
return (0, _lodash.set)(bundle, [
|
|
97
77
|
LAYOUT_JSON
|
|
98
|
-
],
|
|
78
|
+
], (0, _helpersisomorphic.prepareResourceJson)(mutRemoteEmailLayout));
|
|
99
79
|
};
|
|
@@ -14,13 +14,21 @@ _export(exports, {
|
|
|
14
14
|
buildEmailLayoutDirBundle: function() {
|
|
15
15
|
return _processorisomorphic.buildEmailLayoutDirBundle;
|
|
16
16
|
},
|
|
17
|
+
buildMessageTypeDirBundle: function() {
|
|
18
|
+
return _processorisomorphic1.buildMessageTypeDirBundle;
|
|
19
|
+
},
|
|
20
|
+
buildPartialDirBundle: function() {
|
|
21
|
+
return _processorisomorphic2.buildPartialDirBundle;
|
|
22
|
+
},
|
|
17
23
|
buildTranslationDirBundle: function() {
|
|
18
|
-
return
|
|
24
|
+
return _processorisomorphic3.buildTranslationDirBundle;
|
|
19
25
|
},
|
|
20
26
|
buildWorkflowDirBundle: function() {
|
|
21
|
-
return
|
|
27
|
+
return _processorisomorphic4.buildWorkflowDirBundle;
|
|
22
28
|
}
|
|
23
29
|
});
|
|
24
30
|
const _processorisomorphic = require("./email-layout/processor.isomorphic");
|
|
25
|
-
const _processorisomorphic1 = require("./
|
|
26
|
-
const _processorisomorphic2 = require("./
|
|
31
|
+
const _processorisomorphic1 = require("./message-type/processor.isomorphic");
|
|
32
|
+
const _processorisomorphic2 = require("./partial/processor.isomorphic");
|
|
33
|
+
const _processorisomorphic3 = require("./translation/processor.isomorphic");
|
|
34
|
+
const _processorisomorphic4 = require("./workflow/processor.isomorphic");
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./processor.isomorphic"), exports);
|
|
6
|
+
_export_star(require("./types"), exports);
|
|
7
|
+
function _export_star(from, to) {
|
|
8
|
+
Object.keys(from).forEach(function(k) {
|
|
9
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
10
|
+
Object.defineProperty(to, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return from[k];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return from;
|
|
19
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
MESSAGE_TYPE_JSON: function() {
|
|
13
|
+
return MESSAGE_TYPE_JSON;
|
|
14
|
+
},
|
|
15
|
+
buildMessageTypeDirBundle: function() {
|
|
16
|
+
return buildMessageTypeDirBundle;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _lodash = require("lodash");
|
|
20
|
+
const _objectisomorphic = require("../../helpers/object.isomorphic");
|
|
21
|
+
const _constisomorphic = require("../shared/const.isomorphic");
|
|
22
|
+
const _helpersisomorphic = require("../shared/helpers.isomorphic");
|
|
23
|
+
const MESSAGE_TYPE_JSON = "message_type.json";
|
|
24
|
+
const compileExtractionSettings = (messageType)=>{
|
|
25
|
+
const extractableFields = (0, _lodash.get)(messageType, [
|
|
26
|
+
"__annotation",
|
|
27
|
+
"extractable_fields"
|
|
28
|
+
], {});
|
|
29
|
+
const map = new Map();
|
|
30
|
+
for (const [key] of Object.entries(messageType)){
|
|
31
|
+
// If the field we are on is extractable, then add its extraction settings
|
|
32
|
+
// to the map with the current object path.
|
|
33
|
+
if (key in extractableFields) {
|
|
34
|
+
map.set([
|
|
35
|
+
key
|
|
36
|
+
], extractableFields[key]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return map;
|
|
40
|
+
};
|
|
41
|
+
const buildMessageTypeDirBundle = (remoteMessageType, localMessageType = {})=>{
|
|
42
|
+
const bundle = {};
|
|
43
|
+
const mutRemoteMessageType = (0, _lodash.cloneDeep)(remoteMessageType);
|
|
44
|
+
// A map of extraction settings of every field in the message type
|
|
45
|
+
const compiledExtractionSettings = compileExtractionSettings(mutRemoteMessageType);
|
|
46
|
+
// Iterate through each extractable field, determine whether we need to
|
|
47
|
+
// extract the field content, and if so, perform the extraction.
|
|
48
|
+
for (const [objPathParts, extractionSettings] of compiledExtractionSettings){
|
|
49
|
+
// If this message type doesn't have this field path, then we don't extract.
|
|
50
|
+
if (!(0, _lodash.has)(mutRemoteMessageType, objPathParts)) continue;
|
|
51
|
+
// If the field at this path is extracted in the local message type, then
|
|
52
|
+
// always extract; otherwise extract based on the field settings default.
|
|
53
|
+
const objPathStr = _objectisomorphic.ObjPath.stringify(objPathParts);
|
|
54
|
+
const extractedFilePath = (0, _lodash.get)(localMessageType, `${objPathStr}${_constisomorphic.FILEPATH_MARKER}`);
|
|
55
|
+
const { default: extractByDefault, file_ext: fileExt } = extractionSettings;
|
|
56
|
+
if (!extractedFilePath && !extractByDefault) continue;
|
|
57
|
+
// By this point, we have a field where we need to extract its content.
|
|
58
|
+
const data = (0, _lodash.get)(mutRemoteMessageType, objPathParts);
|
|
59
|
+
const fileName = objPathParts.pop();
|
|
60
|
+
// If we have an extracted file path from the local message type, we use
|
|
61
|
+
// that. In the other case we use the default path.
|
|
62
|
+
const relpath = typeof extractedFilePath === "string" ? extractedFilePath : `${fileName}.${fileExt}`;
|
|
63
|
+
// Perform the extraction by adding the content and its file path to the
|
|
64
|
+
// bundle for writing to the file system later. Then replace the field
|
|
65
|
+
// content with the extracted file path and mark the field as extracted
|
|
66
|
+
// with @ suffix.
|
|
67
|
+
(0, _lodash.set)(bundle, [
|
|
68
|
+
relpath
|
|
69
|
+
], data);
|
|
70
|
+
(0, _lodash.set)(mutRemoteMessageType, `${objPathStr}${_constisomorphic.FILEPATH_MARKER}`, relpath);
|
|
71
|
+
(0, _lodash.unset)(mutRemoteMessageType, objPathStr);
|
|
72
|
+
}
|
|
73
|
+
// At this point the bundle contains all extractable files, so we finally add
|
|
74
|
+
// the message type JSON relative path + the file content.
|
|
75
|
+
return (0, _lodash.set)(bundle, [
|
|
76
|
+
MESSAGE_TYPE_JSON
|
|
77
|
+
], (0, _helpersisomorphic.prepareResourceJson)(mutRemoteMessageType));
|
|
78
|
+
};
|
|
@@ -14,34 +14,14 @@ _export(exports, {
|
|
|
14
14
|
},
|
|
15
15
|
buildPartialDirBundle: function() {
|
|
16
16
|
return buildPartialDirBundle;
|
|
17
|
-
},
|
|
18
|
-
toPartialJson: function() {
|
|
19
|
-
return toPartialJson;
|
|
20
17
|
}
|
|
21
18
|
});
|
|
22
19
|
const _lodash = require("lodash");
|
|
23
20
|
const _objectisomorphic = require("../../helpers/object.isomorphic");
|
|
24
21
|
const _constisomorphic = require("../shared/const.isomorphic");
|
|
22
|
+
const _helpersisomorphic = require("../shared/helpers.isomorphic");
|
|
25
23
|
const _types = require("./types");
|
|
26
24
|
const PARTIAL_JSON = "partial.json";
|
|
27
|
-
/*
|
|
28
|
-
* Sanitize the partial content into a format that's appropriate for reading
|
|
29
|
-
* and writing, by stripping out any annotation fields and handling readonly
|
|
30
|
-
* fields.
|
|
31
|
-
*/ const toPartialJson = (partial)=>{
|
|
32
|
-
var _partial___annotation;
|
|
33
|
-
// Move read only field under the dedicated field "__readonly".
|
|
34
|
-
const readonlyFields = ((_partial___annotation = partial.__annotation) === null || _partial___annotation === void 0 ? void 0 : _partial___annotation.readonly_fields) || [];
|
|
35
|
-
const [readonly, remainder] = (0, _objectisomorphic.split)(partial, readonlyFields);
|
|
36
|
-
const partialjson = {
|
|
37
|
-
...remainder,
|
|
38
|
-
__readonly: readonly
|
|
39
|
-
};
|
|
40
|
-
// Strip out all schema annotations, so not to expose them to end users.
|
|
41
|
-
return (0, _objectisomorphic.omitDeep)(partialjson, [
|
|
42
|
-
"__annotation"
|
|
43
|
-
]);
|
|
44
|
-
};
|
|
45
25
|
// Maps the partial type to the correct file extension. Defaults to 'txt'
|
|
46
26
|
const partialTypeToFileExt = (type)=>{
|
|
47
27
|
switch(type){
|
|
@@ -87,8 +67,7 @@ const buildPartialDirBundle = (remotePartial, localPartial = {})=>{
|
|
|
87
67
|
// A map of extraction settings of every field in the partial
|
|
88
68
|
const compiledExtractionSettings = compileExtractionSettings(mutRemotePartial);
|
|
89
69
|
// Iterate through each extractable field, determine whether we need to
|
|
90
|
-
// extract the field content, and if so, perform the
|
|
91
|
-
// extraction.
|
|
70
|
+
// extract the field content, and if so, perform the extraction.
|
|
92
71
|
for (const [objPathParts, extractionSettings] of compiledExtractionSettings){
|
|
93
72
|
// If this partial doesn't have this field path, then we don't extract.
|
|
94
73
|
if (!(0, _lodash.has)(mutRemotePartial, objPathParts)) continue;
|
|
@@ -118,5 +97,5 @@ const buildPartialDirBundle = (remotePartial, localPartial = {})=>{
|
|
|
118
97
|
// the partial JSON relative path + the file content.
|
|
119
98
|
return (0, _lodash.set)(bundle, [
|
|
120
99
|
PARTIAL_JSON
|
|
121
|
-
],
|
|
100
|
+
], (0, _helpersisomorphic.prepareResourceJson)(mutRemotePartial));
|
|
122
101
|
};
|
|
@@ -10,8 +10,8 @@ Object.defineProperty(exports, "PartialType", {
|
|
|
10
10
|
});
|
|
11
11
|
var PartialType;
|
|
12
12
|
(function(PartialType) {
|
|
13
|
-
PartialType["Html"] = "
|
|
14
|
-
PartialType["Json"] = "
|
|
15
|
-
PartialType["Markdown"] = "
|
|
16
|
-
PartialType["Text"] = "
|
|
13
|
+
PartialType["Html"] = "html";
|
|
14
|
+
PartialType["Json"] = "json";
|
|
15
|
+
PartialType["Markdown"] = "markdown";
|
|
16
|
+
PartialType["Text"] = "text";
|
|
17
17
|
})(PartialType || (PartialType = {}));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "prepareResourceJson", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return prepareResourceJson;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _objectisomorphic = require("../../helpers/object.isomorphic");
|
|
12
|
+
const prepareResourceJson = (resource)=>{
|
|
13
|
+
var _resource___annotation;
|
|
14
|
+
// Move read only field under the dedicated field "__readonly".
|
|
15
|
+
const readonlyFields = ((_resource___annotation = resource.__annotation) === null || _resource___annotation === void 0 ? void 0 : _resource___annotation.readonly_fields) || [];
|
|
16
|
+
const [readonly, remainder] = (0, _objectisomorphic.split)(resource, readonlyFields);
|
|
17
|
+
const resourceJson = {
|
|
18
|
+
...remainder,
|
|
19
|
+
__readonly: readonly
|
|
20
|
+
};
|
|
21
|
+
// Strip out all schema annotations, so not to expose them to end users.
|
|
22
|
+
return (0, _objectisomorphic.omitDeep)(resourceJson, [
|
|
23
|
+
"__annotation"
|
|
24
|
+
]);
|
|
25
|
+
};
|
|
@@ -27,15 +27,13 @@ _export(exports, {
|
|
|
27
27
|
},
|
|
28
28
|
formatExtractedFilePath: function() {
|
|
29
29
|
return formatExtractedFilePath;
|
|
30
|
-
},
|
|
31
|
-
toWorkflowJson: function() {
|
|
32
|
-
return toWorkflowJson;
|
|
33
30
|
}
|
|
34
31
|
});
|
|
35
32
|
const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
|
|
36
33
|
const _lodash = require("lodash");
|
|
37
34
|
const _objectisomorphic = require("../../helpers/object.isomorphic");
|
|
38
35
|
const _constisomorphic = require("../shared/const.isomorphic");
|
|
36
|
+
const _helpersisomorphic = require("../shared/helpers.isomorphic");
|
|
39
37
|
const _types = require("./types");
|
|
40
38
|
function _getRequireWildcardCache(nodeInterop) {
|
|
41
39
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -80,24 +78,6 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
80
78
|
}
|
|
81
79
|
const WORKFLOW_JSON = "workflow.json";
|
|
82
80
|
const VISUAL_BLOCKS_JSON = "visual_blocks.json";
|
|
83
|
-
/*
|
|
84
|
-
* Sanitize the workflow content into a format that's appropriate for reading
|
|
85
|
-
* and writing, by stripping out any annotation fields and handling readonly
|
|
86
|
-
* fields.
|
|
87
|
-
*/ const toWorkflowJson = (workflow)=>{
|
|
88
|
-
var _workflow___annotation;
|
|
89
|
-
// Move read only fields of a workflow under the dedicated field "__readonly".
|
|
90
|
-
const readonlyFields = ((_workflow___annotation = workflow.__annotation) === null || _workflow___annotation === void 0 ? void 0 : _workflow___annotation.readonly_fields) || [];
|
|
91
|
-
const [readonly, remainder] = (0, _objectisomorphic.split)(workflow, readonlyFields);
|
|
92
|
-
const worklfowJson = {
|
|
93
|
-
...remainder,
|
|
94
|
-
__readonly: readonly
|
|
95
|
-
};
|
|
96
|
-
// Strip out all schema annotations, so not to expose them to end users.
|
|
97
|
-
return (0, _objectisomorphic.omitDeep)(worklfowJson, [
|
|
98
|
-
"__annotation"
|
|
99
|
-
]);
|
|
100
|
-
};
|
|
101
81
|
const formatExtractedFilePath = (objPathParts, fileExt, opts = {})=>{
|
|
102
82
|
const { unnestDirsBy = 0, nestIntoDirs = [] } = opts;
|
|
103
83
|
// 1. Unnest the obj path parts by the given depths, if the option is given.
|
|
@@ -280,5 +260,5 @@ const buildWorkflowDirBundle = (remoteWorkflow, localWorkflow = {})=>{
|
|
|
280
260
|
// Then, prepare the workflow data to be written into a workflow json file.
|
|
281
261
|
return (0, _lodash.set)(bundle, [
|
|
282
262
|
WORKFLOW_JSON
|
|
283
|
-
],
|
|
263
|
+
], (0, _helpersisomorphic.prepareResourceJson)(mutWorkflow));
|
|
284
264
|
};
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knocklabs/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Knock CLI",
|
|
5
5
|
"author": "@knocklabs",
|
|
6
6
|
"bin": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@types/chai": "^4",
|
|
38
38
|
"@types/fs-extra": "^11.0.4",
|
|
39
39
|
"@types/mocha": "^10.0.6",
|
|
40
|
-
"@types/node": "^20.14.
|
|
40
|
+
"@types/node": "^20.14.11",
|
|
41
41
|
"chai": "^4",
|
|
42
42
|
"eslint": "^7.32.0",
|
|
43
43
|
"eslint-config-oclif": "^4",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"ts-node": "^10.9.1",
|
|
55
55
|
"tsconfig-paths": "^4.2.0",
|
|
56
56
|
"tslib": "^2.6.3",
|
|
57
|
-
"typescript": "^5.5.
|
|
57
|
+
"typescript": "^5.5.3"
|
|
58
58
|
},
|
|
59
59
|
"oclif": {
|
|
60
60
|
"bin": "knock",
|