serverless-spy 0.0.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 (64) hide show
  1. package/.eslintrc.yml +97 -0
  2. package/.gitattributes +24 -0
  3. package/.husky/pre-commit +4 -0
  4. package/.jsii +3199 -0
  5. package/.prettierignore +1 -0
  6. package/.prettierrc.json +5 -0
  7. package/API.md +123 -0
  8. package/LICENSE +202 -0
  9. package/README.md +1 -0
  10. package/cli/cli.ts +97 -0
  11. package/cli/index.html +43 -0
  12. package/cli/package-lock.json +2356 -0
  13. package/cli/package.json +14 -0
  14. package/cli/serverlessSpy.js +73 -0
  15. package/cli/spy_log.json +0 -0
  16. package/cli/style.css +43 -0
  17. package/cli/ws.ts +79 -0
  18. package/common/getWebSocketUrl.ts +68 -0
  19. package/common/package.json +22 -0
  20. package/common/spyEvents/DynamoDBSpyEvent.ts +12 -0
  21. package/common/spyEvents/EventBridgeRuleSpyEvent.ts +13 -0
  22. package/common/spyEvents/EventBridgeSpyEvent.ts +13 -0
  23. package/common/spyEvents/FunctionConsoleSpyEvent.ts +11 -0
  24. package/common/spyEvents/FunctionContext.ts +8 -0
  25. package/common/spyEvents/FunctionErrorSpyEvent.ts +9 -0
  26. package/common/spyEvents/FunctionRequestSpyEvent.ts +8 -0
  27. package/common/spyEvents/FunctionResponseSpyEvent.ts +10 -0
  28. package/common/spyEvents/S3SpyEvent.ts +9 -0
  29. package/common/spyEvents/SnsSubscriptionSpyEvent.ts +12 -0
  30. package/common/spyEvents/SnsTopicSpyEvent.ts +12 -0
  31. package/common/spyEvents/SpyEvent.ts +3 -0
  32. package/common/spyEvents/SpyMessage.ts +7 -0
  33. package/common/spyEvents/SqsSpyEvent.ts +8 -0
  34. package/functions/onConnect.ts +29 -0
  35. package/functions/onDisconnect.ts +28 -0
  36. package/functions/sendMessage.ts +277 -0
  37. package/functions/tsconfig.dev.json +16 -0
  38. package/functions/tsconfig.json +16 -0
  39. package/index.ts +2 -0
  40. package/lambda-extension/aws/Common.ts +88 -0
  41. package/lambda-extension/aws/Errors.ts +140 -0
  42. package/lambda-extension/aws/UserFunction.ts +169 -0
  43. package/lambda-extension/interceptor.ts +146 -0
  44. package/lambda-extension/spy-wrapper +4 -0
  45. package/lambda-extension/tsconfig.json +16 -0
  46. package/lib/ServerlessSpy.d.ts +27 -0
  47. package/lib/ServerlessSpy.js +301 -0
  48. package/lib/index.d.ts +1 -0
  49. package/lib/index.js +14 -0
  50. package/listener/PrettifyForDisplay.ts +5 -0
  51. package/listener/RecursivePartial.ts +9 -0
  52. package/listener/SpyHandlers.ts.ts +190 -0
  53. package/listener/SpyListener.ts +104 -0
  54. package/listener/createServerlessSpyListener.ts +258 -0
  55. package/listener/index.ts +1 -0
  56. package/listener/matchers.ts +53 -0
  57. package/listener/package.json +19 -0
  58. package/listener/setup.ts +21 -0
  59. package/listener/tsconfig.dev.json +16 -0
  60. package/listener/tsconfig.json +16 -0
  61. package/package.json +132 -0
  62. package/scripts/run-task +1836 -0
  63. package/sst-esbuild/esbuild.js +57 -0
  64. package/x_jest.config.ts +203 -0
@@ -0,0 +1,57 @@
1
+ const fs = require('fs');
2
+
3
+ const getCopyFunction =
4
+ (files = {}) =>
5
+ async () => {
6
+ // const operations = Object.entries(files).map(([target, source]) =>
7
+ // cp(source, target)
8
+ // );
9
+ // await Promise.all(operations);
10
+ //console.log("************** getCopyFunction");
11
+ };
12
+
13
+ const afterFunction =
14
+ (out = {}) =>
15
+ async (e) => {
16
+ // const operations = Object.entries(files).map(([target, source]) =>
17
+ // cp(source, target)
18
+ // );
19
+ // await Promise.all(operations);
20
+ //console.log("AFTER", out);
21
+
22
+ // fs.appendFileSync(
23
+ // out,
24
+ // "\nconsole.log('*************** INJECTED ***************')"
25
+ // );
26
+
27
+ const data = fs.readFileSync(out, 'utf8');
28
+ //console.log(data);
29
+ };
30
+
31
+ const copyFilePlugin = ({ before, after }) => ({
32
+ name: 'copyFile',
33
+ async setup(build) {
34
+ //console.log("************** before: " + before);
35
+ //console.log("BUILD ", build);
36
+ const out = build.initialOptions.outfile;
37
+
38
+ //before && build.onStart(getCopyFunction(before));
39
+ //after && build.onEnd(getCopyFunction(after));
40
+ build.onEnd(afterFunction(out));
41
+ },
42
+ });
43
+
44
+ console.log('**************** DELA *****************');
45
+
46
+ module.exports = [
47
+ copyFilePlugin({
48
+ before: {
49
+ // copy before bundling
50
+ './assets/favicon.png': './media/images/favicon.png',
51
+ },
52
+ after: {
53
+ // copy after bundling
54
+ './logs/build-report.json': './dist/report.json',
55
+ },
56
+ }),
57
+ ];
@@ -0,0 +1,203 @@
1
+ /*
2
+ * For a detailed explanation regarding each configuration property and type check, visit:
3
+ * https://jestjs.io/docs/configuration
4
+ */
5
+
6
+ export default {
7
+ // All imported modules in your tests should be mocked automatically
8
+ // automock: false,
9
+
10
+ // Stop running tests after `n` failures
11
+ // bail: 0,
12
+
13
+ // The directory where Jest should store its cached dependency information
14
+ // cacheDirectory: "/tmp/jest_rs",
15
+
16
+ // Automatically clear mock calls, instances, contexts and results before every test
17
+ // clearMocks: false,
18
+
19
+ // Indicates whether the coverage information should be collected while executing the test
20
+ // collectCoverage: false,
21
+
22
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
23
+ // collectCoverageFrom: undefined,
24
+
25
+ // The directory where Jest should output its coverage files
26
+ // coverageDirectory: undefined,
27
+
28
+ // An array of regexp pattern strings used to skip coverage collection
29
+ // coveragePathIgnorePatterns: [
30
+ // "/node_modules/"
31
+ // ],
32
+
33
+ // Indicates which provider should be used to instrument code for coverage
34
+ coverageProvider: 'v8',
35
+
36
+ // A list of reporter names that Jest uses when writing coverage reports
37
+ // coverageReporters: [
38
+ // "json",
39
+ // "text",
40
+ // "lcov",
41
+ // "clover"
42
+ // ],
43
+
44
+ // An object that configures minimum threshold enforcement for coverage results
45
+ // coverageThreshold: undefined,
46
+
47
+ // A path to a custom dependency extractor
48
+ // dependencyExtractor: undefined,
49
+
50
+ // Make calling deprecated APIs throw helpful error messages
51
+ // errorOnDeprecated: false,
52
+
53
+ // The default configuration for fake timers
54
+ // fakeTimers: {
55
+ // "enableGlobally": false
56
+ // },
57
+
58
+ // Force coverage collection from ignored files using an array of glob patterns
59
+ // forceCoverageMatch: [],
60
+
61
+ // A path to a module which exports an async function that is triggered once before all test suites
62
+ // globalSetup: undefined,
63
+
64
+ // A path to a module which exports an async function that is triggered once after all test suites
65
+ // globalTeardown: undefined,
66
+
67
+ // A set of global variables that need to be available in all test environments
68
+ // globals: {},
69
+
70
+ // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
71
+ // maxWorkers: "50%",
72
+
73
+ // An array of directory names to be searched recursively up from the requiring module's location
74
+ // moduleDirectories: [
75
+ // "node_modules"
76
+ // ],
77
+
78
+ // An array of file extensions your modules use
79
+ // moduleFileExtensions: [
80
+ // "js",
81
+ // "mjs",
82
+ // "cjs",
83
+ // "jsx",
84
+ // "ts",
85
+ // "tsx",
86
+ // "json",
87
+ // "node"
88
+ // ],
89
+
90
+ // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
91
+ // moduleNameMapper: {},
92
+
93
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
94
+ // modulePathIgnorePatterns: [],
95
+
96
+ // Activates notifications for test results
97
+ // notify: false,
98
+
99
+ // An enum that specifies notification mode. Requires { notify: true }
100
+ // notifyMode: "failure-change",
101
+
102
+ // A preset that is used as a base for Jest's configuration
103
+ // preset: undefined,
104
+ // preset: 'ts-jest',
105
+
106
+ // Run tests from one or more projects
107
+ // projects: undefined,
108
+
109
+ // Use this configuration option to add custom reporters to Jest
110
+ // reporters: undefined,
111
+
112
+ // Automatically reset mock state before every test
113
+ // resetMocks: false,
114
+
115
+ // Reset the module registry before running each individual test
116
+ // resetModules: false,
117
+
118
+ // A path to a custom resolver
119
+ // resolver: undefined,
120
+
121
+ // Automatically restore mock state and implementation before every test
122
+ // restoreMocks: false,
123
+
124
+ // The root directory that Jest should scan for tests and modules within
125
+ // rootDir: undefined,
126
+
127
+ // A list of paths to directories that Jest should use to search for files in
128
+ // roots: [
129
+ // "<rootDir>"
130
+ // ],
131
+
132
+ // Allows you to use a custom runner instead of Jest's default test runner
133
+ // runner: "jest-runner",
134
+
135
+ // The paths to modules that run some code to configure or set up the testing environment before each test
136
+ // setupFiles: [],
137
+
138
+ // A list of paths to modules that run some code to configure or set up the testing framework before each test
139
+ // setupFilesAfterEnv: [],
140
+ // setupFilesAfterEnv: ['./services/jest-extension/setup.ts'],
141
+
142
+ // The number of seconds after which a test is considered as slow and reported as such in the results.
143
+ // slowTestThreshold: 5,
144
+
145
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
146
+ // snapshotSerializers: [],
147
+
148
+ // The test environment that will be used for testing
149
+ // testEnvironment: "jest-environment-node",
150
+
151
+ // Options that will be passed to the testEnvironment
152
+ // testEnvironmentOptions: {},
153
+
154
+ // Adds a location field to test results
155
+ // testLocationInResults: false,
156
+
157
+ // The glob patterns Jest uses to detect test files
158
+ // testMatch: [
159
+ // "**/__tests__/**/*.[jt]s?(x)",
160
+ // "**/?(*.)+(spec|test).[tj]s?(x)"
161
+ // ],
162
+
163
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
164
+ // testPathIgnorePatterns: [
165
+ // "/node_modules/"
166
+ // ],
167
+
168
+ // The regexp pattern or array of patterns that Jest uses to detect test files
169
+ // testRegex: [],
170
+
171
+ // This option allows the use of a custom results processor
172
+ // testResultsProcessor: undefined,
173
+
174
+ // This option allows use of a custom test runner
175
+ // testRunner: "jest-circus/runner",
176
+
177
+ // A map from regular expressions to paths to transformers
178
+ // transform: undefined,
179
+ // transform: {
180
+ // "^.+\\.ts?$": "ts-jest",
181
+ // },
182
+
183
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
184
+ // transformIgnorePatterns: [
185
+ // "/node_modules/",
186
+ // "\\.pnp\\.[^\\/]+$"
187
+ // ],
188
+ transform: {
189
+ '^.+\\.tsx?$': 'esbuild-jest',
190
+ },
191
+
192
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
193
+ // unmockedModulePathPatterns: undefined,
194
+
195
+ // Indicates whether each individual test should be reported during the run
196
+ // verbose: undefined,
197
+
198
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
199
+ // watchPathIgnorePatterns: [],
200
+
201
+ // Whether to use watchman for file crawling
202
+ // watchman: true,
203
+ };