@blazingagents/sdk 0.56.0 → 0.56.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.
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { calendarDateSchema } from "../utils.js";
2
3
  export const spendingLimitResetIntervalSchema = z.enum([
3
4
  "daily",
4
5
  "weekly",
@@ -8,7 +9,7 @@ export const spendingLimitResetIntervalSchema = z.enum([
8
9
  export const spendingLimitSchema = z
9
10
  .object({
10
11
  amountUsd: z.number().positive().max(1_000_000_000).multipleOf(0.000_001),
11
- resetStartDate: z.iso.date(),
12
+ resetStartDate: calendarDateSchema,
12
13
  resetInterval: spendingLimitResetIntervalSchema,
13
14
  })
14
15
  .strict()
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { agentIdSchema, sessionIdSchema } from "../ids.js";
3
3
  import { DEFAULT_USAGE_OVERVIEW_TOP_N, DEFAULT_USAGE_RANGE_DAYS, MAX_USAGE_OVERVIEW_TOP_N, MAX_USAGE_RANGE_DAYS, } from "../limitations.js";
4
- import { hasUniqueValues } from "../utils.js";
4
+ import { calendarDateSchema, hasUniqueValues } from "../utils.js";
5
5
  import { userIdSchema } from "./attribution.js";
6
6
  /**
7
7
  * Adds a validation issue when the usage date range is invalid.
@@ -35,12 +35,10 @@ function validateUsageRange(value, ctx) {
35
35
  }
36
36
  }
37
37
  const usageRangeFields = {
38
- from: z.iso
39
- .date()
38
+ from: calendarDateSchema
40
39
  .optional()
41
40
  .describe("First UTC day to include, as `YYYY-MM-DD`. Send it with `to`, or leave both out for the last 30 days ending today."),
42
- to: z.iso
43
- .date()
41
+ to: calendarDateSchema
44
42
  .optional()
45
43
  .describe(`Last UTC day to include, as \`YYYY-MM-DD\`. It must not be before \`from\` and can be at most ${MAX_USAGE_RANGE_DAYS} days after it.`),
46
44
  };
@@ -35,3 +35,4 @@ export { sessionUsageQuerySchema, sessionUsageResponseSchema, usageOverviewQuery
35
35
  export type { WorkspaceTier } from "./entities/workspaces.ts";
36
36
  export { createWorkspaceBodySchema, updateWorkspaceBodySchema, workspaceNetworkPolicySchema, workspaceSchema, workspacesListResponseSchema, workspaceTierSchema, } from "./entities/workspaces.ts";
37
37
  export { agentIdSchema, apiKeyTokenSchema, functionCallIdSchema, isAdminAgentId, merchantUsageEventIdSchema, promptIdSchema, sessionIdSchema, } from "./ids.ts";
38
+ export { calendarDateSchema } from "./utils.ts";
@@ -23,3 +23,4 @@ export { tenantDeletionSchema, tenantSettingsResponseSchema, updateTenantSetting
23
23
  export { sessionUsageQuerySchema, sessionUsageResponseSchema, usageOverviewQuerySchema, usageOverviewResponseSchema, usageResponseSchema, } from "./entities/usage.js";
24
24
  export { createWorkspaceBodySchema, updateWorkspaceBodySchema, workspaceNetworkPolicySchema, workspaceSchema, workspacesListResponseSchema, workspaceTierSchema, } from "./entities/workspaces.js";
25
25
  export { agentIdSchema, apiKeyTokenSchema, functionCallIdSchema, isAdminAgentId, merchantUsageEventIdSchema, promptIdSchema, sessionIdSchema, } from "./ids.js";
26
+ export { calendarDateSchema } from "./utils.js";
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  export declare const atLeastOneFieldMessage = "At least one field must be provided.";
2
3
  /**
3
4
  * Checks whether the object has at least one own enumerable key.
@@ -11,3 +12,9 @@ export declare function hasObjectKeys(value: object): boolean;
11
12
  * @returns Whether no string occurs more than once.
12
13
  */
13
14
  export declare function hasUniqueValues(values: string[]): boolean;
15
+ /**
16
+ * A `YYYY-MM-DD` date that PostgreSQL's `date` holds. `z.iso.date()` accepts
17
+ * `0000-01-01`, but PostgreSQL has no year 0 and refuses the cast, so a route
18
+ * that passes the date on would answer 500 instead of `validation_failed`.
19
+ */
20
+ export declare const calendarDateSchema: z.ZodISODate;
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  export const atLeastOneFieldMessage = "At least one field must be provided.";
2
3
  /**
3
4
  * Checks whether the object has at least one own enumerable key.
@@ -15,3 +16,13 @@ export function hasObjectKeys(value) {
15
16
  export function hasUniqueValues(values) {
16
17
  return new Set(values).size === values.length;
17
18
  }
19
+ /**
20
+ * A `YYYY-MM-DD` date that PostgreSQL's `date` holds. `z.iso.date()` accepts
21
+ * `0000-01-01`, but PostgreSQL has no year 0 and refuses the cast, so a route
22
+ * that passes the date on would answer 500 instead of `validation_failed`.
23
+ */
24
+ export const calendarDateSchema = z.iso
25
+ .date()
26
+ .refine((date) => !date.startsWith("0000-"), {
27
+ message: "Year 0000 does not exist.",
28
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazingagents/sdk",
3
- "version": "0.56.0",
3
+ "version": "0.56.1",
4
4
  "description": "TypeScript SDK for the Blazing Agents API",
5
5
  "homepage": "https://docs.blazingagents.com",
6
6
  "bugs": {