@cdot65/prisma-airs-sdk 0.24.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 CHANGED
@@ -101,7 +101,7 @@ 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 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. 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).
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
105
 
106
106
  All AI Gateway write bodies have exported Zod schemas and inferred TypeScript types. Validation
107
107
  happens before OAuth and network access; documented nonempty-update requirements are enforced. The package also
package/dist/index.cjs CHANGED
@@ -1358,7 +1358,7 @@ var MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 20;
1358
1358
  var MAX_CONNECTION_POOL_SIZE = 100;
1359
1359
  var MAX_NUMBER_OF_RETRIES = 5;
1360
1360
  var HTTP_FORCE_RETRY_STATUS_CODES = [500, 502, 503, 504];
1361
- var SDK_VERSION = "0.24.0";
1361
+ var SDK_VERSION = "0.25.0";
1362
1362
  var USER_AGENT = `PAN-AIRS/${SDK_VERSION}-typescript-sdk`;
1363
1363
  var DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
1364
1364
  var DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
@@ -17935,24 +17935,27 @@ function toOffsetIso(d) {
17935
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)}`;
17936
17936
  }
17937
17937
  function serializeWindow(tsgId, opts, schema = telemetryWindowSchema) {
17938
+ return serializeWindowWithOptions(tsgId, opts, schema).params;
17939
+ }
17940
+ function serializeWindowWithOptions(tsgId, opts, schema) {
17938
17941
  const result = schema.safeParse(opts);
17939
17942
  if (!result.success || typeof tsgId !== "string" || !/^\d+$/.test(tsgId)) invalidWindow();
17940
17943
  const end = result.data.end ?? /* @__PURE__ */ new Date();
17941
17944
  const start = result.data.start ?? new Date(end.getTime() - (result.data.days ?? 7) * 864e5);
17942
17945
  if (start.getTime() > end.getTime()) invalidWindow();
17943
17946
  return {
17944
- organisationId: tsgId,
17945
- workspaceSlug: result.data.workspaceSlug,
17946
- timeOfGenerationMin: toOffsetIso(start),
17947
- timeOfGenerationMax: toOffsetIso(end)
17947
+ options: result.data,
17948
+ params: {
17949
+ organisationId: tsgId,
17950
+ workspaceSlug: result.data.workspaceSlug,
17951
+ timeOfGenerationMin: toOffsetIso(start),
17952
+ timeOfGenerationMax: toOffsetIso(end)
17953
+ }
17948
17954
  };
17949
17955
  }
17950
17956
 
17951
17957
  // src/ai-gateway/telemetry-client.ts
17952
17958
  var nonBlankString = import_zod54.z.string().min(1).refine((value2) => value2.trim().length > 0);
17953
- var groupOptionsSchema = telemetryWindowSchema.extend({
17954
- columns: import_zod54.z.array(import_zod54.z.enum(AI_GW_GROUP_COLUMNS)).optional()
17955
- }).strict();
17956
17959
  var logsOptionsSchema = telemetryWindowSchema.extend({
17957
17960
  pageSize: import_zod54.z.number().int().nonnegative().safe().optional(),
17958
17961
  traceId: nonBlankString.optional(),
@@ -17974,8 +17977,12 @@ function validChartBounds(opts) {
17974
17977
  }
17975
17978
  var AIGatewayChartFiltersSchema = import_zod54.z.object(chartFilterFields).strict().refine(validChartBounds);
17976
17979
  var filteredChartOptionsSchema = telemetryWindowSchema.extend(chartFilterFields).strict().refine(validChartBounds);
17977
- function serializeChartOptions(tsgId, opts) {
17978
- const params = serializeWindow(tsgId, opts, filteredChartOptionsSchema);
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);
17979
17986
  if (opts.traceId !== void 0) params.traceId = opts.traceId;
17980
17987
  if (opts.metadata !== void 0) params.metadata = JSON.stringify(opts.metadata);
17981
17988
  if (opts.statusCodes !== void 0) params.statusCode = opts.statusCodes.join(",");
@@ -17984,6 +17991,7 @@ function serializeChartOptions(tsgId, opts) {
17984
17991
  for (const key of ["totalUnitsMin", "totalUnitsMax", "costMin", "costMax"]) {
17985
17992
  if (opts[key] !== void 0) params[key] = String(opts[key]);
17986
17993
  }
17994
+ if (opts.columns?.length) params.columns = opts.columns.join(",");
17987
17995
  return params;
17988
17996
  }
17989
17997
  var AIGatewayTelemetryClient = class {
@@ -18027,7 +18035,7 @@ var AIGatewayTelemetryClient = class {
18027
18035
  "cost",
18028
18036
  opts,
18029
18037
  CostChartResponseSchema,
18030
- serializeChartOptions(this.tsgId, opts)
18038
+ serializeFilteredOptions(this.tsgId, opts)
18031
18039
  );
18032
18040
  }
18033
18041
  /**
@@ -18048,7 +18056,7 @@ var AIGatewayTelemetryClient = class {
18048
18056
  "requests",
18049
18057
  opts,
18050
18058
  CountChartResponseSchema,
18051
- serializeChartOptions(this.tsgId, opts)
18059
+ serializeFilteredOptions(this.tsgId, opts)
18052
18060
  );
18053
18061
  }
18054
18062
  /**
@@ -18070,7 +18078,7 @@ var AIGatewayTelemetryClient = class {
18070
18078
  "latency",
18071
18079
  opts,
18072
18080
  LatencyChartResponseSchema,
18073
- serializeChartOptions(this.tsgId, opts)
18081
+ serializeFilteredOptions(this.tsgId, opts)
18074
18082
  );
18075
18083
  }
18076
18084
  /**
@@ -18091,7 +18099,7 @@ var AIGatewayTelemetryClient = class {
18091
18099
  "tokens",
18092
18100
  opts,
18093
18101
  TokensChartResponseSchema,
18094
- serializeChartOptions(this.tsgId, opts)
18102
+ serializeFilteredOptions(this.tsgId, opts)
18095
18103
  );
18096
18104
  }
18097
18105
  /**
@@ -18275,7 +18283,7 @@ var AIGatewayTelemetryClient = class {
18275
18283
  /**
18276
18284
  * Aggregate requests by a dimension.
18277
18285
  * @param dimension - One of {@link AI_GW_GROUP_DIMENSIONS}. Underscore names only.
18278
- * @param opts - Window plus optional extra columns.
18286
+ * @param opts - Window, verified trace/metadata/list/range filters, and optional extra columns.
18279
18287
  * @returns One row per distinct dimension value.
18280
18288
  * @example
18281
18289
  * ```ts
@@ -18295,8 +18303,7 @@ var AIGatewayTelemetryClient = class {
18295
18303
  "Invalid telemetry grouping dimension",
18296
18304
  "AISEC_USER_REQUEST_PAYLOAD_ERROR" /* USER_REQUEST_PAYLOAD_ERROR */
18297
18305
  );
18298
- const params = serializeWindow(this.tsgId, opts, groupOptionsSchema);
18299
- if (opts.columns?.length) params.columns = opts.columns.join(",");
18306
+ const params = serializeFilteredOptions(this.tsgId, opts, groupOptionsSchema);
18300
18307
  return request({
18301
18308
  method: "GET",
18302
18309
  baseUrl: this.baseUrl,
@@ -18309,7 +18316,7 @@ var AIGatewayTelemetryClient = class {
18309
18316
  }
18310
18317
  /**
18311
18318
  * Requests and cost per end user.
18312
- * @param opts - Workspace slug and time window.
18319
+ * @param opts - Workspace slug, time window and verified trace/metadata/list/range filters.
18313
18320
  * @returns One record per user; `_user: ''` means calls with no end-user id. Costs in cents.
18314
18321
  * @example
18315
18322
  * ```ts
@@ -18325,7 +18332,7 @@ var AIGatewayTelemetryClient = class {
18325
18332
  method: "GET",
18326
18333
  baseUrl: this.baseUrl,
18327
18334
  path: `${AI_GW_GROUPS_PATH}/users`,
18328
- params: serializeWindow(this.tsgId, opts),
18335
+ params: serializeFilteredOptions(this.tsgId, opts),
18329
18336
  responseSchema: UserGroupResponseSchema,
18330
18337
  auth: this.auth,
18331
18338
  numRetries: this.numRetries
@@ -18333,7 +18340,7 @@ var AIGatewayTelemetryClient = class {
18333
18340
  }
18334
18341
  /**
18335
18342
  * Requests grouped by HTTP status code.
18336
- * @param opts - Window plus optional extra columns.
18343
+ * @param opts - Window, verified trace/metadata/list/range filters, and optional extra columns.
18337
18344
  * @returns One row per status. **446 = AIRS security block** (cost 0, never reached the LLM).
18338
18345
  * @example
18339
18346
  * ```ts
@@ -18348,8 +18355,7 @@ var AIGatewayTelemetryClient = class {
18348
18355
  * ```
18349
18356
  */
18350
18357
  async byStatusCode(opts) {
18351
- const params = serializeWindow(this.tsgId, opts, groupOptionsSchema);
18352
- if (opts.columns?.length) params.columns = opts.columns.join(",");
18358
+ const params = serializeFilteredOptions(this.tsgId, opts, groupOptionsSchema);
18353
18359
  return request({
18354
18360
  method: "GET",
18355
18361
  baseUrl: this.baseUrl,
@@ -18384,10 +18390,14 @@ var AIGatewayTelemetryClient = class {
18384
18390
  * ```
18385
18391
  */
18386
18392
  async logs(opts) {
18387
- const params = serializeWindow(this.tsgId, opts, logsOptionsSchema);
18388
- if (opts.pageSize !== void 0) params.pageSize = String(opts.pageSize);
18389
- if (opts.traceId !== void 0) params.traceId = opts.traceId;
18390
- if (opts.statusCode !== void 0) params.statusCode = String(opts.statusCode);
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);
18391
18401
  return request({
18392
18402
  method: "GET",
18393
18403
  baseUrl: this.baseUrl,