@knocklabs/cli 0.1.7 → 0.1.9
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 +23 -23
- package/dist/commands/commit/list.js +2 -2
- package/dist/commands/layout/list.js +2 -2
- package/dist/commands/layout/pull.js +3 -3
- package/dist/commands/layout/push.js +2 -2
- package/dist/commands/translation/list.js +2 -2
- package/dist/commands/translation/pull.js +2 -2
- package/dist/commands/workflow/list.js +2 -2
- package/dist/commands/workflow/new.js +2 -2
- package/dist/commands/workflow/pull.js +3 -3
- package/dist/commands/workflow/push.js +2 -2
- package/dist/isomorphic.js +50 -0
- package/dist/lib/api-v1.js +19 -19
- package/dist/lib/helpers/{object.js → object.isomorphic.js} +8 -1
- package/dist/lib/marshal/email-layout/helpers.js +3 -4
- package/dist/lib/marshal/email-layout/index.js +1 -0
- package/dist/lib/marshal/email-layout/processor.isomorphic.js +93 -0
- package/dist/lib/marshal/email-layout/reader.js +10 -8
- package/dist/lib/marshal/email-layout/writer.js +7 -90
- package/dist/lib/marshal/index.isomorphic.js +18 -0
- package/dist/lib/marshal/shared/const.isomorphic.js +25 -0
- package/dist/lib/marshal/shared/helpers.js +0 -4
- package/dist/lib/marshal/workflow/generator.js +8 -8
- package/dist/lib/marshal/workflow/helpers.js +3 -6
- package/dist/lib/marshal/workflow/index.js +1 -0
- package/dist/lib/marshal/workflow/processor.isomorphic.js +272 -0
- package/dist/lib/marshal/workflow/reader.js +11 -9
- package/dist/lib/marshal/workflow/writer.js +7 -238
- package/oclif.manifest.json +1 -1
- package/package.json +5 -5
|
@@ -9,7 +9,6 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
LAYOUT_JSON: ()=>LAYOUT_JSON,
|
|
13
12
|
emailLayoutJsonPath: ()=>emailLayoutJsonPath,
|
|
14
13
|
isEmailLayoutDir: ()=>isEmailLayoutDir,
|
|
15
14
|
lsEmailLayoutJson: ()=>lsEmailLayoutJson,
|
|
@@ -18,6 +17,7 @@ _export(exports, {
|
|
|
18
17
|
const _nodePath = /*#__PURE__*/ _interopRequireWildcard(require("node:path"));
|
|
19
18
|
const _core = require("@oclif/core");
|
|
20
19
|
const _fsExtra = /*#__PURE__*/ _interopRequireWildcard(require("fs-extra"));
|
|
20
|
+
const _processorIsomorphic = require("./processor.isomorphic");
|
|
21
21
|
function _getRequireWildcardCache(nodeInterop) {
|
|
22
22
|
if (typeof WeakMap !== "function") return null;
|
|
23
23
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -57,11 +57,10 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
57
57
|
}
|
|
58
58
|
return newObj;
|
|
59
59
|
}
|
|
60
|
-
const
|
|
61
|
-
const emailLayoutJsonPath = (layoutDirCtx)=>_nodePath.resolve(layoutDirCtx.abspath, LAYOUT_JSON);
|
|
60
|
+
const emailLayoutJsonPath = (layoutDirCtx)=>_nodePath.resolve(layoutDirCtx.abspath, _processorIsomorphic.LAYOUT_JSON);
|
|
62
61
|
const isEmailLayoutDir = async (dirPath)=>Boolean(await lsEmailLayoutJson(dirPath));
|
|
63
62
|
const lsEmailLayoutJson = async (dirPath)=>{
|
|
64
|
-
const emailLayoutJsonPath = _nodePath.resolve(dirPath, LAYOUT_JSON);
|
|
63
|
+
const emailLayoutJsonPath = _nodePath.resolve(dirPath, _processorIsomorphic.LAYOUT_JSON);
|
|
65
64
|
const exists = await _fsExtra.pathExists(emailLayoutJsonPath);
|
|
66
65
|
return exists ? emailLayoutJsonPath : undefined;
|
|
67
66
|
};
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
_exportStar(require("./helpers"), exports);
|
|
6
|
+
_exportStar(require("./processor.isomorphic"), exports);
|
|
6
7
|
_exportStar(require("./reader"), exports);
|
|
7
8
|
_exportStar(require("./types"), exports);
|
|
8
9
|
_exportStar(require("./writer"), exports);
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
LAYOUT_JSON: ()=>LAYOUT_JSON,
|
|
13
|
+
buildEmailLayoutDirBundle: ()=>buildEmailLayoutDirBundle,
|
|
14
|
+
toEmailLayoutJson: ()=>toEmailLayoutJson
|
|
15
|
+
});
|
|
16
|
+
const _lodash = require("lodash");
|
|
17
|
+
const _objectIsomorphic = require("../../helpers/object.isomorphic");
|
|
18
|
+
const _constIsomorphic = require("../shared/const.isomorphic");
|
|
19
|
+
const LAYOUT_JSON = "layout.json";
|
|
20
|
+
/*
|
|
21
|
+
* Sanitize the email layout content into a format that's appropriate for reading
|
|
22
|
+
* and writing, by stripping out any annotation fields and handling readonly
|
|
23
|
+
* fields.
|
|
24
|
+
*/ const toEmailLayoutJson = (emailLayout)=>{
|
|
25
|
+
var _emailLayout___annotation;
|
|
26
|
+
// Move read only field under the dedicated field "__readonly".
|
|
27
|
+
const readonlyFields = ((_emailLayout___annotation = emailLayout.__annotation) === null || _emailLayout___annotation === void 0 ? void 0 : _emailLayout___annotation.readonly_fields) || [];
|
|
28
|
+
const [readonly, remainder] = (0, _objectIsomorphic.split)(emailLayout, readonlyFields);
|
|
29
|
+
const emailLayoutjson = {
|
|
30
|
+
...remainder,
|
|
31
|
+
__readonly: readonly
|
|
32
|
+
};
|
|
33
|
+
// Strip out all schema annotations, so not to expose them to end users.
|
|
34
|
+
return (0, _objectIsomorphic.omitDeep)(emailLayoutjson, [
|
|
35
|
+
"__annotation"
|
|
36
|
+
]);
|
|
37
|
+
};
|
|
38
|
+
const compileExtractionSettings = (emailLayout)=>{
|
|
39
|
+
const extractableFields = (0, _lodash.get)(emailLayout, [
|
|
40
|
+
"__annotation",
|
|
41
|
+
"extractable_fields"
|
|
42
|
+
], {});
|
|
43
|
+
const map = new Map();
|
|
44
|
+
for (const [key] of Object.entries(emailLayout)){
|
|
45
|
+
// If the field we are on is extractable, then add its extraction
|
|
46
|
+
// settings to the map with the current object path.
|
|
47
|
+
if (key in extractableFields) {
|
|
48
|
+
map.set([
|
|
49
|
+
key
|
|
50
|
+
], extractableFields[key]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return map;
|
|
54
|
+
};
|
|
55
|
+
const buildEmailLayoutDirBundle = (remoteEmailLayout, localEmailLayout = {})=>{
|
|
56
|
+
const bundle = {};
|
|
57
|
+
const mutRemoteEmailLayout = (0, _lodash.cloneDeep)(remoteEmailLayout);
|
|
58
|
+
// A map of extraction settings of every field in the email layout
|
|
59
|
+
const compiledExtractionSettings = compileExtractionSettings(mutRemoteEmailLayout);
|
|
60
|
+
// Iterate through each extractable field, determine whether we need to
|
|
61
|
+
// extract the field content, and if so, perform the
|
|
62
|
+
// extraction.
|
|
63
|
+
for (const [objPathParts, extractionSettings] of compiledExtractionSettings){
|
|
64
|
+
// If this layout doesn't have this field path, then we don't extract.
|
|
65
|
+
if (!(0, _lodash.has)(mutRemoteEmailLayout, objPathParts)) continue;
|
|
66
|
+
// If the field at this path is extracted in the local layout, then
|
|
67
|
+
// always extract; otherwise extract based on the field settings default.
|
|
68
|
+
const objPathStr = _objectIsomorphic.ObjPath.stringify(objPathParts);
|
|
69
|
+
const extractedFilePath = (0, _lodash.get)(localEmailLayout, `${objPathStr}${_constIsomorphic.FILEPATH_MARKER}`);
|
|
70
|
+
const { default: extractByDefault , file_ext: fileExt } = extractionSettings;
|
|
71
|
+
if (!extractedFilePath && !extractByDefault) continue;
|
|
72
|
+
// By this point, we have a field where we need to extract its content.
|
|
73
|
+
const data = (0, _lodash.get)(mutRemoteEmailLayout, objPathParts);
|
|
74
|
+
const fileName = objPathParts.pop();
|
|
75
|
+
// If we have an extracted file path from the local layout, we use that.
|
|
76
|
+
// In the other case we use the default path.
|
|
77
|
+
const relpath = typeof extractedFilePath === "string" ? extractedFilePath : `${fileName}.${fileExt}`;
|
|
78
|
+
// Perform the extraction by adding the content and its file path to the
|
|
79
|
+
// bundle for writing to the file system later. Then replace the field
|
|
80
|
+
// content with the extracted file path and mark the field as extracted
|
|
81
|
+
// with @ suffix.
|
|
82
|
+
(0, _lodash.set)(bundle, [
|
|
83
|
+
relpath
|
|
84
|
+
], data);
|
|
85
|
+
(0, _lodash.set)(mutRemoteEmailLayout, `${objPathStr}${_constIsomorphic.FILEPATH_MARKER}`, relpath);
|
|
86
|
+
(0, _lodash.unset)(mutRemoteEmailLayout, objPathStr);
|
|
87
|
+
}
|
|
88
|
+
// At this point the bundle contains all extractable files, so we finally add
|
|
89
|
+
// the layout JSON realtive path + the file content.
|
|
90
|
+
return (0, _lodash.set)(bundle, [
|
|
91
|
+
LAYOUT_JSON
|
|
92
|
+
], toEmailLayoutJson(mutRemoteEmailLayout));
|
|
93
|
+
};
|
|
@@ -18,9 +18,11 @@ const _fsExtra = /*#__PURE__*/ _interopRequireWildcard(require("fs-extra"));
|
|
|
18
18
|
const _lodash = require("lodash");
|
|
19
19
|
const _error = require("../../helpers/error");
|
|
20
20
|
const _json = require("../../helpers/json");
|
|
21
|
-
const
|
|
21
|
+
const _objectIsomorphic = require("../../helpers/object.isomorphic");
|
|
22
|
+
const _constIsomorphic = require("../shared/const.isomorphic");
|
|
22
23
|
const _helpers = require("../shared/helpers");
|
|
23
24
|
const _helpers1 = require("./helpers");
|
|
25
|
+
const _processorIsomorphic = require("./processor.isomorphic");
|
|
24
26
|
function _interopRequireDefault(obj) {
|
|
25
27
|
return obj && obj.__esModule ? obj : {
|
|
26
28
|
default: obj
|
|
@@ -110,7 +112,7 @@ const readAllForCommandTarget = async (target, opts = {})=>{
|
|
|
110
112
|
// eslint-disable-next-line no-await-in-loop
|
|
111
113
|
const [layout, readErrors] = await readEmailLayoutDir(layoutDirCtx, opts);
|
|
112
114
|
if (readErrors.length > 0) {
|
|
113
|
-
const layoutJsonPath = _nodePath.default.resolve(layoutDirCtx.abspath,
|
|
115
|
+
const layoutJsonPath = _nodePath.default.resolve(layoutDirCtx.abspath, _processorIsomorphic.LAYOUT_JSON);
|
|
114
116
|
const e = new _error.SourceError((0, _error.formatErrors)(readErrors), layoutJsonPath);
|
|
115
117
|
errors.push(e);
|
|
116
118
|
continue;
|
|
@@ -135,7 +137,7 @@ const readEmailLayoutDir = async (layoutDirCtx, opts = {})=>{
|
|
|
135
137
|
const result = await (0, _json.readJson)(layoutJsonPath);
|
|
136
138
|
if (!result[0]) return result;
|
|
137
139
|
let [layoutJson] = result;
|
|
138
|
-
layoutJson = withReadonlyField ? layoutJson : (0,
|
|
140
|
+
layoutJson = withReadonlyField ? layoutJson : (0, _objectIsomorphic.omitDeep)(layoutJson, [
|
|
139
141
|
"__readonly"
|
|
140
142
|
]);
|
|
141
143
|
return withExtractedFiles ? joinExtractedFiles(layoutDirCtx, layoutJson) : [
|
|
@@ -153,15 +155,15 @@ const readEmailLayoutDir = async (layoutDirCtx, opts = {})=>{
|
|
|
153
155
|
// layout.json) in the layout json node. Mutated in place, and used
|
|
154
156
|
// to validate the uniqueness of an extracted path encountered.
|
|
155
157
|
const uniqueFilePaths = {};
|
|
156
|
-
(0,
|
|
158
|
+
(0, _objectIsomorphic.mapValuesDeep)(layoutJson, (relpath, key, parts)=>{
|
|
157
159
|
// If not marked with the @suffix, there's nothing to do.
|
|
158
|
-
if (!
|
|
159
|
-
const objPathToFieldStr =
|
|
160
|
-
const inlinObjPathStr = objPathToFieldStr.replace(
|
|
160
|
+
if (!_constIsomorphic.FILEPATH_MARKED_RE.test(key)) return;
|
|
161
|
+
const objPathToFieldStr = _objectIsomorphic.ObjPath.stringify(parts);
|
|
162
|
+
const inlinObjPathStr = objPathToFieldStr.replace(_constIsomorphic.FILEPATH_MARKED_RE, "");
|
|
161
163
|
// If there is inlined content present already, then nothing more to do.
|
|
162
164
|
if ((0, _lodash.hasIn)(layoutJson, inlinObjPathStr)) return;
|
|
163
165
|
// Check if the extracted path found at the current field path is valid
|
|
164
|
-
const invalidFilePathError = (0, _helpers.validateExtractedFilePath)(relpath, _nodePath.default.resolve(layoutDirCtx.abspath,
|
|
166
|
+
const invalidFilePathError = (0, _helpers.validateExtractedFilePath)(relpath, _nodePath.default.resolve(layoutDirCtx.abspath, _processorIsomorphic.LAYOUT_JSON), uniqueFilePaths, objPathToFieldStr);
|
|
165
167
|
if (invalidFilePathError) {
|
|
166
168
|
errors.push(invalidFilePathError);
|
|
167
169
|
// Wipe the invalid file path in the node so the final layout json
|
|
@@ -11,18 +11,15 @@ function _export(target, all) {
|
|
|
11
11
|
_export(exports, {
|
|
12
12
|
writeEmailLayoutDirFromData: ()=>writeEmailLayoutDirFromData,
|
|
13
13
|
writeEmailLayoutIndexDir: ()=>writeEmailLayoutIndexDir,
|
|
14
|
-
|
|
15
|
-
pruneLayoutsIndexDir: ()=>pruneLayoutsIndexDir,
|
|
16
|
-
toEmailLayoutJson: ()=>toEmailLayoutJson
|
|
14
|
+
pruneLayoutsIndexDir: ()=>pruneLayoutsIndexDir
|
|
17
15
|
});
|
|
18
16
|
const _nodePath = /*#__PURE__*/ _interopRequireDefault(require("node:path"));
|
|
19
17
|
const _fsExtra = /*#__PURE__*/ _interopRequireWildcard(require("fs-extra"));
|
|
20
18
|
const _lodash = require("lodash");
|
|
21
19
|
const _const = require("../../helpers/const");
|
|
22
20
|
const _json = require("../../helpers/json");
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const _helpers1 = require("./helpers");
|
|
21
|
+
const _helpers = require("./helpers");
|
|
22
|
+
const _processorIsomorphic = require("./processor.isomorphic");
|
|
26
23
|
const _reader = require("./reader");
|
|
27
24
|
function _interopRequireDefault(obj) {
|
|
28
25
|
return obj && obj.__esModule ? obj : {
|
|
@@ -68,51 +65,13 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
68
65
|
}
|
|
69
66
|
return newObj;
|
|
70
67
|
}
|
|
71
|
-
/* Traverse a given email layout data and compile extraction settings of every extractable
|
|
72
|
-
* field into a sorted map.
|
|
73
|
-
*
|
|
74
|
-
* NOTE: Currently we do NOT support content extraction at nested levels for email layouts.
|
|
75
|
-
*/ const compileExtractionSettings = (emailLayout)=>{
|
|
76
|
-
const extractableFields = (0, _lodash.get)(emailLayout, [
|
|
77
|
-
"__annotation",
|
|
78
|
-
"extractable_fields"
|
|
79
|
-
], {});
|
|
80
|
-
const map = new Map();
|
|
81
|
-
for (const [key] of Object.entries(emailLayout)){
|
|
82
|
-
// If the field we are on is extractable, then add its extraction
|
|
83
|
-
// settings to the map with the current object path.
|
|
84
|
-
if (key in extractableFields) {
|
|
85
|
-
map.set([
|
|
86
|
-
key
|
|
87
|
-
], extractableFields[key]);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return map;
|
|
91
|
-
};
|
|
92
|
-
/* Sanitize the email layout content into a format that's appropriate for reading
|
|
93
|
-
* and writing, by stripping out any annotation fields and handling readonly
|
|
94
|
-
* fields.
|
|
95
|
-
*/ const toEmailLayoutJson = (emailLayout)=>{
|
|
96
|
-
var _emailLayout___annotation;
|
|
97
|
-
// Move read only field under the dedicated field "__readonly".
|
|
98
|
-
const readonlyFields = ((_emailLayout___annotation = emailLayout.__annotation) === null || _emailLayout___annotation === void 0 ? void 0 : _emailLayout___annotation.readonly_fields) || [];
|
|
99
|
-
const [readonly, remainder] = (0, _object.split)(emailLayout, readonlyFields);
|
|
100
|
-
const emailLayoutjson = {
|
|
101
|
-
...remainder,
|
|
102
|
-
__readonly: readonly
|
|
103
|
-
};
|
|
104
|
-
// Strip out all schema annotations, so not to expose them to end users.
|
|
105
|
-
return (0, _object.omitDeep)(emailLayoutjson, [
|
|
106
|
-
"__annotation"
|
|
107
|
-
]);
|
|
108
|
-
};
|
|
109
68
|
const writeEmailLayoutDirFromData = async (emailLayoutDirCtx, remoteEmailLayout)=>{
|
|
110
69
|
// If the layout directory exists on the file system (i.e. previously
|
|
111
70
|
// pulled before), then read the layout file to use as a reference.
|
|
112
71
|
const [localEmailLayout] = emailLayoutDirCtx.exists ? await (0, _reader.readEmailLayoutDir)(emailLayoutDirCtx, {
|
|
113
72
|
withExtractedFiles: true
|
|
114
73
|
}) : [];
|
|
115
|
-
const bundle = buildEmailLayoutDirBundle(remoteEmailLayout, localEmailLayout);
|
|
74
|
+
const bundle = (0, _processorIsomorphic.buildEmailLayoutDirBundle)(remoteEmailLayout, localEmailLayout);
|
|
116
75
|
const backupDirPath = _nodePath.default.resolve(_const.sandboxDir, (0, _lodash.uniqueId)("backup"));
|
|
117
76
|
try {
|
|
118
77
|
// We store a backup in case there's an error.
|
|
@@ -122,7 +81,7 @@ const writeEmailLayoutDirFromData = async (emailLayoutDirCtx, remoteEmailLayout)
|
|
|
122
81
|
}
|
|
123
82
|
const promises = Object.entries(bundle).map(([relpath, fileContent])=>{
|
|
124
83
|
const filePath = _nodePath.default.resolve(emailLayoutDirCtx.abspath, relpath);
|
|
125
|
-
return relpath ===
|
|
84
|
+
return relpath === _processorIsomorphic.LAYOUT_JSON ? _fsExtra.outputJson(filePath, fileContent, {
|
|
126
85
|
spaces: _json.DOUBLE_SPACES
|
|
127
86
|
}) : _fsExtra.outputFile(filePath, fileContent);
|
|
128
87
|
});
|
|
@@ -142,48 +101,6 @@ const writeEmailLayoutDirFromData = async (emailLayoutDirCtx, remoteEmailLayout)
|
|
|
142
101
|
await _fsExtra.remove(backupDirPath);
|
|
143
102
|
}
|
|
144
103
|
};
|
|
145
|
-
/* For a given email layout payload, this function builds a "email layout directoy bundle".
|
|
146
|
-
* This is an object which contains all the relative paths and its file content.
|
|
147
|
-
* It includes the extractable fields, which are extracted out and added to the bundle as separate files.
|
|
148
|
-
*/ const buildEmailLayoutDirBundle = (remoteEmailLayout, localEmailLayout = {})=>{
|
|
149
|
-
const bundle = {};
|
|
150
|
-
const mutRemoteEmailLayout = (0, _lodash.cloneDeep)(remoteEmailLayout);
|
|
151
|
-
// A map of extraction settings of every field in the email layout
|
|
152
|
-
const compiledExtractionSettings = compileExtractionSettings(mutRemoteEmailLayout);
|
|
153
|
-
// Iterate through each extractable field, determine whether we need to
|
|
154
|
-
// extract the field content, and if so, perform the
|
|
155
|
-
// extraction.
|
|
156
|
-
for (const [objPathParts, extractionSettings] of compiledExtractionSettings){
|
|
157
|
-
// If this layout doesn't have this field path, then we don't extract.
|
|
158
|
-
if (!(0, _lodash.has)(mutRemoteEmailLayout, objPathParts)) continue;
|
|
159
|
-
// If the field at this path is extracted in the local layout, then
|
|
160
|
-
// always extract; otherwise extract based on the field settings default.
|
|
161
|
-
const objPathStr = _object.ObjPath.stringify(objPathParts);
|
|
162
|
-
const extractedFilePath = (0, _lodash.get)(localEmailLayout, `${objPathStr}${_helpers.FILEPATH_MARKER}`);
|
|
163
|
-
const { default: extractByDefault , file_ext: fileExt } = extractionSettings;
|
|
164
|
-
if (!extractedFilePath && !extractByDefault) continue;
|
|
165
|
-
// By this point, we have a field where we need to extract its content.
|
|
166
|
-
const data = (0, _lodash.get)(mutRemoteEmailLayout, objPathParts);
|
|
167
|
-
const fileName = objPathParts.pop();
|
|
168
|
-
// If we have an extracted file path from the local layout, we use that. In the other
|
|
169
|
-
// case we use the default path.
|
|
170
|
-
const relpath = typeof extractedFilePath === "string" ? extractedFilePath : `${fileName}.${fileExt}`;
|
|
171
|
-
// Perform the extraction by adding the content and its file path to the
|
|
172
|
-
// bundle for writing to the file system later. Then replace the field
|
|
173
|
-
// content with the extracted file path and mark the field as extracted
|
|
174
|
-
// with @ suffix.
|
|
175
|
-
(0, _lodash.set)(bundle, [
|
|
176
|
-
relpath
|
|
177
|
-
], data);
|
|
178
|
-
(0, _lodash.set)(mutRemoteEmailLayout, `${objPathStr}${_helpers.FILEPATH_MARKER}`, relpath);
|
|
179
|
-
(0, _lodash.unset)(mutRemoteEmailLayout, objPathStr);
|
|
180
|
-
}
|
|
181
|
-
// At this point the bundle contains all extractable files, so we finally add the layout
|
|
182
|
-
// JSON realtive path + the file content.
|
|
183
|
-
return (0, _lodash.set)(bundle, [
|
|
184
|
-
_helpers1.LAYOUT_JSON
|
|
185
|
-
], toEmailLayoutJson(mutRemoteEmailLayout));
|
|
186
|
-
};
|
|
187
104
|
const writeEmailLayoutIndexDir = async (indexDirCtx, remoteEmailLayouts)=>{
|
|
188
105
|
const backupDirPath = _nodePath.default.resolve(_const.sandboxDir, (0, _lodash.uniqueId)("backup"));
|
|
189
106
|
try {
|
|
@@ -197,7 +114,7 @@ const writeEmailLayoutIndexDir = async (indexDirCtx, remoteEmailLayouts)=>{
|
|
|
197
114
|
type: "email_layout",
|
|
198
115
|
key: remoteEmailLayout.key,
|
|
199
116
|
abspath: emailLayoutDirPath,
|
|
200
|
-
exists: indexDirCtx.exists ? await (0,
|
|
117
|
+
exists: indexDirCtx.exists ? await (0, _helpers.isEmailLayoutDir)(emailLayoutDirPath) : false
|
|
201
118
|
};
|
|
202
119
|
return writeEmailLayoutDirFromData(emailLayoutDirCtx, remoteEmailLayout);
|
|
203
120
|
});
|
|
@@ -231,7 +148,7 @@ const writeEmailLayoutIndexDir = async (indexDirCtx, remoteEmailLayouts)=>{
|
|
|
231
148
|
const promises = dirents.map(async (dirent)=>{
|
|
232
149
|
const direntName = dirent.name.toLowerCase();
|
|
233
150
|
const direntPath = _nodePath.default.resolve(indexDirCtx.abspath, direntName);
|
|
234
|
-
if (await (0,
|
|
151
|
+
if (await (0, _helpers.isEmailLayoutDir)(direntPath) && emailLayoutsByKey[direntName]) {
|
|
235
152
|
return;
|
|
236
153
|
}
|
|
237
154
|
await _fsExtra.remove(direntPath);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* IMPORTANT: You must only expose exports from isomorphic modules.
|
|
3
|
+
*/ "use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
function _export(target, all) {
|
|
8
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: all[name]
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
_export(exports, {
|
|
14
|
+
buildEmailLayoutDirBundle: ()=>_processorIsomorphic.buildEmailLayoutDirBundle,
|
|
15
|
+
buildWorkflowDirBundle: ()=>_processorIsomorphic1.buildWorkflowDirBundle
|
|
16
|
+
});
|
|
17
|
+
const _processorIsomorphic = require("./email-layout/processor.isomorphic");
|
|
18
|
+
const _processorIsomorphic1 = require("./workflow/processor.isomorphic");
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* IMPORTANT:
|
|
3
|
+
*
|
|
4
|
+
* This file is suffixed with `.isomorphic` because the code in this file is
|
|
5
|
+
* meant to run not just in a nodejs environment but also in a browser. For this
|
|
6
|
+
* reason there are some restrictions for which nodejs imports are allowed in
|
|
7
|
+
* this module. See `.eslintrc.json` for more details.
|
|
8
|
+
*/ // Mark any template fields we are extracting out with this suffix as a rule,
|
|
9
|
+
// so we can reliably interpret the field value.
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
function _export(target, all) {
|
|
15
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: all[name]
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
_export(exports, {
|
|
21
|
+
FILEPATH_MARKER: ()=>FILEPATH_MARKER,
|
|
22
|
+
FILEPATH_MARKED_RE: ()=>FILEPATH_MARKED_RE
|
|
23
|
+
});
|
|
24
|
+
const FILEPATH_MARKER = "@";
|
|
25
|
+
const FILEPATH_MARKED_RE = new RegExp(`${FILEPATH_MARKER}$`);
|
|
@@ -9,8 +9,6 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
FILEPATH_MARKER: ()=>FILEPATH_MARKER,
|
|
13
|
-
FILEPATH_MARKED_RE: ()=>FILEPATH_MARKED_RE,
|
|
14
12
|
readExtractedFileSync: ()=>readExtractedFileSync,
|
|
15
13
|
validateExtractedFilePath: ()=>validateExtractedFilePath,
|
|
16
14
|
checkIfValidExtractedFilePathFormat: ()=>checkIfValidExtractedFilePathFormat
|
|
@@ -60,8 +58,6 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
60
58
|
}
|
|
61
59
|
return newObj;
|
|
62
60
|
}
|
|
63
|
-
const FILEPATH_MARKER = "@";
|
|
64
|
-
const FILEPATH_MARKED_RE = new RegExp(`${FILEPATH_MARKER}$`);
|
|
65
61
|
// The following files are exepected to have valid json content, and should be
|
|
66
62
|
// decoded and joined into the main JSON file.
|
|
67
63
|
const DECODABLE_JSON_FILES = new Set([
|
|
@@ -15,8 +15,8 @@ _export(exports, {
|
|
|
15
15
|
});
|
|
16
16
|
const _nodePath = /*#__PURE__*/ _interopRequireWildcard(require("node:path"));
|
|
17
17
|
const _lodash = require("lodash");
|
|
18
|
-
const
|
|
19
|
-
const
|
|
18
|
+
const _constIsomorphic = require("../shared/const.isomorphic");
|
|
19
|
+
const _processorIsomorphic = require("./processor.isomorphic");
|
|
20
20
|
const _types = require("./types");
|
|
21
21
|
const _writer = require("./writer");
|
|
22
22
|
function _getRequireWildcardCache(nodeInterop) {
|
|
@@ -119,7 +119,7 @@ const scaffoldEmailChannelStep = (refSuffix)=>{
|
|
|
119
119
|
layout_key: "default"
|
|
120
120
|
},
|
|
121
121
|
subject: "You've got mail!",
|
|
122
|
-
["html_body" +
|
|
122
|
+
["html_body" + _constIsomorphic.FILEPATH_MARKER]: templateFilePath
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
const bundleFragment = {
|
|
@@ -139,7 +139,7 @@ const scaffoldInAppFeedChannelStep = (refSuffix)=>{
|
|
|
139
139
|
channel_key: "<IN-APP-FEED CHANNEL KEY>",
|
|
140
140
|
template: {
|
|
141
141
|
action_url: "{{ vars.app_url }}",
|
|
142
|
-
["markdown_body" +
|
|
142
|
+
["markdown_body" + _constIsomorphic.FILEPATH_MARKER]: templateFilePath
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
145
|
const bundleFragment = {
|
|
@@ -158,7 +158,7 @@ const scaffoldSmsChannelStep = (refSuffix)=>{
|
|
|
158
158
|
type: _types.StepType.Channel,
|
|
159
159
|
channel_key: "<SMS CHANNEL KEY>",
|
|
160
160
|
template: {
|
|
161
|
-
["text_body" +
|
|
161
|
+
["text_body" + _constIsomorphic.FILEPATH_MARKER]: templateFilePath
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
164
|
const bundleFragment = {
|
|
@@ -180,7 +180,7 @@ const scaffoldPushChannelStep = (refSuffix)=>{
|
|
|
180
180
|
settings: {
|
|
181
181
|
delivery_type: "content"
|
|
182
182
|
},
|
|
183
|
-
["text_body" +
|
|
183
|
+
["text_body" + _constIsomorphic.FILEPATH_MARKER]: templateFilePath
|
|
184
184
|
}
|
|
185
185
|
};
|
|
186
186
|
const bundleFragment = {
|
|
@@ -199,7 +199,7 @@ const scaffoldChatChannelStep = (refSuffix)=>{
|
|
|
199
199
|
type: _types.StepType.Channel,
|
|
200
200
|
channel_key: "<CHAT CHANNEL KEY>",
|
|
201
201
|
template: {
|
|
202
|
-
["markdown_body" +
|
|
202
|
+
["markdown_body" + _constIsomorphic.FILEPATH_MARKER]: templateFilePath
|
|
203
203
|
}
|
|
204
204
|
};
|
|
205
205
|
const bundleFragment = {
|
|
@@ -264,7 +264,7 @@ const scaffoldWorkflowDirBundle = (attrs)=>{
|
|
|
264
264
|
steps: scaffoldedSteps
|
|
265
265
|
};
|
|
266
266
|
return (0, _lodash.assign)({
|
|
267
|
-
[
|
|
267
|
+
[_processorIsomorphic.WORKFLOW_JSON]: workflowJson
|
|
268
268
|
}, ...bundleFragments);
|
|
269
269
|
};
|
|
270
270
|
const generateWorkflowDir = async (workflowDirCtx, attrs)=>{
|
|
@@ -9,8 +9,6 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
WORKFLOW_JSON: ()=>WORKFLOW_JSON,
|
|
13
|
-
VISUAL_BLOCKS_JSON: ()=>VISUAL_BLOCKS_JSON,
|
|
14
12
|
workflowJsonPath: ()=>workflowJsonPath,
|
|
15
13
|
validateWorkflowKey: ()=>validateWorkflowKey,
|
|
16
14
|
lsWorkflowJson: ()=>lsWorkflowJson,
|
|
@@ -26,6 +24,7 @@ const _core = require("@oclif/core");
|
|
|
26
24
|
const _fsExtra = /*#__PURE__*/ _interopRequireWildcard(require("fs-extra"));
|
|
27
25
|
const _lodash = require("lodash");
|
|
28
26
|
const _string = require("../../helpers/string");
|
|
27
|
+
const _processorIsomorphic = require("./processor.isomorphic");
|
|
29
28
|
const _types = require("./types");
|
|
30
29
|
function _getRequireWildcardCache(nodeInterop) {
|
|
31
30
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -66,9 +65,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
66
65
|
}
|
|
67
66
|
return newObj;
|
|
68
67
|
}
|
|
69
|
-
const
|
|
70
|
-
const VISUAL_BLOCKS_JSON = "visual_blocks.json";
|
|
71
|
-
const workflowJsonPath = (workflowDirCtx)=>_nodePath.resolve(workflowDirCtx.abspath, WORKFLOW_JSON);
|
|
68
|
+
const workflowJsonPath = (workflowDirCtx)=>_nodePath.resolve(workflowDirCtx.abspath, _processorIsomorphic.WORKFLOW_JSON);
|
|
72
69
|
const validateWorkflowKey = (input)=>{
|
|
73
70
|
if (!(0, _string.checkSlugifiedFormat)(input, {
|
|
74
71
|
onlyLowerCase: true
|
|
@@ -78,7 +75,7 @@ const validateWorkflowKey = (input)=>{
|
|
|
78
75
|
return undefined;
|
|
79
76
|
};
|
|
80
77
|
const lsWorkflowJson = async (dirPath)=>{
|
|
81
|
-
const workflowJsonPath = _nodePath.resolve(dirPath, WORKFLOW_JSON);
|
|
78
|
+
const workflowJsonPath = _nodePath.resolve(dirPath, _processorIsomorphic.WORKFLOW_JSON);
|
|
82
79
|
const exists = await _fsExtra.pathExists(workflowJsonPath);
|
|
83
80
|
return exists ? workflowJsonPath : undefined;
|
|
84
81
|
};
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
_exportStar(require("./generator"), exports);
|
|
6
6
|
_exportStar(require("./helpers"), exports);
|
|
7
|
+
_exportStar(require("./processor.isomorphic"), exports);
|
|
7
8
|
_exportStar(require("./reader"), exports);
|
|
8
9
|
_exportStar(require("./types"), exports);
|
|
9
10
|
_exportStar(require("./writer"), exports);
|