@commitspark/git-adapter-github 0.7.0 → 0.8.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 (71) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/{addition.model.js → cjs/addition.model.js} +1 -2
  3. package/dist/cjs/addition.model.js.map +1 -0
  4. package/dist/{container.js → cjs/container.js} +1 -1
  5. package/dist/cjs/container.js.map +1 -0
  6. package/dist/cjs/deletion.model.js.map +1 -0
  7. package/dist/cjs/entries-to-actions-converter.service.js.map +1 -0
  8. package/dist/cjs/entry-factory.service.js.map +1 -0
  9. package/dist/cjs/git-hub-adapter.service.js +154 -0
  10. package/dist/cjs/git-hub-adapter.service.js.map +1 -0
  11. package/dist/cjs/graphql-query-factory.service.js.map +1 -0
  12. package/dist/{index.js → cjs/index.js} +2 -2
  13. package/dist/cjs/index.js.map +1 -0
  14. package/dist/cjs/package.json +1 -0
  15. package/dist/cjs/path-factory.service.js.map +1 -0
  16. package/dist/esm/addition.model.js +9 -0
  17. package/dist/esm/addition.model.js.map +1 -0
  18. package/dist/esm/container.js +17 -0
  19. package/dist/esm/container.js.map +1 -0
  20. package/dist/esm/deletion.model.js +7 -0
  21. package/dist/esm/deletion.model.js.map +1 -0
  22. package/dist/esm/entries-to-actions-converter.service.js +27 -0
  23. package/dist/esm/entries-to-actions-converter.service.js.map +1 -0
  24. package/dist/esm/entry-factory.service.js +21 -0
  25. package/dist/esm/entry-factory.service.js.map +1 -0
  26. package/dist/{git-hub-adapter.service.js → esm/git-hub-adapter.service.js} +16 -16
  27. package/dist/esm/git-hub-adapter.service.js.map +1 -0
  28. package/dist/esm/graphql-query-factory.service.js +85 -0
  29. package/dist/esm/graphql-query-factory.service.js.map +1 -0
  30. package/dist/esm/index.js +6 -0
  31. package/dist/esm/index.js.map +1 -0
  32. package/dist/esm/path-factory.service.js +14 -0
  33. package/dist/esm/path-factory.service.js.map +1 -0
  34. package/dist/tsconfig.build.cjs.tsbuildinfo +1 -0
  35. package/dist/tsconfig.build.esm.tsbuildinfo +1 -0
  36. package/dist/tsconfig.build.types.tsbuildinfo +1 -0
  37. package/dist/{addition.model.d.ts → types/addition.model.d.ts} +1 -0
  38. package/dist/types/addition.model.d.ts.map +1 -0
  39. package/dist/{container.d.ts → types/container.d.ts} +1 -0
  40. package/dist/types/container.d.ts.map +1 -0
  41. package/dist/{deletion.model.d.ts → types/deletion.model.d.ts} +1 -0
  42. package/dist/types/deletion.model.d.ts.map +1 -0
  43. package/dist/{entries-to-actions-converter.service.d.ts → types/entries-to-actions-converter.service.d.ts} +1 -0
  44. package/dist/types/entries-to-actions-converter.service.d.ts.map +1 -0
  45. package/dist/{entry-factory.service.d.ts → types/entry-factory.service.d.ts} +1 -0
  46. package/dist/types/entry-factory.service.d.ts.map +1 -0
  47. package/dist/{git-hub-adapter.service.d.ts → types/git-hub-adapter.service.d.ts} +1 -0
  48. package/dist/types/git-hub-adapter.service.d.ts.map +1 -0
  49. package/dist/{graphql-query-factory.service.d.ts → types/graphql-query-factory.service.d.ts} +1 -0
  50. package/dist/types/graphql-query-factory.service.d.ts.map +1 -0
  51. package/dist/{index.d.ts → types/index.d.ts} +1 -0
  52. package/dist/types/index.d.ts.map +1 -0
  53. package/dist/{path-factory.service.d.ts → types/path-factory.service.d.ts} +1 -0
  54. package/dist/types/path-factory.service.d.ts.map +1 -0
  55. package/package.json +27 -14
  56. package/src/addition.model.ts +0 -2
  57. package/dist/addition.model.js.map +0 -1
  58. package/dist/container.js.map +0 -1
  59. package/dist/deletion.model.js.map +0 -1
  60. package/dist/entries-to-actions-converter.service.js.map +0 -1
  61. package/dist/entry-factory.service.js.map +0 -1
  62. package/dist/git-hub-adapter.service.js.map +0 -1
  63. package/dist/graphql-query-factory.service.js.map +0 -1
  64. package/dist/index.js.map +0 -1
  65. package/dist/path-factory.service.js.map +0 -1
  66. package/dist/tsconfig.tsbuildinfo +0 -1
  67. /package/dist/{deletion.model.js → cjs/deletion.model.js} +0 -0
  68. /package/dist/{entries-to-actions-converter.service.js → cjs/entries-to-actions-converter.service.js} +0 -0
  69. /package/dist/{entry-factory.service.js → cjs/entry-factory.service.js} +0 -0
  70. /package/dist/{graphql-query-factory.service.js → cjs/graphql-query-factory.service.js} +0 -0
  71. /package/dist/{path-factory.service.js → cjs/path-factory.service.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.8.0] - 2025-04-13
9
+
10
+ ### Changed
11
+
12
+ - Refactor library packaging to support ESM and CJS
13
+ - Clean up dependencies and relax version constraints
14
+
8
15
  ## [0.7.0] - 2024-08-23
9
16
 
10
17
  ### Changed
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AdditionModel = void 0;
4
- const buffer_1 = require("buffer");
5
4
  class AdditionModel {
6
5
  constructor(path, contents) {
7
6
  this.path = path;
8
- this.contents = buffer_1.Buffer.from(contents, 'utf8').toString('base64');
7
+ this.contents = Buffer.from(contents, 'utf8').toString('base64');
9
8
  }
10
9
  }
11
10
  exports.AdditionModel = AdditionModel;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addition.model.js","sourceRoot":"","sources":["../../src/addition.model.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAa;IAExB,YACW,IAAY,EACrB,QAAgB;QADP,SAAI,GAAJ,IAAI,CAAQ;QAGrB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAClE,CAAC;CACF;AARD,sCAQC"}
@@ -12,7 +12,7 @@ const axios_cache_interceptor_1 = require("axios-cache-interceptor");
12
12
  const path_factory_service_1 = require("./path-factory.service");
13
13
  const entry_factory_service_1 = require("./entry-factory.service");
14
14
  const cachedHttpAdapter = (0, axios_cache_interceptor_1.setupCache)(axios_1.default.create(), {
15
- ttl: git_hub_adapter_service_1.GitHubAdapterService.QUERY_CACHE_SECONDS * 1000,
15
+ ttl: git_hub_adapter_service_1.GitHubAdapterService.QUERY_CACHE_SECONDS * 1000, // milliseconds
16
16
  methods: ['get', 'post'],
17
17
  });
18
18
  const graphqlQueryFactoryService = new graphql_query_factory_service_1.GraphqlQueryFactoryService();
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/container.ts"],"names":[],"mappings":";;;;;;AAAA,iGAAyF;AACzF,uEAAgE;AAChE,mFAA4E;AAC5E,kDAAyB;AACzB,qEAAoD;AACpD,iEAA2D;AAC3D,mEAA6D;AAE7D,MAAM,iBAAiB,GAAG,IAAA,oCAAU,EAAC,eAAK,CAAC,MAAM,EAAE,EAAE;IACnD,GAAG,EAAE,8CAAoB,CAAC,mBAAmB,GAAG,IAAI,EAAE,eAAe;IACrE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;CACzB,CAAC,CAAA;AAEF,MAAM,0BAA0B,GAAG,IAAI,0DAA0B,EAAE,CAAA;AACnE,MAAM,gCAAgC,GAAG,IAAI,uEAAgC,EAAE,CAAA;AAC/E,MAAM,kBAAkB,GAAG,IAAI,yCAAkB,EAAE,CAAA;AACnD,MAAM,mBAAmB,GAAG,IAAI,2CAAmB,EAAE,CAAA;AAExC,QAAA,oBAAoB,GAAG,IAAI,8CAAoB,CAC1D,iBAAiB,EACjB,0BAA0B,EAC1B,gCAAgC,EAChC,kBAAkB,EAClB,mBAAmB,CACpB,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deletion.model.js","sourceRoot":"","sources":["../../src/deletion.model.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAa;IACxB,YAAqB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;CACtC;AAFD,sCAEC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries-to-actions-converter.service.js","sourceRoot":"","sources":["../../src/entries-to-actions-converter.service.ts"],"names":[],"mappings":";;;AAAA,0DAAsE;AACtE,+BAAgC;AAChC,qDAAgD;AAChD,qDAAgD;AAEhD,MAAa,gCAAgC;IAC3C,OAAO,CACL,WAAyB,EACzB,eAAuB;QAKvB,MAAM,SAAS,GAAoB,EAAE,CAAA;QACrC,MAAM,SAAS,GAAoB,EAAE,CAAA;QACrC,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACjC,MAAM,SAAS,GAAG,GAAG,eAAe,IAAI,UAAU,CAAC,EAAE,GAAG,6BAAe,EAAE,CAAA;YACzE,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;gBACxB,SAAS,CAAC,IAAI,CAAC,IAAI,8BAAa,CAAC,SAAS,CAAC,CAAC,CAAA;YAC9C,CAAC;iBAAM,CAAC;gBACN,SAAS,CAAC,IAAI,CACZ,IAAI,8BAAa,CACf,SAAS,EACT,IAAA,gBAAS,EAAC;oBACR,QAAQ,EAAE,UAAU,CAAC,QAAQ;oBAC7B,IAAI,EAAE,UAAU,CAAC,IAAI;iBACtB,CAAC,CACH,CACF,CAAA;YACH,CAAC;QACH,CAAC,CAAC,CAAA;QACF,OAAO;YACL,SAAS;YACT,SAAS;SACV,CAAA;IACH,CAAC;CACF;AA/BD,4EA+BC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-factory.service.js","sourceRoot":"","sources":["../../src/entry-factory.service.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,0DAAiE;AAUjE,MAAa,mBAAmB;IACvB,gCAAgC,CAAC,OAAoB;QAC1D,CAAC;YACC,OAAO,OAAO;iBACX,MAAM,CACL,CAAC,KAAgB,EAAE,EAAE,CACnB,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,6BAAe,CAAC;gBACpC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,MAAM,CACxC;iBACA,GAAG,CAAC,CAAC,KAAgB,EAAE,EAAE;gBACxB,MAAM,WAAW,GAAG,IAAA,YAAK,EAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;gBAC5C,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAC7B,CAAC,EACD,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,6BAAe,CAAC,MAAM,CAC3C,CAAA;gBACD,OAAO;oBACL,EAAE,EAAE,EAAE;oBACN,QAAQ,EAAE,WAAW,CAAC,QAAQ;oBAC9B,IAAI,EAAE,WAAW,CAAC,IAAI;iBACd,CAAA;YACZ,CAAC,CAAC,CAAA;QACN,CAAC;IACH,CAAC;CACF;AAvBD,kDAuBC"}
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.GitHubAdapterService = void 0;
13
+ class GitHubAdapterService {
14
+ constructor(cachedHttpAdapter, graphqlQueryFactory, entriesToActionsConverter, pathFactory, entryFactory) {
15
+ this.cachedHttpAdapter = cachedHttpAdapter;
16
+ this.graphqlQueryFactory = graphqlQueryFactory;
17
+ this.entriesToActionsConverter = entriesToActionsConverter;
18
+ this.pathFactory = pathFactory;
19
+ this.entryFactory = entryFactory;
20
+ }
21
+ setRepositoryOptions(repositoryOptions) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ this.gitRepositoryOptions = repositoryOptions;
24
+ });
25
+ }
26
+ getEntries(commitHash) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ var _a, _b;
29
+ if (this.gitRepositoryOptions === undefined) {
30
+ throw new Error('Repository options must be set before reading');
31
+ }
32
+ const token = this.gitRepositoryOptions.accessToken;
33
+ const pathEntryFolder = this.pathFactory.getPathEntryFolder(this.gitRepositoryOptions);
34
+ const queryFilesContent = this.graphqlQueryFactory.createBlobsContentQuery();
35
+ const filesContentResponse = yield this.cachedHttpAdapter.post(GitHubAdapterService.API_URL, {
36
+ query: queryFilesContent,
37
+ variables: {
38
+ repositoryOwner: this.gitRepositoryOptions.repositoryOwner,
39
+ repositoryName: this.gitRepositoryOptions.repositoryName,
40
+ expression: `${commitHash}:${pathEntryFolder}`,
41
+ },
42
+ }, {
43
+ headers: {
44
+ authorization: `Bearer ${token}`,
45
+ },
46
+ });
47
+ if (!((_b = (_a = filesContentResponse.data.data.repository) === null || _a === void 0 ? void 0 : _a.object) === null || _b === void 0 ? void 0 : _b.entries)) {
48
+ return [];
49
+ }
50
+ return this.entryFactory.createFromBlobsQueryResponseData(filesContentResponse.data.data.repository.object.entries);
51
+ });
52
+ }
53
+ getSchema(commitHash) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ var _a, _b, _c, _d;
56
+ if (this.gitRepositoryOptions === undefined) {
57
+ throw new Error('Repository options must be set before reading');
58
+ }
59
+ const repositoryOwner = this.gitRepositoryOptions.repositoryOwner;
60
+ const repositoryName = this.gitRepositoryOptions.repositoryName;
61
+ const token = this.gitRepositoryOptions.accessToken;
62
+ const schemaFilePath = this.pathFactory.getPathSchema(this.gitRepositoryOptions);
63
+ const queryContent = this.graphqlQueryFactory.createBlobContentQuery();
64
+ const response = yield this.cachedHttpAdapter.post(GitHubAdapterService.API_URL, {
65
+ query: queryContent,
66
+ variables: {
67
+ repositoryOwner: repositoryOwner,
68
+ repositoryName: repositoryName,
69
+ expression: `${commitHash}:${schemaFilePath}`,
70
+ },
71
+ }, {
72
+ headers: {
73
+ authorization: `Bearer ${token}`,
74
+ },
75
+ });
76
+ const schema = (_d = (_c = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.repository) === null || _c === void 0 ? void 0 : _c.object) === null || _d === void 0 ? void 0 : _d.text;
77
+ if (!schema) {
78
+ throw new Error(`"${schemaFilePath}" not found in Git repository "${repositoryOwner}/${repositoryName}" at commit "${commitHash}"`);
79
+ }
80
+ return schema;
81
+ });
82
+ }
83
+ getLatestCommitHash(ref) {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ var _a, _b, _c, _d, _e;
86
+ if (this.gitRepositoryOptions === undefined) {
87
+ throw new Error('Repository options must be set before reading');
88
+ }
89
+ const token = this.gitRepositoryOptions.accessToken;
90
+ const queryLatestCommit = this.graphqlQueryFactory.createLatestCommitQuery();
91
+ const response = yield this.cachedHttpAdapter.post(GitHubAdapterService.API_URL, {
92
+ query: queryLatestCommit,
93
+ variables: {
94
+ repositoryOwner: this.gitRepositoryOptions.repositoryOwner,
95
+ repositoryName: this.gitRepositoryOptions.repositoryName,
96
+ ref: ref,
97
+ },
98
+ }, {
99
+ cache: false, // must not use cache, so we always get the branch's current head
100
+ headers: {
101
+ authorization: `Bearer ${token}`,
102
+ },
103
+ });
104
+ if (!response.data.data.repository) {
105
+ throw new Error(`No repository found "${this.gitRepositoryOptions.repositoryOwner}/${this.gitRepositoryOptions.repositoryName}"`);
106
+ }
107
+ const lastCommit = (_e = (_c = (_b = (_a = response.data.data.repository.ref) === null || _a === void 0 ? void 0 : _a.target) === null || _b === void 0 ? void 0 : _b.oid) !== null && _c !== void 0 ? _c : (_d = response.data.data.repository.object) === null || _d === void 0 ? void 0 : _d.oid) !== null && _e !== void 0 ? _e : undefined;
108
+ if (!lastCommit) {
109
+ throw new Error(`No commit found for ref "${ref}"`);
110
+ }
111
+ return lastCommit;
112
+ });
113
+ }
114
+ createCommit(commitDraft) {
115
+ return __awaiter(this, void 0, void 0, function* () {
116
+ var _a;
117
+ if (this.gitRepositoryOptions === undefined) {
118
+ throw new Error('Repository options must be set before committing');
119
+ }
120
+ const token = this.gitRepositoryOptions.accessToken;
121
+ const pathEntryFolder = this.pathFactory.getPathEntryFolder(this.gitRepositoryOptions);
122
+ const { additions, deletions } = this.entriesToActionsConverter.convert(commitDraft.entries, pathEntryFolder);
123
+ const mutateCommit = this.graphqlQueryFactory.createCommitMutation();
124
+ const response = yield this.cachedHttpAdapter.post(GitHubAdapterService.API_URL, {
125
+ query: mutateCommit,
126
+ variables: {
127
+ repositoryNameWithOwner: `${this.gitRepositoryOptions.repositoryOwner}/${this.gitRepositoryOptions.repositoryName}`,
128
+ branchName: commitDraft.ref,
129
+ commitMessage: (_a = commitDraft.message) !== null && _a !== void 0 ? _a : '-',
130
+ precedingCommitSha: commitDraft.parentSha,
131
+ additions: additions,
132
+ deletions: deletions,
133
+ },
134
+ }, {
135
+ cache: false,
136
+ headers: {
137
+ authorization: `Bearer ${token}`,
138
+ },
139
+ });
140
+ if (response.data.errors) {
141
+ throw new Error(JSON.stringify(response.data.errors));
142
+ }
143
+ const mutationResult = response.data.data.commitCreate;
144
+ if (mutationResult.errors) {
145
+ throw new Error(JSON.stringify(mutationResult.errors));
146
+ }
147
+ return { ref: mutationResult.commit.oid };
148
+ });
149
+ }
150
+ }
151
+ exports.GitHubAdapterService = GitHubAdapterService;
152
+ GitHubAdapterService.QUERY_CACHE_SECONDS = 10 * 60;
153
+ GitHubAdapterService.API_URL = 'https://api.github.com/graphql';
154
+ //# sourceMappingURL=git-hub-adapter.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-hub-adapter.service.js","sourceRoot":"","sources":["../../src/git-hub-adapter.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAaA,MAAa,oBAAoB;IAO/B,YACmB,iBAAqC,EAC9C,mBAA+C,EAC/C,yBAA2D,EAC3D,WAA+B,EAC/B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BACzB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;YACvD,CAAC;YAED,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAA;YAEtD,IAAI,cAAc,CAAC,MAAM,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;YACxD,CAAC;YAED,OAAO,EAAE,GAAG,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;QAC3C,CAAC;KAAA;;AA9LH,oDA+LC;AA9LiB,wCAAmB,GAAG,EAAE,GAAG,EAAE,CAAA;AAE7B,4BAAO,GAAG,gCAAgC,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql-query-factory.service.js","sourceRoot":"","sources":["../../src/graphql-query-factory.service.ts"],"names":[],"mappings":";;;AAAA,MAAa,0BAA0B;IAC9B,uBAAuB;QAC5B,OAAO;;;;;;;;;;;;;;;;;;KAkBN,CAAA;IACH,CAAC;IAEM,sBAAsB;QAC3B,OAAO;;;;;;;;;;KAUN,CAAA;IACH,CAAC;IAEM,oBAAoB;QACzB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6BN,CAAA;IACH,CAAC;IAEM,uBAAuB;QAC5B,OAAO;;;;;;;;;;;;;KAaN,CAAA;IACH,CAAC;CACF;AAtFD,gEAsFC"}
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAdapter = exports.GitHubAdapterService = void 0;
3
+ exports.GitHubAdapterService = void 0;
4
+ exports.createAdapter = createAdapter;
4
5
  const container_1 = require("./container");
5
6
  var git_hub_adapter_service_1 = require("./git-hub-adapter.service");
6
7
  Object.defineProperty(exports, "GitHubAdapterService", { enumerable: true, get: function () { return git_hub_adapter_service_1.GitHubAdapterService; } });
7
8
  function createAdapter() {
8
9
  return container_1.gitHubAdapterService;
9
10
  }
10
- exports.createAdapter = createAdapter;
11
11
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAaA,sCAEC;AAdD,2CAAkD;AAElD,qEAAgE;AAAvD,+HAAA,oBAAoB,OAAA;AAU7B,SAAgB,aAAa;IAC3B,OAAO,gCAAoB,CAAA;AAC7B,CAAC"}
@@ -0,0 +1 @@
1
+ {"type": "commonjs"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-factory.service.js","sourceRoot":"","sources":["../../src/path-factory.service.ts"],"names":[],"mappings":";;;AACA,0DAA8E;AAE9E,MAAa,kBAAkB;IACtB,aAAa,CAAC,oBAA6C;;QAChE,OAAO,MAAA,oBAAoB,CAAC,cAAc,mCAAI,8BAAgB,CAAA;IAChE,CAAC;IAEM,kBAAkB,CACvB,oBAA6C;;QAE7C,MAAM,eAAe,GACnB,MAAA,oBAAoB,CAAC,eAAe,mCAAI,+BAAiB,CAAA;QAE3D,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAClC,OAAO,eAAe,CAAC,SAAS,CAAC,CAAC,EAAE,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QACjE,CAAC;QAED,OAAO,eAAe,CAAA;IACxB,CAAC;CACF;AAjBD,gDAiBC"}
@@ -0,0 +1,9 @@
1
+ export class AdditionModel {
2
+ path;
3
+ contents;
4
+ constructor(path, contents) {
5
+ this.path = path;
6
+ this.contents = Buffer.from(contents, 'utf8').toString('base64');
7
+ }
8
+ }
9
+ //# sourceMappingURL=addition.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addition.model.js","sourceRoot":"","sources":["../../src/addition.model.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,aAAa;IAGb;IAFF,QAAQ,CAAQ;IACzB,YACW,IAAY,EACrB,QAAgB;QADP,SAAI,GAAJ,IAAI,CAAQ;QAGrB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAClE,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ import { EntriesToActionsConverterService } from './entries-to-actions-converter.service';
2
+ import { GitHubAdapterService } from './git-hub-adapter.service';
3
+ import { GraphqlQueryFactoryService } from './graphql-query-factory.service';
4
+ import axios from 'axios';
5
+ import { setupCache } from 'axios-cache-interceptor';
6
+ import { PathFactoryService } from './path-factory.service';
7
+ import { EntryFactoryService } from './entry-factory.service';
8
+ const cachedHttpAdapter = setupCache(axios.create(), {
9
+ ttl: GitHubAdapterService.QUERY_CACHE_SECONDS * 1000, // milliseconds
10
+ methods: ['get', 'post'],
11
+ });
12
+ const graphqlQueryFactoryService = new GraphqlQueryFactoryService();
13
+ const entriesToActionsConverterService = new EntriesToActionsConverterService();
14
+ const pathFactoryService = new PathFactoryService();
15
+ const entryFactoryService = new EntryFactoryService();
16
+ export const gitHubAdapterService = new GitHubAdapterService(cachedHttpAdapter, graphqlQueryFactoryService, entriesToActionsConverterService, pathFactoryService, entryFactoryService);
17
+ //# sourceMappingURL=container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAA;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAA;AAC5E,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAE7D,MAAM,iBAAiB,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE;IACnD,GAAG,EAAE,oBAAoB,CAAC,mBAAmB,GAAG,IAAI,EAAE,eAAe;IACrE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;CACzB,CAAC,CAAA;AAEF,MAAM,0BAA0B,GAAG,IAAI,0BAA0B,EAAE,CAAA;AACnE,MAAM,gCAAgC,GAAG,IAAI,gCAAgC,EAAE,CAAA;AAC/E,MAAM,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAA;AACnD,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAA;AAErD,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CAC1D,iBAAiB,EACjB,0BAA0B,EAC1B,gCAAgC,EAChC,kBAAkB,EAClB,mBAAmB,CACpB,CAAA"}
@@ -0,0 +1,7 @@
1
+ export class DeletionModel {
2
+ path;
3
+ constructor(path) {
4
+ this.path = path;
5
+ }
6
+ }
7
+ //# sourceMappingURL=deletion.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deletion.model.js","sourceRoot":"","sources":["../../src/deletion.model.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,aAAa;IACH;IAArB,YAAqB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;CACtC"}
@@ -0,0 +1,27 @@
1
+ import { ENTRY_EXTENSION } from '@commitspark/git-adapter';
2
+ import { stringify } from 'yaml';
3
+ import { AdditionModel } from './addition.model';
4
+ import { DeletionModel } from './deletion.model';
5
+ export class EntriesToActionsConverterService {
6
+ convert(entryDrafts, pathEntryFolder) {
7
+ const additions = [];
8
+ const deletions = [];
9
+ entryDrafts.forEach((entryDraft) => {
10
+ const entryPath = `${pathEntryFolder}/${entryDraft.id}${ENTRY_EXTENSION}`;
11
+ if (entryDraft.deletion) {
12
+ deletions.push(new DeletionModel(entryPath));
13
+ }
14
+ else {
15
+ additions.push(new AdditionModel(entryPath, stringify({
16
+ metadata: entryDraft.metadata,
17
+ data: entryDraft.data,
18
+ })));
19
+ }
20
+ });
21
+ return {
22
+ additions,
23
+ deletions,
24
+ };
25
+ }
26
+ }
27
+ //# sourceMappingURL=entries-to-actions-converter.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries-to-actions-converter.service.js","sourceRoot":"","sources":["../../src/entries-to-actions-converter.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,eAAe,EAAE,MAAM,0BAA0B,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD,MAAM,OAAO,gCAAgC;IAC3C,OAAO,CACL,WAAyB,EACzB,eAAuB;QAKvB,MAAM,SAAS,GAAoB,EAAE,CAAA;QACrC,MAAM,SAAS,GAAoB,EAAE,CAAA;QACrC,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACjC,MAAM,SAAS,GAAG,GAAG,eAAe,IAAI,UAAU,CAAC,EAAE,GAAG,eAAe,EAAE,CAAA;YACzE,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;gBACxB,SAAS,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC,CAAA;YAC9C,CAAC;iBAAM,CAAC;gBACN,SAAS,CAAC,IAAI,CACZ,IAAI,aAAa,CACf,SAAS,EACT,SAAS,CAAC;oBACR,QAAQ,EAAE,UAAU,CAAC,QAAQ;oBAC7B,IAAI,EAAE,UAAU,CAAC,IAAI;iBACtB,CAAC,CACH,CACF,CAAA;YACH,CAAC;QACH,CAAC,CAAC,CAAA;QACF,OAAO;YACL,SAAS;YACT,SAAS;SACV,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ import { parse } from 'yaml';
2
+ import { ENTRY_EXTENSION } from '@commitspark/git-adapter';
3
+ export class EntryFactoryService {
4
+ createFromBlobsQueryResponseData(entries) {
5
+ {
6
+ return entries
7
+ .filter((entry) => entry.name.endsWith(ENTRY_EXTENSION) &&
8
+ entry.object['__typename'] === 'Blob')
9
+ .map((entry) => {
10
+ const fileContent = parse(entry.object.text);
11
+ const id = entry.name.substring(0, entry.name.length - ENTRY_EXTENSION.length);
12
+ return {
13
+ id: id,
14
+ metadata: fileContent.metadata,
15
+ data: fileContent.data,
16
+ };
17
+ });
18
+ }
19
+ }
20
+ }
21
+ //# sourceMappingURL=entry-factory.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-factory.service.js","sourceRoot":"","sources":["../../src/entry-factory.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAS,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAUjE,MAAM,OAAO,mBAAmB;IACvB,gCAAgC,CAAC,OAAoB;QAC1D,CAAC;YACC,OAAO,OAAO;iBACX,MAAM,CACL,CAAC,KAAgB,EAAE,EAAE,CACnB,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;gBACpC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,MAAM,CACxC;iBACA,GAAG,CAAC,CAAC,KAAgB,EAAE,EAAE;gBACxB,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;gBAC5C,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAC7B,CAAC,EACD,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM,CAC3C,CAAA;gBACD,OAAO;oBACL,EAAE,EAAE,EAAE;oBACN,QAAQ,EAAE,WAAW,CAAC,QAAQ;oBAC9B,IAAI,EAAE,WAAW,CAAC,IAAI;iBACd,CAAA;YACZ,CAAC,CAAC,CAAA;QACN,CAAC;IACH,CAAC;CACF"}
@@ -1,7 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GitHubAdapterService = void 0;
4
- class GitHubAdapterService {
1
+ export class GitHubAdapterService {
2
+ cachedHttpAdapter;
3
+ graphqlQueryFactory;
4
+ entriesToActionsConverter;
5
+ pathFactory;
6
+ entryFactory;
7
+ static QUERY_CACHE_SECONDS = 10 * 60;
8
+ static API_URL = 'https://api.github.com/graphql';
9
+ gitRepositoryOptions;
5
10
  constructor(cachedHttpAdapter, graphqlQueryFactory, entriesToActionsConverter, pathFactory, entryFactory) {
6
11
  this.cachedHttpAdapter = cachedHttpAdapter;
7
12
  this.graphqlQueryFactory = graphqlQueryFactory;
@@ -13,7 +18,6 @@ class GitHubAdapterService {
13
18
  this.gitRepositoryOptions = repositoryOptions;
14
19
  }
15
20
  async getEntries(commitHash) {
16
- var _a, _b;
17
21
  if (this.gitRepositoryOptions === undefined) {
18
22
  throw new Error('Repository options must be set before reading');
19
23
  }
@@ -32,13 +36,12 @@ class GitHubAdapterService {
32
36
  authorization: `Bearer ${token}`,
33
37
  },
34
38
  });
35
- if (!((_b = (_a = filesContentResponse.data.data.repository) === null || _a === void 0 ? void 0 : _a.object) === null || _b === void 0 ? void 0 : _b.entries)) {
39
+ if (!filesContentResponse.data.data.repository?.object?.entries) {
36
40
  return [];
37
41
  }
38
42
  return this.entryFactory.createFromBlobsQueryResponseData(filesContentResponse.data.data.repository.object.entries);
39
43
  }
40
44
  async getSchema(commitHash) {
41
- var _a, _b, _c, _d;
42
45
  if (this.gitRepositoryOptions === undefined) {
43
46
  throw new Error('Repository options must be set before reading');
44
47
  }
@@ -59,14 +62,13 @@ class GitHubAdapterService {
59
62
  authorization: `Bearer ${token}`,
60
63
  },
61
64
  });
62
- const schema = (_d = (_c = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.repository) === null || _c === void 0 ? void 0 : _c.object) === null || _d === void 0 ? void 0 : _d.text;
65
+ const schema = response.data?.data?.repository?.object?.text;
63
66
  if (!schema) {
64
67
  throw new Error(`"${schemaFilePath}" not found in Git repository "${repositoryOwner}/${repositoryName}" at commit "${commitHash}"`);
65
68
  }
66
69
  return schema;
67
70
  }
68
71
  async getLatestCommitHash(ref) {
69
- var _a, _b, _c, _d, _e;
70
72
  if (this.gitRepositoryOptions === undefined) {
71
73
  throw new Error('Repository options must be set before reading');
72
74
  }
@@ -80,7 +82,7 @@ class GitHubAdapterService {
80
82
  ref: ref,
81
83
  },
82
84
  }, {
83
- cache: false,
85
+ cache: false, // must not use cache, so we always get the branch's current head
84
86
  headers: {
85
87
  authorization: `Bearer ${token}`,
86
88
  },
@@ -88,14 +90,15 @@ class GitHubAdapterService {
88
90
  if (!response.data.data.repository) {
89
91
  throw new Error(`No repository found "${this.gitRepositoryOptions.repositoryOwner}/${this.gitRepositoryOptions.repositoryName}"`);
90
92
  }
91
- const lastCommit = (_e = (_c = (_b = (_a = response.data.data.repository.ref) === null || _a === void 0 ? void 0 : _a.target) === null || _b === void 0 ? void 0 : _b.oid) !== null && _c !== void 0 ? _c : (_d = response.data.data.repository.object) === null || _d === void 0 ? void 0 : _d.oid) !== null && _e !== void 0 ? _e : undefined;
93
+ const lastCommit = response.data.data.repository.ref?.target?.oid ??
94
+ response.data.data.repository.object?.oid ??
95
+ undefined;
92
96
  if (!lastCommit) {
93
97
  throw new Error(`No commit found for ref "${ref}"`);
94
98
  }
95
99
  return lastCommit;
96
100
  }
97
101
  async createCommit(commitDraft) {
98
- var _a;
99
102
  if (this.gitRepositoryOptions === undefined) {
100
103
  throw new Error('Repository options must be set before committing');
101
104
  }
@@ -108,7 +111,7 @@ class GitHubAdapterService {
108
111
  variables: {
109
112
  repositoryNameWithOwner: `${this.gitRepositoryOptions.repositoryOwner}/${this.gitRepositoryOptions.repositoryName}`,
110
113
  branchName: commitDraft.ref,
111
- commitMessage: (_a = commitDraft.message) !== null && _a !== void 0 ? _a : '-',
114
+ commitMessage: commitDraft.message ?? '-',
112
115
  precedingCommitSha: commitDraft.parentSha,
113
116
  additions: additions,
114
117
  deletions: deletions,
@@ -129,7 +132,4 @@ class GitHubAdapterService {
129
132
  return { ref: mutationResult.commit.oid };
130
133
  }
131
134
  }
132
- exports.GitHubAdapterService = GitHubAdapterService;
133
- GitHubAdapterService.QUERY_CACHE_SECONDS = 10 * 60;
134
- GitHubAdapterService.API_URL = 'https://api.github.com/graphql';
135
135
  //# sourceMappingURL=git-hub-adapter.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-hub-adapter.service.js","sourceRoot":"","sources":["../../src/git-hub-adapter.service.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,oBAAoB;IAQZ;IACT;IACA;IACA;IACA;IAXV,MAAM,CAAU,mBAAmB,GAAG,EAAE,GAAG,EAAE,CAAA;IAE7C,MAAM,CAAU,OAAO,GAAG,gCAAgC,CAAA;IAElD,oBAAoB,CAAqC;IAEjE,YACmB,iBAAqC,EAC9C,mBAA+C,EAC/C,yBAA2D,EAC3D,WAA+B,EAC/B,YAAiC;QAJxB,sBAAiB,GAAjB,iBAAiB,CAAoB;QAC9C,wBAAmB,GAAnB,mBAAmB,CAA4B;QAC/C,8BAAyB,GAAzB,yBAAyB,CAAkC;QAC3D,gBAAW,GAAX,WAAW,CAAoB;QAC/B,iBAAY,GAAZ,YAAY,CAAqB;IACxC,CAAC;IAEG,KAAK,CAAC,oBAAoB,CAC/B,iBAA0C;QAE1C,IAAI,CAAC,oBAAoB,GAAG,iBAAiB,CAAA;IAC/C,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,UAAkB;QACxC,IAAI,IAAI,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;QAClE,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC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BAAoB,EAAE,CAAA;QACpE,MAAM,QAAQ,GAAQ,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CACrD,oBAAoB,CAAC,OAAO,EAC5B;YACE,KAAK,EAAE,YAAY;YACnB,SAAS,EAAE;gBACT,uBAAuB,EAAE,GAAG,IAAI,CAAC,oBAAoB,CAAC,eAAe,IAAI,IAAI,CAAC,oBAAoB,CAAC,cAAc,EAAE;gBACnH,UAAU,EAAE,WAAW,CAAC,GAAG;gBAC3B,aAAa,EAAE,WAAW,CAAC,OAAO,IAAI,GAAG;gBACzC,kBAAkB,EAAE,WAAW,CAAC,SAAS;gBACzC,SAAS,EAAE,SAAS;gBACpB,SAAS,EAAE,SAAS;aACrB;SACF,EACD;YACE,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,KAAK,EAAE;aACjC;SACF,CACF,CAAA;QAED,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;QACvD,CAAC;QAED,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAA;QAEtD,IAAI,cAAc,CAAC,MAAM,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;QACxD,CAAC;QAED,OAAO,EAAE,GAAG,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;IAC3C,CAAC"}
@@ -0,0 +1,85 @@
1
+ export class GraphqlQueryFactoryService {
2
+ createBlobsContentQuery() {
3
+ return `
4
+ query ($repositoryOwner: String!, $repositoryName: String!, $expression: String!) {
5
+ repository(owner: $repositoryOwner, name: $repositoryName) {
6
+ object(expression: $expression) {
7
+ ... on Tree {
8
+ entries {
9
+ name
10
+ object {
11
+ __typename
12
+ ... on Blob {
13
+ text
14
+ }
15
+ }
16
+ }
17
+ }
18
+ }
19
+ }
20
+ }
21
+ `;
22
+ }
23
+ createBlobContentQuery() {
24
+ return `
25
+ query ($repositoryOwner: String!, $repositoryName: String!, $expression: String!) {
26
+ repository(owner: $repositoryOwner, name: $repositoryName) {
27
+ object(expression: $expression) {
28
+ ... on Blob {
29
+ text
30
+ }
31
+ }
32
+ }
33
+ }
34
+ `;
35
+ }
36
+ createCommitMutation() {
37
+ return `
38
+ mutation (
39
+ $repositoryNameWithOwner: String!,
40
+ $branchName: String!,
41
+ $commitMessage: String!,
42
+ $precedingCommitSha: GitObjectID!,
43
+ $additions: [FileAddition!],
44
+ $deletions: [FileDeletion!]
45
+ ) {
46
+ commitCreate: createCommitOnBranch(input: {
47
+ branch: {
48
+ repositoryNameWithOwner: $repositoryNameWithOwner
49
+ branchName: $branchName
50
+ }
51
+ message: {
52
+ headline: $commitMessage
53
+ body:""
54
+ }
55
+ expectedHeadOid: $precedingCommitSha
56
+ fileChanges: {
57
+ additions: $additions
58
+ deletions: $deletions
59
+ }
60
+ }) {
61
+ commit {
62
+ oid
63
+ }
64
+ }
65
+ }
66
+ `;
67
+ }
68
+ createLatestCommitQuery() {
69
+ return `
70
+ query ($repositoryOwner: String!, $repositoryName: String!, $ref: String!) {
71
+ repository(owner: $repositoryOwner, name: $repositoryName) {
72
+ ref(qualifiedName: $ref) {
73
+ target {
74
+ oid
75
+ }
76
+ }
77
+ object(expression: $ref) {
78
+ oid
79
+ }
80
+ }
81
+ }
82
+ `;
83
+ }
84
+ }
85
+ //# sourceMappingURL=graphql-query-factory.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql-query-factory.service.js","sourceRoot":"","sources":["../../src/graphql-query-factory.service.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,0BAA0B;IAC9B,uBAAuB;QAC5B,OAAO;;;;;;;;;;;;;;;;;;KAkBN,CAAA;IACH,CAAC;IAEM,sBAAsB;QAC3B,OAAO;;;;;;;;;;KAUN,CAAA;IACH,CAAC;IAEM,oBAAoB;QACzB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6BN,CAAA;IACH,CAAC;IAEM,uBAAuB;QAC5B,OAAO;;;;;;;;;;;;;KAaN,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ import { gitHubAdapterService } from './container';
2
+ export { GitHubAdapterService } from './git-hub-adapter.service';
3
+ export function createAdapter() {
4
+ return gitHubAdapterService;
5
+ }
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAElD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAUhE,MAAM,UAAU,aAAa;IAC3B,OAAO,oBAAoB,CAAA;AAC7B,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { PATH_ENTRY_FOLDER, PATH_SCHEMA_FILE } from '@commitspark/git-adapter';
2
+ export class PathFactoryService {
3
+ getPathSchema(gitRepositoryOptions) {
4
+ return gitRepositoryOptions.pathSchemaFile ?? PATH_SCHEMA_FILE;
5
+ }
6
+ getPathEntryFolder(gitRepositoryOptions) {
7
+ const pathEntryFolder = gitRepositoryOptions.pathEntryFolder ?? PATH_ENTRY_FOLDER;
8
+ if (pathEntryFolder.endsWith('/')) {
9
+ return pathEntryFolder.substring(0, pathEntryFolder.length - 1);
10
+ }
11
+ return pathEntryFolder;
12
+ }
13
+ }
14
+ //# sourceMappingURL=path-factory.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-factory.service.js","sourceRoot":"","sources":["../../src/path-factory.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAE9E,MAAM,OAAO,kBAAkB;IACtB,aAAa,CAAC,oBAA6C;QAChE,OAAO,oBAAoB,CAAC,cAAc,IAAI,gBAAgB,CAAA;IAChE,CAAC;IAEM,kBAAkB,CACvB,oBAA6C;QAE7C,MAAM,eAAe,GACnB,oBAAoB,CAAC,eAAe,IAAI,iBAAiB,CAAA;QAE3D,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAClC,OAAO,eAAe,CAAC,SAAS,CAAC,CAAC,EAAE,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QACjE,CAAC;QAED,OAAO,eAAe,CAAA;IACxB,CAAC;CACF"}