@onlyflows/servicenow-mcp 2.3.0-dev.1 → 2.3.0-dev.3
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/CHANGELOG.md +447 -3
- package/README.md +241 -11
- package/dist/call-metrics.d.ts +42 -0
- package/dist/call-metrics.d.ts.map +1 -0
- package/dist/call-metrics.js +89 -0
- package/dist/call-metrics.js.map +1 -0
- package/dist/client.d.ts +18 -14
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +51 -36
- package/dist/client.js.map +1 -1
- package/dist/code-search-snippet.d.ts +25 -0
- package/dist/code-search-snippet.d.ts.map +1 -0
- package/dist/code-search-snippet.js +67 -0
- package/dist/code-search-snippet.js.map +1 -0
- package/dist/code-search-targets.d.ts +66 -0
- package/dist/code-search-targets.d.ts.map +1 -0
- package/dist/code-search-targets.js +82 -0
- package/dist/code-search-targets.js.map +1 -0
- package/dist/encoded-query-policy.d.ts +9 -0
- package/dist/encoded-query-policy.d.ts.map +1 -1
- package/dist/encoded-query-policy.js +19 -1
- package/dist/encoded-query-policy.js.map +1 -1
- package/dist/field-policy.d.ts.map +1 -1
- package/dist/field-policy.js +17 -5
- package/dist/field-policy.js.map +1 -1
- package/dist/http-observability.js +1 -0
- package/dist/http-observability.js.map +1 -1
- package/dist/http-runtime.js +16 -0
- package/dist/http-runtime.js.map +1 -1
- package/dist/metadata-cache.d.ts +97 -7
- package/dist/metadata-cache.d.ts.map +1 -1
- package/dist/metadata-cache.js +284 -21
- package/dist/metadata-cache.js.map +1 -1
- package/dist/policy-card.js +1 -1
- package/dist/policy-card.js.map +1 -1
- package/dist/response-too-large.d.ts +23 -0
- package/dist/response-too-large.d.ts.map +1 -0
- package/dist/response-too-large.js +42 -0
- package/dist/response-too-large.js.map +1 -0
- package/dist/risky-grants.d.ts.map +1 -1
- package/dist/risky-grants.js +1 -0
- package/dist/risky-grants.js.map +1 -1
- package/dist/setup-prompts.js +1 -1
- package/dist/setup-prompts.js.map +1 -1
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +28 -4
- package/dist/setup.js.map +1 -1
- package/dist/structured-query.d.ts +61 -2
- package/dist/structured-query.d.ts.map +1 -1
- package/dist/structured-query.js +376 -35
- package/dist/structured-query.js.map +1 -1
- package/dist/table-policy.d.ts +42 -2
- package/dist/table-policy.d.ts.map +1 -1
- package/dist/table-policy.js +90 -6
- package/dist/table-policy.js.map +1 -1
- package/dist/tool-error.d.ts +40 -4
- package/dist/tool-error.d.ts.map +1 -1
- package/dist/tool-error.js +81 -4
- package/dist/tool-error.js.map +1 -1
- package/dist/tool-table-access.d.ts +9 -2
- package/dist/tool-table-access.d.ts.map +1 -1
- package/dist/tool-table-access.js +93 -30
- package/dist/tool-table-access.js.map +1 -1
- package/dist/tools/batch.d.ts.map +1 -1
- package/dist/tools/batch.js +21 -5
- package/dist/tools/batch.js.map +1 -1
- package/dist/tools/catalog.d.ts.map +1 -1
- package/dist/tools/catalog.js +2 -1
- package/dist/tools/catalog.js.map +1 -1
- package/dist/tools/codesearch.d.ts +2 -2
- package/dist/tools/codesearch.d.ts.map +1 -1
- package/dist/tools/codesearch.js +536 -67
- package/dist/tools/codesearch.js.map +1 -1
- package/dist/tools/flow-view-contracts.d.ts +2 -2
- package/dist/tools/flow-view-module.js +1 -1
- package/dist/tools/flow-view-module.js.map +1 -1
- package/dist/tools/get-module.js +1 -1
- package/dist/tools/get-module.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +37 -13
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/query-module.d.ts.map +1 -1
- package/dist/tools/query-module.js +230 -63
- package/dist/tools/query-module.js.map +1 -1
- package/dist/tools/result-envelope.d.ts +313 -2
- package/dist/tools/result-envelope.d.ts.map +1 -1
- package/dist/tools/result-envelope.js +334 -33
- package/dist/tools/result-envelope.js.map +1 -1
- package/dist/tools/schema-module.d.ts.map +1 -1
- package/dist/tools/schema-module.js +1 -1
- package/dist/tools/schema-module.js.map +1 -1
- package/dist/tools/truncation-hint.d.ts +125 -0
- package/dist/tools/truncation-hint.d.ts.map +1 -0
- package/dist/tools/truncation-hint.js +298 -0
- package/dist/tools/truncation-hint.js.map +1 -0
- package/dist/unknown-filter-fields.d.ts +52 -0
- package/dist/unknown-filter-fields.d.ts.map +1 -0
- package/dist/unknown-filter-fields.js +87 -0
- package/dist/unknown-filter-fields.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/CLIENT-SETUP.md +22 -1
- package/docs/PRODUCTION-SECURITY.md +21 -1
- package/docs/V2-MIGRATION.md +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
package/README.md
CHANGED
|
@@ -406,7 +406,7 @@ The resulting `~/.servicenow-mcp/config.json` looks like this. Note
|
|
|
406
406
|
"table": "incident",
|
|
407
407
|
"kind": "canonical",
|
|
408
408
|
"tools": [
|
|
409
|
-
"sn_query", "sn_get", "sn_aggregate", "sn_schema",
|
|
409
|
+
"sn_query", "sn_get", "sn_aggregate", "sn_schema", "sn_codesearch",
|
|
410
410
|
"sn_create", "sn_update",
|
|
411
411
|
"sn_incident_add_comment", "sn_incident_add_work_note"
|
|
412
412
|
],
|
|
@@ -416,7 +416,7 @@ The resulting `~/.servicenow-mcp/config.json` looks like this. Note
|
|
|
416
416
|
{
|
|
417
417
|
"table": "problem",
|
|
418
418
|
"kind": "canonical",
|
|
419
|
-
"tools": ["sn_query", "sn_get", "sn_aggregate", "sn_schema"],
|
|
419
|
+
"tools": ["sn_query", "sn_get", "sn_aggregate", "sn_schema", "sn_codesearch"],
|
|
420
420
|
"closureComplete": true,
|
|
421
421
|
"relatedTables": ["problem"]
|
|
422
422
|
}
|
|
@@ -563,7 +563,7 @@ For instances using Inbound Authentication Profiles with API keys. The header na
|
|
|
563
563
|
}
|
|
564
564
|
```
|
|
565
565
|
|
|
566
|
-
On a 401, the error explains the Basic Auth restriction program (KB3096078) and
|
|
566
|
+
On a 401 for a basic-auth profile, the error explains the Basic Auth restriction program (KB3096078): the role `snc_basic_auth_api_access` or a Web-Service-Access-Only account is needed, and OAuth is the recommended way to move off Basic Auth. The setup wizard gives the same explanation when it verifies the credential.
|
|
567
567
|
|
|
568
568
|
### Timeouts & retries
|
|
569
569
|
|
|
@@ -692,7 +692,7 @@ in this section is needed to use this server.
|
|
|
692
692
|
|
|
693
693
|
| Tool | Description |
|
|
694
694
|
|------|-------------|
|
|
695
|
-
| `sn_query` | Query an approved table with structured filters, field selection, pagination, and sorting; bounded raw reads require an explicit policy rule |
|
|
695
|
+
| `sn_query` | Query an approved table with structured filters, field selection, pagination, and sorting; bounded raw reads require an explicit policy rule. Paging runs on `has_more` and `next_offset`, which can end early if ServiceNow ACLs strip rows from a page; cross-check with `sn_aggregate` `COUNT`. A page cut to fit `max_response_bytes` keeps the same contract: see [Paging when a response is cut to size](#paging-when-a-response-is-cut-to-size) |
|
|
696
696
|
| `sn_get` | Get a single record by sys_id from an approved table |
|
|
697
697
|
| `sn_create` | Create a record on any table granted for writes, using only field-policy-approved writable fields, including the journal fields `comments` and `work_notes`; `incident` additionally requires a bounded `short_description` |
|
|
698
698
|
| `sn_update` | Update one record selected by exact `sys_id` on any table granted for writes, using only field-policy-approved writable fields; `comments` and `work_notes` append a journal entry |
|
|
@@ -716,7 +716,7 @@ in this section is needed to use this server.
|
|
|
716
716
|
| `sn_relationships` | CMDB CI graph traversal — upstream/downstream/both, configurable depth |
|
|
717
717
|
| `sn_attach` | List attachments, return downloads as inline base64, and upload inline base64 content; never touches a host filesystem path |
|
|
718
718
|
| `sn_syslog` | Query system logs with severity/source/time filters |
|
|
719
|
-
| `sn_codesearch` | Search business rules, script includes, client scripts, etc. |
|
|
719
|
+
| `sn_codesearch` | Search business rules, script includes, client scripts, etc., with a snippet around each match ([Code search](#code-search)). Part of the default read grant, so a plain read grant on a code table allows it |
|
|
720
720
|
| `sn_discover` | Discover tables, scoped apps, store apps, plugins |
|
|
721
721
|
|
|
722
722
|
### Testing & Automation
|
|
@@ -843,15 +843,102 @@ Two failure modes are worth knowing:
|
|
|
843
843
|
builds the request policy with only `allowedHosts` and `allowedOrigins`, so the
|
|
844
844
|
limit is always 1 MiB and no environment variable changes it.
|
|
845
845
|
|
|
846
|
+
### Code search
|
|
847
|
+
|
|
848
|
+
`sn_codesearch {search_term, table?, field?, limit?, offset?}` finds records
|
|
849
|
+
whose script contains the text, in the business rules, script includes, UI
|
|
850
|
+
scripts, client scripts, scripted REST operations, ES modules and ATF step
|
|
851
|
+
scripts of the instance. Each row
|
|
852
|
+
is `{table, table_label, sys_id, name, snippet, line}`: `snippet` is about 200
|
|
853
|
+
characters of the script centred on the first match (`...` marks a cut) and
|
|
854
|
+
`line` is the line that match is on. The comparison is the instance's
|
|
855
|
+
case-insensitive `LIKE`; if the text holds no literal match for the term, the
|
|
856
|
+
snippet is the head of the script and the row has no `line`.
|
|
857
|
+
|
|
858
|
+
- **One table or all.** With `table`, one table is searched (and `field` can
|
|
859
|
+
name another field of it, such as `name`). With none, every code table the
|
|
860
|
+
profile may read is searched, and the tables left out are named in a warning
|
|
861
|
+
(`Not searched, because this profile does not allow sn_codesearch to read
|
|
862
|
+
them: sys_script, sys_ws_operation. To include one, run servicenow-mcp-setup
|
|
863
|
+
grant --profile <profile> --read <table> --tools sn_codesearch.`). A table is
|
|
864
|
+
left out when the table policy does not bind `sn_codesearch` to it or the field
|
|
865
|
+
policy does not let the profile read its script field. The call fails only when
|
|
866
|
+
none can be read, and the error says why.
|
|
867
|
+
- **ES modules** are `sys_module`: the script is its `content` column and a row
|
|
868
|
+
is named by its `path`, because the table has no `name`. A profile reads it
|
|
869
|
+
once the table policy allows it: `servicenow-mcp-setup grant --profile dev
|
|
870
|
+
--read sys_module`, or a read wildcard. It is cached by default like the other
|
|
871
|
+
code tables, and `fields=all` reads `content`. A default `sn_query` of it lists
|
|
872
|
+
`sys_id`, `path` and `sys_updated_on`. `sys_module` is a built-in system table
|
|
873
|
+
(the 24th), so a `"*"` entry in the field policy does not narrow it: a profile
|
|
874
|
+
whose `"*"` entry limits `readable` and that can read `sys_module` now reads
|
|
875
|
+
`content`, where it did not before. To narrow it, name it in `fieldPolicy`
|
|
876
|
+
(`"sys_module": { "readable": ["sys_id", "path"] }`).
|
|
877
|
+
- **ATF step scripts** are searched with `table: "sys_atf_step"`. A step's script
|
|
878
|
+
is not a column of the step but the value of its script input, a row of
|
|
879
|
+
`sys_variable_value`. The search reads only the rows whose `document` is
|
|
880
|
+
`sys_atf_step` and whose `variable` ends with `script`, a condition fixed in
|
|
881
|
+
the server: no argument can widen it to another table's variables, and `field`
|
|
882
|
+
is refused. Each result is the step (`sys_id` is the step's), named
|
|
883
|
+
`<test name> > step <order>` where `order` is the step's own order value, and
|
|
884
|
+
the steps and then their tests are read by id to say so. Three tables are read,
|
|
885
|
+
so the profile needs read on `sys_variable_value`, `sys_atf_step` and
|
|
886
|
+
`sys_atf_test`, each bound to `sn_codesearch`:
|
|
887
|
+
`servicenow-mcp-setup grant --profile dev --read sys_variable_value,sys_atf_step,sys_atf_test`
|
|
888
|
+
(or `--tools sn_codesearch` to bind only this tool: `sys_variable_value` also
|
|
889
|
+
holds other tables' variable values, which that grant does not let this tool
|
|
890
|
+
search). `grant --atf` binds those tables to `sn_atf_author` only, so a profile
|
|
891
|
+
that has it adds this grant on top. A search with no `table` includes ATF
|
|
892
|
+
step scripts when all three are held and names `sys_atf_step` in the warning
|
|
893
|
+
when they are not. These tables are not in the default cache list: the reads go
|
|
894
|
+
straight to the instance.
|
|
895
|
+
- **A page is shared among the tables.** A search of several tables takes turns:
|
|
896
|
+
each table's first match (script includes first, then business rules, UI
|
|
897
|
+
scripts, client scripts, scripted REST operations, ES modules), then each
|
|
898
|
+
table's second,
|
|
899
|
+
and so on, each table in `sys_id` order. No table crowds the others off page
|
|
900
|
+
1, and the order depends only on the data, so `offset` and `next_offset` page
|
|
901
|
+
through it exactly. A table with few matches leaves its share to the others.
|
|
902
|
+
- **Large pages degrade, they do not fail.** A script can be hundreds of
|
|
903
|
+
kilobytes, so a page of them does not fit one response. A search of one table
|
|
904
|
+
with `limit` 49 or less reads the scripts with the rows, in one request (and
|
|
905
|
+
falls back to the two steps below if that page passes the cap). A larger page, or a search of several tables, first finds the rows without
|
|
906
|
+
their scripts and then reads the scripts of the rows it returns, 50 at a time,
|
|
907
|
+
narrowing a batch that is still too large. One search spends at most 12 such
|
|
908
|
+
requests and 8 MiB, and only for the rows one response can hold (about 280);
|
|
909
|
+
when that is spent, the remaining rows keep an empty `snippet` and a warning
|
|
910
|
+
says how many (lower `limit`). A script too large to read even on its own gives
|
|
911
|
+
its row an empty `snippet` and `note: "script too large to preview"`; read it
|
|
912
|
+
with `sn_get`. If the rows alone pass the response cap, the
|
|
913
|
+
error says the response was too large and to lower `limit` or `offset`.
|
|
914
|
+
- **The scripts are still field-policy readable fields.** The search reads the
|
|
915
|
+
identifier, the name and the searched field of each table, each subject to the
|
|
916
|
+
profile's field policy, and the sensitive-name rules apply to `field`.
|
|
917
|
+
|
|
846
918
|
### Metadata cache
|
|
847
919
|
|
|
848
920
|
Stable ServiceNow metadata reads are cached per instance and credential identity
|
|
849
921
|
for 24 hours by default. The default cached table patterns are
|
|
850
922
|
`sys_glide_object`, `sys_dictionary`, `sys_db_object`, `sys_app`, `sys_plugins`,
|
|
851
|
-
`sys_metadata*`,
|
|
923
|
+
`sys_metadata*`, `sys_flow*`, and the six code tables `sn_codesearch`
|
|
924
|
+
searches: `sys_script`, `sys_script_include`, `sys_ui_script`,
|
|
925
|
+
`sys_script_client`, `sys_ws_operation`, and `sys_module`. A repeated code search or
|
|
926
|
+
`sn_query` page on those tables is served from the cache while the table's
|
|
927
|
+
watermark is unchanged. Set `metadataCache.ttlMs` and
|
|
852
928
|
`metadataCache.tables` on a file-backed profile, or `SN_METADATA_CACHE_TTL_MS`
|
|
853
|
-
/ `SN_METADATA_CACHE_TABLES` for the explicit environment profile
|
|
854
|
-
|
|
929
|
+
/ `SN_METADATA_CACHE_TABLES` for the explicit environment profile; a table
|
|
930
|
+
list you set replaces the default list, so name the code tables in it to keep
|
|
931
|
+
caching them. `sn_query`, `sn_get`, and `sn_schema` accept `force_recache: true`
|
|
932
|
+
to refresh metadata; `sn_codesearch` has no such flag, so a change the
|
|
933
|
+
watermark cannot see shows there after at most one TTL. A cold `sn_get` of a
|
|
934
|
+
code-table record costs two requests (the watermark, then the record), and
|
|
935
|
+
`sn_batch` and `sn_aggregate` reads are never cached. Memory is bounded: a
|
|
936
|
+
response over 512 KiB is not cached, one credential scope keeps at most 32 MiB
|
|
937
|
+
and the whole cache 128 MiB, evicting the least recently used first. Cached
|
|
938
|
+
code-table entries hold full script bodies, which can contain hard-coded
|
|
939
|
+
credentials, in process memory (never on disk) for up to the TTL; to keep them
|
|
940
|
+
out, set `metadataCache.tables` or `SN_METADATA_CACHE_TABLES` to
|
|
941
|
+
`sys_glide_object,sys_dictionary,sys_db_object,sys_app,sys_plugins,sys_metadata*,sys_flow*`.
|
|
855
942
|
|
|
856
943
|
**Freshness is checked against the instance, in every auth mode.** Before each
|
|
857
944
|
fetch the cache reads a watermark in one small request: the table's row count
|
|
@@ -871,6 +958,45 @@ A tool call reads each table's watermark once, however many times it reads the
|
|
|
871
958
|
table, until the call writes. A hierarchy walk reads `sys_db_object` once for
|
|
872
959
|
the whole chain. An empty table caches like any other.
|
|
873
960
|
|
|
961
|
+
**Small responses are not cached.** A hit costs a round trip about the size of
|
|
962
|
+
a plain read, so a response under 32 KiB (serialized body) saves nothing and is
|
|
963
|
+
not kept. The first read of such a selector costs the watermark and the read,
|
|
964
|
+
as before; the server then remembers that selector as small, for one TTL, and
|
|
965
|
+
reads it again in a single request with no watermark. If a later read of it
|
|
966
|
+
comes back at 32 KiB or more, it is cached from the next read on. Large reads,
|
|
967
|
+
such as script bodies, are cached and checked exactly as above, and
|
|
968
|
+
`force_recache: true` still reads the watermark and refreshes. The memory is
|
|
969
|
+
per credential scope, holds at most 512 selectors (least recently used out),
|
|
970
|
+
and costs no cached bytes. A call that read a small selector this way reports
|
|
971
|
+
`miss`. On a table whose watermark is slow (`sys_dictionary` on a large
|
|
972
|
+
instance: about 0.5 s against a 0.1 to 0.2 s read in one measurement) even a
|
|
973
|
+
large read may be faster uncached; the threshold is a size, not a time. A
|
|
974
|
+
profile's `metadataCache.smallReadBytes` sets the threshold (0 caches every
|
|
975
|
+
response; at most 512 KiB).
|
|
976
|
+
|
|
977
|
+
**Seeing what the cache did.** Every successful response carries two optional
|
|
978
|
+
fields in `structuredContent.metadata`. `cache` says how the call's cacheable
|
|
979
|
+
reads were served: `hit` (all from the cache), `miss` (from ServiceNow: nothing
|
|
980
|
+
cached yet, the watermark moved, the entry expired, the table could not be
|
|
981
|
+
cached just then, or the response is small and not kept), `bypass` (a `force_recache: true` refresh), or `mixed` (the
|
|
982
|
+
call made several cacheable reads with different outcomes, such as an
|
|
983
|
+
`sn_codesearch` with no `table` over the code tables). It is absent when
|
|
984
|
+
the call read no cache-eligible table. `timing` is `{ total_ms, upstream_ms,
|
|
985
|
+
watermark_ms }` in whole milliseconds, measured wall-clock: `total_ms` is the
|
|
986
|
+
whole tool call; `upstream_ms` is the time during which at least one request to
|
|
987
|
+
ServiceNow other than a watermark read was in flight (retry waits included);
|
|
988
|
+
`watermark_ms` is the same for the cache's watermark reads. Overlapping
|
|
989
|
+
requests are counted once, not summed, so each figure is at most `total_ms`,
|
|
990
|
+
though the two can overlap each other and add up to more than it. A hit reports
|
|
991
|
+
`upstream_ms: 0` and the watermark round trip it still costs. Callers that
|
|
992
|
+
share a credential share cache warmth (several profiles on one credential, or
|
|
993
|
+
several HTTP clients on one profile), so `cache: "hit"` can reflect another
|
|
994
|
+
caller's earlier read made with the same credential. Both fields hold only
|
|
995
|
+
numbers and those four words, and appear whether or not the cache is on
|
|
996
|
+
(`timing` always, `cache` only when a cacheable read happened). Only the server
|
|
997
|
+
sets them; a tool cannot supply its own. Each tool's `outputSchema` grows by
|
|
998
|
+
about 320 characters for them.
|
|
999
|
+
|
|
874
1000
|
If a table's watermark cannot be used, its reads go straight upstream, without
|
|
875
1001
|
a watermark request, for a while: 15 minutes when the cause persists (an
|
|
876
1002
|
incomplete or future-dated watermark, a 403 or 404), 30 seconds when it may not
|
|
@@ -893,6 +1019,72 @@ identity, and effective policy, so a repeat call costs no request at all. They
|
|
|
893
1019
|
are not revalidated in that window; `force_recache: true` refreshes them, and
|
|
894
1020
|
`schemaCacheTtlMs` / `SN_SCHEMA_CACHE_TTL_MS` (up to 1 hour) changes the window.
|
|
895
1021
|
|
|
1022
|
+
### Paging when a response is cut to size
|
|
1023
|
+
|
|
1024
|
+
A read that does not fit `max_response_bytes` (or, for a result with more than
|
|
1025
|
+
1,000 rows, the record limit) is cut by dropping whole rows from the tail, so
|
|
1026
|
+
the rows that come back are always a prefix of the page you asked for. For the
|
|
1027
|
+
list tools, `has_more` and `next_offset` count the rows that were dropped:
|
|
1028
|
+
|
|
1029
|
+
| Field | Meaning |
|
|
1030
|
+
|-------|---------|
|
|
1031
|
+
| `record_count` | Rows in `results`. |
|
|
1032
|
+
| `truncated`, `dropped_records` | `sn_query` sets them when rows were dropped for size, and says how many; every list tool reports the same in `metadata.truncation`. |
|
|
1033
|
+
| `has_more` | True when rows were dropped for size **or** rows exist past the page: rows exist that this response did not contain. A response that came back empty because its rows were too large says `has_more: true`, not "no results". |
|
|
1034
|
+
| `next_offset` | `offset + record_count`: the first row not returned. Following it re-reads the dropped rows before anything later, so a client that only follows `next_offset` sees every row exactly once. |
|
|
1035
|
+
|
|
1036
|
+
When **no row fit**, there is nothing to continue after, so `next_offset` is
|
|
1037
|
+
left out and `metadata.pagination.recovery` is
|
|
1038
|
+
`adjust_request_and_retry_same_offset`: `has_more: true` with no `next_offset`
|
|
1039
|
+
means the request must change (fewer `fields`, a lower `limit`, or a higher
|
|
1040
|
+
`max_response_bytes`; `sn_get` reads one row). The `hint` says which.
|
|
1041
|
+
|
|
1042
|
+
This holds for `sn_query`, `sn_syslog`, `sn_schema`, `sn_relationships`,
|
|
1043
|
+
`sn_codesearch`, `sn_discover`, `sn_attach` (list) and `sn_atf`, whose `offset`
|
|
1044
|
+
is a row offset into the rows they return. Any other collection result that is cut to size
|
|
1045
|
+
(for example `sn_aggregate`) reports `has_more: true` with no `next_offset`.
|
|
1046
|
+
A page that lost no rows to size is unchanged: `has_more` and `next_offset`
|
|
1047
|
+
come from the row after the page, and `next_offset` is `offset + limit`.
|
|
1048
|
+
|
|
1049
|
+
A client that follows `next_offset` should also pass the `limit` the hint names
|
|
1050
|
+
(`continue offset=8 limit=8`): at the original `limit` each page asks
|
|
1051
|
+
ServiceNow for that many rows and the cut drops most of them again, so the same
|
|
1052
|
+
rows are fetched many times over.
|
|
1053
|
+
|
|
1054
|
+
Before this change `next_offset` after a cut page was `offset + limit`, which
|
|
1055
|
+
skipped the dropped rows, and a cut last page reported `has_more: false` with
|
|
1056
|
+
`record_count: 0`.
|
|
1057
|
+
|
|
1058
|
+
**The `sn_query` hint gives values you can use.** For example
|
|
1059
|
+
|
|
1060
|
+
```text
|
|
1061
|
+
Dropped 14/22; continue offset=8 limit=8; retry offset=0 with fields="sys_id,name" or max_response_bytes=1500 (fits the next row) or max_response_bytes=31500 (fits all 22).
|
|
1062
|
+
```
|
|
1063
|
+
|
|
1064
|
+
- `continue offset=8 limit=8` is `next_offset` and the number of rows that fit:
|
|
1065
|
+
page on with that `limit` and nothing is dropped again.
|
|
1066
|
+
- `retry offset=0 with ...` re-reads the whole page in one response, with fewer
|
|
1067
|
+
fields or a larger budget. The two budgets are different numbers, and each
|
|
1068
|
+
says what it buys. `max_response_bytes=1500 (fits the next row)` holds one
|
|
1069
|
+
more row than this response did, so a retry with it returns about one more
|
|
1070
|
+
row; `max_response_bytes=31500 (fits all 22)` holds every row of the page.
|
|
1071
|
+
Both are measured from the response itself (the rows plus the envelope's own
|
|
1072
|
+
metadata) and rounded up. The page figure is left out when it would be more
|
|
1073
|
+
than the 1,000,000-byte maximum (or the `maxResponseBytes` of the raw-read
|
|
1074
|
+
rule that approved a raw `query`, when that is lower) and when only one row
|
|
1075
|
+
was dropped, since the next row is then the rest of the page. When even the
|
|
1076
|
+
next row would be more than that maximum, the hint says the next row exceeds
|
|
1077
|
+
it, names it, and offers only fields and `sn_get`. It never names a budget
|
|
1078
|
+
the policy would deny.
|
|
1079
|
+
- `fields=...` appears when it helps: the table's short default list for a
|
|
1080
|
+
read of the defaults or of `all`, or your own list without its large fields
|
|
1081
|
+
(for example `script`) when you chose one. It only ever names fields your
|
|
1082
|
+
profile may read, and never a sensitive one. A list with nothing large in it
|
|
1083
|
+
gets the `limit` and the budget instead. `response_format="concise"` is
|
|
1084
|
+
offered to a `detailed` read.
|
|
1085
|
+
- When no row fit, there is no `continue` clause and no `limit`: only the
|
|
1086
|
+
retry options and `sn_get`.
|
|
1087
|
+
|
|
896
1088
|
### Unrestricted field selection (`fields=all`, `response_format=detailed`)
|
|
897
1089
|
|
|
898
1090
|
Both resolve to the profile's readable set for the table. Where the field
|
|
@@ -986,6 +1178,31 @@ servicenow-mcp-setup grant --profile dev --read change_request --related change_
|
|
|
986
1178
|
servicenow-mcp-setup grant --profile dev --flows # sn_flow_view's 15 tables, bound to sn_flow_view only
|
|
987
1179
|
```
|
|
988
1180
|
|
|
1181
|
+
A read grant without `--tools` binds `sn_query`, `sn_get`, `sn_aggregate`,
|
|
1182
|
+
`sn_schema` and `sn_codesearch` to each table it names. `sn_codesearch` is
|
|
1183
|
+
authorized per code table it searches (`sys_script`, `sys_script_include`,
|
|
1184
|
+
`sys_ui_script`, `sys_script_client`, `sys_ws_operation`, `sys_module`), so
|
|
1185
|
+
`servicenow-mcp-setup grant --profile dev --read sys_script_include` lets that
|
|
1186
|
+
profile search script includes. A search with no `table` searches the code tables
|
|
1187
|
+
the profile may read and names the others in a warning; it fails only when the
|
|
1188
|
+
profile may read none of them. On any other table the binding is inert. **A profile written before
|
|
1189
|
+
`sn_codesearch` was a default keeps the tool list it was saved with** and is not
|
|
1190
|
+
rewritten: re-run the same `grant --read <code table>` to add it, or pass
|
|
1191
|
+
`--tools sn_codesearch` to add only that tool. Neither removes a tool. The
|
|
1192
|
+
profile's field policy still decides the script field: `sn_codesearch` is
|
|
1193
|
+
denied on a code table whose script field is not readable, exactly as `sn_query`
|
|
1194
|
+
is for that field (in a search with no `table` that table is left out and named
|
|
1195
|
+
in the warning instead).
|
|
1196
|
+
|
|
1197
|
+
A call the table policy refuses says which table and which tool were refused, and
|
|
1198
|
+
whether the table is missing from the profile or only the tool is, and it gives
|
|
1199
|
+
the command that lifts it: `Table access was denied by policy: "sys_script_include"
|
|
1200
|
+
is granted to this profile, but not for sn_codesearch. To allow it, run:
|
|
1201
|
+
servicenow-mcp-setup grant --profile <profile> --read sys_script_include --tools
|
|
1202
|
+
sn_codesearch`. `--tools` adds to the tools a table already has, so that command
|
|
1203
|
+
removes nothing. The message names only the table and the tool of that call,
|
|
1204
|
+
never the rest of the profile's rules.
|
|
1205
|
+
|
|
989
1206
|
Allowlist entries may be exact table names or the literal `*` to allow every
|
|
990
1207
|
table for that operation. Table names are trimmed, lowercased, deduplicated,
|
|
991
1208
|
and must be valid ServiceNow identifiers.
|
|
@@ -1157,8 +1374,8 @@ The same policy in the list form:
|
|
|
1157
1374
|
`cmdb_ci_computer`, `kb_knowledge`.
|
|
1158
1375
|
- **Every table without a built-in entry:** `u_*` and `x_*` tables, and
|
|
1159
1376
|
platform tables such as `change_task` and `sys_properties`.
|
|
1160
|
-
- **The
|
|
1161
|
-
`sys_script_client`, `sys_ui_script`, `sys_ws_operation`, `sys_user`,
|
|
1377
|
+
- **The 24 system tables:** `sys_script`, `sys_script_include`,
|
|
1378
|
+
`sys_script_client`, `sys_ui_script`, `sys_ws_operation`, `sys_module`, `sys_user`,
|
|
1162
1379
|
`sys_user_group`, `sys_user_grmember`, `sys_db_object`, `sys_app`,
|
|
1163
1380
|
`sys_store_app`, `v_plugin`, `sys_atf_test`, `sys_atf_test_suite`,
|
|
1164
1381
|
`sys_atf_test_suite_test`, `sys_atf_test_result`, `sys_atf_step`,
|
|
@@ -1175,11 +1392,24 @@ projections, trimmed to the effective `readable` set.
|
|
|
1175
1392
|
A `"*"` entry never reaches a system table, named or not: each key comes from
|
|
1176
1393
|
the table's own entry, or else covers every field. The system tables include
|
|
1177
1394
|
the script tables (`sys_script`, `sys_script_include`, `sys_script_client`,
|
|
1178
|
-
`sys_ui_script`, `sys_ws_operation`), whose records hold server- or
|
|
1395
|
+
`sys_ui_script`, `sys_ws_operation`, `sys_module`), whose records hold server- or
|
|
1179
1396
|
client-side code, and the user and group tables (`sys_user`,
|
|
1180
1397
|
`sys_user_group`, `sys_user_grmember`). Name a system table to narrow it, and
|
|
1181
1398
|
grant it in `tableAccess` only deliberately.
|
|
1182
1399
|
|
|
1400
|
+
**Code tables list without their scripts.** A read of `sys_script`,
|
|
1401
|
+
`sys_script_include`, `sys_ui_script`, `sys_script_client` or `sys_ws_operation`
|
|
1402
|
+
that names no `fields` returns identifiers and metadata, not the script body, so
|
|
1403
|
+
a page of them is not cut short by a few large bodies. For `sys_script_include`
|
|
1404
|
+
that is `sys_id`, `name`, `api_name`, `active` and `sys_updated_on`; the others
|
|
1405
|
+
keep `sys_id`, `name`, `active`, `sys_updated_on` and what identifies them
|
|
1406
|
+
(`collection` and `when` for a business rule, `table` and `type` for a client
|
|
1407
|
+
script, `http_method` and `relative_path` for a scripted REST operation, `global`
|
|
1408
|
+
for a UI script). The body is one named field away, and `fields=all` and
|
|
1409
|
+
`response_format: "detailed"` still include it:
|
|
1410
|
+
`sn_query {table: "sys_script_include", fields: "sys_id,name,script"}`. A profile
|
|
1411
|
+
that states its own `defaults` for one of these tables keeps them.
|
|
1412
|
+
|
|
1183
1413
|
**Read-only profiles.** A `"*"` entry with `writable: []` does not make a
|
|
1184
1414
|
profile read-only, because it never reaches the system tables. To make a
|
|
1185
1415
|
profile read-only, grant no writes: `tableAccess.writeTables: []`, or
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What one tool call reports about itself: whether the metadata cache served
|
|
3
|
+
* its reads, and where its time went.
|
|
4
|
+
*
|
|
5
|
+
* One {@link CallMetrics} lives in the per-call request scope (see
|
|
6
|
+
* `runWithServiceNowRequestSignal`), so concurrent calls never share one and
|
|
7
|
+
* nothing is global. It only observes: no request, cache decision or policy
|
|
8
|
+
* reads from it. Everything it exposes is a number or one of four fixed
|
|
9
|
+
* strings; it never holds a host, path, parameter or response data.
|
|
10
|
+
*
|
|
11
|
+
* Timing is wall-clock, measured with `performance.now()`. `upstream_ms` and
|
|
12
|
+
* `watermark_ms` are not sums over requests: each is the time during which at
|
|
13
|
+
* least one request of that kind was in flight, so requests that run
|
|
14
|
+
* side by side count once. A figure can therefore never exceed `total_ms`,
|
|
15
|
+
* though the two kinds can overlap each other.
|
|
16
|
+
*
|
|
17
|
+
* @module call-metrics
|
|
18
|
+
*/
|
|
19
|
+
/** How one cacheable read was served. */
|
|
20
|
+
export type CacheOutcome = "hit" | "miss" | "bypass";
|
|
21
|
+
/** The call's cache status: one outcome, or `mixed` when reads differed. */
|
|
22
|
+
export type CacheStatus = CacheOutcome | "mixed";
|
|
23
|
+
/** Which kind of ServiceNow request is being timed. */
|
|
24
|
+
export type RequestLane = "upstream" | "watermark";
|
|
25
|
+
export interface CallTiming {
|
|
26
|
+
readonly total_ms: number;
|
|
27
|
+
readonly upstream_ms: number;
|
|
28
|
+
readonly watermark_ms: number;
|
|
29
|
+
}
|
|
30
|
+
export interface CallMetricsSnapshot {
|
|
31
|
+
/** Absent when the call made no cacheable read. */
|
|
32
|
+
readonly cache?: CacheStatus;
|
|
33
|
+
readonly timing: CallTiming;
|
|
34
|
+
}
|
|
35
|
+
export declare class CallMetrics {
|
|
36
|
+
#private;
|
|
37
|
+
recordCache(outcome: CacheOutcome): void;
|
|
38
|
+
/** Run one request, counting its time against `lane` whether it settles or throws. */
|
|
39
|
+
measure<T>(lane: RequestLane, request: () => Promise<T>): Promise<T>;
|
|
40
|
+
snapshot(): CallMetricsSnapshot;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=call-metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-metrics.d.ts","sourceRoot":"","sources":["../src/call-metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,yCAAyC;AACzC,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAErD,4EAA4E;AAC5E,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,OAAO,CAAC;AAEjD,uDAAuD;AACvD,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,WAAW,CAAC;AAEnD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B;AA4BD,qBAAa,WAAW;;IAQtB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAIxC,sFAAsF;IAChF,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAS1E,QAAQ,IAAI,mBAAmB;CAiBhC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What one tool call reports about itself: whether the metadata cache served
|
|
4
|
+
* its reads, and where its time went.
|
|
5
|
+
*
|
|
6
|
+
* One {@link CallMetrics} lives in the per-call request scope (see
|
|
7
|
+
* `runWithServiceNowRequestSignal`), so concurrent calls never share one and
|
|
8
|
+
* nothing is global. It only observes: no request, cache decision or policy
|
|
9
|
+
* reads from it. Everything it exposes is a number or one of four fixed
|
|
10
|
+
* strings; it never holds a host, path, parameter or response data.
|
|
11
|
+
*
|
|
12
|
+
* Timing is wall-clock, measured with `performance.now()`. `upstream_ms` and
|
|
13
|
+
* `watermark_ms` are not sums over requests: each is the time during which at
|
|
14
|
+
* least one request of that kind was in flight, so requests that run
|
|
15
|
+
* side by side count once. A figure can therefore never exceed `total_ms`,
|
|
16
|
+
* though the two kinds can overlap each other.
|
|
17
|
+
*
|
|
18
|
+
* @module call-metrics
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.CallMetrics = void 0;
|
|
22
|
+
/**
|
|
23
|
+
* Time during which at least one tracked request was in flight. A request
|
|
24
|
+
* entering while another is running does not restart the clock.
|
|
25
|
+
*/
|
|
26
|
+
class BusyClock {
|
|
27
|
+
#active = 0;
|
|
28
|
+
#busySince = 0;
|
|
29
|
+
#accumulated = 0;
|
|
30
|
+
enter() {
|
|
31
|
+
if (this.#active === 0)
|
|
32
|
+
this.#busySince = performance.now();
|
|
33
|
+
this.#active += 1;
|
|
34
|
+
let left = false;
|
|
35
|
+
return () => {
|
|
36
|
+
if (left)
|
|
37
|
+
return;
|
|
38
|
+
left = true;
|
|
39
|
+
this.#active -= 1;
|
|
40
|
+
if (this.#active === 0)
|
|
41
|
+
this.#accumulated += performance.now() - this.#busySince;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
read(now) {
|
|
45
|
+
return this.#accumulated + (this.#active > 0 ? now - this.#busySince : 0);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
class CallMetrics {
|
|
49
|
+
#startedAt = performance.now();
|
|
50
|
+
#outcomes = new Set();
|
|
51
|
+
#clocks = {
|
|
52
|
+
upstream: new BusyClock(),
|
|
53
|
+
watermark: new BusyClock(),
|
|
54
|
+
};
|
|
55
|
+
recordCache(outcome) {
|
|
56
|
+
this.#outcomes.add(outcome);
|
|
57
|
+
}
|
|
58
|
+
/** Run one request, counting its time against `lane` whether it settles or throws. */
|
|
59
|
+
async measure(lane, request) {
|
|
60
|
+
const leave = this.#clocks[lane].enter();
|
|
61
|
+
try {
|
|
62
|
+
return await request();
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
leave();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
snapshot() {
|
|
69
|
+
const now = performance.now();
|
|
70
|
+
const cache = this.#outcomes.size === 0
|
|
71
|
+
? undefined
|
|
72
|
+
: this.#outcomes.size === 1
|
|
73
|
+
? [...this.#outcomes][0]
|
|
74
|
+
: "mixed";
|
|
75
|
+
return {
|
|
76
|
+
...(cache === undefined ? {} : { cache }),
|
|
77
|
+
timing: {
|
|
78
|
+
total_ms: wholeMs(now - this.#startedAt),
|
|
79
|
+
upstream_ms: wholeMs(this.#clocks.upstream.read(now)),
|
|
80
|
+
watermark_ms: wholeMs(this.#clocks.watermark.read(now)),
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.CallMetrics = CallMetrics;
|
|
86
|
+
function wholeMs(value) {
|
|
87
|
+
return Number.isFinite(value) && value > 0 ? Math.round(value) : 0;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=call-metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-metrics.js","sourceRoot":"","sources":["../src/call-metrics.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAuBH;;;GAGG;AACH,MAAM,SAAS;IACb,OAAO,GAAG,CAAC,CAAC;IACZ,UAAU,GAAG,CAAC,CAAC;IACf,YAAY,GAAG,CAAC,CAAC;IAEjB,KAAK;QACH,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC;YAAE,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAC5D,IAAI,CAAC,OAAO,IAA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AAI,KAAK,CAAC;YACvB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC;gBACzB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBACxB,CAAC,CAAC,OAAO,CAAC;QAChB,OAAO;YACL,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;YACzC,MAAM,EAAE;gBACN,QAAQ,EAAE,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC;gBACxC,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACrD,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACxD;SACF,CAAC;IACJ,CAAC;CACF;AAvCD,kCAuCC;AAED,SAAS,OAAO,CAAC,KAAa;IAC5B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -17,8 +17,12 @@
|
|
|
17
17
|
* @module client
|
|
18
18
|
*/
|
|
19
19
|
import { type AtfFormInput } from "./atf-form.js";
|
|
20
|
+
import { CallMetrics, type CacheOutcome } from "./call-metrics.js";
|
|
20
21
|
import { ServiceNowConfig } from "./config.js";
|
|
21
22
|
import { AuthProvider } from "./auth.js";
|
|
23
|
+
import { BASIC_AUTH_401_HINT } from "./tool-error.js";
|
|
24
|
+
import { ServiceNowResponseTooLargeError, isServiceNowResponseTooLarge } from "./response-too-large.js";
|
|
25
|
+
export { ServiceNowResponseTooLargeError, isServiceNowResponseTooLarge };
|
|
22
26
|
/** @deprecated Inspect trusted tool-error provenance instead of raw fields. */
|
|
23
27
|
export type ServiceNowError = Error;
|
|
24
28
|
type ParsedJson = Awaited<ReturnType<Response["json"]>>;
|
|
@@ -70,14 +74,21 @@ export declare const MAX_CUMULATIVE_UPSTREAM_JSON_BYTES: number;
|
|
|
70
74
|
export declare const MAX_CUMULATIVE_RAW_RESPONSE_BYTES: number;
|
|
71
75
|
export declare const DEFAULT_MAX_JSON_RESPONSE_BYTES: number;
|
|
72
76
|
export declare const MAX_ERROR_RESPONSE_BYTES: number;
|
|
73
|
-
/** Guidance
|
|
74
|
-
export
|
|
77
|
+
/** Guidance carried by 401 errors on basic-auth profiles (fixed text). */
|
|
78
|
+
export { BASIC_AUTH_401_HINT };
|
|
75
79
|
export declare const DEFAULT_MAX_CONCURRENT_REQUESTS = 4;
|
|
76
80
|
/**
|
|
77
81
|
* Bind one immutable execution-context signal and fresh atomic upstream byte
|
|
78
82
|
* budgets to cached clients without adding mutable state to the client/cache.
|
|
79
83
|
*/
|
|
80
|
-
export declare function runWithServiceNowRequestSignal<T>(signal: AbortSignal, operation: () => Promise<T
|
|
84
|
+
export declare function runWithServiceNowRequestSignal<T>(signal: AbortSignal, operation: () => Promise<T>, metrics?: CallMetrics): Promise<T>;
|
|
85
|
+
/** Count the cache outcome of one cacheable read against the current call. */
|
|
86
|
+
export declare function recordCacheOutcome(outcome: CacheOutcome): void;
|
|
87
|
+
/**
|
|
88
|
+
* Run a cache freshness check so that its requests count as watermark time
|
|
89
|
+
* rather than upstream time. Outside a call scope it just runs.
|
|
90
|
+
*/
|
|
91
|
+
export declare function asWatermarkRead<T>(operation: () => Promise<T>): Promise<T>;
|
|
81
92
|
export declare class ServiceNowClient {
|
|
82
93
|
#private;
|
|
83
94
|
constructor(config: ServiceNowConfig, options?: ClientOptions);
|
|
@@ -133,18 +144,12 @@ export declare class ServiceNowClient {
|
|
|
133
144
|
private consumeErrorBody;
|
|
134
145
|
private buildHttpError;
|
|
135
146
|
}
|
|
136
|
-
/** Build an immutable, reflection-safe capability around a resolved client. */
|
|
137
|
-
export declare function createServiceNowOperations(client: ServiceNowOperations): ServiceNowOperations;
|
|
138
147
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
148
|
+
* Build an immutable, reflection-safe capability around a resolved client.
|
|
149
|
+
* Every request it makes is timed against the current call (see
|
|
150
|
+
* {@link CallMetrics}); the timing never alters, delays or retries a request.
|
|
142
151
|
*/
|
|
143
|
-
export declare
|
|
144
|
-
constructor(message: string);
|
|
145
|
-
}
|
|
146
|
-
/** True when a request failed because a response or its scope passed a byte limit. */
|
|
147
|
-
export declare function isServiceNowResponseTooLarge(error: unknown): boolean;
|
|
152
|
+
export declare function createServiceNowOperations(client: ServiceNowOperations): ServiceNowOperations;
|
|
148
153
|
/** True when a request failed because its caller cancelled it. */
|
|
149
154
|
export declare function isServiceNowRequestCancellation(error: unknown): boolean;
|
|
150
155
|
/**
|
|
@@ -159,5 +164,4 @@ export declare function parseRetryAfterMs(value: string | null): number | undefi
|
|
|
159
164
|
* MAX_RETRY_DELAY_MS either way.
|
|
160
165
|
*/
|
|
161
166
|
export declare function retryDelayMs(retryAfter: string | null, attempt: number, baseDelayMs: number): number;
|
|
162
|
-
export {};
|
|
163
167
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAsD,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAsD,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAEtG,OAAO,EA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