@copado/agentia-cli 0.41.0-alpha.0 → 0.43.0-alpha.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 (33) hide show
  1. package/README.md +333 -94
  2. package/dist/commands/cicd/repository/create.d.ts +25 -0
  3. package/dist/commands/cicd/repository/create.js +45 -0
  4. package/dist/commands/cicd/repository/create.js.map +1 -0
  5. package/dist/commands/cicd/repository/delete.d.ts +11 -0
  6. package/dist/commands/cicd/repository/delete.js +29 -0
  7. package/dist/commands/cicd/repository/delete.js.map +1 -0
  8. package/dist/commands/cicd/repository/get.d.ts +10 -0
  9. package/dist/commands/cicd/repository/get.js +30 -0
  10. package/dist/commands/cicd/repository/get.js.map +1 -0
  11. package/dist/commands/cicd/repository/list.d.ts +8 -0
  12. package/dist/commands/cicd/repository/list.js +26 -0
  13. package/dist/commands/cicd/repository/list.js.map +1 -0
  14. package/dist/commands/cicd/repository/reset.d.ts +12 -0
  15. package/dist/commands/cicd/repository/reset.js +29 -0
  16. package/dist/commands/cicd/repository/reset.js.map +1 -0
  17. package/dist/commands/cicd/repository/update.d.ts +34 -0
  18. package/dist/commands/cicd/repository/update.js +64 -0
  19. package/dist/commands/cicd/repository/update.js.map +1 -0
  20. package/dist/commands/cicd/repository/validate.d.ts +10 -0
  21. package/dist/commands/cicd/repository/validate.js +33 -0
  22. package/dist/commands/cicd/repository/validate.js.map +1 -0
  23. package/dist/lib/mcp/tools.d.ts +61 -0
  24. package/dist/lib/mcp/tools.js +166 -0
  25. package/dist/lib/mcp/tools.js.map +1 -1
  26. package/dist/lib/repository-flags.d.ts +117 -0
  27. package/dist/lib/repository-flags.js +208 -0
  28. package/dist/lib/repository-flags.js.map +1 -0
  29. package/dist/lib/repository-types.d.ts +94 -0
  30. package/dist/lib/repository-types.js +110 -0
  31. package/dist/lib/repository-types.js.map +1 -0
  32. package/oclif.manifest.json +623 -85
  33. package/package.json +4 -1
@@ -0,0 +1,208 @@
1
+ import { Flags } from '@oclif/core';
2
+ import { REPOSITORY_AUTH_TYPES, REPOSITORY_PROVIDERS, REPOSITORY_SOURCE_FORMATS, } from './repository-types.js';
3
+ export const repositoryRequiredMutationFlags = {
4
+ provider: Flags.string({
5
+ description: 'Git repository provider',
6
+ options: [...REPOSITORY_PROVIDERS],
7
+ required: true,
8
+ }),
9
+ 'source-format': Flags.string({
10
+ description: 'Git repository source format',
11
+ options: [...REPOSITORY_SOURCE_FORMATS],
12
+ required: true,
13
+ }),
14
+ };
15
+ export const repositoryOptionalStringFlags = {
16
+ 'auth-type': Flags.string({
17
+ description: 'Repository authentication type',
18
+ options: [...REPOSITORY_AUTH_TYPES],
19
+ }),
20
+ 'branch-base-url': Flags.string({
21
+ description: 'Base URL for repository branch links',
22
+ }),
23
+ 'commit-base-url': Flags.string({
24
+ description: 'Base URL for repository commit links',
25
+ }),
26
+ 'extra-headers': Flags.string({
27
+ description: 'Additional authentication headers. Prefer environment-specific credential storage when available.',
28
+ }),
29
+ password: Flags.string({
30
+ description: 'Repository password or token. This can be visible in shell history.',
31
+ }),
32
+ 'pull-request-base-url': Flags.string({
33
+ description: 'Base URL for repository pull request links',
34
+ }),
35
+ 'tag-base-url': Flags.string({
36
+ description: 'Base URL for repository tag links',
37
+ }),
38
+ uri: Flags.string({
39
+ description: 'Repository clone URI',
40
+ }),
41
+ username: Flags.string({
42
+ description: 'Repository username',
43
+ }),
44
+ };
45
+ export const repositoryBooleanFlags = {
46
+ 'allow-functions-git-cache': Flags.boolean({
47
+ allowNo: true,
48
+ description: 'Allow Functions Git cache for this repository',
49
+ }),
50
+ 'copado-tunnel-enabled': Flags.boolean({
51
+ allowNo: true,
52
+ description: 'Enable Copado tunnel for this repository',
53
+ }),
54
+ };
55
+ export const repositoryClearFlags = {
56
+ 'clear-branch-base-url': Flags.boolean({
57
+ description: 'Clear the repository branch base URL',
58
+ }),
59
+ 'clear-commit-base-url': Flags.boolean({
60
+ description: 'Clear the repository commit base URL',
61
+ }),
62
+ 'clear-extra-headers': Flags.boolean({
63
+ description: 'Clear additional repository headers',
64
+ }),
65
+ 'clear-password': Flags.boolean({
66
+ description: 'Clear the repository password or token',
67
+ }),
68
+ 'clear-pull-request-base-url': Flags.boolean({
69
+ description: 'Clear the repository pull request base URL',
70
+ }),
71
+ 'clear-tag-base-url': Flags.boolean({
72
+ description: 'Clear the repository tag base URL',
73
+ }),
74
+ 'clear-uri': Flags.boolean({
75
+ description: 'Clear the repository clone URI',
76
+ }),
77
+ 'clear-username': Flags.boolean({
78
+ description: 'Clear the repository username',
79
+ }),
80
+ };
81
+ export const repositoryCreateFlags = {
82
+ ...repositoryBooleanFlags,
83
+ ...repositoryOptionalStringFlags,
84
+ ...repositoryRequiredMutationFlags,
85
+ };
86
+ export const repositoryUpdateFlags = {
87
+ ...repositoryBooleanFlags,
88
+ ...repositoryClearFlags,
89
+ ...repositoryOptionalStringFlags,
90
+ name: Flags.string({
91
+ description: 'Repository name',
92
+ }),
93
+ provider: Flags.string({
94
+ description: 'Git repository provider',
95
+ options: [...REPOSITORY_PROVIDERS],
96
+ }),
97
+ 'source-format': Flags.string({
98
+ description: 'Git repository source format',
99
+ options: [...REPOSITORY_SOURCE_FORMATS],
100
+ }),
101
+ };
102
+ const REPOSITORY_FLAG_TO_PAYLOAD_KEY = {
103
+ 'allow-functions-git-cache': 'allowFunctionsGitCache',
104
+ 'auth-type': 'authType',
105
+ 'branch-base-url': 'branchBaseUrl',
106
+ 'commit-base-url': 'commitBaseUrl',
107
+ 'copado-tunnel-enabled': 'isCopadoTunnelEnabled',
108
+ 'extra-headers': 'extraHeaders',
109
+ name: 'name',
110
+ password: 'password',
111
+ provider: 'provider',
112
+ 'pull-request-base-url': 'pullRequestBaseUrl',
113
+ 'source-format': 'sourceFormat',
114
+ 'tag-base-url': 'tagBaseUrl',
115
+ uri: 'uri',
116
+ username: 'username',
117
+ };
118
+ const REPOSITORY_CLEAR_FLAG_TO_PAYLOAD_KEY = {
119
+ 'clear-branch-base-url': 'branchBaseUrl',
120
+ 'clear-commit-base-url': 'commitBaseUrl',
121
+ 'clear-extra-headers': 'extraHeaders',
122
+ 'clear-password': 'password',
123
+ 'clear-pull-request-base-url': 'pullRequestBaseUrl',
124
+ 'clear-tag-base-url': 'tagBaseUrl',
125
+ 'clear-uri': 'uri',
126
+ 'clear-username': 'username',
127
+ };
128
+ const mutationFlagKeys = Object.keys(REPOSITORY_FLAG_TO_PAYLOAD_KEY);
129
+ const clearFlagKeys = Object.keys(REPOSITORY_CLEAR_FLAG_TO_PAYLOAD_KEY);
130
+ export const REPOSITORY_STRING_VALIDATION_KEYS = [
131
+ 'authType',
132
+ 'branchBaseUrl',
133
+ 'commitBaseUrl',
134
+ 'extraHeaders',
135
+ 'name',
136
+ 'password',
137
+ 'provider',
138
+ 'pullRequestBaseUrl',
139
+ 'sourceFormat',
140
+ 'tagBaseUrl',
141
+ 'uri',
142
+ 'username',
143
+ ];
144
+ export function buildRepositoryCreatePayload(name, flags) {
145
+ return {
146
+ ...buildRepositoryMutationPayload(flags),
147
+ allowFunctionsGitCache: flags['allow-functions-git-cache'] ?? false,
148
+ authType: (flags['auth-type'] ?? 'HTTPS'),
149
+ isCopadoTunnelEnabled: flags['copado-tunnel-enabled'] ?? false,
150
+ name,
151
+ provider: flags.provider,
152
+ sourceFormat: flags['source-format'],
153
+ };
154
+ }
155
+ export function buildRepositoryMutationPayload(flags) {
156
+ const payload = {};
157
+ for (const flagKey of mutationFlagKeys) {
158
+ const value = flags[flagKey];
159
+ if (value !== undefined) {
160
+ const payloadKey = REPOSITORY_FLAG_TO_PAYLOAD_KEY[flagKey];
161
+ Object.assign(payload, { [payloadKey]: value });
162
+ }
163
+ }
164
+ for (const flagKey of clearFlagKeys) {
165
+ if (flags[flagKey] === true) {
166
+ const payloadKey = REPOSITORY_CLEAR_FLAG_TO_PAYLOAD_KEY[flagKey];
167
+ Object.assign(payload, { [payloadKey]: null });
168
+ }
169
+ }
170
+ return payload;
171
+ }
172
+ export function collectRepositoryMutationFlagKeys(flags) {
173
+ const selected = [];
174
+ for (const key of mutationFlagKeys) {
175
+ if (flags[key] !== undefined) {
176
+ selected.push(key);
177
+ }
178
+ }
179
+ for (const key of clearFlagKeys) {
180
+ if (flags[key] === true) {
181
+ selected.push(key);
182
+ }
183
+ }
184
+ return selected;
185
+ }
186
+ export function validateRepositoryMutationFlags(flags) {
187
+ for (const clearFlagKey of clearFlagKeys) {
188
+ if (flags[clearFlagKey] !== true) {
189
+ continue;
190
+ }
191
+ const payloadKey = REPOSITORY_CLEAR_FLAG_TO_PAYLOAD_KEY[clearFlagKey];
192
+ const valueFlag = mutationFlagKeys.find((flagKey) => REPOSITORY_FLAG_TO_PAYLOAD_KEY[flagKey] === payloadKey);
193
+ if (valueFlag !== undefined && flags[valueFlag] !== undefined) {
194
+ return `Cannot provide --${valueFlag} and --${clearFlagKey} together.`;
195
+ }
196
+ }
197
+ return undefined;
198
+ }
199
+ export function validateNonEmptyStringFields(payload, keys) {
200
+ for (const key of keys) {
201
+ const value = payload[key];
202
+ if (typeof value === 'string' && value.trim().length === 0) {
203
+ return `${key} value cannot be empty`;
204
+ }
205
+ }
206
+ return undefined;
207
+ }
208
+ //# sourceMappingURL=repository-flags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository-flags.js","sourceRoot":"","sources":["../../src/lib/repository-flags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjC,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,GAK1B,MAAM,uBAAuB,CAAA;AAE9B,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC;QACrB,WAAW,EAAE,yBAAyB;QACtC,OAAO,EAAE,CAAC,GAAG,oBAAoB,CAAC;QAClC,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC;QAC5B,WAAW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AC,KAAK,IAAI,EAAE,CAAC;YACxB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACpB,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,KAAmC;IACjF,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;QACzC,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC;YACjC,SAAQ;QACV,CAAC;QAED,MAAM,UAAU,GAAG,oCAAoC,CAAC,YAAY,CAAC,CAAA;QACrE,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,8BAA8B,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC,CAAA;QAE5G,IAAI,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;YAC9D,OAAO,oBAAoB,SAAS,UAAU,YAAY,YAAY,CAAA;QACxE,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,OAAkC,EAClC,IAAkD;IAElD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;QAE1B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3D,OAAO,GAAG,GAAG,wBAAwB,CAAA;QACvC,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -0,0 +1,94 @@
1
+ import { type PaginatedListResult } from './list-pagination.js';
2
+ export declare const REPOSITORY_SOURCE_FORMATS: readonly ["DX"];
3
+ export declare const REPOSITORY_PROVIDERS: readonly ["Github", "Bitbucket", "Gitlab", "Microsoft Team Service", "Copado Version Control", "Others"];
4
+ export declare const REPOSITORY_AUTH_TYPES: readonly ["HTTPS"];
5
+ export type RepositorySourceFormat = (typeof REPOSITORY_SOURCE_FORMATS)[number];
6
+ export type RepositoryProvider = (typeof REPOSITORY_PROVIDERS)[number];
7
+ export type RepositoryAuthType = (typeof REPOSITORY_AUTH_TYPES)[number];
8
+ export type PipelineConnection = Record<string, unknown>;
9
+ export type RepositoryPipeline = {
10
+ id?: null | string;
11
+ mainBranch?: null | string;
12
+ name?: null | string;
13
+ pipelineConnections?: PipelineConnection[];
14
+ };
15
+ export type RepositorySnapshot = {
16
+ createdBy?: null | string;
17
+ createdDate?: null | string;
18
+ id: string;
19
+ lastModifiedBy?: null | string;
20
+ lastModifiedDate?: null | string;
21
+ name?: null | string;
22
+ };
23
+ export type GitRepository = {
24
+ allowFunctionsGitCache?: boolean;
25
+ authType?: null | RepositoryAuthType;
26
+ branchBaseUrl?: null | string;
27
+ commitBaseUrl?: null | string;
28
+ createdBy?: null | string;
29
+ createdDate?: null | string;
30
+ extraHeaders?: null | string;
31
+ id: string;
32
+ isCopadoTunnelEnabled?: boolean;
33
+ lastModifiedBy?: null | string;
34
+ lastModifiedDate?: null | string;
35
+ name: string;
36
+ password?: null | string;
37
+ pipelines?: RepositoryPipeline[];
38
+ provider: RepositoryProvider;
39
+ pullRequestBaseUrl?: null | string;
40
+ snapshots?: RepositorySnapshot[];
41
+ sourceFormat: RepositorySourceFormat;
42
+ tagBaseUrl?: null | string;
43
+ uri?: null | string;
44
+ username?: null | string;
45
+ };
46
+ export type RepositoryMutationPayload = {
47
+ allowFunctionsGitCache?: boolean;
48
+ authType?: RepositoryAuthType;
49
+ branchBaseUrl?: null | string;
50
+ commitBaseUrl?: null | string;
51
+ extraHeaders?: null | string;
52
+ isCopadoTunnelEnabled?: boolean;
53
+ name?: string;
54
+ password?: null | string;
55
+ provider?: RepositoryProvider;
56
+ pullRequestBaseUrl?: null | string;
57
+ sourceFormat?: RepositorySourceFormat;
58
+ tagBaseUrl?: null | string;
59
+ uri?: null | string;
60
+ username?: null | string;
61
+ };
62
+ export type RepositoryValidateResult = {
63
+ message?: null | string;
64
+ validated: boolean;
65
+ };
66
+ export type RepositoryListPage = {
67
+ currentPage?: number;
68
+ data?: GitRepository[];
69
+ hasMore?: boolean;
70
+ nextCursor?: string;
71
+ pageSize?: number;
72
+ totalPages?: number;
73
+ totalRecords?: number;
74
+ };
75
+ export type RepositoriesListResponse = GitRepository[] | RepositoryListPage | {
76
+ data?: GitRepository[] | RepositoryListPage;
77
+ };
78
+ export type RepositoryResponse = GitRepository | {
79
+ data?: GitRepository;
80
+ };
81
+ export type RepositoryValidateResponse = RepositoryValidateResult | {
82
+ data?: RepositoryValidateResult;
83
+ };
84
+ export declare function repositoriesEndpoint(): string;
85
+ export declare function repositoryEndpoint(repositoryId: string): string;
86
+ export declare function repositoryResetEndpoint(repositoryId: string): string;
87
+ export declare function repositoryValidateEndpoint(repositoryId: string): string;
88
+ export declare function normalizeRepositoriesListPage(response: RepositoriesListResponse): PaginatedListResult<GitRepository>;
89
+ export declare function normalizeRepository(response: RepositoryResponse): GitRepository;
90
+ export declare function normalizeRepositoryValidateResult(response: RepositoryValidateResponse): RepositoryValidateResult;
91
+ export declare function sanitizeRepository(repository: GitRepository): GitRepository;
92
+ export declare function withRequiredRepositoryFields(payload: RepositoryMutationPayload, current: GitRepository): RepositoryMutationPayload;
93
+ export declare function formatRepositoryTable(repositories: GitRepository[]): string;
94
+ export declare function formatRepositoryDetail(repository: GitRepository): string;
@@ -0,0 +1,110 @@
1
+ import { cellValue, table } from './format.js';
2
+ import { paginatedResultFromNestedData, } from './list-pagination.js';
3
+ const REDACTED = '[REDACTED]';
4
+ const URL_CREDENTIALS_PATTERN = /^([^:]+:\/\/)([^/@]+)@/u;
5
+ export const REPOSITORY_SOURCE_FORMATS = ['DX'];
6
+ export const REPOSITORY_PROVIDERS = [
7
+ 'Github',
8
+ 'Bitbucket',
9
+ 'Gitlab',
10
+ 'Microsoft Team Service',
11
+ 'Copado Version Control',
12
+ 'Others',
13
+ ];
14
+ export const REPOSITORY_AUTH_TYPES = ['HTTPS'];
15
+ export function repositoriesEndpoint() {
16
+ return '/corpus/repositories';
17
+ }
18
+ export function repositoryEndpoint(repositoryId) {
19
+ return `${repositoriesEndpoint()}/${encodeURIComponent(repositoryId)}`;
20
+ }
21
+ export function repositoryResetEndpoint(repositoryId) {
22
+ return `${repositoryEndpoint(repositoryId)}/reset`;
23
+ }
24
+ export function repositoryValidateEndpoint(repositoryId) {
25
+ return `${repositoryEndpoint(repositoryId)}/validate`;
26
+ }
27
+ export function normalizeRepositoriesListPage(response) {
28
+ const page = paginatedResultFromNestedData(response);
29
+ const data = page.data.map((repository) => sanitizeRepository(repository));
30
+ return { ...page, data };
31
+ }
32
+ export function normalizeRepository(response) {
33
+ if ('data' in response && response.data !== undefined && typeof response.data === 'object' && !Array.isArray(response.data)) {
34
+ return sanitizeRepository(response.data);
35
+ }
36
+ return sanitizeRepository(response);
37
+ }
38
+ export function normalizeRepositoryValidateResult(response) {
39
+ if ('data' in response && response.data !== undefined && typeof response.data === 'object' && !Array.isArray(response.data)) {
40
+ return response.data;
41
+ }
42
+ return response;
43
+ }
44
+ export function sanitizeRepository(repository) {
45
+ return {
46
+ ...repository,
47
+ branchBaseUrl: redactUrlCredentials(repository.branchBaseUrl),
48
+ commitBaseUrl: redactUrlCredentials(repository.commitBaseUrl),
49
+ extraHeaders: repository.extraHeaders === null || repository.extraHeaders === undefined ? repository.extraHeaders : REDACTED,
50
+ password: repository.password === null || repository.password === undefined ? repository.password : REDACTED,
51
+ pullRequestBaseUrl: redactUrlCredentials(repository.pullRequestBaseUrl),
52
+ tagBaseUrl: redactUrlCredentials(repository.tagBaseUrl),
53
+ uri: redactUrlCredentials(repository.uri),
54
+ };
55
+ }
56
+ export function withRequiredRepositoryFields(payload, current) {
57
+ return {
58
+ ...payload,
59
+ name: payload.name ?? current.name,
60
+ provider: payload.provider ?? current.provider,
61
+ sourceFormat: payload.sourceFormat ?? current.sourceFormat,
62
+ };
63
+ }
64
+ function redactUrlCredentials(value) {
65
+ if (value === null || value === undefined) {
66
+ return value;
67
+ }
68
+ return value.replace(URL_CREDENTIALS_PATTERN, `$1${REDACTED}@`);
69
+ }
70
+ export function formatRepositoryTable(repositories) {
71
+ return table([
72
+ { alias: 'ID', value: 'id' },
73
+ { alias: 'NAME', value: 'name' },
74
+ { alias: 'PROVIDER', value: 'provider' },
75
+ { alias: 'SOURCE', value: 'sourceFormat' },
76
+ { alias: 'URI', value: 'uri', wrap: true },
77
+ ], repositories.map((repository) => ({
78
+ id: cellValue(repository.id),
79
+ name: cellValue(repository.name),
80
+ provider: cellValue(repository.provider),
81
+ sourceFormat: cellValue(repository.sourceFormat),
82
+ uri: cellValue(repository.uri),
83
+ })));
84
+ }
85
+ export function formatRepositoryDetail(repository) {
86
+ return [
87
+ `ID: ${cellValue(repository.id)}`,
88
+ `Name: ${cellValue(repository.name)}`,
89
+ `Source Format: ${cellValue(repository.sourceFormat)}`,
90
+ `Provider: ${cellValue(repository.provider)}`,
91
+ `Auth Type: ${cellValue(repository.authType)}`,
92
+ `URI: ${cellValue(repository.uri)}`,
93
+ `Tag Base URL: ${cellValue(repository.tagBaseUrl)}`,
94
+ `Pull Request Base URL: ${cellValue(repository.pullRequestBaseUrl)}`,
95
+ `Commit Base URL: ${cellValue(repository.commitBaseUrl)}`,
96
+ `Branch Base URL: ${cellValue(repository.branchBaseUrl)}`,
97
+ `Copado Tunnel Enabled: ${cellValue(repository.isCopadoTunnelEnabled)}`,
98
+ `Functions Git Cache Allowed: ${cellValue(repository.allowFunctionsGitCache)}`,
99
+ `Username: ${cellValue(repository.username)}`,
100
+ `Password: ${cellValue(repository.password)}`,
101
+ `Extra Headers: ${cellValue(repository.extraHeaders)}`,
102
+ `Pipelines: ${cellValue(repository.pipelines?.length)}`,
103
+ `Snapshots: ${cellValue(repository.snapshots?.length)}`,
104
+ `Created By: ${cellValue(repository.createdBy)}`,
105
+ `Created Date: ${cellValue(repository.createdDate)}`,
106
+ `Last Modified By: ${cellValue(repository.lastModifiedBy)}`,
107
+ `Last Modified Date: ${cellValue(repository.lastModifiedDate)}`,
108
+ ].join('\n');
109
+ }
110
+ //# sourceMappingURL=repository-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository-types.js","sourceRoot":"","sources":["../../src/lib/repository-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAC5C,OAAO,EAEL,6BAA6B,GAC9B,MAAM,sBAAsB,CAAA;AAE7B,MAAM,QAAQ,GAAG,YAAY,CAAA;AAC7B,MAAM,uBAAuB,GAAG,yBAAyB,CAAA;AAEzD,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,IAAI,CAAU,CAAA;AACxD,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,wBAAwB;IACxB,wBAAwB;IACxB,QAAQ;CACA,CAAA;AACV,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,OAAO,CAAU,CAAA;AAoFvD,MAAM,UAAU,oBAAoB;IAClC,OAAO,sBAAsB,CAAA;AAC/B,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,YAAoB;IACrD,OAAO,GAAG,oBAAoB,EAAE,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAA;AACxE,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,YAAoB;IAC1D,OAAO,GAAG,kBAAkB,CAAC,YAAY,CAAC,QAAQ,CAAA;AACpD,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,YAAoB;IAC7D,OAAO,GAAG,kBAAkB,CAAC,YAAY,CAAC,WAAW,CAAA;AACvD,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,QAAkC;IAC9E,MAAM,IAAI,GAAG,6BAA6B,CAAgB,QAAQ,CAAC,CAAA;IACnE,MAAM,IAAI,GAAG,I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