@knocklabs/cli 0.1.22 → 0.2.0

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.
Files changed (66) hide show
  1. package/README.md +191 -106
  2. package/bin/dev.js +4 -4
  3. package/dist/commands/commit/list.js +21 -1
  4. package/dist/commands/guide/activate.js +121 -0
  5. package/dist/commands/guide/generate-types.js +148 -0
  6. package/dist/commands/guide/get.js +139 -0
  7. package/dist/commands/guide/list.js +112 -0
  8. package/dist/commands/guide/pull.js +209 -0
  9. package/dist/commands/guide/push.js +171 -0
  10. package/dist/commands/guide/validate.js +148 -0
  11. package/dist/commands/knock.js +3 -0
  12. package/dist/commands/login.js +50 -0
  13. package/dist/commands/logout.js +48 -0
  14. package/dist/commands/whoami.js +6 -2
  15. package/dist/commands/workflow/generate-types.js +6 -5
  16. package/dist/lib/api-v1.js +74 -4
  17. package/dist/lib/auth.js +256 -0
  18. package/dist/lib/base-command.js +85 -12
  19. package/dist/lib/helpers/browser.js +25 -0
  20. package/dist/lib/helpers/const.js +4 -4
  21. package/dist/lib/helpers/date.js +3 -3
  22. package/dist/lib/helpers/error.js +8 -8
  23. package/dist/lib/helpers/flag.js +7 -7
  24. package/dist/lib/helpers/json.js +5 -5
  25. package/dist/lib/helpers/object.isomorphic.js +8 -8
  26. package/dist/lib/helpers/page.js +9 -9
  27. package/dist/lib/helpers/request.js +4 -4
  28. package/dist/lib/helpers/string.js +3 -3
  29. package/dist/lib/helpers/typegen.js +59 -0
  30. package/dist/lib/helpers/ux.js +3 -3
  31. package/dist/lib/marshal/email-layout/helpers.js +5 -5
  32. package/dist/lib/marshal/email-layout/processor.isomorphic.js +3 -3
  33. package/dist/lib/marshal/email-layout/reader.js +5 -5
  34. package/dist/lib/marshal/email-layout/writer.js +4 -4
  35. package/dist/lib/marshal/guide/helpers.js +283 -0
  36. package/dist/lib/marshal/guide/index.js +3 -0
  37. package/dist/lib/marshal/guide/processor.isomorphic.js +3 -3
  38. package/dist/lib/marshal/guide/reader.js +193 -0
  39. package/dist/lib/marshal/guide/writer.js +175 -0
  40. package/dist/lib/marshal/index.isomorphic.js +7 -7
  41. package/dist/lib/marshal/message-type/helpers.js +5 -5
  42. package/dist/lib/marshal/message-type/processor.isomorphic.js +3 -3
  43. package/dist/lib/marshal/message-type/reader.js +5 -5
  44. package/dist/lib/marshal/message-type/writer.js +4 -4
  45. package/dist/lib/marshal/partial/helpers.js +5 -5
  46. package/dist/lib/marshal/partial/processor.isomorphic.js +3 -3
  47. package/dist/lib/marshal/partial/reader.js +5 -5
  48. package/dist/lib/marshal/partial/writer.js +4 -4
  49. package/dist/lib/marshal/shared/const.isomorphic.js +3 -3
  50. package/dist/lib/marshal/shared/helpers.isomorphic.js +9 -2
  51. package/dist/lib/marshal/shared/helpers.js +4 -4
  52. package/dist/lib/marshal/translation/helpers.js +10 -10
  53. package/dist/lib/marshal/translation/processor.isomorphic.js +6 -6
  54. package/dist/lib/marshal/translation/writer.js +3 -3
  55. package/dist/lib/marshal/workflow/generator.js +4 -4
  56. package/dist/lib/marshal/workflow/helpers.js +53 -10
  57. package/dist/lib/marshal/workflow/processor.isomorphic.js +5 -5
  58. package/dist/lib/marshal/workflow/reader.js +5 -5
  59. package/dist/lib/marshal/workflow/writer.js +5 -5
  60. package/dist/lib/resources.js +3 -3
  61. package/dist/lib/types.js +4 -0
  62. package/dist/lib/urls.js +32 -0
  63. package/dist/lib/user-config.js +69 -31
  64. package/oclif.manifest.json +749 -114
  65. package/package.json +12 -11
  66. package/dist/lib/type-generator.js +0 -100
@@ -0,0 +1,193 @@
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: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get readAllForCommandTarget () {
13
+ return readAllForCommandTarget;
14
+ },
15
+ get readGuideDir () {
16
+ return readGuideDir;
17
+ }
18
+ });
19
+ const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
20
+ const _core = require("@oclif/core");
21
+ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
22
+ const _lodash = require("lodash");
23
+ const _error = require("../../helpers/error");
24
+ const _json = require("../../helpers/json");
25
+ const _objectisomorphic = require("../../helpers/object.isomorphic");
26
+ const _constisomorphic = require("../shared/const.isomorphic");
27
+ const _helpers = require("../shared/helpers");
28
+ const _helpers1 = require("./helpers");
29
+ const _processorisomorphic = require("./processor.isomorphic");
30
+ function _getRequireWildcardCache(nodeInterop) {
31
+ if (typeof WeakMap !== "function") return null;
32
+ var cacheBabelInterop = new WeakMap();
33
+ var cacheNodeInterop = new WeakMap();
34
+ return (_getRequireWildcardCache = function(nodeInterop) {
35
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
36
+ })(nodeInterop);
37
+ }
38
+ function _interop_require_wildcard(obj, nodeInterop) {
39
+ if (!nodeInterop && obj && obj.__esModule) {
40
+ return obj;
41
+ }
42
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
43
+ return {
44
+ default: obj
45
+ };
46
+ }
47
+ var cache = _getRequireWildcardCache(nodeInterop);
48
+ if (cache && cache.has(obj)) {
49
+ return cache.get(obj);
50
+ }
51
+ var newObj = {
52
+ __proto__: null
53
+ };
54
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
55
+ for(var key in obj){
56
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
57
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
58
+ if (desc && (desc.get || desc.set)) {
59
+ Object.defineProperty(newObj, key, desc);
60
+ } else {
61
+ newObj[key] = obj[key];
62
+ }
63
+ }
64
+ }
65
+ newObj.default = obj;
66
+ if (cache) {
67
+ cache.set(obj, newObj);
68
+ }
69
+ return newObj;
70
+ }
71
+ /*
72
+ * For the given list of guide directory contexts, read each guide dir and
73
+ * return guide directory data.
74
+ */ const readGuideDirs = async (guideDirCtxs, opts = {})=>{
75
+ const guides = [];
76
+ const errors = [];
77
+ for (const guideDirCtx of guideDirCtxs){
78
+ // eslint-disable-next-line no-await-in-loop
79
+ const [guide, readErrors] = await readGuideDir(guideDirCtx, opts);
80
+ if (readErrors.length > 0) {
81
+ const guideJsonPath = _nodepath.resolve(guideDirCtx.abspath, _processorisomorphic.GUIDE_JSON);
82
+ const e = new _error.SourceError((0, _error.formatErrors)(readErrors), guideJsonPath);
83
+ errors.push(e);
84
+ continue;
85
+ }
86
+ guides.push({
87
+ ...guideDirCtx,
88
+ content: guide
89
+ });
90
+ }
91
+ return [
92
+ guides,
93
+ errors
94
+ ];
95
+ };
96
+ const readGuideDir = async (guideDirCtx, opts = {})=>{
97
+ const { abspath } = guideDirCtx;
98
+ const { withExtractedFiles = false } = opts;
99
+ const dirExists = await _fsextra.pathExists(abspath);
100
+ if (!dirExists) throw new Error(`${abspath} does not exist`);
101
+ const guideJsonPath = await (0, _helpers1.lsGuideJson)(abspath);
102
+ if (!guideJsonPath) throw new Error(`${abspath} is not a guide directory`);
103
+ const result = await (0, _json.readJson)(guideJsonPath);
104
+ if (!result[0]) return result;
105
+ let [guideJson] = result;
106
+ guideJson = (0, _objectisomorphic.omitDeep)(guideJson, [
107
+ "__readonly"
108
+ ]);
109
+ return withExtractedFiles ? joinExtractedFiles(guideDirCtx, guideJson) : [
110
+ guideJson,
111
+ []
112
+ ];
113
+ };
114
+ const joinExtractedFiles = async (guideDirCtx, guideJson)=>{
115
+ // Tracks any errors encountered during traversal. Mutated in place.
116
+ const errors = [];
117
+ // Tracks each new valid extracted file path seen (rebased to be relative to
118
+ // guide.json) in the guide json node. Mutated in place, and used
119
+ // to validate the uniqueness of an extracted path encountered.
120
+ const uniqueFilePaths = {};
121
+ (0, _objectisomorphic.mapValuesDeep)(guideJson, (relpath, key, parts)=>{
122
+ // If not marked with the @suffix, there's nothing to do.
123
+ if (!_constisomorphic.FILEPATH_MARKED_RE.test(key)) return;
124
+ const objPathToFieldStr = _objectisomorphic.ObjPath.stringify(parts);
125
+ const inlinObjPathStr = objPathToFieldStr.replace(_constisomorphic.FILEPATH_MARKED_RE, "");
126
+ // If there is inlined content present already, then nothing more to do.
127
+ if ((0, _lodash.hasIn)(guideJson, inlinObjPathStr)) return;
128
+ // Check if the extracted path found at the current field path is valid
129
+ const invalidFilePathError = (0, _helpers.validateExtractedFilePath)(relpath, _nodepath.resolve(guideDirCtx.abspath, _processorisomorphic.GUIDE_JSON), uniqueFilePaths, objPathToFieldStr);
130
+ if (invalidFilePathError) {
131
+ errors.push(invalidFilePathError);
132
+ // Wipe the invalid file path in the node so the final guide json
133
+ // object ends up with only valid file paths, this way guide writer
134
+ // can see only valid file paths and use those when pulling.
135
+ (0, _lodash.set)(guideJson, inlinObjPathStr, undefined);
136
+ (0, _lodash.set)(guideJson, objPathToFieldStr, undefined);
137
+ return;
138
+ }
139
+ // By this point we have a valid extracted file path, so attempt to read the file.
140
+ const [content, readExtractedFileError] = (0, _helpers.readExtractedFileSync)(relpath, guideDirCtx, key);
141
+ if (readExtractedFileError) {
142
+ errors.push(readExtractedFileError);
143
+ // If there's an error, replace the extracted file path with the original one, and set the
144
+ // inlined field path in guide object with empty content, so we know
145
+ // we do not need to try inlining again.
146
+ (0, _lodash.set)(guideJson, objPathToFieldStr, relpath);
147
+ (0, _lodash.set)(guideJson, inlinObjPathStr, undefined);
148
+ return;
149
+ }
150
+ // Inline the file content and remove the extracted file path.
151
+ (0, _lodash.set)(guideJson, objPathToFieldStr, relpath);
152
+ (0, _lodash.set)(guideJson, inlinObjPathStr, content);
153
+ });
154
+ return [
155
+ guideJson,
156
+ errors
157
+ ];
158
+ };
159
+ const readAllForCommandTarget = async (target, opts = {})=>{
160
+ const { type: targetType, context: targetCtx } = target;
161
+ if (!targetCtx.exists) {
162
+ const subject = targetType === "guideDir" ? "a guide directory at" : "guide directories in";
163
+ return _core.ux.error(`Cannot locate ${subject} \`${targetCtx.abspath}\``);
164
+ }
165
+ switch(targetType){
166
+ case "guideDir":
167
+ {
168
+ return readGuideDirs([
169
+ targetCtx
170
+ ], opts);
171
+ }
172
+ case "guidesIndexDir":
173
+ {
174
+ const dirents = await _fsextra.readdir(targetCtx.abspath, {
175
+ withFileTypes: true
176
+ });
177
+ const promises = dirents.map(async (dirent)=>{
178
+ const abspath = _nodepath.resolve(targetCtx.abspath, dirent.name);
179
+ const guideDirCtx = {
180
+ type: "guide",
181
+ key: dirent.name,
182
+ abspath,
183
+ exists: await (0, _helpers1.isGuideDir)(abspath)
184
+ };
185
+ return guideDirCtx;
186
+ });
187
+ const guideDirCtxs = (await Promise.all(promises)).filter((guideDirCtx)=>guideDirCtx.exists);
188
+ return readGuideDirs(guideDirCtxs, opts);
189
+ }
190
+ default:
191
+ throw new Error(`Invalid guide command target: ${target}`);
192
+ }
193
+ };
@@ -0,0 +1,175 @@
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: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get pruneGuidesIndexDir () {
13
+ return pruneGuidesIndexDir;
14
+ },
15
+ get writeGuideDirFromData () {
16
+ return writeGuideDirFromData;
17
+ },
18
+ get writeGuidesIndexDir () {
19
+ return writeGuidesIndexDir;
20
+ }
21
+ });
22
+ const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
23
+ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
24
+ const _lodash = require("lodash");
25
+ const _const = require("../../helpers/const");
26
+ const _json = require("../../helpers/json");
27
+ const _helpers = require("./helpers");
28
+ const _processorisomorphic = require("./processor.isomorphic");
29
+ const _reader = require("./reader");
30
+ function _getRequireWildcardCache(nodeInterop) {
31
+ if (typeof WeakMap !== "function") return null;
32
+ var cacheBabelInterop = new WeakMap();
33
+ var cacheNodeInterop = new WeakMap();
34
+ return (_getRequireWildcardCache = function(nodeInterop) {
35
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
36
+ })(nodeInterop);
37
+ }
38
+ function _interop_require_wildcard(obj, nodeInterop) {
39
+ if (!nodeInterop && obj && obj.__esModule) {
40
+ return obj;
41
+ }
42
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
43
+ return {
44
+ default: obj
45
+ };
46
+ }
47
+ var cache = _getRequireWildcardCache(nodeInterop);
48
+ if (cache && cache.has(obj)) {
49
+ return cache.get(obj);
50
+ }
51
+ var newObj = {
52
+ __proto__: null
53
+ };
54
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
55
+ for(var key in obj){
56
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
57
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
58
+ if (desc && (desc.get || desc.set)) {
59
+ Object.defineProperty(newObj, key, desc);
60
+ } else {
61
+ newObj[key] = obj[key];
62
+ }
63
+ }
64
+ }
65
+ newObj.default = obj;
66
+ if (cache) {
67
+ cache.set(obj, newObj);
68
+ }
69
+ return newObj;
70
+ }
71
+ const writeGuideDirFromData = async (guideDirCtx, remoteGuide)=>{
72
+ // If the guide directory exists on the file system (i.e. previously
73
+ // pulled before), then read the guide file to use as a reference.
74
+ const [localGuide] = guideDirCtx.exists ? await (0, _reader.readGuideDir)(guideDirCtx, {
75
+ withExtractedFiles: true
76
+ }) : [];
77
+ const bundle = (0, _processorisomorphic.buildGuideDirBundle)(remoteGuide, localGuide);
78
+ return writeGuideDirFromBundle(guideDirCtx, bundle);
79
+ };
80
+ /*
81
+ * A lower level write function that takes a constructed guide dir bundle
82
+ * and writes it into a guide directory on a local file system.
83
+ *
84
+ * It does not make any assumptions about how the guide directory bundle was
85
+ * built; for example, it can be from parsing the guide data fetched from
86
+ * the Knock API, or built manually for scaffolding purposes.
87
+ */ const writeGuideDirFromBundle = async (guideDirCtx, guideDirBundle)=>{
88
+ const backupDirPath = _nodepath.resolve(_const.sandboxDir, (0, _lodash.uniqueId)("backup"));
89
+ try {
90
+ if (guideDirCtx.exists) {
91
+ await _fsextra.copy(guideDirCtx.abspath, backupDirPath);
92
+ await _fsextra.emptyDir(guideDirCtx.abspath);
93
+ }
94
+ const promises = Object.entries(guideDirBundle).map(([relpath, fileContent])=>{
95
+ const filePath = _nodepath.resolve(guideDirCtx.abspath, relpath);
96
+ return relpath === _processorisomorphic.GUIDE_JSON ? _fsextra.outputJson(filePath, fileContent, {
97
+ spaces: _json.DOUBLE_SPACES
98
+ }) : _fsextra.outputFile(filePath, fileContent !== null && fileContent !== void 0 ? fileContent : "");
99
+ });
100
+ await Promise.all(promises);
101
+ } catch (error) {
102
+ // In case of any error, wipe the target directory that is likely in a bad
103
+ // state then restore the backup if one existed before.
104
+ if (guideDirCtx.exists) {
105
+ await _fsextra.emptyDir(guideDirCtx.abspath);
106
+ await _fsextra.copy(backupDirPath, guideDirCtx.abspath);
107
+ } else {
108
+ await _fsextra.remove(guideDirCtx.abspath);
109
+ }
110
+ throw error;
111
+ } finally{
112
+ // Always clean up the backup directory in the temp sandbox.
113
+ await _fsextra.remove(backupDirPath);
114
+ }
115
+ };
116
+ /*
117
+ * Prunes the index directory by removing any files, or directories that aren't
118
+ * guide dirs found in fetched guides. We want to preserve any guide
119
+ * dirs that are going to be updated with remote guides, so extracted links
120
+ * can be respected.
121
+ */ const pruneGuidesIndexDir = async (indexDirCtx, remoteGuides)=>{
122
+ const guidesByKey = Object.fromEntries(remoteGuides.map((w)=>[
123
+ w.key.toLowerCase(),
124
+ w
125
+ ]));
126
+ const dirents = await _fsextra.readdir(indexDirCtx.abspath, {
127
+ withFileTypes: true
128
+ });
129
+ const promises = dirents.map(async (dirent)=>{
130
+ const direntName = dirent.name.toLowerCase();
131
+ const direntPath = _nodepath.resolve(indexDirCtx.abspath, direntName);
132
+ if (await (0, _helpers.isGuideDir)(direntPath) && guidesByKey[direntName]) {
133
+ return;
134
+ }
135
+ await _fsextra.remove(direntPath);
136
+ });
137
+ await Promise.all(promises);
138
+ };
139
+ const writeGuidesIndexDir = async (indexDirCtx, remoteGuides)=>{
140
+ const backupDirPath = _nodepath.resolve(_const.sandboxDir, (0, _lodash.uniqueId)("backup"));
141
+ try {
142
+ // If the index directory already exists, back it up in the temp sandbox
143
+ // before wiping it clean.
144
+ if (indexDirCtx.exists) {
145
+ await _fsextra.copy(indexDirCtx.abspath, backupDirPath);
146
+ await pruneGuidesIndexDir(indexDirCtx, remoteGuides);
147
+ }
148
+ // Write given remote guides into the given guides directory path.
149
+ const writeGuideDirPromises = remoteGuides.map(async (guide)=>{
150
+ const guideDirPath = _nodepath.resolve(indexDirCtx.abspath, guide.key);
151
+ const guideDirCtx = {
152
+ type: "guide",
153
+ key: guide.key,
154
+ abspath: guideDirPath,
155
+ exists: indexDirCtx.exists ? await (0, _helpers.isGuideDir)(guideDirPath) : false
156
+ };
157
+ return writeGuideDirFromData(guideDirCtx, guide);
158
+ });
159
+ await Promise.all(writeGuideDirPromises);
160
+ } catch (error) {
161
+ console.log(error);
162
+ // In case of any error, wipe the index directory that is likely in a bad
163
+ // state then restore the backup if one existed before.
164
+ if (indexDirCtx.exists) {
165
+ await _fsextra.emptyDir(indexDirCtx.abspath);
166
+ await _fsextra.copy(backupDirPath, indexDirCtx.abspath);
167
+ } else {
168
+ await _fsextra.remove(indexDirCtx.abspath);
169
+ }
170
+ throw error;
171
+ } finally{
172
+ // Always clean up the backup directory in the temp sandbox.
173
+ await _fsextra.remove(backupDirPath);
174
+ }
175
+ };
@@ -7,26 +7,26 @@ Object.defineProperty(exports, "__esModule", {
7
7
  function _export(target, all) {
8
8
  for(var name in all)Object.defineProperty(target, name, {
9
9
  enumerable: true,
10
- get: all[name]
10
+ get: Object.getOwnPropertyDescriptor(all, name).get
11
11
  });
12
12
  }
13
13
  _export(exports, {
14
- buildEmailLayoutDirBundle: function() {
14
+ get buildEmailLayoutDirBundle () {
15
15
  return _processorisomorphic.buildEmailLayoutDirBundle;
16
16
  },
17
- buildGuideDirBundle: function() {
17
+ get buildGuideDirBundle () {
18
18
  return _processorisomorphic1.buildGuideDirBundle;
19
19
  },
20
- buildMessageTypeDirBundle: function() {
20
+ get buildMessageTypeDirBundle () {
21
21
  return _processorisomorphic2.buildMessageTypeDirBundle;
22
22
  },
23
- buildPartialDirBundle: function() {
23
+ get buildPartialDirBundle () {
24
24
  return _processorisomorphic3.buildPartialDirBundle;
25
25
  },
26
- buildTranslationDirBundle: function() {
26
+ get buildTranslationDirBundle () {
27
27
  return _processorisomorphic4.buildTranslationDirBundle;
28
28
  },
29
- buildWorkflowDirBundle: function() {
29
+ get buildWorkflowDirBundle () {
30
30
  return _processorisomorphic5.buildWorkflowDirBundle;
31
31
  }
32
32
  });
@@ -5,20 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- ensureValidCommandTarget: function() {
12
+ get ensureValidCommandTarget () {
13
13
  return ensureValidCommandTarget;
14
14
  },
15
- isMessageTypeDir: function() {
15
+ get isMessageTypeDir () {
16
16
  return isMessageTypeDir;
17
17
  },
18
- lsMessageTypeJson: function() {
18
+ get lsMessageTypeJson () {
19
19
  return lsMessageTypeJson;
20
20
  },
21
- messageTypeJsonPath: function() {
21
+ get messageTypeJsonPath () {
22
22
  return messageTypeJsonPath;
23
23
  }
24
24
  });
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- MESSAGE_TYPE_JSON: function() {
12
+ get MESSAGE_TYPE_JSON () {
13
13
  return MESSAGE_TYPE_JSON;
14
14
  },
15
- buildMessageTypeDirBundle: function() {
15
+ get buildMessageTypeDirBundle () {
16
16
  return buildMessageTypeDirBundle;
17
17
  }
18
18
  });
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- readAllForCommandTarget: function() {
12
+ get readAllForCommandTarget () {
13
13
  return readAllForCommandTarget;
14
14
  },
15
- readMessageTypeDir: function() {
15
+ get readMessageTypeDir () {
16
16
  return readMessageTypeDir;
17
17
  }
18
18
  });
@@ -100,7 +100,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
100
100
  };
101
101
  const readMessageTypeDir = async (messageTypeDirCtx, opts = {})=>{
102
102
  const { abspath } = messageTypeDirCtx;
103
- const { withExtractedFiles = false, withReadonlyField = false } = opts;
103
+ const { withExtractedFiles = false } = opts;
104
104
  const dirExists = await _fsextra.pathExists(abspath);
105
105
  if (!dirExists) throw new Error(`${abspath} does not exist`);
106
106
  const messageTypeJsonPath = await (0, _helpers1.lsMessageTypeJson)(abspath);
@@ -108,7 +108,7 @@ const readMessageTypeDir = async (messageTypeDirCtx, opts = {})=>{
108
108
  const result = await (0, _json.readJson)(messageTypeJsonPath);
109
109
  if (!result[0]) return result;
110
110
  let [messageTypeJson] = result;
111
- messageTypeJson = withReadonlyField ? messageTypeJson : (0, _objectisomorphic.omitDeep)(messageTypeJson, [
111
+ messageTypeJson = (0, _objectisomorphic.omitDeep)(messageTypeJson, [
112
112
  "__readonly"
113
113
  ]);
114
114
  return withExtractedFiles ? joinExtractedFiles(messageTypeDirCtx, messageTypeJson) : [
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- pruneMessageTypesIndexDir: function() {
12
+ get pruneMessageTypesIndexDir () {
13
13
  return pruneMessageTypesIndexDir;
14
14
  },
15
- writeMessageTypeDirFromData: function() {
15
+ get writeMessageTypeDirFromData () {
16
16
  return writeMessageTypeDirFromData;
17
17
  },
18
- writeMessageTypesIndexDir: function() {
18
+ get writeMessageTypesIndexDir () {
19
19
  return writeMessageTypesIndexDir;
20
20
  }
21
21
  });
@@ -5,20 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- ensureValidCommandTarget: function() {
12
+ get ensureValidCommandTarget () {
13
13
  return ensureValidCommandTarget;
14
14
  },
15
- isPartialDir: function() {
15
+ get isPartialDir () {
16
16
  return isPartialDir;
17
17
  },
18
- lsPartialJson: function() {
18
+ get lsPartialJson () {
19
19
  return lsPartialJson;
20
20
  },
21
- partialJsonPath: function() {
21
+ get partialJsonPath () {
22
22
  return partialJsonPath;
23
23
  }
24
24
  });
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- PARTIAL_JSON: function() {
12
+ get PARTIAL_JSON () {
13
13
  return PARTIAL_JSON;
14
14
  },
15
- buildPartialDirBundle: function() {
15
+ get buildPartialDirBundle () {
16
16
  return buildPartialDirBundle;
17
17
  }
18
18
  });
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- readAllForCommandTarget: function() {
12
+ get readAllForCommandTarget () {
13
13
  return readAllForCommandTarget;
14
14
  },
15
- readPartialDir: function() {
15
+ get readPartialDir () {
16
16
  return readPartialDir;
17
17
  }
18
18
  });
@@ -100,7 +100,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
100
100
  };
101
101
  const readPartialDir = async (partialDirCtx, opts = {})=>{
102
102
  const { abspath } = partialDirCtx;
103
- const { withExtractedFiles = false, withReadonlyField = false } = opts;
103
+ const { withExtractedFiles = false } = opts;
104
104
  const dirExists = await _fsextra.pathExists(abspath);
105
105
  if (!dirExists) throw new Error(`${abspath} does not exist`);
106
106
  const partialJsonPath = await (0, _helpers1.lsPartialJson)(abspath);
@@ -108,7 +108,7 @@ const readPartialDir = async (partialDirCtx, opts = {})=>{
108
108
  const result = await (0, _json.readJson)(partialJsonPath);
109
109
  if (!result[0]) return result;
110
110
  let [partialJson] = result;
111
- partialJson = withReadonlyField ? partialJson : (0, _objectisomorphic.omitDeep)(partialJson, [
111
+ partialJson = (0, _objectisomorphic.omitDeep)(partialJson, [
112
112
  "__readonly"
113
113
  ]);
114
114
  return withExtractedFiles ? joinExtractedFiles(partialDirCtx, partialJson) : [
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- prunePartialsIndexDir: function() {
12
+ get prunePartialsIndexDir () {
13
13
  return prunePartialsIndexDir;
14
14
  },
15
- writePartialDirFromData: function() {
15
+ get writePartialDirFromData () {
16
16
  return writePartialDirFromData;
17
17
  },
18
- writePartialsIndexDir: function() {
18
+ get writePartialsIndexDir () {
19
19
  return writePartialsIndexDir;
20
20
  }
21
21
  });
@@ -14,14 +14,14 @@ Object.defineProperty(exports, "__esModule", {
14
14
  function _export(target, all) {
15
15
  for(var name in all)Object.defineProperty(target, name, {
16
16
  enumerable: true,
17
- get: all[name]
17
+ get: Object.getOwnPropertyDescriptor(all, name).get
18
18
  });
19
19
  }
20
20
  _export(exports, {
21
- FILEPATH_MARKED_RE: function() {
21
+ get FILEPATH_MARKED_RE () {
22
22
  return FILEPATH_MARKED_RE;
23
23
  },
24
- FILEPATH_MARKER: function() {
24
+ get FILEPATH_MARKER () {
25
25
  return FILEPATH_MARKER;
26
26
  }
27
27
  });
@@ -8,15 +8,22 @@ Object.defineProperty(exports, "prepareResourceJson", {
8
8
  return prepareResourceJson;
9
9
  }
10
10
  });
11
+ const _lodash = require("lodash");
11
12
  const _objectisomorphic = require("../../helpers/object.isomorphic");
13
+ // sha and updated_at fields change too frequently, so we exclude them from resource JSON files
14
+ const REMOVED_READONLY_FIELDS = [
15
+ "sha",
16
+ "updated_at"
17
+ ];
12
18
  const prepareResourceJson = (resource)=>{
13
19
  var _resource___annotation;
14
- // Move read only field under the dedicated field "__readonly".
15
20
  const readonlyFields = ((_resource___annotation = resource.__annotation) === null || _resource___annotation === void 0 ? void 0 : _resource___annotation.readonly_fields) || [];
16
21
  const [readonly, remainder] = (0, _objectisomorphic.split)(resource, readonlyFields);
22
+ const filteredReadonlyFields = (0, _lodash.omit)(readonly, REMOVED_READONLY_FIELDS);
23
+ // Move remaining read only fields under the dedicated field "__readonly".
17
24
  const resourceJson = {
18
25
  ...remainder,
19
- __readonly: readonly
26
+ __readonly: filteredReadonlyFields
20
27
  };
21
28
  // Strip out all schema annotations, so not to expose them to end users.
22
29
  return (0, _objectisomorphic.omitDeep)(resourceJson, [