bktide 0.0.1

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 (160) hide show
  1. package/README.md +145 -0
  2. package/WORKFLOW_README.md +65 -0
  3. package/bin/alfred-entrypoint +54 -0
  4. package/dist/commands/BaseCommand.js +159 -0
  5. package/dist/commands/BaseCommand.js.map +1 -0
  6. package/dist/commands/BaseCommandHandler.js +80 -0
  7. package/dist/commands/BaseCommandHandler.js.map +1 -0
  8. package/dist/commands/BuildCommandHandler.js +28 -0
  9. package/dist/commands/BuildCommandHandler.js.map +1 -0
  10. package/dist/commands/HelloCommandHandler.js +6 -0
  11. package/dist/commands/HelloCommandHandler.js.map +1 -0
  12. package/dist/commands/ListAnnotations.js +60 -0
  13. package/dist/commands/ListAnnotations.js.map +1 -0
  14. package/dist/commands/ListBuilds.js +137 -0
  15. package/dist/commands/ListBuilds.js.map +1 -0
  16. package/dist/commands/ListOrganizations.js +27 -0
  17. package/dist/commands/ListOrganizations.js.map +1 -0
  18. package/dist/commands/ListPipelines.js +114 -0
  19. package/dist/commands/ListPipelines.js.map +1 -0
  20. package/dist/commands/ManageToken.js +180 -0
  21. package/dist/commands/ManageToken.js.map +1 -0
  22. package/dist/commands/OrganizationCommandHandler.js +53 -0
  23. package/dist/commands/OrganizationCommandHandler.js.map +1 -0
  24. package/dist/commands/PipelineCommandHandler.js +142 -0
  25. package/dist/commands/PipelineCommandHandler.js.map +1 -0
  26. package/dist/commands/ShowViewer.js +26 -0
  27. package/dist/commands/ShowViewer.js.map +1 -0
  28. package/dist/commands/UserBuildsCommandHandler.js +61 -0
  29. package/dist/commands/UserBuildsCommandHandler.js.map +1 -0
  30. package/dist/commands/ViewerBuildsCommandHandler.js +176 -0
  31. package/dist/commands/ViewerBuildsCommandHandler.js.map +1 -0
  32. package/dist/commands/ViewerCommandHandler.js +46 -0
  33. package/dist/commands/ViewerCommandHandler.js.map +1 -0
  34. package/dist/commands/index.js +8 -0
  35. package/dist/commands/index.js.map +1 -0
  36. package/dist/formatters/BaseFormatter.js +14 -0
  37. package/dist/formatters/BaseFormatter.js.map +1 -0
  38. package/dist/formatters/FormatterFactory.js +48 -0
  39. package/dist/formatters/FormatterFactory.js.map +1 -0
  40. package/dist/formatters/annotations/Formatter.js +10 -0
  41. package/dist/formatters/annotations/Formatter.js.map +1 -0
  42. package/dist/formatters/annotations/JsonFormatter.js +20 -0
  43. package/dist/formatters/annotations/JsonFormatter.js.map +1 -0
  44. package/dist/formatters/annotations/PlainTextFormatter.js +35 -0
  45. package/dist/formatters/annotations/PlainTextFormatter.js.map +1 -0
  46. package/dist/formatters/annotations/index.js +23 -0
  47. package/dist/formatters/annotations/index.js.map +1 -0
  48. package/dist/formatters/builds/AlfredFormatter.js +135 -0
  49. package/dist/formatters/builds/AlfredFormatter.js.map +1 -0
  50. package/dist/formatters/builds/Formatter.js +10 -0
  51. package/dist/formatters/builds/Formatter.js.map +1 -0
  52. package/dist/formatters/builds/JsonFormatter.js +44 -0
  53. package/dist/formatters/builds/JsonFormatter.js.map +1 -0
  54. package/dist/formatters/builds/PlainTextFormatter.js +113 -0
  55. package/dist/formatters/builds/PlainTextFormatter.js.map +1 -0
  56. package/dist/formatters/builds/index.js +26 -0
  57. package/dist/formatters/builds/index.js.map +1 -0
  58. package/dist/formatters/errors/AlfredFormatter.js +110 -0
  59. package/dist/formatters/errors/AlfredFormatter.js.map +1 -0
  60. package/dist/formatters/errors/Formatter.js +98 -0
  61. package/dist/formatters/errors/Formatter.js.map +1 -0
  62. package/dist/formatters/errors/JsonFormatter.js +63 -0
  63. package/dist/formatters/errors/JsonFormatter.js.map +1 -0
  64. package/dist/formatters/errors/PlainTextFormatter.js +52 -0
  65. package/dist/formatters/errors/PlainTextFormatter.js.map +1 -0
  66. package/dist/formatters/errors/index.js +26 -0
  67. package/dist/formatters/errors/index.js.map +1 -0
  68. package/dist/formatters/index.js +9 -0
  69. package/dist/formatters/index.js.map +1 -0
  70. package/dist/formatters/organizations/Formatter.js +10 -0
  71. package/dist/formatters/organizations/Formatter.js.map +1 -0
  72. package/dist/formatters/organizations/JsonFormatter.js +16 -0
  73. package/dist/formatters/organizations/JsonFormatter.js.map +1 -0
  74. package/dist/formatters/organizations/PlainTextFormatter.js +15 -0
  75. package/dist/formatters/organizations/PlainTextFormatter.js.map +1 -0
  76. package/dist/formatters/organizations/index.js +21 -0
  77. package/dist/formatters/organizations/index.js.map +1 -0
  78. package/dist/formatters/pipelines/AlfredFormatter.js +42 -0
  79. package/dist/formatters/pipelines/AlfredFormatter.js.map +1 -0
  80. package/dist/formatters/pipelines/Formatter.js +10 -0
  81. package/dist/formatters/pipelines/Formatter.js.map +1 -0
  82. package/dist/formatters/pipelines/JsonFormatter.js +13 -0
  83. package/dist/formatters/pipelines/JsonFormatter.js.map +1 -0
  84. package/dist/formatters/pipelines/PlainTextFormatter.js +47 -0
  85. package/dist/formatters/pipelines/PlainTextFormatter.js.map +1 -0
  86. package/dist/formatters/pipelines/index.js +28 -0
  87. package/dist/formatters/pipelines/index.js.map +1 -0
  88. package/dist/formatters/token/AlfredFormatter.js +191 -0
  89. package/dist/formatters/token/AlfredFormatter.js.map +1 -0
  90. package/dist/formatters/token/Formatter.js +13 -0
  91. package/dist/formatters/token/Formatter.js.map +1 -0
  92. package/dist/formatters/token/JsonFormatter.js +211 -0
  93. package/dist/formatters/token/JsonFormatter.js.map +1 -0
  94. package/dist/formatters/token/PlainTextFormatter.js +184 -0
  95. package/dist/formatters/token/PlainTextFormatter.js.map +1 -0
  96. package/dist/formatters/token/index.js +26 -0
  97. package/dist/formatters/token/index.js.map +1 -0
  98. package/dist/formatters/viewer/Formatter.js +10 -0
  99. package/dist/formatters/viewer/Formatter.js.map +1 -0
  100. package/dist/formatters/viewer/JsonFormatter.js +20 -0
  101. package/dist/formatters/viewer/JsonFormatter.js.map +1 -0
  102. package/dist/formatters/viewer/PlainTextFormatter.js +20 -0
  103. package/dist/formatters/viewer/PlainTextFormatter.js.map +1 -0
  104. package/dist/formatters/viewer/index.js +21 -0
  105. package/dist/formatters/viewer/index.js.map +1 -0
  106. package/dist/graphql/generated/fragment-masking.js +17 -0
  107. package/dist/graphql/generated/fragment-masking.js.map +1 -0
  108. package/dist/graphql/generated/gql.js +13 -0
  109. package/dist/graphql/generated/gql.js.map +1 -0
  110. package/dist/graphql/generated/graphql.js +852 -0
  111. package/dist/graphql/generated/graphql.js.map +1 -0
  112. package/dist/graphql/generated/index.js +3 -0
  113. package/dist/graphql/generated/index.js.map +1 -0
  114. package/dist/graphql/generated/sdk.js +872 -0
  115. package/dist/graphql/generated/sdk.js.map +1 -0
  116. package/dist/graphql/queries.js +138 -0
  117. package/dist/graphql/queries.js.map +1 -0
  118. package/dist/index.js +271 -0
  119. package/dist/index.js.map +1 -0
  120. package/dist/services/BuildkiteClient.js +520 -0
  121. package/dist/services/BuildkiteClient.js.map +1 -0
  122. package/dist/services/BuildkiteRestClient.js +244 -0
  123. package/dist/services/BuildkiteRestClient.js.map +1 -0
  124. package/dist/services/CacheManager.js +221 -0
  125. package/dist/services/CacheManager.js.map +1 -0
  126. package/dist/services/CredentialManager.js +158 -0
  127. package/dist/services/CredentialManager.js.map +1 -0
  128. package/dist/services/EnhancedBuildkiteClient.js +297 -0
  129. package/dist/services/EnhancedBuildkiteClient.js.map +1 -0
  130. package/dist/services/logger.js +107 -0
  131. package/dist/services/logger.js.map +1 -0
  132. package/dist/types/buildkite.js +5 -0
  133. package/dist/types/buildkite.js.map +1 -0
  134. package/dist/types/credentials.js +2 -0
  135. package/dist/types/credentials.js.map +1 -0
  136. package/dist/types/index.js +3 -0
  137. package/dist/types/index.js.map +1 -0
  138. package/dist/utils/cli-error-handler.js +172 -0
  139. package/dist/utils/cli-error-handler.js.map +1 -0
  140. package/dist/utils/errorUtils.js +59 -0
  141. package/dist/utils/errorUtils.js.map +1 -0
  142. package/dist/utils/parseBuildRef.js +31 -0
  143. package/dist/utils/parseBuildRef.js.map +1 -0
  144. package/dist/utils/textFormatter.js +53 -0
  145. package/dist/utils/textFormatter.js.map +1 -0
  146. package/dist/utils/xdgPaths.js +95 -0
  147. package/dist/utils/xdgPaths.js.map +1 -0
  148. package/env.example +66 -0
  149. package/icons/README.md +68 -0
  150. package/icons/blocked.png +0 -0
  151. package/icons/buildkite.png +0 -0
  152. package/icons/failed.png +0 -0
  153. package/icons/failing.png +0 -0
  154. package/icons/passed.png +0 -0
  155. package/icons/running.png +0 -0
  156. package/icons/scheduled.png +0 -0
  157. package/icons/skipped.png +0 -0
  158. package/icons/unknown.png +0 -0
  159. package/info.plist +734 -0
  160. package/package.json +87 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AlfredFormatter.js","sourceRoot":"/","sources":["formatters/errors/AlfredFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAyC,MAAM,gBAAgB,CAAC;AAE3F;;;;;GAKG;AACH,MAAM,OAAO,eAAgB,SAAQ,kBAAkB;IACrD,IAAI,GAAG,QAAQ,CAAC;IAEhB;;;;;;OAMG;IACH,WAAW,CAAC,MAA2B,EAAE,OAA+B;QACtE,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC7D,MAAM,KAAK,GAAG,EAAE,CAAC;QAEjB,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;YAC/B,sBAAsB;YACtB,KAAK,CAAC,IAAI,CAAC;gBACT,GAAG,EAAE,OAAO;gBACZ,KAAK,EAAE,UAAU,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;gBAC9C,QAAQ,EAAE,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;gBACtC,GAAG,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC;gBAChC,IAAI,EAAE;oBACJ,IAAI,EAAE,iBAAiB;iBACxB;gBACD,KAAK,EAAE,IAAI;aACZ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,CAAC,KAAK,CAAC,CAAC;QAE3C,IAAI,SAAS,EAAE,MAAM,EAAE,CAAC;YACtB,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YAChC,OAAO,cAAc,UAAU,CAAC,OAAO,IAAI,eAAe,EAAE,CAAC;QAC/D,CAAC;QAED,OAAO,GAAG,SAAS,sCAAsC,CAAC;IAC5D,CAAC;CACF","sourcesContent":["import { BaseErrorFormatter, ErrorFormatter, ErrorFormatterOptions } from './Formatter.js';\n\n/**\n * Alfred formatter for errors\n * \n * This formatter provides Alfred-compatible JSON output for error conditions\n * that can be processed by Alfred workflows\n */\nexport class AlfredFormatter extends BaseErrorFormatter implements ErrorFormatter {\n name = 'alfred';\n\n /**\n * Format one or more errors for display in Alfred JSON format\n * \n * @param errors The error(s) to format\n * @param options Formatting options\n * @returns Alfred JSON formatted error message\n */\n formatError(errors: unknown | unknown[], options?: ErrorFormatterOptions): string {\n const errorArray = Array.isArray(errors) ? errors : [errors];\n const items = [];\n\n for (const error of errorArray) {\n // Add main error item\n items.push({\n uid: 'error',\n title: `Error: ${this.getErrorMessage(error)}`,\n subtitle: this.getErrorSubtitle(error),\n arg: this.getErrorMessage(error),\n icon: {\n path: 'icons/error.png'\n },\n valid: true\n });\n\n // Add stack trace items if debug is enabled\n if (options?.debug) {\n const stack = this.getStackTrace(error);\n if (stack) {\n const stackItems = stack.split('\\n').map((line, index) => ({\n uid: `stack-${index}`,\n title: line.trim(),\n subtitle: 'Stack trace line',\n arg: line,\n icon: {\n path: 'icons/stack.png'\n },\n valid: true\n }));\n items.push(...stackItems);\n }\n\n // Add API errors if present\n const apiErrors = this.getApiErrors(error);\n if (apiErrors?.length) {\n apiErrors.forEach((apiError, index) => {\n items.push({\n uid: `api-error-${index}`,\n title: `API Error: ${apiError.message || 'Unknown error'}`,\n subtitle: apiError.path ? `Path: ${apiError.path.join('.')}` : 'API Error',\n arg: apiError.message || 'Unknown error',\n icon: {\n path: 'icons/api-error.png'\n },\n valid: true\n });\n });\n }\n\n // Add request details if available\n const request = this.getRequestDetails(error);\n if (request) {\n items.push({\n uid: 'request-details',\n title: 'Request Details',\n subtitle: `${request.method || 'Unknown'} ${request.url || 'Unknown URL'}`,\n arg: `${request.method || 'Unknown'} ${request.url || 'Unknown URL'}`,\n icon: {\n path: 'icons/request.png'\n },\n valid: false\n });\n }\n }\n }\n\n // Add system info if debug is enabled\n if (options?.debug) {\n items.push({\n uid: 'system-info',\n title: 'System Information',\n subtitle: `Node ${process.version} on ${process.platform} (${process.arch})`,\n arg: `Node ${process.version} on ${process.platform} (${process.arch})`,\n icon: {\n path: 'icons/info.png'\n },\n valid: false\n });\n }\n\n return JSON.stringify({ items });\n }\n\n /**\n * Get a subtitle for the error to display in Alfred\n * @param error The error object\n * @returns A subtitle string\n */\n private getErrorSubtitle(error: unknown): string {\n const errorName = this.getErrorName(error);\n const apiErrors = this.getApiErrors(error);\n \n if (apiErrors?.length) {\n const firstError = apiErrors[0];\n return `API Error: ${firstError.message || 'Unknown error'}`;\n }\n \n return `${errorName} - Press Enter to copy error message`;\n }\n} "]}
@@ -0,0 +1,98 @@
1
+ import { logger } from '../../services/logger.js';
2
+ /**
3
+ * Base class for error formatters
4
+ */
5
+ export class BaseErrorFormatter {
6
+ format(data, formatFn, options) {
7
+ if (options?.debug) {
8
+ logger.debug(`Formatting with ${this.name} formatter`);
9
+ }
10
+ return formatFn(data, options);
11
+ }
12
+ /**
13
+ * Extract error message from an error object
14
+ * @param error The error object
15
+ * @returns The error message
16
+ */
17
+ getErrorMessage(error) {
18
+ if (error instanceof Error) {
19
+ return error.message;
20
+ }
21
+ else if (error && typeof error === 'object') {
22
+ const errorObj = error;
23
+ if (errorObj.message && typeof errorObj.message === 'string') {
24
+ return errorObj.message;
25
+ }
26
+ return 'Unknown object error';
27
+ }
28
+ return String(error);
29
+ }
30
+ /**
31
+ * Extract error name from an error object
32
+ * @param error The error object
33
+ * @returns The error name
34
+ */
35
+ getErrorName(error) {
36
+ if (error instanceof Error) {
37
+ return error.name;
38
+ }
39
+ else if (error && typeof error === 'object') {
40
+ const errorObj = error;
41
+ if (errorObj.name && typeof errorObj.name === 'string') {
42
+ return errorObj.name;
43
+ }
44
+ }
45
+ return 'Error';
46
+ }
47
+ /**
48
+ * Extract stack trace from an error object
49
+ * @param error The error object
50
+ * @returns The stack trace or undefined
51
+ */
52
+ getStackTrace(error) {
53
+ if (error instanceof Error) {
54
+ return error.stack;
55
+ }
56
+ else if (error && typeof error === 'object') {
57
+ const errorObj = error;
58
+ if (errorObj.stack && typeof errorObj.stack === 'string') {
59
+ return errorObj.stack;
60
+ }
61
+ }
62
+ return undefined;
63
+ }
64
+ /**
65
+ * Extract API errors from an error object
66
+ * @param error The error object
67
+ * @returns Array of API errors or undefined
68
+ */
69
+ getApiErrors(error) {
70
+ if (error && typeof error === 'object') {
71
+ const errorObj = error;
72
+ const response = errorObj.response;
73
+ if (response?.errors && Array.isArray(response.errors)) {
74
+ return response.errors;
75
+ }
76
+ }
77
+ return undefined;
78
+ }
79
+ /**
80
+ * Extract request details from an error object
81
+ * @param error The error object
82
+ * @returns Request details or undefined
83
+ */
84
+ getRequestDetails(error) {
85
+ if (error && typeof error === 'object') {
86
+ const errorObj = error;
87
+ const request = errorObj.request;
88
+ if (request) {
89
+ return {
90
+ url: request.url,
91
+ method: request.method
92
+ };
93
+ }
94
+ }
95
+ return undefined;
96
+ }
97
+ }
98
+ //# sourceMappingURL=Formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Formatter.js","sourceRoot":"/","sources":["formatters/errors/Formatter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAmClD;;GAEG;AACH,MAAM,OAAgB,kBAAkB;IAKtC,MAAM,CAAI,IAAS,EAAE,QAA2D,EAAE,OAA0B;QAC1G,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,MAAM,CAAC,KAAK,CAAC,mBAAmB,IAAI,CAA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C,KAAK,IAAI,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACzD,OAAO,QAAQ,CAAC,KAAK,CAAC;YACxB,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACO,YAAY,CAAC,KAAc;QACnC,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACvC,MAAM,QAAQ,GAAG,KAAgC,CAAC;YAClD,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAwC,CAAC;YACnE,IAAI,QAAQ,EAAE,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBACvD,OAAO,QAAQ,CAAC,MAAM,CAAC;YACzB,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACO,iBAAiB,CAAC,KAAc;QACxC,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACvC,MAAM,QAAQ,GAAG,KAAgC,CAAC;YAClD,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAiC,CAAC;YAC3D,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO;oBACL,GAAG,EAAE,OAAO,CAAC,GAAG;oBAChB,MAAM,EAAE,OAAO,CAAC,MAAM;iBACvB,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { BaseFormatter as BaseFormatterInterface, FormatterOptions } from '../BaseFormatter.js';\nimport { logger } from '../../services/logger.js';\n\n/**\n * Additional options specific to error formatting\n */\nexport interface ErrorFormatterOptions extends FormatterOptions {\n exitOnError?: boolean;\n}\n\ninterface ApiErrorResponse {\n errors?: Array<{\n message?: string;\n path?: string[];\n locations?: Array<{ line: number; column: number }>;\n }>;\n}\n\ninterface ApiRequest {\n url?: string;\n method?: string;\n}\n\n/**\n * Interface for error formatters\n */\nexport interface ErrorFormatter extends BaseFormatterInterface {\n /**\n * Format one or more errors for display\n * @param errors The error(s) to format\n * @param options Formatting options\n * @returns Formatted error message\n */\n formatError(errors: unknown | unknown[], options?: ErrorFormatterOptions): string;\n}\n\n/**\n * Base class for error formatters\n */\nexport abstract class BaseErrorFormatter implements ErrorFormatter {\n abstract name: string;\n \n abstract formatError(errors: unknown | unknown[], options?: ErrorFormatterOptions): string;\n \n format<T>(data: T[], formatFn: (data: T[], options?: FormatterOptions) => string, options?: FormatterOptions): string {\n if (options?.debug) {\n logger.debug(`Formatting with ${this.name} formatter`);\n }\n return formatFn(data, options);\n }\n\n /**\n * Extract error message from an error object\n * @param error The error object\n * @returns The error message\n */\n protected getErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message;\n } else if (error && typeof error === 'object') {\n const errorObj = error as Record<string, unknown>;\n if (errorObj.message && typeof errorObj.message === 'string') {\n return errorObj.message;\n }\n return 'Unknown object error';\n }\n return String(error);\n }\n\n /**\n * Extract error name from an error object\n * @param error The error object\n * @returns The error name\n */\n protected getErrorName(error: unknown): string {\n if (error instanceof Error) {\n return error.name;\n } else if (error && typeof error === 'object') {\n const errorObj = error as Record<string, unknown>;\n if (errorObj.name && typeof errorObj.name === 'string') {\n return errorObj.name;\n }\n }\n return 'Error';\n }\n\n /**\n * Extract stack trace from an error object\n * @param error The error object\n * @returns The stack trace or undefined\n */\n protected getStackTrace(error: unknown): string | undefined {\n if (error instanceof Error) {\n return error.stack;\n } else if (error && typeof error === 'object') {\n const errorObj = error as Record<string, unknown>;\n if (errorObj.stack && typeof errorObj.stack === 'string') {\n return errorObj.stack;\n }\n }\n return undefined;\n }\n\n /**\n * Extract API errors from an error object\n * @param error The error object\n * @returns Array of API errors or undefined\n */\n protected getApiErrors(error: unknown): ApiErrorResponse['errors'] | undefined {\n if (error && typeof error === 'object') {\n const errorObj = error as Record<string, unknown>;\n const response = errorObj.response as ApiErrorResponse | undefined;\n if (response?.errors && Array.isArray(response.errors)) {\n return response.errors;\n }\n }\n return undefined;\n }\n\n /**\n * Extract request details from an error object\n * @param error The error object\n * @returns Request details or undefined\n */\n protected getRequestDetails(error: unknown): ApiRequest | undefined {\n if (error && typeof error === 'object') {\n const errorObj = error as Record<string, unknown>;\n const request = errorObj.request as ApiRequest | undefined;\n if (request) {\n return {\n url: request.url,\n method: request.method\n };\n }\n }\n return undefined;\n }\n} "]}
@@ -0,0 +1,63 @@
1
+ import { BaseErrorFormatter } from './Formatter.js';
2
+ /**
3
+ * JSON formatter for errors
4
+ */
5
+ export class JsonFormatter extends BaseErrorFormatter {
6
+ name = 'json';
7
+ /**
8
+ * Format one or more errors for display in JSON format
9
+ *
10
+ * @param errors The error(s) to format
11
+ * @param options Formatting options
12
+ * @returns JSON formatted error message
13
+ */
14
+ formatError(errors, options) {
15
+ const errorArray = Array.isArray(errors) ? errors : [errors];
16
+ const formattedErrors = errorArray.map(error => this.formatSingleError(error, options?.debug));
17
+ const result = {
18
+ success: false,
19
+ errors: formattedErrors,
20
+ debug: options?.debug ? this.getDebugInfo() : undefined
21
+ };
22
+ return JSON.stringify(result, null, 2);
23
+ }
24
+ /**
25
+ * Format a single error object
26
+ * @param error The error to format
27
+ * @param includeDebug Whether to include debug information
28
+ * @returns Formatted error object
29
+ */
30
+ formatSingleError(error, includeDebug = false) {
31
+ const result = {
32
+ name: this.getErrorName(error),
33
+ message: this.getErrorMessage(error)
34
+ };
35
+ if (includeDebug) {
36
+ const stack = this.getStackTrace(error);
37
+ if (stack) {
38
+ result.stack = stack;
39
+ }
40
+ }
41
+ const apiErrors = this.getApiErrors(error);
42
+ if (apiErrors?.length) {
43
+ result.apiErrors = apiErrors;
44
+ }
45
+ const request = this.getRequestDetails(error);
46
+ if (request && includeDebug) {
47
+ result.request = request;
48
+ }
49
+ return result;
50
+ }
51
+ /**
52
+ * Get debug information about the system
53
+ * @returns Debug information object
54
+ */
55
+ getDebugInfo() {
56
+ return {
57
+ timestamp: new Date().toISOString(),
58
+ nodeVersion: process.version,
59
+ platform: `${process.platform} (${process.arch})`
60
+ };
61
+ }
62
+ }
63
+ //# sourceMappingURL=JsonFormatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonFormatter.js","sourceRoot":"/","sources":["formatters/errors/JsonFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAyC,MAAM,gBAAgB,CAAC;AAE3F;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,kBAAkB;IACnD,IAAI,GAAG,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,WAAW,CAAC,MAA2B,EAAE,OAA+B;QACtE,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC7D,MAAM,eAAe,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;QAE/F,MAAM,MAAM,GAAG;YACb,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,eAAe;YACvB,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,SAAS;SACxD,CAAC;QAEF,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACK,iBAAiB,CAAC,KAAc,EAAE,YAAY,GAAG,KAAK;QAC5D,MAAM,MAAM,GAA4B;YACtC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;YAC9B,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC;SACrC,CAAC;QAEF,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACxC,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;YACvB,CAAC;QACH,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,SAAS,EAAE,MAAM,EAAE,CAAC;YACtB,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;QAC/B,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,OAAO,IAAI,YAAY,EAAE,CAAC;YAC5B,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QAC3B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACK,YAAY;QAClB,OAAO;YACL,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,WAAW,EAAE,OAAO,CAAC,OAAO;YAC5B,QAAQ,EAAE,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,IAAI,GAAG;SAClD,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { BaseErrorFormatter, ErrorFormatter, ErrorFormatterOptions } from './Formatter.js';\n\n/**\n * JSON formatter for errors\n */\nexport class JsonFormatter extends BaseErrorFormatter implements ErrorFormatter {\n name = 'json';\n\n /**\n * Format one or more errors for display in JSON format\n * \n * @param errors The error(s) to format\n * @param options Formatting options\n * @returns JSON formatted error message\n */\n formatError(errors: unknown | unknown[], options?: ErrorFormatterOptions): string {\n const errorArray = Array.isArray(errors) ? errors : [errors];\n const formattedErrors = errorArray.map(error => this.formatSingleError(error, options?.debug));\n \n const result = {\n success: false,\n errors: formattedErrors,\n debug: options?.debug ? this.getDebugInfo() : undefined\n };\n\n return JSON.stringify(result, null, 2);\n }\n\n /**\n * Format a single error object\n * @param error The error to format\n * @param includeDebug Whether to include debug information\n * @returns Formatted error object\n */\n private formatSingleError(error: unknown, includeDebug = false): Record<string, unknown> {\n const result: Record<string, unknown> = {\n name: this.getErrorName(error),\n message: this.getErrorMessage(error)\n };\n\n if (includeDebug) {\n const stack = this.getStackTrace(error);\n if (stack) {\n result.stack = stack;\n }\n }\n\n const apiErrors = this.getApiErrors(error);\n if (apiErrors?.length) {\n result.apiErrors = apiErrors;\n }\n\n const request = this.getRequestDetails(error);\n if (request && includeDebug) {\n result.request = request;\n }\n\n return result;\n }\n\n /**\n * Get debug information about the system\n * @returns Debug information object\n */\n private getDebugInfo(): Record<string, string> {\n return {\n timestamp: new Date().toISOString(),\n nodeVersion: process.version,\n platform: `${process.platform} (${process.arch})`\n };\n }\n} "]}
@@ -0,0 +1,52 @@
1
+ import { BaseErrorFormatter } from './Formatter.js';
2
+ /**
3
+ * Plain text formatter for errors
4
+ */
5
+ export class PlainTextFormatter extends BaseErrorFormatter {
6
+ name = 'plain';
7
+ /**
8
+ * Format one or more errors for display in plain text
9
+ *
10
+ * @param errors The error(s) to format
11
+ * @param options Formatting options
12
+ * @returns Formatted error message
13
+ */
14
+ formatError(errors, options) {
15
+ const errorArray = Array.isArray(errors) ? errors : [errors];
16
+ let output = '';
17
+ for (const error of errorArray) {
18
+ if (output)
19
+ output += '\n\n'; // Add spacing between multiple errors
20
+ // Add error header
21
+ output += `\x1b[31m${this.getErrorName(error)}: ${this.getErrorMessage(error)}\x1b[0m\n`;
22
+ // Add stack trace if available and debug is enabled
23
+ const stack = this.getStackTrace(error);
24
+ if (stack && options?.debug) {
25
+ output += `\n\x1b[33mStack Trace:\x1b[0m\n${stack}\n`;
26
+ }
27
+ // Add API errors if present
28
+ const apiErrors = this.getApiErrors(error);
29
+ if (apiErrors?.length) {
30
+ output += '\n\x1b[33mAPI Errors:\x1b[0m\n';
31
+ apiErrors.forEach((apiError, index) => {
32
+ output += ` Error ${index + 1}: ${apiError.message || 'Unknown error'}\n`;
33
+ if (apiError.path)
34
+ output += ` Path: ${apiError.path.join('.')}\n`;
35
+ if (apiError.locations)
36
+ output += ` Locations: ${JSON.stringify(apiError.locations)}\n`;
37
+ });
38
+ }
39
+ // Add request details if available and debug is enabled
40
+ const request = this.getRequestDetails(error);
41
+ if (request && options?.debug) {
42
+ output += '\n\x1b[36mRequest Details:\x1b[0m\n';
43
+ if (request.url)
44
+ output += ` URL: ${request.url}\n`;
45
+ if (request.method)
46
+ output += ` Method: ${request.method}\n`;
47
+ }
48
+ }
49
+ return output;
50
+ }
51
+ }
52
+ //# sourceMappingURL=PlainTextFormatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlainTextFormatter.js","sourceRoot":"/","sources":["formatters/errors/PlainTextFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAyC,MAAM,gBAAgB,CAAC;AAE3F;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IACxD,IAAI,GAAG,OAAO,CAAC;IAEf;;;;;;OAMG;IACH,WAAW,CAAC,MAA2B,EAAE,OAA+B;QACtE,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC7D,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;YAC/B,IAAI,MAAM;gBAAE,MAAM,IAAI,MAAM,CAAC,CAAC,sCAAsC;YAEpE,mBAAmB;YACnB,MAAM,IAAI,WAAW,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC;YAEzF,oDAAoD;YACpD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACxC,IAAI,KAAK,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;gBAC5B,MAAM,IAAI,kCAAkC,KAAK,IAAI,CAAC;YACxD,CAAC;YAED,4BAA4B;YAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAC3C,IAAI,SAAS,EAAE,MAAM,EAAE,CAAC;gBACtB,MAAM,IAAI,gCAAgC,CAAC;gBAC3C,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;oBACpC,MAAM,IAAI,WAAW,KAAK,GAAG,CAAC,KAAK,QAAQ,CAAC,OAAO,IAAI,eAAe,IAAI,CAAC;oBAC3E,IAAI,QAAQ,CAAC,IAAI;wBAAE,MAAM,IAAI,WAAW,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;oBACpE,IAAI,QAAQ,CAAC,SAAS;wBAAE,MAAM,IAAI,gBAAgB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC;gBAC3F,CAAC,CAAC,CAAC;YACL,CAAC;YAED,wDAAwD;YACxD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC9C,IAAI,OAAO,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;gBAC9B,MAAM,IAAI,qCAAqC,CAAC;gBAChD,IAAI,OAAO,CAAC,GAAG;oBAAE,MAAM,IAAI,UAAU,OAAO,CAAC,GAAG,IAAI,CAAC;gBACrD,IAAI,OAAO,CAAC,MAAM;oBAAE,MAAM,IAAI,aAAa,OAAO,CAAC,MAAM,IAAI,CAAC;YAChE,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { BaseErrorFormatter, ErrorFormatter, ErrorFormatterOptions } from './Formatter.js';\n\n/**\n * Plain text formatter for errors\n */\nexport class PlainTextFormatter extends BaseErrorFormatter implements ErrorFormatter {\n name = 'plain';\n\n /**\n * Format one or more errors for display in plain text\n * \n * @param errors The error(s) to format\n * @param options Formatting options\n * @returns Formatted error message\n */\n formatError(errors: unknown | unknown[], options?: ErrorFormatterOptions): string {\n const errorArray = Array.isArray(errors) ? errors : [errors];\n let output = '';\n\n for (const error of errorArray) {\n if (output) output += '\\n\\n'; // Add spacing between multiple errors\n\n // Add error header\n output += `\\x1b[31m${this.getErrorName(error)}: ${this.getErrorMessage(error)}\\x1b[0m\\n`;\n\n // Add stack trace if available and debug is enabled\n const stack = this.getStackTrace(error);\n if (stack && options?.debug) {\n output += `\\n\\x1b[33mStack Trace:\\x1b[0m\\n${stack}\\n`;\n }\n\n // Add API errors if present\n const apiErrors = this.getApiErrors(error);\n if (apiErrors?.length) {\n output += '\\n\\x1b[33mAPI Errors:\\x1b[0m\\n';\n apiErrors.forEach((apiError, index) => {\n output += ` Error ${index + 1}: ${apiError.message || 'Unknown error'}\\n`;\n if (apiError.path) output += ` Path: ${apiError.path.join('.')}\\n`;\n if (apiError.locations) output += ` Locations: ${JSON.stringify(apiError.locations)}\\n`;\n });\n }\n\n // Add request details if available and debug is enabled\n const request = this.getRequestDetails(error);\n if (request && options?.debug) {\n output += '\\n\\x1b[36mRequest Details:\\x1b[0m\\n';\n if (request.url) output += ` URL: ${request.url}\\n`;\n if (request.method) output += ` Method: ${request.method}\\n`;\n }\n }\n\n return output;\n }\n} "]}
@@ -0,0 +1,26 @@
1
+ import { PlainTextFormatter } from './PlainTextFormatter.js';
2
+ import { JsonFormatter } from './JsonFormatter.js';
3
+ import { AlfredFormatter } from './AlfredFormatter.js';
4
+ import { logger } from '../../services/logger.js';
5
+ /**
6
+ * Get the appropriate error formatter based on the format string
7
+ * @param format The format to use ('plain', 'json', or 'alfred')
8
+ * @returns An ErrorFormatter instance
9
+ */
10
+ export function getErrorFormatter(format = 'plain') {
11
+ // Normalize the format string
12
+ const normalizedFormat = format.toLowerCase().trim();
13
+ switch (normalizedFormat) {
14
+ case 'json':
15
+ return new JsonFormatter();
16
+ case 'alfred':
17
+ return new AlfredFormatter();
18
+ case 'plain':
19
+ case 'text':
20
+ return new PlainTextFormatter();
21
+ default:
22
+ logger.warn(`Unknown format '${format}', defaulting to plain text for error output`);
23
+ return new PlainTextFormatter();
24
+ }
25
+ }
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["formatters/errors/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB,OAAO;IACxD,8BAA8B;IAC9B,MAAM,gBAAgB,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IAErD,QAAQ,gBAAgB,EAAE,CAAC;QACzB,KAAK,MAAM;YACT,OAAO,IAAI,aAAa,EAAE,CAAC;QAC7B,KAAK,QAAQ;YACX,OAAO,IAAI,eAAe,EAAE,CAAC;QAC/B,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,OAAO,IAAI,kBAAkB,EAAE,CAAC;QAClC;YACE,MAAM,CAAC,IAAI,CAAC,mBAAmB,MAAM,8CAA8C,CAAC,CAAC;YACrF,OAAO,IAAI,kBAAkB,EAAE,CAAC;IACpC,CAAC;AACH,CAAC","sourcesContent":["import { ErrorFormatter, ErrorFormatterOptions } from './Formatter.js';\nimport { PlainTextFormatter } from './PlainTextFormatter.js';\nimport { JsonFormatter } from './JsonFormatter.js';\nimport { AlfredFormatter } from './AlfredFormatter.js';\nimport { logger } from '../../services/logger.js';\n\n/**\n * Get the appropriate error formatter based on the format string\n * @param format The format to use ('plain', 'json', or 'alfred')\n * @returns An ErrorFormatter instance\n */\nexport function getErrorFormatter(format: string = 'plain'): ErrorFormatter {\n // Normalize the format string\n const normalizedFormat = format.toLowerCase().trim();\n \n switch (normalizedFormat) {\n case 'json':\n return new JsonFormatter();\n case 'alfred':\n return new AlfredFormatter();\n case 'plain':\n case 'text':\n return new PlainTextFormatter();\n default:\n logger.warn(`Unknown format '${format}', defaulting to plain text for error output`);\n return new PlainTextFormatter();\n }\n}\n\nexport { ErrorFormatter, ErrorFormatterOptions }; "]}
@@ -0,0 +1,9 @@
1
+ import { getPipelineFormatter } from './pipelines/index.js';
2
+ import { getBuildFormatter } from './builds/index.js';
3
+ import { getViewerFormatter } from './viewer/index.js';
4
+ import { getOrganizationFormatter } from './organizations/index.js';
5
+ import { FormatterFactory, FormatterType } from './FormatterFactory.js';
6
+ import { getErrorFormatter } from './errors/index.js';
7
+ import { getAnnotationFormatter } from './annotations/index.js';
8
+ export { getPipelineFormatter, getBuildFormatter, getViewerFormatter, getOrganizationFormatter, getErrorFormatter, getAnnotationFormatter, FormatterFactory, FormatterType };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["formatters/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAkB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAmB,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAyB,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAyC,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,EAAuB,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErF,OAAO,EAGL,oBAAoB,EAEpB,iBAAiB,EAEjB,kBAAkB,EAElB,wBAAwB,EAGxB,iBAAiB,EAEjB,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,EACd,CAAC","sourcesContent":["import { FormatterOptions } from './BaseFormatter.js';\nimport { PipelineFormatter, getPipelineFormatter } from './pipelines/index.js';\nimport { BuildFormatter, getBuildFormatter } from './builds/index.js';\nimport { ViewerFormatter, getViewerFormatter } from './viewer/index.js';\nimport { OrganizationFormatter, getOrganizationFormatter } from './organizations/index.js';\nimport { FormatterFactory, FormatterType } from './FormatterFactory.js';\nimport { ErrorFormatter, ErrorFormatterOptions, getErrorFormatter } from './errors/index.js';\nimport { AnnotationFormatter, getAnnotationFormatter } from './annotations/index.js';\n\nexport { \n FormatterOptions,\n PipelineFormatter, \n getPipelineFormatter,\n BuildFormatter,\n getBuildFormatter,\n ViewerFormatter,\n getViewerFormatter,\n OrganizationFormatter,\n getOrganizationFormatter,\n ErrorFormatter,\n ErrorFormatterOptions,\n getErrorFormatter,\n AnnotationFormatter,\n getAnnotationFormatter,\n FormatterFactory,\n FormatterType\n}; "]}
@@ -0,0 +1,10 @@
1
+ import { logger } from '../../services/logger.js';
2
+ export class BaseFormatter {
3
+ format(data, formatFn, options) {
4
+ if (options?.debug) {
5
+ logger.debug(`Formatting with ${this.name} formatter`);
6
+ }
7
+ return formatFn(data, options);
8
+ }
9
+ }
10
+ //# sourceMappingURL=Formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Formatter.js","sourceRoot":"/","sources":["formatters/organizations/Formatter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAMlD,MAAM,OAAgB,aAAa;IAKjC,MAAM,CAAI,IAAS,EAAE,QAA2D,EAAE,OAA0B;QAC1G,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,MAAM,CAAC,KAAK,CAAC,mBAAmB,IAAI,CAAC,IAAI,YAAY,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;CACF","sourcesContent":["import { BaseFormatter as BaseFormatterInterface, FormatterOptions } from '../BaseFormatter.js';\nimport { Organization } from '../../types/index.js';\nimport { logger } from '../../services/logger.js';\n\nexport interface OrganizationFormatter extends BaseFormatterInterface {\n formatOrganizations(organizations: Organization[], options?: FormatterOptions): string;\n}\n\nexport abstract class BaseFormatter implements OrganizationFormatter {\n abstract name: string;\n \n abstract formatOrganizations(organizations: Organization[], options?: FormatterOptions): string;\n \n format<T>(data: T[], formatFn: (data: T[], options?: FormatterOptions) => string, options?: FormatterOptions): string {\n if (options?.debug) {\n logger.debug(`Formatting with ${this.name} formatter`);\n }\n return formatFn(data, options);\n }\n} "]}
@@ -0,0 +1,16 @@
1
+ import { BaseFormatter } from './Formatter.js';
2
+ export class JsonFormatter extends BaseFormatter {
3
+ name = 'json';
4
+ formatOrganizations(organizations, _options) {
5
+ if (!organizations || organizations.length === 0) {
6
+ return JSON.stringify({ organizations: [] });
7
+ }
8
+ return JSON.stringify({
9
+ organizations: organizations.map(org => ({
10
+ name: org.name,
11
+ slug: org.slug
12
+ }))
13
+ }, null, 2);
14
+ }
15
+ }
16
+ //# sourceMappingURL=JsonFormatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonFormatter.js","sourceRoot":"/","sources":["formatters/organizations/JsonFormatter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C,IAAI,GAAG,MAAM,CAAC;IAEd,mBAAmB,CAAC,aAA6B,EAAE,QAA2B;QAC5E,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjD,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;YACpB,aAAa,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACvC,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,IAAI,EAAE,GAAG,CAAC,IAAI;aACf,CAAC,CAAC;SACJ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACd,CAAC;CACF","sourcesContent":["import { FormatterOptions } from '../BaseFormatter.js';\nimport { BaseFormatter } from './Formatter.js';\nimport { Organization } from '../../types/index.js';\n\nexport class JsonFormatter extends BaseFormatter {\n name = 'json';\n \n formatOrganizations(organizations: Organization[], _options?: FormatterOptions): string {\n if (!organizations || organizations.length === 0) {\n return JSON.stringify({ organizations: [] });\n }\n\n return JSON.stringify({\n organizations: organizations.map(org => ({\n name: org.name,\n slug: org.slug\n }))\n }, null, 2);\n }\n} "]}
@@ -0,0 +1,15 @@
1
+ import { BaseFormatter } from './Formatter.js';
2
+ export class PlainTextFormatter extends BaseFormatter {
3
+ name = 'plain-text';
4
+ formatOrganizations(organizations, _options) {
5
+ if (!organizations || organizations.length === 0) {
6
+ return 'No organizations found.';
7
+ }
8
+ let output = 'Your organizations:\n';
9
+ organizations.forEach(org => {
10
+ output += `- ${org.name} (${org.slug})\n`;
11
+ });
12
+ return output.trim();
13
+ }
14
+ }
15
+ //# sourceMappingURL=PlainTextFormatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlainTextFormatter.js","sourceRoot":"/","sources":["formatters/organizations/PlainTextFormatter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,MAAM,OAAO,kBAAmB,SAAQ,aAAa;IACnD,IAAI,GAAG,YAAY,CAAC;IAEpB,mBAAmB,CAAC,aAA6B,EAAE,QAA2B;QAC5E,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjD,OAAO,yBAAyB,CAAC;QACnC,CAAC;QAED,IAAI,MAAM,GAAG,uBAAuB,CAAC;QACrC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1B,MAAM,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,CAAC;QAC5C,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;CACF","sourcesContent":["import { FormatterOptions } from '../BaseFormatter.js';\nimport { BaseFormatter } from './Formatter.js';\nimport { Organization } from '../../types/index.js';\n\nexport class PlainTextFormatter extends BaseFormatter {\n name = 'plain-text';\n \n formatOrganizations(organizations: Organization[], _options?: FormatterOptions): string {\n if (!organizations || organizations.length === 0) {\n return 'No organizations found.';\n }\n\n let output = 'Your organizations:\\n';\n organizations.forEach(org => {\n output += `- ${org.name} (${org.slug})\\n`;\n });\n \n return output.trim();\n }\n} "]}
@@ -0,0 +1,21 @@
1
+ import { PlainTextFormatter } from './PlainTextFormatter.js';
2
+ import { JsonFormatter } from './JsonFormatter.js';
3
+ import { logger } from '../../services/logger.js';
4
+ /**
5
+ * Factory function to create the appropriate formatter for organization data
6
+ * @param format The format to use
7
+ * @returns An OrganizationFormatter instance
8
+ */
9
+ export function getOrganizationFormatter(format = 'plain') {
10
+ switch (format.toLowerCase()) {
11
+ case 'plain':
12
+ case 'text':
13
+ return new PlainTextFormatter();
14
+ case 'json':
15
+ return new JsonFormatter();
16
+ default:
17
+ logger.warn(`Unknown format '${format}', defaulting to plain text`);
18
+ return new PlainTextFormatter();
19
+ }
20
+ }
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["formatters/organizations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,SAAiB,OAAO;IAC/D,QAAQ,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;QAC7B,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,OAAO,IAAI,kBAAkB,EAAE,CAAC;QAClC,KAAK,MAAM;YACT,OAAO,IAAI,aAAa,EAAE,CAAC;QAC7B;YACE,MAAM,CAAC,IAAI,CAAC,mBAAmB,MAAM,6BAA6B,CAAC,CAAC;YACpE,OAAO,IAAI,kBAAkB,EAAE,CAAC;IACpC,CAAC;AACH,CAAC","sourcesContent":["import { PlainTextFormatter } from './PlainTextFormatter.js';\nimport { JsonFormatter } from './JsonFormatter.js';\nimport { OrganizationFormatter } from './Formatter.js';\nimport { logger } from '../../services/logger.js';\n\n/**\n * Factory function to create the appropriate formatter for organization data\n * @param format The format to use\n * @returns An OrganizationFormatter instance\n */\nexport function getOrganizationFormatter(format: string = 'plain'): OrganizationFormatter {\n switch (format.toLowerCase()) {\n case 'plain':\n case 'text':\n return new PlainTextFormatter();\n case 'json':\n return new JsonFormatter();\n default:\n logger.warn(`Unknown format '${format}', defaulting to plain text`);\n return new PlainTextFormatter();\n }\n}\n\nexport { OrganizationFormatter }; "]}
@@ -0,0 +1,42 @@
1
+ import { BaseFormatter } from './Formatter.js';
2
+ export class AlfredFormatter extends BaseFormatter {
3
+ name = 'alfred';
4
+ formatPipelines(pipelines, _organizations, _options) {
5
+ // Format pipelines as Alfred-compatible JSON items
6
+ const alfredItems = pipelines.map((pipeline) => {
7
+ // Generate web URL for the pipeline (if not already present)
8
+ const pipelineUrl = pipeline.url ||
9
+ `https://buildkite.com/${pipeline.organization}/${pipeline.slug}`;
10
+ const uid = pipeline.uuid;
11
+ const title = pipeline.slug;
12
+ const subtitle = pipeline.description || '';
13
+ const autocomplete = `${pipeline.organization}/${pipeline.name}`;
14
+ const match = `${pipeline.organization}/${pipeline.slug}`;
15
+ return {
16
+ uid: uid,
17
+ title: title,
18
+ subtitle: subtitle,
19
+ match: match,
20
+ arg: pipelineUrl,
21
+ autocomplete: autocomplete,
22
+ mods: {
23
+ alt: {
24
+ subtitle: `Organization: ${pipeline.organization}`,
25
+ arg: pipelineUrl
26
+ },
27
+ cmd: {
28
+ subtitle: `Name: ${pipeline.name}`,
29
+ arg: pipelineUrl
30
+ }
31
+ },
32
+ text: {
33
+ copy: pipelineUrl,
34
+ largetype: `${pipeline.name}\nOrganization: ${pipeline.organization}\nSlug: ${pipeline.slug}`
35
+ }
36
+ };
37
+ });
38
+ // Return formatted JSON for Alfred
39
+ return JSON.stringify({ items: alfredItems }, null, 2);
40
+ }
41
+ }
42
+ //# sourceMappingURL=AlfredFormatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AlfredFormatter.js","sourceRoot":"/","sources":["formatters/pipelines/AlfredFormatter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,MAAM,OAAO,eAAgB,SAAQ,aAAa;IAChD,IAAI,GAAG,QAAQ,CAAC;IAEhB,eAAe,CAAC,SAAqB,EAAE,cAAwB,EAAE,QAA2B;QAC1F,mDAAmD;QACnD,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAkB,EAAE,EAAE;YACvD,6DAA6D;YAC7D,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG;gBAC9B,yBAAyB,QAAQ,CAAC,YAAY,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;YAEpE,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC;YAC1B,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC;YAC5B,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,IAAI,EAAE,CAAC;YAC5C,MAAM,YAAY,GAAG,GAAG,QAAQ,CAAC,YAAY,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;YACjE,MAAM,KAAK,GAAG,GAAG,QAAQ,CAAC,YAAY,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;YAE1D,OAAO;gBACL,GAAG,EAAE,GAAG;gBACR,KAAK,EAAE,KAAK;gBACZ,QAAQ,EAAE,QAAQ;gBAClB,KAAK,EAAE,KAAK;gBACZ,GAAG,EAAE,WAAW;gBAChB,YAAY,EAAE,YAAY;gBAC1B,IAAI,EAAE;oBACJ,GAAG,EAAE;wBACH,QAAQ,EAAE,iBAAiB,QAAQ,CAAC,YAAY,EAAE;wBAClD,GAAG,EAAE,WAAW;qBACjB;oBACD,GAAG,EAAE;wBACH,QAAQ,EAAE,SAAS,QAAQ,CAAC,IAAI,EAAE;wBAClC,GAAG,EAAE,WAAW;qBACjB;iBACF;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,WAAW;oBACjB,SAAS,EAAE,GAAG,QAAQ,CAAC,IAAI,mBAAmB,QAAQ,CAAC,YAAY,WAAW,QAAQ,CAAC,IAAI,EAAE;iBAC9F;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,mCAAmC;QACnC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;CACF","sourcesContent":["import { FormatterOptions } from '../BaseFormatter.js';\nimport { BaseFormatter } from './Formatter.js';\nimport { Pipeline } from '../../types/index.js';\n\nexport class AlfredFormatter extends BaseFormatter {\n name = 'alfred';\n \n formatPipelines(pipelines: Pipeline[], _organizations: string[], _options?: FormatterOptions): string {\n // Format pipelines as Alfred-compatible JSON items\n const alfredItems = pipelines.map((pipeline: Pipeline) => {\n // Generate web URL for the pipeline (if not already present)\n const pipelineUrl = pipeline.url || \n `https://buildkite.com/${pipeline.organization}/${pipeline.slug}`;\n \n const uid = pipeline.uuid;\n const title = pipeline.slug;\n const subtitle = pipeline.description || '';\n const autocomplete = `${pipeline.organization}/${pipeline.name}`;\n const match = `${pipeline.organization}/${pipeline.slug}`;\n\n return {\n uid: uid,\n title: title,\n subtitle: subtitle,\n match: match,\n arg: pipelineUrl,\n autocomplete: autocomplete,\n mods: {\n alt: {\n subtitle: `Organization: ${pipeline.organization}`,\n arg: pipelineUrl\n },\n cmd: {\n subtitle: `Name: ${pipeline.name}`,\n arg: pipelineUrl\n }\n },\n text: {\n copy: pipelineUrl,\n largetype: `${pipeline.name}\\nOrganization: ${pipeline.organization}\\nSlug: ${pipeline.slug}`\n }\n };\n });\n \n // Return formatted JSON for Alfred\n return JSON.stringify({ items: alfredItems }, null, 2);\n }\n} "]}
@@ -0,0 +1,10 @@
1
+ import { logger } from '../../services/logger.js';
2
+ export class BaseFormatter {
3
+ format(data, formatFn, options) {
4
+ if (options?.debug) {
5
+ logger.debug(`Formatting with ${this.name} formatter`);
6
+ }
7
+ return formatFn(data, options);
8
+ }
9
+ }
10
+ //# sourceMappingURL=Formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Formatter.js","sourceRoot":"/","sources":["formatters/pipelines/Formatter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAMlD,MAAM,OAAgB,aAAa;IAKjC,MAAM,CAAI,IAAS,EAAE,QAA2D,EAAE,OAA0B;QAC1G,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,MAAM,CAAC,KAAK,CAAC,mBAAmB,IAAI,CAAC,IAAI,YAAY,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;CACF","sourcesContent":["import { BaseFormatter as BaseFormatterInterface, FormatterOptions } from '../BaseFormatter.js';\nimport { Pipeline } from '../../types/index.js';\nimport { logger } from '../../services/logger.js';\n\nexport interface PipelineFormatter extends BaseFormatterInterface {\n formatPipelines(pipelines: Pipeline[], organizations: string[], options?: FormatterOptions): string;\n}\n\nexport abstract class BaseFormatter implements PipelineFormatter {\n abstract name: string;\n \n abstract formatPipelines(pipelines: Pipeline[], organizations: string[], options?: FormatterOptions): string;\n \n format<T>(data: T[], formatFn: (data: T[], options?: FormatterOptions) => string, options?: FormatterOptions): string {\n if (options?.debug) {\n logger.debug(`Formatting with ${this.name} formatter`);\n }\n return formatFn(data, options);\n }\n} "]}
@@ -0,0 +1,13 @@
1
+ import { BaseFormatter } from './Formatter.js';
2
+ export class JsonFormatter extends BaseFormatter {
3
+ name = 'json';
4
+ formatPipelines(pipelines, organizations, _options) {
5
+ const result = {
6
+ count: pipelines.length,
7
+ organizations,
8
+ pipelines
9
+ };
10
+ return JSON.stringify(result, null, 2);
11
+ }
12
+ }
13
+ //# sourceMappingURL=JsonFormatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonFormatter.js","sourceRoot":"/","sources":["formatters/pipelines/JsonFormatter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C,IAAI,GAAG,MAAM,CAAC;IAEd,eAAe,CAAC,SAAqB,EAAE,aAAuB,EAAE,QAA2B;QACzF,MAAM,MAAM,GAAG;YACb,KAAK,EAAE,SAAS,CAAC,MAAM;YACvB,aAAa;YACb,SAAS;SACV,CAAC;QAEF,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC;CACF","sourcesContent":["import { FormatterOptions } from '../BaseFormatter.js';\nimport { BaseFormatter } from './Formatter.js';\nimport { Pipeline } from '../../types/index.js';\n\nexport class JsonFormatter extends BaseFormatter {\n name = 'json';\n \n formatPipelines(pipelines: Pipeline[], organizations: string[], _options?: FormatterOptions): string {\n const result = {\n count: pipelines.length,\n organizations,\n pipelines\n };\n \n return JSON.stringify(result, null, 2);\n }\n} "]}
@@ -0,0 +1,47 @@
1
+ import { AbstractFormatter } from '../BaseFormatter.js';
2
+ export class PlainTextFormatter extends AbstractFormatter {
3
+ constructor() {
4
+ super('plain-text');
5
+ }
6
+ formatPipelines(pipelines, organizations, options) {
7
+ // If no organizations are found, handle that case
8
+ if (organizations.length === 0) {
9
+ return 'No organizations found.';
10
+ }
11
+ return this.format(pipelines, this.formatPipelinesImpl.bind(this, organizations), options);
12
+ }
13
+ formatPipelinesImpl(organizations, pipelines, _options) {
14
+ const output = [];
15
+ if (pipelines.length === 0) {
16
+ output.push('No pipelines found.');
17
+ if (organizations.length === 1) {
18
+ output.push(`No pipelines found in organization ${organizations[0]}.`);
19
+ }
20
+ else {
21
+ output.push(`No pipelines found across ${organizations.length} organizations.`);
22
+ }
23
+ return output.join('\n');
24
+ }
25
+ if (organizations.length === 1) {
26
+ output.push(`Pipelines for ${organizations[0]} (${pipelines.length} total):`);
27
+ }
28
+ else {
29
+ output.push(`Pipelines across your organizations (${pipelines.length} total):`);
30
+ }
31
+ pipelines.forEach((pipeline) => {
32
+ if (organizations.length > 1) {
33
+ output.push(`- [${pipeline.organization}] ${pipeline.name} (${pipeline.slug})`);
34
+ }
35
+ else {
36
+ output.push(`- ${pipeline.name} (${pipeline.slug})`);
37
+ }
38
+ });
39
+ // Summary line showing total pipelines listed
40
+ output.push(`Showing ${pipelines.length} pipelines.`);
41
+ if (organizations.length > 1) {
42
+ output.push(`\nSearched across ${organizations.length} organizations. Use --org to filter to a specific organization.`);
43
+ }
44
+ return output.join('\n');
45
+ }
46
+ }
47
+ //# sourceMappingURL=PlainTextFormatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlainTextFormatter.js","sourceRoot":"/","sources":["formatters/pipelines/PlainTextFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAI1E,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB;IACvD;QACE,KAAK,CAAC,YAAY,CAAC,CAAC;IACtB,CAAC;IAED,eAAe,CAAC,SAAqB,EAAE,aAAuB,EAAE,OAA0B;QACxF,kDAAkD;QAClD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,yBAAyB,CAAC;QACnC,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC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ACvD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,8CAA8C;QAC9C,MAAM,CAAC,IAAI,CAAC,WAAW,SAAS,CAAC,MAAM,aAAa,CAAC,CAAC;QAEtD,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,qBAAqB,aAAa,CAAC,MAAM,iEAAiE,CAAC,CAAC;QAC1H,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import { FormatterOptions, AbstractFormatter } from '../BaseFormatter.js';\nimport { PipelineFormatter } from './Formatter.js';\nimport { Pipeline } from '../../types/index.js';\n\nexport class PlainTextFormatter extends AbstractFormatter implements PipelineFormatter {\n constructor() {\n super('plain-text');\n }\n\n formatPipelines(pipelines: Pipeline[], organizations: string[], options?: FormatterOptions): string {\n // If no organizations are found, handle that case\n if (organizations.length === 0) {\n return 'No organizations found.';\n }\n \n return this.format(pipelines, this.formatPipelinesImpl.bind(this, organizations), options);\n }\n\n private formatPipelinesImpl(organizations: string[], pipelines: Pipeline[], _options?: FormatterOptions): string {\n const output: string[] = [];\n \n if (pipelines.length === 0) {\n output.push('No pipelines found.');\n if (organizations.length === 1) {\n output.push(`No pipelines found in organization ${organizations[0]}.`);\n } else {\n output.push(`No pipelines found across ${organizations.length} organizations.`);\n }\n return output.join('\\n');\n }\n \n if (organizations.length === 1) {\n output.push(`Pipelines for ${organizations[0]} (${pipelines.length} total):`);\n } else {\n output.push(`Pipelines across your organizations (${pipelines.length} total):`);\n }\n \n pipelines.forEach((pipeline: Pipeline) => {\n if (organizations.length > 1) {\n output.push(`- [${pipeline.organization}] ${pipeline.name} (${pipeline.slug})`);\n } else {\n output.push(`- ${pipeline.name} (${pipeline.slug})`);\n }\n });\n \n // Summary line showing total pipelines listed\n output.push(`Showing ${pipelines.length} pipelines.`);\n \n if (organizations.length > 1) {\n output.push(`\\nSearched across ${organizations.length} organizations. Use --org to filter to a specific organization.`);\n }\n \n return output.join('\\n');\n }\n} "]}
@@ -0,0 +1,28 @@
1
+ export * from './Formatter.js';
2
+ export * from './PlainTextFormatter.js';
3
+ export * from './JsonFormatter.js';
4
+ export * from './AlfredFormatter.js';
5
+ import { PlainTextFormatter } from './PlainTextFormatter.js';
6
+ import { JsonFormatter } from './JsonFormatter.js';
7
+ import { AlfredFormatter } from './AlfredFormatter.js';
8
+ import { logger } from '../../services/logger.js';
9
+ /**
10
+ * Factory function to create the appropriate formatter for pipelines
11
+ * @param format The format to use
12
+ * @returns A PipelineFormatter instance
13
+ */
14
+ export function getPipelineFormatter(format = 'plain') {
15
+ switch (format.toLowerCase()) {
16
+ case 'plain':
17
+ case 'text':
18
+ return new PlainTextFormatter();
19
+ case 'json':
20
+ return new JsonFormatter();
21
+ case 'alfred':
22
+ return new AlfredFormatter();
23
+ default:
24
+ logger.warn(`Unknown format '${format}', defaulting to plain text`);
25
+ return new PlainTextFormatter();
26
+ }
27
+ }
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["formatters/pipelines/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AAGrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAiB,OAAO;IAC3D,QAAQ,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;QAC7B,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,OAAO,IAAI,kBAAkB,EAAE,CAAC;QAClC,KAAK,MAAM;YACT,OAAO,IAAI,aAAa,EAAE,CAAC;QAC7B,KAAK,QAAQ;YACX,OAAO,IAAI,eAAe,EAAE,CAAC;QAC/B;YACE,MAAM,CAAC,IAAI,CAAC,mBAAmB,MAAM,6BAA6B,CAAC,CAAC;YACpE,OAAO,IAAI,kBAAkB,EAAE,CAAC;IACpC,CAAC;AACH,CAAC","sourcesContent":["export * from './Formatter.js';\nexport * from './PlainTextFormatter.js';\nexport * from './JsonFormatter.js';\nexport * from './AlfredFormatter.js';\n\nimport { PipelineFormatter } from './Formatter.js';\nimport { PlainTextFormatter } from './PlainTextFormatter.js';\nimport { JsonFormatter } from './JsonFormatter.js';\nimport { AlfredFormatter } from './AlfredFormatter.js';\nimport { logger } from '../../services/logger.js';\n\n/**\n * Factory function to create the appropriate formatter for pipelines\n * @param format The format to use\n * @returns A PipelineFormatter instance\n */\nexport function getPipelineFormatter(format: string = 'plain'): PipelineFormatter {\n switch (format.toLowerCase()) {\n case 'plain':\n case 'text':\n return new PlainTextFormatter();\n case 'json':\n return new JsonFormatter();\n case 'alfred':\n return new AlfredFormatter();\n default:\n logger.warn(`Unknown format '${format}', defaulting to plain text`);\n return new PlainTextFormatter();\n }\n} "]}