@onlyflows/servicenow-mcp 2.2.0-dev.6 → 2.2.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 (269) hide show
  1. package/.env.example +6 -3
  2. package/CHANGELOG.md +404 -0
  3. package/README.md +580 -104
  4. package/dist/atf-form.d.ts +3 -15
  5. package/dist/atf-form.d.ts.map +1 -1
  6. package/dist/atf-policy.d.ts +1 -1
  7. package/dist/atf-policy.d.ts.map +1 -1
  8. package/dist/atf-policy.js +2 -0
  9. package/dist/atf-policy.js.map +1 -1
  10. package/dist/atf-result-cache.d.ts +23 -59
  11. package/dist/atf-result-cache.d.ts.map +1 -1
  12. package/dist/auth.d.ts +1 -0
  13. package/dist/auth.d.ts.map +1 -1
  14. package/dist/auth.js +17 -0
  15. package/dist/auth.js.map +1 -1
  16. package/dist/batch-limits.d.ts +18 -0
  17. package/dist/batch-limits.d.ts.map +1 -0
  18. package/dist/batch-limits.js +21 -0
  19. package/dist/batch-limits.js.map +1 -0
  20. package/dist/bounded-input.d.ts +49 -0
  21. package/dist/bounded-input.d.ts.map +1 -0
  22. package/dist/bounded-input.js +81 -0
  23. package/dist/bounded-input.js.map +1 -0
  24. package/dist/client.d.ts +25 -0
  25. package/dist/client.d.ts.map +1 -1
  26. package/dist/client.js +92 -18
  27. package/dist/client.js.map +1 -1
  28. package/dist/credential-tables.d.ts +32 -0
  29. package/dist/credential-tables.d.ts.map +1 -0
  30. package/dist/credential-tables.js +58 -0
  31. package/dist/credential-tables.js.map +1 -0
  32. package/dist/encoded-query-policy.d.ts +11 -0
  33. package/dist/encoded-query-policy.d.ts.map +1 -1
  34. package/dist/encoded-query-policy.js +18 -2
  35. package/dist/encoded-query-policy.js.map +1 -1
  36. package/dist/execution-context.d.ts +14 -0
  37. package/dist/execution-context.d.ts.map +1 -1
  38. package/dist/execution-context.js +8 -0
  39. package/dist/execution-context.js.map +1 -1
  40. package/dist/field-policy.d.ts +115 -3
  41. package/dist/field-policy.d.ts.map +1 -1
  42. package/dist/field-policy.js +909 -97
  43. package/dist/field-policy.js.map +1 -1
  44. package/dist/hidden-values.d.ts +225 -0
  45. package/dist/hidden-values.d.ts.map +1 -0
  46. package/dist/hidden-values.js +748 -0
  47. package/dist/hidden-values.js.map +1 -0
  48. package/dist/html-response.d.ts +34 -0
  49. package/dist/html-response.d.ts.map +1 -0
  50. package/dist/html-response.js +72 -0
  51. package/dist/html-response.js.map +1 -0
  52. package/dist/http-entrypoint.d.ts.map +1 -1
  53. package/dist/http-entrypoint.js +7 -0
  54. package/dist/http-entrypoint.js.map +1 -1
  55. package/dist/http-runtime.d.ts.map +1 -1
  56. package/dist/http-runtime.js +8 -0
  57. package/dist/http-runtime.js.map +1 -1
  58. package/dist/incident-journal-policy.d.ts +27 -5
  59. package/dist/incident-journal-policy.d.ts.map +1 -1
  60. package/dist/incident-journal-policy.js +34 -21
  61. package/dist/incident-journal-policy.js.map +1 -1
  62. package/dist/index.js +7 -0
  63. package/dist/index.js.map +1 -1
  64. package/dist/json-shape-limits.d.ts +71 -0
  65. package/dist/json-shape-limits.d.ts.map +1 -0
  66. package/dist/json-shape-limits.js +131 -0
  67. package/dist/json-shape-limits.js.map +1 -0
  68. package/dist/metadata-cache.d.ts +84 -21
  69. package/dist/metadata-cache.d.ts.map +1 -1
  70. package/dist/metadata-cache.js +316 -196
  71. package/dist/metadata-cache.js.map +1 -1
  72. package/dist/policy-card.d.ts +146 -0
  73. package/dist/policy-card.d.ts.map +1 -0
  74. package/dist/policy-card.js +420 -0
  75. package/dist/policy-card.js.map +1 -0
  76. package/dist/profile-manager.d.ts +19 -3
  77. package/dist/profile-manager.d.ts.map +1 -1
  78. package/dist/profile-manager.js +89 -4
  79. package/dist/profile-manager.js.map +1 -1
  80. package/dist/record-identifier-policy.d.ts +2 -8
  81. package/dist/record-identifier-policy.d.ts.map +1 -1
  82. package/dist/risky-grants.d.ts +25 -0
  83. package/dist/risky-grants.d.ts.map +1 -0
  84. package/dist/risky-grants.js +77 -0
  85. package/dist/risky-grants.js.map +1 -0
  86. package/dist/server.d.ts.map +1 -1
  87. package/dist/server.js +26 -5
  88. package/dist/server.js.map +1 -1
  89. package/dist/setup-prompts.js +1 -0
  90. package/dist/setup-prompts.js.map +1 -1
  91. package/dist/setup.d.ts +1 -1
  92. package/dist/setup.d.ts.map +1 -1
  93. package/dist/setup.js +305 -59
  94. package/dist/setup.js.map +1 -1
  95. package/dist/stdio-runtime.d.ts +15 -0
  96. package/dist/stdio-runtime.d.ts.map +1 -1
  97. package/dist/stdio-runtime.js +60 -0
  98. package/dist/stdio-runtime.js.map +1 -1
  99. package/dist/structured-query.d.ts +100 -115
  100. package/dist/structured-query.d.ts.map +1 -1
  101. package/dist/structured-query.js +138 -17
  102. package/dist/structured-query.js.map +1 -1
  103. package/dist/table-policy.d.ts +41 -4
  104. package/dist/table-policy.d.ts.map +1 -1
  105. package/dist/table-policy.js +82 -10
  106. package/dist/table-policy.js.map +1 -1
  107. package/dist/tool-error.d.ts +34 -0
  108. package/dist/tool-error.d.ts.map +1 -1
  109. package/dist/tool-error.js +109 -1
  110. package/dist/tool-error.js.map +1 -1
  111. package/dist/tool-table-access.d.ts.map +1 -1
  112. package/dist/tool-table-access.js +35 -5
  113. package/dist/tool-table-access.js.map +1 -1
  114. package/dist/tools/aggregate.d.ts +13 -19
  115. package/dist/tools/aggregate.d.ts.map +1 -1
  116. package/dist/tools/aggregate.js +4 -5
  117. package/dist/tools/aggregate.js.map +1 -1
  118. package/dist/tools/all-fields-cap.d.ts.map +1 -1
  119. package/dist/tools/all-fields-cap.js +32 -45
  120. package/dist/tools/all-fields-cap.js.map +1 -1
  121. package/dist/tools/atf-author-module.d.ts +29 -14
  122. package/dist/tools/atf-author-module.d.ts.map +1 -1
  123. package/dist/tools/atf-author-module.js +11 -5
  124. package/dist/tools/atf-author-module.js.map +1 -1
  125. package/dist/tools/atf-contracts.d.ts +135 -829
  126. package/dist/tools/atf-contracts.d.ts.map +1 -1
  127. package/dist/tools/atf-shared.js +2 -2
  128. package/dist/tools/atf-shared.js.map +1 -1
  129. package/dist/tools/atf-step-catalog.d.ts +16 -15
  130. package/dist/tools/atf-step-catalog.d.ts.map +1 -1
  131. package/dist/tools/atf-step-catalog.js +181 -10
  132. package/dist/tools/atf-step-catalog.js.map +1 -1
  133. package/dist/tools/atf.d.ts +8 -24
  134. package/dist/tools/atf.d.ts.map +1 -1
  135. package/dist/tools/atf.js +2 -2
  136. package/dist/tools/atf.js.map +1 -1
  137. package/dist/tools/attach.d.ts +6 -22
  138. package/dist/tools/attach.d.ts.map +1 -1
  139. package/dist/tools/batch.d.ts +18 -71
  140. package/dist/tools/batch.d.ts.map +1 -1
  141. package/dist/tools/batch.js +566 -100
  142. package/dist/tools/batch.js.map +1 -1
  143. package/dist/tools/catalog.d.ts +2 -2
  144. package/dist/tools/catalog.d.ts.map +1 -1
  145. package/dist/tools/catalog.js +7 -1
  146. package/dist/tools/catalog.js.map +1 -1
  147. package/dist/tools/codesearch.d.ts +1 -13
  148. package/dist/tools/codesearch.d.ts.map +1 -1
  149. package/dist/tools/create-module.d.ts +9 -14
  150. package/dist/tools/create-module.d.ts.map +1 -1
  151. package/dist/tools/create-module.js +4 -8
  152. package/dist/tools/create-module.js.map +1 -1
  153. package/dist/tools/delete.d.ts +1 -9
  154. package/dist/tools/delete.d.ts.map +1 -1
  155. package/dist/tools/delete.js +2 -3
  156. package/dist/tools/delete.js.map +1 -1
  157. package/dist/tools/discover.d.ts +6 -14
  158. package/dist/tools/discover.d.ts.map +1 -1
  159. package/dist/tools/flow-view-contracts.d.ts +1023 -0
  160. package/dist/tools/flow-view-contracts.d.ts.map +1 -0
  161. package/dist/tools/flow-view-contracts.js +570 -0
  162. package/dist/tools/flow-view-contracts.js.map +1 -0
  163. package/dist/tools/flow-view-graph.d.ts +86 -0
  164. package/dist/tools/flow-view-graph.d.ts.map +1 -0
  165. package/dist/tools/flow-view-graph.js +993 -0
  166. package/dist/tools/flow-view-graph.js.map +1 -0
  167. package/dist/tools/flow-view-gzip.d.ts +52 -0
  168. package/dist/tools/flow-view-gzip.d.ts.map +1 -0
  169. package/dist/tools/flow-view-gzip.js +179 -0
  170. package/dist/tools/flow-view-gzip.js.map +1 -0
  171. package/dist/tools/flow-view-mermaid.d.ts +37 -0
  172. package/dist/tools/flow-view-mermaid.d.ts.map +1 -0
  173. package/dist/tools/flow-view-mermaid.js +337 -0
  174. package/dist/tools/flow-view-mermaid.js.map +1 -0
  175. package/dist/tools/flow-view-module.d.ts +61 -0
  176. package/dist/tools/flow-view-module.d.ts.map +1 -0
  177. package/dist/tools/flow-view-module.js +378 -0
  178. package/dist/tools/flow-view-module.js.map +1 -0
  179. package/dist/tools/flow-view-policy.d.ts +106 -0
  180. package/dist/tools/flow-view-policy.d.ts.map +1 -0
  181. package/dist/tools/flow-view-policy.js +462 -0
  182. package/dist/tools/flow-view-policy.js.map +1 -0
  183. package/dist/tools/flow-view-renderers.d.ts +68 -0
  184. package/dist/tools/flow-view-renderers.d.ts.map +1 -0
  185. package/dist/tools/flow-view-renderers.js +513 -0
  186. package/dist/tools/flow-view-renderers.js.map +1 -0
  187. package/dist/tools/flow-view-table.d.ts +115 -0
  188. package/dist/tools/flow-view-table.d.ts.map +1 -0
  189. package/dist/tools/flow-view-table.js +1002 -0
  190. package/dist/tools/flow-view-table.js.map +1 -0
  191. package/dist/tools/get-module.d.ts +36 -42
  192. package/dist/tools/get-module.d.ts.map +1 -1
  193. package/dist/tools/health.d.ts +9 -6
  194. package/dist/tools/health.d.ts.map +1 -1
  195. package/dist/tools/incident-journal-module.d.ts +8 -7
  196. package/dist/tools/incident-journal-module.d.ts.map +1 -1
  197. package/dist/tools/index.d.ts +4 -4
  198. package/dist/tools/index.d.ts.map +1 -1
  199. package/dist/tools/index.js +118 -18
  200. package/dist/tools/index.js.map +1 -1
  201. package/dist/tools/markdown.d.ts +27 -0
  202. package/dist/tools/markdown.d.ts.map +1 -1
  203. package/dist/tools/markdown.js +104 -1
  204. package/dist/tools/markdown.js.map +1 -1
  205. package/dist/tools/nl.d.ts +1 -11
  206. package/dist/tools/nl.d.ts.map +1 -1
  207. package/dist/tools/profile.d.ts +1 -1
  208. package/dist/tools/profile.d.ts.map +1 -1
  209. package/dist/tools/profile.js +20 -1
  210. package/dist/tools/profile.js.map +1 -1
  211. package/dist/tools/query-module.d.ts +59 -71
  212. package/dist/tools/query-module.d.ts.map +1 -1
  213. package/dist/tools/query-module.js +28 -7
  214. package/dist/tools/query-module.js.map +1 -1
  215. package/dist/tools/record-write-shared.d.ts.map +1 -1
  216. package/dist/tools/record-write-shared.js +20 -2
  217. package/dist/tools/record-write-shared.js.map +1 -1
  218. package/dist/tools/relationships.d.ts +6 -22
  219. package/dist/tools/relationships.d.ts.map +1 -1
  220. package/dist/tools/result-envelope.d.ts +2255 -1357
  221. package/dist/tools/result-envelope.d.ts.map +1 -1
  222. package/dist/tools/result-envelope.js +24 -2
  223. package/dist/tools/result-envelope.js.map +1 -1
  224. package/dist/tools/schema-module.d.ts +36 -21
  225. package/dist/tools/schema-module.d.ts.map +1 -1
  226. package/dist/tools/schema-module.js +106 -65
  227. package/dist/tools/schema-module.js.map +1 -1
  228. package/dist/tools/script.d.ts +1 -11
  229. package/dist/tools/script.d.ts.map +1 -1
  230. package/dist/tools/syslog.d.ts +11 -18
  231. package/dist/tools/syslog.d.ts.map +1 -1
  232. package/dist/tools/syslog.js +2 -3
  233. package/dist/tools/syslog.js.map +1 -1
  234. package/dist/tools/table-hierarchy.d.ts +35 -0
  235. package/dist/tools/table-hierarchy.d.ts.map +1 -0
  236. package/dist/tools/table-hierarchy.js +74 -0
  237. package/dist/tools/table-hierarchy.js.map +1 -0
  238. package/dist/tools/tool-module.d.ts +40 -15
  239. package/dist/tools/tool-module.d.ts.map +1 -1
  240. package/dist/tools/tool-module.js +755 -205
  241. package/dist/tools/tool-module.js.map +1 -1
  242. package/dist/tools/update-module.d.ts +11 -17
  243. package/dist/tools/update-module.d.ts.map +1 -1
  244. package/dist/tools/update-module.js +10 -12
  245. package/dist/tools/update-module.js.map +1 -1
  246. package/dist/unknown-filter-fields.d.ts +52 -0
  247. package/dist/unknown-filter-fields.d.ts.map +1 -0
  248. package/dist/unknown-filter-fields.js +87 -0
  249. package/dist/unknown-filter-fields.js.map +1 -0
  250. package/dist/version.d.ts +1 -1
  251. package/dist/version.d.ts.map +1 -1
  252. package/dist/version.js +1 -1
  253. package/dist/version.js.map +1 -1
  254. package/dist/write-value-policy.d.ts +20 -12
  255. package/dist/write-value-policy.d.ts.map +1 -1
  256. package/dist/write-value-policy.js +179 -67
  257. package/dist/write-value-policy.js.map +1 -1
  258. package/docs/ADDING-TOOLS.md +22 -13
  259. package/docs/CLIENT-SETUP.md +110 -52
  260. package/docs/CROSS-CLIENT-RELEASE-MATRIX.md +2 -2
  261. package/docs/FLOW-VIEW.md +214 -0
  262. package/docs/PRODUCTION-SECURITY.md +218 -25
  263. package/docs/RELEASE-VALIDATION.md +2 -2
  264. package/docs/TESTING-OAUTH.md +1 -1
  265. package/docs/V2-MIGRATION.md +404 -30
  266. package/package.json +20 -6
  267. package/scripts/release-validate.mjs +56 -0
  268. package/server.json +22 -0
  269. package/tools/inspector/package-lock.json +163 -201
@@ -1,16 +1,37 @@
1
1
  "use strict";
2
- /** Shared append-only incident journal validation and migration policy. */
2
+ /**
3
+ * Shared journal content bounds and the dedicated incident journal tools'
4
+ * argument policy.
5
+ *
6
+ * The content schema bounds every journal write: the dedicated incident
7
+ * tools, and `comments`/`work_notes` written through the generic write tools
8
+ * on any table (see write-value-policy.ts). Generic journal writes are no
9
+ * longer rejected by name; the configured field policy decides whether a
10
+ * profile may write them.
11
+ */
3
12
  Object.defineProperty(exports, "__esModule", { value: true });
4
13
  exports.IncidentJournalPolicyError = exports.incidentJournalContentSchema = exports.INCIDENT_JOURNAL_MAX_UTF8_BYTES = exports.INCIDENT_JOURNAL_MAX_CHARACTERS = void 0;
14
+ exports.isJournalFieldName = isJournalFieldName;
5
15
  exports.isIncidentJournalPolicyError = isIncidentJournalPolicyError;
6
16
  exports.incidentJournalMigrationMessage = incidentJournalMigrationMessage;
7
- exports.rejectGenericIncidentJournalFields = rejectGenericIncidentJournalFields;
8
17
  exports.prepareIncidentJournalArguments = prepareIncidentJournalArguments;
9
- const node_util_1 = require("node:util");
10
18
  const zod_1 = require("zod");
11
19
  const servicenow_identifiers_js_1 = require("./servicenow-identifiers.js");
12
20
  exports.INCIDENT_JOURNAL_MAX_CHARACTERS = 8_000;
13
21
  exports.INCIDENT_JOURNAL_MAX_UTF8_BYTES = 16_384;
22
+ /** Journal fields share these names on incident and every other task table. */
23
+ const JOURNAL_FIELD_NAMES = new Set([
24
+ "comments",
25
+ "work_notes",
26
+ ]);
27
+ /**
28
+ * True for a canonical journal field name. A write to one appends an entry,
29
+ * so the value policy bounds it as journal text and the HTTP client never
30
+ * re-sends it after the request may have reached the instance.
31
+ */
32
+ function isJournalFieldName(field) {
33
+ return JOURNAL_FIELD_NAMES.has(field);
34
+ }
14
35
  const JOURNAL_TOOLS = Object.freeze({
15
36
  comments: "sn_incident_add_comment",
16
37
  work_notes: "sn_incident_add_work_note",
@@ -57,6 +78,11 @@ exports.incidentJournalContentSchema = zod_1.z
57
78
  .describe(`Journal text; 1-${exports.INCIDENT_JOURNAL_MAX_CHARACTERS} characters and at most ` +
58
79
  `${exports.INCIDENT_JOURNAL_MAX_UTF8_BYTES} UTF-8 bytes.`);
59
80
  class IncidentJournalPolicyError extends Error {
81
+ /**
82
+ * `generic_journal_update` is no longer issued: generic journal writes are
83
+ * decided by field policy. The reason stays in the type so the dispatcher's
84
+ * existing classification branches keep compiling.
85
+ */
60
86
  reason;
61
87
  field;
62
88
  constructor(reason, field) {
@@ -74,7 +100,11 @@ function isIncidentJournalPolicyError(error) {
74
100
  error !== null &&
75
101
  ISSUED_INCIDENT_JOURNAL_POLICY_ERRORS.has(error));
76
102
  }
77
- /** Safe fixed guidance; caller-controlled journal text is never interpolated. */
103
+ /**
104
+ * Safe fixed guidance; caller-controlled journal text is never interpolated.
105
+ * Only the dispatcher's `generic_journal_update` branch uses it, and nothing
106
+ * issues that reason any more.
107
+ */
78
108
  function incidentJournalMigrationMessage(field, tool) {
79
109
  const rejected = typeof tool === "string" && tool.trim() !== ""
80
110
  ? `${tool.trim()} cannot write append-only incident field ${field}.`
@@ -86,23 +116,6 @@ function incidentJournalMigrationMessage(field, tool) {
86
116
  : `Use ${JOURNAL_TOOLS[field]} with sys_id and content.`;
87
117
  return `${rejected} ${remedy}`;
88
118
  }
89
- /** Reject journal keys in generic writes without reading any payload values. */
90
- function rejectGenericIncidentJournalFields(payload) {
91
- if (typeof payload !== "object" ||
92
- payload === null ||
93
- Array.isArray(payload) ||
94
- node_util_1.types.isProxy(payload)) {
95
- return;
96
- }
97
- for (const candidate of Reflect.ownKeys(payload)) {
98
- if (typeof candidate !== "string")
99
- continue;
100
- const field = candidate.trim().toLowerCase();
101
- if (field === "comments" || field === "work_notes") {
102
- throw new IncidentJournalPolicyError("generic_journal_update", field);
103
- }
104
- }
105
- }
106
119
  /** Defense-in-depth normalization for the fixed incident journal modules. */
107
120
  function prepareIncidentJournalArguments(args) {
108
121
  const identity = servicenow_identifiers_js_1.serviceNowSysIdSchema.safeParse(args.sys_id);
@@ -1 +1 @@
1
- {"version":3,"file":"incident-journal-policy.js","sourceRoot":"","sources":["../src/incident-journal-policy.ts"],"names":[],"mappings":";AAAA,2EAA2E;;;AAmF3E,oEAQC;AAGD,0EAeC;AAGD,gFAgBC;AAGD,0EASC;AA1ID,yCAAmD;AACnD,6BAAwB;AAExB,2EAAoE;AAEvD,QAAA,+BAA+B,GAAG,KAAK,CAAC;AACxC,QAAA,+BAA+B,GAAG,MAAM,CAAC;AAItD,MAAM,aAAa,GACjB,MAAM,CAAC,MAAM,CAAC;IACZ,QAAQ,EAAE,yBAAyB;IACnC,UAAU,EAAE,2BAA2B;CACxC,CAAC,CAAC;AACL,MAAM,qCAAqC,GAAG,IAAI,OAAO,EA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AK,IAAI;QACd,qCAAqC,CAAC,GAAG,CAAC,KAAK,CAAC,CACjD,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAgB,+BAA+B,CAC7C,KAA2B,EAC3B,IAAa;IAEb,MAAM,QAAQ,GACZ,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;QAC5C,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,4CAA4C,KAAK,GAAG;QACpE,CAAC,CAAC,wDAAwD,KAAK,GAAG,CAAC;IACvE,6EAA6E;IAC7E,oEAAoE;IACpE,MAAM,MAAM,GACV,IAAI,KAAK,WAAW;QAClB,CAAC,CAAC,qCAAqC,aAAa,CAAC,KAAK,CAAC,mCAAmC;QAC9F,CAAC,CAAC,OAAO,aAAa,CAAC,KAAK,CAAC,2BAA2B,CAAC;IAC7D,OAAO,GAAG,QAAQ,IAAI,MAAM,EAAE,CAAC;AACjC,CAAC;AAED,6EAA6E;AAC7E,SAAgB,+BAA+B,CAC7C,IAAuC;IAEvC,MAAM,QAAQ,GAAG,iDAAqB,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9D,MAAM,OAAO,GAAG,oCAA4B,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,IAAI,CAAC,QAAQ,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC1C,MAAM,IAAI,0BAA0B,CAAC,yBAAyB,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AACzE,CAAC"}
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ const table_policy_js_1 = require("./table-policy.js");
31
31
  const runtime_environment_js_1 = require("./runtime-environment.js");
32
32
  const index_js_1 = require("./tools/index.js");
33
33
  const version_js_1 = require("./version.js");
34
+ const hidden_values_js_1 = require("./hidden-values.js");
34
35
  function createRestrictedPolicyProvider(profileManager, encodedQueryAccess) {
35
36
  return Object.freeze({
36
37
  resolve: ({ profile }) => {
@@ -58,6 +59,9 @@ function createRestrictedPolicyProvider(profileManager, encodedQueryAccess) {
58
59
  // Only the grants are read from this; cache settings reach handlers
59
60
  // through the resolved configuration instead.
60
61
  atf: profileManager.getAtfConfig(profile.name),
62
+ ...(configuredProfile.fieldTypes === undefined
63
+ ? {}
64
+ : { fieldTypes: configuredProfile.fieldTypes }),
61
65
  });
62
66
  },
63
67
  });
@@ -97,6 +101,9 @@ async function main() {
97
101
  maxPendingLines: 256,
98
102
  }),
99
103
  });
104
+ const optOut = (0, hidden_values_js_1.fieldTypesOptOutWarning)(profileManager.getFieldTypesNotRequiredProfileNames());
105
+ if (optOut !== undefined)
106
+ (0, stdio_runtime_js_1.stderrWrite)(optOut);
100
107
  const basicProfiles = profileManager.getBasicAuthProfileNames();
101
108
  if (basicProfiles.length > 0) {
102
109
  (0, stdio_runtime_js_1.stderrWrite)(`[servicenow-mcp] WARNING: ${basicProfiles.length} configured profile(s) use ` +
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;GAmBG;;AASH,uEAGmC;AACnC,mEAIiC;AACjC,6DAAiG;AACjG,yDAA0D;AAC1D,2CAA8C;AAC9C,yDAK4B;AAC5B,uDAG2B;AAC3B,qEAIkC;AAClC,+CAG0B;AAC1B,6CAAuC;AAEvC,SAAS,8BAA8B,CACrC,cAAkC,EAClC,kBAA4C;IAE5C,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,OAAO,EAAE,CAAC,EAAE,OAAO,EAAiC,EAAE,EAAE;YACtD,MAAM,iBAAiB,GAAG,cAAc,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC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AAS,EAAE,oBAAoB,EAAE;QACjC,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC;YAC/B,KAAK,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE;SACvC,CAAC;KACH,CAAC,CAAC;IACH,OAAO,IAAA,2BAAe,EAAC;QACrB,YAAY,EAAE,EAAE,cAAc,EAAE,gBAAgB,EAAE;QAClD,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;YACxC,IAAA,uCAAoB,EAAC,OAAO,CAAC,CAAC;YAC9B,MAAM,IAAA,kCAAuB,EAC3B,OAAO,EACP,YAAY,CAAC,cAAc,EAC3B,YAAY,CAAC,gBAAgB,CAC9B,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,oBAAoB;IAC3B,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,KAAK,CAAC,OAAwB,IAAS,CAAC;QACxC,eAAe,CAAC,OAA8B,IAAS,CAAC;KACzD,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IACnC,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,uBAAuB,CAAC;IAChF,IAAA,8BAAW,EAAC,+CAA+C,MAAM,IAAI,CAAC,CAAC;IACvE,IAAA,8BAAW,EAAC,oEAAoE,CAAC,CAAC;IAClF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Structural bounds for untrusted JSON-RPC messages, checked before any
3
+ * schema validation runs.
4
+ *
5
+ * Schema libraries walk every element of a collection they validate and can
6
+ * record one issue (or one issue tree, for a union) per failing element. That
7
+ * work grows with the element count rather than the byte count, so a
8
+ * request well inside the body-size limit can still cost far more memory and
9
+ * time to reject than to accept. The protocol schemas for methods such as
10
+ * `initialize` and `prompts/get` run before any tool-level bound can apply,
11
+ * so this module is the only layer that covers them.
12
+ *
13
+ * {@link inspectJsonShape} is plain JavaScript, independent of the schema
14
+ * library and its version. It is a single iterative pass with an explicit
15
+ * stack (no recursion, so no call-stack limit to reach) and it stops at the
16
+ * first bound crossed.
17
+ *
18
+ * The bounds are derived from the largest input any tool legitimately
19
+ * accepts, so a request that passes every later policy check also passes
20
+ * here:
21
+ *
22
+ * - an array may hold at most {@link MAX_FIELD_ARRAY_LENGTH} elements, the
23
+ * field-policy bound for a single array value;
24
+ * - the message may hold at most {@link MAX_JSON_MESSAGE_ELEMENTS} array
25
+ * elements and object members in total: the tool-argument budget plus a
26
+ * fixed allowance for the JSON-RPC envelope;
27
+ * - no value may sit deeper than {@link MAX_JSON_MESSAGE_DEPTH} levels below
28
+ * the message root. The deepest legitimate value is a field-write value at
29
+ * the field-policy depth limit, reached through `params.arguments.fields`.
30
+ *
31
+ * @module json-shape-limits
32
+ */
33
+ /**
34
+ * Element budget for one tool call's arguments, as the SDK counts it (every
35
+ * array element and own object member below the arguments object).
36
+ *
37
+ * The largest legitimate call is a bulk write: a full field-value budget, a
38
+ * structured filter at the compiler's node bound, and the argument keys
39
+ * themselves. Every value in a field-write map counts once as a member of its
40
+ * parent, which is exactly how the field policy counts nodes.
41
+ */
42
+ export declare const MAX_TOOL_INPUT_ELEMENTS: number;
43
+ export declare const MAX_JSON_MESSAGE_ELEMENTS: number;
44
+ export declare const MAX_JSON_MESSAGE_ARRAY_LENGTH = 10000;
45
+ /**
46
+ * Root is depth 0. A field value sits at depth 4 (`params`, `arguments`,
47
+ * `fields`, the field) and may nest {@link MAX_FIELD_VALUE_DEPTH} levels
48
+ * further, which gives 28; the remainder is headroom for envelope changes.
49
+ */
50
+ export declare const MAX_JSON_MESSAGE_DEPTH: number;
51
+ export type JsonShapeViolation = "array_length" | "element_count" | "depth";
52
+ export interface JsonShapeLimits {
53
+ readonly maxArrayLength: number;
54
+ readonly maxElements: number;
55
+ readonly maxDepth: number;
56
+ }
57
+ export declare const JSON_MESSAGE_SHAPE_LIMITS: JsonShapeLimits;
58
+ /** Fixed rejection text. It never includes any part of the rejected input. */
59
+ export declare const JSON_SHAPE_REJECTION_MESSAGE = "Request exceeds structural limits.";
60
+ /** JSON-RPC "Invalid Request". */
61
+ export declare const JSON_SHAPE_REJECTION_CODE = -32600;
62
+ /**
63
+ * Check a parsed JSON value against structural bounds.
64
+ *
65
+ * Returns `undefined` when the value is within every bound, or the first bound
66
+ * it crosses. Only plain JSON data is expected (the output of `JSON.parse`),
67
+ * but anything that throws while being read is reported as a violation rather
68
+ * than propagated.
69
+ */
70
+ export declare function inspectJsonShape(value: unknown, limits?: JsonShapeLimits): JsonShapeViolation | undefined;
71
+ //# sourceMappingURL=json-shape-limits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-shape-limits.d.ts","sourceRoot":"","sources":["../src/json-shape-limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAUH;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,QAC6C,CAAC;AAKlF,eAAO,MAAM,yBAAyB,QAAwD,CAAC;AAC/F,eAAO,MAAM,6BAA6B,QAAyB,CAAC;AACpE;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,QAA4B,CAAC;AAEhE,MAAM,MAAM,kBAAkB,GAAG,cAAc,GAAG,eAAe,GAAG,OAAO,CAAC;AAE5E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,yBAAyB,EAAE,eAItC,CAAC;AAEH,8EAA8E;AAC9E,eAAO,MAAM,4BAA4B,uCAAuC,CAAC;AACjF,kCAAkC;AAClC,eAAO,MAAM,yBAAyB,SAAS,CAAC;AAEhD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,MAAM,GAAE,eAA2C,GAClD,kBAAkB,GAAG,SAAS,CA4ChC"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ /**
3
+ * Structural bounds for untrusted JSON-RPC messages, checked before any
4
+ * schema validation runs.
5
+ *
6
+ * Schema libraries walk every element of a collection they validate and can
7
+ * record one issue (or one issue tree, for a union) per failing element. That
8
+ * work grows with the element count rather than the byte count, so a
9
+ * request well inside the body-size limit can still cost far more memory and
10
+ * time to reject than to accept. The protocol schemas for methods such as
11
+ * `initialize` and `prompts/get` run before any tool-level bound can apply,
12
+ * so this module is the only layer that covers them.
13
+ *
14
+ * {@link inspectJsonShape} is plain JavaScript, independent of the schema
15
+ * library and its version. It is a single iterative pass with an explicit
16
+ * stack (no recursion, so no call-stack limit to reach) and it stops at the
17
+ * first bound crossed.
18
+ *
19
+ * The bounds are derived from the largest input any tool legitimately
20
+ * accepts, so a request that passes every later policy check also passes
21
+ * here:
22
+ *
23
+ * - an array may hold at most {@link MAX_FIELD_ARRAY_LENGTH} elements, the
24
+ * field-policy bound for a single array value;
25
+ * - the message may hold at most {@link MAX_JSON_MESSAGE_ELEMENTS} array
26
+ * elements and object members in total: the tool-argument budget plus a
27
+ * fixed allowance for the JSON-RPC envelope;
28
+ * - no value may sit deeper than {@link MAX_JSON_MESSAGE_DEPTH} levels below
29
+ * the message root. The deepest legitimate value is a field-write value at
30
+ * the field-policy depth limit, reached through `params.arguments.fields`.
31
+ *
32
+ * @module json-shape-limits
33
+ */
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.JSON_SHAPE_REJECTION_CODE = exports.JSON_SHAPE_REJECTION_MESSAGE = exports.JSON_MESSAGE_SHAPE_LIMITS = exports.MAX_JSON_MESSAGE_DEPTH = exports.MAX_JSON_MESSAGE_ARRAY_LENGTH = exports.MAX_JSON_MESSAGE_ELEMENTS = exports.MAX_TOOL_INPUT_ELEMENTS = void 0;
36
+ exports.inspectJsonShape = inspectJsonShape;
37
+ const field_policy_js_1 = require("./field-policy.js");
38
+ const structured_query_js_1 = require("./structured-query.js");
39
+ /**
40
+ * Element budget for one tool call's arguments, as the SDK counts it (every
41
+ * array element and own object member below the arguments object).
42
+ *
43
+ * The largest legitimate call is a bulk write: a full field-value budget, a
44
+ * structured filter at the compiler's node bound, and the argument keys
45
+ * themselves. Every value in a field-write map counts once as a member of its
46
+ * parent, which is exactly how the field policy counts nodes.
47
+ */
48
+ exports.MAX_TOOL_INPUT_ELEMENTS = field_policy_js_1.MAX_FIELD_VALUE_NODES + structured_query_js_1.MAX_STRUCTURED_QUERY_NODES + field_policy_js_1.MAX_TOOL_ARGUMENT_OWN_KEYS;
49
+ /** Members outside the tool arguments: `jsonrpc`, `id`, `method`, `params`, `_meta`, and so on. */
50
+ const JSON_RPC_ENVELOPE_ALLOWANCE = 64;
51
+ exports.MAX_JSON_MESSAGE_ELEMENTS = exports.MAX_TOOL_INPUT_ELEMENTS + JSON_RPC_ENVELOPE_ALLOWANCE;
52
+ exports.MAX_JSON_MESSAGE_ARRAY_LENGTH = field_policy_js_1.MAX_FIELD_ARRAY_LENGTH;
53
+ /**
54
+ * Root is depth 0. A field value sits at depth 4 (`params`, `arguments`,
55
+ * `fields`, the field) and may nest {@link MAX_FIELD_VALUE_DEPTH} levels
56
+ * further, which gives 28; the remainder is headroom for envelope changes.
57
+ */
58
+ exports.MAX_JSON_MESSAGE_DEPTH = field_policy_js_1.MAX_FIELD_VALUE_DEPTH + 8;
59
+ exports.JSON_MESSAGE_SHAPE_LIMITS = Object.freeze({
60
+ maxArrayLength: exports.MAX_JSON_MESSAGE_ARRAY_LENGTH,
61
+ maxElements: exports.MAX_JSON_MESSAGE_ELEMENTS,
62
+ maxDepth: exports.MAX_JSON_MESSAGE_DEPTH,
63
+ });
64
+ /** Fixed rejection text. It never includes any part of the rejected input. */
65
+ exports.JSON_SHAPE_REJECTION_MESSAGE = "Request exceeds structural limits.";
66
+ /** JSON-RPC "Invalid Request". */
67
+ exports.JSON_SHAPE_REJECTION_CODE = -32600;
68
+ /**
69
+ * Check a parsed JSON value against structural bounds.
70
+ *
71
+ * Returns `undefined` when the value is within every bound, or the first bound
72
+ * it crosses. Only plain JSON data is expected (the output of `JSON.parse`),
73
+ * but anything that throws while being read is reported as a violation rather
74
+ * than propagated.
75
+ */
76
+ function inspectJsonShape(value, limits = exports.JSON_MESSAGE_SHAPE_LIMITS) {
77
+ if (value === null || typeof value !== "object")
78
+ return undefined;
79
+ // Parallel stacks avoid allocating a pair per container. Only containers
80
+ // are pushed, and each push follows a counted member, so the stacks never
81
+ // grow past maxElements entries.
82
+ const values = [value];
83
+ const depths = [0];
84
+ let elements = 0;
85
+ try {
86
+ while (values.length > 0) {
87
+ const node = values.pop();
88
+ const childDepth = depths.pop() + 1;
89
+ if (Array.isArray(node)) {
90
+ const length = node.length;
91
+ if (length > limits.maxArrayLength)
92
+ return "array_length";
93
+ elements += length;
94
+ if (elements > limits.maxElements)
95
+ return "element_count";
96
+ if (length === 0)
97
+ continue;
98
+ if (childDepth > limits.maxDepth)
99
+ return "depth";
100
+ for (let index = 0; index < length; index += 1) {
101
+ const child = node[index];
102
+ if (child !== null && typeof child === "object") {
103
+ values.push(child);
104
+ depths.push(childDepth);
105
+ }
106
+ }
107
+ }
108
+ else {
109
+ for (const key in node) {
110
+ if (!Object.hasOwn(node, key))
111
+ continue;
112
+ elements += 1;
113
+ if (elements > limits.maxElements)
114
+ return "element_count";
115
+ if (childDepth > limits.maxDepth)
116
+ return "depth";
117
+ const child = node[key];
118
+ if (child !== null && typeof child === "object") {
119
+ values.push(child);
120
+ depths.push(childDepth);
121
+ }
122
+ }
123
+ }
124
+ }
125
+ }
126
+ catch {
127
+ return "element_count";
128
+ }
129
+ return undefined;
130
+ }
131
+ //# sourceMappingURL=json-shape-limits.js.map
@@ -0,0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AAO,KAAK,KAAK,QAAQ,EAAE,CAAC;wBAChD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;wBACnB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;oBAC1B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -5,33 +5,44 @@
5
5
  * selector. The scope must discriminate credential identity as well as
6
6
  * instance: ServiceNow evaluates ACLs per user, and a cache hit skips the
7
7
  * upstream read entirely, so a scope shared between identities would serve
8
- * one caller's authorized rows to another. A cache hit performs a lightweight
9
- * sys_updated_on probe before reuse; changed rows force a refresh. Callers can
10
- * force refresh by passing the internal sysparm_force_recache=true parameter,
11
- * which is stripped before upstream I/O.
8
+ * one caller's authorized rows to another. Callers can force refresh by
9
+ * passing the internal sysparm_force_recache=true parameter, which is stripped
10
+ * before upstream I/O.
12
11
  *
13
- * The freshness probe compares sys_updated_on, which ServiceNow evaluates in
14
- * the session user's timezone, so the probe timestamp is formatted in that
15
- * timezone rather than UTC. The zone is resolved per identity from
16
- * sys_user.time_zone, falling back to the glide.sys.default.tz property; when
17
- * it cannot be resolved, caching is disabled for that identity rather than
18
- * assuming UTC and serving silently stale metadata.
12
+ * Freshness is a server watermark: the table's row count (X-Total-Count) and
13
+ * its newest row by sys_updated_on, read back as the stored UTC value. Each
14
+ * entry keeps the watermark read just before its rows were fetched, and a
15
+ * cache hit is served only while a new watermark read still matches it. Both
16
+ * sides of the comparison come from the instance, so the session timezone,
17
+ * date format, DST and clock skew between this host and the instance play no
18
+ * part, and no user lookup is needed: caching behaves the same in every auth
19
+ * mode.
19
20
  *
20
- * Deletions are not detected by the probe, which sees updates only. A row
21
- * deleted upstream stays visible for at most one TTL: a successful probe
22
- * refreshes recency for eviction but never extends expiresAt, so the entry
23
- * still expires on schedule and forces a genuine refetch.
21
+ * An insert or an update makes its row the newest, and an insert or a delete
22
+ * changes the count, so every write moves the watermark -- at one-second
23
+ * resolution. An update within the stored watermark's own second, to a row
24
+ * other than the newest, can still go unseen; so can a write that skips the
25
+ * system fields. Such a row stays stale for at most one TTL: a matching
26
+ * watermark refreshes recency for eviction but never extends expiresAt, so the
27
+ * entry still expires on schedule and forces a genuine refetch.
28
+ *
29
+ * Two memos keep the watermark from costing more than it saves. Within one
30
+ * tool call each table's watermark is read once, however many reads of the
31
+ * table the call makes. Across calls, a table whose watermark proved unusable
32
+ * is read straight through, without a watermark, for a while: long for causes
33
+ * that persist (an incomplete or future-dated watermark, a 4xx), short for
34
+ * transient ones (429, 5xx, timeouts, network).
24
35
  *
25
36
  * @module metadata-cache
26
37
  */
27
- import type { ServiceNowOperations } from "./client.js";
38
+ import { type ServiceNowOperations } from "./client.js";
28
39
  export declare const DEFAULT_METADATA_CACHE_TTL_MS: number;
29
40
  /**
30
41
  * Tables cached by default.
31
42
  *
32
- * The bar for inclusion is a large payload relative to the freshness probe,
43
+ * The bar for inclusion is a large payload relative to the watermark read,
33
44
  * not merely "this table changes rarely" -- a cache hit still costs one
34
- * upstream round trip (see hasChangedSince), so the saving is payload bytes,
45
+ * upstream round trip (see tableWatermark), so the saving is payload bytes,
35
46
  * never request count. sys_properties is deliberately absent: its rows are
36
47
  * ACL-restricted per user and routinely hold integration secrets in `value`,
37
48
  * and the only reads of it here are three single-value build-info lookups
@@ -53,19 +64,71 @@ export declare const FORCE_RECACHE_PARAM = "sysparm_force_recache";
53
64
  * so both are capped and evicted in least-recently-used order. */
54
65
  export declare const MAX_METADATA_CACHE_SCOPES = 64;
55
66
  export declare const MAX_METADATA_CACHE_ENTRIES_PER_SCOPE = 512;
67
+ /** How long a table goes uncached after its watermark proved unusable; never
68
+ * longer than the cache TTL. */
69
+ export declare const STRUCTURAL_UNCACHEABLE_MS: number;
70
+ export declare const TRANSIENT_UNCACHEABLE_MS: number;
71
+ /** Bounds on derived values per scope (see derivedMetadataMemo). */
72
+ export declare const MAX_DERIVED_ENTRIES_PER_SCOPE = 512;
73
+ export declare const MAX_DERIVED_BYTES_PER_SCOPE: number;
56
74
  interface MetadataCacheEnvironment {
57
75
  readonly SN_METADATA_CACHE_TTL_MS?: string;
58
76
  readonly SN_METADATA_CACHE_TABLES?: string;
59
77
  }
60
78
  export declare function metadataCacheConfigFromEnvironment(environment?: MetadataCacheEnvironment): MetadataCacheConfigInput;
61
79
  export declare function createMetadataCacheConfig(input: MetadataCacheConfigInput | undefined): MetadataCacheConfig;
80
+ /**
81
+ * A per-credential memo of values derived from metadata reads, kept with the
82
+ * cache scope of a cached wrapper.
83
+ *
84
+ * A metadata-cache hit still costs a watermark round trip. A value a call
85
+ * needs before every read (the hidden-field type map) would then add one
86
+ * request to every call, so the value derived from the rows is memoized here
87
+ * instead: a hit costs no request at all. Each value lives at most `ttlMs`
88
+ * and never longer than the profile's cache TTL; when it expires the deriving
89
+ * read goes back through the cache, whose watermark decides whether the rows
90
+ * changed. The memo sits in the same scope as the rows (instance and
91
+ * credential identity), is bounded in entries and bytes, and is evicted with
92
+ * the scope.
93
+ *
94
+ * It does not follow the profile's cache table list: what it holds is derived
95
+ * metadata (field names and types, table chains), never row values, and
96
+ * without it every call would repeat the deriving reads. An empty table list
97
+ * (rows cached for no table) leaves it on for the same reason; the profile's
98
+ * TTL still caps how long a value lives.
99
+ *
100
+ * Undefined when `operations` is not a cached wrapper.
101
+ */
102
+ export interface DerivedMetadataMemo {
103
+ get(key: string): unknown;
104
+ /** `value` must be immutable; `bytes` is its estimated size. */
105
+ set(key: string, value: unknown, bytes: number, ttlMs: number): void;
106
+ /** The derivation of `key` another call has in flight, if any. */
107
+ pending(key: string): Promise<unknown> | undefined;
108
+ /**
109
+ * Record `promise` as the derivation of `key` in flight until it settles. A
110
+ * rejection is never kept: the entry is cleared, and the next call retries.
111
+ */
112
+ track<T>(key: string, promise: Promise<T>): Promise<T>;
113
+ }
114
+ export declare function derivedMetadataMemo(operations: ServiceNowOperations): DerivedMetadataMemo | undefined;
115
+ /**
116
+ * The operations underneath a cached wrapper, or `operations` itself when it
117
+ * is not one.
118
+ *
119
+ * Use it for a read whose answer decides a write, such as the records a bulk
120
+ * update or delete targets. A cache hit can be stale within the watermark's
121
+ * documented gaps, which a read can tolerate but a write target cannot. The
122
+ * read costs one request, with no watermark, and leaves the cache untouched.
123
+ * The internal force-recache parameter is no substitute: it costs a watermark
124
+ * read as well, stores a single-use entry, and reaches ServiceNow unstripped
125
+ * when no wrapper is in place.
126
+ */
127
+ export declare function uncachedOperations(operations: ServiceNowOperations): ServiceNowOperations;
62
128
  /**
63
129
  * @param scope Cache partition key. Must identify the ServiceNow instance
64
130
  * *and* the credential identity reading from it -- see the module docstring.
65
- * @param sessionUserName ServiceNow user_name this scope authenticates as.
66
- * Required to resolve the session timezone; without it the freshness probe
67
- * cannot be made correct, so caching is disabled for the scope.
68
131
  */
69
- export declare function createCachedServiceNowOperations(operations: ServiceNowOperations, scope: string, config: MetadataCacheConfigInput | undefined, sessionUserName?: string): ServiceNowOperations;
132
+ export declare function createCachedServiceNowOperations(operations: ServiceNowOperations, scope: string, config: MetadataCacheConfigInput | undefined): ServiceNowOperations;
70
133
  export {};
71
134
  //# sourceMappingURL=metadata-cache.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"metadata-cache.d.ts","sourceRoot":"","sources":["../src/metadata-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAEV,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAIrB,eAAO,MAAM,6BAA6B,QAAsB,CAAC;AACjE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,6BAA6B,mBAQxC,CAAC;AAEH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,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