boondmanager-mcp-server 2.15.2 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/LICENSE +1 -1
  2. package/NOTICE +16 -2
  3. package/README.md +60 -15
  4. package/dist/config/access-policy.d.ts.map +1 -1
  5. package/dist/config/access-policy.js +6 -18
  6. package/dist/config/access-policy.js.map +1 -1
  7. package/dist/config/dictionary-overrides.d.ts.map +1 -1
  8. package/dist/config/dictionary-overrides.js +2 -12
  9. package/dist/config/dictionary-overrides.js.map +1 -1
  10. package/dist/config/env.d.ts +63 -0
  11. package/dist/config/env.d.ts.map +1 -0
  12. package/dist/config/env.js +116 -0
  13. package/dist/config/env.js.map +1 -0
  14. package/dist/config/profiles.d.ts +22 -8
  15. package/dist/config/profiles.d.ts.map +1 -1
  16. package/dist/config/profiles.js +48 -4
  17. package/dist/config/profiles.js.map +1 -1
  18. package/dist/constants.d.ts +13 -2
  19. package/dist/constants.d.ts.map +1 -1
  20. package/dist/constants.js +25 -1
  21. package/dist/constants.js.map +1 -1
  22. package/dist/icons.d.ts.map +1 -1
  23. package/dist/icons.js +6 -1
  24. package/dist/icons.js.map +1 -1
  25. package/dist/index.js +33 -15
  26. package/dist/index.js.map +1 -1
  27. package/dist/instructions.d.ts +1 -1
  28. package/dist/instructions.d.ts.map +1 -1
  29. package/dist/instructions.js +6 -6
  30. package/dist/instructions.js.map +1 -1
  31. package/dist/prompts/index.d.ts +19 -1
  32. package/dist/prompts/index.d.ts.map +1 -1
  33. package/dist/prompts/index.js +495 -25
  34. package/dist/prompts/index.js.map +1 -1
  35. package/dist/prompts/periods.d.ts +45 -0
  36. package/dist/prompts/periods.d.ts.map +1 -0
  37. package/dist/prompts/periods.js +154 -0
  38. package/dist/prompts/periods.js.map +1 -0
  39. package/dist/resources/index.d.ts +14 -0
  40. package/dist/resources/index.d.ts.map +1 -1
  41. package/dist/resources/index.js +285 -0
  42. package/dist/resources/index.js.map +1 -1
  43. package/dist/resources/templates.d.ts +1 -1
  44. package/dist/resources/templates.d.ts.map +1 -1
  45. package/dist/resources/templates.js +2 -0
  46. package/dist/resources/templates.js.map +1 -1
  47. package/dist/schema-dialect.js.map +1 -1
  48. package/dist/schemas/filter-aliases.d.ts +1 -1
  49. package/dist/schemas/filter-aliases.d.ts.map +1 -1
  50. package/dist/schemas/filter-aliases.js +101 -2
  51. package/dist/schemas/filter-aliases.js.map +1 -1
  52. package/dist/schemas/index.d.ts +987 -161
  53. package/dist/schemas/index.d.ts.map +1 -1
  54. package/dist/schemas/index.js +853 -323
  55. package/dist/schemas/index.js.map +1 -1
  56. package/dist/server.d.ts.map +1 -1
  57. package/dist/server.js +10 -3
  58. package/dist/server.js.map +1 -1
  59. package/dist/services/boond-client.d.ts +29 -213
  60. package/dist/services/boond-client.d.ts.map +1 -1
  61. package/dist/services/boond-client.js +29 -1168
  62. package/dist/services/boond-client.js.map +1 -1
  63. package/dist/services/dictionary.d.ts +27 -3
  64. package/dist/services/dictionary.d.ts.map +1 -1
  65. package/dist/services/dictionary.js +60 -23
  66. package/dist/services/dictionary.js.map +1 -1
  67. package/dist/services/document-text.d.ts +32 -0
  68. package/dist/services/document-text.d.ts.map +1 -0
  69. package/dist/services/document-text.js +120 -0
  70. package/dist/services/document-text.js.map +1 -0
  71. package/dist/services/format/detail.d.ts +16 -0
  72. package/dist/services/format/detail.d.ts.map +1 -0
  73. package/dist/services/format/detail.js +36 -0
  74. package/dist/services/format/detail.js.map +1 -0
  75. package/dist/services/format/html.d.ts +19 -0
  76. package/dist/services/format/html.d.ts.map +1 -0
  77. package/dist/services/format/html.js +87 -0
  78. package/dist/services/format/html.js.map +1 -0
  79. package/dist/services/format/list.d.ts +3 -0
  80. package/dist/services/format/list.d.ts.map +1 -0
  81. package/dist/services/format/list.js +44 -0
  82. package/dist/services/format/list.js.map +1 -0
  83. package/dist/services/format/summary.d.ts +16 -0
  84. package/dist/services/format/summary.d.ts.map +1 -0
  85. package/dist/services/format/summary.js +172 -0
  86. package/dist/services/format/summary.js.map +1 -0
  87. package/dist/services/format/tab.d.ts +9 -0
  88. package/dist/services/format/tab.d.ts.map +1 -0
  89. package/dist/services/format/tab.js +32 -0
  90. package/dist/services/format/tab.js.map +1 -0
  91. package/dist/services/http/auth.d.ts +44 -0
  92. package/dist/services/http/auth.d.ts.map +1 -0
  93. package/dist/services/http/auth.js +146 -0
  94. package/dist/services/http/auth.js.map +1 -0
  95. package/dist/services/http/download.d.ts +60 -0
  96. package/dist/services/http/download.d.ts.map +1 -0
  97. package/dist/services/http/download.js +160 -0
  98. package/dist/services/http/download.js.map +1 -0
  99. package/dist/services/http/errors.d.ts +45 -0
  100. package/dist/services/http/errors.d.ts.map +1 -0
  101. package/dist/services/http/errors.js +188 -0
  102. package/dist/services/http/errors.js.map +1 -0
  103. package/dist/services/http/rate-limit.d.ts +40 -0
  104. package/dist/services/http/rate-limit.d.ts.map +1 -0
  105. package/dist/services/http/rate-limit.js +92 -0
  106. package/dist/services/http/rate-limit.js.map +1 -0
  107. package/dist/services/http/retry.d.ts +46 -0
  108. package/dist/services/http/retry.d.ts.map +1 -0
  109. package/dist/services/http/retry.js +101 -0
  110. package/dist/services/http/retry.js.map +1 -0
  111. package/dist/services/http/transport.d.ts +73 -0
  112. package/dist/services/http/transport.d.ts.map +1 -0
  113. package/dist/services/http/transport.js +272 -0
  114. package/dist/services/http/transport.js.map +1 -0
  115. package/dist/services/logger.d.ts +53 -2
  116. package/dist/services/logger.d.ts.map +1 -1
  117. package/dist/services/logger.js +82 -21
  118. package/dist/services/logger.js.map +1 -1
  119. package/dist/services/oauth.d.ts +12 -0
  120. package/dist/services/oauth.d.ts.map +1 -1
  121. package/dist/services/oauth.js +21 -8
  122. package/dist/services/oauth.js.map +1 -1
  123. package/dist/services/rate-limiter.d.ts +9 -2
  124. package/dist/services/rate-limiter.d.ts.map +1 -1
  125. package/dist/services/rate-limiter.js +18 -6
  126. package/dist/services/rate-limiter.js.map +1 -1
  127. package/dist/services/request-context.d.ts +47 -0
  128. package/dist/services/request-context.d.ts.map +1 -0
  129. package/dist/services/request-context.js +112 -0
  130. package/dist/services/request-context.js.map +1 -0
  131. package/dist/services/search.d.ts +26 -0
  132. package/dist/services/search.d.ts.map +1 -0
  133. package/dist/services/search.js +98 -0
  134. package/dist/services/search.js.map +1 -0
  135. package/dist/services/update-checker.d.ts.map +1 -1
  136. package/dist/services/update-checker.js +15 -8
  137. package/dist/services/update-checker.js.map +1 -1
  138. package/dist/tools/absences.d.ts +9 -0
  139. package/dist/tools/absences.d.ts.map +1 -1
  140. package/dist/tools/absences.js +65 -20
  141. package/dist/tools/absences.js.map +1 -1
  142. package/dist/tools/actions.d.ts.map +1 -1
  143. package/dist/tools/actions.js +11 -27
  144. package/dist/tools/actions.js.map +1 -1
  145. package/dist/tools/advantages.d.ts +2 -0
  146. package/dist/tools/advantages.d.ts.map +1 -1
  147. package/dist/tools/advantages.js +66 -13
  148. package/dist/tools/advantages.js.map +1 -1
  149. package/dist/tools/alerts.d.ts +18 -0
  150. package/dist/tools/alerts.d.ts.map +1 -0
  151. package/dist/tools/alerts.js +82 -0
  152. package/dist/tools/alerts.js.map +1 -0
  153. package/dist/tools/application.d.ts +2 -1
  154. package/dist/tools/application.d.ts.map +1 -1
  155. package/dist/tools/application.js +9 -3
  156. package/dist/tools/application.js.map +1 -1
  157. package/dist/tools/contacts.d.ts.map +1 -1
  158. package/dist/tools/contacts.js +3 -7
  159. package/dist/tools/contacts.js.map +1 -1
  160. package/dist/tools/contracts.d.ts +22 -0
  161. package/dist/tools/contracts.d.ts.map +1 -1
  162. package/dist/tools/contracts.js +185 -52
  163. package/dist/tools/contracts.js.map +1 -1
  164. package/dist/tools/crud-factory.d.ts +33 -2
  165. package/dist/tools/crud-factory.d.ts.map +1 -1
  166. package/dist/tools/crud-factory.js +42 -15
  167. package/dist/tools/crud-factory.js.map +1 -1
  168. package/dist/tools/deliveries.d.ts +3 -0
  169. package/dist/tools/deliveries.d.ts.map +1 -1
  170. package/dist/tools/deliveries.js +50 -94
  171. package/dist/tools/deliveries.js.map +1 -1
  172. package/dist/tools/description-builders.d.ts +0 -1
  173. package/dist/tools/description-builders.d.ts.map +1 -1
  174. package/dist/tools/description-builders.js +46 -3
  175. package/dist/tools/description-builders.js.map +1 -1
  176. package/dist/tools/documents.d.ts.map +1 -1
  177. package/dist/tools/documents.js +73 -21
  178. package/dist/tools/documents.js.map +1 -1
  179. package/dist/tools/expenses.d.ts.map +1 -1
  180. package/dist/tools/expenses.js +2 -11
  181. package/dist/tools/expenses.js.map +1 -1
  182. package/dist/tools/find.d.ts +61 -0
  183. package/dist/tools/find.d.ts.map +1 -0
  184. package/dist/tools/find.js +221 -0
  185. package/dist/tools/find.js.map +1 -0
  186. package/dist/tools/flags.d.ts +5 -0
  187. package/dist/tools/flags.d.ts.map +1 -1
  188. package/dist/tools/flags.js +116 -1
  189. package/dist/tools/flags.js.map +1 -1
  190. package/dist/tools/forms.d.ts +5 -0
  191. package/dist/tools/forms.d.ts.map +1 -0
  192. package/dist/tools/forms.js +64 -0
  193. package/dist/tools/forms.js.map +1 -0
  194. package/dist/tools/groupments.d.ts +5 -0
  195. package/dist/tools/groupments.d.ts.map +1 -0
  196. package/dist/tools/groupments.js +68 -0
  197. package/dist/tools/groupments.js.map +1 -0
  198. package/dist/tools/inactivities.d.ts +5 -0
  199. package/dist/tools/inactivities.d.ts.map +1 -0
  200. package/dist/tools/inactivities.js +59 -0
  201. package/dist/tools/inactivities.js.map +1 -0
  202. package/dist/tools/index.d.ts +4 -0
  203. package/dist/tools/index.d.ts.map +1 -1
  204. package/dist/tools/index.js +4 -0
  205. package/dist/tools/index.js.map +1 -1
  206. package/dist/tools/invoices.d.ts.map +1 -1
  207. package/dist/tools/invoices.js +27 -2
  208. package/dist/tools/invoices.js.map +1 -1
  209. package/dist/tools/linked-entity-filters.d.ts +48 -0
  210. package/dist/tools/linked-entity-filters.d.ts.map +1 -0
  211. package/dist/tools/linked-entity-filters.js +64 -0
  212. package/dist/tools/linked-entity-filters.js.map +1 -0
  213. package/dist/tools/notifications.d.ts.map +1 -1
  214. package/dist/tools/notifications.js +0 -5
  215. package/dist/tools/notifications.js.map +1 -1
  216. package/dist/tools/orders.d.ts.map +1 -1
  217. package/dist/tools/orders.js +33 -4
  218. package/dist/tools/orders.js.map +1 -1
  219. package/dist/tools/parameter-disclosure.js.map +1 -1
  220. package/dist/tools/payments.d.ts +3 -0
  221. package/dist/tools/payments.d.ts.map +1 -1
  222. package/dist/tools/payments.js +43 -109
  223. package/dist/tools/payments.js.map +1 -1
  224. package/dist/tools/positionings.d.ts.map +1 -1
  225. package/dist/tools/positionings.js +9 -39
  226. package/dist/tools/positionings.js.map +1 -1
  227. package/dist/tools/projects.d.ts.map +1 -1
  228. package/dist/tools/projects.js +5 -12
  229. package/dist/tools/projects.js.map +1 -1
  230. package/dist/tools/provider-invoices.d.ts +2 -0
  231. package/dist/tools/provider-invoices.d.ts.map +1 -1
  232. package/dist/tools/provider-invoices.js +30 -111
  233. package/dist/tools/provider-invoices.js.map +1 -1
  234. package/dist/tools/purchases.d.ts +2 -0
  235. package/dist/tools/purchases.d.ts.map +1 -1
  236. package/dist/tools/purchases.js +50 -104
  237. package/dist/tools/purchases.js.map +1 -1
  238. package/dist/tools/registration-decorators.d.ts +28 -0
  239. package/dist/tools/registration-decorators.d.ts.map +1 -1
  240. package/dist/tools/registration-decorators.js +107 -0
  241. package/dist/tools/registration-decorators.js.map +1 -1
  242. package/dist/tools/resources.d.ts.map +1 -1
  243. package/dist/tools/resources.js +27 -5
  244. package/dist/tools/resources.js.map +1 -1
  245. package/dist/tools/rights.d.ts +101 -0
  246. package/dist/tools/rights.d.ts.map +1 -0
  247. package/dist/tools/rights.js +75 -0
  248. package/dist/tools/rights.js.map +1 -0
  249. package/dist/tools/tab-tools.js +3 -3
  250. package/dist/tools/tab-tools.js.map +1 -1
  251. package/dist/tools/timesheets.d.ts +29 -0
  252. package/dist/tools/timesheets.d.ts.map +1 -1
  253. package/dist/tools/timesheets.js +196 -126
  254. package/dist/tools/timesheets.js.map +1 -1
  255. package/dist/tools/todolists.d.ts +2 -0
  256. package/dist/tools/todolists.d.ts.map +1 -1
  257. package/dist/tools/todolists.js +64 -1
  258. package/dist/tools/todolists.js.map +1 -1
  259. package/dist/tools/validations.d.ts +9 -0
  260. package/dist/tools/validations.d.ts.map +1 -1
  261. package/dist/tools/validations.js +86 -9
  262. package/dist/tools/validations.js.map +1 -1
  263. package/dist/tools/workflows.js +1 -1
  264. package/dist/tools/workflows.js.map +1 -1
  265. package/dist/transports/http.d.ts +116 -0
  266. package/dist/transports/http.d.ts.map +1 -1
  267. package/dist/transports/http.js +422 -92
  268. package/dist/transports/http.js.map +1 -1
  269. package/dist/types.d.ts +3 -3
  270. package/dist/types.d.ts.map +1 -1
  271. package/manifest.json +7 -7
  272. package/package.json +14 -10
@@ -1,40 +1,24 @@
1
- import { IdSchema, fieldsField } from "../schemas/index.js";
2
- import { apiRequest, buildSearchQuery, formatListResponse, formatDetailResponse } from "../services/boond-client.js";
3
- import { buildJsonApiBody } from "./crud-factory.js";
4
- import { z } from "zod";
5
- import { DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE, MAX_SEARCH_PAGE } from "../constants.js";
6
- import { composeDescription, defaultGetDescription } from "./description-builders.js";
7
- const ProviderInvoiceSearchSchema = z
8
- .object({
9
- keywords: z.string().optional().describe("Mots-cles de recherche"),
10
- companyId: z.string().optional().describe("Filtrer par ID societe fournisseur"),
11
- resourceId: z.string().optional().describe("Filtrer par ID ressource via mot-cle COMP<id>"),
12
- page: z.number().int().min(1).max(MAX_SEARCH_PAGE).default(1).describe(`Numero de page (max: ${MAX_SEARCH_PAGE})`),
13
- pageSize: z.number().int().min(1).max(MAX_PAGE_SIZE).default(DEFAULT_PAGE_SIZE).describe("Resultats par page"),
14
- fields: fieldsField,
15
- })
16
- .strict();
17
- const ProviderInvoiceCreateSchema = z
18
- .object({
19
- reference: z.string().min(1).describe("Reference de la facture fournisseur"),
20
- resourceId: z.string().min(1).describe("ID de la ressource portee par la facture fournisseur"),
21
- companyId: z.string().optional().describe("ID de la societe fournisseur, mappe vers providerCompany"),
22
- contactId: z.string().optional().describe("ID du contact fournisseur, mappe vers providerContact"),
23
- invoiceDate: z.string().optional().describe("Date de facture (YYYY-MM-DD)"),
24
- startDate: z.string().min(1).describe("Date de debut de periode (YYYY-MM-DD)"),
25
- endDate: z.string().min(1).describe("Date de fin de periode (YYYY-MM-DD)"),
26
- amountExcludingTax: z.number().optional().describe("Montant HT"),
27
- amountIncludingTax: z.number().optional().describe("Montant TTC"),
28
- currency: z.number().optional().describe("Devise Boond"),
29
- exchangeRate: z.number().optional().describe("Taux de change"),
30
- currencyAgency: z.number().optional().describe("Devise agence"),
31
- exchangeRateAgency: z.number().optional().describe("Taux de change agence"),
32
- state: z.number().int().optional().describe("Etat de la facture fournisseur"),
33
- })
34
- .strict();
1
+ import { ProviderInvoiceCreateSchema, ProviderInvoiceSearchSchema, ProviderInvoiceUpdateSchema, } from "../schemas/index.js";
2
+ import { buildJsonApiBody, registerCreateTool, registerDeleteTool, registerGetTool, registerSearchTool, registerUpdateTool, } from "./crud-factory.js";
3
+ import { composeDescription } from "./description-builders.js";
4
+ const OPTS = {
5
+ entityName: "facture fournisseur",
6
+ entityNamePlural: "factures fournisseur",
7
+ apiPath: "/provider-invoices",
8
+ prefix: "boond_provider_invoices",
9
+ };
10
+ /** `/provider-invoices` payload: `resource` is mandatory, `providerCompany` / `providerContact` optional. */
11
+ export function buildProviderInvoiceBody(params) {
12
+ const { companyId, contactId, resourceId, ...attrs } = params;
13
+ return buildJsonApiBody("providerinvoice", attrs, undefined, {
14
+ resource: { id: String(resourceId), type: "resource" },
15
+ providerCompany: companyId ? { id: String(companyId), type: "company" } : undefined,
16
+ providerContact: contactId ? { id: String(contactId), type: "contact" } : undefined,
17
+ });
18
+ }
35
19
  export function registerProviderInvoiceTools(server) {
36
- server.registerTool("boond_provider_invoices_create", {
37
- title: "Creer une facture fournisseur",
20
+ registerCreateTool(server, OPTS, ProviderInvoiceCreateSchema, buildProviderInvoiceBody, {
21
+ title: "Créer une facture fournisseur",
38
22
  description: composeDescription({
39
23
  purpose: "Crée une facture fournisseur (facture reçue d'un prestataire).",
40
24
  when: "pour enregistrer la facture émise par un sous-traitant.",
@@ -43,89 +27,24 @@ export function registerProviderInvoiceTools(server) {
43
27
  "`resource`, `providerCompany` et `providerContact` sont attendus sous forme d'ID numériques.",
44
28
  "Écriture non idempotente.",
45
29
  ],
46
- returns: "confirmation et fiche de la facture fournisseur créée.",
30
+ returns: "confirmation et fiche de la facture fournisseur créée, avec son ID dans `structuredContent.id`.",
47
31
  }),
48
- inputSchema: ProviderInvoiceCreateSchema,
49
- annotations: {
50
- readOnlyHint: false,
51
- destructiveHint: false,
52
- idempotentHint: false,
53
- openWorldHint: false,
54
- },
55
- }, async (params) => {
56
- const { companyId, contactId, resourceId, ...attrs } = params;
57
- const body = buildJsonApiBody("providerinvoice", attrs);
58
- const relationships = {
59
- resource: { data: { id: resourceId, type: "resource" } },
60
- };
61
- if (companyId)
62
- relationships.providerCompany = { data: { id: companyId, type: "company" } };
63
- if (contactId)
64
- relationships.providerContact = { data: { id: contactId, type: "contact" } };
65
- body.data.relationships = relationships;
66
- const response = await apiRequest("/provider-invoices", "POST", body);
67
- const entity = Array.isArray(response.data) ? response.data[0] : response.data;
68
- return {
69
- content: [
70
- {
71
- type: "text",
72
- text: `Facture fournisseur creee avec succes.\nID: ${entity?.id}\n\n${formatDetailResponse(response)}`,
73
- },
74
- ],
75
- };
76
32
  });
77
- server.registerTool("boond_provider_invoices_search", {
78
- title: "Rechercher des factures fournisseur",
33
+ registerSearchTool(server, OPTS, {
34
+ schema: ProviderInvoiceSearchSchema,
79
35
  description: composeDescription({
80
36
  purpose: "Liste et recherche les factures fournisseur (factures reçues des prestataires).",
81
37
  when: "pour suivre les factures d'achat, par fournisseur, état ou période.",
82
38
  instead: "`boond_invoices_search` pour les factures de vente adressées aux clients — sens opposé, endpoint distinct.",
83
39
  returns: "page de résumés de factures fournisseur (référence, date, montants). Lecture seule.",
84
40
  }),
85
- inputSchema: ProviderInvoiceSearchSchema,
86
- annotations: {
87
- readOnlyHint: true,
88
- destructiveHint: false,
89
- idempotentHint: true,
90
- openWorldHint: true,
91
- },
92
- }, async (params) => {
93
- const { resourceId, companyId, keywords, ...rest } = params;
94
- const tokens = [];
95
- if (keywords)
96
- tokens.push(keywords);
97
- if (resourceId)
98
- tokens.push(`COMP${resourceId}`);
99
- if (companyId)
100
- tokens.push(`CSOC${companyId}`);
101
- const query = buildSearchQuery(tokens.length > 0 ? { ...rest, keywords: tokens.join(" ") } : rest);
102
- const response = await apiRequest("/provider-invoices", "GET", undefined, query);
103
- return {
104
- content: [{ type: "text", text: formatListResponse(response, "facture fournisseur", params.fields) }],
105
- };
106
- });
107
- server.registerTool("boond_provider_invoices_get", {
108
- title: "Details d'une facture fournisseur",
109
- description: defaultGetDescription({
110
- ...{
111
- entityName: "facture fournisseur",
112
- entityNamePlural: "factures fournisseur",
113
- prefix: "boond_provider_invoices",
114
- },
115
- withTab: false,
116
- }),
117
- inputSchema: IdSchema,
118
- annotations: {
119
- readOnlyHint: true,
120
- destructiveHint: false,
121
- idempotentHint: true,
122
- openWorldHint: false,
123
- },
124
- }, async (params) => {
125
- const response = await apiRequest(`/provider-invoices/${params.id}`);
126
- return {
127
- content: [{ type: "text", text: formatDetailResponse(response) }],
128
- };
129
41
  });
42
+ registerGetTool(server, OPTS, { withTab: false, title: "Détails d'une facture fournisseur" });
43
+ // Issue #252: mark a provider invoice paid (paidDate / state), fix a period or an amount.
44
+ registerUpdateTool(server, OPTS, ProviderInvoiceUpdateSchema, (params) => {
45
+ const { id, ...attrs } = params;
46
+ return buildJsonApiBody("providerinvoice", attrs, String(id));
47
+ }, { method: "PUT", title: "Modifier une facture fournisseur" });
48
+ registerDeleteTool(server, OPTS, { title: "Supprimer une facture fournisseur" });
130
49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cp.js";
2
+ /** `/purchases` payload: the three optional ids become relationships; `id` (update) lands on `data.id`. */
3
+ export declare function buildPurchaseBody(params: Record<string, unknown>): unknown;
2
4
  export declare function registerPurchaseTools(server: McpServer): void;
3
5
  //# sourceMappingURL=purchases.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"purchases.d.ts","sourceRoot":"","sources":["../../src/tools/purchases.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAuCzE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAgH7D"}
1
+ {"version":3,"file":"purchases.d.ts","sourceRoot":"","sources":["../../src/tools/purchases.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA8BzE,2GAA2G;AAC3G,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAY1E;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAmD7D"}
@@ -1,76 +1,41 @@
1
- import { IdSchema, fieldsField } from "../schemas/index.js";
2
- import { apiRequest, apiSearch, buildSearchQuery, formatListResponse, formatDetailResponse, } from "../services/boond-client.js";
3
- import { progressReporterFrom } from "../services/progress.js";
4
- import { buildJsonApiBody, registerDeleteTool } from "./crud-factory.js";
5
- import { z } from "zod";
6
- import { DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE, MAX_SEARCH_PAGE } from "../constants.js";
7
- import { composeDescription, defaultDeleteDescription, defaultGetDescription } from "./description-builders.js";
8
- const PurchaseSearchSchema = z
9
- .object({
10
- keywords: z.string().optional().describe("Mots-clés de recherche"),
11
- companyId: z.string().optional().describe("Filtrer par ID société"),
12
- projectId: z.string().optional().describe("Filtrer par ID projet"),
13
- page: z.number().int().min(1).max(MAX_SEARCH_PAGE).default(1).describe(`Numéro de page (max: ${MAX_SEARCH_PAGE})`),
14
- pageSize: z.number().int().min(1).max(MAX_PAGE_SIZE).default(DEFAULT_PAGE_SIZE).describe("Résultats par page"),
15
- fields: fieldsField,
16
- })
17
- .strict();
18
- const PurchaseCreateSchema = z
19
- .object({
20
- title: z.string().optional().describe("Titre de l'achat/sous-traitance"),
21
- companyId: z.string().optional().describe("ID de la société fournisseur"),
22
- contactId: z.string().optional().describe("ID du contact fournisseur"),
23
- projectId: z.string().optional().describe("ID du projet associé"),
24
- state: z.number().int().optional().describe("État de l'achat"),
25
- startDate: z.string().optional().describe("Date de début (YYYY-MM-DD)"),
26
- endDate: z.string().optional().describe("Date de fin (YYYY-MM-DD)"),
27
- note: z.string().optional().describe("Notes / commentaires"),
28
- })
29
- .strict();
1
+ import { PurchaseCreateSchema, PurchaseSearchSchema, PurchaseUpdateSchema } from "../schemas/index.js";
2
+ import { buildJsonApiBody, registerCreateTool, registerDeleteTool, registerGetTool, registerSearchTool, registerUpdateTool, } from "./crud-factory.js";
3
+ import { composeDescription } from "./description-builders.js";
4
+ import { registerTabTools } from "./tab-tools.js";
5
+ const OPTS = { entityName: "achat", entityNamePlural: "achats", apiPath: "/purchases", prefix: "boond_purchases" };
6
+ // `ENTITY_TABS.purchases` — `/purchases/{id}/information` verified live on
7
+ // 2026-09-26 (issue #258); `/actions` answers 404 on this entity.
8
+ const PURCHASE_TABS = [
9
+ {
10
+ name: "information",
11
+ tab: "information",
12
+ title: "Informations complètes d'un achat/sous-traitance",
13
+ subject: "les informations complètes",
14
+ content: "période, quantité, montants, taux de TVA, conditions de paiement, ressource, projet et prestation liés",
15
+ returns: "Fiche complète de l'achat (relations ressource, agence, projet, prestation incluses).",
16
+ },
17
+ ];
18
+ /** `/purchases` payload: the three optional ids become relationships; `id` (update) lands on `data.id`. */
19
+ export function buildPurchaseBody(params) {
20
+ const { id, companyId, contactId, projectId, note, ...attrs } = params;
21
+ return buildJsonApiBody("purchase", { ...attrs, ...(note !== undefined ? { informationComments: note } : {}) }, typeof id === "string" ? id : undefined, {
22
+ company: companyId ? { id: String(companyId), type: "company" } : undefined,
23
+ contact: contactId ? { id: String(contactId), type: "contact" } : undefined,
24
+ project: projectId ? { id: String(projectId), type: "project" } : undefined,
25
+ });
26
+ }
30
27
  export function registerPurchaseTools(server) {
31
- server.registerTool("boond_purchases_search", {
28
+ registerSearchTool(server, OPTS, {
29
+ schema: PurchaseSearchSchema,
32
30
  title: "Rechercher des achats/sous-traitance",
33
- description: `Recherche des achats et sous-traitances dans BoondManager.
31
+ description: `Recherche des achats et sous-traitances dans BoondManager, avec filtres par société et projet.
34
32
 
35
- Args:
36
- - keywords, companyId, projectId: Filtres
37
- - page, pageSize: Pagination
33
+ \`companyId\` / \`projectId\` sont convertis en références \`keywords\` (CSOC<id> / PRJ<id>) : l'API n'a pas de paramètre dédié.
38
34
 
39
35
  Returns: Liste des achats correspondants.`,
40
- inputSchema: PurchaseSearchSchema,
41
- annotations: {
42
- readOnlyHint: true,
43
- destructiveHint: false,
44
- idempotentHint: true,
45
- openWorldHint: true,
46
- },
47
- }, async (params, extra) => {
48
- const query = buildSearchQuery(params);
49
- const response = await apiSearch("/purchases", query, progressReporterFrom(extra));
50
- return {
51
- content: [{ type: "text", text: formatListResponse(response, "achat", params.fields) }],
52
- };
53
36
  });
54
- server.registerTool("boond_purchases_get", {
55
- title: "Détails d'un achat/sous-traitance",
56
- description: defaultGetDescription({
57
- ...{ entityName: "achat", entityNamePlural: "achats", prefix: "boond_purchases" },
58
- withTab: false,
59
- }),
60
- inputSchema: IdSchema,
61
- annotations: {
62
- readOnlyHint: true,
63
- destructiveHint: false,
64
- idempotentHint: true,
65
- openWorldHint: false,
66
- },
67
- }, async (params) => {
68
- const response = await apiRequest(`/purchases/${params.id}`);
69
- return {
70
- content: [{ type: "text", text: formatDetailResponse(response) }],
71
- };
72
- });
73
- server.registerTool("boond_purchases_create", {
37
+ registerGetTool(server, OPTS, { withTab: false, title: "Détails d'un achat/sous-traitance" });
38
+ registerCreateTool(server, OPTS, PurchaseCreateSchema, buildPurchaseBody, {
74
39
  title: "Créer un achat/sous-traitance",
75
40
  description: composeDescription({
76
41
  purpose: "Crée un achat ou une ligne de sous-traitance.",
@@ -80,47 +45,28 @@ Returns: Liste des achats correspondants.`,
80
45
  "Écriture non idempotente.",
81
46
  "Les ID de société, contact et projet sont des ID numériques BoondManager, à résoudre au préalable via les recherches correspondantes.",
82
47
  ],
83
- returns: "confirmation et fiche de l'achat créé.",
48
+ returns: "confirmation et fiche de l'achat créé, avec son ID dans `structuredContent.id`.",
84
49
  }),
85
- inputSchema: PurchaseCreateSchema,
86
- annotations: {
87
- readOnlyHint: false,
88
- destructiveHint: false,
89
- idempotentHint: false,
90
- openWorldHint: false,
91
- },
92
- }, async (params) => {
93
- const { companyId, contactId, projectId, ...attrs } = params;
94
- const body = buildJsonApiBody("purchase", attrs);
95
- const relationships = {};
96
- if (companyId)
97
- relationships.company = { data: { id: companyId, type: "company" } };
98
- if (contactId)
99
- relationships.contact = { data: { id: contactId, type: "contact" } };
100
- if (projectId)
101
- relationships.project = { data: { id: projectId, type: "project" } };
102
- if (Object.keys(relationships).length > 0) {
103
- body.data.relationships = relationships;
104
- }
105
- const response = await apiRequest("/purchases", "POST", body);
106
- const entity = Array.isArray(response.data) ? response.data[0] : response.data;
107
- return {
108
- content: [
109
- {
110
- type: "text",
111
- text: `✅ Achat créé avec succès.\nID: ${entity?.id}\n\n${formatDetailResponse(response)}`,
112
- },
113
- ],
114
- };
115
50
  });
116
- // Delete purchase — via la factory pour l'élicitation de confirmation + structuredContent
117
- registerDeleteTool(server, { entityName: "achat", entityNamePlural: "achats", apiPath: "/purchases", prefix: "boond_purchases" }, {
51
+ // PUT /purchases/{id}/information (RAML `purchases/information.raml`, issue #252).
52
+ registerUpdateTool(server, OPTS, PurchaseUpdateSchema, buildPurchaseBody, {
53
+ method: "PUT",
54
+ pathSuffix: "information",
55
+ title: "Modifier un achat/sous-traitance",
56
+ });
57
+ registerDeleteTool(server, OPTS, {
118
58
  title: "Supprimer un achat/sous-traitance",
119
- description: defaultDeleteDescription({
120
- entityName: "achat",
121
- entityNamePlural: "achats",
122
- prefix: "boond_purchases",
59
+ description: composeDescription({
60
+ purpose: "Supprime définitivement un achat / sous-traitance de BoondManager.",
61
+ when: "uniquement sur demande explicite de l'utilisateur, et après avoir vérifié l'ID avec `boond_purchases_get`.",
62
+ instead: "`boond_purchases_update` pour corriger un montant, une période ou un état — vérifier avec `boond_payments_search` (`purchaseId`) qu'aucun règlement n'y est adossé avant de détruire.",
63
+ behaviour: [
64
+ "⚠️ Irréversible, sans corbeille côté API.",
65
+ "Si le client MCP annonce la capacité `elicitation`, une confirmation est demandée à l'utilisateur final et un refus annule l'appel (`structuredContent.deleted: false` + `reason`) ; sinon la suppression part directement.",
66
+ ],
67
+ returns: "`{ id, deleted, reason? }` — vérifier `deleted`, qui vaut `false` en cas de refus utilisateur.",
123
68
  }),
124
69
  });
70
+ registerTabTools(server, OPTS, PURCHASE_TABS);
125
71
  }
126
72
  //# sourceMappingURL=purchases.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"purchases.js","sourceRoot":"","sources":["../../src/tools/purchases.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EACL,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAA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QACzB,KAAK,EAAE,kCAAkC;KAC1C,CAAC,CAAC;IAEH,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE;QAC/B,KAAK,EAAE,mCAAmC;QAC1C,WAAW,EAAE,kBAAkB,CAAC;YAC9B,OAAO,EAAE,oEAAoE;YAC7E,IAAI,EAAE,4GAA4G;YAClH,OAAO,EACL,uLAAuL;YACzL,SAAS,EAAE;gBACT,2CAA2C;gBAC3C,6NAA6N;aAC9N;YACD,OAAO,EAAE,gGAAgG;SAC1G,CAAC;KACH,CAAC,CAAC;IAEH,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;AAChD,CAAC"}
@@ -30,6 +30,34 @@ export interface RegistrationIndex {
30
30
  toolDomains: Map<string, DomainName>;
31
31
  }
32
32
  export declare function createRegistrationIndex(): RegistrationIndex;
33
+ /**
34
+ * Wrap a server so every handler registered through it — tool, prompt or
35
+ * resource — runs inside a request context (issues #231, #236) and every tool
36
+ * call leaves one log line.
37
+ *
38
+ * The handler is always the last argument of the registration call and
39
+ * `extra` the last argument of the handler (`(args, extra)` for a tool with an
40
+ * input schema, `(extra)` without, `(uri, variables, extra)` for a template).
41
+ * From `extra` the wrapper takes:
42
+ *
43
+ * - `signal` — so `send()` can abort the BoondManager call on
44
+ * `notifications/cancelled`;
45
+ * - `_meta.traceparent` (SEP-414) — forwarded to BoondManager verbatim, and
46
+ * its `trace-id` becomes the `corrId`; otherwise the id the HTTP transport
47
+ * generated for the connection is kept, and on stdio a fresh one is made.
48
+ * `_meta.baggage` is never read.
49
+ *
50
+ * `send()` reads the context back from the AsyncLocalStorage, so the ~180
51
+ * handlers and the client helpers keep their signatures. The tool log line —
52
+ * `{ corrId, tool, durationMs, ok, chars }` — is the single place ~185 tools
53
+ * are instrumented; a thrown handler is logged at `warn` and rethrown so the
54
+ * SDK still turns it into an `isError` result.
55
+ *
56
+ * Applied once, on the innermost server, in `server.ts::registerAll` — before
57
+ * the per-domain decorations and the access policy — so that nothing
58
+ * registered anywhere escapes it.
59
+ */
60
+ export declare function instrumentHandlers(server: McpServer): McpServer;
33
61
  /**
34
62
  * Wrap a server (or an already-wrapped Proxy) so every `registerTool` call made
35
63
  * by `domain`'s registrar is decorated. Methods other than `registerTool` pass
@@ -1 +1 @@
1
- {"version":3,"file":"registration-decorators.d.ts","sourceRoot":"","sources":["../../src/tools/registration-decorators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKlD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACtC;AAED,wBAAgB,uBAAuB,IAAI,iBAAiB,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAyBjH"}
1
+ {"version":3,"file":"registration-decorators.d.ts","sourceRoot":"","sources":["../../src/tools/registration-decorators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAalD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACtC;AAED,wBAAgB,uBAAuB,IAAI,iBAAiB,CAE3D;AAoBD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CA6D/D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAyBjH"}
@@ -1,9 +1,116 @@
1
1
  import { withValidationFeedback } from "./validation-wrapper.js";
2
2
  import { withParameterDisclosure } from "./parameter-disclosure.js";
3
3
  import { withUsageGuidance } from "./usage-guidance.js";
4
+ import { currentCorrId, requestSignalFrom, runWithRequestContext, traceparentFrom, } from "../services/request-context.js";
5
+ import { generateCorrelationId, logger } from "../services/logger.js";
4
6
  export function createRegistrationIndex() {
5
7
  return { toolDomains: new Map() };
6
8
  }
9
+ /** The SDK registration methods whose last argument is a request handler. */
10
+ const HANDLER_REGISTRATIONS = new Set(["registerTool", "registerPrompt", "registerResource"]);
11
+ /** Size of a tool result as the model receives it: text content plus the structured payload. */
12
+ function resultChars(result) {
13
+ if (typeof result !== "object" || result === null)
14
+ return 0;
15
+ const { content, structuredContent } = result;
16
+ let chars = 0;
17
+ if (Array.isArray(content)) {
18
+ for (const item of content) {
19
+ const text = item?.text;
20
+ if (typeof text === "string")
21
+ chars += text.length;
22
+ }
23
+ }
24
+ if (structuredContent !== undefined)
25
+ chars += JSON.stringify(structuredContent).length;
26
+ return chars;
27
+ }
28
+ /**
29
+ * Wrap a server so every handler registered through it — tool, prompt or
30
+ * resource — runs inside a request context (issues #231, #236) and every tool
31
+ * call leaves one log line.
32
+ *
33
+ * The handler is always the last argument of the registration call and
34
+ * `extra` the last argument of the handler (`(args, extra)` for a tool with an
35
+ * input schema, `(extra)` without, `(uri, variables, extra)` for a template).
36
+ * From `extra` the wrapper takes:
37
+ *
38
+ * - `signal` — so `send()` can abort the BoondManager call on
39
+ * `notifications/cancelled`;
40
+ * - `_meta.traceparent` (SEP-414) — forwarded to BoondManager verbatim, and
41
+ * its `trace-id` becomes the `corrId`; otherwise the id the HTTP transport
42
+ * generated for the connection is kept, and on stdio a fresh one is made.
43
+ * `_meta.baggage` is never read.
44
+ *
45
+ * `send()` reads the context back from the AsyncLocalStorage, so the ~180
46
+ * handlers and the client helpers keep their signatures. The tool log line —
47
+ * `{ corrId, tool, durationMs, ok, chars }` — is the single place ~185 tools
48
+ * are instrumented; a thrown handler is logged at `warn` and rethrown so the
49
+ * SDK still turns it into an `isError` result.
50
+ *
51
+ * Applied once, on the innermost server, in `server.ts::registerAll` — before
52
+ * the per-domain decorations and the access policy — so that nothing
53
+ * registered anywhere escapes it.
54
+ */
55
+ export function instrumentHandlers(server) {
56
+ return new Proxy(server, {
57
+ get(target, prop) {
58
+ const value = Reflect.get(target, prop, target);
59
+ if (typeof value !== "function")
60
+ return value;
61
+ if (typeof prop !== "string" || !HANDLER_REGISTRATIONS.has(prop)) {
62
+ return value.bind(target);
63
+ }
64
+ return (...args) => {
65
+ const handler = args[args.length - 1];
66
+ if (typeof handler !== "function") {
67
+ return value.apply(target, args);
68
+ }
69
+ const name = String(args[0]);
70
+ const isTool = prop === "registerTool";
71
+ const wrapped = (...handlerArgs) => {
72
+ const extra = handlerArgs[handlerArgs.length - 1];
73
+ const trace = traceparentFrom(extra);
74
+ const signal = requestSignalFrom(extra);
75
+ const context = {
76
+ ...(signal !== undefined ? { signal } : {}),
77
+ corrId: trace?.traceId ?? currentCorrId() ?? generateCorrelationId(),
78
+ ...(trace !== undefined ? { traceparent: trace.header } : {}),
79
+ };
80
+ return runWithRequestContext(context, () => {
81
+ const call = () => handler(...handlerArgs);
82
+ if (!isTool)
83
+ return call();
84
+ const startedAt = Date.now();
85
+ const done = (result) => {
86
+ const ok = typeof result === "object" && result !== null && !result.isError;
87
+ logger.info({
88
+ corrId: context.corrId,
89
+ tool: name,
90
+ durationMs: Date.now() - startedAt,
91
+ ok,
92
+ chars: resultChars(result),
93
+ }, "tool call");
94
+ return result;
95
+ };
96
+ const failed = (err) => {
97
+ logger.warn({ corrId: context.corrId, tool: name, durationMs: Date.now() - startedAt, err }, "tool call threw");
98
+ throw err;
99
+ };
100
+ try {
101
+ const result = call();
102
+ return result instanceof Promise ? result.then(done, failed) : done(result);
103
+ }
104
+ catch (err) {
105
+ return failed(err);
106
+ }
107
+ });
108
+ };
109
+ return value.apply(target, [...args.slice(0, -1), wrapped]);
110
+ };
111
+ },
112
+ });
113
+ }
7
114
  /**
8
115
  * Wrap a server (or an already-wrapped Proxy) so every `registerTool` call made
9
116
  * by `domain`'s registrar is decorated. Methods other than `registerTool` pass
@@ -1 +1 @@
1
- {"version":3,"file":"registration-decorators.js","sourceRoot":"","sources":["../../src/tools/registration-decorators.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAiCxD,MAAM,UAAU,uBAAuB;IACrC,OAAO,EAAE,WAAW,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,MAAkB,EAAE,KAAyB;IACpG,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;QACvB,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAY,CAAC;YAC3D,IAAI,OAAO,KAAK,KAAK,UAAU;gBAAE,OAAO,KAAK,CAAC;YAE9C,IAAI,IAAI,KAAK,cAAc,EAAE,CAAC;gBAC5B,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE;oBAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAW,CAAC;oBAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAgE,CAAC;oBACtF,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;oBACrC,gEAAgE;oBAChE,oEAAoE;oBACpE,2CAA2C;oBAC3C,M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,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAe5E,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,iBAAiB,GAAG,iBAAiB,CAQlF;AAWD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAsN7D"}
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/tools/resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA8IzE,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuEzB;AAuCD,KAAK,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAe5E,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,iBAAiB,GAAG,iBAAiB,CAQlF;AAWD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAuP7D"}