@onlyflows/servicenow-mcp 2.3.0 → 2.4.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +206 -22
  3. package/dist/atf-result-cache.d.ts +2 -2
  4. package/dist/call-metrics.d.ts +11 -1
  5. package/dist/call-metrics.d.ts.map +1 -1
  6. package/dist/call-metrics.js +2 -0
  7. package/dist/call-metrics.js.map +1 -1
  8. package/dist/client.d.ts +10 -0
  9. package/dist/client.d.ts.map +1 -1
  10. package/dist/client.js +31 -3
  11. package/dist/client.js.map +1 -1
  12. package/dist/execution-context.d.ts +3 -3
  13. package/dist/execution-context.d.ts.map +1 -1
  14. package/dist/execution-context.js +7 -2
  15. package/dist/execution-context.js.map +1 -1
  16. package/dist/field-policy.d.ts +8 -0
  17. package/dist/field-policy.d.ts.map +1 -1
  18. package/dist/field-policy.js +239 -46
  19. package/dist/field-policy.js.map +1 -1
  20. package/dist/hidden-values.d.ts +368 -21
  21. package/dist/hidden-values.d.ts.map +1 -1
  22. package/dist/hidden-values.js +1050 -101
  23. package/dist/hidden-values.js.map +1 -1
  24. package/dist/http-observability.js +3 -1
  25. package/dist/http-observability.js.map +1 -1
  26. package/dist/inert-text.d.ts +27 -0
  27. package/dist/inert-text.d.ts.map +1 -0
  28. package/dist/inert-text.js +57 -0
  29. package/dist/inert-text.js.map +1 -0
  30. package/dist/policy-card.d.ts +1 -1
  31. package/dist/policy-card.d.ts.map +1 -1
  32. package/dist/policy-card.js +3 -1
  33. package/dist/policy-card.js.map +1 -1
  34. package/dist/setup-prompts.js +1 -0
  35. package/dist/setup-prompts.js.map +1 -1
  36. package/dist/setup.js +6 -0
  37. package/dist/setup.js.map +1 -1
  38. package/dist/tool-error.d.ts +39 -3
  39. package/dist/tool-error.d.ts.map +1 -1
  40. package/dist/tool-error.js +101 -2
  41. package/dist/tool-error.js.map +1 -1
  42. package/dist/tool-table-access.d.ts.map +1 -1
  43. package/dist/tool-table-access.js +5 -0
  44. package/dist/tool-table-access.js.map +1 -1
  45. package/dist/tools/aggregate.d.ts +8 -0
  46. package/dist/tools/aggregate.d.ts.map +1 -1
  47. package/dist/tools/aggregate.js +70 -11
  48. package/dist/tools/aggregate.js.map +1 -1
  49. package/dist/tools/atf-contracts.d.ts +9 -9
  50. package/dist/tools/catalog.d.ts +2 -2
  51. package/dist/tools/catalog.d.ts.map +1 -1
  52. package/dist/tools/catalog.js +9 -0
  53. package/dist/tools/catalog.js.map +1 -1
  54. package/dist/tools/envelope-text-fit.d.ts +20 -0
  55. package/dist/tools/envelope-text-fit.d.ts.map +1 -0
  56. package/dist/tools/envelope-text-fit.js +33 -0
  57. package/dist/tools/envelope-text-fit.js.map +1 -0
  58. package/dist/tools/flow-view-mermaid.d.ts.map +1 -1
  59. package/dist/tools/flow-view-mermaid.js +6 -13
  60. package/dist/tools/flow-view-mermaid.js.map +1 -1
  61. package/dist/tools/flow-view-module.js +1 -1
  62. package/dist/tools/get-module.js +1 -1
  63. package/dist/tools/history-contracts.d.ts +198 -0
  64. package/dist/tools/history-contracts.d.ts.map +1 -0
  65. package/dist/tools/history-contracts.js +317 -0
  66. package/dist/tools/history-contracts.js.map +1 -0
  67. package/dist/tools/history-module.d.ts +158 -0
  68. package/dist/tools/history-module.d.ts.map +1 -0
  69. package/dist/tools/history-module.js +937 -0
  70. package/dist/tools/history-module.js.map +1 -0
  71. package/dist/tools/history-renderers.d.ts +32 -0
  72. package/dist/tools/history-renderers.d.ts.map +1 -0
  73. package/dist/tools/history-renderers.js +154 -0
  74. package/dist/tools/history-renderers.js.map +1 -0
  75. package/dist/tools/index.d.ts +3 -3
  76. package/dist/tools/index.d.ts.map +1 -1
  77. package/dist/tools/index.js +31 -14
  78. package/dist/tools/index.js.map +1 -1
  79. package/dist/tools/platform-view-contracts.d.ts +4 -4
  80. package/dist/tools/platform-view-contracts.d.ts.map +1 -1
  81. package/dist/tools/platform-view-contracts.js +3 -0
  82. package/dist/tools/platform-view-contracts.js.map +1 -1
  83. package/dist/tools/platform-view-evaluate.d.ts +7 -2
  84. package/dist/tools/platform-view-evaluate.d.ts.map +1 -1
  85. package/dist/tools/platform-view-evaluate.js +44 -130
  86. package/dist/tools/platform-view-evaluate.js.map +1 -1
  87. package/dist/tools/platform-view-module.d.ts +12 -3
  88. package/dist/tools/platform-view-module.d.ts.map +1 -1
  89. package/dist/tools/platform-view-module.js +61 -16
  90. package/dist/tools/platform-view-module.js.map +1 -1
  91. package/dist/tools/platform-view-payload.d.ts +101 -0
  92. package/dist/tools/platform-view-payload.d.ts.map +1 -0
  93. package/dist/tools/platform-view-payload.js +302 -0
  94. package/dist/tools/platform-view-payload.js.map +1 -0
  95. package/dist/tools/platform-view-update-sets.d.ts +129 -0
  96. package/dist/tools/platform-view-update-sets.d.ts.map +1 -0
  97. package/dist/tools/platform-view-update-sets.js +1060 -0
  98. package/dist/tools/platform-view-update-sets.js.map +1 -0
  99. package/dist/tools/query-module.js +1 -1
  100. package/dist/tools/relationships-map.d.ts +59 -0
  101. package/dist/tools/relationships-map.d.ts.map +1 -0
  102. package/dist/tools/relationships-map.js +162 -0
  103. package/dist/tools/relationships-map.js.map +1 -0
  104. package/dist/tools/relationships-renderer.d.ts +22 -0
  105. package/dist/tools/relationships-renderer.d.ts.map +1 -0
  106. package/dist/tools/relationships-renderer.js +90 -0
  107. package/dist/tools/relationships-renderer.js.map +1 -0
  108. package/dist/tools/relationships.d.ts +37 -2
  109. package/dist/tools/relationships.d.ts.map +1 -1
  110. package/dist/tools/relationships.js +602 -183
  111. package/dist/tools/relationships.js.map +1 -1
  112. package/dist/tools/result-envelope.d.ts +314 -15
  113. package/dist/tools/result-envelope.d.ts.map +1 -1
  114. package/dist/tools/result-envelope.js +120 -19
  115. package/dist/tools/result-envelope.js.map +1 -1
  116. package/dist/tools/syslog.d.ts +1 -1
  117. package/dist/tools/table-hierarchy.d.ts +17 -0
  118. package/dist/tools/table-hierarchy.d.ts.map +1 -1
  119. package/dist/tools/table-hierarchy.js +41 -0
  120. package/dist/tools/table-hierarchy.js.map +1 -1
  121. package/dist/version.d.ts +1 -1
  122. package/dist/version.d.ts.map +1 -1
  123. package/dist/version.js +1 -1
  124. package/dist/version.js.map +1 -1
  125. package/docs/CLIENT-SETUP.md +2 -2
  126. package/docs/CROSS-CLIENT-RELEASE-MATRIX.md +2 -2
  127. package/docs/PRODUCTION-SECURITY.md +145 -2
  128. package/docs/RELEASE-VALIDATION.md +2 -2
  129. package/docs/TESTING-OAUTH.md +1 -1
  130. package/package.json +2 -2
  131. package/server.json +2 -2
@@ -12,17 +12,26 @@
12
12
  * `test/platform-view-skeleton.test.ts` runs the dispatcher against a recording
13
13
  * client and asserts that every table it reads is in the call's plan.
14
14
  *
15
- * The tool is not registered here: its `catalog.ts` entry and its
16
- * result-envelope entry are added when it is. This file exports the module,
17
- * and the contracts file exports `platformViewDataSchema`, for that.
15
+ * Registered in `catalog.ts`; its output schema and byte limit are its
16
+ * result-envelope entries, and `platformViewTextRenderer` is its text.
18
17
  *
19
18
  * @module tools/platform-view-module
20
19
  */
21
20
  import { type PlatformView, type PlatformViewHandler } from "./platform-view-contracts.js";
21
+ import { type EnvelopeTextRenderer } from "./result-envelope.js";
22
22
  /**
23
23
  * Build the module around a handler per view. The shipped module uses
24
24
  * `VIEW_HANDLERS`; a test passes its own to hold a handler to its plan.
25
25
  */
26
26
  export declare function createPlatformViewToolModule(handlers?: Readonly<Record<PlatformView, PlatformViewHandler>>): import("./tool-module.js").ServiceNowToolModuleContract;
27
27
  export declare const platformViewToolModule: import("./tool-module.js").ServiceNowToolModuleContract;
28
+ /** Said in place of a payload the text leaves out; fixed text, not instance data. */
29
+ export declare const PAYLOAD_LEFT_OUT_HINT = "it is in the structured result (summary.payload.text) and is not repeated here, to fit max_response_bytes.";
30
+ /**
31
+ * The text of a result, by its view. It is kept only when it fits beside the
32
+ * structured result within `max_response_bytes`; a shown payload is left out
33
+ * of the text when that alone makes it fit. Otherwise, or for data that is no
34
+ * view's, the text is the dispatcher's one-line summary.
35
+ */
36
+ export declare const platformViewTextRenderer: EnvelopeTextRenderer;
28
37
  //# sourceMappingURL=platform-view-module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform-view-module.d.ts","sourceRoot":"","sources":["../../src/tools/platform-view-module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,EAUL,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;AAkCtC;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,GAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,mBAAmB,CAAC,CAAiB,2DAoD9E;AAED,eAAO,MAAM,sBAAsB,yDAAiC,CAAC"}
1
+ {"version":3,"file":"platform-view-module.d.ts","sourceRoot":"","sources":["../../src/tools/platform-view-module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EASL,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;AAMtC,OAAO,EAA+B,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAwC9F;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,GAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,mBAAmB,CAAC,CAAiB,2DAkD9E;AAED,eAAO,MAAM,sBAAsB,yDAAiC,CAAC;AAErE,qFAAqF;AACrF,eAAO,MAAM,qBAAqB,+GAC4E,CAAC;AAY/G;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,EAAE,oBAWtC,CAAC"}
@@ -13,34 +13,45 @@
13
13
  * `test/platform-view-skeleton.test.ts` runs the dispatcher against a recording
14
14
  * client and asserts that every table it reads is in the call's plan.
15
15
  *
16
- * The tool is not registered here: its `catalog.ts` entry and its
17
- * result-envelope entry are added when it is. This file exports the module,
18
- * and the contracts file exports `platformViewDataSchema`, for that.
16
+ * Registered in `catalog.ts`; its output schema and byte limit are its
17
+ * result-envelope entries, and `platformViewTextRenderer` is its text.
19
18
  *
20
19
  * @module tools/platform-view-module
21
20
  */
22
21
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.platformViewToolModule = void 0;
22
+ exports.platformViewTextRenderer = exports.PAYLOAD_LEFT_OUT_HINT = exports.platformViewToolModule = void 0;
24
23
  exports.createPlatformViewToolModule = createPlatformViewToolModule;
25
24
  const tool_error_js_1 = require("../tool-error.js");
26
25
  const platform_view_contracts_js_1 = require("./platform-view-contracts.js");
26
+ const envelope_text_fit_js_1 = require("./envelope-text-fit.js");
27
27
  const platform_view_evaluate_js_1 = require("./platform-view-evaluate.js");
28
28
  const platform_view_scan_js_1 = require("./platform-view-scan.js");
29
+ const platform_view_update_sets_js_1 = require("./platform-view-update-sets.js");
29
30
  const platform_view_upgrades_js_1 = require("./platform-view-upgrades.js");
30
31
  const result_envelope_js_1 = require("./result-envelope.js");
31
32
  const tool_module_js_1 = require("./tool-module.js");
32
33
  const schema = (0, tool_module_js_1.withRequiredProfile)(platform_view_contracts_js_1.platformViewInputSchema);
33
- /** The update set views have no handler yet: the same fixed error as the stub files. */
34
- const handleUpdateSetViews = async () => {
35
- throw (0, tool_error_js_1.createToolError)("internal", "do_not_retry");
36
- };
34
+ /**
35
+ * One text renderer per group of views; each returns undefined for a view
36
+ * that is not its own. Every one fences instance text in an `untrustedBlock`.
37
+ */
38
+ const VIEW_RENDERERS = Object.freeze({
39
+ update_sets: platform_view_update_sets_js_1.renderUpdateSetViewText,
40
+ update_set: platform_view_update_sets_js_1.renderUpdateSetViewText,
41
+ changes: platform_view_update_sets_js_1.renderUpdateSetViewText,
42
+ batch: platform_view_update_sets_js_1.renderUpdateSetViewText,
43
+ remote_update_sets: platform_view_update_sets_js_1.renderUpdateSetViewText,
44
+ upgrade_skipped: platform_view_upgrades_js_1.renderUpgradeSkippedText,
45
+ scan_findings: platform_view_scan_js_1.renderScanFindingsText,
46
+ evaluate: platform_view_evaluate_js_1.renderEvaluateText,
47
+ });
37
48
  /** One handler per view. Implementing a view replaces its entry. */
38
49
  const VIEW_HANDLERS = Object.freeze({
39
- update_sets: handleUpdateSetViews,
40
- update_set: handleUpdateSetViews,
41
- changes: handleUpdateSetViews,
42
- batch: handleUpdateSetViews,
43
- remote_update_sets: handleUpdateSetViews,
50
+ update_sets: platform_view_update_sets_js_1.handleUpdateSetViews,
51
+ update_set: platform_view_update_sets_js_1.handleUpdateSetViews,
52
+ changes: platform_view_update_sets_js_1.handleUpdateSetViews,
53
+ batch: platform_view_update_sets_js_1.handleUpdateSetViews,
54
+ remote_update_sets: platform_view_update_sets_js_1.handleUpdateSetViews,
44
55
  upgrade_skipped: platform_view_upgrades_js_1.handleUpgradeSkipped,
45
56
  scan_findings: platform_view_scan_js_1.handleScanFindings,
46
57
  evaluate: platform_view_evaluate_js_1.handleEvaluate,
@@ -85,9 +96,7 @@ function createPlatformViewToolModule(handlers = VIEW_HANDLERS) {
85
96
  },
86
97
  },
87
98
  inputSchema: schema,
88
- // The expression to register as
89
- // `productionToolOutputSchemas.sn_platform_view`.
90
- outputSchema: (0, result_envelope_js_1.withStructuredResultEnvelope)(platform_view_contracts_js_1.platformViewDataSchema),
99
+ outputSchema: result_envelope_js_1.productionToolOutputSchemas.sn_platform_view,
91
100
  requirements: {
92
101
  permissions: ["read"],
93
102
  tables: { kind: "static", names: platform_view_contracts_js_1.PLATFORM_VIEW_ALL_TABLES },
@@ -108,4 +117,40 @@ function createPlatformViewToolModule(handlers = VIEW_HANDLERS) {
108
117
  });
109
118
  }
110
119
  exports.platformViewToolModule = createPlatformViewToolModule();
120
+ /** Said in place of a payload the text leaves out; fixed text, not instance data. */
121
+ exports.PAYLOAD_LEFT_OUT_HINT = "it is in the structured result (summary.payload.text) and is not repeated here, to fit max_response_bytes.";
122
+ /** The result's data with a shown payload replaced by a note, or undefined when no payload is shown. */
123
+ function withoutPayloadText(data) {
124
+ if (typeof data !== "object" || data === null)
125
+ return undefined;
126
+ const summary = data.summary;
127
+ if (typeof summary !== "object" || summary === null)
128
+ return undefined;
129
+ const payload = summary.payload;
130
+ if (payload?.status !== "shown")
131
+ return undefined;
132
+ return { ...data, summary: { ...summary, payload: { status: "left out", hint: exports.PAYLOAD_LEFT_OUT_HINT } } };
133
+ }
134
+ /**
135
+ * The text of a result, by its view. It is kept only when it fits beside the
136
+ * structured result within `max_response_bytes`; a shown payload is left out
137
+ * of the text when that alone makes it fit. Otherwise, or for data that is no
138
+ * view's, the text is the dispatcher's one-line summary.
139
+ */
140
+ const platformViewTextRenderer = (envelope, context) => {
141
+ const view = envelope.data?.view;
142
+ if (typeof view !== "string" || !platform_view_contracts_js_1.PLATFORM_VIEWS.includes(view))
143
+ return context.summary;
144
+ const render = VIEW_RENDERERS[view];
145
+ const full = render(envelope.data);
146
+ if (full === undefined)
147
+ return context.summary;
148
+ const fits = (0, envelope_text_fit_js_1.envelopeTextFits)(envelope);
149
+ if (fits(full))
150
+ return full;
151
+ const shorter = withoutPayloadText(envelope.data);
152
+ const text = shorter === undefined ? undefined : render(shorter);
153
+ return text !== undefined && fits(text) ? text : context.summary;
154
+ };
155
+ exports.platformViewTextRenderer = platformViewTextRenderer;
111
156
  //# sourceMappingURL=platform-view-module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform-view-module.js","sourceRoot":"","sources":["../../src/tools/platform-view-module.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAsDH,oEAqDC;AAxGD,oDAAmD;AACnD,6EAYsC;AACtC,2EAA6D;AAC7D,mEAA6D;AAC7D,2EAAmE;AACnE,6DAAoE;AACpE,qDAI0B;AAE1B,MAAM,MAAM,GAAG,IAAA,oCAAmB,EAAC,oDAAuB,CAAC,CAAC;AAE5D,wFAAwF;AACxF,MAAM,oBAAoB,GAAwB,KAAK,IAAI,EAAE;IAC3D,MAAM,IAAA,+BAAe,EAAC,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O,EAAE,YAAY;QACrB,UAAU,EAAE;YACV,IAAI,EAAE,kBAAkB;YACxB,WAAW,EAAE,sDAAyB;YACtC,WAAW,EAAE;gBACX,KAAK,EAAE,oBAAoB;gBAC3B,YAAY,EAAE,IAAI;gBAClB,eAAe,EAAE,KAAK;gBACtB,cAAc,EAAE,IAAI;gBACpB,aAAa,EAAE,IAAI;aACpB;SACF;QACD,WAAW,EAAE,MAAM;QACnB,gCAAgC;QAChC,kDAAkD;QAClD,YAAY,EAAE,IAAA,iDAA4B,EAAC,mDAAsB,CAAC;QAClE,YAAY,EAAE;YACZ,WAAW,EAAE,CAAC,MAAM,CAAC;YACrB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,qDAAwB,EAAE;YAC3D,IAAI,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC;YAC5B,aAAa,EAAE,CAAC,MAAM,CAAC;YACvB,YAAY,EAAE,CAAC,eAAe,CAAC;SAChC;QACD,wEAAwE;QACxE,sEAAsE;QACtE,aAAa,EAAE,CAAC,SAAS,EAAE,EAAE;YAC3B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACtC,OAAO,MAAM,CAAC,MAAM,CAAC;gBACnB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,CAA4B;gBAC5D,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,IAAA,mDAAsB,EAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;aAC7E,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,MAAM;KAChB,CAAC,CAAC;AACL,CAAC;AAEY,QAAA,sBAAsB,GAAG,4BAA4B,EAAE,CAAC"}
1
+ {"version":3,"file":"platform-view-module.js","sourceRoot":"","sources":["../../src/tools/platform-view-module.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkB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c,CAAC,IAAoB,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC;IAC/C,MAAM,IAAI,GAAG,IAAA,uCAAgB,EAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5B,MAAM,OAAO,GAAG,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAClD,MAAM,IAAI,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjE,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;AACnE,CAAC,CAAC;AAXW,QAAA,wBAAwB,4BAWnC"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * `sn_platform_view`, view `changes` with `payload: true`: the masked XML of
3
+ * one customer update.
4
+ *
5
+ * The view reads `sys_update_xml.payload` of one named change, and only when
6
+ * field policy lets the profile read that column (record XML columns are read
7
+ * only when the profile's own `sys_update_xml` entry names them). This module
8
+ * decides what of that XML may be shown, and masks it:
9
+ *
10
+ * 1. The tables the payload writes: the row's `table` column, its update
11
+ * name's table, the root's `table` attribute and every record element (an
12
+ * element with an `action` attribute, every child of the root, and every
13
+ * element below the root that holds elements). A record whose name is not
14
+ * a lower-case table name withholds the payload. A table on the credential
15
+ * list refuses it: the result carries the row's metadata only.
16
+ * 2. Their hierarchies and hidden-typed fields, through the plan-bounded
17
+ * loader (`loadFieldTypesInPlan`), so every read stays in the view's plan.
18
+ * A table that extends a credential table refuses the payload too. A table
19
+ * whose hierarchy is not known in full, or field types that could not be
20
+ * read, withhold it: nothing is shown that cannot be checked.
21
+ * 3. The XML is read with the evaluator's bounded reader and written out
22
+ * again. On the way out:
23
+ * - a field whose type on its record's table is hidden (`password`,
24
+ * `password2`, ...) is replaced with `[hidden]`, text and attributes;
25
+ * - a field or attribute with a sensitive name is replaced the same way,
26
+ * and so is a record's attribute named like one of its hidden-typed
27
+ * fields, and text that sits in a record or the root outside any field;
28
+ * - every other text and attribute value has its credential literals
29
+ * masked (`[masked]`, the evaluator's SEC005 patterns), and the whole
30
+ * text is masked once more after it is written.
31
+ * 4. The masked text is cut to the view's character cap (32 KiB by default,
32
+ * at most 200 KiB) after masking, never before, so no value is split
33
+ * at the cut.
34
+ *
35
+ * Nothing here interpolates payload text into a message: every status,
36
+ * reason and note is a fixed sentence. The text itself is instance data and
37
+ * is fenced by the renderer (`untrustedBlock`).
38
+ *
39
+ * @module tools/platform-view-payload
40
+ */
41
+ import { type PlanFieldTypes } from "../hidden-values.js";
42
+ export declare const PAYLOAD_LIMITS: Readonly<{
43
+ /** Characters of masked text shown by default. */
44
+ DEFAULT_CHARS: 32768;
45
+ /** Characters of masked text shown at most, for a large `max_response_bytes`. */
46
+ MAX_CHARS: 204800;
47
+ /** Tables one payload may write before it is withheld. */
48
+ MAX_TABLES: 16;
49
+ /** UTF-8 bytes of payload the reader accepts. */
50
+ MAX_BYTES: 1048576;
51
+ }>;
52
+ /** What a hidden field's text and attributes are replaced with. */
53
+ export declare const HIDDEN_MARK = "[hidden]";
54
+ /** The fixed note every shown payload carries. */
55
+ export declare const PAYLOAD_NOTE: string;
56
+ export type PayloadReason = "field_policy" | "credential_table" | "hierarchy_unknown" | "field_types_unavailable" | "unreadable" | "too_large" | "too_many_tables" | "not_found";
57
+ /** One fixed sentence per reason. None interpolates anything. */
58
+ export declare const PAYLOAD_HINTS: Readonly<Record<PayloadReason, string>>;
59
+ export type PayloadOutcome = {
60
+ readonly status: "shown";
61
+ readonly text: string;
62
+ /** Characters of masked text before the cap. */
63
+ readonly chars: number;
64
+ readonly truncated: boolean;
65
+ /** Fields replaced because of their type, and because of their name. */
66
+ readonly hidden_by_type: number;
67
+ readonly hidden_by_name: number;
68
+ /** Credential literals masked. */
69
+ readonly masked: number;
70
+ readonly note: string;
71
+ } | {
72
+ readonly status: "empty";
73
+ } | {
74
+ readonly status: "refused" | "withheld" | "not_readable";
75
+ readonly reason: PayloadReason;
76
+ readonly hint: string;
77
+ };
78
+ /** Characters of masked text a call may show: half its byte budget, 32 KiB by default, at most 200 KiB. */
79
+ export declare function payloadCharsFor(maxResponseBytes: number): number;
80
+ /**
81
+ * Bytes the shown text may take in the result: half the call's byte budget,
82
+ * measured as the UTF-8 JSON string the result carries. A character can take
83
+ * up to six bytes there (a multi-byte character, an escaped quote or control
84
+ * character), so the character cap alone does not bound the result.
85
+ */
86
+ export declare function payloadBytesFor(maxResponseBytes: number): number;
87
+ export declare function payloadRefusal(status: "refused" | "withheld" | "not_readable", reason: PayloadReason,
88
+ /** A hint worded for the cause; the reason's fixed sentence when none is known. */
89
+ hint?: string): PayloadOutcome;
90
+ /** The tables named by the row itself, before its payload is read. */
91
+ export declare function rowTables(row: {
92
+ readonly table?: unknown;
93
+ readonly name?: unknown;
94
+ }): string[];
95
+ /**
96
+ * Decide and mask one payload. `tables` are the row's own tables
97
+ * ({@link rowTables}); `load` reads hierarchies and field types for every
98
+ * table the payload writes, inside the view's plan.
99
+ */
100
+ export declare function preparePayload(raw: unknown, tables: readonly string[], load: (tables: readonly string[]) => Promise<PlanFieldTypes>, maxChars: number, maxJsonBytes?: number): Promise<PayloadOutcome>;
101
+ //# sourceMappingURL=platform-view-payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-view-payload.d.ts","sourceRoot":"","sources":["../../src/tools/platform-view-payload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAIH,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,qBAAqB,CAAC;AAW7B,eAAO,MAAM,cAAc;IACzB,kD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AAOD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,cAAc,EAC/C,MAAM,EAAE,aAAa;AACrB,mFAAmF;AACnF,IAAI,CAAC,EAAE,MAAM,GACZ,cAAc,CAEhB;AAMD,sEAAsE;AACtE,wBAAgB,SAAS,CAAC,GAAG,EAAE;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,EAAE,CAO9F;AAeD;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,IAAI,EAAE,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,cAAc,CAAC,EAC5D,QAAQ,EAAE,MAAM,EAChB,YAAY,GAAE,MAAiC,GAC9C,OAAO,CAAC,cAAc,CAAC,CA+HzB"}
@@ -0,0 +1,302 @@
1
+ "use strict";
2
+ /**
3
+ * `sn_platform_view`, view `changes` with `payload: true`: the masked XML of
4
+ * one customer update.
5
+ *
6
+ * The view reads `sys_update_xml.payload` of one named change, and only when
7
+ * field policy lets the profile read that column (record XML columns are read
8
+ * only when the profile's own `sys_update_xml` entry names them). This module
9
+ * decides what of that XML may be shown, and masks it:
10
+ *
11
+ * 1. The tables the payload writes: the row's `table` column, its update
12
+ * name's table, the root's `table` attribute and every record element (an
13
+ * element with an `action` attribute, every child of the root, and every
14
+ * element below the root that holds elements). A record whose name is not
15
+ * a lower-case table name withholds the payload. A table on the credential
16
+ * list refuses it: the result carries the row's metadata only.
17
+ * 2. Their hierarchies and hidden-typed fields, through the plan-bounded
18
+ * loader (`loadFieldTypesInPlan`), so every read stays in the view's plan.
19
+ * A table that extends a credential table refuses the payload too. A table
20
+ * whose hierarchy is not known in full, or field types that could not be
21
+ * read, withhold it: nothing is shown that cannot be checked.
22
+ * 3. The XML is read with the evaluator's bounded reader and written out
23
+ * again. On the way out:
24
+ * - a field whose type on its record's table is hidden (`password`,
25
+ * `password2`, ...) is replaced with `[hidden]`, text and attributes;
26
+ * - a field or attribute with a sensitive name is replaced the same way,
27
+ * and so is a record's attribute named like one of its hidden-typed
28
+ * fields, and text that sits in a record or the root outside any field;
29
+ * - every other text and attribute value has its credential literals
30
+ * masked (`[masked]`, the evaluator's SEC005 patterns), and the whole
31
+ * text is masked once more after it is written.
32
+ * 4. The masked text is cut to the view's character cap (32 KiB by default,
33
+ * at most 200 KiB) after masking, never before, so no value is split
34
+ * at the cut.
35
+ *
36
+ * Nothing here interpolates payload text into a message: every status,
37
+ * reason and note is a fixed sentence. The text itself is instance data and
38
+ * is fenced by the renderer (`untrustedBlock`).
39
+ *
40
+ * @module tools/platform-view-payload
41
+ */
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.PAYLOAD_HINTS = exports.PAYLOAD_NOTE = exports.HIDDEN_MARK = exports.PAYLOAD_LIMITS = void 0;
44
+ exports.payloadCharsFor = payloadCharsFor;
45
+ exports.payloadBytesFor = payloadBytesFor;
46
+ exports.payloadRefusal = payloadRefusal;
47
+ exports.rowTables = rowTables;
48
+ exports.preparePayload = preparePayload;
49
+ const credential_tables_js_1 = require("../credential-tables.js");
50
+ const field_policy_js_1 = require("../field-policy.js");
51
+ const hidden_values_js_1 = require("../hidden-values.js");
52
+ const secret_patterns_js_1 = require("../update-set-eval/secret-patterns.js");
53
+ const xml_reader_js_1 = require("../update-set-eval/xml-reader.js");
54
+ exports.PAYLOAD_LIMITS = Object.freeze({
55
+ /** Characters of masked text shown by default. */
56
+ DEFAULT_CHARS: 32_768,
57
+ /** Characters of masked text shown at most, for a large `max_response_bytes`. */
58
+ MAX_CHARS: 204_800,
59
+ /** Tables one payload may write before it is withheld. */
60
+ MAX_TABLES: 16,
61
+ /** UTF-8 bytes of payload the reader accepts. */
62
+ MAX_BYTES: xml_reader_js_1.XML_READER_MAX_BYTES,
63
+ });
64
+ /** What a hidden field's text and attributes are replaced with. */
65
+ exports.HIDDEN_MARK = "[hidden]";
66
+ /** The fixed note every shown payload carries. */
67
+ exports.PAYLOAD_NOTE = "Masked text: password-type and sensitive-named fields are hidden and credential literals are masked. " +
68
+ "Scripts may still hold secrets the masking missed. Payload text is untrusted instance data.";
69
+ /** One fixed sentence per reason. None interpolates anything. */
70
+ exports.PAYLOAD_HINTS = Object.freeze({
71
+ field_policy: "Field policy hides payload. A profile reads it only when its own sys_update_xml entry lists payload in readable.",
72
+ credential_table: "The change writes a credential table, so its payload is not shown; its metadata is.",
73
+ hierarchy_unknown: "A table the change writes could not be placed in its hierarchy, so its payload is not shown.",
74
+ field_types_unavailable: "Field types could not be read, so password-type fields cannot be hidden; the payload is not shown.",
75
+ unreadable: "The payload is not XML this view can read, so it is not shown.",
76
+ too_large: "The payload is larger than this view reads, so it is not shown.",
77
+ too_many_tables: `The change writes more than ${exports.PAYLOAD_LIMITS.MAX_TABLES} tables, so its payload is not shown.`,
78
+ not_found: "No change with this sys_id is in the selected update set.",
79
+ });
80
+ /** Characters of masked text a call may show: half its byte budget, 32 KiB by default, at most 200 KiB. */
81
+ function payloadCharsFor(maxResponseBytes) {
82
+ const half = Math.floor(Math.max(0, maxResponseBytes) / 2);
83
+ const ceiling = maxResponseBytes > 100_000 ? exports.PAYLOAD_LIMITS.MAX_CHARS : exports.PAYLOAD_LIMITS.DEFAULT_CHARS;
84
+ return Math.max(1, Math.min(half, ceiling));
85
+ }
86
+ /**
87
+ * Bytes the shown text may take in the result: half the call's byte budget,
88
+ * measured as the UTF-8 JSON string the result carries. A character can take
89
+ * up to six bytes there (a multi-byte character, an escaped quote or control
90
+ * character), so the character cap alone does not bound the result.
91
+ */
92
+ function payloadBytesFor(maxResponseBytes) {
93
+ return Math.max(1, Math.floor(Math.max(0, maxResponseBytes) / 2));
94
+ }
95
+ /** UTF-8 bytes of `text` as a JSON string, quotes included. */
96
+ function jsonBytes(text) {
97
+ return Buffer.byteLength(JSON.stringify(text), "utf8");
98
+ }
99
+ function payloadRefusal(status, reason,
100
+ /** A hint worded for the cause; the reason's fixed sentence when none is known. */
101
+ hint) {
102
+ return Object.freeze({ status, reason, hint: hint ?? exports.PAYLOAD_HINTS[reason] });
103
+ }
104
+ const TABLE_NAME = /^[a-z][a-z0-9_]{0,79}$/u;
105
+ /** `<table>_<sys_id>`, the usual update name. */
106
+ const UPDATE_NAME_TABLE = /^([a-z][a-z0-9_]{0,79})_[0-9a-f]{32}$/u;
107
+ /** The tables named by the row itself, before its payload is read. */
108
+ function rowTables(row) {
109
+ const tables = new Set();
110
+ const table = typeof row.table === "string" ? row.table.trim().toLowerCase() : "";
111
+ if (TABLE_NAME.test(table))
112
+ tables.add(table);
113
+ const name = typeof row.name === "string" ? UPDATE_NAME_TABLE.exec(row.name.trim().toLowerCase())?.[1] : undefined;
114
+ if (name !== undefined)
115
+ tables.add(name);
116
+ return [...tables];
117
+ }
118
+ /**
119
+ * True when an element stands where a record does: any child of the root,
120
+ * any element with an `action` attribute, and any element below the root that
121
+ * has element children (a field's value is text, so an element holding
122
+ * elements is read as a record of its own). Its children are that table's
123
+ * fields. The root itself is a record only when it carries `action`.
124
+ */
125
+ function isRecordPosition(element, depth) {
126
+ if ((0, xml_reader_js_1.getAttribute)(element, "action") !== undefined)
127
+ return true;
128
+ if (depth === 1)
129
+ return true;
130
+ return depth >= 2 && element.children.some((child) => child.kind === "element");
131
+ }
132
+ /**
133
+ * Decide and mask one payload. `tables` are the row's own tables
134
+ * ({@link rowTables}); `load` reads hierarchies and field types for every
135
+ * table the payload writes, inside the view's plan.
136
+ */
137
+ async function preparePayload(raw, tables, load, maxChars, maxJsonBytes = Number.POSITIVE_INFINITY) {
138
+ const text = typeof raw === "string" ? raw : "";
139
+ if (text.trim() === "")
140
+ return { status: "empty" };
141
+ if (text.length > exports.PAYLOAD_LIMITS.MAX_BYTES)
142
+ return payloadRefusal("withheld", "too_large");
143
+ const read = (0, xml_reader_js_1.readXml)(text, { maxBytes: exports.PAYLOAD_LIMITS.MAX_BYTES });
144
+ if (!read.ok)
145
+ return payloadRefusal("withheld", read.code === "too_large" ? "too_large" : "unreadable");
146
+ const { document } = read;
147
+ // 1. Every table the payload writes.
148
+ const written = new Set(tables);
149
+ const rootTable = (0, xml_reader_js_1.getAttribute)(document.root, "table")?.trim().toLowerCase();
150
+ if (rootTable !== undefined && rootTable !== "") {
151
+ if (!TABLE_NAME.test(rootTable))
152
+ return payloadRefusal("withheld", "hierarchy_unknown");
153
+ written.add(rootTable);
154
+ }
155
+ // A record's name is its table, so it must be a lower-case table name; any
156
+ // other layout is not one this view can check, and is withheld.
157
+ const records = new WeakSet();
158
+ let unexpected = false;
159
+ (0, xml_reader_js_1.walkElements)(document.root, (element, ancestors) => {
160
+ if (!isRecordPosition(element, ancestors.length))
161
+ return;
162
+ if (!TABLE_NAME.test(element.name)) {
163
+ unexpected = true;
164
+ return "skip";
165
+ }
166
+ records.add(element);
167
+ written.add(element.name);
168
+ });
169
+ if (unexpected)
170
+ return payloadRefusal("withheld", "unreadable");
171
+ if ([...written].some((table) => (0, credential_tables_js_1.isCredentialTable)(table)))
172
+ return payloadRefusal("refused", "credential_table");
173
+ if (written.size > exports.PAYLOAD_LIMITS.MAX_TABLES)
174
+ return payloadRefusal("withheld", "too_many_tables");
175
+ // 2. Their hierarchies and hidden-typed fields.
176
+ const loaded = await load([...written]);
177
+ const hidden = new Map();
178
+ for (const table of written) {
179
+ const chain = loaded.chains.get(table);
180
+ if (chain === undefined || !chain.complete) {
181
+ // The cause comes from what the loader read, never from the payload: the
182
+ // tables it writes are untrusted text, so the hint names none.
183
+ const cause = (0, hidden_values_js_1.planHierarchyProblem)(loaded, written);
184
+ return payloadRefusal("withheld", "hierarchy_unknown", cause === undefined ? undefined : (0, hidden_values_js_1.fieldTypesProblemText)({ surface: "payload", about: "hierarchy", ...cause }));
185
+ }
186
+ if ((0, credential_tables_js_1.isCredentialTableHierarchy)(chain.tables))
187
+ return payloadRefusal("refused", "credential_table");
188
+ }
189
+ for (const table of written) {
190
+ const fields = (0, hidden_values_js_1.hiddenTypedFields)(loaded.types, table);
191
+ if (fields === undefined) {
192
+ const cause = (0, hidden_values_js_1.planTypesProblem)(loaded);
193
+ return payloadRefusal("withheld", "field_types_unavailable", cause === undefined ? undefined : (0, hidden_values_js_1.fieldTypesProblemText)({ surface: "payload", ...cause }));
194
+ }
195
+ hidden.set(table, fields);
196
+ }
197
+ // 3. Write it out, hiding and masking on the way.
198
+ const verdicts = new WeakMap();
199
+ const hiddenElements = { type: new Set(), name: new Set() };
200
+ /** The verdict for the last element of `chain` (root first). */
201
+ const verdictOf = (chain) => {
202
+ const element = chain[chain.length - 1];
203
+ const known = verdicts.get(element);
204
+ if (known !== undefined)
205
+ return known;
206
+ let verdict = false;
207
+ if (chain.length > 1) {
208
+ const inherited = verdictOf(chain.slice(0, -1));
209
+ const parent = chain[chain.length - 2];
210
+ if (inherited !== false)
211
+ verdict = inherited;
212
+ else if (records.has(parent) && hidden.get(parent.name)?.has(element.name.toLowerCase()) === true) {
213
+ verdict = "type";
214
+ }
215
+ else if (records.has(element))
216
+ verdict = false;
217
+ else if ((0, field_policy_js_1.isSensitiveFieldName)(element.name))
218
+ verdict = "name";
219
+ }
220
+ verdicts.set(element, verdict);
221
+ if (verdict !== false && (chain.length < 2 || verdicts.get(chain[chain.length - 2]) === false)) {
222
+ hiddenElements[verdict].add(element);
223
+ }
224
+ return verdict;
225
+ };
226
+ let masked = 0;
227
+ const mask = (value) => {
228
+ const result = (0, secret_patterns_js_1.maskSecrets)(value);
229
+ if (result.status !== "ok")
230
+ return exports.HIDDEN_MARK;
231
+ masked += result.masked;
232
+ return result.text;
233
+ };
234
+ const serialized = (0, xml_reader_js_1.serializeXml)(document.root, {
235
+ declaration: document.declaration !== null,
236
+ text: (value, parent, ancestors) => {
237
+ if (verdictOf(ancestors) !== false)
238
+ return exports.HIDDEN_MARK;
239
+ // Text that belongs to no field (directly in a record or the root) has no type to check.
240
+ if ((records.has(parent) || parent === document.root) && value.trim() !== "")
241
+ return exports.HIDDEN_MARK;
242
+ return mask(value);
243
+ },
244
+ attribute: (name, value, element, ancestors) => {
245
+ if (verdictOf(ancestors) !== false)
246
+ return exports.HIDDEN_MARK;
247
+ if ((0, field_policy_js_1.isSensitiveFieldName)(name))
248
+ return exports.HIDDEN_MARK;
249
+ // A record's attribute named like one of its hidden-typed fields is that field's value.
250
+ if (records.has(element) && hidden.get(element.name)?.has(name.toLowerCase()) === true)
251
+ return exports.HIDDEN_MARK;
252
+ return mask(value);
253
+ },
254
+ });
255
+ // Once more over the whole text, for anything that spans what the reader split.
256
+ const whole = (0, secret_patterns_js_1.maskSecrets)(serialized);
257
+ if (whole.status !== "ok")
258
+ return payloadRefusal("withheld", "too_large");
259
+ masked += whole.masked;
260
+ // 4. The cap, after masking: characters, then the bytes the text takes in the result.
261
+ const shownText = fitted(whole.text, maxChars, maxJsonBytes);
262
+ const truncated = shownText.length < whole.text.length;
263
+ return Object.freeze({
264
+ status: "shown",
265
+ text: shownText,
266
+ chars: whole.text.length,
267
+ truncated,
268
+ hidden_by_type: hiddenElements.type.size,
269
+ hidden_by_name: hiddenElements.name.size,
270
+ masked,
271
+ note: exports.PAYLOAD_NOTE,
272
+ });
273
+ }
274
+ /**
275
+ * The longest prefix of `text` of at most `maxChars` characters whose JSON
276
+ * string takes at most `maxJsonBytes` UTF-8 bytes. The byte size only grows
277
+ * with the prefix, so the cut point is found by binary search.
278
+ */
279
+ function fitted(text, maxChars, maxJsonBytes) {
280
+ const capped = text.length > maxChars ? cut(text, maxChars) : text;
281
+ if (jsonBytes(capped) <= maxJsonBytes)
282
+ return capped;
283
+ let low = 0;
284
+ let high = capped.length;
285
+ while (low < high) {
286
+ const middle = Math.ceil((low + high) / 2);
287
+ if (jsonBytes(capped.slice(0, middle)) <= maxJsonBytes)
288
+ low = middle;
289
+ else
290
+ high = middle - 1;
291
+ }
292
+ return cut(capped, low);
293
+ }
294
+ /** `text` cut to at most `max` characters without splitting a surrogate pair. */
295
+ function cut(text, max) {
296
+ let end = Math.max(0, max);
297
+ const last = text.charCodeAt(end - 1);
298
+ if (last >= 0xd800 && last <= 0xdbff)
299
+ end -= 1;
300
+ return text.slice(0, end);
301
+ }
302
+ //# sourceMappingURL=platform-view-payload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-view-payload.js","sourceRoot":"","sources":["../../src/tools/platform-view-payload.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;;;AAmFH,0CAIC;AAQD,0CAEC;AAOD,wCAOC;AAOD,8BAOC;AAoBD,wCAqIC;AApRD,kEAAwF;AACxF,wDAA0D;AAC1D,0DAM6B;AAC7B,8EAAoE;AACpE,oEAO0C;AAE7B,QAAA,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1C,kDAAkD;IAClD,aAAa,EAAE,MAAM;IACrB,iFAAiF;IACjF,SAAS,EAAE,OAAO;IAClB,0DAA0D;IAC1D,UAAU,EAAE,EAAE;IACd,iDAAiD;IACjD,SAAS,EAAE,oCAAoB;CAChC,CAAC,CAAC;AAEH,mEAAmE;AACtD,QAAA,WAAW,GAAG,UAAU,CAAC;AAEtC,kDAAkD;AACrC,QAAA,YAAY,GACvB,uGAAuG;IACvG,6FAA6F,CAAC;AAYhG,iEAAiE;AACpD,QAAA,aAAa,GAA4C,MAAM,CAAC,MAAM,CAAC;IAClF,YAAY,EACV,kHAAkH;IACpH,gBAAgB,EAAE,qFAAqF;IACvG,iBAAiB,EACf,8FAA8F;IAChG,uBAAuB,EACrB,oGAAoG;IACtG,UAAU,EAAE,gEAAgE;IAC5E,SAAS,EAAE,iEAAiE;IAC5E,eAAe,EAAE,+BAA+B,sBAAc,CAAC,UAAU,uCAAuC;IAChH,SAAS,EAAE,2DAA2D;CACvE,CAAC,CAAC;AAmBH,2GAA2G;AAC3G,SAAgB,eAAe,CAAC,gBAAwB;IACtD,MAAM,IA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