airbyte-faros-destination 0.19.53-rc0 → 0.19.53-rc1

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.
@@ -1,8 +1,12 @@
1
1
  import { AirbyteRecord } from 'faros-airbyte-cdk';
2
+ import { OrgKey } from '../common/vcs';
2
3
  import { Converter } from '../converter';
3
4
  export declare const MAX_DESCRIPTION_LENGTH = 1000;
4
5
  /** Azure TFVC converter base */
5
6
  export declare abstract class AzureTfvcConverter extends Converter {
6
7
  source: string;
7
8
  id(record: AirbyteRecord): any;
9
+ private static readonly _uidsFromUsersStream;
10
+ get uidsFromUsersStream(): Set<string>;
11
+ getOrgKey(name: string): OrgKey;
8
12
  }
@@ -13,6 +13,16 @@ class AzureTfvcConverter 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
+ get uidsFromUsersStream() {
17
+ return AzureTfvcConverter._uidsFromUsersStream;
18
+ }
19
+ getOrgKey(name) {
20
+ return { uid: name.toLowerCase(), source: this.source };
21
+ }
16
22
  }
17
23
  exports.AzureTfvcConverter = AzureTfvcConverter;
24
+ // Records from Users stream have more populated fields than user objects from
25
+ // other streams, so prioritize upserting those over partial duplicates from
26
+ // other streams
27
+ AzureTfvcConverter._uidsFromUsersStream = new Set();
18
28
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/converters/azure-tfvc/common.ts"],"names":[],"mappings":";;;AAEA,4CAAuC;AAE1B,QAAA,sBAAsB,GAAG,IAAI,CAAC;AAE3C,gCAAgC;AAChC,MAAsB,kBAAmB,SAAQ,qBAAS;IAA1D;;QACE,WAAM,GAAG,YAAY,CAAC;IAKxB,CAAC;IAHC,EAAE,CAAC,MAAqB;;QACtB,OAAO,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,0CAAE,IAAI,0CAAE,EAAE,CAAC;IAClC,CAAC;CACF;AAND,gDAMC"}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/converters/azure-tfvc/common.ts"],"names":[],"mappings":";;;AAGA,4CAAuC;AAE1B,QAAA,sBAAsB,GAAG,IAAI,CAAC;AAE3C,gCAAgC;AAChC,MAAsB,kBAAmB,SAAQ,qBAAS;IAA1D;;QACE,WAAM,GAAG,YAAY,CAAC;IAiBxB,CAAC;IAfC,EAAE,CAAC,MAAqB;;QACtB,OAAO,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,0CAAE,IAAI,0CAAE,EAAE,CAAC;IAClC,CAAC;IAMD,IAAW,mBAAmB;QAC5B,OAAO,kBAAkB,CAAC,oBAAoB,CAAC;IACjD,CAAC;IAED,SAAS,CAAC,IAAY;QACpB,OAAO,EAAC,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAC,CAAC;IACxD,CAAC;;AAjBH,gDAkBC;AAXC,8EAA8E;AAC9E,4EAA4E;AAC5E,gBAAgB;AACQ,uCAAoB,GAAgB,IAAI,GAAG,EAAE,AAAzB,CAA0B"}
@@ -0,0 +1,7 @@
1
+ import { AirbyteRecord } from 'faros-airbyte-cdk';
2
+ import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
3
+ import { AzureTfvcConverter } from './common';
4
+ export declare class Users extends AzureTfvcConverter {
5
+ readonly destinationModels: ReadonlyArray<DestinationModel>;
6
+ convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
7
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Users = void 0;
4
+ const azure_devops_1 = require("faros-airbyte-common/azure-devops");
5
+ const azure_devops_2 = require("../common/azure-devops");
6
+ const vcs_1 = require("../common/vcs");
7
+ const common_1 = require("./common");
8
+ class Users extends common_1.AzureTfvcConverter {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.destinationModels = [
12
+ 'vcs_Membership',
13
+ 'vcs_User',
14
+ ];
15
+ }
16
+ async convert(record, ctx) {
17
+ var _a, _b, _c;
18
+ const source = this.streamName.source;
19
+ const userItem = record.record.data;
20
+ const uniqueName = (0, azure_devops_1.getUserIdentifier)(userItem);
21
+ if (!uniqueName) {
22
+ return [];
23
+ }
24
+ const url = (_c = (_b = (_a = userItem._links) === null || _a === void 0 ? void 0 : _a.self) === null || _b === void 0 ? void 0 : _b.href) !== null && _c !== void 0 ? _c : userItem.url;
25
+ const organizationName = (0, azure_devops_2.getOrganization)(ctx, url, 1);
26
+ const organization = this.getOrgKey(organizationName);
27
+ const type = {
28
+ category: vcs_1.UserTypeCategory.User,
29
+ detail: 'subjectKind' in userItem ? userItem.subjectKind : null,
30
+ };
31
+ const uid = uniqueName.toLowerCase();
32
+ this.uidsFromUsersStream.add(uid);
33
+ return [
34
+ {
35
+ model: 'vcs_Membership',
36
+ record: {
37
+ organization,
38
+ user: { uid, source },
39
+ },
40
+ },
41
+ {
42
+ model: 'vcs_User',
43
+ record: {
44
+ uid,
45
+ name: userItem.displayName,
46
+ email: 'mailAddress' in userItem ? userItem.mailAddress : undefined,
47
+ type,
48
+ htmlUrl: userItem.url,
49
+ source,
50
+ },
51
+ },
52
+ ];
53
+ }
54
+ }
55
+ exports.Users = Users;
56
+ //# sourceMappingURL=users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.js","sourceRoot":"","sources":["../../../src/converters/azure-tfvc/users.ts"],"names":[],"mappings":";;;AACA,oEAA0E;AAE1E,yDAAuD;AAEvD,uCAA+C;AAE/C,qCAA4C;AAE5C,MAAa,KAAM,SAAQ,2BAAkB;IAA7C;;QACW,sBAAiB,GAAoC;YAC5D,gBAAgB;YAChB,UAAU;SACX,CAAC;IA8CJ,CAAC;IA5CC,KAAK,CA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