@slack/bolt 3.12.1 → 4.0.0-nextGen.3

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 (97) hide show
  1. package/dist/App.d.ts +35 -6
  2. package/dist/App.d.ts.map +1 -1
  3. package/dist/App.js +132 -45
  4. package/dist/App.js.map +1 -1
  5. package/dist/Manifest.d.ts +5 -0
  6. package/dist/Manifest.d.ts.map +1 -0
  7. package/dist/Manifest.js +16 -0
  8. package/dist/Manifest.js.map +1 -0
  9. package/dist/SlackFunction.d.ts +181 -0
  10. package/dist/SlackFunction.d.ts.map +1 -0
  11. package/dist/SlackFunction.js +418 -0
  12. package/dist/SlackFunction.js.map +1 -0
  13. package/dist/Subscription.d.ts +61 -0
  14. package/dist/Subscription.d.ts.map +1 -0
  15. package/dist/Subscription.js +169 -0
  16. package/dist/Subscription.js.map +1 -0
  17. package/dist/cli/get-hooks.d.ts +2 -0
  18. package/dist/cli/get-hooks.d.ts.map +1 -0
  19. package/dist/cli/get-hooks.js +18 -0
  20. package/dist/cli/get-hooks.js.map +1 -0
  21. package/dist/cli/get-manifest.d.ts +3 -0
  22. package/dist/cli/get-manifest.d.ts.map +1 -0
  23. package/dist/cli/get-manifest.js +16 -0
  24. package/dist/cli/get-manifest.js.map +1 -0
  25. package/dist/cli/hook-utils/manifest.d.ts +7 -0
  26. package/dist/cli/hook-utils/manifest.d.ts.map +1 -0
  27. package/dist/cli/hook-utils/manifest.js +104 -0
  28. package/dist/cli/hook-utils/manifest.js.map +1 -0
  29. package/dist/cli/hook-utils/manifest.spec.d.ts +2 -0
  30. package/dist/cli/hook-utils/manifest.spec.d.ts.map +1 -0
  31. package/dist/cli/hook-utils/manifest.spec.js +75 -0
  32. package/dist/cli/hook-utils/manifest.spec.js.map +1 -0
  33. package/dist/cli/run.d.ts +2 -0
  34. package/dist/cli/run.d.ts.map +1 -0
  35. package/dist/cli/run.js +37 -0
  36. package/dist/cli/run.js.map +1 -0
  37. package/dist/cli/start.d.ts +3 -0
  38. package/dist/cli/start.d.ts.map +1 -0
  39. package/dist/cli/start.js +40 -0
  40. package/dist/cli/start.js.map +1 -0
  41. package/dist/errors.d.ts +13 -1
  42. package/dist/errors.d.ts.map +1 -1
  43. package/dist/errors.js +25 -1
  44. package/dist/errors.js.map +1 -1
  45. package/dist/helpers.d.ts +2 -1
  46. package/dist/helpers.d.ts.map +1 -1
  47. package/dist/helpers.js +8 -0
  48. package/dist/helpers.js.map +1 -1
  49. package/dist/index.d.ts +2 -0
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +2 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/middleware/builtin.d.ts.map +1 -1
  54. package/dist/middleware/builtin.js +0 -1
  55. package/dist/middleware/builtin.js.map +1 -1
  56. package/dist/middleware/process.d.ts.map +1 -1
  57. package/dist/middleware/process.js.map +1 -1
  58. package/dist/receivers/ExpressReceiver.d.ts +1 -1
  59. package/dist/receivers/ExpressReceiver.js +2 -1
  60. package/dist/receivers/ExpressReceiver.js.map +1 -1
  61. package/dist/receivers/HTTPModuleFunctions.js +1 -1
  62. package/dist/receivers/HTTPReceiver.js +4 -4
  63. package/dist/receivers/HTTPReceiver.js.map +1 -1
  64. package/dist/receivers/SocketModeFunctions.js +2 -1
  65. package/dist/receivers/SocketModeFunctions.js.map +1 -1
  66. package/dist/receivers/SocketModeReceiver.js.map +1 -1
  67. package/dist/receivers/verify-request.d.ts +2 -2
  68. package/dist/receivers/verify-request.js +3 -3
  69. package/dist/types/actions/block-action.d.ts +4 -3
  70. package/dist/types/actions/block-action.d.ts.map +1 -1
  71. package/dist/types/actions/dialog-action.d.ts +4 -0
  72. package/dist/types/actions/dialog-action.d.ts.map +1 -1
  73. package/dist/types/events/base-events.d.ts +30 -1
  74. package/dist/types/events/base-events.d.ts.map +1 -1
  75. package/dist/types/events/base-events.js.map +1 -1
  76. package/dist/types/functions/index.d.ts +26 -0
  77. package/dist/types/functions/index.d.ts.map +1 -0
  78. package/dist/types/functions/index.js +3 -0
  79. package/dist/types/functions/index.js.map +1 -0
  80. package/dist/types/index.d.ts +1 -0
  81. package/dist/types/index.d.ts.map +1 -1
  82. package/dist/types/index.js +1 -0
  83. package/dist/types/index.js.map +1 -1
  84. package/dist/types/middleware.d.ts +17 -1
  85. package/dist/types/middleware.d.ts.map +1 -1
  86. package/dist/types/middleware.js.map +1 -1
  87. package/dist/types/subscription/index.d.ts +80 -0
  88. package/dist/types/subscription/index.d.ts.map +1 -0
  89. package/dist/types/subscription/index.js +3 -0
  90. package/dist/types/subscription/index.js.map +1 -0
  91. package/dist/types/view/index.d.ts +6 -5
  92. package/dist/types/view/index.d.ts.map +1 -1
  93. package/package.json +16 -5
  94. package/src/cli/get-hooks.js +16 -0
  95. package/src/cli/get-manifest.js +16 -0
  96. package/src/cli/hook-utils/manifest.js +114 -0
  97. package/src/cli/start.js +43 -0
@@ -0,0 +1,114 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const merge = require('deepmerge');
4
+
5
+ // helper array merge function
6
+ function unionMerge(array1, array2) {
7
+ return [...new Set(array1.concat(array2))];
8
+ }
9
+
10
+ // look for manifest.json in the current working directory
11
+ function readManifestJSONFile(searchDir, filename) {
12
+ let jsonFilePath, manifestJSON;
13
+ try {
14
+ jsonFilePath = find(searchDir, filename);
15
+ if (fs.existsSync(jsonFilePath)) {
16
+ manifestJSON = JSON.parse(fs.readFileSync(jsonFilePath, 'utf8'));
17
+ }
18
+ } catch (error) {
19
+ return;
20
+ }
21
+ return manifestJSON;
22
+ }
23
+
24
+ // look for a manifest file in the current working directory
25
+ function readImportedManifestFile(searchDir, filename) {
26
+ let importedManifestFilePath, manifestImported;
27
+
28
+ try {
29
+ importedManifestFilePath = find(searchDir, filename);
30
+ if (fs.existsSync(importedManifestFilePath)) {
31
+ manifestImported = require(`${importedManifestFilePath}`);
32
+
33
+ // if a default key is provided, assumes default export contains manifest
34
+ if (manifestImported["default"]) {
35
+ manifestImported = manifestImported["default"]
36
+ }
37
+ }
38
+ } catch (error) {
39
+ console.log(error);
40
+ return;
41
+ }
42
+ return manifestImported;
43
+ }
44
+
45
+ // true if any non empty manifest has been supplied
46
+ function hasManifest(...entries) {
47
+ for (let ent of entries) {
48
+ if (ent && (Object.keys(ent).length > 0)) {
49
+ return true;
50
+ }
51
+ }
52
+ return false;
53
+ }
54
+
55
+ // recursive search for provided path and return full path when filename is found
56
+ // TODO: Cache searched paths and check that they haven't been explored already
57
+ // This guards against rare edge case of a subdir in the file tree which is
58
+ // symlinked back to root or in such a way that creates a cycle. Can also implement
59
+ // max depth check.
60
+ function find(currentPath, targetFilename) {
61
+ if (currentPath.endsWith(`/${targetFilename}`)) {
62
+ return currentPath;
63
+ }
64
+
65
+ if (fs.existsSync(currentPath) && fs.lstatSync(currentPath).isDirectory()) {
66
+ let foundEntry;
67
+ let dirents = fs.readdirSync(currentPath);
68
+ for (let entry of dirents) {
69
+ if (entry !== 'node_modules') {
70
+ let newPath = path.resolve(currentPath, entry);
71
+ foundEntry = find(newPath, targetFilename);
72
+ if (foundEntry) {
73
+ return foundEntry;
74
+ }
75
+ }
76
+ }
77
+ return null;
78
+ }
79
+ }
80
+
81
+ function getManifestData(searchDir) {
82
+ const file = 'manifest';
83
+ let manifest = {};
84
+
85
+ // look for a manifest JSON
86
+ const manifestJSON = readManifestJSONFile(searchDir, `${file}.json`);
87
+
88
+ // look for manifest.js
89
+ // stringify and parses the JSON in order to ensure that objects with .toJSON() functions
90
+ // resolve properly. This is a known behavior for CustomType
91
+ const manifestJS = JSON.parse(JSON.stringify(readImportedManifestFile(searchDir, `${file}.js`)));
92
+
93
+ if (!hasManifest(manifestJS, manifestJSON)) {
94
+ throw new Error('Unable to find a manifest file in this project');
95
+ }
96
+
97
+ // manage manifest merge
98
+ if (manifestJSON) {
99
+ manifest = merge(manifest, manifestJSON, { arrayMerge: unionMerge});
100
+ }
101
+ if (manifestJS) {
102
+ manifest = merge(manifest, manifestJS, { arrayMerge: unionMerge });
103
+ }
104
+ return manifest;
105
+ }
106
+
107
+ module.exports = {
108
+ getManifestData,
109
+ unionMerge,
110
+ readManifestJSONFile,
111
+ readImportedManifestFile,
112
+ hasManifest,
113
+ find,
114
+ }
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env node
2
+ const { spawn } = require('child_process');
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+ const { main: pkgJSONMain } = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
6
+
7
+ // Run script hook verifies that requirements for running an App in
8
+ // in developerMode (via Socket Mode) are met
9
+ (function _(cwd, customPath) {
10
+ // TODO - Format so that its less miss-able in output
11
+ console.log('Preparing local run in developer mode (Socket Mode)');
12
+ // Check required local run tokens
13
+ validate();
14
+
15
+ // tries the provided path, then package.json main, then defaults to index.js in the current
16
+ // working directory
17
+ const pkgJSONDefault = 'index.js';
18
+ const fullPath = path.resolve(cwd, customPath ? customPath : pkgJSONMain ? pkgJSONMain : pkgJSONDefault);
19
+ console.log(fullPath);
20
+
21
+ // Kick off a subprocess to run the app in development mode
22
+ const app = spawn('node', [`${fullPath}`]);
23
+ app.stdout.setEncoding('utf-8');
24
+ app.stdout.on('data', (data) => {
25
+ process.stdout.write(data);
26
+ });
27
+ app.stderr.on('data', (data) => {
28
+ process.stderr.write(data);
29
+ });
30
+
31
+ app.on('close', (code) => {
32
+ console.log(`bolt-app local run exited with code ${code}`);
33
+ });
34
+ }(process.cwd(), process.env.SLACK_CLI_CUSTOM_FILE_PATH));
35
+
36
+ function validate() {
37
+ if (!process.env.SLACK_CLI_XOXB) {
38
+ throw new Error('Missing local run bot token. Please see slack-cli maintainers to troubleshoot.');
39
+ }
40
+ if (!process.env.SLACK_CLI_XAPP) {
41
+ throw new Error('Missing local run app token. Please see slack-cli maintainers to troubleshoot');
42
+ }
43
+ }