@onlyflows/servicenow-mcp 2.2.0-dev.6 → 2.2.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.
- package/.env.example +6 -3
- package/CHANGELOG.md +286 -0
- package/README.md +504 -101
- package/dist/atf-form.d.ts +3 -15
- package/dist/atf-form.d.ts.map +1 -1
- package/dist/atf-result-cache.d.ts +23 -59
- package/dist/atf-result-cache.d.ts.map +1 -1
- package/dist/auth.d.ts +1 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +17 -0
- package/dist/auth.js.map +1 -1
- package/dist/batch-limits.d.ts +18 -0
- package/dist/batch-limits.d.ts.map +1 -0
- package/dist/batch-limits.js +21 -0
- package/dist/batch-limits.js.map +1 -0
- package/dist/bounded-input.d.ts +49 -0
- package/dist/bounded-input.d.ts.map +1 -0
- package/dist/bounded-input.js +81 -0
- package/dist/bounded-input.js.map +1 -0
- package/dist/client.d.ts +25 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +92 -18
- package/dist/client.js.map +1 -1
- package/dist/encoded-query-policy.d.ts +11 -0
- package/dist/encoded-query-policy.d.ts.map +1 -1
- package/dist/encoded-query-policy.js +10 -1
- package/dist/encoded-query-policy.js.map +1 -1
- package/dist/field-policy.d.ts +82 -3
- package/dist/field-policy.d.ts.map +1 -1
- package/dist/field-policy.js +609 -80
- package/dist/field-policy.js.map +1 -1
- package/dist/html-response.d.ts +34 -0
- package/dist/html-response.d.ts.map +1 -0
- package/dist/html-response.js +72 -0
- package/dist/html-response.js.map +1 -0
- package/dist/http-runtime.d.ts.map +1 -1
- package/dist/http-runtime.js +8 -0
- package/dist/http-runtime.js.map +1 -1
- package/dist/incident-journal-policy.d.ts +27 -5
- package/dist/incident-journal-policy.d.ts.map +1 -1
- package/dist/incident-journal-policy.js +34 -21
- package/dist/incident-journal-policy.js.map +1 -1
- package/dist/json-shape-limits.d.ts +71 -0
- package/dist/json-shape-limits.d.ts.map +1 -0
- package/dist/json-shape-limits.js +131 -0
- package/dist/json-shape-limits.js.map +1 -0
- package/dist/metadata-cache.d.ts +46 -21
- package/dist/metadata-cache.d.ts.map +1 -1
- package/dist/metadata-cache.js +228 -195
- package/dist/metadata-cache.js.map +1 -1
- package/dist/policy-card.d.ts +131 -0
- package/dist/policy-card.d.ts.map +1 -0
- package/dist/policy-card.js +409 -0
- package/dist/policy-card.js.map +1 -0
- package/dist/profile-manager.d.ts +7 -3
- package/dist/profile-manager.d.ts.map +1 -1
- package/dist/profile-manager.js +66 -3
- package/dist/profile-manager.js.map +1 -1
- package/dist/record-identifier-policy.d.ts +2 -8
- package/dist/record-identifier-policy.d.ts.map +1 -1
- package/dist/risky-grants.d.ts +25 -0
- package/dist/risky-grants.d.ts.map +1 -0
- package/dist/risky-grants.js +77 -0
- package/dist/risky-grants.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +26 -5
- package/dist/server.js.map +1 -1
- package/dist/setup-prompts.js +1 -0
- package/dist/setup-prompts.js.map +1 -1
- package/dist/setup.d.ts +1 -1
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +300 -58
- package/dist/setup.js.map +1 -1
- package/dist/stdio-runtime.d.ts +15 -0
- package/dist/stdio-runtime.d.ts.map +1 -1
- package/dist/stdio-runtime.js +60 -0
- package/dist/stdio-runtime.js.map +1 -1
- package/dist/structured-query.d.ts +100 -115
- package/dist/structured-query.d.ts.map +1 -1
- package/dist/structured-query.js +132 -16
- package/dist/structured-query.js.map +1 -1
- package/dist/table-policy.d.ts +10 -4
- package/dist/table-policy.d.ts.map +1 -1
- package/dist/table-policy.js +1 -1
- package/dist/table-policy.js.map +1 -1
- package/dist/tool-error.d.ts +18 -0
- package/dist/tool-error.d.ts.map +1 -1
- package/dist/tool-error.js +69 -0
- package/dist/tool-error.js.map +1 -1
- package/dist/tool-table-access.d.ts.map +1 -1
- package/dist/tool-table-access.js +32 -2
- package/dist/tool-table-access.js.map +1 -1
- package/dist/tools/aggregate.d.ts +13 -19
- package/dist/tools/aggregate.d.ts.map +1 -1
- package/dist/tools/aggregate.js +2 -3
- package/dist/tools/aggregate.js.map +1 -1
- package/dist/tools/all-fields-cap.d.ts.map +1 -1
- package/dist/tools/all-fields-cap.js +3 -38
- package/dist/tools/all-fields-cap.js.map +1 -1
- package/dist/tools/atf-author-module.d.ts +28 -7
- package/dist/tools/atf-author-module.d.ts.map +1 -1
- package/dist/tools/atf-author-module.js +4 -2
- package/dist/tools/atf-author-module.js.map +1 -1
- package/dist/tools/atf-contracts.d.ts +135 -829
- package/dist/tools/atf-contracts.d.ts.map +1 -1
- package/dist/tools/atf-shared.js +2 -2
- package/dist/tools/atf-shared.js.map +1 -1
- package/dist/tools/atf-step-catalog.d.ts +3 -7
- package/dist/tools/atf-step-catalog.d.ts.map +1 -1
- package/dist/tools/atf-step-catalog.js +12 -5
- package/dist/tools/atf-step-catalog.js.map +1 -1
- package/dist/tools/atf.d.ts +8 -24
- package/dist/tools/atf.d.ts.map +1 -1
- package/dist/tools/atf.js +2 -2
- package/dist/tools/atf.js.map +1 -1
- package/dist/tools/attach.d.ts +6 -22
- package/dist/tools/attach.d.ts.map +1 -1
- package/dist/tools/batch.d.ts +18 -71
- package/dist/tools/batch.d.ts.map +1 -1
- package/dist/tools/batch.js +544 -96
- package/dist/tools/batch.js.map +1 -1
- package/dist/tools/catalog.d.ts +2 -2
- package/dist/tools/catalog.d.ts.map +1 -1
- package/dist/tools/catalog.js +7 -1
- package/dist/tools/catalog.js.map +1 -1
- package/dist/tools/codesearch.d.ts +1 -13
- package/dist/tools/codesearch.d.ts.map +1 -1
- package/dist/tools/create-module.d.ts +9 -14
- package/dist/tools/create-module.d.ts.map +1 -1
- package/dist/tools/create-module.js +4 -8
- package/dist/tools/create-module.js.map +1 -1
- package/dist/tools/delete.d.ts +1 -9
- package/dist/tools/delete.d.ts.map +1 -1
- package/dist/tools/delete.js +2 -3
- package/dist/tools/delete.js.map +1 -1
- package/dist/tools/discover.d.ts +6 -14
- package/dist/tools/discover.d.ts.map +1 -1
- package/dist/tools/flow-view-contracts.d.ts +1023 -0
- package/dist/tools/flow-view-contracts.d.ts.map +1 -0
- package/dist/tools/flow-view-contracts.js +570 -0
- package/dist/tools/flow-view-contracts.js.map +1 -0
- package/dist/tools/flow-view-graph.d.ts +86 -0
- package/dist/tools/flow-view-graph.d.ts.map +1 -0
- package/dist/tools/flow-view-graph.js +993 -0
- package/dist/tools/flow-view-graph.js.map +1 -0
- package/dist/tools/flow-view-gzip.d.ts +52 -0
- package/dist/tools/flow-view-gzip.d.ts.map +1 -0
- package/dist/tools/flow-view-gzip.js +179 -0
- package/dist/tools/flow-view-gzip.js.map +1 -0
- package/dist/tools/flow-view-mermaid.d.ts +37 -0
- package/dist/tools/flow-view-mermaid.d.ts.map +1 -0
- package/dist/tools/flow-view-mermaid.js +337 -0
- package/dist/tools/flow-view-mermaid.js.map +1 -0
- package/dist/tools/flow-view-module.d.ts +61 -0
- package/dist/tools/flow-view-module.d.ts.map +1 -0
- package/dist/tools/flow-view-module.js +378 -0
- package/dist/tools/flow-view-module.js.map +1 -0
- package/dist/tools/flow-view-policy.d.ts +106 -0
- package/dist/tools/flow-view-policy.d.ts.map +1 -0
- package/dist/tools/flow-view-policy.js +461 -0
- package/dist/tools/flow-view-policy.js.map +1 -0
- package/dist/tools/flow-view-renderers.d.ts +68 -0
- package/dist/tools/flow-view-renderers.d.ts.map +1 -0
- package/dist/tools/flow-view-renderers.js +513 -0
- package/dist/tools/flow-view-renderers.js.map +1 -0
- package/dist/tools/flow-view-table.d.ts +115 -0
- package/dist/tools/flow-view-table.d.ts.map +1 -0
- package/dist/tools/flow-view-table.js +1002 -0
- package/dist/tools/flow-view-table.js.map +1 -0
- package/dist/tools/get-module.d.ts +36 -42
- package/dist/tools/get-module.d.ts.map +1 -1
- package/dist/tools/health.d.ts +9 -6
- package/dist/tools/health.d.ts.map +1 -1
- package/dist/tools/incident-journal-module.d.ts +8 -7
- package/dist/tools/incident-journal-module.d.ts.map +1 -1
- package/dist/tools/index.d.ts +4 -4
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +43 -6
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/markdown.d.ts +27 -0
- package/dist/tools/markdown.d.ts.map +1 -1
- package/dist/tools/markdown.js +104 -1
- package/dist/tools/markdown.js.map +1 -1
- package/dist/tools/nl.d.ts +1 -11
- package/dist/tools/nl.d.ts.map +1 -1
- package/dist/tools/profile.d.ts +1 -1
- package/dist/tools/profile.d.ts.map +1 -1
- package/dist/tools/profile.js +19 -1
- package/dist/tools/profile.js.map +1 -1
- package/dist/tools/query-module.d.ts +59 -71
- package/dist/tools/query-module.d.ts.map +1 -1
- package/dist/tools/query-module.js +2 -2
- package/dist/tools/query-module.js.map +1 -1
- package/dist/tools/record-write-shared.d.ts.map +1 -1
- package/dist/tools/record-write-shared.js +19 -2
- package/dist/tools/record-write-shared.js.map +1 -1
- package/dist/tools/relationships.d.ts +6 -22
- package/dist/tools/relationships.d.ts.map +1 -1
- package/dist/tools/result-envelope.d.ts +2255 -1357
- package/dist/tools/result-envelope.d.ts.map +1 -1
- package/dist/tools/result-envelope.js +24 -2
- package/dist/tools/result-envelope.js.map +1 -1
- package/dist/tools/schema-module.d.ts +36 -21
- package/dist/tools/schema-module.d.ts.map +1 -1
- package/dist/tools/schema-module.js +106 -65
- package/dist/tools/schema-module.js.map +1 -1
- package/dist/tools/script.d.ts +1 -11
- package/dist/tools/script.d.ts.map +1 -1
- package/dist/tools/syslog.d.ts +11 -18
- package/dist/tools/syslog.d.ts.map +1 -1
- package/dist/tools/syslog.js +2 -3
- package/dist/tools/syslog.js.map +1 -1
- package/dist/tools/table-hierarchy.d.ts +35 -0
- package/dist/tools/table-hierarchy.d.ts.map +1 -0
- package/dist/tools/table-hierarchy.js +74 -0
- package/dist/tools/table-hierarchy.js.map +1 -0
- package/dist/tools/tool-module.d.ts +40 -15
- package/dist/tools/tool-module.d.ts.map +1 -1
- package/dist/tools/tool-module.js +755 -205
- package/dist/tools/tool-module.js.map +1 -1
- package/dist/tools/update-module.d.ts +11 -17
- package/dist/tools/update-module.d.ts.map +1 -1
- package/dist/tools/update-module.js +10 -12
- package/dist/tools/update-module.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/write-value-policy.d.ts +20 -12
- package/dist/write-value-policy.d.ts.map +1 -1
- package/dist/write-value-policy.js +179 -67
- package/dist/write-value-policy.js.map +1 -1
- package/docs/ADDING-TOOLS.md +22 -13
- package/docs/CLIENT-SETUP.md +110 -52
- package/docs/CROSS-CLIENT-RELEASE-MATRIX.md +2 -2
- package/docs/FLOW-VIEW.md +214 -0
- package/docs/PRODUCTION-SECURITY.md +154 -25
- package/docs/RELEASE-VALIDATION.md +2 -2
- package/docs/TESTING-OAUTH.md +1 -1
- package/docs/V2-MIGRATION.md +404 -30
- package/package.json +20 -6
- package/scripts/release-validate.mjs +56 -0
- package/server.json +22 -0
- package/tools/inspector/package-lock.json +163 -201
|
@@ -1,19 +1,41 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Shared journal content bounds and the dedicated incident journal tools'
|
|
3
|
+
* argument policy.
|
|
4
|
+
*
|
|
5
|
+
* The content schema bounds every journal write: the dedicated incident
|
|
6
|
+
* tools, and `comments`/`work_notes` written through the generic write tools
|
|
7
|
+
* on any table (see write-value-policy.ts). Generic journal writes are no
|
|
8
|
+
* longer rejected by name; the configured field policy decides whether a
|
|
9
|
+
* profile may write them.
|
|
10
|
+
*/
|
|
2
11
|
import { z } from "zod";
|
|
3
12
|
export declare const INCIDENT_JOURNAL_MAX_CHARACTERS = 8000;
|
|
4
13
|
export declare const INCIDENT_JOURNAL_MAX_UTF8_BYTES = 16384;
|
|
5
14
|
export type IncidentJournalField = "comments" | "work_notes";
|
|
6
|
-
|
|
15
|
+
/**
|
|
16
|
+
* True for a canonical journal field name. A write to one appends an entry,
|
|
17
|
+
* so the value policy bounds it as journal text and the HTTP client never
|
|
18
|
+
* re-sends it after the request may have reached the instance.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isJournalFieldName(field: string): boolean;
|
|
21
|
+
export declare const incidentJournalContentSchema: z.ZodString;
|
|
7
22
|
export declare class IncidentJournalPolicyError extends Error {
|
|
23
|
+
/**
|
|
24
|
+
* `generic_journal_update` is no longer issued: generic journal writes are
|
|
25
|
+
* decided by field policy. The reason stays in the type so the dispatcher's
|
|
26
|
+
* existing classification branches keep compiling.
|
|
27
|
+
*/
|
|
8
28
|
readonly reason: "generic_journal_update" | "invalid_journal_content";
|
|
9
29
|
readonly field?: IncidentJournalField;
|
|
10
30
|
constructor(reason: "generic_journal_update" | "invalid_journal_content", field?: IncidentJournalField);
|
|
11
31
|
}
|
|
12
32
|
export declare function isIncidentJournalPolicyError(error: unknown): error is IncidentJournalPolicyError;
|
|
13
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Safe fixed guidance; caller-controlled journal text is never interpolated.
|
|
35
|
+
* Only the dispatcher's `generic_journal_update` branch uses it, and nothing
|
|
36
|
+
* issues that reason any more.
|
|
37
|
+
*/
|
|
14
38
|
export declare function incidentJournalMigrationMessage(field: IncidentJournalField, tool?: string): string;
|
|
15
|
-
/** Reject journal keys in generic writes without reading any payload values. */
|
|
16
|
-
export declare function rejectGenericIncidentJournalFields(payload: unknown): void;
|
|
17
39
|
/** Defense-in-depth normalization for the fixed incident journal modules. */
|
|
18
40
|
export declare function prepareIncidentJournalArguments(args: Readonly<Record<string, unknown>>): Readonly<{
|
|
19
41
|
sys_id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incident-journal-policy.d.ts","sourceRoot":"","sources":["../src/incident-journal-policy.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"incident-journal-policy.d.ts","sourceRoot":"","sources":["../src/incident-journal-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,+BAA+B,OAAQ,CAAC;AACrD,eAAO,MAAM,+BAA+B,QAAS,CAAC;AAEtD,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,YAAY,CAAC;AAQ7D;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEzD;AAYD,eAAO,MAAM,4BAA4B,aA0CtC,CAAC;AAEJ,qBAAa,0BAA2B,SAAQ,KAAK;IACnD;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,wBAAwB,GAAG,yBAAyB,CAAC;IACtE,QAAQ,CAAC,KAAK,CAAC,EAAE,oBAAoB,CAAC;gBAGpC,MAAM,EAAE,wBAAwB,GAAG,yBAAyB,EAC5D,KAAK,CAAC,EAAE,oBAAoB;CAS/B;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,0BAA0B,CAMrC;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,oBAAoB,EAC3B,IAAI,CAAC,EAAE,MAAM,GACZ,MAAM,CAYR;AAED,6EAA6E;AAC7E,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACtC,QAAQ,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAO/C"}
|
|
@@ -1,16 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
1
|
+
{"version":3,"file":"incident-journal-policy.js","sourceRoot":"","sources":["../src/incident-journal-policy.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAsBH,gDAEC;AA8ED,oEAQC;AAOD,0EAeC;AAGD,0EASC;AA9ID,6BAAwB;AAExB,2EAAoE;AAEvD,QAAA,+BAA+B,GAAG,KAAK,CAAC;AACxC,QAAA,+BAA+B,GAAG,MAAM,CAAC;AAItD,+EAA+E;AAC/E,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAuB;IAC7E,UAAU;IACV,YAAY;CACb,CAAC,CAAC;AAEH;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,KAAa;IAC9C,OAAO,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,aAAa,GACjB,MAAM,CAAC,MAAM,CAAC;IACZ,QAAQ,EAAE,yBAAyB;IACnC,UAAU,EAAE,2BAA2B;CACxC,CAAC,CAAC;AACL,MAAM,qCAAqC,GAAG,IAAI,OAAO,EAAU,CAAC;AACpE,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAC9C,MAAM,sBAAsB,GAC1B,0EAA0E,CAAC;AAEhE,QAAA,4BAA4B,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M,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"}
|
|
@@ -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 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-shape-limits.js","sourceRoot":"","sources":["../src/json-shape-limits.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;AA6DH,4CA+CC;AA1GD,uDAK2B;AAC3B,+DAAmE;AAEnE;;;;;;;;GAQG;AACU,QAAA,uBAAuB,GAClC,uCAAqB,GAAG,gDAA0B,GAAG,4CAA0B,CAAC;AAElF,mGAAmG;AACnG,MAAM,2BAA2B,GAAG,EAAE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 -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.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
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
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* still
|
|
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
|
|
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
|
|
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
|
|
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,33 @@ 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;
|
|
56
71
|
interface MetadataCacheEnvironment {
|
|
57
72
|
readonly SN_METADATA_CACHE_TTL_MS?: string;
|
|
58
73
|
readonly SN_METADATA_CACHE_TABLES?: string;
|
|
59
74
|
}
|
|
60
75
|
export declare function metadataCacheConfigFromEnvironment(environment?: MetadataCacheEnvironment): MetadataCacheConfigInput;
|
|
61
76
|
export declare function createMetadataCacheConfig(input: MetadataCacheConfigInput | undefined): MetadataCacheConfig;
|
|
77
|
+
/**
|
|
78
|
+
* The operations underneath a cached wrapper, or `operations` itself when it
|
|
79
|
+
* is not one.
|
|
80
|
+
*
|
|
81
|
+
* Use it for a read whose answer decides a write, such as the records a bulk
|
|
82
|
+
* update or delete targets. A cache hit can be stale within the watermark's
|
|
83
|
+
* documented gaps, which a read can tolerate but a write target cannot. The
|
|
84
|
+
* read costs one request, with no watermark, and leaves the cache untouched.
|
|
85
|
+
* The internal force-recache parameter is no substitute: it costs a watermark
|
|
86
|
+
* read as well, stores a single-use entry, and reaches ServiceNow unstripped
|
|
87
|
+
* when no wrapper is in place.
|
|
88
|
+
*/
|
|
89
|
+
export declare function uncachedOperations(operations: ServiceNowOperations): ServiceNowOperations;
|
|
62
90
|
/**
|
|
63
91
|
* @param scope Cache partition key. Must identify the ServiceNow instance
|
|
64
92
|
* *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
93
|
*/
|
|
69
|
-
export declare function createCachedServiceNowOperations(operations: ServiceNowOperations, scope: string, config: MetadataCacheConfigInput | undefined
|
|
94
|
+
export declare function createCachedServiceNowOperations(operations: ServiceNowOperations, scope: string, config: MetadataCacheConfigInput | undefined): ServiceNowOperations;
|
|
70
95
|
export {};
|
|
71
96
|
//# 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
|
|
1
|
+
{"version":3,"file":"metadata-cache.d.ts","sourceRoot":"","sources":["../src/metadata-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,E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