@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/README.md
CHANGED
|
@@ -101,6 +101,8 @@ Experimental runtime methods also model image/audio/moderation/rerank/OCR, legac
|
|
|
101
101
|
|
|
102
102
|
Secret-reference CRUD is verified using owned, unbound synthetic references; external secret resolution is not certified. See the [captured lifecycle output](docs-site/docs/guides/examples.mdx#secret-reference-management-lifecycle). Portkey compatibility remains partial; retired upstream endpoints and tenant-unverified families stay visible in the [complete operation ledger](docs-site/docs/developer/gateway-coverage.md).
|
|
103
103
|
|
|
104
|
+
Request, cost, token and latency charts, plus all six grouped analytics endpoints, accept verified trace/metadata filters, status-code/API-key/provider-model lists and inclusive total-token/cost bounds. List members match with OR; distinct filters combine with AND. Cost bounds are in cents. Groups preserve their existing columns and response envelopes; user grouping does not accept extra columns. Empty latency aggregates remain `null`, not measured zero. Unknown filters are rejected before authentication; the SCM query names differ from upstream Portkey. See the [typed telemetry contract](docs-site/docs/guides/ai-gateway-api.mdx#charts).
|
|
105
|
+
|
|
104
106
|
All AI Gateway write bodies have exported Zod schemas and inferred TypeScript types. Validation
|
|
105
107
|
happens before OAuth and network access; documented nonempty-update requirements are enforced. The package also
|
|
106
108
|
exports typed routing/provider configuration, deterministic known-value catalogs,
|
package/dist/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
AIGatewayApiKeysClient: () => AIGatewayApiKeysClient,
|
|
24
24
|
AIGatewayAuditLogsClient: () => AIGatewayAuditLogsClient,
|
|
25
|
+
AIGatewayChartFiltersSchema: () => AIGatewayChartFiltersSchema,
|
|
25
26
|
AIGatewayClient: () => AIGatewayClient,
|
|
26
27
|
AIGatewayConfigsClient: () => AIGatewayConfigsClient,
|
|
27
28
|
AIGatewayDeploymentsClient: () => AIGatewayDeploymentsClient,
|
|
@@ -1357,7 +1358,7 @@ var MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 20;
|
|
|
1357
1358
|
var MAX_CONNECTION_POOL_SIZE = 100;
|
|
1358
1359
|
var MAX_NUMBER_OF_RETRIES = 5;
|
|
1359
1360
|
var HTTP_FORCE_RETRY_STATUS_CODES = [500, 502, 503, 504];
|
|
1360
|
-
var SDK_VERSION = "0.
|
|
1361
|
+
var SDK_VERSION = "0.25.0";
|
|
1361
1362
|
var USER_AGENT = `PAN-AIRS/${SDK_VERSION}-typescript-sdk`;
|
|
1362
1363
|
var DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
|
|
1363
1364
|
var DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
|
|
@@ -17934,37 +17935,63 @@ function toOffsetIso(d) {
|
|
|
17934
17935
|
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)}`;
|
|
17935
17936
|
}
|
|
17936
17937
|
function serializeWindow(tsgId, opts, schema = telemetryWindowSchema) {
|
|
17938
|
+
return serializeWindowWithOptions(tsgId, opts, schema).params;
|
|
17939
|
+
}
|
|
17940
|
+
function serializeWindowWithOptions(tsgId, opts, schema) {
|
|
17937
17941
|
const result = schema.safeParse(opts);
|
|
17938
17942
|
if (!result.success || typeof tsgId !== "string" || !/^\d+$/.test(tsgId)) invalidWindow();
|
|
17939
17943
|
const end = result.data.end ?? /* @__PURE__ */ new Date();
|
|
17940
17944
|
const start = result.data.start ?? new Date(end.getTime() - (result.data.days ?? 7) * 864e5);
|
|
17941
17945
|
if (start.getTime() > end.getTime()) invalidWindow();
|
|
17942
17946
|
return {
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
+
options: result.data,
|
|
17948
|
+
params: {
|
|
17949
|
+
organisationId: tsgId,
|
|
17950
|
+
workspaceSlug: result.data.workspaceSlug,
|
|
17951
|
+
timeOfGenerationMin: toOffsetIso(start),
|
|
17952
|
+
timeOfGenerationMax: toOffsetIso(end)
|
|
17953
|
+
}
|
|
17947
17954
|
};
|
|
17948
17955
|
}
|
|
17949
17956
|
|
|
17950
17957
|
// src/ai-gateway/telemetry-client.ts
|
|
17951
17958
|
var nonBlankString = import_zod54.z.string().min(1).refine((value2) => value2.trim().length > 0);
|
|
17952
|
-
var groupOptionsSchema = telemetryWindowSchema.extend({
|
|
17953
|
-
columns: import_zod54.z.array(import_zod54.z.enum(AI_GW_GROUP_COLUMNS)).optional()
|
|
17954
|
-
}).strict();
|
|
17955
17959
|
var logsOptionsSchema = telemetryWindowSchema.extend({
|
|
17956
17960
|
pageSize: import_zod54.z.number().int().nonnegative().safe().optional(),
|
|
17957
17961
|
traceId: nonBlankString.optional(),
|
|
17958
17962
|
statusCode: import_zod54.z.number().int().nonnegative().safe().optional()
|
|
17959
17963
|
}).strict();
|
|
17960
|
-
var
|
|
17964
|
+
var chartFilterFields = {
|
|
17961
17965
|
traceId: nonBlankString.optional(),
|
|
17962
|
-
metadata: GatewayJsonObjectSchema.pipe(import_zod54.z.record(import_zod54.z.string())).optional()
|
|
17963
|
-
|
|
17964
|
-
|
|
17965
|
-
|
|
17966
|
+
metadata: GatewayJsonObjectSchema.pipe(import_zod54.z.record(import_zod54.z.string())).optional(),
|
|
17967
|
+
statusCodes: import_zod54.z.array(import_zod54.z.number().int().nonnegative().safe()).nonempty().optional(),
|
|
17968
|
+
apiKeyIds: import_zod54.z.array(import_zod54.z.string().uuid()).nonempty().optional(),
|
|
17969
|
+
aiOrgModels: import_zod54.z.array(import_zod54.z.string().regex(/^[^,\s]+__[^,\s]+$/)).nonempty().optional(),
|
|
17970
|
+
totalUnitsMin: import_zod54.z.number().int().nonnegative().safe().optional(),
|
|
17971
|
+
totalUnitsMax: import_zod54.z.number().int().nonnegative().safe().optional(),
|
|
17972
|
+
costMin: import_zod54.z.number().finite().nonnegative().optional(),
|
|
17973
|
+
costMax: import_zod54.z.number().finite().nonnegative().optional()
|
|
17974
|
+
};
|
|
17975
|
+
function validChartBounds(opts) {
|
|
17976
|
+
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);
|
|
17977
|
+
}
|
|
17978
|
+
var AIGatewayChartFiltersSchema = import_zod54.z.object(chartFilterFields).strict().refine(validChartBounds);
|
|
17979
|
+
var filteredChartOptionsSchema = telemetryWindowSchema.extend(chartFilterFields).strict().refine(validChartBounds);
|
|
17980
|
+
var groupOptionsSchema = telemetryWindowSchema.extend({
|
|
17981
|
+
...chartFilterFields,
|
|
17982
|
+
columns: import_zod54.z.array(import_zod54.z.enum(AI_GW_GROUP_COLUMNS)).optional()
|
|
17983
|
+
}).strict().refine(validChartBounds);
|
|
17984
|
+
function serializeFilteredOptions(tsgId, input, schema = filteredChartOptionsSchema) {
|
|
17985
|
+
const { params, options: opts } = serializeWindowWithOptions(tsgId, input, schema);
|
|
17966
17986
|
if (opts.traceId !== void 0) params.traceId = opts.traceId;
|
|
17967
17987
|
if (opts.metadata !== void 0) params.metadata = JSON.stringify(opts.metadata);
|
|
17988
|
+
if (opts.statusCodes !== void 0) params.statusCode = opts.statusCodes.join(",");
|
|
17989
|
+
if (opts.apiKeyIds !== void 0) params.apiKeyIds = opts.apiKeyIds.join(",");
|
|
17990
|
+
if (opts.aiOrgModels !== void 0) params.aiOrgModel = opts.aiOrgModels.join(",");
|
|
17991
|
+
for (const key of ["totalUnitsMin", "totalUnitsMax", "costMin", "costMax"]) {
|
|
17992
|
+
if (opts[key] !== void 0) params[key] = String(opts[key]);
|
|
17993
|
+
}
|
|
17994
|
+
if (opts.columns?.length) params.columns = opts.columns.join(",");
|
|
17968
17995
|
return params;
|
|
17969
17996
|
}
|
|
17970
17997
|
var AIGatewayTelemetryClient = class {
|
|
@@ -17992,7 +18019,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
17992
18019
|
}
|
|
17993
18020
|
/**
|
|
17994
18021
|
* Total and per-day spend. **Values are in cents.**
|
|
17995
|
-
* @param opts - Workspace slug, time window and
|
|
18022
|
+
* @param opts - Workspace slug, time window and verified trace, metadata, list and range filters.
|
|
17996
18023
|
* @returns Cost series plus the period total, in cents.
|
|
17997
18024
|
* @example
|
|
17998
18025
|
* ```ts
|
|
@@ -18008,12 +18035,12 @@ var AIGatewayTelemetryClient = class {
|
|
|
18008
18035
|
"cost",
|
|
18009
18036
|
opts,
|
|
18010
18037
|
CostChartResponseSchema,
|
|
18011
|
-
|
|
18038
|
+
serializeFilteredOptions(this.tsgId, opts)
|
|
18012
18039
|
);
|
|
18013
18040
|
}
|
|
18014
18041
|
/**
|
|
18015
18042
|
* Per-day request counts.
|
|
18016
|
-
* @param opts - Workspace slug, time window and
|
|
18043
|
+
* @param opts - Workspace slug, time window and verified trace, metadata, list and range filters.
|
|
18017
18044
|
* @returns Request-count series plus the filtered period total.
|
|
18018
18045
|
* @example
|
|
18019
18046
|
* ```ts
|
|
@@ -18029,12 +18056,12 @@ var AIGatewayTelemetryClient = class {
|
|
|
18029
18056
|
"requests",
|
|
18030
18057
|
opts,
|
|
18031
18058
|
CountChartResponseSchema,
|
|
18032
|
-
|
|
18059
|
+
serializeFilteredOptions(this.tsgId, opts)
|
|
18033
18060
|
);
|
|
18034
18061
|
}
|
|
18035
18062
|
/**
|
|
18036
18063
|
* Latency in milliseconds. Percentiles are returned per-bucket and for the period.
|
|
18037
|
-
* @param opts - Workspace slug, time window and
|
|
18064
|
+
* @param opts - Workspace slug, time window and verified trace, metadata, list and range filters.
|
|
18038
18065
|
* @returns Latency series with p50/p90/p99; `data.total` is the period mean, not a sum.
|
|
18039
18066
|
* The period mean and percentiles are null when the cohort has no matching requests.
|
|
18040
18067
|
* @example
|
|
@@ -18051,12 +18078,12 @@ var AIGatewayTelemetryClient = class {
|
|
|
18051
18078
|
"latency",
|
|
18052
18079
|
opts,
|
|
18053
18080
|
LatencyChartResponseSchema,
|
|
18054
|
-
|
|
18081
|
+
serializeFilteredOptions(this.tsgId, opts)
|
|
18055
18082
|
);
|
|
18056
18083
|
}
|
|
18057
18084
|
/**
|
|
18058
18085
|
* Token usage, split into request and response units.
|
|
18059
|
-
* @param opts - Workspace slug, time window and
|
|
18086
|
+
* @param opts - Workspace slug, time window and verified trace, metadata, list and range filters.
|
|
18060
18087
|
* @returns Token series plus request/response unit totals.
|
|
18061
18088
|
* @example
|
|
18062
18089
|
* ```ts
|
|
@@ -18072,7 +18099,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
18072
18099
|
"tokens",
|
|
18073
18100
|
opts,
|
|
18074
18101
|
TokensChartResponseSchema,
|
|
18075
|
-
|
|
18102
|
+
serializeFilteredOptions(this.tsgId, opts)
|
|
18076
18103
|
);
|
|
18077
18104
|
}
|
|
18078
18105
|
/**
|
|
@@ -18256,7 +18283,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
18256
18283
|
/**
|
|
18257
18284
|
* Aggregate requests by a dimension.
|
|
18258
18285
|
* @param dimension - One of {@link AI_GW_GROUP_DIMENSIONS}. Underscore names only.
|
|
18259
|
-
* @param opts - Window
|
|
18286
|
+
* @param opts - Window, verified trace/metadata/list/range filters, and optional extra columns.
|
|
18260
18287
|
* @returns One row per distinct dimension value.
|
|
18261
18288
|
* @example
|
|
18262
18289
|
* ```ts
|
|
@@ -18276,8 +18303,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
18276
18303
|
"Invalid telemetry grouping dimension",
|
|
18277
18304
|
"AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
|
|
18278
18305
|
);
|
|
18279
|
-
const params =
|
|
18280
|
-
if (opts.columns?.length) params.columns = opts.columns.join(",");
|
|
18306
|
+
const params = serializeFilteredOptions(this.tsgId, opts, groupOptionsSchema);
|
|
18281
18307
|
return request({
|
|
18282
18308
|
method: "GET",
|
|
18283
18309
|
baseUrl: this.baseUrl,
|
|
@@ -18290,7 +18316,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
18290
18316
|
}
|
|
18291
18317
|
/**
|
|
18292
18318
|
* Requests and cost per end user.
|
|
18293
|
-
* @param opts - Workspace slug and
|
|
18319
|
+
* @param opts - Workspace slug, time window and verified trace/metadata/list/range filters.
|
|
18294
18320
|
* @returns One record per user; `_user: ''` means calls with no end-user id. Costs in cents.
|
|
18295
18321
|
* @example
|
|
18296
18322
|
* ```ts
|
|
@@ -18306,7 +18332,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
18306
18332
|
method: "GET",
|
|
18307
18333
|
baseUrl: this.baseUrl,
|
|
18308
18334
|
path: `${AI_GW_GROUPS_PATH}/users`,
|
|
18309
|
-
params:
|
|
18335
|
+
params: serializeFilteredOptions(this.tsgId, opts),
|
|
18310
18336
|
responseSchema: UserGroupResponseSchema,
|
|
18311
18337
|
auth: this.auth,
|
|
18312
18338
|
numRetries: this.numRetries
|
|
@@ -18314,7 +18340,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
18314
18340
|
}
|
|
18315
18341
|
/**
|
|
18316
18342
|
* Requests grouped by HTTP status code.
|
|
18317
|
-
* @param opts - Window
|
|
18343
|
+
* @param opts - Window, verified trace/metadata/list/range filters, and optional extra columns.
|
|
18318
18344
|
* @returns One row per status. **446 = AIRS security block** (cost 0, never reached the LLM).
|
|
18319
18345
|
* @example
|
|
18320
18346
|
* ```ts
|
|
@@ -18329,8 +18355,7 @@ var AIGatewayTelemetryClient = class {
|
|
|
18329
18355
|
* ```
|
|
18330
18356
|
*/
|
|
18331
18357
|
async byStatusCode(opts) {
|
|
18332
|
-
const params =
|
|
18333
|
-
if (opts.columns?.length) params.columns = opts.columns.join(",");
|
|
18358
|
+
const params = serializeFilteredOptions(this.tsgId, opts, groupOptionsSchema);
|
|
18334
18359
|
return request({
|
|
18335
18360
|
method: "GET",
|
|
18336
18361
|
baseUrl: this.baseUrl,
|
|
@@ -18365,10 +18390,14 @@ var AIGatewayTelemetryClient = class {
|
|
|
18365
18390
|
* ```
|
|
18366
18391
|
*/
|
|
18367
18392
|
async logs(opts) {
|
|
18368
|
-
const params =
|
|
18369
|
-
|
|
18370
|
-
|
|
18371
|
-
|
|
18393
|
+
const { params, options: validated } = serializeWindowWithOptions(
|
|
18394
|
+
this.tsgId,
|
|
18395
|
+
opts,
|
|
18396
|
+
logsOptionsSchema
|
|
18397
|
+
);
|
|
18398
|
+
if (validated.pageSize !== void 0) params.pageSize = String(validated.pageSize);
|
|
18399
|
+
if (validated.traceId !== void 0) params.traceId = validated.traceId;
|
|
18400
|
+
if (validated.statusCode !== void 0) params.statusCode = String(validated.statusCode);
|
|
18372
18401
|
return request({
|
|
18373
18402
|
method: "GET",
|
|
18374
18403
|
baseUrl: this.baseUrl,
|
|
@@ -22627,6 +22656,7 @@ function setDottedValue(input, path, value2) {
|
|
|
22627
22656
|
0 && (module.exports = {
|
|
22628
22657
|
AIGatewayApiKeysClient,
|
|
22629
22658
|
AIGatewayAuditLogsClient,
|
|
22659
|
+
AIGatewayChartFiltersSchema,
|
|
22630
22660
|
AIGatewayClient,
|
|
22631
22661
|
AIGatewayConfigsClient,
|
|
22632
22662
|
AIGatewayDeploymentsClient,
|