@cdot65/prisma-airs-sdk 0.23.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.cjs +63 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -13
- package/dist/index.d.ts +100 -13
- package/dist/index.js +62 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ var MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 20;
|
|
|
29
29
|
var MAX_CONNECTION_POOL_SIZE = 100;
|
|
30
30
|
var MAX_NUMBER_OF_RETRIES = 5;
|
|
31
31
|
var HTTP_FORCE_RETRY_STATUS_CODES = [500, 502, 503, 504];
|
|
32
|
-
var SDK_VERSION = "0.
|
|
32
|
+
var SDK_VERSION = "0.25.0";
|
|
33
33
|
var USER_AGENT = `PAN-AIRS/${SDK_VERSION}-typescript-sdk`;
|
|
34
34
|
var DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
|
|
35
35
|
var DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
|
|
@@ -16606,37 +16606,63 @@ function toOffsetIso(d) {
|
|
|
16606
16606
|
return `${String(d.getFullYear()).padStart(4, "0")}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}${sign}${pad(offsetMin / 60)}:${pad(offsetMin % 60)}`;
|
|
16607
16607
|
}
|
|
16608
16608
|
function serializeWindow(tsgId, opts, schema = telemetryWindowSchema) {
|
|
16609
|
+
return serializeWindowWithOptions(tsgId, opts, schema).params;
|
|
16610
|
+
}
|
|
16611
|
+
function serializeWindowWithOptions(tsgId, opts, schema) {
|
|
16609
16612
|
const result = schema.safeParse(opts);
|
|
16610
16613
|
if (!result.success || typeof tsgId !== "string" || !/^\d+$/.test(tsgId)) invalidWindow();
|
|
16611
16614
|
const end = result.data.end ?? /* @__PURE__ */ new Date();
|
|
16612
16615
|
const start = result.data.start ?? new Date(end.getTime() - (result.data.days ?? 7) * 864e5);
|
|
16613
16616
|
if (start.getTime() > end.getTime()) invalidWindow();
|
|
16614
16617
|
return {
|
|
16615
|
-
|
|
16616
|
-
|
|
16617
|
-
|
|
16618
|
-
|
|
16618
|
+
options: result.data,
|
|
16619
|
+
params: {
|
|
16620
|
+
organisationId: tsgId,
|
|
16621
|
+
workspaceSlug: result.data.workspaceSlug,
|
|
16622
|
+
timeOfGenerationMin: toOffsetIso(start),
|
|
16623
|
+
timeOfGenerationMax: toOffsetIso(end)
|
|
16624
|
+
}
|
|
16619
16625
|
};
|
|
16620
16626
|
}
|
|
16621
16627
|
|
|
16622
16628
|
// src/ai-gateway/telemetry-client.ts
|
|
16623
16629
|
var nonBlankString = z54.string().min(1).refine((value2) => value2.trim().length > 0);
|
|
16624
|
-
var groupOptionsSchema = telemetryWindowSchema.extend({
|
|
16625
|
-
columns: z54.array(z54.enum(AI_GW_GROUP_COLUMNS)).optional()
|
|
16626
|
-
}).strict();
|
|
16627
16630
|
var logsOptionsSchema = telemetryWindowSchema.extend({
|
|
16628
16631
|
pageSize: z54.number().int().nonnegative().safe().optional(),
|
|
16629
16632
|
traceId: nonBlankString.optional(),
|
|
16630
16633
|
statusCode: z54.number().int().nonnegative().safe().optional()
|
|
16631
16634
|
}).strict();
|
|
16632
|
-
var
|
|
16635
|
+
var chartFilterFields = {
|
|
16633
16636
|
traceId: nonBlankString.optional(),
|
|
16634
|
-
metadata: GatewayJsonObjectSchema.pipe(z54.record(z54.string())).optional()
|
|
16635
|
-
|
|
16636
|
-
|
|
16637
|
-
|
|
16637
|
+
metadata: GatewayJsonObjectSchema.pipe(z54.record(z54.string())).optional(),
|
|
16638
|
+
statusCodes: z54.array(z54.number().int().nonnegative().safe()).nonempty().optional(),
|
|
16639
|
+
apiKeyIds: z54.array(z54.string().uuid()).nonempty().optional(),
|
|
16640
|
+
aiOrgModels: z54.array(z54.string().regex(/^[^,\s]+__[^,\s]+$/)).nonempty().optional(),
|
|
16641
|
+
totalUnitsMin: z54.number().int().nonnegative().safe().optional(),
|
|
16642
|
+
totalUnitsMax: z54.number().int().nonnegative().safe().optional(),
|
|
16643
|
+
costMin: z54.number().finite().nonnegative().optional(),
|
|
16644
|
+
costMax: z54.number().finite().nonnegative().optional()
|
|
16645
|
+
};
|
|
16646
|
+
function validChartBounds(opts) {
|
|
16647
|
+
return (opts.totalUnitsMin === void 0 || opts.totalUnitsMax === void 0 || opts.totalUnitsMin <= opts.totalUnitsMax) && (opts.costMin === void 0 || opts.costMax === void 0 || opts.costMin <= opts.costMax);
|
|
16648
|
+
}
|
|
16649
|
+
var AIGatewayChartFiltersSchema = z54.object(chartFilterFields).strict().refine(validChartBounds);
|
|
16650
|
+
var filteredChartOptionsSchema = telemetryWindowSchema.extend(chartFilterFields).strict().refine(validChartBounds);
|
|
16651
|
+
var groupOptionsSchema = telemetryWindowSchema.extend({
|
|
16652
|
+
...chartFilterFields,
|
|
16653
|
+
columns: z54.array(z54.enum(AI_GW_GROUP_COLUMNS)).optional()
|
|
16654
|
+
}).strict().refine(validChartBounds);
|
|
16655
|
+
function serializeFilteredOptions(tsgId, input, schema = filteredChartOptionsSchema) {
|
|
16656
|
+
const { params, options: opts } = serializeWindowWithOptions(tsgId, input, schema);
|
|
16638
16657
|
if (opts.traceId !== void 0) params.traceId = opts.traceId;
|
|
16639
16658
|
if (opts.metadata !== void 0) params.metadata = JSON.stringify(opts.metadata);
|
|
16659
|
+
if (opts.statusCodes !== void 0) params.statusCode = opts.statusCodes.join(",");
|
|
16660
|
+
if (opts.apiKeyIds !== void 0) params.apiKeyIds = opts.apiKeyIds.join(",");
|
|
16661
|
+
if (opts.aiOrgModels !== void 0) params.aiOrgModel = opts.aiOrgModels.join(",");
|
|
16662
|
+
for (const key of ["totalUnitsMin", "totalUnitsMax", "costMin", "costMax"]) {
|
|
16663
|
+
if (opts[key] !== void 0) params[key] = String(opts[key]);
|
|
16664
|
+
}
|
|
16665
|
+
if (opts.columns?.length) params.columns = opts.columns.join(",");
|
|
16640
16666
|
return params;
|
|
16641
16667
|
}
|
|
16642
16668
|
var AIGatewayTelemetryClient = class {
|
|
@@ -16664,7 +16690,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
16664
16690
|
}
|
|
16665
16691
|
/**
|
|
16666
16692
|
* Total and per-day spend. **Values are in cents.**
|
|
16667
|
-
* @param opts - Workspace slug, time window and
|
|
16693
|
+
* @param opts - Workspace slug, time window and verified trace, metadata, list and range filters.
|
|
16668
16694
|
* @returns Cost series plus the period total, in cents.
|
|
16669
16695
|
* @example
|
|
16670
16696
|
* ```ts
|
|
@@ -16680,12 +16706,12 @@ var AIGatewayTelemetryClient = class {
|
|
|
16680
16706
|
"cost",
|
|
16681
16707
|
opts,
|
|
16682
16708
|
CostChartResponseSchema,
|
|
16683
|
-
|
|
16709
|
+
serializeFilteredOptions(this.tsgId, opts)
|
|
16684
16710
|
);
|
|
16685
16711
|
}
|
|
16686
16712
|
/**
|
|
16687
16713
|
* Per-day request counts.
|
|
16688
|
-
* @param opts - Workspace slug, time window and
|
|
16714
|
+
* @param opts - Workspace slug, time window and verified trace, metadata, list and range filters.
|
|
16689
16715
|
* @returns Request-count series plus the filtered period total.
|
|
16690
16716
|
* @example
|
|
16691
16717
|
* ```ts
|
|
@@ -16701,12 +16727,12 @@ var AIGatewayTelemetryClient = class {
|
|
|
16701
16727
|
"requests",
|
|
16702
16728
|
opts,
|
|
16703
16729
|
CountChartResponseSchema,
|
|
16704
|
-
|
|
16730
|
+
serializeFilteredOptions(this.tsgId, opts)
|
|
16705
16731
|
);
|
|
16706
16732
|
}
|
|
16707
16733
|
/**
|
|
16708
16734
|
* Latency in milliseconds. Percentiles are returned per-bucket and for the period.
|
|
16709
|
-
* @param opts - Workspace slug, time window and
|
|
16735
|
+
* @param opts - Workspace slug, time window and verified trace, metadata, list and range filters.
|
|
16710
16736
|
* @returns Latency series with p50/p90/p99; `data.total` is the period mean, not a sum.
|
|
16711
16737
|
* The period mean and percentiles are null when the cohort has no matching requests.
|
|
16712
16738
|
* @example
|
|
@@ -16723,12 +16749,12 @@ var AIGatewayTelemetryClient = class {
|
|
|
16723
16749
|
"latency",
|
|
16724
16750
|
opts,
|
|
16725
16751
|
LatencyChartResponseSchema,
|
|
16726
|
-
|
|
16752
|
+
serializeFilteredOptions(this.tsgId, opts)
|
|
16727
16753
|
);
|
|
16728
16754
|
}
|
|
16729
16755
|
/**
|
|
16730
16756
|
* Token usage, split into request and response units.
|
|
16731
|
-
* @param opts - Workspace slug, time window and
|
|
16757
|
+
* @param opts - Workspace slug, time window and verified trace, metadata, list and range filters.
|
|
16732
16758
|
* @returns Token series plus request/response unit totals.
|
|
16733
16759
|
* @example
|
|
16734
16760
|
* ```ts
|
|
@@ -16744,7 +16770,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
16744
16770
|
"tokens",
|
|
16745
16771
|
opts,
|
|
16746
16772
|
TokensChartResponseSchema,
|
|
16747
|
-
|
|
16773
|
+
serializeFilteredOptions(this.tsgId, opts)
|
|
16748
16774
|
);
|
|
16749
16775
|
}
|
|
16750
16776
|
/**
|
|
@@ -16928,7 +16954,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
16928
16954
|
/**
|
|
16929
16955
|
* Aggregate requests by a dimension.
|
|
16930
16956
|
* @param dimension - One of {@link AI_GW_GROUP_DIMENSIONS}. Underscore names only.
|
|
16931
|
-
* @param opts - Window
|
|
16957
|
+
* @param opts - Window, verified trace/metadata/list/range filters, and optional extra columns.
|
|
16932
16958
|
* @returns One row per distinct dimension value.
|
|
16933
16959
|
* @example
|
|
16934
16960
|
* ```ts
|
|
@@ -16948,8 +16974,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
16948
16974
|
"Invalid telemetry grouping dimension",
|
|
16949
16975
|
"AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
|
|
16950
16976
|
);
|
|
16951
|
-
const params =
|
|
16952
|
-
if (opts.columns?.length) params.columns = opts.columns.join(",");
|
|
16977
|
+
const params = serializeFilteredOptions(this.tsgId, opts, groupOptionsSchema);
|
|
16953
16978
|
return request({
|
|
16954
16979
|
method: "GET",
|
|
16955
16980
|
baseUrl: this.baseUrl,
|
|
@@ -16962,7 +16987,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
16962
16987
|
}
|
|
16963
16988
|
/**
|
|
16964
16989
|
* Requests and cost per end user.
|
|
16965
|
-
* @param opts - Workspace slug and
|
|
16990
|
+
* @param opts - Workspace slug, time window and verified trace/metadata/list/range filters.
|
|
16966
16991
|
* @returns One record per user; `_user: ''` means calls with no end-user id. Costs in cents.
|
|
16967
16992
|
* @example
|
|
16968
16993
|
* ```ts
|
|
@@ -16978,7 +17003,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
16978
17003
|
method: "GET",
|
|
16979
17004
|
baseUrl: this.baseUrl,
|
|
16980
17005
|
path: `${AI_GW_GROUPS_PATH}/users`,
|
|
16981
|
-
params:
|
|
17006
|
+
params: serializeFilteredOptions(this.tsgId, opts),
|
|
16982
17007
|
responseSchema: UserGroupResponseSchema,
|
|
16983
17008
|
auth: this.auth,
|
|
16984
17009
|
numRetries: this.numRetries
|
|
@@ -16986,7 +17011,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
16986
17011
|
}
|
|
16987
17012
|
/**
|
|
16988
17013
|
* Requests grouped by HTTP status code.
|
|
16989
|
-
* @param opts - Window
|
|
17014
|
+
* @param opts - Window, verified trace/metadata/list/range filters, and optional extra columns.
|
|
16990
17015
|
* @returns One row per status. **446 = AIRS security block** (cost 0, never reached the LLM).
|
|
16991
17016
|
* @example
|
|
16992
17017
|
* ```ts
|
|
@@ -17001,8 +17026,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
17001
17026
|
* ```
|
|
17002
17027
|
*/
|
|
17003
17028
|
async byStatusCode(opts) {
|
|
17004
|
-
const params =
|
|
17005
|
-
if (opts.columns?.length) params.columns = opts.columns.join(",");
|
|
17029
|
+
const params = serializeFilteredOptions(this.tsgId, opts, groupOptionsSchema);
|
|
17006
17030
|
return request({
|
|
17007
17031
|
method: "GET",
|
|
17008
17032
|
baseUrl: this.baseUrl,
|
|
@@ -17037,10 +17061,14 @@ var AIGatewayTelemetryClient = class {
|
|
|
17037
17061
|
* ```
|
|
17038
17062
|
*/
|
|
17039
17063
|
async logs(opts) {
|
|
17040
|
-
const params =
|
|
17041
|
-
|
|
17042
|
-
|
|
17043
|
-
|
|
17064
|
+
const { params, options: validated } = serializeWindowWithOptions(
|
|
17065
|
+
this.tsgId,
|
|
17066
|
+
opts,
|
|
17067
|
+
logsOptionsSchema
|
|
17068
|
+
);
|
|
17069
|
+
if (validated.pageSize !== void 0) params.pageSize = String(validated.pageSize);
|
|
17070
|
+
if (validated.traceId !== void 0) params.traceId = validated.traceId;
|
|
17071
|
+
if (validated.statusCode !== void 0) params.statusCode = String(validated.statusCode);
|
|
17044
17072
|
return request({
|
|
17045
17073
|
method: "GET",
|
|
17046
17074
|
baseUrl: this.baseUrl,
|
|
@@ -21298,6 +21326,7 @@ function setDottedValue(input, path, value2) {
|
|
|
21298
21326
|
export {
|
|
21299
21327
|
AIGatewayApiKeysClient,
|
|
21300
21328
|
AIGatewayAuditLogsClient,
|
|
21329
|
+
AIGatewayChartFiltersSchema,
|
|
21301
21330
|
AIGatewayClient,
|
|
21302
21331
|
AIGatewayConfigsClient,
|
|
21303
21332
|
AIGatewayDeploymentsClient,
|