@fabasoad/sarif-to-slack 0.1.0 → 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 (44) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
  2. package/.github/pull_request_template.md +3 -3
  3. package/.github/workflows/linting.yml +14 -0
  4. package/.github/workflows/release.yml +2 -0
  5. package/.github/workflows/unit-tests.yml +1 -0
  6. package/.pre-commit-config.yaml +2 -2
  7. package/CONTRIBUTING.md +1 -1
  8. package/Makefile +1 -1
  9. package/README.md +36 -5
  10. package/api-extractor.json +1 -1
  11. package/biome.json +15 -12
  12. package/dist/Logger.d.ts +2 -0
  13. package/dist/Logger.d.ts.map +1 -0
  14. package/dist/Logger.js +25 -0
  15. package/dist/Processors.d.ts +2 -0
  16. package/dist/Processors.d.ts.map +1 -0
  17. package/dist/Processors.js +91 -0
  18. package/dist/SarifToSlackService.d.ts +39 -0
  19. package/dist/SarifToSlackService.d.ts.map +1 -0
  20. package/dist/SarifToSlackService.js +95 -0
  21. package/dist/SlackMessageBuilder.d.ts +2 -0
  22. package/dist/SlackMessageBuilder.d.ts.map +1 -0
  23. package/dist/SlackMessageBuilder.js +145 -0
  24. package/dist/index.d.ts +45 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +46 -0
  27. package/dist/sarif-to-slack.d.ts +28 -9
  28. package/dist/types.d.ts +104 -0
  29. package/dist/types.d.ts.map +1 -0
  30. package/dist/types.js +45 -0
  31. package/dist/version.d.ts +2 -0
  32. package/dist/version.d.ts.map +1 -0
  33. package/dist/version.js +4 -0
  34. package/etc/sarif-to-slack.api.md +19 -6
  35. package/jest.config.json +2 -2
  36. package/package.json +10 -5
  37. package/scripts/save-version.sh +6 -0
  38. package/src/Logger.ts +2 -0
  39. package/src/SarifToSlackService.ts +5 -3
  40. package/src/SlackMessageBuilder.ts +11 -9
  41. package/src/index.ts +7 -4
  42. package/src/types.ts +24 -6
  43. package/src/version.ts +3 -0
  44. package/tsconfig.json +27 -13
@@ -1,8 +1,10 @@
1
1
  import { AnyBlock } from '@slack/types'
2
- import { HeaderBlock, ContextBlock } from '@slack/types/dist/block-kit/blocks'
2
+ import { ContextBlock, HeaderBlock } from '@slack/types/dist/block-kit/blocks'
3
+ import { TextObject } from '@slack/types/dist/block-kit/composition-objects'
3
4
  import { IncomingWebhook } from '@slack/webhook'
4
- import type { Run, Result, ReportingDescriptor } from 'sarif'
5
- import { Sarif, SlackMessage } from './types'
5
+ import { FooterType, Sarif, SlackMessage } from './types'
6
+ import type { ReportingDescriptor, Result, Run } from 'sarif'
7
+ import { LIB_VERSION } from './version'
6
8
 
7
9
  /**
8
10
  * Options for the SlackMessageBuilder.
@@ -61,14 +63,14 @@ export class SlackMessageBuilder implements SlackMessage {
61
63
  this.runId = process.env.GITHUB_RUN_ID
62
64
  }
63
65
 
64
- withFooter(footer?: string): void {
65
- const repoName = 'fabasoad/sarif-to-slack-action'
66
+ withFooter(text?: string, type?: FooterType): void {
67
+ const repoName = 'fabasoad/sarif-to-slack'
68
+ const element: TextObject = text
69
+ ? { type: type || FooterType.PLAIN_TEXT, text }
70
+ : { type: FooterType.MARKDOWN, text: `Generated by <${this.gitHubServerUrl}/${repoName}|@${repoName}@${LIB_VERSION}>` }
66
71
  this.footer = {
67
72
  type: 'context',
68
- elements: [{
69
- type: footer ? 'plain_text' : 'mrkdwn',
70
- text: footer || `Generated by <${this.gitHubServerUrl}/${repoName}|${repoName}>`
71
- }],
73
+ elements: [element],
72
74
  }
73
75
  }
74
76
 
package/src/index.ts CHANGED
@@ -9,9 +9,9 @@
9
9
  *
10
10
  * @example
11
11
  * ```typescript
12
- * import { SarifToSlackService } from 'sarif-to-slack';
12
+ * import { SarifToSlackService, FooterType } from '@fabasoad/sarif-to-slack';
13
13
  *
14
- * const service = new SarifToSlackService({
14
+ * const service = await SarifToSlackService.create({
15
15
  * webhookUrl: 'https://hooks.slack.com/services/your/webhook/url',
16
16
  * sarifPath: 'path/to/your/sarif/file.sarif',
17
17
  * logLevel: 'info',
@@ -24,6 +24,7 @@
24
24
  * },
25
25
  * footer: {
26
26
  * include: true,
27
+ * type: FooterType.PLAIN_TEXT,
27
28
  * value: 'Generated by @fabasoad/sarif-to-slack'
28
29
  * },
29
30
  * actor: {
@@ -43,8 +44,10 @@
43
44
  */
44
45
  export { SarifToSlackService } from './SarifToSlackService'
45
46
  export {
46
- IncludeAwareProps,
47
- IncludeAwareWithValueProps,
47
+ FooterOptions,
48
+ FooterType,
49
+ IncludeAwareOptions,
50
+ IncludeAwareWithValueOptions,
48
51
  LogLevel,
49
52
  Sarif,
50
53
  SarifToSlackServiceOptions,
package/src/types.ts CHANGED
@@ -62,7 +62,7 @@ export enum LogLevel {
62
62
  * in the Slack message.
63
63
  * @public
64
64
  */
65
- export type IncludeAwareProps = {
65
+ export type IncludeAwareOptions = {
66
66
  include: boolean
67
67
  }
68
68
 
@@ -71,10 +71,28 @@ export type IncludeAwareProps = {
71
71
  * in the Slack message, along with an optional value.
72
72
  * @public
73
73
  */
74
- export type IncludeAwareWithValueProps = IncludeAwareProps & {
74
+ export type IncludeAwareWithValueOptions = IncludeAwareOptions & {
75
75
  value?: string
76
76
  }
77
77
 
78
+ /**
79
+ * Enum representing the type of footer in a Slack message.
80
+ * @public
81
+ */
82
+ export enum FooterType {
83
+ PLAIN_TEXT = 'plain_text',
84
+ MARKDOWN = 'mrkdwn'
85
+ }
86
+
87
+ /**
88
+ * Options for the footer of a Slack message. "type" is ignored if "value" is
89
+ * not defined.
90
+ * @public
91
+ */
92
+ export type FooterOptions = IncludeAwareWithValueOptions & {
93
+ type?: FooterType
94
+ }
95
+
78
96
  /**
79
97
  * Options for the SarifToSlackService.
80
98
  * @public
@@ -87,8 +105,8 @@ export type SarifToSlackServiceOptions = {
87
105
  iconUrl?: string,
88
106
  color?: string,
89
107
  logLevel?: LogLevel | string,
90
- header?: IncludeAwareWithValueProps,
91
- footer?: IncludeAwareWithValueProps,
92
- actor?: IncludeAwareWithValueProps,
93
- run?: IncludeAwareProps,
108
+ header?: IncludeAwareWithValueOptions,
109
+ footer?: FooterOptions,
110
+ actor?: IncludeAwareWithValueOptions,
111
+ run?: IncludeAwareOptions,
94
112
  }
package/src/version.ts ADDED
@@ -0,0 +1,3 @@
1
+ // This file is autogenerated by scripts/save-version.sh
2
+ // Do not edit it manually!
3
+ export const LIB_VERSION = '0.2.0'
package/tsconfig.json CHANGED
@@ -1,21 +1,35 @@
1
1
  {
2
2
  "$schema": "http://json.schemastore.org/tsconfig",
3
3
  "compilerOptions": {
4
- "target": "es2024",
5
- "module": "commonjs",
4
+ "allowSyntheticDefaultImports": true,
5
+ "alwaysStrict": true,
6
+ "baseUrl": ".",
6
7
  "declaration": true,
7
- "sourceMap": true,
8
+ "declarationDir": "dist",
8
9
  "declarationMap": true,
9
- "stripInternal": true,
10
- "types": ["node", "jest"],
10
+ "downlevelIteration": true,
11
+ "emitDecoratorMetadata": true,
12
+ "esModuleInterop": true,
13
+ "experimentalDecorators": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "inlineSourceMap": true,
16
+ "lib": ["es2024"],
17
+ "module": "es2022",
18
+ "moduleResolution": "node",
11
19
  "newLine": "lf",
12
- "lib": [
13
- "es2024"
14
- ],
15
- "outDir": "lib"
20
+ "noFallthroughCasesInSwitch": true,
21
+ "noImplicitAny": true,
22
+ "noImplicitThis": true,
23
+ "noUnusedLocals": true,
24
+ "noUnusedParameters": true,
25
+ "outDir": "dist",
26
+ "skipLibCheck": true,
27
+ "strict": true,
28
+ "stripInternal": true,
29
+ "target": "es2024",
30
+ "typeRoots": ["node_modules/@types", "@types"],
31
+ "types": ["node", "jest"]
16
32
  },
17
- "include": [
18
- "src/**/*.ts"
19
- ],
20
- "exclude": ["node_modules", "tests"]
33
+ "include": ["src"],
34
+ "exclude": ["node_modules", "dist", "tests"]
21
35
  }