@onlyflows/servicenow-mcp 2.0.0 → 2.2.0-dev.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.
- package/CHANGELOG.md +85 -1
- package/README.md +5 -4
- package/dist/atf-config.d.ts +72 -0
- package/dist/atf-config.d.ts.map +1 -0
- package/dist/atf-config.js +179 -0
- package/dist/atf-config.js.map +1 -0
- package/dist/atf-policy.d.ts +46 -0
- package/dist/atf-policy.d.ts.map +1 -0
- package/dist/atf-policy.js +83 -0
- package/dist/atf-policy.js.map +1 -0
- package/dist/atf-result-cache.d.ts +104 -0
- package/dist/atf-result-cache.d.ts.map +1 -0
- package/dist/atf-result-cache.js +260 -0
- package/dist/atf-result-cache.js.map +1 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +15 -0
- package/dist/config.js.map +1 -1
- package/dist/execution-context.d.ts +7 -3
- package/dist/execution-context.d.ts.map +1 -1
- package/dist/execution-context.js +8 -2
- package/dist/execution-context.js.map +1 -1
- package/dist/field-policy.d.ts.map +1 -1
- package/dist/field-policy.js +42 -0
- package/dist/field-policy.js.map +1 -1
- package/dist/http-entrypoint.d.ts.map +1 -1
- package/dist/http-entrypoint.js +3 -0
- package/dist/http-entrypoint.js.map +1 -1
- package/dist/http-observability.js +10 -1
- package/dist/http-observability.js.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/profile-manager.d.ts +12 -0
- package/dist/profile-manager.d.ts.map +1 -1
- package/dist/profile-manager.js +30 -3
- package/dist/profile-manager.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 +11 -4
- package/dist/setup.js.map +1 -1
- package/dist/tools/atf-author-module.d.ts +35 -0
- package/dist/tools/atf-author-module.d.ts.map +1 -0
- package/dist/tools/atf-author-module.js +125 -0
- package/dist/tools/atf-author-module.js.map +1 -0
- package/dist/tools/atf.d.ts +2 -2
- package/dist/tools/catalog.d.ts +2 -2
- package/dist/tools/catalog.d.ts.map +1 -1
- package/dist/tools/catalog.js +2 -0
- package/dist/tools/catalog.js.map +1 -1
- package/dist/tools/create-module.d.ts.map +1 -1
- package/dist/tools/create-module.js +23 -19
- package/dist/tools/create-module.js.map +1 -1
- package/dist/tools/index.d.ts +3 -3
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +44 -9
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/markdown.d.ts +77 -0
- package/dist/tools/markdown.d.ts.map +1 -0
- package/dist/tools/markdown.js +279 -0
- package/dist/tools/markdown.js.map +1 -0
- package/dist/tools/nl.d.ts +2 -2
- package/dist/tools/record-write-shared.d.ts +7 -0
- package/dist/tools/record-write-shared.d.ts.map +1 -0
- package/dist/tools/{incident-write-shared.js → record-write-shared.js} +9 -8
- package/dist/tools/record-write-shared.js.map +1 -0
- package/dist/tools/result-envelope.d.ts +94 -16
- package/dist/tools/result-envelope.d.ts.map +1 -1
- package/dist/tools/result-envelope.js +92 -3
- package/dist/tools/result-envelope.js.map +1 -1
- package/dist/tools/tool-module.d.ts +11 -3
- package/dist/tools/tool-module.d.ts.map +1 -1
- package/dist/tools/tool-module.js +1 -0
- package/dist/tools/tool-module.js.map +1 -1
- package/dist/tools/update-module.d.ts.map +1 -1
- package/dist/tools/update-module.js +21 -17
- 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 +56 -0
- package/dist/write-value-policy.d.ts.map +1 -0
- package/dist/write-value-policy.js +310 -0
- package/dist/write-value-policy.js.map +1 -0
- package/docs/CLIENT-SETUP.md +2 -2
- package/docs/CONTAINER-DEPLOYMENT.md +11 -0
- package/docs/CROSS-CLIENT-RELEASE-MATRIX.md +1 -1
- package/docs/PROFILE-CREDENTIALS.md +63 -0
- package/docs/RELEASE-VALIDATION.md +29 -2
- package/docs/TESTING-OAUTH.md +1 -1
- package/package.json +2 -2
- package/scripts/release-validate.mjs +14 -4
- package/dist/incident-write-policy.d.ts +0 -20
- package/dist/incident-write-policy.d.ts.map +0 -1
- package/dist/incident-write-policy.js +0 -196
- package/dist/incident-write-policy.js.map +0 -1
- package/dist/tools/incident-write-shared.d.ts +0 -6
- package/dist/tools/incident-write-shared.d.ts.map +0 -1
- package/dist/tools/incident-write-shared.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,91 @@ All notable changes to this project are documented here.
|
|
|
5
5
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [2.0.
|
|
8
|
+
## [2.2.0-dev.1] — 2026-09-14
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Tag-driven dev prereleases publish to the npm `dev` channel while stable
|
|
13
|
+
releases continue to publish to `latest`.
|
|
14
|
+
|
|
15
|
+
- `sn_atf_author` creates tests, suites, and ordered suite memberships under
|
|
16
|
+
explicit table and field grants. Failed attempts return a structured rollback
|
|
17
|
+
report and identify uncertain inserts that require inspection before retrying.
|
|
18
|
+
- `setup grant --atf` binds the five ATF authoring tables to `sn_atf_author`
|
|
19
|
+
without enabling execution or script steps.
|
|
20
|
+
- Per-profile ATF configuration, opt-in execution-policy infrastructure, and
|
|
21
|
+
escaping-first readable tool renderers.
|
|
22
|
+
- An identity-bound ATF result-cache library with atomic writes, concurrent-writer
|
|
23
|
+
locking, bounded summaries, private storage and memory fallback. Execution and
|
|
24
|
+
results tools will connect to this library in a subsequent change.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- ATF suite-result table policy fields use `rolled_up_test_*`, matching the
|
|
29
|
+
platform fixtures rather than the CI/CD response spelling.
|
|
30
|
+
|
|
31
|
+
## [2.1.0] — 2026-09
|
|
32
|
+
|
|
33
|
+
> **Read this before upgrading if any profile grants `writeTables: ["*"]`, or
|
|
34
|
+
> names a table other than `incident`.** In 2.0.0 a hardcoded gate confined
|
|
35
|
+
> `sn_create` and `sn_update` to the `incident` table no matter what a profile
|
|
36
|
+
> granted, and the README documented them that way. That gate is gone: those
|
|
37
|
+
> tools now write any table the profile grants. If you granted a wide write
|
|
38
|
+
> allowlist while relying on the documented incident-only behaviour to keep
|
|
39
|
+
> single-record writes narrow, that assumption no longer holds — **review the
|
|
40
|
+
> `writeTables` allowlist and `targets` on every profile before upgrading.**
|
|
41
|
+
> This ships as a minor because the grant was always the operator's, and the
|
|
42
|
+
> gate was a defect that stopped it taking effect; the effective write surface
|
|
43
|
+
> can still widen without any configuration change on your side.
|
|
44
|
+
|
|
45
|
+
### Changed
|
|
46
|
+
|
|
47
|
+
- **`sn_create` and `sn_update` are no longer restricted to `incident`.** They
|
|
48
|
+
write to any table the profile grants, so the configured `tableAccess` and
|
|
49
|
+
field policies are now the only thing deciding which tables are writable —
|
|
50
|
+
the same boundary `sn_batch` and `sn_delete` already answered to. Previously
|
|
51
|
+
a hardcoded gate rejected every other table regardless of configuration,
|
|
52
|
+
which both blocked granted work and left the restriction unenforced on
|
|
53
|
+
`sn_batch`. **A profile granting `writeTables: ["*"]` (or naming other
|
|
54
|
+
tables) now permits single-record writes to those tables through
|
|
55
|
+
`sn_create`/`sn_update`; narrow the grant if that is wider than intended.**
|
|
56
|
+
`incident` keeps its bounded typed value policy (approved ordinary fields,
|
|
57
|
+
required `short_description` on create, range-checked `impact`/`urgency`/
|
|
58
|
+
`priority`/`state`); other tables get generic value bounds — scalar values
|
|
59
|
+
only, no control characters, at most 100,000 characters. The `sn_create`
|
|
60
|
+
result's `table` is now the table written rather than the literal
|
|
61
|
+
`"incident"`.
|
|
62
|
+
- **Policy denials are classified separately in errors and audit records.** A
|
|
63
|
+
bounded-value rejection is reported as such and audited as
|
|
64
|
+
`write_value_denied`, instead of being reported as "Table access was denied
|
|
65
|
+
by policy" and audited as `table_access_denied`. The previous message named
|
|
66
|
+
`tableAccess.writeTables` — a key that could not affect the outcome — and
|
|
67
|
+
sent operators to re-issue grants that were already correct. Structured HTTP
|
|
68
|
+
tool events also accept every policy-rejection reason now; previously any
|
|
69
|
+
reason other than `table_access_denied` threw while the event was built.
|
|
70
|
+
|
|
71
|
+
### Fixed
|
|
72
|
+
|
|
73
|
+
- A write denied by the bounded value policy was reported as
|
|
74
|
+
`ERROR: Table access was denied by policy.` — naming `tableAccess.writeTables`,
|
|
75
|
+
a per-profile key that was already correct and could not affect the outcome.
|
|
76
|
+
Operators re-issued grants against a restriction no configuration could lift.
|
|
77
|
+
Each failure reason now has its own message, and the four
|
|
78
|
+
reasons (`unsupported_table`, `missing_short_description`, `invalid_value`,
|
|
79
|
+
`invalid_mode`) are no longer flattened into one misleading string.
|
|
80
|
+
- The incident restriction was not a boundary: `sn_batch` reached the same
|
|
81
|
+
`PATCH /api/now/table/{table}/{sys_id}` endpoint for any table, on a bulk
|
|
82
|
+
surface, so the gate blocked the documented path while leaving the
|
|
83
|
+
undocumented one open. See **Changed** above for how this was resolved.
|
|
84
|
+
- Structured HTTP tool events accepted only `table_access_denied` for a policy
|
|
85
|
+
rejection. Any other reason — including the existing `field_access_denied` —
|
|
86
|
+
threw a `TypeError` while the event was being built.
|
|
87
|
+
- The 50,000-envelope validation gate asserted a single wall-clock reading
|
|
88
|
+
against a 1000ms ceiling, which measured CI runner load as much as this code
|
|
89
|
+
and failed at 1117ms while passing locally. It now takes the best of three
|
|
90
|
+
rounds against a ceiling set to catch an order-of-magnitude regression.
|
|
91
|
+
|
|
92
|
+
## [2.0.0] — 2026-09
|
|
9
93
|
|
|
10
94
|
2.0 is a local, single-owner stdio server. Your client spawns it and speaks
|
|
11
95
|
over that process's stdin and stdout; nothing listens on a port.
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<!-- Logo placeholder -->
|
|
4
4
|
<!--  -->
|
|
5
5
|
|
|
6
|
-
**The most comprehensive ServiceNow MCP server.**
|
|
6
|
+
**The most comprehensive ServiceNow MCP server.** 20 tools for full CRUD, append-only incident journals, CMDB graph traversal, ATF testing, multi-instance profiles, and more.
|
|
7
7
|
|
|
8
8
|
Built by [OnlyFlows](https://onlyflows.tech) · Published by [@onlyflowstech](https://github.com/onlyflowstech)
|
|
9
9
|
|
|
@@ -496,7 +496,7 @@ deny-by-default table and tool policy:
|
|
|
496
496
|
| Natural language interface | ❌ | 🚧 currently policy-denied pending a typed access plan |
|
|
497
497
|
| Background scripts | ❌ | 🚧 on the [roadmap](#roadmap) (SNS-39) |
|
|
498
498
|
| Multi-instance profiles | ❌ | ✅ (named profiles, per-call override) |
|
|
499
|
-
| **Total tools** | **1–3** | **
|
|
499
|
+
| **Total tools** | **1–3** | **20** |
|
|
500
500
|
|
|
501
501
|
---
|
|
502
502
|
|
|
@@ -596,8 +596,8 @@ in this section is needed to use this server.
|
|
|
596
596
|
|------|-------------|
|
|
597
597
|
| `sn_query` | Query an approved table with structured filters, field selection, pagination, and sorting; bounded raw reads require an explicit policy rule |
|
|
598
598
|
| `sn_get` | Get a single record by sys_id from an approved table |
|
|
599
|
-
| `sn_create` | Create
|
|
600
|
-
| `sn_update` | Update one
|
|
599
|
+
| `sn_create` | Create a record on any table granted for writes, using only field-policy-approved writable fields; `incident` additionally requires a bounded `short_description` |
|
|
600
|
+
| `sn_update` | Update one record selected by exact `sys_id` on any table granted for writes, using only field-policy-approved writable fields; rejects `comments` and `work_notes` with dedicated-tool migration guidance |
|
|
601
601
|
| `sn_incident_add_comment` | Append one bounded customer-visible comment to an incident; repeated calls append again |
|
|
602
602
|
| `sn_incident_add_work_note` | Append one bounded internal work note to an incident; repeated calls append again |
|
|
603
603
|
| `sn_delete` | Delete a record on an approved write table (requires `confirm: true`) |
|
|
@@ -625,6 +625,7 @@ in this section is needed to use this server.
|
|
|
625
625
|
|
|
626
626
|
| Tool | Description |
|
|
627
627
|
|------|-------------|
|
|
628
|
+
| `sn_atf_author` | Create tests/suites and ordered suite memberships with explicit write grants |
|
|
628
629
|
| `sn_atf` | List ATF tests/suites and get results; `run`/`run-suite` currently fail closed |
|
|
629
630
|
| `sn_nl` | Currently fails closed until natural-language composition emits a complete typed access plan |
|
|
630
631
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-profile Automated Test Framework (ATF) settings.
|
|
3
|
+
*
|
|
4
|
+
* Two kinds of setting live here, and they are resolved differently:
|
|
5
|
+
*
|
|
6
|
+
* - Grants (`execute`, `allowScriptSteps`) widen what a caller may make the
|
|
7
|
+
* instance do. Like `tableAccess`, they come only from the profile itself;
|
|
8
|
+
* the SN_ATF_* environment variables supply them solely to the explicitly
|
|
9
|
+
* named environment-only profile. A process-wide variable never grants ATF
|
|
10
|
+
* execution to every profile in config.json.
|
|
11
|
+
* - Result-cache settings (`resultCacheSize`, `resultCacheDir`) are ordinary
|
|
12
|
+
* tuning. Like `metadataCache`, the profile value wins and the environment
|
|
13
|
+
* is the fallback for every profile.
|
|
14
|
+
*
|
|
15
|
+
* Every error message names the offending key and never echoes its value.
|
|
16
|
+
*
|
|
17
|
+
* @module atf-config
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEFAULT_ATF_RESULT_CACHE_SIZE = 10;
|
|
20
|
+
export declare const MAX_ATF_RESULT_CACHE_SIZE = 100;
|
|
21
|
+
/** The `atf` block as written in a profile or read from the environment. */
|
|
22
|
+
export interface AtfConfigInput {
|
|
23
|
+
/** Permit ATF execution tools to run suites (default false). */
|
|
24
|
+
readonly execute?: boolean;
|
|
25
|
+
/** Runs retained per suite in the local result cache (1-100, default 10). */
|
|
26
|
+
readonly resultCacheSize?: number;
|
|
27
|
+
/** Absolute directory for the local result cache (default chosen by the cache). */
|
|
28
|
+
readonly resultCacheDir?: string;
|
|
29
|
+
/** Permit authoring ATF steps that run server-side script (default false). */
|
|
30
|
+
readonly allowScriptSteps?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** Fully resolved, frozen ATF settings for one profile. */
|
|
33
|
+
export interface AtfConfig {
|
|
34
|
+
readonly execute: boolean;
|
|
35
|
+
readonly allowScriptSteps: boolean;
|
|
36
|
+
readonly resultCacheSize: number;
|
|
37
|
+
readonly resultCacheDir?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The non-secret slice a tool handler receives. Execution grants are not here:
|
|
41
|
+
* they are enforced before the handler runs, from the resolved policy.
|
|
42
|
+
*/
|
|
43
|
+
export interface AtfHandlerSettings {
|
|
44
|
+
readonly resultCacheSize: number;
|
|
45
|
+
readonly resultCacheDir?: string;
|
|
46
|
+
}
|
|
47
|
+
/** Operator-authored configuration error; the message is safe to display. */
|
|
48
|
+
export declare class AtfConfigurationError extends Error {
|
|
49
|
+
readonly name = "AtfConfigurationError";
|
|
50
|
+
}
|
|
51
|
+
interface AtfEnvironment {
|
|
52
|
+
readonly SN_ATF_EXECUTE?: string;
|
|
53
|
+
readonly SN_ATF_RESULT_CACHE_SIZE?: string;
|
|
54
|
+
readonly SN_ATF_RESULT_CACHE_DIR?: string;
|
|
55
|
+
readonly SN_ATF_ALLOW_SCRIPT_STEPS?: string;
|
|
56
|
+
}
|
|
57
|
+
/** Read the SN_ATF_* variables, keeping only the keys that are set. */
|
|
58
|
+
export declare function atfConfigFromEnvironment(environment?: AtfEnvironment): AtfConfigInput;
|
|
59
|
+
/**
|
|
60
|
+
* Validate a profile's `atf` block and return a frozen copy holding only the
|
|
61
|
+
* keys it states. Throws AtfConfigurationError on any unsupported shape.
|
|
62
|
+
*/
|
|
63
|
+
export declare function validateAtfConfigInput(candidate: unknown): AtfConfigInput;
|
|
64
|
+
/**
|
|
65
|
+
* Merge a profile's `atf` block with the environment. Grants come from the
|
|
66
|
+
* profile alone; cache settings fall back to the environment, then defaults.
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveAtfConfig(profile: AtfConfigInput | undefined, environment: AtfConfigInput): AtfConfig;
|
|
69
|
+
/** Project resolved settings onto what a handler may see. */
|
|
70
|
+
export declare function atfHandlerSettings(config: AtfConfig | undefined): AtfHandlerSettings;
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=atf-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atf-config.d.ts","sourceRoot":"","sources":["../src/atf-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAChD,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAU7C,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,6EAA6E;IAC7E,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,mFAAmF;IACnF,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,8EAA8E;IAC9E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED,2DAA2D;AAC3D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,6EAA6E;AAC7E,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,SAAyB,IAAI,2BAA2B;CACzD;AAED,UAAU,cAAc;IACtB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAC3C,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAC1C,QAAQ,CAAC,yBAAyB,CAAC,EAAE,MAAM,CAAC;CAC7C;AAED,uEAAuE;AACvE,wBAAgB,wBAAwB,CACtC,WAAW,GAAE,cAA8C,GAC1D,cAAc,CAsBhB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,OAAO,GAAG,cAAc,CA4CzE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,WAAW,EAAE,cAAc,GAC1B,SAAS,CAWX;AAED,6DAA6D;AAC7D,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,GAAG,SAAS,GAC5B,kBAAkB,CAOpB"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Per-profile Automated Test Framework (ATF) settings.
|
|
4
|
+
*
|
|
5
|
+
* Two kinds of setting live here, and they are resolved differently:
|
|
6
|
+
*
|
|
7
|
+
* - Grants (`execute`, `allowScriptSteps`) widen what a caller may make the
|
|
8
|
+
* instance do. Like `tableAccess`, they come only from the profile itself;
|
|
9
|
+
* the SN_ATF_* environment variables supply them solely to the explicitly
|
|
10
|
+
* named environment-only profile. A process-wide variable never grants ATF
|
|
11
|
+
* execution to every profile in config.json.
|
|
12
|
+
* - Result-cache settings (`resultCacheSize`, `resultCacheDir`) are ordinary
|
|
13
|
+
* tuning. Like `metadataCache`, the profile value wins and the environment
|
|
14
|
+
* is the fallback for every profile.
|
|
15
|
+
*
|
|
16
|
+
* Every error message names the offending key and never echoes its value.
|
|
17
|
+
*
|
|
18
|
+
* @module atf-config
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
}) : (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
}));
|
|
31
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
32
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
33
|
+
}) : function(o, v) {
|
|
34
|
+
o["default"] = v;
|
|
35
|
+
});
|
|
36
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
37
|
+
var ownKeys = function(o) {
|
|
38
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
39
|
+
var ar = [];
|
|
40
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
41
|
+
return ar;
|
|
42
|
+
};
|
|
43
|
+
return ownKeys(o);
|
|
44
|
+
};
|
|
45
|
+
return function (mod) {
|
|
46
|
+
if (mod && mod.__esModule) return mod;
|
|
47
|
+
var result = {};
|
|
48
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
49
|
+
__setModuleDefault(result, mod);
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
})();
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.AtfConfigurationError = exports.MAX_ATF_RESULT_CACHE_SIZE = exports.DEFAULT_ATF_RESULT_CACHE_SIZE = void 0;
|
|
55
|
+
exports.atfConfigFromEnvironment = atfConfigFromEnvironment;
|
|
56
|
+
exports.validateAtfConfigInput = validateAtfConfigInput;
|
|
57
|
+
exports.resolveAtfConfig = resolveAtfConfig;
|
|
58
|
+
exports.atfHandlerSettings = atfHandlerSettings;
|
|
59
|
+
const path = __importStar(require("path"));
|
|
60
|
+
const config_js_1 = require("./config.js");
|
|
61
|
+
exports.DEFAULT_ATF_RESULT_CACHE_SIZE = 10;
|
|
62
|
+
exports.MAX_ATF_RESULT_CACHE_SIZE = 100;
|
|
63
|
+
const MAX_ATF_RESULT_CACHE_DIR_LENGTH = 1024;
|
|
64
|
+
const CONTROL_CHARACTER = /[\u0000-\u001F\u007F]/u;
|
|
65
|
+
const ATF_CONFIG_KEYS = Object.freeze([
|
|
66
|
+
"execute",
|
|
67
|
+
"resultCacheSize",
|
|
68
|
+
"resultCacheDir",
|
|
69
|
+
"allowScriptSteps",
|
|
70
|
+
]);
|
|
71
|
+
/** Operator-authored configuration error; the message is safe to display. */
|
|
72
|
+
class AtfConfigurationError extends Error {
|
|
73
|
+
name = "AtfConfigurationError";
|
|
74
|
+
}
|
|
75
|
+
exports.AtfConfigurationError = AtfConfigurationError;
|
|
76
|
+
/** Read the SN_ATF_* variables, keeping only the keys that are set. */
|
|
77
|
+
function atfConfigFromEnvironment(environment = process.env) {
|
|
78
|
+
const execute = (0, config_js_1.parseBooleanEnv)(environment.SN_ATF_EXECUTE, "SN_ATF_EXECUTE");
|
|
79
|
+
const allowScriptSteps = (0, config_js_1.parseBooleanEnv)(environment.SN_ATF_ALLOW_SCRIPT_STEPS, "SN_ATF_ALLOW_SCRIPT_STEPS");
|
|
80
|
+
const resultCacheSize = (0, config_js_1.parsePositiveIntegerEnv)(environment.SN_ATF_RESULT_CACHE_SIZE, "SN_ATF_RESULT_CACHE_SIZE", { max: exports.MAX_ATF_RESULT_CACHE_SIZE });
|
|
81
|
+
const rawDirectory = environment.SN_ATF_RESULT_CACHE_DIR;
|
|
82
|
+
const resultCacheDir = rawDirectory === undefined || rawDirectory.trim() === ""
|
|
83
|
+
? undefined
|
|
84
|
+
: validateResultCacheDir(rawDirectory, "SN_ATF_RESULT_CACHE_DIR");
|
|
85
|
+
return Object.freeze({
|
|
86
|
+
...(execute === undefined ? {} : { execute }),
|
|
87
|
+
...(resultCacheSize === undefined ? {} : { resultCacheSize }),
|
|
88
|
+
...(resultCacheDir === undefined ? {} : { resultCacheDir }),
|
|
89
|
+
...(allowScriptSteps === undefined ? {} : { allowScriptSteps }),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Validate a profile's `atf` block and return a frozen copy holding only the
|
|
94
|
+
* keys it states. Throws AtfConfigurationError on any unsupported shape.
|
|
95
|
+
*/
|
|
96
|
+
function validateAtfConfigInput(candidate) {
|
|
97
|
+
if (typeof candidate !== "object" ||
|
|
98
|
+
candidate === null ||
|
|
99
|
+
Array.isArray(candidate)) {
|
|
100
|
+
throw new AtfConfigurationError("atf must be an object");
|
|
101
|
+
}
|
|
102
|
+
const source = candidate;
|
|
103
|
+
for (const key of Object.keys(source)) {
|
|
104
|
+
if (!ATF_CONFIG_KEYS.includes(key)) {
|
|
105
|
+
throw new AtfConfigurationError(`atf supports only ${ATF_CONFIG_KEYS.join(", ")}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const { execute, resultCacheSize, resultCacheDir, allowScriptSteps } = source;
|
|
109
|
+
if (execute !== undefined && typeof execute !== "boolean") {
|
|
110
|
+
throw new AtfConfigurationError("atf.execute must be true or false");
|
|
111
|
+
}
|
|
112
|
+
if (allowScriptSteps !== undefined && typeof allowScriptSteps !== "boolean") {
|
|
113
|
+
throw new AtfConfigurationError("atf.allowScriptSteps must be true or false");
|
|
114
|
+
}
|
|
115
|
+
if (resultCacheSize !== undefined &&
|
|
116
|
+
(typeof resultCacheSize !== "number" ||
|
|
117
|
+
!Number.isSafeInteger(resultCacheSize) ||
|
|
118
|
+
resultCacheSize < 1 ||
|
|
119
|
+
resultCacheSize > exports.MAX_ATF_RESULT_CACHE_SIZE)) {
|
|
120
|
+
throw new AtfConfigurationError(`atf.resultCacheSize must be an integer between 1 and ${exports.MAX_ATF_RESULT_CACHE_SIZE}`);
|
|
121
|
+
}
|
|
122
|
+
const directory = resultCacheDir === undefined
|
|
123
|
+
? undefined
|
|
124
|
+
: validateResultCacheDir(resultCacheDir, "atf.resultCacheDir");
|
|
125
|
+
return Object.freeze({
|
|
126
|
+
...(execute === undefined ? {} : { execute }),
|
|
127
|
+
...(resultCacheSize === undefined ? {} : { resultCacheSize }),
|
|
128
|
+
...(directory === undefined ? {} : { resultCacheDir: directory }),
|
|
129
|
+
...(allowScriptSteps === undefined ? {} : { allowScriptSteps }),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Merge a profile's `atf` block with the environment. Grants come from the
|
|
134
|
+
* profile alone; cache settings fall back to the environment, then defaults.
|
|
135
|
+
*/
|
|
136
|
+
function resolveAtfConfig(profile, environment) {
|
|
137
|
+
const resultCacheDir = profile?.resultCacheDir ?? environment.resultCacheDir;
|
|
138
|
+
return Object.freeze({
|
|
139
|
+
execute: profile?.execute === true,
|
|
140
|
+
allowScriptSteps: profile?.allowScriptSteps === true,
|
|
141
|
+
resultCacheSize: profile?.resultCacheSize ??
|
|
142
|
+
environment.resultCacheSize ??
|
|
143
|
+
exports.DEFAULT_ATF_RESULT_CACHE_SIZE,
|
|
144
|
+
...(resultCacheDir === undefined ? {} : { resultCacheDir }),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/** Project resolved settings onto what a handler may see. */
|
|
148
|
+
function atfHandlerSettings(config) {
|
|
149
|
+
return Object.freeze({
|
|
150
|
+
resultCacheSize: config?.resultCacheSize ?? exports.DEFAULT_ATF_RESULT_CACHE_SIZE,
|
|
151
|
+
...(config?.resultCacheDir === undefined
|
|
152
|
+
? {}
|
|
153
|
+
: { resultCacheDir: config.resultCacheDir }),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Accept only an absolute, normalized directory. The cache opens it later
|
|
158
|
+
* with its own no-symlink checks; this rejects values that are wrong on their
|
|
159
|
+
* face so a typo fails when the profile loads, not on the first ATF run.
|
|
160
|
+
*/
|
|
161
|
+
function validateResultCacheDir(value, label) {
|
|
162
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
163
|
+
throw new AtfConfigurationError(`${label} must be a non-empty string`);
|
|
164
|
+
}
|
|
165
|
+
if (value.length > MAX_ATF_RESULT_CACHE_DIR_LENGTH) {
|
|
166
|
+
throw new AtfConfigurationError(`${label} must not exceed ${MAX_ATF_RESULT_CACHE_DIR_LENGTH} characters`);
|
|
167
|
+
}
|
|
168
|
+
if (CONTROL_CHARACTER.test(value)) {
|
|
169
|
+
throw new AtfConfigurationError(`${label} must not contain control characters`);
|
|
170
|
+
}
|
|
171
|
+
if (!path.isAbsolute(value)) {
|
|
172
|
+
throw new AtfConfigurationError(`${label} must be an absolute path`);
|
|
173
|
+
}
|
|
174
|
+
if (value.split(/[\\/]/u).includes("..")) {
|
|
175
|
+
throw new AtfConfigurationError(`${label} must not contain ".." segments`);
|
|
176
|
+
}
|
|
177
|
+
return value;
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=atf-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atf-config.js","sourceRoot":"","sources":["../src/atf-config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DH,4DAwBC;AAMD,wDA4CC;AAMD,4CAcC;AAGD,gDASC;AAnKD,2CAA6B;AAE7B,2CAAuE;AAE1D,QAAA,6BAA6B,GAAG,EAAE,CAAC;AACnC,QAAA,yBAAyB,GAAG,GAAG,CAAC;AAC7C,MAAM,+BAA+B,GAAG,IAAI,CAAC;AAC7C,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AACnD,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IACpC,SAAS;IACT,iBAAiB;IACjB,gBAAgB;IAChB,kBAAkB;CACV,CAAC,CAAC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AAE,MAAM,CAAC,cAAc,EAAE,CAAC;KAC/C,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,SAAS,sBAAsB,CAAC,KAAc,EAAE,KAAa;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,qBAAqB,CAAC,GAAG,KAAK,6BAA6B,CAAC,CAAC;IACzE,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,+BAA+B,EAAE,CAAC;QACnD,MAAM,IAAI,qBAAqB,CAC7B,GAAG,KAAK,oBAAoB,+BAA+B,aAAa,CACzE,CAAC;IACJ,CAAC;IACD,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,qBAAqB,CAAC,GAAG,KAAK,sCAAsC,CAAC,CAAC;IAClF,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,qBAAqB,CAAC,GAAG,KAAK,2BAA2B,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,qBAAqB,CAAC,GAAG,KAAK,iCAAiC,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ATF execution grant carried on the resolved effective policy, and the
|
|
3
|
+
* classified denial a tool raises from its access resolver when the profile
|
|
4
|
+
* withholds that grant.
|
|
5
|
+
*
|
|
6
|
+
* Running an ATF suite executes its steps on the instance, and a step can
|
|
7
|
+
* change any table the test touches. No table-only plan can describe that
|
|
8
|
+
* side effect, so execution is its own opt-in: omission denies it.
|
|
9
|
+
*
|
|
10
|
+
* @module atf-policy
|
|
11
|
+
*/
|
|
12
|
+
import type { ResolvedEffectivePolicyReference } from "./execution-context.js";
|
|
13
|
+
/** The ATF slice an EffectivePolicyProvider may state. */
|
|
14
|
+
export interface AtfExecutionPolicyInput {
|
|
15
|
+
readonly execute?: boolean;
|
|
16
|
+
readonly allowScriptSteps?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Normalized, frozen ATF grants on a resolved policy. */
|
|
19
|
+
export interface AtfExecutionPolicy {
|
|
20
|
+
readonly execute: boolean;
|
|
21
|
+
readonly allowScriptSteps: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const DENY_ALL_ATF_EXECUTION: AtfExecutionPolicy;
|
|
24
|
+
/**
|
|
25
|
+
* Normalize a provider-supplied ATF policy. Each property is read once, and
|
|
26
|
+
* anything other than an explicit boolean `true` leaves the grant off. A
|
|
27
|
+
* non-boolean value is a provider defect, so it fails context creation.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createAtfExecutionPolicy(candidate: AtfExecutionPolicyInput | undefined): AtfExecutionPolicy;
|
|
30
|
+
export type AtfPolicyFailureReason = "execution_not_enabled";
|
|
31
|
+
export declare class AtfPolicyError extends Error {
|
|
32
|
+
readonly reason: AtfPolicyFailureReason;
|
|
33
|
+
constructor(reason: AtfPolicyFailureReason);
|
|
34
|
+
}
|
|
35
|
+
export declare function isAtfPolicyError(error: unknown): error is AtfPolicyError;
|
|
36
|
+
/**
|
|
37
|
+
* Fixed operator guidance. It names the configuration key that grants the
|
|
38
|
+
* operation, and keeps the "denied by policy" phrase other denials share.
|
|
39
|
+
*/
|
|
40
|
+
export declare function atfPolicyDenialMessage(_error: AtfPolicyError, tool?: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Call from a module's resolveAccess before returning its plan, so a profile
|
|
43
|
+
* without the grant is rejected before any configuration or client exists.
|
|
44
|
+
*/
|
|
45
|
+
export declare function requireAtfExecution(policy: Pick<ResolvedEffectivePolicyReference, "atf">): void;
|
|
46
|
+
//# sourceMappingURL=atf-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atf-policy.d.ts","sourceRoot":"","sources":["../src/atf-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAE/E,0DAA0D;AAC1D,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED,0DAA0D;AAC1D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC;AAED,eAAO,MAAM,sBAAsB,EAAE,kBAGnC,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,uBAAuB,GAAG,SAAS,GAC7C,kBAAkB,CAiBpB;AAED,MAAM,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAI7D,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;gBAE5B,MAAM,EAAE,sBAAsB;CAO3C;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAMxE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,cAAc,EACtB,IAAI,CAAC,EAAE,MAAM,GACZ,MAAM,CAUR;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,IAAI,CAAC,gCAAgC,EAAE,KAAK,CAAC,GACpD,IAAI,CAIN"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ATF execution grant carried on the resolved effective policy, and the
|
|
4
|
+
* classified denial a tool raises from its access resolver when the profile
|
|
5
|
+
* withholds that grant.
|
|
6
|
+
*
|
|
7
|
+
* Running an ATF suite executes its steps on the instance, and a step can
|
|
8
|
+
* change any table the test touches. No table-only plan can describe that
|
|
9
|
+
* side effect, so execution is its own opt-in: omission denies it.
|
|
10
|
+
*
|
|
11
|
+
* @module atf-policy
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.AtfPolicyError = exports.DENY_ALL_ATF_EXECUTION = void 0;
|
|
15
|
+
exports.createAtfExecutionPolicy = createAtfExecutionPolicy;
|
|
16
|
+
exports.isAtfPolicyError = isAtfPolicyError;
|
|
17
|
+
exports.atfPolicyDenialMessage = atfPolicyDenialMessage;
|
|
18
|
+
exports.requireAtfExecution = requireAtfExecution;
|
|
19
|
+
exports.DENY_ALL_ATF_EXECUTION = Object.freeze({
|
|
20
|
+
execute: false,
|
|
21
|
+
allowScriptSteps: false,
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Normalize a provider-supplied ATF policy. Each property is read once, and
|
|
25
|
+
* anything other than an explicit boolean `true` leaves the grant off. A
|
|
26
|
+
* non-boolean value is a provider defect, so it fails context creation.
|
|
27
|
+
*/
|
|
28
|
+
function createAtfExecutionPolicy(candidate) {
|
|
29
|
+
if (candidate === undefined)
|
|
30
|
+
return exports.DENY_ALL_ATF_EXECUTION;
|
|
31
|
+
if (typeof candidate !== "object" || candidate === null) {
|
|
32
|
+
throw new TypeError("ATF execution policy must be an object");
|
|
33
|
+
}
|
|
34
|
+
const execute = candidate.execute;
|
|
35
|
+
const allowScriptSteps = candidate.allowScriptSteps;
|
|
36
|
+
if ((execute !== undefined && typeof execute !== "boolean") ||
|
|
37
|
+
(allowScriptSteps !== undefined && typeof allowScriptSteps !== "boolean")) {
|
|
38
|
+
throw new TypeError("ATF execution policy grants must be booleans");
|
|
39
|
+
}
|
|
40
|
+
return Object.freeze({
|
|
41
|
+
execute: execute === true,
|
|
42
|
+
allowScriptSteps: allowScriptSteps === true,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const ISSUED_ATF_POLICY_ERRORS = new WeakSet();
|
|
46
|
+
class AtfPolicyError extends Error {
|
|
47
|
+
reason;
|
|
48
|
+
constructor(reason) {
|
|
49
|
+
super("ATF operation denied by policy");
|
|
50
|
+
this.name = "AtfPolicyError";
|
|
51
|
+
this.reason = reason;
|
|
52
|
+
ISSUED_ATF_POLICY_ERRORS.add(this);
|
|
53
|
+
Object.freeze(this);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.AtfPolicyError = AtfPolicyError;
|
|
57
|
+
function isAtfPolicyError(error) {
|
|
58
|
+
return (typeof error === "object" &&
|
|
59
|
+
error !== null &&
|
|
60
|
+
ISSUED_ATF_POLICY_ERRORS.has(error));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Fixed operator guidance. It names the configuration key that grants the
|
|
64
|
+
* operation, and keeps the "denied by policy" phrase other denials share.
|
|
65
|
+
*/
|
|
66
|
+
function atfPolicyDenialMessage(_error, tool) {
|
|
67
|
+
const subject = typeof tool === "string" && tool.trim() !== "" ? tool.trim() : "This tool";
|
|
68
|
+
return (`ATF execution denied by policy: ${subject} runs ATF tests, and this profile ` +
|
|
69
|
+
`does not enable ATF execution. Running a suite executes its steps on the ` +
|
|
70
|
+
`instance and can change any data those steps touch. To allow it, set ` +
|
|
71
|
+
`"atf": { "execute": true } on the profile (or SN_ATF_EXECUTE=true for an ` +
|
|
72
|
+
`environment-only profile), then restart the MCP client.`);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Call from a module's resolveAccess before returning its plan, so a profile
|
|
76
|
+
* without the grant is rejected before any configuration or client exists.
|
|
77
|
+
*/
|
|
78
|
+
function requireAtfExecution(policy) {
|
|
79
|
+
if (policy.atf?.execute !== true) {
|
|
80
|
+
throw new AtfPolicyError("execution_not_enabled");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# source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AC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,wBAAwB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;CACF;AAVD,wCAUC;AAED,SAAgB,gBAAgB,CAAC,KAAc;IAC7C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,wBAAwB,CAAC,GAAG,CAAC,KAAK,CAAC,CACpC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,sBAAsB,CACpC,MAAsB,EACtB,IAAa;IAEb,MAAM,OAAO,GACX,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;IAC7E,OAAO,CACL,mCAAmC,OAAO,oCAAoC;QAC9E,2EAA2E;QAC3E,uEAAuE;QACvE,2EAA2E;QAC3E,yDAAyD,CAC1D,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,MAAqD;IAErD,IAAI,MAAM,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC;QACjC,MAAM,IAAI,cAAc,CAAC,uBAAuB,CAAC,CAAC;IACpD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ServiceNowConfig } from "./config.js";
|
|
3
|
+
export declare const atfRunSummarySchema: z.ZodObject<{
|
|
4
|
+
runId: z.ZodString;
|
|
5
|
+
suiteId: z.ZodString;
|
|
6
|
+
startedAt: z.ZodString;
|
|
7
|
+
finishedAt: z.ZodOptional<z.ZodString>;
|
|
8
|
+
status: z.ZodEnum<["pending", "running", "success", "failure", "error", "skipped", "canceled", "success_with_warnings"]>;
|
|
9
|
+
durationMs: z.ZodNumber;
|
|
10
|
+
counts: z.ZodObject<{
|
|
11
|
+
passed: z.ZodNumber;
|
|
12
|
+
failed: z.ZodNumber;
|
|
13
|
+
errors: z.ZodNumber;
|
|
14
|
+
skipped: z.ZodNumber;
|
|
15
|
+
}, "strict", z.ZodTypeAny, {
|
|
16
|
+
skipped: number;
|
|
17
|
+
passed: number;
|
|
18
|
+
failed: number;
|
|
19
|
+
errors: number;
|
|
20
|
+
}, {
|
|
21
|
+
skipped: number;
|
|
22
|
+
passed: number;
|
|
23
|
+
failed: number;
|
|
24
|
+
errors: number;
|
|
25
|
+
}>;
|
|
26
|
+
tests: z.ZodArray<z.ZodObject<{
|
|
27
|
+
testId: z.ZodString;
|
|
28
|
+
status: z.ZodEnum<["pending", "running", "success", "failure", "error", "skipped", "canceled", "success_with_warnings"]>;
|
|
29
|
+
firstFailure: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, "strict", z.ZodTypeAny, {
|
|
31
|
+
status: "success" | "pending" | "running" | "failure" | "error" | "skipped" | "canceled" | "success_with_warnings";
|
|
32
|
+
testId: string;
|
|
33
|
+
firstFailure?: string | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
status: "success" | "pending" | "running" | "failure" | "error" | "skipped" | "canceled" | "success_with_warnings";
|
|
36
|
+
testId: string;
|
|
37
|
+
firstFailure?: string | undefined;
|
|
38
|
+
}>, "many">;
|
|
39
|
+
}, "strict", z.ZodTypeAny, {
|
|
40
|
+
status: "success" | "pending" | "running" | "failure" | "error" | "skipped" | "canceled" | "success_with_warnings";
|
|
41
|
+
runId: string;
|
|
42
|
+
suiteId: string;
|
|
43
|
+
startedAt: string;
|
|
44
|
+
durationMs: number;
|
|
45
|
+
counts: {
|
|
46
|
+
skipped: number;
|
|
47
|
+
passed: number;
|
|
48
|
+
failed: number;
|
|
49
|
+
errors: number;
|
|
50
|
+
};
|
|
51
|
+
tests: {
|
|
52
|
+
status: "success" | "pending" | "running" | "failure" | "error" | "skipped" | "canceled" | "success_with_warnings";
|
|
53
|
+
testId: string;
|
|
54
|
+
firstFailure?: string | undefined;
|
|
55
|
+
}[];
|
|
56
|
+
finishedAt?: string | undefined;
|
|
57
|
+
}, {
|
|
58
|
+
status: "success" | "pending" | "running" | "failure" | "error" | "skipped" | "canceled" | "success_with_warnings";
|
|
59
|
+
runId: string;
|
|
60
|
+
suiteId: string;
|
|
61
|
+
startedAt: string;
|
|
62
|
+
durationMs: number;
|
|
63
|
+
counts: {
|
|
64
|
+
skipped: number;
|
|
65
|
+
passed: number;
|
|
66
|
+
failed: number;
|
|
67
|
+
errors: number;
|
|
68
|
+
};
|
|
69
|
+
tests: {
|
|
70
|
+
status: "success" | "pending" | "running" | "failure" | "error" | "skipped" | "canceled" | "success_with_warnings";
|
|
71
|
+
testId: string;
|
|
72
|
+
firstFailure?: string | undefined;
|
|
73
|
+
}[];
|
|
74
|
+
finishedAt?: string | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
export type AtfRunSummary = z.infer<typeof atfRunSummarySchema>;
|
|
77
|
+
export declare const MAX_ATF_CACHE_BYTES: number;
|
|
78
|
+
export declare class AtfResultCache {
|
|
79
|
+
readonly filePath: string;
|
|
80
|
+
private readonly directory;
|
|
81
|
+
private readonly identity;
|
|
82
|
+
private readonly size;
|
|
83
|
+
private memory;
|
|
84
|
+
private disk;
|
|
85
|
+
private readonly warnings;
|
|
86
|
+
private queue;
|
|
87
|
+
constructor(options: {
|
|
88
|
+
profile: string;
|
|
89
|
+
config: ServiceNowConfig;
|
|
90
|
+
warn?: (message: string) => void;
|
|
91
|
+
});
|
|
92
|
+
private readonly warn;
|
|
93
|
+
private empty;
|
|
94
|
+
private warning;
|
|
95
|
+
put(candidate: AtfRunSummary): Promise<void>;
|
|
96
|
+
history(suiteId: string): Promise<AtfRunSummary[]>;
|
|
97
|
+
testHistory(testId: string): Promise<AtfRunSummary[]>;
|
|
98
|
+
private transaction;
|
|
99
|
+
private boundMemory;
|
|
100
|
+
private lock;
|
|
101
|
+
private read;
|
|
102
|
+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