airbyte-faros-destination 0.6.20 → 0.6.22

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.
@@ -0,0 +1,10 @@
1
+ import { AirbyteRecord } from 'faros-airbyte-cdk';
2
+ import { Converter } from '../converter';
3
+ export declare abstract class AirtableConverter extends Converter {
4
+ source: string;
5
+ id(record: AirbyteRecord): any;
6
+ static getTeamUid(teamName: string): string | undefined;
7
+ static getBaseId(fqTableId: string): string;
8
+ static getTableName(fqTableName: string): string;
9
+ static digest(input: string): string;
10
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AirtableConverter = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const converter_1 = require("../converter");
6
+ class AirtableConverter extends converter_1.Converter {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.source = 'Airtable';
10
+ }
11
+ id(record) {
12
+ var _a, _b;
13
+ 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._airtable_id;
14
+ }
15
+ static getTeamUid(teamName) {
16
+ if (!teamName) {
17
+ return undefined;
18
+ }
19
+ return AirtableConverter.digest(teamName);
20
+ }
21
+ static getBaseId(fqTableId) {
22
+ // Get the first part of the fully qualified table id, which corresponds to the Airtable base id
23
+ // E.g., appwVNmuUAPCIxzSZ/tblWFFSCLxi0gVtkU -> appwVNmuUAPCIxzSZ
24
+ return fqTableId.split('/')[0];
25
+ }
26
+ static getTableName(fqTableName) {
27
+ // Get the second part of the fully qualified table name, which corresponds to the table name
28
+ // E.g., my_surveys/Survey Responses => Survey Responses
29
+ return fqTableName.split('/')[1];
30
+ }
31
+ static digest(input) {
32
+ return (0, crypto_1.createHash)('sha256').update(input).digest('hex');
33
+ }
34
+ }
35
+ exports.AirtableConverter = AirtableConverter;
36
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/converters/airtable/common.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAGlC,4CAAuC;AAEvC,MAAsB,iBAAkB,SAAQ,qBAAS;IAAzD;;QACE,WAAM,GAAG,UAAU,CAAC;IA6BtB,CAAC;IA3BC,EAAE,CAAC,MAAqB;;QACtB,OAAO,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,0CAAE,IAAI,0CAAE,YAAY,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,QAAgB;QAChC,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,SAAiB;QAChC,gGAAgG;QAChG,iEAAiE;QACjE,OAAO,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,WAAmB;QACrC,6FAA6F;QAC7F,wDAAwD;QACxD,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,KAAa;QACzB,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC;CACF;AA9BD,8CA8BC"}
@@ -0,0 +1,92 @@
1
+ export declare type Survey = {
2
+ uid: string;
3
+ name: string;
4
+ description: string;
5
+ type: SurveyType;
6
+ status: SurveyStatus;
7
+ startedAt: Date;
8
+ endedAt: Date;
9
+ creator?: SurveyUser;
10
+ stats?: SurveyStats;
11
+ source: string;
12
+ };
13
+ export declare type SurveyQuestion = {
14
+ uid: string;
15
+ question?: string;
16
+ description?: string;
17
+ questionCategory: SurveyQuestionCategoryType;
18
+ responseType: SurveyResponseType;
19
+ source: string;
20
+ };
21
+ export declare type SurveyQuestionAssociation = {
22
+ survey: Survey;
23
+ question: SurveyQuestion;
24
+ order: number;
25
+ };
26
+ export declare type SurveyStats = {
27
+ questionCount: number;
28
+ invitationCount: number;
29
+ responseCount: number;
30
+ };
31
+ export declare type SurveyUser = {
32
+ uid: string;
33
+ email: string;
34
+ name: string;
35
+ source: string;
36
+ };
37
+ export declare type SurveyTeam = {
38
+ uid: string;
39
+ name: string;
40
+ description?: string;
41
+ source: string;
42
+ };
43
+ export declare type SurveyType = {
44
+ category: SurveyCategory;
45
+ detail: string;
46
+ };
47
+ export declare enum SurveyCategory {
48
+ ENPS = "ENPS",
49
+ NPS = "NPS",
50
+ Satisfaction = "Satisfaction",
51
+ Custom = "Custom"
52
+ }
53
+ export declare type SurveyStatus = {
54
+ category: SurveyStatusCategory;
55
+ detail: string;
56
+ };
57
+ export declare enum SurveyStatusCategory {
58
+ Completed = "Completed",
59
+ Canceled = "Canceled",
60
+ Planned = "Planned",
61
+ InProgress = "InProgress",
62
+ Custom = "Custom"
63
+ }
64
+ export declare type SurveyQuestionCategoryType = {
65
+ category: SurveyQuestionCategory;
66
+ detail: string;
67
+ };
68
+ export declare enum SurveyQuestionCategory {
69
+ AlignmentAndGoals = "AlignmentAndGoals",
70
+ DeveloperProductivity = "DeveloperProductivity",
71
+ ENPS = "ENPS",
72
+ NPS = "NPS",
73
+ Quality = "Quality",
74
+ Satisfaction = "Satisfaction",
75
+ SpeedAndAgility = "SpeedAndAgility",
76
+ Custom = "Custom"
77
+ }
78
+ export declare type SurveyResponseType = {
79
+ category: SurveyResponseCategory;
80
+ detail: string;
81
+ };
82
+ export declare enum SurveyResponseCategory {
83
+ Binary = "Binary",
84
+ LikertScale = "LikertScale",
85
+ MultipleChoice = "MultipleChoice",
86
+ NumericEntry = "NumericEntry",
87
+ OpenEnded = "OpenEnded",
88
+ RankOrder = "RankOrder",
89
+ Rating = "Rating",
90
+ Custom = "Custom"
91
+ }
92
+ export declare type QuestionCategoryMapping = Record<string, string>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SurveyResponseCategory = exports.SurveyQuestionCategory = exports.SurveyStatusCategory = exports.SurveyCategory = void 0;
4
+ var SurveyCategory;
5
+ (function (SurveyCategory) {
6
+ SurveyCategory["ENPS"] = "ENPS";
7
+ SurveyCategory["NPS"] = "NPS";
8
+ SurveyCategory["Satisfaction"] = "Satisfaction";
9
+ SurveyCategory["Custom"] = "Custom";
10
+ })(SurveyCategory = exports.SurveyCategory || (exports.SurveyCategory = {}));
11
+ var SurveyStatusCategory;
12
+ (function (SurveyStatusCategory) {
13
+ SurveyStatusCategory["Completed"] = "Completed";
14
+ SurveyStatusCategory["Canceled"] = "Canceled";
15
+ SurveyStatusCategory["Planned"] = "Planned";
16
+ SurveyStatusCategory["InProgress"] = "InProgress";
17
+ SurveyStatusCategory["Custom"] = "Custom";
18
+ })(SurveyStatusCategory = exports.SurveyStatusCategory || (exports.SurveyStatusCategory = {}));
19
+ var SurveyQuestionCategory;
20
+ (function (SurveyQuestionCategory) {
21
+ SurveyQuestionCategory["AlignmentAndGoals"] = "AlignmentAndGoals";
22
+ SurveyQuestionCategory["DeveloperProductivity"] = "DeveloperProductivity";
23
+ SurveyQuestionCategory["ENPS"] = "ENPS";
24
+ SurveyQuestionCategory["NPS"] = "NPS";
25
+ SurveyQuestionCategory["Quality"] = "Quality";
26
+ SurveyQuestionCategory["Satisfaction"] = "Satisfaction";
27
+ SurveyQuestionCategory["SpeedAndAgility"] = "SpeedAndAgility";
28
+ SurveyQuestionCategory["Custom"] = "Custom";
29
+ })(SurveyQuestionCategory = exports.SurveyQuestionCategory || (exports.SurveyQuestionCategory = {}));
30
+ var SurveyResponseCategory;
31
+ (function (SurveyResponseCategory) {
32
+ SurveyResponseCategory["Binary"] = "Binary";
33
+ SurveyResponseCategory["LikertScale"] = "LikertScale";
34
+ SurveyResponseCategory["MultipleChoice"] = "MultipleChoice";
35
+ SurveyResponseCategory["NumericEntry"] = "NumericEntry";
36
+ SurveyResponseCategory["OpenEnded"] = "OpenEnded";
37
+ SurveyResponseCategory["RankOrder"] = "RankOrder";
38
+ SurveyResponseCategory["Rating"] = "Rating";
39
+ SurveyResponseCategory["Custom"] = "Custom";
40
+ })(SurveyResponseCategory = exports.SurveyResponseCategory || (exports.SurveyResponseCategory = {}));
41
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/converters/airtable/models.ts"],"names":[],"mappings":";;;AAqDA,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,+BAAa,CAAA;IACb,6BAAW,CAAA;IACX,+CAA6B,CAAA;IAC7B,mCAAiB,CAAA;AACnB,CAAC,EALW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAKzB;AAOD,IAAY,oBAMX;AAND,WAAY,oBAAoB;IAC9B,+CAAuB,CAAA;IACvB,6CAAqB,CAAA;IACrB,2CAAmB,CAAA;IACnB,iDAAyB,CAAA;IACzB,yCAAiB,CAAA;AACnB,CAAC,EANW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAM/B;AAOD,IAAY,sBASX;AATD,WAAY,sBAAsB;IAChC,iEAAuC,CAAA;IACvC,yEAA+C,CAAA;IAC/C,uCAAa,CAAA;IACb,qCAAW,CAAA;IACX,6CAAmB,CAAA;IACnB,uDAA6B,CAAA;IAC7B,6DAAmC,CAAA;IACnC,2CAAiB,CAAA;AACnB,CAAC,EATW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QASjC;AAOD,IAAY,sBASX;AATD,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,qDAA2B,CAAA;IAC3B,2DAAiC,CAAA;IACjC,uDAA6B,CAAA;IAC7B,iDAAuB,CAAA;IACvB,iDAAuB,CAAA;IACvB,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;AACnB,CAAC,EATW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QASjC"}
@@ -0,0 +1,57 @@
1
+ import { AirbyteRecord } from 'faros-airbyte-cdk';
2
+ import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
3
+ import { AirtableConverter } from './common';
4
+ import { QuestionCategoryMapping } from './models';
5
+ declare type ColumnNameMapping = {
6
+ survey_name_column_name?: string;
7
+ survey_type_column_name?: string;
8
+ survey_description_column_name?: string;
9
+ survey_started_at_column_name?: string;
10
+ survey_ended_at_column_name?: string;
11
+ survey_status_column_name?: string;
12
+ respondent_name_column_name?: string;
13
+ respondent_email_column_name?: string;
14
+ respondent_team_name_column_name?: string;
15
+ respondent_team_id_column_name?: string;
16
+ question_category_column_name?: string;
17
+ response_type_column_name?: string;
18
+ question_column_name?: string;
19
+ };
20
+ export interface SurveysConfig {
21
+ survey_responses_table_name?: string;
22
+ survey_metadata_table_name?: string;
23
+ question_metadata_table_name?: string;
24
+ question_category_mapping?: QuestionCategoryMapping;
25
+ column_names_mapping?: ColumnNameMapping;
26
+ }
27
+ export declare class Surveys extends AirtableConverter {
28
+ readonly destinationModels: ReadonlyArray<DestinationModel>;
29
+ private questionMetadata;
30
+ private surveyMetadata;
31
+ private surveyStats;
32
+ private usersSeen;
33
+ private teamsSeen;
34
+ private surveysSeen;
35
+ private questionsSeen;
36
+ private _config;
37
+ private _questionCategoryMapping;
38
+ private initialize;
39
+ private get config();
40
+ private get questionCategoryMapping();
41
+ convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
42
+ private processQuestionMetadata;
43
+ private processSurveyMetadata;
44
+ private processResponse;
45
+ /** Upsert surveys to add stats and survey questions records to include metadata (question category and response type) **/
46
+ onProcessingComplete(ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
47
+ private getQuestionWithMetadata;
48
+ private getResponseRecords;
49
+ private getSurveyRecord;
50
+ private updateSurveyStats;
51
+ private getFilteredQuestions;
52
+ private getSurveyData;
53
+ private getSurveyUser;
54
+ private getSurveyTeam;
55
+ static createQuestionUid(surveyId: string, question: string): string;
56
+ }
57
+ export {};
@@ -0,0 +1,346 @@
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.Surveys = void 0;
7
+ const faros_airbyte_cdk_1 = require("faros-airbyte-cdk");
8
+ const faros_js_client_1 = require("faros-js-client");
9
+ const lodash_1 = __importDefault(require("lodash"));
10
+ const converter_1 = require("../converter");
11
+ const common_1 = require("./common");
12
+ const models_1 = require("./models");
13
+ class Surveys extends common_1.AirtableConverter {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.destinationModels = [
17
+ 'survey_Survey',
18
+ 'survey_Question',
19
+ 'survey_SurveyQuestionAssociation',
20
+ 'survey_QuestionResponse',
21
+ 'survey_User',
22
+ 'survey_Team',
23
+ 'survey_TeamMembership',
24
+ ];
25
+ this.questionMetadata = new Map();
26
+ this.surveyMetadata = new Map();
27
+ this.surveyStats = new Map();
28
+ this.usersSeen = new Set();
29
+ this.teamsSeen = new Set();
30
+ this.surveysSeen = new Set();
31
+ this.questionsSeen = new Set();
32
+ this._config = undefined;
33
+ this._questionCategoryMapping = undefined;
34
+ }
35
+ initialize(ctx) {
36
+ var _a, _b, _c, _d, _e, _f;
37
+ this._config =
38
+ (_c = (_a = this._config) !== null && _a !== void 0 ? _a : (_b = ctx.config.source_specific_configs) === null || _b === void 0 ? void 0 : _b.surveys) !== null && _c !== void 0 ? _c : {};
39
+ this._questionCategoryMapping =
40
+ (_f = (_d = this._questionCategoryMapping) !== null && _d !== void 0 ? _d : (0, converter_1.parseObjectConfig)((_e = this._config) === null || _e === void 0 ? void 0 : _e.question_category_mapping, 'Question Category Mapping')) !== null && _f !== void 0 ? _f : {};
41
+ }
42
+ get config() {
43
+ return this._config;
44
+ }
45
+ get questionCategoryMapping() {
46
+ return this._questionCategoryMapping;
47
+ }
48
+ async convert(record, ctx) {
49
+ var _a, _b, _c, _d, _e, _f, _g, _h;
50
+ this.initialize(ctx);
51
+ const row = (_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.row;
52
+ const fqTableId = (_d = (_c = record === null || record === void 0 ? void 0 : record.record) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d._airtable_table_id;
53
+ const fqTableName = (_f = (_e = record === null || record === void 0 ? void 0 : record.record) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f._airtable_table_name;
54
+ if (!row || !fqTableId || !fqTableName) {
55
+ return [];
56
+ }
57
+ const surveyId = Surveys.getBaseId(fqTableId);
58
+ const tableName = Surveys.getTableName(fqTableName);
59
+ // Be a bit more lenient with table names matching
60
+ const normalizeTableName = (tableName) => {
61
+ return tableName.toLowerCase().split(' ').join('_');
62
+ };
63
+ // Question metadata
64
+ if (normalizeTableName(tableName) ===
65
+ normalizeTableName(this.config.question_metadata_table_name)) {
66
+ this.processQuestionMetadata(surveyId, row);
67
+ return [];
68
+ }
69
+ // Survey metadata
70
+ if (normalizeTableName(tableName) ===
71
+ normalizeTableName(this.config.survey_metadata_table_name)) {
72
+ this.processSurveyMetadata(surveyId, row);
73
+ return [];
74
+ }
75
+ // Survey response
76
+ if (normalizeTableName(tableName) ===
77
+ normalizeTableName(this.config.survey_responses_table_name)) {
78
+ const responseId = this.id(record);
79
+ const submittedAt = (_h = (_g = record === null || record === void 0 ? void 0 : record.record) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h._airtable_created_time;
80
+ const questions = this.getFilteredQuestions(row);
81
+ const res = this.processResponse(surveyId, row, responseId, submittedAt, questions);
82
+ // Update survey stats for pushing on processing complete
83
+ this.updateSurveyStats(surveyId, questions);
84
+ return res;
85
+ }
86
+ return [];
87
+ }
88
+ processQuestionMetadata(surveyId, row) {
89
+ const questionWithMetadata = this.getQuestionWithMetadata(surveyId, row);
90
+ if (!questionWithMetadata) {
91
+ return;
92
+ }
93
+ this.questionMetadata.set(questionWithMetadata.uid, questionWithMetadata);
94
+ }
95
+ processSurveyMetadata(surveyId, row) {
96
+ const surveyRecord = this.getSurveyRecord(surveyId, row);
97
+ this.surveyMetadata.set(surveyRecord.uid, surveyRecord);
98
+ }
99
+ processResponse(surveyId, row, responseId, submittedAt, questions) {
100
+ const res = [];
101
+ const surveyUser = this.getSurveyUser(row);
102
+ const surveyTeam = this.getSurveyTeam(row);
103
+ if (surveyUser && !this.usersSeen.has(surveyUser.uid)) {
104
+ this.usersSeen.add(surveyUser.uid);
105
+ res.push({
106
+ model: 'survey_User',
107
+ record: surveyUser,
108
+ });
109
+ }
110
+ if (surveyTeam && !this.teamsSeen.has(surveyTeam.uid)) {
111
+ this.teamsSeen.add(surveyTeam.uid);
112
+ res.push({
113
+ model: 'survey_Team',
114
+ record: surveyTeam,
115
+ });
116
+ }
117
+ if (surveyUser && surveyTeam) {
118
+ res.push({
119
+ model: 'survey_TeamMembership',
120
+ record: {
121
+ member: lodash_1.default.pick(surveyUser, ['uid', 'source']),
122
+ team: lodash_1.default.pick(surveyTeam, ['uid', 'source']),
123
+ },
124
+ });
125
+ }
126
+ res.push(...this.getResponseRecords(surveyId, row, responseId, submittedAt, questions, surveyUser, surveyTeam));
127
+ return res;
128
+ }
129
+ /** Upsert surveys to add stats and survey questions records to include metadata (question category and response type) **/
130
+ async onProcessingComplete(ctx) {
131
+ const updateRecords = [];
132
+ // Add survey questions upsert mutations
133
+ this.questionMetadata.forEach((surveyQuestion) => {
134
+ const questionRecord = {
135
+ model: 'survey_Question__Update',
136
+ record: {
137
+ at: Date.now(),
138
+ where: { uid: surveyQuestion.uid, source: surveyQuestion.source },
139
+ mask: ['questionCategory', 'responseType'],
140
+ patch: {
141
+ questionCategory: surveyQuestion.questionCategory,
142
+ responseType: surveyQuestion.responseType,
143
+ },
144
+ },
145
+ };
146
+ updateRecords.push(questionRecord);
147
+ });
148
+ this.surveyStats.forEach((surveyStats, surveyId) => {
149
+ const surveyRecord = {
150
+ model: 'survey_Survey__Update',
151
+ record: {
152
+ at: Date.now(),
153
+ where: { uid: surveyId, source: this.streamName.source },
154
+ mask: ['stats'],
155
+ patch: {
156
+ stats: surveyStats,
157
+ },
158
+ },
159
+ };
160
+ updateRecords.push(surveyRecord);
161
+ });
162
+ this.surveyMetadata.forEach((survey) => {
163
+ updateRecords.push({
164
+ model: 'survey_Survey__Update',
165
+ record: {
166
+ at: Date.now(),
167
+ where: {
168
+ uid: survey.uid,
169
+ source: this.streamName.source,
170
+ },
171
+ mask: [
172
+ 'name',
173
+ 'description',
174
+ 'type',
175
+ 'status',
176
+ 'startedAt',
177
+ 'endedAt',
178
+ ],
179
+ patch: {
180
+ name: survey.name,
181
+ description: survey.description,
182
+ type: survey.type,
183
+ status: survey.status,
184
+ startedAt: survey.startedAt,
185
+ endedAt: survey.endedAt,
186
+ },
187
+ },
188
+ });
189
+ });
190
+ return updateRecords;
191
+ }
192
+ getQuestionWithMetadata(surveyId, row) {
193
+ const question = row[this.config.column_names_mapping.question_column_name];
194
+ if (!question) {
195
+ return undefined;
196
+ }
197
+ const category = row[this.config.column_names_mapping.question_category_column_name];
198
+ const responseType = row[this.config.column_names_mapping.response_type_column_name];
199
+ return {
200
+ uid: Surveys.createQuestionUid(surveyId, question),
201
+ source: this.source,
202
+ questionCategory: category
203
+ ? faros_js_client_1.Utils.toCategoryDetail(models_1.SurveyQuestionCategory, category, this.questionCategoryMapping)
204
+ : null,
205
+ responseType: responseType
206
+ ? faros_js_client_1.Utils.toCategoryDetail(models_1.SurveyResponseCategory, responseType)
207
+ : null,
208
+ };
209
+ }
210
+ getResponseRecords(surveyId, row, responseId, submittedAt, questions, surveyUser, surveyTeam) {
211
+ return questions.flatMap((question, index) => {
212
+ const surveyRecord = this.getSurveyRecord(surveyId, row);
213
+ const questionId = Surveys.createQuestionUid(surveyId, question);
214
+ const questionRecord = {
215
+ uid: questionId,
216
+ source: this.source,
217
+ question,
218
+ };
219
+ const surveyQuestionAssociationRecord = {
220
+ survey: { uid: surveyId, source: this.source },
221
+ question: { uid: questionRecord.uid, source: this.source },
222
+ order: index + 1,
223
+ };
224
+ const questionResponse = {
225
+ model: 'survey_QuestionResponse',
226
+ record: {
227
+ uid: responseId,
228
+ source: this.source,
229
+ submittedAt,
230
+ response: row[question].toString(),
231
+ surveyQuestion: {
232
+ survey: { uid: surveyId, source: this.source },
233
+ question: { uid: questionRecord.uid, source: this.source },
234
+ },
235
+ respondent: surveyUser
236
+ ? { uid: surveyUser.uid, source: this.source }
237
+ : null,
238
+ team: surveyTeam ? { uid: surveyTeam.uid, source: this.source } : null,
239
+ },
240
+ };
241
+ const res = [questionResponse];
242
+ if (!this.questionsSeen.has(questionRecord.uid)) {
243
+ this.questionsSeen.add(questionRecord.uid);
244
+ res.push(...[
245
+ {
246
+ model: 'survey_Question',
247
+ record: questionRecord,
248
+ },
249
+ {
250
+ model: 'survey_SurveyQuestionAssociation',
251
+ record: surveyQuestionAssociationRecord,
252
+ },
253
+ ]);
254
+ }
255
+ if (!this.surveysSeen.has(surveyId)) {
256
+ this.surveysSeen.add(surveyId);
257
+ res.push({
258
+ model: 'survey_Survey',
259
+ record: surveyRecord,
260
+ });
261
+ }
262
+ return res;
263
+ });
264
+ }
265
+ getSurveyRecord(surveyId, row) {
266
+ const surveyData = this.getSurveyData(row);
267
+ return {
268
+ uid: surveyId,
269
+ source: this.source,
270
+ status: surveyData.status
271
+ ? faros_js_client_1.Utils.toCategoryDetail(models_1.SurveyStatusCategory, surveyData.status)
272
+ : null,
273
+ type: surveyData.type
274
+ ? faros_js_client_1.Utils.toCategoryDetail(models_1.SurveyCategory, surveyData.type)
275
+ : null,
276
+ name: surveyData.name,
277
+ description: surveyData.description,
278
+ startedAt: surveyData.startedAt ? (0, faros_airbyte_cdk_1.toDate)(surveyData.startedAt) : null,
279
+ endedAt: surveyData.endedAt ? (0, faros_airbyte_cdk_1.toDate)(surveyData.endedAt) : null,
280
+ };
281
+ }
282
+ updateSurveyStats(surveyId, questions) {
283
+ const stats = this.surveyStats.get(surveyId) || {
284
+ questionCount: questions.length,
285
+ invitationCount: 0,
286
+ responseCount: 0,
287
+ };
288
+ stats.responseCount += 1;
289
+ this.surveyStats.set(surveyId, stats);
290
+ }
291
+ getFilteredQuestions(row) {
292
+ return Object.keys(row).filter((question) => ![
293
+ this.config.column_names_mapping.survey_name_column_name,
294
+ this.config.column_names_mapping.survey_type_column_name,
295
+ this.config.column_names_mapping.survey_description_column_name,
296
+ this.config.column_names_mapping.survey_started_at_column_name,
297
+ this.config.column_names_mapping.survey_ended_at_column_name,
298
+ this.config.column_names_mapping.survey_status_column_name,
299
+ this.config.column_names_mapping.respondent_name_column_name,
300
+ this.config.column_names_mapping.respondent_email_column_name,
301
+ this.config.column_names_mapping.respondent_team_name_column_name,
302
+ this.config.column_names_mapping.respondent_team_id_column_name,
303
+ ].includes(question));
304
+ }
305
+ getSurveyData(row) {
306
+ var _a, _b, _c, _d, _e, _f;
307
+ return {
308
+ name: (_a = row[this.config.column_names_mapping.survey_name_column_name]) !== null && _a !== void 0 ? _a : null,
309
+ type: (_b = row[this.config.column_names_mapping.survey_type_column_name]) !== null && _b !== void 0 ? _b : null,
310
+ description: (_c = row[this.config.column_names_mapping.survey_description_column_name]) !== null && _c !== void 0 ? _c : null,
311
+ startedAt: (_d = row[this.config.column_names_mapping.survey_started_at_column_name]) !== null && _d !== void 0 ? _d : null,
312
+ endedAt: (_e = row[this.config.column_names_mapping.survey_ended_at_column_name]) !== null && _e !== void 0 ? _e : null,
313
+ status: (_f = row[this.config.column_names_mapping.survey_status_column_name]) !== null && _f !== void 0 ? _f : null,
314
+ };
315
+ }
316
+ getSurveyUser(row) {
317
+ var _a;
318
+ const uid = row[this.config.column_names_mapping.respondent_email_column_name];
319
+ if (!uid) {
320
+ return undefined;
321
+ }
322
+ return {
323
+ uid,
324
+ source: this.source,
325
+ email: uid,
326
+ name: (_a = row[this.config.column_names_mapping.respondent_name_column_name]) !== null && _a !== void 0 ? _a : null,
327
+ };
328
+ }
329
+ getSurveyTeam(row) {
330
+ var _a;
331
+ const uid = (_a = row[this.config.column_names_mapping.respondent_team_id_column_name]) !== null && _a !== void 0 ? _a : Surveys.getTeamUid(row[this.config.column_names_mapping.respondent_team_name_column_name]);
332
+ if (!uid) {
333
+ return undefined;
334
+ }
335
+ return {
336
+ uid,
337
+ source: this.source,
338
+ name: row[this.config.column_names_mapping.respondent_team_name_column_name],
339
+ };
340
+ }
341
+ static createQuestionUid(surveyId, question) {
342
+ return common_1.AirtableConverter.digest(`${surveyId}-${question}`);
343
+ }
344
+ }
345
+ exports.Surveys = Surveys;
346
+ //# sourceMappingURL=surveys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"surveys.js","sourceRoot":"","sources":["../../../src/converters/airtable/surveys.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAwD;AACxD,qDAAsC;AACtC,oDAAuB;AAEvB,4CAKsB;AACtB,qCAA2C;AAC3C,qCAWkB;AA0BlB,MAAa,OAAQ,SAAQ,0BAAiB;IAA9C;;QACW,sBAAiB,GAAoC;YAC5D,eAAe;YACf,iBAAiB;YACjB,kCAAkC;YAClC,yBAAyB;YACzB,aAAa;YACb,aAAa;YACb,uBAAuB;SACxB,CAAC;QAEM,qBAAgB,GAAgC,IAAI,GAAG,EAAE,CAAC;QAC1D,mBAAc,GAAwB,IAAI,GAAG,EAAE,CAAC;QAChD,gBAAW,GAA6B,IAAI,GAAG,EAAE,CAAC;QAElD,cAAS,GAAG,IAAI,GAAG,EAAU,CAAC;QAC9B,cAAS,GAAG,IAAI,GAAG,EAAU,CAAC;QAC9B,gBAAW,GAAG,IAAI,GAAG,EAAU,CAAC;QAChC,kBAAa,GAAG,IAAI,GAAG,EAAU,CAAC;QAElC,YAAO,GAAkB,SAA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E,GAAG,CACP,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,gCAAgC,CAClE;SACF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,QAAgB,EAAE,QAAgB;QACzD,OAAO,0BAAiB,CAAC,MAAM,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF;AA5cD,0BA4cC"}
@@ -1,8 +1,14 @@
1
1
  import { AirbyteRecord } from 'faros-airbyte-cdk';
2
- import { Converter } from '../converter';
2
+ import { Converter, StreamContext } from '../converter';
3
+ interface OctopusConfig {
4
+ vcs_source?: string;
5
+ }
3
6
  /** Octopus converter base */
4
7
  export declare abstract class OctopusConverter extends Converter {
5
8
  source: string;
6
9
  /** Almost every Octopus record have Id property */
7
10
  id(record: AirbyteRecord): any;
11
+ protected octopusConfig(ctx: StreamContext): OctopusConfig;
12
+ protected vcsSource(ctx: StreamContext): string | undefined;
8
13
  }
14
+ export {};
@@ -13,6 +13,14 @@ class OctopusConverter extends converter_1.Converter {
13
13
  var _a, _b;
14
14
  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;
15
15
  }
16
+ octopusConfig(ctx) {
17
+ var _a, _b;
18
+ return (_b = (_a = ctx.config.source_specific_configs) === null || _a === void 0 ? void 0 : _a.octopus) !== null && _b !== void 0 ? _b : {};
19
+ }
20
+ vcsSource(ctx) {
21
+ var _a;
22
+ return (_a = this.octopusConfig(ctx)) === null || _a === void 0 ? void 0 : _a.vcs_source;
23
+ }
16
24
  }
17
25
  exports.OctopusConverter = OctopusConverter;
18
26
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/converters/octopus/common.ts"],"names":[],"mappings":";;;AAEA,4CAAuC;AAEvC,6BAA6B;AAC7B,MAAsB,gBAAiB,SAAQ,qBAAS;IAAxD;;QACE,WAAM,GAAG,SAAS,CAAC;IAKrB,CAAC;IAJC,mDAAmD;IACnD,EAAE,CAAC,MAAqB;;QACtB,OAAO,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,0CAAE,IAAI,0CAAE,EAAE,CAAC;IAClC,CAAC;CACF;AAND,4CAMC"}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/converters/octopus/common.ts"],"names":[],"mappings":";;;AAEA,4CAAsD;AAMtD,6BAA6B;AAC7B,MAAsB,gBAAiB,SAAQ,qBAAS;IAAxD;;QACE,WAAM,GAAG,SAAS,CAAC;IAarB,CAAC;IAZC,mDAAmD;IACnD,EAAE,CAAC,MAAqB;;QACtB,OAAO,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,0CAAE,IAAI,0CAAE,EAAE,CAAC;IAClC,CAAC;IAES,aAAa,CAAC,GAAkB;;QACxC,OAAO,MAAA,MAAA,GAAG,CAAC,MAAM,CAAC,uBAAuB,0CAAE,OAAO,mCAAI,EAAE,CAAC;IAC3D,CAAC;IAES,SAAS,CAAC,GAAkB;;QACpC,OAAO,MAAA,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,0CAAE,UAAU,CAAC;IAC7C,CAAC;CACF;AAdD,4CAcC"}
@@ -4,6 +4,9 @@ import { OctopusConverter } from './common';
4
4
  export declare class Deployments extends OctopusConverter {
5
5
  readonly destinationModels: ReadonlyArray<DestinationModel>;
6
6
  convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
7
+ private getVCSInfo;
8
+ private getRepoInfoFromURL;
9
+ private getVarValue;
7
10
  /**
8
11
  * Octopus task statuses include:
9
12
  * Canceled, Cancelling, Executing, Failed, Queued, Success, TimedOut