@knocklabs/cli 0.1.17 → 0.1.19

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,209 @@
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 PartialPull;
9
+ }
10
+ });
11
+ const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
12
+ const _core = require("@oclif/core");
13
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
14
+ const _error = require("../../lib/helpers/error");
15
+ const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
16
+ const _objectisomorphic = require("../../lib/helpers/object.isomorphic");
17
+ const _page = require("../../lib/helpers/page");
18
+ const _request = require("../../lib/helpers/request");
19
+ const _ux = require("../../lib/helpers/ux");
20
+ const _partial = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/marshal/partial"));
21
+ const _runcontext = require("../../lib/run-context");
22
+ function _define_property(obj, key, value) {
23
+ if (key in obj) {
24
+ Object.defineProperty(obj, key, {
25
+ value: value,
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true
29
+ });
30
+ } else {
31
+ obj[key] = value;
32
+ }
33
+ return obj;
34
+ }
35
+ function _interop_require_default(obj) {
36
+ return obj && obj.__esModule ? obj : {
37
+ default: obj
38
+ };
39
+ }
40
+ function _getRequireWildcardCache(nodeInterop) {
41
+ if (typeof WeakMap !== "function") return null;
42
+ var cacheBabelInterop = new WeakMap();
43
+ var cacheNodeInterop = new WeakMap();
44
+ return (_getRequireWildcardCache = function(nodeInterop) {
45
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
46
+ })(nodeInterop);
47
+ }
48
+ function _interop_require_wildcard(obj, nodeInterop) {
49
+ if (!nodeInterop && obj && obj.__esModule) {
50
+ return obj;
51
+ }
52
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
53
+ return {
54
+ default: obj
55
+ };
56
+ }
57
+ var cache = _getRequireWildcardCache(nodeInterop);
58
+ if (cache && cache.has(obj)) {
59
+ return cache.get(obj);
60
+ }
61
+ var newObj = {
62
+ __proto__: null
63
+ };
64
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
65
+ for(var key in obj){
66
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
67
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
68
+ if (desc && (desc.get || desc.set)) {
69
+ Object.defineProperty(newObj, key, desc);
70
+ } else {
71
+ newObj[key] = obj[key];
72
+ }
73
+ }
74
+ }
75
+ newObj.default = obj;
76
+ if (cache) {
77
+ cache.set(obj, newObj);
78
+ }
79
+ return newObj;
80
+ }
81
+ class PartialPull extends _basecommand.default {
82
+ async run() {
83
+ const { args, flags } = this.props;
84
+ if (flags.all && args.partialKey) {
85
+ return this.error(`partialKey arg \`${args.partialKey}\` cannot also be provided when using --all`);
86
+ }
87
+ return flags.all ? this.pullAllPartials() : this.pullOnePartial();
88
+ }
89
+ // Pull one partial
90
+ async pullOnePartial() {
91
+ const { flags } = this.props;
92
+ const dirContext = await this.getPartialsDirContext();
93
+ if (dirContext.exists) {
94
+ this.log(`‣ Found \`${dirContext.key}\` at ${dirContext.abspath}`);
95
+ } else {
96
+ const prompt = `Create a new partial directory \`${dirContext.key}\` at ${dirContext.abspath}?`;
97
+ const input = flags.force || await (0, _ux.promptToConfirm)(prompt);
98
+ if (!input) return;
99
+ }
100
+ const resp = await (0, _request.withSpinner)(()=>{
101
+ const props = (0, _objectisomorphic.merge)(this.props, {
102
+ args: {
103
+ partialKey: dirContext.key
104
+ },
105
+ flags: {
106
+ annotate: true
107
+ }
108
+ });
109
+ return this.apiV1.getPartial(props);
110
+ });
111
+ await _partial.writePartialDirFromData(dirContext, resp.data);
112
+ const action = dirContext.exists ? "updated" : "created";
113
+ this.log(`‣ Successfully ${action} \`${dirContext.key}\` at ${dirContext.abspath}`);
114
+ }
115
+ // Pull all partials
116
+ async pullAllPartials() {
117
+ const { flags } = this.props;
118
+ const defaultToCwd = {
119
+ abspath: this.runContext.cwd,
120
+ exists: true
121
+ };
122
+ const targetDirCtx = flags["partials-dir"] || defaultToCwd;
123
+ const prompt = targetDirCtx.exists ? `Pull latest partials into ${targetDirCtx.abspath}?\n This will overwrite the contents of this directory.` : `Create a new partials directory at ${targetDirCtx.abspath}?`;
124
+ const input = flags.force || await (0, _ux.promptToConfirm)(prompt);
125
+ if (!input) return;
126
+ _ux.spinner.start(`‣ Loading`);
127
+ const partials = await this.listAllPartials();
128
+ await _partial.writePartialsIndexDir(targetDirCtx, partials);
129
+ _ux.spinner.stop();
130
+ const action = targetDirCtx.exists ? "updated" : "created";
131
+ this.log(`‣ Successfully ${action} the partials directory at ${targetDirCtx.abspath}`);
132
+ }
133
+ async listAllPartials(pageParams = {}, partialsFetchedSoFar = []) {
134
+ const props = (0, _objectisomorphic.merge)(this.props, {
135
+ flags: {
136
+ ...pageParams,
137
+ annotate: true,
138
+ limit: _page.MAX_PAGINATION_LIMIT
139
+ }
140
+ });
141
+ const resp = await this.apiV1.listPartials(props);
142
+ if (!(0, _request.isSuccessResp)(resp)) {
143
+ const message = (0, _request.formatErrorRespMessage)(resp);
144
+ this.error(new _error.ApiError(message));
145
+ }
146
+ const { entries, page_info: pageInfo } = resp.data;
147
+ const partials = [
148
+ ...partialsFetchedSoFar,
149
+ ...entries
150
+ ];
151
+ return pageInfo.after ? this.listAllPartials({
152
+ after: pageInfo.after
153
+ }, partials) : partials;
154
+ }
155
+ async getPartialsDirContext() {
156
+ const { partialKey } = this.props.args;
157
+ const { resourceDir, cwd: runCwd } = this.runContext;
158
+ // Inside an existing resource dir, use it if valid for the target partial.
159
+ if (resourceDir) {
160
+ const target = {
161
+ commandId: _basecommand.default.id,
162
+ type: "partial",
163
+ key: partialKey
164
+ };
165
+ return (0, _runcontext.ensureResourceDirForTarget)(resourceDir, target);
166
+ }
167
+ // Not inside any existing partial directory, which means either create a
168
+ // new partial directory in the cwd, or update it if there is one already.
169
+ if (partialKey) {
170
+ const dirPath = _nodepath.resolve(runCwd, partialKey);
171
+ const exists = await _partial.isPartialDir(dirPath);
172
+ return {
173
+ type: "partial",
174
+ key: partialKey,
175
+ abspath: dirPath,
176
+ exists
177
+ };
178
+ }
179
+ // Not in any partial directory, nor a partial key arg was given so error.
180
+ return this.error("Missing 1 required arg:\npartialKey");
181
+ }
182
+ }
183
+ _define_property(PartialPull, "summary", "Pull one or more partial from an environment into a local file system.");
184
+ _define_property(PartialPull, "flags", {
185
+ environment: _core.Flags.string({
186
+ default: "development",
187
+ summary: "The environment to use."
188
+ }),
189
+ all: _core.Flags.boolean({
190
+ summary: "Whether to pull all partials from the specified environment."
191
+ }),
192
+ "partials-dir": _flag.dirPath({
193
+ summary: "The target directory path to pull all partials into.",
194
+ dependsOn: [
195
+ "all"
196
+ ]
197
+ }),
198
+ "hide-uncommitted-changes": _core.Flags.boolean({
199
+ summary: "Hide any uncommitted changes."
200
+ }),
201
+ force: _core.Flags.boolean({
202
+ summary: "Remove the confirmation prompt."
203
+ })
204
+ });
205
+ _define_property(PartialPull, "args", {
206
+ partialKey: _core.Args.string({
207
+ required: false
208
+ })
209
+ });
@@ -0,0 +1,169 @@
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 PartialPush;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _const = require("../../lib/helpers/const");
14
+ const _error = require("../../lib/helpers/error");
15
+ const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
16
+ const _objectisomorphic = require("../../lib/helpers/object.isomorphic");
17
+ const _request = require("../../lib/helpers/request");
18
+ const _string = require("../../lib/helpers/string");
19
+ const _ux = require("../../lib/helpers/ux");
20
+ const _partial = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/marshal/partial"));
21
+ const _validate = /*#__PURE__*/ _interop_require_default(require("./validate"));
22
+ function _define_property(obj, key, value) {
23
+ if (key in obj) {
24
+ Object.defineProperty(obj, key, {
25
+ value: value,
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true
29
+ });
30
+ } else {
31
+ obj[key] = value;
32
+ }
33
+ return obj;
34
+ }
35
+ function _interop_require_default(obj) {
36
+ return obj && obj.__esModule ? obj : {
37
+ default: obj
38
+ };
39
+ }
40
+ function _getRequireWildcardCache(nodeInterop) {
41
+ if (typeof WeakMap !== "function") return null;
42
+ var cacheBabelInterop = new WeakMap();
43
+ var cacheNodeInterop = new WeakMap();
44
+ return (_getRequireWildcardCache = function(nodeInterop) {
45
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
46
+ })(nodeInterop);
47
+ }
48
+ function _interop_require_wildcard(obj, nodeInterop) {
49
+ if (!nodeInterop && obj && obj.__esModule) {
50
+ return obj;
51
+ }
52
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
53
+ return {
54
+ default: obj
55
+ };
56
+ }
57
+ var cache = _getRequireWildcardCache(nodeInterop);
58
+ if (cache && cache.has(obj)) {
59
+ return cache.get(obj);
60
+ }
61
+ var newObj = {
62
+ __proto__: null
63
+ };
64
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
65
+ for(var key in obj){
66
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
67
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
68
+ if (desc && (desc.get || desc.set)) {
69
+ Object.defineProperty(newObj, key, desc);
70
+ } else {
71
+ newObj[key] = obj[key];
72
+ }
73
+ }
74
+ }
75
+ newObj.default = obj;
76
+ if (cache) {
77
+ cache.set(obj, newObj);
78
+ }
79
+ return newObj;
80
+ }
81
+ class PartialPush extends _basecommand.default {
82
+ async run() {
83
+ const { flags } = this.props;
84
+ // 1. First read all partial directories found for the given command.
85
+ const target = await _partial.ensureValidCommandTarget(this.props, this.runContext);
86
+ const [partials, readErrors] = await _partial.readAllForCommandTarget(target, {
87
+ withExtractedFiles: true
88
+ });
89
+ if (readErrors.length > 0) {
90
+ this.error((0, _error.formatErrors)(readErrors, {
91
+ prependBy: "\n\n"
92
+ }));
93
+ }
94
+ if (partials.length === 0) {
95
+ this.error(`No partial directories found in ${target.context.abspath}`);
96
+ }
97
+ // 2. Then validate them all ahead of pushing them.
98
+ _ux.spinner.start(`‣ Validating`);
99
+ const apiErrors = await _validate.default.validateAll(this.apiV1, this.props, partials);
100
+ if (apiErrors.length > 0) {
101
+ this.error((0, _error.formatErrors)(apiErrors, {
102
+ prependBy: "\n\n"
103
+ }));
104
+ }
105
+ _ux.spinner.stop();
106
+ // 3. Finally push up each partial, abort on the first error.
107
+ _ux.spinner.start(`‣ Pushing`);
108
+ for (const partial of partials){
109
+ const props = (0, _objectisomorphic.merge)(this.props, {
110
+ flags: {
111
+ annotate: true
112
+ }
113
+ });
114
+ // eslint-disable-next-line no-await-in-loop
115
+ const resp = await this.apiV1.upsertPartial(props, {
116
+ ...partial.content,
117
+ key: partial.key
118
+ });
119
+ if ((0, _request.isSuccessResp)(resp)) {
120
+ // Update the partial directory with the successfully pushed partial
121
+ // payload from the server.
122
+ // eslint-disable-next-line no-await-in-loop
123
+ await _partial.writePartialDirFromData(partial, resp.data.partial);
124
+ continue;
125
+ }
126
+ const error = new _error.SourceError((0, _request.formatErrorRespMessage)(resp), _partial.partialJsonPath(partial), "ApiError");
127
+ this.error((0, _error.formatError)(error));
128
+ }
129
+ _ux.spinner.stop();
130
+ // 4. Display a success message.
131
+ const partialKeys = partials.map((l)=>l.key);
132
+ const actioned = flags.commit ? "pushed and committed" : "pushed";
133
+ this.log(`‣ Successfully ${actioned} ${partials.length} partial(s):\n` + (0, _string.indentString)(partialKeys.join("\n"), 4));
134
+ }
135
+ }
136
+ _define_property(PartialPush, "summary", "Push one or more partials from a local file system to Knock.");
137
+ _define_property(PartialPush, "flags", {
138
+ environment: _core.Flags.string({
139
+ summary: "Pushing a partial is only allowed in the development environment",
140
+ default: _const.KnockEnv.Development,
141
+ options: [
142
+ _const.KnockEnv.Development
143
+ ]
144
+ }),
145
+ all: _core.Flags.boolean({
146
+ summary: "Whether to push all partials from the target directory."
147
+ }),
148
+ "partials-dir": _flag.dirPath({
149
+ summary: "The target directory path to find all partials to push.",
150
+ dependsOn: [
151
+ "all"
152
+ ]
153
+ }),
154
+ commit: _core.Flags.boolean({
155
+ summary: "Push and commit the partial(s) at the same time"
156
+ }),
157
+ "commit-message": _core.Flags.string({
158
+ summary: "Use the given value as the commit message",
159
+ char: "m",
160
+ dependsOn: [
161
+ "commit"
162
+ ]
163
+ })
164
+ });
165
+ _define_property(PartialPush, "args", {
166
+ partialKey: _core.Args.string({
167
+ required: false
168
+ })
169
+ });
@@ -0,0 +1,146 @@
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 PartialValidate;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _const = require("../../lib/helpers/const");
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 _string = require("../../lib/helpers/string");
18
+ const _ux = require("../../lib/helpers/ux");
19
+ const _partial = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/marshal/partial"));
20
+ function _define_property(obj, key, value) {
21
+ if (key in obj) {
22
+ Object.defineProperty(obj, key, {
23
+ value: value,
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true
27
+ });
28
+ } else {
29
+ obj[key] = value;
30
+ }
31
+ return obj;
32
+ }
33
+ function _interop_require_default(obj) {
34
+ return obj && obj.__esModule ? obj : {
35
+ default: obj
36
+ };
37
+ }
38
+ function _getRequireWildcardCache(nodeInterop) {
39
+ if (typeof WeakMap !== "function") return null;
40
+ var cacheBabelInterop = new WeakMap();
41
+ var cacheNodeInterop = new WeakMap();
42
+ return (_getRequireWildcardCache = function(nodeInterop) {
43
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
44
+ })(nodeInterop);
45
+ }
46
+ function _interop_require_wildcard(obj, nodeInterop) {
47
+ if (!nodeInterop && obj && obj.__esModule) {
48
+ return obj;
49
+ }
50
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
51
+ return {
52
+ default: obj
53
+ };
54
+ }
55
+ var cache = _getRequireWildcardCache(nodeInterop);
56
+ if (cache && cache.has(obj)) {
57
+ return cache.get(obj);
58
+ }
59
+ var newObj = {
60
+ __proto__: null
61
+ };
62
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
63
+ for(var key in obj){
64
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
65
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
66
+ if (desc && (desc.get || desc.set)) {
67
+ Object.defineProperty(newObj, key, desc);
68
+ } else {
69
+ newObj[key] = obj[key];
70
+ }
71
+ }
72
+ }
73
+ newObj.default = obj;
74
+ if (cache) {
75
+ cache.set(obj, newObj);
76
+ }
77
+ return newObj;
78
+ }
79
+ class PartialValidate extends _basecommand.default {
80
+ async run() {
81
+ // 1. Read all partial directories found for the given command.
82
+ const target = await _partial.ensureValidCommandTarget(this.props, this.runContext);
83
+ const [partials, readErrors] = await _partial.readAllForCommandTarget(target, {
84
+ withExtractedFiles: true
85
+ });
86
+ if (readErrors.length > 0) {
87
+ this.error((0, _error.formatErrors)(readErrors, {
88
+ prependBy: "\n\n"
89
+ }));
90
+ }
91
+ if (partials.length === 0) {
92
+ this.error(`No partial directories found in ${target.context.abspath}`);
93
+ }
94
+ // 2. Validate each partial data.
95
+ _ux.spinner.start(`‣ Validating`);
96
+ const apiErrors = await PartialValidate.validateAll(this.apiV1, this.props, partials);
97
+ if (apiErrors.length > 0) {
98
+ this.error((0, _error.formatErrors)(apiErrors, {
99
+ prependBy: "\n\n"
100
+ }));
101
+ }
102
+ _ux.spinner.stop();
103
+ // 3. Display a success message.
104
+ const partialKeys = partials.map((p)=>p.key);
105
+ this.log(`‣ Successfully validated ${partials.length} partial(s):\n` + (0, _string.indentString)(partialKeys.join("\n"), 4));
106
+ }
107
+ static async validateAll(api, props, partials) {
108
+ // TODO: Throw an error if a non validation error (e.g. authentication error)
109
+ // instead of printing out same error messages repeatedly.
110
+ const errorPromises = partials.map(async (partial)=>{
111
+ const resp = await api.validatePartial(props, {
112
+ ...partial.content,
113
+ key: partial.key
114
+ });
115
+ if ((0, _request.isSuccessResp)(resp)) return;
116
+ const error = new _error.SourceError((0, _request.formatErrorRespMessage)(resp), _partial.partialJsonPath(partial), "ApiError");
117
+ return error;
118
+ });
119
+ const errors = (await Promise.all(errorPromises)).filter((e)=>Boolean(e));
120
+ return errors;
121
+ }
122
+ }
123
+ _define_property(PartialValidate, "summary", "Validate one or more partials from a local file system.");
124
+ _define_property(PartialValidate, "flags", {
125
+ environment: _core.Flags.string({
126
+ summary: "Validating a partial is only done in the development environment",
127
+ default: _const.KnockEnv.Development,
128
+ options: [
129
+ _const.KnockEnv.Development
130
+ ]
131
+ }),
132
+ all: _core.Flags.boolean({
133
+ summary: "Whether to validate all partials from the target directory."
134
+ }),
135
+ "partials-dir": _flag.dirPath({
136
+ summary: "The target directory path to find all partials to validate.",
137
+ dependsOn: [
138
+ "all"
139
+ ]
140
+ })
141
+ });
142
+ _define_property(PartialValidate, "args", {
143
+ partialKey: _core.Args.string({
144
+ required: false
145
+ })
146
+ });
@@ -239,6 +239,53 @@ class ApiV1 {
239
239
  params
240
240
  });
241
241
  }
242
+ // By resources: Partials
243
+ async listPartials({ flags }) {
244
+ const params = (0, _objectisomorphic.prune)({
245
+ environment: flags.environment,
246
+ hide_uncommitted_changes: flags["hide-uncommitted-changes"],
247
+ annotate: flags.annotate,
248
+ ...(0, _page.toPageParams)(flags)
249
+ });
250
+ return this.get("/partials", {
251
+ params
252
+ });
253
+ }
254
+ async getPartial({ args, flags }) {
255
+ const params = (0, _objectisomorphic.prune)({
256
+ environment: flags.environment,
257
+ annotate: flags.annotate,
258
+ hide_uncommitted_changes: flags["hide-uncommitted-changes"]
259
+ });
260
+ return this.get(`/partials/${args.partialKey}`, {
261
+ params
262
+ });
263
+ }
264
+ async upsertPartial({ flags }, partial) {
265
+ const params = (0, _objectisomorphic.prune)({
266
+ environment: flags.environment,
267
+ annotate: flags.annotate,
268
+ commit: flags.commit,
269
+ commit_message: flags["commit-message"]
270
+ });
271
+ const data = {
272
+ partial
273
+ };
274
+ return this.put(`/partials/${partial.key}`, data, {
275
+ params
276
+ });
277
+ }
278
+ async validatePartial({ flags }, partial) {
279
+ const params = (0, _objectisomorphic.prune)({
280
+ environment: flags.environment
281
+ });
282
+ const data = {
283
+ partial
284
+ };
285
+ return this.put(`/partials/${partial.key}/validate`, data, {
286
+ params
287
+ });
288
+ }
242
289
  // By methods:
243
290
  async get(subpath, config) {
244
291
  return this.client.get(`/${API_VERSION}` + subpath, config);
@@ -19,8 +19,6 @@ const disabled = {
19
19
  throw new Error(`"${token.name}" tag is not supported in Knock`);
20
20
  }
21
21
  };
22
- // TODO(KNO-6058) - Enable render tag for partials
23
- engine.registerTag("render", disabled);
24
22
  engine.registerTag("include", disabled);
25
23
  function validateLiquidSyntax(input) {
26
24
  try {
@@ -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
- ], toEmailLayoutJson(mutRemoteEmailLayout));
78
+ ], (0, _helpersisomorphic.prepareResourceJson)(mutRemoteEmailLayout));
99
79
  };
@@ -14,17 +14,21 @@ _export(exports, {
14
14
  buildEmailLayoutDirBundle: function() {
15
15
  return _processorisomorphic.buildEmailLayoutDirBundle;
16
16
  },
17
+ buildMessageTypeDirBundle: function() {
18
+ return _processorisomorphic1.buildMessageTypeDirBundle;
19
+ },
17
20
  buildPartialDirBundle: function() {
18
- return _processorisomorphic1.buildPartialDirBundle;
21
+ return _processorisomorphic2.buildPartialDirBundle;
19
22
  },
20
23
  buildTranslationDirBundle: function() {
21
- return _processorisomorphic2.buildTranslationDirBundle;
24
+ return _processorisomorphic3.buildTranslationDirBundle;
22
25
  },
23
26
  buildWorkflowDirBundle: function() {
24
- return _processorisomorphic3.buildWorkflowDirBundle;
27
+ return _processorisomorphic4.buildWorkflowDirBundle;
25
28
  }
26
29
  });
27
30
  const _processorisomorphic = require("./email-layout/processor.isomorphic");
28
- const _processorisomorphic1 = require("./partial/processor.isomorphic");
29
- const _processorisomorphic2 = require("./translation/processor.isomorphic");
30
- const _processorisomorphic3 = require("./workflow/processor.isomorphic");
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
+ }