airbyte-faros-destination 0.1.53

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 (280) hide show
  1. package/README.md +161 -0
  2. package/lib/common/write-stats.d.ts +16 -0
  3. package/lib/common/write-stats.js +48 -0
  4. package/lib/community/hasura-client.d.ts +27 -0
  5. package/lib/community/hasura-client.js +278 -0
  6. package/lib/community/hasura-writer.d.ts +12 -0
  7. package/lib/community/hasura-writer.js +44 -0
  8. package/lib/community/types.d.ts +26 -0
  9. package/lib/community/types.js +9 -0
  10. package/lib/converters/agileaccelerator/agileaccelerator_types.d.ts +315 -0
  11. package/lib/converters/agileaccelerator/agileaccelerator_types.js +81 -0
  12. package/lib/converters/agileaccelerator/common.d.ts +64 -0
  13. package/lib/converters/agileaccelerator/common.js +167 -0
  14. package/lib/converters/agileaccelerator/works.d.ts +7 -0
  15. package/lib/converters/agileaccelerator/works.js +105 -0
  16. package/lib/converters/asana/common.d.ts +39 -0
  17. package/lib/converters/asana/common.js +64 -0
  18. package/lib/converters/asana/projects.d.ts +7 -0
  19. package/lib/converters/asana/projects.js +29 -0
  20. package/lib/converters/asana/sections.d.ts +7 -0
  21. package/lib/converters/asana/sections.js +28 -0
  22. package/lib/converters/asana/stories.d.ts +7 -0
  23. package/lib/converters/asana/stories.js +32 -0
  24. package/lib/converters/asana/tags.d.ts +7 -0
  25. package/lib/converters/asana/tags.js +22 -0
  26. package/lib/converters/asana/tasks.d.ts +11 -0
  27. package/lib/converters/asana/tasks.js +160 -0
  28. package/lib/converters/asana/users.d.ts +7 -0
  29. package/lib/converters/asana/users.js +16 -0
  30. package/lib/converters/backlog/common.d.ts +20 -0
  31. package/lib/converters/backlog/common.js +59 -0
  32. package/lib/converters/backlog/issues.d.ts +7 -0
  33. package/lib/converters/backlog/issues.js +119 -0
  34. package/lib/converters/backlog/models.d.ts +156 -0
  35. package/lib/converters/backlog/models.js +23 -0
  36. package/lib/converters/backlog/projects.d.ts +7 -0
  37. package/lib/converters/backlog/projects.js +78 -0
  38. package/lib/converters/backlog/users.d.ts +7 -0
  39. package/lib/converters/backlog/users.js +26 -0
  40. package/lib/converters/bitbucket/branches.d.ts +7 -0
  41. package/lib/converters/bitbucket/branches.js +31 -0
  42. package/lib/converters/bitbucket/commits.d.ts +7 -0
  43. package/lib/converters/bitbucket/commits.js +50 -0
  44. package/lib/converters/bitbucket/common.d.ts +28 -0
  45. package/lib/converters/bitbucket/common.js +56 -0
  46. package/lib/converters/bitbucket/deployments.d.ts +11 -0
  47. package/lib/converters/bitbucket/deployments.js +100 -0
  48. package/lib/converters/bitbucket/issues.d.ts +12 -0
  49. package/lib/converters/bitbucket/issues.js +111 -0
  50. package/lib/converters/bitbucket/pipeline_steps.d.ts +10 -0
  51. package/lib/converters/bitbucket/pipeline_steps.js +83 -0
  52. package/lib/converters/bitbucket/pipelines.d.ts +8 -0
  53. package/lib/converters/bitbucket/pipelines.js +90 -0
  54. package/lib/converters/bitbucket/pull_request_activities.d.ts +13 -0
  55. package/lib/converters/bitbucket/pull_request_activities.js +112 -0
  56. package/lib/converters/bitbucket/pull_requests.d.ts +10 -0
  57. package/lib/converters/bitbucket/pull_requests.js +95 -0
  58. package/lib/converters/bitbucket/repositories.d.ts +9 -0
  59. package/lib/converters/bitbucket/repositories.js +41 -0
  60. package/lib/converters/bitbucket/types.d.ts +667 -0
  61. package/lib/converters/bitbucket/types.js +2 -0
  62. package/lib/converters/bitbucket/workspace_users.d.ts +7 -0
  63. package/lib/converters/bitbucket/workspace_users.js +31 -0
  64. package/lib/converters/bitbucket/workspaces.d.ts +8 -0
  65. package/lib/converters/bitbucket/workspaces.js +61 -0
  66. package/lib/converters/converter-registry.d.ts +25 -0
  67. package/lib/converters/converter-registry.js +64 -0
  68. package/lib/converters/converter.d.ts +63 -0
  69. package/lib/converters/converter.js +122 -0
  70. package/lib/converters/datadog/common.d.ts +27 -0
  71. package/lib/converters/datadog/common.js +34 -0
  72. package/lib/converters/datadog/incidents.d.ts +9 -0
  73. package/lib/converters/datadog/incidents.js +128 -0
  74. package/lib/converters/datadog/users.d.ts +7 -0
  75. package/lib/converters/datadog/users.js +27 -0
  76. package/lib/converters/docker/common.d.ts +87 -0
  77. package/lib/converters/docker/common.js +76 -0
  78. package/lib/converters/docker/tags.d.ts +8 -0
  79. package/lib/converters/docker/tags.js +98 -0
  80. package/lib/converters/github/assignees.d.ts +7 -0
  81. package/lib/converters/github/assignees.js +16 -0
  82. package/lib/converters/github/branches.d.ts +7 -0
  83. package/lib/converters/github/branches.js +28 -0
  84. package/lib/converters/github/collaborators.d.ts +7 -0
  85. package/lib/converters/github/collaborators.js +19 -0
  86. package/lib/converters/github/commits.d.ts +7 -0
  87. package/lib/converters/github/commits.js +48 -0
  88. package/lib/converters/github/common.d.ts +37 -0
  89. package/lib/converters/github/common.js +130 -0
  90. package/lib/converters/github/issue_labels.d.ts +7 -0
  91. package/lib/converters/github/issue_labels.js +20 -0
  92. package/lib/converters/github/issue_milestones.d.ts +8 -0
  93. package/lib/converters/github/issue_milestones.js +42 -0
  94. package/lib/converters/github/issues.d.ts +9 -0
  95. package/lib/converters/github/issues.js +90 -0
  96. package/lib/converters/github/organizations.d.ts +7 -0
  97. package/lib/converters/github/organizations.js +37 -0
  98. package/lib/converters/github/projects.d.ts +7 -0
  99. package/lib/converters/github/projects.js +21 -0
  100. package/lib/converters/github/pull_request_stats.d.ts +7 -0
  101. package/lib/converters/github/pull_request_stats.js +43 -0
  102. package/lib/converters/github/pull_requests.d.ts +7 -0
  103. package/lib/converters/github/pull_requests.js +63 -0
  104. package/lib/converters/github/releases.d.ts +7 -0
  105. package/lib/converters/github/releases.js +51 -0
  106. package/lib/converters/github/repositories.d.ts +7 -0
  107. package/lib/converters/github/repositories.js +44 -0
  108. package/lib/converters/github/review_comments.d.ts +7 -0
  109. package/lib/converters/github/review_comments.js +39 -0
  110. package/lib/converters/github/reviews.d.ts +7 -0
  111. package/lib/converters/github/reviews.js +58 -0
  112. package/lib/converters/github/tags.d.ts +7 -0
  113. package/lib/converters/github/tags.js +31 -0
  114. package/lib/converters/github/users.d.ts +7 -0
  115. package/lib/converters/github/users.js +19 -0
  116. package/lib/converters/gitlab/branches.d.ts +8 -0
  117. package/lib/converters/gitlab/branches.js +44 -0
  118. package/lib/converters/gitlab/commits.d.ts +7 -0
  119. package/lib/converters/gitlab/commits.js +33 -0
  120. package/lib/converters/gitlab/common.d.ts +30 -0
  121. package/lib/converters/gitlab/common.js +70 -0
  122. package/lib/converters/gitlab/group_labels.d.ts +7 -0
  123. package/lib/converters/gitlab/group_labels.js +15 -0
  124. package/lib/converters/gitlab/group_milestones.d.ts +8 -0
  125. package/lib/converters/gitlab/group_milestones.js +41 -0
  126. package/lib/converters/gitlab/groups.d.ts +7 -0
  127. package/lib/converters/gitlab/groups.js +43 -0
  128. package/lib/converters/gitlab/issues.d.ts +10 -0
  129. package/lib/converters/gitlab/issues.js +79 -0
  130. package/lib/converters/gitlab/jobs.d.ts +11 -0
  131. package/lib/converters/gitlab/jobs.js +75 -0
  132. package/lib/converters/gitlab/merge_request_commits.d.ts +7 -0
  133. package/lib/converters/gitlab/merge_request_commits.js +34 -0
  134. package/lib/converters/gitlab/merge_requests.d.ts +10 -0
  135. package/lib/converters/gitlab/merge_requests.js +65 -0
  136. package/lib/converters/gitlab/pipelines.d.ts +7 -0
  137. package/lib/converters/gitlab/pipelines.js +41 -0
  138. package/lib/converters/gitlab/project_labels.d.ts +7 -0
  139. package/lib/converters/gitlab/project_labels.js +15 -0
  140. package/lib/converters/gitlab/project_milestones.d.ts +8 -0
  141. package/lib/converters/gitlab/project_milestones.js +41 -0
  142. package/lib/converters/gitlab/projects.d.ts +7 -0
  143. package/lib/converters/gitlab/projects.js +51 -0
  144. package/lib/converters/gitlab/releases.d.ts +10 -0
  145. package/lib/converters/gitlab/releases.js +68 -0
  146. package/lib/converters/gitlab/tags.d.ts +10 -0
  147. package/lib/converters/gitlab/tags.js +41 -0
  148. package/lib/converters/gitlab/users.d.ts +7 -0
  149. package/lib/converters/gitlab/users.js +33 -0
  150. package/lib/converters/googlecalendar/calendar_models.d.ts +618 -0
  151. package/lib/converters/googlecalendar/calendar_models.js +2 -0
  152. package/lib/converters/googlecalendar/calendars.d.ts +7 -0
  153. package/lib/converters/googlecalendar/calendars.js +29 -0
  154. package/lib/converters/googlecalendar/common.d.ts +52 -0
  155. package/lib/converters/googlecalendar/common.js +130 -0
  156. package/lib/converters/googlecalendar/events.d.ts +8 -0
  157. package/lib/converters/googlecalendar/events.js +117 -0
  158. package/lib/converters/harness/common.d.ts +105 -0
  159. package/lib/converters/harness/common.js +16 -0
  160. package/lib/converters/harness/executions.d.ts +15 -0
  161. package/lib/converters/harness/executions.js +245 -0
  162. package/lib/converters/jenkins/builds.d.ts +9 -0
  163. package/lib/converters/jenkins/builds.js +74 -0
  164. package/lib/converters/jenkins/common.d.ts +25 -0
  165. package/lib/converters/jenkins/common.js +54 -0
  166. package/lib/converters/jenkins/jobs.d.ts +8 -0
  167. package/lib/converters/jenkins/jobs.js +29 -0
  168. package/lib/converters/jira/board_issues.d.ts +7 -0
  169. package/lib/converters/jira/board_issues.js +28 -0
  170. package/lib/converters/jira/boards.d.ts +7 -0
  171. package/lib/converters/jira/boards.js +34 -0
  172. package/lib/converters/jira/common.d.ts +61 -0
  173. package/lib/converters/jira/common.js +64 -0
  174. package/lib/converters/jira/epics.d.ts +8 -0
  175. package/lib/converters/jira/epics.js +45 -0
  176. package/lib/converters/jira/issue_fields.d.ts +7 -0
  177. package/lib/converters/jira/issue_fields.js +15 -0
  178. package/lib/converters/jira/issues.d.ts +52 -0
  179. package/lib/converters/jira/issues.js +545 -0
  180. package/lib/converters/jira/project_versions.d.ts +9 -0
  181. package/lib/converters/jira/project_versions.js +48 -0
  182. package/lib/converters/jira/projects.d.ts +7 -0
  183. package/lib/converters/jira/projects.js +40 -0
  184. package/lib/converters/jira/pull_requests.d.ts +7 -0
  185. package/lib/converters/jira/pull_requests.js +15 -0
  186. package/lib/converters/jira/sprint_issues.d.ts +7 -0
  187. package/lib/converters/jira/sprint_issues.js +15 -0
  188. package/lib/converters/jira/sprints.d.ts +16 -0
  189. package/lib/converters/jira/sprints.js +80 -0
  190. package/lib/converters/jira/users.d.ts +8 -0
  191. package/lib/converters/jira/users.js +33 -0
  192. package/lib/converters/jira/workflow_statuses.d.ts +7 -0
  193. package/lib/converters/jira/workflow_statuses.js +15 -0
  194. package/lib/converters/jsonata.d.ts +17 -0
  195. package/lib/converters/jsonata.js +47 -0
  196. package/lib/converters/okta/common.d.ts +8 -0
  197. package/lib/converters/okta/common.js +17 -0
  198. package/lib/converters/okta/groups.d.ts +7 -0
  199. package/lib/converters/okta/groups.js +47 -0
  200. package/lib/converters/okta/models.d.ts +102 -0
  201. package/lib/converters/okta/models.js +2 -0
  202. package/lib/converters/okta/users.d.ts +8 -0
  203. package/lib/converters/okta/users.js +73 -0
  204. package/lib/converters/okta_faros/common.d.ts +4 -0
  205. package/lib/converters/okta_faros/common.js +11 -0
  206. package/lib/converters/okta_faros/groups.d.ts +13 -0
  207. package/lib/converters/okta_faros/groups.js +23 -0
  208. package/lib/converters/okta_faros/users.d.ts +13 -0
  209. package/lib/converters/okta_faros/users.js +23 -0
  210. package/lib/converters/pagerduty/common.d.ts +37 -0
  211. package/lib/converters/pagerduty/common.js +40 -0
  212. package/lib/converters/pagerduty/incident_log_entries.d.ts +8 -0
  213. package/lib/converters/pagerduty/incident_log_entries.js +56 -0
  214. package/lib/converters/pagerduty/incidents.d.ts +10 -0
  215. package/lib/converters/pagerduty/incidents.js +127 -0
  216. package/lib/converters/pagerduty/priorities_resource.d.ts +11 -0
  217. package/lib/converters/pagerduty/priorities_resource.js +64 -0
  218. package/lib/converters/pagerduty/users.d.ts +7 -0
  219. package/lib/converters/pagerduty/users.js +26 -0
  220. package/lib/converters/phabricator/commits.d.ts +8 -0
  221. package/lib/converters/phabricator/commits.js +75 -0
  222. package/lib/converters/phabricator/common.d.ts +40 -0
  223. package/lib/converters/phabricator/common.js +107 -0
  224. package/lib/converters/phabricator/repositories.d.ts +7 -0
  225. package/lib/converters/phabricator/repositories.js +56 -0
  226. package/lib/converters/phabricator/revisions.d.ts +7 -0
  227. package/lib/converters/phabricator/revisions.js +83 -0
  228. package/lib/converters/phabricator/users.d.ts +7 -0
  229. package/lib/converters/phabricator/users.js +39 -0
  230. package/lib/converters/shortcut/common.d.ts +16 -0
  231. package/lib/converters/shortcut/common.js +68 -0
  232. package/lib/converters/shortcut/epics.d.ts +7 -0
  233. package/lib/converters/shortcut/epics.js +29 -0
  234. package/lib/converters/shortcut/iterations.d.ts +7 -0
  235. package/lib/converters/shortcut/iterations.js +29 -0
  236. package/lib/converters/shortcut/members.d.ts +7 -0
  237. package/lib/converters/shortcut/members.js +26 -0
  238. package/lib/converters/shortcut/models.d.ts +392 -0
  239. package/lib/converters/shortcut/models.js +30 -0
  240. package/lib/converters/shortcut/projects.d.ts +7 -0
  241. package/lib/converters/shortcut/projects.js +46 -0
  242. package/lib/converters/shortcut/stories.d.ts +7 -0
  243. package/lib/converters/shortcut/stories.js +127 -0
  244. package/lib/converters/squadcast/common.d.ts +169 -0
  245. package/lib/converters/squadcast/common.js +62 -0
  246. package/lib/converters/squadcast/events.d.ts +9 -0
  247. package/lib/converters/squadcast/events.js +53 -0
  248. package/lib/converters/squadcast/incidents.d.ts +10 -0
  249. package/lib/converters/squadcast/incidents.js +141 -0
  250. package/lib/converters/squadcast/services.d.ts +7 -0
  251. package/lib/converters/squadcast/services.js +28 -0
  252. package/lib/converters/squadcast/users.d.ts +7 -0
  253. package/lib/converters/squadcast/users.js +27 -0
  254. package/lib/converters/statuspage/common.d.ts +93 -0
  255. package/lib/converters/statuspage/common.js +80 -0
  256. package/lib/converters/statuspage/incident_updates.d.ts +8 -0
  257. package/lib/converters/statuspage/incident_updates.js +45 -0
  258. package/lib/converters/statuspage/incidents.d.ts +10 -0
  259. package/lib/converters/statuspage/incidents.js +128 -0
  260. package/lib/converters/statuspage/users.d.ts +7 -0
  261. package/lib/converters/statuspage/users.js +26 -0
  262. package/lib/converters/victorops/common.d.ts +16 -0
  263. package/lib/converters/victorops/common.js +24 -0
  264. package/lib/converters/victorops/incidents.d.ts +12 -0
  265. package/lib/converters/victorops/incidents.js +209 -0
  266. package/lib/converters/victorops/teams.d.ts +8 -0
  267. package/lib/converters/victorops/teams.js +30 -0
  268. package/lib/converters/victorops/users.d.ts +8 -0
  269. package/lib/converters/victorops/users.js +33 -0
  270. package/lib/destination-runner.d.ts +12 -0
  271. package/lib/destination-runner.js +22 -0
  272. package/lib/destination.d.ts +42 -0
  273. package/lib/destination.js +508 -0
  274. package/lib/index.d.ts +16 -0
  275. package/lib/index.js +39 -0
  276. package/lib/tsconfig.tsbuildinfo +1 -0
  277. package/package.json +71 -0
  278. package/resources/fetch-primary-keys.sql +16 -0
  279. package/resources/introspection-query.gql +61 -0
  280. package/resources/spec.json +468 -0
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkspaceUsers = void 0;
4
+ const common_1 = require("./common");
5
+ class WorkspaceUsers extends common_1.BitbucketConverter {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.destinationModels = [
9
+ 'vcs_User',
10
+ 'vcs_Membership',
11
+ ];
12
+ }
13
+ async convert(record, ctx) {
14
+ const source = this.streamName.source;
15
+ const workspaceUser = record.record.data;
16
+ const res = [];
17
+ const user = common_1.BitbucketCommon.vcsUser(workspaceUser.user, source);
18
+ if (!user)
19
+ return res;
20
+ res.push(user);
21
+ res.push({
22
+ model: 'vcs_Membership',
23
+ record: {
24
+ user: { uid: workspaceUser.user.accountId, source },
25
+ organization: { uid: workspaceUser.workspace.slug.toLowerCase(), source },
26
+ },
27
+ });
28
+ return res;
29
+ }
30
+ }
31
+ exports.WorkspaceUsers = WorkspaceUsers;
@@ -0,0 +1,8 @@
1
+ import { AirbyteRecord } from 'faros-airbyte-cdk';
2
+ import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
3
+ import { BitbucketConverter } from './common';
4
+ export declare class Workspaces extends BitbucketConverter {
5
+ readonly destinationModels: ReadonlyArray<DestinationModel>;
6
+ convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
7
+ private VCSOrgType;
8
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Workspaces = void 0;
4
+ const faros_feeds_sdk_1 = require("faros-feeds-sdk");
5
+ const common_1 = require("./common");
6
+ var OrgTypeCategory;
7
+ (function (OrgTypeCategory) {
8
+ OrgTypeCategory["ORGANIZATION"] = "Organization";
9
+ OrgTypeCategory["WORKSPACE"] = "Workspace";
10
+ OrgTypeCategory["GROUP"] = "Group";
11
+ OrgTypeCategory["CUSTOM"] = "Custom";
12
+ })(OrgTypeCategory || (OrgTypeCategory = {}));
13
+ class Workspaces extends common_1.BitbucketConverter {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.destinationModels = [
17
+ 'cicd_Organization',
18
+ 'vcs_Organization',
19
+ ];
20
+ }
21
+ async convert(record, ctx) {
22
+ const source = this.streamName.source;
23
+ const workspace = record.record.data;
24
+ return [
25
+ {
26
+ model: 'cicd_Organization',
27
+ record: {
28
+ uid: workspace.slug.toLowerCase(),
29
+ name: workspace.name,
30
+ url: workspace.links.htmlUrl,
31
+ source,
32
+ },
33
+ },
34
+ {
35
+ model: 'vcs_Organization',
36
+ record: {
37
+ uid: workspace.slug.toLowerCase(),
38
+ name: workspace.name,
39
+ type: this.VCSOrgType(workspace.type),
40
+ htmlUrl: workspace.links.htmlUrl,
41
+ createdAt: faros_feeds_sdk_1.Utils.toDate(workspace.createdOn),
42
+ source,
43
+ },
44
+ },
45
+ ];
46
+ }
47
+ VCSOrgType(type) {
48
+ const detail = type === null || type === void 0 ? void 0 : type.toLowerCase();
49
+ if (detail === 'organization') {
50
+ return { category: OrgTypeCategory.ORGANIZATION, detail };
51
+ }
52
+ else if (detail === 'workspace') {
53
+ return { category: OrgTypeCategory.WORKSPACE, detail };
54
+ }
55
+ else if (detail === 'group') {
56
+ return { category: OrgTypeCategory.GROUP, detail };
57
+ }
58
+ return { category: OrgTypeCategory.CUSTOM, detail };
59
+ }
60
+ }
61
+ exports.Workspaces = Workspaces;
@@ -0,0 +1,25 @@
1
+ import { Converter, StreamName } from './converter';
2
+ /**
3
+ * A handy converter registry to get registered converters by stream name
4
+ */
5
+ export declare class ConverterRegistry {
6
+ private static convertersByStream;
7
+ /**
8
+ * Get converter by stream name.
9
+ *
10
+ * Dynamically loads and creates converter by stream.
11
+ *
12
+ * Example: for stream { source: 'github', name: 'pull_request_stats' }
13
+ * we dynamically import module './github/pull_request_stats'
14
+ * and create a class GithubPullRequestStats.
15
+ *
16
+ * @param streamName stream name
17
+ * @param onLoadError handler to call on converter loading error
18
+ * @returns converter if any
19
+ */
20
+ static getConverter(streamName: StreamName, onLoadError?: (err: Error) => void): Converter | undefined;
21
+ /**
22
+ * Add a convertor to the registory.
23
+ */
24
+ static addConverter(converter: Converter): void;
25
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConverterRegistry = void 0;
4
+ const lodash_1 = require("lodash");
5
+ const verror_1 = require("verror");
6
+ /**
7
+ * A handy converter registry to get registered converters by stream name
8
+ */
9
+ class ConverterRegistry {
10
+ /**
11
+ * Get converter by stream name.
12
+ *
13
+ * Dynamically loads and creates converter by stream.
14
+ *
15
+ * Example: for stream { source: 'github', name: 'pull_request_stats' }
16
+ * we dynamically import module './github/pull_request_stats'
17
+ * and create a class GithubPullRequestStats.
18
+ *
19
+ * @param streamName stream name
20
+ * @param onLoadError handler to call on converter loading error
21
+ * @returns converter if any
22
+ */
23
+ static getConverter(streamName, onLoadError) {
24
+ var _a;
25
+ const name = streamName.asString;
26
+ const res = ConverterRegistry.convertersByStream[name];
27
+ if (res && typeof res !== 'boolean')
28
+ return res;
29
+ if (res)
30
+ return undefined;
31
+ try {
32
+ // Load the necessary module dynamically
33
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
34
+ const mod = require(`./${streamName.source}/${streamName.name}`);
35
+ // Create converter instance by name
36
+ const converterClass = mod[(0, lodash_1.upperFirst)((0, lodash_1.camelCase)(streamName.name))];
37
+ if (!converterClass) {
38
+ throw new verror_1.VError(`Could not find converter from module for stream ${name}`);
39
+ }
40
+ const converter = new converterClass();
41
+ // Keep the converter instance in the registry
42
+ ConverterRegistry.convertersByStream[name] = converter;
43
+ return converter;
44
+ }
45
+ catch (e) {
46
+ // Tried loading the converter but failed - no need to retry
47
+ ConverterRegistry.convertersByStream[name] = true;
48
+ if (onLoadError) {
49
+ const err = (_a = e.message) !== null && _a !== void 0 ? _a : String(e);
50
+ onLoadError(new verror_1.VError(`Failed loading converter for stream ${name}: ${err}`));
51
+ }
52
+ return undefined;
53
+ }
54
+ }
55
+ /**
56
+ * Add a convertor to the registory.
57
+ */
58
+ static addConverter(converter) {
59
+ const name = converter.streamName.asString;
60
+ ConverterRegistry.convertersByStream[name] = converter;
61
+ }
62
+ }
63
+ exports.ConverterRegistry = ConverterRegistry;
64
+ ConverterRegistry.convertersByStream = {};
@@ -0,0 +1,63 @@
1
+ import { AirbyteConfig, AirbyteRecord } from 'faros-airbyte-cdk';
2
+ import { FarosClient } from 'faros-feeds-sdk';
3
+ import { Dictionary } from 'ts-essentials';
4
+ /** Airbyte -> Faros record converter */
5
+ export declare abstract class Converter {
6
+ private stream;
7
+ /** Name of the source system that records were fetched from (e.g. GitHub) **/
8
+ abstract readonly source: string;
9
+ /** Input stream supported by converter */
10
+ get streamName(): StreamName;
11
+ get dependencies(): ReadonlyArray<StreamName>;
12
+ /** Function to extract record id */
13
+ abstract id(record: AirbyteRecord): any;
14
+ /** All the record models produced by converter */
15
+ abstract get destinationModels(): ReadonlyArray<DestinationModel>;
16
+ /** Function converts an input Airbyte record to Faros destination canonical record */
17
+ abstract convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
18
+ }
19
+ export declare function parseObjectConfig<T>(obj: any, name: string): T | undefined;
20
+ /** Stream context to store records by stream and other helpers */
21
+ export declare class StreamContext {
22
+ readonly config: AirbyteConfig;
23
+ readonly farosClient?: FarosClient;
24
+ constructor(config: AirbyteConfig, farosClient?: FarosClient);
25
+ private readonly recordsByStreamName;
26
+ getAll(streamName: string): Dictionary<AirbyteRecord>;
27
+ get(streamName: string, id: string): AirbyteRecord | undefined;
28
+ set(streamName: string, id: string, record: AirbyteRecord): void;
29
+ stats(includeIds?: boolean): string;
30
+ }
31
+ export declare const StreamNameSeparator = "__";
32
+ /**
33
+ * Stream name with source prefix, e.g
34
+ * {
35
+ * source: 'github',
36
+ * name: 'commits'
37
+ * }
38
+ */
39
+ export declare class StreamName {
40
+ readonly source: string;
41
+ readonly name: string;
42
+ constructor(source: string, name: string);
43
+ private str;
44
+ get asString(): string;
45
+ static fromString(s: string): StreamName;
46
+ }
47
+ /**
48
+ * Faros record with the destination canonical model, e.g
49
+ * {
50
+ * model: 'identity_Identity',
51
+ * record: {
52
+ * uid: '123',
53
+ * fullName: 'John Doe',
54
+ * primaryEmail: 'john@example.com'
55
+ * }
56
+ * }
57
+ */
58
+ export declare type DestinationRecord = {
59
+ readonly model: DestinationModel;
60
+ readonly record: Dictionary<any>;
61
+ };
62
+ /** Faros destination model name, e.g identity_Identity, vcs_Commit */
63
+ export declare type DestinationModel = string;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.StreamName = exports.StreamNameSeparator = exports.StreamContext = exports.parseObjectConfig = exports.Converter = void 0;
7
+ const lodash_1 = require("lodash");
8
+ const object_sizeof_1 = __importDefault(require("object-sizeof"));
9
+ const verror_1 = require("verror");
10
+ /** Airbyte -> Faros record converter */
11
+ class Converter {
12
+ /** Input stream supported by converter */
13
+ get streamName() {
14
+ if (this.stream)
15
+ return this.stream;
16
+ this.stream = StreamName.fromString(`${this.source}${exports.StreamNameSeparator}${(0, lodash_1.snakeCase)(this.constructor.name)}`);
17
+ return this.stream;
18
+ }
19
+ // Dependencies on other streams (if any).
20
+ // !!! Use with caution !!! Will result in increased memory usage
21
+ // due to accumulation of records in StreamContext (ctx)
22
+ get dependencies() {
23
+ return [];
24
+ }
25
+ }
26
+ exports.Converter = Converter;
27
+ // Helper function for reading object type configurations that
28
+ // may be inputted as proper JSON via API or stringified JSON via Airbyte UI
29
+ function parseObjectConfig(obj, name) {
30
+ if (!obj)
31
+ return undefined;
32
+ if (typeof obj === 'object')
33
+ return obj;
34
+ if (typeof obj === 'string') {
35
+ try {
36
+ return JSON.parse(obj);
37
+ }
38
+ catch (e) {
39
+ throw new verror_1.VError(`Could not parse JSON object from ${name} ${obj}. Error: ${e}`);
40
+ }
41
+ }
42
+ throw new verror_1.VError(`${name} must be a JSON object or stringified JSON object`);
43
+ }
44
+ exports.parseObjectConfig = parseObjectConfig;
45
+ /** Stream context to store records by stream and other helpers */
46
+ class StreamContext {
47
+ constructor(config, farosClient) {
48
+ this.config = config;
49
+ this.farosClient = farosClient;
50
+ this.recordsByStreamName = {};
51
+ }
52
+ getAll(streamName) {
53
+ const recs = this.recordsByStreamName[streamName];
54
+ if (recs) {
55
+ return recs;
56
+ }
57
+ return {};
58
+ }
59
+ get(streamName, id) {
60
+ const recs = this.recordsByStreamName[streamName];
61
+ if (recs) {
62
+ const rec = recs[id];
63
+ if (rec)
64
+ return rec;
65
+ }
66
+ return undefined;
67
+ }
68
+ set(streamName, id, record) {
69
+ const recs = this.recordsByStreamName[streamName];
70
+ if (!recs)
71
+ this.recordsByStreamName[streamName] = {};
72
+ this.recordsByStreamName[streamName][id] = record;
73
+ }
74
+ stats(includeIds = false) {
75
+ const sizeInBytes = (0, object_sizeof_1.default)(this.recordsByStreamName);
76
+ const res = { sizeInBytes };
77
+ for (const s of Object.keys(this.recordsByStreamName)) {
78
+ const ids = Object.keys(this.recordsByStreamName[s]);
79
+ if (includeIds) {
80
+ res[s] = {
81
+ count: ids.length,
82
+ ids,
83
+ };
84
+ }
85
+ else
86
+ res[s] = { count: ids.length };
87
+ }
88
+ return JSON.stringify(res);
89
+ }
90
+ }
91
+ exports.StreamContext = StreamContext;
92
+ exports.StreamNameSeparator = '__';
93
+ /**
94
+ * Stream name with source prefix, e.g
95
+ * {
96
+ * source: 'github',
97
+ * name: 'commits'
98
+ * }
99
+ */
100
+ class StreamName {
101
+ constructor(source, name) {
102
+ this.source = source;
103
+ this.name = name;
104
+ }
105
+ get asString() {
106
+ if (this.str)
107
+ return this.str;
108
+ this.str = `${this.source}${exports.StreamNameSeparator}${this.name}`;
109
+ return this.str;
110
+ }
111
+ static fromString(s) {
112
+ if (!s) {
113
+ throw new verror_1.VError(`Empty stream name ${s}`);
114
+ }
115
+ const res = s.split(exports.StreamNameSeparator);
116
+ if (res.length < 2) {
117
+ throw new verror_1.VError(`Invalid stream name ${s}: missing source prefix (e.g 'github${exports.StreamNameSeparator}')`);
118
+ }
119
+ return new StreamName(res[res.length - 2], res[res.length - 1]);
120
+ }
121
+ }
122
+ exports.StreamName = StreamName;
@@ -0,0 +1,27 @@
1
+ import { AirbyteRecord } from 'faros-airbyte-cdk';
2
+ import { Converter, StreamContext } from '../converter';
3
+ export declare enum IncidentSeverityCategory {
4
+ Sev1 = "Sev1",
5
+ Sev2 = "Sev2",
6
+ Sev3 = "Sev3",
7
+ Sev4 = "Sev4",
8
+ Sev5 = "Sev5",
9
+ Custom = "Custom"
10
+ }
11
+ interface DatadogConfig {
12
+ application_mapping?: ApplicationMapping;
13
+ default_severity?: IncidentSeverityCategory;
14
+ }
15
+ declare type ApplicationMapping = Record<string, {
16
+ name: string;
17
+ platform?: string;
18
+ }>;
19
+ /** Datadog converter base */
20
+ export declare abstract class DatadogConverter extends Converter {
21
+ source: string;
22
+ /** Almost every Datadog record has an id property */
23
+ id(record: AirbyteRecord): any;
24
+ protected applicationMapping(ctx: StreamContext): ApplicationMapping;
25
+ protected config(ctx: StreamContext): DatadogConfig;
26
+ }
27
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DatadogConverter = exports.IncidentSeverityCategory = void 0;
4
+ const converter_1 = require("../converter");
5
+ var IncidentSeverityCategory;
6
+ (function (IncidentSeverityCategory) {
7
+ IncidentSeverityCategory["Sev1"] = "Sev1";
8
+ IncidentSeverityCategory["Sev2"] = "Sev2";
9
+ IncidentSeverityCategory["Sev3"] = "Sev3";
10
+ IncidentSeverityCategory["Sev4"] = "Sev4";
11
+ IncidentSeverityCategory["Sev5"] = "Sev5";
12
+ IncidentSeverityCategory["Custom"] = "Custom";
13
+ })(IncidentSeverityCategory = exports.IncidentSeverityCategory || (exports.IncidentSeverityCategory = {}));
14
+ /** Datadog converter base */
15
+ class DatadogConverter extends converter_1.Converter {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.source = 'Datadog';
19
+ }
20
+ /** Almost every Datadog record has an id property */
21
+ id(record) {
22
+ var _a, _b;
23
+ return (_b = (_a = record === null || record === void 0 ? void 0 : record.record) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.id;
24
+ }
25
+ applicationMapping(ctx) {
26
+ var _a, _b;
27
+ return ((_b = (0, converter_1.parseObjectConfig)((_a = this.config(ctx)) === null || _a === void 0 ? void 0 : _a.application_mapping, 'Application Mapping')) !== null && _b !== void 0 ? _b : {});
28
+ }
29
+ config(ctx) {
30
+ var _a, _b;
31
+ return (_b = (_a = ctx.config.source_specific_configs) === null || _a === void 0 ? void 0 : _a.datadog) !== null && _b !== void 0 ? _b : {};
32
+ }
33
+ }
34
+ exports.DatadogConverter = DatadogConverter;
@@ -0,0 +1,9 @@
1
+ import { AirbyteRecord } from 'faros-airbyte-cdk';
2
+ import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
3
+ import { DatadogConverter } from './common';
4
+ export declare class Incidents extends DatadogConverter {
5
+ readonly destinationModels: ReadonlyArray<DestinationModel>;
6
+ convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
7
+ private getSeverity;
8
+ private getStatus;
9
+ }
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Incidents = void 0;
4
+ const faros_feeds_sdk_1 = require("faros-feeds-sdk");
5
+ const common_1 = require("./common");
6
+ var IncidentStatusCategory;
7
+ (function (IncidentStatusCategory) {
8
+ IncidentStatusCategory["Created"] = "Created";
9
+ IncidentStatusCategory["Identified"] = "Identified";
10
+ IncidentStatusCategory["Investigating"] = "Investigating";
11
+ IncidentStatusCategory["Resolved"] = "Resolved";
12
+ IncidentStatusCategory["Custom"] = "Custom";
13
+ })(IncidentStatusCategory || (IncidentStatusCategory = {}));
14
+ class Incidents extends common_1.DatadogConverter {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.destinationModels = [
18
+ 'ims_Incident',
19
+ 'ims_IncidentAssignment',
20
+ ];
21
+ }
22
+ async convert(record, ctx) {
23
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
24
+ const config = this.config(ctx);
25
+ const source = this.streamName.source;
26
+ const incident = record.record.data;
27
+ const incidentKey = {
28
+ uid: incident.id,
29
+ source,
30
+ };
31
+ const defaultSeverityCategory = config.default_severity;
32
+ const defaultSeverity = defaultSeverityCategory
33
+ ? {
34
+ category: defaultSeverityCategory,
35
+ detail: 'default',
36
+ }
37
+ : null;
38
+ const res = [];
39
+ res.push({
40
+ model: 'ims_Incident',
41
+ record: {
42
+ ...incidentKey,
43
+ title: (_a = incident.attributes) === null || _a === void 0 ? void 0 : _a.title,
44
+ description: (_d = (_c = (_b = incident.attributes) === null || _b === void 0 ? void 0 : _b.fields) === null || _c === void 0 ? void 0 : _c.summary) === null || _d === void 0 ? void 0 : _d.value,
45
+ url: null,
46
+ severity: (_h = this.getSeverity((_g = (_f = (_e = incident.attributes) === null || _e === void 0 ? void 0 : _e.fields) === null || _f === void 0 ? void 0 : _f.severity) === null || _g === void 0 ? void 0 : _g.value)) !== null && _h !== void 0 ? _h : defaultSeverity,
47
+ priority: null,
48
+ status: (_m = this.getStatus((_l = (_k = (_j = incident.attributes) === null || _j === void 0 ? void 0 : _j.fields) === null || _k === void 0 ? void 0 : _k.state) === null || _l === void 0 ? void 0 : _l.value)) !== null && _m !== void 0 ? _m : null,
49
+ createdAt: (_p = faros_feeds_sdk_1.Utils.toDate((_o = incident.attributes) === null || _o === void 0 ? void 0 : _o.created)) !== null && _p !== void 0 ? _p : null,
50
+ updatedAt: (_r = faros_feeds_sdk_1.Utils.toDate((_q = incident.attributes) === null || _q === void 0 ? void 0 : _q.modified)) !== null && _r !== void 0 ? _r : null,
51
+ resolvedAt: (_t = faros_feeds_sdk_1.Utils.toDate((_s = incident.attributes) === null || _s === void 0 ? void 0 : _s.resolved)) !== null && _t !== void 0 ? _t : null,
52
+ },
53
+ });
54
+ const assigneeUid = (_w = (_v = (_u = incident.relationships) === null || _u === void 0 ? void 0 : _u.commanderUser) === null || _v === void 0 ? void 0 : _v.data) === null || _w === void 0 ? void 0 : _w.id;
55
+ if (assigneeUid) {
56
+ res.push({
57
+ model: 'ims_IncidentAssignment',
58
+ record: {
59
+ incident: incidentKey,
60
+ assignee: {
61
+ uid: assigneeUid,
62
+ source,
63
+ },
64
+ },
65
+ });
66
+ }
67
+ const applicationMapping = this.applicationMapping(ctx);
68
+ const services = (_z = (_y = (_x = incident.attributes) === null || _x === void 0 ? void 0 : _x.fields) === null || _y === void 0 ? void 0 : _y.services) === null || _z === void 0 ? void 0 : _z.value;
69
+ if (services) {
70
+ for (const service of services) {
71
+ if ((_0 = applicationMapping === null || applicationMapping === void 0 ? void 0 : applicationMapping[service]) === null || _0 === void 0 ? void 0 : _0.name) {
72
+ const mappedApp = applicationMapping[service];
73
+ const application = {
74
+ name: mappedApp.name,
75
+ platform: (_1 = mappedApp.platform) !== null && _1 !== void 0 ? _1 : '',
76
+ };
77
+ res.push({ model: 'compute_Application', record: application });
78
+ res.push({
79
+ model: 'ims_IncidentApplicationImpact',
80
+ record: {
81
+ incident: incidentKey,
82
+ application,
83
+ },
84
+ });
85
+ }
86
+ }
87
+ }
88
+ return res;
89
+ }
90
+ getSeverity(severity) {
91
+ if (severity) {
92
+ switch (severity) {
93
+ case 'SEV-1':
94
+ return { category: common_1.IncidentSeverityCategory.Sev1, detail: severity };
95
+ case 'SEV-2':
96
+ return { category: common_1.IncidentSeverityCategory.Sev2, detail: severity };
97
+ case 'SEV-3':
98
+ return { category: common_1.IncidentSeverityCategory.Sev3, detail: severity };
99
+ case 'SEV-4':
100
+ return { category: common_1.IncidentSeverityCategory.Sev4, detail: severity };
101
+ case 'SEV-5':
102
+ return { category: common_1.IncidentSeverityCategory.Sev5, detail: severity };
103
+ default:
104
+ return { category: common_1.IncidentSeverityCategory.Custom, detail: severity };
105
+ }
106
+ }
107
+ }
108
+ getStatus(state) {
109
+ if (state) {
110
+ switch (state) {
111
+ case 'declared':
112
+ return { category: IncidentStatusCategory.Created, detail: state };
113
+ case 'active':
114
+ return {
115
+ category: IncidentStatusCategory.Investigating,
116
+ detail: state,
117
+ };
118
+ case 'stable':
119
+ return { category: IncidentStatusCategory.Identified, detail: state };
120
+ case 'resolved':
121
+ return { category: IncidentStatusCategory.Resolved, detail: state };
122
+ default:
123
+ return { category: IncidentStatusCategory.Custom, detail: state };
124
+ }
125
+ }
126
+ }
127
+ }
128
+ exports.Incidents = Incidents;
@@ -0,0 +1,7 @@
1
+ import { AirbyteRecord } from 'faros-airbyte-cdk';
2
+ import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
3
+ import { DatadogConverter } from './common';
4
+ export declare class Users extends DatadogConverter {
5
+ readonly destinationModels: ReadonlyArray<DestinationModel>;
6
+ convert(record: AirbyteRecord, _ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
7
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Users = void 0;
4
+ const common_1 = require("./common");
5
+ class Users extends common_1.DatadogConverter {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.destinationModels = ['ims_User'];
9
+ }
10
+ async convert(record, _ctx) {
11
+ var _a, _b;
12
+ const source = this.streamName.source;
13
+ const user = record.record.data;
14
+ return [
15
+ {
16
+ model: 'ims_User',
17
+ record: {
18
+ uid: user === null || user === void 0 ? void 0 : user.id,
19
+ email: (_a = user === null || user === void 0 ? void 0 : user.attributes) === null || _a === void 0 ? void 0 : _a.email,
20
+ name: (_b = user === null || user === void 0 ? void 0 : user.attributes) === null || _b === void 0 ? void 0 : _b.name,
21
+ source,
22
+ },
23
+ },
24
+ ];
25
+ }
26
+ }
27
+ exports.Users = Users;