@polar-sh/sdk 0.40.0 → 0.40.2

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 (62) hide show
  1. package/dist/commonjs/lib/config.d.ts +2 -2
  2. package/dist/commonjs/lib/config.js +2 -2
  3. package/dist/commonjs/models/components/costmetadatainput.d.ts +61 -0
  4. package/dist/commonjs/models/components/costmetadatainput.d.ts.map +1 -0
  5. package/dist/commonjs/models/components/costmetadatainput.js +95 -0
  6. package/dist/commonjs/models/components/costmetadatainput.js.map +1 -0
  7. package/dist/commonjs/models/components/costmetadataoutput.d.ts +37 -0
  8. package/dist/commonjs/models/components/costmetadataoutput.d.ts.map +1 -0
  9. package/dist/commonjs/models/components/costmetadataoutput.js +71 -0
  10. package/dist/commonjs/models/components/costmetadataoutput.js.map +1 -0
  11. package/dist/commonjs/models/components/eventmetadatainput.d.ts +4 -23
  12. package/dist/commonjs/models/components/eventmetadatainput.d.ts.map +1 -1
  13. package/dist/commonjs/models/components/eventmetadatainput.js +7 -26
  14. package/dist/commonjs/models/components/eventmetadatainput.js.map +1 -1
  15. package/dist/commonjs/models/components/eventmetadataoutput.d.ts +4 -23
  16. package/dist/commonjs/models/components/eventmetadataoutput.d.ts.map +1 -1
  17. package/dist/commonjs/models/components/eventmetadataoutput.js +7 -27
  18. package/dist/commonjs/models/components/eventmetadataoutput.js.map +1 -1
  19. package/dist/commonjs/models/components/llmmetadata.d.ts +67 -0
  20. package/dist/commonjs/models/components/llmmetadata.d.ts.map +1 -0
  21. package/dist/commonjs/models/components/llmmetadata.js +98 -0
  22. package/dist/commonjs/models/components/llmmetadata.js.map +1 -0
  23. package/dist/commonjs/webhooks.d.ts +1 -1
  24. package/dist/commonjs/webhooks.d.ts.map +1 -1
  25. package/dist/commonjs/webhooks.js +9 -0
  26. package/dist/commonjs/webhooks.js.map +1 -1
  27. package/dist/esm/lib/config.d.ts +2 -2
  28. package/dist/esm/lib/config.js +2 -2
  29. package/dist/esm/models/components/costmetadatainput.d.ts +61 -0
  30. package/dist/esm/models/components/costmetadatainput.d.ts.map +1 -0
  31. package/dist/esm/models/components/costmetadatainput.js +55 -0
  32. package/dist/esm/models/components/costmetadatainput.js.map +1 -0
  33. package/dist/esm/models/components/costmetadataoutput.d.ts +37 -0
  34. package/dist/esm/models/components/costmetadataoutput.d.ts.map +1 -0
  35. package/dist/esm/models/components/costmetadataoutput.js +33 -0
  36. package/dist/esm/models/components/costmetadataoutput.js.map +1 -0
  37. package/dist/esm/models/components/eventmetadatainput.d.ts +4 -23
  38. package/dist/esm/models/components/eventmetadatainput.d.ts.map +1 -1
  39. package/dist/esm/models/components/eventmetadatainput.js +6 -23
  40. package/dist/esm/models/components/eventmetadatainput.js.map +1 -1
  41. package/dist/esm/models/components/eventmetadataoutput.d.ts +4 -23
  42. package/dist/esm/models/components/eventmetadataoutput.d.ts.map +1 -1
  43. package/dist/esm/models/components/eventmetadataoutput.js +6 -24
  44. package/dist/esm/models/components/eventmetadataoutput.js.map +1 -1
  45. package/dist/esm/models/components/llmmetadata.d.ts +67 -0
  46. package/dist/esm/models/components/llmmetadata.d.ts.map +1 -0
  47. package/dist/esm/models/components/llmmetadata.js +60 -0
  48. package/dist/esm/models/components/llmmetadata.js.map +1 -0
  49. package/dist/esm/webhooks.d.ts +1 -1
  50. package/dist/esm/webhooks.d.ts.map +1 -1
  51. package/dist/esm/webhooks.js +9 -0
  52. package/dist/esm/webhooks.js.map +1 -1
  53. package/examples/package-lock.json +1 -1
  54. package/jsr.json +1 -1
  55. package/package.json +1 -1
  56. package/src/lib/config.ts +2 -2
  57. package/src/models/components/costmetadatainput.ts +122 -0
  58. package/src/models/components/costmetadataoutput.ts +76 -0
  59. package/src/models/components/eventmetadatainput.ts +22 -56
  60. package/src/models/components/eventmetadataoutput.ts +26 -45
  61. package/src/models/components/llmmetadata.ts +129 -0
  62. package/src/webhooks.ts +9 -0
@@ -6,48 +6,26 @@ import * as z from "zod/v3";
6
6
  import { safeParse } from "../../lib/schemas.js";
7
7
  import { Result as SafeParseResult } from "../../types/fp.js";
8
8
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
9
+ import {
10
+ CostMetadataOutput,
11
+ CostMetadataOutput$inboundSchema,
12
+ CostMetadataOutput$Outbound,
13
+ CostMetadataOutput$outboundSchema,
14
+ } from "./costmetadataoutput.js";
15
+ import {
16
+ LLMMetadata,
17
+ LLMMetadata$inboundSchema,
18
+ LLMMetadata$Outbound,
19
+ LLMMetadata$outboundSchema,
20
+ } from "./llmmetadata.js";
9
21
 
10
- export type Five = {};
11
-
12
- export type EventMetadataOutput = string | number | number | boolean | Five;
13
-
14
- /** @internal */
15
- export const Five$inboundSchema: z.ZodType<Five, z.ZodTypeDef, unknown> = z
16
- .object({});
17
-
18
- /** @internal */
19
- export type Five$Outbound = {};
20
-
21
- /** @internal */
22
- export const Five$outboundSchema: z.ZodType<Five$Outbound, z.ZodTypeDef, Five> =
23
- z.object({});
24
-
25
- /**
26
- * @internal
27
- * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
28
- */
29
- export namespace Five$ {
30
- /** @deprecated use `Five$inboundSchema` instead. */
31
- export const inboundSchema = Five$inboundSchema;
32
- /** @deprecated use `Five$outboundSchema` instead. */
33
- export const outboundSchema = Five$outboundSchema;
34
- /** @deprecated use `Five$Outbound` instead. */
35
- export type Outbound = Five$Outbound;
36
- }
37
-
38
- export function fiveToJSON(five: Five): string {
39
- return JSON.stringify(Five$outboundSchema.parse(five));
40
- }
41
-
42
- export function fiveFromJSON(
43
- jsonString: string,
44
- ): SafeParseResult<Five, SDKValidationError> {
45
- return safeParse(
46
- jsonString,
47
- (x) => Five$inboundSchema.parse(JSON.parse(x)),
48
- `Failed to parse 'Five' from JSON`,
49
- );
50
- }
22
+ export type EventMetadataOutput =
23
+ | LLMMetadata
24
+ | CostMetadataOutput
25
+ | string
26
+ | number
27
+ | number
28
+ | boolean;
51
29
 
52
30
  /** @internal */
53
31
  export const EventMetadataOutput$inboundSchema: z.ZodType<
@@ -55,20 +33,22 @@ export const EventMetadataOutput$inboundSchema: z.ZodType<
55
33
  z.ZodTypeDef,
56
34
  unknown
57
35
  > = z.union([
36
+ LLMMetadata$inboundSchema,
37
+ CostMetadataOutput$inboundSchema,
58
38
  z.string(),
59
39
  z.number().int(),
60
40
  z.number(),
61
41
  z.boolean(),
62
- z.lazy(() => Five$inboundSchema),
63
42
  ]);
64
43
 
65
44
  /** @internal */
66
45
  export type EventMetadataOutput$Outbound =
46
+ | LLMMetadata$Outbound
47
+ | CostMetadataOutput$Outbound
67
48
  | string
68
49
  | number
69
50
  | number
70
- | boolean
71
- | Five$Outbound;
51
+ | boolean;
72
52
 
73
53
  /** @internal */
74
54
  export const EventMetadataOutput$outboundSchema: z.ZodType<
@@ -76,11 +56,12 @@ export const EventMetadataOutput$outboundSchema: z.ZodType<
76
56
  z.ZodTypeDef,
77
57
  EventMetadataOutput
78
58
  > = z.union([
59
+ LLMMetadata$outboundSchema,
60
+ CostMetadataOutput$outboundSchema,
79
61
  z.string(),
80
62
  z.number().int(),
81
63
  z.number(),
82
64
  z.boolean(),
83
- z.lazy(() => Five$outboundSchema),
84
65
  ]);
85
66
 
86
67
  /**
@@ -0,0 +1,129 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
+
11
+ export type LLMMetadata = {
12
+ /**
13
+ * The vendor of the event.
14
+ */
15
+ vendor: string;
16
+ /**
17
+ * The model used for the event.
18
+ */
19
+ model: string;
20
+ /**
21
+ * The LLM prompt used for the event.
22
+ */
23
+ prompt?: string | null | undefined;
24
+ /**
25
+ * The LLM response used for the event.
26
+ */
27
+ response?: string | null | undefined;
28
+ /**
29
+ * The number of LLM input tokens used for the event.
30
+ */
31
+ inputTokens: number;
32
+ /**
33
+ * The number of LLM cached tokens that were used for the event.
34
+ */
35
+ cachedInputTokens?: number | undefined;
36
+ /**
37
+ * The number of LLM output tokens used for the event.
38
+ */
39
+ outputTokens: number;
40
+ /**
41
+ * The total number of LLM tokens used for the event.
42
+ */
43
+ totalTokens: number;
44
+ };
45
+
46
+ /** @internal */
47
+ export const LLMMetadata$inboundSchema: z.ZodType<
48
+ LLMMetadata,
49
+ z.ZodTypeDef,
50
+ unknown
51
+ > = z.object({
52
+ vendor: z.string(),
53
+ model: z.string(),
54
+ prompt: z.nullable(z.string()).optional(),
55
+ response: z.nullable(z.string()).optional(),
56
+ input_tokens: z.number().int(),
57
+ cached_input_tokens: z.number().int().optional(),
58
+ output_tokens: z.number().int(),
59
+ total_tokens: z.number().int(),
60
+ }).transform((v) => {
61
+ return remap$(v, {
62
+ "input_tokens": "inputTokens",
63
+ "cached_input_tokens": "cachedInputTokens",
64
+ "output_tokens": "outputTokens",
65
+ "total_tokens": "totalTokens",
66
+ });
67
+ });
68
+
69
+ /** @internal */
70
+ export type LLMMetadata$Outbound = {
71
+ vendor: string;
72
+ model: string;
73
+ prompt?: string | null | undefined;
74
+ response?: string | null | undefined;
75
+ input_tokens: number;
76
+ cached_input_tokens?: number | undefined;
77
+ output_tokens: number;
78
+ total_tokens: number;
79
+ };
80
+
81
+ /** @internal */
82
+ export const LLMMetadata$outboundSchema: z.ZodType<
83
+ LLMMetadata$Outbound,
84
+ z.ZodTypeDef,
85
+ LLMMetadata
86
+ > = z.object({
87
+ vendor: z.string(),
88
+ model: z.string(),
89
+ prompt: z.nullable(z.string()).optional(),
90
+ response: z.nullable(z.string()).optional(),
91
+ inputTokens: z.number().int(),
92
+ cachedInputTokens: z.number().int().optional(),
93
+ outputTokens: z.number().int(),
94
+ totalTokens: z.number().int(),
95
+ }).transform((v) => {
96
+ return remap$(v, {
97
+ inputTokens: "input_tokens",
98
+ cachedInputTokens: "cached_input_tokens",
99
+ outputTokens: "output_tokens",
100
+ totalTokens: "total_tokens",
101
+ });
102
+ });
103
+
104
+ /**
105
+ * @internal
106
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
107
+ */
108
+ export namespace LLMMetadata$ {
109
+ /** @deprecated use `LLMMetadata$inboundSchema` instead. */
110
+ export const inboundSchema = LLMMetadata$inboundSchema;
111
+ /** @deprecated use `LLMMetadata$outboundSchema` instead. */
112
+ export const outboundSchema = LLMMetadata$outboundSchema;
113
+ /** @deprecated use `LLMMetadata$Outbound` instead. */
114
+ export type Outbound = LLMMetadata$Outbound;
115
+ }
116
+
117
+ export function llmMetadataToJSON(llmMetadata: LLMMetadata): string {
118
+ return JSON.stringify(LLMMetadata$outboundSchema.parse(llmMetadata));
119
+ }
120
+
121
+ export function llmMetadataFromJSON(
122
+ jsonString: string,
123
+ ): SafeParseResult<LLMMetadata, SDKValidationError> {
124
+ return safeParse(
125
+ jsonString,
126
+ (x) => LLMMetadata$inboundSchema.parse(JSON.parse(x)),
127
+ `Failed to parse 'LLMMetadata' from JSON`,
128
+ );
129
+ }
package/src/webhooks.ts CHANGED
@@ -30,6 +30,9 @@ import { WebhookCustomerCreatedPayload$inboundSchema } from "./models/components
30
30
  import { WebhookCustomerUpdatedPayload$inboundSchema } from "./models/components/webhookcustomerupdatedpayload.js";
31
31
  import { WebhookCustomerDeletedPayload$inboundSchema } from "./models/components/webhookcustomerdeletedpayload.js";
32
32
  import { WebhookCustomerStateChangedPayload$inboundSchema } from "./models/components/webhookcustomerstatechangedpayload.js";
33
+ import { WebhookCustomerSeatAssignedPayload$inboundSchema } from "./models/components/webhookcustomerseatassignedpayload.js";
34
+ import { WebhookCustomerSeatClaimedPayload$inboundSchema } from "./models/components/webhookcustomerseatclaimedpayload.js";
35
+ import { WebhookCustomerSeatRevokedPayload$inboundSchema } from "./models/components/webhookcustomerseatrevokedpayload.js";
33
36
  import { SDKValidationError } from "./models/errors/sdkvalidationerror.js";
34
37
 
35
38
  class WebhookVerificationError extends Error {
@@ -50,6 +53,12 @@ const parseEvent = (parsed: any) => {
50
53
  return WebhookCustomerDeletedPayload$inboundSchema.parse(parsed);
51
54
  case "customer.state_changed":
52
55
  return WebhookCustomerStateChangedPayload$inboundSchema.parse(parsed);
56
+ case "customer_seat.assigned":
57
+ return WebhookCustomerSeatAssignedPayload$inboundSchema.parse(parsed);
58
+ case "customer_seat.claimed":
59
+ return WebhookCustomerSeatClaimedPayload$inboundSchema.parse(parsed);
60
+ case "customer_seat.revoked":
61
+ return WebhookCustomerSeatRevokedPayload$inboundSchema.parse(parsed);
53
62
  case "benefit.created":
54
63
  return WebhookBenefitCreatedPayload$inboundSchema.parse(parsed);
55
64
  case "benefit_grant.created":