@transcend-io/cli 8.36.1 → 8.37.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 (203) hide show
  1. package/README.md +68 -19
  2. package/dist/{api-keys-DB0BZSh5.cjs → api-keys-Bb2BbZQe.cjs} +2 -2
  3. package/dist/{api-keys-DB0BZSh5.cjs.map → api-keys-Bb2BbZQe.cjs.map} +1 -1
  4. package/dist/app-C9jD-f87.cjs +131 -0
  5. package/dist/app-C9jD-f87.cjs.map +1 -0
  6. package/dist/bin/bash-complete.cjs +1 -1
  7. package/dist/bin/bash-complete.cjs.map +1 -1
  8. package/dist/bin/cli.cjs +1 -1
  9. package/dist/bin/cli.cjs.map +1 -1
  10. package/dist/bin/deprecated-command.cjs +1 -1
  11. package/dist/bin/deprecated-command.cjs.map +1 -1
  12. package/dist/buildAIIntegrationType-BwuCYR-o.cjs +2 -0
  13. package/dist/{buildAIIntegrationType-n_Qlv8wG.cjs.map → buildAIIntegrationType-BwuCYR-o.cjs.map} +1 -1
  14. package/dist/chunk-Bmb41Sf3.cjs +1 -0
  15. package/dist/{code-scanning-Yc7rgoTY.cjs → code-scanning-4d0zlFxk.cjs} +2 -2
  16. package/dist/{code-scanning-Yc7rgoTY.cjs.map → code-scanning-4d0zlFxk.cjs.map} +1 -1
  17. package/dist/codecs-Bvmb8o9R.cjs +2 -0
  18. package/dist/{codecs-JSDJgtyL.cjs.map → codecs-Bvmb8o9R.cjs.map} +1 -1
  19. package/dist/command-XJ7XPQ04.cjs +9 -0
  20. package/dist/{command-41dUPvEa.cjs.map → command-XJ7XPQ04.cjs.map} +1 -1
  21. package/dist/{consent-manager-BNMaKHId.cjs → consent-manager-CCyvzvY5.cjs} +2 -2
  22. package/dist/{consent-manager-BNMaKHId.cjs.map → consent-manager-CCyvzvY5.cjs.map} +1 -1
  23. package/dist/constants-wkuhlP8d.cjs +2 -0
  24. package/dist/{constants-JoCDv9ym.cjs.map → constants-wkuhlP8d.cjs.map} +1 -1
  25. package/dist/context-_8xfl0dt.cjs +2 -0
  26. package/dist/{context-Bw1xk9Q_.cjs.map → context-_8xfl0dt.cjs.map} +1 -1
  27. package/dist/{cron-ClvgH2uD.cjs → cron-DfEGA7Rf.cjs} +2 -2
  28. package/dist/{cron-ClvgH2uD.cjs.map → cron-DfEGA7Rf.cjs.map} +1 -1
  29. package/dist/{data-inventory-BzEYoxaa.cjs → data-inventory-C1eqZk1M.cjs} +2 -2
  30. package/dist/{data-inventory-BzEYoxaa.cjs.map → data-inventory-C1eqZk1M.cjs.map} +1 -1
  31. package/dist/{dataFlowsToDataSilos-daBgPi7V.cjs → dataFlowsToDataSilos-DXlFFHMV.cjs} +2 -2
  32. package/dist/{dataFlowsToDataSilos-daBgPi7V.cjs.map → dataFlowsToDataSilos-DXlFFHMV.cjs.map} +1 -1
  33. package/dist/{done-input-validation-Cgk5kNBs.cjs → done-input-validation-DGckEJ5a.cjs} +1 -1
  34. package/dist/{done-input-validation-Cgk5kNBs.cjs.map → done-input-validation-DGckEJ5a.cjs.map} +1 -1
  35. package/dist/enums-BZulhPFa.cjs +2 -0
  36. package/dist/{enums-CBXlBJii.cjs.map → enums-BZulhPFa.cjs.map} +1 -1
  37. package/dist/impl-6TmoWv0o.cjs +2 -0
  38. package/dist/{impl-ClDXxODZ.cjs.map → impl-6TmoWv0o.cjs.map} +1 -1
  39. package/dist/impl-73q3K0b_.cjs +2 -0
  40. package/dist/{impl-BN61r-PG.cjs.map → impl-73q3K0b_.cjs.map} +1 -1
  41. package/dist/{impl-DjVmOb9T.cjs → impl-7LAuV25D.cjs} +2 -2
  42. package/dist/{impl-DjVmOb9T.cjs.map → impl-7LAuV25D.cjs.map} +1 -1
  43. package/dist/impl-B04CctrY.cjs +12 -0
  44. package/dist/{impl-BMxxKrNz.cjs.map → impl-B04CctrY.cjs.map} +1 -1
  45. package/dist/impl-BGoAnVJu.cjs +4 -0
  46. package/dist/{impl-FlZPR0yd.cjs.map → impl-BGoAnVJu.cjs.map} +1 -1
  47. package/dist/impl-BOEjB3fo.cjs +2 -0
  48. package/dist/impl-BOEjB3fo.cjs.map +1 -0
  49. package/dist/impl-BOEoFzcB.cjs +4 -0
  50. package/dist/{impl-8bci0gd2.cjs.map → impl-BOEoFzcB.cjs.map} +1 -1
  51. package/dist/impl-B_2CdctV.cjs +2 -0
  52. package/dist/{impl-CCOEjRnr.cjs.map → impl-B_2CdctV.cjs.map} +1 -1
  53. package/dist/impl-BfC5CRRX.cjs +2 -0
  54. package/dist/{impl-hGu8uCC4.cjs.map → impl-BfC5CRRX.cjs.map} +1 -1
  55. package/dist/impl-C-aKX3zu.cjs +2 -0
  56. package/dist/{impl-DU-WTXTY.cjs.map → impl-C-aKX3zu.cjs.map} +1 -1
  57. package/dist/impl-C4q9xHFr.cjs +2 -0
  58. package/dist/{impl-BIqdEXRo.cjs.map → impl-C4q9xHFr.cjs.map} +1 -1
  59. package/dist/impl-C6JjApDI.cjs +2 -0
  60. package/dist/{impl-Bv4gPikD.cjs.map → impl-C6JjApDI.cjs.map} +1 -1
  61. package/dist/impl-CKYwKeLz.cjs +2 -0
  62. package/dist/{impl-4pmSDQvA.cjs.map → impl-CKYwKeLz.cjs.map} +1 -1
  63. package/dist/impl-CLcnbVfj.cjs +2 -0
  64. package/dist/impl-CLcnbVfj.cjs.map +1 -0
  65. package/dist/impl-CR-wyJSg.cjs +2 -0
  66. package/dist/impl-CR-wyJSg.cjs.map +1 -0
  67. package/dist/impl-CV3axMeT.cjs +2 -0
  68. package/dist/{impl-cfDtPbS9.cjs.map → impl-CV3axMeT.cjs.map} +1 -1
  69. package/dist/impl-CgKn47V9.cjs +2 -0
  70. package/dist/{impl-DpdGWdrr.cjs.map → impl-CgKn47V9.cjs.map} +1 -1
  71. package/dist/impl-CmEsmnYZ.cjs +2 -0
  72. package/dist/{impl-Cp12F9tr.cjs.map → impl-CmEsmnYZ.cjs.map} +1 -1
  73. package/dist/impl-CnRqR4kw.cjs +2 -0
  74. package/dist/{impl-C4D1tHjp.cjs.map → impl-CnRqR4kw.cjs.map} +1 -1
  75. package/dist/impl-Cp7-Tctr.cjs +2 -0
  76. package/dist/{impl-_dGu54cO.cjs.map → impl-Cp7-Tctr.cjs.map} +1 -1
  77. package/dist/impl-CqadSQOh.cjs +2 -0
  78. package/dist/impl-CqadSQOh.cjs.map +1 -0
  79. package/dist/impl-Cru4riTc.cjs +5 -0
  80. package/dist/impl-Cru4riTc.cjs.map +1 -0
  81. package/dist/impl-CsKfLxov.cjs +2 -0
  82. package/dist/impl-CsKfLxov.cjs.map +1 -0
  83. package/dist/impl-CyzGdwB1.cjs +2 -0
  84. package/dist/impl-CyzGdwB1.cjs.map +1 -0
  85. package/dist/impl-DC_YquN8.cjs +2 -0
  86. package/dist/{impl-BwAnSxkP.cjs.map → impl-DC_YquN8.cjs.map} +1 -1
  87. package/dist/impl-DHuguAlW.cjs +2 -0
  88. package/dist/{impl-BRuqPhJU.cjs.map → impl-DHuguAlW.cjs.map} +1 -1
  89. package/dist/impl-DNRsFfbU.cjs +2 -0
  90. package/dist/{impl-8zottXEQ.cjs.map → impl-DNRsFfbU.cjs.map} +1 -1
  91. package/dist/impl-DQ8rr7Fv.cjs +2 -0
  92. package/dist/{impl-ay7i0K_5.cjs.map → impl-DQ8rr7Fv.cjs.map} +1 -1
  93. package/dist/impl-DetfC7CT.cjs +2 -0
  94. package/dist/impl-DetfC7CT.cjs.map +1 -0
  95. package/dist/impl-DhbV3bBZ.cjs +2 -0
  96. package/dist/impl-DhbV3bBZ.cjs.map +1 -0
  97. package/dist/impl-DjP2MJNK.cjs +2 -0
  98. package/dist/{impl-CSZwdpH-.cjs.map → impl-DjP2MJNK.cjs.map} +1 -1
  99. package/dist/impl-DmXYpp-M.cjs +2 -0
  100. package/dist/{impl-J5fV8gbh.cjs.map → impl-DmXYpp-M.cjs.map} +1 -1
  101. package/dist/impl-Dp3-sA6b.cjs +2 -0
  102. package/dist/{impl-yHutqfbd.cjs.map → impl-Dp3-sA6b.cjs.map} +1 -1
  103. package/dist/{impl-KgEJvOhE.cjs → impl-DqfyWyoV.cjs} +2 -2
  104. package/dist/{impl-KgEJvOhE.cjs.map → impl-DqfyWyoV.cjs.map} +1 -1
  105. package/dist/impl-DrJj-l3s.cjs +2 -0
  106. package/dist/{impl-BXMfTm4K.cjs.map → impl-DrJj-l3s.cjs.map} +1 -1
  107. package/dist/impl-Dvoj_snk.cjs +2 -0
  108. package/dist/{impl-BouHRicT.cjs.map → impl-Dvoj_snk.cjs.map} +1 -1
  109. package/dist/impl-DwWoAbT_.cjs +2 -0
  110. package/dist/{impl-DhdY6lbj.cjs.map → impl-DwWoAbT_.cjs.map} +1 -1
  111. package/dist/impl-DxhyqjcY.cjs +2 -0
  112. package/dist/{impl-CFmFCVt8.cjs.map → impl-DxhyqjcY.cjs.map} +1 -1
  113. package/dist/impl-Dzq0t6mX.cjs +2 -0
  114. package/dist/{impl-BH0HWnIY.cjs.map → impl-Dzq0t6mX.cjs.map} +1 -1
  115. package/dist/impl-LgUGDTQK.cjs +2 -0
  116. package/dist/{impl-BS8t24Z7.cjs.map → impl-LgUGDTQK.cjs.map} +1 -1
  117. package/dist/impl-XyWPUpvw.cjs +2 -0
  118. package/dist/{impl-BWiNjS6v.cjs.map → impl-XyWPUpvw.cjs.map} +1 -1
  119. package/dist/impl-_QrpPIPw.cjs +2 -0
  120. package/dist/{impl-D3sI4I1g.cjs.map → impl-_QrpPIPw.cjs.map} +1 -1
  121. package/dist/impl-kxwq3OMk.cjs +2 -0
  122. package/dist/{impl-CoxOrlXu.cjs.map → impl-kxwq3OMk.cjs.map} +1 -1
  123. package/dist/impl-u8o3S8w2.cjs +2 -0
  124. package/dist/{impl-SkiG9sWb.cjs.map → impl-u8o3S8w2.cjs.map} +1 -1
  125. package/dist/index.cjs +4 -4
  126. package/dist/index.cjs.map +1 -1
  127. package/dist/index.d.cts +65 -2
  128. package/dist/{logger-BaHHbWVd.cjs → logger-DQwEYtSS.cjs} +2 -2
  129. package/dist/{logger-BaHHbWVd.cjs.map → logger-DQwEYtSS.cjs.map} +1 -1
  130. package/dist/{manual-enrichment-D-0rM9KN.cjs → manual-enrichment-CzTpv-mM.cjs} +2 -2
  131. package/dist/{manual-enrichment-D-0rM9KN.cjs.map → manual-enrichment-CzTpv-mM.cjs.map} +1 -1
  132. package/dist/{mergeTranscendInputs-PPpGbYgG.cjs → mergeTranscendInputs-BIBCYbug.cjs} +2 -2
  133. package/dist/{mergeTranscendInputs-PPpGbYgG.cjs.map → mergeTranscendInputs-BIBCYbug.cjs.map} +1 -1
  134. package/dist/{pooling-DbIx6-i7.cjs → pooling-DA_LwUEp.cjs} +2 -2
  135. package/dist/{pooling-DbIx6-i7.cjs.map → pooling-DA_LwUEp.cjs.map} +1 -1
  136. package/dist/{preference-management-Dapt3Li3.cjs → preference-management-aOhuZCuE.cjs} +2 -2
  137. package/dist/{preference-management-Dapt3Li3.cjs.map → preference-management-aOhuZCuE.cjs.map} +1 -1
  138. package/dist/{readTranscendYaml-CL9nujUr.cjs → readTranscendYaml-Cycz6RxW.cjs} +2 -2
  139. package/dist/{readTranscendYaml-CL9nujUr.cjs.map → readTranscendYaml-Cycz6RxW.cjs.map} +1 -1
  140. package/dist/syncConfigurationToTranscend-DuTZKIG8.cjs +3000 -0
  141. package/dist/syncConfigurationToTranscend-DuTZKIG8.cjs.map +1 -0
  142. package/dist/{uploadConsents-CN1JucL3.cjs → uploadConsents-C9Pv8Awr.cjs} +2 -2
  143. package/dist/{uploadConsents-CN1JucL3.cjs.map → uploadConsents-C9Pv8Awr.cjs.map} +1 -1
  144. package/package.json +1 -1
  145. package/dist/app-BOlZhpYh.cjs +0 -118
  146. package/dist/app-BOlZhpYh.cjs.map +0 -1
  147. package/dist/buildAIIntegrationType-n_Qlv8wG.cjs +0 -2
  148. package/dist/codecs-JSDJgtyL.cjs +0 -2
  149. package/dist/command-41dUPvEa.cjs +0 -9
  150. package/dist/constants-JoCDv9ym.cjs +0 -2
  151. package/dist/context-Bw1xk9Q_.cjs +0 -2
  152. package/dist/enums-CBXlBJii.cjs +0 -2
  153. package/dist/impl-4pmSDQvA.cjs +0 -2
  154. package/dist/impl-8bci0gd2.cjs +0 -4
  155. package/dist/impl-8zottXEQ.cjs +0 -2
  156. package/dist/impl-BFOghVmx.cjs +0 -2
  157. package/dist/impl-BFOghVmx.cjs.map +0 -1
  158. package/dist/impl-BH0HWnIY.cjs +0 -2
  159. package/dist/impl-BIqdEXRo.cjs +0 -2
  160. package/dist/impl-BMxxKrNz.cjs +0 -12
  161. package/dist/impl-BN61r-PG.cjs +0 -2
  162. package/dist/impl-BRuqPhJU.cjs +0 -2
  163. package/dist/impl-BS8t24Z7.cjs +0 -2
  164. package/dist/impl-BWiNjS6v.cjs +0 -2
  165. package/dist/impl-BXMfTm4K.cjs +0 -2
  166. package/dist/impl-BYK9pQs0.cjs +0 -2
  167. package/dist/impl-BYK9pQs0.cjs.map +0 -1
  168. package/dist/impl-BjOFvm4E.cjs +0 -2
  169. package/dist/impl-BjOFvm4E.cjs.map +0 -1
  170. package/dist/impl-BouHRicT.cjs +0 -2
  171. package/dist/impl-Bv4gPikD.cjs +0 -2
  172. package/dist/impl-BwAnSxkP.cjs +0 -2
  173. package/dist/impl-C-_9uRms.cjs +0 -2
  174. package/dist/impl-C-_9uRms.cjs.map +0 -1
  175. package/dist/impl-C4D1tHjp.cjs +0 -2
  176. package/dist/impl-CA_CO88W.cjs +0 -2
  177. package/dist/impl-CA_CO88W.cjs.map +0 -1
  178. package/dist/impl-CCOEjRnr.cjs +0 -2
  179. package/dist/impl-CFmFCVt8.cjs +0 -2
  180. package/dist/impl-CSZwdpH-.cjs +0 -2
  181. package/dist/impl-ChNLuyNq.cjs +0 -2
  182. package/dist/impl-ChNLuyNq.cjs.map +0 -1
  183. package/dist/impl-ClDXxODZ.cjs +0 -2
  184. package/dist/impl-CoxOrlXu.cjs +0 -2
  185. package/dist/impl-Cp12F9tr.cjs +0 -2
  186. package/dist/impl-D3sI4I1g.cjs +0 -2
  187. package/dist/impl-D7WBmmHb.cjs +0 -2
  188. package/dist/impl-D7WBmmHb.cjs.map +0 -1
  189. package/dist/impl-DU-WTXTY.cjs +0 -2
  190. package/dist/impl-DhdY6lbj.cjs +0 -2
  191. package/dist/impl-DpdGWdrr.cjs +0 -2
  192. package/dist/impl-FlZPR0yd.cjs +0 -4
  193. package/dist/impl-J5fV8gbh.cjs +0 -2
  194. package/dist/impl-NLEQuKnT.cjs +0 -2
  195. package/dist/impl-NLEQuKnT.cjs.map +0 -1
  196. package/dist/impl-SkiG9sWb.cjs +0 -2
  197. package/dist/impl-_dGu54cO.cjs +0 -2
  198. package/dist/impl-ay7i0K_5.cjs +0 -2
  199. package/dist/impl-cfDtPbS9.cjs +0 -2
  200. package/dist/impl-hGu8uCC4.cjs +0 -2
  201. package/dist/impl-yHutqfbd.cjs +0 -2
  202. package/dist/syncConfigurationToTranscend-D4PLA70C.cjs +0 -2994
  203. package/dist/syncConfigurationToTranscend-D4PLA70C.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["makeGraphQLRequest","LARGE_LANGUAGE_MODELS","DEFAULT_TRANSCEND_API","buildTranscendGraphQLClient","uniq","agentNames","fetchPromptsWithVariables","fetchAllAgents","keyBy","name","fetchAllPromptThreads","groupBy","chunk","mapSeries","fetchAllAgentFiles","PromptStatus","ChatCompletionRole","reportPromptRun","PromptRunProductArea","QueueStatus","difference","fastGlob"],"sources":["../src/lib/graphql/fetchLargeLanguageModels.ts","../src/lib/ai/TranscendPromptManager.ts","../src/lib/ai/removeLinks.ts","../src/lib/ai/filterNullishValuesFromObject.ts","../src/lib/ai/getGitFilesThatChanged.ts"],"sourcesContent":["import { GraphQLClient } from 'graphql-request';\nimport { LargeLanguageModelClient } from '@transcend-io/privacy-types';\nimport { LARGE_LANGUAGE_MODELS } from './gqls';\nimport { makeGraphQLRequest } from './makeGraphQLRequest';\n\nexport interface LargeLanguageModel {\n /** ID of prompts */\n id: string;\n /** The name of the large language model. */\n name: string;\n /** The content of the prompt template. */\n client: LargeLanguageModelClient;\n /** Whether hosted by Transcend or not */\n isTranscendHosted: boolean;\n}\n\nconst PAGE_SIZE = 20;\n\n/**\n * Fetch all LargeLanguageModels in the organization\n *\n * @param client - GraphQL client\n * @returns All LargeLanguageModels in the organization\n */\nexport async function fetchAllLargeLanguageModels(\n client: GraphQLClient,\n): Promise<LargeLanguageModel[]> {\n const largeLanguageModels: LargeLanguageModel[] = [];\n let offset = 0;\n\n // Whether to continue looping\n let shouldContinue = false;\n do {\n const {\n largeLanguageModels: { nodes },\n } = await makeGraphQLRequest<{\n /** LargeLanguageModels */\n largeLanguageModels: {\n /** List */\n nodes: LargeLanguageModel[];\n };\n }>(client, LARGE_LANGUAGE_MODELS, {\n first: PAGE_SIZE,\n offset,\n });\n largeLanguageModels.push(...nodes);\n offset += PAGE_SIZE;\n shouldContinue = nodes.length === PAGE_SIZE;\n } while (shouldContinue);\n\n return largeLanguageModels.sort((a, b) => a.name.localeCompare(b.name));\n}\n","/* eslint-disable max-lines */\nimport {\n Optionalize,\n Requirize,\n apply,\n decodeCodec,\n getValues,\n} from '@transcend-io/type-utils';\nimport type { Handlebars } from '@transcend-io/handlebars-utils';\nimport { Secret } from '@transcend-io/secret-value';\nimport * as t from 'io-ts';\nimport { DEFAULT_TRANSCEND_API } from '../../constants';\nimport {\n Agent,\n AgentFile,\n AgentFileFilterBy,\n ReportPromptRunInput,\n buildTranscendGraphQLClient,\n fetchAllAgentFiles,\n fetchAllAgents,\n reportPromptRun,\n} from '../graphql';\nimport {\n HandlebarsInput,\n createHandlebarsWithHelpers,\n} from '@transcend-io/handlebars-utils';\nimport {\n TranscendPromptTemplated,\n TranscendPromptsAndVariables,\n fetchPromptsWithVariables,\n} from '../graphql/fetchPrompts';\nimport { GraphQLClient } from 'graphql-request';\nimport {\n PromptStatus,\n ChatCompletionRole,\n PromptRunProductArea,\n QueueStatus,\n LargeLanguageModelClient,\n} from '@transcend-io/privacy-types';\nimport {\n LargeLanguageModel,\n fetchAllLargeLanguageModels,\n} from '../graphql/fetchLargeLanguageModels';\nimport { groupBy, keyBy, uniq, chunk } from 'lodash-es';\nimport { mapSeries } from '../bluebird';\nimport {\n PromptThread,\n fetchAllPromptThreads,\n} from '../graphql/fetchPromptThreads';\n\n/**\n * An LLM Prompt definition\n */\nexport type TranscendPrompt<\n TInputParams extends t.Any,\n TOutputCodec extends t.Any,\n> = (\n | {\n /** ID of the prompt */\n id: string;\n /** Title of the prompt */\n title?: string;\n }\n | {\n /** ID of the prompt */\n id?: string;\n /** Title of the prompt */\n title: string;\n }\n) & {\n /** The names of the agents that should be loaded along with the prompt */\n agentNames?: string[];\n /** Codec to validate runtime input shape */\n paramCodec: TInputParams;\n /** Codec to validate output response */\n outputCodec: TOutputCodec;\n /**\n * If the output that needs to be parsed is returned within a tag\n * e.g. <tag> or <json> - this is the name of the tag\n */\n extractFromTag?: string;\n};\n\nexport interface PromptRunResult {\n /** The ID of the prompt run created on Transcend */\n promptRunId: string;\n /** The URL of the prompt run on Transcend */\n promptRunUrl: string;\n}\n\n/**\n * Create a regex to extract data from a tag\n *\n * Input:\n * \"here is some data <tag>Data</tag>...\"\n *\n * @param tagName - Name of tag\n * @returns Data within the tag\n */\nexport function createRegexForTag(tagName: string): RegExp {\n return new RegExp(`<${tagName}>([\\\\s\\\\S]+?)<\\\\/${tagName}>`);\n}\n\n/**\n * Helper function to declare prompts\n *\n * @param prompts - Prompt config\n * @returns Prompts as identity function - but type enforced\n */\nexport function defineTranscendPrompts<\n TPromptNames extends string,\n TPrompts extends { [k in TPromptNames]: TranscendPrompt<t.Any, t.Any> },\n>(prompts: TPrompts): TPrompts {\n return prompts;\n}\n\n/**\n * Helper to get the type of the parameter for a given prompt\n */\nexport type GetPromptParamType<\n TPromptName extends keyof TPrompts,\n TPrompts extends { [k in TPromptName]: TranscendPrompt<t.Any, t.Any> },\n> = t.TypeOf<TPrompts[TPromptName]['paramCodec']>;\n\n/**\n * Helper to get the type of the parameter for a given prompt\n */\nexport type GetPromptResponseType<\n TPromptName extends keyof TPrompts,\n TPrompts extends { [k in TPromptName]: TranscendPrompt<t.Any, t.Any> },\n> = t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n\n/**\n * Input for reporting a prompt run\n */\nexport interface ReportPromptRunOptions\n extends Optionalize<\n Omit<ReportPromptRunInput, 'status' | 'promptId' | 'largeLanguageModelId'>,\n 'name' | 'productArea'\n > {\n /** The large language model being run. Either the ID of the LLM or the client/name pairing */\n largeLanguageModel:\n | string\n | {\n /** Name of client */\n client: LargeLanguageModelClient;\n /** Name of the model */\n name: string;\n };\n}\n\nconst jsonParseSafe = (obj: string): unknown => {\n try {\n return JSON.parse(obj);\n } catch (e) {\n return obj;\n }\n};\n\n/**\n * A class that is capable of loading and insert variables into prompts from\n * Transcend's Prompt Manager\n */\nexport class TranscendPromptManager<\n TPromptNames extends string,\n TPrompts extends { [k in TPromptNames]: TranscendPrompt<t.Any, t.Any> },\n> {\n /** Prompt definitions */\n public prompts: TPrompts;\n\n /** Options for configuring handlebars */\n public handlebarsOptions!: HandlebarsInput;\n\n /** Prompt name -> content map, populated by call to Transcend API */\n public promptContentMap?: { [k in TPromptNames]: TranscendPromptTemplated };\n\n /** The large language models that are registered to this organization for reporting */\n public largeLanguageModels: LargeLanguageModel[] = [];\n\n /** The agent definitions registered to this organization */\n private agentsByName: { [name in string]: Agent } = {};\n\n /** The agent definitions registered to this organization */\n private agentsByAgentId: { [id in string]: Agent } = {};\n\n /** The GraphQL client that can be used to call Transcend */\n public graphQLClient: GraphQLClient;\n\n /** The set of variables to expose in handlebars context specified at class initiation */\n public defaultVariables: { [k in string]: unknown };\n\n /**\n * The set of variables to expose in handlebars context,\n * merges defaults with calculated variables from the inventory\n */\n public variables: { [k in string]: unknown };\n\n /** Handlebars compiler */\n public handlebars: typeof Handlebars;\n\n /** The Transcend API key */\n public transcendApiKey: string | Secret<string>;\n\n /** API of Transcend to call */\n public transcendUrl: string;\n\n /** When true, throw an error if the prompt is not approved */\n public requireApproval: boolean;\n\n /**\n * The cache duration in ms for how long prompts and associated metadata should be cached\n * When undefined - prompts are cached indefinitely unless explicitly re-requested\n * When 0, prompts and metadata are fetched every time (not recommended)\n * Setting this to be an hour is a good rate that optimizes for performance and keeping up to date\n */\n public cacheDuration?: number;\n\n /**\n * The last time the metadata was fetched\n */\n public lastUpdatedAt?: Date;\n\n /**\n * Constructor\n *\n * @param options - Options\n */\n constructor({\n prompts,\n handlebarsOptions = {},\n transcendUrl = DEFAULT_TRANSCEND_API,\n transcendApiKey,\n requireApproval = true,\n cacheDuration,\n defaultVariables = {},\n }: {\n /** Prompt definitions to load */\n prompts: TPrompts;\n /** Options for configuring handlebars */\n handlebarsOptions?: HandlebarsInput;\n /** The Transcend API key */\n transcendApiKey: string | Secret<string>;\n /** API of Transcend to call */\n transcendUrl?: string;\n /** When true, throw an error if the prompt is not approved */\n requireApproval?: boolean;\n /** The set of variables to expose in handlebars context specified at class initiation */\n defaultVariables?: { [k in string]: unknown };\n /**\n * The cache duration in ms for how long prompts and associated metadata should be cached\n * When undefined - prompts are cached indefinitely unless explicitly re-requested\n * When 0, prompts and metadata are fetched every time (not recommended)\n * Setting this to be an hour is a good rate that optimizes for performance and keeping up to date\n */\n cacheDuration?: number;\n }) {\n this.prompts = prompts;\n this.transcendUrl = transcendUrl;\n this.transcendApiKey = transcendApiKey;\n this.variables = defaultVariables;\n this.defaultVariables = defaultVariables;\n this.graphQLClient = buildTranscendGraphQLClient(\n transcendUrl,\n typeof transcendApiKey === 'object'\n ? transcendApiKey.release()\n : transcendApiKey,\n );\n this.requireApproval = requireApproval;\n this.cacheDuration = cacheDuration;\n this.handlebarsOptions = handlebarsOptions;\n this.handlebars = createHandlebarsWithHelpers(handlebarsOptions);\n }\n\n /**\n * Fetch prompt metadata from Transcend and cache to the class definition\n *\n * @returns A function that can be used to call the prompt\n */\n async fetchPromptsAndMetadata(): Promise<TranscendPromptsAndVariables> {\n // Determine what to fetch\n const promptDefinitions = getValues(this.prompts) as TranscendPrompt<\n t.Any,\n t.Any\n >[];\n const promptIds = promptDefinitions\n .map(({ id }) => id)\n .filter((x): x is string => !!x);\n const promptTitles = promptDefinitions\n .map(({ title }) => title)\n .filter((x): x is string => !!x);\n const agentNames = uniq(\n promptDefinitions.map(({ agentNames }) => agentNames || []).flat(),\n );\n\n // Fetch prompts and data\n const [response, largeLanguageModels, agents] = await Promise.all([\n fetchPromptsWithVariables(this.graphQLClient, {\n promptIds,\n promptTitles,\n }),\n fetchAllLargeLanguageModels(this.graphQLClient),\n fetchAllAgents(this.graphQLClient, { names: agentNames }),\n ]);\n this.agentsByName = keyBy(agents, 'name');\n this.agentsByAgentId = keyBy(agents, 'agentId');\n this.largeLanguageModels = largeLanguageModels.filter(\n (model) => model.isTranscendHosted === false,\n );\n\n // Lookup prompts by id/title\n const promptByTitle = keyBy(response.prompts, 'title');\n const promptById = keyBy(response.prompts, 'id');\n\n // Update variables\n this.variables = {\n ...response.calculatedVariables.reduce(\n (acc, v) =>\n Object.assign(acc, {\n [v.name]: v.data ? JSON.parse(v.data) : v.data,\n }),\n {},\n ),\n ...this.defaultVariables,\n };\n\n // Update partials\n this.handlebars = createHandlebarsWithHelpers({\n ...this.handlebarsOptions,\n templates: [\n ...(this.handlebarsOptions.templates || []),\n ...response.promptPartials.map((partial) => ({\n name: partial.slug,\n content: partial.content,\n })),\n ],\n });\n\n // Create mapping from prompt to content\n this.promptContentMap = apply(this.prompts, ({ id, title }) => {\n const result = id\n ? promptById[id]\n : title\n ? promptByTitle[title]\n : undefined;\n if (!result) {\n throw new Error(\n `Failed to find prompt with title: \"${title}\" and id: \"${id}\"`,\n );\n }\n return result;\n });\n\n // For cache\n this.lastUpdatedAt = new Date();\n\n return response;\n }\n\n /**\n * Get an agent definition by name\n *\n * @param name - Name of the agent to grab\n * @returns Large language model configuration\n */\n async getAgentByName(name: string): Promise<Agent | undefined> {\n const agent = this.agentsByName[name];\n if (agent) {\n return agent;\n }\n const [remoteAgent] = await fetchAllAgents(this.graphQLClient, {\n names: [name],\n });\n if (!remoteAgent) {\n return undefined;\n }\n this.agentsByName[remoteAgent.name] = remoteAgent;\n this.agentsByAgentId[remoteAgent.agentId] = remoteAgent;\n return remoteAgent;\n }\n\n /**\n * Get a prompt thread by ts\n *\n * @param ts - the slack message timestamp to look up thread for\n * @returns Large language model configuration\n */\n async getPromptThreadBySlackTs(\n ts: string,\n ): Promise<PromptThread | undefined> {\n const [thread] = await fetchAllPromptThreads(this.graphQLClient, {\n slackMessageTs: [ts],\n });\n return thread;\n }\n\n /**\n * Get a list of agent definitions by name.\n * Pulls from cache and may return less agents\n * than requested if some are not found\n *\n * @param names - Names of agents to fetch\n * @returns The agents that were found matching the names\n */\n async getAgentsByName(names: string[]): Promise<Agent[]> {\n if (names.length < 1) {\n throw new Error('Expected at least one name to be provided');\n }\n const { hasCache = [], missingCache = [] } = groupBy(names, (name) =>\n this.agentsByName[name] ? 'hasCache' : 'missingCache',\n );\n const cachedAgents = hasCache.map((name) => this.agentsByName[name]);\n if (missingCache.length === 0) {\n return cachedAgents;\n }\n const chunkedNames = chunk(missingCache, 50);\n const remoteAgents: Agent[] = [];\n await mapSeries(chunkedNames, async (chunkedName) => {\n const pageOfAgents = await fetchAllAgents(this.graphQLClient, {\n names: chunkedName,\n });\n pageOfAgents.forEach((agent) => {\n this.agentsByName[agent.name] = agent;\n this.agentsByAgentId[agent.agentId] = agent;\n });\n remoteAgents.push(...pageOfAgents);\n });\n return [...cachedAgents, ...remoteAgents];\n }\n\n /**\n * Fetch metadata on agent files\n *\n * @param filterBy - Filter by parameters\n * @returns The files found matching the filter\n */\n getAgentFiles(filterBy: AgentFileFilterBy): Promise<AgentFile[]> {\n return fetchAllAgentFiles(this.graphQLClient, filterBy);\n }\n\n /**\n * Look up the large language model to report on\n *\n * @param largeLanguageModel - Input\n * @returns Large language model configuration\n */\n getLargeLanguageModel(\n largeLanguageModel: ReportPromptRunOptions['largeLanguageModel'],\n ): LargeLanguageModel {\n const matching = this.largeLanguageModels.find((model) =>\n typeof largeLanguageModel === 'string'\n ? model.id === largeLanguageModel\n : model.name === largeLanguageModel.name &&\n model.client === largeLanguageModel.client,\n );\n if (!matching) {\n throw new Error(\n `Failed to find model matching: ${\n typeof largeLanguageModel === 'string'\n ? largeLanguageModel\n : JSON.stringify(largeLanguageModel)\n }`,\n );\n }\n return matching;\n }\n\n /**\n * Get a prompt definition by name\n *\n * @param promptName - Prompt to compile\n * @returns Parsed content\n */\n async getPromptDefinition<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n ): Promise<TranscendPromptTemplated> {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration &&\n Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n // Lookup prompt\n const { promptContentMap } = this;\n if (!promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n const promptTemplate = promptContentMap[promptName];\n if (!promptTemplate) {\n throw new Error(\n `Expected this.promptContentMap[${promptName}] to be defined`,\n );\n }\n return promptTemplate;\n }\n\n /**\n * Validate the shape of the response from AI\n *\n * @param promptName - Prompt to compile\n * @param params - Runtime parameters\n * @returns Parsed content\n */\n async compilePrompt<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n params: t.TypeOf<TPrompts[TPromptName]['paramCodec']>,\n ): Promise<string> {\n // Grab the prompt\n const promptTemplate = await this.getPromptDefinition(promptName);\n const promptInput = this.prompts[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure prompt is approved\n if (\n this.requireApproval &&\n promptTemplate.status !== PromptStatus.Approved\n ) {\n throw new Error(\n `Assessment \"${promptTemplate.title}\" cannot be used because its in status: \"${promptTemplate.status}\"`,\n );\n }\n\n // If prompt is rejected, throw error\n if (promptTemplate.status === PromptStatus.Rejected) {\n throw new Error(\n `Assessment \"${promptTemplate.title}\" cannot be used because it's in status: \"${promptTemplate.status}\"`,\n );\n }\n\n // Validate params\n decodeCodec(promptInput.paramCodec, params);\n\n // Compile prompt and template\n return this.handlebars.compile(promptTemplate.content)({\n // template in currentDate by default\n currentDate: new Date().toISOString(),\n ...this.variables,\n ...params,\n });\n }\n\n /**\n * Validate the shape of the response from AI\n *\n * @param promptName - Prompt to parse\n * @param response - AI response as string\n * @returns Parsed content\n */\n parseAiResponse<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n response: string,\n ): t.TypeOf<TPrompts[TPromptName]['outputCodec']> {\n // Look up prompt info\n const promptInput = this.prompts[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Extract from tag if needed\n const extracted = promptInput.extractFromTag\n ? (createRegexForTag(promptInput.extractFromTag).exec(response) ||\n [])[1] || response\n : response;\n\n // Parse via codec\n return decodeCodec(\n promptInput.outputCodec,\n jsonParseSafe(extracted),\n false,\n );\n }\n\n /**\n * Parse the AI response and report back to Transcend\n *\n * @param promptName - Prompt to parse\n * @param options - Options for reporting\n * @returns Parsed content\n */\n async reportAndParsePromptRun<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n { largeLanguageModel, ...options }: ReportPromptRunOptions,\n ): Promise<\n PromptRunResult & {\n /** Resulting prompt run */\n result: t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n }\n > {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration &&\n Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n const name =\n options.name ||\n `@transcend-io/cli-prompt-run-${new Date().toISOString()}`;\n\n if (!this.promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n // Look up prompt info\n const promptInput = this.promptContentMap[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure the first message in `promptRunMessages` is of type=system\n if (options.promptRunMessages.length === 0) {\n throw new Error('promptRunMessages is expected to have length > 0');\n }\n if (options.promptRunMessages[0].role !== ChatCompletionRole.System) {\n throw new Error(\n `promptRunMessages[0].role is expected to be = ${ChatCompletionRole.System}`,\n );\n }\n if (\n options.promptRunMessages[options.promptRunMessages.length - 1].role !==\n ChatCompletionRole.Assistant\n ) {\n throw new Error(\n `promptRunMessages[${\n options.promptRunMessages.length - 1\n }].role is expected to be = ${ChatCompletionRole.Assistant}`,\n );\n }\n const response =\n options.promptRunMessages[options.promptRunMessages.length - 1].content;\n\n let parsed: t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n try {\n // Parse the response\n parsed = this.parseAiResponse(promptName, response);\n } catch (err) {\n await reportPromptRun(this.graphQLClient, {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n error: err.message,\n status: QueueStatus.Error,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n });\n throw err;\n }\n\n // report successful run\n const promptRunId = await reportPromptRun(this.graphQLClient, {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n status: QueueStatus.Resolved,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n });\n\n return {\n result: parsed,\n promptRunId,\n promptRunUrl: `https://app.transcend.io/prompts/runs/${promptRunId}`,\n };\n }\n\n /**\n * Report an error for a particular prompt\n *\n * @param promptName - Prompt to parse\n * @param options - Options for reporting\n * @returns Parsed content\n */\n async reportPromptRunError<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n {\n largeLanguageModel,\n ...options\n }: Requirize<ReportPromptRunOptions, 'error'>,\n ): Promise<PromptRunResult> {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration &&\n Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n const name =\n options.name ||\n `@transcend-io/cli-prompt-run-${new Date().toISOString()}`;\n\n if (!this.promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n // Look up prompt info\n const promptInput = this.promptContentMap[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure the first message in `promptRunMessages` is of type=system\n if (options.promptRunMessages.length === 0) {\n throw new Error('promptRunMessages is expected to have length > 0');\n }\n if (options.promptRunMessages[0].role !== ChatCompletionRole.System) {\n throw new Error(\n `promptRunMessages[0].role is expected to be = ${ChatCompletionRole.System}`,\n );\n }\n\n const promptRunId = await reportPromptRun(this.graphQLClient, {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n status: QueueStatus.Error,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n });\n\n return {\n promptRunId,\n promptRunUrl: `https://app.transcend.io/prompts/runs/${promptRunId}`,\n };\n }\n}\n/* eslint-enable max-lines */\n","/**\n * Remove links from a string\n *\n * @param inputString - String\n * @returns String without links\n */\nexport function removeLinks(inputString: string): string {\n const regex = /(https?:\\/\\/[^\\s]+)/g;\n return inputString.replace(regex, '<link-omitted>');\n}\n","import { ObjByString } from '@transcend-io/type-utils';\n\n/**\n * Given an object, remove all keys that are null-ish\n *\n * @param obj - Object\n * @returns Object with null-ish values removed\n */\nexport function filterNullishValuesFromObject<T extends ObjByString>(\n obj: T,\n): T {\n return Object.entries(obj).reduce(\n (acc, [k, v]) =>\n v !== null &&\n v !== undefined &&\n v !== '' &&\n !(Array.isArray(v) && v.length === 0) &&\n !(typeof v === 'object' && Object.keys(v).length === 0)\n ? Object.assign(acc, { [k]: v })\n : acc,\n {} as T,\n );\n}\n","import { difference } from 'lodash-es';\nimport fastGlob from 'fast-glob';\nimport { execSync } from 'child_process';\n\n/**\n * Function thats gets the git files that have changed\n * and returns the code\n *\n * @param options - Options\n * @returns Changes files and diffs\n */\nexport function getGitFilesThatChanged({\n baseBranch,\n rootDirectory,\n githubRepo,\n excludedGlob = [],\n fileBlockList = [],\n}: {\n /** Base branch */\n baseBranch: string;\n /** Github repo name */\n githubRepo: string;\n /** Root directory */\n rootDirectory: string;\n /** A glob that excludes files */\n excludedGlob?: string[];\n /** Block list of files to not process */\n fileBlockList?: string[];\n}): {\n /** The list of files that changed */\n changedFiles: string[];\n /** Github repo name */\n repoName: string;\n /** Current commit */\n commit: string;\n /** File diffs */\n fileDiffs: { [k in string]: string };\n} {\n // Pull base branch\n execSync(`git fetch origin ${baseBranch}`);\n\n // Latest commit on base branch. If we are on the base branch, we take the prior commit\n const latestBasedCommit = execSync(\n `git ls-remote ${githubRepo} \"refs/heads/${baseBranch}\" | cut -f 1`,\n { encoding: 'utf-8' },\n ).split('\\n')[0];\n\n // This commit\n const latestThisCommit = execSync('git rev-parse HEAD', {\n encoding: 'utf-8',\n }).split('\\n')[0];\n\n // Ensure commits are present\n if (!latestBasedCommit || !latestThisCommit) {\n throw new Error('FAILED TO FIND COMMIT RANGE');\n }\n\n // Get the diff between the given branch and base branch\n const diff = execSync(\n `git fetch && git diff --name-only \"${\n baseBranch || latestBasedCommit\n }...${latestThisCommit}\" -- ${rootDirectory}`,\n { encoding: 'utf-8' },\n );\n\n // Filter out block list\n const changedFiles = difference(\n diff.split('\\n').filter((f) => f),\n fileBlockList,\n );\n\n // Filter out globs\n const filteredChanges =\n excludedGlob.length > 0\n ? fastGlob.sync(changedFiles, { ignore: excludedGlob })\n : changedFiles;\n\n // Get the contents of only the changed files\n const fileDiffs: { [k in string]: string } = {};\n filteredChanges.forEach((file) => {\n const contents = execSync(`git show ${latestThisCommit}:${file}`, {\n encoding: 'utf-8',\n });\n fileDiffs[file] = contents;\n });\n\n // Pull the github repo name\n const repoName = githubRepo.split('/').pop()!.split('.')[0];\n\n return {\n changedFiles,\n fileDiffs,\n repoName,\n commit: latestThisCommit,\n };\n}\n"],"mappings":"uxBAgBA,MAAM,EAAY,GAQlB,eAAsB,EACpB,EAC+B,CAC/B,IAAM,EAA4C,EAAE,CAChD,EAAS,EAGT,EAAiB,GACrB,EAAG,CACD,GAAM,CACJ,oBAAqB,CAAE,UACrB,MAAMA,EAAAA,EAMP,EAAQC,EAAAA,GAAuB,CAChC,MAAO,GACP,SACD,CAAC,CACF,EAAoB,KAAK,GAAG,EAAM,CAClC,GAAU,GACV,EAAiB,EAAM,SAAW,SAC3B,GAET,OAAO,EAAoB,MAAM,EAAG,IAAM,EAAE,KAAK,cAAc,EAAE,KAAK,CAAC,CCiDzE,SAAgB,EAAkB,EAAyB,CACzD,OAAW,OAAO,IAAI,EAAQ,mBAAmB,EAAQ,GAAG,CAS9D,SAAgB,EAGd,EAA6B,CAC7B,OAAO,EAsCT,MAAM,EAAiB,GAAyB,CAC9C,GAAI,CACF,OAAO,KAAK,MAAM,EAAI,MACZ,CACV,OAAO,IAQX,IAAa,EAAb,KAGE,CAEA,QAGA,kBAGA,iBAGA,oBAAmD,EAAE,CAGrD,aAAoD,EAAE,CAGtD,gBAAqD,EAAE,CAGvD,c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,GACjD,OAAO,OAAO,EAAK,EAAG,GAAI,EAAG,CAAC,CAC9B,EACN,EAAE,CACH,CCVH,SAAgB,EAAuB,CACrC,aACA,gBACA,aACA,eAAe,EAAE,CACjB,gBAAgB,EAAE,EAqBlB,EAEA,EAAA,EAAA,UAAS,oBAAoB,IAAa,CAG1C,IAAM,GAAA,EAAA,EAAA,UACJ,iBAAiB,EAAW,eAAe,EAAW,cACtD,CAAE,SAAU,QAAS,CACtB,CAAC,MAAM;EAAK,CAAC,GAGR,GAAA,EAAA,EAAA,UAA4B,qBAAsB,CACtD,SAAU,QACX,CAAC,CAAC,MAAM;EAAK,CAAC,GAGf,GAAI,CAAC,GAAqB,CAAC,EACzB,MAAU,MAAM,8BAA8B,CAYhD,IAAM,EAAeC,EAAAA,IAAAA,EAAAA,EAAAA,UAPnB,sCACE,GAAc,EACf,KAAK,EAAiB,OAAO,IAC9B,CAAE,SAAU,QAAS,CACtB,CAIM,MAAM;EAAK,CAAC,OAAQ,GAAM,EAAE,CACjC,EACD,CAGK,EACJ,EAAa,OAAS,EAClBC,EAAAA,QAAS,KAAK,EAAc,CAAE,OAAQ,EAAc,CAAC,CACrD,EAGA,EAAuC,EAAE,CAW/C,OAVA,EAAgB,QAAS,GAAS,CAIhC,EAAU,IAAA,EAAA,EAAA,UAHgB,YAAY,EAAiB,GAAG,IAAQ,CAChE,SAAU,QACX,CAAC,EAEF,CAKK,CACL,eACA,YACA,SALe,EAAW,MAAM,IAAI,CAAC,KAAK,CAAE,MAAM,IAAI,CAAC,GAMvD,OAAQ,EACT"}
1
+ {"version":3,"file":"index.cjs","names":["makeGraphQLRequest","LARGE_LANGUAGE_MODELS","DEFAULT_TRANSCEND_API","buildTranscendGraphQLClient","uniq","agentNames","fetchPromptsWithVariables","fetchAllAgents","keyBy","name","fetchAllPromptThreads","groupBy","chunk","mapSeries","fetchAllAgentFiles","PromptStatus","ChatCompletionRole","reportPromptRun","PromptRunProductArea","QueueStatus","difference","fastGlob"],"sources":["../src/lib/graphql/fetchLargeLanguageModels.ts","../src/lib/ai/TranscendPromptManager.ts","../src/lib/ai/removeLinks.ts","../src/lib/ai/filterNullishValuesFromObject.ts","../src/lib/ai/getGitFilesThatChanged.ts"],"sourcesContent":["import { GraphQLClient } from 'graphql-request';\nimport { LargeLanguageModelClient } from '@transcend-io/privacy-types';\nimport { LARGE_LANGUAGE_MODELS } from './gqls';\nimport { makeGraphQLRequest } from './makeGraphQLRequest';\n\nexport interface LargeLanguageModel {\n /** ID of prompts */\n id: string;\n /** The name of the large language model. */\n name: string;\n /** The content of the prompt template. */\n client: LargeLanguageModelClient;\n /** Whether hosted by Transcend or not */\n isTranscendHosted: boolean;\n}\n\nconst PAGE_SIZE = 20;\n\n/**\n * Fetch all LargeLanguageModels in the organization\n *\n * @param client - GraphQL client\n * @returns All LargeLanguageModels in the organization\n */\nexport async function fetchAllLargeLanguageModels(\n client: GraphQLClient,\n): Promise<LargeLanguageModel[]> {\n const largeLanguageModels: LargeLanguageModel[] = [];\n let offset = 0;\n\n // Whether to continue looping\n let shouldContinue = false;\n do {\n const {\n largeLanguageModels: { nodes },\n } = await makeGraphQLRequest<{\n /** LargeLanguageModels */\n largeLanguageModels: {\n /** List */\n nodes: LargeLanguageModel[];\n };\n }>(client, LARGE_LANGUAGE_MODELS, {\n first: PAGE_SIZE,\n offset,\n });\n largeLanguageModels.push(...nodes);\n offset += PAGE_SIZE;\n shouldContinue = nodes.length === PAGE_SIZE;\n } while (shouldContinue);\n\n return largeLanguageModels.sort((a, b) => a.name.localeCompare(b.name));\n}\n","/* eslint-disable max-lines */\nimport {\n Optionalize,\n Requirize,\n apply,\n decodeCodec,\n getValues,\n} from '@transcend-io/type-utils';\nimport type { Handlebars } from '@transcend-io/handlebars-utils';\nimport { Secret } from '@transcend-io/secret-value';\nimport * as t from 'io-ts';\nimport { DEFAULT_TRANSCEND_API } from '../../constants';\nimport {\n Agent,\n AgentFile,\n AgentFileFilterBy,\n ReportPromptRunInput,\n buildTranscendGraphQLClient,\n fetchAllAgentFiles,\n fetchAllAgents,\n reportPromptRun,\n} from '../graphql';\nimport {\n HandlebarsInput,\n createHandlebarsWithHelpers,\n} from '@transcend-io/handlebars-utils';\nimport {\n TranscendPromptTemplated,\n TranscendPromptsAndVariables,\n fetchPromptsWithVariables,\n} from '../graphql/fetchPrompts';\nimport { GraphQLClient } from 'graphql-request';\nimport {\n PromptStatus,\n ChatCompletionRole,\n PromptRunProductArea,\n QueueStatus,\n LargeLanguageModelClient,\n} from '@transcend-io/privacy-types';\nimport {\n LargeLanguageModel,\n fetchAllLargeLanguageModels,\n} from '../graphql/fetchLargeLanguageModels';\nimport { groupBy, keyBy, uniq, chunk } from 'lodash-es';\nimport { mapSeries } from '../bluebird';\nimport {\n PromptThread,\n fetchAllPromptThreads,\n} from '../graphql/fetchPromptThreads';\n\n/**\n * An LLM Prompt definition\n */\nexport type TranscendPrompt<\n TInputParams extends t.Any,\n TOutputCodec extends t.Any,\n> = (\n | {\n /** ID of the prompt */\n id: string;\n /** Title of the prompt */\n title?: string;\n }\n | {\n /** ID of the prompt */\n id?: string;\n /** Title of the prompt */\n title: string;\n }\n) & {\n /** The names of the agents that should be loaded along with the prompt */\n agentNames?: string[];\n /** Codec to validate runtime input shape */\n paramCodec: TInputParams;\n /** Codec to validate output response */\n outputCodec: TOutputCodec;\n /**\n * If the output that needs to be parsed is returned within a tag\n * e.g. <tag> or <json> - this is the name of the tag\n */\n extractFromTag?: string;\n};\n\nexport interface PromptRunResult {\n /** The ID of the prompt run created on Transcend */\n promptRunId: string;\n /** The URL of the prompt run on Transcend */\n promptRunUrl: string;\n}\n\n/**\n * Create a regex to extract data from a tag\n *\n * Input:\n * \"here is some data <tag>Data</tag>...\"\n *\n * @param tagName - Name of tag\n * @returns Data within the tag\n */\nexport function createRegexForTag(tagName: string): RegExp {\n return new RegExp(`<${tagName}>([\\\\s\\\\S]+?)<\\\\/${tagName}>`);\n}\n\n/**\n * Helper function to declare prompts\n *\n * @param prompts - Prompt config\n * @returns Prompts as identity function - but type enforced\n */\nexport function defineTranscendPrompts<\n TPromptNames extends string,\n TPrompts extends { [k in TPromptNames]: TranscendPrompt<t.Any, t.Any> },\n>(prompts: TPrompts): TPrompts {\n return prompts;\n}\n\n/**\n * Helper to get the type of the parameter for a given prompt\n */\nexport type GetPromptParamType<\n TPromptName extends keyof TPrompts,\n TPrompts extends { [k in TPromptName]: TranscendPrompt<t.Any, t.Any> },\n> = t.TypeOf<TPrompts[TPromptName]['paramCodec']>;\n\n/**\n * Helper to get the type of the parameter for a given prompt\n */\nexport type GetPromptResponseType<\n TPromptName extends keyof TPrompts,\n TPrompts extends { [k in TPromptName]: TranscendPrompt<t.Any, t.Any> },\n> = t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n\n/**\n * Input for reporting a prompt run\n */\nexport interface ReportPromptRunOptions\n extends Optionalize<\n Omit<ReportPromptRunInput, 'status' | 'promptId' | 'largeLanguageModelId'>,\n 'name' | 'productArea'\n > {\n /** The large language model being run. Either the ID of the LLM or the client/name pairing */\n largeLanguageModel:\n | string\n | {\n /** Name of client */\n client: LargeLanguageModelClient;\n /** Name of the model */\n name: string;\n };\n}\n\nconst jsonParseSafe = (obj: string): unknown => {\n try {\n return JSON.parse(obj);\n } catch (e) {\n return obj;\n }\n};\n\n/**\n * A class that is capable of loading and insert variables into prompts from\n * Transcend's Prompt Manager\n */\nexport class TranscendPromptManager<\n TPromptNames extends string,\n TPrompts extends { [k in TPromptNames]: TranscendPrompt<t.Any, t.Any> },\n> {\n /** Prompt definitions */\n public prompts: TPrompts;\n\n /** Options for configuring handlebars */\n public handlebarsOptions!: HandlebarsInput;\n\n /** Prompt name -> content map, populated by call to Transcend API */\n public promptContentMap?: { [k in TPromptNames]: TranscendPromptTemplated };\n\n /** The large language models that are registered to this organization for reporting */\n public largeLanguageModels: LargeLanguageModel[] = [];\n\n /** The agent definitions registered to this organization */\n private agentsByName: { [name in string]: Agent } = {};\n\n /** The agent definitions registered to this organization */\n private agentsByAgentId: { [id in string]: Agent } = {};\n\n /** The GraphQL client that can be used to call Transcend */\n public graphQLClient: GraphQLClient;\n\n /** The set of variables to expose in handlebars context specified at class initiation */\n public defaultVariables: { [k in string]: unknown };\n\n /**\n * The set of variables to expose in handlebars context,\n * merges defaults with calculated variables from the inventory\n */\n public variables: { [k in string]: unknown };\n\n /** Handlebars compiler */\n public handlebars: typeof Handlebars;\n\n /** The Transcend API key */\n public transcendApiKey: string | Secret<string>;\n\n /** API of Transcend to call */\n public transcendUrl: string;\n\n /** When true, throw an error if the prompt is not approved */\n public requireApproval: boolean;\n\n /**\n * The cache duration in ms for how long prompts and associated metadata should be cached\n * When undefined - prompts are cached indefinitely unless explicitly re-requested\n * When 0, prompts and metadata are fetched every time (not recommended)\n * Setting this to be an hour is a good rate that optimizes for performance and keeping up to date\n */\n public cacheDuration?: number;\n\n /**\n * The last time the metadata was fetched\n */\n public lastUpdatedAt?: Date;\n\n /**\n * Constructor\n *\n * @param options - Options\n */\n constructor({\n prompts,\n handlebarsOptions = {},\n transcendUrl = DEFAULT_TRANSCEND_API,\n transcendApiKey,\n requireApproval = true,\n cacheDuration,\n defaultVariables = {},\n }: {\n /** Prompt definitions to load */\n prompts: TPrompts;\n /** Options for configuring handlebars */\n handlebarsOptions?: HandlebarsInput;\n /** The Transcend API key */\n transcendApiKey: string | Secret<string>;\n /** API of Transcend to call */\n transcendUrl?: string;\n /** When true, throw an error if the prompt is not approved */\n requireApproval?: boolean;\n /** The set of variables to expose in handlebars context specified at class initiation */\n defaultVariables?: { [k in string]: unknown };\n /**\n * The cache duration in ms for how long prompts and associated metadata should be cached\n * When undefined - prompts are cached indefinitely unless explicitly re-requested\n * When 0, prompts and metadata are fetched every time (not recommended)\n * Setting this to be an hour is a good rate that optimizes for performance and keeping up to date\n */\n cacheDuration?: number;\n }) {\n this.prompts = prompts;\n this.transcendUrl = transcendUrl;\n this.transcendApiKey = transcendApiKey;\n this.variables = defaultVariables;\n this.defaultVariables = defaultVariables;\n this.graphQLClient = buildTranscendGraphQLClient(\n transcendUrl,\n typeof transcendApiKey === 'object'\n ? transcendApiKey.release()\n : transcendApiKey,\n );\n this.requireApproval = requireApproval;\n this.cacheDuration = cacheDuration;\n this.handlebarsOptions = handlebarsOptions;\n this.handlebars = createHandlebarsWithHelpers(handlebarsOptions);\n }\n\n /**\n * Fetch prompt metadata from Transcend and cache to the class definition\n *\n * @returns A function that can be used to call the prompt\n */\n async fetchPromptsAndMetadata(): Promise<TranscendPromptsAndVariables> {\n // Determine what to fetch\n const promptDefinitions = getValues(this.prompts) as TranscendPrompt<\n t.Any,\n t.Any\n >[];\n const promptIds = promptDefinitions\n .map(({ id }) => id)\n .filter((x): x is string => !!x);\n const promptTitles = promptDefinitions\n .map(({ title }) => title)\n .filter((x): x is string => !!x);\n const agentNames = uniq(\n promptDefinitions.map(({ agentNames }) => agentNames || []).flat(),\n );\n\n // Fetch prompts and data\n const [response, largeLanguageModels, agents] = await Promise.all([\n fetchPromptsWithVariables(this.graphQLClient, {\n promptIds,\n promptTitles,\n }),\n fetchAllLargeLanguageModels(this.graphQLClient),\n fetchAllAgents(this.graphQLClient, { names: agentNames }),\n ]);\n this.agentsByName = keyBy(agents, 'name');\n this.agentsByAgentId = keyBy(agents, 'agentId');\n this.largeLanguageModels = largeLanguageModels.filter(\n (model) => model.isTranscendHosted === false,\n );\n\n // Lookup prompts by id/title\n const promptByTitle = keyBy(response.prompts, 'title');\n const promptById = keyBy(response.prompts, 'id');\n\n // Update variables\n this.variables = {\n ...response.calculatedVariables.reduce(\n (acc, v) =>\n Object.assign(acc, {\n [v.name]: v.data ? JSON.parse(v.data) : v.data,\n }),\n {},\n ),\n ...this.defaultVariables,\n };\n\n // Update partials\n this.handlebars = createHandlebarsWithHelpers({\n ...this.handlebarsOptions,\n templates: [\n ...(this.handlebarsOptions.templates || []),\n ...response.promptPartials.map((partial) => ({\n name: partial.slug,\n content: partial.content,\n })),\n ],\n });\n\n // Create mapping from prompt to content\n this.promptContentMap = apply(this.prompts, ({ id, title }) => {\n const result = id\n ? promptById[id]\n : title\n ? promptByTitle[title]\n : undefined;\n if (!result) {\n throw new Error(\n `Failed to find prompt with title: \"${title}\" and id: \"${id}\"`,\n );\n }\n return result;\n });\n\n // For cache\n this.lastUpdatedAt = new Date();\n\n return response;\n }\n\n /**\n * Get an agent definition by name\n *\n * @param name - Name of the agent to grab\n * @returns Large language model configuration\n */\n async getAgentByName(name: string): Promise<Agent | undefined> {\n const agent = this.agentsByName[name];\n if (agent) {\n return agent;\n }\n const [remoteAgent] = await fetchAllAgents(this.graphQLClient, {\n names: [name],\n });\n if (!remoteAgent) {\n return undefined;\n }\n this.agentsByName[remoteAgent.name] = remoteAgent;\n this.agentsByAgentId[remoteAgent.agentId] = remoteAgent;\n return remoteAgent;\n }\n\n /**\n * Get a prompt thread by ts\n *\n * @param ts - the slack message timestamp to look up thread for\n * @returns Large language model configuration\n */\n async getPromptThreadBySlackTs(\n ts: string,\n ): Promise<PromptThread | undefined> {\n const [thread] = await fetchAllPromptThreads(this.graphQLClient, {\n slackMessageTs: [ts],\n });\n return thread;\n }\n\n /**\n * Get a list of agent definitions by name.\n * Pulls from cache and may return less agents\n * than requested if some are not found\n *\n * @param names - Names of agents to fetch\n * @returns The agents that were found matching the names\n */\n async getAgentsByName(names: string[]): Promise<Agent[]> {\n if (names.length < 1) {\n throw new Error('Expected at least one name to be provided');\n }\n const { hasCache = [], missingCache = [] } = groupBy(names, (name) =>\n this.agentsByName[name] ? 'hasCache' : 'missingCache',\n );\n const cachedAgents = hasCache.map((name) => this.agentsByName[name]);\n if (missingCache.length === 0) {\n return cachedAgents;\n }\n const chunkedNames = chunk(missingCache, 50);\n const remoteAgents: Agent[] = [];\n await mapSeries(chunkedNames, async (chunkedName) => {\n const pageOfAgents = await fetchAllAgents(this.graphQLClient, {\n names: chunkedName,\n });\n pageOfAgents.forEach((agent) => {\n this.agentsByName[agent.name] = agent;\n this.agentsByAgentId[agent.agentId] = agent;\n });\n remoteAgents.push(...pageOfAgents);\n });\n return [...cachedAgents, ...remoteAgents];\n }\n\n /**\n * Fetch metadata on agent files\n *\n * @param filterBy - Filter by parameters\n * @returns The files found matching the filter\n */\n getAgentFiles(filterBy: AgentFileFilterBy): Promise<AgentFile[]> {\n return fetchAllAgentFiles(this.graphQLClient, filterBy);\n }\n\n /**\n * Look up the large language model to report on\n *\n * @param largeLanguageModel - Input\n * @returns Large language model configuration\n */\n getLargeLanguageModel(\n largeLanguageModel: ReportPromptRunOptions['largeLanguageModel'],\n ): LargeLanguageModel {\n const matching = this.largeLanguageModels.find((model) =>\n typeof largeLanguageModel === 'string'\n ? model.id === largeLanguageModel\n : model.name === largeLanguageModel.name &&\n model.client === largeLanguageModel.client,\n );\n if (!matching) {\n throw new Error(\n `Failed to find model matching: ${\n typeof largeLanguageModel === 'string'\n ? largeLanguageModel\n : JSON.stringify(largeLanguageModel)\n }`,\n );\n }\n return matching;\n }\n\n /**\n * Get a prompt definition by name\n *\n * @param promptName - Prompt to compile\n * @returns Parsed content\n */\n async getPromptDefinition<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n ): Promise<TranscendPromptTemplated> {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration &&\n Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n // Lookup prompt\n const { promptContentMap } = this;\n if (!promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n const promptTemplate = promptContentMap[promptName];\n if (!promptTemplate) {\n throw new Error(\n `Expected this.promptContentMap[${promptName}] to be defined`,\n );\n }\n return promptTemplate;\n }\n\n /**\n * Validate the shape of the response from AI\n *\n * @param promptName - Prompt to compile\n * @param params - Runtime parameters\n * @returns Parsed content\n */\n async compilePrompt<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n params: t.TypeOf<TPrompts[TPromptName]['paramCodec']>,\n ): Promise<string> {\n // Grab the prompt\n const promptTemplate = await this.getPromptDefinition(promptName);\n const promptInput = this.prompts[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure prompt is approved\n if (\n this.requireApproval &&\n promptTemplate.status !== PromptStatus.Approved\n ) {\n throw new Error(\n `Assessment \"${promptTemplate.title}\" cannot be used because its in status: \"${promptTemplate.status}\"`,\n );\n }\n\n // If prompt is rejected, throw error\n if (promptTemplate.status === PromptStatus.Rejected) {\n throw new Error(\n `Assessment \"${promptTemplate.title}\" cannot be used because it's in status: \"${promptTemplate.status}\"`,\n );\n }\n\n // Validate params\n decodeCodec(promptInput.paramCodec, params);\n\n // Compile prompt and template\n return this.handlebars.compile(promptTemplate.content)({\n // template in currentDate by default\n currentDate: new Date().toISOString(),\n ...this.variables,\n ...params,\n });\n }\n\n /**\n * Validate the shape of the response from AI\n *\n * @param promptName - Prompt to parse\n * @param response - AI response as string\n * @returns Parsed content\n */\n parseAiResponse<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n response: string,\n ): t.TypeOf<TPrompts[TPromptName]['outputCodec']> {\n // Look up prompt info\n const promptInput = this.prompts[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Extract from tag if needed\n const extracted = promptInput.extractFromTag\n ? (createRegexForTag(promptInput.extractFromTag).exec(response) ||\n [])[1] || response\n : response;\n\n // Parse via codec\n return decodeCodec(\n promptInput.outputCodec,\n jsonParseSafe(extracted),\n false,\n );\n }\n\n /**\n * Parse the AI response and report back to Transcend\n *\n * @param promptName - Prompt to parse\n * @param options - Options for reporting\n * @returns Parsed content\n */\n async reportAndParsePromptRun<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n { largeLanguageModel, ...options }: ReportPromptRunOptions,\n ): Promise<\n PromptRunResult & {\n /** Resulting prompt run */\n result: t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n }\n > {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration &&\n Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n const name =\n options.name ||\n `@transcend-io/cli-prompt-run-${new Date().toISOString()}`;\n\n if (!this.promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n // Look up prompt info\n const promptInput = this.promptContentMap[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure the first message in `promptRunMessages` is of type=system\n if (options.promptRunMessages.length === 0) {\n throw new Error('promptRunMessages is expected to have length > 0');\n }\n if (options.promptRunMessages[0].role !== ChatCompletionRole.System) {\n throw new Error(\n `promptRunMessages[0].role is expected to be = ${ChatCompletionRole.System}`,\n );\n }\n if (\n options.promptRunMessages[options.promptRunMessages.length - 1].role !==\n ChatCompletionRole.Assistant\n ) {\n throw new Error(\n `promptRunMessages[${\n options.promptRunMessages.length - 1\n }].role is expected to be = ${ChatCompletionRole.Assistant}`,\n );\n }\n const response =\n options.promptRunMessages[options.promptRunMessages.length - 1].content;\n\n let parsed: t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n try {\n // Parse the response\n parsed = this.parseAiResponse(promptName, response);\n } catch (err) {\n await reportPromptRun(this.graphQLClient, {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n error: err.message,\n status: QueueStatus.Error,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n });\n throw err;\n }\n\n // report successful run\n const promptRunId = await reportPromptRun(this.graphQLClient, {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n status: QueueStatus.Resolved,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n });\n\n return {\n result: parsed,\n promptRunId,\n promptRunUrl: `https://app.transcend.io/prompts/runs/${promptRunId}`,\n };\n }\n\n /**\n * Report an error for a particular prompt\n *\n * @param promptName - Prompt to parse\n * @param options - Options for reporting\n * @returns Parsed content\n */\n async reportPromptRunError<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n {\n largeLanguageModel,\n ...options\n }: Requirize<ReportPromptRunOptions, 'error'>,\n ): Promise<PromptRunResult> {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration &&\n Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n const name =\n options.name ||\n `@transcend-io/cli-prompt-run-${new Date().toISOString()}`;\n\n if (!this.promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n // Look up prompt info\n const promptInput = this.promptContentMap[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure the first message in `promptRunMessages` is of type=system\n if (options.promptRunMessages.length === 0) {\n throw new Error('promptRunMessages is expected to have length > 0');\n }\n if (options.promptRunMessages[0].role !== ChatCompletionRole.System) {\n throw new Error(\n `promptRunMessages[0].role is expected to be = ${ChatCompletionRole.System}`,\n );\n }\n\n const promptRunId = await reportPromptRun(this.graphQLClient, {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n status: QueueStatus.Error,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n });\n\n return {\n promptRunId,\n promptRunUrl: `https://app.transcend.io/prompts/runs/${promptRunId}`,\n };\n }\n}\n/* eslint-enable max-lines */\n","/**\n * Remove links from a string\n *\n * @param inputString - String\n * @returns String without links\n */\nexport function removeLinks(inputString: string): string {\n const regex = /(https?:\\/\\/[^\\s]+)/g;\n return inputString.replace(regex, '<link-omitted>');\n}\n","import { ObjByString } from '@transcend-io/type-utils';\n\n/**\n * Given an object, remove all keys that are null-ish\n *\n * @param obj - Object\n * @returns Object with null-ish values removed\n */\nexport function filterNullishValuesFromObject<T extends ObjByString>(\n obj: T,\n): T {\n return Object.entries(obj).reduce(\n (acc, [k, v]) =>\n v !== null &&\n v !== undefined &&\n v !== '' &&\n !(Array.isArray(v) && v.length === 0) &&\n !(typeof v === 'object' && Object.keys(v).length === 0)\n ? Object.assign(acc, { [k]: v })\n : acc,\n {} as T,\n );\n}\n","import { difference } from 'lodash-es';\nimport fastGlob from 'fast-glob';\nimport { execSync } from 'child_process';\n\n/**\n * Function thats gets the git files that have changed\n * and returns the code\n *\n * @param options - Options\n * @returns Changes files and diffs\n */\nexport function getGitFilesThatChanged({\n baseBranch,\n rootDirectory,\n githubRepo,\n excludedGlob = [],\n fileBlockList = [],\n}: {\n /** Base branch */\n baseBranch: string;\n /** Github repo name */\n githubRepo: string;\n /** Root directory */\n rootDirectory: string;\n /** A glob that excludes files */\n excludedGlob?: string[];\n /** Block list of files to not process */\n fileBlockList?: string[];\n}): {\n /** The list of files that changed */\n changedFiles: string[];\n /** Github repo name */\n repoName: string;\n /** Current commit */\n commit: string;\n /** File diffs */\n fileDiffs: { [k in string]: string };\n} {\n // Pull base branch\n execSync(`git fetch origin ${baseBranch}`);\n\n // Latest commit on base branch. If we are on the base branch, we take the prior commit\n const latestBasedCommit = execSync(\n `git ls-remote ${githubRepo} \"refs/heads/${baseBranch}\" | cut -f 1`,\n { encoding: 'utf-8' },\n ).split('\\n')[0];\n\n // This commit\n const latestThisCommit = execSync('git rev-parse HEAD', {\n encoding: 'utf-8',\n }).split('\\n')[0];\n\n // Ensure commits are present\n if (!latestBasedCommit || !latestThisCommit) {\n throw new Error('FAILED TO FIND COMMIT RANGE');\n }\n\n // Get the diff between the given branch and base branch\n const diff = execSync(\n `git fetch && git diff --name-only \"${\n baseBranch || latestBasedCommit\n }...${latestThisCommit}\" -- ${rootDirectory}`,\n { encoding: 'utf-8' },\n );\n\n // Filter out block list\n const changedFiles = difference(\n diff.split('\\n').filter((f) => f),\n fileBlockList,\n );\n\n // Filter out globs\n const filteredChanges =\n excludedGlob.length > 0\n ? fastGlob.sync(changedFiles, { ignore: excludedGlob })\n : changedFiles;\n\n // Get the contents of only the changed files\n const fileDiffs: { [k in string]: string } = {};\n filteredChanges.forEach((file) => {\n const contents = execSync(`git show ${latestThisCommit}:${file}`, {\n encoding: 'utf-8',\n });\n fileDiffs[file] = contents;\n });\n\n // Pull the github repo name\n const repoName = githubRepo.split('/').pop()!.split('.')[0];\n\n return {\n changedFiles,\n fileDiffs,\n repoName,\n commit: latestThisCommit,\n };\n}\n"],"mappings":"yzBAgBA,MAAM,EAAY,GAQlB,eAAsB,EACpB,EAC+B,CAC/B,IAAM,EAA4C,EAAE,CAChD,EAAS,EAGT,EAAiB,GACrB,EAAG,CACD,GAAM,CACJ,oBAAqB,CAAE,UACrB,MAAMA,EAAAA,EAMP,EAAQC,EAAAA,GAAuB,CAChC,MAAO,GACP,SACD,CAAC,CACF,EAAoB,KAAK,GAAG,EAAM,CAClC,GAAU,GACV,EAAiB,EAAM,SAAW,SAC3B,GAET,OAAO,EAAoB,MAAM,EAAG,IAAM,EAAE,KAAK,cAAc,EAAE,KAAK,CAAC,CCiDz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AAC,KAAK,CAAE,MAAM,IAAI,CAAC,GAMvD,OAAQ,EACT"}
package/dist/index.d.cts CHANGED
@@ -134872,6 +134872,8 @@ declare function markSilentPrivacyRequests({
134872
134872
  statuses,
134873
134873
  createdAtAfter,
134874
134874
  createdAtBefore,
134875
+ updatedAtBefore,
134876
+ updatedAtAfter,
134875
134877
  concurrency,
134876
134878
  transcendUrl
134877
134879
  }: {
@@ -134889,6 +134891,10 @@ declare function markSilentPrivacyRequests({
134889
134891
  createdAtBefore?: Date;
134890
134892
  /** Filter for requests created after this date */
134891
134893
  createdAtAfter?: Date;
134894
+ /** Filter for requests updated before this date */
134895
+ updatedAtBefore?: Date;
134896
+ /** Filter for requests updated after this date */
134897
+ updatedAtAfter?: Date;
134892
134898
  /** API URL for Transcend backend */
134893
134899
  transcendUrl?: string;
134894
134900
  }): Promise<number>;
@@ -136800,10 +136806,19 @@ interface RequestIdentifierMetadata {
136800
136806
  * @returns List of request identifiers
136801
136807
  */
136802
136808
  declare function fetchAllRequestIdentifierMetadata(client: GraphQLClient, {
136803
- requestId
136809
+ requestId,
136810
+ requestIds,
136811
+ updatedAtBefore,
136812
+ updatedAtAfter
136804
136813
  }: {
136805
136814
  /** ID of request to filter on */
136806
- requestId: string;
136815
+ requestId?: string;
136816
+ /** IDs of requests to filter on */
136817
+ requestIds?: string[];
136818
+ /** Filter for request identifiers updated before this date */
136819
+ updatedAtBefore?: Date;
136820
+ /** Filter for request identifiers updated after this date */
136821
+ updatedAtAfter?: Date;
136807
136822
  }): Promise<RequestIdentifierMetadata[]>;
136808
136823
  //#endregion
136809
136824
  //#region src/lib/graphql/fetchAllRequestIdentifiers.d.ts
@@ -142660,6 +142675,8 @@ declare function fetchAllRequests(client: GraphQLClient, {
142660
142675
  text,
142661
142676
  createdAtBefore,
142662
142677
  createdAtAfter,
142678
+ updatedAtBefore,
142679
+ updatedAtAfter,
142663
142680
  isTest,
142664
142681
  isSilent,
142665
142682
  isClosed,
@@ -142675,6 +142692,10 @@ declare function fetchAllRequests(client: GraphQLClient, {
142675
142692
  createdAtBefore?: Date;
142676
142693
  /** Filter for requests created after this date */
142677
142694
  createdAtAfter?: Date;
142695
+ /** Filter for requests updated before this date */
142696
+ updatedAtBefore?: Date;
142697
+ /** Filter for requests updated after this date */
142698
+ updatedAtAfter?: Date;
142678
142699
  /** Filter for requests with a specific identifier */
142679
142700
  text?: string;
142680
142701
  /** Return test requests */
@@ -150714,6 +150735,8 @@ declare function downloadPrivacyRequestFiles({
150714
150735
  createdAtBefore,
150715
150736
  sombraAuth,
150716
150737
  createdAtAfter,
150738
+ updatedAtBefore,
150739
+ updatedAtAfter,
150717
150740
  statuses,
150718
150741
  concurrency,
150719
150742
  transcendUrl,
@@ -150735,6 +150758,10 @@ declare function downloadPrivacyRequestFiles({
150735
150758
  createdAtBefore?: Date;
150736
150759
  /** Filter for requests created after this date */
150737
150760
  createdAtAfter?: Date;
150761
+ /** Filter for requests updated before this date */
150762
+ updatedAtBefore?: Date;
150763
+ /** Filter for requests updated after this date */
150764
+ updatedAtAfter?: Date;
150738
150765
  /** API URL for Transcend backend */
150739
150766
  transcendUrl?: string;
150740
150767
  /** When true, approve any requests in Transcend that are in status=APPROVING */
@@ -156229,6 +156256,8 @@ declare function approvePrivacyRequests({
156229
156256
  silentModeBefore,
156230
156257
  createdAtAfter,
156231
156258
  createdAtBefore,
156259
+ updatedAtBefore,
156260
+ updatedAtAfter,
156232
156261
  concurrency,
156233
156262
  transcendUrl
156234
156263
  }: {
@@ -156246,6 +156275,10 @@ declare function approvePrivacyRequests({
156246
156275
  createdAtBefore?: Date;
156247
156276
  /** Filter for requests created after this date */
156248
156277
  createdAtAfter?: Date;
156278
+ /** Filter for requests updated before this date */
156279
+ updatedAtBefore?: Date;
156280
+ /** Filter for requests updated after this date */
156281
+ updatedAtAfter?: Date;
156249
156282
  /** API URL for Transcend backend */
156250
156283
  transcendUrl?: string;
156251
156284
  }): Promise<number>;
@@ -156266,6 +156299,8 @@ declare function notifyPrivacyRequestsAdditionalTime({
156266
156299
  days,
156267
156300
  daysLeft,
156268
156301
  createdAtAfter,
156302
+ updatedAtBefore,
156303
+ updatedAtAfter,
156269
156304
  emailTemplate,
156270
156305
  concurrency,
156271
156306
  transcendUrl
@@ -156276,6 +156311,10 @@ declare function notifyPrivacyRequestsAdditionalTime({
156276
156311
  createdAtBefore: Date;
156277
156312
  /** Filter for requests created after this date */
156278
156313
  createdAtAfter?: Date;
156314
+ /** Filter for requests updated before this date */
156315
+ updatedAtBefore?: Date;
156316
+ /** Filter for requests updated after this date */
156317
+ updatedAtAfter?: Date;
156279
156318
  /** Email template */
156280
156319
  emailTemplate?: string;
156281
156320
  /** Transcend API key authentication */
@@ -156310,6 +156349,8 @@ declare function cancelPrivacyRequests({
156310
156349
  silentModeBefore,
156311
156350
  createdAtBefore,
156312
156351
  createdAtAfter,
156352
+ updatedAtBefore,
156353
+ updatedAtAfter,
156313
156354
  statuses,
156314
156355
  concurrency,
156315
156356
  transcendUrl
@@ -156330,6 +156371,10 @@ declare function cancelPrivacyRequests({
156330
156371
  createdAtBefore?: Date;
156331
156372
  /** Filter for requests created after this date */
156332
156373
  createdAtAfter?: Date;
156374
+ /** Filter for requests updated before this date */
156375
+ updatedAtBefore?: Date;
156376
+ /** Filter for requests updated after this date */
156377
+ updatedAtAfter?: Date;
156333
156378
  /** API URL for Transcend backend */
156334
156379
  transcendUrl?: string;
156335
156380
  /** The email template to use when canceling the requests */
@@ -156602,6 +156647,8 @@ declare function bulkRestartRequests({
156602
156647
  requestStatuses,
156603
156648
  createdAtBefore,
156604
156649
  createdAtAfter,
156650
+ updatedAtBefore,
156651
+ updatedAtAfter,
156605
156652
  transcendUrl,
156606
156653
  requestIds,
156607
156654
  createdAt,
@@ -156642,6 +156689,10 @@ declare function bulkRestartRequests({
156642
156689
  createdAtBefore?: Date;
156643
156690
  /** Filter for requests created after this date */
156644
156691
  createdAtAfter?: Date;
156692
+ /** Filter for requests updated before this date */
156693
+ updatedAtBefore?: Date;
156694
+ /** Filter for requests updated after this date */
156695
+ updatedAtAfter?: Date;
156645
156696
  /** Concurrency to upload requests at */
156646
156697
  concurrency?: number;
156647
156698
  }): Promise<void>;
@@ -156707,6 +156758,8 @@ declare function bulkRetryEnrichers({
156707
156758
  requestActions,
156708
156759
  createdAtBefore,
156709
156760
  createdAtAfter,
156761
+ updatedAtBefore,
156762
+ updatedAtAfter,
156710
156763
  transcendUrl,
156711
156764
  requestEnricherStatuses,
156712
156765
  requestIds,
@@ -156729,6 +156782,10 @@ declare function bulkRetryEnrichers({
156729
156782
  createdAtBefore?: Date;
156730
156783
  /** Filter for requests created after this date */
156731
156784
  createdAtAfter?: Date;
156785
+ /** Filter for requests updated before this date */
156786
+ updatedAtBefore?: Date;
156787
+ /** Filter for requests updated after this date */
156788
+ updatedAtAfter?: Date;
156732
156789
  /** Concurrency to upload requests at */
156733
156790
  concurrency?: number;
156734
156791
  }): Promise<void>;
@@ -156781,6 +156838,8 @@ declare function pullPrivacyRequests({
156781
156838
  createdAtBefore,
156782
156839
  skipRequestIdentifiers,
156783
156840
  createdAtAfter,
156841
+ updatedAtBefore,
156842
+ updatedAtAfter,
156784
156843
  isTest
156785
156844
  }: {
156786
156845
  /** Transcend API key authentication */
@@ -156801,6 +156860,10 @@ declare function pullPrivacyRequests({
156801
156860
  createdAtBefore?: Date;
156802
156861
  /** Filter for requests created after this date */
156803
156862
  createdAtAfter?: Date;
156863
+ /** Filter for requests updated before this date */
156864
+ updatedAtBefore?: Date;
156865
+ /** Filter for requests updated after this date */
156866
+ updatedAtAfter?: Date;
156804
156867
  /** Return test requests */
156805
156868
  isTest?: boolean;
156806
156869
  /** Skip fetching request identifier */
@@ -1,2 +1,2 @@
1
- const e=require(`./enums-CBXlBJii.cjs`);let t=require(`colors`);t=e.s(t);let n=require(`global-agent`),r=require(`undici`),i=require(`yargs-parser`);i=e.s(i);const a=console,{httpProxy:o=process.env.http_proxy}=(0,i.default)(process.argv.slice(2));o&&(a.info(t.default.green(`Initializing proxy: ${o}`)),process.env.GLOBAL_AGENT_HTTP_PROXY=o,(0,n.bootstrap)(),(0,r.setGlobalDispatcher)(new r.ProxyAgent(o))),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
2
- //# sourceMappingURL=logger-BaHHbWVd.cjs.map
1
+ const e=require(`./chunk-Bmb41Sf3.cjs`);let t=require(`colors`);t=e.t(t);let n=require(`global-agent`),r=require(`undici`),i=require(`yargs-parser`);i=e.t(i);const a=console,{httpProxy:o=process.env.http_proxy}=(0,i.default)(process.argv.slice(2));o&&(a.info(t.default.green(`Initializing proxy: ${o}`)),process.env.GLOBAL_AGENT_HTTP_PROXY=o,(0,n.bootstrap)(),(0,r.setGlobalDispatcher)(new r.ProxyAgent(o))),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
2
+ //# sourceMappingURL=logger-DQwEYtSS.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger-BaHHbWVd.cjs","names":["ProxyAgent"],"sources":["../src/logger.ts"],"sourcesContent":["import colors from 'colors';\nimport { bootstrap } from 'global-agent';\nimport { ProxyAgent, setGlobalDispatcher } from 'undici';\nimport yargs from 'yargs-parser';\n\nexport const logger = console;\n\n// When the proxy env var of flag is specified, initiate the proxy\nconst { httpProxy = process.env.http_proxy } = yargs(process.argv.slice(2));\nif (httpProxy) {\n logger.info(colors.green(`Initializing proxy: ${httpProxy}`));\n\n // Use global-agent, which overrides `request` based requests\n process.env.GLOBAL_AGENT_HTTP_PROXY = httpProxy;\n bootstrap();\n\n // Use undici, which overrides `fetch` based requests\n setGlobalDispatcher(new ProxyAgent(httpProxy));\n}\n"],"mappings":"8JAKA,MAAa,EAAS,QAGhB,CAAE,YAAY,QAAQ,IAAI,aAAA,EAAA,EAAA,SAAqB,QAAQ,KAAK,MAAM,EAAE,CAAC,CACvE,IACF,EAAO,KAAK,EAAA,QAAO,MAAM,uBAAuB,IAAY,CAAC,CAG7D,QAAQ,IAAI,wBAA0B,GACtC,EAAA,EAAA,YAAW,EAGX,EAAA,EAAA,qBAAoB,IAAIA,EAAAA,WAAW,EAAU,CAAC"}
1
+ {"version":3,"file":"logger-DQwEYtSS.cjs","names":["ProxyAgent"],"sources":["../src/logger.ts"],"sourcesContent":["import colors from 'colors';\nimport { bootstrap } from 'global-agent';\nimport { ProxyAgent, setGlobalDispatcher } from 'undici';\nimport yargs from 'yargs-parser';\n\nexport const logger = console;\n\n// When the proxy env var of flag is specified, initiate the proxy\nconst { httpProxy = process.env.http_proxy } = yargs(process.argv.slice(2));\nif (httpProxy) {\n logger.info(colors.green(`Initializing proxy: ${httpProxy}`));\n\n // Use global-agent, which overrides `request` based requests\n process.env.GLOBAL_AGENT_HTTP_PROXY = httpProxy;\n bootstrap();\n\n // Use undici, which overrides `fetch` based requests\n setGlobalDispatcher(new ProxyAgent(httpProxy));\n}\n"],"mappings":"8JAKA,MAAa,EAAS,QAGhB,CAAE,YAAY,QAAQ,IAAI,aAAA,EAAA,EAAA,SAAqB,QAAQ,KAAK,MAAM,EAAE,CAAC,CACvE,IACF,EAAO,KAAK,EAAA,QAAO,MAAM,uBAAuB,IAAY,CAAC,CAG7D,QAAQ,IAAI,wBAA0B,GACtC,EAAA,EAAA,YAAW,EAGX,EAAA,EAAA,qBAAoB,IAAIA,EAAAA,WAAW,EAAU,CAAC"}
@@ -1,2 +1,2 @@
1
- const e=require(`./enums-CBXlBJii.cjs`),t=require(`./constants-JoCDv9ym.cjs`),n=require(`./syncConfigurationToTranscend-D4PLA70C.cjs`),r=require(`./logger-BaHHbWVd.cjs`);let i=require(`@transcend-io/privacy-types`),a=require(`colors`);a=e.s(a);let o=require(`io-ts`);o=e.s(o);async function s({file:e,auth:o,sombraAuth:s,requestActions:c=[],concurrency:l=100,transcendUrl:u=t.a}){let d=n.ti(u,o),f=await n.ei(u,o,s);r.t.info(a.default.magenta(`Pulling manual enrichment requests, filtered for actions: ${c.join(`,`)}`));let p=await n.fr(d,{actions:c,statuses:[i.RequestStatus.Enriching]}),m=[];await n.Ts(p,async e=>{let t=await n.gr(d,{requestId:e.id});if(t.filter(({status:e})=>e===`ACTION_REQUIRED`)){let r=await n.mr(d,f,{requestId:e.id});m.push({...e,requestIdentifiers:r,requestEnrichers:t})}},{concurrency:l});let h=m.map(({attributeValues:e,requestIdentifiers:t,requestEnrichers:r,...i})=>({...i,...Object.entries(n.As(t,`name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({value:e})=>e).join(`,`)}),{}),...Object.entries(n.As(e,`attributeKey.name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({name:e})=>e).join(`,`)}),{})}));return await n.l(e,h,n.Ds(h.map(e=>Object.keys(e)).flat())),r.t.info(a.default.green(`Successfully wrote ${m.length} requests to file "${e}"`)),m}const c=`https://app.transcend.io/privacy-requests/incoming-requests/`,l=o.record(o.string,o.string);async function u(e,{id:t,...i},o,s){if(!t){let e=`Request ID must be provided to enricher request.${s?` Found error in row: ${s}`:``}`;throw r.t.error(a.default.red(e)),Error(e)}let l=t.toLowerCase(),u=Object.entries(i).reduce((e,[t,r])=>n.Ds(n.li(r)).length===0?e:Object.assign(e,{[t]:n.Ds(n.li(r)).map(e=>({value:t===`email`?e.toLowerCase():e}))}),{});try{return await e.post(`v1/enrich-identifiers`,{headers:{"x-transcend-request-id":l,"x-transcend-enricher-id":o},json:{enrichedIdentifiers:u}}).json(),r.t.error(a.default.green(`Successfully enriched request: ${c}${l}`)),!0}catch(e){if(typeof e.response.body==`string`&&e.response.body.includes(`Cannot update a resolved RequestEnricher`))return r.t.warn(a.default.magenta(`Skipped enrichment for request: ${c}${l}, request is no longer in the enriching phase.`)),!1;throw r.t.error(a.default.red(`Failed to enricher identifiers for request with id: ${c}${l} - ${e.message} - ${e.response.body}`)),e}}async function d({file:e,auth:i,sombraAuth:o,enricherId:s,markSilent:c,concurrency:d=100,transcendUrl:f=t.a}){let p=await n.ei(f,i,o),m=n.ti(f,i);r.t.info(a.default.magenta(`Reading "${e}" from disk`));let h=n.oi(e,l);r.t.info(a.default.magenta(`Enriching "${h.length}" privacy requests.`));let g=0,_=0,v=0;if(await n.Ts(h,async(e,t)=>{try{c&&(await n.i(m,n.Ao,{input:{id:e.id,isSilent:!0}}),r.t.info(a.default.magenta(`Mark request as silent mode - ${e.id}`))),await u(p,e,s,t)?g+=1:_+=1}catch{v+=1}},{concurrency:d}),r.t.info(a.default.green(`Successfully notified Transcend! \n Success count: ${g}.`)),_>0&&r.t.info(a.default.magenta(`Skipped count: ${_}.`)),v>0)throw r.t.info(a.default.red(`Error Count: ${v}.`)),Error(`Failed to enrich: ${v} requests.`);return h.length}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return d}});
2
- //# sourceMappingURL=manual-enrichment-D-0rM9KN.cjs.map
1
+ const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./constants-wkuhlP8d.cjs`),n=require(`./syncConfigurationToTranscend-DuTZKIG8.cjs`),r=require(`./logger-DQwEYtSS.cjs`);let i=require(`@transcend-io/privacy-types`),a=require(`colors`);a=e.t(a);let o=require(`io-ts`);o=e.t(o);async function s({file:e,auth:o,sombraAuth:s,requestActions:c=[],concurrency:l=100,transcendUrl:u=t.a}){let d=n.ti(u,o),f=await n.ei(u,o,s);r.t.info(a.default.magenta(`Pulling manual enrichment requests, filtered for actions: ${c.join(`,`)}`));let p=await n.fr(d,{actions:c,statuses:[i.RequestStatus.Enriching]}),m=[];await n.Ts(p,async e=>{let t=await n.gr(d,{requestId:e.id});if(t.filter(({status:e})=>e===`ACTION_REQUIRED`)){let r=await n.mr(d,f,{requestId:e.id});m.push({...e,requestIdentifiers:r,requestEnrichers:t})}},{concurrency:l});let h=m.map(({attributeValues:e,requestIdentifiers:t,requestEnrichers:r,...i})=>({...i,...Object.entries(n.As(t,`name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({value:e})=>e).join(`,`)}),{}),...Object.entries(n.As(e,`attributeKey.name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({name:e})=>e).join(`,`)}),{})}));return await n.l(e,h,n.Ds(h.map(e=>Object.keys(e)).flat())),r.t.info(a.default.green(`Successfully wrote ${m.length} requests to file "${e}"`)),m}const c=`https://app.transcend.io/privacy-requests/incoming-requests/`,l=o.record(o.string,o.string);async function u(e,{id:t,...i},o,s){if(!t){let e=`Request ID must be provided to enricher request.${s?` Found error in row: ${s}`:``}`;throw r.t.error(a.default.red(e)),Error(e)}let l=t.toLowerCase(),u=Object.entries(i).reduce((e,[t,r])=>n.Ds(n.li(r)).length===0?e:Object.assign(e,{[t]:n.Ds(n.li(r)).map(e=>({value:t===`email`?e.toLowerCase():e}))}),{});try{return await e.post(`v1/enrich-identifiers`,{headers:{"x-transcend-request-id":l,"x-transcend-enricher-id":o},json:{enrichedIdentifiers:u}}).json(),r.t.error(a.default.green(`Successfully enriched request: ${c}${l}`)),!0}catch(e){if(typeof e.response.body==`string`&&e.response.body.includes(`Cannot update a resolved RequestEnricher`))return r.t.warn(a.default.magenta(`Skipped enrichment for request: ${c}${l}, request is no longer in the enriching phase.`)),!1;throw r.t.error(a.default.red(`Failed to enricher identifiers for request with id: ${c}${l} - ${e.message} - ${e.response.body}`)),e}}async function d({file:e,auth:i,sombraAuth:o,enricherId:s,markSilent:c,concurrency:d=100,transcendUrl:f=t.a}){let p=await n.ei(f,i,o),m=n.ti(f,i);r.t.info(a.default.magenta(`Reading "${e}" from disk`));let h=n.oi(e,l);r.t.info(a.default.magenta(`Enriching "${h.length}" privacy requests.`));let g=0,_=0,v=0;if(await n.Ts(h,async(e,t)=>{try{c&&(await n.i(m,n.Ao,{input:{id:e.id,isSilent:!0}}),r.t.info(a.default.magenta(`Mark request as silent mode - ${e.id}`))),await u(p,e,s,t)?g+=1:_+=1}catch{v+=1}},{concurrency:d}),r.t.info(a.default.green(`Successfully notified Transcend! \n Success count: ${g}.`)),_>0&&r.t.info(a.default.magenta(`Skipped count: ${_}.`)),v>0)throw r.t.info(a.default.red(`Error Count: ${v}.`)),Error(`Failed to enrich: ${v} requests.`);return h.length}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return d}});
2
+ //# sourceMappingURL=manual-enrichment-CzTpv-mM.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"manual-enrichment-D-0rM9KN.cjs","names":["DEFAULT_TRANSCEND_API","buildTranscendGraphQLClient","createSombraGotInstance","fetchAllRequests","RequestStatus","map","fetchAllRequestEnrichers","fetchAllRequestIdentifiers","groupBy","writeCsv","uniq","t","uniq","splitCsvToList","DEFAULT_TRANSCEND_API","createSombraGotInstance","buildTranscendGraphQLClient","readCsv","map","makeGraphQLRequest","UPDATE_PRIVACY_REQUEST"],"sources":["../src/lib/manual-enrichment/pullManualEnrichmentIdentifiersToCsv.ts","../src/lib/manual-enrichment/enrichPrivacyRequest.ts","../src/lib/manual-enrichment/pushManualEnrichmentIdentifiersFromCsv.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport { map } from '../bluebird';\nimport colors from 'colors';\nimport { groupBy, uniq } from 'lodash-es';\nimport { DEFAULT_TRANSCEND_API } from '../../constants';\nimport { writeCsv } from '../helpers/writeCsv';\nimport {\n PrivacyRequest,\n RequestEnricher,\n RequestIdentifier,\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllRequestEnrichers,\n fetchAllRequestIdentifiers,\n fetchAllRequests,\n} from '../graphql';\nimport { logger } from '../../logger';\n\nexport interface PrivacyRequestWithIdentifiers extends PrivacyRequest {\n /** Request Enrichers */\n requestEnrichers: RequestEnricher[];\n /** Request Identifiers */\n requestIdentifiers: RequestIdentifier[];\n}\n\n/**\n * Pull the set of manual enrichment jobs to CSV\n *\n * @param options - Options\n * @returns List of requests with identifiers\n */\nexport async function pullManualEnrichmentIdentifiersToCsv({\n file,\n auth,\n sombraAuth,\n requestActions = [],\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** Sombra API key */\n sombraAuth?: string;\n /** Concurrency */\n concurrency?: number;\n /** The request actions to fetch */\n requestActions?: RequestAction[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<PrivacyRequestWithIdentifiers[]> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n const sombra = await createSombraGotInstance(transcendUrl, auth, sombraAuth);\n\n logger.info(\n colors.magenta(\n `Pulling manual enrichment requests, filtered for actions: ${requestActions.join(\n ',',\n )}`,\n ),\n );\n\n // Pull all privacy requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses: [RequestStatus.Enriching],\n });\n\n // Requests to save\n const savedRequests: PrivacyRequestWithIdentifiers[] = [];\n\n // Filter down requests to what is needed\n await map(\n allRequests,\n async (request) => {\n // Fetch enrichers\n const requestEnrichers = await fetchAllRequestEnrichers(client, {\n requestId: request.id,\n });\n\n // Check if manual enrichment exists for that request\n const hasManualEnrichment = requestEnrichers.filter(\n ({ status }) => status === 'ACTION_REQUIRED',\n );\n\n // Save request to queue\n if (hasManualEnrichment) {\n const requestIdentifiers = await fetchAllRequestIdentifiers(\n client,\n sombra,\n {\n requestId: request.id,\n },\n );\n savedRequests.push({\n ...request,\n requestIdentifiers,\n requestEnrichers,\n });\n }\n },\n {\n concurrency,\n },\n );\n\n const data = savedRequests.map(\n ({\n attributeValues,\n requestIdentifiers,\n requestEnrichers, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...request\n }) => ({\n ...request,\n // flatten identifiers\n ...Object.entries(groupBy(requestIdentifiers, 'name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ value }) => value).join(','),\n }),\n {},\n ),\n // flatten attributes\n ...Object.entries(groupBy(attributeValues, 'attributeKey.name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ name }) => name).join(','),\n }),\n {},\n ),\n }),\n );\n\n // Write out to CSV\n const headers = uniq(data.map((d) => Object.keys(d)).flat());\n await writeCsv(file, data, headers);\n\n logger.info(\n colors.green(\n `Successfully wrote ${savedRequests.length} requests to file \"${file}\"`,\n ),\n );\n\n return savedRequests;\n}\n","import type { Got } from 'got';\nimport * as t from 'io-ts';\nimport { logger } from '../../logger';\nimport { uniq } from 'lodash-es';\nimport colors from 'colors';\nimport { splitCsvToList } from '../requests/splitCsvToList';\n\nconst ADMIN_URL =\n 'https://app.transcend.io/privacy-requests/incoming-requests/';\n/**\n * Minimal set required to mark as completed\n */\nexport const EnrichPrivacyRequest = t.record(t.string, t.string);\n\n/** Type override */\nexport type EnrichPrivacyRequest = t.TypeOf<typeof EnrichPrivacyRequest>;\n\n/**\n * Upload identifiers to a privacy request or mark request as\n *\n * @param sombra - Sombra instance configured to make requests\n * @param request - Request to enricher\n * @param enricherId - The ID of the enricher being uploaded to\n * @param index - Index of request ID\n * @returns True if enriched successfully, false if skipped, throws error if failed\n */\nexport async function enrichPrivacyRequest(\n sombra: Got,\n { id: rawId, ...rest }: EnrichPrivacyRequest,\n enricherId: string,\n index?: number,\n): Promise<boolean> {\n if (!rawId) {\n // error\n const msg = `Request ID must be provided to enricher request.${\n index ? ` Found error in row: ${index}` : ''\n }`;\n logger.error(colors.red(msg));\n throw new Error(msg);\n }\n\n const id = rawId.toLowerCase();\n\n // Pull out the identifiers\n const enrichedIdentifiers = Object.entries(rest).reduce(\n (acc, [key, value]) => {\n const values = uniq(splitCsvToList(value));\n return values.length === 0\n ? acc\n : Object.assign(acc, {\n [key]: uniq(splitCsvToList(value)).map((val) => ({\n value: key === 'email' ? val.toLowerCase() : val,\n })),\n });\n },\n {} as Record<string, string[]>,\n );\n\n // Make the GraphQL request\n try {\n await sombra\n .post('v1/enrich-identifiers', {\n headers: {\n 'x-transcend-request-id': id,\n 'x-transcend-enricher-id': enricherId,\n },\n json: {\n enrichedIdentifiers,\n },\n })\n .json();\n\n logger.error(\n colors.green(`Successfully enriched request: ${ADMIN_URL}${id}`),\n );\n return true;\n } catch (err) {\n // skip if already enriched\n if (\n typeof err.response.body === 'string' &&\n err.response.body.includes('Cannot update a resolved RequestEnricher')\n ) {\n logger.warn(\n colors.magenta(\n `Skipped enrichment for request: ${ADMIN_URL}${id}, request is no longer in the enriching phase.`,\n ),\n );\n return false;\n }\n\n // error\n logger.error(\n colors.red(\n `Failed to enricher identifiers for request with id: ${ADMIN_URL}${id} - ${err.message} - ${err.response.body}`,\n ),\n );\n throw err;\n }\n}\n","import colors from 'colors';\nimport { map } from '../bluebird';\nimport { logger } from '../../logger';\nimport {\n UPDATE_PRIVACY_REQUEST,\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n makeGraphQLRequest,\n} from '../graphql';\nimport {\n enrichPrivacyRequest,\n EnrichPrivacyRequest,\n} from './enrichPrivacyRequest';\nimport { readCsv } from '../requests';\nimport { DEFAULT_TRANSCEND_API } from '../../constants';\n\n/**\n * Push a CSV of enriched requests back into Transcend\n *\n * @param options - Options\n * @returns Number of items processed\n */\nexport async function pushManualEnrichmentIdentifiersFromCsv({\n file,\n auth,\n sombraAuth,\n enricherId,\n markSilent,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** ID of enricher being uploaded to */\n enricherId: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Mark requests in silent mode before enriching */\n markSilent?: boolean;\n}): Promise<number> {\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, sombraAuth);\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Read from CSV\n logger.info(colors.magenta(`Reading \"${file}\" from disk`));\n const activeResults = readCsv(file, EnrichPrivacyRequest);\n\n // Notify Transcend\n logger.info(\n colors.magenta(`Enriching \"${activeResults.length}\" privacy requests.`),\n );\n\n let successCount = 0;\n let skippedCount = 0;\n let errorCount = 0;\n\n await map(\n activeResults,\n async (request, index) => {\n try {\n // Mark requests in silent mode before a certain date\n if (markSilent) {\n await makeGraphQLRequest(client, UPDATE_PRIVACY_REQUEST, {\n input: {\n id: request.id,\n isSilent: true,\n },\n });\n\n logger.info(\n colors.magenta(`Mark request as silent mode - ${request.id}`),\n );\n }\n\n const result = await enrichPrivacyRequest(\n sombra,\n request,\n enricherId,\n index,\n );\n if (result) {\n successCount += 1;\n } else {\n skippedCount += 1;\n }\n } catch (err) {\n errorCount += 1;\n }\n },\n { concurrency },\n );\n\n logger.info(\n colors.green(\n `Successfully notified Transcend! \\n Success count: ${successCount}.`,\n ),\n );\n\n if (skippedCount > 0) {\n logger.info(colors.magenta(`Skipped count: ${skippedCount}.`));\n }\n\n if (errorCount > 0) {\n logger.info(colors.red(`Error Count: ${errorCount}.`));\n throw new Error(`Failed to enrich: ${errorCount} requests.`);\n }\n\n return activeResults.length;\n}\n"],"mappings":"oRA+BA,eAAsB,EAAqC,CACzD,OACA,OACA,aACA,iBAAiB,EAAE,CACnB,cAAc,IACd,eAAeA,EAAAA,GAc4B,CAE3C,IAAM,EAASC,EAAAA,GAA4B,EAAc,EAAK,CACxD,EAAS,MAAMC,EAAAA,GAAwB,EAAc,EAAM,EAAW,CAE5E,EAAA,EAAO,KACL,EAAA,QAAO,QACL,6DAA6D,EAAe,KAC1E,IACD,GACF,CACF,CAGD,IAAM,EAAc,MAAMC,EAAAA,GAAiB,EAAQ,CACjD,QAAS,EACT,SAAU,CAACC,EAAAA,cAAc,UAAU,CACpC,CAAC,CAGI,EAAiD,EAAE,CAGzD,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CAGzD,EAAA,EAAO,KACL,EAAA,QAAO,QAAQ,cAAc,EAAc,OAAO,qBAAqB,CACxE,CAED,IAAI,EAAe,EACf,EAAe,EACf,EAAa,EAgDjB,GA9CA,MAAMC,EAAAA,GACJ,EACA,MAAO,EAAS,IAAU,CACxB,GAAI,CAEE,IACF,MAAMC,EAAAA,EAAmB,EAAQC,EAAAA,GAAwB,CACvD,MAAO,CACL,GAAI,EAAQ,GACZ,SAAU,GACX,CACF,CAAC,CAEF,EAAA,EAAO,KACL,EAAA,QAAO,QAAQ,iCAAiC,EAAQ,KAAK,CAC9D,EAGY,MAAM,EACnB,EACA,EACA,EACA,EACD,CAEC,GAAgB,EAEhB,GAAgB,OAEN,CACZ,GAAc,IAGlB,CAAE,cAAa,CAChB,CAED,EAAA,EAAO,KACL,EAAA,QAAO,MACL,sDAAsD,EAAa,GACpE,CACF,CAEG,EAAe,GACjB,EAAA,EAAO,KAAK,EAAA,QAAO,QAAQ,kBAAkB,EAAa,GAAG,CAAC,CAG5D,EAAa,EAEf,MADA,EAAA,EAAO,KAAK,EAAA,QAAO,IAAI,gBAAgB,EAAW,GAAG,CAAC,CAC5C,MAAM,qBAAqB,EAAW,YAAY,CAG9D,OAAO,EAAc"}
1
+ {"version":3,"file":"manual-enrichment-CzTpv-mM.cjs","names":["DEFAULT_TRANSCEND_API","buildTranscendGraphQLClient","createSombraGotInstance","fetchAllRequests","RequestStatus","map","fetchAllRequestEnrichers","fetchAllRequestIdentifiers","groupBy","writeCsv","uniq","t","uniq","splitCsvToList","DEFAULT_TRANSCEND_API","createSombraGotInstance","buildTranscendGraphQLClient","readCsv","map","makeGraphQLRequest","UPDATE_PRIVACY_REQUEST"],"sources":["../src/lib/manual-enrichment/pullManualEnrichmentIdentifiersToCsv.ts","../src/lib/manual-enrichment/enrichPrivacyRequest.ts","../src/lib/manual-enrichment/pushManualEnrichmentIdentifiersFromCsv.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport { map } from '../bluebird';\nimport colors from 'colors';\nimport { groupBy, uniq } from 'lodash-es';\nimport { DEFAULT_TRANSCEND_API } from '../../constants';\nimport { writeCsv } from '../helpers/writeCsv';\nimport {\n PrivacyRequest,\n RequestEnricher,\n RequestIdentifier,\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllRequestEnrichers,\n fetchAllRequestIdentifiers,\n fetchAllRequests,\n} from '../graphql';\nimport { logger } from '../../logger';\n\nexport interface PrivacyRequestWithIdentifiers extends PrivacyRequest {\n /** Request Enrichers */\n requestEnrichers: RequestEnricher[];\n /** Request Identifiers */\n requestIdentifiers: RequestIdentifier[];\n}\n\n/**\n * Pull the set of manual enrichment jobs to CSV\n *\n * @param options - Options\n * @returns List of requests with identifiers\n */\nexport async function pullManualEnrichmentIdentifiersToCsv({\n file,\n auth,\n sombraAuth,\n requestActions = [],\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** Sombra API key */\n sombraAuth?: string;\n /** Concurrency */\n concurrency?: number;\n /** The request actions to fetch */\n requestActions?: RequestAction[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<PrivacyRequestWithIdentifiers[]> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n const sombra = await createSombraGotInstance(transcendUrl, auth, sombraAuth);\n\n logger.info(\n colors.magenta(\n `Pulling manual enrichment requests, filtered for actions: ${requestActions.join(\n ',',\n )}`,\n ),\n );\n\n // Pull all privacy requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses: [RequestStatus.Enriching],\n });\n\n // Requests to save\n const savedRequests: PrivacyRequestWithIdentifiers[] = [];\n\n // Filter down requests to what is needed\n await map(\n allRequests,\n async (request) => {\n // Fetch enrichers\n const requestEnrichers = await fetchAllRequestEnrichers(client, {\n requestId: request.id,\n });\n\n // Check if manual enrichment exists for that request\n const hasManualEnrichment = requestEnrichers.filter(\n ({ status }) => status === 'ACTION_REQUIRED',\n );\n\n // Save request to queue\n if (hasManualEnrichment) {\n const requestIdentifiers = await fetchAllRequestIdentifiers(\n client,\n sombra,\n {\n requestId: request.id,\n },\n );\n savedRequests.push({\n ...request,\n requestIdentifiers,\n requestEnrichers,\n });\n }\n },\n {\n concurrency,\n },\n );\n\n const data = savedRequests.map(\n ({\n attributeValues,\n requestIdentifiers,\n requestEnrichers, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...request\n }) => ({\n ...request,\n // flatten identifiers\n ...Object.entries(groupBy(requestIdentifiers, 'name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ value }) => value).join(','),\n }),\n {},\n ),\n // flatten attributes\n ...Object.entries(groupBy(attributeValues, 'attributeKey.name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ name }) => name).join(','),\n }),\n {},\n ),\n }),\n );\n\n // Write out to CSV\n const headers = uniq(data.map((d) => Object.keys(d)).flat());\n await writeCsv(file, data, headers);\n\n logger.info(\n colors.green(\n `Successfully wrote ${savedRequests.length} requests to file \"${file}\"`,\n ),\n );\n\n return savedRequests;\n}\n","import type { Got } from 'got';\nimport * as t from 'io-ts';\nimport { logger } from '../../logger';\nimport { uniq } from 'lodash-es';\nimport colors from 'colors';\nimport { splitCsvToList } from '../requests/splitCsvToList';\n\nconst ADMIN_URL =\n 'https://app.transcend.io/privacy-requests/incoming-requests/';\n/**\n * Minimal set required to mark as completed\n */\nexport const EnrichPrivacyRequest = t.record(t.string, t.string);\n\n/** Type override */\nexport type EnrichPrivacyRequest = t.TypeOf<typeof EnrichPrivacyRequest>;\n\n/**\n * Upload identifiers to a privacy request or mark request as\n *\n * @param sombra - Sombra instance configured to make requests\n * @param request - Request to enricher\n * @param enricherId - The ID of the enricher being uploaded to\n * @param index - Index of request ID\n * @returns True if enriched successfully, false if skipped, throws error if failed\n */\nexport async function enrichPrivacyRequest(\n sombra: Got,\n { id: rawId, ...rest }: EnrichPrivacyRequest,\n enricherId: string,\n index?: number,\n): Promise<boolean> {\n if (!rawId) {\n // error\n const msg = `Request ID must be provided to enricher request.${\n index ? ` Found error in row: ${index}` : ''\n }`;\n logger.error(colors.red(msg));\n throw new Error(msg);\n }\n\n const id = rawId.toLowerCase();\n\n // Pull out the identifiers\n const enrichedIdentifiers = Object.entries(rest).reduce(\n (acc, [key, value]) => {\n const values = uniq(splitCsvToList(value));\n return values.length === 0\n ? acc\n : Object.assign(acc, {\n [key]: uniq(splitCsvToList(value)).map((val) => ({\n value: key === 'email' ? val.toLowerCase() : val,\n })),\n });\n },\n {} as Record<string, string[]>,\n );\n\n // Make the GraphQL request\n try {\n await sombra\n .post('v1/enrich-identifiers', {\n headers: {\n 'x-transcend-request-id': id,\n 'x-transcend-enricher-id': enricherId,\n },\n json: {\n enrichedIdentifiers,\n },\n })\n .json();\n\n logger.error(\n colors.green(`Successfully enriched request: ${ADMIN_URL}${id}`),\n );\n return true;\n } catch (err) {\n // skip if already enriched\n if (\n typeof err.response.body === 'string' &&\n err.response.body.includes('Cannot update a resolved RequestEnricher')\n ) {\n logger.warn(\n colors.magenta(\n `Skipped enrichment for request: ${ADMIN_URL}${id}, request is no longer in the enriching phase.`,\n ),\n );\n return false;\n }\n\n // error\n logger.error(\n colors.red(\n `Failed to enricher identifiers for request with id: ${ADMIN_URL}${id} - ${err.message} - ${err.response.body}`,\n ),\n );\n throw err;\n }\n}\n","import colors from 'colors';\nimport { map } from '../bluebird';\nimport { logger } from '../../logger';\nimport {\n UPDATE_PRIVACY_REQUEST,\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n makeGraphQLRequest,\n} from '../graphql';\nimport {\n enrichPrivacyRequest,\n EnrichPrivacyRequest,\n} from './enrichPrivacyRequest';\nimport { readCsv } from '../requests';\nimport { DEFAULT_TRANSCEND_API } from '../../constants';\n\n/**\n * Push a CSV of enriched requests back into Transcend\n *\n * @param options - Options\n * @returns Number of items processed\n */\nexport async function pushManualEnrichmentIdentifiersFromCsv({\n file,\n auth,\n sombraAuth,\n enricherId,\n markSilent,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** ID of enricher being uploaded to */\n enricherId: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Mark requests in silent mode before enriching */\n markSilent?: boolean;\n}): Promise<number> {\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, sombraAuth);\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Read from CSV\n logger.info(colors.magenta(`Reading \"${file}\" from disk`));\n const activeResults = readCsv(file, EnrichPrivacyRequest);\n\n // Notify Transcend\n logger.info(\n colors.magenta(`Enriching \"${activeResults.length}\" privacy requests.`),\n );\n\n let successCount = 0;\n let skippedCount = 0;\n let errorCount = 0;\n\n await map(\n activeResults,\n async (request, index) => {\n try {\n // Mark requests in silent mode before a certain date\n if (markSilent) {\n await makeGraphQLRequest(client, UPDATE_PRIVACY_REQUEST, {\n input: {\n id: request.id,\n isSilent: true,\n },\n });\n\n logger.info(\n colors.magenta(`Mark request as silent mode - ${request.id}`),\n );\n }\n\n const result = await enrichPrivacyRequest(\n sombra,\n request,\n enricherId,\n index,\n );\n if (result) {\n successCount += 1;\n } else {\n skippedCount += 1;\n }\n } catch (err) {\n errorCount += 1;\n }\n },\n { concurrency },\n );\n\n logger.info(\n colors.green(\n `Successfully notified Transcend! \\n Success count: ${successCount}.`,\n ),\n );\n\n if (skippedCount > 0) {\n logger.info(colors.magenta(`Skipped count: ${skippedCount}.`));\n }\n\n if (errorCount > 0) {\n logger.info(colors.red(`Error Count: ${errorCount}.`));\n throw new Error(`Failed to enrich: ${errorCount} requests.`);\n }\n\n return activeResults.length;\n}\n"],"mappings":"oRA+BA,eAAsB,EAA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let r=JSON.parse(JSON.stringify(e));return n.forEach(e=>{(0,t.getEntries)(e).forEach(([e,t])=>{r[e]===void 0?r[e]=t:Array.isArray(t)?r[e]=[...r[e],...t]:r[e]=t})}),r}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
2
- //# sourceMappingURL=mergeTranscendInputs-PPpGbYgG.cjs.map
1
+ const e=require(`./chunk-Bmb41Sf3.cjs`);let t=require(`@transcend-io/type-utils`);function n(e,...n){let r=JSON.parse(JSON.stringify(e));return n.forEach(e=>{(0,t.getEntries)(e).forEach(([e,t])=>{r[e]===void 0?r[e]=t:Array.isArray(t)?r[e]=[...r[e],...t]:r[e]=t})}),r}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
2
+ //# sourceMappingURL=mergeTranscendInputs-BIBCYbug.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTranscendInputs-PPpGbYgG.cjs","names":[],"sources":["../src/lib/mergeTranscendInputs.ts"],"sourcesContent":["import { TranscendInput } from '../codecs';\nimport { getEntries } from '@transcend-io/type-utils';\n\n/**\n * Combine a set of TranscendInput yaml files into a single yaml\n *\n * @param base - Base input\n * @param inputs - The list of inputs\n * @returns Merged input\n */\nexport function mergeTranscendInputs(\n base: TranscendInput,\n ...inputs: TranscendInput[]\n): TranscendInput {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const cloned: any = JSON.parse(JSON.stringify(base));\n inputs.forEach((input) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getEntries(input).forEach(([key, value]: [any, any]) => {\n if (cloned[key] === undefined) {\n cloned[key] = value;\n } else if (Array.isArray(value)) {\n cloned[key] = [...cloned[key], ...value];\n } else {\n cloned[key] = value;\n }\n });\n });\n return cloned;\n}\n"],"mappings":"kFAUA,SAAgB,EACd,EACA,GAAG,EACa,CAEhB,IAAM,EAAc,KAAK,MAAM,KAAK,UAAU,EAAK,CAAC,CAapD,OAZA,EAAO,QAAS,GAAU,EAExB,EAAA,EAAA,YAAW,EAAM,CAAC,SAAS,CAAC,EAAK,KAAuB,CAClD,EAAO,KAAS,IAAA,GAClB,EAAO,GAAO,EACL,MAAM,QAAQ,EAAM,CAC7B,EAAO,GAAO,CAAC,GAAG,EAAO,GAAM,GAAG,EAAM,CAExC,EAAO,GAAO,GAEhB,EACF,CACK"}
1
+ {"version":3,"file":"mergeTranscendInputs-BIBCYbug.cjs","names":[],"sources":["../src/lib/mergeTranscendInputs.ts"],"sourcesContent":["import { TranscendInput } from '../codecs';\nimport { getEntries } from '@transcend-io/type-utils';\n\n/**\n * Combine a set of TranscendInput yaml files into a single yaml\n *\n * @param base - Base input\n * @param inputs - The list of inputs\n * @returns Merged input\n */\nexport function mergeTranscendInputs(\n base: TranscendInput,\n ...inputs: TranscendInput[]\n): TranscendInput {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const cloned: any = JSON.parse(JSON.stringify(base));\n inputs.forEach((input) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getEntries(input).forEach(([key, value]: [any, any]) => {\n if (cloned[key] === undefined) {\n cloned[key] = value;\n } else if (Array.isArray(value)) {\n cloned[key] = [...cloned[key], ...value];\n } else {\n cloned[key] = value;\n }\n });\n });\n return cloned;\n}\n"],"mappings":"kFAUA,SAAgB,EACd,EACA,GAAG,EACa,CAEhB,IAAM,EAAc,KAAK,MAAM,KAAK,UAAU,EAAK,CAAC,CAapD,OAZA,EAAO,QAAS,GAAU,EAExB,EAAA,EAAA,YAAW,EAAM,CAAC,SAAS,CAAC,EAAK,KAAuB,CAClD,EAAO,KAAS,IAAA,GAClB,EAAO,GAAO,EACL,MAAM,QAAQ,EAAM,CAC7B,EAAO,GAAO,CAAC,GAAG,EAAO,GAAM,GAAG,EAAM,CAExC,EAAO,GAAO,GAEhB,EACF,CACK"}
@@ -1,4 +1,4 @@
1
- const e=require(`./enums-CBXlBJii.cjs`),t=require(`./constants-JoCDv9ym.cjs`),n=require(`./syncConfigurationToTranscend-D4PLA70C.cjs`),r=require(`./logger-BaHHbWVd.cjs`);let i=require(`node:fs`),a=require(`node:os`),o=require(`node:path`),s=require(`colors`);s=e.s(s);let c=require(`node:child_process`),l=require(`node:readline`);l=e.s(l);function u(e,t){let n=Math.max(1,a.availableParallelism?.()??1);return{poolSize:typeof e==`number`&&e>0?Math.min(e,t):Math.min(n,t),cpuCount:n}}function d(e){return`'${String(e).replace(/'/g,`'\\''`)}'`}function f(e,t,n=!1){if(n)return;let i=(0,a.platform)();try{if(i===`darwin`){(0,c.spawn)(`osascript`,[`-e`,`
1
+ const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./constants-wkuhlP8d.cjs`),n=require(`./syncConfigurationToTranscend-DuTZKIG8.cjs`),r=require(`./logger-DQwEYtSS.cjs`);let i=require(`node:fs`),a=require(`node:os`),o=require(`node:path`),s=require(`colors`);s=e.t(s);let c=require(`node:child_process`),l=require(`node:readline`);l=e.t(l);function u(e,t){let n=Math.max(1,a.availableParallelism?.()??1);return{poolSize:typeof e==`number`&&e>0?Math.min(e,t):Math.min(n,t),cpuCount:n}}function d(e){return`'${String(e).replace(/'/g,`'\\''`)}'`}function f(e,t,n=!1){if(n)return;let i=(0,a.platform)();try{if(i===`darwin`){(0,c.spawn)(`osascript`,[`-e`,`
2
2
  tell application "Terminal"
3
3
  activate
4
4
  do script "printf '\\e]0;${t}\\a'; tail -n +1 -f ${e.map(d).join(` -f `)}"
@@ -20,4 +20,4 @@ Stopping workers...
20
20
  `))}process.stdin.resume()}B=k({workers:w,onAttach:U,onDetach:W,onCtrlC:H,getLogPaths:e=>N(e,w,E),replayBytes:200*1024,replayWhich:[`out`,`err`],onEnterAttachScreen:U}),e.extraKeyHandler&&(L=e.extraKeyHandler({logsBySlot:E,repaint:()=>R(),setPaused:e=>{I=e}}),process.stdin.on(`data`,L))}await new Promise(e=>{let t=setInterval(async()=>{if(A===0){if(clearInterval(t),P&&clearInterval(P),B(),L)try{process.stdin.off(`data`,L)}catch{}V();let n=Date.now();try{await l.postProcess?.({slots:T,totals:O,logDir:y,logsBySlot:E,startedAt:v,finishedAt:n,viewerMode:f,getLogPathsForSlot:e=>N(e,w,E)})}catch(e){let t=e?.stack??String(e);process.stdout.write(s.default.red(`postProcess error: ${t}\n`))}e()}},300)})}function B(e){let{logsBySlot:t,repaint:n,setPaused:r,exportMgr:i,exportStatus:a,custom:o}=e,s=e=>{process.stdout.write(`${e}\n`)},c=(e,t)=>{let r=Date.now(),i=a?.[e]??{path:t};a&&(a[e]={path:t||i.path,savedAt:r,exported:!0},n())},l=!1,u=(e,i)=>{l||(l=!0,r(!0),process.stdout.write(`\x1B[2J\x1B[H`),process.stdout.write(`Combined logs viewer (press Esc or Ctrl+] to return)
21
21
 
22
22
  `),(async()=>{try{await w(t,e,i)}catch{l=!1,r(!1),n()}})())},d=(e,n)=>{if(i)try{let r=i.exportCombinedLogs(t,e);s(`\nWrote combined ${n} logs to: ${r}`),c(e,r)}catch{s(`\nFailed to write combined ${n} logs`)}};return e=>{let t=e.toString(`utf8`);if(t===`e`){u([`err`],`error`);return}if(t===`w`){u([`warn`,`err`],`warn`);return}if(t===`i`){u([`info`],`all`);return}if(t===`l`){u([`out`,`err`,`structured`],`all`);return}if(t===`E`){d(`error`,`error`);return}if(t===`W`){d(`warn`,`warn`);return}if(t===`I`){d(`info`,`info`);return}if(t===`A`){d(`all`,`ALL`);return}let i=o?.[t];if(i){i({noteExport:c,say:s});return}(t===`\x1B`||t===``)&&(l=!1,r(!1),n())}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return B}});
23
- //# sourceMappingURL=pooling-DbIx6-i7.cjs.map
23
+ //# sourceMappingURL=pooling-DA_LwUEp.cjs.map